Bool I810UnbindGARTMemory(ScrnInfoPtr pScrn) { I810Ptr pI810 = I810PTR(pScrn); if (xf86AgpGARTSupported() && !pI810->directRenderingEnabled && pI810->GttBound) { if (pI810->VramKey != -1 && !xf86UnbindGARTMemory(pScrn->scrnIndex, pI810->VramKey)) return FALSE; if (pI810->DcacheKey != -1 && !xf86UnbindGARTMemory(pScrn->scrnIndex, pI810->DcacheKey)) return FALSE; if (pI810->HwcursKey != -1 && !xf86UnbindGARTMemory(pScrn->scrnIndex, pI810->HwcursKey)) return FALSE; if (pI810->ARGBHwcursKey != -1 && !xf86UnbindGARTMemory(pScrn->scrnIndex, pI810->ARGBHwcursKey)) return FALSE; if (!xf86ReleaseGART(pScrn->scrnIndex)) return FALSE; pI810->GttBound = 0; } return TRUE; }
/* * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called. */ static Bool GARTInit(int screenNum) { struct _agp_info agpinf; if (initDone) return gartFd != -1; initDone = TRUE; if (gartFd == -1) gartFd = open(AGP_DEVICE, O_RDWR, 0); else return FALSE; if (gartFd == -1) { xf86DrvMsg(screenNum, X_ERROR, "GARTInit: Unable to open " AGP_DEVICE " (%s)\n", strerror(errno)); return FALSE; } xf86AcquireGART(-1); /* Check the kernel driver version. */ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { xf86DrvMsg(screenNum, X_ERROR, "GARTInit: AGPIOC_INFO failed (%s)\n", strerror(errno)); close(gartFd); gartFd = -1; return FALSE; } xf86ReleaseGART(-1); #if defined(linux) /* Per Dave Jones, every effort will be made to keep the * agpgart interface backwards compatible, so allow all * future versions. */ if ( #if (AGPGART_MAJOR_VERSION > 0) /* quiet compiler */ agpinf.version.major < AGPGART_MAJOR_VERSION || #endif (agpinf.version.major == AGPGART_MAJOR_VERSION && agpinf.version.minor < AGPGART_MINOR_VERSION)) { xf86DrvMsg(screenNum, X_ERROR, "GARTInit: Kernel agpgart driver version is not current" " (%d.%d vs %d.%d)\n", agpinf.version.major, agpinf.version.minor, AGPGART_MAJOR_VERSION, AGPGART_MINOR_VERSION); close(gartFd); gartFd = -1; return FALSE; } #endif return TRUE; }
Bool I830UnbindGARTMemory(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); DPRINTF(PFX, "I830UnbindGARTMemory: StolenOnly is %s, pI830->GttBound is %s\n", BOOLTOSTRING(pI830->StolenOnly), BOOLTOSTRING(pI830->GttBound)); if (pI830->StolenOnly == TRUE) return TRUE; if (xf86AgpGARTSupported() && pI830->GttBound) { #if REMAP_RESERVED /* "unbind" the pre-allocated region. */ UnbindMemRange(pScrn, &(pI830->Dummy)); #endif if (!UnbindMemRange(pScrn, &(pI830->StolenPool.Allocated))) return FALSE; if (!UnbindMemRange(pScrn, &(pI830->FrontBuffer))) return FALSE; if (!UnbindMemRange(pScrn, &(pI830->CursorMem))) return FALSE; if (!UnbindMemRange(pScrn, &(pI830->LpRing.mem))) return FALSE; if (!UnbindMemRange(pScrn, &(pI830->Scratch))) return FALSE; #ifdef I830_XV if (!UnbindMemRange(pScrn, &(pI830->OverlayMem))) return FALSE; #endif #ifdef XF86DRI if (pI830->directRenderingEnabled) { if (!UnbindMemRange(pScrn, &(pI830->BackBuffer))) return FALSE; if (!UnbindMemRange(pScrn, &(pI830->DepthBuffer))) return FALSE; if (!UnbindMemRange(pScrn, &(pI830->ContextMem))) return FALSE; if (!UnbindMemRange(pScrn, &(pI830->BufferMem))) return FALSE; if (!UnbindMemRange(pScrn, &(pI830->TexMem))) return FALSE; } #endif if (!xf86ReleaseGART(pScrn->scrnIndex)) return FALSE; pI830->GttBound = 0; } return TRUE; }
int I810CheckAvailableMemory(ScrnInfoPtr pScrn) { AgpInfoPtr agpinf; int maxPages; if (!xf86AgpGARTSupported() || !xf86AcquireGART(pScrn->scrnIndex) || (agpinf = xf86GetAGPInfo(pScrn->scrnIndex)) == NULL || !xf86ReleaseGART(pScrn->scrnIndex)) return -1; maxPages = agpinf->totalPages - agpinf->usedPages; xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "%s: %dk available\n", "I810CheckAvailableMemory", maxPages * 4); return maxPages * 4; }