xref: /linux/include/drm/drm_ioctl.h (revision 99a97a8ba9881fc47901ff36b057e5cd0bf06af0)
1 /*
2  * Internal Header for the Direct Rendering Manager
3  *
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 a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice (including the next
20  * paragraph) shall be included in all copies or substantial portions of the
21  * Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
26  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27  * 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 OR
29  * OTHER DEALINGS IN THE SOFTWARE.
30  */
31 
32 #ifndef _DRM_IOCTL_H_
33 #define _DRM_IOCTL_H_
34 
35 #include <linux/types.h>
36 
37 #include <asm/ioctl.h>
38 
39 struct drm_device;
40 struct drm_file;
41 struct file;
42 
43 /**
44  * Ioctl function type.
45  *
46  * \param inode device inode.
47  * \param file_priv DRM file private pointer.
48  * \param cmd command.
49  * \param arg argument.
50  */
51 typedef int drm_ioctl_t(struct drm_device *dev, void *data,
52 			struct drm_file *file_priv);
53 
54 typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
55 			       unsigned long arg);
56 
57 #define DRM_IOCTL_NR(n)                _IOC_NR(n)
58 #define DRM_MAJOR       226
59 
60 #define DRM_AUTH	0x1
61 #define	DRM_MASTER	0x2
62 #define DRM_ROOT_ONLY	0x4
63 #define DRM_CONTROL_ALLOW 0x8
64 #define DRM_UNLOCKED	0x10
65 #define DRM_RENDER_ALLOW 0x20
66 
67 struct drm_ioctl_desc {
68 	unsigned int cmd;
69 	int flags;
70 	drm_ioctl_t *func;
71 	const char *name;
72 };
73 
74 /**
75  * Creates a driver or general drm_ioctl_desc array entry for the given
76  * ioctl, for use by drm_ioctl().
77  */
78 
79 #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags)				\
80 	[DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = {	\
81 		.cmd = DRM_IOCTL_##ioctl,				\
82 		.func = _func,						\
83 		.flags = _flags,					\
84 		.name = #ioctl						\
85 	}
86 
87 int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
88 long drm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
89 #ifdef CONFIG_COMPAT
90 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
91 #else
92 /* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */
93 #define drm_compat_ioctl NULL
94 #endif
95 bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
96 
97 int drm_noop(struct drm_device *dev, void *data,
98 	     struct drm_file *file_priv);
99 int drm_invalid_op(struct drm_device *dev, void *data,
100 		   struct drm_file *file_priv);
101 
102 #endif /* _DRM_IOCTL_H_ */
103