hc
2023-11-20 2e7bd41e4e8ab3d1efdabd9e263a2f7fe79bff8c
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
45
46
47
From 6d5750788b6fbe065c31a8e33977fc6a3dd94059 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Fri, 2 Apr 2021 11:23:36 +0800
Subject: [PATCH 05/74] backend-drm: Bind Nth primary plane to Nth CRTC
 
The vop2 allows primary planes to bind with random CRTC, but we need to
use the same pair as the driver registered.
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 libweston/backend-drm/drm.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
 
diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c
index 4278770..e557d41 100644
--- a/libweston/backend-drm/drm.c
+++ b/libweston/backend-drm/drm.c
@@ -842,10 +842,26 @@ drm_output_find_special_plane(struct drm_backend *b, struct drm_output *output,
                   enum wdrm_plane_type type)
 {
     struct drm_plane *plane;
+    int num_primary;
 
-    wl_list_for_each(plane, &b->plane_list, link) {
+    num_primary = 0;
+    wl_list_for_each_reverse(plane, &b->plane_list, link) {
         struct drm_output *tmp;
         bool found_elsewhere = false;
+        bool is_primary = plane->type == WDRM_PLANE_TYPE_PRIMARY;
+
+        if (is_primary)
+            num_primary ++;
+
+        /**
+         * HACK: Assuming Nth primary plane (or cursor) is the primary
+         * plane for the Nth crtc.
+         * See:
+         * https://lore.kernel.org/dri-devel/20200807090706.GA2352366@phenom.ffwll.local/
+         */
+        if (type == WDRM_PLANE_TYPE_PRIMARY &&
+            num_primary - 1 != output->crtc->pipe)
+            continue;
 
         if (plane->type != type)
             continue;
-- 
2.20.1