blob: b65865c630b0aae2830a30f1e6f855584ced85d5 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/*
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
Olivier Deprez157378f2022-04-04 15:47:50 +020024#include <linux/kthread.h>
25
David Brazdil0f672f62019-12-10 10:32:29 +000026#include <drm/drm_ioctl.h>
Olivier Deprez157378f2022-04-04 15:47:50 +020027#include <drm/drm_vblank.h>
David Brazdil0f672f62019-12-10 10:32:29 +000028
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000029#define DRM_IF_MAJOR 1
30#define DRM_IF_MINOR 4
31
David Brazdil0f672f62019-12-10 10:32:29 +000032#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;
Olivier Deprez157378f2022-04-04 15:47:50 +020044struct drm_vblank_crtc;
David Brazdil0f672f62019-12-10 10:32:29 +000045
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000046/* drm_file.c */
47extern struct mutex drm_global_mutex;
Olivier Deprez157378f2022-04-04 15:47:50 +020048bool drm_dev_needs_global_mutex(struct drm_device *dev);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000049struct 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
Olivier Deprez157378f2022-04-04 15:47:50 +020053#ifdef CONFIG_PCI
54
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000055/* 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
Olivier Deprez157378f2022-04-04 15:47:50 +020061#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
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000081/* 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
Olivier Deprez157378f2022-04-04 15:47:50 +020096/* drm_managed.c */
97void drm_managed_release(struct drm_device *dev);
98void drmm_add_final_kfree(struct drm_device *dev, void *container);
99
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000100/* drm_vblank.c */
Olivier Deprez157378f2022-04-04 15:47:50 +0200101static inline bool drm_vblank_passed(u64 seq, u64 ref)
102{
103 return (seq - ref) <= (1 << 23);
104}
105
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000106void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe);
Olivier Deprez157378f2022-04-04 15:47:50 +0200107int drm_vblank_get(struct drm_device *dev, unsigned int pipe);
108void drm_vblank_put(struct drm_device *dev, unsigned int pipe);
109u64 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
110
111/* drm_vblank_work.c */
112static inline void drm_vblank_flush_worker(struct drm_vblank_crtc *vblank)
113{
114 kthread_flush_worker(vblank->worker);
115}
116
117static inline void drm_vblank_destroy_worker(struct drm_vblank_crtc *vblank)
118{
119 kthread_destroy_worker(vblank->worker);
120}
121
122int drm_vblank_worker_init(struct drm_vblank_crtc *vblank);
123void drm_vblank_cancel_pending_works(struct drm_vblank_crtc *vblank);
124void drm_handle_vblank_works(struct drm_vblank_crtc *vblank);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000125
126/* IOCTLS */
127int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
128 struct drm_file *filp);
129int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
130 struct drm_file *file_priv);
131
132/* drm_irq.c */
133
134/* IOCTLS */
David Brazdil0f672f62019-12-10 10:32:29 +0000135#if IS_ENABLED(CONFIG_DRM_LEGACY)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000136int drm_legacy_irq_control(struct drm_device *dev, void *data,
137 struct drm_file *file_priv);
David Brazdil0f672f62019-12-10 10:32:29 +0000138#endif
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000139
140int drm_crtc_get_sequence_ioctl(struct drm_device *dev, void *data,
141 struct drm_file *filp);
142
143int drm_crtc_queue_sequence_ioctl(struct drm_device *dev, void *data,
144 struct drm_file *filp);
145
146/* drm_auth.c */
147int drm_getmagic(struct drm_device *dev, void *data,
148 struct drm_file *file_priv);
149int drm_authmagic(struct drm_device *dev, void *data,
150 struct drm_file *file_priv);
151int drm_setmaster_ioctl(struct drm_device *dev, void *data,
152 struct drm_file *file_priv);
153int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
154 struct drm_file *file_priv);
155int drm_master_open(struct drm_file *file_priv);
156void drm_master_release(struct drm_file *file_priv);
David Brazdil0f672f62019-12-10 10:32:29 +0000157bool drm_master_internal_acquire(struct drm_device *dev);
158void drm_master_internal_release(struct drm_device *dev);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000159
160/* drm_sysfs.c */
161extern struct class *drm_class;
162
163int drm_sysfs_init(void);
164void drm_sysfs_destroy(void);
165struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
166int drm_sysfs_connector_add(struct drm_connector *connector);
167void drm_sysfs_connector_remove(struct drm_connector *connector);
168
169void drm_sysfs_lease_event(struct drm_device *dev);
170
171/* drm_gem.c */
David Brazdil0f672f62019-12-10 10:32:29 +0000172struct drm_gem_object;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000173int drm_gem_init(struct drm_device *dev);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000174int drm_gem_handle_create_tail(struct drm_file *file_priv,
175 struct drm_gem_object *obj,
176 u32 *handlep);
177int drm_gem_close_ioctl(struct drm_device *dev, void *data,
178 struct drm_file *file_priv);
179int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
180 struct drm_file *file_priv);
181int drm_gem_open_ioctl(struct drm_device *dev, void *data,
182 struct drm_file *file_priv);
183void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
184void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
185void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
186 const struct drm_gem_object *obj);
187
David Brazdil0f672f62019-12-10 10:32:29 +0000188int drm_gem_pin(struct drm_gem_object *obj);
189void drm_gem_unpin(struct drm_gem_object *obj);
190void *drm_gem_vmap(struct drm_gem_object *obj);
191void drm_gem_vunmap(struct drm_gem_object *obj, void *vaddr);
192
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000193/* drm_debugfs.c drm_debugfs_crc.c */
194#if defined(CONFIG_DEBUG_FS)
195int drm_debugfs_init(struct drm_minor *minor, int minor_id,
196 struct dentry *root);
David Brazdil0f672f62019-12-10 10:32:29 +0000197void drm_debugfs_cleanup(struct drm_minor *minor);
198void drm_debugfs_connector_add(struct drm_connector *connector);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000199void drm_debugfs_connector_remove(struct drm_connector *connector);
David Brazdil0f672f62019-12-10 10:32:29 +0000200void drm_debugfs_crtc_add(struct drm_crtc *crtc);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000201void drm_debugfs_crtc_remove(struct drm_crtc *crtc);
David Brazdil0f672f62019-12-10 10:32:29 +0000202void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000203#else
204static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
205 struct dentry *root)
206{
207 return 0;
208}
209
David Brazdil0f672f62019-12-10 10:32:29 +0000210static inline void drm_debugfs_cleanup(struct drm_minor *minor)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000211{
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000212}
213
David Brazdil0f672f62019-12-10 10:32:29 +0000214static inline void drm_debugfs_connector_add(struct drm_connector *connector)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000215{
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000216}
217static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
218{
219}
220
David Brazdil0f672f62019-12-10 10:32:29 +0000221static inline void drm_debugfs_crtc_add(struct drm_crtc *crtc)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000222{
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000223}
224static inline void drm_debugfs_crtc_remove(struct drm_crtc *crtc)
225{
226}
227
David Brazdil0f672f62019-12-10 10:32:29 +0000228static inline void drm_debugfs_crtc_crc_add(struct drm_crtc *crtc)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000229{
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000230}
231
232#endif
233
234drm_ioctl_t drm_version;
235drm_ioctl_t drm_getunique;
236drm_ioctl_t drm_getclient;
237
238/* drm_syncobj.c */
239void drm_syncobj_open(struct drm_file *file_private);
240void drm_syncobj_release(struct drm_file *file_private);
241int drm_syncobj_create_ioctl(struct drm_device *dev, void *data,
242 struct drm_file *file_private);
243int drm_syncobj_destroy_ioctl(struct drm_device *dev, void *data,
244 struct drm_file *file_private);
245int drm_syncobj_handle_to_fd_ioctl(struct drm_device *dev, void *data,
246 struct drm_file *file_private);
247int drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
248 struct drm_file *file_private);
David Brazdil0f672f62019-12-10 10:32:29 +0000249int drm_syncobj_transfer_ioctl(struct drm_device *dev, void *data,
250 struct drm_file *file_private);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000251int drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
252 struct drm_file *file_private);
David Brazdil0f672f62019-12-10 10:32:29 +0000253int drm_syncobj_timeline_wait_ioctl(struct drm_device *dev, void *data,
254 struct drm_file *file_private);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000255int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
256 struct drm_file *file_private);
257int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
258 struct drm_file *file_private);
David Brazdil0f672f62019-12-10 10:32:29 +0000259int drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
260 struct drm_file *file_private);
261int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
262 struct drm_file *file_private);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000263
264/* drm_framebuffer.c */
265void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
266 const struct drm_framebuffer *fb);
Olivier Deprez157378f2022-04-04 15:47:50 +0200267void drm_framebuffer_debugfs_init(struct drm_minor *minor);