summaryrefslogtreecommitdiff
path: root/hw/xfree86/common
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2015-11-28 16:50:47 +0900
committerMichel Dänzer <michel@daenzer.net>2016-07-28 10:12:05 +0900
commitb4e46c0444bb09f4af59d9d13acc939a0fbbc6d6 (patch)
tree1fab326dd553ca99d66e35e50f638d7a3e5557a8 /hw/xfree86/common
parent17213b74fd7fc4c4e2fe7a3781e7422dd482a0ab (diff)
xfree86: Hook up colormaps and RandR 1.2 gamma code v6
Instead of breaking the former when the driver supports the latter, hook them up so that the hardware LUTs reflect the combination of the current colourmap and gamma states. I.e. combine the colourmap, the global gamma value/ramp and the RandR 1.2 per-CRTC gamma ramps into one combined LUT per CRTC. Fixes e.g. gamma sliders not working in games. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=27222 v2: * Initialize palette_size and palette struct members, fixes crash on server startup. v3: * Free randrp->palette in xf86RandR12CloseScreen, fixes memory leak. v4: * Call CMapUnwrapScreen if xf86RandR12InitGamma fails (Emil Velikov). * Still allow xf86HandleColormaps to be called with a NULL loadPalette parameter in the xf86_crtc_supports_gamma case. v5: * Clean up inner loops in xf86RandR12CrtcComputeGamma (Keith Packard) * Move palette update out of per-CRTC loop in xf86RandR12LoadPalette (Keith Packard) v6: * Handle reallocarray failure in xf86RandR12LoadPalette (Keith Packard) Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'hw/xfree86/common')
-rw-r--r--hw/xfree86/common/xf86Helper.c7
-rw-r--r--hw/xfree86/common/xf86cmap.c60
2 files changed, 13 insertions, 54 deletions
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index bceb0174b..6f3a6086b 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -54,7 +54,6 @@
#include "xf86Xinput.h"
#include "xf86InPriv.h"
#include "mivalidate.h"
-#include "xf86Crtc.h"
/* For xf86GetClocks */
#if defined(CSRG_BASED) || defined(__GNU__)
@@ -908,11 +907,7 @@ xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma)
scrp->gamma.green = 1.0;
scrp->gamma.blue = 1.0;
}
- /* Pretend we succeeded if we support better a gamma system.
- * This avoids a confusing message.
- */
- if (xf86_crtc_supports_gamma(scrp))
- return TRUE;
+
xf86DrvMsg(scrp->scrnIndex, from,
"Using gamma correction (%.1f, %.1f, %.1f)\n",
scrp->gamma.red, scrp->gamma.green, scrp->gamma.blue);
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index ba0b277a1..8588c9fba 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -49,6 +49,7 @@
#include "xf86_OSproc.h"
#include "xf86str.h"
#include "micmap.h"
+#include "xf86RandR12.h"
#include "xf86Crtc.h"
#ifdef XFreeXDGA
@@ -132,9 +133,6 @@ static void CMapUnwrapScreen(ScreenPtr pScreen);
Bool
xf86ColormapAllocatePrivates(ScrnInfoPtr pScrn)
{
- /* If we support a better colormap system, then pretend we succeeded. */
- if (xf86_crtc_supports_gamma(pScrn))
- return TRUE;
if (!dixRegisterPrivateKey(&CMapScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
@@ -157,11 +155,8 @@ xf86HandleColormaps(ScreenPtr pScreen,
int *indices;
int elements;
- /* If we support a better colormap system, then pretend we succeeded. */
- if (xf86_crtc_supports_gamma(pScrn))
- return TRUE;
-
- if (!maxColors || !sigRGBbits || !loadPalette)
+ if (!maxColors || !sigRGBbits ||
+ (!loadPalette && !xf86_crtc_supports_gamma(pScrn)))
return FALSE;
elements = 1 << sigRGBbits;
@@ -230,6 +225,15 @@ xf86HandleColormaps(ScreenPtr pScreen,
return FALSE;
}
+ if (xf86_crtc_supports_gamma(pScrn)) {
+ pScrn->LoadPalette = xf86RandR12LoadPalette;
+
+ if (!xf86RandR12InitGamma(pScrn, elements)) {
+ CMapUnwrapScreen(pScreen);
+ return FALSE;
+ }
+ }
+
/* Force the initial map to be loaded */
SetInstalledmiColormap(pScreen, NULL);
CMapInstallColormap(pDefMap);
@@ -1005,19 +1009,6 @@ xf86ChangeGammaRamp(ScreenPtr pScreen,
CMapScreenPtr pScreenPriv;
CMapLinkPtr pLink;
- if (xf86_crtc_supports_gamma(pScrn)) {
- RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
-
- if (crtc) {
- if (crtc->gammaSize != size)
- return BadValue;
-
- RRCrtcGammaSet(crtc, red, green, blue);
-
- return Success;
- }
- }
-
if (!CMapScreenKeyRegistered)
return BadImplementation;
@@ -1077,16 +1068,8 @@ xf86ChangeGammaRamp(ScreenPtr pScreen,
int
xf86GetGammaRampSize(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
CMapScreenPtr pScreenPriv;
- if (xf86_crtc_supports_gamma(pScrn)) {
- RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
-
- if (crtc)
- return crtc->gammaSize;
- }
-
if (!CMapScreenKeyRegistered)
return 0;
@@ -1104,29 +1087,10 @@ xf86GetGammaRamp(ScreenPtr pScreen,
unsigned short *red,
unsigned short *green, unsigned short *blue)
{
- ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
CMapScreenPtr pScreenPriv;
LOCO *entry;
int shift, sigbits;
- if (xf86_crtc_supports_gamma(pScrn)) {
- RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
-
- if (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 (!CMapScreenKeyRegistered)
return BadImplementation;