I patched my devfs patch so it can be used with the r200 branch. This was needed b/c my original patch depended upon the shared structure introduced for BSD. BTW dose the R200 work on BSD?
__________________________________________________ Do You Yahoo!? Yahoo! Autos - Get free new car price quotes http://autos.yahoo.com
diff -aNur orig/linux/drm/kernel/drm.h myne/linux/drm/kernel/drm.h --- orig/linux/drm/kernel/drm.h Fri Jul 5 03:31:09 2002 +++ myne/linux/drm/kernel/drm.h Wed Jul 10 05:11:30 2002 @@ -80,6 +80,7 @@ #if CONFIG_XFREE86_VERSION >= XFREE86_VERSION(4,1,0,0) #define DRM_MAJOR 226 +/* If max minor is bigger than 9999 there is a buffer overrun */ #define DRM_MAX_MINOR 15 #endif #define DRM_NAME "drm" /* Name in kernel, /dev, and /proc */ @@ -439,7 +440,7 @@ #define DRM_IOCTL_SG_ALLOC DRM_IOW( 0x38, drm_scatter_gather_t) #define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, drm_scatter_gather_t) -/* Device specfic ioctls should only be in their respective headers +/* Device specific ioctls should only be in their respective headers * The device specific ioctl range is 0x40 to 0x79. */ #define DRM_COMMAND_BASE 0x40 diff -aNur orig/linux/drm/kernel/drmP.h myne/linux/drm/kernel/drmP.h --- orig/linux/drm/kernel/drmP.h Fri Jul 5 03:31:09 2002 +++ myne/linux/drm/kernel/drmP.h Wed Jul 10 00:35:48 2002 @@ -69,6 +69,7 @@ #include <linux/tqueue.h> #include <linux/poll.h> #include <asm/pgalloc.h> +#include <linux/devfs_fs_kernel.h> #include "drm.h" #include "drm_os_linux.h" @@ -108,6 +109,8 @@ /* Begin the DRM... */ +#define DRM_SUP_LINUX 1 + #define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then also include looping detection. */ @@ -271,10 +274,13 @@ 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_chipinfo +{ + int vendor; + int device; + int supported; + char *name; +} drm_chipinfo_t; typedef struct drm_ioctl_desc { drm_ioctl_t *func; @@ -522,6 +528,7 @@ char *unique; /* Unique identifier: e.g., busid */ int unique_len; /* Length of unique field */ dev_t device; /* Device number for mknod */ + devfs_handle_t dev_handle; /* Device handel for devfs */ char *devname; /* For /proc/interrupts */ int blocked; /* Blocked due to VC switch? */ diff -aNur orig/linux/drm/kernel/drm_drv.h myne/linux/drm/kernel/drm_drv.h --- orig/linux/drm/kernel/drm_drv.h Fri Jul 5 03:31:09 2002 +++ myne/linux/drm/kernel/drm_drv.h Wed Jul 10 05:53:30 2002 @@ -87,6 +87,16 @@ #ifndef __HAVE_KERNEL_CTX_SWITCH #define __HAVE_KERNEL_CTX_SWITCH 0 #endif +#ifndef DRM_MAX_MINOR +/* + * Do not try to bend the spoon, that's impossible. + * Instead edit drm.h + * + * This is only hear for the case where something is wrong with your computer. + */ +# define DRM_MAX_MINOR 16 +#endif + #ifndef DRIVER_PREINIT #define DRIVER_PREINIT() @@ -145,7 +155,7 @@ #endif /* - * The default number of instances (minor numbers) to initialize. + * The default number of instances (minor numbers) to initialise. */ #ifndef DRIVER_NUM_CARDS #define DRIVER_NUM_CARDS 1 @@ -338,7 +348,7 @@ * in drm_dma_enqueue. This is more resource-efficient for * hardware that does not do DMA, but may mean that * drm_select_queue fails between the time the interrupt is - * initialized and the time the queues are initialized. + * initialised and the time the queues are initialised. */ DRIVER_POSTSETUP(); return 0; @@ -501,14 +511,14 @@ } /* - * Figure out how many instances to initialize. + * Figure out how many instances to initialise. */ static int drm_count_cards(void) { int num = 0; #if defined(DRIVER_CARD_LIST) int i; - drm_pci_list_t *l; + drm_chipinfo_t *l; u16 device, vendor; struct pci_dev *pdev = NULL; #endif @@ -519,14 +529,19 @@ num = DRIVER_COUNT_CARDS(); #elif defined(DRIVER_CARD_LIST) for (i = 0, l = DRIVER_CARD_LIST; l[i].vendor != 0; i++) { + if (l[i].supported) + { 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))) { + printk("There is a %s in slot %s.\n", + l[i].name, pdev->slot_name); num++; } + } } #else num = DRIVER_NUM_CARDS; @@ -556,6 +571,13 @@ /* Force at least one instance. */ if (DRM(numdevs) <= 0) DRM(numdevs) = 1; + /* Make sure not grater than 9999, or we have a buffer overrun */ + if (DRM(numdevs) > DRM_MAX_MINOR) { + printk("Max number of cards is %d.\n", DRM_MAX_MINOR); + printk("Try increasing DRM_MAX_MINOR to %d.\n", + DRM(numdevs) + 1); + DRM(numdevs) = DRM_MAX_MINOR; + } DRM(device) = kmalloc(sizeof(*DRM(device)) * DRM(numdevs), GFP_KERNEL); if (!DRM(device)) { @@ -635,6 +657,7 @@ for (i = DRM(numdevs) - 1; i >= 0; i--) { dev = &(DRM(device)[i]); + devfs_unregister(dev->dev_handle); if ( DRM(stub_unregister)(DRM(minor)[i]) ) { DRM_ERROR( "Cannot unload module\n" ); } else { diff -aNur orig/linux/drm/kernel/drm_stub.h myne/linux/drm/kernel/drm_stub.h --- orig/linux/drm/kernel/drm_stub.h Thu May 16 18:47:15 2002 +++ myne/linux/drm/kernel/drm_stub.h Wed Jul 10 05:45:55 2002 @@ -31,7 +31,10 @@ #define __NO_VERSION__ #include "drmP.h" -#define DRM_STUB_MAXCARDS 16 /* Enough for one machine */ +#ifndef DRM_MAX_MINOR +#define DRM_MAX_MINOR 16 /* Enough for one machine */ +#endif +#define DRM_STUB_MAXCARDS ( DRM_MAX_MINOR + 1 ) static struct drm_stub_list { const char *name; @@ -45,8 +48,11 @@ int (*info_register)(const char *name, struct file_operations *fops, drm_device_t *dev); int (*info_unregister)(int minor); + devfs_handle_t *info_handle; } DRM(stub_info); +static devfs_handle_t DRM(devfs_dir_dri); + static int DRM(stub_open)(struct inode *inode, struct file *filp) { int minor = minor(inode->i_rdev); @@ -84,6 +90,7 @@ DRM(stub_list)[i].fops = NULL; } } + for (i = 0; i < DRM_STUB_MAXCARDS; i++) { if (!DRM(stub_list)[i].fops) { DRM(stub_list)[i].name = name; @@ -111,7 +118,8 @@ DRM(free)(DRM(stub_list), sizeof(*DRM(stub_list)) * DRM_STUB_MAXCARDS, DRM_MEM_STUB); - unregister_chrdev(DRM_MAJOR, "drm"); + devfs_unregister_chrdev(DRM_MAJOR, "drm"); + devfs_unregister(DRM(devfs_dir_dri)); } return 0; } @@ -121,25 +129,60 @@ drm_device_t *dev) { struct drm_stub_info *i = NULL; + int minor; + char buff[8]; DRM_DEBUG("\n"); - if (register_chrdev(DRM_MAJOR, "drm", &DRM(stub_fops))) + /* + * FIX-ME + * + * The first drm gets stuck if another drm is loaded + * and can not be unloaded if it needs to be. + * You will have to unload ALL dris. + * + * This is because the other dri modules will increment + * the first dri's use count, making lsmod look funny. + * + * inter_module_get (called if devfs_register_chrdev returns error + * I.E. another drm already registered DRM_MAJOR) + * increments the module use count of the dri that calls + * inter_module_register. + * + * The dri that calls inter_module_register may also + * call inter_module_put and deinc it's own use count. + * It may not be intended to work that way, how ever I + * see no problem in kernel/module.c with doing it this way. + * + */ + if (devfs_register_chrdev(DRM_MAJOR, "drm", &DRM(stub_fops))) i = (struct drm_stub_info *)inter_module_get("drm"); if (i) { /* Already registered */ DRM(stub_info).info_register = i->info_register; DRM(stub_info).info_unregister = i->info_unregister; + DRM(stub_info).info_handle = i->info_handle; + DRM(devfs_dir_dri) = *DRM(stub_info).info_handle; DRM_DEBUG("already registered\n"); } else if (DRM(stub_info).info_register != DRM(stub_getminor)) { + DRM(devfs_dir_dri) = devfs_mk_dir(NULL, "dri", NULL); DRM(stub_info).info_register = DRM(stub_getminor); DRM(stub_info).info_unregister = DRM(stub_putminor); + DRM(stub_info).info_handle = &DRM(devfs_dir_dri); DRM_DEBUG("calling inter_module_register\n"); inter_module_register("drm", THIS_MODULE, &DRM(stub_info)); } if (DRM(stub_info).info_register) - return DRM(stub_info).info_register(name, fops, dev); - return -1; + { minor = DRM(stub_info).info_register(name, fops, dev); } + else return -1; + + sprintf(buff, "card%d", minor); + dev->dev_handle = devfs_register(DRM(devfs_dir_dri), buff, + DEVFS_FL_DEFAULT, DRM_MAJOR, minor, + S_IFCHR | S_IRUGO | S_IWUGO, + fops, NULL); + + return minor; } int DRM(stub_unregister)(int minor) diff -aNur orig/linux/drm/kernel/radeon_drv.c myne/linux/drm/kernel/radeon_drv.c --- orig/linux/drm/kernel/radeon_drv.c Fri Jul 5 03:31:10 2002 +++ myne/linux/drm/kernel/radeon_drv.c Wed Jul 10 06:01:43 2002 @@ -32,6 +32,7 @@ #include "drmP.h" #include "drm.h" #include "radeon_drm.h" +#define DEVICELIST #include "radeon_drv.h" #include "ati_pcigart.h" diff -aNur orig/linux/drm/kernel/drm_sup.h myne/linux/drm/kernel/drm_sup.h --- orig/linux/drm/kernel/drm_sup.h Wed Dec 31 18:00:00 1969 +++ myne/linux/drm/kernel/drm_sup.h Wed Jul 10 05:57:32 2002 @@ -0,0 +1,25 @@ +/* drm_sup.h -- This is for DRM specific kernel identifiers. + * + * Add your DRM_SUP_* hear if your going to use our PCI ids. + * + * Authors: + * Mike Mestnik <[EMAIL PROTECTED]> + */ + +#include "drmP.h" /* so the below can't get miss defined */ + +#ifndef DRM_SUP_LINUX +#ifdef __linux__ +#define DRM_SUP_LINUX 1 +#else +#define DRM_SUP_LINUX 0 +#endif +#endif + +#ifndef DRM_SUP_BSD +#if (defined __NetBSD__ | defined __FreeBSD) +#define DRM_SUP_BSD 1 +#else +#define DRM_SUP_BSD 0 +#endif +#endif diff -aNur orig/linux/drm/kernel/radeon_drv.h myne/linux/drm/kernel/radeon_drv.h --- orig/linux/drm/kernel/radeon_drv.h Fri Jul 5 03:31:11 2002 +++ myne/linux/drm/kernel/radeon_drv.h Wed Jul 10 06:01:31 2002 @@ -31,6 +31,9 @@ #ifndef __RADEON_DRV_H__ #define __RADEON_DRV_H__ +#include "drmP.h" /* drm_chipinfo */ +#include "drm_sup.h" + #define GET_RING_HEAD(ring) DRM_READ32( (volatile u32 *) (ring)->head ) #define SET_RING_HEAD(ring,val) DRM_WRITE32( (volatile u32 *) (ring)->head , (val)) @@ -754,6 +757,26 @@ write &= mask; \ } while (0) +#ifdef DEVICELIST +/* List acquired from http://www.yourvote.com/pci/pcihdr.h and +xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h + * Please report to [EMAIL PROTECTED] inaccuracies or if a chip you have works that is +marked unsupported here. + */ +drm_chipinfo_t DRM(devicelist)[] = { + {0x1002, 0x4C57, 1, "ATI Radeon LW Mobility 7 (AGP)"}, + {0x1002, 0x4C59, 1, "ATI Radeon LY Mobility 6 (AGP)"}, + {0x1002, 0x4C5A, 1, "ATI Radeon LZ Mobility 6 (AGP)"}, + {0x1002, 0x5144, 1, "ATI Radeon QD (AGP)"}, + {0x1002, 0x5145, 1, "ATI Radeon QE (AGP)"}, + {0x1002, 0x5146, 1, "ATI Radeon QF (AGP)"}, + {0x1002, 0x5147, 1, "ATI Radeon QG (AGP)"}, + {0x1002, 0x5157, 1, "ATI Radeon QW 7500 (AGP)"}, + {0x1002, 0x5159, 1, "ATI Radeon QY VE (AGP)"}, + {0x1002, 0x515A, 1, "ATI Radeon QZ VE (AGP)"}, + {0, 0, 0, NULL} +}; + +#define DRIVER_CARD_LIST DRM(devicelist) +#endif #define RADEON_PERFORMANCE_BOXES 0