diff options
author | Rob Clark | 2012-06-11 08:52:24 -0500 |
---|---|---|
committer | Rob Clark | 2012-07-13 16:16:46 -0500 |
commit | 8116a32df613df4433aa1b128c58bf2c18479824 (patch) | |
tree | 95da2da3de090f8a3818364fd51cfd9197c9d82e /omap/omap_drm.c | |
parent | 992e2afd59539d169689bf21d78fac8b5cea4e3c (diff) | |
download | external-libdrm-8116a32df613df4433aa1b128c58bf2c18479824.tar.gz external-libdrm-8116a32df613df4433aa1b128c58bf2c18479824.tar.xz external-libdrm-8116a32df613df4433aa1b128c58bf2c18479824.zip |
omap: clarify dmabuf file descriptor ownership
Signed-off-by: Rob Clark <rob@ti.com>
Diffstat (limited to 'omap/omap_drm.c')
-rw-r--r-- | omap/omap_drm.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/omap/omap_drm.c b/omap/omap_drm.c index 336da115..464dea9c 100644 --- a/omap/omap_drm.c +++ b/omap/omap_drm.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <errno.h> | 35 | #include <errno.h> |
36 | #include <sys/mman.h> | 36 | #include <sys/mman.h> |
37 | #include <fcntl.h> | 37 | #include <fcntl.h> |
38 | #include <unistd.h> | ||
38 | 39 | ||
39 | #include <xf86drm.h> | 40 | #include <xf86drm.h> |
40 | 41 | ||
@@ -228,6 +229,10 @@ void omap_bo_del(struct omap_bo *bo) | |||
228 | munmap(bo->map, bo->size); | 229 | munmap(bo->map, bo->size); |
229 | } | 230 | } |
230 | 231 | ||
232 | if (bo->fd) { | ||
233 | close(bo->fd); | ||
234 | } | ||
235 | |||
231 | if (bo->handle) { | 236 | if (bo->handle) { |
232 | struct drm_gem_close req = { | 237 | struct drm_gem_close req = { |
233 | .handle = bo->handle, | 238 | .handle = bo->handle, |
@@ -266,6 +271,9 @@ uint32_t omap_bo_handle(struct omap_bo *bo) | |||
266 | return bo->handle; | 271 | return bo->handle; |
267 | } | 272 | } |
268 | 273 | ||
274 | /* caller owns the dmabuf fd that is returned and is responsible | ||
275 | * to close() it when done | ||
276 | */ | ||
269 | int omap_bo_dmabuf(struct omap_bo *bo) | 277 | int omap_bo_dmabuf(struct omap_bo *bo) |
270 | { | 278 | { |
271 | if (!bo->fd) { | 279 | if (!bo->fd) { |
@@ -282,7 +290,7 @@ int omap_bo_dmabuf(struct omap_bo *bo) | |||
282 | 290 | ||
283 | bo->fd = req.fd; | 291 | bo->fd = req.fd; |
284 | } | 292 | } |
285 | return bo->fd; | 293 | return dup(bo->fd); |
286 | } | 294 | } |
287 | 295 | ||
288 | uint32_t omap_bo_size(struct omap_bo *bo) | 296 | uint32_t omap_bo_size(struct omap_bo *bo) |