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

Daniel Stone daniels at collabora.com
Thu Feb 9 16:44:23 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 | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

v2: Split drm_output_find_by_crtc into a separate function.

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 7f1eeda9a..5f1ca9592 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;
@@ -239,6 +238,25 @@ drm_sprite_crtc_supported(struct drm_output *output, struct drm_sprite *sprite)
 	return !!(sprite->possible_crtcs & (1 << output->pipe));
 }
 
+static struct drm_output *
+drm_output_find_by_crtc(struct drm_backend *b, uint32_t crtc_id)
+{
+	struct drm_output *output;
+
+	wl_list_for_each(output, &b->compositor->output_list, base.link) {
+		if (output->crtc_id == crtc_id)
+			return output;
+	}
+
+	wl_list_for_each(output, &b->compositor->pending_output_list,
+			 base.link) {
+		if (output->crtc_id == crtc_id)
+			return output;
+	}
+
+	return NULL;
+}
+
 static void
 drm_fb_destroy_callback(struct gbm_bo *bo, void *data)
 {
@@ -1819,9 +1837,13 @@ 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;
+			if (!(possible_crtcs & (1 << i)))
+				continue;
+
+			if (drm_output_find_by_crtc(b, resources->crtcs[i]))
+				continue;
+
+			return i;
 		}
 	}
 
@@ -2507,7 +2529,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 +2606,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