Ian Romanick wrote:

Sven Luther wrote:

On Thu, Jul 31, 2003 at 09:02:08AM -0700, Ian Romanick wrote:

Keith Whitwell wrote:

It would be simple to add some checking to ensure the chipid is recognized by the 3d driver, just hasn't been done yet.


Let me work up a patch that does this in a more generally way. The current big switch-statement is somewhat unpleasant. Do the embedded drivers have a header file where they get PCI IDs? I assume that xf86PciInfo.h is not available. :)


Notice that in order to more easily build 2D drivers of the CVS branch
with the latest released stable driver SDK, it makes more sense to move
the pci id information out of the xf86PciInfo.h file and into each
individual drivers. With the new (well, new as in 4.x or something such)
driver architecture, the xf86PciInfo.h is not really needed anymore,
since each driver knows how to detect supported cards himself.

Maybe doing something similar for the 3D drivers would be a step in the
right direction, instead of importing the monolitic xf86PciInfo.h file.


Agreed. The direction I plan to go is have a Python script that will process pci.ids and generate a table using the data there (much like is done in the Linux kernel's PCI driver). Basically, the table will be of structures like so:

struct driPCIInfoRec {
    uint_fast16_t   device_id;
    uint_fast16_t   device_vendor;
    uint_fast16_t   subsystem_id;
    uint_fast16_t   subsystem_vendor;

    const char * device_name;
    const char * device_driver;

    union {
        int    i;
        void * p;
    } device_data;
};

The script will pull the first 5 fields from pci.ids, and the remaining 2 will be supplied as parameters. The last field could store things like G200 vs. G400 for the MGA driver, or TCL vs. no-TCL for the Radeon driver, etc.

Where would we want such a script to live in the tree? We wouldn't want it to run as part of the build process because pci.ids may not always be available. We'd want to "periodically" run the script against an known good pci.ids to generate the .h files for each driver and commit the new .h files. There are some scripts like that in Mesa, but I don't think they exist in the DRI tree.

This does make one subtle, but VERY important change to the policy carried out by the driver's init function. Right now all of the drivers will try to run even if they don't recognize the PCI ID. If we go this route, that will change. If a device ID isn't in the table, the driver will bail. Given what Keith and Michel had said about the embedded branch, I think this is the better way to go. Thoughts?

The nice part about doing it this way is that, as new devices come out, we just have to make sure that pci.ids is up to date (a good idea anyway!) and regenerate / commit the .h files for the drivers. I had shared Michel's maintainence worries over the old switch-statement based approach, and I think this solves that.

Okay, here it is. r200_pci_info.h was generated by gen_pci_info.py using r200_card_info.txt and a patched version of the 2.6.0-test2 pci.ids file (that patch is also attached).


./gen_pci_info.py r200_card_info.txt \
        ~/devel/linux-2.6.0-test2/drivers/pci/pci.ids > r200_pci_info.h

We would just need to keep r200_card_info.txt and our favorite pci.ids up-to-date, and the rest is magic. :)

The remaining patch modifies the DDX and the DRI driver to exchange PCI information and use that to identify the chip.

Is this to everyone's likeing?
Index: lib/GL/mesa/src/drv/common/utils.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/common/utils.c,v
retrieving revision 1.3
diff -u -d -r1.3 utils.c
--- lib/GL/mesa/src/drv/common/utils.c  2 May 2003 21:41:37 -0000       1.3
+++ lib/GL/mesa/src/drv/common/utils.c  2 Aug 2003 03:17:44 -0000
@@ -180,3 +180,54 @@
 
    return GL_TRUE;
 }
+
+
+
+
+const struct driPCIInfoRec *
+driFindPCIInfo( uint_fast16_t device_id, uint_fast16_t device_vendor,
+               uint_fast16_t subsys_id, uint_fast16_t subsys_vendor,
+               const struct driPCIInfoRec * pci_info )
+{
+   const struct driPCIInfoRec * best_match = NULL;
+   unsigned best_score = 0;
+   unsigned i;
+
+
+   for ( i = 0 ; pci_info[i].device_id != 0x0000 ; i++ ) {
+      if ( (pci_info[i].device_vendor == device_vendor)
+          && (pci_info[i].device_id == device_id) ) {
+        unsigned   score = 0;
+
+        /* There are several possible "match" cases.  If the stored subsystem
+         * vendor and ID are both 0x0000, then it scores 1.  If the subsystem
+         * ID is 0x0000 and the subsystem vendor matches, then it scores 2.
+         * If both the subsystem vendor and ID match, it is a perfect match
+         * and scores 3.  Any other case is not a match.
+         *
+         * Ideally, for each PCI vendor / ID pair in the supplied table there
+         * should be one entry with a subsystem vendor / ID pair of
+         * 0x0000 / 0x0000.
+         */
+
+        if ( pci_info[i].subsystem_vendor == 0 ) {
+           score = 1;
+        }
+        else if ( pci_info[i].subsystem_vendor == subsys_vendor ) {
+           
+           if ( pci_info[i].subsystem_id == 0 ) {
+              score = 2;
+           }
+           else if ( pci_info[i].subsystem_id == subsys_id ) {
+              score = 3;
+           }
+        }
+        
+        if ( score > best_score ) {
+           best_match = & pci_info[i];
+        }
+      }
+   }
+
+   return best_match;
+}
Index: lib/GL/mesa/src/drv/common/utils.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/common/utils.h,v
retrieving revision 1.2
diff -u -d -r1.2 utils.h
--- lib/GL/mesa/src/drv/common/utils.h  30 Apr 2003 01:50:39 -0000      1.2
+++ lib/GL/mesa/src/drv/common/utils.h  2 Aug 2003 03:17:44 -0000
@@ -38,6 +38,20 @@
     unsigned     flag;
 };
 
