diff options
author | Eric Anholt <anholt@freebsd.org> | 2003-10-17 03:14:39 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2003-10-17 03:14:39 +0000 |
commit | ff58476011ba8fe72d65e884380d3d86710bfdd4 (patch) | |
tree | c2855a267ab001340e588ae6b32a55982312cfa0 | |
parent | 355b204de0dbc01308bebc77c4c1c0a9a402cded (diff) |
- Converted Linux drivers to initialize DRM instances based on PCI IDs, not
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, 382 insertions, 643 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h index 2d36c3c8..0a93ef32 100644 --- a/bsd-core/drmP.h +++ b/bsd-core/drmP.h @@ -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; diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c index d517d056..bfded6bb 100644 --- a/bsd-core/drm_drv.c +++ b/bsd-core/drm_drv.c @@ -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 ) diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h index 0bb38ba2..3894f54d 100644 --- a/bsd-core/drm_os_freebsd.h +++ b/bsd-core/drm_os_freebsd.h @@ -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) diff --git a/bsd-core/drm_os_netbsd.h b/bsd-core/drm_os_netbsd.h index 1290e848..47e710c7 100644 --- a/bsd-core/drm_os_netbsd.h +++ b/bsd-core/drm_os_netbsd.h @@ -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) diff --git a/bsd-core/mga_drv.c b/bsd-core/mga_drv.c index 85520d5c..4eaf5edb 100644 --- a/bsd-core/mga_drv.c +++ b/bsd-core/mga_drv.c @@ -36,17 +36,6 @@ #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" diff --git a/bsd-core/r128_drv.c b/bsd-core/r128_drv.c index 14a8cc5f..e656f60d 100644 --- a/bsd-core/r128_drv.c +++ b/bsd-core/r128_drv.c @@ -39,30 +39,6 @@ #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" diff --git a/bsd-core/radeon_drv.c b/bsd-core/radeon_drv.c index 62433c23..3b699768 100644 --- a/bsd-core/radeon_drv.c +++ b/bsd-core/radeon_drv.c @@ -37,45 +37,6 @@ #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" diff --git a/bsd-core/sis_drv.c b/bsd-core/sis_drv.c index 13be07a2..64767a4a 100644 --- a/bsd-core/sis_drv.c +++ b/bsd-core/sis_drv.c @@ -30,13 +30,6 @@ #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" diff --git a/bsd-core/tdfx_drv.c b/bsd-core/tdfx_drv.c index 1c803752..e96216c8 100644 --- a/bsd-core/tdfx_drv.c +++ b/bsd-core/tdfx_drv.c @@ -34,56 +34,12 @@ #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" diff --git a/bsd/Imakefile b/bsd/Imakefile index e51c0737..63e12966 100644 --- a/bsd/Imakefile +++ b/bsd/Imakefile @@ -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) @@ -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; diff --git a/bsd/drm_drv.h b/bsd/drm_drv.h index d517d056..bfded6bb 100644 --- a/bsd/drm_drv.h +++ b/bsd/drm_drv.h @@ -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 ) diff --git a/bsd/drm_os_freebsd.h b/bsd/drm_os_freebsd.h index 0bb38ba2..3894f54d 100644 --- a/bsd/drm_os_freebsd.h +++ b/bsd/drm_os_freebsd.h @@ -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) diff --git a/bsd/drm_os_netbsd.h b/bsd/drm_os_netbsd.h index 1290e848..47e710c7 100644 --- a/bsd/drm_os_netbsd.h +++ b/bsd/drm_os_netbsd.h @@ -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) diff --git a/bsd/mga_drv.c b/bsd/mga_drv.c index 85520d5c..4eaf5edb 100644 --- a/bsd/mga_drv.c +++ b/bsd/mga_drv.c @@ -36,17 +36,6 @@ #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" diff --git a/bsd/r128_drv.c b/bsd/r128_drv.c index 14a8cc5f..e656f60d 100644 --- a/bsd/r128_drv.c +++ b/bsd/r128_drv.c @@ -39,30 +39,6 @@ #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" diff --git a/bsd/radeon_drv.c b/bsd/radeon_drv.c index 62433c23..3b699768 100644 --- a/bsd/radeon_drv.c +++ b/bsd/radeon_drv.c @@ -37,45 +37,6 @@ #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" diff --git a/bsd/sis_drv.c b/bsd/sis_drv.c index 13be07a2..64767a4a 100644 --- a/bsd/sis_drv.c +++ b/bsd/sis_drv.c @@ -30,13 +30,6 @@ #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" diff --git a/bsd/tdfx_drv.c b/bsd/tdfx_drv.c index 1c803752..e96216c8 100644 --- a/bsd/tdfx_drv.c +++ b/bsd/tdfx_drv.c @@ -34,56 +34,12 @@ #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" diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 8a995dbe..f7137b25 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -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 */ diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index d62156b3..801118e3 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -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; } diff --git a/linux-core/tdfx_drv.c b/linux-core/tdfx_drv.c index 8b790188..fafa1f92 100644 --- a/linux-core/tdfx_drv.c +++ b/linux-core/tdfx_drv.c @@ -34,47 +34,6 @@ #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" diff --git a/linux/Makefile.linux b/linux/Makefile.linux index 12e0e8c8..e873242e 100644 --- a/linux/Makefile.linux +++ b/linux/Makefile.linux @@ -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 diff --git a/linux/drmP.h b/linux/drmP.h index 8a995dbe..f7137b25 100644 --- a/linux/drmP.h +++ b/linux/drmP.h @@ -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 */ diff --git a/linux/drm_drv.h b/linux/drm_drv.h index d62156b3..801118e3 100644 --- a/linux/drm_drv.h +++ b/linux/drm_drv.h @@ -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; } diff --git a/linux/gamma.h b/linux/gamma.h index 54dafcfc..407eb369 100644 --- a/linux/gamma.h +++ b/linux/gamma.h @@ -53,6 +53,10 @@ [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) diff --git a/linux/i810.h b/linux/i810.h index a5d300a2..d4098e4d 100644 --- a/linux/i810.h +++ b/linux/i810.h @@ -77,7 +77,14 @@ [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 diff --git a/linux/i830.h b/linux/i830.h index 5775162a..cd770bb5 100644 --- a/linux/i830.h +++ b/linux/i830.h @@ -77,6 +77,11 @@ [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 diff --git a/linux/tdfx_drv.c b/linux/tdfx_drv.c index 8b790188..fafa1f92 100644 --- a/linux/tdfx_drv.c +++ b/linux/tdfx_drv.c @@ -34,47 +34,6 @@ #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" diff --git a/linux/tdfx.h b/shared-core/tdfx_drv.h index 40aba8fb..642b08dc 100644 --- a/linux/tdfx.h +++ b/shared-core/tdfx_drv.h @@ -39,4 +39,22 @@ #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 diff --git a/shared/mga.h b/shared/mga.h index 96179627..696a3b59 100644 --- a/shared/mga.h +++ b/shared/mga.h @@ -64,6 +64,12 @@ [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 diff --git a/shared/r128.h b/shared/r128.h index 9c3363bd..2047e4a4 100644 --- a/shared/r128.h +++ b/shared/r128.h @@ -79,6 +79,26 @@ [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 { \ diff --git a/shared/radeon.h b/shared/radeon.h index 440f96e6..e66c11f7 100644 --- a/shared/radeon.h +++ b/shared/radeon.h @@ -109,6 +109,43 @@ [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: diff --git a/shared/sis.h b/shared/sis.h index 7bdc99c0..67b4c459 100644 --- a/shared/sis.h +++ b/shared/sis.h @@ -62,6 +62,13 @@ [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: diff --git a/bsd/tdfx.h b/shared/tdfx.h index 4e6db524..642b08dc 100644 --- a/bsd/tdfx.h +++ b/shared/tdfx.h @@ -25,7 +25,6 @@ * * Authors: * Gareth Hughes <gareth@valinux.com> - * */ #ifndef __TDFX_H__ @@ -40,4 +39,22 @@ #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 |