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