Skip to content

Commit 44b0fed

Browse files
matte-schwartzalexdeucher
authored andcommitted
drm/amd/display: Only restore backlight after amdgpu_dm_init or dm_resume
On clients that utilize AMD_PRIVATE_COLOR properties for HDR support, brightness sliders can include a hardware controlled portion and a gamma-based portion. This is the case on the Steam Deck OLED when using gamescope with Steam as a client. When a user sets a brightness level while HDR is active, the gamma-based portion and/or hardware portion are adjusted to achieve the desired brightness. However, when a modeset takes place while the gamma-based portion is in-use, restoring the hardware brightness level overrides the user's overall brightness level and results in a mismatch between what the slider reports and the display's current brightness. To avoid overriding gamma-based brightness, only restore HW backlight level after boot or resume. This ensures that the backlight level is set correctly after the DC layer resets it while avoiding interference with subsequent modesets. Fixes: 7875afa ("drm/amd/display: Fix brightness level not retained over reboot") Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4551 Signed-off-by: Matthew Schwartz <matthew.schwartz@linux.dev> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit a490c8d) Cc: stable@vger.kernel.org
1 parent 07e27ad commit 44b0fed

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,6 +2037,8 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
20372037

20382038
dc_hardware_init(adev->dm.dc);
20392039

2040+
adev->dm.restore_backlight = true;
2041+
20402042
adev->dm.hpd_rx_offload_wq = hpd_rx_irq_create_workqueue(adev);
20412043
if (!adev->dm.hpd_rx_offload_wq) {
20422044
drm_err(adev_to_drm(adev), "failed to create hpd rx offload workqueue.\n");
@@ -3399,6 +3401,7 @@ static int dm_resume(struct amdgpu_ip_block *ip_block)
33993401
dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0);
34003402

34013403
dc_resume(dm->dc);
3404+
adev->dm.restore_backlight = true;
34023405

34033406
amdgpu_dm_irq_resume_early(adev);
34043407

@@ -9829,7 +9832,6 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
98299832
bool mode_set_reset_required = false;
98309833
u32 i;
98319834
struct dc_commit_streams_params params = {dc_state->streams, dc_state->stream_count};
9832-
bool set_backlight_level = false;
98339835

98349836
/* Disable writeback */
98359837
for_each_old_connector_in_state(state, connector, old_con_state, i) {
@@ -9949,7 +9951,6 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
99499951
acrtc->hw_mode = new_crtc_state->mode;
99509952
crtc->hwmode = new_crtc_state->mode;
99519953
mode_set_reset_required = true;
9952-
set_backlight_level = true;
99539954
} else if (modereset_required(new_crtc_state)) {
99549955
drm_dbg_atomic(dev,
99559956
"Atomic commit: RESET. crtc id %d:[%p]\n",
@@ -10006,13 +10007,16 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
1000610007
* to fix a flicker issue.
1000710008
* It will cause the dm->actual_brightness is not the current panel brightness
1000810009
* level. (the dm->brightness is the correct panel level)
10009-
* So we set the backlight level with dm->brightness value after set mode
10010+
* So we set the backlight level with dm->brightness value after initial
10011+
* set mode. Use restore_backlight flag to avoid setting backlight level
10012+
* for every subsequent mode set.
1001010013
*/
10011-
if (set_backlight_level) {
10014+
if (dm->restore_backlight) {
1001210015
for (i = 0; i < dm->num_of_edps; i++) {
1001310016
if (dm->backlight_dev[i])
1001410017
amdgpu_dm_backlight_set_level(dm, i, dm->brightness[i]);
1001510018
}
10019+
dm->restore_backlight = false;
1001610020
}
1001710021
}
1001810022

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,13 @@ struct amdgpu_display_manager {
610610
*/
611611
u32 actual_brightness[AMDGPU_DM_MAX_NUM_EDP];
612612

613+
/**
614+
* @restore_backlight:
615+
*
616+
* Flag to indicate whether to restore backlight after modeset.
617+
*/
618+
bool restore_backlight;
619+
613620
/**
614621
* @aux_hpd_discon_quirk:
615622
*

0 commit comments

Comments
 (0)