Commit 9fb978b1 authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Thierry Reding

pwm_backlight: pass correct brightness to callback

pwm_backlight_update_status calls the notify() and notify_after()
callbacks before and after applying the new PWM settings. However, if
brightness levels are used, the brightness value will be changed from
the index into the levels array to the PWM duty cycle length before
being passed to notify_after(), which results in inconsistent behavior.
Signed-off-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Signed-off-by: default avatarThierry Reding <thierry.reding@avionic-design.de>
parent 2437b0d9
...@@ -54,14 +54,18 @@ static int pwm_backlight_update_status(struct backlight_device *bl) ...@@ -54,14 +54,18 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
pwm_config(pb->pwm, 0, pb->period); pwm_config(pb->pwm, 0, pb->period);
pwm_disable(pb->pwm); pwm_disable(pb->pwm);
} else { } else {
int duty_cycle;
if (pb->levels) { if (pb->levels) {
brightness = pb->levels[brightness]; duty_cycle = pb->levels[brightness];
max = pb->levels[max]; max = pb->levels[max];
} else {
duty_cycle = brightness;
} }
brightness = pb->lth_brightness + duty_cycle = pb->lth_brightness +
(brightness * (pb->period - pb->lth_brightness) / max); (duty_cycle * (pb->period - pb->lth_brightness) / max);
pwm_config(pb->pwm, brightness, pb->period); pwm_config(pb->pwm, duty_cycle, pb->period);
pwm_enable(pb->pwm); pwm_enable(pb->pwm);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment