[SurfaceFlinger] Don't touch hw vsync in DEFAULT RR with kernel timeout
As a power optimization, hw vsync shouldn't be enabled when the kernel
timer resets if the display is going to run at 60hz anyways.
Bug: 136197211
Test: systrace when scrolling at peak refresh rate of 60hz.
Change-Id: Ic7df3e7b735f79b183cdd91f770de83082e491b4
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 94eeef5..577deff 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -713,6 +713,24 @@
Mutex::Autolock lock(mStateLock);
setRefreshRateTo(type, event);
});
+ mScheduler->setGetCurrentRefreshRateTypeCallback([this] {
+ Mutex::Autolock lock(mStateLock);
+ const auto display = getDefaultDisplayDeviceLocked();
+ if (!display) {
+ // If we don't have a default display the fallback to the default
+ // refresh rate type
+ return RefreshRateType::DEFAULT;
+ }
+
+ const int configId = display->getActiveConfig();
+ for (const auto& [type, refresh] : mRefreshRateConfigs.getRefreshRates()) {
+ if (refresh && refresh->configId == configId) {
+ return type;
+ }
+ }
+ // This should never happen, but just gracefully fallback to default.
+ return RefreshRateType::DEFAULT;
+ });
mScheduler->setGetVsyncPeriodCallback([this] {
Mutex::Autolock lock(mStateLock);
return getVsyncPeriod();
@@ -1045,6 +1063,7 @@
desiredActiveConfigChangeDone();
return false;
}
+
mUpcomingActiveConfig = desiredActiveConfig;
const auto displayId = display->getId();
LOG_ALWAYS_FATAL_IF(!displayId);