From 8f513813b1774f8f231f26fc566d3ade8e33df9f Mon Sep 17 00:00:00 2001 From: Roman Stratiienko Date: Sat, 9 Sep 2023 13:57:29 +0300 Subject: [PATCH] u_gralloc: Add a function that returns gralloc type This is needed by some drivers to reject the fallback gralloc. Signed-off-by: Roman Stratiienko Reviewed-by: Chia-I Wu Part-of: --- src/util/u_gralloc/u_gralloc.c | 7 +++++++ src/util/u_gralloc/u_gralloc.h | 4 ++-- src/util/u_gralloc/u_gralloc_internal.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/util/u_gralloc/u_gralloc.c b/src/util/u_gralloc/u_gralloc.c index f070453daaf..c2c8ed41f25 100644 --- a/src/util/u_gralloc/u_gralloc.c +++ b/src/util/u_gralloc/u_gralloc.c @@ -58,6 +58,7 @@ u_gralloc_create(enum u_gralloc_type type) assert(u_gralloc_cache[type].u_gralloc->ops.get_buffer_basic_info); assert(u_gralloc_cache[type].u_gralloc->ops.destroy); + u_gralloc_cache[type].u_gralloc->type = u_grallocs[i].type; u_gralloc_cache[type].refcount = 1; out_gralloc = u_gralloc_cache[type].u_gralloc; @@ -148,3 +149,9 @@ u_gralloc_get_front_rendering_usage(struct u_gralloc *gralloc, return gralloc->ops.get_front_rendering_usage(gralloc, out_usage); } + +int +u_gralloc_get_type(struct u_gralloc *gralloc) +{ + return gralloc->type; +} diff --git a/src/util/u_gralloc/u_gralloc.h b/src/util/u_gralloc/u_gralloc.h index e1b04e5a2fa..35eb8ffce39 100644 --- a/src/util/u_gralloc/u_gralloc.h +++ b/src/util/u_gralloc/u_gralloc.h @@ -49,9 +49,7 @@ struct u_gralloc_buffer_color_info { enum u_gralloc_type { U_GRALLOC_TYPE_AUTO, -#ifdef USE_IMAPPER4_METADATA_API U_GRALLOC_TYPE_GRALLOC4, -#endif U_GRALLOC_TYPE_CROS, U_GRALLOC_TYPE_FALLBACK, U_GRALLOC_TYPE_COUNT, @@ -74,6 +72,8 @@ int u_gralloc_get_buffer_color_info( int u_gralloc_get_front_rendering_usage(struct u_gralloc *gralloc, uint64_t *out_usage); +int u_gralloc_get_type(struct u_gralloc *gralloc); + #ifdef __cplusplus } #endif diff --git a/src/util/u_gralloc/u_gralloc_internal.h b/src/util/u_gralloc/u_gralloc_internal.h index a837d2ea33d..906253fd482 100644 --- a/src/util/u_gralloc/u_gralloc_internal.h +++ b/src/util/u_gralloc/u_gralloc_internal.h @@ -28,6 +28,7 @@ struct u_gralloc_ops { struct u_gralloc { struct u_gralloc_ops ops; + int type; }; extern struct u_gralloc *u_gralloc_cros_api_create(void);