compositor: delete cms-static and cms-colord plugins

Plugins cms-static and cms-colord were deprecated with "compositor:
deprecate cms-static and cms-colord plugins", and the promise was that
we'd delete them if no one complained.

They were deprecated 2 years ago, and no one bothered. So it's about
time to delete them.

See https://gitlab.freedesktop.org/wayland/weston/-/issues/634.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
Leandro Ribeiro 2024-07-22 18:21:33 -03:00 committed by Marius Vlad
parent 6449ee9dae
commit f271dd34b6
10 changed files with 5 additions and 1011 deletions

View File

@ -43,7 +43,7 @@
variables: variables:
FDO_UPSTREAM_REPO: wayland/weston FDO_UPSTREAM_REPO: wayland/weston
FDO_REPO_SUFFIX: "$BUILD_OS-$FDO_DISTRIBUTION_VERSION/$BUILD_ARCH" FDO_REPO_SUFFIX: "$BUILD_OS-$FDO_DISTRIBUTION_VERSION/$BUILD_ARCH"
FDO_DISTRIBUTION_TAG: '2024-07-24-00-virtme-ng' FDO_DISTRIBUTION_TAG: '2024-08-05-00-rm-plugins'
include: include:
@ -427,8 +427,6 @@ aarch64-debian-container_prep:
-Db_coverage=true -Db_coverage=true
-Dwerror=true -Dwerror=true
-Dtest-skip-is-failure=true -Dtest-skip-is-failure=true
-Ddeprecated-color-management-static=true
-Ddeprecated-color-management-colord=true
after_script: after_script:
- ninja -C "$BUILDDIR" coverage-html > "$BUILDDIR/meson-logs/ninja-coverage-html.txt" - ninja -C "$BUILDDIR" coverage-html > "$BUILDDIR/meson-logs/ninja-coverage-html.txt"
- ninja -C "$BUILDDIR" coverage-xml - ninja -C "$BUILDDIR" coverage-xml

View File

