[PATCH v2 3/3] drm/amd/display: Add support backlight quirks

Thomas Weißschuh linux at weissschuh.net
Sun Jun 23 08:51:29 UTC 2024


Not all platforms provide correct PWM backlight capabilities through ATIF.
Use the generic drm backlight quirk infrastructure to override the
capabilities where necessary.

Signed-off-by: Thomas Weißschuh <linux at weissschuh.net>
---
 drivers/gpu/drm/amd/amdgpu/Kconfig                |  1 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 28 +++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig
index 692fa7cf8fd2..4fe0e8e74bb9 100644
--- a/drivers/gpu/drm/amd/amdgpu/Kconfig
+++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
@@ -25,6 +25,7 @@ config DRM_AMDGPU
 	select DRM_BUDDY
 	select DRM_SUBALLOC_HELPER
 	select DRM_EXEC
+	select DRM_PANEL_BACKLIGHT_QUIRKS
 	# amdgpu depends on ACPI_VIDEO when ACPI is enabled, for select to work
 	# ACPI_VIDEO's dependencies must also be selected.
 	select INPUT if ACPI
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 60404385d4d0..2d8a6d875170 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -93,6 +93,7 @@
 #include <drm/drm_fourcc.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_eld.h>
+#include <drm/drm_utils.h>
 #include <drm/drm_vblank.h>
 #include <drm/drm_audio_component.h>
 #include <drm/drm_gem_atomic_helper.h>
@@ -3329,6 +3330,31 @@ static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = {
 	.atomic_commit_setup = drm_dp_mst_atomic_setup_commit,
 };
 
+static void amdgpu_dm_apply_backlight_quirks(struct amdgpu_dm_connector *aconnector,
+					     struct amdgpu_dm_backlight_caps *caps)
+{
+	const struct drm_panel_backlight_quirk *quirk;
+	const struct drm_edid *edid;
+
+	edid = drm_edid_alloc(aconnector->edid, EDID_LENGTH * (aconnector->edid->extensions + 1));
+	if (!edid)
+		return;
+
+	quirk = drm_get_panel_backlight_quirk(edid);
+
+	drm_edid_free(edid);
+
+	if (!quirk)
+		return;
+
+	if (quirk->overrides.pwm_min_brightness &&
+	    caps->min_input_signal != quirk->pwm_min_brightness) {
+		drm_info(aconnector->base.dev,
+			 "Quirk: backlight min_input_signal=%d\n", quirk->pwm_min_brightness);
+		caps->min_input_signal = quirk->pwm_min_brightness;
+	}
+}
+
 static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
 {
 	struct amdgpu_dm_backlight_caps *caps;
@@ -3369,6 +3395,8 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
 		caps->aux_min_input_signal = 0;
 		caps->aux_max_input_signal = 512;
 	}
+
+	amdgpu_dm_apply_backlight_quirks(aconnector, caps);
 }
 
 void amdgpu_dm_update_connector_after_detect(

-- 
2.45.2



More information about the amd-gfx mailing list