diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-05-27 01:37:56 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-05-27 01:37:56 +0000 |
commit | 00ac054ef7620ff8a3a2ff16c2a8b8f9dda2dd9e (patch) | |
tree | 707100a75654c6e37a914eacab0c2b060967c884 | |
parent | 5752f91ceb9b37578070e0226ba15727e14b6375 (diff) | |
parent | a5f01d4ae93a775f1eb60f41884c826715bc2bb1 (diff) |
Snap for 10214038 from a5f01d4ae93a775f1eb60f41884c826715bc2bb1 to udc-release
Change-Id: I6ef00e1909e670192ba65b274fbfb90fe80b204e
-rw-r--r-- | libhwc2.1/histogram_mediator.cpp | 12 | ||||
-rw-r--r-- | libhwc2.1/histogram_mediator.h | 6 | ||||
-rw-r--r-- | libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.h | 1 | ||||
-rw-r--r-- | libhwc2.1/libdisplayinterface/ExynosDisplayInterface.h | 1 | ||||
-rw-r--r-- | libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp | 64 | ||||
-rw-r--r-- | libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.h | 4 | ||||
-rw-r--r-- | libhwc2.1/pixel-display.cpp | 2 | ||||
-rw-r--r-- | libhwc2.1/pixel-display.h | 2 |
8 files changed, 47 insertions, 45 deletions
diff --git a/libhwc2.1/histogram_mediator.cpp b/libhwc2.1/histogram_mediator.cpp index 991b972..d1fba54 100644 --- a/libhwc2.1/histogram_mediator.cpp +++ b/libhwc2.1/histogram_mediator.cpp @@ -56,12 +56,12 @@ histogram::HistogramErrorCode histogram::HistogramMediator::requestHist() { ExynosDisplayDrmInterface *moduleDisplayInterface = static_cast<ExynosDisplayDrmInterface *>(mDisplay->mDisplayInterface.get()); - if (moduleDisplayInterface->setHistogramControl( - hidl_histogram_control_t::HISTOGRAM_CONTROL_REQUEST) != NO_ERROR) { - return histogram::HistogramErrorCode::ENABLE_HIST_ERROR; - } { std::unique_lock<std::mutex> lk(mIDLHistogram->mDataCollectingMutex); + if (moduleDisplayInterface->setHistogramControl( + hidl_histogram_control_t::HISTOGRAM_CONTROL_REQUEST) != NO_ERROR) { + return histogram::HistogramErrorCode::ENABLE_HIST_ERROR; + } mIDLHistogram->mHistReq_pending = true; } return histogram::HistogramErrorCode::NONE; @@ -93,7 +93,7 @@ int histogram::HistogramMediator::calculateThreshold(const RoiRect &roi) { } histogram::HistogramErrorCode histogram::HistogramMediator::setRoiWeightThreshold( - const RoiRect roi, const Weight weight, const HistogramPos pos) { + const RoiRect &roi, const Weight &weight, const HistogramPos &pos) { int threshold = calculateThreshold(roi); mIDLHistogram->setHistogramROI((uint16_t)roi.left, (uint16_t)roi.top, (uint16_t)(roi.right - roi.left), @@ -118,7 +118,7 @@ histogram::HistogramErrorCode histogram::HistogramMediator::collectRoiLuma( return histogram::HistogramErrorCode::NONE; } -histogram::RoiRect histogram::HistogramMediator::calRoi(RoiRect roi) { +histogram::RoiRect histogram::HistogramMediator::calRoi(const RoiRect &roi) { RoiRect roi_return = {-1, -1, -1, -1}; ExynosDisplayDrmInterface *moduleDisplayInterface = static_cast<ExynosDisplayDrmInterface *>(mDisplay->mDisplayInterface.get()); diff --git a/libhwc2.1/histogram_mediator.h b/libhwc2.1/histogram_mediator.h index eac4c98..fa81e0b 100644 --- a/libhwc2.1/histogram_mediator.h +++ b/libhwc2.1/histogram_mediator.h @@ -62,9 +62,9 @@ public: HistogramErrorCode requestHist(); HistogramErrorCode cancelHistRequest(); HistogramErrorCode collectRoiLuma(std::vector<char16_t> *buf); - HistogramErrorCode setRoiWeightThreshold(const RoiRect roi, const Weight weight, - const HistogramPos pos); - RoiRect calRoi(RoiRect roi); + HistogramErrorCode setRoiWeightThreshold(const RoiRect &roi, const Weight &weight, + const HistogramPos &pos); + RoiRect calRoi(const RoiRect &roi); struct HistogramReceiver : public IDLHistogram { HistogramReceiver() : mHistData(){}; void callbackHistogram(char16_t *bin) override; diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.h b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.h index 0ad50bc..3997b0f 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.h +++ b/libhwc2.1/libdisplayinterface/ExynosDisplayDrmInterface.h @@ -339,6 +339,7 @@ class ExynosDisplayDrmInterface : virtual int32_t setHistogramData(void *bin) { return NO_ERROR; } int32_t getActiveModeHDisplay() { return mActiveModeState.mode.h_display(); } int32_t getActiveModeVDisplay() { return mActiveModeState.mode.v_display(); } + uint32_t getActiveModeId() { return mActiveModeState.mode.id(); } int32_t panelHsize() { return mPanelResolutionHsize; } int32_t panelVsize() { return mPanelResolutionVsize; } int32_t getPanelResolution(); diff --git a/libhwc2.1/libdisplayinterface/ExynosDisplayInterface.h b/libhwc2.1/libdisplayinterface/ExynosDisplayInterface.h index 2eabdfc..b87c2e2 100644 --- a/libhwc2.1/libdisplayinterface/ExynosDisplayInterface.h +++ b/libhwc2.1/libdisplayinterface/ExynosDisplayInterface.h @@ -80,6 +80,7 @@ class ExynosDisplayInterface { virtual int32_t getDefaultModeId(int32_t* __unused modeId) { return HWC2_ERROR_UNSUPPORTED; } + virtual uint32_t getActiveModeId() { return UINT_MAX; } virtual int32_t waitVBlank() { return 0; }; public: diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp index 20dfea0..d24d1f9 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.cpp @@ -558,39 +558,44 @@ void ExynosPrimaryDisplay::enableConfigSetting(bool en) { mConfigSettingDisabled = false; } -void ExynosPrimaryDisplay::setLhbmDisplayConfig(uint32_t refreshRate) { - auto config = getConfigId(refreshRate, mDisplayConfigs[mActiveConfig].width, - mDisplayConfigs[mActiveConfig].height); - +int32_t ExynosPrimaryDisplay::setLhbmDisplayConfigLocked(uint32_t peakRate) { + auto hwConfig = mDisplayInterface->getActiveModeId(); + auto config = getConfigId(peakRate, mDisplayConfigs[hwConfig].width, + mDisplayConfigs[hwConfig].height); if (config == UINT_MAX) { - DISPLAY_LOGE("%s: failed to get config for rate=%d", __func__, refreshRate); - return; + DISPLAY_LOGE("%s: failed to get config for rate=%d", __func__, peakRate); + return -EINVAL; } - if (mPendingConfig == UINT_MAX) mPendingConfig = mActiveConfig; - if (ExynosDisplay::setActiveConfigInternal(config, true) == HWC2_ERROR_NONE) { - DISPLAY_LOGI("%s: succeeded to set config=%d rate=%d", __func__, config, refreshRate); + if (mPendingConfig == UINT_MAX && mActiveConfig != config) mPendingConfig = mActiveConfig; + if (config != hwConfig) { + if (ExynosDisplay::setActiveConfigInternal(config, true) == HWC2_ERROR_NONE) { + DISPLAY_LOGI("%s: succeeded to set config=%d rate=%d", __func__, config, peakRate); + } else { + DISPLAY_LOGW("%s: failed to set config=%d rate=%d", __func__, config, peakRate); + } } else { - DISPLAY_LOGW("%s: failed to set config=%d rate=%d", __func__, config, refreshRate); + DISPLAY_LOGI("%s: keep config=%d rate=%d", __func__, config, peakRate); } + enableConfigSetting(false); + return OK; } -void ExynosPrimaryDisplay::restoreLhbmDisplayConfig() { - if (mPendingConfig == UINT_MAX) return; - - hwc2_config_t pendingCfg = mPendingConfig; - if (mPendingConfig != mActiveConfig) { +void ExynosPrimaryDisplay::restoreLhbmDisplayConfigLocked() { + enableConfigSetting(true); + hwc2_config_t pendingConfig = mPendingConfig; + auto hwConfig = mDisplayInterface->getActiveModeId(); + if (pendingConfig != UINT_MAX && pendingConfig != hwConfig) { if (applyPendingConfig() == HWC2_ERROR_NONE) { - DISPLAY_LOGI("%s: succeeded to set config=%d rate=%d", __func__, pendingCfg, - getRefreshRate(pendingCfg)); + DISPLAY_LOGI("%s: succeeded to set config=%d rate=%d", __func__, pendingConfig, + getRefreshRate(pendingConfig)); } else { - DISPLAY_LOGE("%s: failed to set config=%d rate=%d", __func__, pendingCfg, - getRefreshRate(pendingCfg)); + DISPLAY_LOGE("%s: failed to set config=%d rate=%d", __func__, pendingConfig, + getRefreshRate(pendingConfig)); } } else { mPendingConfig = UINT_MAX; - DISPLAY_LOGI("%s: keep config=%d rate=%d", __func__, pendingCfg, - getRefreshRate(pendingCfg)); + DISPLAY_LOGI("%s: keep config=%d rate=%d", __func__, hwConfig, getRefreshRate(hwConfig)); } } @@ -638,10 +643,8 @@ int32_t ExynosPrimaryDisplay::setLhbmState(bool enabled) { if (!enabled) { ATRACE_NAME("disable_lhbm"); { - ATRACE_NAME("apply_pending_rate"); Mutex::Autolock lock(mDisplayMutex); - enableConfigSetting(true); - restoreLhbmDisplayConfig(); + restoreLhbmDisplayConfigLocked(); } requestLhbm(false); { @@ -662,7 +665,7 @@ int32_t ExynosPrimaryDisplay::setLhbmState(bool enabled) { ATRACE_NAME("enable_lhbm"); int64_t lhbmWaitForRrNanos, lhbmEnablingNanos, lhbmEnablingDoneNanos; bool enablingStateSupported = !mFramesToReachLhbmPeakBrightness; - uint32_t peakRate; + uint32_t peakRate = 0; auto rrSysfs = mBrightnessController->GetPanelRefreshRateSysfile(); lhbmWaitForRrNanos = systemTime(SYSTEM_TIME_MONOTONIC); { @@ -672,12 +675,10 @@ int32_t ExynosPrimaryDisplay::setLhbmState(bool enabled) { DISPLAY_LOGE("%s: invalid peak rate=%d", __func__, peakRate); return -EINVAL; } - if (getRefreshRate(mActiveConfig) != peakRate) { - ATRACE_NAME("request_peak_rate"); - setLhbmDisplayConfig(peakRate); - } - enableConfigSetting(false); + ret = setLhbmDisplayConfigLocked(peakRate); + if (ret != OK) return ret; } + if (mBrightnessController->fileExists(rrSysfs)) { ATRACE_NAME("wait_for_peak_rate_cmd"); ret = mBrightnessController->checkSysfsStatus(rrSysfs, {std::to_string(peakRate)}, @@ -756,8 +757,7 @@ int32_t ExynosPrimaryDisplay::setLhbmState(bool enabled) { return NO_ERROR; enable_err: Mutex::Autolock lock(mDisplayMutex); - enableConfigSetting(true); - restoreLhbmDisplayConfig(); + restoreLhbmDisplayConfigLocked(); return ret; } diff --git a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.h b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.h index 796f6ef..323eb5a 100644 --- a/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.h +++ b/libhwc2.1/libmaindisplay/ExynosPrimaryDisplay.h @@ -116,8 +116,8 @@ class ExynosPrimaryDisplay : public ExynosDisplay { int32_t setDisplayIdleDelayNanos(int32_t delayNanos, const DispIdleTimerRequester requester); void initDisplayHandleIdleExit(); - void setLhbmDisplayConfig(uint32_t refreshRate); - void restoreLhbmDisplayConfig(); + int32_t setLhbmDisplayConfigLocked(uint32_t peakRate); + void restoreLhbmDisplayConfigLocked(); // LHBM FILE* mLhbmFd; diff --git a/libhwc2.1/pixel-display.cpp b/libhwc2.1/pixel-display.cpp index cfb57a0..fec7309 100644 --- a/libhwc2.1/pixel-display.cpp +++ b/libhwc2.1/pixel-display.cpp @@ -199,7 +199,7 @@ ndk::ScopedAStatus Display::setRefreshRateThrottle(int delayMs, int *_aidl_retur return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); } -bool Display::runMediator(const RoiRect roi, const Weight weight, const HistogramPos pos, +bool Display::runMediator(const RoiRect &roi, const Weight &weight, const HistogramPos &pos, std::vector<char16_t> *histogrambuffer) { if (mMediator.setRoiWeightThreshold(roi, weight, pos) != HistogramErrorCode::NONE) { ALOGE("histogram error, SET_ROI_WEIGHT_THRESHOLD ERROR\n"); diff --git a/libhwc2.1/pixel-display.h b/libhwc2.1/pixel-display.h index 2202a68..df437af 100644 --- a/libhwc2.1/pixel-display.h +++ b/libhwc2.1/pixel-display.h @@ -66,7 +66,7 @@ public: ndk::ScopedAStatus isOperationRateSupported(bool *_aidl_return) override; private: - bool runMediator(const RoiRect roi, const Weight weight, const HistogramPos pos, + bool runMediator(const RoiRect &roi, const Weight &weight, const HistogramPos &pos, std::vector<char16_t> *histogrambuffer); ExynosDisplay *mDisplay = nullptr; histogram::HistogramMediator mMediator; |