History

backlight: gpio-backlight: Correct initial power state handling

The default-on property - or the def_value via legacy pdata) should be handled as: if it is 1, the backlight must be enabled (kept enabled) if it is 0, the backlight must be disabled (kept disabled) This only works for the case when default-on is set. If it is not set then the brightness of the backlight is set to 0. Now if the backlight is enabled by external driver (graphics) the backlight will stay disabled since the brightness is configured as 0. The backlight will not turn on. In order to minimize screen flickering during device boot: The initial brightness should be set to 1. If booted in non DT mode or no phandle link to the backlight node: follow the def_value/default-on to select UNBLANK or POWERDOWN If in DT boot we have phandle link then leave the GPIO in a state which the bootloader left it and let the user of the backlight to configure it further.

Peter Ujfalusi committed 7 years ago

Commit ec665b71 parent 28a1d721 file · +20 −4Browse files

Unified · Split

drivers/video/backlight/gpio_backlight.c+20−4
@@ -59,13 +59,11 @@ static int gpio_backlight_probe_dt(struct platform_device *pdev, · 58 unmodified lines
5959 struct gpio_backlight *gbl)
6060 {
6161 struct device *dev = &pdev->dev;
62− enum gpiod_flags flags;
6362 int ret;
6463
6564 gbl->def_value = device_property_read_bool(dev, "default-on");
66− flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
6765
68− gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
66+ gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS);
6967 if (IS_ERR(gbl->gpiod)) {
7068 ret = PTR_ERR(gbl->gpiod);
7169
@@ -79,6 +77,22 @@ static int gpio_backlight_probe_dt(struct platform_device *pdev, · 7 unmodified lines
7977 return 0;
8078 }
8179
80+static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl)
81+{
82+ struct device_node *node = gbl->dev->of_node;
83+
84+ /* Not booted with device tree or no phandle link to the node */
85+ if (!node || !node->phandle)
86+ return gbl->def_value ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
87+
88+ /* if the enable GPIO is disabled, do not enable the backlight */
89+ if (gpiod_get_value_cansleep(gbl->gpiod) == 0)
90+ return FB_BLANK_POWERDOWN;
91+
92+ return FB_BLANK_UNBLANK;
93+}
94+
95+
8296 static int gpio_backlight_probe(struct platform_device *pdev)
8397 {
8498 struct gpio_backlight_platform_data *pdata =
@@ -136,7 +150,9 @@ static int gpio_backlight_probe(struct platform_device *pdev) · 51 unmodified lines
136150 return PTR_ERR(bl);
137151 }
138152
139− bl->props.brightness = gbl->def_value;
153+ bl->props.power = gpio_backlight_initial_power_state(gbl);
154+ bl->props.brightness = 1;
155+
140156 backlight_update_status(bl);
141157
142158 platform_set_drvdata(pdev, bl);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t