Skip to content

Commit a490c8d

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 <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent cc9a8e2 commit a490c8d

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
@@ -2081,6 +2081,8 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
20812081

20822082
dc_hardware_init(adev->dm.dc);
20832083

2084+
adev->dm.restore_backlight = true;
2085+
20842086
adev->dm.hpd_rx_offload_wq = hpd_rx_irq_create_workqueue(adev);
20852087
if (!adev->dm.hpd_rx_offload_wq) {
20862088
drm_err(adev_to_drm(adev), "failed to create hpd rx offload workqueue.\n");
@@ -3436,6 +3438,7 @@ static int dm_resume(struct amdgpu_ip_block *ip_block)
34363438
dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0);
34373439

34383440
dc_resume(dm->dc);
3441+
adev->dm.restore_backlight = true;
34393442

34403443
amdgpu_dm_irq_resume_early(adev);
34413444

@@ -9927,7 +9930,6 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
99279930
bool mode_set_reset_required = false;
99289931
u32 i;
99299932
struct dc_commit_streams_params params = {dc_state->streams, dc_state->stream_count};
9930-
bool set_backlight_level = false;
99319933

99329934
/* Disable writeback */
99339935
for_each_old_connector_in_state(state, connector, old_con_state, i) {
@@ -10047,7 +10049,6 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
1004710049
acrtc->hw_mode = new_crtc_state->mode;
1004810050
crtc->hwmode = new_crtc_state->mode;
1004910051
mode_set_reset_required = true;
10050-
set_backlight_level = true;
1005110052
} else if (modereset_required(new_crtc_state)) {
1005210053
drm_dbg_atomic(dev,
1005310054
"Atomic commit: RESET. crtc id %d:[%p]\n",
@@ -10104,13 +10105,16 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state,
1010410105
* to fix a flicker issue.
1010510106
* It will cause the dm->actual_brightness is not the current panel brightness
1010610107
* level. (the dm->brightness is the correct panel level)
10107-
* So we set the backlight level with dm->brightness value after set mode
10108+
* So we set the backlight level with dm->brightness value after initial
10109+
* set mode. Use restore_backlight flag to avoid setting backlight level
10110+
* for every subsequent mode set.
1010810111
*/
10109-
if (set_backlight_level) {
10112+
if (dm->restore_backlight) {
1011010113
for (i = 0; i < dm->num_of_edps; i++) {
1011110114
if (dm->backlight_dev[i])
1011210115
amdgpu_dm_backlight_set_level(dm, i, dm->brightness[i]);
1011310116
}
10117+
dm->restore_backlight = false;
1011410118
}
1011510119
}
1011610120

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,13 @@ struct amdgpu_display_manager {
625625
*/
626626
u32 actual_brightness[AMDGPU_DM_MAX_NUM_EDP];
627627

628+
/**
629+
* @restore_backlight:
630+
*
631+
* Flag to indicate whether to restore backlight after modeset.
632+
*/
633+
bool restore_backlight;
634+
628635
/**
629636
* @aux_hpd_discon_quirk:
630637
*

0 commit comments

Comments
 (0)