linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: dri-devel@lists.freedesktop.org
Cc: linux-fbdev@vger.kernel.org, "Marek Vasut" <marex@denx.de>,
	"Daniel Thompson" <daniel.thompson@linaro.org>,
	"Meghana Madhyastha" <meghana.madhyastha@gmail.com>,
	"Noralf Trønnes" <noralf@tronnes.org>,
	"Sean Paul" <seanpaul@chromium.org>,
	"Thierry Reding" <treding@nvidia.com>
Subject: [PATCH] video: backlight: Only set maximum brightness for gpio-backlight
Date: Thu,  8 Jul 2021 11:10:58 +0200	[thread overview]
Message-ID: <20210708091058.56317-1-marex@denx.de> (raw)

The note in c2adda27d202f ("video: backlight: Add of_find_backlight helper
in backlight.c") says that gpio-backlight uses brightness as power state.
Other backlight drivers do not, so limit this workaround to gpio-backlight.

This fixes the case where e.g. pwm-backlight can perfectly well be set to
brightness 0 on boot in DT, which without this patch leads to the display
brightness to be max instead of off.

Fixes: c2adda27d202f ("video: backlight: Add of_find_backlight helper in backlight.c")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Meghana Madhyastha <meghana.madhyastha@gmail.com>
Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Thierry Reding <treding@nvidia.com>
---
 drivers/video/backlight/backlight.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 537fe1b376ad7..dfb66171dec41 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -676,6 +676,7 @@ EXPORT_SYMBOL(of_find_backlight_by_node);
 static struct backlight_device *of_find_backlight(struct device *dev)
 {
 	struct backlight_device *bd = NULL;
+	bool is_gpio_backlight = false;
 	struct device_node *np;
 
 	if (!dev)
@@ -685,6 +686,8 @@ static struct backlight_device *of_find_backlight(struct device *dev)
 		np = of_parse_phandle(dev->of_node, "backlight", 0);
 		if (np) {
 			bd = of_find_backlight_by_node(np);
+			is_gpio_backlight =
+				of_device_is_compatible(np, "gpio-backlight");
 			of_node_put(np);
 			if (!bd)
 				return ERR_PTR(-EPROBE_DEFER);
@@ -692,7 +695,7 @@ static struct backlight_device *of_find_backlight(struct device *dev)
 			 * Note: gpio_backlight uses brightness as
 			 * power state during probe
 			 */
-			if (!bd->props.brightness)
+			if (is_gpio_backlight && !bd->props.brightness)
 				bd->props.brightness = bd->props.max_brightness;
 		}
 	}
-- 
2.30.2


             reply	other threads:[~2021-07-08  9:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08  9:10 Marek Vasut [this message]
2021-07-09 11:03 ` [PATCH] video: backlight: Only set maximum brightness for gpio-backlight Daniel Thompson
2021-07-09 13:19   ` Marek Vasut
2021-07-09 13:25     ` Noralf Trønnes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210708091058.56317-1-marex@denx.de \
    --to=marex@denx.de \
    --cc=daniel.thompson@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=meghana.madhyastha@gmail.com \
    --cc=noralf@tronnes.org \
    --cc=seanpaul@chromium.org \
    --cc=treding@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).