diff options
author | Sandor Yu <Sandor.yu@nxp.com> | 2016-08-08 11:54:03 +0800 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:24:52 +0800 |
commit | b08b7aa2f05f5862f7ae2895ddb7d038446320f8 (patch) | |
tree | 38647d621e740c1a49eacc8071944b7bd2503edd | |
parent | 46f90eb025367a8f09daaa0371bd1dceb0c01a09 (diff) |
MLK-12932-01: pwm backlight: Add fb name check feature
Add fb name check function pwm_backlight_check_fb_name(),
pwm driver can banding to fb with fb name when driver working
in device tree architecture.
Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
-rw-r--r-- | drivers/video/backlight/pwm_bl.c | 19 | ||||
-rw-r--r-- | include/linux/pwm_backlight.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 0fa7d2bd0e48..2e73ec738a1f 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -41,6 +41,7 @@ struct pwm_bl_data { int brightness); int (*check_fb)(struct device *, struct fb_info *); void (*exit)(struct device *); + char fb_id[16]; }; static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness) @@ -133,6 +134,17 @@ static const struct backlight_ops pwm_backlight_ops = { }; #ifdef CONFIG_OF +static int pwm_backlight_check_fb_name(struct device *dev, struct fb_info *info) +{ + struct backlight_device *bl = dev_get_drvdata(dev); + struct pwm_bl_data *pb = bl_get_data(bl); + + if (strcmp(info->fix.id, pb->fb_id) == 0) + return true; + + return false; +} + static int pwm_backlight_parse_dt(struct device *dev, struct platform_pwm_backlight_data *data) { @@ -141,6 +153,7 @@ static int pwm_backlight_parse_dt(struct device *dev, int length; u32 value; int ret; + const char *names; if (!node) return -ENODEV; @@ -177,6 +190,11 @@ static int pwm_backlight_parse_dt(struct device *dev, data->max_brightness--; } + if (!of_property_read_string(node, "fb-names", &names)){ + strcpy(data->fb_id, names); + data->check_fb = &pwm_backlight_check_fb_name; + } + data->enable_gpio = -EINVAL; return 0; } @@ -275,6 +293,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->exit = data->exit; pb->dev = &pdev->dev; pb->enabled = false; + strcpy(pb->fb_id, data->fb_id); pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", GPIOD_ASIS); diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h index e8afbd71a140..cac4d427cde4 100644 --- a/include/linux/pwm_backlight.h +++ b/include/linux/pwm_backlight.h @@ -21,6 +21,7 @@ struct platform_pwm_backlight_data { void (*notify_after)(struct device *dev, int brightness); void (*exit)(struct device *dev); int (*check_fb)(struct device *dev, struct fb_info *info); + char fb_id[16]; }; #endif |