1 | /* xf86drm.h -- OS-independent header for DRM user-level library interface
|
---|
2 | * Created: Tue Jan 5 08:17:23 1999 by [email protected]
|
---|
3 | *
|
---|
4 | * Copyright 1999, 2000 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 | * 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.
|
---|
26 | *
|
---|
27 | * Author: Rickard E. (Rik) Faith <[email protected]>
|
---|
28 | *
|
---|
29 | * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h,v 1.21 2002/12/24 17:42:59 tsi Exp $
|
---|
30 | *
|
---|
31 | */
|
---|
32 |
|
---|
33 | #ifndef _XF86DRM_H_
|
---|
34 | #define _XF86DRM_H_
|
---|
35 |
|
---|
36 | /* Defaults, if nothing set in xf86config */
|
---|
37 | #define DRM_DEV_UID 0
|
---|
38 | #define DRM_DEV_GID 0
|
---|
39 | /* Default /dev/dri directory permissions 0755 */
|
---|
40 | #define DRM_DEV_DIRMODE \
|
---|
41 | (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
|
---|
42 | #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
|
---|
43 |
|
---|
44 | #define DRM_DIR_NAME "/dev/dri"
|
---|
45 | #define DRM_DEV_NAME "%s/card%d"
|
---|
46 | #define DRM_PROC_NAME "/proc/dri/" /* For backware Linux compatibility */
|
---|
47 |
|
---|
48 | #define DRM_ERR_NO_DEVICE (-1001)
|
---|
49 | #define DRM_ERR_NO_ACCESS (-1002)
|
---|
50 | #define DRM_ERR_NOT_ROOT (-1003)
|
---|
51 | #define DRM_ERR_INVALID (-1004)
|
---|
52 | #define DRM_ERR_NO_FD (-1005)
|
---|
53 |
|
---|
54 | typedef unsigned long drmHandle, *drmHandlePtr; /* To mapped regions */
|
---|
55 | typedef unsigned int drmSize, *drmSizePtr; /* For mapped regions */
|
---|
56 | typedef void *drmAddress, **drmAddressPtr; /* For mapped regions */
|
---|
57 | typedef unsigned int drmContext, *drmContextPtr; /* GLXContext handle */
|
---|
58 | typedef unsigned int drmDrawable, *drmDrawablePtr; /* Unused */
|
---|
59 | typedef unsigned int drmMagic, *drmMagicPtr; /* Magic for auth */
|
---|
60 |
|
---|
61 | typedef struct _drmVersion {
|
---|
62 | int version_major; /* Major version */
|
---|
63 | int version_minor; /* Minor version */
|
---|
64 | int version_patchlevel; /* Patch level */
|
---|
65 | int name_len; /* Length of name buffer */
|
---|
66 | char *name; /* Name of driver */
|
---|
67 | int date_len; /* Length of date buffer */
|
---|
68 | char *date; /* User-space buffer to hold date */
|
---|
69 | int desc_len; /* Length of desc buffer */
|
---|
70 | char *desc; /* User-space buffer to hold desc */
|
---|
71 | } drmVersion, *drmVersionPtr;
|
---|
72 |
|
---|
73 | typedef struct _drmStats {
|
---|
74 | unsigned long count; /* Number of data */
|
---|
75 | struct {
|
---|
76 | unsigned long value; /* Value from kernel */
|
---|
77 | const char *long_format; /* Suggested format for long_name */
|
---|
78 | const char *long_name; /* Long name for value */
|
---|
79 | const char *rate_format; /* Suggested format for rate_name */
|
---|
80 | const char *rate_name; /* Short name for value per second */
|
---|
81 | int isvalue; /* True if value (vs. counter) */
|
---|
82 | const char *mult_names; /* Multiplier names (e.g., "KGM") */
|
---|
83 | int mult; /* Multiplier value (e.g., 1024) */
|
---|
84 | int verbose; /* Suggest only in verbose output */
|
---|
85 | } data[15];
|
---|
86 | } drmStatsT;
|
---|
87 |
|
---|
88 |
|
---|
89 | /* All of these enums *MUST* match with the
|
---|
90 | kernel implementation -- so do *NOT*
|
---|
91 | change them! (The drmlib implementation
|
---|
92 | will just copy the flags instead of
|
---|
93 | translating them.) */
|
---|
94 | typedef enum {
|
---|
95 | DRM_FRAME_BUFFER = 0, /* WC, no caching, no core dump */
|
---|
96 | DRM_REGISTERS = 1, /* no caching, no core dump */
|
---|
97 | DRM_SHM = 2, /* shared, cached */
|
---|
98 | DRM_AGP = 3, /* AGP/GART */
|
---|
99 | DRM_SCATTER_GATHER = 4 /* PCI scatter/gather */
|
---|
100 | } drmMapType;
|
---|
101 |
|
---|
102 | typedef enum {
|
---|
103 | DRM_RESTRICTED = 0x0001, /* Cannot be mapped to client-virtual */
|
---|
104 | DRM_READ_ONLY = 0x0002, /* Read-only in client-virtual */
|
---|
105 | DRM_LOCKED = 0x0004, /* Physical pages locked */
|
---|
106 | DRM_KERNEL = 0x0008, /* Kernel requires access */
|
---|
107 | DRM_WRITE_COMBINING = 0x0010, /* Use write-combining, if available */
|
---|
108 | DRM_CONTAINS_LOCK = 0x0020, /* SHM page that contains lock */
|
---|
109 | DRM_REMOVABLE = 0x0040 /* Removable mapping */
|
---|
110 | } drmMapFlags;
|
---|
111 |
|
---|
112 | typedef enum { /* These values *MUST* match drm.h */
|
---|
113 | /* Flags for DMA buffer dispatch */
|
---|
114 | DRM_DMA_BLOCK = 0x01, /* Block until buffer dispatched. Note,
|
---|
115 | the buffer may not yet have been
|
---|
116 | processed by the hardware -- getting a
|
---|
117 | hardware lock with the hardware
|
---|
118 | quiescent will ensure that the buffer
|
---|
119 | has been processed. */
|
---|
120 | DRM_DMA_WHILE_LOCKED = 0x02, /* Dispatch while lock held */
|
---|
121 | DRM_DMA_PRIORITY = 0x04, /* High priority dispatch */
|
---|
122 |
|
---|
123 | /* Flags for DMA buffer request */
|
---|
124 | DRM_DMA_WAIT = 0x10, /* Wait for free buffers */
|
---|
125 | DRM_DMA_SMALLER_OK = 0x20, /* Smaller-than-requested buffers ok */
|
---|
126 | DRM_DMA_LARGER_OK = 0x40 /* Larger-than-requested buffers ok */
|
---|
127 | } drmDMAFlags;
|
---|
128 |
|
---|
129 | typedef enum {
|
---|
130 | DRM_PAGE_ALIGN = 0x01,
|
---|
131 | DRM_AGP_BUFFER = 0x02,
|
---|
132 | DRM_SG_BUFFER = 0x04
|
---|
133 | } drmBufDescFlags;
|
---|
134 |
|
---|
135 | typedef enum {
|
---|
136 | DRM_LOCK_READY = 0x01, /* Wait until hardware is ready for DMA */
|
---|
137 | DRM_LOCK_QUIESCENT = 0x02, /* Wait until hardware quiescent */
|
---|
138 | DRM_LOCK_FLUSH = 0x04, /* Flush this context's DMA queue first */
|
---|
139 | DRM_LOCK_FLUSH_ALL = 0x08, /* Flush all DMA queues first */
|
---|
140 | /* These *HALT* flags aren't supported yet
|
---|
141 | -- they will be used to support the
|
---|
142 | full-screen DGA-like mode. */
|
---|
143 | DRM_HALT_ALL_QUEUES = 0x10, /* Halt all current and future queues */
|
---|
144 | DRM_HALT_CUR_QUEUES = 0x20 /* Halt all current queues */
|
---|
145 | } drmLockFlags;
|
---|
146 |
|
---|
147 | typedef enum {
|
---|
148 | DRM_CONTEXT_PRESERVED = 0x01, /* This context is preserved and
|
---|
149 | never swapped. */
|
---|
150 | DRM_CONTEXT_2DONLY = 0x02 /* This context is for 2D rendering only. */
|
---|
151 | } drmContextFlags, *drmContextFlagsPtr;
|
---|
152 |
|
---|
153 | typedef struct _drmBufDesc {
|
---|
154 | int count; /* Number of buffers of this size */
|
---|
155 | int size; /* Size in bytes */
|
---|
156 | int low_mark; /* Low water mark */
|
---|
157 | int high_mark; /* High water mark */
|
---|
158 | } drmBufDesc, *drmBufDescPtr;
|
---|
159 |
|
---|
160 | typedef struct _drmBufInfo {
|
---|
161 | int count; /* Number of buffers described in list */
|
---|
162 | drmBufDescPtr list; /* List of buffer descriptions */
|
---|
163 | } drmBufInfo, *drmBufInfoPtr;
|
---|
164 |
|
---|
165 | typedef struct _drmBuf {
|
---|
166 | int idx; /* Index into master buflist */
|
---|
167 | int total; /* Buffer size */
|
---|
168 | int used; /* Amount of buffer in use (for DMA) */
|
---|
169 | drmAddress address; /* Address */
|
---|
170 | } drmBuf, *drmBufPtr;
|
---|
171 |
|
---|
172 | typedef struct _drmBufMap {
|
---|
173 | int count; /* Number of buffers mapped */
|
---|
174 | drmBufPtr list; /* Buffers */
|
---|
175 | } drmBufMap, *drmBufMapPtr;
|
---|
176 |
|
---|
177 | typedef struct _drmLock {
|
---|
178 | volatile unsigned int lock;
|
---|
179 | char padding[60];
|
---|
180 | /* This is big enough for most current (and future?) architectures:
|
---|
181 | DEC Alpha: 32 bytes
|
---|
182 | Intel Merced: ?
|
---|
183 | Intel P5/PPro/PII/PIII: 32 bytes
|
---|
184 | Intel StrongARM: 32 bytes
|
---|
185 | Intel i386/i486: 16 bytes
|
---|
186 | MIPS: 32 bytes (?)
|
---|
187 | Motorola 68k: 16 bytes
|
---|
188 | Motorola PowerPC: 32 bytes
|
---|
189 | Sun SPARC: 32 bytes
|
---|
190 | */
|
---|
191 | } drmLock, *drmLockPtr;
|
---|
192 |
|
---|
193 | typedef struct _drmDMAReq {
|
---|
194 | /* Indices here refer to the offset into
|
---|
195 | list in drmBufInfo */
|
---|
196 | drmContext context; /* Context handle */
|
---|
197 | int send_count; /* Number of buffers to send */
|
---|
198 | int *send_list; /* List of handles to buffers */
|
---|
199 | int *send_sizes; /* Lengths of data to send, in bytes */
|
---|
200 | drmDMAFlags flags; /* Flags */
|
---|
201 | int request_count; /* Number of buffers requested */
|
---|
202 | int request_size; /* Desired size of buffers requested */
|
---|
203 | int *request_list; /* Buffer information */
|
---|
204 | int *request_sizes; /* Minimum acceptable sizes */
|
---|
205 | int granted_count; /* Number of buffers granted at this size */
|
---|
206 | } drmDMAReq, *drmDMAReqPtr;
|
---|
207 |
|
---|
208 | typedef struct _drmRegion {
|
---|
209 | drmHandle handle;
|
---|
210 | unsigned int offset;
|
---|
211 | drmSize size;
|
---|
212 | drmAddress map;
|
---|
213 | } drmRegion, *drmRegionPtr;
|
---|
214 |
|
---|
215 | typedef struct _drmTextureRegion {
|
---|
216 | unsigned char next;
|
---|
217 | unsigned char prev;
|
---|
218 | unsigned char in_use;
|
---|
219 | unsigned char padding; /* Explicitly pad this out */
|
---|
220 | unsigned int age;
|
---|
221 | } drmTextureRegion, *drmTextureRegionPtr;
|
---|
222 |
|
---|
223 |
|
---|
224 | typedef struct _drmClipRect {
|
---|
225 | unsigned short x1; /* Upper left: inclusive */
|
---|
226 | unsigned short y1;
|
---|
227 | unsigned short x2; /* Lower right: exclusive */
|
---|
228 | unsigned short y2;
|
---|
229 | } drmClipRect, *drmClipRectPtr;
|
---|
230 |
|
---|
231 |
|
---|
232 | typedef enum {
|
---|
233 | DRM_VBLANK_ABSOLUTE = 0x0, /* Wait for specific vblank sequence number */
|
---|
234 | DRM_VBLANK_RELATIVE = 0x1, /* Wait for given number of vblanks */
|
---|
235 | DRM_VBLANK_SIGNAL = 0x40000000 /* Send signal instead of blocking */
|
---|
236 | } drmVBlankSeqType;
|
---|
237 |
|
---|
238 | typedef struct _drmVBlankReq {
|
---|
239 | drmVBlankSeqType type;
|
---|
240 | unsigned int sequence;
|
---|
241 | unsigned long signal;
|
---|
242 | } drmVBlankReq, *drmVBlankReqPtr;
|
---|
243 |
|
---|
244 | typedef struct _drmVBlankReply {
|
---|
245 | drmVBlankSeqType type;
|
---|
246 | unsigned int sequence;
|
---|
247 | long tval_sec;
|
---|
248 | long tval_usec;
|
---|
249 | } drmVBlankReply, *drmVBlankReplyPtr;
|
---|
250 |
|
---|
251 | typedef union _drmVBlank {
|
---|
252 | drmVBlankReq request;
|
---|
253 | drmVBlankReply reply;
|
---|
254 | } drmVBlank, *drmVBlankPtr;
|
---|
255 |
|
---|
256 |
|
---|
257 |
|
---|
258 | #define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
|
---|
259 |
|
---|
260 | #define DRM_LOCK_HELD 0x80000000 /* Hardware lock is held */
|
---|
261 | #define DRM_LOCK_CONT 0x40000000 /* Hardware lock is contended */
|
---|
262 |
|
---|
263 | #if defined(__GNUC__) && (__GNUC__ >= 2)
|
---|
264 | # if defined(__i386) || defined(__x86_64__)
|
---|
265 | /* Reflect changes here to drmP.h */
|
---|
266 | #define DRM_CAS(lock,old,new,__ret) \
|
---|
267 | do { \
|
---|
268 | int __dummy; /* Can't mark eax as clobbered */ \
|
---|
269 | __asm__ __volatile__( \
|
---|
270 | "lock ; cmpxchg %4,%1\n\t" \
|
---|
271 | "setnz %0" \
|
---|
272 | : "=d" (__ret), \
|
---|
273 | "=m" (__drm_dummy_lock(lock)), \
|
---|
274 | "=a" (__dummy) \
|
---|
275 | : "2" (old), \
|
---|
276 | "r" (new)); \
|
---|
277 | } while (0)
|
---|
278 |
|
---|
279 | #elif defined(__alpha__)
|
---|
280 |
|
---|
281 | #define DRM_CAS(lock, old, new, ret) \
|
---|
282 | do { \
|
---|
283 | int old32; \
|
---|
284 | int cur32; \
|
---|
285 | __asm__ __volatile__( \
|
---|
286 | " mb\n" \
|
---|
287 | " zap %4, 0xF0, %0\n" \
|
---|
288 | " ldl_l %1, %2\n" \
|
---|
289 | " zap %1, 0xF0, %1\n" \
|
---|
290 | " cmpeq %0, %1, %1\n" \
|
---|
291 | " beq %1, 1f\n" \
|
---|
292 | " bis %5, %5, %1\n" \
|
---|
293 | " stl_c %1, %2\n" \
|
---|
294 | "1: xor %1, 1, %1\n" \
|
---|
295 | " stl %1, %3" \
|
---|
296 | : "+r" (old32), \
|
---|
297 | "+&r" (cur32), \
|
---|
298 | "=m" (__drm_dummy_lock(lock)),\
|
---|
299 | "=m" (ret) \
|
---|
300 | : "r" (old), \
|
---|
301 | "r" (new)); \
|
---|
302 | } while(0)
|
---|
303 |
|
---|
304 | #elif defined(__sparc__)
|
---|
305 |
|
---|
306 | #define DRM_CAS(lock,old,new,__ret) \
|
---|
307 | do { register unsigned int __old __asm("o0"); \
|
---|
308 | register unsigned int __new __asm("o1"); \
|
---|
309 | register volatile unsigned int *__lock __asm("o2"); \
|
---|
310 | __old = old; \
|
---|
311 | __new = new; \
|
---|
312 | __lock = (volatile unsigned int *)lock; \
|
---|
313 | __asm__ __volatile__( \
|
---|
314 | /*"cas [%2], %3, %0"*/ \
|
---|
315 | ".word 0xd3e29008\n\t" \
|
---|
316 | /*"membar #StoreStore | #StoreLoad"*/ \
|
---|
317 | ".word 0x8143e00a" \
|
---|
318 | : "=&r" (__new) \
|
---|
319 | : "0" (__new), \
|
---|
320 | "r" (__lock), \
|
---|
321 | "r" (__old) \
|
---|
322 | : "memory"); \
|
---|
323 | __ret = (__new != __old); \
|
---|
324 | } while(0)
|
---|
325 |
|
---|
326 | #elif defined(__ia64__)
|
---|
327 |
|
---|
328 | #if 0
|
---|
329 | /* this currently generates bad code (missing stop bits)... */
|
---|
330 | #include <ia64intrin.h>
|
---|
331 |
|
---|
332 | #define DRM_CAS(lock,old,new,__ret) \
|
---|
333 | do { \
|
---|
334 | __ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \
|
---|
335 | (old), (new)) \
|
---|
336 | != (old)); \
|
---|
337 | } while (0)
|
---|
338 |
|
---|
339 | #else
|
---|
340 | #define DRM_CAS(lock,old,new,__ret) \
|
---|
341 | do { \
|
---|
342 | unsigned int __result, __old = (old); \
|
---|
343 | __asm__ __volatile__( \
|
---|
344 | "mf\n" \
|
---|
345 | "mov ar.ccv=%2\n" \
|
---|
346 | ";;\n" \
|
---|
347 | "cmpxchg4.acq %0=%1,%3,ar.ccv" \
|
---|
348 | : "=r" (__result), "=m" (__drm_dummy_lock(lock)) \
|
---|
349 | : "r" (__old), "r" (new) \
|
---|
350 | : "memory"); \
|
---|
351 | __ret = (__result) != (__old); \
|
---|
352 | } while (0)
|
---|
353 |
|
---|
354 | #endif
|
---|
355 |
|
---|
356 | #elif defined(__powerpc__)
|
---|
357 |
|
---|
358 | #define DRM_CAS(lock,old,new,__ret) \
|
---|
359 | do { \
|
---|
360 | __asm__ __volatile__( \
|
---|
361 | "sync;" \
|
---|
362 | "0: lwarx %0,0,%1;" \
|
---|
363 | " xor. %0,%3,%0;" \
|
---|
364 | " bne 1f;" \
|
---|
365 | " stwcx. %2,0,%1;" \
|
---|
366 | " bne- 0b;" \
|
---|
367 | "1: " \
|
---|
368 | "sync;" \
|
---|
369 | : "=&r"(__ret) \
|
---|
370 | : "r"(lock), "r"(new), "r"(old) \
|
---|
371 | : "cr0", "memory"); \
|
---|
372 | } while (0)
|
---|
373 |
|
---|
374 | #endif /* architecture */
|
---|
375 | #endif /* __GNUC__ >= 2 */
|
---|
376 |
|
---|
377 | #ifndef DRM_CAS
|
---|
378 | #define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
|
---|
379 | #endif
|
---|
380 |
|
---|
381 | #if defined(__alpha__) || defined(__powerpc__)
|
---|
382 | #define DRM_CAS_RESULT(_result) int _result
|
---|
383 | #else
|
---|
384 | #define DRM_CAS_RESULT(_result) char _result
|
---|
385 | #endif
|
---|
386 |
|
---|
387 | #define DRM_LIGHT_LOCK(fd,lock,context) \
|
---|
388 | do { \
|
---|
389 | DRM_CAS_RESULT(__ret); \
|
---|
390 | DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
|
---|
391 | if (__ret) drmGetLock(fd,context,0); \
|
---|
392 | } while(0)
|
---|
393 |
|
---|
394 | /* This one counts fast locks -- for
|
---|
395 | benchmarking only. */
|
---|
396 | #define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count) \
|
---|
397 | do { \
|
---|
398 | DRM_CAS_RESULT(__ret); \
|
---|
399 | DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
|
---|
400 | if (__ret) drmGetLock(fd,context,0); \
|
---|
401 | else ++count; \
|
---|
402 | } while(0)
|
---|
403 |
|
---|
404 | #define DRM_LOCK(fd,lock,context,flags) \
|
---|
405 | do { \
|
---|
406 | if (flags) drmGetLock(fd,context,flags); \
|
---|
407 | else DRM_LIGHT_LOCK(fd,lock,context); \
|
---|
408 | } while(0)
|
---|
409 |
|
---|
410 | #define DRM_UNLOCK(fd,lock,context) \
|
---|
411 | do { \
|
---|
412 | DRM_CAS_RESULT(__ret); \
|
---|
413 | DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret); \
|
---|
414 | if (__ret) drmUnlock(fd,context); \
|
---|
415 | } while(0)
|
---|
416 |
|
---|
417 | /* Simple spin locks */
|
---|
418 | #define DRM_SPINLOCK(spin,val) \
|
---|
419 | do { \
|
---|
420 | DRM_CAS_RESULT(__ret); \
|
---|
421 | do { \
|
---|
422 | DRM_CAS(spin,0,val,__ret); \
|
---|
423 | if (__ret) while ((spin)->lock); \
|
---|
424 | } while (__ret); \
|
---|
425 | } while(0)
|
---|
426 |
|
---|
427 | #define DRM_SPINLOCK_TAKE(spin,val) \
|
---|
428 | do { \
|
---|
429 | DRM_CAS_RESULT(__ret); \
|
---|
430 | int cur; \
|
---|
431 | do { \
|
---|
432 | cur = (*spin).lock; \
|
---|
433 | DRM_CAS(spin,cur,val,__ret); \
|
---|
434 | } while (__ret); \
|
---|
435 | } while(0)
|
---|
436 |
|
---|
437 | #define DRM_SPINLOCK_COUNT(spin,val,count,__ret) \
|
---|
438 | do { \
|
---|
439 | int __i; \
|
---|
440 | __ret = 1; \
|
---|
441 | for (__i = 0; __ret && __i < count; __i++) { \
|
---|
442 | DRM_CAS(spin,0,val,__ret); \
|
---|
443 | if (__ret) for (;__i < count && (spin)->lock; __i++); \
|
---|
444 | } \
|
---|
445 | } while(0)
|
---|
446 |
|
---|
447 | #define DRM_SPINUNLOCK(spin,val) \
|
---|
448 | do { \
|
---|
449 | DRM_CAS_RESULT(__ret); \
|
---|
450 | if ((*spin).lock == val) { /* else server stole lock */ \
|
---|
451 | do { \
|
---|
452 | DRM_CAS(spin,val,0,__ret); \
|
---|
453 | } while (__ret); \
|
---|
454 | } \
|
---|
455 | } while(0)
|
---|
456 |
|
---|
457 | /* General user-level programmer's API: unprivileged */
|
---|
458 | extern int drmAvailable(void);
|
---|
459 | extern int drmOpen(const char *name, const char *busid);
|
---|
460 | extern int drmClose(int fd);
|
---|
461 | extern drmVersionPtr drmGetVersion(int fd);
|
---|
462 | extern drmVersionPtr drmGetLibVersion(int fd);
|
---|
463 | extern void drmFreeVersion(drmVersionPtr);
|
---|
464 | extern int drmGetMagic(int fd, drmMagicPtr magic);
|
---|
465 | extern char *drmGetBusid(int fd);
|
---|
466 | extern int drmGetInterruptFromBusID(int fd, int busnum, int devnum,
|
---|
467 | int funcnum);
|
---|
468 | extern int drmGetMap(int fd, int idx, drmHandle *offset,
|
---|
469 | drmSize *size, drmMapType *type,
|
---|
470 | drmMapFlags *flags, drmHandle *handle,
|
---|
471 | int *mtrr);
|
---|
472 | extern int drmGetClient(int fd, int idx, int *auth, int *pid,
|
---|
473 | int *uid, unsigned long *magic,
|
---|
474 | unsigned long *iocs);
|
---|
475 | extern int drmGetStats(int fd, drmStatsT *stats);
|
---|
476 | extern int drmCommandNone(int fd, unsigned long drmCommandIndex);
|
---|
477 | extern int drmCommandRead(int fd, unsigned long drmCommandIndex,
|
---|
478 | void *data, unsigned long size);
|
---|
479 | extern int drmCommandWrite(int fd, unsigned long drmCommandIndex,
|
---|
480 | void *data, unsigned long size);
|
---|
481 | extern int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
|
---|
482 | void *data, unsigned long size);
|
---|
483 |
|
---|
484 | /* General user-level programmer's API: X server (root) only */
|
---|
485 | extern void drmFreeBusid(const char *busid);
|
---|
486 | extern int drmSetBusid(int fd, const char *busid);
|
---|
487 | extern int drmAuthMagic(int fd, drmMagic magic);
|
---|
488 | extern int drmAddMap(int fd,
|
---|
489 | drmHandle offset,
|
---|
490 | drmSize size,
|
---|
491 | drmMapType type,
|
---|
492 | drmMapFlags flags,
|
---|
493 | drmHandlePtr handle);
|
---|
494 | extern int drmRmMap(int fd, drmHandle handle);
|
---|
495 | extern int drmAddContextPrivateMapping(int fd, drmContext ctx_id,
|
---|
496 | drmHandle handle);
|
---|
497 |
|
---|
498 | extern int drmAddBufs(int fd, int count, int size,
|
---|
499 | drmBufDescFlags flags,
|
---|
500 | int agp_offset);
|
---|
501 | extern int drmMarkBufs(int fd, double low, double high);
|
---|
502 | extern int drmCreateContext(int fd, drmContextPtr handle);
|
---|
503 | extern int drmSetContextFlags(int fd, drmContext context,
|
---|
504 | drmContextFlags flags);
|
---|
505 | extern int drmGetContextFlags(int fd, drmContext context,
|
---|
506 | drmContextFlagsPtr flags);
|
---|
507 | extern int drmAddContextTag(int fd, drmContext context, void *tag);
|
---|
508 | extern int drmDelContextTag(int fd, drmContext context);
|
---|
509 | extern void *drmGetContextTag(int fd, drmContext context);
|
---|
510 | extern drmContextPtr drmGetReservedContextList(int fd, int *count);
|
---|
511 | extern void drmFreeReservedContextList(drmContextPtr);
|
---|
512 | extern int drmSwitchToContext(int fd, drmContext context);
|
---|
513 | extern int drmDestroyContext(int fd, drmContext handle);
|
---|
514 | extern int drmCreateDrawable(int fd, drmDrawablePtr handle);
|
---|
515 | extern int drmDestroyDrawable(int fd, drmDrawable handle);
|
---|
516 | extern int drmCtlInstHandler(int fd, int irq);
|
---|
517 | extern int drmCtlUninstHandler(int fd);
|
---|
518 | extern int drmInstallSIGIOHandler(int fd,
|
---|
519 | void (*f)(int fd,
|
---|
520 | void *oldctx,
|
---|
521 | void *newctx));
|
---|
522 | extern int drmRemoveSIGIOHandler(int fd);
|
---|
523 |
|
---|
524 | /* General user-level programmer's API: authenticated client and/or X */
|
---|
525 | extern int drmMap(int fd,
|
---|
526 | drmHandle handle,
|
---|
527 | drmSize size,
|
---|
528 | drmAddressPtr address);
|
---|
529 | extern int drmUnmap(drmAddress address, drmSize size);
|
---|
530 | extern drmBufInfoPtr drmGetBufInfo(int fd);
|
---|
531 | extern drmBufMapPtr drmMapBufs(int fd);
|
---|
532 | extern int drmUnmapBufs(drmBufMapPtr bufs);
|
---|
533 | extern int drmDMA(int fd, drmDMAReqPtr request);
|
---|
534 | extern int drmFreeBufs(int fd, int count, int *list);
|
---|
535 | extern int drmGetLock(int fd,
|
---|
536 | drmContext context,
|
---|
537 | drmLockFlags flags);
|
---|
538 | extern int drmUnlock(int fd, drmContext context);
|
---|
539 | extern int drmFinish(int fd, int context, drmLockFlags flags);
|
---|
540 | extern int drmGetContextPrivateMapping(int fd, drmContext ctx_id,
|
---|
541 | drmHandlePtr handle);
|
---|
542 |
|
---|
543 | /* AGP/GART support: X server (root) only */
|
---|
544 | extern int drmAgpAcquire(int fd);
|
---|
545 | extern int drmAgpRelease(int fd);
|
---|
546 | extern int drmAgpEnable(int fd, unsigned long mode);
|
---|
547 | extern int drmAgpAlloc(int fd, unsigned long size,
|
---|
548 | unsigned long type, unsigned long *address,
|
---|
549 | unsigned long *handle);
|
---|
550 | extern int drmAgpFree(int fd, unsigned long handle);
|
---|
551 | extern int drmAgpBind(int fd, unsigned long handle,
|
---|
552 | unsigned long offset);
|
---|
553 | extern int drmAgpUnbind(int fd, unsigned long handle);
|
---|
554 |
|
---|
555 | /* AGP/GART info: authenticated client and/or X */
|
---|
556 | extern int drmAgpVersionMajor(int fd);
|
---|
557 | extern int drmAgpVersionMinor(int fd);
|
---|
558 | extern unsigned long drmAgpGetMode(int fd);
|
---|
559 | extern unsigned long drmAgpBase(int fd); /* Physical location */
|
---|
560 | extern unsigned long drmAgpSize(int fd); /* Bytes */
|
---|
561 | extern unsigned long drmAgpMemoryUsed(int fd);
|
---|
562 | extern unsigned long drmAgpMemoryAvail(int fd);
|
---|
563 | extern unsigned int drmAgpVendorId(int fd);
|
---|
564 | extern unsigned int drmAgpDeviceId(int fd);
|
---|
565 |
|
---|
566 | /* PCI scatter/gather support: X server (root) only */
|
---|
567 | extern int drmScatterGatherAlloc(int fd, unsigned long size,
|
---|
568 | unsigned long *handle);
|
---|
569 | extern int drmScatterGatherFree(int fd, unsigned long handle);
|
---|
570 |
|
---|
571 | extern int drmWaitVBlank(int fd, drmVBlankPtr vbl);
|
---|
572 |
|
---|
573 | /* Support routines */
|
---|
574 | extern int drmError(int err, const char *label);
|
---|
575 | extern void *drmMalloc(int size);
|
---|
576 | extern void drmFree(void *pt);
|
---|
577 |
|
---|
578 | /* Hash table routines */
|
---|
579 | extern void *drmHashCreate(void);
|
---|
580 | extern int drmHashDestroy(void *t);
|
---|
581 | extern int drmHashLookup(void *t, unsigned long key, void **value);
|
---|
582 | extern int drmHashInsert(void *t, unsigned long key, void *value);
|
---|
583 | extern int drmHashDelete(void *t, unsigned long key);
|
---|
584 | extern int drmHashFirst(void *t, unsigned long *key, void **value);
|
---|
585 | extern int drmHashNext(void *t, unsigned long *key, void **value);
|
---|
586 |
|
---|
587 | /* PRNG routines */
|
---|
588 | extern void *drmRandomCreate(unsigned long seed);
|
---|
589 | extern int drmRandomDestroy(void *state);
|
---|
590 | extern unsigned long drmRandom(void *state);
|
---|
591 | extern double drmRandomDouble(void *state);
|
---|
592 |
|
---|
593 | /* Skip list routines */
|
---|
594 |
|
---|
595 | extern void *drmSLCreate(void);
|
---|
596 | extern int drmSLDestroy(void *l);
|
---|
597 | extern int drmSLLookup(void *l, unsigned long key, void **value);
|
---|
598 | extern int drmSLInsert(void *l, unsigned long key, void *value);
|
---|
599 | extern int drmSLDelete(void *l, unsigned long key);
|
---|
600 | extern int drmSLNext(void *l, unsigned long *key, void **value);
|
---|
601 | extern int drmSLFirst(void *l, unsigned long *key, void **value);
|
---|
602 | extern void drmSLDump(void *l);
|
---|
603 | extern int drmSLLookupNeighbors(void *l, unsigned long key,
|
---|
604 | unsigned long *prev_key, void **prev_value,
|
---|
605 | unsigned long *next_key, void **next_value);
|
---|
606 |
|
---|
607 | #endif
|
---|