diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/drm/atomic.c | 12 | ||||
-rw-r--r-- | backend/drm/drm.c | 6 |
2 files changed, 12 insertions, 6 deletions
diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index 61d2f6e1..40a272a1 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -199,14 +199,18 @@ static bool atomic_crtc_move_cursor(struct wlr_drm_backend *drm, static bool atomic_crtc_set_gamma(struct wlr_drm_backend *drm, struct wlr_drm_crtc *crtc, uint16_t *r, uint16_t *g, uint16_t *b, uint32_t size) { - struct drm_color_lut gamma[size]; - // Fallback to legacy gamma interface when gamma properties are not available // (can happen on older intel gpu's that support gamma but not degamma) if (crtc->props.gamma_lut == 0) { return legacy_iface.crtc_set_gamma(drm, crtc, r, g, b, size); } + struct drm_color_lut *gamma = malloc(size * sizeof(struct drm_color_lut)); + if (gamma == NULL) { + wlr_log(WLR_ERROR, "Failed to allocate gamma table"); + return false; + } + for (uint32_t i = 0; i < size; i++) { gamma[i].red = r[i]; gamma[i].green = g[i]; @@ -218,10 +222,12 @@ static bool atomic_crtc_set_gamma(struct wlr_drm_backend *drm, } if (drmModeCreatePropertyBlob(drm->fd, gamma, - sizeof(struct drm_color_lut) * size, &crtc->gamma_lut)) { + size * sizeof(struct drm_color_lut), &crtc->gamma_lut)) { + free(gamma); wlr_log_errno(WLR_ERROR, "Unable to create property blob"); return false; } + free(gamma); struct atomic atom; atomic_begin(crtc, &atom); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index c4674235..3e6659f1 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -228,19 +228,19 @@ static bool drm_connector_swap_buffers(struct wlr_output *output, return true; } -static void drm_connector_set_gamma(struct wlr_output *output, +static bool drm_connector_set_gamma(struct wlr_output *output, uint32_t size, uint16_t *r, uint16_t *g, uint16_t *b) { struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output; struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend; - bool ok; + bool ok = false; if (conn->crtc) { ok = drm->iface->crtc_set_gamma(drm, conn->crtc, r, g, b, size); if (ok) { wlr_output_update_needs_swap(output); } } - + return ok; } static uint32_t drm_connector_get_gamma_size(struct wlr_output *output) { |