2 * Copyright © 2013 Richard Hughes
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28 #include "compositor.h"
29 #include "cms-helper.h"
32 struct weston_compositor *ec;
33 struct wl_listener destroy_listener;
34 struct wl_listener output_created_listener;
38 cms_output_created(struct cms_static *cms, struct weston_output *o)
40 struct weston_color_profile *p;
41 struct weston_config_section *s;
44 weston_log("cms-static: output %i [%s] created\n", o->id, o->name);
48 s = weston_config_get_section(cms->ec->config,
49 "output", "name", o->name);
52 if (weston_config_section_get_string(s, "icc_profile", &profile, NULL) < 0)
54 p = weston_cms_load_profile(profile);
56 weston_log("cms-static: failed to load %s\n", profile);
58 weston_log("cms-static: loading %s for %s\n",
60 weston_cms_set_color_profile(o, p);
65 cms_notifier_output_created(struct wl_listener *listener, void *data)
67 struct weston_output *o = (struct weston_output *) data;
68 struct cms_static *cms =
69 container_of(listener, struct cms_static, output_created_listener);
70 cms_output_created(cms, o);
74 cms_module_destroy(struct cms_static *cms)
80 cms_notifier_destroy(struct wl_listener *listener, void *data)
82 struct cms_static *cms = container_of(listener, struct cms_static, destroy_listener);
83 cms_module_destroy(cms);
88 module_init(struct weston_compositor *ec,
89 int *argc, char *argv[])
91 struct cms_static *cms;
92 struct weston_output *output;
94 weston_log("cms-static: initialized\n");
96 /* create local state object */
97 cms = zalloc(sizeof *cms);
102 cms->destroy_listener.notify = cms_notifier_destroy;
103 wl_signal_add(&ec->destroy_signal, &cms->destroy_listener);
105 cms->output_created_listener.notify = cms_notifier_output_created;
106 wl_signal_add(&ec->output_created_signal, &cms->output_created_listener);
108 /* discover outputs */
109 wl_list_for_each(output, &ec->output_list, link)
110 cms_output_created(cms, output);