All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Jernej Skrabec <jernej.skrabec@siol.net>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	dri-devel@lists.freedesktop.org,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Boris Brezillon <boris.brezillon@collabora.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Chris Healy <Chris.Healy@zii.aero>,
	kernel@collabora.com, Sam Ravnborg <sam@ravnborg.org>
Subject: Re: [PATCH RFC 02/19] drm: Support custom encoder/bridge enable/disable sequences officially
Date: Wed, 21 Aug 2019 10:21:07 +0200	[thread overview]
Message-ID: <20190821082107.GI11147@phenom.ffwll.local> (raw)
In-Reply-To: <20190820190505.GP10820@pendragon.ideasonboard.com>

On Tue, Aug 20, 2019 at 10:05:05PM +0300, Laurent Pinchart wrote:
> Hi Boris,
> 
> Thank you for the patch.
> 
> On Thu, Aug 08, 2019 at 05:11:33PM +0200, Boris Brezillon wrote:
> > The VC4 and Exynos DSI encoder drivers need a custom enable/disable
> > sequence and manually set encoder->bridge to NULL to prevent the core
> > from calling the bridge hooks.
> > 
> > Let's provide a more official way to support custom bridge/encoder
> > enable/disable sequences.
> 
> So, while I'm not opposed to this, I think it's a bit of a hack, and I'd
> like to share my vision of how I'd like to see this being implemented in
> the more distant future (and thus possibly on top of this change).

I think it's also counter to how the atomic helpers are meant to be used.
I mean you're adding a pile new hooks here all for essentially not having
to type a few lines of helper code. If you look around at big drivers
(i915, amdgpu, nouveau) _none_ of them use the modesets_enables/disables
helpers. Exactly for reasons like this where you need a custom sequence.

So proper recommendation is to just type your own, you'll be happier.

> It has been established for quite some time now that exposing
> drm_encoder to userspace was likely a mistake, and that it should have
> stayed a kernel-only object. With the generalised usage of drm_bridge, I
> would go one step further: drm_encoder shouldn't matter for DRM/KMS
> drivers at all.
> 
> drm_bridge has been introduced to model chained encoders, where the
> second (and subsequent) encoders couldn't easily be supported in a
> standard and reusable way with just drm_encoder. A bridge (with the
> exception of the panel bridge) is just an encoder. It shouldn't matter
> whether encoders are internal to the display controller, separate IPs in
> the SoC or external components, they could all be modelled as bridges.
> We do have bridges for DSI encoder IPs, and DSI (and other) bridges
> potentially need similar custom enable/disable sequences. I would thus
> ideally like to see the VC4 and Exynos DSI encoders being implemented as
> bridges, with support for custom enable/disable sequences in bridges,
> and drop support for custom enable/disable sequences in drm_encoder.
> 
> Does this make sense to you ? While I would love to see this being
> implemented right away, it may be too much work as a prerequisite for
> this bus format negotiation series, so I don't want to reject this
> patch. I would however like to already make sure we agree on the way
> forward for the next steps.

