summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/meta-ti/recipes-arago/weston/weston/0001-compositor-drm-fix-hotplug-weston-termination-proble.patch
blob: fde38d52bc1b66053d8d56223b8e0b30199b7b50 (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
From 8497d95cc77af9bbdbbce03878e9fd273d94ba7f Mon Sep 17 00:00:00 2001
From: Eric Ruei <e-ruei1@ti.com>
Date: Wed, 7 Dec 2016 15:25:25 -0500
Subject: [PATCH] compositor-drm: fix hotplug weston termination problem

The weston_compositor_exit() is always invoked at function update_outputs()
if all connector ids are greater than 31 because the 32-bit b->connector_allocator
will be zero. Need to increase the size of both crtc_allocator and
connector_allocator from 32-bit to 64-bit until a better solution is implemented.

Upstream-Status: Submitted [wayland-devel@lists.freedesktop.org]

Signed-off-by: Eric Ruei <e-ruei1@ti.com>
---
 src/compositor-drm.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 6485b39..e4d889f 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -103,8 +103,8 @@ struct drm_backend {
 	struct gbm_device *gbm;
 	uint32_t *crtcs;
 	int num_crtcs;
-	uint32_t crtc_allocator;
-	uint32_t connector_allocator;
+	uint64_t crtc_allocator;
+	uint64_t connector_allocator;
 	struct wl_listener session_listener;
 	uint32_t format;
 
@@ -1360,8 +1360,8 @@ drm_output_destroy(struct weston_output *output_base)
 		       &output->connector_id, 1, &origcrtc->mode);
 	drmModeFreeCrtc(origcrtc);
 
-	b->crtc_allocator &= ~(1 << output->crtc_id);
-	b->connector_allocator &= ~(1 << output->connector_id);
+	b->crtc_allocator &= ~(1ULL << output->crtc_id);
+	b->connector_allocator &= ~(1ULL << output->connector_id);
 
 	if (b->use_pixman) {
 		drm_output_fini_pixman(output);
@@ -1842,8 +1842,8 @@ find_crtc_for_connector(struct drm_backend *b,
 		drmModeFreeEncoder(encoder);
 
 		for (i = 0; i < resources->count_crtcs; i++) {
-			if (possible_crtcs & (1 << i) &&
-			    !(b->crtc_allocator & (1 << resources->crtcs[i])))
+			if (possible_crtcs & (1ULL << i) &&
+			    !(b->crtc_allocator & (1ULL << resources->crtcs[i])))
 				return i;
 		}
 	}
@@ -2404,9 +2404,9 @@ create_output_for_connector(struct drm_backend *b,
 
 	output->crtc_id = resources->crtcs[i];
 	output->pipe = i;
-	b->crtc_allocator |= (1 << output->crtc_id);
+	b->crtc_allocator |= (1ULL << output->crtc_id);
 	output->connector_id = connector->connector_id;
-	b->connector_allocator |= (1 << output->connector_id);
+	b->connector_allocator |= (1ULL << output->connector_id);
 
 	output->original_crtc = drmModeGetCrtc(b->drm.fd, output->crtc_id);
 	output->dpms_prop = drm_get_prop(b->drm.fd, connector, "DPMS");
@@ -2511,8 +2511,8 @@ err_free:
 	}
 
 	drmModeFreeCrtc(output->original_crtc);
-	b->crtc_allocator &= ~(1 << output->crtc_id);
-	b->connector_allocator &= ~(1 << output->connector_id);
+	b->crtc_allocator &= ~(1ULL << output->crtc_id);
+	b->connector_allocator &= ~(1ULL << output->connector_id);
 	free(output);
 
 	return -1;
@@ -2658,7 +2658,7 @@ update_outputs(struct drm_backend *b, struct udev_device *drm_device)
 	drmModeRes *resources;
 	struct drm_output *output, *next;
 	int x = 0, y = 0;
-	uint32_t connected = 0, disconnects = 0;
+	uint64_t connected = 0, disconnects = 0;
 	int i;
 
 	resources = drmModeGetResources(b->drm.fd);
@@ -2680,9 +2680,9 @@ update_outputs(struct drm_backend *b, struct udev_device *drm_device)
 			continue;
 		}
 
-		connected |= (1 << connector_id);
+		connected |= (1ULL << connector_id);
 
-		if (!(b->connector_allocator & (1 << connector_id))) {
+		if (!(b->connector_allocator & (1ULL << connector_id))) {
 			struct weston_output *last =
 				container_of(b->compositor->output_list.prev,
 					     struct weston_output, link);
@@ -2707,8 +2707,8 @@ update_outputs(struct drm_backend *b, struct udev_device *drm_device)
 	if (disconnects) {
 		wl_list_for_each_safe(output, next, &b->compositor->output_list,
 				      base.link) {
-			if (disconnects & (1 << output->connector_id)) {
-				disconnects &= ~(1 << output->connector_id);
+			if (disconnects & (1ULL << output->connector_id)) {
+				disconnects &= ~(1ULL << output->connector_id);
 				weston_log("connector %d disconnected\n",
 				       output->connector_id);
 				drm_output_destroy(&output->base);
-- 
1.9.1