display: Set and handle default csc as BT709
- Some clients don't set the csc for a layer and as a result
HWC will error out. Avoid this by setting the default csc as
BT709 in gralloc for RGB buffers.
- HWC will default to BT709 if clients have not set.
Change-Id: I6f2e0f5bf39d0e06450d50f9c7da6857aaff8b8f
Crs-fixed: 2218048
diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp
index 6b6ec87..42ac8ed 100644
--- a/gralloc/gr_buf_mgr.cpp
+++ b/gralloc/gr_buf_mgr.cpp
@@ -354,12 +354,10 @@
hnd->base = 0;
hnd->base_metadata = 0;
hnd->layer_count = layer_count;
+ // set default csc as 709, but for video(yuv) its 601L
+ ColorSpace_t colorSpace = (buffer_type == BUFFER_TYPE_VIDEO) ? ITU_R_601 : ITU_R_709;
+ setMetaData(hnd, UPDATE_COLOR_SPACE, reinterpret_cast<void *>(&colorSpace));
- if (buffer_type == BUFFER_TYPE_VIDEO) {
- // set default csc to 601L for only video buffers
- ColorSpace_t colorSpace = ITU_R_601;
- setMetaData(hnd, UPDATE_COLOR_SPACE, reinterpret_cast<void *>(&colorSpace));
- }
*handle = hnd;
RegisterHandleLocked(hnd, data.ion_handle, e_data.ion_handle);
ALOGD_IF(DEBUG, "Allocated buffer handle: %p id: %" PRIu64, hnd, hnd->id);
diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp
index 96e7499..070f235 100644
--- a/sdm/libs/hwc2/hwc_layers.cpp
+++ b/sdm/libs/hwc2/hwc_layers.cpp
@@ -41,24 +41,22 @@
}
switch (csc) {
- case ITU_R_601:
- case ITU_R_601_FR:
- // video and display driver uses 601_525
- color_metadata->colorPrimaries = ColorPrimaries_BT601_6_525;
- break;
- case ITU_R_709:
- color_metadata->colorPrimaries = ColorPrimaries_BT709_5;
- break;
- case ITU_R_2020:
- case ITU_R_2020_FR:
- color_metadata->colorPrimaries = ColorPrimaries_BT2020;
- break;
- default:
- DLOGE("Unsupported CSC: %d", csc);
- return kErrorNotSupported;
+ case ITU_R_601:
+ case ITU_R_601_FR:
+ // video and display driver uses 601_525
+ color_metadata->colorPrimaries = ColorPrimaries_BT601_6_525;
+ break;
+ case ITU_R_709:
+ color_metadata->colorPrimaries = ColorPrimaries_BT709_5;
+ break;
+ case ITU_R_2020:
+ case ITU_R_2020_FR:
+ color_metadata->colorPrimaries = ColorPrimaries_BT2020;
+ break;
+ default:
+ DLOGE("Unsupported CSC: %d", csc);
+ return kErrorNotSupported;
}
- } else {
- return kErrorNotSupported;
}
}