i = mylog2( pMGADRIServer->agpTextures.size / MGA_NR_TEX_REGIONS ); if ( i < MGA_LOG_MIN_TEX_REGION_SIZE ) i = MGA_LOG_MIN_TEX_REGION_SIZE;  pMGADRI->logAgpTextureGranularity = i; pMGADRI->agpTextureOffset = (unsigned int)pMGADRIServer->agpTextures.handle; pMGADRI->agpTextureSize = (unsigned int)pMGADRIServer->agpTextures.size;
Bool MGADRIFinishScreenInit( ScreenPtr pScreen ){   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];   MGAPtr pMga = MGAPTR(pScrn);   MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo;   MGADRIPtr pMGADRI = (MGADRIPtr)pMga->pDRIInfo->devPrivate;   int i;   if ( !pMga->pDRIInfo )      return FALSE;   pMga->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT;   /* NOTE: DRIFinishScreenInit must be called before *DRIKernelInit    * because *DRIKernelInit requires that the hardware lock is held by    * the X server, and the first time the hardware lock is grabbed is    * in DRIFinishScreenInit.    */   if ( !DRIFinishScreenInit( pScreen ) ) {      MGADRICloseScreen( pScreen );      return FALSE;   }   if ( !MGADRIKernelInit( pScreen ) ) {      MGADRICloseScreen( pScreen );      return FALSE;   }   if ( !MGADRIBuffersInit( pScreen ) ) {      MGADRICloseScreen( pScreen );      return FALSE;   }   switch(pMga->Chipset) {   case PCI_CHIP_MGAG550:   case PCI_CHIP_MGAG400:      pMGADRI->chipset = MGA_CARD_TYPE_G400;      break;   case PCI_CHIP_MGAG200:   case PCI_CHIP_MGAG200_PCI:      pMGADRI->chipset = MGA_CARD_TYPE_G200;      break;   default:      return FALSE;   }   pMGADRI->width		= pScrn->virtualX;   pMGADRI->height		= pScrn->virtualY;   pMGADRI->mem			= pScrn->videoRam * 1024;   pMGADRI->cpp			= pScrn->bitsPerPixel / 8;   pMGADRI->agpMode		= pMga->agpMode;   pMGADRI->frontOffset		= pMGADRIServer->frontOffset;   pMGADRI->frontPitch		= pMGADRIServer->frontPitch;   pMGADRI->backOffset		= pMGADRIServer->backOffset;   pMGADRI->backPitch		= pMGADRIServer->backPitch;   pMGADRI->depthOffset		= pMGADRIServer->depthOffset;   pMGADRI->depthPitch		= pMGADRIServer->depthPitch;   pMGADRI->textureOffset	= pMGADRIServer->textureOffset;   pMGADRI->textureSize		= pMGADRIServer->textureSize;   i = mylog2( pMGADRI->textureSize / MGA_NR_TEX_REGIONS );   if ( i < MGA_LOG_MIN_TEX_REGION_SIZE )      i = MGA_LOG_MIN_TEX_REGION_SIZE;   pMGADRI->logTextureGranularity = i;   pMGADRI->textureSize = (pMGADRI->textureSize >> i) << i; /* truncate */   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;}