From 0ac1e05f6567ef3b0cf1e6afe8840649eb9e3c19 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Wed, 18 Jun 2025 11:32:36 -0700 Subject: [PATCH] u_gralloc/mapper5: fill u_gralloc_buffer_color_info properly Clients are expecting the color info to be fully filled when the api exists. Give proper defaults for the metadata to stay aligned with legacy backends. Fixes: 122fd46b150 ("Android15 support gralloc IMapper5") Reviewed-by: Roman Stratiienko Part-of: --- src/util/u_gralloc/u_gralloc_imapper5_api.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/util/u_gralloc/u_gralloc_imapper5_api.cpp b/src/util/u_gralloc/u_gralloc_imapper5_api.cpp index a7539ab3d7f..ae6604bd506 100644 --- a/src/util/u_gralloc/u_gralloc_imapper5_api.cpp +++ b/src/util/u_gralloc/u_gralloc_imapper5_api.cpp @@ -116,26 +116,27 @@ mapper5_get_buffer_color_info(struct u_gralloc *gralloc, if (error != OK) return -EINVAL; + /* default to __DRI_YUV_COLOR_SPACE_ITU_REC601 */ Dataspace standard = (Dataspace)((int)dataspace & (uint32_t)Dataspace::STANDARD_MASK); switch (standard) { case Dataspace::STANDARD_BT709: out->yuv_color_space = __DRI_YUV_COLOR_SPACE_ITU_REC709; break; - case Dataspace::STANDARD_BT601_625: - case Dataspace::STANDARD_BT601_625_UNADJUSTED: - case Dataspace::STANDARD_BT601_525: - case Dataspace::STANDARD_BT601_525_UNADJUSTED: - out->yuv_color_space = __DRI_YUV_COLOR_SPACE_ITU_REC601; - break; case Dataspace::STANDARD_BT2020: case Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE: out->yuv_color_space = __DRI_YUV_COLOR_SPACE_ITU_REC2020; break; + case Dataspace::STANDARD_BT601_625: + case Dataspace::STANDARD_BT601_625_UNADJUSTED: + case Dataspace::STANDARD_BT601_525: + case Dataspace::STANDARD_BT601_525_UNADJUSTED: default: + out->yuv_color_space = __DRI_YUV_COLOR_SPACE_ITU_REC601; break; } + /* default to __DRI_YUV_NARROW_RANGE */ Dataspace range = (Dataspace)((int)dataspace & (uint32_t)Dataspace::RANGE_MASK); switch (range) { @@ -143,17 +144,13 @@ mapper5_get_buffer_color_info(struct u_gralloc *gralloc, out->sample_range = __DRI_YUV_FULL_RANGE; break; case Dataspace::RANGE_LIMITED: - out->sample_range = __DRI_YUV_NARROW_RANGE; - break; default: + out->sample_range = __DRI_YUV_NARROW_RANGE; break; } + /* default to __DRI_YUV_CHROMA_SITING_0_5 */ switch (chroma_siting) { - case ChromaSiting::SITED_INTERSTITIAL: - out->horizontal_siting = __DRI_YUV_CHROMA_SITING_0_5; - out->vertical_siting = __DRI_YUV_CHROMA_SITING_0_5; - break; case ChromaSiting::COSITED_HORIZONTAL: out->horizontal_siting = __DRI_YUV_CHROMA_SITING_0; out->vertical_siting = __DRI_YUV_CHROMA_SITING_0_5; @@ -166,7 +163,10 @@ mapper5_get_buffer_color_info(struct u_gralloc *gralloc, out->horizontal_siting = __DRI_YUV_CHROMA_SITING_0; out->vertical_siting = __DRI_YUV_CHROMA_SITING_0; break; + case ChromaSiting::SITED_INTERSTITIAL: default: + out->horizontal_siting = __DRI_YUV_CHROMA_SITING_0_5; + out->vertical_siting = __DRI_YUV_CHROMA_SITING_0_5; break; }