diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/char/drm/drmP.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/char/drm/drmP.h')
-rw-r--r-- | drivers/char/drm/drmP.h | 1073 |
1 files changed, 1073 insertions, 0 deletions
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h new file mode 100644 index 000000000000..21f4c54e1a8d --- /dev/null +++ b/drivers/char/drm/drmP.h | |||
@@ -0,0 +1,1073 @@ | |||
1 | /** | ||
2 | * \file drmP.h | ||
3 | * Private header for Direct Rendering Manager | ||
4 | * | ||
5 | * \author Rickard E. (Rik) Faith <faith@valinux.com> | ||
6 | * \author Gareth Hughes <gareth@valinux.com> | ||
7 | */ | ||
8 | |||
9 | /* | ||
10 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | ||
11 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | ||
12 | * All rights reserved. | ||
13 | * | ||
14 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
15 | * copy of this software and associated documentation files (the "Software"), | ||
16 | * to deal in the Software without restriction, including without limitation | ||
17 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
18 | * and/or sell copies of the Software, and to permit persons to whom the | ||
19 | * Software is furnished to do so, subject to the following conditions: | ||
20 | * | ||
21 | * The above copyright notice and this permission notice (including the next | ||
22 | * paragraph) shall be included in all copies or substantial portions of the | ||
23 | * Software. | ||
24 | * | ||
25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
26 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
27 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
28 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
29 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
30 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
31 | * OTHER DEALINGS IN THE SOFTWARE. | ||
32 | */ | ||
33 | |||
34 | #ifndef _DRM_P_H_ | ||
35 | #define _DRM_P_H_ | ||
36 | |||
37 | /* If you want the memory alloc debug functionality, change define below */ | ||
38 | /* #define DEBUG_MEMORY */ | ||
39 | |||
40 | #ifdef __KERNEL__ | ||
41 | #ifdef __alpha__ | ||
42 | /* add include of current.h so that "current" is defined | ||
43 | * before static inline funcs in wait.h. Doing this so we | ||
44 | * can build the DRM (part of PI DRI). 4/21/2000 S + B */ | ||
45 | #include <asm/current.h> | ||
46 | #endif /* __alpha__ */ | ||
47 | #include <linux/config.h> | ||
48 | #include <linux/module.h> | ||
49 | #include <linux/kernel.h> | ||
50 | #include <linux/miscdevice.h> | ||
51 | #include <linux/fs.h> | ||
52 | #include <linux/proc_fs.h> | ||
53 | #include <linux/init.h> | ||
54 | #include <linux/file.h> | ||
55 | #include <linux/pci.h> | ||
56 | #include <linux/version.h> | ||
57 | #include <linux/jiffies.h> | ||
58 | #include <linux/smp_lock.h> /* For (un)lock_kernel */ | ||
59 | #include <linux/mm.h> | ||
60 | #include <linux/cdev.h> | ||
61 | #if defined(__alpha__) || defined(__powerpc__) | ||
62 | #include <asm/pgtable.h> /* For pte_wrprotect */ | ||
63 | #endif | ||
64 | #include <asm/io.h> | ||
65 | #include <asm/mman.h> | ||
66 | #include <asm/uaccess.h> | ||
67 | #ifdef CONFIG_MTRR | ||
68 | #include <asm/mtrr.h> | ||
69 | #endif | ||
70 | #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE) | ||
71 | #include <linux/types.h> | ||
72 | #include <linux/agp_backend.h> | ||
73 | #endif | ||
74 | #include <linux/workqueue.h> | ||
75 | #include <linux/poll.h> | ||
76 | #include <asm/pgalloc.h> | ||
77 | #include "drm.h" | ||
78 | |||
79 | #define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))) | ||
80 | #define __OS_HAS_MTRR (defined(CONFIG_MTRR)) | ||
81 | |||
82 | #include "drm_os_linux.h" | ||
83 | |||
84 | /***********************************************************************/ | ||
85 | /** \name DRM template customization defaults */ | ||
86 | /*@{*/ | ||
87 | |||
88 | /* driver capabilities and requirements mask */ | ||
89 | #define DRIVER_USE_AGP 0x1 | ||
90 | #define DRIVER_REQUIRE_AGP 0x2 | ||
91 | #define DRIVER_USE_MTRR 0x4 | ||
92 | #define DRIVER_PCI_DMA 0x8 | ||
93 | #define DRIVER_SG 0x10 | ||
94 | #define DRIVER_HAVE_DMA 0x20 | ||
95 | #define DRIVER_HAVE_IRQ 0x40 | ||
96 | #define DRIVER_IRQ_SHARED 0x80 | ||
97 | #define DRIVER_IRQ_VBL 0x100 | ||
98 | #define DRIVER_DMA_QUEUE 0x200 | ||
99 | |||
100 | /***********************************************************************/ | ||
101 | /** \name Begin the DRM... */ | ||
102 | /*@{*/ | ||
103 | |||
104 | #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then | ||
105 | also include looping detection. */ | ||
106 | |||
107 | #define DRM_HASH_SIZE 16 /**< Size of key hash table. Must be power of 2. */ | ||
108 | #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */ | ||
109 | #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */ | ||
110 | #define DRM_LOOPING_LIMIT 5000000 | ||
111 | #define DRM_BSZ 1024 /**< Buffer size for /dev/drm? output */ | ||
112 | #define DRM_TIME_SLICE (HZ/20) /**< Time slice for GLXContexts */ | ||
113 | #define DRM_LOCK_SLICE 1 /**< Time slice for lock, in jiffies */ | ||
114 | |||
115 | #define DRM_FLAG_DEBUG 0x01 | ||
116 | |||
117 | #define DRM_MEM_DMA 0 | ||
118 | #define DRM_MEM_SAREA 1 | ||
119 | #define DRM_MEM_DRIVER 2 | ||
120 | #define DRM_MEM_MAGIC 3 | ||
121 | #define DRM_MEM_IOCTLS 4 | ||
122 | #define DRM_MEM_MAPS 5 | ||
123 | #define DRM_MEM_VMAS 6 | ||
124 | #define DRM_MEM_BUFS 7 | ||
125 | #define DRM_MEM_SEGS 8 | ||
126 | #define DRM_MEM_PAGES 9 | ||
127 | #define DRM_MEM_FILES 10 | ||
128 | #define DRM_MEM_QUEUES 11 | ||
129 | #define DRM_MEM_CMDS 12 | ||
130 | #define DRM_MEM_MAPPINGS 13 | ||
131 | #define DRM_MEM_BUFLISTS 14 | ||
132 | #define DRM_MEM_AGPLISTS 15 | ||
133 | #define DRM_MEM_TOTALAGP 16 | ||
134 | #define DRM_MEM_BOUNDAGP 17 | ||
135 | #define DRM_MEM_CTXBITMAP 18 | ||
136 | #define DRM_MEM_STUB 19 | ||
137 | #define DRM_MEM_SGLISTS 20 | ||
138 | #define DRM_MEM_CTXLIST 21 | ||
139 | |||
140 | #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) | ||
141 | |||
142 | /*@}*/ | ||
143 | |||
144 | |||
145 | /***********************************************************************/ | ||
146 | /** \name Backward compatibility section */ | ||
147 | /*@{*/ | ||
148 | |||
149 | #ifndef MODULE_LICENSE | ||
150 | #define MODULE_LICENSE(x) | ||
151 | #endif | ||
152 | |||
153 | #ifndef preempt_disable | ||
154 | #define preempt_disable() | ||
155 | #define preempt_enable() | ||
156 | #endif | ||
157 | |||
158 | #ifndef pte_offset_map | ||
159 | #define pte_offset_map pte_offset | ||
160 | #define pte_unmap(pte) | ||
161 | #endif | ||
162 | |||
163 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19) | ||
164 | static inline struct page * vmalloc_to_page(void * vmalloc_addr) | ||
165 | { | ||
166 | unsigned long addr = (unsigned long) vmalloc_addr; | ||
167 | struct page *page = NULL; | ||
168 | pgd_t *pgd = pgd_offset_k(addr); | ||
169 | pmd_t *pmd; | ||
170 | pte_t *ptep, pte; | ||
171 | |||
172 | if (!pgd_none(*pgd)) { | ||
173 | pmd = pmd_offset(pgd, addr); | ||
174 | if (!pmd_none(*pmd)) { | ||
175 | preempt_disable(); | ||
176 | ptep = pte_offset_map(pmd, addr); | ||
177 | pte = *ptep; | ||
178 | if (pte_present(pte)) | ||
179 | page = pte_page(pte); | ||
180 | pte_unmap(ptep); | ||
181 | preempt_enable(); | ||
182 | } | ||
183 | } | ||
184 | return page; | ||
185 | } | ||
186 | #endif | ||
187 | |||
188 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) | ||
189 | #define DRM_RPR_ARG(vma) | ||
190 | #else | ||
191 | #define DRM_RPR_ARG(vma) vma, | ||
192 | #endif | ||
193 | |||
194 | #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT) | ||
195 | |||
196 | /*@}*/ | ||
197 | |||
198 | |||
199 | /***********************************************************************/ | ||
200 | /** \name Macros to make printk easier */ | ||
201 | /*@{*/ | ||
202 | |||
203 | /** | ||
204 | * Error output. | ||
205 | * | ||
206 | * \param fmt printf() like format string. | ||
207 | * \param arg arguments | ||
208 | */ | ||
209 | #define DRM_ERROR(fmt, arg...) \ | ||
210 | printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg) | ||
211 | |||
212 | /** | ||
213 | * Memory error output. | ||
214 | * | ||
215 | * \param area memory area where the error occurred. | ||
216 | * \param fmt printf() like format string. | ||
217 | * \param arg arguments | ||
218 | */ | ||
219 | #define DRM_MEM_ERROR(area, fmt, arg...) \ | ||
220 | printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \ | ||
221 | drm_mem_stats[area].name , ##arg) | ||
222 | |||
223 | #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg) | ||
224 | |||
225 | /** | ||
226 | * Debug output. | ||
227 | * | ||
228 | * \param fmt printf() like format string. | ||
229 | * \param arg arguments | ||
230 | */ | ||
231 | #if DRM_DEBUG_CODE | ||
232 | #define DRM_DEBUG(fmt, arg...) \ | ||
233 | do { \ | ||
234 | if ( drm_debug ) \ | ||
235 | printk(KERN_DEBUG \ | ||
236 | "[" DRM_NAME ":%s] " fmt , \ | ||
237 | __FUNCTION__ , ##arg); \ | ||
238 | } while (0) | ||
239 | #else | ||
240 | #define DRM_DEBUG(fmt, arg...) do { } while (0) | ||
241 | #endif | ||
242 | |||
243 | #define DRM_PROC_LIMIT (PAGE_SIZE-80) | ||
244 | |||
245 | #define DRM_PROC_PRINT(fmt, arg...) \ | ||
246 | len += sprintf(&buf[len], fmt , ##arg); \ | ||
247 | if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; } | ||
248 | |||
249 | #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \ | ||
250 | len += sprintf(&buf[len], fmt , ##arg); \ | ||
251 | if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; } | ||
252 | |||
253 | /*@}*/ | ||
254 | |||
255 | |||
256 | /***********************************************************************/ | ||
257 | /** \name Internal types and structures */ | ||
258 | /*@{*/ | ||
259 | |||
260 | #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) | ||
261 | #define DRM_MIN(a,b) ((a)<(b)?(a):(b)) | ||
262 | #define DRM_MAX(a,b) ((a)>(b)?(a):(b)) | ||
263 | |||
264 | #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1)) | ||
265 | #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x)) | ||
266 | #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist) | ||
267 | |||
268 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) | ||
269 | /** | ||
270 | * Get the private SAREA mapping. | ||
271 | * | ||
272 | * \param _dev DRM device. | ||
273 | * \param _ctx context number. | ||
274 | * \param _map output mapping. | ||
275 | */ | ||
276 | #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \ | ||
277 | (_map) = (_dev)->context_sareas[_ctx]; \ | ||
278 | } while(0) | ||
279 | |||
280 | /** | ||
281 | * Test that the hardware lock is held by the caller, returning otherwise. | ||
282 | * | ||
283 | * \param dev DRM device. | ||
284 | * \param filp file pointer of the caller. | ||
285 | */ | ||
286 | #define LOCK_TEST_WITH_RETURN( dev, filp ) \ | ||
287 | do { \ | ||
288 | if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \ | ||
289 | dev->lock.filp != filp ) { \ | ||
290 | DRM_ERROR( "%s called without lock held\n", \ | ||
291 | __FUNCTION__ ); \ | ||
292 | return -EINVAL; \ | ||
293 | } \ | ||
294 | } while (0) | ||
295 | |||
296 | /** | ||
297 | * Copy and IOCTL return string to user space | ||
298 | */ | ||
299 | #define DRM_COPY( name, value ) \ | ||
300 | len = strlen( value ); \ | ||
301 | if ( len > name##_len ) len = name##_len; \ | ||
302 | name##_len = strlen( value ); \ | ||
303 | if ( len && name ) { \ | ||
304 | if ( copy_to_user( name, value, len ) ) \ | ||
305 | return -EFAULT; \ | ||
306 | } | ||
307 | |||
308 | /** | ||
309 | * Ioctl function type. | ||
310 | * | ||
311 | * \param inode device inode. | ||
312 | * \param filp file pointer. | ||
313 | * \param cmd command. | ||
314 | * \param arg argument. | ||
315 | */ | ||
316 | typedef int drm_ioctl_t( struct inode *inode, struct file *filp, | ||
317 | unsigned int cmd, unsigned long arg ); | ||
318 | |||
319 | typedef struct drm_ioctl_desc { | ||
320 | drm_ioctl_t *func; | ||
321 | int auth_needed; | ||
322 | int root_only; | ||
323 | } drm_ioctl_desc_t; | ||
324 | |||
325 | typedef struct drm_devstate { | ||
326 | pid_t owner; /**< X server pid holding x_lock */ | ||
327 | } drm_devstate_t; | ||
328 | |||
329 | typedef struct drm_magic_entry { | ||
330 | drm_magic_t magic; | ||
331 | struct drm_file *priv; | ||
332 | struct drm_magic_entry *next; | ||
333 | } drm_magic_entry_t; | ||
334 | |||
335 | typedef struct drm_magic_head { | ||
336 | struct drm_magic_entry *head; | ||
337 | struct drm_magic_entry *tail; | ||
338 | } drm_magic_head_t; | ||
339 | |||
340 | typedef struct drm_vma_entry { | ||
341 | struct vm_area_struct *vma; | ||
342 | struct drm_vma_entry *next; | ||
343 | pid_t pid; | ||
344 | } drm_vma_entry_t; | ||
345 | |||
346 | /** | ||
347 | * DMA buffer. | ||
348 | */ | ||
349 | typedef struct drm_buf { | ||
350 | int idx; /**< Index into master buflist */ | ||
351 | int total; /**< Buffer size */ | ||
352 | int order; /**< log-base-2(total) */ | ||
353 | int used; /**< Amount of buffer in use (for DMA) */ | ||
354 | unsigned long offset; /**< Byte offset (used internally) */ | ||
355 | void *address; /**< Address of buffer */ | ||
356 | unsigned long bus_address; /**< Bus address of buffer */ | ||
357 | struct drm_buf *next; /**< Kernel-only: used for free list */ | ||
358 | __volatile__ int waiting; /**< On kernel DMA queue */ | ||
359 | __volatile__ int pending; /**< On hardware DMA queue */ | ||
360 | wait_queue_head_t dma_wait; /**< Processes waiting */ | ||
361 | struct file *filp; /**< Pointer to holding file descr */ | ||
362 | int context; /**< Kernel queue for this buffer */ | ||
363 | int while_locked;/**< Dispatch this buffer while locked */ | ||
364 | enum { | ||
365 | DRM_LIST_NONE = 0, | ||
366 | DRM_LIST_FREE = 1, | ||
367 | DRM_LIST_WAIT = 2, | ||
368 | DRM_LIST_PEND = 3, | ||
369 | DRM_LIST_PRIO = 4, | ||
370 | DRM_LIST_RECLAIM = 5 | ||
371 | } list; /**< Which list we're on */ | ||
372 | |||
373 | int dev_priv_size; /**< Size of buffer private storage */ | ||
374 | void *dev_private; /**< Per-buffer private storage */ | ||
375 | } drm_buf_t; | ||
376 | |||
377 | |||
378 | /** bufs is one longer than it has to be */ | ||
379 | typedef struct drm_waitlist { | ||
380 | int count; /**< Number of possible buffers */ | ||
381 | drm_buf_t **bufs; /**< List of pointers to buffers */ | ||
382 | drm_buf_t **rp; /**< Read pointer */ | ||
383 | drm_buf_t **wp; /**< Write pointer */ | ||
384 | drm_buf_t **end; /**< End pointer */ | ||
385 | spinlock_t read_lock; | ||
386 | spinlock_t write_lock; | ||
387 | } drm_waitlist_t; | ||
388 | |||
389 | typedef struct drm_freelist { | ||
390 | int initialized; /**< Freelist in use */ | ||
391 | atomic_t count; /**< Number of free buffers */ | ||
392 | drm_buf_t *next; /**< End pointer */ | ||
393 | |||
394 | wait_queue_head_t waiting; /**< Processes waiting on free bufs */ | ||
395 | int low_mark; /**< Low water mark */ | ||
396 | int high_mark; /**< High water mark */ | ||
397 | atomic_t wfh; /**< If waiting for high mark */ | ||
398 | spinlock_t lock; | ||
399 | } drm_freelist_t; | ||
400 | |||
401 | /** | ||
402 | * Buffer entry. There is one of this for each buffer size order. | ||
403 | */ | ||
404 | typedef struct drm_buf_entry { | ||
405 | int buf_size; /**< size */ | ||
406 | int buf_count; /**< number of buffers */ | ||
407 | drm_buf_t *buflist; /**< buffer list */ | ||
408 | int seg_count; | ||
409 | int page_order; | ||
410 | unsigned long *seglist; | ||
411 | |||
412 | drm_freelist_t freelist; | ||
413 | } drm_buf_entry_t; | ||
414 | |||
415 | /** File private data */ | ||
416 | typedef struct drm_file { | ||
417 | int authenticated; | ||
418 | int minor; | ||
419 | pid_t pid; | ||
420 | uid_t uid; | ||
421 | drm_magic_t magic; | ||
422 | unsigned long ioctl_count; | ||
423 | struct drm_file *next; | ||
424 | struct drm_file *prev; | ||
425 | struct drm_head *head; | ||
426 | int remove_auth_on_close; | ||
427 | unsigned long lock_count; | ||
428 | void *driver_priv; | ||
429 | } drm_file_t; | ||
430 | |||
431 | /** Wait queue */ | ||
432 | typedef struct drm_queue { | ||
433 | atomic_t use_count; /**< Outstanding uses (+1) */ | ||
434 | atomic_t finalization; /**< Finalization in progress */ | ||
435 | atomic_t block_count; /**< Count of processes waiting */ | ||
436 | atomic_t block_read; /**< Queue blocked for reads */ | ||
437 | wait_queue_head_t read_queue; /**< Processes waiting on block_read */ | ||
438 | atomic_t block_write; /**< Queue blocked for writes */ | ||
439 | wait_queue_head_t write_queue; /**< Processes waiting on block_write */ | ||
440 | #if 1 | ||
441 | atomic_t total_queued; /**< Total queued statistic */ | ||
442 | atomic_t total_flushed;/**< Total flushes statistic */ | ||
443 | atomic_t total_locks; /**< Total locks statistics */ | ||
444 | #endif | ||
445 | drm_ctx_flags_t flags; /**< Context preserving and 2D-only */ | ||
446 | drm_waitlist_t waitlist; /**< Pending buffers */ | ||
447 | wait_queue_head_t flush_queue; /**< Processes waiting until flush */ | ||
448 | } drm_queue_t; | ||
449 | |||
450 | /** | ||
451 | * Lock data. | ||
452 | */ | ||
453 | typedef struct drm_lock_data { | ||
454 | drm_hw_lock_t *hw_lock; /**< Hardware lock */ | ||
455 | struct file *filp; /**< File descr of lock holder (0=kernel) */ | ||
456 | wait_queue_head_t lock_queue; /**< Queue of blocked processes */ | ||
457 | unsigned long lock_time; /**< Time of last lock in jiffies */ | ||
458 | } drm_lock_data_t; | ||
459 | |||
460 | /** | ||
461 | * DMA data. | ||
462 | */ | ||
463 | typedef struct drm_device_dma { | ||
464 | |||
465 | drm_buf_entry_t bufs[DRM_MAX_ORDER+1]; /**< buffers, grouped by their size order */ | ||
466 | int buf_count; /**< total number of buffers */ | ||
467 | drm_buf_t **buflist; /**< Vector of pointers into drm_device_dma::bufs */ | ||
468 | int seg_count; | ||
469 | int page_count; /**< number of pages */ | ||
470 | unsigned long *pagelist; /**< page list */ | ||
471 | unsigned long byte_count; | ||
472 | enum { | ||
473 | _DRM_DMA_USE_AGP = 0x01, | ||
474 | _DRM_DMA_USE_SG = 0x02 | ||
475 | } flags; | ||
476 | |||
477 | } drm_device_dma_t; | ||
478 | |||
479 | /** | ||
480 | * AGP memory entry. Stored as a doubly linked list. | ||
481 | */ | ||
482 | typedef struct drm_agp_mem { | ||
483 | unsigned long handle; /**< handle */ | ||
484 | DRM_AGP_MEM *memory; | ||
485 | unsigned long bound; /**< address */ | ||
486 | int pages; | ||
487 | struct drm_agp_mem *prev; /**< previous entry */ | ||
488 | struct drm_agp_mem *next; /**< next entry */ | ||
489 | } drm_agp_mem_t; | ||
490 | |||
491 | /** | ||
492 | * AGP data. | ||
493 | * | ||
494 | * \sa drm_agp_init() and drm_device::agp. | ||
495 | */ | ||
496 | typedef struct drm_agp_head { | ||
497 | DRM_AGP_KERN agp_info; /**< AGP device information */ | ||
498 | drm_agp_mem_t *memory; /**< memory entries */ | ||
499 | unsigned long mode; /**< AGP mode */ | ||
500 | struct agp_bridge_data *bridge; | ||
501 | int enabled; /**< whether the AGP bus as been enabled */ | ||
502 | int acquired; /**< whether the AGP device has been acquired */ | ||
503 | unsigned long base; | ||
504 | int agp_mtrr; | ||
505 | int cant_use_aperture; | ||
506 | unsigned long page_mask; | ||
507 | } drm_agp_head_t; | ||
508 | |||
509 | /** | ||
510 | * Scatter-gather memory. | ||
511 | */ | ||
512 | typedef struct drm_sg_mem { | ||
513 | unsigned long handle; | ||
514 | void *virtual; | ||
515 | int pages; | ||
516 | struct page **pagelist; | ||
517 | dma_addr_t *busaddr; | ||
518 | } drm_sg_mem_t; | ||
519 | |||
520 | typedef struct drm_sigdata { | ||
521 | int context; | ||
522 | drm_hw_lock_t *lock; | ||
523 | } drm_sigdata_t; | ||
524 | |||
525 | /** | ||
526 | * Mappings list | ||
527 | */ | ||
528 | typedef struct drm_map_list { | ||
529 | struct list_head head; /**< list head */ | ||
530 | drm_map_t *map; /**< mapping */ | ||
531 | } drm_map_list_t; | ||
532 | |||
533 | typedef drm_map_t drm_local_map_t; | ||
534 | |||
535 | /** | ||
536 | * Context handle list | ||
537 | */ | ||
538 | typedef struct drm_ctx_list { | ||
539 | struct list_head head; /**< list head */ | ||
540 | drm_context_t handle; /**< context handle */ | ||
541 | drm_file_t *tag; /**< associated fd private data */ | ||
542 | } drm_ctx_list_t; | ||
543 | |||
544 | |||
545 | typedef struct drm_vbl_sig { | ||
546 | struct list_head head; | ||
547 | unsigned int sequence; | ||
548 | struct siginfo info; | ||
549 | struct task_struct *task; | ||
550 | } drm_vbl_sig_t; | ||
551 | |||
552 | |||
553 | /** | ||
554 | * DRM driver structure. This structure represent the common code for | ||
555 | * a family of cards. There will one drm_device for each card present | ||
556 | * in this family | ||
557 | */ | ||
558 | struct drm_device; | ||
559 | |||
560 | struct drm_driver { | ||
561 | int (*preinit)(struct drm_device *, unsigned long flags); | ||
562 | void (*prerelease)(struct drm_device *, struct file *filp); | ||
563 | void (*pretakedown)(struct drm_device *); | ||
564 | int (*postcleanup)(struct drm_device *); | ||
565 | int (*presetup)(struct drm_device *); | ||
566 | int (*postsetup)(struct drm_device *); | ||
567 | int (*dma_ioctl)( DRM_IOCTL_ARGS ); | ||
568 | int (*open_helper)(struct drm_device *, drm_file_t *); | ||
569 | void (*free_filp_priv)(struct drm_device *, drm_file_t *); | ||
570 | void (*release)(struct drm_device *, struct file *filp); | ||
571 | void (*dma_ready)(struct drm_device *); | ||
572 | int (*dma_quiescent)(struct drm_device *); | ||
573 | int (*context_ctor)(struct drm_device *dev, int context); | ||
574 | int (*context_dtor)(struct drm_device *dev, int context); | ||
575 | int (*kernel_context_switch)(struct drm_device *dev, int old, int new); | ||
576 | void (*kernel_context_switch_unlock)(struct drm_device *dev, drm_lock_t *lock); | ||
577 | int (*vblank_wait)(struct drm_device *dev, unsigned int *sequence); | ||
578 | /* these have to be filled in */ | ||
579 | int (*postinit)(struct drm_device *, unsigned long flags); | ||
580 | irqreturn_t (*irq_handler)( DRM_IRQ_ARGS ); | ||
581 | void (*irq_preinstall)(struct drm_device *dev); | ||
582 | void (*irq_postinstall)(struct drm_device *dev); | ||
583 | void (*irq_uninstall)(struct drm_device *dev); | ||
584 | void (*reclaim_buffers)(struct drm_device *dev, struct file *filp); | ||
585 | unsigned long (*get_map_ofs)(drm_map_t *map); | ||
586 | unsigned long (*get_reg_ofs)(struct drm_device *dev); | ||
587 | void (*set_version)(struct drm_device *dev, drm_set_version_t *sv); | ||
588 | int (*version)(drm_version_t *version); | ||
589 | u32 driver_features; | ||
590 | int dev_priv_size; | ||
591 | drm_ioctl_desc_t *ioctls; | ||
592 | int num_ioctls; | ||
593 | struct file_operations fops; | ||
594 | struct pci_driver pci_driver; | ||
595 | }; | ||
596 | |||
597 | /** | ||
598 | * DRM head structure. This structure represent a video head on a card | ||
599 | * that may contain multiple heads. Embed one per head of these in the | ||
600 | * private drm_device structure. | ||
601 | */ | ||
602 | typedef struct drm_head { | ||
603 | int minor; /**< Minor device number */ | ||
604 | struct drm_device *dev; | ||
605 | struct proc_dir_entry *dev_root; /**< proc directory entry */ | ||
606 | dev_t device; /**< Device number for mknod */ | ||
607 | struct class_device *dev_class; | ||
608 | } drm_head_t; | ||
609 | |||
610 | /** | ||
611 | * DRM device structure. This structure represent a complete card that | ||
612 | * may contain multiple heads. | ||
613 | */ | ||
614 | typedef struct drm_device { | ||
615 | char *unique; /**< Unique identifier: e.g., busid */ | ||
616 | int unique_len; /**< Length of unique field */ | ||
617 | char *devname; /**< For /proc/interrupts */ | ||
618 | int if_version; /**< Highest interface version set */ | ||
619 | |||
620 | int blocked; /**< Blocked due to VC switch? */ | ||
621 | |||
622 | /** \name Locks */ | ||
623 | /*@{*/ | ||
624 | spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */ | ||
625 | struct semaphore struct_sem; /**< For others */ | ||
626 | /*@}*/ | ||
627 | |||
628 | /** \name Usage Counters */ | ||
629 | /*@{*/ | ||
630 | int open_count; /**< Outstanding files open */ | ||
631 | atomic_t ioctl_count; /**< Outstanding IOCTLs pending */ | ||
632 | atomic_t vma_count; /**< Outstanding vma areas open */ | ||
633 | int buf_use; /**< Buffers in use -- cannot alloc */ | ||
634 | atomic_t buf_alloc; /**< Buffer allocation in progress */ | ||
635 | /*@}*/ | ||
636 | |||
637 | /** \name Performance counters */ | ||
638 | /*@{*/ | ||
639 | unsigned long counters; | ||
640 | drm_stat_type_t types[15]; | ||
641 | atomic_t counts[15]; | ||
642 | /*@}*/ | ||
643 | |||
644 | /** \name Authentication */ | ||
645 | /*@{*/ | ||
646 | drm_file_t *file_first; /**< file list head */ | ||
647 | drm_file_t *file_last; /**< file list tail */ | ||
648 | drm_magic_head_t magiclist[DRM_HASH_SIZE]; /**< magic hash table */ | ||
649 | /*@}*/ | ||
650 | |||
651 | /** \name Memory management */ | ||
652 | /*@{*/ | ||
653 | drm_map_list_t *maplist; /**< Linked list of regions */ | ||
654 | int map_count; /**< Number of mappable regions */ | ||
655 | |||
656 | /** \name Context handle management */ | ||
657 | /*@{*/ | ||
658 | drm_ctx_list_t *ctxlist; /**< Linked list of context handles */ | ||
659 | int ctx_count; /**< Number of context handles */ | ||
660 | struct semaphore ctxlist_sem; /**< For ctxlist */ | ||
661 | |||
662 | drm_map_t **context_sareas; /**< per-context SAREA's */ | ||
663 | int max_context; | ||
664 | |||
665 | drm_vma_entry_t *vmalist; /**< List of vmas (for debugging) */ | ||
666 | drm_lock_data_t lock; /**< Information on hardware lock */ | ||
667 | /*@}*/ | ||
668 | |||
669 | /** \name DMA queues (contexts) */ | ||
670 | /*@{*/ | ||
671 | int queue_count; /**< Number of active DMA queues */ | ||
672 | int queue_reserved; /**< Number of reserved DMA queues */ | ||
673 | int queue_slots; /**< Actual length of queuelist */ | ||
674 | drm_queue_t **queuelist; /**< Vector of pointers to DMA queues */ | ||
675 | drm_device_dma_t *dma; /**< Optional pointer for DMA support */ | ||
676 | /*@}*/ | ||
677 | |||
678 | /** \name Context support */ | ||
679 | /*@{*/ | ||
680 | int irq; /**< Interrupt used by board */ | ||
681 | int irq_enabled; /**< True if irq handler is enabled */ | ||
682 | __volatile__ long context_flag; /**< Context swapping flag */ | ||
683 | __volatile__ long interrupt_flag; /**< Interruption handler flag */ | ||
684 | __volatile__ long dma_flag; /**< DMA dispatch flag */ | ||
685 | struct timer_list timer; /**< Timer for delaying ctx switch */ | ||
686 | wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */ | ||
687 | int last_checked; /**< Last context checked for DMA */ | ||
688 | int last_context; /**< Last current context */ | ||
689 | unsigned long last_switch; /**< jiffies at last context switch */ | ||
690 | /*@}*/ | ||
691 | |||
692 | struct work_struct work; | ||
693 | /** \name VBLANK IRQ support */ | ||
694 | /*@{*/ | ||
695 | |||
696 | wait_queue_head_t vbl_queue; /**< VBLANK wait queue */ | ||
697 | atomic_t vbl_received; | ||
698 | spinlock_t vbl_lock; | ||
699 | drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */ | ||
700 | unsigned int vbl_pending; | ||
701 | |||
702 | /*@}*/ | ||
703 | cycles_t ctx_start; | ||
704 | cycles_t lck_start; | ||
705 | |||
706 | char buf[DRM_BSZ]; /**< Output buffer */ | ||
707 | char *buf_rp; /**< Read pointer */ | ||
708 | char *buf_wp; /**< Write pointer */ | ||
709 | char *buf_end; /**< End pointer */ | ||
710 | struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */ | ||
711 | wait_queue_head_t buf_readers; /**< Processes waiting to read */ | ||
712 | wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */ | ||
713 | |||
714 | drm_agp_head_t *agp; /**< AGP data */ | ||
715 | |||
716 | struct pci_dev *pdev; /**< PCI device structure */ | ||
717 | int pci_domain; /**< PCI bus domain number */ | ||
718 | int pci_bus; /**< PCI bus number */ | ||
719 | int pci_slot; /**< PCI slot number */ | ||
720 | int pci_func; /**< PCI function number */ | ||
721 | #ifdef __alpha__ | ||
722 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3) | ||
723 | struct pci_controler *hose; | ||
724 | #else | ||
725 | struct pci_controller *hose; | ||
726 | #endif | ||
727 | #endif | ||
728 | drm_sg_mem_t *sg; /**< Scatter gather memory */ | ||
729 | unsigned long *ctx_bitmap; /**< context bitmap */ | ||
730 | void *dev_private; /**< device private data */ | ||
731 | drm_sigdata_t sigdata; /**< For block_all_signals */ | ||
732 | sigset_t sigmask; | ||
733 | |||
734 | struct drm_driver *driver; | ||
735 | drm_local_map_t *agp_buffer_map; | ||
736 | drm_head_t primary; /**< primary screen head */ | ||
737 | } drm_device_t; | ||
738 | |||
739 | static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature) | ||
740 | { | ||
741 | return ((dev->driver->driver_features & feature) ? 1 : 0); | ||
742 | } | ||
743 | |||
744 | #if __OS_HAS_AGP | ||
745 | static inline int drm_core_has_AGP(struct drm_device *dev) | ||
746 | { | ||
747 | return drm_core_check_feature(dev, DRIVER_USE_AGP); | ||
748 | } | ||
749 | #else | ||
750 | #define drm_core_has_AGP(dev) (0) | ||
751 | #endif | ||
752 | |||
753 | #if __OS_HAS_MTRR | ||
754 | static inline int drm_core_has_MTRR(struct drm_device *dev) | ||
755 | { | ||
756 | return drm_core_check_feature(dev, DRIVER_USE_MTRR); | ||
757 | } | ||
758 | #else | ||
759 | #define drm_core_has_MTRR(dev) (0) | ||
760 | #endif | ||
761 | |||
762 | /******************************************************************/ | ||
763 | /** \name Internal function definitions */ | ||
764 | /*@{*/ | ||
765 | |||
766 | /* Misc. support (drm_init.h) */ | ||
767 | extern int drm_flags; | ||
768 | extern void drm_parse_options( char *s ); | ||
769 | extern int drm_cpu_valid( void ); | ||
770 | |||
771 | /* Driver support (drm_drv.h) */ | ||
772 | extern int drm_init(struct drm_driver *driver); | ||
773 | extern void drm_exit(struct drm_driver *driver); | ||
774 | extern int drm_version(struct inode *inode, struct file *filp, | ||
775 | unsigned int cmd, unsigned long arg); | ||
776 | extern int drm_ioctl(struct inode *inode, struct file *filp, | ||
777 | unsigned int cmd, unsigned long arg); | ||
778 | extern int drm_takedown(drm_device_t * dev); | ||
779 | |||
780 | /* Device support (drm_fops.h) */ | ||
781 | extern int drm_open(struct inode *inode, struct file *filp); | ||
782 | extern int drm_stub_open(struct inode *inode, struct file *filp); | ||
783 | extern int drm_open_helper(struct inode *inode, struct file *filp, | ||
784 | drm_device_t *dev); | ||
785 | extern int drm_flush(struct file *filp); | ||
786 | extern int drm_fasync(int fd, struct file *filp, int on); | ||
787 | extern int drm_release(struct inode *inode, struct file *filp); | ||
788 | |||
789 | /* Mapping support (drm_vm.h) */ | ||
790 | extern void drm_vm_open(struct vm_area_struct *vma); | ||
791 | extern void drm_vm_close(struct vm_area_struct *vma); | ||
792 | extern void drm_vm_shm_close(struct vm_area_struct *vma); | ||
793 | extern int drm_mmap_dma(struct file *filp, | ||
794 | struct vm_area_struct *vma); | ||
795 | extern int drm_mmap(struct file *filp, struct vm_area_struct *vma); | ||
796 | extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); | ||
797 | extern ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off); | ||
798 | |||
799 | /* Memory management support (drm_memory.h) */ | ||
800 | #include "drm_memory.h" | ||
801 | extern void drm_mem_init(void); | ||
802 | extern int drm_mem_info(char *buf, char **start, off_t offset, | ||
803 | int request, int *eof, void *data); | ||
804 | extern void *drm_calloc(size_t nmemb, size_t size, int area); | ||
805 | extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, | ||
806 | int area); | ||
807 | extern unsigned long drm_alloc_pages(int order, int area); | ||
808 | extern void drm_free_pages(unsigned long address, int order, | ||
809 | int area); | ||
810 | extern void *drm_ioremap(unsigned long offset, unsigned long size, drm_device_t *dev); | ||
811 | extern void *drm_ioremap_nocache(unsigned long offset, unsigned long size, | ||
812 | drm_device_t *dev); | ||
813 | extern void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *dev); | ||
814 | |||
815 | extern DRM_AGP_MEM *drm_alloc_agp(struct agp_bridge_data *bridge, int pages, u32 type); | ||
816 | extern int drm_free_agp(DRM_AGP_MEM *handle, int pages); | ||
817 | extern int drm_bind_agp(DRM_AGP_MEM *handle, unsigned int start); | ||
818 | extern int drm_unbind_agp(DRM_AGP_MEM *handle); | ||
819 | |||
820 | /* Misc. IOCTL support (drm_ioctl.h) */ | ||
821 | extern int drm_irq_by_busid(struct inode *inode, struct file *filp, | ||
822 | unsigned int cmd, unsigned long arg); | ||
823 | extern int drm_getunique(struct inode *inode, struct file *filp, | ||
824 | unsigned int cmd, unsigned long arg); | ||
825 | extern int drm_setunique(struct inode *inode, struct file *filp, | ||
826 | unsigned int cmd, unsigned long arg); | ||
827 | extern int drm_getmap(struct inode *inode, struct file *filp, | ||
828 | unsigned int cmd, unsigned long arg); | ||
829 | extern int drm_getclient(struct inode *inode, struct file *filp, | ||
830 | unsigned int cmd, unsigned long arg); | ||
831 | extern int drm_getstats(struct inode *inode, struct file *filp, | ||
832 | unsigned int cmd, unsigned long arg); | ||
833 | extern int drm_setversion(struct inode *inode, struct file *filp, | ||
834 | unsigned int cmd, unsigned long arg); | ||
835 | |||
836 | /* Context IOCTL support (drm_context.h) */ | ||
837 | extern int drm_resctx( struct inode *inode, struct file *filp, | ||
838 | unsigned int cmd, unsigned long arg ); | ||
839 | extern int drm_addctx( struct inode *inode, struct file *filp, | ||
840 | unsigned int cmd, unsigned long arg ); | ||
841 | extern int drm_modctx( struct inode *inode, struct file *filp, | ||
842 | unsigned int cmd, unsigned long arg ); | ||
843 | extern int drm_getctx( struct inode *inode, struct file *filp, | ||
844 | unsigned int cmd, unsigned long arg ); | ||
845 | extern int drm_switchctx( struct inode *inode, struct file *filp, | ||
846 | unsigned int cmd, unsigned long arg ); | ||
847 | extern int drm_newctx( struct inode *inode, struct file *filp, | ||
848 | unsigned int cmd, unsigned long arg ); | ||
849 | extern int drm_rmctx( struct inode *inode, struct file *filp, | ||
850 | unsigned int cmd, unsigned long arg ); | ||
851 | |||
852 | extern int drm_context_switch(drm_device_t *dev, int old, int new); | ||
853 | extern int drm_context_switch_complete(drm_device_t *dev, int new); | ||
854 | |||
855 | extern int drm_ctxbitmap_init( drm_device_t *dev ); | ||
856 | extern void drm_ctxbitmap_cleanup( drm_device_t *dev ); | ||
857 | extern void drm_ctxbitmap_free( drm_device_t *dev, int ctx_handle ); | ||
858 | |||
859 | extern int drm_setsareactx( struct inode *inode, struct file *filp, | ||
860 | unsigned int cmd, unsigned long arg ); | ||
861 | extern int drm_getsareactx( struct inode *inode, struct file *filp, | ||
862 | unsigned int cmd, unsigned long arg ); | ||
863 | |||
864 | /* Drawable IOCTL support (drm_drawable.h) */ | ||
865 | extern int drm_adddraw(struct inode *inode, struct file *filp, | ||
866 | unsigned int cmd, unsigned long arg); | ||
867 | extern int drm_rmdraw(struct inode *inode, struct file *filp, | ||
868 | unsigned int cmd, unsigned long arg); | ||
869 | |||
870 | |||
871 | /* Authentication IOCTL support (drm_auth.h) */ | ||
872 | extern int drm_add_magic(drm_device_t *dev, drm_file_t *priv, | ||
873 | drm_magic_t magic); | ||
874 | extern int drm_remove_magic(drm_device_t *dev, drm_magic_t magic); | ||
875 | extern int drm_getmagic(struct inode *inode, struct file *filp, | ||
876 | unsigned int cmd, unsigned long arg); | ||
877 | extern int drm_authmagic(struct inode *inode, struct file *filp, | ||
878 | unsigned int cmd, unsigned long arg); | ||
879 | |||
880 | /* Placeholder for ioctls past */ | ||
881 | extern int drm_noop(struct inode *inode, struct file *filp, | ||
882 | unsigned int cmd, unsigned long arg); | ||
883 | |||
884 | /* Locking IOCTL support (drm_lock.h) */ | ||
885 | extern int drm_lock(struct inode *inode, struct file *filp, | ||
886 | unsigned int cmd, unsigned long arg); | ||
887 | extern int drm_unlock(struct inode *inode, struct file *filp, | ||
888 | unsigned int cmd, unsigned long arg); | ||
889 | extern int drm_lock_take(__volatile__ unsigned int *lock, | ||
890 | unsigned int context); | ||
891 | extern int drm_lock_transfer(drm_device_t *dev, | ||
892 | __volatile__ unsigned int *lock, | ||
893 | unsigned int context); | ||
894 | extern int drm_lock_free(drm_device_t *dev, | ||
895 | __volatile__ unsigned int *lock, | ||
896 | unsigned int context); | ||
897 | extern int drm_notifier(void *priv); | ||
898 | |||
899 | /* Buffer management support (drm_bufs.h) */ | ||
900 | extern int drm_order( unsigned long size ); | ||
901 | extern int drm_addmap( struct inode *inode, struct file *filp, | ||
902 | unsigned int cmd, unsigned long arg ); | ||
903 | extern int drm_rmmap( struct inode *inode, struct file *filp, | ||
904 | unsigned int cmd, unsigned long arg ); | ||
905 | extern int drm_addbufs( struct inode *inode, struct file *filp, | ||
906 | unsigned int cmd, unsigned long arg ); | ||
907 | extern int drm_infobufs( struct inode *inode, struct file *filp, | ||
908 | unsigned int cmd, unsigned long arg ); | ||
909 | extern int drm_markbufs( struct inode *inode, struct file *filp, | ||
910 | unsigned int cmd, unsigned long arg ); | ||
911 | extern int drm_freebufs( struct inode *inode, struct file *filp, | ||
912 | unsigned int cmd, unsigned long arg ); | ||
913 | extern int drm_mapbufs( struct inode *inode, struct file *filp, | ||
914 | unsigned int cmd, unsigned long arg ); | ||
915 | |||
916 | /* DMA support (drm_dma.h) */ | ||
917 | extern int drm_dma_setup(drm_device_t *dev); | ||
918 | extern void drm_dma_takedown(drm_device_t *dev); | ||
919 | extern void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf); | ||
920 | extern void drm_core_reclaim_buffers(drm_device_t *dev, struct file *filp); | ||
921 | |||
922 | /* IRQ support (drm_irq.h) */ | ||
923 | extern int drm_control( struct inode *inode, struct file *filp, | ||
924 | unsigned int cmd, unsigned long arg ); | ||
925 | extern int drm_irq_install( drm_device_t *dev ); | ||
926 | extern int drm_irq_uninstall( drm_device_t *dev ); | ||
927 | extern irqreturn_t drm_irq_handler( DRM_IRQ_ARGS ); | ||
928 | extern void drm_driver_irq_preinstall( drm_device_t *dev ); | ||
929 | extern void drm_driver_irq_postinstall( drm_device_t *dev ); | ||
930 | extern void drm_driver_irq_uninstall( drm_device_t *dev ); | ||
931 | |||
932 | extern int drm_wait_vblank(struct inode *inode, struct file *filp, | ||
933 | unsigned int cmd, unsigned long arg); | ||
934 | extern int drm_vblank_wait(drm_device_t *dev, unsigned int *vbl_seq); | ||
935 | extern void drm_vbl_send_signals( drm_device_t *dev ); | ||
936 | |||
937 | /* AGP/GART support (drm_agpsupport.h) */ | ||
938 | extern drm_agp_head_t *drm_agp_init(drm_device_t *dev); | ||
939 | extern int drm_agp_acquire(struct inode *inode, struct file *filp, | ||
940 | unsigned int cmd, unsigned long arg); | ||
941 | extern void drm_agp_do_release(drm_device_t *dev); | ||
942 | extern int drm_agp_release(struct inode *inode, struct file *filp, | ||
943 | unsigned int cmd, unsigned long arg); | ||
944 | extern int drm_agp_enable(struct inode *inode, struct file *filp, | ||
945 | unsigned int cmd, unsigned long arg); | ||
946 | extern int drm_agp_info(struct inode *inode, struct file *filp, | ||
947 | unsigned int cmd, unsigned long arg); | ||
948 | extern int drm_agp_alloc(struct inode *inode, struct file *filp, | ||
949 | unsigned int cmd, unsigned long arg); | ||
950 | extern int drm_agp_free(struct inode *inode, struct file *filp, | ||
951 | unsigned int cmd, unsigned long arg); | ||
952 | extern int drm_agp_unbind(struct inode *inode, struct file *filp, | ||
953 | unsigned int cmd, unsigned long arg); | ||
954 | extern int drm_agp_bind(struct inode *inode, struct file *filp, | ||
955 | unsigned int cmd, unsigned long arg); | ||
956 | extern DRM_AGP_MEM *drm_agp_allocate_memory(struct agp_bridge_data *bridge, size_t pages, u32 type); | ||
957 | extern int drm_agp_free_memory(DRM_AGP_MEM *handle); | ||
958 | extern int drm_agp_bind_memory(DRM_AGP_MEM *handle, off_t start); | ||
959 | extern int drm_agp_unbind_memory(DRM_AGP_MEM *handle); | ||
960 | |||
961 | /* Stub support (drm_stub.h) */ | ||
962 | extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, | ||
963 | struct drm_driver *driver); | ||
964 | extern int drm_put_dev(drm_device_t * dev); | ||
965 | extern int drm_get_head(drm_device_t * dev, drm_head_t *head); | ||
966 | extern int drm_put_head(drm_head_t * head); | ||
967 | extern unsigned int drm_debug; | ||
968 | extern unsigned int drm_cards_limit; | ||
969 | extern drm_head_t **drm_heads; | ||
970 | extern struct drm_sysfs_class *drm_class; | ||
971 | extern struct proc_dir_entry *drm_proc_root; | ||
972 | |||
973 | /* Proc support (drm_proc.h) */ | ||
974 | extern int drm_proc_init(drm_device_t *dev, | ||
975 | int minor, | ||
976 | struct proc_dir_entry *root, | ||
977 | struct proc_dir_entry **dev_root); | ||
978 | extern int drm_proc_cleanup(int minor, | ||
979 | struct proc_dir_entry *root, | ||
980 | struct proc_dir_entry *dev_root); | ||
981 | |||
982 | /* Scatter Gather Support (drm_scatter.h) */ | ||
983 | extern void drm_sg_cleanup(drm_sg_mem_t *entry); | ||
984 | extern int drm_sg_alloc(struct inode *inode, struct file *filp, | ||
985 | unsigned int cmd, unsigned long arg); | ||
986 | extern int drm_sg_free(struct inode *inode, struct file *filp, | ||
987 | unsigned int cmd, unsigned long arg); | ||
988 | |||
989 | /* ATI PCIGART support (ati_pcigart.h) */ | ||
990 | extern int drm_ati_pcigart_init(drm_device_t *dev, | ||
991 | unsigned long *addr, | ||
992 | dma_addr_t *bus_addr); | ||
993 | extern int drm_ati_pcigart_cleanup(drm_device_t *dev, | ||
994 | unsigned long addr, | ||
995 | dma_addr_t bus_addr); | ||
996 | |||
997 | extern void *drm_pci_alloc(drm_device_t * dev, size_t size, | ||
998 | size_t align, dma_addr_t maxaddr, | ||
999 | dma_addr_t * busaddr); | ||
1000 | |||
1001 | extern void drm_pci_free(drm_device_t * dev, size_t size, | ||
1002 | void *vaddr, dma_addr_t busaddr); | ||
1003 | |||
1004 | /* sysfs support (drm_sysfs.c) */ | ||
1005 | struct drm_sysfs_class; | ||
1006 | extern struct drm_sysfs_class *drm_sysfs_create(struct module *owner, | ||
1007 | char *name); | ||
1008 | extern void drm_sysfs_destroy(struct drm_sysfs_class *cs); | ||
1009 | extern struct class_device *drm_sysfs_device_add(struct drm_sysfs_class *cs, | ||
1010 | dev_t dev, | ||
1011 | struct device *device, | ||
1012 | const char *fmt, ...); | ||
1013 | extern void drm_sysfs_device_remove(dev_t dev); | ||
1014 | |||
1015 | |||
1016 | /* Inline replacements for DRM_IOREMAP macros */ | ||
1017 | static __inline__ void drm_core_ioremap(struct drm_map *map, struct drm_device *dev) | ||
1018 | { | ||
1019 | map->handle = drm_ioremap( map->offset, map->size, dev ); | ||
1020 | } | ||
1021 | |||
1022 | static __inline__ void drm_core_ioremap_nocache(struct drm_map *map, struct drm_device *dev) | ||
1023 | { | ||
1024 | map->handle = drm_ioremap_nocache(map->offset, map->size, dev); | ||
1025 | } | ||
1026 | |||
1027 | static __inline__ void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev) | ||
1028 | { | ||
1029 | if ( map->handle && map->size ) | ||
1030 | drm_ioremapfree( map->handle, map->size, dev ); | ||
1031 | } | ||
1032 | |||
1033 | static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, unsigned long offset) | ||
1034 | { | ||
1035 | struct list_head *_list; | ||
1036 | list_for_each( _list, &dev->maplist->head ) { | ||
1037 | drm_map_list_t *_entry = list_entry( _list, drm_map_list_t, head ); | ||
1038 | if ( _entry->map && | ||
1039 | _entry->map->offset == offset ) { | ||
1040 | return _entry->map; | ||
1041 | } | ||
1042 | } | ||
1043 | return NULL; | ||
1044 | } | ||
1045 | |||
1046 | static __inline__ void drm_core_dropmap(struct drm_map *map) | ||
1047 | { | ||
1048 | } | ||
1049 | |||
1050 | #ifndef DEBUG_MEMORY | ||
1051 | /** Wrapper around kmalloc() */ | ||
1052 | static __inline__ void *drm_alloc(size_t size, int area) | ||
1053 | { | ||
1054 | return kmalloc(size, GFP_KERNEL); | ||
1055 | } | ||
1056 | |||
1057 | /** Wrapper around kfree() */ | ||
1058 | static __inline__ void drm_free(void *pt, size_t size, int area) | ||
1059 | { | ||
1060 | kfree(pt); | ||
1061 | } | ||
1062 | #else | ||
1063 | extern void *drm_alloc(size_t size, int area); | ||
1064 | extern void drm_free(void *pt, size_t size, int area); | ||
1065 | #endif | ||
1066 | |||
1067 | /*@}*/ | ||
1068 | |||
1069 | extern unsigned long drm_core_get_map_ofs(drm_map_t *map); | ||
1070 | extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); | ||
1071 | |||
1072 | #endif /* __KERNEL__ */ | ||
1073 | #endif | ||