diff options
Diffstat (limited to 'xc')
10 files changed, 166 insertions, 145 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile index 7ec7f391b..1593a7166 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile @@ -18,10 +18,10 @@ DRIDEFINES = $(GLX_DEFINES) #endif SRCS = tdfx_driver.c tdfx_io.c tdfx_hwcurs.c tdfx_accel.c \ - tdfx_dga.c tdfx_priv.c tdfx_sli.c $(DRISRCS) + tdfx_dga.c tdfx_priv.c tdfx_sli.c tdfx_video.c $(DRISRCS) OBJS = tdfx_driver.o tdfx_io.o tdfx_hwcurs.o tdfx_accel.o \ - tdfx_dga.o tdfx_priv.o tdfx_sli.o $(DRIOBJS) + tdfx_dga.o tdfx_priv.o tdfx_sli.o tdfx_video.o $(DRIOBJS) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include @@ -71,5 +71,6 @@ InstallDriverSDKNonExecFile(tdfx_io.c,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKNonExecFile(tdfx_priv.c,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKNonExecFile(tdfx_priv.h,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKNonExecFile(tdfx_sli.c,$(DRIVERSDKDIR)/drivers/tdfx) +InstallDriverSDKNonExecFile(tdfx_video.c,$(DRIVERSDKDIR)/drivers/tdfx) InstallDriverSDKObjectModule(tdfx,$(DRIVERSDKMODULEDIR),drivers) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp index a92c55a65..950f10368 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp @@ -15,7 +15,7 @@ tdfx \- 3Dfx video driver .SH DESCRIPTION .B tdfx is an XFree86 driver for 3Dfx video cards. -THIS MAN PAGE NEEDS TO BE FILLED IN. +It supports the Voodoo Banshee, Voodoo3, Voodoo4 and Voodoo5 cards. .SH SUPPORTED HARDWARE The .B tdfx diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h index 17221f249..97c039ba5 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h @@ -41,16 +41,14 @@ typedef struct _TDFXRec *TDFXPtr; #define PIXMAP_CACHE_LINES 512 #endif -#ifdef PROP_3DFX #include "tdfx_priv.h" -#else -#define PROPDATA -#define PROPSAREADATA -#endif -extern Bool TDFXInitPrivate(ScreenPtr pScreen); -extern void TDFXShutdownPrivate(ScreenPtr pScreen); -extern void TDFXSwapContextPrivate(ScreenPtr pScreen); + +extern Bool TDFXInitFifo(ScreenPtr pScreen); +extern void TDFXShutdownFifo(ScreenPtr pScreen); +extern void TDFXSwapContextFifo(ScreenPtr pScreen); extern void TDFXLostContext(ScreenPtr pScreen); +extern Bool TDFXSetupSLI(ScrnInfoPtr pScrn, Bool sliEnable, int aaSamples); +extern Bool TDFXDisableSLI(TDFXPtr pTDFX); #ifdef XF86DRI extern void FillPrivateDRI(TDFXPtr pTDFX, TDFXDRIPtr pTDFXDRI); @@ -126,6 +124,7 @@ typedef struct { unsigned int srcbaseaddr; unsigned int dstbaseaddr; unsigned char ExtVga[2]; + unsigned char dactable[512]; } TDFXRegRec, *TDFXRegPtr; typedef struct TextureData_t { @@ -198,6 +197,18 @@ typedef struct _TDFXRec { TDFXConfigPrivPtr pVisualConfigsPriv; TDFXRegRec DRContextRegs; #endif + /* State for video */ + FBAreaPtr offscreenYUVBuf; + int offscreenYUVBufWidth; + int offscreenYUVBufHeight; + + /* This is a small register shadow. I'm only shadowing + * sst2dDstFmt + * sst2dSrcFmt + * If a real register shadow is ever needed we should probably + * shadow everything and make it happen automatically for every write. */ + INT32 sst2DSrcFmtShadow; + INT32 sst2DDstFmtShadow; } TDFXRec; typedef struct { @@ -232,7 +243,7 @@ extern Bool TDFXDRIFinishScreenInit(ScreenPtr pScreen); extern Bool TDFXDGAInit(ScreenPtr pScreen); extern void TDFXCursorGrabMemory(ScreenPtr pScreen); extern void TDFXSetLFBConfig(TDFXPtr pTDFX); -extern void TDFXSendNOPPrivate(ScrnInfoPtr pScrn); +extern void TDFXSendNOPFifo(ScrnInfoPtr pScrn); extern Bool TDFXSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); extern void TDFXAdjustFrame(int scrnIndex, int x, int y, int flags); @@ -259,34 +270,6 @@ extern void TDFXSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, extern void TDFXSelectBuffer(TDFXPtr pTDFX, int which); - -#ifndef PROP_3DFX -#define DECLARE(a) -#define DECLARE_LAUNCH(size, x) -#ifdef TDFX_DEBUG_CMDS -#define TDFXMakeRoom(p, n) \ - do { \ - if (cmdCnt) \ - ErrorF("Previous TDFXMakeRoom passed incorrect size\n"); \ - cmdCnt=n; \ - lastAddr=0; - TDFXMakeRoomNoProp(p, n); \ - } while(0) -#define TDFXWriteLong(p, a, v) \ - do { \ - if (lastAddr && a<lastAddr) \ - ErrorF("TDFXWriteLong not ordered\n"); \ - lastAddr=a; \ - cmdCnt--; \ - TDFXWriteLongMMIO(p, a, v); \ - while (0) -#else -#define TDFXMakeRoom(p, n) TDFXMakeRoomNoProp(p, n) -#define TDFXWriteLong(p, a, v) TDFXWriteLongMMIO(p, a, v) -#endif -#define TDFXSendNOP TDFXSendNOPNoProp -#endif - #endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c index 89ba45a50..1d72845d5 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c @@ -73,6 +73,8 @@ static void TDFXSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int skipleft); static void TDFXSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); +void TDFXSelectBuffer(TDFXPtr pTDFX, int which); + void TDFXNeedSync(ScrnInfoPtr pScrn) { TDFXPtr pTDFX = TDFXPTR(pScrn); @@ -88,7 +90,7 @@ TDFXFirstSync(ScrnInfoPtr pScrn) { #ifdef XF86DRI if (pTDFX->directRenderingEnabled) { DRILock(screenInfo.screens[pScrn->scrnIndex], 0); - TDFXSwapContextPrivate(screenInfo.screens[pScrn->scrnIndex]); + TDFXSwapContextFifo(screenInfo.screens[pScrn->scrnIndex]); } #endif pTDFX->syncDone=TRUE; @@ -105,7 +107,6 @@ TDFXCheckSync(ScrnInfoPtr pScrn) { pTDFX->syncDone=FALSE; #ifdef XF86DRI if (pTDFX->directRenderingEnabled) { - TDFXLostContext(screenInfo.screens[pScrn->scrnIndex]); DRIUnlock(screenInfo.screens[pScrn->scrnIndex]); } #endif @@ -124,8 +125,10 @@ TDFXSelectBuffer(TDFXPtr pTDFX, int which) { else fmt=pTDFX->stride|((pTDFX->cpp+1)<<16); TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->fbOffset); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); + pTDFX->sst2DDstFmtShadow = fmt; TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->fbOffset); TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt); + pTDFX->sst2DSrcFmtShadow = fmt; break; case TDFX_BACK: if (pTDFX->cpp==2) @@ -134,8 +137,10 @@ TDFXSelectBuffer(TDFXPtr pTDFX, int which) { fmt=((pTDFX->stride+127)/128)|(5<<16); /* Tiled 32bpp */ TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->backOffset|BIT(31)); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); + pTDFX->sst2DDstFmtShadow = fmt; TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->backOffset|BIT(31)); TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt); + pTDFX->sst2DSrcFmtShadow = fmt; break; case TDFX_DEPTH: if (pTDFX->cpp==2) @@ -144,8 +149,10 @@ TDFXSelectBuffer(TDFXPtr pTDFX, int which) { fmt=((pTDFX->stride+127)/128)|(5<<16); /* Tiled 32bpp */ TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->depthOffset|BIT(31)); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); + pTDFX->sst2DDstFmtShadow = fmt; TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->depthOffset|BIT(31)); TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt); + pTDFX->sst2DSrcFmtShadow = fmt; break; default: ; @@ -233,21 +240,7 @@ TDFXAccelInit(ScreenPtr pScreen) infoPtr->SubsequentScreenToScreenCopy = TDFXSubsequentScreenToScreenCopy; infoPtr->ScreenToScreenCopyFlags = commonFlags; -#ifndef PROP_3DFX - /* We can use direct method because we're writing straight to the board */ - infoPtr->SetupForCPUToScreenColorExpandFill = - TDFXSetupForCPUToScreenColorExpandFill; - infoPtr->SubsequentCPUToScreenColorExpandFill = - TDFXSubsequentCPUToScreenColorExpandFill; - infoPtr->ColorExpandBase = pTDFX->MMIOBase[0]+SST_2D_LAUNCH; - infoPtr->ColorExpandRange = 128; - infoPtr->CPUToScreenColorExpandFillFlags = commonFlags | - CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD | - LEFT_EDGE_CLIPPING; /* | LEFT_EDGE_CLIPPING_NEGATIVE_X; */ - pTDFX->scanlineColorExpandBuffers[0]=0; - pTDFX->scanlineColorExpandBuffers[1]=0; -#else - /* When we're using the proprietary interface we have to use indirect */ + /* When we're using the fifo we have to use indirect expansion */ pTDFX->scanlineColorExpandBuffers[0] = xalloc((pScrn->virtualX+62)/32*4); pTDFX->scanlineColorExpandBuffers[1] = xalloc((pScrn->virtualX+62)/32*4); infoPtr->NumScanlineColorExpandBuffers=2; @@ -261,7 +254,6 @@ TDFXAccelInit(ScreenPtr pScreen) infoPtr->ScanlineCPUToScreenColorExpandFillFlags = commonFlags | CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD | LEFT_EDGE_CLIPPING; /* | LEFT_EDGE_CLIPPING_NEGATIVE_X; */ -#endif infoPtr->SetupForMono8x8PatternFill = TDFXSetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = @@ -289,6 +281,9 @@ TDFXAccelInit(ScreenPtr pScreen) pTDFX->ModeReg.dstbaseaddr=pTDFX->fbOffset; TDFXWriteLongMMIO(pTDFX, SST_2D_DSTBASEADDR, pTDFX->ModeReg.dstbaseaddr); + pTDFX->sst2DSrcFmtShadow = TDFXReadLongMMIO(pTDFX, SST_2D_SRCFORMAT); + pTDFX->sst2DDstFmtShadow = TDFXReadLongMMIO(pTDFX, SST_2D_DSTFORMAT); + /* Fill in acceleration functions */ return XAAInit(pScreen, infoPtr); } @@ -433,7 +428,9 @@ TDFXSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, TDFXMakeRoom(pTDFX, 2); DECLARE(SSTCP_SRCFORMAT|SSTCP_DSTFORMAT); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); + pTDFX->sst2DDstFmtShadow = fmt; TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt); + pTDFX->sst2DSrcFmtShadow = fmt; } void @@ -491,6 +488,7 @@ TDFXSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, DECLARE(SSTCP_DSTFORMAT|SSTCP_COLORFORE| SSTCP_COLORBACK); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); + pTDFX->sst2DDstFmtShadow = fmt; TDFXWriteLong(pTDFX, SST_2D_COLORBACK, color); TDFXWriteLong(pTDFX, SST_2D_COLORFORE, color); } @@ -540,6 +538,7 @@ TDFXSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, |SSTCP_PATTERN1ALIAS|SSTCP_COLORFORE| SSTCP_COLORBACK); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); + pTDFX->sst2DDstFmtShadow = fmt; TDFXWriteLong(pTDFX, SST_2D_PATTERN0, patx); TDFXWriteLong(pTDFX, SST_2D_PATTERN1, paty); TDFXWriteLong(pTDFX, SST_2D_COLORBACK, bg); @@ -655,6 +654,7 @@ TDFXNonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n, (pbox->x2&0x1FFF)); TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, SST_2D_PIXFMT_1BPP | SST_2D_SOURCE_PACKING_DWORD); + pTDFX->sst2DSrcFmtShadow = SST_2D_PIXFMT_1BPP | SST_2D_SOURCE_PACKING_DWORD; TDFXWriteLong(pTDFX, SST_2D_SRCXY, 0); TDFXWriteLong(pTDFX, SST_2D_COLORFORE, fg); TDFXWriteLong(pTDFX, SST_2D_COMMAND, pTDFX->Cmd); @@ -788,9 +788,11 @@ TDFXSubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, SSTCP_DSTSIZE|SSTCP_DSTXY|SSTCP_COMMAND | SSTCP_CLIP1MIN|SSTCP_CLIP1MAX); TDFXWriteLong(pTDFX,SST_2D_DSTFORMAT, fmt); + pTDFX->sst2DDstFmtShadow = fmt; TDFXWriteLong(pTDFX,SST_2D_CLIP1MIN, (x&0x1FFF) | ((y&0x1FFF)<<16)); TDFXWriteLong(pTDFX,SST_2D_CLIP1MAX, ((x+w)&0x1FFF) | (((y+h)&0x1FFF)<<16)); TDFXWriteLong(pTDFX,SST_2D_SRCFORMAT, pTDFX->stride); + pTDFX->sst2DSrcFmtShadow = pTDFX->stride; TDFXWriteLong(pTDFX,SST_2D_SRCXY, (srcx&0x1FFF) | ((srcy&0x1FFF)<<16)); TDFXWriteLong(pTDFX,SST_2D_DSTSIZE, ((w+offset)&0x1FFF) | ((h&0x1FFF)<<16)); TDFXWriteLong(pTDFX,SST_2D_DSTXY, ((x-offset)&0x1FFF) | ((y&0x1FFF)<<16)); @@ -849,9 +851,11 @@ TDFXSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, SSTCP_DSTFORMAT|SSTCP_DSTSIZE|SSTCP_SRCXY| SSTCP_DSTXY|SSTCP_COMMAND); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); + pTDFX->sst2DDstFmtShadow = fmt; TDFXWriteLong(pTDFX, SST_2D_CLIP1MIN, ((y&0x1FFF)<<16)|(x&0x1FFF)); TDFXWriteLong(pTDFX, SST_2D_CLIP1MAX, (((y+h)&0x1FFF)<<16)|((x+w)&0x1FFF)); TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, (((w+31)/32)*4) & 0x3FFF); + pTDFX->sst2DSrcFmtShadow = (((w+31)/32)*4) & 0x3FFF; TDFXWriteLong(pTDFX, SST_2D_SRCXY, skipleft&0x1F); TDFXWriteLong(pTDFX, SST_2D_DSTSIZE, ((w-skipleft)&0x1FFF)|((h&0x1FFF)<<16)); TDFXWriteLong(pTDFX, SST_2D_DSTXY, ((x+skipleft)&0x1FFF) | ((y&0x1FFF)<<16)); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c index a9fc4499b..51d719a27 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c @@ -26,6 +26,8 @@ static void TDFXDRISwapContext(ScreenPtr pScreen, DRISyncType syncType, void *readContextStore, DRIContextType writeContextType, void *writeContextStore); +static Bool TDFXDRIOpenFullScreen(ScreenPtr pScreen); +static Bool TDFXDRICloseFullScreen(ScreenPtr pScreen); static void TDFXDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index); static void TDFXDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index); @@ -489,21 +491,6 @@ TDFXDRISwapContext(ScreenPtr pScreen, DRISyncType syncType, DRIContextType oldContextType, void *oldContext, DRIContextType newContextType, void *newContext) { -#if 0 - ScrnInfoPtr pScrn; - - pScrn = xf86Screens[pScreen->myNum]; - if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) && - (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */ - TDFXCheckSync(pScrn); - TDFXLostContext(pScreen); - } - if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) && - (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */ - TDFXSwapContextPrivate(pScreen); - TDFXNeedSync(pScrn); - } -#endif } static void @@ -684,3 +671,34 @@ TDFXDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, pTDFX->AccelInfoRec->NeedToSync = TRUE; } + +static Bool +TDFXDRIOpenFullScreen(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn; + TDFXPtr pTDFX; + + xf86DrvMsg(pScreen->myNum, X_INFO, "OpenFullScreen\n"); +#if 0 + pScrn = xf86Screens[pScreen->myNum]; + pTDFX=TDFXPTR(pScrn); + if (pTDFX->numChips>1) { + TDFXSetupSLI(pScrn); + } +#endif + return TRUE; +} + +static Bool +TDFXDRICloseFullScreen(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn; + + xf86DrvMsg(pScreen->myNum, X_INFO, "CloseFullScreen\n"); +#if 0 + pScrn = xf86Screens[pScreen->myNum]; + TDFXDisableSLI(pScrn); +#endif + return TRUE; +} + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c index 72a7bef23..9f0398075 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c @@ -172,7 +172,6 @@ static PciChipsets TDFXPciChipsets[] = { { -1, -1, RES_UNDEFINED } }; -/* !!! Do we want an option for PIO address space? !!! */ /* !!! Do we want an option for alternate clocking? !!! */ typedef enum { @@ -281,6 +280,9 @@ static const char *driSymbols[] = { "DRIGetSAREAPrivate", "DRIGetContext", "DRIQueryVersion", + "DRIAdjustFrame", + "DRIOpenFullScreen", + "DRICloseFullScreen", "GlxSetVisualConfigs", NULL }; @@ -389,7 +391,7 @@ TDFXAvailableOptions(int chipid, int busid) return TDFXOptions; } -void +static void TDFXProbeDDC(ScrnInfoPtr pScrn, int index) { vbeInfoPtr pVbe; @@ -497,7 +499,10 @@ TDFXCountRam(ScrnInfoPtr pScrn) { /* set memory interface delay values and enable refresh */ /* these apply to all RAM vendors */ dramInit1 = 0x0; - dramInit1 |= 2<<SST_SGRAM_OFLOP_DEL_ADJ_SHIFT; + if (pTDFX->ChipType==PCI_CHIP_BANSHEE) + dramInit1 |= 7<<SST_SGRAM_OFLOP_DEL_ADJ_SHIFT; + else + dramInit1 |= 2<<SST_SGRAM_OFLOP_DEL_ADJ_SHIFT; dramInit1 |= SST_SGRAM_CLK_NODELAY; dramInit1 |= SST_DRAM_REFRESH_EN; dramInit1 |= (0x18 << SST_DRAM_REFRESH_VALUE_SHIFT) & SST_DRAM_REFRESH_VALUE; @@ -599,28 +604,31 @@ static void TDFXInitChips(ScrnInfoPtr pScrn) { TDFXPtr pTDFX; - int i, cfgbits, initbits; + int i, v, cfgbits, initbits; int mem0base, mem1base, mem0size, mem0bits, mem1size, mem1bits; pTDFX=TDFXPTR(pScrn); cfgbits=pciReadLong(pTDFX->PciTag[0], CFG_PCI_DECODE); mem0base=pciReadLong(pTDFX->PciTag[0], CFG_MEM0BASE); mem1base=pciReadLong(pTDFX->PciTag[0], CFG_MEM1BASE); + initbits=pciReadLong(pTDFX->PciTag[0], CFG_INIT_ENABLE); mem0size=32*1024*1024; /* Registers are always 32MB */ mem1size=pScrn->videoRam*1024*2; /* Linear mapping is 2x memory */ mem0bits=TDFXSizeToCfg(mem0size); mem1bits=TDFXSizeToCfg(mem1size)<<4; cfgbits=(cfgbits&~(0xFF))|mem0bits|mem1bits; for (i=0; i<pTDFX->numChips; i++) { - initbits=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE); initbits|=BIT(10); pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, initbits); + v=pciReadWord(pTDFX->PciTag[i], CFG_PCI_COMMAND); + if (!i) + pciWriteWord(pTDFX->PciTag[i], CFG_PCI_COMMAND, v|0x3); + else + pciWriteWord(pTDFX->PciTag[i], CFG_PCI_COMMAND, v|0x2); pTDFX->MMIOAddr[i]=mem0base+i*mem0size; - pciWriteLong(pTDFX->PciTag[i], CFG_MEM0BASE, 0xFFFFFFFF); pciWriteLong(pTDFX->PciTag[i], CFG_MEM0BASE, pTDFX->MMIOAddr[i]); pTDFX->MMIOAddr[i]&=0xFFFFFF00; pTDFX->LinearAddr[i]=mem1base+i*mem1size; - pciWriteLong(pTDFX->PciTag[i], CFG_MEM1BASE, 0xFFFFFFFF); pciWriteLong(pTDFX->PciTag[i], CFG_MEM1BASE, pTDFX->LinearAddr[i]); pTDFX->LinearAddr[i]&=0xFFFFFF00; pciWriteLong(pTDFX->PciTag[i], CFG_PCI_DECODE, cfgbits); @@ -661,8 +669,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) pTDFX->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (flags & PROBE_DETECT) { - TDFXProbeDDC(pScrn, pTDFX->pEnt->index); - return TRUE; + TDFXProbeDDC(pScrn, pTDFX->pEnt->index); + return TRUE; } if (pTDFX->pEnt->location.type != BUS_PCI) return FALSE; @@ -1090,6 +1098,7 @@ DoSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, TDFXRegPtr tdfxReg, Bool saveFonts) { TDFXPtr pTDFX; vgaHWPtr hwp; + int i, dummy, count; TDFXTRACE("TDFXDoSave start\n"); pTDFX = TDFXPTR(pScrn); @@ -1120,6 +1129,15 @@ DoSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, TDFXRegPtr tdfxReg, Bool saveFonts) tdfxReg->clip1max=TDFXReadLongMMIO(pTDFX, SST_2D_CLIP1MAX); tdfxReg->srcbaseaddr=TDFXReadLongMMIO(pTDFX, SST_2D_SRCBASEADDR); tdfxReg->dstbaseaddr=TDFXReadLongMMIO(pTDFX, SST_2D_DSTBASEADDR); + for (i=0; i<512; i++) { + count=0; + do { + TDFXWriteLongMMIO(pTDFX, DACADDR, i); + dummy=TDFXReadLongMMIO(pTDFX, DACADDR); + } while (count++<100 && dummy!=i); + tdfxReg->dactable[i]=TDFXReadLongMMIO(pTDFX, DACDATA); + dummy=tdfxReg->dactable[i]; + } } static void @@ -1139,6 +1157,7 @@ DoRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, TDFXRegPtr tdfxReg, Bool restoreFonts) { TDFXPtr pTDFX; vgaHWPtr hwp; + int i, dummy, count; TDFXTRACE("TDFXDoRestore start\n"); pTDFX = TDFXPTR(pScrn); @@ -1169,8 +1188,19 @@ DoRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, TDFXRegPtr tdfxReg, pTDFX->writeLong(pTDFX, VIDPROCCFG, tdfxReg->vidcfg); TDFXWriteLongMMIO(pTDFX, SST_2D_SRCBASEADDR, tdfxReg->srcbaseaddr); TDFXWriteLongMMIO(pTDFX, SST_2D_DSTBASEADDR, tdfxReg->dstbaseaddr); - vgaHWProtect(pScrn, FALSE); + for (i=0; i<512; i++) { + count=0; + do { + TDFXWriteLongMMIO(pTDFX, DACADDR, i); + dummy=TDFXReadLongMMIO(pTDFX, DACADDR); + } while (count++<100 && dummy!=i); + count=0; + do { + TDFXWriteLongMMIO(pTDFX, DACDATA, tdfxReg->dactable[i]); + dummy=TDFXReadLongMMIO(pTDFX, DACDATA); + } while (count++<100 && dummy!=tdfxReg->dactable[i]); + } pTDFX->sync(pScrn); } @@ -1458,7 +1488,7 @@ TDFXModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) #ifdef XF86DRI if (pTDFX->directRenderingEnabled) { DRILock(screenInfo.screens[pScrn->scrnIndex], 0); - TDFXSwapContextPrivate(screenInfo.screens[pScrn->scrnIndex]); + TDFXSwapContextFifo(screenInfo.screens[pScrn->scrnIndex]); } #endif DoRestore(pScrn, &hwp->ModeReg, &pTDFX->ModeReg, FALSE); @@ -1487,8 +1517,8 @@ TDFXLoadPalette16(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, for (j=index<<2; j<max; j++) { repeat=100; do { - pTDFX->writeLong(pTDFX, DACADDR, j); - } while (--repeat && pTDFX->readLong(pTDFX, DACADDR)!=j); + TDFXWriteLongMMIO(pTDFX, DACADDR, j); + } while (--repeat && TDFXReadLongMMIO(pTDFX, DACADDR)!=j); if (!repeat) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac index, " "bypassing CLUT\n"); @@ -1497,8 +1527,8 @@ TDFXLoadPalette16(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, } repeat=100; do { - pTDFX->writeLong(pTDFX, DACDATA, v); - } while (--repeat && pTDFX->readLong(pTDFX, DACDATA)!=v); + TDFXWriteLongMMIO(pTDFX, DACDATA, v); + } while (--repeat && TDFXReadLongMMIO(pTDFX, DACDATA)!=v); if (!repeat) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac value, " "bypassing CLUT\n"); @@ -1522,8 +1552,8 @@ TDFXLoadPalette24(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, v=(colors[index].red<<16)|(colors[index].green<<8)|colors[index].blue; repeat=100; do { - pTDFX->writeLong(pTDFX, DACADDR, index); - } while (--repeat && pTDFX->readLong(pTDFX, DACADDR)!=index); + TDFXWriteLongMMIO(pTDFX, DACADDR, index); + } while (--repeat && TDFXReadLongMMIO(pTDFX, DACADDR)!=index); if (!repeat) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac index, " "bypassing CLUT\n"); @@ -1532,8 +1562,8 @@ TDFXLoadPalette24(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, } repeat=100; do { - pTDFX->writeLong(pTDFX, DACDATA, v); - } while (--repeat && pTDFX->readLong(pTDFX, DACDATA)!=v); + TDFXWriteLongMMIO(pTDFX, DACDATA, v); + } while (--repeat && TDFXReadLongMMIO(pTDFX, DACDATA)!=v); if (!repeat) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac value, " "bypassing CLUT\n"); @@ -1662,12 +1692,12 @@ static void allocateMemory(ScrnInfoPtr pScrn) { fifoSize = ((255 <= CMDFIFO_PAGES) ? 255 : CMDFIFO_PAGES) << 12; /* We give 4096 bytes to the cursor, fifoSize to the */ /* FIFO, and everything to textures. */ - texSize = (pTDFX->fbOffset - fifoSize - 4096); - pTDFX->texOffset = pTDFX->fbOffset - texSize; + texSize = (pTDFX->fbOffset - fifoSize - 4096 - 16*1024); + pTDFX->texOffset = pTDFX->fbOffset - texSize + 16*1024; pTDFX->texSize = texSize; - pTDFX->fifoOffset = 4096; + pTDFX->fifoOffset = 4096+16*1024; pTDFX->fifoSize = fifoSize; - pTDFX->cursorOffset = 0; + pTDFX->cursorOffset = 0+16*1024; #if 0 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Cursor Offset: [0x%08X,0x%08X)\n", @@ -1722,6 +1752,7 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { allocateMemory(pScrn); +#if 0 if (pTDFX->numChips>1) { if (xf86ReturnOptValBool(TDFXOptions, OPTION_NO_SLI, FALSE)) { TDFXSetupSLI(pScrn, FALSE, 0); @@ -1729,13 +1760,14 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { TDFXSetupSLI(pScrn, TRUE, 0); } } +#endif TDFXSetLFBConfig(pTDFX); /* We initialize in the state that our FIFO is up to date */ pTDFX->syncDone=TRUE; #ifdef PROP_3DFX - if (!TDFXInitPrivate(pScreen)) { + if (!TDFXInitFifo(pScreen)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to initialize private\n"); return FALSE; } @@ -1743,7 +1775,7 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { pTDFX->sync=TDFXSync; #endif - maxy=pScrn->virtualY+128; + maxy=pScrn->virtualY+PIXMAP_CACHE_LINES; MemBox.y1 = pScrn->virtualY; MemBox.x1 = 0; MemBox.x2 = pScrn->displayWidth; @@ -1754,6 +1786,8 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { TDFXSave(pScrn); if (!TDFXModeInit(pScrn, pScrn->currentMode)) return FALSE; + TDFXSetLFBConfig(pTDFX); + miClearVisualTypes(); if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), @@ -1769,12 +1803,8 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { * is called. fbScreenInit will eventually call into the drivers * InitGLXVisuals call back. */ - if (!pTDFX->NoAccel) { + if (!pTDFX->NoAccel) pTDFX->directRenderingEnabled = TDFXDRIScreenInit(pScreen); - /* Force the initialization of the context */ - if (pTDFX->directRenderingEnabled) - TDFXLostContext(pScreen); - } #endif switch (pScrn->bitsPerPixel) { @@ -1878,6 +1908,8 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { } #endif +#if 0 + /* Disable for now, not up with latest XFree release */ #ifdef XvExtension { XF86VideoAdaptorPtr *ptr; @@ -1889,6 +1921,7 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { } } #endif +#endif pScreen->SaveScreen = TDFXSaveScreen; pTDFX->CloseScreen = pScreen->CloseScreen; @@ -1934,12 +1967,12 @@ TDFXEnterVT(int scrnIndex, int flags) { TDFXTRACE("TDFXEnterVT start\n"); pScrn = xf86Screens[scrnIndex]; + InstallFifo(pScrn); #ifdef XF86DRI pTDFX = TDFXPTR(pScrn); if (pTDFX->directRenderingEnabled) { pScreen = screenInfo.screens[scrnIndex]; DRIUnlock(pScreen); - TDFXLostContext(pScreen); } #endif if (!TDFXModeInit(pScrn, pScrn->currentMode)) return FALSE; @@ -1962,11 +1995,12 @@ TDFXLeaveVT(int scrnIndex, int flags) { TDFXRestore(pScrn); vgaHWLock(hwp); pScreen = screenInfo.screens[scrnIndex]; + TDFXShutdownFifo(pScreen); #ifdef XF86DRI pTDFX = TDFXPTR(pScrn); if (pTDFX->directRenderingEnabled) { DRILock(pScreen, 0); - TDFXSwapContextPrivate(pScreen); + TDFXSwapContextFifo(pScreen); } #endif } @@ -1990,9 +2024,7 @@ TDFXCloseScreen(int scrnIndex, ScreenPtr pScreen) } #endif -#ifdef PROP_3DFX - TDFXShutdownPrivate(pScreen); -#endif + TDFXShutdownFifo(pScreen); if (pScrn->vtSema) { TDFXRestore(pScrn); @@ -2059,7 +2091,7 @@ TDFXBlankScreen(ScrnInfoPtr pScrn, Bool unblank) scrn |= 0x20; /* blank screen */ } - vgaHWSeqReset(hwp, TRUE); + vgaHWSeqReset(hwp, TRUE); hwp->writeSeq(hwp, 0x01, scrn); /* change mode */ vgaHWSeqReset(hwp, FALSE); } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c index 41d9d2270..ce7a157ec 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c @@ -1,9 +1,6 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c,v 1.10 2000/06/21 21:40:04 tsi Exp $ */ -#if 0 -#include <sys/time.h> -#endif #include "xf86.h" #include "xf86_OSproc.h" #include "xf86_ansic.h" @@ -23,7 +20,7 @@ C - D-1 : Z buffer */ -void TDFXSendNOPPrivate3D(ScrnInfoPtr pScrn) +void TDFXSendNOPFifo3D(ScrnInfoPtr pScrn) { TDFXPtr pTDFX; @@ -33,7 +30,7 @@ void TDFXSendNOPPrivate3D(ScrnInfoPtr pScrn) WRITE_FIFO(pTDFX, 0, 0); } -void TDFXSendNOPPrivate2D(ScrnInfoPtr pScrn) +void TDFXSendNOPFifo2D(ScrnInfoPtr pScrn) { TDFXPtr pTDFX; @@ -47,10 +44,10 @@ void TDFXSendNOPPrivate2D(ScrnInfoPtr pScrn) WRITE_FIFO(pTDFX, SST_2D_COMMAND, SST_2D_NOP|SST_2D_GO); } -void TDFXSendNOPPrivate(ScrnInfoPtr pScrn) +void TDFXSendNOPFifo(ScrnInfoPtr pScrn) { - TDFXSendNOPPrivate2D(pScrn); - TDFXSendNOPPrivate3D(pScrn); + TDFXSendNOPFifo2D(pScrn); + TDFXSendNOPFifo3D(pScrn); } void InstallFifo(ScrnInfoPtr pScrn) @@ -78,7 +75,7 @@ void InstallFifo(ScrnInfoPtr pScrn) pTDFX->fifoPtr = pTDFX->fifoBase; pTDFX->fifoSlots = (pTDFX->fifoSize>>2) - 1; pTDFX->fifoEnd = pTDFX->fifoBase+pTDFX->fifoSlots; - TDFXSendNOPPrivate(pScrn); + TDFXSendNOPFifo(pScrn); } void TDFXResetFifo(ScrnInfoPtr pScrn) @@ -122,15 +119,16 @@ static void TDFXSyncFifo(ScrnInfoPtr pScrn) TDFXPtr pTDFX; int i, cnt; int stat; - long start_sec, end_sec, dummy; + long start_sec, end_sec, dummy, readptr; TDFXTRACEACCEL("TDFXSyncFifo start\n"); pTDFX=TDFXPTR(pScrn); - TDFXSendNOPPrivate(pScrn); + TDFXSendNOPFifo(pScrn); i=0; cnt=0; start_sec=0; do { + readptr=TDFXReadLongMMIO(pTDFX, SST_FIFO_RDPTRL0); stat=TDFXReadLongMMIO(pTDFX, 0); if (stat&SST_BUSY) i=0; else i++; cnt++; @@ -140,7 +138,9 @@ static void TDFXSyncFifo(ScrnInfoPtr pScrn) } else { getsecs(&end_sec, &dummy); if (end_sec-start_sec>3) { - TDFXResetFifo(pScrn); + dummy=TDFXReadLongMMIO(pTDFX, SST_FIFO_RDPTRL0); + if (dummy=readptr) + TDFXResetFifo(pScrn); start_sec=0; } } @@ -152,7 +152,7 @@ static void TDFXSyncFifo(ScrnInfoPtr pScrn) pTDFX->prevBlitDest.x2=pTDFX->prevBlitDest.y2=0; } -Bool TDFXInitPrivate(ScreenPtr pScreen) +Bool TDFXInitFifo(ScreenPtr pScreen) { ScrnInfoPtr pScrn; TDFXPtr pTDFX; @@ -172,7 +172,7 @@ Bool TDFXInitPrivate(ScreenPtr pScreen) return TRUE; } -void TDFXShutdownPrivate(ScreenPtr pScreen) +void TDFXShutdownFifo(ScreenPtr pScreen) { ScrnInfoPtr pScrn; TDFXPtr pTDFX; @@ -200,7 +200,7 @@ GetReadPtr(TDFXPtr pTDFX) } #ifdef XF86DRI -void TDFXSwapContextPrivate(ScreenPtr pScreen) +void TDFXSwapContextFifo(ScreenPtr pScreen) { ScrnInfoPtr pScrn; TDFXPtr pTDFX; @@ -240,24 +240,6 @@ void TDFXSwapContextPrivate(ScreenPtr pScreen) pTDFX->fifoSlots = pTDFX->fifoEnd-pTDFX->fifoPtr-8; } -void TDFXLostContext(ScreenPtr pScreen) -{ - ScrnInfoPtr pScrn; - TDFXPtr pTDFX; - TDFXSAREAPriv *sPriv; - - pScrn = xf86Screens[pScreen->myNum]; - pTDFX=TDFXPTR(pScrn); - sPriv=(TDFXSAREAPriv*)DRIGetSAREAPrivate(pScreen); - if (!sPriv) return; - if (sPriv->fifoPtr!=(((unsigned char*)pTDFX->fifoPtr)-pTDFX->FbBase) || - sPriv->fifoRead!=(((unsigned char*)pTDFX->fifoRead)-pTDFX->FbBase)) { - sPriv->fifoPtr=(((unsigned char*)pTDFX->fifoPtr)-pTDFX->FbBase); - sPriv->fifoRead=(((unsigned char*)pTDFX->fifoRead)-pTDFX->FbBase); - sPriv->fifoOwner=DRIGetContext(pScreen); - /* ErrorF("Out FifoPtr=%d FifoRead=%d\n", sPriv->fifoPtr, sPriv->fifoRead); */ - } -} #endif static void diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h index 657992d21..2437de898 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.h @@ -11,7 +11,7 @@ typedef int int32; typedef short int16; typedef char int8; -#define CMDFIFO_PAGES 64 +#define CMDFIFO_PAGES 255 #define PROPSAREADATA \ volatile int fifoPtr; \ @@ -58,7 +58,7 @@ typedef char int8; #endif #define DECLARE SET_PKT2_HEADER #define DECLARE_LAUNCH SET_PK1_HEADER_LAUNCH -#define TDFXSendNOP TDFXSendNOPPrivate +#define TDFXSendNOP TDFXSendNOPFifo /* ** Structures for Banshee AGP/CMD Transfer/MISC registers. diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c index 07d4a711e..390b9b711 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c @@ -12,7 +12,7 @@ /* #define RD_ABORT_ERROR */ #define H3VDD -static Bool TDFXDisableSLI(TDFXPtr pTDFX) +Bool TDFXDisableSLI(TDFXPtr pTDFX) { int i; int v; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h index 850f35398..cf195f16b 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h @@ -201,6 +201,7 @@ #define SST_3D_CHIPMASK SST_3D_OFFSET+0x214 /* NAPALM REGISTERS */ +#define CFG_PCI_COMMAND 4 #define CFG_MEM0BASE 16 #define CFG_MEM1BASE 20 #define CFG_INIT_ENABLE 64 |