From 0f0a44812dc57b9bb37346e344bcf50235fa4d94 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 12 Jun 2013 15:48:02 +0100 Subject: Initial prime support Add initial prime support for exporting gem objects via dmabuf. Signed-off-by: Russell King --- armada_bufmgr.c | 12 ++++++++++++ armada_bufmgr.h | 3 +++ configure.ac | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) 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 #include #include +#include #include #include @@ -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) -- cgit