diff mbox

[libdrm,2/3] modetest: Add support for YUV422 and YUV444

Message ID 1531017333-1483-3-git-send-email-hyun.kwon@xilinx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hyun Kwon July 8, 2018, 2:35 a.m. UTC
This allows dumb buffer allocation for YUV422 and YUV444 with correct
subsampling values.

Signed-off-by: Hyun Kwon <hyun.kwon@xilinx.com>
---
 tests/modetest/buffers.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c
index 9b635c0..769399e 100644
--- a/tests/modetest/buffers.c
+++ b/tests/modetest/buffers.c
@@ -127,7 +127,7 @@  bo_create(int fd, unsigned int format,
 	  unsigned int handles[4], unsigned int pitches[4],
 	  unsigned int offsets[4], enum util_fill_pattern pattern)
 {
-	unsigned int virtual_height;
+	unsigned int virtual_height, hsub, vsub;
 	struct bo *bo;
 	unsigned int bpp;
 	void *planes[3] = { 0, };
@@ -141,6 +141,10 @@  bo_create(int fd, unsigned int format,
 	case DRM_FORMAT_NV61:
 	case DRM_FORMAT_YUV420:
 	case DRM_FORMAT_YVU420:
+	case DRM_FORMAT_YUV422:
+	case DRM_FORMAT_YVU422:
+	case DRM_FORMAT_YUV444:
+	case DRM_FORMAT_YVU444:
 		bpp = 8;
 		break;
 
@@ -204,15 +208,30 @@  bo_create(int fd, unsigned int format,
 	case DRM_FORMAT_YUV420:
 	case DRM_FORMAT_YVU420:
 		virtual_height = height * 3 / 2;
+		hsub = 2;
+		vsub = 2;
 		break;
 
 	case DRM_FORMAT_NV16:
 	case DRM_FORMAT_NV61:
+	case DRM_FORMAT_YUV422:
+	case DRM_FORMAT_YVU422:
 		virtual_height = height * 2;
+		hsub = 2;
+		vsub = 1;
+		break;
+
+	case DRM_FORMAT_YUV444:
+	case DRM_FORMAT_YVU444:
+		virtual_height = height * 3;
+		hsub = 1;
+		vsub = 1;
 		break;
 
 	default:
 		virtual_height = height;
+		hsub = 1;
+		vsub = 1;
 		break;
 	}
 
@@ -260,14 +279,18 @@  bo_create(int fd, unsigned int format,
 
 	case DRM_FORMAT_YUV420:
 	case DRM_FORMAT_YVU420:
+	case DRM_FORMAT_YUV422:
+	case DRM_FORMAT_YVU422:
+	case DRM_FORMAT_YUV444:
+	case DRM_FORMAT_YVU444:
 		offsets[0] = 0;
 		handles[0] = bo->handle;
 		pitches[0] = bo->pitch;
-		pitches[1] = pitches[0] / 2;
+		pitches[1] = pitches[0] / hsub;
 		offsets[1] = pitches[0] * height;
 		handles[1] = bo->handle;
 		pitches[2] = pitches[1];
-		offsets[2] = offsets[1] + pitches[1] * height / 2;
+		offsets[2] = offsets[1] + pitches[1] * height / vsub;
 		handles[2] = bo->handle;
 
 		planes[0] = virtual;