Skip to content

Commit ffcaed1

Browse files
superm1alexdeucher
authored andcommitted
drm/amd/display: Only read ACPI backlight caps once
[WHY] Backlight caps are read already in amdgpu_dm_update_backlight_caps(). They may be updated by update_connector_ext_caps(). Reading again when registering backlight device may cause wrong values to be used. [HOW] Use backlight caps already registered to the dm. Cc: Mario Limonciello <mario.limonciello@amd.com> Cc: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Roman Li <roman.li@amd.com> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Hung <alex.hung@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 148144f) Cc: stable@vger.kernel.org
1 parent 158f994 commit ffcaed1

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4908,7 +4908,7 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
49084908
struct drm_device *drm = aconnector->base.dev;
49094909
struct amdgpu_display_manager *dm = &drm_to_adev(drm)->dm;
49104910
struct backlight_properties props = { 0 };
4911-
struct amdgpu_dm_backlight_caps caps = { 0 };
4911+
struct amdgpu_dm_backlight_caps *caps;
49124912
char bl_name[16];
49134913
int min, max;
49144914

@@ -4922,20 +4922,20 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
49224922
return;
49234923
}
49244924

4925-
amdgpu_acpi_get_backlight_caps(&caps);
4926-
if (caps.caps_valid && get_brightness_range(&caps, &min, &max)) {
4925+
caps = &dm->backlight_caps[aconnector->bl_idx];
4926+
if (get_brightness_range(caps, &min, &max)) {
49274927
if (power_supply_is_system_supplied() > 0)
4928-
props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps.ac_level, 100);
4928+
props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps->ac_level, 100);
49294929
else
4930-
props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps.dc_level, 100);
4930+
props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps->dc_level, 100);
49314931
/* min is zero, so max needs to be adjusted */
49324932
props.max_brightness = max - min;
49334933
drm_dbg(drm, "Backlight caps: min: %d, max: %d, ac %d, dc %d\n", min, max,
4934-
caps.ac_level, caps.dc_level);
4934+
caps->ac_level, caps->dc_level);
49354935
} else
49364936
props.brightness = AMDGPU_MAX_BL_LEVEL;
49374937

4938-
if (caps.data_points && !(amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE))
4938+
if (caps->data_points && !(amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE))
49394939
drm_info(drm, "Using custom brightness curve\n");
49404940
props.max_brightness = AMDGPU_MAX_BL_LEVEL;
49414941
props.type = BACKLIGHT_RAW;

0 commit comments

Comments
 (0)