diff mbox series

drm: renesas: Extend RZ/G2L supported KMS formats

Message ID 20250321172220.867165-1-kieran.bingham@ideasonboard.com (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series drm: renesas: Extend RZ/G2L supported KMS formats | expand

Commit Message

Kieran Bingham March 21, 2025, 5:22 p.m. UTC
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

The RZ/G2L driver utilises the VSPD to read data from input sources.

The rzg2l_du_kms component lists a restricted subset of the capabilities
of the VSPd which prevents additional formats from being used for
display planes.

The supported display plane formats are mapped in rzg2l_du_vsp_formats[].

Extend the rzg2l_du_format_infos[] table with the corresponding mappings
between the supported DRM formats and the formats exposed by the VSP in
rzg2l_du_vsp_formats, maintaining the same ordering in both tables.

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---
 drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c | 141 ++++++++++++++++++-
 1 file changed, 136 insertions(+), 5 deletions(-)

Prior to this patch, kmstest reports all of these formats as supported
by the Planes, but using them fails during rzg2l_du_fb_create() as the
corresponding format isn't found in rzg2l_du_format_info.

This patch now lets me capture and render pixelformats from the Mali-C55
direct to an attached DSI panel on the Kakip board.

Patch tested with kms-tests:

PYTHONPATH=/usr/lib/aarch64-linux-gnu/python3.11/site-packages ./tests/kms-test-formats.py 
Testing plane formats: SUCCESS

admin@kakip:~/kms-tests$ cat FormatsTest.log 
U [66.967523] Testing plane formats
U [66.975763] Testing connector DSI-1, CRTC 36, mode 720x1280
U [66.978480] Testing format PixelFormat.RGB332
U [70.143998] Testing format PixelFormat.ARGB4444
U [73.357056] Testing format PixelFormat.XRGB4444
U [76.574944] Testing format PixelFormat.ARGB1555
U [79.805636] Testing format PixelFormat.XRGB1555
U [83.016599] Testing format PixelFormat.RGB565
U [86.230362] Testing format PixelFormat.BGR888
U [89.444673] Testing format PixelFormat.RGB888
U [92.677093] Testing format PixelFormat.BGRA8888
U [95.904745] Testing format PixelFormat.BGRX8888
U [99.119926] Testing format PixelFormat.ARGB8888
U [102.350298] Testing format PixelFormat.XRGB8888
U [105.579499] Testing format PixelFormat.UYVY
U [108.878654] Testing format PixelFormat.YUYV
U [112.176515] Testing format PixelFormat.YVYU
U [115.470090] Testing format PixelFormat.NV12
U [118.767513] Testing format PixelFormat.NV21
U [122.065851] Testing format PixelFormat.NV16
U [125.364001] Testing format PixelFormat.NV61
U [128.662145] Testing format PixelFormat.YUV420
U [131.978102] Testing format PixelFormat.YVU420
U [135.292284] Testing format PixelFormat.YUV422
U [138.623485] Testing format PixelFormat.YVU422
U [141.955083] Testing format PixelFormat.YUV444
U [145.336759] Testing format PixelFormat.YVU444
U [148.761832] Test completed successfully

Comments

Biju Das March 21, 2025, 6:40 p.m. UTC | #1
Hi Kieran,

Thanks for the patch.

> -----Original Message-----
> From: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Sent: 21 March 2025 17:22
> Subject: [PATCH] drm: renesas: Extend RZ/G2L supported KMS formats
> 
> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
> The RZ/G2L driver utilises the VSPD to read data from input sources.
> 
> The rzg2l_du_kms component lists a restricted subset of the capabilities of the VSPd which prevents

VSPD

> additional formats from being used for display planes.
> 
> The supported display plane formats are mapped in rzg2l_du_vsp_formats[].
> 
> Extend the rzg2l_du_format_infos[] table with the corresponding mappings between the supported DRM
> formats and the formats exposed by the VSP in rzg2l_du_vsp_formats, maintaining the same ordering in
> both tables.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c | 141 ++++++++++++++++++-
>  1 file changed, 136 insertions(+), 5 deletions(-)
> 
> Prior to this patch, kmstest reports all of these formats as supported by the Planes, but using them
> fails during rzg2l_du_fb_create() as the corresponding format isn't found in rzg2l_du_format_info.
> 
> This patch now lets me capture and render pixelformats from the Mali-C55 direct to an attached DSI
> panel on the Kakip board.

Previously I got a comment to remove all the formats from this table as DSI supports only 3 formats.

I agree VSPD has two planes(2 rpf-instances) which supports all these formats.

Mali-C55(n formats)-->LCDC(VSPD n formats)->DSI(3 formats)-->Panel

Am I missing anything w.r.to the comment that I received previously.
Otherwise patch LGTM.

Cheers,
Biju

> 
> Patch tested with kms-tests:
> 
> PYTHONPATH=/usr/lib/aarch64-linux-gnu/python3.11/site-packages ./tests/kms-test-formats.py Testing
> plane formats: SUCCESS
> 
> admin@kakip:~/kms-tests$ cat FormatsTest.log U [66.967523] Testing plane formats U [66.975763] Testing
> connector DSI-1, CRTC 36, mode 720x1280 U [66.978480] Testing format PixelFormat.RGB332 U [70.143998]
> Testing format PixelFormat.ARGB4444 U [73.357056] Testing format PixelFormat.XRGB4444 U [76.574944]
> Testing format PixelFormat.ARGB1555 U [79.805636] Testing format PixelFormat.XRGB1555 U [83.016599]
> Testing format PixelFormat.RGB565 U [86.230362] Testing format PixelFormat.BGR888 U [89.444673]
> Testing format PixelFormat.RGB888 U [92.677093] Testing format PixelFormat.BGRA8888 U [95.904745]
> Testing format PixelFormat.BGRX8888 U [99.119926] Testing format PixelFormat.ARGB8888 U [102.350298]
> Testing format PixelFormat.XRGB8888 U [105.579499] Testing format PixelFormat.UYVY U [108.878654]
> Testing format PixelFormat.YUYV U [112.176515] Testing format PixelFormat.YVYU U [115.470090] Testing
> format PixelFormat.NV12 U [118.767513] Testing format PixelFormat.NV21 U [122.065851] Testing format
> PixelFormat.NV16 U [125.364001] Testing format PixelFormat.NV61 U [128.662145] Testing format
> PixelFormat.YUV420 U [131.978102] Testing format PixelFormat.YVU420 U [135.292284] Testing format
> PixelFormat.YUV422 U [138.623485] Testing format PixelFormat.YVU422 U [141.955083] Testing format
> PixelFormat.YUV444 U [145.336759] Testing format PixelFormat.YVU444 U [148.761832] Test completed
> successfully
> 
> 
> diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c b/drivers/gpu/drm/renesas/rz-
> du/rzg2l_du_kms.c
> index b1266fbd9598..a5e96f863172 100644
> --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> @@ -36,8 +36,61 @@
> 
>  static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
>  	{
> -		.fourcc = DRM_FORMAT_XRGB8888,
> -		.v4l2 = V4L2_PIX_FMT_XBGR32,
> +		.fourcc = DRM_FORMAT_RGB332,
> +		.v4l2 = V4L2_PIX_FMT_RGB332,
> +		.bpp = 8,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_ARGB4444,
> +		.v4l2 = V4L2_PIX_FMT_ARGB444,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_XRGB4444,
> +		.v4l2 = V4L2_PIX_FMT_XRGB444,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_ARGB1555,
> +		.v4l2 = V4L2_PIX_FMT_ARGB555,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_XRGB1555,
> +		.v4l2 = V4L2_PIX_FMT_XRGB555,
> +		.bpp = 16,
> +		.planes = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_RGB565,
> +		.v4l2 = V4L2_PIX_FMT_RGB565,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_BGR888,
> +		.v4l2 = V4L2_PIX_FMT_RGB24,
> +		.bpp = 24,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_RGB888,
> +		.v4l2 = V4L2_PIX_FMT_BGR24,
> +		.bpp = 24,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_BGRA8888,
> +		.v4l2 = V4L2_PIX_FMT_ARGB32,
> +		.bpp = 32,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_BGRX8888,
> +		.v4l2 = V4L2_PIX_FMT_XRGB32,
>  		.bpp = 32,
>  		.planes = 1,
>  		.hsub = 1,
> @@ -48,11 +101,89 @@ static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
>  		.planes = 1,
>  		.hsub = 1,
>  	}, {
> -		.fourcc = DRM_FORMAT_RGB888,
> -		.v4l2 = V4L2_PIX_FMT_BGR24,
> -		.bpp = 24,
> +		.fourcc = DRM_FORMAT_XRGB8888,
> +		.v4l2 = V4L2_PIX_FMT_XBGR32,
> +		.bpp = 32,
>  		.planes = 1,
>  		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_UYVY,
> +		.v4l2 = V4L2_PIX_FMT_UYVY,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YUYV,
> +		.v4l2 = V4L2_PIX_FMT_YUYV,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YVYU,
> +		.v4l2 = V4L2_PIX_FMT_YVYU,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_NV12,
> +		.v4l2 = V4L2_PIX_FMT_NV12M,
> +		.bpp = 12,
> +		.planes = 2,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_NV21,
> +		.v4l2 = V4L2_PIX_FMT_NV21M,
> +		.bpp = 12,
> +		.planes = 2,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_NV16,
> +		.v4l2 = V4L2_PIX_FMT_NV16M,
> +		.bpp = 16,
> +		.planes = 2,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_NV61,
> +		.v4l2 = V4L2_PIX_FMT_NV61M,
> +		.bpp = 16,
> +		.planes = 2,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YUV420,
> +		.v4l2 = V4L2_PIX_FMT_YUV420M,
> +		.bpp = 12,
> +		.planes = 3,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YVU420,
> +		.v4l2 = V4L2_PIX_FMT_YVU420M,
> +		.bpp = 12,
> +		.planes = 3,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YUV422,
> +		.v4l2 = V4L2_PIX_FMT_YUV422M,
> +		.bpp = 16,
> +		.planes = 3,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YVU422,
> +		.v4l2 = V4L2_PIX_FMT_YVU422M,
> +		.bpp = 16,
> +		.planes = 3,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YUV444,
> +		.v4l2 = V4L2_PIX_FMT_YUV444M,
> +		.bpp = 24,
> +		.planes = 3,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_YVU444,
> +		.v4l2 = V4L2_PIX_FMT_YVU444M,
> +		.bpp = 24,
> +		.planes = 3,
> +		.hsub = 1,
>  	}
>  };
> 
> --
> 2.48.1
Kieran Bingham March 21, 2025, 7:06 p.m. UTC | #2
Hi Biju,

