diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/atiprobe.c | 479 |
2 files changed, 188 insertions, 298 deletions
@@ -1,5 +1,12 @@ 2006-03-16 Luc Verhaegen <libv@skynet.be> + * src/atiprobe.c: (Mach64ChipsetRevisions), (ATIProbe): + + Add proper PciChipsets, add SymTabRec with all Mach64 names. + Move whole of probe over to standard xf86MatchPciInstances. + +2006-03-16 Luc Verhaegen <libv@skynet.be> + * src/atiprobe.c: (Mach64CPIOGetIOBase), (ATIMach64Detect), (ATIMach64Probe), (ATIProbe): diff --git a/src/atiprobe.c b/src/atiprobe.c index 99c74ad..1b7d872 100644 --- a/src/atiprobe.c +++ b/src/atiprobe.c @@ -279,6 +279,108 @@ ATIMach64Probe(ATIPtr pATI) #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 -- * @@ -288,328 +390,109 @@ ATIMach64Probe(ATIPtr pATI) Bool ATIProbe(DriverPtr pDriver, int flags) { - ATIPtr pATI, *ATIPtrs = NULL; - GDevPtr pGDev; - pciVideoPtr pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo(); - ATIGDev *ATIGDevs = NULL, *pATIGDev; - ScrnInfoPtr pScreenInfo; - Bool ProbeSuccess = FALSE; - int i, j, k; - int nATIGDev = -1, nATIPtr = 0; - int Chipset; - ATIChipType Chip; - - /* We only do PCI from now on. */ - if (!xf86PciVideoInfo) - return FALSE; - - for (i = 0; xf86PciVideoInfo[i]; i++) { - pVideo = xf86PciVideoInfo[i]; - - if (!xf86CheckPciSlot(pVideo->bus, pVideo->device, pVideo->func)) - continue; - - if (pVideo->vendor != PCI_VENDOR_ATI) - continue; - - /* Is this a mach64? */ - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - if ((Chip < ATI_CHIP_88800GXC) || (Chip > ATI_CHIP_Mach64)) - continue; + GDevPtr *devSections; + int *usedChips; + int numDevSections; + int numUsed; + Bool ProbeSuccess = FALSE; - pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec)); - pATI->PCIInfo = pVideo; - - pATI->Chip = Chip; - - /* block IO? */ - if (pVideo->size[1]) { - pATI->CPIOBase = pVideo->ioBase[1]; - pATI->CPIODecoding = BLOCK_IO; - } else { /* sparse IO */ - pATI->CPIODecoding = SPARSE_IO; + if ((numDevSections = xf86MatchDevice(ATI_DRIVER_NAME, &devSections)) <= 0) + return FALSE; -#ifndef AVOID_CPIO - pATI->CPIOBase = - Mach64CPIOGetIOBase(((pciConfigPtr) pVideo->thisCard)->tag); -#else - pATI->CPIOBase = 0; -#endif /* AVOID_CPIO */ - } + if (xf86GetPciVideoInfo() == NULL) + return FALSE; - 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 { - xf86MsgVerb(X_INFO, 3, ATI_NAME ": Mach64 detected at %d:%d:%d.\n", - pVideo->bus, pVideo->device, pVideo->func); + numUsed = xf86MatchPciInstances(ATI_DRIVER_NAME, PCI_VENDOR_ATI, + Mach64Chipsets, Mach64PciChipsets, + devSections, numDevSections, + pDriver, &usedChips); + xfree(devSections); - pATI->SharedAccelerator = TRUE; + if (numUsed <= 0) + return FALSE; - /* add to our little list */ - nATIPtr++; - ATIPtrs = (ATIPtr *)xnfrealloc(ATIPtrs, SizeOf(ATIPtr) * nATIPtr); - ATIPtrs[nATIPtr - 1] = pATI; - pATI->iEntity = -2; - } - xf86SetPciVideo(NULL, NONE); - } + if (flags & PROBE_DETECT) { + if (numUsed > 0) + ProbeSuccess = TRUE; + } else { + int i; - /* - * Re-order list of detected devices so that the primary device is before - * any other PCI device. - */ - for (i = 0; i < nATIPtr; i++) { - if (!ATIPtrs[i]->PCIInfo) - continue; + for (i = 0; i < numUsed; i++) { + EntityInfoPtr pEnt; + ATIPtr pATI; + ScrnInfoPtr pScrn; + + pScrn = xf86ConfigPciEntity(NULL, 0, usedChips[i], Mach64PciChipsets, + 0, 0, 0, 0, NULL); - for (j = i; j < nATIPtr; j++) { - pATI = ATIPtrs[j]; - if (!xf86IsPrimaryPci(pATI->PCIInfo)) + if (!pScrn) continue; - for (; j > i; j--) - ATIPtrs[j] = ATIPtrs[j - 1]; - ATIPtrs[j] = pATI; - break; - } - - break; - } + pEnt = xf86GetEntityInfo(usedChips[i]); - if (flags & PROBE_DETECT) - { - /* - * No XF86Config information available, so use the default Chipset of - * "ati", and as many device sections as there are adapters. - */ - for (i = 0; i < nATIPtr; i++) - { - pATI = ATIPtrs[i]; - - 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); - } - } - else - { - GDevPtr *GDevs; - int nGDev; - - /* - * Get a list of XF86Config device sections whose "Driver" is either - * not specified, or specified as this driver. From this list, - * eliminate those device sections that specify a "Chipset" or a - * "ChipID" not recognised by the driver. Those device sections that - * specify a "ChipRev" without a "ChipID" are also weeded out. - */ - nATIGDev = 0; - if ((nGDev = xf86MatchDevice(ATI_NAME, &GDevs)) > 0) - { - ATIGDevs = (ATIGDevPtr)xnfcalloc(nGDev, SizeOf(ATIGDev)); - - for (i = 0, pATIGDev = ATIGDevs; i < nGDev; i++) - { - pGDev = GDevs[i]; - Chipset = ATIIdentProbe(pGDev->chipset); - if (Chipset == -1) - continue; - - if ((pGDev->chipID > (int)((CARD16)(-1))) || - (pGDev->chipRev > (int)((CARD8)(-1)))) - continue; - - if (pGDev->chipID >= 0) - { - if (ATIChipID(pGDev->chipID, 0) == ATI_CHIP_Mach64) - continue; - } - else - { - if (pGDev->chipRev >= 0) - continue; - } - - pATIGDev->pGDev = pGDev; - pATIGDev->Chipset = Chipset; - nATIGDev++; - pATIGDev++; - - xf86MsgVerb(X_INFO, 3, - ATI_NAME ": Candidate \"Device\" section \"%s\".\n", - pGDev->identifier); - } + /* + * 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); - xfree(GDevs); + pATI->Chip = Mach64ChipsetRevisions(pEnt->chipset, pATI->PCIInfo->chipRev); + pATI->Chipset = ATI_CHIPSET_MACH64; - if (!nATIGDev) - { - xfree(ATIGDevs); - ATIGDevs = NULL; - } - } + 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; - /* - * Assign detected devices to XF86Config Device sections. This is done - * by comparing certain Device section specifications against the - * corresponding adapter information. Begin with those specifications - * that are independent of the adapter's bus location. - */ - for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) - { - pGDev = pATIGDev->pGDev; - - for (j = 0; j < nATIPtr; j++) { - pATI = ATIPtrs[j]; - pVideo = pATI->PCIInfo; - - if (!pVideo) - continue; - - /* Check chipset name if exists */ - if (pGDev->chipset && strncasecmp(pGDev->chipset, "mach64", 7)) - continue; - - /* Is this the right busID? */ - if (pGDev->busID && pGDev->busID[0]) - if (!xf86ComparePciBusString(pGDev->busID, pVideo->bus, - pVideo->device, pVideo->func)) - continue; - - /* - * Ensure no two adapters are assigned to the same XF86Config - * Device section. - */ - if (pATIGDev->iATIPtr) - { - if (pATIGDev->iATIPtr < 0) - break; - - xf86Msg(X_ERROR, - ATI_NAME ": XF86Config Device section \"%s\" may not" - " be assigned to more than one adapter.\n", - pGDev->identifier); - pATIGDev->iATIPtr = -1; - break; - } - - /* Assign adapter */ - pATIGDev->iATIPtr = j + 1; - - /* - * For compatibility with previous releases, assign the first - * applicable adapter if there is only one Device section. - */ - if (nATIGDev == 1) - break; +#ifndef AVOID_CPIO + pATI->CPIOBase = + Mach64CPIOGetIOBase(((pciConfigPtr) + pATI->PCIInfo->thisCard)->tag); +#else + pATI->CPIOBase = 0; +#endif /* AVOID_CPIO */ } - } - /* - * Ensure no two XF86Config Device sections are assigned to the same - * adapter. Then, generate screens for any that are left. - */ - for (i = 0, pATIGDev = ATIGDevs; i < nATIGDev; i++, pATIGDev++) - { - pGDev = pATIGDev->pGDev; + pScrn->resourceType = MEM_IO; + xf86EnableAccess(pScrn); - j = pATIGDev->iATIPtr; - if (j <= 0) + 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; - - for (k = i; ++k < nATIGDev; ) { - if (j == ATIGDevs[k].iATIPtr) { - xf86Msg(X_ERROR, ATI_NAME ": XF86Config Device sections " - "\"%s\" and \"%s\" may not be assigned to the same " - "adapter.\n", pGDev->identifier, - ATIGDevs[k].pGDev->identifier); - pATIGDev->iATIPtr = ATIGDevs[k].iATIPtr = -1; - } } - j = ATIGDevs[i].iATIPtr; - if (j <= 0) - continue; - - pATI = ATIPtrs[j - 1]; - - if (!pATI->PCIInfo) - continue; - pVideo = pATI->PCIInfo; - - xf86MsgVerb(X_INFO, 3, ATI_NAME ": Mach64 at %d:%d:%d assigned to " - "%sactive \"Device\" section \"%s\".\n", pVideo->bus, - pVideo->device, pVideo->func, - pGDev->active ? "" : "in", pGDev->identifier); - - /* - * Attach adapter to XF86Config Device section and register its - * resources. - */ - pATI->iEntity = xf86ClaimPciSlot(pVideo->bus, pVideo->device, - pVideo->func, pDriver, - pATIGDev->Chipset, pGDev, - pGDev->active); - - if (pATI->iEntity < 0) { - xf86Msg(X_ERROR, - ATI_NAME ": Could not claim bus slot for %d:%d:%d.\n", - pVideo->bus, pVideo->device, pVideo->func); - continue; - } else - ATIClaimResources(pATI, pGDev->active); - - if (!pGDev->active) - continue; - - /* Allocate screen */ - pScreenInfo = xf86AllocateScreen(pDriver, 0); - - /* Attach device to screen */ - xf86AddEntityToScreen(pScreenInfo, pATI->iEntity); - - ATIPtrs[j - 1] = NULL; - - /* Fill in probe data */ - pScreenInfo->driverVersion = ATI_VERSION_CURRENT; - pScreenInfo->driverName = ATI_DRIVER_NAME; - pScreenInfo->name = ATI_NAME; - pScreenInfo->Probe = ATIProbe; - pScreenInfo->PreInit = ATIPreInit; - pScreenInfo->ScreenInit = ATIScreenInit; - pScreenInfo->SwitchMode = ATISwitchMode; - pScreenInfo->AdjustFrame = ATIAdjustFrame; - pScreenInfo->EnterVT = ATIEnterVT; - pScreenInfo->LeaveVT = ATILeaveVT; - pScreenInfo->FreeScreen = ATIFreeScreen; - pScreenInfo->ValidMode = ATIValidMode; - - pScreenInfo->driverPrivate = pATI; - - pATI->Chipset = pATIGDev->Chipset; + xf86MsgVerb(X_INFO, 3, ATI_NAME + ": Mach64 detected at %02x:%02x:%01x.\n", + pATI->PCIInfo->bus, pATI->PCIInfo->device, + pATI->PCIInfo->func); + + Scrn->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; } - - /* ignore unassigned adapters */ - - xfree(ATIGDevs); } - xfree(ATIPtrs); - return ProbeSuccess; } |