From 057462200343d4329a8e66425910648c8b373f15 Mon Sep 17 00:00:00 2001 From: "Arun Kumar K.R" Date: Wed, 4 Apr 2018 10:45:58 +0530 Subject: [PATCH] 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 --- gralloc/gr_buf_mgr.cpp | 8 +++----- sdm/libs/hwc2/hwc_layers.cpp | 32 +++++++++++++++----------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/gralloc/gr_buf_mgr.cpp b/gralloc/gr_buf_mgr.cpp index 6b6ec874a..42ac8edeb 100644 --- a/gralloc/gr_buf_mgr.cpp +++ b/gralloc/gr_buf_mgr.cpp @@ -354,12 +354,10 @@ Error BufferManager::AllocateBuffer(const BufferDescriptor &descriptor, buffer_h 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(&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(&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 96e74990f..070f23599 100644 --- a/sdm/libs/hwc2/hwc_layers.cpp +++ b/sdm/libs/hwc2/hwc_layers.cpp @@ -41,24 +41,22 @@ DisplayError SetCSC(const private_handle_t *pvt_handle, ColorMetaData *color_met } 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; } }