summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/modetest/buffers.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c
index 576e2cc7..f00a169f 100644
--- a/tests/modetest/buffers.c
+++ b/tests/modetest/buffers.c
@@ -116,9 +116,10 @@ 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, xsub, ysub;
struct bo *bo;
unsigned int bpp;
+ bool is_planar;
void *planes[3] = { 0, };
void *virtual;
int ret;
@@ -223,26 +224,38 @@ bo_create(int fd, unsigned int format,
case DRM_FORMAT_NV15:
case DRM_FORMAT_YUV420:
case DRM_FORMAT_YVU420:
- virtual_height = height * 3 / 2;
+ is_planar = true;
+ xsub = 2;
+ ysub = 2;
break;
case DRM_FORMAT_NV16:
case DRM_FORMAT_NV61:
case DRM_FORMAT_NV20:
- virtual_height = height * 2;
+ is_planar = true;
+ xsub = 2;
+ ysub = 1;
break;
case DRM_FORMAT_NV24:
case DRM_FORMAT_NV42:
case DRM_FORMAT_NV30:
- virtual_height = height * 3;
+ is_planar = true;
+ xsub = 1;
+ ysub = 1;
break;
default:
- virtual_height = height;
+ is_planar = false;
+ xsub = 1;
+ ysub = 1;
break;
}
+ virtual_height = height;
+ if (is_planar)
+ virtual_height += height * 2 / xsub / ysub;
+
bo = bo_create_dumb(fd, width, virtual_height, bpp);
if (!bo)
return NULL;
@@ -275,25 +288,14 @@ bo_create(int fd, unsigned int format,
case DRM_FORMAT_NV16:
case DRM_FORMAT_NV61:
case DRM_FORMAT_NV15:
- case DRM_FORMAT_NV20:
- offsets[0] = 0;
- handles[0] = bo->handle;
- pitches[0] = bo->pitch;
- pitches[1] = pitches[0];
- offsets[1] = pitches[0] * height;
- handles[1] = bo->handle;
-
- planes[0] = virtual;
- planes[1] = virtual + offsets[1];
- break;
-
case DRM_FORMAT_NV24:
case DRM_FORMAT_NV42:
+ case DRM_FORMAT_NV20:
case DRM_FORMAT_NV30:
offsets[0] = 0;
handles[0] = bo->handle;
pitches[0] = bo->pitch;
- pitches[1] = pitches[0] * 2;
+ pitches[1] = pitches[0] * 2 / xsub;
offsets[1] = pitches[0] * height;
handles[1] = bo->handle;
@@ -306,11 +308,11 @@ bo_create(int fd, unsigned int format,
offsets[0] = 0;
handles[0] = bo->handle;
pitches[0] = bo->pitch;
- pitches[1] = pitches[0] / 2;
+ pitches[1] = pitches[0] / xsub;
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 / ysub;
handles[2] = bo->handle;
planes[0] = virtual;