From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

When a head is detached from an enabled output, that output needs to go
through a modeset (drmModeSetCrtc() / ATOMIC_ALLOW_MODESET) so that the
connector is actually removed from the CRTC.

This has not yet been a problem, because an output could only have one
head at a time, and would be automatically disabled on detach. It would
be a problem with clone mode.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Acked-by: Derek Foreman <der...@osg.samsung.com>
---
 libweston/compositor-drm.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 43f5c8e0..ed7ac15b 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -4392,6 +4392,23 @@ drm_output_attach_head(struct weston_output *output_base,
        return 0;
 }
 
+static void
+drm_output_detach_head(struct weston_output *output_base,
+                      struct weston_head *head_base)
+{
+       struct drm_backend *b = to_drm_backend(output_base->compositor);
+
+       if (!output_base->enabled)
+               return;
+
+       /* Need to go through modeset to drop connectors that should no longer
+        * be driven. */
+       /* XXX: Ideally we'd do this per-output, not globally. */
+       b->state_invalid = true;
+
+       weston_output_schedule_repaint(output_base);
+}
+
 static int
 parse_gbm_format(const char *s, uint32_t default_value, uint32_t *gbm_format)
 {
@@ -5405,6 +5422,7 @@ drm_output_create(struct weston_compositor *compositor, 
const char *name)
        output->base.destroy = drm_output_destroy;
        output->base.disable = drm_output_disable;
        output->base.attach_head = drm_output_attach_head;
+       output->base.detach_head = drm_output_detach_head;
 
        output->destroy_pending = 0;
        output->disable_pending = 0;
-- 
2.16.1

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to