[PATCH weston v5 23/36] weston: migrate DRM to head-based output API

Pekka Paalanen ppaalanen at gmail.com
Thu Dec 14 11:41:00 UTC 2017


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

Migrate the DRM frontend to use the simple head-based output
configurator, maintaining the exact same features and semantics as
before.

This is an intermediate step. It is unoptimal to create a weston_output
just to turn it off, but the libweston implementation and the DRM
backend require it for now. In the future, the DRM frontend will get its
own configurator that does not create useless weston_outputs and
supports clone mode by attaching multiple heads to the same
weston_output. Clone mode is not yet supported by libweston/DRM.

This is the last frontend migrated, wet_set_pending_output_handler() is
deleted as dead code.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 compositor/main.c | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 55947675..e171e12d 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -83,7 +83,6 @@ struct wet_head_tracker {
 struct wet_compositor {
 	struct weston_config *config;
 	struct wet_output_config *parsed_options;
-	struct wl_listener pending_output_listener;
 	bool drm_use_current_mode;
 	int (*simple_output_configure)(struct weston_output *output);
 	bool init_failed;
@@ -444,16 +443,6 @@ to_wet_compositor(struct weston_compositor *compositor)
 	return weston_compositor_get_user_data(compositor);
 }
 
-static void
-wet_set_pending_output_handler(struct weston_compositor *ec,
-			       wl_notify_func_t handler)
-{
-	struct wet_compositor *compositor = to_wet_compositor(ec);
-
-	compositor->pending_output_listener.notify = handler;
-	wl_signal_add(&ec->output_pending_signal, &compositor->pending_output_listener);
-}
-
 static struct wet_output_config *
 wet_init_parsed_options(struct weston_compositor *ec)
 {
@@ -1238,6 +1227,10 @@ simple_head_enable(struct weston_compositor *compositor, struct weston_head *hea
 		return;
 	}
 
+	/* Escape hatch for DRM backend "off" setting. */
+	if (ret > 0)
+		return;
+
 	if (weston_output_enable(output) < 0) {
 		weston_log("Enabling output \"%s\" failed.\n",
 			   weston_head_get_name(head));
@@ -1328,10 +1321,9 @@ configure_input_device(struct weston_compositor *compositor,
 	}
 }
 
-static void
-drm_backend_output_configure(struct wl_listener *listener, void *data)
+static int
+drm_backend_output_configure(struct weston_output *output)
 {
-	struct weston_output *output = data;
 	struct weston_config *wc = wet_get_config(output->compositor);
 	struct wet_compositor *wet = to_wet_compositor(output->compositor);
 	struct weston_config_section *section;
@@ -1346,7 +1338,7 @@ drm_backend_output_configure(struct wl_listener *listener, void *data)
 
 	if (!api) {
 		weston_log("Cannot use weston_drm_output_api.\n");
-		return;
+		return -1;
 	}
 
 	section = weston_config_get_section(wc, "output", "name", output->name);
@@ -1355,7 +1347,7 @@ drm_backend_output_configure(struct wl_listener *listener, void *data)
 	if (strcmp(s, "off") == 0) {
 		weston_output_disable(output);
 		free(s);
-		return;
+		return 1;
 	} else if (wet->drm_use_current_mode || strcmp(s, "current") == 0) {
 		mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
 	} else if (strcmp(s, "preferred") != 0) {
@@ -1367,7 +1359,7 @@ drm_backend_output_configure(struct wl_listener *listener, void *data)
 	if (api->set_mode(output, mode, modeline) < 0) {
 		weston_log("Cannot configure an output using weston_drm_output_api.\n");
 		free(modeline);
-		return;
+		return -1;
 	}
 	free(modeline);
 
@@ -1385,7 +1377,7 @@ drm_backend_output_configure(struct wl_listener *listener, void *data)
 	api->set_seat(output, seat);
 	free(seat);
 
-	weston_output_enable(output);
+	return 0;
 }
 
 static int
@@ -1419,11 +1411,11 @@ load_drm_backend(struct weston_compositor *c,
 	config.base.struct_size = sizeof(struct weston_drm_backend_config);
 	config.configure_device = configure_input_device;
 
+	wet_set_simple_head_configurator(c, drm_backend_output_configure);
+
 	ret = weston_compositor_load_backend(c, WESTON_BACKEND_DRM,
 					     &config.base);
 
-	wet_set_pending_output_handler(c, drm_backend_output_configure);
-
 	free(config.gbm_format);
 	free(config.seat_id);
 
-- 
2.13.6



More information about the wayland-devel mailing list