[PATCH] drm/i915/panel: Alwyas record the backlight level again (but cleverly)

Takashi Iwai tiwai at suse.de
Thu Oct 13 01:57:35 PDT 2011

The commit 47356eb67285014527a5ab87543ba1fae3d1e10a introduced a
mechanism to record the backlight level only at disabling time, but it
also introduced a regression.  Since intel_lvds_enable() may be called
without disabling (e.g. intel_lvds_commit() calls it unconditionally),
the backlight gets back to the last recorded value.  For example, this
happens when you dim the backlight, close the lid and open the lid,
then the backlight suddenly goes to the brightest.

This patch fixes the bug by recording the backlight level always
when changed but only when dev_priv->backlight_enabled is set.
In this way, the bogus value for disabling backlight can be skipped.

Signed-off-by: Takashi Iwai <tiwai at suse.de>

Feel free to add Cc to stable kernel, as this is a regression fix.
I've tested only a few machines here so more tests would be
appreciated, because the backlight issue is SOOO sensitive :)

 drivers/gpu/drm/i915/intel_panel.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index a9e0c7b..269d526 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -233,6 +233,9 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level)
 	DRM_DEBUG_DRIVER("set backlight PWM = %d\n", level);
+	if (dev_priv->backlight_enabled)
+		dev_priv->backlight_level = level;
 	if (HAS_PCH_SPLIT(dev))
 		return intel_pch_panel_set_backlight(dev, level);
@@ -258,11 +261,7 @@ void intel_panel_disable_backlight(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	if (dev_priv->backlight_enabled) {
-		dev_priv->backlight_level = intel_panel_get_backlight(dev);
-		dev_priv->backlight_enabled = false;
-	}
+	dev_priv->backlight_enabled = false;
 	intel_panel_set_backlight(dev, 0);
@@ -273,8 +272,8 @@ void intel_panel_enable_backlight(struct drm_device *dev)
 	if (dev_priv->backlight_level == 0)
 		dev_priv->backlight_level = intel_panel_get_max_backlight(dev);
-	intel_panel_set_backlight(dev, dev_priv->backlight_level);
 	dev_priv->backlight_enabled = true;
+	intel_panel_set_backlight(dev, dev_priv->backlight_level);
 static void intel_panel_init_backlight(struct drm_device *dev)

More information about the dri-devel mailing list