• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 EXYNOS_DISPLAY_DRM_INTERFACE_MODULE_H
18 #define EXYNOS_DISPLAY_DRM_INTERFACE_MODULE_H
19 
20 #include <gs101/displaycolor/displaycolor_gs101.h>
21 #include <histogram/histogram.h>
22 
23 #include "ExynosDisplayDrmInterface.h"
24 
25 namespace gs101 {
26 
27 using namespace displaycolor;
28 
29 class ExynosDisplayDrmInterfaceModule : public ExynosDisplayDrmInterface {
30     public:
31         ExynosDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay);
32         virtual ~ExynosDisplayDrmInterfaceModule();
33         virtual int32_t initDrmDevice(DrmDevice *drmDevice);
34 
35         virtual int32_t setDisplayColorSetting(
36                 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);
37         virtual int32_t setPlaneColorSetting(
38                 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq,
39                 const std::unique_ptr<DrmPlane> &plane,
40                 const exynos_win_config_data &config,
41                 uint32_t &solidColor);
42         void setColorSettingChanged(bool changed, bool forceDisplay = false) {
43             mColorSettingChanged = changed;
44             mForceDisplayColorSetting = forceDisplay;
45         };
46         void destroyOldBlobs(std::vector<uint32_t> &oldBlobs);
47 
48         int32_t createCgcBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
49                 uint32_t &blobId);
50         int32_t createDegammaLutBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
51                 uint32_t &blobId);
52         int32_t createRegammaLutBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
53                 uint32_t &blobId);
54         int32_t createGammaMatBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
55                 uint32_t &blobId);
56         int32_t createLinearMatBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
57                 uint32_t &blobId);
58         int32_t createDispDitherBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
59                 uint32_t &blobId);
60         int32_t createCgcDitherBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
61                 uint32_t &blobId);
62 
63         int32_t createEotfBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp,
64                 uint32_t &blobId);
65         int32_t createGmBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp,
66                 uint32_t &blobId);
67         int32_t createDtmBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp,
68                 uint32_t &blobId);
69         int32_t createOetfBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp,
70                 uint32_t &blobId);
71 
72         void getDisplayInfo(std::vector<displaycolor::DisplayInfo> &display_info);
73 
74         /* For Histogram */
75         int32_t createHistoRoiBlob(uint32_t &blobId);
76         int32_t createHistoWeightsBlob(uint32_t &blobId);
77 
78         virtual int32_t setDisplayHistogramSetting(
79                 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);
80 
registerHistogramInfo(const std::shared_ptr<IDLHistogram> & info)81         virtual void registerHistogramInfo(const std::shared_ptr<IDLHistogram> &info) {
82             mHistogramInfo = info;
83         }
isHistogramInfoRegistered()84         bool isHistogramInfoRegistered() { return mHistogramInfo != nullptr; }
85         int32_t setHistogramControl(hidl_histogram_control_t enabled);
86         virtual int32_t setHistogramData(void *bin);
87 
88     protected:
89         class SaveBlob {
90             public:
91                 ~SaveBlob();
init(DrmDevice * drmDevice,uint32_t size)92                 void init(DrmDevice *drmDevice, uint32_t size) {
93                     mDrmDevice = drmDevice;
94                     blobs.resize(size, 0);
95                 };
96                 void addBlob(uint32_t type, uint32_t blob);
97                 uint32_t getBlob(uint32_t type);
98             private:
99                 DrmDevice *mDrmDevice = NULL;
100                 std::vector<uint32_t> blobs;
101         };
102         class DqeBlobs:public SaveBlob {
103             public:
104                 enum Dqe_Blob_Type{
105                     CGC,
106                     DEGAMMA_LUT,
107                     REGAMMA_LUT,
108                     GAMMA_MAT,
109                     LINEAR_MAT,
110                     DISP_DITHER,
111                     CGC_DITHER,
112                     DQE_BLOB_NUM // number of DQE blobs
113                 };
init(DrmDevice * drmDevice)114                 void init(DrmDevice *drmDevice) {
115                     SaveBlob::init(drmDevice, DQE_BLOB_NUM);
116                 };
117         };
118         class DppBlobs:public SaveBlob {
119             public:
120                 enum Dpp_Blob_Type{
121                     EOTF,
122                     GM,
123                     DTM,
124                     OETF,
125                     DPP_BLOB_NUM // number of DPP blobs
126                 };
DppBlobs(DrmDevice * drmDevice,uint32_t pid)127                 DppBlobs(DrmDevice *drmDevice, uint32_t pid) : planeId(pid) {
128                     SaveBlob::init(drmDevice, DPP_BLOB_NUM);
129                 };
130                 uint32_t planeId;
131         };
132         template<typename StageDataType>
133         int32_t setDisplayColorBlob(
134                 const DrmProperty &prop,
135                 const uint32_t type,
136                 const StageDataType &stage,
137                 const IDisplayColorGS101::IDqe &dqe,
138                 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);
139         template<typename StageDataType>
140         int32_t setPlaneColorBlob(
141                 const std::unique_ptr<DrmPlane> &plane,
142                 const DrmProperty &prop,
143                 const uint32_t type,
144                 const StageDataType &stage,
145                 const IDisplayColorGS101::IDpp &dpp,
146                 const uint32_t dppIndex,
147                 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq,
148                 bool forceUpdate);
149         void parseBpcEnums(const DrmProperty& property);
150         DqeBlobs mOldDqeBlobs;
151         std::vector<DppBlobs> mOldDppBlobs;
initOldDppBlobs(DrmDevice * drmDevice)152         void initOldDppBlobs(DrmDevice *drmDevice) {
153             auto const &planes = drmDevice->planes();
154             for (uint32_t ix = 0; ix < planes.size(); ++ix)
155                 mOldDppBlobs.emplace_back(mDrmDevice, planes[ix]->id());
156         };
157         bool mColorSettingChanged = false;
158         bool mForceDisplayColorSetting = false;
159         enum Bpc_Type {
160             BPC_UNSPECIFIED = 0,
161             BPC_8,
162             BPC_10,
163         };
164         DrmEnumParser::MapHal2DrmEnum mBpcEnums;
165 
166         /* For Histogram */
167         class HistoBlobs : public SaveBlob {
168         public:
169             enum Histo_Blob_Type {
170                 ROI,
171                 WEIGHTS,
172                 HISTO_BLOB_NUM // number of Histogram blobs
173             };
init(DrmDevice * drmDevice)174             void init(DrmDevice *drmDevice) { SaveBlob::init(drmDevice, HISTO_BLOB_NUM); }
175         };
176         int32_t setDisplayHistoBlob(const DrmProperty &prop, const uint32_t type,
177                                     ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);
178         HistoBlobs mOldHistoBlobs;
179 
180         std::shared_ptr<IDLHistogram> mHistogramInfo;
181 
182     private:
183         const std::string GetPanelInfo(const std::string &sysfs_rel, char delim);
GetPanelSerial()184         const std::string GetPanelSerial() { return GetPanelInfo("serial_number", '\n'); }
GetPanelName()185         const std::string GetPanelName() { return GetPanelInfo("panel_name", '\n'); }
186 };
187 
188 class ExynosPrimaryDisplayDrmInterfaceModule : public ExynosDisplayDrmInterfaceModule {
189     public:
190         ExynosPrimaryDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay);
191         virtual ~ExynosPrimaryDisplayDrmInterfaceModule();
192 };
193 
194 class ExynosExternalDisplayDrmInterfaceModule : public ExynosDisplayDrmInterfaceModule {
195     public:
196         ExynosExternalDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay);
197         virtual ~ExynosExternalDisplayDrmInterfaceModule();
198 };
199 
200 }  // namespace gs101
201 
202 #endif
203