1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#ifndef _DRM_P_H_
33#define _DRM_P_H_
34
35#ifdef __KERNEL__
36#ifdef __alpha__
37
38
39
40#include <asm/current.h>
41#endif
42#include <linux/config.h>
43#include <linux/module.h>
44#include <linux/kernel.h>
45#include <linux/miscdevice.h>
46#include <linux/fs.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/wrapper.h>
52#include <linux/version.h>
53#include <linux/sched.h>
54#include <linux/smp_lock.h>
55#include <asm/system.h>
56#include <linux/mm.h>
57#include <linux/pagemap.h>
58#if defined(__alpha__) || defined(__powerpc__)
59#include <asm/pgtable.h>
60#endif
61#include <asm/io.h>
62#include <asm/mman.h>
63#include <asm/uaccess.h>
64#ifdef CONFIG_MTRR
65#include <asm/mtrr.h>
66#endif
67#if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
68#include <linux/types.h>
69#include <linux/agp_backend.h>
70#endif
71#include <linux/tqueue.h>
72#include <linux/poll.h>
73#include <asm/pgalloc.h>
74#include "drm.h"
75
76#include "drm_os_linux.h"
77
78
79
80#ifndef __HAVE_AGP
81#define __HAVE_AGP 0
82#endif
83#ifndef __HAVE_MTRR
84#define __HAVE_MTRR 0
85#endif
86#ifndef __HAVE_CTX_BITMAP
87#define __HAVE_CTX_BITMAP 0
88#endif
89#ifndef __HAVE_DMA
90#define __HAVE_DMA 0
91#endif
92#ifndef __HAVE_DMA_IRQ
93#define __HAVE_DMA_IRQ 0
94#endif
95#ifndef __HAVE_DMA_WAITLIST
96#define __HAVE_DMA_WAITLIST 0
97#endif
98#ifndef __HAVE_DMA_FREELIST
99#define __HAVE_DMA_FREELIST 0
100#endif
101#ifndef __HAVE_DMA_HISTOGRAM
102#define __HAVE_DMA_HISTOGRAM 0
103#endif
104
105#define __REALLY_HAVE_AGP (__HAVE_AGP && (defined(CONFIG_AGP) || \
106 defined(CONFIG_AGP_MODULE)))
107#define __REALLY_HAVE_MTRR (__HAVE_MTRR && defined(CONFIG_MTRR))
108
109
110
111#ifndef __HAVE_ARCH_CMPXCHG
112
113
114#if defined(__alpha__)
115static __inline__ unsigned long
116__cmpxchg_u32(volatile int *m, int old, int new)
117{
118 unsigned long prev, cmp;
119
120 __asm__ __volatile__(
121 "1: ldl_l %0,%2\n"
122 " cmpeq %0,%3,%1\n"
123 " beq %1,2f\n"
124 " mov %4,%1\n"
125 " stl_c %1,%2\n"
126 " beq %1,3f\n"
127 "2: mb\n"
128 ".subsection 2\n"
129 "3: br 1b\n"
130 ".previous"
131 : "=&r"(prev), "=&r"(cmp), "=m"(*m)
132 : "r"((long) old), "r"(new), "m"(*m));
133
134 return prev;
135}
136
137static __inline__ unsigned long
138__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
139{
140 unsigned long prev, cmp;
141
142 __asm__ __volatile__(
143 "1: ldq_l %0,%2\n"
144 " cmpeq %0,%3,%1\n"
145 " beq %1,2f\n"
146 " mov %4,%1\n"
147 " stq_c %1,%2\n"
148 " beq %1,3f\n"
149 "2: mb\n"
150 ".subsection 2\n"
151 "3: br 1b\n"
152 ".previous"
153 : "=&r"(prev), "=&r"(cmp), "=m"(*m)
154 : "r"((long) old), "r"(new), "m"(*m));
155
156 return prev;
157}
158
159static __inline__ unsigned long
160__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
161{
162 switch (size) {
163 case 4:
164 return __cmpxchg_u32(ptr, old, new);
165 case 8:
166 return __cmpxchg_u64(ptr, old, new);
167 }
168 return old;
169}
170#define cmpxchg(ptr,o,n) \
171 ({ \
172 __typeof__(*(ptr)) _o_ = (o); \
173 __typeof__(*(ptr)) _n_ = (n); \
174 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
175 (unsigned long)_n_, sizeof(*(ptr))); \
176 })
177
178#endif
179#endif
180#define __REALLY_HAVE_SG (__HAVE_SG)
181
182
183
184
185#define DRM_DEBUG_CODE 2
186
187
188#define DRM_HASH_SIZE 16
189#define DRM_KERNEL_CONTEXT 0
190#define DRM_RESERVED_CONTEXTS 1
191#define DRM_LOOPING_LIMIT 5000000
192#define DRM_BSZ 1024
193#define DRM_TIME_SLICE (HZ/20)
194#define DRM_LOCK_SLICE 1
195
196#define DRM_FLAG_DEBUG 0x01
197#define DRM_FLAG_NOCTX 0x02
198
199#define DRM_MEM_DMA 0
200#define DRM_MEM_SAREA 1
201#define DRM_MEM_DRIVER 2
202#define DRM_MEM_MAGIC 3
203#define DRM_MEM_IOCTLS 4
204#define DRM_MEM_MAPS 5
205#define DRM_MEM_VMAS 6
206#define DRM_MEM_BUFS 7
207#define DRM_MEM_SEGS 8
208#define DRM_MEM_PAGES 9
209#define DRM_MEM_FILES 10
210#define DRM_MEM_QUEUES 11
211#define DRM_MEM_CMDS 12
212#define DRM_MEM_MAPPINGS 13
213#define DRM_MEM_BUFLISTS 14
214#define DRM_MEM_AGPLISTS 15
215#define DRM_MEM_TOTALAGP 16
216#define DRM_MEM_BOUNDAGP 17
217#define DRM_MEM_CTXBITMAP 18
218#define DRM_MEM_STUB 19
219#define DRM_MEM_SGLISTS 20
220
221#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
222
223
224#ifndef minor
225#define minor(x) MINOR((x))
226#endif
227
228#ifndef MODULE_LICENSE
229#define MODULE_LICENSE(x)
230#endif
231
232
233#ifndef pte_offset_map
234#define pte_offset_map pte_offset
235#define pte_unmap(pte)
236#endif
237
238#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19)
239static inline struct page * vmalloc_to_page(void * vmalloc_addr)
240{
241 unsigned long addr = (unsigned long) vmalloc_addr;
242 struct page *page = NULL;
243 pgd_t *pgd = pgd_offset_k(addr);
244 pmd_t *pmd;
245 pte_t *ptep, pte;
246
247 if (!pgd_none(*pgd)) {
248 pmd = pmd_offset(pgd, addr);
249 if (!pmd_none(*pmd)) {
250 ptep = pte_offset_map(pmd, addr);
251 pte = *ptep;
252 if (pte_present(pte))
253 page = pte_page(pte);
254 pte_unmap(ptep);
255 }
256 }
257 return page;
258}
259#endif
260
261#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
262#define DRM_RPR_ARG(vma)
263#else
264#define DRM_RPR_ARG(vma) vma,
265#endif
266
267
268#define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
269
270
271#define DRM_ERROR(fmt, arg...) \
272 printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg)
273#define DRM_MEM_ERROR(area, fmt, arg...) \
274 printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \
275 DRM(mem_stats)[area].name , ##arg)
276#define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
277
278#if DRM_DEBUG_CODE
279#define DRM_DEBUG(fmt, arg...) \
280 do { \
281 if ( DRM(flags) & DRM_FLAG_DEBUG ) \
282 printk(KERN_DEBUG \
283 "[" DRM_NAME ":%s] " fmt , \
284 __FUNCTION__ , ##arg); \
285 } while (0)
286#else
287#define DRM_DEBUG(fmt, arg...) do { } while (0)
288#endif
289
290#define DRM_PROC_LIMIT (PAGE_SIZE-80)
291
292#define DRM_PROC_PRINT(fmt, arg...) \
293 len += sprintf(&buf[len], fmt , ##arg); \
294 if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; }
295
296#define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
297 len += sprintf(&buf[len], fmt , ##arg); \
298 if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }
299
300
301#define DRM_IOREMAP(map, dev) \
302 (map)->handle = DRM(ioremap)((map)->offset, (map)->size, (dev) )
303
304#define DRM_IOREMAP_NOCACHE(map, dev) \
305 (map)->handle = DRM(ioremap_nocache)((map)->offset, (map)->size, (dev) )
306
307#define DRM_IOREMAPFREE(map, dev) \
308 do { \
309 if ( (map)->handle && (map)->size ) \
310 DRM(ioremapfree)( (map)->handle, (map)->size, (dev) ); \
311 } while (0)
312
313#define DRM_FIND_MAP(_map, _o) \
314do { \
315 struct list_head *_list; \
316 list_for_each( _list, &dev->maplist->head ) { \
317 drm_map_list_t *_entry = (drm_map_list_t *)_list; \
318 if ( _entry->map && \
319 _entry->map->offset == (_o) ) { \
320 (_map) = _entry->map; \
321 break; \
322 } \
323 } \
324} while(0)
325
326
327#define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
328#define DRM_MIN(a,b) ((a)<(b)?(a):(b))
329#define DRM_MAX(a,b) ((a)>(b)?(a):(b))
330
331#define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
332#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
333#define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
334
335#define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
336 (_map) = (_dev)->context_sareas[_ctx]; \
337} while(0)
338
339typedef int drm_ioctl_t( struct inode *inode, struct file *filp,
340 unsigned int cmd, unsigned long arg );
341
342typedef struct drm_pci_list {
343 u16 vendor;
344 u16 device;
345} drm_pci_list_t;
346
347typedef struct drm_ioctl_desc {
348 drm_ioctl_t *func;
349 int auth_needed;
350 int root_only;
351} drm_ioctl_desc_t;
352
353typedef struct drm_devstate {
354 pid_t owner;
355
356} drm_devstate_t;
357
358typedef struct drm_magic_entry {
359 drm_magic_t magic;
360 struct drm_file *priv;
361 struct drm_magic_entry *next;
362} drm_magic_entry_t;
363
364typedef struct drm_magic_head {
365 struct drm_magic_entry *head;
366 struct drm_magic_entry *tail;
367} drm_magic_head_t;
368
369typedef struct drm_vma_entry {
370 struct vm_area_struct *vma;
371 struct drm_vma_entry *next;
372 pid_t pid;
373} drm_vma_entry_t;
374
375typedef struct drm_buf {
376 int idx;
377 int total;
378 int order;
379 int used;
380 unsigned long offset;
381 void *address;
382 unsigned long bus_address;
383 struct drm_buf *next;
384 __volatile__ int waiting;
385 __volatile__ int pending;
386 wait_queue_head_t dma_wait;
387 pid_t pid;
388 int context;
389 int while_locked;
390 enum {
391 DRM_LIST_NONE = 0,
392 DRM_LIST_FREE = 1,
393 DRM_LIST_WAIT = 2,
394 DRM_LIST_PEND = 3,
395 DRM_LIST_PRIO = 4,
396 DRM_LIST_RECLAIM = 5
397 } list;
398
399#if DRM_DMA_HISTOGRAM
400 cycles_t time_queued;
401 cycles_t time_dispatched;
402 cycles_t time_completed;
403 cycles_t time_freed;
404#endif
405
406 int dev_priv_size;
407 void *dev_private;
408} drm_buf_t;
409
410#if DRM_DMA_HISTOGRAM
411#define DRM_DMA_HISTOGRAM_SLOTS 9
412#define DRM_DMA_HISTOGRAM_INITIAL 10
413#define DRM_DMA_HISTOGRAM_NEXT(current) ((current)*10)
414typedef struct drm_histogram {
415 atomic_t total;
416
417 atomic_t queued_to_dispatched[DRM_DMA_HISTOGRAM_SLOTS];
418 atomic_t dispatched_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
419 atomic_t completed_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
420
421 atomic_t queued_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
422 atomic_t queued_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
423
424 atomic_t dma[DRM_DMA_HISTOGRAM_SLOTS];
425 atomic_t schedule[DRM_DMA_HISTOGRAM_SLOTS];
426 atomic_t ctx[DRM_DMA_HISTOGRAM_SLOTS];
427 atomic_t lacq[DRM_DMA_HISTOGRAM_SLOTS];
428 atomic_t lhld[DRM_DMA_HISTOGRAM_SLOTS];
429} drm_histogram_t;
430#endif
431
432
433typedef struct drm_waitlist {
434 int count;
435 drm_buf_t **bufs;
436 drm_buf_t **rp;
437 drm_buf_t **wp;
438 drm_buf_t **end;
439 spinlock_t read_lock;
440 spinlock_t write_lock;
441} drm_waitlist_t;
442
443typedef struct drm_freelist {
444 int initialized;
445 atomic_t count;
446 drm_buf_t *next;
447
448 wait_queue_head_t waiting;
449 int low_mark;
450 int high_mark;
451 atomic_t wfh;
452 spinlock_t lock;
453} drm_freelist_t;
454
455typedef struct drm_buf_entry {
456 int buf_size;
457 int buf_count;
458 drm_buf_t *buflist;
459 int seg_count;
460 int page_order;
461 unsigned long *seglist;
462
463 drm_freelist_t freelist;
464} drm_buf_entry_t;
465
466typedef struct drm_hw_lock {
467 __volatile__ unsigned int lock;
468 char padding[60];
469} drm_hw_lock_t;
470
471typedef struct drm_file {
472 int authenticated;
473 int minor;
474 pid_t pid;
475 uid_t uid;
476 drm_magic_t magic;
477 unsigned long ioctl_count;
478 struct drm_file *next;
479 struct drm_file *prev;
480 struct drm_device *dev;
481 int remove_auth_on_close;
482} drm_file_t;
483
484
485typedef struct drm_queue {
486 atomic_t use_count;
487 atomic_t finalization;
488 atomic_t block_count;
489 atomic_t block_read;
490 wait_queue_head_t read_queue;
491 atomic_t block_write;
492 wait_queue_head_t write_queue;
493#if 1
494 atomic_t total_queued;
495 atomic_t total_flushed;
496 atomic_t total_locks;
497#endif
498 drm_ctx_flags_t flags;
499 drm_waitlist_t waitlist;
500 wait_queue_head_t flush_queue;
501} drm_queue_t;
502
503typedef struct drm_lock_data {
504 drm_hw_lock_t *hw_lock;
505 pid_t pid;
506 wait_queue_head_t lock_queue;
507 unsigned long lock_time;
508} drm_lock_data_t;
509
510typedef struct drm_device_dma {
511#if 0
512
513 atomic_t total_prio;
514 atomic_t total_bytes;
515 atomic_t total_dmas;
516
517 atomic_t total_missed_dma;
518 atomic_t total_missed_lock;
519 atomic_t total_missed_free;
520 atomic_t total_missed_sched;
521
522 atomic_t total_tried;
523 atomic_t total_hit;
524 atomic_t total_lost;
525#endif
526
527 drm_buf_entry_t bufs[DRM_MAX_ORDER+1];
528 int buf_count;
529 drm_buf_t **buflist;
530 int seg_count;
531 int page_count;
532 unsigned long *pagelist;
533 unsigned long byte_count;
534 enum {
535 _DRM_DMA_USE_AGP = 0x01,
536 _DRM_DMA_USE_SG = 0x02
537 } flags;
538
539
540 drm_buf_t *this_buffer;
541 drm_buf_t *next_buffer;
542 drm_queue_t *next_queue;
543 wait_queue_head_t waiting;
544} drm_device_dma_t;
545
546#if __REALLY_HAVE_AGP
547typedef struct drm_agp_mem {
548 unsigned long handle;
549 agp_memory *memory;
550 unsigned long bound;
551 int pages;
552 struct drm_agp_mem *prev;
553 struct drm_agp_mem *next;
554} drm_agp_mem_t;
555
556typedef struct drm_agp_head {
557 agp_kern_info agp_info;
558 const char *chipset;
559 drm_agp_mem_t *memory;
560 unsigned long mode;
561 int enabled;
562 int acquired;
563 unsigned long base;
564 int agp_mtrr;
565 int cant_use_aperture;
566 unsigned long page_mask;
567} drm_agp_head_t;
568#endif
569
570typedef struct drm_sg_mem {
571 unsigned long handle;
572 void *virtual;
573 int pages;
574 struct page **pagelist;
575 dma_addr_t *busaddr;
576} drm_sg_mem_t;
577
578typedef struct drm_sigdata {
579 int context;
580 drm_hw_lock_t *lock;
581} drm_sigdata_t;
582
583typedef struct drm_map_list {
584 struct list_head head;
585 drm_map_t *map;
586} drm_map_list_t;
587
588#if __HAVE_VBL_IRQ
589
590typedef struct drm_vbl_sig {
591 struct list_head head;
592 unsigned int sequence;
593 struct siginfo info;
594 struct task_struct *task;
595} drm_vbl_sig_t;
596
597#endif
598
599typedef struct drm_device {
600 const char *name;
601 char *unique;
602 int unique_len;
603 dev_t device;
604 char *devname;
605
606 int blocked;
607 struct proc_dir_entry *root;
608
609
610 spinlock_t count_lock;
611 struct semaphore struct_sem;
612
613
614 int open_count;
615 atomic_t ioctl_count;
616 atomic_t vma_count;
617 int buf_use;
618 atomic_t buf_alloc;
619
620
621 unsigned long counters;
622 drm_stat_type_t types[15];
623 atomic_t counts[15];
624
625
626 drm_file_t *file_first;
627 drm_file_t *file_last;
628 drm_magic_head_t magiclist[DRM_HASH_SIZE];
629
630
631 drm_map_list_t *maplist;
632 int map_count;
633
634 drm_map_t **context_sareas;
635 int max_context;
636
637 drm_vma_entry_t *vmalist;
638 drm_lock_data_t lock;
639
640
641 int queue_count;
642 int queue_reserved;
643 int queue_slots;
644 drm_queue_t **queuelist;
645 drm_device_dma_t *dma;
646
647
648 int irq;
649 __volatile__ long context_flag;
650 __volatile__ long interrupt_flag;
651 __volatile__ long dma_flag;
652 struct timer_list timer;
653 wait_queue_head_t context_wait;
654 int last_checked;
655 int last_context;
656 unsigned long last_switch;
657 struct tq_struct tq;
658#if __HAVE_VBL_IRQ
659 wait_queue_head_t vbl_queue;
660 atomic_t vbl_received;
661 spinlock_t vbl_lock;
662 drm_vbl_sig_t vbl_sigs;
663 unsigned int vbl_pending;
664#endif
665 cycles_t ctx_start;
666 cycles_t lck_start;
667#if __HAVE_DMA_HISTOGRAM
668 drm_histogram_t histo;
669#endif
670
671
672
673 char buf[DRM_BSZ];
674 char *buf_rp;
675 char *buf_wp;
676 char *buf_end;
677 struct fasync_struct *buf_async;
678 wait_queue_head_t buf_readers;
679 wait_queue_head_t buf_writers;
680
681#if __REALLY_HAVE_AGP
682 drm_agp_head_t *agp;
683#endif
684 struct pci_dev *pdev;
685#ifdef __alpha__
686 struct pci_controller *hose;
687#endif
688 drm_sg_mem_t *sg;
689 unsigned long *ctx_bitmap;
690 void *dev_private;
691 drm_sigdata_t sigdata;
692 sigset_t sigmask;
693} drm_device_t;
694
695
696
697
698
699
700
701extern int DRM(flags);
702extern void DRM(parse_options)( char *s );
703extern int DRM(cpu_valid)( void );
704
705
706extern int DRM(version)(struct inode *inode, struct file *filp,
707 unsigned int cmd, unsigned long arg);
708extern int DRM(open)(struct inode *inode, struct file *filp);
709extern int DRM(release)(struct inode *inode, struct file *filp);
710extern int DRM(ioctl)(struct inode *inode, struct file *filp,
711 unsigned int cmd, unsigned long arg);
712extern int DRM(lock)(struct inode *inode, struct file *filp,
713 unsigned int cmd, unsigned long arg);
714extern int DRM(unlock)(struct inode *inode, struct file *filp,
715 unsigned int cmd, unsigned long arg);
716
717
718extern int DRM(open_helper)(struct inode *inode, struct file *filp,
719 drm_device_t *dev);
720extern int DRM(flush)(struct file *filp);
721extern int DRM(release_fuck)(struct inode *inode, struct file *filp);
722extern int DRM(fasync)(int fd, struct file *filp, int on);
723extern ssize_t DRM(read)(struct file *filp, char *buf, size_t count,
724 loff_t *off);
725extern int DRM(write_string)(drm_device_t *dev, const char *s);
726extern unsigned int DRM(poll)(struct file *filp,
727 struct poll_table_struct *wait);
728
729
730extern struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
731 unsigned long address,
732 int write_access);
733extern struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
734 unsigned long address,
735 int write_access);
736extern struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
737 unsigned long address,
738 int write_access);
739extern struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma,
740 unsigned long address,
741 int write_access);
742extern void DRM(vm_open)(struct vm_area_struct *vma);
743extern void DRM(vm_close)(struct vm_area_struct *vma);
744extern void DRM(vm_shm_close)(struct vm_area_struct *vma);
745extern int DRM(mmap_dma)(struct file *filp,
746 struct vm_area_struct *vma);
747extern int DRM(mmap)(struct file *filp, struct vm_area_struct *vma);
748
749
750extern void DRM(mem_init)(void);
751extern int DRM(mem_info)(char *buf, char **start, off_t offset,
752 int request, int *eof, void *data);
753extern void *DRM(alloc)(size_t size, int area);
754extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
755 int area);
756extern char *DRM(strdup)(const char *s, int area);
757extern void DRM(strfree)(const char *s, int area);
758extern void DRM(free)(void *pt, size_t size, int area);
759extern unsigned long DRM(alloc_pages)(int order, int area);
760extern void DRM(free_pages)(unsigned long address, int order,
761 int area);
762extern void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev);
763extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, drm_device_t *dev);
764extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev);
765
766#if __REALLY_HAVE_AGP
767extern agp_memory *DRM(alloc_agp)(int pages, u32 type);
768extern int DRM(free_agp)(agp_memory *handle, int pages);
769extern int DRM(bind_agp)(agp_memory *handle, unsigned int start);
770extern int DRM(unbind_agp)(agp_memory *handle);
771#endif
772
773
774extern int DRM(irq_busid)(struct inode *inode, struct file *filp,
775 unsigned int cmd, unsigned long arg);
776extern int DRM(getunique)(struct inode *inode, struct file *filp,
777 unsigned int cmd, unsigned long arg);
778extern int DRM(setunique)(struct inode *inode, struct file *filp,
779 unsigned int cmd, unsigned long arg);
780extern int DRM(getmap)(struct inode *inode, struct file *filp,
781 unsigned int cmd, unsigned long arg);
782extern int DRM(getclient)(struct inode *inode, struct file *filp,
783 unsigned int cmd, unsigned long arg);
784extern int DRM(getstats)(struct inode *inode, struct file *filp,
785 unsigned int cmd, unsigned long arg);
786
787
788extern int DRM(resctx)( struct inode *inode, struct file *filp,
789 unsigned int cmd, unsigned long arg );
790extern int DRM(addctx)( struct inode *inode, struct file *filp,
791 unsigned int cmd, unsigned long arg );
792extern int DRM(modctx)( struct inode *inode, struct file *filp,
793 unsigned int cmd, unsigned long arg );
794extern int DRM(getctx)( struct inode *inode, struct file *filp,
795 unsigned int cmd, unsigned long arg );
796extern int DRM(switchctx)( struct inode *inode, struct file *filp,
797 unsigned int cmd, unsigned long arg );
798extern int DRM(newctx)( struct inode *inode, struct file *filp,
799 unsigned int cmd, unsigned long arg );
800extern int DRM(rmctx)( struct inode *inode, struct file *filp,
801 unsigned int cmd, unsigned long arg );
802
803extern int DRM(context_switch)(drm_device_t *dev, int old, int new);
804extern int DRM(context_switch_complete)(drm_device_t *dev, int new);
805
806#if __HAVE_CTX_BITMAP
807extern int DRM(ctxbitmap_init)( drm_device_t *dev );
808extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev );
809#endif
810
811extern int DRM(setsareactx)( struct inode *inode, struct file *filp,
812 unsigned int cmd, unsigned long arg );
813extern int DRM(getsareactx)( struct inode *inode, struct file *filp,
814 unsigned int cmd, unsigned long arg );
815
816
817extern int DRM(adddraw)(struct inode *inode, struct file *filp,
818 unsigned int cmd, unsigned long arg);
819extern int DRM(rmdraw)(struct inode *inode, struct file *filp,
820 unsigned int cmd, unsigned long arg);
821
822
823
824extern int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv,
825 drm_magic_t magic);
826extern int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic);
827extern int DRM(getmagic)(struct inode *inode, struct file *filp,
828 unsigned int cmd, unsigned long arg);
829extern int DRM(authmagic)(struct inode *inode, struct file *filp,
830 unsigned int cmd, unsigned long arg);
831
832
833
834extern int DRM(block)(struct inode *inode, struct file *filp,
835 unsigned int cmd, unsigned long arg);
836extern int DRM(unblock)(struct inode *inode, struct file *filp,
837 unsigned int cmd, unsigned long arg);
838extern int DRM(lock_take)(__volatile__ unsigned int *lock,
839 unsigned int context);
840extern int DRM(lock_transfer)(drm_device_t *dev,
841 __volatile__ unsigned int *lock,
842 unsigned int context);
843extern int DRM(lock_free)(drm_device_t *dev,
844 __volatile__ unsigned int *lock,
845 unsigned int context);
846extern int DRM(finish)(struct inode *inode, struct file *filp,
847 unsigned int cmd, unsigned long arg);
848extern int DRM(flush_unblock)(drm_device_t *dev, int context,
849 drm_lock_flags_t flags);
850extern int DRM(flush_block_and_flush)(drm_device_t *dev, int context,
851 drm_lock_flags_t flags);
852extern int DRM(notifier)(void *priv);
853
854
855extern int DRM(order)( unsigned long size );
856extern int DRM(addmap)( struct inode *inode, struct file *filp,
857 unsigned int cmd, unsigned long arg );
858extern int DRM(rmmap)( struct inode *inode, struct file *filp,
859 unsigned int cmd, unsigned long arg );
860#if __HAVE_DMA
861extern int DRM(addbufs)( struct inode *inode, struct file *filp,
862 unsigned int cmd, unsigned long arg );
863extern int DRM(infobufs)( struct inode *inode, struct file *filp,
864 unsigned int cmd, unsigned long arg );
865extern int DRM(markbufs)( struct inode *inode, struct file *filp,
866 unsigned int cmd, unsigned long arg );
867extern int DRM(freebufs)( struct inode *inode, struct file *filp,
868 unsigned int cmd, unsigned long arg );
869extern int DRM(mapbufs)( struct inode *inode, struct file *filp,
870 unsigned int cmd, unsigned long arg );
871
872
873extern int DRM(dma_setup)(drm_device_t *dev);
874extern void DRM(dma_takedown)(drm_device_t *dev);
875extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
876extern void DRM(reclaim_buffers)(drm_device_t *dev, pid_t pid);
877#if __HAVE_OLD_DMA
878
879
880extern void DRM(clear_next_buffer)(drm_device_t *dev);
881extern int DRM(select_queue)(drm_device_t *dev,
882 void (*wrapper)(unsigned long));
883extern int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *dma);
884extern int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma);
885#endif
886#if __HAVE_DMA_IRQ
887extern int DRM(control)( struct inode *inode, struct file *filp,
888 unsigned int cmd, unsigned long arg );
889extern int DRM(irq_install)( drm_device_t *dev, int irq );
890extern int DRM(irq_uninstall)( drm_device_t *dev );
891extern void DRM(dma_service)( int irq, void *device,
892 struct pt_regs *regs );
893extern void DRM(driver_irq_preinstall)( drm_device_t *dev );
894extern void DRM(driver_irq_postinstall)( drm_device_t *dev );
895extern void DRM(driver_irq_uninstall)( drm_device_t *dev );
896#if __HAVE_VBL_IRQ
897extern int DRM(wait_vblank)(struct inode *inode, struct file *filp,
898 unsigned int cmd, unsigned long arg);
899extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
900extern void DRM(vbl_send_signals)( drm_device_t *dev );
901#endif
902#if __HAVE_DMA_IRQ_BH
903extern void DRM(dma_immediate_bh)( void *dev );
904#endif
905#endif
906#if DRM_DMA_HISTOGRAM
907extern int DRM(histogram_slot)(unsigned long count);
908extern void DRM(histogram_compute)(drm_device_t *dev, drm_buf_t *buf);
909#endif
910
911
912#if __HAVE_DMA_WAITLIST
913extern int DRM(waitlist_create)(drm_waitlist_t *bl, int count);
914extern int DRM(waitlist_destroy)(drm_waitlist_t *bl);
915extern int DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf);
916extern drm_buf_t *DRM(waitlist_get)(drm_waitlist_t *bl);
917#endif
918#if __HAVE_DMA_FREELIST
919extern int DRM(freelist_create)(drm_freelist_t *bl, int count);
920extern int DRM(freelist_destroy)(drm_freelist_t *bl);
921extern int DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl,
922 drm_buf_t *buf);
923extern drm_buf_t *DRM(freelist_get)(drm_freelist_t *bl, int block);
924#endif
925#endif
926
927#if __REALLY_HAVE_AGP
928
929extern drm_agp_head_t *DRM(agp_init)(void);
930extern void DRM(agp_uninit)(void);
931extern int DRM(agp_acquire)(struct inode *inode, struct file *filp,
932 unsigned int cmd, unsigned long arg);
933extern void DRM(agp_do_release)(void);
934extern int DRM(agp_release)(struct inode *inode, struct file *filp,
935 unsigned int cmd, unsigned long arg);
936extern int DRM(agp_enable)(struct inode *inode, struct file *filp,
937 unsigned int cmd, unsigned long arg);
938extern int DRM(agp_info)(struct inode *inode, struct file *filp,
939 unsigned int cmd, unsigned long arg);
940extern int DRM(agp_alloc)(struct inode *inode, struct file *filp,
941 unsigned int cmd, unsigned long arg);
942extern int DRM(agp_free)(struct inode *inode, struct file *filp,
943 unsigned int cmd, unsigned long arg);
944extern int DRM(agp_unbind)(struct inode *inode, struct file *filp,
945 unsigned int cmd, unsigned long arg);
946extern int DRM(agp_bind)(struct inode *inode, struct file *filp,
947 unsigned int cmd, unsigned long arg);
948extern agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type);
949extern int DRM(agp_free_memory)(agp_memory *handle);
950extern int DRM(agp_bind_memory)(agp_memory *handle, off_t start);
951extern int DRM(agp_unbind_memory)(agp_memory *handle);
952#endif
953
954
955int DRM(stub_register)(const char *name,
956 struct file_operations *fops,
957 drm_device_t *dev);
958int DRM(stub_unregister)(int minor);
959
960
961extern struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev,
962 int minor,
963 struct proc_dir_entry *root,
964 struct proc_dir_entry **dev_root);
965extern int DRM(proc_cleanup)(int minor,
966 struct proc_dir_entry *root,
967 struct proc_dir_entry *dev_root);
968
969#if __HAVE_SG
970
971extern void DRM(sg_cleanup)(drm_sg_mem_t *entry);
972extern int DRM(sg_alloc)(struct inode *inode, struct file *filp,
973 unsigned int cmd, unsigned long arg);
974extern int DRM(sg_free)(struct inode *inode, struct file *filp,
975 unsigned int cmd, unsigned long arg);
976#endif
977
978
979extern int DRM(ati_pcigart_init)(drm_device_t *dev,
980 unsigned long *addr,
981 dma_addr_t *bus_addr);
982extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev,
983 unsigned long addr,
984 dma_addr_t bus_addr);
985
986#endif
987#endif
988