Skip to content

Commit 52d3d11

Browse files
Vivek Das Mohapatraalexdeucher
authored andcommitted
drm/amd/display: Initialise backlight level values from hw
Internal backlight levels are initialised from ACPI but the values are sometimes out of sync with the levels in effect until there has been a read from hardware (eg triggered by reading from sysfs). This means that the first drm_commit can cause the levels to be set to a different value than the actual starting one, which results in a sudden change in brightness. This path shows the problem (when the values are out of sync): amdgpu_dm_atomic_commit_tail() -> amdgpu_dm_commit_streams() -> amdgpu_dm_backlight_set_level(..., dm->brightness[n]) This patch calls the backlight ops get_brightness explicitly at the end of backlight registration to make sure dm->brightness[n] is in sync with the actual hardware levels. Fixes: 2fe87f5 ("drm/amd/display: Set default brightness according to ACPI") Signed-off-by: Vivek Das Mohapatra <vivek@collabora.com> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 318b1c3) Cc: stable@vger.kernel.org
1 parent fee5007 commit 52d3d11

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5266,6 +5266,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
52665266
struct amdgpu_dm_backlight_caps *caps;
52675267
char bl_name[16];
52685268
int min, max;
5269+
int real_brightness;
5270+
int init_brightness;
52695271

52705272
if (aconnector->bl_idx == -1)
52715273
return;
@@ -5290,6 +5292,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
52905292
} else
52915293
props.brightness = props.max_brightness = MAX_BACKLIGHT_LEVEL;
52925294

5295+
init_brightness = props.brightness;
5296+
52935297
if (caps->data_points && !(amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE)) {
52945298
drm_info(drm, "Using custom brightness curve\n");
52955299
props.scale = BACKLIGHT_SCALE_NON_LINEAR;
@@ -5308,8 +5312,20 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
53085312
if (IS_ERR(dm->backlight_dev[aconnector->bl_idx])) {
53095313
drm_err(drm, "DM: Backlight registration failed!\n");
53105314
dm->backlight_dev[aconnector->bl_idx] = NULL;
5311-
} else
5315+
} else {
5316+
/*
5317+
* dm->brightness[x] can be inconsistent just after startup until
5318+
* ops.get_brightness is called.
5319+
*/
5320+
real_brightness =
5321+
amdgpu_dm_backlight_ops.get_brightness(dm->backlight_dev[aconnector->bl_idx]);
5322+
5323+
if (real_brightness != init_brightness) {
5324+
dm->actual_brightness[aconnector->bl_idx] = real_brightness;
5325+
dm->brightness[aconnector->bl_idx] = real_brightness;
5326+
}
53125327
drm_dbg_driver(drm, "DM: Registered Backlight device: %s\n", bl_name);
5328+
}
53135329
}
53145330

53155331
static int initialize_plane(struct amdgpu_display_manager *dm,

0 commit comments

Comments
 (0)