Loading...
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 <linux/kthread.h>
25
26#include <drm/drm_ioctl.h>
27#include <drm/drm_vblank.h>
28
29#define DRM_IF_MAJOR 1
30#define DRM_IF_MINOR 4
31
32#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
33
34struct dentry;
35struct dma_buf;
36struct drm_connector;
37struct drm_crtc;
38struct drm_framebuffer;
39struct drm_gem_object;
40struct drm_master;
41struct drm_minor;
42struct drm_prime_file_private;
43struct drm_printer;
44struct drm_vblank_crtc;
45
46/* drm_file.c */
47extern struct mutex drm_global_mutex;
48bool drm_dev_needs_global_mutex(struct drm_device *dev);
49struct drm_file *drm_file_alloc(struct drm_minor *minor);
50void drm_file_free(struct drm_file *file);
51void drm_lastclose(struct drm_device *dev);
52
53#ifdef CONFIG_PCI
54
55/* drm_pci.c */
56int drm_irq_by_busid(struct drm_device *dev, void *data,
57 struct drm_file *file_priv);
58void drm_pci_agp_destroy(struct drm_device *dev);
59int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
60
61#else
62
63static inline int drm_irq_by_busid(struct drm_device *dev, void *data,
64 struct drm_file *file_priv)
65{
66 return -EINVAL;
67}
68
69static inline void drm_pci_agp_destroy(struct drm_device *dev)
70{
71}
72
73static inline int drm_pci_set_busid(struct drm_device *dev,
74 struct drm_master *master)
75{
76 return -EINVAL;
77}
78
79#endif
80
81/* drm_prime.c */
82int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
83 struct drm_file *file_priv);
84int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
85 struct drm_file *file_priv);
86
87void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
88void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
89void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv,
90 struct dma_buf *dma_buf);
91
92/* drm_drv.c */
93struct drm_minor *drm_minor_acquire(unsigned int minor_id);
94void drm_minor_release(struct drm_minor *minor);
95
96/* drm_managed.c */
97void drm_managed_release(struct drm_device *dev);
98
99/* drm_vblank.c */
100static inline bool drm_vblank_passed(u64 seq, u64 ref)
101{
102 return (seq - ref) <= (1 << 23);
103}
104
105void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe);
106int drm_vblank_get(struct drm_device *dev, unsigned int pipe);
107void drm_vblank_put(struct drm_device *dev, unsigned int pipe);
108u64 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
109
110/* drm_vblank_work.c */
111static inline void drm_vblank_flush_worker(struct drm_vblank_crtc *vblank)
112{
113 kthread_flush_worker(vblank->worker);
114}
115
116static inline void drm_vblank_destroy_worker(struct drm_vblank_crtc *vblank)
117{
118 kthread_destroy_worker(vblank->worker);
119}
120
121int drm_vblank_worker_init(struct drm_vblank_crtc *vblank);
122void drm_vblank_cancel_pending_works(struct drm_vblank_crtc *vblank);
123void drm_handle_vblank_works(struct drm_vblank_crtc *vblank);
124
125/* IOCTLS */
126int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
127 struct drm_file *filp);
128int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
129 struct drm_file *file_priv);
130
131/* drm_irq.c */
132
133/* IOCTLS */
134#if IS_ENABLED(CONFIG_DRM_LEGACY)
135int drm_legacy_irq_control(struct drm_device *dev, void *data,
136 struct drm_file *file_priv);
137#endif
138
139int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
140 struct drm_file *filp);
141
142int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
143 struct drm_file *filp);
144
145/* drm_auth.c */
146int drm_getmagic(struct drm_device *dev, void *data,
147 struct drm_file *file_priv);
148int drm_authmagic(struct drm_device *dev, void *data,
149 struct drm_file *file_priv);
150int drm_setmaster_ioctl(struct drm_device *dev, void *data,
151 struct drm_file *file_priv);
152int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
153 struct drm_file *file_priv);
154int drm_master_open(struct drm_file *file_priv);
155void drm_master_release(struct drm_file *file_priv);
156bool drm_master_internal_acquire(struct drm_device *dev);
157void drm_master_internal_release(struct drm_device *dev);
158
159/* drm_sysfs.c */
160extern struct class *drm_class;
161
162int drm_sysfs_init(void);
163void drm_sysfs_destroy(void);
164struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
165int drm_sysfs_connector_add(struct drm_connector *connector);
166void drm_sysfs_connector_remove(struct drm_connector *connector);
167
168void drm_sysfs_lease_event(struct drm_device *dev);
169
170/* drm_gem.c */
171struct drm_gem_object;
172int drm_gem_init(struct drm_device *dev);
173int drm_gem_handle_create_tail(struct drm_file *file_priv,
174 struct drm_gem_object *obj,
175 u32 *handlep);
176int drm_gem_close_ioctl(struct drm_device *dev, void *data,
177 struct drm_file *file_priv);
178int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
179 struct drm_file *file_priv);
180int drm_gem_open_ioctl(struct drm_device *dev, void *data,
181 struct drm_file *file_priv);
182void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
183void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
184void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
185 const struct drm_gem_object *obj);
186
187int drm_gem_pin(struct drm_gem_object *obj);
188void drm_gem_unpin(struct drm_gem_object *obj);
189void *drm_gem_vmap(struct drm_gem_object *obj);
190void drm_gem_vunmap(struct drm_gem_object *obj, void *vaddr);
191
192/* drm_debugfs.c drm_debugfs_crc.c */
193#if defined(CONFIG_DEBUG_FS)
194int drm_debugfs_init(struct drm_minor *minor, int minor_id,
195 struct dentry *root);
196void drm_debugfs_cleanup(struct drm_minor *minor);
197void drm_debugfs_connector_add(struct drm_connector *connector);
198void drm_debugfs_connector_remove(struct drm_connector *connector);
199void drm_debugfs_crtc_add(struct drm_crtc *crtc);
200void drm_debugfs_crtc_remove(struct drm_crtc *crtc);
201void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc);
202#else
203static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
204 struct dentry *root)
205{
206 return 0;
207}
208
209static inline void drm_debugfs_cleanup(struct drm_minor *minor)
210{
211}
212
213static inline void drm_debugfs_connector_add(struct drm_connector *connector)
214{
215}
216static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
217{
218}
219
220static inline void drm_debugfs_crtc_add(struct drm_crtc *crtc)
221{
222}
223static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
224{
225}
226
227static inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
228{
229}
230
231#endif
232
233drm_ioctl_t drm_version;
234drm_ioctl_t drm_getunique;
235drm_ioctl_t drm_getclient;
236
237/* drm_syncobj.c */
238void drm_syncobj_open(struct drm_file *file_private);
239void drm_syncobj_release(struct drm_file *file_private);
240int drm_syncobj_create_ioctl(struct drm_device *dev, void *data,
241 struct drm_file *file_private);
242int drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data,
243 struct drm_file *file_private);
244int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
245 struct drm_file *file_private);
246int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
247 struct drm_file *file_private);
248int drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data,
249 struct drm_file *file_private);
250int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
251 struct drm_file *file_private);
252int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data,
253 struct drm_file *file_private);
254int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
255 struct drm_file *file_private);
256int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
257 struct drm_file *file_private);
258int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
259 struct drm_file *file_private);
260int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
261 struct drm_file *file_private);
262
263/* drm_framebuffer.c */
264void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
265 const struct drm_framebuffer *fb);
266void drm_framebuffer_debugfs_init(struct drm_minor *minor);
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#define DRM_IF_MAJOR 1
25#define DRM_IF_MINOR 4
26
27/* drm_fops.c */
28extern struct mutex drm_global_mutex;
29void drm_lastclose(struct drm_device *dev);
30
31/* drm_pci.c */
32int drm_irq_by_busid(struct drm_device *dev, void *data,
33 struct drm_file *file_priv);
34
35/* drm_prime.c */
36int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
37 struct drm_file *file_priv);
38int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
39 struct drm_file *file_priv);
40
41void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
42void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
43void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv,
44 struct dma_buf *dma_buf);
45
46/* drm_drv.c */
47struct drm_minor *drm_minor_acquire(unsigned int minor_id);
48void drm_minor_release(struct drm_minor *minor);
49
50/* drm_info.c */
51int drm_name_info(struct seq_file *m, void *data);
52int drm_clients_info(struct seq_file *m, void* data);
53int drm_gem_name_info(struct seq_file *m, void *data);
54
55/* drm_irq.c */
56extern unsigned int drm_timestamp_monotonic;
57
58/* IOCTLS */
59int drm_wait_vblank(struct drm_device *dev, void *data,
60 struct drm_file *filp);
61int drm_control(struct drm_device *dev, void *data,
62 struct drm_file *file_priv);
63int drm_modeset_ctl(struct drm_device *dev, void *data,
64 struct drm_file *file_priv);
65
66/* drm_auth.c */
67int drm_getmagic(struct drm_device *dev, void *data,
68 struct drm_file *file_priv);
69int drm_authmagic(struct drm_device *dev, void *data,
70 struct drm_file *file_priv);
71int drm_setmaster_ioctl(struct drm_device *dev, void *data,
72 struct drm_file *file_priv);
73int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
74 struct drm_file *file_priv);
75int drm_master_open(struct drm_file *file_priv);
76void drm_master_release(struct drm_file *file_priv);
77
78/* drm_sysfs.c */
79extern struct class *drm_class;
80
81int drm_sysfs_init(void);
82void drm_sysfs_destroy(void);
83struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
84int drm_sysfs_connector_add(struct drm_connector *connector);
85void drm_sysfs_connector_remove(struct drm_connector *connector);
86
87/* drm_gem.c */
88int drm_gem_init(struct drm_device *dev);
89void drm_gem_destroy(struct drm_device *dev);
90int drm_gem_handle_create_tail(struct drm_file *file_priv,
91 struct drm_gem_object *obj,
92 u32 *handlep);
93int drm_gem_close_ioctl(struct drm_device *dev, void *data,
94 struct drm_file *file_priv);
95int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
96 struct drm_file *file_priv);
97int drm_gem_open_ioctl(struct drm_device *dev, void *data,
98 struct drm_file *file_priv);
99void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
100void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
101
102/* drm_debugfs.c */
103#if defined(CONFIG_DEBUG_FS)
104int drm_debugfs_init(struct drm_minor *minor, int minor_id,
105 struct dentry *root);
106int drm_debugfs_cleanup(struct drm_minor *minor);
107int drm_debugfs_connector_add(struct drm_connector *connector);
108void drm_debugfs_connector_remove(struct drm_connector *connector);
109int drm_debugfs_crtc_add(struct drm_crtc *crtc);
110void drm_debugfs_crtc_remove(struct drm_crtc *crtc);
111int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc);
112#else
113static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
114 struct dentry *root)
115{
116 return 0;
117}
118
119static inline int drm_debugfs_cleanup(struct drm_minor *minor)
120{
121 return 0;
122}
123
124static inline int drm_debugfs_connector_add(struct drm_connector *connector)
125{
126 return 0;
127}
128static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
129{
130}
131
132static inline int drm_debugfs_crtc_add(struct drm_crtc *crtc)
133{
134 return 0;
135}
136static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
137{
138}
139
140static inline int drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
141{
142 return 0;
143}
144#endif