From d986e60545283b01d53367fb25d4a21e1a5c061a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 3 May 2015 12:41:55 +0200 Subject: wayland: set and get gamma MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/lib/gamma-wayland.c | 35 +++++++++++++++++++++++++++++++++-- src/lib/gamma-wayland.h | 2 +- 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. -- cgit v1.2.3-70-g09d2