[PATCH v3 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support

From: Luo Liu

Date: Tue Nov 24 2026 - 04:39:55 EST


When attached with DRM_BRIDGE_ATTACH_NO_CONNECTOR, the connector is
created by drm_bridge_connector_init() and the driver's own connector
is never initialised. Several paths still access that connector:

- tda998x_bridge_mode_set() reads display_info from it to decide the
RGB quantization range and whether infoframes and audio are
supported. As it stays zeroed, the bridge always operates in DVI
mode.

- tda998x_audio_get_eld() copies the ELD from it, which is always
empty.

- tda998x_detect_work() uses its drm_device to send hotplug events,
which never happens because the connector was never registered.

Use the connector passed to the bridge detect and EDID read operations
instead of the driver's own connector whenever one was provided, and
report hotplug events through drm_bridge_hpd_notify(). Also advertise
interlaced mode support through the bridge, otherwise the bridge
connector rejects them.

Fixes: c76a8be4feec ("drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR")
Signed-off-by: Luo Liu <Luo.Liu@xxxxxxxxxxx>
---
drivers/gpu/drm/bridge/tda998x_drv.c | 64 +++++++++++++++++++---------
1 file changed, 45 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
index 0b966c9844e7..40379d74a53a 100644
--- a/drivers/gpu/drm/bridge/tda998x_drv.c
+++ b/drivers/gpu/drm/bridge/tda998x_drv.c
@@ -81,6 +81,7 @@ struct tda998x_priv {
struct drm_encoder encoder;
struct drm_bridge bridge;
struct drm_connector connector;
+ struct drm_connector *bridge_connector;

u8 audio_port_enable[AUDIO_ROUTE_NUM];
struct tda9950_glue cec_glue;
@@ -95,6 +96,19 @@ struct tda998x_priv {
#define bridge_to_tda998x_priv(x) \
container_of(x, struct tda998x_priv, bridge)

+/*
+ * When attached with DRM_BRIDGE_ATTACH_NO_CONNECTOR, the connector is created
+ * by drm_bridge_connector_init() and handed to the bridge detect and EDID
+ * operations; otherwise it is the driver's own connector.
+ */
+static struct drm_connector *tda998x_get_connector(struct tda998x_priv *priv)
+{
+ if (priv->bridge_connector)
+ return priv->bridge_connector;
+
+ return &priv->connector;
+}
+
/* The TDA9988 series of devices use a paged register scheme.. to simplify
* things we encode the page # in upper bits of the register #. To read/
* write a given register, we need to make sure CURPAGE register is set
@@ -769,6 +783,14 @@ static int tda998x_edid_delay_wait(struct tda998x_priv *priv)
return wait_event_killable(priv->edid_delay_waitq, !priv->edid_delay_active);
}

+static enum drm_connector_status tda998x_conn_detect(struct tda998x_priv *priv)
+{
+ u8 val = cec_read(priv, REG_CEC_RXSHPDLEV);
+
+ return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected :
+ connector_status_disconnected;
+}
+
/*
* We need to run the KMS hotplug event helper outside of our threaded
* interrupt routine as this can call back into our get_modes method,
@@ -778,10 +800,11 @@ static void tda998x_detect_work(struct work_struct *work)
{
struct tda998x_priv *priv =
container_of(work, struct tda998x_priv, detect_work);
- struct drm_device *dev = priv->connector.dev;

- if (dev)
- drm_kms_helper_hotplug_event(dev);
+ if (priv->bridge_connector)
+ drm_bridge_hpd_notify(&priv->bridge, tda998x_conn_detect(priv));
+ else if (priv->connector.dev)
+ drm_kms_helper_hotplug_event(priv->connector.dev);
}

/*
@@ -859,12 +882,12 @@ static void tda998x_write_aif(struct tda998x_priv *priv,
static void
tda998x_write_avi(struct tda998x_priv *priv, const struct drm_display_mode *mode)
{
+ struct drm_connector *connector = tda998x_get_connector(priv);
union hdmi_infoframe frame;

- drm_hdmi_avi_infoframe_from_display_mode(&frame.avi,
- &priv->connector, mode);
+ drm_hdmi_avi_infoframe_from_display_mode(&frame.avi, connector, mode);
frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_FULL;
- drm_hdmi_avi_infoframe_quant_range(&frame.avi, &priv->connector, mode,
+ drm_hdmi_avi_infoframe_quant_range(&frame.avi, connector, mode,
priv->rgb_quant_range);

tda998x_write_if(priv, DIP_IF_FLAGS_IF2, REG_IF2_HB0, &frame);
@@ -873,10 +896,11 @@ tda998x_write_avi(struct tda998x_priv *priv, const struct drm_display_mode *mode
static void tda998x_write_vsi(struct tda998x_priv *priv,
const struct drm_display_mode *mode)
{
+ struct drm_connector *connector = tda998x_get_connector(priv);
union hdmi_infoframe frame;

if (drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
- &priv->connector,
+ connector,
mode))
reg_clear(priv, REG_DIP_IF_FLAGS, DIP_IF_FLAGS_IF1);
else
@@ -1152,10 +1176,10 @@ static int tda998x_audio_get_eld(struct device *dev, void *data,
uint8_t *buf, size_t len)
{
struct tda998x_priv *priv = dev_get_drvdata(dev);
+ struct drm_connector *connector = tda998x_get_connector(priv);

mutex_lock(&priv->audio_mutex);
- memcpy(buf, priv->connector.eld,
- min(sizeof(priv->connector.eld), len));
+ memcpy(buf, connector->eld, min(sizeof(connector->eld), len));
mutex_unlock(&priv->audio_mutex);

return 0;
@@ -1193,14 +1217,6 @@ static int tda998x_audio_codec_init(struct tda998x_priv *priv,

/* DRM connector functions */

-static enum drm_connector_status tda998x_conn_detect(struct tda998x_priv *priv)
-{
- u8 val = cec_read(priv, REG_CEC_RXSHPDLEV);
-
- return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected :
- connector_status_disconnected;
-}
-
static enum drm_connector_status
tda998x_connector_detect(struct drm_connector *connector, bool force)
{
@@ -1390,6 +1406,8 @@ static void tda998x_bridge_detach(struct drm_bridge *bridge)
{
struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);

+ priv->bridge_connector = NULL;
+
if (priv->connector.dev)
drm_connector_cleanup(&priv->connector);
}
@@ -1449,6 +1467,7 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
const struct drm_display_mode *adjusted_mode)
{
struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
+ struct drm_connector *connector = tda998x_get_connector(priv);
unsigned long tmds_clock;
u16 ref_pix, ref_line, n_pix, n_line;
u16 hs_pix_s, hs_pix_e;
@@ -1465,7 +1484,7 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
* it, otherwise reduce to limited-range.
*/
priv->rgb_quant_range =
- priv->connector.display_info.rgb_quant_range_selectable ?
+ connector->display_info.rgb_quant_range_selectable ?
HDMI_QUANTIZATION_RANGE_FULL :
drm_default_rgb_quant_range(adjusted_mode);

@@ -1674,7 +1693,7 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
* ignore CEA version 2 and below (iow, behave as if we're a
* CEA-861 source.)
*/
- priv->supports_infoframes = priv->connector.display_info.cea_rev >= 3;
+ priv->supports_infoframes = connector->display_info.cea_rev >= 3;

if (priv->supports_infoframes) {
/* We need to turn HDMI HDCP stuff on to get audio through */
@@ -1701,6 +1720,9 @@ tda998x_bridge_edid_read(struct drm_bridge *bridge,
const struct drm_edid *drm_edid;
const struct edid *edid;

+ if (connector)
+ priv->bridge_connector = connector;
+
drm_edid = tda998x_edid_read(priv, connector);
if (!drm_edid) {
dev_dbg(&priv->hdmi->dev, "failed to get edid\n");
@@ -1729,6 +1751,9 @@ tda998x_bridge_detect(struct drm_bridge *bridge,
{
struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);

+ if (connector)
+ priv->bridge_connector = connector;
+
return tda998x_conn_detect(priv);
}

@@ -2011,6 +2036,7 @@ tda998x_probe(struct i2c_client *client)

priv->bridge.ops |= DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
priv->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
+ priv->bridge.interlace_allowed = true;
drm_bridge_add(&priv->bridge);

return 0;
--
2.25.1