2 * Internal Header for the Direct Rendering Manager
4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6 * Copyright (c) 2009-2010, Code Aurora Forum.
9 * Author: Rickard E. (Rik) Faith <faith@valinux.com>
10 * Author: Gareth Hughes <gareth@valinux.com>
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:
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
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.
35 #if defined(_KERNEL) || defined(__KERNEL__)
37 #include <sys/param.h>
38 #include <sys/queue.h>
39 #include <sys/malloc.h>
40 #include <sys/kernel.h>
42 #include <sys/module.h>
43 #include <sys/systm.h>
44 #include <sys/device.h>
45 #include <sys/sglist.h>
50 #include <sys/spinlock.h>
51 #include <sys/spinlock2.h>
52 #include <sys/fcntl.h>
54 #include <sys/filio.h>
55 #include <sys/sysctl.h>
57 #include <sys/queue.h>
58 #include <sys/signalvar.h>
60 #include <linux/highmem.h>
62 #include <sys/taskqueue.h>
66 #include <vm/vm_extern.h>
67 #include <vm/vm_kern.h>
68 #include <vm/vm_map.h>
69 #include <vm/vm_object.h>
70 #include <vm/vm_page2.h>
71 #include <vm/vm_pager.h>
72 #include <vm/vm_param.h>
73 #include <machine/param.h>
74 #include <machine/pmap.h>
76 #include <machine/specialreg.h>
78 #include <machine/sysarch.h>
79 #include <sys/endian.h>
82 #include <sys/memrange.h>
83 #include <sys/agpio.h>
84 #include <sys/mutex.h>
86 MALLOC_DECLARE(M_DRM);
88 #include <uapi_drm/drm.h>
89 #include <uapi_drm/drm_sarea.h>
91 #include <linux/atomic.h>
92 #include <linux/bug.h>
93 #include <linux/dma-mapping.h>
94 #include <linux/capability.h>
95 #include <linux/err.h>
96 #include <linux/idr.h>
97 #include <linux/pci.h>
98 #include <linux/jiffies.h>
99 #include <linux/kernel.h>
100 #include <linux/fs.h>
101 #include <linux/kref.h>
102 #include <linux/list.h>
103 #include <linux/mm.h>
104 #include <linux/moduleparam.h>
105 #include <linux/mutex.h>
106 #include <linux/slab.h>
107 #include <linux/scatterlist.h>
108 #include <linux/timer.h>
110 #include <linux/seq_file.h>
111 #include <linux/types.h>
112 #include <linux/vmalloc.h>
113 #include <linux/wait.h>
114 #include <linux/workqueue.h>
116 #include <asm/uaccess.h>
118 #include <drm/drm_global.h>
120 #include <drm/drm_vma_manager.h>
125 struct drm_gem_object;
130 #include <drm/drm_os_linux.h>
131 #include <drm/drm_hashtab.h>
132 #include <drm/drm_mm.h>
135 * 4 debug categories are defined:
137 * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
138 * This is the category used by the DRM_DEBUG() macro.
140 * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
141 * This is the category used by the DRM_DEBUG_DRIVER() macro.
143 * KMS: used in the modesetting code.
144 * This is the category used by the DRM_DEBUG_KMS() macro.
146 * PRIME: used in the prime code.
147 * This is the category used by the DRM_DEBUG_PRIME() macro.
149 * Enabling verbose debug messages is done through the drm.debug parameter,
150 * each category being enabled by a bit.
152 * drm.debug=0x1 will enable CORE messages
153 * drm.debug=0x2 will enable DRIVER messages
154 * drm.debug=0x3 will enable CORE and DRIVER messages
156 * drm.debug=0xf will enable all messages
158 * An interesting feature is that it's possible to enable verbose logging at
159 * run-time by echoing the debug value in its sysfs node:
160 * # echo 0xf > /sys/module/drm/parameters/debug
162 #define DRM_UT_CORE 0x01
163 #define DRM_UT_DRIVER 0x02
164 #define DRM_UT_KMS 0x04
165 #define DRM_UT_PRIME 0x08
167 void drm_ut_debug_printk(const char *function_name,
168 const char *format, ...);
170 void drm_err(const char *format, ...);
172 /***********************************************************************/
173 /** \name DRM template customization defaults */
176 /* driver capabilities and requirements mask */
177 #define DRIVER_USE_AGP 0x1
178 #define DRIVER_REQUIRE_AGP 0x2
179 #define DRIVER_PCI_DMA 0x8
180 #define DRIVER_SG 0x10
181 #define DRIVER_HAVE_DMA 0x20
182 #define DRIVER_HAVE_IRQ 0x40
183 #define DRIVER_IRQ_SHARED 0x80
184 #define DRIVER_DMA_QUEUE 0x200
185 #define DRIVER_GEM 0x1000
186 #define DRIVER_MODESET 0x2000
187 #define DRIVER_PRIME 0x4000
188 #define DRIVER_RENDER 0x8000
189 #define DRIVER_ATOMIC 0x10000
191 /***********************************************************************/
192 /** \name Begin the DRM... */
195 #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */
199 /***********************************************************************/
200 /** \name Macros to make printk easier */
206 * \param fmt printf() like format string.
207 * \param arg arguments
209 #define DRM_ERROR(fmt, ...) \
210 kprintf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \
211 DRM_CURRENTPID, __func__ , ##__VA_ARGS__)
213 #define DRM_GEM_MAPPING_MASK (3ULL << 62)
214 #define DRM_GEM_MAPPING_KEY (2ULL << 62) /* Non-canonical address form */
215 #define DRM_GEM_MAX_IDX 0x3fffff
216 #define DRM_GEM_MAPPING_IDX(o) (((o) >> 40) & DRM_GEM_MAX_IDX)
217 #define DRM_GEM_MAPPING_OFF(i) (((uint64_t)(i)) << 40)
218 #define DRM_GEM_MAPPING_MAPOFF(o) \
219 ((o) & ~(DRM_GEM_MAPPING_OFF(DRM_GEM_MAX_IDX) | DRM_GEM_MAPPING_KEY))
221 SYSCTL_DECL(_hw_drm);
223 #define DRM_MAX(a,b) ((a)>(b)?(a):(b))
225 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
227 #define __OS_HAS_AGP 1
229 #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
230 #define DRM_DEV_UID UID_ROOT
231 #define DRM_DEV_GID GID_WHEEL
233 #define DRM_CURPROC curthread
234 #define DRM_STRUCTPROC struct thread
235 #define DRM_CURRENTPID (curproc != NULL ? curproc->p_pid : -1)
236 #define DRM_LOCK(dev) lockmgr(&(dev)->struct_mutex, LK_EXCLUSIVE)
237 #define DRM_UNLOCK(dev) lockmgr(&(dev)->struct_mutex, LK_RELEASE)
238 #define DRM_LOCK_SLEEP(dev, chan, flags, msg, timeout) \
239 (lksleep((chan), &(dev)->struct_mutex, (flags), (msg), (timeout)))
240 #if defined(INVARIANTS)
241 #define DRM_LOCK_ASSERT(dev) KKASSERT(lockstatus(&(dev)->struct_mutex, curthread) != 0);
242 #define DRM_UNLOCK_ASSERT(dev) KKASSERT(lockstatus(&(dev)->struct_mutex, curthread) == 0);
244 #define DRM_LOCK_ASSERT(d)
245 #define DRM_UNLOCK_ASSERT(d)
248 #define DRM_SYSCTL_HANDLER_ARGS (SYSCTL_HANDLER_ARGS)
250 typedef void irqreturn_t;
251 #define IRQ_HANDLED /* nothing */
252 #define IRQ_NONE /* nothing */
259 #define DRM_AGP_MEM struct agp_memory_info
261 #define drm_get_device_from_kdev(_kdev) (_kdev->si_drv1)
263 #define DRM_AGP_FIND_DEVICE() agp_find_device()
264 #define DRM_MTRR_WC MDF_WRITECOMBINE
266 #define LOCK_TEST_WITH_RETURN(dev, file_priv) \
268 if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
269 dev->lock.file_priv != file_priv) { \
270 DRM_ERROR("%s called without lock held\n", \
276 /* Returns -errno to shared code */
277 #define DRM_WAIT_ON( ret, queue, timeout, condition ) \
278 for ( ret = 0 ; !ret && !(condition) ; ) { \
280 lwkt_serialize_enter(&dev->irq_lock); \
281 if (!(condition)) { \
282 tsleep_interlock(&(queue), PCATCH); \
283 lwkt_serialize_exit(&dev->irq_lock); \
284 ret = -tsleep(&(queue), PCATCH | PINTERLOCKED, \
285 "drmwtq", (timeout)); \
287 lwkt_serialize_exit(&dev->irq_lock); \
292 int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end,
293 vm_memattr_t memattr);
294 void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end);
295 vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa);
297 /***********************************************************************/
298 /** \name Macros to make printk easier */
302 #define DRM_INFO(fmt, ...) kprintf("info: [" DRM_NAME "] " fmt , ##__VA_ARGS__)
304 #define DRM_INFO_ONCE(fmt, ...) \
305 printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
307 #define DRM_DEBUGBITS_DEBUG 0x1
308 #define DRM_DEBUGBITS_KMS 0x2
309 #define DRM_DEBUGBITS_FAILED_IOCTL 0x4
310 #define DRM_DEBUGBITS_VERBOSE 0x8
312 #define DRM_DEBUG(fmt, ...) do { \
313 if ((drm_debug & DRM_DEBUGBITS_DEBUG) != 0) \
314 kprintf("[" DRM_NAME ":pid%d:%s] " fmt, DRM_CURRENTPID, \
315 __func__ , ##__VA_ARGS__); \
318 #define DRM_DEBUG_VERBOSE(fmt, ...) do { \
319 if ((drm_debug & DRM_DEBUGBITS_VERBOSE) != 0) \
320 kprintf("[" DRM_NAME ":pid%d:%s] " fmt, DRM_CURRENTPID, \
321 __func__ , ##__VA_ARGS__); \
324 #define DRM_DEBUG_KMS(fmt, ...) do { \
325 if ((drm_debug & DRM_DEBUGBITS_KMS) != 0) \
326 kprintf("[" DRM_NAME ":KMS:pid%d:%s] " fmt, DRM_CURRENTPID,\
327 __func__ , ##__VA_ARGS__); \
330 #define DRM_DEBUG_DRIVER(fmt, ...) do { \
331 if ((drm_debug & DRM_DEBUGBITS_KMS) != 0) \
332 kprintf("[" DRM_NAME ":KMS:pid%d:%s] " fmt, DRM_CURRENTPID,\
333 __func__ , ##__VA_ARGS__); \
336 #define DRM_LOG_KMS(fmt, ...) do { \
337 kprintf("[" DRM_NAME ":KMS:pid%d:%s] " fmt, DRM_CURRENTPID, \
338 __func__ , ##__VA_ARGS__); \
341 #define dev_dbg(dev, fmt, ...) do { \
342 if ((drm_debug& DRM_DEBUGBITS_KMS) != 0) { \
343 device_printf((dev), "debug: " fmt, ## __VA_ARGS__); \
347 typedef struct drm_pci_id_list
355 struct drm_msi_blacklist_entry
362 * Ioctl function type.
364 * \param inode device inode.
365 * \param file_priv DRM file private pointer.
366 * \param cmd command.
367 * \param arg argument.
369 typedef int drm_ioctl_t(struct drm_device *dev, void *data,
370 struct drm_file *file_priv);
372 typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
375 #define DRM_IOCTL_NR(n) ((n) & 0xff)
378 #define DRM_MASTER 0x2
379 #define DRM_ROOT_ONLY 0x4
380 #define DRM_CONTROL_ALLOW 0x8
381 #define DRM_UNLOCKED 0x10
382 #define DRM_RENDER_ALLOW 0x20
384 struct drm_ioctl_desc {
388 unsigned int cmd_drv;
393 * Creates a driver or general drm_ioctl_desc array entry for the given
394 * ioctl, for use by drm_ioctl().
396 #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
397 [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl}
399 typedef struct drm_magic_entry {
400 struct list_head head;
401 struct drm_hash_item hash_item;
402 struct drm_file *priv;
403 struct drm_magic_entry *next;
406 typedef struct drm_magic_head {
407 struct drm_magic_entry *head;
408 struct drm_magic_entry *tail;
411 typedef struct drm_buf {
412 int idx; /**< Index into master buflist */
413 int total; /**< Buffer size */
414 int order; /**< log-base-2(total) */
415 int used; /**< Amount of buffer in use (for DMA) */
416 unsigned long offset; /**< Byte offset (used internally) */
417 void *address; /**< Address of buffer */
418 unsigned long bus_address; /**< Bus address of buffer */
419 struct drm_buf *next; /**< Kernel-only: used for free list */
420 __volatile__ int waiting; /**< On kernel DMA queue */
421 __volatile__ int pending; /**< On hardware DMA queue */
422 struct drm_file *file_priv; /**< Private of holding file descr */
423 int context; /**< Kernel queue for this buffer */
424 int while_locked; /**< Dispatch this buffer while locked */
432 } list; /**< Which list we're on */
434 int dev_priv_size; /**< Size of buffer private storage */
435 void *dev_private; /**< Per-buffer private storage */
438 /** bufs is one longer than it has to be */
439 struct drm_waitlist {
440 int count; /**< Number of possible buffers */
441 struct drm_buf **bufs; /**< List of pointers to buffers */
442 struct drm_buf **rp; /**< Read pointer */
443 struct drm_buf **wp; /**< Write pointer */
444 struct drm_buf **end; /**< End pointer */
445 struct spinlock *read_lock;
446 struct spinlock *write_lock;
449 typedef struct drm_dma_handle {
457 typedef struct drm_buf_entry {
463 struct drm_dma_handle **seglist;
465 int low_mark; /**< Low water mark */
466 int high_mark; /**< High water mark */
469 /* Event queued up for userspace to read */
470 struct drm_pending_event {
471 struct drm_event *event;
472 struct list_head link;
473 struct drm_file *file_priv;
474 pid_t pid; /* pid of requester, no guarantee it's valid by the time
475 we deliver the event, for tracing only */
476 void (*destroy)(struct drm_pending_event *event);
479 /* initial implementaton using a linked list - todo hashtab */
480 struct drm_prime_file_private {
481 struct list_head head;
484 #endif /* DUMBBELL_WIP */
487 /** File private data */
490 struct drm_device *dev;
493 /* true when the client has asked us to expose stereo 3D mode flags */
496 * true if client understands CRTC primary planes and cursor planes
499 unsigned universal_planes:1;
500 /* true if client understands atomic properties */
506 unsigned long ioctl_count;
507 struct list_head lhead;
510 /** Mapping of mm object handles to object pointers. */
511 struct idr object_idr;
512 /** Lock for synchronization of access to object_idr. */
513 struct lock table_lock;
518 struct drm_master *masterp;
521 * fbs - List of framebuffers associated with this file.
523 * Protected by fbs_lock. Note that the fbs list holds a reference on
524 * the fb object to prevent it from untimely disappearing.
526 struct list_head fbs;
527 struct lock fbs_lock;
529 wait_queue_head_t event_wait;
530 struct list_head event_list;
533 struct drm_prime_file_private prime;
539 struct drm_lock_data {
540 struct drm_hw_lock *hw_lock; /**< Hardware lock */
541 /** Private of lock holder's file (NULL=kernel) */
542 struct drm_file *file_priv;
543 wait_queue_head_t lock_queue; /**< Queue of blocked processes */
544 unsigned long lock_time; /**< Time of last lock in jiffies */
547 /* This structure, in the struct drm_device, is always initialized while the
549 * is open. dev->dma_lock protects the incrementing of dev->buf_use, which
550 * when set marks that no further bufs may be allocated until device teardown
551 * occurs (when the last open of the device has closed). The high/low
552 * watermarks of bufs are only touched by the X Server, and thus not
553 * concurrently accessed, so no locking is needed.
555 typedef struct drm_device_dma {
557 struct drm_buf_entry bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */
558 int buf_count; /**< total number of buffers */
559 struct drm_buf **buflist; /**< Vector of pointers into drm_device_dma::bufs */
561 int page_count; /**< number of pages */
562 unsigned long *pagelist; /**< page list */
563 unsigned long byte_count;
565 _DRM_DMA_USE_AGP = 0x01,
566 _DRM_DMA_USE_SG = 0x02,
567 _DRM_DMA_USE_FB = 0x04,
568 _DRM_DMA_USE_PCI_RO = 0x08
573 typedef struct drm_sg_mem {
580 * Kernel side of a mapping
582 struct drm_local_map {
583 resource_size_t offset; /**< Requested physical address (0 for SAREA)*/
584 unsigned long size; /**< Requested physical size (bytes) */
585 enum drm_map_type type; /**< Type of memory to map */
586 enum drm_map_flags flags; /**< Flags */
587 void *handle; /**< User-space: "Handle" to pass to mmap() */
588 /**< Kernel-space: kernel-virtual address */
589 int mtrr; /**< MTRR slot used */
592 typedef struct drm_local_map drm_local_map_t;
597 struct drm_map_list {
598 struct list_head head; /**< list head */
599 struct drm_hash_item hash;
600 struct drm_local_map *map; /**< mapping */
602 struct drm_master *master;
603 struct drm_mm_node *file_offset_node; /**< fake offset */
607 * GEM specific mm private for tracking GEM objects
610 struct drm_vma_offset_manager vma_manager;
611 struct drm_mm offset_manager; /**< Offset mgmt for buffer objects */
612 struct drm_open_hash offset_hash; /**< User token hash table for maps */
613 struct unrhdr *idxunr;
617 #include "drm_crtc.h"
620 * struct drm_master - drm master structure
622 * @refcount: Refcount for this master object.
623 * @minor: Link back to minor char device we are master for. Immutable.
624 * @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex.
625 * @unique_len: Length of unique field. Protected by drm_global_mutex.
626 * @unique_size: Amount allocated. Protected by drm_global_mutex.
627 * @magiclist: Hash of used authentication tokens. Protected by struct_mutex.
628 * @magicfree: List of used authentication tokens. Protected by struct_mutex.
629 * @lock: DRI lock information.
630 * @driver_priv: Pointer to driver-private information.
634 struct kref refcount; /* refcount for this master */
636 struct list_head head; /**< each minor contains a list of masters */
637 struct drm_minor *minor; /**< link back to minor we are a master for */
639 char *unique; /**< Unique identifier: e.g., busid */
640 int unique_len; /**< Length of unique field */
641 int unique_size; /**< amount allocated */
643 int blocked; /**< Blocked due to VC switch? */
645 struct drm_open_hash magiclist;
646 struct list_head magicfree;
647 struct drm_lock_data lock;
651 /* Size of ringbuffer for vblank timestamps. Just double-buffer
652 * in initial implementation.
654 #define DRM_VBLANKTIME_RBSIZE 2
656 /* Flags and return codes for get_vblank_timestamp() driver function. */
657 #define DRM_CALLED_FROM_VBLIRQ 1
658 #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
659 #define DRM_VBLANKTIME_IN_VBLANK (1 << 1)
661 /* get_scanout_position() return flags */
662 #define DRM_SCANOUTPOS_VALID (1 << 0)
663 #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1)
664 #define DRM_SCANOUTPOS_ACCURATE (1 << 2)
667 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) - 1)
670 #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
673 * DRM driver structure. This structure represent the common code for
674 * a family of cards. There will one drm_device for each card present
678 int (*load)(struct drm_device *, unsigned long flags);
679 int (*use_msi)(struct drm_device *, unsigned long flags);
680 int (*firstopen)(struct drm_device *);
681 int (*open)(struct drm_device *, struct drm_file *);
682 void (*preclose)(struct drm_device *, struct drm_file *file_priv);
683 void (*postclose)(struct drm_device *, struct drm_file *);
684 void (*lastclose)(struct drm_device *);
685 int (*unload)(struct drm_device *);
686 void (*reclaim_buffers_locked)(struct drm_device *,
687 struct drm_file *file_priv);
688 int (*dma_ioctl)(struct drm_device *dev, void *data,
689 struct drm_file *file_priv);
690 void (*dma_ready)(struct drm_device *);
691 int (*dma_quiescent)(struct drm_device *);
692 int (*dma_flush_block_and_flush)(struct drm_device *, int context,
693 enum drm_lock_flags flags);
694 int (*dma_flush_unblock)(struct drm_device *, int context,
695 enum drm_lock_flags flags);
696 int (*context_ctor)(struct drm_device *dev, int context);
697 int (*context_dtor)(struct drm_device *dev, int context);
698 int (*kernel_context_switch)(struct drm_device *dev, int old,
700 int (*kernel_context_switch_unlock)(struct drm_device *dev);
701 void (*irq_preinstall)(struct drm_device *dev);
702 int (*irq_postinstall)(struct drm_device *dev);
703 void (*irq_uninstall)(struct drm_device *dev);
704 void (*irq_handler)(void *arg);
706 u32 (*get_vblank_counter)(struct drm_device *dev, int crtc);
707 int (*enable_vblank)(struct drm_device *dev, int crtc);
708 void (*disable_vblank)(struct drm_device *dev, int crtc);
711 * Called by vblank timestamping code.
713 * Return the current display scanout position from a crtc, and an
714 * optional accurate ktime_get timestamp of when position was measured.
716 * \param dev DRM device.
717 * \param crtc Id of the crtc to query.
718 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
719 * \param *vpos Target location for current vertical scanout position.
720 * \param *hpos Target location for current horizontal scanout position.
721 * \param *stime Target location for timestamp taken immediately before
722 * scanout position query. Can be NULL to skip timestamp.
723 * \param *etime Target location for timestamp taken immediately after
724 * scanout position query. Can be NULL to skip timestamp.
726 * Returns vpos as a positive number while in active scanout area.
727 * Returns vpos as a negative number inside vblank, counting the number
728 * of scanlines to go until end of vblank, e.g., -1 means "one scanline
729 * until start of active scanout / end of vblank."
731 * \return Flags, or'ed together as follows:
733 * DRM_SCANOUTPOS_VALID = Query successful.
734 * DRM_SCANOUTPOS_INVBL = Inside vblank.
735 * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
736 * this flag means that returned position may be offset by a constant
737 * but unknown small number of scanlines wrt. real scanout position.
740 int (*get_scanout_position) (struct drm_device *dev, int crtc,
742 int *vpos, int *hpos, ktime_t *stime,
745 int (*get_vblank_timestamp)(struct drm_device *dev, int crtc,
746 int *max_error, struct timeval *vblank_time,
749 void (*gem_free_object)(struct drm_gem_object *obj);
750 int (*gem_open_object)(struct drm_gem_object *, struct drm_file *);
751 void (*gem_close_object)(struct drm_gem_object *, struct drm_file *);
753 struct cdev_pager_ops *gem_pager_ops;
755 int (*dumb_create)(struct drm_file *file_priv,
756 struct drm_device *dev, struct drm_mode_create_dumb *args);
757 int (*dumb_map_offset)(struct drm_file *file_priv,
758 struct drm_device *dev, uint32_t handle, uint64_t *offset);
759 int (*dumb_destroy)(struct drm_file *file_priv,
760 struct drm_device *dev, uint32_t handle);
762 int (*sysctl_init)(struct drm_device *dev,
763 struct sysctl_ctx_list *ctx, struct sysctl_oid *top);
764 void (*sysctl_cleanup)(struct drm_device *dev);
766 drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */
769 * Called by \c drm_device_is_agp. Typically used to determine if a
770 * card is really attached to AGP or not.
772 * \param dev DRM device handle
775 * One of three values is returned depending on whether or not the
776 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
777 * (return of 1), or may or may not be AGP (return of 2).
779 int (*device_is_agp) (struct drm_device * dev);
784 const char *name; /* Simple driver name */
785 const char *desc; /* Longer driver name */
786 const char *date; /* Date of last major changes. */
790 const struct drm_ioctl_desc *ioctls;
795 * Info file list entry. This structure represents a debugfs or proc file to
796 * be created by the drm core
798 struct drm_info_list {
799 const char *name; /** file name */
800 int (*show)(struct seq_file*, void*); /** show callback */
801 u32 driver_features; /**< Required driver features for this entry */
806 * debugfs node structure. This structure represents a debugfs file.
808 struct drm_info_node {
809 struct list_head list;
810 struct drm_minor *minor;
811 const struct drm_info_list *info_ent;
816 * DRM minor structure. This structure represents a drm minor number.
819 int index; /**< Minor device number */
820 int type; /**< Control or render */
821 device_t kdev; /**< OS device */
822 struct drm_device *dev;
824 struct drm_master *master; /* currently active master for this node */
825 struct list_head master_list;
826 struct drm_mode_group mode_group;
829 struct drm_pending_vblank_event {
830 struct drm_pending_event base;
832 struct drm_event_vblank event;
835 struct drm_sysctl_info {
836 struct sysctl_ctx_list ctx;
840 /* Length for the array of resource pointers for drm_get_resource_*. */
841 #define DRM_MAX_PCI_RESOURCE 6
843 struct drm_vblank_crtc {
844 struct drm_device *dev; /* pointer to the drm_device */
845 wait_queue_head_t queue; /**< VBLANK wait queue */
846 struct timeval time[DRM_VBLANKTIME_RBSIZE]; /**< timestamp of current count */
847 struct timer_list disable_timer; /* delayed disable timer */
848 atomic_t count; /**< number of VBLANK interrupts */
849 atomic_t refcount; /* number of users of vblank interruptsper crtc */
850 u32 last; /* protected by dev->vbl_lock, used */
851 /* for wraparound handling */
852 u32 last_wait; /* Last vblank seqno waited per CRTC */
853 unsigned int inmodeset; /* Display driver is setting mode */
854 int crtc; /* crtc index */
855 bool enabled; /* so we don't call enable more than
860 * DRM device structure. This structure represent a complete card that
861 * may contain multiple heads.
864 drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */
866 uint16_t pci_subdevice; /* PCI subsystem device id */
867 uint16_t pci_subvendor; /* PCI subsystem vendor id */
869 char *unique; /* Unique identifier: e.g., busid */
870 int unique_len; /* Length of unique field */
871 struct cdev *devnode; /* Device number for mknod */
872 int if_version; /* Highest interface version set */
874 int flags; /* Flags to open(2) */
877 struct spinlock dma_lock; /* protects dev->dma */
878 struct lwkt_serialize irq_lock; /* protects irq condition checks */
879 struct lock dev_lock; /* protects everything else */
883 struct lock struct_mutex; /**< For others */
884 struct lock master_mutex; /**< For drm_minor::master */
887 /** \name Usage Counters */
889 int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
890 struct spinlock buf_lock; /**< For drm_device::buf_use and a few other things. */
891 int buf_use; /**< Buffers in use -- cannot alloc */
892 atomic_t buf_alloc; /**< Buffer allocation in progress */
896 /** \name Performance counters */
898 unsigned long counters;
899 enum drm_stat_type types[15];
904 struct drm_open_hash magiclist; /**< magic hash table */
905 struct list_head magicfree;
907 struct list_head filelist;
909 /** \name Memory management */
911 struct list_head maplist; /**< Linked list of regions */
912 int map_count; /**< Number of mappable regions */
913 struct drm_open_hash map_hash; /**< User token hash table for maps */
915 /** \name Context handle management */
917 struct list_head ctxlist; /**< Linked list of context handles */
918 int ctx_count; /**< Number of context handles */
919 struct lock ctxlist_mutex; /**< For ctxlist */
925 struct drm_lock_data lock; /* Information on hardware lock */
927 /* DMA queues (contexts) */
928 drm_device_dma_t *dma; /* Optional pointer for DMA support */
930 int irq; /* Interrupt used by board */
931 int irq_type; /* IRQ type (MSI enabled or not) */
932 int irqrid; /* Interrupt used by board */
933 struct resource *irqr; /* Resource for interrupt used by board */
934 void *irqh; /* Handle from bus_setup_intr */
936 /* Storage of resource pointers for drm_get_resource_* */
937 struct resource *pcir[DRM_MAX_PCI_RESOURCE];
938 int pcirid[DRM_MAX_PCI_RESOURCE];
945 /** \name Context support */
947 int irq_enabled; /**< True if irq handler is enabled */
948 __volatile__ long context_flag; /**< Context swapping flag */
949 __volatile__ long interrupt_flag; /**< Interruption handler flag */
950 __volatile__ long dma_flag; /**< DMA dispatch flag */
951 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
952 int last_checked; /**< Last context checked for DMA */
953 int last_context; /**< Last current context */
954 unsigned long last_switch; /**< jiffies at last context switch */
957 /** \name VBLANK IRQ support */
961 * At load time, disabling the vblank interrupt won't be allowed since
962 * old clients may not call the modeset ioctl and therefore misbehave.
963 * Once the modeset ioctl *has* been called though, we can safely
964 * disable them when unused.
966 bool vblank_disable_allowed;
969 * If true, vblank interrupt will be disabled immediately when the
970 * refcount drops to zero, as opposed to via the vblank disable
972 * This can be set to true it the hardware has a working vblank
973 * counter and the driver uses drm_vblank_on() and drm_vblank_off()
976 bool vblank_disable_immediate;
978 /* array of size num_crtcs */
979 struct drm_vblank_crtc *vblank;
981 struct lock vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
982 struct lock vbl_lock;
983 struct timer_list vblank_disable_timer;
985 u32 max_vblank_count; /**< size of vblank counter register */
990 struct list_head vblank_event_list;
991 struct lock event_lock;
995 struct sigio *buf_sigio; /* Processes waiting for SIGIO */
998 struct drm_sysctl_info *sysctl;
1001 drm_sg_mem_t *sg; /* Scatter gather memory */
1002 unsigned int num_crtcs; /**< Number of CRTCs on this device */
1004 unsigned long *ctx_bitmap;
1011 struct drm_agp_head *agp; /**< AGP data */
1013 struct device *dev; /**< Device structure */
1014 struct pci_dev *pdev; /**< PCI device structure */
1015 int pci_vendor; /**< PCI vendor id */
1016 int pci_device; /**< PCI device id */
1018 struct drm_driver *driver;
1019 struct drm_local_map *agp_buffer_map;
1020 unsigned int agp_buffer_token;
1021 struct drm_minor *control; /**< Control node for card */
1022 struct drm_minor *primary; /**< render type primary screen head */
1024 struct drm_mode_config mode_config; /**< Current mode config */
1026 /** \name GEM information */
1028 struct lock object_name_lock;
1029 struct idr object_name_idr;
1033 void *sysctl_private;
1034 char busid_str[128];
1037 int switch_power_state;
1039 atomic_t unplugged; /* device has been unplugged or gone away */
1042 #define DRM_SWITCH_POWER_ON 0
1043 #define DRM_SWITCH_POWER_OFF 1
1044 #define DRM_SWITCH_POWER_CHANGING 2
1045 #define DRM_SWITCH_POWER_DYNAMIC_OFF 3
1047 static __inline__ int drm_core_check_feature(struct drm_device *dev,
1050 return ((dev->driver->driver_features & feature) ? 1 : 0);
1053 static inline void drm_device_set_unplugged(struct drm_device *dev)
1056 atomic_set(&dev->unplugged, 1);
1059 static inline int drm_device_is_unplugged(struct drm_device *dev)
1061 int ret = atomic_read(&dev->unplugged);
1066 static inline bool drm_is_primary_client(const struct drm_file *file_priv)
1068 return 0 /* file_priv->minor->type == DRM_MINOR_LEGACY */;
1072 * drm_is_master() - Check whether a DRM open-file is DRM-Master
1073 * @file: DRM open-file context
1075 * This checks whether a DRM open-file context is owner of the master context
1076 * attached to it. If a file owns a master context, it's called DRM-Master.
1077 * Per DRM device, only one such file can be DRM-Master at a time.
1079 * Returns: True if the file is DRM-Master, otherwise false.
1081 static inline bool drm_is_master(const struct drm_file *file)
1084 return file->master && file->master == file->minor->master;
1090 /******************************************************************/
1091 /** \name Internal function definitions */
1095 static inline int drm_core_has_AGP(struct drm_device *dev)
1097 return drm_core_check_feature(dev, DRIVER_USE_AGP);
1100 #define drm_core_has_AGP(dev) (0)
1103 extern int drm_notyet_flag;
1104 extern unsigned int drm_rnodes;
1105 extern unsigned int drm_universal_planes;
1107 extern int drm_vblank_offdelay;
1108 extern unsigned int drm_timestamp_precision;
1110 /* Driver support (drm_drv.h) */
1111 int drm_probe(device_t kdev, drm_pci_id_list_t *idlist);
1112 int drm_attach(device_t kdev, drm_pci_id_list_t *idlist);
1113 int drm_create_cdevs(device_t kdev);
1114 d_ioctl_t drm_ioctl;
1115 extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
1117 /* Device support (drm_fops.h) */
1119 d_close_t drm_close;
1121 d_kqfilter_t drm_kqfilter;
1122 int drm_release(device_t kdev);
1125 d_mmap_single_t drm_mmap_single;
1127 void drm_cdevpriv_dtor(void *cd);
1129 int drm_add_busid_modesetting(struct drm_device *dev,
1130 struct sysctl_ctx_list *ctx, struct sysctl_oid *top);
1132 /* File operations helpers (drm_fops.c) */
1133 extern int drm_open_helper(struct cdev *kdev, int flags, int fmt,
1135 struct drm_device *dev,
1137 extern struct drm_file *drm_find_file_by_proc(struct drm_device *dev,
1141 extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
1142 struct drm_file *file_priv, uint32_t handle, uint32_t flags,
1144 extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
1145 struct drm_file *file_priv, int prime_fd, uint32_t *handle);
1147 extern int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
1148 struct drm_file *file_priv);
1149 extern int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
1150 struct drm_file *file_priv);
1152 extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, vm_page_t *pages,
1153 dma_addr_t *addrs, int max_pages);
1154 #endif /* DUMBBELL_WIP */
1155 extern struct sg_table *drm_prime_pages_to_sg(vm_page_t *pages, int nr_pages);
1156 extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
1159 void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
1160 void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
1161 int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle);
1162 int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle);
1163 void drm_prime_remove_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf);
1165 int drm_prime_add_dma_buf(struct drm_device *dev, struct drm_gem_object *obj);
1166 int drm_prime_lookup_obj(struct drm_device *dev, struct dma_buf *buf,
1167 struct drm_gem_object **obj);
1168 #endif /* DUMBBELL_WIP */
1170 void drm_mem_init(void);
1171 void drm_mem_uninit(void);
1172 void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map);
1173 void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map);
1174 void drm_ioremapfree(drm_local_map_t *map);
1175 int drm_mtrr_add(unsigned long offset, size_t size, int flags);
1176 int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags);
1178 /* Locking IOCTL support (drm_lock.c) */
1179 int drm_lock_take(struct drm_lock_data *lock_data,
1180 unsigned int context);
1181 int drm_lock_transfer(struct drm_lock_data *lock_data,
1182 unsigned int context);
1183 int drm_lock_free(struct drm_lock_data *lock_data,
1184 unsigned int context);
1187 * These are exported to drivers so that they can implement fencing using
1188 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
1191 unsigned long drm_get_resource_start(struct drm_device *dev,
1192 unsigned int resource);
1193 unsigned long drm_get_resource_len(struct drm_device *dev,
1194 unsigned int resource);
1196 /* IRQ support (drm_irq.h) */
1197 extern int drm_irq_install(struct drm_device *dev, int irq);
1198 int drm_irq_uninstall(struct drm_device *dev);
1199 void drm_driver_irq_preinstall(struct drm_device *dev);
1200 void drm_driver_irq_postinstall(struct drm_device *dev);
1201 void drm_driver_irq_uninstall(struct drm_device *dev);
1203 extern int drm_vblank_init(struct drm_device *dev, int num_crtcs);
1204 extern int drm_wait_vblank(struct drm_device *dev, void *data,
1205 struct drm_file *filp);
1206 extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
1207 extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
1208 extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
1209 struct timeval *vblanktime);
1210 extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
1211 struct drm_pending_vblank_event *e);
1212 extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
1213 struct drm_pending_vblank_event *e);
1214 extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
1215 extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
1216 extern int drm_vblank_get(struct drm_device *dev, int crtc);
1217 extern void drm_vblank_put(struct drm_device *dev, int crtc);
1218 extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
1219 extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
1220 extern void drm_wait_one_vblank(struct drm_device *dev, int crtc);
1221 extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);
1222 extern void drm_vblank_off(struct drm_device *dev, int crtc);
1223 extern void drm_vblank_on(struct drm_device *dev, int crtc);
1224 extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
1225 extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
1226 extern void drm_vblank_cleanup(struct drm_device *dev);
1228 extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
1229 int crtc, int *max_error,
1230 struct timeval *vblank_time,
1232 const struct drm_crtc *refcrtc,
1233 const struct drm_display_mode *mode);
1234 extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
1235 const struct drm_display_mode *mode);
1238 * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC
1239 * @crtc: which CRTC's vblank waitqueue to retrieve
1241 * This function returns a pointer to the vblank waitqueue for the CRTC.
1242 * Drivers can use this to implement vblank waits using wait_event() & co.
1244 static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc)
1246 return &crtc->dev->vblank[drm_crtc_index(crtc)].queue;
1249 /* Modesetting support */
1250 extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
1251 extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
1253 /* AGP/GART support (drm_agpsupport.h) */
1255 #include <drm/drm_agpsupport.h>
1257 /* sysctl support (drm_sysctl.h) */
1258 extern int drm_sysctl_init(struct drm_device *dev);
1259 extern int drm_sysctl_cleanup(struct drm_device *dev);
1261 /* Cache management (drm_memory.c) */
1262 void drm_clflush_pages(vm_page_t *pages, unsigned long num_pages);
1264 /* Locking IOCTL support (drm_drv.c) */
1265 int drm_lock(struct drm_device *dev, void *data,
1266 struct drm_file *file_priv);
1267 int drm_unlock(struct drm_device *dev, void *data,
1268 struct drm_file *file_priv);
1269 int drm_setversion(struct drm_device *dev, void *data,
1270 struct drm_file *file_priv);
1273 * These are exported to drivers so that they can implement fencing using
1274 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
1277 extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
1279 /* Misc. IOCTL support (drm_ioctl.c) */
1280 int drm_noop(struct drm_device *dev, void *data,
1281 struct drm_file *file_priv);
1283 /* Cache management (drm_cache.c) */
1284 void drm_clflush_virt_range(void *addr, unsigned long length);
1286 /* DMA support (drm_dma.c) */
1287 int drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv);
1289 /* Stub support (drm_stub.h) */
1291 extern void drm_put_dev(struct drm_device *dev);
1292 extern void drm_unplug_dev(struct drm_device *dev);
1293 extern unsigned int drm_debug;
1294 extern bool drm_atomic;
1296 /* Scatter Gather Support (drm_scatter.c) */
1297 int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
1298 struct drm_file *file_priv);
1299 int drm_sg_free(struct drm_device *dev, void *data,
1300 struct drm_file *file_priv);
1302 /* consistent PCI memory functions (drm_pci.c) */
1303 extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
1305 void drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah);
1307 /* sysfs support (drm_sysfs.c) */
1308 extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1310 int drm_gem_mmap_single(struct drm_device *dev, vm_ooffset_t *offset,
1311 vm_size_t size, struct vm_object **obj_res, int nprot);
1312 void drm_gem_pager_dtr(void *obj);
1314 struct ttm_bo_device;
1315 int ttm_bo_mmap_single(struct ttm_bo_device *bdev, vm_ooffset_t *offset,
1316 vm_size_t size, struct vm_object **obj_res, int nprot);
1317 struct ttm_buffer_object;
1318 void ttm_bo_release_mmap(struct ttm_buffer_object *bo);
1320 void drm_device_lock_mtx(struct drm_device *dev);
1321 void drm_device_unlock_mtx(struct drm_device *dev);
1322 int drm_device_sleep_mtx(struct drm_device *dev, void *chan, int flags,
1323 const char *msg, int timeout);
1324 void drm_device_assert_mtx_locked(struct drm_device *dev);
1325 void drm_device_assert_mtx_unlocked(struct drm_device *dev);
1327 void drm_device_lock_struct(struct drm_device *dev);
1328 void drm_device_unlock_struct(struct drm_device *dev);
1329 int drm_device_sleep_struct(struct drm_device *dev, void *chan, int flags,
1330 const char *msg, int timeout);
1331 void drm_device_assert_struct_locked(struct drm_device *dev);
1332 void drm_device_assert_struct_unlocked(struct drm_device *dev);
1334 void drm_compat_locking_init(struct drm_device *dev);
1335 void drm_sleep_locking_init(struct drm_device *dev);
1337 /* XXX glue logic, should be done in drm_pci_init(), pending drm update */
1338 void drm_init_pdev(struct device *dev, struct pci_dev **pdev);
1339 void drm_fini_pdev(struct pci_dev **pdev);
1341 /* Inline replacements for drm_alloc and friends */
1342 static __inline__ void *
1343 drm_alloc(size_t size, struct malloc_type *area)
1345 return kmalloc(size, area, M_WAITOK | M_NULLOK);
1348 static __inline__ void *
1349 drm_calloc(size_t nmemb, size_t size, struct malloc_type *area)
1351 return kmalloc(size * nmemb, area, M_WAITOK | M_NULLOK | M_ZERO);
1354 static __inline__ void
1355 drm_free(void *pt, struct malloc_type *area)
1357 /* kfree is special!!! */
1362 static __inline__ void
1363 drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev)
1365 map->handle = drm_ioremap_wc(dev, map);
1367 static __inline__ void
1368 drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
1370 map->handle = drm_ioremap(dev, map);
1372 static __inline__ void
1373 drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
1375 if ( map->handle && map->size )
1376 drm_ioremapfree(map);
1379 static __inline__ struct drm_local_map *
1380 drm_core_findmap(struct drm_device *dev, unsigned long offset)
1382 struct drm_map_list *_entry;
1384 list_for_each_entry(_entry, &dev->maplist, head) {
1385 if (offset == (unsigned long)_entry->map->handle)
1391 static __inline__ void drm_core_dropmap(struct drm_map *map)
1395 #include <drm/drm_mem_util.h>
1397 struct drm_device *drm_dev_alloc(struct drm_driver *driver,
1398 struct device *parent);
1399 void drm_dev_ref(struct drm_device *dev);
1400 void drm_dev_unref(struct drm_device *dev);
1401 int drm_dev_register(struct drm_device *dev, unsigned long flags);
1402 void drm_dev_unregister(struct drm_device *dev);
1403 int drm_dev_set_unique(struct drm_device *dev, const char *fmt, ...);
1405 /* FreeBSD compatibility macros */
1406 #define VM_OBJECT_WLOCK(object) VM_OBJECT_LOCK(object)
1407 #define VM_OBJECT_WUNLOCK(object) VM_OBJECT_UNLOCK(object)
1409 #define DRM_PCIE_SPEED_25 1
1410 #define DRM_PCIE_SPEED_50 2
1411 #define DRM_PCIE_SPEED_80 4
1413 extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
1416 #define drm_can_sleep() (HZ & 1)
1418 #endif /* __KERNEL__ */
1419 #endif /* _DRM_P_H_ */