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/module.h>
45 #include <linux/kernel.h>
46 #include <linux/miscdevice.h>
48 #include <linux/proc_fs.h>
49 #include <linux/init.h>
50 #include <linux/file.h>
51 #include <linux/pci.h>
52 #include <linux/version.h>
53 #include <linux/sched.h>
54 #include <linux/smp_lock.h> /* For (un)lock_kernel */
55 #include <linux/dma-mapping.h>
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>
71 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
72 #include <linux/types.h>
73 #include <linux/agp_backend.h>
75 #include <linux/workqueue.h>
76 #include <linux/poll.h>
77 #include <asm/pgalloc.h>
79 #include <linux/slab.h>
80 #include <linux/idr.h>
82 #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
83 #define __OS_HAS_MTRR (defined(CONFIG_MTRR))
85 #include "drm_os_linux.h"
86 #include "drm_hashtab.h"
87 #include "drm_internal.h"
92 /* If you want the memory alloc debug functionality, change define below */
93 /* #define DEBUG_MEMORY */
95 /***********************************************************************/
96 /** \name DRM template customization defaults */
99 /* driver capabilities and requirements mask */
100 #define DRIVER_USE_AGP 0x1
101 #define DRIVER_REQUIRE_AGP 0x2
102 #define DRIVER_USE_MTRR 0x4
103 #define DRIVER_PCI_DMA 0x8
104 #define DRIVER_SG 0x10
105 #define DRIVER_HAVE_DMA 0x20
106 #define DRIVER_HAVE_IRQ 0x40
107 #define DRIVER_IRQ_SHARED 0x80
108 #define DRIVER_DMA_QUEUE 0x100
109 #define DRIVER_FB_DMA 0x200
110 #define DRIVER_MODESET 0x400
115 /***********************************************************************/
116 /** \name Begin the DRM... */
119 #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then
120 also include looping detection. */
122 #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */
123 #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */
124 #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */
125 #define DRM_LOOPING_LIMIT 5000000
126 #define DRM_TIME_SLICE (HZ/20) /**< Time slice for GLXContexts */
127 #define DRM_LOCK_SLICE 1 /**< Time slice for lock, in jiffies */
129 #define DRM_FLAG_DEBUG 0x01
131 #define DRM_MEM_DMA 0
132 #define DRM_MEM_SAREA 1
133 #define DRM_MEM_DRIVER 2
134 #define DRM_MEM_MAGIC 3
135 #define DRM_MEM_IOCTLS 4
136 #define DRM_MEM_MAPS 5
137 #define DRM_MEM_VMAS 6
138 #define DRM_MEM_BUFS 7
139 #define DRM_MEM_SEGS 8
140 #define DRM_MEM_PAGES 9
141 #define DRM_MEM_FILES 10
142 #define DRM_MEM_QUEUES 11
143 #define DRM_MEM_CMDS 12
144 #define DRM_MEM_MAPPINGS 13
145 #define DRM_MEM_BUFLISTS 14
146 #define DRM_MEM_AGPLISTS 15
147 #define DRM_MEM_TOTALAGP 16
148 #define DRM_MEM_BOUNDAGP 17
149 #define DRM_MEM_CTXBITMAP 18
150 #define DRM_MEM_STUB 19
151 #define DRM_MEM_SGLISTS 20
152 #define DRM_MEM_CTXLIST 21
153 #define DRM_MEM_MM 22
154 #define DRM_MEM_HASHTAB 23
155 #define DRM_MEM_OBJECTS 24
156 #define DRM_MEM_FENCE 25
157 #define DRM_MEM_TTM 26
158 #define DRM_MEM_BUFOBJ 27
160 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
161 #define DRM_MAP_HASH_OFFSET 0x10000000
162 #define DRM_MAP_HASH_ORDER 12
163 #define DRM_OBJECT_HASH_ORDER 12
164 #define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1)
165 #define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16)
167 * This should be small enough to allow the use of kmalloc for hash tables
168 * instead of vmalloc.
171 #define DRM_FILE_HASH_ORDER 8
172 #define DRM_MM_INIT_MAX_PAGES 256
176 #include "drm_compat.h"
178 /***********************************************************************/
179 /** \name Macros to make printk easier */
185 * \param fmt printf() like format string.
186 * \param arg arguments
188 #define DRM_ERROR(fmt, arg...) \
189 printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg)
192 * Memory error output.
194 * \param area memory area where the error occurred.
195 * \param fmt printf() like format string.
196 * \param arg arguments
198 #define DRM_MEM_ERROR(area, fmt, arg...) \
199 printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \
200 drm_mem_stats[area].name , ##arg)
201 #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
206 * \param fmt printf() like format string.
207 * \param arg arguments
210 #define DRM_DEBUG(fmt, arg...) \
214 "[" DRM_NAME ":%s] " fmt , \
215 __FUNCTION__ , ##arg); \
218 #define DRM_DEBUG(fmt, arg...) do { } while (0)
221 #define DRM_PROC_LIMIT (PAGE_SIZE-80)
223 #define DRM_PROC_PRINT(fmt, arg...) \
224 len += sprintf(&buf[len], fmt , ##arg); \
225 if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; }
227 #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
228 len += sprintf(&buf[len], fmt , ##arg); \
229 if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }
233 /***********************************************************************/
234 /** \name Internal types and structures */
237 #define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
238 #define DRM_MIN(a,b) min(a,b)
239 #define DRM_MAX(a,b) max(a,b)
241 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
242 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
243 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
245 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
247 * Get the private SAREA mapping.
249 * \param _dev DRM device.
250 * \param _ctx context number.
251 * \param _map output mapping.
253 #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
254 (_map) = (_dev)->context_sareas[_ctx]; \
258 * Test that the hardware lock is held by the caller, returning otherwise.
260 * \param dev DRM device.
261 * \param file_priv DRM file private pointer of the caller.
263 #define LOCK_TEST_WITH_RETURN( dev, file_priv ) \
265 if ( !_DRM_LOCK_IS_HELD( file_priv->master->lock.hw_lock->lock ) || \
266 file_priv->master->lock.file_priv != file_priv ) { \
267 DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\
268 __FUNCTION__, _DRM_LOCK_IS_HELD( file_priv->master->lock.hw_lock->lock ),\
269 file_priv->master->lock.file_priv, file_priv ); \
275 * Copy and IOCTL return string to user space
277 #define DRM_COPY( name, value ) \
278 len = strlen( value ); \
279 if ( len > name##_len ) len = name##_len; \
280 name##_len = strlen( value ); \
281 if ( len && name ) { \
282 if ( copy_to_user( name, value, len ) ) \
287 * Ioctl function type.
289 * \param dev DRM device structure
290 * \param data pointer to kernel-space stored data, copied in and out according
291 * to ioctl description.
292 * \param file_priv DRM file private pointer.
294 typedef int drm_ioctl_t(struct drm_device *dev, void *data,
295 struct drm_file *file_priv);
297 typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
301 #define DRM_MASTER 0x2
302 #define DRM_ROOT_ONLY 0x4
303 #define DRM_CONTROL_ALLOW 0x8 // allow ioctl to operate on control node
305 struct drm_ioctl_desc {
311 * Creates a driver or general drm_ioctl_desc array entry for the given
312 * ioctl, for use by drm_ioctl().
314 #define DRM_IOCTL_DEF(ioctl, func, flags) \
315 [DRM_IOCTL_NR(ioctl)] = {ioctl, func, flags}
317 struct drm_magic_entry {
318 struct list_head head;
319 struct drm_hash_item hash_item;
320 struct drm_file *priv;
323 struct drm_vma_entry {
324 struct list_head head;
325 struct vm_area_struct *vma;
333 int idx; /**< Index into master buflist */
334 int total; /**< Buffer size */
335 int order; /**< log-base-2(total) */
336 int used; /**< Amount of buffer in use (for DMA) */
337 unsigned long offset; /**< Byte offset (used internally) */
338 void *address; /**< Address of buffer */
339 unsigned long bus_address; /**< Bus address of buffer */
340 struct drm_buf *next; /**< Kernel-only: used for free list */
341 __volatile__ int waiting; /**< On kernel DMA queue */
342 __volatile__ int pending; /**< On hardware DMA queue */
343 wait_queue_head_t dma_wait; /**< Processes waiting */
344 struct drm_file *file_priv; /**< Private of holding file descr */
345 int context; /**< Kernel queue for this buffer */
346 int while_locked; /**< Dispatch this buffer while locked */
354 } list; /**< Which list we're on */
356 int dev_priv_size; /**< Size of buffer private storage */
357 void *dev_private; /**< Per-buffer private storage */
360 /** bufs is one longer than it has to be */
361 struct drm_waitlist {
362 int count; /**< Number of possible buffers */
363 struct drm_buf **bufs; /**< List of pointers to buffers */
364 struct drm_buf **rp; /**< Read pointer */
365 struct drm_buf **wp; /**< Write pointer */
366 struct drm_buf **end; /**< End pointer */
367 spinlock_t read_lock;
368 spinlock_t write_lock;
371 struct drm_freelist {
372 int initialized; /**< Freelist in use */
373 atomic_t count; /**< Number of free buffers */
374 struct drm_buf *next; /**< End pointer */
376 wait_queue_head_t waiting; /**< Processes waiting on free bufs */
377 int low_mark; /**< Low water mark */
378 int high_mark; /**< High water mark */
379 atomic_t wfh; /**< If waiting for high mark */
383 typedef struct drm_dma_handle {
390 * Buffer entry. There is one of this for each buffer size order.
392 struct drm_buf_entry {
393 int buf_size; /**< size */
394 int buf_count; /**< number of buffers */
395 struct drm_buf *buflist; /**< buffer list */
398 struct drm_dma_handle **seglist;
399 struct drm_freelist freelist;
410 /** File private data */
416 unsigned long ioctl_count;
417 struct list_head lhead;
418 struct drm_minor *minor;
419 unsigned long lock_count;
422 * The user object hash table is global and resides in the
423 * drm_device structure. We protect the lists and hash tables with the
424 * device struct_mutex. A bit coarse-grained but probably the best
428 struct list_head refd_objects;
430 struct drm_open_hash refd_object_hash[_DRM_NO_REF_TYPES];
434 int is_master; /* this file private is a master for a minor */
435 struct drm_master *master; /* master this node is currently associated with
436 N.B. not always minor->master */
437 struct list_head fbs;
442 atomic_t use_count; /**< Outstanding uses (+1) */
443 atomic_t finalization; /**< Finalization in progress */
444 atomic_t block_count; /**< Count of processes waiting */
445 atomic_t block_read; /**< Queue blocked for reads */
446 wait_queue_head_t read_queue; /**< Processes waiting on block_read */
447 atomic_t block_write; /**< Queue blocked for writes */
448 wait_queue_head_t write_queue; /**< Processes waiting on block_write */
450 atomic_t total_queued; /**< Total queued statistic */
451 atomic_t total_flushed; /**< Total flushes statistic */
452 atomic_t total_locks; /**< Total locks statistics */
454 enum drm_ctx_flags flags; /**< Context preserving and 2D-only */
455 struct drm_waitlist waitlist; /**< Pending buffers */
456 wait_queue_head_t flush_queue; /**< Processes waiting until flush */
462 struct drm_lock_data {
463 struct drm_hw_lock *hw_lock; /**< Hardware lock */
464 /** Private of lock holder's file (NULL=kernel) */
465 struct drm_file *file_priv;
466 wait_queue_head_t lock_queue; /**< Queue of blocked processes */
467 unsigned long lock_time; /**< Time of last lock in jiffies */
469 uint32_t kernel_waiters;
470 uint32_t user_waiters;
477 struct drm_device_dma {
479 struct drm_buf_entry bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */
480 int buf_count; /**< total number of buffers */
481 struct drm_buf **buflist; /**< Vector of pointers into drm_device_dma::bufs */
483 int page_count; /**< number of pages */
484 unsigned long *pagelist; /**< page list */
485 unsigned long byte_count;
487 _DRM_DMA_USE_AGP = 0x01,
488 _DRM_DMA_USE_SG = 0x02,
489 _DRM_DMA_USE_FB = 0x04,
490 _DRM_DMA_USE_PCI_RO = 0x08
496 * AGP memory entry. Stored as a doubly linked list.
499 unsigned long handle; /**< handle */
501 unsigned long bound; /**< address */
503 struct list_head head;
509 * \sa drm_agp_init() and drm_device::agp.
511 struct drm_agp_head {
512 DRM_AGP_KERN agp_info; /**< AGP device information */
513 struct list_head memory;
514 unsigned long mode; /**< AGP mode */
515 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,11)
516 struct agp_bridge_data *bridge;
518 int enabled; /**< whether the AGP bus as been enabled */
519 int acquired; /**< whether the AGP device has been acquired */
522 int cant_use_aperture;
523 unsigned long page_mask;
527 * Scatter-gather memory.
530 unsigned long handle;
533 struct page **pagelist;
539 struct drm_hw_lock *lock;
544 * Generic memory manager structs
548 struct list_head fl_entry;
549 struct list_head ml_entry;
558 struct list_head fl_entry;
559 struct list_head ml_entry;
566 struct drm_map_list {
567 struct list_head head; /**< list head */
568 struct drm_hash_item hash;
569 struct drm_map *map; /**< mapping */
571 struct drm_mm_node *file_offset_node;
572 struct drm_master *master; /** if this map is associated with a specific
576 typedef struct drm_map drm_local_map_t;
579 * Context handle list
581 struct drm_ctx_list {
582 struct list_head head; /**< list head */
583 drm_context_t handle; /**< context handle */
584 struct drm_file *tag; /**< associated fd private data */
588 struct list_head head;
589 unsigned int sequence;
591 struct task_struct *task;
594 struct drm_hotplug_sig {
595 struct list_head head;
596 unsigned int counter;
598 struct task_struct *task;
601 /* location of GART table */
602 #define DRM_ATI_GART_MAIN 1
603 #define DRM_ATI_GART_FB 2
605 #define DRM_ATI_GART_PCI 1
606 #define DRM_ATI_GART_PCIE 2
607 #define DRM_ATI_GART_IGP 3
609 struct drm_ati_pcigart_info {
610 int gart_table_location;
614 dma_addr_t table_mask;
615 dma_addr_t member_mask;
616 struct drm_dma_handle *table_handle;
617 drm_local_map_t mapping;
621 #include "drm_objects.h"
622 #include "drm_crtc.h"
624 /* per-master structure */
627 struct list_head head; /**< each minor contains a list of masters */
628 struct drm_minor *minor; /**< link back to minor we are a master for */
630 char *unique; /**< Unique identifier: e.g., busid */
631 int unique_len; /**< Length of unique field */
633 int blocked; /**< Blocked due to VC switch? */
635 /** \name Authentication */
637 struct drm_open_hash magiclist;
638 struct list_head magicfree;
641 struct drm_lock_data lock; /**< Information on hardware lock */
643 void *driver_priv; /**< Private structure for driver to use */
647 * DRM driver structure. This structure represent the common code for
648 * a family of cards. There will one drm_device for each card present
653 int (*load) (struct drm_device *, unsigned long flags);
654 int (*firstopen) (struct drm_device *);
655 int (*open) (struct drm_device *, struct drm_file *);
656 void (*preclose) (struct drm_device *, struct drm_file *file_priv);
657 void (*postclose) (struct drm_device *, struct drm_file *);
658 void (*lastclose) (struct drm_device *);
659 int (*unload) (struct drm_device *);
660 int (*suspend) (struct drm_device *, pm_message_t state);
661 int (*resume) (struct drm_device *);
662 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
663 void (*dma_ready) (struct drm_device *);
664 int (*dma_quiescent) (struct drm_device *);
665 int (*context_ctor) (struct drm_device *dev, int context);
666 int (*context_dtor) (struct drm_device *dev, int context);
667 int (*kernel_context_switch) (struct drm_device *dev, int old,
669 void (*kernel_context_switch_unlock) (struct drm_device * dev);
671 * get_vblank_counter - get raw hardware vblank counter
673 * @crtc: counter to fetch
675 * Driver callback for fetching a raw hardware vblank counter
676 * for @crtc. If a device doesn't have a hardware counter, the
677 * driver can simply return the value of drm_vblank_count and
678 * make the enable_vblank() and disable_vblank() hooks into no-ops,
679 * leaving interrupts enabled at all times.
681 * Wraparound handling and loss of events due to modesetting is dealt
682 * with in the DRM core code.
685 * Raw vblank counter value.
687 u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);
690 * enable_vblank - enable vblank interrupt events
692 * @crtc: which irq to enable
694 * Enable vblank interrupts for @crtc. If the device doesn't have
695 * a hardware vblank counter, this routine should be a no-op, since
696 * interrupts will have to stay on to keep the count accurate.
699 * Zero on success, appropriate errno if the given @crtc's vblank
700 * interrupt cannot be enabled.
702 int (*enable_vblank) (struct drm_device *dev, int crtc);
705 * disable_vblank - disable vblank interrupt events
707 * @crtc: which irq to enable
709 * Disable vblank interrupts for @crtc. If the device doesn't have
710 * a hardware vblank counter, this routine should be a no-op, since
711 * interrupts will have to stay on to keep the count accurate.
713 void (*disable_vblank) (struct drm_device *dev, int crtc);
714 int (*dri_library_name) (struct drm_device *dev, char * buf);
717 * Called by \c drm_device_is_agp. Typically used to determine if a
718 * card is really attached to AGP or not.
720 * \param dev DRM device handle
723 * One of three values is returned depending on whether or not the
724 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
725 * (return of 1), or may or may not be AGP (return of 2).
727 int (*device_is_agp) (struct drm_device *dev);
729 /* these have to be filled in */
730 irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
731 void (*irq_preinstall) (struct drm_device *dev);
732 int (*irq_postinstall) (struct drm_device *dev);
733 void (*irq_uninstall) (struct drm_device *dev);
734 void (*reclaim_buffers) (struct drm_device *dev,
735 struct drm_file *file_priv);
736 void (*reclaim_buffers_locked) (struct drm_device *dev,
737 struct drm_file *file_priv);
738 void (*reclaim_buffers_idlelocked) (struct drm_device *dev,
739 struct drm_file *file_priv);
740 unsigned long (*get_map_ofs) (struct drm_map *map);
741 unsigned long (*get_reg_ofs) (struct drm_device *dev);
742 void (*set_version) (struct drm_device *dev,
743 struct drm_set_version *sv);
745 /* FB routines, if present */
746 int (*fb_probe)(struct drm_device *dev, struct drm_crtc *crtc, struct drm_connector *connector);
747 int (*fb_remove)(struct drm_device *dev, struct drm_framebuffer *fb);
748 int (*fb_resize)(struct drm_device *dev, struct drm_crtc *crtc);
750 /* Master routines */
751 int (*master_create)(struct drm_device *dev, struct drm_master *master);
752 void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
754 struct drm_fence_driver *fence_driver;
755 struct drm_bo_driver *bo_driver;
767 struct drm_ioctl_desc *ioctls;
769 struct file_operations fops;
770 struct pci_driver pci_driver;
773 #define DRM_MINOR_UNASSIGNED 0
774 #define DRM_MINOR_LEGACY 1
775 #define DRM_MINOR_CONTROL 2
776 #define DRM_MINOR_RENDER 3
779 * DRM minor structure. This structure represents a drm minor number.
782 int index; /**< Minor device number */
783 int type; /**< Control or render */
784 dev_t device; /**< Device number for mknod */
785 struct device kdev; /**< Linux device */
786 struct drm_device *dev;
787 /* for render nodes */
788 struct proc_dir_entry *dev_root; /**< proc directory entry */
789 struct class_device *dev_class;
791 /* for control nodes - a pointer to the current master for this control node */
792 struct drm_master *master; /* currently active master for this node */
793 struct list_head master_list;
795 struct drm_mode_group mode_group;
800 * DRM device structure. This structure represent a complete card that
801 * may contain multiple heads.
804 char *devname; /**< For /proc/interrupts */
805 int if_version; /**< Highest interface version set */
809 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
810 struct mutex struct_mutex; /**< For others */
813 /** \name Usage Counters */
815 int open_count; /**< Outstanding files open */
816 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
817 atomic_t vma_count; /**< Outstanding vma areas open */
818 int buf_use; /**< Buffers in use -- cannot alloc */
819 atomic_t buf_alloc; /**< Buffer allocation in progress */
822 /** \name Performance counters */
824 unsigned long counters;
825 enum drm_stat_type types[15];
830 /** \name Memory management */
832 struct list_head maplist; /**< Linked list of regions */
833 int map_count; /**< Number of mappable regions */
834 struct drm_open_hash map_hash; /**< User token hash table for maps */
835 struct drm_mm offset_manager; /**< User token manager */
836 struct drm_open_hash object_hash; /**< User token hash table for objects */
837 struct address_space *dev_mapping; /**< For unmap_mapping_range() */
838 struct page *ttm_dummy_page;
840 /** \name Context handle management */
842 struct list_head ctxlist; /**< Linked list of context handles */
843 int ctx_count; /**< Number of context handles */
844 struct mutex ctxlist_mutex; /**< For ctxlist */
848 struct list_head vmalist; /**< List of vmas (for debugging) */
850 struct list_head filelist;
854 /** \name DMA queues (contexts) */
856 int queue_count; /**< Number of active DMA queues */
857 int queue_reserved; /**< Number of reserved DMA queues */
858 int queue_slots; /**< Actual length of queuelist */
859 struct drm_queue **queuelist; /**< Vector of pointers to DMA queues */
860 struct drm_device_dma *dma; /**< Optional pointer for DMA support */
864 /** \name Context support */
866 int irq; /**< Interrupt used by board */
867 int irq_enabled; /**< True if irq handler is enabled */
868 __volatile__ long context_flag; /**< Context swapping flag */
869 __volatile__ long interrupt_flag; /**< Interruption handler flag */
870 __volatile__ long dma_flag; /**< DMA dispatch flag */
871 struct timer_list timer; /**< Timer for delaying ctx switch */
872 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
873 int last_checked; /**< Last context checked for DMA */
874 int last_context; /**< Last current context */
875 unsigned long last_switch; /**< jiffies at last context switch */
878 struct work_struct work;
880 /** \name HOTPLUG IRQ support */
882 wait_queue_head_t hotplug_queue; /**< HOTPLUG wait queue */
883 spinlock_t hotplug_lock;
884 struct list_head *hotplug_sigs; /**< signal list to send on HOTPLUG */
885 atomic_t hotplug_signal_pending; /* number of signals pending on all crtcs*/
889 /** \name VBLANK IRQ support */
892 wait_queue_head_t *vbl_queue; /**< VBLANK wait queue */
893 atomic_t *_vblank_count; /**< number of VBLANK interrupts (driver must alloc the right number of counters) */
895 struct list_head *vbl_sigs; /**< signal list to send on VBLANK */
896 atomic_t vbl_signal_pending; /* number of signals pending on all crtcs*/
897 atomic_t *vblank_refcount; /* number of users of vblank interrupts per crtc */
898 u32 *last_vblank; /* protected by dev->vbl_lock, used */
899 /* for wraparound handling */
900 u32 *vblank_offset; /* used to track how many vblanks */
901 int *vblank_enabled; /* so we don't call enable more than
903 u32 *vblank_premodeset; /* were lost during modeset */
904 struct timer_list vblank_disable_timer;
906 unsigned long max_vblank_count; /**< size of vblank counter register */
907 spinlock_t tasklet_lock; /**< For drm_locked_tasklet */
908 void (*locked_tasklet_func)(struct drm_device *dev);
914 struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
915 wait_queue_head_t buf_readers; /**< Processes waiting to read */
916 wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
918 struct drm_agp_head *agp; /**< AGP data */
920 struct pci_dev *pdev; /**< PCI device structure */
921 int pci_vendor; /**< PCI vendor id */
922 int pci_device; /**< PCI device id */
924 struct pci_controller *hose;
926 int num_crtcs; /**< Number of CRTCs on this device */
927 struct drm_sg_mem *sg; /**< Scatter gather memory */
928 void *dev_private; /**< device private data */
929 struct drm_sigdata sigdata; /**< For block_all_signals */
932 struct drm_driver *driver;
933 drm_local_map_t *agp_buffer_map;
934 unsigned int agp_buffer_token;
936 /* minor number for control node */
937 struct drm_minor *control;
938 struct drm_minor *primary; /**< render type primary screen head */
940 struct drm_fence_manager fm;
941 struct drm_buffer_manager bm;
943 /** \name Drawable information */
949 /* DRM mode setting */
950 struct drm_mode_config mode_config;
954 struct drm_agp_ttm_backend {
955 struct drm_ttm_backend backend;
957 struct agp_bridge_data *bridge;
962 typedef struct ati_pcigart_ttm_backend {
963 struct drm_ttm_backend backend;
965 void (*gart_flush_fn)(struct drm_device *dev);
966 struct drm_ati_pcigart_info *gart_info;
967 unsigned long offset;
971 struct drm_device *dev;
972 } ati_pcigart_ttm_backend_t;
974 static __inline__ int drm_core_check_feature(struct drm_device *dev,
977 return ((dev->driver->driver_features & feature) ? 1 : 0);
981 #define drm_get_pci_domain(dev) dev->hose->index
983 #define drm_get_pci_domain(dev) 0
987 static inline int drm_core_has_AGP(struct drm_device *dev)
989 return drm_core_check_feature(dev, DRIVER_USE_AGP);
992 #define drm_core_has_AGP(dev) (0)
996 static inline int drm_core_has_MTRR(struct drm_device *dev)
998 return drm_core_check_feature(dev, DRIVER_USE_MTRR);
1001 #define DRM_MTRR_WC MTRR_TYPE_WRCOMB
1003 static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
1006 return mtrr_add(offset, size, flags, 1);
1009 static inline int drm_mtrr_del(int handle, unsigned long offset,
1010 unsigned long size, unsigned int flags)
1012 return mtrr_del(handle, offset, size);
1016 static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
1022 static inline int drm_mtrr_del(int handle, unsigned long offset,
1023 unsigned long size, unsigned int flags)
1028 #define drm_core_has_MTRR(dev) (0)
1029 #define DRM_MTRR_WC 0
1033 /******************************************************************/
1034 /** \name Internal function definitions */
1037 /* Driver support (drm_drv.h) */
1038 extern int drm_fb_loaded;
1039 extern int drm_init(struct drm_driver *driver,
1040 struct pci_device_id *pciidlist);
1041 extern void drm_exit(struct drm_driver *driver);
1042 extern void drm_cleanup_pci(struct pci_dev *pdev);
1043 extern int drm_ioctl(struct inode *inode, struct file *filp,
1044 unsigned int cmd, unsigned long arg);
1045 extern long drm_unlocked_ioctl(struct file *filp,
1046 unsigned int cmd, unsigned long arg);
1047 extern long drm_compat_ioctl(struct file *filp,
1048 unsigned int cmd, unsigned long arg);
1050 extern int drm_lastclose(struct drm_device *dev);
1052 /* Device support (drm_fops.h) */
1053 extern int drm_open(struct inode *inode, struct file *filp);
1054 extern int drm_stub_open(struct inode *inode, struct file *filp);
1055 extern int drm_fasync(int fd, struct file *filp, int on);
1056 extern int drm_release(struct inode *inode, struct file *filp);
1057 unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
1059 /* Mapping support (drm_vm.h) */
1060 extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
1061 extern unsigned long drm_core_get_map_ofs(struct drm_map * map);
1062 extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev);
1063 extern pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma);
1065 /* Memory management support (drm_memory.h) */
1066 #include "drm_memory.h"
1067 extern void drm_mem_init(void);
1068 extern int drm_mem_info(char *buf, char **start, off_t offset,
1069 int request, int *eof, void *data);
1070 extern void *drm_calloc(size_t nmemb, size_t size, int area);
1071 extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
1072 extern unsigned long drm_alloc_pages(int order, int area);
1073 extern void drm_free_pages(unsigned long address, int order, int area);
1074 extern DRM_AGP_MEM *drm_alloc_agp(struct drm_device *dev, int pages, u32 type);
1075 extern int drm_free_agp(DRM_AGP_MEM * handle, int pages);
1076 extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
1077 extern int drm_unbind_agp(DRM_AGP_MEM * handle);
1079 extern void drm_free_memctl(size_t size);
1080 extern int drm_alloc_memctl(size_t size);
1081 extern void drm_query_memctl(uint64_t *cur_used,
1082 uint64_t *emer_used,
1083 uint64_t *low_threshold,
1084 uint64_t *high_threshold,
1085 uint64_t *emer_threshold);
1086 extern void drm_init_memctl(size_t low_threshold,
1087 size_t high_threshold,
1090 /* Misc. IOCTL support (drm_ioctl.h) */
1091 extern int drm_irq_by_busid(struct drm_device *dev, void *data,
1092 struct drm_file *file_priv);
1093 extern int drm_getunique(struct drm_device *dev, void *data,
1094 struct drm_file *file_priv);
1095 extern int drm_setunique(struct drm_device *dev, void *data,
1096 struct drm_file *file_priv);
1097 extern int drm_getmap(struct drm_device *dev, void *data,
1098 struct drm_file *file_priv);
1099 extern int drm_getclient(struct drm_device *dev, void *data,
1100 struct drm_file *file_priv);
1101 extern int drm_getstats(struct drm_device *dev, void *data,
1102 struct drm_file *file_priv);
1103 extern int drm_setversion(struct drm_device *dev, void *data,
1104 struct drm_file *file_priv);
1105 extern int drm_noop(struct drm_device *dev, void *data,
1106 struct drm_file *file_priv);
1108 /* Context IOCTL support (drm_context.h) */
1109 extern int drm_resctx(struct drm_device *dev, void *data,
1110 struct drm_file *file_priv);
1111 extern int drm_addctx(struct drm_device *dev, void *data,
1112 struct drm_file *file_priv);
1113 extern int drm_modctx(struct drm_device *dev, void *data,
1114 struct drm_file *file_priv);
1115 extern int drm_getctx(struct drm_device *dev, void *data,
1116 struct drm_file *file_priv);
1117 extern int drm_switchctx(struct drm_device *dev, void *data,
1118 struct drm_file *file_priv);
1119 extern int drm_newctx(struct drm_device *dev, void *data,
1120 struct drm_file *file_priv);
1121 extern int drm_rmctx(struct drm_device *dev, void *data,
1122 struct drm_file *file_priv);
1124 extern int drm_ctxbitmap_init(struct drm_device *dev);
1125 extern void drm_ctxbitmap_cleanup(struct drm_device *dev);
1126 extern void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
1128 extern int drm_setsareactx(struct drm_device *dev, void *data,
1129 struct drm_file *file_priv);
1130 extern int drm_getsareactx(struct drm_device *dev, void *data,
1131 struct drm_file *file_priv);
1133 /* Drawable IOCTL support (drm_drawable.h) */
1134 extern int drm_adddraw(struct drm_device *dev, void *data,
1135 struct drm_file *file_priv);
1136 extern int drm_rmdraw(struct drm_device *dev, void *data,
1137 struct drm_file *file_priv);
1138 extern int drm_update_drawable_info(struct drm_device *dev, void *data,
1139 struct drm_file *file_priv);
1140 extern struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev,
1142 extern void drm_drawable_free_all(struct drm_device *dev);
1144 /* Authentication IOCTL support (drm_auth.h) */
1145 extern int drm_getmagic(struct drm_device *dev, void *data,
1146 struct drm_file *file_priv);
1147 extern int drm_authmagic(struct drm_device *dev, void *data,
1148 struct drm_file *file_priv);
1150 /* Locking IOCTL support (drm_lock.h) */
1151 extern int drm_lock(struct drm_device *dev, void *data,
1152 struct drm_file *file_priv);
1153 extern int drm_unlock(struct drm_device *dev, void *data,
1154 struct drm_file *file_priv);
1155 extern int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context);
1156 extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
1157 extern void drm_idlelock_take(struct drm_lock_data *lock_data);
1158 extern void drm_idlelock_release(struct drm_lock_data *lock_data);
1161 * These are exported to drivers so that they can implement fencing using
1162 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
1165 extern int drm_i_have_hw_lock(struct drm_device *dev,
1166 struct drm_file *file_priv);
1168 /* Buffer management support (drm_bufs.h) */
1169 extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
1170 extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request);
1171 extern int drm_addbufs_fb (struct drm_device *dev, struct drm_buf_desc * request);
1172 extern int drm_addmap(struct drm_device *dev, unsigned int offset,
1173 unsigned int size, enum drm_map_type type,
1174 enum drm_map_flags flags, drm_local_map_t ** map_ptr);
1175 extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
1176 struct drm_file *file_priv);
1177 extern int drm_rmmap(struct drm_device *dev, drm_local_map_t *map);
1178 extern int drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map);
1179 extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
1180 struct drm_file *file_priv);
1181 extern int drm_addbufs(struct drm_device *dev, void *data,
1182 struct drm_file *file_priv);
1183 extern int drm_infobufs(struct drm_device *dev, void *data,
1184 struct drm_file *file_priv);
1185 extern int drm_markbufs(struct drm_device *dev, void *data,
1186 struct drm_file *file_priv);
1187 extern int drm_freebufs(struct drm_device *dev, void *data,
1188 struct drm_file *file_priv);
1189 extern int drm_mapbufs(struct drm_device *dev, void *data,
1190 struct drm_file *file_priv);
1191 extern int drm_order(unsigned long size);
1192 extern unsigned long drm_get_resource_start(struct drm_device *dev,
1193 unsigned int resource);
1194 extern unsigned long drm_get_resource_len(struct drm_device *dev,
1195 unsigned int resource);
1196 extern struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
1197 drm_local_map_t *map);
1200 /* DMA support (drm_dma.h) */
1201 extern int drm_dma_setup(struct drm_device *dev);
1202 extern void drm_dma_takedown(struct drm_device *dev);
1203 extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
1204 extern void drm_core_reclaim_buffers(struct drm_device *dev,
1205 struct drm_file *filp);
1207 /* IRQ support (drm_irq.h) */
1208 extern int drm_control(struct drm_device *dev, void *data,
1209 struct drm_file *file_priv);
1210 extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
1211 extern int drm_irq_install(struct drm_device *dev);
1212 extern int drm_irq_uninstall(struct drm_device *dev);
1213 extern void drm_driver_irq_preinstall(struct drm_device *dev);
1214 extern void drm_driver_irq_postinstall(struct drm_device *dev);
1215 extern void drm_driver_irq_uninstall(struct drm_device *dev);
1217 extern int drm_hotplug_init(struct drm_device *dev);
1218 extern int drm_wait_hotplug(struct drm_device *dev, void *data, struct drm_file *filp);
1219 extern int drm_vblank_init(struct drm_device *dev, int num_crtcs);
1220 extern int drm_wait_vblank(struct drm_device *dev, void *data, struct drm_file *filp);
1221 extern int drm_wait_hotplug(struct drm_device *dev, void *data, struct drm_file *filp);
1222 extern int drm_vblank_wait(struct drm_device * dev, unsigned int *vbl_seq);
1223 extern void drm_locked_tasklet(struct drm_device *dev, void(*func)(struct drm_device*));
1224 extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
1225 extern void drm_update_vblank_count(struct drm_device *dev, int crtc);
1226 extern void drm_handle_vblank(struct drm_device *dev, int crtc);
1227 extern void drm_handle_hotplug(struct drm_device *dev);
1228 extern int drm_vblank_get(struct drm_device *dev, int crtc);
1229 extern void drm_vblank_put(struct drm_device *dev, int crtc);
1231 /* Modesetting support */
1232 extern int drm_modeset_ctl(struct drm_device *dev, void *data,
1233 struct drm_file *file_priv);
1235 /* AGP/GART support (drm_agpsupport.h) */
1236 extern struct drm_agp_head *drm_agp_init(struct drm_device *dev);
1237 extern int drm_agp_acquire(struct drm_device *dev);
1238 extern int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
1239 struct drm_file *file_priv);
1240 extern int drm_agp_release(struct drm_device *dev);
1241 extern int drm_agp_release_ioctl(struct drm_device *dev, void *data,
1242 struct drm_file *file_priv);
1243 extern int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
1244 extern int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
1245 struct drm_file *file_priv);
1246 extern int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info);
1247 extern int drm_agp_info_ioctl(struct drm_device *dev, void *data,
1248 struct drm_file *file_priv);
1249 extern int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
1250 extern int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
1251 struct drm_file *file_priv);
1252 extern int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
1253 extern int drm_agp_free_ioctl(struct drm_device *dev, void *data,
1254 struct drm_file *file_priv);
1255 extern int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
1256 extern int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
1257 struct drm_file *file_priv);
1258 extern int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
1259 extern int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
1260 struct drm_file *file_priv);
1261 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11)
1262 extern DRM_AGP_MEM *drm_agp_allocate_memory(size_t pages, u32 type);
1264 extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size_t pages, u32 type);
1266 extern int drm_agp_free_memory(DRM_AGP_MEM * handle);
1267 extern int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start);
1268 extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
1269 extern struct drm_ttm_backend *drm_agp_init_ttm(struct drm_device *dev);
1270 extern void drm_agp_chipset_flush(struct drm_device *dev);
1271 /* Stub support (drm_stub.h) */
1272 extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
1273 struct drm_file *file_priv);
1274 extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1275 struct drm_file *file_priv);
1276 extern struct drm_master *drm_get_master(struct drm_minor *minor);
1277 extern void drm_put_master(struct drm_master *master);
1278 extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
1279 struct drm_driver *driver);
1280 extern int drm_put_dev(struct drm_device *dev);
1281 extern int drm_put_minor(struct drm_minor **minor);
1282 extern unsigned int drm_debug; /* 1 to enable debug output */
1284 extern struct class *drm_class;
1285 extern struct proc_dir_entry *drm_proc_root;
1287 extern struct idr drm_minors_idr;
1289 extern drm_local_map_t *drm_getsarea(struct drm_device *dev);
1291 /* Proc support (drm_proc.h) */
1292 int drm_proc_init(struct drm_minor *minor, int minor_id,
1293 struct proc_dir_entry *root);
1294 int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root);
1296 /* Scatter Gather Support (drm_scatter.h) */
1297 extern void drm_sg_cleanup(struct drm_sg_mem * entry);
1298 extern int drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
1299 struct drm_file *file_priv);
1300 extern int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request);
1301 extern int drm_sg_free(struct drm_device *dev, void *data,
1302 struct drm_file *file_priv);
1304 /* ATI PCIGART support (ati_pcigart.h) */
1305 extern int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info);
1306 extern int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info);
1308 extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
1309 size_t align, dma_addr_t maxaddr);
1310 extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah);
1311 extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah);
1313 /* sysfs support (drm_sysfs.c) */
1314 struct drm_sysfs_class;
1315 extern struct class *drm_sysfs_create(struct module *owner, char *name);
1316 extern void drm_sysfs_destroy(void);
1317 extern int drm_sysfs_device_add(struct drm_minor *minor);
1318 extern void drm_sysfs_hotplug_event(struct drm_device *dev);
1319 extern void drm_sysfs_device_remove(struct drm_minor *minor);
1320 extern char *drm_get_connector_status_name(enum drm_connector_status status);
1321 extern int drm_sysfs_connector_add(struct drm_connector *connector);
1322 extern void drm_sysfs_connector_remove(struct drm_connector *connector);
1325 * Basic memory manager support (drm_mm.c)
1328 extern struct drm_mm_node * drm_mm_get_block(struct drm_mm_node * parent, unsigned long size,
1329 unsigned alignment);
1330 extern void drm_mm_put_block(struct drm_mm_node *cur);
1331 extern struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm, unsigned long size,
1332 unsigned alignment, int best_match);
1333 extern int drm_mm_init(struct drm_mm *mm, unsigned long start, unsigned long size);
1334 extern void drm_mm_takedown(struct drm_mm *mm);
1335 extern int drm_mm_clean(struct drm_mm *mm);
1336 extern unsigned long drm_mm_tail_space(struct drm_mm *mm);
1337 extern int drm_mm_remove_space_from_tail(struct drm_mm *mm, unsigned long size);
1338 extern int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size);
1339 extern void drm_mm_print(struct drm_mm *mm, const char *name);
1341 static inline struct drm_mm *drm_get_mm(struct drm_mm_node *block)
1346 extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev);
1347 extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev);
1349 static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev,
1352 struct drm_map_list *_entry;
1353 list_for_each_entry(_entry, &dev->maplist, head)
1354 if (_entry->user_token == token)
1359 static __inline__ int drm_device_is_agp(struct drm_device *dev)
1361 if ( dev->driver->device_is_agp != NULL ) {
1362 int err = (*dev->driver->device_is_agp)(dev);
1369 return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
1372 static __inline__ int drm_device_is_pcie(struct drm_device *dev)
1374 return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
1377 static __inline__ void drm_core_dropmap(struct drm_map *map)
1381 #ifndef DEBUG_MEMORY
1382 /** Wrapper around kmalloc() */
1383 static __inline__ void *drm_alloc(size_t size, int area)
1385 return kmalloc(size, GFP_KERNEL);
1388 /** Wrapper around kfree() */
1389 static __inline__ void drm_free(void *pt, size_t size, int area)
1394 extern void *drm_alloc(size_t size, int area);
1395 extern void drm_free(void *pt, size_t size, int area);
1399 * Accounting variants of standard calls.
1402 static inline void *drm_ctl_alloc(size_t size, int area)
1405 if (drm_alloc_memctl(size))
1407 ret = drm_alloc(size, area);
1409 drm_free_memctl(size);
1413 static inline void *drm_ctl_calloc(size_t nmemb, size_t size, int area)
1417 if (drm_alloc_memctl(nmemb*size))
1419 ret = drm_calloc(nmemb, size, area);
1421 drm_free_memctl(nmemb*size);
1425 static inline void drm_ctl_free(void *pt, size_t size, int area)
1427 drm_free(pt, size, area);
1428 drm_free_memctl(size);
1433 #endif /* __KERNEL__ */