Quoting Biju Das (2025-03-21 18:40:50)
> Hi Kieran,
> 
> Thanks for the patch.
> 
> > -----Original Message-----
> > From: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > Sent: 21 March 2025 17:22
> > Subject: [PATCH] drm: renesas: Extend RZ/G2L supported KMS formats
> > 
> > From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> > 
> > The RZ/G2L driver utilises the VSPD to read data from input sources.
> > 
> > The rzg2l_du_kms component lists a restricted subset of the capabilities of the VSPd which prevents
> 
> VSPD
> 
> > additional formats from being used for display planes.
> > 
> > The supported display plane formats are mapped in rzg2l_du_vsp_formats[].
> > 
> > Extend the rzg2l_du_format_infos[] table with the corresponding mappings between the supported DRM
> > formats and the formats exposed by the VSP in rzg2l_du_vsp_formats, maintaining the same ordering in
> > both tables.
> > 
> > Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> > ---
> >  drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c | 141 ++++++++++++++++++-
> >  1 file changed, 136 insertions(+), 5 deletions(-)
> > 
> > Prior to this patch, kmstest reports all of these formats as supported by the Planes, but using them
> > fails during rzg2l_du_fb_create() as the corresponding format isn't found in rzg2l_du_format_info.
> > 
> > This patch now lets me capture and render pixelformats from the Mali-C55 direct to an attached DSI
> > panel on the Kakip board.
> 
> Previously I got a comment to remove all the formats from this table as DSI supports only 3 formats.

Indeed, I can see that the DSI only supports the three RGB variant
formats, but the RPF of the VPSD is very capable and does the pixel format
conversion for us here as I understand it!


> I agree VSPD has two planes(2 rpf-instances) which supports all these formats.
> 
> Mali-C55(n formats)-->LCDC(VSPD n formats)->DSI(3 formats)-->Panel
> 
> Am I missing anything w.r.to the comment that I received previously.
> Otherwise patch LGTM.
> 

I haven't looked completely, but as long as the VSPD is only configured
to /output/ the RGB formats to the DSI then I think this is fine,

> Cheers,
> Biju

Thanks,

Kieran

