Add multi-planar support
authorRob Clark <rob.clark@linaro.org>
Fri, 8 Jun 2012 19:48:33 +0000 (14:48 -0500)
committerNikhil Devshatwar <a0132237@ti.com>
Thu, 16 May 2013 14:10:27 +0000 (19:40 +0530)
test/dri2-nouveau.c
test/dri2-omap.c
test/dri2test.c
test/dri2util.h
test/dri2videotest.c

index 52de35e9d5d2a6c71956a0b44e98093ae6847ee7..bd85ddae55a1aeb34754f67b281cd4dbd995d690 100644 (file)
@@ -49,10 +49,10 @@ static void setup(int fd)
        }
 }
 
-static void * init(DRI2Buffer *dri2buf)
+static void * init(DRI2Buffer *dri2buf, int plane)
 {
        struct nouveau_bo *bo = NULL;
-       int ret = nouveau_bo_handle_ref(dev, dri2buf->names[0], &bo);
+       int ret = nouveau_bo_handle_ref(dev, dri2buf->names[plane], &bo);
        if (ret) {
                ERROR_MSG("nouveau_bo_handle_ref failed: %d", ret);
                return NULL;
index 2bcff283b48e12a7d03157ca88e0f7aefda2ebbd..8bb2bf139f405c2c4e66712fca4cf9cf60ff771f 100644 (file)
@@ -46,9 +46,9 @@ static void setup(int fd)
        dev = omap_device_new(fd);
 }
 
-static void * init(DRI2Buffer *dri2buf)
+static void * init(DRI2Buffer *dri2buf, int plane)
 {
-       return omap_bo_from_name(dev, dri2buf->names[0]);
+       return omap_bo_from_name(dev, dri2buf->names[plane]);
 }
 
 static char * prep(void *hdl)
index ec74e813b8c8b4483a761bdf448da6e837fa69c9..7f9a8b05995ff74db827a89e655d9d6c4afee35e 100644 (file)
@@ -102,15 +102,15 @@ int main(int argc, char **argv)
 
        for (i = 0; i < nbufs; i++) {
                bufs[i].dri2buf = &dri2bufs[i];
-               bufs[i].hdl = backend->init(bufs[i].dri2buf);
+               bufs[i].hdls[0] = backend->init(bufs[i].dri2buf, 0);
        }
 
        for (i = 0; i < NFRAMES; i++) {
                CARD64 count;
 
-               char *buf = backend->prep(bufs[i % nbufs].hdl);
+               char *buf = backend->prep(bufs[i % nbufs].hdls[0]);
                fill(buf, i, w, h, bufs[i % nbufs].dri2buf->pitch[0]);
-               backend->fini(bufs[i % nbufs].hdl);
+               backend->fini(bufs[i % nbufs].hdls[0]);
                DRI2SwapBuffers(dpy, win, 0, 0, 0, &count);
                MSG("DRI2SwapBuffers: count=%lu", count);
                if (i > 0) {
index 39a007d447a2987f2194353071a91fdbf59af6e9..2e436baf022dd2b9812ceb4fc93996e0003b90b9 100644 (file)
@@ -64,12 +64,12 @@ static inline void print_hex(int len, const unsigned char *val)
 
 typedef struct {
        DRI2Buffer *dri2buf;
-       void *hdl;
+       void *hdls[3];
 } Buffer;
 
 typedef struct {
        void   (*setup)(int fd);
-       void * (*init)(DRI2Buffer *dri2buf);
+       void * (*init)(DRI2Buffer *dri2buf, int plane);
        char * (*prep)(void *hdl);
        void   (*fini)(void *hdl);
 } Backend;
index 20d8459a2b9cdc282effd8a98ee4254dc4b3f66c..bcae073d3190be0187b1b6834e772f067a0151c2 100644 (file)
@@ -214,7 +214,13 @@ int main(int argc, char **argv)
 
        for (i = 0; i < nbufs; i++) {
                bufs[i].dri2buf = &dri2bufs[i];
-               bufs[i].hdl = backend->init(bufs[i].dri2buf);
+               bufs[i].hdls[0] = backend->init(bufs[i].dri2buf, 0);
+               if (format == FOURCC_STR("I420")) {
+                       bufs[i].hdls[1] = backend->init(bufs[i].dri2buf, 1);
+                       bufs[i].hdls[2] = backend->init(bufs[i].dri2buf, 2);
+               } else if (format == FOURCC_STR("NV12")) {
+                       bufs[i].hdls[1] = backend->init(bufs[i].dri2buf, 1);
+               }
        }
 
        for (i = 0; i < NFRAMES; i++) {
@@ -231,28 +237,26 @@ int main(int argc, char **argv)
 
                Buffer *buf = &bufs[i % nbufs];
                int pitch = buf->dri2buf->pitch[0];
-               unsigned char *ptr = backend->prep(buf->hdl);
+               unsigned char *ptr = backend->prep(buf->hdls[0]);
                if (format == FOURCC_STR("I420")) {
-#if 0
                        unsigned char *y = ptr;
-                       // XXX deal with multiple bo case
-                       unsigned char *u = y + (VID_HEIGHT * pitch);
-                       unsigned char *v = u + (VID_HEIGHT * pitch) / 4;
+                       unsigned char *u = backend->prep(buf->hdls[1]);
+                       unsigned char *v = backend->prep(buf->hdls[2]);
                        fill420(y, u, v, 1, i, VID_WIDTH, VID_HEIGHT, pitch);
-#else
-                       /* I think the nouveau shader actually expects NV12... */
+                       backend->fini(buf->hdls[2]);
+                       backend->fini(buf->hdls[1]);
+               } else if (format == FOURCC_STR("NV12")) {
                        unsigned char *y = ptr;
-                       // XXX deal with multiple bo case
-                       unsigned char *u = y + (VID_HEIGHT * pitch);
+                       unsigned char *u = backend->prep(buf->hdls[1]);
                        unsigned char *v = u + 1;
                        fill420(y, u, v, 2, i, VID_WIDTH, VID_HEIGHT, pitch);
-#endif
+                       backend->fini(buf->hdls[1]);
                } else if (format == FOURCC_STR("YUY2")) {
                        fill422(ptr, i, VID_WIDTH, VID_HEIGHT, pitch);
                } else if (format == FOURCC_STR("RGB4")) {
                        fill(ptr, i, VID_WIDTH, VID_HEIGHT, pitch);
                }
-               backend->fini(buf->hdl);
+               backend->fini(buf->hdls[0]);
                DRI2SwapBuffersVid(dpy, win, 0, 0, 0, &count, (i % nbufs) + 1, &b);
                MSG("DRI2SwapBuffersVid: count=%lu", count);
                if (i > 0) {