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

Commit 91dc9f36 authored by Rachel Lee's avatar Rachel Lee Committed by Android (Google) Code Review
Browse files

Merge "HW Vsync turns off correctly in Doze/AOD." into tm-qpr-dev

parents a09e6780 6a9731d3
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -554,11 +554,12 @@ void Scheduler::onTouchHint() {
    }
}

void Scheduler::setDisplayPowerState(bool normal) {
void Scheduler::setDisplayPowerMode(hal::PowerMode powerMode) {
    {
        std::lock_guard<std::mutex> lock(mPolicyLock);
        mPolicy.isDisplayPowerStateNormal = normal;
        mPolicy.displayPowerMode = powerMode;
    }
    mVsyncSchedule->getController().setDisplayPowerMode(powerMode);

    if (mDisplayPowerTimer) {
        mDisplayPowerTimer->reset();
@@ -706,7 +707,8 @@ auto Scheduler::chooseDisplayMode() -> std::pair<DisplayModePtr, GlobalSignals>
    // If Display Power is not in normal operation we want to be in performance mode. When coming
    // back to normal mode, a grace period is given with DisplayPowerTimer.
    if (mDisplayPowerTimer &&
        (!mPolicy.isDisplayPowerStateNormal || mPolicy.displayPowerTimer == TimerState::Reset)) {
        (mPolicy.displayPowerMode != hal::PowerMode::ON ||
         mPolicy.displayPowerTimer == TimerState::Reset)) {
        constexpr GlobalSignals kNoSignals;
        return {configs->getMaxRefreshRateByPolicy(), kNoSignals};
    }
+2 −2
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ public:
    // Indicates that touch interaction is taking place.
    void onTouchHint();

    void setDisplayPowerState(bool normal);
    void setDisplayPowerMode(hal::PowerMode powerMode);

    VSyncDispatch& getVsyncDispatch() { return mVsyncSchedule->getDispatch(); }

@@ -325,7 +325,7 @@ private:
        TimerState idleTimer = TimerState::Reset;
        TouchState touch = TouchState::Inactive;
        TimerState displayPowerTimer = TimerState::Expired;
        bool isDisplayPowerStateNormal = true;
        hal::PowerMode displayPowerMode = hal::PowerMode::ON;

        // Chosen display mode.
        DisplayModePtr mode;
+10 −0
Original line number Diff line number Diff line
@@ -146,6 +146,11 @@ bool VSyncReactor::periodConfirmed(nsecs_t vsync_timestamp, std::optional<nsecs_
        return false;
    }

    if (mDisplayPowerMode == hal::PowerMode::DOZE ||
        mDisplayPowerMode == hal::PowerMode::DOZE_SUSPEND) {
        return true;
    }

    if (!mLastHwVsync && !HwcVsyncPeriod) {
        return false;
    }
@@ -206,6 +211,11 @@ bool VSyncReactor::addHwVsyncTimestamp(nsecs_t timestamp, std::optional<nsecs_t>
    return mMoreSamplesNeeded;
}

void VSyncReactor::setDisplayPowerMode(hal::PowerMode powerMode) {
    std::scoped_lock lock(mMutex);
    mDisplayPowerMode = powerMode;
}

void VSyncReactor::dump(std::string& result) const {
    std::lock_guard lock(mMutex);
    StringAppendF(&result, "VsyncReactor in use\n");
+4 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ public:
    bool addHwVsyncTimestamp(nsecs_t timestamp, std::optional<nsecs_t> hwcVsyncPeriod,
                             bool* periodFlushed) final;

    void setDisplayPowerMode(hal::PowerMode powerMode) final;

    void dump(std::string& result) const final;

private:
@@ -73,6 +75,8 @@ private:
    std::optional<nsecs_t> mPeriodTransitioningTo GUARDED_BY(mMutex);
    std::optional<nsecs_t> mLastHwVsync GUARDED_BY(mMutex);

    hal::PowerMode mDisplayPowerMode GUARDED_BY(mMutex) = hal::PowerMode::ON;

    const bool mSupportKernelIdleTimer = false;
};

+10 −0
Original line number Diff line number Diff line
@@ -18,7 +18,10 @@

#include <cstddef>
#include <memory>
#include <mutex>

#include <DisplayHardware/HWComposer.h>
#include <DisplayHardware/Hal.h>
#include <ui/FenceTime.h>
#include <utils/Mutex.h>
#include <utils/RefBase.h>
@@ -70,6 +73,13 @@ public:
     */
    virtual void setIgnorePresentFences(bool ignore) = 0;

    /*
     * Sets the primary display power mode to the controller.
     *
     * \param [in] powerMode
     */
    virtual void setDisplayPowerMode(hal::PowerMode powerMode) = 0;

    virtual void dump(std::string& result) const = 0;

protected:
Loading