From 86c62e49c81eb56200ec72936462a9a8629d7d1d Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Wed, 14 Feb 2018 17:05:42 -0600 Subject: [PATCH] android: add helper to convert buffer_handle_t to gralloc_handle_t ptr Clients frequently need to convert a buffer_handle_t (aka native_handle_t *) to a gralloc_handle_t ptr. This is a simple cast, but add an inline function to do the conversion. Reviewed-by: Robert Foss Signed-off-by: Rob Herring --- android/gralloc_handle.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h index b0f5048c..43255ba5 100644 --- a/android/gralloc_handle.h +++ b/android/gralloc_handle.h @@ -76,6 +76,11 @@ struct gralloc_handle_t { ((sizeof(struct gralloc_handle_t) - sizeof(native_handle_t))/sizeof(int)) \ - GRALLOC_HANDLE_NUM_FDS) +static inline struct gralloc_handle_t *gralloc_handle(buffer_handle_t handle) +{ + return (struct gralloc_handle_t *)handle; +} + /** * Create a buffer handle. */