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

Commit 4aadb700 authored by Leon Scroggins's avatar Leon Scroggins Committed by Automerger Merge Worker
Browse files

Merge changes Ibd4099bb,Icfe2bf1d into udc-dev am: 42b349a2

parents d52ae638 42b349a2
Loading
Loading
Loading
Loading
+3 −13
Original line number Diff line number Diff line
@@ -384,23 +384,13 @@ VsyncEventData EventThread::getLatestVsyncEventData(
    return vsyncEventData;
}

void EventThread::onScreenReleased() {
void EventThread::enableSyntheticVsync(bool enable) {
    std::lock_guard<std::mutex> lock(mMutex);
    if (!mVSyncState || mVSyncState->synthetic) {
    if (!mVSyncState || mVSyncState->synthetic == enable) {
        return;
    }

    mVSyncState->synthetic = true;
    mCondition.notify_all();
}

void EventThread::onScreenAcquired() {
    std::lock_guard<std::mutex> lock(mMutex);
    if (!mVSyncState || !mVSyncState->synthetic) {
        return;
    }

    mVSyncState->synthetic = false;
    mVSyncState->synthetic = enable;
    mCondition.notify_all();
}

+3 −10
Original line number Diff line number Diff line
@@ -106,11 +106,8 @@ public:
    virtual sp<EventThreadConnection> createEventConnection(
            ResyncCallback, EventRegistrationFlags eventRegistration = {}) const = 0;

    // called before the screen is turned off from main thread
    virtual void onScreenReleased() = 0;

    // called after the screen is turned on from main thread
    virtual void onScreenAcquired() = 0;
    // Feed clients with fake VSYNC, e.g. while the display is off.
    virtual void enableSyntheticVsync(bool) = 0;

    virtual void onHotplugReceived(PhysicalDisplayId displayId, bool connected) = 0;

@@ -159,11 +156,7 @@ public:
    VsyncEventData getLatestVsyncEventData(
            const sp<EventThreadConnection>& connection) const override;

    // called before the screen is turned off from main thread
    void onScreenReleased() override;

    // called after the screen is turned on from main thread
    void onScreenAcquired() override;
    void enableSyntheticVsync(bool) override;

    void onHotplugReceived(PhysicalDisplayId displayId, bool connected) override;

+4 −12
Original line number Diff line number Diff line
@@ -265,24 +265,16 @@ void Scheduler::onHotplugReceived(ConnectionHandle handle, PhysicalDisplayId dis
    thread->onHotplugReceived(displayId, connected);
}

void Scheduler::onScreenAcquired(ConnectionHandle handle) {
void Scheduler::enableSyntheticVsync(bool enable) {
    // TODO(b/241285945): Remove connection handles.
    const ConnectionHandle handle = mAppConnectionHandle;
    android::EventThread* thread;
    {
        std::lock_guard<std::mutex> lock(mConnectionsLock);
        RETURN_IF_INVALID_HANDLE(handle);
        thread = mConnections[handle].thread.get();
    }
    thread->onScreenAcquired();
}

void Scheduler::onScreenReleased(ConnectionHandle handle) {
    android::EventThread* thread;
    {
        std::lock_guard<std::mutex> lock(mConnectionsLock);
        RETURN_IF_INVALID_HANDLE(handle);
        thread = mConnections[handle].thread.get();
    }
    thread->onScreenReleased();
    thread->enableSyntheticVsync(enable);
}

void Scheduler::onFrameRateOverridesChanged(ConnectionHandle handle, PhysicalDisplayId displayId) {
+2 −2
Original line number Diff line number Diff line
@@ -157,8 +157,8 @@ public:
    void onHotplugReceived(ConnectionHandle, PhysicalDisplayId, bool connected);
    void onPrimaryDisplayModeChanged(ConnectionHandle, const FrameRateMode&) EXCLUDES(mPolicyLock);
    void onNonPrimaryDisplayModeChanged(ConnectionHandle, const FrameRateMode&);
    void onScreenAcquired(ConnectionHandle);
    void onScreenReleased(ConnectionHandle);

    void enableSyntheticVsync(bool = true) REQUIRES(kMainThreadContext);

    void onFrameRateOverridesChanged(ConnectionHandle, PhysicalDisplayId)
            EXCLUDES(mConnectionsLock);
+9 −10
Original line number Diff line number Diff line
@@ -5210,7 +5210,6 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
        return;
    }

    const bool isActiveDisplay = displayId == mActiveDisplayId;
    const bool isInternalDisplay = mPhysicalDisplays.get(displayId)
                                           .transform(&PhysicalDisplay::isInternal)
                                           .value_or(false);
@@ -5247,10 +5246,10 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
            ALOGW("Couldn't set SCHED_FIFO on display on: %s\n", strerror(errno));
        }
        getHwComposer().setPowerMode(displayId, mode);
        if (isActiveDisplay && mode != hal::PowerMode::DOZE_SUSPEND) {
        if (displayId == mActiveDisplayId && mode != hal::PowerMode::DOZE_SUSPEND) {
            setHWCVsyncEnabled(displayId,
                               mScheduler->getVsyncSchedule().getPendingHardwareVsyncState());
            mScheduler->onScreenAcquired(mAppConnectionHandle);
            mScheduler->enableSyntheticVsync(false);
            mScheduler->resyncToHardwareVsync(true, refreshRate);
        }

@@ -5264,9 +5263,9 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
        if (SurfaceFlinger::setSchedAttr(false) != NO_ERROR) {
            ALOGW("Couldn't set uclamp.min on display off: %s\n", strerror(errno));
        }
        if (isActiveDisplay && *currentModeOpt != hal::PowerMode::DOZE_SUSPEND) {
        if (displayId == mActiveDisplayId && *currentModeOpt != hal::PowerMode::DOZE_SUSPEND) {
            mScheduler->disableHardwareVsync(true);
            mScheduler->onScreenReleased(mAppConnectionHandle);
            mScheduler->enableSyntheticVsync();
        }

        // Make sure HWVsync is disabled before turning off the display
@@ -5278,18 +5277,18 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
    } else if (mode == hal::PowerMode::DOZE || mode == hal::PowerMode::ON) {
        // Update display while dozing
        getHwComposer().setPowerMode(displayId, mode);
        if (isActiveDisplay && *currentModeOpt == hal::PowerMode::DOZE_SUSPEND) {
        if (displayId == mActiveDisplayId && *currentModeOpt == hal::PowerMode::DOZE_SUSPEND) {
            ALOGI("Force repainting for DOZE_SUSPEND -> DOZE or ON.");
            mVisibleRegionsDirty = true;
            scheduleRepaint();
            mScheduler->onScreenAcquired(mAppConnectionHandle);
            mScheduler->enableSyntheticVsync(false);
            mScheduler->resyncToHardwareVsync(true, refreshRate);
        }
    } else if (mode == hal::PowerMode::DOZE_SUSPEND) {
        // Leave display going to doze
        if (isActiveDisplay) {
        if (displayId == mActiveDisplayId) {
            mScheduler->disableHardwareVsync(true);
            mScheduler->onScreenReleased(mAppConnectionHandle);
            mScheduler->enableSyntheticVsync();
        }
        getHwComposer().setPowerMode(displayId, mode);
    } else {
@@ -5297,7 +5296,7 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
        getHwComposer().setPowerMode(displayId, mode);
    }

    if (isActiveDisplay) {
    if (displayId == mActiveDisplayId) {
        mTimeStats->setPowerMode(mode);
        mRefreshRateStats->setPowerMode(mode);
        mScheduler->setDisplayPowerMode(mode);
Loading