compositor-drm: preserve CRTC routing harder
If we are processing a connector that does not have an existing routing,
it is possible we pick a CRTC that was previously routed to a connector
we have not enabled yet. If that happens, the latter connector cannot
preserve its routing.
Check that no other connector we might enable later had this CRTC
before.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index d983e1c..851446b 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -4788,7 +4788,9 @@
unsigned j, n = 0;
uint32_t crtc_id;
int best_crtc_index = -1;
+ int fallback_crtc_index = -1;
int i;
+ bool match;
backend = to_drm_backend(output->base.compositor);
@@ -4829,12 +4831,37 @@
return i;
}
- best_crtc_index = i;
+ /* Check if any other head had existing routing to this CRTC.
+ * If they did, this is not the best CRTC as it might be needed
+ * for another output we haven't enabled yet. */
+ match = false;
+ wl_list_for_each(base, &backend->compositor->head_list,
+ compositor_link) {
+ head = to_drm_head(base);
+
+ if (head->base.output == &output->base)
+ continue;
+
+ if (weston_head_is_enabled(&head->base))
+ continue;
+
+ if (head->inherited_crtc_id == crtc_id) {
+ match = true;
+ break;
+ }
+ }
+ if (!match)
+ best_crtc_index = i;
+
+ fallback_crtc_index = i;
}
if (best_crtc_index != -1)
return best_crtc_index;
+ if (fallback_crtc_index != -1)
+ return fallback_crtc_index;
+
/* Likely possible_crtcs was empty due to asking for clones,
* but since the DRM documentation says the kernel lies, let's
* pick one crtc anyway. Trial and error is the only way to