1 /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
2 * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
28 * Rickard E. (Rik) Faith <faith@valinux.com>
29 * Gareth Hughes <gareth@valinux.com>
37 /* add include of current.h so that "current" is defined
38 * before static inline funcs in wait.h. Doing this so we
39 * can build the DRM (part of PI DRI). 4/21/2000 S + B */
40 #include <asm/current.h>
41 #endif /* __alpha__ */
42 #include <linux/config.h>
43 #include <linux/module.h>
44 #include <linux/kernel.h>
45 #include <linux/miscdevice.h>
47 #include <linux/proc_fs.h>
48 #include <linux/init.h>
49 #include <linux/file.h>
50 #include <linux/pci.h>
51 #include <linux/version.h>
52 #include <linux/jiffies.h>
53 #include <linux/smp_lock.h> /* For (un)lock_kernel */
55 #if defined(__alpha__) || defined(__powerpc__)
56 #include <asm/pgtable.h> /* For pte_wrprotect */
60 #include <asm/uaccess.h>
64 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
65 #include <linux/types.h>
66 #include <linux/agp_backend.h>
68 #include <linux/workqueue.h>
69 #include <linux/poll.h>
70 #include <asm/pgalloc.h>
73 #include "drm_os_linux.h"
75 /* DRM template customization defaults
83 #ifndef __HAVE_CTX_BITMAP
84 #define __HAVE_CTX_BITMAP 0
89 #ifndef __HAVE_DMA_IRQ
90 #define __HAVE_DMA_IRQ 0
92 #ifndef __HAVE_DMA_WAITLIST
93 #define __HAVE_DMA_WAITLIST 0
95 #ifndef __HAVE_DMA_FREELIST
96 #define __HAVE_DMA_FREELIST 0
99 #define __REALLY_HAVE_AGP (__HAVE_AGP && (defined(CONFIG_AGP) || \
100 defined(CONFIG_AGP_MODULE)))
101 #define __REALLY_HAVE_MTRR (__HAVE_MTRR && defined(CONFIG_MTRR))
102 #define __REALLY_HAVE_SG (__HAVE_SG)
107 #define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then
108 also include looping detection. */
110 #define DRM_HASH_SIZE 16 /* Size of key hash table */
111 #define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
112 #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
113 #define DRM_LOOPING_LIMIT 5000000
114 #define DRM_BSZ 1024 /* Buffer size for /dev/drm? output */
115 #define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
116 #define DRM_LOCK_SLICE 1 /* Time slice for lock, in jiffies */
118 #define DRM_FLAG_DEBUG 0x01
120 #define DRM_MEM_DMA 0
121 #define DRM_MEM_SAREA 1
122 #define DRM_MEM_DRIVER 2
123 #define DRM_MEM_MAGIC 3
124 #define DRM_MEM_IOCTLS 4
125 #define DRM_MEM_MAPS 5
126 #define DRM_MEM_VMAS 6
127 #define DRM_MEM_BUFS 7
128 #define DRM_MEM_SEGS 8
129 #define DRM_MEM_PAGES 9
130 #define DRM_MEM_FILES 10
131 #define DRM_MEM_QUEUES 11
132 #define DRM_MEM_CMDS 12
133 #define DRM_MEM_MAPPINGS 13
134 #define DRM_MEM_BUFLISTS 14
135 #define DRM_MEM_AGPLISTS 15
136 #define DRM_MEM_TOTALAGP 16
137 #define DRM_MEM_BOUNDAGP 17
138 #define DRM_MEM_CTXBITMAP 18
139 #define DRM_MEM_STUB 19
140 #define DRM_MEM_SGLISTS 20
142 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
144 /* Backward compatibility section */
146 #define minor(x) MINOR((x))
149 #ifndef MODULE_LICENSE
150 #define MODULE_LICENSE(x)
153 #ifndef preempt_disable
154 #define preempt_disable()
155 #define preempt_enable()
158 #ifndef pte_offset_map
159 #define pte_offset_map pte_offset
160 #define pte_unmap(pte)
163 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19)
164 static inline struct page * vmalloc_to_page(void * vmalloc_addr)
166 unsigned long addr = (unsigned long) vmalloc_addr;
167 struct page *page = NULL;
168 pgd_t *pgd = pgd_offset_k(addr);
172 if (!pgd_none(*pgd)) {
173 pmd = pmd_offset(pgd, addr);
174 if (!pmd_none(*pmd)) {
176 ptep = pte_offset_map(pmd, addr);
178 if (pte_present(pte))
179 page = pte_page(pte);
188 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
189 #define DRM_RPR_ARG(vma)
191 #define DRM_RPR_ARG(vma) vma,
195 #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
197 /* Macros to make printk easier */
198 #define DRM_ERROR(fmt, arg...) \
199 printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg)
200 #define DRM_MEM_ERROR(area, fmt, arg...) \
201 printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \
202 DRM(mem_stats)[area].name , ##arg)
203 #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
206 #define DRM_DEBUG(fmt, arg...) \
208 if ( DRM(flags) & DRM_FLAG_DEBUG ) \
210 "[" DRM_NAME ":%s] " fmt , \
211 __FUNCTION__ , ##arg); \
214 #define DRM_DEBUG(fmt, arg...) do { } while (0)
217 #define DRM_PROC_LIMIT (PAGE_SIZE-80)
219 #define DRM_PROC_PRINT(fmt, arg...) \
220 len += sprintf(&buf[len], fmt , ##arg); \
221 if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; }
223 #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
224 len += sprintf(&buf[len], fmt , ##arg); \
225 if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }
227 /* Mapping helper macros */
228 #define DRM_IOREMAP(map, dev) \
229 (map)->handle = DRM(ioremap)( (map)->offset, (map)->size, (dev) )
231 #define DRM_IOREMAP_NOCACHE(map, dev) \
232 (map)->handle = DRM(ioremap_nocache)((map)->offset, (map)->size, (dev))
234 #define DRM_IOREMAPFREE(map, dev) \
236 if ( (map)->handle && (map)->size ) \
237 DRM(ioremapfree)( (map)->handle, (map)->size, (dev) ); \
240 #define DRM_FIND_MAP(_map, _o) \
242 struct list_head *_list; \
243 list_for_each( _list, &dev->maplist->head ) { \
244 drm_map_list_t *_entry = list_entry( _list, drm_map_list_t, head ); \
245 if ( _entry->map && \
246 _entry->map->offset == (_o) ) { \
247 (_map) = _entry->map; \
252 #define DRM_DROP_MAP(_map)
254 /* Internal types and structures */
255 #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
256 #define DRM_MIN(a,b) ((a)<(b)?(a):(b))
257 #define DRM_MAX(a,b) ((a)>(b)?(a):(b))
259 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
260 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
261 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
263 #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
264 (_map) = (_dev)->context_sareas[_ctx]; \
267 #define LOCK_TEST_WITH_RETURN( dev, filp ) \
269 if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
270 dev->lock.filp != filp ) { \
271 DRM_ERROR( "%s called without lock held\n", \
278 typedef int drm_ioctl_t( struct inode *inode, struct file *filp,
279 unsigned int cmd, unsigned long arg );
281 typedef struct drm_pci_list {
286 typedef struct drm_ioctl_desc {
292 typedef struct drm_devstate {
293 pid_t owner; /* X server pid holding x_lock */
297 typedef struct drm_magic_entry {
299 struct drm_file *priv;
300 struct drm_magic_entry *next;
303 typedef struct drm_magic_head {
304 struct drm_magic_entry *head;
305 struct drm_magic_entry *tail;
308 typedef struct drm_vma_entry {
309 struct vm_area_struct *vma;
310 struct drm_vma_entry *next;
314 typedef struct drm_buf {
315 int idx; /* Index into master buflist */
316 int total; /* Buffer size */
317 int order; /* log-base-2(total) */
318 int used; /* Amount of buffer in use (for DMA) */
319 unsigned long offset; /* Byte offset (used internally) */
320 void *address; /* Address of buffer */
321 unsigned long bus_address; /* Bus address of buffer */
322 struct drm_buf *next; /* Kernel-only: used for free list */
323 __volatile__ int waiting; /* On kernel DMA queue */
324 __volatile__ int pending; /* On hardware DMA queue */
325 wait_queue_head_t dma_wait; /* Processes waiting */
326 struct file *filp; /* Pointer to holding file descr */
327 int context; /* Kernel queue for this buffer */
328 int while_locked;/* Dispatch this buffer while locked */
336 } list; /* Which list we're on */
339 int dev_priv_size; /* Size of buffer private stoarge */
340 void *dev_private; /* Per-buffer private storage */
344 /* bufs is one longer than it has to be */
345 typedef struct drm_waitlist {
346 int count; /* Number of possible buffers */
347 drm_buf_t **bufs; /* List of pointers to buffers */
348 drm_buf_t **rp; /* Read pointer */
349 drm_buf_t **wp; /* Write pointer */
350 drm_buf_t **end; /* End pointer */
351 spinlock_t read_lock;
352 spinlock_t write_lock;
355 typedef struct drm_freelist {
356 int initialized; /* Freelist in use */
357 atomic_t count; /* Number of free buffers */
358 drm_buf_t *next; /* End pointer */
360 wait_queue_head_t waiting; /* Processes waiting on free bufs */
361 int low_mark; /* Low water mark */
362 int high_mark; /* High water mark */
363 atomic_t wfh; /* If waiting for high mark */
367 typedef struct drm_buf_entry {
373 unsigned long *seglist;
375 drm_freelist_t freelist;
378 typedef struct drm_hw_lock {
379 __volatile__ unsigned int lock;
380 char padding[60]; /* Pad to cache line */
383 typedef struct drm_file {
389 unsigned long ioctl_count;
390 struct drm_file *next;
391 struct drm_file *prev;
392 struct drm_device *dev;
393 int remove_auth_on_close;
394 unsigned long lock_count;
398 typedef struct drm_queue {
399 atomic_t use_count; /* Outstanding uses (+1) */
400 atomic_t finalization; /* Finalization in progress */
401 atomic_t block_count; /* Count of processes waiting */
402 atomic_t block_read; /* Queue blocked for reads */
403 wait_queue_head_t read_queue; /* Processes waiting on block_read */
404 atomic_t block_write; /* Queue blocked for writes */
405 wait_queue_head_t write_queue; /* Processes waiting on block_write */
407 atomic_t total_queued; /* Total queued statistic */
408 atomic_t total_flushed;/* Total flushes statistic */
409 atomic_t total_locks; /* Total locks statistics */
411 drm_ctx_flags_t flags; /* Context preserving and 2D-only */
412 drm_waitlist_t waitlist; /* Pending buffers */
413 wait_queue_head_t flush_queue; /* Processes waiting until flush */
416 typedef struct drm_lock_data {
417 drm_hw_lock_t *hw_lock; /* Hardware lock */
418 struct file *filp; /* File descr of lock holder (0=kernel) */
419 wait_queue_head_t lock_queue; /* Queue of blocked processes */
420 unsigned long lock_time; /* Time of last lock in jiffies */
423 typedef struct drm_device_dma {
425 drm_buf_entry_t bufs[DRM_MAX_ORDER+1];
427 drm_buf_t **buflist; /* Vector of pointers info bufs */
430 unsigned long *pagelist;
431 unsigned long byte_count;
433 _DRM_DMA_USE_AGP = 0x01,
434 _DRM_DMA_USE_SG = 0x02
438 drm_buf_t *this_buffer; /* Buffer being sent */
439 drm_buf_t *next_buffer; /* Selected buffer to send */
440 drm_queue_t *next_queue; /* Queue from which buffer selected*/
441 wait_queue_head_t waiting; /* Processes waiting on free bufs */
444 #if __REALLY_HAVE_AGP
445 typedef struct drm_agp_mem {
446 unsigned long handle;
448 unsigned long bound; /* address */
450 struct drm_agp_mem *prev;
451 struct drm_agp_mem *next;
454 typedef struct drm_agp_head {
455 agp_kern_info agp_info;
456 drm_agp_mem_t *memory;
462 int cant_use_aperture;
463 unsigned long page_mask;
467 typedef struct drm_sg_mem {
468 unsigned long handle;
471 struct page **pagelist;
475 typedef struct drm_sigdata {
480 typedef struct drm_map_list {
481 struct list_head head;
485 typedef drm_map_t drm_local_map_t;
489 typedef struct drm_vbl_sig {
490 struct list_head head;
491 unsigned int sequence;
493 struct task_struct *task;
498 typedef struct drm_device {
499 const char *name; /* Simple driver name */
500 char *unique; /* Unique identifier: e.g., busid */
501 int unique_len; /* Length of unique field */
502 dev_t device; /* Device number for mknod */
503 char *devname; /* For /proc/interrupts */
505 int blocked; /* Blocked due to VC switch? */
506 struct proc_dir_entry *root; /* Root for this device's entries */
509 spinlock_t count_lock; /* For inuse, open_count, buf_use */
510 struct semaphore struct_sem; /* For others */
513 int open_count; /* Outstanding files open */
514 atomic_t ioctl_count; /* Outstanding IOCTLs pending */
515 atomic_t vma_count; /* Outstanding vma areas open */
516 int buf_use; /* Buffers in use -- cannot alloc */
517 atomic_t buf_alloc; /* Buffer allocation in progress */
519 /* Performance counters */
520 unsigned long counters;
521 drm_stat_type_t types[15];
525 drm_file_t *file_first;
526 drm_file_t *file_last;
527 drm_magic_head_t magiclist[DRM_HASH_SIZE];
529 /* Memory management */
530 drm_map_list_t *maplist; /* Linked list of regions */
532 drm_map_t **context_sareas;
535 drm_vma_entry_t *vmalist; /* List of vmas (for debugging) */
536 drm_lock_data_t lock; /* Information on hardware lock */
538 /* DMA queues (contexts) */
539 int queue_count; /* Number of active DMA queues */
540 int queue_reserved; /* Number of reserved DMA queues */
541 int queue_slots; /* Actual length of queuelist */
542 drm_queue_t **queuelist; /* Vector of pointers to DMA queues */
543 drm_device_dma_t *dma; /* Optional pointer for DMA support */
545 /* Context support */
546 int irq; /* Interrupt used by board */
547 __volatile__ long context_flag; /* Context swapping flag */
548 __volatile__ long interrupt_flag; /* Interruption handler flag */
549 __volatile__ long dma_flag; /* DMA dispatch flag */
550 struct timer_list timer; /* Timer for delaying ctx switch */
551 wait_queue_head_t context_wait; /* Processes waiting on ctx switch */
552 int last_checked; /* Last context checked for DMA */
553 int last_context; /* Last current context */
554 unsigned long last_switch; /* jiffies at last context switch */
555 struct work_struct work;
557 wait_queue_head_t vbl_queue;
558 atomic_t vbl_received;
560 drm_vbl_sig_t vbl_sigs;
561 unsigned int vbl_pending;
566 /* Callback to X server for context switch
567 and for heavy-handed reset. */
568 char buf[DRM_BSZ]; /* Output buffer */
569 char *buf_rp; /* Read pointer */
570 char *buf_wp; /* Write pointer */
571 char *buf_end; /* End pointer */
572 struct fasync_struct *buf_async;/* Processes waiting for SIGIO */
573 wait_queue_head_t buf_readers; /* Processes waiting to read */
574 wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */
576 #if __REALLY_HAVE_AGP
579 struct pci_dev *pdev;
581 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3)
582 struct pci_controler *hose;
584 struct pci_controller *hose;
587 drm_sg_mem_t *sg; /* Scatter gather memory */
588 unsigned long *ctx_bitmap;
590 drm_sigdata_t sigdata; /* For block_all_signals */
595 /* ================================================================
596 * Internal function definitions
599 /* Misc. support (drm_init.h) */
600 extern int DRM(flags);
601 extern void DRM(parse_options)( char *s );
602 extern int DRM(cpu_valid)( void );
604 /* Driver support (drm_drv.h) */
605 extern int DRM(version)(struct inode *inode, struct file *filp,
606 unsigned int cmd, unsigned long arg);
607 extern int DRM(open)(struct inode *inode, struct file *filp);
608 extern int DRM(release)(struct inode *inode, struct file *filp);
609 extern int DRM(ioctl)(struct inode *inode, struct file *filp,
610 unsigned int cmd, unsigned long arg);
611 extern int DRM(lock)(struct inode *inode, struct file *filp,
612 unsigned int cmd, unsigned long arg);
613 extern int DRM(unlock)(struct inode *inode, struct file *filp,
614 unsigned int cmd, unsigned long arg);
616 /* Device support (drm_fops.h) */
617 extern int DRM(open_helper)(struct inode *inode, struct file *filp,
619 extern int DRM(flush)(struct file *filp);
620 extern int DRM(fasync)(int fd, struct file *filp, int on);
622 /* Mapping support (drm_vm.h) */
623 extern struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
624 unsigned long address,
626 extern struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
627 unsigned long address,
629 extern struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
630 unsigned long address,
632 extern struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma,
633 unsigned long address,
635 extern void DRM(vm_open)(struct vm_area_struct *vma);
636 extern void DRM(vm_close)(struct vm_area_struct *vma);
637 extern void DRM(vm_shm_close)(struct vm_area_struct *vma);
638 extern int DRM(mmap_dma)(struct file *filp,
639 struct vm_area_struct *vma);
640 extern int DRM(mmap)(struct file *filp, struct vm_area_struct *vma);
641 extern unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait);
642 extern ssize_t DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off);
644 /* Memory management support (drm_memory.h) */
645 extern void DRM(mem_init)(void);
646 extern int DRM(mem_info)(char *buf, char **start, off_t offset,
647 int request, int *eof, void *data);
648 extern void *DRM(alloc)(size_t size, int area);
649 extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
651 extern void DRM(free)(void *pt, size_t size, int area);
652 extern unsigned long DRM(alloc_pages)(int order, int area);
653 extern void DRM(free_pages)(unsigned long address, int order,
655 extern void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev);
656 extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size,
658 extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev);
660 #if __REALLY_HAVE_AGP
661 extern agp_memory *DRM(alloc_agp)(int pages, u32 type);
662 extern int DRM(free_agp)(agp_memory *handle, int pages);
663 extern int DRM(bind_agp)(agp_memory *handle, unsigned int start);
664 extern int DRM(unbind_agp)(agp_memory *handle);
667 /* Misc. IOCTL support (drm_ioctl.h) */
668 extern int DRM(irq_busid)(struct inode *inode, struct file *filp,
669 unsigned int cmd, unsigned long arg);
670 extern int DRM(getunique)(struct inode *inode, struct file *filp,
671 unsigned int cmd, unsigned long arg);
672 extern int DRM(setunique)(struct inode *inode, struct file *filp,
673 unsigned int cmd, unsigned long arg);
674 extern int DRM(getmap)(struct inode *inode, struct file *filp,
675 unsigned int cmd, unsigned long arg);
676 extern int DRM(getclient)(struct inode *inode, struct file *filp,
677 unsigned int cmd, unsigned long arg);
678 extern int DRM(getstats)(struct inode *inode, struct file *filp,
679 unsigned int cmd, unsigned long arg);
681 /* Context IOCTL support (drm_context.h) */
682 extern int DRM(resctx)( struct inode *inode, struct file *filp,
683 unsigned int cmd, unsigned long arg );
684 extern int DRM(addctx)( struct inode *inode, struct file *filp,
685 unsigned int cmd, unsigned long arg );
686 extern int DRM(modctx)( struct inode *inode, struct file *filp,
687 unsigned int cmd, unsigned long arg );
688 extern int DRM(getctx)( struct inode *inode, struct file *filp,
689 unsigned int cmd, unsigned long arg );
690 extern int DRM(switchctx)( struct inode *inode, struct file *filp,
691 unsigned int cmd, unsigned long arg );
692 extern int DRM(newctx)( struct inode *inode, struct file *filp,
693 unsigned int cmd, unsigned long arg );
694 extern int DRM(rmctx)( struct inode *inode, struct file *filp,
695 unsigned int cmd, unsigned long arg );
697 extern int DRM(context_switch)(drm_device_t *dev, int old, int new);
698 extern int DRM(context_switch_complete)(drm_device_t *dev, int new);
700 #if __HAVE_CTX_BITMAP
701 extern int DRM(ctxbitmap_init)( drm_device_t *dev );
702 extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev );
705 extern int DRM(setsareactx)( struct inode *inode, struct file *filp,
706 unsigned int cmd, unsigned long arg );
707 extern int DRM(getsareactx)( struct inode *inode, struct file *filp,
708 unsigned int cmd, unsigned long arg );
710 /* Drawable IOCTL support (drm_drawable.h) */
711 extern int DRM(adddraw)(struct inode *inode, struct file *filp,
712 unsigned int cmd, unsigned long arg);
713 extern int DRM(rmdraw)(struct inode *inode, struct file *filp,
714 unsigned int cmd, unsigned long arg);
717 /* Authentication IOCTL support (drm_auth.h) */
718 extern int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv,
720 extern int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic);
721 extern int DRM(getmagic)(struct inode *inode, struct file *filp,
722 unsigned int cmd, unsigned long arg);
723 extern int DRM(authmagic)(struct inode *inode, struct file *filp,
724 unsigned int cmd, unsigned long arg);
726 /* Placeholder for ioctls past */
727 extern int DRM(noop)(struct inode *inode, struct file *filp,
728 unsigned int cmd, unsigned long arg);
730 /* Locking IOCTL support (drm_lock.h) */
731 extern int DRM(lock_take)(__volatile__ unsigned int *lock,
732 unsigned int context);
733 extern int DRM(lock_transfer)(drm_device_t *dev,
734 __volatile__ unsigned int *lock,
735 unsigned int context);
736 extern int DRM(lock_free)(drm_device_t *dev,
737 __volatile__ unsigned int *lock,
738 unsigned int context);
739 extern int DRM(notifier)(void *priv);
741 /* Buffer management support (drm_bufs.h) */
742 extern int DRM(order)( unsigned long size );
743 extern int DRM(addmap)( struct inode *inode, struct file *filp,
744 unsigned int cmd, unsigned long arg );
745 extern int DRM(rmmap)( struct inode *inode, struct file *filp,
746 unsigned int cmd, unsigned long arg );
748 extern int DRM(addbufs)( struct inode *inode, struct file *filp,
749 unsigned int cmd, unsigned long arg );
750 extern int DRM(infobufs)( struct inode *inode, struct file *filp,
751 unsigned int cmd, unsigned long arg );
752 extern int DRM(markbufs)( struct inode *inode, struct file *filp,
753 unsigned int cmd, unsigned long arg );
754 extern int DRM(freebufs)( struct inode *inode, struct file *filp,
755 unsigned int cmd, unsigned long arg );
756 extern int DRM(mapbufs)( struct inode *inode, struct file *filp,
757 unsigned int cmd, unsigned long arg );
759 /* DMA support (drm_dma.h) */
760 extern int DRM(dma_setup)(drm_device_t *dev);
761 extern void DRM(dma_takedown)(drm_device_t *dev);
762 extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
763 extern void DRM(reclaim_buffers)( struct file *filp );
765 extern int DRM(control)( struct inode *inode, struct file *filp,
766 unsigned int cmd, unsigned long arg );
767 extern int DRM(irq_install)( drm_device_t *dev, int irq );
768 extern int DRM(irq_uninstall)( drm_device_t *dev );
769 extern irqreturn_t DRM(dma_service)( int irq, void *device,
770 struct pt_regs *regs );
771 extern void DRM(driver_irq_preinstall)( drm_device_t *dev );
772 extern void DRM(driver_irq_postinstall)( drm_device_t *dev );
773 extern void DRM(driver_irq_uninstall)( drm_device_t *dev );
775 extern int DRM(wait_vblank)(struct inode *inode, struct file *filp,
776 unsigned int cmd, unsigned long arg);
777 extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
778 extern void DRM(vbl_send_signals)( drm_device_t *dev );
780 #if __HAVE_DMA_IRQ_BH
781 extern void DRM(dma_immediate_bh)( void *dev );
785 #endif /* __HAVE_DMA */
787 #if __REALLY_HAVE_AGP
788 /* AGP/GART support (drm_agpsupport.h) */
789 extern drm_agp_head_t *DRM(agp_init)(void);
790 extern void DRM(agp_uninit)(void);
791 extern int DRM(agp_acquire)(struct inode *inode, struct file *filp,
792 unsigned int cmd, unsigned long arg);
793 extern void DRM(agp_do_release)(void);
794 extern int DRM(agp_release)(struct inode *inode, struct file *filp,
795 unsigned int cmd, unsigned long arg);
796 extern int DRM(agp_enable)(struct inode *inode, struct file *filp,
797 unsigned int cmd, unsigned long arg);
798 extern int DRM(agp_info)(struct inode *inode, struct file *filp,
799 unsigned int cmd, unsigned long arg);
800 extern int DRM(agp_alloc)(struct inode *inode, struct file *filp,
801 unsigned int cmd, unsigned long arg);
802 extern int DRM(agp_free)(struct inode *inode, struct file *filp,
803 unsigned int cmd, unsigned long arg);
804 extern int DRM(agp_unbind)(struct inode *inode, struct file *filp,
805 unsigned int cmd, unsigned long arg);
806 extern int DRM(agp_bind)(struct inode *inode, struct file *filp,
807 unsigned int cmd, unsigned long arg);
808 extern agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type);
809 extern int DRM(agp_free_memory)(agp_memory *handle);
810 extern int DRM(agp_bind_memory)(agp_memory *handle, off_t start);
811 extern int DRM(agp_unbind_memory)(agp_memory *handle);
814 /* Stub support (drm_stub.h) */
815 int DRM(stub_register)(const char *name,
816 struct file_operations *fops,
818 int DRM(stub_unregister)(int minor);
820 /* Proc support (drm_proc.h) */
821 extern struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev,
823 struct proc_dir_entry *root,
824 struct proc_dir_entry **dev_root);
825 extern int DRM(proc_cleanup)(int minor,
826 struct proc_dir_entry *root,
827 struct proc_dir_entry *dev_root);
830 /* Scatter Gather Support (drm_scatter.h) */
831 extern void DRM(sg_cleanup)(drm_sg_mem_t *entry);
832 extern int DRM(sg_alloc)(struct inode *inode, struct file *filp,
833 unsigned int cmd, unsigned long arg);
834 extern int DRM(sg_free)(struct inode *inode, struct file *filp,
835 unsigned int cmd, unsigned long arg);
838 /* ATI PCIGART support (ati_pcigart.h) */
839 extern int DRM(ati_pcigart_init)(drm_device_t *dev,
841 dma_addr_t *bus_addr);
842 extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev,
844 dma_addr_t bus_addr);
846 #endif /* __KERNEL__ */