3 * Private header for Direct Rendering Manager
5 * \author Rickard E. (Rik) Faith <faith@valinux.com>
6 * \author Gareth Hughes <gareth@valinux.com>
10 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
11 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
12 * All rights reserved.
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
21 * The above copyright notice and this permission notice (including the next
22 * paragraph) shall be included in all copies or substantial portions of the
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
29 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
30 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31 * OTHER DEALINGS IN THE SOFTWARE.
39 /* add include of current.h so that "current" is defined
40 * before static inline funcs in wait.h. Doing this so we
41 * can build the DRM (part of PI DRI). 4/21/2000 S + B */
42 #include <asm/current.h>
43 #endif /* __alpha__ */
44 #include <linux/config.h>
45 #include <linux/module.h>
46 #include <linux/kernel.h>
47 #include <linux/miscdevice.h>
49 #include <linux/proc_fs.h>
50 #include <linux/init.h>
51 #include <linux/file.h>
52 #include <linux/pci.h>
53 #include <linux/version.h>
54 #include <linux/sched.h>
55 #include <linux/smp_lock.h> /* For (un)lock_kernel */
57 #include <linux/pagemap.h>
58 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
59 #include <linux/mutex.h>
61 #if defined(__alpha__) || defined(__powerpc__)
62 #include <asm/pgtable.h> /* For pte_wrprotect */
66 #include <asm/uaccess.h>
70 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
71 #include <linux/types.h>
72 #include <linux/agp_backend.h>
74 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,41)
75 #define HAS_WORKQUEUE 0
77 #define HAS_WORKQUEUE 1
80 #include <linux/tqueue.h>
82 #include <linux/workqueue.h>
84 #include <linux/poll.h>
85 #include <asm/pgalloc.h>
87 #include <linux/slab.h>
89 #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
90 #define __OS_HAS_MTRR (defined(CONFIG_MTRR))
92 #include "drm_os_linux.h"
93 #include "drm_hashtab.h"
95 /* If you want the memory alloc debug functionality, change define below */
96 /* #define DEBUG_MEMORY */
98 /***********************************************************************/
99 /** \name DRM template customization defaults */
102 /* driver capabilities and requirements mask */
103 #define DRIVER_USE_AGP 0x1
104 #define DRIVER_REQUIRE_AGP 0x2
105 #define DRIVER_USE_MTRR 0x4
106 #define DRIVER_PCI_DMA 0x8
107 #define DRIVER_SG 0x10
108 #define DRIVER_HAVE_DMA 0x20
109 #define DRIVER_HAVE_IRQ 0x40
110 #define DRIVER_IRQ_SHARED 0x80
111 #define DRIVER_IRQ_VBL 0x100
112 #define DRIVER_DMA_QUEUE 0x200
113 #define DRIVER_FB_DMA 0x400
118 /***********************************************************************/
119 /** \name Begin the DRM... */
122 #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then
123 also include looping detection. */
125 #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */
126 #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */
127 #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */
128 #define DRM_LOOPING_LIMIT 5000000
129 #define DRM_TIME_SLICE (HZ/20) /**< Time slice for GLXContexts */
130 #define DRM_LOCK_SLICE 1 /**< Time slice for lock, in jiffies */
132 #define DRM_FLAG_DEBUG 0x01
134 #define DRM_MEM_DMA 0
135 #define DRM_MEM_SAREA 1
136 #define DRM_MEM_DRIVER 2
137 #define DRM_MEM_MAGIC 3
138 #define DRM_MEM_IOCTLS 4
139 #define DRM_MEM_MAPS 5
140 #define DRM_MEM_VMAS 6
141 #define DRM_MEM_BUFS 7
142 #define DRM_MEM_SEGS 8
143 #define DRM_MEM_PAGES 9
144 #define DRM_MEM_FILES 10
145 #define DRM_MEM_QUEUES 11
146 #define DRM_MEM_CMDS 12
147 #define DRM_MEM_MAPPINGS 13
148 #define DRM_MEM_BUFLISTS 14
149 #define DRM_MEM_AGPLISTS 15
150 #define DRM_MEM_TOTALAGP 16
151 #define DRM_MEM_BOUNDAGP 17
152 #define DRM_MEM_CTXBITMAP 18
153 #define DRM_MEM_STUB 19
154 #define DRM_MEM_SGLISTS 20
155 #define DRM_MEM_CTXLIST 21
156 #define DRM_MEM_MM 22
157 #define DRM_MEM_HASHTAB 23
158 #define DRM_MEM_OBJECTS 24
159 #define DRM_MEM_FENCE 25
160 #define DRM_MEM_TTM 26
161 #define DRM_MEM_BUFOBJ 27
163 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
164 #define DRM_MAP_HASH_OFFSET 0x10000000
168 #include "drm_compat.h"
170 /***********************************************************************/
171 /** \name Macros to make printk easier */
177 * \param fmt printf() like format string.
178 * \param arg arguments
180 #define DRM_ERROR(fmt, arg...) \
181 printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg)
184 * Memory error output.
186 * \param area memory area where the error occurred.
187 * \param fmt printf() like format string.
188 * \param arg arguments
190 #define DRM_MEM_ERROR(area, fmt, arg...) \
191 printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \
192 drm_mem_stats[area].name , ##arg)
193 #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
198 * \param fmt printf() like format string.
199 * \param arg arguments
202 #define DRM_DEBUG(fmt, arg...) \
206 "[" DRM_NAME ":%s] " fmt , \
207 __FUNCTION__ , ##arg); \
210 #define DRM_DEBUG(fmt, arg...) do { } while (0)
213 #define DRM_PROC_LIMIT (PAGE_SIZE-80)
215 #define DRM_PROC_PRINT(fmt, arg...) \
216 len += sprintf(&buf[len], fmt , ##arg); \
217 if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; }
219 #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
220 len += sprintf(&buf[len], fmt , ##arg); \
221 if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }
225 /***********************************************************************/
226 /** \name Internal types and structures */
229 #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
230 #define DRM_MIN(a,b) min(a,b)
231 #define DRM_MAX(a,b) max(a,b)
233 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
234 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
235 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
237 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
239 * Get the private SAREA mapping.
241 * \param _dev DRM device.
242 * \param _ctx context number.
243 * \param _map output mapping.
245 #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
246 (_map) = (_dev)->context_sareas[_ctx]; \
250 * Test that the hardware lock is held by the caller, returning otherwise.
252 * \param dev DRM device.
253 * \param filp file pointer of the caller.
255 #define LOCK_TEST_WITH_RETURN( dev, filp ) \
257 if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
258 dev->lock.filp != filp ) { \
259 DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\
260 __FUNCTION__, _DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ),\
261 dev->lock.filp, filp ); \
267 * Copy and IOCTL return string to user space
269 #define DRM_COPY( name, value ) \
270 len = strlen( value ); \
271 if ( len > name##_len ) len = name##_len; \
272 name##_len = strlen( value ); \
273 if ( len && name ) { \
274 if ( copy_to_user( name, value, len ) ) \
279 * Ioctl function type.
281 * \param inode device inode.
282 * \param filp file pointer.
283 * \param cmd command.
284 * \param arg argument.
286 typedef int drm_ioctl_t(struct inode *inode, struct file *filp,
287 unsigned int cmd, unsigned long arg);
289 typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
293 #define DRM_MASTER 0x2
294 #define DRM_ROOT_ONLY 0x4
296 typedef struct drm_ioctl_desc {
301 typedef struct drm_devstate {
302 pid_t owner; /**< X server pid holding x_lock */
305 typedef struct drm_magic_entry {
306 drm_hash_item_t hash_item;
307 struct list_head head;
308 struct drm_file *priv;
311 typedef struct drm_magic_head {
312 struct drm_magic_entry *head;
313 struct drm_magic_entry *tail;
316 typedef struct drm_vma_entry {
317 struct vm_area_struct *vma;
318 struct drm_vma_entry *next;
325 typedef struct drm_buf {
326 int idx; /**< Index into master buflist */
327 int total; /**< Buffer size */
328 int order; /**< log-base-2(total) */
329 int used; /**< Amount of buffer in use (for DMA) */
330 unsigned long offset; /**< Byte offset (used internally) */
331 void *address; /**< Address of buffer */
332 unsigned long bus_address; /**< Bus address of buffer */
333 struct drm_buf *next; /**< Kernel-only: used for free list */
334 __volatile__ int waiting; /**< On kernel DMA queue */
335 __volatile__ int pending; /**< On hardware DMA queue */
336 wait_queue_head_t dma_wait; /**< Processes waiting */
337 struct file *filp; /**< Pointer to holding file descr */
338 int context; /**< Kernel queue for this buffer */
339 int while_locked; /**< Dispatch this buffer while locked */
347 } list; /**< Which list we're on */
349 int dev_priv_size; /**< Size of buffer private storage */
350 void *dev_private; /**< Per-buffer private storage */
353 /** bufs is one longer than it has to be */
354 typedef struct drm_waitlist {
355 int count; /**< Number of possible buffers */
356 drm_buf_t **bufs; /**< List of pointers to buffers */
357 drm_buf_t **rp; /**< Read pointer */
358 drm_buf_t **wp; /**< Write pointer */
359 drm_buf_t **end; /**< End pointer */
360 spinlock_t read_lock;
361 spinlock_t write_lock;
364 typedef struct drm_freelist {
365 int initialized; /**< Freelist in use */
366 atomic_t count; /**< Number of free buffers */
367 drm_buf_t *next; /**< End pointer */
369 wait_queue_head_t waiting; /**< Processes waiting on free bufs */
370 int low_mark; /**< Low water mark */
371 int high_mark; /**< High water mark */
372 atomic_t wfh; /**< If waiting for high mark */
376 typedef struct drm_dma_handle {
383 * Buffer entry. There is one of this for each buffer size order.
385 typedef struct drm_buf_entry {
386 int buf_size; /**< size */
387 int buf_count; /**< number of buffers */
388 drm_buf_t *buflist; /**< buffer list */
391 drm_dma_handle_t **seglist;
392 drm_freelist_t freelist;
396 * This should be small enough to allow the use of kmalloc for hash tables
397 * instead of vmalloc.
400 #define DRM_FILE_HASH_ORDER 8
408 /** File private data */
409 typedef struct drm_file {
416 unsigned long ioctl_count;
417 struct drm_file *next;
418 struct drm_file *prev;
419 struct drm_head *head;
420 int remove_auth_on_close;
421 unsigned long lock_count;
424 * The user object hash table is global and resides in the
425 * drm_device structure. We protect the lists and hash tables with the
426 * device struct_mutex. A bit coarse-grained but probably the best
430 struct list_head refd_objects;
431 struct list_head user_objects;
433 drm_open_hash_t refd_object_hash[_DRM_NO_REF_TYPES];
438 typedef struct drm_queue {
439 atomic_t use_count; /**< Outstanding uses (+1) */
440 atomic_t finalization; /**< Finalization in progress */
441 atomic_t block_count; /**< Count of processes waiting */
442 atomic_t block_read; /**< Queue blocked for reads */
443 wait_queue_head_t read_queue; /**< Processes waiting on block_read */
444 atomic_t block_write; /**< Queue blocked for writes */
445 wait_queue_head_t write_queue; /**< Processes waiting on block_write */
447 atomic_t total_queued; /**< Total queued statistic */
448 atomic_t total_flushed; /**< Total flushes statistic */
449 atomic_t total_locks; /**< Total locks statistics */
451 drm_ctx_flags_t flags; /**< Context preserving and 2D-only */
452 drm_waitlist_t waitlist; /**< Pending buffers */
453 wait_queue_head_t flush_queue; /**< Processes waiting until flush */
459 typedef struct drm_lock_data {
460 drm_hw_lock_t *hw_lock; /**< Hardware lock */
461 struct file *filp; /**< File descr of lock holder (0=kernel) */
462 wait_queue_head_t lock_queue; /**< Queue of blocked processes */
463 unsigned long lock_time; /**< Time of last lock in jiffies */
469 typedef struct drm_device_dma {
471 drm_buf_entry_t bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */
472 int buf_count; /**< total number of buffers */
473 drm_buf_t **buflist; /**< Vector of pointers into drm_device_dma::bufs */
475 int page_count; /**< number of pages */
476 unsigned long *pagelist; /**< page list */
477 unsigned long byte_count;
479 _DRM_DMA_USE_AGP = 0x01,
480 _DRM_DMA_USE_SG = 0x02,
481 _DRM_DMA_USE_FB = 0x04
487 * AGP memory entry. Stored as a doubly linked list.
489 typedef struct drm_agp_mem {
490 unsigned long handle; /**< handle */
492 unsigned long bound; /**< address */
494 struct drm_agp_mem *prev; /**< previous entry */
495 struct drm_agp_mem *next; /**< next entry */
501 * \sa drm_agp_init)() and drm_device::agp.
503 typedef struct drm_agp_head {
504 DRM_AGP_KERN agp_info; /**< AGP device information */
505 drm_agp_mem_t *memory; /**< memory entries */
506 unsigned long mode; /**< AGP mode */
507 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,11)
508 struct agp_bridge_data *bridge;
510 int enabled; /**< whether the AGP bus as been enabled */
511 int acquired; /**< whether the AGP device has been acquired */
514 int cant_use_aperture;
515 unsigned long page_mask;
519 * Scatter-gather memory.
521 typedef struct drm_sg_mem {
522 unsigned long handle;
525 struct page **pagelist;
529 typedef struct drm_sigdata {
537 typedef struct drm_map_list {
538 struct list_head head; /**< list head */
539 drm_hash_item_t hash;
540 drm_map_t *map; /**< mapping */
541 unsigned int user_token;
544 typedef drm_map_t drm_local_map_t;
547 * Context handle list
549 typedef struct drm_ctx_list {
550 struct list_head head; /**< list head */
551 drm_context_t handle; /**< context handle */
552 drm_file_t *tag; /**< associated fd private data */
555 typedef struct drm_vbl_sig {
556 struct list_head head;
557 unsigned int sequence;
559 struct task_struct *task;
562 /* location of GART table */
563 #define DRM_ATI_GART_MAIN 1
564 #define DRM_ATI_GART_FB 2
566 typedef struct ati_pcigart_info {
567 int gart_table_location;
571 drm_local_map_t mapping;
572 } drm_ati_pcigart_info;
575 * Generic memory manager structs
578 typedef struct drm_mm_node {
579 struct list_head fl_entry;
580 struct list_head ml_entry;
587 typedef struct drm_mm {
588 drm_mm_node_t root_node;
593 * User space objects and their references.
596 #define drm_user_object_entry(_ptr, _type, _member) container_of(_ptr, _type, _member)
604 * Add other user space object types here.
613 * A user object is a structure that helps the drm give out user handles
614 * to kernel internal objects and to keep track of these objects so that
615 * they can be destroyed, for example when the user space process exits.
616 * Designed to be accessible using a user space 32-bit handle.
619 typedef struct drm_user_object{
620 drm_hash_item_t hash;
621 struct list_head list;
622 drm_object_type_t type;
626 void (*ref_struct_locked) (drm_file_t *priv, struct drm_user_object *obj,
627 drm_ref_t ref_action);
628 void (*unref)(drm_file_t *priv, struct drm_user_object *obj,
629 drm_ref_t unref_action);
630 void (*remove)(drm_file_t *priv, struct drm_user_object *obj);
634 * A ref object is a structure which is used to
635 * keep track of references to user objects and to keep track of these
636 * references so that they can be destroyed for example when the user space
637 * process exits. Designed to be accessible using a pointer to the _user_ object.
641 typedef struct drm_ref_object {
642 drm_hash_item_t hash;
643 struct list_head list;
645 drm_ref_t unref_action;
652 * buffer object driver
655 typedef struct drm_bo_driver{
658 drm_ttm_backend_t *(*create_ttm_backend_entry)
659 (struct drm_device *dev, int cached);
660 int (*fence_type)(uint32_t flags, uint32_t *class, uint32_t *type);
661 int (*invalidate_caches)(struct drm_device *dev, uint32_t flags);
666 * DRM driver structure. This structure represent the common code for
667 * a family of cards. There will one drm_device for each card present
673 int (*load) (struct drm_device *, unsigned long flags);
674 int (*firstopen) (struct drm_device *);
675 int (*open) (struct drm_device *, drm_file_t *);
676 void (*preclose) (struct drm_device *, struct file * filp);
677 void (*postclose) (struct drm_device *, drm_file_t *);
678 void (*lastclose) (struct drm_device *);
679 int (*unload) (struct drm_device *);
680 int (*dma_ioctl) (DRM_IOCTL_ARGS);
681 void (*dma_ready) (struct drm_device *);
682 int (*dma_quiescent) (struct drm_device *);
683 int (*context_ctor) (struct drm_device * dev, int context);
684 int (*context_dtor) (struct drm_device * dev, int context);
685 int (*kernel_context_switch) (struct drm_device * dev, int old,
687 void (*kernel_context_switch_unlock) (struct drm_device * dev);
688 int (*vblank_wait) (struct drm_device * dev, unsigned int *sequence);
689 int (*dri_library_name) (struct drm_device * dev, char * buf);
692 * Called by \c drm_device_is_agp. Typically used to determine if a
693 * card is really attached to AGP or not.
695 * \param dev DRM device handle
698 * One of three values is returned depending on whether or not the
699 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
700 * (return of 1), or may or may not be AGP (return of 2).
702 int (*device_is_agp) (struct drm_device * dev);
704 /* these have to be filled in */
705 irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
706 void (*irq_preinstall) (struct drm_device * dev);
707 void (*irq_postinstall) (struct drm_device * dev);
708 void (*irq_uninstall) (struct drm_device * dev);
709 void (*reclaim_buffers) (struct drm_device *dev, struct file * filp);
710 void (*reclaim_buffers_locked) (struct drm_device *dev,
712 unsigned long (*get_map_ofs) (drm_map_t * map);
713 unsigned long (*get_reg_ofs) (struct drm_device * dev);
714 void (*set_version) (struct drm_device * dev, drm_set_version_t * sv);
716 struct drm_fence_driver *fence_driver;
717 struct drm_bo_driver *bo_driver;
729 drm_ioctl_desc_t *ioctls;
731 struct file_operations fops;
732 struct pci_driver pci_driver;
736 * DRM head structure. This structure represent a video head on a card
737 * that may contain multiple heads. Embed one per head of these in the
738 * private drm_device structure.
740 typedef struct drm_head {
741 int minor; /**< Minor device number */
742 struct drm_device *dev;
743 struct proc_dir_entry *dev_root; /**< proc directory entry */
744 dev_t device; /**< Device number for mknod */
745 struct class_device *dev_class;
748 typedef struct drm_cache {
755 kmem_cache_t *fence_object;
756 kmem_cache_t *ref_object;
761 typedef struct drm_fence_driver{
765 uint32_t sequence_mask;
767 int (*emit) (struct drm_device *dev, uint32_t *breadcrumb);
768 void (*poke_flush) (struct drm_device *dev);
769 } drm_fence_driver_t;
771 #define _DRM_FENCE_TYPE_EXE 0x00
773 typedef struct drm_fence_manager{
778 * The list below should be maintained in sequence order and
779 * access is protected by the above spinlock.
782 struct list_head ring;
783 struct list_head *fence_types[32];
784 volatile uint32_t pending_flush;
785 wait_queue_head_t fence_queue;
786 int pending_exe_flush;
787 uint32_t last_exe_flush;
788 uint32_t exe_flush_sequence;
789 } drm_fence_manager_t;
791 typedef struct drm_buffer_manager{
798 struct list_head tt_lru;
799 drm_mm_t vram_manager;
800 struct list_head vram_lru;
801 struct list_head unfenced;
802 struct list_head ddestroy;
803 struct list_head other;
804 struct work_struct wq;
805 uint32_t fence_flags;
806 } drm_buffer_manager_t;
811 * DRM device structure. This structure represent a complete card that
812 * may contain multiple heads.
814 typedef struct drm_device {
815 char *unique; /**< Unique identifier: e.g., busid */
816 int unique_len; /**< Length of unique field */
817 char *devname; /**< For /proc/interrupts */
818 int if_version; /**< Highest interface version set */
820 int blocked; /**< Blocked due to VC switch? */
824 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
825 struct mutex struct_mutex; /**< For others */
828 /** \name Usage Counters */
830 int open_count; /**< Outstanding files open */
831 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
832 atomic_t vma_count; /**< Outstanding vma areas open */
833 int buf_use; /**< Buffers in use -- cannot alloc */
834 atomic_t buf_alloc; /**< Buffer allocation in progress */
837 /** \name Performance counters */
839 unsigned long counters;
840 drm_stat_type_t types[15];
844 /** \name Authentication */
846 drm_file_t *file_first; /**< file list head */
847 drm_file_t *file_last; /**< file list tail */
848 drm_open_hash_t magiclist;
849 struct list_head magicfree;
852 /** \name Memory management */
854 drm_map_list_t *maplist; /**< Linked list of regions */
855 int map_count; /**< Number of mappable regions */
856 drm_open_hash_t map_hash; /**< User token hash table for maps */
857 drm_open_hash_t object_hash; /**< User token hash table for objects */
859 /** \name Context handle management */
861 drm_ctx_list_t *ctxlist; /**< Linked list of context handles */
862 int ctx_count; /**< Number of context handles */
863 struct mutex ctxlist_mutex; /**< For ctxlist */
865 drm_map_t **context_sareas; /**< per-context SAREA's */
868 drm_vma_entry_t *vmalist; /**< List of vmas (for debugging) */
869 drm_lock_data_t lock; /**< Information on hardware lock */
872 /** \name DMA queues (contexts) */
874 int queue_count; /**< Number of active DMA queues */
875 int queue_reserved; /**< Number of reserved DMA queues */
876 int queue_slots; /**< Actual length of queuelist */
877 drm_queue_t **queuelist; /**< Vector of pointers to DMA queues */
878 drm_device_dma_t *dma; /**< Optional pointer for DMA support */
881 /** \name Context support */
883 int irq; /**< Interrupt used by board */
884 int irq_enabled; /**< True if irq handler is enabled */
885 __volatile__ long context_flag; /**< Context swapping flag */
886 __volatile__ long interrupt_flag; /**< Interruption handler flag */
887 __volatile__ long dma_flag; /**< DMA dispatch flag */
888 struct timer_list timer; /**< Timer for delaying ctx switch */
889 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
890 int last_checked; /**< Last context checked for DMA */
891 int last_context; /**< Last current context */
892 unsigned long last_switch; /**< jiffies at last context switch */
898 struct work_struct work;
900 /** \name VBLANK IRQ support */
903 wait_queue_head_t vbl_queue; /**< VBLANK wait queue */
904 atomic_t vbl_received;
906 drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */
907 unsigned int vbl_pending;
913 struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
914 wait_queue_head_t buf_readers; /**< Processes waiting to read */
915 wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
917 drm_agp_head_t *agp; /**< AGP data */
919 struct pci_dev *pdev; /**< PCI device structure */
921 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3)
922 struct pci_controler *hose;
924 struct pci_controller *hose;
927 drm_sg_mem_t *sg; /**< Scatter gather memory */
928 unsigned long *ctx_bitmap; /**< context bitmap */
929 void *dev_private; /**< device private data */
930 drm_sigdata_t sigdata; /**< For block_all_signals */
933 struct drm_driver *driver;
934 drm_local_map_t *agp_buffer_map;
935 unsigned int agp_buffer_token;
936 drm_head_t primary; /**< primary screen head */
938 drm_fence_manager_t fm;
939 drm_buffer_manager_t bm;
944 typedef struct drm_agp_ttm_priv {
946 struct agp_bridge_data *bridge;
952 typedef struct drm_fence_object{
953 drm_user_object_t base;
957 * The below three fields are protected by the fence manager spinlock.
960 struct list_head ring;
962 volatile uint32_t type;
963 volatile uint32_t signaled;
965 volatile uint32_t flush_mask;
966 volatile uint32_t submitted_flush;
967 } drm_fence_object_t;
970 typedef struct drm_buffer_object{
972 drm_user_object_t base;
975 * If there is a possibility that the usage variable is zero,
976 * then dev->struct_mutext should be locked before incrementing it.
980 drm_ttm_object_t *ttm_object;
981 drm_ttm_backend_list_t *ttm_region;
982 unsigned long num_pages;
983 unsigned long buffer_start;
985 unsigned long offset;
993 struct list_head head;
994 struct list_head ddestroy;
996 uint32_t fence_flags;
997 uint32_t fence_class;
998 drm_fence_object_t *fence;
1000 wait_queue_head_t event_queue;
1002 } drm_buffer_object_t;
1004 #define _DRM_BO_FLAG_UNFENCED 0x00000001
1005 #define _DRM_BO_FLAG_EVICTED 0x00000002
1008 static __inline__ int drm_core_check_feature(struct drm_device *dev,
1011 return ((dev->driver->driver_features & feature) ? 1 : 0);
1015 #define drm_get_pci_domain(dev) dev->hose->bus->number
1017 #define drm_get_pci_domain(dev) pci_domain_nr(dev->pdev->bus)
1021 static inline int drm_core_has_AGP(struct drm_device *dev)
1023 return drm_core_check_feature(dev, DRIVER_USE_AGP);
1026 #define drm_core_has_AGP(dev) (0)
1030 static inline int drm_core_has_MTRR(struct drm_device *dev)
1032 return drm_core_check_feature(dev, DRIVER_USE_MTRR);
1035 #define DRM_MTRR_WC MTRR_TYPE_WRCOMB
1037 static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
1040 return mtrr_add(offset, size, flags, 1);
1043 static inline int drm_mtrr_del(int handle, unsigned long offset,
1044 unsigned long size, unsigned int flags)
1046 return mtrr_del(handle, offset, size);
1050 #define drm_core_has_MTRR(dev) (0)
1054 /******************************************************************/
1055 /** \name Internal function definitions */
1058 /* Driver support (drm_drv.h) */
1059 extern int drm_fb_loaded;
1060 extern int drm_init(struct drm_driver *driver,
1061 struct pci_device_id *pciidlist);
1062 extern void drm_exit(struct drm_driver *driver);
1063 extern void drm_cleanup_pci(struct pci_dev *pdev);
1064 extern int drm_ioctl(struct inode *inode, struct file *filp,
1065 unsigned int cmd, unsigned long arg);
1066 extern long drm_compat_ioctl(struct file *filp,
1067 unsigned int cmd, unsigned long arg);
1069 extern int drm_lastclose(drm_device_t * dev);
1071 /* Device support (drm_fops.h) */
1072 extern int drm_open(struct inode *inode, struct file *filp);
1073 extern int drm_stub_open(struct inode *inode, struct file *filp);
1074 extern int drm_fasync(int fd, struct file *filp, int on);
1075 extern int drm_release(struct inode *inode, struct file *filp);
1076 unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
1078 /* Mapping support (drm_vm.h) */
1079 extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1080 extern unsigned long drm_core_get_map_ofs(drm_map_t * map);
1081 extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev);
1082 extern pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma);
1084 /* Memory management support (drm_memory.h) */
1085 #include "drm_memory.h"
1086 extern void drm_mem_init(void);
1087 extern int drm_mem_info(char *buf, char **start, off_t offset,
1088 int request, int *eof, void *data);
1089 extern void *drm_calloc(size_t nmemb, size_t size, int area);
1090 extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
1091 extern unsigned long drm_alloc_pages(int order, int area);
1092 extern void drm_free_pages(unsigned long address, int order, int area);
1093 extern DRM_AGP_MEM *drm_alloc_agp(drm_device_t *dev, int pages, u32 type);
1094 extern int drm_free_agp(DRM_AGP_MEM * handle, int pages);
1095 extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
1096 extern int drm_unbind_agp(DRM_AGP_MEM * handle);
1098 /* Misc. IOCTL support (drm_ioctl.h) */
1099 extern int drm_irq_by_busid(struct inode *inode, struct file *filp,
1100 unsigned int cmd, unsigned long arg);
1101 extern int drm_getunique(struct inode *inode, struct file *filp,
1102 unsigned int cmd, unsigned long arg);
1103 extern int drm_setunique(struct inode *inode, struct file *filp,
1104 unsigned int cmd, unsigned long arg);
1105 extern int drm_getmap(struct inode *inode, struct file *filp,
1106 unsigned int cmd, unsigned long arg);
1107 extern int drm_getclient(struct inode *inode, struct file *filp,
1108 unsigned int cmd, unsigned long arg);
1109 extern int drm_getstats(struct inode *inode, struct file *filp,
1110 unsigned int cmd, unsigned long arg);
1111 extern int drm_setversion(struct inode *inode, struct file *filp,
1112 unsigned int cmd, unsigned long arg);
1113 extern int drm_noop(struct inode *inode, struct file *filp,
1114 unsigned int cmd, unsigned long arg);
1116 /* Context IOCTL support (drm_context.h) */
1117 extern int drm_resctx(struct inode *inode, struct file *filp,
1118 unsigned int cmd, unsigned long arg);
1119 extern int drm_addctx(struct inode *inode, struct file *filp,
1120 unsigned int cmd, unsigned long arg);
1121 extern int drm_modctx(struct inode *inode, struct file *filp,
1122 unsigned int cmd, unsigned long arg);
1123 extern int drm_getctx(struct inode *inode, struct file *filp,
1124 unsigned int cmd, unsigned long arg);
1125 extern int drm_switchctx(struct inode *inode, struct file *filp,
1126 unsigned int cmd, unsigned long arg);
1127 extern int drm_newctx(struct inode *inode, struct file *filp,
1128 unsigned int cmd, unsigned long arg);
1129 extern int drm_rmctx(struct inode *inode, struct file *filp,
1130 unsigned int cmd, unsigned long arg);
1132 extern int drm_ctxbitmap_init(drm_device_t * dev);
1133 extern void drm_ctxbitmap_cleanup(drm_device_t * dev);
1134 extern void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle);
1136 extern int drm_setsareactx(struct inode *inode, struct file *filp,
1137 unsigned int cmd, unsigned long arg);
1138 extern int drm_getsareactx(struct inode *inode, struct file *filp,
1139 unsigned int cmd, unsigned long arg);
1141 /* Drawable IOCTL support (drm_drawable.h) */
1142 extern int drm_adddraw(struct inode *inode, struct file *filp,
1143 unsigned int cmd, unsigned long arg);
1144 extern int drm_rmdraw(struct inode *inode, struct file *filp,
1145 unsigned int cmd, unsigned long arg);
1147 /* Authentication IOCTL support (drm_auth.h) */
1148 extern int drm_getmagic(struct inode *inode, struct file *filp,
1149 unsigned int cmd, unsigned long arg);
1150 extern int drm_authmagic(struct inode *inode, struct file *filp,
1151 unsigned int cmd, unsigned long arg);
1153 /* Locking IOCTL support (drm_lock.h) */
1154 extern int drm_lock(struct inode *inode, struct file *filp,
1155 unsigned int cmd, unsigned long arg);
1156 extern int drm_unlock(struct inode *inode, struct file *filp,
1157 unsigned int cmd, unsigned long arg);
1158 extern int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context);
1159 extern int drm_lock_free(drm_device_t * dev,
1160 __volatile__ unsigned int *lock, unsigned int context);
1162 * These are exported to drivers so that they can implement fencing using
1163 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
1166 extern int drm_i_have_hw_lock(struct file *filp);
1167 extern int drm_kernel_take_hw_lock(struct file *filp);
1169 /* Buffer management support (drm_bufs.h) */
1170 extern int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request);
1171 extern int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request);
1172 extern int drm_addbufs_fb (drm_device_t * dev, drm_buf_desc_t * request);
1173 extern int drm_addmap(drm_device_t * dev, unsigned int offset,
1174 unsigned int size, drm_map_type_t type,
1175 drm_map_flags_t flags, drm_local_map_t ** map_ptr);
1176 extern int drm_addmap_ioctl(struct inode *inode, struct file *filp,
1177 unsigned int cmd, unsigned long arg);
1178 extern int drm_rmmap(drm_device_t *dev, drm_local_map_t *map);
1179 extern int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map);
1180 extern int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
1181 unsigned int cmd, unsigned long arg);
1182 extern int drm_addbufs(struct inode *inode, struct file *filp,
1183 unsigned int cmd, unsigned long arg);
1184 extern int drm_infobufs(struct inode *inode, struct file *filp,
1185 unsigned int cmd, unsigned long arg);
1186 extern int drm_markbufs(struct inode *inode, struct file *filp,
1187 unsigned int cmd, unsigned long arg);
1188 extern int drm_freebufs(struct inode *inode, struct file *filp,
1189 unsigned int cmd, unsigned long arg);
1190 extern int drm_mapbufs(struct inode *inode, struct file *filp,
1191 unsigned int cmd, unsigned long arg);
1192 extern int drm_order(unsigned long size);
1193 extern unsigned long drm_get_resource_start(drm_device_t *dev,
1194 unsigned int resource);
1195 extern unsigned long drm_get_resource_len(drm_device_t *dev,
1196 unsigned int resource);
1198 /* DMA support (drm_dma.h) */
1199 extern int drm_dma_setup(drm_device_t * dev);
1200 extern void drm_dma_takedown(drm_device_t * dev);
1201 extern void drm_free_buffer(drm_device_t * dev, drm_buf_t * buf);
1202 extern void drm_core_reclaim_buffers(drm_device_t *dev, struct file *filp);
1204 /* IRQ support (drm_irq.h) */
1205 extern int drm_control(struct inode *inode, struct file *filp,
1206 unsigned int cmd, unsigned long arg);
1207 extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
1208 extern int drm_irq_uninstall(drm_device_t *dev);
1209 extern void drm_driver_irq_preinstall(drm_device_t * dev);
1210 extern void drm_driver_irq_postinstall(drm_device_t * dev);
1211 extern void drm_driver_irq_uninstall(drm_device_t * dev);
1213 extern int drm_wait_vblank(struct inode *inode, struct file *filp,
1214 unsigned int cmd, unsigned long arg);
1215 extern int drm_vblank_wait(drm_device_t * dev, unsigned int *vbl_seq);
1216 extern void drm_vbl_send_signals(drm_device_t * dev);
1218 /* AGP/GART support (drm_agpsupport.h) */
1219 extern drm_agp_head_t *drm_agp_init(drm_device_t *dev);
1220 extern int drm_agp_acquire(drm_device_t * dev);
1221 extern int drm_agp_acquire_ioctl(struct inode *inode, struct file *filp,
1222 unsigned int cmd, unsigned long arg);
1223 extern int drm_agp_release(drm_device_t *dev);
1224 extern int drm_agp_release_ioctl(struct inode *inode, struct file *filp,
1225 unsigned int cmd, unsigned long arg);
1226 extern int drm_agp_enable(drm_device_t *dev, drm_agp_mode_t mode);
1227 extern int drm_agp_enable_ioctl(struct inode *inode, struct file *filp,
1228 unsigned int cmd, unsigned long arg);
1229 extern int drm_agp_info(drm_device_t * dev, drm_agp_info_t *info);
1230 extern int drm_agp_info_ioctl(struct inode *inode, struct file *filp,
1231 unsigned int cmd, unsigned long arg);
1232 extern int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request);
1233 extern int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp,
1234 unsigned int cmd, unsigned long arg);
1235 extern int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request);
1236 extern int drm_agp_free_ioctl(struct inode *inode, struct file *filp,
1237 unsigned int cmd, unsigned long arg);
1238 extern int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request);
1239 extern int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp,
1240 unsigned int cmd, unsigned long arg);
1241 extern int drm_agp_bind(drm_device_t *dev, drm_agp_binding_t *request);
1242 extern int drm_agp_bind_ioctl(struct inode *inode, struct file *filp,
1243 unsigned int cmd, unsigned long arg);
1244 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)
1245 extern DRM_AGP_MEM *drm_agp_allocate_memory(size_t pages, u32 type);
1247 extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size_t pages, u32 type);
1249 extern int drm_agp_free_memory(DRM_AGP_MEM * handle);
1250 extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start);
1251 extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
1252 extern drm_ttm_backend_t *drm_agp_init_ttm_cached(struct drm_device *dev);
1253 extern drm_ttm_backend_t *drm_agp_init_ttm_uncached(struct drm_device *dev);
1255 /* Stub support (drm_stub.h) */
1256 extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
1257 struct drm_driver *driver);
1258 extern int drm_put_dev(drm_device_t * dev);
1259 extern int drm_put_head(drm_head_t * head);
1260 extern unsigned int drm_debug; /* 1 to enable debug output */
1261 extern unsigned int drm_cards_limit;
1262 extern drm_head_t **drm_heads;
1263 extern drm_cache_t drm_cache;
1264 extern struct drm_sysfs_class *drm_class;
1265 extern struct proc_dir_entry *drm_proc_root;
1267 /* Proc support (drm_proc.h) */
1268 extern int drm_proc_init(drm_device_t * dev,
1270 struct proc_dir_entry *root,
1271 struct proc_dir_entry **dev_root);
1272 extern int drm_proc_cleanup(int minor,
1273 struct proc_dir_entry *root,
1274 struct proc_dir_entry *dev_root);
1276 /* Scatter Gather Support (drm_scatter.h) */
1277 extern void drm_sg_cleanup(drm_sg_mem_t * entry);
1278 extern int drm_sg_alloc(struct inode *inode, struct file *filp,
1279 unsigned int cmd, unsigned long arg);
1280 extern int drm_sg_free(struct inode *inode, struct file *filp,
1281 unsigned int cmd, unsigned long arg);
1283 /* ATI PCIGART support (ati_pcigart.h) */
1284 extern int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info *gart_info);
1285 extern int drm_ati_pcigart_cleanup(drm_device_t * dev, drm_ati_pcigart_info *gart_info);
1287 extern drm_dma_handle_t *drm_pci_alloc(drm_device_t * dev, size_t size,
1288 size_t align, dma_addr_t maxaddr);
1289 extern void __drm_pci_free(drm_device_t * dev, drm_dma_handle_t *dmah);
1290 extern void drm_pci_free(drm_device_t * dev, drm_dma_handle_t *dmah);
1292 /* sysfs support (drm_sysfs.c) */
1293 struct drm_sysfs_class;
1294 extern struct drm_sysfs_class *drm_sysfs_create(struct module *owner,
1296 extern void drm_sysfs_destroy(struct drm_sysfs_class *cs);
1297 extern struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs,
1299 extern void drm_sysfs_device_remove(struct class_device *class_dev);
1302 * Basic memory manager support (drm_mm.c)
1305 extern drm_mm_node_t * drm_mm_get_block(drm_mm_node_t * parent, unsigned long size,
1306 unsigned alignment);
1307 extern void drm_mm_put_block(drm_mm_t *mm, drm_mm_node_t *cur);
1308 extern drm_mm_node_t *drm_mm_search_free(const drm_mm_t *mm, unsigned long size,
1309 unsigned alignment, int best_match);
1310 extern int drm_mm_init(drm_mm_t *mm, unsigned long start, unsigned long size);
1311 extern void drm_mm_takedown(drm_mm_t *mm);
1312 extern int drm_mm_clean(drm_mm_t *mm);
1315 * User space object bookkeeping (drm_object.c)
1319 * Must be called with the struct_mutex held.
1322 extern int drm_add_user_object(drm_file_t *priv, drm_user_object_t *item,
1325 * Must be called with the struct_mutex held.
1328 extern drm_user_object_t *drm_lookup_user_object(drm_file_t *priv, uint32_t key);
1331 * Must be called with the struct_mutex held.
1332 * If "item" has been obtained by a call to drm_lookup_user_object. You may not
1333 * release the struct_mutex before calling drm_remove_ref_object.
1334 * This function may temporarily release the struct_mutex.
1337 extern int drm_remove_user_object(drm_file_t *priv, drm_user_object_t *item);
1340 * Must be called with the struct_mutex held. May temporarily release it.
1343 extern int drm_add_ref_object(drm_file_t *priv, drm_user_object_t *referenced_object,
1344 drm_ref_t ref_action);
1347 * Must be called with the struct_mutex held.
1350 drm_ref_object_t *drm_lookup_ref_object(drm_file_t *priv,
1351 drm_user_object_t *referenced_object,
1352 drm_ref_t ref_action);
1354 * Must be called with the struct_mutex held.
1355 * If "item" has been obtained by a call to drm_lookup_ref_object. You may not
1356 * release the struct_mutex before calling drm_remove_ref_object.
1357 * This function may temporarily release the struct_mutex.
1360 extern void drm_remove_ref_object(drm_file_t *priv, drm_ref_object_t *item);
1361 extern int drm_user_object_ref(drm_file_t *priv, uint32_t user_token, drm_object_type_t type,
1362 drm_user_object_t **object);
1363 extern int drm_user_object_unref(drm_file_t *priv, uint32_t user_token, drm_object_type_t type);
1368 * fence objects (drm_fence.c)
1371 extern void drm_fence_handler(drm_device_t *dev, uint32_t breadcrumb, uint32_t type);
1372 extern void drm_fence_manager_init(drm_device_t *dev);
1373 extern void drm_fence_manager_takedown(drm_device_t *dev);
1374 extern void drm_fence_flush_old(drm_device_t *dev, uint32_t sequence);
1375 extern int drm_fence_object_flush(drm_device_t * dev,
1376 drm_fence_object_t * fence, uint32_t type);
1377 extern int drm_fence_object_signaled(drm_fence_object_t * fence, uint32_t type);
1378 extern void drm_fence_usage_deref_locked(drm_device_t * dev,
1379 drm_fence_object_t * fence);
1380 extern void drm_fence_usage_deref_unlocked(drm_device_t * dev,
1381 drm_fence_object_t * fence);
1382 extern int drm_fence_object_wait(drm_device_t * dev, drm_fence_object_t * fence,
1383 int lazy, int ignore_signals, uint32_t mask);
1384 extern int drm_fence_object_create(drm_device_t *dev, uint32_t type,
1385 int emit, drm_fence_object_t **c_fence);
1386 extern int drm_fence_add_user_object(drm_file_t *priv,
1387 drm_fence_object_t *fence,
1394 extern int drm_fence_ioctl(DRM_IOCTL_ARGS);
1397 * buffer objects (drm_bo.c)
1400 extern int drm_bo_ioctl(DRM_IOCTL_ARGS);
1401 extern int drm_mm_init_ioctl(DRM_IOCTL_ARGS);
1402 extern int drm_bo_clean_mm(drm_device_t *dev);
1403 extern int drm_fence_buffer_objects(drm_file_t * priv,
1404 struct list_head *list,
1405 drm_fence_object_t *fence,
1406 drm_fence_object_t **used_fence);
1409 /* Inline replacements for DRM_IOREMAP macros */
1410 static __inline__ void drm_core_ioremap(struct drm_map *map,
1411 struct drm_device *dev)
1413 map->handle = drm_ioremap(map->offset, map->size, dev);
1416 static __inline__ void drm_core_ioremap_nocache(struct drm_map *map,
1417 struct drm_device *dev)
1419 map->handle = drm_ioremap_nocache(map->offset, map->size, dev);
1422 static __inline__ void drm_core_ioremapfree(struct drm_map *map,
1423 struct drm_device *dev)
1425 if (map->handle && map->size)
1426 drm_ioremapfree(map->handle, map->size, dev);
1429 static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev,
1432 drm_map_list_t *_entry;
1433 list_for_each_entry(_entry, &dev->maplist->head, head)
1434 if (_entry->user_token == token)
1439 static __inline__ int drm_device_is_agp(drm_device_t *dev)
1441 if ( dev->driver->device_is_agp != NULL ) {
1442 int err = (*dev->driver->device_is_agp)( dev );
1449 return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
1452 static __inline__ int drm_device_is_pcie(drm_device_t *dev)
1454 return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
1457 static __inline__ void drm_core_dropmap(struct drm_map *map)
1461 #ifndef DEBUG_MEMORY
1462 /** Wrapper around kmalloc() */
1463 static __inline__ void *drm_alloc(size_t size, int area)
1465 return kmalloc(size, GFP_KERNEL);
1468 /** Wrapper around kfree() */
1469 static __inline__ void drm_free(void *pt, size_t size, int area)
1474 extern void *drm_alloc(size_t size, int area);
1475 extern void drm_free(void *pt, size_t size, int area);
1480 #endif /* __KERNEL__ */