drm/bridge: dw-hdmi: use display_info and support non-HDMI downstream connectors
Subsystems (3)
cover drm/bridge: dw-hdmi: use display_info and support non-HDMI downstream connectors
This short series updates dw-hdmi's HDMI vs. DVI and audio detection to use connector->display_info and fixes HDMI output framing when dw-hdmi is chained to an active protocol-converting downstream bridge.
Patch 1 resolves the FIXME in dw_hdmi_edid_read() by removing the deprecated drm_edid_raw() / drm_detect_hdmi_monitor() / drm_detect_monitor_audio() calls and latching connector->display_info.is_hdmi and connector->display_info.has_audio in dw_hdmi_bridge_atomic_enable() under hdmi->mutex. This fixes HDMI and audio detection when EDID is read by a downstream display-connector, when an EDID override/firmware EDID is active, or when an EDID read fails after unplugging an HDMI sink, while preserving the cached flags across transient RXSENSE power cycles in dw_hdmi_irq().
Patch 2 enables HDMI TMDS framing (while keeping RGB full-range) when the pipeline terminates in a non-HDMI/DVI connector (e.g. LVDS, eDP, DP, or DSI behind a protocol-converting HDMI receiver bridge such as Rockchip RK628 or Lontium LT9721), where the terminal connector's display_info never carries an HDMI VSDB. Patch 1 stands independently if reviewers prefer a more general bridge-level mechanism for Patch 2.
Gianfranco Mariotti (2):
drm/bridge: dw-hdmi: use connector->display_info for HDMI and audio
detection
drm/bridge: dw-hdmi: enable HDMI mode for non-HDMI/DVI downstream
connectors
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 45 +++++++++++++++-------- 1 file changed, 30 insertions(+), 15 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 drm/bridge: dw-hdmi: use connector->display_info for HDMI and audio detection
Currently dw-hdmi only updates hdmi->sink_is_hdmi and hdmi->sink_has_audio inside dw_hdmi_edid_read() using the deprecated drm_edid_raw(), drm_detect_hdmi_monitor(), and drm_detect_monitor_audio() helpers.
This has three issues:
1. When chained to a standalone display-connector (e.g. hdmi-connector with its own ddc-i2c-bus), drm_bridge_connector reads EDID through the downstream connector bridge and populates connector->display_info, bypassing dw_hdmi_edid_read() and leaving sink_is_hdmi and sink_has_audio false even for HDMI monitors.
2. When an EDID override or firmware EDID is active, connector->display_info reflects the overridden EDID while dw_hdmi_edid_read() may not run.
3. When an EDID read fails after a previous HDMI monitor was unplugged, dw_hdmi_edid_read() returns NULL without clearing the stale flags, whereas drm_edid_connector_update(connector, NULL) resets connector->display_info.
Resolve the FIXME in dw_hdmi_edid_read() by latching connector->display_info.is_hdmi and connector->display_info.has_audio in dw_hdmi_bridge_atomic_enable() under hdmi->mutex before calling dw_hdmi_update_power(). Capturing them in .atomic_enable() (rather than in dw_hdmi_setup()) also avoids racing with connector->display_info updates and preserves the cached HDMI/audio flags across transient hotplug unplug/replug cycles handled inside dw_hdmi_irq() before userspace re-reads EDID.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4 -14
@@ -2471,7 +2471,6 @@ static const struct drm_edid *dw_hdmi_edid_read(struct dw_hdmi *hdmi, struct drm_connector *connector) {const struct drm_edid *drm_edid; -const struct edid *edid;if (!hdmi->ddc)return NULL ;
@@ -2482,19 +2481,6 @@ static const struct drm_edid *dw_hdmi_edid_read(struct dw_hdmi *hdmi,return NULL ; } -/* -* FIXME: This should use connector->display_info.is_hdmi and -* connector->display_info.has_audio from a path that has read the EDID -* and called drm_edid_connector_update(). -*/ - edid =drm_edid_raw (drm_edid); - -dev_dbg (hdmi->dev,"got edid: width[%d] x height[%d]\n" , - edid->width_cm, edid->height_cm); - - hdmi->sink_is_hdmi =drm_detect_hdmi_monitor (edid); - hdmi->sink_has_audio =drm_detect_monitor_audio (edid); -return drm_edid; }
@@ -3006,10 +2992,14 @@ static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge, connector =drm_atomic_get_new_connector_for_encoder (state, bridge->encoder); +if (WARN_ON (!connector)) +return ;mutex_lock (&hdmi->mutex); hdmi->disabled = false; hdmi->curr_conn = connector; + hdmi->sink_is_hdmi = connector->display_info.is_hdmi; + hdmi->sink_has_audio = connector->display_info.has_audio;dw_hdmi_update_power (hdmi);dw_hdmi_update_phy_mask (hdmi);handle_plugged_change (hdmi, true);
Signature · 1 line
2.25.1
PATCH 2/2 drm/bridge: dw-hdmi: enable HDMI mode for non-HDMI/DVI downstream connectors
In reply to Gianfranco MariottiWhen dw-hdmi is chained to an active protocol-converting downstream bridge (such as HDMI-to-LVDS or HDMI-to-eDP, e.g. Rockchip RK628 or Lontium LT9721), the terminal DRM connector represents the downstream panel/interface rather than an HDMI/DVI sink. Its display_info therefore never contains an HDMI VSDB, leaving connector->display_info.is_hdmi false even though the link between dw-hdmi and the downstream bridge is HDMI.
HDMI receivers such as Rockchip RK628 require HDMI TMDS framing (preambles and guard bands) to lock symbol alignment and color depth, and cannot lock to raw DVI mode.
Enable HDMI framing when the terminal connector is not an HDMI or DVI connector, while keeping rgb_limited_range restricted to HDMI/DVI connectors with hdmi->sink_is_hdmi so downstream panel/bridge pipelines continue to receive full-range RGB (and HDMI TVs preserve limited-range RGB across transient RXSENSE power cycles). External HDMI/DVI connectors and passive redrivers in front of them continue to derive HDMI vs. DVI mode from connector->display_info.is_hdmi.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 29 +++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +27 -2
@@ -2251,6 +2251,20 @@ static void hdmi_disable_overflow_interrupts(struct dw_hdmi *hdmi) HDMI_IH_MUTE_FC_STAT2); } +static bool dw_hdmi_connector_is_hdmi_or_dvi (const struct drm_connector *connector) +{ +switch (connector->connector_type) { +case DRM_MODE_CONNECTOR_HDMIA : +case DRM_MODE_CONNECTOR_HDMIB : +case DRM_MODE_CONNECTOR_DVII : +case DRM_MODE_CONNECTOR_DVID : +case DRM_MODE_CONNECTOR_DVIA : +return true; +default : +return false; + } +} +static int dw_hdmi_setup (struct dw_hdmi *hdmi,const struct drm_connector *connector,const struct drm_display_mode *mode)
@@ -2291,7 +2305,9 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi,if (hdmi->hdmi_data.enc_out_bus_format ==MEDIA_BUS_FMT_FIXED ) hdmi->hdmi_data.enc_out_bus_format =MEDIA_BUS_FMT_RGB888_1X24 ; - hdmi->hdmi_data.rgb_limited_range = hdmi->sink_is_hdmi && + hdmi->hdmi_data.rgb_limited_range = +dw_hdmi_connector_is_hdmi_or_dvi (connector) && + hdmi->sink_is_hdmi &&drm_default_rgb_quant_range (mode) ==HDMI_QUANTIZATION_RANGE_LIMITED ;
@@ -2998,7 +3014,16 @@ static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge,mutex_lock (&hdmi->mutex); hdmi->disabled = false; hdmi->curr_conn = connector; - hdmi->sink_is_hdmi = connector->display_info.is_hdmi; +/* +* When the pipeline terminates in a non-HDMI/DVI connector (e.g. LVDS, +* eDP, DisplayPort, or DSI behind a protocol-converting bridge), the +* terminal connector has no HDMI VSDB in display_info, yet the +* intermediate link out of dw-hdmi to the downstream bridge is HDMI. +*/ +if (dw_hdmi_connector_is_hdmi_or_dvi (connector)) + hdmi->sink_is_hdmi = connector->display_info.is_hdmi; +else + hdmi->sink_is_hdmi = true; hdmi->sink_has_audio = connector->display_info.has_audio;dw_hdmi_update_power (hdmi);dw_hdmi_update_phy_mask (hdmi);
Signature · 1 line
2.25.1