[PATCH LIBDRM 2/3] modetest: Add support for YUV422 and YUV444

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This allows dumb buffer allocation for YUV422 and YUV444 with correct
subsampling values.

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

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;
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux