mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Liviu Dudau <liviu.dudau@arm.com>
To: Luo Liu <Luo.Liu@cixtech.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Russell King <linux@armlinux.org.uk>,
	dri-devel@lists.freedesktop.org,
	Ayan Halder <Ayan.Halder@arm.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Kory Maincent <kory.maincent@bootlin.com>,
	Luca Ceresoli <luca.ceresoli@bootlin.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	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
Date: Mon, 30 Nov 2026 14:32:26 +0000	[thread overview]
Message-ID: <aw2I-ngFoQ_WJybL@e142607> (raw)
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 <Luo.Liu@cixtech.com>

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

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!  /
  ---------------
    ¯\_(ツ)_/¯

  reply	other threads:[~2026-11-30 14:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  2:55 [PATCH v4 1/4] drm/komeda: Use the bridge connector Luo Liu
2026-11-30  2:55 ` [PATCH v4 2/4] drm/komeda: Use drmm_mode_config_init() Luo Liu
2026-11-30 13:25   ` Liviu Dudau
2026-11-30  2:55 ` [PATCH v4 3/4] drm/komeda: Free the IRQ before clearing dev_private Luo Liu
2026-11-30 13:27   ` Liviu Dudau
2026-11-30 17:38   ` Luca Ceresoli
2026-11-30  2:55 ` [PATCH v4 4/4] drm/bridge: tda998x: fix DRM_BRIDGE_ATTACH_NO_CONNECTOR support Luo Liu
2026-11-30 14:32   ` Liviu Dudau [this message]
2026-11-30  9:53 ` [PATCH v4 1/4] drm/komeda: Use the bridge connector Kory Maincent
2026-11-30 11:45   ` 回复: " Luo Liu
2026-11-30 13:23 ` Liviu Dudau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aw2I-ngFoQ_WJybL@e142607 \
    --to=liviu.dudau@arm.com \
    --cc=Ayan.Halder@arm.com \
    --cc=Luo.Liu@cixtech.com \
    --cc=Wuyi.Shen@cixtech.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=cix-kernel-upstream@cixtech.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=kory.maincent@bootlin.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=luca.ceresoli@bootlin.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®