From: Pekka Paalanen Date: Tue, 4 Apr 2017 13:36:07 +0000 (+0300) Subject: cms-colord: find a good head X-Git-Tag: upstream/5.0.0~201 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf0a476b8e22950b2f4183b12b0690d8ab392d92;p=platform%2Fupstream%2Fweston.git cms-colord: find a good head 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 Reviewed-by: Ian Ray Reviewed-by: Daniel Stone Acked-by: Derek Foreman --- diff --git a/compositor/cms-colord.c b/compositor/cms-colord.c index f421773..b68e492 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 c3a94d3..f5695f8 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -5249,6 +5249,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 604792a..d606fc9 100644 --- a/libweston/compositor.h +++ b/libweston/compositor.h @@ -2000,6 +2000,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