linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Stefan Agner <stefan@agner.ch>
Cc: airlied@linux.ie, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/mxsfb: use bus_format to determine LCD bus width
Date: Fri, 9 Dec 2016 00:33:34 +0100	[thread overview]
Message-ID: <878d504a-5689-1dd9-2e5e-fad085b7406e@denx.de> (raw)
In-Reply-To: <20161208225243.19792-1-stefan@agner.ch>

On 12/08/2016 11:52 PM, Stefan Agner wrote:
> The LCD bus width does not need to align with the pixel format. The
> LCDIF controller automatically converts between pixel formats and
> bus width by padding or dropping LSBs.
> 
> The DRM subsystem has the notion of bus_format which allows to
> determine what bus_formats are supported by the display. Choose the
> first available or fallback to 24 bit if none are available.
> 
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
>  drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 28 +++++++++++++++++++++++++---
>  drivers/gpu/drm/mxsfb/mxsfb_regs.h |  1 +
>  2 files changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
> index 4bcc8a3..00fa244 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c
> @@ -65,13 +65,11 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb)

You should probably drop the WARNING: comment in this function too.

>  	switch (format) {
>  	case DRM_FORMAT_RGB565:
>  		dev_dbg(drm->dev, "Setting up RGB565 mode\n");
> -		ctrl |= CTRL_SET_BUS_WIDTH(STMLCDIF_16BIT);
>  		ctrl |= CTRL_SET_WORD_LENGTH(0);
>  		ctrl1 |= CTRL1_SET_BYTE_PACKAGING(0xf);
>  		break;
>  	case DRM_FORMAT_XRGB8888:
>  		dev_dbg(drm->dev, "Setting up XRGB8888 mode\n");
> -		ctrl |= CTRL_SET_BUS_WIDTH(STMLCDIF_24BIT);
>  		ctrl |= CTRL_SET_WORD_LENGTH(3);
>  		/* Do not use packed pixels = one pixel per word instead. */
>  		ctrl1 |= CTRL1_SET_BYTE_PACKAGING(0x7);
> @@ -89,6 +87,9 @@ static int mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb)
>  
>  static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)
>  {
> +	struct drm_crtc *crtc = &mxsfb->pipe.crtc;
> +	struct drm_device *drm = crtc->dev;
> +	u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;

So why do you move the bus width configuration from
mxsfb_set_pixel_fmt() to here ? Is there any reason
for it?

>  	u32 reg;
>  
>  	if (mxsfb->clk_disp_axi)
> @@ -97,7 +98,28 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)
>  	mxsfb_enable_axi_clk(mxsfb);
>  
>  	/* If it was disabled, re-enable the mode again */
> -	writel(CTRL_DOTCLK_MODE, mxsfb->base + LCDC_CTRL + REG_SET);
> +	reg = readl(mxsfb->base + LCDC_CTRL);

Wouldn't it make more sense to cache the LCDC_CTRL content rather than
doing R-M-W on it ?

> +	reg |= CTRL_DOTCLK_MODE;
> +
> +	if (mxsfb->connector.display_info.num_bus_formats)
> +		bus_format = mxsfb->connector.display_info.bus_formats[0];
> +
> +	reg &= ~CTRL_BUS_WIDTH_MASK;
> +	switch (bus_format) {
> +	case MEDIA_BUS_FMT_RGB565_1X16:
> +		reg |= CTRL_SET_BUS_WIDTH(STMLCDIF_16BIT);
> +		break;
> +	case MEDIA_BUS_FMT_RGB666_1X18:
> +		reg |= CTRL_SET_BUS_WIDTH(STMLCDIF_18BIT);
> +		break;
> +	case MEDIA_BUS_FMT_RGB888_1X24:
> +		reg |= CTRL_SET_BUS_WIDTH(STMLCDIF_24BIT);
> +		break;
> +	default:
> +		dev_err(drm->dev, "Unknown media bus format %d\n", bus_format);
> +		break;
> +	}
> +	writel(reg, mxsfb->base + LCDC_CTRL);

On MX6SX:
Tested-by: Marek Vasut <marex@denx.de>

-- 
Best regards,
Marek Vasut

  reply	other threads:[~2016-12-09  0:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08 22:52 [PATCH] drm/mxsfb: use bus_format to determine LCD bus width Stefan Agner
2016-12-08 23:33 ` Marek Vasut [this message]
2016-12-09  3:44   ` Stefan Agner
2016-12-09  4:24     ` Marek Vasut
2016-12-13 23:56       ` Stefan Agner
2016-12-14  8:13         ` Marek Vasut

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=878d504a-5689-1dd9-2e5e-fad085b7406e@denx.de \
    --to=marex@denx.de \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stefan@agner.ch \
    /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).