- pre2
[davej-history.git] / drivers / char / drm / drmP.h
blobd6de193d2147d36400e1f51a40e67a00b01a50b5
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 <linux/mm.h>
50 #include <asm/io.h>
51 #include <asm/mman.h>
52 #include <asm/uaccess.h>
53 #ifdef CONFIG_MTRR
54 #include <asm/mtrr.h>
55 #endif
56 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
57 #include <linux/types.h>
58 #include <linux/agp_backend.h>
59 #endif
60 #if LINUX_VERSION_CODE >= 0x020100 /* KERNEL_VERSION(2,1,0) */
61 #include <linux/tqueue.h>
62 #include <linux/poll.h>
63 #endif
64 #if LINUX_VERSION_CODE < 0x020400
65 #include "compat-pre24.h"
66 #endif
67 #include "drm.h"
69 #define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then
70 also include looping detection. */
71 #define DRM_DMA_HISTOGRAM 1 /* Make histogram of DMA latency. */
73 #define DRM_HASH_SIZE 16 /* Size of key hash table */
74 #define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
75 #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
76 #define DRM_LOOPING_LIMIT 5000000
77 #define DRM_BSZ 1024 /* Buffer size for /dev/drm? output */
78 #define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
79 #define DRM_LOCK_SLICE 1 /* Time slice for lock, in jiffies */
81 #define DRM_FLAG_DEBUG 0x01
82 #define DRM_FLAG_NOCTX 0x02
84 #define DRM_MEM_DMA 0
85 #define DRM_MEM_SAREA 1
86 #define DRM_MEM_DRIVER 2
87 #define DRM_MEM_MAGIC 3
88 #define DRM_MEM_IOCTLS 4
89 #define DRM_MEM_MAPS 5
90 #define DRM_MEM_VMAS 6
91 #define DRM_MEM_BUFS 7
92 #define DRM_MEM_SEGS 8
93 #define DRM_MEM_PAGES 9
94 #define DRM_MEM_FILES 10
95 #define DRM_MEM_QUEUES 11
96 #define DRM_MEM_CMDS 12
97 #define DRM_MEM_MAPPINGS 13
98 #define DRM_MEM_BUFLISTS 14
99 #define DRM_MEM_AGPLISTS 15
100 #define DRM_MEM_TOTALAGP 16
101 #define DRM_MEM_BOUNDAGP 17
102 #define DRM_MEM_CTXBITMAP 18
104 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
106 /* Backward compatibility section */
107 /* _PAGE_WT changed to _PAGE_PWT in 2.2.6 */
108 #ifndef _PAGE_PWT
109 #define _PAGE_PWT _PAGE_WT
110 #endif
111 /* Wait queue declarations changed in 2.3.1 */
112 #ifndef DECLARE_WAITQUEUE
113 #define DECLARE_WAITQUEUE(w,c) struct wait_queue w = { c, NULL }
114 typedef struct wait_queue *wait_queue_head_t;
115 #define init_waitqueue_head(q) *q = NULL;
116 #endif
118 /* _PAGE_4M changed to _PAGE_PSE in 2.3.23 */
119 #ifndef _PAGE_PSE
120 #define _PAGE_PSE _PAGE_4M
121 #endif
123 /* vm_offset changed to vm_pgoff in 2.3.25 */
124 #if LINUX_VERSION_CODE < 0x020319
125 #define VM_OFFSET(vma) ((vma)->vm_offset)
126 #else
127 #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
128 #endif
130 /* *_nopage return values defined in 2.3.26 */
131 #ifndef NOPAGE_SIGBUS
132 #define NOPAGE_SIGBUS 0
133 #endif
134 #ifndef NOPAGE_OOM
135 #define NOPAGE_OOM 0
136 #endif
138 /* module_init/module_exit added in 2.3.13 */
139 #ifndef module_init
140 #define module_init(x) int init_module(void) { return x(); }
141 #endif
142 #ifndef module_exit
143 #define module_exit(x) void cleanup_module(void) { x(); }
144 #endif
146 /* Generic cmpxchg added in 2.3.x */
147 #ifndef __HAVE_ARCH_CMPXCHG
148 /* Include this here so that driver can be
149 used with older kernels. */
150 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
151 unsigned long new, int size)
153 unsigned long prev;
154 switch (size) {
155 case 1:
156 __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
157 : "=a"(prev)
158 : "q"(new), "m"(*__xg(ptr)), "0"(old)
159 : "memory");
160 return prev;
161 case 2:
162 __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
163 : "=a"(prev)
164 : "q"(new), "m"(*__xg(ptr)), "0"(old)
165 : "memory");
166 return prev;
167 case 4:
168 __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
169 : "=a"(prev)
170 : "q"(new), "m"(*__xg(ptr)), "0"(old)
171 : "memory");
172 return prev;
174 return old;
177 #define cmpxchg(ptr,o,n) \
178 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \
179 (unsigned long)(n),sizeof(*(ptr))))
180 #endif
182 /* Macros to make printk easier */
183 #define DRM_ERROR(fmt, arg...) \
184 printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ "] *ERROR* " fmt , ##arg)
185 #define DRM_MEM_ERROR(area, fmt, arg...) \
186 printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ ":%s] *ERROR* " fmt , \
187 drm_mem_stats[area].name , ##arg)
188 #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
190 #if DRM_DEBUG_CODE
191 #define DRM_DEBUG(fmt, arg...) \
192 do { \
193 if (drm_flags&DRM_FLAG_DEBUG) \
194 printk(KERN_DEBUG \
195 "[" DRM_NAME ":" __FUNCTION__ "] " fmt , \
196 ##arg); \
197 } while (0)
198 #else
199 #define DRM_DEBUG(fmt, arg...) do { } while (0)
200 #endif
202 #define DRM_PROC_LIMIT (PAGE_SIZE-80)
204 #define DRM_PROC_PRINT(fmt, arg...) \
205 len += sprintf(&buf[len], fmt , ##arg); \
206 if (len > DRM_PROC_LIMIT) return len;
208 #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
209 len += sprintf(&buf[len], fmt , ##arg); \
210 if (len > DRM_PROC_LIMIT) { ret; return len; }
212 /* Internal types and structures */
213 #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
214 #define DRM_MIN(a,b) ((a)<(b)?(a):(b))
215 #define DRM_MAX(a,b) ((a)>(b)?(a):(b))
217 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
218 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
219 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
221 typedef int drm_ioctl_t(struct inode *inode, struct file *filp,
222 unsigned int cmd, unsigned long arg);
224 typedef struct drm_ioctl_desc {
225 drm_ioctl_t *func;
226 int auth_needed;
227 int root_only;
228 } drm_ioctl_desc_t;
230 typedef struct drm_devstate {
231 pid_t owner; /* X server pid holding x_lock */
233 } drm_devstate_t;
235 typedef struct drm_magic_entry {
236 drm_magic_t magic;
237 struct drm_file *priv;
238 struct drm_magic_entry *next;
239 } drm_magic_entry_t;
241 typedef struct drm_magic_head {
242 struct drm_magic_entry *head;
243 struct drm_magic_entry *tail;
244 } drm_magic_head_t;
246 typedef struct drm_vma_entry {
247 struct vm_area_struct *vma;
248 struct drm_vma_entry *next;
249 pid_t pid;
250 } drm_vma_entry_t;
252 typedef struct drm_buf {
253 int idx; /* Index into master buflist */
254 int total; /* Buffer size */
255 int order; /* log-base-2(total) */
256 int used; /* Amount of buffer in use (for DMA) */
257 unsigned long offset; /* Byte offset (used internally) */
258 void *address; /* Address of buffer */
259 unsigned long bus_address; /* Bus address of buffer */
260 struct drm_buf *next; /* Kernel-only: used for free list */
261 __volatile__ int waiting; /* On kernel DMA queue */
262 __volatile__ int pending; /* On hardware DMA queue */
263 wait_queue_head_t dma_wait; /* Processes waiting */
264 pid_t pid; /* PID of holding process */
265 int context; /* Kernel queue for this buffer */
266 int while_locked;/* Dispatch this buffer while locked */
267 enum {
268 DRM_LIST_NONE = 0,
269 DRM_LIST_FREE = 1,
270 DRM_LIST_WAIT = 2,
271 DRM_LIST_PEND = 3,
272 DRM_LIST_PRIO = 4,
273 DRM_LIST_RECLAIM = 5
274 } list; /* Which list we're on */
276 #if DRM_DMA_HISTOGRAM
277 cycles_t time_queued; /* Queued to kernel DMA queue */
278 cycles_t time_dispatched; /* Dispatched to hardware */
279 cycles_t time_completed; /* Completed by hardware */
280 cycles_t time_freed; /* Back on freelist */
281 #endif
283 int dev_priv_size; /* Size of buffer private stoarge */
284 void *dev_private; /* Per-buffer private storage */
285 } drm_buf_t;
287 #if DRM_DMA_HISTOGRAM
288 #define DRM_DMA_HISTOGRAM_SLOTS 9
289 #define DRM_DMA_HISTOGRAM_INITIAL 10
290 #define DRM_DMA_HISTOGRAM_NEXT(current) ((current)*10)
291 typedef struct drm_histogram {
292 atomic_t total;
294 atomic_t queued_to_dispatched[DRM_DMA_HISTOGRAM_SLOTS];
295 atomic_t dispatched_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
296 atomic_t completed_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
298 atomic_t queued_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
299 atomic_t queued_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
301 atomic_t dma[DRM_DMA_HISTOGRAM_SLOTS];
302 atomic_t schedule[DRM_DMA_HISTOGRAM_SLOTS];
303 atomic_t ctx[DRM_DMA_HISTOGRAM_SLOTS];
304 atomic_t lacq[DRM_DMA_HISTOGRAM_SLOTS];
305 atomic_t lhld[DRM_DMA_HISTOGRAM_SLOTS];
306 } drm_histogram_t;
307 #endif
309 /* bufs is one longer than it has to be */
310 typedef struct drm_waitlist {
311 int count; /* Number of possible buffers */
312 drm_buf_t **bufs; /* List of pointers to buffers */
313 drm_buf_t **rp; /* Read pointer */
314 drm_buf_t **wp; /* Write pointer */
315 drm_buf_t **end; /* End pointer */
316 spinlock_t read_lock;
317 spinlock_t write_lock;
318 } drm_waitlist_t;
320 typedef struct drm_freelist {
321 int initialized; /* Freelist in use */
322 atomic_t count; /* Number of free buffers */
323 drm_buf_t *next; /* End pointer */
325 wait_queue_head_t waiting; /* Processes waiting on free bufs */
326 int low_mark; /* Low water mark */
327 int high_mark; /* High water mark */
328 atomic_t wfh; /* If waiting for high mark */
329 spinlock_t lock;
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_sigdata {
453 int context;
454 drm_hw_lock_t *lock;
455 } drm_sigdata_t;
457 typedef struct drm_device {
458 const char *name; /* Simple driver name */
459 char *unique; /* Unique identifier: e.g., busid */
460 int unique_len; /* Length of unique field */
461 dev_t device; /* Device number for mknod */
462 char *devname; /* For /proc/interrupts */
464 int blocked; /* Blocked due to VC switch? */
465 struct proc_dir_entry *root; /* Root for this device's entries */
467 /* Locks */
468 spinlock_t count_lock; /* For inuse, open_count, buf_use */
469 struct semaphore struct_sem; /* For others */
471 /* Usage Counters */
472 int open_count; /* Outstanding files open */
473 atomic_t ioctl_count; /* Outstanding IOCTLs pending */
474 atomic_t vma_count; /* Outstanding vma areas open */
475 int buf_use; /* Buffers in use -- cannot alloc */
476 atomic_t buf_alloc; /* Buffer allocation in progress */
478 /* Performance Counters */
479 atomic_t total_open;
480 atomic_t total_close;
481 atomic_t total_ioctl;
482 atomic_t total_irq; /* Total interruptions */
483 atomic_t total_ctx; /* Total context switches */
485 atomic_t total_locks;
486 atomic_t total_unlocks;
487 atomic_t total_contends;
488 atomic_t total_sleeps;
490 /* Authentication */
491 drm_file_t *file_first;
492 drm_file_t *file_last;
493 drm_magic_head_t magiclist[DRM_HASH_SIZE];
495 /* Memory management */
496 drm_map_t **maplist; /* Vector of pointers to regions */
497 int map_count; /* Number of mappable regions */
499 drm_vma_entry_t *vmalist; /* List of vmas (for debugging) */
500 drm_lock_data_t lock; /* Information on hardware lock */
502 /* DMA queues (contexts) */
503 int queue_count; /* Number of active DMA queues */
504 int queue_reserved; /* Number of reserved DMA queues */
505 int queue_slots; /* Actual length of queuelist */
506 drm_queue_t **queuelist; /* Vector of pointers to DMA queues */
507 drm_device_dma_t *dma; /* Optional pointer for DMA support */
509 /* Context support */
510 int irq; /* Interrupt used by board */
511 __volatile__ long context_flag; /* Context swapping flag */
512 __volatile__ long interrupt_flag; /* Interruption handler flag */
513 __volatile__ long dma_flag; /* DMA dispatch flag */
514 struct timer_list timer; /* Timer for delaying ctx switch */
515 wait_queue_head_t context_wait; /* Processes waiting on ctx switch */
516 int last_checked; /* Last context checked for DMA */
517 int last_context; /* Last current context */
518 unsigned long last_switch; /* jiffies at last context switch */
519 struct tq_struct tq;
520 cycles_t ctx_start;
521 cycles_t lck_start;
522 #if DRM_DMA_HISTOGRAM
523 drm_histogram_t histo;
524 #endif
526 /* Callback to X server for context switch
527 and for heavy-handed reset. */
528 char buf[DRM_BSZ]; /* Output buffer */
529 char *buf_rp; /* Read pointer */
530 char *buf_wp; /* Write pointer */
531 char *buf_end; /* End pointer */
532 struct fasync_struct *buf_async;/* Processes waiting for SIGIO */
533 wait_queue_head_t buf_readers; /* Processes waiting to read */
534 wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */
536 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
537 drm_agp_head_t *agp;
538 #endif
539 unsigned long *ctx_bitmap;
540 void *dev_private;
541 drm_sigdata_t sigdata; /* For block_all_signals */
542 sigset_t sigmask;
543 } drm_device_t;
546 /* Internal function definitions */
548 /* Misc. support (init.c) */
549 extern int drm_flags;
550 extern void drm_parse_options(char *s);
551 extern int drm_cpu_valid(void);
554 /* Device support (fops.c) */
555 extern int drm_open_helper(struct inode *inode, struct file *filp,
556 drm_device_t *dev);
557 extern int drm_flush(struct file *filp);
558 extern int drm_release(struct inode *inode, struct file *filp);
559 extern int drm_fasync(int fd, struct file *filp, int on);
560 extern ssize_t drm_read(struct file *filp, char *buf, size_t count,
561 loff_t *off);
562 extern int drm_write_string(drm_device_t *dev, const char *s);
563 extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
565 /* Mapping support (vm.c) */
566 #if LINUX_VERSION_CODE < 0x020317
567 extern unsigned long drm_vm_nopage(struct vm_area_struct *vma,
568 unsigned long address,
569 int write_access);
570 extern unsigned long drm_vm_shm_nopage(struct vm_area_struct *vma,
571 unsigned long address,
572 int write_access);
573 extern unsigned long drm_vm_shm_nopage_lock(struct vm_area_struct *vma,
574 unsigned long address,
575 int write_access);
576 extern unsigned long drm_vm_dma_nopage(struct vm_area_struct *vma,
577 unsigned long address,
578 int write_access);
579 #else
580 /* Return type changed in 2.3.23 */
581 extern struct page *drm_vm_nopage(struct vm_area_struct *vma,
582 unsigned long address,
583 int write_access);
584 extern struct page *drm_vm_shm_nopage(struct vm_area_struct *vma,
585 unsigned long address,
586 int write_access);
587 extern struct page *drm_vm_shm_nopage_lock(struct vm_area_struct *vma,
588 unsigned long address,
589 int write_access);
590 extern struct page *drm_vm_dma_nopage(struct vm_area_struct *vma,
591 unsigned long address,
592 int write_access);
593 #endif
594 extern void drm_vm_open(struct vm_area_struct *vma);
595 extern void drm_vm_close(struct vm_area_struct *vma);
596 extern int drm_mmap_dma(struct file *filp,
597 struct vm_area_struct *vma);
598 extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
601 /* Proc support (proc.c) */
602 extern int drm_proc_init(drm_device_t *dev);
603 extern int drm_proc_cleanup(void);
605 /* Memory management support (memory.c) */
606 extern void drm_mem_init(void);
607 extern int drm_mem_info(char *buf, char **start, off_t offset,
608 int len, int *eof, void *data);
609 extern void *drm_alloc(size_t size, int area);
610 extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size,
611 int area);
612 extern char *drm_strdup(const char *s, int area);
613 extern void drm_strfree(const char *s, int area);
614 extern void drm_free(void *pt, size_t size, int area);
615 extern unsigned long drm_alloc_pages(int order, int area);
616 extern void drm_free_pages(unsigned long address, int order,
617 int area);
618 extern void *drm_ioremap(unsigned long offset, unsigned long size);
619 extern void drm_ioremapfree(void *pt, unsigned long size);
621 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
622 extern agp_memory *drm_alloc_agp(int pages, u32 type);
623 extern int drm_free_agp(agp_memory *handle, int pages);
624 extern int drm_bind_agp(agp_memory *handle, unsigned int start);
625 extern int drm_unbind_agp(agp_memory *handle);
626 #endif
629 /* Buffer management support (bufs.c) */
630 extern int drm_order(unsigned long size);
631 extern int drm_addmap(struct inode *inode, struct file *filp,
632 unsigned int cmd, unsigned long arg);
633 extern int drm_addbufs(struct inode *inode, struct file *filp,
634 unsigned int cmd, unsigned long arg);
635 extern int drm_infobufs(struct inode *inode, struct file *filp,
636 unsigned int cmd, unsigned long arg);
637 extern int drm_markbufs(struct inode *inode, struct file *filp,
638 unsigned int cmd, unsigned long arg);
639 extern int drm_freebufs(struct inode *inode, struct file *filp,
640 unsigned int cmd, unsigned long arg);
641 extern int drm_mapbufs(struct inode *inode, struct file *filp,
642 unsigned int cmd, unsigned long arg);
645 /* Buffer list management support (lists.c) */
646 extern int drm_waitlist_create(drm_waitlist_t *bl, int count);
647 extern int drm_waitlist_destroy(drm_waitlist_t *bl);
648 extern int drm_waitlist_put(drm_waitlist_t *bl, drm_buf_t *buf);
649 extern drm_buf_t *drm_waitlist_get(drm_waitlist_t *bl);
651 extern int drm_freelist_create(drm_freelist_t *bl, int count);
652 extern int drm_freelist_destroy(drm_freelist_t *bl);
653 extern int drm_freelist_put(drm_device_t *dev, drm_freelist_t *bl,
654 drm_buf_t *buf);
655 extern drm_buf_t *drm_freelist_get(drm_freelist_t *bl, int block);
657 /* DMA support (gen_dma.c) */
658 extern void drm_dma_setup(drm_device_t *dev);
659 extern void drm_dma_takedown(drm_device_t *dev);
660 extern void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
661 extern void drm_reclaim_buffers(drm_device_t *dev, pid_t pid);
662 extern int drm_context_switch(drm_device_t *dev, int old, int new);
663 extern int drm_context_switch_complete(drm_device_t *dev, int new);
664 extern void drm_clear_next_buffer(drm_device_t *dev);
665 extern int drm_select_queue(drm_device_t *dev,
666 void (*wrapper)(unsigned long));
667 extern int drm_dma_enqueue(drm_device_t *dev, drm_dma_t *dma);
668 extern int drm_dma_get_buffers(drm_device_t *dev, drm_dma_t *dma);
669 #if DRM_DMA_HISTOGRAM
670 extern int drm_histogram_slot(unsigned long count);
671 extern void drm_histogram_compute(drm_device_t *dev, drm_buf_t *buf);
672 #endif
675 /* Misc. IOCTL support (ioctl.c) */
676 extern int drm_irq_busid(struct inode *inode, struct file *filp,
677 unsigned int cmd, unsigned long arg);
678 extern int drm_getunique(struct inode *inode, struct file *filp,
679 unsigned int cmd, unsigned long arg);
680 extern int drm_setunique(struct inode *inode, struct file *filp,
681 unsigned int cmd, unsigned long arg);
684 /* Context IOCTL support (context.c) */
685 extern int drm_resctx(struct inode *inode, struct file *filp,
686 unsigned int cmd, unsigned long arg);
687 extern int drm_addctx(struct inode *inode, struct file *filp,
688 unsigned int cmd, unsigned long arg);
689 extern int drm_modctx(struct inode *inode, struct file *filp,
690 unsigned int cmd, unsigned long arg);
691 extern int drm_getctx(struct inode *inode, struct file *filp,
692 unsigned int cmd, unsigned long arg);
693 extern int drm_switchctx(struct inode *inode, struct file *filp,
694 unsigned int cmd, unsigned long arg);
695 extern int drm_newctx(struct inode *inode, struct file *filp,
696 unsigned int cmd, unsigned long arg);
697 extern int drm_rmctx(struct inode *inode, struct file *filp,
698 unsigned int cmd, unsigned long arg);
701 /* Drawable IOCTL support (drawable.c) */
702 extern int drm_adddraw(struct inode *inode, struct file *filp,
703 unsigned int cmd, unsigned long arg);
704 extern int drm_rmdraw(struct inode *inode, struct file *filp,
705 unsigned int cmd, unsigned long arg);
708 /* Authentication IOCTL support (auth.c) */
709 extern int drm_add_magic(drm_device_t *dev, drm_file_t *priv,
710 drm_magic_t magic);
711 extern int drm_remove_magic(drm_device_t *dev, drm_magic_t magic);
712 extern int drm_getmagic(struct inode *inode, struct file *filp,
713 unsigned int cmd, unsigned long arg);
714 extern int drm_authmagic(struct inode *inode, struct file *filp,
715 unsigned int cmd, unsigned long arg);
718 /* Locking IOCTL support (lock.c) */
719 extern int drm_block(struct inode *inode, struct file *filp,
720 unsigned int cmd, unsigned long arg);
721 extern int drm_unblock(struct inode *inode, struct file *filp,
722 unsigned int cmd, unsigned long arg);
723 extern int drm_lock_take(__volatile__ unsigned int *lock,
724 unsigned int context);
725 extern int drm_lock_transfer(drm_device_t *dev,
726 __volatile__ unsigned int *lock,
727 unsigned int context);
728 extern int drm_lock_free(drm_device_t *dev,
729 __volatile__ unsigned int *lock,
730 unsigned int context);
731 extern int drm_finish(struct inode *inode, struct file *filp,
732 unsigned int cmd, unsigned long arg);
733 extern int drm_flush_unblock(drm_device_t *dev, int context,
734 drm_lock_flags_t flags);
735 extern int drm_flush_block_and_flush(drm_device_t *dev, int context,
736 drm_lock_flags_t flags);
737 extern int drm_notifier(void *priv);
739 /* Context Bitmap support (ctxbitmap.c) */
740 extern int drm_ctxbitmap_init(drm_device_t *dev);
741 extern void drm_ctxbitmap_cleanup(drm_device_t *dev);
742 extern int drm_ctxbitmap_next(drm_device_t *dev);
743 extern void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle);
745 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
746 /* AGP/GART support (agpsupport.c) */
747 extern drm_agp_head_t *drm_agp_init(void);
748 extern void drm_agp_uninit(void);
749 extern int drm_agp_acquire(struct inode *inode, struct file *filp,
750 unsigned int cmd, unsigned long arg);
751 extern int drm_agp_release(struct inode *inode, struct file *filp,
752 unsigned int cmd, unsigned long arg);
753 extern int drm_agp_enable(struct inode *inode, struct file *filp,
754 unsigned int cmd, unsigned long arg);
755 extern int drm_agp_info(struct inode *inode, struct file *filp,
756 unsigned int cmd, unsigned long arg);
757 extern int drm_agp_alloc(struct inode *inode, struct file *filp,
758 unsigned int cmd, unsigned long arg);
759 extern int drm_agp_free(struct inode *inode, struct file *filp,
760 unsigned int cmd, unsigned long arg);
761 extern int drm_agp_unbind(struct inode *inode, struct file *filp,
762 unsigned int cmd, unsigned long arg);
763 extern int drm_agp_bind(struct inode *inode, struct file *filp,
764 unsigned int cmd, unsigned long arg);
765 #endif
766 #endif
767 #endif