1#ifndef __DRM_LEGACY_H__
2#define __DRM_LEGACY_H__
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#include <linux/list.h>
32
33#include <drm/drm.h>
34#include <drm/drm_device.h>
35#include <drm/drm_legacy.h>
36
37struct agp_memory;
38struct drm_device;
39struct drm_file;
40struct drm_buf_desc;
41
42
43
44
45
46#define DRM_KERNEL_CONTEXT 0
47#define DRM_RESERVED_CONTEXTS 1
48
49#if IS_ENABLED(CONFIG_DRM_LEGACY)
50void drm_legacy_ctxbitmap_init(struct drm_device *dev);
51void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
52void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
53#else
54static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {}
55static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {}
56static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {}
57#endif
58
59void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
60
61#if IS_ENABLED(CONFIG_DRM_LEGACY)
62int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
63int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
64int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
65int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f);
66int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f);
67int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
68
69int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
70int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
71#endif
72
73
74
75
76
77#define DRM_MAP_HASH_OFFSET 0x10000000
78
79#if IS_ENABLED(CONFIG_DRM_LEGACY)
80static inline int drm_legacy_create_map_hash(struct drm_device *dev)
81{
82 return drm_ht_create(&dev->map_hash, 12);
83}
84
85static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
86{
87 drm_ht_remove(&dev->map_hash);
88}
89#else
90static inline int drm_legacy_create_map_hash(struct drm_device *dev)
91{
92 return 0;
93}
94
95static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {}
96#endif
97
98
99#if IS_ENABLED(CONFIG_DRM_LEGACY)
100int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
101 struct drm_file *file_priv);
102int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
103int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
104
105int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
106int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
107int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
108int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
109int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
110int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
111#endif
112
113int __drm_legacy_infobufs(struct drm_device *, void *, int *,
114 int (*)(void *, int, struct drm_buf_entry *));
115int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
116 void __user **,
117 int (*)(void *, int, unsigned long, struct drm_buf *),
118 struct drm_file *);
119
120#if IS_ENABLED(CONFIG_DRM_LEGACY)
121void drm_legacy_master_rmmaps(struct drm_device *dev,
122 struct drm_master *master);
123void drm_legacy_rmmaps(struct drm_device *dev);
124#else
125static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
126 struct drm_master *master) {}
127static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
128#endif
129
130#if IS_ENABLED(CONFIG_DRM_VM) && IS_ENABLED(CONFIG_DRM_LEGACY)
131void drm_legacy_vma_flush(struct drm_device *d);
132#else
133static inline void drm_legacy_vma_flush(struct drm_device *d)
134{
135
136}
137#endif
138
139
140
141
142
143struct drm_agp_mem {
144 unsigned long handle;
145 struct agp_memory *memory;
146 unsigned long bound;
147 int pages;
148 struct list_head head;
149};
150
151
152#if IS_ENABLED(CONFIG_DRM_LEGACY)
153int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
154int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
155void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
156#else
157static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {}
158#endif
159
160
161#if IS_ENABLED(CONFIG_DRM_LEGACY)
162int drm_legacy_dma_setup(struct drm_device *dev);
163void drm_legacy_dma_takedown(struct drm_device *dev);
164#else
165static inline int drm_legacy_dma_setup(struct drm_device *dev)
166{
167 return 0;
168}
169#endif
170
171void drm_legacy_free_buffer(struct drm_device *dev,
172 struct drm_buf * buf);
173#if IS_ENABLED(CONFIG_DRM_LEGACY)
174void drm_legacy_reclaim_buffers(struct drm_device *dev,
175 struct drm_file *filp);
176#else
177static inline void drm_legacy_reclaim_buffers(struct drm_device *dev,
178 struct drm_file *filp) {}
179#endif
180
181
182#if IS_ENABLED(CONFIG_DRM_LEGACY)
183void drm_legacy_sg_cleanup(struct drm_device *dev);
184int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
185 struct drm_file *file_priv);
186int drm_legacy_sg_free(struct drm_device *dev, void *data,
187 struct drm_file *file_priv);
188#endif
189
190#if IS_ENABLED(CONFIG_DRM_LEGACY)
191void drm_legacy_init_members(struct drm_device *dev);
192void drm_legacy_destroy_members(struct drm_device *dev);
193void drm_legacy_dev_reinit(struct drm_device *dev);
194int drm_legacy_setup(struct drm_device * dev);
195#else
196static inline void drm_legacy_init_members(struct drm_device *dev) {}
197static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
198static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
199static inline int drm_legacy_setup(struct drm_device * dev) { return 0; }
200#endif
201
202#if IS_ENABLED(CONFIG_DRM_LEGACY)
203void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
204#else
205static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
206#endif
207
208#if IS_ENABLED(CONFIG_DRM_LEGACY)
209void drm_master_legacy_init(struct drm_master *master);
210#else
211static inline void drm_master_legacy_init(struct drm_master *master) {}
212#endif
213
214#endif
215