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

Commit 993ddf4a authored by Marin Shalamanov's avatar Marin Shalamanov
Browse files

SF: Recreate display on resolution changes

When the resolution changes from SurfaceFlinger we
need to recreate the frambuffer. This CL reuses the
existing mechanism for processing display changes
to do that. More specifically the logic in this CL
does the same as if there was a subsequent hotplug
"connected" event.

This removes the need HWC HAL implementations to
send hotplug events on each resolution change
(which was violating VTS).

This change impacts only devices which support
multiple resolutions (e.g. TV but no phones).

Test: atest DisplayTest SetFrameRateTest
Test: plug hdmi out and in and verify that there are
      no crashes
Bug: 188684566
Change-Id: I8a00657e9eeb1db716ce58aac7b3e3e40f898352
parent c2baccc4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public:
        if (mCurrentRefreshRate.equalsWithMargin(currRefreshRate)) {
            return;
        }
        mTimeStats.incrementRefreshRateSwitches();
        flushTime();
        mCurrentRefreshRate = currRefreshRate;
    }
+16 −5
Original line number Diff line number Diff line
@@ -1139,7 +1139,18 @@ void SurfaceFlinger::setActiveModeInternal() {
        // have been already updated with the upcoming active mode.
        return;
    }
    const Fps oldRefreshRate = display->getActiveMode()->getFps();

    if (display->getActiveMode()->getSize() != upcomingMode->getSize()) {
        auto& state = mCurrentState.displays.editValueFor(display->getDisplayToken());
        // We need to generate new sequenceId in order to recreate the display (and this
        // way the framebuffer).
        state.sequenceId = DisplayDeviceState{}.sequenceId;
        state.physical->activeMode = upcomingMode;
        processDisplayChangesLocked();

        // processDisplayChangesLocked will update all necessary components so we're done here.
        return;
    }

    std::lock_guard<std::mutex> lock(mActiveModeLock);
    mRefreshRateConfigs->setCurrentModeId(mUpcomingActiveMode.modeId);
@@ -1149,9 +1160,6 @@ void SurfaceFlinger::setActiveModeInternal() {

    mRefreshRateStats->setRefreshRate(refreshRate);

    if (!refreshRate.equalsWithMargin(oldRefreshRate)) {
        mTimeStats->incrementRefreshRateSwitches();
    }
    updatePhaseConfiguration(refreshRate);
    ATRACE_INT("ActiveConfigFPS", refreshRate.getValue());

@@ -2808,7 +2816,10 @@ void SurfaceFlinger::processDisplayChanged(const wp<IBinder>& displayToken,
                mRefreshRateConfigs->updateDisplayModes(currentState.physical->supportedModes,
                                                        currentState.physical->activeMode->getId());
                mVsyncConfiguration->reset();
                updatePhaseConfiguration(mRefreshRateConfigs->getCurrentRefreshRate().getFps());
                const Fps refreshRate = currentState.physical->activeMode->getFps();
                updatePhaseConfiguration(refreshRate);
                mRefreshRateStats->setRefreshRate(refreshRate);

                if (mRefreshRateOverlay) {
                    mRefreshRateOverlay->reset();
                }