diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gamma-linux-drm.c | 39 | ||||
| -rw-r--r-- | src/libgamma-error.h | 5 | 
2 files changed, 41 insertions, 3 deletions
| diff --git a/src/gamma-linux-drm.c b/src/gamma-linux-drm.c index e5e3482..57127bf 100644 --- a/src/gamma-linux-drm.c +++ b/src/gamma-linux-drm.c @@ -400,9 +400,7 @@ int libgamma_linux_drm_crtc_get_gamma_ramps(libgamma_crtc_state_t* restrict this  #endif    r = drmModeCrtcGetGamma(card->fd, (uint32_t)(this->crtc), (uint32_t)(ramps->red_size),  			  ramps->red, ramps->green, ramps->blue); -  if (r < 0) -    return LIBGAMMA_GAMMA_RAMP_READ_FAILED; -  return 0; +  return r ? LIBGAMMA_GAMMA_RAMP_READ_FAILED : 0;  } @@ -417,5 +415,40 @@ int libgamma_linux_drm_crtc_get_gamma_ramps(libgamma_crtc_state_t* restrict this  int libgamma_linux_drm_crtc_set_gamma_ramps(libgamma_crtc_state_t* restrict this,  					    libgamma_gamma_ramps_t ramps)  { +  libgamma_drm_card_data_t* card = this->partition->data; +  int r; +#ifdef DEBUG +  if ((ramps.red_size != ramps.green_size) || +      (ramps.red_size != ramps.blue_size)) +    return LIBGAMMA_MIXED_GAMMA_RAMP_SIZE; +#endif +  r = drmModeCrtcSetGamma(card->fd, (uint32_t)(size_t)(this->data), +			  (uint32_t)(ramps.red_size), ramps.red, ramps.green, ramps.blue); +  if (r) +    switch (errno) +      { +      case EACCES: +      case EAGAIN: +      case EIO: +	/* Permission denied errors must be ignored, because we do not +	 * have permission to do this while a display server is active. +	 * We are also checking for some other error codes just in case. */ +      case EBUSY: +      case EINPROGRESS: +	/* It is hard to find documentation for DRM (in fact all of this is +	 * just based on the functions names and some testing,) perhaps we +	 * could get this if we are updating to fast. */ +	break; +      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. */ +	return LIBGAMMA_GRAPHICS_CARD_REMOVED; + +      default: +	return LIBGAMMA_ERRNO_SET; +      } +  return 0;  } diff --git a/src/libgamma-error.h b/src/libgamma-error.h index 5223207..be1e5d9 100644 --- a/src/libgamma-error.h +++ b/src/libgamma-error.h @@ -154,6 +154,11 @@ extern const char* libgamma_group_name;   */  #define LIBGAMMA_DEVICE_REQUIRE_GROUP  (-22) +/** + * The graphics card appear to have been removed + */ +#define LIBGAMMA_GRAPHICS_CARD_REMOVED  (-23) +  #endif | 
