[Question] gpio-backlight: Is initial power state derived correctly?

Thorsten Maerz info at netztorte.de
Tue Feb 18 13:28:43 UTC 2025


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


More information about the dri-devel mailing list