summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2004-08-10 06:30:28 +0000
committerDave Airlie <airlied@linux.ie>2004-08-10 06:30:28 +0000
commitc9bcc4a6d90c0f2e9c712185a56727a55c11f4e0 (patch)
tree583fcc164c676b40f0fd63230d3965083a876859
parent67eae63e8947e06d7ee42d7e23796b8597e23d83 (diff)
dump: DRIVER_CTX_[CD]TOR, HAVE_KERNEL_CTX_SWITCH, DRIVER_BUF_PRIV_T,
DRIVER_AGP_BUFFERS_MAP
-rw-r--r--bsd-core/drmP.h4
-rw-r--r--bsd-core/drm_context.c11
-rw-r--r--bsd-core/sis_drv.c3
-rw-r--r--bsd/drmP.h4
-rw-r--r--bsd/drm_context.h11
-rw-r--r--bsd/sis_drv.c3
-rw-r--r--linux-core/drmP.h6
-rw-r--r--linux-core/drm_bufs.c26
-rw-r--r--linux-core/drm_context.c14
-rw-r--r--linux-core/drm_drv.c71
-rw-r--r--linux-core/ffb.h4
-rw-r--r--linux-core/ffb_context.c19
-rw-r--r--linux-core/i810_dma.c5
-rw-r--r--linux-core/i810_drv.h1
-rw-r--r--linux-core/i830_dma.c5
-rw-r--r--linux-core/i830_drv.h1
-rw-r--r--linux-core/sis_drv.c4
-rw-r--r--linux/drmP.h6
-rw-r--r--linux/drm_bufs.h26
-rw-r--r--linux/drm_context.h14
-rw-r--r--linux/drm_drv.h71
-rw-r--r--linux/ffb.h4
-rw-r--r--linux/ffb_context.c19
-rw-r--r--linux/gamma.h4
-rw-r--r--linux/gamma_dma.c9
-rw-r--r--linux/gamma_drv.h1
-rw-r--r--linux/i810.h8
-rw-r--r--linux/i810_dma.c5
-rw-r--r--linux/i810_drv.h1
-rw-r--r--linux/i830.h9
-rw-r--r--linux/i830_dma.c5
-rw-r--r--linux/i830_drv.h1
-rw-r--r--linux/sis_drv.c4
-rw-r--r--shared-core/mach64_dma.c16
-rw-r--r--shared-core/mach64_drv.h4
-rw-r--r--shared-core/mga_dma.c12
-rw-r--r--shared-core/r128_cce.c14
-rw-r--r--shared-core/r128_drv.h1
-rw-r--r--shared-core/r128_state.c9
-rw-r--r--shared-core/radeon_cp.c22
-rw-r--r--shared-core/radeon_drv.h1
-rw-r--r--shared-core/radeon_state.c15
-rw-r--r--shared-core/sis_drv.h2
-rw-r--r--shared-core/sis_mm.c10
-rw-r--r--shared-core/via_drv.c3
-rw-r--r--shared-core/via_drv.h1
-rw-r--r--shared-core/via_mm.c10
-rw-r--r--shared/mach64.h6
-rw-r--r--shared/mach64_dma.c16
-rw-r--r--shared/mach64_drv.h4
-rw-r--r--shared/mga.h7
-rw-r--r--shared/mga_dma.c12
-rw-r--r--shared/r128.h7
-rw-r--r--shared/r128_cce.c14
-rw-r--r--shared/r128_drv.h1
-rw-r--r--shared/r128_state.c9
-rw-r--r--shared/radeon.h45
-rw-r--r--shared/radeon_cp.c22
-rw-r--r--shared/radeon_drv.h1
-rw-r--r--shared/radeon_state.c15
-rw-r--r--shared/sis.h11
-rw-r--r--shared/sis_drv.h2
-rw-r--r--shared/sis_mm.c10
-rw-r--r--shared/via.h11
-rw-r--r--shared/via_drv.c3
-rw-r--r--shared/via_drv.h1
-rw-r--r--shared/via_mm.c10
67 files changed, 288 insertions, 418 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index 6ac300878..97168ec6e 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -321,6 +321,10 @@ struct drm_driver_fn {
int (*dma_quiescent)(struct drm_device *);
int (*dma_flush_block_and_flush)(struct drm_device *, int context, drm_lock_flags_t flags);
int (*dma_flush_unblock)(struct drm_device *, int context, drm_lock_flags_t flags);
+ int (*context_ctor)(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_unlock)(struct drm_device *dev);
};
struct drm_device {
diff --git a/bsd-core/drm_context.c b/bsd-core/drm_context.c
index 3cb5992a6..8988ee22e 100644
--- a/bsd-core/drm_context.c
+++ b/bsd-core/drm_context.c
@@ -278,10 +278,8 @@ int DRM(addctx)( DRM_IOCTL_ARGS )
return DRM_ERR(ENOMEM);
}
-#ifdef DRIVER_CTX_CTOR
- if ( ctx.handle != DRM_KERNEL_CONTEXT )
- DRIVER_CTX_CTOR(ctx.handle); /* XXX: also pass dev ? */
-#endif
+ if ( dev->fn_tbl.context_ctor && ctx.handle != DRM_KERNEL_CONTEXT )
+ dev->fn_tbl.context_ctor(dev, ctx.handle);
DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
@@ -341,9 +339,8 @@ int DRM(rmctx)( DRM_IOCTL_ARGS )
DRM_DEBUG( "%d\n", ctx.handle );
if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
-#ifdef DRIVER_CTX_DTOR
- DRIVER_CTX_DTOR(ctx.handle); /* XXX: also pass dev ? */
-#endif
+ if (dev->fn_tbl.context_dtor)
+ dev->fn_tbl.context_dtor(dev, ctx.handle);
DRM(ctxbitmap_free)( dev, ctx.handle );
}
diff --git a/bsd-core/sis_drv.c b/bsd-core/sis_drv.c
index c63b8c56f..2d40018e0 100644
--- a/bsd-core/sis_drv.c
+++ b/bsd-core/sis_drv.c
@@ -51,6 +51,3 @@ DRIVER_MODULE(sisdrm, pci, sisdrv_driver, sisdrv_devclass, 0, 0);
CFDRIVER_DECL(sis, DV_TTY, NULL);
#endif /* __FreeBSD__ */
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
-}
diff --git a/bsd/drmP.h b/bsd/drmP.h
index 6ac300878..97168ec6e 100644
--- a/bsd/drmP.h
+++ b/bsd/drmP.h
@@ -321,6 +321,10 @@ struct drm_driver_fn {
int (*dma_quiescent)(struct drm_device *);
int (*dma_flush_block_and_flush)(struct drm_device *, int context, drm_lock_flags_t flags);
int (*dma_flush_unblock)(struct drm_device *, int context, drm_lock_flags_t flags);
+ int (*context_ctor)(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_unlock)(struct drm_device *dev);
};
struct drm_device {
diff --git a/bsd/drm_context.h b/bsd/drm_context.h
index 3cb5992a6..8988ee22e 100644
--- a/bsd/drm_context.h
+++ b/bsd/drm_context.h
@@ -278,10 +278,8 @@ int DRM(addctx)( DRM_IOCTL_ARGS )
return DRM_ERR(ENOMEM);
}
-#ifdef DRIVER_CTX_CTOR
- if ( ctx.handle != DRM_KERNEL_CONTEXT )
- DRIVER_CTX_CTOR(ctx.handle); /* XXX: also pass dev ? */
-#endif
+ if ( dev->fn_tbl.context_ctor && ctx.handle != DRM_KERNEL_CONTEXT )
+ dev->fn_tbl.context_ctor(dev, ctx.handle);
DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
@@ -341,9 +339,8 @@ int DRM(rmctx)( DRM_IOCTL_ARGS )
DRM_DEBUG( "%d\n", ctx.handle );
if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
-#ifdef DRIVER_CTX_DTOR
- DRIVER_CTX_DTOR(ctx.handle); /* XXX: also pass dev ? */
-#endif
+ if (dev->fn_tbl.context_dtor)
+ dev->fn_tbl.context_dtor(dev, ctx.handle);
DRM(ctxbitmap_free)( dev, ctx.handle );
}
diff --git a/bsd/sis_drv.c b/bsd/sis_drv.c
index c63b8c56f..2d40018e0 100644
--- a/bsd/sis_drv.c
+++ b/bsd/sis_drv.c
@@ -51,6 +51,3 @@ DRIVER_MODULE(sisdrm, pci, sisdrv_driver, sisdrv_devclass, 0, 0);
CFDRIVER_DECL(sis, DV_TTY, NULL);
#endif /* __FreeBSD__ */
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
-}
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 8301d6ef7..05d999b0b 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -588,6 +588,10 @@ struct drm_driver_fn {
int (*dma_quiescent)(struct drm_device *);
int (*dma_flush_block_and_flush)(struct drm_device *, int context, drm_lock_flags_t flags);
int (*dma_flush_unblock)(struct drm_device *, int context, drm_lock_flags_t flags);
+ int (*context_ctor)(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_unlock)(struct drm_device *dev);
};
/**
* DRM device structure.
@@ -724,6 +728,8 @@ typedef struct drm_device {
int need_reset; /**< secondary device needing reset */
struct drm_driver_fn fn_tbl;
+ drm_local_map_t *agp_buffer_map;
+ int dev_priv_size;
} drm_device_t;
extern void DRM(driver_register_fns)(struct drm_device *dev);
diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c
index ef7c37567..3c0d57179 100644
--- a/linux-core/drm_bufs.c
+++ b/linux-core/drm_bufs.c
@@ -45,18 +45,6 @@
#define __HAVE_SG 0
#endif
-#ifndef DRIVER_BUF_PRIV_T
-#define DRIVER_BUF_PRIV_T u32
-#endif
-#ifndef DRIVER_AGP_BUFFERS_MAP
-#if __HAVE_AGP && __HAVE_DMA
-#error "You must define DRIVER_AGP_BUFFERS_MAP()"
-#else
-#define DRIVER_AGP_BUFFERS_MAP( dev ) NULL
-#endif
-#endif
-
-
/**
* Compute size order. Returns the exponent of the smaller power of two which
* is greater or equal to given number.
@@ -474,8 +462,8 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
init_waitqueue_head( &buf->dma_wait );
buf->filp = NULL;
- buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
- buf->dev_private = DRM(alloc)( sizeof(DRIVER_BUF_PRIV_T),
+ buf->dev_priv_size = dev->dev_priv_size;
+ buf->dev_private = DRM(alloc)( buf->dev_priv_size,
DRM_MEM_BUFS );
if(!buf->dev_private) {
/* Set count correctly so we free the proper amount. */
@@ -699,8 +687,8 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
init_waitqueue_head( &buf->dma_wait );
buf->filp = NULL;
- buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
- buf->dev_private = DRM(alloc)( sizeof(DRIVER_BUF_PRIV_T),
+ buf->dev_priv_size = dev->dev_priv_size;
+ buf->dev_private = DRM(alloc)( dev->dev_priv_size,
DRM_MEM_BUFS );
if(!buf->dev_private) {
/* Set count correctly so we free the proper amount. */
@@ -883,8 +871,8 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
init_waitqueue_head( &buf->dma_wait );
buf->filp = NULL;
- buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
- buf->dev_private = DRM(alloc)( sizeof(DRIVER_BUF_PRIV_T),
+ buf->dev_priv_size = dev->dev_priv_size;
+ buf->dev_private = DRM(alloc)( dev->dev_priv_size,
DRM_MEM_BUFS );
if(!buf->dev_private) {
/* Set count correctly so we free the proper amount. */
@@ -1222,7 +1210,7 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
if ( request.count >= dma->buf_count ) {
if ( (__HAVE_AGP && (dma->flags & _DRM_DMA_USE_AGP)) ||
(__HAVE_SG && (dma->flags & _DRM_DMA_USE_SG)) ) {
- drm_map_t *map = DRIVER_AGP_BUFFERS_MAP( dev );
+ drm_map_t *map = dev->agp_buffer_map;
if ( !map ) {
retcode = -EINVAL;
diff --git a/linux-core/drm_context.c b/linux-core/drm_context.c
index 8795198a5..dd280e53b 100644
--- a/linux-core/drm_context.c
+++ b/linux-core/drm_context.c
@@ -420,10 +420,13 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
/* Should this return -EBUSY instead? */
return -ENOMEM;
}
-#ifdef DRIVER_CTX_CTOR
+
if ( ctx.handle != DRM_KERNEL_CONTEXT )
- DRIVER_CTX_CTOR(ctx.handle); /* XXX: also pass dev ? */
-#endif
+ {
+ if (dev->fn_tbl.context_ctor)
+ dev->fn_tbl.context_ctor(dev, ctx.handle);
+ }
+
ctx_entry = DRM(alloc)( sizeof(*ctx_entry), DRM_MEM_CTXLIST );
if ( !ctx_entry ) {
DRM_DEBUG("out of memory\n");
@@ -555,9 +558,8 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
priv->remove_auth_on_close = 1;
}
if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
-#ifdef DRIVER_CTX_DTOR
- DRIVER_CTX_DTOR(ctx.handle); /* XXX: also pass dev ? */
-#endif
+ if (dev->fn_tbl.context_ctor)
+ dev->fn_tbl.context_ctor(dev, ctx.handle);
DRM(ctxbitmap_free)( dev, ctx.handle );
}
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index a7ca103e7..5ce302e38 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -76,13 +76,6 @@
#ifndef __HAVE_SG
#define __HAVE_SG 0
#endif
-/* __HAVE_KERNEL_CTX_SWITCH isn't used by any of the drm modules in
- * the DRI cvs tree, but it is required by the kernel tree's sparc
- * driver.
- */
-#ifndef __HAVE_KERNEL_CTX_SWITCH
-#define __HAVE_KERNEL_CTX_SWITCH 0
-#endif
#ifndef __HAVE_DRIVER_FOPS_READ
#define __HAVE_DRIVER_FOPS_READ 0
#endif
@@ -286,9 +279,6 @@ static int DRM(setup)( drm_device_t *dev )
#ifdef __HAVE_COUNTER14
dev->types[14] = __HAVE_COUNTER14;
#endif
-#ifdef __HAVE_COUNTER15
- dev->types[14] = __HAVE_COUNTER14;
-#endif
for ( i = 0 ; i < DRM_ARRAY_SIZE(dev->counts) ; i++ )
atomic_set( &dev->counts[i], 0 );
@@ -566,7 +556,9 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->pci_slot = PCI_SLOT(pdev->devfn);
dev->pci_func = PCI_FUNC(pdev->devfn);
dev->irq = pdev->irq;
-
+
+ /* dev_priv_size can be changed by a driver in driver_register_fns */
+ dev->dev_priv_size = sizeof(u32);
DRM(driver_register_fns)(dev);
if (dev->fn_tbl.preinit)
@@ -957,9 +949,8 @@ int DRM(release)( struct inode *inode, struct file *filp )
list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) {
if ( pos->tag == priv &&
pos->handle != DRM_KERNEL_CONTEXT ) {
-#ifdef DRIVER_CTX_DTOR
- DRIVER_CTX_DTOR(pos->handle);
-#endif
+ 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
@@ -1166,16 +1157,11 @@ int DRM(lock)( struct inode *inode, struct file *filp,
if ( dev->fn_tbl.dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT ))
return dev->fn_tbl.dma_quiescent(dev);
- /* __HAVE_KERNEL_CTX_SWITCH isn't used by any of the
- * drm modules in the DRI cvs tree, but it is required
- * by the Sparc driver.
- */
-#if __HAVE_KERNEL_CTX_SWITCH
- if ( dev->last_context != lock.context ) {
- DRM(context_switch)(dev, dev->last_context,
- lock.context);
+
+ if ( dev->fn_tbl.kernel_context_switch && dev->last_context != lock.context ) {
+ dev->fn_tbl.kernel_context_switch(dev, dev->last_context,
+ lock.context);
}
-#endif
}
DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );
@@ -1212,40 +1198,21 @@ int DRM(unlock)( struct inode *inode, struct file *filp,
atomic_inc( &dev->counts[_DRM_STAT_UNLOCKS] );
- /* __HAVE_KERNEL_CTX_SWITCH isn't used by any of the drm
- * modules in the DRI cvs tree, but it is required by the
- * Sparc driver.
- */
-#if __HAVE_KERNEL_CTX_SWITCH
- /* We no longer really hold it, but if we are the next
- * agent to request it then we should just be able to
- * take it immediately and not eat the ioctl.
- */
- dev->lock.filp = 0;
+ if (dev->fn_tbl.kernel_context_switch_unlock)
+ dev->fn_tbl.kernel_context_switch_unlock(dev);
+ else
{
- __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);
-#else
- DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT );
+ DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT );
#if __HAVE_DMA_SCHEDULE
- DRM(dma_schedule)( dev, 1 );
+ DRM(dma_schedule)( dev, 1 );
#endif
- if ( DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT ) ) {
- DRM_ERROR( "\n" );
+ if ( DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT ) ) {
+ DRM_ERROR( "\n" );
+ }
}
-#endif /* !__HAVE_KERNEL_CTX_SWITCH */
unblock_all_signals();
return 0;
diff --git a/linux-core/ffb.h b/linux-core/ffb.h
index 179338f63..3691c8652 100644
--- a/linux-core/ffb.h
+++ b/linux-core/ffb.h
@@ -8,9 +8,5 @@
*/
#define DRM(x) ffb_##x
-/* General customization:
- */
-#define __HAVE_KERNEL_CTX_SWITCH 1
-
#endif
diff --git a/linux-core/ffb_context.c b/linux-core/ffb_context.c
index bb5ba6e4b..7960d04ef 100644
--- a/linux-core/ffb_context.c
+++ b/linux-core/ffb_context.c
@@ -570,10 +570,29 @@ 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)
{
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;
}
diff --git a/linux-core/i810_dma.c b/linux-core/i810_dma.c
index f1d5d1f79..b09487e85 100644
--- a/linux-core/i810_dma.c
+++ b/linux-core/i810_dma.c
@@ -378,8 +378,8 @@ static int i810_dma_initialize(drm_device_t *dev,
DRM_ERROR("can not find mmio map!\n");
return -EINVAL;
}
- DRM_FIND_MAP( dev_priv->buffer_map, init->buffers_offset );
- if (!dev_priv->buffer_map) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if (!dev->agp_buffer_map) {
dev->dev_private = (void *)dev_priv;
i810_dma_cleanup(dev);
DRM_ERROR("can not find dma buffer map!\n");
@@ -1413,6 +1413,7 @@ static int i810_driver_dma_quiescent(drm_device_t *dev)
void i810_driver_register_fns(drm_device_t *dev)
{
+ 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;
diff --git a/linux-core/i810_drv.h b/linux-core/i810_drv.h
index 736c20d76..67c5c88bf 100644
--- a/linux-core/i810_drv.h
+++ b/linux-core/i810_drv.h
@@ -53,7 +53,6 @@ typedef struct _drm_i810_ring_buffer{
typedef struct drm_i810_private {
drm_map_t *sarea_map;
- drm_map_t *buffer_map;
drm_map_t *mmio_map;
drm_i810_sarea_t *sarea_priv;
diff --git a/linux-core/i830_dma.c b/linux-core/i830_dma.c
index 9791b97d0..220056046 100644
--- a/linux-core/i830_dma.c
+++ b/linux-core/i830_dma.c
@@ -385,8 +385,8 @@ static int i830_dma_initialize(drm_device_t *dev,
DRM_ERROR("can not find mmio map!\n");
return -EINVAL;
}
- DRM_FIND_MAP( dev_priv->buffer_map, init->buffers_offset );
- if(!dev_priv->buffer_map) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if(!dev->agp_buffer_map) {
dev->dev_private = (void *)dev_priv;
i830_dma_cleanup(dev);
DRM_ERROR("can not find dma buffer map!\n");
@@ -1609,6 +1609,7 @@ static int i830_driver_dma_quiescent(drm_device_t *dev)
void i830_driver_register_fns(drm_device_t *dev)
{
+ 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;
diff --git a/linux-core/i830_drv.h b/linux-core/i830_drv.h
index c6d805fc7..ad4de4c3b 100644
--- a/linux-core/i830_drv.h
+++ b/linux-core/i830_drv.h
@@ -53,7 +53,6 @@ typedef struct _drm_i830_ring_buffer{
typedef struct drm_i830_private {
drm_map_t *sarea_map;
- drm_map_t *buffer_map;
drm_map_t *mmio_map;
drm_i830_sarea_t *sarea_priv;
diff --git a/linux-core/sis_drv.c b/linux-core/sis_drv.c
index 4652e3406..fce5470b9 100644
--- a/linux-core/sis_drv.c
+++ b/linux-core/sis_drv.c
@@ -47,6 +47,4 @@
#include "drm_vm.h"
#include "drm_stub.h"
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
-}
+
diff --git a/linux/drmP.h b/linux/drmP.h
index 8301d6ef7..05d999b0b 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -588,6 +588,10 @@ struct drm_driver_fn {
int (*dma_quiescent)(struct drm_device *);
int (*dma_flush_block_and_flush)(struct drm_device *, int context, drm_lock_flags_t flags);
int (*dma_flush_unblock)(struct drm_device *, int context, drm_lock_flags_t flags);
+ int (*context_ctor)(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_unlock)(struct drm_device *dev);
};
/**
* DRM device structure.
@@ -724,6 +728,8 @@ typedef struct drm_device {
int need_reset; /**< secondary device needing reset */
struct drm_driver_fn fn_tbl;
+ drm_local_map_t *agp_buffer_map;
+ int dev_priv_size;
} drm_device_t;
extern void DRM(driver_register_fns)(struct drm_device *dev);
diff --git a/linux/drm_bufs.h b/linux/drm_bufs.h
index ef7c37567..3c0d57179 100644
--- a/linux/drm_bufs.h
+++ b/linux/drm_bufs.h
@@ -45,18 +45,6 @@
#define __HAVE_SG 0
#endif
-#ifndef DRIVER_BUF_PRIV_T
-#define DRIVER_BUF_PRIV_T u32
-#endif
-#ifndef DRIVER_AGP_BUFFERS_MAP
-#if __HAVE_AGP && __HAVE_DMA
-#error "You must define DRIVER_AGP_BUFFERS_MAP()"
-#else
-#define DRIVER_AGP_BUFFERS_MAP( dev ) NULL
-#endif
-#endif
-
-
/**
* Compute size order. Returns the exponent of the smaller power of two which
* is greater or equal to given number.
@@ -474,8 +462,8 @@ int DRM(addbufs_agp)( struct inode *inode, struct file *filp,
init_waitqueue_head( &buf->dma_wait );
buf->filp = NULL;
- buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
- buf->dev_private = DRM(alloc)( sizeof(DRIVER_BUF_PRIV_T),
+ buf->dev_priv_size = dev->dev_priv_size;
+ buf->dev_private = DRM(alloc)( buf->dev_priv_size,
DRM_MEM_BUFS );
if(!buf->dev_private) {
/* Set count correctly so we free the proper amount. */
@@ -699,8 +687,8 @@ int DRM(addbufs_pci)( struct inode *inode, struct file *filp,
init_waitqueue_head( &buf->dma_wait );
buf->filp = NULL;
- buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
- buf->dev_private = DRM(alloc)( sizeof(DRIVER_BUF_PRIV_T),
+ buf->dev_priv_size = dev->dev_priv_size;
+ buf->dev_private = DRM(alloc)( dev->dev_priv_size,
DRM_MEM_BUFS );
if(!buf->dev_private) {
/* Set count correctly so we free the proper amount. */
@@ -883,8 +871,8 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
init_waitqueue_head( &buf->dma_wait );
buf->filp = NULL;
- buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
- buf->dev_private = DRM(alloc)( sizeof(DRIVER_BUF_PRIV_T),
+ buf->dev_priv_size = dev->dev_priv_size;
+ buf->dev_private = DRM(alloc)( dev->dev_priv_size,
DRM_MEM_BUFS );
if(!buf->dev_private) {
/* Set count correctly so we free the proper amount. */
@@ -1222,7 +1210,7 @@ int DRM(mapbufs)( struct inode *inode, struct file *filp,
if ( request.count >= dma->buf_count ) {
if ( (__HAVE_AGP && (dma->flags & _DRM_DMA_USE_AGP)) ||
(__HAVE_SG && (dma->flags & _DRM_DMA_USE_SG)) ) {
- drm_map_t *map = DRIVER_AGP_BUFFERS_MAP( dev );
+ drm_map_t *map = dev->agp_buffer_map;
if ( !map ) {
retcode = -EINVAL;
diff --git a/linux/drm_context.h b/linux/drm_context.h
index 8795198a5..dd280e53b 100644
--- a/linux/drm_context.h
+++ b/linux/drm_context.h
@@ -420,10 +420,13 @@ int DRM(addctx)( struct inode *inode, struct file *filp,
/* Should this return -EBUSY instead? */
return -ENOMEM;
}
-#ifdef DRIVER_CTX_CTOR
+
if ( ctx.handle != DRM_KERNEL_CONTEXT )
- DRIVER_CTX_CTOR(ctx.handle); /* XXX: also pass dev ? */
-#endif
+ {
+ if (dev->fn_tbl.context_ctor)
+ dev->fn_tbl.context_ctor(dev, ctx.handle);
+ }
+
ctx_entry = DRM(alloc)( sizeof(*ctx_entry), DRM_MEM_CTXLIST );
if ( !ctx_entry ) {
DRM_DEBUG("out of memory\n");
@@ -555,9 +558,8 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
priv->remove_auth_on_close = 1;
}
if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
-#ifdef DRIVER_CTX_DTOR
- DRIVER_CTX_DTOR(ctx.handle); /* XXX: also pass dev ? */
-#endif
+ if (dev->fn_tbl.context_ctor)
+ dev->fn_tbl.context_ctor(dev, ctx.handle);
DRM(ctxbitmap_free)( dev, ctx.handle );
}
diff --git a/linux/drm_drv.h b/linux/drm_drv.h
index a7ca103e7..5ce302e38 100644
--- a/linux/drm_drv.h
+++ b/linux/drm_drv.h
@@ -76,13 +76,6 @@
#ifndef __HAVE_SG
#define __HAVE_SG 0
#endif
-/* __HAVE_KERNEL_CTX_SWITCH isn't used by any of the drm modules in
- * the DRI cvs tree, but it is required by the kernel tree's sparc
- * driver.
- */
-#ifndef __HAVE_KERNEL_CTX_SWITCH
-#define __HAVE_KERNEL_CTX_SWITCH 0
-#endif
#ifndef __HAVE_DRIVER_FOPS_READ
#define __HAVE_DRIVER_FOPS_READ 0
#endif
@@ -286,9 +279,6 @@ static int DRM(setup)( drm_device_t *dev )
#ifdef __HAVE_COUNTER14
dev->types[14] = __HAVE_COUNTER14;
#endif
-#ifdef __HAVE_COUNTER15
- dev->types[14] = __HAVE_COUNTER14;
-#endif
for ( i = 0 ; i < DRM_ARRAY_SIZE(dev->counts) ; i++ )
atomic_set( &dev->counts[i], 0 );
@@ -566,7 +556,9 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->pci_slot = PCI_SLOT(pdev->devfn);
dev->pci_func = PCI_FUNC(pdev->devfn);
dev->irq = pdev->irq;
-
+
+ /* dev_priv_size can be changed by a driver in driver_register_fns */
+ dev->dev_priv_size = sizeof(u32);
DRM(driver_register_fns)(dev);
if (dev->fn_tbl.preinit)
@@ -957,9 +949,8 @@ int DRM(release)( struct inode *inode, struct file *filp )
list_for_each_entry_safe( pos, n, &dev->ctxlist->head, head ) {
if ( pos->tag == priv &&
pos->handle != DRM_KERNEL_CONTEXT ) {
-#ifdef DRIVER_CTX_DTOR
- DRIVER_CTX_DTOR(pos->handle);
-#endif
+ 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
@@ -1166,16 +1157,11 @@ int DRM(lock)( struct inode *inode, struct file *filp,
if ( dev->fn_tbl.dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT ))
return dev->fn_tbl.dma_quiescent(dev);
- /* __HAVE_KERNEL_CTX_SWITCH isn't used by any of the
- * drm modules in the DRI cvs tree, but it is required
- * by the Sparc driver.
- */
-#if __HAVE_KERNEL_CTX_SWITCH
- if ( dev->last_context != lock.context ) {
- DRM(context_switch)(dev, dev->last_context,
- lock.context);
+
+ if ( dev->fn_tbl.kernel_context_switch && dev->last_context != lock.context ) {
+ dev->fn_tbl.kernel_context_switch(dev, dev->last_context,
+ lock.context);
}
-#endif
}
DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );
@@ -1212,40 +1198,21 @@ int DRM(unlock)( struct inode *inode, struct file *filp,
atomic_inc( &dev->counts[_DRM_STAT_UNLOCKS] );
- /* __HAVE_KERNEL_CTX_SWITCH isn't used by any of the drm
- * modules in the DRI cvs tree, but it is required by the
- * Sparc driver.
- */
-#if __HAVE_KERNEL_CTX_SWITCH
- /* We no longer really hold it, but if we are the next
- * agent to request it then we should just be able to
- * take it immediately and not eat the ioctl.
- */
- dev->lock.filp = 0;
+ if (dev->fn_tbl.kernel_context_switch_unlock)
+ dev->fn_tbl.kernel_context_switch_unlock(dev);
+ else
{
- __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);
-#else
- DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT );
+ DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT );
#if __HAVE_DMA_SCHEDULE
- DRM(dma_schedule)( dev, 1 );
+ DRM(dma_schedule)( dev, 1 );
#endif
- if ( DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT ) ) {
- DRM_ERROR( "\n" );
+ if ( DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT ) ) {
+ DRM_ERROR( "\n" );
+ }
}
-#endif /* !__HAVE_KERNEL_CTX_SWITCH */
unblock_all_signals();
return 0;
diff --git a/linux/ffb.h b/linux/ffb.h
index 179338f63..3691c8652 100644
--- a/linux/ffb.h
+++ b/linux/ffb.h
@@ -8,9 +8,5 @@
*/
#define DRM(x) ffb_##x
-/* General customization:
- */
-#define __HAVE_KERNEL_CTX_SWITCH 1
-
#endif
diff --git a/linux/ffb_context.c b/linux/ffb_context.c
index bb5ba6e4b..7960d04ef 100644
--- a/linux/ffb_context.c
+++ b/linux/ffb_context.c
@@ -570,10 +570,29 @@ 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)
{
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;
}
diff --git a/linux/gamma.h b/linux/gamma.h
index 401f6e848..4e5c72b96 100644
--- a/linux/gamma.h
+++ b/linux/gamma.h
@@ -85,8 +85,4 @@
#define __HAVE_IRQ 1
#define __HAVE_IRQ_BH 1
-#define DRIVER_AGP_BUFFERS_MAP( dev ) \
- ((drm_gamma_private_t *)((dev)->dev_private))->buffers
-
-
#endif /* __GAMMA_H__ */
diff --git a/linux/gamma_dma.c b/linux/gamma_dma.c
index eaabb84c3..30ff73785 100644
--- a/linux/gamma_dma.c
+++ b/linux/gamma_dma.c
@@ -668,9 +668,9 @@ static int gamma_do_init_dma( drm_device_t *dev, drm_gamma_init_t *init )
buf = dma->buflist[GLINT_DRI_BUF_COUNT];
} else {
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
- DRM_IOREMAP( dev_priv->buffers, dev );
+ DRM_IOREMAP( dev->agp_buffer_map, dev );
buf = dma->buflist[GLINT_DRI_BUF_COUNT];
pgt = buf->address;
@@ -706,10 +706,9 @@ int gamma_do_cleanup_dma( drm_device_t *dev )
#endif
if ( dev->dev_private ) {
- drm_gamma_private_t *dev_priv = dev->dev_private;
- if ( dev_priv->buffers != NULL )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ if ( dev->agp_buffer_map != NULL )
+ DRM_IOREMAPFREE( dev->agp_buffer_map, dev );
DRM(free)( dev->dev_private, sizeof(drm_gamma_private_t),
DRM_MEM_DRIVER );
diff --git a/linux/gamma_drv.h b/linux/gamma_drv.h
index fc78a11a3..bdcd28c60 100644
--- a/linux/gamma_drv.h
+++ b/linux/gamma_drv.h
@@ -35,7 +35,6 @@
typedef struct drm_gamma_private {
drm_gamma_sarea_t *sarea_priv;
drm_map_t *sarea;
- drm_map_t *buffers;
drm_map_t *mmio0;
drm_map_t *mmio1;
drm_map_t *mmio2;
diff --git a/linux/i810.h b/linux/i810.h
index 1abed8303..33403ed6f 100644
--- a/linux/i810.h
+++ b/linux/i810.h
@@ -97,12 +97,4 @@
/* XXX: Add vblank support? */
#define __HAVE_IRQ 0
-/* Buffer customization:
- */
-
-#define DRIVER_BUF_PRIV_T drm_i810_buf_priv_t
-
-#define DRIVER_AGP_BUFFERS_MAP( dev ) \
- ((drm_i810_private_t *)((dev)->dev_private))->buffer_map
-
#endif
diff --git a/linux/i810_dma.c b/linux/i810_dma.c
index f1d5d1f79..b09487e85 100644
--- a/linux/i810_dma.c
+++ b/linux/i810_dma.c
@@ -378,8 +378,8 @@ static int i810_dma_initialize(drm_device_t *dev,
DRM_ERROR("can not find mmio map!\n");
return -EINVAL;
}
- DRM_FIND_MAP( dev_priv->buffer_map, init->buffers_offset );
- if (!dev_priv->buffer_map) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if (!dev->agp_buffer_map) {
dev->dev_private = (void *)dev_priv;
i810_dma_cleanup(dev);
DRM_ERROR("can not find dma buffer map!\n");
@@ -1413,6 +1413,7 @@ static int i810_driver_dma_quiescent(drm_device_t *dev)
void i810_driver_register_fns(drm_device_t *dev)
{
+ 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;
diff --git a/linux/i810_drv.h b/linux/i810_drv.h
index 736c20d76..67c5c88bf 100644
--- a/linux/i810_drv.h
+++ b/linux/i810_drv.h
@@ -53,7 +53,6 @@ typedef struct _drm_i810_ring_buffer{
typedef struct drm_i810_private {
drm_map_t *sarea_map;
- drm_map_t *buffer_map;
drm_map_t *mmio_map;
drm_i810_sarea_t *sarea_priv;
diff --git a/linux/i830.h b/linux/i830.h
index 8750783f6..694baa1e9 100644
--- a/linux/i830.h
+++ b/linux/i830.h
@@ -104,13 +104,4 @@
#define __HAVE_IRQ 0
#endif
-
-/* Buffer customization:
- */
-
-#define DRIVER_BUF_PRIV_T drm_i830_buf_priv_t
-
-#define DRIVER_AGP_BUFFERS_MAP( dev ) \
- ((drm_i830_private_t *)((dev)->dev_private))->buffer_map
-
#endif
diff --git a/linux/i830_dma.c b/linux/i830_dma.c
index 9791b97d0..220056046 100644
--- a/linux/i830_dma.c
+++ b/linux/i830_dma.c
@@ -385,8 +385,8 @@ static int i830_dma_initialize(drm_device_t *dev,
DRM_ERROR("can not find mmio map!\n");
return -EINVAL;
}
- DRM_FIND_MAP( dev_priv->buffer_map, init->buffers_offset );
- if(!dev_priv->buffer_map) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if(!dev->agp_buffer_map) {
dev->dev_private = (void *)dev_priv;
i830_dma_cleanup(dev);
DRM_ERROR("can not find dma buffer map!\n");
@@ -1609,6 +1609,7 @@ static int i830_driver_dma_quiescent(drm_device_t *dev)
void i830_driver_register_fns(drm_device_t *dev)
{
+ 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;
diff --git a/linux/i830_drv.h b/linux/i830_drv.h
index c6d805fc7..ad4de4c3b 100644
--- a/linux/i830_drv.h
+++ b/linux/i830_drv.h
@@ -53,7 +53,6 @@ typedef struct _drm_i830_ring_buffer{
typedef struct drm_i830_private {
drm_map_t *sarea_map;
- drm_map_t *buffer_map;
drm_map_t *mmio_map;
drm_i830_sarea_t *sarea_priv;
diff --git a/linux/sis_drv.c b/linux/sis_drv.c
index 4652e3406..fce5470b9 100644
--- a/linux/sis_drv.c
+++ b/linux/sis_drv.c
@@ -47,6 +47,4 @@
#include "drm_vm.h"
#include "drm_stub.h"
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
-}
+
diff --git a/shared-core/mach64_dma.c b/shared-core/mach64_dma.c
index acb6690fa..bafbdc407 100644
--- a/shared-core/mach64_dma.c
+++ b/shared-core/mach64_dma.c
@@ -690,15 +690,19 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
mach64_do_cleanup_dma( dev );
return DRM_ERR(ENOMEM);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if ( !dev_priv->buffers ) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if ( !dev->agp_buffer_map ) {
DRM_ERROR( "can not find dma buffer map!\n" );
dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma( dev );
return DRM_ERR(EINVAL);
}
- DRM_IOREMAP( dev_priv->buffers, dev );
- if ( !dev_priv->buffers->handle ) {
+ /* there might be a nicer way to do this -
+ dev isn't passed all the way though the mach64 - DA */
+ dev_priv->dev_buffers = dev->agp_buffer_map;
+
+ DRM_IOREMAP( dev->agp_buffer_map, dev );
+ if ( !dev->agp_buffer_map->handle ) {
DRM_ERROR( "can not ioremap virtual address for"
" dma buffer\n" );
dev->dev_private = (void *) dev_priv;
@@ -990,8 +994,8 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
DRM_IOREMAPFREE( dev_priv->ring_map, dev );
}
- if ( dev_priv->buffers )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ if ( dev->agp_buffer_map )
+ DRM_IOREMAPFREE( dev->agp_buffer_map, dev );
mach64_destroy_freelist( dev );
diff --git a/shared-core/mach64_drv.h b/shared-core/mach64_drv.h
index 4331cde57..d009d29e6 100644
--- a/shared-core/mach64_drv.h
+++ b/shared-core/mach64_drv.h
@@ -92,7 +92,7 @@ typedef struct drm_mach64_private {
drm_local_map_t *fb;
drm_local_map_t *mmio;
drm_local_map_t *ring_map;
- drm_local_map_t *buffers;
+ drm_local_map_t *dev_buffers; /* this is a pointer to a structure in dev */
drm_local_map_t *agp_textures;
} drm_mach64_private_t;
@@ -791,7 +791,7 @@ do { \
#define GETBUFPTR( __buf ) \
((dev_priv->is_pci) ? \
((u32 *)(__buf)->address) : \
- ((u32 *)((char *)dev_priv->buffers->handle + (__buf)->offset)))
+ ((u32 *)((char *)dev_priv->dev_buffers->handle + (__buf)->offset)))
#define GETBUFADDR( __buf ) ((u32)(__buf)->bus_address)
diff --git a/shared-core/mga_dma.c b/shared-core/mga_dma.c
index fafd42efe..7854a1d20 100644
--- a/shared-core/mga_dma.c
+++ b/shared-core/mga_dma.c
@@ -533,8 +533,8 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
mga_do_cleanup_dma( dev );
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if(!dev_priv->buffers) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if(!dev->agp_buffer_map) {
DRM_ERROR( "failed to find dma buffer region!\n" );
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
@@ -548,11 +548,11 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
DRM_IOREMAP( dev_priv->warp, dev );
DRM_IOREMAP( dev_priv->primary, dev );
- DRM_IOREMAP( dev_priv->buffers, dev );
+ DRM_IOREMAP( dev->agp_buffer_map, dev );
if(!dev_priv->warp->handle ||
!dev_priv->primary->handle ||
- !dev_priv->buffers->handle ) {
+ !dev->agp_buffer_map->handle ) {
DRM_ERROR( "failed to ioremap agp regions!\n" );
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
@@ -646,8 +646,8 @@ int mga_do_cleanup_dma( drm_device_t *dev )
DRM_IOREMAPFREE( dev_priv->warp, dev );
if ( dev_priv->primary != NULL )
DRM_IOREMAPFREE( dev_priv->primary, dev );
- if ( dev_priv->buffers != NULL )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ if ( dev->agp_buffer_map != NULL )
+ DRM_IOREMAPFREE( dev->agp_buffer_map, dev );
if ( dev_priv->head != NULL ) {
mga_freelist_cleanup( dev );
diff --git a/shared-core/r128_cce.c b/shared-core/r128_cce.c
index 22d38b70c..83612e571 100644
--- a/shared-core/r128_cce.c
+++ b/shared-core/r128_cce.c
@@ -488,8 +488,8 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
r128_do_cleanup_cce( dev );
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if(!dev_priv->buffers) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if(!dev->agp_buffer_map) {
DRM_ERROR("could not find dma buffer region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
@@ -515,10 +515,10 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
if ( !dev_priv->is_pci ) {
DRM_IOREMAP( dev_priv->cce_ring, dev );
DRM_IOREMAP( dev_priv->ring_rptr, dev );
- DRM_IOREMAP( dev_priv->buffers, dev );
+ DRM_IOREMAP( dev->agp_buffer_map, dev );
if(!dev_priv->cce_ring->handle ||
!dev_priv->ring_rptr->handle ||
- !dev_priv->buffers->handle) {
+ !dev->agp_buffer_map->handle) {
DRM_ERROR("Could not ioremap agp regions!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
@@ -531,7 +531,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
(void *)dev_priv->cce_ring->offset;
dev_priv->ring_rptr->handle =
(void *)dev_priv->ring_rptr->offset;
- dev_priv->buffers->handle = (void *)dev_priv->buffers->offset;
+ dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset;
}
#if __REALLY_HAVE_AGP
@@ -604,8 +604,8 @@ int r128_do_cleanup_cce( drm_device_t *dev )
DRM_IOREMAPFREE( dev_priv->cce_ring, dev );
if ( dev_priv->ring_rptr != NULL )
DRM_IOREMAPFREE( dev_priv->ring_rptr, dev );
- if ( dev_priv->buffers != NULL )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ if ( dev->agp_buffer_map != NULL )
+ DRM_IOREMAPFREE( dev->agp_buffer_map, dev );
} else
#endif
{
diff --git a/shared-core/r128_drv.h b/shared-core/r128_drv.h
index 9df32e566..12ca9b4f5 100644
--- a/shared-core/r128_drv.h
+++ b/shared-core/r128_drv.h
@@ -100,7 +100,6 @@ typedef struct drm_r128_private {
drm_local_map_t *mmio;
drm_local_map_t *cce_ring;
drm_local_map_t *ring_rptr;
- drm_local_map_t *buffers;
drm_local_map_t *agp_textures;
} drm_r128_private_t;
diff --git a/shared-core/r128_state.c b/shared-core/r128_state.c
index 76b0593bc..88d7715a9 100644
--- a/shared-core/r128_state.c
+++ b/shared-core/r128_state.c
@@ -667,7 +667,7 @@ static void r128_cce_dispatch_indirect( drm_device_t *dev,
*/
if ( dwords & 1 ) {
u32 *data = (u32 *)
- ((char *)dev_priv->buffers->handle
+ ((char *)dev->agp_buffer_map->handle
+ buf->offset + start);
data[dwords++] = cpu_to_le32( R128_CCE_PACKET2 );
}
@@ -713,7 +713,7 @@ static void r128_cce_dispatch_indices( drm_device_t *dev,
drm_r128_buf_priv_t *buf_priv = buf->dev_private;
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
int format = sarea_priv->vc_format;
- int offset = dev_priv->buffers->offset - dev_priv->cce_buffers_offset;
+ int offset = dev->agp_buffer_map->offset - dev_priv->cce_buffers_offset;
int prim = buf_priv->prim;
u32 *data;
int dwords;
@@ -733,7 +733,7 @@ static void r128_cce_dispatch_indices( drm_device_t *dev,
dwords = (end - start + 3) / sizeof(u32);
- data = (u32 *)((char *)dev_priv->buffers->handle
+ data = (u32 *)((char *)dev->agp_buffer_map->handle
+ buf->offset + start);
data[0] = cpu_to_le32( CCE_PACKET3( R128_3D_RNDR_GEN_INDX_PRIM,
@@ -857,7 +857,7 @@ static int r128_cce_dispatch_blit( DRMFILE filp,
dwords = (blit->width * blit->height) >> dword_shift;
- data = (u32 *)((char *)dev_priv->buffers->handle + buf->offset);
+ data = (u32 *)((char *)dev->agp_buffer_map->handle + buf->offset);
data[0] = cpu_to_le32( CCE_PACKET3( R128_CNTL_HOSTDATA_BLT, dwords + 6 ) );
data[1] = cpu_to_le32( (R128_GMC_DST_PITCH_OFFSET_CNTL |
@@ -1712,6 +1712,7 @@ static void r128_driver_pretakedown(drm_device_t *dev)
void r128_driver_register_fns(drm_device_t *dev)
{
+ dev->dev_priv_size = sizeof(drm_r128_buf_priv_t);
dev->fn_tbl.prerelease = r128_driver_prerelease;
dev->fn_tbl.pretakedown = r128_driver_pretakedown;
}
diff --git a/shared-core/radeon_cp.c b/shared-core/radeon_cp.c
index f6964908a..1c172b282 100644
--- a/shared-core/radeon_cp.c
+++ b/shared-core/radeon_cp.c
@@ -1139,8 +1139,8 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
radeon_do_cleanup_cp(dev);
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if(!dev_priv->buffers) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if(!dev->agp_buffer_map) {
DRM_ERROR("could not find dma buffer region!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
@@ -1165,10 +1165,10 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
if ( !dev_priv->is_pci ) {
DRM_IOREMAP( dev_priv->cp_ring, dev );
DRM_IOREMAP( dev_priv->ring_rptr, dev );
- DRM_IOREMAP( dev_priv->buffers, dev );
+ DRM_IOREMAP( dev->agp_buffer_map, dev );
if(!dev_priv->cp_ring->handle ||
!dev_priv->ring_rptr->handle ||
- !dev_priv->buffers->handle) {
+ !dev->agp_buffer_map->handle) {
DRM_ERROR("could not find ioremap agp regions!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
@@ -1181,14 +1181,14 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
(void *)dev_priv->cp_ring->offset;
dev_priv->ring_rptr->handle =
(void *)dev_priv->ring_rptr->offset;
- dev_priv->buffers->handle = (void *)dev_priv->buffers->offset;
+ dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset;
DRM_DEBUG( "dev_priv->cp_ring->handle %p\n",
dev_priv->cp_ring->handle );
DRM_DEBUG( "dev_priv->ring_rptr->handle %p\n",
dev_priv->ring_rptr->handle );
- DRM_DEBUG( "dev_priv->buffers->handle %p\n",
- dev_priv->buffers->handle );
+ DRM_DEBUG( "dev->agp_buffer_map->handle %p\n",
+ dev->agp_buffer_map->handle );
}
dev_priv->fb_location = ( RADEON_READ( RADEON_MC_FB_LOCATION )
@@ -1213,12 +1213,12 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
#if __REALLY_HAVE_AGP
if ( !dev_priv->is_pci )
- dev_priv->gart_buffers_offset = (dev_priv->buffers->offset
+ dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
- dev->agp->base
+ dev_priv->gart_vm_start);
else
#endif
- dev_priv->gart_buffers_offset = (dev_priv->buffers->offset
+ dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
- dev->sg->handle
+ dev_priv->gart_vm_start);
@@ -1292,8 +1292,8 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
DRM_IOREMAPFREE( dev_priv->cp_ring, dev );
if ( dev_priv->ring_rptr != NULL )
DRM_IOREMAPFREE( dev_priv->ring_rptr, dev );
- if ( dev_priv->buffers != NULL )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ if ( dev->agp_buffer_map != NULL )
+ DRM_IOREMAPFREE( dev->agp_buffer_map, dev );
} else
#endif
{
diff --git a/shared-core/radeon_drv.h b/shared-core/radeon_drv.h
index e24e0ec09..f0aa0dc23 100644
--- a/shared-core/radeon_drv.h
+++ b/shared-core/radeon_drv.h
@@ -138,7 +138,6 @@ typedef struct drm_radeon_private {
drm_local_map_t *mmio;
drm_local_map_t *cp_ring;
drm_local_map_t *ring_rptr;
- drm_local_map_t *buffers;
drm_local_map_t *gart_textures;
struct mem_block *gart_heap;
diff --git a/shared-core/radeon_state.c b/shared-core/radeon_state.c
index 659f9e9da..57274174d 100644
--- a/shared-core/radeon_state.c
+++ b/shared-core/radeon_state.c
@@ -1247,7 +1247,7 @@ static void radeon_cp_dispatch_indirect( drm_device_t *dev,
*/
if ( dwords & 1 ) {
u32 *data = (u32 *)
- ((char *)dev_priv->buffers->handle
+ ((char *)dev->agp_buffer_map->handle
+ buf->offset + start);
data[dwords++] = RADEON_CP_PACKET2;
}
@@ -1301,7 +1301,7 @@ static void radeon_cp_dispatch_indices( drm_device_t *dev,
dwords = (prim->finish - prim->start + 3) / sizeof(u32);
- data = (u32 *)((char *)dev_priv->buffers->handle +
+ data = (u32 *)((char *)dev->agp_buffer_map->handle +
elt_buf->offset + prim->start);
data[0] = CP_PACKET3( RADEON_3D_RNDR_GEN_INDX_PRIM, dwords-2 );
@@ -1445,7 +1445,7 @@ static int radeon_cp_dispatch_texture( DRMFILE filp,
/* Dispatch the indirect buffer.
*/
- buffer = (u32*)((char*)dev_priv->buffers->handle + buf->offset);
+ buffer = (u32*)((char*)dev->agp_buffer_map->handle + buf->offset);
dwords = size / 4;
buffer[0] = CP_PACKET3( RADEON_CNTL_HOSTDATA_BLT, dwords + 6 );
buffer[1] = (RADEON_GMC_DST_PITCH_OFFSET_CNTL |
@@ -2548,7 +2548,13 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
return 0;
}
-static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE *filp)
+/* When a client dies:
+ * - Check for and clean up flipped page state
+ * - Free any alloced GART memory.
+ *
+ * DRM infrastructure takes care of reclaiming dma buffers.
+ */
+static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -2576,6 +2582,7 @@ static void radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
void radeon_driver_register_fns(struct drm_device *dev)
{
+ dev->dev_priv_size = sizeof(drm_radeon_buf_priv_t);
dev->fn_tbl.prerelease = radeon_driver_prerelease;
dev->fn_tbl.pretakedown = radeon_driver_pretakedown;
dev->fn_tbl.open_helper = radeon_driver_open_helper;
diff --git a/shared-core/sis_drv.h b/shared-core/sis_drv.h
index 40e7f463e..a87001819 100644
--- a/shared-core/sis_drv.h
+++ b/shared-core/sis_drv.h
@@ -31,8 +31,6 @@
#include "sis_ds.h"
typedef struct drm_sis_private {
- drm_map_t *buffers;
-
memHeap_t *AGPHeap;
memHeap_t *FBHeap;
} drm_sis_private_t;
diff --git a/shared-core/sis_mm.c b/shared-core/sis_mm.c
index 9b6311a91..233843d5d 100644
--- a/shared-core/sis_mm.c
+++ b/shared-core/sis_mm.c
@@ -330,7 +330,7 @@ int sis_ioctl_agp_free( DRM_IOCTL_ARGS )
return 0;
}
-int sis_init_context(int context)
+int sis_init_context(struct drm_device *dev, int context)
{
int i;
@@ -362,7 +362,7 @@ int sis_init_context(int context)
return 1;
}
-int sis_final_context(int context)
+int sis_final_context(struct drm_device *dev, int context)
{
int i;
@@ -408,3 +408,9 @@ int sis_final_context(int context)
return 1;
}
+
+void DRM(driver_register_fns)(drm_device_t *dev)
+{
+ dev->fn_tbl.context_ctor = sis_init_context;
+ dev->fn_tbl.context_dtor = sis_final_context;
+}
diff --git a/shared-core/via_drv.c b/shared-core/via_drv.c
index cd8bdf001..ad4903bb9 100644
--- a/shared-core/via_drv.c
+++ b/shared-core/via_drv.c
@@ -66,6 +66,3 @@
#include "drm_vm.h"
#include "drm_stub.h"
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
-}
diff --git a/shared-core/via_drv.h b/shared-core/via_drv.h
index 1eafc95fe..ee3852c35 100644
--- a/shared-core/via_drv.h
+++ b/shared-core/via_drv.h
@@ -33,7 +33,6 @@ typedef struct drm_via_private {
drm_map_t *fb;
drm_map_t *mmio;
unsigned long agpAddr;
- drm_map_t *buffers;
wait_queue_head_t decoder_queue[VIA_NR_XVMC_LOCKS];
} drm_via_private_t;
diff --git a/shared-core/via_mm.c b/shared-core/via_mm.c
index 1bf04fe02..be6184caf 100644
--- a/shared-core/via_mm.c
+++ b/shared-core/via_mm.c
@@ -103,7 +103,7 @@ int via_fb_init( DRM_IOCTL_ARGS )
return 0;
}
-int via_init_context(int context)
+int via_init_context(struct drm_device *dev, int context)
{
int i;
@@ -134,7 +134,7 @@ int via_init_context(int context)
return 1;
}
-int via_final_context(int context)
+int via_final_context(struct drm_device *dev, int context)
{
int i;
for (i=0; i<MAX_CONTEXT; i++)
@@ -345,3 +345,9 @@ int via_agp_free(drm_via_mem_t* mem)
EXPORT_SYMBOL(via_fb_alloc);
EXPORT_SYMBOL(via_fb_free);
+
+void DRM(driver_register_fns)(drm_device_t *dev)
+{
+ dev->fn_tbl.context_ctor = via_init_context;
+ dev->fn_tbl.context_dtor = via_final_context;
+}
diff --git a/shared/mach64.h b/shared/mach64.h
index 9ed5a7fac..6cfb786e1 100644
--- a/shared/mach64.h
+++ b/shared/mach64.h
@@ -79,10 +79,4 @@
#define __HAVE_SHARED_IRQ 1
#define __HAVE_IRQ 1
-/* Buffer customization:
- */
-
-#define DRIVER_AGP_BUFFERS_MAP( dev ) \
- ((drm_mach64_private_t *)((dev)->dev_private))->buffers
-
#endif
diff --git a/shared/mach64_dma.c b/shared/mach64_dma.c
index acb6690fa..bafbdc407 100644
--- a/shared/mach64_dma.c
+++ b/shared/mach64_dma.c
@@ -690,15 +690,19 @@ static int mach64_do_dma_init( drm_device_t *dev, drm_mach64_init_t *init )
mach64_do_cleanup_dma( dev );
return DRM_ERR(ENOMEM);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if ( !dev_priv->buffers ) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if ( !dev->agp_buffer_map ) {
DRM_ERROR( "can not find dma buffer map!\n" );
dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma( dev );
return DRM_ERR(EINVAL);
}
- DRM_IOREMAP( dev_priv->buffers, dev );
- if ( !dev_priv->buffers->handle ) {
+ /* there might be a nicer way to do this -
+ dev isn't passed all the way though the mach64 - DA */
+ dev_priv->dev_buffers = dev->agp_buffer_map;
+
+ DRM_IOREMAP( dev->agp_buffer_map, dev );
+ if ( !dev->agp_buffer_map->handle ) {
DRM_ERROR( "can not ioremap virtual address for"
" dma buffer\n" );
dev->dev_private = (void *) dev_priv;
@@ -990,8 +994,8 @@ int mach64_do_cleanup_dma( drm_device_t *dev )
DRM_IOREMAPFREE( dev_priv->ring_map, dev );
}
- if ( dev_priv->buffers )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ if ( dev->agp_buffer_map )
+ DRM_IOREMAPFREE( dev->agp_buffer_map, dev );
mach64_destroy_freelist( dev );
diff --git a/shared/mach64_drv.h b/shared/mach64_drv.h
index 4331cde57..d009d29e6 100644
--- a/shared/mach64_drv.h
+++ b/shared/mach64_drv.h
@@ -92,7 +92,7 @@ typedef struct drm_mach64_private {
drm_local_map_t *fb;
drm_local_map_t *mmio;
drm_local_map_t *ring_map;
- drm_local_map_t *buffers;
+ drm_local_map_t *dev_buffers; /* this is a pointer to a structure in dev */
drm_local_map_t *agp_textures;
} drm_mach64_private_t;
@@ -791,7 +791,7 @@ do { \
#define GETBUFPTR( __buf ) \
((dev_priv->is_pci) ? \
((u32 *)(__buf)->address) : \
- ((u32 *)((char *)dev_priv->buffers->handle + (__buf)->offset)))
+ ((u32 *)((char *)dev_priv->dev_buffers->handle + (__buf)->offset)))
#define GETBUFADDR( __buf ) ((u32)(__buf)->bus_address)
diff --git a/shared/mga.h b/shared/mga.h
index 09396cbd3..f2813846b 100644
--- a/shared/mga.h
+++ b/shared/mga.h
@@ -76,11 +76,4 @@
#define __HAVE_VBL_IRQ 1
#define __HAVE_SHARED_IRQ 1
-/* Buffer customization:
- */
-#define DRIVER_BUF_PRIV_T drm_mga_buf_priv_t
-
-#define DRIVER_AGP_BUFFERS_MAP( dev ) \
- ((drm_mga_private_t *)((dev)->dev_private))->buffers
-
#endif
diff --git a/shared/mga_dma.c b/shared/mga_dma.c
index fafd42efe..7854a1d20 100644
--- a/shared/mga_dma.c
+++ b/shared/mga_dma.c
@@ -533,8 +533,8 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
mga_do_cleanup_dma( dev );
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if(!dev_priv->buffers) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if(!dev->agp_buffer_map) {
DRM_ERROR( "failed to find dma buffer region!\n" );
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
@@ -548,11 +548,11 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
DRM_IOREMAP( dev_priv->warp, dev );
DRM_IOREMAP( dev_priv->primary, dev );
- DRM_IOREMAP( dev_priv->buffers, dev );
+ DRM_IOREMAP( dev->agp_buffer_map, dev );
if(!dev_priv->warp->handle ||
!dev_priv->primary->handle ||
- !dev_priv->buffers->handle ) {
+ !dev->agp_buffer_map->handle ) {
DRM_ERROR( "failed to ioremap agp regions!\n" );
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
@@ -646,8 +646,8 @@ int mga_do_cleanup_dma( drm_device_t *dev )
DRM_IOREMAPFREE( dev_priv->warp, dev );
if ( dev_priv->primary != NULL )
DRM_IOREMAPFREE( dev_priv->primary, dev );
- if ( dev_priv->buffers != NULL )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ if ( dev->agp_buffer_map != NULL )
+ DRM_IOREMAPFREE( dev->agp_buffer_map, dev );
if ( dev_priv->head != NULL ) {
mga_freelist_cleanup( dev );
diff --git a/shared/r128.h b/shared/r128.h
index 4be951482..b9d2f87e4 100644
--- a/shared/r128.h
+++ b/shared/r128.h
@@ -87,11 +87,4 @@
#define __HAVE_VBL_IRQ 1
#define __HAVE_SHARED_IRQ 1
-/* Buffer customization:
- */
-#define DRIVER_BUF_PRIV_T drm_r128_buf_priv_t
-
-#define DRIVER_AGP_BUFFERS_MAP( dev ) \
- ((drm_r128_private_t *)((dev)->dev_private))->buffers
-
#endif
diff --git a/shared/r128_cce.c b/shared/r128_cce.c
index 22d38b70c..83612e571 100644
--- a/shared/r128_cce.c
+++ b/shared/r128_cce.c
@@ -488,8 +488,8 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
r128_do_cleanup_cce( dev );
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if(!dev_priv->buffers) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if(!dev->agp_buffer_map) {
DRM_ERROR("could not find dma buffer region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
@@ -515,10 +515,10 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
if ( !dev_priv->is_pci ) {
DRM_IOREMAP( dev_priv->cce_ring, dev );
DRM_IOREMAP( dev_priv->ring_rptr, dev );
- DRM_IOREMAP( dev_priv->buffers, dev );
+ DRM_IOREMAP( dev->agp_buffer_map, dev );
if(!dev_priv->cce_ring->handle ||
!dev_priv->ring_rptr->handle ||
- !dev_priv->buffers->handle) {
+ !dev->agp_buffer_map->handle) {
DRM_ERROR("Could not ioremap agp regions!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
@@ -531,7 +531,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
(void *)dev_priv->cce_ring->offset;
dev_priv->ring_rptr->handle =
(void *)dev_priv->ring_rptr->offset;
- dev_priv->buffers->handle = (void *)dev_priv->buffers->offset;
+ dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset;
}
#if __REALLY_HAVE_AGP
@@ -604,8 +604,8 @@ int r128_do_cleanup_cce( drm_device_t *dev )
DRM_IOREMAPFREE( dev_priv->cce_ring, dev );
if ( dev_priv->ring_rptr != NULL )
DRM_IOREMAPFREE( dev_priv->ring_rptr, dev );
- if ( dev_priv->buffers != NULL )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ if ( dev->agp_buffer_map != NULL )
+ DRM_IOREMAPFREE( dev->agp_buffer_map, dev );
} else
#endif
{
diff --git a/shared/r128_drv.h b/shared/r128_drv.h
index 9df32e566..12ca9b4f5 100644
--- a/shared/r128_drv.h
+++ b/shared/r128_drv.h
@@ -100,7 +100,6 @@ typedef struct drm_r128_private {
drm_local_map_t *mmio;
drm_local_map_t *cce_ring;
drm_local_map_t *ring_rptr;
- drm_local_map_t *buffers;
drm_local_map_t *agp_textures;
} drm_r128_private_t;
diff --git a/shared/r128_state.c b/shared/r128_state.c
index 76b0593bc..88d7715a9 100644
--- a/shared/r128_state.c
+++ b/shared/r128_state.c
@@ -667,7 +667,7 @@ static void r128_cce_dispatch_indirect( drm_device_t *dev,
*/
if ( dwords & 1 ) {
u32 *data = (u32 *)
- ((char *)dev_priv->buffers->handle
+ ((char *)dev->agp_buffer_map->handle
+ buf->offset + start);
data[dwords++] = cpu_to_le32( R128_CCE_PACKET2 );
}
@@ -713,7 +713,7 @@ static void r128_cce_dispatch_indices( drm_device_t *dev,
drm_r128_buf_priv_t *buf_priv = buf->dev_private;
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
int format = sarea_priv->vc_format;
- int offset = dev_priv->buffers->offset - dev_priv->cce_buffers_offset;
+ int offset = dev->agp_buffer_map->offset - dev_priv->cce_buffers_offset;
int prim = buf_priv->prim;
u32 *data;
int dwords;
@@ -733,7 +733,7 @@ static void r128_cce_dispatch_indices( drm_device_t *dev,
dwords = (end - start + 3) / sizeof(u32);
- data = (u32 *)((char *)dev_priv->buffers->handle
+ data = (u32 *)((char *)dev->agp_buffer_map->handle
+ buf->offset + start);
data[0] = cpu_to_le32( CCE_PACKET3( R128_3D_RNDR_GEN_INDX_PRIM,
@@ -857,7 +857,7 @@ static int r128_cce_dispatch_blit( DRMFILE filp,
dwords = (blit->width * blit->height) >> dword_shift;
- data = (u32 *)((char *)dev_priv->buffers->handle + buf->offset);
+ data = (u32 *)((char *)dev->agp_buffer_map->handle + buf->offset);
data[0] = cpu_to_le32( CCE_PACKET3( R128_CNTL_HOSTDATA_BLT, dwords + 6 ) );
data[1] = cpu_to_le32( (R128_GMC_DST_PITCH_OFFSET_CNTL |
@@ -1712,6 +1712,7 @@ static void r128_driver_pretakedown(drm_device_t *dev)
void r128_driver_register_fns(drm_device_t *dev)
{
+ dev->dev_priv_size = sizeof(drm_r128_buf_priv_t);
dev->fn_tbl.prerelease = r128_driver_prerelease;
dev->fn_tbl.pretakedown = r128_driver_pretakedown;
}
diff --git a/shared/radeon.h b/shared/radeon.h
index 1dc77a75f..39fb0be90 100644
--- a/shared/radeon.h
+++ b/shared/radeon.h
@@ -118,43 +118,6 @@
#define DRIVER_FILE_FIELDS \
int64_t radeon_fb_delta; \
-#define DRIVER_OPEN_HELPER( filp_priv, dev ) \
-do { \
- drm_radeon_private_t *dev_priv = dev->dev_private; \
- if ( dev_priv ) \
- filp_priv->radeon_fb_delta = dev_priv->fb_location; \
- else \
- filp_priv->radeon_fb_delta = 0; \
-} while( 0 )
-
-/* When a client dies:
- * - Check for and clean up flipped page state
- * - Free any alloced GART memory.
- *
- * DRM infrastructure takes care of reclaiming dma buffers.
- */
-#define DRIVER_PRERELEASE() \
-do { \
- if ( dev->dev_private ) { \
- drm_radeon_private_t *dev_priv = dev->dev_private; \
- if ( dev_priv->page_flipping ) { \
- radeon_do_cleanup_pageflip( dev ); \
- } \
- radeon_mem_release( filp, dev_priv->gart_heap ); \
- radeon_mem_release( filp, dev_priv->fb_heap ); \
- } \
-} while (0)
-
-/* When the last client dies, shut down the CP and free dev->dev_priv.
- */
-#if 0
-#define DRIVER_PRETAKEDOWN( dev ) \
-do { \
- radeon_do_release( dev ); \
-} while (0)
-#endif
-
-
/* DMA customization:
*/
#define __HAVE_DMA 1
@@ -162,12 +125,4 @@ do { \
#define __HAVE_VBL_IRQ 1
#define __HAVE_SHARED_IRQ 1
-
-/* Buffer customization:
- */
-#define DRIVER_BUF_PRIV_T drm_radeon_buf_priv_t
-
-#define DRIVER_AGP_BUFFERS_MAP( dev ) \
- ((drm_radeon_private_t *)((dev)->dev_private))->buffers
-
#endif
diff --git a/shared/radeon_cp.c b/shared/radeon_cp.c
index f6964908a..1c172b282 100644
--- a/shared/radeon_cp.c
+++ b/shared/radeon_cp.c
@@ -1139,8 +1139,8 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
radeon_do_cleanup_cp(dev);
return DRM_ERR(EINVAL);
}
- DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
- if(!dev_priv->buffers) {
+ DRM_FIND_MAP( dev->agp_buffer_map, init->buffers_offset );
+ if(!dev->agp_buffer_map) {
DRM_ERROR("could not find dma buffer region!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
@@ -1165,10 +1165,10 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
if ( !dev_priv->is_pci ) {
DRM_IOREMAP( dev_priv->cp_ring, dev );
DRM_IOREMAP( dev_priv->ring_rptr, dev );
- DRM_IOREMAP( dev_priv->buffers, dev );
+ DRM_IOREMAP( dev->agp_buffer_map, dev );
if(!dev_priv->cp_ring->handle ||
!dev_priv->ring_rptr->handle ||
- !dev_priv->buffers->handle) {
+ !dev->agp_buffer_map->handle) {
DRM_ERROR("could not find ioremap agp regions!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
@@ -1181,14 +1181,14 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
(void *)dev_priv->cp_ring->offset;
dev_priv->ring_rptr->handle =
(void *)dev_priv->ring_rptr->offset;
- dev_priv->buffers->handle = (void *)dev_priv->buffers->offset;
+ dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset;
DRM_DEBUG( "dev_priv->cp_ring->handle %p\n",
dev_priv->cp_ring->handle );
DRM_DEBUG( "dev_priv->ring_rptr->handle %p\n",
dev_priv->ring_rptr->handle );
- DRM_DEBUG( "dev_priv->buffers->handle %p\n",
- dev_priv->buffers->handle );
+ DRM_DEBUG( "dev->agp_buffer_map->handle %p\n",
+ dev->agp_buffer_map->handle );
}
dev_priv->fb_location = ( RADEON_READ( RADEON_MC_FB_LOCATION )
@@ -1213,12 +1213,12 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
#if __REALLY_HAVE_AGP
if ( !dev_priv->is_pci )
- dev_priv->gart_buffers_offset = (dev_priv->buffers->offset
+ dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
- dev->agp->base
+ dev_priv->gart_vm_start);
else
#endif
- dev_priv->gart_buffers_offset = (dev_priv->buffers->offset
+ dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
- dev->sg->handle
+ dev_priv->gart_vm_start);
@@ -1292,8 +1292,8 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
DRM_IOREMAPFREE( dev_priv->cp_ring, dev );
if ( dev_priv->ring_rptr != NULL )
DRM_IOREMAPFREE( dev_priv->ring_rptr, dev );
- if ( dev_priv->buffers != NULL )
- DRM_IOREMAPFREE( dev_priv->buffers, dev );
+ if ( dev->agp_buffer_map != NULL )
+ DRM_IOREMAPFREE( dev->agp_buffer_map, dev );
} else
#endif
{
diff --git a/shared/radeon_drv.h b/shared/radeon_drv.h
index e24e0ec09..f0aa0dc23 100644
--- a/shared/radeon_drv.h
+++ b/shared/radeon_drv.h
@@ -138,7 +138,6 @@ typedef struct drm_radeon_private {
drm_local_map_t *mmio;
drm_local_map_t *cp_ring;
drm_local_map_t *ring_rptr;
- drm_local_map_t *buffers;
drm_local_map_t *gart_textures;
struct mem_block *gart_heap;
diff --git a/shared/radeon_state.c b/shared/radeon_state.c
index 659f9e9da..57274174d 100644
--- a/shared/radeon_state.c
+++ b/shared/radeon_state.c
@@ -1247,7 +1247,7 @@ static void radeon_cp_dispatch_indirect( drm_device_t *dev,
*/
if ( dwords & 1 ) {
u32 *data = (u32 *)
- ((char *)dev_priv->buffers->handle
+ ((char *)dev->agp_buffer_map->handle
+ buf->offset + start);
data[dwords++] = RADEON_CP_PACKET2;
}
@@ -1301,7 +1301,7 @@ static void radeon_cp_dispatch_indices( drm_device_t *dev,
dwords = (prim->finish - prim->start + 3) / sizeof(u32);
- data = (u32 *)((char *)dev_priv->buffers->handle +
+ data = (u32 *)((char *)dev->agp_buffer_map->handle +
elt_buf->offset + prim->start);
data[0] = CP_PACKET3( RADEON_3D_RNDR_GEN_INDX_PRIM, dwords-2 );
@@ -1445,7 +1445,7 @@ static int radeon_cp_dispatch_texture( DRMFILE filp,
/* Dispatch the indirect buffer.
*/
- buffer = (u32*)((char*)dev_priv->buffers->handle + buf->offset);
+ buffer = (u32*)((char*)dev->agp_buffer_map->handle + buf->offset);
dwords = size / 4;
buffer[0] = CP_PACKET3( RADEON_CNTL_HOSTDATA_BLT, dwords + 6 );
buffer[1] = (RADEON_GMC_DST_PITCH_OFFSET_CNTL |
@@ -2548,7 +2548,13 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
return 0;
}
-static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE *filp)
+/* When a client dies:
+ * - Check for and clean up flipped page state
+ * - Free any alloced GART memory.
+ *
+ * DRM infrastructure takes care of reclaiming dma buffers.
+ */
+static void radeon_driver_prerelease(drm_device_t *dev, DRMFILE filp)
{
if ( dev->dev_private ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -2576,6 +2582,7 @@ static void radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
void radeon_driver_register_fns(struct drm_device *dev)
{
+ dev->dev_priv_size = sizeof(drm_radeon_buf_priv_t);
dev->fn_tbl.prerelease = radeon_driver_prerelease;
dev->fn_tbl.pretakedown = radeon_driver_pretakedown;
dev->fn_tbl.open_helper = radeon_driver_open_helper;
diff --git a/shared/sis.h b/shared/sis.h
index c6315d72f..8afba1a91 100644
--- a/shared/sis.h
+++ b/shared/sis.h
@@ -60,15 +60,4 @@
#define __HAVE_COUNTERS 5
-/* Buffer customization:
- */
-#define DRIVER_AGP_BUFFERS_MAP( dev ) \
- ((drm_sis_private_t *)((dev)->dev_private))->buffers
-
-extern int sis_init_context(int context);
-extern int sis_final_context(int context);
-
-#define DRIVER_CTX_CTOR sis_init_context
-#define DRIVER_CTX_DTOR sis_final_context
-
#endif
diff --git a/shared/sis_drv.h b/shared/sis_drv.h
index 40e7f463e..a87001819 100644
--- a/shared/sis_drv.h
+++ b/shared/sis_drv.h
@@ -31,8 +31,6 @@
#include "sis_ds.h"
typedef struct drm_sis_private {
- drm_map_t *buffers;
-
memHeap_t *AGPHeap;
memHeap_t *FBHeap;
} drm_sis_private_t;
diff --git a/shared/sis_mm.c b/shared/sis_mm.c
index 9b6311a91..233843d5d 100644
--- a/shared/sis_mm.c
+++ b/shared/sis_mm.c
@@ -330,7 +330,7 @@ int sis_ioctl_agp_free( DRM_IOCTL_ARGS )
return 0;
}
-int sis_init_context(int context)
+int sis_init_context(struct drm_device *dev, int context)
{
int i;
@@ -362,7 +362,7 @@ int sis_init_context(int context)
return 1;
}
-int sis_final_context(int context)
+int sis_final_context(struct drm_device *dev, int context)
{
int i;
@@ -408,3 +408,9 @@ int sis_final_context(int context)
return 1;
}
+
+void DRM(driver_register_fns)(drm_device_t *dev)
+{
+ dev->fn_tbl.context_ctor = sis_init_context;
+ dev->fn_tbl.context_dtor = sis_final_context;
+}
diff --git a/shared/via.h b/shared/via.h
index 46ac6536a..bf8526fd4 100644
--- a/shared/via.h
+++ b/shared/via.h
@@ -41,15 +41,4 @@
#define __HAVE_SHARED_IRQ 1
#define __HAVE_VBL_IRQ 1
-
-
-#define DRIVER_AGP_BUFFERS_MAP( dev ) \
- ((drm_via_private_t *)((dev)->dev_private))->buffers
-
-extern int via_init_context(int context);
-extern int via_final_context(int context);
-
-#define DRIVER_CTX_CTOR via_init_context
-#define DRIVER_CTX_DTOR via_final_context
-
#endif
diff --git a/shared/via_drv.c b/shared/via_drv.c
index cd8bdf001..ad4903bb9 100644
--- a/shared/via_drv.c
+++ b/shared/via_drv.c
@@ -66,6 +66,3 @@
#include "drm_vm.h"
#include "drm_stub.h"
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
-}
diff --git a/shared/via_drv.h b/shared/via_drv.h
index 1eafc95fe..ee3852c35 100644
--- a/shared/via_drv.h
+++ b/shared/via_drv.h
@@ -33,7 +33,6 @@ typedef struct drm_via_private {
drm_map_t *fb;
drm_map_t *mmio;
unsigned long agpAddr;
- drm_map_t *buffers;
wait_queue_head_t decoder_queue[VIA_NR_XVMC_LOCKS];
} drm_via_private_t;
diff --git a/shared/via_mm.c b/shared/via_mm.c
index 1bf04fe02..be6184caf 100644
--- a/shared/via_mm.c
+++ b/shared/via_mm.c
@@ -103,7 +103,7 @@ int via_fb_init( DRM_IOCTL_ARGS )
return 0;
}
-int via_init_context(int context)
+int via_init_context(struct drm_device *dev, int context)
{
int i;
@@ -134,7 +134,7 @@ int via_init_context(int context)
return 1;
}
-int via_final_context(int context)
+int via_final_context(struct drm_device *dev, int context)
{
int i;
for (i=0; i<MAX_CONTEXT; i++)
@@ -345,3 +345,9 @@ int via_agp_free(drm_via_mem_t* mem)
EXPORT_SYMBOL(via_fb_alloc);
EXPORT_SYMBOL(via_fb_free);
+
+void DRM(driver_register_fns)(drm_device_t *dev)
+{
+ dev->fn_tbl.context_ctor = via_init_context;
+ dev->fn_tbl.context_dtor = via_final_context;
+}