diff options
author | Weizhung Ding <weizhungding@google.com> | 2021-03-09 04:08:29 +0800 |
---|---|---|
committer | Weizhung Ding <weizhungding@google.com> | 2021-09-11 10:01:47 +0800 |
commit | 87ebb8e3e05b6ca71b080a6a33fc7149c5dd9914 (patch) | |
tree | 8df476d544e6e861a89be7bbe9a0283a6d77e15a | |
parent | d6a0f1e668c8a76dbcdbb538ee753fefd2c67961 (diff) | |
download | gs101-87ebb8e3e05b6ca71b080a6a33fc7149c5dd9914.tar.gz |
libhwc2.1: Support two pipeline for displaycolor
Support two pipeline for displaycolor and move
mDisplayColorInterface to ExynosDeviceModule
Bug: 181262509
Test: switch display and check the color effect
Change-Id: Ie99009295efef937fd4816e872c22ce2667805a6
6 files changed, 125 insertions, 75 deletions
diff --git a/libhwc2.1/libdevice/ExynosDeviceModule.cpp b/libhwc2.1/libdevice/ExynosDeviceModule.cpp index 202ae23..b8d31da 100644 --- a/libhwc2.1/libdevice/ExynosDeviceModule.cpp +++ b/libhwc2.1/libdevice/ExynosDeviceModule.cpp @@ -16,15 +16,35 @@ #include "ExynosDeviceModule.h" +#include "ExynosDisplayDrmInterfaceModule.h" + extern struct exynos_hwc_control exynosHWCControl; using namespace gs101; -ExynosDeviceModule::ExynosDeviceModule() - : ExynosDevice() -{ +ExynosDeviceModule::ExynosDeviceModule() : ExynosDevice(), mDisplayColorLoader(DISPLAY_COLOR_LIB) { exynosHWCControl.skipStaticLayers = false; + + std::vector<displaycolor::DisplayInfo> display_info; + for (uint32_t i = 0; i < mDisplays.size(); i++) { + ExynosDisplay* display = mDisplays[i]; + ExynosDisplayDrmInterfaceModule* moduleDisplayInterface = + (ExynosDisplayDrmInterfaceModule*)(display->mDisplayInterface.get()); + + moduleDisplayInterface->getDisplayInfo(display_info); + } + initDisplayColor(display_info); } ExynosDeviceModule::~ExynosDeviceModule() { } + +int ExynosDeviceModule::initDisplayColor( + const std::vector<displaycolor::DisplayInfo>& display_info) { + mDisplayColorInterface = mDisplayColorLoader.GetDisplayColorGS101(display_info); + if (mDisplayColorInterface == nullptr) { + ALOGW("%s failed to load displaycolor", __func__); + } + + return NO_ERROR; +} diff --git a/libhwc2.1/libdevice/ExynosDeviceModule.h b/libhwc2.1/libdevice/ExynosDeviceModule.h index 47523d5..b86e01c 100644 --- a/libhwc2.1/libdevice/ExynosDeviceModule.h +++ b/libhwc2.1/libdevice/ExynosDeviceModule.h @@ -17,8 +17,13 @@ #ifndef EXYNOS_DEVICE_MODULE_H #define EXYNOS_DEVICE_MODULE_H +#include <gs101/displaycolor/displaycolor_gs101.h> + +#include "DisplayColorLoader.h" #include "ExynosDevice.h" +using namespace displaycolor; + namespace gs101 { class ExynosDeviceModule : public ExynosDevice { @@ -26,6 +31,13 @@ class ExynosDeviceModule : public ExynosDevice { ExynosDeviceModule(); virtual ~ExynosDeviceModule(); + IDisplayColorGS101* getDisplayColorInterface() { return mDisplayColorInterface; } + + private: + int initDisplayColor(const std::vector<displaycolor::DisplayInfo>& display_info); + + IDisplayColorGS101* mDisplayColorInterface; + DisplayColorLoader mDisplayColorLoader; }; } // namespace gs101 diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp index 93322a4..dcf7cc3 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp +++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.cpp @@ -79,30 +79,6 @@ int32_t ExynosDisplayDrmInterfaceModule::initDrmDevice(DrmDevice *drmDevice) mOldDqeBlobs.init(drmDevice); - ExynosPrimaryDisplayModule* display = - (ExynosPrimaryDisplayModule*)mExynosDisplay; - - std::vector<displaycolor::DisplayInfo> display_info; - displaycolor::DisplayInfo primary_display; - auto &tb = primary_display.brightness_table; - - tb.nbm_nits_min = mBrightnessTable[BrightnessRange::NORMAL].mNitsStart; - tb.nbm_nits_max = mBrightnessTable[BrightnessRange::NORMAL].mNitsEnd; - tb.nbm_dbv_min = mBrightnessTable[BrightnessRange::NORMAL].mBklStart; - tb.nbm_dbv_max = mBrightnessTable[BrightnessRange::NORMAL].mBklEnd; - - tb.hbm_nits_min = mBrightnessTable[BrightnessRange::HBM].mNitsStart; - tb.hbm_nits_max = mBrightnessTable[BrightnessRange::HBM].mNitsEnd; - tb.hbm_dbv_min = mBrightnessTable[BrightnessRange::HBM].mBklStart; - tb.hbm_dbv_max = mBrightnessTable[BrightnessRange::HBM].mBklEnd; - - display_info.push_back(primary_display); - ret = display->initDisplayColor(display_info); - if (ret != NO_ERROR) { - HWC_LOGE(mExynosDisplay, "Failed to load displaycolor %d", ret); - return ret; - } - initOldDppBlobs(drmDevice); if (mDrmCrtc->force_bpc_property().id()) parseBpcEnums(mDrmCrtc->force_bpc_property()); @@ -767,6 +743,24 @@ uint32_t ExynosDisplayDrmInterfaceModule::SaveBlob::getBlob(uint32_t type) return blobs[type]; } +void ExynosDisplayDrmInterfaceModule::getDisplayInfo( + std::vector<displaycolor::DisplayInfo> &display_info) { + displaycolor::DisplayInfo primary_display; + auto &tb = primary_display.brightness_table; + + tb.nbm_nits_min = mBrightnessTable[BrightnessRange::NORMAL].mNitsStart; + tb.nbm_nits_max = mBrightnessTable[BrightnessRange::NORMAL].mNitsEnd; + tb.nbm_dbv_min = mBrightnessTable[BrightnessRange::NORMAL].mBklStart; + tb.nbm_dbv_max = mBrightnessTable[BrightnessRange::NORMAL].mBklEnd; + + tb.hbm_nits_min = mBrightnessTable[BrightnessRange::HBM].mNitsStart; + tb.hbm_nits_max = mBrightnessTable[BrightnessRange::HBM].mNitsEnd; + tb.hbm_dbv_min = mBrightnessTable[BrightnessRange::HBM].mBklStart; + tb.hbm_dbv_max = mBrightnessTable[BrightnessRange::HBM].mBklEnd; + + display_info.push_back(primary_display); +} + //////////////////////////////////////////////////// ExynosPrimaryDisplayDrmInterfaceModule ////////////////////////////////////////////////////////////////// ExynosPrimaryDisplayDrmInterfaceModule::ExynosPrimaryDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay) : ExynosDisplayDrmInterfaceModule(exynosDisplay) diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h index d0d1b46..0ba995a 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h +++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterfaceModule.h @@ -66,6 +66,9 @@ class ExynosDisplayDrmInterfaceModule : public ExynosDisplayDrmInterface { uint32_t &blobId); int32_t createOetfBlobFromIDpp(const IDisplayColorGS101::IDpp &dpp, uint32_t &blobId); + + void getDisplayInfo(std::vector<displaycolor::DisplayInfo> &display_info); + protected: class SaveBlob { public: diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp index ac57c4e..d61b62a 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.cpp @@ -47,24 +47,13 @@ inline bool operator==(const ExynosPrimaryDisplayModule::DisplaySceneInfo::Layer return lm1.dppIdx == lm2.dppIdx && lm1.planeId == lm2.planeId; } -ExynosPrimaryDisplayModule::ExynosPrimaryDisplayModule(uint32_t index, ExynosDevice *device) - : ExynosPrimaryDisplay(index, device), mDisplayColorLoader(DISPLAY_COLOR_LIB) -{ +ExynosPrimaryDisplayModule::ExynosPrimaryDisplayModule(uint32_t index, ExynosDevice* device) + : ExynosPrimaryDisplay(index, device) { #ifdef FORCE_GPU_COMPOSITION exynosHWCControl.forceGpu = true; #endif } -int ExynosPrimaryDisplayModule::initDisplayColor( - const std::vector<displaycolor::DisplayInfo>& display_info) { - mDisplayColorInterface = mDisplayColorLoader.GetDisplayColorGS101(display_info); - if (mDisplayColorInterface == nullptr) { - ALOGW("%s failed to load displaycolor", __func__); - } - - return NO_ERROR; -} - ExynosPrimaryDisplayModule::~ExynosPrimaryDisplayModule () { } @@ -133,9 +122,11 @@ void ExynosPrimaryDisplayModule::doPreProcessing() { int32_t ExynosPrimaryDisplayModule::getColorModes( uint32_t* outNumModes, int32_t* outModes) { - const ColorModesMap colorModeMap = - mDisplayColorInterface == nullptr ? ColorModesMap() : - mDisplayColorInterface->ColorModesAndRenderIntents(DisplayType::DISPLAY_PRIMARY); + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + const DisplayType display = getDisplayTypeFromIndex(mIndex); + const ColorModesMap colorModeMap = displayColorInterface == nullptr + ? ColorModesMap() + : displayColorInterface->ColorModesAndRenderIntents(display); ALOGD("%s: size(%zu)", __func__, colorModeMap.size()); if (outModes == nullptr) { *outNumModes = colorModeMap.size(); @@ -161,9 +152,11 @@ int32_t ExynosPrimaryDisplayModule::getColorModes( int32_t ExynosPrimaryDisplayModule::setColorMode(int32_t mode) { ALOGD("%s: mode(%d)", __func__, mode); - const ColorModesMap colorModeMap = - mDisplayColorInterface == nullptr ? ColorModesMap() : - mDisplayColorInterface->ColorModesAndRenderIntents(DisplayType::DISPLAY_PRIMARY); + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + const DisplayType display = getDisplayTypeFromIndex(mIndex); + const ColorModesMap colorModeMap = displayColorInterface == nullptr + ? ColorModesMap() + : displayColorInterface->ColorModesAndRenderIntents(display); hwc::ColorMode colorMode = static_cast<hwc::ColorMode>(mode); const auto it = colorModeMap.find(colorMode); @@ -183,9 +176,11 @@ int32_t ExynosPrimaryDisplayModule::setColorMode(int32_t mode) int32_t ExynosPrimaryDisplayModule::getRenderIntents(int32_t mode, uint32_t* outNumIntents, int32_t* outIntents) { - const ColorModesMap colorModeMap = - mDisplayColorInterface == nullptr ? ColorModesMap() : - mDisplayColorInterface->ColorModesAndRenderIntents(DisplayType::DISPLAY_PRIMARY); + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + const DisplayType display = getDisplayTypeFromIndex(mIndex); + const ColorModesMap colorModeMap = displayColorInterface == nullptr + ? ColorModesMap() + : displayColorInterface->ColorModesAndRenderIntents(display); ALOGD("%s, size(%zu)", __func__, colorModeMap.size()); hwc::ColorMode colorMode = static_cast<hwc::ColorMode>(mode); @@ -219,9 +214,11 @@ int32_t ExynosPrimaryDisplayModule::setColorModeWithRenderIntent(int32_t mode, int32_t intent) { ALOGD("%s: mode(%d), intent(%d)", __func__, mode, intent); - const ColorModesMap colorModeMap = - mDisplayColorInterface == nullptr ? ColorModesMap() : - mDisplayColorInterface->ColorModesAndRenderIntents(DisplayType::DISPLAY_PRIMARY); + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + const DisplayType display = getDisplayTypeFromIndex(mIndex); + const ColorModesMap colorModeMap = displayColorInterface == nullptr + ? ColorModesMap() + : displayColorInterface->ColorModesAndRenderIntents(display); hwc::ColorMode colorMode = static_cast<hwc::ColorMode>(mode); hwc::RenderIntent renderIntent = @@ -332,7 +329,8 @@ int32_t ExynosPrimaryDisplayModule::setLayersColorData() bool ExynosPrimaryDisplayModule::hasDppForLayer(ExynosMPPSource* layer) { - if (mDisplayColorInterface == nullptr) { + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + if (displayColorInterface == nullptr) { return false; } @@ -340,7 +338,8 @@ bool ExynosPrimaryDisplayModule::hasDppForLayer(ExynosMPPSource* layer) return false; uint32_t index = mDisplaySceneInfo.layerDataMappingInfo[layer].dppIdx; - auto size = mDisplayColorInterface->GetPipelineData(DisplayType::DISPLAY_PRIMARY)->Dpp().size(); + const DisplayType display = getDisplayTypeFromIndex(mIndex); + auto size = displayColorInterface->GetPipelineData(display)->Dpp().size(); if (index >= size) { DISPLAY_LOGE("%s: invalid dpp index(%d) dpp size(%zu)", __func__, index, size); return false; @@ -352,7 +351,9 @@ bool ExynosPrimaryDisplayModule::hasDppForLayer(ExynosMPPSource* layer) const IDisplayColorGS101::IDpp& ExynosPrimaryDisplayModule::getDppForLayer(ExynosMPPSource* layer) { uint32_t index = mDisplaySceneInfo.layerDataMappingInfo[layer].dppIdx; - return mDisplayColorInterface->GetPipelineData(DisplayType::DISPLAY_PRIMARY)->Dpp()[index].get(); + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + const DisplayType display = getDisplayTypeFromIndex(mIndex); + return displayColorInterface->GetPipelineData(display)->Dpp()[index].get(); } int32_t ExynosPrimaryDisplayModule::getDppIndexForLayer(ExynosMPPSource* layer) @@ -369,12 +370,13 @@ int ExynosPrimaryDisplayModule::deliverWinConfigData() int ret = 0; ExynosDisplayDrmInterfaceModule *moduleDisplayInterface = (ExynosDisplayDrmInterfaceModule*)(mDisplayInterface.get()); + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); bool forceDisplayColorSetting = false; if (!mDisplaySceneInfo.displaySettingDelivered) forceDisplayColorSetting = true; - if (mDisplayColorInterface != nullptr) { + if (displayColorInterface != nullptr) { moduleDisplayInterface->setColorSettingChanged( mDisplaySceneInfo.needDisplayColorSetting(), forceDisplayColorSetting); @@ -632,7 +634,8 @@ int32_t ExynosPrimaryDisplayModule::DisplaySceneInfo::setLayerColorData( int32_t ExynosPrimaryDisplayModule::updateColorConversionInfo() { int ret = 0; - if (mDisplayColorInterface == nullptr) { + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + if (displayColorInterface == nullptr) { return ret; } @@ -656,8 +659,8 @@ int32_t ExynosPrimaryDisplayModule::updateColorConversionInfo() if (hwcCheckDebugMessages(eDebugColorManagement)) mDisplaySceneInfo.printDisplayScene(); - if ((ret = mDisplayColorInterface->Update(DisplayType::DISPLAY_PRIMARY, - mDisplaySceneInfo.displayScene)) != 0) { + const DisplayType display = getDisplayTypeFromIndex(mIndex); + if ((ret = displayColorInterface->Update(display, mDisplaySceneInfo.displayScene)) != 0) { DISPLAY_LOGE("Display Scene update error (%d)", ret); return ret; } @@ -668,7 +671,8 @@ int32_t ExynosPrimaryDisplayModule::updateColorConversionInfo() int32_t ExynosPrimaryDisplayModule::updatePresentColorConversionInfo() { int ret = NO_ERROR; - if (mDisplayColorInterface == nullptr) { + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + if (displayColorInterface == nullptr) { return ret; } @@ -679,8 +683,9 @@ int32_t ExynosPrimaryDisplayModule::updatePresentColorConversionInfo() mDisplaySceneInfo.displayScene.refresh_rate = refresh_rate; } - if ((ret = mDisplayColorInterface->UpdatePresent(DisplayType::DISPLAY_PRIMARY, - mDisplaySceneInfo.displayScene)) != 0) { + const DisplayType display = getDisplayTypeFromIndex(mIndex); + if ((ret = displayColorInterface->UpdatePresent(display, mDisplaySceneInfo.displayScene)) != + 0) { DISPLAY_LOGE("Display Scene update error (%d)", ret); return ret; } @@ -689,13 +694,13 @@ int32_t ExynosPrimaryDisplayModule::updatePresentColorConversionInfo() } int32_t ExynosPrimaryDisplayModule::getColorAdjustedDbv(uint32_t &dbv_adj) { - if (mDisplayColorInterface == nullptr) { + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + if (displayColorInterface == nullptr) { return NO_ERROR; } - dbv_adj = mDisplayColorInterface->GetPipelineData(DisplayType::DISPLAY_PRIMARY) - ->Panel() - .GetAdjustedBrightnessLevel(); + const DisplayType display = getDisplayTypeFromIndex(mIndex); + dbv_adj = displayColorInterface->GetPipelineData(display)->Panel().GetAdjustedBrightnessLevel(); return NO_ERROR; } diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h index 2a1acd3..ef26d1c 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplayModule.h @@ -18,10 +18,10 @@ #include <gs101/displaycolor/displaycolor_gs101.h> -#include "DisplayColorLoader.h" +#include "ExynosDeviceModule.h" #include "ExynosDisplay.h" -#include "ExynosPrimaryDisplay.h" #include "ExynosLayer.h" +#include "ExynosPrimaryDisplay.h" constexpr char kAtcJsonRaw[] = "{\"version\":\"0.0\",\"modes\":[{\"name\":\"normal\",\"lux_map\":[0,5000,10000," @@ -115,7 +115,9 @@ class ExynosPrimaryDisplayModule : public ExynosPrimaryDisplay { virtual int32_t updateColorConversionInfo(); virtual int32_t updatePresentColorConversionInfo(); virtual bool checkRrCompensationEnabled() { - return mDisplayColorInterface->IsRrCompensationEnabled(DisplayType::DISPLAY_PRIMARY); + const DisplayType display = getDisplayTypeFromIndex(mIndex); + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + return displayColorInterface->IsRrCompensationEnabled(display); } virtual int32_t getColorAdjustedDbv(uint32_t &dbv_adj); @@ -215,8 +217,10 @@ class ExynosPrimaryDisplayModule : public ExynosPrimaryDisplay { void printLayerColorData(const LayerColorData& layerData); }; - int initDisplayColor(const std::vector<displaycolor::DisplayInfo>& display_info); - bool hasDisplayColor() { return mDisplayColorInterface != nullptr; } + bool hasDisplayColor() { + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + return displayColorInterface != nullptr; + } /* Call getDppForLayer() only if hasDppForLayer() is true */ bool hasDppForLayer(ExynosMPPSource* layer); @@ -232,19 +236,21 @@ class ExynosPrimaryDisplayModule : public ExynosPrimaryDisplay { } size_t getNumOfDpp() { - return mDisplayColorInterface->GetPipelineData(DisplayType::DISPLAY_PRIMARY)->Dpp().size(); + const DisplayType display = getDisplayTypeFromIndex(mIndex); + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + return displayColorInterface->GetPipelineData(display)->Dpp().size(); }; const IDisplayColorGS101::IDqe& getDqe() { - return mDisplayColorInterface->GetPipelineData(DisplayType::DISPLAY_PRIMARY)->Dqe(); + const DisplayType display = getDisplayTypeFromIndex(mIndex); + IDisplayColorGS101* displayColorInterface = getDisplayColorInterface(); + return displayColorInterface->GetPipelineData(display)->Dqe(); }; private: int32_t setLayersColorData(); - IDisplayColorGS101 *mDisplayColorInterface; DisplaySceneInfo mDisplaySceneInfo; - DisplayColorLoader mDisplayColorLoader; struct atc_lux_map { uint32_t lux; @@ -274,6 +280,16 @@ class ExynosPrimaryDisplayModule : public ExynosPrimaryDisplay { return false; }; + DisplayType getDisplayTypeFromIndex(uint32_t index) { + return (index >= DisplayType::DISPLAY_MAX) ? DisplayType::DISPLAY_PRIMARY + : DisplayType(mIndex); + }; + + IDisplayColorGS101* getDisplayColorInterface() { + ExynosDeviceModule* device = (ExynosDeviceModule*)mDevice; + return device->getDisplayColorInterface(); + } + std::map<std::string, atc_mode> mAtcModeSetting; bool mAtcInit; LbeState mCurrentLbeState = LbeState::OFF; |