@ -1,588 +0,0 @@
/*
* Copyright © 2013 Richard Hughes
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <colord.h>
#include <libweston/libweston.h>
#include "weston.h"
#include "cms-helper.h"
#include "shared/helpers.h"
struct cms_colord {
struct weston_compositor *ec;
CdClient *client;
GHashTable *devices; /* key = device-id, value = cms_output */
GHashTable *pnp_ids; /* key = pnp-id, value = vendor */
gchar *pnp_ids_data;
GMainLoop *loop;
GThread *thread;
GList *pending;
GMutex pending_mutex;
struct wl_event_source *source;
int readfd;
int writefd;
struct wl_listener destroy_listener;
struct wl_listener output_created_listener;
};
struct cms_output {
CdDevice *device;
guint32 backlight_value;
struct cms_colord *cms;
struct weston_color_profile *p;
struct weston_output *o;
struct wl_listener destroy_listener;
};
static gint
colord_idle_find_output_cb(gconstpointer a, gconstpointer b)
{
struct cms_output *ocms = (struct cms_output *) a;
struct weston_output *o = (struct weston_output *) b;
return ocms->o == o ? 0 : -1;
}
static void
colord_idle_cancel_for_output(struct cms_colord *cms, struct weston_output *o)
{
GList *l;
/* cancel and remove any helpers that match the output */
g_mutex_lock(&cms->pending_mutex);
l = g_list_find_custom (cms->pending, o, colord_idle_find_output_cb);
if (l) {
struct cms_output *ocms = l->data;
cms->pending = g_list_remove (cms->pending, ocms);
}
g_mutex_unlock(&cms->pending_mutex);
}
static bool
edid_value_valid(const char *str)
{
if (str == NULL)
return false;
if (str[0] == '\0')
return false;
if (strcmp(str, "unknown") == 0)
return false;
return true;
}
static gchar *
get_output_id(struct cms_colord *cms, struct weston_output *o)
{
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");
if (edid_value_valid(head->make)) {
tmp = g_hash_table_lookup(cms->pnp_ids, head->make);
if (tmp == NULL)
tmp = head->make;
g_string_append_printf(device_id, "-%s", tmp);
}
if (edid_value_valid(head->model))
g_string_append_printf(device_id, "-%s", head->model);
if (edid_value_valid(head->serial_number))
g_string_append_printf(device_id, "-%s", head->serial_number);
/* no EDID data, so use fallback */
if (strcmp(device_id->str, "xrandr") == 0)
g_string_append_printf(device_id, "-drm-%i", o->id);
return g_string_free(device_id, FALSE);
}
static void
update_device_with_profile_in_idle(struct cms_output *ocms)
{
gboolean signal_write = FALSE;
ssize_t rc;
struct cms_colord *cms = ocms->cms;
colord_idle_cancel_for_output(cms, ocms->o);
g_mutex_lock(&cms->pending_mutex);
if (cms->pending == NULL)
signal_write = TRUE;
cms->pending = g_list_prepend(cms->pending, ocms);
g_mutex_unlock(&cms->pending_mutex);
/* signal we've got updates to do */
if (signal_write) {
gchar tmp = '\0';
rc = write(cms->writefd, &tmp, 1);
if (rc == 0)
weston_log("colord: failed to write to pending fd\n");
}
}
static void
colord_update_output_from_device (struct cms_output *ocms)
{
CdProfile *profile;
const gchar *tmp;
gboolean ret;
GError *error = NULL;
gint percentage;
/* old profile is no longer valid */
weston_cms_destroy_profile(ocms->p);
ocms->p = NULL;
ret = cd_device_connect_sync(ocms->device, NULL, &error);
if (!ret) {
weston_log("colord: failed to connect to device %s: %s\n",
cd_device_get_object_path (ocms->device),
error->message);
g_error_free(error);
goto out;
}
profile = cd_device_get_default_profile(ocms->device);
if (!profile) {
weston_log("colord: no assigned color profile for %s\n",
cd_device_get_id (ocms->device));
goto out;
}
ret = cd_profile_connect_sync(profile, NULL, &error);
if (!ret) {
weston_log("colord: failed to connect to profile %s: %s\n",
cd_profile_get_object_path (profile),
error->message);
g_error_free(error);
goto out;
}
/* get the calibration brightness level (only set for some profiles) */
tmp = cd_profile_get_metadata_item(profile, CD_PROFILE_METADATA_SCREEN_BRIGHTNESS);
if (tmp != NULL) {
percentage = atoi(tmp);
if (percentage > 0 && percentage <= 100)
ocms->backlight_value = percentage * 255 / 100;
}
ocms->p = weston_cms_load_profile(cd_profile_get_filename(profile));
if (ocms->p == NULL) {
weston_log("colord: warning failed to load profile %s: %s\n",
cd_profile_get_object_path (profile),
error->message);
g_error_free(error);
goto out;
}
out:
update_device_with_profile_in_idle(ocms);
}
static void
colord_device_changed_cb(CdDevice *device, struct cms_output *ocms)
{
weston_log("colord: device %s changed, update output\n",
cd_device_get_object_path (ocms->device));
colord_update_output_from_device(ocms);
}
static void
colord_notifier_output_destroy(struct wl_listener *listener, void *data)
{
struct cms_output *ocms =
container_of(listener, struct cms_output, destroy_listener);
struct weston_output *o = (struct weston_output *) data;
struct cms_colord *cms = ocms->cms;
gchar *device_id;
device_id = get_output_id(cms, o);
g_hash_table_remove (cms->devices, device_id);
g_free (device_id);
}
static void
colord_output_created(struct cms_colord *cms, struct weston_output *o)
{
struct weston_head *head;
CdDevice *device;
const gchar *tmp;
gchar *device_id;
GError *error = NULL;
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);
device_props = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
g_hash_table_insert (device_props,
g_strdup(CD_DEVICE_PROPERTY_KIND),
g_strdup(cd_device_kind_to_string (CD_DEVICE_KIND_DISPLAY)));
g_hash_table_insert (device_props,
g_strdup(CD_DEVICE_PROPERTY_FORMAT),
g_strdup("ColorModel.OutputMode.OutputResolution"));
g_hash_table_insert (device_props,
g_strdup(CD_DEVICE_PROPERTY_COLORSPACE),
g_strdup(cd_colorspace_to_string(CD_COLORSPACE_RGB)));
if (edid_value_valid(head->make)) {
tmp = g_hash_table_lookup(cms->pnp_ids, head->make);
if (tmp == NULL)
tmp = head->make;
g_hash_table_insert (device_props,
g_strdup(CD_DEVICE_PROPERTY_VENDOR),
g_strdup(tmp));
}
if (edid_value_valid(head->model)) {
g_hash_table_insert (device_props,
g_strdup(CD_DEVICE_PROPERTY_MODEL),
g_strdup(head->model));
}
if (edid_value_valid(head->serial_number)) {
g_hash_table_insert (device_props,
g_strdup(CD_DEVICE_PROPERTY_SERIAL),
g_strdup(head->serial_number));
}
if (head->connection_internal) {
g_hash_table_insert (device_props,
g_strdup (CD_DEVICE_PROPERTY_EMBEDDED),
NULL);
}
device = cd_client_create_device_sync(cms->client,
device_id,
CD_OBJECT_SCOPE_TEMP,
device_props,
NULL,
&error);
if (g_error_matches (error,
CD_CLIENT_ERROR,
CD_CLIENT_ERROR_ALREADY_EXISTS)) {
g_clear_error(&error);
device = cd_client_find_device_sync (cms->client,
device_id,
NULL,
&error);
}
if (!device) {
weston_log("colord: failed to create new or "
"find existing device: %s\n",
error->message);
g_error_free(error);
goto out;
}
/* create object and watch for the output to be destroyed */
ocms = g_slice_new0(struct cms_output);
ocms->cms = cms;
ocms->o = o;
ocms->device = g_object_ref(device);
ocms->destroy_listener.notify = colord_notifier_output_destroy;
wl_signal_add(&o->destroy_signal, &ocms->destroy_listener);
/* add to local cache */
g_hash_table_insert (cms->devices, g_strdup(device_id), ocms);
g_signal_connect (ocms->device, "changed",
G_CALLBACK (colord_device_changed_cb), ocms);
/* get profiles */
colord_update_output_from_device (ocms);
out:
g_hash_table_unref (device_props);
if (device)
g_object_unref (device);
g_free (device_id);
}
static void
colord_notifier_output_created(struct wl_listener *listener, void *data)
{
struct weston_output *o = (struct weston_output *) data;
struct cms_colord *cms =
container_of(listener, struct cms_colord, destroy_listener);
weston_log("colord: output %s created\n", o->name);
colord_output_created(cms, o);
}
static gpointer
colord_run_loop_thread(gpointer data)
{
struct cms_colord *cms = (struct cms_colord *) data;
struct weston_output *o;
/* coldplug outputs */
wl_list_for_each(o, &cms->ec->output_list, link) {
weston_log("colord: output %s coldplugged\n", o->name);
colord_output_created(cms, o);
}
g_main_loop_run(cms->loop);
return NULL;
}
static int
colord_dispatch_all_pending(int fd, uint32_t mask, void *data)
{
gchar tmp;
GList *l;
ssize_t rc;
struct cms_colord *cms = data;
struct cms_output *ocms;
weston_log("colord: dispatching events\n");
g_mutex_lock(&cms->pending_mutex);
for (l = cms->pending; l != NULL; l = l->next) {
ocms = l->data;
/* optionally set backlight to calibration value */
if (ocms->o->set_backlight && ocms->backlight_value != 0) {
weston_log("colord: profile calibration backlight to %i/255\n",
ocms->backlight_value);
ocms->o->set_backlight(ocms->o, ocms->backlight_value);
}
weston_cms_set_color_profile(ocms->o, ocms->p);
}
g_list_free (cms->pending);
cms->pending = NULL;
g_mutex_unlock(&cms->pending_mutex);
/* done */
rc = read(cms->readfd, &tmp, 1);
if (rc == 0)
weston_log("colord: failed to read from pending fd\n");
return 1;
}
static void
colord_load_pnp_ids(struct cms_colord *cms)
{
gboolean ret = FALSE;
gchar *tmp;
GError *error = NULL;
guint i;
const gchar *pnp_ids_fn[] = { "/usr/share/hwdata/pnp.ids",
"/usr/share/misc/pnp.ids",
NULL };
/* find and load file */
for (i = 0; pnp_ids_fn[i] != NULL; i++) {
if (!g_file_test(pnp_ids_fn[i], G_FILE_TEST_EXISTS))
continue;
ret = g_file_get_contents(pnp_ids_fn[i],
&cms->pnp_ids_data,
NULL,
&error);
if (!ret) {
weston_log("colord: failed to load %s: %s\n",
pnp_ids_fn[i], error->message);
g_error_free(error);
return;
}
break;
}
if (!ret) {
weston_log("colord: no pnp.ids found\n");
return;
}
/* parse fixed offsets into lines */
tmp = cms->pnp_ids_data;
for (i = 0; cms->pnp_ids_data[i] != '\0'; i++) {
if (cms->pnp_ids_data[i] != '\n')
continue;
cms->pnp_ids_data[i] = '\0';
if (tmp[0] && tmp[1] && tmp[2] && tmp[3] == '\t' && tmp[4]) {
tmp[3] = '\0';
g_hash_table_insert(cms->pnp_ids, tmp, tmp+4);
tmp = &cms->pnp_ids_data[i+1];
}
}
}
static void
colord_module_destroy(struct cms_colord *cms)
{
if (cms->loop) {
g_main_loop_quit(cms->loop);
g_main_loop_unref(cms->loop);
}
if (cms->thread)
g_thread_join(cms->thread);
/* cms->devices must be destroyed before other resources, as
* the other resources are needed during output cleanup in
* cms->devices unref.
*/
if (cms->devices)
g_hash_table_unref(cms->devices);
if (cms->client)
g_object_unref(cms->client);
if (cms->readfd)
close(cms->readfd);
if (cms->writefd)
close(cms->writefd);
g_free(cms->pnp_ids_data);
g_hash_table_unref(cms->pnp_ids);
wl_list_remove(&cms->destroy_listener.link);
free(cms);
}
static void
colord_notifier_destroy(struct wl_listener *listener, void *data)
{
struct cms_colord *cms =
container_of(listener, struct cms_colord, destroy_listener);
colord_module_destroy(cms);
}
static void
colord_cms_output_destroy(gpointer data)
{
struct cms_output *ocms = (struct cms_output *) data;
struct cms_colord *cms = ocms->cms;
struct weston_output *o = ocms->o;
gboolean ret;
gchar *device_id;
GError *error = NULL;
colord_idle_cancel_for_output(cms, o);
device_id = get_output_id(cms, o);
weston_log("colord: output unplugged %s\n", device_id);
wl_list_remove(&ocms->destroy_listener.link);
g_signal_handlers_disconnect_by_data(ocms->device, ocms);
ret = cd_client_delete_device_sync (cms->client,
ocms->device,
NULL,
&error);
if (!ret) {
weston_log("colord: failed to delete device: %s\n",
error->message);
g_error_free(error);
}
g_object_unref(ocms->device);
g_slice_free(struct cms_output, ocms);
g_free (device_id);
}
WL_EXPORT int
wet_module_init(struct weston_compositor *ec,
int *argc, char *argv[])
{
gboolean ret;
GError *error = NULL;
int fd[2];
struct cms_colord *cms;
struct wl_event_loop *loop;
weston_log("colord: initialized\n");
/* create local state object */
cms = zalloc(sizeof *cms);
if (cms == NULL)
return -1;
cms->ec = ec;
if (!weston_compositor_add_destroy_listener_once(ec,
&cms->destroy_listener,
colord_notifier_destroy)) {
free(cms);
return 0;
}
#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init();
#endif
cms->client = cd_client_new();
ret = cd_client_connect_sync(cms->client, NULL, &error);
if (!ret) {
weston_log("colord: failed to contact daemon: %s\n", error->message);
g_error_free(error);
colord_module_destroy(cms);
return -1;
}
g_mutex_init(&cms->pending_mutex);
cms->devices = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, colord_cms_output_destroy);
/* devices added */
cms->output_created_listener.notify = colord_notifier_output_created;
wl_signal_add(&ec->output_created_signal, &cms->output_created_listener);
/* add all the PNP IDs */
cms->pnp_ids = g_hash_table_new_full(g_str_hash,
g_str_equal,
NULL,
NULL);
colord_load_pnp_ids(cms);
/* setup a thread for the GLib callbacks */
cms->loop = g_main_loop_new(NULL, FALSE);
cms->thread = g_thread_new("colord CMS main loop",
colord_run_loop_thread, cms);
/* batch device<->profile updates */
if (pipe2(fd, O_CLOEXEC) == -1) {
colord_module_destroy(cms);
return -1;
}
cms->readfd = fd[0];
cms->writefd = fd[1];
loop = wl_display_get_event_loop(ec->wl_display);
cms->source = wl_event_loop_add_fd (loop,
cms->readfd,
WL_EVENT_READABLE,
colord_dispatch_all_pending,
cms);
if (!cms->source) {
colord_module_destroy(cms);
return -1;
}
return 0;
}

