summaryrefslogtreecommitdiff
path: root/bsd-core
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2004-08-17 13:10:05 +0000
committerDave Airlie <airlied@linux.ie>2004-08-17 13:10:05 +0000
commit5c9ed8309493acb099463d25b32fabb5b7c004af (patch)
treeeec5be6f9374b5a2f61d52bd02ba0a44ba7e636d /bsd-core
parent93e8c201afac565942f9d3523ac808d3220d6d0e (diff)
Merged drmfntbl-0-0-1
Diffstat (limited to 'bsd-core')
-rw-r--r--bsd-core/drmP.h76
-rw-r--r--bsd-core/drm_bufs.c23
-rw-r--r--bsd-core/drm_context.c12
-rw-r--r--bsd-core/drm_drv.c64
-rw-r--r--bsd-core/drm_fops.c3
-rw-r--r--bsd-core/drm_os_freebsd.h12
-rw-r--r--bsd-core/drm_os_netbsd.h11
-rw-r--r--bsd-core/sis_drv.c1
-rw-r--r--bsd-core/tdfx_drv.c4
9 files changed, 113 insertions, 93 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index e6b1bea9..c67592f6 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -100,19 +100,6 @@ typedef struct drm_file drm_file_t;
#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
- /* Mapping helper macros */
-#define DRM_IOREMAP(map, dev) \
- (map)->handle = DRM(ioremap)( dev, map )
-
-#define DRM_IOREMAP_NOCACHE(map, dev) \
- (map)->handle = DRM(ioremap_nocache)( dev, map )
-
-#define DRM_IOREMAPFREE(map, dev) \
- do { \
- if ( (map)->handle && (map)->size ) \
- DRM(ioremapfree)( map ); \
- } while (0)
-
/* Internal types and structures */
#define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define DRM_MIN(a,b) ((a)<(b)?(a):(b))
@@ -302,6 +289,32 @@ typedef struct drm_vbl_sig {
int pid;
} drm_vbl_sig_t;
+/**
+ * DRM device functions structure
+ */
+struct drm_device;
+
+struct drm_driver_fn {
+ int (*preinit)(struct drm_device *, unsigned long flags);
+ int (*postinit)(struct drm_device *, unsigned long flags);
+ void (*prerelease)(struct drm_device *, void *filp);
+ void (*pretakedown)(struct drm_device *);
+ int (*postcleanup)(struct drm_device *);
+ int (*presetup)(struct drm_device *);
+ int (*postsetup)(struct drm_device *);
+ void (*open_helper)(struct drm_device *, drm_file_t *);
+ void (*release)(struct drm_device *, void *filp);
+ 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);
+ 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);
+ int (*dma_schedule)(struct drm_device *dev, int locked);
+};
+
struct drm_device {
#ifdef __NetBSD__
struct device device; /* NetBSD's softc is an extension of struct device */
@@ -393,8 +406,13 @@ struct drm_device {
drm_sg_mem_t *sg; /* Scatter gather memory */
atomic_t *ctx_bitmap;
void *dev_private;
+ struct drm_driver_fn fn_tbl;
+ drm_local_map_t *agp_buffer_map;
+ int dev_priv_size;
};
+extern void DRM(driver_register_fns)(struct drm_device *dev);
+
extern int DRM(flags);
/* Memory management support (drm_memory.h) */
@@ -570,5 +588,37 @@ extern void *DRM(pci_alloc)(drm_device_t *dev, size_t size,
extern void DRM(pci_free)(drm_device_t *dev, size_t size,
void *vaddr, dma_addr_t busaddr);
+/* Inline replacements for DRM_IOREMAP macros */
+static __inline__ void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
+{
+ map->handle = DRM(ioremap)( dev, map );
+}
+#if 0
+static __inline__ void drm_core_ioremap_nocache(struct drm_map *map, struct drm_device *dev)
+{
+ map->handle = DRM(ioremap_nocache)(dev, map);
+}
+#endif
+static __inline__ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
+{
+ if ( map->handle && map->size )
+ DRM(ioremapfree)( map );
+}
+
+static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, unsigned long offset)
+{
+ drm_map_list_entry_t *listentry;
+ TAILQ_FOREACH(listentry, dev->maplist, link) {
+ if ( listentry->map->offset == offset ) {
+ return listentry->map;
+ }
+ }
+ return NULL;
+}
+
+static __inline__ void drm_core_dropmap(struct drm_map *map)
+{
+}
+
#endif /* __KERNEL__ */
#endif /* _DRM_P_H_ */
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c
index d5beb3be..d27254c2 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -40,17 +40,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 order. Can be made faster.
*/
@@ -111,7 +100,7 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
switch ( map->type ) {
case _DRM_REGISTERS:
- DRM_IOREMAP(map, dev);
+ drm_core_ioremap(map, dev);
if (!(map->flags & _DRM_WRITE_COMBINING))
break;
/* FALLTHROUGH */
@@ -353,7 +342,7 @@ static int DRM(addbufs_agp)(drm_device_t *dev, drm_buf_desc_t *request)
buf->pending = 0;
buf->filp = NULL;
- buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
+ buf->dev_priv_size = dev->dev_priv_size;
buf->dev_private = DRM(calloc)(1, buf->dev_priv_size,
DRM_MEM_BUFS);
if (buf->dev_private == NULL) {
@@ -512,8 +501,8 @@ static int DRM(addbufs_pci)(drm_device_t *dev, drm_buf_desc_t *request)
buf->pending = 0;
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 == NULL) {
/* Set count correctly so we free the proper amount. */
@@ -636,7 +625,7 @@ static int DRM(addbufs_sg)(drm_device_t *dev, drm_buf_desc_t *request)
buf->pending = 0;
buf->filp = NULL;
- buf->dev_priv_size = sizeof(DRIVER_BUF_PRIV_T);
+ buf->dev_priv_size = dev->dev_priv_size;
buf->dev_private = DRM(calloc)(1, buf->dev_priv_size,
DRM_MEM_BUFS);
if (buf->dev_private == NULL) {
@@ -907,7 +896,7 @@ int DRM(mapbufs)( DRM_IOCTL_ARGS )
if ((__HAVE_AGP && (dma->flags & _DRM_DMA_USE_AGP)) ||
(__HAVE_SG && (dma->flags & _DRM_DMA_USE_SG))) {
- drm_local_map_t *map = DRIVER_AGP_BUFFERS_MAP(dev);
+ drm_local_map_t *map = dev->agp_buffer_map;
if (map == NULL) {
retcode = EINVAL;
diff --git a/bsd-core/drm_context.c b/bsd-core/drm_context.c
index a61b7788..aa655297 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(dev, ctx.handle);
-#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,9 @@ 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(dev, ctx.handle);
-#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/drm_drv.c b/bsd-core/drm_drv.c
index 256be44d..4e82ef81 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -77,33 +77,9 @@
#define __HAVE_SG 0
#endif
-#ifndef DRIVER_PREINIT
-#define DRIVER_PREINIT(dev) do {} while (0)
-#endif
-#ifndef DRIVER_POSTINIT
-#define DRIVER_POSTINIT(dev) do {} while (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
#endif
@@ -437,7 +413,9 @@ static int DRM(setup)( drm_device_t *dev )
DRM_SPINLOCK_ASSERT(&dev->dev_lock);
- DRIVER_PRESETUP();
+ if (dev->fn_tbl.presetup)
+ dev->fn_tbl.presetup(dev);
+
dev->buf_use = 0;
#if __HAVE_DMA
@@ -507,7 +485,9 @@ static int DRM(setup)( drm_device_t *dev )
DRM_DEBUG( "\n" );
- DRIVER_POSTSETUP();
+ if (dev->fn_tbl.postsetup)
+ dev->fn_tbl.postsetup(dev);
+
return 0;
}
@@ -523,7 +503,9 @@ 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 );
@@ -638,8 +620,7 @@ static int DRM(init)( device_t nbdev )
int retcode;
#endif
DRM_DEBUG( "\n" );
- DRIVER_PREINIT(dev);
-
+
#ifdef __FreeBSD__
unit = device_get_unit(nbdev);
dev = device_get_softc(nbdev);
@@ -650,6 +631,13 @@ static int DRM(init)( device_t nbdev )
else
dev->device = nbdev;
+ /* 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)
+ dev->fn_tbl.preinit(dev, 0);
+
dev->devnode = make_dev( &DRM(cdevsw),
unit,
DRM_DEV_UID,
@@ -661,6 +649,14 @@ static int DRM(init)( device_t nbdev )
#endif
#elif defined(__NetBSD__)
unit = minor(dev->device.dv_unit);
+
+ /* 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)
+ dev->fn_tbl.preinit(dev, 0);
+
#endif
dev->irq = pci_get_irq(dev->device);
@@ -716,7 +712,8 @@ static int DRM(init)( device_t nbdev )
DRIVER_DATE,
unit );
- DRIVER_POSTINIT(dev);
+ if (dev->fn_tbl.postinit)
+ dev->fn_tbl.postinit(dev, 0);
return 0;
@@ -773,7 +770,9 @@ static void DRM(cleanup)(drm_device_t *dev)
dev->agp = NULL;
}
#endif
- DRIVER_POSTCLEANUP();
+ if (dev->fn_tbl.postcleanup)
+ dev->fn_tbl.postcleanup(dev);
+
DRM(mem_uninit)();
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
mtx_destroy(&dev->dev_lock);
@@ -854,7 +853,8 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
return EINVAL;
}
- DRIVER_PRERELEASE();
+ if (dev->fn_tbl.prerelease)
+ dev->fn_tbl.prerelease(dev, filp);
/* ========================================================
* Begin inline drm_release
diff --git a/bsd-core/drm_fops.c b/bsd-core/drm_fops.c
index a3678730..2c447992 100644
--- a/bsd-core/drm_fops.c
+++ b/bsd-core/drm_fops.c
@@ -90,7 +90,8 @@ int DRM(open_helper)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
priv->ioctl_count = 0;
priv->authenticated = !DRM_SUSER(p);
- DRIVER_OPEN_HELPER( priv, dev );
+ if (dev->fn_tbl.open_helper)
+ dev->fn_tbl.open_helper(dev, priv);
TAILQ_INSERT_TAIL(&dev->files, priv, link);
}
diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h
index dd95d9cb..3ae2dc0b 100644
--- a/bsd-core/drm_os_freebsd.h
+++ b/bsd-core/drm_os_freebsd.h
@@ -447,18 +447,6 @@ find_first_zero_bit(volatile void *p, int max)
#define DRM_SYSCTL_HANDLER_ARGS SYSCTL_HANDLER_ARGS
#endif
-#define DRM_FIND_MAP(dest, o) \
- do { \
- drm_map_list_entry_t *listentry; \
- TAILQ_FOREACH(listentry, dev->maplist, link) { \
- if ( listentry->map->offset == o ) { \
- dest = listentry->map; \
- break; \
- } \
- } \
- } while (0)
-
-
/* Internal functions */
/* drm_drv.h */
diff --git a/bsd-core/drm_os_netbsd.h b/bsd-core/drm_os_netbsd.h
index 47b8f501..832f8318 100644
--- a/bsd-core/drm_os_netbsd.h
+++ b/bsd-core/drm_os_netbsd.h
@@ -357,17 +357,6 @@ do { \
#define DRM_DEBUG(fmt, arg...) do { } while (0)
#endif
-#define DRM_FIND_MAP(dest, o) \
- do { \
- drm_map_list_entry_t *listentry; \
- TAILQ_FOREACH(listentry, dev->maplist, link) { \
- if ( listentry->map->offset == o ) { \
- dest = listentry->map; \
- break; \
- } \
- } \
- } while (0)
-
/* Internal functions */
/* drm_drv.h */
diff --git a/bsd-core/sis_drv.c b/bsd-core/sis_drv.c
index 4283efdc..2d40018e 100644
--- a/bsd-core/sis_drv.c
+++ b/bsd-core/sis_drv.c
@@ -50,3 +50,4 @@ DRIVER_MODULE(sisdrm, pci, sisdrv_driver, sisdrv_devclass, 0, 0);
#elif defined(__NetBSD__)
CFDRIVER_DECL(sis, DV_TTY, NULL);
#endif /* __FreeBSD__ */
+
diff --git a/bsd-core/tdfx_drv.c b/bsd-core/tdfx_drv.c
index e96216c8..bc038cc0 100644
--- a/bsd-core/tdfx_drv.c
+++ b/bsd-core/tdfx_drv.c
@@ -52,3 +52,7 @@ DRIVER_MODULE(tdfx, pci, tdfx_driver, tdfx_devclass, 0, 0);
#elif defined(__NetBSD__)
CFDRIVER_DECL(tdfx, DV_TTY, NULL);
#endif /* __FreeBSD__ */
+
+void DRM(driver_register_fns)(drm_device_t *dev)
+{
+}