SystemUI: Option to use linear scale in BrightnessController

BrightnessController switched to a log scale control after pie
(585ff988) because it matches the brightness perceived by human
eyes. However, if a panel uses LightState to control backlight
brightness and has a backlight max brightness > 255 (e.g. 2047
or 4095), changing brightness in the lower range of the slider
results in a very uneven brightness transition.

LightState.color limits each channel to 8 bits (0-255), so the
normalized brightness gamma value is first converted to a range
of [0, 255], and then linear interpolated to whatever the panel
max brightness is in light HAL. Due to the nature of HLG used
in the conversion, a small increase in lower range of backlight
brightness results in a much more significant increase in gamma
than a small increase in higher range of backlight brightness
does. Therefore, the lost accuracy in the first integer
conversion to [0, 255] makes brightness transition uneven in
lower range.

This patch adds an option to report linear value to light HAL.
Light HAL can then handle the linear-to-gamma conversion and
linear interpolation all together with minimum accuracy loss.
It uses 585ff988 as reference while adapting to the newer
refactored code.

Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
Change-Id: If219fd7622ff9931aab07588316418963ca5bb57
Signed-off-by: Joey Huab <joey@evolution-x.org>
3 files changed