diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-11-17 00:26:03 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-11-17 00:26:03 +0000 |
commit | 7a61cb25c577af4a36ec5b27e1455727d0089e69 (patch) | |
tree | 1fff1e0f50593146e2fd74baf64e3dbf1ff772a5 | |
parent | 10d050bf44a1fa9dd93575f0957ca2007dcfe655 (diff) |
rework how we handle ioctls.
Before it was based on a static array with flags. Instead, let the
driver provide an ioctl callback, which deals with things appropriately.
Makes the code a bit easier to read, and also drops just over 5k on an
amd64 kernel build with all drm drivers enabled.
Tested by a few.
-rw-r--r-- | sys/dev/pci/drm/drmP.h | 5 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_drv.c | 230 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915_drm.h | 1 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915_drv.c | 82 | ||||
-rw-r--r-- | sys/dev/pci/drm/mach64_drv.c | 63 | ||||
-rw-r--r-- | sys/dev/pci/drm/mga_drv.c | 69 | ||||
-rw-r--r-- | sys/dev/pci/drm/r128_drv.c | 81 | ||||
-rw-r--r-- | sys/dev/pci/drm/radeon_drv.c | 111 | ||||
-rw-r--r-- | sys/dev/pci/drm/savage_drv.c | 43 | ||||
-rw-r--r-- | sys/dev/pci/drm/sis_drv.c | 50 | ||||
-rw-r--r-- | sys/dev/pci/drm/tdfx_drv.c | 2 |
11 files changed, 438 insertions, 299 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index e068dfae4e9..7e27de574f6 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -452,6 +452,8 @@ struct drm_driver_info { int (*load)(struct drm_device *, unsigned long); int (*firstopen)(struct drm_device *); int (*open)(struct drm_device *, struct drm_file *); + int (*ioctl)(struct drm_device*, u_long, caddr_t, + struct drm_file *); void (*preclose)(struct drm_device *, struct drm_file *); void (*postclose)(struct drm_device *, struct drm_file *); void (*lastclose)(struct drm_device *); @@ -483,9 +485,6 @@ struct drm_driver_info { */ int (*device_is_agp) (struct drm_device * dev); - drm_ioctl_desc_t *ioctls; - int max_ioctl; - int buf_priv_size; int major; diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c index 367c317f7f7..f8c9bb48ac3 100644 --- a/sys/dev/pci/drm/drm_drv.c +++ b/sys/dev/pci/drm/drm_drv.c @@ -51,94 +51,6 @@ drm_pci_id_list_t *drm_find_description(int , int , int drm_firstopen(struct drm_device *); int drm_lastclose(struct drm_device *); -static drm_ioctl_desc_t drm_ioctls[256] = { - DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, 0), - DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), - DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0), - DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, - DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, 0), - DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, 0), - DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, 0), - DRM_IOCTL_DEF(DRM_IOCTL_SET_VERSION, drm_setversion, - DRM_MASTER|DRM_ROOT_ONLY), - - DRM_IOCTL_DEF(DRM_IOCTL_SET_UNIQUE, drm_setunique, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_BLOCK, drm_noop, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - - DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_rmmap_ioctl, DRM_AUTH), - - DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_noop, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_noop, DRM_AUTH), - - DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_noop, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_noop, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH), - - DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_adddraw, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_rmdraw, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - - DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH), - - DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs_ioctl, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_noop, DRM_AUTH|DRM_MASTER), - DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_noop, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_dma, DRM_AUTH), - - DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - - DRM_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_agp_acquire_ioctl, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_AGP_RELEASE, drm_agp_release_ioctl, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_AGP_ENABLE, drm_agp_enable_ioctl, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_AGP_INFO, drm_agp_info_ioctl, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_AGP_ALLOC, drm_agp_alloc_ioctl, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_AGP_FREE, drm_agp_free_ioctl, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_AGP_BIND, drm_agp_bind_ioctl, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_agp_unbind_ioctl, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - - DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - - DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, 0), - DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0), - DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_draw, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), -}; struct drm_device *drm_units[DRM_MAXUNITS]; @@ -598,11 +510,6 @@ drmioctl(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p) { struct drm_device *dev = drm_get_device_from_kdev(kdev); - int retcode = 0; - drm_ioctl_desc_t *ioctl; - int (*func)(struct drm_device *, void *, struct drm_file *); - int nr = DRM_IOCTL_NR(cmd); - int is_driver_ioctl = 0; struct drm_file *file_priv; if (dev == NULL) @@ -619,7 +526,7 @@ drmioctl(dev_t kdev, u_long cmd, caddr_t data, int flags, ++file_priv->ioctl_count; DRM_DEBUG("pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n", - DRM_CURRENTPID, cmd, nr, (long)&dev->device, + DRM_CURRENTPID, cmd, DRM_IOCTL_NR(cmd), (long)&dev->device, file_priv->authenticated); switch (cmd) { @@ -634,46 +541,115 @@ drmioctl(dev_t kdev, u_long cmd, caddr_t data, int flags, case TIOCGPGRP: *(int *)data = dev->buf_pgid; return 0; - } + case DRM_IOCTL_VERSION: + return (drm_version(dev, data, file_priv)); + case DRM_IOCTL_GET_UNIQUE: + return (drm_getunique(dev, data, file_priv)); + case DRM_IOCTL_GET_MAGIC: + return (drm_getmagic(dev, data, file_priv)); + case DRM_IOCTL_GET_MAP: + return (drm_getmap(dev, data, file_priv)); + case DRM_IOCTL_GET_CLIENT: + return (drm_getclient(dev, data, file_priv)); + case DRM_IOCTL_GET_STATS: + return (drm_getstats(dev, data, file_priv)); + case DRM_IOCTL_WAIT_VBLANK: + return (drm_wait_vblank(dev, data, file_priv)); + case DRM_IOCTL_MODESET_CTL: + return (drm_modeset_ctl(dev, data, file_priv)); - if (IOCGROUP(cmd) != DRM_IOCTL_BASE) { - DRM_DEBUG("Bad ioctl group 0x%x\n", (int)IOCGROUP(cmd)); - return EINVAL; + /* + * no-oped ioctls, we don't check permissions on them because + * they do nothing. they'll be removed as soon as userland is + * definitely purged + */ + case DRM_IOCTL_SET_SAREA_CTX: + case DRM_IOCTL_BLOCK: + case DRM_IOCTL_UNBLOCK: + case DRM_IOCTL_MOD_CTX: + case DRM_IOCTL_MARK_BUFS: + case DRM_IOCTL_FINISH: + case DRM_IOCTL_INFO_BUFS: + case DRM_IOCTL_SWITCH_CTX: + case DRM_IOCTL_NEW_CTX: + case DRM_IOCTL_GET_SAREA_CTX: + return (0); } - ioctl = &drm_ioctls[nr]; - /* It's not a core DRM ioctl, try driver-specific. */ - if (ioctl->func == NULL && nr >= DRM_COMMAND_BASE) { - /* The array entries begin at DRM_COMMAND_BASE ioctl nr */ - nr -= DRM_COMMAND_BASE; - if (nr > dev->driver->max_ioctl) { - DRM_DEBUG("Bad driver ioctl number, 0x%x (of 0x%x)\n", - nr, dev->driver->max_ioctl); - return EINVAL; + if (file_priv->authenticated == 1) { + switch (cmd) { + case DRM_IOCTL_RM_MAP: + return (drm_rmmap_ioctl(dev, data, file_priv)); + case DRM_IOCTL_GET_CTX: + return (drm_getctx(dev, data, file_priv)); + case DRM_IOCTL_RES_CTX: + return (drm_resctx(dev, data, file_priv)); + case DRM_IOCTL_LOCK: + return (drm_lock(dev, data, file_priv)); + case DRM_IOCTL_UNLOCK: + return (drm_unlock(dev, data, file_priv)); + case DRM_IOCTL_MAP_BUFS: + return (drm_mapbufs(dev, data, file_priv)); + case DRM_IOCTL_FREE_BUFS: + return (drm_freebufs(dev, data, file_priv)); + case DRM_IOCTL_DMA: + return (drm_dma(dev, data, file_priv)); + case DRM_IOCTL_AGP_INFO: + return (drm_agp_info_ioctl(dev, data, file_priv)); } - ioctl = &dev->driver->ioctls[nr]; - is_driver_ioctl = 1; } - func = ioctl->func; - if (func == NULL) { - DRM_DEBUG("no function\n"); - return EINVAL; + /* master is always root */ + if (file_priv->master == 1) { + switch(cmd) { + case DRM_IOCTL_SET_VERSION: + return (drm_setversion(dev, data, file_priv)); + case DRM_IOCTL_IRQ_BUSID: + return (drm_irq_by_busid(dev, data, file_priv)); + case DRM_IOCTL_SET_UNIQUE: + return (drm_setunique(dev, data, file_priv)); + case DRM_IOCTL_AUTH_MAGIC: + return (drm_authmagic(dev, data, file_priv)); + case DRM_IOCTL_ADD_MAP: + return (drm_addmap_ioctl(dev, data, file_priv)); + case DRM_IOCTL_ADD_CTX: + return (drm_addctx(dev, data, file_priv)); + case DRM_IOCTL_RM_CTX: + return (drm_rmctx(dev, data, file_priv)); + case DRM_IOCTL_ADD_DRAW: + return (drm_adddraw(dev, data, file_priv)); + case DRM_IOCTL_RM_DRAW: + return (drm_rmdraw(dev, data, file_priv)); + case DRM_IOCTL_ADD_BUFS: + return (drm_addbufs_ioctl(dev, data, file_priv)); + case DRM_IOCTL_CONTROL: + return (drm_control(dev, data, file_priv)); + case DRM_IOCTL_AGP_ACQUIRE: + return (drm_agp_acquire_ioctl(dev, data, file_priv)); + case DRM_IOCTL_AGP_RELEASE: + return (drm_agp_release_ioctl(dev, data, file_priv)); + case DRM_IOCTL_AGP_ENABLE: + return (drm_agp_enable_ioctl(dev, data, file_priv)); + case DRM_IOCTL_AGP_ALLOC: + return (drm_agp_alloc_ioctl(dev, data, file_priv)); + case DRM_IOCTL_AGP_FREE: + return (drm_agp_free_ioctl(dev, data, file_priv)); + case DRM_IOCTL_AGP_BIND: + return (drm_agp_bind_ioctl(dev, data, file_priv)); + case DRM_IOCTL_AGP_UNBIND: + return (drm_agp_unbind_ioctl(dev, data, file_priv)); + case DRM_IOCTL_SG_ALLOC: + return (drm_sg_alloc_ioctl(dev, data, file_priv)); + case DRM_IOCTL_SG_FREE: + return (drm_sg_free(dev, data, file_priv)); + case DRM_IOCTL_UPDATE_DRAW: + return (drm_update_draw(dev, data, file_priv)); + } } - - /* - * master must be root, and all ioctls that are ROOT_ONLY are - * also DRM_MASTER. - */ - if (((ioctl->flags & DRM_AUTH) && !file_priv->authenticated) || - ((ioctl->flags & DRM_MASTER) && !file_priv->master)) - return EACCES; - - retcode = func(dev, data, file_priv); - if (retcode != 0) - DRM_DEBUG(" returning %d\n", retcode); - - return retcode; + if (dev->driver->ioctl != NULL) + return (dev->driver->ioctl(dev, cmd, data, file_priv)); + else + return (EINVAL); } drm_local_map_t * diff --git a/sys/dev/pci/drm/i915_drm.h b/sys/dev/pci/drm/i915_drm.h index ffc1fd3010b..4bb0307cca0 100644 --- a/sys/dev/pci/drm/i915_drm.h +++ b/sys/dev/pci/drm/i915_drm.h @@ -175,6 +175,7 @@ typedef struct drm_i915_sarea { #define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t) #define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t) #define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t) +#define DRM_IOCTL_I915_HWS_ADDR DRM_IOW(DRM_COMMAND_BASE + DRM_I915_HWS_ADDR, drm_i915_hws_addr_t) /* Allow drivers to submit batchbuffers directly to hardware, relying * on the security mechanisms provided by hardware. diff --git a/sys/dev/pci/drm/i915_drv.c b/sys/dev/pci/drm/i915_drv.c index ee857f41c3e..e13790f372e 100644 --- a/sys/dev/pci/drm/i915_drv.c +++ b/sys/dev/pci/drm/i915_drv.c @@ -35,35 +35,19 @@ #include "i915_drv.h" #include "drm_pciids.h" +int i915drm_probe(struct device *, void *, void *); +void i915drm_attach(struct device *, struct device *, void *); +int inteldrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t i915_pciidlist[] = { i915_PCI_IDS }; -struct drm_ioctl_desc i915_ioctls[] = { - DRM_IOCTL_DEF(DRM_I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_I915_FLUSH, i915_flush_ioctl, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_FLIP, i915_flip_bufs, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_BATCHBUFFER, i915_batchbuffer, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_IRQ_EMIT, i915_irq_emit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_IRQ_WAIT, i915_irq_wait, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_GETPARAM, i915_getparam, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_SETPARAM, i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_I915_ALLOC, i915_mem_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_FREE, i915_mem_free, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_INIT_HEAP, i915_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_I915_CMDBUFFER, i915_cmdbuffer, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_DESTROY_HEAP, i915_mem_destroy_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), - DRM_IOCTL_DEF(DRM_I915_SET_VBLANK_PIPE, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), - DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ), - DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), -}; - static const struct drm_driver_info i915_driver = { .buf_priv_size = 1, /* No dev_priv */ .load = i915_driver_load, + .ioctl = inteldrm_ioctl, .preclose = i915_driver_preclose, .lastclose = i915_driver_lastclose, .device_is_agp = i915_driver_device_is_agp, @@ -75,9 +59,6 @@ static const struct drm_driver_info i915_driver = { .irq_uninstall = i915_driver_irq_uninstall, .irq_handler = i915_driver_irq_handler, - .ioctls = i915_ioctls, - .max_ioctl = DRM_ARRAY_SIZE(i915_ioctls), - .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE, @@ -92,9 +73,6 @@ static const struct drm_driver_info i915_driver = { .use_vbl_irq = 1, }; -int i915drm_probe(struct device *, void *, void *); -void i915drm_attach(struct device *, struct device *, void *); - int i915drm_probe(struct device *parent, void *match, void *aux) { @@ -120,3 +98,53 @@ struct cfattach inteldrm_ca = { struct cfdriver inteldrm_cd = { 0, "inteldrm", DV_DULL }; + +int +inteldrm_ioctl(struct drm_device *dev, u_long cmd, caddr_t data, + struct drm_file *file_priv) +{ + if (file_priv->authenticated == 1) { + switch (cmd) { + case DRM_IOCTL_I915_FLUSH: + return (i915_flush_ioctl(dev, data, file_priv)); + case DRM_IOCTL_I915_FLIP: + return (i915_flip_bufs(dev, data, file_priv)); + case DRM_IOCTL_I915_BATCHBUFFER: + return (i915_batchbuffer(dev, data, file_priv)); + case DRM_IOCTL_I915_IRQ_EMIT: + return (i915_irq_emit(dev, data, file_priv)); + case DRM_IOCTL_I915_IRQ_WAIT: + return (i915_irq_wait(dev, data, file_priv)); + case DRM_IOCTL_I915_GETPARAM: + return (i915_getparam(dev, data, file_priv)); + case DRM_IOCTL_I915_ALLOC: + return (i915_mem_alloc(dev, data, file_priv)); + case DRM_IOCTL_I915_FREE: + return (i915_mem_free(dev, data, file_priv)); + case DRM_IOCTL_I915_CMDBUFFER: + return (i915_cmdbuffer(dev, data, file_priv)); + case DRM_IOCTL_I915_GET_VBLANK_PIPE: + return (i915_vblank_pipe_get(dev, data, file_priv)); + case DRM_IOCTL_I915_VBLANK_SWAP: + return (i915_vblank_swap(dev, data, file_priv)); + } + } + + if (file_priv->master == 1) { + switch (cmd) { + case DRM_IOCTL_I915_SETPARAM: + return (i915_setparam(dev, data, file_priv)); + case DRM_IOCTL_I915_INIT: + return (i915_dma_init(dev, data, file_priv)); + case DRM_IOCTL_I915_INIT_HEAP: + return (i915_mem_init_heap(dev, data, file_priv)); + case DRM_IOCTL_I915_DESTROY_HEAP: + return (i915_mem_destroy_heap(dev, data, file_priv)); + case DRM_IOCTL_I915_HWS_ADDR: + return (i915_set_status_page(dev, data, file_priv)); + case DRM_IOCTL_I915_SET_VBLANK_PIPE: + return (0); + } + } + return (EINVAL); +} diff --git a/sys/dev/pci/drm/mach64_drv.c b/sys/dev/pci/drm/mach64_drv.c index 96bbffef44e..16ac8ed35e5 100644 --- a/sys/dev/pci/drm/mach64_drv.c +++ b/sys/dev/pci/drm/mach64_drv.c @@ -39,31 +39,18 @@ #include "mach64_drv.h" #include "drm_pciids.h" +int mach64drm_probe(struct device *, void *, void *); +void mach64drm_attach(struct device *, struct device *, void *); +int machdrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t mach64_pciidlist[] = { mach64_PCI_IDS }; -/* Interface history: - * - * 1.0 - Initial mach64 DRM - * - */ -struct drm_ioctl_desc mach64_ioctls[] = { - DRM_IOCTL_DEF(DRM_MACH64_INIT, mach64_dma_init, - DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_MACH64_CLEAR, mach64_dma_clear, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_SWAP, mach64_dma_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_IDLE, mach64_dma_idle, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_RESET, mach64_engine_reset, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_VERTEX, mach64_dma_vertex, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_BLIT, mach64_dma_blit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_FLUSH, mach64_dma_flush, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MACH64_GETPARAM, mach64_get_param, DRM_AUTH), -}; - static const struct drm_driver_info mach64_driver = { .buf_priv_size = 1, /* No dev_priv */ + .ioctl = machdrm_ioctl, .lastclose = mach64_driver_lastclose, .get_vblank_counter = mach64_get_vblank_counter, .enable_vblank = mach64_enable_vblank, @@ -74,9 +61,6 @@ static const struct drm_driver_info mach64_driver = { .irq_handler = mach64_driver_irq_handler, .dma_ioctl = mach64_dma_buffers, - .ioctls = mach64_ioctls, - .max_ioctl = DRM_ARRAY_SIZE(mach64_ioctls), - .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE, @@ -92,9 +76,6 @@ static const struct drm_driver_info mach64_driver = { .use_vbl_irq = 1, }; -int mach64drm_probe(struct device *, void *, void *); -void mach64drm_attach(struct device *, struct device *, void *); - int mach64drm_probe(struct device *parent, void *match, void *aux) { @@ -120,3 +101,37 @@ struct cfattach machdrm_ca = { struct cfdriver machdrm_cd = { 0, "machdrm", DV_DULL }; + +int +machdrm_ioctl(struct drm_device *dev, u_long cmd, caddr_t data, + struct drm_file *file_priv) +{ + if (file_priv->authenticated == 1) { + switch (cmd) { + case DRM_IOCTL_MACH64_CLEAR: + return (mach64_dma_clear(dev, data, file_priv)); + case DRM_IOCTL_MACH64_SWAP: + return (mach64_dma_swap(dev, data, file_priv)); + case DRM_IOCTL_MACH64_IDLE: + return (mach64_dma_idle(dev, data, file_priv)); + case DRM_IOCTL_MACH64_RESET: + return (mach64_engine_reset(dev, data, file_priv)); + case DRM_IOCTL_MACH64_VERTEX: + return (mach64_dma_vertex(dev, data, file_priv)); + case DRM_IOCTL_MACH64_BLIT: + return (mach64_dma_blit(dev, data, file_priv)); + case DRM_IOCTL_MACH64_FLUSH: + return (mach64_dma_flush(dev, data, file_priv)); + case DRM_IOCTL_MACH64_GETPARAM: + return (mach64_get_param(dev, data, file_priv)); + } + } + + if (file_priv->master == 1) { + switch (cmd) { + case DRM_IOCTL_MACH64_INIT: + return (mach64_dma_init(dev, data, file_priv)); + } + } + return (EINVAL); +} diff --git a/sys/dev/pci/drm/mga_drv.c b/sys/dev/pci/drm/mga_drv.c index 28041bbb409..9b1bd1bfd70 100644 --- a/sys/dev/pci/drm/mga_drv.c +++ b/sys/dev/pci/drm/mga_drv.c @@ -37,7 +37,10 @@ #include "mga_drv.h" #include "drm_pciids.h" +int mgadrm_probe(struct device *, void *, void *); +void mgadrm_attach(struct device *, struct device *, void *); int mga_driver_device_is_agp(struct drm_device * ); +int mgadrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *); /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t mga_pciidlist[] = { @@ -90,27 +93,11 @@ mga_driver_device_is_agp(struct drm_device * dev) } -struct drm_ioctl_desc mga_ioctls[] = { - DRM_IOCTL_DEF(DRM_MGA_INIT, mga_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_MGA_FLUSH, mga_dma_flush, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_RESET, mga_dma_reset, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_SWAP, mga_dma_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_CLEAR, mga_dma_clear, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_VERTEX, mga_dma_vertex, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_INDICES, mga_dma_indices, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_ILOAD, mga_dma_iload, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_BLIT, mga_dma_blit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_GETPARAM, mga_getparam, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_SET_FENCE, mga_set_fence, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_WAIT_FENCE, mga_wait_fence, DRM_AUTH), - DRM_IOCTL_DEF(DRM_MGA_DMA_BOOTSTRAP, mga_dma_bootstrap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - -}; - static const struct drm_driver_info mga_driver = { .buf_priv_size = sizeof(drm_mga_buf_priv_t), .load = mga_driver_load, .unload = mga_driver_unload, + .ioctl = mgadrm_ioctl, .lastclose = mga_driver_lastclose, .enable_vblank = mga_enable_vblank, .disable_vblank = mga_disable_vblank, @@ -123,9 +110,6 @@ static const struct drm_driver_info mga_driver = { .dma_quiescent = mga_driver_dma_quiescent, .device_is_agp = mga_driver_device_is_agp, - .ioctls = mga_ioctls, - .max_ioctl = DRM_ARRAY_SIZE(mga_ioctls), - .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE, @@ -141,8 +125,6 @@ static const struct drm_driver_info mga_driver = { .use_vbl_irq = 1, }; -int mgadrm_probe(struct device *, void *, void *); -void mgadrm_attach(struct device *, struct device *, void *); int mgadrm_probe(struct device *parent, void *match, void *aux) { @@ -167,3 +149,46 @@ struct cfattach mgadrm_ca = { struct cfdriver mgadrm_cd = { 0, "mgadrm", DV_DULL }; + +int +mgadrm_ioctl(struct drm_device *dev, u_long cmd, caddr_t data, + struct drm_file *file_priv) +{ + if (file_priv->authenticated == 1) { + switch (cmd) { + case DRM_IOCTL_MGA_FLUSH: + return (mga_dma_flush(dev, data, file_priv)); + case DRM_IOCTL_MGA_RESET: + return (mga_dma_reset(dev, data, file_priv)); + case DRM_IOCTL_MGA_SWAP: + return (mga_dma_swap(dev, data, file_priv)); + case DRM_IOCTL_MGA_CLEAR: + return (mga_dma_clear(dev, data, file_priv)); + case DRM_IOCTL_MGA_VERTEX: + return (mga_dma_vertex(dev, data, file_priv)); + case DRM_IOCTL_MGA_INDICES: + return (mga_dma_indices(dev, data, file_priv)); + case DRM_IOCTL_MGA_ILOAD: + return (mga_dma_iload(dev, data, file_priv)); + case DRM_IOCTL_MGA_BLIT: + return (mga_dma_blit(dev, data, file_priv)); + case DRM_IOCTL_MGA_GETPARAM: + return (mga_getparam(dev, data, file_priv)); + case DRM_IOCTL_MGA_SET_FENCE: + return (mga_set_fence(dev, data, file_priv)); + case DRM_IOCTL_MGA_WAIT_FENCE: + return (mga_wait_fence(dev, data, file_priv)); + } + } + + if (file_priv->master == 1) { + switch (cmd) { + case DRM_IOCTL_MGA_INIT: + return (mga_dma_init(dev, data, file_priv)); + case DRM_IOCTL_MGA_DMA_BOOTSTRAP: + return (mga_dma_bootstrap(dev, data, file_priv)); + } + } + return (EINVAL); + +} diff --git a/sys/dev/pci/drm/r128_drv.c b/sys/dev/pci/drm/r128_drv.c index ea38a097e31..95d086b95ad 100644 --- a/sys/dev/pci/drm/r128_drv.c +++ b/sys/dev/pci/drm/r128_drv.c @@ -37,33 +37,18 @@ #include "r128_drv.h" #include "drm_pciids.h" +int r128drm_probe(struct device *, void *, void *); +void r128drm_attach(struct device *, struct device *, void *); +int ragedrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t r128_pciidlist[] = { r128_PCI_IDS }; -struct drm_ioctl_desc r128_ioctls[] = { - DRM_IOCTL_DEF(DRM_R128_INIT, r128_cce_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_R128_CCE_START, r128_cce_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_R128_CCE_STOP, r128_cce_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_R128_CCE_RESET, r128_cce_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_R128_CCE_IDLE, r128_cce_idle, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_RESET, r128_engine_reset, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_FULLSCREEN, r128_fullscreen, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_SWAP, r128_cce_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_FLIP, r128_cce_flip, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_CLEAR, r128_cce_clear, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_VERTEX, r128_cce_vertex, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_INDICES, r128_cce_indices, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_BLIT, r128_cce_blit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_DEPTH, r128_cce_depth, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_STIPPLE, r128_cce_stipple, DRM_AUTH), - DRM_IOCTL_DEF(DRM_R128_INDIRECT, r128_cce_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_R128_GETPARAM, r128_getparam, DRM_AUTH), -}; - static const struct drm_driver_info r128_driver = { .buf_priv_size = sizeof(drm_r128_buf_priv_t), + .ioctl = ragedrm_ioctl, .preclose = r128_driver_preclose, .lastclose = r128_driver_lastclose, .get_vblank_counter = r128_get_vblank_counter, @@ -75,9 +60,6 @@ static const struct drm_driver_info r128_driver = { .irq_handler = r128_driver_irq_handler, .dma_ioctl = r128_cce_buffers, - .ioctls = r128_ioctls, - .max_ioctl = DRM_ARRAY_SIZE(r128_ioctls), - .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE, @@ -94,9 +76,6 @@ static const struct drm_driver_info r128_driver = { .use_vbl_irq = 1, }; -int r128drm_probe(struct device *, void *, void *); -void r128drm_attach(struct device *, struct device *, void *); - int r128drm_probe(struct device *parent, void *match, void *aux) { @@ -121,3 +100,53 @@ struct cfattach ragedrm_ca = { struct cfdriver ragedrm_cd = { 0, "ragedrm", DV_DULL }; + +int +ragedrm_ioctl(struct drm_device *dev, u_long cmd, caddr_t data, + struct drm_file *file_priv) +{ + if (file_priv->authenticated == 1) { + switch (cmd) { + case DRM_IOCTL_R128_CCE_IDLE: + return (r128_cce_idle(dev, data, file_priv)); + case DRM_IOCTL_R128_RESET: + return (r128_engine_reset(dev, data, file_priv)); + case DRM_IOCTL_R128_FULLSCREEN: + return (r128_fullscreen(dev, data, file_priv)); + case DRM_IOCTL_R128_SWAP: + return (r128_cce_swap(dev, data, file_priv)); + case DRM_IOCTL_R128_FLIP: + return (r128_cce_flip(dev, data, file_priv)); + case DRM_IOCTL_R128_CLEAR: + return (r128_cce_clear(dev, data, file_priv)); + case DRM_IOCTL_R128_VERTEX: + return (r128_cce_vertex(dev, data, file_priv)); + case DRM_IOCTL_R128_INDICES: + return (r128_cce_indices(dev, data, file_priv)); + case DRM_IOCTL_R128_BLIT: + return (r128_cce_blit(dev, data, file_priv)); + case DRM_IOCTL_R128_DEPTH: + return (r128_cce_depth(dev, data, file_priv)); + case DRM_IOCTL_R128_STIPPLE: + return (r128_cce_stipple(dev, data, file_priv)); + case DRM_IOCTL_R128_GETPARAM: + return (r128_getparam(dev, data, file_priv)); + } + } + + if (file_priv->master == 1) { + switch (cmd) { + case DRM_IOCTL_R128_INIT: + return (r128_cce_init(dev, data, file_priv)); + case DRM_IOCTL_R128_CCE_START: + return (r128_cce_start(dev, data, file_priv)); + case DRM_IOCTL_R128_CCE_STOP: + return (r128_cce_stop(dev, data, file_priv)); + case DRM_IOCTL_R128_CCE_RESET: + return (r128_cce_reset(dev, data, file_priv)); + case DRM_IOCTL_R128_INDIRECT: + return (r128_cce_indirect(dev, data, file_priv)); + } + } + return (EINVAL); +} diff --git a/sys/dev/pci/drm/radeon_drv.c b/sys/dev/pci/drm/radeon_drv.c index 227f59ed262..c3e12d2e56f 100644 --- a/sys/dev/pci/drm/radeon_drv.c +++ b/sys/dev/pci/drm/radeon_drv.c @@ -35,6 +35,10 @@ #include "radeon_drv.h" #include "drm_pciids.h" +int radeondrm_probe(struct device *, void *, void *); +void radeondrm_attach(struct device *, struct device *, void *); +int radeondrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *); + int radeon_no_wb; /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ @@ -42,42 +46,13 @@ static drm_pci_id_list_t radeon_pciidlist[] = { radeon_PCI_IDS }; -struct drm_ioctl_desc radeon_ioctls[] = { - DRM_IOCTL_DEF(DRM_RADEON_CP_INIT, radeon_cp_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_CP_START, radeon_cp_start, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_CP_STOP, radeon_cp_stop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_CP_RESET, radeon_cp_reset, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_CP_IDLE, radeon_cp_idle, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_CP_RESUME, radeon_cp_resume, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_RESET, radeon_engine_reset, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_FULLSCREEN, radeon_fullscreen, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_SWAP, radeon_cp_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_CLEAR, radeon_cp_clear, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_VERTEX, radeon_cp_vertex, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_INDICES, radeon_cp_indices, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_TEXTURE, radeon_cp_texture, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_STIPPLE, radeon_cp_stipple, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_INDIRECT, radeon_cp_indirect, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_VERTEX2, radeon_cp_vertex2, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_CMDBUF, radeon_cp_cmdbuf, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_GETPARAM, radeon_cp_getparam, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_FLIP, radeon_cp_flip, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_ALLOC, radeon_mem_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_FREE, radeon_mem_free, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_INIT_HEAP, radeon_mem_init_heap, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_RADEON_IRQ_EMIT, radeon_irq_emit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_IRQ_WAIT, radeon_irq_wait, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_SETPARAM, radeon_cp_setparam, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_SURF_ALLOC, radeon_surface_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_RADEON_SURF_FREE, radeon_surface_free, DRM_AUTH) -}; - static const struct drm_driver_info radeon_driver = { .buf_priv_size = sizeof(drm_radeon_buf_priv_t), .load = radeon_driver_load, .unload = radeon_driver_unload, .firstopen = radeon_driver_firstopen, .open = radeon_driver_open, + .ioctl = radeondrm_ioctl, .preclose = radeon_driver_preclose, .postclose = radeon_driver_postclose, .lastclose = radeon_driver_lastclose, @@ -90,9 +65,6 @@ static const struct drm_driver_info radeon_driver = { .irq_handler = radeon_driver_irq_handler, .dma_ioctl = radeon_cp_buffers, - .ioctls = radeon_ioctls, - .max_ioctl = DRM_ARRAY_SIZE(radeon_ioctls), - .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE, @@ -109,9 +81,6 @@ static const struct drm_driver_info radeon_driver = { .use_vbl_irq = 1, }; -int radeondrm_probe(struct device *, void *, void *); -void radeondrm_attach(struct device *, struct device *, void *); - int radeondrm_probe(struct device *parent, void *match, void *aux) { @@ -136,3 +105,73 @@ struct cfattach radeondrm_ca = { struct cfdriver radeondrm_cd = { NULL, "radeondrm", DV_DULL }; + +int +radeondrm_ioctl(struct drm_device *dev, u_long cmd, caddr_t data, + struct drm_file *file_priv) +{ + if (file_priv->authenticated == 1) { + switch (cmd) { + case DRM_IOCTL_RADEON_CP_IDLE: + return (radeon_cp_idle(dev, data, file_priv)); + case DRM_IOCTL_RADEON_CP_RESUME: + return (radeon_cp_resume(dev, data, file_priv)); + case DRM_IOCTL_RADEON_RESET: + return (radeon_engine_reset(dev, data, file_priv)); + case DRM_IOCTL_RADEON_FULLSCREEN: + return (radeon_fullscreen(dev, data, file_priv)); + case DRM_IOCTL_RADEON_SWAP: + return (radeon_cp_swap(dev, data, file_priv)); + case DRM_IOCTL_RADEON_CLEAR: + return (radeon_cp_clear(dev, data, file_priv)); + case DRM_IOCTL_RADEON_VERTEX: + return (radeon_cp_vertex(dev, data, file_priv)); + case DRM_IOCTL_RADEON_INDICES: + return (radeon_cp_indices(dev, data, file_priv)); + case DRM_IOCTL_RADEON_TEXTURE: + return (radeon_cp_texture(dev, data, file_priv)); + case DRM_IOCTL_RADEON_STIPPLE: + return (radeon_cp_stipple(dev, data, file_priv)); + case DRM_IOCTL_RADEON_VERTEX2: + return (radeon_cp_vertex2(dev, data, file_priv)); + case DRM_IOCTL_RADEON_CMDBUF: + return (radeon_cp_cmdbuf(dev, data, file_priv)); + case DRM_IOCTL_RADEON_GETPARAM: + return (radeon_cp_getparam(dev, data, file_priv)); + case DRM_IOCTL_RADEON_FLIP: + return (radeon_cp_flip(dev, data, file_priv)); + case DRM_IOCTL_RADEON_ALLOC: + return (radeon_mem_alloc(dev, data, file_priv)); + case DRM_IOCTL_RADEON_FREE: + return (radeon_mem_free(dev, data, file_priv)); + case DRM_IOCTL_RADEON_IRQ_EMIT: + return (radeon_irq_emit(dev, data, file_priv)); + case DRM_IOCTL_RADEON_IRQ_WAIT: + return (radeon_irq_wait(dev, data, file_priv)); + case DRM_IOCTL_RADEON_SETPARAM: + return (radeon_cp_setparam(dev, data, file_priv)); + case DRM_IOCTL_RADEON_SURF_ALLOC: + return (radeon_surface_alloc(dev, data, file_priv)); + case DRM_IOCTL_RADEON_SURF_FREE: + return (radeon_surface_free(dev, data, file_priv)); + } + } + + if (file_priv->master == 1) { + switch (cmd) { + case DRM_IOCTL_RADEON_CP_INIT: + return (radeon_cp_init(dev, data, file_priv)); + case DRM_IOCTL_RADEON_CP_START: + return (radeon_cp_start(dev, data, file_priv)); + case DRM_IOCTL_RADEON_CP_STOP: + return (radeon_cp_stop(dev, data, file_priv)); + case DRM_IOCTL_RADEON_CP_RESET: + return (radeon_cp_reset(dev, data, file_priv)); + case DRM_IOCTL_RADEON_INDIRECT: + return (radeon_cp_indirect(dev, data, file_priv)); + case DRM_IOCTL_RADEON_INIT_HEAP: + return (radeon_mem_init_heap(dev, data, file_priv)); + } + } + return (EINVAL); +} diff --git a/sys/dev/pci/drm/savage_drv.c b/sys/dev/pci/drm/savage_drv.c index 1282aa757b5..4772f381614 100644 --- a/sys/dev/pci/drm/savage_drv.c +++ b/sys/dev/pci/drm/savage_drv.c @@ -32,20 +32,15 @@ #include "savage_drv.h" #include "drm_pciids.h" +int savagedrm_probe(struct device *, void *, void *); +void savagedrm_attach(struct device *, struct device *, void *); +int savagedrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t savage_pciidlist[] = { savage_PCI_IDS }; -struct drm_ioctl_desc savage_ioctls[] = { - DRM_IOCTL_DEF(DRM_SAVAGE_BCI_INIT, savage_bci_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_SAVAGE_BCI_CMDBUF, savage_bci_cmdbuf, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_EMIT, savage_bci_event_emit, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_WAIT, savage_bci_event_wait, DRM_AUTH), -}; - -int savage_max_ioctl = DRM_ARRAY_SIZE(savage_ioctls); - static const struct drm_driver_info savage_driver = { .buf_priv_size = sizeof(drm_savage_buf_priv_t), .load = savage_driver_load, @@ -55,9 +50,6 @@ static const struct drm_driver_info savage_driver = { .reclaim_buffers_locked = savage_reclaim_buffers, .dma_ioctl = savage_bci_buffers, - .ioctls = savage_ioctls, - .max_ioctl = DRM_ARRAY_SIZE(savage_ioctls), - .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE, @@ -71,9 +63,6 @@ static const struct drm_driver_info savage_driver = { .use_dma = 1, }; -int savagedrm_probe(struct device *, void *, void *); -void savagedrm_attach(struct device *, struct device *, void *); - int savagedrm_probe(struct device *parent, void *match, void *aux) { @@ -98,3 +87,27 @@ struct cfattach savagedrm_ca = { struct cfdriver savagedrm_cd = { 0, "savagedrm", DV_DULL }; + +int +savagedrm_ioctl(struct drm_device *dev, u_long cmd, caddr_t data, + struct drm_file *file_priv) +{ + if (file_priv->authenticated == 1) { + switch (cmd) { + case DRM_IOCTL_SAVAGE_CMDBUF: + return (savage_bci_cmdbuf(dev, data, file_priv)); + case DRM_IOCTL_SAVAGE_EVENT_EMIT: + return (savage_bci_event_emit(dev, data, file_priv)); + case DRM_IOCTL_SAVAGE_EVENT_WAIT: + return (savage_bci_event_wait(dev, data, file_priv)); + } + } + + if (file_priv->master == 1) { + switch (cmd) { + case DRM_IOCTL_SAVAGE_INIT: + return (savage_bci_init(dev, data, file_priv)); + } + } + return (EINVAL); +} diff --git a/sys/dev/pci/drm/sis_drv.c b/sys/dev/pci/drm/sis_drv.c index a77125a01cf..5a5924becd1 100644 --- a/sys/dev/pci/drm/sis_drv.c +++ b/sys/dev/pci/drm/sis_drv.c @@ -31,30 +31,21 @@ #include "sis_drv.h" #include "drm_pciids.h" +int sisdrm_probe(struct device *, void *, void *); +void sisdrm_attach(struct device *, struct device *, void *); +int sisdrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *); + /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ static drm_pci_id_list_t sis_pciidlist[] = { sis_PCI_IDS }; -drm_ioctl_desc_t sis_ioctls[] = { - DRM_IOCTL_DEF(DRM_SIS_FB_ALLOC, sis_fb_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SIS_FB_FREE, sis_fb_free, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SIS_AGP_INIT, sis_ioctl_agp_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_SIS_AGP_ALLOC, sis_ioctl_agp_alloc, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SIS_AGP_FREE, sis_ioctl_agp_free, DRM_AUTH), - DRM_IOCTL_DEF(DRM_SIS_FB_INIT, sis_fb_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY) -}; - -int sis_max_ioctl = DRM_ARRAY_SIZE(sis_ioctls); - static const struct drm_driver_info sis_driver = { .buf_priv_size = 1, /* No dev_priv */ + .ioctl = sisdrm_ioctl, .context_ctor = sis_init_context, .context_dtor = sis_final_context, - .ioctls = sis_ioctls, - .max_ioctl = DRM_ARRAY_SIZE(sis_ioctls), - .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE, @@ -66,9 +57,6 @@ static const struct drm_driver_info sis_driver = { .use_mtrr = 1, }; -int sisdrm_probe(struct device *, void *, void *); -void sisdrm_attach(struct device *, struct device *, void *); - int sisdrm_probe(struct device *parent, void *match, void *aux) { @@ -93,3 +81,31 @@ struct cfattach sisdrm_ca = { struct cfdriver sisdrm_cd = { 0, "sisdrm", DV_DULL }; + +int +sisdrm_ioctl(struct drm_device *dev, u_long cmd, caddr_t data, + struct drm_file *file_priv) +{ + if (file_priv->authenticated == 1) { + switch (cmd) { + case DRM_IOCTL_SIS_FB_ALLOC: + return (sis_fb_alloc(dev, data, file_priv)); + case DRM_IOCTL_SIS_FB_FREE: + return (sis_fb_free(dev, data, file_priv)); + case DRM_IOCTL_SIS_AGP_ALLOC: + return (sis_ioctl_agp_alloc(dev, data, file_priv)); + case DRM_IOCTL_SIS_AGP_FREE: + return (sis_ioctl_agp_free(dev, data, file_priv)); + } + } + + if (file_priv->master == 1) { + switch (cmd) { + case DRM_IOCTL_SIS_AGP_INIT: + return (sis_ioctl_agp_init(dev, data, file_priv)); + case DRM_IOCTL_SIS_FB_INIT: + return (sis_fb_init(dev, data, file_priv)); + } + } + return (EINVAL); +} diff --git a/sys/dev/pci/drm/tdfx_drv.c b/sys/dev/pci/drm/tdfx_drv.c index 0a8f5b8d61d..3308621eb0a 100644 --- a/sys/dev/pci/drm/tdfx_drv.c +++ b/sys/dev/pci/drm/tdfx_drv.c @@ -44,8 +44,6 @@ static drm_pci_id_list_t tdfx_pciidlist[] = { static const struct drm_driver_info tdfx_driver = { .buf_priv_size = 1, /* No dev_priv */ - .max_ioctl = 0, - .name = DRIVER_NAME, .desc = DRIVER_DESC, .date = DRIVER_DATE, |