summaryrefslogtreecommitdiff
path: root/src/i830_driver.c
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.de>2004-07-06 14:37:47 +0000
committerEgbert Eich <eich@suse.de>2004-07-06 14:37:47 +0000
commit986bc24892e7ce3784fc723fda54b1f89dd75b66 (patch)
treecd8e25cb6b090f380f040860d188a9379763391c /src/i830_driver.c
parentb7310758e60956a7de14dcf968bb713dfc56738f (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).
Diffstat (limited to 'src/i830_driver.c')
-rw-r--r--src/i830_driver.c56
1 files changed, 31 insertions, 25 deletions
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);
/*