PINE64
Failure in setting the display backlight with Armbian 5.86 [SOLVED] - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: Pinebook (https://forum.pine64.org/forumdisplay.php?fid=76)
+--- Forum: Linux on Pinebook (https://forum.pine64.org/forumdisplay.php?fid=79)
+--- Thread: Failure in setting the display backlight with Armbian 5.86 [SOLVED] (/showthread.php?tid=7582)



Failure in setting the display backlight with Armbian 5.86 [SOLVED] - wlad - 06-11-2019

I tested both current Armbian mainline images (Armbian_5.86_Pinebook-a64_Ubuntu_bionic_next_4.19.38_desktop and Armbian_5.86_Pinebook-a64_Debian_stretch_next_4.19.38) with my Pinebook 11.6" shipped in May '19 and both images have issues with the display brightness settings. 

Indication: After boot up, the backlight is set to maximum brightness and resetting it to other values in /sys/class/backlight/backlight/brightness (or via desktop power manager tool) shows no effect. The brightness level stays the same, although 'cat  /sys/class/backlight/backlight/brightness' returns changed values.

Solution: I managed to work around the issue by modifying the sun50i-a64-pinebook.dtb in /boot/dtb/allwinner/ in the following way:

(You can convert the dtb file to human-readable dts-format with 'dtc -I dtb -O dts /boot/dtb/allwinner/sun50i-a64-pinebook.dtb > converted.dts')

Initial content was:

Code:
[...]
backlight {
compatible = "pwm-backlight";
   pwms = < 0x43 0x00 0xc350 0x01 >;
brightness-levels = < 0x0 0x5 0xa 0xf 0x14 0x1e 0x28 0x37 0x46 0x55 0x64 >;
default-brightness-level = < 0x2 >;
  enable-gpios = < 0x22 0x03 0x17 0x00 >;
phandle = < 0x98 >;
};
[...]

After I removed the line with "phandle = < 0x98 >;", setting backlight brightness worked again. Unfortunately, the levels were reversed (1 meaning brightest, 9 meaning darkest, 0 and 10 turned off the backlight completely). Thus, I have changed the line with "brightness-levels" with inversed level values.

Overall, the final content of the dts file is:
Code:
[...]
backlight {
  compatible = "pwm-backlight";
   pwms = < 0x43 0x00 0xc350 0x01 >;
  brightness-levels = < 0x64 0x55 0x46 0x37 0x28 0x1e 0x14 0xf 0xa 0x5 0x0 >;
  default-brightness-level = < 0x2 >;
  enable-gpios = < 0x22 0x03 0x17 0x00 >;
};
[...]

In order to apply the changes, you have to compile the dts file back to dtb format and overwrite the original file in /boot/dtb/allwinner/. We will backup the original file before overwriting, in case after the reboot you end up with a dark display and need to boot from sd-card in order to undo the changes.
Code:
sudo cp /boot/dtb/allwinner/sun50i-a64-pinebook.dtb /boot/dtb/allwinner/sun50i-a64-pinebook.dtb.bac
sudo dtc -I dts -O dtb converted.dts > /boot/dtb/allwinner/sun50i-a64-pinebook.dtb

Please note, that this is only a shallow workaround. I do not know, what the effect of the phandle line was and why it works to set brightness without it. All I can say is that until now, I saw no negative side effects of this "solution".