commit af550d6aec4f0707850953ddb70b5faf5ab7228b Author: George Sapountzis Date: Fri Mar 16 15:13:34 2007 +0200 [mach64] Convert to pci-rework, keeping source-code compatibility. diff --git a/configure.ac b/configure.ac index 16b93e1..f795d84 100644 --- a/configure.ac +++ b/configure.ac @@ -58,6 +58,12 @@ AC_ARG_ENABLE(exa, [EXA="$enableval"], [EXA=yes]) +AC_ARG_ENABLE(pciaccess, + AS_HELP_STRING([--enable-pciaccess], + [Enable use of libpciaccess [[default: disabled]]]), + [PCIACCESS="$enableval"], + [PCIACCESS=no]) + # Checks for extensions XORG_DRIVER_CHECK_EXT(XINERAMA, xineramaproto) XORG_DRIVER_CHECK_EXT(RANDR, randrproto) @@ -204,6 +210,13 @@ CPPFLAGS="$SAVE_CPPFLAGS" AM_CONDITIONAL(USE_EXA, test "x$USE_EXA" = xyes) +AM_CONDITIONAL(PCIACCESS, [test "x$PCIACCESS" = xyes]) +if test "x$PCIACCESS" = xyes; then + AC_DEFINE(PCIACCESS, 1, [Use libpciaccess]) + PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0]) + XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" +fi + AC_SUBST([XORG_CFLAGS]) AC_SUBST([DRI_CFLAGS]) AC_SUBST([moduledir]) diff --git a/src/Makefile.am b/src/Makefile.am index 2528d2a..2ec2456 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,6 +67,9 @@ atimisc_drv_la_SOURCES = \ atiload.c atimisc.c $(ATIMISC_DRI_SRCS) $(ATIMISC_DGA_SOURCES) \ $(ATIMISC_CPIO_SOURCES) $(ATIMISC_EXA_SOURCES) +if PCIACCESS +# r128, radeon and theatre have not been ported yet +else r128_drv_la_LTLIBRARIES = r128_drv.la r128_drv_la_LDFLAGS = -module -avoid-version r128_drv_ladir = @moduledir@/drivers @@ -102,6 +105,7 @@ theatre200_drv_la_CFLAGS = \ $(AM_CFLAGS) -DMICROC_DIR=\"$(theatre200_drv_ladir)\" theatre200_drv_la_SOURCES = \ theatre200.c theatre200_module.c +endif EXTRA_DIST = \ atimach64render.c \ diff --git a/src/ati.c b/src/ati.c index bf97197..ac3cc32 100644 --- a/src/ati.c +++ b/src/ati.c @@ -57,6 +57,10 @@ #include "config.h" #endif +#ifdef PCIACCESS +#include +#endif /* PCIACCESS */ + #include "ati.h" #include "atichip.h" #include "ativersion.h" @@ -67,6 +71,54 @@ #include "r128_probe.h" #include "r128_version.h" +#ifdef PCIACCESS +#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} +}; +#endif /* PCIACCESS */ + /* * ATIIdentify -- * @@ -90,6 +142,7 @@ ATIIdentify * This function is called once, at the start of the first server generation to * do a minimal probe for supported hardware. */ +#ifndef PCIACCESS static Bool ATIProbe ( @@ -152,6 +205,40 @@ ATIProbe return ProbeSuccess; } +#else /* PCIACCESS */ +static Bool +ATIPciProbe(DriverPtr pDriver, int entity_num, struct pci_device *dev, + intptr_t match_data) +{ + Bool ProbeSuccess = FALSE; + Bool DoMach64 = FALSE; + Bool DoRage128 = FALSE, DoRadeon = FALSE; + ATIChipType Chip; + + 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 && Mach64PciProbe(pDriver, entity_num, dev, match_data)) + ProbeSuccess = TRUE; + + /* Call Rage 128 driver probe */ + if (DoRage128 && R128PciProbe(pDriver, entity_num, dev, match_data)) + ProbeSuccess = TRUE; + + /* Call Radeon driver probe */ + if (DoRadeon && RADEONPciProbe(pDriver, entity_num, dev, match_data)) + ProbeSuccess = TRUE; + + return ProbeSuccess; +} +#endif /* PCIACCESS */ /* * ATIAvailableOptions -- @@ -177,6 +264,7 @@ ATIAvailableOptions } /* The root of all evil... */ +#ifndef PCIACCESS _X_EXPORT DriverRec ATI = { ATI_VERSION_CURRENT, @@ -188,3 +276,19 @@ _X_EXPORT DriverRec ATI = 0, NULL }; +#else /* PCIACCESS */ +_X_EXPORT DriverRec ATI = +{ + ATI_VERSION_CURRENT, + "ati", + ATIIdentify, + NULL, + ATIAvailableOptions, + NULL, + 0, + NULL, + + ati_device_match, + ATIPciProbe +}; +#endif /* PCIACCESS */ diff --git a/src/atimach64probe.c b/src/atimach64probe.c index 4d7a06a..b761060 100644 --- a/src/atimach64probe.c +++ b/src/atimach64probe.c @@ -33,6 +33,7 @@ #include "atioption.h" #include "ativersion.h" +#ifndef PCIACCESS static SymTabRec Mach64Chipsets[] = { {ATI_CHIP_88800GXC, "ATI 88800GX-C"}, @@ -100,6 +101,7 @@ Mach64PciChipsets[] = { {ATI_CHIP_MOBILITY, PCI_CHIP_MACH64LS, RES_SHARED_VGA}, {-1, -1, RES_UNDEFINED} }; +#endif /* PCIACCESS */ const OptionInfoRec * Mach64AvailableOptions(int chipid, int busid) @@ -117,6 +119,7 @@ Mach64AvailableOptions(int chipid, int busid) * This function is called once, at the start of the first server generation to * do a minimal probe for supported hardware. */ +#ifndef PCIACCESS Bool Mach64Probe(DriverPtr pDriver, int flags) { @@ -185,3 +188,40 @@ Mach64Probe(DriverPtr pDriver, int flags) return ProbeSuccess; } +#else /* PCIACCESS */ +Bool +Mach64PciProbe(DriverPtr pDriver, int entity_num, struct pci_device *dev, + intptr_t match_data) +{ + ScrnInfoPtr pScrn; + + if ((match_data < ATI_CHIP_88800GX) || + (match_data > ATI_CHIP_MOBILITY)) + return FALSE; + + pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL, RES_SHARED_VGA, + NULL, NULL, NULL, NULL); + + if (pScrn != NULL) + { + +#ifdef XFree86LOADER + + if (!xf86LoadSubModule(pScrn, "atimisc")) + { + xf86Msg(X_ERROR, + ATI_NAME ": Failed to load \"atimisc\" module.\n"); + xf86DeleteScreen(pScrn->scrnIndex, 0); + return FALSE; + } + + xf86LoaderReqSymLists(ATISymbols, NULL); + +#endif + + ATIFillInScreenInfo(pScrn); + } + + return (pScrn != NULL); +} +#endif /* PCIACCESS */ diff --git a/src/atimach64probe.h b/src/atimach64probe.h index 4e474ca..223ceee 100644 --- a/src/atimach64probe.h +++ b/src/atimach64probe.h @@ -26,6 +26,11 @@ #include "xf86str.h" extern const OptionInfoRec * Mach64AvailableOptions(int, int); +#ifndef PCIACCESS extern Bool Mach64Probe(DriverPtr, int); +#else +extern Bool Mach64PciProbe(DriverPtr, int, struct pci_device *, + intptr_t); +#endif #endif /* ___ATIMACH64PROBE_H___ */ diff --git a/src/atiprobe.c b/src/atiprobe.c index 0b5357d..1d1a5ee 100644 --- a/src/atiprobe.c +++ b/src/atiprobe.c @@ -384,10 +384,12 @@ ATIMach64ProbeIO uint32_t PciReg; uint32_t j; +#ifndef PCIACCESS pciConfigPtr pPCI = pVideo->thisCard; if (pPCI == NULL) goto SkipSparse; +#endif PCI_READ_LONG(pVideo, &PciReg, PCI_REG_USERCONFIG); j = PciReg & 0x03U; diff --git a/src/atividmem.c b/src/atividmem.c index 486c249..34e6b31 100644 --- a/src/atividmem.c +++ b/src/atividmem.c @@ -129,7 +129,11 @@ ATIUnmapLinear if (pATI->LinearBase) setWC(iScreen, pATI->LinearBase, pATI->LinearSize, FALSE); +#ifndef PCIACCESS xf86UnMapVidMem(iScreen, pATI->pMemoryLE, (1U << pVideo->size[0])); +#else + pci_device_unmap_region(pVideo, 0); +#endif } pATI->pMemory = pATI->pMemoryLE = NULL; @@ -149,8 +153,16 @@ ATIUnmapMMIO ATIPtr pATI ) { + pciVideoPtr pVideo = pATI->PCIInfo; + if (pATI->pMMIO) + { +#ifndef PCIACCESS xf86UnMapVidMem(iScreen, pATI->pMMIO, getpagesize()); +#else + pci_device_unmap_region(pVideo, 2); +#endif + } pATI->pMMIO = pATI->pBlock[0] = pATI->pBlock[1] = NULL; } @@ -173,7 +185,11 @@ ATIMapApertures ) { pciVideoPtr pVideo = pATI->PCIInfo; +#ifndef PCIACCESS int mode; +#else + int err; +#endif if (pATI->Mapped) return TRUE; @@ -201,6 +217,9 @@ ATIMapApertures /* Map linear aperture */ if (pATI->LinearBase || (pATI->Block0Base && pATI->MMIOInLinear)) { + +#ifndef PCIACCESS + mode = VIDMEM_FRAMEBUFFER; /* Reset write-combining for the whole FB when MMIO registers fall in @@ -216,6 +235,17 @@ ATIMapApertures if (!pATI->pMemoryLE) goto bail; +#else /* PCIACCESS */ + + err = pci_device_map_region(pVideo, 0, TRUE); + + if (err) + goto bail; + + pATI->pMemoryLE = pVideo->regions[0].memory; + +#endif /* PCIACCESS */ + pATI->Mapped = TRUE; #if X_BYTE_ORDER == X_LITTLE_ENDIAN @@ -239,6 +269,9 @@ ATIMapApertures /* Map MMIO aperture */ if (pATI->Block0Base && !pATI->MMIOInLinear) { + +#ifndef PCIACCESS + mode = VIDMEM_MMIO; pATI->pMMIO = xf86MapPciMem(iScreen, mode, PCI_CFG_TAG(pVideo), pVideo->memBase[2], @@ -247,6 +280,17 @@ ATIMapApertures if (!pATI->pMMIO) goto bail; +#else /* PCIACCESS */ + + err = pci_device_map_region(pVideo, 2, TRUE); + + if (err) + goto bail; + + pATI->pMMIO = pVideo->regions[2].memory; + +#endif /* PCIACCESS */ + pATI->Mapped = TRUE; pATI->pBlock[0] = (char *)pATI->pMMIO + 0x00000400U; diff --git a/src/r128_probe.c b/src/r128_probe.c index 96e7897..0a3d093 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. */ +#ifndef PCIACCESS Bool R128Probe(DriverPtr drv, int flags) { @@ -256,3 +257,11 @@ R128Probe(DriverPtr drv, int flags) return foundScreen; } +#else /* PCIACCESS */ +Bool +R128PciProbe(DriverPtr pDriver, int entity_num, struct pci_device *dev, + intptr_t match_data) +{ + return FALSE; +} +#endif /* PCIACCESS */ diff --git a/src/r128_probe.h b/src/r128_probe.h index 9150296..deee72f 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); +#ifndef PCIACCESS 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 98b35aa..7159f46 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. */ +#ifndef PCIACCESS Bool RADEONProbe(DriverPtr drv, int flags) { @@ -343,3 +344,11 @@ RADEONProbe(DriverPtr drv, int flags) return foundScreen; } +#else /* PCIACCESS */ +Bool +RADEONPciProbe(DriverPtr pDriver, int entity_num, struct pci_device *dev, + intptr_t match_data) +{ + return FALSE; +} +#endif /* PCIACCESS */ diff --git a/src/radeon_probe.h b/src/radeon_probe.h index b651e7d..216ad4d 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); +#ifndef PCIACCESS extern Bool RADEONProbe(DriverPtr, int); +#else +extern Bool RADEONPciProbe(DriverPtr, int, struct pci_device *, + intptr_t); +#endif extern PciChipsets RADEONPciChipsets[];