1 #ifndef __DRM_LEGACY_H__
2 #define __DRM_LEGACY_H__
5 * Copyright (c) 2014 David Herrmann <dh.herrmann@gmail.com>
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:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
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.
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.
31 #include <linux/list.h>
34 #include <drm/drm_device.h>
35 #include <drm/drm_legacy.h>
43 * Generic DRM Contexts
46 #define DRM_KERNEL_CONTEXT 0
47 #define DRM_RESERVED_CONTEXTS 1
49 #if IS_ENABLED(CONFIG_DRM_LEGACY)
50 void drm_legacy_ctxbitmap_init(struct drm_device *dev);
51 void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
52 void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
54 static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {}
55 static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {}
56 static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {}
59 void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
61 #if IS_ENABLED(CONFIG_DRM_LEGACY)
62 int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
63 int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
64 int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
65 int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f);
66 int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f);
67 int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
69 int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
70 int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
74 * Generic Buffer Management
77 #define DRM_MAP_HASH_OFFSET 0x10000000
79 #if IS_ENABLED(CONFIG_DRM_LEGACY)
80 static inline int drm_legacy_create_map_hash(struct drm_device *dev)
82 return drm_ht_create(&dev->map_hash, 12);
85 static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
87 drm_ht_remove(&dev->map_hash);
90 static inline int drm_legacy_create_map_hash(struct drm_device *dev)
95 static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {}
99 #if IS_ENABLED(CONFIG_DRM_LEGACY)
100 int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
101 struct drm_file *file_priv);
102 int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
103 int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
105 int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
106 int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
107 int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
108 int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
109 int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
110 int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
113 int __drm_legacy_infobufs(struct drm_device *, void *, int *,
114 int (*)(void *, int, struct drm_buf_entry *));
115 int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
117 int (*)(void *, int, unsigned long, struct drm_buf *),
120 #if IS_ENABLED(CONFIG_DRM_LEGACY)
121 void drm_legacy_master_rmmaps(struct drm_device *dev,
122 struct drm_master *master);
123 void drm_legacy_rmmaps(struct drm_device *dev);
125 static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
126 struct drm_master *master) {}
127 static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
130 #if IS_ENABLED(CONFIG_DRM_LEGACY)
131 void drm_legacy_vma_flush(struct drm_device *d);
133 static inline void drm_legacy_vma_flush(struct drm_device *d)
144 unsigned long handle;
145 struct agp_memory *memory;
148 struct list_head head;
151 /* drm_agpsupport.c */
152 #if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_AGP)
153 void drm_legacy_agp_clear(struct drm_device *dev);
155 int drm_legacy_agp_acquire_ioctl(struct drm_device *dev, void *data,
156 struct drm_file *file_priv);
157 int drm_legacy_agp_release_ioctl(struct drm_device *dev, void *data,
158 struct drm_file *file_priv);
159 int drm_legacy_agp_enable_ioctl(struct drm_device *dev, void *data,
160 struct drm_file *file_priv);
161 int drm_legacy_agp_info_ioctl(struct drm_device *dev, void *data,
162 struct drm_file *file_priv);
163 int drm_legacy_agp_alloc_ioctl(struct drm_device *dev, void *data,
164 struct drm_file *file_priv);
165 int drm_legacy_agp_free_ioctl(struct drm_device *dev, void *data,
166 struct drm_file *file_priv);
167 int drm_legacy_agp_unbind_ioctl(struct drm_device *dev, void *data,
168 struct drm_file *file_priv);
169 int drm_legacy_agp_bind_ioctl(struct drm_device *dev, void *data,
170 struct drm_file *file_priv);
172 static inline void drm_legacy_agp_clear(struct drm_device *dev) {}
176 #if IS_ENABLED(CONFIG_DRM_LEGACY)
177 int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
178 int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
179 void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
181 static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {}
185 #if IS_ENABLED(CONFIG_DRM_LEGACY)
186 int drm_legacy_dma_setup(struct drm_device *dev);
187 void drm_legacy_dma_takedown(struct drm_device *dev);
189 static inline int drm_legacy_dma_setup(struct drm_device *dev)
195 void drm_legacy_free_buffer(struct drm_device *dev,
196 struct drm_buf * buf);
197 #if IS_ENABLED(CONFIG_DRM_LEGACY)
198 void drm_legacy_reclaim_buffers(struct drm_device *dev,
199 struct drm_file *filp);
201 static inline void drm_legacy_reclaim_buffers(struct drm_device *dev,
202 struct drm_file *filp) {}
205 /* Scatter Gather Support */
206 #if IS_ENABLED(CONFIG_DRM_LEGACY)
207 void drm_legacy_sg_cleanup(struct drm_device *dev);
208 int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
209 struct drm_file *file_priv);
210 int drm_legacy_sg_free(struct drm_device *dev, void *data,
211 struct drm_file *file_priv);
214 #if IS_ENABLED(CONFIG_DRM_LEGACY)
215 void drm_legacy_init_members(struct drm_device *dev);
216 void drm_legacy_destroy_members(struct drm_device *dev);
217 void drm_legacy_dev_reinit(struct drm_device *dev);
218 int drm_legacy_setup(struct drm_device * dev);
220 static inline void drm_legacy_init_members(struct drm_device *dev) {}
221 static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
222 static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
223 static inline int drm_legacy_setup(struct drm_device * dev) { return 0; }
226 #if IS_ENABLED(CONFIG_DRM_LEGACY)
227 void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
229 static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
232 #if IS_ENABLED(CONFIG_DRM_LEGACY)
233 void drm_master_legacy_init(struct drm_master *master);
235 static inline void drm_master_legacy_init(struct drm_master *master) {}
239 #if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
240 int drm_legacy_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv);
241 void drm_legacy_pci_agp_destroy(struct drm_device *dev);
243 static inline int drm_legacy_irq_by_busid(struct drm_device *dev, void *data,
244 struct drm_file *file_priv)
249 static inline void drm_legacy_pci_agp_destroy(struct drm_device *dev) {}
252 #endif /* __DRM_LEGACY_H__ */