aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg2009-11-17 10:14:54 -0600
committerKristian Høgsberg2009-11-17 10:15:06 -0600
commit4f57abfe66091281c9f59c14e6ea27b524b55d5b (patch)
treef00d1022cf208b381b93aa5c96858164e6a3f602 /xf86drm.h
parent9dd3613073aa2491cef440725fdfa0cf1e8f1a42 (diff)
downloadexternal-libdrm-4f57abfe66091281c9f59c14e6ea27b524b55d5b.tar.gz
external-libdrm-4f57abfe66091281c9f59c14e6ea27b524b55d5b.tar.xz
external-libdrm-4f57abfe66091281c9f59c14e6ea27b524b55d5b.zip
Move libdrm/ up one level
Diffstat (limited to 'xf86drm.h')
-rw-r--r--xf86drm.h689
1 files changed, 689 insertions, 0 deletions
diff --git a/xf86drm.h b/xf86drm.h
new file mode 100644
index 00000000..2cb9c9e9
--- /dev/null
+++ b/xf86drm.h
@@ -0,0 +1,689 @@
1/**
2 * \file xf86drm.h
3 * OS-independent header for DRM user-level library interface.
4 *
5 * \author Rickard E. (Rik) Faith <faith@valinux.com>
6 */
7
8/*
9 * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
10 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
11 * All Rights Reserved.
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice (including the next
21 * paragraph) shall be included in all copies or substantial portions of the
22 * Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
28 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 * DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34#ifndef _XF86DRM_H_
35#define _XF86DRM_H_
36
37#include <stdarg.h>
38#include <sys/types.h>
39#include <stdint.h>
40#include <drm.h>
41
42 /* Defaults, if nothing set in xf86config */
43#define DRM_DEV_UID 0
44#define DRM_DEV_GID 0
45/* Default /dev/dri directory permissions 0755 */
46#define DRM_DEV_DIRMODE \
47 (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
48#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
49
50#define DRM_DIR_NAME "/dev/dri"
51#define DRM_DEV_NAME "%s/card%d"
52#define DRM_CONTROL_DEV_NAME "%s/controlD%d"
53#define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
54
55#define DRM_ERR_NO_DEVICE (-1001)
56#define DRM_ERR_NO_ACCESS (-1002)
57#define DRM_ERR_NOT_ROOT (-1003)
58#define DRM_ERR_INVALID (-1004)
59#define DRM_ERR_NO_FD (-1005)
60
61#define DRM_AGP_NO_HANDLE 0
62
63typedef unsigned int drmSize, *drmSizePtr; /**< For mapped regions */
64typedef void *drmAddress, **drmAddressPtr; /**< For mapped regions */
65
66typedef struct _drmServerInfo {
67 int (*debug_print)(const char *format, va_list ap);
68 int (*load_module)(const char *name);
69 void (*get_perms)(gid_t *, mode_t *);
70} drmServerInfo, *drmServerInfoPtr;
71
72typedef struct drmHashEntry {
73 int fd;
74 void (*f)(int, void *, void *);
75 void *tagTable;
76} drmHashEntry;
77
78extern int drmIoctl(int fd, unsigned long request, void *arg);
79extern void *drmGetHashTable(void);
80extern drmHashEntry *drmGetEntry(int fd);
81
82/**
83 * Driver version information.
84 *
85 * \sa drmGetVersion() and drmSetVersion().
86 */
87typedef struct _drmVersion {
88 int version_major; /**< Major version */
89 int version_minor; /**< Minor version */
90 int version_patchlevel; /**< Patch level */
91 int name_len; /**< Length of name buffer */
92 char *name; /**< Name of driver */
93 int date_len; /**< Length of date buffer */
94 char *date; /**< User-space buffer to hold date */
95 int desc_len; /**< Length of desc buffer */
96 char *desc; /**< User-space buffer to hold desc */
97} drmVersion, *drmVersionPtr;
98
99typedef struct _drmStats {
100 unsigned long count; /**< Number of data */
101 struct {
102 unsigned long value; /**< Value from kernel */
103 const char *long_format; /**< Suggested format for long_name */
104 const char *long_name; /**< Long name for value */
105 const char *rate_format; /**< Suggested format for rate_name */
106 const char *rate_name; /**< Short name for value per second */
107 int isvalue; /**< True if value (vs. counter) */
108 const char *mult_names; /**< Multiplier names (e.g., "KGM") */
109 int mult; /**< Multiplier value (e.g., 1024) */
110 int verbose; /**< Suggest only in verbose output */
111 } data[15];
112} drmStatsT;
113
114
115 /* All of these enums *MUST* match with the
116 kernel implementation -- so do *NOT*
117 change them! (The drmlib implementation
118 will just copy the flags instead of
119 translating them.) */
120typedef enum {
121 DRM_FRAME_BUFFER = 0, /**< WC, no caching, no core dump */
122 DRM_REGISTERS = 1, /**< no caching, no core dump */
123 DRM_SHM = 2, /**< shared, cached */
124 DRM_AGP = 3, /**< AGP/GART */
125 DRM_SCATTER_GATHER = 4, /**< PCI scatter/gather */
126 DRM_CONSISTENT = 5 /**< PCI consistent */
127} drmMapType;
128
129typedef enum {
130 DRM_RESTRICTED = 0x0001, /**< Cannot be mapped to client-virtual */
131 DRM_READ_ONLY = 0x0002, /**< Read-only in client-virtual */
132 DRM_LOCKED = 0x0004, /**< Physical pages locked */
133 DRM_KERNEL = 0x0008, /**< Kernel requires access */
134 DRM_WRITE_COMBINING = 0x0010, /**< Use write-combining, if available */
135 DRM_CONTAINS_LOCK = 0x0020, /**< SHM page that contains lock */
136 DRM_REMOVABLE = 0x0040 /**< Removable mapping */
137} drmMapFlags;
138
139/**
140 * \warning These values *MUST* match drm.h
141 */
142typedef enum {
143 /** \name Flags for DMA buffer dispatch */
144 /*@{*/
145 DRM_DMA_BLOCK = 0x01, /**<
146 * Block until buffer dispatched.
147 *
148 * \note the buffer may not yet have been
149 * processed by the hardware -- getting a
150 * hardware lock with the hardware quiescent
151 * will ensure that the buffer has been
152 * processed.
153 */
154 DRM_DMA_WHILE_LOCKED = 0x02, /**< Dispatch while lock held */
155 DRM_DMA_PRIORITY = 0x04, /**< High priority dispatch */
156 /*@}*/
157
158 /** \name Flags for DMA buffer request */
159 /*@{*/
160 DRM_DMA_WAIT = 0x10, /**< Wait for free buffers */
161 DRM_DMA_SMALLER_OK = 0x20, /**< Smaller-than-requested buffers OK */
162 DRM_DMA_LARGER_OK = 0x40 /**< Larger-than-requested buffers OK */
163 /*@}*/
164} drmDMAFlags;
165
166typedef enum {
167 DRM_PAGE_ALIGN = 0x01,
168 DRM_AGP_BUFFER = 0x02,
169 DRM_SG_BUFFER = 0x04,
170 DRM_FB_BUFFER = 0x08,
171 DRM_PCI_BUFFER_RO = 0x10
172} drmBufDescFlags;
173
174typedef enum {
175 DRM_LOCK_READY = 0x01, /**< Wait until hardware is ready for DMA */
176 DRM_LOCK_QUIESCENT = 0x02, /**< Wait until hardware quiescent */
177 DRM_LOCK_FLUSH = 0x04, /**< Flush this context's DMA queue first */
178 DRM_LOCK_FLUSH_ALL = 0x08, /**< Flush all DMA queues first */
179 /* These *HALT* flags aren't supported yet
180 -- they will be used to support the
181 full-screen DGA-like mode. */
182 DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */
183 DRM_HALT_CUR_QUEUES = 0x20 /**< Halt all current queues */
184} drmLockFlags;
185
186typedef enum {
187 DRM_CONTEXT_PRESERVED = 0x01, /**< This context is preserved and
188 never swapped. */
189 DRM_CONTEXT_2DONLY = 0x02 /**< This context is for 2D rendering only. */
190} drm_context_tFlags, *drm_context_tFlagsPtr;
191
192typedef struct _drmBufDesc {
193 int count; /**< Number of buffers of this size */
194 int size; /**< Size in bytes */
195 int low_mark; /**< Low water mark */
196 int high_mark; /**< High water mark */
197} drmBufDesc, *drmBufDescPtr;
198
199typedef struct _drmBufInfo {
200 int count; /**< Number of buffers described in list */
201 drmBufDescPtr list; /**< List of buffer descriptions */
202} drmBufInfo, *drmBufInfoPtr;
203
204typedef struct _drmBuf {
205 int idx; /**< Index into the master buffer list */
206 int total; /**< Buffer size */
207 int used; /**< Amount of buffer in use (for DMA) */
208 drmAddress address; /**< Address */
209} drmBuf, *drmBufPtr;
210
211/**
212 * Buffer mapping information.
213 *
214 * Used by drmMapBufs() and drmUnmapBufs() to store information about the
215 * mapped buffers.
216 */
217typedef struct _drmBufMap {
218 int count; /**< Number of buffers mapped */
219 drmBufPtr list; /**< Buffers */
220} drmBufMap, *drmBufMapPtr;
221
222typedef struct _drmLock {
223 volatile unsigned int lock;
224 char padding[60];
225 /* This is big enough for most current (and future?) architectures:
226 DEC Alpha: 32 bytes
227 Intel Merced: ?
228 Intel P5/PPro/PII/PIII: 32 bytes
229 Intel StrongARM: 32 bytes
230 Intel i386/i486: 16 bytes
231 MIPS: 32 bytes (?)
232 Motorola 68k: 16 bytes
233 Motorola PowerPC: 32 bytes
234 Sun SPARC: 32 bytes
235 */
236} drmLock, *drmLockPtr;
237
238/**
239 * Indices here refer to the offset into
240 * list in drmBufInfo
241 */
242typedef struct _drmDMAReq {
243 drm_context_t context; /**< Context handle */
244 int send_count; /**< Number of buffers to send */
245 int *send_list; /**< List of handles to buffers */
246 int *send_sizes; /**< Lengths of data to send, in bytes */
247 drmDMAFlags flags; /**< Flags */
248 int request_count; /**< Number of buffers requested */
249 int request_size; /**< Desired size of buffers requested */
250 int *request_list; /**< Buffer information */
251 int *request_sizes; /**< Minimum acceptable sizes */
252 int granted_count; /**< Number of buffers granted at this size */
253} drmDMAReq, *drmDMAReqPtr;
254
255typedef struct _drmRegion {
256 drm_handle_t handle;
257 unsigned int offset;
258 drmSize size;
259 drmAddress map;
260} drmRegion, *drmRegionPtr;
261
262typedef struct _drmTextureRegion {
263 unsigned char next;
264 unsigned char prev;
265 unsigned char in_use;
266 unsigned char padding; /**< Explicitly pad this out */
267 unsigned int age;
268} drmTextureRegion, *drmTextureRegionPtr;
269
270
271typedef enum {
272 DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */
273 DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */
274 DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */
275 DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */
276 DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */
277 DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */
278 DRM_VBLANK_SIGNAL = 0x40000000 /* Send signal instead of blocking */
279} drmVBlankSeqType;
280
281typedef struct _drmVBlankReq {
282 drmVBlankSeqType type;
283 unsigned int sequence;
284 unsigned long signal;
285} drmVBlankReq, *drmVBlankReqPtr;
286
287typedef struct _drmVBlankReply {
288 drmVBlankSeqType type;
289 unsigned int sequence;
290 long tval_sec;
291 long tval_usec;
292} drmVBlankReply, *drmVBlankReplyPtr;
293
294typedef union _drmVBlank {
295 drmVBlankReq request;
296 drmVBlankReply reply;
297} drmVBlank, *drmVBlankPtr;
298
299typedef struct _drmSetVersion {
300 int drm_di_major;
301 int drm_di_minor;
302 int drm_dd_major;
303 int drm_dd_minor;
304} drmSetVersion, *drmSetVersionPtr;
305
306#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
307
308#define DRM_LOCK_HELD 0x80000000U /**< Hardware lock is held */
309#define DRM_LOCK_CONT 0x40000000U /**< Hardware lock is contended */
310
311#if defined(__GNUC__) && (__GNUC__ >= 2)
312# if defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
313 /* Reflect changes here to drmP.h */
314#define DRM_CAS(lock,old,new,__ret) \
315 do { \
316 int __dummy; /* Can't mark eax as clobbered */ \
317 __asm__ __volatile__( \
318 "lock ; cmpxchg %4,%1\n\t" \
319 "setnz %0" \
320 : "=d" (__ret), \
321 "=m" (__drm_dummy_lock(lock)), \
322 "=a" (__dummy) \
323 : "2" (old), \
324 "r" (new)); \
325 } while (0)
326
327#elif defined(__alpha__)
328
329#define DRM_CAS(lock, old, new, ret) \
330 do { \
331 int tmp, old32; \
332 __asm__ __volatile__( \
333 " addl $31, %5, %3\n" \
334 "1: ldl_l %0, %2\n" \
335 " cmpeq %0, %3, %1\n" \
336 " beq %1, 2f\n" \
337 " mov %4, %0\n" \
338 " stl_c %0, %2\n" \
339 " beq %0, 3f\n" \
340 " mb\n" \
341 "2: cmpeq %1, 0, %1\n" \
342 ".subsection 2\n" \
343 "3: br 1b\n" \
344 ".previous" \
345 : "=&r"(tmp), "=&r"(ret), \
346 "=m"(__drm_dummy_lock(lock)), \
347 "=&r"(old32) \
348 : "r"(new), "r"(old) \
349 : "memory"); \
350 } while (0)
351
352#elif defined(__sparc__)
353
354#define DRM_CAS(lock,old,new,__ret) \
355do { register unsigned int __old __asm("o0"); \
356 register unsigned int __new __asm("o1"); \
357 register volatile unsigned int *__lock __asm("o2"); \
358 __old = old; \
359 __new = new; \
360 __lock = (volatile unsigned int *)lock; \
361 __asm__ __volatile__( \
362 /*"cas [%2], %3, %0"*/ \
363 ".word 0xd3e29008\n\t" \
364 /*"membar #StoreStore | #StoreLoad"*/ \
365 ".word 0x8143e00a" \
366 : "=&r" (__new) \
367 : "0" (__new), \
368 "r" (__lock), \
369 "r" (__old) \
370 : "memory"); \
371 __ret = (__new != __old); \
372} while(0)
373
374#elif defined(__ia64__)
375
376#ifdef __INTEL_COMPILER
377/* this currently generates bad code (missing stop bits)... */
378#include <ia64intrin.h>
379
380#define DRM_CAS(lock,old,new,__ret) \
381 do { \
382 unsigned long __result, __old = (old) & 0xffffffff; \
383 __mf(); \
384 __result = _InterlockedCompareExchange_acq(&__drm_dummy_lock(lock), (new), __old);\
385 __ret = (__result) != (__old); \
386/* __ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \
387 (old), (new)) \
388 != (old)); */\
389 } while (0)
390
391#else
392#define DRM_CAS(lock,old,new,__ret) \
393 do { \
394 unsigned int __result, __old = (old); \
395 __asm__ __volatile__( \
396 "mf\n" \
397 "mov ar.ccv=%2\n" \
398 ";;\n" \
399 "cmpxchg4.acq %0=%1,%3,ar.ccv" \
400 : "=r" (__result), "=m" (__drm_dummy_lock(lock)) \
401 : "r" ((unsigned long)__old), "r" (new) \
402 : "memory"); \
403 __ret = (__result) != (__old); \
404 } while (0)
405
406#endif
407
408#elif defined(__powerpc__)
409
410#define DRM_CAS(lock,old,new,__ret) \
411 do { \
412 __asm__ __volatile__( \
413 "sync;" \
414 "0: lwarx %0,0,%1;" \
415 " xor. %0,%3,%0;" \
416 " bne 1f;" \
417 " stwcx. %2,0,%1;" \
418 " bne- 0b;" \
419 "1: " \
420 "sync;" \
421 : "=&r"(__ret) \
422 : "r"(lock), "r"(new), "r"(old) \
423 : "cr0", "memory"); \
424 } while (0)
425
426#endif /* architecture */
427#endif /* __GNUC__ >= 2 */
428
429#ifndef DRM_CAS
430#define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
431#endif
432
433#if defined(__alpha__)
434#define DRM_CAS_RESULT(_result) long _result
435#elif defined(__powerpc__)
436#define DRM_CAS_RESULT(_result) int _result
437#else
438#define DRM_CAS_RESULT(_result) char _result
439#endif
440
441#define DRM_LIGHT_LOCK(fd,lock,context) \
442 do { \
443 DRM_CAS_RESULT(__ret); \
444 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
445 if (__ret) drmGetLock(fd,context,0); \
446 } while(0)
447
448 /* This one counts fast locks -- for
449 benchmarking only. */
450#define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count) \
451 do { \
452 DRM_CAS_RESULT(__ret); \
453 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
454 if (__ret) drmGetLock(fd,context,0); \
455 else ++count; \
456 } while(0)
457
458#define DRM_LOCK(fd,lock,context,flags) \
459 do { \
460 if (flags) drmGetLock(fd,context,flags); \
461 else DRM_LIGHT_LOCK(fd,lock,context); \
462 } while(0)
463
464#define DRM_UNLOCK(fd,lock,context) \
465 do { \
466 DRM_CAS_RESULT(__ret); \
467 DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret); \
468 if (__ret) drmUnlock(fd,context); \
469 } while(0)
470
471 /* Simple spin locks */
472#define DRM_SPINLOCK(spin,val) \
473 do { \
474 DRM_CAS_RESULT(__ret); \
475 do { \
476 DRM_CAS(spin,0,val,__ret); \
477 if (__ret) while ((spin)->lock); \
478 } while (__ret); \
479 } while(0)
480
481#define DRM_SPINLOCK_TAKE(spin,val) \
482 do { \
483 DRM_CAS_RESULT(__ret); \
484 int cur; \
485 do { \
486 cur = (*spin).lock; \
487 DRM_CAS(spin,cur,val,__ret); \
488 } while (__ret); \
489 } while(0)
490
491#define DRM_SPINLOCK_COUNT(spin,val,count,__ret) \
492 do { \
493 int __i; \
494 __ret = 1; \
495 for (__i = 0; __ret && __i < count; __i++) { \
496 DRM_CAS(spin,0,val,__ret); \
497 if (__ret) for (;__i < count && (spin)->lock; __i++); \
498 } \
499 } while(0)
500
501#define DRM_SPINUNLOCK(spin,val) \
502 do { \
503 DRM_CAS_RESULT(__ret); \
504 if ((*spin).lock == val) { /* else server stole lock */ \
505 do { \
506 DRM_CAS(spin,val,0,__ret); \
507 } while (__ret); \
508 } \
509 } while(0)
510
511
512
513/* General user-level programmer's API: unprivileged */
514extern int drmAvailable(void);
515extern int drmOpen(const char *name, const char *busid);
516extern int drmOpenControl(int minor);
517extern int drmClose(int fd);
518extern drmVersionPtr drmGetVersion(int fd);
519extern drmVersionPtr drmGetLibVersion(int fd);
520extern void drmFreeVersion(drmVersionPtr);
521extern int drmGetMagic(int fd, drm_magic_t * magic);
522extern char *drmGetBusid(int fd);
523extern int drmGetInterruptFromBusID(int fd, int busnum, int devnum,
524 int funcnum);
525extern int drmGetMap(int fd, int idx, drm_handle_t *offset,
526 drmSize *size, drmMapType *type,
527 drmMapFlags *flags, drm_handle_t *handle,
528 int *mtrr);
529extern int drmGetClient(int fd, int idx, int *auth, int *pid,
530 int *uid, unsigned long *magic,
531 unsigned long *iocs);
532extern int drmGetStats(int fd, drmStatsT *stats);
533extern int drmSetInterfaceVersion(int fd, drmSetVersion *version);
534extern int drmCommandNone(int fd, unsigned long drmCommandIndex);
535extern int drmCommandRead(int fd, unsigned long drmCommandIndex,
536 void *data, unsigned long size);
537extern int drmCommandWrite(int fd, unsigned long drmCommandIndex,
538 void *data, unsigned long size);
539extern int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
540 void *data, unsigned long size);
541
542/* General user-level programmer's API: X server (root) only */
543extern void drmFreeBusid(const char *busid);
544extern int drmSetBusid(int fd, const char *busid);
545extern int drmAuthMagic(int fd, drm_magic_t magic);
546extern int drmAddMap(int fd,
547 drm_handle_t offset,
548 drmSize size,
549 drmMapType type,
550 drmMapFlags flags,
551 drm_handle_t * handle);
552extern int drmRmMap(int fd, drm_handle_t handle);
553extern int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id,
554 drm_handle_t handle);
555
556extern int drmAddBufs(int fd, int count, int size,
557 drmBufDescFlags flags,
558 int agp_offset);
559extern int drmMarkBufs(int fd, double low, double high);
560extern int drmCreateContext(int fd, drm_context_t * handle);
561extern int drmSetContextFlags(int fd, drm_context_t context,
562 drm_context_tFlags flags);
563extern int drmGetContextFlags(int fd, drm_context_t context,
564 drm_context_tFlagsPtr flags);
565extern int drmAddContextTag(int fd, drm_context_t context, void *tag);
566extern int drmDelContextTag(int fd, drm_context_t context);
567extern void *drmGetContextTag(int fd, drm_context_t context);
568extern drm_context_t * drmGetReservedContextList(int fd, int *count);
569extern void drmFreeReservedContextList(drm_context_t *);
570extern int drmSwitchToContext(int fd, drm_context_t context);
571extern int drmDestroyContext(int fd, drm_context_t handle);
572extern int drmCreateDrawable(int fd, drm_drawable_t * handle);
573extern int drmDestroyDrawable(int fd, drm_drawable_t handle);
574extern int drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
575 drm_drawable_info_type_t type,
576 unsigned int num, void *data);
577extern int drmCtlInstHandler(int fd, int irq);
578extern int drmCtlUninstHandler(int fd);
579
580/* General user-level programmer's API: authenticated client and/or X */
581extern int drmMap(int fd,
582 drm_handle_t handle,
583 drmSize size,
584 drmAddressPtr address);
585extern int drmUnmap(drmAddress address, drmSize size);
586extern drmBufInfoPtr drmGetBufInfo(int fd);
587extern drmBufMapPtr drmMapBufs(int fd);
588extern int drmUnmapBufs(drmBufMapPtr bufs);
589extern int drmDMA(int fd, drmDMAReqPtr request);
590extern int drmFreeBufs(int fd, int count, int *list);
591extern int drmGetLock(int fd,
592 drm_context_t context,
593 drmLockFlags flags);
594extern int drmUnlock(int fd, drm_context_t context);
595extern int drmFinish(int fd, int context, drmLockFlags flags);
596extern int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id,
597 drm_handle_t * handle);
598
599/* AGP/GART support: X server (root) only */
600extern int drmAgpAcquire(int fd);
601extern int drmAgpRelease(int fd);
602extern int drmAgpEnable(int fd, unsigned long mode);
603extern int drmAgpAlloc(int fd, unsigned long size,
604 unsigned long type, unsigned long *address,
605 drm_handle_t *handle);
606extern int drmAgpFree(int fd, drm_handle_t handle);
607extern int drmAgpBind(int fd, drm_handle_t handle,
608 unsigned long offset);
609extern int drmAgpUnbind(int fd, drm_handle_t handle);
610
611/* AGP/GART info: authenticated client and/or X */
612extern int drmAgpVersionMajor(int fd);
613extern int drmAgpVersionMinor(int fd);
614extern unsigned long drmAgpGetMode(int fd);
615extern unsigned long drmAgpBase(int fd); /* Physical location */
616extern unsigned long drmAgpSize(int fd); /* Bytes */
617extern unsigned long drmAgpMemoryUsed(int fd);
618extern unsigned long drmAgpMemoryAvail(int fd);
619extern unsigned int drmAgpVendorId(int fd);
620extern unsigned int drmAgpDeviceId(int fd);
621
622/* PCI scatter/gather support: X server (root) only */
623extern int drmScatterGatherAlloc(int fd, unsigned long size,
624 drm_handle_t *handle);
625extern int drmScatterGatherFree(int fd, drm_handle_t handle);
626
627extern int drmWaitVBlank(int fd, drmVBlankPtr vbl);
628
629/* Support routines */
630extern void drmSetServerInfo(drmServerInfoPtr info);
631extern int drmError(int err, const char *label);
632extern void *drmMalloc(int size);
633extern void drmFree(void *pt);
634
635/* Hash table routines */
636extern void *drmHashCreate(void);
637extern int drmHashDestroy(void *t);
638extern int drmHashLookup(void *t, unsigned long key, void **value);
639extern int drmHashInsert(void *t, unsigned long key, void *value);
640extern int drmHashDelete(void *t, unsigned long key);
641extern int drmHashFirst(void *t, unsigned long *key, void **value);
642extern int drmHashNext(void *t, unsigned long *key, void **value);
643
644/* PRNG routines */
645extern void *drmRandomCreate(unsigned long seed);
646extern int drmRandomDestroy(void *state);
647extern unsigned long drmRandom(void *state);
648extern double drmRandomDouble(void *state);
649
650/* Skip list routines */
651
652extern void *drmSLCreate(void);
653extern int drmSLDestroy(void *l);
654extern int drmSLLookup(void *l, unsigned long key, void **value);
655extern int drmSLInsert(void *l, unsigned long key, void *value);
656extern int drmSLDelete(void *l, unsigned long key);
657extern int drmSLNext(void *l, unsigned long *key, void **value);
658extern int drmSLFirst(void *l, unsigned long *key, void **value);
659extern void drmSLDump(void *l);
660extern int drmSLLookupNeighbors(void *l, unsigned long key,
661 unsigned long *prev_key, void **prev_value,
662 unsigned long *next_key, void **next_value);
663
664extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened);
665extern void drmCloseOnce(int fd);
666extern void drmMsg(const char *format, ...);
667
668extern int drmSetMaster(int fd);
669extern int drmDropMaster(int fd);
670
671#define DRM_EVENT_CONTEXT_VERSION 1
672
673typedef struct _drmEventContext {
674
675 /* This struct is versioned so we can add more pointers if we
676 * add more events. */
677 int version;
678
679 void (*vblank_handler)(int fd,
680 unsigned int sequence,
681 unsigned int tv_sec,
682 unsigned int tv_usec,
683 void *user_data);
684
685} drmEventContext, *drmEventContextPtr;
686
687extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
688
689#endif