OSDN Git Service

Merging drm-ttm-0-2-branch
[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     DRM_FB_BUFFER        = 0x08,
153     DRM_PCI_BUFFER_RO    = 0x10
154 } drmBufDescFlags;
155
156 typedef enum {
157     DRM_LOCK_READY      = 0x01, /**< Wait until hardware is ready for DMA */
158     DRM_LOCK_QUIESCENT  = 0x02, /**< Wait until hardware quiescent */
159     DRM_LOCK_FLUSH      = 0x04, /**< Flush this context's DMA queue first */
160     DRM_LOCK_FLUSH_ALL  = 0x08, /**< Flush all DMA queues first */
161                                 /* These *HALT* flags aren't supported yet
162                                    -- they will be used to support the
163                                    full-screen DGA-like mode. */
164     DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */
165     DRM_HALT_CUR_QUEUES = 0x20  /**< Halt all current queues */
166 } drmLockFlags;
167
168 typedef enum {
169     DRM_CONTEXT_PRESERVED = 0x01, /**< This context is preserved and
170                                      never swapped. */
171     DRM_CONTEXT_2DONLY    = 0x02  /**< This context is for 2D rendering only. */
172 } drm_context_tFlags, *drm_context_tFlagsPtr;
173
174 typedef struct _drmBufDesc {
175     int              count;       /**< Number of buffers of this size */
176     int              size;        /**< Size in bytes */
177     int              low_mark;    /**< Low water mark */
178     int              high_mark;   /**< High water mark */
179 } drmBufDesc, *drmBufDescPtr;
180
181 typedef struct _drmBufInfo {
182     int              count;       /**< Number of buffers described in list */
183     drmBufDescPtr    list;        /**< List of buffer descriptions */
184 } drmBufInfo, *drmBufInfoPtr;
185
186 typedef struct _drmBuf {
187     int              idx;         /**< Index into the master buffer list */
188     int              total;       /**< Buffer size */
189     int              used;        /**< Amount of buffer in use (for DMA) */
190     drmAddress       address;     /**< Address */
191 } drmBuf, *drmBufPtr;
192
193 /**
194  * Buffer mapping information.
195  *
196  * Used by drmMapBufs() and drmUnmapBufs() to store information about the
197  * mapped buffers.
198  */
199 typedef struct _drmBufMap {
200     int              count;       /**< Number of buffers mapped */
201     drmBufPtr        list;        /**< Buffers */
202 } drmBufMap, *drmBufMapPtr;
203
204 typedef struct _drmLock {
205     volatile unsigned int lock;
206     char                      padding[60];
207     /* This is big enough for most current (and future?) architectures:
208        DEC Alpha:              32 bytes
209        Intel Merced:           ?
210        Intel P5/PPro/PII/PIII: 32 bytes
211        Intel StrongARM:        32 bytes
212        Intel i386/i486:        16 bytes
213        MIPS:                   32 bytes (?)
214        Motorola 68k:           16 bytes
215        Motorola PowerPC:       32 bytes
216        Sun SPARC:              32 bytes
217     */
218 } drmLock, *drmLockPtr;
219
220 /**
221  * Indices here refer to the offset into
222  * list in drmBufInfo
223  */
224 typedef struct _drmDMAReq {
225     drm_context_t    context;     /**< Context handle */
226     int           send_count;     /**< Number of buffers to send */
227     int           *send_list;     /**< List of handles to buffers */
228     int           *send_sizes;    /**< Lengths of data to send, in bytes */
229     drmDMAFlags   flags;          /**< Flags */
230     int           request_count;  /**< Number of buffers requested */
231     int           request_size;   /**< Desired size of buffers requested */
232     int           *request_list;  /**< Buffer information */
233     int           *request_sizes; /**< Minimum acceptable sizes */
234     int           granted_count;  /**< Number of buffers granted at this size */
235 } drmDMAReq, *drmDMAReqPtr;
236
237 typedef struct _drmRegion {
238     drm_handle_t     handle;
239     unsigned int  offset;
240     drmSize       size;
241     drmAddress    map;
242 } drmRegion, *drmRegionPtr;
243
244 typedef struct _drmTextureRegion {
245     unsigned char next;
246     unsigned char prev;
247     unsigned char in_use;
248     unsigned char padding;      /**< Explicitly pad this out */
249     unsigned int  age;
250 } drmTextureRegion, *drmTextureRegionPtr;
251
252
253 typedef enum {
254     DRM_VBLANK_ABSOLUTE = 0x0,  /**< Wait for specific vblank sequence number */
255     DRM_VBLANK_RELATIVE = 0x1,  /**< Wait for given number of vblanks */
256     DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */
257     DRM_VBLANK_SECONDARY = 0x20000000,  /**< Secondary display controller */
258     DRM_VBLANK_SIGNAL   = 0x40000000    /* Send signal instead of blocking */
259 } drmVBlankSeqType;
260
261 typedef struct _drmVBlankReq {
262         drmVBlankSeqType type;
263         unsigned int sequence;
264         unsigned long signal;
265 } drmVBlankReq, *drmVBlankReqPtr;
266
267 typedef struct _drmVBlankReply {
268         drmVBlankSeqType type;
269         unsigned int sequence;
270         long tval_sec;
271         long tval_usec;
272 } drmVBlankReply, *drmVBlankReplyPtr;
273
274 typedef union _drmVBlank {
275         drmVBlankReq request;
276         drmVBlankReply reply;
277 } drmVBlank, *drmVBlankPtr;
278
279 typedef struct _drmSetVersion {
280         int drm_di_major;
281         int drm_di_minor;
282         int drm_dd_major;
283         int drm_dd_minor;
284 } drmSetVersion, *drmSetVersionPtr;
285
286 #define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
287
288 #define DRM_LOCK_HELD  0x80000000U /**< Hardware lock is held */
289 #define DRM_LOCK_CONT  0x40000000U /**< Hardware lock is contended */
290
291 #if defined(__GNUC__) && (__GNUC__ >= 2)
292 # if defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
293                                 /* Reflect changes here to drmP.h */
294 #define DRM_CAS(lock,old,new,__ret)                                    \
295         do {                                                           \
296                 int __dummy;    /* Can't mark eax as clobbered */      \
297                 __asm__ __volatile__(                                  \
298                         "lock ; cmpxchg %4,%1\n\t"                     \
299                         "setnz %0"                                     \
300                         : "=d" (__ret),                                \
301                           "=m" (__drm_dummy_lock(lock)),               \
302                           "=a" (__dummy)                               \
303                         : "2" (old),                                   \
304                           "r" (new));                                  \
305         } while (0)
306
307 #elif defined(__alpha__)
308
309 #define DRM_CAS(lock, old, new, ret)            \
310         do {                                    \
311                 int old32;                      \
312                 int cur32;                      \
313                 __asm__ __volatile__(           \
314                 "       mb\n"                   \
315                 "       zap   %4, 0xF0, %0\n"   \
316                 "       ldl_l %1, %2\n"         \
317                 "       zap   %1, 0xF0, %1\n"   \
318                 "       cmpeq %0, %1, %1\n"     \
319                 "       beq   %1, 1f\n"         \
320                 "       bis   %5, %5, %1\n"     \
321                 "       stl_c %1, %2\n"         \
322                 "1:     xor   %1, 1, %1\n"      \
323                 "       stl   %1, %3"           \
324                 : "=r" (old32),                 \
325                   "=&r" (cur32),                \
326                    "=m" (__drm_dummy_lock(lock)),\
327                    "=m" (ret)                   \
328                 : "r" (old),                    \
329                   "r" (new));                   \
330         } while(0)
331
332 #elif defined(__sparc__)
333
334 #define DRM_CAS(lock,old,new,__ret)                             \
335 do {    register unsigned int __old __asm("o0");                \
336         register unsigned int __new __asm("o1");                \
337         register volatile unsigned int *__lock __asm("o2");     \
338         __old = old;                                            \
339         __new = new;                                            \
340         __lock = (volatile unsigned int *)lock;                 \
341         __asm__ __volatile__(                                   \
342                 /*"cas [%2], %3, %0"*/                          \
343                 ".word 0xd3e29008\n\t"                          \
344                 /*"membar #StoreStore | #StoreLoad"*/           \
345                 ".word 0x8143e00a"                              \
346                 : "=&r" (__new)                                 \
347                 : "0" (__new),                                  \
348                   "r" (__lock),                                 \
349                   "r" (__old)                                   \
350                 : "memory");                                    \
351         __ret = (__new != __old);                               \
352 } while(0)
353
354 #elif defined(__ia64__)
355
356 #ifdef __INTEL_COMPILER
357 /* this currently generates bad code (missing stop bits)... */
358 #include <ia64intrin.h>
359
360 #define DRM_CAS(lock,old,new,__ret)                                           \
361         do {                                                                  \
362                 unsigned long __result, __old = (old) & 0xffffffff;             \
363                 __mf();                                                         \
364                 __result = _InterlockedCompareExchange_acq(&__drm_dummy_lock(lock), (new), __old);\
365                 __ret = (__result) != (__old);                                  \
366 /*              __ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \
367                                                      (old), (new))            \
368                          != (old));                                           */\
369         } while (0)
370
371 #else
372 #define DRM_CAS(lock,old,new,__ret)                                       \
373         do {                                                              \
374                 unsigned int __result, __old = (old);                     \
375                 __asm__ __volatile__(                                     \
376                         "mf\n"                                            \
377                         "mov ar.ccv=%2\n"                                 \
378                         ";;\n"                                            \
379                         "cmpxchg4.acq %0=%1,%3,ar.ccv"                    \
380                         : "=r" (__result), "=m" (__drm_dummy_lock(lock))  \
381                         : "r" ((unsigned long)__old), "r" (new)                   \
382                         : "memory");                                      \
383                 __ret = (__result) != (__old);                            \
384         } while (0)
385
386 #endif
387
388 #elif defined(__powerpc__)
389
390 #define DRM_CAS(lock,old,new,__ret)                     \
391         do {                                            \
392                 __asm__ __volatile__(                   \
393                         "sync;"                         \
394                         "0:    lwarx %0,0,%1;"          \
395                         "      xor. %0,%3,%0;"          \
396                         "      bne 1f;"                 \
397                         "      stwcx. %2,0,%1;"         \
398                         "      bne- 0b;"                \
399                         "1:    "                        \
400                         "sync;"                         \
401                 : "=&r"(__ret)                          \
402                 : "r"(lock), "r"(new), "r"(old)         \
403                 : "cr0", "memory");                     \
404         } while (0)
405
406 #endif /* architecture */
407 #endif /* __GNUC__ >= 2 */
408
409 #ifndef DRM_CAS
410 #define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
411 #endif
412
413 #if defined(__alpha__) || defined(__powerpc__)
414 #define DRM_CAS_RESULT(_result)         int _result
415 #else
416 #define DRM_CAS_RESULT(_result)         char _result
417 #endif
418
419 #define DRM_LIGHT_LOCK(fd,lock,context)                                \
420         do {                                                           \
421                 DRM_CAS_RESULT(__ret);                                 \
422                 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret);     \
423                 if (__ret) drmGetLock(fd,context,0);                   \
424         } while(0)
425
426                                 /* This one counts fast locks -- for
427                                    benchmarking only. */
428 #define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count)                    \
429         do {                                                           \
430                 DRM_CAS_RESULT(__ret);                                 \
431                 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret);     \
432                 if (__ret) drmGetLock(fd,context,0);                   \
433                 else       ++count;                                    \
434         } while(0)
435
436 #define DRM_LOCK(fd,lock,context,flags)                                \
437         do {                                                           \
438                 if (flags) drmGetLock(fd,context,flags);               \
439                 else       DRM_LIGHT_LOCK(fd,lock,context);            \
440         } while(0)
441
442 #define DRM_UNLOCK(fd,lock,context)                                    \
443         do {                                                           \
444                 DRM_CAS_RESULT(__ret);                                 \
445                 DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret);     \
446                 if (__ret) drmUnlock(fd,context);                      \
447         } while(0)
448
449                                 /* Simple spin locks */
450 #define DRM_SPINLOCK(spin,val)                                         \
451         do {                                                           \
452             DRM_CAS_RESULT(__ret);                                     \
453             do {                                                       \
454                 DRM_CAS(spin,0,val,__ret);                             \
455                 if (__ret) while ((spin)->lock);                       \
456             } while (__ret);                                           \
457         } while(0)
458
459 #define DRM_SPINLOCK_TAKE(spin,val)                                    \
460         do {                                                           \
461             DRM_CAS_RESULT(__ret);                                     \
462             int  cur;                                                  \
463             do {                                                       \
464                 cur = (*spin).lock;                                    \
465                 DRM_CAS(spin,cur,val,__ret);                           \
466             } while (__ret);                                           \
467         } while(0)
468
469 #define DRM_SPINLOCK_COUNT(spin,val,count,__ret)                       \
470         do {                                                           \
471             int  __i;                                                  \
472             __ret = 1;                                                 \
473             for (__i = 0; __ret && __i < count; __i++) {               \
474                 DRM_CAS(spin,0,val,__ret);                             \
475                 if (__ret) for (;__i < count && (spin)->lock; __i++);  \
476             }                                                          \
477         } while(0)
478
479 #define DRM_SPINUNLOCK(spin,val)                                       \
480         do {                                                           \
481             DRM_CAS_RESULT(__ret);                                     \
482             if ((*spin).lock == val) { /* else server stole lock */    \
483                 do {                                                   \
484                     DRM_CAS(spin,val,0,__ret);                         \
485                 } while (__ret);                                       \
486             }                                                          \
487         } while(0)
488
489
490
491 /* General user-level programmer's API: unprivileged */
492 extern int           drmAvailable(void);
493 extern int           drmOpen(const char *name, const char *busid);
494 extern int           drmClose(int fd);
495 extern drmVersionPtr drmGetVersion(int fd);
496 extern drmVersionPtr drmGetLibVersion(int fd);
497 extern void          drmFreeVersion(drmVersionPtr);
498 extern int           drmGetMagic(int fd, drm_magic_t * magic);
499 extern char          *drmGetBusid(int fd);
500 extern int           drmGetInterruptFromBusID(int fd, int busnum, int devnum,
501                                               int funcnum);
502 extern int           drmGetMap(int fd, int idx, drm_handle_t *offset,
503                                drmSize *size, drmMapType *type,
504                                drmMapFlags *flags, drm_handle_t *handle,
505                                int *mtrr);
506 extern int           drmGetClient(int fd, int idx, int *auth, int *pid,
507                                   int *uid, unsigned long *magic,
508                                   unsigned long *iocs);
509 extern int           drmGetStats(int fd, drmStatsT *stats);
510 extern int           drmSetInterfaceVersion(int fd, drmSetVersion *version);
511 extern int           drmCommandNone(int fd, unsigned long drmCommandIndex);
512 extern int           drmCommandRead(int fd, unsigned long drmCommandIndex,
513                                     void *data, unsigned long size);
514 extern int           drmCommandWrite(int fd, unsigned long drmCommandIndex,
515                                      void *data, unsigned long size);
516 extern int           drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
517                                          void *data, unsigned long size);
518
519 /* General user-level programmer's API: X server (root) only  */
520 extern void          drmFreeBusid(const char *busid);
521 extern int           drmSetBusid(int fd, const char *busid);
522 extern int           drmAuthMagic(int fd, drm_magic_t magic);
523 extern int           drmAddMap(int fd,
524                                drm_handle_t offset,
525                                drmSize size,
526                                drmMapType type,
527                                drmMapFlags flags,
528                                drm_handle_t * handle);
529 extern int           drmRmMap(int fd, drm_handle_t handle);
530 extern int           drmAddContextPrivateMapping(int fd, drm_context_t ctx_id,
531                                                  drm_handle_t handle);
532
533 extern int           drmAddBufs(int fd, int count, int size,
534                                 drmBufDescFlags flags,
535                                 int agp_offset);
536 extern int           drmMarkBufs(int fd, double low, double high);
537 extern int           drmCreateContext(int fd, drm_context_t * handle);
538 extern int           drmSetContextFlags(int fd, drm_context_t context,
539                                         drm_context_tFlags flags);
540 extern int           drmGetContextFlags(int fd, drm_context_t context,
541                                         drm_context_tFlagsPtr flags);
542 extern int           drmAddContextTag(int fd, drm_context_t context, void *tag);
543 extern int           drmDelContextTag(int fd, drm_context_t context);
544 extern void          *drmGetContextTag(int fd, drm_context_t context);
545 extern drm_context_t * drmGetReservedContextList(int fd, int *count);
546 extern void          drmFreeReservedContextList(drm_context_t *);
547 extern int           drmSwitchToContext(int fd, drm_context_t context);
548 extern int           drmDestroyContext(int fd, drm_context_t handle);
549 extern int           drmCreateDrawable(int fd, drm_drawable_t * handle);
550 extern int           drmDestroyDrawable(int fd, drm_drawable_t handle);
551 extern int           drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
552                                            drm_drawable_info_type_t type,
553                                            unsigned int num, void *data);
554 extern int           drmCtlInstHandler(int fd, int irq);
555 extern int           drmCtlUninstHandler(int fd);
556
557 /* General user-level programmer's API: authenticated client and/or X */
558 extern int           drmMap(int fd,
559                             drm_handle_t handle,
560                             drmSize size,
561                             drmAddressPtr address);
562 extern int           drmUnmap(drmAddress address, drmSize size);
563 extern drmBufInfoPtr drmGetBufInfo(int fd);
564 extern drmBufMapPtr  drmMapBufs(int fd);
565 extern int           drmUnmapBufs(drmBufMapPtr bufs);
566 extern int           drmDMA(int fd, drmDMAReqPtr request);
567 extern int           drmFreeBufs(int fd, int count, int *list);
568 extern int           drmGetLock(int fd,
569                                 drm_context_t context,
570                                 drmLockFlags flags);
571 extern int           drmUnlock(int fd, drm_context_t context);
572 extern int           drmFinish(int fd, int context, drmLockFlags flags);
573 extern int           drmGetContextPrivateMapping(int fd, drm_context_t ctx_id, 
574                                                  drm_handle_t * handle);
575
576 /* AGP/GART support: X server (root) only */
577 extern int           drmAgpAcquire(int fd);
578 extern int           drmAgpRelease(int fd);
579 extern int           drmAgpEnable(int fd, unsigned long mode);
580 extern int           drmAgpAlloc(int fd, unsigned long size,
581                                  unsigned long type, unsigned long *address,
582                                  drm_handle_t *handle);
583 extern int           drmAgpFree(int fd, drm_handle_t handle);
584 extern int           drmAgpBind(int fd, drm_handle_t handle,
585                                 unsigned long offset);
586 extern int           drmAgpUnbind(int fd, drm_handle_t handle);
587
588 /* AGP/GART info: authenticated client and/or X */
589 extern int           drmAgpVersionMajor(int fd);
590 extern int           drmAgpVersionMinor(int fd);
591 extern unsigned long drmAgpGetMode(int fd);
592 extern unsigned long drmAgpBase(int fd); /* Physical location */
593 extern unsigned long drmAgpSize(int fd); /* Bytes */
594 extern unsigned long drmAgpMemoryUsed(int fd);
595 extern unsigned long drmAgpMemoryAvail(int fd);
596 extern unsigned int  drmAgpVendorId(int fd);
597 extern unsigned int  drmAgpDeviceId(int fd);
598
599 /* PCI scatter/gather support: X server (root) only */
600 extern int           drmScatterGatherAlloc(int fd, unsigned long size,
601                                            drm_handle_t *handle);
602 extern int           drmScatterGatherFree(int fd, drm_handle_t handle);
603
604 extern int           drmWaitVBlank(int fd, drmVBlankPtr vbl);
605
606 /* Support routines */
607 extern int           drmError(int err, const char *label);
608 extern void          *drmMalloc(int size);
609 extern void          drmFree(void *pt);
610
611 /* Hash table routines */
612 extern void *drmHashCreate(void);
613 extern int  drmHashDestroy(void *t);
614 extern int  drmHashLookup(void *t, unsigned long key, void **value);
615 extern int  drmHashInsert(void *t, unsigned long key, void *value);
616 extern int  drmHashDelete(void *t, unsigned long key);
617 extern int  drmHashFirst(void *t, unsigned long *key, void **value);
618 extern int  drmHashNext(void *t, unsigned long *key, void **value);
619
620 /* PRNG routines */
621 extern void          *drmRandomCreate(unsigned long seed);
622 extern int           drmRandomDestroy(void *state);
623 extern unsigned long drmRandom(void *state);
624 extern double        drmRandomDouble(void *state);
625
626 /* Skip list routines */
627
628 extern void *drmSLCreate(void);
629 extern int  drmSLDestroy(void *l);
630 extern int  drmSLLookup(void *l, unsigned long key, void **value);
631 extern int  drmSLInsert(void *l, unsigned long key, void *value);
632 extern int  drmSLDelete(void *l, unsigned long key);
633 extern int  drmSLNext(void *l, unsigned long *key, void **value);
634 extern int  drmSLFirst(void *l, unsigned long *key, void **value);
635 extern void drmSLDump(void *l);
636 extern int  drmSLLookupNeighbors(void *l, unsigned long key,
637                                  unsigned long *prev_key, void **prev_value,
638                                  unsigned long *next_key, void **next_value);
639
640 #include "xf86mm.h"
641
642 #endif