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

Commit aac3a778 authored by Huihong Luo's avatar Huihong Luo
Browse files

SF: Use vsync workaround to detect hotplug errors

HWC sets a system property,
debug.sf.hwc_hotplug_error_via_neg_vsync, to inform SF that
it should check negative vsync, parse and propagate any error
code on hotplug event up the stack.

Bug: 241286153
Test: manual
Change-Id: I32214378b00a1b002fa144dbef3f6610818a053a
parent 5dcd75d4
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -2084,6 +2084,17 @@ nsecs_t SurfaceFlinger::getVsyncPeriodFromHWC() const {

void SurfaceFlinger::onComposerHalVsync(hal::HWDisplayId hwcDisplayId, int64_t timestamp,
                                        std::optional<hal::VsyncPeriodNanos> vsyncPeriod) {
    if (mConnectedDisplayFlagValue) {
        // use ~0 instead of -1 as AidlComposerHal.cpp passes the param as unsigned int32
        if (mIsHotplugErrViaNegVsync && timestamp < 0 && vsyncPeriod.has_value() &&
            vsyncPeriod.value() == ~0) {
            int hotplugErrorCode = static_cast<int32_t>(-timestamp);
            ALOGD("SurfaceFlinger got hotplugErrorCode=%d", hotplugErrorCode);
            mScheduler->onHotplugConnectionError(mAppConnectionHandle, hotplugErrorCode);
            return;
        }
    }

    ATRACE_NAME(vsyncPeriod
                        ? ftl::Concat(__func__, ' ', hwcDisplayId, ' ', *vsyncPeriod, "ns").c_str()
                        : ftl::Concat(__func__, ' ', hwcDisplayId).c_str());
@@ -4050,6 +4061,9 @@ void SurfaceFlinger::initScheduler(const sp<const DisplayDevice>& display) {
            sp<RegionSamplingThread>::make(*this,
                                           RegionSamplingThread::EnvironmentTimingTunables());
    mFpsReporter = sp<FpsReporter>::make(*mFrameTimeline, *this);

    mIsHotplugErrViaNegVsync =
            base::GetBoolProperty("debug.sf.hwc_hotplug_error_via_neg_vsync"s, false);
}

void SurfaceFlinger::updatePhaseConfiguration(Fps refreshRate) {
+2 −0
Original line number Diff line number Diff line
@@ -1233,6 +1233,8 @@ private:
        hal::Connection connection = hal::Connection::INVALID;
    };

    bool mIsHotplugErrViaNegVsync = false;

    std::mutex mHotplugMutex;
    std::vector<HotplugEvent> mPendingHotplugEvents GUARDED_BY(mHotplugMutex);