commit 7bbe9fae73297f2976a21a4c95b998b959f04a5d Author: George Sapountzis Date: Tue Mar 13 20:35:19 2007 +0200 [mach64] Convert driver to the new PCI interfaces. diff --git a/configure.ac b/configure.ac index 16b93e1..5c4e7fb 100644 --- a/configure.ac +++ b/configure.ac @@ -204,6 +204,9 @@ CPPFLAGS="$SAVE_CPPFLAGS" AM_CONDITIONAL(USE_EXA, test "x$USE_EXA" = xyes) +PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0]) +XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" + AC_SUBST([XORG_CFLAGS]) AC_SUBST([DRI_CFLAGS]) AC_SUBST([moduledir]) diff --git a/src/ati.c b/src/ati.c index bf97197..00e3dfb 100644 --- a/src/ati.c +++ b/src/ati.c @@ -57,6 +57,8 @@ #include "config.h" #endif +#include + #include "ati.h" #include "atichip.h" #include "ativersion.h" @@ -67,6 +69,52 @@ #include "r128_probe.h" #include "r128_version.h" +#define ATI_DEVICE_MATCH(d, i) \ + { PCI_VENDOR_ATI, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) } + +static const struct pci_id_match +ati_device_match[] = { + /* Mach64 */ + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GX, ATI_CHIP_88800GX), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64CX, ATI_CHIP_88800CX), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64CT, ATI_CHIP_264CT), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64ET, ATI_CHIP_264ET), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64VT, ATI_CHIP_264VT), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GT, ATI_CHIP_264GT), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64VU, ATI_CHIP_264VT3), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GU, ATI_CHIP_264GTDVD), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64LG, ATI_CHIP_264LT), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64VV, ATI_CHIP_264VT4), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GV, ATI_CHIP_264GT2C), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GW, ATI_CHIP_264GT2C), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GY, ATI_CHIP_264GT2C), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GZ, ATI_CHIP_264GT2C), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GB, ATI_CHIP_264GTPRO), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GD, ATI_CHIP_264GTPRO), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GI, ATI_CHIP_264GTPRO), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GP, ATI_CHIP_264GTPRO), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GQ, ATI_CHIP_264GTPRO), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64LB, ATI_CHIP_264LTPRO), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64LD, ATI_CHIP_264LTPRO), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64LI, ATI_CHIP_264LTPRO), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64LP, ATI_CHIP_264LTPRO), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64LQ, ATI_CHIP_264LTPRO), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GL, ATI_CHIP_264XL), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GM, ATI_CHIP_264XL), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GN, ATI_CHIP_264XL), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GO, ATI_CHIP_264XL), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GR, ATI_CHIP_264XL), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64GS, ATI_CHIP_264XL), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64LM, ATI_CHIP_MOBILITY), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64LN, ATI_CHIP_MOBILITY), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64LR, ATI_CHIP_MOBILITY), + ATI_DEVICE_MATCH(PCI_CHIP_MACH64LS, ATI_CHIP_MOBILITY), + + /* FIXME: fill in r128 and radeon pciid's here */ + + {0, 0, 0} +}; + /* * ATIIdentify -- * @@ -91,63 +139,33 @@ ATIIdentify * do a minimal probe for supported hardware. */ static Bool -ATIProbe -( - DriverPtr pDriver, - int flags -) +ATIPciProbe(DriverPtr pDriver, int entity_num, struct pci_device *dev, + intptr_t match_data) { - pciVideoPtr pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo(); Bool ProbeSuccess = FALSE; Bool DoMach64 = FALSE; Bool DoRage128 = FALSE, DoRadeon = FALSE; - int i; ATIChipType Chip; - if (!(flags & PROBE_DETECT)) - { - if (xf86MatchDevice(ATI_NAME, NULL) > 0) - DoMach64 = TRUE; - if (xf86MatchDevice(R128_NAME, NULL) > 0) - DoRage128 = TRUE; - if (xf86MatchDevice(RADEON_NAME, NULL) > 0) - DoRadeon = TRUE; - } - - if (xf86PciVideoInfo) - { - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) - { - if ((pVideo->vendor != PCI_VENDOR_ATI) || - (pVideo->chipType == PCI_CHIP_MACH32)) - continue; - - /* Check for Rage128's, Radeon's and later adapters */ - Chip = ATIChipID(pVideo->chipType, pVideo->chipRev); - if (Chip > ATI_CHIP_Mach64) - { - if (Chip <= ATI_CHIP_Rage128) - DoRage128 = TRUE; - else if (Chip <= ATI_CHIP_Radeon) - DoRadeon = TRUE; - - continue; - } - - DoMach64 = TRUE; - } - } + Chip = ATIChipID(dev->device_id, dev->revision); + + if (Chip <= ATI_CHIP_Mach64) + DoMach64 = TRUE; + else if (Chip <= ATI_CHIP_Rage128) + DoRage128 = TRUE; + else if (Chip <= ATI_CHIP_Radeon) + DoRadeon = TRUE; /* Call Mach64 driver probe */ - if (DoMach64 && Mach64Probe(pDriver, flags)) + if (DoMach64 && Mach64PciProbe(pDriver, entity_num, dev, match_data)) ProbeSuccess = TRUE; /* Call Rage 128 driver probe */ - if (DoRage128 && R128Probe(pDriver, flags)) + if (DoRage128 && R128PciProbe(pDriver, entity_num, dev, match_data)) ProbeSuccess = TRUE; /* Call Radeon driver probe */ - if (DoRadeon && RADEONProbe(pDriver, flags)) + if (DoRadeon && RADEONPciProbe(pDriver, entity_num, dev, match_data)) ProbeSuccess = TRUE; return ProbeSuccess; @@ -182,9 +200,12 @@ _X_EXPORT DriverRec ATI = ATI_VERSION_CURRENT, "ati", ATIIdentify, - ATIProbe, + NULL, ATIAvailableOptions, NULL, 0, - NULL + NULL, + + ati_device_match, + ATIPciProbe }; diff --git a/src/atidri.c b/src/atidri.c index 83cb25f..d43bc94 100644 --- a/src/atidri.c +++ b/src/atidri.c @@ -774,8 +774,8 @@ static Bool ATIDRISetAgpMode( ScreenPtr pScreen ) xf86DrvMsg( pScreen->myNum, X_INFO, "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", mode, vendor, device, - pATI->PCIInfo->vendor, - pATI->PCIInfo->chipType ); + pATI->PCIInfo->vendor_id, + pATI->PCIInfo->device_id ); if ( drmAgpEnable( pATI->drmFD, mode ) < 0 ) { xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n" ); @@ -1134,18 +1134,17 @@ static Bool ATIDRIIrqInit( ScreenPtr pScreen ) if ( pATI->irq <= 0 ) { pATI->irq = drmGetInterruptFromBusID(pATI->drmFD, - ((pciConfigPtr)pATI->PCIInfo - ->thisCard)->busnum, - ((pciConfigPtr)pATI->PCIInfo - ->thisCard)->devnum, - ((pciConfigPtr)pATI->PCIInfo - ->thisCard)->funcnum); + ((pATI->PCIInfo->domain << 8) | + pATI->PCIInfo->bus), + pATI->PCIInfo->dev, + pATI->PCIInfo->func); if ( pATI->irq <= 0 ) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "[drm] Couldn't find IRQ for bus id %d:%d:%d\n", - ((pciConfigPtr)pATI->PCIInfo->thisCard)->busnum, - ((pciConfigPtr)pATI->PCIInfo->thisCard)->devnum, - ((pciConfigPtr)pATI->PCIInfo->thisCard)->funcnum); + ((pATI->PCIInfo->domain << 8) | + pATI->PCIInfo->bus), + pATI->PCIInfo->dev, + pATI->PCIInfo->func); pATI->irq = 0; } else if ((drmCtlInstHandler(pATI->drmFD, pATI->irq)) != 0) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, @@ -1244,7 +1243,7 @@ Bool ATIDRIScreenInit( ScreenPtr pScreen ) sprintf( pDRIInfo->busIdString, "PCI:%d:%d:%d", pATI->PCIInfo->bus, - pATI->PCIInfo->device, + pATI->PCIInfo->dev, pATI->PCIInfo->func ); } pDRIInfo->ddxDriverMajorVersion = ATI_VERSION_MAJOR; diff --git a/src/atimach64probe.c b/src/atimach64probe.c index 4d7a06a..2c59a5d 100644 --- a/src/atimach64probe.c +++ b/src/atimach64probe.c @@ -33,74 +33,6 @@ #include "atioption.h" #include "ativersion.h" -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} -}; - const OptionInfoRec * Mach64AvailableOptions(int chipid, int busid) { @@ -118,48 +50,20 @@ Mach64AvailableOptions(int chipid, int busid) * do a minimal probe for supported hardware. */ Bool -Mach64Probe(DriverPtr pDriver, int flags) +Mach64PciProbe(DriverPtr pDriver, int entity_num, struct pci_device *dev, + intptr_t match_data) { - 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); + ScrnInfoPtr pScrn; - if (numUsed <= 0) + if ((match_data < ATI_CHIP_88800GX) || + (match_data > ATI_CHIP_MOBILITY)) return FALSE; - if (flags & PROBE_DETECT) { - ProbeSuccess = TRUE; - } else { - int i; - - for (i = 0; i < numUsed; i++) { - ScrnInfoPtr pScrn; - EntityInfoPtr pEnt; - pciVideoPtr pVideo; - - pScrn = xf86ConfigPciEntity(NULL, 0, usedChips[i], - NULL, RES_SHARED_VGA, - NULL, NULL, NULL, NULL); + pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL, RES_SHARED_VGA, + NULL, NULL, NULL, NULL); - if (!pScrn) - continue; - - pEnt = xf86GetEntityInfo(usedChips[i]); - pVideo = xf86GetPciInfoForEntity(usedChips[i]); + if (pScrn != NULL) + { #ifdef XFree86LOADER @@ -168,7 +72,7 @@ Mach64Probe(DriverPtr pDriver, int flags) xf86Msg(X_ERROR, ATI_NAME ": Failed to load \"atimisc\" module.\n"); xf86DeleteScreen(pScrn->scrnIndex, 0); - continue; + return FALSE; } xf86LoaderReqSymLists(ATISymbols, NULL); @@ -176,12 +80,7 @@ Mach64Probe(DriverPtr pDriver, int flags) #endif ATIFillInScreenInfo(pScrn); - - pScrn->Probe = Mach64Probe; - - ProbeSuccess = TRUE; - } } - return ProbeSuccess; + return (pScrn != NULL); } diff --git a/src/atimach64probe.h b/src/atimach64probe.h index 4e474ca..dc67308 100644 --- a/src/atimach64probe.h +++ b/src/atimach64probe.h @@ -26,6 +26,7 @@ #include "xf86str.h" extern const OptionInfoRec * Mach64AvailableOptions(int, int); -extern Bool Mach64Probe(DriverPtr, int); +extern Bool Mach64PciProbe(DriverPtr, int, struct pci_device *, + intptr_t); #endif /* ___ATIMACH64PROBE_H___ */ diff --git a/src/atipreinit.c b/src/atipreinit.c index 0e5b48c..ef81442 100644 --- a/src/atipreinit.c +++ b/src/atipreinit.c @@ -1770,9 +1770,9 @@ ATIPreInit int AcceleratorVideoRAM = 0, ServerVideoRAM; /* Set MMIO address from PCI configuration space, if available */ - if ((pATI->Block0Base = pVideo->memBase[2])) + if ((pATI->Block0Base = pVideo->regions[2].base_addr)) { - if (pATI->Block0Base >= (CARD32)(-1 << pVideo->size[2])) + if (pATI->Block0Base >= ~(CARD32)(pVideo->regions[2].size - 1)) pATI->Block0Base = 0; else pATI->Block0Base += 0x0400U; diff --git a/src/atiprint.c b/src/atiprint.c index d435e21..349ac25 100644 --- a/src/atiprint.c +++ b/src/atiprint.c @@ -356,7 +356,6 @@ ATIPrintRegisters ) { pciVideoPtr pVideo = pATI->PCIInfo; - pciConfigPtr pPCI = pVideo->thisCard; int Index; CARD32 lcd_index, tv_out_index, lcd_gen_ctrl; CARD8 dac_read, dac_mask, dac_write; @@ -642,10 +641,12 @@ ATIPrintRegisters xf86ErrorFVerb(4, "\n\n PCI configuration register values:"); for (Index = 0; Index < 256; Index+= 4) { + uint32_t data; + pci_device_cfg_read_u32(pVideo, &data, Index); + if (!(Index & 15)) xf86ErrorFVerb(4, "\n 0x%02X: ", Index); - xf86ErrorFVerb(4, " 0x%08lX", - (unsigned long)pciReadLong(pPCI->tag, Index)); + xf86ErrorFVerb(4, " 0x%08X", data); } } diff --git a/src/atiprobe.c b/src/atiprobe.c index dcbcd27..3519f1d 100644 --- a/src/atiprobe.c +++ b/src/atiprobe.c @@ -215,16 +215,16 @@ ATIMach64Probe const ATIChipType Chip ) { - CARD16 ChipType = pVideo->chipType; + CARD16 ChipType = pVideo->device_id; /* * 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]))) + if ((pVideo->regions[2].size >= (1 << 12)) && + (pATI->Block0Base = pVideo->regions[2].base_addr) && + (pATI->Block0Base < ~(CARD32)(pVideo->regions[2].size - 1))) { pATI->Block0Base += 0x00000400U; if (ATIMach64Detect(pATI, ChipType, Chip)) @@ -237,13 +237,13 @@ ATIMach64Probe * 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])) + if ((pVideo->regions[0].size >= (1 << 22)) && + (pATI->Block0Base = pVideo->regions[0].base_addr)) { pATI->MMIOInLinear = TRUE; pATI->Block0Base += 0x007FFC00U; - if ((pVideo->size[0] >= 23) && + if ((pVideo->regions[0].size >= (1 << 23)) && ATIMach64Detect(pATI, ChipType, Chip)) return pATI; @@ -272,11 +272,11 @@ ATIMach64Probe ) { CARD32 IOValue; - CARD16 ChipType = pVideo->chipType; + CARD16 ChipType = pVideo->device_id; if ((pATI->CPIODecoding == BLOCK_IO) && - ((pVideo->size[1] < 8) || - (pATI->CPIOBase >= (CARD32)(-1 << pVideo->size[1])))) + ((pVideo->regions[1].size < (1 << 8)) || + (pATI->CPIOBase >= ~(CARD32)(pVideo->regions[1].size - 1)))) return NULL; if (!ATIMach64Detect(pATI, ChipType, Chip)) @@ -376,21 +376,17 @@ ATIMach64ProbeIO #ifndef AVOID_CPIO /* Next, look for sparse I/O Mach64's */ - if (!pVideo->size[1]) + if (!pVideo->regions[1].size) { static const IOADDRESS Mach64SparseIOBases[] = { 0x02ECU, 0x01CCU, 0x01C8U }; - pciConfigPtr pPCI = pVideo->thisCard; - CARD32 PciReg; - CARD32 j; + uint32_t PciReg; + CARD32 j; - if (pPCI == NULL) - goto SkipSparse; - - PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG); + pci_device_cfg_read_u32(pVideo, &PciReg, PCI_REG_USERCONFIG); j = PciReg & 0x03U; if (j == 0x03U) @@ -398,7 +394,7 @@ ATIMach64ProbeIO xf86Msg(X_WARNING, ATI_NAME ": " "PCI Mach64 in slot %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); + pVideo->bus, pVideo->dev, pVideo->func); goto SkipSparse; } @@ -418,14 +414,17 @@ ATIMach64ProbeIO xf86Msg(X_WARNING, ATI_NAME ": " "PCI Mach64 in slot %d:%d:%d will not be probed\n" "set option \"probe_sparse\" to force sparse I/O probing.\n", - pVideo->bus, pVideo->device, pVideo->func); + pVideo->bus, pVideo->dev, pVideo->func); goto SkipSparse; } /* Possibly fix block I/O indicator */ if (PciReg & 0x00000004U) - pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, PciReg & ~0x00000004U); + { + PciReg &= ~0x00000004U; + pci_device_cfg_write_u32(pVideo, PciReg, PCI_REG_USERCONFIG); + } pATI->CPIOBase = Mach64SparseIOBases[j]; pATI->CPIODecoding = SPARSE_IO; @@ -435,7 +434,7 @@ ATIMach64ProbeIO { xf86Msg(X_WARNING, ATI_NAME ": " "PCI Mach64 in slot %d:%d:%d could not be detected!\n", - pVideo->bus, pVideo->device, pVideo->func); + pVideo->bus, pVideo->dev, pVideo->func); } else { @@ -443,7 +442,7 @@ ATIMach64ProbeIO xf86Msg(X_INFO, ATI_NAME ": " "Shared PCI Mach64 in slot %d:%d:%d with sparse PIO base" " 0x%04lX detected.\n", - pVideo->bus, pVideo->device, pVideo->func, + pVideo->bus, pVideo->dev, pVideo->func, Mach64SparseIOBases[j]); if (pATI->VGAAdapter) @@ -455,7 +454,7 @@ SkipSparse: #else /* AVOID_CPIO */ - if (!pVideo->size[1]) + if (!pVideo->regions[1].size) { /* The adapter's CPIO base is of little concern here */ pATI->CPIOBase = 0; @@ -468,23 +467,23 @@ SkipSparse: xf86Msg(X_INFO, ATI_NAME ": " "Shared PCI Mach64 in slot %d:%d:%d with Block 0 base" " 0x%08lX detected.\n", - pVideo->bus, pVideo->device, pVideo->func, + pVideo->bus, pVideo->dev, pVideo->func, pATI->Block0Base); } else { xf86Msg(X_WARNING, ATI_NAME ": " "PCI Mach64 in slot %d:%d:%d could not be detected!\n", - pVideo->bus, pVideo->device, pVideo->func); + pVideo->bus, pVideo->dev, pVideo->func); } } #endif /* AVOID_CPIO */ /* Lastly, look for block I/O devices */ - if (pVideo->size[1]) + if (pVideo->regions[1].size) { - pATI->CPIOBase = pVideo->ioBase[1]; + pATI->CPIOBase = pVideo->regions[1].base_addr; pATI->CPIODecoding = BLOCK_IO; pATI->PCIInfo = pVideo; @@ -493,7 +492,7 @@ SkipSparse: ProbeSuccess = TRUE; xf86Msg(X_INFO, ATI_NAME ": " "Shared PCI/AGP Mach64 in slot %d:%d:%d detected.\n", - pVideo->bus, pVideo->device, pVideo->func); + pVideo->bus, pVideo->dev, pVideo->func); #ifndef AVOID_CPIO @@ -507,7 +506,7 @@ SkipSparse: { xf86Msg(X_WARNING, ATI_NAME ": " "PCI/AGP Mach64 in slot %d:%d:%d could not be detected!\n", - pVideo->bus, pVideo->device, pVideo->func); + pVideo->bus, pVideo->dev, pVideo->func); } } diff --git a/src/atistruct.h b/src/atistruct.h index 597ebd9..8fa493c 100644 --- a/src/atistruct.h +++ b/src/atistruct.h @@ -57,6 +57,7 @@ #ifdef USE_XAA #include "xaa.h" #endif +#include #include "xf86Cursor.h" #include "xf86Pci.h" #include "xf86Resources.h" @@ -209,6 +210,8 @@ typedef struct _Mach64ContextRegs3D #endif /* USE_EXA */ +typedef struct pci_device *pciVideoPtr; + /* * This structure defines the driver's private area. */ diff --git a/src/atividmem.c b/src/atividmem.c index 043bfe4..d119293 100644 --- a/src/atividmem.c +++ b/src/atividmem.c @@ -106,7 +106,7 @@ ATIUnmapLinear pciVideoPtr pVideo = pATI->PCIInfo; if (pATI->pMemoryLE) - xf86UnMapVidMem(iScreen, pATI->pMemoryLE, (1U << pVideo->size[0])); + pci_device_unmap_region(pVideo, 0); pATI->pMemory = pATI->pMemoryLE = NULL; @@ -125,8 +125,10 @@ ATIUnmapMMIO ATIPtr pATI ) { + pciVideoPtr pVideo = pATI->PCIInfo; + if (pATI->pMMIO) - xf86UnMapVidMem(iScreen, pATI->pMMIO, getpagesize()); + pci_device_unmap_region(pVideo, 2); pATI->pMMIO = pATI->pBlock[0] = pATI->pBlock[1] = NULL; } @@ -149,8 +151,7 @@ ATIMapApertures ) { pciVideoPtr pVideo = pATI->PCIInfo; - PCITAG Tag = ((pciConfigPtr)(pVideo->thisCard))->tag; - int mode; + int err; if (pATI->Mapped) return TRUE; @@ -165,7 +166,7 @@ ATIMapApertures * aperture is supported. Hence, the hard-coded values here... */ pATI->pBank = xf86MapDomainMemory(iScreen, VIDMEM_MMIO_32BIT, - Tag, 0x000A0000U, 0x00010000U); + pVideo, 0x000A0000U, 0x00010000U); if (!pATI->pBank) return FALSE; @@ -178,19 +179,9 @@ ATIMapApertures /* Map linear aperture */ if (pATI->LinearBase || (pATI->Block0Base && pATI->MMIOInLinear)) { - mode = VIDMEM_FRAMEBUFFER; - - /* Reset write-combining for the whole FB when MMIO registers fall in - * the linear aperture. - */ - if (pATI->MMIOInLinear) - mode = VIDMEM_MMIO; + err = pci_device_map_region(pVideo, 0, TRUE); - pATI->pMemoryLE = xf86MapPciMem(iScreen, mode, Tag, - pVideo->memBase[0], - (1U << pVideo->size[0])); - - if (!pATI->pMemoryLE) + if (err) { #ifndef AVOID_CPIO @@ -203,6 +194,8 @@ ATIMapApertures return FALSE; } + pATI->pMemoryLE = pVideo->regions[0].memory; + pATI->Mapped = TRUE; #if X_BYTE_ORDER == X_LITTLE_ENDIAN @@ -228,12 +221,9 @@ ATIMapApertures /* Map MMIO aperture */ if (pATI->Block0Base && !pATI->MMIOInLinear) { - mode = VIDMEM_MMIO; - pATI->pMMIO = xf86MapPciMem(iScreen, mode, Tag, - pVideo->memBase[2], - getpagesize()); + err = pci_device_map_region(pVideo, 2, TRUE); - if (!pATI->pMMIO) + if (err) { ATIUnmapLinear(iScreen, pATI); @@ -247,6 +237,8 @@ ATIMapApertures return FALSE; } + pATI->pMMIO = pVideo->regions[2].memory; + pATI->Mapped = TRUE; pATI->pBlock[0] = (char *)pATI->pMMIO + 0x00000400U; @@ -258,9 +250,9 @@ ATIMapApertures { unsigned long mmio_offset, linear_size; - mmio_offset = pATI->Block0Base - pVideo->memBase[0]; + mmio_offset = pATI->Block0Base - pVideo->regions[0].base_addr; - linear_size = (1 << pVideo->size[0]); + linear_size = pVideo->regions[0].size; pATI->pMMIO = NULL; diff --git a/src/r128_probe.c b/src/r128_probe.c index 4063cf8..86198f8 100644 --- a/src/r128_probe.c +++ b/src/r128_probe.c @@ -135,6 +135,7 @@ R128Identify(int flags) } /* Return TRUE if chipset is present; FALSE otherwise. */ +#if 0 Bool R128Probe(DriverPtr drv, int flags) { @@ -257,3 +258,11 @@ R128Probe(DriverPtr drv, int flags) return foundScreen; } +#else +Bool +R128PciProbe(DriverPtr pDriver, int entity_num, struct pci_device *dev, + intptr_t match_data) +{ + return FALSE; +} +#endif diff --git a/src/r128_probe.h b/src/r128_probe.h index 9150296..285ccae 100644 --- a/src/r128_probe.h +++ b/src/r128_probe.h @@ -56,7 +56,12 @@ typedef struct /* r128_probe.c */ extern const OptionInfoRec * R128AvailableOptions(int, int); extern void R128Identify(int); +#if 0 extern Bool R128Probe(DriverPtr, int); +#else +extern Bool R128PciProbe(DriverPtr, int, struct pci_device *, + intptr_t); +#endif extern PciChipsets R128PciChipsets[]; diff --git a/src/radeon_probe.c b/src/radeon_probe.c index abb1566..afc878f 100644 --- a/src/radeon_probe.c +++ b/src/radeon_probe.c @@ -228,6 +228,7 @@ RADEONIdentify(int flags) } /* Return TRUE if chipset is present; FALSE otherwise. */ +#if 0 Bool RADEONProbe(DriverPtr drv, int flags) { @@ -346,3 +347,11 @@ RADEONProbe(DriverPtr drv, int flags) return foundScreen; } +#else +Bool +RADEONPciProbe(DriverPtr pDriver, int entity_num, struct pci_device *dev, + intptr_t match_data) +{ + return FALSE; +} +#endif diff --git a/src/radeon_probe.h b/src/radeon_probe.h index b651e7d..a905ded 100644 --- a/src/radeon_probe.h +++ b/src/radeon_probe.h @@ -151,7 +151,12 @@ typedef struct /* radeon_probe.c */ extern const OptionInfoRec *RADEONAvailableOptions(int, int); extern void RADEONIdentify(int); +#if 0 extern Bool RADEONProbe(DriverPtr, int); +#else +extern Bool RADEONPciProbe(DriverPtr, int, struct pci_device *, + intptr_t); +#endif extern PciChipsets RADEONPciChipsets[];