> 
> > 
> > Patch tested with kms-tests:
> > 
> > PYTHONPATH=/usr/lib/aarch64-linux-gnu/python3.11/site-packages ./tests/kms-test-formats.py Testing
> > plane formats: SUCCESS
> > 
> > admin@kakip:~/kms-tests$ cat FormatsTest.log U [66.967523] Testing plane formats U [66.975763] Testing
> > connector DSI-1, CRTC 36, mode 720x1280 U [66.978480] Testing format PixelFormat.RGB332 U [70.143998]
> > Testing format PixelFormat.ARGB4444 U [73.357056] Testing format PixelFormat.XRGB4444 U [76.574944]
> > Testing format PixelFormat.ARGB1555 U [79.805636] Testing format PixelFormat.XRGB1555 U [83.016599]
> > Testing format PixelFormat.RGB565 U [86.230362] Testing format PixelFormat.BGR888 U [89.444673]
> > Testing format PixelFormat.RGB888 U [92.677093] Testing format PixelFormat.BGRA8888 U [95.904745]
> > Testing format PixelFormat.BGRX8888 U [99.119926] Testing format PixelFormat.ARGB8888 U [102.350298]
> > Testing format PixelFormat.XRGB8888 U [105.579499] Testing format PixelFormat.UYVY U [108.878654]
> > Testing format PixelFormat.YUYV U [112.176515] Testing format PixelFormat.YVYU U [115.470090] Testing
> > format PixelFormat.NV12 U [118.767513] Testing format PixelFormat.NV21 U [122.065851] Testing format
> > PixelFormat.NV16 U [125.364001] Testing format PixelFormat.NV61 U [128.662145] Testing format
> > PixelFormat.YUV420 U [131.978102] Testing format PixelFormat.YVU420 U [135.292284] Testing format
> > PixelFormat.YUV422 U [138.623485] Testing format PixelFormat.YVU422 U [141.955083] Testing format
> > PixelFormat.YUV444 U [145.336759] Testing format PixelFormat.YVU444 U [148.761832] Test completed
> > successfully
> > 
> > 
> > diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c b/drivers/gpu/drm/renesas/rz-
> > du/rzg2l_du_kms.c
> > index b1266fbd9598..a5e96f863172 100644
> > --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > @@ -36,8 +36,61 @@
> > 
> >  static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
> >       {
> > -             .fourcc = DRM_FORMAT_XRGB8888,
> > -             .v4l2 = V4L2_PIX_FMT_XBGR32,
> > +             .fourcc = DRM_FORMAT_RGB332,
> > +             .v4l2 = V4L2_PIX_FMT_RGB332,
> > +             .bpp = 8,
> > +             .planes = 1,
> > +             .hsub = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_ARGB4444,
> > +             .v4l2 = V4L2_PIX_FMT_ARGB444,
> > +             .bpp = 16,
> > +             .planes = 1,
> > +             .hsub = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_XRGB4444,
> > +             .v4l2 = V4L2_PIX_FMT_XRGB444,
> > +             .bpp = 16,
> > +             .planes = 1,
> > +             .hsub = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_ARGB1555,
> > +             .v4l2 = V4L2_PIX_FMT_ARGB555,
> > +             .bpp = 16,
> > +             .planes = 1,
> > +             .hsub = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_XRGB1555,
> > +             .v4l2 = V4L2_PIX_FMT_XRGB555,
> > +             .bpp = 16,
> > +             .planes = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_RGB565,
> > +             .v4l2 = V4L2_PIX_FMT_RGB565,
> > +             .bpp = 16,
> > +             .planes = 1,
> > +             .hsub = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_BGR888,
> > +             .v4l2 = V4L2_PIX_FMT_RGB24,
> > +             .bpp = 24,
> > +             .planes = 1,
> > +             .hsub = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_RGB888,
> > +             .v4l2 = V4L2_PIX_FMT_BGR24,
> > +             .bpp = 24,
> > +             .planes = 1,
> > +             .hsub = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_BGRA8888,
> > +             .v4l2 = V4L2_PIX_FMT_ARGB32,
> > +             .bpp = 32,
> > +             .planes = 1,
> > +             .hsub = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_BGRX8888,
> > +             .v4l2 = V4L2_PIX_FMT_XRGB32,
> >               .bpp = 32,
> >               .planes = 1,
> >               .hsub = 1,
> > @@ -48,11 +101,89 @@ static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
> >               .planes = 1,
> >               .hsub = 1,
> >       }, {
> > -             .fourcc = DRM_FORMAT_RGB888,
> > -             .v4l2 = V4L2_PIX_FMT_BGR24,
> > -             .bpp = 24,
> > +             .fourcc = DRM_FORMAT_XRGB8888,
> > +             .v4l2 = V4L2_PIX_FMT_XBGR32,
> > +             .bpp = 32,
> >               .planes = 1,
> >               .hsub = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_UYVY,
> > +             .v4l2 = V4L2_PIX_FMT_UYVY,
> > +             .bpp = 16,
> > +             .planes = 1,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_YUYV,
> > +             .v4l2 = V4L2_PIX_FMT_YUYV,
> > +             .bpp = 16,
> > +             .planes = 1,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_YVYU,
> > +             .v4l2 = V4L2_PIX_FMT_YVYU,
> > +             .bpp = 16,
> > +             .planes = 1,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_NV12,
> > +             .v4l2 = V4L2_PIX_FMT_NV12M,
> > +             .bpp = 12,
> > +             .planes = 2,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_NV21,
> > +             .v4l2 = V4L2_PIX_FMT_NV21M,
> > +             .bpp = 12,
> > +             .planes = 2,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_NV16,
> > +             .v4l2 = V4L2_PIX_FMT_NV16M,
> > +             .bpp = 16,
> > +             .planes = 2,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_NV61,
> > +             .v4l2 = V4L2_PIX_FMT_NV61M,
> > +             .bpp = 16,
> > +             .planes = 2,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_YUV420,
> > +             .v4l2 = V4L2_PIX_FMT_YUV420M,
> > +             .bpp = 12,
> > +             .planes = 3,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_YVU420,
> > +             .v4l2 = V4L2_PIX_FMT_YVU420M,
> > +             .bpp = 12,
> > +             .planes = 3,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_YUV422,
> > +             .v4l2 = V4L2_PIX_FMT_YUV422M,
> > +             .bpp = 16,
> > +             .planes = 3,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_YVU422,
> > +             .v4l2 = V4L2_PIX_FMT_YVU422M,
> > +             .bpp = 16,
> > +             .planes = 3,
> > +             .hsub = 2,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_YUV444,
> > +             .v4l2 = V4L2_PIX_FMT_YUV444M,
> > +             .bpp = 24,
> > +             .planes = 3,
> > +             .hsub = 1,
> > +     }, {
> > +             .fourcc = DRM_FORMAT_YVU444,
> > +             .v4l2 = V4L2_PIX_FMT_YVU444M,
> > +             .bpp = 24,
> > +             .planes = 3,
> > +             .hsub = 1,
> >       }
> >  };
> > 
> > --
> > 2.48.1
>
Laurent Pinchart March 21, 2025, 10:33 p.m. UTC | #3
Hi Kieran,

