From aac8ca7e1bd5b76967ec9e322526bdb1df10e3d7 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 22 Jan 2016 10:35:14 -0600 Subject: Add gralloc_drm_get_prime_fd function Mesa EGL needs to retrieve prime fds from gralloc handles. Signed-off-by: Rob Herring --- gralloc_drm.c | 7 +++++++ gralloc_drm.h | 1 + gralloc_drm_handle.h | 3 +++ 3 files changed, 11 insertions(+) diff --git a/gralloc_drm.c b/gralloc_drm.c index 54b9408..6b3825e 100644 --- a/gralloc_drm.c +++ b/gralloc_drm.c @@ -278,6 +278,7 @@ static struct gralloc_drm_handle_t *create_bo_handle(int width, handle->format = format; handle->usage = usage; handle->plane_mask = 0; + handle->prime_fd = -1; return handle; } @@ -372,6 +373,12 @@ int gralloc_drm_get_gem_handle(buffer_handle_t _handle) return (handle) ? handle->name : 0; } +int gralloc_drm_get_prime_fd(buffer_handle_t _handle) +{ + struct gralloc_drm_handle_t *handle = gralloc_drm_handle(_handle); + return (handle) ? handle->prime_fd : -1; +} + /* * Query YUV component offsets for a buffer handle */ diff --git a/gralloc_drm.h b/gralloc_drm.h index e1a9957..ac0a53d 100644 --- a/gralloc_drm.h +++ b/gralloc_drm.h @@ -133,6 +133,7 @@ void gralloc_drm_bo_decref(struct gralloc_drm_bo_t *bo); struct gralloc_drm_bo_t *gralloc_drm_bo_from_handle(buffer_handle_t handle); buffer_handle_t gralloc_drm_bo_get_handle(struct gralloc_drm_bo_t *bo, int *stride); +int gralloc_drm_get_prime_fd(buffer_handle_t _handle); int gralloc_drm_get_gem_handle(buffer_handle_t handle); void gralloc_drm_resolve_format(buffer_handle_t _handle, uint32_t *pitches, uint32_t *offsets, uint32_t *handles); unsigned int planes_for_format(struct gralloc_drm_t *drm, int hal_format); diff --git a/gralloc_drm_handle.h b/gralloc_drm_handle.h index f5b6aa0..ee96fbf 100644 --- a/gralloc_drm_handle.h +++ b/gralloc_drm_handle.h @@ -36,6 +36,9 @@ struct gralloc_drm_bo_t; struct gralloc_drm_handle_t { native_handle_t base; + /* file descriptors */ + int prime_fd; + int magic; int width; -- cgit v1.1