View File

@ -1,136 +0,0 @@
/*
* Copyright © 2013 Richard Hughes
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#ifdef HAVE_LCMS
#include <lcms2.h>
#endif
#include <libweston/libweston.h>
#include "cms-helper.h"
#ifdef HAVE_LCMS
static void
weston_cms_gamma_clear(struct weston_output *o)
{
int i;
uint16_t *red;
if (!o->set_gamma)
return;
red = calloc(o->gamma_size, sizeof(uint16_t));
for (i = 0; i < o->gamma_size; i++)
red[i] = (uint32_t) 0xffff * (uint32_t) i / (uint32_t) (o->gamma_size - 1);
o->set_gamma(o, o->gamma_size, red, red, red);
free(red);
}
#endif
void
weston_cms_set_color_profile(struct weston_output *o,
struct weston_color_profile *p)
{
#ifdef HAVE_LCMS
cmsFloat32Number in;
const cmsToneCurve **vcgt;
int i;
int size;
uint16_t *red = NULL;
uint16_t *green = NULL;
uint16_t *blue = NULL;
if (!o->set_gamma)
return;
if (!p) {
weston_cms_gamma_clear(o);
return;
}
weston_log("Using ICC profile %s\n", p->filename);
vcgt = cmsReadTag (p->lcms_handle, cmsSigVcgtTag);
if (vcgt == NULL || vcgt[0] == NULL) {
weston_cms_gamma_clear(o);
return;
}
size = o->gamma_size;
red = calloc(size, sizeof(uint16_t));
green = calloc(size, sizeof(uint16_t));
blue = calloc(size, sizeof(uint16_t));
for (i = 0; i < size; i++) {
in = (cmsFloat32Number) i / (cmsFloat32Number) (size - 1);
red[i] = cmsEvalToneCurveFloat(vcgt[0], in) * (double) 0xffff;
green[i] = cmsEvalToneCurveFloat(vcgt[1], in) * (double) 0xffff;
blue[i] = cmsEvalToneCurveFloat(vcgt[2], in) * (double) 0xffff;
}
o->set_gamma(o, size, red, green, blue);
free(red);
free(green);
free(blue);
#endif
}
void
weston_cms_destroy_profile(struct weston_color_profile *p)
{
if (!p)
return;
#ifdef HAVE_LCMS
cmsCloseProfile(p->lcms_handle);
#endif
free(p->filename);
free(p);
}
struct weston_color_profile *
weston_cms_create_profile(const char *filename,
void *lcms_profile)
{
struct weston_color_profile *p;
p = zalloc(sizeof(struct weston_color_profile));
p->filename = strdup(filename);
p->lcms_handle = lcms_profile;
return p;
}
struct weston_color_profile *
weston_cms_load_profile(const char *filename)
{
struct weston_color_profile *p = NULL;
#ifdef HAVE_LCMS
cmsHPROFILE lcms_profile;
lcms_profile = cmsOpenProfileFromFile(filename, "r");
if (lcms_profile)
p = weston_cms_create_profile(filename, lcms_profile);
#endif
return p;
}

View File

@ -1,75 +0,0 @@
/*
* Copyright © 2013 Richard Hughes
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef _WESTON_CMS_H_
#define _WESTON_CMS_H_
#include "config.h"
#include <libweston/libweston.h>
/* General overview on how to be a CMS plugin:
*
* First, some nomenclature:
*
* CMF: Color management framework, i.e. "Use foo.icc for device $bar"
* CMM: Color management module that converts pixel colors, which is
* usually lcms2 on any modern OS.
* CMS: Color management system that encompasses both a CMF and CMM.
* ICC: International Color Consortium, the people that define the
* binary encoding of a .icc file.
* VCGT: Video Card Gamma Tag. An Apple extension to the ICC specification
* that allows the calibration state to be stored in the ICC profile
* Output: Physical port with a display attached, e.g. LVDS1
*
* As a CMF is probably something you don't want or need on an embedded install
* these functions will not be called if the icc_profile key is set for a
* specific [output] section in weston.ini
*
* Most desktop environments want the CMF to decide what profile to use in
* different situations, so that displays can be profiled and also so that
* the ICC profiles can be changed at runtime depending on the task or ambient
* environment.
*
* The CMF can be selected using the 'modules' key in the [core] section.
*/
struct weston_color_profile {
char *filename;
void *lcms_handle;
};
void
weston_cms_set_color_profile(struct weston_output *o,
struct weston_color_profile *p);
struct weston_color_profile *
weston_cms_create_profile(const char *filename,
void *lcms_profile);
struct weston_color_profile *
weston_cms_load_profile(const char *filename);
void
weston_cms_destroy_profile(struct weston_color_profile *p);
#endif

