[PATCH weston 8/8] compositor-drm: Make output detection order irrelevant

Emmanuel Gil Peyrot emmanuel.peyrot at collabora.com
Mon May 2 21:40:17 UTC 2016


When using the clone mode, the order of detection of outputs shouldn’t
matter for them to be included in a virtual_output or not, this fixes
this issue from the previous patch.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>
---
 src/compositor-drm.c | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index a0ed45f..ed72817 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2426,7 +2426,7 @@ create_output_for_connector(struct drm_backend *b,
 			}
 		}
 		if (logical_output == NULL)
-			return -1;
+			return -2;
 		is_clone = true;
 	} else {
 		logical_output = zalloc(sizeof *logical_output);
@@ -2704,7 +2704,8 @@ create_outputs(struct drm_backend *b, uint32_t option_connector,
 {
 	drmModeConnector *connector;
 	drmModeRes *resources;
-	int i;
+	struct wl_array clones;
+	int i, ret, *clone;
 	int x = 0, y = 0;
 
 	resources = drmModeGetResources(b->drm.fd);
@@ -2727,6 +2728,8 @@ create_outputs(struct drm_backend *b, uint32_t option_connector,
 	b->num_crtcs = resources->count_crtcs;
 	memcpy(b->crtcs, resources->crtcs, sizeof(uint32_t) * b->num_crtcs);
 
+	wl_array_init(&clones);
+
 	for (i = 0; i < resources->count_connectors; i++) {
 		connector = drmModeGetConnector(b->drm.fd,
 						resources->connectors[i]);
@@ -2736,9 +2739,14 @@ create_outputs(struct drm_backend *b, uint32_t option_connector,
 		if (connector->connection == DRM_MODE_CONNECTED &&
 		    (option_connector == 0 ||
 		     connector->connector_id == option_connector)) {
-			if (create_output_for_connector(b, resources,
-							connector, x, y,
-							drm_device) < 0) {
+			ret = create_output_for_connector(b, resources,
+			                                  connector, x, y,
+			                                  drm_device);
+			if (ret == -2) {
+				clone = wl_array_add(&clones, sizeof(int));
+				*clone = i;
+			}
+			if (ret < 0) {
 				drmModeFreeConnector(connector);
 				continue;
 			}
@@ -2750,6 +2758,22 @@ create_outputs(struct drm_backend *b, uint32_t option_connector,
 
 		drmModeFreeConnector(connector);
 	}
+	wl_array_for_each(clone, &clones) {
+		i = *clone;
+		connector = drmModeGetConnector(b->drm.fd,
+						resources->connectors[i]);
+		if (create_output_for_connector(b, resources,
+		                                connector, x, y,
+		                                drm_device) < 0) {
+			drmModeFreeConnector(connector);
+			continue;
+		}
+		x += container_of(b->compositor->output_list.prev,
+		                  struct weston_output,
+		                  link)->width;
+		drmModeFreeConnector(connector);
+	}
+	wl_array_release(&clones);
 
 	if (wl_list_empty(&b->compositor->output_list)) {
 		weston_log("No currently active connector found.\n");
-- 
2.8.2



More information about the wayland-devel mailing list