diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-06-26 17:01:37 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-06-26 17:01:37 +0100 |
commit | d7be3df2fe632bbc8e4f09709cf3cf7a5ef61015 (patch) | |
tree | 342b47f3a4112a7ffeba4972b0794ed99b2a538e /src | |
parent | 491f4fab21df97af1dae92eaf30e76ff62920fb2 (diff) |
sna: Se the default gamma if left uninitialized by the driver
Due to a bug in i915.ko the gamma ramp is left uninitialised...
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna_display.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index ed9f4481..aafde157 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3016,6 +3016,7 @@ static bool sna_probe_initial_configuration(struct sna *sna) gamma = malloc(3 * mode.gamma_size * sizeof(uint16_t)); if (gamma) { struct drm_mode_crtc_lut lut; + bool gamma_set = false; lut.crtc_id = mode.crtc_id; lut.gamma_size = mode.gamma_size; @@ -3023,12 +3024,25 @@ static bool sna_probe_initial_configuration(struct sna *sna) lut.green = (uintptr_t)(gamma + mode.gamma_size); lut.blue = (uintptr_t)(gamma + 2 * mode.gamma_size); if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETGAMMA, &lut) == 0) { - free(crtc->gamma_red); - crtc->gamma_size = mode.gamma_size; - crtc->gamma_red = gamma; - crtc->gamma_green = gamma + mode.gamma_size; - crtc->gamma_blue = gamma + 2*mode.gamma_size; + gamma_set = + gamma[mode.gamma_size - 1] && + gamma[2*mode.gamma_size - 1] && + gamma[3*mode.gamma_size - 1]; } + + if (!gamma_set) { + for (j = 0; j < mode.gamma_size; j++) { + gamma[j] = j << 8; + gamma[mode.gamma_size + j] = j << 8; + gamma[2* mode.gamma_size + j] = j << 8; + } + } + + free(crtc->gamma_red); + crtc->gamma_size = mode.gamma_size; + crtc->gamma_red = gamma; + crtc->gamma_green = gamma + mode.gamma_size; + crtc->gamma_blue = gamma + 2*mode.gamma_size; } } |