summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2007-05-21 14:01:07 +1000
committerBen Skeggs <skeggsb@gmail.com>2007-05-21 14:01:07 +1000
commitbf52c3439c3b48c38fe158cf3244347c2f00babc (patch)
tree6ff8e5036741baab0b0d6b23fb2e3e7e08c69d45
parent1dbe39c8b37249b1747a31aaa315c08ef7a48766 (diff)
downloadxorg-driver-xf86-video-nouveau-bf52c3439c3b48c38fe158cf3244347c2f00babc.tar.gz
NV50: Hook up CLUT, broken - LoadPalette never gets called...
-rw-r--r--src/nv50_display.c2
-rw-r--r--src/nv_driver.c69
-rw-r--r--src/nv_type.h1
3 files changed, 68 insertions, 4 deletions
diff --git a/src/nv50_display.c b/src/nv50_display.c
index 2d38bcc..3864836 100644
--- a/src/nv50_display.c
+++ b/src/nv50_display.c
@@ -414,7 +414,7 @@ NV50CrtcBlankScreen(xf86CrtcPtr crtc, Bool blank)
if(pPriv->cursorVisible)
NV50CrtcShowHideCursor(crtc, TRUE, FALSE);
C(0x00000840 + headOff, pScrn->depth == 8 ? 0x80000000 : 0xc0000000);
- C(0x00000844 + headOff, (pNv->RamAmountKBytes * 1024 - 0x5000) >> 8);
+ C(0x00000844 + headOff, (pNv->CLUT->offset - pNv->VRAMPhysical) >> 8);
if(pNv->_Chipset != 0x50)
C(0x0000085C + headOff, 1);
C(0x00000874 + headOff, 1);
diff --git a/src/nv_driver.c b/src/nv_driver.c
index 7b234ce..79abec2 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -1887,6 +1887,15 @@ NVMapMem(ScrnInfoPtr pScrn)
pNv->Cursor->size >> 10
);
+ if (pNv->Architecture == NV_ARCH_50) {
+ pNv->CLUT = NVAllocateMemory(pNv, NOUVEAU_MEM_FB, 0x1000);
+ if (!pNv->CLUT) {
+ ErrorF("Failed to allocate memory for CLUT\n");
+ return FALSE;
+ }
+ } else
+ pNv->CLUT = NULL;
+
pNv->ScratchBuffer = NVAllocateMemory(pNv, NOUVEAU_MEM_FB,
pNv->Architecture <NV_ARCH_10 ? 8192 : 16384);
if (!pNv->ScratchBuffer) {
@@ -2011,6 +2020,48 @@ NVLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
}
}
+//#define DEPTH_SHIFT(val, w) ((val << (8 - w)) | (val >> ((w << 1) - 8)))
+#define COLOR(c) (unsigned int)(0x3fff * ((c)/255.0))
+static void
+NV50LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
+ VisualPtr pVisual)
+{
+ NVPtr pNv = NVPTR(pScrn);
+ int i, index;
+ volatile struct {
+ unsigned short red, green, blue, unused;
+ } *lut = (void*)pNv->CLUT->map;
+
+ switch(pScrn->depth) {
+ case 15:
+ for(i = 0; i < numColors; i++) {
+ index = indices[i];
+ lut[DEPTH_SHIFT(index, 5)].red = COLOR(colors[index].red);
+ lut[DEPTH_SHIFT(index, 5)].green = COLOR(colors[index].green);
+ lut[DEPTH_SHIFT(index, 5)].blue = COLOR(colors[index].blue);
+ }
+ break;
+ case 16:
+ for(i = 0; i < numColors; i++) {
+ index = indices[i];
+ lut[DEPTH_SHIFT(index, 6)].green = COLOR(colors[index].green);
+ if(index < 32) {
+ lut[DEPTH_SHIFT(index, 5)].red = COLOR(colors[index].red);
+ lut[DEPTH_SHIFT(index, 5)].blue = COLOR(colors[index].blue);
+ }
+ }
+ break;
+ default:
+ for(i = 0; i < numColors; i++) {
+ index = indices[i];
+ lut[index].red = COLOR(colors[index].red);
+ lut[index].green = COLOR(colors[index].green);
+ lut[index].blue = COLOR(colors[index].blue);
+ }
+ break;
+ }
+}
+
/* Mandatory */
/* This gets called at the start of each server generation */
@@ -2218,9 +2269,18 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Initialize colormap layer.
Must follow initialization of the default colormap */
- if(!xf86HandleColormaps(pScreen, 256, 8, NVLoadPalette,
- NULL, CMAP_RELOAD_ON_MODE_SWITCH | CMAP_PALETTED_TRUECOLOR))
- return FALSE;
+ if (pNv->Architecture < NV_ARCH_50) {
+ if(!xf86HandleColormaps(pScreen, 256, 8, NVLoadPalette,
+ NULL,
+ CMAP_RELOAD_ON_MODE_SWITCH |
+ CMAP_PALETTED_TRUECOLOR))
+ return FALSE;
+ } else {
+ if(!xf86HandleColormaps(pScreen, 256, 8, NV50LoadPalette,
+ NULL,
+ CMAP_PALETTED_TRUECOLOR))
+ return FALSE;
+ }
xf86DPMSInit(pScreen, xf86DPMSSet, 0);
@@ -2260,6 +2320,9 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if(pNv->Rotate == 0 && !pNv->RandRRotation)
NVInitVideo(pScreen);
+ if (pNv->Architecture == NV_ARCH_50 && !NV50AcquireDisplay(pScrn))
+ return FALSE;
+
pScreen->SaveScreen = NVSaveScreen;
/* Wrap the current CloseScreen function */
diff --git a/src/nv_type.h b/src/nv_type.h
index 046d2eb..fe2f7f5 100644
--- a/src/nv_type.h
+++ b/src/nv_type.h
@@ -198,6 +198,7 @@ typedef struct _NVRec {
NVAllocRec * FB;
NVAllocRec * Cursor;
+ NVAllocRec * CLUT; /* NV50 only */
NVAllocRec * ScratchBuffer;
NVAllocRec * AGPScratch;