diff options
author | Egbert Eich <eich@suse.de> | 2004-07-06 14:37:47 +0000 |
---|---|---|
committer | Egbert Eich <eich@suse.de> | 2004-07-06 14:37:47 +0000 |
commit | 986bc24892e7ce3784fc723fda54b1f89dd75b66 (patch) | |
tree | cd8e25cb6b090f380f040860d188a9379763391c | |
parent | b7310758e60956a7de14dcf968bb713dfc56738f (diff) |
Increase default video RAM size to 16MB when DRI is enabled and more than 128MB
are available (Egbert Eich).
Fixed lockups during mode switch. Problem was introduced when attempting to copy
the behavior during LeaveVT()/EnterVT() but but forgetting to call
I810DRILeave() before I810DRIEnter(). The entire DRILeave()/Enter() scenario has
been commented out as it didn't seem to be necessary (Egbert Eich).
Fix TweakMemorySize() (tested with i855/i865) (Egbert Eich).
-rw-r--r-- | src/i810_driver.c | 101 | ||||
-rw-r--r-- | src/i830.h | 3 | ||||
-rw-r--r-- | src/i830_driver.c | 56 | ||||
-rw-r--r-- | src/i830_memory.c | 4 |
4 files changed, 93 insertions, 71 deletions
diff --git a/src/i810_driver.c b/src/i810_driver.c index 92bd7e88..26bb2b3b 100644 --- a/src/i810_driver.c +++ b/src/i810_driver.c @@ -776,6 +776,34 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) ptr->found = FALSE; } + if (xf86ReturnOptValBool(pI810->Options, OPTION_NOACCEL, FALSE)) + pI810->noAccel = TRUE; + + if (!pI810->noAccel) { + if (!xf86LoadSubModule(pScrn, "xaa")) { + I810FreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(I810xaaSymbols, NULL); + } + +#ifdef XF86DRI + pI810->directRenderingDisabled = + !xf86ReturnOptValBool(pI810->Options, OPTION_DRI, TRUE); + + if (!pI810->directRenderingDisabled) { + if (pI810->noAccel) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it " + "needs 2D acceleration.\n"); + pI810->directRenderingDisabled=TRUE; + } else if (pScrn->depth!=16) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it " + "runs only at 16-bit depth.\n"); + pI810->directRenderingDisabled=TRUE; + } + } +#endif + /* Get DDC info from monitor */ /* after xf86ProcessOptions, * because it is controlled by options [no]vbe and [no]ddc @@ -875,14 +903,18 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) * * Changed to 8 Meg so we can have acceleration by default (Mark). */ - pScrn->videoRam = 8192; + mem = I810CheckAvailableMemory(pScrn); + if (pI810->directRenderingDisabled || mem < 134217728) /* < 128 MB */ + pScrn->videoRam = 8192; + else + pScrn->videoRam = 16384; from = X_DEFAULT; + if (pI810->pEnt->device->videoRam) { pScrn->videoRam = pI810->pEnt->device->videoRam; from = X_CONFIG; } - mem = I810CheckAvailableMemory(pScrn); if (mem > 0 && mem < pScrn->videoRam) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "%dk of memory was requested," " but the\n\t maximum AGP memory available is %dk.\n", @@ -1014,17 +1046,6 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) } xf86LoaderReqSymLists(I810fbSymbols, NULL); - if (xf86ReturnOptValBool(pI810->Options, OPTION_NOACCEL, FALSE)) - pI810->noAccel = TRUE; - - if (!pI810->noAccel) { - if (!xf86LoadSubModule(pScrn, "xaa")) { - I810FreeRec(pScrn); - return FALSE; - } - xf86LoaderReqSymLists(I810xaaSymbols, NULL); - } - if (!xf86ReturnOptValBool(pI810->Options, OPTION_SW_CURSOR, FALSE)) { if (!xf86LoadSubModule(pScrn, "ramdac")) { I810FreeRec(pScrn); @@ -1044,23 +1065,6 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) 1) << pScrn->offset.blue); } - pI810->directRenderingDisabled = - !xf86ReturnOptValBool(pI810->Options, OPTION_DRI, TRUE); - -#ifdef XF86DRI - if (!pI810->directRenderingDisabled) { - if (pI810->noAccel) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it " - "needs 2D acceleration.\n"); - pI810->directRenderingDisabled=TRUE; - } else if (pScrn->depth!=16) { - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it " - "runs only at 16-bit depth.\n"); - pI810->directRenderingDisabled=TRUE; - } - } -#endif - pI810->allowPageFlip=FALSE; enable = xf86ReturnOptValBool(pI810->Options, OPTION_PAGEFLIP, FALSE); @@ -2261,20 +2265,29 @@ Bool I810SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; +#if 0 I810Ptr pI810 = I810PTR(pScrn); - +#endif if (I810_DEBUG & DEBUG_VERBOSE_CURSOR) ErrorF("I810SwitchMode %p %x\n", (void *)mode, flags); -#ifdef XF86DRI +#if 0 +/* + * This has been added to prevent lockups on mode switch by modeling + * it after I810Leave()/I810Enter() but the call to I810DRILeave() + * was missing so it caused the opposite. + * The version below works but it is doubtful it does any good. + * If lockups on mode switch are still seen revisit this code. (EE) + */ + +# ifdef XF86DRI if (pI810->directRenderingEnabled) { if (I810_DEBUG & DEBUG_VERBOSE_DRI) ErrorF("calling dri lock\n"); DRILock(screenInfo.screens[scrnIndex], 0); pI810->LockHeld = 1; } -#endif - +# endif if (pI810->AccelInfoRec != NULL) { I810RefreshRing(pScrn); I810Sync(pScrn); @@ -2282,18 +2295,20 @@ I810SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) } I810Restore(pScrn); -#ifdef XF86DRI - if (!I810DRIEnter(pScrn)) { - return FALSE; - } +# ifdef XF86DRI if (pI810->directRenderingEnabled) { - if (I810_DEBUG & DEBUG_VERBOSE_DRI) - ErrorF("calling dri unlock\n"); - DRIUnlock(screenInfo.screens[scrnIndex]); - pI810->LockHeld = 0; + if (!I810DRILeave(pScrn)) + return FALSE; + if (!I810DRIEnter(pScrn)) + return FALSE; + + if (I810_DEBUG & DEBUG_VERBOSE_DRI) + ErrorF("calling dri unlock\n"); + DRIUnlock(screenInfo.screens[scrnIndex]); + pI810->LockHeld = 0; } +# endif #endif - return I810ModeInit(pScrn, mode); } @@ -451,7 +451,8 @@ extern void I830ChangeFrontbuffer(ScrnInfoPtr pScrn,int buffer); #define ALLOCATE_DRY_RUN 0x80000000 /* Chipset registers for VIDEO BIOS memory RW access */ -#define DRAM_RW_CONTROL 0x58 +#define _855_DRAM_RW_CONTROL 0x58 +#define _845_DRAM_RW_CONTROL 0x90 #define DRAM_WRITE 0x33330000 #endif /* _I830_H_ */ diff --git a/src/i830_driver.c b/src/i830_driver.c index 458feb28..344cf5bd 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -1170,19 +1170,24 @@ SaveBIOSMemSize(ScrnInfoPtr pScrn) * Original implementation by Christian Zietz in a stand-alone tool. */ static CARD32 -TweakMemorySize(ScrnInfoPtr pScrn, CARD32 newsize) +TweakMemorySize(ScrnInfoPtr pScrn, CARD32 newsize, Bool preinit) { #define SIZE 0x10000 -#define IDOFFSET (-23) +#define _855_IDOFFSET (-23) +#define _845_IDOFFSET (-19) + const char *MAGICstring = "Total time for VGA POST:"; const int len = strlen(MAGICstring); I830Ptr pI830 = I830PTR(pScrn); - char *position; + volatile char *position; char *biosAddr; CARD32 oldsize; CARD32 oldpermission; CARD32 ret = 0; int i,j = 0; + int reg = (IS_845G(pI830) || IS_I865G(pI830)) ? _845_DRAM_RW_CONTROL + : _855_DRAM_RW_CONTROL; + PCITAG tag =pciTag(0,0,0); if(!pI830->PciInfo @@ -1198,7 +1203,7 @@ TweakMemorySize(ScrnInfoPtr pScrn, CARD32 newsize) if (!pI830->BIOSMemSizeLoc) { - if (!pI830->preinit) + if (preinit) return 0; /* Search for MAGIC string */ @@ -1213,30 +1218,32 @@ TweakMemorySize(ScrnInfoPtr pScrn, CARD32 newsize) } if (j < len) return 0; - pI830->BIOSMemSizeLoc = (i - j + 1 + IDOFFSET); + pI830->BIOSMemSizeLoc = (i - j + 1 + (IS_845G(pI830) + ? _845_IDOFFSET : _855_IDOFFSET)); } - + position = biosAddr + pI830->BIOSMemSizeLoc; oldsize = *(CARD32 *)position; - ret = oldsize - (3 << 16); - + ret = oldsize - 0x21000; + /* verify that register really contains current size */ - if (pI830->preinit && ((oldsize) >> 16) - 3 != pI830->vbeInfo->TotalMemory) + if (pI830->preinit && ((ret >> 16) != pI830->vbeInfo->TotalMemory)) return 0; - oldpermission = pciReadLong(tag, DRAM_RW_CONTROL); - pciWriteLong(tag, DRAM_RW_CONTROL, 0x33330000); + oldpermission = pciReadLong(tag, reg); + pciWriteLong(tag, reg, DRAM_WRITE | (oldpermission & 0xffff)); + + *(CARD32 *)position = newsize + 0x21000; - *(CARD32 *)position = newsize + (3 << 16); if (pI830->preinit) { /* reinitialize VBE for new size */ VBEFreeVBEInfo(pI830->vbeInfo); vbeFree(pI830->pVbe); pI830->pVbe = VBEInit(NULL, pI830->pEnt->index); pI830->vbeInfo = VBEGetVBEInfo(pI830->pVbe); - + /* verify that change was successful */ - if (pI830->vbeInfo->TotalMemory * 64 * 1024 != pI830->newBIOSMemSize) { + if (pI830->vbeInfo->TotalMemory != (newsize >> 16)){ ret = 0; *(CARD32 *)position = oldsize; } else { @@ -1247,7 +1254,7 @@ TweakMemorySize(ScrnInfoPtr pScrn, CARD32 newsize) } } - pciWriteLong(tag, DRAM_RW_CONTROL, oldpermission); + pciWriteLong(tag, reg, oldpermission); return ret; } @@ -1260,7 +1267,7 @@ RestoreBIOSMemSize(ScrnInfoPtr pScrn) DPRINTF(PFX, "RestoreBIOSMemSize\n"); - if (TweakMemorySize(pScrn, pI830->saveBIOSMemSize)) + if (TweakMemorySize(pScrn, pI830->saveBIOSMemSize,FALSE)) return; if (!pI830->overrideBIOSMemSize) @@ -2116,14 +2123,13 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BIOS now sees %ld kB VideoRAM\n", pI830->BIOSMemorySize / 1024); - } else - if ((pI830->saveBIOSMemSize = - TweakMemorySize(pScrn, pI830->newBIOSMemSize)) != 0) - pI830->overrideBIOSMemSize = TRUE; + } else if ((pI830->saveBIOSMemSize + = TweakMemorySize(pScrn, pI830->newBIOSMemSize,TRUE)) != 0) + pI830->overrideBIOSMemSize = TRUE; else { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "BIOS view of memory size can't be changed " - "(this is not an error).\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "BIOS view of memory size can't be changed " + "(this is not an error).\n"); } } } @@ -3931,7 +3937,7 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) * first, then re-initialise the VBE information. */ pI830->pVbe = VBEInit(NULL, pI830->pEnt->index); - if (!TweakMemorySize(pScrn, pI830->newBIOSMemSize)) + if (!TweakMemorySize(pScrn, pI830->newBIOSMemSize,FALSE)) SetBIOSMemSize(pScrn, pI830->newBIOSMemSize); if (!pI830->pVbe) return FALSE; @@ -4394,7 +4400,7 @@ I830BIOSEnterVT(int scrnIndex, int flags) return FALSE; CheckInheritedState(pScrn); - if (!TweakMemorySize(pScrn, pI830->newBIOSMemSize)) + if (!TweakMemorySize(pScrn, pI830->newBIOSMemSize,FALSE)) SetBIOSMemSize(pScrn, pI830->newBIOSMemSize); /* diff --git a/src/i830_memory.c b/src/i830_memory.c index 04e8deee..990651e1 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -1008,7 +1008,7 @@ I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags) return FALSE; } xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity, - "%sAllocated %d kB for the logical context at 0x%x.\n", s, + "%sAllocated %ld kB for the logical context at 0x%lx.\n", s, alloced / 1024, pI830->ContextMem.Start); @@ -1230,7 +1230,7 @@ SetFence(ScrnInfoPtr pScrn, int nr, unsigned int start, unsigned int pitch, if (nr < 0 || nr > 7) { xf86DrvMsg(X_WARNING, pScrn->scrnIndex, - "SetFence: fence %d out of range\n"); + "SetFence: fence %d out of range\n",nr); return; } |