From 4b68ed990bd0e89bc226a2bd40865adbe06a4483 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Wed, 18 Jun 2025 12:13:20 -0700 Subject: [PATCH] u_gralloc: assign default u_gralloc_buffer_color_info Gralloc is the central piece to align defaults and expectations across different APIs. Doing so simplifies client side handling. To be noted, midpoint chroma location is preferred as the default to skip the chroma lowering pass. The same has been suggested by all Vulkan drivers with AHB implemented and practiced for years under venus. Reviewed-by: Roman Stratiienko Part-of: --- src/util/u_gralloc/u_gralloc.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/util/u_gralloc/u_gralloc.c b/src/util/u_gralloc/u_gralloc.c index b92057c515d..960986fb89e 100644 --- a/src/util/u_gralloc/u_gralloc.c +++ b/src/util/u_gralloc/u_gralloc.c @@ -126,18 +126,15 @@ u_gralloc_get_buffer_color_info(struct u_gralloc *gralloc, struct u_gralloc_buffer_handle *hnd, struct u_gralloc_buffer_color_info *out) { - struct u_gralloc_buffer_color_info info = {0}; - int ret; + if (gralloc->ops.get_buffer_color_info) + return gralloc->ops.get_buffer_color_info(gralloc, hnd, out); - if (!gralloc->ops.get_buffer_color_info) - return -ENOTSUP; - - ret = gralloc->ops.get_buffer_color_info(gralloc, hnd, &info); - - if (ret) - return ret; - - *out = info; + *out = (struct u_gralloc_buffer_color_info){ + .yuv_color_space = __DRI_YUV_COLOR_SPACE_ITU_REC601, + .sample_range = __DRI_YUV_NARROW_RANGE, + .horizontal_siting = __DRI_YUV_CHROMA_SITING_0_5, + .vertical_siting = __DRI_YUV_CHROMA_SITING_0_5, + }; return 0; }