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

Commit 360ae785 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Avoid forcing modeset during boot

When SF activates the primary display during boot, there is no need to
force setDesiredActiveMode, because DM is about to send its policy via
setDesiredDisplayModeSpecs.

Fixes: 269470715
Test: DisplayModeSwitchingTest.multiDisplay
Change-Id: I4b2ce528037d2f6820376581a44d47246e566040
parent 85795340
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -7680,8 +7680,13 @@ void SurfaceFlinger::onActiveDisplayChangedLocked(const DisplayDevice* inactiveD
                                                  const DisplayDevice& activeDisplay) {
    ATRACE_CALL();

    // For the first display activated during boot, there is no need to force setDesiredActiveMode,
    // because DM is about to send its policy via setDesiredDisplayModeSpecs.
    bool forceApplyPolicy = false;

    if (inactiveDisplayPtr) {
        inactiveDisplayPtr->getCompositionDisplay()->setLayerCachingTexturePoolEnabled(false);
        forceApplyPolicy = true;
    }

    mActiveDisplayId = activeDisplay.getPhysicalId();
@@ -7698,8 +7703,8 @@ void SurfaceFlinger::onActiveDisplayChangedLocked(const DisplayDevice* inactiveD
    // 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.
    constexpr bool kForce = true;
    applyRefreshRateSelectorPolicy(mActiveDisplayId, activeDisplay.refreshRateSelector(), kForce);
    applyRefreshRateSelectorPolicy(mActiveDisplayId, activeDisplay.refreshRateSelector(),
                                   forceApplyPolicy);
}

status_t SurfaceFlinger::addWindowInfosListener(
+10 −6
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ TEST_F(DisplayModeSwitchingTest, changeRefreshRate_OnActiveDisplay_WithRefreshRe
    ASSERT_FALSE(mDisplay->getDesiredActiveMode().has_value());
    ASSERT_EQ(mDisplay->getActiveMode().modePtr->getId(), kModeId60);

    mFlinger.onActiveDisplayChanged(*mDisplay);
    mFlinger.onActiveDisplayChanged(nullptr, *mDisplay);

    mFlinger.setDesiredDisplayModeSpecs(mDisplay->getDisplayToken().promote(),
                                        mock::createDisplayModeSpecs(kModeId90.value(), false, 0,
@@ -159,7 +159,7 @@ TEST_F(DisplayModeSwitchingTest, changeRefreshRate_OnActiveDisplay_WithoutRefres

    ASSERT_FALSE(mDisplay->getDesiredActiveMode().has_value());

    mFlinger.onActiveDisplayChanged(*mDisplay);
    mFlinger.onActiveDisplayChanged(nullptr, *mDisplay);

    mFlinger.setDesiredDisplayModeSpecs(mDisplay->getDisplayToken().promote(),
                                        mock::createDisplayModeSpecs(kModeId90.value(), true, 0,
@@ -195,7 +195,7 @@ TEST_F(DisplayModeSwitchingTest, twoConsecutiveSetDesiredDisplayModeSpecs) {
    ASSERT_FALSE(mDisplay->getDesiredActiveMode().has_value());
    ASSERT_EQ(mDisplay->getActiveMode().modePtr->getId(), kModeId60);

    mFlinger.onActiveDisplayChanged(*mDisplay);
    mFlinger.onActiveDisplayChanged(nullptr, *mDisplay);

    mFlinger.setDesiredDisplayModeSpecs(mDisplay->getDisplayToken().promote(),
                                        mock::createDisplayModeSpecs(kModeId90.value(), false, 0,
@@ -238,7 +238,7 @@ TEST_F(DisplayModeSwitchingTest, changeResolution_OnActiveDisplay_WithoutRefresh
    ASSERT_FALSE(mDisplay->getDesiredActiveMode().has_value());
    ASSERT_EQ(mDisplay->getActiveMode().modePtr->getId(), kModeId60);

    mFlinger.onActiveDisplayChanged(*mDisplay);
    mFlinger.onActiveDisplayChanged(nullptr, *mDisplay);

    mFlinger.setDesiredDisplayModeSpecs(mDisplay->getDisplayToken().promote(),
                                        mock::createDisplayModeSpecs(kModeId90_4K.value(), false, 0,
@@ -315,7 +315,11 @@ TEST_F(DisplayModeSwitchingTest, multiDisplay) {
    EXPECT_EQ(innerDisplay->getActiveMode().modePtr->getId(), kModeId60);
    EXPECT_EQ(outerDisplay->getActiveMode().modePtr->getId(), kModeId120);

    mFlinger.onActiveDisplayChanged(*innerDisplay);
    mFlinger.onActiveDisplayChanged(nullptr, *innerDisplay);

    // No transition on either display.
    EXPECT_FALSE(innerDisplay->getDesiredActiveMode());
    EXPECT_FALSE(outerDisplay->getDesiredActiveMode());

    EXPECT_EQ(NO_ERROR,
              mFlinger.setDesiredDisplayModeSpecs(innerDisplay->getDisplayToken().promote(),
@@ -359,7 +363,7 @@ TEST_F(DisplayModeSwitchingTest, multiDisplay) {
    EXPECT_FALSE(outerDisplay->getDesiredActiveMode());
    EXPECT_EQ(outerDisplay->getActiveMode().modePtr->getId(), kModeId120);

    mFlinger.onActiveDisplayChanged(*outerDisplay);
    mFlinger.onActiveDisplayChanged(innerDisplay.get(), *outerDisplay);

    // No transition on the inner display.
    EXPECT_FALSE(innerDisplay->getDesiredActiveMode());
+3 −2
Original line number Diff line number Diff line
@@ -505,10 +505,11 @@ public:
        return mFlinger->setDesiredDisplayModeSpecs(displayToken, specs);
    }

    void onActiveDisplayChanged(const DisplayDevice& activeDisplay) {
    void onActiveDisplayChanged(const DisplayDevice* inactiveDisplayPtr,
                                const DisplayDevice& activeDisplay) {
        Mutex::Autolock lock(mFlinger->mStateLock);
        ftl::FakeGuard guard(kMainThreadContext);
        mFlinger->onActiveDisplayChangedLocked(nullptr, activeDisplay);
        mFlinger->onActiveDisplayChangedLocked(inactiveDisplayPtr, activeDisplay);
    }

    auto createLayer(LayerCreationArgs& args, const sp<IBinder>& parentHandle,