Commit 07b03017 authored by Dave Airlie's avatar Dave Airlie

Merge starflyer.(none):/home/airlied/bitkeeper/linux-2.5

into starflyer.(none):/home/airlied/bitkeeper/drm-fntbl
parents 69148aae 8b00ce36
...@@ -88,13 +88,11 @@ ...@@ -88,13 +88,11 @@
#define DRIVER_USE_MTRR 0x4 #define DRIVER_USE_MTRR 0x4
#define DRIVER_PCI_DMA 0x8 #define DRIVER_PCI_DMA 0x8
#define DRIVER_SG 0x10 #define DRIVER_SG 0x10
#define DRIVER_HAVE_DMA 0x20
#ifndef __HAVE_DMA #define DRIVER_HAVE_IRQ 0x40
#define __HAVE_DMA 0 #define DRIVER_IRQ_SHARED 0x80
#endif #define DRIVER_IRQ_VBL 0x100
#ifndef __HAVE_IRQ #define DRIVER_DMA_QUEUE 0x200
#define __HAVE_IRQ 0
#endif
/***********************************************************************/ /***********************************************************************/
/** \name Begin the DRM... */ /** \name Begin the DRM... */
...@@ -533,7 +531,6 @@ typedef struct drm_ctx_list { ...@@ -533,7 +531,6 @@ typedef struct drm_ctx_list {
drm_file_t *tag; /**< associated fd private data */ drm_file_t *tag; /**< associated fd private data */
} drm_ctx_list_t; } drm_ctx_list_t;
#ifdef __HAVE_VBL_IRQ
typedef struct drm_vbl_sig { typedef struct drm_vbl_sig {
struct list_head head; struct list_head head;
...@@ -542,7 +539,6 @@ typedef struct drm_vbl_sig { ...@@ -542,7 +539,6 @@ typedef struct drm_vbl_sig {
struct task_struct *task; struct task_struct *task;
} drm_vbl_sig_t; } drm_vbl_sig_t;
#endif
/** /**
* DRM device functions structure * DRM device functions structure
...@@ -565,7 +561,17 @@ struct drm_driver_fn { ...@@ -565,7 +561,17 @@ struct drm_driver_fn {
int (*context_ctor)(struct drm_device *dev, int context); int (*context_ctor)(struct drm_device *dev, int context);
int (*context_dtor)(struct drm_device *dev, int context); int (*context_dtor)(struct drm_device *dev, int context);
int (*kernel_context_switch)(struct drm_device *dev, int old, int new); int (*kernel_context_switch)(struct drm_device *dev, int old, int new);
int (*kernel_context_switch_unlock)(struct drm_device *dev); void (*kernel_context_switch_unlock)(struct drm_device *dev, drm_lock_t *lock);
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);
}; };
/** /**
* DRM device structure. * DRM device structure.
...@@ -655,13 +661,13 @@ typedef struct drm_device { ...@@ -655,13 +661,13 @@ typedef struct drm_device {
struct work_struct work; struct work_struct work;
/** \name VBLANK IRQ support */ /** \name VBLANK IRQ support */
/*@{*/ /*@{*/
#ifdef __HAVE_VBL_IRQ
wait_queue_head_t vbl_queue; /**< VBLANK wait queue */ wait_queue_head_t vbl_queue; /**< VBLANK wait queue */
atomic_t vbl_received; atomic_t vbl_received;
spinlock_t vbl_lock; spinlock_t vbl_lock;
drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */ drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */
unsigned int vbl_pending; unsigned int vbl_pending;
#endif
/*@}*/ /*@}*/
cycles_t ctx_start; cycles_t ctx_start;
cycles_t lck_start; cycles_t lck_start;
...@@ -864,7 +870,6 @@ extern int DRM(addmap)( struct inode *inode, struct file *filp, ...@@ -864,7 +870,6 @@ extern int DRM(addmap)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ); unsigned int cmd, unsigned long arg );
extern int DRM(rmmap)( struct inode *inode, struct file *filp, extern int DRM(rmmap)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ); unsigned int cmd, unsigned long arg );
#if __HAVE_DMA
extern int DRM(addbufs)( struct inode *inode, struct file *filp, extern int DRM(addbufs)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ); unsigned int cmd, unsigned long arg );
extern int DRM(infobufs)( struct inode *inode, struct file *filp, extern int DRM(infobufs)( struct inode *inode, struct file *filp,
...@@ -881,31 +886,21 @@ extern int DRM(dma_setup)(drm_device_t *dev); ...@@ -881,31 +886,21 @@ extern int DRM(dma_setup)(drm_device_t *dev);
extern void DRM(dma_takedown)(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(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
extern void DRM(reclaim_buffers)( struct file *filp ); extern void DRM(reclaim_buffers)( struct file *filp );
#endif /* __HAVE_DMA */
/* IRQ support (drm_irq.h) */ /* IRQ support (drm_irq.h) */
#if __HAVE_IRQ || __HAVE_DMA
extern int DRM(control)( struct inode *inode, struct file *filp, extern int DRM(control)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ); unsigned int cmd, unsigned long arg );
#endif
#if __HAVE_IRQ
extern int DRM(irq_install)( drm_device_t *dev ); extern int DRM(irq_install)( drm_device_t *dev );
extern int DRM(irq_uninstall)( drm_device_t *dev ); extern int DRM(irq_uninstall)( drm_device_t *dev );
extern irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS ); extern irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS );
extern void DRM(driver_irq_preinstall)( drm_device_t *dev ); 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_postinstall)( drm_device_t *dev );
extern void DRM(driver_irq_uninstall)( 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, extern int DRM(wait_vblank)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq); extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
extern void DRM(vbl_send_signals)( drm_device_t *dev ); 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
/* AGP/GART support (drm_agpsupport.h) */ /* AGP/GART support (drm_agpsupport.h) */
extern drm_agp_head_t *DRM(agp_init)(void); extern drm_agp_head_t *DRM(agp_init)(void);
...@@ -998,5 +993,8 @@ static __inline__ void drm_core_dropmap(struct drm_map *map) ...@@ -998,5 +993,8 @@ 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 /* __KERNEL__ */
#endif #endif
...@@ -286,8 +286,6 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, ...@@ -286,8 +286,6 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
return 0; return 0;
} }
#if __HAVE_DMA
/** /**
* Cleanup after an error on one of the addbufs() functions. * Cleanup after an error on one of the addbufs() functions.
* *
...@@ -661,7 +659,9 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp, ...@@ -661,7 +659,9 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
buf->used = 0; buf->used = 0;
buf->offset = (dma->byte_count + byte_count + offset); buf->offset = (dma->byte_count + byte_count + offset);
buf->address = (void *)(page + offset); buf->address = (void *)(page + offset);
#ifndef __sparc__
buf->bus_address = virt_to_bus(buf->address); buf->bus_address = virt_to_bus(buf->address);
#endif
buf->next = NULL; buf->next = NULL;
buf->waiting = 0; buf->waiting = 0;
buf->pending = 0; buf->pending = 0;
...@@ -926,6 +926,11 @@ int DRM(addbufs)( struct inode *inode, struct file *filp, ...@@ -926,6 +926,11 @@ int DRM(addbufs)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ) unsigned int cmd, unsigned long arg )
{ {
drm_buf_desc_t request; drm_buf_desc_t request;
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
return -EINVAL;
if ( copy_from_user( &request, (drm_buf_desc_t __user *)arg, if ( copy_from_user( &request, (drm_buf_desc_t __user *)arg,
sizeof(request) ) ) sizeof(request) ) )
...@@ -971,6 +976,9 @@ int DRM(infobufs)( struct inode *inode, struct file *filp, ...@@ -971,6 +976,9 @@ int DRM(infobufs)( struct inode *inode, struct file *filp,
int i; int i;
int count; int count;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
return -EINVAL;
if ( !dma ) return -EINVAL; if ( !dma ) return -EINVAL;
spin_lock( &dev->count_lock ); spin_lock( &dev->count_lock );
...@@ -1052,6 +1060,9 @@ int DRM(markbufs)( struct inode *inode, struct file *filp, ...@@ -1052,6 +1060,9 @@ int DRM(markbufs)( struct inode *inode, struct file *filp,
int order; int order;
drm_buf_entry_t *entry; drm_buf_entry_t *entry;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
return -EINVAL;
if ( !dma ) return -EINVAL; if ( !dma ) return -EINVAL;
if ( copy_from_user( &request, if ( copy_from_user( &request,
...@@ -1099,6 +1110,9 @@ int DRM(freebufs)( struct inode *inode, struct file *filp, ...@@ -1099,6 +1110,9 @@ int DRM(freebufs)( struct inode *inode, struct file *filp,
int idx; int idx;
drm_buf_t *buf; drm_buf_t *buf;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
return -EINVAL;
if ( !dma ) return -EINVAL; if ( !dma ) return -EINVAL;
if ( copy_from_user( &request, if ( copy_from_user( &request,
...@@ -1156,6 +1170,9 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp, ...@@ -1156,6 +1170,9 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
drm_buf_map_t request; drm_buf_map_t request;
int i; int i;
if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
return -EINVAL;
if ( !dma ) return -EINVAL; if ( !dma ) return -EINVAL;
spin_lock( &dev->count_lock ); spin_lock( &dev->count_lock );
...@@ -1253,4 +1270,3 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp, ...@@ -1253,4 +1270,3 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
return retcode; return retcode;
} }
#endif /* __HAVE_DMA */
...@@ -35,16 +35,6 @@ ...@@ -35,16 +35,6 @@
#include "drmP.h" #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. * Initialize the DMA data.
* *
...@@ -152,12 +142,11 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf) ...@@ -152,12 +142,11 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
buf->filp = NULL; buf->filp = NULL;
buf->used = 0; buf->used = 0;
if ( __HAVE_DMA_WAITQUEUE && waitqueue_active(&buf->dma_wait)) { if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && waitqueue_active(&buf->dma_wait)) {
wake_up_interruptible(&buf->dma_wait); wake_up_interruptible(&buf->dma_wait);
} }
} }
#if !__HAVE_DMA_RECLAIM
/** /**
* Reclaim the buffers. * Reclaim the buffers.
* *
...@@ -165,7 +154,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf) ...@@ -165,7 +154,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
* *
* Frees each buffer associated with \p filp not already on the hardware. * 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_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
...@@ -189,29 +178,4 @@ void DRM(reclaim_buffers)( struct file *filp ) ...@@ -189,29 +178,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 */
...@@ -52,16 +52,6 @@ ...@@ -52,16 +52,6 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#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 #ifndef __HAVE_COUNTERS
#define __HAVE_COUNTERS 0 #define __HAVE_COUNTERS 0
#endif #endif
...@@ -109,9 +99,7 @@ drm_ioctl_desc_t DRM(ioctls)[] = { ...@@ -109,9 +99,7 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 }, [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_UNIQUE)] = { DRM(getunique), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 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 }, [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_MAP)] = { DRM(getmap), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 },
...@@ -144,17 +132,14 @@ drm_ioctl_desc_t DRM(ioctls)[] = { ...@@ -144,17 +132,14 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 }, [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_ADD_BUFS)] = { DRM(addbufs), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { DRM(markbufs), 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_INFO_BUFS)] = { DRM(infobufs), 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { DRM(mapbufs), 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { DRM(mapbufs), 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { DRM(freebufs), 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { DRM(freebufs), 1, 0 },
/* The DRM_IOCTL_DMA ioctl should be defined by the driver. */ /* 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 }, [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 },
#endif
#if __OS_HAS_AGP #if __OS_HAS_AGP
[DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 },
...@@ -170,9 +155,7 @@ drm_ioctl_desc_t DRM(ioctls)[] = { ...@@ -170,9 +155,7 @@ drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { DRM(sg_alloc), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { DRM(sg_alloc), 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { DRM(sg_free), 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { DRM(sg_free), 1, 1 },
#ifdef __HAVE_VBL_IRQ
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 },
#endif
DRIVER_IOCTLS DRIVER_IOCTLS
}; };
...@@ -191,20 +174,26 @@ MODULE_LICENSE("GPL and additional rights"); ...@@ -191,20 +174,26 @@ MODULE_LICENSE("GPL and additional rights");
static int DRM(setup)( drm_device_t *dev ) static int DRM(setup)( drm_device_t *dev )
{ {
int i; int i;
int ret;
if (dev->fn_tbl.presetup) if (dev->fn_tbl.presetup)
dev->fn_tbl.presetup(dev); {
ret=dev->fn_tbl.presetup(dev);
if (ret!=0)
return ret;
}
atomic_set( &dev->ioctl_count, 0 ); atomic_set( &dev->ioctl_count, 0 );
atomic_set( &dev->vma_count, 0 ); atomic_set( &dev->vma_count, 0 );
dev->buf_use = 0; dev->buf_use = 0;
atomic_set( &dev->buf_alloc, 0 ); atomic_set( &dev->buf_alloc, 0 );
#if __HAVE_DMA if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
{
i = DRM(dma_setup)( dev ); i = DRM(dma_setup)( dev );
if ( i < 0 ) if ( i < 0 )
return i; return i;
#endif }
dev->counters = 6 + __HAVE_COUNTERS; dev->counters = 6 + __HAVE_COUNTERS;
dev->types[0] = _DRM_STAT_LOCK; dev->types[0] = _DRM_STAT_LOCK;
...@@ -327,9 +316,7 @@ static int DRM(takedown)( drm_device_t *dev ) ...@@ -327,9 +316,7 @@ static int DRM(takedown)( drm_device_t *dev )
if (dev->fn_tbl.pretakedown) if (dev->fn_tbl.pretakedown)
dev->fn_tbl.pretakedown(dev); dev->fn_tbl.pretakedown(dev);
#if __HAVE_IRQ
if ( dev->irq_enabled ) DRM(irq_uninstall)( dev ); if ( dev->irq_enabled ) DRM(irq_uninstall)( dev );
#endif
down( &dev->struct_sem ); down( &dev->struct_sem );
del_timer( &dev->timer ); del_timer( &dev->timer );
...@@ -430,8 +417,7 @@ static int DRM(takedown)( drm_device_t *dev ) ...@@ -430,8 +417,7 @@ static int DRM(takedown)( drm_device_t *dev )
dev->maplist = NULL; dev->maplist = NULL;
} }
#if __HAVE_DMA_QUEUE || __HAVE_MULTIPLE_DMA_QUEUES if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist ) {
if ( dev->queuelist ) {
for ( i = 0 ; i < dev->queue_count ; i++ ) { for ( i = 0 ; i < dev->queue_count ; i++ ) {
if ( dev->queuelist[i] ) { if ( dev->queuelist[i] ) {
DRM(free)( dev->queuelist[i], DRM(free)( dev->queuelist[i],
...@@ -446,11 +432,10 @@ static int DRM(takedown)( drm_device_t *dev ) ...@@ -446,11 +432,10 @@ static int DRM(takedown)( drm_device_t *dev )
dev->queuelist = NULL; dev->queuelist = NULL;
} }
dev->queue_count = 0; dev->queue_count = 0;
#endif
#if __HAVE_DMA if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
DRM(dma_takedown)( dev ); DRM(dma_takedown)( dev );
#endif
if ( dev->lock.hw_lock ) { if ( dev->lock.hw_lock ) {
dev->sigdata.lock = dev->lock.hw_lock = NULL; /* SHM removed */ dev->sigdata.lock = dev->lock.hw_lock = NULL; /* SHM removed */
dev->lock.filp = NULL; dev->lock.filp = NULL;
...@@ -461,6 +446,13 @@ static int DRM(takedown)( drm_device_t *dev ) ...@@ -461,6 +446,13 @@ static int DRM(takedown)( drm_device_t *dev )
return 0; 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" #include "drm_pciids.h"
static struct pci_device_id DRM(pciidlist)[] = { static struct pci_device_id DRM(pciidlist)[] = {
...@@ -515,6 +507,9 @@ static int DRM(probe)(struct pci_dev *pdev) ...@@ -515,6 +507,9 @@ static int DRM(probe)(struct pci_dev *pdev)
/* dev_priv_size can be changed by a driver in driver_register_fns */ /* dev_priv_size can be changed by a driver in driver_register_fns */
dev->dev_priv_size = sizeof(u32); dev->dev_priv_size = sizeof(u32);
DRM(init_fn_table)(dev);
DRM(driver_register_fns)(dev); DRM(driver_register_fns)(dev);
if (dev->fn_tbl.preinit) if (dev->fn_tbl.preinit)
...@@ -820,9 +815,10 @@ int DRM(release)( struct inode *inode, struct file *filp ) ...@@ -820,9 +815,10 @@ int DRM(release)( struct inode *inode, struct file *filp )
} }
} }
#if __HAVE_DMA if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
DRM(reclaim_buffers)( filp ); {
#endif dev->fn_tbl.reclaim_buffers(filp);
}
DRM(fasync)( -1, filp, 0 ); DRM(fasync)( -1, filp, 0 );
...@@ -966,9 +962,6 @@ int DRM(lock)( struct inode *inode, struct file *filp, ...@@ -966,9 +962,6 @@ int DRM(lock)( struct inode *inode, struct file *filp,
DECLARE_WAITQUEUE( entry, current ); DECLARE_WAITQUEUE( entry, current );
drm_lock_t lock; drm_lock_t lock;
int ret = 0; int ret = 0;
#if __HAVE_MULTIPLE_DMA_QUEUES
drm_queue_t *q;
#endif
++priv->lock_count; ++priv->lock_count;
...@@ -985,14 +978,9 @@ int DRM(lock)( struct inode *inode, struct file *filp, ...@@ -985,14 +978,9 @@ int DRM(lock)( struct inode *inode, struct file *filp,
lock.context, current->pid, lock.context, current->pid,
dev->lock.hw_lock->lock, lock.flags ); dev->lock.hw_lock->lock, lock.flags );
#if __HAVE_DMA_QUEUE if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE))
if ( lock.context < 0 ) if ( lock.context < 0 )
return -EINVAL; return -EINVAL;
#elif __HAVE_MULTIPLE_DMA_QUEUES
if ( lock.context < 0 || lock.context >= dev->queue_count )
return -EINVAL;
q = dev->queuelist[lock.context];
#endif
add_wait_queue( &dev->lock.lock_queue, &entry ); add_wait_queue( &dev->lock.lock_queue, &entry );
for (;;) { for (;;) {
...@@ -1083,7 +1071,7 @@ int DRM(unlock)( struct inode *inode, struct file *filp, ...@@ -1083,7 +1071,7 @@ int DRM(unlock)( struct inode *inode, struct file *filp,
* modules but is required by the Sparc driver. * modules but is required by the Sparc driver.
*/ */
if (dev->fn_tbl.kernel_context_switch_unlock) if (dev->fn_tbl.kernel_context_switch_unlock)
dev->fn_tbl.kernel_context_switch_unlock(dev); dev->fn_tbl.kernel_context_switch_unlock(dev, &lock);
else { else {
DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock, DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT ); DRM_KERNEL_CONTEXT );
......
...@@ -341,9 +341,9 @@ int DRM(setversion)(DRM_IOCTL_ARGS) ...@@ -341,9 +341,9 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
if (sv.drm_dd_major != DRIVER_MAJOR || if (sv.drm_dd_major != DRIVER_MAJOR ||
sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR) sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR)
return EINVAL; return EINVAL;
#ifdef DRIVER_SETVERSION
DRIVER_SETVERSION(dev, &sv); if (dev->fn_tbl.set_version)
#endif dev->fn_tbl.set_version(dev, &sv);
} }
return 0; return 0;
} }
...@@ -37,16 +37,6 @@ ...@@ -37,16 +37,6 @@
#include <linux/interrupt.h> /* For task queue support */ #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. * Get interrupt from bus id.
* *
...@@ -68,6 +58,9 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp, ...@@ -68,6 +58,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 __user *argp = (void __user *)arg;
drm_irq_busid_t p; drm_irq_busid_t p;
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return -EINVAL;
if (copy_from_user(&p, argp, sizeof(p))) if (copy_from_user(&p, argp, sizeof(p)))
return -EFAULT; return -EFAULT;
...@@ -86,8 +79,6 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp, ...@@ -86,8 +79,6 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
return 0; return 0;
} }
#if __HAVE_IRQ
/** /**
* Install IRQ handler. * Install IRQ handler.
* *
...@@ -101,6 +92,10 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp, ...@@ -101,6 +92,10 @@ int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
int DRM(irq_install)( drm_device_t *dev ) int DRM(irq_install)( drm_device_t *dev )
{ {
int ret; int ret;
unsigned long sh_flags=0;
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return -EINVAL;
if ( dev->irq == 0 ) if ( dev->irq == 0 )
return -EINVAL; return -EINVAL;
...@@ -122,17 +117,11 @@ int DRM(irq_install)( drm_device_t *dev ) ...@@ -122,17 +117,11 @@ int DRM(irq_install)( drm_device_t *dev )
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq ); DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
#if __HAVE_DMA
dev->dma->next_buffer = NULL; dev->dma->next_buffer = NULL;
dev->dma->next_queue = NULL; dev->dma->next_queue = NULL;
dev->dma->this_buffer = NULL; dev->dma->this_buffer = NULL;
#endif
#ifdef __HAVE_IRQ_BH if (drm_core_check_feature(dev, DRIVER_IRQ_VBL)) {
INIT_WORK(&dev->work, DRM(irq_immediate_bh), dev);
#endif
#ifdef __HAVE_VBL_IRQ
init_waitqueue_head(&dev->vbl_queue); init_waitqueue_head(&dev->vbl_queue);
spin_lock_init( &dev->vbl_lock ); spin_lock_init( &dev->vbl_lock );
...@@ -140,14 +129,17 @@ int DRM(irq_install)( drm_device_t *dev ) ...@@ -140,14 +129,17 @@ int DRM(irq_install)( drm_device_t *dev )
INIT_LIST_HEAD( &dev->vbl_sigs.head ); INIT_LIST_HEAD( &dev->vbl_sigs.head );
dev->vbl_pending = 0; dev->vbl_pending = 0;
#endif }
/* Before installing handler */ /* Before installing handler */
DRM(driver_irq_preinstall)(dev); dev->fn_tbl.irq_preinstall(dev);
/* Install handler */ /* Install handler */
ret = request_irq( dev->irq, DRM(irq_handler), if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED))
DRM_IRQ_TYPE, dev->devname, dev ); sh_flags = SA_SHIRQ;
ret = request_irq( dev->irq, dev->fn_tbl.irq_handler,
sh_flags, dev->devname, dev );
if ( ret < 0 ) { if ( ret < 0 ) {
down( &dev->struct_sem ); down( &dev->struct_sem );
dev->irq_enabled = 0; dev->irq_enabled = 0;
...@@ -156,7 +148,7 @@ int DRM(irq_install)( drm_device_t *dev ) ...@@ -156,7 +148,7 @@ int DRM(irq_install)( drm_device_t *dev )
} }
/* After installing handler */ /* After installing handler */
DRM(driver_irq_postinstall)(dev); dev->fn_tbl.irq_postinstall(dev);
return 0; return 0;
} }
...@@ -172,6 +164,9 @@ int DRM(irq_uninstall)( drm_device_t *dev ) ...@@ -172,6 +164,9 @@ int DRM(irq_uninstall)( drm_device_t *dev )
{ {
int irq_enabled; int irq_enabled;
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return -EINVAL;
down( &dev->struct_sem ); down( &dev->struct_sem );
irq_enabled = dev->irq_enabled; irq_enabled = dev->irq_enabled;
dev->irq_enabled = 0; dev->irq_enabled = 0;
...@@ -182,7 +177,7 @@ int DRM(irq_uninstall)( drm_device_t *dev ) ...@@ -182,7 +177,7 @@ int DRM(irq_uninstall)( drm_device_t *dev )
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq ); 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 ); free_irq( dev->irq, dev );
...@@ -207,24 +202,28 @@ int DRM(control)( struct inode *inode, struct file *filp, ...@@ -207,24 +202,28 @@ int DRM(control)( struct inode *inode, struct file *filp,
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_control_t ctl; drm_control_t ctl;
/* 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) ) ) if ( copy_from_user( &ctl, (drm_control_t __user *)arg, sizeof(ctl) ) )
return -EFAULT; return -EFAULT;
switch ( ctl.func ) { switch ( ctl.func ) {
case DRM_INST_HANDLER: case DRM_INST_HANDLER:
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return 0;
if (dev->if_version < DRM_IF_VERSION(1, 2) && if (dev->if_version < DRM_IF_VERSION(1, 2) &&
ctl.irq != dev->irq) ctl.irq != dev->irq)
return -EINVAL; return -EINVAL;
return DRM(irq_install)( dev ); return DRM(irq_install)( dev );
case DRM_UNINST_HANDLER: case DRM_UNINST_HANDLER:
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
return 0;
return DRM(irq_uninstall)( dev ); return DRM(irq_uninstall)( dev );
default: default:
return -EINVAL; return -EINVAL;
} }
} }
#ifdef __HAVE_VBL_IRQ
/** /**
* Wait for VBLANK. * Wait for VBLANK.
* *
...@@ -254,6 +253,9 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) ...@@ -254,6 +253,9 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
int ret = 0; int ret = 0;
unsigned int flags; unsigned int flags;
if (!drm_core_check_feature(dev, DRIVER_IRQ_VBL))
return -EINVAL;
if (!dev->irq) if (!dev->irq)
return -EINVAL; return -EINVAL;
...@@ -318,7 +320,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) ...@@ -318,7 +320,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
} else { } 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 ); do_gettimeofday( &now );
vblwait.reply.tval_sec = now.tv_sec; vblwait.reply.tval_sec = now.tv_sec;
...@@ -366,6 +369,4 @@ void DRM(vbl_send_signals)( drm_device_t *dev ) ...@@ -366,6 +369,4 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
spin_unlock_irqrestore( &dev->vbl_lock, flags ); spin_unlock_irqrestore( &dev->vbl_lock, flags );
} }
#endif /* __HAVE_VBL_IRQ */
#endif /* __HAVE_IRQ */
...@@ -493,18 +493,19 @@ int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma) ...@@ -493,18 +493,19 @@ int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma)
return 0; return 0;
} }
#ifndef DRIVER_GET_MAP_OFS unsigned long DRM(core_get_map_ofs)(drm_map_t *map)
#define DRIVER_GET_MAP_OFS() (map->offset) {
#endif return map->offset;
}
#ifndef DRIVER_GET_REG_OFS unsigned long DRM(core_get_reg_ofs)(struct drm_device *dev)
{
#ifdef __alpha__ #ifdef __alpha__
#define DRIVER_GET_REG_OFS() (dev->hose->dense_mem_base - \ return dev->hose->dense_mem_base - dev->hose->mem_space->start;
dev->hose->mem_space->start)
#else #else
#define DRIVER_GET_REG_OFS() 0 return 0;
#endif
#endif #endif
}
/** /**
* mmap DMA memory. * mmap DMA memory.
...@@ -557,7 +558,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) ...@@ -557,7 +558,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
r_list = list_entry(list, drm_map_list_t, head); r_list = list_entry(list, drm_map_list_t, head);
map = r_list->map; map = r_list->map;
if (!map) continue; if (!map) continue;
off = DRIVER_GET_MAP_OFS(); off = dev->fn_tbl.get_map_ofs(map);
if (off == VM_OFFSET(vma)) break; if (off == VM_OFFSET(vma)) break;
} }
...@@ -612,7 +613,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) ...@@ -612,7 +613,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
if (map->type != _DRM_AGP) if (map->type != _DRM_AGP)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
#endif #endif
offset = DRIVER_GET_REG_OFS(); offset = dev->fn_tbl.get_reg_ofs(dev);
#ifdef __sparc__ #ifdef __sparc__
if (io_remap_page_range(DRM_RPR_ARG(vma) vma->vm_start, if (io_remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
VM_OFFSET(vma) + offset, VM_OFFSET(vma) + offset,
......
...@@ -354,7 +354,7 @@ static void FFBWait(ffb_fbcPtr ffb) ...@@ -354,7 +354,7 @@ static void FFBWait(ffb_fbcPtr ffb)
} while (--limit); } while (--limit);
} }
int DRM(context_switch)(drm_device_t *dev, int old, int new) int ffb_driver_context_switch(drm_device_t *dev, int old, int new)
{ {
ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private; ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
...@@ -380,7 +380,7 @@ int DRM(context_switch)(drm_device_t *dev, int old, int new) ...@@ -380,7 +380,7 @@ int DRM(context_switch)(drm_device_t *dev, int old, int new)
return 0; return 0;
} }
int DRM(resctx)(struct inode *inode, struct file *filp, unsigned int cmd, int ffb_driver_resctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
drm_ctx_res_t res; drm_ctx_res_t res;
...@@ -407,7 +407,7 @@ int DRM(resctx)(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -407,7 +407,7 @@ int DRM(resctx)(struct inode *inode, struct file *filp, unsigned int cmd,
} }
int DRM(addctx)(struct inode *inode, struct file *filp, unsigned int cmd, int ffb_driver_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -428,7 +428,7 @@ int DRM(addctx)(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -428,7 +428,7 @@ int DRM(addctx)(struct inode *inode, struct file *filp, unsigned int cmd,
return 0; return 0;
} }
int DRM(modctx)(struct inode *inode, struct file *filp, unsigned int cmd, int ffb_driver_modctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -457,7 +457,7 @@ int DRM(modctx)(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -457,7 +457,7 @@ int DRM(modctx)(struct inode *inode, struct file *filp, unsigned int cmd,
return 0; return 0;
} }
int DRM(getctx)(struct inode *inode, struct file *filp, unsigned int cmd, int ffb_driver_getctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -489,7 +489,7 @@ int DRM(getctx)(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -489,7 +489,7 @@ int DRM(getctx)(struct inode *inode, struct file *filp, unsigned int cmd,
return 0; return 0;
} }
int DRM(switchctx)(struct inode *inode, struct file *filp, unsigned int cmd, int ffb_driver_switchctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -499,10 +499,10 @@ int DRM(switchctx)(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -499,10 +499,10 @@ int DRM(switchctx)(struct inode *inode, struct file *filp, unsigned int cmd,
if (copy_from_user(&ctx, (drm_ctx_t __user *)arg, sizeof(ctx))) if (copy_from_user(&ctx, (drm_ctx_t __user *)arg, sizeof(ctx)))
return -EFAULT; return -EFAULT;
DRM_DEBUG("%d\n", ctx.handle); DRM_DEBUG("%d\n", ctx.handle);
return DRM(context_switch)(dev, dev->last_context, ctx.handle); return ffb_driver_context_switch(dev, dev->last_context, ctx.handle);
} }
int DRM(newctx)(struct inode *inode, struct file *filp, unsigned int cmd, int ffb_driver_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
drm_ctx_t ctx; drm_ctx_t ctx;
...@@ -514,7 +514,7 @@ int DRM(newctx)(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -514,7 +514,7 @@ int DRM(newctx)(struct inode *inode, struct file *filp, unsigned int cmd,
return 0; return 0;
} }
int DRM(rmctx)(struct inode *inode, struct file *filp, unsigned int cmd, int ffb_driver_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
drm_ctx_t ctx; drm_ctx_t ctx;
...@@ -538,62 +538,14 @@ int DRM(rmctx)(struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -538,62 +538,14 @@ int DRM(rmctx)(struct inode *inode, struct file *filp, unsigned int cmd,
return 0; return 0;
} }
static void ffb_driver_release(drm_device_t *dev) void ffb_set_context_ioctls(void)
{ {
ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private; DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)].func = ffb_driver_addctx;
int context = _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock); DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)].func = ffb_driver_rmctx;
int idx; DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)].func = ffb_driver_modctx;
DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)].func = ffb_driver_getctx;
idx = context - 1; DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)].func = ffb_driver_switchctx;
if (fpriv && DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)].func = ffb_driver_newctx;
context != DRM_KERNEL_CONTEXT && DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)].func = ffb_driver_resctx;
fpriv->hw_state[idx] != NULL) {
kfree(fpriv->hw_state[idx]);
fpriv->hw_state[idx] = NULL;
}
}
static int ffb_driver_presetup(drm_device_t *dev)
{
int ret;
ret = ffb_presetup(dev);
if (_ret != 0) return ret;
}
static void ffb_driver_pretakedown(drm_device_t *dev)
{
if (dev->dev_private) kfree(dev->dev_private);
}
static void ffb_driver_postcleanup(drm_device_t *dev)
{
if (ffb_position != NULL) kfree(ffb_position);
}
static int ffb_driver_kernel_context_switch_unlock(struct drm_device *dev)
{
dev->lock.filp = 0;
{
__volatile__ unsigned int *plock = &dev->lock.hw_lock->lock;
unsigned int old, new, prev, ctx;
ctx = lock.context;
do {
old = *plock;
new = ctx;
prev = cmpxchg(plock, old, new);
} while (prev != old);
}
wake_up_interruptible(&dev->lock.lock_queue);
}
static void ffb_driver_register_fns(drm_device_t *dev)
{
DRM(fops).get_unmapped_area = ffb_get_unmapped_area;
dev->fn_tbl.release = ffb_driver_release;
dev->fn_tbl.presetup = ffb_driver_presetup;
dev->fn_tbl.pretakedown = ffb_driver_pretakedown;
dev->fn_tbl.postcleanup = ffb_driver_postcleanup;
dev->fn_tbl.kernel_context_switch = ffb_context_switch;
dev->fn_tbl.kernel_context_switch_unlock = ffb_driver_kernel_context_switch_unlock;
} }
...@@ -26,12 +26,6 @@ ...@@ -26,12 +26,6 @@
#define DRIVER_MINOR 0 #define DRIVER_MINOR 0
#define DRIVER_PATCHLEVEL 1 #define DRIVER_PATCHLEVEL 1
#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 { typedef struct _ffb_position_t {
int node; int node;
int root; int root;
...@@ -146,63 +140,6 @@ static int ffb_init_one(drm_device_t *dev, int prom_node, int parent_node, ...@@ -146,63 +140,6 @@ static int ffb_init_one(drm_device_t *dev, int prom_node, int parent_node,
return 0; return 0;
} }
static int __init ffb_count_siblings(int root)
{
int node, child, count = 0;
child = prom_getchild(root);
for (node = prom_searchsiblings(child, "SUNW,ffb"); node;
node = prom_searchsiblings(prom_getsibling(node), "SUNW,ffb"))
count++;
return count;
}
static int __init ffb_scan_siblings(int root, int instance)
{
int node, child;
child = prom_getchild(root);
for (node = prom_searchsiblings(child, "SUNW,ffb"); node;
node = prom_searchsiblings(prom_getsibling(node), "SUNW,ffb")) {
ffb_position[instance].node = node;
ffb_position[instance].root = root;
instance++;
}
return instance;
}
static int ffb_presetup(drm_device_t *);
static int __init ffb_count_card_instances(void)
{
int root, total, instance;
total = ffb_count_siblings(prom_root_node);
root = prom_getchild(prom_root_node);
for (root = prom_searchsiblings(root, "upa"); root;
root = prom_searchsiblings(prom_getsibling(root), "upa"))
total += ffb_count_siblings(root);
ffb_position = kmalloc(sizeof(ffb_position_t) * total, GFP_KERNEL);
/* Actual failure will be caught during ffb_presetup b/c we can't catch
* it easily here.
*/
if (!ffb_position)
return -ENOMEM;
instance = ffb_scan_siblings(prom_root_node, 0);
root = prom_getchild(prom_root_node);
for (root = prom_searchsiblings(root, "upa"); root;
root = prom_searchsiblings(prom_getsibling(root), "upa"))
instance = ffb_scan_siblings(root, instance);
return total;
}
static drm_map_t *ffb_find_map(struct file *filp, unsigned long off) static drm_map_t *ffb_find_map(struct file *filp, unsigned long off)
{ {
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
...@@ -273,18 +210,9 @@ unsigned long ffb_get_unmapped_area(struct file *filp, ...@@ -273,18 +210,9 @@ unsigned long ffb_get_unmapped_area(struct file *filp,
return addr; 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_auth.h"
#include "drm_bufs.h" #include "drm_bufs.h"
#include "drm_context.h"
#include "drm_dma.h" #include "drm_dma.h"
#include "drm_drawable.h" #include "drm_drawable.h"
#include "drm_drv.h" #include "drm_drv.h"
...@@ -329,8 +257,83 @@ static int ffb_presetup(drm_device_t *dev) ...@@ -329,8 +257,83 @@ static int ffb_presetup(drm_device_t *dev)
#include "drm_fops.h" #include "drm_fops.h"
#include "drm_init.h" #include "drm_init.h"
#include "drm_ioctl.h" #include "drm_ioctl.h"
#include "drm_irq.h"
#include "drm_lock.h" #include "drm_lock.h"
#include "drm_memory.h" #include "drm_memory.h"
#include "drm_proc.h" #include "drm_proc.h"
#include "drm_vm.h" #include "drm_vm.h"
#include "drm_stub.h" #include "drm_stub.h"
#include "drm_scatter.h"
static void ffb_driver_release(drm_device_t *dev, struct file *filp)
{
ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
int context = _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock);
int idx;
idx = context - 1;
if (fpriv &&
context != DRM_KERNEL_CONTEXT &&
fpriv->hw_state[idx] != NULL) {
kfree(fpriv->hw_state[idx]);
fpriv->hw_state[idx] = NULL;
}
}
static void ffb_driver_pretakedown(drm_device_t *dev)
{
if (dev->dev_private) kfree(dev->dev_private);
}
static int ffb_driver_postcleanup(drm_device_t *dev)
{
if (ffb_position != NULL) kfree(ffb_position);
return 0;
}
static void ffb_driver_kernel_context_switch_unlock(struct drm_device *dev, drm_lock_t *lock)
{
dev->lock.filp = 0;
{
__volatile__ unsigned int *plock = &dev->lock.hw_lock->lock;
unsigned int old, new, prev, ctx;
ctx = lock->context;
do {
old = *plock;
new = ctx;
prev = cmpxchg(plock, old, new);
} while (prev != old);
}
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;
}
void ffb_driver_register_fns(drm_device_t *dev)
{
ffb_set_context_ioctls();
DRM(fops).get_unmapped_area = ffb_get_unmapped_area;
dev->fn_tbl.release = ffb_driver_release;
dev->fn_tbl.presetup = ffb_presetup;
dev->fn_tbl.pretakedown = ffb_driver_pretakedown;
dev->fn_tbl.postcleanup = ffb_driver_postcleanup;
dev->fn_tbl.kernel_context_switch = ffb_context_switch;
dev->fn_tbl.kernel_context_switch_unlock = ffb_driver_kernel_context_switch_unlock;
dev->fn_tbl.get_map_ofs = ffb_driver_get_map_ofs;
dev->fn_tbl.get_reg_ofs = ffb_driver_get_reg_ofs;
}
...@@ -281,3 +281,6 @@ extern unsigned long ffb_get_unmapped_area(struct file *filp, ...@@ -281,3 +281,6 @@ extern unsigned long ffb_get_unmapped_area(struct file *filp,
unsigned long len, unsigned long len,
unsigned long pgoff, unsigned long pgoff,
unsigned long flags); unsigned long flags);
extern void ffb_set_context_ioctls(void);
extern drm_ioctl_desc_t DRM(ioctls)[];
...@@ -69,15 +69,9 @@ ...@@ -69,15 +69,9 @@
/* DMA customization: /* DMA customization:
*/ */
#define __HAVE_DMA 1
#define __HAVE_OLD_DMA 1
#define __HAVE_MULTIPLE_DMA_QUEUES 1 #define __HAVE_MULTIPLE_DMA_QUEUES 1
#define __HAVE_DMA_WAITQUEUE 1 #define __HAVE_DMA_WAITQUEUE 1
/* removed from DRM HAVE_DMA_FREELIST & HAVE_DMA_SCHEDULE */ /* removed from DRM HAVE_DMA_FREELIST & HAVE_DMA_SCHEDULE */
#define __HAVE_IRQ 1
#define __HAVE_IRQ_BH 1
#endif /* __GAMMA_H__ */ #endif /* __GAMMA_H__ */
...@@ -116,7 +116,7 @@ static inline int gamma_dma_is_ready(drm_device_t *dev) ...@@ -116,7 +116,7 @@ static inline int gamma_dma_is_ready(drm_device_t *dev)
return (!GAMMA_READ(GAMMA_DMACOUNT)); 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_t *dev = (drm_device_t *)arg;
drm_device_dma_t *dma = dev->dma; drm_device_dma_t *dma = dev->dma;
...@@ -689,13 +689,13 @@ int gamma_do_cleanup_dma( drm_device_t *dev ) ...@@ -689,13 +689,13 @@ int gamma_do_cleanup_dma( drm_device_t *dev )
{ {
DRM_DEBUG( "%s\n", __FUNCTION__ ); DRM_DEBUG( "%s\n", __FUNCTION__ );
#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl /* Make sure interrupts are disabled here because the uninstall ioctl
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if ( dev->irq_enabled ) DRM(irq_uninstall)(dev); if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
#endif if ( dev->irq_enabled )
DRM(irq_uninstall)(dev);
if ( dev->dev_private ) { if ( dev->dev_private ) {
...@@ -866,7 +866,7 @@ int gamma_setsareactx(struct inode *inode, struct file *filp, ...@@ -866,7 +866,7 @@ int gamma_setsareactx(struct inode *inode, struct file *filp,
return 0; 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_priv =
(drm_gamma_private_t *)dev->dev_private; (drm_gamma_private_t *)dev->dev_private;
...@@ -877,7 +877,7 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) { ...@@ -877,7 +877,7 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
GAMMA_WRITE( GAMMA_GDMACONTROL, 0x00000000 ); 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_priv =
(drm_gamma_private_t *)dev->dev_private; (drm_gamma_private_t *)dev->dev_private;
...@@ -889,7 +889,7 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) { ...@@ -889,7 +889,7 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) {
GAMMA_WRITE( GAMMA_GDELAYTIMER, 0x00039090 ); 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_priv =
(drm_gamma_private_t *)dev->dev_private; (drm_gamma_private_t *)dev->dev_private;
if (!dev_priv) if (!dev_priv)
...@@ -934,7 +934,7 @@ static int gamma_driver_dma_quiescent(drm_device_t *dev) ...@@ -934,7 +934,7 @@ static int gamma_driver_dma_quiescent(drm_device_t *dev)
void gamma_driver_register_fns(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; 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).read = gamma_fops_read;
DRM(fops).poll = gamma_fops_poll; DRM(fops).poll = gamma_fops_poll;
dev->fn_tbl.preinit = gamma_driver_preinit; dev->fn_tbl.preinit = gamma_driver_preinit;
......
...@@ -80,16 +80,4 @@ ...@@ -80,16 +80,4 @@
#define __HAVE_COUNTER8 _DRM_STAT_SECONDARY #define __HAVE_COUNTER8 _DRM_STAT_SECONDARY
#define __HAVE_COUNTER9 _DRM_STAT_DMA #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 #endif
...@@ -232,13 +232,12 @@ int i810_dma_cleanup(drm_device_t *dev) ...@@ -232,13 +232,12 @@ int i810_dma_cleanup(drm_device_t *dev)
{ {
drm_device_dma_t *dma = dev->dma; drm_device_dma_t *dma = dev->dma;
#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl /* Make sure interrupts are disabled here because the uninstall ioctl
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if ( dev->irq_enabled ) DRM(irq_uninstall)(dev); if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ) && dev->irq_enabled)
#endif DRM(irq_uninstall)(dev);
if (dev->dev_private) { if (dev->dev_private) {
int i; int i;
...@@ -1407,10 +1406,11 @@ static int i810_driver_dma_quiescent(drm_device_t *dev) ...@@ -1407,10 +1406,11 @@ static int i810_driver_dma_quiescent(drm_device_t *dev)
void i810_driver_register_fns(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; 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->dev_priv_size = sizeof(drm_i810_buf_priv_t);
dev->fn_tbl.pretakedown = i810_driver_pretakedown; dev->fn_tbl.pretakedown = i810_driver_pretakedown;
dev->fn_tbl.release = i810_driver_release; dev->fn_tbl.release = i810_driver_release;
dev->fn_tbl.dma_quiescent = i810_driver_dma_quiescent; dev->fn_tbl.dma_quiescent = i810_driver_dma_quiescent;
dev->fn_tbl.reclaim_buffers = i810_reclaim_buffers;
} }
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "drm_fops.h" #include "drm_fops.h"
#include "drm_init.h" #include "drm_init.h"
#include "drm_ioctl.h" #include "drm_ioctl.h"
#include "drm_irq.h"
#include "drm_lock.h" #include "drm_lock.h"
#include "drm_memory.h" #include "drm_memory.h"
#include "drm_proc.h" #include "drm_proc.h"
......
...@@ -79,12 +79,6 @@ ...@@ -79,12 +79,6 @@
#define __HAVE_COUNTER8 _DRM_STAT_SECONDARY #define __HAVE_COUNTER8 _DRM_STAT_SECONDARY
#define __HAVE_COUNTER9 _DRM_STAT_DMA #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 /* Driver will work either way: IRQ's save cpu time when waiting for
* the card, but are subject to subtle interactions between bios, * the card, but are subject to subtle interactions between bios,
* hardware and the driver. * hardware and the driver.
...@@ -92,11 +86,4 @@ ...@@ -92,11 +86,4 @@
/* XXX: Add vblank support? */ /* XXX: Add vblank support? */
#define USE_IRQS 0 #define USE_IRQS 0
#if USE_IRQS
#define __HAVE_IRQ 1
#define __HAVE_SHARED_IRQ 1
#else
#define __HAVE_IRQ 0
#endif
#endif #endif
...@@ -233,13 +233,11 @@ int i830_dma_cleanup(drm_device_t *dev) ...@@ -233,13 +233,11 @@ int i830_dma_cleanup(drm_device_t *dev)
{ {
drm_device_dma_t *dma = dev->dma; drm_device_dma_t *dma = dev->dma;
#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl /* Make sure interrupts are disabled here because the uninstall ioctl
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if ( dev->irq_enabled ) DRM(irq_uninstall)(dev); if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#endif
if (dev->dev_private) { if (dev->dev_private) {
int i; int i;
...@@ -1602,10 +1600,20 @@ static int i830_driver_dma_quiescent(drm_device_t *dev) ...@@ -1602,10 +1600,20 @@ static int i830_driver_dma_quiescent(drm_device_t *dev)
void i830_driver_register_fns(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; 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->dev_priv_size = sizeof(drm_i830_buf_priv_t);
dev->fn_tbl.pretakedown = i830_driver_pretakedown; dev->fn_tbl.pretakedown = i830_driver_pretakedown;
dev->fn_tbl.release = i830_driver_release; dev->fn_tbl.release = i830_driver_release;
dev->fn_tbl.dma_quiescent = i830_driver_dma_quiescent; 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
} }
...@@ -136,6 +136,10 @@ extern int i830_irq_wait( struct inode *inode, struct file *filp, ...@@ -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_wait_irq(drm_device_t *dev, int irq_nr);
extern int i830_emit_irq(drm_device_t *dev); 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) \ #define I830_BASE(reg) ((unsigned long) \
dev_priv->mmio_map->handle) dev_priv->mmio_map->handle)
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <linux/delay.h> #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_device_t *dev = (drm_device_t *)arg;
drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private; drm_i830_private_t *dev_priv = (drm_i830_private_t *)dev->dev_private;
...@@ -178,7 +178,7 @@ int i830_irq_wait( struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -178,7 +178,7 @@ int i830_irq_wait( struct inode *inode, struct file *filp, unsigned int cmd,
/* drm_dma.h hooks /* 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_priv =
(drm_i830_private_t *)dev->dev_private; (drm_i830_private_t *)dev->dev_private;
...@@ -190,14 +190,14 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) { ...@@ -190,14 +190,14 @@ void DRM(driver_irq_preinstall)( drm_device_t *dev ) {
init_waitqueue_head(&dev_priv->irq_queue); 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_priv =
(drm_i830_private_t *)dev->dev_private; (drm_i830_private_t *)dev->dev_private;
I830_WRITE16( I830REG_INT_ENABLE_R, 0x2 ); 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_priv =
(drm_i830_private_t *)dev->dev_private; (drm_i830_private_t *)dev->dev_private;
if (!dev_priv) if (!dev_priv)
......
...@@ -54,10 +54,6 @@ ...@@ -54,10 +54,6 @@
/* We use our own dma mechanisms, not the drm template code. However, /* We use our own dma mechanisms, not the drm template code. However,
* the shared IRQ code is useful to us: * 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 #define __HAVE_PM 1
#endif #endif
...@@ -732,7 +732,11 @@ static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp) ...@@ -732,7 +732,11 @@ static void i915_driver_prerelease(drm_device_t *dev, DRMFILE filp)
void i915_driver_register_fns(drm_device_t *dev) void i915_driver_register_fns(drm_device_t *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR; 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.pretakedown = i915_driver_pretakedown;
dev->fn_tbl.prerelease = i915_driver_prerelease; 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;
} }
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "drm_bufs.h" #include "drm_bufs.h"
#include "drm_context.h" /* is this needed? */ #include "drm_context.h" /* is this needed? */
#include "drm_drawable.h" /* is this needed? */ #include "drm_drawable.h" /* is this needed? */
#include "drm_dma.h"
#include "drm_drv.h" #include "drm_drv.h"
#include "drm_fops.h" #include "drm_fops.h"
#include "drm_init.h" #include "drm_init.h"
......
...@@ -73,6 +73,11 @@ extern int i915_irq_wait(DRM_IOCTL_ARGS); ...@@ -73,6 +73,11 @@ extern int i915_irq_wait(DRM_IOCTL_ARGS);
extern int i915_wait_irq(drm_device_t * dev, int irq_nr); extern int i915_wait_irq(drm_device_t * dev, int irq_nr);
extern int i915_emit_irq(drm_device_t * dev); 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 */ /* i915_mem.c */
extern int i915_mem_alloc(DRM_IOCTL_ARGS); extern int i915_mem_alloc(DRM_IOCTL_ARGS);
extern int i915_mem_free(DRM_IOCTL_ARGS); extern int i915_mem_free(DRM_IOCTL_ARGS);
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
#define MAX_NOPID ((u32)~0) #define MAX_NOPID ((u32)~0)
#define READ_BREADCRUMB(dev_priv) (((u32*)(dev_priv->hw_status_page))[5]) #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_device_t *dev = (drm_device_t *) arg;
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
u16 temp; u16 temp;
...@@ -135,7 +136,8 @@ int i915_irq_wait(DRM_IOCTL_ARGS) ...@@ -135,7 +136,8 @@ int i915_irq_wait(DRM_IOCTL_ARGS)
/* drm_dma.h hooks /* 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; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
I915_WRITE16(I915REG_HWSTAM, 0xfffe); I915_WRITE16(I915REG_HWSTAM, 0xfffe);
...@@ -143,14 +145,16 @@ void DRM(driver_irq_preinstall) (drm_device_t * dev) { ...@@ -143,14 +145,16 @@ void DRM(driver_irq_preinstall) (drm_device_t * dev) {
I915_WRITE16(I915REG_INT_ENABLE_R, 0x0); 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; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG); I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG);
DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); 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; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
if (!dev_priv) if (!dev_priv)
return; return;
......
...@@ -65,11 +65,4 @@ ...@@ -65,11 +65,4 @@
#define __HAVE_COUNTER7 _DRM_STAT_PRIMARY #define __HAVE_COUNTER7 _DRM_STAT_PRIMARY
#define __HAVE_COUNTER8 _DRM_STAT_SECONDARY #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 #endif
...@@ -630,13 +630,11 @@ int mga_do_cleanup_dma( drm_device_t *dev ) ...@@ -630,13 +630,11 @@ int mga_do_cleanup_dma( drm_device_t *dev )
{ {
DRM_DEBUG( "\n" ); DRM_DEBUG( "\n" );
#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl /* Make sure interrupts are disabled here because the uninstall ioctl
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if ( dev->irq_enabled ) DRM(irq_uninstall)(dev); if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#endif
if ( dev->dev_private ) { if ( dev->dev_private ) {
drm_mga_private_t *dev_priv = dev->dev_private; drm_mga_private_t *dev_priv = dev->dev_private;
...@@ -813,7 +811,12 @@ static int mga_driver_dma_quiescent(drm_device_t *dev) ...@@ -813,7 +811,12 @@ static int mga_driver_dma_quiescent(drm_device_t *dev)
void mga_driver_register_fns(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; 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.pretakedown = mga_driver_pretakedown;
dev->fn_tbl.dma_quiescent = mga_driver_dma_quiescent; 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;
} }
...@@ -130,6 +130,12 @@ extern int mga_getparam( DRM_IOCTL_ARGS ); ...@@ -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_install_microcode( drm_mga_private_t *dev_priv );
extern int mga_warp_init( 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() #define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER()
#if defined(__linux__) && defined(__alpha__) #if defined(__linux__) && defined(__alpha__)
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "mga_drm.h" #include "mga_drm.h"
#include "mga_drv.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_device_t *dev = (drm_device_t *) arg;
drm_mga_private_t *dev_priv = drm_mga_private_t *dev_priv =
...@@ -56,7 +56,7 @@ irqreturn_t mga_irq_handler( DRM_IRQ_ARGS ) ...@@ -56,7 +56,7 @@ irqreturn_t mga_irq_handler( DRM_IRQ_ARGS )
return IRQ_NONE; 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; unsigned int cur_vblank;
int ret = 0; int ret = 0;
......
...@@ -72,11 +72,4 @@ ...@@ -72,11 +72,4 @@
[DRM_IOCTL_NR(DRM_IOCTL_R128_INDIRECT)] = { r128_cce_indirect, 1, 1 }, \ [DRM_IOCTL_NR(DRM_IOCTL_R128_INDIRECT)] = { r128_cce_indirect, 1, 1 }, \
[DRM_IOCTL_NR(DRM_IOCTL_R128_GETPARAM)] = { r128_getparam, 1, 0 }, [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 #endif
...@@ -586,13 +586,11 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) ...@@ -586,13 +586,11 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
int r128_do_cleanup_cce( drm_device_t *dev ) int r128_do_cleanup_cce( drm_device_t *dev )
{ {
#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl /* Make sure interrupts are disabled here because the uninstall ioctl
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if ( dev->irq_enabled ) DRM(irq_uninstall)(dev); if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#endif
if ( dev->dev_private ) { if ( dev->dev_private ) {
drm_r128_private_t *dev_priv = dev->dev_private; drm_r128_private_t *dev_priv = dev->dev_private;
......
...@@ -142,6 +142,12 @@ extern int r128_cce_depth( DRM_IOCTL_ARGS ); ...@@ -142,6 +142,12 @@ extern int r128_cce_depth( DRM_IOCTL_ARGS );
extern int r128_cce_stipple( DRM_IOCTL_ARGS ); extern int r128_cce_stipple( DRM_IOCTL_ARGS );
extern int r128_cce_indirect( 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 /* Register definitions, register access macros and drmAddMap constants
* for Rage 128 kernel driver. * for Rage 128 kernel driver.
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "r128_drm.h" #include "r128_drm.h"
#include "r128_drv.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_device_t *dev = (drm_device_t *) arg;
drm_r128_private_t *dev_priv = drm_r128_private_t *dev_priv =
...@@ -56,7 +56,7 @@ irqreturn_t r128_irq_handler( DRM_IRQ_ARGS ) ...@@ -56,7 +56,7 @@ irqreturn_t r128_irq_handler( DRM_IRQ_ARGS )
return IRQ_NONE; 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; unsigned int cur_vblank;
int ret = 0; int ret = 0;
......
...@@ -1712,8 +1712,13 @@ static void r128_driver_pretakedown(drm_device_t *dev) ...@@ -1712,8 +1712,13 @@ static void r128_driver_pretakedown(drm_device_t *dev)
void r128_driver_register_fns(drm_device_t *dev) void r128_driver_register_fns(drm_device_t *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG; 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->dev_priv_size = sizeof(drm_r128_buf_priv_t);
dev->fn_tbl.prerelease = r128_driver_prerelease; dev->fn_tbl.prerelease = r128_driver_prerelease;
dev->fn_tbl.pretakedown = r128_driver_pretakedown; 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;
} }
...@@ -109,11 +109,4 @@ ...@@ -109,11 +109,4 @@
[DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_WAIT)] = { radeon_irq_wait, 1, 0 }, \ [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 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_SETPARAM)] = { radeon_cp_setparam, 1, 0 }, \
/* DMA customization:
*/
#define __HAVE_DMA 1
#define __HAVE_IRQ 1
#define __HAVE_VBL_IRQ 1
#define __HAVE_SHARED_IRQ 1
#endif #endif
...@@ -1275,13 +1275,11 @@ int radeon_do_cleanup_cp( drm_device_t *dev ) ...@@ -1275,13 +1275,11 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
{ {
DRM_DEBUG( "\n" ); DRM_DEBUG( "\n" );
#if __HAVE_IRQ
/* Make sure interrupts are disabled here because the uninstall ioctl /* Make sure interrupts are disabled here because the uninstall ioctl
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if ( dev->irq_enabled ) DRM(irq_uninstall)(dev); if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#endif
if ( dev->dev_private ) { if ( dev->dev_private ) {
drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_private_t *dev_priv = dev->dev_private;
......
...@@ -205,6 +205,11 @@ extern int radeon_wait_irq(drm_device_t *dev, int swi_nr); ...@@ -205,6 +205,11 @@ extern int radeon_wait_irq(drm_device_t *dev, int swi_nr);
extern int radeon_emit_irq(drm_device_t *dev); extern int radeon_emit_irq(drm_device_t *dev);
extern void radeon_do_release(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 /* Flags for stats.boxes
*/ */
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
* tied to dma at all, this is just a hangover from dri prehistory. * 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_device_t *dev = (drm_device_t *) arg;
drm_radeon_private_t *dev_priv = drm_radeon_private_t *dev_priv =
...@@ -141,7 +141,7 @@ int radeon_emit_and_wait_irq(drm_device_t *dev) ...@@ -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_priv =
(drm_radeon_private_t *)dev->dev_private; (drm_radeon_private_t *)dev->dev_private;
......
...@@ -2603,10 +2603,15 @@ static void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_pri ...@@ -2603,10 +2603,15 @@ static void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_pri
void radeon_driver_register_fns(struct drm_device *dev) void radeon_driver_register_fns(struct drm_device *dev)
{ {
dev->driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG; 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->dev_priv_size = sizeof(drm_radeon_buf_priv_t);
dev->fn_tbl.prerelease = radeon_driver_prerelease; dev->fn_tbl.prerelease = radeon_driver_prerelease;
dev->fn_tbl.pretakedown = radeon_driver_pretakedown; dev->fn_tbl.pretakedown = radeon_driver_pretakedown;
dev->fn_tbl.open_helper = radeon_driver_open_helper; dev->fn_tbl.open_helper = radeon_driver_open_helper;
dev->fn_tbl.free_filp_priv = radeon_driver_free_filp_priv; dev->fn_tbl.free_filp_priv = radeon_driver_free_filp_priv;
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;
} }
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "drm_drv.h" #include "drm_drv.h"
#include "drm_fops.h" #include "drm_fops.h"
#include "drm_init.h" #include "drm_init.h"
#include "drm_irq.h"
#include "drm_ioctl.h" #include "drm_ioctl.h"
#include "drm_lock.h" #include "drm_lock.h"
#include "drm_memory.h" #include "drm_memory.h"
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "drm_fops.h" #include "drm_fops.h"
#include "drm_init.h" #include "drm_init.h"
#include "drm_ioctl.h" #include "drm_ioctl.h"
#include "drm_irq.h"
#include "drm_lock.h" #include "drm_lock.h"
#include "drm_memory.h" #include "drm_memory.h"
#include "drm_proc.h" #include "drm_proc.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment