summaryrefslogtreecommitdiff
path: root/hw/xfree86
diff options
context:
space:
mode:
authorMichel Dänzer <daenzer@vmware.com>2009-07-21 14:34:47 +0200
committerMichel Dänzer <daenzer@vmware.com>2009-07-21 14:34:47 +0200
commit9dc8106ba095474fea1474622b0f0162c8fd5aa4 (patch)
treed8ffbbcdea01f41b5d22c657038a54e195a78279 /hw/xfree86
parent268e227ba06c027f5c56b1aaee5dcc6a2034403f (diff)
randr12: Add compatibility for XF86VidMode gamma ramps.
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.
Diffstat (limited to 'hw/xfree86')
-rw-r--r--hw/xfree86/common/xf86cmap.c38
-rw-r--r--hw/xfree86/modes/xf86RandR12.c19
2 files changed, 45 insertions, 12 deletions
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index 7e73bb85c..7990c74e2 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 0de21e253..c2465bce3 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);