View File

@ -1,124 +0,0 @@
/*
* Copyright © 2013 Richard Hughes
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <libweston/libweston.h>
#include "cms-helper.h"
#include "shared/helpers.h"
#include "weston.h"
struct cms_static {
struct weston_compositor *ec;
struct wl_listener destroy_listener;
struct wl_listener output_created_listener;
};
static void
cms_output_created(struct cms_static *cms, struct weston_output *o)
{
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);
if (o->name == NULL)
return;
s = weston_config_get_section(wet_get_config(cms->ec),
"output", "name", o->name);
if (s == NULL)
return;
if (weston_config_section_get_string(s, "icc_profile", &profile, NULL) < 0)
return;
p = weston_cms_load_profile(profile);
if (p == NULL && strlen(profile) > 0) {
weston_log("cms-static: failed to load %s\n", profile);
} else {
weston_log("cms-static: loading %s for %s\n",
(p != NULL) ? profile : "identity LUT",
o->name);
weston_cms_set_color_profile(o, p);
}
}
static void
cms_notifier_output_created(struct wl_listener *listener, void *data)
{
struct weston_output *o = (struct weston_output *) data;
struct cms_static *cms =
container_of(listener, struct cms_static, output_created_listener);
cms_output_created(cms, o);
}
static void
cms_module_destroy(struct cms_static *cms)
{
free(cms);
}
static void
cms_notifier_destroy(struct wl_listener *listener, void *data)
{
struct cms_static *cms = container_of(listener, struct cms_static, destroy_listener);
cms_module_destroy(cms);
}
WL_EXPORT int
wet_module_init(struct weston_compositor *ec,
int *argc, char *argv[])
{
struct cms_static *cms;
struct weston_output *output;
weston_log("cms-static: initialized\n");
/* create local state object */
cms = zalloc(sizeof *cms);
if (cms == NULL)
return -1;
cms->ec = ec;
if (!weston_compositor_add_destroy_listener_once(ec,
&cms->destroy_listener,
cms_notifier_destroy)) {
free(cms);
return 0;
}
cms->output_created_listener.notify = cms_notifier_output_created;
wl_signal_add(&ec->output_created_signal, &cms->output_created_listener);
/* discover outputs */
wl_list_for_each(output, &ec->output_list, link)
cms_output_created(cms, output);
return 0;
}

