drm/amd/display: use linear backlight curve on Linux
Subsystems (3)
PATCH 1/1 drm/amd/display: use linear backlight curve on Linux
The power module currently uses a non-linear backlight curve for the Linux backlight path. This results in incorrect brightness levels on affected systems.
Use the linear backlight curve instead to preserve the existing brightness-to-PWM mapping.
Tested on an AMD laptop with an eDP panel. The regression was reproduced with commit 3c108046e1d6 ("drm/amd/display: Add power module on Linux"), and the brightness behavior was restored with this change.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
@@ -1913,7 +1913,7 @@ static int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm) !(amdgpu_dc_feature_mask &DC_DISABLE_FRACTIONAL_PWM_MASK ); init_data[i].use_custom_backlight_caps = false; init_data[i].custom_backlight_caps_config_no =0 ; - init_data[i].use_linear_backlight_curve = false; + init_data[i].use_linear_backlight_curve = true; init_data[i].def_varibright_enable =0 ; init_data[i].varibright_level =0 ;/*
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Enabling use_linear_backlight_curve creates an asymmetry between the backlight set and get operations, breaking readbacks.
Pre-existing issues:
- [High] Incorrect millipercent calculation adds the minimum brightness offset twice, artificially doubling the minimum backlight level. --
commit d81c87ee8304f9423dd46886dacd5118c129a998
Author: Aarav Kumar <[email protected]>
drm/amd/display: use linear backlight curve on Linux
This commit switches the power module to use a linear backlight curve on Linux to preserve the existing brightness-to-PWM mapping. This fixes incorrect brightness levels observed on affected systems.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm) · line 421
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -418,7 +418,7 @@ static int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm) !(amdgpu_dc_feature_mask &DC_DISABLE_FRACTIONAL_PWM_MASK ); init_data[i].use_custom_backlight_caps = false; init_data[i].custom_backlight_caps_config_no =0 ; - init_data[i].use_linear_backlight_curve = false; + init_data[i].use_linear_backlight_curve = true;
[Severity: High]
Does enabling this flag create an asymmetry between the backlight set and get operations?
When the write path uses the linear curve, the read path in backlight_pwm_to_millipercent_legacy() in power_abm.c lacks support for this flag and unconditionally performs a binary search on the non-linear ACPI LUT.
Can this cause sysfs readbacks to return incorrect values?
[Severity: High]
This isn't a bug introduced by this patch, but using the linear curve strictly exposes an issue in the millipercent calculation in amdgpu_dm_backlight_set_level() in amdgpu_dm_backlight.c.
In amdgpu_dm_backlight_set_level():
brightness = convert_brightness_from_user(caps, dm->brightness[bl_idx]); ... get_brightness_range(caps, &min, &max); brightness = DIV_ROUND_CLOSEST(brightness * 100, (max - min)) * 1000;
Since convert_brightness_from_user() returns an absolute value scaled between min and max, computing the percentage without subtracting min first causes the millipercent value to already contain the minimum offset.
When this is passed to backlight_millipercent_to_pwm_legacy(), which computes:
min_backlight_pwm + (millipercent * range)
Does this artificially double the minimum backlight level and prevent the screen from dimming properly?
Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0init_data[i].def_varibright_enable =0 ; init_data[i].varibright_level =0 ;/*
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1