[RFC] backlight: convert linear to gamma float brightness #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue we have with our device is that the brightness of the panel is very low most of the time when we control it
through the Android UI.
I'm not totally convinced that this patch is the best solution, that's why I added RFC tag in the title in order to open a discussion and maybe have your opinion on that.
The brightness controller in Android frameworks convert initial value from the slider to a new value not linear [1].
The value is modified by
convertGammaToLinearFloat
.The current implementation in light HAL doesn't take account the none linearity of this incoming value, these values are logarithmic [2].
In order to get back a linear value, one solution is to re-convert the incoming value to a linear form:
convertLinearToGammaFloat
.By doing this the brightness follow in a "normal way" the Android UI slider.
The implementation
convertLinearToGammaFloat
has been highly inspired by the one in BrightnessUtils [3].[1] https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-12.0.0_r34/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessController.java#354
[2] https://tunjid.medium.com/reverse-engineering-android-pies-logarithmic-brightness-curve-ecd41739d7a2
[3] https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-12.0.0_r34/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java#129
Thanks