OLED brightness in Linux

Recently I've got a new laptop with OLED panel only to find out that brightness control for OLED panels is not yet supported in Linux.

Archlinux wiki page mentions using gamma ramp for controlling perceived brightness using hackish userspace tools (icc-brightness), so my first thought was to implement a hack for i915 driver to expose backlight interface that actually adjusts gamma ramp.

So I went to #dri-devel to ask around whether this idea sounds too crazy and it turned out that there are better ways than using gamma ramp.

Basically if you use gamma ramp you essentially reduce dynamic range, i.e. if you have 8 bits per pixel at 50% brightness you would get 7 bit, at 25% - 6 bit and that will result in banding artefacts at low brightness levels.

To overcome that issue OLED panels actually have an interface to control brightness. There are at least 2 competing "standards" - VESA and Intel proprietary. First one is already supported by i915 driver while latter is not. Unfortunately it's the only interface that my panel supports.

Lyude Paul from #dri-devel pointed me to ~6 month old patch [1] that added support for Intel proprietary interface. I made a hacking port to 5.7 to see whether it works - and it indeed does, now brightness can be controlled using regular means and it stays the same even if I switch to VT (it resets to full brightness if you use userspace hacks).

Later Lyude provided cleaned up patches, I rebased them onto 5.7, see [2]. As far as I understand Lyude plans to submit them upstream later.

I tried to update archlinux wiki with this info, but unfortunately my change was reverted. 

[1] https://patchwork.freedesktop.org/patch/334989/?series=67595&rev=2

Comments

Popular posts from this blog

Access point with Raspberry Pi and rtl8192cu dongle

Wayland and software rendering