Skip to content

Commit

Permalink
Add legacy dataspace value supporting
Browse files Browse the repository at this point in the history
In case of legacy dataspace value is passed down by
framework/av/media code.

Tracked-On: OAM-122156
Signed-off-by: ZhuChenyanX <[email protected]>
  • Loading branch information
ZhuChenyanX authored and celadon committed Jul 23, 2024
1 parent 7a93157 commit 077b993
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/util/u_gralloc/u_gralloc_imapper4_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -262,6 +290,14 @@ mapper4_get_buffer_color_info(struct u_gralloc *gralloc,
if (status != android::OK)
return -EINVAL;

// The dataspace value passed down might be a legacy value,
// which does not comply with the pattern:
// (Standard << 16) |(Transfer << 22) | (Range << 27)
// Just convert the legacy value to v0 value,
// according to standard “hardware/interfaces/graphics/common/1.0/types.hal”.
if ((int)dataspace & 0xffff)
dataspace = _legacy_dataspace_to_v0(dataspace);

Dataspace standard =
(Dataspace)((int)dataspace & (uint32_t)Dataspace::STANDARD_MASK);
switch (standard) {
Expand Down

0 comments on commit 077b993

Please sign in to comment.