From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796049167; b=bogHaTh5WbrBUPyM5qeIz9UCQJaOoUTSDeilqwQqEACfkELCNRL83D8bTNGuDhK2tgim mK++w9OPdonnFgws6qTVQLC3v2A8l7N0gUTzIlLhXthmJiNZnTImdytqbW0GPFeIEW6Cs W9jKs1DRhXVdwbAHpZQ1ZOTIZRYVWrceRcEfmcjpJkjwEXAX2roCwSrKG4XSX5xnQjcr4 Defe55KGC/D9ni3w/kzrQGTHdzvsQmbXBjnBOz9W4pcc96Qpr8QFHv7ZxcM8RbJ49qsme wQctzZkraLZiQdh89L15K+zG+JDzI+ExTka6F5lM6kl1JVEPPNVcx7OkV83c8/NySuA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049167; h=DMARC-Filter:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; bh=DRGRZc0guRHWrbl9/NTyhAlUBUFPUUoJbYwCXpBsyiI=; b=XK+sBYBQEAuFvhVWg8zVKJzK4b6oUCMC/CxrKCjzbmOvVR9dVXWCnBN3cD6yIOEiJWoT 23D+RcYj01VCmsNt650Pp9rMmF6er8Vij59kDVlga9p2oeK/mVDP2a1ljky6WJ4mv/6W2 hW1bM6p1GjxS+gxCasUTHXZz2DXdgxprFpP82ERijDrFMfJSkD/7AmG9UMZ/lw78iCKJI z+JSDACGR7P1YlktK1n+lM92loZGYDd9bRimkfIDXbgUgKMQExL05oy37sseFLf15aMfz jHwDyPWQ6Uajr35L+nP7RWFHPQuZkNQd2VRz/JlOCDHz0gqHii1q0K9GNl841VpeUCw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=fOE6j4cb; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53263606A31C for ; Mon, 30 Nov 2026 14:32:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 53263606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=fOE6j4cb Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C75231595 for ; Mon, 30 Nov 2026 06:32:43 -0800 (PST) Received: from [10.2.11.19] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6378A3FBB1 for ; Mon, 30 Nov 2026 06:32:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796049166; bh=ioQoi6E/+RbYfA39l0RcoLW4VVSZwzdaCjCVBDJD0+c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fOE6j4cb58XJ5gjt/uq8lfu7KuobE+cn0NqABxvm7rCUDxMMtBvrf7NjRAFQG4jHb OQfUzcmELhaFqkOCyIRHGqIw5OQpQPa6wA54DSmzMwzxK9hoaCMV8CVsWemiJTA3B0 dC/fmlKI0pQyp5vSEwgWmNiWMkLg5nroFABSRuPY= Date: Mon, 30 Nov 2026 14:32:26 +0000 From: Liviu Dudau To: Luo Liu Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Russell King , dri-devel@lists.freedesktop.org, Ayan Halder , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Kory Maincent , Luca Ceresoli , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org, cix-kernel-upstream@cixtech.com, Wuyi.Shen@cixtech.com Subject: Re: [PATCH v4 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support Message-ID: References: <20261130025520.766762-1-Luo.Liu@cixtech.com> <20261130025520.766762-4-Luo.Liu@cixtech.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261130025520.766762-4-Luo.Liu@cixtech.com> On Mon, Nov 30, 2026 at 10:55:20AM +0800, Luo Liu wrote: > When attached with DRM_BRIDGE_ATTACH_NO_CONNECTOR, the connector is > created by drm_bridge_connector_init() and the driver's own connector > stays uninitialised. The mode set then reads an empty display_info and > always runs in DVI mode, get_eld returns an empty ELD and hotplug events > are never sent. > > The connector passed to the detect and EDID read operations cannot be > cached: the bridge API forbids storing it, it is released with the DRM > device, and those operations are not always called. > > Take the display information and ELD from the connector state in the > bridge atomic check, resolve the connector and adjusted mode from the > atomic state when enabling the bridge, which is where the infoframe and > audio setup now runs, report hotplug through drm_bridge_hpd_notify() for > a connector created outside the driver, and advertise interlaced mode > support through the bridge. > > Since hotplug is now reported through the bridge, unregister the bridge > after the interrupt and the detect work have been stopped, so a pending > notification cannot take the HPD lock once drm_bridge_remove() has > destroyed it. > > Fixes: c76a8be4feec ("drm/bridge: tda998x: Add support for DRM_BRIDGE_ATTACH_NO_CONNECTOR") > Signed-off-by: Luo Liu Reviewed-by: Liviu Dudau Best regards, Liviu > --- > drivers/gpu/drm/bridge/tda998x_drv.c | 146 ++++++++++++++++++--------- > 1 file changed, 97 insertions(+), 49 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c > index 0b966c9844e7..5a59302e09ec 100644 > --- a/drivers/gpu/drm/bridge/tda998x_drv.c > +++ b/drivers/gpu/drm/bridge/tda998x_drv.c > @@ -57,9 +57,11 @@ struct tda998x_priv { > u8 cec_addr; > u8 current_page; > bool is_on; > + bool rgb_quant_range_selectable; > bool supports_infoframes; > bool sink_has_audio; > enum hdmi_quantization_range rgb_quant_range; > + u8 eld[MAX_ELD_BYTES]; > u8 vip_cntrl_0; > u8 vip_cntrl_1; > u8 vip_cntrl_2; > @@ -769,6 +771,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 +788,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->connector.dev) > + drm_kms_helper_hotplug_event(priv->connector.dev); > + else > + drm_bridge_hpd_notify(&priv->bridge, tda998x_conn_detect(priv)); > } > > /* > @@ -857,26 +868,27 @@ static void tda998x_write_aif(struct tda998x_priv *priv, > } > > static void > -tda998x_write_avi(struct tda998x_priv *priv, const struct drm_display_mode *mode) > +tda998x_write_avi(struct tda998x_priv *priv, struct drm_connector *connector, > + const struct drm_display_mode *mode) > { > 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); > } > > static void tda998x_write_vsi(struct tda998x_priv *priv, > + struct drm_connector *connector, > const struct drm_display_mode *mode) > { > 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 > @@ -1154,8 +1166,7 @@ static int tda998x_audio_get_eld(struct device *dev, void *data, > struct tda998x_priv *priv = dev_get_drvdata(dev); > > mutex_lock(&priv->audio_mutex); > - memcpy(buf, priv->connector.eld, > - min(sizeof(priv->connector.eld), len)); > + memcpy(buf, priv->eld, min(sizeof(priv->eld), len)); > mutex_unlock(&priv->audio_mutex); > > return 0; > @@ -1193,14 +1204,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) > { > @@ -1394,6 +1397,26 @@ static void tda998x_bridge_detach(struct drm_bridge *bridge) > drm_connector_cleanup(&priv->connector); > } > > +static int tda998x_bridge_atomic_check(struct drm_bridge *bridge, > + struct drm_bridge_state *bridge_state, > + struct drm_crtc_state *crtc_state, > + struct drm_connector_state *conn_state) > +{ > + struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge); > + struct drm_connector *connector = conn_state->connector; > + > + priv->rgb_quant_range_selectable = > + connector->display_info.rgb_quant_range_selectable; > + > + mutex_lock(&connector->eld_mutex); > + mutex_lock(&priv->audio_mutex); > + memcpy(priv->eld, connector->eld, sizeof(priv->eld)); > + mutex_unlock(&priv->audio_mutex); > + mutex_unlock(&connector->eld_mutex); > + > + return 0; > +} > + > static enum drm_mode_status tda998x_bridge_mode_valid(struct drm_bridge *bridge, > const struct drm_display_info *info, > const struct drm_display_mode *mode) > @@ -1411,9 +1434,59 @@ static enum drm_mode_status tda998x_bridge_mode_valid(struct drm_bridge *bridge, > } > > static void tda998x_bridge_enable(struct drm_bridge *bridge, > - struct drm_atomic_commit *commit) > + struct drm_atomic_commit *state) > { > struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge); > + struct drm_connector *connector; > + struct drm_connector_state *conn_state; > + struct drm_crtc_state *crtc_state; > + const struct drm_display_mode *adjusted_mode; > + u8 reg; > + > + connector = drm_atomic_get_new_connector_for_encoder(state, > + bridge->encoder); > + conn_state = drm_atomic_get_new_connector_state(state, connector); > + > + mutex_lock(&priv->audio_mutex); > + > + if (conn_state && conn_state->crtc) { > + crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc); > + adjusted_mode = &crtc_state->adjusted_mode; > + > + /* > + * CEA-861B section 6 says that: > + * CEA version 1 (CEA-861) has no support for infoframes. > + * CEA version 2 (CEA-861A) supports version 1 AVI infoframes, > + * and optional basic audio. > + * CEA version 3 (CEA-861B) supports version 1 and 2 AVI infoframes, > + * and optional digital audio, with audio infoframes. > + * > + * Since we only support generation of version 2 AVI infoframes, > + * ignore CEA version 2 and below (iow, behave as if we're a > + * CEA-861 source.) > + */ > + 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 */ > + reg = TBG_CNTRL_1_TGL_EN; > + if (crtc_state->mode.flags & DRM_MODE_FLAG_NHSYNC) > + reg |= TBG_CNTRL_1_H_TGL; > + if (crtc_state->mode.flags & DRM_MODE_FLAG_NVSYNC) > + reg |= TBG_CNTRL_1_V_TGL; > + reg_write(priv, REG_TBG_CNTRL_1, reg); > + reg_write(priv, REG_ENC_CNTRL, ENC_CNTRL_CTL_CODE(1)); > + reg_set(priv, REG_TX33, TX33_HDMI); > + > + tda998x_write_avi(priv, connector, adjusted_mode); > + tda998x_write_vsi(priv, connector, adjusted_mode); > + > + if (priv->sink_has_audio) > + tda998x_configure_audio(priv); > + } > + } > + > + mutex_unlock(&priv->audio_mutex); > > if (!priv->is_on) { > /* enable video ports, audio will be enabled later */ > @@ -1465,7 +1538,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 ? > + priv->rgb_quant_range_selectable ? > HDMI_QUANTIZATION_RANGE_FULL : > drm_default_rgb_quant_range(adjusted_mode); > > @@ -1663,33 +1736,6 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge, > /* must be last register set: */ > reg_write(priv, REG_TBG_CNTRL_0, 0); > > - /* CEA-861B section 6 says that: > - * CEA version 1 (CEA-861) has no support for infoframes. > - * CEA version 2 (CEA-861A) supports version 1 AVI infoframes, > - * and optional basic audio. > - * CEA version 3 (CEA-861B) supports version 1 and 2 AVI infoframes, > - * and optional digital audio, with audio infoframes. > - * > - * Since we only support generation of version 2 AVI infoframes, > - * 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; > - > - if (priv->supports_infoframes) { > - /* We need to turn HDMI HDCP stuff on to get audio through */ > - reg &= ~TBG_CNTRL_1_DWIN_DIS; > - reg_write(priv, REG_TBG_CNTRL_1, reg); > - reg_write(priv, REG_ENC_CNTRL, ENC_CNTRL_CTL_CODE(1)); > - reg_set(priv, REG_TX33, TX33_HDMI); > - > - tda998x_write_avi(priv, adjusted_mode); > - tda998x_write_vsi(priv, adjusted_mode); > - > - if (priv->sink_has_audio) > - tda998x_configure_audio(priv); > - } > - > mutex_unlock(&priv->audio_mutex); > } > > @@ -1747,6 +1793,7 @@ static void tda998x_bridge_hpd_disable(struct drm_bridge *bridge) > } > > static const struct drm_bridge_funcs tda998x_bridge_funcs = { > + .atomic_check = tda998x_bridge_atomic_check, > .atomic_create_state = drm_atomic_helper_bridge_create_state, > .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, > .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, > @@ -2011,6 +2058,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; > @@ -2035,8 +2083,6 @@ static void tda998x_remove(struct i2c_client *client) > { > struct tda998x_priv *priv = dev_get_drvdata(&client->dev); > > - drm_bridge_remove(&priv->bridge); > - > if (priv->audio_pdev) > platform_device_unregister(priv->audio_pdev); > > @@ -2053,6 +2099,8 @@ static void tda998x_remove(struct i2c_client *client) > > timer_delete_sync(&priv->edid_delay_timer); > cancel_work_sync(&priv->detect_work); > + > + drm_bridge_remove(&priv->bridge); > } > > #ifdef CONFIG_OF > -- > 2.25.1 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