[PATCH weston 1/3] compositor-drm: Remove crtc_allocator

Daniel Stone daniels at collabora.com
Thu Feb 9 14:54:26 UTC 2017


crtc_allocator was used as a bitmask of CRTC IDs, so we didn't try to
use the same CRTC for multiple outputs. Unfortunately, this only works
to the extent that CRTC object IDs fit within the bitmask; though they
were previously, they are not guaranteed to be under 32 or even 64.

Replace the only use of crtc_allocator with a list walk across outputs.

Signed-off-by: Daniel Stone <daniels at collabora.com>
Reported-by: Peter Senna Tschudin <peter.senna at collabora.com>
---
 libweston/compositor-drm.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 7f1eeda9a..c7da44722 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -94,7 +94,6 @@ struct drm_backend {
 		char *filename;
 	} drm;
 	struct gbm_device *gbm;
-	uint32_t crtc_allocator;
 	uint32_t connector_allocator;
 	struct wl_listener session_listener;
 	uint32_t gbm_format;
@@ -1819,9 +1818,31 @@ 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])))
-				return i;
+			struct drm_output *tmp;
+			bool crtc_in_use = false;
+
+			if (!(possible_crtcs & (1 << i)))
+				continue;
+
+			wl_list_for_each(tmp, &b->compositor->output_list,
+					 base.link) {
+				if (tmp->crtc_id == resources->crtcs[i]) {
+					crtc_in_use = true;
+					break;
+				}
+			}
+			wl_list_for_each(tmp, &b->compositor->pending_output_list,
+					 base.link) {
+				if (tmp->crtc_id == resources->crtcs[i]) {
+					crtc_in_use = true;
+					break;
+				}
+			}
+
+			if (crtc_in_use)
+				continue;
+
+			return i;
 		}
 	}
 
@@ -2507,7 +2528,6 @@ drm_output_destroy(struct weston_output *base)
 	if (output->backlight)
 		backlight_destroy(output->backlight);
 
-	b->crtc_allocator &= ~(1 << output->crtc_id);
 	b->connector_allocator &= ~(1 << output->connector_id);
 
 	free(output);
@@ -2585,7 +2605,6 @@ create_output_for_connector(struct drm_backend *b,
 	output->disable_pending = 0;
 	output->original_crtc = NULL;
 
-	b->crtc_allocator |= (1 << output->crtc_id);
 	b->connector_allocator |= (1 << output->connector_id);
 
 	weston_output_init(&output->base, b->compositor);
-- 
2.11.0



More information about the wayland-devel mailing list