All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Nikita Yushchenko <nikita.yoush@cogentembedded.com>,
	Jernej Skrabec <jernej.skrabec@siol.net>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Andrey Smirnov <andrew.smirnov@gmail.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	dri-devel@lists.freedesktop.org,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Chris Healy <Chris.Healy@zii.aero>,
	kernel@collabora.com, Sam Ravnborg <sam@ravnborg.org>
Subject: Re: [PATCH v2 17/21] drm/imx: pd: Use bus format/flags provided by the bridge when available
Date: Tue, 27 Aug 2019 10:43:53 +0200	[thread overview]
Message-ID: <20190827104353.1447e5ba@collabora.com> (raw)
In-Reply-To: <1566893719.4102.1.camel@pengutronix.de>

On Tue, 27 Aug 2019 10:15:19 +0200
Philipp Zabel <p.zabel@pengutronix.de> wrote:

> Hi Boris,
> 
> On Mon, 2019-08-26 at 17:26 +0200, Boris Brezillon wrote:
> > Now that bridges can expose the bus format/flags they expect, we can
> > use those instead of the relying on the display_info provided by the
> > connector (which is only valid if the encoder is directly connected
> > to bridge element driving the panel/display).
> > 
> > We also explicitly expose the bus formats supported by our encoder by
> > filling encoder->output_bus_caps with proper info.
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > ---
> > Changes in v2:
> > * Adjust things to match the new bus-format negotiation infra
> > ---
> >  drivers/gpu/drm/imx/parallel-display.c | 136 ++++++++++++++++++++++---
> >  1 file changed, 120 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c
> > index 35518e5de356..df47cb74759f 100644
> > --- a/drivers/gpu/drm/imx/parallel-display.c
> > +++ b/drivers/gpu/drm/imx/parallel-display.c
> > @@ -89,37 +89,139 @@ static struct drm_encoder *imx_pd_connector_best_encoder(
> >  	return &imxpd->encoder;
> >  }
> >  
> > -static void imx_pd_encoder_enable(struct drm_encoder *encoder)
> > +static void imx_pd_bridge_enable(struct drm_bridge *bridge)
> >  {
> > +	struct drm_encoder *encoder = bridge_to_encoder(bridge);
> >  	struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
> >  
> >  	drm_panel_prepare(imxpd->panel);
> >  	drm_panel_enable(imxpd->panel);
> >  }
> >  
> > -static void imx_pd_encoder_disable(struct drm_encoder *encoder)
> > +static void imx_pd_bridge_disable(struct drm_bridge *bridge)
> >  {
> > +	struct drm_encoder *encoder = bridge_to_encoder(bridge);
> >  	struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
> >  
> >  	drm_panel_disable(imxpd->panel);
> >  	drm_panel_unprepare(imxpd->panel);
> >  }
> >  
> > -static int imx_pd_encoder_atomic_check(struct drm_encoder *encoder,
> > -				       struct drm_crtc_state *crtc_state,
> > -				       struct drm_connector_state *conn_state)
> > +static const u32 imx_pd_bus_fmts[] = {
> > +	MEDIA_BUS_FMT_RGB888_1X24,
> > +	MEDIA_BUS_FMT_RGB565_1X16,
> > +	MEDIA_BUS_FMT_RGB666_1X18,
> > +	MEDIA_BUS_FMT_RGB666_1X24_CPADHI,  
> 
> ipu-dc.c also supports MEDIA_BUS_FMT_BGR888_1X24.

Will add that one to the list.

> 
> > +};
> > +
> > +static void
> > +imx_pd_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
> > +					 struct drm_bridge_state *bridge_state,
> > +					 struct drm_crtc_state *crtc_state,
> > +					 struct drm_connector_state *conn_state,
> > +					 unsigned int *num_output_fmts,
> > +					 u32 *output_fmts)
> >  {
> > +	struct drm_display_info *di = &conn_state->connector->display_info;
> > +	struct drm_encoder *encoder = bridge_to_encoder(bridge);
> > +	struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
> > +
> > +	*num_output_fmts = 1;
> > +	if (imxpd->bus_format) {
> > +		if (output_fmts)
> > +			output_fmts[0] = imxpd->bus_format;  
> 
> This is the legacy DT configured interface-pix-fmt. Maybe this should be
> moved to the last place.

Hm, shouldn't we restrict things to a single format when we have the
DT prop defined?

> 
> > +	} else if (di->num_bus_formats) {
> > +		*num_output_fmts = 1;  
> 
> num_output_fmts is already set to one above.

Correct, I'll get rid of this assignment.

> 
> > +		if (output_fmts)
> > +			output_fmts[0] = di->bus_formats[0];
> > +	} else {
> > +		*num_output_fmts = ARRAY_SIZE(imx_pd_bus_fmts);
> > +		if (output_fmts)
> > +			memcpy(output_fmts, imx_pd_bus_fmts,
> > +			       ARRAY_SIZE(imx_pd_bus_fmts));
> > +	}
> > +}
> > +
> > +static void
> > +imx_pd_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
> > +					struct drm_bridge_state *bridge_state,
> > +					struct drm_crtc_state *crtc_state,
> > +					struct drm_connector_state *conn_state,
> > +					u32 output_fmt,
> > +					unsigned int *num_input_fmts,
> > +					u32 *input_fmts)
> > +{
> > +	struct drm_encoder *encoder = bridge_to_encoder(bridge);
> > +	struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
> > +
> > +	*num_input_fmts = 0;
> > +	if (output_fmt == MEDIA_BUS_FMT_FIXED) {
> > +		*num_input_fmts = 1;  
> 
> I don't understand this. The bus format stored in imx_crtc_state by
> atomic_check is used to configure the DC later. This should never be
> MEDIA_BUS_FMT_FIXED, that would trigger a WARN_ON in
> ipu_bus_format_to_map().

MEDIA_BUS_FMT_FIXED is the default value used when the next bridge in
the chain does not support bus format negotiation. When the driver
receives this value, it should pick a default value (which I might have
gotten wrong here) so that it keeps working even if some elements of
the bridge chain don't support negotiating the bus format yet.

> 
> > +	} else if (!imxpd->bus_format) {
> > +		unsigned int i;
> > +
> > +		for (i = 0; i < ARRAY_SIZE(imx_pd_bus_fmts); i++) {
> > +			if (imx_pd_bus_fmts[i] == output_fmt) {
> > +				*num_input_fmts = 1;
> > +				break;
> > +			}
> > +		}
> > +	} else if (imxpd->bus_format == output_fmt) {
> > +		*num_input_fmts = 1;
> > +	}
> > +
> > +	if (*num_input_fmts && input_fmts)
> > +		input_fmts[0] = MEDIA_BUS_FMT_FIXED;  
> 
> The parallel-display driver basically represents the wiring, pinmux, and
> drivers between the IPU DI and the DISP pads. The input format should
> always be identical to the output format.

I can do that if you like. Note that we are forwarding
the ->output_bus_cfg.fmt value to the IPU DI, not ->input_bus_cfg.fmt.
I just assumed that input format wouldn't be used in the dummy bridge
element (the one embedded in the encoder) since encoders only have an
output end (input port is likely to be a SoC specific link between the
CRTC and the encoder which we probably don't need/want to expose).

> 
> > +}
> > +
> > +static int imx_pd_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 drm_encoder *encoder = bridge_to_encoder(bridge);
> >  	struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(crtc_state);
> >  	struct drm_display_info *di = &conn_state->connector->display_info;
> >  	struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
> > +	struct drm_bridge_state *next_bridge_state = NULL;
> > +	struct drm_bridge *next_bridge;
> > +	u32 bus_flags, bus_fmt;
> > +	unsigned int i;
> >  
> > -	if (!imxpd->bus_format && di->num_bus_formats) {
> > -		imx_crtc_state->bus_flags = di->bus_flags;
> > -		imx_crtc_state->bus_format = di->bus_formats[0];
> > -	} else {
> > -		imx_crtc_state->bus_flags = imxpd->bus_flags;
> > -		imx_crtc_state->bus_format = imxpd->bus_format;
> > +	next_bridge = drm_bridge_chain_get_next_bridge(bridge);
> > +	if (next_bridge)
> > +		next_bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state,
> > +								    next_bridge);
> > +
> > +	bus_fmt = bridge_state->output_bus_cfg.fmt;
> > +	if (bus_fmt == MEDIA_BUS_FMT_FIXED)
> > +		bus_fmt = 0;  
> 
> I would expect this to return with -EINVAL if bridge_state-
> >output_bus_cfg.fmt is not in the list of supported formats.

As said above, we need a way to support bridge chains where not all
elements support negotiating the bus format, that's what this fallback
is for, but maybe 0 is not an appropriate value to mean 'pick the
default format'.

> 
> > +
> > +	if (next_bridge_state)
> > +		bus_flags = next_bridge_state->input_bus_cfg.flags;
> > +	else if (!imxpd->bus_format && di->num_bus_formats)
> > +		bus_flags = di->bus_flags;
> > +	else
> > +		bus_flags = imxpd->bus_flags;
> > +
> > +	for (i = 0; bus_fmt && i < ARRAY_SIZE(imx_pd_bus_fmts); i++) {
> > +		if (imx_pd_bus_fmts[i] == bridge_state->output_bus_cfg.fmt)
> > +			break;
> >  	}
> > +
> > +	if (i == ARRAY_SIZE(imx_pd_bus_fmts))
> > +		return -EINVAL;
> > +
> > +	if (bus_flags &
> > +	    ~(DRM_BUS_FLAG_DE_LOW | DRM_BUS_FLAG_DE_HIGH |
> > +	      DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE |
> > +	      DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE))
> > +		return -EINVAL;  
> 
> This could allow DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE/NEGEDGE as well, if
> they are not opposite to PIXDATA_DRIVE.

Okay, will add those flags and check that PIXDATA and SYNC are
consistent.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26 15:26 [PATCH v2 00/21] drm: Add support for bus-format negotiation Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 01/21] drm: Stop including drm_bridge.h from drm_crtc.h Boris Brezillon
2019-08-28 20:27   ` Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 02/21] drm: Add a dummy bridge object to drm_encoder Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 03/21] drm/vc4: Implement bridge_funcs instead of encoder_helper_funcs Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 04/21] drm/exynos: Fix potential unbalanced calls to pm_runtime_put Boris Brezillon
2019-10-11 13:31   ` Boris Brezillon
2019-10-11 13:54   ` Andrzej Hajda
2019-10-11 14:20     ` Boris Brezillon
2019-10-12  7:15       ` Sam Ravnborg
2019-10-22  9:14         ` Boris Brezillon
2019-10-22 17:23     ` Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 05/21] drm/exynos: Don't reset bridge->next Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 06/21] drm/exynos: Implement bridge_funcs instead of encoder_helper_funcs Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 07/21] drm/bridge: Rename bridge helpers targeting a bridge chain Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 08/21] drm/msm: Use drm_attach_bridge() to attach a bridge to an encoder Boris Brezillon
2019-08-28 15:22   ` Sean Paul
2019-08-28 15:25     ` Boris Brezillon
2019-08-28 15:30       ` Sean Paul
2019-08-28 20:27         ` Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 09/21] drm/bridge: Introduce drm_bridge_chain_get_next_bridge() Boris Brezillon
2019-08-27  7:19   ` Neil Armstrong
2019-08-26 15:26 ` [PATCH v2 10/21] drm/bridge: Make the bridge chain a double-linked list Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 11/21] drm/bridge: Add the drm_for_each_bridge_in_chain() helper Boris Brezillon
2019-08-27  7:26   ` Neil Armstrong
2019-08-26 15:26 ` [PATCH v2 12/21] drm/bridge: Add a drm_bridge_state object Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 13/21] drm/bridge: Patch atomic hooks to take a drm_bridge_state Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 14/21] drm/bridge: Add an ->atomic_check() hook Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 15/21] drm/bridge: Add the drm_bridge_chain_get_prev_bridge() helper Boris Brezillon
2019-08-27  7:26   ` Neil Armstrong
2019-08-26 15:26 ` [PATCH v2 16/21] drm/bridge: Add the necessary bits to support bus format negotiation Boris Brezillon
2019-08-27  8:18   ` Neil Armstrong
2019-08-26 15:26 ` [PATCH v2 17/21] drm/imx: pd: Use bus format/flags provided by the bridge when available Boris Brezillon
2019-08-27  8:15   ` Philipp Zabel
2019-08-27  8:43     ` Boris Brezillon [this message]
2019-08-27  9:23       ` Philipp Zabel
2019-08-27  9:57         ` Boris Brezillon
2019-08-27 12:51           ` Philipp Zabel
2019-08-27 13:20             ` Boris Brezillon
2019-08-27 13:49               ` Philipp Zabel
2019-08-26 15:26 ` [PATCH v2 18/21] drm/bridge: lvds-encoder: Implement basic bus format negotiation Boris Brezillon
2019-08-26 16:15   ` Jernej Škrabec
2019-08-26 18:17     ` Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 19/21] drm/bridge: panel: Propage bus format/flags Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 20/21] drm/panel: simple: Add support for Toshiba LTA089AC29000 panel Boris Brezillon
2019-08-26 15:26 ` [PATCH v2 21/21] ARM: dts: imx: imx51-zii-rdu1: Fix the display pipeline definition Boris Brezillon

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=20190827104353.1447e5ba@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=Chris.Healy@zii.aero \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=andrew.smirnov@gmail.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=narmstrong@baylibre.com \
    --cc=nikita.yoush@cogentembedded.com \
    --cc=p.zabel@pengutronix.de \
    --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.