diff options
author | Dave Airlie <airlied@linux.ie> | 2004-08-03 13:27:53 +0000 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2004-08-03 13:27:53 +0000 |
commit | eb040bfaf9a4648b12fca7d9c9fa1a2aa1611a83 (patch) | |
tree | 10304f58b9246eee97a07cd502f17b2c140305e7 | |
parent | 4f8f02a1922653b2ce5c115c4469e927b5d826fa (diff) |
initial function table support i830/radeon/mach64/gamma
-rw-r--r-- | linux-core/drmP.h | 22 | ||||
-rw-r--r-- | linux-core/drm_drv.c | 109 | ||||
-rw-r--r-- | linux-core/drm_fops.c | 4 | ||||
-rw-r--r-- | linux-core/i830_dma.c | 27 | ||||
-rw-r--r-- | linux/drmP.h | 22 | ||||
-rw-r--r-- | linux/drm_drv.h | 109 | ||||
-rw-r--r-- | linux/drm_fops.h | 4 | ||||
-rw-r--r-- | linux/gamma.h | 16 | ||||
-rw-r--r-- | linux/gamma_dma.c | 45 | ||||
-rw-r--r-- | linux/i830.h | 11 | ||||
-rw-r--r-- | linux/i830_dma.c | 27 | ||||
-rw-r--r-- | shared-core/mach64_dma.c | 16 | ||||
-rw-r--r-- | shared-core/radeon_state.c | 43 | ||||
-rw-r--r-- | shared/mach64.h | 6 | ||||
-rw-r--r-- | shared/mach64_dma.c | 16 | ||||
-rw-r--r-- | shared/radeon.h | 4 | ||||
-rw-r--r-- | shared/radeon_state.c | 43 |
17 files changed, 343 insertions, 181 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 7b136dfe..a6d752d9 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -569,6 +569,26 @@ typedef struct drm_vbl_sig { #endif +/** + * DRM device functions structure + */ +struct drm_device; + +struct drm_driver_fn { + int (*preinit)(struct drm_device *); + int (*postinit)(struct drm_device *); + void (*prerelease)(struct file *filp, struct drm_device *); + void (*pretakedown)(struct drm_device *); + int (*postcleanup)(struct drm_device *); + int (*presetup)(struct drm_device *); + int (*postsetup)(struct drm_device *); + void (*open_helper)(drm_file_t *, struct drm_device *); + void (*release)(struct file *filp, struct drm_device *); + void (*dma_ready)(struct drm_device *); + 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); +}; /** * DRM device structure. */ @@ -703,8 +723,10 @@ typedef struct drm_device { sigset_t sigmask; int need_reset; /**< secondary device needing reset */ + struct drm_driver_fn *fn_tbl; } drm_device_t; +extern struct drm_driver_fn DRM(fn_tbl); /******************************************************************/ /** \name Internal function definitions */ diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index a75566e8..1e9cb609 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -70,18 +70,6 @@ #ifndef __HAVE_DMA_SCHEDULE #define __HAVE_DMA_SCHEDULE 0 #endif -#ifndef __HAVE_DMA_FLUSH -#define __HAVE_DMA_FLUSH 0 -#endif -#ifndef __HAVE_DMA_READY -#define __HAVE_DMA_READY 0 -#endif -#ifndef __HAVE_DMA_QUIESCENT -#define __HAVE_DMA_QUIESCENT 0 -#endif -#ifndef __HAVE_RELEASE -#define __HAVE_RELEASE 0 -#endif #ifndef __HAVE_COUNTERS #define __HAVE_COUNTERS 0 #endif @@ -102,33 +90,9 @@ #define __HAVE_DRIVER_FOPS_POLL 0 #endif -#ifndef DRIVER_PREINIT -#define DRIVER_PREINIT(dev) 0 -#endif -#ifndef DRIVER_POSTINIT -#define DRIVER_POSTINIT(dev) 0 -#endif -#ifndef DRIVER_PRERELEASE -#define DRIVER_PRERELEASE() -#endif -#ifndef DRIVER_PRETAKEDOWN -#define DRIVER_PRETAKEDOWN(dev) -#endif -#ifndef DRIVER_POSTCLEANUP -#define DRIVER_POSTCLEANUP() -#endif -#ifndef DRIVER_PRESETUP -#define DRIVER_PRESETUP() -#endif -#ifndef DRIVER_POSTSETUP -#define DRIVER_POSTSETUP() -#endif #ifndef DRIVER_IOCTLS #define DRIVER_IOCTLS #endif -#ifndef DRIVER_OPEN_HELPER -#define DRIVER_OPEN_HELPER( priv, dev ) -#endif #ifndef DRIVER_FOPS #define DRIVER_FOPS \ static struct file_operations DRM(fops) = { \ @@ -183,7 +147,7 @@ int DRM(fb_loaded) = 0; DRIVER_FOPS; /** Ioctl table */ -static drm_ioctl_desc_t DRM(ioctls)[] = { +drm_ioctl_desc_t DRM(ioctls)[] = { [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 }, @@ -222,12 +186,7 @@ static drm_ioctl_desc_t DRM(ioctls)[] = { [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 }, -#if __HAVE_DMA_FLUSH - /* Gamma only, really */ - [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(finish), 1, 0 }, -#else [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 }, -#endif #if __HAVE_DMA [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 }, @@ -279,7 +238,9 @@ static int DRM(setup)( drm_device_t *dev ) { int i; - DRIVER_PRESETUP(); + if (dev->fn_tbl->presetup) + dev->fn_tbl->presetup(dev); + atomic_set( &dev->ioctl_count, 0 ); atomic_set( &dev->vma_count, 0 ); dev->buf_use = 0; @@ -385,7 +346,9 @@ static int DRM(setup)( drm_device_t *dev ) * drm_select_queue fails between the time the interrupt is * initialized and the time the queues are initialized. */ - DRIVER_POSTSETUP(); + if (dev->fn_tbl->postsetup) + dev->fn_tbl->postsetup(dev); + return 0; } @@ -410,7 +373,8 @@ static int DRM(takedown)( drm_device_t *dev ) DRM_DEBUG( "\n" ); - DRIVER_PRETAKEDOWN(dev); + if (dev->fn_tbl->pretakedown) + dev->fn_tbl->pretakedown(dev); #if __HAVE_IRQ if ( dev->irq_enabled ) DRM(irq_uninstall)( dev ); #endif @@ -602,9 +566,12 @@ 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->fn_tbl = &DRM(fn_tbl); - if ((retcode = DRIVER_PREINIT(dev))) - goto error_out_unreg; + if (dev->fn_tbl->preinit) + if ((retcode = dev->fn_tbl->preinit(dev))) + goto error_out_unreg; #if __REALLY_HAVE_AGP dev->agp = DRM(agp_init)(); @@ -643,7 +610,8 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_pretty_name(pdev) ); - if ((retcode = DRIVER_POSTINIT(dev))) + if (dev->fn_tbl->postinit) + if ((retcode = dev->fn_tbl->postinit(dev))) goto error_out_unreg; @@ -912,7 +880,8 @@ int DRM(release)( struct inode *inode, struct file *filp ) DRM_DEBUG( "open_count = %d\n", dev->open_count ); - DRIVER_PRERELEASE(); + if (dev->fn_tbl->prerelease) + dev->fn_tbl->prerelease(filp, dev); /* ======================================================== * Begin inline drm_release @@ -927,9 +896,10 @@ int DRM(release)( struct inode *inode, struct file *filp ) DRM_DEBUG( "File %p released, freeing lock for context %d\n", filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) ); -#if __HAVE_RELEASE - DRIVER_RELEASE(); -#endif + + if (dev->fn_tbl->release) + dev->fn_tbl->release(filp, dev); + DRM(lock_free)( dev, &dev->lock.hw_lock->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) ); @@ -938,8 +908,7 @@ int DRM(release)( struct inode *inode, struct file *filp ) processed via a callback to the X server. */ } -#if __HAVE_RELEASE - else if ( priv->lock_count && dev->lock.hw_lock ) { + else if ( dev->fn_tbl->release && priv->lock_count && dev->lock.hw_lock ) { /* The lock is required to reclaim buffers */ DECLARE_WAITQUEUE( entry, current ); @@ -968,12 +937,14 @@ int DRM(release)( struct inode *inode, struct file *filp ) current->state = TASK_RUNNING; remove_wait_queue( &dev->lock.lock_queue, &entry ); if( !retcode ) { - DRIVER_RELEASE(); + if (dev->fn_tbl->release) + dev->fn_tbl->release(filp, dev); DRM(lock_free)( dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT ); } } -#elif __HAVE_DMA + +#if __HAVE_DMA DRM(reclaim_buffers)( filp ); #endif @@ -1145,9 +1116,8 @@ int DRM(lock)( struct inode *inode, struct file *filp, q = dev->queuelist[lock.context]; #endif -#if __HAVE_DMA_FLUSH - ret = DRM(flush_block_and_flush)( dev, lock.context, lock.flags ); -#endif + if (dev->fn_tbl->dma_flush_block_and_flush) + ret = dev->fn_tbl->dma_flush_block_and_flush(dev, lock.context, lock.flags); if ( !ret ) { add_wait_queue( &dev->lock.lock_queue, &entry ); for (;;) { @@ -1176,9 +1146,8 @@ int DRM(lock)( struct inode *inode, struct file *filp, remove_wait_queue( &dev->lock.lock_queue, &entry ); } -#if __HAVE_DMA_FLUSH - DRM(flush_unblock)( dev, lock.context, lock.flags ); /* cleanup phase */ -#endif + if (dev->fn_tbl->dma_flush_unblock) + dev->fn_tbl->dma_flush_unblock(dev, lock.context, lock.flags); if ( !ret ) { sigemptyset( &dev->sigmask ); @@ -1191,16 +1160,12 @@ int DRM(lock)( struct inode *inode, struct file *filp, block_all_signals( DRM(notifier), &dev->sigdata, &dev->sigmask ); -#if __HAVE_DMA_READY - if ( lock.flags & _DRM_LOCK_READY ) { - DRIVER_DMA_READY(); - } -#endif -#if __HAVE_DMA_QUIESCENT - if ( lock.flags & _DRM_LOCK_QUIESCENT ) { - DRIVER_DMA_QUIESCENT(); - } -#endif + if (dev->fn_tbl->dma_ready && (lock.flags & _DRM_LOCK_READY)) + dev->fn_tbl->dma_ready(dev); + + if ( dev->fn_tbl->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT )) + return dev->fn_tbl->dma_quiescent(dev); + /* __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. diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c index 869736a4..51081055 100644 --- a/linux-core/drm_fops.c +++ b/linux-core/drm_fops.c @@ -73,7 +73,9 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) priv->authenticated = capable(CAP_SYS_ADMIN); priv->lock_count = 0; - DRIVER_OPEN_HELPER( priv, dev ); + if (dev->fn_tbl->open_helper) + dev->fn_tbl->open_helper(priv, dev); + // DRIVER_OPEN_HELPER( priv, dev ); down(&dev->struct_sem); if (!dev->file_last) { diff --git a/linux-core/i830_dma.c b/linux-core/i830_dma.c index 55bf1b72..7da99f6c 100644 --- a/linux-core/i830_dma.c +++ b/linux-core/i830_dma.c @@ -1589,3 +1589,30 @@ int i830_setparam( struct inode *inode, struct file *filp, unsigned int cmd, return 0; } + + +static void i830_driver_pretakedown(drm_device_t *dev) +{ + i830_dma_cleanup( dev ); +} + +static void i830_driver_release(struct file *filp, drm_device_t *dev) +{ + i830_reclaim_buffers(filp); +} + +struct drm_driver_fn DRM(fn_tbl) = { + NULL, /* preinit*/ + NULL, /* postinit */ + NULL, /* prerelease */ + i830_driver_pretakedown, /* pretakedown */ + NULL, /* postcleanup */ + NULL, /* presetup */ + NULL, /* postsetup */ + NULL, /* open_helper */ + i830_driver_release, /* release */ + NULL, + NULL, + NULL, + NULL +}; diff --git a/linux/drmP.h b/linux/drmP.h index 7b136dfe..a6d752d9 100644 --- a/linux/drmP.h +++ b/linux/drmP.h @@ -569,6 +569,26 @@ typedef struct drm_vbl_sig { #endif +/** + * DRM device functions structure + */ +struct drm_device; + +struct drm_driver_fn { + int (*preinit)(struct drm_device *); + int (*postinit)(struct drm_device *); + void (*prerelease)(struct file *filp, struct drm_device *); + void (*pretakedown)(struct drm_device *); + int (*postcleanup)(struct drm_device *); + int (*presetup)(struct drm_device *); + int (*postsetup)(struct drm_device *); + void (*open_helper)(drm_file_t *, struct drm_device *); + void (*release)(struct file *filp, struct drm_device *); + void (*dma_ready)(struct drm_device *); + 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); +}; /** * DRM device structure. */ @@ -703,8 +723,10 @@ typedef struct drm_device { sigset_t sigmask; int need_reset; /**< secondary device needing reset */ + struct drm_driver_fn *fn_tbl; } drm_device_t; +extern struct drm_driver_fn DRM(fn_tbl); /******************************************************************/ /** \name Internal function definitions */ diff --git a/linux/drm_drv.h b/linux/drm_drv.h index a75566e8..1e9cb609 100644 --- a/linux/drm_drv.h +++ b/linux/drm_drv.h @@ -70,18 +70,6 @@ #ifndef __HAVE_DMA_SCHEDULE #define __HAVE_DMA_SCHEDULE 0 #endif -#ifndef __HAVE_DMA_FLUSH -#define __HAVE_DMA_FLUSH 0 -#endif -#ifndef __HAVE_DMA_READY -#define __HAVE_DMA_READY 0 -#endif -#ifndef __HAVE_DMA_QUIESCENT -#define __HAVE_DMA_QUIESCENT 0 -#endif -#ifndef __HAVE_RELEASE -#define __HAVE_RELEASE 0 -#endif #ifndef __HAVE_COUNTERS #define __HAVE_COUNTERS 0 #endif @@ -102,33 +90,9 @@ #define __HAVE_DRIVER_FOPS_POLL 0 #endif -#ifndef DRIVER_PREINIT -#define DRIVER_PREINIT(dev) 0 -#endif -#ifndef DRIVER_POSTINIT -#define DRIVER_POSTINIT(dev) 0 -#endif -#ifndef DRIVER_PRERELEASE -#define DRIVER_PRERELEASE() -#endif -#ifndef DRIVER_PRETAKEDOWN -#define DRIVER_PRETAKEDOWN(dev) -#endif -#ifndef DRIVER_POSTCLEANUP -#define DRIVER_POSTCLEANUP() -#endif -#ifndef DRIVER_PRESETUP -#define DRIVER_PRESETUP() -#endif -#ifndef DRIVER_POSTSETUP -#define DRIVER_POSTSETUP() -#endif #ifndef DRIVER_IOCTLS #define DRIVER_IOCTLS #endif -#ifndef DRIVER_OPEN_HELPER -#define DRIVER_OPEN_HELPER( priv, dev ) -#endif #ifndef DRIVER_FOPS #define DRIVER_FOPS \ static struct file_operations DRM(fops) = { \ @@ -183,7 +147,7 @@ int DRM(fb_loaded) = 0; DRIVER_FOPS; /** Ioctl table */ -static drm_ioctl_desc_t DRM(ioctls)[] = { +drm_ioctl_desc_t DRM(ioctls)[] = { [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 }, @@ -222,12 +186,7 @@ static drm_ioctl_desc_t DRM(ioctls)[] = { [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 }, -#if __HAVE_DMA_FLUSH - /* Gamma only, really */ - [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(finish), 1, 0 }, -#else [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 }, -#endif #if __HAVE_DMA [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 }, @@ -279,7 +238,9 @@ static int DRM(setup)( drm_device_t *dev ) { int i; - DRIVER_PRESETUP(); + if (dev->fn_tbl->presetup) + dev->fn_tbl->presetup(dev); + atomic_set( &dev->ioctl_count, 0 ); atomic_set( &dev->vma_count, 0 ); dev->buf_use = 0; @@ -385,7 +346,9 @@ static int DRM(setup)( drm_device_t *dev ) * drm_select_queue fails between the time the interrupt is * initialized and the time the queues are initialized. */ - DRIVER_POSTSETUP(); + if (dev->fn_tbl->postsetup) + dev->fn_tbl->postsetup(dev); + return 0; } @@ -410,7 +373,8 @@ static int DRM(takedown)( drm_device_t *dev ) DRM_DEBUG( "\n" ); - DRIVER_PRETAKEDOWN(dev); + if (dev->fn_tbl->pretakedown) + dev->fn_tbl->pretakedown(dev); #if __HAVE_IRQ if ( dev->irq_enabled ) DRM(irq_uninstall)( dev ); #endif @@ -602,9 +566,12 @@ 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->fn_tbl = &DRM(fn_tbl); - if ((retcode = DRIVER_PREINIT(dev))) - goto error_out_unreg; + if (dev->fn_tbl->preinit) + if ((retcode = dev->fn_tbl->preinit(dev))) + goto error_out_unreg; #if __REALLY_HAVE_AGP dev->agp = DRM(agp_init)(); @@ -643,7 +610,8 @@ static int drm_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_pretty_name(pdev) ); - if ((retcode = DRIVER_POSTINIT(dev))) + if (dev->fn_tbl->postinit) + if ((retcode = dev->fn_tbl->postinit(dev))) goto error_out_unreg; @@ -912,7 +880,8 @@ int DRM(release)( struct inode *inode, struct file *filp ) DRM_DEBUG( "open_count = %d\n", dev->open_count ); - DRIVER_PRERELEASE(); + if (dev->fn_tbl->prerelease) + dev->fn_tbl->prerelease(filp, dev); /* ======================================================== * Begin inline drm_release @@ -927,9 +896,10 @@ int DRM(release)( struct inode *inode, struct file *filp ) DRM_DEBUG( "File %p released, freeing lock for context %d\n", filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) ); -#if __HAVE_RELEASE - DRIVER_RELEASE(); -#endif + + if (dev->fn_tbl->release) + dev->fn_tbl->release(filp, dev); + DRM(lock_free)( dev, &dev->lock.hw_lock->lock, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) ); @@ -938,8 +908,7 @@ int DRM(release)( struct inode *inode, struct file *filp ) processed via a callback to the X server. */ } -#if __HAVE_RELEASE - else if ( priv->lock_count && dev->lock.hw_lock ) { + else if ( dev->fn_tbl->release && priv->lock_count && dev->lock.hw_lock ) { /* The lock is required to reclaim buffers */ DECLARE_WAITQUEUE( entry, current ); @@ -968,12 +937,14 @@ int DRM(release)( struct inode *inode, struct file *filp ) current->state = TASK_RUNNING; remove_wait_queue( &dev->lock.lock_queue, &entry ); if( !retcode ) { - DRIVER_RELEASE(); + if (dev->fn_tbl->release) + dev->fn_tbl->release(filp, dev); DRM(lock_free)( dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT ); } } -#elif __HAVE_DMA + +#if __HAVE_DMA DRM(reclaim_buffers)( filp ); #endif @@ -1145,9 +1116,8 @@ int DRM(lock)( struct inode *inode, struct file *filp, q = dev->queuelist[lock.context]; #endif -#if __HAVE_DMA_FLUSH - ret = DRM(flush_block_and_flush)( dev, lock.context, lock.flags ); -#endif + if (dev->fn_tbl->dma_flush_block_and_flush) + ret = dev->fn_tbl->dma_flush_block_and_flush(dev, lock.context, lock.flags); if ( !ret ) { add_wait_queue( &dev->lock.lock_queue, &entry ); for (;;) { @@ -1176,9 +1146,8 @@ int DRM(lock)( struct inode *inode, struct file *filp, remove_wait_queue( &dev->lock.lock_queue, &entry ); } -#if __HAVE_DMA_FLUSH - DRM(flush_unblock)( dev, lock.context, lock.flags ); /* cleanup phase */ -#endif + if (dev->fn_tbl->dma_flush_unblock) + dev->fn_tbl->dma_flush_unblock(dev, lock.context, lock.flags); if ( !ret ) { sigemptyset( &dev->sigmask ); @@ -1191,16 +1160,12 @@ int DRM(lock)( struct inode *inode, struct file *filp, block_all_signals( DRM(notifier), &dev->sigdata, &dev->sigmask ); -#if __HAVE_DMA_READY - if ( lock.flags & _DRM_LOCK_READY ) { - DRIVER_DMA_READY(); - } -#endif -#if __HAVE_DMA_QUIESCENT - if ( lock.flags & _DRM_LOCK_QUIESCENT ) { - DRIVER_DMA_QUIESCENT(); - } -#endif + if (dev->fn_tbl->dma_ready && (lock.flags & _DRM_LOCK_READY)) + dev->fn_tbl->dma_ready(dev); + + if ( dev->fn_tbl->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT )) + return dev->fn_tbl->dma_quiescent(dev); + /* __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. diff --git a/linux/drm_fops.h b/linux/drm_fops.h index 869736a4..51081055 100644 --- a/linux/drm_fops.h +++ b/linux/drm_fops.h @@ -73,7 +73,9 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) priv->authenticated = capable(CAP_SYS_ADMIN); priv->lock_count = 0; - DRIVER_OPEN_HELPER( priv, dev ); + if (dev->fn_tbl->open_helper) + dev->fn_tbl->open_helper(priv, dev); + // DRIVER_OPEN_HELPER( priv, dev ); down(&dev->struct_sem); if (!dev->file_last) { diff --git a/linux/gamma.h b/linux/gamma.h index 899d4113..c99266ef 100644 --- a/linux/gamma.h +++ b/linux/gamma.h @@ -86,24 +86,8 @@ #define __HAVE_DMA_WAITLIST 1 #define __HAVE_DMA_FREELIST 1 -#define __HAVE_DMA_FLUSH 1 #define __HAVE_DMA_SCHEDULE 1 -#define __HAVE_DMA_READY 1 -#define DRIVER_DMA_READY() do { \ - gamma_dma_ready(dev); \ -} while (0) - -#define __HAVE_DMA_QUIESCENT 1 -#define DRIVER_DMA_QUIESCENT() do { \ - drm_gamma_private_t *dev_priv = \ - (drm_gamma_private_t *)dev->dev_private; \ - if (dev_priv->num_rast == 2) \ - gamma_dma_quiescent_dual(dev); \ - else gamma_dma_quiescent_single(dev); \ - return 0; \ -} while (0) - #define __HAVE_IRQ 1 #define __HAVE_IRQ_BH 1 diff --git a/linux/gamma_dma.c b/linux/gamma_dma.c index ac08b385..da135db3 100644 --- a/linux/gamma_dma.c +++ b/linux/gamma_dma.c @@ -911,3 +911,48 @@ void DRM(driver_irq_uninstall)( drm_device_t *dev ) { GAMMA_WRITE( GAMMA_COMMANDINTENABLE, 0x00000000 ); GAMMA_WRITE( GAMMA_GINTENABLE, 0x00000000 ); } + +extern drm_ioctl_desc_t DRM(ioctls)[]; + +static int gamma_driver_preinit(drm_device_t *dev) +{ + /* reset the finish ioctl */ + DRM(ioctls)[DRM_IOCTL_NR(DRM_IOCTL_FINISH)].func = DRM(finish); + return 0; +} + +static void gamma_driver_pretakedown(drm_device_t *dev) +{ + gamma_do_cleanup_dma(dev); +} + +static void gamma_driver_dma_ready(drm_device_t *dev) +{ + gamma_dma_ready(dev); +} + +static int gamma_driver_dma_quiescent(drm_device_t *dev) +{ + drm_gamma_private_t *dev_priv = ( + drm_gamma_private_t *)dev->dev_private; + if (dev_priv->num_rast == 2) + gamma_dma_quiescent_dual(dev); + else gamma_dma_quiescent_single(dev); + return 0; +} + +struct drm_driver_fn DRM(fn_tbl) = { + gamma_driver_preinit, /* preinit*/ + NULL, /* postinit */ + NULL, /* prerelease */ + gamma_driver_pretakedown, /* pretakedown */ + NULL, /* postcleanup */ + NULL, /* presetup */ + NULL, /* postsetup */ + NULL, /* open_helper */ + NULL, + gamma_driver_dma_ready, + gamma_driver_dma_quiescent, + gamma_flush_block_and_flush, + gamma_flush_unblock, +}; diff --git a/linux/i830.h b/linux/i830.h index 56f7a116..ca1012eb 100644 --- a/linux/i830.h +++ b/linux/i830.h @@ -83,17 +83,6 @@ #define __HAVE_COUNTER8 _DRM_STAT_SECONDARY #define __HAVE_COUNTER9 _DRM_STAT_DMA -/* Driver customization: - */ -#define __HAVE_RELEASE 1 -#define DRIVER_RELEASE() do { \ - i830_reclaim_buffers( filp ); \ -} while (0) - -#define DRIVER_PRETAKEDOWN( dev ) do { \ - i830_dma_cleanup( dev ); \ -} while (0) - /* DMA customization: */ #define __HAVE_DMA 1 diff --git a/linux/i830_dma.c b/linux/i830_dma.c index 55bf1b72..7da99f6c 100644 --- a/linux/i830_dma.c +++ b/linux/i830_dma.c @@ -1589,3 +1589,30 @@ int i830_setparam( struct inode *inode, struct file *filp, unsigned int cmd, return 0; } + + +static void i830_driver_pretakedown(drm_device_t *dev) +{ + i830_dma_cleanup( dev ); +} + +static void i830_driver_release(struct file *filp, drm_device_t *dev) +{ + i830_reclaim_buffers(filp); +} + +struct drm_driver_fn DRM(fn_tbl) = { + NULL, /* preinit*/ + NULL, /* postinit */ + NULL, /* prerelease */ + i830_driver_pretakedown, /* pretakedown */ + NULL, /* postcleanup */ + NULL, /* presetup */ + NULL, /* postsetup */ + NULL, /* open_helper */ + i830_driver_release, /* release */ + NULL, + NULL, + NULL, + NULL +}; diff --git a/shared-core/mach64_dma.c b/shared-core/mach64_dma.c index 60663422..edc68fae 100644 --- a/shared-core/mach64_dma.c +++ b/shared-core/mach64_dma.c @@ -1323,3 +1323,19 @@ int mach64_dma_buffers( DRM_IOCTL_ARGS ) return ret; } +static void mach64_driver_pretakedown(drm_device_t *dev) +{ + mach64_do_cleanup_dma( dev ); +} + +struct drm_driver_fn DRM(fn_tbl) = { + NULL, /* preinit*/ + NULL, /* postinit */ + NULL, /* prerelease */ + mach64_driver_pretakedown, /* pretakedown */ + NULL, /* postcleanup */ + NULL, /* presetup */ + NULL, /* postsetup */ + NULL, /* open_helper */ + NULL, /* release */ +}; diff --git a/shared-core/radeon_state.c b/shared-core/radeon_state.c index 10a6629a..48548ca4 100644 --- a/shared-core/radeon_state.c +++ b/shared-core/radeon_state.c @@ -2547,3 +2547,46 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) { return 0; } + +static void radeon_driver_prerelease(struct file *filp, drm_device_t *dev) +{ + 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 ); + } +} + +static void radeon_driver_pretakedown(drm_device_t *dev) +{ + radeon_do_release(dev); +} + +static void radeon_driver_open_helper(drm_file_t *filp_priv, drm_device_t *dev) +{ + 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; +} + + +struct drm_driver_fn DRM(fn_tbl) = { + NULL, /* preinit*/ + NULL, /* postinit */ + radeon_driver_prerelease, /* prerelease */ + radeon_driver_pretakedown, /* pretakedown */ + NULL, /* postcleanup */ + NULL, /* presetup */ + NULL, /* postsetup */ + radeon_driver_open_helper, /* open_helper */ + NULL, /* release */ + NULL, + NULL, + NULL, + NULL +}; diff --git a/shared/mach64.h b/shared/mach64.h index 2fde4466..9ed5a7fa 100644 --- a/shared/mach64.h +++ b/shared/mach64.h @@ -71,12 +71,6 @@ [DRM_IOCTL_NR(DRM_IOCTL_MACH64_FLUSH)] = { mach64_dma_flush, 1, 0 }, \ [DRM_IOCTL_NR(DRM_IOCTL_MACH64_GETPARAM)] = { mach64_get_param, 1, 0 } -/* Driver customization: - */ -#define DRIVER_PRETAKEDOWN(dev) do { \ - mach64_do_cleanup_dma( dev ); \ -} while (0) - /* DMA customization: */ #define __HAVE_DMA 1 diff --git a/shared/mach64_dma.c b/shared/mach64_dma.c index 60663422..edc68fae 100644 --- a/shared/mach64_dma.c +++ b/shared/mach64_dma.c @@ -1323,3 +1323,19 @@ int mach64_dma_buffers( DRM_IOCTL_ARGS ) return ret; } +static void mach64_driver_pretakedown(drm_device_t *dev) +{ + mach64_do_cleanup_dma( dev ); +} + +struct drm_driver_fn DRM(fn_tbl) = { + NULL, /* preinit*/ + NULL, /* postinit */ + NULL, /* prerelease */ + mach64_driver_pretakedown, /* pretakedown */ + NULL, /* postcleanup */ + NULL, /* presetup */ + NULL, /* postsetup */ + NULL, /* open_helper */ + NULL, /* release */ +}; diff --git a/shared/radeon.h b/shared/radeon.h index eb857daf..1dc77a75 100644 --- a/shared/radeon.h +++ b/shared/radeon.h @@ -147,12 +147,12 @@ do { \ /* When the last client dies, shut down the CP and free dev->dev_priv. */ -/* #define __HAVE_RELEASE 1 */ +#if 0 #define DRIVER_PRETAKEDOWN( dev ) \ do { \ radeon_do_release( dev ); \ } while (0) - +#endif /* DMA customization: diff --git a/shared/radeon_state.c b/shared/radeon_state.c index 10a6629a..48548ca4 100644 --- a/shared/radeon_state.c +++ b/shared/radeon_state.c @@ -2547,3 +2547,46 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) { return 0; } + +static void radeon_driver_prerelease(struct file *filp, drm_device_t *dev) +{ + 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 ); + } +} + +static void radeon_driver_pretakedown(drm_device_t *dev) +{ + radeon_do_release(dev); +} + +static void radeon_driver_open_helper(drm_file_t *filp_priv, drm_device_t *dev) +{ + 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; +} + + +struct drm_driver_fn DRM(fn_tbl) = { + NULL, /* preinit*/ + NULL, /* postinit */ + radeon_driver_prerelease, /* prerelease */ + radeon_driver_pretakedown, /* pretakedown */ + NULL, /* postcleanup */ + NULL, /* presetup */ + NULL, /* postsetup */ + radeon_driver_open_helper, /* open_helper */ + NULL, /* release */ + NULL, + NULL, + NULL, + NULL +}; |