diff options
author | Luc Verhaegen <libv@skynet.be> | 2006-03-17 14:12:42 +0000 |
---|---|---|
committer | Luc Verhaegen <libv@skynet.be> | 2006-03-17 14:12:42 +0000 |
commit | a792e57b2cb61954676a5f092e170c225f3295cf (patch) | |
tree | 7a1079b7c30c2d26e416377e37b8bdc72e3af7f5 | |
parent | b93e5ea84b29d5f33bf817153562886ebd4d81dc (diff) |
Move actual io poking and privates initialisation to PreInit. Move what's
left of the Probe to ati.c for good measure.
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/ati.c | 147 | ||||
-rw-r--r-- | src/atipreinit.c | 304 | ||||
-rw-r--r-- | src/atiprobe.c | 498 | ||||
-rw-r--r-- | src/atiprobe.h | 31 |
6 files changed, 456 insertions, 542 deletions
@@ -1,3 +1,16 @@ +2006-03-17 Luc Verhaegen <libv@skynet.be> + + * src/Makefile.am: + * src/ati.c: (ATIProbe): + * src/atipreinit.c: (ATIGetRec), (Mach64CPIOGetIOBase), + (ATIMach64Detect), (ATIMach64Probe), (Mach64ChipsetRevisions), + (ATIPreInit): + * src/atiprobe.c: + * src/atiprobe.h: + + Move actual io poking and privates initialisation to PreInit. + Move what's left of the Probe to ati.c for good measure. + 2006-03-16 Luc Verhaegen <libv@skynet.be> * src/atiprobe.c: (Mach64ChipsetRevisions), (ATIProbe): @@ -14,7 +27,7 @@ Allocate pATI in ATIProbe instead of the ATIMach64Probes. Shuffle some more code about surrounding this. -2006-03-15 Luc Verhaegen,,, <set EMAIL_ADDRESS environment variable> +2006-03-15 Luc Verhaegen <libv@skynet.be> * src/atiprobe.c: (ATIMach64Detect), (ATIMach64Probe), (ATIProbe): diff --git a/src/Makefile.am b/src/Makefile.am index 155313f..7249ee0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -44,7 +44,7 @@ mach64_drv_la_LTLIBRARIES = mach64_drv.la mach64_drv_la_LDFLAGS = -module -avoid-version mach64_drv_ladir = @moduledir@/drivers mach64_drv_la_SOURCES = \ - atiadapter.c atibus.c atichip.c atiident.c atioption.c atiprobe.c \ + atiadapter.c atibus.c atichip.c atiident.c atioption.c \ atividmem.c atiaccel.c atiadjust.c atiaudio.c aticlock.c \ aticonfig.c aticonsole.c aticursor.c atidac.c atidecoder.c \ atidsp.c atii2c.c atilock.c atimach64.c atimach64accel.c \ @@ -90,7 +90,6 @@ EXTRA_DIST = \ atipreinit.h \ atiprint.h \ atipriv.h \ - atiprobe.h \ atiregs.h \ atirgb514.h \ atiscreen.h \ @@ -58,10 +58,21 @@ #include "config.h" #endif +#include "xf86Resources.h" + #include "atiident.h" #include "atioption.h" -#include "atiprobe.h" #include "ativersion.h" +#include "atichip.h" + +/* All the different functions in their different headers *rolls eyes* */ +#include "atiadjust.h" +#include "aticonsole.h" +#include "atipreinit.h" +#include "atiscreen.h" +#include "ativalid.h" + +static Bool ATIProbe(DriverPtr pDriver, int flags); /* The root of all evil... */ static DriverRec ATI = @@ -279,7 +290,6 @@ ATISetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) } } - /* * The following record must be called atiModuleData */ @@ -291,3 +301,136 @@ _X_EXPORT XF86ModuleData mach64ModuleData = }; #endif /* XFree86LOADER */ + +static SymTabRec +Mach64Chipsets[] = { + {ATI_CHIP_88800GXC, "ATI 88800GX-C"}, + {ATI_CHIP_88800GXD, "ATI 88800GX-D"}, + {ATI_CHIP_88800GXE, "ATI 88800GX-E"}, + {ATI_CHIP_88800GXF, "ATI 88800GX-F"}, + {ATI_CHIP_88800GX, "ATI 88800GX"}, + {ATI_CHIP_88800CX, "ATI 88800CX"}, + {ATI_CHIP_264CT, "ATI 264CT"}, + {ATI_CHIP_264ET, "ATI 264ET"}, + {ATI_CHIP_264VT, "ATI 264VT"}, + {ATI_CHIP_264VTB, "ATI 264VT-B"}, + {ATI_CHIP_264GT, "ATI 3D Rage"}, + {ATI_CHIP_264GTB, "ATI 3D Rage II"}, + {ATI_CHIP_264VT3, "ATI 264VT3"}, + {ATI_CHIP_264GTDVD, "ATI 3D Rage II+DVD"}, + {ATI_CHIP_264LT, "ATI 3D Rage LT"}, + {ATI_CHIP_264VT4, "ATI 264VT4"}, + {ATI_CHIP_264GT2C, "ATI 3D Rage IIc"}, + {ATI_CHIP_264GTPRO, "ATI 3D Rage Pro"}, + {ATI_CHIP_264LTPRO, "ATI 3D Rage LT Pro"}, + {ATI_CHIP_264XL, "ATI 3D Rage XL or XC"}, + {ATI_CHIP_MOBILITY, "ATI 3D Rage Mobility"}, + {-1, NULL } +}; + +/* + * This table maps a PCI device ID to a chipset family identifier. + */ +static PciChipsets +Mach64PciChipsets[] = { + {ATI_CHIP_88800GX, PCI_CHIP_MACH64GX, RES_SHARED_VGA}, + {ATI_CHIP_88800CX, PCI_CHIP_MACH64CX, RES_SHARED_VGA}, + {ATI_CHIP_264CT, PCI_CHIP_MACH64CT, RES_SHARED_VGA}, + {ATI_CHIP_264ET, PCI_CHIP_MACH64ET, RES_SHARED_VGA}, + {ATI_CHIP_264VT, PCI_CHIP_MACH64VT, RES_SHARED_VGA}, + {ATI_CHIP_264GT, PCI_CHIP_MACH64GT, RES_SHARED_VGA}, + {ATI_CHIP_264VT3, PCI_CHIP_MACH64VU, RES_SHARED_VGA}, + {ATI_CHIP_264GTDVD, PCI_CHIP_MACH64GU, RES_SHARED_VGA}, + {ATI_CHIP_264LT, PCI_CHIP_MACH64LG, RES_SHARED_VGA}, + {ATI_CHIP_264VT4, PCI_CHIP_MACH64VV, RES_SHARED_VGA}, + {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GV, RES_SHARED_VGA}, + {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GW, RES_SHARED_VGA}, + {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GY, RES_SHARED_VGA}, + {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GZ, RES_SHARED_VGA}, + {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GB, RES_SHARED_VGA}, + {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GD, RES_SHARED_VGA}, + {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GI, RES_SHARED_VGA}, + {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GP, RES_SHARED_VGA}, + {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GQ, RES_SHARED_VGA}, + {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LB, RES_SHARED_VGA}, + {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LD, RES_SHARED_VGA}, + {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LI, RES_SHARED_VGA}, + {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LP, RES_SHARED_VGA}, + {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LQ, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GL, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GM, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GN, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GO, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GR, RES_SHARED_VGA}, + {ATI_CHIP_264XL, PCI_CHIP_MACH64GS, RES_SHARED_VGA}, + {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LM, RES_SHARED_VGA}, + {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LN, RES_SHARED_VGA}, + {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LR, RES_SHARED_VGA}, + {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LS, RES_SHARED_VGA}, + {-1, -1, RES_UNDEFINED} +}; + +/* + * ATIProbe -- + * + * This function is called once, at the start of the first server generation to + * do a minimal probe for supported hardware. + */ +static Bool +ATIProbe(DriverPtr pDriver, int flags) +{ + GDevPtr *devSections; + int *usedChips; + int numDevSections; + int numUsed; + Bool ProbeSuccess = FALSE; + + if ((numDevSections = xf86MatchDevice(ATI_DRIVER_NAME, &devSections)) <= 0) + return FALSE; + + if (xf86GetPciVideoInfo() == NULL) + return FALSE; + + numUsed = xf86MatchPciInstances(ATI_DRIVER_NAME, PCI_VENDOR_ATI, + Mach64Chipsets, Mach64PciChipsets, + devSections, numDevSections, + pDriver, &usedChips); + xfree(devSections); + + if (numUsed <= 0) + return FALSE; + + if (flags & PROBE_DETECT) { + if (numUsed > 0) + ProbeSuccess = TRUE; + } else { + int i; + + for (i = 0; i < numUsed; i++) { + ScrnInfoPtr pScrn; + + pScrn = xf86ConfigPciEntity(NULL, 0, usedChips[i], Mach64PciChipsets, + 0, 0, 0, 0, NULL); + + if (!pScrn) + continue; + + pScrn->driverVersion = ATI_VERSION_CURRENT; + pScrn->driverName = ATI_DRIVER_NAME; + pScrn->name = ATI_NAME; + pScrn->Probe = ATIProbe; + pScrn->PreInit = ATIPreInit; + pScrn->ScreenInit = ATIScreenInit; + pScrn->SwitchMode = ATISwitchMode; + pScrn->AdjustFrame = ATIAdjustFrame; + pScrn->EnterVT = ATIEnterVT; + pScrn->LeaveVT = ATILeaveVT; + pScrn->FreeScreen = ATIFreeScreen; + pScrn->ValidMode = ATIValidMode; + + ProbeSuccess = TRUE; + } + } + + return ProbeSuccess; +} diff --git a/src/atipreinit.c b/src/atipreinit.c index cc45b05..6ca49c0 100644 --- a/src/atipreinit.c +++ b/src/atipreinit.c @@ -298,6 +298,265 @@ ATIMach32videoRam #endif /* AVOID_CPIO */ /* + * + */ +static Bool +ATIGetRec(ScrnInfoPtr pScrn) +{ + if (!pScrn->driverPrivate) + pScrn->driverPrivate = xnfcalloc(sizeof(ATIRec), 1); + return TRUE; +} + +#ifndef AVOID_CPIO +/* + * + */ +static IOADDRESS +Mach64CPIOGetIOBase(PCITAG tag) +{ + IOADDRESS address; + CARD32 PciReg = pciReadLong(tag, PCI_REG_USERCONFIG); + + 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; + } + + /* Possibly fix block I/O indicator */ + if (PciReg & 0x00000004) + pciWriteLong(tag, PCI_REG_USERCONFIG, PciReg & ~0x00000004U); + + return address; +} +#endif /* AVOID_CPIO */ + +/* + * ATIMach64Detect -- + * + * This function determines if a Mach64 is detectable at a particular base + * address. + */ +static Bool +ATIMach64Detect(ATIPtr pATI) +{ + CARD32 IOValue, bus_cntl, gen_test_cntl; + + (void)ATIMapApertures(-1, pATI); /* Ignore errors */ + +#ifdef AVOID_CPIO + + if (!pATI->pBlock[0]) + { + ATIUnmapApertures(-1, pATI); + return FALSE; + } + +#endif /* AVOID_CPIO */ + + /* Make sure any Mach64 is not in some weird state */ + bus_cntl = inr(BUS_CNTL); + if (pATI->Chip < ATI_CHIP_264VTB) + outr(BUS_CNTL, + (bus_cntl & ~(BUS_HOST_ERR_INT_EN | BUS_FIFO_ERR_INT_EN)) | + (BUS_HOST_ERR_INT | BUS_FIFO_ERR_INT)); + else if (pATI->Chip < ATI_CHIP_264VT4) + outr(BUS_CNTL, (bus_cntl & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT); + + gen_test_cntl = inr(GEN_TEST_CNTL); + IOValue = gen_test_cntl & + (GEN_OVR_OUTPUT_EN | GEN_OVR_POLARITY | GEN_CUR_EN | GEN_BLOCK_WR_EN); + outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN); + outr(GEN_TEST_CNTL, IOValue); + outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN); + + /* See if a Mach64 answers */ + IOValue = inr(SCRATCH_REG0); + + /* Test odd bits */ + outr(SCRATCH_REG0, 0x55555555U); + if (inr(SCRATCH_REG0) == 0x55555555U) { + /* Test even bits */ + outr(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 + * not be producing any more adapters that do not register + * themselves in PCI configuration space. + */ + ATIMach64ChipID(pATI, pATI->PCIInfo->chipType); + if ((pATI->Chip != ATI_CHIP_Mach64) || (pATI->CPIODecoding == BLOCK_IO)) + pATI->Adapter = ATI_ADAPTER_MACH64; + } + } + + /* Restore clobbered register value */ + outr(SCRATCH_REG0, IOValue); + + /* If no Mach64 was detected, return now */ + if (pATI->Adapter != ATI_ADAPTER_MACH64) { + outr(GEN_TEST_CNTL, gen_test_cntl); + outr(BUS_CNTL, bus_cntl); + ATIUnmapApertures(-1, pATI); + return FALSE; + } + + ATIUnmapApertures(-1, pATI); + return TRUE; +} + +#ifdef AVOID_CPIO + +/* + * ATIMach64Probe -- + * + * This function looks for a Mach64 at a particular MMIO address and returns an + * ATIRec if one is found. + */ +static Bool +ATIMach64Probe(ATIPtr pATI) +{ + pciVideoPtr pVideo = pATI->PCIInfo; + + /* + * 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; + return ATIMach64Detect(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)) + return TRUE; + + pATI->Block0Base -= 0x00400000U; + if (ATIMach64Detect(pATI)) + return TRUE; + } + + /* + * A last, perhaps desparate, probe attempt. Note that if this succeeds, + * there's a VGA in the system and it's likely the PIO version of the + * driver should be used instead (barring OS issues). + */ + pATI->Block0Base = 0x000BFC00U; + return ATIMach64Detect(pATI); +} + +#else /* AVOID_CPIO */ + +/* + * ATIMach64Probe -- + * + * This function looks for a Mach64 at a particular PIO address and returns an + * ATIRec if one is found. + */ +static Bool +ATIMach64Probe(ATIPtr pATI) +{ + if (!pATI->CPIOBase) + return FALSE; + + if ((pATI->CPIODecoding == BLOCK_IO) && + ((pATI->PCIInfo->size[1] < 8) || + (pATI->CPIOBase >= (CARD32)(-1 << pATI->PCIInfo->size[1])))) + return FALSE; + + if (!ATIMach64Detect(pATI)) + return FALSE; + + /* + * 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) { + 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)) { + pATI->VGAAdapter = ATI_ADAPTER_MACH64; + pATI->CPIO_VGAWonder = 0x01CEU; + pATI->VGAOffset = 0x80U; + } else + 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); + } + + return TRUE; +} + +#endif /* AVOID_CPIO */ + +/* + * pci device id matching isn't sufficient in all cases. + */ +static ATIChipType +Mach64ChipsetRevisions(ATIChipType Chip, CARD8 ChipRev) +{ + switch (Chip) { + case ATI_CHIP_88800GX: + switch (ChipRev) { + case 0x00: + return ATI_CHIP_88800GXC; + case 0x01: + return ATI_CHIP_88800GXD; + case 0x02: + return ATI_CHIP_88800GXE; + case 0x03: + return ATI_CHIP_88800GXF; + default: + return ATI_CHIP_88800GX; + } + case ATI_CHIP_264VT: + /* For simplicity, ignore ChipID discrepancy that can occur here */ + if (!(ChipRev & GetBits(CFG_CHIP_VERSION, CFG_CHIP_REV))) + return ATI_CHIP_264VT; + return ATI_CHIP_264VTB; + case ATI_CHIP_264GT: + if (!(ChipRev & GetBits(CFG_CHIP_VERSION, CFG_CHIP_REV))) + return ATI_CHIP_264GT; + return ATI_CHIP_264GTB; + default: + return Chip; + } +} + +/* * ATIReportMemory -- * * This function reports on the amount and type of video memory found. @@ -449,20 +708,49 @@ ATIPreInit return FALSE; } - pATI = ATIPTR(pScreenInfo); - - if (pATI->iEntity != pScreenInfo->entityList[0]) - { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Logic error: Entity mismatch.\n"); + if (!ATIGetRec(pScreenInfo)) return FALSE; - } + + pATI = ATIPTR(pScreenInfo); /* Register resources */ - pEntity = xf86GetEntityInfo(pATI->iEntity); + pEntity = xf86GetEntityInfo(pScreenInfo->entityList[0]); + pGDev = pEntity->device; pResources = pEntity->resources; + pATI->PCIInfo = xf86GetPciInfoForEntity(pEntity->index); + xfree(pEntity); + + pATI->Chip = Mach64ChipsetRevisions(pEntity->chipset, pATI->PCIInfo->chipRev); + pATI->Chipset = ATI_CHIPSET_MACH64; + + pATI->SharedAccelerator = TRUE; + + /* 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 */ + } + + if (!ATIMach64Probe(pATI)) { + xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, + "Mach64 at %02x:%02x:%01x can not be accessed!\n", + pATI->PCIInfo->bus, pATI->PCIInfo->device, + pATI->PCIInfo->func); + xfree(pATI); + return FALSE; + } + if (!pResources) pResources = xf86RegisterResources(pATI->iEntity, NULL, pATI->SharedAccelerator ? ResShared : ResExclusive); diff --git a/src/atiprobe.c b/src/atiprobe.c deleted file mode 100644 index 60e9836..0000000 --- a/src/atiprobe.c +++ /dev/null @@ -1,498 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c,v 1.62tsi Exp $ */ -/* - * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of Marc Aurele La France not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Marc Aurele La France makes no representations - * about the suitability of this software for any purpose. It is provided - * "as-is" without express or implied warranty. - * - * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO - * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "ati.h" -#include "atiadapter.h" -#include "atiadjust.h" -#include "atibus.h" -#include "atichip.h" -#include "aticonsole.h" -#include "atiident.h" -#include "atimach64io.h" -#include "atipreinit.h" -#include "atiprobe.h" -#include "atiscreen.h" -#include "ativalid.h" -#include "ativersion.h" -#include "atividmem.h" - -/* - * NOTES: - * - * - The driver private structures (ATIRec's) are allocated here, rather than - * in ATIPreInit(). This allows ATIProbe() to pass information to later - * stages. - * - A minor point, perhaps, is that XF86Config Chipset names denote functional - * levels, rather than specific graphics controller chips. - * - ATIProbe() does not call xf86MatchPciInstances(), because ATIProbe() - * should be able to match a mix of PCI and non-PCI devices to XF86Config - * Device sections. Also, PCI configuration space for Mach32's is to be - * largely ignored. - */ - -/* - * An internal structure definition to facilitate the matching of detected - * adapters to XF86Config Device sections. - */ -typedef struct _ATIGDev -{ - GDevPtr pGDev; - int iATIPtr; - CARD8 Chipset; -} ATIGDev, *ATIGDevPtr; - -#ifndef AVOID_CPIO -/* - * - */ -static IOADDRESS -Mach64CPIOGetIOBase(PCITAG tag) -{ - IOADDRESS address; - CARD32 PciReg = pciReadLong(tag, PCI_REG_USERCONFIG); - - 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; - } - - /* Possibly fix block I/O indicator */ - if (PciReg & 0x00000004) - pciWriteLong(tag, PCI_REG_USERCONFIG, PciReg & ~0x00000004U); - - return address; -} -#endif /* AVOID_CPIO */ - -/* - * ATIMach64Detect -- - * - * This function determines if a Mach64 is detectable at a particular base - * address. - */ -static Bool -ATIMach64Detect(ATIPtr pATI) -{ - CARD32 IOValue, bus_cntl, gen_test_cntl; - - (void)ATIMapApertures(-1, pATI); /* Ignore errors */ - -#ifdef AVOID_CPIO - - if (!pATI->pBlock[0]) - { - ATIUnmapApertures(-1, pATI); - return FALSE; - } - -#endif /* AVOID_CPIO */ - - /* Make sure any Mach64 is not in some weird state */ - bus_cntl = inr(BUS_CNTL); - if (pATI->Chip < ATI_CHIP_264VTB) - outr(BUS_CNTL, - (bus_cntl & ~(BUS_HOST_ERR_INT_EN | BUS_FIFO_ERR_INT_EN)) | - (BUS_HOST_ERR_INT | BUS_FIFO_ERR_INT)); - else if (pATI->Chip < ATI_CHIP_264VT4) - outr(BUS_CNTL, (bus_cntl & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT); - - gen_test_cntl = inr(GEN_TEST_CNTL); - IOValue = gen_test_cntl & - (GEN_OVR_OUTPUT_EN | GEN_OVR_POLARITY | GEN_CUR_EN | GEN_BLOCK_WR_EN); - outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN); - outr(GEN_TEST_CNTL, IOValue); - outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN); - - /* See if a Mach64 answers */ - IOValue = inr(SCRATCH_REG0); - - /* Test odd bits */ - outr(SCRATCH_REG0, 0x55555555U); - if (inr(SCRATCH_REG0) == 0x55555555U) { - /* Test even bits */ - outr(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 - * not be producing any more adapters that do not register - * themselves in PCI configuration space. - */ - ATIMach64ChipID(pATI, pATI->PCIInfo->chipType); - if ((pATI->Chip != ATI_CHIP_Mach64) || (pATI->CPIODecoding == BLOCK_IO)) - pATI->Adapter = ATI_ADAPTER_MACH64; - } - } - - /* Restore clobbered register value */ - outr(SCRATCH_REG0, IOValue); - - /* If no Mach64 was detected, return now */ - if (pATI->Adapter != ATI_ADAPTER_MACH64) { - outr(GEN_TEST_CNTL, gen_test_cntl); - outr(BUS_CNTL, bus_cntl); - ATIUnmapApertures(-1, pATI); - return FALSE; - } - - ATIUnmapApertures(-1, pATI); - return TRUE; -} - -#ifdef AVOID_CPIO - -/* - * ATIMach64Probe -- - * - * This function looks for a Mach64 at a particular MMIO address and returns an - * ATIRec if one is found. - */ -static Bool -ATIMach64Probe(ATIPtr pATI) -{ - pciVideoPtr pVideo = pATI->PCIInfo; - - /* - * 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; - return ATIMach64Detect(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)) - return TRUE; - - pATI->Block0Base -= 0x00400000U; - if (ATIMach64Detect(pATI)) - return TRUE; - } - - /* - * A last, perhaps desparate, probe attempt. Note that if this succeeds, - * there's a VGA in the system and it's likely the PIO version of the - * driver should be used instead (barring OS issues). - */ - pATI->Block0Base = 0x000BFC00U; - return ATIMach64Detect(pATI); -} - -#else /* AVOID_CPIO */ - -/* - * ATIMach64Probe -- - * - * This function looks for a Mach64 at a particular PIO address and returns an - * ATIRec if one is found. - */ -static Bool -ATIMach64Probe(ATIPtr pATI) -{ - if (!pATI->CPIOBase) - return FALSE; - - if ((pATI->CPIODecoding == BLOCK_IO) && - ((pATI->PCIInfo->size[1] < 8) || - (pATI->CPIOBase >= (CARD32)(-1 << pATI->PCIInfo->size[1])))) - return FALSE; - - if (!ATIMach64Detect(pATI)) - return FALSE; - - /* - * 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) { - 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)) { - pATI->VGAAdapter = ATI_ADAPTER_MACH64; - pATI->CPIO_VGAWonder = 0x01CEU; - pATI->VGAOffset = 0x80U; - } else - 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); - } - - return TRUE; -} - -#endif /* AVOID_CPIO */ - -static SymTabRec -Mach64Chipsets[] = { - {ATI_CHIP_88800GXC, "ATI 88800GX-C"}, - {ATI_CHIP_88800GXD, "ATI 88800GX-D"}, - {ATI_CHIP_88800GXE, "ATI 88800GX-E"}, - {ATI_CHIP_88800GXF, "ATI 88800GX-F"}, - {ATI_CHIP_88800GX, "ATI 88800GX"}, - {ATI_CHIP_88800CX, "ATI 88800CX"}, - {ATI_CHIP_264CT, "ATI 264CT"}, - {ATI_CHIP_264ET, "ATI 264ET"}, - {ATI_CHIP_264VT, "ATI 264VT"}, - {ATI_CHIP_264VTB, "ATI 264VT-B"}, - {ATI_CHIP_264GT, "ATI 3D Rage"}, - {ATI_CHIP_264GTB, "ATI 3D Rage II"}, - {ATI_CHIP_264VT3, "ATI 264VT3"}, - {ATI_CHIP_264GTDVD, "ATI 3D Rage II+DVD"}, - {ATI_CHIP_264LT, "ATI 3D Rage LT"}, - {ATI_CHIP_264VT4, "ATI 264VT4"}, - {ATI_CHIP_264GT2C, "ATI 3D Rage IIc"}, - {ATI_CHIP_264GTPRO, "ATI 3D Rage Pro"}, - {ATI_CHIP_264LTPRO, "ATI 3D Rage LT Pro"}, - {ATI_CHIP_264XL, "ATI 3D Rage XL or XC"}, - {ATI_CHIP_MOBILITY, "ATI 3D Rage Mobility"}, - {-1, NULL } -}; - -/* - * This table maps a PCI device ID to a chipset family identifier. - */ -static PciChipsets -Mach64PciChipsets[] = { - {ATI_CHIP_88800GX, PCI_CHIP_MACH64GX, RES_SHARED_VGA}, - {ATI_CHIP_88800CX, PCI_CHIP_MACH64CX, RES_SHARED_VGA}, - {ATI_CHIP_264CT, PCI_CHIP_MACH64CT, RES_SHARED_VGA}, - {ATI_CHIP_264ET, PCI_CHIP_MACH64ET, RES_SHARED_VGA}, - {ATI_CHIP_264VT, PCI_CHIP_MACH64VT, RES_SHARED_VGA}, - {ATI_CHIP_264GT, PCI_CHIP_MACH64GT, RES_SHARED_VGA}, - {ATI_CHIP_264VT3, PCI_CHIP_MACH64VU, RES_SHARED_VGA}, - {ATI_CHIP_264GTDVD, PCI_CHIP_MACH64GU, RES_SHARED_VGA}, - {ATI_CHIP_264LT, PCI_CHIP_MACH64LG, RES_SHARED_VGA}, - {ATI_CHIP_264VT4, PCI_CHIP_MACH64VV, RES_SHARED_VGA}, - {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GV, RES_SHARED_VGA}, - {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GW, RES_SHARED_VGA}, - {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GY, RES_SHARED_VGA}, - {ATI_CHIP_264GT2C, PCI_CHIP_MACH64GZ, RES_SHARED_VGA}, - {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GB, RES_SHARED_VGA}, - {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GD, RES_SHARED_VGA}, - {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GI, RES_SHARED_VGA}, - {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GP, RES_SHARED_VGA}, - {ATI_CHIP_264GTPRO, PCI_CHIP_MACH64GQ, RES_SHARED_VGA}, - {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LB, RES_SHARED_VGA}, - {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LD, RES_SHARED_VGA}, - {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LI, RES_SHARED_VGA}, - {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LP, RES_SHARED_VGA}, - {ATI_CHIP_264LTPRO, PCI_CHIP_MACH64LQ, RES_SHARED_VGA}, - {ATI_CHIP_264XL, PCI_CHIP_MACH64GL, RES_SHARED_VGA}, - {ATI_CHIP_264XL, PCI_CHIP_MACH64GM, RES_SHARED_VGA}, - {ATI_CHIP_264XL, PCI_CHIP_MACH64GN, RES_SHARED_VGA}, - {ATI_CHIP_264XL, PCI_CHIP_MACH64GO, RES_SHARED_VGA}, - {ATI_CHIP_264XL, PCI_CHIP_MACH64GR, RES_SHARED_VGA}, - {ATI_CHIP_264XL, PCI_CHIP_MACH64GS, RES_SHARED_VGA}, - {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LM, RES_SHARED_VGA}, - {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LN, RES_SHARED_VGA}, - {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LR, RES_SHARED_VGA}, - {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LS, RES_SHARED_VGA}, - {-1, -1, RES_UNDEFINED} -}; - -/* - * pci device id matching isn't sufficient in all cases. - */ -static ATIChipType -Mach64ChipsetRevisions(ATIChipType Chip, CARD8 ChipRev) -{ - switch (Chip) { - case ATI_CHIP_88800GX: - switch (ChipRev) { - case 0x00: - return ATI_CHIP_88800GXC; - case 0x01: - return ATI_CHIP_88800GXD; - case 0x02: - return ATI_CHIP_88800GXE; - case 0x03: - return ATI_CHIP_88800GXF; - default: - return ATI_CHIP_88800GX; - } - case ATI_CHIP_264VT: - /* For simplicity, ignore ChipID discrepancy that can occur here */ - if (!(ChipRev & GetBits(CFG_CHIP_VERSION, CFG_CHIP_REV))) - return ATI_CHIP_264VT; - return ATI_CHIP_264VTB; - case ATI_CHIP_264GT: - if (!(ChipRev & GetBits(CFG_CHIP_VERSION, CFG_CHIP_REV))) - return ATI_CHIP_264GT; - return ATI_CHIP_264GTB; - default: - return Chip; - } -} - -/* - * ATIProbe -- - * - * This function is called once, at the start of the first server generation to - * do a minimal probe for supported hardware. - */ -Bool -ATIProbe(DriverPtr pDriver, int flags) -{ - GDevPtr *devSections; - int *usedChips; - int numDevSections; - int numUsed; - Bool ProbeSuccess = FALSE; - - if ((numDevSections = xf86MatchDevice(ATI_DRIVER_NAME, &devSections)) <= 0) - return FALSE; - - if (xf86GetPciVideoInfo() == NULL) - return FALSE; - - numUsed = xf86MatchPciInstances(ATI_DRIVER_NAME, PCI_VENDOR_ATI, - Mach64Chipsets, Mach64PciChipsets, - devSections, numDevSections, - pDriver, &usedChips); - xfree(devSections); - - if (numUsed <= 0) - return FALSE; - - if (flags & PROBE_DETECT) { - if (numUsed > 0) - ProbeSuccess = TRUE; - } else { - int i; - - for (i = 0; i < numUsed; i++) { - EntityInfoPtr pEnt; - ATIPtr pATI; - ScrnInfoPtr pScrn; - - pScrn = xf86ConfigPciEntity(NULL, 0, usedChips[i], Mach64PciChipsets, - 0, 0, 0, 0, NULL); - - if (!pScrn) - continue; - - pEnt = xf86GetEntityInfo(usedChips[i]); - - /* - * Try to set up the privates first. This is a remnant of the old - * Probe layout, and will be moved to PreInit. - */ - pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); - pATI->PCIInfo = xf86GetPciInfoForEntity(pEnt->index); - - pATI->Chip = Mach64ChipsetRevisions(pEnt->chipset, pATI->PCIInfo->chipRev); - pATI->Chipset = ATI_CHIPSET_MACH64; - - pATI->SharedAccelerator = TRUE; - - /* 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 */ - } - - pScrn->resourceType = MEM_IO; - xf86EnableAccess(pScrn); - - if (!ATIMach64Probe(pATI)) { - xf86Msg(X_WARNING, ATI_NAME - ": Mach64 at %02x:%02x:%01x could not be detected!\n", - pATI->PCIInfo->bus, pATI->PCIInfo->device, - pATI->PCIInfo->func); - xfree(pATI); - continue; - } - - xf86MsgVerb(X_INFO, 3, ATI_NAME - ": Mach64 detected at %02x:%02x:%01x.\n", - pATI->PCIInfo->bus, pATI->PCIInfo->device, - pATI->PCIInfo->func); - - pScrn->driverPrivate = pATI; - - pScrn->driverVersion = ATI_VERSION_CURRENT; - pScrn->driverName = ATI_DRIVER_NAME; - pScrn->name = ATI_NAME; - pScrn->Probe = ATIProbe; - pScrn->PreInit = ATIPreInit; - pScrn->ScreenInit = ATIScreenInit; - pScrn->SwitchMode = ATISwitchMode; - pScrn->AdjustFrame = ATIAdjustFrame; - pScrn->EnterVT = ATIEnterVT; - pScrn->LeaveVT = ATILeaveVT; - pScrn->FreeScreen = ATIFreeScreen; - pScrn->ValidMode = ATIValidMode; - - ProbeSuccess = TRUE; - } - } - - return ProbeSuccess; -} diff --git a/src/atiprobe.h b/src/atiprobe.h deleted file mode 100644 index cb4d9d6..0000000 --- a/src/atiprobe.h +++ /dev/null @@ -1,31 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.h,v 1.8 2003/01/01 19:16:33 tsi Exp $ */ -/* - * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of Marc Aurele La France not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. Marc Aurele La France makes no representations - * about the suitability of this software for any purpose. It is provided - * "as-is" without express or implied warranty. - * - * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO - * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef ___ATIPROBE_H___ -#define ___ATIPROBE_H___ 1 - -#include "xf86str.h" - -extern Bool ATIProbe(DriverPtr, int); - -#endif /* ___ATIPROBE_H___ */ |