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

pwm_backlight: add check_fb() hook

In systems with multiple framebuffer devices, one of the devices might be
blanked while another is unblanked. In order for the backlight blanking
logic to know whether to turn off the backlight for a particular
framebuffer's blanking notification, it needs to be able to check if a
given framebuffer device corresponds to the backlight.

This plumbs the check_fb hook from core backlight through the
pwm_backlight helper to allow platform code to plug in a check_fb hook.

Signed-off-by: Robert Morell <rmorell@nvidia.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Arun Murthy <arun.murthy@stericsson.com>
Cc: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Robert Morell and committed by
Linus Torvalds
ef0a5e80 0508e04e

+14
+11
drivers/video/backlight/pwm_bl.c
··· 28 28 unsigned int lth_brightness; 29 29 int (*notify)(struct device *, 30 30 int brightness); 31 + int (*check_fb)(struct device *, struct fb_info *); 31 32 }; 32 33 33 34 static int pwm_backlight_update_status(struct backlight_device *bl) ··· 63 62 return bl->props.brightness; 64 63 } 65 64 65 + static int pwm_backlight_check_fb(struct backlight_device *bl, 66 + struct fb_info *info) 67 + { 68 + struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev); 69 + 70 + return !pb->check_fb || pb->check_fb(pb->dev, info); 71 + } 72 + 66 73 static const struct backlight_ops pwm_backlight_ops = { 67 74 .update_status = pwm_backlight_update_status, 68 75 .get_brightness = pwm_backlight_get_brightness, 76 + .check_fb = pwm_backlight_check_fb, 69 77 }; 70 78 71 79 static int pwm_backlight_probe(struct platform_device *pdev) ··· 105 95 106 96 pb->period = data->pwm_period_ns; 107 97 pb->notify = data->notify; 98 + pb->check_fb = data->check_fb; 108 99 pb->lth_brightness = data->lth_brightness * 109 100 (data->pwm_period_ns / data->max_brightness); 110 101 pb->dev = &pdev->dev;
+3
include/linux/pwm_backlight.h
··· 4 4 #ifndef __LINUX_PWM_BACKLIGHT_H 5 5 #define __LINUX_PWM_BACKLIGHT_H 6 6 7 + #include <linux/backlight.h> 8 + 7 9 struct platform_pwm_backlight_data { 8 10 int pwm_id; 9 11 unsigned int max_brightness; ··· 15 13 int (*init)(struct device *dev); 16 14 int (*notify)(struct device *dev, int brightness); 17 15 void (*exit)(struct device *dev); 16 + int (*check_fb)(struct device *dev, struct fb_info *info); 18 17 }; 19 18 20 19 #endif