Skip to content

Commit 9fb978b

Browse files
GnurouThierry Reding
authored andcommitted
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 <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 2437b0d commit 9fb978b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/video/backlight/pwm_bl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,18 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
5454
pwm_config(pb->pwm, 0, pb->period);
5555
pwm_disable(pb->pwm);
5656
} else {
57+
int duty_cycle;
58+
5759
if (pb->levels) {
58-
brightness = pb->levels[brightness];
60+
duty_cycle = pb->levels[brightness];
5961
max = pb->levels[max];
62+
} else {
63+
duty_cycle = brightness;
6064
}
6165

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);
6569
pwm_enable(pb->pwm);
6670
}
6771

0 commit comments

Comments
 (0)