File 0002-backends-drm-fix-testing-for-more-connectors-than-CR.patch of Package failed_kwin6

From 1fccab877dbcbe34dc0dde92c939713f271410d9 Mon Sep 17 00:00:00 2001
From: Xaver Hugl <xaver.hugl@gmail.com>
Date: Wed, 26 Feb 2025 12:58:09 +0100
Subject: [PATCH 2/2] backends/drm: fix testing for more connectors than CRTCs

The connectors may not actually be enabled, so the checks could sometimes result in
wrongly returning Error::NotEnoughCrtcs.

BUG: 500819
CCBUG: 500797

(cherry picked from commit aa11d89a90bc4eb77bfe191a2cadede4d957d2a9)
(cherry picked from commit e652bdd3118fa55563caf0125deb0999f5ebd503)
---
 src/backends/drm/drm_gpu.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/backends/drm/drm_gpu.cpp b/src/backends/drm/drm_gpu.cpp
index de0fd7e212..3107ed5173 100644
--- a/src/backends/drm/drm_gpu.cpp
+++ b/src/backends/drm/drm_gpu.cpp
@@ -345,17 +345,12 @@ void DrmGpu::removeOutputs()
 
 DrmPipeline::Error DrmGpu::checkCrtcAssignment(QList<DrmConnector *> connectors, const QList<DrmCrtc *> &crtcs)
 {
-    qCDebug(KWIN_DRM) << "Attempting to match" << connectors << "with" << crtcs;
-    if (connectors.isEmpty() || crtcs.isEmpty()) {
-        if (!connectors.empty()) {
-            // we have no crtcs left to drive the remaining connectors
-            qCDebug(KWIN_DRM) << "Ran out of CRTCs";
-            return DrmPipeline::Error::InvalidArguments;
-        }
+    if (connectors.isEmpty()) {
         const auto result = testPipelines();
         qCDebug(KWIN_DRM) << "Testing CRTC assignment..." << (result == DrmPipeline::Error::None ? "passed" : "failed");
         return result;
     }
+    qCDebug(KWIN_DRM) << "Attempting to match" << connectors << "with" << crtcs;
     auto connector = connectors.takeFirst();
     auto pipeline = connector->pipeline();
     if (!pipeline->enabled() || !connector->isConnected()) {
@@ -364,6 +359,11 @@ DrmPipeline::Error DrmGpu::checkCrtcAssignment(QList<DrmConnector *> connectors,
         qCDebug(KWIN_DRM) << "Unassigning CRTC from connector" << connector->id();
         return checkCrtcAssignment(connectors, crtcs);
     }
+    if (crtcs.isEmpty()) {
+        // we have no crtc left to drive this connector
+        qCDebug(KWIN_DRM) << "Ran out of CRTCs";
+        return DrmPipeline::Error::InvalidArguments;
+    }
     DrmCrtc *currentCrtc = nullptr;
     if (m_atomicModeSetting) {
         // try the crtc that this connector is already connected to first
-- 
2.48.1

openSUSE Build Service is sponsored by