Commit | Line | Data |
---|---|---|
18882995 DV |
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 | ||
5e6c2b4f LP |
24 | #include <linux/kthread.h> |
25 | ||
99f45e32 | 26 | #include <drm/drm_ioctl.h> |
5e6c2b4f | 27 | #include <drm/drm_vblank.h> |
99f45e32 | 28 | |
82d5e73f DH |
29 | #define DRM_IF_MAJOR 1 |
30 | #define DRM_IF_MINOR 4 | |
31 | ||
ecb2e2fd SR |
32 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
33 | ||
7a44fdce | 34 | struct dentry; |
99f45e32 | 35 | struct dma_buf; |
7938f421 | 36 | struct iosys_map; |
7a44fdce SR |
37 | struct drm_connector; |
38 | struct drm_crtc; | |
39 | struct drm_framebuffer; | |
40 | struct drm_gem_object; | |
41 | struct drm_master; | |
42 | struct drm_minor; | |
43 | struct drm_prime_file_private; | |
44 | struct drm_printer; | |
5e6c2b4f | 45 | struct drm_vblank_crtc; |
99f45e32 | 46 | |
9acdac68 | 47 | /* drm_file.c */ |
44af3f5c | 48 | extern struct mutex drm_global_mutex; |
4017ad7b | 49 | bool drm_dev_needs_global_mutex(struct drm_device *dev); |
1572042a DH |
50 | struct drm_file *drm_file_alloc(struct drm_minor *minor); |
51 | void drm_file_free(struct drm_file *file); | |
68dfbeba | 52 | void drm_lastclose(struct drm_device *dev); |
67d0ec4e | 53 | |
5c7a0bb0 TZ |
54 | #ifdef CONFIG_PCI |
55 | ||
67d0ec4e | 56 | /* drm_pci.c */ |
5c484cee | 57 | int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master); |
67d0ec4e | 58 | |
5c7a0bb0 TZ |
59 | #else |
60 | ||
5c7a0bb0 TZ |
61 | static inline int drm_pci_set_busid(struct drm_device *dev, |
62 | struct drm_master *master) | |
63 | { | |
64 | return -EINVAL; | |
65 | } | |
66 | ||
67 | #endif | |
68 | ||
67d0ec4e DV |
69 | /* drm_prime.c */ |
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); | |
74 | ||
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); | |
ea2aa97c JC |
77 | void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv, |
78 | uint32_t handle); | |
67d0ec4e | 79 | |
85e634bc DV |
80 | /* drm_drv.c */ |
81 | struct drm_minor *drm_minor_acquire(unsigned int minor_id); | |
82 | void drm_minor_release(struct drm_minor *minor); | |
83 | ||
c6603c74 DV |
84 | /* drm_managed.c */ |
85 | void drm_managed_release(struct drm_device *dev); | |
a7d39439 | 86 | void drmm_add_final_kfree(struct drm_device *dev, void *container); |
c6603c74 | 87 | |
3ed4351a | 88 | /* drm_vblank.c */ |
5e6c2b4f LP |
89 | static inline bool drm_vblank_passed(u64 seq, u64 ref) |
90 | { | |
91 | return (seq - ref) <= (1 << 23); | |
92 | } | |
93 | ||
3ed4351a | 94 | void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe); |
5e6c2b4f LP |
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); | |
98 | ||
99 | /* drm_vblank_work.c */ | |
100 | static inline void drm_vblank_flush_worker(struct drm_vblank_crtc *vblank) | |
101 | { | |
102 | kthread_flush_worker(vblank->worker); | |
103 | } | |
104 | ||
105 | static inline void drm_vblank_destroy_worker(struct drm_vblank_crtc *vblank) | |
106 | { | |
4979524f SX |
107 | if (vblank->worker) |
108 | kthread_destroy_worker(vblank->worker); | |
5e6c2b4f LP |
109 | } |
110 | ||
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); | |
b9876d50 DV |
114 | |
115 | /* IOCTLS */ | |
b6dcaaac DV |
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); | |
120 | ||
121 | /* drm_irq.c */ | |
122 | ||
123 | /* IOCTLS */ | |
61ae2270 | 124 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
25a9939c DV |
125 | int drm_legacy_irq_control(struct drm_device *dev, void *data, |
126 | struct drm_file *file_priv); | |
61ae2270 | 127 | #endif |
67d0ec4e | 128 | |
3064abfa KP |
129 | int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data, |
130 | struct drm_file *filp); | |
131 | ||
132 | int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data, | |
133 | struct drm_file *filp); | |
134 | ||
67d0ec4e DV |
135 | /* drm_auth.c */ |
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); | |
6548f4e7 DV |
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); | |
2cbae7e6 | 144 | int drm_master_open(struct drm_file *file_priv); |
14d71ebd | 145 | void drm_master_release(struct drm_file *file_priv); |
03a9606e NT |
146 | bool drm_master_internal_acquire(struct drm_device *dev); |
147 | void drm_master_internal_release(struct drm_device *dev); | |
67d0ec4e DV |
148 | |
149 | /* drm_sysfs.c */ | |
00285be8 DV |
150 | extern struct class *drm_class; |
151 | ||
fcc90213 | 152 | int drm_sysfs_init(void); |
67d0ec4e DV |
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); | |
157 | ||
ce858828 DV |
158 | void drm_sysfs_lease_event(struct drm_device *dev); |
159 | ||
67d0ec4e DV |
160 | /* drm_gem.c */ |
161 | int drm_gem_init(struct drm_device *dev); | |
67d0ec4e DV |
162 | int drm_gem_handle_create_tail(struct drm_file *file_priv, |
163 | struct drm_gem_object *obj, | |
164 | u32 *handlep); | |
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); | |
45d58b40 NT |
173 | void drm_gem_print_info(struct drm_printer *p, unsigned int indent, |
174 | const struct drm_gem_object *obj); | |
e7f0a889 | 175 | |
eb69c8a4 DV |
176 | int drm_gem_pin(struct drm_gem_object *obj); |
177 | void drm_gem_unpin(struct drm_gem_object *obj); | |
7938f421 LDM |
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); | |
eb69c8a4 | 180 | |
47f10854 LP |
181 | int drm_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev, |
182 | u32 handle); | |
183 | ||
0cad7f71 | 184 | /* drm_debugfs.c drm_debugfs_crc.c */ |
c2611031 DV |
185 | #if defined(CONFIG_DEBUG_FS) |
186 | int drm_debugfs_init(struct drm_minor *minor, int minor_id, | |
187 | struct dentry *root); | |
b792e640 | 188 | void drm_debugfs_cleanup(struct drm_minor *minor); |
dbb23cf5 | 189 | void drm_debugfs_late_register(struct drm_device *dev); |
b792e640 | 190 | void drm_debugfs_connector_add(struct drm_connector *connector); |
c2611031 | 191 | void drm_debugfs_connector_remove(struct drm_connector *connector); |
b792e640 | 192 | void drm_debugfs_crtc_add(struct drm_crtc *crtc); |
9edbf1fa | 193 | void drm_debugfs_crtc_remove(struct drm_crtc *crtc); |
b792e640 | 194 | void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc); |
c2611031 DV |
195 | #else |
196 | static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id, | |
197 | struct dentry *root) | |
198 | { | |
199 | return 0; | |
200 | } | |
201 | ||
b792e640 | 202 | static inline void drm_debugfs_cleanup(struct drm_minor *minor) |
c2611031 | 203 | { |
c2611031 DV |
204 | } |
205 | ||
dbb23cf5 MC |
206 | static inline void drm_debugfs_late_register(struct drm_device *dev) |
207 | { | |
208 | } | |
209 | ||
b792e640 | 210 | static inline void drm_debugfs_connector_add(struct drm_connector *connector) |
c2611031 | 211 | { |
c2611031 DV |
212 | } |
213 | static inline void drm_debugfs_connector_remove(struct drm_connector *connector) | |
214 | { | |
215 | } | |
9edbf1fa | 216 | |
b792e640 | 217 | static inline void drm_debugfs_crtc_add(struct drm_crtc *crtc) |
9edbf1fa | 218 | { |
9edbf1fa TV |
219 | } |
220 | static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc) | |
221 | { | |
222 | } | |
223 | ||
b792e640 | 224 | static inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc) |
9edbf1fa | 225 | { |
9edbf1fa | 226 | } |
e9083420 | 227 | |
c2611031 | 228 | #endif |
e9083420 | 229 | |
012c6741 | 230 | drm_ioctl_t drm_version; |
17e3dade | 231 | drm_ioctl_t drm_getunique; |
9e92662d | 232 | drm_ioctl_t drm_getclient; |
af3c8d98 | 233 | |
e9083420 DA |
234 | /* drm_syncobj.c */ |
235 | void drm_syncobj_open(struct drm_file *file_private); | |
236 | void drm_syncobj_release(struct drm_file *file_private); | |
237 | int drm_syncobj_create_ioctl(struct drm_device *dev, void *data, | |
238 | struct drm_file *file_private); | |
239 | int drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data, | |
240 | struct drm_file *file_private); | |
241 | int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data, | |
242 | struct drm_file *file_private); | |
243 | int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data, | |
244 | struct drm_file *file_private); | |
ea569910 CZ |
245 | int drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data, |
246 | struct drm_file *file_private); | |
5e60a10e DA |
247 | int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data, |
248 | struct drm_file *file_private); | |
01d6c357 CZ |
249 | int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data, |
250 | struct drm_file *file_private); | |
aa4035d2 JE |
251 | int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data, |
252 | struct drm_file *file_private); | |
ffa9443f JE |
253 | int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data, |
254 | struct drm_file *file_private); | |
50d1ebef CZ |
255 | int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, |
256 | struct drm_file *file_private); | |
27b575a9 CZ |
257 | int drm_syncobj_query_ioctl(struct drm_device *dev, void *data, |
258 | struct drm_file *file_private); | |
45d58b40 NT |
259 | |
260 | /* drm_framebuffer.c */ | |
261 | void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent, | |
262 | const struct drm_framebuffer *fb); | |
7ce84471 | 263 | void drm_framebuffer_debugfs_init(struct drm_minor *minor); |