summaryrefslogtreecommitdiff
path: root/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h
blob: b730879b5e356ee340a3d0ab28b5a8d6936d5261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef EXYNOS_DISPLAY_DRM_INTERFACE_MODULE_H
#define EXYNOS_DISPLAY_DRM_INTERFACE_MODULE_H

#include <gs101/displaycolor/displaycolor_gs101.h>
#include <histogram/histogram.h>

#include "ExynosDisplayDrmInterface.h"

namespace gs101 {

using namespace displaycolor;

class ExynosDisplayDrmInterfaceModule : public ExynosDisplayDrmInterface {
    public:
        ExynosDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay);
        virtual ~ExynosDisplayDrmInterfaceModule();
        virtual int32_t initDrmDevice(DrmDevice *drmDevice);

        virtual int32_t setDisplayColorSetting(
                ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);
        virtual int32_t setPlaneColorSetting(
                ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq,
                const std::unique_ptr<DrmPlane> &plane,
                const exynos_win_config_data &config,
                uint32_t &solidColor);
        void setColorSettingChanged(bool changed, bool forceDisplay = false) {
            mColorSettingChanged = changed;
            mForceDisplayColorSetting = forceDisplay;
        };
        void destroyOldBlobs(std::vector<uint32_t> &oldBlobs);

        int32_t createCgcBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
                uint32_t &blobId);
        int32_t createDegammaLutBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
                uint32_t &blobId);
        int32_t createRegammaLutBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
                uint32_t &blobId);
        int32_t createGammaMatBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
                uint32_t &blobId);
        int32_t createLinearMatBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
                uint32_t &blobId);
        int32_t createDispDitherBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
                uint32_t &blobId);
        int32_t createCgcDitherBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe,
                uint32_t &blobId);

        int32_t createEotfBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp,
                uint32_t &blobId);
        int32_t createGmBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp,
                uint32_t &blobId);
        int32_t createDtmBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp,
                uint32_t &blobId);
        int32_t createOetfBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp,
                uint32_t &blobId);

        void getDisplayInfo(std::vector<displaycolor::DisplayInfo> &display_info);

        /* For Histogram */
        int32_t createHistoRoiBlob(uint32_t &blobId);
        int32_t createHistoWeightsBlob(uint32_t &blobId);

        virtual int32_t setDisplayHistogramSetting(
                ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);

        virtual void registerHistogramInfo(const std::shared_ptr<IDLHistogram> &info) {
            mHistogramInfo = info;
        }
        bool isHistogramInfoRegistered() { return mHistogramInfo != nullptr; }
        int32_t setHistogramControl(hidl_histogram_control_t enabled);
        virtual int32_t setHistogramData(void *bin);

    protected:
        class SaveBlob {
            public:
                ~SaveBlob();
                void init(DrmDevice *drmDevice, uint32_t size) {
                    mDrmDevice = drmDevice;
                    blobs.resize(size, 0);
                };
                void addBlob(uint32_t type, uint32_t blob);
                uint32_t getBlob(uint32_t type);
            private:
                DrmDevice *mDrmDevice = NULL;
                std::vector<uint32_t> blobs;
        };
        class DqeBlobs:public SaveBlob {
            public:
                enum Dqe_Blob_Type{
                    CGC,
                    DEGAMMA_LUT,
                    REGAMMA_LUT,
                    GAMMA_MAT,
                    LINEAR_MAT,
                    DISP_DITHER,
                    CGC_DITHER,
                    DQE_BLOB_NUM // number of DQE blobs
                };
                void init(DrmDevice *drmDevice) {
                    SaveBlob::init(drmDevice, DQE_BLOB_NUM);
                };
        };
        class DppBlobs:public SaveBlob {
            public:
                enum Dpp_Blob_Type{
                    EOTF,
                    GM,
                    DTM,
                    OETF,
                    DPP_BLOB_NUM // number of DPP blobs
                };
                DppBlobs(DrmDevice *drmDevice, uint32_t pid) : planeId(pid) {
                    SaveBlob::init(drmDevice, DPP_BLOB_NUM);
                };
                uint32_t planeId;
        };
        template<typename StageDataType>
        int32_t setDisplayColorBlob(
                const DrmProperty &prop,
                const uint32_t type,
                const StageDataType &stage,
                const IDisplayColorGS101::IDqe &dqe,
                ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);
        template<typename StageDataType>
        int32_t setPlaneColorBlob(
                const std::unique_ptr<DrmPlane> &plane,
                const DrmProperty &prop,
                const uint32_t type,
                const StageDataType &stage,
                const IDisplayColorGS101::IDpp &dpp,
                const uint32_t dppIndex,
                ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq,
                bool forceUpdate);
        void parseBpcEnums(const DrmProperty& property);
        DqeBlobs mOldDqeBlobs;
        std::vector<DppBlobs> mOldDppBlobs;
        void initOldDppBlobs(DrmDevice *drmDevice) {
            auto const &planes = drmDevice->planes();
            for (uint32_t ix = 0; ix < planes.size(); ++ix)
                mOldDppBlobs.emplace_back(mDrmDevice, planes[ix]->id());
        };
        bool mColorSettingChanged = false;
        bool mForceDisplayColorSetting = false;
        enum Bpc_Type {
            BPC_UNSPECIFIED = 0,
            BPC_8,
            BPC_10,
        };
        DrmEnumParser::MapHal2DrmEnum mBpcEnums;

        /* For Histogram */
        class HistoBlobs : public SaveBlob {
        public:
            enum Histo_Blob_Type {
                ROI,
                WEIGHTS,
                HISTO_BLOB_NUM // number of Histogram blobs
            };
            void init(DrmDevice *drmDevice) { SaveBlob::init(drmDevice, HISTO_BLOB_NUM); }
        };
        int32_t setDisplayHistoBlob(const DrmProperty &prop, const uint32_t type,
                                    ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq);
        HistoBlobs mOldHistoBlobs;

        std::shared_ptr<IDLHistogram> mHistogramInfo;

    private:
        const std::string GetPanelInfo(const std::string &sysfs_rel, char delim);
        const std::string GetPanelSerial() { return GetPanelInfo("serial_number", '\n'); }
        const std::string GetPanelName() { return GetPanelInfo("panel_name", '\n'); }
};

class ExynosPrimaryDisplayDrmInterfaceModule : public ExynosDisplayDrmInterfaceModule {
    public:
        ExynosPrimaryDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay);
        virtual ~ExynosPrimaryDisplayDrmInterfaceModule();
};

class ExynosExternalDisplayDrmInterfaceModule : public ExynosDisplayDrmInterfaceModule {
    public:
        ExynosExternalDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay);
        virtual ~ExynosExternalDisplayDrmInterfaceModule();
};

}  // namespace gs101

#endif