Commit | Line | Data |
---|---|---|
e7b96070 DH |
1 | #ifndef __DRM_LEGACY_H__ |
2 | #define __DRM_LEGACY_H__ | |
3 | ||
4 | /* | |
5 | * Copyright (c) 2014 David Herrmann <dh.herrmann@gmail.com> | |
6 | * | |
7 | * Permission is hereby granted, free of charge, to any person obtaining a | |
8 | * copy of this software and associated documentation files (the "Software"), | |
9 | * to deal in the Software without restriction, including without limitation | |
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
11 | * and/or sell copies of the Software, and to permit persons to whom the | |
12 | * Software is furnished to do so, subject to the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | |
15 | * all copies or substantial portions of the Software. | |
16 | * | |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
20 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
23 | * OTHER DEALINGS IN THE SOFTWARE. | |
24 | */ | |
25 | ||
9fc5cde7 DH |
26 | /* |
27 | * This file contains legacy interfaces that modern drm drivers | |
28 | * should no longer be using. They cannot be removed as legacy | |
29 | * drivers use them, and removing them are API breaks. | |
30 | */ | |
cc5ea594 | 31 | #include <linux/list.h> |
b8d11488 SR |
32 | |
33 | #include <drm/drm.h> | |
34 | #include <drm/drm_device.h> | |
4f03b1fc | 35 | #include <drm/drm_legacy.h> |
cc5ea594 DH |
36 | |
37 | struct agp_memory; | |
a21800bc | 38 | struct drm_buf_desc; |
e7b96070 DH |
39 | struct drm_device; |
40 | struct drm_file; | |
a21800bc TZ |
41 | struct drm_hash_item; |
42 | struct drm_open_hash; | |
43 | ||
44 | /* | |
45 | * Hash-table Support | |
46 | */ | |
47 | ||
48 | #define drm_hash_entry(_ptr, _type, _member) container_of(_ptr, _type, _member) | |
49 | ||
50 | /* drm_hashtab.c */ | |
51 | #if IS_ENABLED(CONFIG_DRM_LEGACY) | |
52 | int drm_ht_create(struct drm_open_hash *ht, unsigned int order); | |
53 | int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item); | |
54 | int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item, | |
55 | unsigned long seed, int bits, int shift, | |
56 | unsigned long add); | |
57 | int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, struct drm_hash_item **item); | |
58 | ||
59 | void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key); | |
60 | int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key); | |
61 | int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item); | |
62 | void drm_ht_remove(struct drm_open_hash *ht); | |
63 | #endif | |
64 | ||
65 | /* | |
66 | * RCU-safe interface | |
67 | * | |
68 | * The user of this API needs to make sure that two or more instances of the | |
69 | * hash table manipulation functions are never run simultaneously. | |
70 | * The lookup function drm_ht_find_item_rcu may, however, run simultaneously | |
71 | * with any of the manipulation functions as long as it's called from within | |
72 | * an RCU read-locked section. | |
73 | */ | |
74 | #define drm_ht_insert_item_rcu drm_ht_insert_item | |
75 | #define drm_ht_just_insert_please_rcu drm_ht_just_insert_please | |
76 | #define drm_ht_remove_key_rcu drm_ht_remove_key | |
77 | #define drm_ht_remove_item_rcu drm_ht_remove_item | |
78 | #define drm_ht_find_item_rcu drm_ht_find_item | |
e7b96070 DH |
79 | |
80 | /* | |
81 | * Generic DRM Contexts | |
82 | */ | |
83 | ||
84 | #define DRM_KERNEL_CONTEXT 0 | |
85 | #define DRM_RESERVED_CONTEXTS 1 | |
86 | ||
61ae2270 | 87 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
ba6976c1 | 88 | void drm_legacy_ctxbitmap_init(struct drm_device *dev); |
e7b96070 | 89 | void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev); |
e7b96070 | 90 | void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file); |
61ae2270 DA |
91 | #else |
92 | static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {} | |
93 | static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {} | |
94 | static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {} | |
95 | #endif | |
e7b96070 | 96 | |
61ae2270 DA |
97 | void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle); |
98 | ||
99 | #if IS_ENABLED(CONFIG_DRM_LEGACY) | |
e7b96070 DH |
100 | int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f); |
101 | int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f); | |
102 | int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f); | |
103 | int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f); | |
104 | int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f); | |
105 | int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f); | |
106 | ||
107 | int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f); | |
108 | int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f); | |
61ae2270 | 109 | #endif |
e7b96070 | 110 | |
9fc5cde7 DH |
111 | /* |
112 | * Generic Buffer Management | |
113 | */ | |
114 | ||
115 | #define DRM_MAP_HASH_OFFSET 0x10000000 | |
116 | ||
83c163f7 | 117 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
fabb0e2a DA |
118 | static inline int drm_legacy_create_map_hash(struct drm_device *dev) |
119 | { | |
120 | return drm_ht_create(&dev->map_hash, 12); | |
121 | } | |
122 | ||
123 | static inline void drm_legacy_remove_map_hash(struct drm_device *dev) | |
124 | { | |
125 | drm_ht_remove(&dev->map_hash); | |
126 | } | |
83c163f7 DA |
127 | #else |
128 | static inline int drm_legacy_create_map_hash(struct drm_device *dev) | |
129 | { | |
130 | return 0; | |
131 | } | |
132 | ||
133 | static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {} | |
134 | #endif | |
fabb0e2a | 135 | |
61ae2270 DA |
136 | |
137 | #if IS_ENABLED(CONFIG_DRM_LEGACY) | |
ec1f52ef DV |
138 | int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data, |
139 | struct drm_file *file_priv); | |
9fc5cde7 DH |
140 | int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); |
141 | int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); | |
61ae2270 | 142 | |
9fc5cde7 DH |
143 | int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f); |
144 | int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f); | |
145 | int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f); | |
146 | int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f); | |
147 | int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f); | |
148 | int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f); | |
61ae2270 | 149 | #endif |
9fc5cde7 | 150 | |
5c7640ab AV |
151 | int __drm_legacy_infobufs(struct drm_device *, void *, int *, |
152 | int (*)(void *, int, struct drm_buf_entry *)); | |
87d3ce11 AV |
153 | int __drm_legacy_mapbufs(struct drm_device *, void *, int *, |
154 | void __user **, | |
155 | int (*)(void *, int, unsigned long, struct drm_buf *), | |
156 | struct drm_file *); | |
5c7640ab | 157 | |
61ae2270 | 158 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
15e60851 DA |
159 | void drm_legacy_master_rmmaps(struct drm_device *dev, |
160 | struct drm_master *master); | |
35a28021 | 161 | void drm_legacy_rmmaps(struct drm_device *dev); |
61ae2270 DA |
162 | #else |
163 | static inline void drm_legacy_master_rmmaps(struct drm_device *dev, | |
164 | struct drm_master *master) {} | |
165 | static inline void drm_legacy_rmmaps(struct drm_device *dev) {} | |
166 | #endif | |
15e60851 | 167 | |
02e415f8 | 168 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
a677f4cc | 169 | void drm_legacy_vma_flush(struct drm_device *d); |
99c48e1e BG |
170 | #else |
171 | static inline void drm_legacy_vma_flush(struct drm_device *d) | |
172 | { | |
173 | /* do nothing */ | |
174 | } | |
175 | #endif | |
a677f4cc | 176 | |
cc5ea594 DH |
177 | /* |
178 | * AGP Support | |
179 | */ | |
180 | ||
181 | struct drm_agp_mem { | |
182 | unsigned long handle; | |
183 | struct agp_memory *memory; | |
184 | unsigned long bound; | |
185 | int pages; | |
186 | struct list_head head; | |
187 | }; | |
188 | ||
04dfe19a TZ |
189 | /* drm_agpsupport.c */ |
190 | #if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_AGP) | |
191 | void drm_legacy_agp_clear(struct drm_device *dev); | |
192 | ||
193 | int drm_legacy_agp_acquire_ioctl(struct drm_device *dev, void *data, | |
194 | struct drm_file *file_priv); | |
195 | int drm_legacy_agp_release_ioctl(struct drm_device *dev, void *data, | |
196 | struct drm_file *file_priv); | |
197 | int drm_legacy_agp_enable_ioctl(struct drm_device *dev, void *data, | |
198 | struct drm_file *file_priv); | |
199 | int drm_legacy_agp_info_ioctl(struct drm_device *dev, void *data, | |
200 | struct drm_file *file_priv); | |
201 | int drm_legacy_agp_alloc_ioctl(struct drm_device *dev, void *data, | |
202 | struct drm_file *file_priv); | |
203 | int drm_legacy_agp_free_ioctl(struct drm_device *dev, void *data, | |
204 | struct drm_file *file_priv); | |
205 | int drm_legacy_agp_unbind_ioctl(struct drm_device *dev, void *data, | |
206 | struct drm_file *file_priv); | |
207 | int drm_legacy_agp_bind_ioctl(struct drm_device *dev, void *data, | |
208 | struct drm_file *file_priv); | |
209 | #else | |
210 | static inline void drm_legacy_agp_clear(struct drm_device *dev) {} | |
211 | #endif | |
212 | ||
1a75a222 | 213 | /* drm_lock.c */ |
61ae2270 | 214 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
bb6d822e DH |
215 | int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f); |
216 | int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f); | |
1a75a222 | 217 | void drm_legacy_lock_release(struct drm_device *dev, struct file *filp); |
61ae2270 DA |
218 | #else |
219 | static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {} | |
220 | #endif | |
bb6d822e | 221 | |
a266162a | 222 | /* DMA support */ |
61ae2270 | 223 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
a266162a DV |
224 | int drm_legacy_dma_setup(struct drm_device *dev); |
225 | void drm_legacy_dma_takedown(struct drm_device *dev); | |
61ae2270 DA |
226 | #else |
227 | static inline int drm_legacy_dma_setup(struct drm_device *dev) | |
228 | { | |
229 | return 0; | |
230 | } | |
231 | #endif | |
232 | ||
a266162a DV |
233 | void drm_legacy_free_buffer(struct drm_device *dev, |
234 | struct drm_buf * buf); | |
61ae2270 | 235 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
a266162a DV |
236 | void drm_legacy_reclaim_buffers(struct drm_device *dev, |
237 | struct drm_file *filp); | |
61ae2270 DA |
238 | #else |
239 | static inline void drm_legacy_reclaim_buffers(struct drm_device *dev, | |
240 | struct drm_file *filp) {} | |
241 | #endif | |
a266162a | 242 | |
9ec4e2ff | 243 | /* Scatter Gather Support */ |
61ae2270 | 244 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
9ec4e2ff DV |
245 | void drm_legacy_sg_cleanup(struct drm_device *dev); |
246 | int drm_legacy_sg_alloc(struct drm_device *dev, void *data, | |
247 | struct drm_file *file_priv); | |
248 | int drm_legacy_sg_free(struct drm_device *dev, void *data, | |
249 | struct drm_file *file_priv); | |
61ae2270 | 250 | #endif |
9ec4e2ff | 251 | |
61ae2270 | 252 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
8437dd73 DA |
253 | void drm_legacy_init_members(struct drm_device *dev); |
254 | void drm_legacy_destroy_members(struct drm_device *dev); | |
1fa32cb6 | 255 | void drm_legacy_dev_reinit(struct drm_device *dev); |
094aa54f | 256 | int drm_legacy_setup(struct drm_device * dev); |
61ae2270 DA |
257 | #else |
258 | static inline void drm_legacy_init_members(struct drm_device *dev) {} | |
259 | static inline void drm_legacy_destroy_members(struct drm_device *dev) {} | |
260 | static inline void drm_legacy_dev_reinit(struct drm_device *dev) {} | |
094aa54f | 261 | static inline int drm_legacy_setup(struct drm_device * dev) { return 0; } |
61ae2270 | 262 | #endif |
8437dd73 | 263 | |
61ae2270 | 264 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
058ca50c | 265 | void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master); |
61ae2270 DA |
266 | #else |
267 | static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {} | |
268 | #endif | |
269 | ||
ee22f763 DA |
270 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
271 | void drm_master_legacy_init(struct drm_master *master); | |
272 | #else | |
273 | static inline void drm_master_legacy_init(struct drm_master *master) {} | |
274 | #endif | |
275 | ||
644adc3d | 276 | /* drm_pci.c */ |
6bff2279 | 277 | #if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI) |
644adc3d | 278 | int drm_legacy_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv); |
6bff2279 TZ |
279 | void drm_legacy_pci_agp_destroy(struct drm_device *dev); |
280 | #else | |
644adc3d TZ |
281 | static inline int drm_legacy_irq_by_busid(struct drm_device *dev, void *data, |
282 | struct drm_file *file_priv) | |
283 | { | |
284 | return -EINVAL; | |
285 | } | |
286 | ||
6bff2279 TZ |
287 | static inline void drm_legacy_pci_agp_destroy(struct drm_device *dev) {} |
288 | #endif | |
289 | ||
e7b96070 | 290 | #endif /* __DRM_LEGACY_H__ */ |