From e454a37e464a7c5737814494ba6788f5c725ec5f Mon Sep 17 00:00:00 2001 From: Padmanabhan Komanduru Date: Thu, 19 May 2022 15:30:31 +0530 Subject: sf: update phase offsets with extension values properly Add change to update VsyncConfiguration with Phase Offset values everytime the vsync configuration is reset during active display change. Change-Id: I5e80875f13a2d0c1229804f328170f6a1778f99d CRs-Fixed: 3197703 --- services/surfaceflinger/SurfaceFlinger.cpp | 37 ++++++++++++++++++++++-------- services/surfaceflinger/SurfaceFlinger.h | 6 +++-- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 630997cd3a..52db4c1be0 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3994,6 +3994,7 @@ void SurfaceFlinger::processDisplayChanged(const wp& displayToken, void SurfaceFlinger::updateInternalDisplayVsyncLocked(const sp& activeDisplay) { mVsyncConfiguration->reset(); + updateSfPhaseOffsets(activeDisplay); const Fps refreshRate = activeDisplay->refreshRateConfigs().getCurrentRefreshRate().getFps(); updatePhaseConfiguration(refreshRate); mRefreshRateStats->setRefreshRate(refreshRate); @@ -9000,6 +9001,31 @@ void SurfaceFlinger::updateInternalDisplaysPresentationMode() { } } +void SurfaceFlinger::updateSfPhaseOffsets(const sp &display) { +#ifdef PHASE_OFFSET_EXTN + if (!g_comp_ext_intf_.phaseOffsetExtnIntf) { + return; + } + + // Get the Advanced SF Offsets from Phase Offset Extn + std::unordered_map advancedSfOffsets; + g_comp_ext_intf_.phaseOffsetExtnIntf->GetAdvancedSfOffsets(&advancedSfOffsets); + + // Populate the fps supported on device in mOffsetCache + const auto& supportedModes = display->getSupportedModes(); + for (auto mode : supportedModes) { + mVsyncConfiguration->getConfigsForRefreshRate(mode->getFps()); + } + + // Update the Advanced SF Offsets + mVsyncConfiguration->UpdateSfOffsets(advancedSfOffsets); + const auto vsyncConfig = + mVsyncModulator->setVsyncConfigSet(mVsyncConfiguration->getCurrentConfigs()); + ALOGI("VsyncConfig sfOffset %" PRId64 "\n", vsyncConfig.sfOffset); + ALOGI("VsyncConfig appOffset %" PRId64 "\n", vsyncConfig.appOffset); +#endif +} + void SurfaceFlinger::createPhaseOffsetExtn() { #ifdef PHASE_OFFSET_EXTN if (mUseAdvanceSfOffset && mComposerExtnIntf) { @@ -9009,16 +9035,7 @@ void SurfaceFlinger::createPhaseOffsetExtn() { return; } - // Get the Advanced SF Offsets from Phase Offset Extn - std::unordered_map advancedSfOffsets; - g_comp_ext_intf_.phaseOffsetExtnIntf->GetAdvancedSfOffsets(&advancedSfOffsets); - - // Update the Advanced SF Offsets - mVsyncConfiguration->UpdateSfOffsets(advancedSfOffsets); - const auto vsyncConfig = - mVsyncModulator->setVsyncConfigSet(mVsyncConfiguration->getCurrentConfigs()); - ALOGI("VsyncConfig sfOffset %" PRId64 "\n", vsyncConfig.sfOffset); - ALOGI("VsyncConfig appOffset %" PRId64 "\n", vsyncConfig.appOffset); + updateSfPhaseOffsets(getDefaultDisplayDeviceLocked()); } #endif } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 44394e50fc..e192c3a9d7 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -900,7 +900,7 @@ private: void onMessageRefresh(); // Check if unified draw supported - void startUnifiedDraw(); + void startUnifiedDraw() REQUIRES(mStateLock); void InitComposerExtn(); void createSmomoInstance(const DisplayDeviceState& state) REQUIRES(mStateLock); void destroySmomoInstance(const sp& display); @@ -1334,7 +1334,9 @@ private: void updateInternalDisplaysPresentationMode(); - void createPhaseOffsetExtn(); + void createPhaseOffsetExtn() REQUIRES(mStateLock); + + void updateSfPhaseOffsets(const sp &display); void setupDisplayExtnFeatures(); -- cgit v1.2.3