summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux-core/Makefile65
-rw-r--r--linux-core/Makefile.kernel73
-rw-r--r--linux-core/ati_pcigart.c16
-rw-r--r--linux-core/drmP.h318
-rw-r--r--linux-core/drm_agpsupport.c62
-rw-r--r--linux-core/drm_auth.c30
-rw-r--r--linux-core/drm_bufs.c157
-rw-r--r--linux-core/drm_context.c64
-rw-r--r--linux-core/drm_core.h31
-rw-r--r--linux-core/drm_dma.c27
-rw-r--r--linux-core/drm_drawable.c4
-rw-r--r--linux-core/drm_drv.c526
-rw-r--r--linux-core/drm_fops.c22
-rw-r--r--linux-core/drm_init.c15
-rw-r--r--linux-core/drm_ioctl.c32
-rw-r--r--linux-core/drm_irq.c38
-rw-r--r--linux-core/drm_lock.c10
-rw-r--r--linux-core/drm_memory.h160
-rw-r--r--linux-core/drm_pci.c48
-rw-r--r--linux-core/drm_proc.c76
-rw-r--r--linux-core/drm_scatter.c36
-rw-r--r--linux-core/drm_stub.c177
-rw-r--r--linux-core/drm_sysfs.c32
-rw-r--r--linux-core/drm_vm.c120
-rw-r--r--linux-core/ffb_context.c17
-rw-r--r--linux-core/ffb_drv.c87
-rw-r--r--linux-core/ffb_drv.h2
-rw-r--r--linux-core/i810_dma.c51
-rw-r--r--linux-core/i810_drm.h46
-rw-r--r--linux-core/i810_drv.c103
-rw-r--r--linux-core/i810_drv.h35
-rw-r--r--linux-core/i830_dma.c55
-rw-r--r--linux-core/i830_drm.h43
-rw-r--r--linux-core/i830_drv.c110
-rw-r--r--linux-core/i830_drv.h33
-rw-r--r--linux-core/i830_irq.c1
-rw-r--r--linux-core/i915_drv.c102
-rw-r--r--linux-core/mach64_drv.c98
-rw-r--r--linux-core/mga_drv.c100
-rw-r--r--linux-core/r128_drv.c109
-rw-r--r--linux-core/radeon_drv.c149
-rw-r--r--linux-core/radeon_i2c.c1
-rw-r--r--linux-core/savage_dma.c17
-rw-r--r--linux-core/savage_drv.c97
-rw-r--r--linux-core/savage_drv.h2
-rw-r--r--linux-core/sis_drv.c84
-rw-r--r--linux-core/tdfx_drv.c71
-rw-r--r--shared-core/i915_dma.c34
-rw-r--r--shared-core/i915_drm.h37
-rw-r--r--shared-core/i915_drv.h24
-rw-r--r--shared-core/i915_irq.c1
-rw-r--r--shared-core/i915_mem.c21
-rw-r--r--shared-core/mach64_dma.c48
-rw-r--r--shared-core/mach64_drv.h15
-rw-r--r--shared-core/mach64_irq.c3
-rw-r--r--shared-core/mach64_state.c3
-rw-r--r--shared-core/mga_dma.c34
-rw-r--r--shared-core/mga_drv.h15
-rw-r--r--shared-core/mga_irq.c3
-rw-r--r--shared-core/mga_state.c1
-rw-r--r--shared-core/mga_warp.c1
-rw-r--r--shared-core/r128_cce.c17
-rw-r--r--shared-core/r128_drv.h17
-rw-r--r--shared-core/r128_irq.c3
-rw-r--r--shared-core/r128_state.c102
-rw-r--r--shared-core/radeon_cp.c22
-rw-r--r--shared-core/radeon_drv.h18
-rw-r--r--shared-core/radeon_irq.c11
-rw-r--r--shared-core/radeon_mem.c21
-rw-r--r--shared-core/radeon_state.c32
-rw-r--r--shared-core/sis_drm.h21
-rw-r--r--shared-core/sis_drv.h11
-rw-r--r--shared-core/sis_ds.c17
-rw-r--r--shared-core/sis_mm.c12
-rw-r--r--shared-core/via_dma.c1
-rw-r--r--shared-core/via_drm.h32
-rw-r--r--shared-core/via_drv.c102
-rw-r--r--shared-core/via_ds.c16
-rw-r--r--shared-core/via_ds.h1
-rw-r--r--shared-core/via_irq.c3
-rw-r--r--shared-core/via_map.c5
-rw-r--r--shared-core/via_mm.c53
-rw-r--r--shared/i915_dma.c34
-rw-r--r--shared/i915_drm.h37
-rw-r--r--shared/i915_drv.h24
-rw-r--r--shared/i915_irq.c1
-rw-r--r--shared/i915_mem.c21
-rw-r--r--shared/mach64_dma.c48
-rw-r--r--shared/mach64_drv.h15
-rw-r--r--shared/mach64_irq.c3
-rw-r--r--shared/mach64_state.c3
-rw-r--r--shared/mga_dma.c34
-rw-r--r--shared/mga_drv.h15
-rw-r--r--shared/mga_irq.c3
-rw-r--r--shared/mga_state.c1
-rw-r--r--shared/mga_warp.c1
-rw-r--r--shared/r128_cce.c17
-rw-r--r--shared/r128_drv.h17
-rw-r--r--shared/r128_irq.c3
-rw-r--r--shared/r128_state.c102
-rw-r--r--shared/radeon_cp.c22
-rw-r--r--shared/radeon_drv.h18
-rw-r--r--shared/radeon_irq.c11
-rw-r--r--shared/radeon_mem.c21
-rw-r--r--shared/radeon_state.c32
-rw-r--r--shared/sis_drm.h21
-rw-r--r--shared/sis_drv.h11
-rw-r--r--shared/sis_ds.c17
-rw-r--r--shared/sis_mm.c12
-rw-r--r--shared/via_dma.c1
-rw-r--r--shared/via_drm.h32
-rw-r--r--shared/via_drv.c102
-rw-r--r--shared/via_ds.c16
-rw-r--r--shared/via_ds.h1
-rw-r--r--shared/via_irq.c3
-rw-r--r--shared/via_map.c5
-rw-r--r--shared/via_mm.c53
117 files changed, 3005 insertions, 2061 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");
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index cf0333f6..1b91c60a 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -7,7 +7,6 @@
*
**************************************************************************/
-#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
@@ -84,7 +83,7 @@ int i915_dma_cleanup(drm_device_t * dev)
* is freed, it's too late.
*/
if (dev->irq)
- DRM(irq_uninstall) (dev);
+ drm_irq_uninstall (dev);
if (dev->dev_private) {
drm_i915_private_t *dev_priv =
@@ -98,7 +97,7 @@ int i915_dma_cleanup(drm_device_t * dev)
#ifdef __FreeBSD__
#if __FreeBSD_version > 500000
contigfree(dev_priv->hw_status_page, PAGE_SIZE,
- DRM(M_DRM));
+ drm_M_DRM);
#endif
#else
pci_free_consistent(dev->pdev, PAGE_SIZE,
@@ -109,7 +108,7 @@ int i915_dma_cleanup(drm_device_t * dev)
I915_WRITE(0x02080, 0x1ffff000);
}
- DRM(free) (dev->dev_private, sizeof(drm_i915_private_t),
+ drm_free (dev->dev_private, sizeof(drm_i915_private_t),
DRM_MEM_DRIVER);
dev->dev_private = NULL;
@@ -183,7 +182,7 @@ static int i915_initialize(drm_device_t * dev,
/* Program Hardware Status Page */
#ifdef __FreeBSD__
dev_priv->hw_status_page =
- contigmalloc(PAGE_SIZE, DRM(M_DRM), M_NOWAIT, 0ul, 0, 0, 0);
+ contigmalloc(PAGE_SIZE, drm_M_DRM, M_NOWAIT, 0ul, 0, 0, 0);
dev_priv->dma_status_page = vtophys(dev_priv->hw_status_page);
#else
dev_priv->hw_status_page =
@@ -255,7 +254,7 @@ int i915_dma_init(DRM_IOCTL_ARGS)
switch (init.func) {
case I915_INIT_DMA:
- dev_priv = DRM(alloc) (sizeof(drm_i915_private_t),
+ dev_priv = drm_alloc (sizeof(drm_i915_private_t),
DRM_MEM_DRIVER);
if (dev_priv == NULL)
return DRM_ERR(ENOMEM);
@@ -733,7 +732,7 @@ int i915_setparam(DRM_IOCTL_ARGS)
return 0;
}
-static void i915_driver_pretakedown(drm_device_t *dev)
+void i915_driver_pretakedown(drm_device_t *dev)
{
if (dev->dev_private) {
drm_i915_private_t *dev_priv = dev->dev_private;
@@ -742,29 +741,10 @@ static void i915_driver_pretakedown(drm_device_t *dev)
i915_dma_cleanup(dev);
}
-static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if (dev->dev_private) {
drm_i915_private_t *dev_priv = dev->dev_private;
i915_mem_release(dev, filp, dev_priv->agp_heap);
}
}
-
-void i915_driver_register_fns(drm_device_t *dev)
-{
- dev->driver_features =
- DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR |
- DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED;
- dev->fn_tbl.pretakedown = i915_driver_pretakedown;
- dev->fn_tbl.prerelease = i915_driver_prerelease;
- dev->fn_tbl.irq_preinstall = i915_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = i915_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = i915_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = i915_driver_irq_handler;
-
- 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/shared-core/i915_drm.h b/shared-core/i915_drm.h
index 24f4cd62..7e55edf4 100644
--- a/shared-core/i915_drm.h
+++ b/shared-core/i915_drm.h
@@ -61,18 +61,31 @@ typedef struct _drm_i915_sarea {
/* I915 specific ioctls
* The device specific ioctl range is 0x40 to 0x79.
*/
-#define DRM_IOCTL_I915_INIT DRM_IOW( 0x40, drm_i915_init_t)
-#define DRM_IOCTL_I915_FLUSH DRM_IO ( 0x41)
-#define DRM_IOCTL_I915_FLIP DRM_IO ( 0x42)
-#define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( 0x43, drm_i915_batchbuffer_t)
-#define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(0x44, drm_i915_irq_emit_t)
-#define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( 0x45, drm_i915_irq_wait_t)
-#define DRM_IOCTL_I915_GETPARAM DRM_IOWR(0x46, drm_i915_getparam_t)
-#define DRM_IOCTL_I915_SETPARAM DRM_IOW( 0x47, drm_i915_setparam_t)
-#define DRM_IOCTL_I915_ALLOC DRM_IOWR(0x48, drm_i915_mem_alloc_t)
-#define DRM_IOCTL_I915_FREE DRM_IOW( 0x49, drm_i915_mem_free_t)
-#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( 0x4a, drm_i915_mem_init_heap_t)
-#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( 0x4b, drm_i915_cmdbuffer_t)
+#define DRM_I915_INIT 0x00
+#define DRM_I915_FLUSH 0x01
+#define DRM_I915_FLIP 0x02
+#define DRM_I915_BATCHBUFFER 0x03
+#define DRM_I915_IRQ_EMIT 0x04
+#define DRM_I915_IRQ_WAIT 0x05
+#define DRM_I915_GETPARAM 0x06
+#define DRM_I915_SETPARAM 0x07
+#define DRM_I915_ALLOC 0x08
+#define DRM_I915_FREE 0x09
+#define DRM_I915_INIT_HEAP 0x0a
+#define DRM_I915_CMDBUFFER 0x0b
+
+#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
+#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
+#define DRM_IOCTL_I915_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)
+#define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
+#define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
+#define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
+#define DRM_IOCTL_I915_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
+#define DRM_IOCTL_I915_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
+#define DRM_IOCTL_I915_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
+#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
+#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
+#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
/* Allow drivers to submit batchbuffers directly to hardware, relying
* on the security mechanisms provided by hardware.
diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h
index 7564cd09..f6ca92a5 100644
--- a/shared-core/i915_drv.h
+++ b/shared-core/i915_drv.h
@@ -10,6 +10,28 @@
#ifndef _I915_DRV_H_
#define _I915_DRV_H_
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR "Tungsten Graphics, Inc."
+
+#define DRIVER_NAME "i915"
+#define DRIVER_DESC "Intel Graphics"
+#define DRIVER_DATE "20040405"
+
+/* Interface history:
+ *
+ * 1.1: Original.
+ */
+#define DRIVER_MAJOR 1
+#define DRIVER_MINOR 1
+#define DRIVER_PATCHLEVEL 0
+
+/* We use our own dma mechanisms, not the drm template code. However,
+ * the shared IRQ code is useful to us:
+ */
+#define __HAVE_PM 1
+
typedef struct _drm_i915_ring_buffer {
int tail_mask;
unsigned long Start;
@@ -66,6 +88,8 @@ extern int i915_getparam(DRM_IOCTL_ARGS);
extern int i915_setparam(DRM_IOCTL_ARGS);
extern int i915_cmdbuffer(DRM_IOCTL_ARGS);
extern void i915_kernel_lost_context(drm_device_t * dev);
+extern void i915_driver_pretakedown(drm_device_t *dev);
+extern void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp);
/* i915_irq.c */
extern int i915_irq_emit(DRM_IOCTL_ARGS);
diff --git a/shared-core/i915_irq.c b/shared-core/i915_irq.c
index de91aba5..581d3f22 100644
--- a/shared-core/i915_irq.c
+++ b/shared-core/i915_irq.c
@@ -7,7 +7,6 @@
*
**************************************************************************/
-#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
diff --git a/shared-core/i915_mem.c b/shared-core/i915_mem.c
index c6115b7e..d54a3005 100644
--- a/shared-core/i915_mem.c
+++ b/shared-core/i915_mem.c
@@ -7,7 +7,6 @@
*
**************************************************************************/
-#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
@@ -75,7 +74,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
+ struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start;
@@ -91,7 +90,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
+ struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start + size;
@@ -148,7 +147,7 @@ static void free_block(struct mem_block *p)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
+ drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
if (p->prev->filp == NULL) {
@@ -156,7 +155,7 @@ static void free_block(struct mem_block *p)
q->size += p->size;
q->next = p->next;
q->next->prev = q;
- DRM(free)(p, sizeof(*q), DRM_MEM_BUFLISTS);
+ drm_free(p, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
@@ -164,14 +163,14 @@ static void free_block(struct mem_block *p)
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
- struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFLISTS);
+ struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFLISTS);
if (!blocks)
return -ENOMEM;
- *heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFLISTS);
+ *heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFLISTS);
if (!*heap) {
- DRM(free)(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
+ drm_free(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
return -ENOMEM;
}
@@ -211,7 +210,7 @@ void i915_mem_release(drm_device_t * dev, DRMFILE filp, struct mem_block *heap)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
+ drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
}
@@ -228,10 +227,10 @@ void i915_mem_takedown(struct mem_block **heap)
for (p = (*heap)->next; p != *heap;) {
struct mem_block *q = p;
p = p->next;
- DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
+ drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
- DRM(free)(*heap, sizeof(**heap), DRM_MEM_BUFLISTS);
+ drm_free(*heap, sizeof(**heap), DRM_MEM_BUFLISTS);
*heap = NULL;
}
diff --git a/shared-core/mach64_dma.c b/shared-core/mach64_dma.c
index 210a6103..c463b6cf 100644
--- a/shared-core/mach64_dma.c
+++ b/shared-core/mach64_dma.c
@@ -28,10 +28,9 @@
* Gareth Hughes <gareth@valinux.com>
* Frank C. Earl <fearl@airmail.net>
* Leif Delgass <ldelgass@retinalburn.net>
- * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
*/
-#include "mach64.h"
#include "drmP.h"
#include "drm.h"
#include "mach64_drm.h"
@@ -447,7 +446,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
/* FIXME: get a dma buffer from the freelist here */
DRM_DEBUG( "Allocating data memory ...\n" );
- cpu_addr_data = DRM(pci_alloc)( dev, 0x1000, 0x1000, 0xfffffffful, &data_handle );
+ cpu_addr_data = drm_pci_alloc( dev, 0x1000, 0x1000, 0xfffffffful, &data_handle );
if (!cpu_addr_data || !data_handle) {
DRM_INFO( "data-memory allocation failed!\n" );
return DRM_ERR(ENOMEM);
@@ -481,7 +480,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
DRM_INFO( "resetting engine ...\n");
mach64_do_engine_reset( dev_priv );
DRM_INFO( "freeing data buffer memory.\n" );
- DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
+ drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
return DRM_ERR(EIO);
}
}
@@ -535,7 +534,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
MACH64_WRITE( MACH64_PAT_REG0, pat_reg0 );
MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 );
DRM_INFO( "freeing data buffer memory.\n" );
- DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
+ drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
return i;
}
DRM_DEBUG( "waiting for idle...done\n" );
@@ -572,7 +571,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
MACH64_WRITE( MACH64_PAT_REG0, pat_reg0 );
MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 );
DRM_INFO( "freeing data buffer memory.\n" );
- DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
+ drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
return i;
}
@@ -600,7 +599,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 );
DRM_DEBUG( "freeing data buffer memory.\n" );
- DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
+ drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
DRM_DEBUG( "returning ...\n" );
return failed;
@@ -615,7 +614,7 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
DRM_DEBUG( "%s\n", __FUNCTION__ );
- dev_priv = DRM(alloc)( sizeof(drm_mach64_private_t), DRM_MEM_DRIVER );
+ dev_priv = drm_alloc( sizeof(drm_mach64_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
@@ -747,7 +746,7 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
dev_priv->ring.size = 0x4000; /* 16KB */
if ( dev_priv->is_pci ) {
- dev_priv->ring.start = DRM(pci_alloc)( dev, dev_priv->ring.size,
+ dev_priv->ring.start = drm_pci_alloc( dev, dev_priv->ring.size,
dev_priv->ring.size, 0xfffffffful,
&dev_priv->ring.handle );
@@ -976,14 +975,14 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
- if ( dev->irq ) DRM(irq_uninstall)(dev);
+ if ( dev->irq ) drm_irq_uninstall(dev);
if ( dev->dev_private ) {
drm_mach64_private_t *dev_priv = dev->dev_private;
if ( dev_priv->is_pci ) {
if ( (dev_priv->ring.start != NULL) && dev_priv->ring.handle ) {
- DRM(pci_free)( dev, dev_priv->ring.size,
+ drm_pci_free( dev, dev_priv->ring.size,
dev_priv->ring.start, dev_priv->ring.handle );
}
} else {
@@ -998,7 +997,7 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
mach64_destroy_freelist( dev );
- DRM(free)( dev_priv, sizeof(drm_mach64_private_t),
+ drm_free( dev_priv, sizeof(drm_mach64_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
@@ -1085,7 +1084,7 @@ int mach64_init_freelist( drm_device_t *dev )
for ( i = 0 ; i < dma->buf_count ; i++ ) {
if ((entry =
- (drm_mach64_freelist_t *) DRM(alloc)(sizeof(drm_mach64_freelist_t),
+ (drm_mach64_freelist_t *) drm_alloc(sizeof(drm_mach64_freelist_t),
DRM_MEM_BUFLISTS)) == NULL)
return DRM_ERR(ENOMEM);
memset( entry, 0, sizeof(drm_mach64_freelist_t) );
@@ -1110,20 +1109,20 @@ void mach64_destroy_freelist( drm_device_t *dev )
{
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- DRM(free)(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
}
list_for_each_safe(ptr, tmp, &dev_priv->placeholders)
{
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- DRM(free)(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
}
list_for_each_safe(ptr, tmp, &dev_priv->free_list)
{
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- DRM(free)(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
}
}
@@ -1313,7 +1312,7 @@ int mach64_dma_buffers( DRM_IOCTL_ARGS )
DRM_CURRENTPID, d.request_count, dma->buf_count );
ret = DRM_ERR(EINVAL);
}
-
+
d.granted_count = 0;
if ( d.request_count )
@@ -1326,18 +1325,7 @@ int mach64_dma_buffers( DRM_IOCTL_ARGS )
return ret;
}
-static void mach64_driver_pretakedown(drm_device_t *dev)
-{
- mach64_do_cleanup_dma( dev );
-}
-
-void mach64_driver_register_fns(drm_device_t *dev)
+void mach64_driver_pretakedown(drm_device_t *dev)
{
- dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
- dev->fn_tbl.pretakedown = mach64_driver_pretakedown;
- dev->fn_tbl.vblank_wait = mach64_driver_vblank_wait;
- dev->fn_tbl.irq_preinstall = mach64_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = mach64_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = mach64_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = mach64_driver_irq_handler;
+ mach64_do_cleanup_dma( dev );
}
diff --git a/shared-core/mach64_drv.h b/shared-core/mach64_drv.h
index b49e6f65..f047b7ef 100644
--- a/shared-core/mach64_drv.h
+++ b/shared-core/mach64_drv.h
@@ -28,12 +28,24 @@
* Gareth Hughes <gareth@valinux.com>
* Frank C. Earl <fearl@airmail.net>
* Leif Delgass <ldelgass@retinalburn.net>
- * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
*/
#ifndef __MACH64_DRV_H__
#define __MACH64_DRV_H__
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR "Gareth Hughes, Leif Delgass, José Fonseca"
+
+#define DRIVER_NAME "mach64"
+#define DRIVER_DESC "DRM module for the ATI Rage Pro"
+#define DRIVER_DATE "20020904"
+
+#define DRIVER_MAJOR 1
+#define DRIVER_MINOR 0
+#define DRIVER_PATCHLEVEL 0
/* FIXME: remove these when not needed */
/* Development driver options */
@@ -102,6 +114,7 @@ extern int mach64_dma_idle( DRM_IOCTL_ARGS );
extern int mach64_dma_flush( DRM_IOCTL_ARGS );
extern int mach64_engine_reset( DRM_IOCTL_ARGS );
extern int mach64_dma_buffers( DRM_IOCTL_ARGS );
+extern void mach64_driver_pretakedown(drm_device_t *dev);
extern int mach64_init_freelist( drm_device_t *dev );
extern void mach64_destroy_freelist( drm_device_t *dev );
diff --git a/shared-core/mach64_irq.c b/shared-core/mach64_irq.c
index efa0641f..966c3c10 100644
--- a/shared-core/mach64_irq.c
+++ b/shared-core/mach64_irq.c
@@ -34,7 +34,6 @@
* Leif Delgass <ldelgass@retinalburn.net>
*/
-#include "mach64.h"
#include "drmP.h"
#include "drm.h"
#include "mach64_drm.h"
@@ -63,7 +62,7 @@ irqreturn_t mach64_driver_irq_handler( DRM_IRQ_ARGS )
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- DRM(vbl_send_signals)( dev );
+ drm_vbl_send_signals( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
diff --git a/shared-core/mach64_state.c b/shared-core/mach64_state.c
index ef85ffd8..127f67d2 100644
--- a/shared-core/mach64_state.c
+++ b/shared-core/mach64_state.c
@@ -26,10 +26,9 @@
* Authors:
* Gareth Hughes <gareth@valinux.com>
* Leif Delgass <ldelgass@retinalburn.net>
- * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
*/
-#include "mach64.h"
#include "drmP.h"
#include "drm.h"
#include "mach64_drm.h"
diff --git a/shared-core/mga_dma.c b/shared-core/mga_dma.c
index 0288f1c2..896787be 100644
--- a/shared-core/mga_dma.c
+++ b/shared-core/mga_dma.c
@@ -33,7 +33,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
@@ -308,7 +307,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
int i;
DRM_DEBUG( "count=%d\n", dma->buf_count );
- dev_priv->head = DRM(alloc)( sizeof(drm_mga_freelist_t),
+ dev_priv->head = drm_alloc( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
return DRM_ERR(ENOMEM);
@@ -320,7 +319,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
buf = dma->buflist[i];
buf_priv = buf->dev_private;
- entry = DRM(alloc)( sizeof(drm_mga_freelist_t),
+ entry = drm_alloc( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( entry == NULL )
return DRM_ERR(ENOMEM);
@@ -357,7 +356,7 @@ static void mga_freelist_cleanup( drm_device_t *dev )
entry = dev_priv->head;
while ( entry ) {
next = entry->next;
- DRM(free)( entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER );
+ drm_free( entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER );
entry = next;
}
@@ -458,7 +457,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
int ret;
DRM_DEBUG( "\n" );
- dev_priv = DRM(alloc)( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
+ dev_priv = drm_alloc( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
if ( !dev_priv )
return DRM_ERR(ENOMEM);
@@ -634,7 +633,7 @@ int mga_do_cleanup_dma( 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 ) {
drm_mga_private_t *dev_priv = dev->dev_private;
@@ -652,7 +651,7 @@ int mga_do_cleanup_dma( drm_device_t *dev )
mga_freelist_cleanup( dev );
}
- DRM(free)( dev->dev_private, sizeof(drm_mga_private_t),
+ drm_free( dev->dev_private, sizeof(drm_mga_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
@@ -800,30 +799,13 @@ int mga_dma_buffers( DRM_IOCTL_ARGS )
return ret;
}
-static void mga_driver_pretakedown(drm_device_t *dev)
+void mga_driver_pretakedown(drm_device_t *dev)
{
mga_do_cleanup_dma( dev );
}
-static int mga_driver_dma_quiescent(drm_device_t *dev)
+int mga_driver_dma_quiescent(drm_device_t *dev)
{
drm_mga_private_t *dev_priv = dev->dev_private;
return mga_do_wait_for_idle( dev_priv );
}
-
-void mga_driver_register_fns(drm_device_t *dev)
-{
- dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
- dev->fn_tbl.pretakedown = mga_driver_pretakedown;
- dev->fn_tbl.dma_quiescent = mga_driver_dma_quiescent;
- dev->fn_tbl.vblank_wait = mga_driver_vblank_wait;
- dev->fn_tbl.irq_preinstall = mga_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = mga_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = mga_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = mga_driver_irq_handler;
-
- dev->counters += 3;
- dev->types[6] = _DRM_STAT_IRQ;
- dev->types[7] = _DRM_STAT_PRIMARY;
- dev->types[8] = _DRM_STAT_SECONDARY;
-}
diff --git a/shared-core/mga_drv.h b/shared-core/mga_drv.h
index 75dcb0e9..3d8e9aef 100644
--- a/shared-core/mga_drv.h
+++ b/shared-core/mga_drv.h
@@ -31,6 +31,19 @@
#ifndef __MGA_DRV_H__
#define __MGA_DRV_H__
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
+
+#define DRIVER_NAME "mga"
+#define DRIVER_DESC "Matrox G200/G400"
+#define DRIVER_DATE "20021029"
+
+#define DRIVER_MAJOR 3
+#define DRIVER_MINOR 1
+#define DRIVER_PATCHLEVEL 0
+
typedef struct drm_mga_primary_buffer {
u8 *start;
u8 *end;
@@ -104,6 +117,8 @@ extern int mga_dma_init( DRM_IOCTL_ARGS );
extern int mga_dma_flush( DRM_IOCTL_ARGS );
extern int mga_dma_reset( DRM_IOCTL_ARGS );
extern int mga_dma_buffers( DRM_IOCTL_ARGS );
+extern void mga_driver_pretakedown(drm_device_t *dev);
+extern int mga_driver_dma_quiescent(drm_device_t *dev);
extern int mga_do_wait_for_idle( drm_mga_private_t *dev_priv );
extern int mga_do_dma_idle( drm_mga_private_t *dev_priv );
diff --git a/shared-core/mga_irq.c b/shared-core/mga_irq.c
index c3185b0b..bc0b6b5d 100644
--- a/shared-core/mga_irq.c
+++ b/shared-core/mga_irq.c
@@ -30,7 +30,6 @@
* Eric Anholt <anholt@FreeBSD.org>
*/
-#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
@@ -50,7 +49,7 @@ irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS )
MGA_WRITE( MGA_ICLEAR, MGA_VLINEICLR );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- DRM(vbl_send_signals)( dev );
+ drm_vbl_send_signals( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
diff --git a/shared-core/mga_state.c b/shared-core/mga_state.c
index 43659825..f676e974 100644
--- a/shared-core/mga_state.c
+++ b/shared-core/mga_state.c
@@ -32,7 +32,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
diff --git a/shared-core/mga_warp.c b/shared-core/mga_warp.c
index de1b911f..0a3a0cc7 100644
--- a/shared-core/mga_warp.c
+++ b/shared-core/mga_warp.c
@@ -27,7 +27,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
diff --git a/shared-core/r128_cce.c b/shared-core/r128_cce.c
index 64c9b8be..809e6c8c 100644
--- a/shared-core/r128_cce.c
+++ b/shared-core/r128_cce.c
@@ -28,7 +28,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
@@ -355,7 +354,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_DEBUG( "\n" );
- dev_priv = DRM(alloc)( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );
+ dev_priv = drm_alloc( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
@@ -544,7 +543,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv->ring.end = ((u32 *)dev_priv->cce_ring->handle
+ init->ring_size / sizeof(u32));
dev_priv->ring.size = init->ring_size;
- dev_priv->ring.size_l2qw = DRM(order)( init->ring_size / 8 );
+ dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 );
dev_priv->ring.tail_mask =
(dev_priv->ring.size / sizeof(u32)) - 1;
@@ -561,7 +560,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
#if __OS_HAS_AGP
if ( dev_priv->is_pci ) {
#endif
- if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
+ if (!drm_ati_pcigart_init( dev, &dev_priv->phys_pci_gart,
&dev_priv->bus_pci_gart) ) {
DRM_ERROR( "failed to init PCI GART!\n" );
dev->dev_private = (void *)dev_priv;
@@ -590,7 +589,7 @@ int r128_do_cleanup_cce( 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 ) {
drm_r128_private_t *dev_priv = dev->dev_private;
@@ -608,13 +607,13 @@ int r128_do_cleanup_cce( drm_device_t *dev )
} else
#endif
{
- if (!DRM(ati_pcigart_cleanup)( dev,
+ if (!drm_ati_pcigart_cleanup( dev,
dev_priv->phys_pci_gart,
dev_priv->bus_pci_gart ))
DRM_ERROR( "failed to cleanup PCI GART!\n" );
}
- DRM(free)( dev->dev_private, sizeof(drm_r128_private_t),
+ drm_free( dev->dev_private, sizeof(drm_r128_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
@@ -773,7 +772,7 @@ static int r128_freelist_init( drm_device_t *dev )
drm_r128_freelist_t *entry;
int i;
- dev_priv->head = DRM(alloc)( sizeof(drm_r128_freelist_t),
+ dev_priv->head = drm_alloc( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
return DRM_ERR(ENOMEM);
@@ -785,7 +784,7 @@ static int r128_freelist_init( drm_device_t *dev )
buf = dma->buflist[i];
buf_priv = buf->dev_private;
- entry = DRM(alloc)( sizeof(drm_r128_freelist_t),
+ entry = drm_alloc( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
if ( !entry ) return DRM_ERR(ENOMEM);
diff --git a/shared-core/r128_drv.h b/shared-core/r128_drv.h
index 5b91256c..9cec2f3e 100644
--- a/shared-core/r128_drv.h
+++ b/shared-core/r128_drv.h
@@ -28,12 +28,25 @@
* Rickard E. (Rik) Faith <faith@valinux.com>
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
- * Michel Dänzer <daenzerm@student.ethz.ch>
+ * Michel D�zer <daenzerm@student.ethz.ch>
*/
#ifndef __R128_DRV_H__
#define __R128_DRV_H__
+/* General customization:
+ */
+#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
+
+#define DRIVER_NAME "r128"
+#define DRIVER_DESC "ATI Rage 128"
+#define DRIVER_DATE "20030725"
+
+#define DRIVER_MAJOR 2
+#define DRIVER_MINOR 5
+#define DRIVER_PATCHLEVEL 0
+
+
#define GET_RING_HEAD(dev_priv) R128_READ( R128_PM4_BUFFER_DL_RPTR )
typedef struct drm_r128_freelist {
@@ -148,6 +161,8 @@ extern irqreturn_t r128_driver_irq_handler( DRM_IRQ_ARGS );
extern void r128_driver_irq_preinstall( drm_device_t *dev );
extern void r128_driver_irq_postinstall( drm_device_t *dev );
extern void r128_driver_irq_uninstall( drm_device_t *dev );
+extern void r128_driver_pretakedown(drm_device_t *dev);
+extern void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp);
/* Register definitions, register access macros and drmAddMap constants
* for Rage 128 kernel driver.
diff --git a/shared-core/r128_irq.c b/shared-core/r128_irq.c
index be1b9dac..643a3078 100644
--- a/shared-core/r128_irq.c
+++ b/shared-core/r128_irq.c
@@ -30,7 +30,6 @@
* Eric Anholt <anholt@FreeBSD.org>
*/
-#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
@@ -50,7 +49,7 @@ irqreturn_t r128_driver_irq_handler( DRM_IRQ_ARGS )
R128_WRITE( R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- DRM(vbl_send_signals)( dev );
+ drm_vbl_send_signals( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
diff --git a/shared-core/r128_state.c b/shared-core/r128_state.c
index 5b8af9f9..ed643682 100644
--- a/shared-core/r128_state.c
+++ b/shared-core/r128_state.c
@@ -27,7 +27,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
@@ -926,24 +925,24 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
buffer_size = depth->n * sizeof(u32);
- buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
+ buffer = drm_alloc( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL )
return DRM_ERR(ENOMEM);
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS);
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS);
return DRM_ERR(EFAULT);
}
mask_size = depth->n * sizeof(u8);
if ( depth->mask ) {
- mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
+ mask = drm_alloc( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
- DRM(free)( mask, mask_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -970,7 +969,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM(free)( mask, mask_size, DRM_MEM_BUFS );
+ drm_free( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++, x++ ) {
BEGIN_RING( 6 );
@@ -994,7 +993,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
@@ -1016,54 +1015,54 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
+ x = drm_alloc( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
- y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
+ y = drm_alloc( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, xbuf_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
buffer_size = depth->n * sizeof(u32);
- buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
+ buffer = drm_alloc( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( depth->mask ) {
mask_size = depth->n * sizeof(u8);
- mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
+ mask = drm_alloc( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
- DRM(free)( mask, mask_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -1090,7 +1089,7 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM(free)( mask, mask_size, DRM_MEM_BUFS );
+ drm_free( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++ ) {
BEGIN_RING( 6 );
@@ -1114,9 +1113,9 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
@@ -1184,23 +1183,23 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
+ x = drm_alloc( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
- y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
+ y = drm_alloc( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, ybuf_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -1228,8 +1227,8 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
ADVANCE_RING();
}
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return 0;
}
@@ -1695,7 +1694,7 @@ int r128_getparam( DRM_IOCTL_ARGS )
return 0;
}
-static void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_r128_private_t *dev_priv = dev->dev_private;
@@ -1705,20 +1704,7 @@ static void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
}
}
-static void r128_driver_pretakedown(drm_device_t *dev)
+void r128_driver_pretakedown(drm_device_t *dev)
{
r128_do_cleanup_cce( dev );
}
-
-void r128_driver_register_fns(drm_device_t *dev)
-{
- dev->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->dev_priv_size = sizeof(drm_r128_buf_priv_t);
- dev->fn_tbl.prerelease = r128_driver_prerelease;
- dev->fn_tbl.pretakedown = r128_driver_pretakedown;
- dev->fn_tbl.vblank_wait = r128_driver_vblank_wait;
- dev->fn_tbl.irq_preinstall = r128_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = r128_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = r128_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = r128_driver_irq_handler;
-}
diff --git a/shared-core/radeon_cp.c b/shared-core/radeon_cp.c
index cbde7ce9..78c41b5d 100644
--- a/shared-core/radeon_cp.c
+++ b/shared-core/radeon_cp.c
@@ -28,7 +28,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
@@ -1216,7 +1215,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv->ring.end = ((u32 *)dev_priv->cp_ring->handle
+ init->ring_size / sizeof(u32));
dev_priv->ring.size = init->ring_size;
- dev_priv->ring.size_l2qw = DRM(order)( init->ring_size / 8 );
+ dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 );
dev_priv->ring.tail_mask =
(dev_priv->ring.size / sizeof(u32)) - 1;
@@ -1230,7 +1229,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
} else
#endif
{
- if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
+ if (!drm_ati_pcigart_init( dev, &dev_priv->phys_pci_gart,
&dev_priv->bus_pci_gart)) {
DRM_ERROR( "failed to init PCI GART!\n" );
radeon_do_cleanup_cp(dev);
@@ -1260,7 +1259,7 @@ int radeon_do_cleanup_cp( 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 __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
@@ -1279,7 +1278,7 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
} else
#endif
{
- if (!DRM(ati_pcigart_cleanup)( dev,
+ if (!drm_ati_pcigart_cleanup( dev,
dev_priv->phys_pci_gart,
dev_priv->bus_pci_gart ))
DRM_ERROR( "failed to cleanup PCI GART!\n" );
@@ -1734,7 +1733,7 @@ int radeon_preinit( struct drm_device *dev, unsigned long flags )
drm_radeon_private_t *dev_priv;
int ret = 0;
- dev_priv = DRM(alloc)( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER );
+ dev_priv = drm_alloc( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
@@ -1743,12 +1742,12 @@ int radeon_preinit( struct drm_device *dev, unsigned long flags )
dev_priv->flags = flags;
/* registers */
- if( (ret = DRM(initmap)( dev, pci_resource_start( dev->pdev, 2 ),
+ if( (ret = drm_initmap( dev, pci_resource_start( dev->pdev, 2 ),
pci_resource_len( dev->pdev, 2 ), _DRM_REGISTERS, 0 )))
return ret;
/* framebuffer */
- if( (ret = DRM(initmap)( dev, pci_resource_start( dev->pdev, 0 ),
+ if( (ret = drm_initmap( dev, pci_resource_start( dev->pdev, 0 ),
pci_resource_len( dev->pdev, 0 ), _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING )))
return ret;
@@ -1776,11 +1775,6 @@ int radeon_preinit( struct drm_device *dev, unsigned long flags )
return ret;
}
-int radeon_postinit( struct drm_device *dev, unsigned long flags )
-{
- return 0;
-}
-
int radeon_postcleanup( struct drm_device *dev )
{
drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -1789,7 +1783,7 @@ int radeon_postcleanup( struct drm_device *dev )
#if defined(__linux__)
radeon_delete_i2c_busses(dev);
#endif
- DRM(free)( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER );
+ drm_free( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER );
dev->dev_private = NULL;
return 0;
diff --git a/shared-core/radeon_drv.h b/shared-core/radeon_drv.h
index ccb1654f..75c02e7a 100644
--- a/shared-core/radeon_drv.h
+++ b/shared-core/radeon_drv.h
@@ -31,6 +31,20 @@
#ifndef __RADEON_DRV_H__
#define __RADEON_DRV_H__
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR "Gareth Hughes, Keith Whitwell, others."
+
+#define DRIVER_NAME "radeon"
+#define DRIVER_DESC "ATI Radeon"
+#define DRIVER_DATE "20020828"
+
+#define DRIVER_MAJOR 1
+#define DRIVER_MINOR 11
+#define DRIVER_PATCHLEVEL 0
+
+
enum radeon_family {
CHIP_R100,
CHIP_RS100,
@@ -247,6 +261,10 @@ extern irqreturn_t radeon_driver_irq_handler( DRM_IRQ_ARGS );
extern void radeon_driver_irq_preinstall( drm_device_t *dev );
extern void radeon_driver_irq_postinstall( drm_device_t *dev );
extern void radeon_driver_irq_uninstall( drm_device_t *dev );
+extern void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp);
+extern void radeon_driver_pretakedown(drm_device_t *dev);
+extern int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv);
+extern void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv);
/* Flags for stats.boxes
*/
diff --git a/shared-core/radeon_irq.c b/shared-core/radeon_irq.c
index bdb3cc16..b7deca73 100644
--- a/shared-core/radeon_irq.c
+++ b/shared-core/radeon_irq.c
@@ -27,10 +27,9 @@
*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
- * Michel Dänzer <michel@daenzer.net>
+ * Michel D�zer <michel@daenzer.net>
*/
-#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
@@ -78,7 +77,7 @@ irqreturn_t radeon_driver_irq_handler( DRM_IRQ_ARGS )
if (stat & RADEON_CRTC_VBLANK_STAT) {
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- DRM(vbl_send_signals)( dev );
+ drm_vbl_send_signals( dev );
}
/* Acknowledge interrupts we handle */
@@ -223,7 +222,7 @@ int radeon_irq_wait( DRM_IOCTL_ARGS )
/* drm_dma.h hooks
*/
-void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+void radeon_driver_irq_preinstall( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
@@ -234,7 +233,7 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
radeon_acknowledge_irqs( dev_priv );
}
-void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+void radeon_driver_irq_postinstall( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
@@ -247,7 +246,7 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
RADEON_SW_INT_ENABLE );
}
-void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+void radeon_driver_irq_uninstall( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
if (!dev_priv)
diff --git a/shared-core/radeon_mem.c b/shared-core/radeon_mem.c
index 9d7fded7..17483dd1 100644
--- a/shared-core/radeon_mem.c
+++ b/shared-core/radeon_mem.c
@@ -29,7 +29,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
@@ -44,7 +43,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
+ struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start;
@@ -60,7 +59,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
+ struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start + size;
@@ -118,7 +117,7 @@ static void free_block( struct mem_block *p )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM(free)(q, sizeof(*q), DRM_MEM_BUFS );
+ drm_free(q, sizeof(*q), DRM_MEM_BUFS );
}
if (p->prev->filp == 0) {
@@ -126,7 +125,7 @@ static void free_block( struct mem_block *p )
q->size += p->size;
q->next = p->next;
q->next->prev = q;
- DRM(free)(p, sizeof(*q), DRM_MEM_BUFS );
+ drm_free(p, sizeof(*q), DRM_MEM_BUFS );
}
}
@@ -134,14 +133,14 @@ static void free_block( struct mem_block *p )
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
- struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFS );
+ struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFS );
if (!blocks)
return DRM_ERR(ENOMEM);
- *heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFS );
+ *heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFS );
if (!*heap) {
- DRM(free)( blocks, sizeof(*blocks), DRM_MEM_BUFS );
+ drm_free( blocks, sizeof(*blocks), DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
@@ -180,7 +179,7 @@ void radeon_mem_release( DRMFILE filp, struct mem_block *heap )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
+ drm_free(q, sizeof(*q),DRM_MEM_DRIVER);
}
}
}
@@ -197,10 +196,10 @@ void radeon_mem_takedown( struct mem_block **heap )
for (p = (*heap)->next ; p != *heap ; ) {
struct mem_block *q = p;
p = p->next;
- DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
+ drm_free(q, sizeof(*q),DRM_MEM_DRIVER);
}
- DRM(free)( *heap, sizeof(**heap),DRM_MEM_DRIVER );
+ drm_free( *heap, sizeof(**heap),DRM_MEM_DRIVER );
*heap = NULL;
}
diff --git a/shared-core/radeon_state.c b/shared-core/radeon_state.c
index 9675da92..35fb16e9 100644
--- a/shared-core/radeon_state.c
+++ b/shared-core/radeon_state.c
@@ -27,7 +27,6 @@
* Kevin E. Martin <martin@valinux.com>
*/
-#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "drm_sarea.h"
@@ -1598,7 +1597,7 @@ static int radeon_do_init_pageflip( drm_device_t *dev )
return 0;
}
-/* Called whenever a client dies, from DRM(release).
+/* Called whenever a client dies, from drm_release.
* NOTE: Lock isn't necessarily held when this is called!
*/
int radeon_do_cleanup_pageflip( drm_device_t *dev )
@@ -2560,7 +2559,7 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
*
* DRM infrastructure takes care of reclaiming dma buffers.
*/
-static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -2572,17 +2571,17 @@ static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
}
}
-static void radeon_driver_pretakedown(drm_device_t *dev)
+void radeon_driver_pretakedown(drm_device_t *dev)
{
radeon_do_release(dev);
}
-static int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
+int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
{
drm_radeon_private_t *dev_priv = dev->dev_private;
struct drm_radeon_driver_file_fields *radeon_priv;
- radeon_priv = (struct drm_radeon_driver_file_fields *)DRM(alloc)(sizeof(*radeon_priv), DRM_MEM_FILES);
+ radeon_priv = (struct drm_radeon_driver_file_fields *)drm_alloc(sizeof(*radeon_priv), DRM_MEM_FILES);
if (!radeon_priv)
return -ENOMEM;
@@ -2596,27 +2595,10 @@ static int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
return 0;
}
-static void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv)
+void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv)
{
struct drm_radeon_driver_file_fields *radeon_priv = filp_priv->driver_priv;
- DRM(free)(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
+ drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
}
-void radeon_driver_register_fns(struct drm_device *dev)
-{
- dev->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->dev_priv_size = sizeof(drm_radeon_buf_priv_t);
- dev->fn_tbl.preinit = radeon_preinit;
- dev->fn_tbl.postinit = radeon_postinit;
- dev->fn_tbl.postcleanup = radeon_postcleanup;
- dev->fn_tbl.prerelease = radeon_driver_prerelease;
- dev->fn_tbl.pretakedown = radeon_driver_pretakedown;
- dev->fn_tbl.open_helper = radeon_driver_open_helper;
- dev->fn_tbl.vblank_wait = radeon_driver_vblank_wait;
- dev->fn_tbl.irq_preinstall = radeon_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = radeon_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = radeon_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = radeon_driver_irq_handler;
- dev->fn_tbl.free_filp_priv = radeon_driver_free_filp_priv;
-}
diff --git a/shared-core/sis_drm.h b/shared-core/sis_drm.h
index 49505719..e99c3a43 100644
--- a/shared-core/sis_drm.h
+++ b/shared-core/sis_drm.h
@@ -3,12 +3,21 @@
#define __SIS_DRM_H__
/* SiS specific ioctls */
-#define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(0x44, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_FB_FREE DRM_IOW( 0x45, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(0x53, drm_sis_agp_t)
-#define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(0x54, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( 0x55, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_FB_INIT DRM_IOW( 0x56, drm_sis_fb_t)
+#define NOT_USED_0_3
+#define DRM_SIS_FB_ALLOC 0x04
+#define DRM_SIS_FB_FREE 0x05
+#define NOT_USED_6_12
+#define DRM_SIS_AGP_INIT 0x13
+#define DRM_SIS_AGP_ALLOC 0x14
+#define DRM_SIS_AGP_FREE 0x15
+#define DRM_SIS_FB_INIT 0x16
+
+#define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_FB_ALLOC, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_FB_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_FREE, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_INIT, drm_sis_agp_t)
+#define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_ALLOC, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_AGP_FREE, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_FB_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_INIT, drm_sis_fb_t)
/*
#define DRM_IOCTL_SIS_FLIP DRM_IOW( 0x48, drm_sis_flip_t)
#define DRM_IOCTL_SIS_FLIP_INIT DRM_IO( 0x49)
diff --git a/shared-core/sis_drv.h b/shared-core/sis_drv.h
index 1ca618cf..7232b8f3 100644
--- a/shared-core/sis_drv.h
+++ b/shared-core/sis_drv.h
@@ -28,6 +28,17 @@
#ifndef _SIS_DRV_H_
#define _SIS_DRV_H_
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR "SIS"
+#define DRIVER_NAME "sis"
+#define DRIVER_DESC "SIS 300/630/540"
+#define DRIVER_DATE "20030826"
+#define DRIVER_MAJOR 1
+#define DRIVER_MINOR 1
+#define DRIVER_PATCHLEVEL 0
+
#include "sis_ds.h"
typedef struct drm_sis_private {
diff --git a/shared-core/sis_ds.c b/shared-core/sis_ds.c
index 08391554..60bffa69 100644
--- a/shared-core/sis_ds.c
+++ b/shared-core/sis_ds.c
@@ -28,7 +28,6 @@
*
*/
-#include "sis.h"
#include "drmP.h"
#include "drm.h"
#include "sis_ds.h"
@@ -42,7 +41,7 @@ set_t *setInit(void)
int i;
set_t *set;
- set = (set_t *)DRM(alloc)(sizeof(set_t), DRM_MEM_DRIVER);
+ set = (set_t *)drm_alloc(sizeof(set_t), DRM_MEM_DRIVER);
if (set != NULL) {
for (i = 0; i < SET_SIZE; i++) {
set->list[i].free_next = i + 1;
@@ -128,7 +127,7 @@ int setNext(set_t *set, ITEM_TYPE *item)
int setDestroy(set_t *set)
{
- DRM(free)(set, sizeof(set_t), DRM_MEM_DRIVER);
+ drm_free(set, sizeof(set_t), DRM_MEM_DRIVER);
return 1;
}
@@ -167,7 +166,7 @@ memHeap_t *mmInit(int ofs,
if (size <= 0)
return NULL;
- blocks = (TMemBlock *)DRM(calloc)(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)drm_calloc(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
if (blocks != NULL) {
blocks->ofs = ofs;
blocks->size = size;
@@ -202,7 +201,7 @@ memHeap_t *mmAddRange( memHeap_t *heap,
int size )
{
PMemBlock blocks;
- blocks = (TMemBlock *)DRM(calloc)(2, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)drm_calloc(2, sizeof(TMemBlock), DRM_MEM_DRIVER);
if (blocks != NULL) {
blocks[0].size = size;
blocks[0].free = 1;
@@ -229,7 +228,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break left */
if (startofs > p->ofs) {
- newblock = (TMemBlock*) DRM(calloc)(1, sizeof(TMemBlock),
+ newblock = (TMemBlock*) drm_calloc(1, sizeof(TMemBlock),
DRM_MEM_DRIVER);
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
@@ -242,7 +241,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break right */
if (size < p->size) {
- newblock = (TMemBlock*) DRM(calloc)(1, sizeof(TMemBlock),
+ newblock = (TMemBlock*) drm_calloc(1, sizeof(TMemBlock),
DRM_MEM_DRIVER);
newblock->ofs = startofs + size;
newblock->size = p->size - size;
@@ -295,7 +294,7 @@ static __inline__ int Join2Blocks(TMemBlock *p)
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
- DRM(free)(q, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ drm_free(q, sizeof(TMemBlock), DRM_MEM_DRIVER);
return 1;
}
return 0;
@@ -380,7 +379,7 @@ void mmDestroy(memHeap_t *heap)
p = (TMemBlock *)heap;
while (p != NULL) {
q = p->next;
- DRM(free)(p, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ drm_free(p, sizeof(TMemBlock), DRM_MEM_DRIVER);
p = q;
}
}
diff --git a/shared-core/sis_mm.c b/shared-core/sis_mm.c
index 27b904fc..a895e0b8 100644
--- a/shared-core/sis_mm.c
+++ b/shared-core/sis_mm.c
@@ -28,7 +28,6 @@
*
*/
-#include "sis.h"
#include "drmP.h"
#include "sis_drm.h"
#include "sis_drv.h"
@@ -163,7 +162,7 @@ int sis_fb_init( DRM_IOCTL_ARGS )
DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_fb_t __user *)data, sizeof(fb));
if (dev_priv == NULL) {
- dev->dev_private = DRM(calloc)(1, sizeof(drm_sis_private_t),
+ dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
DRM_MEM_DRIVER);
dev_priv = dev->dev_private;
if (dev_priv == NULL)
@@ -251,7 +250,7 @@ int sis_ioctl_agp_init( DRM_IOCTL_ARGS )
drm_sis_agp_t agp;
if (dev_priv == NULL) {
- dev->dev_private = DRM(calloc)(1, sizeof(drm_sis_private_t),
+ dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
DRM_MEM_DRIVER);
dev_priv = dev->dev_private;
if (dev_priv == NULL)
@@ -408,10 +407,3 @@ int sis_final_context(struct drm_device *dev, int context)
return 1;
}
-
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
- dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR;
- dev->fn_tbl.context_ctor = sis_init_context;
- dev->fn_tbl.context_dtor = sis_final_context;
-}
diff --git a/shared-core/via_dma.c b/shared-core/via_dma.c
index 4afc5215..493c0b00 100644
--- a/shared-core/via_dma.c
+++ b/shared-core/via_dma.c
@@ -10,7 +10,6 @@
*
**************************************************************************/
-#include "via.h"
#include "drmP.h"
#include "drm.h"
#include "via_drm.h"
diff --git a/shared-core/via_drm.h b/shared-core/via_drm.h
index ddc89f83..ba94a4fe 100644
--- a/shared-core/via_drm.h
+++ b/shared-core/via_drm.h
@@ -62,16 +62,28 @@
#define VIA_UPLOAD_ALL 0xff
/* VIA specific ioctls */
-#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(0x40, drm_via_mem_t)
-#define DRM_IOCTL_VIA_FREEMEM DRM_IOW(0x41, drm_via_mem_t)
-#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(0x42, drm_via_agp_t)
-#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(0x43, drm_via_fb_t)
-#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(0x44, drm_via_init_t)
-#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW(0x45, drm_via_futex_t)
-#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(0x47, drm_via_dma_init_t)
-#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW(0x48, drm_via_cmdbuffer_t)
-#define DRM_IOCTL_VIA_FLUSH DRM_IO(0x49)
-#define DRM_IOCTL_VIA_PCICMD DRM_IOW(0x4A, drm_via_cmdbuffer_t)
+#define DRM_VIA_ALLOCMEM 0x00
+#define DRM_VIA_FREEMEM 0x01
+#define DRM_VIA_AGP_INIT 0x02
+#define DRM_VIA_FB_INIT 0x03
+#define DRM_VIA_MAP_INIT 0x04
+#define DRM_VIA_DEC_FUTEX 0x05
+#define NOT_USED
+#define DRM_VIA_DMA_INIT 0x07
+#define DRM_VIA_CMDBUFFER 0x08
+#define DRM_VIA_FLUSH 0x09
+#define DRM_VIA_PCICMD 0x0a
+
+#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
+#define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
+#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
+#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
+#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
+#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
+#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
+#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
+#define DRM_IOCTL_VIA_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_VIA_FLUSH)
+#define DRM_IOCTL_VIA_PCICMD DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
/* Indices into buf.Setup where various bits of state are mirrored per
diff --git a/shared-core/via_drv.c b/shared-core/via_drv.c
index 7b6e1b96..cec14e7a 100644
--- a/shared-core/via_drv.c
+++ b/shared-core/via_drv.c
@@ -23,7 +23,6 @@
*/
#include <linux/config.h>
-#include "via.h"
#include "drmP.h"
#include "via_drm.h"
#include "via_drv.h"
@@ -38,18 +37,95 @@
#define DRIVER_MINOR 5
#define DRIVER_PATCHLEVEL 0
+#include "drm_pciids.h"
-#define DRIVER_IOCTLS \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_ALLOCMEM)] = { via_mem_alloc, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_FREEMEM)] = { via_mem_free, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_AGP_INIT)] = { via_agp_init, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_FB_INIT)] = { via_fb_init, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_MAP_INIT)] = { via_map_init, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_DEC_FUTEX)] = { via_decoder_futex, 1, 0}, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_DMA_INIT)] = { via_dma_init, 1, 0}, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_CMDBUFFER)] = { via_cmdbuffer, 1, 0}, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_FLUSH)] = { via_flush_ioctl, 1, 0}, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_PCICMD)] = { via_pci_cmdbuffer, 1, 0}
+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;
-#include "drm_core.h"
+ 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[] = {
+ viadrv_PCI_IDS
+};
+
+static drm_ioctl_desc_t ioctls[] = {
+ [DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = { via_mem_alloc, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = { via_mem_free, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = { via_agp_init, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = { via_fb_init, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = { via_map_init, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = { via_decoder_futex, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = { via_dma_init, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = { via_cmdbuffer, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_FLUSH)] = { via_flush_ioctl, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_PCICMD)] = { via_pci_cmdbuffer, 1, 0}
+};
+
+static struct drm_driver_fn driver_fn = {
+ .driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL,
+ .context_ctor = via_init_context,
+ .context_dtor = via_final_context,
+ .vblank_wait = via_driver_vblank_wait,
+ .irq_preinstall = via_driver_irq_preinstall,
+ .irq_postinstall = via_driver_irq_postinstall,
+ .irq_uninstall = via_driver_irq_uninstall,
+ .irq_handler = via_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 via_init(void)
+{
+ return drm_init(&driver, pciidlist, &driver_fn);
+}
+
+static void __exit via_exit(void)
+{
+ drm_exit(&driver);
+}
+
+module_init(via_init);
+module_exit(via_exit);
+
+MODULE_AUTHOR( DRIVER_AUTHOR );
+MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_LICENSE("GPL and additional rights");
diff --git a/shared-core/via_ds.c b/shared-core/via_ds.c
index a29204ce..71af0c9b 100644
--- a/shared-core/via_ds.c
+++ b/shared-core/via_ds.c
@@ -38,7 +38,7 @@ set_t *via_setInit(void)
{
int i;
set_t *set;
- set = (set_t *)DRM(alloc)(sizeof(set_t), DRM_MEM_DRIVER);
+ set = (set_t *)drm_alloc(sizeof(set_t), DRM_MEM_DRIVER);
for (i = 0; i < SET_SIZE; i++) {
set->list[i].free_next = i+1;
set->list[i].alloc_next = -1;
@@ -120,7 +120,7 @@ int via_setNext(set_t *set, ITEM_TYPE *item)
int via_setDestroy(set_t *set)
{
- DRM(free)(set, sizeof(set_t), DRM_MEM_DRIVER);
+ drm_free(set, sizeof(set_t), DRM_MEM_DRIVER);
return 1;
}
@@ -161,7 +161,7 @@ memHeap_t *via_mmInit(int ofs,
return 0;
- blocks = (TMemBlock *)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)drm_calloc(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
if (blocks) {
blocks->ofs = ofs;
@@ -177,7 +177,7 @@ memHeap_t *via_mmAddRange(memHeap_t *heap,
int size)
{
PMemBlock blocks;
- blocks = (TMemBlock *)DRM(calloc)(2,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)drm_calloc(2,sizeof(TMemBlock),DRM_MEM_DRIVER);
if (blocks) {
blocks[0].size = size;
@@ -206,7 +206,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break left */
if (startofs > p->ofs) {
- newblock = (TMemBlock*)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ newblock = (TMemBlock*)drm_calloc(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
newblock->free = 1;
@@ -218,7 +218,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break right */
if (size < p->size) {
- newblock = (TMemBlock*)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ newblock = (TMemBlock*)drm_calloc(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
newblock->ofs = startofs + size;
newblock->size = p->size - size;
newblock->free = 1;
@@ -277,7 +277,7 @@ static __inline__ int Join2Blocks(TMemBlock *p)
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
- DRM(free)(q,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ drm_free(q,sizeof(TMemBlock),DRM_MEM_DRIVER);
return 1;
}
@@ -384,7 +384,7 @@ void via_mmDestroy(memHeap_t *heap)
while (p) {
q = p->next;
- DRM(free)(p,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ drm_free(p,sizeof(TMemBlock),DRM_MEM_DRIVER);
p = q;
}
}
diff --git a/shared-core/via_ds.h b/shared-core/via_ds.h
index 50ab3e7f..d9a60186 100644
--- a/shared-core/via_ds.h
+++ b/shared-core/via_ds.h
@@ -26,7 +26,6 @@
#ifndef _via_ds_h_
#define _via_ds_h_
-#include "via.h"
#include "drmP.h"
/* Set Data Structure */
diff --git a/shared-core/via_irq.c b/shared-core/via_irq.c
index eafb1d7d..b0a3349e 100644
--- a/shared-core/via_irq.c
+++ b/shared-core/via_irq.c
@@ -33,7 +33,6 @@
* interrupt.
*/
-#include "via.h"
#include "drmP.h"
#include "drm.h"
#include "via_drm.h"
@@ -58,7 +57,7 @@ irqreturn_t via_driver_irq_handler( DRM_IRQ_ARGS )
if(status & VIA_IRQ_VBI_PENDING){
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- DRM(vbl_send_signals)(dev);
+ drm_vbl_send_signals(dev);
handled = 1;
}
diff --git a/shared-core/via_map.c b/shared-core/via_map.c
index f08503d4..b7f0b43b 100644
--- a/shared-core/via_map.c
+++ b/shared-core/via_map.c
@@ -21,7 +21,6 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
-#include "via.h"
#include "drmP.h"
#include "via_drv.h"
@@ -32,7 +31,7 @@ int via_do_init_map(drm_device_t *dev, drm_via_init_t *init)
DRM_DEBUG("%s\n", __FUNCTION__);
- dev_priv = DRM(alloc)(sizeof(drm_via_private_t), DRM_MEM_DRIVER);
+ dev_priv = drm_alloc(sizeof(drm_via_private_t), DRM_MEM_DRIVER);
if (dev_priv == NULL)
return -ENOMEM;
@@ -84,7 +83,7 @@ int via_do_cleanup_map(drm_device_t *dev)
via_dma_cleanup(dev);
- DRM(free)(dev_priv, sizeof(drm_via_private_t),
+ drm_free(dev_priv, sizeof(drm_via_private_t),
DRM_MEM_DRIVER);
dev->dev_private = NULL;
}
diff --git a/shared-core/via_mm.c b/shared-core/via_mm.c
index 2a9be681..706f00d1 100644
--- a/shared-core/via_mm.c
+++ b/shared-core/via_mm.c
@@ -21,7 +21,6 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
-#include "via.h"
#include "drmP.h"
#include "via_drm.h"
#include "via_drv.h"
@@ -175,7 +174,7 @@ int via_final_context(struct drm_device *dev, int context)
/* Linux specific until context tracking code gets ported to BSD */
/* Last context, perform cleanup */
if (dev->ctx_count == 1 && dev->dev_private) {
- if (dev->irq) DRM(irq_uninstall)(dev);
+ if (dev->irq) drm_irq_uninstall(dev);
via_do_cleanup_map(dev);
}
@@ -211,13 +210,13 @@ int via_fb_alloc(drm_via_mem_t* mem)
drm_via_mm_t fb;
PMemBlock block;
int retval = 0;
-
+
if (!FBHeap)
return -1;
fb.size = mem->size;
fb.context = mem->context;
-
+
block = via_mmAllocMem(FBHeap, fb.size, 5, 0);
if (block) {
fb.offset = block->ofs;
@@ -234,13 +233,13 @@ int via_fb_alloc(drm_via_mem_t* mem)
fb.free = 0;
retval = -1;
}
-
+
mem->offset = fb.offset;
mem->index = fb.free;
DRM_DEBUG("alloc fb, size = %d, offset = %d\n", fb.size,
(int)fb.offset);
-
+
return retval;
}
int via_agp_alloc(drm_via_mem_t* mem)
@@ -270,7 +269,7 @@ int via_agp_alloc(drm_via_mem_t* mem)
agp.size = 0;
agp.free = 0;
}
-
+
mem->offset = agp.offset;
mem->index = agp.free;
@@ -282,7 +281,7 @@ int via_agp_alloc(drm_via_mem_t* mem)
int via_mem_free( DRM_IOCTL_ARGS )
{
drm_via_mem_t mem;
-
+
DRM_COPY_FROM_USER_IOCTL(mem, (drm_via_mem_t *)data, sizeof(mem));
switch (mem.type) {
@@ -296,22 +295,23 @@ int via_mem_free( DRM_IOCTL_ARGS )
return 0;
break;
}
-
+
return -EFAULT;
}
+
int via_fb_free(drm_via_mem_t* mem)
{
drm_via_mm_t fb;
int retval = 0;
-
+
if (!FBHeap) {
return -1;
}
fb.free = mem->index;
fb.context = mem->context;
-
+
if (!fb.free)
{
return -1;
@@ -319,50 +319,37 @@ int via_fb_free(drm_via_mem_t* mem)
}
via_mmFreeMem((PMemBlock)fb.free);
-
+
if (!del_alloc_set(fb.context, VIDEO, fb.free))
{
retval = -1;
}
-
+
DRM_DEBUG("free fb, free = %d\n", fb.free);
-
+
return retval;
-}
+}
+
int via_agp_free(drm_via_mem_t* mem)
{
drm_via_mm_t agp;
-
+
int retval = 0;
agp.free = mem->index;
agp.context = mem->context;
-
+
if (!agp.free)
return -1;
via_mmFreeMem((PMemBlock)agp.free);
-
+
if (!del_alloc_set(agp.context, AGP, agp.free)) {
retval = -1;
}
DRM_DEBUG("free agp, free = %d\n", agp.free);
-
+
return retval;
}
-EXPORT_SYMBOL(via_fb_alloc);
-EXPORT_SYMBOL(via_fb_free);
-
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
- dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
- dev->fn_tbl.context_ctor = via_init_context;
- dev->fn_tbl.context_dtor = via_final_context;
- dev->fn_tbl.vblank_wait = via_driver_vblank_wait;
- dev->fn_tbl.irq_preinstall = via_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = via_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = via_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = via_driver_irq_handler;
-}
diff --git a/shared/i915_dma.c b/shared/i915_dma.c
index cf0333f6..1b91c60a 100644
--- a/shared/i915_dma.c
+++ b/shared/i915_dma.c
@@ -7,7 +7,6 @@
*
**************************************************************************/
-#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
@@ -84,7 +83,7 @@ int i915_dma_cleanup(drm_device_t * dev)
* is freed, it's too late.
*/
if (dev->irq)
- DRM(irq_uninstall) (dev);
+ drm_irq_uninstall (dev);
if (dev->dev_private) {
drm_i915_private_t *dev_priv =
@@ -98,7 +97,7 @@ int i915_dma_cleanup(drm_device_t * dev)
#ifdef __FreeBSD__
#if __FreeBSD_version > 500000
contigfree(dev_priv->hw_status_page, PAGE_SIZE,
- DRM(M_DRM));
+ drm_M_DRM);
#endif
#else
pci_free_consistent(dev->pdev, PAGE_SIZE,
@@ -109,7 +108,7 @@ int i915_dma_cleanup(drm_device_t * dev)
I915_WRITE(0x02080, 0x1ffff000);
}
- DRM(free) (dev->dev_private, sizeof(drm_i915_private_t),
+ drm_free (dev->dev_private, sizeof(drm_i915_private_t),
DRM_MEM_DRIVER);
dev->dev_private = NULL;
@@ -183,7 +182,7 @@ static int i915_initialize(drm_device_t * dev,
/* Program Hardware Status Page */
#ifdef __FreeBSD__
dev_priv->hw_status_page =
- contigmalloc(PAGE_SIZE, DRM(M_DRM), M_NOWAIT, 0ul, 0, 0, 0);
+ contigmalloc(PAGE_SIZE, drm_M_DRM, M_NOWAIT, 0ul, 0, 0, 0);
dev_priv->dma_status_page = vtophys(dev_priv->hw_status_page);
#else
dev_priv->hw_status_page =
@@ -255,7 +254,7 @@ int i915_dma_init(DRM_IOCTL_ARGS)
switch (init.func) {
case I915_INIT_DMA:
- dev_priv = DRM(alloc) (sizeof(drm_i915_private_t),
+ dev_priv = drm_alloc (sizeof(drm_i915_private_t),
DRM_MEM_DRIVER);
if (dev_priv == NULL)
return DRM_ERR(ENOMEM);
@@ -733,7 +732,7 @@ int i915_setparam(DRM_IOCTL_ARGS)
return 0;
}
-static void i915_driver_pretakedown(drm_device_t *dev)
+void i915_driver_pretakedown(drm_device_t *dev)
{
if (dev->dev_private) {
drm_i915_private_t *dev_priv = dev->dev_private;
@@ -742,29 +741,10 @@ static void i915_driver_pretakedown(drm_device_t *dev)
i915_dma_cleanup(dev);
}
-static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if (dev->dev_private) {
drm_i915_private_t *dev_priv = dev->dev_private;
i915_mem_release(dev, filp, dev_priv->agp_heap);
}
}
-
-void i915_driver_register_fns(drm_device_t *dev)
-{
- dev->driver_features =
- DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR |
- DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED;
- dev->fn_tbl.pretakedown = i915_driver_pretakedown;
- dev->fn_tbl.prerelease = i915_driver_prerelease;
- dev->fn_tbl.irq_preinstall = i915_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = i915_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = i915_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = i915_driver_irq_handler;
-
- 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/shared/i915_drm.h b/shared/i915_drm.h
index 24f4cd62..7e55edf4 100644
--- a/shared/i915_drm.h
+++ b/shared/i915_drm.h
@@ -61,18 +61,31 @@ typedef struct _drm_i915_sarea {
/* I915 specific ioctls
* The device specific ioctl range is 0x40 to 0x79.
*/
-#define DRM_IOCTL_I915_INIT DRM_IOW( 0x40, drm_i915_init_t)
-#define DRM_IOCTL_I915_FLUSH DRM_IO ( 0x41)
-#define DRM_IOCTL_I915_FLIP DRM_IO ( 0x42)
-#define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( 0x43, drm_i915_batchbuffer_t)
-#define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(0x44, drm_i915_irq_emit_t)
-#define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( 0x45, drm_i915_irq_wait_t)
-#define DRM_IOCTL_I915_GETPARAM DRM_IOWR(0x46, drm_i915_getparam_t)
-#define DRM_IOCTL_I915_SETPARAM DRM_IOW( 0x47, drm_i915_setparam_t)
-#define DRM_IOCTL_I915_ALLOC DRM_IOWR(0x48, drm_i915_mem_alloc_t)
-#define DRM_IOCTL_I915_FREE DRM_IOW( 0x49, drm_i915_mem_free_t)
-#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( 0x4a, drm_i915_mem_init_heap_t)
-#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( 0x4b, drm_i915_cmdbuffer_t)
+#define DRM_I915_INIT 0x00
+#define DRM_I915_FLUSH 0x01
+#define DRM_I915_FLIP 0x02
+#define DRM_I915_BATCHBUFFER 0x03
+#define DRM_I915_IRQ_EMIT 0x04
+#define DRM_I915_IRQ_WAIT 0x05
+#define DRM_I915_GETPARAM 0x06
+#define DRM_I915_SETPARAM 0x07
+#define DRM_I915_ALLOC 0x08
+#define DRM_I915_FREE 0x09
+#define DRM_I915_INIT_HEAP 0x0a
+#define DRM_I915_CMDBUFFER 0x0b
+
+#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
+#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
+#define DRM_IOCTL_I915_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)
+#define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
+#define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
+#define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
+#define DRM_IOCTL_I915_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
+#define DRM_IOCTL_I915_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
+#define DRM_IOCTL_I915_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
+#define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
+#define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
+#define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
/* Allow drivers to submit batchbuffers directly to hardware, relying
* on the security mechanisms provided by hardware.
diff --git a/shared/i915_drv.h b/shared/i915_drv.h
index 7564cd09..f6ca92a5 100644
--- a/shared/i915_drv.h
+++ b/shared/i915_drv.h
@@ -10,6 +10,28 @@
#ifndef _I915_DRV_H_
#define _I915_DRV_H_
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR "Tungsten Graphics, Inc."
+
+#define DRIVER_NAME "i915"
+#define DRIVER_DESC "Intel Graphics"
+#define DRIVER_DATE "20040405"
+
+/* Interface history:
+ *
+ * 1.1: Original.
+ */
+#define DRIVER_MAJOR 1
+#define DRIVER_MINOR 1
+#define DRIVER_PATCHLEVEL 0
+
+/* We use our own dma mechanisms, not the drm template code. However,
+ * the shared IRQ code is useful to us:
+ */
+#define __HAVE_PM 1
+
typedef struct _drm_i915_ring_buffer {
int tail_mask;
unsigned long Start;
@@ -66,6 +88,8 @@ extern int i915_getparam(DRM_IOCTL_ARGS);
extern int i915_setparam(DRM_IOCTL_ARGS);
extern int i915_cmdbuffer(DRM_IOCTL_ARGS);
extern void i915_kernel_lost_context(drm_device_t * dev);
+extern void i915_driver_pretakedown(drm_device_t *dev);
+extern void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp);
/* i915_irq.c */
extern int i915_irq_emit(DRM_IOCTL_ARGS);
diff --git a/shared/i915_irq.c b/shared/i915_irq.c
index de91aba5..581d3f22 100644
--- a/shared/i915_irq.c
+++ b/shared/i915_irq.c
@@ -7,7 +7,6 @@
*
**************************************************************************/
-#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
diff --git a/shared/i915_mem.c b/shared/i915_mem.c
index c6115b7e..d54a3005 100644
--- a/shared/i915_mem.c
+++ b/shared/i915_mem.c
@@ -7,7 +7,6 @@
*
**************************************************************************/
-#include "i915.h"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
@@ -75,7 +74,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
+ struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start;
@@ -91,7 +90,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
+ struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start + size;
@@ -148,7 +147,7 @@ static void free_block(struct mem_block *p)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
+ drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
if (p->prev->filp == NULL) {
@@ -156,7 +155,7 @@ static void free_block(struct mem_block *p)
q->size += p->size;
q->next = p->next;
q->next->prev = q;
- DRM(free)(p, sizeof(*q), DRM_MEM_BUFLISTS);
+ drm_free(p, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
@@ -164,14 +163,14 @@ static void free_block(struct mem_block *p)
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
- struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFLISTS);
+ struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFLISTS);
if (!blocks)
return -ENOMEM;
- *heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFLISTS);
+ *heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFLISTS);
if (!*heap) {
- DRM(free)(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
+ drm_free(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
return -ENOMEM;
}
@@ -211,7 +210,7 @@ void i915_mem_release(drm_device_t * dev, DRMFILE filp, struct mem_block *heap)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
+ drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
}
@@ -228,10 +227,10 @@ void i915_mem_takedown(struct mem_block **heap)
for (p = (*heap)->next; p != *heap;) {
struct mem_block *q = p;
p = p->next;
- DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
+ drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
- DRM(free)(*heap, sizeof(**heap), DRM_MEM_BUFLISTS);
+ drm_free(*heap, sizeof(**heap), DRM_MEM_BUFLISTS);
*heap = NULL;
}
diff --git a/shared/mach64_dma.c b/shared/mach64_dma.c
index 210a6103..c463b6cf 100644
--- a/shared/mach64_dma.c
+++ b/shared/mach64_dma.c
@@ -28,10 +28,9 @@
* Gareth Hughes <gareth@valinux.com>
* Frank C. Earl <fearl@airmail.net>
* Leif Delgass <ldelgass@retinalburn.net>
- * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
*/
-#include "mach64.h"
#include "drmP.h"
#include "drm.h"
#include "mach64_drm.h"
@@ -447,7 +446,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
/* FIXME: get a dma buffer from the freelist here */
DRM_DEBUG( "Allocating data memory ...\n" );
- cpu_addr_data = DRM(pci_alloc)( dev, 0x1000, 0x1000, 0xfffffffful, &data_handle );
+ cpu_addr_data = drm_pci_alloc( dev, 0x1000, 0x1000, 0xfffffffful, &data_handle );
if (!cpu_addr_data || !data_handle) {
DRM_INFO( "data-memory allocation failed!\n" );
return DRM_ERR(ENOMEM);
@@ -481,7 +480,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
DRM_INFO( "resetting engine ...\n");
mach64_do_engine_reset( dev_priv );
DRM_INFO( "freeing data buffer memory.\n" );
- DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
+ drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
return DRM_ERR(EIO);
}
}
@@ -535,7 +534,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
MACH64_WRITE( MACH64_PAT_REG0, pat_reg0 );
MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 );
DRM_INFO( "freeing data buffer memory.\n" );
- DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
+ drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
return i;
}
DRM_DEBUG( "waiting for idle...done\n" );
@@ -572,7 +571,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
MACH64_WRITE( MACH64_PAT_REG0, pat_reg0 );
MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 );
DRM_INFO( "freeing data buffer memory.\n" );
- DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
+ drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
return i;
}
@@ -600,7 +599,7 @@ static int mach64_bm_dma_test( drm_device_t *dev )
MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 );
DRM_DEBUG( "freeing data buffer memory.\n" );
- DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle );
+ drm_pci_free( dev, 0x1000, cpu_addr_data, data_handle );
DRM_DEBUG( "returning ...\n" );
return failed;
@@ -615,7 +614,7 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
DRM_DEBUG( "%s\n", __FUNCTION__ );
- dev_priv = DRM(alloc)( sizeof(drm_mach64_private_t), DRM_MEM_DRIVER );
+ dev_priv = drm_alloc( sizeof(drm_mach64_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
@@ -747,7 +746,7 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
dev_priv->ring.size = 0x4000; /* 16KB */
if ( dev_priv->is_pci ) {
- dev_priv->ring.start = DRM(pci_alloc)( dev, dev_priv->ring.size,
+ dev_priv->ring.start = drm_pci_alloc( dev, dev_priv->ring.size,
dev_priv->ring.size, 0xfffffffful,
&dev_priv->ring.handle );
@@ -976,14 +975,14 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
- if ( dev->irq ) DRM(irq_uninstall)(dev);
+ if ( dev->irq ) drm_irq_uninstall(dev);
if ( dev->dev_private ) {
drm_mach64_private_t *dev_priv = dev->dev_private;
if ( dev_priv->is_pci ) {
if ( (dev_priv->ring.start != NULL) && dev_priv->ring.handle ) {
- DRM(pci_free)( dev, dev_priv->ring.size,
+ drm_pci_free( dev, dev_priv->ring.size,
dev_priv->ring.start, dev_priv->ring.handle );
}
} else {
@@ -998,7 +997,7 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
mach64_destroy_freelist( dev );
- DRM(free)( dev_priv, sizeof(drm_mach64_private_t),
+ drm_free( dev_priv, sizeof(drm_mach64_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
@@ -1085,7 +1084,7 @@ int mach64_init_freelist( drm_device_t *dev )
for ( i = 0 ; i < dma->buf_count ; i++ ) {
if ((entry =
- (drm_mach64_freelist_t *) DRM(alloc)(sizeof(drm_mach64_freelist_t),
+ (drm_mach64_freelist_t *) drm_alloc(sizeof(drm_mach64_freelist_t),
DRM_MEM_BUFLISTS)) == NULL)
return DRM_ERR(ENOMEM);
memset( entry, 0, sizeof(drm_mach64_freelist_t) );
@@ -1110,20 +1109,20 @@ void mach64_destroy_freelist( drm_device_t *dev )
{
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- DRM(free)(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
}
list_for_each_safe(ptr, tmp, &dev_priv->placeholders)
{
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- DRM(free)(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
}
list_for_each_safe(ptr, tmp, &dev_priv->free_list)
{
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- DRM(free)(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
}
}
@@ -1313,7 +1312,7 @@ int mach64_dma_buffers( DRM_IOCTL_ARGS )
DRM_CURRENTPID, d.request_count, dma->buf_count );
ret = DRM_ERR(EINVAL);
}
-
+
d.granted_count = 0;
if ( d.request_count )
@@ -1326,18 +1325,7 @@ int mach64_dma_buffers( DRM_IOCTL_ARGS )
return ret;
}
-static void mach64_driver_pretakedown(drm_device_t *dev)
-{
- mach64_do_cleanup_dma( dev );
-}
-
-void mach64_driver_register_fns(drm_device_t *dev)
+void mach64_driver_pretakedown(drm_device_t *dev)
{
- dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
- dev->fn_tbl.pretakedown = mach64_driver_pretakedown;
- dev->fn_tbl.vblank_wait = mach64_driver_vblank_wait;
- dev->fn_tbl.irq_preinstall = mach64_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = mach64_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = mach64_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = mach64_driver_irq_handler;
+ mach64_do_cleanup_dma( dev );
}
diff --git a/shared/mach64_drv.h b/shared/mach64_drv.h
index b49e6f65..f047b7ef 100644
--- a/shared/mach64_drv.h
+++ b/shared/mach64_drv.h
@@ -28,12 +28,24 @@
* Gareth Hughes <gareth@valinux.com>
* Frank C. Earl <fearl@airmail.net>
* Leif Delgass <ldelgass@retinalburn.net>
- * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
*/
#ifndef __MACH64_DRV_H__
#define __MACH64_DRV_H__
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR "Gareth Hughes, Leif Delgass, José Fonseca"
+
+#define DRIVER_NAME "mach64"
+#define DRIVER_DESC "DRM module for the ATI Rage Pro"
+#define DRIVER_DATE "20020904"
+
+#define DRIVER_MAJOR 1
+#define DRIVER_MINOR 0
+#define DRIVER_PATCHLEVEL 0
/* FIXME: remove these when not needed */
/* Development driver options */
@@ -102,6 +114,7 @@ extern int mach64_dma_idle( DRM_IOCTL_ARGS );
extern int mach64_dma_flush( DRM_IOCTL_ARGS );
extern int mach64_engine_reset( DRM_IOCTL_ARGS );
extern int mach64_dma_buffers( DRM_IOCTL_ARGS );
+extern void mach64_driver_pretakedown(drm_device_t *dev);
extern int mach64_init_freelist( drm_device_t *dev );
extern void mach64_destroy_freelist( drm_device_t *dev );
diff --git a/shared/mach64_irq.c b/shared/mach64_irq.c
index efa0641f..966c3c10 100644
--- a/shared/mach64_irq.c
+++ b/shared/mach64_irq.c
@@ -34,7 +34,6 @@
* Leif Delgass <ldelgass@retinalburn.net>
*/
-#include "mach64.h"
#include "drmP.h"
#include "drm.h"
#include "mach64_drm.h"
@@ -63,7 +62,7 @@ irqreturn_t mach64_driver_irq_handler( DRM_IRQ_ARGS )
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- DRM(vbl_send_signals)( dev );
+ drm_vbl_send_signals( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
diff --git a/shared/mach64_state.c b/shared/mach64_state.c
index ef85ffd8..127f67d2 100644
--- a/shared/mach64_state.c
+++ b/shared/mach64_state.c
@@ -26,10 +26,9 @@
* Authors:
* Gareth Hughes <gareth@valinux.com>
* Leif Delgass <ldelgass@retinalburn.net>
- * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
*/
-#include "mach64.h"
#include "drmP.h"
#include "drm.h"
#include "mach64_drm.h"
diff --git a/shared/mga_dma.c b/shared/mga_dma.c
index 0288f1c2..896787be 100644
--- a/shared/mga_dma.c
+++ b/shared/mga_dma.c
@@ -33,7 +33,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
@@ -308,7 +307,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
int i;
DRM_DEBUG( "count=%d\n", dma->buf_count );
- dev_priv->head = DRM(alloc)( sizeof(drm_mga_freelist_t),
+ dev_priv->head = drm_alloc( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
return DRM_ERR(ENOMEM);
@@ -320,7 +319,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
buf = dma->buflist[i];
buf_priv = buf->dev_private;
- entry = DRM(alloc)( sizeof(drm_mga_freelist_t),
+ entry = drm_alloc( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( entry == NULL )
return DRM_ERR(ENOMEM);
@@ -357,7 +356,7 @@ static void mga_freelist_cleanup( drm_device_t *dev )
entry = dev_priv->head;
while ( entry ) {
next = entry->next;
- DRM(free)( entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER );
+ drm_free( entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER );
entry = next;
}
@@ -458,7 +457,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
int ret;
DRM_DEBUG( "\n" );
- dev_priv = DRM(alloc)( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
+ dev_priv = drm_alloc( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
if ( !dev_priv )
return DRM_ERR(ENOMEM);
@@ -634,7 +633,7 @@ int mga_do_cleanup_dma( 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 ) {
drm_mga_private_t *dev_priv = dev->dev_private;
@@ -652,7 +651,7 @@ int mga_do_cleanup_dma( drm_device_t *dev )
mga_freelist_cleanup( dev );
}
- DRM(free)( dev->dev_private, sizeof(drm_mga_private_t),
+ drm_free( dev->dev_private, sizeof(drm_mga_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
@@ -800,30 +799,13 @@ int mga_dma_buffers( DRM_IOCTL_ARGS )
return ret;
}
-static void mga_driver_pretakedown(drm_device_t *dev)
+void mga_driver_pretakedown(drm_device_t *dev)
{
mga_do_cleanup_dma( dev );
}
-static int mga_driver_dma_quiescent(drm_device_t *dev)
+int mga_driver_dma_quiescent(drm_device_t *dev)
{
drm_mga_private_t *dev_priv = dev->dev_private;
return mga_do_wait_for_idle( dev_priv );
}
-
-void mga_driver_register_fns(drm_device_t *dev)
-{
- dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
- dev->fn_tbl.pretakedown = mga_driver_pretakedown;
- dev->fn_tbl.dma_quiescent = mga_driver_dma_quiescent;
- dev->fn_tbl.vblank_wait = mga_driver_vblank_wait;
- dev->fn_tbl.irq_preinstall = mga_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = mga_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = mga_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = mga_driver_irq_handler;
-
- dev->counters += 3;
- dev->types[6] = _DRM_STAT_IRQ;
- dev->types[7] = _DRM_STAT_PRIMARY;
- dev->types[8] = _DRM_STAT_SECONDARY;
-}
diff --git a/shared/mga_drv.h b/shared/mga_drv.h
index 75dcb0e9..3d8e9aef 100644
--- a/shared/mga_drv.h
+++ b/shared/mga_drv.h
@@ -31,6 +31,19 @@
#ifndef __MGA_DRV_H__
#define __MGA_DRV_H__
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
+
+#define DRIVER_NAME "mga"
+#define DRIVER_DESC "Matrox G200/G400"
+#define DRIVER_DATE "20021029"
+
+#define DRIVER_MAJOR 3
+#define DRIVER_MINOR 1
+#define DRIVER_PATCHLEVEL 0
+
typedef struct drm_mga_primary_buffer {
u8 *start;
u8 *end;
@@ -104,6 +117,8 @@ extern int mga_dma_init( DRM_IOCTL_ARGS );
extern int mga_dma_flush( DRM_IOCTL_ARGS );
extern int mga_dma_reset( DRM_IOCTL_ARGS );
extern int mga_dma_buffers( DRM_IOCTL_ARGS );
+extern void mga_driver_pretakedown(drm_device_t *dev);
+extern int mga_driver_dma_quiescent(drm_device_t *dev);
extern int mga_do_wait_for_idle( drm_mga_private_t *dev_priv );
extern int mga_do_dma_idle( drm_mga_private_t *dev_priv );
diff --git a/shared/mga_irq.c b/shared/mga_irq.c
index c3185b0b..bc0b6b5d 100644
--- a/shared/mga_irq.c
+++ b/shared/mga_irq.c
@@ -30,7 +30,6 @@
* Eric Anholt <anholt@FreeBSD.org>
*/
-#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
@@ -50,7 +49,7 @@ irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS )
MGA_WRITE( MGA_ICLEAR, MGA_VLINEICLR );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- DRM(vbl_send_signals)( dev );
+ drm_vbl_send_signals( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
diff --git a/shared/mga_state.c b/shared/mga_state.c
index 43659825..f676e974 100644
--- a/shared/mga_state.c
+++ b/shared/mga_state.c
@@ -32,7 +32,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
diff --git a/shared/mga_warp.c b/shared/mga_warp.c
index de1b911f..0a3a0cc7 100644
--- a/shared/mga_warp.c
+++ b/shared/mga_warp.c
@@ -27,7 +27,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "mga.h"
#include "drmP.h"
#include "drm.h"
#include "mga_drm.h"
diff --git a/shared/r128_cce.c b/shared/r128_cce.c
index 64c9b8be..809e6c8c 100644
--- a/shared/r128_cce.c
+++ b/shared/r128_cce.c
@@ -28,7 +28,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
@@ -355,7 +354,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_DEBUG( "\n" );
- dev_priv = DRM(alloc)( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );
+ dev_priv = drm_alloc( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
@@ -544,7 +543,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv->ring.end = ((u32 *)dev_priv->cce_ring->handle
+ init->ring_size / sizeof(u32));
dev_priv->ring.size = init->ring_size;
- dev_priv->ring.size_l2qw = DRM(order)( init->ring_size / 8 );
+ dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 );
dev_priv->ring.tail_mask =
(dev_priv->ring.size / sizeof(u32)) - 1;
@@ -561,7 +560,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
#if __OS_HAS_AGP
if ( dev_priv->is_pci ) {
#endif
- if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
+ if (!drm_ati_pcigart_init( dev, &dev_priv->phys_pci_gart,
&dev_priv->bus_pci_gart) ) {
DRM_ERROR( "failed to init PCI GART!\n" );
dev->dev_private = (void *)dev_priv;
@@ -590,7 +589,7 @@ int r128_do_cleanup_cce( 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 ) {
drm_r128_private_t *dev_priv = dev->dev_private;
@@ -608,13 +607,13 @@ int r128_do_cleanup_cce( drm_device_t *dev )
} else
#endif
{
- if (!DRM(ati_pcigart_cleanup)( dev,
+ if (!drm_ati_pcigart_cleanup( dev,
dev_priv->phys_pci_gart,
dev_priv->bus_pci_gart ))
DRM_ERROR( "failed to cleanup PCI GART!\n" );
}
- DRM(free)( dev->dev_private, sizeof(drm_r128_private_t),
+ drm_free( dev->dev_private, sizeof(drm_r128_private_t),
DRM_MEM_DRIVER );
dev->dev_private = NULL;
}
@@ -773,7 +772,7 @@ static int r128_freelist_init( drm_device_t *dev )
drm_r128_freelist_t *entry;
int i;
- dev_priv->head = DRM(alloc)( sizeof(drm_r128_freelist_t),
+ dev_priv->head = drm_alloc( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
return DRM_ERR(ENOMEM);
@@ -785,7 +784,7 @@ static int r128_freelist_init( drm_device_t *dev )
buf = dma->buflist[i];
buf_priv = buf->dev_private;
- entry = DRM(alloc)( sizeof(drm_r128_freelist_t),
+ entry = drm_alloc( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
if ( !entry ) return DRM_ERR(ENOMEM);
diff --git a/shared/r128_drv.h b/shared/r128_drv.h
index 5b91256c..9cec2f3e 100644
--- a/shared/r128_drv.h
+++ b/shared/r128_drv.h
@@ -28,12 +28,25 @@
* Rickard E. (Rik) Faith <faith@valinux.com>
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
- * Michel Dänzer <daenzerm@student.ethz.ch>
+ * Michel D�zer <daenzerm@student.ethz.ch>
*/
#ifndef __R128_DRV_H__
#define __R128_DRV_H__
+/* General customization:
+ */
+#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
+
+#define DRIVER_NAME "r128"
+#define DRIVER_DESC "ATI Rage 128"
+#define DRIVER_DATE "20030725"
+
+#define DRIVER_MAJOR 2
+#define DRIVER_MINOR 5
+#define DRIVER_PATCHLEVEL 0
+
+
#define GET_RING_HEAD(dev_priv) R128_READ( R128_PM4_BUFFER_DL_RPTR )
typedef struct drm_r128_freelist {
@@ -148,6 +161,8 @@ extern irqreturn_t r128_driver_irq_handler( DRM_IRQ_ARGS );
extern void r128_driver_irq_preinstall( drm_device_t *dev );
extern void r128_driver_irq_postinstall( drm_device_t *dev );
extern void r128_driver_irq_uninstall( drm_device_t *dev );
+extern void r128_driver_pretakedown(drm_device_t *dev);
+extern void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp);
/* Register definitions, register access macros and drmAddMap constants
* for Rage 128 kernel driver.
diff --git a/shared/r128_irq.c b/shared/r128_irq.c
index be1b9dac..643a3078 100644
--- a/shared/r128_irq.c
+++ b/shared/r128_irq.c
@@ -30,7 +30,6 @@
* Eric Anholt <anholt@FreeBSD.org>
*/
-#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
@@ -50,7 +49,7 @@ irqreturn_t r128_driver_irq_handler( DRM_IRQ_ARGS )
R128_WRITE( R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK );
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- DRM(vbl_send_signals)( dev );
+ drm_vbl_send_signals( dev );
return IRQ_HANDLED;
}
return IRQ_NONE;
diff --git a/shared/r128_state.c b/shared/r128_state.c
index 5b8af9f9..ed643682 100644
--- a/shared/r128_state.c
+++ b/shared/r128_state.c
@@ -27,7 +27,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "r128.h"
#include "drmP.h"
#include "drm.h"
#include "r128_drm.h"
@@ -926,24 +925,24 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
buffer_size = depth->n * sizeof(u32);
- buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
+ buffer = drm_alloc( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL )
return DRM_ERR(ENOMEM);
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS);
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS);
return DRM_ERR(EFAULT);
}
mask_size = depth->n * sizeof(u8);
if ( depth->mask ) {
- mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
+ mask = drm_alloc( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
- DRM(free)( mask, mask_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -970,7 +969,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM(free)( mask, mask_size, DRM_MEM_BUFS );
+ drm_free( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++, x++ ) {
BEGIN_RING( 6 );
@@ -994,7 +993,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
@@ -1016,54 +1015,54 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
+ x = drm_alloc( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
- y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
+ y = drm_alloc( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, xbuf_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
buffer_size = depth->n * sizeof(u32);
- buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
+ buffer = drm_alloc( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( depth->mask ) {
mask_size = depth->n * sizeof(u8);
- mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
+ mask = drm_alloc( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
- DRM(free)( mask, mask_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -1090,7 +1089,7 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM(free)( mask, mask_size, DRM_MEM_BUFS );
+ drm_free( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++ ) {
BEGIN_RING( 6 );
@@ -1114,9 +1113,9 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
- DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
@@ -1184,23 +1183,23 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
+ x = drm_alloc( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
- y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
+ y = drm_alloc( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, ybuf_size ) ) {
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -1228,8 +1227,8 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
ADVANCE_RING();
}
- DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
- DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ drm_free( x, xbuf_size, DRM_MEM_BUFS );
+ drm_free( y, ybuf_size, DRM_MEM_BUFS );
return 0;
}
@@ -1695,7 +1694,7 @@ int r128_getparam( DRM_IOCTL_ARGS )
return 0;
}
-static void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_r128_private_t *dev_priv = dev->dev_private;
@@ -1705,20 +1704,7 @@ static void r128_driver_prerelease(drm_device_t *dev, DRMFILE filp)
}
}
-static void r128_driver_pretakedown(drm_device_t *dev)
+void r128_driver_pretakedown(drm_device_t *dev)
{
r128_do_cleanup_cce( dev );
}
-
-void r128_driver_register_fns(drm_device_t *dev)
-{
- dev->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->dev_priv_size = sizeof(drm_r128_buf_priv_t);
- dev->fn_tbl.prerelease = r128_driver_prerelease;
- dev->fn_tbl.pretakedown = r128_driver_pretakedown;
- dev->fn_tbl.vblank_wait = r128_driver_vblank_wait;
- dev->fn_tbl.irq_preinstall = r128_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = r128_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = r128_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = r128_driver_irq_handler;
-}
diff --git a/shared/radeon_cp.c b/shared/radeon_cp.c
index cbde7ce9..78c41b5d 100644
--- a/shared/radeon_cp.c
+++ b/shared/radeon_cp.c
@@ -28,7 +28,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
@@ -1216,7 +1215,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv->ring.end = ((u32 *)dev_priv->cp_ring->handle
+ init->ring_size / sizeof(u32));
dev_priv->ring.size = init->ring_size;
- dev_priv->ring.size_l2qw = DRM(order)( init->ring_size / 8 );
+ dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 );
dev_priv->ring.tail_mask =
(dev_priv->ring.size / sizeof(u32)) - 1;
@@ -1230,7 +1229,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
} else
#endif
{
- if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
+ if (!drm_ati_pcigart_init( dev, &dev_priv->phys_pci_gart,
&dev_priv->bus_pci_gart)) {
DRM_ERROR( "failed to init PCI GART!\n" );
radeon_do_cleanup_cp(dev);
@@ -1260,7 +1259,7 @@ int radeon_do_cleanup_cp( 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 __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
@@ -1279,7 +1278,7 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
} else
#endif
{
- if (!DRM(ati_pcigart_cleanup)( dev,
+ if (!drm_ati_pcigart_cleanup( dev,
dev_priv->phys_pci_gart,
dev_priv->bus_pci_gart ))
DRM_ERROR( "failed to cleanup PCI GART!\n" );
@@ -1734,7 +1733,7 @@ int radeon_preinit( struct drm_device *dev, unsigned long flags )
drm_radeon_private_t *dev_priv;
int ret = 0;
- dev_priv = DRM(alloc)( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER );
+ dev_priv = drm_alloc( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
return DRM_ERR(ENOMEM);
@@ -1743,12 +1742,12 @@ int radeon_preinit( struct drm_device *dev, unsigned long flags )
dev_priv->flags = flags;
/* registers */
- if( (ret = DRM(initmap)( dev, pci_resource_start( dev->pdev, 2 ),
+ if( (ret = drm_initmap( dev, pci_resource_start( dev->pdev, 2 ),
pci_resource_len( dev->pdev, 2 ), _DRM_REGISTERS, 0 )))
return ret;
/* framebuffer */
- if( (ret = DRM(initmap)( dev, pci_resource_start( dev->pdev, 0 ),
+ if( (ret = drm_initmap( dev, pci_resource_start( dev->pdev, 0 ),
pci_resource_len( dev->pdev, 0 ), _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING )))
return ret;
@@ -1776,11 +1775,6 @@ int radeon_preinit( struct drm_device *dev, unsigned long flags )
return ret;
}
-int radeon_postinit( struct drm_device *dev, unsigned long flags )
-{
- return 0;
-}
-
int radeon_postcleanup( struct drm_device *dev )
{
drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -1789,7 +1783,7 @@ int radeon_postcleanup( struct drm_device *dev )
#if defined(__linux__)
radeon_delete_i2c_busses(dev);
#endif
- DRM(free)( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER );
+ drm_free( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER );
dev->dev_private = NULL;
return 0;
diff --git a/shared/radeon_drv.h b/shared/radeon_drv.h
index ccb1654f..75c02e7a 100644
--- a/shared/radeon_drv.h
+++ b/shared/radeon_drv.h
@@ -31,6 +31,20 @@
#ifndef __RADEON_DRV_H__
#define __RADEON_DRV_H__
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR "Gareth Hughes, Keith Whitwell, others."
+
+#define DRIVER_NAME "radeon"
+#define DRIVER_DESC "ATI Radeon"
+#define DRIVER_DATE "20020828"
+
+#define DRIVER_MAJOR 1
+#define DRIVER_MINOR 11
+#define DRIVER_PATCHLEVEL 0
+
+
enum radeon_family {
CHIP_R100,
CHIP_RS100,
@@ -247,6 +261,10 @@ extern irqreturn_t radeon_driver_irq_handler( DRM_IRQ_ARGS );
extern void radeon_driver_irq_preinstall( drm_device_t *dev );
extern void radeon_driver_irq_postinstall( drm_device_t *dev );
extern void radeon_driver_irq_uninstall( drm_device_t *dev );
+extern void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp);
+extern void radeon_driver_pretakedown(drm_device_t *dev);
+extern int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv);
+extern void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv);
/* Flags for stats.boxes
*/
diff --git a/shared/radeon_irq.c b/shared/radeon_irq.c
index bdb3cc16..b7deca73 100644
--- a/shared/radeon_irq.c
+++ b/shared/radeon_irq.c
@@ -27,10 +27,9 @@
*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
- * Michel Dänzer <michel@daenzer.net>
+ * Michel D�zer <michel@daenzer.net>
*/
-#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
@@ -78,7 +77,7 @@ irqreturn_t radeon_driver_irq_handler( DRM_IRQ_ARGS )
if (stat & RADEON_CRTC_VBLANK_STAT) {
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- DRM(vbl_send_signals)( dev );
+ drm_vbl_send_signals( dev );
}
/* Acknowledge interrupts we handle */
@@ -223,7 +222,7 @@ int radeon_irq_wait( DRM_IOCTL_ARGS )
/* drm_dma.h hooks
*/
-void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+void radeon_driver_irq_preinstall( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
@@ -234,7 +233,7 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
radeon_acknowledge_irqs( dev_priv );
}
-void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+void radeon_driver_irq_postinstall( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
@@ -247,7 +246,7 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
RADEON_SW_INT_ENABLE );
}
-void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+void radeon_driver_irq_uninstall( drm_device_t *dev ) {
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
if (!dev_priv)
diff --git a/shared/radeon_mem.c b/shared/radeon_mem.c
index 9d7fded7..17483dd1 100644
--- a/shared/radeon_mem.c
+++ b/shared/radeon_mem.c
@@ -29,7 +29,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "radeon_drm.h"
@@ -44,7 +43,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
+ struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start;
@@ -60,7 +59,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
+ struct mem_block *newblock = drm_alloc(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start + size;
@@ -118,7 +117,7 @@ static void free_block( struct mem_block *p )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM(free)(q, sizeof(*q), DRM_MEM_BUFS );
+ drm_free(q, sizeof(*q), DRM_MEM_BUFS );
}
if (p->prev->filp == 0) {
@@ -126,7 +125,7 @@ static void free_block( struct mem_block *p )
q->size += p->size;
q->next = p->next;
q->next->prev = q;
- DRM(free)(p, sizeof(*q), DRM_MEM_BUFS );
+ drm_free(p, sizeof(*q), DRM_MEM_BUFS );
}
}
@@ -134,14 +133,14 @@ static void free_block( struct mem_block *p )
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
- struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFS );
+ struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFS );
if (!blocks)
return DRM_ERR(ENOMEM);
- *heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFS );
+ *heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFS );
if (!*heap) {
- DRM(free)( blocks, sizeof(*blocks), DRM_MEM_BUFS );
+ drm_free( blocks, sizeof(*blocks), DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
@@ -180,7 +179,7 @@ void radeon_mem_release( DRMFILE filp, struct mem_block *heap )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
+ drm_free(q, sizeof(*q),DRM_MEM_DRIVER);
}
}
}
@@ -197,10 +196,10 @@ void radeon_mem_takedown( struct mem_block **heap )
for (p = (*heap)->next ; p != *heap ; ) {
struct mem_block *q = p;
p = p->next;
- DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
+ drm_free(q, sizeof(*q),DRM_MEM_DRIVER);
}
- DRM(free)( *heap, sizeof(**heap),DRM_MEM_DRIVER );
+ drm_free( *heap, sizeof(**heap),DRM_MEM_DRIVER );
*heap = NULL;
}
diff --git a/shared/radeon_state.c b/shared/radeon_state.c
index 9675da92..35fb16e9 100644
--- a/shared/radeon_state.c
+++ b/shared/radeon_state.c
@@ -27,7 +27,6 @@
* Kevin E. Martin <martin@valinux.com>
*/
-#include "radeon.h"
#include "drmP.h"
#include "drm.h"
#include "drm_sarea.h"
@@ -1598,7 +1597,7 @@ static int radeon_do_init_pageflip( drm_device_t *dev )
return 0;
}
-/* Called whenever a client dies, from DRM(release).
+/* Called whenever a client dies, from drm_release.
* NOTE: Lock isn't necessarily held when this is called!
*/
int radeon_do_cleanup_pageflip( drm_device_t *dev )
@@ -2560,7 +2559,7 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
*
* DRM infrastructure takes care of reclaiming dma buffers.
*/
-static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
+void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -2572,17 +2571,17 @@ static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
}
}
-static void radeon_driver_pretakedown(drm_device_t *dev)
+void radeon_driver_pretakedown(drm_device_t *dev)
{
radeon_do_release(dev);
}
-static int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
+int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
{
drm_radeon_private_t *dev_priv = dev->dev_private;
struct drm_radeon_driver_file_fields *radeon_priv;
- radeon_priv = (struct drm_radeon_driver_file_fields *)DRM(alloc)(sizeof(*radeon_priv), DRM_MEM_FILES);
+ radeon_priv = (struct drm_radeon_driver_file_fields *)drm_alloc(sizeof(*radeon_priv), DRM_MEM_FILES);
if (!radeon_priv)
return -ENOMEM;
@@ -2596,27 +2595,10 @@ static int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
return 0;
}
-static void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv)
+void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv)
{
struct drm_radeon_driver_file_fields *radeon_priv = filp_priv->driver_priv;
- DRM(free)(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
+ drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
}
-void radeon_driver_register_fns(struct drm_device *dev)
-{
- dev->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->dev_priv_size = sizeof(drm_radeon_buf_priv_t);
- dev->fn_tbl.preinit = radeon_preinit;
- dev->fn_tbl.postinit = radeon_postinit;
- dev->fn_tbl.postcleanup = radeon_postcleanup;
- dev->fn_tbl.prerelease = radeon_driver_prerelease;
- dev->fn_tbl.pretakedown = radeon_driver_pretakedown;
- dev->fn_tbl.open_helper = radeon_driver_open_helper;
- dev->fn_tbl.vblank_wait = radeon_driver_vblank_wait;
- dev->fn_tbl.irq_preinstall = radeon_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = radeon_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = radeon_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = radeon_driver_irq_handler;
- dev->fn_tbl.free_filp_priv = radeon_driver_free_filp_priv;
-}
diff --git a/shared/sis_drm.h b/shared/sis_drm.h
index 49505719..e99c3a43 100644
--- a/shared/sis_drm.h
+++ b/shared/sis_drm.h
@@ -3,12 +3,21 @@
#define __SIS_DRM_H__
/* SiS specific ioctls */
-#define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(0x44, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_FB_FREE DRM_IOW( 0x45, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(0x53, drm_sis_agp_t)
-#define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(0x54, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( 0x55, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_FB_INIT DRM_IOW( 0x56, drm_sis_fb_t)
+#define NOT_USED_0_3
+#define DRM_SIS_FB_ALLOC 0x04
+#define DRM_SIS_FB_FREE 0x05
+#define NOT_USED_6_12
+#define DRM_SIS_AGP_INIT 0x13
+#define DRM_SIS_AGP_ALLOC 0x14
+#define DRM_SIS_AGP_FREE 0x15
+#define DRM_SIS_FB_INIT 0x16
+
+#define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_FB_ALLOC, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_FB_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_FREE, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_INIT, drm_sis_agp_t)
+#define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_ALLOC, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_AGP_FREE, drm_sis_mem_t)
+#define DRM_IOCTL_SIS_FB_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_INIT, drm_sis_fb_t)
/*
#define DRM_IOCTL_SIS_FLIP DRM_IOW( 0x48, drm_sis_flip_t)
#define DRM_IOCTL_SIS_FLIP_INIT DRM_IO( 0x49)
diff --git a/shared/sis_drv.h b/shared/sis_drv.h
index 1ca618cf..7232b8f3 100644
--- a/shared/sis_drv.h
+++ b/shared/sis_drv.h
@@ -28,6 +28,17 @@
#ifndef _SIS_DRV_H_
#define _SIS_DRV_H_
+/* General customization:
+ */
+
+#define DRIVER_AUTHOR "SIS"
+#define DRIVER_NAME "sis"
+#define DRIVER_DESC "SIS 300/630/540"
+#define DRIVER_DATE "20030826"
+#define DRIVER_MAJOR 1
+#define DRIVER_MINOR 1
+#define DRIVER_PATCHLEVEL 0
+
#include "sis_ds.h"
typedef struct drm_sis_private {
diff --git a/shared/sis_ds.c b/shared/sis_ds.c
index 08391554..60bffa69 100644
--- a/shared/sis_ds.c
+++ b/shared/sis_ds.c
@@ -28,7 +28,6 @@
*
*/
-#include "sis.h"
#include "drmP.h"
#include "drm.h"
#include "sis_ds.h"
@@ -42,7 +41,7 @@ set_t *setInit(void)
int i;
set_t *set;
- set = (set_t *)DRM(alloc)(sizeof(set_t), DRM_MEM_DRIVER);
+ set = (set_t *)drm_alloc(sizeof(set_t), DRM_MEM_DRIVER);
if (set != NULL) {
for (i = 0; i < SET_SIZE; i++) {
set->list[i].free_next = i + 1;
@@ -128,7 +127,7 @@ int setNext(set_t *set, ITEM_TYPE *item)
int setDestroy(set_t *set)
{
- DRM(free)(set, sizeof(set_t), DRM_MEM_DRIVER);
+ drm_free(set, sizeof(set_t), DRM_MEM_DRIVER);
return 1;
}
@@ -167,7 +166,7 @@ memHeap_t *mmInit(int ofs,
if (size <= 0)
return NULL;
- blocks = (TMemBlock *)DRM(calloc)(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)drm_calloc(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
if (blocks != NULL) {
blocks->ofs = ofs;
blocks->size = size;
@@ -202,7 +201,7 @@ memHeap_t *mmAddRange( memHeap_t *heap,
int size )
{
PMemBlock blocks;
- blocks = (TMemBlock *)DRM(calloc)(2, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)drm_calloc(2, sizeof(TMemBlock), DRM_MEM_DRIVER);
if (blocks != NULL) {
blocks[0].size = size;
blocks[0].free = 1;
@@ -229,7 +228,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break left */
if (startofs > p->ofs) {
- newblock = (TMemBlock*) DRM(calloc)(1, sizeof(TMemBlock),
+ newblock = (TMemBlock*) drm_calloc(1, sizeof(TMemBlock),
DRM_MEM_DRIVER);
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
@@ -242,7 +241,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break right */
if (size < p->size) {
- newblock = (TMemBlock*) DRM(calloc)(1, sizeof(TMemBlock),
+ newblock = (TMemBlock*) drm_calloc(1, sizeof(TMemBlock),
DRM_MEM_DRIVER);
newblock->ofs = startofs + size;
newblock->size = p->size - size;
@@ -295,7 +294,7 @@ static __inline__ int Join2Blocks(TMemBlock *p)
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
- DRM(free)(q, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ drm_free(q, sizeof(TMemBlock), DRM_MEM_DRIVER);
return 1;
}
return 0;
@@ -380,7 +379,7 @@ void mmDestroy(memHeap_t *heap)
p = (TMemBlock *)heap;
while (p != NULL) {
q = p->next;
- DRM(free)(p, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ drm_free(p, sizeof(TMemBlock), DRM_MEM_DRIVER);
p = q;
}
}
diff --git a/shared/sis_mm.c b/shared/sis_mm.c
index 27b904fc..a895e0b8 100644
--- a/shared/sis_mm.c
+++ b/shared/sis_mm.c
@@ -28,7 +28,6 @@
*
*/
-#include "sis.h"
#include "drmP.h"
#include "sis_drm.h"
#include "sis_drv.h"
@@ -163,7 +162,7 @@ int sis_fb_init( DRM_IOCTL_ARGS )
DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_fb_t __user *)data, sizeof(fb));
if (dev_priv == NULL) {
- dev->dev_private = DRM(calloc)(1, sizeof(drm_sis_private_t),
+ dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
DRM_MEM_DRIVER);
dev_priv = dev->dev_private;
if (dev_priv == NULL)
@@ -251,7 +250,7 @@ int sis_ioctl_agp_init( DRM_IOCTL_ARGS )
drm_sis_agp_t agp;
if (dev_priv == NULL) {
- dev->dev_private = DRM(calloc)(1, sizeof(drm_sis_private_t),
+ dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
DRM_MEM_DRIVER);
dev_priv = dev->dev_private;
if (dev_priv == NULL)
@@ -408,10 +407,3 @@ int sis_final_context(struct drm_device *dev, int context)
return 1;
}
-
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
- dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR;
- dev->fn_tbl.context_ctor = sis_init_context;
- dev->fn_tbl.context_dtor = sis_final_context;
-}
diff --git a/shared/via_dma.c b/shared/via_dma.c
index 4afc5215..493c0b00 100644
--- a/shared/via_dma.c
+++ b/shared/via_dma.c
@@ -10,7 +10,6 @@
*
**************************************************************************/
-#include "via.h"
#include "drmP.h"
#include "drm.h"
#include "via_drm.h"
diff --git a/shared/via_drm.h b/shared/via_drm.h
index ddc89f83..ba94a4fe 100644
--- a/shared/via_drm.h
+++ b/shared/via_drm.h
@@ -62,16 +62,28 @@
#define VIA_UPLOAD_ALL 0xff
/* VIA specific ioctls */
-#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(0x40, drm_via_mem_t)
-#define DRM_IOCTL_VIA_FREEMEM DRM_IOW(0x41, drm_via_mem_t)
-#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(0x42, drm_via_agp_t)
-#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(0x43, drm_via_fb_t)
-#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(0x44, drm_via_init_t)
-#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW(0x45, drm_via_futex_t)
-#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(0x47, drm_via_dma_init_t)
-#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW(0x48, drm_via_cmdbuffer_t)
-#define DRM_IOCTL_VIA_FLUSH DRM_IO(0x49)
-#define DRM_IOCTL_VIA_PCICMD DRM_IOW(0x4A, drm_via_cmdbuffer_t)
+#define DRM_VIA_ALLOCMEM 0x00
+#define DRM_VIA_FREEMEM 0x01
+#define DRM_VIA_AGP_INIT 0x02
+#define DRM_VIA_FB_INIT 0x03
+#define DRM_VIA_MAP_INIT 0x04
+#define DRM_VIA_DEC_FUTEX 0x05
+#define NOT_USED
+#define DRM_VIA_DMA_INIT 0x07
+#define DRM_VIA_CMDBUFFER 0x08
+#define DRM_VIA_FLUSH 0x09
+#define DRM_VIA_PCICMD 0x0a
+
+#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
+#define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
+#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
+#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
+#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
+#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
+#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
+#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
+#define DRM_IOCTL_VIA_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_VIA_FLUSH)
+#define DRM_IOCTL_VIA_PCICMD DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
/* Indices into buf.Setup where various bits of state are mirrored per
diff --git a/shared/via_drv.c b/shared/via_drv.c
index 7b6e1b96..cec14e7a 100644
--- a/shared/via_drv.c
+++ b/shared/via_drv.c
@@ -23,7 +23,6 @@
*/
#include <linux/config.h>
-#include "via.h"
#include "drmP.h"
#include "via_drm.h"
#include "via_drv.h"
@@ -38,18 +37,95 @@
#define DRIVER_MINOR 5
#define DRIVER_PATCHLEVEL 0
+#include "drm_pciids.h"
-#define DRIVER_IOCTLS \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_ALLOCMEM)] = { via_mem_alloc, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_FREEMEM)] = { via_mem_free, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_AGP_INIT)] = { via_agp_init, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_FB_INIT)] = { via_fb_init, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_MAP_INIT)] = { via_map_init, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_DEC_FUTEX)] = { via_decoder_futex, 1, 0}, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_DMA_INIT)] = { via_dma_init, 1, 0}, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_CMDBUFFER)] = { via_cmdbuffer, 1, 0}, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_FLUSH)] = { via_flush_ioctl, 1, 0}, \
- [DRM_IOCTL_NR(DRM_IOCTL_VIA_PCICMD)] = { via_pci_cmdbuffer, 1, 0}
+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;
-#include "drm_core.h"
+ 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[] = {
+ viadrv_PCI_IDS
+};
+
+static drm_ioctl_desc_t ioctls[] = {
+ [DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = { via_mem_alloc, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = { via_mem_free, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = { via_agp_init, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = { via_fb_init, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = { via_map_init, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = { via_decoder_futex, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = { via_dma_init, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = { via_cmdbuffer, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_FLUSH)] = { via_flush_ioctl, 1, 0},
+ [DRM_IOCTL_NR(DRM_VIA_PCICMD)] = { via_pci_cmdbuffer, 1, 0}
+};
+
+static struct drm_driver_fn driver_fn = {
+ .driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL,
+ .context_ctor = via_init_context,
+ .context_dtor = via_final_context,
+ .vblank_wait = via_driver_vblank_wait,
+ .irq_preinstall = via_driver_irq_preinstall,
+ .irq_postinstall = via_driver_irq_postinstall,
+ .irq_uninstall = via_driver_irq_uninstall,
+ .irq_handler = via_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 via_init(void)
+{
+ return drm_init(&driver, pciidlist, &driver_fn);
+}
+
+static void __exit via_exit(void)
+{
+ drm_exit(&driver);
+}
+
+module_init(via_init);
+module_exit(via_exit);
+
+MODULE_AUTHOR( DRIVER_AUTHOR );
+MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_LICENSE("GPL and additional rights");
diff --git a/shared/via_ds.c b/shared/via_ds.c
index a29204ce..71af0c9b 100644
--- a/shared/via_ds.c
+++ b/shared/via_ds.c
@@ -38,7 +38,7 @@ set_t *via_setInit(void)
{
int i;
set_t *set;
- set = (set_t *)DRM(alloc)(sizeof(set_t), DRM_MEM_DRIVER);
+ set = (set_t *)drm_alloc(sizeof(set_t), DRM_MEM_DRIVER);
for (i = 0; i < SET_SIZE; i++) {
set->list[i].free_next = i+1;
set->list[i].alloc_next = -1;
@@ -120,7 +120,7 @@ int via_setNext(set_t *set, ITEM_TYPE *item)
int via_setDestroy(set_t *set)
{
- DRM(free)(set, sizeof(set_t), DRM_MEM_DRIVER);
+ drm_free(set, sizeof(set_t), DRM_MEM_DRIVER);
return 1;
}
@@ -161,7 +161,7 @@ memHeap_t *via_mmInit(int ofs,
return 0;
- blocks = (TMemBlock *)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)drm_calloc(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
if (blocks) {
blocks->ofs = ofs;
@@ -177,7 +177,7 @@ memHeap_t *via_mmAddRange(memHeap_t *heap,
int size)
{
PMemBlock blocks;
- blocks = (TMemBlock *)DRM(calloc)(2,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ blocks = (TMemBlock *)drm_calloc(2,sizeof(TMemBlock),DRM_MEM_DRIVER);
if (blocks) {
blocks[0].size = size;
@@ -206,7 +206,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break left */
if (startofs > p->ofs) {
- newblock = (TMemBlock*)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ newblock = (TMemBlock*)drm_calloc(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
newblock->free = 1;
@@ -218,7 +218,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break right */
if (size < p->size) {
- newblock = (TMemBlock*)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ newblock = (TMemBlock*)drm_calloc(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
newblock->ofs = startofs + size;
newblock->size = p->size - size;
newblock->free = 1;
@@ -277,7 +277,7 @@ static __inline__ int Join2Blocks(TMemBlock *p)
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
- DRM(free)(q,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ drm_free(q,sizeof(TMemBlock),DRM_MEM_DRIVER);
return 1;
}
@@ -384,7 +384,7 @@ void via_mmDestroy(memHeap_t *heap)
while (p) {
q = p->next;
- DRM(free)(p,sizeof(TMemBlock),DRM_MEM_DRIVER);
+ drm_free(p,sizeof(TMemBlock),DRM_MEM_DRIVER);
p = q;
}
}
diff --git a/shared/via_ds.h b/shared/via_ds.h
index 50ab3e7f..d9a60186 100644
--- a/shared/via_ds.h
+++ b/shared/via_ds.h
@@ -26,7 +26,6 @@
#ifndef _via_ds_h_
#define _via_ds_h_
-#include "via.h"
#include "drmP.h"
/* Set Data Structure */
diff --git a/shared/via_irq.c b/shared/via_irq.c
index eafb1d7d..b0a3349e 100644
--- a/shared/via_irq.c
+++ b/shared/via_irq.c
@@ -33,7 +33,6 @@
* interrupt.
*/
-#include "via.h"
#include "drmP.h"
#include "drm.h"
#include "via_drm.h"
@@ -58,7 +57,7 @@ irqreturn_t via_driver_irq_handler( DRM_IRQ_ARGS )
if(status & VIA_IRQ_VBI_PENDING){
atomic_inc(&dev->vbl_received);
DRM_WAKEUP(&dev->vbl_queue);
- DRM(vbl_send_signals)(dev);
+ drm_vbl_send_signals(dev);
handled = 1;
}
diff --git a/shared/via_map.c b/shared/via_map.c
index f08503d4..b7f0b43b 100644
--- a/shared/via_map.c
+++ b/shared/via_map.c
@@ -21,7 +21,6 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
-#include "via.h"
#include "drmP.h"
#include "via_drv.h"
@@ -32,7 +31,7 @@ int via_do_init_map(drm_device_t *dev, drm_via_init_t *init)
DRM_DEBUG("%s\n", __FUNCTION__);
- dev_priv = DRM(alloc)(sizeof(drm_via_private_t), DRM_MEM_DRIVER);
+ dev_priv = drm_alloc(sizeof(drm_via_private_t), DRM_MEM_DRIVER);
if (dev_priv == NULL)
return -ENOMEM;
@@ -84,7 +83,7 @@ int via_do_cleanup_map(drm_device_t *dev)
via_dma_cleanup(dev);
- DRM(free)(dev_priv, sizeof(drm_via_private_t),
+ drm_free(dev_priv, sizeof(drm_via_private_t),
DRM_MEM_DRIVER);
dev->dev_private = NULL;
}
diff --git a/shared/via_mm.c b/shared/via_mm.c
index 2a9be681..706f00d1 100644
--- a/shared/via_mm.c
+++ b/shared/via_mm.c
@@ -21,7 +21,6 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
-#include "via.h"
#include "drmP.h"
#include "via_drm.h"
#include "via_drv.h"
@@ -175,7 +174,7 @@ int via_final_context(struct drm_device *dev, int context)
/* Linux specific until context tracking code gets ported to BSD */
/* Last context, perform cleanup */
if (dev->ctx_count == 1 && dev->dev_private) {
- if (dev->irq) DRM(irq_uninstall)(dev);
+ if (dev->irq) drm_irq_uninstall(dev);
via_do_cleanup_map(dev);
}
@@ -211,13 +210,13 @@ int via_fb_alloc(drm_via_mem_t* mem)
drm_via_mm_t fb;
PMemBlock block;
int retval = 0;
-
+
if (!FBHeap)
return -1;
fb.size = mem->size;
fb.context = mem->context;
-
+
block = via_mmAllocMem(FBHeap, fb.size, 5, 0);
if (block) {
fb.offset = block->ofs;
@@ -234,13 +233,13 @@ int via_fb_alloc(drm_via_mem_t* mem)
fb.free = 0;
retval = -1;
}
-
+
mem->offset = fb.offset;
mem->index = fb.free;
DRM_DEBUG("alloc fb, size = %d, offset = %d\n", fb.size,
(int)fb.offset);
-
+
return retval;
}
int via_agp_alloc(drm_via_mem_t* mem)
@@ -270,7 +269,7 @@ int via_agp_alloc(drm_via_mem_t* mem)
agp.size = 0;
agp.free = 0;
}
-
+
mem->offset = agp.offset;
mem->index = agp.free;
@@ -282,7 +281,7 @@ int via_agp_alloc(drm_via_mem_t* mem)
int via_mem_free( DRM_IOCTL_ARGS )
{
drm_via_mem_t mem;
-
+
DRM_COPY_FROM_USER_IOCTL(mem, (drm_via_mem_t *)data, sizeof(mem));
switch (mem.type) {
@@ -296,22 +295,23 @@ int via_mem_free( DRM_IOCTL_ARGS )
return 0;
break;
}
-
+
return -EFAULT;
}
+
int via_fb_free(drm_via_mem_t* mem)
{
drm_via_mm_t fb;
int retval = 0;
-
+
if (!FBHeap) {
return -1;
}
fb.free = mem->index;
fb.context = mem->context;
-
+
if (!fb.free)
{
return -1;
@@ -319,50 +319,37 @@ int via_fb_free(drm_via_mem_t* mem)
}
via_mmFreeMem((PMemBlock)fb.free);
-
+
if (!del_alloc_set(fb.context, VIDEO, fb.free))
{
retval = -1;
}
-
+
DRM_DEBUG("free fb, free = %d\n", fb.free);
-
+
return retval;
-}
+}
+
int via_agp_free(drm_via_mem_t* mem)
{
drm_via_mm_t agp;
-
+
int retval = 0;
agp.free = mem->index;
agp.context = mem->context;
-
+
if (!agp.free)
return -1;
via_mmFreeMem((PMemBlock)agp.free);
-
+
if (!del_alloc_set(agp.context, AGP, agp.free)) {
retval = -1;
}
DRM_DEBUG("free agp, free = %d\n", agp.free);
-
+
return retval;
}
-EXPORT_SYMBOL(via_fb_alloc);
-EXPORT_SYMBOL(via_fb_free);
-
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
- dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL;
- dev->fn_tbl.context_ctor = via_init_context;
- dev->fn_tbl.context_dtor = via_final_context;
- dev->fn_tbl.vblank_wait = via_driver_vblank_wait;
- dev->fn_tbl.irq_preinstall = via_driver_irq_preinstall;
- dev->fn_tbl.irq_postinstall = via_driver_irq_postinstall;
- dev->fn_tbl.irq_uninstall = via_driver_irq_uninstall;
- dev->fn_tbl.irq_handler = via_driver_irq_handler;
-}