1 /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
2 * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
3 * Revised: Sun Feb 13 23:34:30 2000 by kevin@precisioninsight.com
5 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
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 * PRECISION INSIGHT 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 OTHER
25 * DEALINGS IN THE SOFTWARE.
27 * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h,v 1.6 2000/02/23 04:47:27 martin Exp $
35 #include <linux/module.h>
36 #include <linux/kernel.h>
37 #include <linux/miscdevice.h>
39 #include <linux/proc_fs.h>
40 #include <linux/init.h>
41 #include <linux/file.h>
42 #include <linux/pci.h>
43 #include <linux/wrapper.h>
44 #include <linux/version.h>
47 #include <asm/uaccess.h>
52 #include <linux/types.h>
53 #include <linux/agp_backend.h>
55 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
56 #include <linux/tqueue.h>
57 #include <linux/poll.h>
61 #define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then
62 also include looping detection. */
63 #define DRM_DMA_HISTOGRAM 1 /* Make histogram of DMA latency. */
65 #define DRM_HASH_SIZE 16 /* Size of key hash table */
66 #define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
67 #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
68 #define DRM_LOOPING_LIMIT 5000000
69 #define DRM_BSZ 1024 /* Buffer size for /dev/drm? output */
70 #define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
71 #define DRM_LOCK_SLICE 1 /* Time slice for lock, in jiffies */
73 #define DRM_FLAG_DEBUG 0x01
74 #define DRM_FLAG_NOCTX 0x02
77 #define DRM_MEM_SAREA 1
78 #define DRM_MEM_DRIVER 2
79 #define DRM_MEM_MAGIC 3
80 #define DRM_MEM_IOCTLS 4
81 #define DRM_MEM_MAPS 5
82 #define DRM_MEM_VMAS 6
83 #define DRM_MEM_BUFS 7
84 #define DRM_MEM_SEGS 8
85 #define DRM_MEM_PAGES 9
86 #define DRM_MEM_FILES 10
87 #define DRM_MEM_QUEUES 11
88 #define DRM_MEM_CMDS 12
89 #define DRM_MEM_MAPPINGS 13
90 #define DRM_MEM_BUFLISTS 14
91 #define DRM_MEM_AGPLISTS 15
92 #define DRM_MEM_TOTALAGP 16
93 #define DRM_MEM_BOUNDAGP 17
94 #define DRM_MEM_CTXBITMAP 18
96 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
98 /* Backward compatibility section */
99 /* _PAGE_WT changed to _PAGE_PWT in 2.2.6 */
101 #define _PAGE_PWT _PAGE_WT
103 /* Wait queue declarations changed in 2.3.1 */
104 #ifndef DECLARE_WAITQUEUE
105 #define DECLARE_WAITQUEUE(w,c) struct wait_queue w = { c, NULL }
106 typedef struct wait_queue *wait_queue_head_t;
107 #define init_waitqueue_head(q) *q = NULL;
110 /* _PAGE_4M changed to _PAGE_PSE in 2.3.23 */
112 #define _PAGE_PSE _PAGE_4M
115 /* vm_offset changed to vm_pgoff in 2.3.25 */
116 #if LINUX_VERSION_CODE < 0x020319
117 #define VM_OFFSET(vma) ((vma)->vm_offset)
119 #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
122 /* *_nopage return values defined in 2.3.26 */
123 #ifndef NOPAGE_SIGBUS
124 #define NOPAGE_SIGBUS 0
130 /* Generic cmpxchg added in 2.3.x */
132 #ifndef __HAVE_ARCH_CMPXCHG
133 /* Include this here so that driver can be
134 used with older kernels. */
135 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
136 unsigned long new, int size)
141 __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
143 : "q"(new), "m"(*__xg(ptr)), "0"(old)
147 __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
149 : "q"(new), "m"(*__xg(ptr)), "0"(old)
153 __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
155 : "q"(new), "m"(*__xg(ptr)), "0"(old)
162 #define cmpxchg(ptr,o,n) \
163 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \
164 (unsigned long)(n),sizeof(*(ptr))))
167 /* Compiling for a 386 proper... */
168 #error DRI not supported on Intel 80386
171 /* Macros to make printk easier */
172 #define DRM_ERROR(fmt, arg...) \
173 printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ "] *ERROR* " fmt , ##arg)
174 #define DRM_MEM_ERROR(area, fmt, arg...) \
175 printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ ":%s] *ERROR* " fmt , \
176 drm_mem_stats[area].name , ##arg)
177 #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
180 #define DRM_DEBUG(fmt, arg...) \
182 if (drm_flags&DRM_FLAG_DEBUG) \
184 "[" DRM_NAME ":" __FUNCTION__ "] " fmt , \
188 #define DRM_DEBUG(fmt, arg...) do { } while (0)
191 #define DRM_PROC_LIMIT (PAGE_SIZE-80)
193 #define DRM_PROC_PRINT(fmt, arg...) \
194 len += sprintf(&buf[len], fmt , ##arg); \
195 if (len > DRM_PROC_LIMIT) return len;
197 #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
198 len += sprintf(&buf[len], fmt , ##arg); \
199 if (len > DRM_PROC_LIMIT) { ret; return len; }
201 /* Internal types and structures */
202 #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
203 #define DRM_MIN(a,b) ((a)<(b)?(a):(b))
204 #define DRM_MAX(a,b) ((a)>(b)?(a):(b))
206 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
207 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
208 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
210 typedef int drm_ioctl_t(struct inode *inode, struct file *filp,
211 unsigned int cmd, unsigned long arg);
213 typedef struct drm_ioctl_desc {
219 typedef struct drm_devstate {
220 pid_t owner; /* X server pid holding x_lock */
224 typedef struct drm_magic_entry {
226 struct drm_file *priv;
227 struct drm_magic_entry *next;
230 typedef struct drm_magic_head {
231 struct drm_magic_entry *head;
232 struct drm_magic_entry *tail;
235 typedef struct drm_vma_entry {
236 struct vm_area_struct *vma;
237 struct drm_vma_entry *next;
241 typedef struct drm_buf {
242 int idx; /* Index into master buflist */
243 int total; /* Buffer size */
244 int order; /* log-base-2(total) */
245 int used; /* Amount of buffer in use (for DMA) */
246 unsigned long offset; /* Byte offset (used internally) */
247 void *address; /* Address of buffer */
248 unsigned long bus_address; /* Bus address of buffer */
249 struct drm_buf *next; /* Kernel-only: used for free list */
250 __volatile__ int waiting; /* On kernel DMA queue */
251 __volatile__ int pending; /* On hardware DMA queue */
252 wait_queue_head_t dma_wait; /* Processes waiting */
253 pid_t pid; /* PID of holding process */
254 int context; /* Kernel queue for this buffer */
255 int while_locked;/* Dispatch this buffer while locked */
263 } list; /* Which list we're on */
269 #if DRM_DMA_HISTOGRAM
270 cycles_t time_queued; /* Queued to kernel DMA queue */
271 cycles_t time_dispatched; /* Dispatched to hardware */
272 cycles_t time_completed; /* Completed by hardware */
273 cycles_t time_freed; /* Back on freelist */
277 #if DRM_DMA_HISTOGRAM
278 #define DRM_DMA_HISTOGRAM_SLOTS 9
279 #define DRM_DMA_HISTOGRAM_INITIAL 10
280 #define DRM_DMA_HISTOGRAM_NEXT(current) ((current)*10)
281 typedef struct drm_histogram {
284 atomic_t queued_to_dispatched[DRM_DMA_HISTOGRAM_SLOTS];
285 atomic_t dispatched_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
286 atomic_t completed_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
288 atomic_t queued_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
289 atomic_t queued_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
291 atomic_t dma[DRM_DMA_HISTOGRAM_SLOTS];
292 atomic_t schedule[DRM_DMA_HISTOGRAM_SLOTS];
293 atomic_t ctx[DRM_DMA_HISTOGRAM_SLOTS];
294 atomic_t lacq[DRM_DMA_HISTOGRAM_SLOTS];
295 atomic_t lhld[DRM_DMA_HISTOGRAM_SLOTS];
299 /* bufs is one longer than it has to be */
300 typedef struct drm_waitlist {
301 int count; /* Number of possible buffers */
302 drm_buf_t **bufs; /* List of pointers to buffers */
303 drm_buf_t **rp; /* Read pointer */
304 drm_buf_t **wp; /* Write pointer */
305 drm_buf_t **end; /* End pointer */
306 spinlock_t read_lock;
307 spinlock_t write_lock;
310 typedef struct drm_freelist {
311 int initialized; /* Freelist in use */
312 atomic_t count; /* Number of free buffers */
313 drm_buf_t *next; /* End pointer */
315 wait_queue_head_t waiting; /* Processes waiting on free bufs */
316 int low_mark; /* Low water mark */
317 int high_mark; /* High water mark */
318 atomic_t wfh; /* If waiting for high mark */
321 typedef struct drm_buf_entry {
327 unsigned long *seglist;
329 drm_freelist_t freelist;
332 typedef struct drm_hw_lock {
333 __volatile__ unsigned int lock;
334 char padding[60]; /* Pad to cache line */
337 typedef struct drm_file {
343 unsigned long ioctl_count;
344 struct drm_file *next;
345 struct drm_file *prev;
346 struct drm_device *dev;
350 typedef struct drm_queue {
351 atomic_t use_count; /* Outstanding uses (+1) */
352 atomic_t finalization; /* Finalization in progress */
353 atomic_t block_count; /* Count of processes waiting */
354 atomic_t block_read; /* Queue blocked for reads */
355 wait_queue_head_t read_queue; /* Processes waiting on block_read */
356 atomic_t block_write; /* Queue blocked for writes */
357 wait_queue_head_t write_queue; /* Processes waiting on block_write */
358 atomic_t total_queued; /* Total queued statistic */
359 atomic_t total_flushed;/* Total flushes statistic */
360 atomic_t total_locks; /* Total locks statistics */
361 drm_ctx_flags_t flags; /* Context preserving and 2D-only */
362 drm_waitlist_t waitlist; /* Pending buffers */
363 wait_queue_head_t flush_queue; /* Processes waiting until flush */
366 typedef struct drm_lock_data {
367 drm_hw_lock_t *hw_lock; /* Hardware lock */
368 pid_t pid; /* PID of lock holder (0=kernel) */
369 wait_queue_head_t lock_queue; /* Queue of blocked processes */
370 unsigned long lock_time; /* Time of last lock in jiffies */
373 typedef struct drm_device_dma {
374 /* Performance Counters */
375 atomic_t total_prio; /* Total DRM_DMA_PRIORITY */
376 atomic_t total_bytes; /* Total bytes DMA'd */
377 atomic_t total_dmas; /* Total DMA buffers dispatched */
379 atomic_t total_missed_dma; /* Missed drm_do_dma */
380 atomic_t total_missed_lock; /* Missed lock in drm_do_dma */
381 atomic_t total_missed_free; /* Missed drm_free_this_buffer */
382 atomic_t total_missed_sched;/* Missed drm_dma_schedule */
384 atomic_t total_tried; /* Tried next_buffer */
385 atomic_t total_hit; /* Sent next_buffer */
386 atomic_t total_lost; /* Lost interrupt */
388 drm_buf_entry_t bufs[DRM_MAX_ORDER+1];
390 drm_buf_t **buflist; /* Vector of pointers info bufs */
393 unsigned long *pagelist;
394 unsigned long byte_count;
396 _DRM_DMA_USE_AGP = 0x01
400 drm_buf_t *this_buffer; /* Buffer being sent */
401 drm_buf_t *next_buffer; /* Selected buffer to send */
402 drm_queue_t *next_queue; /* Queue from which buffer selected*/
403 wait_queue_head_t waiting; /* Processes waiting on free bufs */
407 typedef struct drm_agp_mem {
408 unsigned long handle;
410 unsigned long bound; /* address */
412 struct drm_agp_mem *prev;
413 struct drm_agp_mem *next;
416 typedef struct drm_agp_head {
417 agp_kern_info agp_info;
419 drm_agp_mem_t *memory;
428 void (*free_memory)(agp_memory *);
429 agp_memory *(*allocate_memory)(size_t, u32);
430 int (*bind_memory)(agp_memory *, off_t);
431 int (*unbind_memory)(agp_memory *);
433 int (*acquire)(void);
434 void (*release)(void);
435 void (*copy_info)(agp_kern_info *);
438 extern drm_agp_func_t drm_agp;
441 typedef struct drm_device {
442 const char *name; /* Simple driver name */
443 char *unique; /* Unique identifier: e.g., busid */
444 int unique_len; /* Length of unique field */
445 dev_t device; /* Device number for mknod */
446 char *devname; /* For /proc/interrupts */
448 int blocked; /* Blocked due to VC switch? */
449 struct proc_dir_entry *root; /* Root for this device's entries */
452 spinlock_t count_lock; /* For inuse, open_count, buf_use */
453 struct semaphore struct_sem; /* For others */
456 int open_count; /* Outstanding files open */
457 atomic_t ioctl_count; /* Outstanding IOCTLs pending */
458 atomic_t vma_count; /* Outstanding vma areas open */
459 int buf_use; /* Buffers in use -- cannot alloc */
460 atomic_t buf_alloc; /* Buffer allocation in progress */
462 /* Performance Counters */
464 atomic_t total_close;
465 atomic_t total_ioctl;
466 atomic_t total_irq; /* Total interruptions */
467 atomic_t total_ctx; /* Total context switches */
469 atomic_t total_locks;
470 atomic_t total_unlocks;
471 atomic_t total_contends;
472 atomic_t total_sleeps;
475 drm_file_t *file_first;
476 drm_file_t *file_last;
477 drm_magic_head_t magiclist[DRM_HASH_SIZE];
479 /* Memory management */
480 drm_map_t **maplist; /* Vector of pointers to regions */
481 int map_count; /* Number of mappable regions */
483 drm_vma_entry_t *vmalist; /* List of vmas (for debugging) */
484 drm_lock_data_t lock; /* Information on hardware lock */
486 /* DMA queues (contexts) */
487 int queue_count; /* Number of active DMA queues */
488 int queue_reserved; /* Number of reserved DMA queues */
489 int queue_slots; /* Actual length of queuelist */
490 drm_queue_t **queuelist; /* Vector of pointers to DMA queues */
491 drm_device_dma_t *dma; /* Optional pointer for DMA support */
493 /* Context support */
494 int irq; /* Interrupt used by board */
495 __volatile__ int context_flag; /* Context swapping flag */
496 __volatile__ int interrupt_flag;/* Interruption handler flag */
497 __volatile__ int dma_flag; /* DMA dispatch flag */
498 struct timer_list timer; /* Timer for delaying ctx switch */
499 wait_queue_head_t context_wait; /* Processes waiting on ctx switch */
500 int last_checked; /* Last context checked for DMA */
501 int last_context; /* Last current context */
502 unsigned long last_switch; /* jiffies at last context switch */
506 #if DRM_DMA_HISTOGRAM
507 drm_histogram_t histo;
510 /* Callback to X server for context switch
511 and for heavy-handed reset. */
512 char buf[DRM_BSZ]; /* Output buffer */
513 char *buf_rp; /* Read pointer */
514 char *buf_wp; /* Write pointer */
515 char *buf_end; /* End pointer */
516 struct fasync_struct *buf_async;/* Processes waiting for SIGIO */
517 wait_queue_head_t buf_readers; /* Processes waiting to read */
518 wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */
523 unsigned long *ctx_bitmap;
528 /* Internal function definitions */
530 /* Misc. support (init.c) */
531 extern int drm_flags;
532 extern void drm_parse_options(char *s);
535 /* Device support (fops.c) */
536 extern int drm_open_helper(struct inode *inode, struct file *filp,
538 extern int drm_flush(struct file *filp);
539 extern int drm_release(struct inode *inode, struct file *filp);
540 extern int drm_fasync(int fd, struct file *filp, int on);
541 extern ssize_t drm_read(struct file *filp, char *buf, size_t count,
543 extern int drm_write_string(drm_device_t *dev, const char *s);
544 extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
546 /* Mapping support (vm.c) */
547 #if LINUX_VERSION_CODE < 0x020317
548 extern unsigned long drm_vm_nopage(struct vm_area_struct *vma,
549 unsigned long address,
551 extern unsigned long drm_vm_shm_nopage(struct vm_area_struct *vma,
552 unsigned long address,
554 extern unsigned long drm_vm_dma_nopage(struct vm_area_struct *vma,
555 unsigned long address,
558 /* Return type changed in 2.3.23 */
559 extern struct page *drm_vm_nopage(struct vm_area_struct *vma,
560 unsigned long address,
562 extern struct page *drm_vm_shm_nopage(struct vm_area_struct *vma,
563 unsigned long address,
565 extern struct page *drm_vm_dma_nopage(struct vm_area_struct *vma,
566 unsigned long address,
569 extern void drm_vm_open(struct vm_area_struct *vma);
570 extern void drm_vm_close(struct vm_area_struct *vma);
571 extern int drm_mmap_dma(struct file *filp,
572 struct vm_area_struct *vma);
573 extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
576 /* Proc support (proc.c) */
577 extern int drm_proc_init(drm_device_t *dev);
578 extern int drm_proc_cleanup(void);
580 /* Memory management support (memory.c) */
581 extern void drm_mem_init(void);
582 extern int drm_mem_info(char *buf, char **start, off_t offset,
583 int len, int *eof, void *data);
584 extern void *drm_alloc(size_t size, int area);
585 extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size,
587 extern char *drm_strdup(const char *s, int area);
588 extern void drm_strfree(const char *s, int area);
589 extern void drm_free(void *pt, size_t size, int area);
590 extern unsigned long drm_alloc_pages(int order, int area);
591 extern void drm_free_pages(unsigned long address, int order,
593 extern void *drm_ioremap(unsigned long offset, unsigned long size);
594 extern void drm_ioremapfree(void *pt, unsigned long size);
597 extern agp_memory *drm_alloc_agp(int pages, u32 type);
598 extern int drm_free_agp(agp_memory *handle, int pages);
599 extern int drm_bind_agp(agp_memory *handle, unsigned int start);
600 extern int drm_unbind_agp(agp_memory *handle);
604 /* Buffer management support (bufs.c) */
605 extern int drm_order(unsigned long size);
606 extern int drm_addmap(struct inode *inode, struct file *filp,
607 unsigned int cmd, unsigned long arg);
608 extern int drm_addbufs(struct inode *inode, struct file *filp,
609 unsigned int cmd, unsigned long arg);
610 extern int drm_infobufs(struct inode *inode, struct file *filp,
611 unsigned int cmd, unsigned long arg);
612 extern int drm_markbufs(struct inode *inode, struct file *filp,
613 unsigned int cmd, unsigned long arg);
614 extern int drm_freebufs(struct inode *inode, struct file *filp,
615 unsigned int cmd, unsigned long arg);
616 extern int drm_mapbufs(struct inode *inode, struct file *filp,
617 unsigned int cmd, unsigned long arg);
620 /* Buffer list management support (lists.c) */
621 extern int drm_waitlist_create(drm_waitlist_t *bl, int count);
622 extern int drm_waitlist_destroy(drm_waitlist_t *bl);
623 extern int drm_waitlist_put(drm_waitlist_t *bl, drm_buf_t *buf);
624 extern drm_buf_t *drm_waitlist_get(drm_waitlist_t *bl);
626 extern int drm_freelist_create(drm_freelist_t *bl, int count);
627 extern int drm_freelist_destroy(drm_freelist_t *bl);
628 extern int drm_freelist_put(drm_device_t *dev, drm_freelist_t *bl,
630 extern drm_buf_t *drm_freelist_get(drm_freelist_t *bl, int block);
632 /* DMA support (gen_dma.c) */
633 extern void drm_dma_setup(drm_device_t *dev);
634 extern void drm_dma_takedown(drm_device_t *dev);
635 extern void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
636 extern void drm_reclaim_buffers(drm_device_t *dev, pid_t pid);
637 extern int drm_context_switch(drm_device_t *dev, int old, int new);
638 extern int drm_context_switch_complete(drm_device_t *dev, int new);
639 extern void drm_wakeup(drm_device_t *dev, drm_buf_t *buf);
640 extern void drm_clear_next_buffer(drm_device_t *dev);
641 extern int drm_select_queue(drm_device_t *dev,
642 void (*wrapper)(unsigned long));
643 extern int drm_dma_enqueue(drm_device_t *dev, drm_dma_t *dma);
644 extern int drm_dma_get_buffers(drm_device_t *dev, drm_dma_t *dma);
645 #if DRM_DMA_HISTOGRAM
646 extern int drm_histogram_slot(unsigned long count);
647 extern void drm_histogram_compute(drm_device_t *dev, drm_buf_t *buf);
651 /* Misc. IOCTL support (ioctl.c) */
652 extern int drm_irq_busid(struct inode *inode, struct file *filp,
653 unsigned int cmd, unsigned long arg);
654 extern int drm_getunique(struct inode *inode, struct file *filp,
655 unsigned int cmd, unsigned long arg);
656 extern int drm_setunique(struct inode *inode, struct file *filp,
657 unsigned int cmd, unsigned long arg);
660 /* Context IOCTL support (context.c) */
661 extern int drm_resctx(struct inode *inode, struct file *filp,
662 unsigned int cmd, unsigned long arg);
663 extern int drm_addctx(struct inode *inode, struct file *filp,
664 unsigned int cmd, unsigned long arg);
665 extern int drm_modctx(struct inode *inode, struct file *filp,
666 unsigned int cmd, unsigned long arg);
667 extern int drm_getctx(struct inode *inode, struct file *filp,
668 unsigned int cmd, unsigned long arg);
669 extern int drm_switchctx(struct inode *inode, struct file *filp,
670 unsigned int cmd, unsigned long arg);
671 extern int drm_newctx(struct inode *inode, struct file *filp,
672 unsigned int cmd, unsigned long arg);
673 extern int drm_rmctx(struct inode *inode, struct file *filp,
674 unsigned int cmd, unsigned long arg);
677 /* Drawable IOCTL support (drawable.c) */
678 extern int drm_adddraw(struct inode *inode, struct file *filp,
679 unsigned int cmd, unsigned long arg);
680 extern int drm_rmdraw(struct inode *inode, struct file *filp,
681 unsigned int cmd, unsigned long arg);
684 /* Authentication IOCTL support (auth.c) */
685 extern int drm_add_magic(drm_device_t *dev, drm_file_t *priv,
687 extern int drm_remove_magic(drm_device_t *dev, drm_magic_t magic);
688 extern int drm_getmagic(struct inode *inode, struct file *filp,
689 unsigned int cmd, unsigned long arg);
690 extern int drm_authmagic(struct inode *inode, struct file *filp,
691 unsigned int cmd, unsigned long arg);
694 /* Locking IOCTL support (lock.c) */
695 extern int drm_block(struct inode *inode, struct file *filp,
696 unsigned int cmd, unsigned long arg);
697 extern int drm_unblock(struct inode *inode, struct file *filp,
698 unsigned int cmd, unsigned long arg);
699 extern int drm_lock_take(__volatile__ unsigned int *lock,
700 unsigned int context);
701 extern int drm_lock_transfer(drm_device_t *dev,
702 __volatile__ unsigned int *lock,
703 unsigned int context);
704 extern int drm_lock_free(drm_device_t *dev,
705 __volatile__ unsigned int *lock,
706 unsigned int context);
707 extern int drm_finish(struct inode *inode, struct file *filp,
708 unsigned int cmd, unsigned long arg);
709 extern int drm_flush_unblock(drm_device_t *dev, int context,
710 drm_lock_flags_t flags);
711 extern int drm_flush_block_and_flush(drm_device_t *dev, int context,
712 drm_lock_flags_t flags);
714 /* Context Bitmap support (ctxbitmap.c) */
715 extern int drm_ctxbitmap_init(drm_device_t *dev);
716 extern void drm_ctxbitmap_cleanup(drm_device_t *dev);
717 extern int drm_ctxbitmap_next(drm_device_t *dev);
718 extern void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle);
721 /* AGP/GART support (agpsupport.c) */
722 extern drm_agp_head_t *drm_agp_init(void);
723 extern int drm_agp_acquire(struct inode *inode, struct file *filp,
724 unsigned int cmd, unsigned long arg);
725 extern int drm_agp_release(struct inode *inode, struct file *filp,
726 unsigned int cmd, unsigned long arg);
727 extern int drm_agp_enable(struct inode *inode, struct file *filp,
728 unsigned int cmd, unsigned long arg);
729 extern int drm_agp_info(struct inode *inode, struct file *filp,
730 unsigned int cmd, unsigned long arg);
731 extern int drm_agp_alloc(struct inode *inode, struct file *filp,
732 unsigned int cmd, unsigned long arg);
733 extern int drm_agp_free(struct inode *inode, struct file *filp,
734 unsigned int cmd, unsigned long arg);
735 extern int drm_agp_unbind(struct inode *inode, struct file *filp,
736 unsigned int cmd, unsigned long arg);
737 extern int drm_agp_bind(struct inode *inode, struct file *filp,
738 unsigned int cmd, unsigned long arg);