SurfaceFlinger: remove mUse90Hz flag
As we have now DisplayManager changes in place (b/122905403)
there is no need for mUse90Hz flag. 90Hz will be enabled by
DisplayManager.
Fixes: 126725468
Test: Enable peak refresh from settings
Change-Id: I949727f8ba41bba874ab07160f3f6153d3bf4c67
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp
index 7cd9e49..da34083 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -392,7 +392,7 @@
void BufferQueueLayer::onFrameAvailable(const BufferItem& item) {
// Add this buffer from our internal queue tracker
{ // Autolock scope
- if (mFlinger->mUse90Hz && mFlinger->mUseSmart90ForVideo) {
+ if (mFlinger->mUseSmart90ForVideo) {
// Report the requested present time to the Scheduler, if the feature is turned on.
mFlinger->mScheduler->addFramePresentTimeForLayer(item.mTimestamp,
item.mIsAutoTimestamp, mName.c_str());
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index f8667d0..5b9759b 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -148,6 +148,9 @@
void incrementFrameCounter();
// Callback that gets invoked when Scheduler wants to change the refresh rate.
void setChangeRefreshRateCallback(const ChangeRefreshRateCallback& changeRefreshRateCallback);
+
+ // Returns whether idle timer is enabled or not
+ bool isIdleTimerEnabled() { return mSetIdleTimerMs > 0; }
// Returns relevant information about Scheduler for dumpsys purposes.
std::string doDump();
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index e445eb6..9b0e8c1 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -370,9 +370,6 @@
auto listSize = property_get_int32("debug.sf.max_igbp_list_size", int32_t(defaultListSize));
mMaxGraphicBufferProducerListSize = (listSize > 0) ? size_t(listSize) : defaultListSize;
- property_get("debug.sf.use_90Hz", value, "0");
- mUse90Hz = atoi(value);
-
property_get("debug.sf.use_smart_90_for_video", value, "0");
mUseSmart90ForVideo = atoi(value);
@@ -563,12 +560,14 @@
readPersistentProperties();
mBootStage = BootStage::FINISHED;
- // TODO(b/122905403): Once the display policy is completely integrated, this flag should go
- // away and it should be controlled by flipping the switch in setting. The switch in
- // settings should only be available to P19 devices, if they are opted into 90Hz fishfood.
- // The boot must be complete before we can set the active config.
+ // set the refresh rate according to the policy
+ const auto displayId = getInternalDisplayIdLocked();
+ LOG_ALWAYS_FATAL_IF(!displayId);
- if (mUse90Hz) {
+ const auto performanceRefreshRate =
+ mRefreshRateConfigs[*displayId]->getRefreshRate(RefreshRateType::PERFORMANCE);
+
+ if (isConfigAllowed(*displayId, performanceRefreshRate.configId)) {
mPhaseOffsets->setRefreshRateType(
scheduler::RefreshRateConfigs::RefreshRateType::PERFORMANCE);
setRefreshRateTo(RefreshRateType::PERFORMANCE, Scheduler::ConfigEvent::None);
@@ -699,7 +698,7 @@
ALOGE("Run StartPropertySetThread failed!");
}
- if (mUse90Hz) {
+ if (mScheduler->isIdleTimerEnabled()) {
mScheduler->setChangeRefreshRateCallback(
[this](RefreshRateType type, Scheduler::ConfigEvent event) {
Mutex::Autolock lock(mStateLock);
@@ -1588,7 +1587,7 @@
break;
}
- if (mUse90Hz && mUseSmart90ForVideo) {
+ if (mUseSmart90ForVideo) {
// This call is made each time SF wakes up and creates a new frame. It is part
// of video detection feature.
mScheduler->incrementFrameCounter();
@@ -4391,7 +4390,7 @@
" present offset: %9" PRId64 " ns\t VSYNC period: %9" PRId64 " ns\n\n",
dispSyncPresentTimeOffset, getVsyncPeriod());
- StringAppendF(&result, "Scheduler enabled. 90Hz feature: %s\n", mUse90Hz ? "on" : "off");
+ StringAppendF(&result, "Scheduler enabled.");
StringAppendF(&result, "+ Smart 90 for video detection: %s\n\n",
mUseSmart90ForVideo ? "on" : "off");
mScheduler->dump(mAppConnectionHandle, result);
@@ -5658,6 +5657,18 @@
}
}
}
+
+ // If idle timer and fps detection are disabled and we are in RefreshRateType::DEFAULT,
+ // there is no trigger to move to RefreshRateType::PERFORMANCE, even if it is an allowed.
+ if (!mScheduler->isIdleTimerEnabled() && !mUseSmart90ForVideo) {
+ const auto performanceRefreshRate =
+ mRefreshRateConfigs[*displayId]->getRefreshRate(RefreshRateType::PERFORMANCE);
+ if (isConfigAllowed(*displayId, performanceRefreshRate.configId)) {
+ mPhaseOffsets->setRefreshRateType(
+ scheduler::RefreshRateConfigs::RefreshRateType::PERFORMANCE);
+ setRefreshRateTo(RefreshRateType::PERFORMANCE, Scheduler::ConfigEvent::Changed);
+ }
+ }
}
status_t SurfaceFlinger::setAllowedDisplayConfigs(const android::sp<android::IBinder>& displayToken,
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index deffe9d..8de1e97 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1100,7 +1100,6 @@
/* ------------------------------------------------------------------------
* Scheduler
*/
- bool mUse90Hz = false;
bool mUseSmart90ForVideo = false;
std::unique_ptr<Scheduler> mScheduler;
sp<Scheduler::ConnectionHandle> mAppConnectionHandle;