LCD Backlight
LCD backlight usually involves a power supply, PWM controller, and some enable signals. For example on PinePhone, it looks like this:
Linux
On my devices PWM
controller is configured for 20kHz frequency in DTS
(sun50i-a64-pinephone.dts
):
backlight: backlight { compatible = "pwm-backlight"; pwms = <&r_pwm 0 50000 PWM_POLARITY_INVERTED>; brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>; default-brightness-level = <4>; enable-gpios = <&pio 7 10 GPIO_ACTIVE_HIGH>; /* PH10 */ };
Here
50000
means a period of 50000 ns. Frequency thus is
1e9 / 50000 = 20kHz
. You can experiment with differnt frequencies
by changing this number.
You can control the backlight from userspace via
sysfs
(to set backlight intensity) or via KMS atomic modesetting
API (it's enabled/disabled automatically when suspending the display
pipeline).
Backlight intensity
Setting the backlight intensity always works via
sysfs
:
max=`cat /sys/class/backlight/backlight/max_brightness` echo 0 > /sys/class/backlight/backlight/brightness echo $max > /sys/class/backlight/backlight/brightness # and anything in between
Brightness PWM duty cycles for the brightness levels are set in the DTS file. See above. You can add more, or change the scale.
Power saving
Be aware that LCD backlight and LCD panel controller and LCD panel interface are all separate parts of the display pipeline. If you turn off the backlight via sysfs, you're just turning off the light, but rest of the pipeline is still in full gear.
To get maximum power savings you need to shut down the entire
pipeline using DPMS via KMS API. If you're using Linux console you can do that
via echo 3 > /sys/class/graphics/fb0/blank
. This will not work
if you're using other KMS based app. (eg. Xorg server) The app needs to tell the
kernel to shutdown the pipeline itself.