Thank you for the patch.

On Fri, Mar 21, 2025 at 05:22:19PM +0000, Kieran Bingham wrote:
> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
> The RZ/G2L driver utilises the VSPD to read data from input sources.
> 
> The rzg2l_du_kms component lists a restricted subset of the capabilities
> of the VSPd which prevents additional formats from being used for

s/VSPd/VSPD/

> display planes.
> 
> The supported display plane formats are mapped in rzg2l_du_vsp_formats[].
> 
> Extend the rzg2l_du_format_infos[] table with the corresponding mappings
> between the supported DRM formats and the formats exposed by the VSP in
> rzg2l_du_vsp_formats, maintaining the same ordering in both tables.

Given the other replies to this patch, you may want to extend the commit
message to explain why this is fine, and how the VSPD will convert YUV
formats to RGB.

Now this makes realize we should implement support for colorspace in the
VSPD driver... It's a separate issue.

> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c | 141 ++++++++++++++++++-
>  1 file changed, 136 insertions(+), 5 deletions(-)
> 
> Prior to this patch, kmstest reports all of these formats as supported
> by the Planes, but using them fails during rzg2l_du_fb_create() as the
> corresponding format isn't found in rzg2l_du_format_info.
> 
> This patch now lets me capture and render pixelformats from the Mali-C55
> direct to an attached DSI panel on the Kakip board.
> 
> Patch tested with kms-tests:
> 
> PYTHONPATH=/usr/lib/aarch64-linux-gnu/python3.11/site-packages ./tests/kms-test-formats.py 
> Testing plane formats: SUCCESS
> 
> admin@kakip:~/kms-tests$ cat FormatsTest.log 
> U [66.967523] Testing plane formats
> U [66.975763] Testing connector DSI-1, CRTC 36, mode 720x1280
> U [66.978480] Testing format PixelFormat.RGB332
> U [70.143998] Testing format PixelFormat.ARGB4444
> U [73.357056] Testing format PixelFormat.XRGB4444
> U [76.574944] Testing format PixelFormat.ARGB1555
> U [79.805636] Testing format PixelFormat.XRGB1555
> U [83.016599] Testing format PixelFormat.RGB565
> U [86.230362] Testing format PixelFormat.BGR888
> U [89.444673] Testing format PixelFormat.RGB888
> U [92.677093] Testing format PixelFormat.BGRA8888
> U [95.904745] Testing format PixelFormat.BGRX8888
> U [99.119926] Testing format PixelFormat.ARGB8888
> U [102.350298] Testing format PixelFormat.XRGB8888
> U [105.579499] Testing format PixelFormat.UYVY
> U [108.878654] Testing format PixelFormat.YUYV
> U [112.176515] Testing format PixelFormat.YVYU
> U [115.470090] Testing format PixelFormat.NV12
> U [118.767513] Testing format PixelFormat.NV21
> U [122.065851] Testing format PixelFormat.NV16
> U [125.364001] Testing format PixelFormat.NV61
> U [128.662145] Testing format PixelFormat.YUV420
> U [131.978102] Testing format PixelFormat.YVU420
> U [135.292284] Testing format PixelFormat.YUV422
> U [138.623485] Testing format PixelFormat.YVU422
> U [141.955083] Testing format PixelFormat.YUV444
> U [145.336759] Testing format PixelFormat.YVU444
> U [148.761832] Test completed successfully
> 
> 
> diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> index b1266fbd9598..a5e96f863172 100644
> --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> @@ -36,8 +36,61 @@
>  
>  static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
>  	{
> -		.fourcc = DRM_FORMAT_XRGB8888,
> -		.v4l2 = V4L2_PIX_FMT_XBGR32,
> +		.fourcc = DRM_FORMAT_RGB332,
> +		.v4l2 = V4L2_PIX_FMT_RGB332,
> +		.bpp = 8,
> +		.planes = 1,
> +		.hsub = 1,

hsub isn't used in the driver, should it be removed (in a separate patch
of course) ? Or is that a sign there's a bug somewhere ?

Actually, bpp isn't used either. Biju, could you look into this, and
check if we should remove the fields or use them ?

Regardless, with the commit message expanded,

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> +	}, {
> +		.fourcc = DRM_FORMAT_ARGB4444,
> +		.v4l2 = V4L2_PIX_FMT_ARGB444,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_XRGB4444,
> +		.v4l2 = V4L2_PIX_FMT_XRGB444,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_ARGB1555,
> +		.v4l2 = V4L2_PIX_FMT_ARGB555,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_XRGB1555,
> +		.v4l2 = V4L2_PIX_FMT_XRGB555,
> +		.bpp = 16,
> +		.planes = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_RGB565,
> +		.v4l2 = V4L2_PIX_FMT_RGB565,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_BGR888,
> +		.v4l2 = V4L2_PIX_FMT_RGB24,
> +		.bpp = 24,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_RGB888,
> +		.v4l2 = V4L2_PIX_FMT_BGR24,
> +		.bpp = 24,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_BGRA8888,
> +		.v4l2 = V4L2_PIX_FMT_ARGB32,
> +		.bpp = 32,
> +		.planes = 1,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_BGRX8888,
> +		.v4l2 = V4L2_PIX_FMT_XRGB32,
>  		.bpp = 32,
>  		.planes = 1,
>  		.hsub = 1,
> @@ -48,11 +101,89 @@ static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
>  		.planes = 1,
>  		.hsub = 1,
>  	}, {
> -		.fourcc = DRM_FORMAT_RGB888,
> -		.v4l2 = V4L2_PIX_FMT_BGR24,
> -		.bpp = 24,
> +		.fourcc = DRM_FORMAT_XRGB8888,
> +		.v4l2 = V4L2_PIX_FMT_XBGR32,
> +		.bpp = 32,
>  		.planes = 1,
>  		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_UYVY,
> +		.v4l2 = V4L2_PIX_FMT_UYVY,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YUYV,
> +		.v4l2 = V4L2_PIX_FMT_YUYV,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YVYU,
> +		.v4l2 = V4L2_PIX_FMT_YVYU,
> +		.bpp = 16,
> +		.planes = 1,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_NV12,
> +		.v4l2 = V4L2_PIX_FMT_NV12M,
> +		.bpp = 12,
> +		.planes = 2,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_NV21,
> +		.v4l2 = V4L2_PIX_FMT_NV21M,
> +		.bpp = 12,
> +		.planes = 2,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_NV16,
> +		.v4l2 = V4L2_PIX_FMT_NV16M,
> +		.bpp = 16,
> +		.planes = 2,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_NV61,
> +		.v4l2 = V4L2_PIX_FMT_NV61M,
> +		.bpp = 16,
> +		.planes = 2,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YUV420,
> +		.v4l2 = V4L2_PIX_FMT_YUV420M,
> +		.bpp = 12,
> +		.planes = 3,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YVU420,
> +		.v4l2 = V4L2_PIX_FMT_YVU420M,
> +		.bpp = 12,
> +		.planes = 3,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YUV422,
> +		.v4l2 = V4L2_PIX_FMT_YUV422M,
> +		.bpp = 16,
> +		.planes = 3,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YVU422,
> +		.v4l2 = V4L2_PIX_FMT_YVU422M,
> +		.bpp = 16,
> +		.planes = 3,
> +		.hsub = 2,
> +	}, {
> +		.fourcc = DRM_FORMAT_YUV444,
> +		.v4l2 = V4L2_PIX_FMT_YUV444M,
> +		.bpp = 24,
> +		.planes = 3,
> +		.hsub = 1,
> +	}, {
> +		.fourcc = DRM_FORMAT_YVU444,
> +		.v4l2 = V4L2_PIX_FMT_YVU444M,
> +		.bpp = 24,
> +		.planes = 3,
> +		.hsub = 1,
>  	}
>  };
>
Biju Das March 22, 2025, 9:29 a.m. UTC | #4
Hi Laurent,

