diff options
author | Eric Anholt <anholt@freebsd.org> | 2004-06-16 09:26:18 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2004-06-16 09:26:18 +0000 |
commit | bec47f9369b6f02ce4537ab1ac547ba933609edc (patch) | |
tree | 4fc679522a0ba2737836772b91bc77aeca933bdf /src/i810_dri.c | |
parent | c5b1972b50a6dbe57c67d3cc88ae010386b908a6 (diff) |
DRI trunk-20040613 importDRI-trunk-20040721DRI-trunk-20040613
Diffstat (limited to 'src/i810_dri.c')
-rw-r--r-- | src/i810_dri.c | 140 |
1 files changed, 115 insertions, 25 deletions
diff --git a/src/i810_dri.c b/src/i810_dri.c index 06bb0f14..787eef56 100644 --- a/src/i810_dri.c +++ b/src/i810_dri.c @@ -34,9 +34,9 @@ static char I810ClientDriverName[] = "i810"; static Bool I810InitVisualConfigs(ScreenPtr pScreen); static Bool I810CreateContext(ScreenPtr pScreen, VisualPtr visual, - drmContext hwContext, void *pVisualConfigPriv, + drm_context_t hwContext, void *pVisualConfigPriv, DRIContextType contextStore); -static void I810DestroyContext(ScreenPtr pScreen, drmContext hwContext, +static void I810DestroyContext(ScreenPtr pScreen, drm_context_t hwContext, DRIContextType contextStore); static void I810DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, DRIContextType readContextType, @@ -343,12 +343,15 @@ I810DRIScreenInit(ScreenPtr pScreen) pDRIInfo->drmDriverName = I810KernelDriverName; pDRIInfo->clientDriverName = I810ClientDriverName; - pDRIInfo->busIdString = xalloc(64); - - sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d", - ((pciConfigPtr) pI810->PciInfo->thisCard)->busnum, - ((pciConfigPtr) pI810->PciInfo->thisCard)->devnum, - ((pciConfigPtr) pI810->PciInfo->thisCard)->funcnum); + if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) { + pDRIInfo->busIdString = DRICreatePCIBusID(pI810->PciInfo); + } else { + pDRIInfo->busIdString = xalloc(64); + sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d", + ((pciConfigPtr) pI810->PciInfo->thisCard)->busnum, + ((pciConfigPtr) pI810->PciInfo->thisCard)->devnum, + ((pciConfigPtr) pI810->PciInfo->thisCard)->funcnum); + } pDRIInfo->ddxDriverMajorVersion = I810_MAJOR_VERSION; pDRIInfo->ddxDriverMinorVersion = I810_MINOR_VERSION; pDRIInfo->ddxDriverPatchVersion = I810_PATCHLEVEL; @@ -478,7 +481,7 @@ I810DRIScreenInit(ScreenPtr pScreen) } pI810DRI->regsSize = I810_REG_SIZE; - if (drmAddMap(pI810->drmSubFD, (drmHandle) pI810->MMIOAddr, + if (drmAddMap(pI810->drmSubFD, (drm_handle_t) pI810->MMIOAddr, pI810DRI->regsSize, DRM_REGISTERS, 0, &pI810DRI->regs) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAddMap(regs) failed\n"); DRICloseScreen(pScreen); @@ -678,16 +681,19 @@ I810DRIScreenInit(ScreenPtr pScreen) * regular framebuffer as well as texture memory. */ drmAgpAlloc(pI810->drmSubFD, sysmem_size, 0, NULL, &agpHandle); - - if (agpHandle == DRM_AGP_NO_HANDLE) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] drmAgpAlloc failed\n"); - DRICloseScreen(pScreen); - return FALSE; - } pI810->sysmemHandle = agpHandle; - - if (drmAgpBind(pI810->drmSubFD, agpHandle, 0) != 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] drmAgpBind failed\n"); + + if (agpHandle != DRM_AGP_NO_HANDLE) { + if (drmAgpBind(pI810->drmSubFD, agpHandle, 0) == 0) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[agp] Bound System Texture Memory\n"); + } else { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Unable to bind system texture memory. Disabling DRI.\n"); + DRICloseScreen(pScreen); + return FALSE; + } + } else { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Unable to allocate system texture memory. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } @@ -818,7 +824,7 @@ I810DRIScreenInit(ScreenPtr pScreen) pI810->SavedDcacheMem = pI810->DcacheMem; pI810DRI->backbufferSize = pI810->BackBuffer.Size; - if (drmAddMap(pI810->drmSubFD, (drmHandle) pI810->BackBuffer.Start, + if (drmAddMap(pI810->drmSubFD, (drm_handle_t) pI810->BackBuffer.Start, pI810->BackBuffer.Size, DRM_AGP, 0, &pI810DRI->backbuffer) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, @@ -828,7 +834,7 @@ I810DRIScreenInit(ScreenPtr pScreen) } pI810DRI->depthbufferSize = pI810->DepthBuffer.Size; - if (drmAddMap(pI810->drmSubFD, (drmHandle) pI810->DepthBuffer.Start, + if (drmAddMap(pI810->drmSubFD, (drm_handle_t) pI810->DepthBuffer.Start, pI810->DepthBuffer.Size, DRM_AGP, 0, &pI810DRI->depthbuffer) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, @@ -858,7 +864,7 @@ I810DRIScreenInit(ScreenPtr pScreen) DRICloseScreen(pScreen); return FALSE; } - if (drmAddMap(pI810->drmSubFD, (drmHandle) pI810->BufferMem.Start, + if (drmAddMap(pI810->drmSubFD, (drm_handle_t) pI810->BufferMem.Start, pI810->BufferMem.Size, DRM_AGP, 0, &pI810->buffer_map) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAddMap(buffer_map) failed. Disabling DRI.\n"); @@ -869,7 +875,7 @@ I810DRIScreenInit(ScreenPtr pScreen) pI810DRI->agp_buffers = pI810->buffer_map; pI810DRI->agp_buf_size = pI810->BufferMem.Size; - if (drmAddMap(pI810->drmSubFD, (drmHandle) pI810->LpRing.mem.Start, + if (drmAddMap(pI810->drmSubFD, (drm_handle_t) pI810->LpRing.mem.Start, pI810->LpRing.mem.Size, DRM_AGP, 0, &pI810->ring_map) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAddMap(ring_map) failed. Disabling DRI.\n"); @@ -897,7 +903,7 @@ I810DRIScreenInit(ScreenPtr pScreen) I810AllocLow(&(pI810->TexMem), &(pI810->SysMem), pI810DRI->textureSize); - if (drmAddMap(pI810->drmSubFD, (drmHandle) pI810->TexMem.Start, + if (drmAddMap(pI810->drmSubFD, (drm_handle_t) pI810->TexMem.Start, pI810->TexMem.Size, DRM_AGP, 0, &pI810DRI->textures) < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAddMap(textures) failed. Disabling DRI.\n"); @@ -1037,14 +1043,14 @@ I810DRICloseScreen(ScreenPtr pScreen) static Bool I810CreateContext(ScreenPtr pScreen, VisualPtr visual, - drmContext hwContext, void *pVisualConfigPriv, + drm_context_t hwContext, void *pVisualConfigPriv, DRIContextType contextStore) { return TRUE; } static void -I810DestroyContext(ScreenPtr pScreen, drmContext hwContext, +I810DestroyContext(ScreenPtr pScreen, drm_context_t hwContext, DRIContextType contextStore) { } @@ -1418,9 +1424,93 @@ static void I810DRITransitionTo2d(ScreenPtr pScreen) I810Ptr pI810 = I810PTR(pScrn); I810SAREAPtr pSAREAPriv = DRIGetSAREAPrivate(pScreen); + /* Try flipping back to the front page if necessary */ + if (pSAREAPriv->pf_current_page == 1) + drmCommandNone(pI810->drmSubFD, DRM_I810_FLIP); + /* Shut down shadowing if we've made it back to the front page */ if (pSAREAPriv->pf_current_page == 0) { I810DisablePageFlip(pScreen); } pI810->have3DWindows = 0; } + +Bool +I810DRILeave(ScrnInfoPtr pScrn) +{ + I810Ptr pI810 = I810PTR(pScrn); + + if (pI810->directRenderingEnabled) { + if (pI810->dcacheHandle != 0) + if (drmAgpUnbind(pI810->drmSubFD, pI810->dcacheHandle) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno)); + return FALSE; + } + if (pI810->backHandle != 0) + if (drmAgpUnbind(pI810->drmSubFD, pI810->backHandle) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno)); + return FALSE; + } + if (pI810->zHandle != 0) + if (drmAgpUnbind(pI810->drmSubFD, pI810->zHandle) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno)); + return FALSE; + } + if (pI810->sysmemHandle != 0) + if (drmAgpUnbind(pI810->drmSubFD, pI810->sysmemHandle) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno)); + return FALSE; + } + if (pI810->xvmcHandle != 0) + if (drmAgpUnbind(pI810->drmSubFD, pI810->xvmcHandle) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno)); + return FALSE; + } + if (pI810->cursorHandle != 0) + if (drmAgpUnbind(pI810->drmSubFD, pI810->cursorHandle) != 0) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno)); + return FALSE; + } + if (pI810->agpAcquired == TRUE) + drmAgpRelease(pI810->drmSubFD); + pI810->agpAcquired = FALSE; + } + return TRUE; +} + +Bool +I810DRIEnter(ScrnInfoPtr pScrn) +{ + I810Ptr pI810 = I810PTR(pScrn); + + if (pI810->directRenderingEnabled) { + + if (pI810->agpAcquired == FALSE) + drmAgpAcquire(pI810->drmSubFD); + pI810->agpAcquired = TRUE; + if (pI810->dcacheHandle != 0) + if (drmAgpBind(pI810->drmSubFD, pI810->dcacheHandle, + pI810->DepthOffset) != 0) + return FALSE; + if (pI810->backHandle != 0) + if (drmAgpBind(pI810->drmSubFD, pI810->backHandle, + pI810->BackOffset) != 0) + return FALSE; + if (pI810->zHandle != 0) + if (drmAgpBind(pI810->drmSubFD, pI810->zHandle, + pI810->DepthOffset) != 0) + return FALSE; + if (pI810->sysmemHandle != 0) + if (drmAgpBind(pI810->drmSubFD, pI810->sysmemHandle, 0) != 0) + return FALSE; + if (pI810->xvmcHandle != 0) + if (drmAgpBind(pI810->drmSubFD, pI810->xvmcHandle, + pI810->MC.Start) != 0) + return FALSE; + if (pI810->cursorHandle != 0) + if (drmAgpBind(pI810->drmSubFD, pI810->cursorHandle, + pI810->CursorStart) != 0) + return FALSE; + } + return TRUE; +} |