- Converted Linux drivers to initialize DRM instances based on PCI IDs, not
authorEric Anholt <anholt@freebsd.org>
Fri, 17 Oct 2003 03:14:39 +0000 (03:14 +0000)
committerEric Anholt <anholt@freebsd.org>
Fri, 17 Oct 2003 03:14:39 +0000 (03:14 +0000)
    just a single instance. Moved the PCI ID lists from <card>_drv.c in BSD
    to <card>.h. The PCI ID lists include a driver private field, which may
    be used by drivers for chip family or other information. Based on work
    by jonsmirl.
- Make tdfx_drv.c and tdfx.h match other drivers.
- Fixed up linking of sis shared files.
Tested with Radeon and SiS on Linux and FreeBSD, including a Linux setup
    with
2 SiS cards in a machine, but only one head being used (with DRI)

35 files changed:
bsd-core/drmP.h
bsd-core/drm_drv.c
bsd-core/drm_os_freebsd.h
bsd-core/drm_os_netbsd.h
bsd-core/mga_drv.c
bsd-core/r128_drv.c
bsd-core/radeon_drv.c
bsd-core/sis_drv.c
bsd-core/tdfx_drv.c
bsd/Imakefile
bsd/drmP.h
bsd/drm_drv.h
bsd/drm_os_freebsd.h
bsd/drm_os_netbsd.h
bsd/mga_drv.c
bsd/r128_drv.c
bsd/radeon_drv.c
bsd/sis_drv.c
bsd/tdfx_drv.c
linux-core/drmP.h
linux-core/drm_drv.c
linux-core/tdfx_drv.c
linux/Makefile.linux
linux/drmP.h
linux/drm_drv.h
linux/gamma.h
linux/i810.h
linux/i830.h
linux/tdfx_drv.c
shared-core/tdfx_drv.h [moved from linux/tdfx.h with 75% similarity]
shared/mga.h
shared/r128.h
shared/radeon.h
shared/sis.h
shared/tdfx.h [moved from bsd/tdfx.h with 75% similarity]

index 2d36c3c..0a93ef3 100644 (file)
@@ -123,6 +123,14 @@ typedef struct drm_file drm_file_t;
 } while(0)
 
 
