Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit 5421fee

Browse files
ZhuChenyanXsysopenci
authored andcommitted
Add legacy dataspace value supporting
In case of legacy dataspace value is passed down by framework/av/media code. Tracked-On: OAM-130969 Signed-off-by: ZhuChenyanX <zhucx@intel.com>
1 parent 5c797f2 commit 5421fee

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

src/util/u_gralloc/u_gralloc_imapper5_api.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <dlfcn.h>
2222
#include <gralloctypes/Gralloc4.h>
2323
#include <hidl/HidlSupport.h>
24+
#include <system/window.h>
2425
#include <ui/FatVector.h>
2526
#include <vndksupport/linker.h>
2627

@@ -317,6 +318,34 @@ mapper_get_buffer_basic_info(struct u_gralloc *gralloc,
317318
return error;
318319
}
319320

321+
static __inline__ Dataspace
322+
_legacy_dataspace_to_v0(Dataspace ds)
323+
{
324+
switch((android_dataspace_t)ds) {
325+
case HAL_DATASPACE_SRGB:
326+
ds = Dataspace::SRGB;
327+
break;
328+
case HAL_DATASPACE_BT709:
329+
ds = Dataspace::BT709;
330+
break;
331+
case HAL_DATASPACE_SRGB_LINEAR:
332+
ds = Dataspace::SRGB_LINEAR;
333+
break;
334+
case HAL_DATASPACE_BT601_525:
335+
ds = Dataspace::BT601_525;
336+
break;
337+
case HAL_DATASPACE_BT601_625:
338+
ds = Dataspace::BT601_625;
339+
break;
340+
case HAL_DATASPACE_JFIF:
341+
ds = Dataspace::JFIF;
342+
break;
343+
default:
344+
break;
345+
}
346+
return ds;
347+
}
348+
320349
static int
321350
mapper_get_buffer_color_info(struct u_gralloc *gralloc,
322351
struct u_gralloc_buffer_handle *hnd,
@@ -375,6 +404,14 @@ mapper_get_buffer_color_info(struct u_gralloc *gralloc,
375404
if (value.has_value()) {
376405
Dataspace dataspace = static_cast<Dataspace>(*value);
377406

407+
// The dataspace value passed down might be a legacy value,
408+
// which does not comply with the pattern:
409+
// (Standard << 16) |(Transfer << 22) | (Range << 27)
410+
// Just convert the legacy value to v0 value,
411+
// according to standard “hardware/interfaces/graphics/common/1.0/types.hal”.
412+
if ((int)dataspace & 0xffff)
413+
dataspace = _legacy_dataspace_to_v0(dataspace);
414+
378415
Dataspace standard =
379416
(Dataspace)((int)dataspace & (uint32_t)Dataspace::STANDARD_MASK);
380417
switch (standard) {

0 commit comments

Comments
 (0)