summaryrefslogtreecommitdiff
path: root/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h
blob: aa35ef12508666476fcb1191cf3e86ba10c679a3 (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
/*
 * Copyright (C) 2020 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 "ExynosDisplayDrmInterface.h"

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);
        void setColorSettingChanged(bool changed) {
            mColorSettingChanged = changed; };
        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);
    private:
        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;
        enum Bpc_Type {
            BPC_UNSPECIFIED = 0,
            BPC_8,
            BPC_10,
        };
        DrmPropertyMap mBpcEnums;
};

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

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