dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	dri-devel@lists.freedesktop.org,
	 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>
Cc: Tony Lindgren <tony@atomide.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	linux-media@vger.kernel.org
Subject: Re: [PATCHv3 1/6] drm: drm_bridge: add connector_attach/detach bridge ops
Date: Tue, 4 May 2021 11:26:13 +0300	[thread overview]
Message-ID: <bcf1d476-216f-db51-840e-7cda58585b5b@ideasonboard.com> (raw)
In-Reply-To: <20210428132545.1205162-2-hverkuil-cisco@xs4all.nl>

On 28/04/2021 16:25, Hans Verkuil wrote:
> Add bridge connector_attach/detach ops. These ops are called when a
> bridge is attached or detached to a drm_connector. These ops can be
> used to register and unregister an HDMI CEC adapter for a bridge that
> supports CEC.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>   drivers/gpu/drm/drm_bridge_connector.c | 25 +++++++++++++++++++++++-
>   include/drm/drm_bridge.h               | 27 ++++++++++++++++++++++++++
>   2 files changed, 51 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c
> index 791379816837..0676677badfe 100644
> --- a/drivers/gpu/drm/drm_bridge_connector.c
> +++ b/drivers/gpu/drm/drm_bridge_connector.c
> @@ -203,6 +203,11 @@ static void drm_bridge_connector_destroy(struct drm_connector *connector)
>   {
>   	struct drm_bridge_connector *bridge_connector =
>   		to_drm_bridge_connector(connector);
> +	struct drm_bridge *bridge;
> +
> +	drm_for_each_bridge_in_chain(bridge_connector->encoder, bridge)
> +		if (bridge->funcs->connector_detach)
> +			bridge->funcs->connector_detach(bridge, connector);
>   
>   	if (bridge_connector->bridge_hpd) {
>   		struct drm_bridge *hpd = bridge_connector->bridge_hpd;
> @@ -318,6 +323,7 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
>   	struct i2c_adapter *ddc = NULL;
>   	struct drm_bridge *bridge;
>   	int connector_type;
> +	int ret;
>   
>   	bridge_connector = kzalloc(sizeof(*bridge_connector), GFP_KERNEL);
>   	if (!bridge_connector)
> @@ -375,6 +381,23 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
>   		connector->polled = DRM_CONNECTOR_POLL_CONNECT
>   				  | DRM_CONNECTOR_POLL_DISCONNECT;
>   
> -	return connector;
> +	ret = 0;
> +	/* call connector_attach for all bridges */
> +	drm_for_each_bridge_in_chain(encoder, bridge) {
> +		if (!bridge->funcs->connector_attach)
> +			continue;
> +		ret = bridge->funcs->connector_attach(bridge, connector);
> +		if (ret)
> +			break;
> +	}
> +	if (!ret)
> +		return connector;
> +
> +	/* on error, detach any previously successfully attached connectors */
> +	list_for_each_entry_continue_reverse(bridge, &(encoder)->bridge_chain,

No need for parenthesis in (encoder) here.

> +					     chain_node)
> +		if (bridge->funcs->connector_detach)
> +			bridge->funcs->connector_detach(bridge, connector);
> +	return ERR_PTR(ret);
>   }
>   EXPORT_SYMBOL_GPL(drm_bridge_connector_init);
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index 2195daa289d2..333fbc3a03e9 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -629,6 +629,33 @@ struct drm_bridge_funcs {
>   	 * the DRM_BRIDGE_OP_HPD flag in their &drm_bridge->ops.
>   	 */
>   	void (*hpd_disable)(struct drm_bridge *bridge);
> +
> +	/**
> +	 * @connector_attach:
> +	 *
> +	 * This callback is invoked whenever our bridge is being attached to a
> +	 * &drm_connector. This is where an HDMI CEC adapter can be registered.
> +	 *
> +	 * The @connector_attach callback is optional.
> +	 *
> +	 * RETURNS:
> +	 *
> +	 * Zero on success, error code on failure.
> +	 */
> +	int (*connector_attach)(struct drm_bridge *bridge,
> +				struct drm_connector *conn);
> +
> +	/**
> +	 * @connector_detach:
> +	 *
> +	 * This callback is invoked whenever our bridge is being detached from a
> +	 * &drm_connector. This is where an HDMI CEC adapter can be
> +	 * unregistered.
> +	 *
> +	 * The @connector_detach callback is optional.
> +	 */
> +	void (*connector_detach)(struct drm_bridge *bridge,
> +				 struct drm_connector *conn);
>   };
>   
>   /**
> 

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

I can take this series as it's mostly omapdrm, but we'll need a 
reviewed-by/acked-by from a maintainer for this patch.

  Tomi
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2021-05-04  8:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28 13:25 [PATCHv3 0/6] drm/omap: hdmi: improve hdmi4 CEC, add CEC for hdmi5 Hans Verkuil
2021-04-28 13:25 ` [PATCHv3 1/6] drm: drm_bridge: add connector_attach/detach bridge ops Hans Verkuil
2021-05-04  8:26   ` Tomi Valkeinen [this message]
2021-05-27  7:22     ` Hans Verkuil
2021-06-03 12:34       ` Laurent Pinchart
2021-04-28 13:25 ` [PATCHv3 2/6] drm/omapdrm/dss/hdmi4: switch to the connector " Hans Verkuil
2021-04-28 13:25 ` [PATCHv3 3/6] drm/omapdrm/dss/hdmi4: simplify CEC Phys Addr handling Hans Verkuil
2021-04-28 13:25 ` [PATCHv3 4/6] dt-bindings: display: ti: ti, omap5-dss.txt: add cec clock Hans Verkuil
2021-04-28 13:25 ` [PATCHv3 5/6] dra7.dtsi/omap5.dtsi: " Hans Verkuil
2021-04-28 13:25 ` [PATCHv3 6/6] drm/omapdrm/dss/hdmi5: add CEC support Hans Verkuil

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=bcf1d476-216f-db51-840e-7cda58585b5b@ideasonboard.com \
    --to=tomi.valkeinen@ideasonboard.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=tony@atomide.com \
    --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;
as well as URLs for NNTP newsgroup(s).