Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c9e82ba authored by Alec Mouri's avatar Alec Mouri
Browse files

SF: fix bad phase offsets.

Moves the issuance of 60hz/90hz config changes from the boot phase to
the message-handling phase in setActiveConfig.

Bug: 127782993
Test: dumpsys
Change-Id: I5a12e4c5f0744107c6352269a8c6ad75a90c9be0
parent 4720543f
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
@@ -573,12 +573,8 @@ void SurfaceFlinger::bootFinished()
                mRefreshRateConfigs[*displayId]->getRefreshRate(RefreshRateType::PERFORMANCE);

        if (isConfigAllowed(*displayId, performanceRefreshRate.configId)) {
            mPhaseOffsets->setRefreshRateType(
                    scheduler::RefreshRateConfigs::RefreshRateType::PERFORMANCE);
            setRefreshRateTo(RefreshRateType::PERFORMANCE, Scheduler::ConfigEvent::None);
        } else {
            mPhaseOffsets->setRefreshRateType(
                    scheduler::RefreshRateConfigs::RefreshRateType::DEFAULT);
            setRefreshRateTo(RefreshRateType::DEFAULT, Scheduler::ConfigEvent::None);
        }
    }));
@@ -975,6 +971,8 @@ void SurfaceFlinger::setActiveConfigInternal() {
    display->setActiveConfig(mUpcomingActiveConfig.configId);

    mScheduler->resyncToHardwareVsync(true, getVsyncPeriod());
    const auto [early, gl, late] = mPhaseOffsets->getCurrentOffsets();
    mVsyncModulator.setPhaseOffsets(early, gl, late);
    ATRACE_INT("ActiveConfigMode", mUpcomingActiveConfig.configId);
    if (mUpcomingActiveConfig.event != Scheduler::ConfigEvent::None) {
        mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value,
@@ -1418,15 +1416,10 @@ bool SurfaceFlinger::isConfigAllowed(const DisplayId& displayId, int32_t config)
}

void SurfaceFlinger::setRefreshRateTo(RefreshRateType refreshRate, Scheduler::ConfigEvent event) {
    ATRACE_CALL();
    mPhaseOffsets->setRefreshRateType(refreshRate);

    const auto [early, gl, late] = mPhaseOffsets->getCurrentOffsets();
    mVsyncModulator.setPhaseOffsets(early, gl, late);

    if (mBootStage != BootStage::FINISHED) {
        return;
    }
    ATRACE_CALL();

    // Don't do any updating if the current fps is the same as the new one.
    const auto displayId = getInternalDisplayIdLocked();
@@ -1444,6 +1437,7 @@ void SurfaceFlinger::setRefreshRateTo(RefreshRateType refreshRate, Scheduler::Co
        return;
    }

    mPhaseOffsets->setRefreshRateType(refreshRate);
    setDesiredActiveConfig(getInternalDisplayTokenLocked(), desiredConfigId, event);
}

@@ -5671,8 +5665,6 @@ void SurfaceFlinger::setAllowedDisplayConfigsInternal(
        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);
        }
    }