dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] backlight: ktd253: Bring up in a known state
@ 2021-01-26 21:32 Linus Walleij
  2021-02-05 17:27 ` Daniel Thompson
  2021-02-09 14:10 ` Lee Jones
  0 siblings, 2 replies; 4+ messages in thread
From: Linus Walleij @ 2021-01-26 21:32 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, dri-devel

The KTD253 backlight might already be on when the driver
is probed: then we don't really know what the current
ratio is and all light intensity settings will be off
relative to what it was at boot.

To fix this, bring up the backlight OFF then move it to
the default backlight from there so we know the state.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/video/backlight/ktd253-backlight.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/video/backlight/ktd253-backlight.c b/drivers/video/backlight/ktd253-backlight.c
index e3fee3f1f582..d7b287cffd5c 100644
--- a/drivers/video/backlight/ktd253-backlight.c
+++ b/drivers/video/backlight/ktd253-backlight.c
@@ -137,15 +137,7 @@ static int ktd253_backlight_probe(struct platform_device *pdev)
 		brightness = max_brightness;
 	}
 
-	if (brightness)
-		/* This will be the default ratio when the KTD253 is enabled */
-		ktd253->ratio = KTD253_MAX_RATIO;
-	else
-		ktd253->ratio = 0;
-
-	ktd253->gpiod = devm_gpiod_get(dev, "enable",
-				       brightness ? GPIOD_OUT_HIGH :
-				       GPIOD_OUT_LOW);
+	ktd253->gpiod = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
 	if (IS_ERR(ktd253->gpiod)) {
 		ret = PTR_ERR(ktd253->gpiod);
 		if (ret != -EPROBE_DEFER)
@@ -153,6 +145,8 @@ static int ktd253_backlight_probe(struct platform_device *pdev)
 		return ret;
 	}
 	gpiod_set_consumer_name(ktd253->gpiod, dev_name(dev));
+	/* Bring backlight to a known off state */
+	msleep(KTD253_T_OFF_MS);
 
 	bl = devm_backlight_device_register(dev, dev_name(dev), dev, ktd253,
 					    &ktd253_backlight_ops, NULL);
-- 
2.29.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] backlight: ktd253: Bring up in a known state
  2021-01-26 21:32 [PATCH] backlight: ktd253: Bring up in a known state Linus Walleij
@ 2021-02-05 17:27 ` Daniel Thompson
  2021-02-09 10:10   ` Linus Walleij
  2021-02-09 14:10 ` Lee Jones
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Thompson @ 2021-02-05 17:27 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Jingoo Han, Lee Jones, dri-devel

On Tue, Jan 26, 2021 at 10:32:00PM +0100, Linus Walleij wrote:
> The KTD253 backlight might already be on when the driver
> is probed: then we don't really know what the current
> ratio is and all light intensity settings will be off
> relative to what it was at boot.
> 
> To fix this, bring up the backlight OFF then move it to
> the default backlight from there so we know the state.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Hmnnn... horid, since the backlight will flicker during boot,
but I recall that this bit of hardware is pretty horid anyway
so it is not easily avoided.

Therefore, slightly grudgingly,
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


Daniel.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] backlight: ktd253: Bring up in a known state
  2021-02-05 17:27 ` Daniel Thompson
@ 2021-02-09 10:10   ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2021-02-09 10:10 UTC (permalink / raw)
  To: Daniel Thompson; +Cc: Jingoo Han, Lee Jones, open list:DRM PANEL DRIVERS

On Fri, Feb 5, 2021 at 6:27 PM Daniel Thompson
<daniel.thompson@linaro.org> wrote:
> On Tue, Jan 26, 2021 at 10:32:00PM +0100, Linus Walleij wrote:
> > The KTD253 backlight might already be on when the driver
> > is probed: then we don't really know what the current
> > ratio is and all light intensity settings will be off
> > relative to what it was at boot.
> >
> > To fix this, bring up the backlight OFF then move it to
> > the default backlight from there so we know the state.
> >
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> Hmnnn... horid, since the backlight will flicker during boot,
> but I recall that this bit of hardware is pretty horid anyway
> so it is not easily avoided.
>
> Therefore, slightly grudgingly,
> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>

Thanks, and I agree, this makes things better than before though.

The actual problem translates to the generic problem of bringing
misc boot-time conditions over to the kernel, and handing over
any type of hardware in a half-initialized state. We don't really have
a solution to that yet, many have tried.

For this specific case, one can imagine a "kinetic,boot-time-brightness"
(or similar) DT property, with the idea that the boot loader or
DT author knows what to put in there. I put that on my TODO
(the code in this patch will still needed if that property isn't provided).

Yours,
Linus Walleij
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] backlight: ktd253: Bring up in a known state
  2021-01-26 21:32 [PATCH] backlight: ktd253: Bring up in a known state Linus Walleij
  2021-02-05 17:27 ` Daniel Thompson
@ 2021-02-09 14:10 ` Lee Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2021-02-09 14:10 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Jingoo Han, Daniel Thompson, dri-devel

On Tue, 26 Jan 2021, Linus Walleij wrote:

> The KTD253 backlight might already be on when the driver
> is probed: then we don't really know what the current
> ratio is and all light intensity settings will be off
> relative to what it was at boot.
> 
> To fix this, bring up the backlight OFF then move it to
> the default backlight from there so we know the state.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/video/backlight/ktd253-backlight.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)

Grudgingly applied, thanks.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2021-02-09 14:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 21:32 [PATCH] backlight: ktd253: Bring up in a known state Linus Walleij
2021-02-05 17:27 ` Daniel Thompson
2021-02-09 10:10   ` Linus Walleij
2021-02-09 14:10 ` 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 NNTP newsgroup(s).