Back to index

libdrm  2.4.37
xf86drm.h
Go to the documentation of this file.
00001 
00008 /*
00009  * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
00010  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
00011  * All Rights Reserved.
00012  *
00013  * Permission is hereby granted, free of charge, to any person obtaining a
00014  * copy of this software and associated documentation files (the "Software"),
00015  * to deal in the Software without restriction, including without limitation
00016  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00017  * and/or sell copies of the Software, and to permit persons to whom the
00018  * Software is furnished to do so, subject to the following conditions:
00019  *
00020  * The above copyright notice and this permission notice (including the next
00021  * paragraph) shall be included in all copies or substantial portions of the
00022  * Software.
00023  *
00024  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00025  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00026  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00027  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00028  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00029  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00030  * DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 #ifndef _XF86DRM_H_
00035 #define _XF86DRM_H_
00036 
00037 #include <stdarg.h>
00038 #include <sys/types.h>
00039 #include <stdint.h>
00040 #include <drm.h>
00041 
00042 #if defined(__cplusplus) || defined(c_plusplus)
00043 extern "C" {
00044 #endif
00045 
00046 #ifndef DRM_MAX_MINOR
00047 #define DRM_MAX_MINOR   16
00048 #endif
00049 
00050 #if defined(__linux__)
00051 
00052 #define DRM_IOCTL_NR(n)            _IOC_NR(n)
00053 #define DRM_IOC_VOID        _IOC_NONE
00054 #define DRM_IOC_READ        _IOC_READ
00055 #define DRM_IOC_WRITE              _IOC_WRITE
00056 #define DRM_IOC_READWRITE   _IOC_READ|_IOC_WRITE
00057 #define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
00058 
00059 #else /* One of the *BSDs */
00060 
00061 #include <sys/ioccom.h>
00062 #define DRM_IOCTL_NR(n)         ((n) & 0xff)
00063 #define DRM_IOC_VOID            IOC_VOID
00064 #define DRM_IOC_READ            IOC_OUT
00065 #define DRM_IOC_WRITE           IOC_IN
00066 #define DRM_IOC_READWRITE       IOC_INOUT
00067 #define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
00068 
00069 #endif
00070 
00071                             /* Defaults, if nothing set in xf86config */
00072 #define DRM_DEV_UID   0
00073 #define DRM_DEV_GID   0
00074 /* Default /dev/dri directory permissions 0755 */
00075 #define DRM_DEV_DIRMODE            \
00076        (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
00077 #define DRM_DEV_MODE  (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
00078 
00079 #define DRM_DIR_NAME  "/dev/dri"
00080 #define DRM_DEV_NAME  "%s/card%d"
00081 #define DRM_CONTROL_DEV_NAME  "%s/controlD%d"
00082 #define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
00083 
00084 #define DRM_ERR_NO_DEVICE  (-1001)
00085 #define DRM_ERR_NO_ACCESS  (-1002)
00086 #define DRM_ERR_NOT_ROOT   (-1003)
00087 #define DRM_ERR_INVALID    (-1004)
00088 #define DRM_ERR_NO_FD      (-1005)
00089 
00090 #define DRM_AGP_NO_HANDLE 0
00091 
00092 typedef unsigned int  drmSize,     *drmSizePtr;      
00093 typedef void          *drmAddress, **drmAddressPtr; 
00095 typedef struct _drmServerInfo {
00096   int (*debug_print)(const char *format, va_list ap);
00097   int (*load_module)(const char *name);
00098   void (*get_perms)(gid_t *, mode_t *);
00099 } drmServerInfo, *drmServerInfoPtr;
00100 
00101 typedef struct drmHashEntry {
00102     int      fd;
00103     void     (*f)(int, void *, void *);
00104     void     *tagTable;
00105 } drmHashEntry;
00106 
00107 extern int drmIoctl(int fd, unsigned long request, void *arg);
00108 extern void *drmGetHashTable(void);
00109 extern drmHashEntry *drmGetEntry(int fd);
00110 
00116 typedef struct _drmVersion {
00117     int     version_major;        
00118     int     version_minor;        
00119     int     version_patchlevel;   
00120     int     name_len;                 
00121     char    *name;             
00122     int     date_len;             
00123     char    *date;                
00124     int     desc_len;                 
00125     char    *desc;                
00126 } drmVersion, *drmVersionPtr;
00127 
00128 typedef struct _drmStats {
00129     unsigned long count;         
00130     struct {
00131        unsigned long value;      
00132        const char    *long_format;  
00133        const char    *long_name;    
00134        const char    *rate_format;  
00135        const char    *rate_name;    
00136        int           isvalue;       
00137        const char    *mult_names;   
00138        int           mult;          
00139        int           verbose;       
00140     } data[15];
00141 } drmStatsT;
00142 
00143 
00144                             /* All of these enums *MUST* match with the
00145                                    kernel implementation -- so do *NOT*
00146                                    change them!  (The drmlib implementation
00147                                    will just copy the flags instead of
00148                                    translating them.) */
00149 typedef enum {
00150     DRM_FRAME_BUFFER    = 0,      
00151     DRM_REGISTERS       = 1,      
00152     DRM_SHM             = 2,      
00153     DRM_AGP             = 3,         
00154     DRM_SCATTER_GATHER  = 4,         
00155     DRM_CONSISTENT      = 5   
00156 } drmMapType;
00157 
00158 typedef enum {
00159     DRM_RESTRICTED      = 0x0001, 
00160     DRM_READ_ONLY       = 0x0002, 
00161     DRM_LOCKED          = 0x0004, 
00162     DRM_KERNEL          = 0x0008, 
00163     DRM_WRITE_COMBINING = 0x0010, 
00164     DRM_CONTAINS_LOCK   = 0x0020, 
00165     DRM_REMOVABLE    = 0x0040  
00166 } drmMapFlags;
00167 
00171 typedef enum {
00174     DRM_DMA_BLOCK        = 0x01, 
00183     DRM_DMA_WHILE_LOCKED = 0x02, 
00184     DRM_DMA_PRIORITY     = 0x04, 
00186 
00189     DRM_DMA_WAIT         = 0x10, 
00190     DRM_DMA_SMALLER_OK   = 0x20, 
00191     DRM_DMA_LARGER_OK    = 0x40  
00193 } drmDMAFlags;
00194 
00195 typedef enum {
00196     DRM_PAGE_ALIGN       = 0x01,
00197     DRM_AGP_BUFFER       = 0x02,
00198     DRM_SG_BUFFER        = 0x04,
00199     DRM_FB_BUFFER        = 0x08,
00200     DRM_PCI_BUFFER_RO    = 0x10
00201 } drmBufDescFlags;
00202 
00203 typedef enum {
00204     DRM_LOCK_READY      = 0x01, 
00205     DRM_LOCK_QUIESCENT  = 0x02, 
00206     DRM_LOCK_FLUSH      = 0x04, 
00207     DRM_LOCK_FLUSH_ALL  = 0x08, 
00208                             /* These *HALT* flags aren't supported yet
00209                                    -- they will be used to support the
00210                                    full-screen DGA-like mode. */
00211     DRM_HALT_ALL_QUEUES = 0x10, 
00212     DRM_HALT_CUR_QUEUES = 0x20  
00213 } drmLockFlags;
00214 
00215 typedef enum {
00216     DRM_CONTEXT_PRESERVED = 0x01, 
00218     DRM_CONTEXT_2DONLY    = 0x02  
00219 } drm_context_tFlags, *drm_context_tFlagsPtr;
00220 
00221 typedef struct _drmBufDesc {
00222     int              count;   
00223     int              size;    
00224     int              low_mark;       
00225     int              high_mark;      
00226 } drmBufDesc, *drmBufDescPtr;
00227 
00228 typedef struct _drmBufInfo {
00229     int              count;   
00230     drmBufDescPtr    list;    
00231 } drmBufInfo, *drmBufInfoPtr;
00232 
00233 typedef struct _drmBuf {
00234     int              idx;     
00235     int              total;   
00236     int              used;    
00237     drmAddress       address;        
00238 } drmBuf, *drmBufPtr;
00239 
00246 typedef struct _drmBufMap {
00247     int              count;   
00248     drmBufPtr        list;    
00249 } drmBufMap, *drmBufMapPtr;
00250 
00251 typedef struct _drmLock {
00252     volatile unsigned int lock;
00253     char                      padding[60];
00254     /* This is big enough for most current (and future?) architectures:
00255        DEC Alpha:              32 bytes
00256        Intel Merced:           ?
00257        Intel P5/PPro/PII/PIII: 32 bytes
00258        Intel StrongARM:        32 bytes
00259        Intel i386/i486:        16 bytes
00260        MIPS:                   32 bytes (?)
00261        Motorola 68k:           16 bytes
00262        Motorola PowerPC:       32 bytes
00263        Sun SPARC:              32 bytes
00264     */
00265 } drmLock, *drmLockPtr;
00266 
00271 typedef struct _drmDMAReq {
00272     drm_context_t    context;        
00273     int           send_count;     
00274     int           *send_list;     
00275     int           *send_sizes;    
00276     drmDMAFlags   flags;          
00277     int           request_count;  
00278     int           request_size;      
00279     int           *request_list;  
00280     int           *request_sizes; 
00281     int           granted_count;  
00282 } drmDMAReq, *drmDMAReqPtr;
00283 
00284 typedef struct _drmRegion {
00285     drm_handle_t     handle;
00286     unsigned int  offset;
00287     drmSize       size;
00288     drmAddress    map;
00289 } drmRegion, *drmRegionPtr;
00290 
00291 typedef struct _drmTextureRegion {
00292     unsigned char next;
00293     unsigned char prev;
00294     unsigned char in_use;
00295     unsigned char padding;  
00296     unsigned int  age;
00297 } drmTextureRegion, *drmTextureRegionPtr;
00298 
00299 
00300 typedef enum {
00301     DRM_VBLANK_ABSOLUTE = 0x0,     
00302     DRM_VBLANK_RELATIVE = 0x1,     
00303     /* bits 1-6 are reserved for high crtcs */
00304     DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e,
00305     DRM_VBLANK_EVENT = 0x4000000,  
00306     DRM_VBLANK_FLIP = 0x8000000,   
00307     DRM_VBLANK_NEXTONMISS = 0x10000000,   
00308     DRM_VBLANK_SECONDARY = 0x20000000,    
00309     DRM_VBLANK_SIGNAL   = 0x40000000      /* Send signal instead of blocking */
00310 } drmVBlankSeqType;
00311 #define DRM_VBLANK_HIGH_CRTC_SHIFT 1
00312 
00313 typedef struct _drmVBlankReq {
00314        drmVBlankSeqType type;
00315        unsigned int sequence;
00316        unsigned long signal;
00317 } drmVBlankReq, *drmVBlankReqPtr;
00318 
00319 typedef struct _drmVBlankReply {
00320        drmVBlankSeqType type;
00321        unsigned int sequence;
00322        long tval_sec;
00323        long tval_usec;
00324 } drmVBlankReply, *drmVBlankReplyPtr;
00325 
00326 typedef union _drmVBlank {
00327        drmVBlankReq request;
00328        drmVBlankReply reply;
00329 } drmVBlank, *drmVBlankPtr;
00330 
00331 typedef struct _drmSetVersion {
00332        int drm_di_major;
00333        int drm_di_minor;
00334        int drm_dd_major;
00335        int drm_dd_minor;
00336 } drmSetVersion, *drmSetVersionPtr;
00337 
00338 #define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
00339 
00340 #define DRM_LOCK_HELD  0x80000000U 
00341 #define DRM_LOCK_CONT  0x40000000U 
00343 #if defined(__GNUC__) && (__GNUC__ >= 2)
00344 # if defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
00345                             /* Reflect changes here to drmP.h */
00346 #define DRM_CAS(lock,old,new,__ret)                                    \
00347        do {                                                           \
00348                 int __dummy;       /* Can't mark eax as clobbered */      \
00349               __asm__ __volatile__(                                  \
00350                      "lock ; cmpxchg %4,%1\n\t"                     \
00351                         "setnz %0"                                     \
00352                      : "=d" (__ret),                                \
00353                        "=m" (__drm_dummy_lock(lock)),               \
00354                           "=a" (__dummy)                               \
00355                      : "2" (old),                                   \
00356                        "r" (new));                                  \
00357        } while (0)
00358 
00359 #elif defined(__alpha__)
00360 
00361 #define       DRM_CAS(lock, old, new, ret)              \
00362        do {                               \
00363               int tmp, old32;                    \
00364               __asm__ __volatile__(              \
00365               "      addl   $31, %5, %3\n"       \
00366               "1:    ldl_l  %0, %2\n"     \
00367               "      cmpeq  %0, %3, %1\n" \
00368               "      beq    %1, 2f\n"     \
00369               "      mov    %4, %0\n"     \
00370               "      stl_c  %0, %2\n"     \
00371               "      beq    %0, 3f\n"     \
00372               "      mb\n"                \
00373               "2:    cmpeq  %1, 0, %1\n"  \
00374               ".subsection 2\n"           \
00375               "3:    br     1b\n"         \
00376               ".previous"                 \
00377               : "=&r"(tmp), "=&r"(ret),   \
00378                 "=m"(__drm_dummy_lock(lock)),    \
00379                 "=&r"(old32)                     \
00380               : "r"(new), "r"(old)        \
00381               : "memory");                \
00382        } while (0)
00383 
00384 #elif defined(__sparc__)
00385 
00386 #define DRM_CAS(lock,old,new,__ret)                            \
00387 do {   register unsigned int __old __asm("o0");         \
00388        register unsigned int __new __asm("o1");         \
00389        register volatile unsigned int *__lock __asm("o2");     \
00390        __old = old;                                     \
00391        __new = new;                                     \
00392        __lock = (volatile unsigned int *)lock;                 \
00393        __asm__ __volatile__(                                   \
00394               /*"cas [%2], %3, %0"*/                           \
00395               ".word 0xd3e29008\n\t"                           \
00396               /*"membar #StoreStore | #StoreLoad"*/            \
00397               ".word 0x8143e00a"                        \
00398               : "=&r" (__new)                                  \
00399               : "0" (__new),                                   \
00400                 "r" (__lock),                                  \
00401                 "r" (__old)                             \
00402               : "memory");                              \
00403        __ret = (__new != __old);                        \
00404 } while(0)
00405 
00406 #elif defined(__ia64__)
00407 
00408 #ifdef __INTEL_COMPILER
00409 /* this currently generates bad code (missing stop bits)... */
00410 #include <ia64intrin.h>
00411 
00412 #define DRM_CAS(lock,old,new,__ret)                                         \
00413        do {                                                          \
00414               unsigned long __result, __old = (old) & 0xffffffff;            \
00415               __mf();                                                        \
00416               __result = _InterlockedCompareExchange_acq(&__drm_dummy_lock(lock), (new), __old);\
00417               __ret = (__result) != (__old);                                 \
00418 /*            __ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \
00419                                                (old), (new))         \
00420                       != (old));                                     */\
00421        } while (0)
00422 
00423 #else
00424 #define DRM_CAS(lock,old,new,__ret)                                     \
00425        do {                                                      \
00426               unsigned int __result, __old = (old);                     \
00427               __asm__ __volatile__(                                     \
00428                      "mf\n"                                      \
00429                      "mov ar.ccv=%2\n"                           \
00430                      ";;\n"                                      \
00431                      "cmpxchg4.acq %0=%1,%3,ar.ccv"                     \
00432                      : "=r" (__result), "=m" (__drm_dummy_lock(lock))  \
00433                      : "r" ((unsigned long)__old), "r" (new)                   \
00434                      : "memory");                                \
00435               __ret = (__result) != (__old);                            \
00436        } while (0)
00437 
00438 #endif
00439 
00440 #elif defined(__powerpc__)
00441 
00442 #define DRM_CAS(lock,old,new,__ret)                     \
00443        do {                                      \
00444               __asm__ __volatile__(                     \
00445                      "sync;"                            \
00446                      "0:    lwarx %0,0,%1;"             \
00447                      "      xor. %0,%3,%0;"             \
00448                      "      bne 1f;"                    \
00449                      "      stwcx. %2,0,%1;"            \
00450                      "      bne- 0b;"            \
00451                      "1:    "                    \
00452                      "sync;"                            \
00453               : "=&r"(__ret)                            \
00454               : "r"(lock), "r"(new), "r"(old)           \
00455               : "cr0", "memory");                \
00456        } while (0)
00457 
00458 #endif /* architecture */
00459 #endif /* __GNUC__ >= 2 */
00460 
00461 #ifndef DRM_CAS
00462 #define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
00463 #endif
00464 
00465 #if defined(__alpha__)
00466 #define DRM_CAS_RESULT(_result)           long _result
00467 #elif defined(__powerpc__)
00468 #define DRM_CAS_RESULT(_result)           int _result
00469 #else
00470 #define DRM_CAS_RESULT(_result)           char _result
00471 #endif
00472 
00473 #define DRM_LIGHT_LOCK(fd,lock,context)                                \
00474        do {                                                           \
00475                 DRM_CAS_RESULT(__ret);                                 \
00476               DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret);     \
00477                 if (__ret) drmGetLock(fd,context,0);                   \
00478         } while(0)
00479 
00480                             /* This one counts fast locks -- for
00481                                    benchmarking only. */
00482 #define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count)                    \
00483        do {                                                           \
00484                 DRM_CAS_RESULT(__ret);                                 \
00485               DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret);     \
00486                 if (__ret) drmGetLock(fd,context,0);                   \
00487                 else       ++count;                                    \
00488         } while(0)
00489 
00490 #define DRM_LOCK(fd,lock,context,flags)                                \
00491        do {                                                           \
00492               if (flags) drmGetLock(fd,context,flags);               \
00493               else       DRM_LIGHT_LOCK(fd,lock,context);            \
00494        } while(0)
00495 
00496 #define DRM_UNLOCK(fd,lock,context)                                    \
00497        do {                                                           \
00498                 DRM_CAS_RESULT(__ret);                                 \
00499               DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret);     \
00500                 if (__ret) drmUnlock(fd,context);                      \
00501         } while(0)
00502 
00503                             /* Simple spin locks */
00504 #define DRM_SPINLOCK(spin,val)                                         \
00505        do {                                                           \
00506             DRM_CAS_RESULT(__ret);                                     \
00507            do {                                                       \
00508               DRM_CAS(spin,0,val,__ret);                             \
00509               if (__ret) while ((spin)->lock);                       \
00510            } while (__ret);                                           \
00511        } while(0)
00512 
00513 #define DRM_SPINLOCK_TAKE(spin,val)                                    \
00514        do {                                                           \
00515             DRM_CAS_RESULT(__ret);                                     \
00516             int  cur;                                                  \
00517            do {                                                       \
00518                 cur = (*spin).lock;                                    \
00519               DRM_CAS(spin,cur,val,__ret);                           \
00520            } while (__ret);                                           \
00521        } while(0)
00522 
00523 #define DRM_SPINLOCK_COUNT(spin,val,count,__ret)                       \
00524        do {                                                           \
00525             int  __i;                                                  \
00526             __ret = 1;                                                 \
00527             for (__i = 0; __ret && __i < count; __i++) {               \
00528               DRM_CAS(spin,0,val,__ret);                             \
00529               if (__ret) for (;__i < count && (spin)->lock; __i++);  \
00530            }                                                          \
00531        } while(0)
00532 
00533 #define DRM_SPINUNLOCK(spin,val)                                       \
00534        do {                                                           \
00535             DRM_CAS_RESULT(__ret);                                     \
00536             if ((*spin).lock == val) { /* else server stole lock */    \
00537                do {                                                   \
00538                   DRM_CAS(spin,val,0,__ret);                         \
00539                } while (__ret);                                       \
00540             }                                                          \
00541        } while(0)
00542 
00543 
00544 
00545 /* General user-level programmer's API: unprivileged */
00546 extern int           drmAvailable(void);
00547 extern int           drmOpen(const char *name, const char *busid);
00548 extern int drmOpenControl(int minor);
00549 extern int           drmClose(int fd);
00550 extern drmVersionPtr drmGetVersion(int fd);
00551 extern drmVersionPtr drmGetLibVersion(int fd);
00552 extern int           drmGetCap(int fd, uint64_t capability, uint64_t *value);
00553 extern void          drmFreeVersion(drmVersionPtr);
00554 extern int           drmGetMagic(int fd, drm_magic_t * magic);
00555 extern char          *drmGetBusid(int fd);
00556 extern int           drmGetInterruptFromBusID(int fd, int busnum, int devnum,
00557                                          int funcnum);
00558 extern int           drmGetMap(int fd, int idx, drm_handle_t *offset,
00559                             drmSize *size, drmMapType *type,
00560                             drmMapFlags *flags, drm_handle_t *handle,
00561                             int *mtrr);
00562 extern int           drmGetClient(int fd, int idx, int *auth, int *pid,
00563                               int *uid, unsigned long *magic,
00564                               unsigned long *iocs);
00565 extern int           drmGetStats(int fd, drmStatsT *stats);
00566 extern int           drmSetInterfaceVersion(int fd, drmSetVersion *version);
00567 extern int           drmCommandNone(int fd, unsigned long drmCommandIndex);
00568 extern int           drmCommandRead(int fd, unsigned long drmCommandIndex,
00569                                     void *data, unsigned long size);
00570 extern int           drmCommandWrite(int fd, unsigned long drmCommandIndex,
00571                                      void *data, unsigned long size);
00572 extern int           drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
00573                                          void *data, unsigned long size);
00574 
00575 /* General user-level programmer's API: X server (root) only  */
00576 extern void          drmFreeBusid(const char *busid);
00577 extern int           drmSetBusid(int fd, const char *busid);
00578 extern int           drmAuthMagic(int fd, drm_magic_t magic);
00579 extern int           drmAddMap(int fd,
00580                             drm_handle_t offset,
00581                             drmSize size,
00582                             drmMapType type,
00583                             drmMapFlags flags,
00584                             drm_handle_t * handle);
00585 extern int         drmRmMap(int fd, drm_handle_t handle);
00586 extern int         drmAddContextPrivateMapping(int fd, drm_context_t ctx_id,
00587                                            drm_handle_t handle);
00588 
00589 extern int           drmAddBufs(int fd, int count, int size,
00590                             drmBufDescFlags flags,
00591                             int agp_offset);
00592 extern int           drmMarkBufs(int fd, double low, double high);
00593 extern int           drmCreateContext(int fd, drm_context_t * handle);
00594 extern int           drmSetContextFlags(int fd, drm_context_t context,
00595                                    drm_context_tFlags flags);
00596 extern int           drmGetContextFlags(int fd, drm_context_t context,
00597                                    drm_context_tFlagsPtr flags);
00598 extern int           drmAddContextTag(int fd, drm_context_t context, void *tag);
00599 extern int           drmDelContextTag(int fd, drm_context_t context);
00600 extern void          *drmGetContextTag(int fd, drm_context_t context);
00601 extern drm_context_t * drmGetReservedContextList(int fd, int *count);
00602 extern void          drmFreeReservedContextList(drm_context_t *);
00603 extern int           drmSwitchToContext(int fd, drm_context_t context);
00604 extern int           drmDestroyContext(int fd, drm_context_t handle);
00605 extern int           drmCreateDrawable(int fd, drm_drawable_t * handle);
00606 extern int           drmDestroyDrawable(int fd, drm_drawable_t handle);
00607 extern int           drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
00608                                       drm_drawable_info_type_t type,
00609                                       unsigned int num, void *data);
00610 extern int           drmCtlInstHandler(int fd, int irq);
00611 extern int           drmCtlUninstHandler(int fd);
00612 
00613 /* General user-level programmer's API: authenticated client and/or X */
00614 extern int           drmMap(int fd,
00615                          drm_handle_t handle,
00616                          drmSize size,
00617                          drmAddressPtr address);
00618 extern int           drmUnmap(drmAddress address, drmSize size);
00619 extern drmBufInfoPtr drmGetBufInfo(int fd);
00620 extern drmBufMapPtr  drmMapBufs(int fd);
00621 extern int           drmUnmapBufs(drmBufMapPtr bufs);
00622 extern int           drmDMA(int fd, drmDMAReqPtr request);
00623 extern int           drmFreeBufs(int fd, int count, int *list);
00624 extern int           drmGetLock(int fd,
00625                              drm_context_t context,
00626                              drmLockFlags flags);
00627 extern int           drmUnlock(int fd, drm_context_t context);
00628 extern int           drmFinish(int fd, int context, drmLockFlags flags);
00629 extern int         drmGetContextPrivateMapping(int fd, drm_context_t ctx_id, 
00630                                            drm_handle_t * handle);
00631 
00632 /* AGP/GART support: X server (root) only */
00633 extern int           drmAgpAcquire(int fd);
00634 extern int           drmAgpRelease(int fd);
00635 extern int           drmAgpEnable(int fd, unsigned long mode);
00636 extern int           drmAgpAlloc(int fd, unsigned long size,
00637                              unsigned long type, unsigned long *address,
00638                              drm_handle_t *handle);
00639 extern int           drmAgpFree(int fd, drm_handle_t handle);
00640 extern int         drmAgpBind(int fd, drm_handle_t handle,
00641                             unsigned long offset);
00642 extern int           drmAgpUnbind(int fd, drm_handle_t handle);
00643 
00644 /* AGP/GART info: authenticated client and/or X */
00645 extern int           drmAgpVersionMajor(int fd);
00646 extern int           drmAgpVersionMinor(int fd);
00647 extern unsigned long drmAgpGetMode(int fd);
00648 extern unsigned long drmAgpBase(int fd); /* Physical location */
00649 extern unsigned long drmAgpSize(int fd); /* Bytes */
00650 extern unsigned long drmAgpMemoryUsed(int fd);
00651 extern unsigned long drmAgpMemoryAvail(int fd);
00652 extern unsigned int  drmAgpVendorId(int fd);
00653 extern unsigned int  drmAgpDeviceId(int fd);
00654 
00655 /* PCI scatter/gather support: X server (root) only */
00656 extern int           drmScatterGatherAlloc(int fd, unsigned long size,
00657                                       drm_handle_t *handle);
00658 extern int           drmScatterGatherFree(int fd, drm_handle_t handle);
00659 
00660 extern int           drmWaitVBlank(int fd, drmVBlankPtr vbl);
00661 
00662 /* Support routines */
00663 extern void          drmSetServerInfo(drmServerInfoPtr info);
00664 extern int           drmError(int err, const char *label);
00665 extern void          *drmMalloc(int size);
00666 extern void          drmFree(void *pt);
00667 
00668 /* Hash table routines */
00669 extern void *drmHashCreate(void);
00670 extern int  drmHashDestroy(void *t);
00671 extern int  drmHashLookup(void *t, unsigned long key, void **value);
00672 extern int  drmHashInsert(void *t, unsigned long key, void *value);
00673 extern int  drmHashDelete(void *t, unsigned long key);
00674 extern int  drmHashFirst(void *t, unsigned long *key, void **value);
00675 extern int  drmHashNext(void *t, unsigned long *key, void **value);
00676 
00677 /* PRNG routines */
00678 extern void          *drmRandomCreate(unsigned long seed);
00679 extern int           drmRandomDestroy(void *state);
00680 extern unsigned long drmRandom(void *state);
00681 extern double        drmRandomDouble(void *state);
00682 
00683 /* Skip list routines */
00684 
00685 extern void *drmSLCreate(void);
00686 extern int  drmSLDestroy(void *l);
00687 extern int  drmSLLookup(void *l, unsigned long key, void **value);
00688 extern int  drmSLInsert(void *l, unsigned long key, void *value);
00689 extern int  drmSLDelete(void *l, unsigned long key);
00690 extern int  drmSLNext(void *l, unsigned long *key, void **value);
00691 extern int  drmSLFirst(void *l, unsigned long *key, void **value);
00692 extern void drmSLDump(void *l);
00693 extern int  drmSLLookupNeighbors(void *l, unsigned long key,
00694                              unsigned long *prev_key, void **prev_value,
00695                              unsigned long *next_key, void **next_value);
00696 
00697 extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened);
00698 extern void drmCloseOnce(int fd);
00699 extern void drmMsg(const char *format, ...);
00700 
00701 extern int drmSetMaster(int fd);
00702 extern int drmDropMaster(int fd);
00703 
00704 #define DRM_EVENT_CONTEXT_VERSION 2
00705 
00706 typedef struct _drmEventContext {
00707 
00708        /* This struct is versioned so we can add more pointers if we
00709         * add more events. */
00710        int version;
00711 
00712        void (*vblank_handler)(int fd,
00713                             unsigned int sequence, 
00714                             unsigned int tv_sec,
00715                             unsigned int tv_usec,
00716                             void *user_data);
00717 
00718        void (*page_flip_handler)(int fd,
00719                               unsigned int sequence,
00720                               unsigned int tv_sec,
00721                               unsigned int tv_usec,
00722                               void *user_data);
00723 
00724 } drmEventContext, *drmEventContextPtr;
00725 
00726 extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
00727 
00728 extern char *drmGetDeviceNameFromFd(int fd);
00729 
00730 #if defined(__cplusplus) || defined(c_plusplus)
00731 }
00732 #endif
00733 
00734 #endif