> -----Original Message-----
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Sent: 21 March 2025 22:33
> Subject: Re: [PATCH] drm: renesas: Extend RZ/G2L supported KMS formats
> 
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Fri, Mar 21, 2025 at 05:22:19PM +0000, Kieran Bingham wrote:
> > From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> >
> > The RZ/G2L driver utilises the VSPD to read data from input sources.
> >
> > The rzg2l_du_kms component lists a restricted subset of the
> > capabilities of the VSPd which prevents additional formats from being
> > used for
> 
> s/VSPd/VSPD/
> 
> > display planes.
> >
> > The supported display plane formats are mapped in rzg2l_du_vsp_formats[].
> >
> > Extend the rzg2l_du_format_infos[] table with the corresponding
> > mappings between the supported DRM formats and the formats exposed by
> > the VSP in rzg2l_du_vsp_formats, maintaining the same ordering in both tables.
> 
> Given the other replies to this patch, you may want to extend the commit message to explain why this
> is fine, and how the VSPD will convert YUV formats to RGB.
> 
> Now this makes realize we should implement support for colorspace in the VSPD driver... It's a
> separate issue.
> 
> > Signed-off-by: Kieran Bingham
> > <kieran.bingham+renesas@ideasonboard.com>
> > ---
> >  drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c | 141
> > ++++++++++++++++++-
> >  1 file changed, 136 insertions(+), 5 deletions(-)
> >
> > Prior to this patch, kmstest reports all of these formats as supported
> > by the Planes, but using them fails during rzg2l_du_fb_create() as the
> > corresponding format isn't found in rzg2l_du_format_info.
> >
> > This patch now lets me capture and render pixelformats from the
> > Mali-C55 direct to an attached DSI panel on the Kakip board.
> >
> > Patch tested with kms-tests:
> >
> > PYTHONPATH=/usr/lib/aarch64-linux-gnu/python3.11/site-packages
> > ./tests/kms-test-formats.py Testing plane formats: SUCCESS
> >
> >
> > diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > index b1266fbd9598..a5e96f863172 100644
> > --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > @@ -36,8 +36,61 @@
> >
> >  static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
> >  	{
> > -		.fourcc = DRM_FORMAT_XRGB8888,
> > -		.v4l2 = V4L2_PIX_FMT_XBGR32,
> > +		.fourcc = DRM_FORMAT_RGB332,
> > +		.v4l2 = V4L2_PIX_FMT_RGB332,
> > +		.bpp = 8,
> > +		.planes = 1,
> > +		.hsub = 1,
> 
> hsub isn't used in the driver, should it be removed (in a separate patch of course) ? Or is that a
> sign there's a bug somewhere ?
> 
> Actually, bpp isn't used either. Biju, could you look into this, and check if we should remove the
> fields or use them ?

Both bpp and hsub unused previously.

bpp still can be removed as it is unused like R-Car Gen3.

Now this patch is extending to support YUV formats,
I think hsub can be used for YUV like in rzg2l_du_fb_create().

         /*                                                                       
          * Calculate the chroma plane(s) pitch using the horizontal subsampling  
          * factor. For semi-planar formats, the U and V planes are combined, the 
          * pitch must thus be doubled.                                           
          */                                                                      
             chroma_pitch = mode_cmd->pitches[0] / format->hsub;                      
             if (format->planes == 2)                                                 
                    chroma_pitch *= 2;                                               
                                                                                  
          for (i = 1; i < format->planes; ++i) {                                   
                  if (mode_cmd->pitches[i] != chroma_pitch) {                      
                          dev_dbg(dev->dev,                                        
                                  "luma and chroma pitches are not compatible\n"); 
                          return ERR_PTR(-EINVAL);                                 
                  }                                                                
          }

Cheers,
Biju    

> 
> Regardless, with the commit message expanded,
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> 
> > +	}, {
> > +		.fourcc = DRM_FORMAT_ARGB4444,
> > +		.v4l2 = V4L2_PIX_FMT_ARGB444,
> > +		.bpp = 16,
> > +		.planes = 1,
> > +		.hsub = 1,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_XRGB4444,
> > +		.v4l2 = V4L2_PIX_FMT_XRGB444,
> > +		.bpp = 16,
> > +		.planes = 1,
> > +		.hsub = 1,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_ARGB1555,
> > +		.v4l2 = V4L2_PIX_FMT_ARGB555,
> > +		.bpp = 16,
> > +		.planes = 1,
> > +		.hsub = 1,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_XRGB1555,
> > +		.v4l2 = V4L2_PIX_FMT_XRGB555,
> > +		.bpp = 16,
> > +		.planes = 1,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_RGB565,
> > +		.v4l2 = V4L2_PIX_FMT_RGB565,
> > +		.bpp = 16,
> > +		.planes = 1,
> > +		.hsub = 1,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_BGR888,
> > +		.v4l2 = V4L2_PIX_FMT_RGB24,
> > +		.bpp = 24,
> > +		.planes = 1,
> > +		.hsub = 1,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_RGB888,
> > +		.v4l2 = V4L2_PIX_FMT_BGR24,
> > +		.bpp = 24,
> > +		.planes = 1,
> > +		.hsub = 1,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_BGRA8888,
> > +		.v4l2 = V4L2_PIX_FMT_ARGB32,
> > +		.bpp = 32,
> > +		.planes = 1,
> > +		.hsub = 1,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_BGRX8888,
> > +		.v4l2 = V4L2_PIX_FMT_XRGB32,
> >  		.bpp = 32,
> >  		.planes = 1,
> >  		.hsub = 1,
> > @@ -48,11 +101,89 @@ static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
> >  		.planes = 1,
> >  		.hsub = 1,
> >  	}, {
> > -		.fourcc = DRM_FORMAT_RGB888,
> > -		.v4l2 = V4L2_PIX_FMT_BGR24,
> > -		.bpp = 24,
> > +		.fourcc = DRM_FORMAT_XRGB8888,
> > +		.v4l2 = V4L2_PIX_FMT_XBGR32,
> > +		.bpp = 32,
> >  		.planes = 1,
> >  		.hsub = 1,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_UYVY,
> > +		.v4l2 = V4L2_PIX_FMT_UYVY,
> > +		.bpp = 16,
> > +		.planes = 1,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_YUYV,
> > +		.v4l2 = V4L2_PIX_FMT_YUYV,
> > +		.bpp = 16,
> > +		.planes = 1,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_YVYU,
> > +		.v4l2 = V4L2_PIX_FMT_YVYU,
> > +		.bpp = 16,
> > +		.planes = 1,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_NV12,
> > +		.v4l2 = V4L2_PIX_FMT_NV12M,
> > +		.bpp = 12,
> > +		.planes = 2,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_NV21,
> > +		.v4l2 = V4L2_PIX_FMT_NV21M,
> > +		.bpp = 12,
> > +		.planes = 2,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_NV16,
> > +		.v4l2 = V4L2_PIX_FMT_NV16M,
> > +		.bpp = 16,
> > +		.planes = 2,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_NV61,
> > +		.v4l2 = V4L2_PIX_FMT_NV61M,
> > +		.bpp = 16,
> > +		.planes = 2,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_YUV420,
> > +		.v4l2 = V4L2_PIX_FMT_YUV420M,
> > +		.bpp = 12,
> > +		.planes = 3,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_YVU420,
> > +		.v4l2 = V4L2_PIX_FMT_YVU420M,
> > +		.bpp = 12,
> > +		.planes = 3,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_YUV422,
> > +		.v4l2 = V4L2_PIX_FMT_YUV422M,
> > +		.bpp = 16,
> > +		.planes = 3,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_YVU422,
> > +		.v4l2 = V4L2_PIX_FMT_YVU422M,
> > +		.bpp = 16,
> > +		.planes = 3,
> > +		.hsub = 2,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_YUV444,
> > +		.v4l2 = V4L2_PIX_FMT_YUV444M,
> > +		.bpp = 24,
> > +		.planes = 3,
> > +		.hsub = 1,
> > +	}, {
> > +		.fourcc = DRM_FORMAT_YVU444,
> > +		.v4l2 = V4L2_PIX_FMT_YVU444M,
> > +		.bpp = 24,
> > +		.planes = 3,
> > +		.hsub = 1,
> >  	}
> >  };
> >
> 
> --
> Regards,
> 
> Laurent Pinchart
Biju Das March 22, 2025, 10:06 a.m. UTC | #5
Hi Kieran,

