[PATCH weston v6 09/73] cms-colord: find a good head

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 16 14:56:54 UTC 2018


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

The 'head' member of 'struct weston_output' is going to go unused and
then disappear, so stop using it and find a head from the proper list.

However, this leaves a problem in cms-colord: if you have multiple
monitors driver with the same CRTC, what do you say to the color
management system? The monitors could be different, but all the color
LUTs etc. are in the CRTC and are shared, as is the framebuffer.

Do the simple hack here and just use whatever head happens to be the
first in the list.

The warning is printed in get_output_id(), because if heads are added or
removed while the output is enabled, the id could change.

v6:
- add weston_output_get_first_head(), at first use
- add warning message for nr. heads > 1

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 compositor/cms-colord.c | 17 +++++++++++++++--
 libweston/compositor.c  | 18 ++++++++++++++++++
 libweston/compositor.h  |  3 +++
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/compositor/cms-colord.c b/compositor/cms-colord.c
index f421773b..b68e4921 100644
--- a/compositor/cms-colord.c
+++ b/compositor/cms-colord.c
@@ -102,10 +102,20 @@ edid_value_valid(const char *str)
 static gchar *
 get_output_id(struct cms_colord *cms, struct weston_output *o)
 {
-	struct weston_head *head = &o->head;
+	struct weston_head *head;
 	const gchar *tmp;
 	GString *device_id;
 
+	/* XXX: What to do with multiple heads?
+	 * This is potentially unstable, if head configuration is changed
+	 * while the output is enabled. */
+	head = weston_output_get_first_head(o);
+
+	if (wl_list_length(&o->head_list) > 1) {
+		weston_log("colord: WARNING: multiple heads are not supported (output %s).\n",
+			   o->name);
+	}
+
 	/* see https://github.com/hughsie/colord/blob/master/doc/device-and-profile-naming-spec.txt
 	 * for format and allowed values */
 	device_id = g_string_new("xrandr");
@@ -231,7 +241,7 @@ colord_notifier_output_destroy(struct wl_listener *listener, void *data)
 static void
 colord_output_created(struct cms_colord *cms, struct weston_output *o)
 {
-	struct weston_head *head = &o->head;
+	struct weston_head *head;
 	CdDevice *device;
 	const gchar *tmp;
 	gchar *device_id;
@@ -239,6 +249,9 @@ colord_output_created(struct cms_colord *cms, struct weston_output *o)
 	GHashTable *device_props;
 	struct cms_output *ocms;
 
+	/* XXX: What to do with multiple heads? */
+	head = weston_output_get_first_head(o);
+
 	/* create device */
 	device_id = get_output_id(cms, o);
 	weston_log("colord: output added %s\n", device_id);
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 4647679d..a73af222 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -5243,6 +5243,24 @@ weston_output_release(struct weston_output *output)
 	free(output->name);
 }
 
+/** When you need a head...
+ *
+ * This function is a hack, used until all code has been converted to become
+ * multi-head aware.
+ *
+ * \param output The weston_output whose head to get.
+ * \return The first head in the output's list.
+ */
+WL_EXPORT struct weston_head *
+weston_output_get_first_head(struct weston_output *output)
+{
+	if (wl_list_empty(&output->head_list))
+		return NULL;
+
+	return container_of(output->head_list.next,
+			    struct weston_head, output_link);
+}
+
 static void
 destroy_viewport(struct wl_resource *resource)
 {
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 8a4ddd74..78b6e2f6 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -1994,6 +1994,9 @@ weston_pending_output_coldplug(struct weston_compositor *compositor);
 struct weston_head *
 weston_head_from_resource(struct wl_resource *resource);
 
+struct weston_head *
+weston_output_get_first_head(struct weston_output *output);
+
 #ifdef  __cplusplus
 }
 #endif
-- 
2.13.6



More information about the wayland-devel mailing list