summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2009-05-05 00:45:10 +0200
committerFrancisco Jerez <currojerez@riseup.net>2009-05-05 00:48:12 +0200
commit3cc1b9d4bcf1b7a756ea4426c93392ff6d82e9a6 (patch)
treefe9ecb0bfc10c16d8910b051196a576e1ff48141 /src
parent32628d9884d577d7a672c172c12b7097be276700 (diff)
Fail gracefully when the specified virtual screen doesn't fit in RAM.
Diffstat (limited to 'src')
-rw-r--r--src/smi_driver.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/smi_driver.c b/src/smi_driver.c
index c0e72e4..b788ed6 100644
--- a/src/smi_driver.c
+++ b/src/smi_driver.c
@@ -578,6 +578,8 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags)
xf86PrintDepthBpp(pScrn);
+ pSmi->Bpp = pScrn->bitsPerPixel >> 3;
+
/*
* This must happen after pScrn->display has been set because
* xf86SetWeight references it.
@@ -937,9 +939,27 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags)
/* Only allow growing the screen dimensions if EXA is being used */
if (!xf86InitialConfiguration (pScrn, !pSmi->NoAccel && pSmi->useEXA)){
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
+
+ SMI_EnableVideo(pScrn);
+ SMI_UnmapMem(pScrn);
LEAVE(FALSE);
}
+ /* Ensure that the framebuffer size just set fits in video memory. */
+ {
+ int aligned_pitch = (pScrn->virtualX*pSmi->Bpp + 15) & ~15;
+
+ if(aligned_pitch * pScrn->virtualY > pSmi->FBReserved){
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Not enough video memory "
+ "for the configured screen size (%dx%d) and color depth.\n",
+ pScrn->virtualX, pScrn->virtualY);
+
+ SMI_EnableVideo(pScrn);
+ SMI_UnmapMem(pScrn);
+ LEAVE(FALSE);
+ }
+ }
+
SMI_EnableVideo(pScrn);
SMI_UnmapMem(pScrn);
@@ -1724,7 +1744,6 @@ SMI_ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pScrn->vtSema = TRUE;
pScrn->pScreen = pScreen;
- pSmi->Bpp = pScrn->bitsPerPixel >> 3;
pScrn->displayWidth = ((pScrn->virtualX * pSmi->Bpp + 15) & ~15) / pSmi->Bpp;
pSmi->fbArea = NULL;