Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1246743 > unrolled thread

[RESEND PATCH v2] pwm-backlight: Avoid backlight flicker when probed from DT

Started byPhilipp Zabel <p.zabel@pengutronix.de>
First post2015-10-14 15:30 +0200
Last post2015-10-15 14:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [RESEND PATCH v2] pwm-backlight: Avoid backlight flicker when probed from DT Philipp Zabel <p.zabel@pengutronix.de> - 2015-10-14 15:30 +0200
    Re: [RESEND PATCH v2] pwm-backlight: Avoid backlight flicker when  probed from DT Christian Gmeiner <christian.gmeiner@gmail.com> - 2015-10-15 14:00 +0200

#1246743 — [RESEND PATCH v2] pwm-backlight: Avoid backlight flicker when probed from DT

FromPhilipp Zabel <p.zabel@pengutronix.de>
Date2015-10-14 15:30 +0200
Subject[RESEND PATCH v2] pwm-backlight: Avoid backlight flicker when probed from DT
Message-ID<qjuhY-8cu-35@gated-at.bofh.it>
If the driver is probed from the device tree, and there is a phandle
property set on it, and the enable GPIO is already configured as output,
and the backlight is currently disabled, keep it disabled.
If all these conditions are met, assume there will be some other driver
that can enable the backlight at the appropriate time.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
Changes since v1:
 - Also check if the regulator is enabled. If the power supply is disabled,
   and a phandle points to it, the backlight should stay powered down.
---
 drivers/video/backlight/pwm_bl.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index eff379b..31afd6d 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -199,6 +199,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 	struct backlight_properties props;
 	struct backlight_device *bl;
 	struct pwm_bl_data *pb;
+	int initial_blank = FB_BLANK_UNBLANK;
+	bool phandle;
 	int ret;
 
 	if (!data) {
@@ -264,12 +266,32 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 		pb->enable_gpio = gpio_to_desc(data->enable_gpio);
 	}
 
+	phandle = of_find_property(pdev->dev.of_node, "phandle", NULL) != NULL;
+
+	if (pb->enable_gpio) {
+		/*
+		 * If the driver is probed from the device tree and there is a
+		 * phandle link pointing to the backlight node, it is safe to
+		 * assume that another driver will enable the backlight at the
+		 * appropriate time. Therefore, if it is disabled, keep it so.
+		 */
+		if (phandle &&
+		    gpiod_get_direction(pb->enable_gpio) == GPIOF_DIR_OUT &&
+		    gpiod_get_value(pb->enable_gpio) == 0)
+			initial_blank = FB_BLANK_POWERDOWN;
+		else
+			gpiod_direction_output(pb->enable_gpio, 1);
+	}
+
 	pb->power_supply = devm_regulator_get(&pdev->dev, "power");
 	if (IS_ERR(pb->power_supply)) {
 		ret = PTR_ERR(pb->power_supply);
 		goto err_alloc;
 	}
 
+	if (phandle && !regulator_is_enabled(pb->power_supply))
+		initial_blank = FB_BLANK_POWERDOWN;
+
 	pb->pwm = devm_pwm_get(&pdev->dev, NULL);
 	if (IS_ERR(pb->pwm)) {
 		ret = PTR_ERR(pb->pwm);
@@ -321,6 +343,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 	}
 
 	bl->props.brightness = data->dft_brightness;
+	bl->props.power = initial_blank;
 	backlight_update_status(bl);
 
 	platform_set_drvdata(pdev, bl);
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1247725 — Re: [RESEND PATCH v2] pwm-backlight: Avoid backlight flicker when probed from DT

FromChristian Gmeiner <christian.gmeiner@gmail.com>
Date2015-10-15 14:00 +0200
SubjectRe: [RESEND PATCH v2] pwm-backlight: Avoid backlight flicker when probed from DT
Message-ID<qjPmr-5vG-5@gated-at.bofh.it>
In reply to#1246743
2015-10-14 15:25 GMT+02:00 Philipp Zabel <p.zabel@pengutronix.de>:
> If the driver is probed from the device tree, and there is a phandle
> property set on it, and the enable GPIO is already configured as output,
> and the backlight is currently disabled, keep it disabled.
> If all these conditions are met, assume there will be some other driver
> that can enable the backlight at the appropriate time.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
> Changes since v1:
>  - Also check if the regulator is enabled. If the power supply is disabled,
>    and a phandle points to it, the backlight should stay powered down.
> ---
>  drivers/video/backlight/pwm_bl.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index eff379b..31afd6d 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -199,6 +199,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>         struct backlight_properties props;
>         struct backlight_device *bl;
>         struct pwm_bl_data *pb;
> +       int initial_blank = FB_BLANK_UNBLANK;
> +       bool phandle;
>         int ret;
>
>         if (!data) {
> @@ -264,12 +266,32 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>                 pb->enable_gpio = gpio_to_desc(data->enable_gpio);
>         }
>
> +       phandle = of_find_property(pdev->dev.of_node, "phandle", NULL) != NULL;
> +
> +       if (pb->enable_gpio) {
> +               /*
> +                * If the driver is probed from the device tree and there is a
> +                * phandle link pointing to the backlight node, it is safe to
> +                * assume that another driver will enable the backlight at the
> +                * appropriate time. Therefore, if it is disabled, keep it so.
> +                */
> +               if (phandle &&
> +                   gpiod_get_direction(pb->enable_gpio) == GPIOF_DIR_OUT &&
> +                   gpiod_get_value(pb->enable_gpio) == 0)
> +                       initial_blank = FB_BLANK_POWERDOWN;
> +               else
> +                       gpiod_direction_output(pb->enable_gpio, 1);
> +       }
> +
>         pb->power_supply = devm_regulator_get(&pdev->dev, "power");
>         if (IS_ERR(pb->power_supply)) {
>                 ret = PTR_ERR(pb->power_supply);
>                 goto err_alloc;
>         }
>
> +       if (phandle && !regulator_is_enabled(pb->power_supply))
> +               initial_blank = FB_BLANK_POWERDOWN;
> +
>         pb->pwm = devm_pwm_get(&pdev->dev, NULL);
>         if (IS_ERR(pb->pwm)) {
>                 ret = PTR_ERR(pb->pwm);
> @@ -321,6 +343,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>         }
>
>         bl->props.brightness = data->dft_brightness;
> +       bl->props.power = initial_blank;
>         backlight_update_status(bl);
>
>         platform_set_drvdata(pdev, bl);
> --
> 2.6.1
>

Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
--
Christian Gmeiner, MSc

https://soundcloud.com/christian-gmeiner
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web