Thanks for the patch.

> -----Original Message-----
> From: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Sent: 21 March 2025 19:06
> Subject: RE: [PATCH] drm: renesas: Extend RZ/G2L supported KMS formats
> 
> Hi Biju,
> 
> Quoting Biju Das (2025-03-21 18:40:50)
> > Hi Kieran,
> >
> > Thanks for the patch.
> >
> > > -----Original Message-----
> > > From: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > > Sent: 21 March 2025 17:22
> > > Subject: [PATCH] drm: renesas: Extend RZ/G2L supported KMS formats
> > >
> > > From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> > >
> > > The RZ/G2L driver utilises the VSPD to read data from input sources.
> > >
> > > The rzg2l_du_kms component lists a restricted subset of the
> > > capabilities of the VSPd which prevents
> >
> > VSPD
> >
> > > additional formats from being used for display planes.
> > >
> > > The supported display plane formats are mapped in rzg2l_du_vsp_formats[].
> > >
> > > Extend the rzg2l_du_format_infos[] table with the corresponding
> > > mappings between the supported DRM formats and the formats exposed
> > > by the VSP in rzg2l_du_vsp_formats, maintaining the same ordering in both tables.
> > >
> > > Signed-off-by: Kieran Bingham
> > > <kieran.bingham+renesas@ideasonboard.com>
> > > ---
> > >  drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c | 141
> > > ++++++++++++++++++-
> > >  1 file changed, 136 insertions(+), 5 deletions(-)
> > >
> > > Prior to this patch, kmstest reports all of these formats as
> > > supported by the Planes, but using them fails during rzg2l_du_fb_create() as the corresponding
> format isn't found in rzg2l_du_format_info.
> > >
> > > This patch now lets me capture and render pixelformats from the
> > > Mali-C55 direct to an attached DSI panel on the Kakip board.
> >
> > Previously I got a comment to remove all the formats from this table as DSI supports only 3 formats.
> 
> Indeed, I can see that the DSI only supports the three RGB variant formats, but the RPF of the VPSD is
> very capable and does the pixel format conversion for us here as I understand it!

Cool, I haven't tested pixel format conversion previously.

