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

Commit 3f726401 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Obey active display's RefreshRateSelector

When a display becomes active, apply its RefreshRateSelector's policy,
as it may have changed while the display was inactive.

When booting while folded, DisplayManager first sends DisplayModeSpecs
for each display, and then powers on the outer display. Before this CL,
the outer display would become the new active/leader display, but its
DisplayManagerPolicy would never be applied.

Also, remove calls during boot (or restart) that are now redundant given
that onActiveDisplayChangedLocked is called when powering on the primary
display in onInitializeDisplays.

Bug: 250421145
Test: Force 120 Hz, and reboot while folded.
Test: Apply Ifaa46027bad8ff0945db9da5c30f2f31b6c8d10c and repeat.
Change-Id: I15e0f5a280e62baf6d4e6ea2748d95342e79ac44
parent b4ff7d97
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -845,8 +845,6 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) {
        }
    }

    onActiveDisplaySizeChanged(display);

    // Inform native graphics APIs whether the present timestamp is supported:

    const bool presentFenceReliable =
@@ -3433,14 +3431,6 @@ void SurfaceFlinger::initScheduler(const sp<const DisplayDevice>& display) {
            sp<RegionSamplingThread>::make(*this,
                                           RegionSamplingThread::EnvironmentTimingTunables());
    mFpsReporter = sp<FpsReporter>::make(*mFrameTimeline, *this);
    // Dispatch a mode change request for the primary display on scheduler
    // initialization, so that the EventThreads always contain a reference to a
    // prior configuration.
    //
    // This is a bit hacky, but this avoids a back-pointer into the main SF
    // classes from EventThread, and there should be no run-time binder cost
    // anyway since there are no connected apps at this point.
    mScheduler->onPrimaryDisplayModeChanged(mAppConnectionHandle, activeModePtr);
}

void SurfaceFlinger::updatePhaseConfiguration(const Fps& refreshRate) {
@@ -4623,8 +4613,6 @@ void SurfaceFlinger::onInitializeDisplays() {
                          {}, mPid, getuid(), transactionId);

    setPowerModeInternal(display, hal::PowerMode::ON);

    mActiveDisplayTransformHint = display->getTransformHint();
}

void SurfaceFlinger::initializeDisplays() {
@@ -6642,9 +6630,12 @@ status_t SurfaceFlinger::setDesiredDisplayModeSpecsInternal(
        case SetPolicyResult::Unchanged:
            return NO_ERROR;
        case SetPolicyResult::Changed:
            break;
            return applyRefreshRateSelectorPolicy(displayId, selector);
    }
}

status_t SurfaceFlinger::applyRefreshRateSelectorPolicy(
        PhysicalDisplayId displayId, const scheduler::RefreshRateSelector& selector) {
    const scheduler::RefreshRateSelector::Policy currentPolicy = selector.getCurrentPolicy();
    ALOGV("Setting desired display mode specs: %s", currentPolicy.toString().c_str());

@@ -6976,9 +6967,11 @@ void SurfaceFlinger::onActiveDisplayChangedLocked(const sp<DisplayDevice>& activ
    onActiveDisplaySizeChanged(activeDisplay);
    mActiveDisplayTransformHint = activeDisplay->getTransformHint();

    // Update the kernel timer for the current active display, since the policy
    // for this display might have changed when it was not the active display.
    toggleKernelIdleTimer();
    // The policy of the new active/leader display may have changed while it was inactive. In that
    // case, its preferred mode has not been propagated to HWC (via setDesiredActiveMode). In either
    // case, the Scheduler's cachedModeChangedParams must be initialized to the newly active mode,
    // and the kernel idle timer of the newly active display must be toggled.
    applyRefreshRateSelectorPolicy(mActiveDisplayId, activeDisplay->refreshRateSelector());
}

status_t SurfaceFlinger::addWindowInfosListener(
+5 −0
Original line number Diff line number Diff line
@@ -666,6 +666,11 @@ private:
            const sp<DisplayDevice>&, const scheduler::RefreshRateSelector::PolicyVariant&)
            EXCLUDES(mStateLock) REQUIRES(kMainThreadContext);

    // TODO(b/241285191): Look up RefreshRateSelector on Scheduler to remove redundant parameter.
    status_t applyRefreshRateSelectorPolicy(PhysicalDisplayId,
                                            const scheduler::RefreshRateSelector&)
            REQUIRES(mStateLock, kMainThreadContext);

    void commitTransactions() EXCLUDES(mStateLock) REQUIRES(kMainThreadContext);
    void commitTransactionsLocked(uint32_t transactionFlags)
            REQUIRES(mStateLock, kMainThreadContext);