[PATCH weston 1/2] compositor-drm: let repaint cycle disable crtcs

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 9 10:29:09 UTC 2018


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Rather than smashing the state to disable a CRTC immediately, just
delegate that to the normal repaint cycle by setting state_invalid =
true. drm_pending_state_apply() will pick up the unused_crtcs.

A caveat here is that we have no enabled outputs at all, we will never
enter repaint, and so CRTCs do not actually get turned off until we get
at least one output to drive.

However, this should help the problem reported here:
https://lists.freedesktop.org/archives/wayland-devel/2018-January/036713.html
Arguably it is better to leave an output spuriously on in rare cases
rather than fail modeset completely in somewhat more common cases.

My personal motivation for this change is that it helps if we later move
CRTC allocation to output enable/deinit instead of create/destroy,
because then the CRTC will not be available here for initial turn-off as
the output has not been enabled to begin with.

Cc: Philipp Zabel <p.zabel at pengutronix.de>
Cc: Daniel Stone <daniel at fooishbar.org>
Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 libweston/compositor-drm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 61c9bf5e..b1dbacbd 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -4742,8 +4742,6 @@ drm_output_disable(struct weston_output *base)
 {
 	struct drm_output *output = to_drm_output(base);
 	struct drm_backend *b = to_drm_backend(base->compositor);
-	struct drm_pending_state *pending_state;
-	int ret;
 
 	if (output->page_flip_pending || output->vblank_pending ||
 	    output->atomic_complete_pending) {
@@ -4752,17 +4750,15 @@ drm_output_disable(struct weston_output *base)
 	}
 
 	weston_log("Disabling output %s\n", output->base.name);
-	pending_state = drm_pending_state_alloc(b);
-	drm_output_get_disable_state(pending_state, output);
-	ret = drm_pending_state_apply_sync(pending_state);
-	if (ret)
-		weston_log("Couldn't disable output %s\n", output->base.name);
 
 	if (output->base.enabled)
 		drm_output_deinit(&output->base);
 
 	output->disable_pending = 0;
 
+	/* Force resetting unused connectors and crtcs. */
+	b->state_invalid = true;
+
 	return 0;
 }
 
-- 
2.13.6



More information about the wayland-devel mailing list