View File

@ -93,70 +93,6 @@ if get_option('screenshare')
env_modmap += 'screen-share.so=@0@;'.format(plugin_screenshare.full_path()) env_modmap += 'screen-share.so=@0@;'.format(plugin_screenshare.full_path())
endif endif
if get_option('deprecated-color-management-static')
srcs_lcms = [
'cms-static.c',
'cms-helper.c',
]
if not dep_lcms2.found()
error('cms-static requires lcms2 which was not found. Or, you can use \'-Ddeprecated-color-management-static=false\'.')
endif
plugin_lcms = shared_library(
'cms-static',
srcs_lcms,
include_directories: common_inc,
dependencies: [ dep_libexec_weston, dep_libweston_public, dep_lcms2 ],
name_prefix: '',
install: true,
install_dir: dir_module_weston,
install_rpath: '$ORIGIN'
)
env_modmap += 'cms-static.so=@0@;'.format(plugin_lcms.full_path())
warning('deprecated-color-management-static is enabled. This will go away, see https://gitlab.freedesktop.org/wayland/weston/-/issues/634')
endif
if get_option('deprecated-color-management-colord')
if not get_option('deprecated-color-management-static')
error('deprecated-color-management-static must be enabled to support colord. Or, you can use \'-Ddeprecated-color-management-colord=false\'.')
endif
srcs_colord = [
'cms-colord.c',
'cms-helper.c',
]
dep_colord = dependency('colord', version: '>= 0.1.27', required: false)
if not dep_colord.found()
error('cms-colord requires colord >= 0.1.27 which was not found. Or, you can use \'-Ddeprecated-color-management-colord=false\'.')
endif
plugin_colord_deps = [ dep_libweston_public, dep_colord, dep_lcms2 ]
foreach depname : [ 'glib-2.0', 'gobject-2.0' ]
dep = dependency(depname, required: false)
if not dep.found()
error('cms-colord requires \'@0@\' which was not found. If you rather not build this, set \'-Ddeprecated-color-management-colord=false\'.'.format(depname))
endif
plugin_colord_deps += dep
endforeach
plugin_colord = shared_library(
'cms-colord',
srcs_colord,
include_directories: common_inc,
dependencies: plugin_colord_deps,
name_prefix: '',
install: true,
install_dir: dir_module_weston
)
env_modmap += 'cms-colord.so=@0@;'.format(plugin_colord.full_path())
warning('deprecated-color-management-colord is enabled. This will go away, see https://gitlab.freedesktop.org/wayland/weston/-/issues/634')
endif
if get_option('systemd') if get_option('systemd')
dep_libsystemd = dependency('libsystemd', required: false) dep_libsystemd = dependency('libsystemd', required: false)
if not dep_libsystemd.found() if not dep_libsystemd.found()

