diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/atiprobe.c | 297 |
2 files changed, 75 insertions, 231 deletions
@@ -1,3 +1,12 @@ +2006-03-15 Luc Verhaegen,,, <set EMAIL_ADDRESS environment variable> + + * src/atiprobe.c: (ATIMach64Detect), (ATIMach64Probe), (ATIProbe): + + Remove extensive checking for sharable VGA. We know that it's + sharable, and i do believe that these devices will all be marked as + VGA compatible. Just keep the code that wakes up the VGA controller. + + 2006-03-15 Luc Verhaegen <libv@skynet.be> * src/atiprobe.c: (ATIVGAProbe), (ATIAssignVGA), (ATIFindVGA), diff --git a/src/atiprobe.c b/src/atiprobe.c index f250f94..658fbd0 100644 --- a/src/atiprobe.c +++ b/src/atiprobe.c @@ -39,7 +39,6 @@ #include "ativalid.h" #include "ativersion.h" #include "atividmem.h" -#include "atiwonderio.h" /* * NOTES: @@ -66,57 +65,6 @@ typedef struct _ATIGDev CARD8 Chipset; } ATIGDev, *ATIGDevPtr; -#ifndef AVOID_CPIO - -/* - * ATIVGAProbe -- - * - * This function looks for an IBM standard VGA, or clone, and sets - * pATI->VGAAdapter if one is found. - */ -static ATIPtr -ATIVGAProbe(ATIPtr pVGA) -{ - CARD8 IOValue1, IOValue2, IOValue3; - - if (!pVGA) - pVGA = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); - - /* - * VGA has one more attribute register than EGA. See if it can be read and - * written. Note that the CRTC registers are not used here, so there's no - * need to unlock them. - */ - ATISetVGAIOBase(pVGA, inb(R_GENMO)); - (void)inb(GENS1(pVGA->CPIO_VGABase)); - IOValue1 = inb(ATTRX); - (void)inb(GENS1(pVGA->CPIO_VGABase)); - IOValue2 = GetReg(ATTRX, 0x14U | 0x20U); - outb(ATTRX, IOValue2 ^ 0x0FU); - IOValue3 = GetReg(ATTRX, 0x14U | 0x20U); - outb(ATTRX, IOValue2); - outb(ATTRX, IOValue1); - (void)inb(GENS1(pVGA->CPIO_VGABase)); - if (IOValue3 == (IOValue2 ^ 0x0FU)) - { - /* VGA device detected */ - if (pVGA->Chip == ATI_CHIP_NONE) - pVGA->Chip = ATI_CHIP_VGA; - if (pVGA->VGAAdapter == ATI_ADAPTER_NONE) - pVGA->VGAAdapter = ATI_ADAPTER_VGA; - if (pVGA->Adapter == ATI_ADAPTER_NONE) - pVGA->Adapter = ATI_ADAPTER_VGA; - } - else - { - pVGA->VGAAdapter = ATI_ADAPTER_NONE; - } - - return pVGA; -} - -#endif /* AVOID_CPIO */ - /* * ATIMach64Detect -- * @@ -124,12 +72,7 @@ ATIVGAProbe(ATIPtr pVGA) * address. */ static Bool -ATIMach64Detect -( - ATIPtr pATI, - const CARD16 ChipType, - const ATIChipType Chip -) +ATIMach64Detect(ATIPtr pATI, const CARD16 ChipType, const ATIChipType Chip) { CARD32 IOValue, bus_cntl, gen_test_cntl; @@ -166,12 +109,10 @@ ATIMach64Detect /* Test odd bits */ outr(SCRATCH_REG0, 0x55555555U); - if (inr(SCRATCH_REG0) == 0x55555555U) - { + if (inr(SCRATCH_REG0) == 0x55555555U) { /* Test even bits */ outr(SCRATCH_REG0, 0xAAAAAAAAU); - if (inr(SCRATCH_REG0) == 0xAAAAAAAAU) - { + if (inr(SCRATCH_REG0) == 0xAAAAAAAAU) { /* * *Something* has a R/W 32-bit register at this address. Try to * make sure it's a Mach64. The following assumes that ATI will @@ -179,8 +120,7 @@ ATIMach64Detect * themselves in PCI configuration space. */ ATIMach64ChipID(pATI, ChipType); - if ((pATI->Chip != ATI_CHIP_Mach64) || - (pATI->CPIODecoding == BLOCK_IO)) + if ((pATI->Chip != ATI_CHIP_Mach64) || (pATI->CPIODecoding == BLOCK_IO)) pATI->Adapter = ATI_ADAPTER_MACH64; } } @@ -189,8 +129,7 @@ ATIMach64Detect outr(SCRATCH_REG0, IOValue); /* If no Mach64 was detected, return now */ - if (pATI->Adapter != ATI_ADAPTER_MACH64) - { + if (pATI->Adapter != ATI_ADAPTER_MACH64) { outr(GEN_TEST_CNTL, gen_test_cntl); outr(BUS_CNTL, bus_cntl); ATIUnmapApertures(-1, pATI); @@ -211,53 +150,39 @@ ATIMach64Detect * ATIRec if one is found. */ static ATIPtr -ATIMach64Probe -( - pciVideoPtr pVideo, - const IOADDRESS IOBase, - const CARD8 IODecoding, - const ATIChipType Chip -) +ATIMach64Probe(pciVideoPtr pVideo, const IOADDRESS IOBase, + const CARD8 IODecoding, const ATIChipType Chip) { - ATIPtr pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); - CARD16 ChipType = 0; + ATIPtr pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); pATI->CPIOBase = IOBase; pATI->CPIODecoding = IODecoding; + pATI->PCIInfo = pVideo; - if (pVideo) - { - pATI->PCIInfo = pVideo; - ChipType = pVideo->chipType; - - /* - * Probe through auxiliary MMIO aperture if one exists. Because such - * apertures can be enabled/disabled only through PCI, this probes no - * further. - */ - if ((pVideo->size[2] >= 12) && - (pATI->Block0Base = pVideo->memBase[2]) && - (pATI->Block0Base < (CARD32)(-1 << pVideo->size[2]))) - { - pATI->Block0Base += 0x00000400U; - goto LastProbe; - } + /* + * Probe through auxiliary MMIO aperture if one exists. Because such + * apertures can be enabled/disabled only through PCI, this probes no + * further. + */ + if ((pVideo->size[2] >= 12) && + (pATI->Block0Base = pVideo->memBase[2]) && + (pATI->Block0Base < (CARD32)(-1 << pVideo->size[2]))) { + pATI->Block0Base += 0x00000400U; + goto LastProbe; + } - /* - * Probe through the primary MMIO aperture that exists at the tail end - * of the linear aperture. Test for both 8MB and 4MB linear apertures. - */ - if ((pVideo->size[0] >= 22) && (pATI->Block0Base = pVideo->memBase[0])) - { - pATI->Block0Base += 0x007FFC00U; - if ((pVideo->size[0] >= 23) && - ATIMach64Detect(pATI, ChipType, Chip)) - return pATI; - - pATI->Block0Base -= 0x00400000U; - if (ATIMach64Detect(pATI, ChipType, Chip)) - return pATI; - } + /* + * Probe through the primary MMIO aperture that exists at the tail end + * of the linear aperture. Test for both 8MB and 4MB linear apertures. + */ + if ((pVideo->size[0] >= 22) && (pATI->Block0Base = pVideo->memBase[0])) { + pATI->Block0Base += 0x007FFC00U; + if ((pVideo->size[0] >= 23) && ATIMach64Detect(pATI, pVideo->chipType, Chip)) + return pATI; + + pATI->Block0Base -= 0x00400000U; + if (ATIMach64Detect(pATI, pVideo->chipType, Chip)) + return pATI; } /* @@ -268,7 +193,7 @@ ATIMach64Probe pATI->Block0Base = 0x000BFC00U; LastProbe: - if (ATIMach64Detect(pATI, ChipType, Chip)) + if (ATIMach64Detect(pATI, pVideo->chipType, Chip)) return pATI; xfree(pATI); @@ -284,38 +209,25 @@ LastProbe: * ATIRec if one is found. */ static ATIPtr -ATIMach64Probe -( - pciVideoPtr pVideo, - const IOADDRESS IOBase, - const CARD8 IODecoding, - const ATIChipType Chip -) +ATIMach64Probe(pciVideoPtr pVideo, const IOADDRESS IOBase, + const CARD8 IODecoding, const ATIChipType Chip) { ATIPtr pATI; - CARD32 IOValue; - CARD16 ChipType = 0; if (!IOBase) return NULL; - if (pVideo) - { - if ((IODecoding == BLOCK_IO) && - ((pVideo->size[1] < 8) || - (IOBase >= (CARD32)(-1 << pVideo->size[1])))) - return NULL; - - ChipType = pVideo->chipType; - } - + if ((IODecoding == BLOCK_IO) && + ((pVideo->size[1] < 8) || + (IOBase >= (CARD32)(-1 << pVideo->size[1])))) + return NULL; + pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); pATI->CPIOBase = IOBase; pATI->CPIODecoding = IODecoding; pATI->PCIInfo = pVideo; - if (!ATIMach64Detect(pATI, ChipType, Chip)) - { + if (!ATIMach64Detect(pATI, pVideo->chipType, Chip)) { xfree(pATI); return NULL; } @@ -324,93 +236,33 @@ ATIMach64Probe * Determine VGA capability. VGA can always be enabled on integrated * controllers. For the GX/CX, it's a board strap. */ - if (pATI->Chip >= ATI_CHIP_264CT) - { - pATI->VGAAdapter = ATI_ADAPTER_MACH64; - } - else - { + if (pATI->Chip < ATI_CHIP_264CT) { + CARD32 IOValue; + IOValue = inr(CONFIG_STATUS64_0); pATI->BusType = GetBits(IOValue, CFG_BUS_TYPE); IOValue &= (CFG_VGA_EN | CFG_CHIP_EN); + if (pATI->Chip == ATI_CHIP_88800CX) IOValue |= CFG_VGA_EN; - if (IOValue == (CFG_VGA_EN | CFG_CHIP_EN)) - { + + if (IOValue == (CFG_VGA_EN | CFG_CHIP_EN)) { pATI->VGAAdapter = ATI_ADAPTER_MACH64; pATI->CPIO_VGAWonder = 0x01CEU; pATI->VGAOffset = 0x80U; - } - } - - return pATI; -} - -/* - * ATIAssignVGA -- - * - * This function is called to associate a VGA interface with an accelerator. - * This is done by temporarily configuring the accelerator to route VGA RAMDAC - * I/O through the accelerator's RAMDAC. A value is then written through the - * VGA DAC ports and a check is made to see if the same value shows up on the - * accelerator side. - */ -static void -ATIAssignVGA(pciVideoPtr pVideo, ATIPtr pATI) -{ - CARD32 DACCntl = inr(DAC_CNTL); - CARD8 OldDACMask; - - /* Assume unassignable VGA */ - pATI->VGAAdapter = ATI_ADAPTER_NONE; - if (pATI->CPIO_VGAWonder) - pATI->CPIO_VGAWonder = 0; - - if (!(DACCntl & DAC_VGA_ADR_EN)) - outr(DAC_CNTL, DACCntl | DAC_VGA_ADR_EN); - - OldDACMask = inb(VGA_DAC_MASK); - - if (in8(M64_DAC_MASK) == OldDACMask) { - outb(VGA_DAC_MASK, 0xA5U); - - if (in8(M64_DAC_MASK) == 0xA5U) { - pATI->VGAAdapter = ATI_ADAPTER_MACH64; - pATI->SharedVGA = TRUE; } else - pATI->CPIO_VGAWonder = 0; - - outb(VGA_DAC_MASK, OldDACMask); + pATI->VGAAdapter = ATI_ADAPTER_NONE; + } else + pATI->VGAAdapter = ATI_ADAPTER_MACH64; + + /* Ensure that the VGA isn't in sleep mode. */ + if (pATI->VGAAdapter != ATI_ADAPTER_NONE) { + outb(GENENA, 0x16U); + outb(GENVS, 0x01U); + outb(GENENA, 0x0EU); } - if (!(DACCntl & DAC_VGA_ADR_EN)) - outr(DAC_CNTL, DACCntl); -} - -/* - * ATIFindVGA -- - * - * This function determines if a VGA associated with an ATI PCI adapter is - * shareable. - */ -static void -ATIFindVGA(pciVideoPtr pVideo, ATIPtr *ppATI) -{ - ATIPtr pATI = *ppATI; - - /* - * An ATI PCI adapter has been detected at this point, and its VGA, if - * any, is shareable. Ensure the VGA isn't in sleep mode. - */ - outb(GENENA, 0x16U); - outb(GENVS, 0x01U); - outb(GENENA, 0x0EU); - - pATI = ATIVGAProbe(pATI); - if (pATI->VGAAdapter == ATI_ADAPTER_NONE) - return; - - ATIAssignVGA(pVideo, pATI); + return pATI; } #endif /* AVOID_CPIO */ @@ -537,11 +389,6 @@ ATIProbe(DriverPtr pDriver, int flags) pATI->SharedAccelerator = TRUE; pATI->PCIInfo = pVideo; - -#ifndef AVOID_CPIO - if (pATI->VGAAdapter != ATI_ADAPTER_NONE) - ATIFindVGA(pVideo, &pATI); -#endif /* AVOID_CPIO */ } xf86SetPciVideo(NULL, NONE); @@ -581,27 +428,15 @@ ATIProbe(DriverPtr pDriver, int flags) { pATI = ATIPtrs[i]; -#ifndef AVOID_CPIO - - if ((pATI->Adapter != ATI_ADAPTER_VGA) && - ((pATI->Adapter != ATI_ADAPTER_8514A) || - ((pATI->VGAAdapter != ATI_ADAPTER_VGA) && - (pATI->VGAAdapter != ATI_ADAPTER_NONE)))) - -#endif /* AVOID_CPIO */ - - { - ProbeSuccess = TRUE; - pGDev = xf86AddDeviceToConfigure(ATI_DRIVER_NAME, - pATI->PCIInfo, ATI_CHIPSET_ATI); - if (pGDev) - { - /* Fill in additional information */ - pGDev->vendor = ATI_NAME; - pGDev->chipset = (char *)ATIChipsetNames[ATI_CHIPSET_ATI]; - if (!pATI->PCIInfo) - pGDev->busID = NULL; - } + ProbeSuccess = TRUE; + pGDev = xf86AddDeviceToConfigure(ATI_DRIVER_NAME, + pATI->PCIInfo, ATI_CHIPSET_ATI); + if (pGDev) { + /* Fill in additional information */ + pGDev->vendor = ATI_NAME; + pGDev->chipset = (char *)ATIChipsetNames[ATI_CHIPSET_ATI]; + if (!pATI->PCIInfo) + pGDev->busID = NULL; } xfree(pATI); |