Skip to contentSkip to conversation

drm/vc4 support for extra formats

PATCH In review Dave Stevenson 2 participants 5 messages Nov 16, 2017 – Nov 20, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drm/vc4 support for extra formats

These are relatively trivial patches that just expand the
list of formats that the vc4 DRM driver will accept.
RGB888, BGR888, NV21, and NV61 tested with the modetest app from the libdrm repo. YUV422 and YVU422 can't be as they aren't supported.

Dave Stevenson (3):
drm/vc4: Add support for DRM_FORMAT_RGB888 and DRM_FORMAT_BGR888 drm/vc4: Use .pixel_order instead of custom .flip_cbcr drm/vc4: Add support for NV21 and NV61.

 drivers/gpu/drm/vc4/vc4_plane.c | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 1/3 drm/vc4: Add support for DRM_FORMAT_RGB888 and DRM_FORMAT_BGR888

Filling out the list of supported formats based on those the hardware can support.

---
 drivers/gpu/drm/vc4/vc4_plane.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/vc4/vc4_plane.c +8 -0
index 423a23e..513b4b1 100644
@@ -121,6 +121,14 @@ static const struct hvs_format {
 		.pixel_order = HVS_PIXEL_ORDER_ABGR, .has_alpha = false,
 	},
 	{
+		.drm = DRM_FORMAT_RGB888, .hvs = HVS_PIXEL_FORMAT_RGB888,
+		.pixel_order = HVS_PIXEL_ORDER_XRGB, .has_alpha = false,
+	},
+	{
+		.drm = DRM_FORMAT_BGR888, .hvs = HVS_PIXEL_FORMAT_RGB888,
+		.pixel_order = HVS_PIXEL_ORDER_XBGR, .has_alpha = false,
+	},
+	{
 		.drm = DRM_FORMAT_YUV422,
 		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
 	},
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 2/3 drm/vc4: Use .pixel_order instead of custom .flip_cbcr

In reply to Dave Stevenson

The hardware has enums for altering the Cr and Cb order, so use this instead of having a flag which swaps the order the pointers are presented to the hardware (that only worked for 3 plane formats anyway).

Explicitly sets .pixel_order in each case, rather than relying on then default XYCBCR order being a value 0.

---
 drivers/gpu/drm/vc4/vc4_plane.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/gpu/drm/vc4/vc4_plane.c +8 -12
index 513b4b1..6373fd5 100644
@@ -86,7 +86,6 @@ static const struct hvs_format {
 	u32 hvs; /* HVS_FORMAT_* */
 	u32 pixel_order;
 	bool has_alpha;
-	bool flip_cbcr;
 } hvs_formats[] = {
 	{
 		.drm = DRM_FORMAT_XRGB8888, .hvs = HVS_PIXEL_FORMAT_RGBA8888,
@@ -131,28 +130,32 @@ static const struct hvs_format {
 	{
 		.drm = DRM_FORMAT_YUV422,
 		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
+		.pixel_order = HVS_PIXEL_ORDER_XYCBCR,
 	},
 	{
 		.drm = DRM_FORMAT_YVU422,
 		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
-		.flip_cbcr = true,
+		.pixel_order = HVS_PIXEL_ORDER_XYCRCB,
 	},
 	{
 		.drm = DRM_FORMAT_YUV420,
 		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_3PLANE,
+		.pixel_order = HVS_PIXEL_ORDER_XYCBCR,
 	},
 	{
 		.drm = DRM_FORMAT_YVU420,
 		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_3PLANE,
-		.flip_cbcr = true,
+		.pixel_order = HVS_PIXEL_ORDER_XYCRCB,
 	},
 	{
 		.drm = DRM_FORMAT_NV12,
 		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_2PLANE,
+		.pixel_order = HVS_PIXEL_ORDER_XYCBCR,
 	},
 	{
 		.drm = DRM_FORMAT_NV16,
 		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_2PLANE,
+		.pixel_order = HVS_PIXEL_ORDER_XYCBCR,
 	},
 };
 
@@ -625,15 +628,8 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
 	 * The pointers may be any byte address.
 	 */
 	vc4_state->ptr0_offset = vc4_state->dlist_count;
-	if (!format->flip_cbcr) {
-		for (i = 0; i < num_planes; i++)
-			vc4_dlist_write(vc4_state, vc4_state->offsets[i]);
-	} else {
-		WARN_ON_ONCE(num_planes != 3);
-		vc4_dlist_write(vc4_state, vc4_state->offsets[0]);
-		vc4_dlist_write(vc4_state, vc4_state->offsets[2]);
-		vc4_dlist_write(vc4_state, vc4_state->offsets[1]);
-	}
+	for (i = 0; i < num_planes; i++)
+		vc4_dlist_write(vc4_state, vc4_state->offsets[i]);
 
 	/* Pointer Context Word 0/1/2: Written by the HVS */
 	for (i = 0; i < num_planes; i++)
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 3/3 drm/vc4: Add support for NV21 and NV61.

In reply to Dave Stevenson

NV12 (YUV420 2 plane) and NV16 (YUV422 2 plane) were supported, but NV21 and NV61 (same but with Cb and Cr swapped) weren't. Add them.

---
 drivers/gpu/drm/vc4/vc4_plane.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/gpu/drm/vc4/vc4_plane.c +10 -0
index 6373fd5..515f979 100644
@@ -153,10 +153,20 @@ static const struct hvs_format {
 		.pixel_order = HVS_PIXEL_ORDER_XYCBCR,
 	},
 	{
+		.drm = DRM_FORMAT_NV21,
+		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_2PLANE,
+		.pixel_order = HVS_PIXEL_ORDER_XYCRCB,
+	},
+	{
 		.drm = DRM_FORMAT_NV16,
 		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_2PLANE,
 		.pixel_order = HVS_PIXEL_ORDER_XYCBCR,
 	},
+	{
+		.drm = DRM_FORMAT_NV61,
+		.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_2PLANE,
+		.pixel_order = HVS_PIXEL_ORDER_XYCRCB,
+	},
 };
 
 static const struct hvs_format *vc4_get_hvs_format(u32 drm_format)
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw
In reply to Dave Stevenson
Quoted 4 lines · Dave Stevenson

These are relatively trivial patches that just expand the
list of formats that the vc4 DRM driver will accept.
RGB888, BGR888, NV21, and NV61 tested with the modetest app from the libdrm repo. YUV422 and YVU422 can't be as they aren't supported.

It worked in my testing, as well. Reviewed and applied to drm-misc-next. Thanks!

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel