diff options
author | Liu Ying <Ying.Liu@freescale.com> | 2014-03-19 13:20:30 +0800 |
---|---|---|
committer | Nitin Garg <nitin.garg@freescale.com> | 2014-04-16 08:58:06 -0500 |
commit | ad78bc949297164951848f396dce7469c8307420 (patch) | |
tree | 6ba246e9c9b891dffad6317a10812971fc76c0dd /drivers/video | |
parent | 4586b1a712570e0e0a026b17bdea34c0a984754b (diff) |
ENGR00305067-1 video: pwm backlight: Add DT check fb support
A system based on a devicetree kernel may have multiple framebuffers
and each framebuffer has its own pwm backlight. A specific pwm backlight
should be enabled/disabled according to its framebuffer unblank/blank
events respectively. The backlight device's callback check_fb() is the
method the backlight core driver uses to determine if a backlight device
should respond to a certain framebuffer blank/unblank events or not.
This patch adds the callback check_fb() for the pwm backlight driver with
devicetree supported. Users should list every framebuffer name in the
string property fb-names of a pwm backlight devicetree node, otherwise,
the backlight device will respond to every framebuffer's blank/unblank
events in a system.
Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/backlight/pwm_bl.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 1fea627394d7..c867813218a4 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -33,6 +33,7 @@ struct pwm_bl_data { int brightness); int (*check_fb)(struct device *, struct fb_info *); void (*exit)(struct device *); + const char *fb_names[FB_MAX]; }; static int pwm_backlight_update_status(struct backlight_device *bl) @@ -84,7 +85,7 @@ static int pwm_backlight_check_fb(struct backlight_device *bl, { struct pwm_bl_data *pb = bl_get_data(bl); - return !pb->check_fb || pb->check_fb(pb->dev, info); + return pb->check_fb(pb->dev, info); } static const struct backlight_ops pwm_backlight_ops = { @@ -161,15 +162,36 @@ static int pwm_backlight_parse_dt(struct device *dev, } #endif +static int pwm_backlight_check_fb_dt(struct device *dev, + struct fb_info *info) +{ + struct backlight_device *bl = dev_get_drvdata(dev); + struct pwm_bl_data *pb = bl_get_data(bl); + int i; + + for (i = 0; i < FB_MAX; i++) + if (pb->fb_names[i] && + !strcmp(info->fix.id, pb->fb_names[i])) + return 1; + + /* Any fb_names? */ + for (i = 0; i < FB_MAX; i++) + if (pb->fb_names[i]) + return 0; + + return 1; +} + static int pwm_backlight_probe(struct platform_device *pdev) { struct platform_pwm_backlight_data *data = pdev->dev.platform_data; struct platform_pwm_backlight_data defdata; + struct device_node *np = pdev->dev.of_node; struct backlight_properties props; struct backlight_device *bl; struct pwm_bl_data *pb; unsigned int max; - int ret; + int ret, index; if (!data) { ret = pwm_backlight_parse_dt(&pdev->dev, &defdata); @@ -194,6 +216,15 @@ static int pwm_backlight_probe(struct platform_device *pdev) goto err_alloc; } + if (np) + for (index = 0; index < FB_MAX; index++) { + ret = of_property_read_string_index(np, "fb-names", + index, + &pb->fb_names[index]); + if (ret < 0) + break; + } + if (data->levels) { max = data->levels[data->max_brightness]; pb->levels = data->levels; @@ -202,7 +233,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->notify = data->notify; pb->notify_after = data->notify_after; - pb->check_fb = data->check_fb; + pb->check_fb = np ? pwm_backlight_check_fb_dt : data->check_fb; pb->exit = data->exit; pb->dev = &pdev->dev; |