1
2
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
32#ifndef _DRM_P_H_
33#define _DRM_P_H_
34
35#include <linux/agp_backend.h>
36#include <linux/cdev.h>
37#include <linux/dma-mapping.h>
38#include <linux/file.h>
39#include <linux/fs.h>
40#include <linux/highmem.h>
41#include <linux/idr.h>
42#include <linux/init.h>
43#include <linux/io.h>
44#include <linux/jiffies.h>
45#include <linux/kernel.h>
46#include <linux/kref.h>
47#include <linux/miscdevice.h>
48#include <linux/mm.h>
49#include <linux/mutex.h>
50#include <linux/platform_device.h>
51#include <linux/poll.h>
52#include <linux/ratelimit.h>
53#include <linux/sched.h>
54#include <linux/slab.h>
55#include <linux/types.h>
56#include <linux/vmalloc.h>
57#include <linux/workqueue.h>
58#include <linux/dma-fence.h>
59#include <linux/module.h>
60
61#include <asm/mman.h>
62#include <asm/pgalloc.h>
63#include <linux/uaccess.h>
64
65#include <uapi/drm/drm.h>
66#include <uapi/drm/drm_mode.h>
67
68#include <drm/drm_agpsupport.h>
69#include <drm/drm_crtc.h>
70#include <drm/drm_fourcc.h>
71#include <drm/drm_global.h>
72#include <drm/drm_hashtab.h>
73#include <drm/drm_mm.h>
74#include <drm/drm_os_linux.h>
75#include <drm/drm_sarea.h>
76#include <drm/drm_drv.h>
77#include <drm/drm_prime.h>
78#include <drm/drm_pci.h>
79#include <drm/drm_file.h>
80#include <drm/drm_debugfs.h>
81#include <drm/drm_ioctl.h>
82#include <drm/drm_sysfs.h>
83#include <drm/drm_vblank.h>
84#include <drm/drm_irq.h>
85#include <drm/drm_device.h>
86
87struct module;
88
89struct device_node;
90struct videomode;
91struct reservation_object;
92struct dma_buf_attachment;
93
94struct pci_dev;
95struct pci_controller;
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131#define DRM_UT_NONE 0x00
132#define DRM_UT_CORE 0x01
133#define DRM_UT_DRIVER 0x02
134#define DRM_UT_KMS 0x04
135#define DRM_UT_PRIME 0x08
136#define DRM_UT_ATOMIC 0x10
137#define DRM_UT_VBL 0x20
138#define DRM_UT_STATE 0x40
139#define DRM_UT_LEASE 0x80
140
141
142
143
144
145
146
147
148
149#define _DRM_PRINTK(once, level, fmt, ...) \
150 do { \
151 printk##once(KERN_##level "[" DRM_NAME "] " fmt, \
152 ##__VA_ARGS__); \
153 } while (0)
154
155#define DRM_INFO(fmt, ...) \
156 _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
157#define DRM_NOTE(fmt, ...) \
158 _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
159#define DRM_WARN(fmt, ...) \
160 _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
161
162#define DRM_INFO_ONCE(fmt, ...) \
163 _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
164#define DRM_NOTE_ONCE(fmt, ...) \
165 _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
166#define DRM_WARN_ONCE(fmt, ...) \
167 _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
168
169
170
171
172
173
174
175#define DRM_DEV_ERROR(dev, fmt, ...) \
176 drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\
177 fmt, ##__VA_ARGS__)
178#define DRM_ERROR(fmt, ...) \
179 drm_printk(KERN_ERR, DRM_UT_NONE, fmt, ##__VA_ARGS__)
180
181
182
183
184
185
186
187#define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \
188({ \
189 static DEFINE_RATELIMIT_STATE(_rs, \
190 DEFAULT_RATELIMIT_INTERVAL, \
191 DEFAULT_RATELIMIT_BURST); \
192 \
193 if (__ratelimit(&_rs)) \
194 DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \
195})
196#define DRM_ERROR_RATELIMITED(fmt, ...) \
197 DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
198
199#define DRM_DEV_INFO(dev, fmt, ...) \
200 drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \
201 ##__VA_ARGS__)
202
203#define DRM_DEV_INFO_ONCE(dev, fmt, ...) \
204({ \
205 static bool __print_once __read_mostly; \
206 if (!__print_once) { \
207 __print_once = true; \
208 DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \
209 } \
210})
211
212
213
214
215
216
217
218#define DRM_DEV_DEBUG(dev, fmt, args...) \
219 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \
220 ##args)
221#define DRM_DEBUG(fmt, ...) \
222 drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__)
223
224#define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \
225 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \
226 fmt, ##args)
227#define DRM_DEBUG_DRIVER(fmt, ...) \
228 drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
229
230#define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \
231 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \
232 ##args)
233#define DRM_DEBUG_KMS(fmt, ...) \
234 drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__)
235
236#define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \
237 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \
238 fmt, ##args)
239#define DRM_DEBUG_PRIME(fmt, ...) \
240 drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
241
242#define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \
243 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \
244 fmt, ##args)
245#define DRM_DEBUG_ATOMIC(fmt, ...) \
246 drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
247
248#define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \
249 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \
250 ##args)
251#define DRM_DEBUG_VBL(fmt, ...) \
252 drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__)
253
254#define DRM_DEBUG_LEASE(fmt, ...) \
255 drm_printk(KERN_DEBUG, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
256
257#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \
258({ \
259 static DEFINE_RATELIMIT_STATE(_rs, \
260 DEFAULT_RATELIMIT_INTERVAL, \
261 DEFAULT_RATELIMIT_BURST); \
262 if (__ratelimit(&_rs)) \
263 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level, \
264 __func__, "", fmt, ##args); \
265})
266
267
268
269
270
271
272
273#define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \
274 DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args)
275#define DRM_DEBUG_RATELIMITED(fmt, args...) \
276 DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args)
277#define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...) \
278 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args)
279#define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \
280 DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args)
281#define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...) \
282 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args)
283#define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \
284 DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args)
285#define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...) \
286 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args)
287#define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \
288 DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args)
289
290
291
292
293
294
295
296
297
298
299
300#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
301
302
303
304
305
306
307
308
309
310
311static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
312{
313 return dev->mode_config.funcs->atomic_commit != NULL;
314}
315
316#define DRM_SWITCH_POWER_ON 0
317#define DRM_SWITCH_POWER_OFF 1
318#define DRM_SWITCH_POWER_CHANGING 2
319#define DRM_SWITCH_POWER_DYNAMIC_OFF 3
320
321static __inline__ int drm_core_check_feature(struct drm_device *dev,
322 int feature)
323{
324 return ((dev->driver->driver_features & feature) ? 1 : 0);
325}
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341static __inline__ bool drm_can_sleep(void)
342{
343 if (in_atomic() || in_dbg_master() || irqs_disabled())
344 return false;
345 return true;
346}
347
348
349#define for_each_if(condition) if (!(condition)) {} else
350
351#endif
352