From: Kieran Bingham <kieran.bingham@ideasonboard.com>
To: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
dri-devel@lists.freedesktop.org
Cc: Liviu Dudau <Liviu.Dudau@arm.com>,
James Qian Wang <james.qian.wang@arm.com>
Subject: Re: [PATCH v5 17/19] drm: rcar-du: Store V4L2 fourcc in rcar_du_format_info structure
Date: Mon, 11 Mar 2019 23:20:55 +0000 [thread overview]
Message-ID: <9e897eef-b218-df1e-cb1a-c240bbdfb7d7@ideasonboard.com> (raw)
In-Reply-To: <20190221103212.28764-18-laurent.pinchart+renesas@ideasonboard.com>
Hi Laurent,
On 21/02/2019 10:32, Laurent Pinchart wrote:
> The mapping between DRM and V4L2 fourcc's is stored in two separate
> tables in rcar_du_vsp.c. In order to make it reusable to implement
> writeback support, move it to the rcar_du_format_info structure.
It's a shame there isn't some core framework conversion helpers that do
these mappings (presumably in both directions). But even if we had one
of those, having a table entry here is a fast conversion.
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> drivers/gpu/drm/rcar-du/rcar_du_kms.c | 25 +++++++++++++++
> drivers/gpu/drm/rcar-du/rcar_du_kms.h | 1 +
> drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 44 ++++-----------------------
> 3 files changed, 32 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> index b0c80dffd8b8..999440c7b258 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
> @@ -32,60 +32,70 @@
> static const struct rcar_du_format_info rcar_du_format_infos[] = {
> {
> .fourcc = DRM_FORMAT_RGB565,
> + .v4l2 = V4L2_PIX_FMT_RGB565,
> .bpp = 16,
> .planes = 1,
> .pnmr = PnMR_SPIM_TP | PnMR_DDDF_16BPP,
> .edf = PnDDCR4_EDF_NONE,
> }, {
> .fourcc = DRM_FORMAT_ARGB1555,
> + .v4l2 = V4L2_PIX_FMT_ARGB555,
> .bpp = 16,
> .planes = 1,
> .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_ARGB,
> .edf = PnDDCR4_EDF_NONE,
> }, {
> .fourcc = DRM_FORMAT_XRGB1555,
> + .v4l2 = V4L2_PIX_FMT_XRGB555,
> .bpp = 16,
> .planes = 1,
> .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_ARGB,
> .edf = PnDDCR4_EDF_NONE,
> }, {
> .fourcc = DRM_FORMAT_XRGB8888,
> + .v4l2 = V4L2_PIX_FMT_XBGR32,
> .bpp = 32,
> .planes = 1,
> .pnmr = PnMR_SPIM_TP | PnMR_DDDF_16BPP,
> .edf = PnDDCR4_EDF_RGB888,
> }, {
> .fourcc = DRM_FORMAT_ARGB8888,
> + .v4l2 = V4L2_PIX_FMT_ABGR32,
> .bpp = 32,
> .planes = 1,
> .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_16BPP,
> .edf = PnDDCR4_EDF_ARGB8888,
> }, {
> .fourcc = DRM_FORMAT_UYVY,
> + .v4l2 = V4L2_PIX_FMT_UYVY,
> .bpp = 16,
> .planes = 1,
> .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
> .edf = PnDDCR4_EDF_NONE,
> }, {
> .fourcc = DRM_FORMAT_YUYV,
> + .v4l2 = V4L2_PIX_FMT_YUYV,
> .bpp = 16,
> .planes = 1,
> .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
> .edf = PnDDCR4_EDF_NONE,
> }, {
> .fourcc = DRM_FORMAT_NV12,
> + .v4l2 = V4L2_PIX_FMT_NV12M,
> .bpp = 12,
> .planes = 2,
> .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
> .edf = PnDDCR4_EDF_NONE,
> }, {
> .fourcc = DRM_FORMAT_NV21,
> + .v4l2 = V4L2_PIX_FMT_NV21M,
> .bpp = 12,
> .planes = 2,
> .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
> .edf = PnDDCR4_EDF_NONE,
> }, {
> .fourcc = DRM_FORMAT_NV16,
> + .v4l2 = V4L2_PIX_FMT_NV16M,
> .bpp = 16,
> .planes = 2,
> .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
> @@ -97,62 +107,77 @@ static const struct rcar_du_format_info rcar_du_format_infos[] = {
> */
> {
> .fourcc = DRM_FORMAT_RGB332,
> + .v4l2 = V4L2_PIX_FMT_RGB332,
> .bpp = 8,
> .planes = 1,
> }, {
> .fourcc = DRM_FORMAT_ARGB4444,
> + .v4l2 = V4L2_PIX_FMT_ARGB444,
> .bpp = 16,
> .planes = 1,
> }, {
> .fourcc = DRM_FORMAT_XRGB4444,
> + .v4l2 = V4L2_PIX_FMT_XRGB444,
> .bpp = 16,
> .planes = 1,
> }, {
> .fourcc = DRM_FORMAT_BGR888,
> + .v4l2 = V4L2_PIX_FMT_RGB24,
> .bpp = 24,
> .planes = 1,
> }, {
> .fourcc = DRM_FORMAT_RGB888,
> + .v4l2 = V4L2_PIX_FMT_BGR24,
> .bpp = 24,
> .planes = 1,
> }, {
> .fourcc = DRM_FORMAT_BGRA8888,
> + .v4l2 = V4L2_PIX_FMT_ARGB32,
> .bpp = 32,
> .planes = 1,
> }, {
> .fourcc = DRM_FORMAT_BGRX8888,
> + .v4l2 = V4L2_PIX_FMT_XRGB32,
> .bpp = 32,
> .planes = 1,
> }, {
> .fourcc = DRM_FORMAT_YVYU,
> + .v4l2 = V4L2_PIX_FMT_YVYU,
> .bpp = 16,
> .planes = 1,
> }, {
> .fourcc = DRM_FORMAT_NV61,
> + .v4l2 = V4L2_PIX_FMT_NV61M,
> .bpp = 16,
> .planes = 2,
> }, {
> .fourcc = DRM_FORMAT_YUV420,
> + .v4l2 = V4L2_PIX_FMT_YUV420M,
> .bpp = 12,
> .planes = 3,
> }, {
> .fourcc = DRM_FORMAT_YVU420,
> + .v4l2 = V4L2_PIX_FMT_YVU420M,
> .bpp = 12,
> .planes = 3,
> }, {
> .fourcc = DRM_FORMAT_YUV422,
> + .v4l2 = V4L2_PIX_FMT_YUV422M,
> .bpp = 16,
> .planes = 3,
> }, {
> .fourcc = DRM_FORMAT_YVU422,
> + .v4l2 = V4L2_PIX_FMT_YVU422M,
> .bpp = 16,
> .planes = 3,
> }, {
> .fourcc = DRM_FORMAT_YUV444,
> + .v4l2 = V4L2_PIX_FMT_YUV444M,
> .bpp = 24,
> .planes = 3,
> }, {
> .fourcc = DRM_FORMAT_YVU444,
> + .v4l2 = V4L2_PIX_FMT_YVU444M,
> .bpp = 24,
> .planes = 3,
Phew, that was a chore.. But they all match up to their respective
comparisons from the two original tables.
These 'name' inversions are fun:
DRM_FORMAT_BGR888, V4L2_PIX_FMT_RGB24,
DRM_FORMAT_RGB888, V4L2_PIX_FMT_BGR24,
DRM_FORMAT_BGRA8888, V4L2_PIX_FMT_ARGB32,
DRM_FORMAT_BGRX8888, V4L2_PIX_FMT_XRGB32,
DRM_FORMAT_ARGB8888, V4L2_PIX_FMT_ABGR32,
DRM_FORMAT_XRGB8888, V4L2_PIX_FMT_XBGR32,
But they all check out.
> },
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.h b/drivers/gpu/drm/rcar-du/rcar_du_kms.h
> index e171527abdaa..0346504d8c59 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.h
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.h
> @@ -19,6 +19,7 @@ struct rcar_du_device;
>
> struct rcar_du_format_info {
> u32 fourcc;
> + u32 v4l2;
> unsigned int bpp;
> unsigned int planes;
> unsigned int pnmr;
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> index 28bfeb8c24fb..29a08f7b0761 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> @@ -109,8 +109,7 @@ void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc)
> vsp1_du_atomic_flush(crtc->vsp->vsp, crtc->vsp_pipe, &cfg);
> }
>
> -/* Keep the two tables in sync. */
> -static const u32 formats_kms[] = {
> +static const u32 rcar_du_vsp_formats[] = {
> DRM_FORMAT_RGB332,
> DRM_FORMAT_ARGB4444,
> DRM_FORMAT_XRGB4444,
> @@ -138,40 +137,13 @@ static const u32 formats_kms[] = {
> DRM_FORMAT_YVU444,
> };
>
> -static const u32 formats_v4l2[] = {
> - V4L2_PIX_FMT_RGB332,
> - V4L2_PIX_FMT_ARGB444,
> - V4L2_PIX_FMT_XRGB444,
> - V4L2_PIX_FMT_ARGB555,
> - V4L2_PIX_FMT_XRGB555,
> - V4L2_PIX_FMT_RGB565,
> - V4L2_PIX_FMT_RGB24,
> - V4L2_PIX_FMT_BGR24,
> - V4L2_PIX_FMT_ARGB32,
> - V4L2_PIX_FMT_XRGB32,
> - V4L2_PIX_FMT_ABGR32,
> - V4L2_PIX_FMT_XBGR32,
> - V4L2_PIX_FMT_UYVY,
> - V4L2_PIX_FMT_YUYV,
> - V4L2_PIX_FMT_YVYU,
> - V4L2_PIX_FMT_NV12M,
> - V4L2_PIX_FMT_NV21M,
> - V4L2_PIX_FMT_NV16M,
> - V4L2_PIX_FMT_NV61M,
> - V4L2_PIX_FMT_YUV420M,
> - V4L2_PIX_FMT_YVU420M,
> - V4L2_PIX_FMT_YUV422M,
> - V4L2_PIX_FMT_YVU422M,
> - V4L2_PIX_FMT_YUV444M,
> - V4L2_PIX_FMT_YVU444M,
> -};
> -
> static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
> {
> struct rcar_du_vsp_plane_state *state =
> to_rcar_vsp_plane_state(plane->plane.state);
> struct rcar_du_crtc *crtc = to_rcar_crtc(state->state.crtc);
> struct drm_framebuffer *fb = plane->plane.state->fb;
> + const struct rcar_du_format_info *format;
> struct vsp1_du_atomic_config cfg = {
> .pixelformat = 0,
> .pitch = fb->pitches[0],
> @@ -194,12 +166,8 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
> cfg.mem[i] = sg_dma_address(state->sg_tables[i].sgl)
> + fb->offsets[i];
>
> - for (i = 0; i < ARRAY_SIZE(formats_kms); ++i) {
> - if (formats_kms[i] == state->format->fourcc) {
> - cfg.pixelformat = formats_v4l2[i];
> - break;
> - }
> - }
> + format = rcar_du_format_info(state->format->fourcc);
> + cfg.pixelformat = format->v4l2;
>
> vsp1_du_atomic_update(plane->vsp->vsp, crtc->vsp_pipe,
> plane->index, &cfg);
> @@ -394,8 +362,8 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
>
> ret = drm_universal_plane_init(rcdu->ddev, &plane->plane, crtcs,
> &rcar_du_vsp_plane_funcs,
> - formats_kms,
> - ARRAY_SIZE(formats_kms),
> + rcar_du_vsp_formats,
> + ARRAY_SIZE(rcar_du_vsp_formats),
> NULL, type, NULL);
> if (ret < 0)
> return ret;
>
--
Regards
--
Kieran
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-03-11 23:21 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 10:31 [PATCH v5 00/19] R-Car DU display writeback support Laurent Pinchart
2019-02-21 10:31 ` [PATCH v5 01/19] Revert "[media] v4l: vsp1: Supply frames to the DU continuously" Laurent Pinchart
2019-02-21 13:16 ` Kieran Bingham
2019-02-21 10:31 ` [PATCH v5 02/19] media: vsp1: wpf: Fix partition configuration for display pipelines Laurent Pinchart
2019-02-21 10:31 ` [PATCH v5 03/19] media: vsp1: Replace leftover occurrence of fragment with body Laurent Pinchart
2019-02-21 10:31 ` [PATCH v5 04/19] media: vsp1: Fix addresses of display-related registers for VSP-DL Laurent Pinchart
2019-02-21 10:31 ` [PATCH v5 05/19] media: vsp1: Refactor vsp1_video_complete_buffer() for later reuse Laurent Pinchart
2019-02-21 10:31 ` [PATCH v5 06/19] media: vsp1: Replace the display list internal flag with a flags field Laurent Pinchart
2019-02-21 10:32 ` [PATCH v5 07/19] media: vsp1: dl: Support one-shot entries in the display list Laurent Pinchart
2019-02-21 13:16 ` Kieran Bingham
2019-02-22 14:30 ` Brian Starkey
2019-02-22 14:46 ` Laurent Pinchart
2019-02-22 15:06 ` Brian Starkey
2019-03-05 23:14 ` Laurent Pinchart
2019-03-06 11:05 ` Brian Starkey
2019-03-06 18:22 ` Laurent Pinchart
2019-03-07 12:28 ` Brian Starkey
2019-03-08 12:24 ` Laurent Pinchart
2019-03-18 16:59 ` Brian Starkey
2019-03-19 10:00 ` Laurent Pinchart
2019-03-06 14:20 ` Liviu Dudau
2019-03-06 18:01 ` Laurent Pinchart
2019-03-07 11:52 ` Liviu Dudau
2019-03-07 13:48 ` Laurent Pinchart
2019-03-07 16:31 ` Liviu Dudau
2019-03-08 12:46 ` Laurent Pinchart
2019-03-08 15:02 ` Liviu Dudau
2019-03-13 0:56 ` Laurent Pinchart
2019-02-21 10:32 ` [PATCH v5 08/19] media: vsp1: wpf: Add writeback support Laurent Pinchart
2019-02-21 10:32 ` [PATCH v5 09/19] media: vsp1: drm: Split RPF format setting to separate function Laurent Pinchart
2019-02-21 10:32 ` [PATCH v5 10/19] media: vsp1: drm: Extend frame completion API to the DU driver Laurent Pinchart
2019-02-21 10:32 ` [PATCH v5 11/19] media: vsp1: drm: Implement writeback support Laurent Pinchart
2019-02-21 10:32 ` [PATCH v5 12/19] drm: writeback: Cleanup job ownership handling when queuing job Laurent Pinchart
2019-02-21 10:42 ` Laurent Pinchart
2019-02-21 16:02 ` Brian Starkey
2019-02-21 21:56 ` Laurent Pinchart
2019-02-22 13:33 ` Brian Starkey
2019-02-21 16:40 ` Eric Anholt
2019-02-26 18:07 ` Liviu Dudau
2019-02-21 10:32 ` [PATCH v5 13/19] drm: writeback: Fix leak of writeback job Laurent Pinchart
2019-02-21 17:48 ` Brian Starkey
2019-02-26 18:10 ` Liviu Dudau
2019-02-21 10:32 ` [PATCH v5 14/19] drm: writeback: Add job prepare and cleanup operations Laurent Pinchart
2019-02-21 18:12 ` Brian Starkey
2019-02-21 22:12 ` Laurent Pinchart
2019-02-22 13:50 ` Brian Starkey
2019-02-22 14:49 ` Laurent Pinchart
2019-02-22 15:11 ` Brian Starkey
2019-02-26 18:39 ` Liviu Dudau
2019-02-27 12:38 ` Laurent Pinchart
2019-02-21 10:32 ` [PATCH v5 15/19] drm/msm: Remove prototypes for non-existing functions Laurent Pinchart
2019-02-21 10:39 ` Laurent Pinchart
2019-03-13 0:00 ` Laurent Pinchart
2020-12-16 2:54 ` Laurent Pinchart
2019-03-13 9:05 ` Kieran Bingham
2019-02-21 10:32 ` [PATCH v5 16/19] drm: rcar-du: Fix rcar_du_crtc structure documentation Laurent Pinchart
2019-03-11 22:57 ` Kieran Bingham
2019-03-12 15:24 ` Laurent Pinchart
2019-03-12 20:42 ` Kieran Bingham
2019-02-21 10:32 ` [PATCH v5 17/19] drm: rcar-du: Store V4L2 fourcc in rcar_du_format_info structure Laurent Pinchart
2019-03-11 23:20 ` Kieran Bingham [this message]
2019-02-21 10:32 ` [PATCH v5 18/19] drm: rcar-du: vsp: Extract framebuffer (un)mapping to separate functions Laurent Pinchart
2019-02-21 10:32 ` [PATCH v5 19/19] drm: rcar-du: Add writeback support for R-Car Gen3 Laurent Pinchart
2019-02-22 14:04 ` [PATCH v5 00/19] R-Car DU display writeback support Brian Starkey
2019-02-22 14:47 ` 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=9e897eef-b218-df1e-cb1a-c240bbdfb7d7@ideasonboard.com \
--to=kieran.bingham@ideasonboard.com \
--cc=Liviu.Dudau@arm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=james.qian.wang@arm.com \
--cc=laurent.pinchart+renesas@ideasonboard.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox