xf86-video-ati: Branch 'master' - 6 commits

George Sapountzis gsap7 at kemper.freedesktop.org
Fri Feb 15 08:40:17 PST 2008


 src/Makefile.am                   |    2 
 src/ati.c                         |  361 +++++++++++---------------------------
 src/ati.h                         |    4 
 src/atimach64probe.c              |  163 +++++++++++------
 src/atimisc.c                     |    8 
 src/atimodule.c                   |    6 
 src/atipciids.h                   |    7 
 src/atipcirename.h                |    3 
 src/atipreinit.c                  |   16 +
 src/atiprobe.c                    |   90 ++-------
 src/pcidb/parse_pci_ids.pl        |    8 
 src/r128_chipset.h                |   54 -----
 src/r128_dri.c                    |    2 
 src/r128_driver.c                 |    4 
 src/r128_misc.c                   |    6 
 src/r128_probe.c                  |  324 ++++++++++++++++++++++------------
 src/r128_probe.h                  |    2 
 src/radeon_misc.c                 |    6 
 src/radeon_pci_device_match_gen.h |  280 +++++++++++++++++++++++++++++
 src/radeon_probe.c                |  211 +++++++++++-----------
 20 files changed, 878 insertions(+), 679 deletions(-)

New commits:
commit fc85188fd95bf78b7f965cdde3e22b644c74ff81
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Fri Feb 15 18:36:10 2008 +0200

    ati: convert to pci probe
    
    add pciids for each subdriver, make no use of the match_data functionality.
    
    thanks to Alex Deucher for reviewing and testing.

diff --git a/src/Makefile.am b/src/Makefile.am
index 069076b..a146df3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -232,6 +232,7 @@ EXTRA_DIST = \
 	radeon_chipinfo_gen.h \
 	radeon_chipset_gen.h \
 	radeon_pci_chipset_gen.h \
+	radeon_pci_device_match_gen.h \
 	pcidb/ati_pciids.csv \
 	pcidb/parse_pci_ids.pl \
 	radeon_atombios.h
diff --git a/src/atimach64probe.c b/src/atimach64probe.c
index 2b701d7..087ab49 100644
--- a/src/atimach64probe.c
+++ b/src/atimach64probe.c
@@ -106,6 +106,48 @@ Mach64PciChipsets[] = {
     {-1, -1, RES_UNDEFINED}
 };
 
+#ifdef XSERVER_LIBPCIACCESS
+
+static const struct pci_id_match mach64_device_match[] = {
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GX, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64CX, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64CT, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64ET, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64VT, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GT, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64VU, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GU, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64LG, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64VV, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GV, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GW, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GY, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GZ, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GB, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GD, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GI, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GP, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GQ, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64LB, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64LD, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64LI, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64LP, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64LQ, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GL, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GM, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GN, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GO, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GR, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64GS, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64LM, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64LN, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64LR, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_MACH64LS, 0 ),
+    { 0, 0, 0 }
+};
+
+#endif /* XSERVER_LIBPCIACCESS */
+
 static const OptionInfoRec *
 Mach64AvailableOptions(int chipid, int busid)
 {
@@ -127,6 +169,39 @@ Mach64Identify
             "Driver for ATI Mach64 chipsets");
 }
 
+static Bool
+mach64_get_scrninfo(int entity_num)
+{
+    ScrnInfoPtr pScrn;
+
+    pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, Mach64PciChipsets,
+                                0, 0, 0, 0, NULL);
+
+    if (!pScrn)
+        return FALSE;
+
+    pScrn->driverVersion = MACH64_VERSION_CURRENT;
+    pScrn->driverName    = MACH64_DRIVER_NAME;
+    pScrn->name          = MACH64_NAME;
+#ifdef XSERVER_LIBPCIACCESS
+    pScrn->Probe         = NULL;
+#else
+    pScrn->Probe         = Mach64Probe;
+#endif
+    pScrn->PreInit       = ATIPreInit;
+    pScrn->ScreenInit    = ATIScreenInit;
+    pScrn->SwitchMode    = ATISwitchMode;
+    pScrn->AdjustFrame   = ATIAdjustFrame;
+    pScrn->EnterVT       = ATIEnterVT;
+    pScrn->LeaveVT       = ATILeaveVT;
+    pScrn->FreeScreen    = ATIFreeScreen;
+    pScrn->ValidMode     = ATIValidMode;
+
+    return TRUE;
+}
+
+#ifndef XSERVER_LIBPCIACCESS
+
 /*
  * Mach64Probe --
  *
@@ -141,11 +216,10 @@ Mach64Probe(DriverPtr pDriver, int flags)
     int     numDevSections;
     int     numUsed;
     Bool    ProbeSuccess = FALSE;
+    int     i;
 
-#ifndef XSERVER_LIBPCIACCESS
     if (xf86GetPciVideoInfo() == NULL)
         return FALSE;
-#endif
 
     numDevSections = xf86MatchDevice(MACH64_DRIVER_NAME, &devSections);
 
@@ -164,31 +238,9 @@ Mach64Probe(DriverPtr pDriver, int flags)
     if (flags & PROBE_DETECT) {
         ProbeSuccess = TRUE;
     } else {
-        int  i;
-
         for (i = 0; i < numUsed; i++) {
-            ScrnInfoPtr pScrn;
-
-            pScrn = xf86ConfigPciEntity(NULL, 0, usedChips[i], Mach64PciChipsets,
-                                        0, 0, 0, 0, NULL);
-
-            if (!pScrn)
-                continue;
-
-            pScrn->driverVersion = MACH64_VERSION_CURRENT;
-            pScrn->driverName    = MACH64_DRIVER_NAME;
-            pScrn->name          = MACH64_NAME;
-            pScrn->Probe         = Mach64Probe;
-            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;
+            if (mach64_get_scrninfo(usedChips[i]))
+                ProbeSuccess = TRUE;
         }
     }
 
@@ -197,13 +249,37 @@ Mach64Probe(DriverPtr pDriver, int flags)
     return ProbeSuccess;
 }
 
+#else /* XSERVER_LIBPCIACCESS */
+
+static Bool
+mach64_pci_probe(
+    DriverPtr          pDriver,
+    int                entity_num,
+    struct pci_device *device,
+    intptr_t           match_data
+)
+{
+    return mach64_get_scrninfo(entity_num);
+}
+
+#endif /* XSERVER_LIBPCIACCESS */
+
 _X_EXPORT DriverRec MACH64 =
 {
     MACH64_VERSION_CURRENT,
     MACH64_DRIVER_NAME,
     Mach64Identify,
+#ifdef XSERVER_LIBPCIACCESS
+    NULL,
+#else
     Mach64Probe,
+#endif
     Mach64AvailableOptions,
     NULL,
-    0
+    0,
+    NULL,
+#ifdef XSERVER_LIBPCIACCESS
+    mach64_device_match,
+    mach64_pci_probe
+#endif
 };
diff --git a/src/atimisc.c b/src/atimisc.c
index 0bcbff5..ebfde54 100644
--- a/src/atimisc.c
+++ b/src/atimisc.c
@@ -63,7 +63,7 @@ ATISetup
     if (!Inited)
     {
         Inited = TRUE;
-        xf86AddDriver(&MACH64, Module, 0);
+        xf86AddDriver(&MACH64, Module, HaveDriverFuncs);
     }
 
     return (pointer)TRUE;
diff --git a/src/atipcirename.h b/src/atipcirename.h
index 5aa6b80..de8f0a3 100644
--- a/src/atipcirename.h
+++ b/src/atipcirename.h
@@ -117,6 +117,9 @@ typedef struct pci_device *pciVideoPtr;
 #define PCI_WRITE_LONG(_pcidev, _value, _offset) \
     pci_device_cfg_write_u32((_pcidev), (_value), (_offset))
 
+#define ATI_DEVICE_MATCH(d, i) \
+    { PCI_VENDOR_ATI, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) }
+
 #endif /* XSERVER_LIBPCIACCESS */
 
 #endif /* ATIPCIRENAME_H */
diff --git a/src/pcidb/parse_pci_ids.pl b/src/pcidb/parse_pci_ids.pl
index e6eac76..a3a8af8 100755
--- a/src/pcidb/parse_pci_ids.pl
+++ b/src/pcidb/parse_pci_ids.pl
@@ -12,6 +12,7 @@ my $file = $ARGV[0];
 
 my $atioutfile = 'ati_pciids_gen.h';
 my $radeonpcichipsetfile = 'radeon_pci_chipset_gen.h';
+my $radeonpcidevicematchfile = 'radeon_pci_device_match_gen.h';
 my $radeonchipsetfile = 'radeon_chipset_gen.h';
 my $radeonchipinfofile  = 'radeon_chipinfo_gen.h';
 
@@ -21,6 +22,7 @@ open (CSV, "<", $file) or die $!;
 
 open (ATIOUT, ">", $atioutfile) or die;
 open (PCICHIPSET, ">", $radeonpcichipsetfile) or die;
+open (PCIDEVICEMATCH, ">", $radeonpcidevicematchfile) or die;
 open (RADEONCHIPSET, ">", $radeonchipsetfile) or die;
 open (RADEONCHIPINFO, ">", $radeonchipinfofile) or die;
 
@@ -28,6 +30,8 @@ print RADEONCHIPSET "/* This file is autogenerated please do not edit */\n";
 print RADEONCHIPSET "static SymTabRec RADEONChipsets[] = {\n";
 print PCICHIPSET "/* This file is autogenerated please do not edit */\n";
 print PCICHIPSET "PciChipsets RADEONPciChipsets[] = {\n";
