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

Commit d822d11f authored by Dominik Laskowski's avatar Dominik Laskowski Committed by Android (Google) Code Review
Browse files

Merge changes I2a9be009,I5c7b2bef into main

* changes:
  SF: Fall back to pacesetter in getDisplayStats
  SF: Pass display ID to updatePhaseConfiguration
parents 697bd220 cfaaceb8
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ void Scheduler::setPacesetterDisplay(PhysicalDisplayId pacesetterId) {
    mVsyncModulator->cancelRefreshRateChange();

    mVsyncConfiguration->reset();
    updatePhaseConfiguration(pacesetterSelectorPtr()->getActiveMode().fps);
    updatePhaseConfiguration(pacesetterId, pacesetterSelectorPtr()->getActiveMode().fps);
}

void Scheduler::registerDisplay(PhysicalDisplayId displayId, RefreshRateSelectorPtr selectorPtr,
@@ -487,7 +487,12 @@ void Scheduler::setDuration(Cycle cycle, std::chrono::nanoseconds workDuration,
    }
}

void Scheduler::updatePhaseConfiguration(Fps refreshRate) {
void Scheduler::updatePhaseConfiguration(PhysicalDisplayId displayId, Fps refreshRate) {
    const bool isPacesetter =
            FTL_FAKE_GUARD(kMainThreadContext,
                           (std::scoped_lock(mDisplayLock), displayId == mPacesetterDisplayId));
    if (!isPacesetter) return;

    mRefreshRateStats->setRefreshRate(refreshRate);
    mVsyncConfiguration->setRefreshRateFps(refreshRate);
    setVsyncConfig(mVsyncModulator->setVsyncConfigSet(mVsyncConfiguration->getCurrentConfigs()),
+1 −1
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ public:
        }
    }

    void updatePhaseConfiguration(Fps);
    void updatePhaseConfiguration(PhysicalDisplayId, Fps);

    const VsyncConfiguration& getVsyncConfiguration() const { return *mVsyncConfiguration; }

+11 −27
Original line number Diff line number Diff line
@@ -1280,21 +1280,15 @@ status_t SurfaceFlinger::getDisplayStats(const sp<IBinder>& displayToken,
        return BAD_VALUE;
    }

    // TODO: b/277364366 - Require a display token from clients and remove fallback to pacesetter.
    std::optional<PhysicalDisplayId> displayIdOpt;
    {
        Mutex::Autolock lock(mStateLock);
    if (displayToken) {
        Mutex::Autolock lock(mStateLock);
        displayIdOpt = getPhysicalDisplayIdLocked(displayToken);
        if (!displayIdOpt) {
            ALOGW("%s: Invalid physical display token %p", __func__, displayToken.get());
            return NAME_NOT_FOUND;
        }
        } else {
            // TODO (b/277364366): Clients should be updated to pass in the display they
            // want, rather than us picking an arbitrary one (the active display, in this
            // case).
            displayIdOpt = mActiveDisplayId;
        }
    }

    const auto schedule = mScheduler->getVsyncSchedule(displayIdOpt);
@@ -1340,19 +1334,13 @@ void SurfaceFlinger::setDesiredMode(display::DisplayModeRequest&& desiredMode) {
            // VsyncController model is locked.
            mScheduler->modulateVsync(displayId, &VsyncModulator::onRefreshRateChangeInitiated);

            if (displayId == mActiveDisplayId) {
                mScheduler->updatePhaseConfiguration(mode.fps);
            }

            mScheduler->updatePhaseConfiguration(displayId, mode.fps);
            mScheduler->setModeChangePending(true);
            break;
        }
        case DesiredModeAction::InitiateRenderRateSwitch:
            mScheduler->setRenderRate(displayId, mode.fps, /*applyImmediately*/ false);

            if (displayId == mActiveDisplayId) {
                mScheduler->updatePhaseConfiguration(mode.fps);
            }
            mScheduler->updatePhaseConfiguration(displayId, mode.fps);

            if (emitEvent) {
                mScheduler->onDisplayModeChanged(displayId, mode);
@@ -1447,9 +1435,7 @@ void SurfaceFlinger::finalizeDisplayModeChange(PhysicalDisplayId displayId) {
    mDisplayModeController.finalizeModeChange(displayId, activeMode.modePtr->getId(),
                                              activeMode.modePtr->getVsyncRate(), activeMode.fps);

    if (displayId == mActiveDisplayId) {
        mScheduler->updatePhaseConfiguration(activeMode.fps);
    }
    mScheduler->updatePhaseConfiguration(displayId, activeMode.fps);

    if (pendingModeOpt->emitEvent) {
        mScheduler->onDisplayModeChanged(displayId, activeMode);
@@ -1473,11 +1459,9 @@ void SurfaceFlinger::applyActiveMode(PhysicalDisplayId displayId) {

    constexpr bool kAllowToEnable = true;
    mScheduler->resyncToHardwareVsync(displayId, kAllowToEnable, std::move(activeModePtr).take());
    mScheduler->setRenderRate(displayId, renderFps, /*applyImmediately*/ true);

    if (displayId == mActiveDisplayId) {
        mScheduler->updatePhaseConfiguration(renderFps);
    }
    mScheduler->setRenderRate(displayId, renderFps, /*applyImmediately*/ true);
    mScheduler->updatePhaseConfiguration(displayId, renderFps);
}

void SurfaceFlinger::initiateDisplayModeChanges() {