175 lines · c
1/*2 * Internal Header for the Direct Rendering Manager3 *4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.6 * Copyright (c) 2009-2010, Code Aurora Forum.7 * All rights reserved.8 *9 * Author: Rickard E. (Rik) Faith <faith@valinux.com>10 * Author: Gareth Hughes <gareth@valinux.com>11 *12 * Permission is hereby granted, free of charge, to any person obtaining a13 * copy of this software and associated documentation files (the "Software"),14 * to deal in the Software without restriction, including without limitation15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,16 * and/or sell copies of the Software, and to permit persons to whom the17 * Software is furnished to do so, subject to the following conditions:18 *19 * The above copyright notice and this permission notice (including the next20 * paragraph) shall be included in all copies or substantial portions of the21 * Software.22 *23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL26 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR27 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,28 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR29 * OTHER DEALINGS IN THE SOFTWARE.30 */31 32#ifndef _DRM_IOCTL_H_33#define _DRM_IOCTL_H_34 35#include <linux/types.h>36#include <linux/bitops.h>37 38#include <asm/ioctl.h>39 40struct drm_device;41struct drm_file;42struct file;43 44/**45 * drm_ioctl_t - DRM ioctl function type.46 * @dev: DRM device inode47 * @data: private pointer of the ioctl call48 * @file_priv: DRM file this ioctl was made on49 *50 * This is the DRM ioctl typedef. Note that drm_ioctl() has alrady copied @data51 * into kernel-space, and will also copy it back, depending upon the read/write52 * settings in the ioctl command code.53 */54typedef int drm_ioctl_t(struct drm_device *dev, void *data,55 struct drm_file *file_priv);56 57/**58 * drm_ioctl_compat_t - compatibility DRM ioctl function type.59 * @filp: file pointer60 * @cmd: ioctl command code61 * @arg: DRM file this ioctl was made on62 *63 * Just a typedef to make declaring an array of compatibility handlers easier.64 * New drivers shouldn't screw up the structure layout for their ioctl65 * structures and hence never need this.66 */67typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,68 unsigned long arg);69 70#define DRM_IOCTL_NR(n) _IOC_NR(n)71#define DRM_IOCTL_TYPE(n) _IOC_TYPE(n)72#define DRM_MAJOR 22673 74/**75 * enum drm_ioctl_flags - DRM ioctl flags76 *77 * Various flags that can be set in &drm_ioctl_desc.flags to control how78 * userspace can use a given ioctl.79 */80enum drm_ioctl_flags {81 /**82 * @DRM_AUTH:83 *84 * This is for ioctl which are used for rendering, and require that the85 * file descriptor is either for a render node, or if it's a86 * legacy/primary node, then it must be authenticated.87 */88 DRM_AUTH = BIT(0),89 /**90 * @DRM_MASTER:91 *92 * This must be set for any ioctl which can change the modeset or93 * display state. Userspace must call the ioctl through a primary node,94 * while it is the active master.95 *96 * Note that read-only modeset ioctl can also be called by97 * unauthenticated clients, or when a master is not the currently active98 * one.99 */100 DRM_MASTER = BIT(1),101 /**102 * @DRM_ROOT_ONLY:103 *104 * Anything that could potentially wreak a master file descriptor needs105 * to have this flag set. Current that's only for the SETMASTER and106 * DROPMASTER ioctl, which e.g. logind can call to force a non-behaving107 * master (display compositor) into compliance.108 *109 * This is equivalent to callers with the SYSADMIN capability.110 */111 DRM_ROOT_ONLY = BIT(2),112 /**113 * @DRM_RENDER_ALLOW:114 *115 * This is used for all ioctl needed for rendering only, for drivers116 * which support render nodes. This should be all new render drivers,117 * and hence it should be always set for any ioctl with DRM_AUTH set.118 * Note though that read-only query ioctl might have this set, but have119 * not set DRM_AUTH because they do not require authentication.120 */121 DRM_RENDER_ALLOW = BIT(5),122};123 124/**125 * struct drm_ioctl_desc - DRM driver ioctl entry126 * @cmd: ioctl command number, without flags127 * @flags: a bitmask of &enum drm_ioctl_flags128 * @func: handler for this ioctl129 * @name: user-readable name for debug output130 *131 * For convenience it's easier to create these using the DRM_IOCTL_DEF_DRV()132 * macro.133 */134struct drm_ioctl_desc {135 unsigned int cmd;136 enum drm_ioctl_flags flags;137 drm_ioctl_t *func;138 const char *name;139};140 141/**142 * DRM_IOCTL_DEF_DRV() - helper macro to fill out a &struct drm_ioctl_desc143 * @ioctl: ioctl command suffix144 * @_func: handler for the ioctl145 * @_flags: a bitmask of &enum drm_ioctl_flags146 *147 * Small helper macro to create a &struct drm_ioctl_desc entry. The ioctl148 * command number is constructed by prepending ``DRM_IOCTL\_`` and passing that149 * to DRM_IOCTL_NR().150 */151#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \152 [DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \153 .cmd = DRM_IOCTL_##ioctl, \154 .func = _func, \155 .flags = _flags, \156 .name = #ioctl \157 }158 159long drm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);160long drm_ioctl_kernel(struct file *, drm_ioctl_t, void *, u32);161#ifdef CONFIG_COMPAT162long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);163#else164/* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */165#define drm_compat_ioctl NULL166#endif167bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);168 169int drm_noop(struct drm_device *dev, void *data,170 struct drm_file *file_priv);171int drm_invalid_op(struct drm_device *dev, void *data,172 struct drm_file *file_priv);173 174#endif /* _DRM_IOCTL_H_ */175