All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pwm_backlight: pass correct brightness to callback
@ 2012-07-09  4:21 ` Alexandre Courbot
  0 siblings, 0 replies; 14+ messages in thread
From: Alexandre Courbot @ 2012-07-09  4:21 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-kernel, linux-fbdev, Alexandre Courbot

pwm_backlight_update_status calls two callbacks before and after
applying the new PWM settings. However, the brightness scale is
completely changed in between if brightness levels are used. This patch
ensures that both callbacks are passed brightness values of the same
meaning.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/video/backlight/pwm_bl.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 057389d..dd4d24d 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -39,6 +39,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
 {
 	struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev);
 	int brightness = bl->props.brightness;
+	int pwm_brightness;
 	int max = bl->props.max_brightness;
 
 	if (bl->props.power != FB_BLANK_UNBLANK)
@@ -55,13 +56,14 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
 		pwm_disable(pb->pwm);
 	} else {
 		if (pb->levels) {
-			brightness = pb->levels[brightness];
+			pwm_brightness = pb->levels[brightness];
 			max = pb->levels[max];
-		}
+		} else
+			pwm_brightness = brightness;
 
-		brightness = pb->lth_brightness +
-			(brightness * (pb->period - pb->lth_brightness) / max);
-		pwm_config(pb->pwm, brightness, pb->period);
+		pwm_brightness = pb->lth_brightness +
+		     (pwm_brightness * (pb->period - pb->lth_brightness) / max);
+		pwm_config(pb->pwm, pwm_brightness, pb->period);
 		pwm_enable(pb->pwm);
 	}
 
-- 
1.7.11.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-07-09  6:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-09  4:21 [PATCH] pwm_backlight: pass correct brightness to callback Alexandre Courbot
2012-07-09  4:21 ` Alexandre Courbot
2012-07-09  5:10 ` Thierry Reding
2012-07-09  5:10   ` Thierry Reding
2012-07-09  5:27   ` Alex Courbot
2012-07-09  5:27     ` Alex Courbot
2012-07-09  5:36     ` [PATCHv2] " Alexandre Courbot
2012-07-09  5:36       ` Alexandre Courbot
2012-07-09  6:04     ` [PATCHv3] " Alexandre Courbot
2012-07-09  6:04       ` Alexandre Courbot
2012-07-09  6:30       ` Thierry Reding
2012-07-09  6:30         ` Thierry Reding
2012-07-09  5:11 ` [PATCH] " Jingoo Han
2012-07-09  5:11   ` Jingoo Han

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.