From 7112a01f4a606c80bfef1b9d6ab0ccc87b634933 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 3 Jul 2013 22:44:46 +0100 Subject: [PATCH] sna: Always read back the gamma, even for a inactive CRTC Even if the CRTC is inactive, we still need to initialise the gamma tables. Reported-by: Timo Kamph Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66563 Signed-off-by: Chris Wilson --- src/sna/sna_display.c | 54 ++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index c124c22..d007472 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3001,32 +3001,7 @@ static bool sna_probe_initial_configuration(struct sna *sna) crtc->enabled = FALSE; crtc->desiredMode.status = MODE_NOMODE; - VG_CLEAR(mode); - mode.crtc_id = sna_crtc->id; - if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETCRTC, &mode)) - continue; - - if (!mode.mode_valid) - continue; - - memset(&crtc->desiredMode, 0, sizeof(crtc->desiredMode)); - mode_from_kmode(scrn, &mode.mode, &crtc->desiredMode); - crtc->desiredRotation = RR_Rotate_0; - crtc->desiredX = mode.x; - crtc->desiredY = mode.y; - crtc->desiredTransformPresent = FALSE; - - crtc->mode = crtc->desiredMode; - crtc->mode.name = NULL; - crtc->x = mode.x; - crtc->y = mode.y; - crtc->rotation = RR_Rotate_0; - crtc->transformPresent = FALSE; - - memset(&crtc->panningTotalArea, 0, sizeof(BoxRec)); - memset(&crtc->panningTrackingArea, 0, sizeof(BoxRec)); - memset(crtc->panningBorder, 0, 4 * sizeof(INT16)); - + /* Initialize the gamma ramps */ gamma = malloc(3 * mode.gamma_size * sizeof(uint16_t)); if (gamma) { struct drm_mode_crtc_lut lut; @@ -3058,6 +3033,33 @@ static bool sna_probe_initial_configuration(struct sna *sna) crtc->gamma_green = gamma + mode.gamma_size; crtc->gamma_blue = gamma + 2*mode.gamma_size; } + + /* Retrieve the current mode */ + VG_CLEAR(mode); + mode.crtc_id = sna_crtc->id; + if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETCRTC, &mode)) + continue; + + if (!mode.mode_valid) + continue; + + memset(&crtc->desiredMode, 0, sizeof(crtc->desiredMode)); + mode_from_kmode(scrn, &mode.mode, &crtc->desiredMode); + crtc->desiredRotation = RR_Rotate_0; + crtc->desiredX = mode.x; + crtc->desiredY = mode.y; + crtc->desiredTransformPresent = FALSE; + + crtc->mode = crtc->desiredMode; + crtc->mode.name = NULL; + crtc->x = mode.x; + crtc->y = mode.y; + crtc->rotation = RR_Rotate_0; + crtc->transformPresent = FALSE; + + memset(&crtc->panningTotalArea, 0, sizeof(BoxRec)); + memset(&crtc->panningTrackingArea, 0, sizeof(BoxRec)); + memset(crtc->panningBorder, 0, 4 * sizeof(INT16)); } /* Reconstruct outputs pointing to active CRTC */ -- 1.8.3.2