omap: clarify dmabuf file descriptor ownership

Signed-off-by: Rob Clark <rob@ti.com>
main
Rob Clark 2012-06-11 08:52:24 -05:00
parent 992e2afd59
commit 8116a32df6
1 changed files with 9 additions and 1 deletions

View File

@ -35,6 +35,7 @@
#include <errno.h> #include <errno.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h>
#include <xf86drm.h> #include <xf86drm.h>
@ -228,6 +229,10 @@ void omap_bo_del(struct omap_bo *bo)
munmap(bo->map, bo->size); munmap(bo->map, bo->size);
} }
if (bo->fd) {
close(bo->fd);
}
if (bo->handle) { if (bo->handle) {
struct drm_gem_close req = { struct drm_gem_close req = {
.handle = bo->handle, .handle = bo->handle,
@ -266,6 +271,9 @@ uint32_t omap_bo_handle(struct omap_bo *bo)
return bo->handle; return bo->handle;
} }
/* caller owns the dmabuf fd that is returned and is responsible
* to close() it when done
*/
int omap_bo_dmabuf(struct omap_bo *bo) int omap_bo_dmabuf(struct omap_bo *bo)
{ {
if (!bo->fd) { if (!bo->fd) {
@ -282,7 +290,7 @@ int omap_bo_dmabuf(struct omap_bo *bo)
bo->fd = req.fd; bo->fd = req.fd;
} }
return bo->fd; return dup(bo->fd);
} }
uint32_t omap_bo_size(struct omap_bo *bo) uint32_t omap_bo_size(struct omap_bo *bo)