Yeah the other bit is that bridges are supposed to be some kind of
standard. I do wonder (I haven't looked at the series) whether the problem
here is that encoders don't have their own full set of pre/post enable
hooks like bridges (essentially that's what you're adding here), or
whether the idea behind pre/post enable/disable hooks is not good enough.

Anyway, this here is imo not the right thing to do. If setting
encoder->bridge to NULL doesn't work for you then just type your own
enable/disable implementations. There's explicitly no requirement to use
all parts of atomic helpers, au contraire, it's explicitly discouraged.

Cheers, Daniel

> 
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > ---
> >  drivers/gpu/drm/drm_atomic_helper.c | 13 +++++++---
> >  drivers/gpu/drm/drm_crtc_helper.c   | 38 ++++++++++++++++++-----------
> >  include/drm/drm_encoder.h           |  9 +++++++
> >  3 files changed, 42 insertions(+), 18 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> > index 4706439fb490..15ea61877122 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -1030,7 +1030,8 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
> >  		 * Each encoder has at most one connector (since we always steal
> >  		 * it away), so we won't call disable hooks twice.
> >  		 */
> > -		drm_atomic_bridge_disable(encoder->bridge, old_state);
> > +		if (!encoder->custom_bridge_enable_disable_seq)
> > +			drm_atomic_bridge_disable(encoder->bridge, old_state);
> >  
> >  		/* Right function depends upon target state. */
> >  		if (funcs) {
> > @@ -1044,7 +1045,9 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
> >  				funcs->dpms(encoder, DRM_MODE_DPMS_OFF);
> >  		}
> >  
> > -		drm_atomic_bridge_post_disable(encoder->bridge, old_state);
> > +		if (!encoder->custom_bridge_enable_disable_seq)
> > +			drm_atomic_bridge_post_disable(encoder->bridge,
> > +						       old_state);
> >  	}
> >  
> >  	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
> > @@ -1342,7 +1345,8 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
> >  		 * Each encoder has at most one connector (since we always steal
> >  		 * it away), so we won't call enable hooks twice.
> >  		 */
> > -		drm_atomic_bridge_pre_enable(encoder->bridge, old_state);
> > +		if (!encoder->custom_bridge_enable_disable_seq)
> > +			drm_atomic_bridge_pre_enable(encoder->bridge, old_state);
> >  
> >  		if (funcs) {
> >  			if (funcs->atomic_enable)
> > @@ -1353,7 +1357,8 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
> >  				funcs->commit(encoder);
> >  		}
> >  
> > -		drm_atomic_bridge_enable(encoder->bridge, old_state);
> > +		if (!encoder->custom_bridge_enable_disable_seq)
> > +			drm_atomic_bridge_enable(encoder->bridge, old_state);
> >  	}
> >  
> >  	drm_atomic_helper_commit_writebacks(dev, old_state);
> > diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
> > index fa3694836c22..87dae37fec12 100644
> > --- a/drivers/gpu/drm/drm_crtc_helper.c
> > +++ b/drivers/gpu/drm/drm_crtc_helper.c
> > @@ -160,14 +160,16 @@ drm_encoder_disable(struct drm_encoder *encoder)
> >  	if (!encoder_funcs)
> >  		return;
> >  
> > -	drm_bridge_disable(encoder->bridge);
> > +	if (!encoder->custom_bridge_enable_disable_seq)
> > +		drm_bridge_disable(encoder->bridge);
> >  
> >  	if (encoder_funcs->disable)
> >  		(*encoder_funcs->disable)(encoder);
> >  	else if (encoder_funcs->dpms)
> >  		(*encoder_funcs->dpms)(encoder, DRM_MODE_DPMS_OFF);
> >  
> > -	drm_bridge_post_disable(encoder->bridge);
> > +	if (!encoder->custom_bridge_enable_disable_seq)
> > +		drm_bridge_post_disable(encoder->bridge);
> >  }
> >  
> >  static void __drm_helper_disable_unused_functions(struct drm_device *dev)
> > @@ -365,13 +367,15 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
> >  		if (!encoder_funcs)
> >  			continue;
> >  
> > -		drm_bridge_disable(encoder->bridge);
> > +		if (!encoder->custom_bridge_enable_disable_seq)
> > +			drm_bridge_disable(encoder->bridge);
> >  
> >  		/* Disable the encoders as the first thing we do. */
> >  		if (encoder_funcs->prepare)
> >  			encoder_funcs->prepare(encoder);
> >  
> > -		drm_bridge_post_disable(encoder->bridge);
> > +		if (!encoder->custom_bridge_enable_disable_seq)
> > +			drm_bridge_post_disable(encoder->bridge);
> >  	}
> >  
> >  	drm_crtc_prepare_encoders(dev);
> > @@ -414,12 +418,14 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
> >  		if (!encoder_funcs)
> >  			continue;
> >  
> > -		drm_bridge_pre_enable(encoder->bridge);
> > +		if (!encoder->custom_bridge_enable_disable_seq)
> > +			drm_bridge_pre_enable(encoder->bridge);
> >  
> >  		if (encoder_funcs->commit)
> >  			encoder_funcs->commit(encoder);
> >  
> > -		drm_bridge_enable(encoder->bridge);
> > +		if (!encoder->custom_bridge_enable_disable_seq)
> > +			drm_bridge_enable(encoder->bridge);
> >  	}
> >  
> >  	/* Calculate and store various constants which
> > @@ -825,18 +831,22 @@ static void drm_helper_encoder_dpms(struct drm_encoder *encoder, int mode)
> >  	if (!encoder_funcs)
> >  		return;
> >  
> > -	if (mode == DRM_MODE_DPMS_ON)
> > -		drm_bridge_pre_enable(bridge);
> > -	else
> > -		drm_bridge_disable(bridge);
> > +	if (!encoder->custom_bridge_enable_disable_seq) {
> > +		if (mode == DRM_MODE_DPMS_ON)
> > +			drm_bridge_pre_enable(bridge);
> > +		else
> > +			drm_bridge_disable(bridge);
> > +	}
> >  
> >  	if (encoder_funcs->dpms)
> >  		encoder_funcs->dpms(encoder, mode);
> >  
> > -	if (mode == DRM_MODE_DPMS_ON)
> > -		drm_bridge_enable(bridge);
> > -	else
> > -		drm_bridge_post_disable(bridge);
> > +	if (!encoder->custom_bridge_enable_disable_seq) {
> > +		if (mode == DRM_MODE_DPMS_ON)
> > +			drm_bridge_enable(bridge);
> > +		else
> > +			drm_bridge_post_disable(bridge);
> > +	}
> >  }
> >  
> >  static int drm_helper_choose_crtc_dpms(struct drm_crtc *crtc)
> > diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h
> > index 70cfca03d812..d986ff1197ce 100644
> > --- a/include/drm/drm_encoder.h
> > +++ b/include/drm/drm_encoder.h
> > @@ -175,6 +175,15 @@ struct drm_encoder {
> >  	struct drm_bridge *bridge;
> >  	const struct drm_encoder_funcs *funcs;
> >  	const struct drm_encoder_helper_funcs *helper_private;
> > +
> > +	/**
> > +	 * @custom_bridge_enable_disable_seq: Set to true if the encoder needs
> > +	 * a custom bridge/encoder enable/disable sequence. In that case the
> > +	 * driver is responsible for calling the
> > +	 * drm[_atomic]_bridge_{pre_enable,enable,disable,post_disable}()
> > +	 * functions as part of its encoder enable/disable handling.
> > +	 */
> > +	uint32_t custom_bridge_enable_disable_seq : 1;
> >  };
> >  
> >  #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
> 
> -- 
> Regards,
> 
> Laurent Pinchart

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-08-21  8:21 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-08 15:11 [PATCH RFC 00/19] drm: Add support for bus-format negotiation Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 01/19] drm: Stop including drm_bridge.h from drm_crtc.h Boris Brezillon
2019-08-08 18:05   ` Sam Ravnborg
2019-08-20 18:53   ` Laurent Pinchart
2019-08-21 15:44     ` Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 02/19] drm: Support custom encoder/bridge enable/disable sequences officially Boris Brezillon
2019-08-20 19:05   ` Laurent Pinchart
2019-08-21  8:21     ` Daniel Vetter [this message]
2019-08-21 13:57       ` Laurent Pinchart
2019-08-21 15:39       ` Boris Brezillon
2019-08-21 15:30     ` Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 03/19] drm/vc4: Get rid of the dsi->bridge field Boris Brezillon
2019-08-08 20:31   ` Eric Anholt
2019-08-08 15:11 ` [PATCH RFC 04/19] drm/exynos: Get rid of exynos_dsi->out_bridge Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 05/19] drm/exynos: Don't reset bridge->next Boris Brezillon
2019-08-08 21:04   ` Boris Brezillon
2019-08-21 14:01   ` Laurent Pinchart
2019-08-08 15:11 ` [PATCH RFC 06/19] drm/bridge: Create drm_bridge_chain_xx() wrappers Boris Brezillon
2019-08-21 14:45   ` Laurent Pinchart
2019-08-21 15:53     ` Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 07/19] drm/msm: Use drm_attach_bridge() to attach a bridge to an encoder Boris Brezillon
2019-08-19 17:19   ` Sam Ravnborg
2019-08-21 14:46     ` Laurent Pinchart
2019-08-08 15:11 ` [PATCH RFC 08/19] drm/bridge: Introduce drm_bridge_chain_get_{first, last, next}_bridge() Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 09/19] drm/bridge: Make the bridge chain a double-linked list Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 10/19] drm/bridge: Add a drm_bridge_state object Boris Brezillon
2019-08-21 20:14   ` Laurent Pinchart
2019-08-22  9:00     ` Boris Brezillon
2019-12-02 15:52       ` Laurent Pinchart
2019-08-08 15:11 ` [PATCH RFC 11/19] drm/bridge: Patch atomic hooks to take a drm_bridge_state Boris Brezillon
2019-08-22  0:02   ` Laurent Pinchart
2019-08-22  8:25     ` Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 12/19] drm/bridge: Add an ->atomic_check() hook Boris Brezillon
2019-08-22  0:12   ` Laurent Pinchart
2019-08-22  7:58     ` Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 13/19] drm/bridge: Add the drm_bridge_chain_get_prev_bridge() helper Boris Brezillon
2019-08-22  0:17   ` Laurent Pinchart
2019-08-22  8:04     ` Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 14/19] drm/bridge: Add the necessary bits to support bus format negotiation Boris Brezillon
2019-08-14  7:51   ` Neil Armstrong
2019-08-21 18:31     ` Boris Brezillon
2019-08-22  0:55   ` Laurent Pinchart
2019-08-22  7:48     ` Boris Brezillon
2019-08-22  9:29       ` Neil Armstrong
2019-08-22 10:09         ` Boris Brezillon
2019-08-22 10:22           ` Neil Armstrong
2019-08-22 10:34             ` Boris Brezillon
2019-08-22 11:30               ` Neil Armstrong
2019-08-08 15:11 ` [PATCH RFC 15/19] drm/imx: pd: Use bus format/flags provided by the bridge when available Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 16/19] drm/bridge: lvds-encoder: Add a way to support custom ->atomic_check() implem Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 17/19] drm/bridge: lvds-encoder: Implement bus format negotiation for sn75lvds83 Boris Brezillon
2019-08-22  0:32   ` Laurent Pinchart
2019-08-22  8:12     ` Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 18/19] drm/panel: simple: Add support for Toshiba LTA089AC29000 panel Boris Brezillon
2019-08-22  0:36   ` Laurent Pinchart
2019-08-22  8:15     ` Boris Brezillon
2019-08-08 15:11 ` [PATCH RFC 19/19] ARM: dts: imx: imx51-zii-rdu1: Fix the display pipeline definition Boris Brezillon
2019-08-09  6:58 ` [PATCH RFC 00/19] drm: Add support for bus-format negotiation Neil Armstrong

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=20190821082107.GI11147@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=Chris.Healy@zii.aero \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@siol.net \
    --cc=jonas@kwiboo.se \
    --cc=kernel@collabora.com \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=narmstrong@baylibre.com \
    --cc=sam@ravnborg.org \
    --cc=sw0312.kim@samsung.com \
    --cc=thierry.reding@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.