+print PCIDEVICEMATCH "/* This file is autogenerated please do not edit */\n";
+print PCIDEVICEMATCH "static const struct pci_id_match radeon_device_match[] = {\n";
 print RADEONCHIPINFO "/* This file is autogenerated please do not edit */\n";
 print RADEONCHIPINFO "RADEONCardInfo RADEONCards[] = {\n";
 while (<CSV>) {
@@ -41,6 +45,8 @@ while (<CSV>) {
       if (($columns[2] ne "R128") && ($columns[2] ne "MACH64") && ($columns[2] ne "MACH32")) {
 	print PCICHIPSET " { PCI_CHIP_$columns[1], PCI_CHIP_$columns[1], RES_SHARED_VGA },\n";
 	
+	print PCIDEVICEMATCH " ATI_DEVICE_MATCH( PCI_CHIP_$columns[1], 0 ),\n";
+
 	print RADEONCHIPSET "  { PCI_CHIP_$columns[1], \"$columns[8]\" },\n";
 
 	print RADEONCHIPINFO " { $columns[0], CHIP_FAMILY_$columns[2], ";
@@ -87,8 +93,10 @@ while (<CSV>) {
 print RADEONCHIPINFO "};\n";
 print RADEONCHIPSET "  { -1,                 NULL }\n};\n";
 print PCICHIPSET " { -1,                 -1,                 RES_UNDEFINED }\n};\n";
+print PCIDEVICEMATCH " { 0, 0, 0 }\n};\n";
 close CSV;
 close ATIOUT;
 close PCICHIPSET;
+close PCIDEVICEMATCH;
 close RADEONCHIPSET;
 close RADEONCHIPINFO;
diff --git a/src/r128_misc.c b/src/r128_misc.c
index 5eb6fac..2dc6040 100644
--- a/src/r128_misc.c
+++ b/src/r128_misc.c
@@ -64,7 +64,7 @@ R128Setup
     if (!Inited)
     {
         Inited = TRUE;
-        xf86AddDriver(&R128, Module, 0);
+        xf86AddDriver(&R128, Module, HaveDriverFuncs);
     }
 
     return (pointer)TRUE;
diff --git a/src/r128_probe.c b/src/r128_probe.c
index 8fc65cb..7895166 100644
--- a/src/r128_probe.c
+++ b/src/r128_probe.c
@@ -41,6 +41,7 @@
 
 #include "r128_probe.h"
 #include "r128_version.h"
+#include "atipcirename.h"
 
 #include "xf86.h"
 #include "xf86PciInfo.h"
@@ -148,6 +149,61 @@ static PciChipsets R128PciChipsets[] = {
     { -1,                 -1,                 RES_UNDEFINED }
 };
 
+#ifdef XSERVER_LIBPCIACCESS
+
+static const struct pci_id_match r128_device_match[] = {
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128LE, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128LF, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128MF, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128ML, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PA, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PB, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PC, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PD, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PE, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PF, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PG, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PH, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PI, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PJ, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PK, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PL, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PM, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PN, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PO, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PP, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PQ, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PR, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PS, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PT, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PU, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PV, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PW, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128PX, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128RE, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128RF, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128RG, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128RK, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128RL, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128SE, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128SF, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128SG, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128SH, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128SK, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128SL, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128SM, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128SN, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128TF, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128TL, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128TR, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128TS, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128TT, 0 ),
+    ATI_DEVICE_MATCH( PCI_CHIP_RAGE128TU, 0 ),
+    { 0, 0, 0 }
+};
+
+#endif /* XSERVER_LIBPCIACCESS */
+
 int gR128EntityIndex = -1;
 
 /* Return the options for supported chipset 'n'; NULL otherwise */
@@ -166,6 +222,81 @@ R128Identify(int flags)
 		      R128Chipsets);
 }
 
+static Bool
+r128_get_scrninfo(int entity_num)
+{
+    ScrnInfoPtr   pScrn = NULL;
+    EntityInfoPtr pEnt;
+
+    pScrn = xf86ConfigPciEntity(pScrn, 0, entity_num, R128PciChipsets,
+                                NULL,
+                                NULL, NULL, NULL, NULL);
+
+    if (!pScrn)
+        return FALSE;
+
+    pScrn->driverVersion = R128_VERSION_CURRENT;
+    pScrn->driverName    = R128_DRIVER_NAME;
+    pScrn->name          = R128_NAME;
+#ifdef XSERVER_LIBPCIACCESS
+    pScrn->Probe         = NULL;
+#else
+    pScrn->Probe         = R128Probe;
+#endif
+    pScrn->PreInit       = R128PreInit;
+    pScrn->ScreenInit    = R128ScreenInit;
+    pScrn->SwitchMode    = R128SwitchMode;
+    pScrn->AdjustFrame   = R128AdjustFrame;
+    pScrn->EnterVT       = R128EnterVT;
+    pScrn->LeaveVT       = R128LeaveVT;
+    pScrn->FreeScreen    = R128FreeScreen;
+    pScrn->ValidMode     = R128ValidMode;
+
+    pEnt = xf86GetEntityInfo(entity_num);
+
+    /* mobility cards support Dual-Head, mark the entity as sharable*/
+    if (pEnt->chipset == PCI_CHIP_RAGE128LE ||
+        pEnt->chipset == PCI_CHIP_RAGE128LF ||
+        pEnt->chipset == PCI_CHIP_RAGE128MF ||
+        pEnt->chipset == PCI_CHIP_RAGE128ML)
+    {
+        static int instance = 0;
+        DevUnion* pPriv;
+
+        xf86SetEntitySharable(entity_num);
+
+        xf86SetEntityInstanceForScreen(pScrn,
+                                       pScrn->entityList[0],
+                                       instance);
+
+        if (gR128EntityIndex < 0)
+        {
+            gR128EntityIndex = xf86AllocateEntityPrivateIndex();
+
+            pPriv = xf86GetEntityPrivate(pScrn->entityList[0],
+                                         gR128EntityIndex);
+
+            if (!pPriv->ptr)
+            {
+                R128EntPtr pR128Ent;
+                pPriv->ptr = xnfcalloc(sizeof(R128EntRec), 1);
+                pR128Ent = pPriv->ptr;
+                pR128Ent->IsDRIEnabled = FALSE;
+                pR128Ent->BypassSecondary = FALSE;
+                pR128Ent->HasSecondary = FALSE;
+                pR128Ent->IsSecondaryRestored = FALSE;
+            }
+        }
+        instance++;
+    }
+
+    xfree(pEnt);
+
+    return TRUE;
+}
+
+#ifndef XSERVER_LIBPCIACCESS
+
 /* Return TRUE if chipset is present; FALSE otherwise. */
 static Bool
 R128Probe(DriverPtr drv, int flags)
@@ -177,9 +308,7 @@ R128Probe(DriverPtr drv, int flags)
     Bool          foundScreen = FALSE;
     int           i;
 
-#ifndef XSERVER_LIBPCIACCESS
     if (!xf86GetPciVideoInfo()) return FALSE;
-#endif
 
     numDevSections = xf86MatchDevice(R128_NAME, &devSections);
 
@@ -199,64 +328,8 @@ R128Probe(DriverPtr drv, int flags)
     if (flags & PROBE_DETECT)
 	foundScreen = TRUE;
     else for (i = 0; i < numUsed; i++) {
-        ScrnInfoPtr pScrn;
-        EntityInfoPtr pEnt;
- 
-        pScrn    = NULL;
-        if((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
-             R128PciChipsets, NULL, NULL, NULL, NULL, NULL)))
-	{
-	    pScrn->driverVersion = R128_VERSION_CURRENT;
-	    pScrn->driverName    = R128_DRIVER_NAME;
-	    pScrn->name          = R128_NAME;
-	    pScrn->Probe         = R128Probe;
-	    pScrn->PreInit       = R128PreInit;
-	    pScrn->ScreenInit    = R128ScreenInit;
-	    pScrn->SwitchMode    = R128SwitchMode;
-	    pScrn->AdjustFrame   = R128AdjustFrame;
-	    pScrn->EnterVT       = R128EnterVT;
-	    pScrn->LeaveVT       = R128LeaveVT;
-	    pScrn->FreeScreen    = R128FreeScreen;
-	    pScrn->ValidMode     = R128ValidMode;
-
-	    foundScreen          = TRUE;
-
-        pEnt = xf86GetEntityInfo(usedChips[i]);
-
-        /* mobility cards support Dual-Head, mark the entity as sharable*/
-        if(pEnt->chipset == PCI_CHIP_RAGE128LE ||
-           pEnt->chipset == PCI_CHIP_RAGE128LF ||
-           pEnt->chipset == PCI_CHIP_RAGE128MF ||
-           pEnt->chipset == PCI_CHIP_RAGE128ML)
-        {
-            static int instance = 0;
-            DevUnion* pPriv;
-
-            xf86SetEntitySharable(usedChips[i]);
-            xf86SetEntityInstanceForScreen(pScrn,
-                pScrn->entityList[0], instance);
-
-            if(gR128EntityIndex < 0)
-            {
-                gR128EntityIndex = xf86AllocateEntityPrivateIndex();
-                pPriv = xf86GetEntityPrivate(pScrn->entityList[0],
-                        gR128EntityIndex);
-
-                if (!pPriv->ptr)
-                {
-                    R128EntPtr pR128Ent;
-                    pPriv->ptr = xnfcalloc(sizeof(R128EntRec), 1);
-                    pR128Ent = pPriv->ptr;
-                    pR128Ent->IsDRIEnabled = FALSE;
-                    pR128Ent->BypassSecondary = FALSE;
-                    pR128Ent->HasSecondary = FALSE;
-                    pR128Ent->IsSecondaryRestored = FALSE;                   
-                } 
-            }
-            instance++;
-	}
-	xfree(pEnt);
-    }
+	if (r128_get_scrninfo(entity_num))
+	    foundScreen = TRUE;
     }
 
     xfree(usedChips);
@@ -265,13 +338,37 @@ R128Probe(DriverPtr drv, int flags)
     return foundScreen;
 }
 
+#else /* XSERVER_LIBPCIACCESS */
+
+static Bool
+r128_pci_probe(
+    DriverPtr          pDriver,
+    int                entity_num,
+    struct pci_device *device,
+    intptr_t           match_data
+)
+{
+    return r128_get_scrninfo(entity_num);
+}
+
+#endif /* XSERVER_LIBPCIACCESS */
+
 _X_EXPORT DriverRec R128 =
 {
     R128_VERSION_CURRENT,
     R128_DRIVER_NAME,
     R128Identify,
+#ifdef XSERVER_LIBPCIACCESS
+    NULL,
+#else
     R128Probe,
+#endif
     R128AvailableOptions,
     NULL,
-    0
+    0,
+    NULL,
+#ifdef XSERVER_LIBPCIACCESS
+    r128_device_match,
+    r128_pci_probe
+#endif
 };
