summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2004-08-24 11:15:53 +0000
committerDave Airlie <airlied@linux.ie>2004-08-24 11:15:53 +0000
commitd4dbf457813e97531ded3bf24f3b6ad421189c69 (patch)
tree8e47c1dd5d7cf9c8c4bce4a7e34531fc9a8eae75
parenteac498baeaf9b57b448065b0fb9f4eeadbb9aa6b (diff)
Merged drmfntbl-0-0-2drmfntbl-0-0-2-20040824-merge
-rw-r--r--linux-core/Makefile2
-rw-r--r--linux-core/drmP.h90
-rw-r--r--linux-core/drm_agpsupport.c5
-rw-r--r--linux-core/drm_bufs.c87
-rw-r--r--linux-core/drm_context.c21
-rw-r--r--linux-core/drm_dma.c39
-rw-r--r--linux-core/drm_drv.c186
-rw-r--r--linux-core/drm_fops.c10
-rw-r--r--linux-core/drm_ioctl.c7
-rw-r--r--linux-core/drm_irq.c88
-rw-r--r--linux-core/drm_memory.h18
-rw-r--r--linux-core/drm_memory_debug.h2
-rw-r--r--linux-core/drm_scatter.c6
-rw-r--r--linux-core/drm_vm.c36
-rw-r--r--linux-core/ffb_context.c18
-rw-r--r--linux-core/ffb_drv.c14
-rw-r--r--linux-core/i810_dma.c7
-rw-r--r--linux-core/i810_drv.c2
-rw-r--r--linux-core/i830_dma.c13
-rw-r--r--linux-core/i830_drv.c1
-rw-r--r--linux-core/i830_drv.h4
-rw-r--r--linux-core/i830_irq.c8
-rw-r--r--linux-core/i915_drv.c2
-rw-r--r--linux-core/mach64_drv.c1
-rw-r--r--linux-core/mga_drv.c1
-rw-r--r--linux-core/savage.h7
-rw-r--r--linux-core/savage_dma.c1
-rw-r--r--linux-core/savage_drv.c2
-rw-r--r--linux-core/sis_drv.c2
-rw-r--r--linux-core/tdfx_drv.c4
-rw-r--r--linux/Makefile2
-rw-r--r--linux/drmP.h90
-rw-r--r--linux/drm_agpsupport.h5
-rw-r--r--linux/drm_bufs.h87
-rw-r--r--linux/drm_context.h21
-rw-r--r--linux/drm_dma.h39
-rw-r--r--linux/drm_drv.h186
-rw-r--r--linux/drm_fops.h10
-rw-r--r--linux/drm_ioctl.h7
-rw-r--r--linux/drm_irq.h88
-rw-r--r--linux/drm_memory.h18
-rw-r--r--linux/drm_memory_debug.h2
-rw-r--r--linux/drm_scatter.h6
-rw-r--r--linux/drm_vm.h36
-rw-r--r--linux/ffb_context.c18
-rw-r--r--linux/ffb_drv.c14
-rw-r--r--linux/gamma.h12
-rw-r--r--linux/gamma_context.h14
-rw-r--r--linux/gamma_dma.c19
-rw-r--r--linux/gamma_drv.c3
-rw-r--r--linux/i810.h16
-rw-r--r--linux/i810_dma.c7
-rw-r--r--linux/i810_drv.c2
-rw-r--r--linux/i830.h17
-rw-r--r--linux/i830_dma.c13
-rw-r--r--linux/i830_drv.c1
-rw-r--r--linux/i830_drv.h4
-rw-r--r--linux/i830_irq.c8
-rw-r--r--linux/i915_drv.c2
-rw-r--r--linux/mach64_drv.c1
-rw-r--r--linux/mga_drv.c1
-rw-r--r--linux/savage.h7
-rw-r--r--linux/savage_dma.c1
-rw-r--r--linux/savage_drv.c2
-rw-r--r--linux/sis_drv.c2
-rw-r--r--linux/tdfx_drv.c4
-rw-r--r--shared-core/i915_dma.c5
-rw-r--r--shared-core/i915_drv.h4
-rw-r--r--shared-core/i915_irq.c8
-rw-r--r--shared-core/mach64_dma.c8
-rw-r--r--shared-core/mach64_drv.h6
-rw-r--r--shared-core/mach64_irq.c10
-rw-r--r--shared-core/mga_dma.c8
-rw-r--r--shared-core/mga_drv.h6
-rw-r--r--shared-core/mga_irq.c4
-rw-r--r--shared-core/r128_cce.c14
-rw-r--r--shared-core/r128_drv.h6
-rw-r--r--shared-core/r128_irq.c4
-rw-r--r--shared-core/r128_state.c8
-rw-r--r--shared-core/radeon_cp.c16
-rw-r--r--shared-core/radeon_drv.h8
-rw-r--r--shared-core/radeon_irq.c4
-rw-r--r--shared-core/radeon_state.c41
-rw-r--r--shared-core/sis_mm.c1
-rw-r--r--shared-core/tdfx_drv.h2
-rw-r--r--shared-core/via_drv.c1
-rw-r--r--shared-core/via_drv.h8
-rw-r--r--shared-core/via_irq.c11
-rw-r--r--shared-core/via_mm.c10
-rw-r--r--shared/i915.h8
-rw-r--r--shared/i915_dma.c5
-rw-r--r--shared/i915_drv.h4
-rw-r--r--shared/i915_irq.c8
-rw-r--r--shared/mach64.h13
-rw-r--r--shared/mach64_dma.c8
-rw-r--r--shared/mach64_drv.h6
-rw-r--r--shared/mach64_irq.c10
-rw-r--r--shared/mga.h11
-rw-r--r--shared/mga_dma.c8
-rw-r--r--shared/mga_drv.h6
-rw-r--r--shared/mga_irq.c4
-rw-r--r--shared/r128.h13
-rw-r--r--shared/r128_cce.c14
-rw-r--r--shared/r128_drv.h6
-rw-r--r--shared/r128_irq.c4
-rw-r--r--shared/r128_state.c8
-rw-r--r--shared/radeon.h16
-rw-r--r--shared/radeon_cp.c16
-rw-r--r--shared/radeon_drv.h8
-rw-r--r--shared/radeon_irq.c4
-rw-r--r--shared/radeon_state.c41
-rw-r--r--shared/sis.h4
-rw-r--r--shared/sis_mm.c1
-rw-r--r--shared/tdfx.h2
-rw-r--r--shared/via.h10
-rw-r--r--shared/via_drv.c1
-rw-r--r--shared/via_drv.h8
-rw-r--r--shared/via_irq.c11
-rw-r--r--shared/via_mm.c10
119 files changed, 984 insertions, 926 deletions
diff --git a/linux-core/Makefile b/linux-core/Makefile
index 658d9d87..f677f63d 100644
--- a/linux-core/Makefile
+++ b/linux-core/Makefile
@@ -50,7 +50,7 @@ endif
MACHINE := $(shell uname -m)
# Modules for all architectures
-MODULE_LIST := gamma.o tdfx.o r128.o radeon.o mga.o sis.o savage.o via.o mach64.o
+MODULE_LIST := 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)))
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 4271a7a2..e84685de 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -90,27 +90,20 @@
/** \name DRM template customization defaults */
/*@{*/
-#ifndef __HAVE_AGP
-#define __HAVE_AGP 0
-#endif
-#ifndef __HAVE_MTRR
-#define __HAVE_MTRR 0
-#endif
-#ifndef __HAVE_CTX_BITMAP
-#define __HAVE_CTX_BITMAP 0
-#endif
-#ifndef __HAVE_DMA
-#define __HAVE_DMA 0
-#endif
-#ifndef __HAVE_IRQ
-#define __HAVE_IRQ 0
-#endif
-
-#define __REALLY_HAVE_AGP (__HAVE_AGP && (defined(CONFIG_AGP) || \
- defined(CONFIG_AGP_MODULE)))
-#define __REALLY_HAVE_MTRR (__HAVE_MTRR && defined(CONFIG_MTRR))
-#define __REALLY_HAVE_SG (__HAVE_SG)
-
+/* driver capabilities and requirements mask */
+#define DRIVER_USE_AGP 0x1
+#define DRIVER_REQUIRE_AGP 0x2
+#define DRIVER_USE_MTRR 0x4
+#define DRIVER_HAVE_DMA 0x10
+#define DRIVER_HAVE_IRQ 0x20
+#define DRIVER_SG 0x40
+#define DRIVER_PCI_DMA 0x80
+#define DRIVER_IRQ_SHARED 0x100
+#define DRIVER_IRQ_VBL 0x200
+#define DRIVER_DMA_QUEUE 0x800
+
+#define __OS_HAS_AGP (defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE))
+#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
/*@}*/
@@ -378,9 +371,7 @@ typedef struct drm_file {
struct drm_device *dev;
int remove_auth_on_close;
unsigned long lock_count;
-#ifdef DRIVER_FILE_FIELDS
- DRIVER_FILE_FIELDS;
-#endif
+ void *driver_priv;
} drm_file_t;
/** Wait queue */
@@ -438,7 +429,7 @@ typedef struct drm_device_dma {
/*@}*/
} drm_device_dma_t;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
/**
* AGP memory entry. Stored as a doubly linked list.
*/
@@ -504,7 +495,6 @@ typedef struct drm_ctx_list {
drm_file_t *tag; /**< associated fd private data */
} drm_ctx_list_t;
-#ifdef __HAVE_VBL_IRQ
typedef struct drm_vbl_sig {
struct list_head head;
@@ -513,7 +503,6 @@ typedef struct drm_vbl_sig {
struct task_struct *task;
} drm_vbl_sig_t;
-#endif
/**
* DRM device functions structure
@@ -528,7 +517,11 @@ struct drm_driver_fn {
int (*postcleanup)(struct drm_device *);
int (*presetup)(struct drm_device *);
int (*postsetup)(struct drm_device *);
- void (*open_helper)(struct drm_device *, drm_file_t *);
+
+ /* these are opposites at the moment */
+ int (*open_helper)(struct drm_device *, drm_file_t *);
+ void (*free_filp_private)(struct drm_device *, drm_file_t *);
+
void (*release)(struct drm_device *, struct file *filp);
void (*dma_ready)(struct drm_device *);
int (*dma_quiescent)(struct drm_device *);
@@ -542,7 +535,17 @@ struct drm_driver_fn {
int (*waitlist_destroy)(drm_waitlist_t *bl);
int (*freelist_create)(drm_freelist_t *bl, int count);
int (*freelist_put)(struct drm_device *dev, drm_freelist_t *bl, drm_buf_t *buf);
- int (*freelist_destroy)(drm_freelist_t *bl);
+ int (*freelist_destroy)(drm_freelist_t *bl);
+ int (*vblank_wait)(struct drm_device *dev, unsigned int *sequence);
+/* these have to be filled in */
+ irqreturn_t (*irq_handler)( DRM_IRQ_ARGS );
+ void (*irq_preinstall)(struct drm_device *dev);
+ void (*irq_postinstall)(struct drm_device *dev);
+ void (*irq_uninstall)(struct drm_device *dev);
+ void (*reclaim_buffers)(struct file *filp);
+ 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);
};
/**
@@ -637,13 +640,13 @@ typedef struct drm_device {
#endif
/** \name VBLANK IRQ support */
/*@{*/
-#ifdef __HAVE_VBL_IRQ
+
wait_queue_head_t vbl_queue; /**< VBLANK wait queue */
atomic_t vbl_received;
spinlock_t vbl_lock;
drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */
unsigned int vbl_pending;
-#endif
+
/*@}*/
cycles_t ctx_start;
cycles_t lck_start;
@@ -656,7 +659,7 @@ typedef struct drm_device {
wait_queue_head_t buf_readers; /**< Processes waiting to read */
wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
drm_agp_head_t *agp; /**< AGP data */
#endif
@@ -682,6 +685,7 @@ typedef struct drm_device {
struct drm_driver_fn fn_tbl;
drm_local_map_t *agp_buffer_map;
int dev_priv_size;
+ u32 driver_features;
} drm_device_t;
extern void DRM(driver_register_fns)(struct drm_device *dev);
@@ -742,7 +746,7 @@ 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);
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
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);
@@ -784,10 +788,8 @@ extern int DRM(rmctx)( struct inode *inode, struct file *filp,
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);
-#if __HAVE_CTX_BITMAP
extern int DRM(ctxbitmap_init)( drm_device_t *dev );
extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev );
-#endif
extern int DRM(setsareactx)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
@@ -833,7 +835,6 @@ 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,
unsigned int size, int type, int flags );
-#if __HAVE_DMA
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,
@@ -850,33 +851,24 @@ 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 );
-#endif /* __HAVE_DMA */
/* IRQ support (drm_irq.h) */
-#if __HAVE_IRQ || __HAVE_DMA
extern int DRM(control)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
-#endif
-#if __HAVE_IRQ
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 );
-#ifdef __HAVE_VBL_IRQ
+
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 );
-#endif
-#ifdef __HAVE_IRQ_BH
-extern void DRM(irq_immediate_bh)( void *dev );
-#endif
-#endif
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
/* AGP/GART support (drm_agpsupport.h) */
extern drm_agp_head_t *DRM(agp_init)(void);
extern void DRM(agp_uninit)(void);
@@ -918,14 +910,12 @@ extern int DRM(proc_cleanup)(int minor,
struct proc_dir_entry *root,
struct proc_dir_entry *dev_root);
-#ifdef __HAVE_SG
/* 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,
unsigned int cmd, unsigned long arg);
extern int DRM(sg_free)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
-#endif
/* ATI PCIGART support (ati_pcigart.h) */
extern int DRM(ati_pcigart_init)(drm_device_t *dev,
@@ -977,5 +967,7 @@ static __inline__ void drm_core_dropmap(struct drm_map *map)
}
/*@}*/
+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 c4f0e465..12a8ba11 100644
--- a/linux-core/drm_agpsupport.c
+++ b/linux-core/drm_agpsupport.c
@@ -35,8 +35,7 @@
#include "drmP.h"
#include <linux/module.h>
-#if __REALLY_HAVE_AGP
-
+#if __OS_HAS_AGP
#define DRM_AGP_GET (drm_agp_t *)inter_module_get("drm_agp")
#define DRM_AGP_PUT inter_module_put("drm_agp")
@@ -471,4 +470,4 @@ int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle)
return drm_agp->unbind_memory(handle);
}
-#endif /* __REALLY_HAVE_AGP */
+#endif /* __OS_HAS_AGP */
diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c
index 7ae95fcc..95858b80 100644
--- a/linux-core/drm_bufs.c
+++ b/linux-core/drm_bufs.c
@@ -37,14 +37,6 @@
#include <linux/vmalloc.h>
#include "drmP.h"
-#ifndef __HAVE_PCI_DMA
-#define __HAVE_PCI_DMA 0
-#endif
-
-#ifndef __HAVE_SG
-#define __HAVE_SG 0
-#endif
-
/**
* Compute size order. Returns the exponent of the smaller power of two which
* is greater or equal to given number.
@@ -111,11 +103,13 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int
#ifdef __alpha__
map->offset += dev->hose->mem_space->start;
#endif
-#if __REALLY_HAVE_MTRR
- if ( map->type == _DRM_FRAME_BUFFER ||
- (map->flags & _DRM_WRITE_COMBINING) ) {
- map->mtrr = mtrr_add( map->offset, map->size,
- MTRR_TYPE_WRCOMB, 1 );
+#if __OS_HAS_MTRR
+ if ( dev->driver_features & DRIVER_USE_MTRR) {
+ if ( map->type == _DRM_FRAME_BUFFER ||
+ (map->flags & _DRM_WRITE_COMBINING) ) {
+ map->mtrr = mtrr_add( map->offset, map->size,
+ MTRR_TYPE_WRCOMB, 1 );
+ }
}
#endif
if (map->type == _DRM_REGISTERS)
@@ -130,7 +124,6 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int
return 0;
}
-
/**
* Ioctl to specify a range of memory that is available for mapping by a non-root process.
*
@@ -208,11 +201,13 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
#ifdef __alpha__
map->offset += dev->hose->mem_space->start;
#endif
-#if __REALLY_HAVE_MTRR
- if ( map->type == _DRM_FRAME_BUFFER ||
- (map->flags & _DRM_WRITE_COMBINING) ) {
- map->mtrr = mtrr_add( map->offset, map->size,
- MTRR_TYPE_WRCOMB, 1 );
+#if __OS_HAS_MTRR
+ if (dev->driver_features & DRIVER_USE_MTRR) {
+ if ( map->type == _DRM_FRAME_BUFFER ||
+ (map->flags & _DRM_WRITE_COMBINING) ) {
+ map->mtrr = mtrr_add( map->offset, map->size,
+ MTRR_TYPE_WRCOMB, 1 );
+ }
}
#endif
if (map->type == _DRM_REGISTERS)
@@ -240,13 +235,15 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
dev->lock.hw_lock = map->handle; /* Pointer to lock */
}
break;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
case _DRM_AGP:
+ if (dev->driver_features & DRIVER_USE_AGP) {
#ifdef __alpha__
- map->offset += dev->hose->mem_space->start;
+ map->offset += dev->hose->mem_space->start;
#endif
- map->offset += dev->agp->base;
- map->mtrr = dev->agp->agp_mtrr; /* for getmap */
+ map->offset += dev->agp->base;
+ map->mtrr = dev->agp->agp_mtrr; /* for getmap */
+ }
break;
#endif
case _DRM_SCATTER_GATHER:
@@ -368,8 +365,6 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
return 0;
}
-#if __HAVE_DMA
-
/**
* Cleanup after an error on one of the addbufs() functions.
*
@@ -417,7 +412,7 @@ static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry)
}
}
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
/**
* Add AGP buffers for DMA transfers (ioctl).
*
@@ -602,9 +597,8 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
atomic_dec( &dev->buf_alloc );
return 0;
}
-#endif /* __REALLY_HAVE_AGP */
+#endif /* __OS_HAS_AGP */
-#if __HAVE_PCI_DMA
int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
@@ -629,6 +623,8 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
drm_buf_t **temp_buflist;
drm_buf_desc_t __user *argp = (void __user *)arg;
+ if (!(dev->driver_features & DRIVER_PCI_DMA)) return -EINVAL;
+
if ( !dma ) return -EINVAL;
if ( copy_from_user( &request, argp, sizeof(request) ) )
@@ -842,9 +838,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
return 0;
}
-#endif /* __HAVE_PCI_DMA */
-#if __HAVE_SG
int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
@@ -867,6 +861,8 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
int i;
drm_buf_t **temp_buflist;
+ if (!(dev->driver_features & DRIVER_SG)) return -EINVAL;
+
if ( !dma ) return -EINVAL;
if ( copy_from_user( &request, argp, sizeof(request) ) )
@@ -1016,7 +1012,6 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
atomic_dec( &dev->buf_alloc );
return 0;
}
-#endif /* __HAVE_SG */
/**
* Add buffers for DMA transfers (ioctl).
@@ -1036,26 +1031,25 @@ int DRM(addbufs)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_buf_desc_t request;
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
if ( copy_from_user( &request, (drm_buf_desc_t __user *)arg,
sizeof(request) ) )
return -EFAULT;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( request.flags & _DRM_AGP_BUFFER )
return DRM(addbufs_agp)( inode, filp, cmd, arg );
else
#endif
-#if __HAVE_SG
if ( request.flags & _DRM_SG_BUFFER )
return DRM(addbufs_sg)( inode, filp, cmd, arg );
else
-#endif
-#if __HAVE_PCI_DMA
return DRM(addbufs_pci)( inode, filp, cmd, arg );
-#else
- return -EINVAL;
-#endif
}
@@ -1087,6 +1081,9 @@ int DRM(infobufs)( struct inode *inode, struct file *filp,
int i;
int count;
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
+
if ( !dma ) return -EINVAL;
spin_lock( &dev->count_lock );
@@ -1168,6 +1165,9 @@ int DRM(markbufs)( struct inode *inode, struct file *filp,
int order;
drm_buf_entry_t *entry;
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
+
if ( !dma ) return -EINVAL;
if ( copy_from_user( &request,
@@ -1215,6 +1215,9 @@ int DRM(freebufs)( struct inode *inode, struct file *filp,
int idx;
drm_buf_t *buf;
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
+
if ( !dma ) return -EINVAL;
if ( copy_from_user( &request,
@@ -1272,6 +1275,9 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
drm_buf_map_t request;
int i;
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
+
if ( !dma ) return -EINVAL;
spin_lock( &dev->count_lock );
@@ -1286,8 +1292,8 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
return -EFAULT;
if ( request.count >= dma->buf_count ) {
- if ( (__HAVE_AGP && (dma->flags & _DRM_DMA_USE_AGP)) ||
- (__HAVE_SG && (dma->flags & _DRM_DMA_USE_SG)) ) {
+ if (( (dev->driver_features & DRIVER_USE_AGP) && (dma->flags & _DRM_DMA_USE_AGP)) ||
+ ( (dev->driver_features & DRIVER_SG) && (dma->flags & _DRM_DMA_USE_SG)) ) {
drm_map_t *map = dev->agp_buffer_map;
if ( !map ) {
@@ -1369,4 +1375,3 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
return retcode;
}
-#endif /* __HAVE_DMA */
diff --git a/linux-core/drm_context.c b/linux-core/drm_context.c
index dd280e53..cf3a536a 100644
--- a/linux-core/drm_context.c
+++ b/linux-core/drm_context.c
@@ -1,5 +1,5 @@
/**
- * \file drm_context.h
+* \file drm_context.h
* IOCTLs for generic contexts
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
@@ -43,11 +43,7 @@
#define __NO_VERSION__
#include "drmP.h"
-#if !__HAVE_CTX_BITMAP
-#error "__HAVE_CTX_BITMAP must be defined"
-#endif
-
-
+#ifndef DRIVER_ALTERNATE_CONTEXT
/******************************************************************/
/** \name Context bitmap support */
/*@{*/
@@ -579,5 +575,18 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
return 0;
}
+#endif
+extern drm_ioctl_desc_t DRM(ioctls)[];
+void DRM(context_add_ioctls)(void)
+{
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)].func = DRM(setsareactx);
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)].auth_needed = 1;
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)].root_only = 1;
+
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)].func = DRM(getsareactx);
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)].auth_needed = 1;
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)].root_only = 0;
+}
/*@}*/
+
diff --git a/linux-core/drm_dma.c b/linux-core/drm_dma.c
index 811d768d..cf8d8931 100644
--- a/linux-core/drm_dma.c
+++ b/linux-core/drm_dma.c
@@ -37,15 +37,6 @@
#include "drmP.h"
-#ifndef __HAVE_DMA_WAITQUEUE
-#define __HAVE_DMA_WAITQUEUE 0
-#endif
-#ifndef __HAVE_DMA_RECLAIM
-#define __HAVE_DMA_RECLAIM 0
-#endif
-
-#if __HAVE_DMA
-
/**
* Initialize the DMA data.
*
@@ -156,7 +147,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
buf->filp = NULL;
buf->used = 0;
- if ( __HAVE_DMA_WAITQUEUE && waitqueue_active(&buf->dma_wait)) {
+ if ( (dev->driver_features & DRIVER_DMA_QUEUE) && waitqueue_active(&buf->dma_wait)) {
wake_up_interruptible(&buf->dma_wait);
}
/* If processes are waiting, the last one
@@ -168,7 +159,6 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
}
-#if !__HAVE_DMA_RECLAIM
/**
* Reclaim the buffers.
*
@@ -176,7 +166,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(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;
@@ -200,29 +190,4 @@ void DRM(reclaim_buffers)( struct file *filp )
}
}
}
-#endif
-
-#if !__HAVE_IRQ
-/* This stub DRM_IOCTL_CONTROL handler is for the drivers that used to require
- * IRQs for DMA but no longer do. It maintains compatibility with the X Servers
- * that try to use the control ioctl by simply returning success.
- */
-int DRM(control)( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
-{
- drm_control_t ctl;
-
- if ( copy_from_user( &ctl, (drm_control_t __user *)arg, sizeof(ctl) ) )
- return -EFAULT;
-
- switch ( ctl.func ) {
- case DRM_INST_HANDLER:
- case DRM_UNINST_HANDLER:
- return 0;
- default:
- return -EINVAL;
- }
-}
-#endif
-#endif /* __HAVE_DMA */
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 4b97e40c..9588781b 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -52,27 +52,11 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef __MUST_HAVE_AGP
-#define __MUST_HAVE_AGP 0
-#endif
-#ifndef __HAVE_CTX_BITMAP
-#define __HAVE_CTX_BITMAP 0
-#endif
-#ifndef __HAVE_IRQ
-#define __HAVE_IRQ 0
-#endif
-#ifndef __HAVE_DMA_QUEUE
-#define __HAVE_DMA_QUEUE 0
-#endif
-#ifndef __HAVE_MULTIPLE_DMA_QUEUES
-#define __HAVE_MULTIPLE_DMA_QUEUES 0
-#endif
+
+
#ifndef __HAVE_COUNTERS
#define __HAVE_COUNTERS 0
#endif
-#ifndef __HAVE_SG
-#define __HAVE_SG 0
-#endif
#ifndef DRIVER_IOCTLS
#define DRIVER_IOCTLS
@@ -131,9 +115,7 @@ 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 },
-#if __HAVE_IRQ
[DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_by_busid), 0, 1 },
-#endif
[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 },
@@ -147,11 +129,6 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 },
-#if __HAVE_CTX_BITMAP
- [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { DRM(setsareactx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { DRM(getsareactx), 1, 0 },
-#endif
-
[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 },
@@ -168,19 +145,16 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 },
-#if __HAVE_DMA
[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. */
-#endif
-#if __HAVE_IRQ || __HAVE_DMA
+
[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 },
-#endif
-#if __REALLY_HAVE_AGP
+#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 },
@@ -191,14 +165,10 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 },
#endif
-#if __HAVE_SG
[DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { DRM(sg_alloc), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { DRM(sg_free), 1, 1 },
-#endif
-#if __HAVE_VBL_IRQ
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 },
-#endif
DRIVER_IOCTLS
};
@@ -226,11 +196,12 @@ static int DRM(setup)( drm_device_t *dev )
dev->buf_use = 0;
atomic_set( &dev->buf_alloc, 0 );
-#if __HAVE_DMA
- i = DRM(dma_setup)( dev );
- if ( i < 0 )
- return i;
-#endif
+ if (dev->driver_features & DRIVER_HAVE_DMA)
+ {
+ i = DRM(dma_setup)( dev );
+ if ( i < 0 )
+ return i;
+ }
dev->counters = 6 + __HAVE_COUNTERS;
dev->types[0] = _DRM_STAT_LOCK;
@@ -346,9 +317,8 @@ static int DRM(takedown)( drm_device_t *dev )
if (dev->fn_tbl.pretakedown)
dev->fn_tbl.pretakedown(dev);
-#if __HAVE_IRQ
+
if ( dev->irq_enabled ) DRM(irq_uninstall)( dev );
-#endif
down( &dev->struct_sem );
del_timer( &dev->timer );
@@ -374,9 +344,9 @@ static int DRM(takedown)( drm_device_t *dev )
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
/* Clear AGP information */
- if ( dev->agp ) {
+ if ( (dev->driver_features & DRIVER_USE_AGP) && dev->agp ) {
drm_agp_mem_t *entry;
drm_agp_mem_t *nexte;
@@ -426,15 +396,11 @@ static int DRM(takedown)( drm_device_t *dev )
*/
break;
case _DRM_SCATTER_GATHER:
- /* Handle it, but do nothing, if HAVE_SG
- * isn't defined.
- */
-#if __HAVE_SG
- if(dev->sg) {
+ /* Handle it */
+ if (dev->driver_features & DRIVER_SG && dev->sg) {
DRM(sg_cleanup)(dev->sg);
dev->sg = NULL;
}
-#endif
break;
}
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
@@ -444,8 +410,8 @@ static int DRM(takedown)( drm_device_t *dev )
}
}
-#if __HAVE_DMA_QUEUE || __HAVE_MULTIPLE_DMA_QUEUES
- if ( dev->queuelist ) {
+
+ if ( (dev->driver_features & DRIVER_DMA_QUEUE) && dev->queuelist ) {
for ( i = 0 ; i < dev->queue_count ; i++ ) {
if (dev->fn_tbl.waitlist_destroy)
dev->fn_tbl.waitlist_destroy( &dev->queuelist[i]->waitlist);
@@ -463,11 +429,10 @@ static int DRM(takedown)( drm_device_t *dev )
dev->queuelist = NULL;
}
dev->queue_count = 0;
-#endif
-#if __HAVE_DMA
- DRM(dma_takedown)( dev );
-#endif
+ if (dev->driver_features & DRIVER_HAVE_DMA)
+ DRM(dma_takedown)( dev );
+
if ( dev->lock.hw_lock ) {
dev->sigdata.lock = dev->lock.hw_lock = NULL; /* SHM removed */
dev->lock.filp = NULL;
@@ -479,6 +444,13 @@ 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)[] = {
@@ -527,37 +499,44 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* dev_priv_size can be changed by a driver in driver_register_fns */
dev->dev_priv_size = sizeof(u32);
- DRM(driver_register_fns)(dev);
+
+ DRM(init_fn_table)(dev);
+ DRM(driver_register_fns)(dev);
+
+ /* if we have CTX_BITMAP add the ioctls */
+ DRM(context_add_ioctls)();
+
if (dev->fn_tbl.preinit)
if ((retcode = dev->fn_tbl.preinit(dev, ent->driver_data)))
goto error_out_unreg;
-#if __REALLY_HAVE_AGP
- dev->agp = DRM(agp_init)();
-#if __MUST_HAVE_AGP
- if ( dev->agp == NULL ) {
- DRM_ERROR( "Cannot initialize the agpgart module.\n" );
- retcode = -EINVAL;
- goto error_out_unreg;
+#if __OS_HAS_AGP
+ if (dev->driver_features & DRIVER_USE_AGP) {
+ dev->agp = DRM(agp_init)();
+ if ( (dev->driver_features & DRIVER_REQUIRE_AGP) && dev->agp == NULL ) {
+ DRM_ERROR( "Cannot initialize the agpgart module.\n" );
+ retcode = -EINVAL;
+ goto error_out_unreg;
+ }
+
+#if __OS_HAS_MTRR
+ if (dev->driver_features & DRIVER_USE_MTRR) {
+ if (dev->agp)
+ dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
+ dev->agp->agp_info.aper_size*1024*1024,
+ MTRR_TYPE_WRCOMB,
+ 1 );
+ }
}
#endif
-#if __REALLY_HAVE_MTRR
- if (dev->agp)
- dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
- dev->agp->agp_info.aper_size*1024*1024,
- MTRR_TYPE_WRCOMB,
- 1 );
-#endif
#endif
-
-#if __HAVE_CTX_BITMAP
retcode = DRM(ctxbitmap_init)( dev );
if( retcode ) {
- DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
- goto error_out_unreg;
- }
-#endif
+ DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
+ goto error_out_unreg;
+ }
+
if ((dev->minor = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0)
{
retcode = -EPERM;
@@ -688,13 +667,15 @@ static void __exit drm_cleanup( drm_device_t *dev )
break;
case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
- if ( map->mtrr >= 0 ) {
- int retcode;
- retcode = mtrr_del( map->mtrr,
- map->offset,
- map->size );
- DRM_DEBUG( "mtrr_del=%d\n", retcode );
+#if __OS_HAS_MTRR
+ if ( dev->driver_features & DRIVER_USE_MTRR) {
+ if ( map->mtrr >= 0 ) {
+ int retcode;
+ retcode = mtrr_del( map->mtrr,
+ map->offset,
+ map->size );
+ DRM_DEBUG( "mtrr_del=%d\n", retcode );
+ }
}
#endif
break;
@@ -722,11 +703,12 @@ static void __exit drm_cleanup( drm_device_t *dev )
} else {
DRM_DEBUG( "minor %d unregistered\n", dev->minor);
}
-#if __HAVE_CTX_BITMAP
+
DRM(ctxbitmap_cleanup)( dev );
-#endif
-#if __REALLY_HAVE_AGP && __REALLY_HAVE_MTRR
- if ( dev->agp && dev->agp->agp_mtrr >= 0) {
+
+#if __OS_HAS_AGP
+#if __OS_HAS_MTRR
+ if ( (dev->driver_features & DRIVER_USE_MTRR) && dev->agp && dev->agp->agp_mtrr >= 0 ) {
int retval;
retval = mtrr_del( dev->agp->agp_mtrr,
dev->agp->agp_info.aper_base,
@@ -734,8 +716,7 @@ static void __exit drm_cleanup( drm_device_t *dev )
DRM_DEBUG( "mtrr_del=%d\n", retval );
}
#endif
-#if __REALLY_HAVE_AGP
- if ( dev->agp ) {
+ if ( (dev->driver_features & DRIVER_USE_AGP) && dev->agp ) {
DRM(agp_uninit)();
DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS );
dev->agp = NULL;
@@ -942,9 +923,10 @@ int DRM(release)( struct inode *inode, struct file *filp )
}
}
-#if __HAVE_DMA
- DRM(reclaim_buffers)( filp );
-#endif
+ if (dev->driver_features & DRIVER_HAVE_DMA)
+ {
+ dev->fn_tbl.reclaim_buffers(filp);
+ }
DRM(fasync)( -1, filp, 0 );
@@ -957,9 +939,9 @@ int DRM(release)( struct inode *inode, struct file *filp )
pos->handle != DRM_KERNEL_CONTEXT ) {
if (dev->fn_tbl.context_dtor)
dev->fn_tbl.context_dtor(dev, pos->handle);
-#if __HAVE_CTX_BITMAP
+
DRM(ctxbitmap_free)( dev, pos->handle );
-#endif
+
list_del( &pos->head );
DRM(free)( pos, sizeof(*pos), DRM_MEM_CTXLIST );
--dev->ctx_count;
@@ -988,6 +970,8 @@ int DRM(release)( struct inode *inode, struct file *filp )
}
up( &dev->struct_sem );
+ if (dev->fn_tbl.free_filp_private)
+ dev->fn_tbl.free_filp_private( dev, priv );
DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES );
/* ========================================================
@@ -1086,9 +1070,6 @@ int DRM(lock)( struct inode *inode, struct file *filp,
DECLARE_WAITQUEUE( entry, current );
drm_lock_t lock;
int ret = 0;
-#if __HAVE_MULTIPLE_DMA_QUEUES
- drm_queue_t *q;
-#endif
++priv->lock_count;
@@ -1105,14 +1086,9 @@ int DRM(lock)( struct inode *inode, struct file *filp,
lock.context, current->pid,
dev->lock.hw_lock->lock, lock.flags );
-#if __HAVE_DMA_QUEUE
- if ( lock.context < 0 )
- return -EINVAL;
-#elif __HAVE_MULTIPLE_DMA_QUEUES
- if ( lock.context < 0 || lock.context >= dev->queue_count )
- return -EINVAL;
- q = dev->queuelist[lock.context];
-#endif
+ if (dev->driver_features & DRIVER_DMA_QUEUE)
+ if ( lock.context < 0 )
+ return -EINVAL;
if (dev->fn_tbl.dma_flush_block_and_flush)
ret = dev->fn_tbl.dma_flush_block_and_flush(dev, lock.context, lock.flags);
diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c
index d21f7898..4589231f 100644
--- a/linux-core/drm_fops.c
+++ b/linux-core/drm_fops.c
@@ -54,6 +54,7 @@ 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;
@@ -74,7 +75,11 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
priv->lock_count = 0;
if (dev->fn_tbl.open_helper)
- dev->fn_tbl.open_helper(dev, priv);
+ {
+ ret=dev->fn_tbl.open_helper(dev, priv);
+ if (ret < 0)
+ goto out_free;
+ }
down(&dev->struct_sem);
if (!dev->file_last) {
@@ -106,6 +111,9 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
#endif
return 0;
+ out_free:
+ DRM(free)(priv, sizeof(*priv), DRM_MEM_FILES);
+ return ret;
}
/** No-op. */
diff --git a/linux-core/drm_ioctl.c b/linux-core/drm_ioctl.c
index 2ecce48f..049afe11 100644
--- a/linux-core/drm_ioctl.c
+++ b/linux-core/drm_ioctl.c
@@ -342,9 +342,10 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
if (sv.drm_dd_major != DRIVER_MAJOR ||
sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR)
return EINVAL;
-#ifdef DRIVER_SETVERSION
- DRIVER_SETVERSION(dev, &sv);
-#endif
+
+ 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 aac0b1b0..73a62e68 100644
--- a/linux-core/drm_irq.c
+++ b/linux-core/drm_irq.c
@@ -38,16 +38,6 @@
#include <linux/interrupt.h> /* For task queue support */
-#ifndef __HAVE_SHARED_IRQ
-#define __HAVE_SHARED_IRQ 0
-#endif
-
-#if __HAVE_SHARED_IRQ
-#define DRM_IRQ_TYPE SA_SHIRQ
-#else
-#define DRM_IRQ_TYPE 0
-#endif
-
/**
* Get interrupt from bus id.
*
@@ -69,6 +59,9 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
drm_irq_busid_t __user *argp = (void __user *)arg;
drm_irq_busid_t p;
+ if (!(dev->driver_features & DRIVER_HAVE_IRQ))
+ return -EINVAL;
+
if (copy_from_user(&p, argp, sizeof(p)))
return -EFAULT;
@@ -87,8 +80,6 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
return 0;
}
-#if __HAVE_IRQ
-
/**
* Install IRQ handler.
*
@@ -102,7 +93,11 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
int DRM(irq_install)( drm_device_t *dev )
{
int ret;
-
+ unsigned long sh_flags=0;
+
+ if (!(dev->driver_features & DRIVER_HAVE_IRQ ))
+ return -EINVAL;
+
if ( dev->irq == 0 )
return -EINVAL;
@@ -123,39 +118,29 @@ int DRM(irq_install)( drm_device_t *dev )
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
-#if __HAVE_DMA
dev->dma->next_buffer = NULL;
dev->dma->next_queue = NULL;
dev->dma->this_buffer = NULL;
-#endif
-
-#ifdef __HAVE_IRQ_BH
-#if !HAS_WORKQUEUE
- INIT_LIST_HEAD( &dev->tq.list );
- dev->tq.sync = 0;
- dev->tq.routine = DRM(irq_immediate_bh);
- dev->tq.data = dev;
-#else
- INIT_WORK(&dev->work, DRM(irq_immediate_bh), dev);
-#endif
-#endif
-
-#ifdef __HAVE_VBL_IRQ
- init_waitqueue_head(&dev->vbl_queue);
- spin_lock_init( &dev->vbl_lock );
-
- INIT_LIST_HEAD( &dev->vbl_sigs.head );
-
- dev->vbl_pending = 0;
-#endif
+ if (dev->driver_features & DRIVER_IRQ_VBL) {
+ init_waitqueue_head(&dev->vbl_queue);
+
+ spin_lock_init( &dev->vbl_lock );
+
+ INIT_LIST_HEAD( &dev->vbl_sigs.head );
+
+ dev->vbl_pending = 0;
+ }
/* Before installing handler */
- DRM(driver_irq_preinstall)(dev);
+ dev->fn_tbl.irq_preinstall(dev);
/* Install handler */
- ret = request_irq( dev->irq, DRM(irq_handler),
- DRM_IRQ_TYPE, dev->devname, dev );
+ if (dev->driver_features & DRIVER_IRQ_SHARED)
+ sh_flags = SA_SHIRQ;
+
+ ret = request_irq( dev->irq, dev->fn_tbl.irq_handler,
+ sh_flags, dev->devname, dev );
if ( ret < 0 ) {
down( &dev->struct_sem );
dev->irq_enabled = 0;
@@ -164,7 +149,7 @@ int DRM(irq_install)( drm_device_t *dev )
}
/* After installing handler */
- DRM(driver_irq_postinstall)(dev);
+ dev->fn_tbl.irq_postinstall(dev);
return 0;
}
@@ -180,6 +165,9 @@ int DRM(irq_uninstall)( drm_device_t *dev )
{
int irq_enabled;
+ if (!(dev->driver_features & DRIVER_HAVE_IRQ ))
+ return -EINVAL;
+
down( &dev->struct_sem );
irq_enabled = dev->irq_enabled;
dev->irq_enabled = 0;
@@ -190,7 +178,7 @@ int DRM(irq_uninstall)( drm_device_t *dev )
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
- DRM(driver_irq_uninstall)( dev );
+ dev->fn_tbl.irq_uninstall(dev);
free_irq( dev->irq, dev );
@@ -214,25 +202,33 @@ int DRM(control)( struct inode *inode, struct file *filp,
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
drm_control_t ctl;
+
+ /* if we haven't dma then no need for this control */
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
+
+ /* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */
if ( copy_from_user( &ctl, (drm_control_t __user *)arg, sizeof(ctl) ) )
return -EFAULT;
switch ( ctl.func ) {
case DRM_INST_HANDLER:
+ if (!(dev->driver_features & DRIVER_HAVE_IRQ))
+ return 0;
if (dev->if_version < DRM_IF_VERSION(1, 2) &&
ctl.irq != dev->irq)
return -EINVAL;
return DRM(irq_install)( dev );
case DRM_UNINST_HANDLER:
+ if (!(dev->driver_features & DRIVER_HAVE_IRQ))
+ return 0;
return DRM(irq_uninstall)( dev );
default:
return -EINVAL;
}
}
-#ifdef __HAVE_VBL_IRQ
-
/**
* Wait for VBLANK.
*
@@ -262,6 +258,9 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
int ret = 0;
unsigned int flags;
+ if (!(dev->driver_features & DRIVER_IRQ_VBL))
+ return -EINVAL;
+
if (!dev->irq)
return -EINVAL;
@@ -326,7 +325,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
} else {
- ret = DRM(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;
@@ -374,6 +374,4 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
spin_unlock_irqrestore( &dev->vbl_lock, flags );
}
-#endif /* __HAVE_VBL_IRQ */
-#endif /* __HAVE_IRQ */
diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h
index d1c4b23a..c407292a 100644
--- a/linux-core/drm_memory.h
+++ b/linux-core/drm_memory.h
@@ -46,7 +46,7 @@
#define DEBUG_MEMORY 0
/* Need the 4-argument version of vmap(). */
-#if __REALLY_HAVE_AGP && defined(VMAP_4_ARGS)
+#if __OS_HAS_AGP && defined(VMAP_4_ARGS)
#include <linux/vmalloc.h>
@@ -142,12 +142,12 @@ drm_follow_page (void *vaddr)
return pte_pfn(*ptep) << PAGE_SHIFT;
}
-#endif /* __REALLY_HAVE_AGP && defined(VMAP_4_ARGS) */
+#endif /* __OS_HAS_AGP && defined(VMAP_4_ARGS) */
static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev)
{
-#if __REALLY_HAVE_AGP && defined(VMAP_4_ARGS)
- if (dev->agp && dev->agp->cant_use_aperture) {
+#if __OS_HAS_AGP && defined(VMAP_4_ARGS)
+ if ( (dev->driver_features & DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture) {
drm_map_t *map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP)
@@ -161,8 +161,8 @@ static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_de
static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size,
drm_device_t *dev)
{
-#if __REALLY_HAVE_AGP && defined(VMAP_4_ARGS)
- if (dev->agp && dev->agp->cant_use_aperture) {
+#if __OS_HAS_AGP&& defined(VMAP_4_ARGS)
+ if ( (dev->driver_features & DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture) {
drm_map_t *map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP)
@@ -175,13 +175,13 @@ static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size
static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev)
{
-#if __REALLY_HAVE_AGP && defined(VMAP_4_ARGS)
+#if __OS_HAS_AGP && defined(VMAP_4_ARGS)
/*
* This is a bit ugly. It would be much cleaner if the DRM API would use separate
* routines for handling mappings in the AGP space. Hopefully this can be done in
* a future revision of the interface...
*/
- if (dev->agp && dev->agp->cant_use_aperture
+ if ((dev->driver_features & DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture
&& ((unsigned long) pt >= VMALLOC_START && (unsigned long) pt < VMALLOC_END))
{
unsigned long offset;
@@ -344,7 +344,7 @@ void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev)
drm_ioremapfree(pt, size, dev);
}
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
/** Wrapper around agp_allocate_memory() */
DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type)
{
diff --git a/linux-core/drm_memory_debug.h b/linux-core/drm_memory_debug.h
index 6723818a..4f23918d 100644
--- a/linux-core/drm_memory_debug.h
+++ b/linux-core/drm_memory_debug.h
@@ -353,7 +353,7 @@ void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev)
}
}
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type)
{
diff --git a/linux-core/drm_scatter.c b/linux-core/drm_scatter.c
index 4aaf89d4..89ac166a 100644
--- a/linux-core/drm_scatter.c
+++ b/linux-core/drm_scatter.c
@@ -74,6 +74,9 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
DRM_DEBUG( "%s\n", __FUNCTION__ );
+ if ( dev->driver_features & DRIVER_SG )
+ return -EINVAL;
+
if ( dev->sg )
return -EINVAL;
@@ -207,6 +210,9 @@ int DRM(sg_free)( struct inode *inode, struct file *filp,
drm_scatter_gather_t request;
drm_sg_mem_t *entry;
+ if ( dev->driver_features & DRIVER_SG )
+ return -EINVAL;
+
if ( copy_from_user( &request,
(drm_scatter_gather_t __user *)arg,
sizeof(request) ) )
diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c
index 7ab7d5ac..9c444aff 100644
--- a/linux-core/drm_vm.c
+++ b/linux-core/drm_vm.c
@@ -50,7 +50,7 @@
static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
unsigned long address)
{
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
drm_file_t *priv = vma->vm_file->private_data;
drm_device_t *dev = priv->dev;
drm_map_t *map = NULL;
@@ -60,6 +60,7 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
/*
* Find the right map
*/
+ if (!(dev->agp && DRIVER_USE_AGP)) goto vm_nopage_error;
if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error;
@@ -111,7 +112,7 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
return page;
}
vm_nopage_error:
-#endif /* __REALLY_HAVE_AGP */
+#endif /* __OS_HAS_AGP */
return NOPAGE_SIGBUS; /* Disallow mremap */
}
@@ -205,8 +206,8 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
switch (map->type) {
case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
- if (map->mtrr >= 0) {
+#if __OS_HAS_MTRR
+ if ((dev->driver_features & DRIVER_USE_MTRR) && map->mtrr >= 0) {
int retcode;
retcode = mtrr_del(map->mtrr,
map->offset,
@@ -492,18 +493,19 @@ int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma)
return 0;
}
-#ifndef DRIVER_GET_MAP_OFS
-#define DRIVER_GET_MAP_OFS() (map->offset)
-#endif
+unsigned long DRM(core_get_map_ofs)(drm_map_t *map)
+{
+ return map->offset;
+}
-#ifndef DRIVER_GET_REG_OFS
+unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev)
+{
#ifdef __alpha__
-#define DRIVER_GET_REG_OFS() (dev->hose->dense_mem_base - \
- dev->hose->mem_space->start)
+ return dev->host->dense_mem_base - dev->hose_mem_space->start;
#else
-#define DRIVER_GET_REG_OFS() 0
-#endif
+ return 0;
#endif
+}
/**
* mmap DMA memory.
@@ -537,7 +539,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
* --BenH.
*/
if (!VM_OFFSET(vma)
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
&& (!dev->agp || dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE)
#endif
)
@@ -556,7 +558,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 = DRIVER_GET_MAP_OFS();
+ off = dev->fn_tbl.get_map_ofs(map);
if (off == VM_OFFSET(vma)) break;
}
@@ -581,8 +583,8 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
switch (map->type) {
case _DRM_AGP:
-#if __REALLY_HAVE_AGP
- if (dev->agp->cant_use_aperture) {
+#if __OS_HAS_AGP
+ if ((dev->driver_features & DRIVER_USE_AGP) && dev->agp->cant_use_aperture) {
/*
* On some platforms we can't talk to bus dma address from the CPU, so for
* memory of type DRM_AGP, we'll deal with sorting out the real physical
@@ -613,7 +615,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 = DRIVER_GET_REG_OFS();
+ 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,
diff --git a/linux-core/ffb_context.c b/linux-core/ffb_context.c
index add2a743..0fccddb8 100644
--- a/linux-core/ffb_context.c
+++ b/linux-core/ffb_context.c
@@ -587,6 +587,21 @@ 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)
+{
+ return (map->offset & 0xffffffff);
+}
+
+static unsigned long ffb_driver_get_reg_ofs(drm_device_t *dev)
+{
+ ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *)dev->dev_private;
+
+ if (ffb_priv)
+ return ffb_priv->card_phys_base;
+
+ return 0;
+}
+
static void ffb_driver_register_fns(drm_device_t *dev)
{
DRM(fops).get_unmapped_area = ffb_get_unmapped_area;
@@ -596,4 +611,7 @@ static void ffb_driver_register_fns(drm_device_t *dev)
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 fe0d129b..113c2d6b 100644
--- a/linux-core/ffb_drv.c
+++ b/linux-core/ffb_drv.c
@@ -28,10 +28,6 @@
#define DRIVER_COUNT_CARDS() ffb_count_card_instances()
-/* For mmap customization */
-#define DRIVER_GET_MAP_OFS() (map->offset & 0xffffffff)
-#define DRIVER_GET_REG_OFS() ffb_get_reg_offset(dev)
-
typedef struct _ffb_position_t {
int node;
int root;
@@ -273,16 +269,6 @@ unsigned long ffb_get_unmapped_area(struct file *filp,
return addr;
}
-static unsigned long ffb_get_reg_offset(drm_device_t *dev)
-{
- ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *)dev->dev_private;
-
- if (ffb_priv)
- return ffb_priv->card_phys_base;
-
- return 0;
-}
-
#include "drm_auth.h"
#include "drm_bufs.h"
#include "drm_dma.h"
diff --git a/linux-core/i810_dma.c b/linux-core/i810_dma.c
index d558988f..8ee32f74 100644
--- a/linux-core/i810_dma.c
+++ b/linux-core/i810_dma.c
@@ -239,13 +239,12 @@ int i810_dma_cleanup(drm_device_t *dev)
{
drm_device_dma_t *dma = dev->dma;
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
+ if ( (dev->driver_features & DRIVER_HAVE_IRQ) && dev->irq_enabled )
+ DRM(irq_uninstall)(dev);
if (dev->dev_private) {
int i;
@@ -1413,9 +1412,11 @@ static int i810_driver_dma_quiescent(drm_device_t *dev)
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;
}
diff --git a/linux-core/i810_drv.c b/linux-core/i810_drv.c
index 0bc79386..1ab8b013 100644
--- a/linux-core/i810_drv.c
+++ b/linux-core/i810_drv.c
@@ -48,8 +48,10 @@
#include "drm_fops.h"
#include "drm_init.h"
#include "drm_ioctl.h"
+#include "drm_irq.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux-core/i830_dma.c b/linux-core/i830_dma.c
index 1a8c6336..8a110403 100644
--- a/linux-core/i830_dma.c
+++ b/linux-core/i830_dma.c
@@ -240,13 +240,11 @@ int i830_dma_cleanup(drm_device_t *dev)
{
drm_device_dma_t *dma = dev->dma;
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
if (dev->dev_private) {
int i;
@@ -1609,9 +1607,20 @@ static int i830_driver_dma_quiescent(drm_device_t *dev)
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
}
diff --git a/linux-core/i830_drv.c b/linux-core/i830_drv.c
index 2f4e8157..900706cf 100644
--- a/linux-core/i830_drv.c
+++ b/linux-core/i830_drv.c
@@ -56,3 +56,4 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux-core/i830_drv.h b/linux-core/i830_drv.h
index ad4de4c3..c3cab2d8 100644
--- a/linux-core/i830_drv.h
+++ b/linux-core/i830_drv.h
@@ -136,6 +136,10 @@ extern int i830_irq_wait( struct inode *inode, struct file *filp,
extern int i830_wait_irq(drm_device_t *dev, int irq_nr);
extern int i830_emit_irq(drm_device_t *dev);
+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 );
#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 7a066b6f..0bb4ce8e 100644
--- a/linux-core/i830_irq.c
+++ b/linux-core/i830_irq.c
@@ -36,7 +36,7 @@
#include <linux/delay.h>
-irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
+irqreturn_t i830_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *)arg;
drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
@@ -179,7 +179,7 @@ int i830_irq_wait( struct inode *inode, struct file *filp, unsigned int cmd,
/* drm_dma.h hooks
*/
-void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+void i830_driver_irq_preinstall( drm_device_t *dev ) {
drm_i830_private_t *dev_priv =
(drm_i830_private_t *)dev->dev_private;
@@ -191,14 +191,14 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
init_waitqueue_head(&dev_priv->irq_queue);
}
-void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+void i830_driver_irq_postinstall( drm_device_t *dev ) {
drm_i830_private_t *dev_priv =
(drm_i830_private_t *)dev->dev_private;
I830_WRITE16( I830REG_INT_ENABLE_R, 0x2 );
}
-void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+void i830_driver_irq_uninstall( drm_device_t *dev ) {
drm_i830_private_t *dev_priv =
(drm_i830_private_t *)dev->dev_private;
if (!dev_priv)
diff --git a/linux-core/i915_drv.c b/linux-core/i915_drv.c
index 1e563387..6078b54f 100644
--- a/linux-core/i915_drv.c
+++ b/linux-core/i915_drv.c
@@ -19,6 +19,7 @@
#include "drm_bufs.h"
#include "drm_context.h" /* is this needed? */
#include "drm_drawable.h" /* is this needed? */
+#include "drm_dma.h"
#include "drm_drv.h"
#include "drm_fops.h"
#include "drm_init.h"
@@ -29,3 +30,4 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux-core/mach64_drv.c b/linux-core/mach64_drv.c
index 56d79137..32f6cddc 100644
--- a/linux-core/mach64_drv.c
+++ b/linux-core/mach64_drv.c
@@ -51,3 +51,4 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux-core/mga_drv.c b/linux-core/mga_drv.c
index 6bcad048..57940d5d 100644
--- a/linux-core/mga_drv.c
+++ b/linux-core/mga_drv.c
@@ -51,3 +51,4 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux-core/savage.h b/linux-core/savage.h
index fb828ce6..cb50d6e2 100644
--- a/linux-core/savage.h
+++ b/linux-core/savage.h
@@ -29,11 +29,4 @@
*/
#define DRM(x) savage_##x
-/* General customization:
- */
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 1
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
-
#endif
diff --git a/linux-core/savage_dma.c b/linux-core/savage_dma.c
index 34410116..271d1f23 100644
--- a/linux-core/savage_dma.c
+++ b/linux-core/savage_dma.c
@@ -37,4 +37,5 @@
void DRM(driver_register_fns)(drm_device_t *dev)
{
+ dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR;
}
diff --git a/linux-core/savage_drv.c b/linux-core/savage_drv.c
index 331bbc9e..481a3886 100644
--- a/linux-core/savage_drv.c
+++ b/linux-core/savage_drv.c
@@ -265,11 +265,13 @@ int savage_free_cont_mem(struct inode *inode, struct file *filp,
#include "drm_fops.h"
#include "drm_init.h"
#include "drm_ioctl.h"
+#include "drm_irq.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux-core/sis_drv.c b/linux-core/sis_drv.c
index fce5470b..0b968dc2 100644
--- a/linux-core/sis_drv.c
+++ b/linux-core/sis_drv.c
@@ -40,11 +40,13 @@
#include "drm_drv.h"
#include "drm_fops.h"
#include "drm_init.h"
+#include "drm_irq.h"
#include "drm_ioctl.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux-core/tdfx_drv.c b/linux-core/tdfx_drv.c
index f3fcdf84..f34d32db 100644
--- a/linux-core/tdfx_drv.c
+++ b/linux-core/tdfx_drv.c
@@ -34,6 +34,7 @@
#include "tdfx.h"
#include "drmP.h"
+#include "drm_agpsupport.h"
#include "drm_auth.h"
#include "drm_bufs.h"
#include "drm_context.h"
@@ -44,13 +45,16 @@
#include "drm_fops.h"
#include "drm_init.h"
#include "drm_ioctl.h"
+#include "drm_irq.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
void DRM(driver_register_fns)(drm_device_t *dev)
{
+ dev->driver_features = DRIVER_USE_MTRR;
}
diff --git a/linux/Makefile b/linux/Makefile
index 658d9d87..f677f63d 100644
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -50,7 +50,7 @@ endif
MACHINE := $(shell uname -m)
# Modules for all architectures
-MODULE_LIST := gamma.o tdfx.o r128.o radeon.o mga.o sis.o savage.o via.o mach64.o
+MODULE_LIST := 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)))
diff --git a/linux/drmP.h b/linux/drmP.h
index 4271a7a2..e84685de 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -90,27 +90,20 @@
/** \name DRM template customization defaults */
/*@{*/
-#ifndef __HAVE_AGP
-#define __HAVE_AGP 0
-#endif
-#ifndef __HAVE_MTRR
-#define __HAVE_MTRR 0
-#endif
-#ifndef __HAVE_CTX_BITMAP
-#define __HAVE_CTX_BITMAP 0
-#endif
-#ifndef __HAVE_DMA
-#define __HAVE_DMA 0
-#endif
-#ifndef __HAVE_IRQ
-#define __HAVE_IRQ 0
-#endif
-
-#define __REALLY_HAVE_AGP (__HAVE_AGP && (defined(CONFIG_AGP) || \
- defined(CONFIG_AGP_MODULE)))
-#define __REALLY_HAVE_MTRR (__HAVE_MTRR && defined(CONFIG_MTRR))
-#define __REALLY_HAVE_SG (__HAVE_SG)
-
+/* driver capabilities and requirements mask */
+#define DRIVER_USE_AGP 0x1
+#define DRIVER_REQUIRE_AGP 0x2
+#define DRIVER_USE_MTRR 0x4
+#define DRIVER_HAVE_DMA 0x10
+#define DRIVER_HAVE_IRQ 0x20
+#define DRIVER_SG 0x40
+#define DRIVER_PCI_DMA 0x80
+#define DRIVER_IRQ_SHARED 0x100
+#define DRIVER_IRQ_VBL 0x200
+#define DRIVER_DMA_QUEUE 0x800
+
+#define __OS_HAS_AGP (defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE))
+#define __OS_HAS_MTRR (defined(CONFIG_MTRR))
/*@}*/
@@ -378,9 +371,7 @@ typedef struct drm_file {
struct drm_device *dev;
int remove_auth_on_close;
unsigned long lock_count;
-#ifdef DRIVER_FILE_FIELDS
- DRIVER_FILE_FIELDS;
-#endif
+ void *driver_priv;
} drm_file_t;
/** Wait queue */
@@ -438,7 +429,7 @@ typedef struct drm_device_dma {
/*@}*/
} drm_device_dma_t;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
/**
* AGP memory entry. Stored as a doubly linked list.
*/
@@ -504,7 +495,6 @@ typedef struct drm_ctx_list {
drm_file_t *tag; /**< associated fd private data */
} drm_ctx_list_t;
-#ifdef __HAVE_VBL_IRQ
typedef struct drm_vbl_sig {
struct list_head head;
@@ -513,7 +503,6 @@ typedef struct drm_vbl_sig {
struct task_struct *task;
} drm_vbl_sig_t;
-#endif
/**
* DRM device functions structure
@@ -528,7 +517,11 @@ struct drm_driver_fn {
int (*postcleanup)(struct drm_device *);
int (*presetup)(struct drm_device *);
int (*postsetup)(struct drm_device *);
- void (*open_helper)(struct drm_device *, drm_file_t *);
+
+ /* these are opposites at the moment */
+ int (*open_helper)(struct drm_device *, drm_file_t *);
+ void (*free_filp_private)(struct drm_device *, drm_file_t *);
+
void (*release)(struct drm_device *, struct file *filp);
void (*dma_ready)(struct drm_device *);
int (*dma_quiescent)(struct drm_device *);
@@ -542,7 +535,17 @@ struct drm_driver_fn {
int (*waitlist_destroy)(drm_waitlist_t *bl);
int (*freelist_create)(drm_freelist_t *bl, int count);
int (*freelist_put)(struct drm_device *dev, drm_freelist_t *bl, drm_buf_t *buf);
- int (*freelist_destroy)(drm_freelist_t *bl);
+ int (*freelist_destroy)(drm_freelist_t *bl);
+ int (*vblank_wait)(struct drm_device *dev, unsigned int *sequence);
+/* these have to be filled in */
+ irqreturn_t (*irq_handler)( DRM_IRQ_ARGS );
+ void (*irq_preinstall)(struct drm_device *dev);
+ void (*irq_postinstall)(struct drm_device *dev);
+ void (*irq_uninstall)(struct drm_device *dev);
+ void (*reclaim_buffers)(struct file *filp);
+ 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);
};
/**
@@ -637,13 +640,13 @@ typedef struct drm_device {
#endif
/** \name VBLANK IRQ support */
/*@{*/
-#ifdef __HAVE_VBL_IRQ
+
wait_queue_head_t vbl_queue; /**< VBLANK wait queue */
atomic_t vbl_received;
spinlock_t vbl_lock;
drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */
unsigned int vbl_pending;
-#endif
+
/*@}*/
cycles_t ctx_start;
cycles_t lck_start;
@@ -656,7 +659,7 @@ typedef struct drm_device {
wait_queue_head_t buf_readers; /**< Processes waiting to read */
wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
drm_agp_head_t *agp; /**< AGP data */
#endif
@@ -682,6 +685,7 @@ typedef struct drm_device {
struct drm_driver_fn fn_tbl;
drm_local_map_t *agp_buffer_map;
int dev_priv_size;
+ u32 driver_features;
} drm_device_t;
extern void DRM(driver_register_fns)(struct drm_device *dev);
@@ -742,7 +746,7 @@ 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);
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
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);
@@ -784,10 +788,8 @@ extern int DRM(rmctx)( struct inode *inode, struct file *filp,
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);
-#if __HAVE_CTX_BITMAP
extern int DRM(ctxbitmap_init)( drm_device_t *dev );
extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev );
-#endif
extern int DRM(setsareactx)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
@@ -833,7 +835,6 @@ 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,
unsigned int size, int type, int flags );
-#if __HAVE_DMA
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,
@@ -850,33 +851,24 @@ 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 );
-#endif /* __HAVE_DMA */
/* IRQ support (drm_irq.h) */
-#if __HAVE_IRQ || __HAVE_DMA
extern int DRM(control)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
-#endif
-#if __HAVE_IRQ
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 );
-#ifdef __HAVE_VBL_IRQ
+
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 );
-#endif
-#ifdef __HAVE_IRQ_BH
-extern void DRM(irq_immediate_bh)( void *dev );
-#endif
-#endif
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
/* AGP/GART support (drm_agpsupport.h) */
extern drm_agp_head_t *DRM(agp_init)(void);
extern void DRM(agp_uninit)(void);
@@ -918,14 +910,12 @@ extern int DRM(proc_cleanup)(int minor,
struct proc_dir_entry *root,
struct proc_dir_entry *dev_root);
-#ifdef __HAVE_SG
/* 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,
unsigned int cmd, unsigned long arg);
extern int DRM(sg_free)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
-#endif
/* ATI PCIGART support (ati_pcigart.h) */
extern int DRM(ati_pcigart_init)(drm_device_t *dev,
@@ -977,5 +967,7 @@ static __inline__ void drm_core_dropmap(struct drm_map *map)
}
/*@}*/
+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/drm_agpsupport.h b/linux/drm_agpsupport.h
index c4f0e465..12a8ba11 100644
--- a/linux/drm_agpsupport.h
+++ b/linux/drm_agpsupport.h
@@ -35,8 +35,7 @@
#include "drmP.h"
#include <linux/module.h>
-#if __REALLY_HAVE_AGP
-
+#if __OS_HAS_AGP
#define DRM_AGP_GET (drm_agp_t *)inter_module_get("drm_agp")
#define DRM_AGP_PUT inter_module_put("drm_agp")
@@ -471,4 +470,4 @@ int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle)
return drm_agp->unbind_memory(handle);
}
-#endif /* __REALLY_HAVE_AGP */
+#endif /* __OS_HAS_AGP */
diff --git a/linux/drm_bufs.h b/linux/drm_bufs.h
index 7ae95fcc..95858b80 100644
--- a/linux/drm_bufs.h
+++ b/linux/drm_bufs.h
@@ -37,14 +37,6 @@
#include <linux/vmalloc.h>
#include "drmP.h"
-#ifndef __HAVE_PCI_DMA
-#define __HAVE_PCI_DMA 0
-#endif
-
-#ifndef __HAVE_SG
-#define __HAVE_SG 0
-#endif
-
/**
* Compute size order. Returns the exponent of the smaller power of two which
* is greater or equal to given number.
@@ -111,11 +103,13 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int
#ifdef __alpha__
map->offset += dev->hose->mem_space->start;
#endif
-#if __REALLY_HAVE_MTRR
- if ( map->type == _DRM_FRAME_BUFFER ||
- (map->flags & _DRM_WRITE_COMBINING) ) {
- map->mtrr = mtrr_add( map->offset, map->size,
- MTRR_TYPE_WRCOMB, 1 );
+#if __OS_HAS_MTRR
+ if ( dev->driver_features & DRIVER_USE_MTRR) {
+ if ( map->type == _DRM_FRAME_BUFFER ||
+ (map->flags & _DRM_WRITE_COMBINING) ) {
+ map->mtrr = mtrr_add( map->offset, map->size,
+ MTRR_TYPE_WRCOMB, 1 );
+ }
}
#endif
if (map->type == _DRM_REGISTERS)
@@ -130,7 +124,6 @@ int DRM(initmap)( drm_device_t *dev, unsigned int offset, unsigned int size, int
return 0;
}
-
/**
* Ioctl to specify a range of memory that is available for mapping by a non-root process.
*
@@ -208,11 +201,13 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
#ifdef __alpha__
map->offset += dev->hose->mem_space->start;
#endif
-#if __REALLY_HAVE_MTRR
- if ( map->type == _DRM_FRAME_BUFFER ||
- (map->flags & _DRM_WRITE_COMBINING) ) {
- map->mtrr = mtrr_add( map->offset, map->size,
- MTRR_TYPE_WRCOMB, 1 );
+#if __OS_HAS_MTRR
+ if (dev->driver_features & DRIVER_USE_MTRR) {
+ if ( map->type == _DRM_FRAME_BUFFER ||
+ (map->flags & _DRM_WRITE_COMBINING) ) {
+ map->mtrr = mtrr_add( map->offset, map->size,
+ MTRR_TYPE_WRCOMB, 1 );
+ }
}
#endif
if (map->type == _DRM_REGISTERS)
@@ -240,13 +235,15 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
dev->lock.hw_lock = map->handle; /* Pointer to lock */
}
break;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
case _DRM_AGP:
+ if (dev->driver_features & DRIVER_USE_AGP) {
#ifdef __alpha__
- map->offset += dev->hose->mem_space->start;
+ map->offset += dev->hose->mem_space->start;
#endif
- map->offset += dev->agp->base;
- map->mtrr = dev->agp->agp_mtrr; /* for getmap */
+ map->offset += dev->agp->base;
+ map->mtrr = dev->agp->agp_mtrr; /* for getmap */
+ }
break;
#endif
case _DRM_SCATTER_GATHER:
@@ -368,8 +365,6 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
return 0;
}
-#if __HAVE_DMA
-
/**
* Cleanup after an error on one of the addbufs() functions.
*
@@ -417,7 +412,7 @@ static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry)
}
}
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
/**
* Add AGP buffers for DMA transfers (ioctl).
*
@@ -602,9 +597,8 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
atomic_dec( &dev->buf_alloc );
return 0;
}
-#endif /* __REALLY_HAVE_AGP */
+#endif /* __OS_HAS_AGP */
-#if __HAVE_PCI_DMA
int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
@@ -629,6 +623,8 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
drm_buf_t **temp_buflist;
drm_buf_desc_t __user *argp = (void __user *)arg;
+ if (!(dev->driver_features & DRIVER_PCI_DMA)) return -EINVAL;
+
if ( !dma ) return -EINVAL;
if ( copy_from_user( &request, argp, sizeof(request) ) )
@@ -842,9 +838,7 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
return 0;
}
-#endif /* __HAVE_PCI_DMA */
-#if __HAVE_SG
int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
@@ -867,6 +861,8 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
int i;
drm_buf_t **temp_buflist;
+ if (!(dev->driver_features & DRIVER_SG)) return -EINVAL;
+
if ( !dma ) return -EINVAL;
if ( copy_from_user( &request, argp, sizeof(request) ) )
@@ -1016,7 +1012,6 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
atomic_dec( &dev->buf_alloc );
return 0;
}
-#endif /* __HAVE_SG */
/**
* Add buffers for DMA transfers (ioctl).
@@ -1036,26 +1031,25 @@ int DRM(addbufs)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg )
{
drm_buf_desc_t request;
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
if ( copy_from_user( &request, (drm_buf_desc_t __user *)arg,
sizeof(request) ) )
return -EFAULT;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( request.flags & _DRM_AGP_BUFFER )
return DRM(addbufs_agp)( inode, filp, cmd, arg );
else
#endif
-#if __HAVE_SG
if ( request.flags & _DRM_SG_BUFFER )
return DRM(addbufs_sg)( inode, filp, cmd, arg );
else
-#endif
-#if __HAVE_PCI_DMA
return DRM(addbufs_pci)( inode, filp, cmd, arg );
-#else
- return -EINVAL;
-#endif
}
@@ -1087,6 +1081,9 @@ int DRM(infobufs)( struct inode *inode, struct file *filp,
int i;
int count;
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
+
if ( !dma ) return -EINVAL;
spin_lock( &dev->count_lock );
@@ -1168,6 +1165,9 @@ int DRM(markbufs)( struct inode *inode, struct file *filp,
int order;
drm_buf_entry_t *entry;
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
+
if ( !dma ) return -EINVAL;
if ( copy_from_user( &request,
@@ -1215,6 +1215,9 @@ int DRM(freebufs)( struct inode *inode, struct file *filp,
int idx;
drm_buf_t *buf;
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
+
if ( !dma ) return -EINVAL;
if ( copy_from_user( &request,
@@ -1272,6 +1275,9 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
drm_buf_map_t request;
int i;
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
+
if ( !dma ) return -EINVAL;
spin_lock( &dev->count_lock );
@@ -1286,8 +1292,8 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
return -EFAULT;
if ( request.count >= dma->buf_count ) {
- if ( (__HAVE_AGP && (dma->flags & _DRM_DMA_USE_AGP)) ||
- (__HAVE_SG && (dma->flags & _DRM_DMA_USE_SG)) ) {
+ if (( (dev->driver_features & DRIVER_USE_AGP) && (dma->flags & _DRM_DMA_USE_AGP)) ||
+ ( (dev->driver_features & DRIVER_SG) && (dma->flags & _DRM_DMA_USE_SG)) ) {
drm_map_t *map = dev->agp_buffer_map;
if ( !map ) {
@@ -1369,4 +1375,3 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
return retcode;
}
-#endif /* __HAVE_DMA */
diff --git a/linux/drm_context.h b/linux/drm_context.h
index dd280e53..cf3a536a 100644
--- a/linux/drm_context.h
+++ b/linux/drm_context.h
@@ -1,5 +1,5 @@
/**
- * \file drm_context.h
+* \file drm_context.h
* IOCTLs for generic contexts
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
@@ -43,11 +43,7 @@
#define __NO_VERSION__
#include "drmP.h"
-#if !__HAVE_CTX_BITMAP
-#error "__HAVE_CTX_BITMAP must be defined"
-#endif
-
-
+#ifndef DRIVER_ALTERNATE_CONTEXT
/******************************************************************/
/** \name Context bitmap support */
/*@{*/
@@ -579,5 +575,18 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
return 0;
}
+#endif
+extern drm_ioctl_desc_t DRM(ioctls)[];
+void DRM(context_add_ioctls)(void)
+{
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)].func = DRM(setsareactx);
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)].auth_needed = 1;
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)].root_only = 1;
+
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)].func = DRM(getsareactx);
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)].auth_needed = 1;
+ DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)].root_only = 0;
+}
/*@}*/
+
diff --git a/linux/drm_dma.h b/linux/drm_dma.h
index 811d768d..cf8d8931 100644
--- a/linux/drm_dma.h
+++ b/linux/drm_dma.h
@@ -37,15 +37,6 @@
#include "drmP.h"
-#ifndef __HAVE_DMA_WAITQUEUE
-#define __HAVE_DMA_WAITQUEUE 0
-#endif
-#ifndef __HAVE_DMA_RECLAIM
-#define __HAVE_DMA_RECLAIM 0
-#endif
-
-#if __HAVE_DMA
-
/**
* Initialize the DMA data.
*
@@ -156,7 +147,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
buf->filp = NULL;
buf->used = 0;
- if ( __HAVE_DMA_WAITQUEUE && waitqueue_active(&buf->dma_wait)) {
+ if ( (dev->driver_features & DRIVER_DMA_QUEUE) && waitqueue_active(&buf->dma_wait)) {
wake_up_interruptible(&buf->dma_wait);
}
/* If processes are waiting, the last one
@@ -168,7 +159,6 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
}
-#if !__HAVE_DMA_RECLAIM
/**
* Reclaim the buffers.
*
@@ -176,7 +166,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(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;
@@ -200,29 +190,4 @@ void DRM(reclaim_buffers)( struct file *filp )
}
}
}
-#endif
-
-#if !__HAVE_IRQ
-/* This stub DRM_IOCTL_CONTROL handler is for the drivers that used to require
- * IRQs for DMA but no longer do. It maintains compatibility with the X Servers
- * that try to use the control ioctl by simply returning success.
- */
-int DRM(control)( struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg )
-{
- drm_control_t ctl;
-
- if ( copy_from_user( &ctl, (drm_control_t __user *)arg, sizeof(ctl) ) )
- return -EFAULT;
-
- switch ( ctl.func ) {
- case DRM_INST_HANDLER:
- case DRM_UNINST_HANDLER:
- return 0;
- default:
- return -EINVAL;
- }
-}
-#endif
-#endif /* __HAVE_DMA */
diff --git a/linux/drm_drv.h b/linux/drm_drv.h
index 4b97e40c..9588781b 100644
--- a/linux/drm_drv.h
+++ b/linux/drm_drv.h
@@ -52,27 +52,11 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef __MUST_HAVE_AGP
-#define __MUST_HAVE_AGP 0
-#endif
-#ifndef __HAVE_CTX_BITMAP
-#define __HAVE_CTX_BITMAP 0
-#endif
-#ifndef __HAVE_IRQ
-#define __HAVE_IRQ 0
-#endif
-#ifndef __HAVE_DMA_QUEUE
-#define __HAVE_DMA_QUEUE 0
-#endif
-#ifndef __HAVE_MULTIPLE_DMA_QUEUES
-#define __HAVE_MULTIPLE_DMA_QUEUES 0
-#endif
+
+
#ifndef __HAVE_COUNTERS
#define __HAVE_COUNTERS 0
#endif
-#ifndef __HAVE_SG
-#define __HAVE_SG 0
-#endif
#ifndef DRIVER_IOCTLS
#define DRIVER_IOCTLS
@@ -131,9 +115,7 @@ 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 },
-#if __HAVE_IRQ
[DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_by_busid), 0, 1 },
-#endif
[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 },
@@ -147,11 +129,6 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 },
-#if __HAVE_CTX_BITMAP
- [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { DRM(setsareactx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { DRM(getsareactx), 1, 0 },
-#endif
-
[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 },
@@ -168,19 +145,16 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 },
-#if __HAVE_DMA
[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. */
-#endif
-#if __HAVE_IRQ || __HAVE_DMA
+
[DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 },
-#endif
-#if __REALLY_HAVE_AGP
+#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 },
@@ -191,14 +165,10 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 },
#endif
-#if __HAVE_SG
[DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { DRM(sg_alloc), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { DRM(sg_free), 1, 1 },
-#endif
-#if __HAVE_VBL_IRQ
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 },
-#endif
DRIVER_IOCTLS
};
@@ -226,11 +196,12 @@ static int DRM(setup)( drm_device_t *dev )
dev->buf_use = 0;
atomic_set( &dev->buf_alloc, 0 );
-#if __HAVE_DMA
- i = DRM(dma_setup)( dev );
- if ( i < 0 )
- return i;
-#endif
+ if (dev->driver_features & DRIVER_HAVE_DMA)
+ {
+ i = DRM(dma_setup)( dev );
+ if ( i < 0 )
+ return i;
+ }
dev->counters = 6 + __HAVE_COUNTERS;
dev->types[0] = _DRM_STAT_LOCK;
@@ -346,9 +317,8 @@ static int DRM(takedown)( drm_device_t *dev )
if (dev->fn_tbl.pretakedown)
dev->fn_tbl.pretakedown(dev);
-#if __HAVE_IRQ
+
if ( dev->irq_enabled ) DRM(irq_uninstall)( dev );
-#endif
down( &dev->struct_sem );
del_timer( &dev->timer );
@@ -374,9 +344,9 @@ static int DRM(takedown)( drm_device_t *dev )
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
/* Clear AGP information */
- if ( dev->agp ) {
+ if ( (dev->driver_features & DRIVER_USE_AGP) && dev->agp ) {
drm_agp_mem_t *entry;
drm_agp_mem_t *nexte;
@@ -426,15 +396,11 @@ static int DRM(takedown)( drm_device_t *dev )
*/
break;
case _DRM_SCATTER_GATHER:
- /* Handle it, but do nothing, if HAVE_SG
- * isn't defined.
- */
-#if __HAVE_SG
- if(dev->sg) {
+ /* Handle it */
+ if (dev->driver_features & DRIVER_SG && dev->sg) {
DRM(sg_cleanup)(dev->sg);
dev->sg = NULL;
}
-#endif
break;
}
DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
@@ -444,8 +410,8 @@ static int DRM(takedown)( drm_device_t *dev )
}
}
-#if __HAVE_DMA_QUEUE || __HAVE_MULTIPLE_DMA_QUEUES
- if ( dev->queuelist ) {
+
+ if ( (dev->driver_features & DRIVER_DMA_QUEUE) && dev->queuelist ) {
for ( i = 0 ; i < dev->queue_count ; i++ ) {
if (dev->fn_tbl.waitlist_destroy)
dev->fn_tbl.waitlist_destroy( &dev->queuelist[i]->waitlist);
@@ -463,11 +429,10 @@ static int DRM(takedown)( drm_device_t *dev )
dev->queuelist = NULL;
}
dev->queue_count = 0;
-#endif
-#if __HAVE_DMA
- DRM(dma_takedown)( dev );
-#endif
+ if (dev->driver_features & DRIVER_HAVE_DMA)
+ DRM(dma_takedown)( dev );
+
if ( dev->lock.hw_lock ) {
dev->sigdata.lock = dev->lock.hw_lock = NULL; /* SHM removed */
dev->lock.filp = NULL;
@@ -479,6 +444,13 @@ 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)[] = {
@@ -527,37 +499,44 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* dev_priv_size can be changed by a driver in driver_register_fns */
dev->dev_priv_size = sizeof(u32);
- DRM(driver_register_fns)(dev);
+
+ DRM(init_fn_table)(dev);
+ DRM(driver_register_fns)(dev);
+
+ /* if we have CTX_BITMAP add the ioctls */
+ DRM(context_add_ioctls)();
+
if (dev->fn_tbl.preinit)
if ((retcode = dev->fn_tbl.preinit(dev, ent->driver_data)))
goto error_out_unreg;
-#if __REALLY_HAVE_AGP
- dev->agp = DRM(agp_init)();
-#if __MUST_HAVE_AGP
- if ( dev->agp == NULL ) {
- DRM_ERROR( "Cannot initialize the agpgart module.\n" );
- retcode = -EINVAL;
- goto error_out_unreg;
+#if __OS_HAS_AGP
+ if (dev->driver_features & DRIVER_USE_AGP) {
+ dev->agp = DRM(agp_init)();
+ if ( (dev->driver_features & DRIVER_REQUIRE_AGP) && dev->agp == NULL ) {
+ DRM_ERROR( "Cannot initialize the agpgart module.\n" );
+ retcode = -EINVAL;
+ goto error_out_unreg;
+ }
+
+#if __OS_HAS_MTRR
+ if (dev->driver_features & DRIVER_USE_MTRR) {
+ if (dev->agp)
+ dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
+ dev->agp->agp_info.aper_size*1024*1024,
+ MTRR_TYPE_WRCOMB,
+ 1 );
+ }
}
#endif
-#if __REALLY_HAVE_MTRR
- if (dev->agp)
- dev->agp->agp_mtrr = mtrr_add( dev->agp->agp_info.aper_base,
- dev->agp->agp_info.aper_size*1024*1024,
- MTRR_TYPE_WRCOMB,
- 1 );
-#endif
#endif
-
-#if __HAVE_CTX_BITMAP
retcode = DRM(ctxbitmap_init)( dev );
if( retcode ) {
- DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
- goto error_out_unreg;
- }
-#endif
+ DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
+ goto error_out_unreg;
+ }
+
if ((dev->minor = DRM(stub_register)(DRIVER_NAME, &DRM(fops),dev)) < 0)
{
retcode = -EPERM;
@@ -688,13 +667,15 @@ static void __exit drm_cleanup( drm_device_t *dev )
break;
case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
- if ( map->mtrr >= 0 ) {
- int retcode;
- retcode = mtrr_del( map->mtrr,
- map->offset,
- map->size );
- DRM_DEBUG( "mtrr_del=%d\n", retcode );
+#if __OS_HAS_MTRR
+ if ( dev->driver_features & DRIVER_USE_MTRR) {
+ if ( map->mtrr >= 0 ) {
+ int retcode;
+ retcode = mtrr_del( map->mtrr,
+ map->offset,
+ map->size );
+ DRM_DEBUG( "mtrr_del=%d\n", retcode );
+ }
}
#endif
break;
@@ -722,11 +703,12 @@ static void __exit drm_cleanup( drm_device_t *dev )
} else {
DRM_DEBUG( "minor %d unregistered\n", dev->minor);
}
-#if __HAVE_CTX_BITMAP
+
DRM(ctxbitmap_cleanup)( dev );
-#endif
-#if __REALLY_HAVE_AGP && __REALLY_HAVE_MTRR
- if ( dev->agp && dev->agp->agp_mtrr >= 0) {
+
+#if __OS_HAS_AGP
+#if __OS_HAS_MTRR
+ if ( (dev->driver_features & DRIVER_USE_MTRR) && dev->agp && dev->agp->agp_mtrr >= 0 ) {
int retval;
retval = mtrr_del( dev->agp->agp_mtrr,
dev->agp->agp_info.aper_base,
@@ -734,8 +716,7 @@ static void __exit drm_cleanup( drm_device_t *dev )
DRM_DEBUG( "mtrr_del=%d\n", retval );
}
#endif
-#if __REALLY_HAVE_AGP
- if ( dev->agp ) {
+ if ( (dev->driver_features & DRIVER_USE_AGP) && dev->agp ) {
DRM(agp_uninit)();
DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS );
dev->agp = NULL;
@@ -942,9 +923,10 @@ int DRM(release)( struct inode *inode, struct file *filp )
}
}
-#if __HAVE_DMA
- DRM(reclaim_buffers)( filp );
-#endif
+ if (dev->driver_features & DRIVER_HAVE_DMA)
+ {
+ dev->fn_tbl.reclaim_buffers(filp);
+ }
DRM(fasync)( -1, filp, 0 );
@@ -957,9 +939,9 @@ int DRM(release)( struct inode *inode, struct file *filp )
pos->handle != DRM_KERNEL_CONTEXT ) {
if (dev->fn_tbl.context_dtor)
dev->fn_tbl.context_dtor(dev, pos->handle);
-#if __HAVE_CTX_BITMAP
+
DRM(ctxbitmap_free)( dev, pos->handle );
-#endif
+
list_del( &pos->head );
DRM(free)( pos, sizeof(*pos), DRM_MEM_CTXLIST );
--dev->ctx_count;
@@ -988,6 +970,8 @@ int DRM(release)( struct inode *inode, struct file *filp )
}
up( &dev->struct_sem );
+ if (dev->fn_tbl.free_filp_private)
+ dev->fn_tbl.free_filp_private( dev, priv );
DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES );
/* ========================================================
@@ -1086,9 +1070,6 @@ int DRM(lock)( struct inode *inode, struct file *filp,
DECLARE_WAITQUEUE( entry, current );
drm_lock_t lock;
int ret = 0;
-#if __HAVE_MULTIPLE_DMA_QUEUES
- drm_queue_t *q;
-#endif
++priv->lock_count;
@@ -1105,14 +1086,9 @@ int DRM(lock)( struct inode *inode, struct file *filp,
lock.context, current->pid,
dev->lock.hw_lock->lock, lock.flags );
-#if __HAVE_DMA_QUEUE
- if ( lock.context < 0 )
- return -EINVAL;
-#elif __HAVE_MULTIPLE_DMA_QUEUES
- if ( lock.context < 0 || lock.context >= dev->queue_count )
- return -EINVAL;
- q = dev->queuelist[lock.context];
-#endif
+ if (dev->driver_features & DRIVER_DMA_QUEUE)
+ if ( lock.context < 0 )
+ return -EINVAL;
if (dev->fn_tbl.dma_flush_block_and_flush)
ret = dev->fn_tbl.dma_flush_block_and_flush(dev, lock.context, lock.flags);
diff --git a/linux/drm_fops.h b/linux/drm_fops.h
index d21f7898..4589231f 100644
--- a/linux/drm_fops.h
+++ b/linux/drm_fops.h
@@ -54,6 +54,7 @@ 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;
@@ -74,7 +75,11 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
priv->lock_count = 0;
if (dev->fn_tbl.open_helper)
- dev->fn_tbl.open_helper(dev, priv);
+ {
+ ret=dev->fn_tbl.open_helper(dev, priv);
+ if (ret < 0)
+ goto out_free;
+ }
down(&dev->struct_sem);
if (!dev->file_last) {
@@ -106,6 +111,9 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
#endif
return 0;
+ out_free:
+ DRM(free)(priv, sizeof(*priv), DRM_MEM_FILES);
+ return ret;
}
/** No-op. */
diff --git a/linux/drm_ioctl.h b/linux/drm_ioctl.h
index 2ecce48f..049afe11 100644
--- a/linux/drm_ioctl.h
+++ b/linux/drm_ioctl.h
@@ -342,9 +342,10 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
if (sv.drm_dd_major != DRIVER_MAJOR ||
sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR)
return EINVAL;
-#ifdef DRIVER_SETVERSION
- DRIVER_SETVERSION(dev, &sv);
-#endif
+
+ if (dev->fn_tbl.set_version)
+ dev->fn_tbl.set_version(dev, &sv);
+
}
return 0;
}
diff --git a/linux/drm_irq.h b/linux/drm_irq.h
index aac0b1b0..73a62e68 100644
--- a/linux/drm_irq.h
+++ b/linux/drm_irq.h
@@ -38,16 +38,6 @@
#include <linux/interrupt.h> /* For task queue support */
-#ifndef __HAVE_SHARED_IRQ
-#define __HAVE_SHARED_IRQ 0
-#endif
-
-#if __HAVE_SHARED_IRQ
-#define DRM_IRQ_TYPE SA_SHIRQ
-#else
-#define DRM_IRQ_TYPE 0
-#endif
-
/**
* Get interrupt from bus id.
*
@@ -69,6 +59,9 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
drm_irq_busid_t __user *argp = (void __user *)arg;
drm_irq_busid_t p;
+ if (!(dev->driver_features & DRIVER_HAVE_IRQ))
+ return -EINVAL;
+
if (copy_from_user(&p, argp, sizeof(p)))
return -EFAULT;
@@ -87,8 +80,6 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
return 0;
}
-#if __HAVE_IRQ
-
/**
* Install IRQ handler.
*
@@ -102,7 +93,11 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
int DRM(irq_install)( drm_device_t *dev )
{
int ret;
-
+ unsigned long sh_flags=0;
+
+ if (!(dev->driver_features & DRIVER_HAVE_IRQ ))
+ return -EINVAL;
+
if ( dev->irq == 0 )
return -EINVAL;
@@ -123,39 +118,29 @@ int DRM(irq_install)( drm_device_t *dev )
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
-#if __HAVE_DMA
dev->dma->next_buffer = NULL;
dev->dma->next_queue = NULL;
dev->dma->this_buffer = NULL;
-#endif
-
-#ifdef __HAVE_IRQ_BH
-#if !HAS_WORKQUEUE
- INIT_LIST_HEAD( &dev->tq.list );
- dev->tq.sync = 0;
- dev->tq.routine = DRM(irq_immediate_bh);
- dev->tq.data = dev;
-#else
- INIT_WORK(&dev->work, DRM(irq_immediate_bh), dev);
-#endif
-#endif
-
-#ifdef __HAVE_VBL_IRQ
- init_waitqueue_head(&dev->vbl_queue);
- spin_lock_init( &dev->vbl_lock );
-
- INIT_LIST_HEAD( &dev->vbl_sigs.head );
-
- dev->vbl_pending = 0;
-#endif
+ if (dev->driver_features & DRIVER_IRQ_VBL) {
+ init_waitqueue_head(&dev->vbl_queue);
+
+ spin_lock_init( &dev->vbl_lock );
+
+ INIT_LIST_HEAD( &dev->vbl_sigs.head );
+
+ dev->vbl_pending = 0;
+ }
/* Before installing handler */
- DRM(driver_irq_preinstall)(dev);
+ dev->fn_tbl.irq_preinstall(dev);
/* Install handler */
- ret = request_irq( dev->irq, DRM(irq_handler),
- DRM_IRQ_TYPE, dev->devname, dev );
+ if (dev->driver_features & DRIVER_IRQ_SHARED)
+ sh_flags = SA_SHIRQ;
+
+ ret = request_irq( dev->irq, dev->fn_tbl.irq_handler,
+ sh_flags, dev->devname, dev );
if ( ret < 0 ) {
down( &dev->struct_sem );
dev->irq_enabled = 0;
@@ -164,7 +149,7 @@ int DRM(irq_install)( drm_device_t *dev )
}
/* After installing handler */
- DRM(driver_irq_postinstall)(dev);
+ dev->fn_tbl.irq_postinstall(dev);
return 0;
}
@@ -180,6 +165,9 @@ int DRM(irq_uninstall)( drm_device_t *dev )
{
int irq_enabled;
+ if (!(dev->driver_features & DRIVER_HAVE_IRQ ))
+ return -EINVAL;
+
down( &dev->struct_sem );
irq_enabled = dev->irq_enabled;
dev->irq_enabled = 0;
@@ -190,7 +178,7 @@ int DRM(irq_uninstall)( drm_device_t *dev )
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
- DRM(driver_irq_uninstall)( dev );
+ dev->fn_tbl.irq_uninstall(dev);
free_irq( dev->irq, dev );
@@ -214,25 +202,33 @@ int DRM(control)( struct inode *inode, struct file *filp,
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
drm_control_t ctl;
+
+ /* if we haven't dma then no need for this control */
+ if (!(dev->driver_features & DRIVER_HAVE_DMA))
+ return -EINVAL;
+
+ /* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */
if ( copy_from_user( &ctl, (drm_control_t __user *)arg, sizeof(ctl) ) )
return -EFAULT;
switch ( ctl.func ) {
case DRM_INST_HANDLER:
+ if (!(dev->driver_features & DRIVER_HAVE_IRQ))
+ return 0;
if (dev->if_version < DRM_IF_VERSION(1, 2) &&
ctl.irq != dev->irq)
return -EINVAL;
return DRM(irq_install)( dev );
case DRM_UNINST_HANDLER:
+ if (!(dev->driver_features & DRIVER_HAVE_IRQ))
+ return 0;
return DRM(irq_uninstall)( dev );
default:
return -EINVAL;
}
}
-#ifdef __HAVE_VBL_IRQ
-
/**
* Wait for VBLANK.
*
@@ -262,6 +258,9 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
int ret = 0;
unsigned int flags;
+ if (!(dev->driver_features & DRIVER_IRQ_VBL))
+ return -EINVAL;
+
if (!dev->irq)
return -EINVAL;
@@ -326,7 +325,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
} else {
- ret = DRM(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;
@@ -374,6 +374,4 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
spin_unlock_irqrestore( &dev->vbl_lock, flags );
}
-#endif /* __HAVE_VBL_IRQ */
-#endif /* __HAVE_IRQ */
diff --git a/linux/drm_memory.h b/linux/drm_memory.h
index d1c4b23a..c407292a 100644
--- a/linux/drm_memory.h
+++ b/linux/drm_memory.h
@@ -46,7 +46,7 @@
#define DEBUG_MEMORY 0
/* Need the 4-argument version of vmap(). */
-#if __REALLY_HAVE_AGP && defined(VMAP_4_ARGS)
+#if __OS_HAS_AGP && defined(VMAP_4_ARGS)
#include <linux/vmalloc.h>
@@ -142,12 +142,12 @@ drm_follow_page (void *vaddr)
return pte_pfn(*ptep) << PAGE_SHIFT;
}
-#endif /* __REALLY_HAVE_AGP && defined(VMAP_4_ARGS) */
+#endif /* __OS_HAS_AGP && defined(VMAP_4_ARGS) */
static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev)
{
-#if __REALLY_HAVE_AGP && defined(VMAP_4_ARGS)
- if (dev->agp && dev->agp->cant_use_aperture) {
+#if __OS_HAS_AGP && defined(VMAP_4_ARGS)
+ if ( (dev->driver_features & DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture) {
drm_map_t *map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP)
@@ -161,8 +161,8 @@ static inline void *drm_ioremap(unsigned long offset, unsigned long size, drm_de
static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size,
drm_device_t *dev)
{
-#if __REALLY_HAVE_AGP && defined(VMAP_4_ARGS)
- if (dev->agp && dev->agp->cant_use_aperture) {
+#if __OS_HAS_AGP&& defined(VMAP_4_ARGS)
+ if ( (dev->driver_features & DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture) {
drm_map_t *map = drm_lookup_map(offset, size, dev);
if (map && map->type == _DRM_AGP)
@@ -175,13 +175,13 @@ static inline void *drm_ioremap_nocache(unsigned long offset, unsigned long size
static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev)
{
-#if __REALLY_HAVE_AGP && defined(VMAP_4_ARGS)
+#if __OS_HAS_AGP && defined(VMAP_4_ARGS)
/*
* This is a bit ugly. It would be much cleaner if the DRM API would use separate
* routines for handling mappings in the AGP space. Hopefully this can be done in
* a future revision of the interface...
*/
- if (dev->agp && dev->agp->cant_use_aperture
+ if ((dev->driver_features & DRIVER_USE_AGP) && dev->agp && dev->agp->cant_use_aperture
&& ((unsigned long) pt >= VMALLOC_START && (unsigned long) pt < VMALLOC_END))
{
unsigned long offset;
@@ -344,7 +344,7 @@ void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev)
drm_ioremapfree(pt, size, dev);
}
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
/** Wrapper around agp_allocate_memory() */
DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type)
{
diff --git a/linux/drm_memory_debug.h b/linux/drm_memory_debug.h
index 6723818a..4f23918d 100644
--- a/linux/drm_memory_debug.h
+++ b/linux/drm_memory_debug.h
@@ -353,7 +353,7 @@ void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev)
}
}
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type)
{
diff --git a/linux/drm_scatter.h b/linux/drm_scatter.h
index 4aaf89d4..89ac166a 100644
--- a/linux/drm_scatter.h
+++ b/linux/drm_scatter.h
@@ -74,6 +74,9 @@ int DRM(sg_alloc)( struct inode *inode, struct file *filp,
DRM_DEBUG( "%s\n", __FUNCTION__ );
+ if ( dev->driver_features & DRIVER_SG )
+ return -EINVAL;
+
if ( dev->sg )
return -EINVAL;
@@ -207,6 +210,9 @@ int DRM(sg_free)( struct inode *inode, struct file *filp,
drm_scatter_gather_t request;
drm_sg_mem_t *entry;
+ if ( dev->driver_features & DRIVER_SG )
+ return -EINVAL;
+
if ( copy_from_user( &request,
(drm_scatter_gather_t __user *)arg,
sizeof(request) ) )
diff --git a/linux/drm_vm.h b/linux/drm_vm.h
index 7ab7d5ac..9c444aff 100644
--- a/linux/drm_vm.h
+++ b/linux/drm_vm.h
@@ -50,7 +50,7 @@
static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
unsigned long address)
{
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
drm_file_t *priv = vma->vm_file->private_data;
drm_device_t *dev = priv->dev;
drm_map_t *map = NULL;
@@ -60,6 +60,7 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
/*
* Find the right map
*/
+ if (!(dev->agp && DRIVER_USE_AGP)) goto vm_nopage_error;
if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error;
@@ -111,7 +112,7 @@ static __inline__ struct page *DRM(do_vm_nopage)(struct vm_area_struct *vma,
return page;
}
vm_nopage_error:
-#endif /* __REALLY_HAVE_AGP */
+#endif /* __OS_HAS_AGP */
return NOPAGE_SIGBUS; /* Disallow mremap */
}
@@ -205,8 +206,8 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
switch (map->type) {
case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
- if (map->mtrr >= 0) {
+#if __OS_HAS_MTRR
+ if ((dev->driver_features & DRIVER_USE_MTRR) && map->mtrr >= 0) {
int retcode;
retcode = mtrr_del(map->mtrr,
map->offset,
@@ -492,18 +493,19 @@ int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma)
return 0;
}
-#ifndef DRIVER_GET_MAP_OFS
-#define DRIVER_GET_MAP_OFS() (map->offset)
-#endif
+unsigned long DRM(core_get_map_ofs)(drm_map_t *map)
+{
+ return map->offset;
+}
-#ifndef DRIVER_GET_REG_OFS
+unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev)
+{
#ifdef __alpha__
-#define DRIVER_GET_REG_OFS() (dev->hose->dense_mem_base - \
- dev->hose->mem_space->start)
+ return dev->host->dense_mem_base - dev->hose_mem_space->start;
#else
-#define DRIVER_GET_REG_OFS() 0
-#endif
+ return 0;
#endif
+}
/**
* mmap DMA memory.
@@ -537,7 +539,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
* --BenH.
*/
if (!VM_OFFSET(vma)
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
&& (!dev->agp || dev->agp->agp_info.device->vendor != PCI_VENDOR_ID_APPLE)
#endif
)
@@ -556,7 +558,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 = DRIVER_GET_MAP_OFS();
+ off = dev->fn_tbl.get_map_ofs(map);
if (off == VM_OFFSET(vma)) break;
}
@@ -581,8 +583,8 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
switch (map->type) {
case _DRM_AGP:
-#if __REALLY_HAVE_AGP
- if (dev->agp->cant_use_aperture) {
+#if __OS_HAS_AGP
+ if ((dev->driver_features & DRIVER_USE_AGP) && dev->agp->cant_use_aperture) {
/*
* On some platforms we can't talk to bus dma address from the CPU, so for
* memory of type DRM_AGP, we'll deal with sorting out the real physical
@@ -613,7 +615,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 = DRIVER_GET_REG_OFS();
+ 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,
diff --git a/linux/ffb_context.c b/linux/ffb_context.c
index add2a743..0fccddb8 100644
--- a/linux/ffb_context.c
+++ b/linux/ffb_context.c
@@ -587,6 +587,21 @@ 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)
+{
+ return (map->offset & 0xffffffff);
+}
+
+static unsigned long ffb_driver_get_reg_ofs(drm_device_t *dev)
+{
+ ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *)dev->dev_private;
+
+ if (ffb_priv)
+ return ffb_priv->card_phys_base;
+
+ return 0;
+}
+
static void ffb_driver_register_fns(drm_device_t *dev)
{
DRM(fops).get_unmapped_area = ffb_get_unmapped_area;
@@ -596,4 +611,7 @@ static void ffb_driver_register_fns(drm_device_t *dev)
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/ffb_drv.c b/linux/ffb_drv.c
index fe0d129b..113c2d6b 100644
--- a/linux/ffb_drv.c
+++ b/linux/ffb_drv.c
@@ -28,10 +28,6 @@
#define DRIVER_COUNT_CARDS() ffb_count_card_instances()
-/* For mmap customization */
-#define DRIVER_GET_MAP_OFS() (map->offset & 0xffffffff)
-#define DRIVER_GET_REG_OFS() ffb_get_reg_offset(dev)
-
typedef struct _ffb_position_t {
int node;
int root;
@@ -273,16 +269,6 @@ unsigned long ffb_get_unmapped_area(struct file *filp,
return addr;
}
-static unsigned long ffb_get_reg_offset(drm_device_t *dev)
-{
- ffb_dev_priv_t *ffb_priv = (ffb_dev_priv_t *)dev->dev_private;
-
- if (ffb_priv)
- return ffb_priv->card_phys_base;
-
- return 0;
-}
-
#include "drm_auth.h"
#include "drm_bufs.h"
#include "drm_dma.h"
diff --git a/linux/gamma.h b/linux/gamma.h
index c30e70ea..59b2fb17 100644
--- a/linux/gamma.h
+++ b/linux/gamma.h
@@ -36,8 +36,6 @@
/* General customization:
*/
-#define __HAVE_MTRR 1
-
#define DRIVER_AUTHOR "VA Linux Systems Inc."
#define DRIVER_NAME "gamma"
@@ -65,16 +63,12 @@
/* DMA customization:
*/
-#define __HAVE_DMA 1
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 0
-#define __HAVE_OLD_DMA 1
-#define __HAVE_PCI_DMA 1
-
#define __HAVE_MULTIPLE_DMA_QUEUES 1
#define __HAVE_DMA_WAITQUEUE 1
-#define __HAVE_IRQ 1
+
#define __HAVE_IRQ_BH 1
+#error "Gamma is broken"
+
#endif /* __GAMMA_H__ */
diff --git a/linux/gamma_context.h b/linux/gamma_context.h
index d11b507f..0358f679 100644
--- a/linux/gamma_context.h
+++ b/linux/gamma_context.h
@@ -490,3 +490,17 @@ int DRM(rmctx)(struct inode *inode, struct file *filp,
return 0;
}
+void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle )
+{
+
+}
+
+void DRM(ctxbitmap_cleanup)( drm_device_t *dev )
+{
+
+}
+
+int DRM(ctxbitmap_init)( drm_device_t *dev )
+{
+ return 0;
+}
diff --git a/linux/gamma_dma.c b/linux/gamma_dma.c
index 2a79f71b..fa3201b3 100644
--- a/linux/gamma_dma.c
+++ b/linux/gamma_dma.c
@@ -117,7 +117,7 @@ static inline int gamma_dma_is_ready(drm_device_t *dev)
return (!GAMMA_READ(GAMMA_DMACOUNT));
}
-irqreturn_t gamma_irq_handler( DRM_IRQ_ARGS )
+irqreturn_t gamma_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *)arg;
drm_device_dma_t *dma = dev->dma;
@@ -696,13 +696,13 @@ int gamma_do_cleanup_dma( drm_device_t *dev )
{
DRM_DEBUG( "%s\n", __FUNCTION__ );
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
+ if ( dev->driver_features & DRIVER_HAVE_IRQ )
+ if ( dev->irq_enabled )
+ DRM(irq_uninstall)(dev);
if ( dev->dev_private ) {
@@ -873,7 +873,7 @@ int gamma_setsareactx(struct inode *inode, struct file *filp,
return 0;
}
-void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+void gamma_driver_irq_preinstall( drm_device_t *dev ) {
drm_gamma_private_t *dev_priv =
(drm_gamma_private_t *)dev->dev_private;
@@ -884,7 +884,7 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
GAMMA_WRITE( GAMMA_GDMACONTROL, 0x00000000 );
}
-void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+void gamma_driver_irq_postinstall( drm_device_t *dev ) {
drm_gamma_private_t *dev_priv =
(drm_gamma_private_t *)dev->dev_private;
@@ -896,7 +896,7 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
GAMMA_WRITE( GAMMA_GDELAYTIMER, 0x00039090 );
}
-void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+void gamma_driver_irq_uninstall( drm_device_t *dev ) {
drm_gamma_private_t *dev_priv =
(drm_gamma_private_t *)dev->dev_private;
if (!dev_priv)
@@ -941,6 +941,7 @@ static int gamma_driver_dma_quiescent(drm_device_t *dev)
void gamma_driver_register_fns(drm_device_t *dev)
{
+ dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ;
DRM(fops).read = gamma_fops_read;
DRM(fops).poll = gamma_fops_poll;
dev->fn_tbl.preinit = gamma_driver_preinit;
@@ -954,4 +955,8 @@ void gamma_driver_register_fns(drm_device_t *dev)
dev->fn_tbl.freelist_create = gamma_freelist_create;
dev->fn_tbl.freelist_put = gamma_freelist_put;
dev->fn_tbl.freelist_destroy = gamma_freelist_destroy;
+ dev->fn_tbl.irq_preinstall = gamma_driver_irq_preinstall;
+ dev->fn_tbl.irq_postinstall = gamma_driver_irq_postinstall;
+ dev->fn_tbl.irq_uninstall = gamma_driver_irq_uninstall;
+ dev->fn_tbl.irq_handler = gamma_driver_irq_handler;
}
diff --git a/linux/gamma_drv.c b/linux/gamma_drv.c
index b1fb0505..315cab61 100644
--- a/linux/gamma_drv.c
+++ b/linux/gamma_drv.c
@@ -40,6 +40,8 @@
#include "drm_agpsupport.h"
#include "drm_bufs.h"
#include "gamma_context.h" /* NOTE! */
+#define DRIVER_ALTERNATE_CONTEXT
+#include "drm_context.h"
#include "drm_dma.h"
#include "gamma_old_dma.h" /* NOTE */
#include "drm_drawable.h"
@@ -56,3 +58,4 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux/i810.h b/linux/i810.h
index aea8a63c..ee682368 100644
--- a/linux/i810.h
+++ b/linux/i810.h
@@ -36,10 +36,6 @@
/* General customization:
*/
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 1
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "VA Linux Systems Inc."
@@ -84,16 +80,4 @@
#define __HAVE_COUNTER8 _DRM_STAT_SECONDARY
#define __HAVE_COUNTER9 _DRM_STAT_DMA
-/* DMA customization:
- */
-#define __HAVE_DMA 1
-#define __HAVE_DMA_QUEUE 1
-#define __HAVE_DMA_RECLAIM 1
-
-/* Don't need an irq any more. The template code will make sure that
- * a noop stub is generated for compatibility.
- */
-/* XXX: Add vblank support? */
-#define __HAVE_IRQ 0
-
#endif
diff --git a/linux/i810_dma.c b/linux/i810_dma.c
index d558988f..8ee32f74 100644
--- a/linux/i810_dma.c
+++ b/linux/i810_dma.c
@@ -239,13 +239,12 @@ int i810_dma_cleanup(drm_device_t *dev)
{
drm_device_dma_t *dma = dev->dma;
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
+ if ( (dev->driver_features & DRIVER_HAVE_IRQ) && dev->irq_enabled )
+ DRM(irq_uninstall)(dev);
if (dev->dev_private) {
int i;
@@ -1413,9 +1412,11 @@ static int i810_driver_dma_quiescent(drm_device_t *dev)
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;
}
diff --git a/linux/i810_drv.c b/linux/i810_drv.c
index 0bc79386..1ab8b013 100644
--- a/linux/i810_drv.c
+++ b/linux/i810_drv.c
@@ -48,8 +48,10 @@
#include "drm_fops.h"
#include "drm_init.h"
#include "drm_ioctl.h"
+#include "drm_irq.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux/i830.h b/linux/i830.h
index 7e176f2c..eb2d9449 100644
--- a/linux/i830.h
+++ b/linux/i830.h
@@ -36,10 +36,6 @@
/* General customization:
*/
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 1
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "VA Linux Systems Inc."
@@ -83,12 +79,6 @@
#define __HAVE_COUNTER8 _DRM_STAT_SECONDARY
#define __HAVE_COUNTER9 _DRM_STAT_DMA
-/* DMA customization:
- */
-#define __HAVE_DMA 1
-#define __HAVE_DMA_QUEUE 1
-#define __HAVE_DMA_RECLAIM 1
-
/* 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.
@@ -96,11 +86,4 @@
/* XXX: Add vblank support? */
#define USE_IRQS 0
-#if USE_IRQS
-#define __HAVE_IRQ 1
-#define __HAVE_SHARED_IRQ 1
-#else
-#define __HAVE_IRQ 0
-#endif
-
#endif
diff --git a/linux/i830_dma.c b/linux/i830_dma.c
index 1a8c6336..8a110403 100644
--- a/linux/i830_dma.c
+++ b/linux/i830_dma.c
@@ -240,13 +240,11 @@ int i830_dma_cleanup(drm_device_t *dev)
{
drm_device_dma_t *dma = dev->dma;
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
if (dev->dev_private) {
int i;
@@ -1609,9 +1607,20 @@ static int i830_driver_dma_quiescent(drm_device_t *dev)
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
}
diff --git a/linux/i830_drv.c b/linux/i830_drv.c
index 2f4e8157..900706cf 100644
--- a/linux/i830_drv.c
+++ b/linux/i830_drv.c
@@ -56,3 +56,4 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux/i830_drv.h b/linux/i830_drv.h
index ad4de4c3..c3cab2d8 100644
--- a/linux/i830_drv.h
+++ b/linux/i830_drv.h
@@ -136,6 +136,10 @@ extern int i830_irq_wait( struct inode *inode, struct file *filp,
extern int i830_wait_irq(drm_device_t *dev, int irq_nr);
extern int i830_emit_irq(drm_device_t *dev);
+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 );
#define I830_BASE(reg) ((unsigned long) \
dev_priv->mmio_map->handle)
diff --git a/linux/i830_irq.c b/linux/i830_irq.c
index 7a066b6f..0bb4ce8e 100644
--- a/linux/i830_irq.c
+++ b/linux/i830_irq.c
@@ -36,7 +36,7 @@
#include <linux/delay.h>
-irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
+irqreturn_t i830_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *)arg;
drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
@@ -179,7 +179,7 @@ int i830_irq_wait( struct inode *inode, struct file *filp, unsigned int cmd,
/* drm_dma.h hooks
*/
-void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+void i830_driver_irq_preinstall( drm_device_t *dev ) {
drm_i830_private_t *dev_priv =
(drm_i830_private_t *)dev->dev_private;
@@ -191,14 +191,14 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
init_waitqueue_head(&dev_priv->irq_queue);
}
-void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+void i830_driver_irq_postinstall( drm_device_t *dev ) {
drm_i830_private_t *dev_priv =
(drm_i830_private_t *)dev->dev_private;
I830_WRITE16( I830REG_INT_ENABLE_R, 0x2 );
}
-void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+void i830_driver_irq_uninstall( drm_device_t *dev ) {
drm_i830_private_t *dev_priv =
(drm_i830_private_t *)dev->dev_private;
if (!dev_priv)
diff --git a/linux/i915_drv.c b/linux/i915_drv.c
index 1e563387..6078b54f 100644
--- a/linux/i915_drv.c
+++ b/linux/i915_drv.c
@@ -19,6 +19,7 @@
#include "drm_bufs.h"
#include "drm_context.h" /* is this needed? */
#include "drm_drawable.h" /* is this needed? */
+#include "drm_dma.h"
#include "drm_drv.h"
#include "drm_fops.h"
#include "drm_init.h"
@@ -29,3 +30,4 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux/mach64_drv.c b/linux/mach64_drv.c
index 56d79137..32f6cddc 100644
--- a/linux/mach64_drv.c
+++ b/linux/mach64_drv.c
@@ -51,3 +51,4 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux/mga_drv.c b/linux/mga_drv.c
index 6bcad048..57940d5d 100644
--- a/linux/mga_drv.c
+++ b/linux/mga_drv.c
@@ -51,3 +51,4 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux/savage.h b/linux/savage.h
index fb828ce6..cb50d6e2 100644
--- a/linux/savage.h
+++ b/linux/savage.h
@@ -29,11 +29,4 @@
*/
#define DRM(x) savage_##x
-/* General customization:
- */
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 1
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
-
#endif
diff --git a/linux/savage_dma.c b/linux/savage_dma.c
index 34410116..271d1f23 100644
--- a/linux/savage_dma.c
+++ b/linux/savage_dma.c
@@ -37,4 +37,5 @@
void DRM(driver_register_fns)(drm_device_t *dev)
{
+ dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR;
}
diff --git a/linux/savage_drv.c b/linux/savage_drv.c
index 331bbc9e..481a3886 100644
--- a/linux/savage_drv.c
+++ b/linux/savage_drv.c
@@ -265,11 +265,13 @@ int savage_free_cont_mem(struct inode *inode, struct file *filp,
#include "drm_fops.h"
#include "drm_init.h"
#include "drm_ioctl.h"
+#include "drm_irq.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux/sis_drv.c b/linux/sis_drv.c
index fce5470b..0b968dc2 100644
--- a/linux/sis_drv.c
+++ b/linux/sis_drv.c
@@ -40,11 +40,13 @@
#include "drm_drv.h"
#include "drm_fops.h"
#include "drm_init.h"
+#include "drm_irq.h"
#include "drm_ioctl.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux/tdfx_drv.c b/linux/tdfx_drv.c
index f3fcdf84..f34d32db 100644
--- a/linux/tdfx_drv.c
+++ b/linux/tdfx_drv.c
@@ -34,6 +34,7 @@
#include "tdfx.h"
#include "drmP.h"
+#include "drm_agpsupport.h"
#include "drm_auth.h"
#include "drm_bufs.h"
#include "drm_context.h"
@@ -44,13 +45,16 @@
#include "drm_fops.h"
#include "drm_init.h"
#include "drm_ioctl.h"
+#include "drm_irq.h"
#include "drm_lock.h"
#include "drm_memory.h"
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
void DRM(driver_register_fns)(drm_device_t *dev)
{
+ dev->driver_features = DRIVER_USE_MTRR;
}
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index 72573cbb..91de65a7 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -790,6 +790,11 @@ static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
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;
}
diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h
index 40530eb0..4773d056 100644
--- a/shared-core/i915_drv.h
+++ b/shared-core/i915_drv.h
@@ -76,6 +76,10 @@ extern int i915_irq_wait( DRM_IOCTL_ARGS );
extern int i915_wait_irq(drm_device_t *dev, int irq_nr);
extern int i915_emit_irq(drm_device_t *dev);
+extern irqreturn_t i915_driver_irq_handler( DRM_IRQ_ARGS );
+extern void i915_driver_irq_preinstall( drm_device_t *dev );
+extern void i915_driver_irq_postinstall( drm_device_t *dev );
+extern void i915_driver_irq_uninstall( drm_device_t *dev );
/* i915_mem.c */
extern int i915_mem_alloc( DRM_IOCTL_ARGS );
diff --git a/shared-core/i915_irq.c b/shared-core/i915_irq.c
index e37da827..96c7e0f5 100644
--- a/shared-core/i915_irq.c
+++ b/shared-core/i915_irq.c
@@ -19,7 +19,7 @@
#define READ_BREADCRUMB(dev_priv) (((u32*)(dev_priv->hw_status_page))[5])
-irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
+irqreturn_t i915_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *)arg;
drm_i915_private_t *dev_priv = (drm_i915_private_t *)dev->dev_private;
@@ -144,7 +144,7 @@ int i915_irq_wait( DRM_IOCTL_ARGS )
/* drm_dma.h hooks
*/
-void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+void i915_driver_irq_preinstall( drm_device_t *dev ) {
drm_i915_private_t *dev_priv =
(drm_i915_private_t *)dev->dev_private;
@@ -153,7 +153,7 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
I915_WRITE16( I915REG_INT_ENABLE_R, 0x0 );
}
-void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+void i915_driver_irq_postinstall( drm_device_t *dev ) {
drm_i915_private_t *dev_priv =
(drm_i915_private_t *)dev->dev_private;
@@ -161,7 +161,7 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
}
-void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+void i915_driver_irq_uninstall( drm_device_t *dev ) {
drm_i915_private_t *dev_priv =
(drm_i915_private_t *)dev->dev_private;
if (!dev_priv)
diff --git a/shared-core/mach64_dma.c b/shared-core/mach64_dma.c
index 4f90916d..210a6103 100644
--- a/shared-core/mach64_dma.c
+++ b/shared-core/mach64_dma.c
@@ -972,13 +972,11 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
{
DRM_DEBUG( "%s\n", __FUNCTION__ );
-#if _HAVE_DMA_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
if ( dev->irq ) DRM(irq_uninstall)(dev);
-#endif
if ( dev->dev_private ) {
drm_mach64_private_t *dev_priv = dev->dev_private;
@@ -1335,5 +1333,11 @@ static void mach64_driver_pretakedown(drm_device_t *dev)
void mach64_driver_register_fns(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;
}
diff --git a/shared-core/mach64_drv.h b/shared-core/mach64_drv.h
index d009d29e..b49e6f65 100644
--- a/shared-core/mach64_drv.h
+++ b/shared-core/mach64_drv.h
@@ -127,6 +127,12 @@ extern int mach64_dma_swap( DRM_IOCTL_ARGS );
extern int mach64_dma_vertex( DRM_IOCTL_ARGS );
extern int mach64_dma_blit( DRM_IOCTL_ARGS );
extern int mach64_get_param( DRM_IOCTL_ARGS );
+extern int mach64_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
+
+extern irqreturn_t mach64_driver_irq_handler( DRM_IRQ_ARGS );
+extern void mach64_driver_irq_preinstall( drm_device_t *dev );
+extern void mach64_driver_irq_postinstall( drm_device_t *dev );
+extern void mach64_driver_irq_uninstall( drm_device_t *dev );
/* ================================================================
* Registers
diff --git a/shared-core/mach64_irq.c b/shared-core/mach64_irq.c
index 9acd6269..efa0641f 100644
--- a/shared-core/mach64_irq.c
+++ b/shared-core/mach64_irq.c
@@ -40,7 +40,7 @@
#include "mach64_drm.h"
#include "mach64_drv.h"
-irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
+irqreturn_t mach64_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *) arg;
drm_mach64_private_t *dev_priv =
@@ -69,7 +69,7 @@ irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
return IRQ_NONE;
}
-int DRM(vblank_wait)(drm_device_t *dev, unsigned int *sequence)
+int mach64_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
{
unsigned int cur_vblank;
int ret = 0;
@@ -89,7 +89,7 @@ int DRM(vblank_wait)(drm_device_t *dev, unsigned int *sequence)
/* drm_dma.h hooks
*/
-void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+void mach64_driver_irq_preinstall( drm_device_t *dev ) {
drm_mach64_private_t *dev_priv =
(drm_mach64_private_t *)dev->dev_private;
@@ -102,7 +102,7 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
| MACH64_CRTC_VBLANK_INT );
}
-void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+void mach64_driver_irq_postinstall( drm_device_t *dev ) {
drm_mach64_private_t *dev_priv =
(drm_mach64_private_t *)dev->dev_private;
@@ -114,7 +114,7 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
}
-void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+void mach64_driver_irq_uninstall( drm_device_t *dev ) {
drm_mach64_private_t *dev_priv =
(drm_mach64_private_t *)dev->dev_private;
if ( !dev_priv )
diff --git a/shared-core/mga_dma.c b/shared-core/mga_dma.c
index 2a095014..409f0ab7 100644
--- a/shared-core/mga_dma.c
+++ b/shared-core/mga_dma.c
@@ -630,13 +630,11 @@ int mga_do_cleanup_dma( drm_device_t *dev )
{
DRM_DEBUG( "\n" );
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
if ( dev->dev_private ) {
drm_mga_private_t *dev_priv = dev->dev_private;
@@ -815,6 +813,12 @@ static int mga_driver_dma_quiescent(drm_device_t *dev)
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;
}
diff --git a/shared-core/mga_drv.h b/shared-core/mga_drv.h
index 65847165..75dcb0e9 100644
--- a/shared-core/mga_drv.h
+++ b/shared-core/mga_drv.h
@@ -130,6 +130,12 @@ extern int mga_getparam( DRM_IOCTL_ARGS );
extern int mga_warp_install_microcode( drm_mga_private_t *dev_priv );
extern int mga_warp_init( drm_mga_private_t *dev_priv );
+extern int mga_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
+extern irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS );
+extern void mga_driver_irq_preinstall( drm_device_t *dev );
+extern void mga_driver_irq_postinstall( drm_device_t *dev );
+extern void mga_driver_irq_uninstall( drm_device_t *dev );
+
#define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER()
#if defined(__linux__) && defined(__alpha__)
diff --git a/shared-core/mga_irq.c b/shared-core/mga_irq.c
index e486618b..c3185b0b 100644
--- a/shared-core/mga_irq.c
+++ b/shared-core/mga_irq.c
@@ -36,7 +36,7 @@
#include "mga_drm.h"
#include "mga_drv.h"
-irqreturn_t mga_irq_handler( DRM_IRQ_ARGS )
+irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *) arg;
drm_mga_private_t *dev_priv =
@@ -56,7 +56,7 @@ irqreturn_t mga_irq_handler( DRM_IRQ_ARGS )
return IRQ_NONE;
}
-int mga_vblank_wait(drm_device_t *dev, unsigned int *sequence)
+int mga_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
{
unsigned int cur_vblank;
int ret = 0;
diff --git a/shared-core/r128_cce.c b/shared-core/r128_cce.c
index c6c7f6d3..64c9b8be 100644
--- a/shared-core/r128_cce.c
+++ b/shared-core/r128_cce.c
@@ -322,7 +322,7 @@ static void r128_cce_init_ring_buffer( drm_device_t *dev,
/* The manual (p. 2) says this address is in "VM space". This
* means it's an offset from the start of AGP space.
*/
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( !dev_priv->is_pci )
ring_start = dev_priv->cce_ring->offset - dev->agp->base;
else
@@ -510,7 +510,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
(drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle +
init->sarea_priv_offset);
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( !dev_priv->is_pci ) {
drm_core_ioremap( dev_priv->cce_ring, dev );
drm_core_ioremap( dev_priv->ring_rptr, dev );
@@ -533,7 +533,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset;
}
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( !dev_priv->is_pci )
dev_priv->cce_buffers_offset = dev->agp->base;
else
@@ -558,7 +558,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
R128_WRITE( R128_LAST_DISPATCH_REG,
dev_priv->sarea_priv->last_dispatch );
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( dev_priv->is_pci ) {
#endif
if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
@@ -569,7 +569,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
return DRM_ERR(ENOMEM);
}
R128_WRITE( R128_PCI_GART_PAGE, dev_priv->bus_pci_gart );
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
}
#endif
@@ -586,18 +586,16 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
int r128_do_cleanup_cce( drm_device_t *dev )
{
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
if ( dev->dev_private ) {
drm_r128_private_t *dev_priv = dev->dev_private;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( !dev_priv->is_pci ) {
if ( dev_priv->cce_ring != NULL )
drm_core_ioremapfree( dev_priv->cce_ring, dev );
diff --git a/shared-core/r128_drv.h b/shared-core/r128_drv.h
index 12ca9b4f..5b91256c 100644
--- a/shared-core/r128_drv.h
+++ b/shared-core/r128_drv.h
@@ -142,6 +142,12 @@ extern int r128_cce_depth( DRM_IOCTL_ARGS );
extern int r128_cce_stipple( DRM_IOCTL_ARGS );
extern int r128_cce_indirect( DRM_IOCTL_ARGS );
+extern int r128_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
+
+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 );
/* 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 e77a5538..be1b9dac 100644
--- a/shared-core/r128_irq.c
+++ b/shared-core/r128_irq.c
@@ -36,7 +36,7 @@
#include "r128_drm.h"
#include "r128_drv.h"
-irqreturn_t r128_irq_handler( DRM_IRQ_ARGS )
+irqreturn_t r128_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *) arg;
drm_r128_private_t *dev_priv =
@@ -56,7 +56,7 @@ irqreturn_t r128_irq_handler( DRM_IRQ_ARGS )
return IRQ_NONE;
}
-int DRM(vblank_wait)(drm_device_t *dev, unsigned int *sequence)
+int r128_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
{
unsigned int cur_vblank;
int ret = 0;
diff --git a/shared-core/r128_state.c b/shared-core/r128_state.c
index 88d7715a..d772f173 100644
--- a/shared-core/r128_state.c
+++ b/shared-core/r128_state.c
@@ -1712,7 +1712,13 @@ static void r128_driver_pretakedown(drm_device_t *dev)
void r128_driver_register_fns(drm_device_t *dev)
{
- dev->dev_priv_size = sizeof(drm_r128_buf_priv_t);
+ 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 6987a84c..1e87ff37 100644
--- a/shared-core/radeon_cp.c
+++ b/shared-core/radeon_cp.c
@@ -858,7 +858,7 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev,
( ( dev_priv->gart_vm_start - 1 ) & 0xffff0000 )
| ( dev_priv->fb_location >> 16 ) );
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
RADEON_WRITE( RADEON_MC_AGP_LOCATION,
(((dev_priv->gart_vm_start - 1 +
@@ -885,7 +885,7 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev,
SET_RING_HEAD( dev_priv, cur_read_ptr );
dev_priv->ring.tail = cur_read_ptr;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
/* set RADEON_AGP_BASE here instead of relying on X from user space */
RADEON_WRITE( RADEON_AGP_BASE, (unsigned int)dev->agp->base );
@@ -1146,7 +1146,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
(drm_radeon_sarea_t *)((u8 *)dev_priv->sarea->handle +
init->sarea_priv_offset);
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( dev_priv->flags & CHIP_IS_AGP ) {
drm_core_ioremap( dev_priv->cp_ring, dev );
drm_core_ioremap( dev_priv->ring_rptr, dev );
@@ -1195,7 +1195,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv->gart_vm_start = dev_priv->fb_location
+ RADEON_READ( RADEON_CONFIG_APER_SIZE );
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP)
dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
- dev->agp->base
@@ -1224,7 +1224,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
/* Turn off PCI GART */
radeon_set_pcigart( dev_priv, 0 );
@@ -1257,15 +1257,13 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
if ( dev_priv->cp_ring != NULL ) {
drm_core_ioremapfree( dev_priv->cp_ring, dev );
@@ -1315,7 +1313,7 @@ static int radeon_do_resume_cp( drm_device_t *dev )
DRM_DEBUG("Starting radeon_do_resume_cp()\n");
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
/* Turn off PCI GART */
radeon_set_pcigart( dev_priv, 0 );
diff --git a/shared-core/radeon_drv.h b/shared-core/radeon_drv.h
index 4b66e5be..8c584864 100644
--- a/shared-core/radeon_drv.h
+++ b/shared-core/radeon_drv.h
@@ -72,6 +72,9 @@ typedef struct drm_radeon_depth_clear_t {
u32 se_cntl;
} drm_radeon_depth_clear_t;
+struct drm_radeon_driver_file_fields {
+ int64_t radeon_fb_delta;
+};
struct mem_block {
struct mem_block *next;
@@ -216,6 +219,11 @@ extern int radeon_wait_irq(drm_device_t *dev, int swi_nr);
extern int radeon_emit_irq(drm_device_t *dev);
extern void radeon_do_release(drm_device_t *dev);
+extern int radeon_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
+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 );
/* Flags for stats.boxes
*/
diff --git a/shared-core/radeon_irq.c b/shared-core/radeon_irq.c
index 51d19493..bdb3cc16 100644
--- a/shared-core/radeon_irq.c
+++ b/shared-core/radeon_irq.c
@@ -54,7 +54,7 @@
* tied to dma at all, this is just a hangover from dri prehistory.
*/
-irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
+irqreturn_t radeon_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *) arg;
drm_radeon_private_t *dev_priv =
@@ -141,7 +141,7 @@ int radeon_emit_and_wait_irq(drm_device_t *dev)
}
-int DRM(vblank_wait)(drm_device_t *dev, unsigned int *sequence)
+int radeon_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
{
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
diff --git a/shared-core/radeon_state.c b/shared-core/radeon_state.c
index 4a7bfd2d..cdbd7a8e 100644
--- a/shared-core/radeon_state.c
+++ b/shared-core/radeon_state.c
@@ -43,12 +43,15 @@ static __inline__ int radeon_check_and_fixup_offset( drm_radeon_private_t *dev_p
drm_file_t *filp_priv,
u32 *offset ) {
u32 off = *offset;
+ struct drm_radeon_driver_file_fields *radeon_priv;
if ( off >= dev_priv->fb_location &&
off < ( dev_priv->gart_vm_start + dev_priv->gart_size ) )
return 0;
- off += filp_priv->radeon_fb_delta;
+ radeon_priv = filp_priv->driver_priv;
+
+ off += radeon_priv->radeon_fb_delta;
DRM_DEBUG( "offset fixed up to 0x%x\n", off );
@@ -2525,7 +2528,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_file_t *filp_priv;
drm_radeon_setparam_t sp;
-
+ struct drm_radeon_driver_file_fields *radeon_priv;
+
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
return DRM_ERR( EINVAL );
@@ -2538,7 +2542,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
switch( sp.param ) {
case RADEON_SETPARAM_FB_LOCATION:
- filp_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
+ radeon_priv = filp_priv->driver_priv;
+ radeon_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
break;
default:
DRM_DEBUG( "Invalid parameter %d\n", sp.param );
@@ -2571,17 +2576,35 @@ static void radeon_driver_pretakedown(drm_device_t *dev)
radeon_do_release(dev);
}
-static void radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
+static 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);
+
+ if (!radeon_priv)
+ return -ENOMEM;
+
+ filp_priv->driver_priv = radeon_priv;
+
if ( dev_priv )
- filp_priv->radeon_fb_delta = dev_priv->fb_location;
+ radeon_priv->radeon_fb_delta = dev_priv->fb_location;
else
- filp_priv->radeon_fb_delta = 0;
+ radeon_priv->radeon_fb_delta = 0;
+ return 0;
+}
+
+static void radeon_driver_free_filp_private(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);
}
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;
@@ -2589,4 +2612,10 @@ void radeon_driver_register_fns(struct drm_device *dev)
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_private = radeon_driver_free_filp_private;
}
diff --git a/shared-core/sis_mm.c b/shared-core/sis_mm.c
index 233843d5..27b904fc 100644
--- a/shared-core/sis_mm.c
+++ b/shared-core/sis_mm.c
@@ -411,6 +411,7 @@ int sis_final_context(struct drm_device *dev, int context)
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/tdfx_drv.h b/shared-core/tdfx_drv.h
index 6b067db7..a582a3db 100644
--- a/shared-core/tdfx_drv.h
+++ b/shared-core/tdfx_drv.h
@@ -36,8 +36,6 @@
/* General customization:
*/
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "VA Linux Systems Inc."
diff --git a/shared-core/via_drv.c b/shared-core/via_drv.c
index 77423764..b3119f66 100644
--- a/shared-core/via_drv.c
+++ b/shared-core/via_drv.c
@@ -68,4 +68,5 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/shared-core/via_drv.h b/shared-core/via_drv.h
index 582eb6de..dd4a370f 100644
--- a/shared-core/via_drv.h
+++ b/shared-core/via_drv.h
@@ -64,6 +64,14 @@ extern int via_do_init_map(drm_device_t *dev, drm_via_init_t *init);
extern int via_do_cleanup_map(drm_device_t *dev);
extern int via_map_init(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
+extern int via_driver_vblank_wait(drm_device_t* dev, unsigned int* sequence);
+
+extern irqreturn_t via_driver_irq_handler( DRM_IRQ_ARGS );
+extern void via_driver_irq_preinstall( drm_device_t *dev );
+extern void via_driver_irq_postinstall( drm_device_t *dev );
+extern void via_driver_irq_uninstall( drm_device_t *dev );
+
+extern int via_dma_cleanup(drm_device_t *dev);
extern int via_dma_cleanup(drm_device_t *dev);
diff --git a/shared-core/via_irq.c b/shared-core/via_irq.c
index 7e540cc1..eafb1d7d 100644
--- a/shared-core/via_irq.c
+++ b/shared-core/via_irq.c
@@ -46,8 +46,7 @@
#define VIA_IRQ_VBI_ENABLE (1 << 19)
#define VIA_IRQ_VBI_PENDING (1 << 3)
-irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
-
+irqreturn_t via_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t* dev = (drm_device_t*)arg;
drm_via_private_t* dev_priv = (drm_via_private_t*)dev->dev_private;
@@ -83,7 +82,7 @@ static __inline__ void viadrv_acknowledge_irqs(drm_via_private_t* dev_priv)
}
}
-int DRM(vblank_wait)(drm_device_t* dev, unsigned int* sequence)
+int via_driver_vblank_wait(drm_device_t* dev, unsigned int* sequence)
{
drm_via_private_t* dev_priv = (drm_via_private_t*)dev->dev_private;
unsigned int cur_vblank;
@@ -112,7 +111,7 @@ int DRM(vblank_wait)(drm_device_t* dev, unsigned int* sequence)
/*
* drm_dma.h hooks
*/
-void DRM(driver_irq_preinstall)(drm_device_t* dev){
+void via_driver_irq_preinstall(drm_device_t* dev){
drm_via_private_t* dev_priv = (drm_via_private_t *)dev->dev_private;
u32 status;
@@ -130,7 +129,7 @@ void DRM(driver_irq_preinstall)(drm_device_t* dev){
}
}
-void DRM(driver_irq_postinstall)(drm_device_t* dev){
+void via_driver_irq_postinstall(drm_device_t* dev){
drm_via_private_t* dev_priv = (drm_via_private_t *)dev->dev_private;
u32 status;
@@ -147,7 +146,7 @@ void DRM(driver_irq_postinstall)(drm_device_t* dev){
}
}
-void DRM(driver_irq_uninstall)(drm_device_t* dev){
+void via_driver_irq_uninstall(drm_device_t* dev){
drm_via_private_t* dev_priv = (drm_via_private_t *)dev->dev_private;
u32 status;
diff --git a/shared-core/via_mm.c b/shared-core/via_mm.c
index fa37e782..117cca70 100644
--- a/shared-core/via_mm.c
+++ b/shared-core/via_mm.c
@@ -358,6 +358,12 @@ EXPORT_SYMBOL(via_fb_free);
void DRM(driver_register_fns)(drm_device_t *dev)
{
- dev->fn_tbl.context_ctor = via_init_context;
- dev->fn_tbl.context_dtor = via_final_context;
+ 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.h b/shared/i915.h
index a5844e4c..5a234a18 100644
--- a/shared/i915.h
+++ b/shared/i915.h
@@ -16,10 +16,6 @@
/* General customization:
*/
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 1
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "Tungsten Graphics, Inc."
@@ -60,10 +56,6 @@
/* We use our own dma mechanisms, not the drm template code. However,
* the shared IRQ code is useful to us:
*/
-#define __HAVE_DMA 0
-#define __HAVE_IRQ 1
-#define __HAVE_SHARED_IRQ 1
-
#define __HAVE_PM 1
diff --git a/shared/i915_dma.c b/shared/i915_dma.c
index 72573cbb..91de65a7 100644
--- a/shared/i915_dma.c
+++ b/shared/i915_dma.c
@@ -790,6 +790,11 @@ static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
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;
}
diff --git a/shared/i915_drv.h b/shared/i915_drv.h
index 40530eb0..4773d056 100644
--- a/shared/i915_drv.h
+++ b/shared/i915_drv.h
@@ -76,6 +76,10 @@ extern int i915_irq_wait( DRM_IOCTL_ARGS );
extern int i915_wait_irq(drm_device_t *dev, int irq_nr);
extern int i915_emit_irq(drm_device_t *dev);
+extern irqreturn_t i915_driver_irq_handler( DRM_IRQ_ARGS );
+extern void i915_driver_irq_preinstall( drm_device_t *dev );
+extern void i915_driver_irq_postinstall( drm_device_t *dev );
+extern void i915_driver_irq_uninstall( drm_device_t *dev );
/* i915_mem.c */
extern int i915_mem_alloc( DRM_IOCTL_ARGS );
diff --git a/shared/i915_irq.c b/shared/i915_irq.c
index e37da827..96c7e0f5 100644
--- a/shared/i915_irq.c
+++ b/shared/i915_irq.c
@@ -19,7 +19,7 @@
#define READ_BREADCRUMB(dev_priv) (((u32*)(dev_priv->hw_status_page))[5])
-irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
+irqreturn_t i915_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *)arg;
drm_i915_private_t *dev_priv = (drm_i915_private_t *)dev->dev_private;
@@ -144,7 +144,7 @@ int i915_irq_wait( DRM_IOCTL_ARGS )
/* drm_dma.h hooks
*/
-void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+void i915_driver_irq_preinstall( drm_device_t *dev ) {
drm_i915_private_t *dev_priv =
(drm_i915_private_t *)dev->dev_private;
@@ -153,7 +153,7 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
I915_WRITE16( I915REG_INT_ENABLE_R, 0x0 );
}
-void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+void i915_driver_irq_postinstall( drm_device_t *dev ) {
drm_i915_private_t *dev_priv =
(drm_i915_private_t *)dev->dev_private;
@@ -161,7 +161,7 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
}
-void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+void i915_driver_irq_uninstall( drm_device_t *dev ) {
drm_i915_private_t *dev_priv =
(drm_i915_private_t *)dev->dev_private;
if (!dev_priv)
diff --git a/shared/mach64.h b/shared/mach64.h
index 6cfb786e..9fae3433 100644
--- a/shared/mach64.h
+++ b/shared/mach64.h
@@ -38,11 +38,6 @@
/* General customization:
*/
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 0
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
-#define __HAVE_PCI_DMA 1
#define DRIVER_AUTHOR "Gareth Hughes, Leif Delgass, José Fonseca"
@@ -71,12 +66,4 @@
[DRM_IOCTL_NR(DRM_IOCTL_MACH64_FLUSH)] = { mach64_dma_flush, 1, 0 }, \
[DRM_IOCTL_NR(DRM_IOCTL_MACH64_GETPARAM)] = { mach64_get_param, 1, 0 }
-/* DMA customization:
- */
-#define __HAVE_DMA 1
-#define __HAVE_DMA_IRQ 1
-#define __HAVE_VBL_IRQ 1
-#define __HAVE_SHARED_IRQ 1
-#define __HAVE_IRQ 1
-
#endif
diff --git a/shared/mach64_dma.c b/shared/mach64_dma.c
index 4f90916d..210a6103 100644
--- a/shared/mach64_dma.c
+++ b/shared/mach64_dma.c
@@ -972,13 +972,11 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
{
DRM_DEBUG( "%s\n", __FUNCTION__ );
-#if _HAVE_DMA_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
if ( dev->irq ) DRM(irq_uninstall)(dev);
-#endif
if ( dev->dev_private ) {
drm_mach64_private_t *dev_priv = dev->dev_private;
@@ -1335,5 +1333,11 @@ static void mach64_driver_pretakedown(drm_device_t *dev)
void mach64_driver_register_fns(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;
}
diff --git a/shared/mach64_drv.h b/shared/mach64_drv.h
index d009d29e..b49e6f65 100644
--- a/shared/mach64_drv.h
+++ b/shared/mach64_drv.h
@@ -127,6 +127,12 @@ extern int mach64_dma_swap( DRM_IOCTL_ARGS );
extern int mach64_dma_vertex( DRM_IOCTL_ARGS );
extern int mach64_dma_blit( DRM_IOCTL_ARGS );
extern int mach64_get_param( DRM_IOCTL_ARGS );
+extern int mach64_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
+
+extern irqreturn_t mach64_driver_irq_handler( DRM_IRQ_ARGS );
+extern void mach64_driver_irq_preinstall( drm_device_t *dev );
+extern void mach64_driver_irq_postinstall( drm_device_t *dev );
+extern void mach64_driver_irq_uninstall( drm_device_t *dev );
/* ================================================================
* Registers
diff --git a/shared/mach64_irq.c b/shared/mach64_irq.c
index 9acd6269..efa0641f 100644
--- a/shared/mach64_irq.c
+++ b/shared/mach64_irq.c
@@ -40,7 +40,7 @@
#include "mach64_drm.h"
#include "mach64_drv.h"
-irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
+irqreturn_t mach64_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *) arg;
drm_mach64_private_t *dev_priv =
@@ -69,7 +69,7 @@ irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
return IRQ_NONE;
}
-int DRM(vblank_wait)(drm_device_t *dev, unsigned int *sequence)
+int mach64_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
{
unsigned int cur_vblank;
int ret = 0;
@@ -89,7 +89,7 @@ int DRM(vblank_wait)(drm_device_t *dev, unsigned int *sequence)
/* drm_dma.h hooks
*/
-void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
+void mach64_driver_irq_preinstall( drm_device_t *dev ) {
drm_mach64_private_t *dev_priv =
(drm_mach64_private_t *)dev->dev_private;
@@ -102,7 +102,7 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
| MACH64_CRTC_VBLANK_INT );
}
-void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
+void mach64_driver_irq_postinstall( drm_device_t *dev ) {
drm_mach64_private_t *dev_priv =
(drm_mach64_private_t *)dev->dev_private;
@@ -114,7 +114,7 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
}
-void DRM(driver_irq_uninstall)( drm_device_t *dev ) {
+void mach64_driver_irq_uninstall( drm_device_t *dev ) {
drm_mach64_private_t *dev_priv =
(drm_mach64_private_t *)dev->dev_private;
if ( !dev_priv )
diff --git a/shared/mga.h b/shared/mga.h
index f2813846..ec63e7f4 100644
--- a/shared/mga.h
+++ b/shared/mga.h
@@ -36,10 +36,6 @@
/* General customization:
*/
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 1
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
@@ -69,11 +65,4 @@
#define __HAVE_COUNTER7 _DRM_STAT_PRIMARY
#define __HAVE_COUNTER8 _DRM_STAT_SECONDARY
-/* DMA customization:
- */
-#define __HAVE_DMA 1
-#define __HAVE_IRQ 1
-#define __HAVE_VBL_IRQ 1
-#define __HAVE_SHARED_IRQ 1
-
#endif
diff --git a/shared/mga_dma.c b/shared/mga_dma.c
index 2a095014..409f0ab7 100644
--- a/shared/mga_dma.c
+++ b/shared/mga_dma.c
@@ -630,13 +630,11 @@ int mga_do_cleanup_dma( drm_device_t *dev )
{
DRM_DEBUG( "\n" );
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
if ( dev->dev_private ) {
drm_mga_private_t *dev_priv = dev->dev_private;
@@ -815,6 +813,12 @@ static int mga_driver_dma_quiescent(drm_device_t *dev)
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;
}
diff --git a/shared/mga_drv.h b/shared/mga_drv.h
index 65847165..75dcb0e9 100644
--- a/shared/mga_drv.h
+++ b/shared/mga_drv.h
@@ -130,6 +130,12 @@ extern int mga_getparam( DRM_IOCTL_ARGS );
extern int mga_warp_install_microcode( drm_mga_private_t *dev_priv );
extern int mga_warp_init( drm_mga_private_t *dev_priv );
+extern int mga_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
+extern irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS );
+extern void mga_driver_irq_preinstall( drm_device_t *dev );
+extern void mga_driver_irq_postinstall( drm_device_t *dev );
+extern void mga_driver_irq_uninstall( drm_device_t *dev );
+
#define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER()
#if defined(__linux__) && defined(__alpha__)
diff --git a/shared/mga_irq.c b/shared/mga_irq.c
index e486618b..c3185b0b 100644
--- a/shared/mga_irq.c
+++ b/shared/mga_irq.c
@@ -36,7 +36,7 @@
#include "mga_drm.h"
#include "mga_drv.h"
-irqreturn_t mga_irq_handler( DRM_IRQ_ARGS )
+irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *) arg;
drm_mga_private_t *dev_priv =
@@ -56,7 +56,7 @@ irqreturn_t mga_irq_handler( DRM_IRQ_ARGS )
return IRQ_NONE;
}
-int mga_vblank_wait(drm_device_t *dev, unsigned int *sequence)
+int mga_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
{
unsigned int cur_vblank;
int ret = 0;
diff --git a/shared/r128.h b/shared/r128.h
index b9d2f87e..bcee91b5 100644
--- a/shared/r128.h
+++ b/shared/r128.h
@@ -36,12 +36,6 @@
/* General customization:
*/
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 0
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
-#define __HAVE_SG 1
-#define __HAVE_PCI_DMA 1
#define DRIVER_AUTHOR "Gareth Hughes, VA Linux Systems Inc."
@@ -80,11 +74,4 @@
[DRM_IOCTL_NR(DRM_IOCTL_R128_GETPARAM)] = { r128_getparam, 1, 0 },
-/* DMA customization:
- */
-#define __HAVE_DMA 1
-#define __HAVE_IRQ 1
-#define __HAVE_VBL_IRQ 1
-#define __HAVE_SHARED_IRQ 1
-
#endif
diff --git a/shared/r128_cce.c b/shared/r128_cce.c
index c6c7f6d3..64c9b8be 100644
--- a/shared/r128_cce.c
+++ b/shared/r128_cce.c
@@ -322,7 +322,7 @@ static void r128_cce_init_ring_buffer( drm_device_t *dev,
/* The manual (p. 2) says this address is in "VM space". This
* means it's an offset from the start of AGP space.
*/
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( !dev_priv->is_pci )
ring_start = dev_priv->cce_ring->offset - dev->agp->base;
else
@@ -510,7 +510,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
(drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle +
init->sarea_priv_offset);
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( !dev_priv->is_pci ) {
drm_core_ioremap( dev_priv->cce_ring, dev );
drm_core_ioremap( dev_priv->ring_rptr, dev );
@@ -533,7 +533,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset;
}
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( !dev_priv->is_pci )
dev_priv->cce_buffers_offset = dev->agp->base;
else
@@ -558,7 +558,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
R128_WRITE( R128_LAST_DISPATCH_REG,
dev_priv->sarea_priv->last_dispatch );
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( dev_priv->is_pci ) {
#endif
if (!DRM(ati_pcigart_init)( dev, &dev_priv->phys_pci_gart,
@@ -569,7 +569,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
return DRM_ERR(ENOMEM);
}
R128_WRITE( R128_PCI_GART_PAGE, dev_priv->bus_pci_gart );
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
}
#endif
@@ -586,18 +586,16 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
int r128_do_cleanup_cce( drm_device_t *dev )
{
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
if ( dev->dev_private ) {
drm_r128_private_t *dev_priv = dev->dev_private;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( !dev_priv->is_pci ) {
if ( dev_priv->cce_ring != NULL )
drm_core_ioremapfree( dev_priv->cce_ring, dev );
diff --git a/shared/r128_drv.h b/shared/r128_drv.h
index 12ca9b4f..5b91256c 100644
--- a/shared/r128_drv.h
+++ b/shared/r128_drv.h
@@ -142,6 +142,12 @@ extern int r128_cce_depth( DRM_IOCTL_ARGS );
extern int r128_cce_stipple( DRM_IOCTL_ARGS );
extern int r128_cce_indirect( DRM_IOCTL_ARGS );
+extern int r128_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
+
+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 );
/* 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 e77a5538..be1b9dac 100644
--- a/shared/r128_irq.c
+++ b/shared/r128_irq.c
@@ -36,7 +36,7 @@
#include "r128_drm.h"
#include "r128_drv.h"
-irqreturn_t r128_irq_handler( DRM_IRQ_ARGS )
+irqreturn_t r128_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *) arg;
drm_r128_private_t *dev_priv =
@@ -56,7 +56,7 @@ irqreturn_t r128_irq_handler( DRM_IRQ_ARGS )
return IRQ_NONE;
}
-int DRM(vblank_wait)(drm_device_t *dev, unsigned int *sequence)
+int r128_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
{
unsigned int cur_vblank;
int ret = 0;
diff --git a/shared/r128_state.c b/shared/r128_state.c
index 88d7715a..d772f173 100644
--- a/shared/r128_state.c
+++ b/shared/r128_state.c
@@ -1712,7 +1712,13 @@ static void r128_driver_pretakedown(drm_device_t *dev)
void r128_driver_register_fns(drm_device_t *dev)
{
- dev->dev_priv_size = sizeof(drm_r128_buf_priv_t);
+ 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.h b/shared/radeon.h
index 39fb0be9..43723d53 100644
--- a/shared/radeon.h
+++ b/shared/radeon.h
@@ -37,12 +37,6 @@
/* General customization:
*/
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 0
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
-#define __HAVE_SG 1
-#define __HAVE_PCI_DMA 1
#define DRIVER_AUTHOR "Gareth Hughes, Keith Whitwell, others."
@@ -115,14 +109,4 @@
[DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_WAIT)] = { radeon_irq_wait, 1, 0 }, \
[DRM_IOCTL_NR(DRM_IOCTL_RADEON_SETPARAM)] = { radeon_cp_setparam, 1, 0 }, \
-#define DRIVER_FILE_FIELDS \
- int64_t radeon_fb_delta; \
-
-/* DMA customization:
- */
-#define __HAVE_DMA 1
-#define __HAVE_IRQ 1
-#define __HAVE_VBL_IRQ 1
-#define __HAVE_SHARED_IRQ 1
-
#endif
diff --git a/shared/radeon_cp.c b/shared/radeon_cp.c
index 6987a84c..1e87ff37 100644
--- a/shared/radeon_cp.c
+++ b/shared/radeon_cp.c
@@ -858,7 +858,7 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev,
( ( dev_priv->gart_vm_start - 1 ) & 0xffff0000 )
| ( dev_priv->fb_location >> 16 ) );
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
RADEON_WRITE( RADEON_MC_AGP_LOCATION,
(((dev_priv->gart_vm_start - 1 +
@@ -885,7 +885,7 @@ static void radeon_cp_init_ring_buffer( drm_device_t *dev,
SET_RING_HEAD( dev_priv, cur_read_ptr );
dev_priv->ring.tail = cur_read_ptr;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
/* set RADEON_AGP_BASE here instead of relying on X from user space */
RADEON_WRITE( RADEON_AGP_BASE, (unsigned int)dev->agp->base );
@@ -1146,7 +1146,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
(drm_radeon_sarea_t *)((u8 *)dev_priv->sarea->handle +
init->sarea_priv_offset);
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if ( dev_priv->flags & CHIP_IS_AGP ) {
drm_core_ioremap( dev_priv->cp_ring, dev );
drm_core_ioremap( dev_priv->ring_rptr, dev );
@@ -1195,7 +1195,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv->gart_vm_start = dev_priv->fb_location
+ RADEON_READ( RADEON_CONFIG_APER_SIZE );
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP)
dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
- dev->agp->base
@@ -1224,7 +1224,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK;
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
/* Turn off PCI GART */
radeon_set_pcigart( dev_priv, 0 );
@@ -1257,15 +1257,13 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
-#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl
* 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);
-#endif
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
if ( dev_priv->cp_ring != NULL ) {
drm_core_ioremapfree( dev_priv->cp_ring, dev );
@@ -1315,7 +1313,7 @@ static int radeon_do_resume_cp( drm_device_t *dev )
DRM_DEBUG("Starting radeon_do_resume_cp()\n");
-#if __REALLY_HAVE_AGP
+#if __OS_HAS_AGP
if (dev_priv->flags & CHIP_IS_AGP) {
/* Turn off PCI GART */
radeon_set_pcigart( dev_priv, 0 );
diff --git a/shared/radeon_drv.h b/shared/radeon_drv.h
index 4b66e5be..8c584864 100644
--- a/shared/radeon_drv.h
+++ b/shared/radeon_drv.h
@@ -72,6 +72,9 @@ typedef struct drm_radeon_depth_clear_t {
u32 se_cntl;
} drm_radeon_depth_clear_t;
+struct drm_radeon_driver_file_fields {
+ int64_t radeon_fb_delta;
+};
struct mem_block {
struct mem_block *next;
@@ -216,6 +219,11 @@ extern int radeon_wait_irq(drm_device_t *dev, int swi_nr);
extern int radeon_emit_irq(drm_device_t *dev);
extern void radeon_do_release(drm_device_t *dev);
+extern int radeon_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
+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 );
/* Flags for stats.boxes
*/
diff --git a/shared/radeon_irq.c b/shared/radeon_irq.c
index 51d19493..bdb3cc16 100644
--- a/shared/radeon_irq.c
+++ b/shared/radeon_irq.c
@@ -54,7 +54,7 @@
* tied to dma at all, this is just a hangover from dri prehistory.
*/
-irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
+irqreturn_t radeon_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t *dev = (drm_device_t *) arg;
drm_radeon_private_t *dev_priv =
@@ -141,7 +141,7 @@ int radeon_emit_and_wait_irq(drm_device_t *dev)
}
-int DRM(vblank_wait)(drm_device_t *dev, unsigned int *sequence)
+int radeon_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
{
drm_radeon_private_t *dev_priv =
(drm_radeon_private_t *)dev->dev_private;
diff --git a/shared/radeon_state.c b/shared/radeon_state.c
index 4a7bfd2d..cdbd7a8e 100644
--- a/shared/radeon_state.c
+++ b/shared/radeon_state.c
@@ -43,12 +43,15 @@ static __inline__ int radeon_check_and_fixup_offset( drm_radeon_private_t *dev_p
drm_file_t *filp_priv,
u32 *offset ) {
u32 off = *offset;
+ struct drm_radeon_driver_file_fields *radeon_priv;
if ( off >= dev_priv->fb_location &&
off < ( dev_priv->gart_vm_start + dev_priv->gart_size ) )
return 0;
- off += filp_priv->radeon_fb_delta;
+ radeon_priv = filp_priv->driver_priv;
+
+ off += radeon_priv->radeon_fb_delta;
DRM_DEBUG( "offset fixed up to 0x%x\n", off );
@@ -2525,7 +2528,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_file_t *filp_priv;
drm_radeon_setparam_t sp;
-
+ struct drm_radeon_driver_file_fields *radeon_priv;
+
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
return DRM_ERR( EINVAL );
@@ -2538,7 +2542,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
switch( sp.param ) {
case RADEON_SETPARAM_FB_LOCATION:
- filp_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
+ radeon_priv = filp_priv->driver_priv;
+ radeon_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
break;
default:
DRM_DEBUG( "Invalid parameter %d\n", sp.param );
@@ -2571,17 +2576,35 @@ static void radeon_driver_pretakedown(drm_device_t *dev)
radeon_do_release(dev);
}
-static void radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
+static 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);
+
+ if (!radeon_priv)
+ return -ENOMEM;
+
+ filp_priv->driver_priv = radeon_priv;
+
if ( dev_priv )
- filp_priv->radeon_fb_delta = dev_priv->fb_location;
+ radeon_priv->radeon_fb_delta = dev_priv->fb_location;
else
- filp_priv->radeon_fb_delta = 0;
+ radeon_priv->radeon_fb_delta = 0;
+ return 0;
+}
+
+static void radeon_driver_free_filp_private(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);
}
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;
@@ -2589,4 +2612,10 @@ void radeon_driver_register_fns(struct drm_device *dev)
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_private = radeon_driver_free_filp_private;
}
diff --git a/shared/sis.h b/shared/sis.h
index 8afba1a9..1b149ebc 100644
--- a/shared/sis.h
+++ b/shared/sis.h
@@ -37,10 +37,6 @@
/* General customization:
*/
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 0
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "SIS"
#define DRIVER_NAME "sis"
diff --git a/shared/sis_mm.c b/shared/sis_mm.c
index 233843d5..27b904fc 100644
--- a/shared/sis_mm.c
+++ b/shared/sis_mm.c
@@ -411,6 +411,7 @@ int sis_final_context(struct drm_device *dev, int context)
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/tdfx.h b/shared/tdfx.h
index 6b067db7..a582a3db 100644
--- a/shared/tdfx.h
+++ b/shared/tdfx.h
@@ -36,8 +36,6 @@
/* General customization:
*/
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
#define DRIVER_AUTHOR "VA Linux Systems Inc."
diff --git a/shared/via.h b/shared/via.h
index bf8526fd..1c09448e 100644
--- a/shared/via.h
+++ b/shared/via.h
@@ -27,18 +27,8 @@
#define DRM(x) viadrv_##x
-
-#define __HAVE_AGP 1
-#define __MUST_HAVE_AGP 0
-#define __HAVE_MTRR 1
-#define __HAVE_CTX_BITMAP 1
-
/* BEAM: Have enabled DMA,DMA_IRQ and VBL_IRQ needed to do this to get standard
* support for VBL_IRQ.
*/
-#define __HAVE_IRQ 1
-#define __HAVE_SHARED_IRQ 1
-#define __HAVE_VBL_IRQ 1
-
#endif
diff --git a/shared/via_drv.c b/shared/via_drv.c
index 77423764..b3119f66 100644
--- a/shared/via_drv.c
+++ b/shared/via_drv.c
@@ -68,4 +68,5 @@
#include "drm_proc.h"
#include "drm_vm.h"
#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/shared/via_drv.h b/shared/via_drv.h
index 582eb6de..dd4a370f 100644
--- a/shared/via_drv.h
+++ b/shared/via_drv.h
@@ -64,6 +64,14 @@ extern int via_do_init_map(drm_device_t *dev, drm_via_init_t *init);
extern int via_do_cleanup_map(drm_device_t *dev);
extern int via_map_init(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
+extern int via_driver_vblank_wait(drm_device_t* dev, unsigned int* sequence);
+
+extern irqreturn_t via_driver_irq_handler( DRM_IRQ_ARGS );
+extern void via_driver_irq_preinstall( drm_device_t *dev );
+extern void via_driver_irq_postinstall( drm_device_t *dev );
+extern void via_driver_irq_uninstall( drm_device_t *dev );
+
+extern int via_dma_cleanup(drm_device_t *dev);
extern int via_dma_cleanup(drm_device_t *dev);
diff --git a/shared/via_irq.c b/shared/via_irq.c
index 7e540cc1..eafb1d7d 100644
--- a/shared/via_irq.c
+++ b/shared/via_irq.c
@@ -46,8 +46,7 @@
#define VIA_IRQ_VBI_ENABLE (1 << 19)
#define VIA_IRQ_VBI_PENDING (1 << 3)
-irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS )
-
+irqreturn_t via_driver_irq_handler( DRM_IRQ_ARGS )
{
drm_device_t* dev = (drm_device_t*)arg;
drm_via_private_t* dev_priv = (drm_via_private_t*)dev->dev_private;
@@ -83,7 +82,7 @@ static __inline__ void viadrv_acknowledge_irqs(drm_via_private_t* dev_priv)
}
}
-int DRM(vblank_wait)(drm_device_t* dev, unsigned int* sequence)
+int via_driver_vblank_wait(drm_device_t* dev, unsigned int* sequence)
{
drm_via_private_t* dev_priv = (drm_via_private_t*)dev->dev_private;
unsigned int cur_vblank;
@@ -112,7 +111,7 @@ int DRM(vblank_wait)(drm_device_t* dev, unsigned int* sequence)
/*
* drm_dma.h hooks
*/
-void DRM(driver_irq_preinstall)(drm_device_t* dev){
+void via_driver_irq_preinstall(drm_device_t* dev){
drm_via_private_t* dev_priv = (drm_via_private_t *)dev->dev_private;
u32 status;
@@ -130,7 +129,7 @@ void DRM(driver_irq_preinstall)(drm_device_t* dev){
}
}
-void DRM(driver_irq_postinstall)(drm_device_t* dev){
+void via_driver_irq_postinstall(drm_device_t* dev){
drm_via_private_t* dev_priv = (drm_via_private_t *)dev->dev_private;
u32 status;
@@ -147,7 +146,7 @@ void DRM(driver_irq_postinstall)(drm_device_t* dev){
}
}
-void DRM(driver_irq_uninstall)(drm_device_t* dev){
+void via_driver_irq_uninstall(drm_device_t* dev){
drm_via_private_t* dev_priv = (drm_via_private_t *)dev->dev_private;
u32 status;
diff --git a/shared/via_mm.c b/shared/via_mm.c
index fa37e782..117cca70 100644
--- a/shared/via_mm.c
+++ b/shared/via_mm.c
@@ -358,6 +358,12 @@ EXPORT_SYMBOL(via_fb_free);
void DRM(driver_register_fns)(drm_device_t *dev)
{
- dev->fn_tbl.context_ctor = via_init_context;
- dev->fn_tbl.context_dtor = via_final_context;
+ 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;
}