All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libdrm 0/4] gralloc handle fixes
@ 2018-02-15 13:59 Rob Herring
  2018-02-15 13:59 ` [PATCH libdrm 1/4] android: revert making handle magic and version members const Rob Herring
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Rob Herring @ 2018-02-15 13:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Robert Foss

The recently committed gralloc handle definition has a few issues like 
not actually compiling. This series fixes those issues. I now have 
things working with these fixes and switching mesa, gbm_gralloc, and 
drm_hwcomposer to use this header.

Rob

Rob Herring (4):
  android: revert making handle magic and version members const
  android: fix mis-named alloc_handle_t
  android: add helper to convert buffer_handle_t to gralloc_handle_t ptr
  android: fix gralloc_handle_create() problems

 android/gralloc_handle.h | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH libdrm 1/4] android: revert making handle magic and version members const
  2018-02-15 13:59 [PATCH libdrm 0/4] gralloc handle fixes Rob Herring
@ 2018-02-15 13:59 ` Rob Herring
  2018-02-15 13:59 ` [PATCH libdrm 2/4] android: fix mis-named alloc_handle_t Rob Herring
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2018-02-15 13:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Robert Foss

Const members are problematic for dynamically allocating struct
gralloc_handle_t, so just drop the const modifier.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 android/gralloc_handle.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index b47bee191f94..b035e03566cc 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 */
-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH libdrm 2/4] android: fix mis-named alloc_handle_t
  2018-02-15 13:59 [PATCH libdrm 0/4] gralloc handle fixes Rob Herring
  2018-02-15 13:59 ` [PATCH libdrm 1/4] android: revert making handle magic and version members const Rob Herring
@ 2018-02-15 13:59 ` Rob Herring
  2018-02-15 13:59 ` [PATCH libdrm 3/4] android: add helper to convert buffer_handle_t to gralloc_handle_t ptr Rob Herring
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2018-02-15 13:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Robert Foss

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.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 android/gralloc_handle.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index b035e03566cc..b0f5048cc6a1 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)
 
 /**
-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH libdrm 3/4] android: add helper to convert buffer_handle_t to gralloc_handle_t ptr
  2018-02-15 13:59 [PATCH libdrm 0/4] gralloc handle fixes Rob Herring
  2018-02-15 13:59 ` [PATCH libdrm 1/4] android: revert making handle magic and version members const Rob Herring
  2018-02-15 13:59 ` [PATCH libdrm 2/4] android: fix mis-named alloc_handle_t Rob Herring
@ 2018-02-15 13:59 ` Rob Herring
  2018-02-15 13:59 ` [PATCH libdrm 4/4] android: fix gralloc_handle_create() problems Rob Herring
  2018-02-15 15:43 ` [PATCH libdrm 0/4] gralloc handle fixes Robert Foss
  4 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2018-02-15 13:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Robert Foss

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.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 android/gralloc_handle.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index b0f5048cc6a1..43255ba539c2 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.
  */
-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH libdrm 4/4] android: fix gralloc_handle_create() problems
  2018-02-15 13:59 [PATCH libdrm 0/4] gralloc handle fixes Rob Herring
                   ` (2 preceding siblings ...)
  2018-02-15 13:59 ` [PATCH libdrm 3/4] android: add helper to convert buffer_handle_t to gralloc_handle_t ptr Rob Herring
@ 2018-02-15 13:59 ` Rob Herring
  2018-02-15 15:43 ` [PATCH libdrm 0/4] gralloc handle fixes Robert Foss
  4 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2018-02-15 13:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Robert Foss

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().

Signed-off-by: Rob Herring <robh@kernel.org>
---
 android/gralloc_handle.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/android/gralloc_handle.h b/android/gralloc_handle.h
index 43255ba539c2..3177f7a1fd8f 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 struct gralloc_handle_t *gralloc_handle_create(int32_t width,
                                                      int32_t height,
                                                      int32_t 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 = format;
+	handle->usage = usage;
+	handle->prime_fd = -1;
 
 	return handle;
 }
-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH libdrm 0/4] gralloc handle fixes
  2018-02-15 13:59 [PATCH libdrm 0/4] gralloc handle fixes Rob Herring
                   ` (3 preceding siblings ...)
  2018-02-15 13:59 ` [PATCH libdrm 4/4] android: fix gralloc_handle_create() problems Rob Herring
@ 2018-02-15 15:43 ` Robert Foss
  4 siblings, 0 replies; 6+ messages in thread
From: Robert Foss @ 2018-02-15 15:43 UTC (permalink / raw)
  To: Rob Herring, dri-devel

Hey Rob,

Thanks for ironing out the kinks, and the new helper.
If you need reviews for any of the related changes, CC me.

This all looks good to me. Feel free to add my r-b.


Rob.

On 02/15/2018 02:59 PM, Rob Herring wrote:
> The recently committed gralloc handle definition has a few issues like
> not actually compiling. This series fixes those issues. I now have
> things working with these fixes and switching mesa, gbm_gralloc, and
> drm_hwcomposer to use this header.
> 
> Rob
> 
> Rob Herring (4):
>    android: revert making handle magic and version members const
>    android: fix mis-named alloc_handle_t
>    android: add helper to convert buffer_handle_t to gralloc_handle_t ptr
>    android: fix gralloc_handle_create() problems
> 
>   android/gralloc_handle.h | 43 +++++++++++++++++++++++--------------------
>   1 file changed, 23 insertions(+), 20 deletions(-)
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-15 15:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15 13:59 [PATCH libdrm 0/4] gralloc handle fixes Rob Herring
2018-02-15 13:59 ` [PATCH libdrm 1/4] android: revert making handle magic and version members const Rob Herring
2018-02-15 13:59 ` [PATCH libdrm 2/4] android: fix mis-named alloc_handle_t Rob Herring
2018-02-15 13:59 ` [PATCH libdrm 3/4] android: add helper to convert buffer_handle_t to gralloc_handle_t ptr Rob Herring
2018-02-15 13:59 ` [PATCH libdrm 4/4] android: fix gralloc_handle_create() problems Rob Herring
2018-02-15 15:43 ` [PATCH libdrm 0/4] gralloc handle fixes Robert Foss

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.