summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2006-03-16 01:19:38 +0000
committerLuc Verhaegen <libv@skynet.be>2006-03-16 01:19:38 +0000
commitd1eda1600b1b5da2c26dc4a0cc0ff44a4394d8fc (patch)
treef9f5949a7854f73a74f53b073cd054c6616b309b
parentd7376c949e63b07e67a2ef625485a73ff000c064 (diff)
Move the CPIO pci poking to a seperate function. Allocate pATI in ATIProbe
instead of the ATIMach64Probes. Shuffle some more code about surrounding this.
-rw-r--r--ChangeLog9
-rw-r--r--src/atiprobe.c199
2 files changed, 89 insertions, 119 deletions
diff --git a/ChangeLog b/ChangeLog
index f51daaf..b0a7d24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-03-16 Luc Verhaegen <libv@skynet.be>
+
+ * src/atiprobe.c: (Mach64CPIOGetIOBase), (ATIMach64Detect),
+ (ATIMach64Probe), (ATIProbe):
+
+ Move the CPIO pci poking to a seperate function.
+ 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>
* src/atiprobe.c: (ATIMach64Detect), (ATIMach64Probe), (ATIProbe):
diff --git a/src/atiprobe.c b/src/atiprobe.c
index 658fbd0..99c74ad 100644
--- a/src/atiprobe.c
+++ b/src/atiprobe.c
@@ -65,6 +65,40 @@ typedef struct _ATIGDev
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 --
*
@@ -72,7 +106,7 @@ typedef struct _ATIGDev
* address.
*/
static Bool
-ATIMach64Detect(ATIPtr pATI, const CARD16 ChipType, const ATIChipType Chip)
+ATIMach64Detect(ATIPtr pATI)
{
CARD32 IOValue, bus_cntl, gen_test_cntl;
@@ -90,11 +124,11 @@ ATIMach64Detect(ATIPtr pATI, const CARD16 ChipType, const ATIChipType Chip)
/* Make sure any Mach64 is not in some weird state */
bus_cntl = inr(BUS_CNTL);
- if (Chip < ATI_CHIP_264VTB)
+ 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 (Chip < ATI_CHIP_264VT4)
+ 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);
@@ -119,7 +153,7 @@ ATIMach64Detect(ATIPtr pATI, const CARD16 ChipType, const ATIChipType Chip)
* not be producing any more adapters that do not register
* themselves in PCI configuration space.
*/
- ATIMach64ChipID(pATI, ChipType);
+ ATIMach64ChipID(pATI, pATI->PCIInfo->chipType);
if ((pATI->Chip != ATI_CHIP_Mach64) || (pATI->CPIODecoding == BLOCK_IO))
pATI->Adapter = ATI_ADAPTER_MACH64;
}
@@ -137,7 +171,6 @@ ATIMach64Detect(ATIPtr pATI, const CARD16 ChipType, const ATIChipType Chip)
}
ATIUnmapApertures(-1, pATI);
- pATI->PCIInfo = NULL;
return TRUE;
}
@@ -149,15 +182,10 @@ ATIMach64Detect(ATIPtr pATI, const CARD16 ChipType, const ATIChipType Chip)
* This function looks for a Mach64 at a particular MMIO address and returns an
* ATIRec if one is found.
*/
-static ATIPtr
-ATIMach64Probe(pciVideoPtr pVideo, const IOADDRESS IOBase,
- const CARD8 IODecoding, const ATIChipType Chip)
+static Bool
+ATIMach64Probe(ATIPtr pATI)
{
- ATIPtr pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec));
-
- pATI->CPIOBase = IOBase;
- pATI->CPIODecoding = IODecoding;
- pATI->PCIInfo = pVideo;
+ pciVideoPtr pVideo = pATI->PCIInfo;
/*
* Probe through auxiliary MMIO aperture if one exists. Because such
@@ -168,7 +196,7 @@ ATIMach64Probe(pciVideoPtr pVideo, const IOADDRESS IOBase,
(pATI->Block0Base = pVideo->memBase[2]) &&
(pATI->Block0Base < (CARD32)(-1 << pVideo->size[2]))) {
pATI->Block0Base += 0x00000400U;
- goto LastProbe;
+ return ATIMach64Detect(pATI);
}
/*
@@ -177,12 +205,12 @@ ATIMach64Probe(pciVideoPtr pVideo, const IOADDRESS IOBase,
*/
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;
+ if ((pVideo->size[0] >= 23) && ATIMach64Detect(pATI))
+ return TRUE;
pATI->Block0Base -= 0x00400000U;
- if (ATIMach64Detect(pATI, pVideo->chipType, Chip))
- return pATI;
+ if (ATIMach64Detect(pATI))
+ return TRUE;
}
/*
@@ -191,13 +219,7 @@ ATIMach64Probe(pciVideoPtr pVideo, const IOADDRESS IOBase,
* driver should be used instead (barring OS issues).
*/
pATI->Block0Base = 0x000BFC00U;
-
-LastProbe:
- if (ATIMach64Detect(pATI, pVideo->chipType, Chip))
- return pATI;
-
- xfree(pATI);
- return NULL;
+ return ATIMach64Detect(pATI);
}
#else /* AVOID_CPIO */
@@ -208,29 +230,19 @@ LastProbe:
* This function looks for a Mach64 at a particular PIO address and returns an
* ATIRec if one is found.
*/
-static ATIPtr
-ATIMach64Probe(pciVideoPtr pVideo, const IOADDRESS IOBase,
- const CARD8 IODecoding, const ATIChipType Chip)
+static Bool
+ATIMach64Probe(ATIPtr pATI)
{
- ATIPtr pATI;
-
- if (!IOBase)
- return NULL;
+ if (!pATI->CPIOBase)
+ return FALSE;
- if ((IODecoding == BLOCK_IO) &&
- ((pVideo->size[1] < 8) ||
- (IOBase >= (CARD32)(-1 << pVideo->size[1]))))
- return NULL;
+ if ((pATI->CPIODecoding == BLOCK_IO) &&
+ ((pATI->PCIInfo->size[1] < 8) ||
+ (pATI->CPIOBase >= (CARD32)(-1 << pATI->PCIInfo->size[1]))))
+ return FALSE;
- pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec));
- pATI->CPIOBase = IOBase;
- pATI->CPIODecoding = IODecoding;
- pATI->PCIInfo = pVideo;
-
- if (!ATIMach64Detect(pATI, pVideo->chipType, Chip)) {
- xfree(pATI);
- return NULL;
- }
+ if (!ATIMach64Detect(pATI))
+ return FALSE;
/*
* Determine VGA capability. VGA can always be enabled on integrated
@@ -262,7 +274,7 @@ ATIMach64Probe(pciVideoPtr pVideo, const IOADDRESS IOBase,
outb(GENENA, 0x0EU);
}
- return pATI;
+ return TRUE;
}
#endif /* AVOID_CPIO */
@@ -279,33 +291,18 @@ ATIProbe(DriverPtr pDriver, int flags)
ATIPtr pATI, *ATIPtrs = NULL;
GDevPtr pGDev;
pciVideoPtr pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo();
- pciConfigPtr pPCI;
ATIGDev *ATIGDevs = NULL, *pATIGDev;
ScrnInfoPtr pScreenInfo;
- CARD32 PciReg;
Bool ProbeSuccess = FALSE;
int i, j, k;
int nATIGDev = -1, nATIPtr = 0;
int Chipset;
ATIChipType Chip;
-#ifndef AVOID_CPIO
- static const IOADDRESS Mach64SparseIOBases[] = {0x02ECU, 0x01CCU, 0x01C8U};
-#endif /* AVOID_CPIO */
-
/* We only do PCI from now on. */
if (!xf86PciVideoInfo)
return FALSE;
-# define AddAdapter(_p) \
- do \
- { \
- nATIPtr++; \
- ATIPtrs = (ATIPtr *)xnfrealloc(ATIPtrs, SizeOf(ATIPtr) * nATIPtr); \
- ATIPtrs[nATIPtr - 1] = (_p); \
- (_p)->iEntity = -2; \
- } while (0)
-
for (i = 0; xf86PciVideoInfo[i]; i++) {
pVideo = xf86PciVideoInfo[i];
@@ -320,80 +317,44 @@ ATIProbe(DriverPtr pDriver, int flags)
if ((Chip < ATI_CHIP_88800GXC) || (Chip > ATI_CHIP_Mach64))
continue;
- /* Check if this one has already been detected */
- for (j = 0; j < nATIPtr; j++) {
- pATI = ATIPtrs[j];
+ pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec));
+ pATI->PCIInfo = pVideo;
- /* Block IO? */
- if ((pVideo->size[1]) && (pATI->CPIOBase == pVideo->ioBase[1])) {
- pATI->PCIInfo = pVideo;
- goto SkipThisSlot;
- }
-
- if (pATI->PCIInfo == pVideo)
- goto SkipThisSlot;
- }
+ pATI->Chip = Chip;
- xf86SetPciVideo(pVideo, MEM_IO);
-
/* block IO? */
if (pVideo->size[1]) {
- pATI = ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip);
- if (pATI)
- xf86MsgVerb(X_INFO, 3, ATI_NAME ": Mach64 detected at %d:%d:%d.\n",
- pVideo->bus, pVideo->device, pVideo->func);
- } else {
+ pATI->CPIOBase = pVideo->ioBase[1];
+ pATI->CPIODecoding = BLOCK_IO;
+ } else { /* sparse IO */
+ pATI->CPIODecoding = SPARSE_IO;
#ifndef AVOID_CPIO
- pPCI = pVideo->thisCard;
- if (pPCI == NULL)
- continue;
-
- PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG);
- j = PciReg & 0x03U;
- if (j == 0x03U) {
- xf86Msg(X_WARNING,
- ATI_NAME ": Mach64 at %d:%d:%d cannot be"
- " enabled\n because it has neither a block, nor a"
- " sparse, I/O base.\n",
- pVideo->bus, pVideo->device, pVideo->func);
- continue;
- }
-
- /* Possibly fix block I/O indicator */
- if (PciReg & 0x00000004U)
- pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, PciReg & ~0x00000004U);
-
- pATI = ATIMach64Probe(pVideo, Mach64SparseIOBases[j], SPARSE_IO, Chip);
- if (pATI)
- xf86MsgVerb(X_INFO, 3, ATI_NAME ": Mach64 detected at %d:%d:%d"
- " with sparse PIO base 0x%04lX detected.\n",
- pVideo->bus, pVideo->device, pVideo->func,
- Mach64SparseIOBases[j]);
+ pATI->CPIOBase =
+ Mach64CPIOGetIOBase(((pciConfigPtr) pVideo->thisCard)->tag);
#else
- /* The adapter's CPIO base is of little concern here */
- pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip);
- if (pATI)
- xf86MsgVerb(X_INFO, 3, ATI_NAME ": Mach64 detected at %d:%d:%d"
- " with Block 0 base 0x%08lX detected.\n",
- pVideo->bus, pVideo->device, pVideo->func,
- pATI->Block0Base);
+ pATI->CPIOBase = 0;
#endif /* AVOID_CPIO */
}
- if (!pATI) {
+ xf86SetPciVideo(pVideo, MEM_IO);
+ if (!ATIMach64Probe(pATI)) {
xf86Msg(X_WARNING, ATI_NAME ": Mach64 at %d:%d:%d could not be"
" detected!\n", pVideo->bus, pVideo->device, pVideo->func);
+ xfree(pATI);
} else {
- AddAdapter(pATI);
-
+ xf86MsgVerb(X_INFO, 3, ATI_NAME ": Mach64 detected at %d:%d:%d.\n",
+ pVideo->bus, pVideo->device, pVideo->func);
+
pATI->SharedAccelerator = TRUE;
- pATI->PCIInfo = pVideo;
+
+ /* add to our little list */
+ nATIPtr++;
+ ATIPtrs = (ATIPtr *)xnfrealloc(ATIPtrs, SizeOf(ATIPtr) * nATIPtr);
+ ATIPtrs[nATIPtr - 1] = pATI;
+ pATI->iEntity = -2;
}
-
xf86SetPciVideo(NULL, NONE);
-
- SkipThisSlot:;
}
/*