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

Commit 5155aa62 authored by Lucas Berthou's avatar Lucas Berthou Committed by Android (Google) Code Review
Browse files

Merge "SF: Handle Link training failure in SF and DM" into main

parents 2d1ee0cb a41a5928
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ std::optional<DisplayIdentificationInfo> HWComposer::onHotplug(hal::HWDisplayId
        case HotplugEvent::Disconnected:
            return onHotplugDisconnect(hwcDisplayId);
        case HotplugEvent::LinkUnstable:
            return {};
            return onHotplugLinkTrainingFailure(hwcDisplayId);
    }
}

@@ -1245,6 +1245,16 @@ std::optional<DisplayIdentificationInfo> HWComposer::onHotplugDisconnect(
    return DisplayIdentificationInfo{.id = *displayId};
}

std::optional<DisplayIdentificationInfo> HWComposer::onHotplugLinkTrainingFailure(
        hal::HWDisplayId hwcDisplayId) {
    const auto displayId = toPhysicalDisplayId(hwcDisplayId);
    if (!displayId) {
        LOG_HWC_DISPLAY_ERROR(hwcDisplayId, "Invalid HWC display");
        return {};
    }
    return DisplayIdentificationInfo{.id = *displayId};
}

void HWComposer::loadCapabilities() {
    static_assert(sizeof(hal::Capability) == sizeof(int32_t), "Capability size has changed");
    auto capabilities = mComposer->getCapabilities();
+1 −0
Original line number Diff line number Diff line
@@ -544,6 +544,7 @@ private:

    std::optional<DisplayIdentificationInfo> onHotplugConnect(hal::HWDisplayId);
    std::optional<DisplayIdentificationInfo> onHotplugDisconnect(hal::HWDisplayId);
    std::optional<DisplayIdentificationInfo> onHotplugLinkTrainingFailure(hal::HWDisplayId);
    bool shouldIgnoreHotplugConnect(hal::HWDisplayId, uint8_t port,
                                    bool hasDisplayIdentificationData) const;

+23 −8
Original line number Diff line number Diff line
@@ -2339,10 +2339,20 @@ void SurfaceFlinger::onComposerHalHotplugEvent(hal::HWDisplayId hwcDisplayId,
        return;
    }

    if (event == DisplayHotplugEvent::ERROR_LINK_UNSTABLE &&
        !FlagManager::getInstance().display_config_error_hal()) {
    if (event == DisplayHotplugEvent::ERROR_LINK_UNSTABLE) {
        if (!FlagManager::getInstance().display_config_error_hal()) {
            return;
        }
        {
            std::lock_guard<std::mutex> lock(mHotplugMutex);
            mPendingHotplugEvents.push_back(
                    HotplugEvent{hwcDisplayId, HWComposer::HotplugEvent::LinkUnstable});
        }
        if (mScheduler) {
            mScheduler->scheduleConfigure();
        }
        // do not return to also report the error.
    }

    // TODO(b/311403559): use enum type instead of int
    const auto errorCode = static_cast<int32_t>(event);
@@ -3719,11 +3729,12 @@ bool SurfaceFlinger::configureLocked() {
            const auto displayId = info->id;
            const ftl::Concat displayString("display ", displayId.value, "(HAL ID ", hwcDisplayId,
                                            ')');

            if (event == HWComposer::HotplugEvent::Connected) {
            // TODO: b/393126541 - replace if with switch as all cases are handled.
            if (event == HWComposer::HotplugEvent::Connected ||
                event == HWComposer::HotplugEvent::LinkUnstable) {
                const auto activeModeIdOpt =
                        processHotplugConnect(displayId, hwcDisplayId, std::move(*info),
                                              displayString.c_str());
                                              displayString.c_str(), event);
                if (!activeModeIdOpt) {
                    mScheduler->dispatchHotplugError(
                            static_cast<int32_t>(DisplayHotplugEvent::ERROR_UNKNOWN));
@@ -3749,7 +3760,7 @@ bool SurfaceFlinger::configureLocked() {
                LOG_ALWAYS_FATAL_IF(!snapshotOpt);

                mDisplayModeController.registerDisplay(*snapshotOpt, *activeModeIdOpt, config);
            } else {
            } else { // event == HWComposer::HotplugEvent::Disconnected
                // Unregister before destroying the DisplaySnapshot below.
                mDisplayModeController.unregisterDisplay(displayId);

@@ -3764,7 +3775,8 @@ bool SurfaceFlinger::configureLocked() {
std::optional<DisplayModeId> SurfaceFlinger::processHotplugConnect(PhysicalDisplayId displayId,
                                                                   hal::HWDisplayId hwcDisplayId,
                                                                   DisplayIdentificationInfo&& info,
                                                                   const char* displayString) {
                                                                   const char* displayString,
                                                                   HWComposer::HotplugEvent event) {
    auto [displayModes, activeMode] = loadDisplayModes(displayId);
    if (!activeMode) {
        ALOGE("Failed to hotplug %s", displayString);
@@ -3799,6 +3811,9 @@ std::optional<DisplayModeId> SurfaceFlinger::processHotplugConnect(PhysicalDispl
        state.physical->port = port;
        ALOGI("Reconnecting %s", displayString);
        return activeModeId;
    } else if (event == HWComposer::HotplugEvent::LinkUnstable) {
        ALOGE("Failed to reconnect unknown %s", displayString);
        return std::nullopt;
    }

    const sp<IBinder> token = sp<BBinder>::make();
+2 −1
Original line number Diff line number Diff line
@@ -1067,7 +1067,8 @@ private:
    // Returns the active mode ID, or nullopt on hotplug failure.
    std::optional<DisplayModeId> processHotplugConnect(PhysicalDisplayId, hal::HWDisplayId,
                                                       DisplayIdentificationInfo&&,
                                                       const char* displayString)
                                                       const char* displayString,
                                                       HWComposer::HotplugEvent event)
            REQUIRES(mStateLock, kMainThreadContext);
    void processHotplugDisconnect(PhysicalDisplayId, const char* displayString)
            REQUIRES(mStateLock, kMainThreadContext);