xref: /linux/drivers/gpu/drm/drm_internal.h (revision 95298d63c67673c654c08952672d016212b26054)
1 /*
2  * Copyright © 2014 Intel Corporation
3  *   Daniel Vetter <daniel.vetter@ffwll.ch>
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21  * OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #include <drm/drm_ioctl.h>
25 
26 #define DRM_IF_MAJOR 1
27 #define DRM_IF_MINOR 4
28 
29 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
30 
31 struct dentry;
32 struct dma_buf;
33 struct drm_connector;
34 struct drm_crtc;
35 struct drm_framebuffer;
36 struct drm_gem_object;
37 struct drm_master;
38 struct drm_minor;
39 struct drm_prime_file_private;
40 struct drm_printer;
41 
42 /* drm_file.c */
43 extern struct mutex drm_global_mutex;
44 bool drm_dev_needs_global_mutex(struct drm_device *dev);
45 struct drm_file *drm_file_alloc(struct drm_minor *minor);
46 void drm_file_free(struct drm_file *file);
47 void drm_lastclose(struct drm_device *dev);
48 
49 #ifdef CONFIG_PCI
50 
51 /* drm_pci.c */
52 int drm_irq_by_busid(struct drm_device *dev, void *data,
53 		     struct drm_file *file_priv);
54 void drm_pci_agp_destroy(struct drm_device *dev);
55 int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
56 
57 #else
58 
59 static inline int drm_irq_by_busid(struct drm_device *dev, void *data,
60 				   struct drm_file *file_priv)
61 {
62 	return -EINVAL;
63 }
64 
65 static inline void drm_pci_agp_destroy(struct drm_device *dev)
66 {
67 }
68 
69 static inline int drm_pci_set_busid(struct drm_device *dev,
70 				    struct drm_master *master)
71 {
72 	return -EINVAL;
73 }
74 
75 #endif
76 
77 /* drm_prime.c */
78 int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
79 				 struct drm_file *file_priv);
80 int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
81 				 struct drm_file *file_priv);
82 
83 void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
84 void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
85 void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv,
86 					struct dma_buf *dma_buf);
87 
88 /* drm_drv.c */
89 struct drm_minor *drm_minor_acquire(unsigned int minor_id);
90 void drm_minor_release(struct drm_minor *minor);
91 
92 /* drm_managed.c */
93 void drm_managed_release(struct drm_device *dev);
94 
95 /* drm_vblank.c */
96 void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe);
97 
98 /* IOCTLS */
99 int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
100 			  struct drm_file *filp);
101 int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
102 				 struct drm_file *file_priv);
103 
104 /* drm_irq.c */
105 
106 /* IOCTLS */
107 #if IS_ENABLED(CONFIG_DRM_LEGACY)
108 int drm_legacy_irq_control(struct drm_device *dev, void *data,
109 			   struct drm_file *file_priv);
110 #endif
111 
112 int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
113 				struct drm_file *filp);
114 
115 int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
116 				  struct drm_file *filp);
117 
118 /* drm_auth.c */
119 int drm_getmagic(struct drm_device *dev, void *data,
120 		 struct drm_file *file_priv);
121 int drm_authmagic(struct drm_device *dev, void *data,
122 		  struct drm_file *file_priv);
123 int drm_setmaster_ioctl(struct drm_device *dev, void *data,
124 			struct drm_file *file_priv);
125 int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
126 			 struct drm_file *file_priv);
127 int drm_master_open(struct drm_file *file_priv);
128 void drm_master_release(struct drm_file *file_priv);
129 bool drm_master_internal_acquire(struct drm_device *dev);
130 void drm_master_internal_release(struct drm_device *dev);
131 
132 /* drm_sysfs.c */
133 extern struct class *drm_class;
134 
135 int drm_sysfs_init(void);
136 void drm_sysfs_destroy(void);
137 struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
138 int drm_sysfs_connector_add(struct drm_connector *connector);
139 void drm_sysfs_connector_remove(struct drm_connector *connector);
140 
141 void drm_sysfs_lease_event(struct drm_device *dev);
142 
143 /* drm_gem.c */
144 struct drm_gem_object;
145 int drm_gem_init(struct drm_device *dev);
146 int drm_gem_handle_create_tail(struct drm_file *file_priv,
147 			       struct drm_gem_object *obj,
148 			       u32 *handlep);
149 int drm_gem_close_ioctl(struct drm_device *dev, void *data,
150 			struct drm_file *file_priv);
151 int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
152 			struct drm_file *file_priv);
153 int drm_gem_open_ioctl(struct drm_device *dev, void *data,
154 		       struct drm_file *file_priv);
155 void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
156 void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
157 void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
158 			const struct drm_gem_object *obj);
159 
160 int drm_gem_pin(struct drm_gem_object *obj);
161 void drm_gem_unpin(struct drm_gem_object *obj);
162 void *drm_gem_vmap(struct drm_gem_object *obj);
163 void drm_gem_vunmap(struct drm_gem_object *obj, void *vaddr);
164 
165 /* drm_debugfs.c drm_debugfs_crc.c */
166 #if defined(CONFIG_DEBUG_FS)
167 int drm_debugfs_init(struct drm_minor *minor, int minor_id,
168 		     struct dentry *root);
169 void drm_debugfs_cleanup(struct drm_minor *minor);
170 void drm_debugfs_connector_add(struct drm_connector *connector);
171 void drm_debugfs_connector_remove(struct drm_connector *connector);
172 void drm_debugfs_crtc_add(struct drm_crtc *crtc);
173 void drm_debugfs_crtc_remove(struct drm_crtc *crtc);
174 void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc);
175 #else
176 static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
177 				   struct dentry *root)
178 {
179 	return 0;
180 }
181 
182 static inline void drm_debugfs_cleanup(struct drm_minor *minor)
183 {
184 }
185 
186 static inline void drm_debugfs_connector_add(struct drm_connector *connector)
187 {
188 }
189 static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
190 {
191 }
192 
193 static inline void drm_debugfs_crtc_add(struct drm_crtc *crtc)
194 {
195 }
196 static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
197 {
198 }
199 
200 static inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
201 {
202 }
203 
204 #endif
205 
206 drm_ioctl_t drm_version;
207 drm_ioctl_t drm_getunique;
208 drm_ioctl_t drm_getclient;
209 
210 /* drm_syncobj.c */
211 void drm_syncobj_open(struct drm_file *file_private);
212 void drm_syncobj_release(struct drm_file *file_private);
213 int drm_syncobj_create_ioctl(struct drm_device *dev, void *data,
214 			     struct drm_file *file_private);
215 int drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data,
216 			      struct drm_file *file_private);
217 int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
218 				   struct drm_file *file_private);
219 int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
220 				   struct drm_file *file_private);
221 int drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data,
222 			       struct drm_file *file_private);
223 int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
224 			   struct drm_file *file_private);
225 int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data,
226 				    struct drm_file *file_private);
227 int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
228 			    struct drm_file *file_private);
229 int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
230 			     struct drm_file *file_private);
231 int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
232 				      struct drm_file *file_private);
233 int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
234 			    struct drm_file *file_private);
235 
236 /* drm_framebuffer.c */
237 void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
238 				const struct drm_framebuffer *fb);
239 void drm_framebuffer_debugfs_init(struct drm_minor *minor);
240