All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Rosin <peda@axentia.se>
To: Jacopo Mondi <jacopo+renesas@jmondi.org>,
	architt@codeaurora.org, a.hajda@samsung.com,
	Laurent.pinchart@ideasonboard.com, airlied@linux.ie
Cc: daniel@ffwll.ch, linux-renesas-soc@vger.kernel.org,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/8] drm: rcar-du: rcar-lvds: Add bridge format support
Date: Sun, 22 Apr 2018 22:08:21 +0200	[thread overview]
Message-ID: <11e82e23-4ab0-7441-1798-1eeb4fb96995@axentia.se> (raw)
In-Reply-To: <1524130269-32688-7-git-send-email-jacopo+renesas@jmondi.org>

On 2018-04-19 11:31, Jacopo Mondi wrote:
> With the introduction of static input image format enumeration in DRM
> bridges, add support to retrieve the format in rcar-lvds LVDS encoder
> from both panel or bridge, to set the desired LVDS mode.
> 
> Do not rely on 'DRM_BUS_FLAG_DATA_LSB_TO_MSB' flag to mirror the LVDS
> format, as it is only defined for drm connectors, but use the newly
> introduced _LE version of LVDS mbus image formats.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
>  drivers/gpu/drm/rcar-du/rcar_lvds.c | 64 +++++++++++++++++++++++++------------
>  1 file changed, 44 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_lvds.c b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> index 3d2d3bb..2fa875f 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_lvds.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_lvds.c
> @@ -280,41 +280,65 @@ static bool rcar_lvds_mode_fixup(struct drm_bridge *bridge,
>  	return true;
>  }
>  
> -static void rcar_lvds_get_lvds_mode(struct rcar_lvds *lvds)
> +static int rcar_lvds_get_lvds_mode_from_connector(struct rcar_lvds *lvds,
> +						  unsigned int *bus_fmt)
>  {
>  	struct drm_display_info *info = &lvds->connector.display_info;
> -	enum rcar_lvds_mode mode;
> -
> -	/*
> -	 * There is no API yet to retrieve LVDS mode from a bridge, only panels
> -	 * are supported.
> -	 */
> -	if (!lvds->panel)
> -		return;
>  
>  	if (!info->num_bus_formats || !info->bus_formats) {
>  		dev_err(lvds->dev, "no LVDS bus format reported\n");
> -		return;
> +		return -EINVAL;
> +	}
> +
> +	*bus_fmt = info->bus_formats[0];
> +
> +	return 0;
> +}
> +
> +static int rcar_lvds_get_lvds_mode_from_bridge(struct rcar_lvds *lvds,
> +					       unsigned int *bus_fmt)
> +{
> +	if (!lvds->next_bridge->num_bus_formats ||
> +	    !lvds->next_bridge->bus_formats) {
> +		dev_err(lvds->dev, "no LVDS bus format reported\n");
> +		return -EINVAL;
>  	}
>  
> -	switch (info->bus_formats[0]) {
> +	*bus_fmt = lvds->next_bridge->bus_formats[0];

What makes the first reported format the best choice?

> +
> +	return 0;
> +}
> +
> +static void rcar_lvds_get_lvds_mode(struct rcar_lvds *lvds)
> +{
> +	unsigned int bus_fmt;
> +	int ret;
> +
> +	if (lvds->panel)
> +		ret = rcar_lvds_get_lvds_mode_from_connector(lvds, &bus_fmt);
> +	else
> +		ret = rcar_lvds_get_lvds_mode_from_bridge(lvds, &bus_fmt);

What if no bridge reports any format, shouldn't the connector be examined
then?

> +	if (ret)
> +		return;
> +
> +	switch (bus_fmt) {
> +	case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG_LE:
> +	case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA_LE:
> +		lvds->mode |= RCAR_LVDS_MODE_MIRROR;
>  	case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
>  	case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
> -		mode = RCAR_LVDS_MODE_JEIDA;
> +		lvds->mode = RCAR_LVDS_MODE_JEIDA;

This is b0rken, first the mirror bit is ORed into some unknown preexisting
value, then the code falls through (without any fall through comment, btw)
and forcibly sets the mode, thus discarding the mirror bit which was
carefully ORed in.

>  		break;
> +
> +	case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG_LE:
> +		lvds->mode |= RCAR_LVDS_MODE_MIRROR;
>  	case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
> -		mode = RCAR_LVDS_MODE_VESA;
> +		lvds->mode = RCAR_LVDS_MODE_VESA;

Dito.

Cheers,
Peter

>  		break;
>  	default:
>  		dev_err(lvds->dev, "unsupported LVDS bus format 0x%04x\n",
> -			info->bus_formats[0]);
> -		return;
> +			bus_fmt);
>  	}
> -
> -	if (info->bus_flags & DRM_BUS_FLAG_DATA_LSB_TO_MSB)
> -		mode |= RCAR_LVDS_MODE_MIRROR;
> -
> -	lvds->mode = mode;
>  }
>  
>  static void rcar_lvds_mode_set(struct drm_bridge *bridge,
> 

  reply	other threads:[~2018-04-22 20:08 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19  9:31 [PATCH 0/8] drm: bridge: Add support for static image formats Jacopo Mondi
2018-04-19  9:31 ` [PATCH 1/8] " Jacopo Mondi
2018-04-22 20:02   ` Peter Rosin
2018-04-26 18:44     ` jacopo mondi
2018-04-26 18:44       ` jacopo mondi
2018-04-23  9:27   ` Laurent Pinchart
2018-04-23  9:27     ` Laurent Pinchart
2018-04-26 18:40     ` jacopo mondi
2018-04-26 18:40       ` jacopo mondi
2018-04-26 19:57       ` Laurent Pinchart
2018-04-26 19:57         ` Laurent Pinchart
2018-04-19  9:31 ` [PATCH 2/8] dt-bindings: display: bridge: thc63lvd1024: Add lvds map property Jacopo Mondi
2018-04-22 20:02   ` Peter Rosin
2018-04-23  7:35     ` jacopo mondi
2018-04-23  7:35       ` jacopo mondi
2018-04-23 11:59       ` Laurent Pinchart
2018-04-23 11:59         ` Laurent Pinchart
2018-04-23 12:02   ` Laurent Pinchart
2018-04-23 12:02     ` Laurent Pinchart
2018-04-24 16:37   ` Rob Herring
2018-04-24 16:37     ` Rob Herring
2018-04-19  9:31 ` [PATCH 3/8] drm: bridge: thc63lvd1024: Add support for LVDS mode map Jacopo Mondi
2018-04-22 20:02   ` Peter Rosin
2018-04-23  7:41     ` jacopo mondi
2018-04-23 12:12       ` Laurent Pinchart
2018-04-23 12:12         ` Laurent Pinchart
2018-04-23 12:08   ` Laurent Pinchart
2018-04-23 12:08     ` Laurent Pinchart
2018-04-19  9:31 ` [PATCH 4/8] arm64: dts: renesas: eagle: Add thc63 LVDS map Jacopo Mondi
2018-04-23 10:29   ` Simon Horman
2018-04-23 13:07   ` Laurent Pinchart
2018-04-23 13:07     ` Laurent Pinchart
2018-04-19  9:31 ` [PATCH 5/8] media: Add LE version of RGB LVDS formats Jacopo Mondi
2018-04-23 13:06   ` Laurent Pinchart
2018-04-23 13:06     ` Laurent Pinchart
2018-04-24  7:16     ` jacopo mondi
2018-04-24  7:16       ` jacopo mondi
2018-04-19  9:31 ` [PATCH 6/8] drm: rcar-du: rcar-lvds: Add bridge format support Jacopo Mondi
2018-04-22 20:08   ` Peter Rosin [this message]
2018-04-23  7:28     ` jacopo mondi
2018-04-23  7:28       ` jacopo mondi
2018-04-23  7:59       ` Peter Rosin
2018-04-23  8:47         ` jacopo mondi
2018-04-23  8:47           ` jacopo mondi
2018-04-23 12:59           ` Laurent Pinchart
2018-04-23 12:59             ` Laurent Pinchart
2018-04-19  9:31 ` [PATCH 7/8] drm: panel: Use _LE LVDS formats for data mirroring Jacopo Mondi
2018-04-19  9:31 ` [PATCH 8/8] drm: connector: Remove DRM_BUS_FLAG_DATA_* flags Jacopo Mondi
2018-04-23 21:03   ` Laurent Pinchart
2018-04-23 21:03     ` Laurent Pinchart
2018-04-24  7:22     ` jacopo mondi
2018-04-24  7:22       ` jacopo mondi

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=11e82e23-4ab0-7441-1798-1eeb4fb96995@axentia.se \
    --to=peda@axentia.se \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=architt@codeaurora.org \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jacopo+renesas@jmondi.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    /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.