summaryrefslogtreecommitdiff
path: root/bsd-core/drm_drv.c
diff options
context:
space:
mode:
Diffstat (limited to 'bsd-core/drm_drv.c')
-rw-r--r--bsd-core/drm_drv.c683
1 files changed, 264 insertions, 419 deletions
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index 4e82ef81..b40bf1e4 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -30,173 +30,105 @@
*
*/
-/*
- * To use this template, you must at least define the following (samples
- * given for the MGA driver):
- *
- * #define DRIVER_AUTHOR "VA Linux Systems, Inc."
- *
- * #define DRIVER_NAME "mga"
- * #define DRIVER_DESC "Matrox G200/G400"
- * #define DRIVER_DATE "20001127"
- *
- * #define DRIVER_MAJOR 2
- * #define DRIVER_MINOR 0
- * #define DRIVER_PATCHLEVEL 2
- *
- * #define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( mga_ioctls )
- *
- * #define DRM(x) mga_##x
- */
-
-#ifndef __MUST_HAVE_AGP
-#define __MUST_HAVE_AGP 0
-#endif
-#ifndef __HAVE_CTX_BITMAP
-#define __HAVE_CTX_BITMAP 0
-#endif
-#ifndef __HAVE_IRQ
-#define __HAVE_IRQ 0
-#endif
-#ifndef __HAVE_DMA_QUEUE
-#define __HAVE_DMA_QUEUE 0
-#endif
-#ifndef __HAVE_DMA_SCHEDULE
-#define __HAVE_DMA_SCHEDULE 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
-#ifndef __HAVE_SG
-#define __HAVE_SG 0
-#endif
-
-#ifndef DRIVER_IOCTLS
-#define DRIVER_IOCTLS
-#endif
-#ifndef DRIVER_FOPS
-#endif
+#include "drmP.h"
+#include "drm.h"
#if 1 && DRM_DEBUG_CODE
-int DRM(flags) = DRM_FLAG_DEBUG;
+int drm_flags = DRM_FLAG_DEBUG;
#else
-int DRM(flags) = 0;
+int drm_flags = 0;
#endif
-static int DRM(init)(device_t nbdev);
-static void DRM(cleanup)(drm_device_t *dev);
+static int drm_init(device_t nbdev);
+static void drm_cleanup(drm_device_t *dev);
#ifdef __FreeBSD__
#define DRIVER_SOFTC(unit) \
- ((drm_device_t *) devclass_get_softc(DRM(devclass), unit))
+ ((drm_device_t *)devclass_get_softc(drm_devclass, unit))
-#if __REALLY_HAVE_AGP
-MODULE_DEPEND(DRIVER_NAME, agp, 1, 1, 1);
-#endif
+MODULE_VERSION(drm, 1);
+MODULE_DEPEND(drm, agp, 1, 1, 1);
+MODULE_DEPEND(drm, pci, 1, 1, 1);
#endif /* __FreeBSD__ */
#ifdef __NetBSD__
#define DRIVER_SOFTC(unit) \
- ((drm_device_t *) device_lookup(&DRM(cd), unit))
+ ((drm_device_t *)device_lookup(&drm_cd, unit))
#endif /* __NetBSD__ */
-static 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 },
-#if __HAVE_IRQ
- [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_by_busid), 0, 1 },
-#endif
- [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = { DRM(setversion), 0, 1 },
-
- [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(noop), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(noop), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 },
-
- [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 },
-
-#if __HAVE_CTX_BITMAP
- [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { DRM(setsareactx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { DRM(getsareactx), 1, 0 },
-#endif
-
- [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { DRM(addctx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { DRM(rmctx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { DRM(modctx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { DRM(getctx), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { DRM(switchctx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { DRM(newctx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { DRM(resctx), 1, 0 },
-
- [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { DRM(adddraw), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { DRM(rmdraw), 1, 1 },
-
- [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 },
-
-#if __HAVE_DMA
- [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { DRM(markbufs), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { DRM(infobufs), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { DRM(mapbufs), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { DRM(freebufs), 1, 0 },
+static drm_ioctl_desc_t drm_ioctls[256] = {
+ [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 },
+ [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_by_busid, 0, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { drm_getmap, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { drm_getclient, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { drm_getstats, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = { drm_setversion, 0, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_noop, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_noop, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { drm_rmmap, 1, 0 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { drm_setsareactx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { drm_getsareactx, 1, 0 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { drm_addctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { drm_rmctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { drm_modctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { drm_getctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { drm_switchctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { drm_newctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { drm_resctx, 1, 0 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { drm_lock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { drm_unlock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_noop, 1, 0 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { drm_addbufs, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { drm_mapbufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 },
/* The DRM_IOCTL_DMA ioctl should be defined by the driver. */
-#endif
-#if __HAVE_IRQ || __HAVE_DMA
- [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 },
-#endif
+ [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { drm_control, 1, 1 },
-#if __REALLY_HAVE_AGP
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { DRM(agp_release), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { DRM(agp_enable), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { DRM(agp_info), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { DRM(agp_alloc), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { DRM(agp_free), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { DRM(agp_bind), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 },
-#endif
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { drm_agp_acquire, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { drm_agp_release, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { drm_agp_enable, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { drm_agp_info, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { drm_agp_alloc, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 },
-#if __HAVE_SG
- [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { DRM(sg_alloc), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { DRM(sg_free), 1, 1 },
-#endif
+ [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { drm_sg_alloc, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { drm_sg_free, 1, 1 },
-#if __HAVE_VBL_IRQ
- [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 },
-#endif
-
- DRIVER_IOCTLS
+ [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { drm_wait_vblank, 0, 0 },
};
-#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( DRM(ioctls) )
-
-const char *DRM(find_description)(int vendor, int device);
+const char *drm_find_description(int vendor, int device, drm_pci_id_list_t *idlist);
#ifdef __FreeBSD__
-static struct cdevsw DRM(cdevsw) = {
+static struct cdevsw drm_cdevsw = {
#if __FreeBSD_version >= 502103
.d_version = D_VERSION,
#endif
- .d_open = DRM( open ),
- .d_close = DRM( close ),
- .d_read = DRM( read ),
- .d_ioctl = DRM( ioctl ),
- .d_poll = DRM( poll ),
- .d_mmap = DRM( mmap ),
- .d_name = DRIVER_NAME,
+ .d_open = drm_open,
+ .d_close = drm_close,
+ .d_read = drm_read,
+ .d_ioctl = drm_ioctl,
+ .d_poll = drm_poll,
+ .d_mmap = drm_mmap,
+ .d_name = "drm",
#if __FreeBSD_version >= 502103
.d_flags = D_TRACKCLOSE | D_NEEDGIANT,
#else
@@ -208,13 +140,7 @@ static struct cdevsw DRM(cdevsw) = {
#endif
};
-#include "drm_pciids.h"
-
-static drm_pci_id_list_t DRM(pciidlist)[] = {
- DRM(PCI_IDS)
-};
-
-static int DRM(probe)(device_t dev)
+int drm_probe(device_t dev, drm_pci_id_list_t *idlist)
{
const char *s = NULL;
int pciid, vendor, device;
@@ -228,7 +154,7 @@ static int DRM(probe)(device_t dev)
vendor = (pciid & 0x0000ffff);
device = (pciid & 0xffff0000) >> 16;
- s = DRM(find_description)(vendor, device);
+ s = drm_find_description(vendor, device, idlist);
if (s != NULL) {
device_set_desc(dev, s);
return 0;
@@ -237,72 +163,58 @@ static int DRM(probe)(device_t dev)
return ENXIO;
}
-static int DRM(attach)(device_t dev)
+int drm_attach(device_t dev, drm_pci_id_list_t *idlist)
{
- return DRM(init)(dev);
+ return drm_init(dev);
}
-static int DRM(detach)(device_t dev)
+int drm_detach(device_t dev)
{
- DRM(cleanup)(device_get_softc(dev));
+ drm_cleanup(device_get_softc(dev));
return 0;
}
-static device_method_t DRM(methods)[] = {
- /* Device interface */
- DEVMETHOD(device_probe, DRM(probe)),
- DEVMETHOD(device_attach, DRM(attach)),
- DEVMETHOD(device_detach, DRM(detach)),
-
- { 0, 0 }
-};
#ifndef DRM_DEV_NAME
#define DRM_DEV_NAME "drm"
#endif
-static driver_t DRM(driver) = {
- DRM_DEV_NAME,
- DRM(methods),
- sizeof(drm_device_t),
-};
-
-static devclass_t DRM(devclass);
+devclass_t drm_devclass;
#elif defined(__NetBSD__)
-static struct cdevsw DRM(cdevsw) = {
- DRM(open),
- DRM(close),
- DRM(read),
+static struct cdevsw drm_cdevsw = {
+ drm_open,
+ drm_close,
+ drm_read,
nowrite,
- DRM(ioctl),
+ drm_ioctl,
nostop,
notty,
- DRM(poll),
- DRM(mmap),
+ drm_poll,
+ drm_mmap,
nokqfilter,
D_TTY
};
-int DRM(refcnt) = 0;
+int drm_refcnt = 0;
#if __NetBSD_Version__ >= 106080000
-MOD_DEV( DRIVER_NAME, DRIVER_NAME, NULL, -1, &DRM(cdevsw), CDEV_MAJOR);
+MOD_DEV("drm", DRIVER_NAME, NULL, -1, &drm_cdevsw, CDEV_MAJOR);
#else
-MOD_DEV( DRIVER_NAME, LM_DT_CHAR, CDEV_MAJOR, &DRM(cdevsw) );
+MOD_DEV("drm", LM_DT_CHAR, CDEV_MAJOR, &drm_cdevsw);
#endif
-int DRM(lkmentry)(struct lkm_table *lkmtp, int cmd, int ver);
-static int DRM(lkmhandle)(struct lkm_table *lkmtp, int cmd);
+int drm_lkmentry(struct lkm_table *lkmtp, int cmd, int ver);
+static int drm_lkmhandle(struct lkm_table *lkmtp, int cmd);
-int DRM(modprobe)();
-int DRM(probe)(struct pci_attach_args *pa);
-void DRM(attach)(struct pci_attach_args *pa, dev_t kdev);
+int drm_modprobe();
+int drm_probe(struct pci_attach_args *pa);
+void drm_attach(struct pci_attach_args *pa, dev_t kdev);
-int DRM(lkmentry)(struct lkm_table *lkmtp, int cmd, int ver) {
- DISPATCH(lkmtp, cmd, ver, DRM(lkmhandle), DRM(lkmhandle), DRM(lkmhandle));
+int drm_lkmentry(struct lkm_table *lkmtp, int cmd, int ver) {
+ DISPATCH(lkmtp, cmd, ver, drm_lkmhandle, drm_lkmhandle, drm_lkmhandle);
}
-static int DRM(lkmhandle)(struct lkm_table *lkmtp, int cmd)
+static int drm_lkmhandle(struct lkm_table *lkmtp, int cmd)
{
int j, error = 0;
#if defined(__NetBSD__) && (__NetBSD_Version__ > 106080000)
@@ -314,13 +226,13 @@ static int DRM(lkmhandle)(struct lkm_table *lkmtp, int cmd)
if (lkmexists(lkmtp))
return EEXIST;
- if(DRM(modprobe)())
+ if(drm_modprobe())
return 0;
return 1;
case LKM_E_UNLOAD:
- if (DRM(refcnt) > 0)
+ if (drm_refcnt > 0)
return (EBUSY);
break;
case LKM_E_STAT:
@@ -334,21 +246,23 @@ static int DRM(lkmhandle)(struct lkm_table *lkmtp, int cmd)
return error;
}
-int DRM(modprobe)() {
+int drm_modprobe() {
struct pci_attach_args pa;
- int error = 0;
- if((error = pci_find_device(&pa, DRM(probe))) != 0)
- DRM(attach)(&pa, 0);
+ int error;
+
+ error = pci_find_device(&pa, drm_probe, idlist);
+ if (error != 0)
+ drm_attach(&pa, 0);
return error;
}
-int DRM(probe)(struct pci_attach_args *pa)
+int drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t idlist)
{
const char *desc;
- desc = DRM(find_description)(PCI_VENDOR(pa->pa_id),
- PCI_PRODUCT(pa->pa_id));
+ desc = drm_find_description(PCI_VENDOR(pa->pa_id),
+ PCI_PRODUCT(pa->pa_id), idlist);
if (desc != NULL) {
return 1;
}
@@ -356,30 +270,31 @@ int DRM(probe)(struct pci_attach_args *pa)
return 0;
}
-void DRM(attach)(struct pci_attach_args *pa, dev_t kdev)
+void drm_attach(struct pci_attach_args *pa, dev_t kdev,
+ drm_pci_id_list_t *idlist)
{
int i;
drm_device_t *dev;
- config_makeroom(kdev, &DRM(cd));
- DRM(cd).cd_devs[(kdev)] = DRM(alloc)(sizeof(drm_device_t),
+ config_makeroom(kdev, &drm_cd);
+ drm_cd.cd_devs[(kdev)] = drm_alloc(sizeof(drm_device_t),
DRM_MEM_DRIVER);
dev = DRIVER_SOFTC(kdev);
memset(dev, 0, sizeof(drm_device_t));
memcpy(&dev->pa, pa, sizeof(dev->pa));
- DRM_INFO("%s", DRM(find_description)(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id)));
- DRM(init)(dev);
+ DRM_INFO("%s", drm_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), idlist));
+ drm_init(dev);
}
-int DRM(detach)(struct device *self, int flags)
+int drm_detach(struct device *self, int flags)
{
- DRM(cleanup)((drm_device_t *)self);
+ drm_cleanup((drm_device_t *)self);
return 0;
}
-int DRM(activate)(struct device *self, enum devact act)
+int drm_activate(struct device *self, enum devact act)
{
switch (act) {
case DVACT_ACTIVATE:
@@ -394,73 +309,43 @@ int DRM(activate)(struct device *self, enum devact act)
}
#endif /* __NetBSD__ */
-const char *DRM(find_description)(int vendor, int device) {
+const char *drm_find_description(int vendor, int device, drm_pci_id_list_t *idlist) {
int i = 0;
- for (i = 0; DRM(pciidlist)[i].vendor != 0; i++) {
- if ((DRM(pciidlist)[i].vendor == vendor) &&
- (DRM(pciidlist)[i].device == device)) {
- return DRM(pciidlist)[i].name;
+ for (i = 0; idlist[i].vendor != 0; i++) {
+ if ((idlist[i].vendor == vendor) &&
+ (idlist[i].device == device)) {
+ return idlist[i].name;
}
}
return NULL;
}
/* Initialize the DRM on first open. */
-static int DRM(setup)( drm_device_t *dev )
+static int drm_setup(drm_device_t *dev)
{
int i;
DRM_SPINLOCK_ASSERT(&dev->dev_lock);
- if (dev->fn_tbl.presetup)
- dev->fn_tbl.presetup(dev);
+ if (dev->presetup)
+ dev->presetup(dev);
dev->buf_use = 0;
-#if __HAVE_DMA
- i = DRM(dma_setup)( dev );
- if ( i != 0 )
- return i;
-#endif
+ if (dev->use_dma) {
+ i = drm_dma_setup(dev);
+ if (i != 0)
+ return i;
+ }
- dev->counters = 6 + __HAVE_COUNTERS;
+ dev->counters = 6;
dev->types[0] = _DRM_STAT_LOCK;
dev->types[1] = _DRM_STAT_OPENS;
dev->types[2] = _DRM_STAT_CLOSES;
dev->types[3] = _DRM_STAT_IOCTLS;
dev->types[4] = _DRM_STAT_LOCKS;
dev->types[5] = _DRM_STAT_UNLOCKS;
-#ifdef __HAVE_COUNTER6
- dev->types[6] = __HAVE_COUNTER6;
-#endif
-#ifdef __HAVE_COUNTER7
- dev->types[7] = __HAVE_COUNTER7;
-#endif
-#ifdef __HAVE_COUNTER8
- dev->types[8] = __HAVE_COUNTER8;
-#endif
-#ifdef __HAVE_COUNTER9
- dev->types[9] = __HAVE_COUNTER9;
-#endif
-#ifdef __HAVE_COUNTER10
- dev->types[10] = __HAVE_COUNTER10;
-#endif
-#ifdef __HAVE_COUNTER11
- dev->types[11] = __HAVE_COUNTER11;
-#endif
-#ifdef __HAVE_COUNTER12
- dev->types[12] = __HAVE_COUNTER12;
-#endif
-#ifdef __HAVE_COUNTER13
- dev->types[13] = __HAVE_COUNTER13;
-#endif
-#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 );
@@ -485,14 +370,14 @@ static int DRM(setup)( drm_device_t *dev )
DRM_DEBUG( "\n" );
- if (dev->fn_tbl.postsetup)
- dev->fn_tbl.postsetup(dev);
+ if (dev->postsetup)
+ dev->postsetup(dev);
return 0;
}
/* Free resources associated with the DRM on the last close. */
-static int DRM(takedown)( drm_device_t *dev )
+static int drm_takedown(drm_device_t *dev)
{
drm_magic_entry_t *pt, *next;
drm_local_map_t *map;
@@ -503,17 +388,15 @@ static int DRM(takedown)( drm_device_t *dev )
DRM_DEBUG( "\n" );
- if (dev->fn_tbl.pretakedown)
- dev->fn_tbl.pretakedown(dev);
+ if (dev->pretakedown != NULL)
+ dev->pretakedown(dev);
-#if __HAVE_IRQ
if (dev->irq_enabled)
- DRM(irq_uninstall)( dev );
-#endif
+ drm_irq_uninstall(dev);
if ( dev->unique ) {
- DRM(free)( dev->unique, strlen( dev->unique ) + 1,
- DRM_MEM_DRIVER );
+ drm_free(dev->unique, strlen( dev->unique ) + 1,
+ DRM_MEM_DRIVER);
dev->unique = NULL;
dev->unique_len = 0;
}
@@ -521,60 +404,56 @@ static int DRM(takedown)( drm_device_t *dev )
for ( i = 0 ; i < DRM_HASH_SIZE ; i++ ) {
for ( pt = dev->magiclist[i].head ; pt ; pt = next ) {
next = pt->next;
- DRM(free)( pt, sizeof(*pt), DRM_MEM_MAGIC );
+ drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
}
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
-#if __REALLY_HAVE_AGP
/* Clear AGP information */
if ( dev->agp ) {
drm_agp_mem_t *entry;
drm_agp_mem_t *nexte;
/* Remove AGP resources, but leave dev->agp
- intact until DRM(cleanup) is called. */
+ intact until drm_cleanup is called. */
for ( entry = dev->agp->memory ; entry ; entry = nexte ) {
nexte = entry->next;
- if ( entry->bound ) DRM(unbind_agp)( entry->handle );
- DRM(free_agp)( entry->handle, entry->pages );
- DRM(free)( entry, sizeof(*entry), DRM_MEM_AGPLISTS );
+ if ( entry->bound )
+ drm_unbind_agp(entry->handle);
+ drm_free_agp(entry->handle, entry->pages);
+ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
}
dev->agp->memory = NULL;
- if ( dev->agp->acquired ) DRM(agp_do_release)();
+ if (dev->agp->acquired)
+ drm_agp_do_release();
dev->agp->acquired = 0;
dev->agp->enabled = 0;
}
-#endif
-#if __REALLY_HAVE_SG
if (dev->sg != NULL) {
- DRM(sg_cleanup)(dev->sg);
+ drm_sg_cleanup(dev->sg);
dev->sg = NULL;
}
-#endif
if (dev->maplist != NULL) {
while ((list=TAILQ_FIRST(dev->maplist))) {
map = list->map;
switch ( map->type ) {
case _DRM_REGISTERS:
- DRM(ioremapfree)(map);
+ drm_ioremapfree(map);
/* FALLTHROUGH */
case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
if (map->mtrr) {
int __unused retcode;
- retcode = DRM(mtrr_del)(map->offset,
+ retcode = drm_mtrr_del(map->offset,
map->size, DRM_MTRR_WC);
DRM_DEBUG("mtrr_del = %d", retcode);
}
-#endif
break;
case _DRM_SHM:
- DRM(free)(map->handle,
+ drm_free(map->handle,
map->size,
DRM_MEM_SAREA);
break;
@@ -587,14 +466,12 @@ static int DRM(takedown)( drm_device_t *dev )
break;
}
TAILQ_REMOVE(dev->maplist, list, link);
- DRM(free)(list, sizeof(*list), DRM_MEM_MAPS);
- DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
+ drm_free(list, sizeof(*list), DRM_MEM_MAPS);
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
}
-#if __HAVE_DMA
- DRM(dma_takedown)( dev );
-#endif
+ drm_dma_takedown(dev);
if ( dev->lock.hw_lock ) {
dev->lock.hw_lock = NULL; /* SHM removed */
dev->lock.filp = NULL;
@@ -608,55 +485,40 @@ static int DRM(takedown)( drm_device_t *dev )
* linux/init/main.c (this is not currently supported).
* bsd: drm_init is called via the attach function per device.
*/
-static int DRM(init)( device_t nbdev )
+static int drm_init(device_t nbdev)
{
int unit;
-#ifdef __FreeBSD__
drm_device_t *dev;
-#elif defined(__NetBSD__)
- drm_device_t *dev = nbdev;
-#endif
-#if __HAVE_CTX_BITMAP
int retcode;
-#endif
DRM_DEBUG( "\n" );
-
+
#ifdef __FreeBSD__
unit = device_get_unit(nbdev);
dev = device_get_softc(nbdev);
- memset( (void *)dev, 0, sizeof(*dev) );
if (!strcmp(device_get_name(nbdev), "drmsub"))
dev->device = device_get_parent(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);
+ if (dev->preinit != NULL)
+ dev->preinit(dev, 0);
- dev->devnode = make_dev( &DRM(cdevsw),
+ dev->devnode = make_dev(&drm_cdevsw,
unit,
DRM_DEV_UID,
DRM_DEV_GID,
DRM_DEV_MODE,
- "dri/card%d", unit );
+ "dri/card%d", unit);
#if __FreeBSD_version >= 500000
mtx_init(&dev->dev_lock, "drm device", NULL, MTX_DEF);
#endif
#elif defined(__NetBSD__)
unit = minor(dev->device.dv_unit);
+ dev = 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);
-
+ if (dev->preinit != NULL)
+ dev->preinit(dev, 0);
#endif
dev->irq = pci_get_irq(dev->device);
@@ -666,61 +528,56 @@ static int DRM(init)( device_t nbdev )
dev->pci_slot = pci_get_slot(dev->device);
dev->pci_func = pci_get_function(dev->device);
- dev->maplist = DRM(calloc)(1, sizeof(*dev->maplist), DRM_MEM_MAPS);
+ dev->maplist = drm_calloc(1, sizeof(*dev->maplist), DRM_MEM_MAPS);
if (dev->maplist == NULL) {
retcode = ENOMEM;
goto error;
}
TAILQ_INIT(dev->maplist);
- dev->name = DRIVER_NAME;
- DRM(mem_init)();
- DRM(sysctl_init)(dev);
+ drm_mem_init();
+ drm_sysctl_init(dev);
TAILQ_INIT(&dev->files);
-#if __REALLY_HAVE_AGP
- dev->agp = DRM(agp_init)();
-#if __MUST_HAVE_AGP
- if ( dev->agp == NULL ) {
- DRM_ERROR( "Cannot initialize the agpgart module.\n" );
- retcode = DRM_ERR(ENOMEM);
- goto error;
- }
-#endif /* __MUST_HAVE_AGP */
-#if __REALLY_HAVE_MTRR
- if (dev->agp) {
- if (DRM(mtrr_add)(dev->agp->info.ai_aperture_base,
- dev->agp->info.ai_aperture_size, DRM_MTRR_WC) == 0)
- dev->agp->mtrr = 1;
+ if (dev->use_agp) {
+ dev->agp = drm_agp_init();
+ if (dev->require_agp && dev->agp == NULL) {
+ DRM_ERROR("Cannot initialize the agpgart module.\n");
+ retcode = DRM_ERR(ENOMEM);
+ goto error;
+ }
+ if (dev->agp != NULL) {
+ if (drm_mtrr_add(dev->agp->info.ai_aperture_base,
+ dev->agp->info.ai_aperture_size, DRM_MTRR_WC) == 0)
+ dev->agp->mtrr = 1;
+ }
}
-#endif /* __REALLY_HAVE_MTRR */
-#endif /* __REALLY_HAVE_AGP */
-#if __HAVE_CTX_BITMAP
- retcode = DRM(ctxbitmap_init)( dev );
- if (retcode != 0) {
- DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
- goto error;
+ if (dev->use_ctxbitmap) {
+ retcode = drm_ctxbitmap_init(dev);
+ if (retcode != 0) {
+ DRM_ERROR("Cannot allocate memory for context bitmap.\n");
+ goto error;
+ }
}
-#endif
DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n",
- DRIVER_NAME,
- DRIVER_MAJOR,
- DRIVER_MINOR,
- DRIVER_PATCHLEVEL,
- DRIVER_DATE,
+ dev->driver_name,
+ dev->driver_major,
+ dev->driver_minor,
+ dev->driver_patchlevel,
+ dev->driver_date,
unit );
- if (dev->fn_tbl.postinit)
- dev->fn_tbl.postinit(dev, 0);
+ if (dev->postinit != NULL)
+ dev->postinit(dev, 0);
return 0;
error:
- DRM(sysctl_cleanup)(dev);
+ drm_sysctl_cleanup(dev);
DRM_LOCK();
- DRM(takedown)(dev);
+ drm_takedown(dev);
DRM_UNLOCK();
#ifdef __FreeBSD__
destroy_dev(dev->devnode);
@@ -728,7 +585,7 @@ error:
mtx_destroy(&dev->dev_lock);
#endif
#endif
- DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
+ drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
return retcode;
}
@@ -736,53 +593,51 @@ error:
* bsd: drm_cleanup is called per device at module unload time.
* FIXME: NetBSD
*/
-static void DRM(cleanup)(drm_device_t *dev)
+static void drm_cleanup(drm_device_t *dev)
{
DRM_DEBUG( "\n" );
- DRM(sysctl_cleanup)( dev );
+ drm_sysctl_cleanup(dev);
#ifdef __FreeBSD__
destroy_dev(dev->devnode);
#endif
-#if __HAVE_CTX_BITMAP
- DRM(ctxbitmap_cleanup)( dev );
-#endif
-#if __REALLY_HAVE_AGP && __REALLY_HAVE_MTRR
+ if (dev->use_ctxbitmap)
+ drm_ctxbitmap_cleanup(dev);
+
if (dev->agp && dev->agp->mtrr) {
int __unused retcode;
- retcode = DRM(mtrr_del)(dev->agp->info.ai_aperture_base,
+ retcode = drm_mtrr_del(dev->agp->info.ai_aperture_base,
dev->agp->info.ai_aperture_size, DRM_MTRR_WC);
DRM_DEBUG("mtrr_del = %d", retcode);
}
-#endif
DRM_LOCK();
- DRM(takedown)( dev );
+ drm_takedown(dev);
DRM_UNLOCK();
-#if __REALLY_HAVE_AGP
if ( dev->agp ) {
- DRM(agp_uninit)();
- DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS );
+ drm_agp_uninit();
+ drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
dev->agp = NULL;
}
-#endif
- if (dev->fn_tbl.postcleanup)
- dev->fn_tbl.postcleanup(dev);
- DRM(mem_uninit)();
+ if (dev->postcleanup != NULL)
+ dev->postcleanup(dev);
+
+ drm_mem_uninit();
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
mtx_destroy(&dev->dev_lock);
#endif
- DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
+ drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
}
-int DRM(version)( DRM_IOCTL_ARGS )
+int drm_version(DRM_IOCTL_ARGS)
{
+ DRM_DEVICE;
drm_version_t version;
int len;
@@ -797,20 +652,20 @@ int DRM(version)( DRM_IOCTL_ARGS )
return DRM_ERR(EFAULT); \
}
- version.version_major = DRIVER_MAJOR;
- version.version_minor = DRIVER_MINOR;
- version.version_patchlevel = DRIVER_PATCHLEVEL;
+ version.version_major = dev->driver_major;
+ version.version_minor = dev->driver_minor;
+ version.version_patchlevel = dev->driver_patchlevel;
- DRM_COPY( version.name, DRIVER_NAME );
- DRM_COPY( version.date, DRIVER_DATE );
- DRM_COPY( version.desc, DRIVER_DESC );
+ DRM_COPY(version.name, dev->driver_name);
+ DRM_COPY(version.date, dev->driver_date);
+ DRM_COPY(version.desc, dev->driver_desc);
DRM_COPY_TO_USER_IOCTL( (drm_version_t *)data, version, sizeof(version) );
return 0;
}
-int DRM(open)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
+int drm_open(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
{
drm_device_t *dev = NULL;
int retcode = 0;
@@ -819,7 +674,7 @@ int DRM(open)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
DRM_DEBUG( "open_count = %d\n", dev->open_count );
- retcode = DRM(open_helper)(kdev, flags, fmt, p, dev);
+ retcode = drm_open_helper(kdev, flags, fmt, p, dev);
if ( !retcode ) {
atomic_inc( &dev->counts[_DRM_STAT_OPENS] );
@@ -828,14 +683,14 @@ int DRM(open)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
device_busy(dev->device);
#endif
if ( !dev->open_count++ )
- retcode = DRM(setup)( dev );
+ retcode = drm_setup(dev);
DRM_UNLOCK();
}
return retcode;
}
-int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
+int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
{
drm_file_t *priv;
DRM_DEVICE;
@@ -846,15 +701,15 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
DRM_LOCK();
- priv = DRM(find_file_by_proc)(dev, p);
+ priv = drm_find_file_by_proc(dev, p);
if (!priv) {
DRM_UNLOCK();
DRM_ERROR("can't find authenticator\n");
return EINVAL;
}
- if (dev->fn_tbl.prerelease)
- dev->fn_tbl.prerelease(dev, filp);
+ if (dev->prerelease != NULL)
+ dev->prerelease(dev, filp);
/* ========================================================
* Begin inline drm_release
@@ -873,20 +728,17 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
DRM_DEBUG("Process %d dead, freeing lock for context %d\n",
DRM_CURRENTPID,
_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
-#if __HAVE_RELEASE
- DRIVER_RELEASE();
-#endif
- DRM(lock_free)(dev,
- &dev->lock.hw_lock->lock,
- _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ if (dev->release != NULL)
+ dev->release(dev, filp);
+
+ drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
/* FIXME: may require heavy-handed reset of
hardware at this point, possibly
processed via a callback to the X
server. */
- }
-#if __HAVE_RELEASE
- else if ( dev->lock.hw_lock ) {
+ } else if (dev->release != NULL && dev->lock.hw_lock != NULL) {
/* The lock is required to reclaim buffers */
for (;;) {
if ( !dev->lock.hw_lock ) {
@@ -894,9 +746,9 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
retcode = DRM_ERR(EINTR);
break;
}
- if ( DRM(lock_take)( &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT ) ) {
- dev->lock.pid = DRM_CURRENTPID;
+ if (drm_lock_take(&dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ dev->lock.filp = filp;
dev->lock.lock_time = jiffies;
atomic_inc( &dev->counts[_DRM_STAT_LOCKS] );
break; /* Got lock */
@@ -904,7 +756,7 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
/* Contention */
#if defined(__FreeBSD__) && __FreeBSD_version > 500000
retcode = msleep((void *)&dev->lock.lock_queue,
- dev->dev_lock, PZERO | PCATCH, "drmlk2", 0);
+ &dev->dev_lock, PZERO | PCATCH, "drmlk2", 0);
#else
retcode = tsleep((void *)&dev->lock.lock_queue,
PZERO | PCATCH, "drmlk2", 0);
@@ -913,14 +765,14 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
break;
}
if (retcode == 0) {
- DRIVER_RELEASE();
- DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT );
+ dev->release(dev, filp);
+ drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT);
}
}
-#elif __HAVE_DMA
- DRM(reclaim_buffers)( dev, (void *)(uintptr_t)priv->pid );
-#endif
+
+ if (dev->use_dma)
+ drm_reclaim_buffers(dev, (void *)(uintptr_t)priv->pid);
#if defined (__FreeBSD__) && (__FreeBSD_version >= 500000)
funsetown(&dev->buf_sigio);
@@ -932,7 +784,7 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
if (--priv->refs == 0) {
TAILQ_REMOVE(&dev->files, priv, link);
- DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES );
+ drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
}
/* ========================================================
@@ -944,7 +796,7 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
device_unbusy(dev->device);
#endif
if (--dev->open_count == 0) {
- retcode = DRM(takedown)(dev);
+ retcode = drm_takedown(dev);
}
DRM_UNLOCK();
@@ -952,9 +804,9 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
return retcode;
}
-/* DRM(ioctl) is called whenever a process performs an ioctl on /dev/drm.
+/* drm_ioctl is called whenever a process performs an ioctl on /dev/drm.
*/
-int DRM(ioctl)(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
+int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
DRM_STRUCTPROC *p)
{
DRM_DEVICE;
@@ -1005,10 +857,13 @@ int DRM(ioctl)(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
#endif /* __NetBSD__ */
}
- if (nr >= DRIVER_IOCTL_COUNT || IOCGROUP(cmd) != DRM_IOCTL_BASE)
+ if (nr >= dev->max_driver_ioctl || IOCGROUP(cmd) != DRM_IOCTL_BASE)
return EINVAL;
- ioctl = &DRM(ioctls)[nr];
+ ioctl = &drm_ioctls[nr];
+ /* It's not a core DRM ioctl, try driver-specific. */
+ if (ioctl->func == NULL)
+ ioctl = &dev->driver_ioctls[nr];
func = ioctl->func;
if (func == NULL) {
@@ -1024,7 +879,7 @@ int DRM(ioctl)(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
return DRM_ERR(retcode);
}
-int DRM(lock)( DRM_IOCTL_ARGS )
+int drm_lock(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_lock_t lock;
@@ -1042,14 +897,12 @@ int DRM(lock)( DRM_IOCTL_ARGS )
lock.context, DRM_CURRENTPID,
dev->lock.hw_lock->lock, lock.flags );
-#if __HAVE_DMA_QUEUE
- if ( lock.context < 0 )
+ if (dev->use_dma_queue && lock.context < 0)
return DRM_ERR(EINVAL);
-#endif
DRM_LOCK();
for (;;) {
- if (DRM(lock_take)(&dev->lock.hw_lock->lock, lock.context)) {
+ if (drm_lock_take(&dev->lock.hw_lock->lock, lock.context)) {
dev->lock.filp = (void *)(uintptr_t)DRM_CURRENTPID;
dev->lock.lock_time = jiffies;
atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
@@ -1075,17 +928,14 @@ int DRM(lock)( DRM_IOCTL_ARGS )
/* XXX: Add signal blocking here */
-#if __HAVE_DMA_QUIESCENT
- if (lock.flags & _DRM_LOCK_QUIESCENT) {
- DRIVER_DMA_QUIESCENT();
- }
-#endif
+ if (dev->dma_quiescent != NULL && (lock.flags & _DRM_LOCK_QUIESCENT))
+ dev->dma_quiescent(dev);
return 0;
}
-int DRM(unlock)( DRM_IOCTL_ARGS )
+int drm_unlock(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_lock_t lock;
@@ -1101,14 +951,9 @@ int DRM(unlock)( DRM_IOCTL_ARGS )
atomic_inc( &dev->counts[_DRM_STAT_UNLOCKS] );
DRM_LOCK();
- DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT );
-#if __HAVE_DMA_SCHEDULE
- DRM(dma_schedule)( dev, 1 );
-#endif
+ drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT);
- if ( DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT ) ) {
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) {
DRM_ERROR( "\n" );
}
DRM_UNLOCK();
@@ -1125,21 +970,21 @@ MODULE_DEPEND(DRIVER_NAME, linux, 1, 1, 1);
#define LINUX_IOCTL_DRM_MIN 0x6400
#define LINUX_IOCTL_DRM_MAX 0x64ff
-static linux_ioctl_function_t DRM(linux_ioctl);
-static struct linux_ioctl_handler DRM(handler) = {DRM(linux_ioctl),
+static linux_ioctl_function_t drm_linux_ioctl;
+static struct linux_ioctl_handler drm_handler = {drm_linux_ioctl,
LINUX_IOCTL_DRM_MIN, LINUX_IOCTL_DRM_MAX};
-SYSINIT(DRM(register), SI_SUB_KLD, SI_ORDER_MIDDLE,
- linux_ioctl_register_handler, &DRM(handler));
-SYSUNINIT(DRM(unregister), SI_SUB_KLD, SI_ORDER_MIDDLE,
- linux_ioctl_unregister_handler, &DRM(handler));
+SYSINIT(drm_register, SI_SUB_KLD, SI_ORDER_MIDDLE,
+ linux_ioctl_register_handler, &drm_handler);
+SYSUNINIT(drm_unregister, SI_SUB_KLD, SI_ORDER_MIDDLE,
+ linux_ioctl_unregister_handler, &drm_handler);
/* The bits for in/out are switched on Linux */
#define LINUX_IOC_IN IOC_OUT
#define LINUX_IOC_OUT IOC_IN
static int
-DRM(linux_ioctl)(DRM_STRUCTPROC *p, struct linux_ioctl_args* args)
+drm_linux_ioctl(DRM_STRUCTPROC *p, struct linux_ioctl_args* args)
{
int error;
int cmd = args->cmd;