commit b97892417ec1649c780e85e403842a77a6ab87b6
Author: Xaver Hugl <xaver.hugl@gmail.com>
Date:   Wed Feb 26 12:58:09 2025 +0100

    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)

diff --git a/src/backends/drm/drm_gpu.cpp b/src/backends/drm/drm_gpu.cpp
index 9291b5296d..4599b3dc46 100644
--- a/src/backends/drm/drm_gpu.cpp
+++ b/src/backends/drm/drm_gpu.cpp
@@ -345,15 +345,7 @@ void DrmGpu::removeOutputs()
 
 DrmPipeline::Error DrmGpu::checkCrtcAssignment(QList<DrmConnector *> connectors, const QList<DrmCrtc *> &crtcs)
 {
-    if (connectors.isEmpty() || crtcs.isEmpty()) {
-        if (m_pipelines.isEmpty()) {
-            // nothing to do
-            return DrmPipeline::Error::None;
-        }
-        if (!connectors.empty()) {
-            // we have no crtcs left to drive the remaining connectors
-            return DrmPipeline::Error::InvalidArguments;
-        }
+    if (connectors.isEmpty()) {
         return testPipelines();
     }
     auto connector = connectors.takeFirst();
@@ -363,6 +355,10 @@ DrmPipeline::Error DrmGpu::checkCrtcAssignment(QList<DrmConnector *> connectors,
         pipeline->setCrtc(nullptr);
         return checkCrtcAssignment(connectors, crtcs);
     }
+    if (crtcs.isEmpty()) {
+        // we have no crtc left to drive this connector
+        return DrmPipeline::Error::InvalidArguments;
+    }
     DrmCrtc *currentCrtc = nullptr;
     if (m_atomicModeSetting) {
         // try the crtc that this connector is already connected to first
