[PATCH weston 1/1] weston: add force-on option for DRM

Pekka Paalanen ppaalanen at gmail.com
Wed May 23 12:47:07 UTC 2018


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

Add a new boolean output section key "force-on". When set to true, the
output will be enabled regardless of connector status. This is the
opposite of the mode=off setting.

Forcing connectors on is useful in special circumstances: avoid output
configuration changes due to hotplug e.g. with KVM switches, or hardware
with unreliable connector status readout for example.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 compositor/main.c  | 22 ++++++++++++++++++++--
 man/weston-drm.man |  8 ++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index fd07aa95..7779108b 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1511,6 +1511,22 @@ drm_head_prepare_enable(struct wet_compositor *wet,
 	}
 }
 
+static bool
+drm_head_should_force_enable(struct wet_compositor *wet,
+			     struct weston_head *head)
+{
+	const char *name = weston_head_get_name(head);
+	struct weston_config_section *section;
+	int force = 0;
+
+	section = drm_config_find_controlling_output_section(wet->config, name);
+	if (!section)
+		return false;
+
+	weston_config_section_get_bool(section, "force-on", &force, 0);
+	return !!force;
+}
+
 static void
 drm_try_attach(struct weston_output *output,
 	       struct wet_head_array *add,
@@ -1700,6 +1716,7 @@ drm_heads_changed(struct wl_listener *listener, void *arg)
 	bool connected;
 	bool enabled;
 	bool changed;
+	bool forced;
 
 	/* We need to collect all cloned heads into outputs before enabling the
 	 * output.
@@ -1708,10 +1725,11 @@ drm_heads_changed(struct wl_listener *listener, void *arg)
 		connected = weston_head_is_connected(head);
 		enabled = weston_head_is_enabled(head);
 		changed = weston_head_is_device_changed(head);
+		forced = drm_head_should_force_enable(wet, head);
 
-		if (connected && !enabled) {
+		if ((connected || forced) && !enabled) {
 			drm_head_prepare_enable(wet, head);
-		} else if (!connected && enabled) {
+		} else if (!(connected || forced) && enabled) {
 			drm_head_disable(head);
 		} else if (enabled && changed) {
 			weston_log("Detected a monitor change on head '%s', "
diff --git a/man/weston-drm.man b/man/weston-drm.man
index 3295be81..308e0a70 100644
--- a/man/weston-drm.man
+++ b/man/weston-drm.man
@@ -91,6 +91,14 @@ NOTE: cms-colord plugin does not work correctly with this option. The plugin
 chooses an arbitrary monitor to load the color profile for, but the
 profile is applied equally to all cloned monitors regardless of their
 properties.
+.TP
+\fBforce-on\fR=\fItrue\fR
+Force the output to be enabled even if the connector is disconnected.
+Defaults to false. Note that
+.BR mode=off " will override " force-on=true .
+When a connector is disconnected, there is no EDID information to provide
+a list of video modes. Therefore a forced output should also have a
+detailed mode line specified.
 .
 .\" ***************************************************************
 .SH OPTIONS
-- 
2.16.1



More information about the wayland-devel mailing list