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 | 307 |
1 files changed, 140 insertions, 167 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 591207b65..e2c48f68f 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c @@ -64,7 +64,8 @@ Bool I810CleanupDma(ScrnInfoPtr pScrn) Bool ret_val; ret_val = drmI810CleanupDma(pI810->drmSubFD); - if(ret_val == FALSE) ErrorF("I810 Dma Cleanup Failed\n"); + if (ret_val == FALSE) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I810 Dma Cleanup Failed\n"); return ret_val; } @@ -104,6 +105,7 @@ I810InitVisualConfigs(ScreenPtr pScreen) __GLXvisualConfig *pConfigs = 0; I810ConfigPrivPtr pI810Configs = 0; I810ConfigPrivPtr *pI810ConfigPtrs = 0; + int accum, stencil, db, depth; int i; switch (pScrn->bitsPerPixel) { @@ -112,25 +114,20 @@ I810InitVisualConfigs(ScreenPtr pScreen) case 32: break; case 16: - numConfigs = 4; + numConfigs = 8; - if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), - numConfigs))) { + pConfigs = (__GLXvisualConfig *) xnfcalloc(sizeof(__GLXvisualConfig), numConfigs); + if (!pConfigs) return FALSE; - } - if (!(pI810Configs = - (I810ConfigPrivPtr)xnfcalloc(sizeof(I810ConfigPrivRec), - numConfigs))) - { + pI810Configs = (I810ConfigPrivPtr) xnfcalloc(sizeof(I810ConfigPrivRec), numConfigs); + if (!pI810Configs) { xfree(pConfigs); return FALSE; } - if (!(pI810ConfigPtrs = - (I810ConfigPrivPtr*)xnfcalloc(sizeof(I810ConfigPrivPtr), - numConfigs))) - { + pI810ConfigPtrs = (I810ConfigPrivPtr *) xnfcalloc(sizeof(I810ConfigPrivPtr), numConfigs); + if (!pI810ConfigPtrs) { xfree(pConfigs); xfree(pI810Configs); return FALSE; @@ -139,126 +136,61 @@ I810InitVisualConfigs(ScreenPtr pScreen) for (i=0; i<numConfigs; i++) pI810ConfigPtrs[i] = &pI810Configs[i]; - /* config 0: db=FALSE, depth=0 - config 1: db=FALSE, depth=16 - config 2: db=TRUE, depth=0; - config 3: db=TRUE, depth=16 - */ - pConfigs[0].vid = -1; - pConfigs[0].class = -1; - pConfigs[0].rgba = TRUE; - pConfigs[0].redSize = 5; - pConfigs[0].greenSize = 6; - pConfigs[0].blueSize = 5; - pConfigs[0].redMask = 0x0000F800; - pConfigs[0].greenMask = 0x000007E0; - pConfigs[0].blueMask = 0x0000001F; - pConfigs[0].alphaMask = 0; - pConfigs[0].accumRedSize = 0; - pConfigs[0].accumGreenSize = 0; - pConfigs[0].accumBlueSize = 0; - pConfigs[0].accumAlphaSize = 0; - pConfigs[0].doubleBuffer = FALSE; - pConfigs[0].stereo = FALSE; - pConfigs[0].bufferSize = 16; - pConfigs[0].depthSize = 16; - pConfigs[0].stencilSize = 0; - pConfigs[0].auxBuffers = 0; - pConfigs[0].level = 0; - pConfigs[0].visualRating = 0; - pConfigs[0].transparentPixel = 0; - pConfigs[0].transparentRed = 0; - pConfigs[0].transparentGreen = 0; - pConfigs[0].transparentBlue = 0; - pConfigs[0].transparentAlpha = 0; - pConfigs[0].transparentIndex = 0; - - pConfigs[1].vid = -1; - pConfigs[1].class = -1; - pConfigs[1].rgba = TRUE; - pConfigs[1].redSize = 5; - pConfigs[1].greenSize = 6; - pConfigs[1].blueSize = 5; - pConfigs[1].redMask = 0x0000F800; - pConfigs[1].greenMask = 0x000007E0; - pConfigs[1].blueMask = 0x0000001F; - pConfigs[1].alphaMask = 0; - pConfigs[1].accumRedSize = 0; - pConfigs[1].accumGreenSize = 0; - pConfigs[1].accumBlueSize = 0; - pConfigs[1].accumAlphaSize = 0; - pConfigs[1].doubleBuffer = FALSE; - pConfigs[1].stereo = FALSE; - pConfigs[1].bufferSize = 16; - pConfigs[1].depthSize = 16; - pConfigs[1].stencilSize = 0; - pConfigs[1].auxBuffers = 0; - pConfigs[1].level = 0; - pConfigs[1].visualRating = 0; - pConfigs[1].transparentPixel = 0; - pConfigs[1].transparentRed = 0; - pConfigs[1].transparentGreen = 0; - pConfigs[1].transparentBlue = 0; - pConfigs[1].transparentAlpha = 0; - pConfigs[1].transparentIndex = 0; - - pConfigs[2].vid = -1; - pConfigs[2].class = -1; - pConfigs[2].rgba = TRUE; - pConfigs[2].redSize = 5; - pConfigs[2].greenSize = 6; - pConfigs[2].blueSize = 5; - pConfigs[2].redMask = 0x0000F800; - pConfigs[2].greenMask = 0x000007E0; - pConfigs[2].blueMask = 0x0000001F; - pConfigs[2].alphaMask = 0; - pConfigs[2].accumRedSize = 0; - pConfigs[2].accumGreenSize = 0; - pConfigs[2].accumBlueSize = 0; - pConfigs[2].accumAlphaSize = 0; - pConfigs[2].doubleBuffer = TRUE; - pConfigs[2].stereo = FALSE; - pConfigs[2].bufferSize = 16; - pConfigs[2].depthSize = 16; - pConfigs[2].stencilSize = 0; - pConfigs[2].auxBuffers = 0; - pConfigs[2].level = 0; - pConfigs[2].visualRating = 0; - pConfigs[2].transparentPixel = 0; - pConfigs[2].transparentRed = 0; - pConfigs[2].transparentGreen = 0; - pConfigs[2].transparentBlue = 0; - pConfigs[2].transparentAlpha = 0; - pConfigs[2].transparentIndex = 0; - - pConfigs[3].vid = -1; - pConfigs[3].class = -1; - pConfigs[3].rgba = TRUE; - pConfigs[3].redSize = 5; - pConfigs[3].greenSize = 6; - pConfigs[3].blueSize = 5; - pConfigs[3].redMask = 0x0000F800; - pConfigs[3].greenMask = 0x000007E0; - pConfigs[3].blueMask = 0x0000001F; - pConfigs[3].alphaMask = 0; - pConfigs[3].accumRedSize = 0; - pConfigs[3].accumGreenSize = 0; - pConfigs[3].accumBlueSize = 0; - pConfigs[3].accumAlphaSize = 0; - pConfigs[3].doubleBuffer = TRUE; - pConfigs[3].stereo = FALSE; - pConfigs[3].bufferSize = 16; - pConfigs[3].depthSize = 16; - pConfigs[3].stencilSize = 0; - pConfigs[3].auxBuffers = 0; - pConfigs[3].level = 0; - pConfigs[3].visualRating = 0; - pConfigs[3].transparentPixel = 0; - pConfigs[3].transparentRed = 0; - pConfigs[3].transparentGreen = 0; - pConfigs[3].transparentBlue = 0; - pConfigs[3].transparentAlpha = 0; - pConfigs[3].transparentIndex = 0; + i = 0; + depth = 1; + for (accum = 0; accum <= 1; accum++) { + for (stencil = 0; stencil <= 1; stencil++) { + for (db = 0; db <= 1; db++) { + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 5; + pConfigs[i].greenSize = 6; + pConfigs[i].blueSize = 5; + pConfigs[i].redMask = 0x0000F800; + pConfigs[i].greenMask = 0x000007E0; + pConfigs[i].blueMask = 0x0000001F; + pConfigs[i].alphaMask = 0; + if (accum) { + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 16; + } + else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + pConfigs[i].doubleBuffer = db ? TRUE : FALSE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 16; + if (depth) + pConfigs[i].depthSize = 16; + else + pConfigs[i].depthSize = 0; + if (stencil) + pConfigs[i].stencilSize = 8; + else + pConfigs[i].stencilSize = 0; + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (stencil) + pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; + else + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = 0; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + } + assert(i == numConfigs); break; } pI810->numVisualConfigs = numConfigs; @@ -301,9 +233,21 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (!LoaderSymbol("drmAvailable")) return FALSE; #endif + /* Check the DRI version */ + { + int major, minor, patch; + DRIQueryVersion(&major, &minor, &patch); + if (major != 3 || minor != 0 || patch < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "I810DRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n", + major, minor, patch); + return FALSE; + } + } + pDRIInfo = DRICreateInfoRec(); if (!pDRIInfo) { - ErrorF("DRICreateInfoRec failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "DRICreateInfoRec failed\n"); return FALSE; } @@ -322,10 +266,9 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) ((pciConfigPtr)pI810->PciInfo->thisCard)->busnum, ((pciConfigPtr)pI810->PciInfo->thisCard)->devnum, ((pciConfigPtr)pI810->PciInfo->thisCard)->funcnum); - - pDRIInfo->ddxDriverMajorVersion = 0; - pDRIInfo->ddxDriverMinorVersion = 1; - pDRIInfo->ddxDriverPatchVersion = 0; + pDRIInfo->ddxDriverMajorVersion = I810_MAJOR_VERSION; + pDRIInfo->ddxDriverMinorVersion = I810_MINOR_VERSION; + pDRIInfo->ddxDriverPatchVersion = I810_PATCHLEVEL; pDRIInfo->frameBufferPhysicalAddress = pI810->LinearAddr; pDRIInfo->frameBufferSize = (((pScrn->displayWidth * pScrn->virtualY * pI810->cpp) + @@ -343,7 +286,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) * in the SAREA header */ if (sizeof(XF86DRISAREARec)+sizeof(I810SAREARec)>SAREA_MAX) { - ErrorF("Data does not fit in SAREA\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "Data does not fit in SAREA\n"); return FALSE; } pDRIInfo->SAREASize = SAREA_MAX; @@ -369,7 +312,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) * to allocate it. Scary stuff, hold on... */ if (!DRIScreenInit(pScreen, pDRIInfo, &pI810->drmSubFD)) { - ErrorF("DRIScreenInit failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "DRIScreenInit failed\n"); xfree(pDRIInfo->devPrivate); pDRIInfo->devPrivate=0; DRIDestroyInfoRec(pI810->pDRIInfo); @@ -377,10 +320,31 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) return FALSE; } + /* Check the i810 DRM version */ + { + drmVersionPtr version = drmGetVersion(pI810->drmSubFD); + if (version) { + if (version->version_major != 1 || + version->version_minor != 0 || + version->version_patchlevel < 0) { + /* incompatible drm version */ + xf86DrvMsg(pScreen->myNum, X_ERROR, + "I810DRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n", + version->version_major, + version->version_minor, + version->version_patchlevel); + I810DRICloseScreen(pScreen); + drmFreeVersion(version); + return FALSE; + } + drmFreeVersion(version); + } + } + pI810DRI->regsSize=I810_REG_SIZE; if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->MMIOAddr, pI810DRI->regsSize, DRM_REGISTERS, 0, &pI810DRI->regs)<0) { - ErrorF("drmAddMap(regs) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(regs) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -397,14 +361,14 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) /* Agp Support - Need this just to get the framebuffer. */ if(drmAgpAcquire(pI810->drmSubFD) < 0) { - ErrorF("drmAgpAquire failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpAquire failed\n"); DRICloseScreen(pScreen); return FALSE; } pI810->agpAcquired = TRUE; if (drmAgpEnable(pI810->drmSubFD, 0) < 0) { - ErrorF("drmAgpEnable failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpEnable failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -420,7 +384,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) drmAgpAlloc(pI810->drmSubFD, 4096 * 1024, 1, NULL, &dcacheHandle); pI810->dcacheHandle = dcacheHandle; - + xf86DrvMsg(pScreen->myNum, X_INFO, "dcacheHandle : %p\n", dcacheHandle); #define Elements(x) sizeof(x)/sizeof(*x) for (pitch_idx = 0 ; pitch_idx < Elements(i810_pitches) ; pitch_idx++) @@ -432,22 +396,25 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) "Couldn't find depth/back buffer pitch"); DRICloseScreen(pScreen); return FALSE; - } else { + } + else { 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) { - ErrorF("Backsize is larger then 4 meg\n"); + if (dcacheHandle != 0) { + if (back_size > 4*1024*1024) { + xf86DrvMsg(pScreen->myNum, X_INFO, "Backsize is larger then 4 meg\n"); sysmem_size = sysmem_size - 2*back_size; drmAgpFree(pI810->drmSubFD, dcacheHandle); pI810->dcacheHandle = dcacheHandle = 0; - } else { + } + else { sysmem_size = sysmem_size - back_size; } - } else { + } + else { sysmem_size = sysmem_size - 2*back_size; } @@ -499,7 +466,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) drmAgpAlloc(pI810->drmSubFD, back_size, 0, NULL, &agpHandle); pI810->backHandle = agpHandle; - if(agpHandle != 0) { + 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) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -552,15 +519,15 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) * regular framebuffer as well as texture memory. */ drmAgpAlloc(pI810->drmSubFD, sysmem_size, 0, NULL, &agpHandle); - if(agpHandle == 0) { - ErrorF("drmAgpAlloc failed\n"); + if (agpHandle == 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpAlloc failed\n"); DRICloseScreen(pScreen); return FALSE; } pI810->sysmemHandle = agpHandle; - if(drmAgpBind(pI810->drmSubFD, agpHandle, 0) != 0) { - ErrorF("drmAgpBind failed\n"); + if (drmAgpBind(pI810->drmSubFD, agpHandle, 0) != 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpBind failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -572,16 +539,18 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (agpHandle != 0) { tom = sysmem_size; - if(drmAgpBind(pI810->drmSubFD, agpHandle, tom) == 0) { + if (drmAgpBind(pI810->drmSubFD, agpHandle, tom) == 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: Allocated 4K for mouse cursor image\n"); pI810->CursorStart = tom; tom += 4096; - } else { + } + else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: cursor bind failed\n"); pI810->CursorPhysical = 0; } - } else { + } + else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: cursor alloc failed\n"); pI810->CursorPhysical = 0; } @@ -604,7 +573,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BackBuffer.Start, pI810->BackBuffer.Size, DRM_AGP, 0, &pI810DRI->backbuffer) < 0) { - ErrorF("drmAddMap(backbuffer) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(backbuffer) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -613,7 +582,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->DepthBuffer.Start, pI810->DepthBuffer.Size, DRM_AGP, 0, &pI810DRI->depthbuffer) < 0) { - ErrorF("drmAddMap(depthbuffer) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(depthbuffer) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -625,17 +594,21 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) I810AllocHigh( &(pI810->BufferMem), &(pI810->SysMem), I810_DMA_BUF_NR * I810_DMA_BUF_SZ); - if(pI810->BufferMem.Start == 0 || + xf86DrvMsg(pScreen->myNum, X_INFO, "Buffer map : %lx\n", + pI810->BufferMem.Start); + + if (pI810->BufferMem.Start == 0 || pI810->BufferMem.End - pI810->BufferMem.Start > I810_DMA_BUF_NR * I810_DMA_BUF_SZ) { - ErrorF("Not enough memory for dma buffers\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "Not enough memory for dma buffers\n"); DRICloseScreen(pScreen); return FALSE; } - if(drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BufferMem.Start, + if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BufferMem.Start, pI810->BufferMem.Size, DRM_AGP, 0, &pI810->buffer_map) < 0) { - ErrorF("drmAddMap(buffer_map) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(buffer_map) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -646,7 +619,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->LpRing.mem.Start, pI810->LpRing.mem.Size, DRM_AGP, 0, &pI810->ring_map) < 0) { - ErrorF("drmAddMap(ring_map) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(ring_map) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -674,7 +647,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->TexMem.Start, pI810->TexMem.Size, DRM_AGP, 0, &pI810DRI->textures) < 0) { - ErrorF("drmAddMap(textures) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(textures) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -745,7 +718,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pI810DRI->auxPitchBits = pI810->auxPitchBits; if (!(I810InitVisualConfigs(pScreen))) { - ErrorF("I810InitVisualConfigs failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "I810InitVisualConfigs failed\n"); DRICloseScreen(pScreen); return FALSE; } |