From 63eb1a4aa402ac3bf117634c3c9270261c6a4258 Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Sat, 30 Jun 2007 21:51:15 -0700 Subject: Support configs with BAR1 < total RAM < 256 MB. --- src/g80_driver.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/g80_driver.c b/src/g80_driver.c index c81388c..e703ea8 100644 --- a/src/g80_driver.c +++ b/src/g80_driver.c @@ -194,6 +194,7 @@ G80PreInit(ScrnInfoPtr pScrn, int flags) const Gamma gzeros = {0.0, 0.0, 0.0}; char *s; CARD32 tmp; + memType BAR1sizeKB; if(flags & PROBE_DETECT) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -341,18 +342,35 @@ G80PreInit(ScrnInfoPtr pScrn, int flags) pNv->architecture = pNv->reg[0] >> 20 & 0x1ff; pNv->RamAmountKBytes = pNv->RamAmountKBytes = (pNv->reg[0x0010020C/4] & 0xFFF00000) >> 10; pNv->videoRam = pNv->RamAmountKBytes; - /* Limit videoRam to the max BAR1 size of 256MB */ - if(pNv->videoRam <= 1024) { + + /* Determine the size of BAR1 */ + /* Some configs have BAR1 < total RAM < 256 MB */ + BAR1sizeKB = 1UL << (pPci->size[1] - 10); + if(BAR1sizeKB > 256 * 1024) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "BAR1 is > 256 MB, which is " + "probably wrong. Clamping to 256 MB.\n"); + BAR1sizeKB = 256 * 1024; + } + + /* Limit videoRam to the size of BAR1 */ + if(pNv->videoRam <= 1024 || BAR1sizeKB == 0) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to determine the amount of " "available video memory\n"); goto fail; } pNv->videoRam -= 1024; - if(pNv->videoRam > 256 * 1024) - pNv->videoRam = 256 * 1024; + if(pNv->videoRam > BAR1sizeKB) + pNv->videoRam = BAR1sizeKB; + pScrn->videoRam = pNv->videoRam; - xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Mapping %.1f of %.1f MB of video RAM\n", - pScrn->videoRam / 1024.0, pNv->RamAmountKBytes / 1024.0); + + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Total video RAM: %.1f MB\n", + pNv->RamAmountKBytes / 1024.0); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " BAR1 size: %.1f MB\n", + BAR1sizeKB / 1024.0); + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, " Mapped memory: %.1f MB\n", + pScrn->videoRam / 1024.0); + pNv->mem = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO | VIDMEM_READSIDEEFFECT, pcitag, pPci->memBase[1], pScrn->videoRam * 1024); -- cgit v1.2.3