mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: DRI mailing list <dri-devel@lists.freedesktop.org>,
	Chris Wilson <chris@chris-wilson.co.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] fix backlight brightness on intel LVDS panel after reopening lid
Date: Wed, 16 Feb 2011 20:26:58 +0100	[thread overview]
Message-ID: <20110216192658.GA7225@blimp.localdomain> (raw)
In-Reply-To: <AANLkTi=Mc8O8cNWYOKgD0cESQhfa2jiHor11DBuagJDF@mail.gmail.com>

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>

---
Linus Torvalds, Wed, Feb 16, 2011 05:16:01 +0100:
> Most of the changes are pretty spread out and small, with drivers/gpu
> (radeon and i915) somewhat standing out from the pack. ... 

The backlight level on this Dell XPS M1330 reduces every time I reopen the
lid, and BIOS does not seem to know anything about that (the keyboard
shortcuts to set backlight brightness cause it to jump to the level next to
the one set before closing the lid).

Maybe i915 code for LVDS panels have lost some parts of the backlight
enable/disable balancing patch by Chris Wilson? Or maybe it just got broken
along the way...

This part of the patch by Chris helped here, but I afraid it might be not
complete or just wrong (for instance, the original patch didn't have to remove
the i915_read_blc_pwm_ctl function).

 drivers/gpu/drm/i915/intel_panel.c |   65 ++++++++++--------------------------
 1 files changed, 18 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index c65992d..c4b1ca4 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -125,55 +125,15 @@ static int is_backlight_combination_mode(struct drm_device *dev)
 	return 0;
 }
 
-static u32 i915_read_blc_pwm_ctl(struct drm_i915_private *dev_priv)
-{
-	u32 val;
-
-	/* Restore the CTL value if it lost, e.g. GPU reset */
-
-	if (HAS_PCH_SPLIT(dev_priv->dev)) {
-		val = I915_READ(BLC_PWM_PCH_CTL2);
-		if (dev_priv->saveBLC_PWM_CTL2 == 0) {
-			dev_priv->saveBLC_PWM_CTL2 = val;
-		} else if (val == 0) {
-			I915_WRITE(BLC_PWM_PCH_CTL2,
-				   dev_priv->saveBLC_PWM_CTL);
-			val = dev_priv->saveBLC_PWM_CTL;
-		}
-	} else {
-		val = I915_READ(BLC_PWM_CTL);
-		if (dev_priv->saveBLC_PWM_CTL == 0) {
-			dev_priv->saveBLC_PWM_CTL = val;
-			dev_priv->saveBLC_PWM_CTL2 = I915_READ(BLC_PWM_CTL2);
-		} else if (val == 0) {
-			I915_WRITE(BLC_PWM_CTL,
-				   dev_priv->saveBLC_PWM_CTL);
-			I915_WRITE(BLC_PWM_CTL2,
-				   dev_priv->saveBLC_PWM_CTL2);
-			val = dev_priv->saveBLC_PWM_CTL;
-		}
-	}
-
-	return val;
-}
-
 u32 intel_panel_get_max_backlight(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	u32 max;
 
-	max = i915_read_blc_pwm_ctl(dev_priv);
-	if (max == 0) {
-		/* XXX add code here to query mode clock or hardware clock
-		 * and program max PWM appropriately.
-		 */
-		printk_once(KERN_WARNING "fixme: max PWM is zero.\n");
-		return 1;
-	}
-
 	if (HAS_PCH_SPLIT(dev)) {
-		max >>= 16;
+		max = I915_READ(BLC_PWM_PCH_CTL2) >> 16;
 	} else {
+		max = I915_READ(BLC_PWM_CTL);
 		if (IS_PINEVIEW(dev)) {
 			max >>= 17;
 		} else {
@@ -186,6 +146,14 @@ u32 intel_panel_get_max_backlight(struct drm_device *dev)
 			max *= 0xff;
 	}
 
+	if (max == 0) {
+		/* XXX add code here to query mode clock or hardware clock
+		 * and program max PWM appropriately.
+		 */
+		DRM_ERROR("fixme: max PWM is zero.\n");
+		max = 1;
+	}
+
 	DRM_DEBUG_DRIVER("max backlight PWM = %d\n", max);
 	return max;
 }
@@ -255,11 +223,11 @@ 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;
-	}
+	if (!dev_priv->backlight_enabled)
+		return;
 
