]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - drivers/gpu/drm/drm_legacy.h
Merge tag 'drm-intel-next-2019-05-24' of git://anongit.freedesktop.org/drm/drm-intel...
[thirdparty/kernel/stable.git] / drivers / gpu / drm / drm_legacy.h
CommitLineData
e7b96070
DR
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
DR
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>
4f03b1fc 32#include <drm/drm_legacy.h>
cc5ea594
DR
33
34struct agp_memory;
e7b96070
DR
35struct drm_device;
36struct drm_file;
37
38/*
39 * Generic DRM Contexts
40 */
41
42#define DRM_KERNEL_CONTEXT 0
43#define DRM_RESERVED_CONTEXTS 1
44
61ae2270 45#if IS_ENABLED(CONFIG_DRM_LEGACY)
ba6976c1 46void drm_legacy_ctxbitmap_init(struct drm_device *dev);
e7b96070 47void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
e7b96070 48void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
61ae2270
DA
49#else
50static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {}
51static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {}
52static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {}
53#endif
e7b96070 54
61ae2270
DA
55void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
56
57#if IS_ENABLED(CONFIG_DRM_LEGACY)
e7b96070
DR
58int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
59int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
60int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
61int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f);
62int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f);
63int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
64
65int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
66int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
61ae2270 67#endif
e7b96070 68
9fc5cde7
DR
69/*
70 * Generic Buffer Management
71 */
72
73#define DRM_MAP_HASH_OFFSET 0x10000000
74
83c163f7 75#if IS_ENABLED(CONFIG_DRM_LEGACY)
fabb0e2a
DA
76static inline int drm_legacy_create_map_hash(struct drm_device *dev)
77{
78 return drm_ht_create(&dev->map_hash, 12);
79}
80
81static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
82{
83 drm_ht_remove(&dev->map_hash);
84}
83c163f7
DA
85#else
86static inline int drm_legacy_create_map_hash(struct drm_device *dev)
87{
88 return 0;
89}
90
91static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {}
92#endif
fabb0e2a 93
61ae2270
DA
94
95#if IS_ENABLED(CONFIG_DRM_LEGACY)
ec1f52ef
DV
96int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
97 struct drm_file *file_priv);
9fc5cde7
DR
98int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
99int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
61ae2270 100
9fc5cde7
DR
101int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
102int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
103int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
104int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
105int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
106int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
61ae2270 107#endif
9fc5cde7 108
5c7640ab
AV
109int __drm_legacy_infobufs(struct drm_device *, void *, int *,
110 int (*)(void *, int, struct drm_buf_entry *));
87d3ce11
AV
111int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
112 void __user **,
113 int (*)(void *, int, unsigned long, struct drm_buf *),
114 struct drm_file *);
5c7640ab 115
61ae2270 116#if IS_ENABLED(CONFIG_DRM_LEGACY)
15e60851
DA
117void drm_legacy_master_rmmaps(struct drm_device *dev,
118 struct drm_master *master);
35a28021 119void drm_legacy_rmmaps(struct drm_device *dev);
61ae2270
DA
120#else
121static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
122 struct drm_master *master) {}
123static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
124#endif
15e60851 125
61ae2270 126#if IS_ENABLED(CONFIG_DRM_VM) && IS_ENABLED(CONFIG_DRM_LEGACY)
a677f4cc 127void drm_legacy_vma_flush(struct drm_device *d);
99c48e1e
BG
128#else
129static inline void drm_legacy_vma_flush(struct drm_device *d)
130{
131 /* do nothing */
132}
133#endif
a677f4cc 134
cc5ea594
DR
135/*
136 * AGP Support
137 */
138
139struct drm_agp_mem {
140 unsigned long handle;
141 struct agp_memory *memory;
142 unsigned long bound;
143 int pages;
144 struct list_head head;
145};
146
1a75a222 147/* drm_lock.c */
61ae2270 148#if IS_ENABLED(CONFIG_DRM_LEGACY)
bb6d822e
DR
149int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
150int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
1a75a222 151void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
61ae2270
DA
152#else
153static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {}
154#endif
bb6d822e 155
a266162a 156/* DMA support */
61ae2270 157#if IS_ENABLED(CONFIG_DRM_LEGACY)
a266162a
DV
158int drm_legacy_dma_setup(struct drm_device *dev);
159void drm_legacy_dma_takedown(struct drm_device *dev);
61ae2270
DA
160#else
161static inline int drm_legacy_dma_setup(struct drm_device *dev)
162{
163 return 0;
164}
165#endif
166
a266162a
DV
167void drm_legacy_free_buffer(struct drm_device *dev,
168 struct drm_buf * buf);
61ae2270 169#if IS_ENABLED(CONFIG_DRM_LEGACY)
a266162a
DV
170void drm_legacy_reclaim_buffers(struct drm_device *dev,
171 struct drm_file *filp);
61ae2270
DA
172#else
173static inline void drm_legacy_reclaim_buffers(struct drm_device *dev,
174 struct drm_file *filp) {}
175#endif
a266162a 176
9ec4e2ff 177/* Scatter Gather Support */
61ae2270 178#if IS_ENABLED(CONFIG_DRM_LEGACY)
9ec4e2ff
DV
179void drm_legacy_sg_cleanup(struct drm_device *dev);
180int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
181 struct drm_file *file_priv);
182int drm_legacy_sg_free(struct drm_device *dev, void *data,
183 struct drm_file *file_priv);
61ae2270 184#endif
9ec4e2ff 185
61ae2270 186#if IS_ENABLED(CONFIG_DRM_LEGACY)
8437dd73
DA
187void drm_legacy_init_members(struct drm_device *dev);
188void drm_legacy_destroy_members(struct drm_device *dev);
1fa32cb6 189void drm_legacy_dev_reinit(struct drm_device *dev);
094aa54f 190int drm_legacy_setup(struct drm_device * dev);
61ae2270
DA
191#else
192static inline void drm_legacy_init_members(struct drm_device *dev) {}
193static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
194static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
094aa54f 195static inline int drm_legacy_setup(struct drm_device * dev) { return 0; }
61ae2270 196#endif
8437dd73 197
61ae2270 198#if IS_ENABLED(CONFIG_DRM_LEGACY)
058ca50c 199void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
61ae2270
DA
200#else
201static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
202#endif
203
ee22f763
DA
204#if IS_ENABLED(CONFIG_DRM_LEGACY)
205void drm_master_legacy_init(struct drm_master *master);
206#else
207static inline void drm_master_legacy_init(struct drm_master *master) {}
208#endif
209
e7b96070 210#endif /* __DRM_LEGACY_H__ */