+typedef struct drm_pci_id_list
+{
+       int vendor;
+       int device;
+       long driver_private;
+       char *name;
+} drm_pci_id_list_t;
+
 typedef struct drm_ioctl_desc {
        int                  (*func)(DRM_IOCTL_ARGS);
        int                  auth_needed;
index d517d05..bfded6b 100644 (file)
@@ -219,11 +219,14 @@ static struct cdevsw DRM(cdevsw) = {
 #endif
 };
 
+static drm_pci_id_list_t DRM(pciidlist)[] = {
+       DRIVER_PCI_IDS
+};
+
 static int DRM(probe)(device_t dev)
 {
        const char *s = NULL;
        int pciid, vendor, device;
-   
 
        /* XXX: Cope with agp bridge device? */
        if (!strcmp(device_get_name(dev), "drmsub"))
@@ -235,7 +238,7 @@ static int DRM(probe)(device_t dev)
        device = (pciid & 0xffff0000) >> 16;
        
        s = DRM(find_description)(vendor, device);
-       if (s) {
+       if (s != NULL) {
                device_set_desc(dev, s);
                return 0;
        }
@@ -349,7 +352,8 @@ int DRM(probe)(struct pci_attach_args *pa)
 {
        const char *desc;
 
-       desc = DRM(find_description)(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id));
+       desc = DRM(find_description)(PCI_VENDOR(pa->pa_id),
+           PCI_PRODUCT(pa->pa_id));
        if (desc != NULL) {
                return 1;
        }
@@ -396,21 +400,15 @@ int DRM(activate)(struct device *self, enum devact act)
 #endif /* __NetBSD__ */
 
 const char *DRM(find_description)(int vendor, int device) {
-       const char *s = NULL;
-       int i=0, done=0;
+       int i = 0;
        
-       while ( !done && (DRM(devicelist)[i].vendor != 0 ) ) {
-               if ( (DRM(devicelist)[i].vendor == vendor) &&
-                    (DRM(devicelist)[i].device == device) ) {
-                       done=1;
-                       if ( DRM(devicelist)[i].supported )
-                               s = DRM(devicelist)[i].name;
-                       else
-                               DRM_INFO("%s not supported\n", DRM(devicelist)[i].name);
+       for (i = 0; DRM(pciidlist)[i].vendor != 0; i++) {
+               if ((DRM(pciidlist)[i].vendor == vendor) &&
+                   (DRM(pciidlist)[i].device == device)) {
+                       return DRM(pciidlist)[i].name;
                }
-               i++;
        }
-       return s;
+       return NULL;
 }
 
 static int DRM(setup)( drm_device_t *dev )
index 0bb38ba..3894f54 100644 (file)
@@ -270,14 +270,6 @@ for ( ret = 0 ; !ret && !(condition) ; ) {         \
 MALLOC_DECLARE(malloctype);
 #undef malloctype
 
-typedef struct drm_chipinfo
-{
-       int vendor;
-       int device;
-       int supported;
-       char *name;
-} drm_chipinfo_t;
-
 #if __FreeBSD_version >= 480000
 #define cpu_to_le32(x) htole32(x)
 #define le32_to_cpu(x) le32toh(x)
index 1290e84..47e710c 100644 (file)
@@ -230,14 +230,6 @@ while (!condition) {                                               \
 
 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
 
-typedef struct drm_chipinfo
-{
-       int vendor;
-       int device;
-       int supported;
-       char *name;
-} drm_chipinfo_t;
-
 #define cpu_to_le32(x) htole32(x)
 #define le32_to_cpu(x) le32toh(x)
 
index 85520d5..4eaf5ed 100644 (file)
 #include "mga_drm.h"
 #include "mga_drv.h"
 
-/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
- * Please report to anholt@teleport.com inaccuracies or if a chip you have works that is marked unsupported here.
- */
-drm_chipinfo_t DRM(devicelist)[] = {
-       {0x102b, 0x0520, 0, "Matrox G200 (PCI)"},
-       {0x102b, 0x0521, 1, "Matrox G200 (AGP)"},
-       {0x102b, 0x0525, 1, "Matrox G400/G450 (AGP)"},
-       {0x102b, 0x2527, 1, "Matrox G550 (AGP)"},
-       {0, 0, 0, NULL}
-};
-
 #include "drm_agpsupport.h"
 #include "drm_auth.h"
 #include "drm_bufs.h"
index 14a8cc5..e656f60 100644 (file)
 #include "ati_pcigart.h"
 #endif
 
-/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
- * Please report to eta@lclark.edu inaccuracies or if a chip you have works that is marked unsupported here.
- */
-drm_chipinfo_t DRM(devicelist)[] = {
-       {0x1002, 0x4c45, __REALLY_HAVE_SG, "ATI Rage 128 Mobility LE (PCI)"},
-       {0x1002, 0x4c46, 1, "ATI Rage 128 Mobility LF (AGP)"},
-       {0x1002, 0x4d46, 1, "ATI Rage 128 Mobility MF (AGP)"},
-       {0x1002, 0x4d4c, 1, "ATI Rage 128 Mobility ML (AGP)"},
-       {0x1002, 0x5044, __REALLY_HAVE_SG, "ATI Rage 128 Pro PD (PCI)"},
-       {0x1002, 0x5046, 1, "ATI Rage 128 Pro PF (AGP)"},
-       {0x1002, 0x5050, __REALLY_HAVE_SG, "ATI Rage 128 Pro PP (PCI)"},
-       {0x1002, 0x5052, __REALLY_HAVE_SG, "ATI Rage 128 Pro PR (PCI)"},
-       {0x1002, 0x5245, __REALLY_HAVE_SG, "ATI Rage 128 RE (PCI)"},
-       {0x1002, 0x5246, 1, "ATI Rage 128 RF (AGP)"},
-       {0x1002, 0x5247, 1, "ATI Rage 128 RG (AGP)"},
-       {0x1002, 0x524b, __REALLY_HAVE_SG, "ATI Rage 128 RK (PCI)"},
-       {0x1002, 0x524c, 1, "ATI Rage 128 RL (AGP)"},
-       {0x1002, 0x534d, 1, "ATI Rage 128 SM (AGP)"},
-       {0x1002, 0x5446, 1, "ATI Rage 128 Pro Ultra TF (AGP)"},
-       {0x1002, 0x544C, 1, "ATI Rage 128 Pro Ultra TL (AGP)"},
-       {0x1002, 0x5452, 1, "ATI Rage 128 Pro Ultra TR (AGP)"},
-       {0, 0, 0, NULL}
-};
-
 #include "drm_agpsupport.h"
 #include "drm_auth.h"
 #include "drm_bufs.h"
index 62433c2..3b69976 100644 (file)
 #include "ati_pcigart.h"
 #endif
 
-drm_chipinfo_t DRM(devicelist)[] = {
-       {0x1002, 0x4242, 1, "ATI Radeon BB R200 AIW 8500DV"},
-       {0x1002, 0x4964, 1, "ATI Radeon Id R250 9000"},
-       {0x1002, 0x4965, 1, "ATI Radeon Ie R250 9000"},
-       {0x1002, 0x4966, 1, "ATI Radeon If R250 9000"},
-       {0x1002, 0x4967, 1, "ATI Radeon Ig R250 9000"},
-       {0x1002, 0x4C57, 1, "ATI Radeon LW Mobility 7500 M7"},
-       {0x1002, 0x4C58, 1, "ATI Radeon LX RV200 Mobility FireGL 7800 M7"},
-       {0x1002, 0x4C59, 1, "ATI Radeon LY Mobility M6"},
-       {0x1002, 0x4C5A, 1, "ATI Radeon LZ Mobility M6"},
-       {0x1002, 0x4C64, 1, "ATI Radeon Ld R250 Mobility 9000 M9"},
-       {0x1002, 0x4C65, 1, "ATI Radeon Le R250 Mobility 9000 M9"},
-       {0x1002, 0x4C66, 1, "ATI Radeon Lf R250 Mobility 9000 M9"},
-       {0x1002, 0x4C67, 1, "ATI Radeon Lg R250 Mobility 9000 M9"},
-       {0x1002, 0x5144, 1, "ATI Radeon QD R100"},
-       {0x1002, 0x5145, 1, "ATI Radeon QE R100"},
-       {0x1002, 0x5146, 1, "ATI Radeon QF R100"},
-       {0x1002, 0x5147, 1, "ATI Radeon QG R100"},
-       {0x1002, 0x5148, 1, "ATI Radeon QH R200 8500"},
-       {0x1002, 0x5149, 1, "ATI Radeon QI R200"},
-       {0x1002, 0x514A, 1, "ATI Radeon QJ R200"},
-       {0x1002, 0x514B, 1, "ATI Radeon QK R200"},
-       {0x1002, 0x514C, 1, "ATI Radeon QL R200 8500 LE"},
-       {0x1002, 0x514D, 1, "ATI Radeon QM R200 9100"},
-       {0x1002, 0x514E, 1, "ATI Radeon QN R200 8500 LE"},
-       {0x1002, 0x514F, 1, "ATI Radeon QO R200 8500 LE"},
-       {0x1002, 0x5157, 1, "ATI Radeon QW RV200 7500"},
-       {0x1002, 0x5158, 1, "ATI Radeon QX RV200 7500"},
-       {0x1002, 0x5159, 1, "ATI Radeon QY RV100 7000/VE"},
-       {0x1002, 0x515A, 1, "ATI Radeon QZ RV100 7000/VE"},
-       {0x1002, 0x5168, 1, "ATI Radeon Qh R200"},
-       {0x1002, 0x5169, 1, "ATI Radeon Qi R200"},
-       {0x1002, 0x516A, 1, "ATI Radeon Qj R200"},
-       {0x1002, 0x516B, 1, "ATI Radeon Qk R200"},
-       {0x1002, 0x516C, 1, "ATI Radeon Ql R200"},
-       {0x1002, 0x5961, 1, "ATI Radeon RV280 9200"},
-       {0, 0, 0, NULL}
-};
-
 #include "drm_agpsupport.h"
 #include "drm_auth.h"
 #include "drm_bufs.h"
index 13be07a..64767a4 100644 (file)
 #include "sis_drm.h"
 #include "sis_drv.h"
 
-drm_chipinfo_t DRM(devicelist)[] = {
-       {0x1039, 0x0300, 1, "SiS 300"},
-       {0x1039, 0x5300, 1, "SiS 540"},
-       {0x1039, 0x6300, 1, "SiS 630"},
-       {0, 0, 0, NULL}
-};
-
 #include "drm_auth.h"
 #include "drm_agpsupport.h"
 #include "drm_bufs.h"
index 1c80375..e96216c 100644 (file)
 #include "tdfx.h"
 #include "drmP.h"
 
-#define DRIVER_AUTHOR          "VA Linux Systems Inc."
-
-#define DRIVER_NAME            "tdfx"
-#define DRIVER_DESC            "3dfx Banshee/Voodoo3+"
-#define DRIVER_DATE            "20010216"
-
-#define DRIVER_MAJOR           1
-#define DRIVER_MINOR           0
-#define DRIVER_PATCHLEVEL      0
-
-#ifndef PCI_VENDOR_ID_3DFX
-#define PCI_VENDOR_ID_3DFX 0x121A
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO5
-#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO4
-#define PCI_DEVICE_ID_3DFX_VOODOO4 0x0007
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_3000 /* Voodoo3 3000 */
-#define PCI_DEVICE_ID_3DFX_VOODOO3_3000 0x0005
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_2000 /* Voodoo3 3000 */
-#define PCI_DEVICE_ID_3DFX_VOODOO3_2000 0x0004
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_BANSHEE
-#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
-#endif
-
-/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
- * Please report to anholt@teleport.com inaccuracies or if a chip you have works that is marked unsupported here.
- */
-drm_chipinfo_t DRM(devicelist)[] = {
-       {0x121a, 0x0003, 1, "3dfx Voodoo Banshee"},
-       {0x121a, 0x0004, 1, "3dfx Voodoo3 2000"},
-       {0x121a, 0x0005, 1, "3dfx Voodoo3 3000"},
-       {0x121a, 0x0007, 1, "3dfx Voodoo4"},
-       {0x121a, 0x0009, 1, "3dfx Voodoo5"},
-       {0, 0, 0, NULL}
-};
-
-
 #include "drm_auth.h"
 #include "drm_bufs.h"
 #include "drm_context.h"
 #include "drm_dma.h"
 #include "drm_drawable.h"
 #include "drm_drv.h"
-
-
 #include "drm_fops.h"
 #include "drm_ioctl.h"
 #include "drm_lock.h"
index e51c073..63e1296 100644 (file)
@@ -47,3 +47,4 @@ LinkSourceFile(sis_drv.h,$(XF86OSSRC)/shared/drm/kernel)
 LinkSourceFile(sis_ds.c,$(XF86OSSRC)/shared/drm/kernel)
 LinkSourceFile(sis_ds.h,$(XF86OSSRC)/shared/drm/kernel)
 LinkSourceFile(sis_mm.c,$(XF86OSSRC)/shared/drm/kernel)
+LinkSourceFile(tdfx.h,$(XF86OSSRC)/shared/drm/kernel)
index 2d36c3c..0a93ef3 100644 (file)
@@ -123,6 +123,14 @@ typedef struct drm_file drm_file_t;
 } while(0)
 
 
+typedef struct drm_pci_id_list
+{
+       int vendor;
+       int device;
+       long driver_private;
+       char *name;
+} drm_pci_id_list_t;
+
 typedef struct drm_ioctl_desc {
        int                  (*func)(DRM_IOCTL_ARGS);
        int                  auth_needed;
index d517d05..bfded6b 100644 (file)
@@ -219,11 +219,14 @@ static struct cdevsw DRM(cdevsw) = {
 #endif
 };
 
+static drm_pci_id_list_t DRM(pciidlist)[] = {
+       DRIVER_PCI_IDS
+};
+
 static int DRM(probe)(device_t dev)
 {
        const char *s = NULL;
        int pciid, vendor, device;
-   
 
        /* XXX: Cope with agp bridge device? */
        if (!strcmp(device_get_name(dev), "drmsub"))
@@ -235,7 +238,7 @@ static int DRM(probe)(device_t dev)
        device = (pciid & 0xffff0000) >> 16;
        
        s = DRM(find_description)(vendor, device);
-       if (s) {
+       if (s != NULL) {
                device_set_desc(dev, s);
                return 0;
        }
@@ -349,7 +352,8 @@ int DRM(probe)(struct pci_attach_args *pa)
 {
        const char *desc;
 
-       desc = DRM(find_description)(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id));
+       desc = DRM(find_description)(PCI_VENDOR(pa->pa_id),
+           PCI_PRODUCT(pa->pa_id));
        if (desc != NULL) {
                return 1;
        }
@@ -396,21 +400,15 @@ int DRM(activate)(struct device *self, enum devact act)
 #endif /* __NetBSD__ */
 
 const char *DRM(find_description)(int vendor, int device) {
-       const char *s = NULL;
-       int i=0, done=0;
+       int i = 0;
        
-       while ( !done && (DRM(devicelist)[i].vendor != 0 ) ) {
-               if ( (DRM(devicelist)[i].vendor == vendor) &&
-                    (DRM(devicelist)[i].device == device) ) {
-                       done=1;
-                       if ( DRM(devicelist)[i].supported )
-                               s = DRM(devicelist)[i].name;
-                       else
-                               DRM_INFO("%s not supported\n", DRM(devicelist)[i].name);
+       for (i = 0; DRM(pciidlist)[i].vendor != 0; i++) {
+               if ((DRM(pciidlist)[i].vendor == vendor) &&
+                   (DRM(pciidlist)[i].device == device)) {
+                       return DRM(pciidlist)[i].name;
                }
-               i++;
        }
-       return s;
+       return NULL;
 }
 
 static int DRM(setup)( drm_device_t *dev )
index 0bb38ba..3894f54 100644 (file)
@@ -270,14 +270,6 @@ for ( ret = 0 ; !ret && !(condition) ; ) {         \
 MALLOC_DECLARE(malloctype);
 #undef malloctype
 
-typedef struct drm_chipinfo
-{
-       int vendor;
-       int device;
-       int supported;
-       char *name;
-} drm_chipinfo_t;
-
 #if __FreeBSD_version >= 480000
 #define cpu_to_le32(x) htole32(x)
 #define le32_to_cpu(x) le32toh(x)
index 1290e84..47e710c 100644 (file)
@@ -230,14 +230,6 @@ while (!condition) {                                               \
 
 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
 
-typedef struct drm_chipinfo
-{
-       int vendor;
-       int device;
-       int supported;
-       char *name;
-} drm_chipinfo_t;
-
 #define cpu_to_le32(x) htole32(x)
 #define le32_to_cpu(x) le32toh(x)
 
index 85520d5..4eaf5ed 100644 (file)
 #include "mga_drm.h"
 #include "mga_drv.h"
 
-/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
- * Please report to anholt@teleport.com inaccuracies or if a chip you have works that is marked unsupported here.
- */
-drm_chipinfo_t DRM(devicelist)[] = {
-       {0x102b, 0x0520, 0, "Matrox G200 (PCI)"},
-       {0x102b, 0x0521, 1, "Matrox G200 (AGP)"},
-       {0x102b, 0x0525, 1, "Matrox G400/G450 (AGP)"},
-       {0x102b, 0x2527, 1, "Matrox G550 (AGP)"},
-       {0, 0, 0, NULL}
-};
-
 #include "drm_agpsupport.h"
 #include "drm_auth.h"
 #include "drm_bufs.h"
index 14a8cc5..e656f60 100644 (file)
 #include "ati_pcigart.h"
 #endif
 
-/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
- * Please report to eta@lclark.edu inaccuracies or if a chip you have works that is marked unsupported here.
- */
-drm_chipinfo_t DRM(devicelist)[] = {
-       {0x1002, 0x4c45, __REALLY_HAVE_SG, "ATI Rage 128 Mobility LE (PCI)"},
-       {0x1002, 0x4c46, 1, "ATI Rage 128 Mobility LF (AGP)"},
-       {0x1002, 0x4d46, 1, "ATI Rage 128 Mobility MF (AGP)"},
-       {0x1002, 0x4d4c, 1, "ATI Rage 128 Mobility ML (AGP)"},
-       {0x1002, 0x5044, __REALLY_HAVE_SG, "ATI Rage 128 Pro PD (PCI)"},
-       {0x1002, 0x5046, 1, "ATI Rage 128 Pro PF (AGP)"},
-       {0x1002, 0x5050, __REALLY_HAVE_SG, "ATI Rage 128 Pro PP (PCI)"},
-       {0x1002, 0x5052, __REALLY_HAVE_SG, "ATI Rage 128 Pro PR (PCI)"},
-       {0x1002, 0x5245, __REALLY_HAVE_SG, "ATI Rage 128 RE (PCI)"},
-       {0x1002, 0x5246, 1, "ATI Rage 128 RF (AGP)"},
-       {0x1002, 0x5247, 1, "ATI Rage 128 RG (AGP)"},
-       {0x1002, 0x524b, __REALLY_HAVE_SG, "ATI Rage 128 RK (PCI)"},
-       {0x1002, 0x524c, 1, "ATI Rage 128 RL (AGP)"},
-       {0x1002, 0x534d, 1, "ATI Rage 128 SM (AGP)"},
-       {0x1002, 0x5446, 1, "ATI Rage 128 Pro Ultra TF (AGP)"},
-       {0x1002, 0x544C, 1, "ATI Rage 128 Pro Ultra TL (AGP)"},
-       {0x1002, 0x5452, 1, "ATI Rage 128 Pro Ultra TR (AGP)"},
-       {0, 0, 0, NULL}
-};
-
 #include "drm_agpsupport.h"
 #include "drm_auth.h"
 #include "drm_bufs.h"
index 62433c2..3b69976 100644 (file)
 #include "ati_pcigart.h"
 #endif
 
-drm_chipinfo_t DRM(devicelist)[] = {
-       {0x1002, 0x4242, 1, "ATI Radeon BB R200 AIW 8500DV"},
-       {0x1002, 0x4964, 1, "ATI Radeon Id R250 9000"},
-       {0x1002, 0x4965, 1, "ATI Radeon Ie R250 9000"},
-       {0x1002, 0x4966, 1, "ATI Radeon If R250 9000"},
-       {0x1002, 0x4967, 1, "ATI Radeon Ig R250 9000"},
-       {0x1002, 0x4C57, 1, "ATI Radeon LW Mobility 7500 M7"},
-       {0x1002, 0x4C58, 1, "ATI Radeon LX RV200 Mobility FireGL 7800 M7"},
-       {0x1002, 0x4C59, 1, "ATI Radeon LY Mobility M6"},
-       {0x1002, 0x4C5A, 1, "ATI Radeon LZ Mobility M6"},
-       {0x1002, 0x4C64, 1, "ATI Radeon Ld R250 Mobility 9000 M9"},
-       {0x1002, 0x4C65, 1, "ATI Radeon Le R250 Mobility 9000 M9"},
-       {0x1002, 0x4C66, 1, "ATI Radeon Lf R250 Mobility 9000 M9"},
-       {0x1002, 0x4C67, 1, "ATI Radeon Lg R250 Mobility 9000 M9"},
-       {0x1002, 0x5144, 1, "ATI Radeon QD R100"},
-       {0x1002, 0x5145, 1, "ATI Radeon QE R100"},
-       {0x1002, 0x5146, 1, "ATI Radeon QF R100"},
-       {0x1002, 0x5147, 1, "ATI Radeon QG R100"},
-       {0x1002, 0x5148, 1, "ATI Radeon QH R200 8500"},
-       {0x1002, 0x5149, 1, "ATI Radeon QI R200"},
-       {0x1002, 0x514A, 1, "ATI Radeon QJ R200"},
-       {0x1002, 0x514B, 1, "ATI Radeon QK R200"},
-       {0x1002, 0x514C, 1, "ATI Radeon QL R200 8500 LE"},
-       {0x1002, 0x514D, 1, "ATI Radeon QM R200 9100"},
-       {0x1002, 0x514E, 1, "ATI Radeon QN R200 8500 LE"},
-       {0x1002, 0x514F, 1, "ATI Radeon QO R200 8500 LE"},
-       {0x1002, 0x5157, 1, "ATI Radeon QW RV200 7500"},
-       {0x1002, 0x5158, 1, "ATI Radeon QX RV200 7500"},
-       {0x1002, 0x5159, 1, "ATI Radeon QY RV100 7000/VE"},
-       {0x1002, 0x515A, 1, "ATI Radeon QZ RV100 7000/VE"},
-       {0x1002, 0x5168, 1, "ATI Radeon Qh R200"},
-       {0x1002, 0x5169, 1, "ATI Radeon Qi R200"},
-       {0x1002, 0x516A, 1, "ATI Radeon Qj R200"},
-       {0x1002, 0x516B, 1, "ATI Radeon Qk R200"},
-       {0x1002, 0x516C, 1, "ATI Radeon Ql R200"},
-       {0x1002, 0x5961, 1, "ATI Radeon RV280 9200"},
-       {0, 0, 0, NULL}
-};
-
 #include "drm_agpsupport.h"
 #include "drm_auth.h"
 #include "drm_bufs.h"
index 13be07a..64767a4 100644 (file)
 #include "sis_drm.h"
 #include "sis_drv.h"
 
-drm_chipinfo_t DRM(devicelist)[] = {
-       {0x1039, 0x0300, 1, "SiS 300"},
-       {0x1039, 0x5300, 1, "SiS 540"},
-       {0x1039, 0x6300, 1, "SiS 630"},
-       {0, 0, 0, NULL}
-};
-
 #include "drm_auth.h"
 #include "drm_agpsupport.h"
 #include "drm_bufs.h"
index 1c80375..e96216c 100644 (file)
 #include "tdfx.h"
 #include "drmP.h"
 
-#define DRIVER_AUTHOR          "VA Linux Systems Inc."
-
-#define DRIVER_NAME            "tdfx"
-#define DRIVER_DESC            "3dfx Banshee/Voodoo3+"
-#define DRIVER_DATE            "20010216"
-
-#define DRIVER_MAJOR           1
-#define DRIVER_MINOR           0
-#define DRIVER_PATCHLEVEL      0
-
-#ifndef PCI_VENDOR_ID_3DFX
-#define PCI_VENDOR_ID_3DFX 0x121A
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO5
-#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO4
-#define PCI_DEVICE_ID_3DFX_VOODOO4 0x0007
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_3000 /* Voodoo3 3000 */
-#define PCI_DEVICE_ID_3DFX_VOODOO3_3000 0x0005
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_2000 /* Voodoo3 3000 */
-#define PCI_DEVICE_ID_3DFX_VOODOO3_2000 0x0004
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_BANSHEE
-#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
-#endif
-
-/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
- * Please report to anholt@teleport.com inaccuracies or if a chip you have works that is marked unsupported here.
- */
-drm_chipinfo_t DRM(devicelist)[] = {
-       {0x121a, 0x0003, 1, "3dfx Voodoo Banshee"},
-       {0x121a, 0x0004, 1, "3dfx Voodoo3 2000"},
-       {0x121a, 0x0005, 1, "3dfx Voodoo3 3000"},
-       {0x121a, 0x0007, 1, "3dfx Voodoo4"},
-       {0x121a, 0x0009, 1, "3dfx Voodoo5"},
-       {0, 0, 0, NULL}
-};
-
-
 #include "drm_auth.h"
 #include "drm_bufs.h"
 #include "drm_context.h"
 #include "drm_dma.h"
 #include "drm_drawable.h"
 #include "drm_drv.h"
-
-
 #include "drm_fops.h"
 #include "drm_ioctl.h"
 #include "drm_lock.h"
index 8a995db..f7137b2 100644 (file)
@@ -391,10 +391,13 @@ do {                                                                      \
 typedef int drm_ioctl_t( struct inode *inode, struct file *filp,
                         unsigned int cmd, unsigned long arg );
 
-typedef struct drm_pci_list {
-       u16 vendor;
-       u16 device;
-} drm_pci_list_t;
+typedef struct drm_pci_id_list
+{
+       int vendor;
+       int device;
+       long driver_private;
+       char *name;
+} drm_pci_id_list_t;
 
 typedef struct drm_ioctl_desc {
        drm_ioctl_t          *func;
@@ -651,6 +654,7 @@ typedef struct drm_device {
        int               unique_len;   /**< Length of unique field */
        dev_t             device;       /**< Device number for mknod */
        char              *devname;     /**< For /proc/interrupts */
+       int               minor;        /**< Minor device number */
 
        int               blocked;      /**< Blocked due to VC switch? */
        struct proc_dir_entry *root;    /**< Root for this device's entries */
index d62156b..801118e 100644 (file)
@@ -159,15 +159,8 @@ __setup( DRIVER_NAME "=", DRM_OPTIONS_FUNC );
 #undef DRM_OPTIONS_FUNC
 #endif
 
-/**
- * The default number of instances (minor numbers) to initialize.
- */
-#ifndef DRIVER_NUM_CARDS
-#define DRIVER_NUM_CARDS 1
-#endif
-
-static drm_device_t    *DRM(device);
-static int             *DRM(minor);
+#define MAX_DEVICES 4
+static drm_device_t    DRM(device)[MAX_DEVICES];
 static int             DRM(numdevs) = 0;
 
 DRIVER_FOPS;
@@ -534,52 +527,112 @@ static int DRM(takedown)( drm_device_t *dev )
        return 0;
 }
 
-/**
- * Figure out how many instances to initialize.
- *
- * \return number of cards found.
- *
- * Searches for every PCI card in \c DRIVER_CARD_LIST with matching vendor and device ids.
- */
-static int drm_count_cards(void)
+static drm_pci_id_list_t DRM(pciidlist)[] = {
+       DRIVER_PCI_IDS
+};
+
+static int probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-       int num = 0;
-#if defined(DRIVER_CARD_LIST)
-       int i;
-       drm_pci_list_t *l;
-       u16 device, vendor;
-       struct pci_dev *pdev = NULL;
+       drm_device_t *dev;
+#if __HAVE_CTX_BITMAP
+       int retcode;
 #endif
+       int i;
+       char *desc = NULL;
 
        DRM_DEBUG( "\n" );
 
-#if defined(DRIVER_COUNT_CARDS)
-       num = DRIVER_COUNT_CARDS();
-#elif defined(DRIVER_CARD_LIST)
-       for (i = 0, l = DRIVER_CARD_LIST; l[i].vendor != 0; i++) {
-               pdev = NULL;
-               vendor = l[i].vendor;
-               device = l[i].device;
-               if(device == 0xffff) device = PCI_ANY_ID;
-               if(vendor == 0xffff) vendor = PCI_ANY_ID;
-               while ((pdev = pci_find_device(vendor, device, pdev))) {
-                       num++;
+       for (i = 0; DRM(pciidlist)[i].vendor != 0; i++) {
+               if ((DRM(pciidlist)[i].vendor == pdev->vendor) &&
+                   (DRM(pciidlist)[i].device == pdev->device)) {
+                       desc = DRM(pciidlist)[i].name;
                }
        }
-#else
-       num = DRIVER_NUM_CARDS;
+       if (desc == NULL)
+               return -ENODEV;
+
+       if (DRM(numdevs) >= MAX_DEVICES)
+               return -ENODEV;
+
+       dev = &(DRM(device)[DRM(numdevs)]);
+
+       memset( (void *)dev, 0, sizeof(*dev) );
+       dev->count_lock = SPIN_LOCK_UNLOCKED;
+       init_timer( &dev->timer );
+       sema_init( &dev->struct_sem, 1 );
+
+       if ((dev->minor = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0)
+               return -EPERM;
+       dev->device = MKDEV(DRM_MAJOR, dev->minor );
+       dev->name   = DRIVER_NAME;
+       dev->pdev   = pdev;
+#ifdef __alpha__
+       dev->hose   = pdev->sysdata;
 #endif
-       DRM_DEBUG("numdevs = %d\n", num);
-       return num;
+
+       DRIVER_PREINIT();
+
+#if __REALLY_HAVE_AGP
+       dev->agp = DRM(agp_init)();
+#if __MUST_HAVE_AGP
+       if ( dev->agp == NULL ) {
+               DRM_ERROR( "Cannot initialize the agpgart module.\n" );
+               DRM(stub_unregister)(dev->minor);
+               DRM(takedown)( dev );
+               return -ENOMEM;
+       }
+#endif
+#if __REALLY_HAVE_MTRR
+       if (dev->agp)
+               dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
+                                       dev->agp->agp_info.aper_size*1024*1024,
+                                       MTRR_TYPE_WRCOMB,
+                                       1 );
+#endif
+#endif
+
+#if __HAVE_CTX_BITMAP
+       retcode = DRM(ctxbitmap_init)( dev );
+       if( retcode ) {
+               DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
+               DRM(stub_unregister)(dev->minor);
+               DRM(takedown)( dev );
+               return retcode;
+       }
+#endif
+       DRM(numdevs)++; /* no errors, mark it reserved */
+       
+       DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n",
+               DRIVER_NAME,
+               DRIVER_MAJOR,
+               DRIVER_MINOR,
+               DRIVER_PATCHLEVEL,
+               DRIVER_DATE,
+               dev->minor );
+
+       DRIVER_POSTINIT();
+
+       return 0;
+}
+
+static void __exit remove(struct pci_dev *dev)
+{
 }
 
+static struct pci_driver driver = {
+       .name     = DRIVER_NAME,
+       .id_table = NULL,
+       .probe    = probe,
+       .remove   = remove,
+};
+
 /**
  * Module initialization. Called via init_module at module load time, or via
  * linux/init/main.c (this is not currently supported).
  *
  * \return zero on success or a negative number on failure.
  *
- * Allocates and initialize an array of drm_device structures, and attempts to
+ * Initializes an array of drm_device structures, and attempts to
  * initialize all available devices, using consecutive minors, registering the
  * stubs and initializing the AGP device.
  * 
@@ -588,89 +641,15 @@ static int drm_count_cards(void)
  */
 static int __init drm_init( void )
 {
-
-       drm_device_t *dev;
-       int i;
-#if __HAVE_CTX_BITMAP
-       int retcode;
-#endif
        DRM_DEBUG( "\n" );
 
 #ifdef MODULE
        DRM(parse_options)( drm_opts );
 #endif
 
-       DRM(numdevs) = drm_count_cards();
-       /* Force at least one instance. */
-       if (DRM(numdevs) <= 0)
-               DRM(numdevs) = 1;
-
-       DRM(device) = kmalloc(sizeof(*DRM(device)) * DRM(numdevs), GFP_KERNEL);
-       if (!DRM(device)) {
-               return -ENOMEM;
-       }
-       DRM(minor) = kmalloc(sizeof(*DRM(minor)) * DRM(numdevs), GFP_KERNEL);
-       if (!DRM(minor)) {
-               kfree(DRM(device));
-               return -ENOMEM;
-       }
-
-       DRIVER_PREINIT();
-
        DRM(mem_init)();
 
-       for (i = 0; i < DRM(numdevs); i++) {
-               dev = &(DRM(device)[i]);
-               memset( (void *)dev, 0, sizeof(*dev) );
-               dev->count_lock = SPIN_LOCK_UNLOCKED;
-               init_timer( &dev->timer );
-               sema_init( &dev->struct_sem, 1 );
-
-               if ((DRM(minor)[i] = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0)
-                       return -EPERM;
-               dev->device = MKDEV(DRM_MAJOR, DRM(minor)[i] );
-               dev->name   = DRIVER_NAME;
-
-#if __REALLY_HAVE_AGP
-               dev->agp = DRM(agp_init)();
-#if __MUST_HAVE_AGP
-               if ( dev->agp == NULL ) {
-                       DRM_ERROR( "Cannot initialize the agpgart module.\n" );
-                       DRM(stub_unregister)(DRM(minor)[i]);
-                       DRM(takedown)( dev );
-                       return -ENOMEM;
-               }
-#endif
-#if __REALLY_HAVE_MTRR
-               if (dev->agp)
-                       dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
-                                      dev->agp->agp_info.aper_size*1024*1024,
-                                      MTRR_TYPE_WRCOMB,
-                                      1 );
-#endif
-#endif
-
-#if __HAVE_CTX_BITMAP
-               retcode = DRM(ctxbitmap_init)( dev );
-               if( retcode ) {
-                       DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
-                       DRM(stub_unregister)(DRM(minor)[i]);
-                       DRM(takedown)( dev );
-                       return retcode;
-               }
-#endif
-               DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n",
-                       DRIVER_NAME,
-                       DRIVER_MAJOR,
-                       DRIVER_MINOR,
-                       DRIVER_PATCHLEVEL,
-                       DRIVER_DATE,
-                       DRM(minor)[i] );
-       }
-
-       DRIVER_POSTINIT();
-
-       return 0;
+       return pci_module_init (&driver);;
 }
 
 /**
@@ -687,12 +666,14 @@ static void __exit drm_cleanup( void )
 
        DRM_DEBUG( "\n" );
 
+       pci_unregister_driver (&driver);
+
        for (i = DRM(numdevs) - 1; i >= 0; i--) {
                dev = &(DRM(device)[i]);
-               if ( DRM(stub_unregister)(DRM(minor)[i]) ) {
+               if ( DRM(stub_unregister)(dev->minor) ) {
                        DRM_ERROR( "Cannot unload module\n" );
                } else {
-                       DRM_DEBUG("minor %d unregistered\n", DRM(minor)[i]);
+                       DRM_DEBUG("minor %d unregistered\n", dev->minor);
                        if (i == 0) {
                                DRM_INFO( "Module unloaded\n" );
                        }
@@ -722,8 +703,6 @@ static void __exit drm_cleanup( void )
 #endif
        }
        DRIVER_POSTCLEANUP();
-       kfree(DRM(minor));
-       kfree(DRM(device));
        DRM(numdevs) = 0;
 }
 
@@ -795,7 +774,7 @@ int DRM(open)( struct inode *inode, struct file *filp )
        int i;
 
        for (i = 0; i < DRM(numdevs); i++) {
-               if (minor(inode->i_rdev) == DRM(minor)[i]) {
+               if (minor(inode->i_rdev) == DRM(device)[i].minor) {
                        dev = &(DRM(device)[i]);
                        break;
                }
index 8b79018..fafa1f9 100644 (file)
 #include "tdfx.h"
 #include "drmP.h"
 
-#define DRIVER_AUTHOR          "VA Linux Systems Inc."
-
-#define DRIVER_NAME            "tdfx"
-#define DRIVER_DESC            "3dfx Banshee/Voodoo3+"
-#define DRIVER_DATE            "20010216"
-
-#define DRIVER_MAJOR           1
-#define DRIVER_MINOR           0
-#define DRIVER_PATCHLEVEL      0
-
-#ifndef PCI_VENDOR_ID_3DFX
-#define PCI_VENDOR_ID_3DFX 0x121A
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO5
-#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO4
-#define PCI_DEVICE_ID_3DFX_VOODOO4 0x0007
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_3000 /* Voodoo3 3000 */
-#define PCI_DEVICE_ID_3DFX_VOODOO3_3000 0x0005
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_2000 /* Voodoo3 3000 */
-#define PCI_DEVICE_ID_3DFX_VOODOO3_2000 0x0004
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_BANSHEE
-#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
-#endif
-
-static drm_pci_list_t DRM(idlist)[] = {
-       { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE },
-       { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3_2000 },
-       { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3_3000 },
-       { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO4 },
-       { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO5 },
-       { 0, 0 }
-};
-
-#define DRIVER_CARD_LIST DRM(idlist)
-
-
 #include "drm_auth.h"
 #include "drm_bufs.h"
 #include "drm_context.h"
index 12e0e8c..e873242 100644 (file)
@@ -68,6 +68,7 @@ DRMHEADERS =    drm.h drmP.h $(DRMSHARED)
 GAMMAHEADERS =  gamma.h gamma_context.h gamma_drm.h gamma_drv.h gamma_lists.h \
                 gamma_old_dma.h gamma_lock.h $(DRMHEADERS) $(DRMTEMPLATES)
 TDFXHEADERS =   tdfx.h $(DRMHEADERS) $(DRMTEMPLATES)
+TDFXSHARED =    tdfx.h
 R128HEADERS =   r128.h r128_drv.h r128_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
 R128SHARED =    r128.h r128_drv.h r128_drm.h r128_cce.c r128_state.c r128_irq.c
 RADEONHEADERS = radeon.h radeon_drv.h radeon_drm.h $(DRMHEADERS) \
@@ -81,8 +82,10 @@ MGASHARED =     mga.h mga_dma.c mga_drm.h mga_drv.h mga_irq.c mga_state.c \
 I810HEADERS =   i810.h i810_drv.h i810_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
 I830HEADERS =   i830.h i830_drv.h i830_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
 SISHEADERS=     sis_drv.h sis_drm.h $(DRMHEADERS)
+SISSHARED=      sis_drv.h sis_drm.h sis_ds.c sis_ds.h sis_mm.c
 
-SHAREDSRC = $(DRMSHARED) $(MGASHARED) $(R128SHARED) $(RADEONSHARED)
+SHAREDSRC = $(DRMSHARED) $(MGASHARED) $(R128SHARED) $(RADEONSHARED) \
+       $(SISSHARED) $(TDFXSHARED)
 
 PROGS = dristat drmstat
 
index 8a995db..f7137b2 100644 (file)
@@ -391,10 +391,13 @@ do {                                                                      \
 typedef int drm_ioctl_t( struct inode *inode, struct file *filp,
                         unsigned int cmd, unsigned long arg );
 
-typedef struct drm_pci_list {
-       u16 vendor;
-       u16 device;
-} drm_pci_list_t;
+typedef struct drm_pci_id_list
+{
+       int vendor;
+       int device;
+       long driver_private;
+       char *name;
+} drm_pci_id_list_t;
 
 typedef struct drm_ioctl_desc {
        drm_ioctl_t          *func;
@@ -651,6 +654,7 @@ typedef struct drm_device {
        int               unique_len;   /**< Length of unique field */
        dev_t             device;       /**< Device number for mknod */
        char              *devname;     /**< For /proc/interrupts */
+       int               minor;        /**< Minor device number */
 
        int               blocked;      /**< Blocked due to VC switch? */
        struct proc_dir_entry *root;    /**< Root for this device's entries */
index d62156b..801118e 100644 (file)
@@ -159,15 +159,8 @@ __setup( DRIVER_NAME "=", DRM_OPTIONS_FUNC );
 #undef DRM_OPTIONS_FUNC
 #endif
 
-/**
- * The default number of instances (minor numbers) to initialize.
- */
-#ifndef DRIVER_NUM_CARDS
-#define DRIVER_NUM_CARDS 1
-#endif
-
-static drm_device_t    *DRM(device);
-static int             *DRM(minor);
+#define MAX_DEVICES 4
+static drm_device_t    DRM(device)[MAX_DEVICES];
 static int             DRM(numdevs) = 0;
 
 DRIVER_FOPS;
@@ -534,52 +527,112 @@ static int DRM(takedown)( drm_device_t *dev )
        return 0;
 }
 
-/**
- * Figure out how many instances to initialize.
- *
- * \return number of cards found.
- *
- * Searches for every PCI card in \c DRIVER_CARD_LIST with matching vendor and device ids.
- */
-static int drm_count_cards(void)
+static drm_pci_id_list_t DRM(pciidlist)[] = {
+       DRIVER_PCI_IDS
+};
+
+static int probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-       int num = 0;
-#if defined(DRIVER_CARD_LIST)
-       int i;
-       drm_pci_list_t *l;
-       u16 device, vendor;
-       struct pci_dev *pdev = NULL;
+       drm_device_t *dev;
+#if __HAVE_CTX_BITMAP
+       int retcode;
 #endif
+       int i;
+       char *desc = NULL;
 
        DRM_DEBUG( "\n" );
 
-#if defined(DRIVER_COUNT_CARDS)
-       num = DRIVER_COUNT_CARDS();
-#elif defined(DRIVER_CARD_LIST)
-       for (i = 0, l = DRIVER_CARD_LIST; l[i].vendor != 0; i++) {
-               pdev = NULL;
-               vendor = l[i].vendor;
-               device = l[i].device;
-               if(device == 0xffff) device = PCI_ANY_ID;
-               if(vendor == 0xffff) vendor = PCI_ANY_ID;
-               while ((pdev = pci_find_device(vendor, device, pdev))) {
-                       num++;
+       for (i = 0; DRM(pciidlist)[i].vendor != 0; i++) {
+               if ((DRM(pciidlist)[i].vendor == pdev->vendor) &&
+                   (DRM(pciidlist)[i].device == pdev->device)) {
+                       desc = DRM(pciidlist)[i].name;
                }
        }
-#else
-       num = DRIVER_NUM_CARDS;
+       if (desc == NULL)
+               return -ENODEV;
+
+       if (DRM(numdevs) >= MAX_DEVICES)
+               return -ENODEV;
+
+       dev = &(DRM(device)[DRM(numdevs)]);
+
+       memset( (void *)dev, 0, sizeof(*dev) );
+       dev->count_lock = SPIN_LOCK_UNLOCKED;
+       init_timer( &dev->timer );
+       sema_init( &dev->struct_sem, 1 );
+
+       if ((dev->minor = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0)
+               return -EPERM;
+       dev->device = MKDEV(DRM_MAJOR, dev->minor );
+       dev->name   = DRIVER_NAME;
+       dev->pdev   = pdev;
+#ifdef __alpha__
+       dev->hose   = pdev->sysdata;
 #endif
-       DRM_DEBUG("numdevs = %d\n", num);
-       return num;
+
+       DRIVER_PREINIT();
+
+#if __REALLY_HAVE_AGP
+       dev->agp = DRM(agp_init)();
+#if __MUST_HAVE_AGP
+       if ( dev->agp == NULL ) {
+               DRM_ERROR( "Cannot initialize the agpgart module.\n" );
+               DRM(stub_unregister)(dev->minor);
+               DRM(takedown)( dev );
+               return -ENOMEM;
+       }
+#endif
+#if __REALLY_HAVE_MTRR
+       if (dev->agp)
+               dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
+                                       dev->agp->agp_info.aper_size*1024*1024,
+                                       MTRR_TYPE_WRCOMB,
+                                       1 );
+#endif
+#endif
+
+#if __HAVE_CTX_BITMAP
+       retcode = DRM(ctxbitmap_init)( dev );
+       if( retcode ) {
+               DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
+               DRM(stub_unregister)(dev->minor);
+               DRM(takedown)( dev );
+               return retcode;
+       }
+#endif
+       DRM(numdevs)++; /* no errors, mark it reserved */
+       
+       DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n",
+               DRIVER_NAME,
+               DRIVER_MAJOR,
+               DRIVER_MINOR,
+               DRIVER_PATCHLEVEL,
+               DRIVER_DATE,
+               dev->minor );
+
+       DRIVER_POSTINIT();
+
+       return 0;
+}
+
+static void __exit remove(struct pci_dev *dev)
+{
 }
 
+static struct pci_driver driver = {
+       .name     = DRIVER_NAME,
+       .id_table = NULL,
+       .probe    = probe,
+       .remove   = remove,
+};
+
 /**
  * Module initialization. Called via init_module at module load time, or via
  * linux/init/main.c (this is not currently supported).
  *
  * \return zero on success or a negative number on failure.
  *
- * Allocates and initialize an array of drm_device structures, and attempts to
+ * Initializes an array of drm_device structures, and attempts to
  * initialize all available devices, using consecutive minors, registering the
  * stubs and initializing the AGP device.
  * 
@@ -588,89 +641,15 @@ static int drm_count_cards(void)
  */
 static int __init drm_init( void )
 {
-
-       drm_device_t *dev;
-       int i;
-#if __HAVE_CTX_BITMAP
-       int retcode;
-#endif
        DRM_DEBUG( "\n" );
 
 #ifdef MODULE
        DRM(parse_options)( drm_opts );
 #endif
 
-       DRM(numdevs) = drm_count_cards();
-       /* Force at least one instance. */
-       if (DRM(numdevs) <= 0)
-               DRM(numdevs) = 1;
-
-       DRM(device) = kmalloc(sizeof(*DRM(device)) * DRM(numdevs), GFP_KERNEL);
-       if (!DRM(device)) {
-               return -ENOMEM;
-       }
-       DRM(minor) = kmalloc(sizeof(*DRM(minor)) * DRM(numdevs), GFP_KERNEL);
-       if (!DRM(minor)) {
-               kfree(DRM(device));
-               return -ENOMEM;
-       }
-
-       DRIVER_PREINIT();
-
        DRM(mem_init)();
 
-       for (i = 0; i < DRM(numdevs); i++) {
-               dev = &(DRM(device)[i]);
-               memset( (void *)dev, 0, sizeof(*dev) );
-               dev->count_lock = SPIN_LOCK_UNLOCKED;
-               init_timer( &dev->timer );
-               sema_init( &dev->struct_sem, 1 );
-
-               if ((DRM(minor)[i] = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0)
-                       return -EPERM;
-               dev->device = MKDEV(DRM_MAJOR, DRM(minor)[i] );
-               dev->name   = DRIVER_NAME;
-
-#if __REALLY_HAVE_AGP
-               dev->agp = DRM(agp_init)();
-#if __MUST_HAVE_AGP
-               if ( dev->agp == NULL ) {
-                       DRM_ERROR( "Cannot initialize the agpgart module.\n" );
-                       DRM(stub_unregister)(DRM(minor)[i]);
-                       DRM(takedown)( dev );
-                       return -ENOMEM;
-               }
-#endif
-#if __REALLY_HAVE_MTRR
-               if (dev->agp)
-                       dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
-                                      dev->agp->agp_info.aper_size*1024*1024,
-                                      MTRR_TYPE_WRCOMB,
-                                      1 );
-#endif
-#endif
-
-#if __HAVE_CTX_BITMAP
-               retcode = DRM(ctxbitmap_init)( dev );
-               if( retcode ) {
-                       DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
-                       DRM(stub_unregister)(DRM(minor)[i]);
-                       DRM(takedown)( dev );
-                       return retcode;
-               }
-#endif
-               DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n",
-                       DRIVER_NAME,
-                       DRIVER_MAJOR,
-                       DRIVER_MINOR,
-                       DRIVER_PATCHLEVEL,
-                       DRIVER_DATE,
-                       DRM(minor)[i] );
-       }
-
-       DRIVER_POSTINIT();
-
-       return 0;
+       return pci_module_init (&driver);;
 }
 
 /**
@@ -687,12 +666,14 @@ static void __exit drm_cleanup( void )
 
        DRM_DEBUG( "\n" );
 
+       pci_unregister_driver (&driver);
+
        for (i = DRM(numdevs) - 1; i >= 0; i--) {
                dev = &(DRM(device)[i]);
-               if ( DRM(stub_unregister)(DRM(minor)[i]) ) {
+               if ( DRM(stub_unregister)(dev->minor) ) {
                        DRM_ERROR( "Cannot unload module\n" );
                } else {
-                       DRM_DEBUG("minor %d unregistered\n", DRM(minor)[i]);
+                       DRM_DEBUG("minor %d unregistered\n", dev->minor);
                        if (i == 0) {
                                DRM_INFO( "Module unloaded\n" );
                        }
@@ -722,8 +703,6 @@ static void __exit drm_cleanup( void )
 #endif
        }
        DRIVER_POSTCLEANUP();
-       kfree(DRM(minor));
-       kfree(DRM(device));
        DRM(numdevs) = 0;
 }
 
@@ -795,7 +774,7 @@ int DRM(open)( struct inode *inode, struct file *filp )
        int i;
 
        for (i = 0; i < DRM(numdevs); i++) {
-               if (minor(inode->i_rdev) == DRM(minor)[i]) {
+               if (minor(inode->i_rdev) == DRM(device)[i].minor) {
                        dev = &(DRM(device)[i]);
                        break;
                }
index 54dafcf..407eb36 100644 (file)
        [DRM_IOCTL_NR(DRM_IOCTL_GAMMA_INIT)] = { gamma_dma_init,  1, 1 }, \
        [DRM_IOCTL_NR(DRM_IOCTL_GAMMA_COPY)] = { gamma_dma_copy,  1, 1 }
 
+#define DRIVER_PCI_IDS                                                 \
+       {0x3d3d, 0x0008, 0, "3DLabs GLINT Gamma G1"},                   \
+       {0, 0, 0, NULL}
+
 #define IOCTL_TABLE_NAME       DRM(ioctls)
 #define IOCTL_FUNC_NAME        DRM(ioctl)
 
index a5d300a..d4098e4 100644 (file)
        [DRM_IOCTL_NR(DRM_IOCTL_I810_MC)]      = { i810_dma_mc,     1, 1 }, \
        [DRM_IOCTL_NR(DRM_IOCTL_I810_RSTATUS)] = { i810_rstatus,    1, 0 }, \
        [DRM_IOCTL_NR(DRM_IOCTL_I810_FLIP)] =    { i810_flip_bufs,  1, 0 }
+
+#define DRIVER_PCI_IDS                                                 \
+       {0x8086, 0x7121, 0, "Intel i810 GMCH"},                         \
+       {0x8086, 0x7123, 0, "Intel i810-DC100 GMCH"},                   \
+       {0x8086, 0x7125, 0, "Intel i810E GMCH"},                        \
+       {0x8086, 0x1132, 0, "Intel i815 GMCH"},                         \
+       {0, 0, 0, NULL}
+
 
 #define __HAVE_COUNTERS         4
 #define __HAVE_COUNTER6         _DRM_STAT_IRQ
index 5775162..cd770bb 100644 (file)
        [DRM_IOCTL_NR(DRM_IOCTL_I830_GETPARAM)] = { i830_getparam,  1, 0 }, \
        [DRM_IOCTL_NR(DRM_IOCTL_I830_SETPARAM)] = { i830_setparam,  1, 0 } 
 
+#define DRIVER_PCI_IDS                                                 \
+       {0x8086, 0x3577, 0, "Intel i830M GMCH"},                                \
+       {0x8086, 0x2562, 0, "Intel i845G GMCH"},                                \
+       {0, 0, 0, NULL}
+
 #define __HAVE_COUNTERS         4
 #define __HAVE_COUNTER6         _DRM_STAT_IRQ
 #define __HAVE_COUNTER7         _DRM_STAT_PRIMARY
index 8b79018..fafa1f9 100644 (file)
 #include "tdfx.h"
 #include "drmP.h"
 
-#define DRIVER_AUTHOR          "VA Linux Systems Inc."
-
-#define DRIVER_NAME            "tdfx"
-#define DRIVER_DESC            "3dfx Banshee/Voodoo3+"
-#define DRIVER_DATE            "20010216"
-
-#define DRIVER_MAJOR           1
-#define DRIVER_MINOR           0
-#define DRIVER_PATCHLEVEL      0
-
-#ifndef PCI_VENDOR_ID_3DFX
-#define PCI_VENDOR_ID_3DFX 0x121A
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO5
-#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO4
-#define PCI_DEVICE_ID_3DFX_VOODOO4 0x0007
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_3000 /* Voodoo3 3000 */
-#define PCI_DEVICE_ID_3DFX_VOODOO3_3000 0x0005
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_2000 /* Voodoo3 3000 */
-#define PCI_DEVICE_ID_3DFX_VOODOO3_2000 0x0004
-#endif
-#ifndef PCI_DEVICE_ID_3DFX_BANSHEE
-#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
-#endif
-
-static drm_pci_list_t DRM(idlist)[] = {
-       { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE },
-       { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3_2000 },
-       { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3_3000 },
-       { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO4 },
-       { PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO5 },
-       { 0, 0 }
-};
-
-#define DRIVER_CARD_LIST DRM(idlist)
-
-
 #include "drm_auth.h"
 #include "drm_bufs.h"
 #include "drm_context.h"
similarity index 75%
rename from linux/tdfx.h
rename to shared-core/tdfx_drv.h
index 40aba8f..642b08d 100644 (file)
 #define __HAVE_MTRR            1
 #define __HAVE_CTX_BITMAP      1
 
+#define DRIVER_AUTHOR          "VA Linux Systems Inc."
+
+#define DRIVER_NAME            "tdfx"
+#define DRIVER_DESC            "3dfx Banshee/Voodoo3+"
+#define DRIVER_DATE            "20010216"
+
+#define DRIVER_MAJOR           1
+#define DRIVER_MINOR           0
+#define DRIVER_PATCHLEVEL      0
+
+#define DRIVER_PCI_IDS                                                 \
+       {0x121a, 0x0003, 0, "3dfx Voodoo Banshee"},                     \
+       {0x121a, 0x0004, 0, "3dfx Voodoo3 2000"},                       \
+       {0x121a, 0x0005, 0, "3dfx Voodoo3 3000"},                       \
+       {0x121a, 0x0007, 0, "3dfx Voodoo4"},                            \
+       {0x121a, 0x0009, 0, "3dfx Voodoo5"},                            \
+       {0, 0, 0, NULL}
+
 #endif
index 9617962..696a3b5 100644 (file)
        [DRM_IOCTL_NR(DRM_IOCTL_MGA_BLIT)]    = { mga_dma_blit,    1, 0 }, \
        [DRM_IOCTL_NR(DRM_IOCTL_MGA_GETPARAM)]= { mga_getparam,    1, 0 },
 
+#define DRIVER_PCI_IDS                                                 \
+       {0x102b, 0x0521, 0, "Matrox G200 (AGP)"},                       \
+       {0x102b, 0x0525, 0, "Matrox G400/G450 (AGP)"},                  \
+       {0x102b, 0x2527, 0, "Matrox G550 (AGP)"},                       \
+       {0, 0, 0, NULL}
+
 #define __HAVE_COUNTERS         3
 #define __HAVE_COUNTER6         _DRM_STAT_IRQ
 #define __HAVE_COUNTER7         _DRM_STAT_PRIMARY
index 9c3363b..2047e4a 100644 (file)
    [DRM_IOCTL_NR(DRM_IOCTL_R128_INDIRECT)]   = { r128_cce_indirect, 1, 1 }, \
    [DRM_IOCTL_NR(DRM_IOCTL_R128_GETPARAM)]   = { r128_getparam, 1, 0 },
 
+#define DRIVER_PCI_IDS                                                 \
+       {0x1002, 0x4c45, 0, "ATI Rage 128 Mobility LE (PCI)"},          \
+       {0x1002, 0x4c46, 0, "ATI Rage 128 Mobility LF (AGP)"},          \
+       {0x1002, 0x4d46, 0, "ATI Rage 128 Mobility MF (AGP)"},          \
+       {0x1002, 0x4d4c, 0, "ATI Rage 128 Mobility ML (AGP)"},          \
+       {0x1002, 0x5044, 0, "ATI Rage 128 Pro PD (PCI)"},               \
+       {0x1002, 0x5046, 0, "ATI Rage 128 Pro PF (AGP)"},               \
+       {0x1002, 0x5050, 0, "ATI Rage 128 Pro PP (PCI)"},               \
+       {0x1002, 0x5052, 0, "ATI Rage 128 Pro PR (PCI)"},               \
+       {0x1002, 0x5245, 0, "ATI Rage 128 RE (PCI)"},                   \
+       {0x1002, 0x5246, 0, "ATI Rage 128 RF (AGP)"},                   \
+       {0x1002, 0x5247, 0, "ATI Rage 128 RG (AGP)"},                   \
+       {0x1002, 0x524b, 0, "ATI Rage 128 RK (PCI)"},                   \
+       {0x1002, 0x524c, 0, "ATI Rage 128 RL (AGP)"},                   \
+       {0x1002, 0x534d, 0, "ATI Rage 128 SM (AGP)"},                   \
+       {0x1002, 0x5446, 0, "ATI Rage 128 Pro Ultra TF (AGP)"},         \
+       {0x1002, 0x544C, 0, "ATI Rage 128 Pro Ultra TL (AGP)"},         \
+       {0x1002, 0x5452, 0, "ATI Rage 128 Pro Ultra TR (AGP)"},         \
+       {0, 0, 0, NULL}
+
 /* Driver customization:
  */
 #define DRIVER_PRERELEASE() do {                                       \
index 440f96e..e66c11f 100644 (file)
  [DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_EMIT)]   = { radeon_irq_emit, 1, 0 }, \
  [DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_WAIT)]   = { radeon_irq_wait, 1, 0 },
 
+#define DRIVER_PCI_IDS                                                 \
+       {0x1002, 0x4242, 0, "ATI Radeon BB R200 AIW 8500DV"},           \
+       {0x1002, 0x4964, 0, "ATI Radeon Id R250 9000"},                 \
+       {0x1002, 0x4965, 0, "ATI Radeon Ie R250 9000"},                 \
+       {0x1002, 0x4966, 0, "ATI Radeon If R250 9000"},                 \
+       {0x1002, 0x4967, 0, "ATI Radeon Ig R250 9000"},                 \
+       {0x1002, 0x4C57, 0, "ATI Radeon LW Mobility 7500 M7"},          \
+       {0x1002, 0x4C58, 0, "ATI Radeon LX RV200 Mobility FireGL 7800 M7"}, \
+       {0x1002, 0x4C59, 0, "ATI Radeon LY Mobility M6"},               \
+       {0x1002, 0x4C5A, 0, "ATI Radeon LZ Mobility M6"},               \
+       {0x1002, 0x4C64, 0, "ATI Radeon Ld R250 Mobility 9000 M9"},     \
+       {0x1002, 0x4C65, 0, "ATI Radeon Le R250 Mobility 9000 M9"},     \
+       {0x1002, 0x4C66, 0, "ATI Radeon Lf R250 Mobility 9000 M9"},     \
+       {0x1002, 0x4C67, 0, "ATI Radeon Lg R250 Mobility 9000 M9"},     \
+       {0x1002, 0x5144, 0, "ATI Radeon QD R100"},                      \
+       {0x1002, 0x5145, 0, "ATI Radeon QE R100"},                      \
+       {0x1002, 0x5146, 0, "ATI Radeon QF R100"},                      \
+       {0x1002, 0x5147, 0, "ATI Radeon QG R100"},                      \
+       {0x1002, 0x5148, 0, "ATI Radeon QH R200 8500"},                 \
+       {0x1002, 0x5149, 0, "ATI Radeon QI R200"},                      \
+       {0x1002, 0x514A, 0, "ATI Radeon QJ R200"},                      \
+       {0x1002, 0x514B, 0, "ATI Radeon QK R200"},                      \
+       {0x1002, 0x514C, 0, "ATI Radeon QL R200 8500 LE"},              \
+       {0x1002, 0x514D, 0, "ATI Radeon QM R200 9100"},                 \
+       {0x1002, 0x514E, 0, "ATI Radeon QN R200 8500 LE"},              \
+       {0x1002, 0x514F, 0, "ATI Radeon QO R200 8500 LE"},              \
+       {0x1002, 0x5157, 0, "ATI Radeon QW RV200 7500"},                \
+       {0x1002, 0x5158, 0, "ATI Radeon QX RV200 7500"},                \
+       {0x1002, 0x5159, 0, "ATI Radeon QY RV100 7000/VE"},             \
+       {0x1002, 0x515A, 0, "ATI Radeon QZ RV100 7000/VE"},             \
+       {0x1002, 0x5168, 0, "ATI Radeon Qh R200"},                      \
+       {0x1002, 0x5169, 0, "ATI Radeon Qi R200"},                      \
+       {0x1002, 0x516A, 0, "ATI Radeon Qj R200"},                      \
+       {0x1002, 0x516B, 0, "ATI Radeon Qk R200"},                      \
+       {0x1002, 0x516C, 0, "ATI Radeon Ql R200"},                      \
+       {0x1002, 0x5961, 0, "ATI Radeon RV280 9200"},                   \
+       {0, 0, 0, NULL}
 
 
 /* When a client dies:
index 7bdc99c..67b4c45 100644 (file)
        [DRM_IOCTL_NR(DRM_IOCTL_SIS_AGP_FREE)]  = { sis_ioctl_agp_free, 1, 0 }, \
        [DRM_IOCTL_NR(DRM_IOCTL_SIS_FB_INIT)]   = { sis_fb_init,        1, 1 }
 
+#define DRIVER_PCI_IDS                                                 \
+       {0x1039, 0x0300, 0, "SiS 300"},                                 \
+       {0x1039, 0x5300, 0, "SiS 540"},                                 \
+       {0x1039, 0x6300, 0, "SiS 630"},                                 \
+       {0x1039, 0x7300, 0, "SiS 730"},                                 \
+       {0, 0, 0, NULL}
+
 #define __HAVE_COUNTERS                5
 
 /* Buffer customization:
similarity index 75%
rename from bsd/tdfx.h
rename to shared/tdfx.h
index 4e6db52..642b08d 100644 (file)
@@ -25,7 +25,6 @@
  *
  * Authors:
  *    Gareth Hughes <gareth@valinux.com>
- *
  */
 
 #ifndef __TDFX_H__
 #define __HAVE_MTRR            1
 #define __HAVE_CTX_BITMAP      1
 
+#define DRIVER_AUTHOR          "VA Linux Systems Inc."
+
+#define DRIVER_NAME            "tdfx"
+#define DRIVER_DESC            "3dfx Banshee/Voodoo3+"
+#define DRIVER_DATE            "20010216"
+
+#define DRIVER_MAJOR           1
+#define DRIVER_MINOR           0
+#define DRIVER_PATCHLEVEL      0
+
+#define DRIVER_PCI_IDS                                                 \
+       {0x121a, 0x0003, 0, "3dfx Voodoo Banshee"},                     \
+       {0x121a, 0x0004, 0, "3dfx Voodoo3 2000"},                       \
+       {0x121a, 0x0005, 0, "3dfx Voodoo3 3000"},                       \
+       {0x121a, 0x0007, 0, "3dfx Voodoo4"},                            \
+       {0x121a, 0x0009, 0, "3dfx Voodoo5"},                            \
+       {0, 0, 0, NULL}
+
 #endif