1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef DISPLAYCOLOR_ZUMA_H_ 18 #define DISPLAYCOLOR_ZUMA_H_ 19 20 #include <displaycolor/displaycolor_gs101.h> 21 22 namespace displaycolor { 23 24 /// An interface for accessing ZUMA color management data. 25 class IDisplayColorZuma : public IDisplayColorGeneric { 26 public: 27 /// Interface for accessing data for DPP stages. 28 struct IDppData { 29 struct IEotfData { 30 private: 31 struct EotfConfigType 32 : public IDisplayColorGS101::FlexLutConfigType<uint16_t, uint16_t, 39> { 33 // True to use built-in PQ table, false to use tf_data 34 bool eotf_lut_en; 35 uint16_t eotf_scalar; 36 }; 37 38 public: 39 /// Register data for the EOTF LUT in DPP. 40 using EotfData = DisplayStage<EotfConfigType>; 41 42 /// Get data for the EOTF LUT. 43 virtual const EotfData& EotfLut() const = 0; ~IEotfDataIDppData::IEotfData44 virtual ~IEotfData() {} 45 }; 46 47 struct IGmData { 48 /// Register data for the gamut mapping (GM) matrix in DPP. 49 using GmData = DisplayStage<IDisplayColorGS101::MatrixConfigType<uint16_t, 3>>; 50 51 /// Get data for the gamut mapping (GM) matrix. 52 virtual const GmData& Gm() const = 0; ~IGmDataIDppData::IGmData53 virtual ~IGmData() {} 54 }; 55 56 struct IDtmData { 57 private: 58 struct Rgb2YData { 59 uint16_t coeff_r; 60 uint16_t coeff_g; 61 uint16_t coeff_b; 62 uint16_t ymix_tf; 63 uint16_t ymix_vf; 64 uint16_t ymix_dv; 65 uint16_t ymix_slope; 66 }; 67 struct DtmConfigType 68 : public IDisplayColorGS101::FlexLutConfigType<uint16_t, uint16_t, 48>, 69 public Rgb2YData {}; 70 71 public: 72 using DtmData = DisplayStage<DtmConfigType>; 73 74 /// Get data for DTM stage 75 virtual const DtmData& Dtm() const = 0; ~IDtmDataIDppData::IDtmData76 virtual ~IDtmData() {} 77 }; 78 79 struct IOetfData { 80 /// Register data for the OETF LUT in DPP. 81 using OetfData = 82 DisplayStage<IDisplayColorGS101::FlexLutConfigType<uint16_t, uint16_t, 48>>; 83 84 /// Get data for the OETF LUT. 85 virtual const OetfData& OetfLut() const = 0; ~IOetfDataIDppData::IOetfData86 virtual ~IOetfData() {} 87 }; 88 }; 89 90 struct IDpp 91 : public IStageDataCollection<IDppData::IEotfData, IDppData::IGmData, 92 IDppData::IDtmData, IDppData::IOetfData> { 93 /// Get the solid color 94 virtual const Color SolidColor() const = 0; 95 ~IDppIDpp96 virtual ~IDpp() {} 97 }; 98 99 /// Interface for accessing data for DQE stages. 100 struct IDqeData { 101 public: 102 struct IDegammaLutData { 103 private: 104 struct DegammaConfigType { 105 using XContainer = uint16_t; 106 using YContainer = uint16_t; 107 static constexpr size_t kLutLen = 33; 108 109 IDisplayColorGS101::TransferFunctionData<XContainer, YContainer, kLutLen> values; 110 }; 111 112 public: 113 /// Register data for the degamma LUT in DQE. 114 using DegammaLutData = DisplayStage<DegammaConfigType>; 115 /// Get data for the 1D de-gamma LUT (EOTF). 116 virtual const DegammaLutData& DegammaLut() const = 0; ~IDegammaLutDataIDqeData::IDegammaLutData117 virtual ~IDegammaLutData() {} 118 }; 119 120 struct IRegammaLutData { 121 private: 122 struct RegammaConfigType { 123 using XContainer = uint16_t; 124 using YContainer = uint16_t; 125 static constexpr size_t kChannelLutLen = 33; 126 127 IDisplayColorGS101::TransferFunctionData<XContainer, YContainer, kChannelLutLen> 128 r_values; 129 IDisplayColorGS101::TransferFunctionData<XContainer, YContainer, kChannelLutLen> 130 g_values; 131 IDisplayColorGS101::TransferFunctionData<XContainer, YContainer, kChannelLutLen> 132 b_values; 133 }; 134 135 public: 136 /// Register data for the regamma LUT. 137 using RegammaLutData = DisplayStage<RegammaConfigType>; 138 139 /// Get data for the 3x1D re-gamma LUTa (OETF). 140 virtual const RegammaLutData& RegammaLut() const = 0; ~IRegammaLutDataIDqeData::IRegammaLutData141 virtual ~IRegammaLutData() {} 142 }; 143 }; 144 145 using IPanel = IDisplayColorGS101::IPanel; 146 147 struct IDqe : public IStageDataCollection< 148 IDisplayColorGS101::IDqeData::IDqeControlData, 149 IDisplayColorGS101::IDqeData::IGammaMatrixData, 150 IDqeData::IDegammaLutData, 151 IDisplayColorGS101::IDqeData::ILinearMatrixData, 152 IDisplayColorGS101::IDqeData::ICgcData, 153 IDqeData::IRegammaLutData> { ~IDqeIDqe154 virtual ~IDqe() {} 155 }; 156 157 /// Interface for accessing particular display color data 158 struct IDisplayPipelineData { 159 /** 160 * @brief Get handles to Display Pre-Processor (DPP) data accessors. 161 * 162 * The order of the returned DPP handles match the order of the 163 * LayerColorData provided as part of struct DisplayScene and 164 * IDisplayColorGeneric::Update(). 165 */ 166 virtual std::vector<std::reference_wrapper<const IDpp>> Dpp() const = 0; 167 168 /// Get a handle to Display Quality Enhancer (DQE) data accessors. 169 virtual const IDqe& Dqe() const = 0; 170 171 /// Get a handle to panel data accessors 172 virtual const IPanel& Panel() const = 0; 173 ~IDisplayPipelineDataIDisplayPipelineData174 virtual ~IDisplayPipelineData() {} 175 }; 176 177 /// Get pipeline color data for specified display type 178 // deprecated by the 'int64_t display' version 179 virtual const IDisplayPipelineData* GetPipelineData(DisplayType display) const = 0; 180 virtual const IDisplayPipelineData* GetPipelineData(const int64_t display) const = 0; 181 ~IDisplayColorZuma()182 virtual ~IDisplayColorZuma() {} 183 }; 184 185 extern "C" { 186 187 /// Get the ZUMA instance. 188 IDisplayColorZuma* GetDisplayColorZuma(const std::vector<DisplayInfo> &display_info); 189 } 190 191 } // namespace displaycolor 192 193 #endif // DISPLAYCOLOR_ZUMA_H_ 194