LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] pwm-backlight: Avoid backlight flicker when probed from DT
@ 2015-11-18 17:12 Philipp Zabel
  2015-11-24 16:26 ` Lee Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Philipp Zabel @ 2015-11-18 17:12 UTC (permalink / raw
  To: Thierry Reding, Jingoo Han, Lee Jones
  Cc: Ajay Kumar, YH Huang, Christian Gmeiner, Heiko Stuebner,
	linux-pwm, linux-fbdev, linux-kernel, linux-arm-kernel, kernel,
	Philipp Zabel

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>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
---
 - Rebased onto v4.4-rc1
 - Added Heiko's Tested-by
---
 drivers/video/backlight/pwm_bl.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index ae3c6b6..3daf9cc 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;
+	phandle phandle = pdev->dev.of_node->phandle;
+	int initial_blank = FB_BLANK_UNBLANK;
 	int ret;
 
 	if (!data) {
@@ -242,7 +244,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 	pb->enabled = false;
 
 	pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
-						  GPIOD_OUT_HIGH);
+						  GPIOD_ASIS);
 	if (IS_ERR(pb->enable_gpio)) {
 		ret = PTR_ERR(pb->enable_gpio);
 		goto err_alloc;
@@ -264,12 +266,30 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 		pb->enable_gpio = gpio_to_desc(data->enable_gpio);
 	}
 
+	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) && PTR_ERR(pb->pwm) != -EPROBE_DEFER
 	    && !pdev->dev.of_node) {
@@ -320,6 +340,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.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v5] pwm-backlight: Avoid backlight flicker when probed from DT
  2015-11-18 17:12 [PATCH v5] pwm-backlight: Avoid backlight flicker when probed from DT Philipp Zabel
@ 2015-11-24 16:26 ` Lee Jones
  2015-12-07  4:20   ` Daniel Kurtz
  0 siblings, 1 reply; 4+ messages in thread
From: Lee Jones @ 2015-11-24 16:26 UTC (permalink / raw
  To: Philipp Zabel
  Cc: Thierry Reding, Jingoo Han, Ajay Kumar, YH Huang,
	Christian Gmeiner, Heiko Stuebner, linux-pwm, linux-fbdev,
	linux-kernel, linux-arm-kernel, kernel

On Wed, 18 Nov 2015, Philipp Zabel wrote:

> 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>
> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> Tested-by: Heiko Stuebner <heiko@sntech.de>
> ---
>  - Rebased onto v4.4-rc1
>  - Added Heiko's Tested-by
> ---
>  drivers/video/backlight/pwm_bl.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)

Applied, thanks.

> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index ae3c6b6..3daf9cc 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;
> +	phandle phandle = pdev->dev.of_node->phandle;
> +	int initial_blank = FB_BLANK_UNBLANK;
>  	int ret;
>  
>  	if (!data) {
> @@ -242,7 +244,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>  	pb->enabled = false;
>  
>  	pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
> -						  GPIOD_OUT_HIGH);
> +						  GPIOD_ASIS);
>  	if (IS_ERR(pb->enable_gpio)) {
>  		ret = PTR_ERR(pb->enable_gpio);
>  		goto err_alloc;
> @@ -264,12 +266,30 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>  		pb->enable_gpio = gpio_to_desc(data->enable_gpio);
>  	}
>  
> +	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) && PTR_ERR(pb->pwm) != -EPROBE_DEFER
>  	    && !pdev->dev.of_node) {
> @@ -320,6 +340,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);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v5] pwm-backlight: Avoid backlight flicker when probed from DT
  2015-11-24 16:26 ` Lee Jones
@ 2015-12-07  4:20   ` Daniel Kurtz
  2015-12-07  9:35     ` Lee Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Kurtz @ 2015-12-07  4:20 UTC (permalink / raw
  To: Lee Jones
  Cc: Philipp Zabel, Thierry Reding, Jingoo Han, Ajay Kumar, YH Huang,
	Christian Gmeiner, Heiko Stuebner, linux-pwm,
	Linux Fbdev development list, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, Sasha Hauer

Hi Lee,

On Wed, Nov 25, 2015 at 12:26 AM, Lee Jones <lee.jones@linaro.org> wrote:
> On Wed, 18 Nov 2015, Philipp Zabel wrote:
>
>> 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>
>> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
>> Tested-by: Heiko Stuebner <heiko@sntech.de>
>> ---
>>  - Rebased onto v4.4-rc1
>>  - Added Heiko's Tested-by
>> ---
>>  drivers/video/backlight/pwm_bl.c | 23 ++++++++++++++++++++++-
>>  1 file changed, 22 insertions(+), 1 deletion(-)
>
> Applied, thanks.

Hmm, where was this applied?  I do not see it in:
 * v4.4-rc4
 * linux-next next-20151203 (dcccebc - Add linux-next specific files
for 20151203)

Nor do I see it in any branch in:
 * git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
Is this the right git?
By the way this repository has a git tag called "HEAD", which is a bit
annoying since every time I "git remote update" from here, git gets
confused until I manually delete it (git tag -d HEAD).

Thanks,
-Dan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v5] pwm-backlight: Avoid backlight flicker when probed from DT
  2015-12-07  4:20   ` Daniel Kurtz
@ 2015-12-07  9:35     ` Lee Jones
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2015-12-07  9:35 UTC (permalink / raw
  To: Daniel Kurtz
  Cc: Philipp Zabel, Thierry Reding, Jingoo Han, Ajay Kumar, YH Huang,
	Christian Gmeiner, Heiko Stuebner, linux-pwm,
	Linux Fbdev development list, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, Sasha Hauer

On Mon, 07 Dec 2015, Daniel Kurtz wrote:

> Hi Lee,
> 
> On Wed, Nov 25, 2015 at 12:26 AM, Lee Jones <lee.jones@linaro.org> wrote:
> > On Wed, 18 Nov 2015, Philipp Zabel wrote:
> >
> >> 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>
> >> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> >> Tested-by: Heiko Stuebner <heiko@sntech.de>
> >> ---
> >>  - Rebased onto v4.4-rc1
> >>  - Added Heiko's Tested-by
> >> ---
> >>  drivers/video/backlight/pwm_bl.c | 23 ++++++++++++++++++++++-
> >>  1 file changed, 22 insertions(+), 1 deletion(-)
> >
> > Applied, thanks.
> 
> Hmm, where was this applied?  I do not see it in:
>  * v4.4-rc4
>  * linux-next next-20151203 (dcccebc - Add linux-next specific files
> for 20151203)
> 
> Nor do I see it in any branch in:
>  * git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
> Is this the right git?

Yes, that's right.  When I say "applied", it means I applied it to my
local repository.  I am careful not to allude to the patch being
"pushed".  There is no guarantee when this will happen, since it
completly depends how busy the subsystem is.  For Backlight, as the
churn is low, the impetus for pushing is pretty low.

It has been "pushed" now though.

> By the way this repository has a git tag called "HEAD", which is a bit
> annoying since every time I "git remote update" from here, git gets
> confused until I manually delete it (git tag -d HEAD).

Thanks for letting me know.  I have now removed this tag.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-07  9:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-18 17:12 [PATCH v5] pwm-backlight: Avoid backlight flicker when probed from DT Philipp Zabel
2015-11-24 16:26 ` Lee Jones
2015-12-07  4:20   ` Daniel Kurtz
2015-12-07  9:35     ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).