diff options
author | Felix Kuehling <fxkuehl@gmx.de> | 2005-01-10 23:11:53 +0000 |
---|---|---|
committer | Felix Kuehling <fxkuehl@gmx.de> | 2005-01-10 23:11:53 +0000 |
commit | d62d010ca8590d99d4150f7b00999e619a6aaac3 (patch) | |
tree | 16abd9b2033fe0cf362882e2f5fe9dda6aeaa036 /src/savage_dri.c | |
parent | 303bc2a7df00aadc13d747d6c240ca3d693cad4e (diff) |
- Support for PCI Savages: on PCI cards don't run SAVAGEDRIAgpInit, add PCI
DMA buffers instead of AGP buffers. Set dma_type properly in
SAVAGEDRIKernelInit.
- Something's still wrong with ShadowStatus on the PCI card I'm testing
here. Probably a DRM issue.
- Fixed error handling. Call SAVAGEDRICloseScreen instead of
DRICloseScreen.
- Added AGP/PCI detection (copied from the radeon driver).
Diffstat (limited to 'src/savage_dri.c')
-rw-r--r-- | src/savage_dri.c | 121 |
1 files changed, 69 insertions, 52 deletions
diff --git a/src/savage_dri.c b/src/savage_dri.c index d42f895..9af6780 100644 --- a/src/savage_dri.c +++ b/src/savage_dri.c @@ -733,7 +733,7 @@ static Bool SAVAGEDRIAgpInit(ScreenPtr pScreen) SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; unsigned long mode; unsigned int vendor, device; - int ret, count; + int ret; /*int size,numbuffer,i; savageAgpBufferPtr agpbuffer;*/ @@ -829,18 +829,6 @@ static Bool SAVAGEDRIAgpInit(ScreenPtr pScreen) "[agp] DMA buffers mapped at 0x%08lx\n", (unsigned long)pSAVAGEDRIServer->buffers.map ); */ - count = drmAddBufs( psav->drmFD, - SAVAGE_NUM_BUFFERS, SAVAGE_BUFFER_SIZE, - DRM_AGP_BUFFER, pSAVAGEDRIServer->buffers.offset ); - if ( count <= 0 ) { - xf86DrvMsg( pScrn->scrnIndex, X_INFO, - "[drm] failure adding %d %d byte DMA buffers (%d)\n", - SAVAGE_NUM_BUFFERS, SAVAGE_BUFFER_SIZE, count ); - return FALSE; - } - xf86DrvMsg( pScreen->myNum, X_INFO, - "[drm] Added %d %d byte DMA buffers\n", - count, SAVAGE_BUFFER_SIZE ); /* AGP textures */ @@ -976,6 +964,47 @@ static Bool SAVAGEDRIMapInit( ScreenPtr pScreen ) return TRUE; } +static Bool SAVAGEDRIBuffersInit( ScreenPtr pScreen ) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SavagePtr psav = SAVPTR(pScrn); + SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; + int count; + + if ( psav->IsPCI ) { + count = drmAddBufs( psav->drmFD, + SAVAGE_NUM_BUFFERS, SAVAGE_BUFFER_SIZE, + 0, 0 ); + } else { + count = drmAddBufs( psav->drmFD, + SAVAGE_NUM_BUFFERS, SAVAGE_BUFFER_SIZE, + DRM_AGP_BUFFER, pSAVAGEDRIServer->buffers.offset ); + } + if ( count <= 0 ) { + xf86DrvMsg( pScrn->scrnIndex, X_INFO, + "[drm] failure adding %d %d byte DMA buffers (%d)\n", + SAVAGE_NUM_BUFFERS, SAVAGE_BUFFER_SIZE, count ); + return FALSE; + } + xf86DrvMsg( pScreen->myNum, X_INFO, + "[drm] Added %d %d byte DMA buffers\n", + count, SAVAGE_BUFFER_SIZE ); + + /* not needed in the server + pSAVAGEDRIServer->drmBuffers = drmMapBufs( psav->drmFD ); + if ( !pSAVAGEDRIServer->drmBuffers ) { + xf86DrvMsg( pScreen->myNum, X_ERROR, + "[drm] Failed to map DMA buffers list\n" ); + return FALSE; + } + xf86DrvMsg( pScreen->myNum, X_INFO, + "[drm] Mapped %d DMA buffers\n", + pSAVAGEDRIServer->drmBuffers->count ); + */ + + return TRUE; +} + static Bool SAVAGEDRIKernelInit( ScreenPtr pScreen ) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; @@ -992,7 +1021,7 @@ static Bool SAVAGEDRIKernelInit( ScreenPtr pScreen ) init.cob_size = psav->cobSize/4; /* size in 32-bit entries */ init.bci_threshold_lo = psav->bciThresholdLo; init.bci_threshold_hi = psav->bciThresholdHi; - init.dma_type = SAVAGE_DMA_AGP; /* PCI support will be added soon */ + init.dma_type = psav->IsPCI ? SAVAGE_DMA_PCI : SAVAGE_DMA_AGP; init.fb_bpp = pScrn->bitsPerPixel; init.front_offset = pSAVAGEDRIServer->frontOffset; @@ -1021,28 +1050,6 @@ static Bool SAVAGEDRIKernelInit( ScreenPtr pScreen ) return TRUE; } -#if 0 -static Bool SAVAGEDRIBuffersInit( ScreenPtr pScreen ) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - SavagePtr psav = SAVPTR(pScrn); - SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; - - - pSAVAGEDRIServer->drmBuffers = drmMapBufs( psav->drmFD ); - if ( !pSAVAGEDRIServer->drmBuffers ) { - xf86DrvMsg( pScreen->myNum, X_ERROR, - "[drm] Failed to map DMA buffers list\n" ); - return FALSE; - } - xf86DrvMsg( pScreen->myNum, X_INFO, - "[drm] Mapped %d DMA buffers\n", - pSAVAGEDRIServer->drmBuffers->count ); - - return TRUE; -} -#endif - Bool SAVAGEDRIScreenInit( ScreenPtr pScreen ) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; @@ -1271,18 +1278,30 @@ Bool SAVAGEDRIScreenInit( ScreenPtr pScreen ) } #endif - if ( !SAVAGEDRIAgpInit( pScreen ) ) { - DRICloseScreen( pScreen ); - return FALSE; + if ( !psav->IsPCI && !SAVAGEDRIAgpInit( pScreen ) ) { + /* + SAVAGEDRICloseScreen( pScreen ); + return FALSE; + */ + psav->IsPCI = TRUE; + xf86DrvMsg( pScrn->scrnIndex, X_WARNING, + "[agp] AGP failed to initialize -- falling back to PCI mode.\n"); + xf86DrvMsg( pScrn->scrnIndex, X_WARNING, + "[agp] Make sure you have the agpgart kernel module loaded.\n"); } if ( !SAVAGEDRIMapInit( pScreen ) ) { - DRICloseScreen( pScreen ); + SAVAGEDRICloseScreen( pScreen ); + return FALSE; + } + + if ( !SAVAGEDRIBuffersInit( pScreen ) ) { + SAVAGEDRICloseScreen( pScreen ); return FALSE; } if ( !SAVAGEInitVisualConfigs( pScreen ) ) { - DRICloseScreen( pScreen ); + SAVAGEDRICloseScreen( pScreen ); return FALSE; } xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[dri] visual configs initialized\n" ); @@ -1320,14 +1339,6 @@ Bool SAVAGEDRIFinishScreenInit( ScreenPtr pScreen ) return FALSE; } -/* no dma...... */ -#if 0 - if ( !SAVAGEDRIBuffersInit( pScreen ) ) { - SAVAGEDRICloseScreen( pScreen ); - return FALSE; - } -#endif - pSAVAGEDRI->chipset = psav->Chipset; pSAVAGEDRI->width = pScrn->virtualX; pSAVAGEDRI->height = pScrn->virtualY; @@ -1533,7 +1544,11 @@ void SAVAGEDRICloseScreen( ScreenPtr pScreen ) drmUnmap( pSAVAGEDRIServer->registers.map, pSAVAGEDRIServer->registers.size ); pSAVAGEDRIServer->registers.map = NULL; } - + + if ( pSAVAGEDRIServer->aperture.map ) { + drmUnmap( pSAVAGEDRIServer->aperture.map, pSAVAGEDRIServer->aperture.size ); + pSAVAGEDRIServer->aperture.map = NULL; + } if ( pSAVAGEDRIServer->agpTextures.map ) { drmUnmap( pSAVAGEDRIServer->agpTextures.map, @@ -1547,15 +1562,17 @@ void SAVAGEDRICloseScreen( ScreenPtr pScreen ) if (pSAVAGEDRIServer->registers.handle) drmRmMap(psav->drmFD,pSAVAGEDRIServer->registers.handle); + if (pSAVAGEDRIServer->aperture.handle) + drmRmMap(psav->drmFD,pSAVAGEDRIServer->registers.handle); + if (pSAVAGEDRIServer->agpTextures.handle) drmRmMap(psav->drmFD,pSAVAGEDRIServer->agpTextures.handle); -/* no DMA now.... */ -#if 0 if ( pSAVAGEDRIServer->buffers.map ) { drmUnmap( pSAVAGEDRIServer->buffers.map, pSAVAGEDRIServer->buffers.size ); pSAVAGEDRIServer->buffers.map = NULL; } +#if 0 if ( pSAVAGEDRIServer->primary.map ) { drmUnmap( pSAVAGEDRIServer->primary.map, pSAVAGEDRIServer->primary.size ); pSAVAGEDRIServer->primary.map = NULL; |