OSDN Git Service

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