diff options
-rw-r--r-- | src/mesa/drivers/dri/mga/Makefile | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/mga/README | 17 | ||||
-rw-r--r-- | src/mesa/drivers/dri/mga/mga_xmesa.c | 28 | ||||
-rw-r--r-- | src/mesa/drivers/dri/mga/mgabuffers.c | 59 | ||||
-rw-r--r-- | src/mesa/drivers/dri/mga/server/mga_dri.c | 357 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/server/radeon_dri.c | 340 | ||||
-rw-r--r-- | src/miniglx/dri_util.c | 41 | ||||
-rw-r--r-- | src/miniglx/miniglx.c | 122 | ||||
-rw-r--r-- | src/miniglx/miniglxP.h | 135 | ||||
-rw-r--r-- | src/miniglx/miniglx_events.c | 38 |
10 files changed, 582 insertions, 565 deletions
diff --git a/src/mesa/drivers/dri/mga/Makefile b/src/mesa/drivers/dri/mga/Makefile index 369b8dac20..5b195852c4 100644 --- a/src/mesa/drivers/dri/mga/Makefile +++ b/src/mesa/drivers/dri/mga/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.1.2.1 2003/04/24 22:33:53 keithw Exp $ +# $Id: Makefile,v 1.1.2.2 2003/04/26 21:17:43 keithw Exp $ # Mesa 3-D graphics library # Version: 5.0 @@ -84,14 +84,14 @@ INCLUDES = $(MINIGLX_INCLUDES) \ ifeq ($(FULL_DRIVER),true) -C_SOURCES = $(DRIVER_SOURCES) \ +C_SOURCES = $(MINIGLX_SOURCES) \ $(FULL_DRIVER_SOURCES) \ - $(MINIGLX_SOURCES) + $(DRIVER_SOURCES) MESA_MODULES = $(FULL_MESA) else -C_SOURCES = $(DRIVER_SOURCES) \ +C_SOURCES = $(MINIGLX_SOURCES) \ $(SUBSET_DRIVER_SOURCES) \ - $(MINIGLX_SOURCES) + $(DRIVER_SOURCES) MESA_MODULES = $(SUBSET_MESA) endif diff --git a/src/mesa/drivers/dri/mga/README b/src/mesa/drivers/dri/mga/README index 57cedb3cdb..a7133fa66f 100644 --- a/src/mesa/drivers/dri/mga/README +++ b/src/mesa/drivers/dri/mga/README @@ -8,21 +8,6 @@ This driver has been ported from the head branch of XFree86 to the embedded-1-branch of Mesa. -INSTRUCTIONS - -1. Checkout Mesa embedded-1-branch via: - - cvs -d :pserver:anonymous@cvs.mesa3d.sourceforge.net:/cvsroot/mesa3d co -r embedded-1-branch Mesa - -2. Patch some Makefiles (within the Mesa/ directory) via: - - patch -p0 < Mesa-embedded-1-branch-mga.diff - -3. Unpack the driver source (within the Mesa/ directory) via: - - tar xvjf Mesa-embedded-1-branch-src-drv-mga.tar.bz2 - - STATUS Already working very well as far as I've tested it (16/32 bit). @@ -32,6 +17,8 @@ Other demos (terrain, fire, etc.) have been successfully tested as well. TODO +- mgaEngineShutdown +- mgaEngineRestore - SGRAM detection - remove some unused bits from server/* - subset driver support diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index b9bf5b19ae..01d6000562 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -505,6 +505,8 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv, __DRIdrawablePrivate *driDrawPriv, __DRIdrawablePrivate *driReadPriv) { + fprintf(stderr, "%s\n", __FUNCTION__); + if (driContextPriv) { mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; @@ -530,7 +532,6 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv, return GL_TRUE; } - void mgaGetLock( mgaContextPtr mmesa, GLuint flags ) { __DRIdrawablePrivate *dPriv = mmesa->driDrawable; @@ -538,10 +539,29 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags ) int me = mmesa->hHWContext; int i; + fprintf(stderr, "%s\n", __FUNCTION__); + drmGetLock(mmesa->driFd, mmesa->hHWContext, flags); + + fprintf(stderr, + "mmesa->lastStamp %d dpriv->lastStamp %d *(dpriv->pStamp) %d\n", + mmesa->lastStamp, + dPriv->lastStamp, + *(dPriv->pStamp)); + + /* The window might have moved, so we might need to get new clip + * rects. + * + * NOTE: This releases and regrabs the hw lock to allow the X server + * to respond to the DRI protocol request for new drawable info. + * Since the hardware state depends on having the latest drawable + * clip rects, all state checking must be done _after_ this call. + */ + DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv ); - if (*(dPriv->pStamp) != mmesa->lastStamp) { - mmesa->lastStamp = *(dPriv->pStamp); + if ( mmesa->lastStamp == 0 || + mmesa->lastStamp != dPriv->lastStamp ) { + mmesa->lastStamp = dPriv->lastStamp; mmesa->SetupNewInputs |= VERT_BIT_CLIP; mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK); mgaUpdateRects( mmesa, (MGA_FRONT|MGA_BACK) ); @@ -549,7 +569,7 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags ) mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_CLIPRECTS; - mmesa->sarea->dirty |= MGA_UPLOAD_CONTEXT; + mmesa->sarea->dirty |= MGA_UPLOAD_CONTEXT; if (sarea->ctxOwner != me) { mmesa->dirty |= (MGA_UPLOAD_CONTEXT | MGA_UPLOAD_TEX0 | diff --git a/src/mesa/drivers/dri/mga/mgabuffers.c b/src/mesa/drivers/dri/mga/mgabuffers.c index 820f04f496..aad8b57472 100644 --- a/src/mesa/drivers/dri/mga/mgabuffers.c +++ b/src/mesa/drivers/dri/mga/mgabuffers.c @@ -37,6 +37,8 @@ static void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa ) { __DRIdrawablePrivate *driDrawable = mmesa->driDrawable; +/* fprintf( stderr, "%s\n", __FUNCTION__ );*/ + if (driDrawable->numClipRects == 0) { static XF86DRIClipRectRec zeroareacliprect = {0,0,0,0}; mmesa->numClipRects = 1; @@ -57,10 +59,12 @@ static void mgaXMesaSetBackClipRects( mgaContextPtr mmesa ) { __DRIdrawablePrivate *driDrawable = mmesa->driDrawable; +/* fprintf( stderr, "%s\n", __FUNCTION__ );*/ + if (driDrawable->numBackClipRects == 0) { if (driDrawable->numClipRects == 0) { - static XF86DRIClipRectRec zeroareacliprect = {0,0,800,600}; + static XF86DRIClipRectRec zeroareacliprect = {0,0,0,0}; mmesa->numClipRects = 1; mmesa->pClipRects = &zeroareacliprect; } else { @@ -210,7 +214,7 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers ) __DRIdrawablePrivate *driDrawable = mmesa->driDrawable; MGASAREAPrivPtr sarea = mmesa->sarea; -/* fprintf(stderr, "%s\n", __FUNCTION__); */ +/* fprintf(stderr, "%s\n", __FUNCTION__);*/ DRI_VALIDATE_DRAWABLE_INFO(driScreen, driDrawable); mmesa->dirty_cliprects = 0; @@ -256,30 +260,33 @@ void mgaDDSetDrawBuffer(GLcontext *ctx, GLenum mode ) FLUSH_BATCH( MGA_CONTEXT(ctx) ); - - if (mode == GL_FRONT_LEFT) - { - mmesa->drawOffset = mmesa->mgaScreen->frontOffset; - mmesa->readOffset = mmesa->mgaScreen->frontOffset; - mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset; - mmesa->dirty |= MGA_UPLOAD_CONTEXT; - mmesa->draw_buffer = MGA_FRONT; - mgaXMesaSetFrontClipRects( mmesa ); - FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE ); - } - else if (mode == GL_BACK_LEFT) - { - mmesa->drawOffset = mmesa->mgaScreen->backOffset; - mmesa->readOffset = mmesa->mgaScreen->backOffset; - mmesa->setup.dstorg = mmesa->mgaScreen->backOffset; - mmesa->draw_buffer = MGA_BACK; - mmesa->dirty |= MGA_UPLOAD_CONTEXT; - mgaXMesaSetBackClipRects( mmesa ); - FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE ); - } - else - { - FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE ); +/* fprintf( stderr, "%s %d\n", __FUNCTION__, mode);*/ + + /* + * _DrawDestMask is easier to cope with than <mode>. + */ + switch ( ctx->Color._DrawDestMask ) { + case FRONT_LEFT_BIT: + mmesa->drawOffset = mmesa->mgaScreen->frontOffset; + mmesa->readOffset = mmesa->mgaScreen->frontOffset; + mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset; + mmesa->dirty |= MGA_UPLOAD_CONTEXT; + mmesa->draw_buffer = MGA_FRONT; + mgaXMesaSetFrontClipRects( mmesa ); + FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE ); + break; + case BACK_LEFT_BIT: + mmesa->drawOffset = mmesa->mgaScreen->backOffset; + mmesa->readOffset = mmesa->mgaScreen->backOffset; + mmesa->setup.dstorg = mmesa->mgaScreen->backOffset; + mmesa->draw_buffer = MGA_BACK; + mmesa->dirty |= MGA_UPLOAD_CONTEXT; + mgaXMesaSetBackClipRects( mmesa ); + FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE ); + break; + default: + FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE ); + break; } } diff --git a/src/mesa/drivers/dri/mga/server/mga_dri.c b/src/mesa/drivers/dri/mga/server/mga_dri.c index e60888dd73..55c4eb917b 100644 --- a/src/mesa/drivers/dri/mga/server/mga_dri.c +++ b/src/mesa/drivers/dri/mga/server/mga_dri.c @@ -50,7 +50,7 @@ */ #define MGA_TIMEOUT 2048 -static void MGAWaitForIdleDMA( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) +static void MGAWaitForIdleDMA( struct DRIDriverContextRec *ctx, MGAPtr pMga ) { drmMGALock lock; int ret; @@ -63,7 +63,7 @@ static void MGAWaitForIdleDMA( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) /* first ask for quiescent and flush */ lock.flags = DRM_MGA_LOCK_QUIESCENT | DRM_MGA_LOCK_FLUSH; do { - ret = drmCommandWrite( dpy->drmFD, DRM_MGA_FLUSH, + ret = drmCommandWrite( ctx->drmFD, DRM_MGA_FLUSH, &lock, sizeof( drmMGALock ) ); } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY ); @@ -71,7 +71,7 @@ static void MGAWaitForIdleDMA( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) if ( ret == -EBUSY ) { lock.flags = DRM_MGA_LOCK_QUIESCENT; do { - ret = drmCommandWrite( dpy->drmFD, DRM_MGA_FLUSH, + ret = drmCommandWrite( ctx->drmFD, DRM_MGA_FLUSH, &lock, sizeof( drmMGALock ) ); } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY ); } @@ -83,7 +83,7 @@ static void MGAWaitForIdleDMA( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) fprintf( stderr, "[dri] Idle timed out, resetting engine...\n" ); - drmCommandNone( dpy->drmFD, DRM_MGA_RESET ); + drmCommandNone( ctx->drmFD, DRM_MGA_RESET ); } } @@ -94,7 +94,7 @@ static unsigned int mylog2( unsigned int n ) return log2; } -static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) +static int MGADRIAgpInit(struct DRIDriverContextRec *ctx, MGAPtr pMga) { unsigned long mode; unsigned int vendor, device; @@ -125,14 +125,14 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) pMga->agpTextures.size = pMga->agp.size - pMga->agpTextures.offset; - if ( drmAgpAcquire( dpy->drmFD ) < 0 ) { + if ( drmAgpAcquire( ctx->drmFD ) < 0 ) { fprintf( stderr, "[agp] AGP not available\n" ); return 0; } - mode = drmAgpGetMode( dpy->drmFD ); /* Default mode */ - vendor = drmAgpVendorId( dpy->drmFD ); - device = drmAgpDeviceId( dpy->drmFD ); + mode = drmAgpGetMode( ctx->drmFD ); /* Default mode */ + vendor = drmAgpVendorId( ctx->drmFD ); + device = drmAgpDeviceId( ctx->drmFD ); mode &= ~MGA_AGP_MODE_MASK; switch ( pMga->agpMode ) { @@ -149,13 +149,13 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) fprintf( stderr, "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", mode, vendor, device, - dpy->pciVendor, - dpy->pciChipType ); + ctx->pciVendor, + ctx->pciChipType ); #endif - if ( drmAgpEnable( dpy->drmFD, mode ) < 0 ) { + if ( drmAgpEnable( ctx->drmFD, mode ) < 0 ) { fprintf( stderr, "[agp] AGP not enabled\n" ); - drmAgpRelease( dpy->drmFD ); + drmAgpRelease( ctx->drmFD ); return 0; } @@ -177,27 +177,27 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) } } - ret = drmAgpAlloc( dpy->drmFD, pMga->agp.size, + ret = drmAgpAlloc( ctx->drmFD, pMga->agp.size, 0, NULL, &pMga->agp.handle ); if ( ret < 0 ) { fprintf( stderr, "[agp] Out of memory (%d)\n", ret ); - drmAgpRelease( dpy->drmFD ); + drmAgpRelease( ctx->drmFD ); return 0; } fprintf( stderr, "[agp] %d kB allocated with handle 0x%08x\n", pMga->agp.size/1024, (unsigned int)pMga->agp.handle ); - if ( drmAgpBind( dpy->drmFD, pMga->agp.handle, 0 ) < 0 ) { + if ( drmAgpBind( ctx->drmFD, pMga->agp.handle, 0 ) < 0 ) { fprintf( stderr, "[agp] Could not bind memory\n" ); - drmAgpFree( dpy->drmFD, pMga->agp.handle ); - drmAgpRelease( dpy->drmFD ); + drmAgpFree( ctx->drmFD, pMga->agp.handle ); + drmAgpRelease( ctx->drmFD ); return 0; } /* WARP microcode space */ - if ( drmAddMap( dpy->drmFD, + if ( drmAddMap( ctx->drmFD, pMga->warp.offset, pMga->warp.size, DRM_AGP, DRM_READ_ONLY, @@ -210,7 +210,7 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) "[agp] WARP microcode handle = 0x%08lx\n", pMga->warp.handle ); - if ( drmMap( dpy->drmFD, + if ( drmMap( ctx->drmFD, pMga->warp.handle, pMga->warp.size, &pMga->warp.map ) < 0 ) { @@ -224,7 +224,7 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) /* Primary DMA space */ - if ( drmAddMap( dpy->drmFD, + if ( drmAddMap( ctx->drmFD, pMga->primary.offset, pMga->primary.size, DRM_AGP, DRM_READ_ONLY, @@ -237,7 +237,7 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) "[agp] Primary DMA handle = 0x%08lx\n", pMga->primary.handle ); - if ( drmMap( dpy->drmFD, + if ( drmMap( ctx->drmFD, pMga->primary.handle, pMga->primary.size, &pMga->primary.map ) < 0 ) { @@ -251,7 +251,7 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) /* DMA buffers */ - if ( drmAddMap( dpy->drmFD, + if ( drmAddMap( ctx->drmFD, pMga->buffers.offset, pMga->buffers.size, DRM_AGP, 0, @@ -264,7 +264,7 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) "[agp] DMA buffers handle = 0x%08lx\n", pMga->buffers.handle ); - if ( drmMap( dpy->drmFD, + if ( drmMap( ctx->drmFD, pMga->buffers.handle, pMga->buffers.size, &pMga->buffers.map ) < 0 ) { @@ -276,7 +276,7 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) "[agp] DMA buffers mapped at 0x%08lx\n", (unsigned long)pMga->buffers.map ); - count = drmAddBufs( dpy->drmFD, + count = drmAddBufs( ctx->drmFD, MGA_NUM_BUFFERS, MGA_BUFFER_SIZE, DRM_AGP_BUFFER, pMga->buffers.offset ); if ( count <= 0 ) { @@ -294,7 +294,7 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) i = MGA_LOG_MIN_TEX_REGION_SIZE; pMga->agpTextures.size = (pMga->agpTextures.size >> i) << i; - if ( drmAddMap( dpy->drmFD, + if ( drmAddMap( ctx->drmFD, pMga->agpTextures.offset, pMga->agpTextures.size, DRM_AGP, 0, @@ -313,11 +313,11 @@ static int MGADRIAgpInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) return 1; } -static int MGADRIMapInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) +static int MGADRIMapInit( struct DRIDriverContextRec *ctx, MGAPtr pMga ) { pMga->registers.size = MGAIOMAPSIZE; - if ( drmAddMap( dpy->drmFD, + if ( drmAddMap( ctx->drmFD, (drmHandle)pMga->IOAddress, pMga->registers.size, DRM_REGISTERS, DRM_READ_ONLY, @@ -332,7 +332,7 @@ static int MGADRIMapInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) pMga->status.size = SAREA_MAX; - if ( drmAddMap( dpy->drmFD, 0, pMga->status.size, + if ( drmAddMap( ctx->drmFD, 0, pMga->status.size, DRM_SHM, DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL, &pMga->status.handle ) < 0 ) { fprintf( stderr, @@ -343,7 +343,7 @@ static int MGADRIMapInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) "[drm] Status handle = 0x%08lx\n", pMga->status.handle ); - if ( drmMap( dpy->drmFD, + if ( drmMap( ctx->drmFD, pMga->status.handle, pMga->status.size, &pMga->status.map ) < 0 ) { @@ -358,7 +358,7 @@ static int MGADRIMapInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) return 1; } -static int MGADRIKernelInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) +static int MGADRIKernelInit( struct DRIDriverContextRec *ctx, MGAPtr pMga ) { drmMGAInit init; int ret; @@ -384,7 +384,7 @@ static int MGADRIKernelInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) init.sgram = 0; /* FIXME !pMga->HasSDRAM; */ - switch (dpy->bpp) + switch (ctx->bpp) { case 16: init.maccess = MGA_MACCESS_PW16; @@ -393,25 +393,25 @@ static int MGADRIKernelInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) init.maccess = MGA_MACCESS_PW32; break; default: - fprintf( stderr, "[mga] invalid bpp (%d)\n", dpy->bpp ); + fprintf( stderr, "[mga] invalid bpp (%d)\n", ctx->bpp ); return 0; } - init.fb_cpp = dpy->bpp / 8; + init.fb_cpp = ctx->bpp / 8; init.front_offset = pMga->frontOffset; init.front_pitch = pMga->frontPitch / init.fb_cpp; init.back_offset = pMga->backOffset; init.back_pitch = pMga->backPitch / init.fb_cpp; - init.depth_cpp = dpy->bpp / 8; + init.depth_cpp = ctx->bpp / 8; init.depth_offset = pMga->depthOffset; init.depth_pitch = pMga->depthPitch / init.depth_cpp; init.texture_offset[0] = pMga->textureOffset; init.texture_size[0] = pMga->textureSize; - init.fb_offset = dpy->shared.hFrameBuffer; + init.fb_offset = ctx->shared.hFrameBuffer; init.mmio_offset = pMga->registers.handle; init.status_offset = pMga->status.handle; @@ -422,7 +422,7 @@ static int MGADRIKernelInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) init.texture_offset[1] = pMga->agpTextures.handle; init.texture_size[1] = pMga->agpTextures.size; - ret = drmCommandWrite( dpy->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit)); + ret = drmCommandWrite( ctx->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit)); if ( ret < 0 ) { fprintf( stderr, "[drm] Failed to initialize DMA! (%d)\n", ret ); @@ -432,18 +432,18 @@ static int MGADRIKernelInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) return 1; } -static void MGADRIIrqInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) +static void MGADRIIrqInit(struct DRIDriverContextRec *ctx, MGAPtr pMga) { if (!pMga->irq) { - pMga->irq = drmGetInterruptFromBusID(dpy->drmFD, - dpy->pciBus, - dpy->pciDevice, - dpy->pciFunc); + pMga->irq = drmGetInterruptFromBusID(ctx->drmFD, + ctx->pciBus, + ctx->pciDevice, + ctx->pciFunc); fprintf(stderr, "[drm] got IRQ %d\n", pMga->irq); - if((drmCtlInstHandler(dpy->drmFD, pMga->irq)) != 0) + if((drmCtlInstHandler(ctx->drmFD, pMga->irq)) != 0) { fprintf(stderr, "[drm] failure adding irq handler, " @@ -463,9 +463,9 @@ static void MGADRIIrqInit(struct MiniGLXDisplayRec *dpy, MGAPtr pMga) pMga->irq); } -static int MGADRIBuffersInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) +static int MGADRIBuffersInit( struct DRIDriverContextRec *ctx, MGAPtr pMga ) { - pMga->drmBuffers = drmMapBufs( dpy->drmFD ); + pMga->drmBuffers = drmMapBufs( ctx->drmFD ); if ( !pMga->drmBuffers ) { fprintf( stderr, @@ -480,19 +480,19 @@ static int MGADRIBuffersInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) return 1; } -static int MGAMemoryInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) +static int MGAMemoryInit( struct DRIDriverContextRec *ctx, MGAPtr pMga ) { - int width_bytes = dpy->shared.virtualWidth * dpy->cpp; - int bufferSize = ((dpy->shared.virtualHeight * width_bytes + int width_bytes = ctx->shared.virtualWidth * ctx->cpp; + int bufferSize = ((ctx->shared.virtualHeight * width_bytes + MGA_BUFFER_ALIGN) & ~MGA_BUFFER_ALIGN); - int depthSize = ((((dpy->shared.virtualHeight+15) & ~15) * width_bytes + int depthSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes + MGA_BUFFER_ALIGN) & ~MGA_BUFFER_ALIGN); int l; pMga->frontOffset = 0; - pMga->frontPitch = dpy->shared.virtualWidth * dpy->cpp; + pMga->frontPitch = ctx->shared.virtualWidth * ctx->cpp; fprintf(stderr, "Using %d MB AGP aperture\n", pMga->agpSize); @@ -503,7 +503,7 @@ static int MGAMemoryInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) /* Front, back and depth buffers - everything else texture?? */ - pMga->textureSize = dpy->shared.fbSize - 2 * bufferSize - depthSize; + pMga->textureSize = ctx->shared.fbSize - 2 * bufferSize - depthSize; if (pMga->textureSize < 0) return 0; @@ -528,7 +528,7 @@ static int MGAMemoryInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) } /* Reserve space for textures */ - pMga->textureOffset = ((dpy->shared.fbSize - pMga->textureSize + + pMga->textureOffset = ((ctx->shared.fbSize - pMga->textureSize + MGA_BUFFER_ALIGN) & ~MGA_BUFFER_ALIGN); @@ -538,12 +538,12 @@ static int MGAMemoryInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) pMga->depthOffset = ((pMga->textureOffset - depthSize + MGA_BUFFER_ALIGN) & ~MGA_BUFFER_ALIGN); - pMga->depthPitch = dpy->shared.virtualWidth * dpy->cpp; + pMga->depthPitch = ctx->shared.virtualWidth * ctx->cpp; pMga->backOffset = ((pMga->depthOffset - bufferSize + MGA_BUFFER_ALIGN) & ~MGA_BUFFER_ALIGN); - pMga->backPitch = dpy->shared.virtualWidth * dpy->cpp; + pMga->backPitch = ctx->shared.virtualWidth * ctx->cpp; fprintf(stderr, @@ -559,12 +559,12 @@ static int MGAMemoryInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) return 1; } -static int MGACheckDRMVersion( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) +static int MGACheckDRMVersion( struct DRIDriverContextRec *ctx, MGAPtr pMga ) { drmVersionPtr version; /* Check the MGA DRM version */ - version = drmGetVersion(dpy->drmFD); + version = drmGetVersion(ctx->drmFD); if ( version ) { if ( version->version_major != 3 || version->version_minor < 0 ) { @@ -627,28 +627,27 @@ static void print_client_msg( MGADRIPtr pMGADRI ) #endif } -static int MGAScreenInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) +static int MGAScreenInit( struct DRIDriverContextRec *ctx, MGAPtr pMga ) { int i; int err; MGADRIPtr pMGADRI; - unsigned int serverContext; usleep(100); - assert(!dpy->IsClient); + //assert(!ctx->IsClient); { - int width_bytes = (dpy->shared.virtualWidth * dpy->cpp); - int maxy = dpy->shared.fbSize / width_bytes; + int width_bytes = (ctx->shared.virtualWidth * ctx->cpp); + int maxy = ctx->shared.fbSize / width_bytes; - if (maxy <= dpy->shared.virtualHeight * 3) { + if (maxy <= ctx->shared.virtualHeight * 3) { fprintf(stderr, "Static buffer allocation failed -- " "need at least %d kB video memory (have %d kB)\n", - (dpy->shared.virtualWidth * dpy->shared.virtualHeight * - dpy->cpp * 3 + 1023) / 1024, - dpy->shared.fbSize / 1024); + (ctx->shared.virtualWidth * ctx->shared.virtualHeight * + ctx->cpp * 3 + 1023) / 1024, + ctx->shared.fbSize / 1024); return 0; } } @@ -668,77 +667,77 @@ static int MGAScreenInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) fprintf( stderr, "[drm] bpp: %d depth: %d\n", - dpy->bpp, dpy->bpp /* FIXME: depth */ ); + ctx->bpp, ctx->bpp /* FIXME: depth */ ); - if ( (dpy->bpp / 8) != 2 && - (dpy->bpp / 8) != 4 ) { + if ( (ctx->bpp / 8) != 2 && + (ctx->bpp / 8) != 4 ) { fprintf( stderr, "[dri] Direct rendering only supported in 16 and 32 bpp modes\n" ); return 0; } - dpy->shared.SAREASize = SAREA_MAX; + ctx->shared.SAREASize = SAREA_MAX; /* Note that drmOpen will try to load the kernel module, if needed. */ - dpy->drmFD = drmOpen("mga", NULL ); - if (dpy->drmFD < 0) { + ctx->drmFD = drmOpen("mga", NULL ); + if (ctx->drmFD < 0) { fprintf(stderr, "[drm] drmOpen failed\n"); return 0; } - if ((err = drmSetBusid(dpy->drmFD, dpy->pciBusID)) < 0) { + if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) { fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - dpy->drmFD, dpy->pciBusID, strerror(-err)); + ctx->drmFD, ctx->pciBusID, strerror(-err)); return 0; } - if (drmAddMap( dpy->drmFD, + if (drmAddMap( ctx->drmFD, 0, - dpy->shared.SAREASize, + ctx->shared.SAREASize, DRM_SHM, DRM_CONTAINS_LOCK, - &dpy->shared.hSAREA) < 0) + &ctx->shared.hSAREA) < 0) { fprintf(stderr, "[drm] drmAddMap failed\n"); return 0; } fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - dpy->shared.SAREASize, dpy->shared.hSAREA); + ctx->shared.SAREASize, ctx->shared.hSAREA); - if (drmMap( dpy->drmFD, - dpy->shared.hSAREA, - dpy->shared.SAREASize, - (drmAddressPtr)(&dpy->pSAREA)) < 0) + if (drmMap( ctx->drmFD, + ctx->shared.hSAREA, + ctx->shared.SAREASize, + (drmAddressPtr)(&ctx->pSAREA)) < 0) { fprintf(stderr, "[drm] drmMap failed\n"); return 0; } - memset(dpy->pSAREA, 0, dpy->shared.SAREASize); + memset(ctx->pSAREA, 0, ctx->shared.SAREASize); fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - dpy->shared.hSAREA, dpy->pSAREA, dpy->shared.SAREASize); + ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize); /* Need to AddMap the framebuffer and mmio regions here: */ - if (drmAddMap( dpy->drmFD, - (drmHandle)dpy->FixedInfo.smem_start, - dpy->FixedInfo.smem_len, + if (drmAddMap( ctx->drmFD, + (drmHandle)ctx->FBStart, + ctx->FBSize, DRM_FRAME_BUFFER, 0, - &dpy->shared.hFrameBuffer) < 0) + &ctx->shared.hFrameBuffer) < 0) { fprintf(stderr, "[drm] drmAddMap framebuffer failed\n"); return 0; } fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n", - dpy->shared.hFrameBuffer); + ctx->shared.hFrameBuffer); #if 0 /* will be done in MGADRIMapInit */ - if (drmAddMap(dpy->drmFD, - dpy->FixedInfo.mmio_start, - dpy->FixedInfo.mmio_len, + if (drmAddMap(ctx->drmFD, + ctx->FixedInfo.mmio_start, + ctx->FixedInfo.mmio_len, DRM_REGISTERS, DRM_READ_ONLY, &pMga->registers.handle) < 0) { @@ -751,20 +750,20 @@ static int MGAScreenInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) /* Check the mga DRM version */ - if (!MGACheckDRMVersion(dpy, pMga)) { + if (!MGACheckDRMVersion(ctx, pMga)) { return 0; } - if ( !MGADRIAgpInit( dpy, pMga ) ) { + if ( !MGADRIAgpInit( ctx, pMga ) ) { return 0; } - if ( !MGADRIMapInit( dpy, pMga ) ) { + if ( !MGADRIMapInit( ctx, pMga ) ) { return 0; } /* Memory manager setup */ - if (!MGAMemoryInit(dpy, pMga)) { + if (!MGAMemoryInit(ctx, pMga)) { return 0; } @@ -772,61 +771,59 @@ static int MGAScreenInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) /* Create a 'server' context so we can grab the lock for * initialization ioctls. */ - if ((err = drmCreateContext(dpy->drmFD, &serverContext)) != 0) { + if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) { fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); return 0; } - DRM_LOCK(dpy->drmFD, dpy->pSAREA, serverContext, 0); + DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0); /* Initialize the kernel data structures */ - if (!MGADRIKernelInit(dpy, pMga)) { + if (!MGADRIKernelInit(ctx, pMga)) { fprintf(stderr, "MGADRIKernelInit failed\n"); - DRM_UNLOCK(dpy->drmFD, dpy->pSAREA, serverContext); + DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); return 0; } /* Initialize the vertex buffers list */ - if (!MGADRIBuffersInit(dpy, pMga)) { + if (!MGADRIBuffersInit(ctx, pMga)) { fprintf(stderr, "MGADRIBuffersInit failed\n"); - DRM_UNLOCK(dpy->drmFD, dpy->pSAREA, serverContext); + DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); return 0; } /* Initialize IRQ */ - MGADRIIrqInit(dpy, pMga); + MGADRIIrqInit(ctx, pMga); /* Initialize the SAREA private data structure */ { MGASAREAPrivPtr pSAREAPriv; - pSAREAPriv = (MGASAREAPrivPtr)(((char*)dpy->pSAREA) + + pSAREAPriv = (MGASAREAPrivPtr)(((char*)ctx->pSAREA) + sizeof(XF86DRISAREARec)); memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); } - /* Quick hack to clear the front & back buffers. Could also use * the clear ioctl to do this, but would need to setup hw state * first. */ - memset(dpy->FrameBuffer + pMga->frontOffset, + memset(ctx->FBAddress + pMga->frontOffset, 0, - pMga->frontPitch * dpy->shared.virtualHeight ); + pMga->frontPitch * ctx->shared.virtualHeight ); - memset(dpy->FrameBuffer + pMga->backOffset, + memset(ctx->FBAddress + pMga->backOffset, 0, - pMga->backPitch * dpy->shared.virtualHeight ); - + pMga->backPitch * ctx->shared.virtualHeight ); /* Can release the lock now */ - DRM_UNLOCK(dpy->drmFD, dpy->pSAREA, serverContext); +/* DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);*/ /* This is the struct passed to radeon_dri.so for its initialization */ - dpy->driverClientMsg = malloc(sizeof(MGADRIRec)); - dpy->driverClientMsgSize = sizeof(MGADRIRec); + ctx->driverClientMsg = malloc(sizeof(MGADRIRec)); + ctx->driverClientMsgSize = sizeof(MGADRIRec); - pMGADRI = (MGADRIPtr)dpy->driverClientMsg; + pMGADRI = (MGADRIPtr)ctx->driverClientMsg; switch(pMga->Chipset) { @@ -841,10 +838,10 @@ static int MGAScreenInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) default: return 0; } - pMGADRI->width = dpy->shared.virtualWidth; - pMGADRI->height = dpy->shared.virtualHeight; - pMGADRI->mem = dpy->shared.fbSize; - pMGADRI->cpp = dpy->bpp / 8; + pMGADRI->width = ctx->shared.virtualWidth; + pMGADRI->height = ctx->shared.virtualHeight; + pMGADRI->mem = ctx->shared.fbSize; + pMGADRI->cpp = ctx->bpp / 8; pMGADRI->agpMode = pMga->agpMode; @@ -885,7 +882,7 @@ static int MGAScreenInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) /** * \brief Establish the set of visuals available for the display. * - * \param dpy display handle. + * \param ctx display handle. * \param numConfigs will receive the number of supported visuals. * \param configs will point to the list of supported visuals. * @@ -897,7 +894,7 @@ static int MGAScreenInit( struct MiniGLXDisplayRec *dpy, MGAPtr pMga ) * display bit depth. Supports only 16 and 32 bpp bit depths, aborting * otherwise. */ -static int mgaInitScreenConfigs( struct MiniGLXDisplayRec *dpy, +static int mgaInitScreenConfigs( struct DRIDriverContextRec *ctx, int *numConfigs, __GLXvisualConfig **configs) { int i; @@ -906,7 +903,7 @@ static int mgaInitScreenConfigs( struct MiniGLXDisplayRec *dpy, *configs = (__GLXvisualConfig *) calloc(*numConfigs, sizeof(__GLXvisualConfig)); - switch (dpy->bpp) { + switch (ctx->bpp) { case 32: for (i = 0; i < *numConfigs; i++) { (*configs)[i].vid = 100 + i; @@ -957,7 +954,7 @@ static int mgaInitScreenConfigs( struct MiniGLXDisplayRec *dpy, default: fprintf(stderr, "Unknown bpp in %s: %d\n", __FUNCTION__, - dpy->bpp); + ctx->bpp); exit(1); break; @@ -969,7 +966,7 @@ static int mgaInitScreenConfigs( struct MiniGLXDisplayRec *dpy, /** * \brief Validate the fbdev mode. * - * \param dpy display handle. + * \param ctx display handle. * * \return one on success, or zero on failure. * @@ -977,7 +974,7 @@ static int mgaInitScreenConfigs( struct MiniGLXDisplayRec *dpy, * * \sa mgaValidateMode(). */ -static int mgaValidateMode( struct MiniGLXDisplayRec *dpy ) +static int mgaValidateMode( struct DRIDriverContextRec *ctx ) { return 1; } @@ -986,7 +983,7 @@ static int mgaValidateMode( struct MiniGLXDisplayRec *dpy ) /** * \brief Examine mode returned by fbdev. * - * \param dpy display handle. + * \param ctx display handle. * * \return one on success, or zero on failure. * @@ -994,7 +991,7 @@ static int mgaValidateMode( struct MiniGLXDisplayRec *dpy ) * * \sa mgaValidateMode(). */ -static int mgaPostValidateMode( struct MiniGLXDisplayRec *dpy ) +static int mgaPostValidateMode( struct DRIDriverContextRec *ctx ) { return 1; } @@ -1003,45 +1000,45 @@ static int mgaPostValidateMode( struct MiniGLXDisplayRec *dpy ) /** * \brief Initialize the framebuffer device mode * - * \param dpy display handle. + * \param ctx display handle. * * \return one on success, or zero on failure. * - * Fills in \p info with some default values and some information from \p dpy + * Fills in \p info with some default values and some information from \p ctx * and then calls MGAScreenInit() for the screen initialization. * * Before exiting clears the framebuffer memomry accessing it directly. */ -static int mgaInitFBDev( struct MiniGLXDisplayRec *dpy ) +static int mgaInitFBDev( struct DRIDriverContextRec *ctx ) { MGAPtr pMga = calloc(1, sizeof(*pMga)); { - int dummy = dpy->shared.virtualWidth; + int dummy = ctx->shared.virtualWidth; - switch (dpy->bpp / 8) { - case 1: dummy = (dpy->shared.virtualWidth + 127) & ~127; break; - case 2: dummy = (dpy->shared.virtualWidth + 31) & ~31; break; + switch (ctx->bpp / 8) { + case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break; + case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break; case 3: - case 4: dummy = (dpy->shared.virtualWidth + 15) & ~15; break; + case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break; } - dpy->shared.virtualWidth = dummy; + ctx->shared.virtualWidth = dummy; } - dpy->driverInfo = (void *)pMga; + ctx->driverPrivate = (void *)pMga; pMga->agpMode = MGA_DEFAULT_AGP_MODE; pMga->agpSize = MGA_DEFAULT_AGP_SIZE; - pMga->Chipset = dpy->chipset; + pMga->Chipset = ctx->chipset; - pMga->IOAddress = dpy->FixedInfo.mmio_start; - pMga->IOBase = dpy->MMIOAddress; + pMga->IOAddress = ctx->MMIOStart; + pMga->IOBase = ctx->MMIOAddress; - pMga->frontPitch = dpy->shared.virtualWidth * dpy->cpp; + pMga->frontPitch = ctx->shared.virtualWidth * ctx->cpp; - if (!MGAScreenInit( dpy, pMga )) + if (!MGAScreenInit( ctx, pMga )) return 0; return 1; @@ -1052,76 +1049,50 @@ static int mgaInitFBDev( struct MiniGLXDisplayRec *dpy ) * \brief The screen is being closed, so clean up any state and free any * resources used by the DRI. * - * \param dpy display handle. + * \param ctx display handle. * * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver * private data. */ -static void mgaHaltFBDev( struct MiniGLXDisplayRec *dpy ) +static void mgaHaltFBDev( struct DRIDriverContextRec *ctx ) { - drmUnmap( dpy->pSAREA, dpy->shared.SAREASize ); - drmClose(dpy->drmFD); + drmUnmap( ctx->pSAREA, ctx->shared.SAREASize ); + drmClose(ctx->drmFD); - if (dpy->driverInfo) { - free(dpy->driverInfo); - dpy->driverInfo = 0; + if (ctx->driverPrivate) { + free(ctx->driverPrivate); + ctx->driverPrivate = NULL; } } -/** - * \brief A VT release or aquire signal has been received, and - * requires some action. We deal with loosing the VT by setting the - * cliprects to zero and emitting an event to the application. - */ -static int mgaVTSwitchHandler( struct MiniGLXDisplayRec *dpy, int have_vt ) +static int mgaEngineShutdown( struct DRIDriverContextRec *ctx ) { - int *lock = (int *)dpy->pSAREA; - int old, new; - DRM_CAS_RESULT(ret); - GLXDrawable draw; - __DRIdrawable *pdraw; - __DRIdrawablePrivate *pdp; - - /* Indicate cliprects have changed - */ - draw = dpy->TheWindow; - if (!draw) return 1; - pdraw = &draw->driDrawable; - if (!pdraw) return 1; - pdp = (__DRIdrawablePrivate *) pdraw->private; - if (!pdp) return 1; - pdp->lastStamp++; - pdp->numClipRects = have_vt ? 1 : 0; - - /* Mark the lock contended. - */ - if (!dpy->pSAREA) return 0; - do { - old = *(int *)dpy->pSAREA; - new = old | _DRM_LOCK_CONT; - DRM_CAS( lock, old, new, ret ); - fprintf(stderr, "old %x new %x\n", old, new ); - } while (ret); - - if (have_vt) - return !(old & _DRM_LOCK_HELD); - else - return 1; + fprintf(stderr, "%s() is not yet implemented!\n", __FUNCTION__); + + return 1; +} + +static int mgaEngineRestore( struct DRIDriverContextRec *ctx ) +{ + fprintf(stderr, "%s() is not yet implemented!\n", __FUNCTION__); + + return 1; } /** * \brief Exported driver interface for Mini GLX. * - * \sa MiniGLXDriverRec. + * \sa DRIDriverRec. */ -struct MiniGLXDriverRec __driMiniGLXDriver = { +struct DRIDriverRec __driDriver = { mgaInitScreenConfigs, mgaValidateMode, mgaPostValidateMode, mgaInitFBDev, mgaHaltFBDev, - mgaVTSwitchHandler + mgaEngineShutdown, + mgaEngineRestore }; @@ -1141,14 +1112,14 @@ void MGADRICloseScreen( ScreenPtr pScreen ) } if (pMga->irq) { - drmCtlUninstHandler(dpy->drmFD); + drmCtlUninstHandler(ctx->drmFD); pMga->irq = 0; } /* Cleanup DMA */ memset( &init, 0, sizeof(drmMGAInit) ); init.func = MGA_CLEANUP_DMA; - drmCommandWrite( dpy->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit) ); + drmCommandWrite( ctx->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit) ); if ( pMga->status.map ) { drmUnmap( pMga->status.map, pMga->status.size ); @@ -1173,10 +1144,10 @@ void MGADRICloseScreen( ScreenPtr pScreen ) } if ( pMga->agp.handle ) { - drmAgpUnbind( dpy->drmFD, pMga->agp.handle ); - drmAgpFree( dpy->drmFD, pMga->agp.handle ); + drmAgpUnbind( ctx->drmFD, pMga->agp.handle ); + drmAgpFree( ctx->drmFD, pMga->agp.handle ); pMga->agp.handle = 0; - drmAgpRelease( dpy->drmFD ); + drmAgpRelease( ctx->drmFD ); } DRICloseScreen( pScreen ); diff --git a/src/mesa/drivers/dri/radeon/server/radeon_dri.c b/src/mesa/drivers/dri/radeon/server/radeon_dri.c index d09fda8aff..5a733a3fb0 100644 --- a/src/mesa/drivers/dri/radeon/server/radeon_dri.c +++ b/src/mesa/drivers/dri/radeon/server/radeon_dri.c @@ -40,16 +40,16 @@ /** * \brief Wait for free FIFO entries. * - * \param dpy display handle. + * \param ctx display handle. * \param entries number of free entries to wait. * * It polls the free entries from the chip until it reaches the requested value * or a timeout (3000 tries) occurs. Aborts the program if the FIFO times out. */ -static void RADEONWaitForFifo( struct MiniGLXDisplayRec *dpy, +static void RADEONWaitForFifo( struct DRIDriverContextRec *ctx, int entries ) { - unsigned char *RADEONMMIO = dpy->MMIOAddress; + unsigned char *RADEONMMIO = ctx->MMIOAddress; int i; for (i = 0; i < 3000; i++) { @@ -70,14 +70,14 @@ static void RADEONWaitForFifo( struct MiniGLXDisplayRec *dpy, /** * \brief Read a PLL register. * - * \param dpy display handle. + * \param ctx display handle. * \param addr PLL register index. * * \return value of the PLL register. */ -static unsigned int RADEONINPLL( struct MiniGLXDisplayRec *dpy, int addr) +static unsigned int RADEONINPLL( struct DRIDriverContextRec *ctx, int addr) { - unsigned char *RADEONMMIO = dpy->MMIOAddress; + unsigned char *RADEONMMIO = ctx->MMIOAddress; unsigned int data; OUTREG8(RADEON_CLOCK_CNTL_INDEX, addr & 0x3f); @@ -89,13 +89,13 @@ static unsigned int RADEONINPLL( struct MiniGLXDisplayRec *dpy, int addr) /** * \brief Reset graphics card to known state. * - * \param dpy display handle. + * \param ctx display handle. * * Resets the values of several Radeon registers. */ -static void RADEONEngineReset( struct MiniGLXDisplayRec *dpy ) +static void RADEONEngineReset( struct DRIDriverContextRec *ctx ) { - unsigned char *RADEONMMIO = dpy->MMIOAddress; + unsigned char *RADEONMMIO = ctx->MMIOAddress; unsigned int clock_cntl_index; unsigned int mclk_cntl; unsigned int rbbm_soft_reset; @@ -112,7 +112,7 @@ static void RADEONEngineReset( struct MiniGLXDisplayRec *dpy ) clock_cntl_index = INREG(RADEON_CLOCK_CNTL_INDEX); - mclk_cntl = INPLL(dpy, RADEON_MCLK_CNTL); + mclk_cntl = INPLL(ctx, RADEON_MCLK_CNTL); OUTPLL(RADEON_MCLK_CNTL, (mclk_cntl | RADEON_FORCEON_MCLKA | RADEON_FORCEON_MCLKB | @@ -160,25 +160,25 @@ static void RADEONEngineReset( struct MiniGLXDisplayRec *dpy ) /** * \brief Restore the drawing engine. * - * \param dpy display handle + * \param ctx display handle * * Resets the graphics card and sets initial values for several registers of * the card's drawing engine. * * Turns on the radeon command processor engine (ie: the ringbuffer). */ -static int RADEONEngineRestore( struct MiniGLXDisplayRec *dpy ) +static int RADEONEngineRestore( struct DRIDriverContextRec *ctx ) { - RADEONInfoPtr info = dpy->driverInfo; - unsigned char *RADEONMMIO = dpy->MMIOAddress; + RADEONInfoPtr info = ctx->driverPrivate; + unsigned char *RADEONMMIO = ctx->MMIOAddress; int pitch64, datatype, dp_gui_master_cntl, err; fprintf(stderr, "%s\n", __FUNCTION__); OUTREG(RADEON_RB3D_CNTL, 0); - RADEONEngineReset( dpy ); + RADEONEngineReset( ctx ); - switch (dpy->bpp) { + switch (ctx->bpp) { case 16: datatype = 4; break; case 32: datatype = 6; break; default: return 0; @@ -188,25 +188,25 @@ static int RADEONEngineRestore( struct MiniGLXDisplayRec *dpy ) ((datatype << RADEON_GMC_DST_DATATYPE_SHIFT) | RADEON_GMC_CLR_CMP_CNTL_DIS); - pitch64 = ((dpy->shared.virtualWidth * (dpy->bpp / 8) + 0x3f)) >> 6; + pitch64 = ((ctx->shared.virtualWidth * (ctx->bpp / 8) + 0x3f)) >> 6; - RADEONWaitForFifo(dpy, 1); + RADEONWaitForFifo(ctx, 1); OUTREG(RADEON_DEFAULT_OFFSET, ((INREG(RADEON_DEFAULT_OFFSET) & 0xC0000000) | (pitch64 << 22))); - RADEONWaitForFifo(dpy, 1); + RADEONWaitForFifo(ctx, 1); OUTREG(RADEON_SURFACE_CNTL, RADEON_SURF_TRANSLATION_DIS); - RADEONWaitForFifo(dpy, 1); + RADEONWaitForFifo(ctx, 1); OUTREG(RADEON_DEFAULT_SC_BOTTOM_RIGHT, (RADEON_DEFAULT_SC_RIGHT_MAX | RADEON_DEFAULT_SC_BOTTOM_MAX)); - RADEONWaitForFifo(dpy, 1); + RADEONWaitForFifo(ctx, 1); OUTREG(RADEON_DP_GUI_MASTER_CNTL, (dp_gui_master_cntl | RADEON_GMC_BRUSH_SOLID_COLOR | RADEON_GMC_SRC_DATATYPE_COLOR)); - RADEONWaitForFifo(dpy, 7); + RADEONWaitForFifo(ctx, 7); OUTREG(RADEON_DST_LINE_START, 0); OUTREG(RADEON_DST_LINE_END, 0); OUTREG(RADEON_DP_BRUSH_FRGD_CLR, 0xffffffff); @@ -216,7 +216,7 @@ static int RADEONEngineRestore( struct MiniGLXDisplayRec *dpy ) OUTREG(RADEON_DP_WRITE_MASK, 0xffffffff); OUTREG(RADEON_AUX_SC_CNTL, 0); -/* RADEONWaitForIdleMMIO(dpy); */ +/* RADEONWaitForIdleMMIO(ctx); */ usleep(100); @@ -225,7 +225,7 @@ static int RADEONEngineRestore( struct MiniGLXDisplayRec *dpy ) /* Initialize and start the CP if required */ - if ((err = drmCommandNone(dpy->drmFD, DRM_RADEON_CP_START)) != 0) { + if ((err = drmCommandNone(ctx->drmFD, DRM_RADEON_CP_START)) != 0) { fprintf(stderr, "%s: CP start %d\n", __FUNCTION__, err); return 0; } @@ -237,12 +237,12 @@ static int RADEONEngineRestore( struct MiniGLXDisplayRec *dpy ) /** * \brief Shutdown the drawing engine. * - * \param dpy display handle + * \param ctx display handle * * Turns off the command processor engine & restores the graphics card * to a state that fbdev understands. */ -static int RADEONEngineShutdown( struct MiniGLXDisplayRec *dpy ) +static int RADEONEngineShutdown( struct DRIDriverContextRec *ctx ) { drmRadeonCPStop stop; int ret, i; @@ -250,7 +250,7 @@ static int RADEONEngineShutdown( struct MiniGLXDisplayRec *dpy ) stop.flush = 1; stop.idle = 1; - ret = drmCommandWrite(dpy->drmFD, DRM_RADEON_CP_STOP, &stop, + ret = drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_STOP, &stop, sizeof(drmRadeonCPStop)); if (ret == 0) { @@ -263,7 +263,7 @@ static int RADEONEngineShutdown( struct MiniGLXDisplayRec *dpy ) i = 0; do { - ret = drmCommandWrite(dpy->drmFD, DRM_RADEON_CP_STOP, &stop, + ret = drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_STOP, &stop, sizeof(drmRadeonCPStop)); } while (ret && errno == EBUSY && i++ < 10); @@ -275,7 +275,7 @@ static int RADEONEngineShutdown( struct MiniGLXDisplayRec *dpy ) stop.idle = 0; - if (drmCommandWrite(dpy->drmFD, DRM_RADEON_CP_STOP, + if (drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_STOP, &stop, sizeof(drmRadeonCPStop))) { return -errno; } else { @@ -302,7 +302,7 @@ static int RADEONMinBits(int val) /** * \brief Initialize the AGP state * - * \param dpy display handle. + * \param ctx display handle. * \param info driver private data. * * \return one on sucess, or zero on failure. @@ -311,14 +311,14 @@ static int RADEONMinBits(int val) * the ring buffer, vertex buffers and textures. Initialize the Radeon * registers to point to that memory and add client mappings. */ -static int RADEONDRIAgpInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info) +static int RADEONDRIAgpInit( struct DRIDriverContextRec *ctx, RADEONInfoPtr info) { - unsigned char *RADEONMMIO = dpy->MMIOAddress; + unsigned char *RADEONMMIO = ctx->MMIOAddress; unsigned long mode; int ret; int s, l; - if (drmAgpAcquire(dpy->drmFD) < 0) { + if (drmAgpAcquire(ctx->drmFD) < 0) { fprintf(stderr, "[agp] AGP not available\n"); return 0; } @@ -330,7 +330,7 @@ static int RADEONDRIAgpInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info) /* Modify the mode if the default mode is not appropriate for this * particular combination of graphics card and AGP chipset. */ - mode = drmAgpGetMode(dpy->drmFD); /* Default mode */ + mode = drmAgpGetMode(ctx->drmFD); /* Default mode */ /* Disable fast write entirely - too many lockups. */ @@ -341,29 +341,29 @@ static int RADEONDRIAgpInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info) case 1: default: mode |= RADEON_AGP_1X_MODE; } - if (drmAgpEnable(dpy->drmFD, mode) < 0) { + if (drmAgpEnable(ctx->drmFD, mode) < 0) { fprintf(stderr, "[agp] AGP not enabled\n"); - drmAgpRelease(dpy->drmFD); + drmAgpRelease(ctx->drmFD); return 0; } info->agpOffset = 0; - if ((ret = drmAgpAlloc(dpy->drmFD, info->agpSize*1024*1024, 0, NULL, + if ((ret = drmAgpAlloc(ctx->drmFD, info->agpSize*1024*1024, 0, NULL, &info->agpMemHandle)) < 0) { fprintf(stderr, "[agp] Out of memory (%d)\n", ret); - drmAgpRelease(dpy->drmFD); + drmAgpRelease(ctx->drmFD); return 0; } fprintf(stderr, "[agp] %d kB allocated with handle 0x%08x\n", info->agpSize*1024, (unsigned)info->agpMemHandle); - if (drmAgpBind(dpy->drmFD, + if (drmAgpBind(ctx->drmFD, info->agpMemHandle, info->agpOffset) < 0) { fprintf(stderr, "[agp] Could not bind\n"); - drmAgpFree(dpy->drmFD, info->agpMemHandle); - drmAgpRelease(dpy->drmFD); + drmAgpFree(ctx->drmFD, info->agpMemHandle); + drmAgpRelease(ctx->drmFD); return 0; } @@ -386,7 +386,7 @@ static int RADEONDRIAgpInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info) info->agpTexMapSize = (s >> l) << l; info->log2AGPTexGran = l; - if (drmAddMap(dpy->drmFD, info->ringStart, info->ringMapSize, + if (drmAddMap(ctx->drmFD, info->ringStart, info->ringMapSize, DRM_AGP, DRM_READ_ONLY, &info->ringHandle) < 0) { fprintf(stderr, "[agp] Could not add ring mapping\n"); return 0; @@ -394,7 +394,7 @@ static int RADEONDRIAgpInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info) fprintf(stderr, "[agp] ring handle = 0x%08lx\n", info->ringHandle); - if (drmAddMap(dpy->drmFD, info->ringReadOffset, info->ringReadMapSize, + if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize, DRM_AGP, DRM_READ_ONLY, &info->ringReadPtrHandle) < 0) { fprintf(stderr, "[agp] Could not add ring read ptr mapping\n"); @@ -405,7 +405,7 @@ static int RADEONDRIAgpInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info) "[agp] ring read ptr handle = 0x%08lx\n", info->ringReadPtrHandle); - if (drmAddMap(dpy->drmFD, info->bufStart, info->bufMapSize, + if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize, DRM_AGP, 0, &info->bufHandle) < 0) { fprintf(stderr, "[agp] Could not add vertex/indirect buffers mapping\n"); @@ -415,7 +415,7 @@ static int RADEONDRIAgpInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info) "[agp] vertex/indirect buffers handle = 0x%08lx\n", info->bufHandle); - if (drmAddMap(dpy->drmFD, info->agpTexStart, info->agpTexMapSize, + if (drmAddMap(ctx->drmFD, info->agpTexStart, info->agpTexMapSize, DRM_AGP, 0, &info->agpTexHandle) < 0) { fprintf(stderr, "[agp] Could not add AGP texture map mapping\n"); @@ -436,7 +436,7 @@ static int RADEONDRIAgpInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info) /** * \brief Initialize the kernel data structures and enable the CP engine. * - * \param dpy display handle. + * \param ctx display handle. * \param info driver private data. * * \return non-zero on sucess, or zero on failure. @@ -444,10 +444,10 @@ static int RADEONDRIAgpInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info) * This function is a wrapper around the DRM_RADEON_CP_INIT command, passing * all the parameters in a drmRadeonInit structure. */ -static int RADEONDRIKernelInit(struct MiniGLXDisplayRec *dpy, +static int RADEONDRIKernelInit(struct DRIDriverContextRec *ctx, RADEONInfoPtr info) { - int cpp = dpy->bpp / 8; + int cpp = ctx->bpp / 8; drmRadeonInit drmInfo; int ret; @@ -467,8 +467,8 @@ static int RADEONDRIKernelInit(struct MiniGLXDisplayRec *dpy, drmInfo.agp_size = info->agpSize*1024*1024; drmInfo.ring_size = info->ringSize*1024*1024; drmInfo.usec_timeout = 1000; - drmInfo.fb_bpp = dpy->bpp; - drmInfo.depth_bpp = dpy->bpp; + drmInfo.fb_bpp = ctx->bpp; + drmInfo.depth_bpp = ctx->bpp; drmInfo.front_offset = info->frontOffset; drmInfo.front_pitch = info->frontPitch * cpp; drmInfo.back_offset = info->backOffset; @@ -482,7 +482,7 @@ static int RADEONDRIKernelInit(struct MiniGLXDisplayRec *dpy, drmInfo.buffers_offset = info->bufHandle; drmInfo.agp_textures_offset = info->agpTexHandle; - ret = drmCommandWrite(dpy->drmFD, DRM_RADEON_CP_INIT, &drmInfo, + ret = drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_INIT, &drmInfo, sizeof(drmRadeonInit)); return ret >= 0; @@ -492,13 +492,13 @@ static int RADEONDRIKernelInit(struct MiniGLXDisplayRec *dpy, /** * \brief Initialize the AGP heap. * - * \param dpy display handle. + * \param ctx display handle. * \param info driver private data. * * This function is a wrapper around the DRM_RADEON_INIT_HEAP command, passing * all the parameters in a drm_radeon_mem_init_heap structure. */ -static void RADEONDRIAgpHeapInit(struct MiniGLXDisplayRec *dpy, +static void RADEONDRIAgpHeapInit(struct DRIDriverContextRec *ctx, RADEONInfoPtr info) { drmRadeonMemInitHeap drmHeap; @@ -508,7 +508,7 @@ static void RADEONDRIAgpHeapInit(struct MiniGLXDisplayRec *dpy, drmHeap.start = 0; drmHeap.size = info->agpTexMapSize; - if (drmCommandWrite(dpy->drmFD, DRM_RADEON_INIT_HEAP, + if (drmCommandWrite(ctx->drmFD, DRM_RADEON_INIT_HEAP, &drmHeap, sizeof(drmHeap))) { fprintf(stderr, "[drm] Failed to initialized agp heap manager\n"); @@ -523,17 +523,17 @@ static void RADEONDRIAgpHeapInit(struct MiniGLXDisplayRec *dpy, * \brief Add a map for the vertex buffers that will be accessed by any * DRI-based clients. * - * \param dpy display handle. + * \param ctx display handle. * \param info driver private data. * * \return one on sucess, or zero on failure. * * Calls drmAddBufs() with the previously allocated vertex buffers. */ -static int RADEONDRIBufInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) +static int RADEONDRIBufInit( struct DRIDriverContextRec *ctx, RADEONInfoPtr info ) { /* Initialize vertex buffers */ - info->bufNumBufs = drmAddBufs(dpy->drmFD, + info->bufNumBufs = drmAddBufs(ctx->drmFD, info->bufMapSize / RADEON_BUFFER_SIZE, RADEON_BUFFER_SIZE, DRM_AGP_BUFFER, @@ -554,22 +554,22 @@ static int RADEONDRIBufInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) /** * \brief Install an IRQ handler. * - * \param dpy display handle. + * \param ctx display handle. * \param info driver private data. * * Attemps to install an IRQ handler via drmCtlInstHandler(), falling back to * IRQ-free operation on failure. */ -static void RADEONDRIIrqInit(struct MiniGLXDisplayRec *dpy, +static void RADEONDRIIrqInit(struct DRIDriverContextRec *ctx, RADEONInfoPtr info) { if (!info->irq) { - info->irq = drmGetInterruptFromBusID(dpy->drmFD, - dpy->pciBus, - dpy->pciDevice, - dpy->pciFunc); + info->irq = drmGetInterruptFromBusID(ctx->drmFD, + ctx->pciBus, + ctx->pciDevice, + ctx->pciFunc); - if ((drmCtlInstHandler(dpy->drmFD, info->irq)) != 0) { + if ((drmCtlInstHandler(ctx->drmFD, info->irq)) != 0) { fprintf(stderr, "[drm] failure adding irq handler, " "there is a device already using that irq\n" @@ -584,12 +584,12 @@ static void RADEONDRIIrqInit(struct MiniGLXDisplayRec *dpy, info->irq); } -static int RADEONCheckDRMVersion( struct MiniGLXDisplayRec *dpy, +static int RADEONCheckDRMVersion( struct DRIDriverContextRec *ctx, RADEONInfoPtr info ) { drmVersionPtr version; - version = drmGetVersion(dpy->drmFD); + version = drmGetVersion(ctx->drmFD); if (version) { int req_minor, req_patch; @@ -625,20 +625,20 @@ static int RADEONCheckDRMVersion( struct MiniGLXDisplayRec *dpy, return 1; } -static int RADEONMemoryInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) +static int RADEONMemoryInit( struct DRIDriverContextRec *ctx, RADEONInfoPtr info ) { - int width_bytes = dpy->shared.virtualWidth * dpy->cpp; - int cpp = dpy->cpp; - int bufferSize = ((dpy->shared.virtualHeight * width_bytes + int width_bytes = ctx->shared.virtualWidth * ctx->cpp; + int cpp = ctx->cpp; + int bufferSize = ((ctx->shared.virtualHeight * width_bytes + RADEON_BUFFER_ALIGN) & ~RADEON_BUFFER_ALIGN); - int depthSize = ((((dpy->shared.virtualHeight+15) & ~15) * width_bytes + int depthSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes + RADEON_BUFFER_ALIGN) & ~RADEON_BUFFER_ALIGN); int l; info->frontOffset = 0; - info->frontPitch = dpy->shared.virtualWidth; + info->frontPitch = ctx->shared.virtualWidth; fprintf(stderr, "Using %d MB AGP aperture\n", info->agpSize); @@ -651,7 +651,7 @@ static int RADEONMemoryInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) /* Front, back and depth buffers - everything else texture?? */ - info->textureSize = dpy->shared.fbSize - 2 * bufferSize - depthSize; + info->textureSize = ctx->shared.fbSize - 2 * bufferSize - depthSize; if (info->textureSize < 0) return 0; @@ -675,7 +675,7 @@ static int RADEONMemoryInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) } /* Reserve space for textures */ - info->textureOffset = ((dpy->shared.fbSize - info->textureSize + + info->textureOffset = ((ctx->shared.fbSize - info->textureSize + RADEON_BUFFER_ALIGN) & ~RADEON_BUFFER_ALIGN); @@ -685,12 +685,12 @@ static int RADEONMemoryInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) info->depthOffset = ((info->textureOffset - depthSize + RADEON_BUFFER_ALIGN) & ~RADEON_BUFFER_ALIGN); - info->depthPitch = dpy->shared.virtualWidth; + info->depthPitch = ctx->shared.virtualWidth; info->backOffset = ((info->depthOffset - bufferSize + RADEON_BUFFER_ALIGN) & ~RADEON_BUFFER_ALIGN); - info->backPitch = dpy->shared.virtualWidth; + info->backPitch = ctx->shared.virtualWidth; fprintf(stderr, @@ -720,7 +720,7 @@ static int RADEONMemoryInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) /** * Called at the start of each server generation. * - * \param dpy display handle. + * \param ctx display handle. * \param info driver private data. * * \return non-zero on sucess, or zero on failure. @@ -734,26 +734,26 @@ static int RADEONMemoryInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) * Setups a RADEONDRIRec structure to be passed to radeon_dri.so for its * initialization. */ -static int RADEONScreenInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) +static int RADEONScreenInit( struct DRIDriverContextRec *ctx, RADEONInfoPtr info ) { RADEONDRIPtr pRADEONDRI; int err; usleep(100); - assert(!dpy->IsClient); + //assert(!ctx->IsClient); { - int width_bytes = (dpy->shared.virtualWidth * dpy->cpp); - int maxy = dpy->shared.fbSize / width_bytes; + int width_bytes = (ctx->shared.virtualWidth * ctx->cpp); + int maxy = ctx->shared.fbSize / width_bytes; - if (maxy <= dpy->shared.virtualHeight * 3) { + if (maxy <= ctx->shared.virtualHeight * 3) { fprintf(stderr, "Static buffer allocation failed -- " "need at least %d kB video memory (have %d kB)\n", - (dpy->shared.virtualWidth * dpy->shared.virtualHeight * - dpy->cpp * 3 + 1023) / 1024, - dpy->shared.fbSize / 1024); + (ctx->shared.virtualWidth * ctx->shared.virtualHeight * + ctx->cpp * 3 + 1023) / 1024, + ctx->shared.fbSize / 1024); return 0; } } @@ -766,68 +766,68 @@ static int RADEONScreenInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) return 0; } - info->registerSize = dpy->FixedInfo.mmio_len; - dpy->shared.SAREASize = DRM_PAGE_SIZE; + info->registerSize = ctx->MMIOSize; + ctx->shared.SAREASize = DRM_PAGE_SIZE; /* Note that drmOpen will try to load the kernel module, if needed. */ - dpy->drmFD = drmOpen("radeon", NULL ); - if (dpy->drmFD < 0) { + ctx->drmFD = drmOpen("radeon", NULL ); + if (ctx->drmFD < 0) { fprintf(stderr, "[drm] drmOpen failed\n"); return 0; } - if ((err = drmSetBusid(dpy->drmFD, dpy->pciBusID)) < 0) { + if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) { fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - dpy->drmFD, dpy->pciBusID, strerror(-err)); + ctx->drmFD, ctx->pciBusID, strerror(-err)); return 0; } - if (drmAddMap( dpy->drmFD, + if (drmAddMap( ctx->drmFD, 0, - dpy->shared.SAREASize, + ctx->shared.SAREASize, DRM_SHM, DRM_CONTAINS_LOCK, - &dpy->shared.hSAREA) < 0) + &ctx->shared.hSAREA) < 0) { fprintf(stderr, "[drm] drmAddMap failed\n"); return 0; } fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - dpy->shared.SAREASize, dpy->shared.hSAREA); + ctx->shared.SAREASize, ctx->shared.hSAREA); - if (drmMap( dpy->drmFD, - dpy->shared.hSAREA, - dpy->shared.SAREASize, - (drmAddressPtr)(&dpy->pSAREA)) < 0) + if (drmMap( ctx->drmFD, + ctx->shared.hSAREA, + ctx->shared.SAREASize, + (drmAddressPtr)(&ctx->pSAREA)) < 0) { fprintf(stderr, "[drm] drmMap failed\n"); return 0; } - memset(dpy->pSAREA, 0, dpy->shared.SAREASize); + memset(ctx->pSAREA, 0, ctx->shared.SAREASize); fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - dpy->shared.hSAREA, dpy->pSAREA, dpy->shared.SAREASize); + ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize); /* Need to AddMap the framebuffer and mmio regions here: */ - if (drmAddMap( dpy->drmFD, - (drmHandle)dpy->FixedInfo.smem_start, - dpy->FixedInfo.smem_len, + if (drmAddMap( ctx->drmFD, + (drmHandle)ctx->FBStart, + ctx->FBSize, DRM_FRAME_BUFFER, 0, - &dpy->shared.hFrameBuffer) < 0) + &ctx->shared.hFrameBuffer) < 0) { fprintf(stderr, "[drm] drmAddMap framebuffer failed\n"); return 0; } fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n", - dpy->shared.hFrameBuffer); + ctx->shared.hFrameBuffer); - if (drmAddMap(dpy->drmFD, - dpy->FixedInfo.mmio_start, - dpy->FixedInfo.mmio_len, + if (drmAddMap(ctx->drmFD, + ctx->MMIOStart, + ctx->MMIOSize, DRM_REGISTERS, DRM_READ_ONLY, &info->registerHandle) < 0) { @@ -838,61 +838,61 @@ static int RADEONScreenInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) "[drm] register handle = 0x%08lx\n", info->registerHandle); /* Check the radeon DRM version */ - if (!RADEONCheckDRMVersion(dpy, info)) { + if (!RADEONCheckDRMVersion(ctx, info)) { return 0; } /* Initialize AGP */ - if (!RADEONDRIAgpInit(dpy, info)) { + if (!RADEONDRIAgpInit(ctx, info)) { return 0; } /* Memory manager setup */ - if (!RADEONMemoryInit(dpy, info)) { + if (!RADEONMemoryInit(ctx, info)) { return 0; } /* Create a 'server' context so we can grab the lock for * initialization ioctls. */ - if ((err = drmCreateContext(dpy->drmFD, &dpy->serverContext)) != 0) { + if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) { fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); return 0; } - DRM_LOCK(dpy->drmFD, dpy->pSAREA, dpy->serverContext, 0); + DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0); /* Initialize the kernel data structures */ - if (!RADEONDRIKernelInit(dpy, info)) { + if (!RADEONDRIKernelInit(ctx, info)) { fprintf(stderr, "RADEONDRIKernelInit failed\n"); - DRM_UNLOCK(dpy->drmFD, dpy->pSAREA, dpy->serverContext); + DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); return 0; } /* Initialize the vertex buffers list */ - if (!RADEONDRIBufInit(dpy, info)) { + if (!RADEONDRIBufInit(ctx, info)) { fprintf(stderr, "RADEONDRIBufInit failed\n"); - DRM_UNLOCK(dpy->drmFD, dpy->pSAREA, dpy->serverContext); + DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); return 0; } /* Initialize IRQ */ - RADEONDRIIrqInit(dpy, info); + RADEONDRIIrqInit(ctx, info); /* Initialize kernel agp memory manager */ - RADEONDRIAgpHeapInit(dpy, info); + RADEONDRIAgpHeapInit(ctx, info); fprintf(stderr, "calling RADEONEngineRestore from %s\n", __FUNCTION__); - if (0 && !RADEONEngineRestore( dpy )) { - DRM_UNLOCK(dpy->drmFD, dpy->pSAREA, dpy->serverContext); + if (0 && !RADEONEngineRestore( ctx )) { + DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); return 0; } /* Initialize the SAREA private data structure */ { RADEONSAREAPrivPtr pSAREAPriv; - pSAREAPriv = (RADEONSAREAPrivPtr)(((char*)dpy->pSAREA) + + pSAREAPriv = (RADEONSAREAPrivPtr)(((char*)ctx->pSAREA) + sizeof(XF86DRISAREARec)); memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); pSAREAPriv->pfAllowPageFlip = 1; @@ -903,27 +903,27 @@ static int RADEONScreenInit( struct MiniGLXDisplayRec *dpy, RADEONInfoPtr info ) * the clear ioctl to do this, but would need to setup hw state * first. */ - memset(dpy->FrameBuffer + info->frontOffset, + memset(ctx->FBAddress + info->frontOffset, 0, - info->frontPitch * dpy->cpp * dpy->shared.virtualHeight ); + info->frontPitch * ctx->cpp * ctx->shared.virtualHeight ); - memset(dpy->FrameBuffer + info->backOffset, + memset(ctx->FBAddress + info->backOffset, 0, - info->backPitch * dpy->cpp * dpy->shared.virtualHeight ); + info->backPitch * ctx->cpp * ctx->shared.virtualHeight ); /* Can release the lock now */ -/* DRM_UNLOCK(dpy->drmFD, dpy->pSAREA, dpy->serverContext); */ +/* DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); */ /* This is the struct passed to radeon_dri.so for its initialization */ - dpy->driverClientMsg = malloc(sizeof(RADEONDRIRec)); - dpy->driverClientMsgSize = sizeof(RADEONDRIRec); - pRADEONDRI = (RADEONDRIPtr)dpy->driverClientMsg; + ctx->driverClientMsg = malloc(sizeof(RADEONDRIRec)); + ctx->driverClientMsgSize = sizeof(RADEONDRIRec); + pRADEONDRI = (RADEONDRIPtr)ctx->driverClientMsg; pRADEONDRI->deviceID = info->Chipset; - pRADEONDRI->width = dpy->shared.virtualWidth; - pRADEONDRI->height = dpy->shared.virtualHeight; - pRADEONDRI->depth = dpy->bpp; /* XXX: depth */ - pRADEONDRI->bpp = dpy->bpp; + pRADEONDRI->width = ctx->shared.virtualWidth; + pRADEONDRI->height = ctx->shared.virtualHeight; + pRADEONDRI->depth = ctx->bpp; /* XXX: depth */ + pRADEONDRI->bpp = ctx->bpp; pRADEONDRI->IsPCI = 0; pRADEONDRI->AGPMode = info->agpMode; pRADEONDRI->frontOffset = info->frontOffset; @@ -1025,7 +1025,7 @@ static int get_chipfamily_from_chipset( RADEONInfoPtr info ) /** * \brief Establish the set of visuals available for the display. * - * \param dpy display handle. + * \param ctx display handle. * \param numConfigs will receive the number of supported visuals. * \param configs will point to the list of supported visuals. * @@ -1037,7 +1037,7 @@ static int get_chipfamily_from_chipset( RADEONInfoPtr info ) * display bit depth. Supports only 16 and 32 bpp bit depths, aborting * otherwise. */ -static int radeonInitScreenConfigs( struct MiniGLXDisplayRec *dpy, +static int radeonInitScreenConfigs( struct DRIDriverContextRec *ctx, int *numConfigs, __GLXvisualConfig **configs) { int i; @@ -1046,7 +1046,7 @@ static int radeonInitScreenConfigs( struct MiniGLXDisplayRec *dpy, *configs = (__GLXvisualConfig *) calloc(*numConfigs, sizeof(__GLXvisualConfig)); - switch (dpy->bpp) { + switch (ctx->bpp) { case 32: for (i = 0; i < *numConfigs; i++) { (*configs)[i].vid = 100 + i; @@ -1097,7 +1097,7 @@ static int radeonInitScreenConfigs( struct MiniGLXDisplayRec *dpy, default: fprintf(stderr, "Unknown bpp in %s: %d\n", __FUNCTION__, - dpy->bpp); + ctx->bpp); exit(1); break; @@ -1109,7 +1109,7 @@ static int radeonInitScreenConfigs( struct MiniGLXDisplayRec *dpy, /** * \brief Validate the fbdev mode. * - * \param dpy display handle. + * \param ctx display handle. * * \return one on success, or zero on failure. * @@ -1117,10 +1117,10 @@ static int radeonInitScreenConfigs( struct MiniGLXDisplayRec *dpy, * * \sa radeonValidateMode(). */ -static int radeonValidateMode( struct MiniGLXDisplayRec *dpy ) +static int radeonValidateMode( struct DRIDriverContextRec *ctx ) { - unsigned char *RADEONMMIO = dpy->MMIOAddress; - RADEONInfoPtr info = dpy->driverInfo; + unsigned char *RADEONMMIO = ctx->MMIOAddress; + RADEONInfoPtr info = ctx->driverPrivate; info->gen_int_cntl = INREG(RADEON_GEN_INT_CNTL); info->crtc_offset_cntl = INREG(RADEON_CRTC_OFFSET_CNTL); @@ -1132,7 +1132,7 @@ static int radeonValidateMode( struct MiniGLXDisplayRec *dpy ) /** * \brief Examine mode returned by fbdev. * - * \param dpy display handle. + * \param ctx display handle. * * \return one on success, or zero on failure. * @@ -1140,10 +1140,10 @@ static int radeonValidateMode( struct MiniGLXDisplayRec *dpy ) * * \sa radeonValidateMode(). */ -static int radeonPostValidateMode( struct MiniGLXDisplayRec *dpy ) +static int radeonPostValidateMode( struct DRIDriverContextRec *ctx ) { - unsigned char *RADEONMMIO = dpy->MMIOAddress; - RADEONInfoPtr info = dpy->driverInfo; + unsigned char *RADEONMMIO = ctx->MMIOAddress; + RADEONInfoPtr info = ctx->driverPrivate; OUTREG(RADEON_GEN_INT_CNTL, info->gen_int_cntl); OUTREG(RADEON_CRTC_OFFSET_CNTL, info->crtc_offset_cntl); @@ -1155,33 +1155,33 @@ static int radeonPostValidateMode( struct MiniGLXDisplayRec *dpy ) /** * \brief Initialize the framebuffer device mode * - * \param dpy display handle. + * \param ctx display handle. * * \return one on success, or zero on failure. * - * Fills in \p info with some default values and some information from \p dpy + * Fills in \p info with some default values and some information from \p ctx * and then calls RADEONScreenInit() for the screen initialization. * * Before exiting clears the framebuffer memomry accessing it directly. */ -static int radeonInitFBDev( struct MiniGLXDisplayRec *dpy ) +static int radeonInitFBDev( struct DRIDriverContextRec *ctx ) { RADEONInfoPtr info = calloc(1, sizeof(*info)); { - int dummy = dpy->shared.virtualWidth; + int dummy = ctx->shared.virtualWidth; - switch (dpy->bpp / 8) { - case 1: dummy = (dpy->shared.virtualWidth + 127) & ~127; break; - case 2: dummy = (dpy->shared.virtualWidth + 31) & ~31; break; + switch (ctx->bpp / 8) { + case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break; + case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break; case 3: - case 4: dummy = (dpy->shared.virtualWidth + 15) & ~15; break; + case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break; } - dpy->shared.virtualWidth = dummy; + ctx->shared.virtualWidth = dummy; } - dpy->driverInfo = (void *)info; + ctx->driverPrivate = (void *)info; info->agpFastWrite = RADEON_DEFAULT_AGP_FAST_WRITE; info->agpMode = RADEON_DEFAULT_AGP_MODE; @@ -1190,7 +1190,7 @@ static int radeonInitFBDev( struct MiniGLXDisplayRec *dpy ) info->bufSize = RADEON_DEFAULT_BUFFER_SIZE; info->ringSize = RADEON_DEFAULT_RING_SIZE; - info->Chipset = dpy->chipset; + info->Chipset = ctx->chipset; if (!get_chipfamily_from_chipset( info )) { fprintf(stderr, "Unknown or non-radeon chipset -- cannot continue\n"); @@ -1198,11 +1198,11 @@ static int radeonInitFBDev( struct MiniGLXDisplayRec *dpy ) return 0; } - info->frontPitch = dpy->shared.virtualWidth; - info->LinearAddr = dpy->FixedInfo.smem_start & 0xfc000000; + info->frontPitch = ctx->shared.virtualWidth; + info->LinearAddr = ctx->FBStart & 0xfc000000; - if (!RADEONScreenInit( dpy, info )) + if (!RADEONScreenInit( ctx, info )) return 0; @@ -1214,19 +1214,19 @@ static int radeonInitFBDev( struct MiniGLXDisplayRec *dpy ) * \brief The screen is being closed, so clean up any state and free any * resources used by the DRI. * - * \param dpy display handle. + * \param ctx display handle. * * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver * private data. */ -static void radeonHaltFBDev( struct MiniGLXDisplayRec *dpy ) +static void radeonHaltFBDev( struct DRIDriverContextRec *ctx ) { - drmUnmap( dpy->pSAREA, dpy->shared.SAREASize ); - drmClose(dpy->drmFD); + drmUnmap( ctx->pSAREA, ctx->shared.SAREASize ); + drmClose(ctx->drmFD); - if (dpy->driverInfo) { - free(dpy->driverInfo); - dpy->driverInfo = 0; + if (ctx->driverPrivate) { + free(ctx->driverPrivate); + ctx->driverPrivate = 0; } } @@ -1235,9 +1235,9 @@ static void radeonHaltFBDev( struct MiniGLXDisplayRec *dpy ) /** * \brief Exported driver interface for Mini GLX. * - * \sa MiniGLXDriverRec. + * \sa DRIDriverRec. */ -struct MiniGLXDriverRec __driMiniGLXDriver = { +struct DRIDriverRec __driDRIDriver = { radeonInitScreenConfigs, radeonValidateMode, radeonPostValidateMode, diff --git a/src/miniglx/dri_util.c b/src/miniglx/dri_util.c index 2a3c2000ce..e8cad64d49 100644 --- a/src/miniglx/dri_util.c +++ b/src/miniglx/dri_util.c @@ -621,7 +621,7 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, psp->display = dpy; psp->myNum = scrn; - psp->fd = drmOpen(NULL,dpy->pciBusID); + psp->fd = drmOpen(NULL,dpy->driverContext.pciBusID); if (psp->fd < 0) { fprintf(stderr, "libGL error: failed to open DRM: %s\n", strerror(-psp->fd)); @@ -665,19 +665,19 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, * ancilliary buffers, DRM mmap handles, etc. */ psp->fbOrigin = 0; - psp->fbSize = dpy->shared.fbSize; - psp->fbStride = dpy->shared.fbStride; - psp->devPrivSize = dpy->driverClientMsgSize; - psp->pDevPriv = dpy->driverClientMsg; - psp->fbWidth = dpy->shared.virtualWidth; - psp->fbHeight = dpy->shared.virtualHeight; - psp->fbBPP = dpy->bpp; + psp->fbSize = dpy->driverContext.shared.fbSize; + psp->fbStride = dpy->driverContext.shared.fbStride; + psp->devPrivSize = dpy->driverContext.driverClientMsgSize; + psp->pDevPriv = dpy->driverContext.driverClientMsg; + psp->fbWidth = dpy->driverContext.shared.virtualWidth; + psp->fbHeight = dpy->driverContext.shared.virtualHeight; + psp->fbBPP = dpy->driverContext.bpp; if (dpy->IsClient) { /* * Map the framebuffer region. */ - if (drmMap(psp->fd, dpy->shared.hFrameBuffer, psp->fbSize, + if (drmMap(psp->fd, dpy->driverContext.shared.hFrameBuffer, psp->fbSize, (drmAddressPtr)&psp->pFB)) { fprintf(stderr, "libGL error: drmMap of framebuffer failed\n"); (void)drmClose(psp->fd); @@ -689,7 +689,8 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, * Map the SAREA region. Further mmap regions may be setup in * each DRI driver's "createScreen" function. */ - if (drmMap(psp->fd, dpy->shared.hSAREA, dpy->shared.SAREASize, + if (drmMap(psp->fd, dpy->driverContext.shared.hSAREA, + dpy->driverContext.shared.SAREASize, (drmAddressPtr)&psp->pSAREA)) { fprintf(stderr, "libGL error: drmMap of sarea failed\n"); (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize); @@ -698,8 +699,8 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, return NULL; } } else { - psp->pFB = dpy->FrameBuffer; - psp->pSAREA = dpy->pSAREA; + psp->pFB = dpy->driverContext.FBAddress; + psp->pSAREA = dpy->driverContext.pSAREA; } @@ -752,15 +753,15 @@ __driUtilCreateScreenNoDRM(Display *dpy, int scrn, __DRIscreen *psc, psp->fd = 0; psp->fbOrigin = 0; - psp->fbSize = dpy->shared.fbSize; - psp->fbStride = dpy->shared.fbStride; - psp->devPrivSize = dpy->driverClientMsgSize; - psp->pDevPriv = dpy->driverClientMsg; - psp->fbWidth = dpy->shared.virtualWidth; - psp->fbHeight = dpy->shared.virtualHeight; - psp->fbBPP = dpy->bpp; + psp->fbSize = dpy->driverContext.shared.fbSize; + psp->fbStride = dpy->driverContext.shared.fbStride; + psp->devPrivSize = dpy->driverContext.driverClientMsgSize; + psp->pDevPriv = dpy->driverContext.driverClientMsg; + psp->fbWidth = dpy->driverContext.shared.virtualWidth; + psp->fbHeight = dpy->driverContext.shared.virtualHeight; + psp->fbBPP = dpy->driverContext.bpp; - psp->pFB = dpy->FrameBuffer; + psp->pFB = dpy->driverContext.FBAddress; /* install driver's callback functions */ memcpy(&psp->DriverAPI, driverAPI, sizeof(struct __DriverAPIRec)); diff --git a/src/miniglx/miniglx.c b/src/miniglx/miniglx.c index a03978e81d..cd83e6fb17 100644 --- a/src/miniglx/miniglx.c +++ b/src/miniglx/miniglx.c @@ -22,7 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $Id: miniglx.c,v 1.1.4.52 2003/04/25 11:22:36 keithw Exp $ */ +/* $Id: miniglx.c,v 1.1.4.53 2003/04/26 21:17:47 keithw Exp $ */ /** @@ -308,34 +308,38 @@ OpenFBDev( Display *dpy ) /* mmap the framebuffer into our address space */ - dpy->shared.fbSize = dpy->FixedInfo.smem_len; - dpy->FrameBuffer = (caddr_t) mmap(0, /* start */ - dpy->shared.fbSize, /* bytes */ + dpy->driverContext.FBStart = dpy->FixedInfo.smem_start; + dpy->driverContext.FBSize = dpy->FixedInfo.smem_len; + dpy->driverContext.shared.fbSize = dpy->FixedInfo.smem_len; + dpy->driverContext.FBAddress = (caddr_t) mmap(0, /* start */ + dpy->driverContext.shared.fbSize, /* bytes */ PROT_READ | PROT_WRITE, /* prot */ MAP_SHARED, /* flags */ dpy->FrameBufferFD, /* fd */ 0 /* offset */); - if (dpy->FrameBuffer == (caddr_t) - 1) { + if (dpy->driverContext.FBAddress == (caddr_t) - 1) { fprintf(stderr, "error: unable to mmap framebuffer: %s\n", strerror(errno)); return GL_FALSE; } /* mmap the MMIO region into our address space */ - dpy->MMIOSize = dpy->FixedInfo.mmio_len; - dpy->MMIOAddress = (caddr_t) mmap(0, /* start */ - dpy->MMIOSize, /* bytes */ + dpy->driverContext.MMIOStart = dpy->FixedInfo.mmio_start; + dpy->driverContext.MMIOSize = dpy->FixedInfo.mmio_len; + dpy->driverContext.MMIOAddress = (caddr_t) mmap(0, /* start */ + dpy->driverContext.MMIOSize, /* bytes */ PROT_READ | PROT_WRITE, /* prot */ MAP_SHARED, /* flags */ dpy->FrameBufferFD, /* fd */ dpy->FixedInfo.smem_len /* offset */); - if (dpy->MMIOAddress == (caddr_t) - 1) { + if (dpy->driverContext.MMIOAddress == (caddr_t) - 1) { fprintf(stderr, "error: unable to mmap mmio region: %s\n", strerror(errno)); return GL_FALSE; } - fprintf(stderr, "got MMIOAddress %p offset %d\n", dpy->MMIOAddress, + fprintf(stderr, "got MMIOAddress %p offset %d\n", + dpy->driverContext.MMIOAddress, dpy->FixedInfo.smem_len); return GL_TRUE; @@ -377,8 +381,8 @@ SetupFBDev( Display *dpy ) assert(dpy); - width = dpy->shared.virtualWidth; - height = dpy->shared.virtualHeight; + width = dpy->driverContext.shared.virtualWidth; + height = dpy->driverContext.shared.virtualHeight; /* Bump size up to next supported mode. */ @@ -396,14 +400,14 @@ SetupFBDev( Display *dpy ) } - dpy->shared.virtualHeight = height; - dpy->shared.virtualWidth = width; + dpy->driverContext.shared.virtualHeight = height; + dpy->driverContext.shared.virtualWidth = width; /* set the depth, resolution, etc */ dpy->VarInfo = dpy->OrigVarInfo; - dpy->VarInfo.bits_per_pixel = dpy->bpp; - dpy->VarInfo.xres_virtual = dpy->shared.virtualWidth; - dpy->VarInfo.yres_virtual = dpy->shared.virtualHeight; + dpy->VarInfo.bits_per_pixel = dpy->driverContext.bpp; + dpy->VarInfo.xres_virtual = dpy->driverContext.shared.virtualWidth; + dpy->VarInfo.yres_virtual = dpy->driverContext.shared.virtualHeight; dpy->VarInfo.xres = width; dpy->VarInfo.yres = height; dpy->VarInfo.xoffset = 0; @@ -436,7 +440,7 @@ SetupFBDev( Display *dpy ) return 0; } - if (!dpy->driver->validateMode( dpy )) { + if (!dpy->driver->validateMode( &dpy->driverContext )) { fprintf(stderr, "Driver validateMode() failed\n"); return 0; } @@ -562,7 +566,7 @@ SetupFBDev( Display *dpy ) /* May need to restore regs fbdev has clobbered: */ - if (!dpy->driver->postValidateMode( dpy )) { + if (!dpy->driver->postValidateMode( &dpy->driverContext )) { fprintf(stderr, "Driver postValidateMode() failed\n"); return 0; } @@ -616,8 +620,8 @@ CloseFBDev( Display *dpy ) { struct vt_mode VT; - munmap(dpy->FrameBuffer, dpy->shared.fbSize); - munmap(dpy->MMIOAddress, dpy->MMIOSize); + munmap(dpy->driverContext.FBAddress, dpy->driverContext.FBSize); + munmap(dpy->driverContext.MMIOAddress, dpy->driverContext.MMIOSize); /* restore text mode */ ioctl(dpy->ConsoleFD, KDSETMODE, KD_TEXT); @@ -728,7 +732,9 @@ static int get_chipset_from_busid( Display *dpy ) if (nr != 5) break; - if (bus == dpy->pciBus && dev == dpy->pciDevice && fn == dpy->pciFunc) { + if (bus == dpy->driverContext.pciBus && + dev == dpy->driverContext.pciDevice && + fn == dpy->driverContext.pciFunc) { retval = device; break; } @@ -771,15 +777,15 @@ static int __read_config_file( Display *dpy ) */ dpy->fbdevDevice = "/dev/fb0"; dpy->clientDriverName = "fb_dri.so"; - dpy->pciBus = 0; - dpy->pciDevice = 0; - dpy->pciFunc = 0; - dpy->chipset = 0; - dpy->pciBusID = 0; - dpy->shared.virtualWidth = 1280; - dpy->shared.virtualHeight = 1024; - dpy->bpp = 32; - dpy->cpp = 4; + dpy->driverContext.pciBus = 0; + dpy->driverContext.pciDevice = 0; + dpy->driverContext.pciFunc = 0; + dpy->driverContext.chipset = 0; + dpy->driverContext.pciBusID = 0; + dpy->driverContext.shared.virtualWidth = 1280; + dpy->driverContext.shared.virtualHeight = 1024; + dpy->driverContext.bpp = 32; + dpy->driverContext.cpp = 4; dpy->rotateMode = 0; fname = getenv("MINIGLX_CONF"); @@ -821,35 +827,37 @@ static int __read_config_file( Display *dpy ) dpy->rotateMode = atoi(val) ? 1 : 0; else if (strcmp(opt, "pciBusID") == 0) { if (sscanf(val, "PCI:%d:%d:%d", - &dpy->pciBus, &dpy->pciDevice, &dpy->pciFunc) != 3) { + &dpy->driverContext.pciBus, + &dpy->driverContext.pciDevice, + &dpy->driverContext.pciFunc) != 3) { fprintf(stderr, "malformed bus id: %s\n", val); continue; } - dpy->pciBusID = strdup(val); + dpy->driverContext.pciBusID = strdup(val); } else if (strcmp(opt, "chipset") == 0) { - if (sscanf(val, "0x%x", &dpy->chipset) != 1) + if (sscanf(val, "0x%x", &dpy->driverContext.chipset) != 1) fprintf(stderr, "malformed chipset: %s\n", opt); } else if (strcmp(opt, "virtualWidth") == 0) { - if (sscanf(val, "%d", &dpy->shared.virtualWidth) != 1) + if (sscanf(val, "%d", &dpy->driverContext.shared.virtualWidth) != 1) fprintf(stderr, "malformed virtualWidth: %s\n", opt); } else if (strcmp(opt, "virtualHeight") == 0) { - if (sscanf(val, "%d", &dpy->shared.virtualHeight) != 1) + if (sscanf(val, "%d", &dpy->driverContext.shared.virtualHeight) != 1) fprintf(stderr, "malformed virutalHeight: %s\n", opt); } else if (strcmp(opt, "bpp") == 0) { - if (sscanf(val, "%d", &dpy->bpp) != 1) + if (sscanf(val, "%d", &dpy->driverContext.bpp) != 1) fprintf(stderr, "malformed bpp: %s\n", opt); - dpy->cpp = dpy->bpp / 8; + dpy->driverContext.cpp = dpy->driverContext.bpp / 8; } } fclose(file); - if (dpy->chipset == 0 && dpy->pciBusID != 0) - dpy->chipset = get_chipset_from_busid( dpy ); + if (dpy->driverContext.chipset == 0 && dpy->driverContext.pciBusID != 0) + dpy->driverContext.chipset = get_chipset_from_busid( dpy ); return 1; } @@ -870,10 +878,10 @@ static int InitDriver( Display *dpy ) /* Pull in Mini GLX specific hooks: */ - dpy->driver = (struct MiniGLXDriverRec *) dlsym(dpy->dlHandle, - "__driMiniGLXDriver"); + dpy->driver = (struct DRIDriverRec *) dlsym(dpy->dlHandle, + "__driDriver"); if (!dpy->driver) { - fprintf(stderr, "Couldn't find __driMiniGLXDriver in %s\n", + fprintf(stderr, "Couldn't find __driDriver in %s\n", dpy->clientDriverName); dlclose(dpy->dlHandle); return GL_FALSE; @@ -911,10 +919,10 @@ static int InitDriver( Display *dpy ) * configuration file. * * Calls OpenFBDev() to open the framebuffer device and calls - * MiniGLXDriverRec::initFBDev to do the client-side initialization on it. + * DRIDriverRec::initFBDev to do the client-side initialization on it. * * Loads the DRI driver and pulls in Mini GLX specific hooks into a - * MiniGLXDriverRec structure, and the standard DRI \e __driCreateScreen hook. + * DRIDriverRec structure, and the standard DRI \e __driCreateScreen hook. * Asks the driver for a list of supported visuals. Performs the per-screen * client-side initialization. Also setups the callbacks in the screen private * information. @@ -953,11 +961,12 @@ __miniglx_StartServer( const char *display_name ) /* Ask the driver for a list of supported configs: */ - dpy->driver->initScreenConfigs( dpy, &dpy->numConfigs, &dpy->configs ); + dpy->driver->initScreenConfigs( &dpy->driverContext, + &dpy->numConfigs, &dpy->configs ); /* Perform the initialization normally done in the X server */ - if (!dpy->driver->initFBDev( dpy )) { + if (!dpy->driver->initFBDev( &dpy->driverContext )) { fprintf(stderr, "%s: __driInitFBDev failed\n", __FUNCTION__); dlclose(dpy->dlHandle); return GL_FALSE; @@ -1031,7 +1040,8 @@ XOpenDisplay( const char *display_name ) /* Ask the driver for a list of supported configs: */ - dpy->driver->initScreenConfigs( dpy, &dpy->numConfigs, &dpy->configs ); + dpy->driver->initScreenConfigs( &dpy->driverContext, + &dpy->numConfigs, &dpy->configs ); /* Perform the client-side initialization. @@ -1097,7 +1107,7 @@ XCloseDisplay( Display *dpy ) if (!dpy->IsClient) { /* put framebuffer back to initial state */ - (*dpy->driver->haltFBDev)( dpy ); + (*dpy->driver->haltFBDev)( &dpy->driverContext ); RestoreFBDev(dpy); CloseFBDev(dpy); } @@ -1194,10 +1204,10 @@ XCreateWindow( Display *display, Window parent, int x, int y, win->h = height; win->visual = visual; /* ptr assignment */ - win->bytesPerPixel = display->bpp / 8; + win->bytesPerPixel = display->driverContext.cpp; win->rowStride = display->VarInfo.xres_virtual * win->bytesPerPixel; win->size = win->rowStride * height; - win->frontStart = display->FrameBuffer; + win->frontStart = display->driverContext.FBAddress; win->frontBottom = (GLubyte *) win->frontStart + (height-1) * win->rowStride; /* This is incorrect: the hardware driver could put the backbuffer @@ -1390,7 +1400,7 @@ XGetVisualInfo( Display *dpy, long vinfo_mask, XVisualInfo *vinfo_template, int visResults[i].visInfo = results + i; visResults[i].dpy = dpy; - if (dpy->bpp == 32) + if (dpy->driverContext.bpp == 32) visResults[i].pixelFormat = PF_B8G8R8A8; /* XXX: FIX ME */ else visResults[i].pixelFormat = PF_B5G6R5; /* XXX: FIX ME */ @@ -1402,7 +1412,7 @@ XGetVisualInfo( Display *dpy, long vinfo_mask, XVisualInfo *vinfo_template, int dpy->configs[i].greenSize + dpy->configs[i].blueSize + dpy->configs[i].alphaSize; - results[i].bits_per_rgb = dpy->bpp; + results[i].bits_per_rgb = dpy->driverContext.bpp; } *nitens_return = n; return results; @@ -1583,9 +1593,9 @@ glXChooseVisual( Display *dpy, int screen, int *attribList ) if (rgbFlag) { /* XXX maybe support depth 16 someday */ visInfo->class = TrueColor; - visInfo->depth = dpy->bpp; - visInfo->bits_per_rgb = dpy->bpp; - if (dpy->bpp == 32) + visInfo->depth = dpy->driverContext.bpp; + visInfo->bits_per_rgb = dpy->driverContext.bpp; + if (dpy->driverContext.bpp == 32) vis->pixelFormat = PF_B8G8R8A8; else vis->pixelFormat = PF_B5G6R5; diff --git a/src/miniglx/miniglxP.h b/src/miniglx/miniglxP.h index bbee5d6ae4..439d44adfe 100644 --- a/src/miniglx/miniglxP.h +++ b/src/miniglx/miniglxP.h @@ -173,49 +173,111 @@ struct __DRIdrawableRec { }; /** + * \brief DRIDriverContext type. + */ +struct DRIDriverContextRec { + const char *pciBusID; + int pciBus; + int pciDevice; + int pciFunc; + int chipset; + int bpp; + int cpp; + + unsigned long FBStart; /**< \brief physical address of the framebuffer */ + unsigned long MMIOStart; /**< \brief physical address of the MMIO region */ + + int FBSize; /**< \brief size of the mmap'd framebuffer in bytes */ + int MMIOSize; /**< \brief size of the mmap'd MMIO region in bytes */ + + void *FBAddress; /**< \brief start of the mmap'd framebuffer */ + void *MMIOAddress; /**< \brief start of the mmap'd MMIO region */ + + /** + * \name Client configuration details + * + * These are computed on the server and sent to clients as part of + * the initial handshaking. + */ + /*@{*/ + struct { + unsigned long hSAREA; + int SAREASize; + unsigned long hFrameBuffer; + int fbOrigin; + int fbSize; + int fbStride; + int virtualWidth; + int virtualHeight; + } shared; + + /*@}*/ + /** + * \name From DRIInfoRec + */ + /*@{*/ + int drmFD; /**< \brief DRM device file descriptor */ + struct _XF86DRISAREA *pSAREA; + unsigned int serverContext; /**< \brief DRM context only active on server */ + /*@}*/ + + + /** + * \name Driver private + * + * Populated by __driInitFBDev() + */ + /*@{*/ + void *driverPrivate; + void *driverClientMsg; + int driverClientMsgSize; + /*@}*/ +}; + +/** * \brief Interface to the DRI driver. * * This structure is retrieved from the loadable driver by the \e - * __driMiniGLXDriver symbol to access the Mini GLX specific hardware + * __driDriver symbol to access the Mini GLX specific hardware * initialization and take down routines. */ -struct MiniGLXDriverRec { +struct DRIDriverRec { /** * \brief Get the list of supported visuals. */ - int (*initScreenConfigs)( struct MiniGLXDisplayRec *dpy, + int (*initScreenConfigs)( struct DRIDriverContextRec *dpy, int *numConfigs, __GLXvisualConfig **configs ); /** * \brief Validate the framebuffer device mode */ - int (*validateMode)( struct MiniGLXDisplayRec *dpy ); + int (*validateMode)( struct DRIDriverContextRec *dpy ); /** * \brief Examine mode returned by fbdev (may differ from the one * requested), restore any hw regs clobbered by fbdev. */ - int (*postValidateMode)( struct MiniGLXDisplayRec *dpy ); + int (*postValidateMode)( struct DRIDriverContextRec *dpy ); /** * \brief Initialize the framebuffer device. */ - int (*initFBDev)( struct MiniGLXDisplayRec *dpy ); + int (*initFBDev)( struct DRIDriverContextRec *dpy ); /** * \brief Halt the framebuffer device. */ - void (*haltFBDev)( struct MiniGLXDisplayRec *dpy ); + void (*haltFBDev)( struct DRIDriverContextRec *dpy ); /** * \brief Idle and shutdown hardware in preparation for a vt switch. */ - int (*shutdownHardware)( struct MiniGLXDisplayRec *dpy ); + int (*shutdownHardware)( struct DRIDriverContextRec *dpy ); /** * \brief Restore hardware state after regaining the vt. */ - int (*restoreHardware)( struct MiniGLXDisplayRec *dpy ); + int (*restoreHardware)( struct DRIDriverContextRec *dpy ); }; @@ -305,7 +367,6 @@ struct MiniGLXConnection { }; - /** * \brief X Display type * @@ -321,9 +382,6 @@ struct MiniGLXDisplayRec { int OriginalVT; int ConsoleFD; /**< \brief console TTY device file descriptor */ int FrameBufferFD; /**< \brief framebuffer device file descriptor */ - caddr_t FrameBuffer; /**< \brief start of the mmap'd framebuffer */ - caddr_t MMIOAddress; /**< \brief start of the mmap'd MMIO region */ - int MMIOSize; /**< \brief size of the mmap'd MMIO region in bytes */ int NumWindows; /**< \brief number of open windows */ Window TheWindow; /**< \brief open window - only allow one window for now */ int rotateMode; @@ -366,7 +424,8 @@ struct MiniGLXDisplayRec { /** * \brief Mini GLX specific driver hooks */ - struct MiniGLXDriverRec *driver; + struct DRIDriverRec *driver; + struct DRIDriverContextRec driverContext; /** * \name Configuration details @@ -376,54 +435,6 @@ struct MiniGLXDisplayRec { /*@{*/ const char *fbdevDevice; const char *clientDriverName; - const char *pciBusID; - int pciBus; - int pciDevice; - int pciFunc; - int chipset; - int bpp; - int cpp; - /*@}*/ - - - /** - * \name Client configuration details - * - * These are computed on the server and sent to clients as part of - * the initial handshaking. - */ - /*@{*/ - struct { - unsigned long hSAREA; - int SAREASize; - unsigned long hFrameBuffer; - int fbOrigin; - int fbSize; - int fbStride; - int virtualWidth; - int virtualHeight; - } shared; - /*@}*/ - - - /** - * \name From DRIInfoRec - */ - /*@{*/ - int drmFD; /**< \brief DRM device file descriptor */ - struct _XF86DRISAREA *pSAREA; - unsigned int serverContext; /**< \brief DRM context only active on server */ - /*@}*/ - - /** - * \name Driver private - * - * Populated by __driInitFBDev() - */ - /*@{*/ - void *driverInfo; - void *driverClientMsg; - int driverClientMsgSize; /*@}*/ }; diff --git a/src/miniglx/miniglx_events.c b/src/miniglx/miniglx_events.c index 9b283cf9f0..afdbadeb08 100644 --- a/src/miniglx/miniglx_events.c +++ b/src/miniglx/miniglx_events.c @@ -22,7 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $Id: miniglx_events.c,v 1.1.2.6 2003/04/25 23:09:01 keithw Exp $ */ +/* $Id: miniglx_events.c,v 1.1.2.7 2003/04/26 21:17:47 keithw Exp $ */ /** @@ -52,6 +52,7 @@ #include <unistd.h> #include <sys/ioctl.h> #include <sys/mman.h> +#include <sys/stat.h> #include <sys/types.h> #include <sys/time.h> #include <sys/socket.h> @@ -191,17 +192,18 @@ static int welcome_message_part( Display *dpy, int i, void **msg, int sz ) static int welcome_message( Display *dpy, int i ) { - void *tmp = &dpy->shared; + void *tmp = &dpy->driverContext.shared; int *clientid = dpy->IsClient ? &dpy->clientID : &i; if (!welcome_message_part( dpy, i, (void **)&clientid, sizeof(*clientid))) return False; - if (!welcome_message_part( dpy, i, &tmp, sizeof(dpy->shared))) + if (!welcome_message_part( dpy, i, &tmp, sizeof(dpy->driverContext.shared))) return False; - if (!welcome_message_part( dpy, i, (void **)&dpy->driverClientMsg, - dpy->driverClientMsgSize )) + if (!welcome_message_part( dpy, i, + (void **)&dpy->driverContext.driverClientMsg, + dpy->driverContext.driverClientMsgSize )) return False; return True; @@ -402,8 +404,10 @@ static void __driHandleVtSignals( Display *dpy ) if (!dpy->haveVT && dpy->hwActive) { /* Need to get lock and shutdown hardware */ - DRM_LIGHT_LOCK( dpy->drmFD, dpy->pSAREA, dpy->serverContext ); - dpy->driver->shutdownHardware( dpy ); + DRM_LIGHT_LOCK( dpy->driverContext.drmFD, + dpy->driverContext.pSAREA, + dpy->driverContext.serverContext ); + dpy->driver->shutdownHardware( &dpy->driverContext ); /* Can now give up control of the VT */ ioctl( dpy->ConsoleFD, VT_RELDISP, 1 ); @@ -414,8 +418,10 @@ static void __driHandleVtSignals( Display *dpy ) ioctl( dpy->ConsoleFD, VT_RELDISP, VT_ACTIVATE ); /* restore HW state, release lock */ - dpy->driver->restoreHardware( dpy ); - DRM_UNLOCK( dpy->drmFD, dpy->pSAREA, dpy->serverContext ); + dpy->driver->restoreHardware( &dpy->driverContext ); + DRM_UNLOCK( dpy->driverContext.drmFD, + dpy->driverContext.pSAREA, + dpy->driverContext.serverContext ); dpy->hwActive = 1; } } @@ -640,13 +646,17 @@ static void set_drawable_flag( Display *dpy, int w, int flag ) { fprintf(stderr, "%s %d %d\n", __FUNCTION__, w, flag); - if (dpy->pSAREA) { - DRM_LIGHT_LOCK( dpy->drmFD, dpy->pSAREA, dpy->serverContext ); + if (dpy->driverContext.pSAREA) { + DRM_LIGHT_LOCK( dpy->driverContext.drmFD, + dpy->driverContext.pSAREA, + dpy->driverContext.serverContext ); - dpy->pSAREA->drawableTable[w].stamp++; - dpy->pSAREA->drawableTable[w].flags = flag; + dpy->driverContext.pSAREA->drawableTable[w].stamp++; + dpy->driverContext.pSAREA->drawableTable[w].flags = flag; - DRM_UNLOCK( dpy->drmFD, dpy->pSAREA, dpy->serverContext ); + DRM_UNLOCK( dpy->driverContext.drmFD, + dpy->driverContext.pSAREA, + dpy->driverContext.serverContext ); } } |