aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/common/xf86cmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/common/xf86cmap.c')
-rw-r--r--xorg-server/hw/xfree86/common/xf86cmap.c75
1 files changed, 63 insertions, 12 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86cmap.c b/xorg-server/hw/xfree86/common/xf86cmap.c
index e57844764..36e6f96de 100644
--- a/xorg-server/hw/xfree86/common/xf86cmap.c
+++ b/xorg-server/hw/xfree86/common/xf86cmap.c
@@ -49,10 +49,10 @@
#include "xf86_OSproc.h"
#include "xf86str.h"
#include "micmap.h"
+#include "xf86Crtc.h"
#ifdef XFreeXDGA
-#define _XF86DGA_SERVER_
-#include <X11/extensions/xf86dgastr.h>
+#include <X11/extensions/xf86dgaproto.h>
#include "dgaproc.h"
#endif
@@ -84,6 +84,7 @@ typedef struct {
Bool (*EnterVT)(int, int);
Bool (*SwitchMode)(int, DisplayModePtr, int);
int (*SetDGAMode)(int, int, DGADevicePtr);
+ xf86ChangeGammaProc *ChangeGamma;
int maxColors;
int sigRGBbits;
int gammaElements;
@@ -126,7 +127,7 @@ static void CMapUnwrapScreen(ScreenPtr pScreen);
-_X_EXPORT Bool xf86HandleColormaps(
+Bool xf86HandleColormaps(
ScreenPtr pScreen,
int maxColors,
int sigRGBbits,
@@ -141,6 +142,10 @@ _X_EXPORT Bool xf86HandleColormaps(
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)
return FALSE;
@@ -190,6 +195,7 @@ _X_EXPORT Bool xf86HandleColormaps(
pScreenPriv->EnterVT = pScrn->EnterVT;
pScreenPriv->SwitchMode = pScrn->SwitchMode;
pScreenPriv->SetDGAMode = pScrn->SetDGAMode;
+ pScreenPriv->ChangeGamma = pScrn->ChangeGamma;
if (!(flags & CMAP_LOAD_EVEN_IF_OFFSCREEN)) {
pScrn->EnterVT = CMapEnterVT;
@@ -204,8 +210,8 @@ _X_EXPORT Bool xf86HandleColormaps(
ComputeGamma(pScreenPriv);
/* get the default map */
-
- pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP);
+ dixLookupResourceByType((pointer *)&pDefMap, pScreen->defColormap,
+ RT_COLORMAP, serverClient, DixInstallAccess);
if(!CMapAllocateColormapPrivate(pDefMap)) {
CMapUnwrapScreen(pScreen);
@@ -557,8 +563,8 @@ CMapRefreshColors(ColormapPtr pmap, int defs, int* indices)
switch(pVisual->class) {
case StaticGray:
- for(i = 0; i <= numColors - 1; i++) {
- index = i * maxValue / numColors;
+ for(i = 0; i < numColors; i++) {
+ index = (i+1) * maxValue / numColors;
colors[i].red = gamma[index].red;
colors[i].green = gamma[index].green;
colors[i].blue = gamma[index].blue;
@@ -819,6 +825,7 @@ CMapUnwrapScreen(ScreenPtr pScreen)
pScrn->EnterVT = pScreenPriv->EnterVT;
pScrn->SwitchMode = pScreenPriv->SwitchMode;
pScrn->SetDGAMode = pScreenPriv->SetDGAMode;
+ pScrn->ChangeGamma = pScreenPriv->ChangeGamma;
xfree(pScreenPriv->gamma);
xfree(pScreenPriv->PreAllocIndices);
@@ -884,6 +891,7 @@ CMapChangeGamma(
int index,
Gamma gamma
){
+ int ret = Success;
ScrnInfoPtr pScrn = xf86Screens[index];
ScreenPtr pScreen = pScrn->pScreen;
CMapColormapPtr pColPriv;
@@ -949,7 +957,12 @@ CMapChangeGamma(
CMapReinstallMap(pMap);
}
- return Success;
+ pScrn->ChangeGamma = pScreenPriv->ChangeGamma;
+ if (pScrn->ChangeGamma)
+ ret = pScrn->ChangeGamma(index, gamma);
+ pScrn->ChangeGamma = CMapChangeGamma;
+
+ return ret;
}
@@ -972,7 +985,7 @@ ComputeGammaRamp (
}
}
-_X_EXPORT int
+int
xf86ChangeGammaRamp(
ScreenPtr pScreen,
int size,
@@ -985,6 +998,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;
@@ -1040,11 +1065,19 @@ xf86ChangeGammaRamp(
return Success;
}
-_X_EXPORT int
+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,
@@ -1054,7 +1087,7 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
return pScreenPriv->gammaElements;
}
-_X_EXPORT int
+int
xf86GetGammaRamp(
ScreenPtr pScreen,
int size,
@@ -1062,10 +1095,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;
@@ -1108,5 +1159,5 @@ xf86ChangeGamma(
if(pScrn->ChangeGamma)
return (*pScrn->ChangeGamma)(pScreen->myNum, gamma);
- return Success; /* Success? */
+ return BadImplementation;
}