3 * OS-independent header for DRM user-level library interface.
5 * \author Rickard E. (Rik) Faith <faith@valinux.com>
9 * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
10 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
11 * All Rights Reserved.
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:
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
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.
38 #include <sys/types.h>
43 #define DRM_MAX_MINOR 16
46 #if defined(__linux__)
48 #define DRM_IOCTL_NR(n) _IOC_NR(n)
49 #define DRM_IOC_VOID _IOC_NONE
50 #define DRM_IOC_READ _IOC_READ
51 #define DRM_IOC_WRITE _IOC_WRITE
52 #define DRM_IOC_READWRITE _IOC_READ|_IOC_WRITE
53 #define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
55 #else /* One of the *BSDs */
57 #include <sys/ioccom.h>
58 #define DRM_IOCTL_NR(n) ((n) & 0xff)
59 #define DRM_IOC_VOID IOC_VOID
60 #define DRM_IOC_READ IOC_OUT
61 #define DRM_IOC_WRITE IOC_IN
62 #define DRM_IOC_READWRITE IOC_INOUT
63 #define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
67 /* Defaults, if nothing set in xf86config */
70 /* Default /dev/dri directory permissions 0755 */
71 #define DRM_DEV_DIRMODE \
72 (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
73 #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
75 #define DRM_DIR_NAME "/dev/dri"
76 #define DRM_DEV_NAME "%s/card%d"
77 #define DRM_CONTROL_DEV_NAME "%s/controlD%d"
78 #define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
80 #define DRM_ERR_NO_DEVICE (-1001)
81 #define DRM_ERR_NO_ACCESS (-1002)
82 #define DRM_ERR_NOT_ROOT (-1003)
83 #define DRM_ERR_INVALID (-1004)
84 #define DRM_ERR_NO_FD (-1005)
86 #define DRM_AGP_NO_HANDLE 0
88 typedef unsigned int drmSize, *drmSizePtr; /**< For mapped regions */
89 typedef void *drmAddress, **drmAddressPtr; /**< For mapped regions */
91 typedef struct _drmServerInfo {
92 int (*debug_print)(const char *format, va_list ap);
93 int (*load_module)(const char *name);
94 void (*get_perms)(gid_t *, mode_t *);
95 } drmServerInfo, *drmServerInfoPtr;
97 typedef struct drmHashEntry {
99 void (*f)(int, void *, void *);
103 extern int drmIoctl(int fd, unsigned long request, void *arg);
104 extern void *drmGetHashTable(void);
105 extern drmHashEntry *drmGetEntry(int fd);
108 * Driver version information.
110 * \sa drmGetVersion() and drmSetVersion().
112 typedef struct _drmVersion {
113 int version_major; /**< Major version */
114 int version_minor; /**< Minor version */
115 int version_patchlevel; /**< Patch level */
116 int name_len; /**< Length of name buffer */
117 char *name; /**< Name of driver */
118 int date_len; /**< Length of date buffer */
119 char *date; /**< User-space buffer to hold date */
120 int desc_len; /**< Length of desc buffer */
121 char *desc; /**< User-space buffer to hold desc */
122 } drmVersion, *drmVersionPtr;
124 typedef struct _drmStats {
125 unsigned long count; /**< Number of data */
127 unsigned long value; /**< Value from kernel */
128 const char *long_format; /**< Suggested format for long_name */
129 const char *long_name; /**< Long name for value */
130 const char *rate_format; /**< Suggested format for rate_name */
131 const char *rate_name; /**< Short name for value per second */
132 int isvalue; /**< True if value (vs. counter) */
133 const char *mult_names; /**< Multiplier names (e.g., "KGM") */
134 int mult; /**< Multiplier value (e.g., 1024) */
135 int verbose; /**< Suggest only in verbose output */
140 /* All of these enums *MUST* match with the
141 kernel implementation -- so do *NOT*
142 change them! (The drmlib implementation
143 will just copy the flags instead of
144 translating them.) */
146 DRM_FRAME_BUFFER = 0, /**< WC, no caching, no core dump */
147 DRM_REGISTERS = 1, /**< no caching, no core dump */
148 DRM_SHM = 2, /**< shared, cached */
149 DRM_AGP = 3, /**< AGP/GART */
150 DRM_SCATTER_GATHER = 4, /**< PCI scatter/gather */
151 DRM_CONSISTENT = 5 /**< PCI consistent */
155 DRM_RESTRICTED = 0x0001, /**< Cannot be mapped to client-virtual */
156 DRM_READ_ONLY = 0x0002, /**< Read-only in client-virtual */
157 DRM_LOCKED = 0x0004, /**< Physical pages locked */
158 DRM_KERNEL = 0x0008, /**< Kernel requires access */
159 DRM_WRITE_COMBINING = 0x0010, /**< Use write-combining, if available */
160 DRM_CONTAINS_LOCK = 0x0020, /**< SHM page that contains lock */
161 DRM_REMOVABLE = 0x0040 /**< Removable mapping */
165 * \warning These values *MUST* match drm.h
168 /** \name Flags for DMA buffer dispatch */
170 DRM_DMA_BLOCK = 0x01, /**<
171 * Block until buffer dispatched.
173 * \note the buffer may not yet have been
174 * processed by the hardware -- getting a
175 * hardware lock with the hardware quiescent
176 * will ensure that the buffer has been
179 DRM_DMA_WHILE_LOCKED = 0x02, /**< Dispatch while lock held */
180 DRM_DMA_PRIORITY = 0x04, /**< High priority dispatch */
183 /** \name Flags for DMA buffer request */
185 DRM_DMA_WAIT = 0x10, /**< Wait for free buffers */
186 DRM_DMA_SMALLER_OK = 0x20, /**< Smaller-than-requested buffers OK */
187 DRM_DMA_LARGER_OK = 0x40 /**< Larger-than-requested buffers OK */
192 DRM_PAGE_ALIGN = 0x01,
193 DRM_AGP_BUFFER = 0x02,
194 DRM_SG_BUFFER = 0x04,
195 DRM_FB_BUFFER = 0x08,
196 DRM_PCI_BUFFER_RO = 0x10
200 DRM_LOCK_READY = 0x01, /**< Wait until hardware is ready for DMA */
201 DRM_LOCK_QUIESCENT = 0x02, /**< Wait until hardware quiescent */
202 DRM_LOCK_FLUSH = 0x04, /**< Flush this context's DMA queue first */
203 DRM_LOCK_FLUSH_ALL = 0x08, /**< Flush all DMA queues first */
204 /* These *HALT* flags aren't supported yet
205 -- they will be used to support the
206 full-screen DGA-like mode. */
207 DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */
208 DRM_HALT_CUR_QUEUES = 0x20 /**< Halt all current queues */
212 DRM_CONTEXT_PRESERVED = 0x01, /**< This context is preserved and
214 DRM_CONTEXT_2DONLY = 0x02 /**< This context is for 2D rendering only. */
215 } drm_context_tFlags, *drm_context_tFlagsPtr;
217 typedef struct _drmBufDesc {
218 int count; /**< Number of buffers of this size */
219 int size; /**< Size in bytes */
220 int low_mark; /**< Low water mark */
221 int high_mark; /**< High water mark */
222 } drmBufDesc, *drmBufDescPtr;
224 typedef struct _drmBufInfo {
225 int count; /**< Number of buffers described in list */
226 drmBufDescPtr list; /**< List of buffer descriptions */
227 } drmBufInfo, *drmBufInfoPtr;
229 typedef struct _drmBuf {
230 int idx; /**< Index into the master buffer list */
231 int total; /**< Buffer size */
232 int used; /**< Amount of buffer in use (for DMA) */
233 drmAddress address; /**< Address */
234 } drmBuf, *drmBufPtr;
237 * Buffer mapping information.
239 * Used by drmMapBufs() and drmUnmapBufs() to store information about the
242 typedef struct _drmBufMap {
243 int count; /**< Number of buffers mapped */
244 drmBufPtr list; /**< Buffers */
245 } drmBufMap, *drmBufMapPtr;
247 typedef struct _drmLock {
248 volatile unsigned int lock;
250 /* This is big enough for most current (and future?) architectures:
253 Intel P5/PPro/PII/PIII: 32 bytes
254 Intel StrongARM: 32 bytes
255 Intel i386/i486: 16 bytes
257 Motorola 68k: 16 bytes
258 Motorola PowerPC: 32 bytes
261 } drmLock, *drmLockPtr;
264 * Indices here refer to the offset into
267 typedef struct _drmDMAReq {
268 drm_context_t context; /**< Context handle */
269 int send_count; /**< Number of buffers to send */
270 int *send_list; /**< List of handles to buffers */
271 int *send_sizes; /**< Lengths of data to send, in bytes */
272 drmDMAFlags flags; /**< Flags */
273 int request_count; /**< Number of buffers requested */
274 int request_size; /**< Desired size of buffers requested */
275 int *request_list; /**< Buffer information */
276 int *request_sizes; /**< Minimum acceptable sizes */
277 int granted_count; /**< Number of buffers granted at this size */
278 } drmDMAReq, *drmDMAReqPtr;
280 typedef struct _drmRegion {
285 } drmRegion, *drmRegionPtr;
287 typedef struct _drmTextureRegion {
290 unsigned char in_use;
291 unsigned char padding; /**< Explicitly pad this out */
293 } drmTextureRegion, *drmTextureRegionPtr;
297 DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */
298 DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */
299 DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */
300 DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */
301 DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */
302 DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */
303 DRM_VBLANK_SIGNAL = 0x40000000 /* Send signal instead of blocking */
306 typedef struct _drmVBlankReq {
307 drmVBlankSeqType type;
308 unsigned int sequence;
309 unsigned long signal;
310 } drmVBlankReq, *drmVBlankReqPtr;
312 typedef struct _drmVBlankReply {
313 drmVBlankSeqType type;
314 unsigned int sequence;
317 } drmVBlankReply, *drmVBlankReplyPtr;
319 typedef union _drmVBlank {
320 drmVBlankReq request;
321 drmVBlankReply reply;
322 } drmVBlank, *drmVBlankPtr;
324 typedef struct _drmSetVersion {
329 } drmSetVersion, *drmSetVersionPtr;
331 #define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
333 #define DRM_LOCK_HELD 0x80000000U /**< Hardware lock is held */
334 #define DRM_LOCK_CONT 0x40000000U /**< Hardware lock is contended */
336 #if defined(__GNUC__) && (__GNUC__ >= 2)
337 # if defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
338 /* Reflect changes here to drmP.h */
339 #define DRM_CAS(lock,old,new,__ret) \
341 int __dummy; /* Can't mark eax as clobbered */ \
342 __asm__ __volatile__( \
343 "lock ; cmpxchg %4,%1\n\t" \
346 "=m" (__drm_dummy_lock(lock)), \
352 #elif defined(__alpha__)
354 #define DRM_CAS(lock, old, new, ret) \
357 __asm__ __volatile__( \
358 " addl $31, %5, %3\n" \
359 "1: ldl_l %0, %2\n" \
360 " cmpeq %0, %3, %1\n" \
366 "2: cmpeq %1, 0, %1\n" \
370 : "=&r"(tmp), "=&r"(ret), \
371 "=m"(__drm_dummy_lock(lock)), \
373 : "r"(new), "r"(old) \
377 #elif defined(__sparc__)
379 #define DRM_CAS(lock,old,new,__ret) \
380 do { register unsigned int __old __asm("o0"); \
381 register unsigned int __new __asm("o1"); \
382 register volatile unsigned int *__lock __asm("o2"); \
385 __lock = (volatile unsigned int *)lock; \
386 __asm__ __volatile__( \
387 /*"cas [%2], %3, %0"*/ \
388 ".word 0xd3e29008\n\t" \
389 /*"membar #StoreStore | #StoreLoad"*/ \
396 __ret = (__new != __old); \
399 #elif defined(__ia64__)
401 #ifdef __INTEL_COMPILER
402 /* this currently generates bad code (missing stop bits)... */
403 #include <ia64intrin.h>
405 #define DRM_CAS(lock,old,new,__ret) \
407 unsigned long __result, __old = (old) & 0xffffffff; \
409 __result = _InterlockedCompareExchange_acq(&__drm_dummy_lock(lock), (new), __old);\
410 __ret = (__result) != (__old); \
411 /* __ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \
417 #define DRM_CAS(lock,old,new,__ret) \
419 unsigned int __result, __old = (old); \
420 __asm__ __volatile__( \
424 "cmpxchg4.acq %0=%1,%3,ar.ccv" \
425 : "=r" (__result), "=m" (__drm_dummy_lock(lock)) \
426 : "r" ((unsigned long)__old), "r" (new) \
428 __ret = (__result) != (__old); \
433 #elif defined(__powerpc__)
435 #define DRM_CAS(lock,old,new,__ret) \
437 __asm__ __volatile__( \
439 "0: lwarx %0,0,%1;" \
447 : "r"(lock), "r"(new), "r"(old) \
448 : "cr0", "memory"); \
451 #endif /* architecture */
452 #endif /* __GNUC__ >= 2 */
455 #define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
458 #if defined(__alpha__)
459 #define DRM_CAS_RESULT(_result) long _result
460 #elif defined(__powerpc__)
461 #define DRM_CAS_RESULT(_result) int _result
463 #define DRM_CAS_RESULT(_result) char _result
466 #define DRM_LIGHT_LOCK(fd,lock,context) \
468 DRM_CAS_RESULT(__ret); \
469 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
470 if (__ret) drmGetLock(fd,context,0); \
473 /* This one counts fast locks -- for
474 benchmarking only. */
475 #define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count) \
477 DRM_CAS_RESULT(__ret); \
478 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
479 if (__ret) drmGetLock(fd,context,0); \
483 #define DRM_LOCK(fd,lock,context,flags) \
485 if (flags) drmGetLock(fd,context,flags); \
486 else DRM_LIGHT_LOCK(fd,lock,context); \
489 #define DRM_UNLOCK(fd,lock,context) \
491 DRM_CAS_RESULT(__ret); \
492 DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret); \
493 if (__ret) drmUnlock(fd,context); \
496 /* Simple spin locks */
497 #define DRM_SPINLOCK(spin,val) \
499 DRM_CAS_RESULT(__ret); \
501 DRM_CAS(spin,0,val,__ret); \
502 if (__ret) while ((spin)->lock); \
506 #define DRM_SPINLOCK_TAKE(spin,val) \
508 DRM_CAS_RESULT(__ret); \
511 cur = (*spin).lock; \
512 DRM_CAS(spin,cur,val,__ret); \
516 #define DRM_SPINLOCK_COUNT(spin,val,count,__ret) \
520 for (__i = 0; __ret && __i < count; __i++) { \
521 DRM_CAS(spin,0,val,__ret); \
522 if (__ret) for (;__i < count && (spin)->lock; __i++); \
526 #define DRM_SPINUNLOCK(spin,val) \
528 DRM_CAS_RESULT(__ret); \
529 if ((*spin).lock == val) { /* else server stole lock */ \
531 DRM_CAS(spin,val,0,__ret); \
538 /* General user-level programmer's API: unprivileged */
539 extern int drmAvailable(void);
540 extern int drmOpen(const char *name, const char *busid);
541 extern int drmOpenControl(int minor);
542 extern int drmClose(int fd);
543 extern drmVersionPtr drmGetVersion(int fd);
544 extern drmVersionPtr drmGetLibVersion(int fd);
545 extern void drmFreeVersion(drmVersionPtr);
546 extern int drmGetMagic(int fd, drm_magic_t * magic);
547 extern char *drmGetBusid(int fd);
548 extern int drmGetInterruptFromBusID(int fd, int busnum, int devnum,
550 extern int drmGetMap(int fd, int idx, drm_handle_t *offset,
551 drmSize *size, drmMapType *type,
552 drmMapFlags *flags, drm_handle_t *handle,
554 extern int drmGetClient(int fd, int idx, int *auth, int *pid,
555 int *uid, unsigned long *magic,
556 unsigned long *iocs);
557 extern int drmGetStats(int fd, drmStatsT *stats);
558 extern int drmSetInterfaceVersion(int fd, drmSetVersion *version);
559 extern int drmCommandNone(int fd, unsigned long drmCommandIndex);
560 extern int drmCommandRead(int fd, unsigned long drmCommandIndex,
561 void *data, unsigned long size);
562 extern int drmCommandWrite(int fd, unsigned long drmCommandIndex,
563 void *data, unsigned long size);
564 extern int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
565 void *data, unsigned long size);
567 /* General user-level programmer's API: X server (root) only */
568 extern void drmFreeBusid(const char *busid);
569 extern int drmSetBusid(int fd, const char *busid);
570 extern int drmAuthMagic(int fd, drm_magic_t magic);
571 extern int drmAddMap(int fd,
576 drm_handle_t * handle);
577 extern int drmRmMap(int fd, drm_handle_t handle);
578 extern int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id,
579 drm_handle_t handle);
581 extern int drmAddBufs(int fd, int count, int size,
582 drmBufDescFlags flags,
584 extern int drmMarkBufs(int fd, double low, double high);
585 extern int drmCreateContext(int fd, drm_context_t * handle);
586 extern int drmSetContextFlags(int fd, drm_context_t context,
587 drm_context_tFlags flags);
588 extern int drmGetContextFlags(int fd, drm_context_t context,
589 drm_context_tFlagsPtr flags);
590 extern int drmAddContextTag(int fd, drm_context_t context, void *tag);
591 extern int drmDelContextTag(int fd, drm_context_t context);
592 extern void *drmGetContextTag(int fd, drm_context_t context);
593 extern drm_context_t * drmGetReservedContextList(int fd, int *count);
594 extern void drmFreeReservedContextList(drm_context_t *);
595 extern int drmSwitchToContext(int fd, drm_context_t context);
596 extern int drmDestroyContext(int fd, drm_context_t handle);
597 extern int drmCreateDrawable(int fd, drm_drawable_t * handle);
598 extern int drmDestroyDrawable(int fd, drm_drawable_t handle);
599 extern int drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
600 drm_drawable_info_type_t type,
601 unsigned int num, void *data);
602 extern int drmCtlInstHandler(int fd, int irq);
603 extern int drmCtlUninstHandler(int fd);
605 /* General user-level programmer's API: authenticated client and/or X */
606 extern int drmMap(int fd,
609 drmAddressPtr address);
610 extern int drmUnmap(drmAddress address, drmSize size);
611 extern drmBufInfoPtr drmGetBufInfo(int fd);
612 extern drmBufMapPtr drmMapBufs(int fd);
613 extern int drmUnmapBufs(drmBufMapPtr bufs);
614 extern int drmDMA(int fd, drmDMAReqPtr request);
615 extern int drmFreeBufs(int fd, int count, int *list);
616 extern int drmGetLock(int fd,
617 drm_context_t context,
619 extern int drmUnlock(int fd, drm_context_t context);
620 extern int drmFinish(int fd, int context, drmLockFlags flags);
621 extern int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id,
622 drm_handle_t * handle);
624 /* AGP/GART support: X server (root) only */
625 extern int drmAgpAcquire(int fd);
626 extern int drmAgpRelease(int fd);
627 extern int drmAgpEnable(int fd, unsigned long mode);
628 extern int drmAgpAlloc(int fd, unsigned long size,
629 unsigned long type, unsigned long *address,
630 drm_handle_t *handle);
631 extern int drmAgpFree(int fd, drm_handle_t handle);
632 extern int drmAgpBind(int fd, drm_handle_t handle,
633 unsigned long offset);
634 extern int drmAgpUnbind(int fd, drm_handle_t handle);
636 /* AGP/GART info: authenticated client and/or X */
637 extern int drmAgpVersionMajor(int fd);
638 extern int drmAgpVersionMinor(int fd);
639 extern unsigned long drmAgpGetMode(int fd);
640 extern unsigned long drmAgpBase(int fd); /* Physical location */
641 extern unsigned long drmAgpSize(int fd); /* Bytes */
642 extern unsigned long drmAgpMemoryUsed(int fd);
643 extern unsigned long drmAgpMemoryAvail(int fd);
644 extern unsigned int drmAgpVendorId(int fd);
645 extern unsigned int drmAgpDeviceId(int fd);
647 /* PCI scatter/gather support: X server (root) only */
648 extern int drmScatterGatherAlloc(int fd, unsigned long size,
649 drm_handle_t *handle);
650 extern int drmScatterGatherFree(int fd, drm_handle_t handle);
652 extern int drmWaitVBlank(int fd, drmVBlankPtr vbl);
654 /* Support routines */
655 extern void drmSetServerInfo(drmServerInfoPtr info);
656 extern int drmError(int err, const char *label);
657 extern void *drmMalloc(int size);
658 extern void drmFree(void *pt);
660 /* Hash table routines */
661 extern void *drmHashCreate(void);
662 extern int drmHashDestroy(void *t);
663 extern int drmHashLookup(void *t, unsigned long key, void **value);
664 extern int drmHashInsert(void *t, unsigned long key, void *value);
665 extern int drmHashDelete(void *t, unsigned long key);
666 extern int drmHashFirst(void *t, unsigned long *key, void **value);
667 extern int drmHashNext(void *t, unsigned long *key, void **value);
670 extern void *drmRandomCreate(unsigned long seed);
671 extern int drmRandomDestroy(void *state);
672 extern unsigned long drmRandom(void *state);
673 extern double drmRandomDouble(void *state);
675 /* Skip list routines */
677 extern void *drmSLCreate(void);
678 extern int drmSLDestroy(void *l);
679 extern int drmSLLookup(void *l, unsigned long key, void **value);
680 extern int drmSLInsert(void *l, unsigned long key, void *value);
681 extern int drmSLDelete(void *l, unsigned long key);
682 extern int drmSLNext(void *l, unsigned long *key, void **value);
683 extern int drmSLFirst(void *l, unsigned long *key, void **value);
684 extern void drmSLDump(void *l);
685 extern int drmSLLookupNeighbors(void *l, unsigned long key,
686 unsigned long *prev_key, void **prev_value,
687 unsigned long *next_key, void **next_value);
689 extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened);
690 extern void drmCloseOnce(int fd);
691 extern void drmMsg(const char *format, ...);
693 extern int drmSetMaster(int fd);
694 extern int drmDropMaster(int fd);
696 #define DRM_EVENT_CONTEXT_VERSION 2
698 typedef struct _drmEventContext {
700 /* This struct is versioned so we can add more pointers if we
701 * add more events. */
704 void (*vblank_handler)(int fd,
705 unsigned int sequence,
707 unsigned int tv_usec,
710 void (*page_flip_handler)(int fd,
711 unsigned int sequence,
713 unsigned int tv_usec,
716 } drmEventContext, *drmEventContextPtr;
718 extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
720 extern char *drmGetDeviceNameFromFd(int fd);