aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-03-05 00:43:38 +0100
committerMattias Andrée <maandree@kth.se>2021-03-05 00:43:38 +0100
commit0ce0d8d6e0c420ccafa79e0203b928c3559a4311 (patch)
tree88e8228a93691c28811a49898abf86a96dd9d613 /src
parentChange license + change style + misc (diff)
downloadlibgamma-0ce0d8d6e0c420ccafa79e0203b928c3559a4311.tar.gz
libgamma-0ce0d8d6e0c420ccafa79e0203b928c3559a4311.tar.bz2
libgamma-0ce0d8d6e0c420ccafa79e0203b928c3559a4311.tar.xz
Split source files, merge public header files, eliminite use gpp, rewrite makefile
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--fake-quartz-cg.c (renamed from src/lib/fake-quartz-cg.c)0
-rw-r--r--fake-quartz-cg.h (renamed from src/lib/fake-quartz-cg.h)0
-rw-r--r--fake-w32-gdi.c (renamed from src/lib/fake-w32-gdi.c)0
-rw-r--r--fake-w32-gdi.h (renamed from src/lib/fake-w32-gdi.h)0
-rw-r--r--gamma-dummy.c.gpp (renamed from src/lib/gamma-dummy.c.gpp)10
-rw-r--r--gamma-dummy.h (renamed from src/lib/gamma-dummy.h)7
-rw-r--r--gamma-linux-drm.c (renamed from src/lib/gamma-linux-drm.c)6
-rw-r--r--gamma-linux-drm.h (renamed from src/lib/gamma-linux-drm.h)11
-rw-r--r--gamma-quartz-cg.c (renamed from src/lib/gamma-quartz-cg.c)0
-rw-r--r--gamma-quartz-cg.h (renamed from src/lib/gamma-quartz-cg.h)9
-rw-r--r--gamma-w32-gdi.c (renamed from src/lib/gamma-w32-gdi.c)0
-rw-r--r--gamma-w32-gdi.h (renamed from src/lib/gamma-w32-gdi.h)11
-rw-r--r--gamma-x-randr.c (renamed from src/lib/gamma-x-randr.c)4
-rw-r--r--gamma-x-randr.h (renamed from src/lib/gamma-x-randr.h)9
-rw-r--r--gamma-x-vidmode.c (renamed from src/lib/gamma-x-vidmode.c)0
-rw-r--r--gamma-x-vidmode.h (renamed from src/lib/gamma-x-vidmode.h)11
-rw-r--r--libgamma_internal_parse_edid.c (renamed from src/lib/edid.c)12
-rw-r--r--src/lib/edid.h22
-rw-r--r--src/lib/gamma-helper.c372
-rw-r--r--src/lib/gamma-helper.h144
-rw-r--r--src/lib/libgamma-error.c.gpp178
-rw-r--r--src/lib/libgamma-error.h379
-rw-r--r--src/lib/libgamma-facade.c.gpp1097
-rw-r--r--src/lib/libgamma-facade.h537
-rw-r--r--src/lib/libgamma-method.c324
-rw-r--r--src/lib/libgamma-method.h1323
-rw-r--r--src/lib/libgamma.h11
27 files changed, 21 insertions, 4456 deletions
diff --git a/src/lib/fake-quartz-cg.c b/fake-quartz-cg.c
index 75f1fb2..75f1fb2 100644
--- a/src/lib/fake-quartz-cg.c
+++ b/fake-quartz-cg.c
diff --git a/src/lib/fake-quartz-cg.h b/fake-quartz-cg.h
index 361a73c..361a73c 100644
--- a/src/lib/fake-quartz-cg.h
+++ b/fake-quartz-cg.h
diff --git a/src/lib/fake-w32-gdi.c b/fake-w32-gdi.c
index 68847ca..68847ca 100644
--- a/src/lib/fake-w32-gdi.c
+++ b/fake-w32-gdi.c
diff --git a/src/lib/fake-w32-gdi.h b/fake-w32-gdi.h
index bcc2fa9..bcc2fa9 100644
--- a/src/lib/fake-w32-gdi.h
+++ b/fake-w32-gdi.h
diff --git a/src/lib/gamma-dummy.c.gpp b/gamma-dummy.c.gpp
index a9aa724..4cc758d 100644
--- a/src/lib/gamma-dummy.c.gpp
+++ b/gamma-dummy.c.gpp
@@ -669,7 +669,7 @@ libgamma_dummy_get_crtc_information(libgamma_crtc_information_t *restrict this,
if (this->edid_error)
this->width_mm_edid_error = this->height_mm_edid_error = this->gamma_error = this->edid_error;
else if (fields & (LIBGAMMA_CRTC_INFO_MACRO_EDID ^ LIBGAMMA_CRTC_INFO_EDID))
- e |= libgamma_parse_edid(this, fields);
+ e |= libgamma_internal_parse_edid(this, fields);
/* Test errors */
#define _E(FIELD, VAR)\
@@ -717,7 +717,7 @@ int
libgamma_dummy_crtc_get_gamma_${2}(libgamma_crtc_state_t *restrict this, libgamma_gamma_${2}_t *restrict ramps)
{
libgamma_dummy_crtc_t *data = this->data;
- libgamma_gamma_ramps_any_t ramps_;
+ gamma_ramps_any_t ramps_;
${1}* r_ramp = data->gamma_red;
${1}* g_ramp = data->gamma_green;
${1}* b_ramp = data->gamma_blue;
@@ -742,7 +742,7 @@ libgamma_dummy_crtc_get_gamma_${2}(libgamma_crtc_state_t *restrict this, libgamm
do {\
if (data->info.gamma_depth == DEPTH) {\
ramps_.${3} = *ramps;\
- return libgamma_translated_ramp_get(this, &ramps_, ${4}, DEPTH, libgamma_crtc_get_gamma_ramps ## SUFFIX);\
+ return libgamma_internal_translated_ramp_get(this, &ramps_, ${4}, DEPTH, libgamma_crtc_get_gamma_ramps ## SUFFIX);\
}\
} while (0)
@@ -796,7 +796,7 @@ int
libgamma_dummy_crtc_set_gamma_${2}(libgamma_crtc_state_t *restrict this, libgamma_gamma_${2}_t ramps)
{
libgamma_dummy_crtc_t *data = this->data;
- libgamma_gamma_ramps_any_t ramps_;
+ gamma_ramps_any_t ramps_;
${1} *r_ramp = data->gamma_red;
${1} *g_ramp = data->gamma_green;
${1} *b_ramp = data->gamma_blue;
@@ -821,7 +821,7 @@ libgamma_dummy_crtc_set_gamma_${2}(libgamma_crtc_state_t *restrict this, libgamm
do {\
if (data->info.gamma_depth == DEPTH) {\
ramps_.${3} = ramps;\
- return libgamma_translated_ramp_set(this, ramps_, ${4}, DEPTH, libgamma_crtc_set_gamma_ramps ## SUFFIX);\
+ return libgamma_internal_translated_ramp_set(this, ramps_, ${4}, DEPTH, libgamma_crtc_set_gamma_ramps ## SUFFIX);\
}\
} while (0)
diff --git a/src/lib/gamma-dummy.h b/gamma-dummy.h
index a52b087..684934e 100644
--- a/src/lib/gamma-dummy.h
+++ b/gamma-dummy.h
@@ -2,13 +2,6 @@
#ifndef LIBGAMMA_GAMMA_DUMMY_H
#define LIBGAMMA_GAMMA_DUMMY_H
-#ifndef HAVE_LIBGAMMA_METHOD_DUMMY
-# error Including gamma-dummy.h without HAVE_LIBGAMMA_METHOD_DUMMY
-#endif
-
-
-#include "libgamma-method.h"
-
/**
* Return the capabilities of the adjustment method
diff --git a/src/lib/gamma-linux-drm.c b/gamma-linux-drm.c
index c2fc646..25a5861 100644
--- a/src/lib/gamma-linux-drm.c
+++ b/gamma-linux-drm.c
@@ -803,7 +803,7 @@ libgamma_linux_drm_get_crtc_information(libgamma_crtc_information_t *restrict th
}
/* Parse EDID */
if (fields & (LIBGAMMA_CRTC_INFO_MACRO_EDID ^ LIBGAMMA_CRTC_INFO_EDID))
- e |= libgamma_parse_edid(this, fields);
+ e |= libgamma_internal_parse_edid(this, fields);
cont:
/* Get gamma ramp size */
@@ -890,8 +890,8 @@ libgamma_linux_drm_crtc_set_gamma_ramps16(libgamma_crtc_state_t *restrict this,
case EBADF:
case ENODEV:
case ENXIO:
- /* XXX: I have not actually tested removing my graphics card or,
- * monitor but I imagine either of these is what would happen. */
+ /* TODO: I have not actually tested removing my graphics card or,
+ * monitor but I imagine either of these is what would happen. */
return LIBGAMMA_GRAPHICS_CARD_REMOVED;
default:
diff --git a/src/lib/gamma-linux-drm.h b/gamma-linux-drm.h
index 41a654d..a8f1e1c 100644
--- a/src/lib/gamma-linux-drm.h
+++ b/gamma-linux-drm.h
@@ -2,13 +2,6 @@
#ifndef LIBGAMMA_GAMMA_LINUX_DRM_H
#define LIBGAMMA_GAMMA_LINUX_DRM_H
-#ifndef HAVE_LIBGAMMA_METHOD_LINUX_DRM
-# error Including gamma-linux-drm.h without HAVE_LIBGAMMA_METHOD_LINUX_DRM
-#endif
-
-
-#include "libgamma-method.h"
-
/**
* Return the capabilities of the adjustment method
@@ -37,7 +30,7 @@ int libgamma_linux_drm_site_initialise(libgamma_site_state_t *restrict, char *re
*
* @param this The site state
*/
-void libgamma_linux_drm_site_destroy(libgamma_site_state_t *restrict) __attribute__((const));
+void libgamma_linux_drm_site_destroy(libgamma_site_state_t *restrict);
/**
* Restore the gamma ramps all CRTC:s with a site to the system settings
@@ -93,7 +86,7 @@ int libgamma_linux_drm_crtc_initialise(libgamma_crtc_state_t *restrict, libgamma
*
* @param this The CRTC state
*/
-void libgamma_linux_drm_crtc_destroy(libgamma_crtc_state_t *restrict) __attribute__((const));
+void libgamma_linux_drm_crtc_destroy(libgamma_crtc_state_t *restrict);
/**
* Restore the gamma ramps for a CRTC to the system settings for that CRTC
diff --git a/src/lib/gamma-quartz-cg.c b/gamma-quartz-cg.c
index b0e3a29..b0e3a29 100644
--- a/src/lib/gamma-quartz-cg.c
+++ b/gamma-quartz-cg.c
diff --git a/src/lib/gamma-quartz-cg.h b/gamma-quartz-cg.h
index 211e055..6044680 100644
--- a/src/lib/gamma-quartz-cg.h
+++ b/gamma-quartz-cg.h
@@ -2,13 +2,6 @@
#ifndef LIBGAMMA_GAMMA_QUARTZ_CG_H
#define LIBGAMMA_GAMMA_QUARTZ_CG_H
-#ifndef HAVE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS
-# error Including gamma-quartz-cg.h without HAVE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS
-#endif
-
-
-#include "libgamma-method.h"
-
/**
* Return the capabilities of the adjustment method
@@ -94,7 +87,7 @@ int libgamma_quartz_cg_crtc_initialise(libgamma_crtc_state_t *restrict, libgamma
*
* @param this The CRTC state
*/
-void libgamma_quartz_cg_crtc_destroy(libgamma_crtc_state_t *restrict) __attribute__((const));
+void libgamma_quartz_cg_crtc_destroy(libgamma_crtc_state_t *restrict);
/**
* Restore the gamma ramps for a CRTC to the system settings for that CRTC
diff --git a/src/lib/gamma-w32-gdi.c b/gamma-w32-gdi.c
index e93b53d..e93b53d 100644
--- a/src/lib/gamma-w32-gdi.c
+++ b/gamma-w32-gdi.c
diff --git a/src/lib/gamma-w32-gdi.h b/gamma-w32-gdi.h
index d139f16..245a94d 100644
--- a/src/lib/gamma-w32-gdi.h
+++ b/gamma-w32-gdi.h
@@ -2,13 +2,6 @@
#ifndef LIBGAMMA_GAMMA_W32_GDI_H
#define LIBGAMMA_GAMMA_W32_GDI_H
-#ifndef HAVE_LIBGAMMA_METHOD_W32_GDI
-# error Including gamma-w32-gdi.h without HAVE_LIBGAMMA_METHOD_W32_GDI
-#endif
-
-
-#include "libgamma-method.h"
-
/**
* Return the capabilities of the adjustment method
@@ -37,7 +30,7 @@ int libgamma_w32_gdi_site_initialise(libgamma_site_state_t *restrict, char *rest
*
* @param this The site state
*/
-void libgamma_w32_gdi_site_destroy(libgamma_site_state_t *restrict) __attribute__((const));
+void libgamma_w32_gdi_site_destroy(libgamma_site_state_t *restrict);
/**
* Restore the gamma ramps all CRTC:s with a site to the system settings
@@ -65,7 +58,7 @@ int libgamma_w32_gdi_partition_initialise(libgamma_partition_state_t *restrict,
*
* @param this The partition state
*/
-void libgamma_w32_gdi_partition_destroy(libgamma_partition_state_t *restrict) __attribute__((const));
+void libgamma_w32_gdi_partition_destroy(libgamma_partition_state_t *restrict);
/**
* Restore the gamma ramps all CRTC:s with a partition to the system settings
diff --git a/src/lib/gamma-x-randr.c b/gamma-x-randr.c
index fce65d1..95d730c 100644
--- a/src/lib/gamma-x-randr.c
+++ b/gamma-x-randr.c
@@ -192,7 +192,7 @@ libgamma_x_randr_site_initialise(libgamma_site_state_t *restrict this, char *res
/* Release resources */
free(reply);
/* If `xcb_connect` failed, both `error` and `reply` will be `NULL`.
- XXX: Can both be `NULL` for any other reason? */
+ * TODO: Can both be `NULL` for any other reason? */
if (!error && !reply)
return LIBGAMMA_OPEN_SITE_FAILED;
xcb_disconnect(connection);
@@ -874,7 +874,7 @@ libgamma_x_randr_get_crtc_information(libgamma_crtc_information_t *restrict this
}
/* Parse EDID */
if ((fields & (LIBGAMMA_CRTC_INFO_MACRO_EDID ^ LIBGAMMA_CRTC_INFO_EDID)))
- e |= libgamma_parse_edid(this, fields);
+ e |= libgamma_internal_parse_edid(this, fields);
cont:
/* Get gamma ramp size */
diff --git a/src/lib/gamma-x-randr.h b/gamma-x-randr.h
index 59c64bc..3591192 100644
--- a/src/lib/gamma-x-randr.h
+++ b/gamma-x-randr.h
@@ -2,13 +2,6 @@
#ifndef LIBGAMMA_GAMMA_X_RANDR_H
#define LIBGAMMA_GAMMA_X_RANDR_H
-#ifndef HAVE_LIBGAMMA_METHOD_X_RANDR
-# error Including gamma-x-randr.h without HAVE_LIBGAMMA_METHOD_X_RANDR
-#endif
-
-
-#include "libgamma-method.h"
-
/**
* Return the capabilities of the adjustment method
@@ -93,7 +86,7 @@ int libgamma_x_randr_crtc_initialise(libgamma_crtc_state_t *restrict, libgamma_p
*
* @param this The CRTC state
*/
-void libgamma_x_randr_crtc_destroy(libgamma_crtc_state_t *restrict) __attribute__((const));
+void libgamma_x_randr_crtc_destroy(libgamma_crtc_state_t *restrict);
/**
* Restore the gamma ramps for a CRTC to the system settings for that CRTC
diff --git a/src/lib/gamma-x-vidmode.c b/gamma-x-vidmode.c
index bae9d31..bae9d31 100644
--- a/src/lib/gamma-x-vidmode.c
+++ b/gamma-x-vidmode.c
diff --git a/src/lib/gamma-x-vidmode.h b/gamma-x-vidmode.h
index 618d5c4..8a95442 100644
--- a/src/lib/gamma-x-vidmode.h
+++ b/gamma-x-vidmode.h
@@ -2,13 +2,6 @@
#ifndef LIBGAMMA_GAMMA_X_VIDMODE_H
#define LIBGAMMA_GAMMA_X_VIDMODE_H
-#ifndef HAVE_LIBGAMMA_METHOD_X_VIDMODE
-# error Including gamma-x-vidmode.h without HAVE_LIBGAMMA_METHOD_X_VIDMODE
-#endif
-
-
-#include "libgamma-method.h"
-
/**
* Return the capabilities of the adjustment method
@@ -65,7 +58,7 @@ int libgamma_x_vidmode_partition_initialise(libgamma_partition_state_t *restrict
*
* @param this The partition state
*/
-void libgamma_x_vidmode_partition_destroy(libgamma_partition_state_t *restrict) __attribute__((const));
+void libgamma_x_vidmode_partition_destroy(libgamma_partition_state_t *restrict);
/**
* Restore the gamma ramps all CRTC:s with a partition to the system settings
@@ -94,7 +87,7 @@ int libgamma_x_vidmode_crtc_initialise(libgamma_crtc_state_t *restrict, libgamma
*
* @param this The CRTC state
*/
-void libgamma_x_vidmode_crtc_destroy(libgamma_crtc_state_t *restrict) __attribute__((const));
+void libgamma_x_vidmode_crtc_destroy(libgamma_crtc_state_t *restrict);
/**
* Restore the gamma ramps for a CRTC to the system settings for that CRTC
diff --git a/src/lib/edid.c b/libgamma_internal_parse_edid.c
index fc7b498..aa1b87c 100644
--- a/src/lib/edid.c
+++ b/libgamma_internal_parse_edid.c
@@ -1,10 +1,5 @@
/* See LICENSE file for copyright and license details. */
-#include "edid.h"
-
-#include "libgamma-method.h"
-#include "libgamma-error.h"
-
-#include <stdint.h>
+#include "common.h"
/*
@@ -26,7 +21,7 @@
* @return Non-zero on error
*/
int
-libgamma_parse_edid(libgamma_crtc_information_t *restrict this, int32_t fields)
+libgamma_internal_parse_edid(libgamma_crtc_information_t *restrict this, int32_t fields)
{
#define __test_version(edid, major, minor_min, minor_max)\
((edid)[18] == (major) && (minor_min) <= (edid)[19] && (edid)[19] <= (minor_max))
@@ -79,10 +74,9 @@ libgamma_parse_edid(libgamma_crtc_information_t *restrict this, int32_t fields)
/* If not error has occurred, calculate and test the checksum.
It is not considered an error that the gamma characteristics
is left unspecified in the EDID. */
- if (!error) {
+ if (!error)
for (i = 0; i < this->edid_length; i++)
checksum += (int)this->edid[i];
- }
/* The checksum should be zero. */
if (checksum & 255) {
/* Store the error in all fields that require the EDID to be parsed,
diff --git a/src/lib/edid.h b/src/lib/edid.h
deleted file mode 100644
index 51529ae..0000000
--- a/src/lib/edid.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef LIBGAMMA_EDID_H
-#define LIBGAMMA_EDID_H
-
-#include "libgamma-method.h"
-
-#include <stdint.h>
-
-
-/**
- * Parse the EDID of a monitor
- *
- * @param this Instance of a data structure to fill with the information about the EDID;
- * it must contain the EDID and its length
- * @param fields OR:ed identifiers for the information about the EDID that should be parsed;
- * fields that do not have to do with EDID are ignored
- * @return Non-zero on error
- */
-int libgamma_parse_edid(libgamma_crtc_information_t *restrict, int32_t);
-
-
-#endif
diff --git a/src/lib/gamma-helper.c b/src/lib/gamma-helper.c
deleted file mode 100644
index f67e107..0000000
--- a/src/lib/gamma-helper.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#include "gamma-helper.h"
-
-#include "libgamma-method.h"
-#include "libgamma-error.h"
-
-#include <errno.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-
-/**
- * Just an arbitrary version
- */
-#define ANY bits64
-
-/**
- * Concatenation of all ramps
- */
-#define ALL red
-
-
-/**
- * Preform installation in an `for (i = 0; i < n; i++)`
- * loop and do a `break` afterwords
- */
-#define __translate(instruction) for (i = 0; i < n; i++) instruction; break
-
-
-/**
- * Convert a [0, 1] `float` to a full range `uint64_t`
- * and mark sure rounding errors does not cause the
- * value be 0 instead of ~0 and vice versa
- *
- * @param value To `float` to convert
- * @return The value as an `uint64_t`
- */
-static inline uint64_t
-float_to_64(float value)
-{
- /* TODO Which is faster? */
-
-#if defined(HAVE_INT128) && __WORDSIZE == 64
- /* `__int128` is a GNU C extension, which
- (because it is not ISO C) emits a warning
- under -pedantic */
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpedantic"
-
- /* In GCC we can use `__int128`, this is
- a signed 128-bit integer. It fits all
- uint64_t values but also native values,
- which is a nice because it eleminates
- some overflow condition tests. It is
- also more readable. */
-
- /* Convert to integer */
- __int128 product = (__int128)(value * (float)UINT64_MAX);
- /* Negative overflow */
- if (product > UINT64_MAX)
- return UINT64_MAX;
- /* Positive overflow */
- if (product < 0)
- return 0;
- /* Did not overflow */
- return (uint64_t)product;
-
-# pragma GCC diagnostic pop
-#else
-
- /* If we are not using GCC we cannot be
- sure that we have `__int128` so we have
- to use `uint64_t` and perform overflow
- checkes based on the input value */
-
- /* Convert to integer. */
- uint64_t product = (uint64_t)(value * (float)UINT64_MAX);
- /* Negative overflow,
- if the input is less than 0.5 but
- the output is greater then we got
- -1 when we should have gotten 0 */
- if (value < 0.1f && product > 0xF000000000000000ULL)
- return 0;
- /* Positive overflow,
- if the input is greater than 0.5
- but the output is less then we got
- 0 when we should have gotten ~0 */
- else if (value > 0.9f && product < 0x1000000000000000ULL)
- return (uint64_t)~0;
- /* Did not overflow */
- return product;
-
-#endif
-}
-
-
-/**
- * Convert a [0, 1] `double` to a full range `uint64_t`
- * and mark sure rounding errors does not cause the
- * value be 0 instead of ~0 and vice versa
- *
- * @param value To `double` to convert
- * @return The value as an `uint64_t`
- */
-static inline uint64_t
-double_to_64(double value)
-{
- /* XXX Which is faster? */
-
-#if defined(HAVE_INT128) && __WORDSIZE == 64
- /* `__int128` is a GNU C extension, which
- (because it is not ISO C) emits a warning
- under -pedantic */
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpedantic"
-
- /* In GCC we can use `__int128`, this is
- a signed 128-bit integer. It fits all
- uint64_t values but also native values,
- which is a nice because it eleminates
- some overflow condition tests. It is
- also more readable. */
-
- /* Convert to integer */
- __int128 product = (__int128)(value * (double)UINT64_MAX);
- /* Negative overflow */
- if (product > UINT64_MAX)
- return UINT64_MAX;
- /* Positive overflow */
- if (product < 0)
- return 0;
- /* Did not overflow */
- return (uint64_t)product;
-
-# pragma GCC diagnostic pop
-#else
-
- /* If we are not using GCC we cannot be
- sure that we have `__int128` so we have
- to use `uint64_t` and perform overflow
- checkes based on the input value. */
-
- /* Convert to integer. */
- uint64_t product = (uint64_t)(value * (double)UINT64_MAX);
- /* Negative overflow,
- if the input is less than 0.5 but
- the output is greater then we got
- -1 when we should have gotten 0 */
- if (value < (double)0.1f && product > 0xF000000000000000ULL)
- product = 0;
- /* Positive overflow,
- if the input is greater than 0.5
- but the output is less then we got
- 0 when we should have gotten ~0 */
- else if ((value > (double)0.9f) && (product < 0x1000000000000000ULL))
- product = (uint64_t)~0;
- /* Did not overflow */
- return product;
-
-#endif
-}
-
-
-/**
- * Convert any set of gamma ramps into a 64-bit integer array with all channels
- *
- * @param depth The depth of the gamma ramp, `-1` for `float`, `-2` for `double`
- * @param n The grand size of gamma ramps (sum of all channels' sizes)
- * @param out Output array
- * @param in Input gamma ramps
- */
-static void
-translate_to_64(signed depth, size_t n, uint64_t *restrict out, libgamma_gamma_ramps_any_t in)
-{
- size_t i;
- switch (depth) {
- /* Translate integer */
- case 8: __translate(out[i] = (uint64_t)(in.bits8. ALL[i]) * 0x0101010101010101ULL);
- case 16: __translate(out[i] = (uint64_t)(in.bits16.ALL[i]) * 0x0001000100010001ULL);
- case 32: __translate(out[i] = (uint64_t)(in.bits32.ALL[i]) * 0x0000000100000001ULL);
- /* Identity translation */
- case 64: __translate(out[i] = in.bits64.ALL[i]);
- /* Translate floating point */
- case -1: __translate(out[i] = float_to_64(in.float_single.ALL[i]));
- case -2: __translate(out[i] = double_to_64(in.float_double.ALL[i]));
- default:
- /* This is not possible */
- abort();
- break;
- }
-}
-
-
-/**
- * Undo the actions of `translate_to_64`
- *
- * @param depth The depth of the gamma ramp, `-1` for `float`, `-2` for `double`
- * @param n The grand size of gamma ramps (sum of all channels' sizes)
- * @param out Output gamma ramps
- * @param in Input array, may be modified
- */
-static void
-translate_from_64(signed depth, size_t n, libgamma_gamma_ramps_any_t out, uint64_t *restrict in)
-{
- size_t i;
- switch (depth) {
- /* Translate integer */
- case 8: __translate(out.bits8. ALL[i] = (uint8_t)(in[i] / 0x0101010101010101ULL));
- case 16: __translate(out.bits16.ALL[i] = (uint16_t)(in[i] / 0x0001000100010001ULL));
- case 32: __translate(out.bits32.ALL[i] = (uint32_t)(in[i] / 0x0000000100000001ULL));
- /* Identity translation */
- case 64: __translate(out.bits64.ALL[i] = in[i]);
- /* Translate floating point */
- case -1: __translate(out.float_single.ALL[i] = (float)(in[i]) / (float)UINT64_MAX);
- case -2: __translate(out.float_double.ALL[i] = (double)(in[i]) / (double)UINT64_MAX);
- default:
- /* This is not possible */
- abort();
- break;
- }
-}
-
-
-/**
- * Allocate and initalise a gamma ramp with any depth
- *
- * @param ramps_sys Output gamma ramps
- * @param ramps The gamma ramps whose sizes should be duplicated
- * @param depth The depth of the gamma ramps to allocate,
- * `-1` for `float`, `-2` for `double`
- * @param elements Output reference for the grand size of the gamma ramps
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-static int
-allocated_any_ramp(libgamma_gamma_ramps_any_t *restrict ramps_sys,
- libgamma_gamma_ramps_any_t ramps, signed depth, size_t *restrict elements)
-{
- /* Calculate the size of the allocation to do */
- size_t d, n = ramps.ANY.red_size + ramps.ANY.green_size + ramps.ANY.blue_size;
- switch (depth) {
- case 8: d = sizeof(uint8_t); break;
- case 16: d = sizeof(uint16_t); break;
- case 32: d = sizeof(uint32_t); break;
- case 64: d = sizeof(uint64_t); break;
- case -1: d = sizeof(float); break;
- case -2: d = sizeof(double); break;
- default:
- return errno = EINVAL, LIBGAMMA_ERRNO_SET;
- }
-
- /* Copy the gamma ramp sizes */
- ramps_sys->ANY = ramps.ANY;
- /* Allocate the new ramps */
-#ifdef HAVE_LIBGAMMA_METHOD_LINUX_DRM
- /* Valgrind complains about us reading uninitialize memory if we just use malloc */
- ramps_sys->ANY.red = calloc(n, d);
-#else
- ramps_sys->ANY.red = malloc(n * d);
-#endif
- ramps_sys->ANY.green = (void *)&((char *)ramps_sys->ANY. red)[ramps.ANY. red_size * d / sizeof(char)];
- ramps_sys->ANY.blue = (void *)&((char *)ramps_sys->ANY.green)[ramps.ANY.green_size * d / sizeof(char)];
-
- /* Report the total gamma ramp size */
- *elements = n;
- /* Report successfulness */
- return ramps_sys->ANY.red ? 0 : LIBGAMMA_ERRNO_SET;
-}
-
-
-/**
- * Get the current gamma ramps for a CRTC, re-encoding version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @param depth_user The depth of the gamma ramps that are provided by the user,
- * `-1` for `float`, `-2` for `double`
- * @param depth_system The depth of the gamma ramps as required by the adjustment method,
- * `-1` for `float`, `-2` for `double`
- * @param fun Function that is to be used read the ramps, its parameters have
- * the same function as those of this function with the same names,
- * and the return value too is identical
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int
-libgamma_translated_ramp_get_(libgamma_crtc_state_t *restrict this, libgamma_gamma_ramps_any_t *restrict ramps,
- signed depth_user, signed depth_system, libgamma_get_ramps_any_fun *fun)
-{
- size_t n;
- int r;
- libgamma_gamma_ramps_any_t ramps_sys;
- uint64_t *restrict ramps_full;
-
- /* Allocate ramps with proper data type */
- if ((r = allocated_any_ramp(&ramps_sys, *ramps, depth_system, &n)))
- return r;
-
- /* Fill the ramps */
- if ((r = fun(this, &ramps_sys)))
- return free(ramps_sys.ANY.red), r;
-
- /* Allocate intermediary ramps */
- ramps_full = malloc(n * sizeof(uint64_t));
- if (!ramps_full) {
- free(ramps_sys.ANY.red);
- return LIBGAMMA_ERRNO_SET;
- }
-
- /* Translate ramps to 64-bit integers */
- translate_to_64(depth_system, n, ramps_full, ramps_sys);
- free(ramps_sys.ANY.red);
-
- /* Translate ramps to the user's format */
- translate_from_64(depth_user, n, *ramps, ramps_full);
- free(ramps_full);
- return 0;
-}
-
-
-/**
- * Set the gamma ramps for a CRTC, re-encoding version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @param depth_user The depth of the gamma ramps that are provided by the user,
- * `-1` for `float`, `-2` for `double`
- * @param depth_system The depth of the gamma ramps as required by the adjustment method,
- * `-1` for `float`, `-2` for `double`
- * @param fun Function that is to be used write the ramps, its parameters have
- * the same function as those of this function with the same names,
- * and the return value too is identical
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int
-libgamma_translated_ramp_set_(libgamma_crtc_state_t *restrict this, libgamma_gamma_ramps_any_t ramps,
- signed depth_user, signed depth_system, libgamma_set_ramps_any_fun *fun)
-{
- size_t n;
- int r;
- libgamma_gamma_ramps_any_t ramps_sys;
- uint64_t *restrict ramps_full;
-
- /* Allocate ramps with proper data type */
- if ((r = allocated_any_ramp(&ramps_sys, ramps, depth_system, &n)))
- return r;
-
- /* Allocate intermediary ramps */
- ramps_full = malloc(n * sizeof(uint64_t));
- if (!ramps_full) {
- free(ramps_sys.ANY.red);
- return LIBGAMMA_ERRNO_SET;
- }
-
- /* Translate ramps to 64-bit integers. */
- translate_to_64(depth_user, n, ramps_full, ramps);
- /* Translate ramps to the proper format. */
- translate_from_64(depth_system, n, ramps_sys, ramps_full);
- free(ramps_full);
-
- /* Apply the ramps */
- r = fun(this, ramps_sys);
-
- free(ramps_sys.ANY.red);
- return r;
-}
-
-
-#undef __translate
-#undef ALL
-#undef ANY
diff --git a/src/lib/gamma-helper.h b/src/lib/gamma-helper.h
deleted file mode 100644
index 38d678d..0000000
--- a/src/lib/gamma-helper.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef LIBGAMMA_GAMMA_HELPER_H
-#define LIBGAMMA_GAMMA_HELPER_H
-
-
-#include "libgamma-method.h"
-
-
-/**
- * Gamma ramp structure union for different depths
- */
-typedef union libgamma_gamma_ramps_any {
- /**
- * 8-bit gamma ramps
- */
- libgamma_gamma_ramps8_t bits8;
-
- /**
- * 16-bit gamma ramps
- */
- libgamma_gamma_ramps16_t bits16;
-
- /**
- * 32-bit gamma ramps
- */
- libgamma_gamma_ramps32_t bits32;
-
- /**
- * 64-bit gamma ramps
- */
- libgamma_gamma_ramps64_t bits64;
-
- /**
- * Single precision float gamma ramps
- */
- libgamma_gamma_rampsf_t float_single;
-
- /**
- * Double precision float gamma ramps
- */
- libgamma_gamma_rampsd_t float_double;
-
-} libgamma_gamma_ramps_any_t;
-
-
-/**
- * A function for reading the gamma ramps from a CRTC
- *
- * @param this The CRTC state
- * @param ramps The store for the gamma ramps
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-typedef int libgamma_get_ramps_any_fun(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps_any_t *restrict);
-
-/**
- * A function for writing the gamma ramps to a CRTC
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-typedef int libgamma_set_ramps_any_fun(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps_any_t);
-
-
-
-/**
- * Get the current gamma ramps for a CRTC, re-encoding version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @param depth_user The depth of the gamma ramps that are provided by the user,
- * `-1` for `float`, `-2` for `double`
- * @param depth_system The depth of the gamma ramps as required by the adjustment method,
- * `-1` for `float`, `-2` for `double`
- * @param fun Function that is to be used read the ramps, its parameters have
- * the same function as those of this function with the same names,
- * and the return value too is identical
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-#define libgamma_translated_ramp_get(this, ramps, depth_user, depth_system, fun)\
- libgamma_translated_ramp_get_((this), (ramps), (depth_user), (depth_system), (libgamma_get_ramps_any_fun *)(fun))
-
-
-/**
- * Set the gamma ramps for a CRTC, re-encoding version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @param depth_user The depth of the gamma ramps that are provided by the user,
- * `-1` for `float`, `-2` for `double`
- * @param depth_system The depth of the gamma ramps as required by the adjustment method,
- * `-1` for `float`, `-2` for `double`
- * @param fun Function that is to be used write the ramps, its parameters have
- * the same function as those of this function with the same names,
- * and the return value too is identical
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-#define libgamma_translated_ramp_set(this, ramps, depth_user, depth_system, fun)\
- libgamma_translated_ramp_set_((this), (ramps), (depth_user), (depth_system), (libgamma_set_ramps_any_fun *)fun)
-
-
-/**
- * Get the current gamma ramps for a CRTC, re-encoding version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @param depth_user The depth of the gamma ramps that are provided by the user,
- * `-1` for `float`, `-2` for `double`
- * @param depth_system The depth of the gamma ramps as required by the adjustment method,
- * `-1` for `float`, `-2` for `double`
- * @param fun Function that is to be used read the ramps, its parameters have
- * the same function as those of this function with the same names,
- * and the return value too is identical
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_translated_ramp_get_(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps_any_t *restrict,
- signed, signed, libgamma_get_ramps_any_fun *);
-
-
-/**
- * Set the gamma ramps for a CRTC, re-encoding version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @param depth_user The depth of the gamma ramps that are provided by the user,
- * `-1` for `float`, `-2` for `double`
- * @param depth_system The depth of the gamma ramps as required by the adjustment method,
- * `-1` for `float`, `-2` for `double`
- * @param fun Function that is to be used write the ramps, its parameters have
- * the same function as those of this function with the same names,
- * and the return value too is identical
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_translated_ramp_set_(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps_any_t,
- signed, signed, libgamma_set_ramps_any_fun *);
-
-
-#endif
diff --git a/src/lib/libgamma-error.c.gpp b/src/lib/libgamma-error.c.gpp
deleted file mode 100644
index d43f336..0000000
--- a/src/lib/libgamma-error.c.gpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/* -*- c -*- */
-/* See LICENSE file for copyright and license details. */
-#include "libgamma-error.h"
-
-
-#include <stddef.h>
-#include <sys/types.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-
-
-
-$>set -u
-$>cd src/extract
-$>export PATH=".:${PATH}"
-
-
-
-/**
- * Group that the user needs to be a member of if
- * `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
- */
-#ifndef __WIN32__
-__thread gid_t libgamma_group_gid = 0;
-gid_t
-libgamma_group_gid_get(void)
-{
- return libgamma_group_gid;
-}
-void
-libgamma_group_gid_set(gid_t value)
-{
- libgamma_group_gid = value;
-}
-#else
-short libgamma_group_gid = 0;
-#endif
-
-/**
- * Group that the user needs to be a member of if
- * `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned,
- * `NULL` if the name of the group `libgamma_group_gid`
- * cannot be determined
- */
-#ifndef __WIN32__
-__thread const char *libgamma_group_name = NULL;
-const char *
-libgamma_group_name_get(void) {
- return libgamma_group_name;
-}
-void
-libgamma_group_name_set(const char *value)
-{
- libgamma_group_name = value;
-}
-#else
-const char *libgamma_group_name = NULL;
-#endif
-
-
-
-/**
- * Prints an error to stderr in a `perror` fashion,
- * however this function will not translate the `libgamma`
- * errors into human-readable strings, it will simply
- * print the name of the error. If the value `error_code`
- * is the value of `LIBGAMMA_ERRNO_SET`, `perror` will be
- * used to print the current error stored in `errno`.
- * If `error_code` is non-negative (an `errno` value`), that
- * value will be stored in `errno` and `perror` will be
- * used to print it. Additionally, if the `error_code` is
- * the value of `LIBGAMMA_DEVICE_REQUIRE_GROUP` the
- * required group will be printed with its numerical value
- * and, if known, its name.
- *
- * @param name The text to add at the beginning
- * @param value The error code, may be an `errno` value
- */
-void
-libgamma_perror(const char *name, int error_code)
-{
- const char *error;
- long int gid;
-
- if (error_code >= 0) {
- /* Print the stored errno value */
- errno = error_code;
- perror(name);
- } else if (error_code == LIBGAMMA_ERRNO_SET) {
- /* Print errno */
- perror(name);
- } else if (error_code == LIBGAMMA_DEVICE_REQUIRE_GROUP) {
- /* Print the error name and the required group membership */
- error = libgamma_name_of_error(error_code);
- gid = (long int)libgamma_group_gid;
- if (!libgamma_group_name) {
- /* Group name unknown */
- if (name && *name)
- fprintf(stderr, "%s: %s: %ld\n", name, error, gid);
- else
- fprintf(stderr, "%s: %ld\n", error, gid);
- } else {
- /* Group name known, ID is second class */
- if (name && *name)
- fprintf(stderr, "%s: %s: %s (%ld)\n", name, error, libgamma_group_name, gid);
- else
- fprintf(stderr, "%s: %s (%ld)\n", error, libgamma_group_name, gid);
- }
- } else if (error_code < LIBGAMMA_ERROR_MIN) {
- /* If the error code does not exist, print "(?)" */
- if (name && *name)
- fprintf(stderr, "%s: (?)\n", name);
- else
- fprintf(stderr, "(?)\n");
- } else {
- /* Print the name of the error */
- if (name && *name)
- fprintf(stderr, "%s: %s\n", name, libgamma_name_of_error(error_code));
- else
- fprintf(stderr, "%s\n", libgamma_name_of_error(error_code));
- }
-}
-
-
-/**
- * Returns the name of the definition associated with a `libgamma` error code
- *
- * @param value The error code
- * @return The name of the definition associated with the error code,
- * `NULL` if the error code does not exist; the return string
- * should not be `free`:d
- */
-const char *
-libgamma_name_of_error(int value)
-{
- /* Map from error codes to error names.
- The output of $(libgamma-error-extract --list)
- is sorted by error code in decreasing order */
- static const char* error_names[] = {
-$>for error in $(libgamma-error-extract --list); do
- "${error}",
-$>done
- };
-
- /* Return `NULL` if the error code is invalid */
- if (value < LIBGAMMA_ERROR_MIN || value >= 0)
- return NULL;
-
- /* Convert error code from {-1, -2, -3, ...} to {0, 1, 2, ...}
- * and look up the error's name and return it */
- return error_names[-value - 1];
-}
-
-
-/**
- * Return the value of a `libgamma` error definition refered to by name
- *
- * @param name The name of the definition associated with the error code
- * @return The error code, zero if the name does is `NULL`
- * or does not refer to a `libgamma` error
- */
-int
-libgamma_value_of_error(const char *name)
-{
- /* Return 0 (not a valid error code) if the error name is `NULL` */
- if (!name)
- return 0;
-
- /* Test error names against `name` and return the value of the match error */
-$>for error in $(libgamma-error-extract --list); do
- if (!strcmp(name, "${error}"))
- return ${error};
-$>done
-
- /* Return 0 (not a valid error code) if the error name is unknown */
- return 0;
-}
diff --git a/src/lib/libgamma-error.h b/src/lib/libgamma-error.h
deleted file mode 100644
index a026e79..0000000
--- a/src/lib/libgamma-error.h
+++ /dev/null
@@ -1,379 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef LIBGAMMA_ERROR_H
-#define LIBGAMMA_ERROR_H
-
-#if !defined(LIBGAMMA_CONFIG_H) && !defined(DEBUG)
-# error libgamma-error.h should not be included directly, include libgamma.h instead
-#endif
-
-
-#include <sys/types.h>
-
-#ifndef __GNUC__
-# define __attribute__(x)
-#endif
-
-
-/**
- * Group that the user needs to be a member of if
- * `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned
- */
-#ifndef __WIN32__
-extern __thread gid_t libgamma_group_gid;
-gid_t libgamma_group_gid_get(void) __attribute__((pure));
-void libgamma_group_gid_set(gid_t value);
-#else
-extern short libgamma_group_gid;
-#endif
-
-/**
- * Group that the user needs to be a member of if
- * `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned,
- * `NULL` if the name of the group `libgamma_group_gid`
- * cannot be determined
- */
-#ifndef __WIN32__
-extern __thread const char *libgamma_group_name;
-const char *libgamma_group_name_get(void) __attribute__((pure));
-void libgamma_group_name_set(const char *value);
-#else
-extern const char *libgamma_group_name;
-#endif
-
-
-/**
- * `errno` has be set with a standard error number
- * to indicate the what has gone wrong
- */
-#define LIBGAMMA_ERRNO_SET (-1)
-
-/**
- * The selected adjustment method does not exist
- * or has been excluded at compile-time
- */
-#define LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD (-2)
-
-/**
- * The selected site does not exist
- */
-#define LIBGAMMA_NO_SUCH_SITE (-3)
-
-/**
- * The selected partition does not exist
- */
-#define LIBGAMMA_NO_SUCH_PARTITION (-4)
-
-/**
- * The selected CRTC does not exist
- */
-#define LIBGAMMA_NO_SUCH_CRTC (-5)
-
-/**
- * Counter overflowed when counting the number
- * of available items
- */
-#define LIBGAMMA_IMPOSSIBLE_AMOUNT (-6)
-
-/**
- * The selected connector is disabled, it does
- * not have a CRTC
- */
-#define LIBGAMMA_CONNECTOR_DISABLED (-7)
-
-/**
- * The selected CRTC could not be opened,
- * reason unknown
- */
-#define LIBGAMMA_OPEN_CRTC_FAILED (-8)
-
-/**
- * The CRTC information field is not supported
- * by the adjustment method
- */
-#define LIBGAMMA_CRTC_INFO_NOT_SUPPORTED (-9)
-
-/**
- * Failed to read the current gamma ramps for
- * the selected CRTC, reason unknown
- */
-#define LIBGAMMA_GAMMA_RAMP_READ_FAILED (-10)
-
-/**
- * Failed to write the current gamma ramps for
- * the selected CRTC, reason unknown
- */
-#define LIBGAMMA_GAMMA_RAMP_WRITE_FAILED (-11)
-
-/**
- * The specified ramp sizes does not match the
- * ramps sizes returned by the adjustment methods
- * in response to the query/command
- */
-#define LIBGAMMA_GAMMA_RAMP_SIZE_CHANGED (-12)
-
-/**
- * The specified ramp sizes are not identical
- * which is required by the adjustment method
- *
- * (Only returned in debug mode)
- */
-#define LIBGAMMA_MIXED_GAMMA_RAMP_SIZE (-13)
-
-/**
- * The specified ramp sizes are not supported
- * by the adjustment method
- *
- * (Only returned in debug mode)
- */
-#define LIBGAMMA_WRONG_GAMMA_RAMP_SIZE (-14)
-
-/**
- * The adjustment method reported that the gamma
- * ramps size is 1, or perhaps even zero or negative
- */
-#define LIBGAMMA_SINGLETON_GAMMA_RAMP (-15)
-
-/**
- * The adjustment method failed to list
- * available CRTC:s, reason unknown
- */
-#define LIBGAMMA_LIST_CRTCS_FAILED (-16)
-
-/**
- * Failed to acquire mode resources from the
- * adjustment method
- */
-#define LIBGAMMA_ACQUIRING_MODE_RESOURCES_FAILED (-17)
-
-/**
- * The adjustment method reported that a negative
- * number of partitions exists in the site
- */
-#define LIBGAMMA_NEGATIVE_PARTITION_COUNT (-18)
-
-/**
- * The adjustment method reported that a negative
- * number of CRTC:s exists in the partition
- */
-#define LIBGAMMA_NEGATIVE_CRTC_COUNT (-19)
-
-/**
- * Device cannot be access becauses of
- * insufficient permissions
- */
-#define LIBGAMMA_DEVICE_RESTRICTED (-20)
-
-/**
- * Device cannot be access, reason unknown
- */
-#define LIBGAMMA_DEVICE_ACCESS_FAILED (-21)
-
-/**
- * Device cannot be access, membership of the
- * `libgamma_group_gid` (named by `libgamma_group_name`
- * (can be `NULL`, if so `errno` may have been set
- * to tell why)) is required
- */
-#define LIBGAMMA_DEVICE_REQUIRE_GROUP (-22)
-
-/**
- * The graphics card appear to have been removed
- */
-#define LIBGAMMA_GRAPHICS_CARD_REMOVED (-23)
-
-/**
- * The state of the requested information is unknown
- */
-#define LIBGAMMA_STATE_UNKNOWN (-24)
-
-/**
- * Failed to determine which connector the
- * CRTC belongs to
- */
-#define LIBGAMMA_CONNECTOR_UNKNOWN (-25)
-
-/**
- * The detected connector type is not listed
- * in this library and has to be updated
- */
-#define LIBGAMMA_CONNECTOR_TYPE_NOT_RECOGNISED (-26)
-
-/**
- * The detected subpixel order is not listed
- * in this library and has to be updated
- */
-#define LIBGAMMA_SUBPIXEL_ORDER_NOT_RECOGNISED (-27)
-
-/**
- * The length of the EDID does not match that
- * of any supported EDID structure revision
- */
-#define LIBGAMMA_EDID_LENGTH_UNSUPPORTED (-28)
-
-/**
- * The magic number in the EDID does not match
- * that of any supported EDID structure revision
- */
-#define LIBGAMMA_EDID_WRONG_MAGIC_NUMBER (-29)
-
-/**
- * The EDID structure revision used by the
- * monitor is not supported
- */
-#define LIBGAMMA_EDID_REVISION_UNSUPPORTED (-30)
-
-/**
- * The gamma characteristics field in the EDID
- * is left unspecified
- *
- * (This could be considered a non-error)
- */
-#define LIBGAMMA_GAMMA_NOT_SPECIFIED (-31)
-
-/**
- * The checksum in the EDID is incorrect, all
- * request information has been provided
- * by you cannot count on it
- */
-#define LIBGAMMA_EDID_CHECKSUM_ERROR (-32)
-
-/**
- * Both of the errors `LIBGAMMA_GAMMA_NOT_SPECIFIED`
- * and `LIBGAMMA_EDID_CHECKSUM_ERROR` have occurred
- */
-#define LIBGAMMA_GAMMA_NOT_SPECIFIED_AND_EDID_CHECKSUM_ERROR (-33)
-
-/**
- * Failed to query the gamma ramps size from the
- * adjustment method, reason unknown
- */
-#define LIBGAMMA_GAMMA_RAMPS_SIZE_QUERY_FAILED (-34)
-
-/**
- * The selected partition could not be opened,
- * reason unknown
- */
-#define LIBGAMMA_OPEN_PARTITION_FAILED (-35)
-
-/**
- * The selected site could not be opened,
- * reason unknown
- */
-#define LIBGAMMA_OPEN_SITE_FAILED (-36)
-
-/**
- * Failed to query the adjustment method for
- * its protocol version, reason unknown
- */
-#define LIBGAMMA_PROTOCOL_VERSION_QUERY_FAILED (-37)
-
-/**
- * The adjustment method's version of its
- * protocol is not supported
- */
-#define LIBGAMMA_PROTOCOL_VERSION_NOT_SUPPORTED (-38)
-
-/**
- * The adjustment method failed to list
- * available partitions, reason unknown
- */
-#define LIBGAMMA_LIST_PARTITIONS_FAILED (-39)
-
-/**
- * Partition exists by index, but the partition
- * at that index does not exist
- */
-#define LIBGAMMA_NULL_PARTITION (-40)
-
-/**
- * There is not monitor connected to the
- * connector of the selected CRTC
- */
-#define LIBGAMMA_NOT_CONNECTED (-41)
-
-/**
- * Data extraction from a reply from the
- * adjustment method failed, reason unknown
- */
-#define LIBGAMMA_REPLY_VALUE_EXTRACTION_FAILED (-42)
-
-/**
- * No EDID property was found on the output
- */
-#define LIBGAMMA_EDID_NOT_FOUND (-43)
-
-/**
- * Failed to list properties on the output,
- * reason unknown
- */
-#define LIBGAMMA_LIST_PROPERTIES_FAILED (-44)
-
-/**
- * Failed to query a property's value from
- * the output, reason unknown
- */
-#define LIBGAMMA_PROPERTY_VALUE_QUERY_FAILED (-45)
-
-/**
- * A request for information on an output
- * failed, reason unknown
- */
-#define LIBGAMMA_OUTPUT_INFORMATION_QUERY_FAILED (-46)
-
-
-
-/**
- * The number of the libgamma error with the
- * lowest number. If this is lower than the
- * number your program thinks it should be sould
- * update your program for new errors.
- */
-#define LIBGAMMA_ERROR_MIN (-46)
-
-
-
-/**
- * Prints an error to stderr in a `perror` fashion,
- * however this function will not translate the `libgamma`
- * errors into human-readable strings, it will simply
- * print the name of the error. If the value `error_code`
- * is the value of `LIBGAMMA_ERRNO_SET`, `perror` will be
- * used to print the current error stored in `errno`.
- * If `error_code` is non-negative (an `errno` value`), that
- * value will be stored in `errno` and `perror` will be
- * used to print it. Additionally, if the `error_code` is
- * the value of `LIBGAMMA_DEVICE_REQUIRE_GROUP` the
- * required group will be printed with its numerical value
- * and, if known, its name.
- *
- * @param name The text to add at the beginning
- * @param error_code The error code, may be an `errno` value
- */
-void libgamma_perror(const char *, int);
-
-/**
- * Returns the name of the definition associated with a `libgamma` error code
- *
- * @param value The error code
- * @return The name of the definition associated with the error code,
- * `NULL` if the error code does not exist. The return string
- * should not be `free`:d.
- */
-const char *libgamma_name_of_error(int) __attribute__((const));
-
-/**
- * Return the value of a `libgamma` error definition refered to by name
- *
- * @param name The name of the definition associated with the error code
- * @return The error code, zero if the name is `NULL`
- * or does not refer to a `libgamma` error
- */
-int libgamma_value_of_error(const char *) __attribute__((const));
-
-
-
-#ifndef __GNUC__
-# undef __attribute__
-#endif
-
-#endif
diff --git a/src/lib/libgamma-facade.c.gpp b/src/lib/libgamma-facade.c.gpp
deleted file mode 100644
index 9f90ed6..0000000
--- a/src/lib/libgamma-facade.c.gpp
+++ /dev/null
@@ -1,1097 +0,0 @@
-/* -*- c -*- */
-/* See LICENSE file for copyright and license details. */
-#include "libgamma-facade.h"
-
-#include "libgamma-error.h"
-#include "libgamma-method.h"
-#include "gamma-helper.h"
-
-
-/* Initialise the general preprocessor */
-$>cd src/extract
-$>export PATH=".:${PATH}"
-
-/* Some general preprocessor we will use frequently */
-$<
-get-methods ()
-{
- ./libgamma-method-extract --list --method | cut -d _ -f 1,2 --complement
-}
-lowercase ()
-{
- echo "$*" | sed -e y/QWERTYUIOPASDFGHJKLZXCVBNM/qwertyuiopasdfghjklzxcvbnm/ | sed -e s:core_graphics:cg:g
-}
-$>
-
-/* Include all adjustment methods that are enabled at compile-time. */
-$>for method in $(get-methods); do
-#ifdef HAVE_LIBGAMMA_METHOD_${method}
-# include "gamma-$(lowercase $method | sed -e s:_:-:g).h"
-# ifndef HAVE_LIBGAMMA_METHODS
-# define HAVE_LIBGAMMA_METHODS
-# endif
-#endif
-$>done
-
-#include <unistd.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-
-/* Some things to reduce warnings when we do
- * not have any adjustment methods enabled */
-#ifndef HAVE_LIBGAMMA_METHODS
-# define HAVE_NO_LIBGAMMA_METHODS
-# ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
-# endif
-#endif
-
-
-
-#ifdef HAVE_LIBGAMMA_METHODS
-# ifdef HAVE_LIBGAMMA_METHOD_LINUX_DRM
-/**
- * Test whether a file descriptor refers to a VT
- *
- * @param fd The file descriptor
- * @return Whether the file descriptor refers to a VT
- */
-static int
-libgamma_is_vt_proper(int fd)
-{
- char buf[32], digit0;
-
- /* Get TTY */
- if (ttyname_r(fd, buf, sizeof(buf) / sizeof(char)))
- return 0;
-
- /* Validate TTY path */
- if (!strcmp(buf, "/dev/console"))
- return 1;
- if (strstr(buf, "/dev/tty") != buf)
- return 0;
-
- /* Validate TTY name */
- digit0 = buf[strlen("/dev/tty")];
- return '1' <= digit0 && digit0 <= '9';
-}
-# endif
-
-
-/**
- * Test the availability of an adjustment method
- *
- * @param method The adjustment method
- * @param operation Allowed values:
- * 0: Pass if the environment suggests it will work but is not fake
- * 1: Pass if the environment suggests it will work
- * 2: Pass if real and not fake
- * 3: Pass if real
- * 4: Always pass
- * Other values invoke undefined behaviour
- * @return Whether the test passed
- */
-static int
-libgamma_list_method_test(int method, int operation)
-{
- libgamma_method_capabilities_t caps;
- libgamma_method_capabilities(&caps, method);
-
- switch (operation) {
- case 0:
- /* Methods that the environment suggests will work, excluding fake */
- if (caps.fake)
- return 0;
- /* fall through */
-
- case 1:
- /* Methods that the environment suggests will work, including fake */
- if (!caps.real)
- return 0;
-#ifdef HAVE_LIBGAMMA_METHOD_LINUX_DRM
- if (method == LIBGAMMA_METHOD_LINUX_DRM) {
- return libgamma_is_vt_proper(STDIN_FILENO) ||
- libgamma_is_vt_proper(STDOUT_FILENO) ||
- libgamma_is_vt_proper(STDERR_FILENO);
- }
-#endif
-#ifdef HAVE_LIBGAMMA_METHOD_DUMMY
- if (method == LIBGAMMA_METHOD_DUMMY)
- return 0;
-#endif
- return caps.default_site_known;
-
- case 2:
- /* All real non-fake methods */
- return caps.real && !caps.fake;
-
- case 3:
- /* All real methods */
- return caps.real;
-
- default:
- /* All methods */
- return 1;
- }
-}
-#endif
-
-
-/**
- * List available adjustment methods by their order of preference based on the environment
- *
- * @param methods Output array of methods, should be able to hold `LIBGAMMA_METHOD_COUNT` elements
- * @param buf_size The number of elements that fits in `methods`, it should be `LIBGAMMA_METHOD_COUNT`,
- * This is used to avoid writing outside the output buffer if this library adds new
- * adjustment methods without the users of the library recompiling
- * @param operation Allowed values:
- * 0: Methods that the environment suggests will work, excluding fake
- * 1: Methods that the environment suggests will work, including fake
- * 2: All real non-fake methods
- * 3: All real methods
- * 4: All methods
- * Other values invoke undefined behaviour
- * @return The number of element that have been stored in `methods`, or should
- * have been stored if the buffer was large enough.
- */
-size_t
-libgamma_list_methods(int *restrict methods, size_t buf_size, int operation)
-{
-#ifdef HAVE_NO_LIBGAMMA_METHODS
- (void) methods;
- (void) buf_size;
- (void) operation;
- return 0;
-#else
- size_t n = 0;
-
-$>for method in $(get-methods); do
-#ifdef HAVE_LIBGAMMA_METHOD_${method}
- if (libgamma_list_method_test(LIBGAMMA_METHOD_${method}, operation) && n++ < buf_size)
- methods[n - 1] = LIBGAMMA_METHOD_${method};
-#endif
-$>done
-
- return n;
-#endif
-}
-
-
-/**
- * Check whether an adjustment method is available, non-existing (invalid) methods will be
- * identified as not available under the rationale that the library may be out of date
- *
- * @param method The adjustment method
- * @return Whether the adjustment method is available
- */
-int
-libgamma_is_method_available(int method)
-{
-#ifdef HAVE_NO_LIBGAMMA_METHODS
- (void) method;
- return 0;
-#else
- switch (method) {
-$>for method in $(get-methods); do
-#ifdef HAVE_LIBGAMMA_METHOD_${method}
- case LIBGAMMA_METHOD_${method}:
-#endif
-$>done
- return 1;
-
- default:
- return 0;
- }
-#endif
-}
-
-
-/**
- * Call the adjustment method's implementation of the called function
- *
- * @param 1 The adjustment method, you may use `.` instead of `->` when resolving it
- * @param 2 `return` if the function returns a value, `break` otherwise
- * @param 3 The base name of the function to call, that is, the name of the function
- * this is expended into without the libgamma namespace prefix
- * @param * The function's parameters
- */
-$<switch ()
-$>{
- /* Read out macro's parameters */
-$<method="${1//./->}"
- ctrl=$2
- fun=$3
- shift 3
- params="$*"
-$>params="${params// /, }"
-
- switch (${method}) {
-$>for adjmethod in $(get-methods); do
-#ifdef HAVE_LIBGAMMA_METHOD_${adjmethod}
- case LIBGAMMA_METHOD_${adjmethod}:
- /* Call the adjustment method's implementation, either
- * return or break after it depending on macro parameter's */
-$> if [ $ctrl = return ]; then
- return
- libgamma_$(lowercase $adjmethod)_${fun}(${params});
-$> elif [ ! $ctrl = return ]; then
- break;
-$> fi
-#endif
-$>done
-
- default:
- /* If the adjustment method does not exists, either return
- * that error, or do nothing because the function this is
- * expanded into does return errors */
-$>if [ $ctrl = return ]; then
- return LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD;
-$>else
- /* Method does not exists/excluded at compile-time.
- * We will assume that this is not done... */
- break;
-$>fi
- }
-$>}
-
-
-/**
- * Return the capabilities of an adjustment method
- *
- * @param this The data structure to fill with the method's capabilities
- * @param method The adjustment method (display server and protocol)
- */
-void
-libgamma_method_capabilities(libgamma_method_capabilities_t *restrict this, int method)
-{
- memset(this, 0, sizeof(libgamma_method_capabilities_t));
-$>switch method break method_capabilities this
-}
-
-
-/**
- * Return the default site for an adjustment method
- *
- * @param method The adjustment method (display server and protocol)
- * @return The default site, `NULL` if it cannot be determined or
- * if multiple sites are not supported by the adjustment
- * method; this value should not be `free`:d
- */
-char *
-libgamma_method_default_site(int method)
-{
- const char *restrict var = libgamma_method_default_site_variable(method);
- char *restrict env;
-
- /* Return `NULL` there is not variable to read */
- if (!var)
- return NULL;
-
- /* Read the variable */
- env = getenv(var);
- /* Return `NULL` if it does not exist (or is empty) */
- if (!env || !*env)
- return NULL;
-
- /* Return the variable's value */
- return env;
-}
-
-
-/**
- * Return the default variable that determines
- * the default site for an adjustment method
- *
- * @param method The adjustment method (display server and protocol)
- * @return The environ variables that is used to determine the
- * default site. `NULL` if there is none, that is, if
- * the method does not support multiple sites.
- * This value should not be `free`:d.
- */
-const char *
-libgamma_method_default_site_variable(int method)
-{
- switch (method) {
-#ifdef HAVE_LIBGAMMA_METHOD_X_RANDR
- case LIBGAMMA_METHOD_X_RANDR:
- return "DISPLAY";
-#endif
-#ifdef HAVE_LIBGAMMA_METHOD_X_VIDMODE
- case LIBGAMMA_METHOD_X_VIDMODE:
- return "DISPLAY";
-#endif
- default:
- return NULL;
- }
-}
-
-
-/**
- * Initialise an allocated site state
- *
- * @param this The site state to initialise
- * @param method The adjustment method (display server and protocol)
- * @param site The site identifier, unless it is `NULL` it must a
- * `free`:able. Once the state is destroyed the library
- * will attempt to free it. There you should not free
- * it yourself, and it must not be a string constant
- * or allocated on the stack. Note however that it will
- * not be `free`:d if this function fails.
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int
-libgamma_site_initialise(libgamma_site_state_t *restrict this, int method, char *restrict site)
-{
- this->method = method;
- this->site = site;
-$>switch method return site_initialise this site
-}
-
-
-/**
- * Release all resources held by a site state
- *
- * @param this The site state
- */
-void
-libgamma_site_destroy(libgamma_site_state_t *restrict this)
-{
-$>switch this.method break site_destroy this
- free(this->site);
-}
-
-
-/**
- * Release all resources held by a site state
- * and free the site state pointer
- *
- * @param this The site state
- */
-void
-libgamma_site_free(libgamma_site_state_t *restrict this)
-{
- libgamma_site_destroy(this);
- free(this);
-}
-
-
-/**
- * Restore the gamma ramps all CRTC:s with a site to the system settings
- *
- * @param this The site state
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int
-libgamma_site_restore(libgamma_site_state_t *restrict this)
-{
-$>switch this.method return site_restore this
-}
-
-
-
-/**
- * Initialise an allocated partition state
- *
- * @param this The partition state to initialise
- * @param site The site state for the site that the partition belongs to
- * @param partition The index of the partition within the site
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int
-libgamma_partition_initialise(libgamma_partition_state_t *restrict this, libgamma_site_state_t *restrict site, size_t partition)
-{
- this->site = site;
- this->partition = partition;
-$>switch site.method return partition_initialise this site partition
-}
-
-
-/**
- * Release all resources held by a partition state
- *
- * @param this The partition state
- */
-void
-libgamma_partition_destroy(libgamma_partition_state_t *restrict this)
-{
-$>switch this.site.method break partition_destroy this
-}
-
-
-/**
- * Release all resources held by a partition state
- * and free the partition state pointer
- *
- * @param this The partition state
- */
-void
-libgamma_partition_free(libgamma_partition_state_t *restrict this)
-{
- libgamma_partition_destroy(this);
- free(this);
-}
-
-
-/**
- * Restore the gamma ramps all CRTC:s with a partition to the system settings
- *
- * @param this The partition state
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int
-libgamma_partition_restore(libgamma_partition_state_t *restrict this)
-{
-$>switch this.site.method return partition_restore this
-}
-
-
-
-/**
- * Initialise an allocated CRTC state
- *
- * @param this The CRTC state to initialise
- * @param partition The partition state for the partition that the CRTC belongs to
- * @param crtc The index of the CRTC within the partition
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int
-libgamma_crtc_initialise(libgamma_crtc_state_t *restrict this, libgamma_partition_state_t *restrict partition, size_t crtc)
-{
- this->partition = partition;
- this->crtc = crtc;
-$>switch partition.site.method return crtc_initialise this partition crtc
-}
-
-
-/**
- * Release all resources held by a CRTC state
- *
- * @param this The CRTC state
- */
-void
-libgamma_crtc_destroy(libgamma_crtc_state_t *restrict this)
-{
-$>switch this.partition.site.method break crtc_destroy this
-}
-
-
-/**
- * Release all resources held by a CRTC state
- * and free the CRTC state pointer
- *
- * @param this The CRTC state
- */
-void
-libgamma_crtc_free(libgamma_crtc_state_t *restrict this)
-{
- libgamma_crtc_destroy(this);
- free(this);
-}
-
-
-/**
- * Restore the gamma ramps for a CRTC to the system settings for that CRTC
- *
- * @param this The CRTC state
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int
-libgamma_crtc_restore(libgamma_crtc_state_t *restrict this)
-{
-$>switch this.partition.site.method return crtc_restore this
-}
-
-
-
-/**
- * Read information about a CRTC
- *
- * @param this Instance of a data structure to fill with the information about the CRTC
- * @param crtc The state of the CRTC whose information should be read
- * @param fields OR:ed identifiers for the information about the CRTC that should be read
- * @return Zero on success, -1 on error; on error refer to the error reports in `this`
- */
-int
-libgamma_get_crtc_information(libgamma_crtc_information_t *restrict this, libgamma_crtc_state_t *restrict crtc, int32_t fields)
-{
-#ifdef HAVE_NO_LIBGAMMA_METHODS
- (void) fields;
-#endif
- this->edid = NULL;
- this->connector_name = NULL;
-$>switch crtc.partition.site.method return get_crtc_information this crtc fields
-}
-
-
-/**
- * Release all resources in an information data structure for a CRTC
- *
- * @param this The CRTC information
- */
-void
-libgamma_crtc_information_destroy(libgamma_crtc_information_t *restrict this)
-{
- free(this->edid);
- free(this->connector_name);
-}
-
-
-/**
- * Release all resources in an information data structure for a CRTC
- * and free the data structure pointer
- *
- * @param this The CRTC information
- */
-void
-libgamma_crtc_information_free(libgamma_crtc_information_t *restrict this)
-{
- libgamma_crtc_information_destroy(this);
- free(this);
-}
-
-
-/**
- * Convert a raw representation of an EDID to a hexadecimal representation
- *
- * @param 1 Casing name
- * @param 2 The hexadecimal alphabet
- * @param edid The EDID in raw representation
- * @param length The length of `edid`
- * @return The EDID in hexadecimal representation
- * `NULL` on allocation error, `errno` will be set accordingly
- */
-$>behex_edid ()
-$>{
-char *
-libgamma_behex_edid_${1}(const unsigned char *restrict edid, size_t length)
-{
- char *restrict out;
- size_t i;
-
- /* Allocate memory area for the output string */
- out = malloc((length * 2 + 1) * sizeof(char));
- if (!out)
- return NULL;
-
- /* Translate from raw octets to hexadecimal */
- for (i = 0; i < length; i++) {
- out[i * 2 + 0] = "${2}"[(edid[i] >> 4) & 15];
- out[i * 2 + 1] = "${2}"[(edid[i] >> 0) & 15];
- }
- /* NUL-terminate the output string */
- out[length * 2] = '\0';
-
- return out;
-}
-$>}
-
-
-/**
- * Convert a raw representation of an EDID to a lowercase hexadecimal representation
- *
- * @param edid The EDID in raw representation
- * @param length The length of `edid`
- * @return The EDID in lowercase hexadecimal representation,
- * `NULL` on allocation error, `errno` will be set accordingly
- */
-$>behex_edid lowercase 0123456789abcdef
-
-
-/**
- * Convert a raw representation of an EDID to an uppercase hexadecimal representation
- *
- * @param edid The EDID in raw representation
- * @param length The length of `edid`
- * @return The EDID in uppercase hexadecimal representation,
- * NULL` on allocation error, `errno` will be set accordingly
- */
-$>behex_edid uppercase 0123456789ABCDEF
-
-
-/**
- * Convert an hexadecimal representation of an EDID to a raw representation
- *
- * @param edid The EDID in hexadecimal representation
- * @return The EDID in raw representation, it will be half the length
- * of `edid` (the input value); `NULL` on allocation error or
- * if the EDID is malformated, `errno` will be set accordingly
- */
-unsigned char *
-libgamma_unhex_edid(const char *restrict edid)
-{
-#define not_range(lower, V, upper) (V < lower || upper < V)
-#define is_not_hex(V) (not_range('0', V, '9') && not_range('a', V, 'f') && not_range('A', V, 'F'))
-
- unsigned char *restrict out;
- size_t i, n = strlen(edid);
- char a, b;
-
- /* Check that the length of the strings is even,
- * otherwise it cannot represent bytes */
- if (n & 1) {
- errno = EINVAL;
- return NULL;
- }
-
- /* Allocate memory area for output octet array */
- n /= 2 * sizeof(unsigned char);
- out = malloc(n);
- if (!out)
- return NULL;
-
- /* Convert to raw octet array */
- for (i = 0; i < n; i++) {
- /* Get the next character pair that, it represents an octet. */
- a = edid[i * 2 + 0];
- b = edid[i * 2 + 1];
-
- /* Verify that the input is in hexadecimal */
- if (is_not_hex(a) || is_not_hex(b)) {
- free(out);
- errno = EINVAL;
- return NULL;
- }
-
- /* Convert each chararacter to raw format */
- a = (char)((a & 15) + (a > '9' ? 9 : 0));
- b = (char)((b & 15) + (b > '9' ? 9 : 0));
-
- /* Combine the two characters into one octet */
- out[i] = (unsigned char)((a << 4) | b);
- }
-
- return out;
-
-#undef is_hex
-#undef not_range
-}
-
-
-/**
- * Get the current gamma ramps for a CRTC, 16-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int
-libgamma_crtc_get_gamma_ramps16(libgamma_crtc_state_t *restrict this, libgamma_gamma_ramps16_t *restrict ramps)
-{
- libgamma_gamma_ramps_any_t ramps_;
-
-#ifdef HAVE_NO_LIBGAMMA_METHODS
- (void) ramps;
-#endif
-
- switch (this->partition->site->method) {
- /* Methods other than Quartz/CoreGraphics uses 16-bit integers */
-$>for method in $(get-methods | grep -v QUARTZ_CORE_GRAPHICS); do
-#ifdef HAVE_LIBGAMMA_METHOD_${method}
- case LIBGAMMA_METHOD_${method}:
- return libgamma_$(lowercase $method)_crtc_get_gamma_ramps16(this, ramps);
-#endif
-
- /* The Quartz/CoreGraphics method uses single precision float */
-$>done
-#ifdef HAVE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS
- case LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS:
- ramps_.bits16 = *ramps;
- return libgamma_translated_ramp_get(this, &ramps_, 16, -1, libgamma_crtc_get_gamma_rampsf);
-#endif
-
- /* The selected method does not exist */
- default:
- return LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD;
- }
-}
-
-
-/**
- * Set the gamma ramps for a CRTC, 16-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int
-libgamma_crtc_set_gamma_ramps16(libgamma_crtc_state_t *restrict this, libgamma_gamma_ramps16_t ramps)
-{
- libgamma_gamma_ramps_any_t ramps_;
-
-#ifdef HAVE_NO_LIBGAMMA_METHODS
- (void) ramps;
-#endif
-
- switch (this->partition->site->method) {
- /* Methods other than Quartz/CoreGraphics uses 16-bit integers */
-$>for method in $(get-methods | grep -v QUARTZ_CORE_GRAPHICS); do
-#ifdef HAVE_LIBGAMMA_METHOD_${method}
- case LIBGAMMA_METHOD_${method}:
- return libgamma_$(lowercase $method)_crtc_set_gamma_ramps16(this, ramps);
-#endif
-$>done
-
- /* The Quartz/CoreGraphics method uses single precision float */
-#ifdef HAVE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS
- case LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS:
- ramps_.bits16 = ramps;
- return libgamma_translated_ramp_set(this, ramps_, 16, -1, libgamma_crtc_set_gamma_rampsf);
-#endif
-
- /* The selected method does not exist. */
- default:
- return LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD;
- }
-}
-
-
-
-/**
- * Set or get the gamma ramps for a CRTC, non-16-bit gamma-depth version
- *
- * @param 1 Either `get` or `set`, for the action that the name of value implies
- * @param 2 The `ramp*` pattern for the ramp structure and function to call
- * @param 3 Either of `bit8`, `bit16`, `bit32`, `bit64`, `float_single`, `float_double`;
- * rather self-explanatory
- * @param 4 The number of bits in the gamma depth, -1 for single precision float,
- * (`float`) and -2 for double percition float (`double`)
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply, or
- * the gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps ()
-$>{
-$<action=$1
- ramps=$2
- type=$3
- bits=$4
- p=
- if [ $action = get ]; then
- p='*'
- fi
-$>
-int
-libgamma_crtc_${action}_gamma_${ramps}(libgamma_crtc_state_t *restrict this, libgamma_gamma_${ramps}_t${p:+* restrict} ramps)
-{
- libgamma_gamma_ramps_any_t ramps_;
- switch (this->partition->site->method) {
- /* The dummy method supports all ramp depths */
-#ifdef HAVE_LIBGAMMA_METHOD_DUMMY
- case LIBGAMMA_METHOD_DUMMY:
- return libgamma_dummy_crtc_${action}_gamma_${ramps}(this, ramps);
-#endif
-
- /* The Quartz/CoreGraphics method uses single precision float */
-#ifdef HAVE_LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS
- case LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS:
-$>if [ $bits = -1 ]; then
- /* Single precision float is used */
- return libgamma_quartz_cg_crtc_${action}_gamma_${ramps}(this, ramps);
-$>else
- /* Something else is used and we convert to Single precision float */
- ramps_.${type} = ${p}ramps;
- return libgamma_translated_ramp_${action}(this, ${p:+&}ramps_, ${bits}, -1, libgamma_crtc_${action}_gamma_rampsf);
-$>fi
-#endif
-
- /* Other methods use 16-bit integers. */
- default:
- ramps_.${type} = ${p}ramps;
- return libgamma_translated_ramp_${action}(this, ${p:+&}ramps_, ${bits}, 16, libgamma_crtc_${action}_gamma_ramps16);
- }
-}
-$>}
-
-
-
-/**
- * Get the current gamma ramps for a CRTC, 8-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps get ramps8 bits8 8
-
-
-/**
- * Set the gamma ramps for a CRTC, 32-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps set ramps8 bits8 8
-
-
-
-/**
- * Get the current gamma ramps for a CRTC, 32-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps get ramps32 bits32 32
-
-
-/**
- * Set the gamma ramps for a CRTC, 32-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps set ramps32 bits32 32
-
-
-
-/**
- * Get the current gamma ramps for a CRTC, 64-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps get ramps64 bits64 64
-
-
-/**
- * Set the gamma ramps for a CRTC, 64-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps set ramps64 bits64 64
-
-
-/**
- * Get the current gamma ramps for a CRTC, `float` version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps get rampsf float_single -1
-
-
-/**
- * Set the gamma ramps for a CRTC, `float` version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps set rampsf float_single -1
-
-
-
-/**
- * Get the current gamma ramps for a CRTC, `double` version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps get rampsd float_double -2
-
-
-/**
- * Set the gamma ramps for a CRTC, `double` version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_get_gamma_ramps set rampsd float_double -2
-
-
-
-/**
- * Set the gamma ramps for a CRTC
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param 1 The data type for the ramp stop elements
- * @param 2 The `ramp*` pattern for the ramp structure and function to call
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_gamma_ramps_f ()
-$>{
-int
-libgamma_crtc_set_gamma_${2}_f(libgamma_crtc_state_t *restrict this, libgamma_gamma_${2}_fun *red_function,
- libgamma_gamma_${2}_fun *green_function, libgamma_gamma_${2}_fun *blue_function)
-{
- libgamma_crtc_information_t info;
- libgamma_gamma_${2}_t ramps;
- size_t i, n;
- int e;
-
- /* Get the size of the gamma ramps */
- if (libgamma_get_crtc_information(&info, this, LIBGAMMA_CRTC_INFO_GAMMA_SIZE)) {
- e = info.gamma_size_error;
- if (e < 0)
- return e;
- errno = e;
- return LIBGAMMA_ERRNO_SET;
- }
-
- /* Copy the size of the gamma ramps and calculte the grand size */
- n = ramps. red_size = info. red_gamma_size;
- n += ramps.green_size = info.green_gamma_size;
- n += ramps. blue_size = info. blue_gamma_size;
-
- /* Allocate gamma ramps */
- ramps. red = malloc(n * sizeof(${1}));
- ramps.green = &ramps. red[ramps. red_size];
- ramps. blue = &ramps.green[ramps.green_size];
- if (!ramps.red)
- return LIBGAMMA_ERRNO_SET;
-
- /* Generate the gamma ramp for the red chennel */
- for (i = 0, n = ramps.red_size; i < n; i++)
- ramps.red[i] = red_function((float)i / (float)(n - 1));
-
- /* Generate the gamma ramp for the green chennel */
- for (i = 0, n = ramps.green_size; i < n; i++)
- ramps.green[i] = green_function((float)i / (float)(n - 1));
-
- /* Generate the gamma ramp for the blue chennel */
- for (i = 0, n = ramps.blue_size; i < n; i++)
- ramps.blue[i] = blue_function((float)i / (float)(n - 1));
-
- /* Apply the gamma ramps */
- e = libgamma_crtc_set_gamma_${2}(this, ramps);
- free(ramps.red);
- return e;
-}
-$>}
-
-
-/**
- * Set the gamma ramps for a CRTC, 8-bit gamma-depth function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_gamma_ramps_f uint8_t ramps8
-
-
-/**
- * Set the gamma ramps for a CRTC, 16-bit gamma-depth function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_gamma_ramps_f uint16_t ramps16
-
-
-/**
- * Set the gamma ramps for a CRTC, 32-bit gamma-depth function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_gamma_ramps_f uint32_t ramps32
-
-
-/**
- * Set the gamma ramps for a CRTC, 64-bit gamma-depth function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_gamma_ramps_f uint64_t ramps64
-
-
-/**
- * Set the gamma ramps for a CRTC, `float` function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_gamma_ramps_f float rampsf
-
-
-/**
- * Set the gamma ramps for a CRTC, `double` function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-$>crtc_set_gamma_ramps_f double rampsd
-
-
-
-#ifdef HAVE_NO_LIBGAMMA_METHODS
-# ifdef __GNUC__
-# pragma GCC diagnostic pop
-# endif
-#endif
diff --git a/src/lib/libgamma-facade.h b/src/lib/libgamma-facade.h
deleted file mode 100644
index 596094c..0000000
--- a/src/lib/libgamma-facade.h
+++ /dev/null
@@ -1,537 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef LIBGAMMA_FACADE_H
-#define LIBGAMMA_FACADE_H
-
-#if !defined(LIBGAMMA_CONFIG_H) && !defined(DEBUG)
-# error libgamma-facade.h should not be included directly, include libgamma.h instead
-#endif
-
-
-#include "libgamma-method.h"
-
-#include <stddef.h>
-#include <stdint.h>
-
-#ifndef __GNUC__
-# define __attribute__(x)
-#endif
-
-
-
-/**
- * Mapping function from [0, 1] float encoding value to [0, 2⁸ − 1] integer output value
- *
- * @param encoding [0, 1] float encoding value
- * @return [0, 2⁸ − 1] integer output value
- */
-typedef uint8_t libgamma_gamma_ramps8_fun(float);
-
-/**
- * Mapping function from [0, 1] float encoding value to [0, 2¹⁶ − 1] integer output value
- *
- * @param encoding [0, 1] float encoding value
- * @return [0, 2¹⁶ − 1] integer output value
- */
-typedef uint16_t libgamma_gamma_ramps16_fun(float);
-
-/**
- * Mapping function from [0, 1] float encoding value to [0, 2³² − 1] integer output value
- *
- * @param encoding [0, 1] float encoding value
- * @return [0, 2³² − 1] integer output value
- */
-typedef uint32_t libgamma_gamma_ramps32_fun(float);
-
-/**
- * Mapping function from [0, 1] float encoding value to [0, 2⁶⁴ − 1] integer output value
- *
- * @param encoding [0, 1] float encoding value
- * @return [0, 2⁶⁴ − 1] integer output value
- */
-typedef uint64_t libgamma_gamma_ramps64_fun(float);
-
-/**
- * Mapping function from [0, 1] float encoding value to [0, 1] float output value
- *
- * @param encoding [0, 1] float encoding value
- * @return [0, 1] float output value
- */
-typedef float libgamma_gamma_rampsf_fun(float);
-
-/**
- * Mapping function from [0, 1] double precision float encoding
- * value to [0, 1] double precision float output value
- *
- * @param encoding [0, 1] float encoding value
- * @return [0, 1] float output value
- */
-typedef double libgamma_gamma_rampsd_fun(double);
-
-
-
-/**
- * List available adjustment methods by their order of preference based on the environment
- *
- * @param methods Output array of methods, should be able to hold `LIBGAMMA_METHOD_COUNT` elements
- * @param buf_size The number of elements that fits in `methods`, it should be `LIBGAMMA_METHOD_COUNT`,
- * This is used to avoid writing outside the output buffer if this library adds new
- * adjustment methods without the users of the library recompiling
- * @param operation Allowed values:
- * 0: Methods that the environment suggests will work, excluding fake
- * 1: Methods that the environment suggests will work, including fake
- * 2: All real non-fake methods
- * 3: All real methods
- * 4: All methods
- * Other values invoke undefined behaviour
- * @return The number of element that have been stored in `methods`, or should
- * have been stored if the buffer was large enough
- */
-size_t libgamma_list_methods(int *restrict, size_t, int);
-
-/**
- * Check whether an adjustment method is available, non-existing (invalid) methods will be
- * identified as not available under the rationale that the library may be out of date
- *
- * @param method The adjustment method
- * @return Whether the adjustment method is available
- */
-int libgamma_is_method_available(int) __attribute__((const));
-
-/**
- * Return the capabilities of an adjustment method
- *
- * @param this The data structure to fill with the method's capabilities
- * @param method The adjustment method (display server and protocol)
- */
-void libgamma_method_capabilities(libgamma_method_capabilities_t *restrict, int);
-
-/**
- * Return the default site for an adjustment method
- *
- * @param method The adjustment method (display server and protocol)
- * @return The default site, `NULL` if it cannot be determined or
- * if multiple sites are not supported by the adjustment
- * method; this value should not be `free`:d
- */
-char *libgamma_method_default_site(int);
-
-/**
- * Return the default variable that determines
- * the default site for an adjustment method
- *
- * @param method The adjustment method (display server and protocol)
- * @return The environ variables that is used to determine the
- * default site, `NULL` if there is none, that is, if
- * the method does not support multiple sites; this
- * value should not be `free`:d
- */
-const char *libgamma_method_default_site_variable(int) __attribute__((const));
-
-
-/**
- * Initialise an allocated site state
- *
- * @param this The site state to initialise
- * @param method The adjustment method (display server and protocol)
- * @param site The site identifier, unless it is `NULL` it must a
- * `free`:able. Once the state is destroyed the library
- * will attempt to free it. There you should not free
- * it yourself, and it must not be a string constant
- * or allocate on the stack. Note however that it will
- * not be `free`:d if this function fails.
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_site_initialise(libgamma_site_state_t *restrict, int, char *restrict);
-
-/**
- * Release all resources held by a site state
- *
- * @param this The site state
- */
-void libgamma_site_destroy(libgamma_site_state_t *restrict);
-
-/**
- * Release all resources held by a site state
- * and free the site state pointer
- *
- * @param this The site state
- */
-void libgamma_site_free(libgamma_site_state_t *restrict);
-
-/**
- * Restore the gamma ramps all CRTC:s within a site to the system settings
- *
- * @param this The site state
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_site_restore(libgamma_site_state_t *restrict);
-
-
-/**
- * Initialise an allocated partition state
- *
- * @param this The partition state to initialise
- * @param site The site state for the site that the partition belongs to
- * @param partition The index of the partition within the site
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_partition_initialise(libgamma_partition_state_t *restrict, libgamma_site_state_t *restrict, size_t);
-
-/**
- * Release all resources held by a partition state
- *
- * @param this The partition state
- */
-void libgamma_partition_destroy(libgamma_partition_state_t *restrict);
-
-/**
- * Release all resources held by a partition state
- * and free the partition state pointer
- *
- * @param this The partition state
- */
-void libgamma_partition_free(libgamma_partition_state_t *restrict);
-
-/**
- * Restore the gamma ramps all CRTC:s within a partition to the system settings
- *
- * @param this The partition state
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_partition_restore(libgamma_partition_state_t *restrict);
-
-
-/**
- * Initialise an allocated CRTC state
- *
- * @param this The CRTC state to initialise
- * @param partition The partition state for the partition that the CRTC belongs to
- * @param crtc The index of the CRTC within the partition
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_initialise(libgamma_crtc_state_t *restrict, libgamma_partition_state_t *restrict, size_t);
-
-/**
- * Release all resources held by a CRTC state
- *
- * @param this The CRTC state
- */
-void libgamma_crtc_destroy(libgamma_crtc_state_t *restrict);
-
-/**
- * Release all resources held by a CRTC state
- * and free the CRTC state pointer
- *
- * @param this The CRTC state
- */
-void libgamma_crtc_free(libgamma_crtc_state_t *restrict);
-
-/**
- * Restore the gamma ramps for a CRTC to the system settings for that CRTC
- *
- * @param this The CRTC state
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_restore(libgamma_crtc_state_t *restrict);
-
-
-/**
- * Read information about a CRTC
- *
- * @param this Instance of a data structure to fill with the information about the CRTC
- * @param crtc The state of the CRTC whose information should be read
- * @param fields OR:ed identifiers for the information about the CRTC that should be read
- * @return Zero on success, -1 on error; on error refer to the error reports in `this`
- */
-int libgamma_get_crtc_information(libgamma_crtc_information_t *restrict, libgamma_crtc_state_t *restrict, int32_t);
-
-/**
- * Release all resources in an information data structure for a CRTC
- *
- * @param this The CRTC information
- */
-void libgamma_crtc_information_destroy(libgamma_crtc_information_t *restrict);
-
-/**
- * Release all resources in an information data structure for a CRTC
- * and free the data structure pointer
- *
- * @param this The CRTC information
- */
-void libgamma_crtc_information_free(libgamma_crtc_information_t *restrict);
-
-/**
- * Convert a raw representation of an EDID to a lowercase hexadecimal representation
- *
- * @param edid:const unsigned char* The EDID in raw representation
- * @param length:size_t The length of `edid`
- * @return :char* The EDID in lowercase hexadecimal representation,
- * `NULL` on allocation error, `errno` will be set accordingly
- */
-#define libgamma_behex_edid(edid, length) libgamma_behex_edid_lowercase((edid), (length))
-
-/**
- * Convert a raw representation of an EDID to a lowercase hexadecimal representation
- *
- * @param edid The EDID in raw representation
- * @param length The length of `edid`
- * @return The EDID in lowercase hexadecimal representation
- * `NULL` on allocation error, `errno` will be set accordingly
- */
-char *libgamma_behex_edid_lowercase(const unsigned char *restrict, size_t);
-
-/**
- * Convert a raw representation of an EDID to an uppercase hexadecimal representation
- *
- * @param edid The EDID in raw representation
- * @param length The length of `edid`
- * @return The EDID in uppercase hexadecimal representation,
- * NULL` on allocation error, `errno` will be set accordingly
- */
-char *libgamma_behex_edid_uppercase(const unsigned char *restrict, size_t);
-
-/**
- * Convert an hexadecimal representation of an EDID to a raw representation
- *
- * @param edid The EDID in hexadecimal representation
- * @return The EDID in raw representation, it will be half the length
- * of `edid` (the input value); `NULL` on allocation error or
- * if the EDID is malformated, `errno` will be set accordingly
- */
-unsigned char *libgamma_unhex_edid(const char *restrict);
-
-
-/**
- * Get the current gamma ramps for a CRTC, 8-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_get_gamma_ramps8(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps8_t *restrict);
-
-/**
- * Set the gamma ramps for a CRTC, 8-bit gamma-depth version.
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_set_gamma_ramps8(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps8_t);
-
-
-/**
- * Get the current gamma ramps for a CRTC, 16-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_get_gamma_ramps16(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps16_t *restrict);
-
-/**
- * Set the gamma ramps for a CRTC, 16-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_set_gamma_ramps16(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps16_t) __attribute__((hot));
-
-
-/**
- * Get the current gamma ramps for a CRTC, 32-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_get_gamma_ramps32(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps32_t *restrict);
-
-/**
- * Set the gamma ramps for a CRTC, 32-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_set_gamma_ramps32(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps32_t);
-
-
-/**
- * Get the current gamma ramps for a CRTC, 64-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_get_gamma_ramps64(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps64_t *restrict);
-
-/**
- * Set the gamma ramps for a CRTC, 64-bit gamma-depth version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_set_gamma_ramps64(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps64_t);
-
-
-/**
- * Set the gamma ramps for a CRTC, `float` version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_set_gamma_rampsf(libgamma_crtc_state_t *restrict, libgamma_gamma_rampsf_t);
-
-/**
- * Get the current gamma ramps for a CRTC, `float` version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_get_gamma_rampsf(libgamma_crtc_state_t *restrict, libgamma_gamma_rampsf_t *restrict);
-
-
-/**
- * Get the current gamma ramps for a CRTC, `double` version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_get_gamma_rampsd(libgamma_crtc_state_t *restrict, libgamma_gamma_rampsd_t *restrict);
-
-/**
- * Set the gamma ramps for a CRTC, `double` version
- *
- * @param this The CRTC state
- * @param ramps The gamma ramps to apply
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-int libgamma_crtc_set_gamma_rampsd(libgamma_crtc_state_t *restrict, libgamma_gamma_rampsd_t);
-
-
-/**
- * Set the gamma ramps for a CRTC, 8-bit gamma-depth function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-__attribute__((cold))
-int libgamma_crtc_set_gamma_ramps8_f(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps8_fun *,
- libgamma_gamma_ramps8_fun *, libgamma_gamma_ramps8_fun *);
-
-/**
- * Set the gamma ramps for a CRTC, 16-bit gamma-depth function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-__attribute__((cold))
-int libgamma_crtc_set_gamma_ramps16_f(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps16_fun *,
- libgamma_gamma_ramps16_fun *, libgamma_gamma_ramps16_fun *);
-
-/**
- * Set the gamma ramps for a CRTC, 32-bit gamma-depth function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-__attribute__((cold))
-int libgamma_crtc_set_gamma_ramps32_f(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps32_fun *,
- libgamma_gamma_ramps32_fun *, libgamma_gamma_ramps32_fun *);
-
-/**
- * Set the gamma ramps for a CRTC, 64-bit gamma-depth function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-__attribute__((cold));
-int libgamma_crtc_set_gamma_ramps64_f(libgamma_crtc_state_t *restrict, libgamma_gamma_ramps64_fun *,
- libgamma_gamma_ramps64_fun *, libgamma_gamma_ramps64_fun *);
-
-/**
- * Set the gamma ramps for a CRTC, `float` function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-__attribute__((cold))
-int libgamma_crtc_set_gamma_rampsf_f(libgamma_crtc_state_t *restrict, libgamma_gamma_rampsf_fun *,
- libgamma_gamma_rampsf_fun *, libgamma_gamma_rampsf_fun *);
-
-/**
- * Set the gamma ramps for a CRTC, `double` function version
- *
- * Note that this will probably involve the library allocating temporary data
- *
- * @param this The CRTC state
- * @param red_function The function that generates the gamma ramp for the red channel
- * @param green_function The function that generates the gamma ramp for the green channel
- * @param blue_function The function that generates the gamma ramp for the blue channel
- * @return Zero on success, otherwise (negative) the value of an
- * error identifier provided by this library
- */
-__attribute__((cold))
-int libgamma_crtc_set_gamma_rampsd_f(libgamma_crtc_state_t *restrict, libgamma_gamma_rampsd_fun *,
- libgamma_gamma_rampsd_fun *, libgamma_gamma_rampsd_fun *);
-
-
-#ifndef __GNUC__
-# undef __attribute__
-#endif
-
-#endif
diff --git a/src/lib/libgamma-method.c b/src/lib/libgamma-method.c
deleted file mode 100644
index cf9a23b..0000000
--- a/src/lib/libgamma-method.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#include "libgamma-method.h"
-
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int
-libgamma_gamma_ramps8_initialise(libgamma_gamma_ramps8_t *restrict this)
-{
- size_t n = this->red_size + this->green_size + this->blue_size;
- this->red = malloc(n * sizeof(uint8_t));
- this->green = &this-> red[this-> red_size];
- this->blue = &this->green[this->green_size];
- return this->red ? 0 : -1;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise
- * initialises in the proper manner
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_ramps8_destroy(libgamma_gamma_ramps8_t *restrict this)
-{
- free(this->red);
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise
- * initialises in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_ramps8_free(libgamma_gamma_ramps8_t *restrict this)
-{
- free(this->red);
- free(this);
-}
-
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int
-libgamma_gamma_ramps16_initialise(libgamma_gamma_ramps16_t *restrict this)
-{
- size_t n = this->red_size + this->green_size + this->blue_size;
-#ifdef HAVE_LIBGAMMA_METHOD_LINUX_DRM
- /* Valgrind complains about us reading uninitialize memory if we just use malloc */
- this->red = calloc(n, sizeof(uint16_t));
-#else
- this->red = malloc(n * sizeof(uint16_t));
-#endif
- this->green = &this-> red[this-> red_size];
- this->blue = &this->green[this->green_size];
- return this->red ? 0 : -1;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps_initialise` or otherwise
- * initialises in the proper manner
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_ramps16_destroy(libgamma_gamma_ramps16_t *restrict this)
-{
- free(this->red);
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps_initialise` or otherwise
- * initialises in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_ramps16_free(libgamma_gamma_ramps16_t *restrict this)
-{
- free(this->red);
- free(this);
-}
-
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int
-libgamma_gamma_ramps32_initialise(libgamma_gamma_ramps32_t *restrict this)
-{
- size_t n = this->red_size + this->green_size + this->blue_size;
- this->red = malloc(n * sizeof(uint32_t));
- this->green = &this-> red[this-> red_size];
- this->blue = &this->green[this->green_size];
- return this->red ? 0 : -1;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps32_initialise` or otherwise
- * initialises in the proper manner
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_ramps32_destroy(libgamma_gamma_ramps32_t *restrict this)
-{
- free(this->red);
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps32_initialise` or otherwise
- * initialises in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_ramps32_free(libgamma_gamma_ramps32_t *restrict this)
-{
- free(this->red);
- free(this);
-}
-
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int
-libgamma_gamma_ramps64_initialise(libgamma_gamma_ramps64_t *restrict this)
-{
- size_t n = this->red_size + this->green_size + this->blue_size;
- this->red = malloc(n * sizeof(uint64_t));
- this->green = &this-> red[this-> red_size];
- this->blue = &this->green[this->green_size];
- return this->red ? 0 : -1;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps64_initialise` or otherwise
- * initialises in the proper manner
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_ramps64_destroy(libgamma_gamma_ramps64_t *restrict this)
-{
- free(this->red);
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps64_initialise` or otherwise
- * initialises in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_ramps64_free(libgamma_gamma_ramps64_t *restrict this)
-{
- free(this->red);
- free(this);
-}
-
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int
-libgamma_gamma_rampsf_initialise(libgamma_gamma_rampsf_t *restrict this)
-{
- size_t n = this->red_size + this->green_size + this->blue_size;
- this->red = malloc(n * sizeof(float));
- this->green = &this-> red[this-> red_size];
- this->blue = &this->green[this->green_size];
- return this->red ? 0 : -1;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_rampsf_initialise` or otherwise
- * initialises in the proper manner
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_rampsf_destroy(libgamma_gamma_rampsf_t *restrict this)
-{
- free(this->red);
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_rampsf_initialise` or otherwise
- * initialises in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_rampsf_free(libgamma_gamma_rampsf_t *restrict this)
-{
- free(this->red);
- free(this);
-}
-
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int
-libgamma_gamma_rampsd_initialise(libgamma_gamma_rampsd_t *restrict this)
-{
- size_t n = this->red_size + this->green_size + this->blue_size;
- this->red = malloc(n * sizeof(double));
- this->green = &this-> red[this-> red_size];
- this->blue = &this->green[this->green_size];
- return this->red ? 0 : -1;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_rampsd_initialise` or otherwise
- * initialises in the proper manner
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_rampsd_destroy(libgamma_gamma_rampsd_t *restrict this)
-{
- free(this->red);
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_rampsd_initialise` or otherwise
- * initialises in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void
-libgamma_gamma_rampsd_free(libgamma_gamma_rampsd_t *restrict this)
-{
- free(this->red);
- free(this);
-}
diff --git a/src/lib/libgamma-method.h b/src/lib/libgamma-method.h
deleted file mode 100644
index e2a35c6..0000000
--- a/src/lib/libgamma-method.h
+++ /dev/null
@@ -1,1323 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef LIBGAMMA_METHOD_H
-#define LIBGAMMA_METHOD_H
-
-#if !defined(LIBGAMMA_CONFIG_H) && !defined(DEBUG)
-# error libgamma-method.h should not be included directly, include libgamma.h instead
-#endif
-
-
-#ifndef __GNUC__
-# define __attribute__(x)
-#endif
-
-#include <stddef.h>
-#include <stdint.h>
-
-
-
-/**
- * The identifier for the dummy adjustment method
- *
- * This method can be configured and is useful for
- * testing your program's ability to handle errors
- */
-#define LIBGAMMA_METHOD_DUMMY 0
-
-/**
- * The identifier for the adjustment method with
- * uses the RandR protocol under the X display server
- */
-#define LIBGAMMA_METHOD_X_RANDR 1
-
-/**
- * The identifier for the adjustment method with
- * uses the VidMode protocol under the X display server
- *
- * This is an older alternative to RandR that can
- * work on some drivers that are not supported by RandR,
- * however it can only control the primary CRTC per
- * screen (partition)
- */
-#define LIBGAMMA_METHOD_X_VIDMODE 2
-
-/**
- * The identifier for the Direct Rendering Manager
- * adjustment method that is available in Linux
- * (built in to the Linux kernel with a userland
- * library for access) and is a part of the
- * Direct Rendering Infrastructure.
- *
- * This adjustment method will work when you are
- * in non-graphical mode; however a display server
- * cannot be started while this is running, but it
- * can be started while a display server is running
- */
-#define LIBGAMMA_METHOD_LINUX_DRM 3
-
-/**
- * The identifier for the Graphics Device Interface
- * adjustment method that is available in Windows
- *
- * This method is not well tested; it can be compiled
- * to be available under X.org using a translation layer
- */
-#define LIBGAMMA_METHOD_W32_GDI 4
-
-/**
- * The identifier for the CoreGraphics adjustment
- * method that is available in Mac OS X that can
- * adjust gamma ramps under the Quartz display server
- *
- * This method is not well tested; it can be compiled
- * to be available under X.org using a translation layer
- */
-#define LIBGAMMA_METHOD_QUARTZ_CORE_GRAPHICS 5
-
-
-/**
- * The index of the last gamma method, neither it
- * nor any index before it may actually be supported
- * as it could have been disabled at compile-time
- */
-#define LIBGAMMA_METHOD_MAX 5
-
-/**
- * The number adjustment methods provided by this library.
- * Note however that this includes adjstment methods that
- * have been removed at compile-time
- */
-#define LIBGAMMA_METHOD_COUNT (LIBGAMMA_METHOD_MAX + 1)
-
-
-
-/**
- * Capabilities of adjustment methods
- */
-typedef struct libgamma_method_capabilities {
- /**
- * OR of the CRTC information fields in `libgamma_crtc_information_t`
- * that may (but can fail) be read successfully
- */
- int32_t crtc_information;
-
- /**
- * Whether the default site is known, if true the site is integrated
- * to the system or can be determined using environment variables
- */
- unsigned default_site_known : 1;
-
- /**
- * Whether the adjustment method supports multiple sites rather
- * than just the default site
- */
- unsigned multiple_sites : 1;
-
- /**
- * Whether the adjustment method supports multiple partitions
- * per site
- */
- unsigned multiple_partitions : 1;
-
- /**
- * Whether the adjustment method supports multiple CRTC:s
- * per partition per site
- */
- unsigned multiple_crtcs : 1;
-
- /**
- * Whether the partition to graphics card is a bijection
- */
- unsigned partitions_are_graphics_cards : 1;
-
- /**
- * Whether the adjustment method supports `libgamma_site_restore`
- */
- unsigned site_restore : 1;
-
- /**
- * Whether the adjustment method supports `libgamma_partition_restore`
- */
- unsigned partition_restore : 1;
-
- /**
- * Whether the adjustment method supports `libgamma_crtc_restore`
- */
- unsigned crtc_restore : 1;
-
- /**
- * Whether the `red_gamma_size`, `green_gamma_size` and `blue_gamma_size`
- * fields in `libgamma_crtc_information_t` will always have the same
- * values as each other for the adjustment method
- */
- unsigned identical_gamma_sizes : 1;
-
- /**
- * Whether the `red_gamma_size`, `green_gamma_size` and `blue_gamma_size`
- * fields in `libgamma_crtc_information_t` will always be filled with the
- * same value for the adjustment method
- */
- unsigned fixed_gamma_size : 1;
-
- /**
- * Whether the `gamma_depth` field in `libgamma_crtc_information_t`
- * will always be filled with the same value for the adjustment method
- */
- unsigned fixed_gamma_depth : 1;
-
- /**
- * Whether the adjustment method will actually perform adjustments
- */
- unsigned real : 1;
-
- /**
- * Whether the adjustment method is implement using a translation layer
- */
- unsigned fake : 1;
-
- /**
- * Whether adjustments are undone when the process disconnects from
- * the display server
- */
- unsigned auto_restore : 1;
-
-} libgamma_method_capabilities_t;
-
-
-
-/**
- * Site state
- *
- * On operating systems that integrate a graphical environment
- * there is usually just one site. However, one systems with
- * pluggable graphics, like Unix-like systems such as GNU/Linux
- * and the BSD:s, there can usually be any (feasible) number of
- * sites. In X.org parlance they are called displays.
- */
-typedef struct libgamma_site_state {
- /**
- * Adjustment method implementation specific data.
- * You as a user of this library should not touch this.
- */
- void *data;
-
- /**
- * This field specifies, for the methods if this library,
- * which adjustment method (display server and protocol)
- * is used to adjust the gamma ramps
- */
- int method;
-
- /**
- * The site identifier. It can either be `NULL` or a string.
- * `NULL` indicates the default site. On systems like the
- * Unix-like systems, where the graphics are pluggable, this
- * is usually resolved by an environment variable, such as
- * "DISPLAY" for X.org.
- */
- char *site;
-
- /**
- * The number of partitions that is available on this site.
- * Probably the majority of display server only one partition
- * per site. However, X.org can, and traditional used to have
- * on multi-headed environments, multiple partitions per site.
- * In X.org partitions are called 'screens'. It is not to be
- * confused with monitor. A screen is a collection of monitors,
- * and the mapping from monitors to screens is a surjection.
- * On hardware-level adjustment methods, such as Direct
- * Rendering Manager, a partition is a graphics card.
- */
- size_t partitions_available;
-
-} libgamma_site_state_t;
-
-
-/**
- * Partition state
- *
- * Probably the majority of display server only one partition
- * per site. However, X.org can, and traditional used to have
- * on multi-headed environments, multiple partitions per site.
- * In X.org partitions are called 'screens'. It is not to be
- * confused with monitor. A screen is a collection of monitors,
- * and the mapping from monitors to screens is a surjection.
- * On hardware-level adjustment methods, such as Direct
- * Rendering Manager, a partition is a graphics card.
- */
-typedef struct libgamma_partition_state {
- /**
- * Adjustment method implementation specific data
- *
- * You as a user of this library should not touch this
- */
- void *data;
-
- /**
- * The site this partition belongs to
- */
- libgamma_site_state_t *site;
-
- /**
- * The index of the partition
- */
- size_t partition;
-
- /**
- * The number of CRTC:s that are available
- * under this partition
- *
- * Note that the CRTC:s are not necessarily
- * online.
- */
- size_t crtcs_available;
-
-} libgamma_partition_state_t;
-
-
-/**
- * Cathode ray tube controller state
- *
- * The CRTC controls the gamma ramps for the
- * monitor that is plugged in to the connector
- * that the CRTC belongs to
- */
-typedef struct libgamma_crtc_state {
- /**
- * Adjustment method implementation specific data
- *
- * You as a user of this library should not touch this
- */
- void *data;
-
- /**
- * The partition this CRTC belongs to
- */
- libgamma_partition_state_t *partition;
-
- /**
- * The index of the CRTC within its partition
- */
- size_t crtc;
-
-} libgamma_crtc_state_t;
-
-
-/**
- * Types for connectors
- */
-typedef enum libgamma_connector_type {
- /**
- * The adjustment method does not know the connector's type
- *
- * (This could be considered an error)
- */
- LIBGAMMA_CONNECTOR_TYPE_Unknown = 0,
-
- /**
- * Video Graphics Array (VGA)
- */
- LIBGAMMA_CONNECTOR_TYPE_VGA,
-
- /**
- * Digital Visual Interface, unknown type
- */
- LIBGAMMA_CONNECTOR_TYPE_DVI,
-
- /**
- * Digital Visual Interface, integrated (DVI-I)
- */
- LIBGAMMA_CONNECTOR_TYPE_DVII,
-
- /**
- * Digital Visual Interface, digital only (DVI-D)
- */
- LIBGAMMA_CONNECTOR_TYPE_DVID,
-
- /**
- * Digital Visual Interface, analogue only (DVI-A)
- */
- LIBGAMMA_CONNECTOR_TYPE_DVIA,
-
- /**
- * Composite video
- */
- LIBGAMMA_CONNECTOR_TYPE_Composite,
-
- /**
- * Separate Video (S-video)
- */
- LIBGAMMA_CONNECTOR_TYPE_SVIDEO,
-
- /**
- * Low-voltage differential signaling (LVDS)
- */
- LIBGAMMA_CONNECTOR_TYPE_LVDS,
-
- /**
- * Component video, usually separate cables for each channel
- */
- LIBGAMMA_CONNECTOR_TYPE_Component,
-
- /**
- * 9 pin DIN (Deutsches Institut für Normung) connector
- */
- LIBGAMMA_CONNECTOR_TYPE_9PinDIN,
-
- /**
- * DisplayPort
- */
- LIBGAMMA_CONNECTOR_TYPE_DisplayPort,
-
- /**
- * High-Definition Multimedia Interface (HDMI), unknown type
- */
- LIBGAMMA_CONNECTOR_TYPE_HDMI,
-
- /**
- * High-Definition Multimedia Interface, type A (HDMI-A)
- */
- LIBGAMMA_CONNECTOR_TYPE_HDMIA,
-
- /**
- * High-Definition Multimedia Interface, type B (HDMI-B)
- */
- LIBGAMMA_CONNECTOR_TYPE_HDMIB,
-
- /**
- * Television, unknown connector
- */
- LIBGAMMA_CONNECTOR_TYPE_TV,
-
- /**
- * Embedded DisplayPort (eDP)
- */
- LIBGAMMA_CONNECTOR_TYPE_eDP,
-
- /**
- * A virtual connector
- */
- LIBGAMMA_CONNECTOR_TYPE_VIRTUAL,
-
- /**
- * Display Serial Interface (DSI)
- */
- LIBGAMMA_CONNECTOR_TYPE_DSI,
-
- /**
- * LFP connector
- *
- * (What is this?)
- */
- LIBGAMMA_CONNECTOR_TYPE_LFP
-
-} libgamma_connector_type_t;
-
-/**
- * The number of values defined in `libgamma_connector_type_t`
- */
-#define LIBGAMMA_CONNECTOR_TYPE_COUNT 20
-
-/**
- * Orders for subpixels
- *
- * Currently the possible values are very biased
- * to LCD, Plasma and monochrome monitors
- */
-typedef enum libgamma_subpixel_order {
- /**
- * The adjustment method does not know the order of the subpixels
- *
- * (This could be considered an error)
- */
- LIBGAMMA_SUBPIXEL_ORDER_UNKNOWN = 0,
-
- /**
- * There are no subpixels in the monitor
- */
- LIBGAMMA_SUBPIXEL_ORDER_NONE,
-
- /**
- * The subpixels are ordered red, green and then blue, from left to right
- */
- LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_RGB,
-
- /**
- * The subpixels are ordered blue, green and then red, from left to right
- */
- LIBGAMMA_SUBPIXEL_ORDER_HORIZONTAL_BGR,
-
- /**
- * The subpixels are ordered red, green and then blue, from the top down
- */
- LIBGAMMA_SUBPIXEL_ORDER_VERTICAL_RGB,
-
- /**
- * The subpixels are ordered blue, green and then red, from the top down
- */
- LIBGAMMA_SUBPIXEL_ORDER_VERTICAL_BGR
-
-} libgamma_subpixel_order_t;
-
-/**
- * The number of values defined in `libgamma_subpixel_order_t`
- */
-#define LIBGAMMA_SUBPIXEL_ORDER_COUNT 6
-
-
-/**
- * Answer enum to a decision problem
- */
-typedef enum libgamma_decision {
- /**
- * The answer is negative
- */
- LIBGAMMA_NO = 0,
-
- /**
- * The answer is unknown
- */
- LIBGAMMA_MAYBE = 1,
-
- /**
- * The answer is positive
- */
- LIBGAMMA_YES = 2
-
-} libgamma_decision_t;
-
-
-/**
- * For a `libgamma_crtc_information_t` fill in the values for
- * `edid` and `edid_length` and report errors to `edid_error`
- */
-#define LIBGAMMA_CRTC_INFO_EDID (1 << 0)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the value
- * for `width_mm` and report errors to `width_mm_error`
- */
-#define LIBGAMMA_CRTC_INFO_WIDTH_MM (1 << 1)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the value
- * for `height_mm` and report errors to `height_mm_error`
- */
-#define LIBGAMMA_CRTC_INFO_HEIGHT_MM (1 << 2)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the value for
- * `width_mm_edid` and report errors to `width_mm_edid_error`
- */
-#define LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID (1 << 3)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the value for
- * `height_mm_edid` and report errors to `height_mm_edid_error`
- */
-#define LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID (1 << 4)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the values for
- * `red_gamma_size`, `green_gamma_size`, and `blue_gamma_size`,
- * and report errors to `gamma_size_error`
- */
-#define LIBGAMMA_CRTC_INFO_GAMMA_SIZE (1 << 5)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the value for
- * `gamma_depth` and report errors to `gamma_depth_error`
- */
-#define LIBGAMMA_CRTC_INFO_GAMMA_DEPTH (1 << 6)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the value for
- * `gamma_support` and report errors to `gamma_support_error`
- */
-#define LIBGAMMA_CRTC_INFO_GAMMA_SUPPORT (1 << 7)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the value for
- * `subpixel_order` and report errors to `subpixel_order_error`
- */
-#define LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER (1 << 8)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the
- * value for `active` and report errors to `active_error`
- */
-#define LIBGAMMA_CRTC_INFO_ACTIVE (1 << 9)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the value for
- * `connector_name` and report errors to `connector_name_error`
- */
-#define LIBGAMMA_CRTC_INFO_CONNECTOR_NAME (1 << 10)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the value for
- * `connector_type` and report errors to `connector_type_error`
- */
-#define LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE (1 << 11)
-
-/**
- * For a `libgamma_crtc_information_t` fill in the
- * values for `gamma_red`, `gamma_green`, and `gamma_blue`
- * and report errors to `gamma_error`
- */
-#define LIBGAMMA_CRTC_INFO_GAMMA (1 << 12)
-
-/**
- * The number of `LIBGAMMA_CRTC_INFO_*` values defined
- */
-#define LIBGAMMA_CRTC_INFO_COUNT 13
-
-/**
- * Macro for both `libgamma_crtc_information_t` fields
- * that can specify the size of the monitor's viewport
- * as specified in the monitor's Extended Display
- * Information Data
- */
-#define LIBGAMMA_CRTC_INFO_MACRO_EDID_VIEWPORT (LIBGAMMA_CRTC_INFO_WIDTH_MM_EDID | LIBGAMMA_CRTC_INFO_HEIGHT_MM_EDID)
-
-/**
- * Macro for all `libgamma_crtc_information_t` fields
- * that can be filled if the adjustment method have
- * support for reading the monitors' Extended Display
- * Information Data
- */
-#define LIBGAMMA_CRTC_INFO_MACRO_EDID (LIBGAMMA_CRTC_INFO_EDID | LIBGAMMA_CRTC_INFO_MACRO_EDID_VIEWPORT | LIBGAMMA_CRTC_INFO_GAMMA)
-
-/**
- * Macro for both `libgamma_crtc_information_t` fields
- * that can specify the size of the monitor's viewport
- * as provided by the adjustment method without this
- * library having to parse the monitor's Extended Display
- * Information Data
- */
-#define LIBGAMMA_CRTC_INFO_MACRO_VIEWPORT (LIBGAMMA_CRTC_INFO_WIDTH_MM | LIBGAMMA_CRTC_INFO_HEIGHT_MM)
-
-/**
- * Macro for the `libgamma_crtc_information_t` fields
- * that specifies the CRTC's gamma ramp sizes and gamma
- * ramp depth
- */
-#define LIBGAMMA_CRTC_INFO_MACRO_RAMP (LIBGAMMA_CRTC_INFO_GAMMA_SIZE | LIBGAMMA_CRTC_INFO_GAMMA_DEPTH)
-
-/**
- * Macro for the `libgamma_crtc_information_t` fields
- * that specifies the CRTC's connector type and the
- * partition unique name of the connector
- */
-#define LIBGAMMA_CRTC_INFO_MACRO_CONNECTOR (LIBGAMMA_CRTC_INFO_CONNECTOR_NAME | LIBGAMMA_CRTC_INFO_CONNECTOR_TYPE)
-
-/**
- * Macro for the `libgamma_crtc_information_t` fields
- * that required there is a monitor attached to the
- * connector, and that status itself
- */
-#define LIBGAMMA_CRTC_INFO_MACRO_ACTIVE (LIBGAMMA_CRTC_INFO_MACRO_EDID | LIBGAMMA_CRTC_INFO_MACRO_VIEWPORT |\
- LIBGAMMA_CRTC_INFO_SUBPIXEL_ORDER | LIBGAMMA_CRTC_INFO_ACTIVE)
-
-
-
-/**
- * Cathode ray tube controller information data structure
- */
-typedef struct libgamma_crtc_information {
- /**
- * The Extended Display Identification Data associated with
- * the attached monitor.
- *
- * This is raw byte array that is usually 128 bytes long.
- * It is not NUL-terminate, rather its length is stored in
- * `edid_length`.
- */
- unsigned char *edid;
-
- /**
- * The length of `edid`
- */
- size_t edid_length;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int edid_error;
-
-
- /**
- * The phyical width, in millimetres, of the viewport of the
- * attached monitor, as reported by the adjustment method
- *
- * This value may be incorrect, which is a known issue with
- * the X server where it is the result of the X server
- * attempting the estimate the size on its own
- *
- * Zero means that its is not applicable, which is the case
- * for projectors
- */
- size_t width_mm;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int width_mm_error;
-
-
- /**
- * The phyical height, in millimetres, of the viewport of the
- * attached monitor, as reported by the adjustment method
- *
- * This value may be incorrect, which is a known issue with
- * the X server where it is the result of the X server
- * attempting the estimate the size on its own
- *
- * Zero means that its is not applicable, which is the case
- * for projectors
- */
- size_t height_mm;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int height_mm_error;
-
-
- /**
- * The phyical width, in millimetres, of the viewport of the
- * attached monitor, as reported by it the monitor's Extended
- * Display Information Data
- *
- * This value can only contain whole centimetres, which means
- * that the result is always zero modulus ten. However, this
- * could change with revisions of the EDID structure.
- *
- * Zero means that its is not applicable, which is the case
- * for projectors.
- */
- size_t width_mm_edid;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int width_mm_edid_error;
-
-
- /**
- * The phyical height, in millimetres, of the viewport of the
- * attached monitor, as reported by it the monitor's Extended
- * Display Information Data
- *
- * This value can only contain whole centimetres, which means
- * that the result is always zero modulus ten. However, this
- * could change with revisions of the EDID structure.
- *
- * Zero means that its is not applicable, which is the case
- * for projectors
- */
- size_t height_mm_edid;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int height_mm_edid_error;
-
-
- /**
- * The size of the encoding axis of the red gamma ramp
- */
- size_t red_gamma_size;
-
- /**
- * The size of the encoding axis of the green gamma ramp
- */
- size_t green_gamma_size;
-
- /**
- * The size of the encoding axis of the blue gamma ramp
- */
- size_t blue_gamma_size;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int gamma_size_error;
-
-
- /**
- * The bit-depth of the value axes of gamma ramps,
- * -1 for single precision floating point, and -2 for
- * double precision floating point
- */
- signed gamma_depth;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int gamma_depth_error;
-
-
- /**
- * `LIBGAMMA_NO` indicates that the CRTC does not support
- * gamma ramp adjustments. `LIBGAMMA_MAYBE` indicates that
- * the CRTC may or may not support gamma ramp adjustments,
- * meaning that the display server really does not know, but
- * the protocol is available. `LIBGAMMA_NO` indicates that
- * the CRTC does support gamma ramp adjustments.
- */
- libgamma_decision_t gamma_support;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int gamma_support_error;
-
-
- /**
- * The layout of the subpixels
- *
- * You cannot count on this value — especially for CRT:s —
- * but it is provided anyway as a means of distinguishing
- * monitors
- */
- libgamma_subpixel_order_t subpixel_order;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int subpixel_order_error;
-
-
- /**
- * Whether there is a monitor connected to the CRTC
- */
- int active;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int active_error;
-
-
- /**
- * The name of the connector as designated by the display
- * server or as give by this library in case the display
- * server lacks this feature.
- */
- char *connector_name;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library.
- */
- int connector_name_error;
-
-
- /**
- * The type of the connector that is associated with the CRTC.
- */
- libgamma_connector_type_t connector_type;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library.
- */
- int connector_type_error;
-
-
- /**
- * The gamma characteristics of the monitor as reported
- * in its Extended Display Information Data. The value
- * holds the value for the red channel.
- *
- * If you do not have and more accurate measurement of the
- * gamma for the monitor this could be used to give a rought
- * gamma correction; simply divide the value with 2.2 and use
- * the result for the red channel in the gamma correction.
- */
- float gamma_red;
-
- /**
- * The gamma characteristics of the monitor as reported
- * in its Extended Display Information Data. The value
- * holds the value for the green channel.
- *
- * If you do not have and more accurate measurement of the
- * gamma for the monitor this could be used to give a rought
- * gamma correction; simply divide the value with 2.2 and use
- * the result for the green channel in the gamma correction.
- */
- float gamma_green;
-
- /**
- * The gamma characteristics of the monitor as reported
- * in its Extended Display Information Data. The value
- * holds the value for the blue channel.
- *
- * If you do not have and more accurate measurement of the
- * gamma for the monitor this could be used to give a rought
- * gamma correction; simply divide the value with 2.2 and use
- * the result for the blue channel in the gamma correction.
- */
- float gamma_blue;
-
- /**
- * Zero on success, positive it holds the value `errno` had
- * when the reading failed, otherwise (negative) the value
- * of an error identifier provided by this library
- */
- int gamma_error;
-
-} libgamma_crtc_information_t;
-
-
-
-/**
- * Gamma ramp structure for 8-bit gamma ramps
- */
-typedef struct libgamma_gamma_ramps8 {
- /**
- * The size of `red`
- */
- size_t red_size;
-
- /**
- * The size of `green`
- */
- size_t green_size;
-
- /**
- * The size of `blue`
- */
- size_t blue_size;
-
- /**
- * The gamma ramp for the red channel
- */
- uint8_t *red;
-
- /**
- * The gamma ramp for the green channel
- */
- uint8_t *green;
-
- /**
- * The gamma ramp for the blue channel
- */
- uint8_t *blue;
-
-} libgamma_gamma_ramps8_t;
-
-
-/**
- * Gamma ramp structure for 16-bit gamma ramps
- */
-typedef struct libgamma_gamma_ramps16
-{
- /**
- * The size of `red`
- */
- size_t red_size;
-
- /**
- * The size of `green`
- */
- size_t green_size;
-
- /**
- * The size of `blue`
- */
- size_t blue_size;
-
- /**
- * The gamma ramp for the red channel
- */
- uint16_t *red;
-
- /**
- * The gamma ramp for the green channel
- */
- uint16_t *green;
-
- /**
- * The gamma ramp for the blue channel
- */
- uint16_t *blue;
-
-} libgamma_gamma_ramps16_t;
-
-
-/**
- * Gamma ramp structure for 32-bit gamma ramps
- */
-typedef struct libgamma_gamma_ramps32
-{
- /**
- * The size of `red`
- */
- size_t red_size;
-
- /**
- * The size of `green`
- */
- size_t green_size;
-
- /**
- * The size of `blue`
- */
- size_t blue_size;
-
- /**
- * The gamma ramp for the red channel
- */
- uint32_t *red;
-
- /**
- * The gamma ramp for the green channel
- */
- uint32_t *green;
-
- /**
- * The gamma ramp for the blue channel
- */
- uint32_t *blue;
-
-} libgamma_gamma_ramps32_t;
-
-
-/**
- * Gamma ramp structure for 64-bit gamma ramps
- */
-typedef struct libgamma_gamma_ramps64
-{
- /**
- * The size of `red`
- */
- size_t red_size;
-
- /**
- * The size of `green`
- */
- size_t green_size;
-
- /**
- * The size of `blue`
- */
- size_t blue_size;
-
- /**
- * The gamma ramp for the red channel
- */
- uint64_t *red;
-
- /**
- * The gamma ramp for the green channel
- */
- uint64_t *green;
-
- /**
- * The gamma ramp for the blue channel
- */
- uint64_t *blue;
-
-} libgamma_gamma_ramps64_t;
-
-
-/**
- * Gamma ramp structure for `float` gamma ramps
- */
-typedef struct libgamma_gamma_rampsf
-{
- /**
- * The size of `red`
- */
- size_t red_size;
-
- /**
- * The size of `green`
- */
- size_t green_size;
-
- /**
- * The size of `blue`
- */
- size_t blue_size;
-
- /**
- * The gamma ramp for the red channel
- */
- float *red;
-
- /**
- * The gamma ramp for the green channel
- */
- float *green;
-
- /**
- * The gamma ramp for the blue channel
- */
- float *blue;
-
-} libgamma_gamma_rampsf_t;
-
-
-/**
- * Gamma ramp structure for `double` gamma ramps
- */
-typedef struct libgamma_gamma_rampsd
-{
- /**
- * The size of `red`
- */
- size_t red_size;
-
- /**
- * The size of `green`
- */
- size_t green_size;
-
- /**
- * The size of `blue`
- */
- size_t blue_size;
-
- /**
- * The gamma ramp for the red channel
- */
- double *red;
-
- /**
- * The gamma ramp for the green channel
- */
- double *green;
-
- /**
- * The gamma ramp for the blue channel
- */
- double *blue;
-
-} libgamma_gamma_rampsd_t;
-
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int libgamma_gamma_ramps8_initialise(libgamma_gamma_ramps8_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise
- * initialised in the proper manner
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_ramps8_destroy(libgamma_gamma_ramps8_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps8_initialise` or otherwise
- * initialised in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_ramps8_free(libgamma_gamma_ramps8_t *restrict);
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int libgamma_gamma_ramps16_initialise(libgamma_gamma_ramps16_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps16_initialise` or otherwise
- * initialised in the proper manner
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_ramps16_destroy(libgamma_gamma_ramps16_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps16_initialise` or otherwise
- * initialised in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_ramps16_free(libgamma_gamma_ramps16_t *restrict);
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated.
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int libgamma_gamma_ramps32_initialise(libgamma_gamma_ramps32_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps32_initialise` or otherwise
- * initialised in the proper manner
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_ramps32_destroy(libgamma_gamma_ramps32_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps32_initialise` or otherwise
- * initialised in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_ramps32_free(libgamma_gamma_ramps32_t *restrict);
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated.
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int libgamma_gamma_ramps64_initialise(libgamma_gamma_ramps64_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps64_initialise` or otherwise
- * initialised in the proper manner
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_ramps64_destroy(libgamma_gamma_ramps64_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_ramps64_initialise` or otherwise
- * initialised in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_ramps64_free(libgamma_gamma_ramps64_t *restrict);
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int libgamma_gamma_rampsf_initialise(libgamma_gamma_rampsf_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_rampsf_initialise` or otherwise
- * initialised in the proper manner
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_rampsf_destroy(libgamma_gamma_rampsf_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_rampsf_initialise` or otherwise
- * initialised in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_rampsf_free(libgamma_gamma_rampsf_t *restrict);
-
-
-/**
- * Initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation
- *
- * The input must have `red_size`, `green_size`, and `blue_size` set to the
- * sizes of the gamma ramps that should be allocated
- *
- * @param this The gamma ramps
- * @return Zero on success, -1 on allocation error, `errno` will be set accordingly
- */
-int libgamma_gamma_rampsd_initialise(libgamma_gamma_rampsd_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_rampsd_initialise` or otherwise
- * initialised in the proper manner
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_rampsd_destroy(libgamma_gamma_rampsd_t *restrict);
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by `libgamma_gamma_rampsd_initialise` or otherwise
- * initialised in the proper manner, as well as release the pointer
- * to the structure
- *
- * @param this The gamma ramps
- */
-void libgamma_gamma_rampsd_free(libgamma_gamma_rampsd_t *restrict);
-
-
-
-#ifndef __GNUC__
-# undef __attribute__
-#endif
-
-#endif
diff --git a/src/lib/libgamma.h b/src/lib/libgamma.h
deleted file mode 100644
index cc63fb8..0000000
--- a/src/lib/libgamma.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef LIBGAMMA_H
-#define LIBGAMMA_H
-
-#include "libgamma-config.h" /* Must be first. */
-
-#include "libgamma-method.h"
-#include "libgamma-facade.h"
-#include "libgamma-error.h"
-
-#endif