Skip to content

Fix minimal brightness on OLED screens

Bartosz Taudul requested to merge wolfpld/powerdevil:master into master

When OLED screen brightness is set to zero, the display becomes completely black. Unlike LCD screens, OLED pixels are self-lit, so if the brightness becomes zero, there is no light emitted at all.

This can be fixed by clamping the minimum brightness value to 1. OLED screens will retain contents, even if barely visible. LCD screens may be slightly brighter on the lowest setting.

Gnome uses similar logic: https://gitlab.gnome.org/GNOME/gnome-settings-daemon/-/blob/e30c9cdea5dbc0bf5202142491a13213f3145c92/plugins/power/gsd-backlight.c#L233

The best place I found for this is BrightnessLogic::stepToValue(), the implementation of which had to be split to only perform clamping for screen brightness, but not for keyboard backlight brightness.

stepToValue() is only called from increased() and decreased(). The only call path to both these functions is action() <- BackendInterface::calculateNextStep() <- PowerDevilUPowerBackend::brightnessKeyPressed(). This last function is only called from BrightnessControl's increaseBrightness() and decreaseBrightness() and KeyboardBrightnessControl's increaseKeyboardBrightness(), decreaseKeyboardBrightness() and toggleKeyboardBacklight(). All these functions are only called in response to keyboard shortcut presses issued by the user.

Limiting clamping to user key interaction should minimize possible impact on other functionality that may actually want to set zero brightness, for example to disable display when the laptop lid is closed. A comment in DimDisplay::onIdleTimeout() suggests that such cases could be possible.

The OSD display still displays the minimum brightness as "0%", even though the actual set value is 1. I have not checked why it works this way.


See https://cdn.discordapp.com/attachments/745210855725203516/1071241573842567209/oled.mp4 for comparison of the new behavior (first part) and the old behavior (second part).

Merge request reports