dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Agner <stefan@agner.ch>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Marek Vasut <marex@denx.de>,
	kernel@pengutronix.de, dri-devel@lists.freedesktop.org,
	linux-imx@nxp.com
Subject: Re: [PATCH 20/21] drm: mxsfb: Merge mxsfb_set_pixel_fmt() and mxsfb_set_bus_fmt()
Date: Tue, 24 Mar 2020 00:34:28 +0100	[thread overview]
Message-ID: <ac95b58bf0574cf14840997466c8c9dd@agner.ch> (raw)
In-Reply-To: <20200309195216.31042-21-laurent.pinchart@ideasonboard.com>

On 2020-03-09 20:52, Laurent Pinchart wrote:
> The mxsfb_set_pixel_fmt() and mxsfb_set_bus_fmt() functions both deal
> with format configuration, are always called in a row from
> mxsfb_crtc_mode_set_nofb(), and set fields from the LCDC_CTRL register.
> This requires a read-modify-update cycle in mxsfb_set_bus_fmt(). Make
> this more efficient by merging them together.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Stefan Agner <stefan@agner.ch>

> ---
>  drivers/gpu/drm/mxsfb/mxsfb_kms.c | 47 +++++++++++++------------------
>  1 file changed, 19 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> index 19b937b383cf..f81f8c222c13 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> @@ -42,13 +42,23 @@ static u32 set_hsync_pulse_width(struct
> mxsfb_drm_private *mxsfb, u32 val)
>  		mxsfb->devdata->hs_wdth_shift;
>  }
>  
> -/* Setup the MXSFB registers for decoding the pixels out of the framebuffer */
> -static void mxsfb_set_pixel_fmt(struct mxsfb_drm_private *mxsfb)
> +/*
> + * Setup the MXSFB registers for decoding the pixels out of the framebuffer and
> + * outputting them on the bus.
> + */
> +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 ctrl, ctrl1;
>  
> +	if (mxsfb->connector->display_info.num_bus_formats)
> +		bus_format = mxsfb->connector->display_info.bus_formats[0];
> +
> +	DRM_DEV_DEBUG_DRIVER(drm->dev, "Using bus_format: 0x%08X\n",
> +			     bus_format);
> +
>  	ctrl = CTRL_BYPASS_COUNT | CTRL_MASTER;
>  
>  	/* CTRL1 contains IRQ config and status bits, preserve those. */
> @@ -69,40 +79,23 @@ static void mxsfb_set_pixel_fmt(struct
> mxsfb_drm_private *mxsfb)
>  		break;
>  	}
>  
> -	writel(ctrl1, mxsfb->base + LCDC_CTRL1);
> -	writel(ctrl, mxsfb->base + LCDC_CTRL);
> -}
> -
> -static void mxsfb_set_bus_fmt(struct mxsfb_drm_private *mxsfb)
> -{
> -	struct drm_device *drm = mxsfb->drm;
> -	u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
> -	u32 reg;
> -
> -	reg = readl(mxsfb->base + LCDC_CTRL);
> -
> -	if (mxsfb->connector->display_info.num_bus_formats)
> -		bus_format = mxsfb->connector->display_info.bus_formats[0];
> -
> -	DRM_DEV_DEBUG_DRIVER(drm->dev, "Using bus_format: 0x%08X\n",
> -			     bus_format);
> -
> -	reg &= ~CTRL_BUS_WIDTH_MASK;
>  	switch (bus_format) {
>  	case MEDIA_BUS_FMT_RGB565_1X16:
> -		reg |= CTRL_BUS_WIDTH_16;
> +		ctrl |= CTRL_BUS_WIDTH_16;
>  		break;
>  	case MEDIA_BUS_FMT_RGB666_1X18:
> -		reg |= CTRL_BUS_WIDTH_18;
> +		ctrl |= CTRL_BUS_WIDTH_18;
>  		break;
>  	case MEDIA_BUS_FMT_RGB888_1X24:
> -		reg |= CTRL_BUS_WIDTH_24;
> +		ctrl |= CTRL_BUS_WIDTH_24;
>  		break;
>  	default:
>  		dev_err(drm->dev, "Unknown media bus format %d\n", bus_format);
>  		break;
>  	}
> -	writel(reg, mxsfb->base + LCDC_CTRL);
> +
> +	writel(ctrl1, mxsfb->base + LCDC_CTRL1);
> +	writel(ctrl, mxsfb->base + LCDC_CTRL);
>  }
>  
>  static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb)
> @@ -213,7 +206,7 @@ static void mxsfb_crtc_mode_set_nofb(struct
> mxsfb_drm_private *mxsfb)
>  	/* Clear the FIFOs */
>  	writel(CTRL1_FIFO_CLEAR, mxsfb->base + LCDC_CTRL1 + REG_SET);
>  
> -	mxsfb_set_pixel_fmt(mxsfb);
> +	mxsfb_set_formats(mxsfb);
>  
>  	clk_set_rate(mxsfb->clk, m->crtc_clock * 1000);
>  
> @@ -255,8 +248,6 @@ static void mxsfb_crtc_mode_set_nofb(struct
> mxsfb_drm_private *mxsfb)
>  
>  	writel(vdctrl0, mxsfb->base + LCDC_VDCTRL0);
>  
> -	mxsfb_set_bus_fmt(mxsfb);
> -
>  	/* Frame length in lines. */
>  	writel(m->crtc_vtotal, mxsfb->base + LCDC_VDCTRL1);
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-03-23 23:34 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 19:51 [PATCH 00/21] drm: mxsfb: Add i.MX7 support Laurent Pinchart
2020-03-09 19:51 ` [PATCH 01/21] drm: mxsfb: Remove fbdev leftovers Laurent Pinchart
2020-03-23 20:23   ` Stefan Agner
2020-03-09 19:51 ` [PATCH 02/21] drm: mxsfb: Use drm_panel_bridge Laurent Pinchart
2020-03-23 21:27   ` Stefan Agner
2020-03-23 21:38     ` Sam Ravnborg
2020-03-23 23:50       ` Stefan Agner
2020-05-30  2:14     ` Laurent Pinchart
2020-06-02 13:12       ` Daniel Vetter
2020-06-02 14:34         ` Stefan Agner
2020-06-02 17:18           ` Laurent Pinchart
2020-06-02 17:13         ` Laurent Pinchart
2020-06-03  8:16           ` Daniel Vetter
2020-06-04 20:10             ` Sam Ravnborg
2020-03-09 19:51 ` [PATCH 03/21] drm: mxsfb: Use BIT() macro to define register bitfields Laurent Pinchart
2020-03-23 21:34   ` Stefan Agner
2020-03-09 19:51 ` [PATCH 04/21] drm: mxsfb: Remove unused macros from mxsfb_regs.h Laurent Pinchart
2020-03-23 21:36   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 05/21] drm: mxsfb: Clarify format and bus width configuration Laurent Pinchart
2020-03-23 21:42   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 06/21] drm: mxsfb: Pass mxsfb_drm_private pointer to mxsfb_reset_block() Laurent Pinchart
2020-03-23 21:43   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 07/21] drm: mxsfb: Use LCDC_CTRL register name explicitly Laurent Pinchart
2020-03-23 21:48   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 08/21] drm: mxsfb: Remove register definitions from mxsfb_crtc.c Laurent Pinchart
2020-03-23 21:49   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 09/21] drm: mxsfb: Remove unneeded includes Laurent Pinchart
2020-03-23 21:53   ` Stefan Agner
2020-05-30  0:33     ` Laurent Pinchart
2020-03-09 19:52 ` [PATCH 10/21] drm: mxsfb: Stop using DRM simple display pipeline helper Laurent Pinchart
2020-03-23 22:30   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 11/21] drm: mxsfb: Rename mxsfb_crtc.c to mxsfb_kms.c Laurent Pinchart
2020-03-23 22:31   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 12/21] drm: mxsfb: Move vblank event arm to CRTC .atomic_flush() Laurent Pinchart
2020-03-23 22:38   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 13/21] drm: mxsfb: Don't touch AXI clock in IRQ context Laurent Pinchart
2020-03-23 22:50   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 14/21] drm: mxsfb: Enable vblank handling Laurent Pinchart
2020-03-23 23:08   ` Stefan Agner
2020-03-24 10:37     ` Stefan Agner
2020-03-09 19:52 ` [PATCH 15/21] drm: mxsfb: Remove mxsfb_devdata unused fields Laurent Pinchart
2020-03-23 23:15   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 16/21] drm: mxsfb: Add i.MX7 to the list of supported SoCs in Kconfig Laurent Pinchart
2020-03-10 16:28   ` Fabio Estevam
2020-03-10 16:32     ` Laurent Pinchart
2020-03-10 16:37       ` [PATCH v1.1 " Laurent Pinchart
2020-03-23 23:18   ` [PATCH " Stefan Agner
2020-03-09 19:52 ` [PATCH 17/21] drm: mxsfb: Update internal IP version number for i.MX6SX Laurent Pinchart
2020-03-23 23:20   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 18/21] drm: mxsfb: Drop non-OF support Laurent Pinchart
2020-03-23 23:23   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 19/21] drm: mxsfb: Turn mxsfb_set_pixel_fmt() into a void function Laurent Pinchart
2020-03-23 23:28   ` Stefan Agner
2020-03-09 19:52 ` [PATCH 20/21] drm: mxsfb: Merge mxsfb_set_pixel_fmt() and mxsfb_set_bus_fmt() Laurent Pinchart
2020-03-23 23:34   ` Stefan Agner [this message]
2020-03-09 19:52 ` [PATCH 21/21] drm: mxsfb: Support the alpha plane Laurent Pinchart
2020-03-23 23:48   ` Stefan Agner
2020-05-30  2:44     ` Laurent Pinchart
2020-03-19  9:36 ` [PATCH 00/21] drm: mxsfb: Add i.MX7 support Laurent Pinchart
2020-04-12 16:37 ` Guido Günther
2020-05-26 15:13 ` Stefan Agner
2020-05-30  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=ac95b58bf0574cf14840997466c8c9dd@agner.ch \
    --to=stefan@agner.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-imx@nxp.com \
    --cc=marex@denx.de \
    --subject='Re: [PATCH 20/21] drm: mxsfb: Merge mxsfb_set_pixel_fmt() and mxsfb_set_bus_fmt()' \
    /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

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).