1 /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
2 * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * 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.
28 * Rickard E. (Rik) Faith <faith@valinux.com>
37 /* add include of current.h so that "current" is defined
38 * before static inline funcs in wait.h. Doing this so we
39 * can build the DRM (part of PI DRI). 4/21/2000 S + B */
40 #include <asm/current.h>
41 #endif /* __alpha__ */
42 #include <linux/config.h>
43 #include <linux/module.h>
44 #include <linux/kernel.h>
45 #include <linux/miscdevice.h>
47 #include <linux/proc_fs.h>
48 #include <linux/init.h>
49 #include <linux/file.h>
50 #include <linux/pci.h>
51 #include <linux/wrapper.h>
52 #include <linux/version.h>
53 #include <linux/sched.h>
54 #include <linux/smp_lock.h> /* For (un)lock_kernel */
57 #include <asm/pgtable.h> /* For pte_wrprotect */
61 #include <asm/uaccess.h>
65 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
66 #include <linux/types.h>
67 #include <linux/agp_backend.h>
69 #if LINUX_VERSION_CODE >= 0x020100 /* KERNEL_VERSION(2,1,0) */
70 #include <linux/tqueue.h>
71 #include <linux/poll.h>
73 #if LINUX_VERSION_CODE < 0x020400
74 #include "compat-pre24.h"
78 #define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then
79 also include looping detection. */
80 #define DRM_DMA_HISTOGRAM 1 /* Make histogram of DMA latency. */
82 #define DRM_HASH_SIZE 16 /* Size of key hash table */
83 #define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
84 #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
85 #define DRM_LOOPING_LIMIT 5000000
86 #define DRM_BSZ 1024 /* Buffer size for /dev/drm? output */
87 #define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
88 #define DRM_LOCK_SLICE 1 /* Time slice for lock, in jiffies */
90 #define DRM_FLAG_DEBUG 0x01
91 #define DRM_FLAG_NOCTX 0x02
94 #define DRM_MEM_SAREA 1
95 #define DRM_MEM_DRIVER 2
96 #define DRM_MEM_MAGIC 3
97 #define DRM_MEM_IOCTLS 4
98 #define DRM_MEM_MAPS 5
99 #define DRM_MEM_VMAS 6
100 #define DRM_MEM_BUFS 7
101 #define DRM_MEM_SEGS 8
102 #define DRM_MEM_PAGES 9
103 #define DRM_MEM_FILES 10
104 #define DRM_MEM_QUEUES 11
105 #define DRM_MEM_CMDS 12
106 #define DRM_MEM_MAPPINGS 13
107 #define DRM_MEM_BUFLISTS 14
108 #define DRM_MEM_AGPLISTS 15
109 #define DRM_MEM_TOTALAGP 16
110 #define DRM_MEM_BOUNDAGP 17
111 #define DRM_MEM_CTXBITMAP 18
113 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
115 /* Backward compatibility section */
116 /* _PAGE_WT changed to _PAGE_PWT in 2.2.6 */
118 #define _PAGE_PWT _PAGE_WT
120 /* Wait queue declarations changed in 2.3.1 */
121 #ifndef DECLARE_WAITQUEUE
122 #define DECLARE_WAITQUEUE(w,c) struct wait_queue w = { c, NULL }
123 typedef struct wait_queue
*wait_queue_head_t
;
124 #define init_waitqueue_head(q) *q = NULL;
127 /* _PAGE_4M changed to _PAGE_PSE in 2.3.23 */
129 #define _PAGE_PSE _PAGE_4M
132 /* vm_offset changed to vm_pgoff in 2.3.25 */
133 #if LINUX_VERSION_CODE < 0x020319
134 #define VM_OFFSET(vma) ((vma)->vm_offset)
136 #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
139 /* *_nopage return values defined in 2.3.26 */
140 #ifndef NOPAGE_SIGBUS
141 #define NOPAGE_SIGBUS 0
147 /* module_init/module_exit added in 2.3.13 */
149 #define module_init(x) int init_module(void) { return x(); }
152 #define module_exit(x) void cleanup_module(void) { x(); }
155 /* Generic cmpxchg added in 2.3.x */
156 #ifndef __HAVE_ARCH_CMPXCHG
157 /* Include this here so that driver can be
158 used with older kernels. */
159 #if defined(__alpha__)
160 static __inline__
unsigned long
161 __cmpxchg_u32(volatile int *m
, int old
, int new)
163 unsigned long prev
, cmp
;
165 __asm__
__volatile__(
176 : "=&r"(prev
), "=&r"(cmp
), "=m"(*m
)
177 : "r"((long) old
), "r"(new), "m"(*m
));
182 static __inline__
unsigned long
183 __cmpxchg_u64(volatile long *m
, unsigned long old
, unsigned long new)
185 unsigned long prev
, cmp
;
187 __asm__
__volatile__(
198 : "=&r"(prev
), "=&r"(cmp
), "=m"(*m
)
199 : "r"((long) old
), "r"(new), "m"(*m
));
204 static __inline__
unsigned long
205 __cmpxchg(volatile void *ptr
, unsigned long old
, unsigned long new, int size
)
209 return __cmpxchg_u32(ptr
, old
, new);
211 return __cmpxchg_u64(ptr
, old
, new);
215 #define cmpxchg(ptr,o,n) \
217 __typeof__(*(ptr)) _o_ = (o); \
218 __typeof__(*(ptr)) _n_ = (n); \
219 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
220 (unsigned long)_n_, sizeof(*(ptr))); \
224 static inline unsigned long __cmpxchg(volatile void *ptr
, unsigned long old
,
225 unsigned long new, int size
)
230 __asm__
__volatile__(LOCK_PREFIX
"cmpxchgb %b1,%2"
232 : "q"(new), "m"(*__xg(ptr
)), "0"(old
)
236 __asm__
__volatile__(LOCK_PREFIX
"cmpxchgw %w1,%2"
238 : "q"(new), "m"(*__xg(ptr
)), "0"(old
)
242 __asm__
__volatile__(LOCK_PREFIX
"cmpxchgl %1,%2"
244 : "q"(new), "m"(*__xg(ptr
)), "0"(old
)
251 #define cmpxchg(ptr,o,n) \
252 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \
253 (unsigned long)(n),sizeof(*(ptr))))
254 #endif /* i386 & alpha */
257 /* Macros to make printk easier */
258 #define DRM_ERROR(fmt, arg...) \
259 printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ "] *ERROR* " fmt , ##arg)
260 #define DRM_MEM_ERROR(area, fmt, arg...) \
261 printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ ":%s] *ERROR* " fmt , \
262 drm_mem_stats[area].name , ##arg)
263 #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
266 #define DRM_DEBUG(fmt, arg...) \
268 if (drm_flags&DRM_FLAG_DEBUG) \
270 "[" DRM_NAME ":" __FUNCTION__ "] " fmt , \
274 #define DRM_DEBUG(fmt, arg...) do { } while (0)
277 #define DRM_PROC_LIMIT (PAGE_SIZE-80)
279 #define DRM_PROC_PRINT(fmt, arg...) \
280 len += sprintf(&buf[len], fmt , ##arg); \
281 if (len > DRM_PROC_LIMIT) return len;
283 #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
284 len += sprintf(&buf[len], fmt , ##arg); \
285 if (len > DRM_PROC_LIMIT) { ret; return len; }
287 /* Internal types and structures */
288 #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
289 #define DRM_MIN(a,b) ((a)<(b)?(a):(b))
290 #define DRM_MAX(a,b) ((a)>(b)?(a):(b))
292 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
293 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
294 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
296 typedef int drm_ioctl_t(struct inode
*inode
, struct file
*filp
,
297 unsigned int cmd
, unsigned long arg
);
299 typedef struct drm_ioctl_desc
{
305 typedef struct drm_devstate
{
306 pid_t owner
; /* X server pid holding x_lock */
310 typedef struct drm_magic_entry
{
312 struct drm_file
*priv
;
313 struct drm_magic_entry
*next
;
316 typedef struct drm_magic_head
{
317 struct drm_magic_entry
*head
;
318 struct drm_magic_entry
*tail
;
321 typedef struct drm_vma_entry
{
322 struct vm_area_struct
*vma
;
323 struct drm_vma_entry
*next
;
327 typedef struct drm_buf
{
328 int idx
; /* Index into master buflist */
329 int total
; /* Buffer size */
330 int order
; /* log-base-2(total) */
331 int used
; /* Amount of buffer in use (for DMA) */
332 unsigned long offset
; /* Byte offset (used internally) */
333 void *address
; /* Address of buffer */
334 unsigned long bus_address
; /* Bus address of buffer */
335 struct drm_buf
*next
; /* Kernel-only: used for free list */
336 __volatile__
int waiting
; /* On kernel DMA queue */
337 __volatile__
int pending
; /* On hardware DMA queue */
338 wait_queue_head_t dma_wait
; /* Processes waiting */
339 pid_t pid
; /* PID of holding process */
340 int context
; /* Kernel queue for this buffer */
341 int while_locked
;/* Dispatch this buffer while locked */
349 } list
; /* Which list we're on */
351 #if DRM_DMA_HISTOGRAM
352 cycles_t time_queued
; /* Queued to kernel DMA queue */
353 cycles_t time_dispatched
; /* Dispatched to hardware */
354 cycles_t time_completed
; /* Completed by hardware */
355 cycles_t time_freed
; /* Back on freelist */
358 int dev_priv_size
; /* Size of buffer private stoarge */
359 void *dev_private
; /* Per-buffer private storage */
362 #if DRM_DMA_HISTOGRAM
363 #define DRM_DMA_HISTOGRAM_SLOTS 9
364 #define DRM_DMA_HISTOGRAM_INITIAL 10
365 #define DRM_DMA_HISTOGRAM_NEXT(current) ((current)*10)
366 typedef struct drm_histogram
{
369 atomic_t queued_to_dispatched
[DRM_DMA_HISTOGRAM_SLOTS
];
370 atomic_t dispatched_to_completed
[DRM_DMA_HISTOGRAM_SLOTS
];
371 atomic_t completed_to_freed
[DRM_DMA_HISTOGRAM_SLOTS
];
373 atomic_t queued_to_completed
[DRM_DMA_HISTOGRAM_SLOTS
];
374 atomic_t queued_to_freed
[DRM_DMA_HISTOGRAM_SLOTS
];
376 atomic_t dma
[DRM_DMA_HISTOGRAM_SLOTS
];
377 atomic_t schedule
[DRM_DMA_HISTOGRAM_SLOTS
];
378 atomic_t ctx
[DRM_DMA_HISTOGRAM_SLOTS
];
379 atomic_t lacq
[DRM_DMA_HISTOGRAM_SLOTS
];
380 atomic_t lhld
[DRM_DMA_HISTOGRAM_SLOTS
];
384 /* bufs is one longer than it has to be */
385 typedef struct drm_waitlist
{
386 int count
; /* Number of possible buffers */
387 drm_buf_t
**bufs
; /* List of pointers to buffers */
388 drm_buf_t
**rp
; /* Read pointer */
389 drm_buf_t
**wp
; /* Write pointer */
390 drm_buf_t
**end
; /* End pointer */
391 spinlock_t read_lock
;
392 spinlock_t write_lock
;
395 typedef struct drm_freelist
{
396 int initialized
; /* Freelist in use */
397 atomic_t count
; /* Number of free buffers */
398 drm_buf_t
*next
; /* End pointer */
400 wait_queue_head_t waiting
; /* Processes waiting on free bufs */
401 int low_mark
; /* Low water mark */
402 int high_mark
; /* High water mark */
403 atomic_t wfh
; /* If waiting for high mark */
407 typedef struct drm_buf_entry
{
413 unsigned long *seglist
;
415 drm_freelist_t freelist
;
418 typedef struct drm_hw_lock
{
419 __volatile__
unsigned int lock
;
420 char padding
[60]; /* Pad to cache line */
423 typedef struct drm_file
{
429 unsigned long ioctl_count
;
430 struct drm_file
*next
;
431 struct drm_file
*prev
;
432 struct drm_device
*dev
;
436 typedef struct drm_queue
{
437 atomic_t use_count
; /* Outstanding uses (+1) */
438 atomic_t finalization
; /* Finalization in progress */
439 atomic_t block_count
; /* Count of processes waiting */
440 atomic_t block_read
; /* Queue blocked for reads */
441 wait_queue_head_t read_queue
; /* Processes waiting on block_read */
442 atomic_t block_write
; /* Queue blocked for writes */
443 wait_queue_head_t write_queue
; /* Processes waiting on block_write */
444 atomic_t total_queued
; /* Total queued statistic */
445 atomic_t total_flushed
;/* Total flushes statistic */
446 atomic_t total_locks
; /* Total locks statistics */
447 drm_ctx_flags_t flags
; /* Context preserving and 2D-only */
448 drm_waitlist_t waitlist
; /* Pending buffers */
449 wait_queue_head_t flush_queue
; /* Processes waiting until flush */
452 typedef struct drm_lock_data
{
453 drm_hw_lock_t
*hw_lock
; /* Hardware lock */
454 pid_t pid
; /* PID of lock holder (0=kernel) */
455 wait_queue_head_t lock_queue
; /* Queue of blocked processes */
456 unsigned long lock_time
; /* Time of last lock in jiffies */
459 typedef struct drm_device_dma
{
460 /* Performance Counters */
461 atomic_t total_prio
; /* Total DRM_DMA_PRIORITY */
462 atomic_t total_bytes
; /* Total bytes DMA'd */
463 atomic_t total_dmas
; /* Total DMA buffers dispatched */
465 atomic_t total_missed_dma
; /* Missed drm_do_dma */
466 atomic_t total_missed_lock
; /* Missed lock in drm_do_dma */
467 atomic_t total_missed_free
; /* Missed drm_free_this_buffer */
468 atomic_t total_missed_sched
;/* Missed drm_dma_schedule */
470 atomic_t total_tried
; /* Tried next_buffer */
471 atomic_t total_hit
; /* Sent next_buffer */
472 atomic_t total_lost
; /* Lost interrupt */
474 drm_buf_entry_t bufs
[DRM_MAX_ORDER
+1];
476 drm_buf_t
**buflist
; /* Vector of pointers info bufs */
479 unsigned long *pagelist
;
480 unsigned long byte_count
;
482 _DRM_DMA_USE_AGP
= 0x01
486 drm_buf_t
*this_buffer
; /* Buffer being sent */
487 drm_buf_t
*next_buffer
; /* Selected buffer to send */
488 drm_queue_t
*next_queue
; /* Queue from which buffer selected*/
489 wait_queue_head_t waiting
; /* Processes waiting on free bufs */
492 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
493 typedef struct drm_agp_mem
{
494 unsigned long handle
;
496 unsigned long bound
; /* address */
498 struct drm_agp_mem
*prev
;
499 struct drm_agp_mem
*next
;
502 typedef struct drm_agp_head
{
503 agp_kern_info agp_info
;
505 drm_agp_mem_t
*memory
;
514 void (*free_memory
)(agp_memory
*);
515 agp_memory
*(*allocate_memory
)(size_t, u32
);
516 int (*bind_memory
)(agp_memory
*, off_t
);
517 int (*unbind_memory
)(agp_memory
*);
519 int (*acquire
)(void);
520 void (*release
)(void);
521 void (*copy_info
)(agp_kern_info
*);
524 extern drm_agp_func_t drm_agp
;
527 typedef struct drm_sigdata
{
532 typedef struct drm_device
{
533 const char *name
; /* Simple driver name */
534 char *unique
; /* Unique identifier: e.g., busid */
535 int unique_len
; /* Length of unique field */
536 dev_t device
; /* Device number for mknod */
537 char *devname
; /* For /proc/interrupts */
539 int blocked
; /* Blocked due to VC switch? */
540 struct proc_dir_entry
*root
; /* Root for this device's entries */
543 spinlock_t count_lock
; /* For inuse, open_count, buf_use */
544 struct semaphore struct_sem
; /* For others */
547 int open_count
; /* Outstanding files open */
548 atomic_t ioctl_count
; /* Outstanding IOCTLs pending */
549 atomic_t vma_count
; /* Outstanding vma areas open */
550 int buf_use
; /* Buffers in use -- cannot alloc */
551 atomic_t buf_alloc
; /* Buffer allocation in progress */
553 /* Performance Counters */
555 atomic_t total_close
;
556 atomic_t total_ioctl
;
557 atomic_t total_irq
; /* Total interruptions */
558 atomic_t total_ctx
; /* Total context switches */
560 atomic_t total_locks
;
561 atomic_t total_unlocks
;
562 atomic_t total_contends
;
563 atomic_t total_sleeps
;
566 drm_file_t
*file_first
;
567 drm_file_t
*file_last
;
568 drm_magic_head_t magiclist
[DRM_HASH_SIZE
];
570 /* Memory management */
571 drm_map_t
**maplist
; /* Vector of pointers to regions */
572 int map_count
; /* Number of mappable regions */
574 drm_vma_entry_t
*vmalist
; /* List of vmas (for debugging) */
575 drm_lock_data_t lock
; /* Information on hardware lock */
577 /* DMA queues (contexts) */
578 int queue_count
; /* Number of active DMA queues */
579 int queue_reserved
; /* Number of reserved DMA queues */
580 int queue_slots
; /* Actual length of queuelist */
581 drm_queue_t
**queuelist
; /* Vector of pointers to DMA queues */
582 drm_device_dma_t
*dma
; /* Optional pointer for DMA support */
584 /* Context support */
585 int irq
; /* Interrupt used by board */
586 __volatile__
long context_flag
; /* Context swapping flag */
587 __volatile__
long interrupt_flag
; /* Interruption handler flag */
588 __volatile__
long dma_flag
; /* DMA dispatch flag */
589 struct timer_list timer
; /* Timer for delaying ctx switch */
590 wait_queue_head_t context_wait
; /* Processes waiting on ctx switch */
591 int last_checked
; /* Last context checked for DMA */
592 int last_context
; /* Last current context */
593 unsigned long last_switch
; /* jiffies at last context switch */
597 #if DRM_DMA_HISTOGRAM
598 drm_histogram_t histo
;
601 /* Callback to X server for context switch
602 and for heavy-handed reset. */
603 char buf
[DRM_BSZ
]; /* Output buffer */
604 char *buf_rp
; /* Read pointer */
605 char *buf_wp
; /* Write pointer */
606 char *buf_end
; /* End pointer */
607 struct fasync_struct
*buf_async
;/* Processes waiting for SIGIO */
608 wait_queue_head_t buf_readers
; /* Processes waiting to read */
609 wait_queue_head_t buf_writers
; /* Processes waiting to ctx switch */
611 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
614 unsigned long *ctx_bitmap
;
616 drm_sigdata_t sigdata
; /* For block_all_signals */
621 /* Internal function definitions */
623 /* Misc. support (init.c) */
624 extern int drm_flags
;
625 extern void drm_parse_options(char *s
);
626 extern int drm_cpu_valid(void);
629 /* Device support (fops.c) */
630 extern int drm_open_helper(struct inode
*inode
, struct file
*filp
,
632 extern int drm_flush(struct file
*filp
);
633 extern int drm_release(struct inode
*inode
, struct file
*filp
);
634 extern int drm_fasync(int fd
, struct file
*filp
, int on
);
635 extern ssize_t
drm_read(struct file
*filp
, char *buf
, size_t count
,
637 extern int drm_write_string(drm_device_t
*dev
, const char *s
);
638 extern unsigned int drm_poll(struct file
*filp
, struct poll_table_struct
*wait
);
640 /* Mapping support (vm.c) */
641 #if LINUX_VERSION_CODE < 0x020317
642 extern unsigned long drm_vm_nopage(struct vm_area_struct
*vma
,
643 unsigned long address
,
645 extern unsigned long drm_vm_shm_nopage(struct vm_area_struct
*vma
,
646 unsigned long address
,
648 extern unsigned long drm_vm_shm_nopage_lock(struct vm_area_struct
*vma
,
649 unsigned long address
,
651 extern unsigned long drm_vm_dma_nopage(struct vm_area_struct
*vma
,
652 unsigned long address
,
655 /* Return type changed in 2.3.23 */
656 extern struct page
*drm_vm_nopage(struct vm_area_struct
*vma
,
657 unsigned long address
,
659 extern struct page
*drm_vm_shm_nopage(struct vm_area_struct
*vma
,
660 unsigned long address
,
662 extern struct page
*drm_vm_shm_nopage_lock(struct vm_area_struct
*vma
,
663 unsigned long address
,
665 extern struct page
*drm_vm_dma_nopage(struct vm_area_struct
*vma
,
666 unsigned long address
,
669 extern void drm_vm_open(struct vm_area_struct
*vma
);
670 extern void drm_vm_close(struct vm_area_struct
*vma
);
671 extern int drm_mmap_dma(struct file
*filp
,
672 struct vm_area_struct
*vma
);
673 extern int drm_mmap(struct file
*filp
, struct vm_area_struct
*vma
);
676 /* Proc support (proc.c) */
677 extern int drm_proc_init(drm_device_t
*dev
);
678 extern int drm_proc_cleanup(void);
680 /* Memory management support (memory.c) */
681 extern void drm_mem_init(void);
682 extern int drm_mem_info(char *buf
, char **start
, off_t offset
,
683 int len
, int *eof
, void *data
);
684 extern void *drm_alloc(size_t size
, int area
);
685 extern void *drm_realloc(void *oldpt
, size_t oldsize
, size_t size
,
687 extern char *drm_strdup(const char *s
, int area
);
688 extern void drm_strfree(const char *s
, int area
);
689 extern void drm_free(void *pt
, size_t size
, int area
);
690 extern unsigned long drm_alloc_pages(int order
, int area
);
691 extern void drm_free_pages(unsigned long address
, int order
,
693 extern void *drm_ioremap(unsigned long offset
, unsigned long size
);
694 extern void drm_ioremapfree(void *pt
, unsigned long size
);
696 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
697 extern agp_memory
*drm_alloc_agp(int pages
, u32 type
);
698 extern int drm_free_agp(agp_memory
*handle
, int pages
);
699 extern int drm_bind_agp(agp_memory
*handle
, unsigned int start
);
700 extern int drm_unbind_agp(agp_memory
*handle
);
704 /* Buffer management support (bufs.c) */
705 extern int drm_order(unsigned long size
);
706 extern int drm_addmap(struct inode
*inode
, struct file
*filp
,
707 unsigned int cmd
, unsigned long arg
);
708 extern int drm_addbufs(struct inode
*inode
, struct file
*filp
,
709 unsigned int cmd
, unsigned long arg
);
710 extern int drm_infobufs(struct inode
*inode
, struct file
*filp
,
711 unsigned int cmd
, unsigned long arg
);
712 extern int drm_markbufs(struct inode
*inode
, struct file
*filp
,
713 unsigned int cmd
, unsigned long arg
);
714 extern int drm_freebufs(struct inode
*inode
, struct file
*filp
,
715 unsigned int cmd
, unsigned long arg
);
716 extern int drm_mapbufs(struct inode
*inode
, struct file
*filp
,
717 unsigned int cmd
, unsigned long arg
);
720 /* Buffer list management support (lists.c) */
721 extern int drm_waitlist_create(drm_waitlist_t
*bl
, int count
);
722 extern int drm_waitlist_destroy(drm_waitlist_t
*bl
);
723 extern int drm_waitlist_put(drm_waitlist_t
*bl
, drm_buf_t
*buf
);
724 extern drm_buf_t
*drm_waitlist_get(drm_waitlist_t
*bl
);
726 extern int drm_freelist_create(drm_freelist_t
*bl
, int count
);
727 extern int drm_freelist_destroy(drm_freelist_t
*bl
);
728 extern int drm_freelist_put(drm_device_t
*dev
, drm_freelist_t
*bl
,
730 extern drm_buf_t
*drm_freelist_get(drm_freelist_t
*bl
, int block
);
732 /* DMA support (gen_dma.c) */
733 extern void drm_dma_setup(drm_device_t
*dev
);
734 extern void drm_dma_takedown(drm_device_t
*dev
);
735 extern void drm_free_buffer(drm_device_t
*dev
, drm_buf_t
*buf
);
736 extern void drm_reclaim_buffers(drm_device_t
*dev
, pid_t pid
);
737 extern int drm_context_switch(drm_device_t
*dev
, int old
, int new);
738 extern int drm_context_switch_complete(drm_device_t
*dev
, int new);
739 extern void drm_clear_next_buffer(drm_device_t
*dev
);
740 extern int drm_select_queue(drm_device_t
*dev
,
741 void (*wrapper
)(unsigned long));
742 extern int drm_dma_enqueue(drm_device_t
*dev
, drm_dma_t
*dma
);
743 extern int drm_dma_get_buffers(drm_device_t
*dev
, drm_dma_t
*dma
);
744 #if DRM_DMA_HISTOGRAM
745 extern int drm_histogram_slot(unsigned long count
);
746 extern void drm_histogram_compute(drm_device_t
*dev
, drm_buf_t
*buf
);
750 /* Misc. IOCTL support (ioctl.c) */
751 extern int drm_irq_busid(struct inode
*inode
, struct file
*filp
,
752 unsigned int cmd
, unsigned long arg
);
753 extern int drm_getunique(struct inode
*inode
, struct file
*filp
,
754 unsigned int cmd
, unsigned long arg
);
755 extern int drm_setunique(struct inode
*inode
, struct file
*filp
,
756 unsigned int cmd
, unsigned long arg
);
759 /* Context IOCTL support (context.c) */
760 extern int drm_resctx(struct inode
*inode
, struct file
*filp
,
761 unsigned int cmd
, unsigned long arg
);
762 extern int drm_addctx(struct inode
*inode
, struct file
*filp
,
763 unsigned int cmd
, unsigned long arg
);
764 extern int drm_modctx(struct inode
*inode
, struct file
*filp
,
765 unsigned int cmd
, unsigned long arg
);
766 extern int drm_getctx(struct inode
*inode
, struct file
*filp
,
767 unsigned int cmd
, unsigned long arg
);
768 extern int drm_switchctx(struct inode
*inode
, struct file
*filp
,
769 unsigned int cmd
, unsigned long arg
);
770 extern int drm_newctx(struct inode
*inode
, struct file
*filp
,
771 unsigned int cmd
, unsigned long arg
);
772 extern int drm_rmctx(struct inode
*inode
, struct file
*filp
,
773 unsigned int cmd
, unsigned long arg
);
776 /* Drawable IOCTL support (drawable.c) */
777 extern int drm_adddraw(struct inode
*inode
, struct file
*filp
,
778 unsigned int cmd
, unsigned long arg
);
779 extern int drm_rmdraw(struct inode
*inode
, struct file
*filp
,
780 unsigned int cmd
, unsigned long arg
);
783 /* Authentication IOCTL support (auth.c) */
784 extern int drm_add_magic(drm_device_t
*dev
, drm_file_t
*priv
,
786 extern int drm_remove_magic(drm_device_t
*dev
, drm_magic_t magic
);
787 extern int drm_getmagic(struct inode
*inode
, struct file
*filp
,
788 unsigned int cmd
, unsigned long arg
);
789 extern int drm_authmagic(struct inode
*inode
, struct file
*filp
,
790 unsigned int cmd
, unsigned long arg
);
793 /* Locking IOCTL support (lock.c) */
794 extern int drm_block(struct inode
*inode
, struct file
*filp
,
795 unsigned int cmd
, unsigned long arg
);
796 extern int drm_unblock(struct inode
*inode
, struct file
*filp
,
797 unsigned int cmd
, unsigned long arg
);
798 extern int drm_lock_take(__volatile__
unsigned int *lock
,
799 unsigned int context
);
800 extern int drm_lock_transfer(drm_device_t
*dev
,
801 __volatile__
unsigned int *lock
,
802 unsigned int context
);
803 extern int drm_lock_free(drm_device_t
*dev
,
804 __volatile__
unsigned int *lock
,
805 unsigned int context
);
806 extern int drm_finish(struct inode
*inode
, struct file
*filp
,
807 unsigned int cmd
, unsigned long arg
);
808 extern int drm_flush_unblock(drm_device_t
*dev
, int context
,
809 drm_lock_flags_t flags
);
810 extern int drm_flush_block_and_flush(drm_device_t
*dev
, int context
,
811 drm_lock_flags_t flags
);
812 extern int drm_notifier(void *priv
);
814 /* Context Bitmap support (ctxbitmap.c) */
815 extern int drm_ctxbitmap_init(drm_device_t
*dev
);
816 extern void drm_ctxbitmap_cleanup(drm_device_t
*dev
);
817 extern int drm_ctxbitmap_next(drm_device_t
*dev
);
818 extern void drm_ctxbitmap_free(drm_device_t
*dev
, int ctx_handle
);
820 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
821 /* AGP/GART support (agpsupport.c) */
822 extern drm_agp_head_t
*drm_agp_init(void);
823 extern void drm_agp_uninit(void);
824 extern int drm_agp_acquire(struct inode
*inode
, struct file
*filp
,
825 unsigned int cmd
, unsigned long arg
);
826 extern int drm_agp_release(struct inode
*inode
, struct file
*filp
,
827 unsigned int cmd
, unsigned long arg
);
828 extern int drm_agp_enable(struct inode
*inode
, struct file
*filp
,
829 unsigned int cmd
, unsigned long arg
);
830 extern int drm_agp_info(struct inode
*inode
, struct file
*filp
,
831 unsigned int cmd
, unsigned long arg
);
832 extern int drm_agp_alloc(struct inode
*inode
, struct file
*filp
,
833 unsigned int cmd
, unsigned long arg
);
834 extern int drm_agp_free(struct inode
*inode
, struct file
*filp
,
835 unsigned int cmd
, unsigned long arg
);
836 extern int drm_agp_unbind(struct inode
*inode
, struct file
*filp
,
837 unsigned int cmd
, unsigned long arg
);
838 extern int drm_agp_bind(struct inode
*inode
, struct file
*filp
,
839 unsigned int cmd
, unsigned long arg
);