aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2013-10-18 04:46:24 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:58:17 -0400
commite3e74c9e6e4f68826d672f18c60066883956e118 (patch)
treea7337c6def2fc7adfc8844fce4094324c80fe958 /drivers/video
parenta8b160f1c0a57b57d38001bb795145078f92f01e (diff)
pwm-backlight: Fix brightness adjustment
Split adjustment of the brightness (by changing the PWM duty cycle) from the power on sequence. This fixes an issue where the brightness can no longer be updated once the backlight has been enabled. Reported-by: Marc Dietrich <marvin24@gmx.de> Signed-off-by: Thierry Reding <treding@nvidia.com> (cherry picked from commit e4bfeda96872bfe6015cd360008b77cd3b981b2b) Conflicts: drivers/video/backlight/pwm_bl.c
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/backlight/pwm_bl.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 65b63961d3fd..130125001454 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -44,21 +44,9 @@ struct pwm_bl_data {
44 44
45static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness) 45static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness)
46{ 46{
47 unsigned int lth = pb->lth_brightness;
48 int duty_cycle, err;
49
50 if (pb->enabled) 47 if (pb->enabled)
51 return; 48 return;
52 49
53 if (pb->levels)
54 duty_cycle = pb->levels[brightness];
55 else
56 duty_cycle = brightness;
57
58 duty_cycle = (duty_cycle * (pb->period - lth) / pb->scale) + lth;
59
60 pwm_config(pb->pwm, duty_cycle, pb->period);
61
62 if (gpio_is_valid(pb->enable_gpio)) { 50 if (gpio_is_valid(pb->enable_gpio)) {
63 if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW) 51 if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW)
64 gpio_set_value(pb->enable_gpio, 0); 52 gpio_set_value(pb->enable_gpio, 0);
@@ -88,10 +76,24 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb)
88 pb->enabled = false; 76 pb->enabled = false;
89} 77}
90 78
79static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness)
80{
81 unsigned int lth = pb->lth_brightness;
82 int duty_cycle;
83
84 if (pb->levels)
85 duty_cycle = pb->levels[brightness];
86 else
87 duty_cycle = brightness;
88
89 return (duty_cycle * (pb->period - lth) / pb->scale) + lth;
90}
91
91static int pwm_backlight_update_status(struct backlight_device *bl) 92static int pwm_backlight_update_status(struct backlight_device *bl)
92{ 93{
93 struct pwm_bl_data *pb = bl_get_data(bl); 94 struct pwm_bl_data *pb = bl_get_data(bl);
94 int brightness = bl->props.brightness; 95 int brightness = bl->props.brightness;
96 int duty_cycle;
95 97
96 if (bl->props.power != FB_BLANK_UNBLANK || 98 if (bl->props.power != FB_BLANK_UNBLANK ||
97 bl->props.fb_blank != FB_BLANK_UNBLANK || 99 bl->props.fb_blank != FB_BLANK_UNBLANK ||
@@ -101,9 +103,11 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
101 if (pb->notify) 103 if (pb->notify)
102 brightness = pb->notify(pb->dev, brightness); 104 brightness = pb->notify(pb->dev, brightness);
103 105
104 if (brightness > 0) 106 if (brightness > 0) {
107 duty_cycle = compute_duty_cycle(pb, brightness);
108 pwm_config(pb->pwm, duty_cycle, pb->period);
105 pwm_backlight_power_on(pb, brightness); 109 pwm_backlight_power_on(pb, brightness);
106 else 110 } else
107 pwm_backlight_power_off(pb); 111 pwm_backlight_power_off(pb);
108 112
109 if (pb->notify_after) 113 if (pb->notify_after)