diff options
Diffstat (limited to 'linux-core')
47 files changed, 2167 insertions, 1385 deletions
diff --git a/linux-core/Makefile b/linux-core/Makefile index 040b4527..f3bbce06 100644 --- a/linux-core/Makefile +++ b/linux-core/Makefile @@ -50,7 +50,7 @@ endif MACHINE := $(shell uname -m) # Modules for all architectures -MODULE_LIST := tdfx.o r128.o radeon.o mga.o sis.o savage.o via.o mach64.o +MODULE_LIST := drm.0 tdfx.o r128.o radeon.o mga.o sis.o savage.o via.o mach64.o # Modules only for ix86 architectures ifneq (,$(findstring 86,$(MACHINE))) @@ -67,44 +67,36 @@ DRM_MODULES ?= $(MODULE_LIST) # These definitions are for handling dependencies in the out of kernel build. -DRMTEMPLATES = drm_auth.h drm_bufs.h drm_context.h drm_dma.h drm_drawable.h \ - drm_drv.h drm_fops.h drm_init.h drm_ioctl.h drm_irq.h \ - drm_lock.h drm_memory.h drm_proc.h drm_stub.h drm_vm.h \ - drm_core.h - DRMSHARED = drm.h drm_sarea.h -DRMHEADERS = drmP.h $(DRMSHARED) - -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) \ - $(DRMTEMPLATES) -RADEONSHARED = radeon.h radeon_drv.h radeon_drm.h radeon_cp.c radeon_irq.c \ +DRMHEADERS = drmP.h drm_compat.h drm_os_linux.h drm_module.h $(DRMSHARED) +COREHEADERS = drm_core.h + +TDFXHEADERS = tdfx_drv.h $(DRMHEADERS) +TDFXSHARED = tdfx_drv.h +R128HEADERS = r128_drv.h r128_drm.h $(DRMHEADERS) +R128SHARED = r128_drv.h r128_drm.h r128_cce.c r128_state.c r128_irq.c +RADEONHEADERS = radeon_drv.h radeon_drm.h $(DRMHEADERS) +RADEONSHARED = radeon_drv.h radeon_drm.h radeon_cp.c radeon_irq.c \ radeon_mem.c radeon_state.c -MGAHEADERS = mga.h mga_drv.h mga_drm.h mga_ucode.h $(DRMHEADERS) \ - $(DRMTEMPLATES) -MGASHARED = mga.h mga_dma.c mga_drm.h mga_drv.h mga_irq.c mga_state.c \ +MGAHEADERS = mga_drv.h mga_drm.h mga_ucode.h $(DRMHEADERS) +MGASHARED = mga_dma.c mga_drm.h mga_drv.h mga_irq.c mga_state.c \ mga_ucode.h mga_warp.c -I810HEADERS = i810.h i810_drv.h i810_drm.h $(DRMHEADERS) $(DRMTEMPLATES) -I830HEADERS = i830.h i830_drv.h i830_drm.h $(DRMHEADERS) $(DRMTEMPLATES) -I915HEADERS = i915.h i915_drv.h i915_drm.h $(DRMHEADERS) $(DRMTEMPLATES) -I915SHARED = i915.h i915_drv.h i915_drm.h i915_irq.c i915_mem.c i915_dma.c -SISHEADERS= sis.h sis_drv.h sis_drm.h $(DRMHEADERS) -SISSHARED= sis.h sis_drv.h sis_drm.h sis_ds.c sis_ds.h sis_mm.c -SAVAGEHEADERS= savage.h savage_drv.h savage_drm.h $(DRMHEADERS) \ - $(DRMTEMPLATES) -VIAHEADERS = via_drm.h via_drv.h via.h via_mm.h via_ds.h \ - via_3d_reg.h $(DRMHEADERS) $(DRMTEMPLATES) -VIASHARED = via_drm.h via_drv.h via.h via_mm.h via_ds.h \ +I810HEADERS = i810_drv.h i810_drm.h $(DRMHEADERS) +I830HEADERS = i830_drv.h i830_drm.h $(DRMHEADERS) +I915HEADERS = i915_drv.h i915_drm.h $(DRMHEADERS) +I915SHARED = i915_drv.h i915_drm.h i915_irq.c i915_mem.c i915_dma.c +SISHEADERS= sis_drv.h sis_drm.h $(DRMHEADERS) +SISSHARED= sis_drv.h sis_drm.h sis_ds.c sis_ds.h sis_mm.c +SAVAGEHEADERS= savage_drv.h savage_drm.h $(DRMHEADERS) +VIAHEADERS = via_drm.h via_drv.h via_mm.h via_ds.h \ + via_3d_reg.h $(DRMHEADERS) +VIASHARED = via_drm.h via_drv.h via_mm.h via_ds.h \ via_3d_reg.h via_drv.c via_ds.c via_irq.c via_map.c \ via_mm.c via_dma.c -MACH64HEADERS = mach64.h mach64_drv.h mach64_drm.h $(DRMHEADERS) \ - $(DRMTEMPLATES) -MACH64SHARED = mach64.h mach64_drv.h mach64_drm.h mach64_dma.c \ +MACH64HEADERS = mach64_drv.h mach64_drm.h $(DRMHEADERS) +MACH64SHARED = mach64_drv.h mach64_drm.h mach64_dma.c \ mach64_irq.c mach64_state.c -FFBHEADERS = ffb.h ffb_drv.h $(DRMHEADERS) $(DRMTEMPLATES) +FFBHEADERS = ffb_drv.h $(DRMHEADERS) SHAREDSRC = $(DRMSHARED) $(MGASHARED) $(R128SHARED) $(RADEONSHARED) \ $(SISSHARED) $(TDFXSHARED) $(VIASHARED) $(MACH64SHARED) \ @@ -172,10 +164,6 @@ endif endif -ifneq ($(findstring 2.6,$(RUNNING_REL)),) -$(error Building 2.4 version on $(RUNNING_REL)) -endif - CLEANCONFIG := $(shell if cmp -s $(LINUXDIR)/.config .config; then echo y; fi) ifeq ($(CLEANCONFIG),y) CLEANFILES += $(LINUXDIR)/.config .config $(LINUXDIR)/tmp_include_depends @@ -227,7 +215,7 @@ endif # Make sure that the shared source files are linked into this directory. -SHAREDDIR := ../shared +SHAREDDIR := ../shared-core HASSHARED := $(shell if [ -d $(SHAREDDIR) ]; then echo y; fi) @@ -389,6 +377,7 @@ endif include $(DRMSRCDIR)/Makefile.kernel # Depencencies +$(drm-objs): $(DRMHEADERS) $(COREHEADERS) $(tdfx-objs): $(TDFXHEADERS) $(r128-objs): $(R128HEADERS) $(mga-objs): $(MGAHEADERS) diff --git a/linux-core/Makefile.kernel b/linux-core/Makefile.kernel index 92e3f73e..92f2f3a2 100644 --- a/linux-core/Makefile.kernel +++ b/linux-core/Makefile.kernel @@ -7,40 +7,25 @@ # $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel,v 1.18 2003/08/16 17:59:17 dawes Exp $ # +drm-objs := drm_auth.o drm_bufs.o drm_context.o drm_dma.o drm_drawable.o \ + drm_drv.o drm_fops.o drm_init.o drm_ioctl.o drm_irq.o \ + drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \ + drm_sysfs.o drm_pci.o drm_agpsupport.o drm_scatter.o \ + drm_sysfs.o tdfx-objs := tdfx_drv.o r128-objs := r128_drv.o r128_cce.o r128_state.o r128_irq.o mga-objs := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o i810-objs := i810_drv.o i810_dma.o i830-objs := i830_drv.o i830_dma.o i830_irq.o i915-objs := i915_drv.o i915_dma.o i915_irq.o i915_mem.o -radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o +radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o radeon_i2c.o sis-objs := sis_drv.o sis_ds.o sis_mm.o ffb-objs := ffb_drv.o ffb_context.o savage-objs := savage_drv.o savage_dma.o via-objs := via_irq.o via_drv.o via_ds.o via_map.o via_mm.o via_dma.o mach64-objs := mach64_drv.o mach64_dma.o mach64_irq.o mach64_state.o -# Kernel version checks - -BELOW25 := $(shell if [ $(PATCHLEVEL) -lt 5 ]; then echo y; fi) - -# There were major build changes starting with 2.5.52 -ifneq ($(BELOW25),y) -BELOW2552 := $(shell if [ $(PATCHLEVEL) -eq 5 -a $(SUBLEVEL) -lt 52 ]; then echo y; fi) -else -BELOW2552 := y -endif - -ifeq ($(BELOW25),y) -O_TARGET := drm.o -list-multi := tdfx.o r128.o mga.o i810.o i830.o ffb.o radeon.o \ - savage.o via.o mach64.o i915.o -obj-m := -obj-n := -obj- := -export-objs := via_mm.o -endif - +obj-m += drm.o obj-$(CONFIG_DRM_TDFX) += tdfx.o obj-$(CONFIG_DRM_R128) += r128.o obj-$(CONFIG_DRM_RADEON)+= radeon.o @@ -53,47 +38,3 @@ obj-$(CONFIG_DRM_FFB) += ffb.o obj-$(CONFIG_DRM_SAVAGE)+= savage.o obj-$(CONFIG_DRM_VIA) += via.o obj-$(CONFIG_DRM_MACH64)+= mach64.o - -ifeq ($(BELOW2552),y) -include $(TOPDIR)/Rules.make -endif - -ifeq ($(BELOW25),y) -tdfx.o: $(tdfx-objs) $(lib) - $(LD) -r -o $@ $(tdfx-objs) $(lib) - -mga.o: $(mga-objs) $(lib) - $(LD) -r -o $@ $(mga-objs) $(lib) - -i810.o: $(i810-objs) $(lib) - $(LD) -r -o $@ $(i810-objs) $(lib) - -i830.o: $(i830-objs) $(lib) - $(LD) -r -o $@ $(i830-objs) $(lib) - -i915.o: $(i915-objs) $(lib) - $(LD) -r -o $@ $(i915-objs) $(lib) - -r128.o: $(r128-objs) $(lib) - $(LD) -r -o $@ $(r128-objs) $(lib) - -radeon.o: $(radeon-objs) $(lib) - $(LD) -r -o $@ $(radeon-objs) $(lib) - -sis.o: $(sis-objs) $(lib) - $(LD) -r -o $@ $(sis-objs) $(lib) - -ffb.o: $(ffb-objs) $(lib) - $(LD) -r -o $@ $(ffb-objs) $(lib) - -savage.o: $(savage-objs) $(lib) - $(LD) -r -o $@ $(savage-objs) $(lib) - -via.o: $(via-objs) $(lib) - $(LD) -r -o $@ $(via-objs) $(lib) - -mach64.o: $(mach64-objs) $(lib) - $(LD) -r -o $@ $(mach64-objs) $(lib) - -endif - diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c index 0d7df0f3..e338fe15 100644 --- a/linux-core/ati_pcigart.c +++ b/linux-core/ati_pcigart.c @@ -52,7 +52,7 @@ # define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */ # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ -static unsigned long DRM(ati_alloc_pcigart_table)( void ) +static unsigned long drm_ati_alloc_pcigart_table( void ) { unsigned long address; struct page *page; @@ -75,7 +75,7 @@ static unsigned long DRM(ati_alloc_pcigart_table)( void ) return address; } -static void DRM(ati_free_pcigart_table)( unsigned long address ) +static void drm_ati_free_pcigart_table( unsigned long address ) { struct page *page; int i; @@ -91,7 +91,7 @@ static void DRM(ati_free_pcigart_table)( unsigned long address ) free_pages( address, ATI_PCIGART_TABLE_ORDER ); } -int DRM(ati_pcigart_init)( drm_device_t *dev, +int drm_ati_pcigart_init( drm_device_t *dev, unsigned long *addr, dma_addr_t *bus_addr) { @@ -106,7 +106,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, goto done; } - address = DRM(ati_alloc_pcigart_table)(); + address = drm_ati_alloc_pcigart_table(); if ( !address ) { DRM_ERROR( "cannot allocate PCI GART page!\n" ); goto done; @@ -122,7 +122,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, PCI_DMA_TODEVICE); if (bus_address == 0) { DRM_ERROR( "unable to map PCIGART pages!\n" ); - DRM(ati_free_pcigart_table)( address ); + drm_ati_free_pcigart_table( address ); address = 0; goto done; } @@ -142,7 +142,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, PCI_DMA_TODEVICE); if (entry->busaddr[i] == 0) { DRM_ERROR( "unable to map PCIGART pages!\n" ); - DRM(ati_pcigart_cleanup)( dev, address, bus_address ); + drm_ati_pcigart_cleanup( dev, address, bus_address ); address = 0; bus_address = 0; goto done; @@ -169,7 +169,7 @@ done: return ret; } -int DRM(ati_pcigart_cleanup)( drm_device_t *dev, +int drm_ati_pcigart_cleanup( drm_device_t *dev, unsigned long addr, dma_addr_t bus_addr) { @@ -199,7 +199,7 @@ int DRM(ati_pcigart_cleanup)( drm_device_t *dev, } if ( addr ) { - DRM(ati_free_pcigart_table)( addr ); + drm_ati_free_pcigart_table( addr ); } return 1; diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 7ed64535..3bd11aaa 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -179,7 +179,7 @@ */ #define DRM_MEM_ERROR(area, fmt, arg...) \ printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \ - DRM(mem_stats)[area].name , ##arg) + drm_mem_stats)[area].name , ##arg) #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg) /** @@ -191,7 +191,7 @@ #if DRM_DEBUG_CODE #define DRM_DEBUG(fmt, arg...) \ do { \ - if ( DRM(flags) & DRM_FLAG_DEBUG ) \ + if ( drm_flags & DRM_FLAG_DEBUG ) \ printk(KERN_DEBUG \ "[" DRM_NAME ":%s] " fmt , \ __FUNCTION__ , ##arg); \ @@ -254,6 +254,18 @@ do { \ } while (0) /** + * Copy and IOCTL return string to user space + */ +#define DRM_COPY( name, value ) \ + len = strlen( value ); \ + if ( len > name##_len ) len = name##_len; \ + name##_len = strlen( value ); \ + if ( len && name ) { \ + if ( copy_to_user( name, value, len ) ) \ + return -EFAULT; \ + } + +/** * Ioctl function type. * * \param inode device inode. @@ -446,7 +458,7 @@ typedef struct drm_agp_mem { /** * AGP data. * - * \sa DRM(agp_init)() and drm_device::agp. + * \sa drm_agp_init)() and drm_device::agp. */ typedef struct drm_agp_head { DRM_AGP_KERN agp_info; /**< AGP device information */ @@ -510,14 +522,18 @@ typedef struct drm_vbl_sig { struct drm_device; struct drm_driver_fn { + u32 driver_features; + int dev_priv_size; + int permanent_maps; + drm_ioctl_desc_t *ioctls; + int num_ioctls; int (*preinit)(struct drm_device *, unsigned long flags); - int (*postinit)(struct drm_device *, unsigned long flags); void (*prerelease)(struct drm_device *, struct file *filp); void (*pretakedown)(struct drm_device *); int (*postcleanup)(struct drm_device *); int (*presetup)(struct drm_device *); int (*postsetup)(struct drm_device *); - + int (*dma_ioctl)( DRM_IOCTL_ARGS ); /* these are opposites at the moment */ int (*open_helper)(struct drm_device *, drm_file_t *); void (*free_filp_priv)(struct drm_device *, drm_file_t *); @@ -531,6 +547,7 @@ struct drm_driver_fn { int (*kernel_context_switch_unlock)(struct drm_device *dev); int (*vblank_wait)(struct drm_device *dev, unsigned int *sequence); /* these have to be filled in */ + int (*postinit)(struct drm_device *, unsigned long flags); irqreturn_t (*irq_handler)( DRM_IRQ_ARGS ); void (*irq_preinstall)(struct drm_device *dev); void (*irq_postinstall)(struct drm_device *dev); @@ -539,8 +556,10 @@ struct drm_driver_fn { unsigned long (*get_map_ofs)(drm_map_t *map); unsigned long (*get_reg_ofs)(struct drm_device *dev); void (*set_version)(struct drm_device *dev, drm_set_version_t *sv); + int (*version)(drm_version_t *version); }; + /** * DRM device structure. */ @@ -673,10 +692,8 @@ typedef struct drm_device { struct file_operations *fops; /**< file operations */ - struct drm_driver_fn fn_tbl; + struct drm_driver_fn *fn_tbl; drm_local_map_t *agp_buffer_map; - int dev_priv_size; - u32 driver_features; } drm_device_t; typedef struct drm_minor { @@ -689,16 +706,9 @@ typedef struct drm_minor { struct proc_dir_entry *dev_root; /**< proc directory entry */ } drm_minor_t; -typedef struct drm_global { - unsigned int cards_limit; - drm_minor_t *minors; - struct drm_sysfs_class *drm_class; - struct proc_dir_entry *proc_root; -} drm_global_t; - static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature) { - return ((dev->driver_features & feature) ? 1 : 0); + return ((dev->fn_tbl->driver_features & feature) ? 1 : 0); } #if __OS_HAS_AGP @@ -719,260 +729,274 @@ static inline int drm_core_has_MTRR(struct drm_device *dev) #define drm_core_has_MTRR(dev) (0) #endif -extern void DRM(driver_register_fns)(struct drm_device *dev); - /******************************************************************/ /** \name Internal function definitions */ /*@{*/ /* Misc. support (drm_init.h) */ -extern int DRM(flags); -extern void DRM(parse_options)( char *s ); -extern int DRM(cpu_valid)( void ); +extern int drm_flags; +extern void drm_parse_options( char *s ); +extern int drm_cpu_valid( void ); /* Driver support (drm_drv.h) */ -extern int DRM(version)(struct inode *inode, struct file *filp, +extern int __devinit drm_init(struct pci_driver *driver, struct pci_device_id* pciidlist, + struct drm_driver_fn *driver_fn); +extern void __exit drm_exit (struct pci_driver *driver); +extern void __exit drm_cleanup_pci(struct pci_dev *pdev); +extern int drm_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(open)(struct inode *inode, struct file *filp); -extern int DRM(release)(struct inode *inode, struct file *filp); -extern int DRM(ioctl)(struct inode *inode, struct file *filp, +extern int drm_open(struct inode *inode, struct file *filp); +extern int drm_release(struct inode *inode, struct file *filp); +extern int drm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(lock)(struct inode *inode, struct file *filp, +extern int drm_lock(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(unlock)(struct inode *inode, struct file *filp, +extern int drm_unlock(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(fb_loaded); -extern struct file_operations DRM(fops); +extern int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev, + const struct pci_device_id *ent, struct drm_driver_fn *driver_fn); +extern int drm_fb_loaded; +extern struct file_operations drm_fops; /* Device support (drm_fops.h) */ -extern int DRM(open_helper)(struct inode *inode, struct file *filp, +extern int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t *dev); -extern int DRM(flush)(struct file *filp); -extern int DRM(fasync)(int fd, struct file *filp, int on); +extern int drm_flush(struct file *filp); +extern int drm_fasync(int fd, struct file *filp, int on); /* Mapping support (drm_vm.h) */ -extern void DRM(vm_open)(struct vm_area_struct *vma); -extern void DRM(vm_close)(struct vm_area_struct *vma); -extern void DRM(vm_shm_close)(struct vm_area_struct *vma); -extern int DRM(mmap_dma)(struct file *filp, +extern void drm_vm_open(struct vm_area_struct *vma); +extern void drm_vm_close(struct vm_area_struct *vma); +extern void drm_vm_shm_close(struct vm_area_struct *vma); +extern int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma); -extern int DRM(mmap)(struct file *filp, struct vm_area_struct *vma); -extern unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait); -extern ssize_t DRM(read)(struct file *filp, char __user *buf, size_t count, loff_t *off); +extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); +extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); +extern ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off); /* Memory management support (drm_memory.h) */ -extern void DRM(mem_init)(void); -extern int DRM(mem_info)(char *buf, char **start, off_t offset, +#include "drm_memory.h" +extern void drm_mem_init(void); +extern int drm_mem_info(char *buf, char **start, off_t offset, int request, int *eof, void *data); -extern void *DRM(calloc)(size_t nmemb, size_t size, int area); -extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, +extern void *drm_calloc(size_t nmemb, size_t size, int area); +extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area); -extern unsigned long DRM(alloc_pages)(int order, int area); -extern void DRM(free_pages)(unsigned long address, int order, +extern unsigned long drm_alloc_pages(int order, int area); +extern void drm_free_pages(unsigned long address, int order, int area); -extern void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev); -extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, - drm_device_t *dev); -extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev); - -extern DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type); -extern int DRM(free_agp)(DRM_AGP_MEM *handle, int pages); -extern int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start); -extern int DRM(unbind_agp)(DRM_AGP_MEM *handle); +extern DRM_AGP_MEM *drm_alloc_agp(int pages, u32 type); +extern int drm_free_agp(DRM_AGP_MEM *handle, int pages); +extern int drm_bind_agp(DRM_AGP_MEM *handle, unsigned int start); +extern int drm_unbind_agp(DRM_AGP_MEM *handle); /* Misc. IOCTL support (drm_ioctl.h) */ -extern int DRM(irq_by_busid)(struct inode *inode, struct file *filp, +extern int drm_irq_by_busid(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(getunique)(struct inode *inode, struct file *filp, +extern int drm_getunique(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(setunique)(struct inode *inode, struct file *filp, +extern int drm_setunique(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(getmap)(struct inode *inode, struct file *filp, +extern int drm_getmap(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(getclient)(struct inode *inode, struct file *filp, +extern int drm_getclient(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(getstats)(struct inode *inode, struct file *filp, +extern int drm_getstats(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(setversion)(struct inode *inode, struct file *filp, +extern int drm_setversion(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* Context IOCTL support (drm_context.h) */ -extern int DRM(resctx)( struct inode *inode, struct file *filp, +extern int drm_resctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(addctx)( struct inode *inode, struct file *filp, +extern int drm_addctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(modctx)( struct inode *inode, struct file *filp, +extern int drm_modctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(getctx)( struct inode *inode, struct file *filp, +extern int drm_getctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(switchctx)( struct inode *inode, struct file *filp, +extern int drm_switchctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(newctx)( struct inode *inode, struct file *filp, +extern int drm_newctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(rmctx)( struct inode *inode, struct file *filp, +extern int drm_rmctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(context_switch)(drm_device_t *dev, int old, int new); -extern int DRM(context_switch_complete)(drm_device_t *dev, int new); +extern int drm_context_switch(drm_device_t *dev, int old, int new); +extern int drm_context_switch_complete(drm_device_t *dev, int new); -extern int DRM(ctxbitmap_init)( drm_device_t *dev ); -extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev ); +extern int drm_ctxbitmap_init( drm_device_t *dev ); +extern void drm_ctxbitmap_cleanup( drm_device_t *dev ); +extern void drm_ctxbitmap_free( drm_device_t *dev, int ctx_handle ); -extern int DRM(setsareactx)( struct inode *inode, struct file *filp, +extern int drm_setsareactx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(getsareactx)( struct inode *inode, struct file *filp, +extern int drm_getsareactx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); /* Drawable IOCTL support (drm_drawable.h) */ -extern int DRM(adddraw)(struct inode *inode, struct file *filp, +extern int drm_adddraw(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(rmdraw)(struct inode *inode, struct file *filp, +extern int drm_rmdraw(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* Authentication IOCTL support (drm_auth.h) */ -extern int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, +extern int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic); -extern int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic); -extern int DRM(getmagic)(struct inode *inode, struct file *filp, +extern int drm_remove_magic(drm_device_t *dev, drm_magic_t magic); +extern int drm_getmagic(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(authmagic)(struct inode *inode, struct file *filp, +extern int drm_authmagic(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* Placeholder for ioctls past */ -extern int DRM(noop)(struct inode *inode, struct file *filp, +extern int drm_noop(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* Locking IOCTL support (drm_lock.h) */ -extern int DRM(lock_take)(__volatile__ unsigned int *lock, +extern int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context); -extern int DRM(lock_transfer)(drm_device_t *dev, +extern int drm_lock_transfer(drm_device_t *dev, __volatile__ unsigned int *lock, unsigned int context); -extern int DRM(lock_free)(drm_device_t *dev, +extern int drm_lock_free(drm_device_t *dev, __volatile__ unsigned int *lock, unsigned int context); -extern int DRM(notifier)(void *priv); +extern int drm_notifier(void *priv); /* Buffer management support (drm_bufs.h) */ -extern int DRM(order)( unsigned long size ); -extern int DRM(addmap)( struct inode *inode, struct file *filp, +extern int drm_order( unsigned long size ); +extern int drm_addmap( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(rmmap)( struct inode *inode, struct file *filp, +extern int drm_rmmap( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(initmap)( drm_device_t *dev, unsigned int offset, +extern int drm_initmap( drm_device_t *dev, unsigned int offset, unsigned int size, int type, int flags ); -extern int DRM(addbufs)( struct inode *inode, struct file *filp, +extern int drm_addbufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(infobufs)( struct inode *inode, struct file *filp, +extern int drm_infobufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(markbufs)( struct inode *inode, struct file *filp, +extern int drm_markbufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(freebufs)( struct inode *inode, struct file *filp, +extern int drm_freebufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(mapbufs)( struct inode *inode, struct file *filp, +extern int drm_mapbufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); /* DMA support (drm_dma.h) */ -extern int DRM(dma_setup)(drm_device_t *dev); -extern void DRM(dma_takedown)(drm_device_t *dev); -extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf); -extern void DRM(reclaim_buffers)( struct file *filp ); +extern int drm_dma_setup(drm_device_t *dev); +extern void drm_dma_takedown(drm_device_t *dev); +extern void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf); +extern void drm_core_reclaim_buffers( struct file *filp ); /* IRQ support (drm_irq.h) */ -extern int DRM(control)( struct inode *inode, struct file *filp, +extern int drm_control( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); -extern int DRM(irq_install)( drm_device_t *dev ); -extern int DRM(irq_uninstall)( drm_device_t *dev ); -extern irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS ); -extern void DRM(driver_irq_preinstall)( drm_device_t *dev ); -extern void DRM(driver_irq_postinstall)( drm_device_t *dev ); -extern void DRM(driver_irq_uninstall)( drm_device_t *dev ); - -extern int DRM(wait_vblank)(struct inode *inode, struct file *filp, +extern int drm_irq_install( drm_device_t *dev ); +extern int drm_irq_uninstall( drm_device_t *dev ); +extern irqreturn_t drm_irq_handler( DRM_IRQ_ARGS ); +extern void drm_driver_irq_preinstall( drm_device_t *dev ); +extern void drm_driver_irq_postinstall( drm_device_t *dev ); +extern void drm_driver_irq_uninstall( drm_device_t *dev ); + +extern int drm_wait_vblank(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq); -extern void DRM(vbl_send_signals)( drm_device_t *dev ); +extern int drm_vblank_wait(drm_device_t *dev, unsigned int *vbl_seq); +extern void drm_vbl_send_signals( drm_device_t *dev ); /* AGP/GART support (drm_agpsupport.h) */ -extern drm_agp_head_t *DRM(agp_init)(void); -extern void DRM(agp_uninit)(void); -extern int DRM(agp_acquire)(struct inode *inode, struct file *filp, +extern drm_agp_head_t *drm_agp_init(void); +extern void drm_agp_uninit(void); +extern int drm_agp_acquire(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern void DRM(agp_do_release)(void); -extern int DRM(agp_release)(struct inode *inode, struct file *filp, +extern void drm_agp_do_release(void); +extern int drm_agp_release(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(agp_enable)(struct inode *inode, struct file *filp, +extern int drm_agp_enable(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(agp_info)(struct inode *inode, struct file *filp, +extern int drm_agp_info(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(agp_alloc)(struct inode *inode, struct file *filp, +extern int drm_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(agp_free)(struct inode *inode, struct file *filp, +extern int drm_agp_free(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(agp_unbind)(struct inode *inode, struct file *filp, +extern int drm_agp_unbind(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(agp_bind)(struct inode *inode, struct file *filp, +extern int drm_agp_bind(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type); -extern int DRM(agp_free_memory)(DRM_AGP_MEM *handle); -extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start); -extern int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle); +extern DRM_AGP_MEM *drm_agp_allocate_memory(size_t pages, u32 type); +extern int drm_agp_free_memory(DRM_AGP_MEM *handle); +extern int drm_agp_bind_memory(DRM_AGP_MEM *handle, off_t start); +extern int drm_agp_unbind_memory(DRM_AGP_MEM *handle); /* Stub support (drm_stub.h) */ -extern int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent); -extern int DRM(put_minor)(drm_device_t *dev); -extern int DRM(get_secondary_minor)(drm_device_t *dev, drm_minor_t **sec_minor); -extern int DRM(put_secondary_minor)(drm_minor_t *sec_minor); -extern drm_global_t *DRM(global); +extern int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent, + struct drm_driver_fn *driver_fn); +extern int drm_put_minor(drm_device_t *dev); +extern int drm_get_secondary_minor(drm_device_t *dev, drm_minor_t **sec_minor); +extern int drm_put_secondary_minor(drm_minor_t *sec_minor); +extern unsigned int cards_limit; +extern drm_minor_t *drm_minors; +extern struct drm_sysfs_class *drm_class; +extern struct proc_dir_entry *drm_proc_root; +extern struct file_operations drm_stub_fops; /* Proc support (drm_proc.h) */ -extern int DRM(proc_init)(drm_device_t *dev, +extern int drm_proc_init(drm_device_t *dev, int minor, struct proc_dir_entry *root, struct proc_dir_entry **dev_root); -extern int DRM(proc_cleanup)(int minor, +extern int drm_proc_cleanup(int minor, struct proc_dir_entry *root, struct proc_dir_entry *dev_root); /* Scatter Gather Support (drm_scatter.h) */ -extern void DRM(sg_cleanup)(drm_sg_mem_t *entry); -extern int DRM(sg_alloc)(struct inode *inode, struct file *filp, +extern void drm_sg_cleanup(drm_sg_mem_t *entry); +extern int drm_sg_alloc(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int DRM(sg_free)(struct inode *inode, struct file *filp, +extern int drm_sg_free(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* ATI PCIGART support (ati_pcigart.h) */ -extern int DRM(ati_pcigart_init)(drm_device_t *dev, +extern int drm_ati_pcigart_init(drm_device_t *dev, unsigned long *addr, dma_addr_t *bus_addr); -extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev, +extern int drm_ati_pcigart_cleanup(drm_device_t *dev, unsigned long addr, dma_addr_t bus_addr); -extern void *DRM(pci_alloc)(drm_device_t *dev, size_t size, +extern void *drm_pci_alloc(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr, dma_addr_t *busaddr); -extern void DRM(pci_free)(drm_device_t *dev, size_t size, +extern void drm_pci_free(drm_device_t *dev, size_t size, void *vaddr, dma_addr_t busaddr); + /* sysfs support (drm_sysfs.c) */ +struct drm_sysfs_class; +extern struct drm_sysfs_class *drm_sysfs_create(struct module *owner, char *name); +extern void drm_sysfs_destroy(struct drm_sysfs_class *cs); +extern struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, + dev_t dev, struct device *device, const char *fmt, ...); +extern void drm_sysfs_device_remove(dev_t dev); + /* Inline replacements for DRM_IOREMAP macros */ static __inline__ void drm_core_ioremap(struct drm_map *map, struct drm_device *dev) { - map->handle = DRM(ioremap)( map->offset, map->size, dev ); + map->handle = drm_ioremap( map->offset, map->size, dev ); } static __inline__ void drm_core_ioremap_nocache(struct drm_map *map, struct drm_device *dev) { - map->handle = DRM(ioremap_nocache)(map->offset, map->size, dev); + map->handle = drm_ioremap_nocache(map->offset, map->size, dev); } static __inline__ void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev) { if ( map->handle && map->size ) - DRM(ioremapfree)( map->handle, map->size, dev ); + drm_ioremapfree( map->handle, map->size, dev ); } static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, unsigned long offset) @@ -994,24 +1018,24 @@ static __inline__ void drm_core_dropmap(struct drm_map *map) #ifndef DEBUG_MEMORY /** Wrapper around kmalloc() */ -static __inline__ void *DRM(alloc)(size_t size, int area) +static __inline__ void *drm_alloc(size_t size, int area) { return kmalloc(size, GFP_KERNEL); } /** Wrapper around kfree() */ -static __inline__ void DRM(free)(void *pt, size_t size, int area) +static __inline__ void drm_free(void *pt, size_t size, int area) { kfree(pt); } #else -extern void *DRM(alloc)(size_t size, int area); -extern void DRM(free)(void *pt, size_t size, int area); +extern void *drm_alloc(size_t size, int area); +extern void drm_free(void *pt, size_t size, int area); #endif /*@}*/ -extern unsigned long DRM(core_get_map_ofs)(drm_map_t *map); -extern unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev); +extern unsigned long drm_core_get_map_ofs(drm_map_t *map); +extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); #endif /* __KERNEL__ */ #endif diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index 7d2f7125..8165c835 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -56,7 +56,7 @@ static const drm_agp_t *drm_agp = NULL; * Verifies the AGP device has been initialized and acquired and fills in the * drm_agp_info structure with the information in drm_agp_head::agp_info. */ -int DRM(agp_info)(struct inode *inode, struct file *filp, +int drm_agp_info(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -95,7 +95,7 @@ int DRM(agp_info)(struct inode *inode, struct file *filp, * Verifies the AGP device hasn't been acquired before and calls * drm_agp->acquire(). */ -int DRM(agp_acquire)(struct inode *inode, struct file *filp, +int drm_agp_acquire(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -129,7 +129,7 @@ int DRM(agp_acquire)(struct inode *inode, struct file *filp, * * Verifies the AGP device has been acquired and calls drm_agp->release(). */ -int DRM(agp_release)(struct inode *inode, struct file *filp, +int drm_agp_release(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -148,7 +148,7 @@ int DRM(agp_release)(struct inode *inode, struct file *filp, * * Calls drm_agp->release(). */ -void DRM(agp_do_release)(void) +void drm_agp_do_release(void) { if (drm_agp->release) drm_agp->release(); @@ -166,7 +166,7 @@ void DRM(agp_do_release)(void) * Verifies the AGP device has been acquired but not enabled, and calls * drm_agp->enable(). */ -int DRM(agp_enable)(struct inode *inode, struct file *filp, +int drm_agp_enable(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -198,7 +198,7 @@ int DRM(agp_enable)(struct inode *inode, struct file *filp, * Verifies the AGP device is present and has been acquired, allocates the * memory via alloc_agp() and creates a drm_agp_mem entry for it. */ -int DRM(agp_alloc)(struct inode *inode, struct file *filp, +int drm_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -214,7 +214,7 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp, return -EINVAL; if (copy_from_user(&request, argp, sizeof(request))) return -EFAULT; - if (!(entry = DRM(alloc)(sizeof(*entry), DRM_MEM_AGPLISTS))) + if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS))) return -ENOMEM; memset(entry, 0, sizeof(*entry)); @@ -222,8 +222,8 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp, pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE; type = (u32) request.type; - if (!(memory = DRM(alloc_agp)(pages, type))) { - DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS); + if (!(memory = drm_alloc_agp(pages, type))) { + drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); return -ENOMEM; } @@ -243,8 +243,8 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp, if (copy_to_user(argp, &request, sizeof(request))) { dev->agp->memory = entry->next; dev->agp->memory->prev = NULL; - DRM(free_agp)(memory, pages); - DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS); + drm_free_agp(memory, pages); + drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); return -EFAULT; } return 0; @@ -259,7 +259,7 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp, * * Walks through drm_agp_head::memory until finding a matching handle. */ -static drm_agp_mem_t *DRM(agp_lookup_entry)(drm_device_t *dev, +static drm_agp_mem_t *drm_agp_lookup_entry(drm_device_t *dev, unsigned long handle) { drm_agp_mem_t *entry; @@ -283,7 +283,7 @@ static drm_agp_mem_t *DRM(agp_lookup_entry)(drm_device_t *dev, * Verifies the AGP device is present and acquired, looks-up the AGP memory * entry and passes it to the unbind_agp() function. */ -int DRM(agp_unbind)(struct inode *inode, struct file *filp, +int drm_agp_unbind(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -296,11 +296,11 @@ int DRM(agp_unbind)(struct inode *inode, struct file *filp, return -EINVAL; if (copy_from_user(&request, (drm_agp_binding_t __user *)arg, sizeof(request))) return -EFAULT; - if (!(entry = DRM(agp_lookup_entry)(dev, request.handle))) + if (!(entry = drm_agp_lookup_entry(dev, request.handle))) return -EINVAL; if (!entry->bound) return -EINVAL; - ret = DRM(unbind_agp)(entry->memory); + ret = drm_unbind_agp(entry->memory); if (ret == 0) entry->bound = 0; return ret; @@ -319,7 +319,7 @@ int DRM(agp_unbind)(struct inode *inode, struct file *filp, * is currently bound into the GATT. Looks-up the AGP memory entry and passes * it to bind_agp() function. */ -int DRM(agp_bind)(struct inode *inode, struct file *filp, +int drm_agp_bind(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -333,12 +333,12 @@ int DRM(agp_bind)(struct inode *inode, struct file *filp, return -EINVAL; if (copy_from_user(&request, (drm_agp_binding_t __user *)arg, sizeof(request))) return -EFAULT; - if (!(entry = DRM(agp_lookup_entry)(dev, request.handle))) + if (!(entry = drm_agp_lookup_entry(dev, request.handle))) return -EINVAL; if (entry->bound) return -EINVAL; page = (request.offset + PAGE_SIZE - 1) / PAGE_SIZE; - if ((retcode = DRM(bind_agp)(entry->memory, page))) + if ((retcode = drm_bind_agp(entry->memory, page))) return retcode; entry->bound = dev->agp->base + (page << PAGE_SHIFT); DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n", @@ -360,7 +360,7 @@ int DRM(agp_bind)(struct inode *inode, struct file *filp, * unbind_agp(). Frees it via free_agp() as well as the entry itself * and unlinks from the doubly linked list it's inserted in. */ -int DRM(agp_free)(struct inode *inode, struct file *filp, +int drm_agp_free(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -372,10 +372,10 @@ int DRM(agp_free)(struct inode *inode, struct file *filp, return -EINVAL; if (copy_from_user(&request, (drm_agp_buffer_t __user *)arg, sizeof(request))) return -EFAULT; - if (!(entry = DRM(agp_lookup_entry)(dev, request.handle))) + if (!(entry = drm_agp_lookup_entry(dev, request.handle))) return -EINVAL; if (entry->bound) - DRM(unbind_agp)(entry->memory); + drm_unbind_agp(entry->memory); if (entry->prev) entry->prev->next = entry->next; @@ -385,8 +385,8 @@ int DRM(agp_free)(struct inode *inode, struct file *filp, if (entry->next) entry->next->prev = entry->prev; - DRM(free_agp)(entry->memory, entry->pages); - DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS); + drm_free_agp(entry->memory, entry->pages); + drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); return 0; } @@ -399,18 +399,18 @@ int DRM(agp_free)(struct inode *inode, struct file *filp, * via the inter_module_* functions. Creates and initializes a drm_agp_head * structure. */ -drm_agp_head_t *DRM(agp_init)(void) +drm_agp_head_t *drm_agp_init(void) { drm_agp_head_t *head = NULL; drm_agp = DRM_AGP_GET; if (drm_agp) { - if (!(head = DRM(alloc)(sizeof(*head), DRM_MEM_AGPLISTS))) + if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS))) return NULL; memset((void *)head, 0, sizeof(*head)); drm_agp->copy_info(&head->agp_info); if (head->agp_info.chipset == NOT_SUPPORTED) { - DRM(free)(head, sizeof(*head), DRM_MEM_AGPLISTS); + drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); return NULL; } head->memory = NULL; @@ -430,14 +430,14 @@ drm_agp_head_t *DRM(agp_init)(void) * * Releases the pointer in ::drm_agp. */ -void DRM(agp_uninit)(void) +void drm_agp_uninit(void) { DRM_AGP_PUT; drm_agp = NULL; } /** Calls drm_agp->allocate_memory() */ -DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type) +DRM_AGP_MEM *drm_agp_allocate_memory(size_t pages, u32 type) { if (!drm_agp->allocate_memory) return NULL; @@ -445,7 +445,7 @@ DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type) } /** Calls drm_agp->free_memory() */ -int DRM(agp_free_memory)(DRM_AGP_MEM *handle) +int drm_agp_free_memory(DRM_AGP_MEM *handle) { if (!handle || !drm_agp->free_memory) return 0; @@ -454,7 +454,7 @@ int DRM(agp_free_memory)(DRM_AGP_MEM *handle) } /** Calls drm_agp->bind_memory() */ -int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start) +int drm_agp_bind_memory(DRM_AGP_MEM *handle, off_t start) { if (!handle || !drm_agp->bind_memory) return -EINVAL; @@ -462,7 +462,7 @@ int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start) } /** Calls drm_agp->unbind_memory() */ -int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle) +int drm_agp_unbind_memory(DRM_AGP_MEM *handle) { if (!handle || !drm_agp->unbind_memory) return -EINVAL; diff --git a/linux-core/drm_auth.c b/linux-core/drm_auth.c index fe099871..84c39f74 100644 --- a/linux-core/drm_auth.c +++ b/linux-core/drm_auth.c @@ -44,7 +44,7 @@ * The key is the modulus of the hash table size, #DRM_HASH_SIZE, which must be * a power of 2. */ -static int DRM(hash_magic)(drm_magic_t magic) +static int drm_hash_magic(drm_magic_t magic) { return magic & (DRM_HASH_SIZE-1); } @@ -59,11 +59,11 @@ static int DRM(hash_magic)(drm_magic_t magic) * the one with matching magic number, while holding the drm_device::struct_sem * lock. */ -static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic) +static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic) { drm_file_t *retval = NULL; drm_magic_entry_t *pt; - int hash = DRM(hash_magic)(magic); + int hash = drm_hash_magic(magic); down(&dev->struct_sem); for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { @@ -87,15 +87,15 @@ static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic) * associated the magic number hash key in drm_device::magiclist, while holding * the drm_device::struct_sem lock. */ -int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) +int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) { int hash; drm_magic_entry_t *entry; DRM_DEBUG("%d\n", magic); - hash = DRM(hash_magic)(magic); - entry = DRM(alloc)(sizeof(*entry), DRM_MEM_MAGIC); + hash = drm_hash_magic(magic); + entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC); if (!entry) return -ENOMEM; memset(entry, 0, sizeof(*entry)); entry->magic = magic; @@ -124,7 +124,7 @@ int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) * Searches and unlinks the entry in drm_device::magiclist with the magic * number hash key, while holding the drm_device::struct_sem lock. */ -int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) +int drm_remove_magic(drm_device_t *dev, drm_magic_t magic) { drm_magic_entry_t *prev = NULL; drm_magic_entry_t *pt; @@ -132,7 +132,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) DRM_DEBUG("%d\n", magic); - hash = DRM(hash_magic)(magic); + hash = drm_hash_magic(magic); down(&dev->struct_sem); for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { @@ -152,7 +152,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) } up(&dev->struct_sem); - DRM(free)(pt, sizeof(*pt), DRM_MEM_MAGIC); + drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); return -EINVAL; } @@ -170,7 +170,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) * searches an unique non-zero magic number and add it associating it with \p * filp. */ -int DRM(getmagic)(struct inode *inode, struct file *filp, +int drm_getmagic(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { static drm_magic_t sequence = 0; @@ -188,9 +188,9 @@ int DRM(getmagic)(struct inode *inode, struct file *filp, if (!sequence) ++sequence; /* reserve 0 */ auth.magic = sequence++; spin_unlock(&lock); - } while (DRM(find_file)(dev, auth.magic)); + } while (drm_find_file(dev, auth.magic)); priv->magic = auth.magic; - DRM(add_magic)(dev, priv, auth.magic); + drm_add_magic(dev, priv, auth.magic); } DRM_DEBUG("%u\n", auth.magic); @@ -210,7 +210,7 @@ int DRM(getmagic)(struct inode *inode, struct file *filp, * * Checks if \p filp is associated with the magic number passed in \arg. */ -int DRM(authmagic)(struct inode *inode, struct file *filp, +int drm_authmagic(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -221,9 +221,9 @@ int DRM(authmagic)(struct inode *inode, struct file *filp, if (copy_from_user(&auth, (drm_auth_t __user *)arg, sizeof(auth))) return -EFAULT; DRM_DEBUG("%u\n", auth.magic); - if ((file = DRM(find_file)(dev, auth.magic))) { + if ((file = drm_find_file(dev, auth.magic))) { file->authenticated = 1; - DRM(remove_magic)(dev, auth.magic); + drm_remove_magic(dev, auth.magic); return 0; } return -EINVAL; diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index 5058a1d3..88ca09ce 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -45,7 +45,7 @@ * * \todo Can be made faster. */ -int DRM(order)( unsigned long size ) +int drm_order( unsigned long size ) { int order; unsigned long tmp; @@ -58,14 +58,14 @@ int DRM(order)( unsigned long size ) return order; } +EXPORT_SYMBOL(drm_order); -static int permanent_maps = 0; /** * Adjusts the memory offset to its absolute value according to the mapping * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where * applicable and if supported by the kernel. */ -int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int type, int flags ) +int drm_initmap( drm_device_t *dev, unsigned int offset, unsigned int size, int type, int flags ) { drm_map_t *map; drm_map_list_t *list; @@ -78,12 +78,12 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int if ( offset + size < offset || offset < virt_to_phys(high_memory) ) return -EINVAL; #endif - if ( !(list = DRM(alloc)( sizeof(*list), DRM_MEM_MAPS ))) + if ( !(list = drm_alloc( sizeof(*list), DRM_MEM_MAPS ))) return -ENOMEM; memset(list, 0, sizeof(*list)); - if ( !(map = DRM(alloc)( sizeof(*map), DRM_MEM_MAPS ))) { - DRM(free)(list, sizeof(*list), DRM_MEM_MAPS); + if ( !(map = drm_alloc( sizeof(*map), DRM_MEM_MAPS ))) { + drm_free(list, sizeof(*list), DRM_MEM_MAPS); return -ENOMEM; } @@ -99,7 +99,7 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int DRM_DEBUG( "initmap offset = 0x%08lx, size = 0x%08lx, type = %d\n", map->offset, map->size, map->type ); - + #ifdef __alpha__ map->offset += dev->hose->mem_space->start; #endif @@ -112,17 +112,18 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int } if (map->type == _DRM_REGISTERS) - map->handle = DRM(ioremap)( map->offset, map->size, dev ); + map->handle = drm_ioremap( map->offset, map->size, dev ); down(&dev->struct_sem); list_add(&list->head, &dev->maplist->head); up(&dev->struct_sem); - permanent_maps = 1; + dev->fn_tbl->permanent_maps = 1; DRM_DEBUG("finished\n"); return 0; } +EXPORT_SYMBOL(drm_initmap); /** * Ioctl to specify a range of memory that is available for mapping by a non-root process. @@ -137,7 +138,7 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where * applicable and if supported by the kernel. */ -int DRM(addmap)( struct inode *inode, struct file *filp, +int drm_addmap( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -148,12 +149,12 @@ int DRM(addmap)( struct inode *inode, struct file *filp, if ( !(filp->f_mode & 3) ) return -EACCES; /* Require read/write */ - map = DRM(alloc)( sizeof(*map), DRM_MEM_MAPS ); + map = drm_alloc( sizeof(*map), DRM_MEM_MAPS ); if ( !map ) return -ENOMEM; if ( copy_from_user( map, argp, sizeof(*map) ) ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EFAULT; } @@ -162,13 +163,13 @@ int DRM(addmap)( struct inode *inode, struct file *filp, * when processes fork. */ if ( (map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EINVAL; } DRM_DEBUG( "offset = 0x%08lx, size = 0x%08lx, type = %d\n", map->offset, map->size, map->type ); if ( (map->offset & (~PAGE_MASK)) || (map->size & (~PAGE_MASK)) ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EINVAL; } map->mtrr = -1; @@ -181,7 +182,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp, struct list_head *_list; /* If permanent maps are implemented, maps must match */ - if (permanent_maps) { + if (dev->fn_tbl->permanent_maps) { DRM_DEBUG( "Looking for: offset = 0x%08lx, size = 0x%08lx, type = %d\n", map->offset, map->size, map->type ); list_for_each( _list, &dev->maplist->head ) { @@ -191,7 +192,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp, if ( _entry->map && map->type == _entry->map->type && map->offset == _entry->map->offset ) { _entry->map->size = map->size; - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); map = _entry->map; DRM_DEBUG( "Found existing: offset = 0x%08lx, size = 0x%08lx, type = %d\n", map->offset, map->size, map->type ); @@ -204,7 +205,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp, #if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) if ( map->offset + map->size < map->offset || map->offset < virt_to_phys(high_memory) ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EINVAL; } #endif @@ -219,16 +220,16 @@ int DRM(addmap)( struct inode *inode, struct file *filp, } } if (map->type == _DRM_REGISTERS) - map->handle = DRM(ioremap)( map->offset, map->size, + map->handle = drm_ioremap( map->offset, map->size, dev ); break; } case _DRM_SHM: map->handle = vmalloc_32(map->size); DRM_DEBUG( "%lu %d %p\n", - map->size, DRM(order)( map->size ), map->handle ); + map->size, drm_order( map->size ), map->handle ); if ( !map->handle ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -ENOMEM; } map->offset = (unsigned long)map->handle; @@ -236,7 +237,7 @@ int DRM(addmap)( struct inode *inode, struct file *filp, /* Prevent a 2nd X Server from creating a 2nd lock */ if (dev->lock.hw_lock != NULL) { vfree( map->handle ); - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EBUSY; } dev->sigdata.lock = @@ -254,20 +255,20 @@ int DRM(addmap)( struct inode *inode, struct file *filp, break; case _DRM_SCATTER_GATHER: if (!dev->sg) { - DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + drm_free(map, sizeof(*map), DRM_MEM_MAPS); return -EINVAL; } map->offset += dev->sg->handle; break; default: - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); + drm_free( map, sizeof(*map), DRM_MEM_MAPS ); return -EINVAL; } - list = DRM(alloc)(sizeof(*list), DRM_MEM_MAPS); + list = drm_alloc(sizeof(*list), DRM_MEM_MAPS); if(!list) { - DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + drm_free(map, sizeof(*map), DRM_MEM_MAPS); return -EINVAL; } memset(list, 0, sizeof(*list)); @@ -305,7 +306,7 @@ found_it: * * \sa addmap(). */ -int DRM(rmmap)(struct inode *inode, struct file *filp, +int drm_rmmap(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -347,7 +348,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, return 0; } list_del(list); - DRM(free)(list, sizeof(*list), DRM_MEM_MAPS); + drm_free(list, sizeof(*list), DRM_MEM_MAPS); for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) { if (pt->vma->vm_private_data == map) found_maps++; @@ -365,7 +366,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, case _DRM_SCATTER_GATHER: break; } - DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + drm_free(map, sizeof(*map), DRM_MEM_MAPS); } up(&dev->struct_sem); return 0; @@ -379,19 +380,19 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, * * Frees any pages and buffers associated with the given entry. */ -static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry) +static void drm_cleanup_buf_error(drm_device_t *dev, drm_buf_entry_t *entry) { int i; if (entry->seg_count) { for (i = 0; i < entry->seg_count; i++) { if (entry->seglist[i]) { - DRM(free_pages)(entry->seglist[i], + drm_free_pages(entry->seglist[i], entry->page_order, DRM_MEM_DMA); } } - DRM(free)(entry->seglist, + drm_free(entry->seglist, entry->seg_count * sizeof(*entry->seglist), DRM_MEM_SEGS); @@ -402,12 +403,12 @@ static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry) if (entry->buf_count) { for (i = 0; i < entry->buf_count; i++) { if (entry->buflist[i].dev_private) { - DRM(free)(entry->buflist[i].dev_private, + drm_free(entry->buflist[i].dev_private, entry->buflist[i].dev_priv_size, DRM_MEM_BUFS); } } - DRM(free)(entry->buflist, + drm_free(entry->buflist, entry->buf_count * sizeof(*entry->buflist), DRM_MEM_BUFS); @@ -430,7 +431,7 @@ static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry) * reallocates the buffer list of the same size order to accommodate the new * buffers. */ -int DRM(addbufs_agp)( struct inode *inode, struct file *filp, +int drm_addbufs_agp( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -459,7 +460,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, return -EFAULT; count = request.count; - order = DRM(order)( request.size ); + order = drm_order( request.size ); size = 1 << order; alignment = (request.flags & _DRM_PAGE_ALIGN) @@ -503,7 +504,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, return -EINVAL; } - entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist), + entry->buflist = drm_alloc( count * sizeof(*entry->buflist), DRM_MEM_BUFS ); if ( !entry->buflist ) { up( &dev->struct_sem ); @@ -533,13 +534,13 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, init_waitqueue_head( &buf->dma_wait ); buf->filp = NULL; - buf->dev_priv_size = dev->dev_priv_size; - buf->dev_private = DRM(alloc)( buf->dev_priv_size, + buf->dev_priv_size = dev->fn_tbl->dev_priv_size; + buf->dev_private = drm_alloc( buf->dev_priv_size, DRM_MEM_BUFS ); if(!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; - DRM(cleanup_buf_error)(dev,entry); + drm_cleanup_buf_error(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -556,14 +557,14 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, DRM_DEBUG( "byte_count: %d\n", byte_count ); - temp_buflist = DRM(realloc)( dma->buflist, + temp_buflist = drm_realloc( dma->buflist, dma->buf_count * sizeof(*dma->buflist), (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), DRM_MEM_BUFS ); if(!temp_buflist) { /* Free the entry because it isn't valid */ - DRM(cleanup_buf_error)(dev,entry); + drm_cleanup_buf_error(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -595,7 +596,7 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp, } #endif /* __OS_HAS_AGP */ -int DRM(addbufs_pci)( struct inode *inode, struct file *filp, +int drm_addbufs_pci( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -627,7 +628,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, return -EFAULT; count = request.count; - order = DRM(order)( request.size ); + order = drm_order( request.size ); size = 1 << order; DRM_DEBUG( "count=%d, size=%d (%d), order=%d, queue_count=%d\n", @@ -664,7 +665,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, return -EINVAL; } - entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist), + entry->buflist = drm_alloc( count * sizeof(*entry->buflist), DRM_MEM_BUFS ); if ( !entry->buflist ) { up( &dev->struct_sem ); @@ -673,10 +674,10 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, } memset( entry->buflist, 0, count * sizeof(*entry->buflist) ); - entry->seglist = DRM(alloc)( count * sizeof(*entry->seglist), + entry->seglist = drm_alloc( count * sizeof(*entry->seglist), DRM_MEM_SEGS ); if ( !entry->seglist ) { - DRM(free)( entry->buflist, + drm_free( entry->buflist, count * sizeof(*entry->buflist), DRM_MEM_BUFS ); up( &dev->struct_sem ); @@ -688,14 +689,14 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, /* Keep the original pagelist until we know all the allocations * have succeeded */ - temp_pagelist = DRM(alloc)( (dma->page_count + (count << page_order)) + temp_pagelist = drm_alloc( (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), DRM_MEM_PAGES ); if (!temp_pagelist) { - DRM(free)( entry->buflist, + drm_free( entry->buflist, count * sizeof(*entry->buflist), DRM_MEM_BUFS ); - DRM(free)( entry->seglist, + drm_free( entry->seglist, count * sizeof(*entry->seglist), DRM_MEM_SEGS ); up( &dev->struct_sem ); @@ -714,13 +715,13 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, page_count = 0; while ( entry->buf_count < count ) { - page = DRM(alloc_pages)( page_order, DRM_MEM_DMA ); + page = drm_alloc_pages( page_order, DRM_MEM_DMA ); if ( !page ) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; entry->seg_count = count; - DRM(cleanup_buf_error)(dev,entry); - DRM(free)( temp_pagelist, + drm_cleanup_buf_error(dev,entry); + drm_free( temp_pagelist, (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), DRM_MEM_PAGES ); @@ -753,15 +754,15 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, init_waitqueue_head( &buf->dma_wait ); buf->filp = NULL; - buf->dev_priv_size = dev->dev_priv_size; - buf->dev_private = DRM(alloc)( dev->dev_priv_size, + buf->dev_priv_size = dev->fn_tbl->dev_priv_size; + buf->dev_private = drm_alloc( dev->fn_tbl->dev_priv_size, DRM_MEM_BUFS ); if(!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; entry->seg_count = count; - DRM(cleanup_buf_error)(dev,entry); - DRM(free)( temp_pagelist, + drm_cleanup_buf_error(dev,entry); + drm_free( temp_pagelist, (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), DRM_MEM_PAGES ); @@ -777,15 +778,15 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, byte_count += PAGE_SIZE << page_order; } - temp_buflist = DRM(realloc)( dma->buflist, + temp_buflist = drm_realloc( dma->buflist, dma->buf_count * sizeof(*dma->buflist), (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), DRM_MEM_BUFS ); if (!temp_buflist) { /* Free the entry because it isn't valid */ - DRM(cleanup_buf_error)(dev,entry); - DRM(free)( temp_pagelist, + drm_cleanup_buf_error(dev,entry); + drm_free( temp_pagelist, (dma->page_count + (count << page_order)) * sizeof(*dma->pagelist), DRM_MEM_PAGES ); @@ -803,7 +804,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, * with the new one. */ if (dma->page_count) { - DRM(free)(dma->pagelist, + drm_free(dma->pagelist, dma->page_count * sizeof(*dma->pagelist), DRM_MEM_PAGES); } @@ -827,7 +828,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, } -int DRM(addbufs_sg)( struct inode *inode, struct file *filp, +int drm_addbufs_sg( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -857,7 +858,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, return -EFAULT; count = request.count; - order = DRM(order)( request.size ); + order = drm_order( request.size ); size = 1 << order; alignment = (request.flags & _DRM_PAGE_ALIGN) @@ -901,7 +902,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, return -EINVAL; } - entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist), + entry->buflist = drm_alloc( count * sizeof(*entry->buflist), DRM_MEM_BUFS ); if ( !entry->buflist ) { up( &dev->struct_sem ); @@ -931,13 +932,13 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, init_waitqueue_head( &buf->dma_wait ); buf->filp = NULL; - buf->dev_priv_size = dev->dev_priv_size; - buf->dev_private = DRM(alloc)( dev->dev_priv_size, + buf->dev_priv_size = dev->fn_tbl->dev_priv_size; + buf->dev_private = drm_alloc( dev->fn_tbl->dev_priv_size, DRM_MEM_BUFS ); if(!buf->dev_private) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; - DRM(cleanup_buf_error)(dev,entry); + drm_cleanup_buf_error(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -955,14 +956,14 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, DRM_DEBUG( "byte_count: %d\n", byte_count ); - temp_buflist = DRM(realloc)( dma->buflist, + temp_buflist = drm_realloc( dma->buflist, dma->buf_count * sizeof(*dma->buflist), (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), DRM_MEM_BUFS ); if(!temp_buflist) { /* Free the entry because it isn't valid */ - DRM(cleanup_buf_error)(dev,entry); + drm_cleanup_buf_error(dev,entry); up( &dev->struct_sem ); atomic_dec( &dev->buf_alloc ); return -ENOMEM; @@ -1007,7 +1008,7 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp, * addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent * PCI memory respectively. */ -int DRM(addbufs)( struct inode *inode, struct file *filp, +int drm_addbufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_buf_desc_t request; @@ -1023,13 +1024,13 @@ int DRM(addbufs)( struct inode *inode, struct file *filp, #if __OS_HAS_AGP if ( request.flags & _DRM_AGP_BUFFER ) - return DRM(addbufs_agp)( inode, filp, cmd, arg ); + return drm_addbufs_agp( inode, filp, cmd, arg ); else #endif if ( request.flags & _DRM_SG_BUFFER ) - return DRM(addbufs_sg)( inode, filp, cmd, arg ); + return drm_addbufs_sg( inode, filp, cmd, arg ); else - return DRM(addbufs_pci)( inode, filp, cmd, arg ); + return drm_addbufs_pci( inode, filp, cmd, arg ); } @@ -1050,7 +1051,7 @@ int DRM(addbufs)( struct inode *inode, struct file *filp, * lock, preventing of allocating more buffers after this call. Information * about each requested buffer is then copied into user space. */ -int DRM(infobufs)( struct inode *inode, struct file *filp, +int drm_infobufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -1135,7 +1136,7 @@ int DRM(infobufs)( struct inode *inode, struct file *filp, * * \note This ioctl is deprecated and mostly never used. */ -int DRM(markbufs)( struct inode *inode, struct file *filp, +int drm_markbufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -1157,7 +1158,7 @@ int DRM(markbufs)( struct inode *inode, struct file *filp, DRM_DEBUG( "%d, %d, %d\n", request.size, request.low_mark, request.high_mark ); - order = DRM(order)( request.size ); + order = drm_order( request.size ); if ( order < DRM_MIN_ORDER || order > DRM_MAX_ORDER ) return -EINVAL; entry = &dma->bufs[order]; @@ -1184,7 +1185,7 @@ int DRM(markbufs)( struct inode *inode, struct file *filp, * Calls free_buffer() for each used buffer. * This function is primarily used for debugging. */ -int DRM(freebufs)( struct inode *inode, struct file *filp, +int drm_freebufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -1222,7 +1223,7 @@ int DRM(freebufs)( struct inode *inode, struct file *filp, current->pid ); return -EINVAL; } - DRM(free_buffer)( dev, buf ); + drm_free_buffer( dev, buf ); } return 0; @@ -1241,7 +1242,7 @@ int DRM(freebufs)( struct inode *inode, struct file *filp, * about each buffer into user space. The PCI buffers are already mapped on the * addbufs_pci() call. */ -int DRM(mapbufs)( struct inode *inode, struct file *filp, +int drm_mapbufs( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; diff --git a/linux-core/drm_context.c b/linux-core/drm_context.c index b99c9947..cfa4a172 100644 --- a/linux-core/drm_context.c +++ b/linux-core/drm_context.c @@ -56,7 +56,7 @@ * in drm_device::context_sareas, while holding the drm_device::struct_sem * lock. */ -void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle ) +void drm_ctxbitmap_free( drm_device_t *dev, int ctx_handle ) { if ( ctx_handle < 0 ) goto failed; if ( !dev->ctx_bitmap ) goto failed; @@ -84,7 +84,7 @@ failed: * drm_device::context_sareas to accommodate the new entry while holding the * drm_device::struct_sem lock. */ -int DRM(ctxbitmap_next)( drm_device_t *dev ) +int drm_ctxbitmap_next( drm_device_t *dev ) { int bit; @@ -100,7 +100,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) if(dev->context_sareas) { drm_map_t **ctx_sareas; - ctx_sareas = DRM(realloc)(dev->context_sareas, + ctx_sareas = drm_realloc(dev->context_sareas, (dev->max_context - 1) * sizeof(*dev->context_sareas), dev->max_context * @@ -115,7 +115,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) dev->context_sareas[bit] = NULL; } else { /* max_context == 1 at this point */ - dev->context_sareas = DRM(alloc)( + dev->context_sareas = drm_alloc( dev->max_context * sizeof(*dev->context_sareas), DRM_MEM_MAPS); @@ -142,13 +142,13 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) * Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding * the drm_device::struct_sem lock. */ -int DRM(ctxbitmap_init)( drm_device_t *dev ) +int drm_ctxbitmap_init( drm_device_t *dev ) { int i; int temp; down(&dev->struct_sem); - dev->ctx_bitmap = (unsigned long *) DRM(alloc)( PAGE_SIZE, + dev->ctx_bitmap = (unsigned long *) drm_alloc( PAGE_SIZE, DRM_MEM_CTXBITMAP ); if ( dev->ctx_bitmap == NULL ) { up(&dev->struct_sem); @@ -160,7 +160,7 @@ int DRM(ctxbitmap_init)( drm_device_t *dev ) up(&dev->struct_sem); for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) { - temp = DRM(ctxbitmap_next)( dev ); + temp = drm_ctxbitmap_next( dev ); DRM_DEBUG( "drm_ctxbitmap_init : %d\n", temp ); } @@ -175,14 +175,14 @@ int DRM(ctxbitmap_init)( drm_device_t *dev ) * Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding * the drm_device::struct_sem lock. */ -void DRM(ctxbitmap_cleanup)( drm_device_t *dev ) +void drm_ctxbitmap_cleanup( drm_device_t *dev ) { down(&dev->struct_sem); - if( dev->context_sareas ) DRM(free)( dev->context_sareas, + if( dev->context_sareas ) drm_free( dev->context_sareas, sizeof(*dev->context_sareas) * dev->max_context, DRM_MEM_MAPS ); - DRM(free)( (void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP ); + drm_free( (void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP ); up(&dev->struct_sem); } @@ -204,7 +204,7 @@ void DRM(ctxbitmap_cleanup)( drm_device_t *dev ) * Gets the map from drm_device::context_sareas with the handle specified and * returns its handle. */ -int DRM(getsareactx)(struct inode *inode, struct file *filp, +int drm_getsareactx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -243,7 +243,7 @@ int DRM(getsareactx)(struct inode *inode, struct file *filp, * Searches the mapping specified in \p arg and update the entry in * drm_device::context_sareas with it. */ -int DRM(setsareactx)(struct inode *inode, struct file *filp, +int drm_setsareactx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -297,7 +297,7 @@ found: * * Attempt to set drm_device::context_flag. */ -int DRM(context_switch)( drm_device_t *dev, int old, int new ) +int drm_context_switch( drm_device_t *dev, int old, int new ) { if ( test_and_set_bit( 0, &dev->context_flag ) ) { DRM_ERROR( "Reentering -- FIXME\n" ); @@ -326,7 +326,7 @@ int DRM(context_switch)( drm_device_t *dev, int old, int new ) * hardware lock is held, clears the drm_device::context_flag and wakes up * drm_device::context_wait. */ -int DRM(context_switch_complete)( drm_device_t *dev, int new ) +int drm_context_switch_complete( drm_device_t *dev, int new ) { dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ dev->last_switch = jiffies; @@ -353,7 +353,7 @@ int DRM(context_switch_complete)( drm_device_t *dev, int new ) * \param arg user argument pointing to a drm_ctx_res structure. * \return zero on success or a negative number on failure. */ -int DRM(resctx)( struct inode *inode, struct file *filp, +int drm_resctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_ctx_res_t res; @@ -391,7 +391,7 @@ int DRM(resctx)( struct inode *inode, struct file *filp, * * Get a new handle for the context and copy to userspace. */ -int DRM(addctx)( struct inode *inode, struct file *filp, +int drm_addctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -403,10 +403,10 @@ int DRM(addctx)( struct inode *inode, struct file *filp, if ( copy_from_user( &ctx, argp, sizeof(ctx) ) ) return -EFAULT; - ctx.handle = DRM(ctxbitmap_next)( dev ); + ctx.handle = drm_ctxbitmap_next( dev ); if ( ctx.handle == DRM_KERNEL_CONTEXT ) { /* Skip kernel's context and get a new one. */ - ctx.handle = DRM(ctxbitmap_next)( dev ); + ctx.handle = drm_ctxbitmap_next( dev ); } DRM_DEBUG( "%d\n", ctx.handle ); if ( ctx.handle == -1 ) { @@ -417,11 +417,11 @@ int DRM(addctx)( struct inode *inode, struct file *filp, if ( ctx.handle != DRM_KERNEL_CONTEXT ) { - if (dev->fn_tbl.context_ctor) - dev->fn_tbl.context_ctor(dev, ctx.handle); + if (dev->fn_tbl->context_ctor) + dev->fn_tbl->context_ctor(dev, ctx.handle); } - ctx_entry = DRM(alloc)( sizeof(*ctx_entry), DRM_MEM_CTXLIST ); + ctx_entry = drm_alloc( sizeof(*ctx_entry), DRM_MEM_CTXLIST ); if ( !ctx_entry ) { DRM_DEBUG("out of memory\n"); return -ENOMEM; @@ -441,7 +441,7 @@ int DRM(addctx)( struct inode *inode, struct file *filp, return 0; } -int DRM(modctx)( struct inode *inode, struct file *filp, +int drm_modctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { /* This does nothing */ @@ -457,7 +457,7 @@ int DRM(modctx)( struct inode *inode, struct file *filp, * \param arg user argument pointing to a drm_ctx structure. * \return zero on success or a negative number on failure. */ -int DRM(getctx)( struct inode *inode, struct file *filp, +int drm_getctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_ctx_t __user *argp = (void __user *)arg; @@ -485,7 +485,7 @@ int DRM(getctx)( struct inode *inode, struct file *filp, * * Calls context_switch(). */ -int DRM(switchctx)( struct inode *inode, struct file *filp, +int drm_switchctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -496,7 +496,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp, return -EFAULT; DRM_DEBUG( "%d\n", ctx.handle ); - return DRM(context_switch)( dev, dev->last_context, ctx.handle ); + return drm_context_switch( dev, dev->last_context, ctx.handle ); } /** @@ -510,7 +510,7 @@ int DRM(switchctx)( struct inode *inode, struct file *filp, * * Calls context_switch_complete(). */ -int DRM(newctx)( struct inode *inode, struct file *filp, +int drm_newctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -521,7 +521,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp, return -EFAULT; DRM_DEBUG( "%d\n", ctx.handle ); - DRM(context_switch_complete)( dev, ctx.handle ); + drm_context_switch_complete( dev, ctx.handle ); return 0; } @@ -537,7 +537,7 @@ int DRM(newctx)( struct inode *inode, struct file *filp, * * If not the special kernel context, calls ctxbitmap_free() to free the specified context. */ -int DRM(rmctx)( struct inode *inode, struct file *filp, +int drm_rmctx( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -552,9 +552,9 @@ int DRM(rmctx)( struct inode *inode, struct file *filp, priv->remove_auth_on_close = 1; } if ( ctx.handle != DRM_KERNEL_CONTEXT ) { - if (dev->fn_tbl.context_dtor) - dev->fn_tbl.context_dtor(dev, ctx.handle); - DRM(ctxbitmap_free)( dev, ctx.handle ); + if (dev->fn_tbl->context_dtor) + dev->fn_tbl->context_dtor(dev, ctx.handle); + drm_ctxbitmap_free( dev, ctx.handle ); } down( &dev->ctxlist_sem ); @@ -564,7 +564,7 @@ int DRM(rmctx)( struct inode *inode, struct file *filp, list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) { if ( pos->handle == ctx.handle ) { list_del( &pos->head ); - DRM(free)( pos, sizeof(*pos), DRM_MEM_CTXLIST ); + drm_free( pos, sizeof(*pos), DRM_MEM_CTXLIST ); --dev->ctx_count; } } diff --git a/linux-core/drm_core.h b/linux-core/drm_core.h index adaf581b..cfe62191 100644 --- a/linux-core/drm_core.h +++ b/linux-core/drm_core.h @@ -23,21 +23,16 @@ * DEALINGS IN THE SOFTWARE. */ -#include "drm_auth.h" -#include "drm_agpsupport.h" -#include "drm_bufs.h" -#include "drm_context.h" -#include "drm_dma.h" -#include "drm_irq.h" -#include "drm_drawable.h" -#include "drm_drv.h" -#include "drm_fops.h" -#include "drm_init.h" -#include "drm_ioctl.h" -#include "drm_lock.h" -#include "drm_memory.h" -#include "drm_pci.h" -#include "drm_proc.h" -#include "drm_vm.h" -#include "drm_stub.h" -#include "drm_scatter.h" +#define DRIVER_AUTHOR "Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl" + +#define DRIVER_NAME "drm" +#define DRIVER_DESC "DRM shared core routines" +#define DRIVER_DATE "20040925" + +#define DRM_IF_MAJOR 1 +#define DRM_IF_MINOR 2 + +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 0 +#define DRIVER_PATCHLEVEL 0 + diff --git a/linux-core/drm_dma.c b/linux-core/drm_dma.c index 5cbdc931..c7a5448a 100644 --- a/linux-core/drm_dma.c +++ b/linux-core/drm_dma.c @@ -43,11 +43,11 @@ * * Allocate and initialize a drm_device_dma structure. */ -int DRM(dma_setup)( drm_device_t *dev ) +int drm_dma_setup( drm_device_t *dev ) { int i; - dev->dma = DRM(alloc)( sizeof(*dev->dma), DRM_MEM_DRIVER ); + dev->dma = drm_alloc( sizeof(*dev->dma), DRM_MEM_DRIVER ); if ( !dev->dma ) return -ENOMEM; @@ -67,7 +67,7 @@ int DRM(dma_setup)( drm_device_t *dev ) * Free all pages associated with DMA buffers, the buffers and pages lists, and * finally the the drm_device::dma structure itself. */ -void DRM(dma_takedown)(drm_device_t *dev) +void drm_dma_takedown(drm_device_t *dev) { drm_device_dma_t *dma = dev->dma; int i, j; @@ -84,12 +84,12 @@ void DRM(dma_takedown)(drm_device_t *dev) dma->bufs[i].seg_count); for (j = 0; j < dma->bufs[i].seg_count; j++) { if (dma->bufs[i].seglist[j]) { - DRM(free_pages)(dma->bufs[i].seglist[j], + drm_free_pages(dma->bufs[i].seglist[j], dma->bufs[i].page_order, DRM_MEM_DMA); } } - DRM(free)(dma->bufs[i].seglist, + drm_free(dma->bufs[i].seglist, dma->bufs[i].seg_count * sizeof(*dma->bufs[0].seglist), DRM_MEM_SEGS); @@ -97,12 +97,12 @@ void DRM(dma_takedown)(drm_device_t *dev) if (dma->bufs[i].buf_count) { for (j = 0; j < dma->bufs[i].buf_count; j++) { if (dma->bufs[i].buflist[j].dev_private) { - DRM(free)(dma->bufs[i].buflist[j].dev_private, + drm_free(dma->bufs[i].buflist[j].dev_private, dma->bufs[i].buflist[j].dev_priv_size, DRM_MEM_BUFS); } } - DRM(free)(dma->bufs[i].buflist, + drm_free(dma->bufs[i].buflist, dma->bufs[i].buf_count * sizeof(*dma->bufs[0].buflist), DRM_MEM_BUFS); @@ -110,17 +110,17 @@ void DRM(dma_takedown)(drm_device_t *dev) } if (dma->buflist) { - DRM(free)(dma->buflist, + drm_free(dma->buflist, dma->buf_count * sizeof(*dma->buflist), DRM_MEM_BUFS); } if (dma->pagelist) { - DRM(free)(dma->pagelist, + drm_free(dma->pagelist, dma->page_count * sizeof(*dma->pagelist), DRM_MEM_PAGES); } - DRM(free)(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER); + drm_free(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER); dev->dma = NULL; } @@ -133,7 +133,7 @@ void DRM(dma_takedown)(drm_device_t *dev) * * Resets the fields of \p buf. */ -void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf) +void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf) { if (!buf) return; @@ -154,7 +154,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf) * * Frees each buffer associated with \p filp not already on the hardware. */ -void DRM(core_reclaim_buffers)( struct file *filp ) +void drm_core_reclaim_buffers( struct file *filp ) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; @@ -166,7 +166,7 @@ void DRM(core_reclaim_buffers)( struct file *filp ) if (dma->buflist[i]->filp == filp) { switch (dma->buflist[i]->list) { case DRM_LIST_NONE: - DRM(free_buffer)(dev, dma->buflist[i]); + drm_free_buffer(dev, dma->buflist[i]); break; case DRM_LIST_WAIT: dma->buflist[i]->list = DRM_LIST_RECLAIM; @@ -178,4 +178,5 @@ void DRM(core_reclaim_buffers)( struct file *filp ) } } } +EXPORT_SYMBOL(drm_core_reclaim_buffers); diff --git a/linux-core/drm_drawable.c b/linux-core/drm_drawable.c index 5f1562b6..e8e8e42b 100644 --- a/linux-core/drm_drawable.c +++ b/linux-core/drm_drawable.c @@ -36,7 +36,7 @@ #include "drmP.h" /** No-op. */ -int DRM(adddraw)(struct inode *inode, struct file *filp, +int drm_adddraw(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_draw_t draw; @@ -49,7 +49,7 @@ int DRM(adddraw)(struct inode *inode, struct file *filp, } /** No-op. */ -int DRM(rmdraw)(struct inode *inode, struct file *filp, +int drm_rmdraw(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { return 0; /* NOOP */ diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index dc3c96ef..425320b1 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -21,7 +21,7 @@ * * #define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( mga_ioctls ) * - * #define DRM(x) mga_##x + * #define drm_x mga_##x * \endcode */ @@ -51,24 +51,22 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef DRIVER_IOCTLS -#define DRIVER_IOCTLS -#endif +#include "drmP.h" +#include "drm_core.h" static void __exit drm_cleanup( drm_device_t *dev ); #ifndef MODULE /** Use an additional macro to avoid preprocessor troubles */ -#define DRM_OPTIONS_FUNC DRM(options) +#define DRM_OPTIONS_FUNC drm_options /** * Called by the kernel to parse command-line options passed via the * boot-loader (e.g., LILO). It calls the insmod option routine, * parse_options(). */ -static int __init DRM(options)( char *str ) +static int __init drm_options( char *str ) { - DRM(parse_options)( str ); + drm_parse_options( str ); return 1; } @@ -76,94 +74,92 @@ __setup( DRIVER_NAME "=", DRM_OPTIONS_FUNC ); #undef DRM_OPTIONS_FUNC #endif -int DRM(fb_loaded) = 0; +int drm_fb_loaded = 0; -struct file_operations DRM(fops) = { +struct file_operations drm_fops = { .owner = THIS_MODULE, - .open = DRM(open), - .flush = DRM(flush), - .release = DRM(release), - .ioctl = DRM(ioctl), - .mmap = DRM(mmap), - .fasync = DRM(fasync), - .poll = DRM(poll), - .read = DRM(read), + .open = drm_open, + .flush = drm_flush, + .release = drm_release, + .ioctl = drm_ioctl, + .mmap = drm_mmap, + .fasync = drm_fasync, + .poll = drm_poll, + .read = drm_read, }; /** Ioctl table */ -drm_ioctl_desc_t DRM(ioctls)[] = { - [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_by_busid), 0, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = { DRM(setversion), 0, 1 }, - - [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(noop), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(noop), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 }, +drm_ioctl_desc_t drm_ioctls[] = { + [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { drm_version, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_by_busid, 0, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { drm_getmap, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { drm_getclient, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { drm_getstats, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = { drm_setversion, 0, 1 }, + + [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_noop, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_noop, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { drm_rmmap, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { DRM(setsareactx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { DRM(getsareactx), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { drm_setsareactx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { drm_getsareactx, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { DRM(addctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { DRM(rmctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { DRM(modctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { DRM(getctx), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { DRM(switchctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { DRM(newctx), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { DRM(resctx), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { drm_addctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { drm_rmctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { drm_modctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { drm_getctx, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { drm_switchctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { drm_newctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { drm_resctx, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { DRM(adddraw), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { DRM(rmdraw), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { drm_lock, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { drm_unlock, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_noop, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { DRM(markbufs), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { DRM(infobufs), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { DRM(mapbufs), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { DRM(freebufs), 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { drm_addbufs, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { drm_mapbufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 }, /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */ - [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { drm_control, 1, 1 }, #if __OS_HAS_AGP - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { DRM(agp_release), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { DRM(agp_enable), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { DRM(agp_info), 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { DRM(agp_alloc), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { DRM(agp_free), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { DRM(agp_bind), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { drm_agp_acquire, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { drm_agp_release, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { drm_agp_enable, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { drm_agp_info, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { drm_agp_alloc, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 }, #endif - [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { DRM(sg_alloc), 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { DRM(sg_free), 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { drm_sg_alloc, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { drm_sg_free, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 }, - - DRIVER_IOCTLS + [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { drm_wait_vblank, 0, 0 }, }; -#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( DRM(ioctls) ) +#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( drm_ioctls ) -static int DRM(setup)( drm_device_t *dev ) +static int drm_setup( drm_device_t *dev ) { int i; - if (dev->fn_tbl.presetup) - dev->fn_tbl.presetup(dev); + if (dev->fn_tbl->presetup) + dev->fn_tbl->presetup(dev); atomic_set( &dev->ioctl_count, 0 ); atomic_set( &dev->vma_count, 0 ); @@ -172,7 +168,7 @@ static int DRM(setup)( drm_device_t *dev ) if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) { - i = DRM(dma_setup)( dev ); + i = drm_dma_setup( dev ); if ( i < 0 ) return i; } @@ -185,7 +181,7 @@ static int DRM(setup)( drm_device_t *dev ) dev->magiclist[i].tail = NULL; } - dev->ctxlist = DRM(alloc)(sizeof(*dev->ctxlist), + dev->ctxlist = drm_alloc(sizeof(*dev->ctxlist), DRM_MEM_CTXLIST); if(dev->ctxlist == NULL) return -ENOMEM; memset(dev->ctxlist, 0, sizeof(*dev->ctxlist)); @@ -227,8 +223,8 @@ static int DRM(setup)( drm_device_t *dev ) * drm_select_queue fails between the time the interrupt is * initialized and the time the queues are initialized. */ - if (dev->fn_tbl.postsetup) - dev->fn_tbl.postsetup(dev); + if (dev->fn_tbl->postsetup) + dev->fn_tbl->postsetup(dev); return 0; } @@ -243,7 +239,7 @@ static int DRM(setup)( drm_device_t *dev ) * * \sa drm_device and setup(). */ -static int DRM(takedown)( drm_device_t *dev ) +static int drm_takedown( drm_device_t *dev ) { drm_magic_entry_t *pt, *next; drm_map_t *map; @@ -254,22 +250,22 @@ static int DRM(takedown)( drm_device_t *dev ) DRM_DEBUG( "\n" ); - if (dev->fn_tbl.pretakedown) - dev->fn_tbl.pretakedown(dev); + if (dev->fn_tbl->pretakedown) + dev->fn_tbl->pretakedown(dev); - if ( dev->irq_enabled ) DRM(irq_uninstall)( dev ); + if ( dev->irq_enabled ) drm_irq_uninstall( dev ); down( &dev->struct_sem ); del_timer( &dev->timer ); if ( dev->devname ) { - DRM(free)( dev->devname, strlen( dev->devname ) + 1, + drm_free( dev->devname, strlen( dev->devname ) + 1, DRM_MEM_DRIVER ); dev->devname = NULL; } if ( dev->unique ) { - DRM(free)( dev->unique, strlen( dev->unique ) + 1, + drm_free( dev->unique, strlen( dev->unique ) + 1, DRM_MEM_DRIVER ); dev->unique = NULL; dev->unique_len = 0; @@ -278,7 +274,7 @@ static int DRM(takedown)( drm_device_t *dev ) for ( i = 0 ; i < DRM_HASH_SIZE ; i++ ) { for ( pt = dev->magiclist[i].head ; pt ; pt = next ) { next = pt->next; - DRM(free)( pt, sizeof(*pt), DRM_MEM_MAGIC ); + drm_free( pt, sizeof(*pt), DRM_MEM_MAGIC ); } dev->magiclist[i].head = dev->magiclist[i].tail = NULL; } @@ -292,13 +288,13 @@ static int DRM(takedown)( drm_device_t *dev ) intact until drv_cleanup is called. */ for ( entry = dev->agp->memory ; entry ; entry = nexte ) { nexte = entry->next; - if ( entry->bound ) DRM(unbind_agp)( entry->memory ); - DRM(free_agp)( entry->memory, entry->pages ); - DRM(free)( entry, sizeof(*entry), DRM_MEM_AGPLISTS ); + if ( entry->bound ) drm_unbind_agp( entry->memory ); + drm_free_agp( entry->memory, entry->pages ); + drm_free( entry, sizeof(*entry), DRM_MEM_AGPLISTS ); } dev->agp->memory = NULL; - if ( dev->agp->acquired ) DRM(agp_do_release)(); + if ( dev->agp->acquired ) drm_agp_do_release(); dev->agp->acquired = 0; dev->agp->enabled = 0; @@ -308,7 +304,7 @@ static int DRM(takedown)( drm_device_t *dev ) if ( dev->vmalist ) { for ( vma = dev->vmalist ; vma ; vma = vma_next ) { vma_next = vma->next; - DRM(free)( vma, sizeof(*vma), DRM_MEM_VMAS ); + drm_free( vma, sizeof(*vma), DRM_MEM_VMAS ); } dev->vmalist = NULL; } @@ -335,15 +331,15 @@ static int DRM(takedown)( drm_device_t *dev ) case _DRM_SCATTER_GATHER: /* Handle it */ if (drm_core_check_feature(dev, DRIVER_SG) && dev->sg) { - DRM(sg_cleanup)(dev->sg); + drm_sg_cleanup(dev->sg); dev->sg = NULL; } break; } - DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + drm_free(map, sizeof(*map), DRM_MEM_MAPS); } list_del( list ); - DRM(free)(r_list, sizeof(*r_list), DRM_MEM_MAPS); + drm_free(r_list, sizeof(*r_list), DRM_MEM_MAPS); } } @@ -352,13 +348,13 @@ static int DRM(takedown)( drm_device_t *dev ) for ( i = 0 ; i < dev->queue_count ; i++ ) { if ( dev->queuelist[i] ) { - DRM(free)( dev->queuelist[i], + drm_free( dev->queuelist[i], sizeof(*dev->queuelist[0]), DRM_MEM_QUEUES ); dev->queuelist[i] = NULL; } } - DRM(free)( dev->queuelist, + drm_free( dev->queuelist, dev->queue_slots * sizeof(*dev->queuelist), DRM_MEM_QUEUES ); dev->queuelist = NULL; @@ -366,7 +362,7 @@ static int DRM(takedown)( drm_device_t *dev ) dev->queue_count = 0; if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) - DRM(dma_takedown)( dev ); + drm_dma_takedown( dev ); if ( dev->lock.hw_lock ) { dev->sigdata.lock = dev->lock.hw_lock = NULL; /* SHM removed */ @@ -378,20 +374,7 @@ static int DRM(takedown)( drm_device_t *dev ) return 0; } -static void DRM(init_fn_table)(struct drm_device *dev) -{ - dev->fn_tbl.reclaim_buffers = DRM(core_reclaim_buffers); - dev->fn_tbl.get_map_ofs = DRM(core_get_map_ofs); - dev->fn_tbl.get_reg_ofs = DRM(core_get_reg_ofs); -} - -#include "drm_pciids.h" - -static struct pci_device_id DRM(pciidlist)[] = { - DRM(PCI_IDS) -}; - -int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_device_id *ent) +int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver_fn *driver_fn) { int retcode; @@ -401,7 +384,7 @@ int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_d sema_init( &dev->ctxlist_sem, 1 ); dev->name = DRIVER_NAME; - dev->fops = &DRM(fops); + dev->fops = &drm_fops; dev->pdev = pdev; #ifdef __alpha__ @@ -415,13 +398,10 @@ int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_d dev->pci_func = PCI_FUNC(pdev->devfn); dev->irq = pdev->irq; - dev->maplist = DRM(calloc)(1, sizeof(*dev->maplist), DRM_MEM_MAPS); + dev->maplist = drm_calloc(1, sizeof(*dev->maplist), DRM_MEM_MAPS); if(dev->maplist == NULL) return -ENOMEM; INIT_LIST_HEAD(&dev->maplist->head); - /* dev_priv_size can be changed by a driver in driver_register_fns */ - dev->dev_priv_size = sizeof(u32); - /* the DRM has 6 counters */ dev->counters = 6; dev->types[0] = _DRM_STAT_LOCK; @@ -431,16 +411,14 @@ int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_d dev->types[4] = _DRM_STAT_LOCKS; dev->types[5] = _DRM_STAT_UNLOCKS; - DRM(init_fn_table)(dev); + dev->fn_tbl = driver_fn; - DRM(driver_register_fns)(dev); - - if (dev->fn_tbl.preinit) - if ((retcode = dev->fn_tbl.preinit(dev, ent->driver_data))) + if (dev->fn_tbl->preinit) + if ((retcode = dev->fn_tbl->preinit(dev, ent->driver_data))) goto error_out_unreg; if (drm_core_has_AGP(dev)) { - dev->agp = DRM(agp_init)(); + dev->agp = drm_agp_init(); if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP) && (dev->agp == NULL)) { DRM_ERROR( "Cannot initialize the agpgart module.\n" ); retcode = -EINVAL; @@ -457,37 +435,28 @@ int DRM(fill_in_dev)(drm_device_t *dev, struct pci_dev *pdev, const struct pci_d } } - retcode = DRM(ctxbitmap_init)( dev ); + retcode = drm_ctxbitmap_init( dev ); if( retcode ) { DRM_ERROR( "Cannot allocate memory for context bitmap.\n" ); goto error_out_unreg; } dev->device = MKDEV(DRM_MAJOR, dev->minor ); +DRM_DEBUG("driver_fn->postinit %p\n", driver_fn->postinit); - DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", - DRIVER_NAME, - DRIVER_MAJOR, - DRIVER_MINOR, - DRIVER_PATCHLEVEL, - DRIVER_DATE, - dev->minor, - pci_pretty_name(pdev) - ); - + /* postinit is a required function to display the signon banner */ /* drivers add secondary heads here if needed */ - if (dev->fn_tbl.postinit) - if ((retcode = dev->fn_tbl.postinit(dev, ent->driver_data))) - goto error_out_unreg; + if ((retcode = dev->fn_tbl->postinit(dev, ent->driver_data))) + goto error_out_unreg; return 0; error_out_unreg: - DRM(takedown)(dev); + drm_takedown(dev); return retcode; } -static void __exit drm_cleanup_pci(struct pci_dev *pdev) +void __exit drm_cleanup_pci(struct pci_dev *pdev) { drm_device_t *dev = pci_get_drvdata(pdev); @@ -496,13 +465,7 @@ static void __exit drm_cleanup_pci(struct pci_dev *pdev) if (dev) drm_cleanup(dev); } - -static struct pci_driver drm_driver = { - .name = DRIVER_NAME, - .id_table = DRM(pciidlist), - .probe = DRM(probe), - .remove = __devexit_p(drm_cleanup_pci), -}; +EXPORT_SYMBOL(drm_cleanup_pci); #ifdef MODULE static char *drm_opts = NULL; @@ -522,7 +485,7 @@ MODULE_PARM( drm_opts, "s" ); * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and * after the initialization for driver customization. */ -static int __init drm_init( void ) +int __devinit drm_init( struct pci_driver *driver, struct pci_device_id* pciidlist, struct drm_driver_fn *driver_fn) { struct pci_dev *pdev; struct pci_device_id *pid; @@ -531,13 +494,13 @@ static int __init drm_init( void ) DRM_DEBUG( "\n" ); #ifdef MODULE - DRM(parse_options)( drm_opts ); + drm_parse_options( drm_opts ); #endif - DRM(mem_init)(); + drm_mem_init(); - for (i=0; (DRM(pciidlist)[i].vendor != 0) && !DRM(fb_loaded); i++) { - pid = &DRM(pciidlist[i]); + for (i=0; (pciidlist[i].vendor != 0) && !drm_fb_loaded; i++) { + pid = &pciidlist[i]; pdev = NULL; /* pass back in pdev to account for multiple identical cards */ @@ -546,7 +509,7 @@ static int __init drm_init( void ) /* does something like VesaFB have control of the memory region? */ if (pci_dev_driver(pdev) || pci_request_regions(pdev, "DRM scan")) { /* go into stealth mode */ - DRM(fb_loaded) = 1; + drm_fb_loaded = 1; pci_dev_put(pdev); break; } @@ -555,23 +518,24 @@ static int __init drm_init( void ) } } - if (DRM(fb_loaded) == 0) - pci_register_driver(&drm_driver); + if (drm_fb_loaded == 0) + pci_register_driver(driver); else { - for (i=0; DRM(pciidlist)[i].vendor != 0; i++) { - pid = &DRM(pciidlist[i]); + for (i=0; pciidlist[i].vendor != 0; i++) { + pid = &pciidlist[i]; pdev = NULL; /* pass back in pdev to account for multiple identical cards */ while ((pdev = pci_get_subsys(pid->vendor, pid->device, pid->subvendor, pid->subdevice, pdev))) { /* stealth mode requires a manual probe */ - DRM(probe)(pdev, &DRM(pciidlist[i])); + drm_probe(pdev, &pciidlist[i], driver_fn); } } DRM_INFO("Used old pci detect: framebuffer loaded\n"); } return 0; } +EXPORT_SYMBOL(drm_init); /** * Called via cleanup_module() at module unload time. @@ -592,7 +556,7 @@ static void __exit drm_cleanup( drm_device_t *dev ) return; } - DRM(takedown)(dev); + drm_takedown(dev); if( dev->maplist ) { list_for_each_safe( list, list_next, &dev->maplist->head ) { @@ -601,7 +565,7 @@ static void __exit drm_cleanup( drm_device_t *dev ) if ( ( map = r_list->map ) ) { switch ( map->type ) { case _DRM_REGISTERS: - DRM(ioremapfree)( map->handle, map->size, dev ); + drm_ioremapfree( map->handle, map->size, dev ); break; case _DRM_FRAME_BUFFER: @@ -622,18 +586,18 @@ static void __exit drm_cleanup( drm_device_t *dev ) DRM_DEBUG("Extra maplist item\n"); break; } - DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + drm_free(map, sizeof(*map), DRM_MEM_MAPS); } list_del( list ); - DRM(free)(r_list, sizeof(*r_list), DRM_MEM_MAPS); + drm_free(r_list, sizeof(*r_list), DRM_MEM_MAPS); } - DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); + drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); dev->maplist = NULL; } - if (DRM(fb_loaded)==0) + if (drm_fb_loaded==0) pci_disable_device(dev->pdev); - DRM(ctxbitmap_cleanup)( dev ); + drm_ctxbitmap_cleanup( dev ); if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && dev->agp && dev->agp->agp_mtrr >= 0) { int retval; @@ -644,46 +608,100 @@ static void __exit drm_cleanup( drm_device_t *dev ) } if (drm_core_has_AGP(dev) && dev->agp ) { - DRM(agp_uninit)(); - DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS ); + drm_agp_uninit(); + drm_free( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS ); dev->agp = NULL; } - if (dev->fn_tbl.postcleanup) - dev->fn_tbl.postcleanup(dev); + if (dev->fn_tbl->postcleanup) + dev->fn_tbl->postcleanup(dev); - if ( DRM(put_minor)(dev) ) + if ( drm_put_minor(dev) ) DRM_ERROR( "Cannot unload module\n" ); } -static void __exit drm_exit (void) +void __exit drm_exit (struct pci_driver *driver) { int i; drm_device_t *dev; drm_minor_t *minor; DRM_DEBUG( "\n" ); - if (DRM(fb_loaded)) { - if (DRM(global)) { - for (i = 0; i < DRM(global)->cards_limit; i++) { - minor = &DRM(global)->minors[i]; - dev = minor->dev; - DRM_DEBUG("fb loaded release minor %d\n", dev->minor); - if ((minor->class == DRM_MINOR_PRIMARY) && (dev->fops == &DRM(fops))) { - /* release the pci driver */ - if (dev->pdev) - pci_dev_put(dev->pdev); - drm_cleanup(dev); - } + if (drm_fb_loaded) { + for (i = 0; i < cards_limit; i++) { + minor = &drm_minors[i]; + dev = minor->dev; + DRM_DEBUG("fb loaded release minor %d\n", dev->minor); + if ((minor->class == DRM_MINOR_PRIMARY) && (dev->fops == &drm_fops)) { + /* release the pci driver */ + if (dev->pdev) + pci_dev_put(dev->pdev); + drm_cleanup(dev); } } } else - pci_unregister_driver(&drm_driver); + pci_unregister_driver(driver); DRM_INFO( "Module unloaded\n" ); } +EXPORT_SYMBOL(drm_exit); +static int __init drm_core_init(void) +{ + int ret = -ENOMEM; -module_init( drm_init ); -module_exit( drm_exit ); + cards_limit = (cards_limit < DRM_MAX_MINOR + 1 ? cards_limit : DRM_MAX_MINOR + 1); + drm_minors = drm_calloc(cards_limit, + sizeof(*drm_minors), DRM_MEM_STUB); + if(!drm_minors) + goto err_p1; + + if (register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops)) + goto err_p1; + + drm_class = drm_sysfs_create(THIS_MODULE, "drm"); + if (IS_ERR(drm_class)) { + printk (KERN_ERR "DRM: Error creating drm class.\n"); + ret = PTR_ERR(drm_class); + goto err_p2; + } + + drm_proc_root = create_proc_entry("dri", S_IFDIR, NULL); + if (!drm_proc_root) { + DRM_ERROR("Cannot create /proc/dri\n"); + ret = -1; + goto err_p3; + } + DRM_DEBUG("calling inter_module_register\n"); + + DRM_INFO( "Initialized %s %d.%d.%d %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE + ); + return 0; +err_p3: + drm_sysfs_destroy(drm_class); +err_p2: + unregister_chrdev(DRM_MAJOR, "drm"); + drm_free(drm_minors, sizeof(*drm_minors) * cards_limit, DRM_MEM_STUB); +err_p1: + return ret; +} + +static void __exit drm_core_exit (void) +{ + remove_proc_entry("dri", NULL); + drm_sysfs_destroy(drm_class); + + unregister_chrdev(DRM_MAJOR, "drm"); + + drm_free(drm_minors, sizeof(*drm_minors) * + cards_limit, DRM_MEM_STUB); +} + +module_init( drm_core_init ); +module_exit( drm_core_exit ); /** @@ -697,33 +715,22 @@ module_exit( drm_exit ); * * Fills in the version information in \p arg. */ -int DRM(version)( struct inode *inode, struct file *filp, +int drm_version( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; drm_version_t __user *argp = (void __user *)arg; drm_version_t version; - int len; + int ret; if ( copy_from_user( &version, argp, sizeof(version) ) ) return -EFAULT; -#define DRM_COPY( name, value ) \ - len = strlen( value ); \ - if ( len > name##_len ) len = name##_len; \ - name##_len = strlen( value ); \ - if ( len && name ) { \ - if ( copy_to_user( name, value, len ) ) \ - return -EFAULT; \ - } - - version.version_major = DRIVER_MAJOR; - version.version_minor = DRIVER_MINOR; - version.version_patchlevel = DRIVER_PATCHLEVEL; - - DRM_COPY( version.name, DRIVER_NAME ); - DRM_COPY( version.date, DRIVER_DATE ); - DRM_COPY( version.desc, DRIVER_DESC ); - + /* version is a required function to return the personality module version */ + if ((ret = dev->fn_tbl->version(&version))) + return ret; + if ( copy_to_user( argp, &version, sizeof(version) ) ) return -EFAULT; return 0; @@ -740,32 +747,33 @@ int DRM(version)( struct inode *inode, struct file *filp, * increments the device open count. If the open count was previous at zero, * i.e., it's the first that the device is open, then calls setup(). */ -int DRM(open)( struct inode *inode, struct file *filp ) +int drm_open( struct inode *inode, struct file *filp ) { drm_device_t *dev = NULL; int minor = iminor(inode); int retcode = 0; - if (!((minor >= 0) && (minor < DRM(global)->cards_limit))) + if (!((minor >= 0) && (minor < cards_limit))) return -ENODEV; - dev = DRM(global)->minors[minor].dev; + dev = drm_minors[minor].dev; if (!dev) return -ENODEV; - retcode = DRM(open_helper)( inode, filp, dev ); + retcode = drm_open_helper( inode, filp, dev ); if ( !retcode ) { atomic_inc( &dev->counts[_DRM_STAT_OPENS] ); spin_lock( &dev->count_lock ); if ( !dev->open_count++ ) { spin_unlock( &dev->count_lock ); - return DRM(setup)( dev ); + return drm_setup( dev ); } spin_unlock( &dev->count_lock ); } return retcode; } +EXPORT_SYMBOL(drm_open); /** * Release file. @@ -779,7 +787,7 @@ int DRM(open)( struct inode *inode, struct file *filp ) * data from its list and free it. Decreases the open count and if it reaches * zero calls takedown(). */ -int DRM(release)( struct inode *inode, struct file *filp ) +int drm_release( struct inode *inode, struct file *filp ) { drm_file_t *priv = filp->private_data; drm_device_t *dev; @@ -790,8 +798,8 @@ int DRM(release)( struct inode *inode, struct file *filp ) DRM_DEBUG( "open_count = %d\n", dev->open_count ); - if (dev->fn_tbl.prerelease) - dev->fn_tbl.prerelease(dev, filp); + if (dev->fn_tbl->prerelease) + dev->fn_tbl->prerelease(dev, filp); /* ======================================================== * Begin inline drm_release @@ -807,10 +815,10 @@ int DRM(release)( struct inode *inode, struct file *filp ) filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) ); - if (dev->fn_tbl.release) - dev->fn_tbl.release(dev, filp); + if (dev->fn_tbl->release) + dev->fn_tbl->release(dev, filp); - DRM(lock_free)( dev, &dev->lock.hw_lock->lock, + drm_lock_free( dev, &dev->lock.hw_lock->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) ); /* FIXME: may require heavy-handed reset of @@ -818,7 +826,7 @@ int DRM(release)( struct inode *inode, struct file *filp ) processed via a callback to the X server. */ } - else if ( dev->fn_tbl.release && priv->lock_count && dev->lock.hw_lock ) { + else if ( dev->fn_tbl->release && priv->lock_count && dev->lock.hw_lock ) { /* The lock is required to reclaim buffers */ DECLARE_WAITQUEUE( entry, current ); @@ -830,7 +838,7 @@ int DRM(release)( struct inode *inode, struct file *filp ) retcode = -EINTR; break; } - if ( DRM(lock_take)( &dev->lock.hw_lock->lock, + if ( drm_lock_take( &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT ) ) { dev->lock.filp = filp; dev->lock.lock_time = jiffies; @@ -847,19 +855,19 @@ int DRM(release)( struct inode *inode, struct file *filp ) current->state = TASK_RUNNING; remove_wait_queue( &dev->lock.lock_queue, &entry ); if( !retcode ) { - if (dev->fn_tbl.release) - dev->fn_tbl.release(dev, filp); - DRM(lock_free)( dev, &dev->lock.hw_lock->lock, + if (dev->fn_tbl->release) + dev->fn_tbl->release(dev, filp); + drm_lock_free( dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT ); } } if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) { - dev->fn_tbl.reclaim_buffers(filp); + dev->fn_tbl->reclaim_buffers(filp); } - DRM(fasync)( -1, filp, 0 ); + drm_fasync( -1, filp, 0 ); down( &dev->ctxlist_sem ); if ( !list_empty( &dev->ctxlist->head ) ) { @@ -868,13 +876,13 @@ int DRM(release)( struct inode *inode, struct file *filp ) list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) { if ( pos->tag == priv && pos->handle != DRM_KERNEL_CONTEXT ) { - if (dev->fn_tbl.context_dtor) - dev->fn_tbl.context_dtor(dev, pos->handle); + if (dev->fn_tbl->context_dtor) + dev->fn_tbl->context_dtor(dev, pos->handle); - DRM(ctxbitmap_free)( dev, pos->handle ); + drm_ctxbitmap_free( dev, pos->handle ); list_del( &pos->head ); - DRM(free)( pos, sizeof(*pos), DRM_MEM_CTXLIST ); + drm_free( pos, sizeof(*pos), DRM_MEM_CTXLIST ); --dev->ctx_count; } } @@ -901,9 +909,9 @@ int DRM(release)( struct inode *inode, struct file *filp ) } up( &dev->struct_sem ); - if (dev->fn_tbl.free_filp_priv) - dev->fn_tbl.free_filp_priv( dev, priv ); - DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES ); + if (dev->fn_tbl->free_filp_priv) + dev->fn_tbl->free_filp_priv( dev, priv ); + drm_free( priv, sizeof(*priv), DRM_MEM_FILES ); /* ======================================================== * End inline drm_release @@ -922,7 +930,7 @@ int DRM(release)( struct inode *inode, struct file *filp ) } spin_unlock( &dev->count_lock ); unlock_kernel(); - return DRM(takedown)( dev ); + return drm_takedown( dev ); } spin_unlock( &dev->count_lock ); @@ -930,6 +938,7 @@ int DRM(release)( struct inode *inode, struct file *filp ) return retcode; } +EXPORT_SYMBOL(drm_release); /** * Called whenever a process performs an ioctl on /dev/drm. @@ -943,15 +952,15 @@ int DRM(release)( struct inode *inode, struct file *filp ) * Looks up the ioctl function in the ::ioctls table, checking for root * previleges if so required, and dispatches to the respective function. */ -int DRM(ioctl)( struct inode *inode, struct file *filp, +int drm_ioctl( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_ioctl_desc_t *ioctl; drm_ioctl_t *func; - int nr = DRM_IOCTL_NR(cmd); - int retcode = 0; + unsigned int nr = DRM_IOCTL_NR(cmd); + int retcode = -EINVAL; atomic_inc( &dev->ioctl_count ); atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] ); @@ -961,27 +970,32 @@ int DRM(ioctl)( struct inode *inode, struct file *filp, current->pid, cmd, nr, (long)old_encode_dev(dev->device), priv->authenticated ); - if ( nr >= DRIVER_IOCTL_COUNT ) { + if (nr < DRIVER_IOCTL_COUNT) + ioctl = &drm_ioctls[nr]; + else if ((nr >= DRM_COMMAND_BASE) || (nr < DRM_COMMAND_BASE + dev->fn_tbl->num_ioctls)) + ioctl = &dev->fn_tbl->ioctls[nr - DRM_COMMAND_BASE]; + else + goto err_i1; + + func = ioctl->func; + if ((nr == DRM_IOCTL_NR(DRM_IOCTL_DMA)) && dev->fn_tbl->dma_ioctl) /* Local override? */ + func = dev->fn_tbl->dma_ioctl; + + if ( !func ) { + DRM_DEBUG( "no function\n" ); retcode = -EINVAL; + } else if ( ( ioctl->root_only && !capable( CAP_SYS_ADMIN ) )|| + ( ioctl->auth_needed && !priv->authenticated ) ) { + retcode = -EACCES; } else { - ioctl = &DRM(ioctls)[nr]; - func = ioctl->func; - - if ( !func ) { - DRM_DEBUG( "no function\n" ); - retcode = -EINVAL; - } else if ( ( ioctl->root_only && !capable( CAP_SYS_ADMIN ) )|| - ( ioctl->auth_needed && !priv->authenticated ) ) { - retcode = -EACCES; - } else { - retcode = func( inode, filp, cmd, arg ); - } + retcode = func( inode, filp, cmd, arg ); } - +err_i1: atomic_dec( &dev->ioctl_count ); if (retcode) DRM_DEBUG( "ret = %x\n", retcode); return retcode; } +EXPORT_SYMBOL(drm_ioctl); /** * Lock ioctl. @@ -994,7 +1008,7 @@ int DRM(ioctl)( struct inode *inode, struct file *filp, * * Add the current task to the lock wait queue, and attempt to take to lock. */ -int DRM(lock)( struct inode *inode, struct file *filp, +int drm_lock( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -1030,7 +1044,7 @@ int DRM(lock)( struct inode *inode, struct file *filp, ret = -EINTR; break; } - if ( DRM(lock_take)( &dev->lock.hw_lock->lock, + if ( drm_lock_take( &dev->lock.hw_lock->lock, lock.context ) ) { dev->lock.filp = filp; dev->lock.lock_time = jiffies; @@ -1055,18 +1069,18 @@ int DRM(lock)( struct inode *inode, struct file *filp, sigaddset( &dev->sigmask, SIGTTOU ); dev->sigdata.context = lock.context; dev->sigdata.lock = dev->lock.hw_lock; - block_all_signals( DRM(notifier), + block_all_signals( drm_notifier, &dev->sigdata, &dev->sigmask ); - if (dev->fn_tbl.dma_ready && (lock.flags & _DRM_LOCK_READY)) - dev->fn_tbl.dma_ready(dev); + if (dev->fn_tbl->dma_ready && (lock.flags & _DRM_LOCK_READY)) + dev->fn_tbl->dma_ready(dev); - if ( dev->fn_tbl.dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT )) - return dev->fn_tbl.dma_quiescent(dev); + if ( dev->fn_tbl->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT )) + return dev->fn_tbl->dma_quiescent(dev); - if ( dev->fn_tbl.kernel_context_switch && dev->last_context != lock.context ) { - dev->fn_tbl.kernel_context_switch(dev, dev->last_context, + if ( dev->fn_tbl->kernel_context_switch && dev->last_context != lock.context ) { + dev->fn_tbl->kernel_context_switch(dev, dev->last_context, lock.context); } @@ -1087,7 +1101,7 @@ int DRM(lock)( struct inode *inode, struct file *filp, * * Transfer and free the lock. */ -int DRM(unlock)( struct inode *inode, struct file *filp, +int drm_unlock( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -1105,14 +1119,14 @@ int DRM(unlock)( struct inode *inode, struct file *filp, atomic_inc( &dev->counts[_DRM_STAT_UNLOCKS] ); - if (dev->fn_tbl.kernel_context_switch_unlock) - dev->fn_tbl.kernel_context_switch_unlock(dev); + if (dev->fn_tbl->kernel_context_switch_unlock) + dev->fn_tbl->kernel_context_switch_unlock(dev); else { - DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock, + drm_lock_transfer( dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT ); - if ( DRM(lock_free)( dev, &dev->lock.hw_lock->lock, + if ( drm_lock_free( dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT ) ) { DRM_ERROR( "\n" ); } diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c index 0e91190a..89f64527 100644 --- a/linux-core/drm_fops.c +++ b/linux-core/drm_fops.c @@ -49,18 +49,18 @@ * Creates and initializes a drm_file structure for the file private data in \p * filp and add it into the double linked list in \p dev. */ -int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) +int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t *dev) { int minor = iminor(inode); drm_file_t *priv; int ret; if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */ - if (!DRM(cpu_valid)()) return -EINVAL; + if (!drm_cpu_valid()) return -EINVAL; DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor); - priv = DRM(alloc)(sizeof(*priv), DRM_MEM_FILES); + priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES); if(!priv) return -ENOMEM; memset(priv, 0, sizeof(*priv)); @@ -73,8 +73,8 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) priv->authenticated = capable(CAP_SYS_ADMIN); priv->lock_count = 0; - if (dev->fn_tbl.open_helper) { - ret=dev->fn_tbl.open_helper(dev, priv); + if (dev->fn_tbl->open_helper) { + ret=dev->fn_tbl->open_helper(dev, priv); if (ret < 0) goto out_free; } @@ -110,13 +110,13 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) return 0; out_free: - DRM(free)(priv, sizeof(*priv), DRM_MEM_FILES); + drm_free(priv, sizeof(*priv), DRM_MEM_FILES); filp->private_data=NULL; return ret; } /** No-op. */ -int DRM(flush)(struct file *filp) +int drm_flush(struct file *filp) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; @@ -125,9 +125,10 @@ int DRM(flush)(struct file *filp) current->pid, (long)old_encode_dev(dev->device), dev->open_count); return 0; } +EXPORT_SYMBOL(drm_flush); /** No-op. */ -int DRM(fasync)(int fd, struct file *filp, int on) +int drm_fasync(int fd, struct file *filp, int on) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; @@ -138,16 +139,17 @@ int DRM(fasync)(int fd, struct file *filp, int on) if (retcode < 0) return retcode; return 0; } +EXPORT_SYMBOL(drm_fasync); /** No-op. */ -unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait) +unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait) { return 0; } /** No-op. */ -ssize_t DRM(read)(struct file *filp, char __user *buf, size_t count, loff_t *off) +ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off) { return 0; } diff --git a/linux-core/drm_init.c b/linux-core/drm_init.c index ae6ecbf9..f359b8d8 100644 --- a/linux-core/drm_init.c +++ b/linux-core/drm_init.c @@ -37,10 +37,11 @@ /** Debug flags. Set by parse_option(). */ #if 0 -int DRM(flags) = DRM_FLAG_DEBUG; +int drm_flags = DRM_FLAG_DEBUG; #else -int DRM(flags) = 0; +int drm_flags = 0; #endif +EXPORT_SYMBOL(drm_flags); /** * Parse a single option. @@ -49,7 +50,7 @@ int DRM(flags) = 0; * * \sa See parse_options() for details. */ -static void DRM(parse_option)(char *s) +static void drm_parse_option(char *s) { char *c, *r; @@ -59,7 +60,7 @@ static void DRM(parse_option)(char *s) if (*c) r = c + 1; else r = NULL; /* remember remainder */ *c = '\0'; /* terminate */ if (!strcmp(s, "debug")) { - DRM(flags) |= DRM_FLAG_DEBUG; + drm_flags |= DRM_FLAG_DEBUG; DRM_INFO("Debug messages ON\n"); return; } @@ -96,7 +97,7 @@ static void DRM(parse_option)(char *s) * checked. */ -void DRM(parse_options)(char *s) +void drm_parse_options(char *s) { char *h, *t, *n; @@ -107,7 +108,7 @@ void DRM(parse_options)(char *s) for (; *t && *t != ';'; t++); /* find ; or \0 */ if (*t) n = t + 1; else n = NULL; /* remember next */ *t = '\0'; /* terminate */ - DRM(parse_option)(h); /* parse */ + drm_parse_option(h); /* parse */ } } @@ -116,7 +117,7 @@ void DRM(parse_options)(char *s) * * \return non-zero if the DRI will run on this CPU, or zero otherwise. */ -int DRM(cpu_valid)(void) +int drm_cpu_valid(void) { #if defined(__i386__) if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */ diff --git a/linux-core/drm_ioctl.c b/linux-core/drm_ioctl.c index 33695440..6bccbcad 100644 --- a/linux-core/drm_ioctl.c +++ b/linux-core/drm_ioctl.c @@ -34,6 +34,7 @@ */ #include "drmP.h" +#include "drm_core.h" #include "linux/pci.h" @@ -48,7 +49,7 @@ * * Copies the bus id from drm_device::unique into user space. */ -int DRM(getunique)(struct inode *inode, struct file *filp, +int drm_getunique(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -82,7 +83,7 @@ int DRM(getunique)(struct inode *inode, struct file *filp, * in interface version 1.1 and will return EBUSY when setversion has requested * version 1.1 or greater. */ -int DRM(setunique)(struct inode *inode, struct file *filp, +int drm_setunique(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -98,14 +99,14 @@ int DRM(setunique)(struct inode *inode, struct file *filp, if (!u.unique_len || u.unique_len > 1024) return -EINVAL; dev->unique_len = u.unique_len; - dev->unique = DRM(alloc)(u.unique_len + 1, DRM_MEM_DRIVER); + dev->unique = drm_alloc(u.unique_len + 1, DRM_MEM_DRIVER); if(!dev->unique) return -ENOMEM; if (copy_from_user(dev->unique, u.unique, dev->unique_len)) return -EFAULT; dev->unique[dev->unique_len] = '\0'; - dev->devname = DRM(alloc)(strlen(dev->name) + strlen(dev->unique) + 2, + dev->devname = drm_alloc(strlen(dev->name) + strlen(dev->unique) + 2, DRM_MEM_DRIVER); if (!dev->devname) return -ENOMEM; @@ -131,20 +132,20 @@ int DRM(setunique)(struct inode *inode, struct file *filp, } static int -DRM(set_busid)(drm_device_t *dev) +drm_set_busid(drm_device_t *dev) { if (dev->unique != NULL) return EBUSY; dev->unique_len = 20; - dev->unique = DRM(alloc)(dev->unique_len + 1, DRM_MEM_DRIVER); + dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER); if (dev->unique == NULL) return ENOMEM; snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d", dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func); - dev->devname = DRM(alloc)(strlen(dev->name) + dev->unique_len + 2, + dev->devname = drm_alloc(strlen(dev->name) + dev->unique_len + 2, DRM_MEM_DRIVER); if (dev->devname == NULL) return ENOMEM; @@ -168,7 +169,7 @@ DRM(set_busid)(drm_device_t *dev) * Searches for the mapping with the specified offset and copies its information * into userspace */ -int DRM(getmap)( struct inode *inode, struct file *filp, +int drm_getmap( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -228,7 +229,7 @@ int DRM(getmap)( struct inode *inode, struct file *filp, * Searches for the client with the specified index and copies its information * into userspace */ -int DRM(getclient)( struct inode *inode, struct file *filp, +int drm_getclient( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -272,7 +273,7 @@ int DRM(getclient)( struct inode *inode, struct file *filp, * * \return zero on success or a negative number on failure. */ -int DRM(getstats)( struct inode *inode, struct file *filp, +int drm_getstats( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -303,10 +304,7 @@ int DRM(getstats)( struct inode *inode, struct file *filp, return 0; } -#define DRM_IF_MAJOR 1 -#define DRM_IF_MINOR 2 - -int DRM(setversion)(DRM_IOCTL_ARGS) +int drm_setversion(DRM_IOCTL_ARGS) { DRM_DEVICE; drm_set_version_t sv; @@ -333,7 +331,7 @@ int DRM(setversion)(DRM_IOCTL_ARGS) /* * Version 1.1 includes tying of DRM to specific device */ - DRM(set_busid)(dev); + drm_set_busid(dev); } } @@ -342,8 +340,8 @@ int DRM(setversion)(DRM_IOCTL_ARGS) sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR) return EINVAL; - if (dev->fn_tbl.set_version) - dev->fn_tbl.set_version(dev, &sv); + if (dev->fn_tbl->set_version) + dev->fn_tbl->set_version(dev, &sv); } return 0; } diff --git a/linux-core/drm_irq.c b/linux-core/drm_irq.c index 3e0cfe25..d8cc56ad 100644 --- a/linux-core/drm_irq.c +++ b/linux-core/drm_irq.c @@ -50,7 +50,7 @@ * This IOCTL is deprecated, and will now return EINVAL for any busid not equal * to that of the device that this DRM instance attached to. */ -int DRM(irq_by_busid)(struct inode *inode, struct file *filp, +int drm_irq_by_busid(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; @@ -85,10 +85,10 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp, * \param dev DRM device. * * Initializes the IRQ related data, and setups drm_device::vbl_queue. Installs the handler, calling the driver - * \c DRM(driver_irq_preinstall)() and \c DRM(driver_irq_postinstall)() functions + * \c drm_driver_irq_preinstall() and \c drm_driver_irq_postinstall() functions * before and after the installation. */ -int DRM(irq_install)( drm_device_t *dev ) +int drm_irq_install( drm_device_t *dev ) { int ret; unsigned long sh_flags=0; @@ -131,13 +131,13 @@ int DRM(irq_install)( drm_device_t *dev ) } /* Before installing handler */ - dev->fn_tbl.irq_preinstall(dev); + dev->fn_tbl->irq_preinstall(dev); /* Install handler */ if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED)) sh_flags = SA_SHIRQ; - ret = request_irq( dev->irq, dev->fn_tbl.irq_handler, + ret = request_irq( dev->irq, dev->fn_tbl->irq_handler, sh_flags, dev->devname, dev ); if ( ret < 0 ) { down( &dev->struct_sem ); @@ -147,7 +147,7 @@ int DRM(irq_install)( drm_device_t *dev ) } /* After installing handler */ - dev->fn_tbl.irq_postinstall(dev); + dev->fn_tbl->irq_postinstall(dev); return 0; } @@ -157,9 +157,9 @@ int DRM(irq_install)( drm_device_t *dev ) * * \param dev DRM device. * - * Calls the driver's \c DRM(driver_irq_uninstall)() function, and stops the irq. + * Calls the driver's \c drm_driver_irq_uninstall() function, and stops the irq. */ -int DRM(irq_uninstall)( drm_device_t *dev ) +int drm_irq_uninstall( drm_device_t *dev ) { int irq_enabled; @@ -176,12 +176,13 @@ int DRM(irq_uninstall)( drm_device_t *dev ) DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq ); - dev->fn_tbl.irq_uninstall(dev); + dev->fn_tbl->irq_uninstall(dev); free_irq( dev->irq, dev ); return 0; } +EXPORT_SYMBOL(drm_irq_uninstall); /** * IRQ control ioctl. @@ -194,7 +195,7 @@ int DRM(irq_uninstall)( drm_device_t *dev ) * * Calls irq_install() or irq_uninstall() according to \p arg. */ -int DRM(control)( struct inode *inode, struct file *filp, +int drm_control( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -213,11 +214,11 @@ int DRM(control)( struct inode *inode, struct file *filp, if (dev->if_version < DRM_IF_VERSION(1, 2) && ctl.irq != dev->irq) return -EINVAL; - return DRM(irq_install)( dev ); + return drm_irq_install( dev ); case DRM_UNINST_HANDLER: if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) return 0; - return DRM(irq_uninstall)( dev ); + return drm_irq_uninstall( dev ); default: return -EINVAL; } @@ -242,7 +243,7 @@ int DRM(control)( struct inode *inode, struct file *filp, * * If a signal is not requested, then calls vblank_wait(). */ -int DRM(wait_vblank)( DRM_IOCTL_ARGS ) +int drm_wait_vblank( DRM_IOCTL_ARGS ) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; @@ -303,7 +304,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); - if ( !( vbl_sig = DRM(alloc)( sizeof( drm_vbl_sig_t ), DRM_MEM_DRIVER ) ) ) { + if ( !( vbl_sig = drm_alloc( sizeof( drm_vbl_sig_t ), DRM_MEM_DRIVER ) ) ) { return -ENOMEM; } @@ -319,8 +320,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); } else { - if (dev->fn_tbl.vblank_wait) - ret = dev->fn_tbl.vblank_wait( dev, &vblwait.request.sequence ); + if (dev->fn_tbl->vblank_wait) + ret = dev->fn_tbl->vblank_wait( dev, &vblwait.request.sequence ); do_gettimeofday( &now ); vblwait.reply.tval_sec = now.tv_sec; @@ -342,7 +343,7 @@ done: * * If a signal is not requested, then calls vblank_wait(). */ -void DRM(vbl_send_signals)( drm_device_t *dev ) +void drm_vbl_send_signals( drm_device_t *dev ) { struct list_head *list, *tmp; drm_vbl_sig_t *vbl_sig; @@ -359,7 +360,7 @@ void DRM(vbl_send_signals)( drm_device_t *dev ) list_del( list ); - DRM(free)( vbl_sig, sizeof(*vbl_sig), DRM_MEM_DRIVER ); + drm_free( vbl_sig, sizeof(*vbl_sig), DRM_MEM_DRIVER ); dev->vbl_pending--; } @@ -367,5 +368,6 @@ void DRM(vbl_send_signals)( drm_device_t *dev ) spin_unlock_irqrestore( &dev->vbl_lock, flags ); } +EXPORT_SYMBOL(drm_vbl_send_signals); diff --git a/linux-core/drm_lock.c b/linux-core/drm_lock.c index 55fb29f3..90c9109f 100644 --- a/linux-core/drm_lock.c +++ b/linux-core/drm_lock.c @@ -36,7 +36,7 @@ #include "drmP.h" /** No-op ioctl. */ -int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd, +int drm_noop(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { DRM_DEBUG("\n"); @@ -52,7 +52,7 @@ int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd, * * Attempt to mark the lock as held by the given context, via the \p cmpxchg instruction. */ -int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context) +int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context) { unsigned int old, new, prev; @@ -90,7 +90,7 @@ int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context) * Resets the lock file pointer. * Marks the lock as held by the given context, via the \p cmpxchg instruction. */ -int DRM(lock_transfer)(drm_device_t *dev, +int drm_lock_transfer(drm_device_t *dev, __volatile__ unsigned int *lock, unsigned int context) { unsigned int old, new, prev; @@ -115,7 +115,7 @@ int DRM(lock_transfer)(drm_device_t *dev, * Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task * waiting on the lock queue. */ -int DRM(lock_free)(drm_device_t *dev, +int drm_lock_free(drm_device_t *dev, __volatile__ unsigned int *lock, unsigned int context) { unsigned int old, new, prev; @@ -147,7 +147,7 @@ int DRM(lock_free)(drm_device_t *dev, * \return one if the signal should be delivered normally, or zero if the * signal should be blocked. */ -int DRM(notifier)(void *priv) +int drm_notifier(void *priv) { drm_sigdata_t *s = (drm_sigdata_t *)priv; unsigned int old, new, prev; diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h index 9674cef0..cb90b514 100644 --- a/linux-core/drm_memory.h +++ b/linux-core/drm_memory.h @@ -212,163 +212,3 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d iounmap(pt); } - - -#ifdef DEBUG_MEMORY -#include "drm_memory_debug.h" -#else - -/** No-op. */ -void DRM(mem_init)(void) -{ -} - -/** - * Called when "/proc/dri/%dev%/mem" is read. - * - * \param buf output buffer. - * \param start start of output data. - * \param offset requested start offset. - * \param len requested number of bytes. - * \param eof whether there is no more data to return. - * \param data private data. - * \return number of written bytes. - * - * No-op. - */ -int DRM(mem_info)(char *buf, char **start, off_t offset, - int len, int *eof, void *data) -{ - return 0; -} - -/** Wrapper around kmalloc() */ -void *DRM(calloc)(size_t nmemb, size_t size, int area) -{ - void *addr; - - addr = kmalloc(size * nmemb, GFP_KERNEL); - if (addr != NULL) - memset((void *)addr, 0, size * nmemb); - - return addr; -} - -/** Wrapper around kmalloc() and kfree() */ -void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area) -{ - void *pt; - - if (!(pt = kmalloc(size, GFP_KERNEL))) return NULL; - if (oldpt && oldsize) { - memcpy(pt, oldpt, oldsize); - kfree(oldpt); - } - return pt; -} - -/** - * Allocate pages. - * - * \param order size order. - * \param area memory area. (Not used.) - * \return page address on success, or zero on failure. - * - * Allocate and reserve free pages. - */ -unsigned long DRM(alloc_pages)(int order, int area) -{ - unsigned long address; - unsigned long bytes = PAGE_SIZE << order; - unsigned long addr; - unsigned int sz; - - address = __get_free_pages(GFP_KERNEL, order); - if (!address) - return 0; - - /* Zero */ - memset((void *)address, 0, bytes); - - /* Reserve */ - for (addr = address, sz = bytes; - sz > 0; - addr += PAGE_SIZE, sz -= PAGE_SIZE) { - SetPageReserved(virt_to_page(addr)); - } - - return address; -} - -/** - * Free pages. - * - * \param address address of the pages to free. - * \param order size order. - * \param area memory area. (Not used.) - * - * Unreserve and free pages allocated by alloc_pages(). - */ -void DRM(free_pages)(unsigned long address, int order, int area) -{ - unsigned long bytes = PAGE_SIZE << order; - unsigned long addr; - unsigned int sz; - - if (!address) - return; - - /* Unreserve */ - for (addr = address, sz = bytes; - sz > 0; - addr += PAGE_SIZE, sz -= PAGE_SIZE) { - ClearPageReserved(virt_to_page(addr)); - } - - free_pages(address, order); -} - -/** Wrapper around drm_ioremap() */ -void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev) -{ - return drm_ioremap(offset, size, dev); -} - -/** Wrapper around drm_ioremap_nocache() */ -void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, drm_device_t *dev) -{ - return drm_ioremap_nocache(offset, size, dev); -} - -/** Wrapper around drm_iounmap() */ -void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev) -{ - drm_ioremapfree(pt, size, dev); -} - -#if __OS_HAS_AGP -/** Wrapper around agp_allocate_memory() */ -DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type) -{ - return DRM(agp_allocate_memory)(pages, type); -} - -/** Wrapper around agp_free_memory() */ -int DRM(free_agp)(DRM_AGP_MEM *handle, int pages) -{ - return DRM(agp_free_memory)(handle) ? 0 : -EINVAL; -} - -/** Wrapper around agp_bind_memory() */ -int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start) -{ - return DRM(agp_bind_memory)(handle, start); -} - -/** Wrapper around agp_unbind_memory() */ -int DRM(unbind_agp)(DRM_AGP_MEM *handle) -{ - return DRM(agp_unbind_memory)(handle); -} -#endif /* agp */ -#endif /* debug_memory */ diff --git a/linux-core/drm_pci.c b/linux-core/drm_pci.c index b9d54c45..ba46f4fa 100644 --- a/linux-core/drm_pci.c +++ b/linux-core/drm_pci.c @@ -9,12 +9,12 @@ * \todo Add support to map these buffers. * \todo The wrappers here are so thin that they would be better off inlined.. * - * \author José Fonseca <jrfonseca@tungstengraphics.com> + * \author Jos�Fonseca <jrfonseca@tungstengraphics.com> * \author Leif Delgass <ldelgass@retinalburn.net> */ /* - * Copyright 2003 José Fonseca. + * Copyright 2003 Jos�Fonseca. * Copyright 2003 Leif Delgass. * All Rights Reserved. * @@ -50,7 +50,7 @@ * \brief Allocate a PCI consistent memory block, for DMA. */ void * -DRM(pci_alloc)(drm_device_t *dev, size_t size, size_t align, +drm_pci_alloc(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr, dma_addr_t *busaddr) { void *address; @@ -61,13 +61,13 @@ DRM(pci_alloc)(drm_device_t *dev, size_t size, size_t align, #if DRM_DEBUG_MEMORY int area = DRM_MEM_DMA; - spin_lock(&DRM(mem_lock)); - if ((DRM(ram_used) >> PAGE_SHIFT) - > (DRM_RAM_PERCENT * DRM(ram_available)) / 100) { - spin_unlock(&DRM(mem_lock)); + spin_lock(&drm_mem_lock); + if ((drm_ram_used >> PAGE_SHIFT) + > (DRM_RAM_PERCENT * drm_ram_available) / 100) { + spin_unlock(&drm_mem_lock); return 0; } - spin_unlock(&DRM(mem_lock)); + spin_unlock(&drm_mem_lock); #endif /* pci_alloc_consistent only guarantees alignment to the smallest @@ -86,17 +86,17 @@ DRM(pci_alloc)(drm_device_t *dev, size_t size, size_t align, #if DRM_DEBUG_MEMORY if (address == NULL) { - spin_lock(&DRM(mem_lock)); - ++DRM(mem_stats)[area].fail_count; - spin_unlock(&DRM(mem_lock)); + spin_lock(&drm_mem_lock); + ++drm_mem_stats[area].fail_count; + spin_unlock(&drm_mem_lock); return NULL; } - spin_lock(&DRM(mem_lock)); - ++DRM(mem_stats)[area].succeed_count; - DRM(mem_stats)[area].bytes_allocated += size; - DRM(ram_used) += size; - spin_unlock(&DRM(mem_lock)); + spin_lock(&drm_mem_lock); + ++drm_mem_stats[area].succeed_count; + drm_mem_stats[area].bytes_allocated += size; + drm_ram_used += size; + spin_unlock(&drm_mem_lock); #else if (address == NULL) return NULL; @@ -116,12 +116,13 @@ DRM(pci_alloc)(drm_device_t *dev, size_t size, size_t align, return address; } +EXPORT_SYMBOL(drm_pci_alloc); /** * \brief Free a PCI consistent memory block. */ void -DRM(pci_free)(drm_device_t *dev, size_t size, void *vaddr, dma_addr_t busaddr) +drm_pci_free(drm_device_t *dev, size_t size, void *vaddr, dma_addr_t busaddr) { #if 0 unsigned long addr; @@ -151,12 +152,12 @@ DRM(pci_free)(drm_device_t *dev, size_t size, void *vaddr, dma_addr_t busaddr) } #if DRM_DEBUG_MEMORY - spin_lock(&DRM(mem_lock)); - free_count = ++DRM(mem_stats)[area].free_count; - alloc_count = DRM(mem_stats)[area].succeed_count; - DRM(mem_stats)[area].bytes_freed += size; - DRM(ram_used) -= size; - spin_unlock(&DRM(mem_lock)); + spin_lock(&drm_mem_lock); + free_count = ++drm_mem_stats[area].free_count; + alloc_count = drm_mem_stats[area].succeed_count; + drm_mem_stats[area].bytes_freed += size; + drm_ram_used -= size; + spin_unlock(&drm_mem_lock); if (free_count > alloc_count) { DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n", @@ -165,5 +166,6 @@ DRM(pci_free)(drm_device_t *dev, size_t size, void *vaddr, dma_addr_t busaddr) #endif } +EXPORT_SYMBOL(drm_pci_free); /*@}*/ diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c index 7df63fbd..7f342075 100644 --- a/linux-core/drm_proc.c +++ b/linux-core/drm_proc.c @@ -39,18 +39,18 @@ #include "drmP.h" -static int DRM(name_info)(char *buf, char **start, off_t offset, +static int drm_name_info(char *buf, char **start, off_t offset, int request, int *eof, void *data); -static int DRM(vm_info)(char *buf, char **start, off_t offset, +static int drm_vm_info(char *buf, char **start, off_t offset, int request, int *eof, void *data); -static int DRM(clients_info)(char *buf, char **start, off_t offset, +static int drm_clients_info(char *buf, char **start, off_t offset, int request, int *eof, void *data); -static int DRM(queues_info)(char *buf, char **start, off_t offset, +static int drm_queues_info(char *buf, char **start, off_t offset, int request, int *eof, void *data); -static int DRM(bufs_info)(char *buf, char **start, off_t offset, +static int drm_bufs_info(char *buf, char **start, off_t offset, int request, int *eof, void *data); #if DRM_DEBUG_CODE -static int DRM(vma_info)(char *buf, char **start, off_t offset, +static int drm_vma_info(char *buf, char **start, off_t offset, int request, int *eof, void *data); #endif @@ -60,18 +60,18 @@ static int DRM(vma_info)(char *buf, char **start, off_t offset, struct drm_proc_list { const char *name; /**< file name */ int (*f)(char *, char **, off_t, int, int *, void *); /**< proc callback*/ -} DRM(proc_list)[] = { - { "name", DRM(name_info) }, - { "mem", DRM(mem_info) }, - { "vm", DRM(vm_info) }, - { "clients", DRM(clients_info) }, - { "queues", DRM(queues_info) }, - { "bufs", DRM(bufs_info) }, +} drm_proc_list[] = { + { "name", drm_name_info }, + { "mem", drm_mem_info }, + { "vm", drm_vm_info }, + { "clients", drm_clients_info }, + { "queues", drm_queues_info }, + { "bufs", drm_bufs_info }, #if DRM_DEBUG_CODE - { "vma", DRM(vma_info) }, + { "vma", drm_vma_info }, #endif }; -#define DRM_PROC_ENTRIES (sizeof(DRM(proc_list))/sizeof(DRM(proc_list)[0])) +#define DRM_PROC_ENTRIES (sizeof(drm_proc_list)/sizeof(drm_proc_list[0])) /** * Initialize the DRI proc filesystem for a device. @@ -86,7 +86,7 @@ struct drm_proc_list { * "/proc/dri/%minor%/", and each entry in proc_list as * "/proc/dri/%minor%/%name%". */ -int DRM(proc_init)(drm_device_t *dev, int minor, +int drm_proc_init(drm_device_t *dev, int minor, struct proc_dir_entry *root, struct proc_dir_entry **dev_root) { @@ -102,18 +102,18 @@ int DRM(proc_init)(drm_device_t *dev, int minor, } for (i = 0; i < DRM_PROC_ENTRIES; i++) { - ent = create_proc_entry(DRM(proc_list)[i].name, + ent = create_proc_entry(drm_proc_list[i].name, S_IFREG|S_IRUGO, *dev_root); if (!ent) { DRM_ERROR("Cannot create /proc/dri/%s/%s\n", - name, DRM(proc_list)[i].name); + name, drm_proc_list[i].name); for (j = 0; j < i; j++) - remove_proc_entry(DRM(proc_list)[i].name, + remove_proc_entry(drm_proc_list[i].name, *dev_root); remove_proc_entry(name, root); return -1; } - ent->read_proc = DRM(proc_list)[i].f; + ent->read_proc = drm_proc_list[i].f; ent->data = dev; } return 0; @@ -130,7 +130,7 @@ int DRM(proc_init)(drm_device_t *dev, int minor, * * Remove all proc entries created by proc_init(). */ -int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root, +int drm_proc_cleanup(int minor, struct proc_dir_entry *root, struct proc_dir_entry *dev_root) { int i; @@ -139,7 +139,7 @@ int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root, if (!root || !dev_root) return 0; for (i = 0; i < DRM_PROC_ENTRIES; i++) - remove_proc_entry(DRM(proc_list)[i].name, dev_root); + remove_proc_entry(drm_proc_list[i].name, dev_root); sprintf(name, "%d", minor); remove_proc_entry(name, root); @@ -159,7 +159,7 @@ int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root, * * Prints the device name together with the bus id if available. */ -static int DRM(name_info)(char *buf, char **start, off_t offset, int request, +static int drm_name_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; @@ -198,7 +198,7 @@ static int DRM(name_info)(char *buf, char **start, off_t offset, int request, * * Prints information about all mappings in drm_device::maplist. */ -static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request, +static int drm__vm_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; @@ -254,14 +254,14 @@ static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request, /** * Simply calls _vm_info() while holding the drm_device::struct_sem lock. */ -static int DRM(vm_info)(char *buf, char **start, off_t offset, int request, +static int drm_vm_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; int ret; down(&dev->struct_sem); - ret = DRM(_vm_info)(buf, start, offset, request, eof, data); + ret = drm__vm_info(buf, start, offset, request, eof, data); up(&dev->struct_sem); return ret; } @@ -277,7 +277,7 @@ static int DRM(vm_info)(char *buf, char **start, off_t offset, int request, * \param data private data. * \return number of written bytes. */ -static int DRM(_queues_info)(char *buf, char **start, off_t offset, +static int drm__queues_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; @@ -324,14 +324,14 @@ static int DRM(_queues_info)(char *buf, char **start, off_t offset, /** * Simply calls _queues_info() while holding the drm_device::struct_sem lock. */ -static int DRM(queues_info)(char *buf, char **start, off_t offset, int request, +static int drm_queues_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; int ret; down(&dev->struct_sem); - ret = DRM(_queues_info)(buf, start, offset, request, eof, data); + ret = drm__queues_info(buf, start, offset, request, eof, data); up(&dev->struct_sem); return ret; } @@ -347,7 +347,7 @@ static int DRM(queues_info)(char *buf, char **start, off_t offset, int request, * \param data private data. * \return number of written bytes. */ -static int DRM(_bufs_info)(char *buf, char **start, off_t offset, int request, +static int drm__bufs_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; @@ -394,14 +394,14 @@ static int DRM(_bufs_info)(char *buf, char **start, off_t offset, int request, /** * Simply calls _bufs_info() while holding the drm_device::struct_sem lock. */ -static int DRM(bufs_info)(char *buf, char **start, off_t offset, int request, +static int drm_bufs_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; int ret; down(&dev->struct_sem); - ret = DRM(_bufs_info)(buf, start, offset, request, eof, data); + ret = drm__bufs_info(buf, start, offset, request, eof, data); up(&dev->struct_sem); return ret; } @@ -417,7 +417,7 @@ static int DRM(bufs_info)(char *buf, char **start, off_t offset, int request, * \param data private data. * \return number of written bytes. */ -static int DRM(_clients_info)(char *buf, char **start, off_t offset, +static int drm__clients_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; @@ -451,21 +451,21 @@ static int DRM(_clients_info)(char *buf, char **start, off_t offset, /** * Simply calls _clients_info() while holding the drm_device::struct_sem lock. */ -static int DRM(clients_info)(char *buf, char **start, off_t offset, +static int drm_clients_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; int ret; down(&dev->struct_sem); - ret = DRM(_clients_info)(buf, start, offset, request, eof, data); + ret = drm__clients_info(buf, start, offset, request, eof, data); up(&dev->struct_sem); return ret; } #if DRM_DEBUG_CODE -static int DRM(_vma_info)(char *buf, char **start, off_t offset, int request, +static int drm__vma_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; @@ -522,14 +522,14 @@ static int DRM(_vma_info)(char *buf, char **start, off_t offset, int request, return len - offset; } -static int DRM(vma_info)(char *buf, char **start, off_t offset, int request, +static int drm_vma_info(char *buf, char **start, off_t offset, int request, int *eof, void *data) { drm_device_t *dev = (drm_device_t *)data; int ret; down(&dev->struct_sem); - ret = DRM(_vma_info)(buf, start, offset, request, eof, data); + ret = drm__vma_info(buf, start, offset, request, eof, data); up(&dev->struct_sem); return ret; } diff --git a/linux-core/drm_scatter.c b/linux-core/drm_scatter.c index 436a0170..5611bada 100644 --- a/linux-core/drm_scatter.c +++ b/linux-core/drm_scatter.c @@ -37,7 +37,7 @@ #define DEBUG_SCATTER 0 -void DRM(sg_cleanup)( drm_sg_mem_t *entry ) +void drm_sg_cleanup( drm_sg_mem_t *entry ) { struct page *page; int i; @@ -50,18 +50,18 @@ void DRM(sg_cleanup)( drm_sg_mem_t *entry ) vfree( entry->virtual ); - DRM(free)( entry->busaddr, + drm_free( entry->busaddr, entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES ); - DRM(free)( entry->pagelist, + drm_free( entry->pagelist, entry->pages * sizeof(*entry->pagelist), DRM_MEM_PAGES ); - DRM(free)( entry, + drm_free( entry, sizeof(*entry), DRM_MEM_SGLISTS ); } -int DRM(sg_alloc)( struct inode *inode, struct file *filp, +int drm_sg_alloc( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -82,7 +82,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, if ( copy_from_user( &request, argp, sizeof(request) ) ) return -EFAULT; - entry = DRM(alloc)( sizeof(*entry), DRM_MEM_SGLISTS ); + entry = drm_alloc( sizeof(*entry), DRM_MEM_SGLISTS ); if ( !entry ) return -ENOMEM; @@ -92,22 +92,22 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages ); entry->pages = pages; - entry->pagelist = DRM(alloc)( pages * sizeof(*entry->pagelist), + entry->pagelist = drm_alloc( pages * sizeof(*entry->pagelist), DRM_MEM_PAGES ); if ( !entry->pagelist ) { - DRM(free)( entry, sizeof(*entry), DRM_MEM_SGLISTS ); + drm_free( entry, sizeof(*entry), DRM_MEM_SGLISTS ); return -ENOMEM; } memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist)); - entry->busaddr = DRM(alloc)( pages * sizeof(*entry->busaddr), + entry->busaddr = drm_alloc( pages * sizeof(*entry->busaddr), DRM_MEM_PAGES ); if ( !entry->busaddr ) { - DRM(free)( entry->pagelist, + drm_free( entry->pagelist, entry->pages * sizeof(*entry->pagelist), DRM_MEM_PAGES ); - DRM(free)( entry, + drm_free( entry, sizeof(*entry), DRM_MEM_SGLISTS ); return -ENOMEM; @@ -116,13 +116,13 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, entry->virtual = vmalloc_32( pages << PAGE_SHIFT ); if ( !entry->virtual ) { - DRM(free)( entry->busaddr, + drm_free( entry->busaddr, entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES ); - DRM(free)( entry->pagelist, + drm_free( entry->pagelist, entry->pages * sizeof(*entry->pagelist), DRM_MEM_PAGES ); - DRM(free)( entry, + drm_free( entry, sizeof(*entry), DRM_MEM_SGLISTS ); return -ENOMEM; @@ -148,7 +148,7 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, request.handle = entry->handle; if ( copy_to_user( argp, &request, sizeof(request) ) ) { - DRM(sg_cleanup)( entry ); + drm_sg_cleanup( entry ); return -EFAULT; } @@ -197,11 +197,11 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp, return 0; failed: - DRM(sg_cleanup)( entry ); + drm_sg_cleanup( entry ); return -ENOMEM; } -int DRM(sg_free)( struct inode *inode, struct file *filp, +int drm_sg_free( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ) { drm_file_t *priv = filp->private_data; @@ -225,7 +225,7 @@ int DRM(sg_free)( struct inode *inode, struct file *filp, DRM_DEBUG( "sg free virtual = %p\n", entry->virtual ); - DRM(sg_cleanup)( entry ); + drm_sg_cleanup( entry ); return 0; } diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c index a09f08b8..00188b8c 100644 --- a/linux-core/drm_stub.c +++ b/linux-core/drm_stub.c @@ -31,10 +31,12 @@ * DEALINGS IN THE SOFTWARE. */ +#include <linux/module.h> #include "drmP.h" +#include "drm_core.h" -static unsigned int cards_limit = 16; /* Enough for one machine */ -static unsigned int debug = 0; /* 1 to enable debug output */ +unsigned int cards_limit = 16; /* Enough for one machine */ +unsigned int debug = 0; /* 1 to enable debug output */ MODULE_AUTHOR( DRIVER_AUTHOR ); MODULE_DESCRIPTION( DRIVER_DESC ); @@ -45,7 +47,9 @@ MODULE_PARM_DESC(debug, "Enable debug output"); module_param(cards_limit, int, 0444); module_param(debug, int, 0666); -drm_global_t *DRM(global); +drm_minor_t *drm_minors; +struct drm_sysfs_class *drm_class; +struct proc_dir_entry *drm_proc_root; /** * File \c open operation. @@ -65,10 +69,10 @@ static int stub_open(struct inode *inode, struct file *filp) DRM_DEBUG("\n"); - if (!((minor >= 0) && (minor < DRM(global)->cards_limit))) + if (!((minor >= 0) && (minor < cards_limit))) return -ENODEV; - dev = DRM(global)->minors[minor].dev; + dev = drm_minors[minor].dev; if (!dev) return -ENODEV; @@ -84,56 +88,57 @@ static int stub_open(struct inode *inode, struct file *filp) } /** File operations structure */ -static struct file_operations DRM(stub_fops) = { +struct file_operations drm_stub_fops = { .owner = THIS_MODULE, .open = stub_open }; /** - * Get a device minor number. + * Register. * - * \param pdev PCI device structure + * \param pdev - PCI device structure * \param ent entry from the PCI ID table with device type flags - * \return negative number on failure. + * \return zero on success or a negative number on failure. * - * Search an empty entry and initialize it to the given parameters, and - * create the proc init entry via proc_init(). + * Attempt to gets inter module "drm" information. If we are first + * then register the character device and inter module information. + * Try and register, if we fail to register, backout previous work. */ -static int get_minor(struct pci_dev *pdev, const struct pci_device_id *ent) +int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver_fn *driver_fn) { struct class_device *dev_class; drm_device_t *dev; int ret; int minor; - drm_minor_t *minors = &DRM(global)->minors[0]; + drm_minor_t *minors = &drm_minors[0]; DRM_DEBUG("\n"); - for (minor = 0; minor < DRM(global)->cards_limit; minor++, minors++) { + for (minor = 0; minor < cards_limit; minor++, minors++) { if (minors->class == DRM_MINOR_FREE) { DRM_DEBUG("assigning minor %d\n", minor); - dev = DRM(calloc)(1, sizeof(*dev), DRM_MEM_STUB); + dev = drm_calloc(1, sizeof(*dev), DRM_MEM_STUB); if(!dev) return -ENOMEM; *minors = (drm_minor_t){.dev = dev, .class = DRM_MINOR_PRIMARY}; dev->minor = minor; - if ((ret = DRM(fill_in_dev)(dev, pdev, ent))) { + if ((ret = drm_fill_in_dev(dev, pdev, ent, driver_fn))) { printk (KERN_ERR "DRM: Fill_in_dev failed.\n"); goto err_g1; } - if ((ret = DRM(proc_init)(dev, minor, DRM(global)->proc_root, &minors->dev_root))) { + if ((ret = drm_proc_init(dev, minor, drm_proc_root, &minors->dev_root))) { printk (KERN_ERR "DRM: Failed to initialize /proc/dri.\n"); goto err_g1; } - if (!DRM(fb_loaded)) { + if (!drm_fb_loaded) { pci_set_drvdata(pdev, dev); pci_request_regions(pdev, DRIVER_NAME); pci_enable_device(pdev); } - dev_class = DRM(sysfs_device_add)(DRM(global)->drm_class, + dev_class = drm_sysfs_device_add(drm_class, MKDEV(DRM_MAJOR, minor), DRM_PCI_DEV(pdev), "card%d", minor); if (IS_ERR(dev_class)) { printk (KERN_ERR "DRM: Error sysfs_device_add.\n"); @@ -148,17 +153,18 @@ static int get_minor(struct pci_dev *pdev, const struct pci_device_id *ent) DRM_ERROR("out of minors\n"); return -ENOMEM; err_g2: - if (!DRM(fb_loaded)) { + if (!drm_fb_loaded) { pci_set_drvdata(pdev, NULL); pci_release_regions(pdev); pci_disable_device(pdev); } - DRM(proc_cleanup)(minor, DRM(global)->proc_root, minors->dev_root); + drm_proc_cleanup(minor, drm_proc_root, minors->dev_root); err_g1: *minors = (drm_minor_t){.dev = NULL, .class = DRM_MINOR_FREE}; - DRM(free)(dev, sizeof(*dev), DRM_MEM_STUB); + drm_free(dev, sizeof(*dev), DRM_MEM_STUB); return ret; } +EXPORT_SYMBOL(drm_probe); /** * Get a secondary minor number. @@ -171,25 +177,25 @@ err_g1: * create the proc init entry via proc_init(). This routines assigns * minor numbers to secondary heads of multi-headed cards */ -int DRM(get_secondary_minor)(drm_device_t *dev, drm_minor_t **sec_minor) +int drm_get_secondary_minor(drm_device_t *dev, drm_minor_t **sec_minor) { - drm_minor_t *minors = &DRM(global)->minors[0]; + drm_minor_t *minors = &drm_minors[0]; struct class_device *dev_class; int ret; int minor; DRM_DEBUG("\n"); - for (minor = 0; minor < DRM(global)->cards_limit; minor++, minors++) { + for (minor = 0; minor < cards_limit; minor++, minors++) { if (minors->class == DRM_MINOR_FREE) { *minors = (drm_minor_t){.dev = dev, .class = DRM_MINOR_SECONDARY}; - if ((ret = DRM(proc_init)(dev, minor, DRM(global)->proc_root, &minors->dev_root))) { + if ((ret = drm_proc_init(dev, minor, drm_proc_root, &minors->dev_root))) { printk (KERN_ERR "DRM: Failed to initialize /proc/dri.\n"); goto err_g1; } - dev_class = DRM(sysfs_device_add)(DRM(global)->drm_class, + dev_class = drm_sysfs_device_add(drm_class, MKDEV(DRM_MAJOR, minor), DRM_PCI_DEV(dev->pdev), "card%d", minor); if (IS_ERR(dev_class)) { printk (KERN_ERR "DRM: Error sysfs_device_add.\n"); @@ -205,10 +211,10 @@ int DRM(get_secondary_minor)(drm_device_t *dev, drm_minor_t **sec_minor) DRM_ERROR("out of minors\n"); return -ENOMEM; err_g2: - DRM(proc_cleanup)(minor, DRM(global)->proc_root, minors->dev_root); + drm_proc_cleanup(minor, drm_proc_root, minors->dev_root); err_g1: *minors = (drm_minor_t){.dev = NULL, .class = DRM_MINOR_FREE}; - DRM(free)(dev, sizeof(*dev), DRM_MEM_STUB); + drm_free(dev, sizeof(*dev), DRM_MEM_STUB); return ret; } @@ -222,38 +228,17 @@ err_g1: * "drm" data, otherwise unregisters the "drm" data, frees the dev list and * unregisters the character device. */ -int DRM(put_minor)(drm_device_t *dev) +int drm_put_minor(drm_device_t *dev) { - drm_minor_t *minors = &DRM(global)->minors[dev->minor]; - int i; + drm_minor_t *minors = &drm_minors[dev->minor]; DRM_DEBUG("release primary minor %d\n", dev->minor); - DRM(proc_cleanup)(dev->minor, DRM(global)->proc_root, minors->dev_root); - DRM(sysfs_device_remove)(MKDEV(DRM_MAJOR, dev->minor)); + drm_proc_cleanup(dev->minor, drm_proc_root, minors->dev_root); + drm_sysfs_device_remove(MKDEV(DRM_MAJOR, dev->minor)); *minors = (drm_minor_t){.dev = NULL, .class = DRM_MINOR_FREE}; - DRM(free)(dev, sizeof(*dev), DRM_MEM_STUB); - - /* if any device pointers are non-NULL we are not the last module */ - for (i = 0; i < DRM(global)->cards_limit; i++) { - if (DRM(global)->minors[i].class != DRM_MINOR_FREE) { - DRM_DEBUG("inter_module_put called\n"); - inter_module_put("drm"); - return 0; - } - } - DRM_DEBUG("unregistering inter_module \n"); - inter_module_unregister("drm"); - remove_proc_entry("dri", NULL); - DRM(sysfs_destroy)(DRM(global)->drm_class); - - unregister_chrdev(DRM_MAJOR, "drm"); - - DRM(free)(DRM(global)->minors, sizeof(*DRM(global)->minors) * - DRM(global)->cards_limit, DRM_MEM_STUB); - DRM(free)(DRM(global), sizeof(*DRM(global)), DRM_MEM_STUB); - DRM(global) = NULL; + drm_free(dev, sizeof(*dev), DRM_MEM_STUB); return 0; } @@ -268,91 +253,17 @@ int DRM(put_minor)(drm_device_t *dev) * last minor released. * */ -int DRM(put_secondary_minor)(drm_minor_t *sec_minor) +int drm_put_secondary_minor(drm_minor_t *sec_minor) { - int minor = sec_minor - &DRM(global)->minors[0]; + int minor = sec_minor - &drm_minors[0]; DRM_DEBUG("release secondary minor %d\n", minor); - DRM(proc_cleanup)(minor, DRM(global)->proc_root, sec_minor->dev_root); - DRM(sysfs_device_remove)(MKDEV(DRM_MAJOR, minor)); + drm_proc_cleanup(minor, drm_proc_root, sec_minor->dev_root); + drm_sysfs_device_remove(MKDEV(DRM_MAJOR, minor)); *sec_minor = (drm_minor_t){.dev = NULL, .class = DRM_MINOR_FREE}; return 0; } -/** - * Register. - * - * \param pdev - PCI device structure - * \param ent entry from the PCI ID table with device type flags - * \return zero on success or a negative number on failure. - * - * Attempt to gets inter module "drm" information. If we are first - * then register the character device and inter module information. - * Try and register, if we fail to register, backout previous work. - */ -int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent) -{ - drm_global_t *global; - int ret = -ENOMEM; - - DRM_DEBUG("\n"); - - /* use the inter_module_get to check - as if the same module - registers chrdev twice it succeeds */ - global = (drm_global_t *)inter_module_get("drm"); - if (global) { - DRM(global) = global; - global = NULL; - } else { - DRM_DEBUG("first probe\n"); - - global = DRM(calloc)(1, sizeof(*global), DRM_MEM_STUB); - if(!global) - return -ENOMEM; - - global->cards_limit = (cards_limit < DRM_MAX_MINOR + 1 ? cards_limit : DRM_MAX_MINOR + 1); - global->minors = DRM(calloc)(global->cards_limit, - sizeof(*global->minors), DRM_MEM_STUB); - if(!global->minors) - goto err_p1; - - if (register_chrdev(DRM_MAJOR, "drm", &DRM(stub_fops))) - goto err_p1; - - global->drm_class = DRM(sysfs_create)(THIS_MODULE, "drm"); - if (IS_ERR(global->drm_class)) { - printk (KERN_ERR "DRM: Error creating drm class.\n"); - ret = PTR_ERR(global->drm_class); - goto err_p2; - } - - global->proc_root = create_proc_entry("dri", S_IFDIR, NULL); - if (!global->proc_root) { - DRM_ERROR("Cannot create /proc/dri\n"); - ret = -1; - goto err_p3; - } - DRM_DEBUG("calling inter_module_register\n"); - inter_module_register("drm", THIS_MODULE, global); - - DRM(global) = global; - } - if ((ret = get_minor(pdev, ent))) { - if (global) - goto err_p3; - return ret; - } - return 0; -err_p3: - DRM(sysfs_destroy)(global->drm_class); -err_p2: - unregister_chrdev(DRM_MAJOR, "drm"); - DRM(free)(global->minors, sizeof(*global->minors) * global->cards_limit, DRM_MEM_STUB); -err_p1: - DRM(free)(global, sizeof(*global), DRM_MEM_STUB); - DRM(global) = NULL; - return ret; -} diff --git a/linux-core/drm_sysfs.c b/linux-core/drm_sysfs.c index c6f6a7a9..f623341b 100644 --- a/linux-core/drm_sysfs.c +++ b/linux-core/drm_sysfs.c @@ -1,4 +1,3 @@ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) /* * drm_sysfs.c - Modifications to drm_sysfs_class.c to support * extra sysfs attribute from DRM. Normal drm_sysfs_class @@ -17,6 +16,8 @@ #include <linux/kdev_t.h> #include <linux/err.h> +#include "drm_core.h" + struct drm_sysfs_class { struct class_device_attribute attr; struct class class; @@ -54,23 +55,23 @@ static void drm_sysfs_class_release(struct class *class) /* Display the version of drm_core. This doesn't work right in current design */ static ssize_t version_show(struct class *dev, char *buf) { - return sprintf(buf, "fixme for drm_core %s %d.%d.%d %s\n", DRIVER_NAME, DRIVER_MAJOR, + return sprintf(buf, "%s %d.%d.%d %s\n", DRIVER_NAME, DRIVER_MAJOR, DRIVER_MINOR, DRIVER_PATCHLEVEL, DRIVER_DATE); } static CLASS_ATTR(version, S_IRUGO, version_show, NULL); /** - * DRM(sysfs_create) - create a struct drm_sysfs_class structure + * drm_sysfs_create - create a struct drm_sysfs_class structure * @owner: pointer to the module that is to "own" this struct drm_sysfs_class * @name: pointer to a string for the name of this class. * * This is used to create a struct drm_sysfs_class pointer that can then be used - * in calls to DRM(sysfs_device_add)(). + * in calls to drm_sysfs_device_add(). * * Note, the pointer created here is to be destroyed when finished by making a - * call to DRM(sysfs_destroy)(). + * call to drm_sysfs_destroy(). */ -struct drm_sysfs_class *DRM(sysfs_create)(struct module *owner, char *name) +struct drm_sysfs_class *drm_sysfs_create(struct module *owner, char *name) { struct drm_sysfs_class *cs; int retval; @@ -105,13 +106,13 @@ error: } /** - * DRM(sysfs_destroy) - destroys a struct drm_sysfs_class structure + * drm_sysfs_destroy - destroys a struct drm_sysfs_class structure * @cs: pointer to the struct drm_sysfs_class that is to be destroyed * * Note, the pointer to be destroyed must have been created with a call to - * DRM(sysfs_create)(). + * drm_sysfs_create(). */ -void DRM(sysfs_destroy)(struct drm_sysfs_class *cs) +void drm_sysfs_destroy(struct drm_sysfs_class *cs) { if ((cs == NULL) || (IS_ERR(cs))) return; @@ -120,7 +121,7 @@ void DRM(sysfs_destroy)(struct drm_sysfs_class *cs) } /** - * DRM(sysfs_device_add) - adds a class device to sysfs for a character driver + * drm_sysfs_device_add - adds a class device to sysfs for a character driver * @cs: pointer to the struct drm_sysfs_class that this device should be registered to. * @dev: the dev_t for the device to be added. * @device: a pointer to a struct device that is assiociated with this class device. @@ -131,9 +132,9 @@ void DRM(sysfs_destroy)(struct drm_sysfs_class *cs) * pointer to the struct class_device will be returned from the call. Any further * sysfs files that might be required can be created using this pointer. * Note: the struct drm_sysfs_class passed to this function must have previously been - * created with a call to DRM(sysfs_create)(). + * created with a call to drm_sysfs_create(). */ -struct class_device *DRM(sysfs_device_add)(struct drm_sysfs_class *cs, dev_t dev, struct device *device, const char *fmt, ...) +struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, dev_t dev, struct device *device, const char *fmt, ...) { va_list args; struct simple_dev *s_dev = NULL; @@ -176,13 +177,13 @@ error: } /** - * DRM(sysfs_device_remove) - removes a class device that was created with DRM(sysfs_device_add)() + * drm_sysfs_device_remove - removes a class device that was created with drm_sysfs_device_add() * @dev: the dev_t of the device that was previously registered. * * This call unregisters and cleans up a class device that was created with a - * call to DRM(sysfs_device_add)() + * call to drm_sysfs_device_add() */ -void DRM(sysfs_device_remove)(dev_t dev) +void drm_sysfs_device_remove(dev_t dev) { struct simple_dev *s_dev = NULL; int found = 0; @@ -203,4 +204,3 @@ void DRM(sysfs_device_remove)(dev_t dev) } } -#endif diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index 30b0e73e..0895a5bc 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -47,7 +47,7 @@ * map, get the page, increment the use count and return it. */ #if __OS_HAS_AGP -static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma, +static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, unsigned long address) { drm_file_t *priv = vma->vm_file->private_data; @@ -115,7 +115,7 @@ vm_nopage_error: return NOPAGE_SIGBUS; /* Disallow mremap */ } #else /* __OS_HAS_AGP */ -static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma, +static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma, unsigned long address) { return NOPAGE_SIGBUS; @@ -132,7 +132,7 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma, * Get the the mapping, find the real physical page to map, get the page, and * return it. */ -static __inline__ struct page *DRM(do_vm_shm_nopage)(struct vm_area_struct *vma, +static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma, unsigned long address) { drm_map_t *map = (drm_map_t *)vma->vm_private_data; @@ -163,7 +163,7 @@ static __inline__ struct page *DRM(do_vm_shm_nopage)(struct vm_area_struct *vma, * Deletes map information if we are the last * person to close a mapping and it's not in the global maplist. */ -void DRM(vm_shm_close)(struct vm_area_struct *vma) +void drm_vm_shm_close(struct vm_area_struct *vma) { drm_file_t *priv = vma->vm_file->private_data; drm_device_t *dev = priv->dev; @@ -189,7 +189,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma) } else { dev->vmalist = pt->next; } - DRM(free)(pt, sizeof(*pt), DRM_MEM_VMAS); + drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); } else { prev = pt; } @@ -218,7 +218,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma) map->size); DRM_DEBUG("mtrr_del = %d\n", retcode); } - DRM(ioremapfree)(map->handle, map->size, dev); + drm_ioremapfree(map->handle, map->size, dev); break; case _DRM_SHM: vfree(map->handle); @@ -227,7 +227,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma) case _DRM_SCATTER_GATHER: break; } - DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + drm_free(map, sizeof(*map), DRM_MEM_MAPS); } } up(&dev->struct_sem); @@ -242,7 +242,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma) * * Determine the page number from the page offset and get it from drm_device_dma::pagelist. */ -static __inline__ struct page *DRM(do_vm_dma_nopage)(struct vm_area_struct *vma, +static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma, unsigned long address) { drm_file_t *priv = vma->vm_file->private_data; @@ -276,7 +276,7 @@ static __inline__ struct page *DRM(do_vm_dma_nopage)(struct vm_area_struct *vma, * * Determine the map offset from the page offset and get it from drm_sg_mem::pagelist. */ -static __inline__ struct page *DRM(do_vm_sg_nopage)(struct vm_area_struct *vma, +static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma, unsigned long address) { drm_map_t *map = (drm_map_t *)vma->vm_private_data; @@ -305,89 +305,89 @@ static __inline__ struct page *DRM(do_vm_sg_nopage)(struct vm_area_struct *vma, #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) -static struct page *DRM(vm_nopage)(struct vm_area_struct *vma, +static struct page *drm_vm_nopage(struct vm_area_struct *vma, unsigned long address, int *type) { if (type) *type = VM_FAULT_MINOR; - return DRM(do_vm_nopage)(vma, address); + return drm_do_vm_nopage(vma, address); } -static struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma, +static struct page *drm_vm_shm_nopage(struct vm_area_struct *vma, unsigned long address, int *type) { if (type) *type = VM_FAULT_MINOR; - return DRM(do_vm_shm_nopage)(vma, address); + return drm_do_vm_shm_nopage(vma, address); } -static struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma, +static struct page *drm_vm_dma_nopage(struct vm_area_struct *vma, unsigned long address, int *type) { if (type) *type = VM_FAULT_MINOR; - return DRM(do_vm_dma_nopage)(vma, address); + return drm_do_vm_dma_nopage(vma, address); } -static struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma, +static struct page *drm_vm_sg_nopage(struct vm_area_struct *vma, unsigned long address, int *type) { if (type) *type = VM_FAULT_MINOR; - return DRM(do_vm_sg_nopage)(vma, address); + return drm_do_vm_sg_nopage(vma, address); } #else /* LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0) */ -static struct page *DRM(vm_nopage)(struct vm_area_struct *vma, +static struct page *drm_vm_nopage(struct vm_area_struct *vma, unsigned long address, int unused) { - return DRM(do_vm_nopage)(vma, address); + return drm_do_vm_nopage(vma, address); } -static struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma, +static struct page *drm_vm_shm_nopage(struct vm_area_struct *vma, unsigned long address, int unused) { - return DRM(do_vm_shm_nopage)(vma, address); + return drm_do_vm_shm_nopage(vma, address); } -static struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma, +static struct page *drm_vm_dma_nopage(struct vm_area_struct *vma, unsigned long address, int unused) { - return DRM(do_vm_dma_nopage)(vma, address); + return drm_do_vm_dma_nopage(vma, address); } -static struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma, +static struct page *drm_vm_sg_nopage(struct vm_area_struct *vma, unsigned long address, int unused) { - return DRM(do_vm_sg_nopage)(vma, address); + return drm_do_vm_sg_nopage(vma, address); } #endif /** AGP virtual memory operations */ -static struct vm_operations_struct DRM(vm_ops) = { - .nopage = DRM(vm_nopage), - .open = DRM(vm_open), - .close = DRM(vm_close), +static struct vm_operations_struct drm_vm_ops = { + .nopage = drm_vm_nopage, + .open = drm_vm_open, + .close = drm_vm_close, }; /** Shared virtual memory operations */ -static struct vm_operations_struct DRM(vm_shm_ops) = { - .nopage = DRM(vm_shm_nopage), - .open = DRM(vm_open), - .close = DRM(vm_shm_close), +static struct vm_operations_struct drm_vm_shm_ops = { + .nopage = drm_vm_shm_nopage, + .open = drm_vm_open, + .close = drm_vm_shm_close, }; /** DMA virtual memory operations */ -static struct vm_operations_struct DRM(vm_dma_ops) = { - .nopage = DRM(vm_dma_nopage), - .open = DRM(vm_open), - .close = DRM(vm_close), +static struct vm_operations_struct drm_vm_dma_ops = { + .nopage = drm_vm_dma_nopage, + .open = drm_vm_open, + .close = drm_vm_close, }; /** Scatter-gather virtual memory operations */ -static struct vm_operations_struct DRM(vm_sg_ops) = { - .nopage = DRM(vm_sg_nopage), - .open = DRM(vm_open), - .close = DRM(vm_close), +static struct vm_operations_struct drm_vm_sg_ops = { + .nopage = drm_vm_sg_nopage, + .open = drm_vm_open, + .close = drm_vm_close, }; @@ -399,7 +399,7 @@ static struct vm_operations_struct DRM(vm_sg_ops) = { * Create a new drm_vma_entry structure as the \p vma private data entry and * add it to drm_device::vmalist. */ -void DRM(vm_open)(struct vm_area_struct *vma) +void drm_vm_open(struct vm_area_struct *vma) { drm_file_t *priv = vma->vm_file->private_data; drm_device_t *dev = priv->dev; @@ -409,7 +409,7 @@ void DRM(vm_open)(struct vm_area_struct *vma) vma->vm_start, vma->vm_end - vma->vm_start); atomic_inc(&dev->vma_count); - vma_entry = DRM(alloc)(sizeof(*vma_entry), DRM_MEM_VMAS); + vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); if (vma_entry) { down(&dev->struct_sem); vma_entry->vma = vma; @@ -428,7 +428,7 @@ void DRM(vm_open)(struct vm_area_struct *vma) * Search the \p vma private data entry in drm_device::vmalist, unlink it, and * free it. */ -void DRM(vm_close)(struct vm_area_struct *vma) +void drm_vm_close(struct vm_area_struct *vma) { drm_file_t *priv = vma->vm_file->private_data; drm_device_t *dev = priv->dev; @@ -446,7 +446,7 @@ void DRM(vm_close)(struct vm_area_struct *vma) } else { dev->vmalist = pt->next; } - DRM(free)(pt, sizeof(*pt), DRM_MEM_VMAS); + drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); break; } } @@ -463,7 +463,7 @@ void DRM(vm_close)(struct vm_area_struct *vma) * Sets the virtual memory area operations structure to vm_dma_ops, the file * pointer, and calls vm_open(). */ -int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma) +int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma) { drm_file_t *priv = filp->private_data; drm_device_t *dev; @@ -483,7 +483,7 @@ int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma) } unlock_kernel(); - vma->vm_ops = &DRM(vm_dma_ops); + vma->vm_ops = &drm_vm_dma_ops; #if LINUX_VERSION_CODE <= 0x02040e /* KERNEL_VERSION(2,4,14) */ vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */ @@ -492,16 +492,17 @@ int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma) #endif vma->vm_file = filp; /* Needed for drm_vm_open() */ - DRM(vm_open)(vma); + drm_vm_open(vma); return 0; } -unsigned long DRM(core_get_map_ofs)(drm_map_t *map) +unsigned long drm_core_get_map_ofs(drm_map_t *map) { return map->offset; } +EXPORT_SYMBOL(drm_core_get_map_ofs); -unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev) +unsigned long drm_core_get_reg_ofs(struct drm_device *dev) { #ifdef __alpha__ return dev->hose->dense_mem_base - dev->hose->mem_space->start; @@ -509,6 +510,7 @@ unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev) return 0; #endif } +EXPORT_SYMBOL(drm_core_get_reg_ofs); /** * mmap DMA memory. @@ -523,7 +525,7 @@ unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev) * according to the mapping type and remaps the pages. Finally sets the file * pointer and calls vm_open(). */ -int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) +int drm_mmap(struct file *filp, struct vm_area_struct *vma) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; @@ -546,7 +548,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) && (!dev->agp || dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE) #endif ) - return DRM(mmap_dma)(filp, vma); + return drm_mmap_dma(filp, vma); /* A sequential search of a linked list is fine here because: 1) there will only be @@ -561,7 +563,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) r_list = list_entry(list, drm_map_list_t, head); map = r_list->map; if (!map) continue; - off = dev->fn_tbl.get_map_ofs(map); + off = dev->fn_tbl->get_map_ofs(map); if (off == VM_OFFSET(vma)) break; } @@ -595,7 +597,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) #if defined(__powerpc__) pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE; #endif - vma->vm_ops = &DRM(vm_ops); + vma->vm_ops = &drm_vm_ops; break; } /* fall through to _DRM_FRAME_BUFFER... */ @@ -616,7 +618,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) if (map->type != _DRM_AGP) vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); #endif - offset = dev->fn_tbl.get_reg_ofs(dev); + offset = dev->fn_tbl->get_reg_ofs(dev); #ifdef __sparc__ if (io_remap_page_range(DRM_RPR_ARG(vma) vma->vm_start, VM_OFFSET(vma) + offset, @@ -633,10 +635,10 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) " offset = 0x%lx\n", map->type, vma->vm_start, vma->vm_end, VM_OFFSET(vma) + offset); - vma->vm_ops = &DRM(vm_ops); + vma->vm_ops = &drm_vm_ops; break; case _DRM_SHM: - vma->vm_ops = &DRM(vm_shm_ops); + vma->vm_ops = &drm_vm_shm_ops; vma->vm_private_data = (void *)map; /* Don't let this area swap. Change when DRM_KERNEL advisory is supported. */ @@ -647,7 +649,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) #endif break; case _DRM_SCATTER_GATHER: - vma->vm_ops = &DRM(vm_sg_ops); + vma->vm_ops = &drm_vm_sg_ops; vma->vm_private_data = (void *)map; #if LINUX_VERSION_CODE <= 0x02040e /* KERNEL_VERSION(2,4,14) */ vma->vm_flags |= VM_LOCKED; @@ -665,6 +667,6 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) #endif vma->vm_file = filp; /* Needed for drm_vm_open() */ - DRM(vm_open)(vma); + drm_vm_open(vma); return 0; } diff --git a/linux-core/ffb_context.c b/linux-core/ffb_context.c index 718ae93f..b4ce2a09 100644 --- a/linux-core/ffb_context.c +++ b/linux-core/ffb_context.c @@ -587,12 +587,12 @@ static int ffb_driver_kernel_context_switch_unlock(struct drm_device *dev) wake_up_interruptible(&dev->lock.lock_queue); } -static unsigned long ffb_driver_get_map_ofs(drm_map_t *map) +unsigned long ffb_driver_get_map_ofs(drm_map_t *map) { return (map->offset & 0xffffffff); } -static unsigned long ffb_driver_get_reg_ofs(drm_device_t *dev) +unsigned long ffb_driver_get_reg_ofs(drm_device_t *dev) { ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *)dev->dev_private; @@ -601,16 +601,3 @@ static unsigned long ffb_driver_get_reg_ofs(drm_device_t *dev) return 0; } - -static void ffb_driver_register_fns(drm_device_t *dev) -{ - DRM(fops).get_unmapped_area = ffb_get_unmapped_area; - dev->fn_tbl.release = ffb_driver_release; - dev->fn_tbl.presetup = ffb_driver_presetup; - dev->fn_tbl.pretakedown = ffb_driver_pretakedown; - dev->fn_tbl.postcleanup = ffb_driver_postcleanup; - dev->fn_tbl.kernel_context_switch = ffb_context_switch; - dev->fn_tbl.kernel_context_switch_unlock = ffb_driver_kernel_context_switch_unlock; - dev->fn_tbl.get_map_ofs = ffb_driver_get_map_ofs; - dev->fn_tbl.get_reg_ofs = ffb_driver_get_reg_ofs; -} diff --git a/linux-core/ffb_drv.c b/linux-core/ffb_drv.c index 1d78cbda..15a79738 100644 --- a/linux-core/ffb_drv.c +++ b/linux-core/ffb_drv.c @@ -237,9 +237,7 @@ unsigned long ffb_get_unmapped_area(struct file *filp, return addr; } -#include "drm_core.h" - -/* This functions must be here since it references DRM(numdevs) +/* This functions must be here since it references drm_numdevs) * which drm_drv.h declares. */ int ffb_presetup(drm_device_t *dev) @@ -254,13 +252,13 @@ int ffb_presetup(drm_device_t *dev) return -ENODEV; /* Find our instance number by finding our device in dev structure */ - for (i = 0; i < DRM(numdevs); i++) { - temp_dev = &(DRM(device)[i]); + for (i = 0; i < drm_numdevs; i++) { + temp_dev = &(drm_device[i]); if(temp_dev == dev) break; } - if (i == DRM(numdevs)) + if (i == drm_numdevs) return -ENODEV; ffb_priv = kmalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL); @@ -276,3 +274,80 @@ int ffb_presetup(drm_device_t *dev) return ret; } +#include "drm_pciids.h" + +static int postinit( struct drm_device *dev, unsigned long flags ) +{ + DRM(fops).get_unmapped_area = ffb_get_unmapped_area; + + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(pdev) + ); + return 0; +} + +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + ffb_PCI_IDS +}; + +static struct drm_driver_fn ffb_driver_fn = { + .release = ffb_driver_release, + .presetup = ffb_driver_presetup, + .pretakedown = ffb_driver_pretakedown, + .postcleanup = ffb_driver_postcleanup, + .kernel_context_switch = ffb_context_switch, + .kernel_context_switch_unlock = ffb_driver_kernel_context_switch_unlock, + .get_map_ofs = ffb_driver_get_map_ofs, + .get_reg_ofs = ffb_driver_get_reg_ofs, + .reclaim_buffers = drm_core_reclaim_buffers, + .postinit = postinit, + .version = version, +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init ffb_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit ffb_exit(void) +{ + drm_exit(&driver); +} + +drm_module_init(ffb_init); +drm_module_exit(ffb_exit)); + +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); diff --git a/linux-core/ffb_drv.h b/linux-core/ffb_drv.h index 3948c08a..54384524 100644 --- a/linux-core/ffb_drv.h +++ b/linux-core/ffb_drv.h @@ -281,3 +281,5 @@ extern unsigned long ffb_get_unmapped_area(struct file *filp, unsigned long len, unsigned long pgoff, unsigned long flags); +extern unsigned long ffb_driver_get_map_ofs(drm_map_t *map) +extern unsigned long ffb_driver_get_reg_ofs(drm_device_t *dev) diff --git a/linux-core/i810_dma.c b/linux-core/i810_dma.c index 5d2165c6..56632aed 100644 --- a/linux-core/i810_dma.c +++ b/linux-core/i810_dma.c @@ -30,7 +30,6 @@ * */ -#include "i810.h" #include "drmP.h" #include "drm.h" #include "i810_drm.h" @@ -111,12 +110,12 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf) } static struct file_operations i810_buffer_fops = { - .open = DRM(open), - .flush = DRM(flush), - .release = DRM(release), - .ioctl = DRM(ioctl), + .open = drm_open, + .flush = drm_flush, + .release = drm_release, + .ioctl = drm_ioctl, .mmap = i810_mmap_buffers, - .fasync = DRM(fasync), + .fasync = drm_fasync, }; int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma) @@ -238,7 +237,7 @@ int i810_dma_cleanup(drm_device_t *dev) * is freed, it's too late. */ if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ) && dev->irq_enabled) - DRM(irq_uninstall)(dev); + drm_irq_uninstall(dev); if (dev->dev_private) { int i; @@ -246,7 +245,7 @@ int i810_dma_cleanup(drm_device_t *dev) (drm_i810_private_t *) dev->dev_private; if (dev_priv->ring.virtual_start) { - DRM(ioremapfree)((void *) dev_priv->ring.virtual_start, + drm_ioremapfree((void *) dev_priv->ring.virtual_start, dev_priv->ring.Size, dev); } if (dev_priv->hw_status_page) { @@ -256,7 +255,7 @@ int i810_dma_cleanup(drm_device_t *dev) /* Need to rewrite hardware status page */ I810_WRITE(0x02080, 0x1ffff000); } - DRM(free)(dev->dev_private, sizeof(drm_i810_private_t), + drm_free(dev->dev_private, sizeof(drm_i810_private_t), DRM_MEM_DRIVER); dev->dev_private = NULL; @@ -264,7 +263,7 @@ int i810_dma_cleanup(drm_device_t *dev) drm_buf_t *buf = dma->buflist[ i ]; drm_i810_buf_priv_t *buf_priv = buf->dev_private; if ( buf_priv->kernel_virtual && buf->total ) - DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total, dev); + drm_ioremapfree(buf_priv->kernel_virtual, buf->total, dev); } } return 0; @@ -335,7 +334,7 @@ static int i810_freelist_init(drm_device_t *dev, drm_i810_private_t *dev_priv) *buf_priv->in_use = I810_BUF_FREE; - buf_priv->kernel_virtual = DRM(ioremap)(buf->bus_address, + buf_priv->kernel_virtual = drm_ioremap(buf->bus_address, buf->total, dev); } return 0; @@ -387,7 +386,7 @@ static int i810_dma_initialize(drm_device_t *dev, dev_priv->ring.End = init->ring_end; dev_priv->ring.Size = init->ring_size; - dev_priv->ring.virtual_start = DRM(ioremap)(dev->agp->base + + dev_priv->ring.virtual_start = drm_ioremap(dev->agp->base + init->ring_start, init->ring_size, dev); @@ -511,7 +510,7 @@ int i810_dma_init(struct inode *inode, struct file *filp, if (retcode) return retcode; - dev_priv = DRM(alloc)(sizeof(drm_i810_private_t), + dev_priv = drm_alloc(sizeof(drm_i810_private_t), DRM_MEM_DRIVER); if (dev_priv == NULL) return -ENOMEM; @@ -525,7 +524,7 @@ int i810_dma_init(struct inode *inode, struct file *filp, sizeof(drm_i810_init_t))) { return -EFAULT; } - dev_priv = DRM(alloc)(sizeof(drm_i810_private_t), + dev_priv = drm_alloc(sizeof(drm_i810_private_t), DRM_MEM_DRIVER); if (dev_priv == NULL) return -ENOMEM; @@ -1388,36 +1387,18 @@ int i810_flip_bufs(struct inode *inode, struct file *filp, return 0; } -static void i810_driver_pretakedown(drm_device_t *dev) +void i810_driver_pretakedown(drm_device_t *dev) { i810_dma_cleanup( dev ); } -static void i810_driver_release(drm_device_t *dev, struct file *filp) +void i810_driver_release(drm_device_t *dev, struct file *filp) { i810_reclaim_buffers(filp); } -static int i810_driver_dma_quiescent(drm_device_t *dev) +int i810_driver_dma_quiescent(drm_device_t *dev) { i810_dma_quiescent( dev ); return 0; } - -void i810_driver_register_fns(drm_device_t *dev) -{ - dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE; - dev->dev_priv_size = sizeof(drm_i810_buf_priv_t); - dev->fn_tbl.pretakedown = i810_driver_pretakedown; - dev->fn_tbl.release = i810_driver_release; - dev->fn_tbl.dma_quiescent = i810_driver_dma_quiescent; - dev->fn_tbl.reclaim_buffers = i810_reclaim_buffers; - - /* i810 has 4 more counters */ - dev->counters += 4; - dev->types[6] = _DRM_STAT_IRQ; - dev->types[7] = _DRM_STAT_PRIMARY; - dev->types[8] = _DRM_STAT_SECONDARY; - dev->types[9] = _DRM_STAT_DMA; -} - diff --git a/linux-core/i810_drm.h b/linux-core/i810_drm.h index 93775f68..95703f3d 100644 --- a/linux-core/i810_drm.h +++ b/linux-core/i810_drm.h @@ -204,21 +204,37 @@ typedef struct _drm_i810_sarea { /* i810 specific ioctls * The device specific ioctl range is 0x40 to 0x79. */ -#define DRM_IOCTL_I810_INIT DRM_IOW( 0x40, drm_i810_init_t) -#define DRM_IOCTL_I810_VERTEX DRM_IOW( 0x41, drm_i810_vertex_t) -#define DRM_IOCTL_I810_CLEAR DRM_IOW( 0x42, drm_i810_clear_t) -#define DRM_IOCTL_I810_FLUSH DRM_IO( 0x43) -#define DRM_IOCTL_I810_GETAGE DRM_IO( 0x44) -#define DRM_IOCTL_I810_GETBUF DRM_IOWR(0x45, drm_i810_dma_t) -#define DRM_IOCTL_I810_SWAP DRM_IO( 0x46) -#define DRM_IOCTL_I810_COPY DRM_IOW( 0x47, drm_i810_copy_t) -#define DRM_IOCTL_I810_DOCOPY DRM_IO( 0x48) -#define DRM_IOCTL_I810_OV0INFO DRM_IOR( 0x49, drm_i810_overlay_t) -#define DRM_IOCTL_I810_FSTATUS DRM_IO ( 0x4a) -#define DRM_IOCTL_I810_OV0FLIP DRM_IO ( 0x4b) -#define DRM_IOCTL_I810_MC DRM_IOW( 0x4c, drm_i810_mc_t) -#define DRM_IOCTL_I810_RSTATUS DRM_IO ( 0x4d ) -#define DRM_IOCTL_I810_FLIP DRM_IO ( 0x4e ) +#define DRM_I810_INIT 0x00 +#define DRM_I810_VERTEX 0x01 +#define DRM_I810_CLEAR 0x02 +#define DRM_I810_FLUSH 0x03 +#define DRM_I810_GETAGE 0x04 +#define DRM_I810_GETBUF 0x05 +#define DRM_I810_SWAP 0x06 +#define DRM_I810_COPY 0x07 +#define DRM_I810_DOCOPY 0x08 +#define DRM_I810_OV0INFO 0x09 +#define DRM_I810_FSTATUS 0x0a +#define DRM_I810_OV0FLIP 0x0b +#define DRM_I810_MC 0x0c +#define DRM_I810_RSTATUS 0x0d +#define DRM_I810_FLIP 0x0e + +#define DRM_IOCTL_I810_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I810_INIT, drm_i810_init_t) +#define DRM_IOCTL_I810_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_I810_VERTEX, drm_i810_vertex_t) +#define DRM_IOCTL_I810_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_I810_CLEAR, drm_i810_clear_t) +#define DRM_IOCTL_I810_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_I810_FLUSH) +#define DRM_IOCTL_I810_GETAGE DRM_IO( DRM_COMMAND_BASE + DRM_I810_GETAGE) +#define DRM_IOCTL_I810_GETBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_I810_GETBUF, drm_i810_dma_t) +#define DRM_IOCTL_I810_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_I810_SWAP) +#define DRM_IOCTL_I810_COPY DRM_IOW( DRM_COMMAND_BASE + DRM_I810_COPY, drm_i810_copy_t) +#define DRM_IOCTL_I810_DOCOPY DRM_IO( DRM_COMMAND_BASE + DRM_I810_DOCOPY) +#define DRM_IOCTL_I810_OV0INFO DRM_IOR( DRM_COMMAND_BASE + DRM_I810_OV0INFO, drm_i810_overlay_t) +#define DRM_IOCTL_I810_FSTATUS DRM_IO ( DRM_COMMAND_BASE + DRM_I810_FSTATUS) +#define DRM_IOCTL_I810_OV0FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I810_OV0FLIP) +#define DRM_IOCTL_I810_MC DRM_IOW( DRM_COMMAND_BASE + DRM_I810_MC, drm_i810_mc_t) +#define DRM_IOCTL_I810_RSTATUS DRM_IO ( DRM_COMMAND_BASE + DRM_I810_RSTATUS) +#define DRM_IOCTL_I810_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I810_FLIP) typedef struct _drm_i810_clear { int clear_color; diff --git a/linux-core/i810_drv.c b/linux-core/i810_drv.c index 00ca5516..60b3177e 100644 --- a/linux-core/i810_drv.c +++ b/linux-core/i810_drv.c @@ -31,10 +31,109 @@ */ #include <linux/config.h> -#include "i810.h" #include "drmP.h" #include "drm.h" #include "i810_drm.h" #include "i810_drv.h" -#include "drm_core.h" +#include "drm_pciids.h" + +static int postinit( struct drm_device *dev, unsigned long flags ) +{ + /* i810 has 4 more counters */ + dev->counters += 4; + dev->types[6] = _DRM_STAT_IRQ; + dev->types[7] = _DRM_STAT_PRIMARY; + dev->types[8] = _DRM_STAT_SECONDARY; + dev->types[9] = _DRM_STAT_DMA; + + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(dev->pdev) + ); + return 0; +} + +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + i810_PCI_IDS +}; + +static drm_ioctl_desc_t ioctls[] = { + [DRM_IOCTL_NR(DRM_I810_INIT)] = { i810_dma_init, 1, 1 }, + [DRM_IOCTL_NR(DRM_I810_VERTEX)] = { i810_dma_vertex, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_CLEAR)] = { i810_clear_bufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_FLUSH)] = { i810_flush_ioctl, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_GETAGE)] = { i810_getage, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_GETBUF)] = { i810_getbuf, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_SWAP)] = { i810_swap_bufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_COPY)] = { i810_copybuf, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_DOCOPY)] = { i810_docopy, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_OV0INFO)] = { i810_ov0_info, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_FSTATUS)] = { i810_fstatus, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_OV0FLIP)] = { i810_ov0_flip, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_MC)] = { i810_dma_mc, 1, 1 }, + [DRM_IOCTL_NR(DRM_I810_RSTATUS)] = { i810_rstatus, 1, 0 }, + [DRM_IOCTL_NR(DRM_I810_FLIP)] = { i810_flip_bufs, 1, 0 } +}; + +static struct drm_driver_fn driver_fn = { + .driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE, + .dev_priv_size = sizeof(drm_i810_buf_priv_t), + .pretakedown = i810_driver_pretakedown, + .release = i810_driver_release, + .dma_quiescent = i810_driver_dma_quiescent, + .reclaim_buffers = i810_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .postinit = postinit, + .version = version, + .ioctls = ioctls, + .num_ioctls = DRM_ARRAY_SIZE(ioctls), +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init i810_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit i810_exit(void) +{ + drm_exit(&driver); +} + +module_init(i810_init); +module_exit(i810_exit); + +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); diff --git a/linux-core/i810_drv.h b/linux-core/i810_drv.h index 67c5c88b..d867429d 100644 --- a/linux-core/i810_drv.h +++ b/linux-core/i810_drv.h @@ -32,6 +32,29 @@ #ifndef _I810_DRV_H_ #define _I810_DRV_H_ +/* General customization: + */ + +#define DRIVER_AUTHOR "VA Linux Systems Inc." + +#define DRIVER_NAME "i810" +#define DRIVER_DESC "Intel i810" +#define DRIVER_DATE "20030605" + +/* Interface history + * + * 1.1 - XFree86 4.1 + * 1.2 - XvMC interfaces + * - XFree86 4.2 + * 1.2.1 - Disable copying code (leave stub ioctls for backwards compatibility) + * - Remove requirement for interrupt (leave stubs again) + * 1.3 - Add page flipping. + * 1.4 - fix DRM interface + */ +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 4 +#define DRIVER_PATCHLEVEL 0 + typedef struct drm_i810_buf_priv { u32 *in_use; int my_use_idx; @@ -127,18 +150,22 @@ extern int i810_dma_mc(struct inode *inode, struct file *filp, extern void i810_dma_quiescent(drm_device_t *dev); -int i810_dma_vertex(struct inode *inode, struct file *filp, +extern int i810_dma_vertex(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -int i810_swap_bufs(struct inode *inode, struct file *filp, +extern int i810_swap_bufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -int i810_clear_bufs(struct inode *inode, struct file *filp, +extern int i810_clear_bufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -int i810_flip_bufs(struct inode *inode, struct file *filp, +extern int i810_flip_bufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); +extern int i810_driver_dma_quiescent(drm_device_t *dev); +extern void i810_driver_release(drm_device_t *dev, struct file *filp); +extern void i810_driver_pretakedown(drm_device_t *dev); + #define I810_BASE(reg) ((unsigned long) \ dev_priv->mmio_map->handle) #define I810_ADDR(reg) (I810_BASE(reg) + reg) diff --git a/linux-core/i830_dma.c b/linux-core/i830_dma.c index 1ce2a357..9f2c22e2 100644 --- a/linux-core/i830_dma.c +++ b/linux-core/i830_dma.c @@ -31,7 +31,6 @@ * */ -#include "i830.h" #include "drmP.h" #include "drm.h" #include "i830_drm.h" @@ -112,12 +111,12 @@ static int i830_freelist_put(drm_device_t *dev, drm_buf_t *buf) } static struct file_operations i830_buffer_fops = { - .open = DRM(open), - .flush = DRM(flush), - .release = DRM(release), - .ioctl = DRM(ioctl), + .open = drm_open, + .flush = drm_flush, + .release = drm_release, + .ioctl = drm_ioctl, .mmap = i830_mmap_buffers, - .fasync = DRM(fasync), + .fasync = drm_fasync, }; int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma) @@ -238,7 +237,7 @@ int i830_dma_cleanup(drm_device_t *dev) * may not have been called from userspace and after dev_private * is freed, it's too late. */ - if (dev->irq_enabled) DRM(irq_uninstall)(dev); + if (dev->irq_enabled) drm_irq_uninstall(dev); if (dev->dev_private) { int i; @@ -246,7 +245,7 @@ int i830_dma_cleanup(drm_device_t *dev) (drm_i830_private_t *) dev->dev_private; if (dev_priv->ring.virtual_start) { - DRM(ioremapfree)((void *) dev_priv->ring.virtual_start, + drm_ioremapfree((void *) dev_priv->ring.virtual_start, dev_priv->ring.Size, dev); } if (dev_priv->hw_status_page) { @@ -257,7 +256,7 @@ int i830_dma_cleanup(drm_device_t *dev) I830_WRITE(0x02080, 0x1ffff000); } - DRM(free)(dev->dev_private, sizeof(drm_i830_private_t), + drm_free(dev->dev_private, sizeof(drm_i830_private_t), DRM_MEM_DRIVER); dev->dev_private = NULL; @@ -265,7 +264,7 @@ int i830_dma_cleanup(drm_device_t *dev) drm_buf_t *buf = dma->buflist[ i ]; drm_i830_buf_priv_t *buf_priv = buf->dev_private; if ( buf_priv->kernel_virtual && buf->total ) - DRM(ioremapfree)(buf_priv->kernel_virtual, buf->total, dev); + drm_ioremapfree(buf_priv->kernel_virtual, buf->total, dev); } } return 0; @@ -340,7 +339,7 @@ static int i830_freelist_init(drm_device_t *dev, drm_i830_private_t *dev_priv) *buf_priv->in_use = I830_BUF_FREE; - buf_priv->kernel_virtual = DRM(ioremap)(buf->bus_address, + buf_priv->kernel_virtual = drm_ioremap(buf->bus_address, buf->total, dev); } return 0; @@ -393,7 +392,7 @@ static int i830_dma_initialize(drm_device_t *dev, dev_priv->ring.End = init->ring_end; dev_priv->ring.Size = init->ring_size; - dev_priv->ring.virtual_start = DRM(ioremap)(dev->agp->base + + dev_priv->ring.virtual_start = drm_ioremap(dev->agp->base + init->ring_start, init->ring_size, dev); @@ -476,7 +475,7 @@ int i830_dma_init(struct inode *inode, struct file *filp, switch(init.func) { case I830_INIT_DMA: - dev_priv = DRM(alloc)(sizeof(drm_i830_private_t), + dev_priv = drm_alloc(sizeof(drm_i830_private_t), DRM_MEM_DRIVER); if(dev_priv == NULL) return -ENOMEM; retcode = i830_dma_initialize(dev, dev_priv, &init); @@ -1583,43 +1582,19 @@ int i830_setparam( struct inode *inode, struct file *filp, unsigned int cmd, } -static void i830_driver_pretakedown(drm_device_t *dev) +void i830_driver_pretakedown(drm_device_t *dev) { i830_dma_cleanup( dev ); } -static void i830_driver_release(drm_device_t *dev, struct file *filp) +void i830_driver_release(drm_device_t *dev, struct file *filp) { i830_reclaim_buffers(filp); } -static int i830_driver_dma_quiescent(drm_device_t *dev) +int i830_driver_dma_quiescent(drm_device_t *dev) { i830_dma_quiescent( dev ); return 0; } -void i830_driver_register_fns(drm_device_t *dev) -{ - dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE; -#if USE_IRQS - dev->driver_features |= DRIVER_HAVE_IRQ | DRIVER_SHARED_IRQ; -#endif - dev->dev_priv_size = sizeof(drm_i830_buf_priv_t); - dev->fn_tbl.pretakedown = i830_driver_pretakedown; - dev->fn_tbl.release = i830_driver_release; - dev->fn_tbl.dma_quiescent = i830_driver_dma_quiescent; - dev->fn_tbl.reclaim_buffers = i830_reclaim_buffers; -#if USE_IRQS - dev->fn_tbl.irq_preinstall = i830_driver_irq_preinstall; - dev->fn_tbl.irq_postinstall = i830_driver_irq_postinstall; - dev->fn_tbl.irq_uninstall = i830_driver_irq_uninstall; - dev->fn_tbl.irq_handler = i830_driver_irq_handler; -#endif - dev->counters += 4; - dev->types[6] = _DRM_STAT_IRQ; - dev->types[7] = _DRM_STAT_PRIMARY; - dev->types[8] = _DRM_STAT_SECONDARY; - dev->types[9] = _DRM_STAT_DMA; -} - diff --git a/linux-core/i830_drm.h b/linux-core/i830_drm.h index 1bd45994..03382c0b 100644 --- a/linux-core/i830_drm.h +++ b/linux-core/i830_drm.h @@ -251,20 +251,35 @@ typedef struct _drm_i830_sarea { /* I830 specific ioctls * The device specific ioctl range is 0x40 to 0x79. */ -#define DRM_IOCTL_I830_INIT DRM_IOW( 0x40, drm_i830_init_t) -#define DRM_IOCTL_I830_VERTEX DRM_IOW( 0x41, drm_i830_vertex_t) -#define DRM_IOCTL_I830_CLEAR DRM_IOW( 0x42, drm_i830_clear_t) -#define DRM_IOCTL_I830_FLUSH DRM_IO ( 0x43) -#define DRM_IOCTL_I830_GETAGE DRM_IO ( 0x44) -#define DRM_IOCTL_I830_GETBUF DRM_IOWR(0x45, drm_i830_dma_t) -#define DRM_IOCTL_I830_SWAP DRM_IO ( 0x46) -#define DRM_IOCTL_I830_COPY DRM_IOW( 0x47, drm_i830_copy_t) -#define DRM_IOCTL_I830_DOCOPY DRM_IO ( 0x48) -#define DRM_IOCTL_I830_FLIP DRM_IO ( 0x49) -#define DRM_IOCTL_I830_IRQ_EMIT DRM_IOWR(0x4a, drm_i830_irq_emit_t) -#define DRM_IOCTL_I830_IRQ_WAIT DRM_IOW( 0x4b, drm_i830_irq_wait_t) -#define DRM_IOCTL_I830_GETPARAM DRM_IOWR(0x4c, drm_i830_getparam_t) -#define DRM_IOCTL_I830_SETPARAM DRM_IOWR(0x4d, drm_i830_setparam_t) +#define DRM_I830_INIT 0x00 +#define DRM_I830_VERTEX 0x01 +#define DRM_I830_CLEAR 0x02 +#define DRM_I830_FLUSH 0x03 +#define DRM_I830_GETAGE 0x04 +#define DRM_I830_GETBUF 0x05 +#define DRM_I830_SWAP 0x06 +#define DRM_I830_COPY 0x07 +#define DRM_I830_DOCOPY 0x08 +#define DRM_I830_FLIP 0x09 +#define DRM_I830_IRQ_EMIT 0x0a +#define DRM_I830_IRQ_WAIT 0x0b +#define DRM_I830_GETPARAM 0x0c +#define DRM_I830_SETPARAM 0x0d + +#define DRM_IOCTL_I830_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_INIT, drm_i830_init_t) +#define DRM_IOCTL_I830_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_VERTEX, drm_i830_vertex_t) +#define DRM_IOCTL_I830_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_CLEAR, drm_i830_clear_t) +#define DRM_IOCTL_I830_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_FLUSH) +#define DRM_IOCTL_I830_GETAGE DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_GETAGE) +#define DRM_IOCTL_I830_GETBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_GETBUF, drm_i830_dma_t) +#define DRM_IOCTL_I830_SWAP DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_SWAP) +#define DRM_IOCTL_I830_COPY DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_COPY, drm_i830_copy_t) +#define DRM_IOCTL_I830_DOCOPY DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_DOCOPY) +#define DRM_IOCTL_I830_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_IOCTL_I830_FLIP) +#define DRM_IOCTL_I830_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_IRQ_EMIT, drm_i830_irq_emit_t) +#define DRM_IOCTL_I830_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_IOCTL_I830_IRQ_WAIT, drm_i830_irq_wait_t) +#define DRM_IOCTL_I830_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_GETPARAM, drm_i830_getparam_t) +#define DRM_IOCTL_I830_SETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_IOCTL_I830_SETPARAM, drm_i830_setparam_t) typedef struct _drm_i830_clear { int clear_color; diff --git a/linux-core/i830_drv.c b/linux-core/i830_drv.c index eb45b272..b2aacc61 100644 --- a/linux-core/i830_drv.c +++ b/linux-core/i830_drv.c @@ -33,10 +33,116 @@ */ #include <linux/config.h> -#include "i830.h" #include "drmP.h" #include "drm.h" #include "i830_drm.h" #include "i830_drv.h" -#include "drm_core.h" +#include "drm_pciids.h" + +int postinit( struct drm_device *dev, unsigned long flags ) +{ + dev->counters += 4; + dev->types[6] = _DRM_STAT_IRQ; + dev->types[7] = _DRM_STAT_PRIMARY; + dev->types[8] = _DRM_STAT_SECONDARY; + dev->types[9] = _DRM_STAT_DMA; + + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(dev->pdev) + ); + return 0; +} + +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + i830_PCI_IDS +}; + +static drm_ioctl_desc_t ioctls[] = { + [DRM_IOCTL_NR(DRM_I830_INIT)] = { i830_dma_init, 1, 1 }, + [DRM_IOCTL_NR(DRM_I830_VERTEX)] = { i830_dma_vertex, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_CLEAR)] = { i830_clear_bufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_FLUSH)] = { i830_flush_ioctl, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_GETAGE)] = { i830_getage, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_GETBUF)] = { i830_getbuf, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_SWAP)] = { i830_swap_bufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_COPY)] = { i830_copybuf, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_DOCOPY)] = { i830_docopy, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_FLIP)] = { i830_flip_bufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_IRQ_EMIT)] = { i830_irq_emit, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_IRQ_WAIT)] = { i830_irq_wait, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_GETPARAM)] = { i830_getparam, 1, 0 }, + [DRM_IOCTL_NR(DRM_I830_SETPARAM)] = { i830_setparam, 1, 0 } +}; + +static struct drm_driver_fn driver_fn = { + .driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE, +#if USE_IRQS + .driver_features |= DRIVER_HAVE_IRQ | DRIVER_SHARED_IRQ, +#endif + .dev_priv_size = sizeof(drm_i830_buf_priv_t), + .pretakedown = i830_driver_pretakedown, + .release = i830_driver_release, + .dma_quiescent = i830_driver_dma_quiescent, + .reclaim_buffers = i830_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, +#if USE_IRQS + .irq_preinstall = i830_driver_irq_preinstall, + .irq_postinstall = i830_driver_irq_postinstall, + .irq_uninstall = i830_driver_irq_uninstall, + .irq_handler = i830_driver_irq_handler, +#endif + .postinit = postinit, + .version = version, + .ioctls = ioctls, + .num_ioctls = DRM_ARRAY_SIZE(ioctls), +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init i830_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit i830_exit(void) +{ + drm_exit(&driver); +} + +module_init(i830_init); +module_exit(i830_exit); + +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); diff --git a/linux-core/i830_drv.h b/linux-core/i830_drv.h index c3cab2d8..c2832cf8 100644 --- a/linux-core/i830_drv.h +++ b/linux-core/i830_drv.h @@ -32,6 +32,36 @@ #ifndef _I830_DRV_H_ #define _I830_DRV_H_ +/* General customization: + */ + +#define DRIVER_AUTHOR "VA Linux Systems Inc." + +#define DRIVER_NAME "i830" +#define DRIVER_DESC "Intel 830M" +#define DRIVER_DATE "20021108" + +/* Interface history: + * + * 1.1: Original. + * 1.2: ? + * 1.3: New irq emit/wait ioctls. + * New pageflip ioctl. + * New getparam ioctl. + * State for texunits 3&4 in sarea. + * New (alternative) layout for texture state. + */ +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 3 +#define DRIVER_PATCHLEVEL 2 + +/* Driver will work either way: IRQ's save cpu time when waiting for + * the card, but are subject to subtle interactions between bios, + * hardware and the driver. + */ +/* XXX: Add vblank support? */ +#define USE_IRQS 0 + typedef struct drm_i830_buf_priv { u32 *in_use; int my_use_idx; @@ -140,6 +170,9 @@ extern irqreturn_t i830_driver_irq_handler( DRM_IRQ_ARGS ); extern void i830_driver_irq_preinstall( drm_device_t *dev ); extern void i830_driver_irq_postinstall( drm_device_t *dev ); extern void i830_driver_irq_uninstall( drm_device_t *dev ); +extern void i830_driver_pretakedown(drm_device_t *dev); +extern void i830_driver_release(drm_device_t *dev, struct file *filp); +extern int i830_driver_dma_quiescent(drm_device_t *dev); #define I830_BASE(reg) ((unsigned long) \ dev_priv->mmio_map->handle) diff --git a/linux-core/i830_irq.c b/linux-core/i830_irq.c index 0f01d088..19f4fd51 100644 --- a/linux-core/i830_irq.c +++ b/linux-core/i830_irq.c @@ -26,7 +26,6 @@ * */ -#include "i830.h" #include "drmP.h" #include "drm.h" #include "i830_drm.h" diff --git a/linux-core/i915_drv.c b/linux-core/i915_drv.c index becce4d7..464a44de 100644 --- a/linux-core/i915_drv.c +++ b/linux-core/i915_drv.c @@ -8,10 +8,108 @@ * **************************************************************************/ -#include "i915.h" #include "drmP.h" #include "drm.h" #include "i915_drm.h" #include "i915_drv.h" -#include "drm_core.h" +#include "drm_pciids.h" + +int postinit( struct drm_device *dev, unsigned long flags ) +{ + dev->counters += 4; + dev->types[6] = _DRM_STAT_IRQ; + dev->types[7] = _DRM_STAT_PRIMARY; + dev->types[8] = _DRM_STAT_SECONDARY; + dev->types[9] = _DRM_STAT_DMA; + + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(dev->pdev) + ); + return 0; +} + +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + i915_PCI_IDS +}; + +static drm_ioctl_desc_t ioctls[] = { + [DRM_IOCTL_NR(DRM_I915_INIT)] = { i915_dma_init, 1, 1 }, + [DRM_IOCTL_NR(DRM_I915_FLUSH)] = { i915_flush_ioctl, 1, 0 }, + [DRM_IOCTL_NR(DRM_I915_FLIP)] = { i915_flip_bufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_I915_BATCHBUFFER)] = { i915_batchbuffer, 1, 0 }, + [DRM_IOCTL_NR(DRM_I915_IRQ_EMIT)] = { i915_irq_emit, 1, 0 }, + [DRM_IOCTL_NR(DRM_I915_IRQ_WAIT)] = { i915_irq_wait, 1, 0 }, + [DRM_IOCTL_NR(DRM_I915_GETPARAM)] = { i915_getparam, 1, 0 }, + [DRM_IOCTL_NR(DRM_I915_SETPARAM)] = { i915_setparam, 1, 1 }, + [DRM_IOCTL_NR(DRM_I915_ALLOC)] = { i915_mem_alloc, 1, 0 }, + [DRM_IOCTL_NR(DRM_I915_FREE)] = { i915_mem_free, 1, 0 }, + [DRM_IOCTL_NR(DRM_I915_INIT_HEAP)] = { i915_mem_init_heap, 1, 1 }, + [DRM_IOCTL_NR(DRM_I915_CMDBUFFER)] = { i915_cmdbuffer, 1, 0 } +}; + +static struct drm_driver_fn driver_fn = { + .driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | + DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, + .pretakedown = i915_driver_pretakedown, + .prerelease = i915_driver_prerelease, + .irq_preinstall = i915_driver_irq_preinstall, + .irq_postinstall = i915_driver_irq_postinstall, + .irq_uninstall = i915_driver_irq_uninstall, + .irq_handler = i915_driver_irq_handler, + .reclaim_buffers = drm_core_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .postinit = postinit, + .version = version, + .ioctls = ioctls, + .num_ioctls = DRM_ARRAY_SIZE(ioctls), +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init i915_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit i915_exit(void) +{ + drm_exit(&driver); +} + +module_init(i915_init); +module_exit(i915_exit); + +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); diff --git a/linux-core/mach64_drv.c b/linux-core/mach64_drv.c index 05170abc..fb9b6b94 100644 --- a/linux-core/mach64_drv.c +++ b/linux-core/mach64_drv.c @@ -28,10 +28,104 @@ */ #include <linux/config.h> -#include "mach64.h" #include "drmP.h" #include "drm.h" #include "mach64_drm.h" #include "mach64_drv.h" -#include "drm_core.h" +#include "drm_pciids.h" + +static int postinit( struct drm_device *dev, unsigned long flags ) +{ + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(dev->pdev) + ); + return 0; +} + +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + mach64_PCI_IDS +}; + +/* Interface history: + * + * 1.0 - Initial mach64 DRM + * + */ +static drm_ioctl_desc_t ioctls[] = { + [DRM_IOCTL_NR(DRM_MACH64_INIT)] = { mach64_dma_init, 1, 1 }, + [DRM_IOCTL_NR(DRM_MACH64_CLEAR)] = { mach64_dma_clear, 1, 0 }, + [DRM_IOCTL_NR(DRM_MACH64_SWAP)] = { mach64_dma_swap, 1, 0 }, + [DRM_IOCTL_NR(DRM_MACH64_IDLE)] = { mach64_dma_idle, 1, 0 }, + [DRM_IOCTL_NR(DRM_MACH64_RESET)] = { mach64_engine_reset, 1, 0 }, + [DRM_IOCTL_NR(DRM_MACH64_VERTEX)] = { mach64_dma_vertex, 1, 0 }, + [DRM_IOCTL_NR(DRM_MACH64_BLIT)] = { mach64_dma_blit, 1, 0 }, + [DRM_IOCTL_NR(DRM_MACH64_FLUSH)] = { mach64_dma_flush, 1, 0 }, + [DRM_IOCTL_NR(DRM_MACH64_GETPARAM)] = { mach64_get_param, 1, 0 }, +}; + +static struct drm_driver_fn driver_fn = { + .driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL, + .pretakedown = mach64_driver_pretakedown, + .vblank_wait = mach64_driver_vblank_wait, + .irq_preinstall = mach64_driver_irq_preinstall, + .irq_postinstall = mach64_driver_irq_postinstall, + .irq_uninstall = mach64_driver_irq_uninstall, + .irq_handler = mach64_driver_irq_handler, + .reclaim_buffers = drm_core_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .postinit = postinit, + .version = version, + .ioctls = ioctls, + .num_ioctls = DRM_ARRAY_SIZE(ioctls), + .dma_ioctl = mach64_dma_buffers, +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init mach64_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit mach64_exit(void) +{ + drm_exit(&driver); +} + +module_init(mach64_init); +module_exit(mach64_exit); + +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); diff --git a/linux-core/mga_drv.c b/linux-core/mga_drv.c index 54bfb2d3..7371bb8c 100644 --- a/linux-core/mga_drv.c +++ b/linux-core/mga_drv.c @@ -30,10 +30,106 @@ */ #include <linux/config.h> -#include "mga.h" #include "drmP.h" #include "drm.h" #include "mga_drm.h" #include "mga_drv.h" -#include "drm_core.h" +#include "drm_pciids.h" + +static int postinit( struct drm_device *dev, unsigned long flags ) +{ + dev->counters += 3; + dev->types[6] = _DRM_STAT_IRQ; + dev->types[7] = _DRM_STAT_PRIMARY; + dev->types[8] = _DRM_STAT_SECONDARY; + + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(dev->pdev) + ); + return 0; +} + +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + mga_PCI_IDS +}; + +static drm_ioctl_desc_t ioctls[] = { + [DRM_IOCTL_NR(DRM_MGA_INIT)] = { mga_dma_init, 1, 1 }, + [DRM_IOCTL_NR(DRM_MGA_FLUSH)] = { mga_dma_flush, 1, 0 }, + [DRM_IOCTL_NR(DRM_MGA_RESET)] = { mga_dma_reset, 1, 0 }, + [DRM_IOCTL_NR(DRM_MGA_SWAP)] = { mga_dma_swap, 1, 0 }, + [DRM_IOCTL_NR(DRM_MGA_CLEAR)] = { mga_dma_clear, 1, 0 }, + [DRM_IOCTL_NR(DRM_MGA_VERTEX)] = { mga_dma_vertex, 1, 0 }, + [DRM_IOCTL_NR(DRM_MGA_INDICES)] = { mga_dma_indices, 1, 0 }, + [DRM_IOCTL_NR(DRM_MGA_ILOAD)] = { mga_dma_iload, 1, 0 }, + [DRM_IOCTL_NR(DRM_MGA_BLIT)] = { mga_dma_blit, 1, 0 }, + [DRM_IOCTL_NR(DRM_MGA_GETPARAM)]= { mga_getparam, 1, 0 }, +}; + +static struct drm_driver_fn driver_fn = { + .driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL, + .pretakedown = mga_driver_pretakedown, + .dma_quiescent = mga_driver_dma_quiescent, + .vblank_wait = mga_driver_vblank_wait, + .irq_preinstall = mga_driver_irq_preinstall, + .irq_postinstall = mga_driver_irq_postinstall, + .irq_uninstall = mga_driver_irq_uninstall, + .irq_handler = mga_driver_irq_handler, + .reclaim_buffers = drm_core_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .postinit = postinit, + .version = version, + .ioctls = ioctls, + .num_ioctls = DRM_ARRAY_SIZE(ioctls), + .dma_ioctl = mga_dma_buffers, +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init mga_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit mga_exit(void) +{ + drm_exit(&driver); +} + +module_init(mga_init); +module_exit(mga_exit); + +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); diff --git a/linux-core/r128_drv.c b/linux-core/r128_drv.c index 8cfc9966..cdf6ea72 100644 --- a/linux-core/r128_drv.c +++ b/linux-core/r128_drv.c @@ -30,11 +30,116 @@ */ #include <linux/config.h> -#include "r128.h" #include "drmP.h" #include "drm.h" #include "r128_drm.h" #include "r128_drv.h" #include "ati_pcigart.h" -#include "drm_core.h" +#include "drm_pciids.h" + +static int postinit( struct drm_device *dev, unsigned long flags ) +{ + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(dev->pdev) + ); + return 0; +} + +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + r128_PCI_IDS +}; + +/* Interface history: + * + * ?? - ?? + * 2.4 - Add support for ycbcr textures (no new ioctls) + * 2.5 - Add FLIP ioctl, disable FULLSCREEN. + */ +static drm_ioctl_desc_t ioctls[] = { + [DRM_IOCTL_NR(DRM_R128_INIT)] = { r128_cce_init, 1, 1 }, + [DRM_IOCTL_NR(DRM_R128_CCE_START)] = { r128_cce_start, 1, 1 }, + [DRM_IOCTL_NR(DRM_R128_CCE_STOP)] = { r128_cce_stop, 1, 1 }, + [DRM_IOCTL_NR(DRM_R128_CCE_RESET)] = { r128_cce_reset, 1, 1 }, + [DRM_IOCTL_NR(DRM_R128_CCE_IDLE)] = { r128_cce_idle, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_RESET)] = { r128_engine_reset, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_FULLSCREEN)] = { r128_fullscreen, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_SWAP)] = { r128_cce_swap, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_FLIP)] = { r128_cce_flip, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_CLEAR)] = { r128_cce_clear, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_VERTEX)] = { r128_cce_vertex, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_INDICES)] = { r128_cce_indices, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_BLIT)] = { r128_cce_blit, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_DEPTH)] = { r128_cce_depth, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_STIPPLE)] = { r128_cce_stipple, 1, 0 }, + [DRM_IOCTL_NR(DRM_R128_INDIRECT)] = { r128_cce_indirect, 1, 1 }, + [DRM_IOCTL_NR(DRM_R128_GETPARAM)] = { r128_getparam, 1, 0 }, +}; + +static struct drm_driver_fn driver_fn = { + .driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL, + .dev_priv_size = sizeof(drm_r128_buf_priv_t), + .prerelease = r128_driver_prerelease, + .pretakedown = r128_driver_pretakedown, + .vblank_wait = r128_driver_vblank_wait, + .irq_preinstall = r128_driver_irq_preinstall, + .irq_postinstall = r128_driver_irq_postinstall, + .irq_uninstall = r128_driver_irq_uninstall, + .irq_handler = r128_driver_irq_handler, + .reclaim_buffers = drm_core_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .postinit = postinit, + .version = version, + .ioctls = ioctls, + .num_ioctls = DRM_ARRAY_SIZE(ioctls), + .dma_ioctl = r128_cce_buffers, +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init r128_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit r128_exit(void) +{ + drm_exit(&driver); +} + +module_init(r128_init); +module_exit(r128_exit); + +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); diff --git a/linux-core/radeon_drv.c b/linux-core/radeon_drv.c index 965abc44..e73d1744 100644 --- a/linux-core/radeon_drv.c +++ b/linux-core/radeon_drv.c @@ -31,11 +31,156 @@ #include <linux/config.h> -#include "radeon.h" #include "drmP.h" #include "drm.h" #include "radeon_drm.h" #include "radeon_drv.h" #include "ati_pcigart.h" -#include "drm_core.h" +#include "drm_pciids.h" + +static int postinit( struct drm_device *dev, unsigned long flags ) +{ + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(dev->pdev) + ); + return 0; +} + +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + radeon_PCI_IDS +}; + +/* Interface history: + * + * 1.1 - ?? + * 1.2 - Add vertex2 ioctl (keith) + * - Add stencil capability to clear ioctl (gareth, keith) + * - Increase MAX_TEXTURE_LEVELS (brian) + * 1.3 - Add cmdbuf ioctl (keith) + * - Add support for new radeon packets (keith) + * - Add getparam ioctl (keith) + * - Add flip-buffers ioctl, deprecate fullscreen foo (keith). + * 1.4 - Add scratch registers to get_param ioctl. + * 1.5 - Add r200 packets to cmdbuf ioctl + * - Add r200 function to init ioctl + * - Add 'scalar2' instruction to cmdbuf + * 1.6 - Add static GART memory manager + * Add irq handler (won't be turned on unless X server knows to) + * Add irq ioctls and irq_active getparam. + * Add wait command for cmdbuf ioctl + * Add GART offset query for getparam + * 1.7 - Add support for cube map registers: R200_PP_CUBIC_FACES_[0..5] + * and R200_PP_CUBIC_OFFSET_F1_[0..5]. + * Added packets R200_EMIT_PP_CUBIC_FACES_[0..5] and + * R200_EMIT_PP_CUBIC_OFFSETS_[0..5]. (brian) + * 1.8 - Remove need to call cleanup ioctls on last client exit (keith) + * Add 'GET' queries for starting additional clients on different VT's. + * 1.9 - Add DRM_IOCTL_RADEON_CP_RESUME ioctl. + * Add texture rectangle support for r100. + * 1.10- Add SETPARAM ioctl; first parameter to set is FB_LOCATION, which + * clients use to tell the DRM where they think the framebuffer is + * located in the card's address space + * 1.11- Add packet R200_EMIT_RB3D_BLENDCOLOR to support GL_EXT_blend_color + * and GL_EXT_blend_[func|equation]_separate on r200 + */ +static drm_ioctl_desc_t ioctls[] = { + [DRM_IOCTL_NR(DRM_RADEON_CP_INIT)] = { radeon_cp_init, 1, 1 }, + [DRM_IOCTL_NR(DRM_RADEON_CP_START)] = { radeon_cp_start, 1, 1 }, + [DRM_IOCTL_NR(DRM_RADEON_CP_STOP)] = { radeon_cp_stop, 1, 1 }, + [DRM_IOCTL_NR(DRM_RADEON_CP_RESET)] = { radeon_cp_reset, 1, 1 }, + [DRM_IOCTL_NR(DRM_RADEON_CP_IDLE)] = { radeon_cp_idle, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_CP_RESUME)] = { radeon_cp_resume, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_RESET)] = { radeon_engine_reset, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_FULLSCREEN)] = { radeon_fullscreen, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_SWAP)] = { radeon_cp_swap, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_CLEAR)] = { radeon_cp_clear, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_VERTEX)] = { radeon_cp_vertex, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_INDICES)] = { radeon_cp_indices, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_TEXTURE)] = { radeon_cp_texture, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_STIPPLE)] = { radeon_cp_stipple, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_INDIRECT)] = { radeon_cp_indirect, 1, 1 }, + [DRM_IOCTL_NR(DRM_RADEON_VERTEX2)] = { radeon_cp_vertex2, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_CMDBUF)] = { radeon_cp_cmdbuf, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_GETPARAM)] = { radeon_cp_getparam, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_FLIP)] = { radeon_cp_flip, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_ALLOC)] = { radeon_mem_alloc, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_FREE)] = { radeon_mem_free, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_INIT_HEAP)] = { radeon_mem_init_heap,1, 1 }, + [DRM_IOCTL_NR(DRM_RADEON_IRQ_EMIT)] = { radeon_irq_emit, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_IRQ_WAIT)] = { radeon_irq_wait, 1, 0 }, + [DRM_IOCTL_NR(DRM_RADEON_SETPARAM)] = { radeon_cp_setparam, 1, 0 }, +}; + +static struct drm_driver_fn driver_fn = { + .driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL, + .dev_priv_size = sizeof(drm_radeon_buf_priv_t), + .preinit = radeon_preinit, + .postinit = radeon_postinit, + .postcleanup = radeon_postcleanup, + .prerelease = radeon_driver_prerelease, + .pretakedown = radeon_driver_pretakedown, + .open_helper = radeon_driver_open_helper, + .vblank_wait = radeon_driver_vblank_wait, + .irq_preinstall = radeon_driver_irq_preinstall, + .irq_postinstall = radeon_driver_irq_postinstall, + .irq_uninstall = radeon_driver_irq_uninstall, + .irq_handler = radeon_driver_irq_handler, + .free_filp_priv = radeon_driver_free_filp_priv, + .reclaim_buffers = drm_core_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .postinit = postinit, + .version = version, + .ioctls = ioctls, + .num_ioctls = DRM_ARRAY_SIZE(ioctls), + .dma_ioctl = radeon_cp_buffers, +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init radeon_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit radeon_exit(void) +{ + drm_exit(&driver); +} + +module_init(radeon_init); +module_exit(radeon_exit); + +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); diff --git a/linux-core/radeon_i2c.c b/linux-core/radeon_i2c.c index e2591723..5073884c 100644 --- a/linux-core/radeon_i2c.c +++ b/linux-core/radeon_i2c.c @@ -26,7 +26,6 @@ #include <asm/io.h> #include <video/radeon.h> -#include "radeon.h" #include "drmP.h" #include "drm.h" #include "radeon_drm.h" diff --git a/linux-core/savage_dma.c b/linux-core/savage_dma.c index 581d4302..401fd942 100644 --- a/linux-core/savage_dma.c +++ b/linux-core/savage_dma.c @@ -24,7 +24,6 @@ /*=========================================================*/ -#include "savage.h" #include "drmP.h" #include "savage_drm.h" #include "savage_drv.h" @@ -35,13 +34,13 @@ #define SAVAGE_DEFAULT_USEC_TIMEOUT 10000 #define SAVAGE_FREELIST_DEBUG 0 -static int savage_preinit( drm_device_t *dev, unsigned long chipset ) +int savage_preinit( drm_device_t *dev, unsigned long chipset ) { drm_savage_private_t *dev_priv; unsigned mmioBase, fbBase, fbSize, apertureBase; int ret = 0; - dev_priv = DRM(alloc)( sizeof(drm_savage_private_t), DRM_MEM_DRIVER ); + dev_priv = drm_alloc( sizeof(drm_savage_private_t), DRM_MEM_DRIVER ); if ( dev_priv == NULL ) return DRM_ERR(ENOMEM); @@ -66,23 +65,17 @@ static int savage_preinit( drm_device_t *dev, unsigned long chipset ) apertureBase = pci_resource_start( dev->pdev, 2 ); } - if( (ret = DRM(initmap)( dev, mmioBase, SAVAGE_MMIO_SIZE, + if( (ret = drm_initmap( dev, mmioBase, SAVAGE_MMIO_SIZE, _DRM_REGISTERS, 0 ))) return ret; - if( (ret = DRM(initmap)( dev, fbBase, fbSize, + if( (ret = drm_initmap( dev, fbBase, fbSize, _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING ))) return ret; - if( (ret = DRM(initmap)( dev, apertureBase, SAVAGE_APERTURE_SIZE, + if( (ret = drm_initmap( dev, apertureBase, SAVAGE_APERTURE_SIZE, _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING ))) return ret; return ret; } - -void DRM(driver_register_fns)(drm_device_t *dev) -{ - dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR; - dev->fn_tbl.preinit = savage_preinit; -} diff --git a/linux-core/savage_drv.c b/linux-core/savage_drv.c index 0c518874..6304ae20 100644 --- a/linux-core/savage_drv.c +++ b/linux-core/savage_drv.c @@ -23,7 +23,6 @@ */ #include <linux/config.h> -#include "savage.h" #include "drmP.h" #include "savage_drm.h" #include "savage_drv.h" @@ -44,14 +43,6 @@ #if SAVAGE_CMD_DMA /* Check the 3D driver, and we need to fix this anyway */ -#define DRIVER_IOCTLS \ - [DRM_IOCTL_NR(DRM_IOCTL_SAVAGE_ALLOC_CONTINUOUS_MEM)] \ - = {savage_alloc_continuous_mem,1,0},\ - [DRM_IOCTL_NR( DRM_IOCTL_SAVAGE_GET_PHYSICS_ADDRESS)] \ - = {savage_get_physics_address,1,0},\ - [DRM_IOCTL_NR(DRM_IOCTL_SAVAGE_FREE_CONTINUOUS_MEM)] \ - = {savage_free_cont_mem,1,0} - int savage_alloc_continuous_mem(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { @@ -71,7 +62,7 @@ int savage_alloc_continuous_mem(struct inode *inode, struct file *filp, if (copy_from_user(&cont_mem,(drm_savage_alloc_cont_mem_t *)arg,sizeof(cont_mem))) return -EFAULT; - map = DRM(alloc)( sizeof(*map), DRM_MEM_MAPS ); + map = savage_alloc)( sizeof(*map), DRM_MEM_MAPS ); if ( !map ) return -ENOMEM; @@ -119,9 +110,9 @@ int savage_alloc_continuous_mem(struct inode *inode, struct file *filp, map->mtrr=-1; /*map-flags,type??*/ - list = DRM(alloc)(sizeof(*list), DRM_MEM_MAPS); + list = savage_alloc)(sizeof(*list), DRM_MEM_MAPS); if(!list) { - DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + savage_free)(map, sizeof(*map), DRM_MEM_MAPS); return -EINVAL; } memset(list, 0, sizeof(*list)); @@ -215,7 +206,7 @@ int savage_free_cont_mem(struct inode *inode, struct file *filp, } map = r_list->map; list_del(list); - DRM(free)(list, sizeof(*list), DRM_MEM_MAPS); + savage_free)(list, sizeof(*list), DRM_MEM_MAPS); /*unmap the user space */ #ifdef DO_MUNMAP_4_ARGS @@ -250,6 +241,84 @@ int savage_free_cont_mem(struct inode *inode, struct file *filp, #endif /* end #if 0 */ -#include "drm_core.h" +#include "drm_pciids.h" + +static int postinit( struct drm_device *dev, unsigned long flags ) +{ + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(dev->pdev) + ); + return 0; +} + +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + savage_PCI_IDS +}; + +static drm_ioctl_desc_t ioctls[] = { +#if SAVAGE_CMD_DMA /* Check the 3D driver, and we need to fix this anyway */ + [DRM_IOCTL_NR(DRM_SAVAGE_ALLOC_CONTINUOUS_MEM)] = {savage_alloc_continuous_mem, 1, 0}, + [DRM_IOCTL_NR(DRM_SAVAGE_GET_PHYSICS_ADDRESS)] = {savage_get_physics_address, 1, 0}, + [DRM_IOCTL_NR(DRM_SAVAGE_FREE_CONTINUOUS_MEM)] = {savage_free_cont_mem, 1, 0}, +#endif +}; + +static struct drm_driver_fn driver_fn = { + .driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR, + .reclaim_buffers = drm_core_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .preinit = savage_preinit, + .postinit = postinit, + .version = version, + .ioctls = ioctls, + .num_ioctls = DRM_ARRAY_SIZE(ioctls), +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init savage_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit savage_exit(void) +{ + drm_exit(&driver); +} +module_init(savage_init); +module_exit(savage_exit); +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); diff --git a/linux-core/savage_drv.h b/linux-core/savage_drv.h index 755ed2e9..4931d74a 100644 --- a/linux-core/savage_drv.h +++ b/linux-core/savage_drv.h @@ -38,6 +38,8 @@ enum savage_family { S3_LAST }; +extern int savage_preinit( drm_device_t *dev, unsigned long chipset ); + #define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX)) #define S3_SAVAGE4_SERIES(chip) ((chip==S3_SAVAGE4) \ diff --git a/linux-core/sis_drv.c b/linux-core/sis_drv.c index 90e01cdc..79a0d079 100644 --- a/linux-core/sis_drv.c +++ b/linux-core/sis_drv.c @@ -26,10 +26,90 @@ */ #include <linux/config.h> -#include "sis.h" #include "drmP.h" #include "sis_drm.h" #include "sis_drv.h" -#include "drm_core.h" +#include "drm_pciids.h" +static int postinit( struct drm_device *dev, unsigned long flags ) +{ + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(dev->pdev) + ); + return 0; +} + +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + sisdrv_PCI_IDS +}; + +static drm_ioctl_desc_t ioctls[] = { + [DRM_IOCTL_NR(DRM_SIS_FB_ALLOC)] = { sis_fb_alloc, 1, 0 }, + [DRM_IOCTL_NR(DRM_SIS_FB_FREE)] = { sis_fb_free, 1, 0 }, + [DRM_IOCTL_NR(DRM_SIS_AGP_INIT)] = { sis_ioctl_agp_init, 1, 1 }, + [DRM_IOCTL_NR(DRM_SIS_AGP_ALLOC)] = { sis_ioctl_agp_alloc, 1, 0 }, + [DRM_IOCTL_NR(DRM_SIS_AGP_FREE)] = { sis_ioctl_agp_free, 1, 0 }, + [DRM_IOCTL_NR(DRM_SIS_FB_INIT)] = { sis_fb_init, 1, 1 } +}; + +static struct drm_driver_fn driver_fn = { + .driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR, + .context_ctor = sis_init_context, + .context_dtor = sis_final_context, + .reclaim_buffers = drm_core_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .postinit = postinit, + .version = version, + .ioctls = ioctls, + .num_ioctls = DRM_ARRAY_SIZE(ioctls), +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init sis_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit sis_exit(void) +{ + drm_exit(&driver); +} + +module_init(sis_init); +module_exit(sis_exit); + +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); diff --git a/linux-core/tdfx_drv.c b/linux-core/tdfx_drv.c index d1314443..7ea192ca 100644 --- a/linux-core/tdfx_drv.c +++ b/linux-core/tdfx_drv.c @@ -31,13 +31,76 @@ */ #include <linux/config.h> -#include "tdfx.h" #include "drmP.h" +#include "tdfx_drv.h" -#include "drm_core.h" +#include "drm_pciids.h" -void DRM(driver_register_fns)(drm_device_t *dev) +static int postinit( struct drm_device *dev, unsigned long flags ) { - dev->driver_features = DRIVER_USE_MTRR; + DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d: %s\n", + DRIVER_NAME, + DRIVER_MAJOR, + DRIVER_MINOR, + DRIVER_PATCHLEVEL, + DRIVER_DATE, + dev->minor, + pci_pretty_name(dev->pdev) + ); + return 0; } +static int version( drm_version_t *version ) +{ + int len; + + version->version_major = DRIVER_MAJOR; + version->version_minor = DRIVER_MINOR; + version->version_patchlevel = DRIVER_PATCHLEVEL; + DRM_COPY( version->name, DRIVER_NAME ); + DRM_COPY( version->date, DRIVER_DATE ); + DRM_COPY( version->desc, DRIVER_DESC ); + return 0; +} + +static struct pci_device_id pciidlist[] = { + tdfx_PCI_IDS +}; + +static struct drm_driver_fn driver_fn = { + .driver_features = DRIVER_USE_MTRR, + .reclaim_buffers = drm_core_reclaim_buffers, + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .postinit = postinit, + .version = version, +}; + +static int probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + return drm_probe(pdev, ent, &driver_fn); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = pciidlist, + .probe = probe, + .remove = __devexit_p(drm_cleanup_pci), +}; + +static int __init tdfx_init(void) +{ + return drm_init(&driver, pciidlist, &driver_fn); +} + +static void __exit tdfx_exit(void) +{ + drm_exit(&driver); +} + +module_init(tdfx_init); +module_exit(tdfx_exit); + +MODULE_AUTHOR( DRIVER_AUTHOR ); +MODULE_DESCRIPTION( DRIVER_DESC ); +MODULE_LICENSE("GPL and additional rights"); |