diff options
author | Ricardo Salveti de Araujo <ricardo.salveti@linaro.org> | 2012-08-23 15:14:39 -0300 |
---|---|---|
committer | Rob Clark <rob.clark@linaro.org> | 2012-08-23 13:24:01 -0500 |
commit | 7311a299c22a8e36a4dff6daeb7eb98dc8a6f52a (patch) | |
tree | 9994621fecced679a338d4a40c06dc8a32885f87 | |
parent | 423ec8f6b3ce668adb21d7f2a0561bdf5676775b (diff) |
dri2: change DRI2Buffer to enable multiplanar yuv
Change DRI2Buffer to make names/pitches into an array to deal with
multiplanar yuv.
Based on the dri2video support patch by Rob Clark <rob@ti.com>
Signed-off-by: Ricardo Salveti de Araujo <ricardo.salveti@linaro.org>
-rw-r--r-- | include/X11/extensions/dri2.h | 4 | ||||
-rw-r--r-- | src/dri2.c | 106 | ||||
-rw-r--r-- | test/dri2-nouveau.c | 2 | ||||
-rw-r--r-- | test/dri2-omap.c | 2 | ||||
-rw-r--r-- | test/dri2test.c | 4 |
5 files changed, 40 insertions, 78 deletions
diff --git a/include/X11/extensions/dri2.h b/include/X11/extensions/dri2.h index e42cdb6..71c7334 100644 --- a/include/X11/extensions/dri2.h +++ b/include/X11/extensions/dri2.h @@ -43,8 +43,8 @@ typedef struct { unsigned int attachment; - unsigned int name; - unsigned int pitch; + unsigned int names[3]; /* unused entries set to zero.. non-planar formats only use names[0] */ + unsigned int pitch[3]; /* unused entries set to zero.. non-planar formats only use pitch[0] */ unsigned int cpp; unsigned int flags; } DRI2Buffer; @@ -363,10 +363,9 @@ DRI2DestroyDrawable(Display * dpy, XID drawable) SyncHandle(); } -DRI2Buffer * -DRI2GetBuffers(Display * dpy, XID drawable, - int *width, int *height, - unsigned int *attachments, int count, int *outCount) +static DRI2Buffer * +getbuffers(Display *dpy, XID drawable, int *width, int *height, + unsigned int *attachments, int count, int *outCount, int dri2ReqType) { XExtDisplayInfo *info = DRI2FindDisplay(dpy); xDRI2GetBuffersReply rep; @@ -374,18 +373,27 @@ DRI2GetBuffers(Display * dpy, XID drawable, DRI2Buffer *buffers; xDRI2Buffer repBuffer; CARD32 *p; - int i; + int i, nattachments; + + /* DRI2GetBuffersWithFormat has interleaved attachment+format in + * attachments[] array, so length of array is 2x as long.. + */ + if (dri2ReqType == X_DRI2GetBuffersWithFormat) { + nattachments = 2 * count; + } else { + nattachments = count; + } XextCheckExtension(dpy, info, dri2ExtensionName, False); LockDisplay(dpy); - GetReqExtra(DRI2GetBuffers, count * 4, req); + GetReqExtra(DRI2GetBuffers, nattachments * 4, req); req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2GetBuffers; + req->dri2ReqType = dri2ReqType; req->drawable = drawable; req->count = count; p = (CARD32 *) & req[1]; - for (i = 0; i < count; i++) + for (i = 0; i < nattachments; i++) p[i] = attachments[i]; if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { @@ -398,21 +406,16 @@ DRI2GetBuffers(Display * dpy, XID drawable, *height = rep.height; *outCount = rep.count; - buffers = Xmalloc(rep.count * sizeof buffers[0]); - if (buffers == NULL) { - _XEatData(dpy, rep.count * sizeof repBuffer); - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - + buffers = calloc(rep.count, sizeof buffers[0]); for (i = 0; i < rep.count; i++) { _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer); - buffers[i].attachment = repBuffer.attachment; - buffers[i].name = repBuffer.name; - buffers[i].pitch = repBuffer.pitch; - buffers[i].cpp = repBuffer.cpp; - buffers[i].flags = repBuffer.flags; + if (buffers) { + buffers[i].attachment = repBuffer.attachment; + buffers[i].names[0] = repBuffer.name; + buffers[i].pitch[0] = repBuffer.pitch; + buffers[i].cpp = repBuffer.cpp; + buffers[i].flags = repBuffer.flags; + } } UnlockDisplay(dpy); @@ -421,63 +424,22 @@ DRI2GetBuffers(Display * dpy, XID drawable, return buffers; } +DRI2Buffer * +DRI2GetBuffers(Display * dpy, XID drawable, + int *width, int *height, + unsigned int *attachments, int count, int *outCount) +{ + return getbuffers(dpy, drawable, width, height, attachments, + count, outCount, X_DRI2GetBuffers); +} DRI2Buffer * DRI2GetBuffersWithFormat(Display * dpy, XID drawable, int *width, int *height, unsigned int *attachments, int count, int *outCount) { - XExtDisplayInfo *info = DRI2FindDisplay(dpy); - xDRI2GetBuffersReply rep; - xDRI2GetBuffersReq *req; - DRI2Buffer *buffers; - xDRI2Buffer repBuffer; - CARD32 *p; - int i; - - XextCheckExtension(dpy, info, dri2ExtensionName, False); - - LockDisplay(dpy); - GetReqExtra(DRI2GetBuffers, count * (4 * 2), req); - req->reqType = info->codes->major_opcode; - req->dri2ReqType = X_DRI2GetBuffersWithFormat; - req->drawable = drawable; - req->count = count; - p = (CARD32 *) & req[1]; - for (i = 0; i < (count * 2); i++) - p[i] = attachments[i]; - - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - *width = rep.width; - *height = rep.height; - *outCount = rep.count; - - buffers = Xmalloc(rep.count * sizeof buffers[0]); - if (buffers == NULL) { - _XEatData(dpy, rep.count * sizeof repBuffer); - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - for (i = 0; i < rep.count; i++) { - _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer); - buffers[i].attachment = repBuffer.attachment; - buffers[i].name = repBuffer.name; - buffers[i].pitch = repBuffer.pitch; - buffers[i].cpp = repBuffer.cpp; - buffers[i].flags = repBuffer.flags; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return buffers; + return getbuffers(dpy, drawable, width, height, attachments, + count, outCount, X_DRI2GetBuffersWithFormat); } diff --git a/test/dri2-nouveau.c b/test/dri2-nouveau.c index f91cc48..52de35e 100644 --- a/test/dri2-nouveau.c +++ b/test/dri2-nouveau.c @@ -52,7 +52,7 @@ static void setup(int fd) static void * init(DRI2Buffer *dri2buf) { struct nouveau_bo *bo = NULL; - int ret = nouveau_bo_handle_ref(dev, dri2buf->name, &bo); + int ret = nouveau_bo_handle_ref(dev, dri2buf->names[0], &bo); if (ret) { ERROR_MSG("nouveau_bo_handle_ref failed: %d", ret); return NULL; diff --git a/test/dri2-omap.c b/test/dri2-omap.c index 181599d..2bcff28 100644 --- a/test/dri2-omap.c +++ b/test/dri2-omap.c @@ -48,7 +48,7 @@ static void setup(int fd) static void * init(DRI2Buffer *dri2buf) { - return omap_bo_from_name(dev, dri2buf->name); + return omap_bo_from_name(dev, dri2buf->names[0]); } static char * prep(void *hdl) diff --git a/test/dri2test.c b/test/dri2test.c index 1aa101d..ec74e81 100644 --- a/test/dri2test.c +++ b/test/dri2test.c @@ -48,7 +48,7 @@ static void fill(char *virtual, int n, int width, int height, int stride) for (j = 0; j < height; j++) { uint32_t *fb_ptr = (uint32_t*)((char*)virtual + j * stride); for (i = 0; i < width; i++) { - div_t d = div(n+i, width); + div_t d = div(n+i+j, width); fb_ptr[i] = 0x00130502 * (d.quot >> 6) + 0x000a1120 * (d.rem >> 6); @@ -109,7 +109,7 @@ int main(int argc, char **argv) CARD64 count; char *buf = backend->prep(bufs[i % nbufs].hdl); - fill(buf, i, w, h, bufs[i % nbufs].dri2buf->pitch); + fill(buf, i, w, h, bufs[i % nbufs].dri2buf->pitch[0]); backend->fini(bufs[i % nbufs].hdl); DRI2SwapBuffers(dpy, win, 0, 0, 0, &count); MSG("DRI2SwapBuffers: count=%lu", count); |