Skip to contentSkip to conversation

drm/amd: fix HDMI output with non-HDMI EDID overrides

PATCH Superseded Johannes Wüller 1 participant 5 messages Mar 15

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover drm/amd: fix HDMI output with non-HDMI EDID overrides

This series fixes several issues that prevent amdgpu from driving an HDMI display at its native resolution when a non-HDMI EDID is injected via drm.edid_firmware or debugfs edid_override.

The motivating case is a Dell U3011 (2560x1600) connected via HDMI, whose native HDMI EDID only advertises CEA modes up to 1920x1080. By injecting the monitor's DisplayPort EDID (which contains the native 2560x1600 mode), the correct resolution becomes available. However, amdgpu then fails to drive the output because the injected EDID lacks an HDMI VSDB, causing the driver to treat the physical HDMI connector as a passive HDMI-DVI dongle, and rejecting the required pixel clock.

Patch 1 adds an edid_overridden flag to drm_connector, set by the existing EDID override mechanisms in _drm_do_get_edid(), so that drivers can detect when an override is in effect and adjust their behavior accordingly, without duplicating the override mechanism.

Patches 2-4 fix the amdgpu-specific issues:
- incorrect signal type selection when an override is active
- unconditional rejection of all colour depths when max_tmds_clock is zero
- force_yuv420/422_output flags being silently ignored when the display doesn't advertise the requested format.

Tested on AMD Ryzen 9 7950X (RDNA3 iGPU, DCN 3.1.5) with a Dell U3011 connected via HDMI at 2560x1600@60Hz RGB 8bpc, and another Dell U3011 connected via DisplayPort in the same mode.

This is my first code contribution to the kernel, so I would appreciate feedback on whether I've gotten recipients and other procedural details right! :)

Johannes Wüller (4):
drm: add edid_overridden flag to drm_connector drm/amd: fix HDMI signal type for EDID overrides drm/amd: treat max_tmds_clock==0 as unconstrained drm/amd: fix force_yuv420/422_output being ignored

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 +++++++++++--------
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |  9 ++++++++-
 drivers/gpu/drm/drm_edid.c                    |  2 ++
 include/drm/drm_connector.h                   |  8 ++++++++
 4 files changed, 30 insertions(+), 9 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/4 drm: add edid_overridden flag to drm_connector

When an EDID override is in effect, the physical connector may not match reported capabilities. Adds a drm_connector flag that allows drivers to detect such mismatches.

---
 drivers/gpu/drm/drm_edid.c  | 2 ++
 include/drm/drm_connector.h | 8 ++++++++
 2 files changed, 10 insertions(+)
