bcm27xx: 6.1: add kernel patches
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-6.1 / 950-0558-drm-vc4_plane-Add-support-for-YUV444-formats.patch
1 From 18c4facfe095ee51ea193970bbe7826f86cbabf7 Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Tue, 31 Jan 2023 15:14:32 +0000
4 Subject: [PATCH] drm/vc4_plane: Add support for YUV444 formats
5
6 Support displaying DRM_FORMAT_YUV444 and DRM_FORMAT_YVU444 formats.
7 Tested with kmstest and kodi. e.g.
8
9 kmstest -r 1920x1080@60 -f 400x300-YU24
10
11 Note: without the shift of width, only half the chroma is fetched,
12 resulting in correct left half of image and corrupt colours on right half.
13
14 The increase in width shouldn't affect fetching of Y data,
15 as the hardware will clamp at dest width.
16
17 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
18 ---
19 drivers/gpu/drm/vc4/vc4_plane.c | 16 ++++++++++++++++
20 1 file changed, 16 insertions(+)
21
22 --- a/drivers/gpu/drm/vc4/vc4_plane.c
23 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
24 @@ -110,6 +110,18 @@ static const struct hvs_format {
25 .pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCRCB,
26 },
27 {
28 + .drm = DRM_FORMAT_YUV444,
29 + .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
30 + .pixel_order = HVS_PIXEL_ORDER_XYCBCR,
31 + .pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCBCR,
32 + },
33 + {
34 + .drm = DRM_FORMAT_YVU444,
35 + .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
36 + .pixel_order = HVS_PIXEL_ORDER_XYCRCB,
37 + .pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCRCB,
38 + },
39 + {
40 .drm = DRM_FORMAT_YUV420,
41 .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_3PLANE,
42 .pixel_order = HVS_PIXEL_ORDER_XYCBCR,
43 @@ -1106,6 +1118,10 @@ static int vc4_plane_mode_set(struct drm
44 vc4_state->src_y + vc4_state->src_h[0] < (state->fb->height << 16))
45 height++;
46
47 + /* for YUV444 hardware wants double the width, otherwise it doesn't fetch full width of chroma */
48 + if (format->drm == DRM_FORMAT_YUV444 || format->drm == DRM_FORMAT_YVU444)
49 + width <<= 1;
50 +
51 /* Don't waste cycles mixing with plane alpha if the set alpha
52 * is opaque or there is no per-pixel alpha information.
53 * In any case we use the alpha property value as the fixed alpha.