Commit f6eeab30 authored by Mario Limonciello (AMD)'s avatar Mario Limonciello (AMD) Committed by Alex Deucher
Browse files

drm/amd/display: Don't change brightness for disabled connectors

[WHY]
When a laptop lid is closed the connector is disabled but userspace
can still try to change brightness.  This doesn't work because the
panel is turned off. It will eventually time out, but there is a lot
of stutter along the way.

[How]
Iterate all connectors to check whether the matching one for the backlight
index is enabled.

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4675


Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarRay Wu <ray.wu@amd.com>
Signed-off-by: default avatarMario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: default avatarAlex Hung <alex.hung@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 1a794826
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -5125,6 +5125,21 @@ static void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
	struct dc_link *link;
	u32 brightness;
	bool rc, reallow_idle = false;
	struct drm_connector *connector;

	list_for_each_entry(connector, &dm->ddev->mode_config.connector_list, head) {
		struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);

		if (aconnector->bl_idx != bl_idx)
			continue;

		/* if connector is off, save the brightness for next time it's on */
		if (!aconnector->base.encoder) {
			dm->brightness[bl_idx] = user_brightness;
			dm->actual_brightness[bl_idx] = 0;
			return;
		}
	}

	amdgpu_dm_update_backlight_caps(dm, bl_idx);
	caps = &dm->backlight_caps[bl_idx];