drivers/gpu/drm/drm_edid.c +2 -0
index 26bb7710a462..9b0f410ea2de 100644
@@ -2373,6 +2373,7 @@ static struct edid *_drm_do_get_edid(struct drm_connector *connector,
 	struct edid *edid, *new;
 	size_t alloc_size = EDID_LENGTH;
 
+	connector->edid_overridden = false;
 	override = drm_edid_override_get(connector);
 	if (override) {
 		alloc_size = override->size;
@@ -2380,6 +2381,7 @@ static struct edid *_drm_do_get_edid(struct drm_connector *connector,
 		drm_edid_free(override);
 		if (!edid)
 			return NULL;
+		connector->edid_overridden = true;
 		goto ok;
 	}
 
include/drm/drm_connector.h +8 -0
index c18be8c19de0..43d7ac31deba 100644
@@ -2261,6 +2261,14 @@ struct drm_connector {
 	/** @bad_edid_counter: track sinks that give us an EDID with invalid checksum */
 	unsigned bad_edid_counter;
 
+	/**
+	 * @edid_overridden: Indicates whether the last read EDID was an
+	 * override (e.g. via debugfs edid_override or drm.edid_firmware kernel
+	 * parameter), which can cause the physical connector to differ from
+	 * the advertised capabilities.
+	 */
+	bool edid_overridden;
+
 	/**
 	 * @edid_corrupt: Indicates whether the last read EDID was corrupt. Used
 	 * in Displayport compliance testing - Displayport Link CTS Core 1.2
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/4 drm/amd: fix HDMI signal type for EDID overrides

In reply to Johannes Wüller

If an EDID override is in effect (e.g. via debugfs edid_override or drm.edid_firmware kernel parameter), the overriding EDID may not advertise capabilities matching the physical connector being used. In that case, trust the physical connector type over the EDID in create_eml_sink() and dm_helpers_parse_edid_caps().

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c        | 9 ++++++++-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c    | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -1
index ff09a5371cb2..bc853f7555a9 100644
@@ -7911,7 +7911,14 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
 		return;
 	}
 
-	if (connector->display_info.is_hdmi)
+	/*
+	 * If an EDID override is active, it may not advertise HDMI capability
+	 * even though the physical connector is HDMI. Trust the connector type.
+	 */
+	if (connector->display_info.is_hdmi ||
+	    (connector->edid_overridden &&
+	     (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+	      connector->connector_type == DRM_MODE_CONNECTOR_HDMIB)))
 		init_params.sink_signal = SIGNAL_TYPE_HDMI_TYPE_A;
 
 	aconnector->drm_edid = drm_edid;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +8 -1
index d7b0b84b3865..36b6e37f1517 100644
@@ -137,7 +137,14 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 				  edid_caps->display_name,
 				  AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS);
 
-	edid_caps->edid_hdmi = connector->display_info.is_hdmi;
+	/*
+	 * If an EDID override is active, it may not advertise HDMI capability
+	 * even though the physical connector is HDMI. Trust the connector type.
+	 */
+	edid_caps->edid_hdmi = connector->display_info.is_hdmi ||
+		(connector->edid_overridden &&
+		 (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+		  connector->connector_type == DRM_MODE_CONNECTOR_HDMIB));
 
 	if (edid_caps->edid_hdmi)
 		populate_hdmi_info_from_connector(&connector->display_info.hdmi, edid_caps);
Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/4 drm/amd: treat max_tmds_clock==0 as unconstrained

In reply to Johannes Wüller

If max_tmds_clock is not specified by the EDID, it should be treated as unconstrained rather than as a zero MHz limit, since it would cause adjust_colour_depth_from_display_info() to reject all color depths unconditionally.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -1
index bc853f7555a9..82c8dc8dd39f 100644
@@ -6612,7 +6612,8 @@ static bool adjust_colour_depth_from_display_info(
 			/* The above depths are the only ones valid for HDMI. */
 			return false;
 		}
-		if (normalized_clk <= info->max_tmds_clock) {
+		if (info->max_tmds_clock == 0 ||
+		    normalized_clk <= info->max_tmds_clock) {
 			timing_out->display_color_depth = depth;
 			return true;
 		}
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/4 drm/amd: fix force_yuv420/422_output being ignored

In reply to Johannes Wüller

force_yuv420_output and force_yuv422_output are intended to force a specific pixel encoding. However, if the display doesn't advertise this capability, the flag becomes ineffective.

Fix the flag to actually enforce the encoding, regardless of advertised capabilities.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -6
index 82c8dc8dd39f..9b298879de53 100644
@@ -6650,13 +6650,9 @@ static void fill_stream_properties_from_drm_display_mode(
 	if (drm_mode_is_420_only(info, mode_in)
 			&& stream->signal == SIGNAL_TYPE_HDMI_TYPE_A)
 		timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420;
-	else if (drm_mode_is_420_also(info, mode_in)
-			&& aconnector
-			&& aconnector->force_yuv420_output)
+	else if (aconnector && aconnector->force_yuv420_output)
 		timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR420;
-	else if ((connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR422)
-			&& aconnector
-			&& aconnector->force_yuv422_output)
+	else if (aconnector && aconnector->force_yuv422_output)
 		timing_out->pixel_encoding = PIXEL_ENCODING_YCBCR422;
 	else if ((connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR444)
 			&& stream->signal == SIGNAL_TYPE_HDMI_TYPE_A)
Signature · 1 line
2.53.0