Skip to content

Commit 9c28830

Browse files
lotheacalexdeucher
authored andcommitted
drm/amd/display: fix initial backlight brightness calculation
DIV_ROUND_CLOSEST(x, 100) returns either 0 or 1 if 0<x<=100, so the division needs to be performed after the multiplication and not the other way around, to properly scale the value. Fixes: 8b5f3a2 ("drm/amd/display: Fix default DC and AC levels") Signed-off-by: Lauri Tirkkonen <[email protected]> Cc: [email protected] Reviewed-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 1f02f20 commit 9c28830

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4983,9 +4983,9 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
49834983
caps = &dm->backlight_caps[aconnector->bl_idx];
49844984
if (get_brightness_range(caps, &min, &max)) {
49854985
if (power_supply_is_system_supplied() > 0)
4986-
props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps->ac_level, 100);
4986+
props.brightness = DIV_ROUND_CLOSEST((max - min) * caps->ac_level, 100);
49874987
else
4988-
props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps->dc_level, 100);
4988+
props.brightness = DIV_ROUND_CLOSEST((max - min) * caps->dc_level, 100);
49894989
/* min is zero, so max needs to be adjusted */
49904990
props.max_brightness = max - min;
49914991
drm_dbg(drm, "Backlight caps: min: %d, max: %d, ac %d, dc %d\n", min, max,

0 commit comments

Comments
 (0)