+struct driPCIInfoRec {
+   uint_fast16_t   device_id;
+   uint_fast16_t   device_vendor;
+   uint_fast16_t   subsystem_id;
+   uint_fast16_t   subsystem_vendor;
+   
+   const char * device_name;
+   const char * driver;
+   union {
+      int    i;
+      void * p;
+   } device_private;
+};
+
 extern unsigned driParseDebugString( const char * debug,
     const struct dri_debug_control * control );
 
@@ -50,5 +64,9 @@
 extern GLboolean driCheckDriDdxDrmVersions( __DRIscreenPrivate *sPriv,
     const char * driver_name, int dri_major, int dri_minor,
     int ddx_major, int ddx_minor, int drm_major, int drm_minor );
+
+extern const struct driPCIInfoRec * driFindPCIInfo( uint_fast16_t device_id,
+    uint_fast16_t device_vendor, uint_fast16_t subsys_id,
+    uint_fast16_t subsys_vendor, const struct driPCIInfoRec * pci_info );
 
 #endif /* DRI_DEBUG_H */
Index: lib/GL/mesa/src/drv/r200/r200_context.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/r200/r200_context.c,v
retrieving revision 1.25
diff -u -d -r1.25 r200_context.c
--- lib/GL/mesa/src/drv/r200/r200_context.c     21 May 2003 17:32:07 -0000      1.25
+++ lib/GL/mesa/src/drv/r200/r200_context.c     2 Aug 2003 03:17:44 -0000
@@ -100,8 +100,8 @@
       return (GLubyte *)"Tungsten Graphics, Inc.";
 
    case GL_RENDERER:
