power: Implement linear auto-brightness
The current implementation of auto-brightness has two problems:
- The brightness updates are quite unstable, with the value reacting too quickly to changes in ALS.
- In cases where ambient light is low, the code tends to set the brightness value to zero and gets stuck there (with a division by zero error for ambient_norm_value):
gsd-power[4201]: Setting brightness from ambient 0,0%, brightness: 0.000000, ambient_percentage_old: 0.000000, ambient_norm_value: inf
This new implementation is characterized by:
- A brightness update that adapts to changes in the environment: rapid if brighter, slow if darker. This allows for a stable brightness even with highly unstable ambient light.
- The ability for vendors to define their own mappings between ambient light and screen brightness (more suitable for phones) instead of the default linear function.
Origin work by arpio alex@familyrutz.com.
Edited by Cédric Bellegarde