diff options
author | Arun Kumar K.R <akumarkr@codeaurora.org> | 2016-10-03 21:38:23 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-11-14 02:16:36 -0800 |
commit | b2771bff77d962ef662ee18217af8693bc760e0c (patch) | |
tree | 80689fb7f0fd16ca4a11cdf2423c6d89887cfb3e | |
parent | 8b3dddc082fffaa0906e625b8abccf4a7fe80767 (diff) | |
download | android_hardware_qcom_sdm710_display-b2771bff77d962ef662ee18217af8693bc760e0c.tar.gz android_hardware_qcom_sdm710_display-b2771bff77d962ef662ee18217af8693bc760e0c.tar.bz2 android_hardware_qcom_sdm710_display-b2771bff77d962ef662ee18217af8693bc760e0c.zip |
display: Add color Metadata
- Add color aspects and HDR10 related static metadata
which will be used in the existing metadata structure.
- Clients can use COLOR_METADATA to update the CSC
information
- UPDATE_COLOR_SPACE is legacy and will be used when
COLOR_METADATA is not set.
- Update gralloc to return color space when set from
COLOR_METADATA
- Gaurd the usage with USE_COLOR_METADATA for cobalt.
Change-Id: I460accf6cd2bb7a305c7e93284955e566a5b7532
Crs-fixed: 1074172
-rw-r--r-- | Android.mk | 2 | ||||
-rw-r--r-- | common.mk | 5 | ||||
-rw-r--r-- | include/Android.mk | 9 | ||||
-rw-r--r-- | include/color_metadata.h | 180 | ||||
-rw-r--r-- | libgralloc/mapper.cpp | 25 | ||||
-rw-r--r-- | libgralloc1/gr_buf_mgr.cpp | 22 | ||||
-rw-r--r-- | libqdutils/qdMetaData.cpp | 10 | ||||
-rw-r--r-- | libqdutils/qdMetaData.h | 11 |
8 files changed, 260 insertions, 4 deletions
@@ -1,5 +1,5 @@ sdm-libs := sdm/libs -display-hals := libqservice libqdutils $(sdm-libs)/utils $(sdm-libs)/core +display-hals := include libqservice libqdutils $(sdm-libs)/utils $(sdm-libs)/core ifneq ($(TARGET_IS_HEADLESS), true) display-hals += libcopybit liblight libmemtrack hdmi_cec \ @@ -5,6 +5,10 @@ display_top := $(call my-dir) common_flags := -DDEBUG_CALC_FPS -Wno-missing-field-initializers common_flags += -Wconversion -Wall -Werror -std=c++11 +ifeq ($(call is-board-platform-in-list, msmcobalt msm8998), true) +common_flags += -DUSE_COLOR_METADATA +endif + use_hwc2 := false ifeq ($(TARGET_USES_HWC2), true) use_hwc2 := true @@ -17,6 +21,7 @@ ifneq ($(TARGET_IS_HEADLESS), true) common_includes += $(display_top)/libcopybit endif +common_includes += $(display_top)/include common_includes += $(display_top)/sdm/include common_header_export_path := qcom/display diff --git a/include/Android.mk b/include/Android.mk new file mode 100644 index 00000000..4d0d9f76 --- /dev/null +++ b/include/Android.mk @@ -0,0 +1,9 @@ +LOCAL_PATH:= $(call my-dir) +include $(LOCAL_PATH)/../common.mk +include $(CLEAR_VARS) + +LOCAL_COPY_HEADERS_TO := $(common_header_export_path) +LOCAL_COPY_HEADERS := color_metadata.h + +include $(BUILD_COPY_HEADERS) + diff --git a/include/color_metadata.h b/include/color_metadata.h new file mode 100644 index 00000000..328cb0e0 --- /dev/null +++ b/include/color_metadata.h @@ -0,0 +1,180 @@ +/* +* Copyright (c) 2016, The Linux Foundation. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are permitted +* provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright notice, this list of +* conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright notice, this list of +* conditions and the following disclaimer in the documentation and/or other materials provided +* with the distribution. +* * Neither the name of The Linux Foundation nor the names of its contributors may be used to +* endorse or promote products derived from this software without specific prior written +* permission. +* +* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef __COLOR_METADATA_H__ +#define __COLOR_METADATA_H__ + +#ifdef __cplusplus +extern "C" { +#else +#include <stdbool.h> +#endif + +typedef enum ColorRange { + Range_Limited = 0, + Range_Full = 1, + Range_Max = 0xff, +} ColorRange; + +// The following values matches the HEVC spec +typedef enum ColorPrimaries { + // Unused = 0; + ColorPrimaries_BT709_5 = 1, // ITU-R BT.709-5 or equivalent + /* Unspecified = 2, Reserved = 3*/ + ColorPrimaries_BT470_6M = 4, // ITU-R BT.470-6 System M or equivalent + ColorPrimaries_BT601_6_625 = 5, // ITU-R BT.601-6 625 or equivalent + ColorPrimaries_BT601_6_525 = 6, // ITU-R BT.601-6 525 or equivalent + ColorPrimaries_SMPTE_240M = 7, // SMPTE_240M + ColorPrimaries_GenericFilm = 8, // Generic Film + ColorPrimaries_BT2020 = 9, // ITU-R BT.2020 or equivalent + ColorPrimaries_SMPTE_ST428 = 10, // SMPTE_240M + ColorPrimaries_AdobeRGB = 11, + ColorPrimaries_DCIP3 = 12, + ColorPrimaries_Max = 0xff, +} ColorPrimaries; + +typedef enum GammaTransfer { + // Unused = 0; + Transfer_sRGB = 1, // ITR-BT.709-5 + /* Unspecified = 2, Reserved = 3 */ + Transfer_Gamma2_2 = 4, + Transfer_Gamma2_8 = 5, + Transfer_SMPTE_170M = 6, // BT.601-6 525 or 625 + Transfer_SMPTE_240M = 7, // SMPTE_240M + Transfer_Linear = 8, + Transfer_HLG = 9, + Transfer_XvYCC = 11, // IEC 61966-2-4 + Transfer_BT1361 = 12, // Rec.ITU-R BT.1361 extended gamut + Transfer_SMPTE_ST2084 = 16, // 2084 + // transfers unlikely to be required by Android + Transfer_ST_428 = 17, // SMPTE ST 428-1 + Transfer_Max = 0xff, +} GammaTransfer; + +typedef enum MatrixCoEfficients { + MatrixCoEff_Identity = 0, + MatrixCoEff_BT709_5 = 1, + /* Unspecified = 2, Reserved = 3 */ + MatrixCoEff_BT601_6_625 = 5, + MatrixCoEff_BT601_6_525 = 6, + MatrixCoEff_SMPTE240M = 7, // used with 601_525_Unadjusted + MatrixCoEff_BT2020 = 9, + MatrixCoEff_BT2020Constant = 10, + MatrixCoEff_BT601_6_Unadjusted = 11, // Used with BT601_625(KR=0.222, KB=0.071) + MatrixCoEff_DCIP3 = 12, + MatrixCoEff_Max = 0xff, +} MatrixCoEfficients; + +typedef struct Primaries { + uint32_t rgbPrimaries[3][2]; // unit 1/50000; + uint32_t whitePoint[2]; // unit 1/50000; +} Primaries; + +typedef struct MasteringDisplay { + bool colorVolumeSEIEnabled; + Primaries primaries; + uint32_t maxDisplayLuminance; // unit: cd/m^2. + uint32_t minDisplayLuminance; // unit: 1/10000 cd/m^2. +} MasteringDisplay; + +typedef struct ContentLightLevel { + bool lightLevelSEIEnabled; + uint32_t maxContentLightLevel; // unit: cd/m^2. + uint32_t minPicAverageLightLevel; // unit: 1/10000 cd/m^2. +} ContentLightLevel; + +typedef struct ColorRemappingInfo { + bool criEnabled; + uint32_t crId; + uint32_t crCancelFlag; + uint32_t crPersistenceFlag; + uint32_t crVideoSignalInfoPresentFlag; + uint32_t crRange; + ColorPrimaries crPrimaries; + GammaTransfer crTransferFunction; + MatrixCoEfficients crMatrixCoefficients; + uint32_t crInputBitDepth; + uint32_t crOutputBitDepth; + uint32_t crPreLutNumValMinusOne[3]; + uint32_t crPreLutCodedValue[3*33]; + uint32_t crPreLutTargetValue[3*33]; + uint32_t crMatrixPresentFlag; + uint32_t crLog2MatrixDenom; + int32_t crCoefficients[3*3]; + uint32_t crPostLutNumValMinusOne[3]; + uint32_t crPostLutCodedValue[3*33]; + uint32_t crPostLutTargetValue[3*33]; +} ColorRemappingInfo; + +typedef struct ColorMetaData { + // Default values based on sRGB, needs to be overridden in gralloc + // based on the format and size. + ColorPrimaries colorPrimaries; + ColorRange range; + GammaTransfer transfer; + MatrixCoEfficients matrixCoefficients; + + MasteringDisplay masteringDisplayInfo; + ContentLightLevel contentLightLevel; + ColorRemappingInfo cRI; +} ColorMetaData; + +typedef struct Color10Bit { + uint32_t R: 10; + uint32_t G: 10; + uint32_t B: 10; + uint32_t A: 2; +} Color10Bit; + +typedef struct Lut3d { + uint16_t dim; // dimension of each side of LUT cube (ex: 13, 17)in lutEntries + uint16_t gridSize; // number of elements in the gridEntries + /* Matrix ordering convension + for (b = 0; b < dim; b++) { + for (g = 0; g < dim; g++) { + for (r = 0; r < dim; r++) { + read/write [mR mG mB] associated w/ 3DLUT[r][g][b] to/from file + } + } + } */ + Color10Bit *lutEntries; + bool validLutEntries; // Indicates if entries are valid and can be used. + /* + The grid is a 1D LUT for each of the R,G,B channels that can be + used to apply an independent nonlinear transformation to each + channel before it is used as a coordinate for addressing + the uniform 3D LUT. This effectively creates a non-uniformly + sampled 3D LUT. This is useful for having independent control + of the sampling grid density along each dimension for greater + precision in spite of having a relatively small number of samples.i + */ + Color10Bit *gridEntries; + bool validGridEntries; // Indicates if entries are valid and can be used. +} Lut3d; + +#ifdef __cplusplus +} +#endif + +#endif // __COLOR_METADATA_H__ diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp index 15bb71a5..132c768a 100644 --- a/libgralloc/mapper.cpp +++ b/libgralloc/mapper.cpp @@ -412,7 +412,30 @@ int gralloc_perform(struct gralloc_module_t const* module, return res; } MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; - if(metadata && metadata->operation & UPDATE_COLOR_SPACE) { + if (!metadata) { + break; +#ifdef USE_COLOR_METADATA + } else if (metadata->operation & COLOR_METADATA) { + ColorMetaData *colorMetadata = &metadata->color; + res = 0; + switch (colorMetadata->colorPrimaries) { + case ColorPrimaries_BT709_5: + *color_space = HAL_CSC_ITU_R_709; + break; + case ColorPrimaries_BT601_6_525: + *color_space = ((colorMetadata->range) ? + HAL_CSC_ITU_R_601_FR : HAL_CSC_ITU_R_601); + break; + case ColorPrimaries_BT2020: + *color_space = (colorMetadata->range) ? + HAL_CSC_ITU_R_2020_FR : HAL_CSC_ITU_R_2020; + break; + default: + res = -EINVAL; + break; + } +#endif + } else if(metadata->operation & UPDATE_COLOR_SPACE) { *color_space = metadata->colorSpace; res = 0; } diff --git a/libgralloc1/gr_buf_mgr.cpp b/libgralloc1/gr_buf_mgr.cpp index 6c363455..96505832 100644 --- a/libgralloc1/gr_buf_mgr.cpp +++ b/libgralloc1/gr_buf_mgr.cpp @@ -588,7 +588,27 @@ gralloc1_error_t BufferManager::Perform(int operation, va_list args) { return GRALLOC1_ERROR_BAD_HANDLE; } MetaData_t *metadata = reinterpret_cast<MetaData_t *>(hnd->base_metadata); - if (metadata && metadata->operation & UPDATE_COLOR_SPACE) { + if (!metadata) { + return GRALLOC1_ERROR_BAD_HANDLE; +#ifdef USE_COLOR_METADATA + } else if (metadata->operation & COLOR_METADATA) { + ColorMetaData *colorMetadata = &metadata->color; + switch (colorMetadata->colorPrimaries) { + case ColorPrimaries_BT709_5: + *color_space = HAL_CSC_ITU_R_709; + break; + case ColorPrimaries_BT601_6_525: + *color_space = ((colorMetadata->range) ? HAL_CSC_ITU_R_601_FR : HAL_CSC_ITU_R_601); + break; + case ColorPrimaries_BT2020: + *color_space = (colorMetadata->range) ? HAL_CSC_ITU_R_2020_FR : HAL_CSC_ITU_R_2020; + break; + default: + ALOGE("Unknown Color Space = %d", colorMetadata->colorPrimaries); + break; + } +#endif + } else if (metadata->operation & UPDATE_COLOR_SPACE) { *color_space = metadata->colorSpace; } } break; diff --git a/libqdutils/qdMetaData.cpp b/libqdutils/qdMetaData.cpp index f62653ab..c888baaf 100644 --- a/libqdutils/qdMetaData.cpp +++ b/libqdutils/qdMetaData.cpp @@ -95,6 +95,11 @@ int setMetaData(private_handle_t *handle, DispParamType paramType, case SET_VT_TIMESTAMP: data->vtTimeStamp = *((uint64_t *)param); break; +#ifdef USE_COLOR_METADATA + case COLOR_METADATA: + data->color = *((ColorMetaData *)param); +#endif + break; default: ALOGE("Unknown paramType %d", paramType); break; @@ -196,6 +201,11 @@ int getMetaData(private_handle_t *handle, DispFetchParamType paramType, case GET_VT_TIMESTAMP: *((uint64_t *)param) = data->vtTimeStamp; break; +#ifdef USE_COLOR_METADATA + case GET_COLOR_METADATA: + *((ColorMetaData *)param) = data->color; +#endif + break; default: ALOGE("Unknown paramType %d", paramType); break; diff --git a/libqdutils/qdMetaData.h b/libqdutils/qdMetaData.h index 2b0b8c61..a0ac324d 100644 --- a/libqdutils/qdMetaData.h +++ b/libqdutils/qdMetaData.h @@ -30,6 +30,10 @@ #ifndef _QDMETADATA_H #define _QDMETADATA_H +#ifdef USE_COLOR_METADATA +#include <color_metadata.h> +#endif + #ifdef __cplusplus extern "C" { #endif @@ -91,11 +95,15 @@ struct MetaData_t { /* Set by camera to program the VT Timestamp */ uint64_t vtTimeStamp; +#ifdef USE_COLOR_METADATA + /* Color Aspects + HDR info */ + ColorMetaData color; +#endif }; enum DispParamType { SET_VT_TIMESTAMP = 0x0001, - UNUSED1 = 0x0002, + COLOR_METADATA = 0x0002, PP_PARAM_INTERLACED = 0x0004, UNUSED2 = 0x0008, UNUSED3 = 0x0010, @@ -114,6 +122,7 @@ enum DispParamType { enum DispFetchParamType { GET_VT_TIMESTAMP = 0x0001, + GET_COLOR_METADATA = 0x0002, GET_PP_PARAM_INTERLACED = 0x0004, GET_BUFFER_GEOMETRY = 0x0080, GET_REFRESH_RATE = 0x0100, |