From 5e5b5a9f7c7d7170b303b26a2e1cb99930357f1c Mon Sep 17 00:00:00 2001
From: Xaver Hugl <xaver.hugl@gmail.com>
Date: Sat, 12 Oct 2024 18:18:53 +0200
Subject: [PATCH] backends/drm: if no cursor plane is available, fall back to
 an overlay plane

While we should have more generic overlay plane usage handling, this special case is easy
to deal with until we have that more generic infrastructure

(cherry picked from commit 1830494db118d0493937a2e442c6a0a986ae3d51)
---
 src/backends/drm/drm_gpu.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/backends/drm/drm_gpu.cpp b/src/backends/drm/drm_gpu.cpp
index 15618870e4..6ad191f6b1 100644
--- a/src/backends/drm/drm_gpu.cpp
+++ b/src/backends/drm/drm_gpu.cpp
@@ -183,12 +183,15 @@ void DrmGpu::initDrmResources()
         uint32_t crtcId = resources->crtcs[i];
         QList<DrmPlane *> primaryCandidates;
         QList<DrmPlane *> cursorCandidates;
+        QList<DrmPlane *> overlayCandidates;
         for (const auto &plane : m_planes) {
             if (plane->isCrtcSupported(i) && !assignedPlanes.contains(plane.get())) {
                 if (plane->type.enumValue() == DrmPlane::TypeIndex::Primary) {
                     primaryCandidates.push_back(plane.get());
                 } else if (plane->type.enumValue() == DrmPlane::TypeIndex::Cursor) {
                     cursorCandidates.push_back(plane.get());
+                } else if (plane->type.enumValue() == DrmPlane::TypeIndex::Overlay) {
+                    overlayCandidates.push_back(plane.get());
                 }
             }
         }
@@ -214,8 +217,11 @@ void DrmGpu::initDrmResources()
             return list.empty() ? nullptr : list.front();
         };
         DrmPlane *primary = findBestPlane(primaryCandidates);
-        DrmPlane *cursor = findBestPlane(cursorCandidates);
         assignedPlanes.push_back(primary);
+        DrmPlane *cursor = findBestPlane(cursorCandidates);
+        if (!cursor) {
+            cursor = findBestPlane(overlayCandidates);
+        }
         if (cursor) {
             assignedPlanes.push_back(cursor);
         }
-- 
2.46.2

