Skip to contentSkip to conversation

drm/i915: write backlight harder

PATCH In review Daniel Vetter 3 participants 4 messages Feb 6, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: write backlight harder

770c12312ad617172b1a65b911d3e6564fc5aca8 is the first bad commit commit 770c12312ad617172b1a65b911d3e6564fc5aca8

Author: Takashi Iwai <[email protected]>
Date:   Sat Aug 11 08:56:42 2012 +0200

drm/i915: Fix blank panel at reopening lid

changed the register write sequence for restoring the backlight, which helped prevent non-working backlights on some machines. Turns out that the original sequence was the right thing to do for a different set of machines. Worse, setting the backlight level _after_ enabling it seems to reset it somehow. So we need to make that one conditional upon the backlight having been reset to zero, and add the old one back.

Cargo-culting at it's best, but it seems to work.

Cc: [email protected]
Cc: Takashi Iwai <[email protected]>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=47941

---
 drivers/gpu/drm/i915/intel_panel.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_panel.c +8 -5
index bee8cb6..a3730e0 100644
@@ -321,6 +321,9 @@ 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);
 
+	dev_priv->backlight_enabled = true;
+	intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);
+
 	if (INTEL_INFO(dev)->gen >= 4) {
 		uint32_t reg, tmp;
 
@@ -356,12 +359,12 @@ void intel_panel_enable_backlight(struct drm_device *dev,
 	}
 
 set_level:
-	/* Call below after setting BLC_PWM_CPU_CTL2 and BLC_PWM_PCH_CTL1.
-	 * BLC_PWM_CPU_CTL may be cleared to zero automatically when these
-	 * registers are set.
+	/* Check the current backlight level and try to set again if it's zero.
+	 * On some machines, BLC_PWM_CPU_CTL is cleared to zero automatically
+	 * when BLC_PWM_CPU_CTL2 and BLC_PWM_PCH_CTL1 are written.
 	 */
-	dev_priv->backlight_enabled = true;
-	intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);
+	if (!intel_panel_get_backlight(dev))
+		intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);
 }
 
 static void intel_panel_init_backlight(struct drm_device *dev)
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw

At Wed, 6 Feb 2013 11:24:41 +0100,

Quoted 15 lines · Daniel Vetter

770c12312ad617172b1a65b911d3e6564fc5aca8 is the first bad commit commit 770c12312ad617172b1a65b911d3e6564fc5aca8

Author: Takashi Iwai <[email protected]>
Date:   Sat Aug 11 08:56:42 2012 +0200

drm/i915: Fix blank panel at reopening lid

changed the register write sequence for restoring the backlight, which helped prevent non-working backlights on some machines. Turns out that the original sequence was the right thing to do for a different set of machines. Worse, setting the backlight level _after_ enabling it seems to reset it somehow. So we need to make that one conditional upon the backlight having been reset to zero, and add the old one back.

Quoted 6 lines

Cargo-culting at it's best, but it seems to work.

Cc: [email protected]
Cc: Takashi Iwai <[email protected]>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=47941

Feel free to take:

thanks,

Takashi

Quoted 39 lines
---
 drivers/gpu/drm/i915/intel_panel.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_panel.c +8 -5
index bee8cb6..a3730e0 100644
@@ -321,6 +321,9 @@ 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);
 
+	dev_priv->backlight_enabled = true;
+	intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);
+
 	if (INTEL_INFO(dev)->gen >= 4) {
 		uint32_t reg, tmp;
 
@@ -356,12 +359,12 @@ void intel_panel_enable_backlight(struct drm_device *dev,
 	}
 
 set_level:
-	/* Call below after setting BLC_PWM_CPU_CTL2 and BLC_PWM_PCH_CTL1.
-	 * BLC_PWM_CPU_CTL may be cleared to zero automatically when these
-	 * registers are set.
+	/* Check the current backlight level and try to set again if it's zero.
+	 * On some machines, BLC_PWM_CPU_CTL is cleared to zero automatically
+	 * when BLC_PWM_CPU_CTL2 and BLC_PWM_PCH_CTL1 are written.
 	 */
-	dev_priv->backlight_enabled = true;
-	intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);
+	if (!intel_panel_get_backlight(dev))
+		intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);
 }
 
 static void intel_panel_init_backlight(struct drm_device *dev)
Signature · 1 line
1.7.10.4
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Daniel Vetter
Quoted 43 lines · Daniel Vetter

770c12312ad617172b1a65b911d3e6564fc5aca8 is the first bad commit commit 770c12312ad617172b1a65b911d3e6564fc5aca8

Author: Takashi Iwai <[email protected]>
Date:   Sat Aug 11 08:56:42 2012 +0200

drm/i915: Fix blank panel at reopening lid

changed the register write sequence for restoring the backlight, which helped prevent non-working backlights on some machines. Turns out that the original sequence was the right thing to do for a different set of machines. Worse, setting the backlight level _after_ enabling it seems to reset it somehow. So we need to make that one conditional upon the backlight having been reset to zero, and add the old one back.

Cargo-culting at it's best, but it seems to work.

Cc: [email protected]
Cc: Takashi Iwai <[email protected]>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=47941

---
 drivers/gpu/drm/i915/intel_panel.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_panel.c +3 -1
index bee8cb6..a3730e0 100644
@@ -321,6 +321,9 @@ 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);
 
+	dev_priv->backlight_enabled = true;
+	intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);
+
 	if (INTEL_INFO(dev)->gen >= 4) {
 		uint32_t reg, tmp;
 
@@ -356,12 +359,12 @@ void intel_panel_enable_backlight(struct drm_device *dev,
 	}
 
 set_level:
-	/* Call below after setting BLC_PWM_CPU_CTL2 and BLC_PWM_PCH_CTL1.

drivers/gpu/drm/i915/intel_panel.c void intel_panel_enable_backlight(struct drm_device *dev, · line 367

Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +5 -4
-	 * BLC_PWM_CPU_CTL may be cleared to zero automatically when these
-	 * registers are set.
+	/* Check the current backlight level and try to set again if it's zero.
+	 * On some machines, BLC_PWM_CPU_CTL is cleared to zero automatically
+	 * when BLC_PWM_CPU_CTL2 and BLC_PWM_PCH_CTL1 are written.
 	 */
-	dev_priv->backlight_enabled = true;
-	intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);
+	if (!intel_panel_get_backlight(dev))
+		intel_panel_actually_set_backlight(dev, dev_priv->backlight_level);

Given how much pain the backlight keeps giving us, do you think we would benefit from sticking a DRM_DEBUG_DRIVER in the if block there?

Either way, with a heavy *sigh*,

Quoted 10 lines
drivers/gpu/drm/i915/intel_panel.c +0 -0
 }
 
 static void intel_panel_init_backlight(struct drm_device *dev)
Signature · 6 lines
1.7.10.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
author Applied
#3 lore raw
Quoted 5 lines · Jani Nikula

Given how much pain the backlight keeps giving us, do you think we would benefit from sticking a DRM_DEBUG_DRIVER in the if block there?

Either way, with a heavy *sigh*,

Merged to dinq, thanks for the review.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch