1 /* 2 * Copyright (C) 2020 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 22 #include "ExynosDisplayDrmInterface.h" 23 24 namespace gs101 { 25 26 using namespace displaycolor; 27 28 class ExynosDisplayDrmInterfaceModule : public ExynosDisplayDrmInterface { 29 public: 30 ExynosDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay); 31 virtual ~ExynosDisplayDrmInterfaceModule(); 32 virtual int32_t initDrmDevice(DrmDevice *drmDevice); 33 34 virtual int32_t setDisplayColorSetting( 35 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq); 36 virtual int32_t setPlaneColorSetting( 37 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq, 38 const std::unique_ptr<DrmPlane> &plane, 39 const exynos_win_config_data &config); 40 void setColorSettingChanged(bool changed, bool forceDisplay = false) { 41 mColorSettingChanged = changed; 42 mForceDisplayColorSetting = forceDisplay; 43 }; 44 void destroyOldBlobs(std::vector<uint32_t> &oldBlobs); 45 46 int32_t createCgcBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe, 47 uint32_t &blobId); 48 int32_t createDegammaLutBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe, 49 uint32_t &blobId); 50 int32_t createRegammaLutBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe, 51 uint32_t &blobId); 52 int32_t createGammaMatBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe, 53 uint32_t &blobId); 54 int32_t createLinearMatBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe, 55 uint32_t &blobId); 56 int32_t createDispDitherBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe, 57 uint32_t &blobId); 58 int32_t createCgcDitherBlobFromIDqe(const IDisplayColorGS101::IDqe &dqe, 59 uint32_t &blobId); 60 61 int32_t createEotfBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp, 62 uint32_t &blobId); 63 int32_t createGmBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp, 64 uint32_t &blobId); 65 int32_t createDtmBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp, 66 uint32_t &blobId); 67 int32_t createOetfBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp, 68 uint32_t &blobId); 69 70 void getDisplayInfo(std::vector<displaycolor::DisplayInfo> &display_info); 71 72 protected: 73 class SaveBlob { 74 public: 75 ~SaveBlob(); init(DrmDevice * drmDevice,uint32_t size)76 void init(DrmDevice *drmDevice, uint32_t size) { 77 mDrmDevice = drmDevice; 78 blobs.resize(size, 0); 79 }; 80 void addBlob(uint32_t type, uint32_t blob); 81 uint32_t getBlob(uint32_t type); 82 private: 83 DrmDevice *mDrmDevice = NULL; 84 std::vector<uint32_t> blobs; 85 }; 86 class DqeBlobs:public SaveBlob { 87 public: 88 enum Dqe_Blob_Type{ 89 CGC, 90 DEGAMMA_LUT, 91 REGAMMA_LUT, 92 GAMMA_MAT, 93 LINEAR_MAT, 94 DISP_DITHER, 95 CGC_DITHER, 96 DQE_BLOB_NUM // number of DQE blobs 97 }; init(DrmDevice * drmDevice)98 void init(DrmDevice *drmDevice) { 99 SaveBlob::init(drmDevice, DQE_BLOB_NUM); 100 }; 101 }; 102 class DppBlobs:public SaveBlob { 103 public: 104 enum Dpp_Blob_Type{ 105 EOTF, 106 GM, 107 DTM, 108 OETF, 109 DPP_BLOB_NUM // number of DPP blobs 110 }; DppBlobs(DrmDevice * drmDevice,uint32_t pid)111 DppBlobs(DrmDevice *drmDevice, uint32_t pid) : planeId(pid) { 112 SaveBlob::init(drmDevice, DPP_BLOB_NUM); 113 }; 114 uint32_t planeId; 115 }; 116 template<typename StageDataType> 117 int32_t setDisplayColorBlob( 118 const DrmProperty &prop, 119 const uint32_t type, 120 const StageDataType &stage, 121 const IDisplayColorGS101::IDqe &dqe, 122 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq); 123 template<typename StageDataType> 124 int32_t setPlaneColorBlob( 125 const std::unique_ptr<DrmPlane> &plane, 126 const DrmProperty &prop, 127 const uint32_t type, 128 const StageDataType &stage, 129 const IDisplayColorGS101::IDpp &dpp, 130 const uint32_t dppIndex, 131 ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq, 132 bool forceUpdate); 133 void parseBpcEnums(const DrmProperty& property); 134 DqeBlobs mOldDqeBlobs; 135 std::vector<DppBlobs> mOldDppBlobs; initOldDppBlobs(DrmDevice * drmDevice)136 void initOldDppBlobs(DrmDevice *drmDevice) { 137 auto const &planes = drmDevice->planes(); 138 for (uint32_t ix = 0; ix < planes.size(); ++ix) 139 mOldDppBlobs.emplace_back(mDrmDevice, planes[ix]->id()); 140 }; 141 bool mColorSettingChanged = false; 142 bool mForceDisplayColorSetting = false; 143 enum Bpc_Type { 144 BPC_UNSPECIFIED = 0, 145 BPC_8, 146 BPC_10, 147 }; 148 DrmPropertyMap mBpcEnums; 149 }; 150 151 class ExynosPrimaryDisplayDrmInterfaceModule : public ExynosDisplayDrmInterfaceModule { 152 public: 153 ExynosPrimaryDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay); 154 virtual ~ExynosPrimaryDisplayDrmInterfaceModule(); 155 }; 156 157 class ExynosExternalDisplayDrmInterfaceModule : public ExynosDisplayDrmInterfaceModule { 158 public: 159 ExynosExternalDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay); 160 virtual ~ExynosExternalDisplayDrmInterfaceModule(); 161 }; 162 163 } // namespace gs101 164 165 #endif 166