drm/msm: fix brightness level mapping
The current brightness level mapping does not correctly map the brightness level range from user space to the range supported by the panel. For example if the max user brightness reported is 4095, and panel backlight range is 0-255. Then user is expected to be able to set brightness in range from 0-4095, but current logic truncates at bl-max (255). Moreover it doesn't take into account bl-min. Fix logic such that the brightness range set by user correctly scales to the backlight level from panel. Bug: 139263611 Change-Id: Ic70909af63fb5b66ebc1434477f2fc41a785ce1f Signed-off-by: Adrian Salido <salidoa@google.com>
This commit is contained in:
parent
97635aec45
commit
dd4123dba7
@ -115,17 +115,21 @@ static int sde_backlight_device_update_status(struct backlight_device *bd)
|
||||
brightness = 0;
|
||||
|
||||
display = (struct dsi_display *) c_conn->display;
|
||||
if (brightness > display->panel->bl_config.bl_max_level)
|
||||
brightness = display->panel->bl_config.bl_max_level;
|
||||
if (brightness > display->panel->bl_config.brightness_max_level)
|
||||
brightness = display->panel->bl_config.brightness_max_level;
|
||||
if (brightness > c_conn->thermal_max_brightness)
|
||||
brightness = c_conn->thermal_max_brightness;
|
||||
|
||||
/* map UI brightness into driver backlight level with rounding */
|
||||
bl_lvl = mult_frac(brightness, display->panel->bl_config.bl_max_level,
|
||||
display->panel->bl_config.brightness_max_level);
|
||||
if (brightness) {
|
||||
int bl_min = display->panel->bl_config.bl_min_level ? : 1;
|
||||
int bl_range = display->panel->bl_config.bl_max_level - bl_min;
|
||||
|
||||
if (!bl_lvl && brightness)
|
||||
bl_lvl = 1;
|
||||
/* map UI brightness into driver backlight level rounding it */
|
||||
bl_lvl = bl_min + DIV_ROUND_CLOSEST((brightness - 1) * bl_range,
|
||||
display->panel->bl_config.brightness_max_level - 1);
|
||||
} else {
|
||||
bl_lvl = 0;
|
||||
}
|
||||
|
||||
if (!display->panel->bl_config.allow_bl_update) {
|
||||
display->panel->bl_config.unset_bl_level = bl_lvl;
|
||||
|
Loading…
Reference in New Issue
Block a user