> 
> 
> > I agree VSPD has two planes(2 rpf-instances) which supports all these formats.
> >
> > Mali-C55(n formats)-->LCDC(VSPD n formats)->DSI(3 formats)-->Panel
> >
> > Am I missing anything w.r.to the comment that I received previously.
> > Otherwise patch LGTM.
> >
> 
> I haven't looked completely, but as long as the VSPD is only configured to /output/ the RGB formats to
> the DSI then I think this is fine,
> 
> >
> > >
> > > Patch tested with kms-tests:
> > >
> > >
> > >
> > > diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > > b/drivers/gpu/drm/renesas/rz- du/rzg2l_du_kms.c index
> > > b1266fbd9598..a5e96f863172 100644
> > > --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > > +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > > @@ -36,8 +36,61 @@
> > >
> > >  static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
> > >       {
> > > -             .fourcc = DRM_FORMAT_XRGB8888,
> > > -             .v4l2 = V4L2_PIX_FMT_XBGR32,
> > > +             .fourcc = DRM_FORMAT_RGB332,
> > > +             .v4l2 = V4L2_PIX_FMT_RGB332,
> > > +             .bpp = 8,


Please drop bpp as it is unused like R-Car Gen3.

> > > +             .planes = 1,
> > > +             .hsub = 1,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_ARGB4444,
> > > +             .v4l2 = V4L2_PIX_FMT_ARGB444,
> > > +             .bpp = 16,
> > > +             .planes = 1,
> > > +             .hsub = 1,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_XRGB4444,
> > > +             .v4l2 = V4L2_PIX_FMT_XRGB444,
> > > +             .bpp = 16,
> > > +             .planes = 1,
> > > +             .hsub = 1,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_ARGB1555,
> > > +             .v4l2 = V4L2_PIX_FMT_ARGB555,
> > > +             .bpp = 16,
> > > +             .planes = 1,
> > > +             .hsub = 1,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_XRGB1555,
> > > +             .v4l2 = V4L2_PIX_FMT_XRGB555,
> > > +             .bpp = 16,
> > > +             .planes = 1,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_RGB565,
> > > +             .v4l2 = V4L2_PIX_FMT_RGB565,
> > > +             .bpp = 16,
> > > +             .planes = 1,
> > > +             .hsub = 1,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_BGR888,
> > > +             .v4l2 = V4L2_PIX_FMT_RGB24,
> > > +             .bpp = 24,
> > > +             .planes = 1,
> > > +             .hsub = 1,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_RGB888,
> > > +             .v4l2 = V4L2_PIX_FMT_BGR24,
> > > +             .bpp = 24,
> > > +             .planes = 1,
> > > +             .hsub = 1,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_BGRA8888,
> > > +             .v4l2 = V4L2_PIX_FMT_ARGB32,
> > > +             .bpp = 32,
> > > +             .planes = 1,
> > > +             .hsub = 1,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_BGRX8888,
> > > +             .v4l2 = V4L2_PIX_FMT_XRGB32,
> > >               .bpp = 32,
> > >               .planes = 1,
> > >               .hsub = 1,
> > > @@ -48,11 +101,89 @@ static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
> > >               .planes = 1,
> > >               .hsub = 1,
> > >       }, {
> > > -             .fourcc = DRM_FORMAT_RGB888,
> > > -             .v4l2 = V4L2_PIX_FMT_BGR24,
> > > -             .bpp = 24,
> > > +             .fourcc = DRM_FORMAT_XRGB8888,
> > > +             .v4l2 = V4L2_PIX_FMT_XBGR32,
> > > +             .bpp = 32,
> > >               .planes = 1,
> > >               .hsub = 1,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_UYVY,
> > > +             .v4l2 = V4L2_PIX_FMT_UYVY,
> > > +             .bpp = 16,
> > > +             .planes = 1,
> > > +             .hsub = 2,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_YUYV,
> > > +             .v4l2 = V4L2_PIX_FMT_YUYV,
> > > +             .bpp = 16,
> > > +             .planes = 1,
> > > +             .hsub = 2,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_YVYU,
> > > +             .v4l2 = V4L2_PIX_FMT_YVYU,
> > > +             .bpp = 16,
> > > +             .planes = 1,
> > > +             .hsub = 2,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_NV12,
> > > +             .v4l2 = V4L2_PIX_FMT_NV12M,
> > > +             .bpp = 12,
> > > +             .planes = 2,
> > > +             .hsub = 2,
> > > +     }, {
> > > +             .fourcc = DRM_FORMAT_NV21,
> > > +             .v4l2 = V4L2_PIX_FMT_NV21M,
> > > +             .bpp = 12,
> > > +             .planes = 2,
> > > +             .hsub = 2,

As this patch is extending to support YUV formats, 
Now hsub can be used in rzg2l_du_fb_create() like R-Car Gen3.

         /*                                                                       
          * Calculate the chroma plane(s) pitch using the horizontal subsampling  
          * factor. For semi-planar formats, the U and V planes are combined, the 
          * pitch must thus be doubled.                                           
          */                                                                      
         chroma_pitch = mode_cmd->pitches[0] / format->hsub;                      
         if (format->planes == 2)                                                 
               chroma_pitch *= 2;                                               
                                                                                  
          for (i = 1; i < format->planes; ++i) {                                   
                  if (mode_cmd->pitches[i] != chroma_pitch) {                      
                          dev_dbg(dev->dev,                                        
                                  "luma and chroma pitches are not compatible\n"); 
                          return ERR_PTR(-EINVAL);                                 
                  }                                                                
          }

Cheers,
Biju
Biju Das March 22, 2025, 10:12 a.m. UTC | #6
Hi Laurent,

> -----Original Message-----
> From: Biju Das <biju.das.jz@bp.renesas.com>
> Sent: 22 March 2025 09:29
> Subject: RE: [PATCH] drm: renesas: Extend RZ/G2L supported KMS formats
> 
> Hi Laurent,
> 
> > -----Original Message-----
> > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Sent: 21 March 2025 22:33
> > Subject: Re: [PATCH] drm: renesas: Extend RZ/G2L supported KMS formats
> >
> > Hi Kieran,
> >
> > Thank you for the patch.
> >
> > On Fri, Mar 21, 2025 at 05:22:19PM +0000, Kieran Bingham wrote:
> > > From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> > >
> > > The RZ/G2L driver utilises the VSPD to read data from input sources.
> > >
> > > The rzg2l_du_kms component lists a restricted subset of the
> > > capabilities of the VSPd which prevents additional formats from
> > > being used for
> >
> > s/VSPd/VSPD/
> >
> > > display planes.
> > >
> > > The supported display plane formats are mapped in rzg2l_du_vsp_formats[].
> > >
> > > Extend the rzg2l_du_format_infos[] table with the corresponding
> > > mappings between the supported DRM formats and the formats exposed
> > > by the VSP in rzg2l_du_vsp_formats, maintaining the same ordering in both tables.
> >
> > Given the other replies to this patch, you may want to extend the
> > commit message to explain why this is fine, and how the VSPD will convert YUV formats to RGB.
> >
> > Now this makes realize we should implement support for colorspace in
> > the VSPD driver... It's a separate issue.
> >
> > > Signed-off-by: Kieran Bingham
> > > <kieran.bingham+renesas@ideasonboard.com>
> > > ---
> > >  drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c | 141
> > > ++++++++++++++++++-
> > >  1 file changed, 136 insertions(+), 5 deletions(-)
> > >
> > > Prior to this patch, kmstest reports all of these formats as
> > > supported by the Planes, but using them fails during
> > > rzg2l_du_fb_create() as the corresponding format isn't found in rzg2l_du_format_info.
> > >
> > > This patch now lets me capture and render pixelformats from the
> > > Mali-C55 direct to an attached DSI panel on the Kakip board.
> > >
> > > Patch tested with kms-tests:
> > >
> > > PYTHONPATH=/usr/lib/aarch64-linux-gnu/python3.11/site-packages
> > > ./tests/kms-test-formats.py Testing plane formats: SUCCESS
> > >
> > >
> > > diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > > b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > > index b1266fbd9598..a5e96f863172 100644
> > > --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > > +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
> > > @@ -36,8 +36,61 @@
> > >
> > >  static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
> > >  	{
> > > -		.fourcc = DRM_FORMAT_XRGB8888,
> > > -		.v4l2 = V4L2_PIX_FMT_XBGR32,
> > > +		.fourcc = DRM_FORMAT_RGB332,
> > > +		.v4l2 = V4L2_PIX_FMT_RGB332,
> > > +		.bpp = 8,
> > > +		.planes = 1,
> > > +		.hsub = 1,
> >
> > hsub isn't used in the driver, should it be removed (in a separate
> > patch of course) ? Or is that a sign there's a bug somewhere ?
> >
> > Actually, bpp isn't used either. Biju, could you look into this, and
> > check if we should remove the fields or use them ?
> 
> Both bpp and hsub unused previously.
> 
> bpp still can be removed as it is unused like R-Car Gen3.

Correction, On R-Car Gen3 it is used by du_plane where as
RZ/G2L does not support DU hardware planes.

Cheere,
Biju
diff mbox series

Patch

diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
index b1266fbd9598..a5e96f863172 100644
--- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
+++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c
@@ -36,8 +36,61 @@ 
 
 static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
 	{
-		.fourcc = DRM_FORMAT_XRGB8888,
-		.v4l2 = V4L2_PIX_FMT_XBGR32,
+		.fourcc = DRM_FORMAT_RGB332,
+		.v4l2 = V4L2_PIX_FMT_RGB332,
+		.bpp = 8,
+		.planes = 1,
+		.hsub = 1,
+	}, {
+		.fourcc = DRM_FORMAT_ARGB4444,
+		.v4l2 = V4L2_PIX_FMT_ARGB444,
+		.bpp = 16,
+		.planes = 1,
+		.hsub = 1,
+	}, {
+		.fourcc = DRM_FORMAT_XRGB4444,
+		.v4l2 = V4L2_PIX_FMT_XRGB444,
+		.bpp = 16,
+		.planes = 1,
+		.hsub = 1,
+	}, {
+		.fourcc = DRM_FORMAT_ARGB1555,
+		.v4l2 = V4L2_PIX_FMT_ARGB555,
+		.bpp = 16,
+		.planes = 1,
+		.hsub = 1,
+	}, {
+		.fourcc = DRM_FORMAT_XRGB1555,
+		.v4l2 = V4L2_PIX_FMT_XRGB555,
+		.bpp = 16,
+		.planes = 1,
+	}, {
+		.fourcc = DRM_FORMAT_RGB565,
+		.v4l2 = V4L2_PIX_FMT_RGB565,
+		.bpp = 16,
+		.planes = 1,
+		.hsub = 1,
+	}, {
+		.fourcc = DRM_FORMAT_BGR888,
+		.v4l2 = V4L2_PIX_FMT_RGB24,
+		.bpp = 24,
+		.planes = 1,
+		.hsub = 1,
+	}, {
+		.fourcc = DRM_FORMAT_RGB888,
+		.v4l2 = V4L2_PIX_FMT_BGR24,
+		.bpp = 24,
+		.planes = 1,
+		.hsub = 1,
+	}, {
+		.fourcc = DRM_FORMAT_BGRA8888,
+		.v4l2 = V4L2_PIX_FMT_ARGB32,
+		.bpp = 32,
+		.planes = 1,
+		.hsub = 1,
+	}, {
+		.fourcc = DRM_FORMAT_BGRX8888,
+		.v4l2 = V4L2_PIX_FMT_XRGB32,
 		.bpp = 32,
 		.planes = 1,
 		.hsub = 1,
@@ -48,11 +101,89 @@  static const struct rzg2l_du_format_info rzg2l_du_format_infos[] = {
 		.planes = 1,
 		.hsub = 1,
 	}, {
-		.fourcc = DRM_FORMAT_RGB888,
-		.v4l2 = V4L2_PIX_FMT_BGR24,
-		.bpp = 24,
+		.fourcc = DRM_FORMAT_XRGB8888,
+		.v4l2 = V4L2_PIX_FMT_XBGR32,
+		.bpp = 32,
 		.planes = 1,
 		.hsub = 1,
+	}, {
+		.fourcc = DRM_FORMAT_UYVY,
+		.v4l2 = V4L2_PIX_FMT_UYVY,
+		.bpp = 16,
+		.planes = 1,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_YUYV,
+		.v4l2 = V4L2_PIX_FMT_YUYV,
+		.bpp = 16,
+		.planes = 1,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_YVYU,
+		.v4l2 = V4L2_PIX_FMT_YVYU,
+		.bpp = 16,
+		.planes = 1,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_NV12,
+		.v4l2 = V4L2_PIX_FMT_NV12M,
+		.bpp = 12,
+		.planes = 2,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_NV21,
+		.v4l2 = V4L2_PIX_FMT_NV21M,
+		.bpp = 12,
+		.planes = 2,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_NV16,
+		.v4l2 = V4L2_PIX_FMT_NV16M,
+		.bpp = 16,
+		.planes = 2,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_NV61,
+		.v4l2 = V4L2_PIX_FMT_NV61M,
+		.bpp = 16,
+		.planes = 2,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_YUV420,
+		.v4l2 = V4L2_PIX_FMT_YUV420M,
+		.bpp = 12,
+		.planes = 3,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_YVU420,
+		.v4l2 = V4L2_PIX_FMT_YVU420M,
+		.bpp = 12,
+		.planes = 3,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_YUV422,
+		.v4l2 = V4L2_PIX_FMT_YUV422M,
+		.bpp = 16,
+		.planes = 3,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_YVU422,
+		.v4l2 = V4L2_PIX_FMT_YVU422M,
+		.bpp = 16,
+		.planes = 3,
+		.hsub = 2,
+	}, {
+		.fourcc = DRM_FORMAT_YUV444,
+		.v4l2 = V4L2_PIX_FMT_YUV444M,
+		.bpp = 24,
+		.planes = 3,
+		.hsub = 1,
+	}, {
+		.fourcc = DRM_FORMAT_YVU444,
+		.v4l2 = V4L2_PIX_FMT_YVU444M,
+		.bpp = 24,
+		.planes = 3,
+		.hsub = 1,
 	}
 };