]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/amd/display: Restore correct backlight brightness after a GPU reset
authorMario Limonciello <mario.limonciello@amd.com>
Sun, 23 Feb 2025 06:04:35 +0000 (00:04 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 10 Mar 2025 17:27:39 +0000 (13:27 -0400)
[Why]
GPU reset will attempt to restore cached state, but brightness doesn't
get restored. It will come back at 100% brightness, but userspace thinks
it's the previous value.

[How]
When running resume sequence if GPU is in reset restore brightness
to previous value.

Acked-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Tom Chung <chiahsuan.chung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 5ae521d1b74be6a0f3b818e9f4087a6342620fb3..bf69cd50712e34b882421b51de039b2622e87e8c 100644 (file)
@@ -250,6 +250,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 static void handle_hpd_irq_helper(struct amdgpu_dm_connector *aconnector);
 static void handle_hpd_rx_irq(void *param);
 
+static void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
+                                        int bl_idx,
+                                        u32 user_brightness);
+
 static bool
 is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
                                 struct drm_crtc_state *new_crtc_state);
@@ -3432,6 +3436,12 @@ static int dm_resume(struct amdgpu_ip_block *ip_block)
 
                mutex_unlock(&dm->dc_lock);
 
+               /* set the backlight after a reset */
+               for (i = 0; i < dm->num_of_edps; i++) {
+                       if (dm->backlight_dev[i])
+                               amdgpu_dm_backlight_set_level(dm, i, dm->brightness[i]);
+               }
+
                return 0;
        }