drm: Branch 'master' - 4 commits

[email protected] (Rob Herring) Tue, 20 Feb 2018 20:23:31 +0000 (UTC)
Newsgroups gmane.comp.video.dri.patches
Message-ID <[email protected]>
 android/gralloc_handle.h |   45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

New commits:
commit 009634e493097afae95d190fc26cb04a1664648a
Author: Rob Herring <[email protected]>
Date:   Wed Feb 14 17:03:56 2018 -0600

    android: fix gralloc_handle_create() problems
    
    There's a number of problems with gralloc_handle_create starting with it
    doesn't even compile. More importantly, it doesn't really create (i.e.
    allocate) a handle. It allocates a native_handle_t, copies it to a
    struct gralloc_handle_t on the stack and returns the struct (not a ptr).
    So the caller still has to allocate a struct gralloc_handle_t to hold
    the returned struct.
    
    Rework gralloc_handle_create() to allocate a new handle and return the
    pointer to the allocated handle. Callers should free the handle with
    native_handle_close() and native_handle_delete(). In the interest of
    making gralloc_handle_t opaque, return a native_handle_t ptr instead.
    
    Reviewed-by: Robert Foss <[email protected]>
    Signed-off-by: Rob Herring <[email protected]>

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index 43255ba5..9cb5a5d7 100644
--- a/android/gralloc_handle.h
+++ b/android/gralloc_handle.h
@@ -84,28 +84,26 @@ static inline struct gralloc_handle_t *gralloc_handle(buffer_handle_t handle)
 /**
  * Create a buffer handle.
  */
-static struct gralloc_handle_t gralloc_handle_create(int32_t width,
+static inline native_handle_t *gralloc_handle_create(int32_t width,
                                                      int32_t height,
-                                                     int32_t format,
+                                                     int32_t hal_format,
                                                      int32_t usage)
 {
-	struct alloc_handle_t handle = {
-		.magic = GRALLOC_HANDLE_MAGIC,
-		.version = GRALLOC_HANDLE_VERSION };
-
+	struct gralloc_handle_t *handle;
 	native_handle_t *nhandle = native_handle_create(GRALLOC_HANDLE_NUM_FDS,
-		                                            GRALLOC_HANDLE_NUM_INTS);
-	handle.base = *nhandle;
-	native_handle_delete(nhandle);
-
-	handle.width = width;
-	handle.height = height;
-	handle.format = format;
-	handle.usage = usage;
-	handle.prime_fd = -1;
-
-	handle->data_owner = getpid();
-	handle->data = bo;
+							GRALLOC_HANDLE_NUM_INTS);
+
+	if (!nhandle)
+		return NULL;
+
+	handle = gralloc_handle(nhandle);
+	handle->magic = GRALLOC_HANDLE_MAGIC;
+	handle->version = GRALLOC_HANDLE_VERSION;
+	handle->width = width;
+	handle->height = height;
+	handle->format = hal_format;
+	handle->usage = usage;
+	handle->prime_fd = -1;
 
 	return handle;
 }
commit 86c62e49c81eb56200ec72936462a9a8629d7d1d
Author: Rob Herring <[email protected]>
Date:   Wed Feb 14 17:05:42 2018 -0600

    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 <[email protected]>
    Signed-off-by: Rob Herring <[email protected]>

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.
  */
commit 652bcea5a609ab6de1f54d2143968c954a37e959
Author: Rob Herring <[email protected]>
Date:   Wed Feb 14 17:06:46 2018 -0600

    android: fix mis-named alloc_handle_t
    
    Fix a typo where alloc_handle_t should be gralloc_handle_t. One still
    remains in gralloc_handle_create, but a subsequent commit will fix that
    along with other problems in gralloc_handle_create.
    
    Reviewed-by: Robert Foss <[email protected]>
    Signed-off-by: Rob Herring <[email protected]>

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index b035e035..b0f5048c 100644
--- a/android/gralloc_handle.h
+++ b/android/gralloc_handle.h
@@ -73,7 +73,7 @@ struct gralloc_handle_t {
 #define GRALLOC_HANDLE_MAGIC 0x60585350
 #define GRALLOC_HANDLE_NUM_FDS 1
 #define GRALLOC_HANDLE_NUM_INTS (	\
-	((sizeof(struct alloc_handle_t) - sizeof(native_handle_t))/sizeof(int))	\
+	((sizeof(struct gralloc_handle_t) - sizeof(native_handle_t))/sizeof(int))	\
 	 - GRALLOC_HANDLE_NUM_FDS)
 
 /**
commit 5db7bf41b27d7445f2920a938c780920b6c27851
Author: Rob Herring <[email protected]>
Date:   Wed Feb 14 17:10:25 2018 -0600

    android: revert making handle magic and version members const
    
    Const members are problematic for dynamically allocating struct
    gralloc_handle_t, so just drop the const modifier.
    
    Reviewed-by: Robert Foss <[email protected]>
    Signed-off-by: Rob Herring <[email protected]>

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index b47bee19..b035e035 100644
--- a/android/gralloc_handle.h
+++ b/android/gralloc_handle.h
@@ -51,8 +51,8 @@ struct gralloc_handle_t {
 	int prime_fd;
 
 	/* api variables */
-	const uint32_t magic; /* differentiate between allocator impls */
-	const uint32_t version; /* api version */
+	uint32_t magic; /* differentiate between allocator impls */
+	uint32_t version; /* api version */
 
 	uint32_t width; /* width of buffer in pixels */
 	uint32_t height; /* height of buffer in pixels */

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--