-      offset = driGetRendererString( buffer, "R200", DRIVER_DATE,
-                                    agp_mode );
+      offset = driGetRendererString( buffer, rmesa->r200Screen->device_name,
+                                    DRIVER_DATE, agp_mode );
 
       sprintf( & buffer[ offset ], " %sTCL",
               !(rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)
Index: lib/GL/mesa/src/drv/r200/r200_screen.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/r200/r200_screen.c,v
retrieving revision 1.11
diff -u -d -r1.11 r200_screen.c
--- lib/GL/mesa/src/drv/r200/r200_screen.c      21 May 2003 17:32:08 -0000      1.11
+++ lib/GL/mesa/src/drv/r200/r200_screen.c      2 Aug 2003 03:17:44 -0000
@@ -49,20 +49,7 @@
 
 #include "glxextensions.h"
 
-#if 1
-/* Including xf86PciInfo.h introduces a bunch of errors...
- */
-#define PCI_CHIP_R200_QD       0x5144
-#define PCI_CHIP_R200_QE       0x5145
-#define PCI_CHIP_R200_QF       0x5146
-#define PCI_CHIP_R200_QG       0x5147
-#define PCI_CHIP_R200_QY       0x5159
-#define PCI_CHIP_R200_QZ       0x515A
-#define PCI_CHIP_R200_LW       0x4C57 
-#define PCI_CHIP_R200_LY       0x4C59
-#define PCI_CHIP_R200_LZ       0x4C5A
-#define PCI_CHIP_RV200_QW      0x5157 /* Radeon 7500 - not an R200 at all */
-#endif
+#include "r200_pci_info.h"
 
 static r200ScreenPtr __r200Screen;
 
@@ -75,10 +62,31 @@
 {
    r200ScreenPtr screen;
    RADEONDRIPtr dri_priv = (RADEONDRIPtr)sPriv->pDevPriv;
+   uint_fast16_t  device_id;
+   uint_fast16_t  device_vendor;
+   uint_fast16_t  subsys_id;
+   uint_fast16_t  subsys_vendor;
+   const struct driPCIInfoRec * pci_info;
 
    if ( ! driCheckDriDdxDrmVersions( sPriv, "R200", 4, 0, 4, 0, 1, 5 ) )
       return NULL;
 
+   /* Newer versions of the XFree86 DDX driver supply the device vendor,
+    * subsystem ID, and subsystem vendor in addition to the device ID.
+    */
+
+   device_id = dri_priv->deviceID;
+   if ( (sPriv->ddxMajor == 4) && (sPriv->ddxMinor >= 1) ) {
+      device_vendor = dri_priv->device_vendor;
+      subsys_id     = dri_priv->subsys_id;
+      subsys_vendor = dri_priv->subsys_vendor;
+   }
+   else {
+      device_vendor = 0x1002;
+      subsys_id     = 0x0000;
+      subsys_vendor = 0x0000;
+   }
+
    /* Allocate the private area */
    screen = (r200ScreenPtr) CALLOC( sizeof(*screen) );
    if ( !screen ) {
@@ -87,25 +95,19 @@
       return NULL;
    }
 
-   switch ( dri_priv->deviceID ) {
-   case PCI_CHIP_R200_QD:
-   case PCI_CHIP_R200_QE:
-   case PCI_CHIP_R200_QF:
-   case PCI_CHIP_R200_QG:
-   case PCI_CHIP_R200_QY:
-   case PCI_CHIP_R200_QZ:
-   case PCI_CHIP_RV200_QW:
-   case PCI_CHIP_R200_LW:
-   case PCI_CHIP_R200_LY:
-   case PCI_CHIP_R200_LZ:
-      __driUtilMessage("r200CreateScreen(): Device isn't an r200!\n");
-      FREE( screen );
-      return NULL;      
-   default:
-      screen->chipset = R200_CHIPSET_R200;
-      break;
-   }
 
+   pci_info = driFindPCIInfo( device_vendor, device_id,
+                             subsys_vendor, subsys_id,
+                             r200_pci_info );
+   if ( pci_info != NULL ) {
+      screen->chipset     = pci_info->device_private.i;
+      screen->device_name = pci_info->device_name;
+   }
+   else {
+      screen->chipset     = RADEON_CHIPSET_R200;
+      screen->device_name = "R200 [Unknown generic R200-type]";
+   }
+      
 
    /* This is first since which regions we map depends on whether or
     * not we are using a PCI card.
Index: lib/GL/mesa/src/drv/r200/r200_screen.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/r200/r200_screen.h,v
retrieving revision 1.6
diff -u -d -r1.6 r200_screen.h
--- lib/GL/mesa/src/drv/r200/r200_screen.h      30 Apr 2003 01:50:48 -0000      1.6
+++ lib/GL/mesa/src/drv/r200/r200_screen.h      2 Aug 2003 03:17:44 -0000
@@ -50,8 +50,8 @@
    drmAddress map;                     /* Mapping of the DRM region */
 } r200RegionRec, *r200RegionPtr;
 
-#define R200_CHIPSET_R200   1
-#define R200_CHIPSET_MOBILITY 2
+#define RADEON_CHIPSET_R200            1
+#define RADEON_CHIPSET_R200_MOBILITY   2
 
 
 #define R200_NR_TEX_HEAPS 2
@@ -59,6 +59,7 @@
 typedef struct {
 
    int chipset;
+   const char * device_name;
    int cpp;
    int IsPCI;                          /* Current card is a PCI card */
    int AGPMode;
Index: programs/Xserver/hw/xfree86/drivers/ati/radeon.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h,v
retrieving revision 1.35
diff -u -d -r1.35 radeon.h
--- programs/Xserver/hw/xfree86/drivers/ati/radeon.h    25 Mar 2003 11:19:48 -0000     
 1.35
+++ programs/Xserver/hw/xfree86/drivers/ati/radeon.h    2 Aug 2003 03:17:45 -0000
@@ -263,6 +263,8 @@
     pciVideoPtr       PciInfo;
     PCITAG            PciTag;
     int               Chipset;
+    int               SubChipset;
+    int               SubVendor;
     RADEONChipFamily  ChipFamily;
 
     Bool              FBDev;
Index: programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c,v
retrieving revision 1.49
diff -u -d -r1.49 radeon_dri.c
--- programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c        9 Jul 2003 23:21:15 
-0000       1.49
+++ programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c        2 Aug 2003 03:17:45 
-0000
@@ -1547,6 +1547,10 @@
     pRADEONDRI->perctx_sarea_size = info->perctx_sarea_size;
 #endif
 
+    pRADEONDRI->device_vendor     = 0x1002;
+    pRADEONDRI->subsys_id         = info->SubChipset;
+    pRADEONDRI->subsys_vendor     = info->SubVendor;
+
     /* Have shadowfb run only while there is 3d active. */
     if (info->allowPageFlip /* && info->drmMinor >= 3 */) {
        ShadowFBInit( pScreen, RADEONDRIRefreshArea );
Index: programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.h,v
retrieving revision 1.11
diff -u -d -r1.11 radeon_dri.h
--- programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.h        25 Mar 2003 11:19:52 
-0000      1.11
+++ programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.h        2 Aug 2003 03:17:45 
-0000
@@ -102,6 +102,9 @@
 #ifdef PER_CONTEXT_SAREA
     drmSize      perctx_sarea_size;
 #endif
+    int           device_vendor;       /* PCI device vendor */
+    int           subsys_id;           /* PCI device subsystem ID */
+    int           subsys_vendor;       /* PCI device subsystem vendor */
 } RADEONDRIRec, *RADEONDRIPtr;
 
 #endif
Index: programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c,v
retrieving revision 1.58
diff -u -d -r1.58 radeon_driver.c
--- programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c     14 Jul 2003 22:09:45 
-0000      1.58
+++ programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c     2 Aug 2003 03:17:45 
-0000
@@ -1332,15 +1332,21 @@
     unsigned char *RADEONMMIO;
 
                                /* Chipset */
-    from = X_PROBED;
     if (dev->chipset && *dev->chipset) {
-       info->Chipset  = xf86StringToToken(RADEONChipsets, dev->chipset);
-       from           = X_CONFIG;
+       info->Chipset    = xf86StringToToken(RADEONChipsets, dev->chipset);
+       info->SubChipset = 0;
+       info->SubVendor  = 0;
+       from             = X_CONFIG;
     } else if (dev->chipID >= 0) {
-       info->Chipset  = dev->chipID;
-       from           = X_CONFIG;
+       info->Chipset    = dev->chipID;
+       info->SubChipset = 0;
+       info->SubVendor  = 0;
+       from             = X_CONFIG;
     } else {
-       info->Chipset = info->PciInfo->chipType;
+       info->Chipset    = info->PciInfo->chipType;
+       info->SubChipset = info->PciInfo->subsysCard;
+       info->SubVendor  = info->PciInfo->subsysVendor;
+       from             = X_PROBED;
     }
 
     pScrn->chipset = (char *)xf86TokenToString(RADEONChipsets, info->Chipset);
Index: programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h,v
retrieving revision 1.5
diff -u -d -r1.5 radeon_version.h
--- programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h    25 Mar 2003 11:19:53 
-0000      1.5
+++ programs/Xserver/hw/xfree86/drivers/ati/radeon_version.h    2 Aug 2003 03:17:45 
-0000
@@ -41,8 +41,8 @@
 #define RV250_DRIVER_NAME    "r200"
 
 #define RADEON_VERSION_MAJOR 4
-#define RADEON_VERSION_MINOR 0
-#define RADEON_VERSION_PATCH 1
+#define RADEON_VERSION_MINOR 1
+#define RADEON_VERSION_PATCH 0
 
 #ifndef RADEON_VERSION_EXTRA
 #define RADEON_VERSION_EXTRA ""
/* DO NOT EDIT - This file generated automtically by gen_pci_info.py script */

/* This file is intended to be included by a device driver and is used to
 * indentify the specific graphics chip used in the system.
 */

static const struct driPCIInfoRec r200_pci_info[] = {
/*   device  device  subdev  subdev */
/*   vendor    ID    vendor    ID   */
   { 0x1002, 0x4242, 0x0000, 0x0000, "R200 BB [Radeon All-in-Wonder 8500DV]", "r200", 
{ .i = RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4242, 0x1002, 0x02aa, "R200 BB [Radeon 8500 All-in-Wonder DV Edition]", 
"r200", { .i = RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4964, 0x0000, 0x0000, "RV250 Id [Radeon 9000]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4965, 0x0000, 0x0000, "RV250 Ie [Radeon 9000]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4966, 0x0000, 0x0000, "RV250 If [Radeon 9000]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4966, 0x10f1, 0x0002, "RV250 If [Tachyon G9000 PRO]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4966, 0x148c, 0x2039, "RV250 If [Radeon 9000 Pro \"Evil Commando\"]", 
"r200", { .i = RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4966, 0x1509, 0x9a00, "RV250 If [Radeon 9000 \"AT009\"]", "r200", { .i 
= RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4966, 0x174b, 0x7176, "RV250 If [Sapphire Radeon 9000 Pro]", "r200", { 
.i = RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4966, 0x174b, 0x7192, "RV250 If [Radeon 9000 \"Atlantis\"]", "r200", { 
.i = RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4966, 0x17af, 0x2005, "RV250 If [Excalibur Radeon 9000 Pro]", "r200", { 
.i = RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4966, 0x17af, 0x2006, "RV250 If [Excalibur Radeon 9000]", "r200", { .i 
= RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4967, 0x0000, 0x0000, "RV250 Ig [Radeon 9000]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x496e, 0x0000, 0x0000, "RV250 In [Radeon 9000] (Secondary)", "r200", { 
.i = RADEON_CHIPSET_R200 } },
   { 0x1002, 0x496f, 0x0000, 0x0000, "RV250 Io [Radeon 9000] (Secondary)", "r200", { 
.i = RADEON_CHIPSET_R200 } },
   { 0x1002, 0x4c64, 0x0000, 0x0000, "RV250 Ld [Radeon Mobility M9]", "r200", { .i = 
RADEON_CHIPSET_R200_MOBILITY } },
   { 0x1002, 0x4c65, 0x0000, 0x0000, "RV250 Le [Radeon Mobility M9]", "r200", { .i = 
RADEON_CHIPSET_R200_MOBILITY } },
   { 0x1002, 0x4c66, 0x0000, 0x0000, "RV250 Lf [Radeon Mobility M9-GL]", "r200", { .i 
= RADEON_CHIPSET_R200_MOBILITY } },
   { 0x1002, 0x4c67, 0x0000, 0x0000, "RV250 Lg [Radeon Mobility M9]", "r200", { .i = 
RADEON_CHIPSET_R200_MOBILITY } },
   { 0x1002, 0x5148, 0x0000, 0x0000, "R200 QH [Radeon 8500]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5148, 0x1002, 0x0152, "R200 QH [FireGL 8800]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5148, 0x1002, 0x0172, "R200 QH [FireGL 8700]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5149, 0x0000, 0x0000, "R200 QI [Radeon 8500]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x514a, 0x0000, 0x0000, "R200 QJ [Radeon 8500]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x514b, 0x0000, 0x0000, "R200 QK [Radeon 8500]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x514c, 0x0000, 0x0000, "R200 QL [Radeon 8500 LE]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x514c, 0x1002, 0x003a, "R200 QL [Radeon 8500 LE]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x514c, 0x1002, 0x013a, "R200 QL [Radeon 8500]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x514c, 0x148c, 0x2026, "R200 QL [Radeon 8500 Evil Master II Multi 
Display Edition]", "r200", { .i = RADEON_CHIPSET_R200 } },
   { 0x1002, 0x514c, 0x174b, 0x7149, "R200 QL [Sapphire Radeon 8500 LE]", "r200", { .i 
= RADEON_CHIPSET_R200 } },
   { 0x1002, 0x514d, 0x0000, 0x0000, "R200 QM [Radeon 9100]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x514e, 0x0000, 0x0000, "R200 QN [Radeon 9100]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x514f, 0x0000, 0x0000, "R200 QO [Radeon 9100]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5168, 0x0000, 0x0000, "R200 Qh [Radeon 8500]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5169, 0x0000, 0x0000, "R200 Qi [Radeon 8500]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x516a, 0x0000, 0x0000, "R200 Qj [Radeon 8500]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x516b, 0x0000, 0x0000, "R200 Qk [Radeon 8500]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x516c, 0x0000, 0x0000, "R200 Ql [Radeon 8500]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x516d, 0x0000, 0x0000, "R200 Qm [Radeon 9100] (Secondary)", "r200", { .i 
= RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5941, 0x0000, 0x0000, "RV280 [Radeon 9200]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5960, 0x0000, 0x0000, "RV280 [Radeon 9200]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5961, 0x0000, 0x0000, "RV280 [Radeon 9200]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5962, 0x0000, 0x0000, "RV280 [Radeon 9200]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5963, 0x0000, 0x0000, "RV280 [Radeon 9200]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5968, 0x0000, 0x0000, "RV280 [Radeon 9200]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x5969, 0x0000, 0x0000, "RV280 [Radeon 9200]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x596a, 0x0000, 0x0000, "RV280 [Radeon 9200]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x1002, 0x596b, 0x0000, 0x0000, "RV280 [Radeon 9200]", "r200", { .i = 
RADEON_CHIPSET_R200 } },
   { 0x0000, 0x0000, 0x0000, 0x0000, NULL, NULL, { .i = 0 } },
};
# PCI info for the DRI R200 driver.  The first non-comment /
# non-whitespace line is the name of the table.  The remaining lines
# name the device vendor / ID to match.  In generated table, the third
# field becomes the driver name and the fourth field becomes the
# device_private.

r200_pci_info
0x1002 0x4242 r200 .i = RADEON_CHIPSET_R200
0x1002 0x4964 r200 .i = RADEON_CHIPSET_R200
0x1002 0x4965 r200 .i = RADEON_CHIPSET_R200
0x1002 0x4966 r200 .i = RADEON_CHIPSET_R200
0x1002 0x4967 r200 .i = RADEON_CHIPSET_R200
0x1002 0x496E r200 .i = RADEON_CHIPSET_R200
0x1002 0x496F r200 .i = RADEON_CHIPSET_R200
0x1002 0x4c64 r200 .i = RADEON_CHIPSET_R200_MOBILITY
0x1002 0x4c65 r200 .i = RADEON_CHIPSET_R200_MOBILITY
0x1002 0x4c66 r200 .i = RADEON_CHIPSET_R200_MOBILITY
0x1002 0x4c67 r200 .i = RADEON_CHIPSET_R200_MOBILITY
0x1002 0x5148 r200 .i = RADEON_CHIPSET_R200
0x1002 0x5149 r200 .i = RADEON_CHIPSET_R200
0x1002 0x514A r200 .i = RADEON_CHIPSET_R200
0x1002 0x514B r200 .i = RADEON_CHIPSET_R200
0x1002 0x514C r200 .i = RADEON_CHIPSET_R200
0x1002 0x514D r200 .i = RADEON_CHIPSET_R200
0x1002 0x514E r200 .i = RADEON_CHIPSET_R200
0x1002 0x514F r200 .i = RADEON_CHIPSET_R200
0x1002 0x5168 r200 .i = RADEON_CHIPSET_R200
0x1002 0x5169 r200 .i = RADEON_CHIPSET_R200
0x1002 0x516A r200 .i = RADEON_CHIPSET_R200
0x1002 0x516B r200 .i = RADEON_CHIPSET_R200
0x1002 0x516C r200 .i = RADEON_CHIPSET_R200
0x1002 0x516D r200 .i = RADEON_CHIPSET_R200

# These are the RV280 chips.

0x1002 0x5941 r200 .i = RADEON_CHIPSET_R200
0x1002 0x5960 r200 .i = RADEON_CHIPSET_R200
0x1002 0x5961 r200 .i = RADEON_CHIPSET_R200
0x1002 0x5962 r200 .i = RADEON_CHIPSET_R200
0x1002 0x5963 r200 .i = RADEON_CHIPSET_R200
0x1002 0x5968 r200 .i = RADEON_CHIPSET_R200
0x1002 0x5969 r200 .i = RADEON_CHIPSET_R200
0x1002 0x596A r200 .i = RADEON_CHIPSET_R200
0x1002 0x596B r200 .i = RADEON_CHIPSET_R200
--- /usr/src/linux-2.6.0-test2/drivers/pci/pci.ids      Sun Jul 27 10:02:34 2003
+++ ./pci.ids   Thu Jul 31 12:19:35 2003
@@ -162,8 +162,8 @@
        9100  INI-9100/9100W SCSI Host
 1002  ATI Technologies Inc
        4158  68800AX [Mach32]
-       4242  Radeon R200 BB [Radeon All in Wonder 8500DV]
-               1002 02aa  Radeon 8500 AIW DV Edition
+       4242  R200 BB [Radeon All-in-Wonder 8500DV]
+               1002 02aa  R200 BB [Radeon 8500 All-in-Wonder DV Edition]
        4336  Radeon Mobility U1
        4354  215CT [Mach64 CT]
        4358  210888CX [Mach64 CX]
@@ -232,18 +232,19 @@
        475a  3D Rage IIC AGP
                1002 0087  Rage 3D IIC
                1002 475a  Rage IIC AGP
-       4964  Radeon R250 Id [Radeon 9000]
-       4965  Radeon R250 Ie [Radeon 9000]
-       4966  Radeon R250 If [Radeon 9000]
-               10f1 0002  R250 If [Tachyon G9000 PRO]
-               148c 2039  R250 If [Radeon 9000 Pro "Evil Commando"]
-               1509 9a00  R250 If [Radeon 9000 "AT009"]
-               174b 7176  R250 If [Sapphire Radeon 9000 Pro]
-               174b 7192  R250 If [Radeon 9000 "Atlantis"]
-               17af 2005  R250 If [Excalibur Radeon 9000 Pro]
-               17af 2006  R250 If [Excalibur Radeon 9000]
-       4967  Radeon R250 Ig [Radeon 9000]
-       496e  Radeon R250 [Radeon 9000] (Secondary)
+       4964  RV250 Id [Radeon 9000]
+       4965  RV250 Ie [Radeon 9000]
+       4966  RV250 If [Radeon 9000]
+               10f1 0002  RV250 If [Tachyon G9000 PRO]
+               148c 2039  RV250 If [Radeon 9000 Pro "Evil Commando"]
+               1509 9a00  RV250 If [Radeon 9000 "AT009"]
+               174b 7176  RV250 If [Sapphire Radeon 9000 Pro]
+               174b 7192  RV250 If [Radeon 9000 "Atlantis"]
+               17af 2005  RV250 If [Excalibur Radeon 9000 Pro]
+               17af 2006  RV250 If [Excalibur Radeon 9000]
+       4967  RV250 Ig [Radeon 9000]
+       496e  RV250 In [Radeon 9000] (Secondary)
+       496f  RV250 Io [Radeon 9000] (Secondary)
        4c42  3D Rage LT Pro AGP-133
                0e11 b0e8  Rage 3D LT Pro
                0e11 b10e  3D Rage LT Pro (Compaq Armada 1750)
@@ -255,6 +256,7 @@
        4c44  3D Rage LT Pro AGP-66
        4c45  Rage Mobility M3 AGP
        4c46  Rage Mobility M3 AGP 2x
+               1014 0155  Rage Mobility M3 AGP [ThinkPad A22p]
        4c47  3D Rage LT-G 215LG
        4c49  3D Rage LT Pro
                1002 0004  Rage LT Pro
@@ -271,26 +273,26 @@
        4c52  Rage Mobility P/M
        4c53  Rage Mobility L
        4c54  264LT [Mach64 LT]
-       4c57  Radeon Mobility M7 LW [Radeon Mobility 7500]
-               1014 0517  ThinkPad T30
-               1028 00e6  Radeon Mobility M7 LW (Dell Inspiron 8100)
-       4c58  Radeon Mobility M7 LX [Radeon Mobility FireGL 7800]
-       4c59  Radeon Mobility M6 LY
-               1014 0235  ThinkPad A30p (2653-64G)
-               1014 0239  ThinkPad X22/X23/X24
-               104d 80e7  VAIO PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP
-       4c5a  Radeon Mobility M6 LZ
-       4c64  Radeon R250 Ld [Radeon Mobility 9000]
-       4c65  Radeon R250 Le [Radeon Mobility 9000]
-       4c66  Radeon R250 Lf [Radeon Mobility 9000]
-       4c67  Radeon R250 Lg [Radeon Mobility 9000]
+       4c57  RV200 LW [Radeon Mobility M7]
+               1014 0517  RV200 LW [Radeon Mobility M7 ThinkPad T30]
+               1028 00e6  RV200 LW [Radeon Mobility M7 Dell Inspiron 8100]
+       4c58  RV200 LX [Radeon Mobility FireGL 7800]
+       4c59  RV100 LY [Radeon Mobility M6]
+               1014 0235  RV100 LY [Radeon Mobility M6 ThinkPad A30p (2653-64G)]
+               1014 0239  RV100 LY [Radeon Mobility M6 ThinkPad X22/X23/X24]
+               104d 80e7  RV100 LY [Radeon Mobility M6 VAIO 
PCG-GR214EP/GR214MP/GR215MP/GR314MP/GR315MP]
+       4c5a  RV100 LZ [Radeon Mobility M6]
+       4c64  RV250 Ld [Radeon Mobility M9]
+       4c65  RV250 Le [Radeon Mobility M9]
+       4c66  RV250 Lf [Radeon Mobility M9-GL]
+       4c67  RV250 Lg [Radeon Mobility M9]
        4d46  Rage Mobility M4 AGP
        4d4c  Rage Mobility M4 AGP
-       4e44  Radeon R300 ND [Radeon 9700]
-       4e45  Radeon R300 NE [Radeon 9700]
-       4e46  Radeon R300 NF [Radeon 9700]
-       4e47  Radeon R300 NG [Radeon 9700]
-       4e64  Radeon R300 [Radeon 9700] (Secondary)
+       4e44  R300 ND [Radeon 9700]
+       4e45  R300 NE [Radeon 9700]
+       4e46  R300 NF [Radeon 9700]
+       4e47  R300 NG [Radeon 9700]
+       4e64  R300 Nd [Radeon 9700] (Secondary)
        5041  Rage 128 PA/PRO
        5042  Rage 128 PB/PRO AGP 2x
        5043  Rage 128 PC/PRO AGP 4x
@@ -327,61 +329,68 @@
        5056  Rage 128 PV/PRO TMDS
        5057  Rage 128 PW/PRO AGP 2x TMDS
        5058  Rage 128 PX/PRO AGP 4x TMDS
-       5144  Radeon R100 QD [Radeon 64 DDR]
-               1002 0008  Radeon 7000/Radeon VE
-               1002 0009  Radeon 7000/Radeon
-               1002 000a  Radeon 7000/Radeon
-               1002 001a  Radeon 7000/Radeon
-               1002 0029  Radeon AIW
-               1002 0038  Radeon 7000/Radeon
-               1002 0039  Radeon 7000/Radeon
-               1002 008a  Radeon 7000/Radeon
-               1002 00ba  Radeon 7000/Radeon
-               1002 0139  Radeon 7000/Radeon
-               1002 028a  Radeon 7000/Radeon
-               1002 02aa  Radeon AIW
-               1002 053a  Radeon 7000/Radeon
-       5145  Radeon R100 QE
-       5146  Radeon R100 QF
-       5147  Radeon R100 QG
-       5148  Radeon R200 QH [Radeon 8500]
-               1002 0152  FireGL 8800
-               1002 0172  FireGL 8700
-       5149  Radeon R200 QI
-       514a  Radeon R200 QJ
-       514b  Radeon R200 QK
-       514c  Radeon R200 QL [Radeon 8500 LE]
-               1002 003a  Radeon R200 QL [Radeon 8500 LE]
-               1002 013a  Radeon 8500
+       5144  R100 QD [Radeon 7200]
+               1002 0008  R100 QD [Radeon 7200]
+               1002 0009  R100 QD [Radeon 7200]
+               1002 000a  R100 QD [Radeon 7200]
+               1002 001a  R100 QD [Radeon 7200]
+               1002 0029  R100 QD [Radeon 7200 All-In-Wonder]
+               1002 0038  R100 QD [Radeon 7200]
+               1002 0039  R100 QD [Radeon 7200]
+               1002 008a  R100 QD [Radeon 7200]
+               1002 00ba  R100 QD [Radeon 7200]
+               1002 0138  R100 QD [Radeon 7200 SDRAM]
+               1002 0139  R100 QD [Radeon 7200]
+               1002 028a  R100 QD [Radeon 7200]
+               1002 02aa  R100 QD [Radeon 7200 All-In-Wonder]
+               1002 053a  R100 QD [Radeon 7200]
+               1002 0908  R100 QD [Radeon 7200 SDRAM]
+       5145  R100 QE [Radeon 7200]
+       5146  R100 QF [Radeon 7200]
+       5147  R100 QG [Radeon 7200]
+       5148  R200 QH [Radeon 8500]
+               1002 0152  R200 QH [FireGL 8800]
+               1002 0172  R200 QH [FireGL 8700]
+       5149  R200 QI [Radeon 8500]
+       514a  R200 QJ [Radeon 8500]
+       514b  R200 QK [Radeon 8500]
+       514c  R200 QL [Radeon 8500 LE]
+               1002 003a  R200 QL [Radeon 8500 LE]
+               1002 013a  R200 QL [Radeon 8500]
                148c 2026  R200 QL [Radeon 8500 Evil Master II Multi Display Edition]
-               174b 7149  Radeon R200 QL [Sapphire Radeon 8500 LE]
-       5157  Radeon RV200 QW [Radeon 7500]
-               1002 013a  Radeon 7500
-               1458 4000  RV200 QW [RADEON 7500 PRO MAYA AR]
-               148c 2024  RV200 QW [Radeon 7500LE Dual Display]
+               174b 7149  R200 QL [Sapphire Radeon 8500 LE]
+       514d  R200 QM [Radeon 9100]
+       514e  R200 QN [Radeon 9100]
+       514f  R200 QO [Radeon 9100]
+       5157  RV200 QW [Radeon 7500]
+               1002 013a  RV200 QW [Radeon 7500]
+               1458 4000  RV200 QW [Radeon 7500 Pro Maya AR]
+               148c 2024  RV200 QW [Radeon 7500 LE Dual Display]
                148c 2025  RV200 QW [Radeon 7500 Evil Master Multi Display Edition]
                148c 2036  RV200 QW [Radeon 7500 PCI Dual Display]
-               174b 7147  RV200 QW [Sapphire Radeon 7500LE]
-               174b 7161  Radeon RV200 QW [Radeon 7500 LE]
-               17af 0202  RV200 QW [Excalibur Radeon 7500LE]
-       5158  Radeon RV200 QX [Radeon 7500]
-       5159  Radeon VE QY
-               1002 000a  Radeon 7000/Radeon VE
-               1002 000b  Radeon 7000
-               1002 0038  Radeon 7000/Radeon VE
-               1002 003a  Radeon 7000/Radeon VE
-               1002 00ba  Radeon 7000/Radeon VE
-               1002 013a  Radeon 7000/Radeon VE
-               1458 4002  RV100 QY [RADEON 7000 PRO MAYA AV Series]
+               174b 7147  RV200 QW [Sapphire Radeon 7500 LE]
+               174b 7161  RV200 QW [Radeon 7500 LE]
+               17af 0202  RV200 QW [Excalibur Radeon 7500 LE]
+       5158  RV200 QX [Radeon 7500]
+       5159  RV100 QY [Radeon 7000/VE]
+               1002 000a  RV100 QY [Radeon 7000/VE]
+               1002 000b  RV100 QY [Radeon 7000/VE]
+               1002 0038  RV100 QY [Radeon 7000/VE]
+               1002 003a  RV100 QY [Radeon 7000/VE]
+               1002 00ba  RV100 QY [Radeon 7000/VE]
+               1002 013a  RV100 QY [Radeon 7000/VE]
+               1458 4002  RV100 QY [Radeon 7000 Pro Maya AV Series]
                148c 2003  RV100 QY [Radeon 7000 Multi-Display Edition]
                148c 2023  RV100 QY [Radeon 7000 Evil Master Multi-Display]
                174b 7112  RV100 QY [Sapphire Radeon VE 7000]
                1787 0202  RV100 QY [Excalibur Radeon 7000]
-       515a  Radeon VE QZ
-       5168  Radeon R200 Qh
-       5169  Radeon R200 Qi
-       516a  Radeon R200 Qj
-       516b  Radeon R200 Qk
+       515a  RV100 QZ [Radeon 7000/VE]
+       5168  R200 Qh [Radeon 8500]
+       5169  R200 Qi [Radeon 8500]
+       516a  R200 Qj [Radeon 8500]
+       516b  R200 Qk [Radeon 8500]
+       516c  R200 Ql [Radeon 8500]
+       516d  R200 Qm [Radeon 9100] (Secondary)
        5245  Rage 128 RE/SG
                1002 0008  Xpert 128
                1002 0028  Rage 128 AIW
@@ -431,6 +440,15 @@
                1002 5654  Mach64VT Reference
        5655  264VT3 [Mach64 VT3]
        5656  264VT4 [Mach64 VT4]
+       5941  RV280 [Radeon 9200]
+       5960  RV280 [Radeon 9200]
+       5961  RV280 [Radeon 9200]
+       5962  RV280 [Radeon 9200]
+       5963  RV280 [Radeon 9200]
+       5968  RV280 [Radeon 9200]
+       5969  RV280 [Radeon 9200]
+       596A  RV280 [Radeon 9200]
+       596B  RV280 [Radeon 9200]
        700f  U1/A3 AGP Bridge [IGP 320M]
 1003  ULSI Systems
        0201  US201
#!/usr/bin/python2
#
# (c) Copyright IBM Corporation 2002
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# on the rights to use, copy, modify, merge, publish, distribute, sub
# license, and/or sell copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
# VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Authors:
#    Ian Romanick <[EMAIL PROTECTED]>

import sys
import string
import re
import os.path

True = (1 == 1)
False = not True
comment_re = re.compile( '^[ \t]*#|$' )

def fix_name(name):
    """Convert quotation marks in device names to C-escape sequences"""
    return string.join( string.split( name, '"' ), '\\"' )
    

def process_file(infile, target_vendor, target_id, driver, param):
    device_vendor_re = re.compile( '^([\da-fA-F]{4}) ' )
    device_id_re = re.compile( '^[ \t]([\da-fA-F]{4})[ \t]+(.+)' )
    subsys_re = re.compile( '^[ \t]{2}([\da-fA-F]{4})[ \t]+([\da-fA-F]{4})[ \t]+(.+)' )

    state = 0
    no_read = False
    while 1:
        if not no_read:
            line = infile.readline()
            if line == '':
                break;

        no_read = False
        if re.match( comment_re, line ):
            continue

        if state == 0:
            m = re.match( device_vendor_re, line )
            if m != None:
                device_vendor = int( m.group(1), 16 )
                if device_vendor == target_vendor:
                    state = 1

        elif state == 1:
            m = re.match( device_id_re, line )
            if m != None:
                device_id   = int( m.group(1), 16 )
                if device_id == target_id:
                    device_name = fix_name( m.group(2) )
                    print '   { 0x%04x, 0x%04x, 0x0000, 0x0000, "%s", "%s", { %s } },' 
\
                    % (device_vendor, device_id, device_name, driver, param)

            elif re.match( subsys_re, line ):
                if device_id == target_id:
                    state = 2
                    no_read = True
            else:
                state = 0
                no_read = True

        elif state == 2:
            m = re.match( subsys_re, line )
            if m != None:
                subsys_vendor = int( m.group(1), 16 )
                subsys_id     = int( m.group(2), 16 )
                device_name = fix_name( m.group(3) )
                print '   { 0x%04x, 0x%04x, 0x%04x, 0x%04x, "%s", "%s", { %s } },' \
                % (device_vendor, device_id, subsys_vendor, subsys_id, device_name, 
driver, param)
            elif re.match( device_id_re, line ):
                state = 1
                no_read = True
            else:
                state = 0
                no_read = True


def main():
    top_file_name = sys.argv[1]
    pci_file_name = sys.argv[2]

    card_line_re = re.compile( '^[ \t]*(0[xX][\da-fA-F]{1,4})[ 
\t]+(0[xX][\da-fA-F]{1,4})[ \t]+([a-zA-Z0-9]+)[ \t]+(.+)' )
    top_file = open( top_file_name, 'r' )

    line_number = 0
    while 1:
        line_number += 1
        line = top_file.readline();
        if not re.match( comment_re, line ):
            rec_name = string.strip( line )
            break


    print '/* DO NOT EDIT - This file generated automtically by %s script */' % ( 
os.path.basename(sys.argv[0]) )
    print '''
/* This file is intended to be included by a device driver and is used to
 * indentify the specific graphics chip used in the system.
 */
'''
    print 'static const struct driPCIInfoRec %s[] = {' % (rec_name)
    print '/*   device  device  subdev  subdev */'
    print '/*   vendor    ID    vendor    ID   */'
    for line in top_file:
        line_number += 1
        if not re.match( comment_re, line ):
            m = re.match( card_line_re, line )
            if m != None:
                first = False
                infile = open( pci_file_name, 'r' )
                process_file( infile, int( m.group(1), 16 ), int( m.group(2), 16 ),
                m.group(3), m.group(4) )
                infile.close
            else:
                print 'Malformed input line at %d' % (line_number)
                break

    print '   { 0x0000, 0x0000, 0x0000, 0x0000, NULL, NULL, { .i = 0 } },'
    print '};'

if __name__ == "__main__":
    main()

Reply via email to