aboutsummaryrefslogtreecommitdiffstats
path: root/omap
diff options
context:
space:
mode:
authorRob Clark2012-04-11 09:51:36 -0500
committerRob Clark2012-04-11 09:51:36 -0500
commitf00efc7ab442f106d3ac7699e80f1f7aee8451f4 (patch)
treee75871cc6e430e658dc4e7b6b2ee09be42833b98 /omap
parent9b893e4a429d58bf0954ffc09b18890fcfe92941 (diff)
downloadexternal-libgbm-f00efc7ab442f106d3ac7699e80f1f7aee8451f4.tar.gz
external-libgbm-f00efc7ab442f106d3ac7699e80f1f7aee8451f4.tar.xz
external-libgbm-f00efc7ab442f106d3ac7699e80f1f7aee8451f4.zip
omap: add dmabuf support
Signed-off-by: Rob Clark <rob@ti.com>
Diffstat (limited to 'omap')
-rw-r--r--omap/omap_drm.c21
-rw-r--r--omap/omap_drmif.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/omap/omap_drm.c b/omap/omap_drm.c
index 96e18717..336da115 100644
--- a/omap/omap_drm.c
+++ b/omap/omap_drm.c
@@ -34,6 +34,7 @@
34#include <linux/stddef.h> 34#include <linux/stddef.h>
35#include <errno.h> 35#include <errno.h>
36#include <sys/mman.h> 36#include <sys/mman.h>
37#include <fcntl.h>
37 38
38#include <xf86drm.h> 39#include <xf86drm.h>
39 40
@@ -56,6 +57,7 @@ struct omap_bo {
56 uint32_t handle; 57 uint32_t handle;
57 uint32_t name; /* flink global handle (DRI2 name) */ 58 uint32_t name; /* flink global handle (DRI2 name) */
58 uint64_t offset; /* offset to mmap() */ 59 uint64_t offset; /* offset to mmap() */
60 int fd; /* dmabuf handle */
59}; 61};
60 62
61struct omap_device * omap_device_new(int fd) 63struct omap_device * omap_device_new(int fd)
@@ -264,6 +266,25 @@ uint32_t omap_bo_handle(struct omap_bo *bo)
264 return bo->handle; 266 return bo->handle;
265} 267}
266 268
269int omap_bo_dmabuf(struct omap_bo *bo)
270{
271 if (!bo->fd) {
272 struct drm_prime_handle req = {
273 .handle = bo->handle,
274 .flags = DRM_CLOEXEC,
275 };
276 int ret;
277
278 ret = drmIoctl(bo->dev->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &req);
279 if (ret) {
280 return ret;
281 }
282
283 bo->fd = req.fd;
284 }
285 return bo->fd;
286}
287
267uint32_t omap_bo_size(struct omap_bo *bo) 288uint32_t omap_bo_size(struct omap_bo *bo)
268{ 289{
269 if (!bo->size) { 290 if (!bo->size) {
diff --git a/omap/omap_drmif.h b/omap/omap_drmif.h
index eb75a80a..1e03eee1 100644
--- a/omap/omap_drmif.h
+++ b/omap/omap_drmif.h
@@ -53,6 +53,7 @@ struct omap_bo * omap_bo_from_name(struct omap_device *dev, uint32_t name);
53void omap_bo_del(struct omap_bo *bo); 53void omap_bo_del(struct omap_bo *bo);
54int omap_bo_get_name(struct omap_bo *bo, uint32_t *name); 54int omap_bo_get_name(struct omap_bo *bo, uint32_t *name);
55uint32_t omap_bo_handle(struct omap_bo *bo); 55uint32_t omap_bo_handle(struct omap_bo *bo);
56int omap_bo_dmabuf(struct omap_bo *bo);
56uint32_t omap_bo_size(struct omap_bo *bo); 57uint32_t omap_bo_size(struct omap_bo *bo);
57void * omap_bo_map(struct omap_bo *bo); 58void * omap_bo_map(struct omap_bo *bo);
58int omap_bo_cpu_prep(struct omap_bo *bo, enum omap_gem_op op); 59int omap_bo_cpu_prep(struct omap_bo *bo, enum omap_gem_op op);