diff options
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c')
-rw-r--r-- | xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c | 321 |
1 files changed, 167 insertions, 154 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c index 7bf02f271..a9becbd9f 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.18 2001/04/10 16:08:00 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.21 2001/05/19 00:26:44 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -19,18 +19,18 @@ static char I810KernelDriverName[] = "i810"; static char I810ClientDriverName[] = "i810"; static Bool I810InitVisualConfigs(ScreenPtr pScreen); -static Bool I810CreateContext(ScreenPtr pScreen, VisualPtr visual, +static Bool I810CreateContext(ScreenPtr pScreen, VisualPtr visual, drmContext hwContext, void *pVisualConfigPriv, DRIContextType contextStore); static void I810DestroyContext(ScreenPtr pScreen, drmContext hwContext, DRIContextType contextStore); -static void I810DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, - DRIContextType readContextType, +static void I810DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType readContextType, void *readContextStore, - DRIContextType writeContextType, + DRIContextType writeContextType, void *writeContextStore); static void I810DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index); -static void I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, +static void I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index); extern void GlxSetVisualConfigs(int nconfigs, @@ -57,10 +57,10 @@ Bool I810CleanupDma(ScrnInfoPtr pScrn) { I810Ptr pI810 = I810PTR(pScrn); Bool ret_val; - + ret_val = drmI810CleanupDma(pI810->drmSubFD); if (ret_val == FALSE) - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I810 Dma Cleanup Failed\n"); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[dri] I810 Dma Cleanup Failed\n"); return ret_val; } @@ -71,9 +71,9 @@ Bool I810InitDma(ScrnInfoPtr pScrn) I810DRIPtr pI810DRI = (I810DRIPtr) pI810->pDRIInfo->devPrivate; drmI810Init info; Bool ret_val; - + info.start = ring->mem.Start; - info.end = ring->mem.End; + info.end = ring->mem.End; info.size = ring->mem.Size; info.mmio_offset = (unsigned int)pI810DRI->regs; info.buffers_offset = (unsigned int)pI810->buffer_map; @@ -88,7 +88,10 @@ Bool I810InitDma(ScrnInfoPtr pScrn) info.pitch_bits = pI810->auxPitchBits; ret_val = drmI810InitDma(pI810->drmSubFD, &info); - if(ret_val == FALSE) ErrorF("I810 Dma Initialization Failed\n"); + if(ret_val == FALSE) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[drm] I810 Dma Initialization failed.\n"); + } return ret_val; } @@ -129,7 +132,7 @@ I810InitVisualConfigs(ScreenPtr pScreen) return FALSE; } - for (i=0; i<numConfigs; i++) + for (i=0; i<numConfigs; i++) pI810ConfigPtrs[i] = &pI810Configs[i]; i = 0; @@ -168,7 +171,7 @@ I810InitVisualConfigs(ScreenPtr pScreen) pConfigs[i].depthSize = 0; if (stencil) pConfigs[i].stencilSize = 8; - else + else pConfigs[i].stencilSize = 0; pConfigs[i].auxBuffers = 0; pConfigs[i].level = 0; @@ -219,7 +222,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) int bufs; int width = pScrn->displayWidth * pI810->cpp; int i; - + /* Hardware 3D rendering only implemented for 16bpp */ /* And it only works for 5:6:5 (Mark) */ if (pScrn->depth != 16) @@ -232,17 +235,19 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE; if (!xf86LoaderCheckSymbol("DRIQueryVersion")) { xf86DrvMsg(pScreen->myNum, X_ERROR, - "TDFXDRIScreenInit failed (libdri.a too old)\n"); + "[dri] I810DRIScreenInit failed (libdri.a too old)\n"); return FALSE; } - + /* Check the DRI version */ { int major, minor, patch; DRIQueryVersion(&major, &minor, &patch); if (major != 4 || minor < 0) { xf86DrvMsg(pScreen->myNum, X_ERROR, - "I810DRIScreenInit failed (DRI version = %d.%d.%d, expected 4.0.x). Disabling DRI.\n", + "[dri] I810DRIScreenInit failed because of a version mismatch.\n" + "[dri] libDRI version is %d.%d.%d bug version 4.0.x is needed.\n" + "[dri] Disabling DRI.\n", major, minor, patch); return FALSE; } @@ -250,7 +255,8 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pDRIInfo = DRICreateInfoRec(); if (!pDRIInfo) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "DRICreateInfoRec failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[dri] DRICreateInfoRec failed. Disabling DRI.\n"); return FALSE; } @@ -273,8 +279,8 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pDRIInfo->ddxDriverMinorVersion = I810_MINOR_VERSION; pDRIInfo->ddxDriverPatchVersion = I810_PATCHLEVEL; pDRIInfo->frameBufferPhysicalAddress = pI810->LinearAddr; - pDRIInfo->frameBufferSize = (((pScrn->displayWidth * - pScrn->virtualY * pI810->cpp) + + pDRIInfo->frameBufferSize = (((pScrn->displayWidth * + pScrn->virtualY * pI810->cpp) + 4096 - 1) / 4096) * 4096; pDRIInfo->frameBufferStride = pScrn->displayWidth*pI810->cpp; @@ -289,7 +295,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) * in the SAREA header */ if (sizeof(XF86DRISAREARec)+sizeof(I810SAREARec)>SAREA_MAX) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "Data does not fit in SAREA\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] Data does not fit in SAREA\n"); return FALSE; } pDRIInfo->SAREASize = SAREA_MAX; @@ -302,29 +308,30 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pDRIInfo->devPrivate = pI810DRI; pDRIInfo->devPrivateSize = sizeof(I810DRIRec); pDRIInfo->contextSize = sizeof(I810DRIContextRec); - + pDRIInfo->CreateContext = I810CreateContext; pDRIInfo->DestroyContext = I810DestroyContext; pDRIInfo->SwapContext = I810DRISwapContext; pDRIInfo->InitBuffers = I810DRIInitBuffers; pDRIInfo->MoveBuffers = I810DRIMoveBuffers; pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; - + pDRIInfo->createDummyCtx = TRUE; pDRIInfo->createDummyCtxPriv = FALSE; - + /* This adds the framebuffer as a drm map *before* we have asked agp * to allocate it. Scary stuff, hold on... */ if (!DRIScreenInit(pScreen, pDRIInfo, &pI810->drmSubFD)) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "DRIScreenInit failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[dri] DRIScreenInit failed. Disabling DRI.\n"); xfree(pDRIInfo->devPrivate); pDRIInfo->devPrivate=0; DRIDestroyInfoRec(pI810->pDRIInfo); pI810->pDRIInfo=0; return FALSE; } - + /* Check the i810 DRM version */ { drmVersionPtr version = drmGetVersion(pI810->drmSubFD); @@ -333,7 +340,9 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) version->version_minor < 1) { /* incompatible drm version */ xf86DrvMsg(pScreen->myNum, X_ERROR, - "I810DRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n", + "[dri] I810DRIScreenInit failed because of a version mismatch.\n" + "[dri] i810.o kernel module version is %d.%d.%d but version 1.0.x is needed.\n" + "[dri] Disabling DRI.\n", version->version_major, version->version_minor, version->version_patchlevel); @@ -346,33 +355,33 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) } pI810DRI->regsSize=I810_REG_SIZE; - if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->MMIOAddr, + if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->MMIOAddr, pI810DRI->regsSize, DRM_REGISTERS, 0, &pI810DRI->regs)<0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(regs) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAddMap(regs) failed\n"); DRICloseScreen(pScreen); return FALSE; } xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n", pI810DRI->regs); - + pI810->backHandle = 0; pI810->zHandle = 0; pI810->cursorHandle = 0; pI810->sysmemHandle = 0; pI810->agpAcquired = FALSE; pI810->dcacheHandle = 0; - + /* Agp Support - Need this just to get the framebuffer. */ if(drmAgpAcquire(pI810->drmSubFD) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpAquire failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] drmAgpAquire failed\n"); DRICloseScreen(pScreen); return FALSE; } pI810->agpAcquired = TRUE; - + if (drmAgpEnable(pI810->drmSubFD, 0) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpEnable failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] drmAgpEnable failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -381,23 +390,23 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) memset (&pI810->BackBuffer, 0, sizeof(I810MemRange)); memset (&pI810->DepthBuffer, 0, sizeof(I810MemRange)); pI810->CursorPhysical = 0; - + /* Dcache - half the speed of normal ram, but has use as a Z buffer - * under the DRI. + * under the DRI. */ drmAgpAlloc(pI810->drmSubFD, 4096 * 1024, 1, NULL, &dcacheHandle); pI810->dcacheHandle = dcacheHandle; - xf86DrvMsg(pScreen->myNum, X_INFO, "dcacheHandle : %p\n", dcacheHandle); - + xf86DrvMsg(pScreen->myNum, X_INFO, "[agp] dcacheHandle : %p\n", dcacheHandle); + #define Elements(x) sizeof(x)/sizeof(*x) - for (pitch_idx = 0 ; pitch_idx < Elements(i810_pitches) ; pitch_idx++) - if (width <= i810_pitches[pitch_idx]) + for (pitch_idx = 0 ; pitch_idx < Elements(i810_pitches) ; pitch_idx++) + if (width <= i810_pitches[pitch_idx]) break; - + if (pitch_idx == Elements(i810_pitches)) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Couldn't find depth/back buffer pitch"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[dri] Couldn't find depth/back buffer pitch"); DRICloseScreen(pScreen); return FALSE; } @@ -405,11 +414,11 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) back_size = i810_pitches[pitch_idx] * (pScrn->virtualY + 4); back_size = ((back_size + 4096 - 1) / 4096) * 4096; } - + sysmem_size = pScrn->videoRam * 1024; if (dcacheHandle != 0) { if (back_size > 4*1024*1024) { - xf86DrvMsg(pScreen->myNum, X_INFO, "Backsize is larger then 4 meg\n"); + xf86DrvMsg(pScreen->myNum, X_INFO, "[dri] Backsize is larger then 4 meg\n"); sysmem_size = sysmem_size - 2*back_size; drmAgpFree(pI810->drmSubFD, dcacheHandle); pI810->dcacheHandle = dcacheHandle = 0; @@ -422,13 +431,13 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) sysmem_size = sysmem_size - 2*back_size; } - if(sysmem_size > 48*1024*1024) { - sysmem_size = 48*1024*1024; + if(sysmem_size > pI810->FbMapSize) { + sysmem_size = pI810->FbMapSize; xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "User requested more memory then fits in the agp aperture\n" - "Truncating to %d bytes of memory\n", - sysmem_size); + "[dri] User requested more memory then fits in the agp" + " aperture\n\tTruncating to %d bytes of memory\n", + sysmem_size); } sysmem_size -= 4096; /* remove 4k for the hw cursor */ @@ -441,121 +450,119 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pI810->SavedSysMem = pI810->SysMem; if (dcacheHandle != 0) { - /* The Z buffer is always aligned to the 48 mb mark in the aperture */ - if(drmAgpBind(pI810->drmSubFD, dcacheHandle, 48*1024*1024) == 0) { + if(drmAgpBind(pI810->drmSubFD, dcacheHandle, pI810->DepthOffset) == 0) { memset (&pI810->DcacheMem, 0, sizeof(I810MemRange)); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "GART: Found 4096K Z buffer memory\n"); - pI810->DcacheMem.Start = 48*1024*1024; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[agp] GART: Found 4096K Z buffer memory\n"); + pI810->DcacheMem.Start = pI810->DepthOffset; pI810->DcacheMem.Size = 1024 * 4096; pI810->DcacheMem.End = pI810->DcacheMem.Start + pI810->DcacheMem.Size; - if (!I810AllocLow(&(pI810->DepthBuffer), + if (!I810AllocLow(&(pI810->DepthBuffer), &(pI810->DcacheMem), - back_size)) + back_size)) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Depth buffer allocation failed\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[agp] Depth buffer allocation failed\n"); DRICloseScreen(pScreen); return FALSE; } } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: dcache bind failed\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[agp] GART: dcache bind failed\n"); drmAgpFree(pI810->drmSubFD, dcacheHandle); pI810->dcacheHandle = dcacheHandle = 0; - } + } } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: no dcache memory found\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[agp] GART: no dcache memory found\n"); } drmAgpAlloc(pI810->drmSubFD, back_size, 0, NULL, &agpHandle); pI810->backHandle = agpHandle; - + if (agpHandle != 0) { - /* The backbuffer is always aligned to the 56 mb mark in the aperture */ - if(drmAgpBind(pI810->drmSubFD, agpHandle, 56*1024*1024) == 0) { + if(drmAgpBind(pI810->drmSubFD, agpHandle, pI810->BackOffset) == 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Bound backbuffer memory\n"); - - pI810->BackBuffer.Start = 56*1024*1024; + "[agp] Bound backbuffer memory\n"); + + pI810->BackBuffer.Start = pI810->BackOffset; pI810->BackBuffer.Size = back_size; - pI810->BackBuffer.End = (pI810->BackBuffer.Start + + pI810->BackBuffer.End = (pI810->BackBuffer.Start + pI810->BackBuffer.Size); } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Unable to bind backbuffer\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[agp] Unable to bind backbuffer. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Unable to allocate backbuffer memory\n"); + "[dri] Unable to allocate backbuffer memory. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } - + if(dcacheHandle == 0) { - /* The Z buffer is always aligned to the 48 mb mark in the aperture */ drmAgpAlloc(pI810->drmSubFD, back_size, 0, NULL, &agpHandle); pI810->zHandle = agpHandle; if(agpHandle != 0) { - if(drmAgpBind(pI810->drmSubFD, agpHandle, 48*1024*1024) == 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Bound depthbuffer memory\n"); - pI810->DepthBuffer.Start = 48*1024*1024; + if(drmAgpBind(pI810->drmSubFD, agpHandle, pI810->DepthOffset) == 0) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[agp] Bound depthbuffer memory\n"); + pI810->DepthBuffer.Start = pI810->DepthOffset; pI810->DepthBuffer.Size = back_size; - pI810->DepthBuffer.End = (pI810->DepthBuffer.Start + + pI810->DepthBuffer.End = (pI810->DepthBuffer.Start + pI810->DepthBuffer.Size); } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Unable to bind depthbuffer\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[agp] Unable to bind depthbuffer. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Unable to allocate depthbuffer memory\n"); + "[agp] Unable to allocate depthbuffer memory. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } - } - + } + /* Now allocate and bind the agp space. This memory will include the * regular framebuffer as well as texture memory. */ drmAgpAlloc(pI810->drmSubFD, sysmem_size, 0, NULL, &agpHandle); if (agpHandle == 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpAlloc failed\n"); + 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, "drmAgpBind failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] drmAgpBind failed\n"); DRICloseScreen(pScreen); return FALSE; } - - drmAgpAlloc(pI810->drmSubFD, 4096, 2, - (unsigned long *)&pI810->CursorPhysical, &agpHandle); + + drmAgpAlloc(pI810->drmSubFD, 4096, 2, + (unsigned long *)&pI810->CursorPhysical, &agpHandle); pI810->cursorHandle = agpHandle; if (agpHandle != 0) { tom = sysmem_size; - if (drmAgpBind(pI810->drmSubFD, agpHandle, tom) == 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "GART: Allocated 4K for mouse cursor image\n"); - pI810->CursorStart = tom; + if (drmAgpBind(pI810->drmSubFD, agpHandle, tom) == 0) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[agp] GART: Allocated 4K for mouse cursor image\n"); + pI810->CursorStart = tom; tom += 4096; } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: cursor bind failed\n"); - pI810->CursorPhysical = 0; - } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[agp] GART: cursor bind failed\n"); + pI810->CursorPhysical = 0; + } } else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: cursor alloc failed\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[agp] GART: cursor alloc failed\n"); pI810->CursorPhysical = 0; } @@ -573,34 +580,36 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pI810->DepthBuffer.Start, i810_pitches[pitch_idx], 8*1024*1024); - + I810SetTiledMemory(pScrn, 2, pI810->BackBuffer.Start, i810_pitches[pitch_idx], 8*1024*1024); - + pI810->auxPitch = i810_pitches[pitch_idx]; pI810->auxPitchBits = i810_pitch_flags[pitch_idx]; pI810->SavedDcacheMem = pI810->DcacheMem; pI810DRI->backbufferSize = pI810->BackBuffer.Size; if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BackBuffer.Start, - pI810->BackBuffer.Size, DRM_AGP, 0, + pI810->BackBuffer.Size, DRM_AGP, 0, &pI810DRI->backbuffer) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(backbuffer) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAddMap(backbuffer) failed. Disabling DRI\n"); DRICloseScreen(pScreen); return FALSE; } - + pI810DRI->depthbufferSize = pI810->DepthBuffer.Size; if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->DepthBuffer.Start, - pI810->DepthBuffer.Size, DRM_AGP, 0, + pI810->DepthBuffer.Size, DRM_AGP, 0, &pI810DRI->depthbuffer) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(depthbuffer) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAddMap(depthbuffer) failed. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } - + /* Allocate FrontBuffer etc. */ if (!I810AllocateFront(pScrn)) { DRICloseScreen(pScreen); @@ -608,24 +617,25 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) } /* Allocate buffer memory */ - I810AllocHigh( &(pI810->BufferMem), &(pI810->SysMem), + I810AllocHigh( &(pI810->BufferMem), &(pI810->SysMem), I810_DMA_BUF_NR * I810_DMA_BUF_SZ); - - xf86DrvMsg(pScreen->myNum, X_INFO, "Buffer map : %lx\n", + + xf86DrvMsg(pScreen->myNum, X_INFO, "[dri] Buffer map : %lx\n", pI810->BufferMem.Start); - - if (pI810->BufferMem.Start == 0 || - pI810->BufferMem.End - pI810->BufferMem.Start > + + if (pI810->BufferMem.Start == 0 || + pI810->BufferMem.End - pI810->BufferMem.Start > I810_DMA_BUF_NR * I810_DMA_BUF_SZ) { xf86DrvMsg(pScreen->myNum, X_ERROR, - "Not enough memory for dma buffers\n"); + "[dri] Not enough memory for dma buffers. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BufferMem.Start, pI810->BufferMem.Size, DRM_AGP, 0, &pI810->buffer_map) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(buffer_map) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAddMap(buffer_map) failed. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } @@ -636,11 +646,12 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->LpRing.mem.Start, pI810->LpRing.mem.Size, DRM_AGP, 0, &pI810->ring_map) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(ring_map) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAddMap(ring_map) failed. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } - + /* Use the rest of memory for textures. */ pI810DRI->textureSize = pI810->SysMem.Size; @@ -653,28 +664,30 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pI810DRI->textureSize = (pI810DRI->textureSize >> i) << i; /* truncate */ if(pI810DRI->textureSize < 512*1024) { - ErrorF("Less then 512k for textures\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Less then 512k memory left for textures. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } - + I810AllocLow( &(pI810->TexMem), &(pI810->SysMem), pI810DRI->textureSize); - + if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->TexMem.Start, pI810->TexMem.Size, DRM_AGP, 0, &pI810DRI->textures) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(textures) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAddMap(textures) failed. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } - + if((bufs = drmAddBufs(pI810->drmSubFD, I810_DMA_BUF_NR, I810_DMA_BUF_SZ, DRM_AGP_BUFFER, pI810->BufferMem.Start)) <= 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] failure adding %d %d byte DMA buffers\n", + "[drm] failure adding %d %d byte DMA buffers. Disabling DRI.\n", I810_DMA_BUF_NR, I810_DMA_BUF_SZ); DRICloseScreen(pScreen); @@ -687,7 +700,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) xf86EnablePciBusMaster(pI810->PciInfo, TRUE); I810InitDma(pScrn); - + /* Okay now initialize the dma engine */ if (!pI810DRI->irq) { @@ -702,7 +715,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] failure adding irq handler, there is a device " "already using that irq\n Consider rearranging your " - "PCI cards\n"); + "PCI cards. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } @@ -711,41 +724,41 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] dma control initialized, using IRQ %d\n", pI810DRI->irq); - - pI810DRI=(I810DRIPtr)pI810->pDRIInfo->devPrivate; + pI810DRI->deviceID=pI810->PciInfo->chipType; pI810DRI->width=pScrn->virtualX; pI810DRI->height=pScrn->virtualY; pI810DRI->mem=pScrn->videoRam*1024; pI810DRI->cpp=pI810->cpp; - + pI810DRI->fbOffset=pI810->FrontBuffer.Start; pI810DRI->fbStride=pI810->auxPitch; - + pI810DRI->bitsPerPixel = pScrn->bitsPerPixel; - - + + pI810DRI->textureOffset=pI810->TexMem.Start; - + pI810DRI->backOffset=pI810->BackBuffer.Start; pI810DRI->depthOffset=pI810->DepthBuffer.Start; - + pI810DRI->ringOffset=pI810->LpRing.mem.Start; pI810DRI->ringSize=pI810->LpRing.mem.Size; - + pI810DRI->auxPitch = pI810->auxPitch; pI810DRI->auxPitchBits = pI810->auxPitchBits; pI810DRI->sarea_priv_offset = sizeof(XF86DRISAREARec); if (!(I810InitVisualConfigs(pScreen))) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "I810InitVisualConfigs failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[dri] I810InitVisualConfigs failed. Disabling DRI.\n"); DRICloseScreen(pScreen); return FALSE; } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "visual configs initialized\n" ); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] visual configs initialized.\n" ); pI810->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT; - + return TRUE; } @@ -764,7 +777,7 @@ I810DRICloseScreen(ScreenPtr pScreen) if(pI810->sysmemHandle) drmAgpFree(pI810->drmSubFD, pI810->sysmemHandle); if(pI810->agpAcquired == TRUE) drmAgpRelease(pI810->drmSubFD); - + pI810->backHandle = 0; pI810->zHandle = 0; pI810->cursorHandle = 0; @@ -772,7 +785,7 @@ I810DRICloseScreen(ScreenPtr pScreen) pI810->agpAcquired = FALSE; pI810->dcacheHandle = 0; - + DRICloseScreen(pScreen); if (pI810->pDRIInfo) { @@ -788,7 +801,7 @@ I810DRICloseScreen(ScreenPtr pScreen) } static Bool -I810CreateContext(ScreenPtr pScreen, VisualPtr visual, +I810CreateContext(ScreenPtr pScreen, VisualPtr visual, drmContext hwContext, void *pVisualConfigPriv, DRIContextType contextStore) { @@ -796,7 +809,7 @@ I810CreateContext(ScreenPtr pScreen, VisualPtr visual, } static void -I810DestroyContext(ScreenPtr pScreen, drmContext hwContext, +I810DestroyContext(ScreenPtr pScreen, drmContext hwContext, DRIContextType contextStore) { } @@ -811,29 +824,29 @@ I810DRIFinishScreenInit(ScreenPtr pScreen) } void -I810DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, +I810DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, DRIContextType oldContextType, void *oldContext, DRIContextType newContextType, void *newContext) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; I810Ptr pI810 = I810PTR(pScrn); - if (syncType == DRI_3D_SYNC && + if (syncType == DRI_3D_SYNC && oldContextType == DRI_2D_CONTEXT && - newContextType == DRI_2D_CONTEXT) - { + newContextType == DRI_2D_CONTEXT) + { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; if (I810_DEBUG & DEBUG_VERBOSE_DRI) ErrorF("I810DRISwapContext (in)\n"); - + pI810->LockHeld = 1; I810RefreshRing( pScrn ); } - else if (syncType == DRI_2D_SYNC && + else if (syncType == DRI_2D_SYNC && oldContextType == DRI_NO_CONTEXT && - newContextType == DRI_2D_CONTEXT) - { + newContextType == DRI_2D_CONTEXT) + { pI810->LockHeld = 0; if (I810_DEBUG & DEBUG_VERBOSE_DRI) ErrorF("I810DRISwapContext (out)\n"); @@ -857,7 +870,7 @@ I810DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) I810SetupForSolidFill(pScrn, 0, GXcopy, -1); while (nbox--) { I810SelectBuffer(pScrn, I810_BACK); - I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1, + I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1, pbox->x2-pbox->x1, pbox->y2-pbox->y1); pbox++; } @@ -868,8 +881,8 @@ I810DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) nbox = REGION_NUM_RECTS(prgn); I810SelectBuffer(pScrn, I810_DEPTH); I810SetupForSolidFill(pScrn, 0xffff, GXcopy, -1); - while (nbox--) { - I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1, + while (nbox--) { + I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1, pbox->x2-pbox->x1, pbox->y2-pbox->y1); pbox++; } @@ -880,12 +893,12 @@ I810DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) /* This routine is a modified form of XAADoBitBlt with the calls to * ScreenToScreenBitBlt built in. My routine has the prgnSrc as source * instead of destination. My origin is upside down so the ydir cases - * are reversed. + * are reversed. * * KW: can you believe that this is called even when a 2d window moves? */ static void -I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, +I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index) { ScreenPtr pScreen = pParent->drawable.pScreen; @@ -988,21 +1001,21 @@ I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, I810EmitFlush(pScrn); I810SetupForScreenToScreenCopy(pScrn, xdir, ydir, GXcopy, -1, -1); for ( ; nbox-- ; pbox++ ) { - + int x1 = pbox->x1; int y1 = pbox->y1; int destx = x1 + dx; int desty = y1 + dy; int w = pbox->x2 - x1 + 1; int h = pbox->y2 - y1 + 1; - - if ( destx < 0 ) x1 -= destx, w += destx, destx = 0; + + if ( destx < 0 ) x1 -= destx, w += destx, destx = 0; if ( desty < 0 ) y1 -= desty, h += desty, desty = 0; if ( destx + w > screenwidth ) w = screenwidth - destx; if ( desty + h > screenheight ) h = screenheight - desty; if ( w <= 0 ) continue; if ( h <= 0 ) continue; - + if (I810_DEBUG & DEBUG_VERBOSE_DRI) ErrorF( "MoveBuffers %d,%d %dx%d dx: %d dy: %d\n", |