From 777bb9f08261c6e839e2fca4fadbb63d3f5ccf26 Mon Sep 17 00:00:00 2001 From: Sandor Yu Date: Tue, 8 Jan 2019 17:42:10 +0530 Subject: [PATCH] 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 Signed-off-by: Vipul Kumar --- drivers/video/backlight/pwm_bl.c | 20 +++++++++++++++++++- include/linux/pwm_backlight.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 7ddc0930e98c..d59953421846 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -44,6 +44,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) @@ -244,6 +245,17 @@ int pwm_backlight_brightness_default(struct device *dev, return 0; } +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) { @@ -256,12 +268,18 @@ static int pwm_backlight_parse_dt(struct device *dev, int length; u32 value; int ret; + const char *names; if (!node) return -ENODEV; memset(data, 0, sizeof(*data)); + if (!of_property_read_string(node, "fb-names", &names)) { + strcpy(data->fb_id, names); + data->check_fb = &pwm_backlight_check_fb_name; + } + /* * These values are optional and set as 0 by default, the out values * are modified only if a valid u32 value can be decoded. @@ -383,7 +401,6 @@ static int pwm_backlight_parse_dt(struct device *dev, data->max_brightness--; } - return 0; } @@ -482,6 +499,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->enabled = false; pb->post_pwm_on_delay = data->post_pwm_on_delay; pb->pwm_off_delay = data->pwm_off_delay; + 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 8ea265a022fd..d5f73e14445b 100644 --- a/include/linux/pwm_backlight.h +++ b/include/linux/pwm_backlight.h @@ -23,6 +23,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 -- 2.17.1