+	dev_priv->backlight_enabled = false;
+	dev_priv->backlight_level = intel_panel_get_backlight(dev);
 	intel_panel_set_backlight(dev, 0);
 }
 
@@ -267,6 +235,9 @@ void intel_panel_enable_backlight(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	if (dev_priv->backlight_enabled)
+		return;
+
 	if (dev_priv->backlight_level == 0)
 		dev_priv->backlight_level = intel_panel_get_max_backlight(dev);
 
@@ -278,6 +249,6 @@ void intel_panel_setup_backlight(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	dev_priv->backlight_level = intel_panel_get_backlight(dev);
+	dev_priv->backlight_level = intel_panel_get_max_backlight(dev);
 	dev_priv->backlight_enabled = dev_priv->backlight_level != 0;
 }
-- 
1.7.4.27.gf5729

  parent reply	other threads:[~2011-02-16 19:27 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-16  4:16 Linux 2.6.38-rc5 Linus Torvalds
2011-02-16 11:14 ` Eric Dumazet
2011-02-16 13:55   ` Eric Dumazet
2011-02-16 15:46   ` Linus Torvalds
2011-02-16 16:06     ` Al Viro
2011-02-16 16:19       ` Al Viro
2011-02-16 16:33         ` Linus Torvalds
2011-02-16 16:39           ` Al Viro
2011-02-16 16:47             ` Eric Dumazet
2011-02-16 16:22     ` Eric Dumazet
2011-02-16 19:26 ` Alex Riesen [this message]
2011-02-16 19:46   ` [PATCH] fix backlight brightness on intel LVDS panel after reopening lid Alex Riesen
2011-02-16 19:54     ` Jesse Barnes
2011-02-16 19:59       ` Alex Riesen
2011-02-16 20:05         ` Jesse Barnes
2011-02-16 20:28           ` Alex Riesen
2011-02-17  1:41     ` [PATCH] drm/i915: Do not handle backlight combination mode specially Indan Zupancic
2011-02-17 22:13   ` [PATCH] fix backlight brightness on intel LVDS panel after reopening lid Tino Keitel
2011-02-18  4:57     ` Indan Zupancic
2011-02-19 12:11       ` Alex Riesen
2011-02-19 12:26         ` Alex Riesen
2011-02-19 23:07           ` Linus Torvalds
2011-02-22 21:04             ` Jesse Barnes
2011-02-22 22:31               ` Tino Keitel
2011-02-23  1:09                 ` Linus Torvalds
2011-03-04  6:53                   ` Indan Zupancic
2011-03-04 18:47                     ` Linus Torvalds
2011-03-04 23:32                       ` Indan Zupancic
2011-03-06 17:40                       ` Alex Riesen
2011-03-10  5:50                       ` Indan Zupancic
2011-03-10  6:00                         ` Indan Zupancic
2011-03-10  7:49                         ` Takashi Iwai
2011-03-10  8:25                           ` Takashi Iwai
2011-03-10 10:06                             ` Indan Zupancic
2011-03-10 12:59                               ` Takashi Iwai
2011-03-10 13:02                               ` [PATCH] drm/i915: Revive combination mode for backlight control Takashi Iwai
2011-03-10 19:36                                 ` Keith Packard
2011-03-11  1:30                                   ` Indan Zupancic
2011-03-11  1:23                                 ` Indan Zupancic
2011-03-11  1:28                                   ` Linus Torvalds
2011-03-11  7:26                                   ` Takashi Iwai
2011-03-11  9:08                                     ` Indan Zupancic
2011-03-11  7:34                                   ` Keith Packard
2011-03-10  8:45                           ` [PATCH] fix backlight brightness on intel LVDS panel after reopening lid Indan Zupancic
2011-03-10 12:51                             ` Takashi Iwai
2011-03-05  0:26                     ` Peter Stuge
2011-02-23  1:32               ` Indan Zupancic
2011-02-20 14:03 ` Linux 2.6.38-rc5 Paul Rolland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110216192658.GA7225@blimp.localdomain \
    --to=raa.lkml@gmail.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome