Revert "drm/amd/display: Fix AMDGPU_MAX_BL_LEVEL value"
PATCH 1/1 Revert "drm/amd/display: Fix AMDGPU_MAX_BL_LEVEL value"
From: Mario Limonciello <[email protected]>
This reverts commit 66abb996999de0d440a02583a6e70c2c24deab45. This broke custom brightness curves but it wasn't obvious because of other related changes. Custom brightness curves are always from a 0-255 input signal. The correct fix was to fix the default value which was done by [1].
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -5
@@ -4740,16 +4740,16 @@ static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,return 1 ; } -/* Rescale from [min..max] to [0..MAX_BACKLIGHT_LEVEL] */ +/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */ static inline u32 scale_input_to_fw (int min,int max,u64 input) { -return DIV_ROUND_CLOSEST_ULL (input *MAX_BACKLIGHT_LEVEL , max - min); +return DIV_ROUND_CLOSEST_ULL (input *AMDGPU_MAX_BL_LEVEL , max - min); } -/* Rescale from [0..MAX_BACKLIGHT_LEVEL] to [min..max] */ +/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */ static inline u32 scale_fw_to_input (int min,int max,u64 input) { -return min +DIV_ROUND_CLOSEST_ULL (input * (max - min),MAX_BACKLIGHT_LEVEL ); +return min +DIV_ROUND_CLOSEST_ULL (input * (max - min),AMDGPU_MAX_BL_LEVEL ); } static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *caps,
@@ -4977,7 +4977,7 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)drm_dbg (drm,"Backlight caps: min: %d, max: %d, ac %d, dc %d\n" , min, max, caps->ac_level, caps->dc_level); }else - props.brightness = props.max_brightness =MAX_BACKLIGHT_LEVEL ; + props.brightness = props.max_brightness =AMDGPU_MAX_BL_LEVEL ;if (caps->data_points && !(amdgpu_dc_debug_mask &DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE ))drm_info (drm,"Using custom brightness curve\n" );
Signature · 1 line
2.43.0
Quoted 42 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
This reverts commit
66abb996999de0d440a02583a6e70c2c24deab45. This broke custom brightness curves but it wasn't obvious because of other related changes. Custom brightness curves are always from a 0-255 input signal. The correct fix was to fix the default value which was done by [1].Link https://lore.kernel.org/amd-gfx/[email protected]/T/#m69f875a7e69aa22df3370b3e3a9e69f4a61fdaf2 open hereSigned-off-by Mario Limonciello <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4
-4@@ -4740,16 +4740,16 @@ static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,return 1 ; } -/* Rescale from [min..max] to [0..MAX_BACKLIGHT_LEVEL] */ +/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */ static inline u32 scale_input_to_fw (int min,int max,u64 input) { -return DIV_ROUND_CLOSEST_ULL (input *MAX_BACKLIGHT_LEVEL , max - min); +return DIV_ROUND_CLOSEST_ULL (input *AMDGPU_MAX_BL_LEVEL , max - min); } -/* Rescale from [0..MAX_BACKLIGHT_LEVEL] to [min..max] */ +/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */ static inline u32 scale_fw_to_input (int min,int max,u64 input) { -return min +DIV_ROUND_CLOSEST_ULL (input * (max - min),MAX_BACKLIGHT_LEVEL ); +return min +DIV_ROUND_CLOSEST_ULL (input * (max - min),AMDGPU_MAX_BL_LEVEL ); } static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *caps,
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector) · line 4980
Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4977,7 +4977,7 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)drm_dbg (drm,"Backlight caps: min: %d, max: %d, ac %d, dc %d\n" , min, max, caps->ac_level, caps->dc_level); }else - props.brightness = props.max_brightness =MAX_BACKLIGHT_LEVEL ; + props.brightness = props.max_brightness =AMDGPU_MAX_BL_LEVEL ;
This bottom hunk doesn't need to revert, that one is fine. The other two need to be reverted though to fix this issue.
Alex Deucher
Acked-byQuoted 42 lines · Mario
Quoted 40 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
This reverts commit
66abb996999de0d440a02583a6e70c2c24deab45. This broke custom brightness curves but it wasn't obvious because of other related changes. Custom brightness curves are always from a 0-255 input signal. The correct fix was to fix the default value which was done by [1].Link https://lore.kernel.org/amd-gfx/[email protected]/T/#m69f875a7e69aa22df3370b3e3a9e69f4a61fdaf2 open hereSigned-off-by Mario Limonciello <[email protected]>--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4
-4@@ -4740,16 +4740,16 @@ static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,return 1 ; } -/* Rescale from [min..max] to [0..MAX_BACKLIGHT_LEVEL] */ +/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */ static inline u32 scale_input_to_fw (int min,int max,u64 input) { -return DIV_ROUND_CLOSEST_ULL (input *MAX_BACKLIGHT_LEVEL , max - min); +return DIV_ROUND_CLOSEST_ULL (input *AMDGPU_MAX_BL_LEVEL , max - min); } -/* Rescale from [0..MAX_BACKLIGHT_LEVEL] to [min..max] */ +/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */ static inline u32 scale_fw_to_input (int min,int max,u64 input) { -return min +DIV_ROUND_CLOSEST_ULL (input * (max - min),MAX_BACKLIGHT_LEVEL ); +return min +DIV_ROUND_CLOSEST_ULL (input * (max - min),AMDGPU_MAX_BL_LEVEL ); }
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector) · line 4980
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *caps,@@ -4977,7 +4977,7 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)drm_dbg (drm,"Backlight caps: min: %d, max: %d, ac %d, dc %d\n" , min, max, caps->ac_level, caps->dc_level); }else - props.brightness = props.max_brightness =MAX_BACKLIGHT_LEVEL ; + props.brightness = props.max_brightness =AMDGPU_MAX_BL_LEVEL ;This bottom hunk doesn't need to revert, that one is fine. The other two need to be reverted though to fix this issue.
With that fixed, the patch is: