aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-05-03 12:41:55 +0200
committerMattias Andrée <maandree@operamail.com>2015-05-03 12:47:45 +0200
commitd986e60545283b01d53367fb25d4a21e1a5c061a (patch)
tree8245986c1ac9576bb4c81211e3daeb53ba943cc3 /src
parentbeginning of wayland support (diff)
downloadlibgamma-d986e60545283b01d53367fb25d4a21e1a5c061a.tar.gz
libgamma-d986e60545283b01d53367fb25d4a21e1a5c061a.tar.bz2
libgamma-d986e60545283b01d53367fb25d4a21e1a5c061a.tar.xz
wayland: set and get gamma
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/lib/gamma-wayland.c35
-rw-r--r--src/lib/gamma-wayland.h2
2 files changed, 34 insertions, 3 deletions
diff --git a/src/lib/gamma-wayland.c b/src/lib/gamma-wayland.c
index be41c7a..e3e68e7 100644
--- a/src/lib/gamma-wayland.c
+++ b/src/lib/gamma-wayland.c
@@ -582,7 +582,9 @@ int libgamma_wayland_get_crtc_information(libgamma_crtc_information_t* restrict
int libgamma_wayland_crtc_get_gamma_ramps16(libgamma_crtc_state_t* restrict this,
libgamma_gamma_ramps16_t* restrict ramps)
{
- return 0; (void) this, (void) ramps; /* TODO */
+ (void) this;
+ (void) ramps;
+ return errno = ENOTSUP, LIBGAMMA_ERRNO_SET;
}
@@ -597,6 +599,35 @@ int libgamma_wayland_crtc_get_gamma_ramps16(libgamma_crtc_state_t* restrict this
int libgamma_wayland_crtc_set_gamma_ramps16(libgamma_crtc_state_t* restrict this,
libgamma_gamma_ramps16_t ramps)
{
- return 0; (void) this, (void) ramps; /* TODO */
+ libgamma_wayland_site_data_t* site = this->partition->site->data;
+ libgamma_wayland_crtc_data_t* crtc = this->data;
+ struct wl_array red;
+ struct wl_array green;
+ struct wl_array blue;
+
+ /* TODO Verify that gamma can be set. */
+
+#ifdef DEBUG
+ /* Gamma ramp sizes are identical but not fixed. */
+ if ((ramps.red_size != ramps.green_size) ||
+ (ramps.red_size != ramps.blue_size))
+ return LIBGAMMA_MIXED_GAMMA_RAMP_SIZE;
+#endif
+
+ /* Translate gamma ramps to Wayland structure. */
+ red .size = red .alloc = ramps. red_size * sizeof(uint16_t);
+ green.size = green.alloc = ramps.green_size * sizeof(uint16_t);
+ blue .size = blue .alloc = ramps. blue_size * sizeof(uint16_t);
+ red .data = ramps.red;
+ green.data = ramps.green;
+ blue .data = ramps.blue;
+
+ /* Apply gamma ramps. */
+ gamma_control_set_gamma(crtc->gamma_control, &red, &green, &blue);
+ wl_display_flush(site->display);
+
+ /* TODO Check for errors. */
+
+ return 0;
}
diff --git a/src/lib/gamma-wayland.h b/src/lib/gamma-wayland.h
index b8435b1..3ae6ade 100644
--- a/src/lib/gamma-wayland.h
+++ b/src/lib/gamma-wayland.h
@@ -145,7 +145,7 @@ int libgamma_wayland_get_crtc_information(libgamma_crtc_information_t* restrict
* error identifier provided by this library.
*/
int libgamma_wayland_crtc_get_gamma_ramps16(libgamma_crtc_state_t* restrict this,
- libgamma_gamma_ramps16_t* restrict ramps);
+ libgamma_gamma_ramps16_t* restrict ramps) __attribute__((const));
/**
* Set the gamma ramps for a CRTC, 16-bit gamma-depth version.