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 DH |
72 | #include <drm/drm_hashtab.h> |
73 | #include <drm/drm_mm.h> | |
74 | #include <drm/drm_os_linux.h> | |
19218e48 | 75 | #include <drm/drm_sarea.h> |
85e634bc | 76 | #include <drm/drm_drv.h> |
c6bb9baa | 77 | #include <drm/drm_prime.h> |
23ef59ef | 78 | #include <drm/drm_pci.h> |
a8f8b1d9 | 79 | #include <drm/drm_file.h> |
4834442d | 80 | #include <drm/drm_debugfs.h> |
7cfdf711 | 81 | #include <drm/drm_ioctl.h> |
e2271704 | 82 | #include <drm/drm_sysfs.h> |
3ed4351a DV |
83 | #include <drm/drm_vblank.h> |
84 | #include <drm/drm_irq.h> | |
85 | ||
1da177e4 | 86 | |
de477254 PG |
87 | struct module; |
88 | ||
c153f45f | 89 | struct drm_device; |
cc5ea594 | 90 | struct drm_agp_head; |
ba8286fa DV |
91 | struct drm_local_map; |
92 | struct drm_device_dma; | |
d9fc9413 | 93 | struct drm_gem_object; |
3b96a0b1 | 94 | struct drm_master; |
34a67dd7 | 95 | struct drm_vblank_crtc; |
c6bb9baa | 96 | struct drm_vma_offset_manager; |
c153f45f | 97 | |
edb37a95 | 98 | struct device_node; |
ebc64e45 | 99 | struct videomode; |
3aac4502 | 100 | struct reservation_object; |
b5e9c1a2 | 101 | struct dma_buf_attachment; |
ebc64e45 | 102 | |
23ef59ef DV |
103 | struct pci_dev; |
104 | struct pci_controller; | |
105 | ||
87fdff81 | 106 | /* |
346fea63 | 107 | * The following categories are defined: |
1414b76c LD |
108 | * |
109 | * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ... | |
110 | * This is the category used by the DRM_DEBUG() macro. | |
111 | * | |
112 | * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ... | |
113 | * This is the category used by the DRM_DEBUG_DRIVER() macro. | |
87fdff81 | 114 | * |
1414b76c LD |
115 | * KMS: used in the modesetting code. |
116 | * This is the category used by the DRM_DEBUG_KMS() macro. | |
87fdff81 | 117 | * |
1414b76c LD |
118 | * PRIME: used in the prime code. |
119 | * This is the category used by the DRM_DEBUG_PRIME() macro. | |
87fdff81 | 120 | * |
17a38d9c DV |
121 | * ATOMIC: used in the atomic code. |
122 | * This is the category used by the DRM_DEBUG_ATOMIC() macro. | |
123 | * | |
235fabe0 VS |
124 | * VBL: used for verbose debug message in the vblank code |
125 | * This is the category used by the DRM_DEBUG_VBL() macro. | |
126 | * | |
1414b76c LD |
127 | * Enabling verbose debug messages is done through the drm.debug parameter, |
128 | * each category being enabled by a bit. | |
129 | * | |
130 | * drm.debug=0x1 will enable CORE messages | |
131 | * drm.debug=0x2 will enable DRIVER messages | |
132 | * drm.debug=0x3 will enable CORE and DRIVER messages | |
133 | * ... | |
235fabe0 | 134 | * drm.debug=0x3f will enable all messages |
1414b76c LD |
135 | * |
136 | * An interesting feature is that it's possible to enable verbose logging at | |
137 | * run-time by echoing the debug value in its sysfs node: | |
138 | * # echo 0xf > /sys/module/drm/parameters/debug | |
87fdff81 | 139 | */ |
c4e68a58 | 140 | #define DRM_UT_NONE 0x00 |
1414b76c LD |
141 | #define DRM_UT_CORE 0x01 |
142 | #define DRM_UT_DRIVER 0x02 | |
143 | #define DRM_UT_KMS 0x04 | |
144 | #define DRM_UT_PRIME 0x08 | |
17a38d9c | 145 | #define DRM_UT_ATOMIC 0x10 |
235fabe0 | 146 | #define DRM_UT_VBL 0x20 |
fceffb32 | 147 | #define DRM_UT_STATE 0x40 |
4fefcb27 | 148 | |
1da177e4 LT |
149 | /***********************************************************************/ |
150 | /** \name DRM template customization defaults */ | |
151 | /*@{*/ | |
152 | ||
1da177e4 | 153 | /***********************************************************************/ |
1da177e4 LT |
154 | /** \name Macros to make printk easier */ |
155 | /*@{*/ | |
156 | ||
30b0da8d DG |
157 | #define _DRM_PRINTK(once, level, fmt, ...) \ |
158 | do { \ | |
159 | printk##once(KERN_##level "[" DRM_NAME "] " fmt, \ | |
160 | ##__VA_ARGS__); \ | |
161 | } while (0) | |
162 | ||
163 | #define DRM_INFO(fmt, ...) \ | |
164 | _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__) | |
165 | #define DRM_NOTE(fmt, ...) \ | |
166 | _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__) | |
167 | #define DRM_WARN(fmt, ...) \ | |
168 | _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__) | |
169 | ||
170 | #define DRM_INFO_ONCE(fmt, ...) \ | |
171 | _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__) | |
172 | #define DRM_NOTE_ONCE(fmt, ...) \ | |
173 | _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__) | |
174 | #define DRM_WARN_ONCE(fmt, ...) \ | |
175 | _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__) | |
176 | ||
1da177e4 LT |
177 | /** |
178 | * Error output. | |
179 | * | |
180 | * \param fmt printf() like format string. | |
181 | * \param arg arguments | |
182 | */ | |
c4e68a58 SP |
183 | #define DRM_DEV_ERROR(dev, fmt, ...) \ |
184 | drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\ | |
185 | fmt, ##__VA_ARGS__) | |
186 | #define DRM_ERROR(fmt, ...) \ | |
6bd488db | 187 | drm_printk(KERN_ERR, DRM_UT_NONE, fmt, ##__VA_ARGS__) |
1da177e4 | 188 | |
5d13d425 RC |
189 | /** |
190 | * Rate limited error output. Like DRM_ERROR() but won't flood the log. | |
191 | * | |
192 | * \param fmt printf() like format string. | |
193 | * \param arg arguments | |
194 | */ | |
c4e68a58 | 195 | #define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \ |
5d13d425 RC |
196 | ({ \ |
197 | static DEFINE_RATELIMIT_STATE(_rs, \ | |
198 | DEFAULT_RATELIMIT_INTERVAL, \ | |
199 | DEFAULT_RATELIMIT_BURST); \ | |
200 | \ | |
201 | if (__ratelimit(&_rs)) \ | |
c4e68a58 | 202 | DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \ |
5d13d425 | 203 | }) |
c4e68a58 SP |
204 | #define DRM_ERROR_RATELIMITED(fmt, ...) \ |
205 | DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) | |
5d13d425 | 206 | |
c4e68a58 SP |
207 | #define DRM_DEV_INFO(dev, fmt, ...) \ |
208 | drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \ | |
209 | ##__VA_ARGS__) | |
1da177e4 | 210 | |
c4e68a58 SP |
211 | #define DRM_DEV_INFO_ONCE(dev, fmt, ...) \ |
212 | ({ \ | |
213 | static bool __print_once __read_mostly; \ | |
214 | if (!__print_once) { \ | |
215 | __print_once = true; \ | |
216 | DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \ | |
217 | } \ | |
218 | }) | |
48b8f631 | 219 | |
1da177e4 LT |
220 | /** |
221 | * Debug output. | |
b5e89ed5 | 222 | * |
1da177e4 LT |
223 | * \param fmt printf() like format string. |
224 | * \param arg arguments | |
225 | */ | |
c4e68a58 SP |
226 | #define DRM_DEV_DEBUG(dev, fmt, args...) \ |
227 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \ | |
228 | ##args) | |
6bd488db JP |
229 | #define DRM_DEBUG(fmt, ...) \ |
230 | drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__) | |
4fefcb27 | 231 | |
c4e68a58 SP |
232 | #define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \ |
233 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \ | |
234 | fmt, ##args) | |
6bd488db JP |
235 | #define DRM_DEBUG_DRIVER(fmt, ...) \ |
236 | drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) | |
c4e68a58 SP |
237 | |
238 | #define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \ | |
239 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \ | |
240 | ##args) | |
6bd488db JP |
241 | #define DRM_DEBUG_KMS(fmt, ...) \ |
242 | drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__) | |
c4e68a58 SP |
243 | |
244 | #define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \ | |
245 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \ | |
246 | fmt, ##args) | |
6bd488db JP |
247 | #define DRM_DEBUG_PRIME(fmt, ...) \ |
248 | drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__) | |
c4e68a58 SP |
249 | |
250 | #define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \ | |
251 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \ | |
252 | fmt, ##args) | |
6bd488db JP |
253 | #define DRM_DEBUG_ATOMIC(fmt, ...) \ |
254 | drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) | |
c4e68a58 SP |
255 | |
256 | #define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \ | |
257 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \ | |
258 | ##args) | |
6bd488db JP |
259 | #define DRM_DEBUG_VBL(fmt, ...) \ |
260 | drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__) | |
1da177e4 | 261 | |
c4e68a58 SP |
262 | #define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \ |
263 | ({ \ | |
264 | static DEFINE_RATELIMIT_STATE(_rs, \ | |
265 | DEFAULT_RATELIMIT_INTERVAL, \ | |
266 | DEFAULT_RATELIMIT_BURST); \ | |
267 | if (__ratelimit(&_rs)) \ | |
268 | drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level, \ | |
269 | __func__, "", fmt, ##args); \ | |
270 | }) | |
27528c66 L |
271 | |
272 | /** | |
273 | * Rate limited debug output. Like DRM_DEBUG() but won't flood the log. | |
274 | * | |
275 | * \param fmt printf() like format string. | |
276 | * \param arg arguments | |
277 | */ | |
c4e68a58 SP |
278 | #define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \ |
279 | DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args) | |
27528c66 | 280 | #define DRM_DEBUG_RATELIMITED(fmt, args...) \ |
c4e68a58 SP |
281 | DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args) |
282 | #define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...) \ | |
283 | _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args) | |
27528c66 | 284 | #define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \ |
c4e68a58 SP |
285 | DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args) |
286 | #define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...) \ | |
287 | _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args) | |
27528c66 | 288 | #define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \ |
c4e68a58 SP |
289 | DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args) |
290 | #define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...) \ | |
291 | _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args) | |
27528c66 | 292 | #define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \ |
c4e68a58 | 293 | DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args) |
27528c66 | 294 | |
65c7dc18 RC |
295 | /* Format strings and argument splitters to simplify printing |
296 | * various "complex" objects | |
297 | */ | |
65c7dc18 | 298 | |
1da177e4 LT |
299 | /*@}*/ |
300 | ||
1da177e4 LT |
301 | /***********************************************************************/ |
302 | /** \name Internal types and structures */ | |
303 | /*@{*/ | |
304 | ||
1da177e4 | 305 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
1da177e4 | 306 | |
1da177e4 | 307 | |
1da177e4 LT |
308 | /** |
309 | * DRM device structure. This structure represent a complete card that | |
310 | * may contain multiple heads. | |
311 | */ | |
84b1fd10 | 312 | struct drm_device { |
b3f2333d | 313 | struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ |
b5e89ed5 | 314 | int if_version; /**< Highest interface version set */ |
1da177e4 | 315 | |
45e212d2 DH |
316 | /** \name Lifetime Management */ |
317 | /*@{ */ | |
099d1c29 | 318 | struct kref ref; /**< Object ref-count */ |
45e212d2 DH |
319 | struct device *dev; /**< Device structure of bus-device */ |
320 | struct drm_driver *driver; /**< DRM driver managing the device */ | |
321 | void *dev_private; /**< DRM driver private data */ | |
45e212d2 DH |
322 | struct drm_minor *control; /**< Control node */ |
323 | struct drm_minor *primary; /**< Primary node */ | |
324 | struct drm_minor *render; /**< Render node */ | |
e6e7b48b | 325 | bool registered; |
95c081c1 DV |
326 | |
327 | /* currently active master for this device. Protected by master_mutex */ | |
328 | struct drm_master *master; | |
329 | ||
45e212d2 | 330 | atomic_t unplugged; /**< Flag whether dev is dead */ |
07b48c3a | 331 | struct inode *anon_inode; /**< inode for private address-space */ |
ca8e2ad7 | 332 | char *unique; /**< unique name of the device */ |
45e212d2 DH |
333 | /*@} */ |
334 | ||
1da177e4 | 335 | /** \name Locks */ |
b5e89ed5 | 336 | /*@{ */ |
30e2fb18 | 337 | struct mutex struct_mutex; /**< For others */ |
c996fd0b | 338 | struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */ |
b5e89ed5 | 339 | /*@} */ |
1da177e4 LT |
340 | |
341 | /** \name Usage Counters */ | |
b5e89ed5 | 342 | /*@{ */ |
fc8fd40e | 343 | int open_count; /**< Outstanding files open, protected by drm_global_mutex. */ |
2177a218 | 344 | spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */ |
b5e89ed5 DA |
345 | int buf_use; /**< Buffers in use -- cannot alloc */ |
346 | atomic_t buf_alloc; /**< Buffer allocation in progress */ | |
347 | /*@} */ | |
1da177e4 | 348 | |
1d2ac403 | 349 | struct mutex filelist_mutex; |
bd1b331f | 350 | struct list_head filelist; |
1da177e4 LT |
351 | |
352 | /** \name Memory management */ | |
b5e89ed5 | 353 | /*@{ */ |
bd1b331f | 354 | struct list_head maplist; /**< Linked list of regions */ |
e0be428e | 355 | struct drm_open_hash map_hash; /**< User token hash table for maps */ |
1da177e4 LT |
356 | |
357 | /** \name Context handle management */ | |
b5e89ed5 | 358 | /*@{ */ |
bd1b331f | 359 | struct list_head ctxlist; /**< Linked list of context handles */ |
30e2fb18 | 360 | struct mutex ctxlist_mutex; /**< For ctxlist */ |
1da177e4 | 361 | |
62968144 | 362 | struct idr ctx_idr; |
1da177e4 | 363 | |
bd1b331f | 364 | struct list_head vmalist; /**< List of vmas (for debugging) */ |
f453ba04 | 365 | |
b5e89ed5 | 366 | /*@} */ |
1da177e4 | 367 | |
a344a7e7 | 368 | /** \name DMA support */ |
b5e89ed5 | 369 | /*@{ */ |
cdd55a29 | 370 | struct drm_device_dma *dma; /**< Optional pointer for DMA support */ |
b5e89ed5 | 371 | /*@} */ |
1da177e4 LT |
372 | |
373 | /** \name Context support */ | |
b5e89ed5 | 374 | /*@{ */ |
7c1a38e3 | 375 | |
1da177e4 | 376 | __volatile__ long context_flag; /**< Context swapping flag */ |
b5e89ed5 | 377 | int last_context; /**< Last current context */ |
b5e89ed5 DA |
378 | /*@} */ |
379 | ||
16584b20 DV |
380 | /** |
381 | * @irq_enabled: | |
382 | * | |
383 | * Indicates that interrupt handling is enabled, specifically vblank | |
384 | * handling. Drivers which don't use drm_irq_install() need to set this | |
385 | * to true manually. | |
386 | */ | |
b46004b7 TR |
387 | bool irq_enabled; |
388 | int irq; | |
b5e89ed5 | 389 | |
00185e66 VS |
390 | /* |
391 | * If true, vblank interrupt will be disabled immediately when the | |
392 | * refcount drops to zero, as opposed to via the vblank disable | |
393 | * timer. | |
394 | * This can be set to true it the hardware has a working vblank | |
395 | * counter and the driver uses drm_vblank_on() and drm_vblank_off() | |
396 | * appropriately. | |
397 | */ | |
398 | bool vblank_disable_immediate; | |
399 | ||
5380e929 VS |
400 | /* array of size num_crtcs */ |
401 | struct drm_vblank_crtc *vblank; | |
0a3e67a4 | 402 | |
27641c3f | 403 | spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ |
b5e89ed5 | 404 | spinlock_t vbl_lock; |
0a3e67a4 JB |
405 | |
406 | u32 max_vblank_count; /**< size of vblank counter register */ | |
b5e89ed5 | 407 | |
c9a9c5e0 KH |
408 | /** |
409 | * List of events | |
410 | */ | |
411 | struct list_head vblank_event_list; | |
412 | spinlock_t event_lock; | |
413 | ||
b5e89ed5 | 414 | /*@} */ |
b5e89ed5 | 415 | |
55910517 | 416 | struct drm_agp_head *agp; /**< AGP data */ |
1da177e4 | 417 | |
b5e89ed5 | 418 | struct pci_dev *pdev; /**< PCI device structure */ |
1da177e4 | 419 | #ifdef __alpha__ |
1da177e4 | 420 | struct pci_controller *hose; |
1da177e4 | 421 | #endif |
dcdb1674 | 422 | |
55910517 | 423 | struct drm_sg_mem *sg; /**< Scatter gather memory */ |
19227561 | 424 | unsigned int num_crtcs; /**< Number of CRTCs on this device */ |
b5e89ed5 | 425 | |
69d516c0 DH |
426 | struct { |
427 | int context; | |
428 | struct drm_hw_lock *lock; | |
429 | } sigdata; | |
430 | ||
f77d390c | 431 | struct drm_local_map *agp_buffer_map; |
d1f2b55a | 432 | unsigned int agp_buffer_token; |
bea5679f | 433 | |
417009fb | 434 | struct drm_mode_config mode_config; /**< Current mode config */ |
f453ba04 | 435 | |
673a394b EA |
436 | /** \name GEM information */ |
437 | /*@{ */ | |
cd4f013f | 438 | struct mutex object_name_lock; |
673a394b | 439 | struct idr object_name_idr; |
b04a5906 | 440 | struct drm_vma_offset_manager *vma_offset_manager; |
673a394b | 441 | /*@} */ |
5bcf719b | 442 | int switch_power_state; |
84b1fd10 | 443 | }; |
1da177e4 | 444 | |
a743d758 DP |
445 | /** |
446 | * drm_drv_uses_atomic_modeset - check if the driver implements | |
447 | * atomic_commit() | |
448 | * @dev: DRM device | |
449 | * | |
450 | * This check is useful if drivers do not have DRIVER_ATOMIC set but | |
451 | * have atomic modesetting internally implemented. | |
452 | */ | |
453 | static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev) | |
454 | { | |
455 | return dev->mode_config.funcs->atomic_commit != NULL; | |
456 | } | |
457 | ||
5bcf719b DA |
458 | #define DRM_SWITCH_POWER_ON 0 |
459 | #define DRM_SWITCH_POWER_OFF 1 | |
460 | #define DRM_SWITCH_POWER_CHANGING 2 | |
13bb9cc8 | 461 | #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 |
5bcf719b | 462 | |
b5e89ed5 DA |
463 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
464 | int feature) | |
1da177e4 LT |
465 | { |
466 | return ((dev->driver->driver_features & feature) ? 1 : 0); | |
467 | } | |
468 | ||
2c07a21d DA |
469 | static inline void drm_device_set_unplugged(struct drm_device *dev) |
470 | { | |
471 | smp_wmb(); | |
472 | atomic_set(&dev->unplugged, 1); | |
473 | } | |
474 | ||
475 | static inline int drm_device_is_unplugged(struct drm_device *dev) | |
476 | { | |
477 | int ret = atomic_read(&dev->unplugged); | |
478 | smp_rmb(); | |
479 | return ret; | |
480 | } | |
481 | ||
1da177e4 LT |
482 | /******************************************************************/ |
483 | /** \name Internal function definitions */ | |
484 | /*@{*/ | |
485 | ||
1da177e4 | 486 | /* Driver support (drm_drv.h) */ |
1da177e4 | 487 | |
040ac320 TH |
488 | /* |
489 | * These are exported to drivers so that they can implement fencing using | |
490 | * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. | |
491 | */ | |
492 | ||
8410ea3b DA |
493 | /*@}*/ |
494 | ||
cc1f7194 DA |
495 | /* returns true if currently okay to sleep */ |
496 | static __inline__ bool drm_can_sleep(void) | |
497 | { | |
498 | if (in_atomic() || in_dbg_master() || irqs_disabled()) | |
499 | return false; | |
500 | return true; | |
501 | } | |
502 | ||
373701b1 JN |
503 | /* helper for handling conditionals in various for_each macros */ |
504 | #define for_each_if(condition) if (!(condition)) {} else | |
505 | ||
1da177e4 | 506 | #endif |