-/* $OpenBSD: drmP.h,v 1.193 2015/04/12 11:26:54 jsg Exp $ */
+/* $OpenBSD: drmP.h,v 1.194 2015/04/17 00:54:41 jsg Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
struct drm_file;
struct drm_device;
+/**
+ * Ioctl function type.
+ *
+ * \param inode device inode.
+ * \param file_priv DRM file private pointer.
+ * \param cmd command.
+ * \param arg argument.
+ */
+typedef int drm_ioctl_t(struct drm_device *dev, void *data,
+ struct drm_file *file_priv);
+
+typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
+ unsigned long arg);
+
+#define DRM_AUTH 0x1
+#define DRM_MASTER 0x2
+#define DRM_ROOT_ONLY 0x4
+#define DRM_CONTROL_ALLOW 0x8
+#define DRM_UNLOCKED 0x10
+
+struct drm_ioctl_desc {
+ unsigned int cmd;
+ int flags;
+ drm_ioctl_t *func;
+ unsigned int cmd_drv;
+};
+
+/**
+ * Creates a driver or general drm_ioctl_desc array entry for the given
+ * ioctl, for use by drm_ioctl().
+ */
+
+#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
+ [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl}
+
struct drm_buf {
int idx; /* Index into master buflist */
int total; /* Buffer size */
struct drm_driver_info {
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 (*close)(struct drm_device *, struct drm_file *);
void (*lastclose)(struct drm_device *);
struct uvm_object *(*mmap)(struct drm_device *, voff_t, vsize_t);
const char *desc; /* Longer driver name */
const char *date; /* Date of last major changes. */
+ struct drm_ioctl_desc *ioctls;
+ int num_ioctls;
+
#define DRIVER_AGP 0x1
#define DRIVER_AGP_REQUIRE 0x2
#define DRIVER_MTRR 0x4
-/* $OpenBSD: drm_drv.c,v 1.134 2015/04/15 09:48:18 kettenis Exp $ */
+/* $OpenBSD: drm_drv.c,v 1.135 2015/04/17 00:54:41 jsg Exp $ */
/*-
* Copyright 2007-2009 Owain G. Ainsworth <oga@openbsd.org>
* Copyright © 2008 Intel Corporation
int drm_fault(struct uvm_faultinfo *, vaddr_t, vm_page_t *, int, int,
vm_fault_t, vm_prot_t, int);
boolean_t drm_flush(struct uvm_object *, voff_t, voff_t, int);
+int drm_setunique(struct drm_device *, void *, struct drm_file *);
+int drm_noop(struct drm_device *, void *, struct drm_file *);
SPLAY_PROTOTYPE(drm_obj_tree, drm_handle, entry, drm_handle_cmp);
SPLAY_PROTOTYPE(drm_name_tree, drm_gem_object, entry, drm_name_cmp);
int drm_getcap(struct drm_device *, void *, struct drm_file *);
+#define DRM_IOCTL_DEF(ioctl, _func, _flags) \
+ [DRM_IOCTL_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, .cmd_drv = 0}
+
+/** Ioctl table */
+static struct drm_ioctl_desc drm_ioctls[] = {
+ DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, DRM_UNLOCKED),
+ 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),
+#ifdef __linux__
+ DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, DRM_UNLOCKED),
+#endif
+ DRM_IOCTL_DEF(DRM_IOCTL_GET_CAP, drm_getcap, DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_SET_VERSION, drm_setversion, DRM_MASTER),
+
+ 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),
+
+#ifdef __linux__
+ 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_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH),
+#else
+ 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),
+#endif
+
+#ifdef __linux__
+ DRM_IOCTL_DEF(DRM_IOCTL_SET_MASTER, drm_setmaster_ioctl, DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_DROP_MASTER, drm_dropmaster_ioctl, DRM_ROOT_ONLY),
+
+ DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|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_modctx, 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_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_newctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+#else
+ DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ 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),
+#endif
+#ifdef __linux__
+ DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH),
+#endif
+
+ DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+
+#ifdef __linux__
+ DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH),
+#endif
+
+ DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
+
+#ifdef __linux__
+ DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH),
+#else
+ DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_noop, DRM_AUTH),
+#endif
+#ifdef __linux__
+ DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH),
+ DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH),
+ /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */
+ DRM_IOCTL_DEF(DRM_IOCTL_DMA, NULL, DRM_AUTH),
+#endif
+
+ DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+
+#if defined(__linux__) && defined(__OS_HAS_AGP)
+ 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),
+#endif
+
+#ifdef __linux__
+ 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),
+#endif
+
+ DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, DRM_UNLOCKED),
+
+ DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0),
+
+ DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+
+ DRM_IOCTL_DEF(DRM_IOCTL_GEM_CLOSE, drm_gem_close_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_GEM_FLINK, drm_gem_flink_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_GEM_OPEN, drm_gem_open_ioctl, DRM_AUTH|DRM_UNLOCKED),
+
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+
+#ifdef notyet
+ DRM_IOCTL_DEF(DRM_IOCTL_PRIME_HANDLE_TO_FD, drm_prime_handle_to_fd_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_PRIME_FD_TO_HANDLE, drm_prime_fd_to_handle_ioctl, DRM_AUTH|DRM_UNLOCKED),
+#endif
+
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANERESOURCES, drm_mode_getplane_res, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANE, drm_mode_getplane, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPLANE, drm_mode_setplane, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR, drm_mode_cursor_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETGAMMA, drm_mode_gamma_get_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETGAMMA, drm_mode_gamma_set_ioctl, DRM_MASTER|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETENCODER, drm_mode_getencoder, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCONNECTOR, drm_mode_getconnector, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATTACHMODE, drm_mode_attachmode_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_DETACHMODE, drm_mode_detachmode_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPERTY, drm_mode_getproperty_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPROPERTY, drm_mode_connector_property_set_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB2, drm_mode_addfb2, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_PAGE_FLIP, drm_mode_page_flip_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_DIRTYFB, drm_mode_dirtyfb_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_CREATE_DUMB, drm_mode_create_dumb_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_MAP_DUMB, drm_mode_mmap_dumb_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_DESTROY_DUMB, drm_mode_destroy_dumb_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_OBJ_GETPROPERTIES, drm_mode_obj_get_properties_ioctl, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_MODE_OBJ_SETPROPERTY, drm_mode_obj_set_property_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+};
+
+#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
+
+int
+drm_setunique(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ /*
+ * Deprecated in DRM version 1.1, and will return EBUSY
+ * when setversion has
+ * requested version 1.1 or greater.
+ */
+ return (-EBUSY);
+}
+
+/** No-op ioctl. */
+int drm_noop(struct drm_device *dev, void *data,
+ struct drm_file *file_priv)
+{
+ return 0;
+}
+
/*
* attach drm to a pci-based driver.
*
drm_do_ioctl(struct drm_device *dev, int minor, u_long cmd, caddr_t data)
{
struct drm_file *file_priv;
+ struct drm_ioctl_desc *ioctl;
+ drm_ioctl_t *func;
+ unsigned int nr = DRM_IOCTL_NR(cmd);
+ int retcode = -EINVAL;
+ unsigned int usize, asize;
mutex_lock(&dev->struct_mutex);
file_priv = drm_find_file_by_minor(dev, minor);
mutex_unlock(&dev->struct_mutex);
if (file_priv == NULL) {
DRM_ERROR("can't find authenticator\n");
- return EINVAL;
+ return -EINVAL;
}
++file_priv->ioctl_count;
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_WAIT_VBLANK:
- return -drm_wait_vblank(dev, data, file_priv);
- case DRM_IOCTL_MODESET_CTL:
- return -drm_modeset_ctl(dev, data, file_priv);
- case DRM_IOCTL_GEM_CLOSE:
- return -drm_gem_close_ioctl(dev, data, file_priv);
-
- /*
- * 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);
}
- if (file_priv->authenticated == 1) {
- switch (cmd) {
- case DRM_IOCTL_GEM_FLINK:
- return -drm_gem_flink_ioctl(dev, data, file_priv);
- case DRM_IOCTL_GEM_OPEN:
- return -drm_gem_open_ioctl(dev, data, file_priv);
- case DRM_IOCTL_GET_CAP:
- return -drm_getcap(dev, data, file_priv);
- }
+ if ((nr >= DRM_CORE_IOCTL_COUNT) &&
+ ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END)))
+ return (-EINVAL);
+ if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_END) &&
+ (nr < DRM_COMMAND_BASE + dev->driver->num_ioctls)) {
+ uint32_t drv_size;
+ ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE];
+ drv_size = IOCPARM_LEN(ioctl->cmd_drv);
+ usize = asize = IOCPARM_LEN(cmd);
+ if (drv_size > asize)
+ asize = drv_size;
+ } else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) {
+ uint32_t drv_size;
+ ioctl = &drm_ioctls[nr];
+
+ drv_size = IOCPARM_LEN(ioctl->cmd_drv);
+ usize = asize = IOCPARM_LEN(cmd);
+ if (drv_size > asize)
+ asize = drv_size;
+ cmd = ioctl->cmd;
+ } else
+ return (-EINVAL);
+
+ func = ioctl->func;
+ if (!func) {
+ 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_AUTH_MAGIC:
- return -drm_authmagic(dev, data, file_priv);
- case DRM_IOCTL_CONTROL:
- return -drm_control(dev, data, file_priv);
- case DRM_IOCTL_ADD_DRAW:
- case DRM_IOCTL_RM_DRAW:
- case DRM_IOCTL_UPDATE_DRAW:
- /*
- * Support removed from kernel since it's not used.
- * just return zero until userland stops calling this
- * ioctl.
- */
- return (0);
- case DRM_IOCTL_SET_UNIQUE:
- /*
- * Deprecated in DRM version 1.1, and will return EBUSY
- * when setversion has
- * requested version 1.1 or greater.
- */
- return (EBUSY);
- case DRM_IOCTL_MODE_GETRESOURCES:
- return -drm_mode_getresources(dev, data, file_priv);
- case DRM_IOCTL_MODE_GETPLANERESOURCES:
- return -drm_mode_getplane_res(dev, data, file_priv);
- case DRM_IOCTL_MODE_GETCRTC:
- return -drm_mode_getcrtc(dev, data, file_priv);
- case DRM_IOCTL_MODE_SETCRTC:
- return -drm_mode_setcrtc(dev, data, file_priv);
- case DRM_IOCTL_MODE_GETPLANE:
- return -drm_mode_getplane(dev, data, file_priv);
- case DRM_IOCTL_MODE_SETPLANE:
- return -drm_mode_setplane(dev, data, file_priv);
- case DRM_IOCTL_MODE_CURSOR:
- return -drm_mode_cursor_ioctl(dev, data, file_priv);
- case DRM_IOCTL_MODE_GETGAMMA:
- return -drm_mode_gamma_get_ioctl(dev, data, file_priv);
- case DRM_IOCTL_MODE_SETGAMMA:
- return -drm_mode_gamma_set_ioctl(dev, data, file_priv);
- case DRM_IOCTL_MODE_GETENCODER:
- return -drm_mode_getencoder(dev, data, file_priv);
- case DRM_IOCTL_MODE_GETCONNECTOR:
- return -drm_mode_getconnector(dev, data, file_priv);
- case DRM_IOCTL_MODE_ATTACHMODE:
- return -drm_mode_attachmode_ioctl(dev, data, file_priv);
- case DRM_IOCTL_MODE_DETACHMODE:
- return -drm_mode_detachmode_ioctl(dev, data, file_priv);
- case DRM_IOCTL_MODE_GETPROPERTY:
- return -drm_mode_getproperty_ioctl(dev, data,
- file_priv);
- case DRM_IOCTL_MODE_SETPROPERTY:
- return -drm_mode_connector_property_set_ioctl(dev,
- data, file_priv);
- case DRM_IOCTL_MODE_GETPROPBLOB:
- return -drm_mode_getblob_ioctl(dev, data, file_priv);
- case DRM_IOCTL_MODE_GETFB:
- return -drm_mode_getfb(dev, data, file_priv);
- case DRM_IOCTL_MODE_ADDFB:
- return -drm_mode_addfb(dev, data, file_priv);
- case DRM_IOCTL_MODE_ADDFB2:
- return -drm_mode_addfb2(dev, data, file_priv);
- case DRM_IOCTL_MODE_RMFB:
- return -drm_mode_rmfb(dev, data, file_priv);
- case DRM_IOCTL_MODE_PAGE_FLIP:
- return -drm_mode_page_flip_ioctl(dev, data, file_priv);
- case DRM_IOCTL_MODE_DIRTYFB:
- return -drm_mode_dirtyfb_ioctl(dev, data, file_priv);
- case DRM_IOCTL_MODE_CREATE_DUMB:
- return -drm_mode_create_dumb_ioctl(dev, data,
- file_priv);
- case DRM_IOCTL_MODE_MAP_DUMB:
- return -drm_mode_mmap_dumb_ioctl(dev, data, file_priv);
- case DRM_IOCTL_MODE_DESTROY_DUMB:
- return -drm_mode_destroy_dumb_ioctl(dev, data,
- file_priv);
- case DRM_IOCTL_MODE_OBJ_GETPROPERTIES:
- return -drm_mode_obj_get_properties_ioctl(dev, data,
- file_priv);
- case DRM_IOCTL_MODE_OBJ_SETPROPERTY:
- return -drm_mode_obj_set_property_ioctl(dev, data,
- file_priv);
- }
+ if (((ioctl->flags & DRM_ROOT_ONLY) && !DRM_SUSER(curproc)) ||
+ ((ioctl->flags & DRM_AUTH) && !file_priv->authenticated) ||
+ ((ioctl->flags & DRM_MASTER) && !file_priv->master))
+ return (-EACCES);
+
+ if (ioctl->flags & DRM_UNLOCKED)
+ retcode = func(dev, data, file_priv);
+ else {
+ /* XXX lock */
+ retcode = func(dev, data, file_priv);
+ /* XXX unlock */
}
- if (dev->driver->ioctl != NULL)
- return (dev->driver->ioctl(dev, cmd, data, file_priv));
- else
- return (EINVAL);
+
+ return (retcode);
}
/* drmioctl is called whenever a process performs an ioctl on /dev/drm.
dev->quiesce_count++;
mtx_leave(&dev->quiesce_mtx);
- error = drm_do_ioctl(dev, minor(kdev), cmd, data);
+ error = -drm_do_ioctl(dev, minor(kdev), cmd, data);
if (error < 0 && error != ERESTART && error != EJUSTRETURN)
printf("%s: cmd 0x%lx errno %d\n", __func__, cmd, error);
-/* $OpenBSD: i915_dma.c,v 1.19 2015/04/03 13:10:59 jsg Exp $ */
+/* $OpenBSD: i915_dma.c,v 1.20 2015/04/17 00:54:42 jsg Exp $ */
/* i915_dma.c -- DMA support for the I915 -*- linux-c -*-
*/
/*
mutex_unlock(&dev->struct_mutex);
kfree(file_priv);
}
+
+struct drm_ioctl_desc i915_ioctls[] = {
+#ifdef __linux__
+ DRM_IOCTL_DEF_DRV(I915_INIT, i915_dma_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF_DRV(I915_FLUSH, i915_flush_ioctl, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(I915_FLIP, i915_flip_bufs, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(I915_BATCHBUFFER, i915_batchbuffer, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(I915_IRQ_EMIT, i915_irq_emit, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(I915_IRQ_WAIT, i915_irq_wait, DRM_AUTH),
+#endif
+ DRM_IOCTL_DEF_DRV(I915_GETPARAM, i915_getparam, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(I915_SETPARAM, i915_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+#ifdef __linux__
+ DRM_IOCTL_DEF_DRV(I915_ALLOC, drm_noop, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(I915_FREE, drm_noop, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(I915_INIT_HEAP, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF_DRV(I915_CMDBUFFER, i915_cmdbuffer, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(I915_DESTROY_HEAP, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF_DRV(I915_SET_VBLANK_PIPE, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF_DRV(I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(I915_HWS_ADDR, i915_set_status_page, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+#endif
+ DRM_IOCTL_DEF_DRV(I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
+#ifdef __linux__
+ DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH|DRM_UNLOCKED),
+#endif
+ DRM_IOCTL_DEF_DRV(I915_GEM_EXECBUFFER2, i915_gem_execbuffer2, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_SET_CACHING, i915_gem_set_caching_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_GET_CACHING, i915_gem_get_caching_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_ENTERVT, i915_gem_entervt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_LEAVEVT, i915_gem_leavevt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_CREATE, i915_gem_create_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_PREAD, i915_gem_pread_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_PWRITE, i915_gem_pwrite_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_MMAP, i915_gem_mmap_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_MMAP_GTT, i915_gem_mmap_gtt_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_SET_TILING, i915_gem_set_tiling, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_GET_TILING, i915_gem_get_tiling, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_MADVISE, i915_gem_madvise_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_OVERLAY_ATTRS, intel_overlay_attrs, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_SET_SPRITE_COLORKEY, intel_sprite_set_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GET_SPRITE_COLORKEY, intel_sprite_get_colorkey, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_WAIT, i915_gem_wait_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_CREATE, i915_gem_context_create_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_DESTROY, i915_gem_context_destroy_ioctl, DRM_UNLOCKED),
+#ifdef __linux__
+ DRM_IOCTL_DEF_DRV(I915_REG_READ, i915_reg_read_ioctl, DRM_UNLOCKED),
+#endif
+};
+
+int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
-/* $OpenBSD: i915_drv.c,v 1.78 2015/04/12 11:26:54 jsg Exp $ */
+/* $OpenBSD: i915_drv.c,v 1.79 2015/04/17 00:54:42 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
static struct drm_driver_info inteldrm_driver = {
.buf_priv_size = 1, /* No dev_priv */
.file_priv_size = sizeof(struct inteldrm_file),
- .ioctl = inteldrm_ioctl,
.open = i915_driver_open,
.close = i915_driver_close,
.lastclose = i915_driver_lastclose,
.dumb_map_offset = i915_gem_mmap_gtt,
.dumb_destroy = i915_gem_dumb_destroy,
+ .ioctls = i915_ioctls,
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
if (dev_priv->info->gen >= 6)
inteldrm_driver.flags &= ~(DRIVER_AGP | DRIVER_AGP_REQUIRE);
+ inteldrm_driver.num_ioctls = i915_max_ioctl;
+
/* All intel chipsets need to be treated as agp, so just pass one */
dev = dev_priv->dev = (struct drm_device *)
drm_attach_pci(&inteldrm_driver, pa, 1, 1, self);
0, "inteldrm", DV_DULL
};
-int
-inteldrm_ioctl(struct drm_device *dev, u_long cmd, caddr_t data,
- struct drm_file *file_priv)
-{
- struct inteldrm_softc *dev_priv = dev->dev_private;
- int error = 0;
-
- dev_priv->entries++;
-
- error = -inteldrm_doioctl(dev, cmd, data, file_priv);
-
- dev_priv->entries--;
- return (error);
-}
-
-int
-inteldrm_doioctl(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_GETPARAM:
- return (i915_getparam(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_EXECBUFFER2:
- return (i915_gem_execbuffer2(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_BUSY:
- return (i915_gem_busy_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_THROTTLE:
- return (i915_gem_ring_throttle(dev, file_priv));
- case DRM_IOCTL_I915_GEM_MMAP:
- return (i915_gem_mmap_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_MMAP_GTT:
- return (i915_gem_mmap_gtt_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_CREATE:
- return (i915_gem_create_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_PREAD:
- return (i915_gem_pread_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_PWRITE:
- return (i915_gem_pwrite_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_SET_DOMAIN:
- return (i915_gem_set_domain_ioctl(dev, data,
- file_priv));
- case DRM_IOCTL_I915_GEM_SET_TILING:
- return (i915_gem_set_tiling(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_GET_TILING:
- return (i915_gem_get_tiling(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_GET_APERTURE:
- return (i915_gem_get_aperture_ioctl(dev, data,
- file_priv));
- case DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID:
- return (intel_get_pipe_from_crtc_id(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_MADVISE:
- return (i915_gem_madvise_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_SW_FINISH:
- return (i915_gem_sw_finish_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_SET_CACHING:
- return (i915_gem_set_caching_ioctl(dev, data,
- file_priv));
- case DRM_IOCTL_I915_GEM_GET_CACHING:
- return (i915_gem_get_caching_ioctl(dev, data,
- file_priv));
- case DRM_IOCTL_I915_GEM_WAIT:
- return (i915_gem_wait_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_CONTEXT_CREATE:
- return (i915_gem_context_create_ioctl(dev, data,
- file_priv));
- case DRM_IOCTL_I915_GEM_CONTEXT_DESTROY:
- return (i915_gem_context_destroy_ioctl(dev, data,
- file_priv));
- default:
- break;
- }
- }
-
- if (file_priv->master == 1) {
- switch (cmd) {
- case DRM_IOCTL_I915_SETPARAM:
- return (i915_setparam(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_INIT:
- return (i915_gem_init_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_ENTERVT:
- return (i915_gem_entervt_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_LEAVEVT:
- return (i915_gem_leavevt_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_PIN:
- return (i915_gem_pin_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_GEM_UNPIN:
- return (i915_gem_unpin_ioctl(dev, data, file_priv));
- case DRM_IOCTL_I915_OVERLAY_PUT_IMAGE:
- return (intel_overlay_put_image(dev, data, file_priv));
- case DRM_IOCTL_I915_OVERLAY_ATTRS:
- return (intel_overlay_attrs(dev, data, file_priv));
- case DRM_IOCTL_I915_GET_SPRITE_COLORKEY:
- return (intel_sprite_get_colorkey(dev, data, file_priv));
- case DRM_IOCTL_I915_SET_SPRITE_COLORKEY:
- return (intel_sprite_set_colorkey(dev, data, file_priv));
- }
- }
- return -EINVAL;
-}
-
void
i915_alloc_ifp(struct inteldrm_softc *dev_priv, struct pci_attach_args *bpa)
{
-/* $OpenBSD: i915_drv.h,v 1.60 2015/04/11 05:10:13 jsg Exp $ */
+/* $OpenBSD: i915_drv.h,v 1.61 2015/04/17 00:54:42 jsg Exp $ */
/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
*/
/*
#define INTEL_RC6p_ENABLE (1<<1)
#define INTEL_RC6pp_ENABLE (1<<2)
-#ifdef notyet
extern struct drm_ioctl_desc i915_ioctls[];
-#endif
extern int i915_max_ioctl;
extern unsigned int i915_fbpercrtc __always_unused;
extern int i915_panel_ignore_lid __read_mostly;
-/* $OpenBSD: i915_gem.c,v 1.91 2015/04/12 17:10:07 kettenis Exp $ */
+/* $OpenBSD: i915_gem.c,v 1.92 2015/04/17 00:54:42 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
return ret;
}
-#ifdef notyet
int
i915_gem_throttle_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
return i915_gem_ring_throttle(dev, file_priv);
}
-#endif
int
i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
-/* $OpenBSD: radeon_kms.c,v 1.37 2015/04/06 12:25:10 jsg Exp $ */
+/* $OpenBSD: radeon_kms.c,v 1.38 2015/04/17 00:54:42 jsg Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
int radeon_get_vblank_timestamp_kms(struct drm_device *, int, int *,
struct timeval *, unsigned);
-int radeondrm_ioctl_kms(struct drm_device *, u_long, caddr_t, struct drm_file *);
-int radeon_ioctl_kms(struct drm_device *, u_long, caddr_t, struct drm_file *);
int radeon_dma_ioctl_kms(struct drm_device *, struct drm_dma *, struct drm_file *);
int radeon_cp_init_kms(struct drm_device *, void *, struct drm_file *);
void radeondrm_attachhook(void *);
int radeondrm_forcedetach(struct radeon_device *);
+extern struct drm_ioctl_desc radeon_ioctls_kms[];
+extern int radeon_max_kms_ioctl;
+
struct cfattach radeondrm_ca = {
sizeof (struct radeon_device), radeondrm_probe, radeondrm_attach_kms,
radeondrm_detach_kms, radeondrm_activate_kms
DRIVER_AGP | DRIVER_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
DRIVER_IRQ | DRIVER_DMA | DRIVER_GEM | DRIVER_MODESET,
.buf_priv_size = 0,
- .ioctl = radeondrm_ioctl_kms,
.firstopen = radeon_driver_firstopen_kms,
.open = radeon_driver_open_kms,
.mmap = radeon_mmap,
.irq_postinstall = radeon_driver_irq_postinstall_kms,
.irq_uninstall = radeon_driver_irq_uninstall_kms,
.irq_handler = radeon_driver_irq_handler_kms,
+ .ioctls = radeon_ioctls_kms,
.gem_init_object = radeon_gem_object_init,
.gem_free_object = radeon_gem_object_free,
.gem_open_object = radeon_gem_object_open,
printf("\n");
+ kms_driver.num_ioctls = radeon_max_kms_ioctl;
+
dev = (struct drm_device *)drm_attach_pci(&kms_driver, pa, is_agp,
rdev->console, self);
rdev->ddev = dev;
KMS_INVALID_IOCTL(radeon_surface_alloc_kms)
KMS_INVALID_IOCTL(radeon_surface_free_kms)
-int
-radeondrm_ioctl_kms(struct drm_device *dev, u_long cmd, caddr_t data,
- struct drm_file *file_priv)
-{
- return -(radeon_ioctl_kms(dev, cmd, data, file_priv));
-}
-int
-radeon_ioctl_kms(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_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_CP_RESUME:
- return (radeon_cp_resume_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_RESET:
- return (radeon_engine_reset_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_FULLSCREEN:
- return (radeon_fullscreen_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_SWAP:
- return (radeon_cp_swap_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_CLEAR:
- return (radeon_cp_clear_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_VERTEX:
- return (radeon_cp_vertex_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_INDICES:
- return (radeon_cp_indices_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_TEXTURE:
- return (radeon_cp_texture_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_STIPPLE:
- return (radeon_cp_stipple_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_VERTEX2:
- return (radeon_cp_vertex2_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_CMDBUF:
- return (radeon_cp_cmdbuf_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GETPARAM:
- return (radeon_cp_getparam_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_FLIP:
- return (radeon_cp_flip_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_ALLOC:
- return (radeon_mem_alloc_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_FREE:
- return (radeon_mem_free_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_IRQ_EMIT:
- return (radeon_irq_emit_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_IRQ_WAIT:
- return (radeon_irq_wait_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_SETPARAM:
- return (radeon_cp_setparam_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_SURF_ALLOC:
- return (radeon_surface_alloc_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_SURF_FREE:
- return (radeon_surface_free_kms(dev, data, file_priv));
- /* KMS */
- case DRM_IOCTL_RADEON_GEM_INFO:
- return (radeon_gem_info_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GEM_CREATE:
- return (radeon_gem_create_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GEM_MMAP:
- return (radeon_gem_mmap_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GEM_SET_DOMAIN:
- return (radeon_gem_set_domain_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GEM_PREAD:
- return (radeon_gem_pread_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GEM_PWRITE:
- return (radeon_gem_pwrite_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GEM_WAIT_IDLE:
- return (radeon_gem_wait_idle_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_CS:
- return (radeon_cs_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_INFO:
- return (radeon_info_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GEM_SET_TILING:
- return (radeon_gem_set_tiling_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GEM_GET_TILING:
- return (radeon_gem_get_tiling_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GEM_BUSY:
- return (radeon_gem_busy_ioctl(dev, data, file_priv));
- case DRM_IOCTL_RADEON_GEM_VA:
- return (radeon_gem_va_ioctl(dev, data, file_priv));
- }
- }
-
- if (file_priv->master == 1) {
- switch (cmd) {
- case DRM_IOCTL_RADEON_CP_INIT:
- return (radeon_cp_init_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_CP_START:
- return (radeon_cp_start_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_CP_STOP:
- return (radeon_cp_stop_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_CP_RESET:
- return (radeon_cp_reset_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_INDIRECT:
- return (radeon_cp_indirect_kms(dev, data, file_priv));
- case DRM_IOCTL_RADEON_INIT_HEAP:
- return (radeon_mem_init_heap_kms(dev, data, file_priv));
- }
- }
- return -EINVAL;
-}
+struct drm_ioctl_desc radeon_ioctls_kms[] = {
+ DRM_IOCTL_DEF_DRV(RADEON_CP_INIT, radeon_cp_init_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF_DRV(RADEON_CP_START, radeon_cp_start_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF_DRV(RADEON_CP_STOP, radeon_cp_stop_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF_DRV(RADEON_CP_RESET, radeon_cp_reset_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF_DRV(RADEON_CP_IDLE, radeon_cp_idle_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_CP_RESUME, radeon_cp_resume_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_RESET, radeon_engine_reset_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_FULLSCREEN, radeon_fullscreen_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_SWAP, radeon_cp_swap_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_CLEAR, radeon_cp_clear_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_VERTEX, radeon_cp_vertex_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_INDICES, radeon_cp_indices_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_TEXTURE, radeon_cp_texture_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_STIPPLE, radeon_cp_stipple_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_INDIRECT, radeon_cp_indirect_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF_DRV(RADEON_VERTEX2, radeon_cp_vertex2_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_CMDBUF, radeon_cp_cmdbuf_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_GETPARAM, radeon_cp_getparam_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_FLIP, radeon_cp_flip_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_ALLOC, radeon_mem_alloc_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_FREE, radeon_mem_free_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_INIT_HEAP, radeon_mem_init_heap_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF_DRV(RADEON_IRQ_EMIT, radeon_irq_emit_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_IRQ_WAIT, radeon_irq_wait_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_SETPARAM, radeon_cp_setparam_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_SURF_ALLOC, radeon_surface_alloc_kms, DRM_AUTH),
+ DRM_IOCTL_DEF_DRV(RADEON_SURF_FREE, radeon_surface_free_kms, DRM_AUTH),
+ /* KMS */
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_INFO, radeon_gem_info_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_CREATE, radeon_gem_create_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_MMAP, radeon_gem_mmap_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_SET_DOMAIN, radeon_gem_set_domain_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_PREAD, radeon_gem_pread_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_PWRITE, radeon_gem_pwrite_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_WAIT_IDLE, radeon_gem_wait_idle_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_CS, radeon_cs_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_INFO, radeon_info_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_SET_TILING, radeon_gem_set_tiling_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_GET_TILING, radeon_gem_get_tiling_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_BUSY, radeon_gem_busy_ioctl, DRM_AUTH|DRM_UNLOCKED),
+ DRM_IOCTL_DEF_DRV(RADEON_GEM_VA, radeon_gem_va_ioctl, DRM_AUTH|DRM_UNLOCKED),
+};
+int radeon_max_kms_ioctl = DRM_ARRAY_SIZE(radeon_ioctls_kms);