diff options
author | Shiyong Li <shiyongli@google.com> | 2023-05-24 01:19:36 +0000 |
---|---|---|
committer | Shiyong Li <shiyongli@google.com> | 2023-05-26 05:37:43 +0000 |
commit | ea4408f84f7326c51bb54a57e4069594a7969c87 (patch) | |
tree | 6acea2f924ddf550bddd61cc47d3ddf69cf5bb70 | |
parent | 2a4e22ebcc9afeabdd953b5eb3f9b12e33433838 (diff) |
libhwc2.1: correct refresh rate reference at toggling lhbm
The refresh rate associated with mActiveConfig takes one or more frames
to actually becomre effective on hardware, and can't be used as reference
to decide if it's needed to set new refresh rate while toggling lhbm.
Use drm value instead, which can't be blocked by enableConfigSetting()
and takes 1 frame at most to reflect on hardware.
Bug: 280727927
Test: check udfps enrollment failure rate
Signed-off-by: Shiyong Li <shiyongli@google.com>
Change-Id: Ie2f39f73761cc6f9fe51637aa3ebf8e5d85026e5
4 files changed, 36 insertions, 34 deletions
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; |