Skip to contentSkip to conversation

libdrm: gralloc_handle.h: Fix build issue with Android

RFC PATCH Superseded John Stultz 5 participants 7 messages Mar 16, 2018 – Apr 3, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 libdrm: gralloc_handle.h: Fix build issue with Android

In trying to integrate the new gralloc_handle.h with the drm_hwcomposer, I started seeing the following compilation errors:

In file included from external/drm_hwcomposer/platformdrmgeneric.cpp:28:
external/libdrm/android/gralloc_handle.h:108:9: error: cannot initialize return object of type 'native_handle_t *' (aka 'native_handle *') with an lvalue of type 'struct gralloc_handle_t *'

        return handle;
               ^~~~~~

1 error generated.

This seems to be due to the gralloc_handle_create() definition claiming to return a native_handle_t * type, rather then a gralloc_handle_t *, which is what the code actually returns.

This function isn't actually used in the current drm_hwcomposer, so I'm not totally sure that this fix is correct (rather then returning the gralloc_handle_t's embadedded native_handle_t ptr).

But it seems something like this is needed.

Cc Robert Foss <[email protected]>
Cc Rob Herring <[email protected]>
Cc Sean Paul <[email protected]>
---
 android/gralloc_handle.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
android/gralloc_handle.h +1 -2
index 9cb5a5d..6e925c9 100644
@@ -84,7 +84,7 @@ static inline struct gralloc_handle_t *gralloc_handle(buffer_handle_t handle)
 /**
  * Create a buffer handle.
  */
-static inline native_handle_t *gralloc_handle_create(int32_t width,
+static inline gralloc_handle_t *gralloc_handle_create(int32_t width,
                                                      int32_t height,
                                                      int32_t hal_format,
                                                      int32_t usage)
@@ -107,5 +107,4 @@ static inline native_handle_t *gralloc_handle_create(int32_t width,
 
 	return handle;
 }
-
 #endif
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Hey John,

Quoted 10 lines · John Stultz

In trying to integrate the new gralloc_handle.h with the drm_hwcomposer, I started seeing the following compilation errors:

In file included from external/drm_hwcomposer/platformdrmgeneric.cpp:28:
external/libdrm/android/gralloc_handle.h:108:9: error: cannot initialize return object of type 'native_handle_t *' (aka 'native_handle *') with an lvalue of type 'struct gralloc_handle_t *'

        return handle;
               ^~~~~~

1 error generated.

Quoted 7 lines

This seems to be due to the gralloc_handle_create() definition claiming to return a native_handle_t * type, rather then a gralloc_handle_t *, which is what the code actually returns.

This function isn't actually used in the current drm_hwcomposer, so I'm not totally sure that this fix is correct (rather then returning the gralloc_handle_t's embadedded native_handle_t ptr).

This changed in 009634e49309 ("android: fix gralloc_handle_create() problems") to make the return value from gralloc_handle_create opaque to its user.

Since the only one that would use gralloc_handle_create is the gralloc implementation itself (and libdrm isn't one) and using getters/setters was rejected (IIRC), I would think there is no reason to obscure the return type. Since buffer_handle_t is native_handle_t* is gralloc_handle_t* it's also correct. The alternative to changing the declaration here is returning nhandle instead of handle.

Adding Rob Herring who authored 009634e49309.

Thanks,
Stefan
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v1 1/1
#6 lore raw
In reply to John Stultz

Hey John,

Quoted 43 lines · John Stultz

In trying to integrate the new gralloc_handle.h with the drm_hwcomposer, I started seeing the following compilation errors:

In file included from external/drm_hwcomposer/platformdrmgeneric.cpp:28:
external/libdrm/android/gralloc_handle.h:108:9: error: cannot initialize return object of type 'native_handle_t *' (aka 'native_handle *') with an lvalue of type 'struct gralloc_handle_t *'

         return handle;
                ^~~~~~

1 error generated.

This seems to be due to the gralloc_handle_create() definition claiming to return a native_handle_t * type, rather then a gralloc_handle_t *, which is what the code actually returns.

This function isn't actually used in the current drm_hwcomposer, so I'm not totally sure that this fix is correct (rather then returning the gralloc_handle_t's embadedded native_handle_t ptr).

But it seems something like this is needed.

Cc Robert Foss <[email protected]>
Cc Rob Herring <[email protected]>
Cc Sean Paul <[email protected]>
---
  android/gralloc_handle.h | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
android/gralloc_handle.h +1 -1
index 9cb5a5d..6e925c9 100644
@@ -84,7 +84,7 @@ static inline struct gralloc_handle_t *gralloc_handle(buffer_handle_t handle)
  /**
   * Create a buffer handle.
   */
-static inline native_handle_t *gralloc_handle_create(int32_t width,
+static inline gralloc_handle_t *gralloc_handle_create(int32_t width,
                                                       int32_t height,
                                                       int32_t hal_format,
                                                       int32_t usage)

android/gralloc_handle.h static inline native_handle_t *gralloc_handle_create(int32_t width, · line 110

Quoted 5 lines
android/gralloc_handle.h +0 -1
@@ -107,5 +107,4 @@ static inline native_handle_t *gralloc_handle_create(int32_t width,
 
  	return handle;
  }
-
  #endif

The gralloc_handle_t regturn type seems to be the correct one to me.

This patch is:

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
In reply to Stefan Schake
Quoted 12 lines · Stefan Schake

Hey John,

Quoted 9 lines · John Stultz

In trying to integrate the new gralloc_handle.h with the drm_hwcomposer, I started seeing the following compilation errors:

In file included from external/drm_hwcomposer/platformdrmgeneric.cpp:28:
external/libdrm/android/gralloc_handle.h:108:9: error: cannot initialize return object of type 'native_handle_t *' (aka 'native_handle *') with an lvalue of type 'struct gralloc_handle_t *'

        return handle;
               ^~~~~~

1 error generated.

Somehow this is not throwing an error for me...

Quoted 8 lines
Quoted 7 lines

This seems to be due to the gralloc_handle_create() definition claiming to return a native_handle_t * type, rather then a gralloc_handle_t *, which is what the code actually returns.

This function isn't actually used in the current drm_hwcomposer, so I'm not totally sure that this fix is correct (rather then returning the gralloc_handle_t's embadedded native_handle_t ptr).

Quoted 6 lines

This changed in 009634e49309 ("android: fix gralloc_handle_create() problems") to make the return value from gralloc_handle_create opaque to its user.

Since the only one that would use gralloc_handle_create is the gralloc implementation itself (and libdrm isn't one) and using getters/setters was rejected (IIRC), I would think there is no reason to obscure the return type.

Not rejected, just not required at the start and not in a lib. And I am working on adding helper functions and I'm using buffer_handle_t everywhere.

Quoted 3 lines

Since buffer_handle_t is native_handle_t* is gralloc_handle_t* it's also correct. The alternative to changing the declaration here is returning nhandle instead of handle.

BTW, returning buffer_handle_t doesn't work though because it is const.

Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 8 lines · Rob Herring
Quoted 7 lines · Stefan Schake

Hey John,

Quoted 4 lines · John Stultz

In trying to integrate the new gralloc_handle.h with the drm_hwcomposer, I started seeing the following compilation errors:

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

In file included from external/drm_hwcomposer/platformdrmgeneric.cpp:28:
external/libdrm/android/gralloc_handle.h:108:9: error: cannot initialize return object of type 'native_handle_t *' (aka 'native_handle *') with an lvalue of type 'struct gralloc_handle_t *'

        return handle;
               ^~~~~~

1 error generated.

Somehow this is not throwing an error for me...

NM. I have it fixed in a subsequent change in my tree...
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

2018-03-28 23:22 GMT+08:00 Rob Herring <[email protected]>:

Quoted 15 lines · Rob Herring
Quoted 14 lines · Stefan Schake
Quoted 12 lines

Hey John,

Quoted 9 lines · John Stultz

In trying to integrate the new gralloc_handle.h with the drm_hwcomposer, I started seeing the following compilation errors:

In file included from external/drm_hwcomposer/platformdrmgeneric.cpp:28:
external/libdrm/android/gralloc_handle.h:108:9: error: cannot initialize return object of type 'native_handle_t *' (aka 'native_handle *') with an lvalue of type 'struct gralloc_handle_t *'

        return handle;
               ^~~~~~

1 error generated.

Quoted 3 lines
Quoted 1 line

Somehow this is not throwing an error for me...

NM. I have it fixed in a subsequent change in my tree...

Hi,
I saw the same error after updated to libdrm master branch. Could John's fix be merged?
Or maybe Rob has a better fix?

Signature · 7 lines
Chih-Wei
Android-x86 project
http://www.android-x86.org
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Hey Chih-Wei,

Thanks for the poke, the patch has been pushed now.

Rob.

Quoted 16 lines · Chih-Wei Huang

2018-03-28 23:22 GMT+08:00 Rob Herring <[email protected]>:

Quoted 15 lines · Rob Herring
Quoted 14 lines · Stefan Schake
Quoted 12 lines

Hey John,

Quoted 9 lines · John Stultz

In trying to integrate the new gralloc_handle.h with the drm_hwcomposer, I started seeing the following compilation errors:

In file included from external/drm_hwcomposer/platformdrmgeneric.cpp:28:
external/libdrm/android/gralloc_handle.h:108:9: error: cannot initialize return object of type 'native_handle_t *' (aka 'native_handle *') with an lvalue of type 'struct gralloc_handle_t *'

         return handle;
                ^~~~~~

1 error generated.

Quoted 10 lines
Quoted 3 lines
Quoted 1 line

Somehow this is not throwing an error for me...

NM. I have it fixed in a subsequent change in my tree...

Hi,
I saw the same error after updated to libdrm master branch. Could John's fix be merged?
Or maybe Rob has a better fix?

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel