Skip to content

Commit c4d7426

Browse files
6by9pelwell
authored andcommitted
drm/vc4: plane: Add support for P01[026] and Q01[026] formats
There are now formats defined for 2-plane YUV420 at 10, 12, and 16 bit depth using the most significant bits of the 16bit word (P010, P012, and P016), and 3-plane YUV420 at those depths using the least significant bits of the 16 bit word (S010, S012, and S016). VC4_GEN_6 can support all those formats although only composing using at most 10bits of resolution, so add them as supported formats for all planes. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent f662237 commit c4d7426

File tree

2 files changed

+59
-4
lines changed

2 files changed

+59
-4
lines changed

drivers/gpu/drm/vc4/vc4_plane.c

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ static const struct hvs_format {
3636
u32 pixel_order;
3737
u32 pixel_order_hvs5;
3838
bool hvs5_only;
39+
bool hvs6_only;
3940
} hvs_formats[] = {
4041
{
4142
.drm = DRM_FORMAT_XRGB8888,
@@ -247,6 +248,42 @@ static const struct hvs_format {
247248
.pixel_order = HVS_PIXEL_ORDER_BGRA,
248249
.pixel_order_hvs5 = HVS_PIXEL_ORDER_RGBA,
249250
},
251+
{
252+
.drm = DRM_FORMAT_P010,
253+
.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_15_6_2PLANE,
254+
.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCBCR,
255+
.hvs6_only = true,
256+
},
257+
{
258+
.drm = DRM_FORMAT_P012,
259+
.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_15_6_2PLANE,
260+
.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCBCR,
261+
.hvs6_only = true,
262+
},
263+
{
264+
.drm = DRM_FORMAT_P016,
265+
.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_15_6_2PLANE,
266+
.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCBCR,
267+
.hvs6_only = true,
268+
},
269+
{
270+
.drm = DRM_FORMAT_S010,
271+
.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_9_0_3PLANE,
272+
.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCBCR,
273+
.hvs6_only = true,
274+
},
275+
{
276+
.drm = DRM_FORMAT_S012,
277+
.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_11_2_3PLANE,
278+
.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCBCR,
279+
.hvs6_only = true,
280+
},
281+
{
282+
.drm = DRM_FORMAT_S016,
283+
.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_15_6_3PLANE,
284+
.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCBCR,
285+
.hvs6_only = true,
286+
},
250287
};
251288

252289
static const struct hvs_format *vc4_get_hvs_format(u32 drm_format)
@@ -2635,6 +2672,12 @@ static bool vc4_format_mod_supported(struct drm_plane *plane,
26352672
case DRM_FORMAT_YVU420:
26362673
case DRM_FORMAT_NV16:
26372674
case DRM_FORMAT_NV61:
2675+
case DRM_FORMAT_P010:
2676+
case DRM_FORMAT_P012:
2677+
case DRM_FORMAT_P016:
2678+
case DRM_FORMAT_S010:
2679+
case DRM_FORMAT_S012:
2680+
case DRM_FORMAT_S016:
26382681
default:
26392682
return (modifier == DRM_FORMAT_MOD_LINEAR);
26402683
}
@@ -2669,10 +2712,13 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev,
26692712
};
26702713

26712714
for (i = 0; i < ARRAY_SIZE(hvs_formats); i++) {
2672-
if (!hvs_formats[i].hvs5_only || vc4->gen >= VC4_GEN_5) {
2673-
formats[num_formats] = hvs_formats[i].drm;
2674-
num_formats++;
2675-
}
2715+
if (hvs_formats[i].hvs5_only && vc4->gen < VC4_GEN_5)
2716+
continue;
2717+
if (hvs_formats[i].hvs6_only && vc4->gen < VC4_GEN_6_C)
2718+
continue;
2719+
2720+
formats[num_formats] = hvs_formats[i].drm;
2721+
num_formats++;
26762722
}
26772723

26782724
vc4_plane = drmm_universal_plane_alloc(dev, struct vc4_plane, base,

drivers/gpu/drm/vc4/vc4_regs.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,15 @@ enum hvs_pixel_format {
10791079
HVS_PIXEL_FORMAT_AYUV444_RGB = 15,
10801080
HVS_PIXEL_FORMAT_RGBA1010102 = 16,
10811081
HVS_PIXEL_FORMAT_YCBCR_10BIT = 17,
1082+
/* 10 bit YUV420 formats with data with various different alignments */
1083+
HVS_PIXEL_FORMAT_YCBCR_YUV420_15_6_2PLANE = 24,
1084+
HVS_PIXEL_FORMAT_YCBCR_YUV420_15_6_3PLANE = 25,
1085+
HVS_PIXEL_FORMAT_YCBCR_YUV420_13_4_2PLANE = 26,
1086+
HVS_PIXEL_FORMAT_YCBCR_YUV420_13_4_3PLANE = 27,
1087+
HVS_PIXEL_FORMAT_YCBCR_YUV420_11_2_2PLANE = 28,
1088+
HVS_PIXEL_FORMAT_YCBCR_YUV420_11_2_3PLANE = 29,
1089+
HVS_PIXEL_FORMAT_YCBCR_YUV420_9_0_2PLANE = 30,
1090+
HVS_PIXEL_FORMAT_YCBCR_YUV420_9_0_3PLANE = 31,
10821091
};
10831092

10841093
/* Note: the LSB is the rightmost character shown. Only valid for

0 commit comments

Comments
 (0)