summaryrefslogtreecommitdiff
path: root/bsd
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2004-08-04 10:38:39 +0000
committerDave Airlie <airlied@linux.ie>2004-08-04 10:38:39 +0000
commit67eae63e8947e06d7ee42d7e23796b8597e23d83 (patch)
tree888abcf918e4c72dc84c9fe739eda085e91ee348 /bsd
parenteb040bfaf9a4648b12fca7d9c9fa1a2aa1611a83 (diff)
Move to standard init function - finish porting other drivers and hopefully
BSD
Diffstat (limited to 'bsd')
-rw-r--r--bsd/drmP.h24
-rw-r--r--bsd/drm_drv.h56
-rw-r--r--bsd/drm_fops.h3
-rw-r--r--bsd/sis_drv.c4
-rw-r--r--bsd/tdfx_drv.c4
5 files changed, 58 insertions, 33 deletions
diff --git a/bsd/drmP.h b/bsd/drmP.h
index e6b1bea9..6ac30087 100644
--- a/bsd/drmP.h
+++ b/bsd/drmP.h
@@ -302,6 +302,27 @@ 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 *);
+ int (*postinit)(struct drm_device *);
+ 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);
+};
+
struct drm_device {
#ifdef __NetBSD__
struct device device; /* NetBSD's softc is an extension of struct device */
@@ -393,8 +414,11 @@ struct drm_device {
drm_sg_mem_t *sg; /* Scatter gather memory */
atomic_t *ctx_bitmap;
void *dev_private;
+ struct drm_driver_fn fn_tbl;
};
+extern void DRM(driver_register_fns)(struct drm_device *dev);
+
extern int DRM(flags);
/* Memory management support (drm_memory.h) */
diff --git a/bsd/drm_drv.h b/bsd/drm_drv.h
index af69029b..4474f250 100644
--- a/bsd/drm_drv.h
+++ b/bsd/drm_drv.h
@@ -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
@@ -433,7 +409,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
@@ -503,7 +481,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;
}
@@ -519,7 +499,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 );
@@ -634,8 +616,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);
@@ -646,6 +627,9 @@ static int DRM(init)( device_t nbdev )
else
dev->device = nbdev;
+ if (dev->fn_tbl.preinit)
+ dev->fn_tbl.preinit(dev);
+
dev->devnode = make_dev( &DRM(cdevsw),
unit,
DRM_DEV_UID,
@@ -657,6 +641,10 @@ static int DRM(init)( device_t nbdev )
#endif
#elif defined(__NetBSD__)
unit = minor(dev->device.dv_unit);
+
+ if (dev->fn_tbl.preinit)
+ dev->fn_tbl.preinit(dev);
+
#endif
dev->irq = pci_get_irq(dev->device);
@@ -712,7 +700,8 @@ static int DRM(init)( device_t nbdev )
DRIVER_DATE,
unit );
- DRIVER_POSTINIT(dev);
+ if (dev->fn_tbl.postinit)
+ dev->fn_tbl.postinit(dev);
return 0;
@@ -769,7 +758,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);
@@ -850,7 +841,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/drm_fops.h b/bsd/drm_fops.h
index a3678730..2c447992 100644
--- a/bsd/drm_fops.h
+++ b/bsd/drm_fops.h
@@ -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/sis_drv.c b/bsd/sis_drv.c
index 4283efdc..c63b8c56 100644
--- a/bsd/sis_drv.c
+++ b/bsd/sis_drv.c
@@ -50,3 +50,7 @@ DRIVER_MODULE(sisdrm, pci, sisdrv_driver, sisdrv_devclass, 0, 0);
#elif defined(__NetBSD__)
CFDRIVER_DECL(sis, DV_TTY, NULL);
#endif /* __FreeBSD__ */
+
+void DRM(driver_register_fns)(drm_device_t *dev)
+{
+}
diff --git a/bsd/tdfx_drv.c b/bsd/tdfx_drv.c
index e96216c8..bc038cc0 100644
--- a/bsd/tdfx_drv.c
+++ b/bsd/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)
+{
+}