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.
40 /* add include of current.h so that "current" is defined
41 * before static inline funcs in wait.h. Doing this so we
42 * can build the DRM (part of PI DRI). 4/21/2000 S + B */
43 #include <asm/current.h>
44 #endif /* __alpha__ */
45 #include <linux/config.h>
46 #include <linux/module.h>
47 #include <linux/kernel.h>
48 #include <linux/miscdevice.h>
50 #include <linux/proc_fs.h>
51 #include <linux/init.h>
52 #include <linux/file.h>
53 #include <linux/pci.h>
54 #include <linux/version.h>
55 #include <linux/jiffies.h>
56 #include <linux/smp_lock.h> /* For (un)lock_kernel */
58 #if defined(__alpha__) || defined(__powerpc__)
59 #include <asm/pgtable.h> /* For pte_wrprotect */
63 #include <asm/uaccess.h>
67 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
68 #include <linux/types.h>
69 #include <linux/agp_backend.h>
71 #include <linux/workqueue.h>
72 #include <linux/poll.h>
73 #include <asm/pgalloc.h>
76 #include "drm_os_linux.h"
79 /***********************************************************************/
80 /** \name DRM template customization defaults */
89 #ifndef __HAVE_CTX_BITMAP
90 #define __HAVE_CTX_BITMAP 0
98 #ifndef __HAVE_DMA_WAITLIST
99 #define __HAVE_DMA_WAITLIST 0
101 #ifndef __HAVE_DMA_FREELIST
102 #define __HAVE_DMA_FREELIST 0
105 #define __REALLY_HAVE_AGP (__HAVE_AGP && (defined(CONFIG_AGP) || \
106 defined(CONFIG_AGP_MODULE)))
107 #define __REALLY_HAVE_MTRR (__HAVE_MTRR && defined(CONFIG_MTRR))
108 #define __REALLY_HAVE_SG (__HAVE_SG)
113 /***********************************************************************/
114 /** \name Begin the DRM... */
117 #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then
118 also include looping detection. */
120 #define DRM_HASH_SIZE 16 /**< Size of key hash table. Must be power of 2. */
121 #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */
122 #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */
123 #define DRM_LOOPING_LIMIT 5000000
124 #define DRM_BSZ 1024 /**< Buffer size for /dev/drm? output */
125 #define DRM_TIME_SLICE (HZ/20) /**< Time slice for GLXContexts */
126 #define DRM_LOCK_SLICE 1 /**< Time slice for lock, in jiffies */
128 #define DRM_FLAG_DEBUG 0x01
130 #define DRM_MEM_DMA 0
131 #define DRM_MEM_SAREA 1
132 #define DRM_MEM_DRIVER 2
133 #define DRM_MEM_MAGIC 3
134 #define DRM_MEM_IOCTLS 4
135 #define DRM_MEM_MAPS 5
136 #define DRM_MEM_VMAS 6
137 #define DRM_MEM_BUFS 7
138 #define DRM_MEM_SEGS 8
139 #define DRM_MEM_PAGES 9
140 #define DRM_MEM_FILES 10
141 #define DRM_MEM_QUEUES 11
142 #define DRM_MEM_CMDS 12
143 #define DRM_MEM_MAPPINGS 13
144 #define DRM_MEM_BUFLISTS 14
145 #define DRM_MEM_AGPLISTS 15
146 #define DRM_MEM_TOTALAGP 16
147 #define DRM_MEM_BOUNDAGP 17
148 #define DRM_MEM_CTXBITMAP 18
149 #define DRM_MEM_STUB 19
150 #define DRM_MEM_SGLISTS 20
151 #define DRM_MEM_CTXLIST 21
153 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
158 /***********************************************************************/
159 /** \name Backward compatibility section */
162 #ifndef MODULE_LICENSE
163 #define MODULE_LICENSE(x)
166 #ifndef preempt_disable
167 #define preempt_disable()
168 #define preempt_enable()
171 #ifndef pte_offset_map
172 #define pte_offset_map pte_offset
173 #define pte_unmap(pte)
176 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19)
177 static inline struct page * vmalloc_to_page(void * vmalloc_addr)
179 unsigned long addr = (unsigned long) vmalloc_addr;
180 struct page *page = NULL;
181 pgd_t *pgd = pgd_offset_k(addr);
185 if (!pgd_none(*pgd)) {
186 pmd = pmd_offset(pgd, addr);
187 if (!pmd_none(*pmd)) {
189 ptep = pte_offset_map(pmd, addr);
191 if (pte_present(pte))
192 page = pte_page(pte);
201 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
202 #define DRM_RPR_ARG(vma)
204 #define DRM_RPR_ARG(vma) vma,
207 #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
212 /***********************************************************************/
213 /** \name Macros to make printk easier */
219 * \param fmt printf() like format string.
220 * \param arg arguments
222 #define DRM_ERROR(fmt, arg...) \
223 printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg)
226 * Memory error output.
228 * \param area memory area where the error occurred.
229 * \param fmt printf() like format string.
230 * \param arg arguments
232 #define DRM_MEM_ERROR(area, fmt, arg...) \
233 printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \
234 DRM(mem_stats)[area].name , ##arg)
235 #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
240 * \param fmt printf() like format string.
241 * \param arg arguments
244 #define DRM_DEBUG(fmt, arg...) \
246 if ( DRM(flags) & DRM_FLAG_DEBUG ) \
248 "[" DRM_NAME ":%s] " fmt , \
249 __FUNCTION__ , ##arg); \
252 #define DRM_DEBUG(fmt, arg...) do { } while (0)
255 #define DRM_PROC_LIMIT (PAGE_SIZE-80)
257 #define DRM_PROC_PRINT(fmt, arg...) \
258 len += sprintf(&buf[len], fmt , ##arg); \
259 if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; }
261 #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
262 len += sprintf(&buf[len], fmt , ##arg); \
263 if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }
268 /***********************************************************************/
269 /** \name Mapping helper macros */
272 #define DRM_IOREMAP(map, dev) \
273 (map)->handle = DRM(ioremap)( (map)->offset, (map)->size, (dev) )
275 #define DRM_IOREMAP_NOCACHE(map, dev) \
276 (map)->handle = DRM(ioremap_nocache)((map)->offset, (map)->size, (dev))
278 #define DRM_IOREMAPFREE(map, dev) \
280 if ( (map)->handle && (map)->size ) \
281 DRM(ioremapfree)( (map)->handle, (map)->size, (dev) ); \
287 * \param _map matching mapping if found, untouched otherwise.
290 * Expects the existence of a local variable named \p dev pointing to the
291 * drm_device structure.
293 #define DRM_FIND_MAP(_map, _o) \
295 struct list_head *_list; \
296 list_for_each( _list, &dev->maplist->head ) { \
297 drm_map_list_t *_entry = list_entry( _list, drm_map_list_t, head ); \
298 if ( _entry->map && \
299 _entry->map->offset == (_o) ) { \
300 (_map) = _entry->map; \
311 #define DRM_DROP_MAP(_map)
316 /***********************************************************************/
317 /** \name Internal types and structures */
320 #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
321 #define DRM_MIN(a,b) ((a)<(b)?(a):(b))
322 #define DRM_MAX(a,b) ((a)>(b)?(a):(b))
324 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
325 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
326 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
328 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
330 * Get the private SAREA mapping.
332 * \param _dev DRM device.
333 * \param _ctx context number.
334 * \param _map output mapping.
336 #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
337 (_map) = (_dev)->context_sareas[_ctx]; \
341 * Test that the hardware lock is held by the caller, returning otherwise.
343 * \param dev DRM device.
344 * \param filp file pointer of the caller.
346 #define LOCK_TEST_WITH_RETURN( dev, filp ) \
348 if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
349 dev->lock.filp != filp ) { \
350 DRM_ERROR( "%s called without lock held\n", \
357 * Ioctl function type.
359 * \param inode device inode.
360 * \param filp file pointer.
361 * \param cmd command.
362 * \param arg argument.
364 typedef int drm_ioctl_t( struct inode *inode, struct file *filp,
365 unsigned int cmd, unsigned long arg );
367 typedef struct drm_ioctl_desc {
373 typedef struct drm_devstate {
374 pid_t owner; /**< X server pid holding x_lock */
377 typedef struct drm_magic_entry {
379 struct drm_file *priv;
380 struct drm_magic_entry *next;
383 typedef struct drm_magic_head {
384 struct drm_magic_entry *head;
385 struct drm_magic_entry *tail;
388 typedef struct drm_vma_entry {
389 struct vm_area_struct *vma;
390 struct drm_vma_entry *next;
397 typedef struct drm_buf {
398 int idx; /**< Index into master buflist */
399 int total; /**< Buffer size */
400 int order; /**< log-base-2(total) */
401 int used; /**< Amount of buffer in use (for DMA) */
402 unsigned long offset; /**< Byte offset (used internally) */
403 void *address; /**< Address of buffer */
404 unsigned long bus_address; /**< Bus address of buffer */
405 struct drm_buf *next; /**< Kernel-only: used for free list */
406 __volatile__ int waiting; /**< On kernel DMA queue */
407 __volatile__ int pending; /**< On hardware DMA queue */
408 wait_queue_head_t dma_wait; /**< Processes waiting */
409 struct file *filp; /**< Pointer to holding file descr */
410 int context; /**< Kernel queue for this buffer */
411 int while_locked;/**< Dispatch this buffer while locked */
419 } list; /**< Which list we're on */
421 int dev_priv_size; /**< Size of buffer private storage */
422 void *dev_private; /**< Per-buffer private storage */
426 /** bufs is one longer than it has to be */
427 typedef struct drm_waitlist {
428 int count; /**< Number of possible buffers */
429 drm_buf_t **bufs; /**< List of pointers to buffers */
430 drm_buf_t **rp; /**< Read pointer */
431 drm_buf_t **wp; /**< Write pointer */
432 drm_buf_t **end; /**< End pointer */
433 spinlock_t read_lock;
434 spinlock_t write_lock;
437 typedef struct drm_freelist {
438 int initialized; /**< Freelist in use */
439 atomic_t count; /**< Number of free buffers */
440 drm_buf_t *next; /**< End pointer */
442 wait_queue_head_t waiting; /**< Processes waiting on free bufs */
443 int low_mark; /**< Low water mark */
444 int high_mark; /**< High water mark */
445 atomic_t wfh; /**< If waiting for high mark */
450 * Buffer entry. There is one of this for each buffer size order.
452 typedef struct drm_buf_entry {
453 int buf_size; /**< size */
454 int buf_count; /**< number of buffers */
455 drm_buf_t *buflist; /**< buffer list */
458 unsigned long *seglist;
460 drm_freelist_t freelist;
463 /** File private data */
464 typedef struct drm_file {
470 unsigned long ioctl_count;
471 struct drm_file *next;
472 struct drm_file *prev;
473 struct drm_device *dev;
474 int remove_auth_on_close;
475 unsigned long lock_count;
476 #ifdef DRIVER_FILE_FIELDS
482 typedef struct drm_queue {
483 atomic_t use_count; /**< Outstanding uses (+1) */
484 atomic_t finalization; /**< Finalization in progress */
485 atomic_t block_count; /**< Count of processes waiting */
486 atomic_t block_read; /**< Queue blocked for reads */
487 wait_queue_head_t read_queue; /**< Processes waiting on block_read */
488 atomic_t block_write; /**< Queue blocked for writes */
489 wait_queue_head_t write_queue; /**< Processes waiting on block_write */
491 atomic_t total_queued; /**< Total queued statistic */
492 atomic_t total_flushed;/**< Total flushes statistic */
493 atomic_t total_locks; /**< Total locks statistics */
495 drm_ctx_flags_t flags; /**< Context preserving and 2D-only */
496 drm_waitlist_t waitlist; /**< Pending buffers */
497 wait_queue_head_t flush_queue; /**< Processes waiting until flush */
503 typedef struct drm_lock_data {
504 drm_hw_lock_t *hw_lock; /**< Hardware lock */
505 struct file *filp; /**< File descr of lock holder (0=kernel) */
506 wait_queue_head_t lock_queue; /**< Queue of blocked processes */
507 unsigned long lock_time; /**< Time of last lock in jiffies */
513 typedef struct drm_device_dma {
515 drm_buf_entry_t bufs[DRM_MAX_ORDER+1]; /**< buffers, grouped by their size order */
516 int buf_count; /**< total number of buffers */
517 drm_buf_t **buflist; /**< Vector of pointers into drm_device_dma::bufs */
519 int page_count; /**< number of pages */
520 unsigned long *pagelist; /**< page list */
521 unsigned long byte_count;
523 _DRM_DMA_USE_AGP = 0x01,
524 _DRM_DMA_USE_SG = 0x02
527 /** \name DMA support */
529 drm_buf_t *this_buffer; /**< Buffer being sent */
530 drm_buf_t *next_buffer; /**< Selected buffer to send */
531 drm_queue_t *next_queue; /**< Queue from which buffer selected*/
532 wait_queue_head_t waiting; /**< Processes waiting on free bufs */
536 #if __REALLY_HAVE_AGP
538 * AGP memory entry. Stored as a doubly linked list.
540 typedef struct drm_agp_mem {
541 unsigned long handle; /**< handle */
543 unsigned long bound; /**< address */
545 struct drm_agp_mem *prev; /**< previous entry */
546 struct drm_agp_mem *next; /**< next entry */
552 * \sa DRM(agp_init)() and drm_device::agp.
554 typedef struct drm_agp_head {
555 DRM_AGP_KERN agp_info; /**< AGP device information */
556 drm_agp_mem_t *memory; /**< memory entries */
557 unsigned long mode; /**< AGP mode */
558 int enabled; /**< whether the AGP bus as been enabled */
559 int acquired; /**< whether the AGP device has been acquired */
562 int cant_use_aperture;
563 unsigned long page_mask;
568 * Scatter-gather memory.
570 typedef struct drm_sg_mem {
571 unsigned long handle;
574 struct page **pagelist;
578 typedef struct drm_sigdata {
586 typedef struct drm_map_list {
587 struct list_head head; /**< list head */
588 drm_map_t *map; /**< mapping */
591 typedef drm_map_t drm_local_map_t;
594 * Context handle list
596 typedef struct drm_ctx_list {
597 struct list_head head; /**< list head */
598 drm_context_t handle; /**< context handle */
599 drm_file_t *tag; /**< associated fd private data */
604 typedef struct drm_vbl_sig {
605 struct list_head head;
606 unsigned int sequence;
608 struct task_struct *task;
614 * DRM device structure.
616 typedef struct drm_device {
617 const char *name; /**< Simple driver name */
618 char *unique; /**< Unique identifier: e.g., busid */
619 int unique_len; /**< Length of unique field */
620 dev_t device; /**< Device number for mknod */
621 char *devname; /**< For /proc/interrupts */
622 int minor; /**< Minor device number */
623 int if_version; /**< Highest interface version set */
625 int blocked; /**< Blocked due to VC switch? */
626 struct proc_dir_entry *root; /**< Root for this device's entries */
630 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
631 struct semaphore struct_sem; /**< For others */
634 /** \name Usage Counters */
636 int open_count; /**< Outstanding files open */
637 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
638 atomic_t vma_count; /**< Outstanding vma areas open */
639 int buf_use; /**< Buffers in use -- cannot alloc */
640 atomic_t buf_alloc; /**< Buffer allocation in progress */
643 /** \name Performance counters */
645 unsigned long counters;
646 drm_stat_type_t types[15];
650 /** \name Authentication */
652 drm_file_t *file_first; /**< file list head */
653 drm_file_t *file_last; /**< file list tail */
654 drm_magic_head_t magiclist[DRM_HASH_SIZE]; /**< magic hash table */
657 /** \name Memory management */
659 drm_map_list_t *maplist; /**< Linked list of regions */
660 int map_count; /**< Number of mappable regions */
662 /** \name Context handle management */
664 drm_ctx_list_t *ctxlist; /**< Linked list of context handles */
665 int ctx_count; /**< Number of context handles */
666 struct semaphore ctxlist_sem; /**< For ctxlist */
668 drm_map_t **context_sareas; /**< per-context SAREA's */
671 drm_vma_entry_t *vmalist; /**< List of vmas (for debugging) */
672 drm_lock_data_t lock; /**< Information on hardware lock */
675 /** \name DMA queues (contexts) */
677 int queue_count; /**< Number of active DMA queues */
678 int queue_reserved; /**< Number of reserved DMA queues */
679 int queue_slots; /**< Actual length of queuelist */
680 drm_queue_t **queuelist; /**< Vector of pointers to DMA queues */
681 drm_device_dma_t *dma; /**< Optional pointer for DMA support */
684 /** \name Context support */
686 int irq; /**< Interrupt used by board */
687 int irq_enabled; /**< True if irq handler is enabled */
688 __volatile__ long context_flag; /**< Context swapping flag */
689 __volatile__ long interrupt_flag; /**< Interruption handler flag */
690 __volatile__ long dma_flag; /**< DMA dispatch flag */
691 struct timer_list timer; /**< Timer for delaying ctx switch */
692 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
693 int last_checked; /**< Last context checked for DMA */
694 int last_context; /**< Last current context */
695 unsigned long last_switch; /**< jiffies at last context switch */
698 struct work_struct work;
699 /** \name VBLANK IRQ support */
702 wait_queue_head_t vbl_queue; /**< VBLANK wait queue */
703 atomic_t vbl_received;
705 drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */
706 unsigned int vbl_pending;
712 char buf[DRM_BSZ]; /**< Output buffer */
713 char *buf_rp; /**< Read pointer */
714 char *buf_wp; /**< Write pointer */
715 char *buf_end; /**< End pointer */
716 struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
717 wait_queue_head_t buf_readers; /**< Processes waiting to read */
718 wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
720 #if __REALLY_HAVE_AGP
721 drm_agp_head_t *agp; /**< AGP data */
724 struct pci_dev *pdev; /**< PCI device structure */
725 int pci_domain; /**< PCI bus domain number */
726 int pci_bus; /**< PCI bus number */
727 int pci_slot; /**< PCI slot number */
728 int pci_func; /**< PCI function number */
730 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3)
731 struct pci_controler *hose;
733 struct pci_controller *hose;
736 drm_sg_mem_t *sg; /**< Scatter gather memory */
737 unsigned long *ctx_bitmap; /**< context bitmap */
738 void *dev_private; /**< device private data */
739 drm_sigdata_t sigdata; /**< For block_all_signals */
744 /******************************************************************/
745 /** \name Internal function definitions */
748 /* Misc. support (drm_init.h) */
749 extern int DRM(flags);
750 extern void DRM(parse_options)( char *s );
751 extern int DRM(cpu_valid)( void );
753 /* Driver support (drm_drv.h) */
754 extern int DRM(version)(struct inode *inode, struct file *filp,
755 unsigned int cmd, unsigned long arg);
756 extern int DRM(open)(struct inode *inode, struct file *filp);
757 extern int DRM(release)(struct inode *inode, struct file *filp);
758 extern int DRM(ioctl)(struct inode *inode, struct file *filp,
759 unsigned int cmd, unsigned long arg);
760 extern int DRM(lock)(struct inode *inode, struct file *filp,
761 unsigned int cmd, unsigned long arg);
762 extern int DRM(unlock)(struct inode *inode, struct file *filp,
763 unsigned int cmd, unsigned long arg);
765 /* Device support (drm_fops.h) */
766 extern int DRM(open_helper)(struct inode *inode, struct file *filp,
768 extern int DRM(flush)(struct file *filp);
769 extern int DRM(fasync)(int fd, struct file *filp, int on);
771 /* Mapping support (drm_vm.h) */
772 extern void DRM(vm_open)(struct vm_area_struct *vma);
773 extern void DRM(vm_close)(struct vm_area_struct *vma);
774 extern void DRM(vm_shm_close)(struct vm_area_struct *vma);
775 extern int DRM(mmap_dma)(struct file *filp,
776 struct vm_area_struct *vma);
777 extern int DRM(mmap)(struct file *filp, struct vm_area_struct *vma);
778 extern unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait);
779 extern ssize_t DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off);
781 /* Memory management support (drm_memory.h) */
782 extern void DRM(mem_init)(void);
783 extern int DRM(mem_info)(char *buf, char **start, off_t offset,
784 int request, int *eof, void *data);
785 extern void *DRM(alloc)(size_t size, int area);
786 extern void *DRM(calloc)(size_t nmemb, size_t size, int area);
787 extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
789 extern void DRM(free)(void *pt, size_t size, int area);
790 extern unsigned long DRM(alloc_pages)(int order, int area);
791 extern void DRM(free_pages)(unsigned long address, int order,
793 extern void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev);
794 extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size,
796 extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev);
798 #if __REALLY_HAVE_AGP
799 extern DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type);
800 extern int DRM(free_agp)(DRM_AGP_MEM *handle, int pages);
801 extern int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start);
802 extern int DRM(unbind_agp)(DRM_AGP_MEM *handle);
805 /* Misc. IOCTL support (drm_ioctl.h) */
806 extern int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
807 unsigned int cmd, unsigned long arg);
808 extern int DRM(getunique)(struct inode *inode, struct file *filp,
809 unsigned int cmd, unsigned long arg);
810 extern int DRM(setunique)(struct inode *inode, struct file *filp,
811 unsigned int cmd, unsigned long arg);
812 extern int DRM(getmap)(struct inode *inode, struct file *filp,
813 unsigned int cmd, unsigned long arg);
814 extern int DRM(getclient)(struct inode *inode, struct file *filp,
815 unsigned int cmd, unsigned long arg);
816 extern int DRM(getstats)(struct inode *inode, struct file *filp,
817 unsigned int cmd, unsigned long arg);
818 extern int DRM(setversion)(struct inode *inode, struct file *filp,
819 unsigned int cmd, unsigned long arg);
821 /* Context IOCTL support (drm_context.h) */
822 extern int DRM(resctx)( struct inode *inode, struct file *filp,
823 unsigned int cmd, unsigned long arg );
824 extern int DRM(addctx)( struct inode *inode, struct file *filp,
825 unsigned int cmd, unsigned long arg );
826 extern int DRM(modctx)( struct inode *inode, struct file *filp,
827 unsigned int cmd, unsigned long arg );
828 extern int DRM(getctx)( struct inode *inode, struct file *filp,
829 unsigned int cmd, unsigned long arg );
830 extern int DRM(switchctx)( struct inode *inode, struct file *filp,
831 unsigned int cmd, unsigned long arg );
832 extern int DRM(newctx)( struct inode *inode, struct file *filp,
833 unsigned int cmd, unsigned long arg );
834 extern int DRM(rmctx)( struct inode *inode, struct file *filp,
835 unsigned int cmd, unsigned long arg );
837 extern int DRM(context_switch)(drm_device_t *dev, int old, int new);
838 extern int DRM(context_switch_complete)(drm_device_t *dev, int new);
840 #if __HAVE_CTX_BITMAP
841 extern int DRM(ctxbitmap_init)( drm_device_t *dev );
842 extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev );
845 extern int DRM(setsareactx)( struct inode *inode, struct file *filp,
846 unsigned int cmd, unsigned long arg );
847 extern int DRM(getsareactx)( struct inode *inode, struct file *filp,
848 unsigned int cmd, unsigned long arg );
850 /* Drawable IOCTL support (drm_drawable.h) */
851 extern int DRM(adddraw)(struct inode *inode, struct file *filp,
852 unsigned int cmd, unsigned long arg);
853 extern int DRM(rmdraw)(struct inode *inode, struct file *filp,
854 unsigned int cmd, unsigned long arg);
857 /* Authentication IOCTL support (drm_auth.h) */
858 extern int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv,
860 extern int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic);
861 extern int DRM(getmagic)(struct inode *inode, struct file *filp,
862 unsigned int cmd, unsigned long arg);
863 extern int DRM(authmagic)(struct inode *inode, struct file *filp,
864 unsigned int cmd, unsigned long arg);
866 /* Placeholder for ioctls past */
867 extern int DRM(noop)(struct inode *inode, struct file *filp,
868 unsigned int cmd, unsigned long arg);
870 /* Locking IOCTL support (drm_lock.h) */
871 extern int DRM(lock_take)(__volatile__ unsigned int *lock,
872 unsigned int context);
873 extern int DRM(lock_transfer)(drm_device_t *dev,
874 __volatile__ unsigned int *lock,
875 unsigned int context);
876 extern int DRM(lock_free)(drm_device_t *dev,
877 __volatile__ unsigned int *lock,
878 unsigned int context);
879 extern int DRM(notifier)(void *priv);
881 /* Buffer management support (drm_bufs.h) */
882 extern int DRM(order)( unsigned long size );
883 extern int DRM(addmap)( struct inode *inode, struct file *filp,
884 unsigned int cmd, unsigned long arg );
885 extern int DRM(rmmap)( struct inode *inode, struct file *filp,
886 unsigned int cmd, unsigned long arg );
888 extern int DRM(addbufs)( struct inode *inode, struct file *filp,
889 unsigned int cmd, unsigned long arg );
890 extern int DRM(infobufs)( struct inode *inode, struct file *filp,
891 unsigned int cmd, unsigned long arg );
892 extern int DRM(markbufs)( struct inode *inode, struct file *filp,
893 unsigned int cmd, unsigned long arg );
894 extern int DRM(freebufs)( struct inode *inode, struct file *filp,
895 unsigned int cmd, unsigned long arg );
896 extern int DRM(mapbufs)( struct inode *inode, struct file *filp,
897 unsigned int cmd, unsigned long arg );
899 /* DMA support (drm_dma.h) */
900 extern int DRM(dma_setup)(drm_device_t *dev);
901 extern void DRM(dma_takedown)(drm_device_t *dev);
902 extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
903 extern void DRM(reclaim_buffers)( struct file *filp );
904 #endif /* __HAVE_DMA */
906 /* IRQ support (drm_irq.h) */
907 #if __HAVE_IRQ || __HAVE_DMA
908 extern int DRM(control)( struct inode *inode, struct file *filp,
909 unsigned int cmd, unsigned long arg );
912 extern int DRM(irq_install)( drm_device_t *dev );
913 extern int DRM(irq_uninstall)( drm_device_t *dev );
914 extern irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS );
915 extern void DRM(driver_irq_preinstall)( drm_device_t *dev );
916 extern void DRM(driver_irq_postinstall)( drm_device_t *dev );
917 extern void DRM(driver_irq_uninstall)( drm_device_t *dev );
919 extern int DRM(wait_vblank)(struct inode *inode, struct file *filp,
920 unsigned int cmd, unsigned long arg);
921 extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
922 extern void DRM(vbl_send_signals)( drm_device_t *dev );
925 extern void DRM(irq_immediate_bh)( void *dev );
930 #if __REALLY_HAVE_AGP
931 /* AGP/GART support (drm_agpsupport.h) */
932 extern drm_agp_head_t *DRM(agp_init)(void);
933 extern void DRM(agp_uninit)(void);
934 extern int DRM(agp_acquire)(struct inode *inode, struct file *filp,
935 unsigned int cmd, unsigned long arg);
936 extern void DRM(agp_do_release)(void);
937 extern int DRM(agp_release)(struct inode *inode, struct file *filp,
938 unsigned int cmd, unsigned long arg);
939 extern int DRM(agp_enable)(struct inode *inode, struct file *filp,
940 unsigned int cmd, unsigned long arg);
941 extern int DRM(agp_info)(struct inode *inode, struct file *filp,
942 unsigned int cmd, unsigned long arg);
943 extern int DRM(agp_alloc)(struct inode *inode, struct file *filp,
944 unsigned int cmd, unsigned long arg);
945 extern int DRM(agp_free)(struct inode *inode, struct file *filp,
946 unsigned int cmd, unsigned long arg);
947 extern int DRM(agp_unbind)(struct inode *inode, struct file *filp,
948 unsigned int cmd, unsigned long arg);
949 extern int DRM(agp_bind)(struct inode *inode, struct file *filp,
950 unsigned int cmd, unsigned long arg);
951 extern DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type);
952 extern int DRM(agp_free_memory)(DRM_AGP_MEM *handle);
953 extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start);
954 extern int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle);
957 /* Stub support (drm_stub.h) */
958 int DRM(stub_register)(const char *name,
959 struct file_operations *fops,
961 int DRM(stub_unregister)(int minor);
963 /* Proc support (drm_proc.h) */
964 extern struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev,
966 struct proc_dir_entry *root,
967 struct proc_dir_entry **dev_root);
968 extern int DRM(proc_cleanup)(int minor,
969 struct proc_dir_entry *root,
970 struct proc_dir_entry *dev_root);
973 /* Scatter Gather Support (drm_scatter.h) */
974 extern void DRM(sg_cleanup)(drm_sg_mem_t *entry);
975 extern int DRM(sg_alloc)(struct inode *inode, struct file *filp,
976 unsigned int cmd, unsigned long arg);
977 extern int DRM(sg_free)(struct inode *inode, struct file *filp,
978 unsigned int cmd, unsigned long arg);
981 /* ATI PCIGART support (ati_pcigart.h) */
982 extern int DRM(ati_pcigart_init)(drm_device_t *dev,
984 dma_addr_t *bus_addr);
985 extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev,
987 dma_addr_t bus_addr);
991 #endif /* __KERNEL__ */