diff options
author | Dave Airlie <airlied@redhat.com> | 2015-03-03 13:59:58 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2015-03-03 14:00:43 +1000 |
commit | 57dce23a849055c1c13d764ef0d43edf7325bfd5 (patch) | |
tree | 567f0ecfc5e8f2c9732e7bcc3b2cf5ce47530975 | |
parent | cc2bc58634e819cb4f3b736142b956c17cf1a5df (diff) |
-rw-r--r-- | server_egl.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/server_egl.c b/server_egl.c index c272fee..bd52888 100644 --- a/server_egl.c +++ b/server_egl.c @@ -48,6 +48,7 @@ struct server { int stride; int width, height; int sock_fd; + int fourcc; }; static int rnode_open(void) @@ -191,7 +192,7 @@ static int server_init_texture(struct server *server) EGLint name, handle, stride; int r; int fd; - + EGLint nplanes; server->width = 640; server->height = 480; /* create some textures */ @@ -213,6 +214,21 @@ static int server_init_texture(struct server *server) fprintf(stderr,"got image %p\n", server->image); +#ifdef EGL_MESA_image_dma_buf_export + b = eglExportDMABUFImageQueryMESA(server->d->rnode.egl_display, + server->image, + &server->fourcc, + &nplanes); + + if (!b) + error(1, errno, "failed to export query image\n"); + + b = eglExportDMABUFImageMESA(server->d->rnode.egl_display, + server->image, + &fd, + &server->stride); + fprintf(stderr,"image exported fd %d %d\n", server->fourcc, server->stride); +#else b = eglExportDRMImageMESA(server->d->rnode.egl_display, server->image, NULL, &handle, @@ -220,12 +236,14 @@ static int server_init_texture(struct server *server) if (!b) error(1, errno, "failed to export image\n"); - fprintf(stderr,"image exported %d %d\n", handle, server->stride); - r = drmPrimeHandleToFD(server->d->rnode.fd, handle, DRM_CLOEXEC, &fd); if (r < 0) error(1, errno, "cannot get prime-fd for handle"); + +#endif + + return fd; } @@ -259,7 +277,7 @@ struct server *server_create(int sock_fd) buf.u.buf.stride = server->stride; buf.u.buf.width = server->width; buf.u.buf.height = server->height; - buf.u.buf.format = DRM_FORMAT_XRGB8888; + buf.u.buf.format = server->fourcc ? server->fourcc : DRM_FORMAT_XRGB8888; size = sock_fd_write(server->sock_fd, &buf, sizeof(buf), fd); buf.type = CMD_TYPE_DIRT; |