From d4dbf457813e97531ded3bf24f3b6ad421189c69 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 24 Aug 2004 11:15:53 +0000 Subject: Merged drmfntbl-0-0-2 --- linux-core/Makefile | 2 +- linux-core/drmP.h | 90 ++++++++++---------- linux-core/drm_agpsupport.c | 5 +- linux-core/drm_bufs.c | 87 ++++++++++---------- linux-core/drm_context.c | 21 +++-- linux-core/drm_dma.c | 39 +-------- linux-core/drm_drv.c | 186 ++++++++++++++++++------------------------ linux-core/drm_fops.c | 10 ++- linux-core/drm_ioctl.c | 7 +- linux-core/drm_irq.c | 88 ++++++++++---------- linux-core/drm_memory.h | 18 ++-- linux-core/drm_memory_debug.h | 2 +- linux-core/drm_scatter.c | 6 ++ linux-core/drm_vm.c | 36 ++++---- linux-core/ffb_context.c | 18 ++++ linux-core/ffb_drv.c | 14 ---- linux-core/i810_dma.c | 7 +- linux-core/i810_drv.c | 2 + linux-core/i830_dma.c | 13 ++- linux-core/i830_drv.c | 1 + linux-core/i830_drv.h | 4 + linux-core/i830_irq.c | 8 +- linux-core/i915_drv.c | 2 + linux-core/mach64_drv.c | 1 + linux-core/mga_drv.c | 1 + linux-core/savage.h | 7 -- linux-core/savage_dma.c | 1 + linux-core/savage_drv.c | 2 + linux-core/sis_drv.c | 2 + linux-core/tdfx_drv.c | 4 + 30 files changed, 336 insertions(+), 348 deletions(-) (limited to 'linux-core') 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 -#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 #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 @@ -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 /* 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 @@ -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 -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; } -- cgit v1.2.3