Table of Contents | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
1. Overview
This application note explains how to enable the display backlight on and off, in those hardware design where the backlight is controlled by a GPIO and, therefore, can have one of the two states: off and on.
Note the display backlight can be controlled independently of any display software. That is, the backlight may be turned on and off regardless of whether or not your BSP configuration has a display device driver (and an upper-layer GUI stack) enabled.
2. Understanding Implementation
Control of the LCD backlight is managed by the standard Linux driver gpio_backlight.c
residing in the linux/drivers/video/backlight
directory in the kernel tree. The driver is enabled at the build time by the CONFIG_BACKLIGHT_GPIO
kernel config option.
...
Code Block |
---|
backlight {
compatible = "gpio-backlight";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_backlight>;
gpios = <&gpio2 31 GPIO_ACTIVE_HIGH>;
};
|
Note that in this configuration the backlight is turned off at system startup.
...
Code Block |
---|
backlight {
compatible = "gpio-backlight";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_backlight>;
gpios = <&gpio2 31 GPIO_ACTIVE_HIGH>;
default-on;
};
|
3. Controlling Backlight
To turn the LCD backlight on, run the following command:
Code Block |
---|
/ # echo 0 > /sys/class/backlight/backlight/bl_power
|
To turn the LCD backlight off, run the following command:
...