]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
d7d2c48e DH |
2 | * Internal Header for the Direct Rendering Manager |
3 | * | |
1da177e4 LT |
4 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
5 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | |
dcdb1674 | 6 | * Copyright (c) 2009-2010, Code Aurora Forum. |
1da177e4 LT |
7 | * All rights reserved. |
8 | * | |
d7d2c48e DH |
9 | * Author: Rickard E. (Rik) Faith <faith@valinux.com> |
10 | * Author: Gareth Hughes <gareth@valinux.com> | |
11 | * | |
1da177e4 LT |
12 | * Permission is hereby granted, free of charge, to any person obtaining a |
13 | * copy of this software and associated documentation files (the "Software"), | |
14 | * to deal in the Software without restriction, including without limitation | |
15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
16 | * and/or sell copies of the Software, and to permit persons to whom the | |
17 | * Software is furnished to do so, subject to the following conditions: | |
18 | * | |
19 | * The above copyright notice and this permission notice (including the next | |
20 | * paragraph) shall be included in all copies or substantial portions of the | |
21 | * Software. | |
22 | * | |
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
26 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
27 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
28 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
29 | * OTHER DEALINGS IN THE SOFTWARE. | |
30 | */ | |
31 | ||
32 | #ifndef _DRM_P_H_ | |
33 | #define _DRM_P_H_ | |
34 | ||
96993908 DH |
35 | #include <linux/agp_backend.h> |
36 | #include <linux/cdev.h> | |
37 | #include <linux/dma-mapping.h> | |
38 | #include <linux/file.h> | |
1da177e4 | 39 | #include <linux/fs.h> |
96993908 DH |
40 | #include <linux/highmem.h> |
41 | #include <linux/idr.h> | |
1da177e4 | 42 | #include <linux/init.h> |
96993908 | 43 | #include <linux/io.h> |
1da177e4 | 44 | #include <linux/jiffies.h> |
96993908 DH |
45 | #include <linux/kernel.h> |
46 | #include <linux/kref.h> | |
47 | #include <linux/miscdevice.h> | |
1da177e4 | 48 | #include <linux/mm.h> |
30e2fb18 | 49 | #include <linux/mutex.h> |
96993908 DH |
50 | #include <linux/platform_device.h> |
51 | #include <linux/poll.h> | |
5d13d425 | 52 | #include <linux/ratelimit.h> |
96993908 DH |
53 | #include <linux/sched.h> |
54 | #include <linux/slab.h> | |
1da177e4 | 55 | #include <linux/types.h> |
d6db6564 | 56 | #include <linux/vmalloc.h> |
96993908 | 57 | #include <linux/workqueue.h> |
f54d1867 | 58 | #include <linux/dma-fence.h> |
c6bb9baa | 59 | #include <linux/module.h> |
96993908 DH |
60 | |
61 | #include <asm/mman.h> | |
1da177e4 | 62 | #include <asm/pgalloc.h> |
7c0f6ba6 | 63 | #include <linux/uaccess.h> |
96993908 | 64 | |
d7d2c48e DH |
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> | |
ae4df11a | 70 | #include <drm/drm_fourcc.h> |
d7d2c48e | 71 | #include <drm/drm_global.h> |
96993908 | 72 | #include <drm/drm_hashtab.h> |
d7d2c48e | 73 | #include <drm/drm_mem_util.h> |
96993908 DH |
74 | #include <drm/drm_mm.h> |
75 | #include <drm/drm_os_linux.h> | |
19218e48 | 76 | #include <drm/drm_sarea.h> |
85e634bc | 77 | #include <drm/drm_drv.h> |
c6bb9baa | 78 | #include <drm/drm_prime.h> |
23ef59ef | 79 | #include <drm/drm_pci.h> |
a8f8b1d9 | 80 | #include <drm/drm_file.h> |
4834442d | 81 | #include <drm/drm_debugfs.h> |
7cfdf711 | 82 | #include <drm/drm_ioctl.h> |
e2271704 | 83 | #include <drm/drm_sysfs.h> |
1da177e4 | 84 | |
de477254 PG |
85 | struct module; |
86 | ||
c153f45f | 87 | struct drm_device; |
cc5ea594 | 88 | struct drm_agp_head; |
ba8286fa DV |
89 | struct drm_local_map; |
90 | struct drm_device_dma; | |
d9fc9413 | 91 | struct drm_gem_object; |
3b96a0b1 | 92 | struct drm_master; |
34a67dd7 | 93 | struct drm_vblank_crtc; |
c6bb9baa | 94 | struct drm_vma_offset_manager; |
c153f45f | 95 | |
edb37a95 | 96 | struct device_node; |
ebc64e45 | 97 | struct videomode; |
3aac4502 | 98 | struct reservation_object; |
b5e9c1a2 | 99 | struct dma_buf_attachment; |
ebc64e45 | 100 | |
23ef59ef DV |
101 | struct pci_dev; |
102 | struct pci_controller; | |
103 | ||
87fdff81 | 104 | /* |
346fea63 | 105 | * The following categories are defined: |
1414b76c LD |
106 | * |
107 | * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ... | |
108 | * This is the category used by the DRM_DEBUG() macro. | |
109 | * | |
110 | * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ... | |
111 | * This is the category used by the DRM_DEBUG_DRIVER() macro. | |
87fdff81 | 112 | * |
1414b76c LD |
113 | * KMS: used in the modesetting code. |
114 | * This is the category used by the DRM_DEBUG_KMS() macro. | |
87fdff81 | 115 | * |
1414b76c LD |
116 | * PRIME: used in the prime code. |
117 | * This is the category used by the DRM_DEBUG_PRIME() macro. | |
87fdff81 | 118 | * |
17a38d9c DV |
119 | * ATOMIC: used in the atomic code. |
120 | * This is the category used by the DRM_DEBUG_ATOMIC() macro. | |
121 | * | |
235fabe0 VS |
122 | * VBL: used for verbose debug message in the vblank code |
123 | * This is the category used by the DRM_DEBUG_VBL() macro. | |
124 | * | |
1414b76c LD |
125 | * Enabling verbose debug messages is done through the drm.debug parameter, |
126 | * each category being enabled by a bit. | |
127 | * | |
128 | * drm.debug=0x1 will enable CORE messages | |
129 | * drm.debug=0x2 will enable DRIVER messages | |
130 | * drm.debug=0x3 will enable CORE and DRIVER messages | |
131 | * ... | |
235fabe0 | 132 | * drm.debug=0x3f will enable all messages |
1414b76c LD |
133 | * |
134 | * An interesting feature is that it's possible to enable verbose logging at | |
135 | * run-time by echoing the debug value in its sysfs node: | |
136 | * # echo 0xf > /sys/module/drm/parameters/debug | |
87fdff81 | 137 | */ |
c4e68a58 | 138 | #define DRM_UT_NONE 0x00 |
1414b76c LD |
139 | #define DRM_UT_CORE 0x01 |
140 | #define DRM_UT_DRIVER 0x02 | |
141 | #define DRM_UT_KMS 0x04 | |
142 | #define DRM_UT_PRIME 0x08 | |
17a38d9c | 143 | #define DRM_UT_ATOMIC 0x10 |
235fabe0 | 144 | #define DRM_UT_VBL 0x20 |
fceffb32 | 145 | #define DRM_UT_STATE 0x40 |
4fefcb27 | 146 | |
1da177e4 LT |
147 | /***********************************************************************/ |
148 | /** \name DRM template customization defaults */ | |
149 | /*@{*/ | |
150 | ||
1da177e4 | 151 | /***********************************************************************/ |
1da177e4 LT |
152 | /** \name Macros to make printk easier */ |
153 | /*@{*/ | |
154 | ||
30b0da8d DG |
155 | #define _DRM_PRINTK(once, level, fmt, ...) \ |
156 | do { \ | |
157 | printk##once(KERN_##level "[" DRM_NAME "] " fmt, \ | |
158 | ##__VA_ARGS__); \ | |
159 | } while (0) | |
160 | ||
161 | #define DRM_INFO(fmt, ...) \ | |
162 | _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__) | |
163 | #define DRM_NOTE(fmt, ...) \ | |
164 | _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__) | |
165 | #define DRM_WARN(fmt, ...) \ | |
166 | _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__) | |
167 | ||
168 | #define DRM_INFO_ONCE(fmt, ...) \ | |
169 | _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__) | |
170 | #define DRM_NOTE_ONCE(fmt, ...) \ | |
171 | _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__) | |
172 | #define DRM_WARN_ONCE(fmt, ...) \ | |
173 | _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__) | |
174 | ||
1da177e4 LT |
175 | /** |
176 | * Error output. | |
177 | * | |
178 | * \param fmt printf() like format string. | |
179 | * \param arg arguments | |
180 | */ | |
c4e68a58 SP |
181 | #define DRM_DEV_ERROR(dev, fmt, ...) \ |
182 | drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\ | |
183 | fmt, ##__VA_ARGS__) | |
184 | #define DRM_ERROR(fmt, ...) \ | |
6bd488db | 185 | drm_printk(KERN_ERR, DRM_UT_NONE, fmt, ##__VA_ARGS__) |
1da177e4 | 186 | |
5d13d425 RC |
187 | /** |
188 | * Rate limited error output. Like DRM_ERROR() but won't flood the log. | |
189 | * | |
190 | * \param fmt printf() like format string. | |
191 | * \param arg arguments | |
192 | */ | |
c4e68a58 | 193 | #define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \ |
5d13d425 RC |
194 | ({ \ |
195 | static DEFINE_RATELIMIT_STATE(_rs, \ | |
196 | DEFAULT_RATELIMIT_INTERVAL, \ | |
197 | DEFAULT_RATELIMIT_BURST); \ | |
198 | \ | |
199 | if (__ratelimit(&_rs)) \ | |
c4e68a58 | 200 | DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \ |
5d13d425 | 201 | }) |
c4e68a58 SP |
202 | #define DRM_ERROR_RATELIMITED(fmt, ...) \ |
203 | DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) | |
5d13d425 | 204 | |
c4e68a58 SP |
205 | #define DRM_DEV_INFO(dev, fmt, ...) \ |
206 | drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \ | |
207 | ##__VA_ARGS__) | |
1da177e4 | 208 | |
c4e68a58 SP |
209 | #define DRM_DEV_INFO_ONCE(dev, fmt, ...) \ |
210 | ({ \ | |
211 | static bool __print_once __read_mostly; \ | |
212 | if (!__print_once) { \ | |
213 | __print_once = true; \ | |
214 | DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \ | |
215 | } \ | |
216 | }) | |
48b8f631 | 217 | |
1da177e4 LT |
218 | /** |
219 | * Debug output. | |
b5e89ed5 | 220 | * |
1da177e4 LT |
221 | * \param fmt printf() like format string. |
222 | * \param arg arguments | |
223 | */ | |
c4e68a58 SP |
224 | #define DRM_DEV_DEBUG(dev, fmt, args...) \ |
225 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \ | |
226 | ##args) | |
6bd488db JP |
227 | #define DRM_DEBUG(fmt, ...) \ |
228 | drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__) | |
4fefcb27 | 229 | |
c4e68a58 SP |
230 | #define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \ |
231 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \ | |
232 | fmt, ##args) | |
6bd488db JP |
233 | #define DRM_DEBUG_DRIVER(fmt, ...) \ |
234 | drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) | |
c4e68a58 SP |
235 | |
236 | #define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \ | |
237 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \ | |
238 | ##args) | |
6bd488db JP |
239 | #define DRM_DEBUG_KMS(fmt, ...) \ |
240 | drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__) | |
c4e68a58 SP |
241 | |
242 | #define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \ | |
243 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \ | |
244 | fmt, ##args) | |
6bd488db JP |
245 | #define DRM_DEBUG_PRIME(fmt, ...) \ |
246 | drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__) | |
c4e68a58 SP |
247 | |
248 | #define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \ | |
249 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \ | |
250 | fmt, ##args) | |
6bd488db JP |
251 | #define DRM_DEBUG_ATOMIC(fmt, ...) \ |
252 | drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) | |
c4e68a58 SP |
253 | |
254 | #define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \ | |
255 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \ | |
256 | ##args) | |
6bd488db JP |
257 | #define DRM_DEBUG_VBL(fmt, ...) \ |
258 | drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__) | |
1da177e4 | 259 | |
c4e68a58 SP |
260 | #define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \ |
261 | ({ \ | |
262 | static DEFINE_RATELIMIT_STATE(_rs, \ | |
263 | DEFAULT_RATELIMIT_INTERVAL, \ | |
264 | DEFAULT_RATELIMIT_BURST); \ | |
265 | if (__ratelimit(&_rs)) \ | |
266 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level, \ | |
267 | __func__, "", fmt, ##args); \ | |
268 | }) | |
27528c66 L |
269 | |
270 | /** | |
271 | * Rate limited debug output. Like DRM_DEBUG() but won't flood the log. | |
272 | * | |
273 | * \param fmt printf() like format string. | |
274 | * \param arg arguments | |
275 | */ | |
c4e68a58 SP |
276 | #define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \ |
277 | DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args) | |
27528c66 | 278 | #define DRM_DEBUG_RATELIMITED(fmt, args...) \ |
c4e68a58 SP |
279 | DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args) |
280 | #define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...) \ | |
281 | _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args) | |
27528c66 | 282 | #define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \ |
c4e68a58 SP |
283 | DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args) |
284 | #define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...) \ | |
285 | _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args) | |
27528c66 | 286 | #define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \ |
c4e68a58 SP |
287 | DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args) |
288 | #define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...) \ | |
289 | _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args) | |
27528c66 | 290 | #define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \ |
c4e68a58 | 291 | DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args) |
27528c66 | 292 | |
65c7dc18 RC |
293 | /* Format strings and argument splitters to simplify printing |
294 | * various "complex" objects | |
295 | */ | |
296 | #define DRM_MODE_FMT "%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x" | |
297 | #define DRM_MODE_ARG(m) \ | |
298 | (m)->base.id, (m)->name, (m)->vrefresh, (m)->clock, \ | |
299 | (m)->hdisplay, (m)->hsync_start, (m)->hsync_end, (m)->htotal, \ | |
300 | (m)->vdisplay, (m)->vsync_start, (m)->vsync_end, (m)->vtotal, \ | |
301 | (m)->type, (m)->flags | |
302 | ||
303 | #define DRM_RECT_FMT "%dx%d%+d%+d" | |
304 | #define DRM_RECT_ARG(r) drm_rect_width(r), drm_rect_height(r), (r)->x1, (r)->y1 | |
305 | ||
306 | /* for rect's in fixed-point format: */ | |
307 | #define DRM_RECT_FP_FMT "%d.%06ux%d.%06u%+d.%06u%+d.%06u" | |
308 | #define DRM_RECT_FP_ARG(r) \ | |
309 | drm_rect_width(r) >> 16, ((drm_rect_width(r) & 0xffff) * 15625) >> 10, \ | |
310 | drm_rect_height(r) >> 16, ((drm_rect_height(r) & 0xffff) * 15625) >> 10, \ | |
311 | (r)->x1 >> 16, (((r)->x1 & 0xffff) * 15625) >> 10, \ | |
312 | (r)->y1 >> 16, (((r)->y1 & 0xffff) * 15625) >> 10 | |
313 | ||
1da177e4 LT |
314 | /*@}*/ |
315 | ||
1da177e4 LT |
316 | /***********************************************************************/ |
317 | /** \name Internal types and structures */ | |
318 | /*@{*/ | |
319 | ||
1da177e4 | 320 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
1da177e4 | 321 | |
1da177e4 | 322 | |
1da177e4 LT |
323 | /** |
324 | * DRM device structure. This structure represent a complete card that | |
325 | * may contain multiple heads. | |
326 | */ | |
84b1fd10 | 327 | struct drm_device { |
b3f2333d | 328 | struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ |
b5e89ed5 | 329 | int if_version; /**< Highest interface version set */ |
1da177e4 | 330 | |
45e212d2 DH |
331 | /** \name Lifetime Management */ |
332 | /*@{ */ | |
099d1c29 | 333 | struct kref ref; /**< Object ref-count */ |
45e212d2 DH |
334 | struct device *dev; /**< Device structure of bus-device */ |
335 | struct drm_driver *driver; /**< DRM driver managing the device */ | |
336 | void *dev_private; /**< DRM driver private data */ | |
45e212d2 DH |
337 | struct drm_minor *control; /**< Control node */ |
338 | struct drm_minor *primary; /**< Primary node */ | |
339 | struct drm_minor *render; /**< Render node */ | |
e6e7b48b | 340 | bool registered; |
95c081c1 DV |
341 | |
342 | /* currently active master for this device. Protected by master_mutex */ | |
343 | struct drm_master *master; | |
344 | ||
45e212d2 | 345 | atomic_t unplugged; /**< Flag whether dev is dead */ |
07b48c3a | 346 | struct inode *anon_inode; /**< inode for private address-space */ |
ca8e2ad7 | 347 | char *unique; /**< unique name of the device */ |
45e212d2 DH |
348 | /*@} */ |
349 | ||
1da177e4 | 350 | /** \name Locks */ |
b5e89ed5 | 351 | /*@{ */ |
30e2fb18 | 352 | struct mutex struct_mutex; /**< For others */ |
c996fd0b | 353 | struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */ |
b5e89ed5 | 354 | /*@} */ |
1da177e4 LT |
355 | |
356 | /** \name Usage Counters */ | |
b5e89ed5 | 357 | /*@{ */ |
fc8fd40e | 358 | int open_count; /**< Outstanding files open, protected by drm_global_mutex. */ |
2177a218 | 359 | spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */ |
b5e89ed5 DA |
360 | int buf_use; /**< Buffers in use -- cannot alloc */ |
361 | atomic_t buf_alloc; /**< Buffer allocation in progress */ | |
362 | /*@} */ | |
1da177e4 | 363 | |
1d2ac403 | 364 | struct mutex filelist_mutex; |
bd1b331f | 365 | struct list_head filelist; |
1da177e4 LT |
366 | |
367 | /** \name Memory management */ | |
b5e89ed5 | 368 | /*@{ */ |
bd1b331f | 369 | struct list_head maplist; /**< Linked list of regions */ |
e0be428e | 370 | struct drm_open_hash map_hash; /**< User token hash table for maps */ |
1da177e4 LT |
371 | |
372 | /** \name Context handle management */ | |
b5e89ed5 | 373 | /*@{ */ |
bd1b331f | 374 | struct list_head ctxlist; /**< Linked list of context handles */ |
30e2fb18 | 375 | struct mutex ctxlist_mutex; /**< For ctxlist */ |
1da177e4 | 376 | |
62968144 | 377 | struct idr ctx_idr; |
1da177e4 | 378 | |
bd1b331f | 379 | struct list_head vmalist; /**< List of vmas (for debugging) */ |
f453ba04 | 380 | |
b5e89ed5 | 381 | /*@} */ |
1da177e4 | 382 | |
a344a7e7 | 383 | /** \name DMA support */ |
b5e89ed5 | 384 | /*@{ */ |
cdd55a29 | 385 | struct drm_device_dma *dma; /**< Optional pointer for DMA support */ |
b5e89ed5 | 386 | /*@} */ |
1da177e4 LT |
387 | |
388 | /** \name Context support */ | |
b5e89ed5 | 389 | /*@{ */ |
7c1a38e3 | 390 | |
1da177e4 | 391 | __volatile__ long context_flag; /**< Context swapping flag */ |
b5e89ed5 | 392 | int last_context; /**< Last current context */ |
b5e89ed5 DA |
393 | /*@} */ |
394 | ||
1da177e4 | 395 | /** \name VBLANK IRQ support */ |
b5e89ed5 | 396 | /*@{ */ |
b46004b7 TR |
397 | bool irq_enabled; |
398 | int irq; | |
b5e89ed5 | 399 | |
00185e66 VS |
400 | /* |
401 | * If true, vblank interrupt will be disabled immediately when the | |
402 | * refcount drops to zero, as opposed to via the vblank disable | |
403 | * timer. | |
404 | * This can be set to true it the hardware has a working vblank | |
405 | * counter and the driver uses drm_vblank_on() and drm_vblank_off() | |
406 | * appropriately. | |
407 | */ | |
408 | bool vblank_disable_immediate; | |
409 | ||
5380e929 VS |
410 | /* array of size num_crtcs */ |
411 | struct drm_vblank_crtc *vblank; | |
0a3e67a4 | 412 | |
27641c3f | 413 | spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ |
b5e89ed5 | 414 | spinlock_t vbl_lock; |
0a3e67a4 JB |
415 | |
416 | u32 max_vblank_count; /**< size of vblank counter register */ | |
b5e89ed5 | 417 | |
c9a9c5e0 KH |
418 | /** |
419 | * List of events | |
420 | */ | |
421 | struct list_head vblank_event_list; | |
422 | spinlock_t event_lock; | |
423 | ||
b5e89ed5 | 424 | /*@} */ |
b5e89ed5 | 425 | |
55910517 | 426 | struct drm_agp_head *agp; /**< AGP data */ |
1da177e4 | 427 | |
b5e89ed5 | 428 | struct pci_dev *pdev; /**< PCI device structure */ |
1da177e4 | 429 | #ifdef __alpha__ |
1da177e4 | 430 | struct pci_controller *hose; |
1da177e4 | 431 | #endif |
dcdb1674 | 432 | |
dc5698e8 | 433 | struct virtio_device *virtdev; |
dcdb1674 | 434 | |
55910517 | 435 | struct drm_sg_mem *sg; /**< Scatter gather memory */ |
19227561 | 436 | unsigned int num_crtcs; /**< Number of CRTCs on this device */ |
b5e89ed5 | 437 | |
69d516c0 DH |
438 | struct { |
439 | int context; | |
440 | struct drm_hw_lock *lock; | |
441 | } sigdata; | |
442 | ||
f77d390c | 443 | struct drm_local_map *agp_buffer_map; |
d1f2b55a | 444 | unsigned int agp_buffer_token; |
bea5679f | 445 | |
417009fb | 446 | struct drm_mode_config mode_config; /**< Current mode config */ |
f453ba04 | 447 | |
673a394b EA |
448 | /** \name GEM information */ |
449 | /*@{ */ | |
cd4f013f | 450 | struct mutex object_name_lock; |
673a394b | 451 | struct idr object_name_idr; |
b04a5906 | 452 | struct drm_vma_offset_manager *vma_offset_manager; |
673a394b | 453 | /*@} */ |
5bcf719b | 454 | int switch_power_state; |
84b1fd10 | 455 | }; |
1da177e4 | 456 | |
a743d758 DP |
457 | /** |
458 | * drm_drv_uses_atomic_modeset - check if the driver implements | |
459 | * atomic_commit() | |
460 | * @dev: DRM device | |
461 | * | |
462 | * This check is useful if drivers do not have DRIVER_ATOMIC set but | |
463 | * have atomic modesetting internally implemented. | |
464 | */ | |
465 | static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev) | |
466 | { | |
467 | return dev->mode_config.funcs->atomic_commit != NULL; | |
468 | } | |
469 | ||
34a67dd7 DV |
470 | #include <drm/drm_irq.h> |
471 | ||
5bcf719b DA |
472 | #define DRM_SWITCH_POWER_ON 0 |
473 | #define DRM_SWITCH_POWER_OFF 1 | |
474 | #define DRM_SWITCH_POWER_CHANGING 2 | |
13bb9cc8 | 475 | #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 |
5bcf719b | 476 | |
b5e89ed5 DA |
477 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
478 | int feature) | |
1da177e4 LT |
479 | { |
480 | return ((dev->driver->driver_features & feature) ? 1 : 0); | |
481 | } | |
482 | ||
2c07a21d DA |
483 | static inline void drm_device_set_unplugged(struct drm_device *dev) |
484 | { | |
485 | smp_wmb(); | |
486 | atomic_set(&dev->unplugged, 1); | |
487 | } | |
488 | ||
489 | static inline int drm_device_is_unplugged(struct drm_device *dev) | |
490 | { | |
491 | int ret = atomic_read(&dev->unplugged); | |
492 | smp_rmb(); | |
493 | return ret; | |
494 | } | |
495 | ||
1da177e4 LT |
496 | /******************************************************************/ |
497 | /** \name Internal function definitions */ | |
498 | /*@{*/ | |
499 | ||
1da177e4 | 500 | /* Driver support (drm_drv.h) */ |
1da177e4 | 501 | |
040ac320 TH |
502 | /* |
503 | * These are exported to drivers so that they can implement fencing using | |
504 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. | |
505 | */ | |
506 | ||
8410ea3b DA |
507 | /*@}*/ |
508 | ||
cc1f7194 DA |
509 | /* returns true if currently okay to sleep */ |
510 | static __inline__ bool drm_can_sleep(void) | |
511 | { | |
512 | if (in_atomic() || in_dbg_master() || irqs_disabled()) | |
513 | return false; | |
514 | return true; | |
515 | } | |
516 | ||
373701b1 JN |
517 | /* helper for handling conditionals in various for_each macros */ |
518 | #define for_each_if(condition) if (!(condition)) {} else | |
519 | ||
1da177e4 | 520 | #endif |