View File

@ -155,11 +155,6 @@ Make this output (connector) a clone of another. The argument
.BR name " value of another output section. The .BR name " value of another output section. The
referred to output section must exist. When this key is present in an referred to output section must exist. When this key is present in an
output section, all other keys have no effect on the configuration. output section, all other keys have no effect on the configuration.
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 .TP
\fBforce-on\fR=\fItrue\fR \fBforce-on\fR=\fItrue\fR
Force the output to be enabled even if the connector is disconnected. Force the output to be enabled even if the connector is disconnected.

View File

@ -115,14 +115,14 @@ directory are:
.BI "xwayland=" true .BI "xwayland=" true
ask Weston to load the XWayland module (boolean). ask Weston to load the XWayland module (boolean).
.TP 7 .TP 7
.BI "modules=" cms-colord.so,screen-share.so .BI "modules=" screen-share.so
specifies the modules to load (string). Available modules in the specifies the modules to load (string, comma separated). Available modules
in the
.IR "@weston_modules_dir@" .IR "@weston_modules_dir@"
directory are: directory are:
.PP .PP
.RS 10 .RS 10
.nf .nf
.BR cms-colord.so
.BR screen-share.so .BR screen-share.so
.fi .fi
.RE .RE

View File

@ -143,18 +143,6 @@ option(
value: true, value: true,
description: 'Compositor color management: Little CMS' description: 'Compositor color management: Little CMS'
) )
option(
'deprecated-color-management-static',
type: 'boolean',
value: false,
description: 'DEPRECATED: color management plugin cms-static'
)
option(
'deprecated-color-management-colord',
type: 'boolean',
value: false,
description: 'DEPRECATED: color management plugin cms-colord (requires cms-static)'
)
option( option(
'image-jpeg', 'image-jpeg',

View File

@ -1,5 +1,5 @@
[core] [core]
#modules=cms-colord.so #modules=screen-share.so
#xwayland=true #xwayland=true
#shell=desktop #shell=desktop
#gbm-format=xrgb2101010 #gbm-format=xrgb2101010