[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <nclqj5lovum5cv7xhznv3hcuhxivl2vtky3caiduo3izbc4bcn@lmgyev4soj4q>
Date: Sun, 9 Feb 2025 09:00:44 +0200
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: Maxime Ripard <mripard@...nel.org>
Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Thomas Zimmermann <tzimmermann@...e.de>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>, Andrzej Hajda <andrzej.hajda@...el.com>,
Neil Armstrong <neil.armstrong@...aro.org>, Robert Foss <rfoss@...nel.org>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>, Jonas Karlman <jonas@...boo.se>,
Jernej Skrabec <jernej.skrabec@...il.com>, Douglas Anderson <dianders@...omium.org>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 30/35] drm/bridge: Provide pointers to the connector
and crtc in bridge state
On Tue, Feb 04, 2025 at 03:57:58PM +0100, Maxime Ripard wrote:
> Now that connectors are no longer necessarily created by the bridges
> drivers themselves but might be created by drm_bridge_connector, it's
> pretty hard for bridge drivers to retrieve pointers to the connector and
> CRTC they are attached to.
>
> Indeed, the only way to retrieve the CRTC is to follow the drm_bridge
> encoder field, and then the drm_encoder crtc field, both of them being
> deprecated.
>
> And for the connector, since we can have multiple connectors attached to
> a CRTC, we don't really have a reliable way to get it.
It's not very precise, there is usually only a single connector attached
to that encoder:
connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
Most likely I understand what you mean, but the commit message might
require some polishing.
>
> Let's provide both pointers in the drm_bridge_state structure so we
> don't have to follow deprecated, non-atomic, pointers, and be more
> consistent with the other KMS entities.
Well... Currently we mostly have variable data inside the state. Adding
drm_connector to the drm_bridge_state means that it also becomes
dynamic, however it usually isn't. Another option might be to pass
drm_connector as an argument to various atomic_foo() callbacks, but it
is also suboptimal.
>
> Signed-off-by: Maxime Ripard <mripard@...nel.org>
> ---
> drivers/gpu/drm/drm_atomic_state_helper.c | 5 +++++
> drivers/gpu/drm/drm_bridge.c | 5 +++++
> include/drm/drm_atomic.h | 14 ++++++++++++++
> 3 files changed, 24 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
> index 519228eb109533d2596e899a57b571fa0995824f..66661dca077215b78dffca7bc1712f56d35e3918 100644
> --- a/drivers/gpu/drm/drm_atomic_state_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_state_helper.c
> @@ -777,10 +777,15 @@ EXPORT_SYMBOL(drm_atomic_helper_bridge_duplicate_state);
> * that don't subclass the bridge state.
> */
> void drm_atomic_helper_bridge_destroy_state(struct drm_bridge *bridge,
> struct drm_bridge_state *state)
> {
> + if (state->connector) {
> + drm_connector_put(state->connector);
> + state->connector = NULL;
> + }
> +
> kfree(state);
> }
> EXPORT_SYMBOL(drm_atomic_helper_bridge_destroy_state);
>
> /**
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index ad91a0ac375a9c8cf82834354ec7f654a59a7292..fcff08c7d609477b7cadabc109f0b543a6b9b506 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -803,10 +803,15 @@ static int drm_atomic_bridge_check(struct drm_bridge *bridge,
> bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state,
> bridge);
> if (WARN_ON(!bridge_state))
> return -EINVAL;
>
> + bridge_state->crtc = crtc_state->crtc;
> +
> + drm_connector_get(conn_state->connector);
> + bridge_state->connector = conn_state->connector;
> +
> if (bridge->funcs->atomic_check) {
> ret = bridge->funcs->atomic_check(bridge, bridge_state,
> crtc_state, conn_state);
> if (ret)
> return ret;
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 7af43062e5ca8c30b3fd600a34543e79137ab3ea..12f3676b85454e81de74c6b5eec700a355d42836 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -1197,10 +1197,24 @@ struct drm_bridge_state {
> /**
> * @bridge: the bridge this state refers to
> */
> struct drm_bridge *bridge;
>
> + /**
> + * @crtc: CRTC the bridge is connected to, NULL if disabled.
> + *
> + * Do not change this directly.
> + */
> + struct drm_crtc *crtc;
> +
> + /**
> + * @connector: The connector the bridge is connected to, NULL if disabled.
> + *
> + * Do not change this directly.
> + */
> + struct drm_connector *connector;
> +
> /**
> * @input_bus_cfg: input bus configuration
> */
> struct drm_bus_cfg input_bus_cfg;
>
>
> --
> 2.48.0
>
--
With best wishes
Dmitry
Powered by blists - more mailing lists