diff options
author | Luc Verhaegen <libv@skynet.be> | 2006-01-14 00:18:29 +0000 |
---|---|---|
committer | Luc Verhaegen <libv@skynet.be> | 2006-01-14 00:18:29 +0000 |
commit | 122aeaa83251440aad26f13fb52a67d9eab5711f (patch) | |
tree | c0734eddae745d3f8b32e01251765911b1678257 | |
parent | d06e08595f001d2ded3121aa7912a06df0494286 (diff) |
[devel-fix_16bpp_gamma]
- Even in 16bpp, the VIA hw requires a full lut. X doesn't deliver this, it
instead delivers 565bit values, causing the actual gamma to be way off.
Code is a quick and ugly hack, but does work.
- Remove CrtGamma option as this was the same issue. It is terrible how i
managed to miss 16bpp twice before.
- Fix 8bpp too, this is palette, not gamma.
-rw-r--r-- | src/via_driver.c | 88 | ||||
-rw-r--r-- | src/via_driver.h | 1 | ||||
-rw-r--r-- | src/via_mode.c | 13 |
3 files changed, 66 insertions, 36 deletions
diff --git a/src/via_driver.c b/src/via_driver.c index f8d1e2f..8e21090 100644 --- a/src/via_driver.c +++ b/src/via_driver.c @@ -134,7 +134,6 @@ typedef enum { OPTION_VIDEORAM, OPTION_FORCEMEMCLOCK, OPTION_ACTIVEDEVICE, - OPTION_CRTGAMMA, OPTION_DISABLEVQ, OPTION_DRIXINERAMA, OPTION_DISABLEIRQ, @@ -161,7 +160,6 @@ static OptionInfoRec VIAOptions[] = {OPTION_VIDEORAM, "VideoRAM", OPTV_INTEGER, {0}, FALSE}, {OPTION_FORCEMEMCLOCK, "ForceMemClock", OPTV_INTEGER, {0}, FALSE}, {OPTION_ACTIVEDEVICE, "ActiveDevice", OPTV_ANYSTR, {0}, FALSE}, - {OPTION_CRTGAMMA, "CRTGamma", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_DISABLEVQ, "DisableVQ", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_DRIXINERAMA, "DRIXINERAMA", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_DISABLEIRQ, "DisableIRQ", OPTV_BOOLEAN, {0}, FALSE}, @@ -369,7 +367,6 @@ VIAGetRec(ScrnInfoPtr pScrn) pVia->CursorImage = NULL; return TRUE; - } @@ -1146,14 +1143,6 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags) pVia->ActiveDevice |= VIA_DEVICE_TV; } - if (xf86ReturnOptValBool(VIAOptions, OPTION_CRTGAMMA, TRUE)) - pVia->CRTGamma = TRUE; - else { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: Disabling gamma" - "correction for the CRT.\n"); - pVia->CRTGamma = FALSE; - } - pVia->PciInfo = xf86GetPciInfoForEntity(pEnt->index); xf86RegisterResources(pEnt->index, NULL, ResNone); /* @@ -1870,36 +1859,64 @@ VIAUnmapMem(ScrnInfoPtr pScrn) } /* - * Doesn't do secondary/merged currently + * Doesn't do secondary/merged currently. + * CRT bit is wrong for unichrome pros too. */ static void ViaPaletteLoad(ScrnInfoPtr pScrn, int numColors, int *indices, - LOCO *colors, VisualPtr pVisual) + LOCO *colors, VisualPtr pVisual) { vgaHWPtr hwp = VGAHWPTR(pScrn); - int i, index; + int i, j, index; VIAFUNC(pScrn->scrnIndex); hwp->enablePalette(hwp); hwp->writeDacMask(hwp, 0xFF); - /* install colormap */ - for (i = 0; i < numColors; i++) { - index = indices[i]; - hwp->writeDacWriteAddr(hwp, index); - hwp->writeDacData(hwp, colors[index].red); - hwp->writeDacData(hwp, colors[index].green); - hwp->writeDacData(hwp, colors[index].blue); + /* We need the same palette contents for 16 as 24bit, but X doesn't + * play. X cmap handling is hopelessly intertwined with just about any X + * subsystem you can care to name. So we just space out RGB values over the + * 256*3 lut. This is quite unlike me, but even i draw a line somewhere. + * Digging out the DIX is somewhere. */ + switch (pScrn->bitsPerPixel) { + case 16: + for (i = 0; i < numColors; i++) { + index = indices[i]; + hwp->writeDacWriteAddr(hwp, index * 4); + + for (j = 0; j < 4; j++) { + hwp->writeDacData(hwp, colors[index/2].red); + hwp->writeDacData(hwp, colors[index].green); + hwp->writeDacData(hwp, colors[index/2].blue); + } + } + break; + case 8: + case 24: + case 32: + for (i = 0; i < numColors; i++) { + index = indices[i]; + hwp->writeDacWriteAddr(hwp, index); + + hwp->writeDacData(hwp, colors[index].red); + hwp->writeDacData(hwp, colors[index].green); + hwp->writeDacData(hwp, colors[index].blue); + } + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: Unsupported bitdepth: %d\n", + __func__, pScrn->bitsPerPixel); + break; } hwp->disablePalette(hwp); /* enable CLT glammal collection */ - if (VIAPTR(pScrn)->CRTGamma) - ViaSeqMask(hwp, 0x16, 0x80, 0x80); + if (pScrn->bitsPerPixel == 8) + ViaSeqMask(hwp, 0x16, 0x00, 0x80); /* 8bit is palette, not gamma */ else - ViaSeqMask(hwp, 0x16, 0x00, 0x80); + ViaSeqMask(hwp, 0x16, 0x80, 0x80); } /* @@ -1909,7 +1926,23 @@ static void ViaOverScan(ScrnInfoPtr pScrn, int overscan) { vgaHWPtr hwp = VGAHWPTR(pScrn); - hwp->writeAttr(hwp, 0x11, overscan); + + VIAFUNC(pScrn->scrnIndex); + + switch (pScrn->bitsPerPixel) { + case 16: + hwp->writeAttr(hwp, 0x11, overscan * 4); + break; + case 8: + case 24: + case 32: + hwp->writeAttr(hwp, 0x11, overscan); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: Unsupported bitdepth: %d\n", + __func__, pScrn->bitsPerPixel); + break; + } } /* @@ -2050,15 +2083,12 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (!miCreateDefColormap(pScreen)) return FALSE; - ViaDebug(scrnIndex, "- Def Color map set up\n"); if (!xf86HandleColormaps(pScreen, 256, 8, ViaPaletteLoad, ViaOverScan, CMAP_RELOAD_ON_MODE_SWITCH | CMAP_PALETTED_TRUECOLOR)) return FALSE; - ViaDebug(scrnIndex, "- Palette loaded\n"); - vgaHWBlankScreen(pScrn, TRUE); pVia->CloseScreen = pScreen->CloseScreen; @@ -2096,7 +2126,7 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (pVia->PrintTVRegs) ViaOutputsPrintRegs(pScrn, __func__); - + ViaDebug(scrnIndex, "- Done\n"); return TRUE; } diff --git a/src/via_driver.h b/src/via_driver.h index 9bc5aa3..d89cdb3 100644 --- a/src/via_driver.h +++ b/src/via_driver.h @@ -185,7 +185,6 @@ typedef struct _VIA { Bool NoAccel; Bool shadowFB; int rotate; - Bool CRTGamma; CloseScreenProcPtr CloseScreen; pciVideoPtr PciInfo; diff --git a/src/via_mode.c b/src/via_mode.c index 1d3870e..473f7bd 100644 --- a/src/via_mode.c +++ b/src/via_mode.c @@ -1117,20 +1117,21 @@ ViaModePrimaryVGA(ScrnInfoPtr pScrn, DisplayModePtr mode) hwp->writeSeq(hwp, 0x02, 0x0F); hwp->writeSeq(hwp, 0x03, 0x00); hwp->writeSeq(hwp, 0x04, 0x0E); - - ViaSeqMask(hwp, 0x15, 0x02, 0x02); - /* bpp */ + /* 8bit lut / 80 text columns / wrap-around / extended mode */ + ViaSeqMask(hwp, 0x15, 0xA2, 0xE2); + + /* 555/565 -- bpp */ switch (pScrn->bitsPerPixel) { case 8: - ViaSeqMask(hwp, 0x15, 0x20, 0xFC); + ViaSeqMask(hwp, 0x15, 0x00, 0x1C); break; case 16: - ViaSeqMask(hwp, 0x15, 0xB4, 0xFC); + ViaSeqMask(hwp, 0x15, 0x14, 0x1C); break; case 24: case 32: - ViaSeqMask(hwp, 0x15, 0xAC, 0xFC); + ViaSeqMask(hwp, 0x15, 0x0C, 0x1C); break; default: xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unhandled bitdepth: %d\n", |