aboutsummaryrefslogtreecommitdiffstats
path: root/omap
diff options
context:
space:
mode:
Diffstat (limited to 'omap')
-rw-r--r--omap/omap_drm.c32
-rw-r--r--omap/omap_drmif.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/omap/omap_drm.c b/omap/omap_drm.c
index 464dea9c..1d37e451 100644
--- a/omap/omap_drm.c
+++ b/omap/omap_drm.c
@@ -218,6 +218,38 @@ fail:
218 return NULL; 218 return NULL;
219} 219}
220 220
221/* import a buffer from dmabuf fd, does not take ownership of the
222 * fd so caller should close() the fd when it is otherwise done
223 * with it (even if it is still using the 'struct omap_bo *')
224 */
225struct omap_bo * omap_bo_from_dmabuf(struct omap_device *dev, int fd)
226{
227 struct omap_bo *bo;
228 struct drm_prime_handle req = {
229 .fd = fd,
230 };
231 int ret;
232
233 bo = calloc(sizeof(*bo), 1);
234 if (!bo) {
235 goto fail;
236 }
237
238 ret = drmIoctl(dev->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &req);
239 if (ret) {
240 goto fail;
241 }
242
243 bo->dev = dev;
244 bo->handle = req.handle;
245
246 return bo;
247
248fail:
249 free(bo);
250 return NULL;
251}
252
221/* destroy a buffer object */ 253/* destroy a buffer object */
222void omap_bo_del(struct omap_bo *bo) 254void omap_bo_del(struct omap_bo *bo)
223{ 255{
diff --git a/omap/omap_drmif.h b/omap/omap_drmif.h
index 1e03eee1..284b9ccc 100644
--- a/omap/omap_drmif.h
+++ b/omap/omap_drmif.h
@@ -50,6 +50,7 @@ struct omap_bo * omap_bo_new(struct omap_device *dev,
50struct omap_bo * omap_bo_new_tiled(struct omap_device *dev, 50struct omap_bo * omap_bo_new_tiled(struct omap_device *dev,
51 uint32_t width, uint32_t height, uint32_t flags); 51 uint32_t width, uint32_t height, uint32_t flags);
52struct omap_bo * omap_bo_from_name(struct omap_device *dev, uint32_t name); 52struct omap_bo * omap_bo_from_name(struct omap_device *dev, uint32_t name);
53struct omap_bo * omap_bo_from_dmabuf(struct omap_device *dev, int fd);
53void omap_bo_del(struct omap_bo *bo); 54void omap_bo_del(struct omap_bo *bo);
54int omap_bo_get_name(struct omap_bo *bo, uint32_t *name); 55int omap_bo_get_name(struct omap_bo *bo, uint32_t *name);
55uint32_t omap_bo_handle(struct omap_bo *bo); 56uint32_t omap_bo_handle(struct omap_bo *bo);