From ecbcf327f02b1284163e68fc176ad45ff64e355d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 12 Mar 2014 08:46:33 +0100 Subject: add blueshift_drm_set_gamma_ramps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blueshift_drm_c.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/blueshift_drm_c.c') diff --git a/src/blueshift_drm_c.c b/src/blueshift_drm_c.c index 4e8c750..fd11be1 100644 --- a/src/blueshift_drm_c.c +++ b/src/blueshift_drm_c.c @@ -274,7 +274,7 @@ const char* blueshift_drm_get_connector_type_name() /** - * Get the current gamma ramps of the + * Get the current gamma ramps of the monitor connected to the connector * * @param crtc_index The index of the CRTC to read from * @param gamma_size The size a gamma ramp @@ -295,6 +295,24 @@ int blueshift_drm_get_gamma_ramps(int crtc_index, int gamma_size, uint16_t* red, } +/* Fails if inside a graphical environment */ + +/** + * Set the gamma ramps of the of the monitor connected to the connector + * + * @param crtc_index The index of the CRTC to read from + * @param gamma_size The size a gamma ramp + * @param red The red gamma ramp + * @param green The green gamma ramp + * @param blue The blue gamma ramp + * @return Zero on success + */ +int blueshift_drm_set_gamma_ramps(int crtc_index, int gamma_size, uint16_t* red, uint16_t* green, uint16_t* blue) +{ + return drmModeCrtcSetGamma(drm_fd, *(drm_res->crtcs + crtc_index), gamma_size, red, green, blue); +} + + /** * Get the extended display identification data for the monitor connected to the connector * @@ -430,8 +448,7 @@ int main(int argc, char** argv) for (j = 0; j < gamma_size; j++) *(blue + j) /= 2; - drmModeCrtcSetGamma(drm_fd, *(drm_res->crtcs + crtc), gamma_size, red, green, blue); - /* Fails if inside a graphical environment */ + blueshift_drm_set_gamma_ramps(crtc, gamma_size, red, green, blue); } } } -- cgit v1.2.3-70-g09d2