• 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 <histogram/histogram.h>
21 #include "DisplayColorModule.h"
22 #include "ExynosDisplayDrmInterface.h"
23 
24 namespace gs101 {
25 
26 using namespace displaycolor;
27 
28 class ExynosDisplayDrmInterfaceModule : public ExynosDisplayDrmInterface {
29     using GsInterfaceType = gs::ColorDrmBlobFactory::GsInterfaceType;
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         void getDisplayInfo(std::vector<displaycolor::DisplayInfo> &display_info);
48 
49         /* For Histogram */
50         int32_t createHistoRoiBlob(uint32_t &blobId);
51         int32_t createHistoWeightsBlob(uint32_t &blobId);
52 
53         virtual int32_t setDisplayHistogramSetting(
54                 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);
55 
registerHistogramInfo(const std::shared_ptr<IDLHistogram> & info)56         virtual void registerHistogramInfo(const std::shared_ptr<IDLHistogram> &info) {
57             mHistogramInfo = info;
58         }
isHistogramInfoRegistered()59         bool isHistogramInfoRegistered() { return mHistogramInfo != nullptr; }
60         int32_t setHistogramControl(hidl_histogram_control_t enabled);
61         virtual int32_t setHistogramData(void *bin);
62 
63     protected:
64         class SaveBlob {
65             public:
66                 ~SaveBlob();
init(DrmDevice * drmDevice,uint32_t size)67                 void init(DrmDevice *drmDevice, uint32_t size) {
68                     mDrmDevice = drmDevice;
69                     blobs.resize(size, 0);
70                 };
71                 void addBlob(uint32_t type, uint32_t blob);
72                 uint32_t getBlob(uint32_t type);
73             private:
74                 DrmDevice *mDrmDevice = NULL;
75                 std::vector<uint32_t> blobs;
76         };
77         class DqeBlobs:public SaveBlob {
78             public:
79                 enum Dqe_Blob_Type{
80                     CGC,
81                     DEGAMMA_LUT,
82                     REGAMMA_LUT,
83                     GAMMA_MAT,
84                     LINEAR_MAT,
85                     DISP_DITHER,
86                     CGC_DITHER,
87                     DQE_BLOB_NUM // number of DQE blobs
88                 };
init(DrmDevice * drmDevice)89                 void init(DrmDevice *drmDevice) {
90                     SaveBlob::init(drmDevice, DQE_BLOB_NUM);
91                 };
92         };
93         class DppBlobs:public SaveBlob {
94             public:
95                 enum Dpp_Blob_Type{
96                     EOTF,
97                     GM,
98                     DTM,
99                     OETF,
100                     DPP_BLOB_NUM // number of DPP blobs
101                 };
DppBlobs(DrmDevice * drmDevice,uint32_t pid)102                 DppBlobs(DrmDevice *drmDevice, uint32_t pid) : planeId(pid) {
103                     SaveBlob::init(drmDevice, DPP_BLOB_NUM);
104                 };
105                 uint32_t planeId;
106         };
107         template<typename StageDataType>
108         int32_t setDisplayColorBlob(
109                 const DrmProperty &prop,
110                 const uint32_t type,
111                 const StageDataType &stage,
112                 const typename GsInterfaceType::IDqe &dqe,
113                 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);
114         template<typename StageDataType>
115         int32_t setPlaneColorBlob(
116                 const std::unique_ptr<DrmPlane> &plane,
117                 const DrmProperty &prop,
118                 const uint32_t type,
119                 const StageDataType &stage,
120                 const typename GsInterfaceType::IDpp &dpp,
121                 const uint32_t dppIndex,
122                 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq,
123                 bool forceUpdate);
124         void parseBpcEnums(const DrmProperty& property);
125         DqeBlobs mOldDqeBlobs;
126         std::vector<DppBlobs> mOldDppBlobs;
initOldDppBlobs(DrmDevice * drmDevice)127         void initOldDppBlobs(DrmDevice *drmDevice) {
128             auto const &planes = drmDevice->planes();
129             for (uint32_t ix = 0; ix < planes.size(); ++ix)
130                 mOldDppBlobs.emplace_back(mDrmDevice, planes[ix]->id());
131         };
132         bool mColorSettingChanged = false;
133         bool mForceDisplayColorSetting = false;
134         enum Bpc_Type {
135             BPC_UNSPECIFIED = 0,
136             BPC_8,
137             BPC_10,
138         };
139         DrmEnumParser::MapHal2DrmEnum mBpcEnums;
140 
141         /* For Histogram */
142         class HistoBlobs : public SaveBlob {
143         public:
144             enum Histo_Blob_Type {
145                 ROI,
146                 WEIGHTS,
147                 HISTO_BLOB_NUM // number of Histogram blobs
148             };
init(DrmDevice * drmDevice)149             void init(DrmDevice *drmDevice) { SaveBlob::init(drmDevice, HISTO_BLOB_NUM); }
150         };
151         int32_t setDisplayHistoBlob(const DrmProperty &prop, const uint32_t type,
152                                     ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);
153         HistoBlobs mOldHistoBlobs;
154 
155         std::shared_ptr<IDLHistogram> mHistogramInfo;
156 
157     private:
158         const std::string GetPanelInfo(const std::string &sysfs_rel, char delim);
GetPanelSerial()159         const std::string GetPanelSerial() { return GetPanelInfo("serial_number", '\n'); }
GetPanelName()160         const std::string GetPanelName() { return GetPanelInfo("panel_name", '\n'); }
161 };
162 
163 class ExynosPrimaryDisplayDrmInterfaceModule : public ExynosDisplayDrmInterfaceModule {
164     public:
165         ExynosPrimaryDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay);
166         virtual ~ExynosPrimaryDisplayDrmInterfaceModule();
167 };
168 
169 class ExynosExternalDisplayDrmInterfaceModule : public ExynosDisplayDrmInterfaceModule {
170     public:
171         ExynosExternalDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay);
172         virtual ~ExynosExternalDisplayDrmInterfaceModule();
173 };
174 
175 }  // namespace gs101
176 
177 #endif
178