commit 880e31b435f3148956c9e52a3392cd9a756c0c93 Author: George Sapountzis Date: Wed Mar 21 16:14:14 2007 +0200 [mach64] Convert to pci-rework, keeping source-code compatibility. It still uses the old probe method though, this is mainly because of the ati wrapper. Loading the radeon driver for both "ati" and "radeon" device sections would probably work fine with pci probe also. 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 803ac0b..9fad222 100644 --- a/src/ati.c +++ b/src/ati.c @@ -57,6 +57,9 @@ #include "config.h" #endif +#ifdef PCIACCESS +#include +#endif #include "atipcirename.h" #include "ati.h" @@ -69,6 +72,12 @@ #include "r128_probe.h" #include "r128_version.h" +#ifdef PCIACCESS +static const struct pci_id_match ati_device_match = { + PCI_VENDOR_ATI, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0 +}; +#endif + /* * ATIIdentify -- * @@ -99,11 +108,16 @@ ATIProbe int flags ) { - pciVideoPtr pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo(); + pciVideoPtr pVideo; +#ifndef PCIACCESS + pciVideoPtr *xf86PciVideoInfo; + int i; +#else + struct pci_device_iterator *pVideoIter; +#endif Bool ProbeSuccess = FALSE; Bool DoMach64 = FALSE; Bool DoRage128 = FALSE, DoRadeon = FALSE; - int i; ATIChipType Chip; if (!(flags & PROBE_DETECT)) @@ -116,9 +130,21 @@ ATIProbe DoRadeon = TRUE; } - if (xf86PciVideoInfo) - { - for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) +#ifndef PCIACCESS + xf86PciVideoInfo = xf86GetPciVideoInfo(); + i = 0; + + if (xf86PciVideoInfo == NULL) + return FALSE; +#else + pVideoIter = pci_id_match_iterator_create(&ati_device_match); +#endif + +#ifndef PCIACCESS + while ((pVideo = xf86PciVideoInfo[i++])) +#else + while ((pVideo = pci_device_next(pVideoIter))) +#endif { if ((PCI_DEV_VENDOR_ID(pVideo) != PCI_VENDOR_ATI) || (PCI_DEV_DEVICE_ID(pVideo) == PCI_CHIP_MACH32)) @@ -139,7 +165,10 @@ ATIProbe DoMach64 = TRUE; } - } + +#ifdef PCIACCESS + pci_iterator_destroy(pVideoIter); +#endif /* Call Mach64 driver probe */ if (DoMach64 && Mach64Probe(pDriver, flags)) diff --git a/src/atimach64probe.c b/src/atimach64probe.c index 47340a5..bef1313 100644 --- a/src/atimach64probe.c +++ b/src/atimach64probe.c @@ -129,8 +129,10 @@ Mach64Probe(DriverPtr pDriver, int flags) if ((numDevSections = xf86MatchDevice(ATI_DRIVER_NAME, &devSections)) <= 0) return FALSE; +#ifndef PCIACCESS if (xf86GetPciVideoInfo() == NULL) return FALSE; +#endif numUsed = xf86MatchPciInstances(ATI_DRIVER_NAME, PCI_VENDOR_ATI, Mach64Chipsets, Mach64PciChipsets, diff --git a/src/atiprobe.c b/src/atiprobe.c index b82ea5f..49f367c 100644 --- a/src/atiprobe.c +++ b/src/atiprobe.c @@ -386,10 +386,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 7ab203e..b7bf5f6 100644 --- a/src/atividmem.c +++ b/src/atividmem.c @@ -73,9 +73,16 @@ const char *ATIMemoryTypeNames_264xT[] = * * It is called implicitely by xf86MapPciMem(VIDMEM_FRAMEBUFFER). */ +#ifndef PCIACCESS #define nop_setWC(_screenNum, _base, _size, _enable) \ do { \ } while (0) +#else +#define nop_setWC(_screenNum, _base, _size, _enable) \ +do { \ + /* XXX */ \ +} while (0) +#endif #ifndef AVOID_CPIO @@ -120,7 +127,11 @@ ATIUnmapLinear if (pATI->LinearBase) nop_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; @@ -140,8 +151,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; } @@ -164,7 +183,11 @@ ATIMapApertures ) { pciVideoPtr pVideo = pATI->PCIInfo; +#ifndef PCIACCESS int mode; +#else + int err; +#endif if (pATI->Mapped) return TRUE; @@ -192,6 +215,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 @@ -207,6 +233,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 @@ -230,6 +267,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], @@ -238,6 +278,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..ed52df6 100644 --- a/src/r128_probe.c +++ b/src/r128_probe.c @@ -145,7 +145,9 @@ R128Probe(DriverPtr drv, int flags) Bool foundScreen = FALSE; int i; +#ifndef PCIACCESS if (!xf86GetPciVideoInfo()) return FALSE; +#endif /* Collect unclaimed device sections for both driver names */ nATIGDev = xf86MatchDevice(ATI_NAME, &ATIGDevs); diff --git a/src/radeon_probe.c b/src/radeon_probe.c index 98b35aa..852f8f6 100644 --- a/src/radeon_probe.c +++ b/src/radeon_probe.c @@ -238,7 +238,9 @@ RADEONProbe(DriverPtr drv, int flags) Bool foundScreen = FALSE; int i; +#ifndef PCIACCESS if (!xf86GetPciVideoInfo()) return FALSE; +#endif /* Collect unclaimed device sections for both driver names */ nATIGDev = xf86MatchDevice(ATI_NAME, &ATIGDevs);