diff options
author | Long Ling <longling@google.com> | 2022-07-06 15:01:21 -0700 |
---|---|---|
committer | Long Ling <longling@google.com> | 2022-07-22 10:39:41 -0700 |
commit | 1f1a2c83b7e46f9ee9a3d006faf8624d4992143a (patch) | |
tree | 09a8d3b43c8840df3ecfa3d9b489ccfd68438ecc /libhwc2.1 | |
parent | c2f8a04a9eb8f41277a89309fb1e38ad12334f73 (diff) | |
download | gs101-1f1a2c83b7e46f9ee9a3d006faf8624d4992143a.tar.gz |
libhwc2.1: refactor displaycolor code
Move DisplayColorLoader to common.
Move soc specific code to DisplayColorModule.
Use displaycolor type alias name in shared code.
Bug: 237804887
Change-Id: Iafdfc0f86f2586eac2520dfbac654f94524bc7db
Diffstat (limited to 'libhwc2.1')
-rw-r--r-- | libhwc2.1/Android.mk | 1 | ||||
-rw-r--r-- | libhwc2.1/libcolormanager/DisplayColorModule.cpp | 320 | ||||
-rw-r--r-- | libhwc2.1/libcolormanager/DisplayColorModule.h | 57 | ||||
-rw-r--r-- | libhwc2.1/libdevice/ExynosDeviceModule.cpp | 2 | ||||
-rw-r--r-- | libhwc2.1/libdevice/ExynosDeviceModule.h | 11 | ||||
-rw-r--r-- | libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp | 380 | ||||
-rw-r--r-- | libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h | 33 | ||||
-rw-r--r-- | libhwc2.1/libmaindisplay/DisplayColorLoader.h | 102 | ||||
-rw-r--r-- | libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp | 28 | ||||
-rw-r--r-- | libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h | 17 | ||||
-rw-r--r-- | libhwc2.1/libresource/ExynosMPPModule.cpp | 6 |
11 files changed, 445 insertions, 512 deletions
diff --git a/libhwc2.1/Android.mk b/libhwc2.1/Android.mk index b29122c..de43986 100644 --- a/libhwc2.1/Android.mk +++ b/libhwc2.1/Android.mk @@ -13,6 +13,7 @@ # limitations under the License. LOCAL_SRC_FILES += \ + ../../$(TARGET_BOARD_PLATFORM)/libhwc2.1/libcolormanager/DisplayColorModule.cpp \ ../../$(TARGET_BOARD_PLATFORM)/libhwc2.1/libdevice/ExynosDeviceModule.cpp \ ../../$(TARGET_BOARD_PLATFORM)/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp \ ../../$(TARGET_BOARD_PLATFORM)/libhwc2.1/libresource/ExynosMPPModule.cpp \ diff --git a/libhwc2.1/libcolormanager/DisplayColorModule.cpp b/libhwc2.1/libcolormanager/DisplayColorModule.cpp new file mode 100644 index 0000000..496caf6 --- /dev/null +++ b/libhwc2.1/libcolormanager/DisplayColorModule.cpp @@ -0,0 +1,320 @@ +/* + * 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. + */ + +#include <drm/samsung_drm.h> +#include "DisplayColorModule.h" + +using namespace android; +namespace gs { + +template <typename T, typename M> +int32_t convertDqeMatrixDataToDrmMatrix(T &colorMatrix, M &mat, uint32_t dimension) { + if (colorMatrix.coeffs.size() != (dimension * dimension)) { + ALOGE("Invalid coeff size(%zu)", + colorMatrix.coeffs.size()); + return -EINVAL; + } + if (colorMatrix.offsets.size() != dimension) { + ALOGE("Invalid offset size(%zu)", + colorMatrix.offsets.size()); + return -EINVAL; + } + for (uint32_t i = 0; i < (dimension * dimension); i++) { + mat.coeffs[i] = colorMatrix.coeffs[i]; + } + + for (uint32_t i = 0; i < dimension; i++) { + mat.offsets[i] = colorMatrix.offsets[i]; + } + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::eotf(const GsInterfaceType::IDpp::EotfData::ConfigType *config, + DrmDevice *drm, uint32_t &blobId) { + struct hdr_eotf_lut eotfLut; + + if (config == nullptr) { + ALOGE("no dpp eotf config"); + return -EINVAL; + } + + if ((config->tf_data.posx.size() != DRM_SAMSUNG_HDR_EOTF_LUT_LEN) || + (config->tf_data.posy.size() != DRM_SAMSUNG_HDR_EOTF_LUT_LEN)) { + ALOGE("%s: eotf pos size (%zu, %zu)", __func__, config->tf_data.posx.size(), + config->tf_data.posy.size()); + return -EINVAL; + } + + for (uint32_t i = 0; i < DRM_SAMSUNG_HDR_EOTF_LUT_LEN; i++) { + eotfLut.posx[i] = config->tf_data.posx[i]; + eotfLut.posy[i] = config->tf_data.posy[i]; + } + int ret = drm->CreatePropertyBlob(&eotfLut, sizeof(eotfLut), &blobId); + if (ret) { + ALOGE("Failed to create eotf lut blob %d", ret); + return ret; + } + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::gm(const GsInterfaceType::IDpp::GmData::ConfigType *config, + DrmDevice *drm, uint32_t &blobId) { + int ret = 0; + struct hdr_gm_data gmMatrix; + + if (config == nullptr) { + ALOGE("no dpp GM config"); + return -EINVAL; + } + + if ((ret = convertDqeMatrixDataToDrmMatrix(config->matrix_data, gmMatrix, + DRM_SAMSUNG_HDR_GM_DIMENS)) != NO_ERROR) { + ALOGE("Failed to convert gm matrix"); + return ret; + } + ret = drm->CreatePropertyBlob(&gmMatrix, sizeof(gmMatrix), &blobId); + if (ret) { + ALOGE("Failed to create gm matrix blob %d", ret); + return ret; + } + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::dtm(const GsInterfaceType::IDpp::DtmData::ConfigType *config, + DrmDevice *drm, uint32_t &blobId) { + struct hdr_tm_data tmData; + + if (config == nullptr) { + ALOGE("no dpp DTM config"); + return -EINVAL; + } + + if ((config->tf_data.posx.size() != DRM_SAMSUNG_HDR_TM_LUT_LEN) || + (config->tf_data.posy.size() != DRM_SAMSUNG_HDR_TM_LUT_LEN)) { + ALOGE("%s: dtm pos size (%zu, %zu)", __func__, config->tf_data.posx.size(), + config->tf_data.posy.size()); + return -EINVAL; + } + + for (uint32_t i = 0; i < DRM_SAMSUNG_HDR_TM_LUT_LEN; i++) { + tmData.posx[i] = config->tf_data.posx[i]; + tmData.posy[i] = config->tf_data.posy[i]; + } + + tmData.coeff_r = config->coeff_r; + tmData.coeff_g = config->coeff_g; + tmData.coeff_b = config->coeff_b; + tmData.rng_x_min = config->rng_x_min; + tmData.rng_x_max = config->rng_x_max; + tmData.rng_y_min = config->rng_y_min; + tmData.rng_y_max = config->rng_y_max; + + int ret = drm->CreatePropertyBlob(&tmData, sizeof(tmData), &blobId); + if (ret) { + ALOGE("Failed to create tmData blob %d", ret); + return ret; + } + + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::oetf(const GsInterfaceType::IDpp::OetfData::ConfigType *config, + DrmDevice *drm, uint32_t &blobId) { + struct hdr_oetf_lut oetfLut; + + if (config == nullptr) { + ALOGE("no dpp OETF config"); + return -EINVAL; + } + + if ((config->tf_data.posx.size() != DRM_SAMSUNG_HDR_OETF_LUT_LEN) || + (config->tf_data.posy.size() != DRM_SAMSUNG_HDR_OETF_LUT_LEN)) { + ALOGE("%s: oetf pos size (%zu, %zu)", __func__, config->tf_data.posx.size(), + config->tf_data.posy.size()); + return -EINVAL; + } + + for (uint32_t i = 0; i < DRM_SAMSUNG_HDR_OETF_LUT_LEN; i++) { + oetfLut.posx[i] = config->tf_data.posx[i]; + oetfLut.posy[i] = config->tf_data.posy[i]; + } + int ret = drm->CreatePropertyBlob(&oetfLut, sizeof(oetfLut), &blobId); + if (ret) { + ALOGE("Failed to create oetf lut blob %d", ret); + return ret; + } + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::gammaMatrix( + const GsInterfaceType::IDqe::DqeMatrixData::ConfigType *config, DrmDevice *drm, + uint32_t &blobId) { + int ret = 0; + struct exynos_matrix gammaMatrix; + if ((ret = convertDqeMatrixDataToDrmMatrix(config->matrix_data, gammaMatrix, + DRM_SAMSUNG_MATRIX_DIMENS)) != NO_ERROR) { + ALOGE("Failed to convert gamma matrix"); + return ret; + } + ret = drm->CreatePropertyBlob(&gammaMatrix, sizeof(gammaMatrix), &blobId); + if (ret) { + ALOGE("Failed to create gamma matrix blob %d", ret); + return ret; + } + + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::degamma(const uint64_t drmLutSize, + const GsInterfaceType::IDqe::DegammaLutData::ConfigType *config, DrmDevice *drm, + uint32_t &blobId) { + if (config == nullptr) { + ALOGE("no degamma config"); + return -EINVAL; + } + using ConfigType = typename GsInterfaceType::IDqe::DegammaLutData::ConfigType; + if (drmLutSize != ConfigType::kLutLen) { + ALOGE("degamma lut size mismatch"); + return -EINVAL; + } + + struct drm_color_lut colorLut[ConfigType::kLutLen]; + for (uint32_t i = 0; i < ConfigType::kLutLen; i++) { + colorLut[i].red = config->values[i]; + } + int ret = drm->CreatePropertyBlob(colorLut, sizeof(colorLut), &blobId); + if (ret) { + ALOGE("Failed to create degamma lut blob %d", ret); + return ret; + } + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::linearMatrix( + const GsInterfaceType::IDqe::DqeMatrixData::ConfigType *config, DrmDevice *drm, + uint32_t &blobId) { + int ret = 0; + struct exynos_matrix linear_matrix; + if ((ret = convertDqeMatrixDataToDrmMatrix(config->matrix_data, linear_matrix, + DRM_SAMSUNG_MATRIX_DIMENS)) != NO_ERROR) { + ALOGE("Failed to convert linear matrix"); + return ret; + } + ret = drm->CreatePropertyBlob(&linear_matrix, sizeof(linear_matrix), &blobId); + if (ret) { + ALOGE("Failed to create linear matrix blob %d", ret); + return ret; + } + + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::cgc(const GsInterfaceType::IDqe::CgcData::ConfigType *config, + DrmDevice *drm, uint32_t &blobId) { + struct cgc_lut cgc; + if (config == nullptr) { + ALOGE("no CGC config"); + return -EINVAL; + } + + if ((config->r_values.size() != DRM_SAMSUNG_CGC_LUT_REG_CNT) || + (config->g_values.size() != DRM_SAMSUNG_CGC_LUT_REG_CNT) || + (config->b_values.size() != DRM_SAMSUNG_CGC_LUT_REG_CNT)) { + ALOGE("CGC data size is not same (r: %zu, g: %zu: b: %zu)", config->r_values.size(), + config->g_values.size(), config->b_values.size()); + return -EINVAL; + } + + for (uint32_t i = 0; i < DRM_SAMSUNG_CGC_LUT_REG_CNT; i++) { + cgc.r_values[i] = config->r_values[i]; + cgc.g_values[i] = config->g_values[i]; + cgc.b_values[i] = config->b_values[i]; + } + int ret = drm->CreatePropertyBlob(&cgc, sizeof(cgc_lut), &blobId); + if (ret) { + ALOGE("Failed to create cgc blob %d", ret); + return ret; + } + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::cgcDither( + const GsInterfaceType::IDqe::DqeControlData::ConfigType *config, DrmDevice *drm, + uint32_t &blobId) { + int ret = 0; + if (config->cgc_dither_override == false) { + blobId = 0; + return ret; + } + + ret = drm->CreatePropertyBlob((void *)&config->cgc_dither_reg, sizeof(config->cgc_dither_reg), + &blobId); + if (ret) { + ALOGE("Failed to create disp dither blob %d", ret); + return ret; + } + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::regamma( + const uint64_t drmLutSize, + const GsInterfaceType::IDqe::RegammaLutData::ConfigType *config, DrmDevice *drm, + uint32_t &blobId) { + if (config == nullptr) { + ALOGE("no regamma config"); + return -EINVAL; + } + + using ConfigType = typename GsInterfaceType::IDqe::RegammaLutData::ConfigType; + if (drmLutSize != ConfigType::kChannelLutLen) { + ALOGE("gamma lut size mismatch"); + return -EINVAL; + } + + struct drm_color_lut colorLut[ConfigType::kChannelLutLen]; + for (uint32_t i = 0; i < ConfigType::kChannelLutLen; i++) { + colorLut[i].red = config->r_values[i]; + colorLut[i].green = config->g_values[i]; + colorLut[i].blue = config->b_values[i]; + } + int ret = drm->CreatePropertyBlob(colorLut, sizeof(colorLut), &blobId); + if (ret) { + ALOGE("Failed to create gamma lut blob %d", ret); + return ret; + } + return NO_ERROR; +} + +int32_t ColorDrmBlobFactory::displayDither( + const GsInterfaceType::IDqe::DqeControlData::ConfigType *config, DrmDevice *drm, + uint32_t &blobId) { + int ret = 0; + if (config->disp_dither_override == false) { + blobId = 0; + return ret; + } + + ret = drm->CreatePropertyBlob((void *)&config->disp_dither_reg, sizeof(config->disp_dither_reg), + &blobId); + if (ret) { + ALOGE("Failed to create disp dither blob %d", ret); + return ret; + } + + return NO_ERROR; +} + +} // namespace gs diff --git a/libhwc2.1/libcolormanager/DisplayColorModule.h b/libhwc2.1/libcolormanager/DisplayColorModule.h new file mode 100644 index 0000000..f59009d --- /dev/null +++ b/libhwc2.1/libcolormanager/DisplayColorModule.h @@ -0,0 +1,57 @@ +/* + * 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. + */ + +#pragma once + +#include <gs101/displaycolor/displaycolor_gs101.h> +#include "DisplayColorLoader.h" +#include "drmdevice.h" + +namespace gs { + +static constexpr char kGsEntry[] = "GetDisplayColorGS101"; +class ColorDrmBlobFactory { + public: + using GsInterfaceType = displaycolor::IDisplayColorGS101; + using DcLoaderType = DisplayColorLoader<GsInterfaceType, kGsEntry>; + + static int32_t eotf(const GsInterfaceType::IDpp::EotfData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); + static int32_t gm(const GsInterfaceType::IDpp::GmData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); + static int32_t dtm(const GsInterfaceType::IDpp::DtmData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); + static int32_t oetf(const GsInterfaceType::IDpp::OetfData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); + static int32_t gammaMatrix(const GsInterfaceType::IDqe::DqeMatrixData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); + static int32_t degamma(const uint64_t drmLutSize, + const GsInterfaceType::IDqe::DegammaLutData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); + static int32_t linearMatrix(const GsInterfaceType::IDqe::DqeMatrixData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); + static int32_t cgc(const GsInterfaceType::IDqe::CgcData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); + static int32_t cgcDither(const GsInterfaceType::IDqe::DqeControlData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); + static int32_t regamma(const uint64_t drmLutSize, + const GsInterfaceType::IDqe::RegammaLutData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); + static int32_t displayDither(const GsInterfaceType::IDqe::DqeControlData::ConfigType *config, + android::DrmDevice *drm, uint32_t &blobId); +}; + +} // namespace gs diff --git a/libhwc2.1/libdevice/ExynosDeviceModule.cpp b/libhwc2.1/libdevice/ExynosDeviceModule.cpp index 678c474..2e01693 100644 --- a/libhwc2.1/libdevice/ExynosDeviceModule.cpp +++ b/libhwc2.1/libdevice/ExynosDeviceModule.cpp @@ -43,7 +43,7 @@ ExynosDeviceModule::~ExynosDeviceModule() { int ExynosDeviceModule::initDisplayColor( const std::vector<displaycolor::DisplayInfo>& display_info) { - mDisplayColorInterface = mDisplayColorLoader.GetDisplayColorGS101(display_info); + mDisplayColorInterface = mDisplayColorLoader.GetDisplayColor(display_info); if (mDisplayColorInterface == nullptr) { ALOGW("%s failed to load displaycolor", __func__); } diff --git a/libhwc2.1/libdevice/ExynosDeviceModule.h b/libhwc2.1/libdevice/ExynosDeviceModule.h index ba37e29..6c772b6 100644 --- a/libhwc2.1/libdevice/ExynosDeviceModule.h +++ b/libhwc2.1/libdevice/ExynosDeviceModule.h @@ -17,9 +17,7 @@ #ifndef EXYNOS_DEVICE_MODULE_H #define EXYNOS_DEVICE_MODULE_H -#include <gs101/displaycolor/displaycolor_gs101.h> - -#include "DisplayColorLoader.h" +#include "DisplayColorModule.h" #include "ExynosDevice.h" using namespace displaycolor; @@ -27,19 +25,20 @@ using namespace displaycolor; namespace gs101 { class ExynosDeviceModule : public ExynosDevice { + using GsInterfaceType = gs::ColorDrmBlobFactory::GsInterfaceType; public: ExynosDeviceModule(); virtual ~ExynosDeviceModule(); - IDisplayColorGS101* getDisplayColorInterface() { return mDisplayColorInterface; } + GsInterfaceType* getDisplayColorInterface() { return mDisplayColorInterface; } void setActiveDisplay(uint32_t index) { mActiveDisplay = index; } uint32_t getActiveDisplay() const { return mActiveDisplay; } private: int initDisplayColor(const std::vector<displaycolor::DisplayInfo>& display_info); - IDisplayColorGS101* mDisplayColorInterface; - DisplayColorLoader mDisplayColorLoader; + GsInterfaceType * mDisplayColorInterface; + gs::ColorDrmBlobFactory::DcLoaderType mDisplayColorLoader; uint32_t mActiveDisplay; }; diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp index 2969eea..2411e17 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp +++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp @@ -21,29 +21,6 @@ using BrightnessRange = BrightnessController::BrightnessRange; -template <typename T, typename M> -int32_t convertDqeMatrixDataToMatrix(T &colorMatrix, M &mat, - uint32_t dimension) { - if (colorMatrix.coeffs.size() != (dimension * dimension)) { - HWC_LOGE(nullptr, "Invalid coeff size(%zu)", - colorMatrix.coeffs.size()); - return -EINVAL; - } - for (uint32_t i = 0; i < (dimension * dimension); i++) { - mat.coeffs[i] = colorMatrix.coeffs[i]; - } - - if (colorMatrix.offsets.size() != dimension) { - HWC_LOGE(nullptr, "Invalid offset size(%zu)", - colorMatrix.offsets.size()); - return -EINVAL; - } - for (uint32_t i = 0; i < dimension; i++) { - mat.offsets[i] = colorMatrix.offsets[i]; - } - return NO_ERROR; -} - using namespace gs101; /////////////////////////////////////////////////// ExynosDisplayDrmInterfaceModule ////////////////////////////////////////////////////////////////// @@ -100,321 +77,12 @@ void ExynosDisplayDrmInterfaceModule::destroyOldBlobs( oldBlobs.clear(); } -int32_t ExynosDisplayDrmInterfaceModule::createCgcBlobFromIDqe( - const IDisplayColorGS101::IDqe &dqe, uint32_t &blobId) -{ - struct cgc_lut cgc; - const IDisplayColorGS101::IDqe::CgcData &cgcData = dqe.Cgc(); - - if (cgcData.config == nullptr) { - ALOGE("no CGC config"); - return -EINVAL; - } - - if ((cgcData.config->r_values.size() != DRM_SAMSUNG_CGC_LUT_REG_CNT) || - (cgcData.config->g_values.size() != DRM_SAMSUNG_CGC_LUT_REG_CNT) || - (cgcData.config->b_values.size() != DRM_SAMSUNG_CGC_LUT_REG_CNT)) { - ALOGE("CGC data size is not same (r: %zu, g: %zu: b: %zu)", - cgcData.config->r_values.size(), - cgcData.config->g_values.size(), - cgcData.config->b_values.size()); - return -EINVAL; - } - - for (uint32_t i = 0; i < DRM_SAMSUNG_CGC_LUT_REG_CNT; i++) { - cgc.r_values[i] = cgcData.config->r_values[i]; - cgc.g_values[i] = cgcData.config->g_values[i]; - cgc.b_values[i] = cgcData.config->b_values[i]; - } - int ret = mDrmDevice->CreatePropertyBlob(&cgc, sizeof(cgc_lut), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create cgc blob %d", ret); - return ret; - } - return NO_ERROR; -} - -int32_t ExynosDisplayDrmInterfaceModule::createDegammaLutBlobFromIDqe( - const IDisplayColorGS101::IDqe &dqe, uint32_t &blobId) -{ - int ret = 0; - uint64_t lut_size = 0; - - if (dqe.DegammaLut().config == nullptr) { - ALOGE("no degamma config"); - return -EINVAL; - } - - std::tie(ret, lut_size) = mDrmCrtc->degamma_lut_size_property().value(); - if (ret < 0) { - HWC_LOGE(mExynosDisplay, "%s: there is no degamma_lut_size (ret = %d)", - __func__, ret); - return ret; - } - if (lut_size != IDisplayColorGS101::IDqe::DegammaLutData::ConfigType::kLutLen) { - HWC_LOGE(mExynosDisplay, "%s: invalid lut size (%" PRId64 ")", - __func__, lut_size); - return -EINVAL; - } - - struct drm_color_lut color_lut[IDisplayColorGS101::IDqe::DegammaLutData::ConfigType::kLutLen]; - for (uint32_t i = 0; i < lut_size; i++) { - color_lut[i].red = dqe.DegammaLut().config->values[i]; - } - ret = mDrmDevice->CreatePropertyBlob(color_lut, sizeof(color_lut), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create degamma lut blob %d", ret); - return ret; - } - return NO_ERROR; -} - -int32_t ExynosDisplayDrmInterfaceModule::createRegammaLutBlobFromIDqe( - const IDisplayColorGS101::IDqe &dqe, uint32_t &blobId) -{ - int ret = 0; - uint64_t lut_size = 0; - - if (dqe.RegammaLut().config == nullptr) { - ALOGE("no regamma config"); - return -EINVAL; - } - - std::tie(ret, lut_size) = mDrmCrtc->gamma_lut_size_property().value(); - if (ret < 0) { - HWC_LOGE(mExynosDisplay, "%s: there is no gamma_lut_size (ret = %d)", - __func__, ret); - return ret; - } - if (lut_size != IDisplayColorGS101::IDqe::DegammaLutData::ConfigType::kLutLen) { - HWC_LOGE(mExynosDisplay, "%s: invalid lut size (%" PRId64 ")", - __func__, lut_size); - return -EINVAL; - } - - struct drm_color_lut color_lut[IDisplayColorGS101::IDqe::DegammaLutData::ConfigType::kLutLen]; - for (uint32_t i = 0; i < lut_size; i++) { - color_lut[i].red = dqe.RegammaLut().config->r_values[i]; - color_lut[i].green = dqe.RegammaLut().config->g_values[i]; - color_lut[i].blue = dqe.RegammaLut().config->b_values[i]; - } - ret = mDrmDevice->CreatePropertyBlob(color_lut, sizeof(color_lut), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create gamma lut blob %d", ret); - return ret; - } - return NO_ERROR; -} - -int32_t ExynosDisplayDrmInterfaceModule::createGammaMatBlobFromIDqe( - const IDisplayColorGS101::IDqe &dqe, uint32_t &blobId) -{ - int ret = 0; - struct exynos_matrix gamma_matrix; - if ((ret = convertDqeMatrixDataToMatrix( - dqe.GammaMatrix().config->matrix_data, gamma_matrix, DRM_SAMSUNG_MATRIX_DIMENS)) != NO_ERROR) - { - HWC_LOGE(mExynosDisplay, "Failed to convert gamma matrix"); - return ret; - } - ret = mDrmDevice->CreatePropertyBlob(&gamma_matrix, sizeof(gamma_matrix), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create gamma matrix blob %d", ret); - return ret; - } - - return NO_ERROR; -} - -int32_t ExynosDisplayDrmInterfaceModule::createLinearMatBlobFromIDqe( - const IDisplayColorGS101::IDqe &dqe, uint32_t &blobId) -{ - int ret = 0; - struct exynos_matrix linear_matrix; - if ((ret = convertDqeMatrixDataToMatrix( - dqe.LinearMatrix().config->matrix_data, linear_matrix, DRM_SAMSUNG_MATRIX_DIMENS)) != NO_ERROR) - { - HWC_LOGE(mExynosDisplay, "Failed to convert linear matrix"); - return ret; - } - ret = mDrmDevice->CreatePropertyBlob(&linear_matrix, sizeof(linear_matrix), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create linear matrix blob %d", ret); - return ret; - } - - return NO_ERROR; -} - -int32_t ExynosDisplayDrmInterfaceModule::createDispDitherBlobFromIDqe( - const IDisplayColorGS101::IDqe &dqe, uint32_t &blobId) -{ - int ret = 0; - const IDisplayColorGS101::IDqe::DqeControlData& dqeControl = dqe.DqeControl(); - if (dqeControl.config->disp_dither_override == false) { - blobId = 0; - return ret; - } - - ret = mDrmDevice->CreatePropertyBlob((void*)&dqeControl.config->disp_dither_reg, - sizeof(dqeControl.config->disp_dither_reg), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create disp dither blob %d", ret); - return ret; - } - - return NO_ERROR; -} - -int32_t ExynosDisplayDrmInterfaceModule::createCgcDitherBlobFromIDqe( - const IDisplayColorGS101::IDqe &dqe, uint32_t &blobId) -{ - int ret = 0; - const IDisplayColorGS101::IDqe::DqeControlData& dqeControl = dqe.DqeControl(); - if (dqeControl.config->cgc_dither_override == false) { - blobId = 0; - return ret; - } - - ret = mDrmDevice->CreatePropertyBlob((void*)&dqeControl.config->cgc_dither_reg, - sizeof(dqeControl.config->cgc_dither_reg), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create disp dither blob %d", ret); - return ret; - } - return NO_ERROR; -} - -int32_t ExynosDisplayDrmInterfaceModule::createEotfBlobFromIDpp( - const IDisplayColorGS101::IDpp &dpp, uint32_t &blobId) -{ - struct hdr_eotf_lut eotf_lut; - - if (dpp.EotfLut().config == nullptr) { - ALOGE("no dpp eotf config"); - return -EINVAL; - } - - if ((dpp.EotfLut().config->tf_data.posx.size() != DRM_SAMSUNG_HDR_EOTF_LUT_LEN) || - (dpp.EotfLut().config->tf_data.posy.size() != DRM_SAMSUNG_HDR_EOTF_LUT_LEN)) { - HWC_LOGE(mExynosDisplay, "%s: eotf pos size (%zu, %zu)", - __func__, dpp.EotfLut().config->tf_data.posx.size(), - dpp.EotfLut().config->tf_data.posy.size()); - return -EINVAL; - } - - for (uint32_t i = 0; i < DRM_SAMSUNG_HDR_EOTF_LUT_LEN; i++) { - eotf_lut.posx[i] = dpp.EotfLut().config->tf_data.posx[i]; - eotf_lut.posy[i] = dpp.EotfLut().config->tf_data.posy[i]; - } - int ret = mDrmDevice->CreatePropertyBlob(&eotf_lut, sizeof(eotf_lut), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create eotf lut blob %d", ret); - return ret; - } - return NO_ERROR; -} - -int32_t ExynosDisplayDrmInterfaceModule::createGmBlobFromIDpp( - const IDisplayColorGS101::IDpp &dpp, uint32_t &blobId) -{ - int ret = 0; - struct hdr_gm_data gm_matrix; - - if (dpp.Gm().config == nullptr) { - ALOGE("no dpp GM config"); - return -EINVAL; - } - - if ((ret = convertDqeMatrixDataToMatrix(dpp.Gm().config->matrix_data, gm_matrix, - DRM_SAMSUNG_HDR_GM_DIMENS)) != NO_ERROR) - { - HWC_LOGE(mExynosDisplay, "Failed to convert gm matrix"); - return ret; - } - ret = mDrmDevice->CreatePropertyBlob(&gm_matrix, sizeof(gm_matrix), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create gm matrix blob %d", ret); - return ret; - } - return NO_ERROR; -} - -int32_t ExynosDisplayDrmInterfaceModule::createDtmBlobFromIDpp( - const IDisplayColorGS101::IDpp &dpp, uint32_t &blobId) -{ - struct hdr_tm_data tm_data; - - if (dpp.Dtm().config == nullptr) { - ALOGE("no dpp DTM config"); - return -EINVAL; - } - - if ((dpp.Dtm().config->tf_data.posx.size() != DRM_SAMSUNG_HDR_TM_LUT_LEN) || - (dpp.Dtm().config->tf_data.posy.size() != DRM_SAMSUNG_HDR_TM_LUT_LEN)) { - HWC_LOGE(mExynosDisplay, "%s: dtm pos size (%zu, %zu)", - __func__, dpp.Dtm().config->tf_data.posx.size(), - dpp.Dtm().config->tf_data.posy.size()); - return -EINVAL; - } - - for (uint32_t i = 0; i < DRM_SAMSUNG_HDR_TM_LUT_LEN; i++) { - tm_data.posx[i] = dpp.Dtm().config->tf_data.posx[i]; - tm_data.posy[i] = dpp.Dtm().config->tf_data.posy[i]; - } - - tm_data.coeff_r = dpp.Dtm().config->coeff_r; - tm_data.coeff_g = dpp.Dtm().config->coeff_g; - tm_data.coeff_b = dpp.Dtm().config->coeff_b; - tm_data.rng_x_min = dpp.Dtm().config->rng_x_min; - tm_data.rng_x_max = dpp.Dtm().config->rng_x_max; - tm_data.rng_y_min = dpp.Dtm().config->rng_y_min; - tm_data.rng_y_max = dpp.Dtm().config->rng_y_max; - - int ret = mDrmDevice->CreatePropertyBlob(&tm_data, sizeof(tm_data), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create tm_data blob %d", ret); - return ret; - } - - return NO_ERROR; -} -int32_t ExynosDisplayDrmInterfaceModule::createOetfBlobFromIDpp( - const IDisplayColorGS101::IDpp &dpp, uint32_t &blobId) -{ - struct hdr_oetf_lut oetf_lut; - - if (dpp.OetfLut().config == nullptr) { - ALOGE("no dpp OETF config"); - return -EINVAL; - } - - if ((dpp.OetfLut().config->tf_data.posx.size() != DRM_SAMSUNG_HDR_OETF_LUT_LEN) || - (dpp.OetfLut().config->tf_data.posy.size() != DRM_SAMSUNG_HDR_OETF_LUT_LEN)) { - HWC_LOGE(mExynosDisplay, "%s: oetf pos size (%zu, %zu)", - __func__, dpp.OetfLut().config->tf_data.posx.size(), - dpp.OetfLut().config->tf_data.posy.size()); - return -EINVAL; - } - - for (uint32_t i = 0; i < DRM_SAMSUNG_HDR_OETF_LUT_LEN; i++) { - oetf_lut.posx[i] = dpp.OetfLut().config->tf_data.posx[i]; - oetf_lut.posy[i] = dpp.OetfLut().config->tf_data.posy[i]; - } - int ret = mDrmDevice->CreatePropertyBlob(&oetf_lut, sizeof(oetf_lut), &blobId); - if (ret) { - HWC_LOGE(mExynosDisplay, "Failed to create oetf lut blob %d", ret); - return ret; - } - return NO_ERROR; -} - template<typename StageDataType> int32_t ExynosDisplayDrmInterfaceModule::setDisplayColorBlob( const DrmProperty &prop, const uint32_t type, const StageDataType &stage, - const IDisplayColorGS101::IDqe &dqe, + const typename GsInterfaceType::IDqe &dqe, ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq) { /* dirty bit is valid only if enable is true */ @@ -425,29 +93,47 @@ int32_t ExynosDisplayDrmInterfaceModule::setDisplayColorBlob( int32_t ret = 0; uint32_t blobId = 0; + uint64_t lutSize; if (stage.enable) { switch (type) { case DqeBlobs::CGC: - ret = createCgcBlobFromIDqe(dqe, blobId); + ret = gs::ColorDrmBlobFactory::cgc(dqe.Cgc().config, mDrmDevice, blobId); break; case DqeBlobs::DEGAMMA_LUT: - ret = createDegammaLutBlobFromIDqe(dqe, blobId); + std::tie(ret, lutSize) = mDrmCrtc->degamma_lut_size_property().value(); + if (ret < 0) { + HWC_LOGE(mExynosDisplay, "%s: there is no degamma_lut_size (ret = %d)", + __func__, ret); + } else { + ret = gs::ColorDrmBlobFactory::degamma(lutSize, dqe.DegammaLut().config, + mDrmDevice, blobId); + } break; case DqeBlobs::REGAMMA_LUT: - ret = createRegammaLutBlobFromIDqe(dqe, blobId); + std::tie(ret, lutSize) = mDrmCrtc->gamma_lut_size_property().value(); + if (ret < 0) { + HWC_LOGE(mExynosDisplay, "%s: there is no gamma_lut_size (ret = %d)", __func__, + ret); + } else { + ret = gs::ColorDrmBlobFactory::regamma(lutSize, dqe.RegammaLut().config, + mDrmDevice, blobId); + } break; case DqeBlobs::GAMMA_MAT: - ret = createGammaMatBlobFromIDqe(dqe, blobId); + ret = gs::ColorDrmBlobFactory::gammaMatrix(dqe.GammaMatrix().config, mDrmDevice, + blobId); break; case DqeBlobs::LINEAR_MAT: - ret = createLinearMatBlobFromIDqe(dqe, blobId); + ret = gs::ColorDrmBlobFactory::linearMatrix(dqe.LinearMatrix().config, mDrmDevice, + blobId); break; case DqeBlobs::DISP_DITHER: - ret = createDispDitherBlobFromIDqe(dqe, blobId); + ret = gs::ColorDrmBlobFactory::displayDither(dqe.DqeControl().config, mDrmDevice, + blobId); break; case DqeBlobs::CGC_DITHER: - ret = createCgcDitherBlobFromIDqe(dqe, blobId); + ret = gs::ColorDrmBlobFactory::cgcDither(dqe.DqeControl().config, mDrmDevice, blobId); break; default: ret = -EINVAL; @@ -488,7 +174,7 @@ int32_t ExynosDisplayDrmInterfaceModule::setDisplayColorSetting( (ExynosPrimaryDisplayModule*)mExynosDisplay; int ret = NO_ERROR; - const IDisplayColorGS101::IDqe &dqe = display->getDqe(); + const typename GsInterfaceType::IDqe &dqe = display->getDqe(); if ((mDrmCrtc->cgc_lut_property().id() != 0) && (ret = setDisplayColorBlob(mDrmCrtc->cgc_lut_property(), @@ -563,7 +249,7 @@ int32_t ExynosDisplayDrmInterfaceModule::setPlaneColorBlob( const DrmProperty &prop, const uint32_t type, const StageDataType &stage, - const IDisplayColorGS101::IDpp &dpp, + const typename GsInterfaceType::IDpp &dpp, const uint32_t dppIndex, ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq, bool forceUpdate) @@ -590,16 +276,16 @@ int32_t ExynosDisplayDrmInterfaceModule::setPlaneColorBlob( if (stage.enable) { switch (type) { case DppBlobs::EOTF: - ret = createEotfBlobFromIDpp(dpp, blobId); + ret = gs::ColorDrmBlobFactory::eotf(dpp.EotfLut().config, mDrmDevice, blobId); break; case DppBlobs::GM: - ret = createGmBlobFromIDpp(dpp, blobId); + ret = gs::ColorDrmBlobFactory::gm(dpp.Gm().config, mDrmDevice, blobId); break; case DppBlobs::DTM: - ret = createDtmBlobFromIDpp(dpp, blobId); + ret = gs::ColorDrmBlobFactory::dtm(dpp.Dtm().config, mDrmDevice, blobId); break; case DppBlobs::OETF: - ret = createOetfBlobFromIDpp(dpp, blobId); + ret = gs::ColorDrmBlobFactory::oetf(dpp.OetfLut().config, mDrmDevice, blobId); break; default: ret = -EINVAL; @@ -681,7 +367,7 @@ int32_t ExynosDisplayDrmInterfaceModule::setPlaneColorSetting( } } - const IDisplayColorGS101::IDpp &dpp = display->getDppForLayer(mppSource); + const typename GsInterfaceType::IDpp &dpp = display->getDppForLayer(mppSource); const uint32_t dppIndex = static_cast<uint32_t>(display->getDppIndexForLayer(mppSource)); bool planeChanged = display->checkAndSaveLayerPlaneId(mppSource, plane->id()); diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h index f783c5f..1a7afb5 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h +++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h @@ -17,9 +17,8 @@ #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 "DisplayColorModule.h" #include "ExynosDisplayDrmInterface.h" namespace gs101 { @@ -27,6 +26,7 @@ namespace gs101 { using namespace displaycolor; class ExynosDisplayDrmInterfaceModule : public ExynosDisplayDrmInterface { + using GsInterfaceType = gs::ColorDrmBlobFactory::GsInterfaceType; public: ExynosDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay); virtual ~ExynosDisplayDrmInterfaceModule(); @@ -44,31 +44,6 @@ class ExynosDisplayDrmInterfaceModule : public ExynosDisplayDrmInterface { 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 */ @@ -141,7 +116,7 @@ class ExynosDisplayDrmInterfaceModule : public ExynosDisplayDrmInterface { const DrmProperty &prop, const uint32_t type, const StageDataType &stage, - const IDisplayColorGS101::IDqe &dqe, + const typename GsInterfaceType::IDqe &dqe, ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq); template<typename StageDataType> int32_t setPlaneColorBlob( @@ -149,7 +124,7 @@ class ExynosDisplayDrmInterfaceModule : public ExynosDisplayDrmInterface { const DrmProperty &prop, const uint32_t type, const StageDataType &stage, - const IDisplayColorGS101::IDpp &dpp, + const typename GsInterfaceType::IDpp &dpp, const uint32_t dppIndex, ExynosDisplayDrmInterface::DrmModeAtomicReq &drmReq, bool forceUpdate); diff --git a/libhwc2.1/libmaindisplay/DisplayColorLoader.h b/libhwc2.1/libmaindisplay/DisplayColorLoader.h deleted file mode 100644 index e5a241d..0000000 --- a/libhwc2.1/libmaindisplay/DisplayColorLoader.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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 DISPLAY_COLOR_LOADER_H -#define DISPLAY_COLOR_LOADER_H - -#include <dlfcn.h> -#include <gs101/displaycolor/displaycolor_gs101.h> -#include <log/log.h> -#include <string> -#include <vector> - -namespace gs101 { - -class DisplayColorLoader { - public: - DisplayColorLoader(const char *lib_name) { - lib_handle = dlopen(lib_name, RTLD_LAZY); - - if (lib_handle != nullptr) { - const displaycolor::DisplayColorIntfVer *(*get_version)(); - get_version = (decltype(get_version)) - dlsym(lib_handle, "GetInterfaceVersion"); - if (get_version == nullptr) { - ALOGE("%s: prebuilt lib is not versioned", __func__); - } else { - auto intf_ver = get_version(); - - if (intf_ver != nullptr && - displaycolor::kInterfaceVersion.Compatible(*intf_ver)) { - get_display_color_gs101 = - (decltype(get_display_color_gs101))dlsym(lib_handle, - "GetDisplayColorGS101"); - - if (get_display_color_gs101 == nullptr) { - ALOGE("%s: failed to get GetDisplayColorGS101\n", __func__); - } else if (!(displaycolor::kInterfaceVersion == *intf_ver)) { - ALOGW("%s: different hwc/displaycolor patch level %u.%u.%u/%u", - __func__, - intf_ver->major, - intf_ver->minor, - displaycolor::kInterfaceVersion.patch, - intf_ver->patch); - } - } else { - if (intf_ver != nullptr) { - ALOGE("%s: prebuilt lib version %u.%u.%u expected %u.%u.%u", - __func__, - intf_ver->major, - intf_ver->minor, - intf_ver->patch, - displaycolor::kInterfaceVersion.major, - displaycolor::kInterfaceVersion.minor, - displaycolor::kInterfaceVersion.patch); - } else { - ALOGE("%s: prebult lib get_version returns null", __func__); - } - } - } - } else { - ALOGE("%s: failed to load library %s\n", __func__, lib_name); - get_display_color_gs101 = nullptr; - } - } - - displaycolor::IDisplayColorGS101 *GetDisplayColorGS101( - const std::vector<displaycolor::DisplayInfo> &display_info) { - if (get_display_color_gs101 != nullptr) { - return get_display_color_gs101(display_info); - } - - return nullptr; - } - - ~DisplayColorLoader() { - if (lib_handle != nullptr) { - dlclose(lib_handle); - } - } - - private: - void *lib_handle; - displaycolor::IDisplayColorGS101 *(*get_display_color_gs101)( - const std::vector<displaycolor::DisplayInfo> &); -}; - -} // namespace gs101 - -#endif //DISPLAY_COLOR_LOADER_H diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp index a7ae2c3..9ae4647 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp @@ -123,7 +123,7 @@ void ExynosPrimaryDisplayModule::doPreProcessing() { int32_t ExynosPrimaryDisplayModule::getColorModes( uint32_t* outNumModes, int32_t* outModes) { - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); const DisplayType display = getDisplayTypeFromIndex(mIndex); const ColorModesMap colorModeMap = displayColorInterface == nullptr ? ColorModesMap() @@ -153,7 +153,7 @@ int32_t ExynosPrimaryDisplayModule::getColorModes( int32_t ExynosPrimaryDisplayModule::setColorMode(int32_t mode) { ALOGD("%s: mode(%d)", __func__, mode); - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); const DisplayType display = getDisplayTypeFromIndex(mIndex); const ColorModesMap colorModeMap = displayColorInterface == nullptr ? ColorModesMap() @@ -177,7 +177,7 @@ int32_t ExynosPrimaryDisplayModule::setColorMode(int32_t mode) int32_t ExynosPrimaryDisplayModule::getRenderIntents(int32_t mode, uint32_t* outNumIntents, int32_t* outIntents) { - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); const DisplayType display = getDisplayTypeFromIndex(mIndex); const ColorModesMap colorModeMap = displayColorInterface == nullptr ? ColorModesMap() @@ -214,7 +214,7 @@ int32_t ExynosPrimaryDisplayModule::getRenderIntents(int32_t mode, int32_t ExynosPrimaryDisplayModule::setColorModeWithRenderIntent(int32_t mode, int32_t intent) { - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); const DisplayType display = getDisplayTypeFromIndex(mIndex); const ColorModesMap colorModeMap = displayColorInterface == nullptr ? ColorModesMap() @@ -270,7 +270,7 @@ int32_t ExynosPrimaryDisplayModule::setColorTransform( int32_t ExynosPrimaryDisplayModule::getClientTargetProperty( hwc_client_target_property_t* outClientTargetProperty, HwcDimmingStage *outDimmingStage) { - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); if (displayColorInterface == nullptr) { ALOGI("%s dc interface not created", __func__); return ExynosDisplay::getClientTargetProperty(outClientTargetProperty); @@ -361,7 +361,7 @@ int32_t ExynosPrimaryDisplayModule::setLayersColorData() bool ExynosPrimaryDisplayModule::hasDppForLayer(ExynosMPPSource* layer) { - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); if (displayColorInterface == nullptr) { return false; } @@ -380,10 +380,10 @@ bool ExynosPrimaryDisplayModule::hasDppForLayer(ExynosMPPSource* layer) return true; } -const IDisplayColorGS101::IDpp& ExynosPrimaryDisplayModule::getDppForLayer(ExynosMPPSource* layer) -{ +const ExynosPrimaryDisplayModule::GsInterfaceType::IDpp& ExynosPrimaryDisplayModule::getDppForLayer( + ExynosMPPSource* layer) { uint32_t index = mDisplaySceneInfo.layerDataMappingInfo[layer].dppIdx; - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); const DisplayType display = getDisplayTypeFromIndex(mIndex); return displayColorInterface->GetPipelineData(display)->Dpp()[index].get(); } @@ -402,7 +402,7 @@ int ExynosPrimaryDisplayModule::deliverWinConfigData() int ret = 0; ExynosDisplayDrmInterfaceModule *moduleDisplayInterface = (ExynosDisplayDrmInterfaceModule*)(mDisplayInterface.get()); - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); bool forceDisplayColorSetting = false; if (!mDisplaySceneInfo.displaySettingDelivered || isForceColorUpdate()) @@ -679,7 +679,7 @@ int32_t ExynosPrimaryDisplayModule::DisplaySceneInfo::setLayerColorData( int32_t ExynosPrimaryDisplayModule::updateColorConversionInfo() { int ret = 0; - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); if (displayColorInterface == nullptr) { return ret; } @@ -714,7 +714,7 @@ int32_t ExynosPrimaryDisplayModule::updateColorConversionInfo() int32_t ExynosPrimaryDisplayModule::updatePresentColorConversionInfo() { int ret = NO_ERROR; - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); if (displayColorInterface == nullptr) { return ret; } @@ -739,7 +739,7 @@ int32_t ExynosPrimaryDisplayModule::updatePresentColorConversionInfo() } int32_t ExynosPrimaryDisplayModule::getColorAdjustedDbv(uint32_t &dbv_adj) { - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); if (displayColorInterface == nullptr) { return NO_ERROR; } @@ -1169,6 +1169,6 @@ bool ExynosPrimaryDisplayModule::isDisplaySwitched(int32_t mode, int32_t prevMod bool ExynosPrimaryDisplayModule::isColorCalibratedByDevice() { const DisplayType display = getDisplayTypeFromIndex(mIndex); - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); return displayColorInterface->GetCalibrationInfo(display).factory_cal_loaded; }; diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h index 6b326ae..bdea07e 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h @@ -16,8 +16,6 @@ #ifndef EXYNOS_DISPLAY_MODULE_H #define EXYNOS_DISPLAY_MODULE_H -#include <gs101/displaycolor/displaycolor_gs101.h> - #include "ExynosDeviceModule.h" #include "ExynosDisplay.h" #include "ExynosLayer.h" @@ -96,6 +94,7 @@ namespace gs101 { using namespace displaycolor; class ExynosPrimaryDisplayModule : public ExynosPrimaryDisplay { + using GsInterfaceType = gs::ColorDrmBlobFactory::GsInterfaceType; public: ExynosPrimaryDisplayModule(uint32_t index, ExynosDevice *device); ~ExynosPrimaryDisplayModule(); @@ -119,7 +118,7 @@ class ExynosPrimaryDisplayModule : public ExynosPrimaryDisplay { virtual int32_t updatePresentColorConversionInfo(); virtual bool checkRrCompensationEnabled() { const DisplayType display = getDisplayTypeFromIndex(mIndex); - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); return displayColorInterface ? displayColorInterface->IsRrCompensationEnabled(display) : false; @@ -228,13 +227,13 @@ class ExynosPrimaryDisplayModule : public ExynosPrimaryDisplay { }; bool hasDisplayColor() { - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); return displayColorInterface != nullptr; } /* Call getDppForLayer() only if hasDppForLayer() is true */ bool hasDppForLayer(ExynosMPPSource* layer); - const IDisplayColorGS101::IDpp& getDppForLayer(ExynosMPPSource* layer); + const GsInterfaceType::IDpp& getDppForLayer(ExynosMPPSource* layer); int32_t getDppIndexForLayer(ExynosMPPSource* layer); /* Check if layer's assigned plane id has changed, save the new planeId. * call only if hasDppForLayer is true */ @@ -247,14 +246,14 @@ class ExynosPrimaryDisplayModule : public ExynosPrimaryDisplay { size_t getNumOfDpp() { const DisplayType display = getDisplayTypeFromIndex(mIndex); - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); return displayColorInterface->GetPipelineData(display)->Dpp().size(); }; - const IDisplayColorGS101::IDqe& getDqe() + const GsInterfaceType::IDqe& getDqe() { const DisplayType display = getDisplayTypeFromIndex(mIndex); - IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + GsInterfaceType* displayColorInterface = getDisplayColorInterface(); return displayColorInterface->GetPipelineData(display)->Dqe(); }; @@ -297,7 +296,7 @@ class ExynosPrimaryDisplayModule : public ExynosPrimaryDisplay { return false; }; - IDisplayColorGS101* getDisplayColorInterface() { + GsInterfaceType* getDisplayColorInterface() { ExynosDeviceModule* device = (ExynosDeviceModule*)mDevice; return device->getDisplayColorInterface(); } diff --git a/libhwc2.1/libresource/ExynosMPPModule.cpp b/libhwc2.1/libresource/ExynosMPPModule.cpp index bc435ad..357c61a 100644 --- a/libhwc2.1/libresource/ExynosMPPModule.cpp +++ b/libhwc2.1/libresource/ExynosMPPModule.cpp @@ -77,10 +77,8 @@ int32_t ExynosMPPModule::setColorConversionInfo() } MPP_LOGD(eDebugColorManagement, "%s, src: 0x%8x", __func__, mppSource->mSrcImg.dataSpace); - const IDisplayColorGS101::IDpp& dpp = - primaryDisplay->getDppForLayer(layer); - mppLayer->setLayerData((void *)&dpp, - sizeof(IDisplayColorGS101::IDpp)); + const auto& dpp = primaryDisplay->getDppForLayer(layer); + mppLayer->setLayerData((void *)&dpp, sizeof(dpp)); } return NO_ERROR; } |