Skip to content

Commit 318b1c3

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>
1 parent fff90bb commit 318b1c3

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
@@ -5279,6 +5279,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
52795279
struct amdgpu_dm_backlight_caps *caps;
52805280
char bl_name[16];
52815281
int min, max;
5282+
int real_brightness;
5283+
int init_brightness;
52825284

52835285
if (aconnector->bl_idx == -1)
52845286
return;
@@ -5303,6 +5305,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
53035305
} else
53045306
props.brightness = props.max_brightness = MAX_BACKLIGHT_LEVEL;
53055307

5308+
init_brightness = props.brightness;
5309+
53065310
if (caps->data_points && !(amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE)) {
53075311
drm_info(drm, "Using custom brightness curve\n");
53085312
props.scale = BACKLIGHT_SCALE_NON_LINEAR;
@@ -5321,8 +5325,20 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
53215325
if (IS_ERR(dm->backlight_dev[aconnector->bl_idx])) {
53225326
drm_err(drm, "DM: Backlight registration failed!\n");
53235327
dm->backlight_dev[aconnector->bl_idx] = NULL;
5324-
} else
5328+
} else {
5329+
/*
5330+
* dm->brightness[x] can be inconsistent just after startup until
5331+
* ops.get_brightness is called.
5332+
*/
5333+
real_brightness =
5334+
amdgpu_dm_backlight_ops.get_brightness(dm->backlight_dev[aconnector->bl_idx]);
5335+
5336+
if (real_brightness != init_brightness) {
5337+
dm->actual_brightness[aconnector->bl_idx] = real_brightness;
5338+
dm->brightness[aconnector->bl_idx] = real_brightness;
5339+
}
53255340
drm_dbg_driver(drm, "DM: Registered Backlight device: %s\n", bl_name);
5341+
}
53265342
}
53275343

53285344
static int initialize_plane(struct amdgpu_display_manager *dm,

0 commit comments

Comments
 (0)