Skip to content

Commit f91c15e

Browse files
jnikuladanvet
authored andcommitted
drm/i915: use the initialized backlight max value instead of reading it
We now have the max backlight value cached. Use it. Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Imre Deak <imre.deak@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent 3bd712e commit f91c15e

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

‎drivers/gpu/drm/i915/intel_panel.c‎

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,6 @@ static u32 vlv_get_max_backlight(struct intel_connector *connector)
436436
return _vlv_get_max_backlight(dev, pipe);
437437
}
438438

439-
/* XXX: query mode clock or hardware clock and program max PWM appropriately
440-
* when it's 0.
441-
*/
442439
static u32 intel_panel_get_max_backlight(struct intel_connector *connector)
443440
{
444441
struct drm_device *dev = connector->base.dev;
@@ -466,15 +463,16 @@ static u32 intel_panel_compute_brightness(struct intel_connector *connector,
466463
{
467464
struct drm_device *dev = connector->base.dev;
468465
struct drm_i915_private *dev_priv = dev->dev_private;
466+
struct intel_panel *panel = &connector->panel;
467+
468+
WARN_ON(panel->backlight.max == 0);
469469

470470
if (i915_panel_invert_brightness < 0)
471471
return val;
472472

473473
if (i915_panel_invert_brightness > 0 ||
474474
dev_priv->quirks & QUIRK_INVERT_BRIGHTNESS) {
475-
u32 max = intel_panel_get_max_backlight(connector);
476-
if (max)
477-
return max - val;
475+
return panel->backlight.max - val;
478476
}
479477

480478
return val;
@@ -555,17 +553,15 @@ static void i9xx_set_backlight(struct intel_connector *connector, u32 level)
555553
{
556554
struct drm_device *dev = connector->base.dev;
557555
struct drm_i915_private *dev_priv = dev->dev_private;
556+
struct intel_panel *panel = &connector->panel;
558557
u32 tmp, mask;
559558

559+
WARN_ON(panel->backlight.max == 0);
560+
560561
if (is_backlight_combination_mode(dev)) {
561-
u32 max = intel_panel_get_max_backlight(connector);
562562
u8 lbpc;
563563

564-
/* we're screwed, but keep behaviour backwards compatible */
565-
if (!max)
566-
max = 1;
567-
568-
lbpc = level * 0xfe / max + 1;
564+
lbpc = level * 0xfe / panel->backlight.max + 1;
569565
level /= lbpc;
570566
pci_write_config_byte(dev->pdev, PCI_LBPC, lbpc);
571567
}
@@ -620,13 +616,10 @@ void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
620616

621617
spin_lock_irqsave(&dev_priv->backlight_lock, flags);
622618

623-
freq = intel_panel_get_max_backlight(connector);
624-
if (!freq) {
625-
/* we are screwed, bail out */
626-
goto out;
627-
}
619+
WARN_ON(panel->backlight.max == 0);
628620

629-
/* scale to hardware, but be careful to not overflow */
621+
/* scale to hardware max, but be careful to not overflow */
622+
freq = panel->backlight.max;
630623
if (freq < max)
631624
level = level * freq / max;
632625
else
@@ -638,7 +631,7 @@ void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
638631

639632
if (panel->backlight.enabled)
640633
intel_panel_actually_set_backlight(connector, level);
641-
out:
634+
642635
spin_unlock_irqrestore(&dev_priv->backlight_lock, flags);
643636
}
644637

@@ -839,8 +832,13 @@ void intel_panel_enable_backlight(struct intel_connector *connector)
839832

840833
spin_lock_irqsave(&dev_priv->backlight_lock, flags);
841834

835+
/* XXX: transitional, call to make sure freq is set */
836+
intel_panel_get_max_backlight(connector);
837+
838+
WARN_ON(panel->backlight.max == 0);
839+
842840
if (panel->backlight.level == 0) {
843-
panel->backlight.level = intel_panel_get_max_backlight(connector);
841+
panel->backlight.level = panel->backlight.max;
844842
if (panel->backlight.device)
845843
panel->backlight.device->props.brightness =
846844
panel->backlight.level;
@@ -960,7 +958,12 @@ static void intel_backlight_device_unregister(struct intel_connector *connector)
960958
}
961959
#endif /* CONFIG_BACKLIGHT_CLASS_DEVICE */
962960

963-
/* Note: The setup hooks can't assume pipe is set! */
961+
/*
962+
* Note: The setup hooks can't assume pipe is set!
963+
*
964+
* XXX: Query mode clock or hardware clock and program PWM modulation frequency
965+
* appropriately when it's 0. Use VBT and/or sane defaults.
966+
*/
964967
static int pch_setup_backlight(struct intel_connector *connector)
965968
{
966969
struct intel_panel *panel = &connector->panel;

0 commit comments

Comments
 (0)