hc
2023-02-14 0cc9b7c44253c93447ddf73e206fbdbb3d9f16b1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From 38c67d13993fd5454226934a22be558d2a6a8233 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Mon, 23 May 2022 11:46:38 +0800
Subject: [PATCH 1/3] kms: Use Nth primary plane for Nth CRTC
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 src/ws/atomic_kms_window_system.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
 
diff --git a/src/ws/atomic_kms_window_system.cpp b/src/ws/atomic_kms_window_system.cpp
index 1aa7948..b5c2ab5 100644
--- a/src/ws/atomic_kms_window_system.cpp
+++ b/src/ws/atomic_kms_window_system.cpp
@@ -98,6 +98,7 @@ ManagedResource<drmModePlanePtr> get_plane_for_crtc(
     if (!plane_resources)
         throw ErrnoError{"Failed to get plane resources"};
 
+    auto num_primaries = 0;
     for (auto i = 0u; i < plane_resources->count_planes; ++i)
     {
         auto plane = ManagedResource<drmModePlanePtr>{
@@ -107,12 +108,17 @@ ManagedResource<drmModePlanePtr> get_plane_for_crtc(
         if (!plane)
             throw ErrnoError{"Failed to get plane"};
 
+        if (!is_plane_primary(drm_fd, plane))
+            continue;
+
+        /*  Nth primary plane for Nth CRTC */
+        if (num_primaries ++ != crtc_index)
+            continue;
+
         if (does_plane_support_crtc_index(plane, crtc_index))
         {
             ret_plane = std::move(plane);
 
-            if (is_plane_primary(drm_fd, ret_plane))
-                break;
         }
     }
 
-- 
2.20.1