SF: enable high refresh rate virtual mode
Add support for SF backdoor to set a multiplier
and divisor on the period for VSYNC-sf and
VSYNC-app from the primary DispSync object.
Bug: 111549030
Test: enable high refresh rate in devOptions and
view with systrace
Change-Id: I4226d5791d8d7ddeae1ad96577713c9c2141ed58
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp
index cdfbba3..b789d04 100644
--- a/services/surfaceflinger/DispSync.cpp
+++ b/services/surfaceflinger/DispSync.cpp
@@ -515,12 +515,26 @@
void DispSync::setPeriod(nsecs_t period) {
Mutex::Autolock lock(mMutex);
- mPeriod = period;
+ mPeriodBase = mPeriod = period;
mPhase = 0;
mReferenceTime = 0;
mThread->updateModel(mPeriod, mPhase, mReferenceTime);
}
+void DispSync::scalePeriod(uint32_t multiplier, uint32_t divisor) {
+ Mutex::Autolock lock(mMutex);
+
+ // if only 1 of the properties is updated, we will get to this
+ // point "attempting" to set the scale to 1 when it is already
+ // 1. Check that special case so that we don't do a useless
+ // update of the model.
+ if ((multiplier == 1) && (divisor == 1) && (mPeriod == mPeriodBase))
+ return;
+
+ mPeriod = mPeriodBase * multiplier / divisor;
+ mThread->updateModel(mPeriod, mPhase, mReferenceTime);
+}
+
nsecs_t DispSync::getPeriod() {
// lock mutex as mPeriod changes multiple times in updateModelLocked
Mutex::Autolock lock(mMutex);
@@ -545,7 +559,7 @@
// Exclude the min and max from the average
durationSum -= minDuration + maxDuration;
- mPeriod = durationSum / (mNumResyncSamples - 3);
+ mPeriodBase = mPeriod = durationSum / (mNumResyncSamples - 3);
ALOGV("[%s] mPeriod = %" PRId64, mName, ns2us(mPeriod));