diff --git a/src/radeon_misc.c b/src/radeon_misc.c
index a5a2ccc..1115118 100644
--- a/src/radeon_misc.c
+++ b/src/radeon_misc.c
@@ -63,7 +63,7 @@ RADEONSetup
 
     if (!Inited) {
         Inited = TRUE;
-        xf86AddDriver(&RADEON, Module, 0);
+        xf86AddDriver(&RADEON, Module, HaveDriverFuncs);
     }
 
     return (pointer)TRUE;
diff --git a/src/radeon_pci_device_match_gen.h b/src/radeon_pci_device_match_gen.h
new file mode 100644
index 0000000..04393da
--- /dev/null
+++ b/src/radeon_pci_device_match_gen.h
@@ -0,0 +1,280 @@
+/* This file is autogenerated please do not edit */
+static const struct pci_id_match radeon_device_match[] = {
+ ATI_DEVICE_MATCH( PCI_CHIP_RV380_3150, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV380_3152, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV380_3154, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV380_3E50, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV380_3E54, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS100_4136, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS200_4137, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R300_AD, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R300_AE, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R300_AF, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R300_AG, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R350_AH, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R350_AI, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R350_AJ, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R350_AK, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_AP, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_AQ, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV360_AR, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_AS, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_AT, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_4155, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_AV, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS250_4237, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R200_BB, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R200_BC, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS100_4336, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS200_4337, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS250_4437, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV250_If, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV250_Ig, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R420_JH, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R420_JI, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R420_JJ, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R420_JK, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R420_JL, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R420_JM, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R420_JN, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R420_4A4F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R420_JP, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R481_4B49, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R481_4B4A, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R481_4B4B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R481_4B4C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RADEON_LW, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RADEON_LX, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RADEON_LY, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RADEON_LZ, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV250_Ld, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV250_Lf, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV250_Lg, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R300_ND, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R300_NE, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R300_NF, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R300_NG, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R350_NH, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R350_NI, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R360_NJ, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R350_NK, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_NP, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_NQ, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_NR, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_NS, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_NT, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV350_NV, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RADEON_QD, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RADEON_QE, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RADEON_QF, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RADEON_QG, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R200_QH, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R200_QL, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R200_QM, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV200_QW, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV200_QX, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV100_QY, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV100_QZ, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RN50_515E, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV370_5460, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV370_5462, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV370_5464, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R423_UH, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R423_UI, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R423_UJ, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R423_UK, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R430_554C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R430_554D, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R430_554E, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R430_554F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R423_5550, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R423_UQ, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R423_UR, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R423_UT, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_564A, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_564B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_564F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_5652, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_5653, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS300_5834, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS300_5835, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS480_5954, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS480_5955, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV280_5960, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV280_5961, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV280_5962, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV280_5964, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV280_5965, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RN50_5969, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS482_5974, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS485_5975, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS400_5A41, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS400_5A42, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RC410_5A61, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RC410_5A62, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV370_5B60, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV370_5B62, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV370_5B63, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV370_5657, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV370_5B64, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV370_5B65, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV280_5C61, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV280_5C63, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R430_5D48, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R430_5D49, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R430_5D4A, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R480_5D4C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R480_5D4D, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R480_5D4E, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R480_5D4F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R480_5D50, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R480_5D52, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R423_5D57, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_5E48, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_5E4A, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_5E4B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_5E4C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_5E4D, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV410_5E4F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_7100, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_7101, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_7102, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_7103, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_7104, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_7105, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_7106, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_7108, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_7109, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_710A, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_710B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_710C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_710E, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R520_710F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7140, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7141, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7142, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7143, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7144, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7145, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7146, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7147, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7149, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_714A, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_714B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_714C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_714D, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_714E, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_714F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7151, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7152, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7153, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_715E, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_715F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7180, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7181, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7183, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7186, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7187, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7188, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_718A, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_718B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_718C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_718D, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_718F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7193, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_7196, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_719B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV515_719F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71C0, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71C1, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71C2, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71C3, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71C4, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71C5, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71C6, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71C7, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71CD, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71CE, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71D2, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71D4, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71D5, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71D6, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71DA, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_71DE, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_7200, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_7210, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV530_7211, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_7240, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_7243, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_7244, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_7245, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_7246, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_7247, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_7248, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_7249, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_724A, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_724B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_724C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_724D, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_724E, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_724F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV570_7280, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV560_7281, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV560_7283, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R580_7284, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV560_7287, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV570_7288, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV570_7289, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV570_728B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV570_728C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV560_7290, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV560_7291, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV560_7293, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV560_7297, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS350_7834, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS350_7835, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS690_791E, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS690_791F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS740_796C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS740_796D, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS740_796E, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RS740_796F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R600_9400, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R600_9401, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R600_9402, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R600_9403, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R600_9405, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R600_940A, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R600_940B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_R600_940F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94C0, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94C1, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94C3, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94C4, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94C5, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94C6, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94C7, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94C8, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94C9, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94CB, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV610_94CC, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV670_9500, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV670_9501, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV670_9505, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV670_9507, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV670_950F, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV670_9511, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_9580, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_9581, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_9583, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_9586, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_9587, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_9588, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_9589, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_958A, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_958B, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_958C, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_958D, 0 ),
+ ATI_DEVICE_MATCH( PCI_CHIP_RV630_958E, 0 ),
+ { 0, 0, 0 }
+};
diff --git a/src/radeon_probe.c b/src/radeon_probe.c
index 4974530..658f909 100644
--- a/src/radeon_probe.c
+++ b/src/radeon_probe.c
@@ -41,6 +41,7 @@
 #include "radeon_probe.h"
 #include "radeon_version.h"
 #include "atipciids.h"
+#include "atipcirename.h"
 
 #include "xf86.h"
 #define _XF86MISC_SERVER_
@@ -51,6 +52,10 @@
 
 #include "radeon_pci_chipset_gen.h"
 
+#ifdef XSERVER_LIBPCIACCESS
+#include "radeon_pci_device_match_gen.h"
+#endif
+
 int gRADEONEntityIndex = -1;
 
 /* Return the options for supported chipset 'n'; NULL otherwise */
@@ -69,6 +74,76 @@ RADEONIdentify(int flags)
 		      RADEONChipsets);
 }
 
+static Bool
+radeon_get_scrninfo(int entity_num)
+{
+    ScrnInfoPtr   pScrn = NULL;
+    EntityInfoPtr pEnt;
+
+    pScrn = xf86ConfigPciEntity(pScrn, 0, entity_num, RADEONPciChipsets,
+                                NULL,
+                                NULL, NULL, NULL, NULL);
+
+    if (!pScrn)
+        return FALSE;
+
+    pScrn->driverVersion = RADEON_VERSION_CURRENT;
+    pScrn->driverName    = RADEON_DRIVER_NAME;
+    pScrn->name          = RADEON_NAME;
+#ifdef XSERVER_LIBPCIACCESS
+    pScrn->Probe         = NULL;
+#else
+    pScrn->Probe         = RADEONProbe;
+#endif
+    pScrn->PreInit       = RADEONPreInit;
+    pScrn->ScreenInit    = RADEONScreenInit;
+    pScrn->SwitchMode    = RADEONSwitchMode;
+    pScrn->AdjustFrame   = RADEONAdjustFrame;
+    pScrn->EnterVT       = RADEONEnterVT;
+    pScrn->LeaveVT       = RADEONLeaveVT;
+    pScrn->FreeScreen    = RADEONFreeScreen;
+    pScrn->ValidMode     = RADEONValidMode;
+
+    pEnt = xf86GetEntityInfo(entity_num);
+
+    /* Create a RADEONEntity for all chips, even with old single head
+     * Radeon, need to use pRADEONEnt for new monitor detection routines.
+     */
+    {
+        DevUnion    *pPriv;
+        RADEONEntPtr pRADEONEnt;
+
+        xf86SetEntitySharable(entity_num);
+
+        if (gRADEONEntityIndex == -1)
+            gRADEONEntityIndex = xf86AllocateEntityPrivateIndex();
+
+        pPriv = xf86GetEntityPrivate(pEnt->index,
+                                     gRADEONEntityIndex);
+
+        if (!pPriv->ptr) {
+            int j;
+            int instance = xf86GetNumEntityInstances(pEnt->index);
+
+            for (j = 0; j < instance; j++)
+                xf86SetEntityInstanceForScreen(pScrn, pEnt->index, j);
+
+            pPriv->ptr = xnfcalloc(sizeof(RADEONEntRec), 1);
+            pRADEONEnt = pPriv->ptr;
+            pRADEONEnt->HasSecondary = FALSE;
+        } else {
+            pRADEONEnt = pPriv->ptr;
+            pRADEONEnt->HasSecondary = TRUE;
+        }
+    }
+
+    xfree(pEnt);
+
+    return TRUE;
+}
+
+#ifndef XSERVER_LIBPCIACCESS
+
 /* Return TRUE if chipset is present; FALSE otherwise. */
 static Bool
 RADEONProbe(DriverPtr drv, int flags)
@@ -80,9 +155,7 @@ RADEONProbe(DriverPtr drv, int flags)
     Bool     foundScreen = FALSE;
     int      i;
 
-#ifndef XSERVER_LIBPCIACCESS
     if (!xf86GetPciVideoInfo()) return FALSE;
-#endif
 
     numDevSections = xf86MatchDevice(RADEON_NAME, &devSections);
 
