diff options
author | Ian Romanick <idr@us.ibm.com> | 2006-10-27 11:48:35 -0700 |
---|---|---|
committer | Ian Romanick <idr@us.ibm.com> | 2006-10-27 11:48:35 -0700 |
commit | 19d950e61b2b33052e52c33add8e70c29ac9d766 (patch) | |
tree | f4b9aed1afe45c52984bf9e7c705d767b08daf2d | |
parent | d28c4a3307984b86e0f3cc68fa48cdc01e307a7c (diff) |
Convert tests of pMga->Chipset to tests of single bit flags.
Several places in the driver contain if-statements that test Chipset against
several different values to determine what functionality to use. Some of
these tests, HALCHIPSETS in particular, test as many as 6 different values.
This bloats the code size unnecessarilly. Instead we cache the results of
some of those tests in single bit flags stored in pMga.
These changes are similar to some changes in the pci-rework branch.
-rw-r--r-- | src/mga.h | 5 | ||||
-rw-r--r-- | src/mga_dacG.c | 17 | ||||
-rw-r--r-- | src/mga_driver.c | 22 | ||||
-rw-r--r-- | src/mga_macros.h | 10 |
4 files changed, 28 insertions, 26 deletions
@@ -391,6 +391,11 @@ typedef struct { xf86AccessRec Access; int Chipset; int ChipRev; + + int is_Gx50:1; + int is_G200SE:1; + int is_HAL_chipset:1; + Bool Primary; Bool Interleave; int HwBpp; diff --git a/src/mga_dacG.c b/src/mga_dacG.c index 0caf9fe..df29b48 100644 --- a/src/mga_dacG.c +++ b/src/mga_dacG.c @@ -242,8 +242,7 @@ MGAGSetPCLK( ScrnInfoPtr pScrn, long f_out ) return; } - if ((pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI)) { + if (pMga->is_G200SE) { MGAG200SEComputePLLParam(pScrn, f_out, &m, &n, &p); pReg->DacRegs[ MGA1064_PIX_PLLC_M ] = m; @@ -761,9 +760,8 @@ MGA_NOT_HAL( ((i == 0x2c) || (i == 0x2d) || (i == 0x2e) || (i == 0x4c) || (i == 0x4d) || (i == 0x4e)))) continue; - if (((pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI)) && - ((i == 0x2C) || (i == 0x2D) || (i == 0x2E))) + if (pMga->is_G200SE + && ((i == 0x2C) || (i == 0x2D) || (i == 0x2E))) continue; outMGAdac(i, mgaReg->DacRegs[i]); } @@ -800,8 +798,7 @@ MGA_NOT_HAL( OUTREG16(0x1FDE, (mgaReg->ExtVga[i] << 8) | i); /* This handles restoring the generic VGA registers. */ - if ((pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI)) { + if (pMga->is_G200SE) { vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE); if (restoreFonts) MGAG200SERestoreFonts(pScrn, vgaReg); @@ -901,8 +898,7 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg, * This function will handle creating the data structure and filling * in the generic VGA portion. */ - if ((pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI)) { + if (pMga->is_G200SE) { vgaHWSave(pScrn, vgaReg, VGA_SR_MODE); if (saveFonts) MGAG200SESaveFonts(pScrn, vgaReg); @@ -1114,8 +1110,7 @@ MGAG_ddc1Read(ScrnInfoPtr pScrn) outMGAdacmsk(MGA1064_GEN_IO_CTL, ~(DDC_P1_SCL_MASK | DDC_P1_SDA_MASK), 0); /* wait for Vsync */ - if ((pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI)) { + if (pMga->is_G200SE) { usleep(4); } else { while( INREG( MGAREG_Status ) & 0x08 ); diff --git a/src/mga_driver.c b/src/mga_driver.c index cb2b94e..a95871a 100644 --- a/src/mga_driver.c +++ b/src/mga_driver.c @@ -827,9 +827,7 @@ MGACountRam(ScrnInfoPtr pScrn) OUTREG8(MGAREG_CRTCEXT_DATA, tmp | 0x80); /* apparently the G200SE doesn't have a BIOS to read */ - if ((pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI)) { - + if (pMga->is_G200SE) { CARD32 MemoryAt0, MemoryAt1, Offset; CARD32 FirstMemoryVal1, FirstMemoryVal2; CARD32 SecondMemoryVal1, SecondMemoryVal2; @@ -1283,6 +1281,18 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) } else { xf86ErrorF("\n"); } + + pMga->is_Gx50 = ((pMga->Chipset == PCI_CHIP_MGAG400) && (pMga->ChipRev >= 0x80)) + || (pMga->Chipset == PCI_CHIP_MGAG550); + pMga->is_G200SE = (pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) + || (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI); + pMga->is_HAL_chipset = ((pMga->Chipset == PCI_CHIP_MGAG200_PCI) || + (pMga->Chipset == PCI_CHIP_MGAG200) || + (pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || + (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI) || + (pMga->Chipset == PCI_CHIP_MGAG400) || + (pMga->Chipset == PCI_CHIP_MGAG550)); + #ifdef USEMGAHAL if (HAL_CHIPSETS) { Bool loadHal = TRUE; @@ -3067,8 +3077,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pMga = MGAPTR(pScrn); MGAdac = &pMga->Dac; - if ((pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI)) { + if (pMga->is_G200SE) { VRTemp = pScrn->videoRam; FBTemp = pMga->FbMapSize; pScrn->videoRam = 4096; @@ -3152,8 +3161,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) ); /* MGA_HAL */ #endif } - if ((pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI)) { + if (pMga->is_G200SE) { pScrn->videoRam = VRTemp; pMga->FbMapSize = FBTemp; } diff --git a/src/mga_macros.h b/src/mga_macros.h index c8ba847..8a3221d 100644 --- a/src/mga_macros.h +++ b/src/mga_macros.h @@ -63,12 +63,7 @@ while(INREG(MGAREG_DWGSYNC) != MGA_SYNC_XTAG) ; \ #endif #ifdef USEMGAHAL -#define HAL_CHIPSETS ((pMga->Chipset == PCI_CHIP_MGAG200_PCI) || \ - (pMga->Chipset == PCI_CHIP_MGAG200) || \ - (pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || \ - (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI) || \ - (pMga->Chipset == PCI_CHIP_MGAG400) || \ - (pMga->Chipset == PCI_CHIP_MGAG550)) +#define HAL_CHIPSETS (pMga->is_HAL_chipset) #define MGA_HAL(x) { \ MGAPtr pMga = MGAPTR(pScrn); \ @@ -82,8 +77,7 @@ while(INREG(MGAREG_DWGSYNC) != MGA_SYNC_XTAG) ; \ #define MGA_NOT_HAL(x) { x; } #endif -#define MGAISGx50(x) ( (((x)->Chipset == PCI_CHIP_MGAG400) && ((x)->ChipRev >= 0x80)) || \ - ((x)->Chipset == PCI_CHIP_MGAG550) ) +#define MGAISGx50(x) ((x)->is_Gx50) #define MGA_DH_NEEDS_HAL(x) (((x)->Chipset == PCI_CHIP_MGAG400) && \ ((x)->ChipRev < 0x80)) |