diff mbox series

[05/31] drm/vc4_plane: Add support for YUV444 formats

Message ID 20240620154632.4125308-6-dave.stevenson@raspberrypi.com (mailing list archive)
State New, archived
Headers show
Series Preparatory patches for BCM2712 (Pi5) support | expand

Commit Message

Dave Stevenson June 20, 2024, 3:46 p.m. UTC
From: Dom Cobley <popcornmix@gmail.com>

Support displaying DRM_FORMAT_YUV444 and DRM_FORMAT_YVU444 formats.
Tested with kmstest and kodi. e.g.

kmstest -r 1920x1080@60 -f 400x300-YU24

Note: without the shift of width, only half the chroma is fetched,
resulting in correct left half of image and corrupt colours on right half.

The increase in width shouldn't affect fetching of Y data,
as the hardware will clamp at dest width.

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
---
 drivers/gpu/drm/vc4/vc4_plane.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Maxime Ripard June 21, 2024, 8:57 a.m. UTC | #1
Hi,

On Thu, Jun 20, 2024 at 04:46:06PM GMT, Dave Stevenson wrote:
> From: Dom Cobley <popcornmix@gmail.com>
> 
> Support displaying DRM_FORMAT_YUV444 and DRM_FORMAT_YVU444 formats.
> Tested with kmstest and kodi. e.g.
> 
> kmstest -r 1920x1080@60 -f 400x300-YU24
> 
> Note: without the shift of width, only half the chroma is fetched,
> resulting in correct left half of image and corrupt colours on right half.
> 
> The increase in width shouldn't affect fetching of Y data,
> as the hardware will clamp at dest width.
> 
> Signed-off-by: Dom Cobley <popcornmix@gmail.com>

Also, this is missing your Signed-off-by. It needs to be there for all
the patches you send on someone's behalf.

Maxime
Dave Stevenson June 21, 2024, 9:56 a.m. UTC | #2
On Fri, 21 Jun 2024 at 09:57, Maxime Ripard <mripard@kernel.org> wrote:
>
> Hi,
>
> On Thu, Jun 20, 2024 at 04:46:06PM GMT, Dave Stevenson wrote:
> > From: Dom Cobley <popcornmix@gmail.com>
> >
> > Support displaying DRM_FORMAT_YUV444 and DRM_FORMAT_YVU444 formats.
> > Tested with kmstest and kodi. e.g.
> >
> > kmstest -r 1920x1080@60 -f 400x300-YU24
> >
> > Note: without the shift of width, only half the chroma is fetched,
> > resulting in correct left half of image and corrupt colours on right half.
> >
> > The increase in width shouldn't affect fetching of Y data,
> > as the hardware will clamp at dest width.
> >
> > Signed-off-by: Dom Cobley <popcornmix@gmail.com>
>
> Also, this is missing your Signed-off-by. It needs to be there for all
> the patches you send on someone's behalf.

Drat. I went through checking and adding my Sob, and obviously missed this one.

Will add in v2.

> Maxime
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index b8c68d4688c8..978433554f3d 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -109,6 +109,18 @@  static const struct hvs_format {
 		.pixel_order = HVS_PIXEL_ORDER_XYCRCB,
 		.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCRCB,
 	},
+	{
+		.drm = DRM_FORMAT_YUV444,
+		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
+		.pixel_order = HVS_PIXEL_ORDER_XYCBCR,
+		.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCBCR,
+	},
+	{
+		.drm = DRM_FORMAT_YVU444,
+		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
+		.pixel_order = HVS_PIXEL_ORDER_XYCRCB,
+		.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCRCB,
+	},
 	{
 		.drm = DRM_FORMAT_YUV420,
 		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_3PLANE,
@@ -1117,6 +1129,12 @@  static int vc4_plane_mode_set(struct drm_plane *plane,
 	    vc4_state->src_y + vc4_state->src_h[0] < (state->fb->height << 16))
 		height++;
 
+	/* For YUV444 the hardware wants double the width, otherwise it doesn't
+	 * fetch full width of chroma
+	 */
+	if (format->drm == DRM_FORMAT_YUV444 || format->drm == DRM_FORMAT_YVU444)
+		width <<= 1;
+
 	/* Don't waste cycles mixing with plane alpha if the set alpha
 	 * is opaque or there is no per-pixel alpha information.
 	 * In any case we use the alpha property value as the fixed alpha.