@@ -103,66 +176,8 @@ RADEONProbe(DriverPtr drv, int flags)
 	foundScreen = TRUE;
     } else {
 	for (i = 0; i < numUsed; i++) {
-	    ScrnInfoPtr    pScrn = NULL;
-	    EntityInfoPtr  pEnt;
-	    pEnt = xf86GetEntityInfo(usedChips[i]);
-	    if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
-					     RADEONPciChipsets, 0, 0, 0,
-					     0, 0))) {
-		pScrn->driverVersion = RADEON_VERSION_CURRENT;
-		pScrn->driverName    = RADEON_DRIVER_NAME;
-		pScrn->name          = RADEON_NAME;
-		pScrn->Probe         = RADEONProbe;
-		pScrn->PreInit       = RADEONPreInit;
-		pScrn->ScreenInit    = RADEONScreenInit;
-		pScrn->SwitchMode    = RADEONSwitchMode;
-#ifdef X_XF86MiscPassMessage
-		pScrn->HandleMessage = RADEONHandleMessage;
-#endif
-		pScrn->AdjustFrame   = RADEONAdjustFrame;
-		pScrn->EnterVT       = RADEONEnterVT;
-		pScrn->LeaveVT       = RADEONLeaveVT;
-		pScrn->FreeScreen    = RADEONFreeScreen;
-		pScrn->ValidMode     = RADEONValidMode;
-
-		foundScreen          = TRUE;
-	    }
-
-            xfree(pEnt);
-	    pEnt = xf86GetEntityInfo(usedChips[i]);
-
-            /* create a RADEONEntity for all chips, even with
-               old single head Radeon, need to use pRADEONEnt
-               for new monitor detection routines
-            */
-            {
-		DevUnion   *pPriv;
-		RADEONEntPtr pRADEONEnt;
-
-		xf86SetEntitySharable(usedChips[i]);
-
-		if (gRADEONEntityIndex == -1)
-		    gRADEONEntityIndex = xf86AllocateEntityPrivateIndex();
-
-		pPriv = xf86GetEntityPrivate(pEnt->index,
-					     gRADEONEntityIndex);
-
-		if (!pPriv->ptr) {
-		    int j;
-		    int instance = xf86GetNumEntityInstances(pEnt->index);
-
-		    for (j = 0; j < instance; j++)
-			xf86SetEntityInstanceForScreen(pScrn, pEnt->index, j);
-
-		    pPriv->ptr = xnfcalloc(sizeof(RADEONEntRec), 1);
-		    pRADEONEnt = pPriv->ptr;
-		    pRADEONEnt->HasSecondary = FALSE;
-		} else {
-		    pRADEONEnt = pPriv->ptr;
-		    pRADEONEnt->HasSecondary = TRUE;
-		}
-	    }
-	    xfree(pEnt);
+	    if (radeon_get_scrninfo(entity_num))
+		foundScreen = TRUE;
 	}
     }
 
@@ -172,13 +187,37 @@ RADEONProbe(DriverPtr drv, int flags)
     return foundScreen;
 }
 
+#else /* XSERVER_LIBPCIACCESS */
+
+static Bool
+radeon_pci_probe(
+    DriverPtr          pDriver,
+    int                entity_num,
+    struct pci_device *device,
+    intptr_t           match_data
+)
+{
+    return radeon_get_scrninfo(entity_num);
+}
+
+#endif /* XSERVER_LIBPCIACCESS */
+
 _X_EXPORT DriverRec RADEON =
 {
     RADEON_VERSION_CURRENT,
     RADEON_DRIVER_NAME,
     RADEONIdentify,
+#ifdef XSERVER_LIBPCIACCESS
+    NULL,
+#else
     RADEONProbe,
+#endif
     RADEONAvailableOptions,
     NULL,
-    0
+    0,
+    NULL,
+#ifdef XSERVER_LIBPCIACCESS
+    radeon_device_match,
+    radeon_pci_probe
+#endif
 };
commit 665bd7e2f61cac3e029bbad5024034e5136deec1
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Fri Feb 15 18:34:56 2008 +0200

    ati wrapper: translate Device lines

diff --git a/src/ati.c b/src/ati.c
index 89e62dc..b3f07ca 100644
--- a/src/ati.c
+++ b/src/ati.c
@@ -66,11 +66,8 @@
 #include "ativersion.h"
 
 /* names duplicated from version headers */
-#define MACH64_NAME         "MACH64"
 #define MACH64_DRIVER_NAME  "mach64"
-#define R128_NAME           "R128"
 #define R128_DRIVER_NAME    "r128"
-#define RADEON_NAME         "RADEON"
 #define RADEON_DRIVER_NAME  "radeon"
 
 enum
@@ -81,304 +78,170 @@ enum
     ATI_CHIP_FAMILY_Radeon
 };
 
-/*
- * Record which sub-drivers have already been loaded, and thus have called
- * xf86AddDriver(). For those sub-drivers, cause the ati wrapper later to fail
- * when probing.
- *
- * The check is only called once when the ati wrapper is loaded and depends on
- * the X server loading all drivers before doing any probes.
- */
-static Bool mach64_drv_added = FALSE;
-static Bool r128_drv_added = FALSE;
-static Bool radeon_drv_added = FALSE;
-
-void
-ati_check_subdriver_added()
-{
-    if (LoaderSymbol(MACH64_NAME))
-        mach64_drv_added = TRUE;
-    if (LoaderSymbol(R128_NAME))
-        r128_drv_added = TRUE;
-    if (LoaderSymbol(RADEON_NAME))
-        radeon_drv_added = TRUE;
-}
-
 static int ATIChipID(const CARD16);
 
 #ifdef XSERVER_LIBPCIACCESS
-static const struct pci_id_match ati_device_match = {
-    PCI_VENDOR_ATI, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0
-};
 
