Skip to content

Commit 66abb99

Browse files
superm1alexdeucher
authored andcommitted
drm/amd/display: Fix AMDGPU_MAX_BL_LEVEL value
[Why] commit 16dc8bc ("drm/amd/display: Export full brightness range to userspace") adjusted the brightness range to scale to larger values, but missed updating AMDGPU_MAX_BL_LEVEL which is needed to make sure that scaling works properly with custom brightness curves. [How] As the change for max brightness of 0xFFFF only applies to devices supporting DC, use existing DC define MAX_BACKLIGHT_LEVEL. Fixes: 16dc8bc ("drm/amd/display: Export full brightness range to userspace") Acked-by: Alex Deucher <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit 5b85204) Cc: [email protected]
1 parent 31135cc commit 66abb99

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4718,16 +4718,16 @@ static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
47184718
return 1;
47194719
}
47204720

4721-
/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */
4721+
/* Rescale from [min..max] to [0..MAX_BACKLIGHT_LEVEL] */
47224722
static inline u32 scale_input_to_fw(int min, int max, u64 input)
47234723
{
4724-
return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max - min);
4724+
return DIV_ROUND_CLOSEST_ULL(input * MAX_BACKLIGHT_LEVEL, max - min);
47254725
}
47264726

4727-
/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
4727+
/* Rescale from [0..MAX_BACKLIGHT_LEVEL] to [min..max] */
47284728
static inline u32 scale_fw_to_input(int min, int max, u64 input)
47294729
{
4730-
return min + DIV_ROUND_CLOSEST_ULL(input * (max - min), AMDGPU_MAX_BL_LEVEL);
4730+
return min + DIV_ROUND_CLOSEST_ULL(input * (max - min), MAX_BACKLIGHT_LEVEL);
47314731
}
47324732

47334733
static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *caps,
@@ -4947,7 +4947,7 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
49474947
drm_dbg(drm, "Backlight caps: min: %d, max: %d, ac %d, dc %d\n", min, max,
49484948
caps->ac_level, caps->dc_level);
49494949
} else
4950-
props.brightness = props.max_brightness = AMDGPU_MAX_BL_LEVEL;
4950+
props.brightness = props.max_brightness = MAX_BACKLIGHT_LEVEL;
49514951

49524952
if (caps->data_points && !(amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE))
49534953
drm_info(drm, "Using custom brightness curve\n");

0 commit comments

Comments
 (0)