diff options
author | Luc Verhaegen <libv@skynet.be> | 2006-04-15 16:10:33 +0200 |
---|---|---|
committer | Luc Verhaegen <libv@skynet.be> | 2006-04-15 16:10:33 +0200 |
commit | 26ef6400d83b3173a73815da85ae75dac71b7c0c (patch) | |
tree | 1a35e8131a5960dc0d4cd25f5331f4108739a400 | |
parent | a5b8c226cdd69285043ed0362ff6b5262d6025b0 (diff) |
The VGAWonder IO range is always 0x1CE, so use a #define and just track a Bool
IsVGAWonder instead.
Move CPIOBase resource claim next to the retrieval of the address.
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | src/atiadjust.c | 5 | ||||
-rw-r--r-- | src/aticlock.c | 8 | ||||
-rw-r--r-- | src/atilock.c | 6 | ||||
-rw-r--r-- | src/atimode.c | 10 | ||||
-rw-r--r-- | src/atipreinit.c | 157 | ||||
-rw-r--r-- | src/atiprint.c | 7 | ||||
-rw-r--r-- | src/atistruct.h | 7 | ||||
-rw-r--r-- | src/atiwonderio.h | 9 |
9 files changed, 105 insertions, 121 deletions
@@ -1,5 +1,22 @@ 2006-04-15 Luc Verhaegen <libv@skynet.be> + * src/atiadjust.c: (ATIAdjustPreInit), (ATIAdjustFrame): + * src/aticlock.c: (ProbeClocks), (ATIClockCalculate): + * src/atilock.c: (ATIUnlock), (ATILock): + * src/atimode.c: (ATIModePreInit), (ATIModeSave), (ATIModeCalculate), + (ATIModeSet): + * src/atipreinit.c: (Mach64IOSetup), (ATIMach64Probe), + (ATIClaimVGAResources), (ATIPreInit): + * src/atiprint.c: (ATIPrintRegisters): + * src/atistruct.h: + * src/atiwonderio.h: + + The VGAWonder IO range is always 0x1CE, so use a #define and just + track a Bool IsVGAWonder instead. + Move CPIOBase resource claim next to the retrieval of the address. + +2006-04-15 Luc Verhaegen <libv@skynet.be> + * src/Makefile.am: * src/atibus.c: (ATIClaimResources): * src/atibus.h: diff --git a/src/atiadjust.c b/src/atiadjust.c index e95af55..b558fa2 100644 --- a/src/atiadjust.c +++ b/src/atiadjust.c @@ -73,7 +73,7 @@ ATIAdjustPreInit { pATI->AdjustMaxBase = MaxBits(CRTC_OFFSET_VGA) << 2; } - else if (!pATI->CPIO_VGAWonder) + else if (!pATI->IsVGAWonder) { pATI->AdjustMaxBase = 0xFFFFU << 3; } @@ -160,8 +160,7 @@ ATIAdjustFrame PutReg(CRTX(pATI->CPIO_VGABase), 0x0CU, GetByte(Base, 1)); PutReg(CRTX(pATI->CPIO_VGABase), 0x0DU, GetByte(Base, 0)); - if (pATI->CPIO_VGAWonder) - { + if (pATI->IsVGAWonder) { ATIModifyExtReg(pATI, 0xB0U, -1, 0xBFU, Base >> 10); ATIModifyExtReg(pATI, 0xA3U, -1, 0xEFU, Base >> 13); diff --git a/src/aticlock.c b/src/aticlock.c index bdb4957..c7b1d58 100644 --- a/src/aticlock.c +++ b/src/aticlock.c @@ -734,7 +734,7 @@ ProbeClocks: ATIModeSave(pScreenInfo, pATI, &pATI->OldHW); /* Ensure clock select pins are not OR'ed with anything */ - if (pATI->CPIO_VGAWonder && (pATI->OldHW.crtc == ATI_CRTC_VGA)) + if (pATI->IsVGAWonder && (pATI->OldHW.crtc == ATI_CRTC_VGA)) ATIModifyExtReg(pATI, 0xB5U, pATI->OldHW.b5, 0x7FU, 0x00U); } @@ -764,8 +764,7 @@ ProbeClocks: /* Get generic two low-order bits */ genmo = (inb(R_GENMO) & 0xF3U) | ((Index << 2) & 0x0CU); - if (pATI->CPIO_VGAWonder) - { + if (pATI->IsVGAWonder) { /* Start sequencer reset */ PutReg(SEQX, 0x00U, 0x00U); @@ -1281,8 +1280,7 @@ ATIClockCalculate pATIHW->genmo = (pATIHW->genmo & 0xF3U) | ((ClockSelect << 2) & 0x0CU); - if (pATI->CPIO_VGAWonder) - { + if (pATI->IsVGAWonder) { /* Set ATI clock select bits */ pATIHW->be = (pATIHW->be & 0xEFU) | ((ClockSelect << 2) & 0x10U); diff --git a/src/atilock.c b/src/atilock.c index 02e3167..f310ce3 100644 --- a/src/atilock.c +++ b/src/atilock.c @@ -173,8 +173,7 @@ ATIUnlock } if (pATI->IsVGA) { - if (pATI->CPIO_VGAWonder) - { + if (pATI->IsVGAWonder) { /* * Ensure all registers are read/write and disable all non-VGA * emulations. @@ -445,8 +444,7 @@ ATILock ATIMach64PutLCDReg(LCD_GEN_CNTL, saved_lcd_gen_ctrl); } - if (pATI->CPIO_VGAWonder) - { + if (pATI->IsVGAWonder) { /* * Restore emulation and protection bits in ATI extended VGA * registers. diff --git a/src/atimode.c b/src/atimode.c index 175db92..171d750 100644 --- a/src/atimode.c +++ b/src/atimode.c @@ -267,7 +267,7 @@ ATIModePreInit ATIVGAPreInit(pATI, pATIHW); /* Fill in VGA Wonder data */ - if (pATI->CPIO_VGAWonder) + if (pATI->IsVGAWonder) ATIVGAWonderPreInit(pATI, pATIHW); } @@ -425,7 +425,7 @@ ATIModeSave ATIVGASave(pATI, pATIHW); /* Save VGA Wonder data */ - if (pATI->CPIO_VGAWonder) + if (pATI->IsVGAWonder) ATIVGAWonderSave(pATI, pATIHW); } @@ -587,7 +587,7 @@ ATIModeCalculate ATIVGACalculate(pATI, pATIHW, pMode); /* Fill in VGA Wonder data */ - if (pATI->CPIO_VGAWonder) + if (pATI->IsVGAWonder) ATIVGAWonderCalculate(pATI, pATIHW, pMode); if (pATI->Chip >= ATI_CHIP_264CT) { @@ -1070,7 +1070,7 @@ ATIModeSet ATIRGB514Set(pATI, pATIHW); /* Load VGA Wonder */ - if (pATI->CPIO_VGAWonder) + if (pATI->IsVGAWonder) ATIVGAWonderSet(pATI, pATIHW); /* Load VGA device */ @@ -1127,7 +1127,7 @@ ATIModeSet PutReg(SEQX, 0x02U, pATIHW->seq[2]); PutReg(SEQX, 0x04U, pATIHW->seq[4]); PutReg(GRAX, 0x06U, pATIHW->gra[6]); - if (pATI->CPIO_VGAWonder) + if (pATI->IsVGAWonder) ATIModifyExtReg(pATI, 0xB6U, -1, 0x00U, pATIHW->b6); } diff --git a/src/atipreinit.c b/src/atipreinit.c index d2402d5..6048c37 100644 --- a/src/atipreinit.c +++ b/src/atipreinit.c @@ -70,39 +70,56 @@ ATIGetRec(ScrnInfoPtr pScrn) return TRUE; } -#ifndef AVOID_CPIO /* - * + * Collect IO range information. */ -static IOADDRESS -Mach64CPIOGetIOBase(PCITAG tag) +static void +Mach64IOSetup(ATIPtr pATI) { - IOADDRESS address; - CARD32 PciReg = pciReadLong(tag, PCI_REG_USERCONFIG); + /* block IO? */ + if (pATI->PCIInfo->size[1]) { + pATI->CPIOBase = pATI->PCIInfo->ioBase[1]; + pATI->CPIODecoding = BLOCK_IO; + } else { /* sparse IO */ + pATI->CPIODecoding = SPARSE_IO; + pATI->CPIOBase = 0; - switch (PciReg & 0x03) { - case 0x00: - address = 0x02EC; - break; - case 0x01: - address = 0x01CC; - break; - case 0x02: - address = 0x01C8; - break; - case 0x03: - default: - /* not accepted! */ - return 0x00; - } +#ifndef AVOID_CPIO + { + PCITAG tag = ((pciConfigPtr) pATI->PCIInfo->thisCard)->tag; + CARD32 PciReg = pciReadLong(tag, PCI_REG_USERCONFIG); + resRange Resources[2] = {{0, 0, 0}, _END}; + + switch (PciReg & 0x03) { + case 0x00: + pATI->CPIOBase = 0x02EC; + break; + case 0x01: + pATI->CPIOBase = 0x01CC; + break; + case 0x02: + pATI->CPIOBase = 0x01C8; + break; + case 0x03: + default: + /* not accepted! */ + pATI->CPIOBase = 0x00; + break; + } - /* Possibly fix block I/O indicator */ - if (PciReg & 0x00000004) - pciWriteLong(tag, PCI_REG_USERCONFIG, PciReg & ~0x00000004U); + Resources[0].type = ResShrIoSparse | ResBus; + Resources[0].rBase = pATI->CPIOBase; + Resources[0].rMask = 0x03FCU; + + xf86ClaimFixedResources(Resources, pATI->iEntity); - return address; -} + /* Possibly fix block I/O indicator */ + if (PciReg & 0x00000004) + pciWriteLong(tag, PCI_REG_USERCONFIG, PciReg & ~0x00000004U); + } #endif /* AVOID_CPIO */ + } +} /* * ATIMach64Detect -- @@ -172,10 +189,7 @@ ATIMach64Detect(ATIPtr pATI) #ifdef AVOID_CPIO /* - * ATIMach64Probe -- - * - * This function looks for a Mach64 at a particular MMIO address and returns an - * ATIRec if one is found. + * This function looks for a Mach64 at a particular MMIO address. */ static Bool ATIMach64Probe(ATIPtr pATI) @@ -220,10 +234,7 @@ ATIMach64Probe(ATIPtr pATI) #else /* AVOID_CPIO */ /* - * ATIMach64Probe -- - * - * This function looks for a Mach64 at a particular PIO address and returns an - * ATIRec if one is found. + * This function looks for a Mach64 at a particular PIO address. */ static Bool ATIMach64Probe(ATIPtr pATI) @@ -255,8 +266,7 @@ ATIMach64Probe(ATIPtr pATI) if (IOValue == (CFG_VGA_EN | CFG_CHIP_EN)) { pATI->IsVGA = TRUE; - pATI->CPIO_VGAWonder = 0x01CEU; - pATI->VGAOffset = 0x80U; + pATI->IsVGAWonder = TRUE; } else pATI->IsVGA = FALSE; } else @@ -273,47 +283,27 @@ ATIMach64Probe(ATIPtr pATI) } /* - * ATIClaimResources -- + * Claim VGA and VGAWonder resources * - * This function registers most of the bus resources used by an adapter. The - * exceptions are PCI-configured resources and non-PCI non-AGP linear - * apertures, both of which are registered by ATIPreInit(). This function also - * attempts to register unshareable resources for inactive PCI adapters, - * whether or not they are relocatable. + * 18800-x's are the only ATI controllers that decode all ISA aliases + * of VGA and VGA Wonder I/O ports. Other x8800's do not decode >any< + * VGA aliases, but do decode VGA Wonder aliases whose most significant + * nibble is zero. */ static void -ATIClaimResources(ATIPtr pATI) +ATIClaimVGAResources(ATIPtr pATI) { - /* Claim VGA and VGAWonder resources */ - if (pATI->IsVGA) { - /* - * 18800-x's are the only ATI controllers that decode all ISA aliases - * of VGA and VGA Wonder I/O ports. Other x8800's do not decode >any< - * VGA aliases, but do decode VGA Wonder aliases whose most significant - * nibble is zero. - */ - xf86ClaimFixedResources(resVgaShared, pATI->iEntity); - - if (pATI->CPIO_VGAWonder) { - resRange Resources[2] = {{0, 0, 0}, _END}; - Resources[0].type = ResShrIoSparse | ResBus; - Resources[0].rBase = pATI->CPIO_VGAWonder; - Resources[0].rMask = 0xF3FEU; - - xf86ClaimFixedResources(Resources, pATI->iEntity); - - (void)memcpy(pATI->VGAWonderResources, Resources, SizeOf(Resources)); - } - } + xf86ClaimFixedResources(resVgaShared, pATI->iEntity); - /* Claim Mach64 sparse I/O resources */ - if (pATI->CPIODecoding == SPARSE_IO) { + if (pATI->IsVGAWonder) { resRange Resources[2] = {{0, 0, 0}, _END}; Resources[0].type = ResShrIoSparse | ResBus; - Resources[0].rBase = pATI->CPIOBase; - Resources[0].rMask = 0x03FCU; + Resources[0].rBase = WONDER_IO; + Resources[0].rMask = WONDER_IO_MASK; xf86ClaimFixedResources(Resources, pATI->iEntity); + + (void)memcpy(pATI->VGAWonderResources, Resources, SizeOf(Resources)); } } #endif /* AVOID_CPIO */ @@ -878,7 +868,6 @@ ATIPrintNoiseIfRequested _X_EXPORT Bool ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) { - char Buffer[128], *Message; ATIPtr pATI; GDevPtr pGDev; EntityInfoPtr pEntity; @@ -937,20 +926,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) pATI->Chip = pEntity->chipset; Mach64ChipIDInfo(pATI); - /* block IO? */ - if (pATI->PCIInfo->size[1]) { - pATI->CPIOBase = pATI->PCIInfo->ioBase[1]; - pATI->CPIODecoding = BLOCK_IO; - } else { /* sparse IO */ - pATI->CPIODecoding = SPARSE_IO; - -#ifndef AVOID_CPIO - pATI->CPIOBase = Mach64CPIOGetIOBase(((pciConfigPtr) - pATI->PCIInfo->thisCard)->tag); -#else - pATI->CPIOBase = 0; -#endif /* AVOID_CPIO */ - } + Mach64IOSetup(pATI); if (!ATIMach64Probe(pATI)) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, @@ -962,7 +938,8 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) } #ifndef AVOID_CPIO - ATIClaimResources(pATI); + if (pATI->IsVGA) + ATIClaimVGAResources(pATI); #endif if (!pResources) @@ -1370,10 +1347,9 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) (pATI->CPIODecoding == SPARSE_IO) ? "sparse" : "block", pATI->CPIOBase); - if (pATI->CPIO_VGAWonder) + if (pATI->IsVGAWonder) xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, - "VGA Wonder registers at I/O port 0x%04lX.\n", - pATI->CPIO_VGAWonder); + "VGA Wonder registers at I/O port 0x%04X.\n", WONDER_IO); #endif /* AVOID_CPIO */ @@ -1526,7 +1502,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) xf86FreeResList(pResources); } - if (pATI->CPIO_VGAWonder) { + if (pATI->IsVGAWonder) { pResources = xf86SetOperatingState(pATI->VGAWonderResources, pATI->iEntity, ResUnusedOpr); if (pResources) { @@ -2149,8 +2125,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) #ifndef AVOID_CPIO AcceleratorVideoRAM = pScreenInfo->videoRam; - if (pATI->CPIO_VGAWonder) - { + if (pATI->IsVGAWonder) { /* * XXX There's an assumption here that the values retrieved are those * set by BIOS initialisation. @@ -2703,7 +2678,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags) * Don't exceed the memory clock on VGA Wonder capables * with less than 1 MB, if using a packed mode. */ - if (pATI->CPIO_VGAWonder && (pATI->VideoRAM < 1024)) + if (pATI->IsVGAWonder && (pATI->VideoRAM < 1024)) DefaultmaxClock = (GetBits(BIOSByte(0x44U), 0x04U) * 5000) + 40000; else diff --git a/src/atiprint.c b/src/atiprint.c index 15fb8b3..bbc9175 100644 --- a/src/atiprint.c +++ b/src/atiprint.c @@ -467,10 +467,9 @@ ATIPrintRegisters ATIPrintIndexedRegisters(GRAX, 0, 16, "Graphics controller", 0); ATIPrintIndexedRegisters(SEQX, 0, 8, "Sequencer", 0); - if (pATI->CPIO_VGAWonder) - ATIPrintIndexedRegisters(pATI->CPIO_VGAWonder, - xf86ServerIsOnlyProbing() ? 0x80U : pATI->VGAOffset, 0xC0U, - "ATI extended VGA", 0); + if (pATI->IsVGAWonder) + ATIPrintIndexedRegisters(WONDER_IO, 0x80U, 0xC0U, + "ATI extended VGA", 0); } #endif /* AVOID_CPIO */ diff --git a/src/atistruct.h b/src/atistruct.h index abaa540..c01cee6 100644 --- a/src/atistruct.h +++ b/src/atistruct.h @@ -197,12 +197,9 @@ typedef struct _ATIRec */ IOADDRESS CPIO_VGABase; - /* - * Processor I/O port definitions for VGA Wonder. - */ - IOADDRESS CPIO_VGAWonder; + /* Processor I/O port definitions for VGA Wonder. */ + Bool IsVGAWonder; CARD8 B2Reg; /* The B2 mirror */ - CARD8 VGAOffset; /* Low index for CPIO_VGAWonder */ #endif /* AVOID_CPIO */ diff --git a/src/atiwonderio.h b/src/atiwonderio.h index cdd6087..8072978 100644 --- a/src/atiwonderio.h +++ b/src/atiwonderio.h @@ -35,12 +35,13 @@ #ifndef AVOID_CPIO +#define WONDER_IO 0x1CEU +#define WONDER_IO_MASK 0xF3FEU; + extern void ATIModifyExtReg(ATIPtr, const CARD8, int, const CARD8, CARD8); -#define ATIGetExtReg(_Index) \ - GetReg(pATI->CPIO_VGAWonder, _Index) -#define ATIPutExtReg(_Index, _Value) \ - PutReg(pATI->CPIO_VGAWonder, _Index, _Value) +#define ATIGetExtReg(_Index) GetReg(WONDER_IO, _Index) +#define ATIPutExtReg(_Index, _Value) PutReg(WONDER_IO, _Index, _Value) #endif /* AVOID_CPIO */ |