Merge with Linux 2.4.0-test6-pre9.
[linux-2.6/linux-mips.git] / drivers / char / drm / drmP.h
blob4f85d07ca931fd8fc79d68df1bba3e27b11ef0a9
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.
6 * All rights reserved.
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
17 * Software.
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 * Authors:
28 * Rickard E. (Rik) Faith <faith@valinux.com>
32 #ifndef _DRM_P_H_
33 #define _DRM_P_H_
35 #ifdef __KERNEL__
36 #include <linux/config.h>
37 #include <linux/module.h>
38 #include <linux/kernel.h>
39 #include <linux/miscdevice.h>
40 #include <linux/fs.h>
41 #include <linux/proc_fs.h>
42 #include <linux/init.h>
43 #include <linux/file.h>
44 #include <linux/pci.h>
45 #include <linux/wrapper.h>
46 #include <linux/version.h>
47 #include <linux/sched.h>
48 #include <linux/smp_lock.h> /* For (un)lock_kernel */
49 #include <asm/io.h>
50 #include <asm/mman.h>
51 #include <asm/uaccess.h>
52 #ifdef CONFIG_MTRR
53 #include <asm/mtrr.h>
54 #endif
55 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
56 #include <linux/types.h>
57 #include <linux/agp_backend.h>
58 #endif
59 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
60 #include <linux/tqueue.h>
61 #include <linux/poll.h>
62 #endif
63 #include "drm.h"
65 #define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then
66 also include looping detection. */
67 #define DRM_DMA_HISTOGRAM 1 /* Make histogram of DMA latency. */
69 #define DRM_HASH_SIZE 16 /* Size of key hash table */
70 #define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
71 #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
72 #define DRM_LOOPING_LIMIT 5000000
73 #define DRM_BSZ 1024 /* Buffer size for /dev/drm? output */
74 #define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
75 #define DRM_LOCK_SLICE 1 /* Time slice for lock, in jiffies */
77 #define DRM_FLAG_DEBUG 0x01
78 #define DRM_FLAG_NOCTX 0x02
80 #define DRM_MEM_DMA 0
81 #define DRM_MEM_SAREA 1
82 #define DRM_MEM_DRIVER 2
83 #define DRM_MEM_MAGIC 3
84 #define DRM_MEM_IOCTLS 4
85 #define DRM_MEM_MAPS 5
86 #define DRM_MEM_VMAS 6
87 #define DRM_MEM_BUFS 7
88 #define DRM_MEM_SEGS 8
89 #define DRM_MEM_PAGES 9
90 #define DRM_MEM_FILES 10
91 #define DRM_MEM_QUEUES 11
92 #define DRM_MEM_CMDS 12
93 #define DRM_MEM_MAPPINGS 13
94 #define DRM_MEM_BUFLISTS 14
95 #define DRM_MEM_AGPLISTS 15
96 #define DRM_MEM_TOTALAGP 16
97 #define DRM_MEM_BOUNDAGP 17
98 #define DRM_MEM_CTXBITMAP 18
100 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
102 /* Backward compatibility section */
103 /* _PAGE_WT changed to _PAGE_PWT in 2.2.6 */
104 #ifndef _PAGE_PWT
105 #define _PAGE_PWT _PAGE_WT
106 #endif
107 /* Wait queue declarations changed in 2.3.1 */
108 #ifndef DECLARE_WAITQUEUE
109 #define DECLARE_WAITQUEUE(w,c) struct wait_queue w = { c, NULL }
110 typedef struct wait_queue *wait_queue_head_t;
111 #define init_waitqueue_head(q) *q = NULL;
112 #endif
114 /* _PAGE_4M changed to _PAGE_PSE in 2.3.23 */
115 #ifndef _PAGE_PSE
116 #define _PAGE_PSE _PAGE_4M
117 #endif
119 /* vm_offset changed to vm_pgoff in 2.3.25 */
120 #if LINUX_VERSION_CODE < 0x020319
121 #define VM_OFFSET(vma) ((vma)->vm_offset)
122 #else
123 #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
124 #endif
126 /* *_nopage return values defined in 2.3.26 */
127 #ifndef NOPAGE_SIGBUS
128 #define NOPAGE_SIGBUS 0
129 #endif
130 #ifndef NOPAGE_OOM
131 #define NOPAGE_OOM 0
132 #endif
134 /* module_init/module_exit added in 2.3.13 */
135 #ifndef module_init
136 #define module_init(x) int init_module(void) { return x(); }
137 #endif
138 #ifndef module_exit
139 #define module_exit(x) void cleanup_module(void) { x(); }
140 #endif
142 /* virt_to_page added in 2.4.0-test6 */
143 #ifndef virt_to_page
144 #define virt_to_page(kaddr) (mem_map + MAP_NR(kaddr))
145 #endif
147 /* Generic cmpxchg added in 2.3.x */
148 #ifndef __HAVE_ARCH_CMPXCHG
149 /* Include this here so that driver can be
150 used with older kernels. */
151 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
152 unsigned long new, int size)
154 unsigned long prev;
155 switch (size) {
156 case 1:
157 __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
158 : "=a"(prev)
159 : "q"(new), "m"(*__xg(ptr)), "0"(old)
160 : "memory");
161 return prev;
162 case 2:
163 __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
164 : "=a"(prev)
165 : "q"(new), "m"(*__xg(ptr)), "0"(old)
166 : "memory");
167 return prev;
168 case 4:
169 __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
170 : "=a"(prev)
171 : "q"(new), "m"(*__xg(ptr)), "0"(old)
172 : "memory");
173 return prev;
175 return old;
178 #define cmpxchg(ptr,o,n) \
179 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \
180 (unsigned long)(n),sizeof(*(ptr))))
181 #endif
183 /* Macros to make printk easier */
184 #define DRM_ERROR(fmt, arg...) \
185 printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ "] *ERROR* " fmt , ##arg)
186 #define DRM_MEM_ERROR(area, fmt, arg...) \
187 printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ ":%s] *ERROR* " fmt , \
188 drm_mem_stats[area].name , ##arg)
189 #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
191 #if DRM_DEBUG_CODE
192 #define DRM_DEBUG(fmt, arg...) \
193 do { \
194 if (drm_flags&DRM_FLAG_DEBUG) \
195 printk(KERN_DEBUG \
196 "[" DRM_NAME ":" __FUNCTION__ "] " fmt , \
197 ##arg); \
198 } while (0)
199 #else
200 #define DRM_DEBUG(fmt, arg...) do { } while (0)
201 #endif
203 #define DRM_PROC_LIMIT (PAGE_SIZE-80)
205 #define DRM_PROC_PRINT(fmt, arg...) \
206 len += sprintf(&buf[len], fmt , ##arg); \
207 if (len > DRM_PROC_LIMIT) return len;
209 #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
210 len += sprintf(&buf[len], fmt , ##arg); \
211 if (len > DRM_PROC_LIMIT) { ret; return len; }
213 /* Internal types and structures */
214 #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
215 #define DRM_MIN(a,b) ((a)<(b)?(a):(b))
216 #define DRM_MAX(a,b) ((a)>(b)?(a):(b))
218 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
219 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
220 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
222 typedef int drm_ioctl_t(struct inode *inode, struct file *filp,
223 unsigned int cmd, unsigned long arg);
225 typedef struct drm_ioctl_desc {
226 drm_ioctl_t *func;
227 int auth_needed;
228 int root_only;
229 } drm_ioctl_desc_t;
231 typedef struct drm_devstate {
232 pid_t owner; /* X server pid holding x_lock */
234 } drm_devstate_t;
236 typedef struct drm_magic_entry {
237 drm_magic_t magic;
238 struct drm_file *priv;
239 struct drm_magic_entry *next;
240 } drm_magic_entry_t;
242 typedef struct drm_magic_head {
243 struct drm_magic_entry *head;
244 struct drm_magic_entry *tail;
245 } drm_magic_head_t;
247 typedef struct drm_vma_entry {
248 struct vm_area_struct *vma;
249 struct drm_vma_entry *next;
250 pid_t pid;
251 } drm_vma_entry_t;
253 typedef struct drm_buf {
254 int idx; /* Index into master buflist */
255 int total; /* Buffer size */
256 int order; /* log-base-2(total) */
257 int used; /* Amount of buffer in use (for DMA) */
258 unsigned long offset; /* Byte offset (used internally) */
259 void *address; /* Address of buffer */
260 unsigned long bus_address; /* Bus address of buffer */
261 struct drm_buf *next; /* Kernel-only: used for free list */
262 __volatile__ int waiting; /* On kernel DMA queue */
263 __volatile__ int pending; /* On hardware DMA queue */
264 wait_queue_head_t dma_wait; /* Processes waiting */
265 pid_t pid; /* PID of holding process */
266 int context; /* Kernel queue for this buffer */
267 int while_locked;/* Dispatch this buffer while locked */
268 enum {
269 DRM_LIST_NONE = 0,
270 DRM_LIST_FREE = 1,
271 DRM_LIST_WAIT = 2,
272 DRM_LIST_PEND = 3,
273 DRM_LIST_PRIO = 4,
274 DRM_LIST_RECLAIM = 5
275 } list; /* Which list we're on */
277 #if DRM_DMA_HISTOGRAM
278 cycles_t time_queued; /* Queued to kernel DMA queue */
279 cycles_t time_dispatched; /* Dispatched to hardware */
280 cycles_t time_completed; /* Completed by hardware */
281 cycles_t time_freed; /* Back on freelist */
282 #endif
284 int dev_priv_size; /* Size of buffer private stoarge */
285 void *dev_private; /* Per-buffer private storage */
286 } drm_buf_t;
288 #if DRM_DMA_HISTOGRAM
289 #define DRM_DMA_HISTOGRAM_SLOTS 9
290 #define DRM_DMA_HISTOGRAM_INITIAL 10
291 #define DRM_DMA_HISTOGRAM_NEXT(current) ((current)*10)
292 typedef struct drm_histogram {
293 atomic_t total;
295 atomic_t queued_to_dispatched[DRM_DMA_HISTOGRAM_SLOTS];
296 atomic_t dispatched_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
297 atomic_t completed_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
299 atomic_t queued_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
300 atomic_t queued_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
302 atomic_t dma[DRM_DMA_HISTOGRAM_SLOTS];
303 atomic_t schedule[DRM_DMA_HISTOGRAM_SLOTS];
304 atomic_t ctx[DRM_DMA_HISTOGRAM_SLOTS];
305 atomic_t lacq[DRM_DMA_HISTOGRAM_SLOTS];
306 atomic_t lhld[DRM_DMA_HISTOGRAM_SLOTS];
307 } drm_histogram_t;
308 #endif
310 /* bufs is one longer than it has to be */
311 typedef struct drm_waitlist {
312 int count; /* Number of possible buffers */
313 drm_buf_t **bufs; /* List of pointers to buffers */
314 drm_buf_t **rp; /* Read pointer */
315 drm_buf_t **wp; /* Write pointer */
316 drm_buf_t **end; /* End pointer */
317 spinlock_t read_lock;
318 spinlock_t write_lock;
319 } drm_waitlist_t;
321 typedef struct drm_freelist {
322 int initialized; /* Freelist in use */
323 atomic_t count; /* Number of free buffers */
324 drm_buf_t *next; /* End pointer */
326 wait_queue_head_t waiting; /* Processes waiting on free bufs */
327 int low_mark; /* Low water mark */
328 int high_mark; /* High water mark */
329 atomic_t wfh; /* If waiting for high mark */
330 } drm_freelist_t;
332 typedef struct drm_buf_entry {
333 int buf_size;
334 int buf_count;
335 drm_buf_t *buflist;
336 int seg_count;
337 int page_order;
338 unsigned long *seglist;
340 drm_freelist_t freelist;
341 } drm_buf_entry_t;
343 typedef struct drm_hw_lock {
344 __volatile__ unsigned int lock;
345 char padding[60]; /* Pad to cache line */
346 } drm_hw_lock_t;
348 typedef struct drm_file {
349 int authenticated;
350 int minor;
351 pid_t pid;
352 uid_t uid;
353 drm_magic_t magic;
354 unsigned long ioctl_count;
355 struct drm_file *next;
356 struct drm_file *prev;
357 struct drm_device *dev;
358 } drm_file_t;
361 typedef struct drm_queue {
362 atomic_t use_count; /* Outstanding uses (+1) */
363 atomic_t finalization; /* Finalization in progress */
364 atomic_t block_count; /* Count of processes waiting */
365 atomic_t block_read; /* Queue blocked for reads */
366 wait_queue_head_t read_queue; /* Processes waiting on block_read */
367 atomic_t block_write; /* Queue blocked for writes */
368 wait_queue_head_t write_queue; /* Processes waiting on block_write */
369 atomic_t total_queued; /* Total queued statistic */
370 atomic_t total_flushed;/* Total flushes statistic */
371 atomic_t total_locks; /* Total locks statistics */
372 drm_ctx_flags_t flags; /* Context preserving and 2D-only */
373 drm_waitlist_t waitlist; /* Pending buffers */
374 wait_queue_head_t flush_queue; /* Processes waiting until flush */
375 } drm_queue_t;
377 typedef struct drm_lock_data {
378 drm_hw_lock_t *hw_lock; /* Hardware lock */
379 pid_t pid; /* PID of lock holder (0=kernel) */
380 wait_queue_head_t lock_queue; /* Queue of blocked processes */
381 unsigned long lock_time; /* Time of last lock in jiffies */
382 } drm_lock_data_t;
384 typedef struct drm_device_dma {
385 /* Performance Counters */
386 atomic_t total_prio; /* Total DRM_DMA_PRIORITY */
387 atomic_t total_bytes; /* Total bytes DMA'd */
388 atomic_t total_dmas; /* Total DMA buffers dispatched */
390 atomic_t total_missed_dma; /* Missed drm_do_dma */
391 atomic_t total_missed_lock; /* Missed lock in drm_do_dma */
392 atomic_t total_missed_free; /* Missed drm_free_this_buffer */
393 atomic_t total_missed_sched;/* Missed drm_dma_schedule */
395 atomic_t total_tried; /* Tried next_buffer */
396 atomic_t total_hit; /* Sent next_buffer */
397 atomic_t total_lost; /* Lost interrupt */
399 drm_buf_entry_t bufs[DRM_MAX_ORDER+1];
400 int buf_count;
401 drm_buf_t **buflist; /* Vector of pointers info bufs */
402 int seg_count;
403 int page_count;
404 unsigned long *pagelist;
405 unsigned long byte_count;
406 enum {
407 _DRM_DMA_USE_AGP = 0x01
408 } flags;
410 /* DMA support */
411 drm_buf_t *this_buffer; /* Buffer being sent */
412 drm_buf_t *next_buffer; /* Selected buffer to send */
413 drm_queue_t *next_queue; /* Queue from which buffer selected*/
414 wait_queue_head_t waiting; /* Processes waiting on free bufs */
415 } drm_device_dma_t;
417 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
418 typedef struct drm_agp_mem {
419 unsigned long handle;
420 agp_memory *memory;
421 unsigned long bound; /* address */
422 int pages;
423 struct drm_agp_mem *prev;
424 struct drm_agp_mem *next;
425 } drm_agp_mem_t;
427 typedef struct drm_agp_head {
428 agp_kern_info agp_info;
429 const char *chipset;
430 drm_agp_mem_t *memory;
431 unsigned long mode;
432 int enabled;
433 int acquired;
434 unsigned long base;
435 int agp_mtrr;
436 } drm_agp_head_t;
438 typedef struct {
439 void (*free_memory)(agp_memory *);
440 agp_memory *(*allocate_memory)(size_t, u32);
441 int (*bind_memory)(agp_memory *, off_t);
442 int (*unbind_memory)(agp_memory *);
443 void (*enable)(u32);
444 int (*acquire)(void);
445 void (*release)(void);
446 void (*copy_info)(agp_kern_info *);
447 } drm_agp_func_t;
449 extern drm_agp_func_t drm_agp;
450 #endif
452 typedef struct drm_device {
453 const char *name; /* Simple driver name */
454 char *unique; /* Unique identifier: e.g., busid */
455 int unique_len; /* Length of unique field */
456 dev_t device; /* Device number for mknod */
457 char *devname; /* For /proc/interrupts */
459 int blocked; /* Blocked due to VC switch? */
460 struct proc_dir_entry *root; /* Root for this device's entries */
462 /* Locks */
463 spinlock_t count_lock; /* For inuse, open_count, buf_use */
464 struct semaphore struct_sem; /* For others */
466 /* Usage Counters */
467 int open_count; /* Outstanding files open */
468 atomic_t ioctl_count; /* Outstanding IOCTLs pending */
469 atomic_t vma_count; /* Outstanding vma areas open */
470 int buf_use; /* Buffers in use -- cannot alloc */
471 atomic_t buf_alloc; /* Buffer allocation in progress */
473 /* Performance Counters */
474 atomic_t total_open;
475 atomic_t total_close;
476 atomic_t total_ioctl;
477 atomic_t total_irq; /* Total interruptions */
478 atomic_t total_ctx; /* Total context switches */
480 atomic_t total_locks;
481 atomic_t total_unlocks;
482 atomic_t total_contends;
483 atomic_t total_sleeps;
485 /* Authentication */
486 drm_file_t *file_first;
487 drm_file_t *file_last;
488 drm_magic_head_t magiclist[DRM_HASH_SIZE];
490 /* Memory management */
491 drm_map_t **maplist; /* Vector of pointers to regions */
492 int map_count; /* Number of mappable regions */
494 drm_vma_entry_t *vmalist; /* List of vmas (for debugging) */
495 drm_lock_data_t lock; /* Information on hardware lock */
497 /* DMA queues (contexts) */
498 int queue_count; /* Number of active DMA queues */
499 int queue_reserved; /* Number of reserved DMA queues */
500 int queue_slots; /* Actual length of queuelist */
501 drm_queue_t **queuelist; /* Vector of pointers to DMA queues */
502 drm_device_dma_t *dma; /* Optional pointer for DMA support */
504 /* Context support */
505 int irq; /* Interrupt used by board */
506 __volatile__ long context_flag; /* Context swapping flag */
507 __volatile__ long interrupt_flag; /* Interruption handler flag */
508 __volatile__ long dma_flag; /* DMA dispatch flag */
509 struct timer_list timer; /* Timer for delaying ctx switch */
510 wait_queue_head_t context_wait; /* Processes waiting on ctx switch */
511 int last_checked; /* Last context checked for DMA */
512 int last_context; /* Last current context */
513 unsigned long last_switch; /* jiffies at last context switch */
514 struct tq_struct tq;
515 cycles_t ctx_start;
516 cycles_t lck_start;
517 #if DRM_DMA_HISTOGRAM
518 drm_histogram_t histo;
519 #endif
521 /* Callback to X server for context switch
522 and for heavy-handed reset. */
523 char buf[DRM_BSZ]; /* Output buffer */
524 char *buf_rp; /* Read pointer */
525 char *buf_wp; /* Write pointer */
526 char *buf_end; /* End pointer */
527 struct fasync_struct *buf_async;/* Processes waiting for SIGIO */
528 wait_queue_head_t buf_readers; /* Processes waiting to read */
529 wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */
531 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
532 drm_agp_head_t *agp;
533 #endif
534 unsigned long *ctx_bitmap;
535 void *dev_private;
536 } drm_device_t;
539 /* Internal function definitions */
541 /* Misc. support (init.c) */
542 extern int drm_flags;
543 extern void drm_parse_options(char *s);
544 extern int drm_cpu_valid(void);
547 /* Device support (fops.c) */
548 extern int drm_open_helper(struct inode *inode, struct file *filp,
549 drm_device_t *dev);
550 extern int drm_flush(struct file *filp);
551 extern int drm_release(struct inode *inode, struct file *filp);
552 extern int drm_fasync(int fd, struct file *filp, int on);
553 extern ssize_t drm_read(struct file *filp, char *buf, size_t count,
554 loff_t *off);
555 extern int drm_write_string(drm_device_t *dev, const char *s);
556 extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
558 /* Mapping support (vm.c) */
559 #if LINUX_VERSION_CODE < 0x020317
560 extern unsigned long drm_vm_nopage(struct vm_area_struct *vma,
561 unsigned long address,
562 int write_access);
563 extern unsigned long drm_vm_shm_nopage(struct vm_area_struct *vma,
564 unsigned long address,
565 int write_access);
566 extern unsigned long drm_vm_shm_nopage_lock(struct vm_area_struct *vma,
567 unsigned long address,
568 int write_access);
569 extern unsigned long drm_vm_dma_nopage(struct vm_area_struct *vma,
570 unsigned long address,
571 int write_access);
572 #else
573 /* Return type changed in 2.3.23 */
574 extern struct page *drm_vm_nopage(struct vm_area_struct *vma,
575 unsigned long address,
576 int write_access);
577 extern struct page *drm_vm_shm_nopage(struct vm_area_struct *vma,
578 unsigned long address,
579 int write_access);
580 extern struct page *drm_vm_shm_nopage_lock(struct vm_area_struct *vma,
581 unsigned long address,
582 int write_access);
583 extern struct page *drm_vm_dma_nopage(struct vm_area_struct *vma,
584 unsigned long address,
585 int write_access);
586 #endif
587 extern void drm_vm_open(struct vm_area_struct *vma);
588 extern void drm_vm_close(struct vm_area_struct *vma);
589 extern int drm_mmap_dma(struct file *filp,
590 struct vm_area_struct *vma);
591 extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
594 /* Proc support (proc.c) */
595 extern int drm_proc_init(drm_device_t *dev);
596 extern int drm_proc_cleanup(void);
598 /* Memory management support (memory.c) */
599 extern void drm_mem_init(void);
600 extern int drm_mem_info(char *buf, char **start, off_t offset,
601 int len, int *eof, void *data);
602 extern void *drm_alloc(size_t size, int area);
603 extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size,
604 int area);
605 extern char *drm_strdup(const char *s, int area);
606 extern void drm_strfree(const char *s, int area);
607 extern void drm_free(void *pt, size_t size, int area);
608 extern unsigned long drm_alloc_pages(int order, int area);
609 extern void drm_free_pages(unsigned long address, int order,
610 int area);
611 extern void *drm_ioremap(unsigned long offset, unsigned long size);
612 extern void drm_ioremapfree(void *pt, unsigned long size);
614 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
615 extern agp_memory *drm_alloc_agp(int pages, u32 type);
616 extern int drm_free_agp(agp_memory *handle, int pages);
617 extern int drm_bind_agp(agp_memory *handle, unsigned int start);
618 extern int drm_unbind_agp(agp_memory *handle);
619 #endif
622 /* Buffer management support (bufs.c) */
623 extern int drm_order(unsigned long size);
624 extern int drm_addmap(struct inode *inode, struct file *filp,
625 unsigned int cmd, unsigned long arg);
626 extern int drm_addbufs(struct inode *inode, struct file *filp,
627 unsigned int cmd, unsigned long arg);
628 extern int drm_infobufs(struct inode *inode, struct file *filp,
629 unsigned int cmd, unsigned long arg);
630 extern int drm_markbufs(struct inode *inode, struct file *filp,
631 unsigned int cmd, unsigned long arg);
632 extern int drm_freebufs(struct inode *inode, struct file *filp,
633 unsigned int cmd, unsigned long arg);
634 extern int drm_mapbufs(struct inode *inode, struct file *filp,
635 unsigned int cmd, unsigned long arg);
638 /* Buffer list management support (lists.c) */
639 extern int drm_waitlist_create(drm_waitlist_t *bl, int count);
640 extern int drm_waitlist_destroy(drm_waitlist_t *bl);
641 extern int drm_waitlist_put(drm_waitlist_t *bl, drm_buf_t *buf);
642 extern drm_buf_t *drm_waitlist_get(drm_waitlist_t *bl);
644 extern int drm_freelist_create(drm_freelist_t *bl, int count);
645 extern int drm_freelist_destroy(drm_freelist_t *bl);
646 extern int drm_freelist_put(drm_device_t *dev, drm_freelist_t *bl,
647 drm_buf_t *buf);
648 extern drm_buf_t *drm_freelist_get(drm_freelist_t *bl, int block);
650 /* DMA support (gen_dma.c) */
651 extern void drm_dma_setup(drm_device_t *dev);
652 extern void drm_dma_takedown(drm_device_t *dev);
653 extern void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
654 extern void drm_reclaim_buffers(drm_device_t *dev, pid_t pid);
655 extern int drm_context_switch(drm_device_t *dev, int old, int new);
656 extern int drm_context_switch_complete(drm_device_t *dev, int new);
657 extern void drm_clear_next_buffer(drm_device_t *dev);
658 extern int drm_select_queue(drm_device_t *dev,
659 void (*wrapper)(unsigned long));
660 extern int drm_dma_enqueue(drm_device_t *dev, drm_dma_t *dma);
661 extern int drm_dma_get_buffers(drm_device_t *dev, drm_dma_t *dma);
662 #if DRM_DMA_HISTOGRAM
663 extern int drm_histogram_slot(unsigned long count);
664 extern void drm_histogram_compute(drm_device_t *dev, drm_buf_t *buf);
665 #endif
668 /* Misc. IOCTL support (ioctl.c) */
669 extern int drm_irq_busid(struct inode *inode, struct file *filp,
670 unsigned int cmd, unsigned long arg);
671 extern int drm_getunique(struct inode *inode, struct file *filp,
672 unsigned int cmd, unsigned long arg);
673 extern int drm_setunique(struct inode *inode, struct file *filp,
674 unsigned int cmd, unsigned long arg);
677 /* Context IOCTL support (context.c) */
678 extern int drm_resctx(struct inode *inode, struct file *filp,
679 unsigned int cmd, unsigned long arg);
680 extern int drm_addctx(struct inode *inode, struct file *filp,
681 unsigned int cmd, unsigned long arg);
682 extern int drm_modctx(struct inode *inode, struct file *filp,
683 unsigned int cmd, unsigned long arg);
684 extern int drm_getctx(struct inode *inode, struct file *filp,
685 unsigned int cmd, unsigned long arg);
686 extern int drm_switchctx(struct inode *inode, struct file *filp,
687 unsigned int cmd, unsigned long arg);
688 extern int drm_newctx(struct inode *inode, struct file *filp,
689 unsigned int cmd, unsigned long arg);
690 extern int drm_rmctx(struct inode *inode, struct file *filp,
691 unsigned int cmd, unsigned long arg);
694 /* Drawable IOCTL support (drawable.c) */
695 extern int drm_adddraw(struct inode *inode, struct file *filp,
696 unsigned int cmd, unsigned long arg);
697 extern int drm_rmdraw(struct inode *inode, struct file *filp,
698 unsigned int cmd, unsigned long arg);
701 /* Authentication IOCTL support (auth.c) */
702 extern int drm_add_magic(drm_device_t *dev, drm_file_t *priv,
703 drm_magic_t magic);
704 extern int drm_remove_magic(drm_device_t *dev, drm_magic_t magic);
705 extern int drm_getmagic(struct inode *inode, struct file *filp,
706 unsigned int cmd, unsigned long arg);
707 extern int drm_authmagic(struct inode *inode, struct file *filp,
708 unsigned int cmd, unsigned long arg);
711 /* Locking IOCTL support (lock.c) */
712 extern int drm_block(struct inode *inode, struct file *filp,
713 unsigned int cmd, unsigned long arg);
714 extern int drm_unblock(struct inode *inode, struct file *filp,
715 unsigned int cmd, unsigned long arg);
716 extern int drm_lock_take(__volatile__ unsigned int *lock,
717 unsigned int context);
718 extern int drm_lock_transfer(drm_device_t *dev,
719 __volatile__ unsigned int *lock,
720 unsigned int context);
721 extern int drm_lock_free(drm_device_t *dev,
722 __volatile__ unsigned int *lock,
723 unsigned int context);
724 extern int drm_finish(struct inode *inode, struct file *filp,
725 unsigned int cmd, unsigned long arg);
726 extern int drm_flush_unblock(drm_device_t *dev, int context,
727 drm_lock_flags_t flags);
728 extern int drm_flush_block_and_flush(drm_device_t *dev, int context,
729 drm_lock_flags_t flags);
731 /* Context Bitmap support (ctxbitmap.c) */
732 extern int drm_ctxbitmap_init(drm_device_t *dev);
733 extern void drm_ctxbitmap_cleanup(drm_device_t *dev);
734 extern int drm_ctxbitmap_next(drm_device_t *dev);
735 extern void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle);
737 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
738 /* AGP/GART support (agpsupport.c) */
739 extern drm_agp_head_t *drm_agp_init(void);
740 extern void drm_agp_uninit(void);
741 extern int drm_agp_acquire(struct inode *inode, struct file *filp,
742 unsigned int cmd, unsigned long arg);
743 extern int drm_agp_release(struct inode *inode, struct file *filp,
744 unsigned int cmd, unsigned long arg);
745 extern int drm_agp_enable(struct inode *inode, struct file *filp,
746 unsigned int cmd, unsigned long arg);
747 extern int drm_agp_info(struct inode *inode, struct file *filp,
748 unsigned int cmd, unsigned long arg);
749 extern int drm_agp_alloc(struct inode *inode, struct file *filp,
750 unsigned int cmd, unsigned long arg);
751 extern int drm_agp_free(struct inode *inode, struct file *filp,
752 unsigned int cmd, unsigned long arg);
753 extern int drm_agp_unbind(struct inode *inode, struct file *filp,
754 unsigned int cmd, unsigned long arg);
755 extern int drm_agp_bind(struct inode *inode, struct file *filp,
756 unsigned int cmd, unsigned long arg);
757 #endif
758 #endif
759 #endif