How to set the brightness of a screen#
It is possible to set the brightness of a LVDS screen using the interface in
the sysfs
. This interface consists mainly in 4 files:
/sys/class/backlight/<backlight>/bl_power
, which is RW and gives the ability to control the backlight power./sys/class/backlight/<backlight>/brightness
, which is RW and gives the ability to set the brightness for this backlight. The value must be between 0 and the max_brightness. If this file is read, it returns the value of the brightness stored in the driver./sys/class/backlight/<backlight>/actual_brightnes
, which is RO and displays the value of the brightness by querying the hardware./sys/class/backlight/<backlight>/max_brightness
, which is RO and returns the maximum value of the brightness we can set in brightness file.
The <backlight>
directory name depends on the SOM you use. With an Intel
SOM, it is intel_backlight
, with an ARM SOM it depends on the LVDS device
tree overlay which has been loaded. It could be lcd0_backlight
or
lcd1_backlight
.
Set the brightness#
The process is simple:
read the maximum value you can set:
$ cat /sys/class/backlight/<backlight>/max_brightness
set the wanted value
$ echo 100 > /sys/class/backlight/<backlight>/brightness
By default the value of the brightness should be its maximum value. On Intel
SOM, this value is 96000
, on ARM SOM this value is 255
.
Turn off/on the backlight#
It is possible to completely turn off the backlight. It is done with the following command:
$ echo 4 > /sys/class/backlight/<backlight>/bl_power
Then it is possible to turn it on again doing:
$ echo 0 > /sys/class/backlight/<backlight>/bl_power
The brightness of the screen will be the same that before turning off the backlight.
Note
bl_power
file has no effect on Intel SOM.
Restore the brightness after a reboot#
It is automatically done by the systemd service systemd-backlight@.service
,
which stores the value of the brightness when the service is stopped, and loads
this value when the service is started. This value is stored in the directory
/var/lib/systemd/backlight/
.
By default, the systemd-backlight@.service
restores a value equal to at
least 5% of the max_brightness value even if it has been set to a lower value.
On Intel SOM, this value is 4800, on ARM SOM this value is 12.