[PATCH] randr12: Add compatibility for XF86VidMode gamma ramps.

Michel Dänzer michel at daenzer.net
Sat Jul 18 11:10:07 PDT 2009


From: Michel Dänzer <daenzer at vmware.com>

Fixes screensaver fadeout effects.

Also make all RandR 1.2 compatibility code for XF86VidMode operate only on the
CRTC associated with the compatibility output, not all CRTCs at once.
---
 hw/xfree86/common/xf86cmap.c   |   38 ++++++++++++++++++++++++++++++++++++++
 hw/xfree86/modes/xf86RandR12.c |   19 +++++++------------
 2 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index 7e73bb8..7990c74 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -999,6 +999,18 @@ xf86ChangeGammaRamp(
     CMapScreenPtr pScreenPriv;
     CMapLinkPtr pLink;
 
+    if (xf86_crtc_supports_gamma(pScrn)) {
+	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+	RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
+
+	if (crtc->gammaSize != size)
+	    return BadValue;
+
+	RRCrtcGammaSet(crtc, red, green, blue);
+
+	return Success;
+    }
+
     if(CMapScreenKey == NULL)
         return BadImplementation;
 
@@ -1057,8 +1069,16 @@ xf86ChangeGammaRamp(
 int
 xf86GetGammaRampSize(ScreenPtr pScreen)
 {
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     CMapScreenPtr pScreenPriv;
 
+    if (xf86_crtc_supports_gamma(pScrn)) {
+	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+	RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
+
+	return crtc->gammaSize;
+    }
+
     if(CMapScreenKey == NULL) return 0;
 
     pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
@@ -1076,10 +1096,28 @@ xf86GetGammaRamp(
    unsigned short *green,
    unsigned short *blue
 ){
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     CMapScreenPtr pScreenPriv;
     LOCO *entry;
     int shift, sigbits;
 
+    if (xf86_crtc_supports_gamma(pScrn)) {
+	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+	RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
+
+	if (crtc->gammaSize < size)
+	    return BadValue;
+
+	if (!RRCrtcGammaGet(crtc))
+	    return BadImplementation;
+
+	memcpy(red, crtc->gammaRed, size * sizeof(*red));
+	memcpy(green, crtc->gammaGreen, size * sizeof(*green));
+	memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
+
+	return Success;
+    }
+
     if(CMapScreenKey == NULL) 
 	return BadImplementation;
 
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 0de21e2..c2465bc 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -1718,13 +1718,11 @@ gamma_to_ramp(float gamma, CARD16 *ramp, int size)
 static int
 xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma)
 {
-    int i, size = 0;
     CARD16 *points, *red, *green, *blue;
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-    rrScrPrivPtr rp = rrGetScrPriv(pScrn->pScreen);
-
-    for (i = 0; i < rp->numCrtcs; i++)
-	size = max(size, rp->crtcs[i]->gammaSize);
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+    RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
+    int size = max(0, crtc->gammaSize);
 
     if (!size)
 	return Success;
@@ -1737,13 +1735,10 @@ xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma)
     green = points + size;
     blue = points + 2 * size;
 
-    for (i = 0; i < rp->numCrtcs; i++) {
-	gamma_to_ramp(gamma.red, red, rp->crtcs[i]->gammaSize);
-	gamma_to_ramp(gamma.green, green, rp->crtcs[i]->gammaSize);
-	gamma_to_ramp(gamma.blue, blue, rp->crtcs[i]->gammaSize);
-	RRCrtcGammaSet(rp->crtcs[i], red, green, blue);
-	memset(points, 0, 3 * size * sizeof(CARD16));
-    }
+    gamma_to_ramp(gamma.red, red, size);
+    gamma_to_ramp(gamma.green, green, size);
+    gamma_to_ramp(gamma.blue, blue, size);
+    RRCrtcGammaSet(crtc, red, green, blue);
 
     xfree(points);
 
-- 
1.6.3.3



More information about the xorg-devel mailing list