@@ -39,6 +39,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
{
struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev);
int brightness = bl->props.brightness;
+ int pwm_brightness;
int max = bl->props.max_brightness;
if (bl->props.power != FB_BLANK_UNBLANK)
@@ -55,13 +56,15 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
pwm_disable(pb->pwm);
} else {
if (pb->levels) {
- brightness = pb->levels[brightness];
+ pwm_brightness = pb->levels[brightness];
max = pb->levels[max];
+ } else {
+ pwm_brightness = brightness;
}
- brightness = pb->lth_brightness +
- (brightness * (pb->period - pb->lth_brightness) / max);
- pwm_config(pb->pwm, brightness, pb->period);
+ pwm_brightness = pb->lth_brightness +
+ (pwm_brightness * (pb->period - pb->lth_brightness) / max);
+ pwm_config(pb->pwm, pwm_brightness, pb->period);
pwm_enable(pb->pwm);
}
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> --- drivers/video/backlight/pwm_bl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)