diff options
author | Ian Romanick <idr@us.ibm.com> | 2005-06-07 23:20:02 +0000 |
---|---|---|
committer | Ian Romanick <idr@us.ibm.com> | 2005-06-07 23:20:02 +0000 |
commit | c2e50aad47ce32f528dad2abee8b7a8df363c93e (patch) | |
tree | ca507a76a60a523a43d0cf3aa16987842f84c7f5 | |
parent | f4b3779cafdbcfeaddf6f55c4b2c67a667ab5d14 (diff) |
Numerous comments, clean-ups, and refactorings for the DRI portion of theXORG-6_8_99_11
MGA driver.
- Use mga_drm.h instead of mga_common.h. Due to this, all the MGA-specific
DRM names were changed to generic versions (i.e., drmMGALock became
drm_lock_t).
- Merge MGADRIMapInit into MGADRIAGPInit and rename the resulting function
MGADRIBootstrapDMA.
- Eliminate several unnecessary drmMap calls. The server has no need to map
MMIO space, primary DMA buffer space, secondary DMA buffer space, WARP
microcode space, or the DRM status page.
- Clarified which portions of the client / server DRI interface are no
longer used.
- Removed some unused fields from MGADRIServerPrivateRec.
- Bump MGA_PATCHLEVEL.
Reviewed by: Adam Jackson Reviewed by: Eric Anholt
-rw-r--r-- | src/mga.h | 2 | ||||
-rw-r--r-- | src/mga_dri.c | 182 | ||||
-rw-r--r-- | src/mga_dri.h | 49 |
3 files changed, 76 insertions, 157 deletions
@@ -153,7 +153,7 @@ void MGAdbg_outreg32(ScrnInfoPtr, int,int, char*); #define MGA_DRIVER_NAME "mga" #define MGA_MAJOR_VERSION 1 #define MGA_MINOR_VERSION 1 -#define MGA_PATCHLEVEL 1 +#define MGA_PATCHLEVEL 2 typedef struct { unsigned char ExtVga[6]; diff --git a/src/mga_dri.c b/src/mga_dri.c index 1506a7f..d919161 100644 --- a/src/mga_dri.c +++ b/src/mga_dri.c @@ -52,7 +52,7 @@ #include "mga_macros.h" #include "mga_dri.h" #include "mga_sarea.h" -#include "mga_common.h" +#include "mga_drm.h" #define _XF86DRI_SERVER_ #include "GL/glxtokens.h" @@ -70,7 +70,7 @@ #include "mga_macros.h" #include "mga_dri.h" -#include "mga_sarea.h" +#define DRM_MGA_IDLE_RETRY 2048 static char MGAKernelDriverName[] = "mga"; static char MGAClientDriverName[] = "mga"; @@ -343,27 +343,27 @@ static void MGADestroyContext( ScreenPtr pScreen, drm_context_t hwContext, static void MGAWaitForIdleDMA( ScrnInfoPtr pScrn ) { MGAPtr pMga = MGAPTR(pScrn); - drmMGALock lock; + drm_lock_t lock; int ret; int i = 0; - memset( &lock, 0, sizeof(drmMGALock) ); + memset( &lock, 0, sizeof(drm_lock_t) ); for (;;) { do { /* first ask for quiescent and flush */ - lock.flags = DRM_MGA_LOCK_QUIESCENT | DRM_MGA_LOCK_FLUSH; + lock.flags = DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH; do { ret = drmCommandWrite( pMga->drmFD, DRM_MGA_FLUSH, - &lock, sizeof( drmMGALock ) ); + &lock, sizeof( drm_lock_t ) ); } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY ); /* if it's still busy just try quiescent */ if ( ret == -EBUSY ) { - lock.flags = DRM_MGA_LOCK_QUIESCENT; + lock.flags = DRM_LOCK_QUIESCENT; do { ret = drmCommandWrite( pMga->drmFD, DRM_MGA_FLUSH, - &lock, sizeof( drmMGALock ) ); + &lock, sizeof( drm_lock_t ) ); } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY ); } } while ( ( ret == -EBUSY ) && ( i++ < MGA_TIMEOUT ) ); @@ -583,7 +583,17 @@ static unsigned int mylog2( unsigned int n ) return log2; } -static Bool MGADRIAgpInit(ScreenPtr pScreen) +/** + * Initialize DMA and secondary texture memory + * + * \todo + * The sizes used for the primary DMA buffer and the bin size and count for + * the secondary DMA buffers should be configurable from the xorg.conf. + * + * \todo + * Add support for PCI cards. + */ +static Bool MGADRIBootstrapDMA(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMga = MGAPTR(pScrn); @@ -700,18 +710,6 @@ static Bool MGADRIAgpInit(ScreenPtr pScreen) "[agp] WARP microcode handle = 0x%08lx\n", pMGADRIServer->warp.handle ); - if ( drmMap( pMga->drmFD, - pMGADRIServer->warp.handle, - pMGADRIServer->warp.size, - &pMGADRIServer->warp.map ) < 0 ) { - xf86DrvMsg( pScreen->myNum, X_ERROR, - "[agp] Could not map WARP microcode\n" ); - return FALSE; - } - xf86DrvMsg( pScreen->myNum, X_INFO, - "[agp] WARP microcode mapped at 0x%08lx\n", - (unsigned long)pMGADRIServer->warp.map ); - /* Primary DMA space */ if ( drmAddMap( pMga->drmFD, @@ -727,18 +725,6 @@ static Bool MGADRIAgpInit(ScreenPtr pScreen) "[agp] Primary DMA handle = 0x%08lx\n", pMGADRIServer->primary.handle ); - if ( drmMap( pMga->drmFD, - pMGADRIServer->primary.handle, - pMGADRIServer->primary.size, - &pMGADRIServer->primary.map ) < 0 ) { - xf86DrvMsg( pScreen->myNum, X_ERROR, - "[agp] Could not map primary DMA\n" ); - return FALSE; - } - xf86DrvMsg( pScreen->myNum, X_INFO, - "[agp] Primary DMA mapped at 0x%08lx\n", - (unsigned long)pMGADRIServer->primary.map ); - /* DMA buffers */ if ( drmAddMap( pMga->drmFD, @@ -754,18 +740,6 @@ static Bool MGADRIAgpInit(ScreenPtr pScreen) "[agp] DMA buffers handle = 0x%08lx\n", pMGADRIServer->buffers.handle ); - if ( drmMap( pMga->drmFD, - pMGADRIServer->buffers.handle, - pMGADRIServer->buffers.size, - &pMGADRIServer->buffers.map ) < 0 ) { - xf86DrvMsg( pScreen->myNum, X_ERROR, - "[agp] Could not map DMA buffers\n" ); - return FALSE; - } - xf86DrvMsg( pScreen->myNum, X_INFO, - "[agp] DMA buffers mapped at 0x%08lx\n", - (unsigned long)pMGADRIServer->buffers.map ); - count = drmAddBufs( pMga->drmFD, MGA_NUM_BUFFERS, MGA_BUFFER_SIZE, DRM_AGP_BUFFER, pMGADRIServer->buffers.offset ); @@ -793,22 +767,13 @@ static Bool MGADRIAgpInit(ScreenPtr pScreen) "[agp] Could not add agpTexture mapping\n" ); return FALSE; } -/* should i map it ? */ + xf86DrvMsg( pScreen->myNum, X_INFO, "[agp] agpTexture handle = 0x%08lx\n", pMGADRIServer->agpTextures.handle ); xf86DrvMsg( pScreen->myNum, X_INFO, "[agp] agpTexture size: %d kb\n", pMGADRIServer->agpTextures.size/1024 ); - return TRUE; -} - -static Bool MGADRIMapInit( ScreenPtr pScreen ) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - MGAPtr pMga = MGAPTR(pScrn); - MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo; - pMGADRIServer->registers.size = MGAIOMAPSIZE; if ( drmAddMap( pMga->drmFD, @@ -837,18 +802,6 @@ static Bool MGADRIMapInit( ScreenPtr pScreen ) "[drm] Status handle = 0x%08lx\n", pMGADRIServer->status.handle ); - if ( drmMap( pMga->drmFD, - pMGADRIServer->status.handle, - pMGADRIServer->status.size, - &pMGADRIServer->status.map ) < 0 ) { - xf86DrvMsg( pScreen->myNum, X_ERROR, - "[agp] Could not map status page\n" ); - return FALSE; - } - xf86DrvMsg( pScreen->myNum, X_INFO, - "[agp] Status page mapped at 0x%08lx\n", - (unsigned long)pMGADRIServer->status.map ); - return TRUE; } @@ -857,10 +810,10 @@ static Bool MGADRIKernelInit( ScreenPtr pScreen ) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMga = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo; - drmMGAInit init; + drm_mga_init_t init; int ret; - memset( &init, 0, sizeof(drmMGAInit) ); + memset( &init, 0, sizeof(drm_mga_init_t) ); init.func = MGA_INIT_DMA; init.sarea_priv_offset = sizeof(XF86DRISAREARec); @@ -905,19 +858,13 @@ static Bool MGADRIKernelInit( ScreenPtr pScreen ) init.texture_offset[1] = pMGADRIServer->agpTextures.handle; init.texture_size[1] = pMGADRIServer->agpTextures.size; - ret = drmCommandWrite( pMga->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit)); + ret = drmCommandWrite( pMga->drmFD, DRM_MGA_INIT, &init, sizeof(drm_mga_init_t)); if ( ret < 0 ) { xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[drm] Failed to initialize DMA! (%d)\n", ret ); return FALSE; } -#if 0 - /* FIXME: This is just here to clean up after the engine reset test - * in the kernel module. Please remove it later... - */ - pMga->GetQuiescence( pScrn ); -#endif return TRUE; } @@ -1215,33 +1162,11 @@ Bool MGADRIScreenInit( ScreenPtr pScreen ) } } -#if 0 - /* Calculate texture constants for AGP texture space. - * FIXME: move! - */ - { - CARD32 agpTextureOffset = MGA_DMA_BUF_SZ * MGA_DMA_BUF_NR; - CARD32 agpTextureSize = pMGADRI->agp.size - agpTextureOffset; - - i = mylog2(agpTextureSize / MGA_NR_TEX_REGIONS); - if (i < MGA_LOG_MIN_TEX_REGION_SIZE) - i = MGA_LOG_MIN_TEX_REGION_SIZE; - - pMGADRI->logAgpTextureGranularity = i; - pMGADRI->agpTextureSize = (agpTextureSize >> i) << i; - pMGADRI->agpTextureOffset = agpTextureOffset; - } -#endif - - if ( !MGADRIAgpInit( pScreen ) ) { + if ( !MGADRIBootstrapDMA( pScreen ) ) { DRICloseScreen( pScreen ); return FALSE; } - if ( !MGADRIMapInit( pScreen ) ) { - DRICloseScreen( pScreen ); - return FALSE; - } { void *scratch_ptr; int scratch_int; @@ -1311,7 +1236,6 @@ Bool MGADRIFinishScreenInit( ScreenPtr pScreen ) } pMGADRI->width = pScrn->virtualX; pMGADRI->height = pScrn->virtualY; - pMGADRI->mem = pScrn->videoRam * 1024; pMGADRI->cpp = pScrn->bitsPerPixel / 8; pMGADRI->agpMode = pMga->agpMode; @@ -1325,6 +1249,25 @@ Bool MGADRIFinishScreenInit( ScreenPtr pScreen ) pMGADRI->textureOffset = pMGADRIServer->textureOffset; pMGADRI->textureSize = pMGADRIServer->textureSize; + pMGADRI->agpTextureOffset = (unsigned int)pMGADRIServer->agpTextures.handle; + pMGADRI->agpTextureSize = (unsigned int)pMGADRIServer->agpTextures.size; + + pMGADRI->registers.handle = pMGADRIServer->registers.handle; + pMGADRI->registers.size = pMGADRIServer->registers.size; + pMGADRI->primary.handle = pMGADRIServer->primary.handle; + pMGADRI->primary.size = pMGADRIServer->primary.size; + pMGADRI->sarea_priv_offset = sizeof(XF86DRISAREARec); + + + /* These are no longer used by the client-side DRI driver. They should + * be removed in the next release (i.e., 6.9 / 7.0). + */ + + pMGADRI->status.handle = pMGADRIServer->status.handle; + pMGADRI->status.size = pMGADRIServer->status.size; + pMGADRI->buffers.handle = pMGADRIServer->buffers.handle; + pMGADRI->buffers.size = pMGADRIServer->buffers.size; + i = mylog2( pMGADRI->textureSize / MGA_NR_TEX_REGIONS ); if ( i < MGA_LOG_MIN_TEX_REGION_SIZE ) i = MGA_LOG_MIN_TEX_REGION_SIZE; @@ -1337,18 +1280,7 @@ Bool MGADRIFinishScreenInit( ScreenPtr pScreen ) i = MGA_LOG_MIN_TEX_REGION_SIZE; pMGADRI->logAgpTextureGranularity = i; - pMGADRI->agpTextureOffset = (unsigned int)pMGADRIServer->agpTextures.handle; - pMGADRI->agpTextureSize = (unsigned int)pMGADRIServer->agpTextures.size; - pMGADRI->registers.handle = pMGADRIServer->registers.handle; - pMGADRI->registers.size = pMGADRIServer->registers.size; - pMGADRI->status.handle = pMGADRIServer->status.handle; - pMGADRI->status.size = pMGADRIServer->status.size; - pMGADRI->primary.handle = pMGADRIServer->primary.handle; - pMGADRI->primary.size = pMGADRIServer->primary.size; - pMGADRI->buffers.handle = pMGADRIServer->buffers.handle; - pMGADRI->buffers.size = pMGADRIServer->buffers.size; - pMGADRI->sarea_priv_offset = sizeof(XF86DRISAREARec); return TRUE; } @@ -1358,7 +1290,7 @@ void MGADRICloseScreen( ScreenPtr pScreen ) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMga = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo; - drmMGAInit init; + drm_mga_init_t init; if ( pMGADRIServer->drmBuffers ) { drmUnmapBufs( pMGADRIServer->drmBuffers ); @@ -1372,31 +1304,9 @@ void MGADRICloseScreen( ScreenPtr pScreen ) } /* Cleanup DMA */ - memset( &init, 0, sizeof(drmMGAInit) ); + memset( &init, 0, sizeof(drm_mga_init_t) ); init.func = MGA_CLEANUP_DMA; - drmCommandWrite( pMga->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit) ); - - if ( pMGADRIServer->status.map ) { - drmUnmap( pMGADRIServer->status.map, pMGADRIServer->status.size ); - pMGADRIServer->status.map = NULL; - } - if ( pMGADRIServer->buffers.map ) { - drmUnmap( pMGADRIServer->buffers.map, pMGADRIServer->buffers.size ); - pMGADRIServer->buffers.map = NULL; - } - if ( pMGADRIServer->primary.map ) { - drmUnmap( pMGADRIServer->primary.map, pMGADRIServer->primary.size ); - pMGADRIServer->primary.map = NULL; - } - if ( pMGADRIServer->warp.map ) { - drmUnmap( pMGADRIServer->warp.map, pMGADRIServer->warp.size ); - pMGADRIServer->warp.map = NULL; - } - - if ( pMGADRIServer->agpTextures.map ) { - drmUnmap( pMGADRIServer->agpTextures.map, pMGADRIServer->agpTextures.size ); - pMGADRIServer->agpTextures.map = NULL; - } + drmCommandWrite( pMga->drmFD, DRM_MGA_INIT, &init, sizeof(drm_mga_init_t) ); if ( pMGADRIServer->agp.handle != DRM_AGP_NO_HANDLE ) { drmAgpUnbind( pMga->drmFD, pMGADRIServer->agp.handle ); diff --git a/src/mga_dri.h b/src/mga_dri.h index 6d2addc..ef845c8 100644 --- a/src/mga_dri.h +++ b/src/mga_dri.h @@ -41,15 +41,6 @@ #define MGA_BUFFER_ALIGN 0x00000fff typedef struct { - int reserved_map_agpstart; - int reserved_map_idx; - int buffer_map_idx; - int sarea_priv_offset; - int primary_size; - int warp_ucode_size; - int chipset; - int sgram; - unsigned int frontOffset; unsigned int frontPitch; @@ -79,11 +70,25 @@ typedef struct { } MGADRIServerPrivateRec, *MGADRIServerPrivatePtr; +#ifdef __GNUC__ +# define DEPRECATED __attribute__ ((deprecated)) +#else +# define DEPRECATED +#endif + +/** + * Hardware information sent from server to client-side DRI driver. + * + * \todo + * Several of these fields are no longer used (and will never be used + * again) on the client-side. At some point when it is safe to do so + * (probably for the X.org 6.9 / 7.0 release), these fields should be removed. + */ typedef struct { int chipset; int width; int height; - int mem; + int mem DEPRECATED; /**< Unused client-side since forever. */ int cpp; int agpMode; @@ -99,22 +104,26 @@ typedef struct { unsigned int textureOffset; unsigned int textureSize; - int logTextureGranularity; + int logTextureGranularity; /**< Unused client-side since 2003-Aug-06 */ - /* Allow calculation of setup dma addresses. - */ - unsigned int agpBufferOffset; + unsigned int agpBufferOffset DEPRECATED; /**< Unused client-side since forever. */ unsigned int agpTextureOffset; unsigned int agpTextureSize; - int logAgpTextureGranularity; + int logAgpTextureGranularity; /**< Unused client-side since 2003-Aug-06 */ - unsigned int mAccess; + unsigned int mAccess DEPRECATED; /**< Unused client-side since forever. */ + + /** + * \name DRM memory regions. + */ + /*@{*/ + drmRegion registers; /**< MMIO registers. */ + drmRegion status; /**< Unused client-side since forever. */ + drmRegion primary; /**< Primary DMA region. */ + drmRegion buffers; /**< Unused client-side since forever. */ + /*@}*/ - drmRegion registers; - drmRegion status; - drmRegion primary; - drmRegion buffers; unsigned int sarea_priv_offset; } MGADRIRec, *MGADRIPtr; |