-/* Stolen from xf86pciBus.c */
-/* PCI classes that get included in xf86PciVideoInfo */
-#define PCIINFOCLASSES(c) \
-    (  (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) ||           \
-       (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) ||               \
-      ((((c) & 0x00ffff00) == ((PCI_CLASS_MULTIMEDIA << 16) |             \
-                               (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) || \
-      ((((c) & 0x00ffff00) == ((PCI_CLASS_PROCESSOR << 16) |              \
-                               (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) )
+/* domain defines (stolen from xserver) */
+#if (defined(__alpha__) || defined(__ia64__)) && defined (linux)
+# define PCI_DOM_MASK 0x01fful
+#else
+# define PCI_DOM_MASK 0x0ffu
 #endif
 
-/*
- * ATIIdentify --
- *
- * Print the driver's list of chipset names.
- */
-static void
-ATIIdentify
-(
-    int flags
-)
+#define PCI_DOM_FROM_BUS(bus)  (((bus) >> 8) & (PCI_DOM_MASK))
+#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
+
+static struct pci_device*
+ati_device_get_from_busid(int bus, int dev, int func)
 {
-    /*
-     * Only print chip families here, chip lists are printed when a subdriver
-     * is loaded.
-     */
-    xf86Msg(X_INFO, "%s: %s\n", ATI_NAME,
-            "ATI driver wrapper (version " ATI_VERSION_NAME ") for chipsets: "
-            "mach64, rage128, radeon");
+    return pci_device_find_by_slot(PCI_DOM_FROM_BUS(bus),
+                                   PCI_BUS_NO_DOMAIN(bus),
+                                   dev,
+                                   func);
 }
 
-/*
- * ATIProbe --
- *
- * This function is called once, at the start of the first server generation to
- * do a minimal probe for supported hardware.
- */
-static Bool
-ATIProbe
-(
-    DriverPtr pDriver,
-    int       flags
-)
+static struct pci_device*
+ati_device_get_primary()
 {
-    pciVideoPtr pVideo;
-#ifndef XSERVER_LIBPCIACCESS
-    pciVideoPtr *xf86PciVideoInfo;
-#else
-    struct pci_device_iterator *pVideoIter;
-#endif
-    Bool        DoMach64 = FALSE;
-    Bool        DoRage128 = FALSE, DoRadeon = FALSE;
-    int         Chip;
+    struct pci_device *device = NULL;
+    struct pci_device_iterator *device_iter;
 
-    /* Let the sub-drivers probe & configure for themselves */
-    if (xf86ServerIsOnlyDetecting())
-        return FALSE;
+    device_iter = pci_slot_match_iterator_create(NULL);
+
+    while ((device = pci_device_next(device_iter)) != NULL) {
+        if (xf86IsPrimaryPci(device))
+            break;
+    }
+
+    pci_iterator_destroy(device_iter);
+
+    return device;
+}
+
+#else /* XSERVER_LIBPCIACCESS */
 
-#ifndef XSERVER_LIBPCIACCESS
+static pciVideoPtr
+ati_device_get_from_busid(int bus, int dev, int func)
+{
+    pciVideoPtr  pVideo = NULL;
+    pciVideoPtr *xf86PciVideoInfo;
 
     xf86PciVideoInfo = xf86GetPciVideoInfo();
 
     if (xf86PciVideoInfo == NULL)
-        return FALSE;
+        return NULL;
 
     while ((pVideo = *xf86PciVideoInfo++) != NULL)
     {
-        if ((PCI_DEV_VENDOR_ID(pVideo) != PCI_VENDOR_ATI) ||
-            (PCI_DEV_DEVICE_ID(pVideo) == PCI_CHIP_MACH32))
-            continue;
-
-        /* Check for Rage128's, Radeon's and later adapters */
-        Chip = ATIChipID(PCI_DEV_DEVICE_ID(pVideo));
-        if (Chip == ATI_CHIP_FAMILY_Mach64)
-            DoMach64 = TRUE;
-        else if (Chip == ATI_CHIP_FAMILY_Rage128)
-            DoRage128 = TRUE;
-        else if (Chip == ATI_CHIP_FAMILY_Radeon)
-            DoRadeon = TRUE;
+        if ((pVideo->bus == bus) && (pVideo->device == dev) &&
+            (pVideo->func == func))
+            break;
     }
 
-#else /* XSERVER_LIBPCIACCESS */
+    return pVideo;
+}
 
-    pVideoIter = pci_id_match_iterator_create(&ati_device_match);
+static pciVideoPtr
+ati_device_get_primary()
+{
+    pciVideoPtr  pVideo = NULL;
+    pciVideoPtr *xf86PciVideoInfo;
 
-    while ((pVideo = pci_device_next(pVideoIter)) != NULL)
-    {
-        /* Check for non-video devices */
-        if (!PCIINFOCLASSES(pVideo->device_class))
-            continue;
+    xf86PciVideoInfo = xf86GetPciVideoInfo();
 
-        /* Check for prehistoric PCI Mach32 */
-        if ((PCI_DEV_VENDOR_ID(pVideo) != PCI_VENDOR_ATI) ||
-            (PCI_DEV_DEVICE_ID(pVideo) == PCI_CHIP_MACH32))
-            continue;
+    if (xf86PciVideoInfo == NULL)
+        return NULL;
 
-        /* Check for Rage128's, Radeon's and later adapters */
-        Chip = ATIChipID(PCI_DEV_DEVICE_ID(pVideo));
-        if (Chip == ATI_CHIP_FAMILY_Mach64)
-            DoMach64 = TRUE;
-        else if (Chip == ATI_CHIP_FAMILY_Rage128)
-            DoRage128 = TRUE;
-        else if (Chip == ATI_CHIP_FAMILY_Radeon)
-            DoRadeon = TRUE;
+    while ((pVideo = *xf86PciVideoInfo++) != NULL)
+    {
+        if (xf86IsPrimaryPci(pVideo))
+            break;
     }
 
-    pci_iterator_destroy(pVideoIter);
+    return pVideo;
+}
 
 #endif /* XSERVER_LIBPCIACCESS */
 
-    /* Call Radeon driver probe */
-    if (DoRadeon)
-    {
-        DriverRec *radeon;
-
-        /* If the sub-driver was added, let it probe for itself */
-        if (radeon_drv_added)
-            return FALSE;
-
-        if (!LoaderSymbol(RADEON_NAME))
-            xf86LoadDrvSubModule(pDriver, RADEON_DRIVER_NAME);
-
-        radeon = (DriverRec*)LoaderSymbol(RADEON_NAME);
-
-        if (!radeon)
-        {
-            xf86Msg(X_ERROR,
-                ATI_NAME ":  Failed to find \"radeon\" driver symbol.\n");
-            return FALSE;
-        }
-
-        radeon->Identify(flags);
+void
+ati_gdev_subdriver(pointer options)
+{
+    int      nATIGDev, nMach64GDev, nR128GDev, nRadeonGDev;
+    GDevPtr *ATIGDevs;
+    Bool     load_mach64 = FALSE, load_r128 = FALSE, load_radeon = FALSE;
+    int      i;
 
-        if (radeon->Probe(pDriver, flags))
-            return TRUE;
-    }
+    /* let the subdrivers configure for themselves */
+    if (xf86ServerIsOnlyDetecting())
+        return;
 
-    /* Call Rage 128 driver probe */
-    if (DoRage128)
-    {
-        DriverRec *r128;
+    /* get Device sections with Driver "ati" */
+    nATIGDev = xf86MatchDevice(ATI_DRIVER_NAME, &ATIGDevs);
+    nMach64GDev = xf86MatchDevice(MACH64_DRIVER_NAME, NULL);
+    nR128GDev = xf86MatchDevice(R128_DRIVER_NAME, NULL);
+    nRadeonGDev = xf86MatchDevice(RADEON_DRIVER_NAME, NULL);
 
-        /* If the sub-driver was added, let it probe for itself */
-        if (r128_drv_added)
-            return FALSE;
+    for (i = 0; i < nATIGDev; i++) {
+        GDevPtr     ati_gdev = ATIGDevs[i];
+        pciVideoPtr device = NULL;
+        int         chip_family;
 
-        if (!LoaderSymbol(R128_NAME))
-            xf86LoadDrvSubModule(pDriver, R128_DRIVER_NAME);
+        /* get pci device for the Device section */
+        if (ati_gdev->busID) {
+            int bus, dev, func;
 
-        r128 = (DriverRec*)LoaderSymbol(R128_NAME);
+            if (!xf86ParsePciBusString(ati_gdev->busID, &bus, &dev, &func))
+                continue;
 
-        if (!r128)
-        {
-            xf86Msg(X_ERROR,
-                ATI_NAME ":  Failed to find \"r128\" driver symbol.\n");
-            return FALSE;
+            device = ati_device_get_from_busid(bus, dev, func);
         }
-
-        r128->Identify(flags);
-
-        if (r128->Probe(pDriver, flags))
-            return TRUE;
-    }
-
-    /* Call Mach64 driver probe */
-    if (DoMach64)
-    {
-        DriverRec *mach64;
-
-        /* If the sub-driver was added, let it probe for itself */
-        if (mach64_drv_added)
-            return FALSE;
-
-        if (!LoaderSymbol(MACH64_NAME))
-            xf86LoadDrvSubModule(pDriver, MACH64_DRIVER_NAME);
-
-        mach64 = (DriverRec*)LoaderSymbol(MACH64_NAME);
-
-        if (!mach64)
-        {
-            xf86Msg(X_ERROR,
-                ATI_NAME ":  Failed to find \"mach64\" driver symbol.\n");
-            return FALSE;
+        else {
+            device = ati_device_get_primary();
         }
 
-        mach64->Identify(flags);
-
-        if (mach64->Probe(pDriver, flags))
-            return TRUE;
-    }
-
-    return FALSE;
-}
-
-/*
- * ATIAvailableOptions --
- *
- * Return recognised options that are intended for public consumption.
- */
-static const OptionInfoRec *
-ATIAvailableOptions
-(
-    int ChipId,
-    int BusId
-)
-{
-    CARD16      ChipType = ChipId & 0xffff;
-    int         Chip;
+        if (!device)
+            continue;
 
-    /* Probe should have loaded the appropriate subdriver by this point */
+        /* check for non-ati devices and prehistoric mach32 */
+        if ((PCI_DEV_VENDOR_ID(device) != PCI_VENDOR_ATI) ||
+            (PCI_DEV_DEVICE_ID(device) == PCI_CHIP_MACH32))
+            continue;
 
-    Chip = ATIChipID(ChipType);
-    if (Chip == ATI_CHIP_FAMILY_Mach64)
-    {
-        DriverRec *mach64 = (DriverRec*)LoaderSymbol(MACH64_NAME);
+        /* replace Driver line in the Device section */
+        chip_family = ATIChipID(PCI_DEV_DEVICE_ID(device));
 
-        if (!mach64)
-        {
-            xf86Msg(X_ERROR,
-                ATI_NAME ":  Failed to find \"mach64\" driver symbol.\n");
-            return NULL;
+        if (chip_family == ATI_CHIP_FAMILY_Mach64) {
+            ati_gdev->driver = MACH64_DRIVER_NAME;
+            load_mach64 = TRUE;
         }
 
-        return mach64->AvailableOptions(ChipId, BusId);
-    }
-
-    if (Chip == ATI_CHIP_FAMILY_Rage128)
-    {
-        DriverRec *r128 = (DriverRec*)LoaderSymbol(R128_NAME);
-
-        if (!r128)
-        {
-            xf86Msg(X_ERROR,
-                ATI_NAME ":  Failed to find \"r128\" driver symbol.\n");
-            return NULL;
+        if (chip_family == ATI_CHIP_FAMILY_Rage128) {
+            ati_gdev->driver = R128_DRIVER_NAME;
+            load_r128 = TRUE;
         }
 
-        return r128->AvailableOptions(ChipId, BusId);
+        if (chip_family == ATI_CHIP_FAMILY_Radeon) {
+            ati_gdev->driver = RADEON_DRIVER_NAME;
+            load_radeon = TRUE;
+        }
     }
 
-    if (Chip == ATI_CHIP_FAMILY_Radeon)
-    {
-        DriverRec *radeon = (DriverRec*)LoaderSymbol(RADEON_NAME);
+    xfree(ATIGDevs);
 
-        if (!radeon)
-        {
-            xf86Msg(X_ERROR,
-                ATI_NAME ":  Failed to find \"radeon\" driver symbol.\n");
-            return NULL;
-        }
+    /* load subdrivers as primary modules and only if they do not get loaded
+     * from other device sections
+     */
 
-        return radeon->AvailableOptions(ChipId, BusId);
-    }
+    if (load_mach64 && (nMach64GDev == 0))
+         xf86LoadOneModule(MACH64_DRIVER_NAME, options);
 
-    return NULL;
-}
+    if (load_r128 && (nR128GDev == 0))
+         xf86LoadOneModule(R128_DRIVER_NAME, options);
 
-/* The root of all evil... */
-_X_EXPORT DriverRec ATI =
-{
-    ATI_VERSION_CURRENT,
-    "ati",
-    ATIIdentify,
-    ATIProbe,
-    ATIAvailableOptions,
-    NULL,
-    0
-};
+    if (load_radeon && (nRadeonGDev == 0))
+         xf86LoadOneModule(RADEON_DRIVER_NAME, options);
+}
 
 /*
  * ATIChipID --
diff --git a/src/ati.h b/src/ati.h
index e86e50c..828aae1 100644
--- a/src/ati.h
+++ b/src/ati.h
@@ -31,8 +31,4 @@
 
 #include "xf86_OSproc.h"
 
-extern void ati_check_subdriver_added();
-
-extern DriverRec ATI;
-
 #endif /* ___ATI_H___ */
diff --git a/src/atimach64probe.c b/src/atimach64probe.c
index ffab153..2b701d7 100644
--- a/src/atimach64probe.c
+++ b/src/atimach64probe.c
@@ -30,7 +30,6 @@
 #include "atimach64probe.h"
 #include "atimach64version.h"
 #include "atioption.h"
-#include "ativersion.h"
 
 /* include headers corresponding to ScrnInfoPtr fields */
 #include "atipreinit.h"
@@ -110,10 +109,6 @@ Mach64PciChipsets[] = {
 static const OptionInfoRec *
 Mach64AvailableOptions(int chipid, int busid)
 {
-    /*
-     * Return options defined in the mach64 submodule which will have been
-     * loaded by this point.
-     */
     return ATIOptionsWeak();
 }
 
@@ -141,9 +136,9 @@ Mach64Identify
 static Bool
 Mach64Probe(DriverPtr pDriver, int flags)
 {
-    GDevPtr *devSections, *ATIGDevs, *Mach64GDevs;
+    GDevPtr *devSections;
     int     *usedChips;
-    int     numDevSections, nATIGDev, nMach64GDev;
+    int     numDevSections;
     int     numUsed;
     Bool    ProbeSuccess = FALSE;
 
@@ -152,31 +147,11 @@ Mach64Probe(DriverPtr pDriver, int flags)
         return FALSE;
 #endif
 
-    /* Collect unclaimed device sections for both driver names */
-    nATIGDev = xf86MatchDevice(ATI_DRIVER_NAME, &ATIGDevs);
-    nMach64GDev = xf86MatchDevice(MACH64_DRIVER_NAME, &Mach64GDevs);
+    numDevSections = xf86MatchDevice(MACH64_DRIVER_NAME, &devSections);
 
-    if ((numDevSections = nATIGDev + nMach64GDev) <= 0)
+    if (numDevSections <= 0)
         return FALSE;
 
-    if (ATIGDevs == NULL) {
-        devSections = Mach64GDevs;
-        numDevSections = nMach64GDev;
-    } else if (Mach64GDevs == NULL) {
-        devSections = ATIGDevs;
-        numDevSections = nATIGDev;
-    } else {
-        /* Combine into one list */
-        devSections = xnfalloc((numDevSections + 1) * sizeof(GDevPtr));
-        (void)memcpy(devSections,
-                     ATIGDevs, nATIGDev * sizeof(GDevPtr));
-        (void)memcpy(devSections + nATIGDev,
-                     Mach64GDevs, nMach64GDev * sizeof(GDevPtr));
-        devSections[numDevSections] = NULL;
-        xfree(ATIGDevs);
-        xfree(Mach64GDevs);
-    }
-
     numUsed = xf86MatchPciInstances(MACH64_NAME, PCI_VENDOR_ATI,
                                     Mach64Chipsets, Mach64PciChipsets,
                                     devSections, numDevSections,
diff --git a/src/atimisc.c b/src/atimisc.c
index cf2347a..0bcbff5 100644
--- a/src/atimisc.c
+++ b/src/atimisc.c
@@ -25,8 +25,6 @@
 #endif
 
 #include "ati.h"
-#include "ativersion.h"
-
 #include "atimach64probe.h"
 #include "atimach64version.h"
 
@@ -34,7 +32,7 @@
 
 static XF86ModuleVersionInfo ATIVersionRec =
 {
-    "mach64",
+    MACH64_DRIVER_NAME,
     MODULEVENDORSTRING,
     MODINFOSTRING1,
     MODINFOSTRING2,
@@ -64,10 +62,8 @@ ATISetup
 
     if (!Inited)
     {
-        if (xf86ServerIsOnlyDetecting() || !LoaderSymbol(ATI_NAME))
-            xf86AddDriver(&MACH64, Module, 0);
-
         Inited = TRUE;
+        xf86AddDriver(&MACH64, Module, 0);
     }
 
     return (pointer)TRUE;
diff --git a/src/atimodule.c b/src/atimodule.c
index 802c35a..c249333 100644
--- a/src/atimodule.c
+++ b/src/atimodule.c
@@ -27,6 +27,8 @@
 #include "ati.h"
 #include "ativersion.h"
 
+extern void ati_gdev_subdriver(pointer options);
+
 /* Module loader interface */
 
 static XF86ModuleVersionInfo ATIVersionRec =
@@ -62,9 +64,7 @@ ATISetup
     if (!Inited)
     {
         Inited = TRUE;
-        xf86AddDriver(&ATI, Module, 0);
-
-        ati_check_subdriver_added();
+        ati_gdev_subdriver(Options);
     }
 
     return (pointer)1;
diff --git a/src/r128_misc.c b/src/r128_misc.c
index f8bccfe..5eb6fac 100644
--- a/src/r128_misc.c
+++ b/src/r128_misc.c
@@ -24,8 +24,6 @@
 #include "config.h"
 #endif
 
-#include "ativersion.h"
-
 #include "r128_probe.h"
 #include "r128_version.h"
 
@@ -65,10 +63,8 @@ R128Setup
 
     if (!Inited)
     {
-        if (xf86ServerIsOnlyDetecting() || !LoaderSymbol(ATI_NAME))
-            xf86AddDriver(&R128, Module, 0);
-
         Inited = TRUE;
+        xf86AddDriver(&R128, Module, 0);
     }
 
     return (pointer)TRUE;
diff --git a/src/r128_probe.c b/src/r128_probe.c
index 75fae31..8fc65cb 100644
--- a/src/r128_probe.c
+++ b/src/r128_probe.c
@@ -37,12 +37,8 @@
  * Authors:
  *   Rickard E. Faith <faith at valinux.com>
  *   Kevin E. Martin <martin at valinux.com>
- *
- * Modified by Marc Aurele La France <tsi at xfree86.org> for ATI driver merge.
  */
 
-#include "ativersion.h"
-
 #include "r128_probe.h"
 #include "r128_version.h"
 
@@ -158,19 +154,7 @@ int gR128EntityIndex = -1;
 static const OptionInfoRec *
 R128AvailableOptions(int chipid, int busid)
 {
-    int i;
-
-    /*
-     * Return options defined in the r128 submodule which will have been
-     * loaded by this point.
-     */
-    if ((chipid >> 16) == PCI_VENDOR_ATI)
-	chipid -= PCI_VENDOR_ATI << 16;
-    for (i = 0; R128PciChipsets[i].PCIid > 0; i++) {
-	if (chipid == R128PciChipsets[i].PCIid)
-	    return R128OptionsWeak();
-    }
-    return NULL;
+    return R128OptionsWeak();
 }
 
 /* Return the string name for supported chipset 'n'; NULL otherwise. */
@@ -187,9 +171,9 @@ static Bool
 R128Probe(DriverPtr drv, int flags)
 {
     int           numUsed;
-    int           numDevSections, nATIGDev, nR128GDev;
+    int           numDevSections;
     int           *usedChips;
-    GDevPtr       *devSections, *ATIGDevs, *R128GDevs;
+    GDevPtr       *devSections;
     Bool          foundScreen = FALSE;
     int           i;
 
@@ -197,31 +181,9 @@ R128Probe(DriverPtr drv, int flags)
     if (!xf86GetPciVideoInfo()) return FALSE;
 #endif
 
-    /* Collect unclaimed device sections for both driver names */
-    nATIGDev = xf86MatchDevice(ATI_NAME, &ATIGDevs);
-    nR128GDev = xf86MatchDevice(R128_NAME, &R128GDevs);
-
-    if (!(numDevSections = nATIGDev + nR128GDev)) return FALSE;
+    numDevSections = xf86MatchDevice(R128_NAME, &devSections);
 
-    if (!ATIGDevs) {
-	if (!(devSections = R128GDevs))
-	    numDevSections = 1;
-	else
-	    numDevSections = nR128GDev;
-    } if (!R128GDevs) {
-	devSections = ATIGDevs;
-	numDevSections = nATIGDev;
-    } else {
-	/* Combine into one list */
-	devSections = xnfalloc((numDevSections + 1) * sizeof(GDevPtr));
-	(void)memcpy(devSections,
-		     ATIGDevs, nATIGDev * sizeof(GDevPtr));
-	(void)memcpy(devSections + nATIGDev,
-		     R128GDevs, nR128GDev * sizeof(GDevPtr));
-	devSections[numDevSections] = NULL;
-	xfree(ATIGDevs);
-	xfree(R128GDevs);
-    }
+    if (!numDevSections) return FALSE;
 
     numUsed = xf86MatchPciInstances(R128_NAME,
 				    PCI_VENDOR_ATI,
diff --git a/src/radeon_misc.c b/src/radeon_misc.c
index fc608dd..a5a2ccc 100644
--- a/src/radeon_misc.c
+++ b/src/radeon_misc.c
@@ -24,8 +24,6 @@
 #include "config.h"
 #endif
 
-#include "ativersion.h"
-
 #include "radeon_probe.h"
 #include "radeon_version.h"
 
@@ -64,10 +62,8 @@ RADEONSetup
     static Bool Inited = FALSE;
 
     if (!Inited) {
-        if (xf86ServerIsOnlyDetecting() || !LoaderSymbol(ATI_NAME))
-            xf86AddDriver(&RADEON, Module, 0);
-
         Inited = TRUE;
+        xf86AddDriver(&RADEON, Module, 0);
     }
 
     return (pointer)TRUE;
diff --git a/src/radeon_probe.c b/src/radeon_probe.c
index 0cf54b6..4974530 100644
--- a/src/radeon_probe.c
+++ b/src/radeon_probe.c
@@ -36,12 +36,8 @@
  * Authors:
  *   Kevin E. Martin <martin at xfree86.org>
  *   Rickard E. Faith <faith at valinux.com>
- *
- * Modified by Marc Aurele La France <tsi at xfree86.org> for ATI driver merge.
  */
 
-#include "ativersion.h"
-
 #include "radeon_probe.h"
 #include "radeon_version.h"
 #include "atipciids.h"
@@ -61,19 +57,7 @@ int gRADEONEntityIndex = -1;
 static const OptionInfoRec *
 RADEONAvailableOptions(int chipid, int busid)
 {
-    int  i;
-
-    /*
-     * Return options defined in the radeon submodule which will have been
-     * loaded by this point.
-     */
-    if ((chipid >> 16) == PCI_VENDOR_ATI)
-	chipid -= PCI_VENDOR_ATI << 16;
-    for (i = 0; RADEONPciChipsets[i].PCIid > 0; i++) {
-	if (chipid == RADEONPciChipsets[i].PCIid)
-	    return RADEONOptionsWeak();
-    }
-    return NULL;
+    return RADEONOptionsWeak();
 }
 
 /* Return the string name for supported chipset 'n'; NULL otherwise. */
@@ -90,9 +74,9 @@ static Bool
 RADEONProbe(DriverPtr drv, int flags)
 {
     int      numUsed;
-    int      numDevSections, nATIGDev, nRadeonGDev;
+    int      numDevSections;
     int     *usedChips;
-    GDevPtr *devSections, *ATIGDevs, *RadeonGDevs;
+    GDevPtr *devSections;
     Bool     foundScreen = FALSE;
     int      i;
 
@@ -100,29 +84,9 @@ RADEONProbe(DriverPtr drv, int flags)
     if (!xf86GetPciVideoInfo()) return FALSE;
 #endif
 
-    /* Collect unclaimed device sections for both driver names */
-    nATIGDev    = xf86MatchDevice(ATI_NAME, &ATIGDevs);
-    nRadeonGDev = xf86MatchDevice(RADEON_NAME, &RadeonGDevs);
+    numDevSections = xf86MatchDevice(RADEON_NAME, &devSections);
 
-    if (!(numDevSections = nATIGDev + nRadeonGDev)) return FALSE;
-
-    if (!ATIGDevs) {
-	if (!(devSections = RadeonGDevs)) numDevSections = 1;
-	else                              numDevSections = nRadeonGDev;
-    } if (!RadeonGDevs) {
-	devSections    = ATIGDevs;
-	numDevSections = nATIGDev;
-    } else {
-	/* Combine into one list */
-	devSections = xnfalloc((numDevSections + 1) * sizeof(GDevPtr));
-	(void)memcpy(devSections,
-		     ATIGDevs, nATIGDev * sizeof(GDevPtr));
-	(void)memcpy(devSections + nATIGDev,
-		     RadeonGDevs, nRadeonGDev * sizeof(GDevPtr));
-	devSections[numDevSections] = NULL;
-	xfree(ATIGDevs);
-	xfree(RadeonGDevs);
-    }
+    if (!numDevSections) return FALSE;
 
     numUsed = xf86MatchPciInstances(RADEON_NAME,
 				    PCI_VENDOR_ATI,
commit a596c1618f72179a45289a50a1f9e89462ce9667
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Fri Feb 15 18:34:31 2008 +0200

    r128: do not compile in PciChipsets twice

diff --git a/src/Makefile.am b/src/Makefile.am
index 9e318ba..069076b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -199,7 +199,6 @@ EXTRA_DIST = \
 	mach64_common.h \
 	mach64_dri.h \
 	mach64_sarea.h \
-	r128_chipset.h \
 	r128_common.h \
 	r128_dri.h \
 	r128_dripriv.h \
diff --git a/src/r128_chipset.h b/src/r128_chipset.h
deleted file mode 100644
index e896f76..0000000
--- a/src/r128_chipset.h
+++ /dev/null
@@ -1,54 +0,0 @@
-static SymTabRec R128Chipsets[] = {
-    /* FIXME: The chipsets with (PCI/AGP) are not known wether they are AGP or
-     *        PCI, so I've labeled them as such in hopes users will submit
-     *        data if we're unable to gather it from official documentation
-     */
-    { PCI_CHIP_RAGE128LE, "ATI Rage 128 Mobility M3 LE (PCI)" },
-    { PCI_CHIP_RAGE128LF, "ATI Rage 128 Mobility M3 LF (AGP)" },
-    { PCI_CHIP_RAGE128MF, "ATI Rage 128 Mobility M4 MF (AGP)" },
-    { PCI_CHIP_RAGE128ML, "ATI Rage 128 Mobility M4 ML (AGP)" },
-    { PCI_CHIP_RAGE128PA, "ATI Rage 128 Pro GL PA (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PB, "ATI Rage 128 Pro GL PB (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PC, "ATI Rage 128 Pro GL PC (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PD, "ATI Rage 128 Pro GL PD (PCI)" },
-    { PCI_CHIP_RAGE128PE, "ATI Rage 128 Pro GL PE (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PF, "ATI Rage 128 Pro GL PF (AGP)" },
-    { PCI_CHIP_RAGE128PG, "ATI Rage 128 Pro VR PG (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PH, "ATI Rage 128 Pro VR PH (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PI, "ATI Rage 128 Pro VR PI (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PJ, "ATI Rage 128 Pro VR PJ (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PK, "ATI Rage 128 Pro VR PK (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PL, "ATI Rage 128 Pro VR PL (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PM, "ATI Rage 128 Pro VR PM (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PN, "ATI Rage 128 Pro VR PN (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PO, "ATI Rage 128 Pro VR PO (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PP, "ATI Rage 128 Pro VR PP (PCI)" },
-    { PCI_CHIP_RAGE128PQ, "ATI Rage 128 Pro VR PQ (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PR, "ATI Rage 128 Pro VR PR (PCI)" },
-    { PCI_CHIP_RAGE128PS, "ATI Rage 128 Pro VR PS (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PT, "ATI Rage 128 Pro VR PT (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PU, "ATI Rage 128 Pro VR PU (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PV, "ATI Rage 128 Pro VR PV (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PW, "ATI Rage 128 Pro VR PW (PCI/AGP)" },
-    { PCI_CHIP_RAGE128PX, "ATI Rage 128 Pro VR PX (PCI/AGP)" },
-    { PCI_CHIP_RAGE128RE, "ATI Rage 128 GL RE (PCI)" },
-    { PCI_CHIP_RAGE128RF, "ATI Rage 128 GL RF (AGP)" },
-    { PCI_CHIP_RAGE128RG, "ATI Rage 128 RG (AGP)" },
-    { PCI_CHIP_RAGE128RK, "ATI Rage 128 VR RK (PCI)" },
-    { PCI_CHIP_RAGE128RL, "ATI Rage 128 VR RL (AGP)" },
-    { PCI_CHIP_RAGE128SE, "ATI Rage 128 4X SE (PCI/AGP)" },
-    { PCI_CHIP_RAGE128SF, "ATI Rage 128 4X SF (PCI/AGP)" },
-    { PCI_CHIP_RAGE128SG, "ATI Rage 128 4X SG (PCI/AGP)" },
-    { PCI_CHIP_RAGE128SH, "ATI Rage 128 4X SH (PCI/AGP)" },
-    { PCI_CHIP_RAGE128SK, "ATI Rage 128 4X SK (PCI/AGP)" },
-    { PCI_CHIP_RAGE128SL, "ATI Rage 128 4X SL (PCI/AGP)" },
-    { PCI_CHIP_RAGE128SM, "ATI Rage 128 4X SM (AGP)" },
-    { PCI_CHIP_RAGE128SN, "ATI Rage 128 4X SN (PCI/AGP)" },
-    { PCI_CHIP_RAGE128TF, "ATI Rage 128 Pro ULTRA TF (AGP)" },
-    { PCI_CHIP_RAGE128TL, "ATI Rage 128 Pro ULTRA TL (AGP)" },
-    { PCI_CHIP_RAGE128TR, "ATI Rage 128 Pro ULTRA TR (AGP)" },
-    { PCI_CHIP_RAGE128TS, "ATI Rage 128 Pro ULTRA TS (AGP?)" },
-    { PCI_CHIP_RAGE128TT, "ATI Rage 128 Pro ULTRA TT (AGP?)" },
-    { PCI_CHIP_RAGE128TU, "ATI Rage 128 Pro ULTRA TU (AGP?)" },
-    { -1,                 NULL }
-};
diff --git a/src/r128_dri.c b/src/r128_dri.c
index da201e3..2927718 100644
--- a/src/r128_dri.c
+++ b/src/r128_dri.c
@@ -53,8 +53,8 @@
 
 				/* X and server generic header files */
 #include "xf86.h"
+#include "xf86PciInfo.h"
 #include "windowstr.h"
-#include "atipciids.h"
 
 #include "shadowfb.h"
 				/* GLX/DRI/DRM definitions */
diff --git a/src/r128_driver.c b/src/r128_driver.c
index 45917cd..0e693e0 100644
--- a/src/r128_driver.c
+++ b/src/r128_driver.c
@@ -86,6 +86,7 @@
 				/* X and server generic header files */
 #include "xf86.h"
 #include "xf86_OSproc.h"
+#include "xf86PciInfo.h"
 #include "xf86RAC.h"
 #include "xf86Resources.h"
 #include "xf86cmap.h"
@@ -103,9 +104,6 @@
 #define DPMS_SERVER
 #include <X11/extensions/dpms.h>
 
-#include "atipciids.h"
-#include "r128_chipset.h"
-
 #ifndef MAX
 #define MAX(a,b) ((a)>(b)?(a):(b))
 #endif
diff --git a/src/r128_probe.c b/src/r128_probe.c
index 5dd5cc9..75fae31 100644
--- a/src/r128_probe.c
+++ b/src/r128_probe.c
@@ -45,14 +45,63 @@
 
 #include "r128_probe.h"
 #include "r128_version.h"
-#include "atipciids.h"
 
 #include "xf86.h"
+#include "xf86PciInfo.h"
 #include "xf86Resources.h"
 
-#include "r128_chipset.h"
+SymTabRec R128Chipsets[] = {
+    { PCI_CHIP_RAGE128LE, "ATI Rage 128 Mobility M3 LE (PCI)" },
+    { PCI_CHIP_RAGE128LF, "ATI Rage 128 Mobility M3 LF (AGP)" },
+    { PCI_CHIP_RAGE128MF, "ATI Rage 128 Mobility M4 MF (AGP)" },
+    { PCI_CHIP_RAGE128ML, "ATI Rage 128 Mobility M4 ML (AGP)" },
+    { PCI_CHIP_RAGE128PA, "ATI Rage 128 Pro GL PA (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PB, "ATI Rage 128 Pro GL PB (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PC, "ATI Rage 128 Pro GL PC (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PD, "ATI Rage 128 Pro GL PD (PCI)" },
+    { PCI_CHIP_RAGE128PE, "ATI Rage 128 Pro GL PE (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PF, "ATI Rage 128 Pro GL PF (AGP)" },
+    { PCI_CHIP_RAGE128PG, "ATI Rage 128 Pro VR PG (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PH, "ATI Rage 128 Pro VR PH (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PI, "ATI Rage 128 Pro VR PI (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PJ, "ATI Rage 128 Pro VR PJ (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PK, "ATI Rage 128 Pro VR PK (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PL, "ATI Rage 128 Pro VR PL (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PM, "ATI Rage 128 Pro VR PM (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PN, "ATI Rage 128 Pro VR PN (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PO, "ATI Rage 128 Pro VR PO (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PP, "ATI Rage 128 Pro VR PP (PCI)" },
+    { PCI_CHIP_RAGE128PQ, "ATI Rage 128 Pro VR PQ (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PR, "ATI Rage 128 Pro VR PR (PCI)" },
+    { PCI_CHIP_RAGE128PS, "ATI Rage 128 Pro VR PS (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PT, "ATI Rage 128 Pro VR PT (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PU, "ATI Rage 128 Pro VR PU (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PV, "ATI Rage 128 Pro VR PV (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PW, "ATI Rage 128 Pro VR PW (PCI/AGP)" },
+    { PCI_CHIP_RAGE128PX, "ATI Rage 128 Pro VR PX (PCI/AGP)" },
+    { PCI_CHIP_RAGE128RE, "ATI Rage 128 GL RE (PCI)" },
+    { PCI_CHIP_RAGE128RF, "ATI Rage 128 GL RF (AGP)" },
+    { PCI_CHIP_RAGE128RG, "ATI Rage 128 RG (AGP)" },
+    { PCI_CHIP_RAGE128RK, "ATI Rage 128 VR RK (PCI)" },
+    { PCI_CHIP_RAGE128RL, "ATI Rage 128 VR RL (AGP)" },
+    { PCI_CHIP_RAGE128SE, "ATI Rage 128 4X SE (PCI/AGP)" },
+    { PCI_CHIP_RAGE128SF, "ATI Rage 128 4X SF (PCI/AGP)" },
+    { PCI_CHIP_RAGE128SG, "ATI Rage 128 4X SG (PCI/AGP)" },
+    { PCI_CHIP_RAGE128SH, "ATI Rage 128 4X SH (PCI/AGP)" },
+    { PCI_CHIP_RAGE128SK, "ATI Rage 128 4X SK (PCI/AGP)" },
+    { PCI_CHIP_RAGE128SL, "ATI Rage 128 4X SL (PCI/AGP)" },
+    { PCI_CHIP_RAGE128SM, "ATI Rage 128 4X SM (AGP)" },
+    { PCI_CHIP_RAGE128SN, "ATI Rage 128 4X SN (PCI/AGP)" },
+    { PCI_CHIP_RAGE128TF, "ATI Rage 128 Pro ULTRA TF (AGP)" },
+    { PCI_CHIP_RAGE128TL, "ATI Rage 128 Pro ULTRA TL (AGP)" },
+    { PCI_CHIP_RAGE128TR, "ATI Rage 128 Pro ULTRA TR (AGP)" },
+    { PCI_CHIP_RAGE128TS, "ATI Rage 128 Pro ULTRA TS (AGP?)" },
+    { PCI_CHIP_RAGE128TT, "ATI Rage 128 Pro ULTRA TT (AGP?)" },
+    { PCI_CHIP_RAGE128TU, "ATI Rage 128 Pro ULTRA TU (AGP?)" },
+    { -1,                 NULL }
+};
 
-PciChipsets R128PciChipsets[] = {
+static PciChipsets R128PciChipsets[] = {
     { PCI_CHIP_RAGE128LE, PCI_CHIP_RAGE128LE, RES_SHARED_VGA },
     { PCI_CHIP_RAGE128LF, PCI_CHIP_RAGE128LF, RES_SHARED_VGA },
     { PCI_CHIP_RAGE128MF, PCI_CHIP_RAGE128MF, RES_SHARED_VGA },
diff --git a/src/r128_probe.h b/src/r128_probe.h
index 719340a..59c9a00 100644
--- a/src/r128_probe.h
+++ b/src/r128_probe.h
@@ -56,7 +56,7 @@ typedef struct
 } R128EntRec, *R128EntPtr;
 
 /* r128_probe.c */
-extern PciChipsets           R128PciChipsets[];
+extern SymTabRec             R128Chipsets[];
 
 /* r128_driver.c */
 extern Bool                  R128PreInit(ScrnInfoPtr, int);
commit 99cd8ff9a7e15fc2b4e55f8bc020f584173a8c2d
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Fri Feb 15 18:33:51 2008 +0200

    ati: drop duplicate pci-id defines

diff --git a/src/atipciids.h b/src/atipciids.h
index 2953964..f24f8fb 100644
--- a/src/atipciids.h
+++ b/src/atipciids.h
@@ -40,13 +40,6 @@
 
 #include "ati_pciids_gen.h"
 
-#define PCI_CHIP_R520_7104		0x7104
-#define PCI_CHIP_RV515_7142             0x7142
-#define PCI_CHIP_RV515_7183             0x7183
-#define PCI_CHIP_RV530_71C5             0x71C5
-#define PCI_CHIP_R580_7249		0x7249
-#define PCI_CHIP_RV570_7280             0x7280
-
 /* Misc */
 #define PCI_CHIP_AMD761			0x700E
 
commit 146b01b51069dc227d0b125babb3f6957c9b9de2
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Fri Feb 15 18:33:29 2008 +0200

    mach64: clean probe a little
    
    do not report I/O ports now, they are reported later.

diff --git a/src/atiprobe.c b/src/atiprobe.c
index 6636a7e..5092073 100644
--- a/src/atiprobe.c
+++ b/src/atiprobe.c
@@ -367,13 +367,12 @@ ATIMach64ProbeIO
     ATIPtr      pATI
 )
 {
-    Bool ProbeSuccess = FALSE;
-
-#ifndef AVOID_CPIO
-
     /* Next, look for sparse I/O Mach64's */
     if (!PCI_REGION_SIZE(pVideo, 1))
     {
+
+#ifndef AVOID_CPIO
+
         static const IOADDRESS Mach64SparseIOBases[] = {
             0x02ECU,
             0x01CCU,
@@ -386,7 +385,7 @@ ATIMach64ProbeIO
         pciConfigPtr pPCI = pVideo->thisCard;
 
         if (pPCI == NULL)
-            goto SkipSparse;
+            return FALSE;
 #endif
 
         PCI_READ_LONG(pVideo, &PciReg, PCI_REG_USERCONFIG);
@@ -399,7 +398,7 @@ ATIMach64ProbeIO
                 "because it has neither a block, nor a sparse, I/O base.\n",
                 PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
 
-            goto SkipSparse;
+            return FALSE;
         }
 
         /* Possibly fix block I/O indicator */
@@ -426,92 +425,51 @@ ATIMach64ProbeIO
                 "set option \"probe_sparse\" to force sparse I/O probing.\n",
                 PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
 
-            goto SkipSparse;
+            return FALSE;
         }
 
         pATI->CPIOBase = Mach64SparseIOBases[j];
         pATI->CPIODecoding = SPARSE_IO;
         pATI->PCIInfo = pVideo;
 
-        if (!ATIMach64Probe(pATI, pVideo, pATI->Chip))
-        {
-            xf86Msg(X_WARNING, MACH64_NAME ": "
-                "PCI Mach64 in slot %d:%d:%d could not be detected!\n",
-                PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
-        }
-        else
-        {
-            ProbeSuccess = TRUE;
-            xf86Msg(X_INFO, MACH64_NAME ": "
-                "Shared PCI Mach64 in slot %d:%d:%d with sparse PIO base"
-                " 0x%04lX detected.\n",
-                PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo),
-                Mach64SparseIOBases[j]);
-
-            if (pATI->VGAAdapter)
-                ATIFindVGA(pVideo, pATI);
-        }
-    }
-
-SkipSparse:
-
 #else /* AVOID_CPIO */
 
-    if (!PCI_REGION_SIZE(pVideo, 1))
-    {
         /* The adapter's CPIO base is of little concern here */
         pATI->CPIOBase = 0;
         pATI->CPIODecoding = SPARSE_IO;
         pATI->PCIInfo = pVideo;
 
-        if (ATIMach64Probe(pATI, pVideo, pATI->Chip))
-        {
-            ProbeSuccess = TRUE;
-            xf86Msg(X_INFO, MACH64_NAME ": "
-                "Shared PCI Mach64 in slot %d:%d:%d with Block 0 base"
-                " 0x%08lX detected.\n",
-                PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo),
-                pATI->Block0Base);
-        }
-        else
-        {
-            xf86Msg(X_WARNING, MACH64_NAME ": "
-                "PCI Mach64 in slot %d:%d:%d could not be detected!\n",
-                PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
-        }
-    }
-
 #endif /* AVOID_CPIO */
 
+    }
+
     /* Lastly, look for block I/O devices */
     if (PCI_REGION_SIZE(pVideo, 1))
     {
         pATI->CPIOBase = PCI_REGION_BASE(pVideo, 1, REGION_IO);
         pATI->CPIODecoding = BLOCK_IO;
         pATI->PCIInfo = pVideo;
+    }
 
-        if (ATIMach64Probe(pATI, pVideo, pATI->Chip))
-        {
-            ProbeSuccess = TRUE;
-            xf86Msg(X_INFO, MACH64_NAME ": "
-                "Shared PCI/AGP Mach64 in slot %d:%d:%d detected.\n",
-                PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
+    if (!ATIMach64Probe(pATI, pVideo, pATI->Chip))
+    {
+        xf86Msg(X_WARNING, MACH64_NAME ": "
+            "Mach64 in slot %d:%d:%d could not be detected!\n",
+            PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
+
+        return FALSE;
+    }
+
+    xf86Msg(X_INFO, MACH64_NAME ": "
+        "Mach64 in slot %d:%d:%d detected.\n",
+        PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
 
 #ifndef AVOID_CPIO
 
-            if (pATI->VGAAdapter)
-                ATIFindVGA(pVideo, pATI);
+    if (pATI->VGAAdapter)
+        ATIFindVGA(pVideo, pATI);
 
 #endif /* AVOID_CPIO */
 
-        }
-        else
-        {
-            xf86Msg(X_WARNING, MACH64_NAME ": "
-                "PCI/AGP Mach64 in slot %d:%d:%d could not be detected!\n",
-                PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
-        }
-    }
-
-    return ProbeSuccess;
+    return TRUE;
 }
commit f47d461331a032f9bdcf6f63336e848778cec6cc
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Fri Feb 15 18:32:56 2008 +0200

    mach64: minor cosmetic, I2C type

diff --git a/src/atipreinit.c b/src/atipreinit.c
index 86ef80d..f89f5b7 100644
--- a/src/atipreinit.c
+++ b/src/atipreinit.c
@@ -326,7 +326,8 @@ ati_bios_mmedia
     ScrnInfoPtr  pScreenInfo,
     ATIPtr       pATI,
     CARD8       *BIOS,
-    unsigned int VideoTable
+    unsigned int VideoTable,
+    unsigned int HardwareTable
 )
 {
     pATI->Audio = ATI_AUDIO_NONE;
@@ -368,6 +369,11 @@ ati_bios_mmedia
                 break;
         }
     }
+
+    if (HardwareTable > 0)
+    {
+        pATI->I2CType = BIOSByte(HardwareTable + 0x06U) & 0x0FU;
+    }
 }
 
 /*
@@ -968,17 +974,15 @@ ATIPreInit
             if (BIOSWord(ROMTable - 0x02U) >= 0x004AU)
             {
                 HardwareTable = BIOSWord(ROMTable + 0x48U);
-                if (((HardwareTable + 0x08U) <= BIOSSize) &&
-                    !memcmp(BIOS + HardwareTable, "$ATI", 4))
-                    pATI->I2CType = BIOSByte(HardwareTable + 0x06U) & 0x0FU;
-                else
+                if (((HardwareTable + 0x08U) > BIOSSize) ||
+                    (memcmp(BIOS + HardwareTable, "$ATI", 4) != 0))
                     HardwareTable = 0;
             }
         }
 
         ati_bios_clock(pScreenInfo, pATI, BIOS, ClockTable, pGDev);
 
-        ati_bios_mmedia(pScreenInfo, pATI, BIOS, VideoTable);
+        ati_bios_mmedia(pScreenInfo, pATI, BIOS, VideoTable, HardwareTable);
 
         if (pATI->LCDPanelID >= 0)
         {


More information about the xorg-commit mailing list