[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/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index cfdbd91..d2270d3 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -380,11 +380,17 @@
}
void Scheduler::setChangeRefreshRateCallback(
- const ChangeRefreshRateCallback& changeRefreshRateCallback) {
+ const ChangeRefreshRateCallback&& changeRefreshRateCallback) {
std::lock_guard<std::mutex> lock(mCallbackLock);
mChangeRefreshRateCallback = changeRefreshRateCallback;
}
+void Scheduler::setGetCurrentRefreshRateTypeCallback(
+ const GetCurrentRefreshRateTypeCallback&& getCurrentRefreshRateTypeCallback) {
+ std::lock_guard<std::mutex> lock(mCallbackLock);
+ mGetCurrentRefreshRateTypeCallback = getCurrentRefreshRateTypeCallback;
+}
+
void Scheduler::setGetVsyncPeriodCallback(const GetVsyncPeriod&& getVsyncPeriod) {
std::lock_guard<std::mutex> lock(mCallbackLock);
mGetVsyncPeriod = getVsyncPeriod;
@@ -427,8 +433,13 @@
void Scheduler::resetKernelTimerCallback() {
ATRACE_INT("ExpiredKernelIdleTimer", 0);
std::lock_guard<std::mutex> lock(mCallbackLock);
- if (mGetVsyncPeriod) {
- resyncToHardwareVsync(true, mGetVsyncPeriod());
+ if (mGetVsyncPeriod && mGetCurrentRefreshRateTypeCallback) {
+ // If we're not in performance mode then the kernel timer shouldn't do
+ // anything, as the refresh rate during DPU power collapse will be the
+ // same.
+ if (mGetCurrentRefreshRateTypeCallback() == Scheduler::RefreshRateType::PERFORMANCE) {
+ resyncToHardwareVsync(true, mGetVsyncPeriod());
+ }
}
}
@@ -450,10 +461,16 @@
}
void Scheduler::expiredKernelTimerCallback() {
+ std::lock_guard<std::mutex> lock(mCallbackLock);
ATRACE_INT("ExpiredKernelIdleTimer", 1);
- // Disable HW Vsync if the timer expired, as we don't need it
- // enabled if we're not pushing frames.
- disableHardwareVsync(false);
+ if (mGetCurrentRefreshRateTypeCallback) {
+ if (mGetCurrentRefreshRateTypeCallback() != Scheduler::RefreshRateType::PERFORMANCE) {
+ // Disable HW Vsync if the timer expired, as we don't need it
+ // enabled if we're not pushing frames, and if we're in PERFORMANCE
+ // mode then we'll need to re-update the DispSync model anyways.
+ disableHardwareVsync(false);
+ }
+ }
}
std::string Scheduler::doDump() {