All of lore.kernel.org
 help / color / mirror / Atom feed
* [Question] gpio-backlight: Is initial power state derived correctly?
@ 2025-02-18 13:28 Thorsten Maerz
  0 siblings, 0 replies; only message in thread
From: Thorsten Maerz @ 2025-02-18 13:28 UTC (permalink / raw)
  To: dri-devel


I am struggling with the gpio-backlight module, it starts up
with a black screen, though the devicetree states "default-on":
        backlight {
                compatible = "gpio-backlight";
                gpios = <0x31 0x05 0x00>;
                default-on;
        };

After bootup, the content of "/sys/class/backlight/backlight/bl_power"
is "4", meaning BACKLIGHT_POWER_OFF. The screen is black.

(The backlight devicetree section is working, I can switch on
backlight by writing "0" (BACKLIGHT_POWER_ON) to bl_power.)

It looks to me as if the logic for detecting the devicetree
is reversed:

See drivers/video/backlight/gpio_backlight.c :
---8<--- start
        def_value = device_property_read_bool(dev, "default-on");
[...]
        /* Set the initial power state */
        if (!of_node || !of_node->phandle)
                /* Not booted with device tree or no phandle link to the node */
                bl->props.power = def_value ? BACKLIGHT_POWER_ON
                                            : BACKLIGHT_POWER_OFF;
        else if (gpiod_get_value_cansleep(gbl->gpiod) == 0)
                bl->props.power = BACKLIGHT_POWER_OFF;
        else
                bl->props.power = BACKLIGHT_POWER_ON;
--->8--- end

1. "def_value" is read from the devicetree.
2. "def_value" is evaluated after "if (!of_node || !of_node->phandle)"

Shouldn't the logic be the other way round?

        if (of_node && of_node->phandle)
                /* booted with device tree */
                bl->props.power = def_value ? BACKLIGHT_POWER_ON
                                            : BACKLIGHT_POWER_OFF;
        else [...]
                /* Not booted with device tree or no phandle link to the node */

--
Best regards,
Thorsten

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-18 13:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-18 13:28 [Question] gpio-backlight: Is initial power state derived correctly? Thorsten Maerz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.