drm/i915: Move PLANE_BUG_CFG bit definitions to the correct place
[linux-2.6-block.git] / drivers / gpu / drm / drm_legacy.h
CommitLineData
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
37struct agp_memory;
a21800bc 38struct drm_buf_desc;
e7b96070
DH
39struct drm_device;
40struct drm_file;
a21800bc
TZ
41struct drm_hash_item;
42struct 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)
52int drm_ht_create(struct drm_open_hash *ht, unsigned int order);
53int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item);
54int 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);
57int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, struct drm_hash_item **item);
58
59void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key);
60int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key);
61int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item);
62void 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 88void drm_legacy_ctxbitmap_init(struct drm_device *dev);
e7b96070 89void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
e7b96070 90void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
61ae2270
DA
91#else
92static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {}
93static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {}
94static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {}
95#endif
e7b96070 96
61ae2270
DA
97void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
98
99#if IS_ENABLED(CONFIG_DRM_LEGACY)
e7b96070
DH
100int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
101int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
102int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
103int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f);
104int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f);
105int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
106
107int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
108int 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
118static inline int drm_legacy_create_map_hash(struct drm_device *dev)
119{
120 return drm_ht_create(&dev->map_hash, 12);
121}
122
123static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
124{
125 drm_ht_remove(&dev->map_hash);
126}
83c163f7
DA
127#else
128static inline int drm_legacy_create_map_hash(struct drm_device *dev)
129{
130 return 0;
131}
132
133static 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
138int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
139 struct drm_file *file_priv);
9fc5cde7
DH
140int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
141int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
61ae2270 142
9fc5cde7
DH
143int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
144int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
145int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
146int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
147int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
148int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
61ae2270 149#endif
9fc5cde7 150
5c7640ab
AV
151int __drm_legacy_infobufs(struct drm_device *, void *, int *,
152 int (*)(void *, int, struct drm_buf_entry *));
87d3ce11
AV
153int __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
159void drm_legacy_master_rmmaps(struct drm_device *dev,
160 struct drm_master *master);
35a28021 161void drm_legacy_rmmaps(struct drm_device *dev);
61ae2270
DA
162#else
163static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
164 struct drm_master *master) {}
165static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
166#endif
15e60851 167
02e415f8 168#if IS_ENABLED(CONFIG_DRM_LEGACY)
a677f4cc 169void drm_legacy_vma_flush(struct drm_device *d);
99c48e1e
BG
170#else
171static 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
181struct 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)
191void drm_legacy_agp_clear(struct drm_device *dev);
192
193int drm_legacy_agp_acquire_ioctl(struct drm_device *dev, void *data,
194 struct drm_file *file_priv);
195int drm_legacy_agp_release_ioctl(struct drm_device *dev, void *data,
196 struct drm_file *file_priv);
197int drm_legacy_agp_enable_ioctl(struct drm_device *dev, void *data,
198 struct drm_file *file_priv);
199int drm_legacy_agp_info_ioctl(struct drm_device *dev, void *data,
200 struct drm_file *file_priv);
201int drm_legacy_agp_alloc_ioctl(struct drm_device *dev, void *data,
202 struct drm_file *file_priv);
203int drm_legacy_agp_free_ioctl(struct drm_device *dev, void *data,
204 struct drm_file *file_priv);
205int drm_legacy_agp_unbind_ioctl(struct drm_device *dev, void *data,
206 struct drm_file *file_priv);
207int drm_legacy_agp_bind_ioctl(struct drm_device *dev, void *data,
208 struct drm_file *file_priv);
209#else
210static 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
215int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
216int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
1a75a222 217void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
61ae2270
DA
218#else
219static 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
224int drm_legacy_dma_setup(struct drm_device *dev);
225void drm_legacy_dma_takedown(struct drm_device *dev);
61ae2270
DA
226#else
227static inline int drm_legacy_dma_setup(struct drm_device *dev)
228{
229 return 0;
230}
231#endif
232
a266162a
DV
233void drm_legacy_free_buffer(struct drm_device *dev,
234 struct drm_buf * buf);
61ae2270 235#if IS_ENABLED(CONFIG_DRM_LEGACY)
a266162a
DV
236void drm_legacy_reclaim_buffers(struct drm_device *dev,
237 struct drm_file *filp);
61ae2270
DA
238#else
239static 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
245void drm_legacy_sg_cleanup(struct drm_device *dev);
246int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
247 struct drm_file *file_priv);
248int 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
253void drm_legacy_init_members(struct drm_device *dev);
254void drm_legacy_destroy_members(struct drm_device *dev);
1fa32cb6 255void drm_legacy_dev_reinit(struct drm_device *dev);
094aa54f 256int drm_legacy_setup(struct drm_device * dev);
61ae2270
DA
257#else
258static inline void drm_legacy_init_members(struct drm_device *dev) {}
259static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
260static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
094aa54f 261static 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 265void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
61ae2270
DA
266#else
267static 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)
271void drm_master_legacy_init(struct drm_master *master);
272#else
273static 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 278int drm_legacy_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv);
6bff2279
TZ
279void drm_legacy_pci_agp_destroy(struct drm_device *dev);
280#else
644adc3d
TZ
281static 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
287static inline void drm_legacy_pci_agp_destroy(struct drm_device *dev) {}
288#endif
289
e7b96070 290#endif /* __DRM_LEGACY_H__ */