diff --git a/src/util/u_gralloc/u_gralloc_imapper4_api.cpp b/src/util/u_gralloc/u_gralloc_imapper4_api.cpp index dc1980f6a99..7e6726bfb31 100644 --- a/src/util/u_gralloc/u_gralloc_imapper4_api.cpp +++ b/src/util/u_gralloc/u_gralloc_imapper4_api.cpp @@ -209,6 +209,34 @@ mapper4_get_buffer_basic_info(struct u_gralloc *gralloc, return 0; } +static __inline__ Dataspace +_legacy_dataspace_to_v0(Dataspace ds) +{ + switch((android_dataspace_t)ds) { + case HAL_DATASPACE_SRGB: + ds = Dataspace::SRGB; + break; + case HAL_DATASPACE_BT709: + ds = Dataspace::BT709; + break; + case HAL_DATASPACE_SRGB_LINEAR: + ds = Dataspace::SRGB_LINEAR; + break; + case HAL_DATASPACE_BT601_525: + ds = Dataspace::BT601_525; + break; + case HAL_DATASPACE_BT601_625: + ds = Dataspace::BT601_625; + break; + case HAL_DATASPACE_JFIF: + ds = Dataspace::JFIF; + break; + default: + break; + } + return ds; +} + static int mapper4_get_buffer_color_info(struct u_gralloc *gralloc, struct u_gralloc_buffer_handle *hnd, @@ -261,6 +289,8 @@ mapper4_get_buffer_color_info(struct u_gralloc *gralloc, android::gralloc4::decodeDataspace(encoded_dataspace, &dataspace); if (status != android::OK) return -EINVAL; + if ((int)dataspace & 0xffff) + dataspace = _legacy_dataspace_to_v0(dataspace); Dataspace standard = (Dataspace)((int)dataspace & (uint32_t)Dataspace::STANDARD_MASK);