devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: dri-devel@lists.freedesktop.org, "Marek Vasut" <marex@denx.de>,
	devicetree@vger.kernel.org, "Guido Günther" <agx@sigxcpu.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 8/8] drm: mxsfb: Add support for the bus-width DT property
Date: Sun, 16 Aug 2020 09:46:30 +0200	[thread overview]
Message-ID: <20200816074630.GI1201814@ravnborg.org> (raw)
In-Reply-To: <20200813012910.13576-9-laurent.pinchart@ideasonboard.com>

Hi Laurent.

On Thu, Aug 13, 2020 at 04:29:10AM +0300, Laurent Pinchart wrote:
> A new bus-width DT property has been introduced in the bindings to allow
> overriding the bus width. Support it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

We already reads the bus-width in following files in drm:
atmel-hlcdc/atmel_hlcdc_output.c bridge/ti-tfp410.c

So this calls for a common helper to do this like:

int drm_of_bus_fmt(const struct device_node *ep)
{
}

This helper could then read bus-width, data-shift (if relevant)
and return the relevant bus format.

I can see that bridge/ti-tfp410.c assumes 12 equals
MEDIA_BUS_FMT_RGB888_2X12_LE where as mxsfb assumes 12 is
MEDIA_BUS_FMT_RGB444_1X12.
I do not know why neither how to handle this difference.
Maybe this is something to do with DVI as this is what tfp410
seems to support.

	Sam


> ---
>  drivers/gpu/drm/mxsfb/mxsfb_drv.c | 26 ++++++++++++++++++++++++++
>  drivers/gpu/drm/mxsfb/mxsfb_drv.h |  2 ++
>  drivers/gpu/drm/mxsfb/mxsfb_kms.c |  8 ++++++--
>  3 files changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> index 8c549c3931af..fab3aae8cf73 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
> @@ -95,10 +95,36 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
>  {
>  	struct drm_device *drm = mxsfb->drm;
>  	struct drm_connector_list_iter iter;
> +	struct device_node *ep;
>  	struct drm_panel *panel;
>  	struct drm_bridge *bridge;
> +	u32 bus_width = 0;
>  	int ret;
>  
> +	ep = of_graph_get_endpoint_by_regs(drm->dev->of_node, 0, 0);
> +	if (!ep)
> +		return -ENODEV;
> +
> +	of_property_read_u32(ep, "bus-width", &bus_width);
> +	of_node_put(ep);
> +
> +	switch (bus_width) {
> +	case 16:
> +		mxsfb->bus_format = MEDIA_BUS_FMT_RGB565_1X16;
> +		break;
> +	case 18:
> +		mxsfb->bus_format = MEDIA_BUS_FMT_RGB666_1X18;
> +		break;
> +	case 24:
> +		mxsfb->bus_format = MEDIA_BUS_FMT_RGB888_1X24;
> +		break;
> +	case 0:
> +		break;
> +	default:
> +		DRM_DEV_ERROR(drm->dev, "Invalid bus-width %u", bus_width);
> +		return -ENODEV;
> +	}
> +
>  	ret = drm_of_find_panel_or_bridge(drm->dev->of_node, 0, 0, &panel,
>  					  &bridge);
>  	if (ret)
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h b/drivers/gpu/drm/mxsfb/mxsfb_drv.h
> index 399d23e91ed1..c4f7a8a0c891 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h
> @@ -32,6 +32,8 @@ struct mxsfb_drm_private {
>  	struct clk			*clk_axi;
>  	struct clk			*clk_disp_axi;
>  
> +	u32				bus_format;
> +
>  	struct drm_device		*drm;
>  	struct {
>  		struct drm_plane	primary;
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> index b721b8b262ce..6d512f346918 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> @@ -50,11 +50,15 @@ static void mxsfb_set_formats(struct mxsfb_drm_private *mxsfb)
>  {
>  	struct drm_device *drm = mxsfb->drm;
>  	const u32 format = mxsfb->crtc.primary->state->fb->format->format;
> -	u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
> +	u32 bus_format;
>  	u32 ctrl, ctrl1;
>  
> -	if (mxsfb->connector->display_info.num_bus_formats)
> +	if (mxsfb->bus_format)
> +		bus_format = mxsfb->bus_format;
> +	else if (mxsfb->connector->display_info.num_bus_formats)
>  		bus_format = mxsfb->connector->display_info.bus_formats[0];
> +	else
> +		bus_format = MEDIA_BUS_FMT_RGB888_1X24;
>  
>  	DRM_DEV_DEBUG_DRIVER(drm->dev, "Using bus_format: 0x%08X\n",
>  			     bus_format);
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-08-16  7:46 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13  1:29 [PATCH 0/8] drm: mxsfb: Allow overriding bus width Laurent Pinchart
2020-08-13  1:29 ` [PATCH 1/8] dt-bindings: display: mxsfb: Convert binding to YAML Laurent Pinchart
2020-08-16  6:22   ` Sam Ravnborg
2020-08-17  0:00     ` Laurent Pinchart
2020-08-24 23:59   ` Rob Herring
2020-08-13  1:29 ` [PATCH 2/8] dt-bindings: display: mxsfb: Add and fix compatible strings Laurent Pinchart
2020-08-16  6:39   ` Sam Ravnborg
2020-08-17  0:04     ` Laurent Pinchart
2020-08-24 23:57       ` Rob Herring
2020-08-21 14:53   ` Stefan Agner
2020-08-23 23:26     ` Laurent Pinchart
2020-08-24 14:19       ` Stefan Agner
2020-10-07  1:12         ` Laurent Pinchart
2020-08-13  1:29 ` [PATCH 3/8] dt-bindings: display: mxsfb: Add a bus-width endpoint property Laurent Pinchart
2020-08-15 21:28   ` Guido Günther
2020-08-17  0:09     ` Laurent Pinchart
2020-08-16  7:25   ` Sam Ravnborg
2020-08-17  0:17     ` Laurent Pinchart
2020-08-13  1:29 ` [PATCH 4/8] dt-bindings: display: mxsfb: Rename to fsl,lcdif.yaml Laurent Pinchart
2020-08-16  7:27   ` Sam Ravnborg
2020-08-21 14:55   ` Stefan Agner
2020-08-23 23:27     ` Laurent Pinchart
2020-08-13  1:29 ` [PATCH 5/8] ARM: dts: imx: Fix LCDIF compatible strings Laurent Pinchart
2020-08-16  7:28   ` Sam Ravnborg
2020-08-13  1:29 ` [PATCH 6/8] arm64: dts: imx8mq: " Laurent Pinchart
2020-08-16  7:28   ` Sam Ravnborg
2020-08-13  1:29 ` [PATCH 7/8] ARM: dts: imx: Remove unneeded LCDIF disp_axi clock Laurent Pinchart
2020-08-16  7:28   ` Sam Ravnborg
2020-08-13  1:29 ` [PATCH 8/8] drm: mxsfb: Add support for the bus-width DT property Laurent Pinchart
2020-08-16  7:46   ` Sam Ravnborg [this message]
2020-08-17  0:29     ` Laurent Pinchart

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=20200816074630.GI1201814@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=agx@sigxcpu.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=marex@denx.de \
    --cc=robh+dt@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 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).