Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>

authored by

Alexandre Courbot and committed by
Thierry Reding
9fb978b1 2437b0d9

+8 -4
+8 -4
drivers/video/backlight/pwm_bl.c
··· 54 54 pwm_config(pb->pwm, 0, pb->period); 55 55 pwm_disable(pb->pwm); 56 56 } else { 57 + int duty_cycle; 58 + 57 59 if (pb->levels) { 58 - brightness = pb->levels[brightness]; 60 + duty_cycle = pb->levels[brightness]; 59 61 max = pb->levels[max]; 62 + } else { 63 + duty_cycle = brightness; 60 64 } 61 65 62 - brightness = pb->lth_brightness + 63 - (brightness * (pb->period - pb->lth_brightness) / max); 64 - pwm_config(pb->pwm, brightness, pb->period); 66 + duty_cycle = pb->lth_brightness + 67 + (duty_cycle * (pb->period - pb->lth_brightness) / max); 68 + pwm_config(pb->pwm, duty_cycle, pb->period); 65 69 pwm_enable(pb->pwm); 66 70 } 67 71