diff options
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/drivers')
21 files changed, 1171 insertions, 257 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c index d2997aacd..2e97a3c26 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c @@ -135,7 +135,7 @@ I810InitVisualConfigs(ScreenPtr pScreen) depth = 1; for (accum = 0; accum <= 1; accum++) { for (stencil = 0; stencil <= 1; stencil++) { - for (db = 0; db <= 1; db++) { + for (db = 1; db >= 0; db--) { pConfigs[i].vid = -1; pConfigs[i].class = -1; pConfigs[i].rgba = TRUE; @@ -171,7 +171,7 @@ I810InitVisualConfigs(ScreenPtr pScreen) pConfigs[i].stencilSize = 0; pConfigs[i].auxBuffers = 0; pConfigs[i].level = 0; - if (stencil) + if (stencil || accum) pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; else pConfigs[i].visualRating = GLX_NONE_EXT; @@ -850,9 +850,6 @@ I810DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) I810SetupForSolidFill(pScrn, 0, GXcopy, -1); while (nbox--) { - I810SelectBuffer(pScrn, I810_FRONT); - I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1, - pbox->x2-pbox->x1, pbox->y2-pbox->y1); I810SelectBuffer(pScrn, I810_BACK); I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1, pbox->x2-pbox->x1, pbox->y2-pbox->y1); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c index caab501c8..2e55a7849 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c @@ -1900,12 +1900,15 @@ I810CloseScreen(int scrnIndex, ScreenPtr pScreen) I810Ptr pI810 = I810PTR(pScrn); XAAInfoRecPtr infoPtr = pI810->AccelInfoRec; - + if (pScrn->vtSema == TRUE) { + I810Restore(pScrn); + vgaHWLock(hwp); + } #ifdef XF86DRI - if (pI810->directRenderingEnabled) { - I810DRICloseScreen(pScreen); - pI810->directRenderingEnabled=FALSE; - } + if (pI810->directRenderingEnabled) { + I810DRICloseScreen(pScreen); + pI810->directRenderingEnabled=FALSE; + } #endif if(pScrn->vtSema == TRUE) { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c index 505f9d092..42893411d 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c @@ -50,7 +50,6 @@ int I810AllocLow( I810MemRange *result, I810MemRange *pool, int size ) return 1; } - int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size ) { if (size > pool->Size) return 0; @@ -62,7 +61,6 @@ int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size ) return 1; } - int I810AllocateGARTMemory( ScrnInfoPtr pScrn ) { unsigned long size = pScrn->videoRam * 1024; @@ -94,6 +92,7 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn ) if (!xf86BindGARTMemory(pScrn->scrnIndex, key, 0)) return FALSE; + pI810->SysMem.Start = 0; pI810->SysMem.Size = size; pI810->SysMem.End = size; @@ -135,6 +134,8 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn ) size); pI810->DcacheKey = -1; } + + /* Mouse cursor -- The i810 (crazy) needs a physical address in * system memory from which to upload the cursor. We get this from diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile index 4bb3168ad..abfc49e87 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile @@ -6,6 +6,11 @@ XCOMM #define IHaveModules #include <Server.tmpl> +#if BuildMatroxHal +#define IHaveSubdirs +SUBDIRS=hallib +#endif + #if BuildXF86DRI DRISRCS = mga_dri.c mga_warp.c mga_wrap.c DRIOBJS = mga_dri.o mga_warp.o mga_wrap.o @@ -14,17 +19,31 @@ DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri \ DRIDEFINES = $(GLX_DEFINES) #endif +#if UseMatroxHal +MGAHALSRCS = clientlx.c +MGAHALDEFINES = -DUSEMGAHAL +#if !BuildMatroxHal +MGAHALOBJS = clientlx.o HALlib/mgaHALlib.a +MGAHALINCLUDES = -IHALlib +#else +MGAHALOBJS = clientlx.o hallib/libmga_hal.a +MGAHALINCLUDES = -Ihallib +hallib/libmga_hal.a: $(SUBDIRS) +#endif +#endif + SRCS = mga_driver.c mga_hwcurs.c /* mga_cmap.c */ mga_dac3026.c mga_dacG.c \ mga_storm8.c mga_storm16.c mga_storm24.c mga_storm32.c mga_arc.c \ - mga_dga.c mga_shadow.c mga_video.c $(DRISRCS) + mga_dga.c mga_shadow.c mga_video.c $(MGAHALSRCS) $(DRISRCS) OBJS = mga_driver.o mga_hwcurs.o /* mga_cmap.o */ mga_dac3026.o mga_dacG.o \ mga_storm8.o mga_storm16.o mga_storm24.o mga_storm32.o mga_arc.o \ - mga_dga.o mga_shadow.o mga_video.o $(DRIOBJS) + mga_dga.o mga_shadow.o mga_video.o $(MGAHALOBJS) $(DRIOBJS) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include #else -INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/fb \ +INCLUDES = -I. $(MGAHALINCLUDES) -I$(XF86COMSRC) -I$(XF86OSSRC) \ + -I$(SERVERSRC)/fb \ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi -I$(XF86SRC)/int10 \ -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \ -I$(XF86SRC)/vgahw -I$(XF86SRC)/fbdevhw \ @@ -36,7 +55,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/fb \ -I$(XF86OSSRC)/vbe $(DRIINCLUDES) #endif -DEFINES = $(DRIDEFINES) +DEFINES = $(MGAHALDEFINES) $(DRIDEFINES) #if MakeHasPosixVariableSubstitutions SubdirLibraryRule($(OBJS)) @@ -78,3 +97,9 @@ InstallDriverSDKNonExecFile(mga_video.c,$(DRIVERSDKDIR)/drivers/mga) InstallDriverSDKObjectModule(mga,$(DRIVERSDKMODULEDIR),drivers) +#if BuildMatroxHal +MakeSubdirs($(SUBDIRS)) +ForceSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) +#endif + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h index e246ba594..26da1dead 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h @@ -32,6 +32,11 @@ #include "mga_dri.h" #endif +#ifdef USEMGAHAL +#include "client.h" +#endif +#include "mga_bios.h" + #if !defined(EXTRADEBUG) #define INREG8(addr) MMIO_IN8(pMga->IOBase, addr) #define INREG16(addr) MMIO_IN16(pMga->IOBase, addr) @@ -58,6 +63,8 @@ void dbg_outreg32(ScrnInfoPtr,int,int); #define MGA_VERSION 4000 #define MGA_NAME "MGA" +#define MGA_C_NAME MGA +#define MGA_MODULE_DATA mgaModuleData #define MGA_DRIVER_NAME "mga" #define MGA_MAJOR_VERSION 1 #define MGA_MINOR_VERSION 0 @@ -137,6 +144,31 @@ typedef struct mgaSave { #endif typedef struct { + int lastInstance; +#ifdef USEMGAHAL + LPCLIENTDATA pClientStruct; + LPBOARDHANDLE pBoard; + LPMGAHWINFO pMgaHwInfo; +#endif + int refCount; + CARD32 masterFbAddress; + long masterFbMapSize; + CARD32 slaveFbAddress; + long slaveFbMapSize; + int mastervideoRam; + int slavevideoRam; + Bool directRenderingEnabled; + ScrnInfoPtr pScrn_1; + ScrnInfoPtr pScrn_2; +} MGAEntRec, *MGAEntPtr; + +typedef struct { +#ifdef USEMGAHAL + LPCLIENTDATA pClientStruct; + LPBOARDHANDLE pBoard; + LPMGAMODEINFO pMgaModeInfo; + LPMGAHWINFO pMgaHwInfo; +#endif EntityInfoPtr pEnt; MGABiosInfo Bios; MGABios2Info Bios2; @@ -238,6 +270,7 @@ typedef struct { int expandHeight; int expandY; #ifdef XF86DRI + int agp_mode; Bool have_quiescense; Bool directRenderingEnabled; DRIInfoPtr pDRIInfo; @@ -247,8 +280,20 @@ typedef struct { MGAConfigPrivPtr pVisualConfigsPriv; MGARegRec DRContextRegs; MGADRIServerPrivatePtr DRIServerInfo; + void (*GetQuiescence)(ScrnInfoPtr pScrn); #endif XF86VideoAdaptorPtr adaptor; + Bool SecondCrtc; + GDevPtr device; + /* The hardware's real SrcOrg */ + int realSrcOrg; + MGAEntPtr entityPrivate; + void (*SetupForSolidFill)(ScrnInfoPtr pScrn, int color, + int rop, unsigned int planemask); + void (*SubsequentSolidFillRect)(ScrnInfoPtr pScrn, + int x, int y, int w, int h); + void (*RestoreAccelState)(ScrnInfoPtr pScrn); + int allowedWidth; void (*VideoTimerCallback)(ScrnInfoPtr, Time); void (*PaletteLoadCallback)(ScrnInfoPtr); MGAPaletteInfo palinfo[256]; /* G400 hardware bug workaround */ @@ -303,6 +348,11 @@ Bool Mga16AccelInit(ScreenPtr pScreen); Bool Mga24AccelInit(ScreenPtr pScreen); Bool Mga32AccelInit(ScreenPtr pScreen); +void Mga8InitSolidFillRectFuncs(MGAPtr pMga); +void Mga16InitSolidFillRectFuncs(MGAPtr pMga); +void Mga24InitSolidFillRectFuncs(MGAPtr pMga); +void Mga32InitSolidFillRectFuncs(MGAPtr pMga); + void MGAPolyArcThinSolid(DrawablePtr, GCPtr, int, xArc*); Bool MGADGAInit(ScreenPtr pScreen); @@ -319,6 +369,8 @@ Bool MgaCleanupDma(ScrnInfoPtr pScrn); Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size); #ifdef XF86DRI Bool MgaLockUpdate(ScrnInfoPtr pScrn, drmLockFlags flags); +void mgaGetQuiescence(ScrnInfoPtr pScrn); +void mgaGetQuiescence_shared(ScrnInfoPtr pScrn); #endif void MGARefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void MGARefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c index 3c2fe556f..091dd3edb 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c @@ -24,7 +24,6 @@ #include "mga_bios.h" #include "mga_reg.h" -#include "mga_macros.h" #include "mga.h" #include "xf86DDC.h" @@ -83,6 +82,12 @@ static Bool MGAGInit(ScrnInfoPtr, DisplayModePtr); static void MGAGLoadPalette(ScrnInfoPtr, int, int*, LOCO*, VisualPtr); static Bool MGAG_i2cInit(ScrnInfoPtr pScrn); + +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +/* We don't need anymore: MGAGCalcClock and MGAGSetPCLK function */ +#ifndef USEMGAHAL /* * MGAGCalcClock - Calculate the PLL settings (m, n, p, s). * @@ -245,6 +250,10 @@ MGAGSetPCLK( ScrnInfoPtr pScrn, long f_out ) pReg->DacRegs[ MGA1064_PIX_PLLC_N ] = n & 0x7F; pReg->DacRegs[ MGA1064_PIX_PLLC_P ] = (p & 0x07) | ((s & 0x03) << 3); } +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif /* * MGAGInit @@ -283,6 +292,10 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) BppShift = pMga->BppShifts[(pLayout->bitsPerPixel >> 3) - 1]; +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL /* Allocate the DacRegs space if not done already */ if (pReg->DacRegs == NULL) { pReg->DacRegs = xnfcalloc(DACREGSIZE, 1); @@ -423,6 +436,10 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) default: FatalError("MGA: unsupported depth\n"); } +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif /* * This will initialize all of the generic VGA registers. @@ -503,23 +520,49 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode) pVga->CRTC[21] = vd & 0xFF; pVga->CRTC[22] = (vt + 1) & 0xFF; - if (mode->Flags & V_DBLSCAN) - pVga->CRTC[9] |= 0x80; - +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL pReg->DacRegs[ MGA1064_CURSOR_BASE_ADR_LOW ] = pMga->FbCursorOffset >> 10; pReg->DacRegs[ MGA1064_CURSOR_BASE_ADR_HI ] = pMga->FbCursorOffset >> 18; +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif if (pMga->SyncOnGreen) { +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL pReg->DacRegs[ MGA1064_GEN_CTL ] &= ~0x20; +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif pReg->ExtVga[3] |= 0x40; } /* select external clock */ pVga->MiscOutReg |= 0x0C; - + +#ifndef USEMGAHAL + if (mode->Flags & V_DBLSCAN) + pVga->CRTC[9] |= 0x80; +#endif + +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL MGAGSetPCLK( pScrn, mode->Clock ); +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif /* This disables the VGA memory aperture */ pVga->MiscOutReg &= ~0x02; @@ -630,7 +673,10 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, CARD32 optionMask; MGAPtr pMga = MGAPTR(pScrn); - CHECK_DMA_QUIESCENT( pMga, pScrn ); +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL /* * Code is needed to get things back to bank zero. */ @@ -665,6 +711,10 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, pciSetBitsLong(pMga->PciTag, PCI_MGA_OPTION3, OPTION3_MASK, mgaReg->Option3); +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif /* restore CRTCEXT regs */ for (i = 0; i < 6; i++) OUTREG16(0x1FDE, (mgaReg->ExtVga[i] << 8) | i); @@ -712,12 +762,20 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, int i; MGAPtr pMga = MGAPTR(pScrn); - CHECK_DMA_QUIESCENT( pMga, pScrn ); + if(pMga->SecondCrtc == TRUE) return; +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL /* Allocate the DacRegs space if not done already */ if (mgaReg->DacRegs == NULL) { mgaReg->DacRegs = xnfcalloc(DACREGSIZE, 1); } +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif /* * Code is needed to get back to bank zero. @@ -731,6 +789,10 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, vgaHWSave(pScrn, vgaReg, VGA_SR_MODE | (saveFonts ? VGA_SR_FONTS : 0)); MGAGSavePalette(pScrn, vgaReg->DAC); +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#ifndef USEMGAHAL /* * The port I/O code necessary to read in the extended registers. */ @@ -742,6 +804,10 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, mgaReg->Option2 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION2); if (pMga->Chipset == PCI_CHIP_MGAG400) mgaReg->Option3 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION3); +/*******************/ +/* ADDED BY MATROX */ +/*******************/ +#endif for (i = 0; i < 6; i++) { @@ -833,8 +899,12 @@ MGAGSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) static Bool MGAGUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs) { + MGAPtr pMga = MGAPTR(xf86Screens[pScrn->myNum]); + /* This needs to detect if its on the second dac */ if( XF86SCRNINFO(pScrn)->currentMode->Flags & V_DBLSCAN ) return FALSE; + if( pMga->SecondCrtc == TRUE ) + return FALSE; return TRUE; } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c index db75b5985..41b82801c 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.7 2000/08/25 13:42:37 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.5 2000/06/23 23:43:44 alanh Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -38,6 +38,11 @@ static void MGADRISwapContext(ScreenPtr pScreen, DRISyncType syncType, void *readContextStore, DRIContextType writeContextType, void *writeContextStore); +static void MGADRISwapContext_shared(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType readContextType, + void *readContextStore, + DRIContextType writeContextType, + void *writeContextStore); extern void Mga8DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index); extern void Mga8DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index); @@ -145,7 +150,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen) case 24: break; case 16: - numConfigs = 4; + numConfigs = 8; if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), numConfigs))) { @@ -168,7 +173,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen) i = 0; depth = 1; for (accum = 0; accum <= 1; accum++) { - for (stencil = 0; stencil <= 0; stencil++) { /* no stencil for now */ + for (stencil = 0; stencil <= 1; stencil++) { /* no stencil for now */ for (db=1; db>=0; db--) { pConfigs[i].vid = -1; pConfigs[i].class = -1; @@ -229,7 +234,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen) break; case 32: - numConfigs = 4; + numConfigs = 8; if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), numConfigs))) { @@ -252,7 +257,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen) i = 0; depth = 1; for (accum = 0; accum <= 1; accum++) { - for (stencil = 0; stencil <= 0; stencil++) { /* no stencil for now */ + for (stencil = 0; stencil <= 1; stencil++) { for (db=1; db>=0; db--) { pConfigs[i].vid = -1; pConfigs[i].class = -1; @@ -282,7 +287,10 @@ MGAInitVisualConfigs(ScreenPtr pScreen) pConfigs[i].stereo = FALSE; pConfigs[i].bufferSize = 32; if (depth) - pConfigs[i].depthSize = 32; + if (stencil) + pConfigs[i].depthSize = 24; + else + pConfigs[i].depthSize = 32; else pConfigs[i].depthSize = 0; if (stencil) @@ -291,7 +299,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen) pConfigs[i].stencilSize = 0; pConfigs[i].auxBuffers = 0; pConfigs[i].level = 0; - if (stencil || accum) + if (accum) pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; else pConfigs[i].visualRating = GLX_NONE_EXT; @@ -329,6 +337,39 @@ static unsigned int mylog2(unsigned int n) return log2; } +static unsigned long MGAParseAgpMode(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMga = MGAPTR(pScrn); + unsigned long mode_mask; + + switch(pMga->agp_mode) { + case 4: + mode_mask = ~0x00000003; + break; + case 2: + if (pMga->Chipset == PCI_CHIP_MGAG200) { + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Enabling AGP 2x pll encoding\n"); + OUTREG(MGAREG_AGP_PLL, AGP_PLL_agp2xpllen_enable); + } + mode_mask = ~0x00000005; + break; + default: + /* Default to 1X agp mode */ + case 1: + if (pMga->Chipset == PCI_CHIP_MGAG200) { + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Disabling AGP 2x pll encoding\n"); + OUTREG(MGAREG_AGP_PLL, AGP_PLL_agp2xpllen_disable); + } + pMga->agp_mode = 1; + mode_mask = ~0x00000006; + break; + } + + return mode_mask; +} Bool MGADRIScreenInit(ScreenPtr pScreen) { @@ -341,6 +382,7 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) int prim_size; int init_offset; int i; + unsigned long mode_mask; /* Check that the GLX, DRI, and DRM modules have been loaded by testing * for canonical symbols in each module. */ @@ -442,7 +484,10 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) pDRIInfo->CreateContext = MGACreateContext; pDRIInfo->DestroyContext = MGADestroyContext; - pDRIInfo->SwapContext = MGADRISwapContext; + if (xf86IsEntityShared(pScrn->entityList[0])) + pDRIInfo->SwapContext = MGADRISwapContext_shared; + else + pDRIInfo->SwapContext = MGADRISwapContext; switch( pScrn->bitsPerPixel ) { case 8: @@ -476,16 +521,17 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) { drmVersionPtr version = drmGetVersion(pMGA->drmSubFD); if (version) { - if (version->version_major != 1 || + if (version->version_major != 2 || version->version_minor != 0 || version->version_patchlevel < 0) { /* incompatible drm version */ xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] MGADRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n", + "[drm] MGADRIScreenInit failed (DRM version = %d.%d.%d, expected 2.0.x). Disabling DRI.\n", version->version_major, version->version_minor, version->version_patchlevel); - MGADRICloseScreen(pScreen); +/* MGADRICloseScreen(pScreen); */ + drmFreeVersion(version); return FALSE; } @@ -524,16 +570,17 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) DRICloseScreen(pScreen); return FALSE; } - + + mode_mask = MGAParseAgpMode(pScreen); + pMGADRIServer->agpMode = drmAgpGetMode(pMGA->drmSubFD); - /* Default to 1X agp mode */ - pMGADRIServer->agpMode &= ~0x00000002; + pMGADRIServer->agpMode &= mode_mask; if (drmAgpEnable(pMGA->drmSubFD, pMGADRIServer->agpMode) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpEnable failed\n"); DRICloseScreen(pScreen); return FALSE; } - ErrorF("[drm] drmAgpEnabled succeeded\n"); + ErrorF("[drm] drmAgpEnabled succeeded for AGP mode %dx\n", pMGA->agp_mode); prim_size = 65536; init_offset = ((prim_size + pMGADRIServer->warp_ucode_size + @@ -724,22 +771,16 @@ MGADRICloseScreen(ScreenPtr pScreen) MGAPtr pMGA = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo; - MgaCleanupDma(pScrn); - +/* The DRI will automagically clean these up when driFD is closed */ if(pMGADRIServer->agp_map) { - ErrorF("Unmapped agp region\n"); drmUnmap(pMGADRIServer->agp_map, pMGADRIServer->agpSizep); pMGADRIServer->agp_map = 0; } if(pMGADRIServer->agpHandle) { - ErrorF("Freeing agp memory\n"); - drmAgpFree(pMGA->drmSubFD, pMGADRIServer->agpHandle); pMGADRIServer->agpHandle = 0; pMGADRIServer->agpSizep = 0; } if(pMGADRIServer->agpAcquired == TRUE) { - ErrorF("releasing agp module\n"); - drmAgpRelease(pMGA->drmSubFD); pMGADRIServer->agpAcquired = FALSE; } @@ -797,7 +838,8 @@ MGADRIFinishScreenInit(ScreenPtr pScreen) } -void mgaGetQuiescence( ScrnInfoPtr pScrn ) +void +mgaGetQuiescence( ScrnInfoPtr pScrn ) { MGAPtr pMga = MGAPTR(pScrn); @@ -812,13 +854,13 @@ void mgaGetQuiescence( ScrnInfoPtr pScrn ) OUTREG(MGAREG_MACCESS, pMga->MAccess); OUTREG(MGAREG_PITCH, pLayout->displayWidth); pMga->PlaneMask = ~0; + OUTREG(MGAREG_PLNWT, pMga->PlaneMask); pMga->BgColor = 0; pMga->FgColor = 0; - OUTREG(MGAREG_PLNWT, ~0); - OUTREG(MGAREG_BCOL, 0); - OUTREG(MGAREG_FCOL, 0); + OUTREG(MGAREG_BCOL, pMga->BgColor); + OUTREG(MGAREG_FCOL, pMga->FgColor); + OUTREG(MGAREG_SRCORG, pMga->realSrcOrg); pMga->SrcOrg = 0; - OUTREG(MGAREG_SRCORG, 0); OUTREG(MGAREG_DSTORG, pMga->DstOrg); OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT); OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */ @@ -829,8 +871,27 @@ void mgaGetQuiescence( ScrnInfoPtr pScrn ) } +void +mgaGetQuiescence_shared( ScrnInfoPtr pScrn ) +{ + MGAPtr pMga = MGAPTR(pScrn); + MGAEntPtr pMgaEnt = pMga->entityPrivate; + MGAPtr pMga2 = MGAPTR(pMgaEnt->pScrn_2); -void MGASwapContext(ScreenPtr pScreen) + pMga = MGAPTR(pMgaEnt->pScrn_1); + pMga->have_quiescense = 1; + pMga2->have_quiescense = 1; + + if (pMgaEnt->directRenderingEnabled) { + MgaLockUpdate(pMgaEnt->pScrn_1, (DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH)); + pMga->RestoreAccelState(pScrn); + xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex); + } +} + + +void +MGASwapContext(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMga = MGAPTR(pScrn); @@ -842,6 +903,20 @@ void MGASwapContext(ScreenPtr pScreen) pMga->AccelInfoRec->NeedToSync = TRUE; } +void +MGASwapContext_shared(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMga = MGAPTR(pScrn); + MGAEntPtr pMgaEnt = pMga->entityPrivate; + MGAPtr pMga2 = MGAPTR(pMgaEnt->pScrn_2); + + pMga = MGAPTR(pMgaEnt->pScrn_1); + pMga->have_quiescense = 0; + pMga->AccelInfoRec->NeedToSync = TRUE; + pMga2->have_quiescense = 0; + pMga2->AccelInfoRec->NeedToSync = TRUE; +} /* This is really only called from validate/postvalidate as we @@ -874,6 +949,18 @@ MGADRISwapContext(ScreenPtr pScreen, DRISyncType syncType, } } +static void +MGADRISwapContext_shared(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType oldContextType, void *oldContext, + DRIContextType newContextType, void *newContext) +{ + if (syncType == DRI_3D_SYNC && + oldContextType == DRI_2D_CONTEXT && + newContextType == DRI_2D_CONTEXT) + { + MGASwapContext_shared(pScreen); + } +} void MGASelectBuffer(ScrnInfoPtr pScrn, int which) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c index ea5d061e1..845e3f85a 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c @@ -43,7 +43,7 @@ * Fixed 32bpp hires 8MB horizontal line glitch at middle right */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.167 2000/09/20 00:09:22 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.165 2000/07/11 01:46:36 tsi Exp $ */ /* * This is a first cut at a non-accelerated version to work with the @@ -79,11 +79,10 @@ #include "xf86RAC.h" #include "vbe.h" -#include "cfb8_32.h" #include "fb.h" +#include "cfb8_32.h" #include "dixstruct.h" -#include "mga_bios.h" #include "mga_reg.h" #include "mga.h" #include "mga_macros.h" @@ -118,6 +117,7 @@ static Bool MGAEnterVTFBDev(int scrnIndex, int flags); static void MGALeaveVT(int scrnIndex, int flags); static Bool MGACloseScreen(int scrnIndex, ScreenPtr pScreen); static Bool MGASaveScreen(ScreenPtr pScreen, int mode); +static Bool MGASaveScreenCrtc2(ScreenPtr pScreen, int mode); /* This shouldn't be needed since RAC will disable all I/O for MGA cards. */ #ifdef DISABLE_VGA_IO @@ -141,8 +141,10 @@ static Bool MGAUnmapMem(ScrnInfoPtr pScrn); static void MGASave(ScrnInfoPtr pScrn); static void MGARestore(ScrnInfoPtr pScrn); static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +void MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags); static void MGABlockHandler(int, pointer, pointer, pointer); +static int MGAEntityIndex = -1; /* * This contains the functions needed by the server after loading the @@ -152,7 +154,7 @@ static void MGABlockHandler(int, pointer, pointer, pointer); * this DriverRec be an upper-case version of the driver name. */ -DriverRec MGA = { +DriverRec MGA_C_NAME = { MGA_VERSION, MGA_DRIVER_NAME, #if 0 @@ -207,7 +209,10 @@ typedef enum { OPTION_VIDEO_KEY, OPTION_ROTATE, OPTION_TEXTURED_VIDEO, - OPTION_XAALINES + OPTION_XAALINES, + OPTION_CRTC2HALF, + OPTION_AGP_MODE_2X, + OPTION_AGP_MODE_4X } MGAOpts; static OptionInfoRec MGAOptions[] = { @@ -228,6 +233,9 @@ static OptionInfoRec MGAOptions[] = { { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, { OPTION_TEXTURED_VIDEO, "TexturedVideo",OPTV_BOOLEAN, {0}, FALSE }, { OPTION_XAALINES, "XAALines", OPTV_INTEGER, {0}, FALSE }, + { OPTION_CRTC2HALF, "Crtc2Half", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_AGP_MODE_2X, "AGPMode2x", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_AGP_MODE_4X, "AGPMode4x", OPTV_BOOLEAN, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -395,7 +403,7 @@ static MODULESETUPPROTO(mgaSetup); static XF86ModuleVersionInfo mgaVersRec = { - "mga", + MGA_DRIVER_NAME, MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, @@ -407,7 +415,7 @@ static XF86ModuleVersionInfo mgaVersRec = {0,0,0,0} }; -XF86ModuleData mgaModuleData = { &mgaVersRec, mgaSetup, NULL }; +XF86ModuleData MGA_MODULE_DATA = { &mgaVersRec, mgaSetup, NULL }; static pointer mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin) @@ -418,7 +426,7 @@ mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin) if (!setupDone) { setupDone = TRUE; - xf86AddDriver(&MGA, module, 0); + xf86AddDriver(&MGA_C_NAME, module, 0); /* * Modules that this driver always requires may be loaded here @@ -429,10 +437,11 @@ mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin) * Tell the loader about symbols from other modules that this module * might refer to. */ - LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, + LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols, xf8_32bppSymbols, ramdacSymbols, ddcSymbols, i2cSymbols, shadowSymbols, - fbdevHWSymbols, vbeSymbols, fbSymbols, + fbdevHWSymbols, vbeSymbols, + fbSymbols, #ifdef XF86DRI drmSymbols, driSymbols, #endif @@ -575,6 +584,7 @@ MGAProbe(DriverPtr drv, int flags) foundScreen = TRUE; else for (i = 0; i < numUsed; i++) { ScrnInfoPtr pScrn; + EntityInfoPtr pEnt; #ifdef DISABLE_VGA_IO MgaSavePtr smga; #endif @@ -610,6 +620,37 @@ MGAProbe(DriverPtr drv, int flags) pScrn->ValidMode = MGAValidMode; foundScreen = TRUE; } + + /* + * For cards that can do dual head per entity, mark the entity + * as sharable. + */ + pEnt = xf86GetEntityInfo(usedChips[i]); + if (pEnt->chipset == PCI_CHIP_MGAG400) { + MGAEntPtr pMgaEnt = NULL; + DevUnion *pPriv; + + xf86SetEntitySharable(usedChips[i]); + /* Allocate an entity private if necessary */ + if (MGAEntityIndex < 0) + MGAEntityIndex = xf86AllocateEntityPrivateIndex(); + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex); + if (!pPriv->ptr) { + pPriv->ptr = xnfcalloc(sizeof(MGAEntRec), 1); + pMgaEnt = pPriv->ptr; + pMgaEnt->lastInstance = -1; + } else { + pMgaEnt = pPriv->ptr; + } + /* + * Set the entity instance for this instance of the driver. For + * dual head per card, instance 0 is the "master" instance, driving + * the primary head, and instance 1 is the "slave". + */ + pMgaEnt->lastInstance++; + xf86SetEntityInstanceForScreen(pScrn, pScrn->entityList[0], + pMgaEnt->lastInstance); + } } if (usedChips) xfree(usedChips); @@ -783,6 +824,7 @@ MGASoftReset(ScrnInfoPtr pScrn) { MGAPtr pMga = MGAPTR(pScrn); + ErrorF("SoftReset called!!!\n"); pMga->FbMapSize = 8192 * 1024; MGAMapMem(pScrn); @@ -1071,8 +1113,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) double real; int bytesPerPixel; ClockRangePtr clockRanges; + const char *reqSym = NULL; const char *s; int flags24; + MGAEntPtr pMgaEnt = NULL; +#ifdef USEMGAHAL + MGAMODEINFO mgaModeInfo = {0}; + ULONG ulBOARDHANDLESize; + UCHAR ucMgaBase2; + ULONG ulOrgFBuffer; +#endif /* * Note: This function is only called once at server startup, and @@ -1097,12 +1147,26 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) } pMga = MGAPTR(pScrn); - + /* Set here until dri is enabled */ +#ifdef XF86DRI + pMga->have_quiescense = 1; +#endif /* Get the entity, and make sure it is PCI. */ pMga->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (pMga->pEnt->location.type != BUS_PCI) return FALSE; + /* Allocate an entity private if necessary */ + if (xf86IsEntityShared(pScrn->entityList[0])) { + pMgaEnt = xf86GetEntityPrivate(pScrn->entityList[0], + MGAEntityIndex)->ptr; + pMga->entityPrivate = pMgaEnt; + } + + /* Set pMga->device to the relevant Device section */ + pMga->device = xf86GetDevFromEntity(pScrn->entityList[0], + pScrn->entityInstanceList[0]); + if (flags & PROBE_DETECT) { MGAProbeDDC(pScrn, pMga->pEnt->index); return TRUE; @@ -1173,6 +1237,55 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) /* Set pScrn->monitor */ pScrn->monitor = pScrn->confScreen->monitor; +#if 1 + /* + * XXX This assumes that the lower number screen is always the "master" + * head, and that the "master" is the first CRTC. This can result in + * unexpected behaviour when the config file marks the primary CRTC + * as the second screen. + */ + if(xf86IsEntityShared(pScrn->entityList[0]) && + xf86IsPrimInitDone(pScrn->entityList[0])) { + /* This is the second crtc */ + pMga->SecondCrtc = TRUE; + pMga->HWCursor = FALSE; + pScrn->AdjustFrame = MGAAdjustFrameCrtc2; + pMgaEnt->pScrn_2 = pScrn; +#ifdef XF86DRI + pMga->GetQuiescence = mgaGetQuiescence_shared; +#endif + } else { + pMga->SecondCrtc = FALSE; + pMga->HWCursor = TRUE; + if (xf86IsEntityShared(pScrn->entityList[0])) { + pMgaEnt->pScrn_1 = pScrn; +#ifdef XF86DRI + pMga->GetQuiescence = mgaGetQuiescence_shared; +#endif + } else { +#ifdef XF86DRI + pMga->GetQuiescence = mgaGetQuiescence; +#endif + } + } +#else + /* + * This is an alternative version that determines which is the secondary + * CRTC from the screen field in pMga->device. It doesn't currently + * work becasue there are things that assume the primary CRTC is + * initialised first. + */ + if (pMga->device->screen == 1) { + /* This is the second CRTC */ + pMga->SecondCrtc = TRUE; + pMga->HWCursor = FALSE; + pScrn->AdjustFrame = MGAAdjustFrameCrtc2; + } else { + pMga->SecondCrtc = FALSE; + pMga->HWCursor = TRUE; + } +#endif + /* * The first thing we should figure out is the depth, bpp, etc. * Our default depth is 8, so pass it to the helper function. @@ -1183,10 +1296,13 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) flags24 = Support24bppFb | Support32bppFb | SupportConvert32to24; s = xf86TokenToOptName(MGAOptions, OPTION_OVERLAY); if (!(xf86FindOption(pScrn->confScreen->options, s) || - xf86FindOption(pMga->pEnt->device->options, s))) { + xf86FindOption(pMga->device->options, s))) { flags24 |= PreferConvert32to24; } + if (pMga->SecondCrtc) + flags24 = Support32bppFb; + if (!xf86SetDepthBpp(pScrn, 8, 8, 8, flags24)) { return FALSE; } else { @@ -1243,12 +1359,12 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * Set the Chipset and ChipRev, allowing config file entries to * override. */ - if (pMga->pEnt->device->chipset && *pMga->pEnt->device->chipset) { - pScrn->chipset = pMga->pEnt->device->chipset; + if (pMga->device->chipset && *pMga->device->chipset) { + pScrn->chipset = pMga->device->chipset; pMga->Chipset = xf86StringToToken(MGAChipsets, pScrn->chipset); from = X_CONFIG; - } else if (pMga->pEnt->device->chipID >= 0) { - pMga->Chipset = pMga->pEnt->device->chipID; + } else if (pMga->device->chipID >= 0) { + pMga->Chipset = pMga->device->chipID; pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset); from = X_CONFIG; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n", @@ -1258,8 +1374,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->Chipset = pMga->PciInfo->chipType; pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset); } - if (pMga->pEnt->device->chipRev >= 0) { - pMga->ChipRev = pMga->pEnt->device->chipRev; + if (pMga->device->chipRev >= 0) { + pMga->ChipRev = pMga->device->chipRev; xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", pMga->ChipRev); } else { @@ -1305,8 +1421,31 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->numXAALines); } +#ifdef XF86DRI + { + Bool temp; + + from = X_DEFAULT; + + pMga->agp_mode = 1; + if (xf86GetOptValBool(MGAOptions, OPTION_AGP_MODE_2X, + &temp)) { + pMga->agp_mode = 2; + from = X_CONFIG; + } + + if (xf86GetOptValBool(MGAOptions, OPTION_AGP_MODE_4X, + &temp)) { + pMga->agp_mode = 4; + from = X_CONFIG; + } + xf86DrvMsg(pScrn->scrnIndex, from, "Using AGP Mode %dx\n", + pMga->agp_mode); + } +#endif + from = X_DEFAULT; - pMga->HWCursor = TRUE; + /* * The preferred method is to use the "hw cursor" option as a tri-state * option, with the default set above. @@ -1346,7 +1485,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) } if ((s = xf86GetOptValString(MGAOptions, OPTION_OVERLAY))) { if (!*s || !xf86NameCmp(s, "8,24") || !xf86NameCmp(s, "24,8")) { - if(pScrn->bitsPerPixel == 32) { + if(pScrn->bitsPerPixel == 32 && pMga->SecondCrtc == FALSE) { pMga->Overlay8Plus24 = TRUE; if(!xf86GetOptValInteger( MGAOptions, OPTION_COLOR_KEY,&(pMga->colorKey))) @@ -1357,13 +1496,15 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) "PseudoColor overlay enabled\n"); } else { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, - "Option \"Overlay\" is only supported in 32 bits per pixel\n"); + "Option \"Overlay\" is only supported in 32 bits per pixel on" + "the first CRTC\n"); } } else { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"%s\" is not a valid value for Option \"Overlay\"\n", s); } } + if(xf86GetOptValInteger(MGAOptions, OPTION_VIDEO_KEY, &(pMga->videoKey))) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n", pMga->videoKey); @@ -1467,16 +1608,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * For the 2064 and older rev 1064, base0 is the MMIO and base0 is * the framebuffer is base1. Let the config file override these. */ - if (pMga->pEnt->device->MemBase != 0) { + if (pMga->device->MemBase != 0) { /* Require that the config file value matches one of the PCI values. */ - if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->pEnt->device->MemBase)) { + if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->device->MemBase)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "MemBase 0x%08lX doesn't match any PCI base register.\n", - pMga->pEnt->device->MemBase); + pMga->device->MemBase); MGAFreeRec(pScrn); return FALSE; } - pMga->FbAddress = pMga->pEnt->device->MemBase; + pMga->FbAddress = pMga->device->MemBase; from = X_CONFIG; } else { /* details: mgabase2 sdk pp 4-12 */ @@ -1493,19 +1634,20 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) return FALSE; } } + xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n", (unsigned long)pMga->FbAddress); - if (pMga->pEnt->device->IOBase != 0) { + if (pMga->device->IOBase != 0) { /* Require that the config file value matches one of the PCI values. */ - if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->pEnt->device->IOBase)) { + if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->device->IOBase)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "IOBase 0x%08lX doesn't match any PCI base register.\n", - pMga->pEnt->device->IOBase); + pMga->device->IOBase); MGAFreeRec(pScrn); return FALSE; } - pMga->IOAddress = pMga->pEnt->device->IOBase; + pMga->IOAddress = pMga->device->IOBase; from = X_CONFIG; } else { /* details: mgabase1 sdk pp 4-11 */ @@ -1542,9 +1684,9 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) */ pMga->BiosFrom = X_NONE; - if (pMga->pEnt->device->BiosBase != 0) { + if (pMga->device->BiosBase != 0) { /* XXX This isn't used */ - pMga->BiosAddress = pMga->pEnt->device->BiosBase; + pMga->BiosAddress = pMga->device->BiosBase; pMga->BiosFrom = X_CONFIG; } else { /* details: rombase sdk pp 4-15 */ @@ -1591,20 +1733,73 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * file, we respect that setting. */ from = X_PROBED; - if (pMga->pEnt->device->videoRam != 0) { - pScrn->videoRam = pMga->pEnt->device->videoRam; + if (pMga->device->videoRam != 0) { + pScrn->videoRam = pMga->device->videoRam; from = X_CONFIG; } else if (pMga->FBDev) { pScrn->videoRam = fbdevHWGetVidmem(pScrn)/1024; } else { pScrn->videoRam = MGACountRam(pScrn); } + + if(xf86IsEntityShared(pScrn->entityList[0])) { + /* This takes gives either half or 8 meg to the second head + * whichever is less. */ + if(pMga->SecondCrtc == FALSE) { + Bool UseHalf = FALSE; + int adjust; + + xf86GetOptValBool(MGAOptions, OPTION_CRTC2HALF, &UseHalf); + adjust = pScrn->videoRam / 2; + + if (UseHalf == TRUE) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Crtc2 will use %dK of VideoRam\n", + adjust); + } else { + adjust = min(adjust, 8192); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Crtc2 will use %dK of VideoRam\n", + adjust); + } + pMgaEnt->mastervideoRam = pScrn->videoRam - adjust; + pScrn->videoRam = pMgaEnt->mastervideoRam; + pMgaEnt->slavevideoRam = adjust; + pMgaEnt->masterFbAddress = pMga->FbAddress; + pMga->FbMapSize = + pMgaEnt->masterFbMapSize = pScrn->videoRam * 1024; + pMgaEnt->slaveFbAddress = pMga->FbAddress + + pMgaEnt->masterFbMapSize; + pMgaEnt->slaveFbMapSize = pMgaEnt->slavevideoRam * 1024; + pMga->realSrcOrg = pMga->SrcOrg = 0; + pMga->DstOrg = 0; + } else { + pMga->FbAddress = pMgaEnt->slaveFbAddress; + pMga->FbMapSize = pMgaEnt->slaveFbMapSize; + pScrn->videoRam = pMgaEnt->slavevideoRam; + pMga->DstOrg = pMga->realSrcOrg = + pMgaEnt->slaveFbAddress - pMgaEnt->masterFbAddress; + pMga->SrcOrg = 0; /* This is not stored in hw format!! */ + } + pMgaEnt->refCount++; + } else { + /* Normal Handling of video ram etc */ + pMga->FbMapSize = pScrn->videoRam * 1024; + switch(pMga->Chipset) { + case PCI_CHIP_MGAG400: + case PCI_CHIP_MGAG200: + case PCI_CHIP_MGAG200_PCI: + pMga->SrcOrg = 0; + pMga->DstOrg = 0; + break; + default: + break; + } + } xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n", pScrn->videoRam); - - pMga->FbMapSize = pScrn->videoRam * 1024; - - /* Set the bpp shift value */ + + /* Set the bpp shift value */ pMga->BppShifts[0] = 0; pMga->BppShifts[1] = 1; pMga->BppShifts[2] = 0; @@ -1670,25 +1865,25 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * If the user has specified ramdac speed in the XF86Config * file, we respect that setting. */ - if (pMga->pEnt->device->dacSpeeds[0]) { + if (pMga->device->dacSpeeds[0]) { int speed = 0; switch (pScrn->bitsPerPixel) { case 8: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP8]; + speed = pMga->device->dacSpeeds[DAC_BPP8]; break; case 16: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP16]; + speed = pMga->device->dacSpeeds[DAC_BPP16]; break; case 24: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP24]; + speed = pMga->device->dacSpeeds[DAC_BPP24]; break; case 32: - speed = pMga->pEnt->device->dacSpeeds[DAC_BPP32]; + speed = pMga->device->dacSpeeds[DAC_BPP32]; break; } if (speed == 0) - pMga->MaxClock = pMga->pEnt->device->dacSpeeds[0]; + pMga->MaxClock = pMga->device->dacSpeeds[0]; else pMga->MaxClock = speed; from = X_CONFIG; @@ -1696,10 +1891,13 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->MaxClock = pMga->Dac.maxPixelClock; from = pMga->Dac.ClockFrom; } + if(pMga->SecondCrtc == TRUE) { + /* Override on 2nd crtc */ + pMga->MaxClock = 112000; + } xf86DrvMsg(pScrn->scrnIndex, from, "Max pixel clock is %d MHz\n", pMga->MaxClock / 1000); - - /* + /* * Setup the ClockRanges, which describe what clock ranges are available, * and what sort of modes they can be used for. */ @@ -1708,8 +1906,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) clockRanges->minClock = pMga->MinClock; clockRanges->maxClock = pMga->MaxClock; clockRanges->clockIndex = -1; /* programmable */ - clockRanges->interlaceAllowed = TRUE; +#ifdef USEMGAHAL + clockRanges->interlaceAllowed = FALSE; + clockRanges->doubleScanAllowed = FALSE; +#else + if (pMga->SecondCrtc == TRUE) + clockRanges->interlaceAllowed = FALSE; + else + clockRanges->interlaceAllowed = TRUE; clockRanges->doubleScanAllowed = TRUE; +#endif clockRanges->ClockMulFactor = 1; clockRanges->ClockDivFactor = 1; @@ -1788,6 +1994,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) i = 1; } if (i == -1) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Validate Modes Failed\n"); MGAFreeRec(pScrn); return FALSE; } @@ -1800,6 +2007,86 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) MGAFreeRec(pScrn); return FALSE; } + /*******************/ + /* ADDED BY MATROX */ + /*******************/ +#ifdef USEMGAHAL + if(pMga->SecondCrtc == FALSE) { + ulBOARDHANDLESize = MGAGetBOARDHANDLESize(); + pMga->pBoard = (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + ulBOARDHANDLESize); + pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); + /* Fill the client part */ + pMga->pClientStruct->pMga = (MGAPtr) pMga; + + /* Determine the Frame buffer limit size */ + if((pMga->Chipset == PCI_CHIP_MGA1064 && pMga->ChipRev < 3) || + (pMga->Chipset == PCI_CHIP_MGA2064)) { + ucMgaBase2 = 0x14; + } else { + ucMgaBase2 = 0x10; + } +#if 0 + /* + * This is bad for cards where there is less physical memory than + * the PCI map size. + */ + ulOrgFBuffer = pciReadLong(pMga->PciTag,ucMgaBase2); + pciWriteLong(pMga->PciTag,ucMgaBase2,0xffffffff); + pMga->FbMapSize = pciReadLong(pMga->PciTag,ucMgaBase2); + pciWriteLong(pMga->PciTag,ucMgaBase2,ulOrgFBuffer); + pMga->FbMapSize = ~(pMga->FbMapSize & 0xfffffff0) + 1; +#endif + /* Open the matrox low level library */ + MGAMapMem(pScrn); + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); + MGAUnmapMem(pScrn); + pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); + MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); + /* copy the board handles */ + if(xf86IsEntityShared(pScrn->entityList[0])) { + pMgaEnt->pClientStruct = pMga->pClientStruct; + pMgaEnt->pBoard = pMga->pBoard; + pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo; + } + mgaModeInfo.flOutput = MGAMODEINFO_ANALOG1; +#if 1 + mgaModeInfo.ulDispWidth = pScrn->virtualX; + mgaModeInfo.ulDispHeight = pScrn->virtualY; +#else + mgaModeInfo.ulDispWidth = pScrn->modes->HDisplay; + mgaModeInfo.ulDispHeight = pScrn->modes->VDisplay; +#endif + mgaModeInfo.ulDeskWidth = pScrn->virtualX; + mgaModeInfo.ulDeskHeight = pScrn->virtualY; + mgaModeInfo.ulBpp = pScrn->bitsPerPixel; + mgaModeInfo.ulZoom = 1; + } else { /* Second CRTC && entity is shared */ + mgaModeInfo.flOutput = MGAMODEINFO_ANALOG2 | + MGAMODEINFO_SECOND_CRTC; +#if 1 + mgaModeInfo.ulDispWidth = pScrn->virtualX; + mgaModeInfo.ulDispHeight = pScrn->virtualY; +#else + mgaModeInfo.ulDispWidth = pScrn->modes->HDisplay; + mgaModeInfo.ulDispHeight = pScrn->modes->VDisplay; +#endif + mgaModeInfo.ulDeskWidth = pScrn->virtualX; + mgaModeInfo.ulDeskHeight = pScrn->virtualY; + mgaModeInfo.ulBpp = pScrn->bitsPerPixel; + mgaModeInfo.ulZoom = 1; + pMga->pBoard = pMgaEnt->pBoard; + pMga->pClientStruct = pMgaEnt->pClientStruct; + pMga->pMgaHwInfo = pMga->pMgaHwInfo; + } + if(MGAValidateMode(pMga->pBoard,&mgaModeInfo) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "MGAValidateMode found the mode to be invalid\n"); + return FALSE; + } + + pScrn->displayWidth = mgaModeInfo.ulFBPitch; + +#endif /* USEMGAHAL */ /* * Set the CRTC parameters for all of the modes based on the type @@ -1809,8 +2096,11 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) * driver and if the driver doesn't provide code to set them. They * are not pre-initialised at all. */ - xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); - +#ifdef USEMGAHAL + xf86SetCrtcForModes(pScrn, 0); +#else + xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); +#endif /* Set the current mode to the first in the list */ pScrn->currentMode = pScrn->modes; @@ -1869,43 +2159,73 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "YDstOrg is set to %d\n", pMga->YDstOrg); - pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel; + if(xf86IsEntityShared(pScrn->entityList[0])) { + if(pMga->SecondCrtc == FALSE) { + pMga->FbUsableSize = pMgaEnt->masterFbMapSize; + /* Allocate HW cursor buffer at the end of video ram */ + if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) { + if( pScrn->virtualY * pScrn->displayWidth * + pScrn->bitsPerPixel / 8 <= + pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) { + pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize; + pMga->FbCursorOffset = + pMgaEnt->masterFbMapSize - + pMga->Dac.CursorOffscreenMemSize; + } else { + pMga->HWCursor = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Too little offscreen memory for HW cursor; " + "using SW cursor\n"); + } + } + } else { /* Second CRTC */ + pMga->FbUsableSize = pMgaEnt->slaveFbMapSize; + pMga->HWCursor = FALSE; + } + } else { + pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel; + /* Allocate HW cursor buffer at the end of video ram */ + if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) { + if( pScrn->virtualY * pScrn->displayWidth * + pScrn->bitsPerPixel / 8 <= + pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) { + pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize; + pMga->FbCursorOffset = + pMga->FbMapSize - pMga->Dac.CursorOffscreenMemSize; + } else { + pMga->HWCursor = FALSE; + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "Too little offscreen memory for HW cursor; " + "using SW cursor\n"); + } + } + } /* * XXX This should be taken into account in some way in the mode valdation * section. */ - /* Allocate HW cursor buffer at the end of video ram */ - if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) { - if( pScrn->virtualY * pScrn->displayWidth * pScrn->bitsPerPixel / 8 <= - pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) { - pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize; - pMga->FbCursorOffset = - pMga->FbMapSize - pMga->Dac.CursorOffscreenMemSize; - } else { - pMga->HWCursor = FALSE; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Too little offscreen memory for HW cursor; using SW cursor\n"); - } - } /* Load the required framebuffer */ - if(pMga->Overlay8Plus24) { + if (pMga->Overlay8Plus24) { if (!xf86LoadSubModule(pScrn, "xf8_32bpp")) { MGAFreeRec(pScrn); return FALSE; } - xf86LoaderReqSymbols("cfb8_32ScreenInit", NULL); + reqSym = "cfb8_32ScreenInit"; } else { if (!xf86LoadSubModule(pScrn, "fb")) { MGAFreeRec(pScrn); return FALSE; } + reqSym = "fbScreenInit"; xf86LoaderReqSymbols("fbScreenInit", NULL); #ifdef RENDER xf86LoaderReqSymbols("fbPictureInit", NULL); #endif } + xf86LoaderReqSymbols(reqSym, NULL); + /* Load XAA if needed */ if (!pMga->NoAccel) { @@ -1942,7 +2262,43 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->CurrentLayout.weight.blue = pScrn->weight.blue; pMga->CurrentLayout.Overlay8Plus24 = pMga->Overlay8Plus24; pMga->CurrentLayout.mode = pScrn->currentMode; +#ifdef USEMGAHAL + /* Close the library after preinit */ + /* This needs to only happen after this board has completed preinit + * both times + */ + if(xf86IsEntityShared(pScrn->entityList[0])) { + /* Entity is shared make sure refcount == 2 */ + /* If ref count is 2 then reset it to 0 */ + if(pMgaEnt->refCount == 2) { + /* Both boards have done there initialization */ + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + pMgaEnt->refCount = 0; + } + } else { + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + } +#endif + xf86SetPrimInitDone(pScrn->entityList[0]); return TRUE; } @@ -2089,10 +2445,51 @@ MGASave(ScrnInfoPtr pScrn) MGAPtr pMga = MGAPTR(pScrn); MGARegPtr mgaReg = &pMga->SavedReg; +#ifdef USEMGAHAL + if(pMga->SecondCrtc == TRUE) return; + + if(pMga->pBoard != NULL) { + MGASaveVgaState(pMga->pBoard); + } +#endif + /* Only save text mode fonts/text for the primary card */ (*pMga->Save)(pScrn, vgaReg, mgaReg, pMga->Primary); } +#ifdef USEMGAHAL +/* Convert DisplayModeRec parameters in MGAMODEINFO parameters. */ +static void FillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + MGAPtr pMga = MGAPTR(pScrn); + pMga->pMgaModeInfo = (LPMGAMODEINFO) xalloc (sizeof(MGAMODEINFO)); + + pMga->pMgaModeInfo->flOutput = 0; + pMga->pMgaModeInfo->ulDispWidth = mode->HDisplay; + pMga->pMgaModeInfo->ulDispHeight = mode->VDisplay; + pMga->pMgaModeInfo->ulDeskWidth = pScrn->virtualX; + pMga->pMgaModeInfo->ulDeskHeight = pScrn->virtualY; + pMga->pMgaModeInfo->ulFBPitch = 0; + pMga->pMgaModeInfo->ulBpp = pScrn->bitsPerPixel; + pMga->pMgaModeInfo->ulZoom = 1; + pMga->pMgaModeInfo->flSignalMode = 0; + pMga->pMgaModeInfo->ulRefreshRate = 0; + pMga->pMgaModeInfo->ulHorizRate = 0; + pMga->pMgaModeInfo->ulPixClock = mode->Clock; + pMga->pMgaModeInfo->ulHFPorch = mode->HSyncStart - mode->HDisplay; + pMga->pMgaModeInfo->ulHSync = mode->HSyncEnd - mode->HSyncStart; + pMga->pMgaModeInfo->ulHBPorch = mode->HTotal - mode->HSyncEnd; + pMga->pMgaModeInfo->ulVFPorch = mode->VSyncStart - mode->VDisplay; + pMga->pMgaModeInfo->ulVSync = mode->VSyncEnd - mode->VSyncStart; + pMga->pMgaModeInfo->ulVBPorch = mode->VTotal - mode->VSyncEnd; + /* Use DstOrg directly */ + /* This is an offset in pixels not memory */ + pMga->pMgaModeInfo->ulDstOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8); + pMga->pMgaModeInfo->ulDisplayOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8); + pMga->pMgaModeInfo->ulPanXGran = 0; + pMga->pMgaModeInfo->ulPanYGran = 0; +} +#endif /* USEMGAHAL */ /* * Initialise a new mode. This is currently still using the old @@ -2123,13 +2520,57 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) vgaReg = &hwp->ModeReg; mgaReg = &pMga->ModeReg; +#ifdef USEMGAHAL + FillModeInfoStruct(pScrn,mode); + + if(pMga->SecondCrtc == TRUE) { + pMga->pMgaModeInfo->flOutput = MGAMODEINFO_ANALOG2 | + MGAMODEINFO_SECOND_CRTC | + MGAMODEINFO_FORCE_PITCH | + MGAMODEINFO_FORCE_DISPLAYORG; + } else { + pMga->pMgaModeInfo->flOutput = MGAMODEINFO_ANALOG1 | + MGAMODEINFO_FORCE_PITCH; + } + + pMga->pMgaModeInfo->ulFBPitch = pScrn->displayWidth; + if(MGAValidateMode(pMga->pBoard,pMga->pMgaModeInfo) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Invalid parameters\n"); + return FALSE; + } + + if(MGAValidateVideoParameters(pMga->pBoard,pMga->pMgaModeInfo) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Invalid parameters\n"); + return FALSE; + } +#endif /* USEMGAHAL */ + #ifdef XF86DRI if (pMga->directRenderingEnabled) { DRILock(screenInfo.screens[pScrn->scrnIndex], 0); } #endif + +#ifdef USEMGAHAL + if(MGASetMode(pMga->pBoard,pMga->pMgaModeInfo) != 0) { + return FALSE; + } + +#define outMGAdreg(reg, val) OUTREG8(RAMDAC_OFFSET + (reg), val) + +#define outMGAdac(reg, val) \ + (outMGAdreg(MGA1064_INDEX, reg), outMGAdreg(MGA1064_DATA, val)) + + if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) { + outMGAdac(MGA1064_CURSOR_BASE_ADR_LOW, pMga->FbCursorOffset >> 10); + outMGAdac(MGA1064_CURSOR_BASE_ADR_HI, pMga->FbCursorOffset >> 18); + } +#endif /* USEMGAHAL */ + +#ifndef USEMGAHAL (*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE); +#endif MGAStormSync(pScrn); MGAStormEngineInit(pScrn); @@ -2163,19 +2604,50 @@ MGARestore(ScrnInfoPtr pScrn) MGAPtr pMga = MGAPTR(pScrn); MGARegPtr mgaReg = &pMga->SavedReg; - if (pScrn->pScreen != NULL) - MGAStormSync(pScrn); + if (pScrn->pScreen != NULL) + MGAStormSync(pScrn); + + if(pMga->SecondCrtc == TRUE) return; /* Only restore text mode fonts/text for the primary card */ vgaHWProtect(pScrn, TRUE); - if (pMga->Primary) + if (pMga->Primary) { +#ifdef USEMGAHAL + if(pMga->pBoard != NULL) { + MGASetVgaMode(pMga->pBoard); + MGARestoreVgaState(pMga->pBoard); + } +#endif (*pMga->Restore)(pScrn, vgaReg, mgaReg, TRUE); - else + } else { vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); + } vgaHWProtect(pScrn, FALSE); } +/* Workaround for a G400 CRTC2 display problem */ +static void +MGACrtc2FillStrip(ScrnInfoPtr pScrn) +{ + MGAPtr pMga = MGAPTR(pScrn); + + if (pMga->NoAccel) { + /* Clears the whole screen, but ... */ + bzero(pMga->FbStart, + (pScrn->bitsPerPixel >> 3) * pScrn->displayWidth * pScrn->virtualY); + } else { + xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex); + pMga->RestoreAccelState(pScrn); + pMga->SetupForSolidFill(pScrn, 0, GXcopy, 0xFFFFFFFF); + pMga->SubsequentSolidFillRect(pScrn, pScrn->virtualX, 0, + pScrn->displayWidth - pScrn->virtualX, + pScrn->virtualY); + MGAStormSync(pScrn); + } +} + + /* Mandatory */ /* This gets called at the start of each server generation */ @@ -2191,6 +2663,8 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) VisualPtr visual; unsigned char *FBStart; int width, height, displayWidth; + MGAEntPtr pMgaEnt = NULL; + int f; /* * First get the ScrnInfoRec @@ -2200,6 +2674,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) hwp = VGAHWPTR(pScrn); pMga = MGAPTR(pScrn); MGAdac = &pMga->Dac; + /* Map the MGA memory and MMIO areas */ if (pMga->FBDev) { @@ -2210,6 +2685,51 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; } + if (xf86IsEntityShared(pScrn->entityList[0])) { + DevUnion *pPriv; + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex); + pMgaEnt = pPriv->ptr; + pMgaEnt->refCount++; +#ifdef USEMGAHAL + if(pMgaEnt->refCount == 1) { + pMga->pBoard = + (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + + MGAGetBOARDHANDLESize()); + pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); + /* Fill the client part */ + pMga->pClientStruct->pMga = (MGAPtr) pMga; + + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); + + pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); + MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); + /* Now copy these to the entitystructure */ + pMgaEnt->pClientStruct = pMga->pClientStruct; + pMgaEnt->pBoard = pMga->pBoard; + pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo; + } else { /* Ref count is 2 */ + pMga->pClientStruct = pMgaEnt->pClientStruct; + pMga->pBoard = pMgaEnt->pBoard; + pMga->pMgaHwInfo = pMgaEnt->pMgaHwInfo; + } +#endif /* USEMGAHAL */ + } else { +#ifdef USEMGAHAL + pMga->pBoard = + (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + + MGAGetBOARDHANDLESize()); + pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA)); + /* Fill the client part */ + pMga->pClientStruct->pMga = (MGAPtr) pMga; + + MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA)); + + pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO)); + MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo); +#endif /* USEMGAHAL */ + } + + /* Initialise the MMIO vgahw functions */ vgaHWSetMmioFuncs(hwp, pMga->IOBase, PORT_OFFSET); vgaHWGetIOBase(hwp); @@ -2238,7 +2758,11 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Darken the screen for aesthetic reasons and set the viewport */ - MGASaveScreen(pScreen, SCREEN_SAVER_ON); + if (pMga->SecondCrtc == TRUE) { + MGASaveScreenCrtc2(pScreen, SCREEN_SAVER_ON); + } else { + MGASaveScreen(pScreen, SCREEN_SAVER_ON); + } pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); /* @@ -2267,6 +2791,11 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; if (!miSetVisualTypes(24, TrueColorMask, pScrn->rgbBits, TrueColor)) return FALSE; + } else if (pMga->SecondCrtc) { + /* No DirectColor on the second head */ + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, + TrueColor)) + return FALSE; } else { if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; @@ -2313,27 +2842,29 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) * The DRI does not work when textured video is enabled at this time. */ - if (!pMga->NoAccel && pMga->TexturedVideo != TRUE) + if (!pMga->NoAccel && pMga->TexturedVideo != TRUE && + pMga->SecondCrtc == FALSE) pMga->directRenderingEnabled = MGADRIScreenInit(pScreen); else pMga->directRenderingEnabled = FALSE; #endif - - if(pMga->Overlay8Plus24) { + + if (pMga->Overlay8Plus24) { ret = cfb8_32ScreenInit(pScreen, FBStart, width, height, pScrn->xDpi, pScrn->yDpi, displayWidth); } else { ret = fbScreenInit(pScreen, FBStart, width, height, - pScrn->xDpi, pScrn->yDpi, - displayWidth, pScrn->bitsPerPixel); + pScrn->xDpi, pScrn->yDpi, + displayWidth, pScrn->bitsPerPixel); #ifdef RENDER if (ret) fbPictureInit (pScreen, 0, 0); #endif } + if (!ret) return FALSE; @@ -2386,9 +2917,12 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* Initialize colormap layer. Must follow initialization of the default colormap */ + if (!pMga->SecondCrtc) + f = CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH; + else + f = CMAP_RELOAD_ON_MODE_SWITCH; if(!xf86HandleColormaps(pScreen, 256, 8, - (pMga->FBDev ? fbdevHWLoadPalette : MGAdac->LoadPalette), NULL, - CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH)) + (pMga->FBDev ? fbdevHWLoadPalette : MGAdac->LoadPalette), NULL, f)) return FALSE; if(pMga->Overlay8Plus24) { /* Must come after colormap initialization */ @@ -2436,14 +2970,20 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n"); } + if (xf86IsEntityShared(pScrn->entityList[0]) && pMga->SecondCrtc == FALSE) + pMgaEnt->directRenderingEnabled = pMga->directRenderingEnabled; + pMga->have_quiescense = 1; #endif pScrn->memPhysBase = pMga->FbAddress; pScrn->fbOffset = pMga->YDstOrg * (pScrn->bitsPerPixel / 8); - MGAInitVideo(pScreen); - - pScreen->SaveScreen = MGASaveScreen; + if(pMga->SecondCrtc == TRUE) { + pScreen->SaveScreen = MGASaveScreenCrtc2; + } else { + pScreen->SaveScreen = MGASaveScreen; + MGAInitVideo(pScreen); + } /* Wrap the current CloseScreen function */ pMga->CloseScreen = pScreen->CloseScreen; @@ -2454,6 +2994,11 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); } + /* For the second head, work around display problem. */ + if (pMga->SecondCrtc) { + MGACrtc2FillStrip(pScrn); + } + /* Done */ return TRUE; } @@ -2512,6 +3057,33 @@ MGAAdjustFrame(int scrnIndex, int x, int y, int flags) } +#define C2STARTADD0 0x3C28 + +void +MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn; + int Base; + MGAFBLayout *pLayout; + MGAPtr pMga; + + pScrn = xf86Screens[scrnIndex]; + pMga = MGAPTR(pScrn); + pLayout = &pMga->CurrentLayout; + + if(pMga->ShowCache && y && pScrn->vtSema) + y += pScrn->virtualY - 1; + + /* 3-85 c2offset + * 3-93 c2startadd0 + * 3-96 c2vcount + */ + + Base = (y * pLayout->displayWidth + x) * pLayout->bitsPerPixel >> 3; + Base += pMga->DstOrg; + Base &= 0x01ffffc0; + OUTREG(C2STARTADD0, Base); +} /* * This is called when VT switching back to the X server. Its job is @@ -2525,12 +3097,15 @@ static Bool MGAEnterVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + MGAPtr pMga; #ifdef XF86DRI ScreenPtr pScreen; - MGAPtr pMGA; +#endif - pMGA = MGAPTR(pScrn); - if (pMGA->directRenderingEnabled) { + pMga = MGAPTR(pScrn); + +#ifdef XF86DRI + if (pMga->directRenderingEnabled) { pScreen = screenInfo.screens[scrnIndex]; DRIUnlock(pScreen); } @@ -2539,6 +3114,12 @@ MGAEnterVT(int scrnIndex, int flags) if (!MGAModeInit(pScrn, pScrn->currentMode)) return FALSE; MGAAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + /* For the second head, work around display problem. */ + if (pMga->SecondCrtc) { + MGACrtc2FillStrip(pScrn); + } + return TRUE; } @@ -2610,7 +3191,8 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; vgaHWPtr hwp = VGAHWPTR(pScrn); MGAPtr pMga = MGAPTR(pScrn); - + MGAEntPtr pMgaEnt = NULL; + if (pScrn->vtSema) { if (pMga->FBDev) { fbdevHWRestore(pScrn); @@ -2628,7 +3210,43 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) pMga->directRenderingEnabled=FALSE; } #endif - + + if (xf86IsEntityShared(pScrn->entityList[0])) { + DevUnion *pPriv; + pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex); + pMgaEnt = pPriv->ptr; + pMgaEnt->refCount--; + } + +#ifdef USEMGAHAL + if(xf86IsEntityShared(pScrn->entityList[0])) { + if(pMgaEnt->refCount == 0) { + /* Both boards have closed there screen */ + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + } + } else { + MGACloseLibrary(pMga->pBoard); + + if (pMga->pBoard) + xfree(pMga->pBoard); + if (pMga->pClientStruct) + xfree(pMga->pClientStruct); + if (pMga->pMgaModeInfo) + xfree(pMga->pMgaModeInfo); + if (pMga->pMgaHwInfo) + xfree(pMga->pMgaHwInfo); + } +#endif /* USEMGAHAL */ + if (pMga->AccelInfoRec) XAADestroyInfoRec(pMga->AccelInfoRec); if (pMga->CursorInfoRec) @@ -2649,6 +3267,8 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) if (xf86IsPc98()) outb(0xfac, 0x00); + xf86ClearPrimInitDone(pScrn->entityList[0]); + if(pMga->BlockHandler) pScreen->BlockHandler = pMga->BlockHandler; @@ -2680,6 +3300,8 @@ static int MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) { int lace; + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + MGAPtr pMga = MGAPTR(pScrn); lace = 1 + ((mode->Flags & V_INTERLACE) != 0); @@ -2691,6 +3313,17 @@ MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) (mode->CrtcVSyncStart <= 4096 * lace) && (mode->CrtcVSyncEnd <= 4096 * lace) && (mode->CrtcVTotal <= 4096 * lace)) { + + /* Can't have horizontal panning for second head of G400 */ + if (pMga->SecondCrtc) { + if (flags == MODECHECK_FINAL) { + if (pMga->allowedWidth == 0) + pMga->allowedWidth = pScrn->virtualX; + if (mode->HDisplay != pMga->allowedWidth) + return(MODE_ONE_WIDTH); + } + } + return(MODE_OK); } else { return(MODE_BAD); @@ -2701,6 +3334,36 @@ MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) /* Do screen blanking */ /* Mandatory */ +#define MGAREG_C2CTL 0x3c10 + +static Bool +MGASaveScreenCrtc2(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = NULL; + MGAPtr pMga = NULL; + Bool on; + CARD32 tmp; + + on = xf86IsUnblank(mode); + + if (on) + SetTimeSinceLastInputEvent(); + if (pScreen != NULL) + pScrn = xf86Screens[pScreen->myNum]; + + if (pScrn != NULL) + pMga = MGAPTR(pScrn); + + if(pMga != NULL && pScrn->vtSema) { + tmp = INREG(MGAREG_C2CTL); + tmp &= ~0x00000008; + if (!on) tmp |= 0x0000008; + OUTREG(MGAREG_C2CTL, tmp); + } + + return TRUE; +} + static Bool MGASaveScreen(ScreenPtr pScreen, int mode) { @@ -2721,8 +3384,6 @@ MGADisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, MGAPtr pMga = MGAPTR(pScrn); unsigned char seq1 = 0, crtcext1 = 0; -ErrorF("MGADisplayPowerManagementSet: %d\n", PowerManagementMode); - switch (PowerManagementMode) { case DPMSModeOn: diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h index 12538fd3c..3f38943ee 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h @@ -429,6 +429,9 @@ #define MGAREG_DWGSYNC 0x2c4c +#define MGAREG_AGP_PLL 0x1e4c +#define AGP_PLL_agp2xpllen_enable 0x1 +#define AGP_PLL_agp2xpllen_disable 0x0 #endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile index 8bd933bbf..e6bdf32af 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile @@ -1,4 +1,4 @@ -XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile,v 1.8 2000/06/17 00:03:21 martin Exp $ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile,v 1.9 2000/09/20 00:09:26 keithp Exp $ XCOMM XCOMM This is the Imakefile for the ATI Rage 128 (r128) and XCOMM the ATI Radeon (radeon) driver. @@ -47,7 +47,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ -I$(XF86SRC)/int10 -I$(SERVERSRC)/Xext \ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ -I$(EXTINCSRC) -I$(XF86SRC)/xf24_32bpp \ - $(DRIINCLUDES) + $(DRIINCLUDES) -I$(SERVERSRC)/render #endif DEFINES = $(DRIDEFINES) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c index 5c6f33673..0a1512d9c 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c @@ -122,8 +122,6 @@ const char *fbdevHWSymbols[] = { NULL }; -#if 0 - /* Not used until DDC is supported. */ const char *ddcSymbols[] = { "xf86PrintEDID", "xf86DoEDID_DDC1", @@ -131,13 +129,6 @@ const char *ddcSymbols[] = { NULL }; -const char *i2cSymbols[] = { - "xf86CreateI2CBusRec", - "xf86I2CBusInit", - NULL -}; -#endif - #ifdef XFree86LOADER #ifdef USE_FB static const char *fbSymbols[] = { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h index bcb2d80e7..1f26edb5c 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.11 2000/08/04 16:13:32 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.12 2000/09/13 15:47:32 martin Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., @@ -179,7 +179,6 @@ typedef struct { unsigned char *MMIO; /* Map of MMIO region */ unsigned char *FB; /* Map of frame buffer */ - CARD8 *VBIOS; /* Video BIOS pointer */ CARD32 MemCntl; CARD32 BusCntl; @@ -188,6 +187,7 @@ typedef struct { Bool HasPanelRegs; /* Current chip can connect to a FP */ Bool CRTOnly; /* Only use External CRT instead of FP */ + CARD8 *VBIOS; /* Video BIOS for mode validation on FPs */ int FPBIOSstart; /* Start of the flat panel info */ /* Computed values for FPs */ @@ -204,7 +204,6 @@ typedef struct { Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ - I2CBusPtr i2c; XAAInfoRecPtr accel; Bool accelOn; xf86CursorInfoPtr cursor; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c index 4d0ab433e..2f7b28187 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c,v 1.13 2000/06/26 05:41:32 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c,v 1.14 2000/08/24 22:20:17 tsi Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., @@ -791,6 +791,7 @@ static void R128SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) x11perf -putimage100 2150.0/sec 1170.0/sec x11perf -putimage500 108.0/sec 49.8/sec */ +#if R128_IMAGEWRITE static void R128SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, @@ -911,6 +912,7 @@ static void R128SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) } } } +#endif /* Initialize the acceleration hardware. */ void R128EngineInit(ScrnInfoPtr pScrn) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c index 380fc0c9c..9aea26df5 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c,v 1.4 2000/06/26 05:41:32 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c,v 1.5 2000/08/25 13:42:37 dawes Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c index e39828343..50a982597 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.40 2000/08/04 16:13:32 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.46 2000/09/20 00:09:26 keithp Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., @@ -120,6 +120,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_sarea.h" #endif +#ifdef RENDER +#include "picturestr.h" +#endif /* Driver data structures */ #include "ati2.h" #include "r128.h" @@ -245,10 +248,7 @@ R128RAMRec R128RAM[] = { /* Memory Specifications extern const char *vgahwSymbols[]; extern const char *fbdevHWSymbols[]; -#if 0 extern const char *ddcSymbols[]; -extern const char *i2cSymbols[]; -#endif /* Allocate our private R128InfoRec. */ static Bool R128GetRec(ScrnInfoPtr pScrn) @@ -977,33 +977,19 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn) static Bool R128PreInitDDC(ScrnInfoPtr pScrn) { - /* FIXME: DDC support goes here. */ -#if 0 - /* Using the GPIO_MONID register for DDC2 - does not appear to work as expected. - Hence, the implementation of DDC is - deferred. */ R128InfoPtr info = R128PTR(pScrn); - Bool ret = TRUE; - + vbeInfoPtr pVbe; + if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE; xf86LoaderReqSymLists(ddcSymbols, NULL); - if (!xf86LoadSubModule(pScrn, "i2c")) return FALSE; - xf86LoaderReqSymLists(i2cSymbols, NULL); - - R128MapMMIO(pScrn); - if (!R128I2CInit(pScrn)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I2C initialization failed\n"); - ret = FALSE; - } else { - xf86SetDDCProperties(pScrn,xf86PrintEDID( - xf86DoEDID_DDC2(pScrn->scrnIndex, info->i2c))); - } - R128UnmapMMIO(pScrn); - return ret; -#else - return TRUE; -#endif + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,info->pEnt->index); + if (!pVbe) return FALSE; + + xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL))); + return TRUE; + } else + return FALSE; } /* This is called by R128PreInit to initialize gamma correction. */ @@ -1094,6 +1080,11 @@ static Bool R128PreInitModes(ScrnInfoPtr pScrn) #endif if (mod && !xf86LoadSubModule(pScrn, mod)) return FALSE; xf86LoaderReqSymbols(Sym, NULL); +#ifdef USE_FB +#ifdef RENDER + xf86LoaderReqSymbols("fbPictureInit", NULL); +#endif +#endif info->CurrentLayout.displayWidth = pScrn->displayWidth; info->CurrentLayout.mode = pScrn->currentMode; @@ -1471,7 +1462,8 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; - + miSetPixmapDepths (); + #ifdef XF86DRI /* Setup DRI after visuals have been established, but before cfbScreenInit is @@ -1511,6 +1503,9 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, pScrn->bitsPerPixel)) return FALSE; +#ifdef RENDER + fbPictureInit (pScreen, 0, 0); +#endif #else switch (pScrn->bitsPerPixel) { case 8: diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h index 890cf0004..8dc4c44a1 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.11 2000/07/01 01:40:46 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.13 2000/09/13 15:47:32 martin Exp $ */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h index eb82611a1..600f99bc5 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h @@ -215,7 +215,6 @@ typedef struct { Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ - I2CBusPtr i2c; XAAInfoRecPtr accel; Bool accelOn; xf86CursorInfoPtr cursor; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c index a04f0adad..6821d48ed 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c @@ -668,6 +668,7 @@ static void RADEONSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) } } +#if RADEON_IMAGEWRITE /* Setup for XAA indirect image write. */ static void RADEONSetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, @@ -780,6 +781,7 @@ static void RADEONSubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) } } } +#endif /* Initialize the acceleration hardware. */ void RADEONEngineInit(ScrnInfoPtr pScrn) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c index b3f8ce6b7..fe9ebd382 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c @@ -237,10 +237,7 @@ RADEONRAMRec RADEONRAM[] = { /* Memory Specifications extern const char *vgahwSymbols[]; extern const char *fbdevHWSymbols[]; -#if 0 extern const char *ddcSymbols[]; -extern const char *i2cSymbols[]; -#endif /* Allocate our private RADEONInfoRec. */ static Bool RADEONGetRec(ScrnInfoPtr pScrn) @@ -971,33 +968,19 @@ static Bool RADEONPreInitConfig(ScrnInfoPtr pScrn) static Bool RADEONPreInitDDC(ScrnInfoPtr pScrn) { - /* FIXME: DDC support goes here. */ -#if 0 - /* Using the GPIO_MONID register for DDC2 - does not appear to work as expected. - Hence, the implementation of DDC is - deferred. */ RADEONInfoPtr info = RADEONPTR(pScrn); - Bool ret = TRUE; - + vbeInfoPtr pVbe; + if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE; xf86LoaderReqSymLists(ddcSymbols, NULL); - if (!xf86LoadSubModule(pScrn, "i2c")) return FALSE; - xf86LoaderReqSymLists(i2cSymbols, NULL); - - RADEONMapMMIO(pScrn); - if (!RADEONI2CInit(pScrn)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I2C initialization failed\n"); - ret = FALSE; - } else { - xf86SetDDCProperties(pScrn,xf86PrintEDID( - xf86DoEDID_DDC2(pScrn->scrnIndex, info->i2c))); - } - RADEONUnmapMMIO(pScrn); - return ret; -#else - return TRUE; -#endif + if (xf86LoadSubModule(pScrn, "vbe")) { + pVbe = VBEInit(NULL,info->pEnt->index); + if (!pVbe) return FALSE; + + xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL))); + return TRUE; + } else + return FALSE; } /* This is called by RADEONPreInit to initialize gamma correction. */ 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 c0c3f1433..87960acf3 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c @@ -161,12 +161,22 @@ TDFXSetLFBConfig(TDFXPtr pTDFX) { } else { int chip; int stride, bits; + int TileAperturePitch, lg2TileAperturePitch; if (pTDFX->cpp==2) stride=pTDFX->stride; else stride=4*pTDFX->stride/pTDFX->cpp; bits=pTDFX->backOffset>>12; + for (lg2TileAperturePitch = 0, TileAperturePitch = 1024; + (lg2TileAperturePitch < 5) && + TileAperturePitch < stride; + lg2TileAperturePitch += 1, TileAperturePitch <<= 1); +#if 0 + fprintf(stderr, "Using %d (== lg2(%d)-10) for tile aperture pitch\n", + lg2TileAperturePitch, TileAperturePitch); + fprintf(stderr, "stride == %d\n", stride); +#endif for (chip=0; chip<pTDFX->numChips; chip++) { TDFXWriteChipLongMMIO(pTDFX, chip, LFBMEMORYCONFIG, (bits&0x1FFF) | - SST_RAW_LFB_ADDR_STRIDE_4K | + SST_RAW_LFB_ADDR_STRIDE(lg2TileAperturePitch) | ((bits&0x6000)<<10) | ((stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT); } 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 da906ecde..201216076 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c @@ -643,7 +643,6 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) ClockRangePtr clockRanges; int i; MessageType from; - char *mod=0, *reqSym=0; int flags24; rgb defaultWeight = {0, 0, 0}; pciVideoPtr match; @@ -668,6 +667,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) if (pTDFX->pEnt->location.type != BUS_PCI) return FALSE; + if (flags & PROBE_DETECT) { + TDFXProbeDDC(pScrn, pTDFX->pEnt->index); + return TRUE; + } + /* The vgahw module should be loaded here when needed */ if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; @@ -1200,7 +1204,10 @@ CalcPLL(int freq, int *f_out, int isBanshee) { maxm=24; } else { minm=1; - maxm=64; + maxm=57; /* This used to be 64, alas it seems the last 8 (funny that ?) + * values cause jittering at lower resolutions. I've not done + * any calculations to what the adjustment affects clock ranges, + * but I can still run at 1600x1200@75Hz */ } for (n=1; n<256; n++) { f_cur=REFFREQ*(n+2); @@ -1609,15 +1616,6 @@ static void allocateMemory(ScrnInfoPtr pScrn) { pTDFX = TDFXPTR(pScrn); pTDFX->stride = pScrn->displayWidth*pTDFX->cpp; - /* Layout the memory. Start with all the ram */ - memRemaining=pScrn->videoRam<<10; - /* Remove the cursor space */ - memRemaining-=4096; - /* Remove the main screen and offscreen pixmaps */ - memRemaining-=pTDFX->stride*(pScrn->virtualY+128); - /* Remove one scanline for page alignment */ - memRemaining-=4095; - /* Remove the back and Z buffers */ if (pTDFX->cpp!=3) { screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, TRUE, pTDFX->cpp); @@ -1627,41 +1625,77 @@ static void allocateMemory(ScrnInfoPtr pScrn) { screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, TRUE, 4); } - memRemaining-=screenSizeInTiles*2; - - /* Give all the rest to textures, rounded down to a page */ - texSize=memRemaining&~0xFFF; - - /* Make sure fifo has CMDFIFO_PAGES<fifoSize<255 pages */ - if (memRemaining-texSize<CMDFIFO_PAGES<<12) - texSize=(memRemaining-(CMDFIFO_PAGES<<12))&~0xFFF; - /* Fifo uses the remaining space up to 255 pages */ - fifoSize = (memRemaining-texSize)&~0xFFF; - if (fifoSize>255<<12) fifoSize=255<<12; - - /* Assign the variables */ - /* Cursor */ - pTDFX->cursorOffset=0; /* Size 1024 bytes */ - - /* Point the fifo at the first page */ + memRemaining=((pScrn->videoRam<<10) - 1) &~ 0xFFF; + /* Note that a page is 4096 bytes, and a */ + /* tile is 32 x 128 = 4096 bytes. So, */ + /* page and tile boundaries are the same */ + /* Place the depth offset first, forcing */ + /* it to be on an *odd* page boundary. */ + pTDFX->depthOffset = (memRemaining - screenSizeInTiles) &~ 0xFFF; + if ((pTDFX->depthOffset & (0x1 << 12)) == 0) { +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Changing depth offset from 0x%08x to 0x%08x\n", + pTDFX->depthOffset, + pTDFX->depthOffset - (0x1 << 12)); +#endif + pTDFX->depthOffset -= (0x1 << 12); + } + /* Now, place the back buffer, forcing it */ + /* to be on an *even* page boundary. */ + pTDFX->backOffset = (pTDFX->depthOffset - screenSizeInTiles) &~ 0xFFF; + if (pTDFX->backOffset & (0x1 << 12)) { +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Changing back offset from 0x%08x to 0x%08x\n", + pTDFX->backOffset, + pTDFX->backOffset - (0x1 << 12)); +#endif + pTDFX->backOffset -= (0x1 << 12); + } + /* Now, place the front buffer, forcing */ + /* it to be on a page boundary too, just */ + /* for giggles. */ + pTDFX->fbOffset + = (pTDFX->backOffset - (pScrn->virtualY+128)*pTDFX->stride) &~ 0xFFF; + /* Give the cmd fifo at least */ + /* CMDFIFO_PAGES pages, but no more than */ + /* 255. */ + 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; + pTDFX->texSize = texSize; pTDFX->fifoOffset = 4096; pTDFX->fifoSize = fifoSize; - - /* Textures */ - pTDFX->texOffset = pTDFX->fifoOffset+fifoSize; - pTDFX->texSize = texSize; - - /* Frame buffer */ - pTDFX->fbOffset=pTDFX->texOffset+pTDFX->texSize; - - /* Back buffer */ - pTDFX->backOffset=pTDFX->fbOffset+(pScrn->virtualY+128)*pTDFX->stride; - /* Round off to a page */ - pTDFX->backOffset=(pTDFX->backOffset+4095)&~0xFFF; - - /* Depth buffer */ - pTDFX->depthOffset=pTDFX->backOffset+screenSizeInTiles; - + pTDFX->cursorOffset = 0; +#if 0 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Cursor Offset: [0x%08X,0x%08X)\n", + pTDFX->cursorOffset, + pTDFX->cursorOffset+1024); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Fifo Offset: [0x%08X, 0x%08X)\n", + pTDFX->fifoOffset, + pTDFX->fifoOffset+fifoSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Texture Offset: [0x%08X, 0x%08X)\n", + pTDFX->texOffset, + pTDFX->texOffset + texSize); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Front Buffer Offset: [0x%08X, 0x%08X)\n", + pTDFX->fbOffset, + pTDFX->fbOffset + (pScrn->virtualY+128)*pTDFX->stride); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "BackOffset: [0x%08X, 0x%08X)\n", + pTDFX->backOffset, + pTDFX->backOffset+screenSizeInTiles); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "DepthOffset: [0x%08X, 0x%08X)\n", + pTDFX->depthOffset, + pTDFX->depthOffset+screenSizeInTiles); +#endif /* 0/1 */ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Textures Memory %0.02f MB\n", (float)texSize/1024.0/1024.0); } |