|
|
@ -35,37 +35,30 @@ struct cms_static { |
|
|
|
struct weston_compositor *ec; |
|
|
|
struct weston_compositor *ec; |
|
|
|
struct wl_listener destroy_listener; |
|
|
|
struct wl_listener destroy_listener; |
|
|
|
struct wl_listener output_created_listener; |
|
|
|
struct wl_listener output_created_listener; |
|
|
|
struct wl_list configured_output_list; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct cms_configured_output { |
|
|
|
|
|
|
|
char *icc_profile; |
|
|
|
|
|
|
|
char *name; |
|
|
|
|
|
|
|
struct wl_list link; |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
cms_output_created(struct cms_static *cms, struct weston_output *o) |
|
|
|
cms_output_created(struct cms_static *cms, struct weston_output *o) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct cms_configured_output *configured_output; |
|
|
|
|
|
|
|
struct weston_color_profile *p; |
|
|
|
struct weston_color_profile *p; |
|
|
|
|
|
|
|
struct weston_config_section *s; |
|
|
|
|
|
|
|
char *profile; |
|
|
|
|
|
|
|
|
|
|
|
weston_log("cms-static: output %i [%s] created\n", o->id, o->name); |
|
|
|
weston_log("cms-static: output %i [%s] created\n", o->id, o->name); |
|
|
|
|
|
|
|
|
|
|
|
/* find profile from configured list */ |
|
|
|
s = weston_config_get_section(cms->ec->config, |
|
|
|
wl_list_for_each(configured_output, &cms->configured_output_list, link) { |
|
|
|
"output", "name", o->name); |
|
|
|
if (strcmp (o->name, configured_output->name) == 0) { |
|
|
|
if (s == NULL) |
|
|
|
p = weston_cms_load_profile(configured_output->icc_profile); |
|
|
|
return; |
|
|
|
if (p == NULL) { |
|
|
|
if (weston_config_section_get_string(s, "icc_profile", &profile, NULL) < 0) |
|
|
|
weston_log("cms-static: failed to load %s\n", |
|
|
|
return; |
|
|
|
configured_output->icc_profile); |
|
|
|
p = weston_cms_load_profile(profile); |
|
|
|
} else { |
|
|
|
if (p == NULL) { |
|
|
|
weston_log("cms-static: loading %s for %s\n", |
|
|
|
weston_log("cms-static: failed to load %s\n", profile); |
|
|
|
configured_output->icc_profile, o->name); |
|
|
|
} else { |
|
|
|
weston_cms_set_color_profile(o, p); |
|
|
|
weston_log("cms-static: loading %s for %s\n", |
|
|
|
} |
|
|
|
profile, o->name); |
|
|
|
break; |
|
|
|
weston_cms_set_color_profile(o, p); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -81,14 +74,6 @@ cms_notifier_output_created(struct wl_listener *listener, void *data) |
|
|
|
static void |
|
|
|
static void |
|
|
|
cms_module_destroy(struct cms_static *cms) |
|
|
|
cms_module_destroy(struct cms_static *cms) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct cms_configured_output *configured_output, *next_co; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_list_for_each_safe(configured_output, next_co, |
|
|
|
|
|
|
|
&cms->configured_output_list, link) { |
|
|
|
|
|
|
|
free(configured_output->name); |
|
|
|
|
|
|
|
free(configured_output->icc_profile); |
|
|
|
|
|
|
|
free(configured_output); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
free(cms); |
|
|
|
free(cms); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -99,36 +84,6 @@ cms_notifier_destroy(struct wl_listener *listener, void *data) |
|
|
|
cms_module_destroy(cms); |
|
|
|
cms_module_destroy(cms); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static char *output_icc_profile; |
|
|
|
|
|
|
|
static char *output_name; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
output_section_done(void *data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct cms_configured_output *configured_output; |
|
|
|
|
|
|
|
struct cms_static *cms = (struct cms_static *) data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (output_name == NULL || output_icc_profile == NULL) { |
|
|
|
|
|
|
|
free(output_name); |
|
|
|
|
|
|
|
free(output_icc_profile); |
|
|
|
|
|
|
|
output_name = NULL; |
|
|
|
|
|
|
|
output_icc_profile = NULL; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
weston_log("cms-static: output %s profile configured as %s\n", |
|
|
|
|
|
|
|
output_name, output_icc_profile); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* create an object used to store name<->profile data to avoid parsing
|
|
|
|
|
|
|
|
* the config file every time a new output is added */ |
|
|
|
|
|
|
|
configured_output = malloc(sizeof *configured_output); |
|
|
|
|
|
|
|
memset(configured_output, 0, sizeof *configured_output); |
|
|
|
|
|
|
|
configured_output->name = output_name; |
|
|
|
|
|
|
|
configured_output->icc_profile = output_icc_profile; |
|
|
|
|
|
|
|
wl_list_insert(&cms->configured_output_list, &configured_output->link); |
|
|
|
|
|
|
|
output_name = NULL; |
|
|
|
|
|
|
|
output_icc_profile = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WL_EXPORT int |
|
|
|
WL_EXPORT int |
|
|
|
module_init(struct weston_compositor *ec, |
|
|
|
module_init(struct weston_compositor *ec, |
|
|
@ -145,22 +100,7 @@ module_init(struct weston_compositor *ec, |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
memset(cms, 0, sizeof *cms); |
|
|
|
memset(cms, 0, sizeof *cms); |
|
|
|
|
|
|
|
|
|
|
|
wl_list_init(&cms->configured_output_list); |
|
|
|
cms->ec = ec; |
|
|
|
|
|
|
|
|
|
|
|
/* parse config file */ |
|
|
|
|
|
|
|
const struct config_key drm_config_keys[] = { |
|
|
|
|
|
|
|
{ "name", CONFIG_KEY_STRING, &output_name }, |
|
|
|
|
|
|
|
{ "icc_profile", CONFIG_KEY_STRING, &output_icc_profile }, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const struct config_section config_section[] = { |
|
|
|
|
|
|
|
{ "output", drm_config_keys, |
|
|
|
|
|
|
|
ARRAY_LENGTH(drm_config_keys), output_section_done }, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parse_config_file(ec->config_fd, config_section, |
|
|
|
|
|
|
|
ARRAY_LENGTH(config_section), cms); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cms->destroy_listener.notify = cms_notifier_destroy; |
|
|
|
cms->destroy_listener.notify = cms_notifier_destroy; |
|
|
|
wl_signal_add(&ec->destroy_signal, &cms->destroy_listener); |
|
|
|
wl_signal_add(&ec->destroy_signal, &cms->destroy_listener); |
|
|
|
|
|
|
|
|
|
|
|