diff options
author | Russell King <rmk_cubox@arm.linux.org.uk> | 2013-06-12 15:48:02 +0100 |
---|---|---|
committer | Russell King <rmk@arm.linux.org.uk> | 2013-09-22 15:19:00 +0100 |
commit | 0f0a44812dc57b9bb37346e344bcf50235fa4d94 (patch) | |
tree | 1f4cb13aef893bafd8d9677d5f38eb9216d03993 | |
parent | 7923dea762934a715063465338a4d8e9275034e3 (diff) |
Initial prime support
Add initial prime support for exporting gem objects via dmabuf.
Signed-off-by: Russell King <rmk_cubox@arm.linux.org.uk>
-rw-r--r-- | armada_bufmgr.c | 12 | ||||
-rw-r--r-- | armada_bufmgr.h | 3 | ||||
-rw-r--r-- | configure.ac | 2 |
3 files changed, 16 insertions, 1 deletions
diff --git a/armada_bufmgr.c b/armada_bufmgr.c index 2364051..6b9e667 100644 --- a/armada_bufmgr.c +++ b/armada_bufmgr.c @@ -3,6 +3,7 @@ #include <stdlib.h> #include <string.h> #include <errno.h> +#include <sys/fcntl.h> #include <sys/mman.h> #include <time.h> @@ -452,6 +453,17 @@ int drm_armada_bo_flink(struct drm_armada_bo *dbo, uint32_t *name) return 0; } +int drm_armada_bo_to_fd(struct drm_armada_bo *dbo, int *prime_fd) +{ + struct armada_bo *bo = to_armada_bo(dbo); + int fd = bo->mgr->fd; + + if (drmPrimeHandleToFD(fd, bo->bo.handle, DRM_CLOEXEC, prime_fd)) + return -1; + + return 0; +} + int drm_armada_bo_map(struct drm_armada_bo *dbo) { struct armada_bo *bo = to_armada_bo(dbo); diff --git a/armada_bufmgr.h b/armada_bufmgr.h index 9e6188f..f84785f 100644 --- a/armada_bufmgr.h +++ b/armada_bufmgr.h @@ -36,6 +36,9 @@ struct drm_armada_bo *drm_armada_bo_create_from_name(struct drm_armada_bufmgr *, /* Create a global name from a BO */ int drm_armada_bo_flink(struct drm_armada_bo *bo, uint32_t *name); +/* Create a dmabuf fd for the BO */ +int drm_armada_bo_to_fd(struct drm_armada_bo *bo, int *fd); + int drm_armada_bo_map(struct drm_armada_bo *bo); uint32_t drm_armada_bo_phys(struct drm_armada_bo *bo); void drm_armada_bo_get(struct drm_armada_bo *bo); diff --git a/configure.ac b/configure.ac index 0e1ab67..7b110a8 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=], [AC_MSG_ERROR([Could not find clock_gettime])])]) AC_SUBST([CLOCK_LIB]) -PKG_CHECK_MODULES(LIBDRM, libdrm) +PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.38]) AC_SUBST(LIBDRM_CFLAGS) AC_SUBST(LIBDRM_LIBS) |