[PATCH savage] Refactor BIOS modes retrieval to only call VBEGetVBEInfo once

Tormod Volden lists.tormod at gmail.com
Wed Feb 15 14:07:12 PST 2012


From: Tormod Volden <debian.tormod at gmail.com>

Signed-off-by: Tormod Volden <debian.tormod at gmail.com>
---

The change should be fine by itself, but the reason I changed this is
that with the latest stack (upgraded to 1.12RC etc) the second call to
VBEGetVBEInfo would return corrupted values. There, I fixed it!(TM) :)

So was the issue due to bugs in the savage driver, or is there something
more general VBE stuff broken? I also noticed that the vesa driver messes
up now, the computer hardlocks when I try to change VT. I haven't had time
to investigate that much further so I don't know if it is related.

Anyone else seeing strange stuff with VBE-enabled drivers?

Cheers,
Tormod


 src/savage_driver.h |    1 +
 src/savage_vbe.c    |   25 ++++++++++++++-----------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/savage_driver.h b/src/savage_driver.h
index 7b7e01d..338cfac 100644
--- a/src/savage_driver.h
+++ b/src/savage_driver.h
@@ -625,6 +625,7 @@ ModeStatus SavageMatchBiosMode(ScrnInfoPtr pScrn,int width,int height,int refres
 
 unsigned short SavageGetBIOSModes( 
     SavagePtr psav,
+    VbeInfoBlock *vbe,
     int iDepth,
     SavageModeEntryPtr s3vModeTable );
 
diff --git a/src/savage_vbe.c b/src/savage_vbe.c
index d24da24..7dba538 100644
--- a/src/savage_vbe.c
+++ b/src/savage_vbe.c
@@ -242,17 +242,28 @@ SavageFreeBIOSModeTable( SavagePtr psav, SavageModeTablePtr* ppTable )
 SavageModeTablePtr
 SavageGetBIOSModeTable( SavagePtr psav, int iDepth )
 {
-    int nModes = SavageGetBIOSModes( psav, iDepth, NULL );
+    VbeInfoBlock *vbe;
+    int nModes;
     SavageModeTablePtr pTable;
 
+    if( !psav->pVbe )
+	return 0;
+
+    if (!(vbe = VBEGetVBEInfo(psav->pVbe)))
+	return 0;
+
+    nModes = SavageGetBIOSModes( psav, vbe, iDepth, NULL );
+
     pTable = (SavageModeTablePtr) 
 	calloc( 1, sizeof(SavageModeTableRec) + 
 		    (nModes-1) * sizeof(SavageModeEntry) );
     if( pTable ) {
 	pTable->NumModes = nModes;
-	SavageGetBIOSModes( psav, iDepth, pTable->Modes );
+	SavageGetBIOSModes( psav, vbe, iDepth, pTable->Modes );
     }
 
+    VBEFreeVBEInfo(vbe);
+
     return pTable;
 }
 
@@ -260,19 +271,16 @@ SavageGetBIOSModeTable( SavagePtr psav, int iDepth )
 unsigned short
 SavageGetBIOSModes( 
     SavagePtr psav,
+    VbeInfoBlock *vbe,
     int iDepth,
     SavageModeEntryPtr s3vModeTable )
 {
     unsigned short iModeCount = 0;
     unsigned short int *mode_list;
     pointer vbeLinear = NULL;
-    VbeInfoBlock *vbe;
     int vbeReal;
     struct vbe_mode_info_block * vmib;
 
-    if( !psav->pVbe )
-	return 0;
-
     vbeLinear = xf86Int10AllocPages( psav->pVbe->pInt10, 1, &vbeReal );
     if( !vbeLinear )
     {
@@ -281,9 +289,6 @@ SavageGetBIOSModes(
     }
     vmib = (struct vbe_mode_info_block *) vbeLinear;
     
-    if (!(vbe = VBEGetVBEInfo(psav->pVbe)))
-	return 0;
-
     for (mode_list = vbe->VideoModePtr; *mode_list != 0xffff; mode_list++) {
 
 	/*
@@ -377,8 +382,6 @@ SavageGetBIOSModes(
 	}
     }
 
-    VBEFreeVBEInfo(vbe);
-
     xf86Int10FreePages( psav->pVbe->pInt10, vbeLinear, 1 );
 
     return iModeCount;
-- 
1.7.0.4



More information about the xorg-devel mailing list