2 * Copyright © 2014 Intel Corporation
3 * Daniel Vetter <daniel.vetter@ffwll.ch>
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
24 #include <linux/kthread.h>
26 #include <drm/drm_ioctl.h>
27 #include <drm/drm_vblank.h>
29 #define DRM_IF_MAJOR 1
30 #define DRM_IF_MINOR 4
32 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
39 struct drm_framebuffer;
40 struct drm_gem_object;
43 struct drm_prime_file_private;
45 struct drm_vblank_crtc;
48 extern struct mutex drm_global_mutex;
49 bool drm_dev_needs_global_mutex(struct drm_device *dev);
50 struct drm_file *drm_file_alloc(struct drm_minor *minor);
51 void drm_file_free(struct drm_file *file);
52 void drm_lastclose(struct drm_device *dev);
57 int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
61 static inline int drm_pci_set_busid(struct drm_device *dev,
62 struct drm_master *master)
70 int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
71 struct drm_file *file_priv);
72 int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
73 struct drm_file *file_priv);
75 void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
76 void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
77 void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
81 struct drm_minor *drm_minor_acquire(unsigned int minor_id);
82 void drm_minor_release(struct drm_minor *minor);
85 void drm_managed_release(struct drm_device *dev);
86 void drmm_add_final_kfree(struct drm_device *dev, void *container);
89 static inline bool drm_vblank_passed(u64 seq, u64 ref)
91 return (seq - ref) <= (1 << 23);
94 void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe);
95 int drm_vblank_get(struct drm_device *dev, unsigned int pipe);
96 void drm_vblank_put(struct drm_device *dev, unsigned int pipe);
97 u64 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
99 /* drm_vblank_work.c */
100 static inline void drm_vblank_flush_worker(struct drm_vblank_crtc *vblank)
102 kthread_flush_worker(vblank->worker);
105 static inline void drm_vblank_destroy_worker(struct drm_vblank_crtc *vblank)
108 kthread_destroy_worker(vblank->worker);
111 int drm_vblank_worker_init(struct drm_vblank_crtc *vblank);
112 void drm_vblank_cancel_pending_works(struct drm_vblank_crtc *vblank);
113 void drm_handle_vblank_works(struct drm_vblank_crtc *vblank);
116 int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
117 struct drm_file *filp);
118 int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
119 struct drm_file *file_priv);
124 #if IS_ENABLED(CONFIG_DRM_LEGACY)
125 int drm_legacy_irq_control(struct drm_device *dev, void *data,
126 struct drm_file *file_priv);
129 int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
130 struct drm_file *filp);
132 int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
133 struct drm_file *filp);
136 int drm_getmagic(struct drm_device *dev, void *data,
137 struct drm_file *file_priv);
138 int drm_authmagic(struct drm_device *dev, void *data,
139 struct drm_file *file_priv);
140 int drm_setmaster_ioctl(struct drm_device *dev, void *data,
141 struct drm_file *file_priv);
142 int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
143 struct drm_file *file_priv);
144 int drm_master_open(struct drm_file *file_priv);
145 void drm_master_release(struct drm_file *file_priv);
146 bool drm_master_internal_acquire(struct drm_device *dev);
147 void drm_master_internal_release(struct drm_device *dev);
150 extern struct class *drm_class;
152 int drm_sysfs_init(void);
153 void drm_sysfs_destroy(void);
154 struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
155 int drm_sysfs_connector_add(struct drm_connector *connector);
156 void drm_sysfs_connector_remove(struct drm_connector *connector);
158 void drm_sysfs_lease_event(struct drm_device *dev);
161 int drm_gem_init(struct drm_device *dev);
162 int drm_gem_handle_create_tail(struct drm_file *file_priv,
163 struct drm_gem_object *obj,
165 int drm_gem_close_ioctl(struct drm_device *dev, void *data,
166 struct drm_file *file_priv);
167 int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
168 struct drm_file *file_priv);
169 int drm_gem_open_ioctl(struct drm_device *dev, void *data,
170 struct drm_file *file_priv);
171 void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
172 void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
173 void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
174 const struct drm_gem_object *obj);
176 int drm_gem_pin(struct drm_gem_object *obj);
177 void drm_gem_unpin(struct drm_gem_object *obj);
178 int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map);
179 void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map);
181 /* drm_debugfs.c drm_debugfs_crc.c */
182 #if defined(CONFIG_DEBUG_FS)
183 int drm_debugfs_init(struct drm_minor *minor, int minor_id,
184 struct dentry *root);
185 void drm_debugfs_cleanup(struct drm_minor *minor);
186 void drm_debugfs_late_register(struct drm_device *dev);
187 void drm_debugfs_connector_add(struct drm_connector *connector);
188 void drm_debugfs_connector_remove(struct drm_connector *connector);
189 void drm_debugfs_crtc_add(struct drm_crtc *crtc);
190 void drm_debugfs_crtc_remove(struct drm_crtc *crtc);
191 void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc);
193 static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
199 static inline void drm_debugfs_cleanup(struct drm_minor *minor)
203 static inline void drm_debugfs_late_register(struct drm_device *dev)
207 static inline void drm_debugfs_connector_add(struct drm_connector *connector)
210 static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
214 static inline void drm_debugfs_crtc_add(struct drm_crtc *crtc)
217 static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
221 static inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
227 drm_ioctl_t drm_version;
228 drm_ioctl_t drm_getunique;
229 drm_ioctl_t drm_getclient;
232 void drm_syncobj_open(struct drm_file *file_private);
233 void drm_syncobj_release(struct drm_file *file_private);
234 int drm_syncobj_create_ioctl(struct drm_device *dev, void *data,
235 struct drm_file *file_private);
236 int drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data,
237 struct drm_file *file_private);
238 int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
239 struct drm_file *file_private);
240 int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
241 struct drm_file *file_private);
242 int drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data,
243 struct drm_file *file_private);
244 int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
245 struct drm_file *file_private);
246 int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data,
247 struct drm_file *file_private);
248 int drm_syncobj_eventfd_ioctl(struct drm_device *dev, void *data,
249 struct drm_file *file_private);
250 int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
251 struct drm_file *file_private);
252 int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
253 struct drm_file *file_private);
254 int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
255 struct drm_file *file_private);
256 int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
257 struct drm_file *file_private);
259 /* drm_framebuffer.c */
260 void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
261 const struct drm_framebuffer *fb);
262 void drm_framebuffer_debugfs_init(struct drm_minor *minor);