summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2013-10-18 10:46:24 +0200
committerNitin Garg <nitin.garg@freescale.com>2014-08-27 18:11:47 -0500
commitaf34aba135b53f9e3d0db1a696f819168e93e325 (patch)
treef74d5161655e394e1e82aa04f751f2f98ffb050c
parent2e070b5b4d2d00d96eff8f504da8c1d58d9ec90a (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
-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 {
static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness)
{
- unsigned int lth = pb->lth_brightness;
- int duty_cycle, err;
-
if (pb->enabled)
return;
- if (pb->levels)
- duty_cycle = pb->levels[brightness];
- else
- duty_cycle = brightness;
-
- duty_cycle = (duty_cycle * (pb->period - lth) / pb->scale) + lth;
-
- pwm_config(pb->pwm, duty_cycle, pb->period);
-
if (gpio_is_valid(pb->enable_gpio)) {
if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW)
gpio_set_value(pb->enable_gpio, 0);
@@ -88,10 +76,24 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb)
pb->enabled = false;
}
+static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness)
+{
+ unsigned int lth = pb->lth_brightness;
+ int duty_cycle;
+
+ if (pb->levels)
+ duty_cycle = pb->levels[brightness];
+ else
+ duty_cycle = brightness;
+
+ return (duty_cycle * (pb->period - lth) / pb->scale) + lth;
+}
+
static int pwm_backlight_update_status(struct backlight_device *bl)
{
struct pwm_bl_data *pb = bl_get_data(bl);
int brightness = bl->props.brightness;
+ int duty_cycle;
if (bl->props.power != FB_BLANK_UNBLANK ||
bl->props.fb_blank != FB_BLANK_UNBLANK ||
@@ -101,9 +103,11 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
if (pb->notify)
brightness = pb->notify(pb->dev, brightness);
- if (brightness > 0)
+ if (brightness > 0) {
+ duty_cycle = compute_duty_cycle(pb, brightness);
+ pwm_config(pb->pwm, duty_cycle, pb->period);
pwm_backlight_power_on(pb, brightness);
- else
+ } else
pwm_backlight_power_off(pb);
if (pb->notify_after)