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>
42 #if defined(__linux__)
44 #define DRM_IOCTL_NR(n) _IOC_NR(n)
45 #define DRM_IOC_VOID _IOC_NONE
46 #define DRM_IOC_READ _IOC_READ
47 #define DRM_IOC_WRITE _IOC_WRITE
48 #define DRM_IOC_READWRITE _IOC_READ|_IOC_WRITE
49 #define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
51 #define DRM_MAX_MINOR 15
53 #else /* One of the *BSDs */
55 #include <sys/ioccom.h>
56 #define DRM_IOCTL_NR(n) ((n) & 0xff)
57 #define DRM_IOC_VOID IOC_VOID
58 #define DRM_IOC_READ IOC_OUT
59 #define DRM_IOC_WRITE IOC_IN
60 #define DRM_IOC_READWRITE IOC_INOUT
61 #define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
65 /* Defaults, if nothing set in xf86config */
68 /* Default /dev/dri directory permissions 0755 */
69 #define DRM_DEV_DIRMODE \
70 (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
71 #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
73 #define DRM_DIR_NAME "/dev/dri"
74 #define DRM_DEV_NAME "%s/card%d"
75 #define DRM_CONTROL_DEV_NAME "%s/controlD%d"
76 #define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
78 #define DRM_ERR_NO_DEVICE (-1001)
79 #define DRM_ERR_NO_ACCESS (-1002)
80 #define DRM_ERR_NOT_ROOT (-1003)
81 #define DRM_ERR_INVALID (-1004)
82 #define DRM_ERR_NO_FD (-1005)
84 #define DRM_AGP_NO_HANDLE 0
86 typedef unsigned int drmSize, *drmSizePtr; /**< For mapped regions */
87 typedef void *drmAddress, **drmAddressPtr; /**< For mapped regions */
89 typedef struct _drmServerInfo {
90 int (*debug_print)(const char *format, va_list ap);
91 int (*load_module)(const char *name);
92 void (*get_perms)(gid_t *, mode_t *);
93 } drmServerInfo, *drmServerInfoPtr;
95 typedef struct drmHashEntry {
97 void (*f)(int, void *, void *);
101 extern int drmIoctl(int fd, unsigned long request, void *arg);
102 extern void *drmGetHashTable(void);
103 extern drmHashEntry *drmGetEntry(int fd);
106 * Driver version information.
108 * \sa drmGetVersion() and drmSetVersion().
110 typedef struct _drmVersion {
111 int version_major; /**< Major version */
112 int version_minor; /**< Minor version */
113 int version_patchlevel; /**< Patch level */
114 int name_len; /**< Length of name buffer */
115 char *name; /**< Name of driver */
116 int date_len; /**< Length of date buffer */
117 char *date; /**< User-space buffer to hold date */
118 int desc_len; /**< Length of desc buffer */
119 char *desc; /**< User-space buffer to hold desc */
120 } drmVersion, *drmVersionPtr;
122 typedef struct _drmStats {
123 unsigned long count; /**< Number of data */
125 unsigned long value; /**< Value from kernel */
126 const char *long_format; /**< Suggested format for long_name */
127 const char *long_name; /**< Long name for value */
128 const char *rate_format; /**< Suggested format for rate_name */
129 const char *rate_name; /**< Short name for value per second */
130 int isvalue; /**< True if value (vs. counter) */
131 const char *mult_names; /**< Multiplier names (e.g., "KGM") */
132 int mult; /**< Multiplier value (e.g., 1024) */
133 int verbose; /**< Suggest only in verbose output */
138 /* All of these enums *MUST* match with the
139 kernel implementation -- so do *NOT*
140 change them! (The drmlib implementation
141 will just copy the flags instead of
142 translating them.) */
144 DRM_FRAME_BUFFER = 0, /**< WC, no caching, no core dump */
145 DRM_REGISTERS = 1, /**< no caching, no core dump */
146 DRM_SHM = 2, /**< shared, cached */
147 DRM_AGP = 3, /**< AGP/GART */
148 DRM_SCATTER_GATHER = 4, /**< PCI scatter/gather */
149 DRM_CONSISTENT = 5 /**< PCI consistent */
153 DRM_RESTRICTED = 0x0001, /**< Cannot be mapped to client-virtual */
154 DRM_READ_ONLY = 0x0002, /**< Read-only in client-virtual */
155 DRM_LOCKED = 0x0004, /**< Physical pages locked */
156 DRM_KERNEL = 0x0008, /**< Kernel requires access */
157 DRM_WRITE_COMBINING = 0x0010, /**< Use write-combining, if available */
158 DRM_CONTAINS_LOCK = 0x0020, /**< SHM page that contains lock */
159 DRM_REMOVABLE = 0x0040 /**< Removable mapping */
163 * \warning These values *MUST* match drm.h
166 /** \name Flags for DMA buffer dispatch */
168 DRM_DMA_BLOCK = 0x01, /**<
169 * Block until buffer dispatched.
171 * \note the buffer may not yet have been
172 * processed by the hardware -- getting a
173 * hardware lock with the hardware quiescent
174 * will ensure that the buffer has been
177 DRM_DMA_WHILE_LOCKED = 0x02, /**< Dispatch while lock held */
178 DRM_DMA_PRIORITY = 0x04, /**< High priority dispatch */
181 /** \name Flags for DMA buffer request */
183 DRM_DMA_WAIT = 0x10, /**< Wait for free buffers */
184 DRM_DMA_SMALLER_OK = 0x20, /**< Smaller-than-requested buffers OK */
185 DRM_DMA_LARGER_OK = 0x40 /**< Larger-than-requested buffers OK */
190 DRM_PAGE_ALIGN = 0x01,
191 DRM_AGP_BUFFER = 0x02,
192 DRM_SG_BUFFER = 0x04,
193 DRM_FB_BUFFER = 0x08,
194 DRM_PCI_BUFFER_RO = 0x10
198 DRM_LOCK_READY = 0x01, /**< Wait until hardware is ready for DMA */
199 DRM_LOCK_QUIESCENT = 0x02, /**< Wait until hardware quiescent */
200 DRM_LOCK_FLUSH = 0x04, /**< Flush this context's DMA queue first */
201 DRM_LOCK_FLUSH_ALL = 0x08, /**< Flush all DMA queues first */
202 /* These *HALT* flags aren't supported yet
203 -- they will be used to support the
204 full-screen DGA-like mode. */
205 DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */
206 DRM_HALT_CUR_QUEUES = 0x20 /**< Halt all current queues */
210 DRM_CONTEXT_PRESERVED = 0x01, /**< This context is preserved and
212 DRM_CONTEXT_2DONLY = 0x02 /**< This context is for 2D rendering only. */
213 } drm_context_tFlags, *drm_context_tFlagsPtr;
215 typedef struct _drmBufDesc {
216 int count; /**< Number of buffers of this size */
217 int size; /**< Size in bytes */
218 int low_mark; /**< Low water mark */
219 int high_mark; /**< High water mark */
220 } drmBufDesc, *drmBufDescPtr;
222 typedef struct _drmBufInfo {
223 int count; /**< Number of buffers described in list */
224 drmBufDescPtr list; /**< List of buffer descriptions */
225 } drmBufInfo, *drmBufInfoPtr;
227 typedef struct _drmBuf {
228 int idx; /**< Index into the master buffer list */
229 int total; /**< Buffer size */
230 int used; /**< Amount of buffer in use (for DMA) */
231 drmAddress address; /**< Address */
232 } drmBuf, *drmBufPtr;
235 * Buffer mapping information.
237 * Used by drmMapBufs() and drmUnmapBufs() to store information about the
240 typedef struct _drmBufMap {
241 int count; /**< Number of buffers mapped */
242 drmBufPtr list; /**< Buffers */
243 } drmBufMap, *drmBufMapPtr;
245 typedef struct _drmLock {
246 volatile unsigned int lock;
248 /* This is big enough for most current (and future?) architectures:
251 Intel P5/PPro/PII/PIII: 32 bytes
252 Intel StrongARM: 32 bytes
253 Intel i386/i486: 16 bytes
255 Motorola 68k: 16 bytes
256 Motorola PowerPC: 32 bytes
259 } drmLock, *drmLockPtr;
262 * Indices here refer to the offset into
265 typedef struct _drmDMAReq {
266 drm_context_t context; /**< Context handle */
267 int send_count; /**< Number of buffers to send */
268 int *send_list; /**< List of handles to buffers */
269 int *send_sizes; /**< Lengths of data to send, in bytes */
270 drmDMAFlags flags; /**< Flags */
271 int request_count; /**< Number of buffers requested */
272 int request_size; /**< Desired size of buffers requested */
273 int *request_list; /**< Buffer information */
274 int *request_sizes; /**< Minimum acceptable sizes */
275 int granted_count; /**< Number of buffers granted at this size */
276 } drmDMAReq, *drmDMAReqPtr;
278 typedef struct _drmRegion {
283 } drmRegion, *drmRegionPtr;
285 typedef struct _drmTextureRegion {
288 unsigned char in_use;
289 unsigned char padding; /**< Explicitly pad this out */
291 } drmTextureRegion, *drmTextureRegionPtr;
295 DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */
296 DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */
297 DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */
298 DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */
299 DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */
300 DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */
301 DRM_VBLANK_SIGNAL = 0x40000000 /* Send signal instead of blocking */
304 typedef struct _drmVBlankReq {
305 drmVBlankSeqType type;
306 unsigned int sequence;
307 unsigned long signal;
308 } drmVBlankReq, *drmVBlankReqPtr;
310 typedef struct _drmVBlankReply {
311 drmVBlankSeqType type;
312 unsigned int sequence;
315 } drmVBlankReply, *drmVBlankReplyPtr;
317 typedef union _drmVBlank {
318 drmVBlankReq request;
319 drmVBlankReply reply;
320 } drmVBlank, *drmVBlankPtr;
322 typedef struct _drmSetVersion {
327 } drmSetVersion, *drmSetVersionPtr;
329 #define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
331 #define DRM_LOCK_HELD 0x80000000U /**< Hardware lock is held */
332 #define DRM_LOCK_CONT 0x40000000U /**< Hardware lock is contended */
334 #if defined(__GNUC__) && (__GNUC__ >= 2)
335 # if defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
336 /* Reflect changes here to drmP.h */
337 #define DRM_CAS(lock,old,new,__ret) \
339 int __dummy; /* Can't mark eax as clobbered */ \
340 __asm__ __volatile__( \
341 "lock ; cmpxchg %4,%1\n\t" \
344 "=m" (__drm_dummy_lock(lock)), \
350 #elif defined(__alpha__)
352 #define DRM_CAS(lock, old, new, ret) \
355 __asm__ __volatile__( \
356 " addl $31, %5, %3\n" \
357 "1: ldl_l %0, %2\n" \
358 " cmpeq %0, %3, %1\n" \
364 "2: cmpeq %1, 0, %1\n" \
368 : "=&r"(tmp), "=&r"(ret), \
369 "=m"(__drm_dummy_lock(lock)), \
371 : "r"(new), "r"(old) \
375 #elif defined(__sparc__)
377 #define DRM_CAS(lock,old,new,__ret) \
378 do { register unsigned int __old __asm("o0"); \
379 register unsigned int __new __asm("o1"); \
380 register volatile unsigned int *__lock __asm("o2"); \
383 __lock = (volatile unsigned int *)lock; \
384 __asm__ __volatile__( \
385 /*"cas [%2], %3, %0"*/ \
386 ".word 0xd3e29008\n\t" \
387 /*"membar #StoreStore | #StoreLoad"*/ \
394 __ret = (__new != __old); \
397 #elif defined(__ia64__)
399 #ifdef __INTEL_COMPILER
400 /* this currently generates bad code (missing stop bits)... */
401 #include <ia64intrin.h>
403 #define DRM_CAS(lock,old,new,__ret) \
405 unsigned long __result, __old = (old) & 0xffffffff; \
407 __result = _InterlockedCompareExchange_acq(&__drm_dummy_lock(lock), (new), __old);\
408 __ret = (__result) != (__old); \
409 /* __ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \
415 #define DRM_CAS(lock,old,new,__ret) \
417 unsigned int __result, __old = (old); \
418 __asm__ __volatile__( \
422 "cmpxchg4.acq %0=%1,%3,ar.ccv" \
423 : "=r" (__result), "=m" (__drm_dummy_lock(lock)) \
424 : "r" ((unsigned long)__old), "r" (new) \
426 __ret = (__result) != (__old); \
431 #elif defined(__powerpc__)
433 #define DRM_CAS(lock,old,new,__ret) \
435 __asm__ __volatile__( \
437 "0: lwarx %0,0,%1;" \
445 : "r"(lock), "r"(new), "r"(old) \
446 : "cr0", "memory"); \
449 #endif /* architecture */
450 #endif /* __GNUC__ >= 2 */
453 #define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
456 #if defined(__alpha__)
457 #define DRM_CAS_RESULT(_result) long _result
458 #elif defined(__powerpc__)
459 #define DRM_CAS_RESULT(_result) int _result
461 #define DRM_CAS_RESULT(_result) char _result
464 #define DRM_LIGHT_LOCK(fd,lock,context) \
466 DRM_CAS_RESULT(__ret); \
467 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
468 if (__ret) drmGetLock(fd,context,0); \
471 /* This one counts fast locks -- for
472 benchmarking only. */
473 #define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count) \
475 DRM_CAS_RESULT(__ret); \
476 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
477 if (__ret) drmGetLock(fd,context,0); \
481 #define DRM_LOCK(fd,lock,context,flags) \
483 if (flags) drmGetLock(fd,context,flags); \
484 else DRM_LIGHT_LOCK(fd,lock,context); \
487 #define DRM_UNLOCK(fd,lock,context) \
489 DRM_CAS_RESULT(__ret); \
490 DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret); \
491 if (__ret) drmUnlock(fd,context); \
494 /* Simple spin locks */
495 #define DRM_SPINLOCK(spin,val) \
497 DRM_CAS_RESULT(__ret); \
499 DRM_CAS(spin,0,val,__ret); \
500 if (__ret) while ((spin)->lock); \
504 #define DRM_SPINLOCK_TAKE(spin,val) \
506 DRM_CAS_RESULT(__ret); \
509 cur = (*spin).lock; \
510 DRM_CAS(spin,cur,val,__ret); \
514 #define DRM_SPINLOCK_COUNT(spin,val,count,__ret) \
518 for (__i = 0; __ret && __i < count; __i++) { \
519 DRM_CAS(spin,0,val,__ret); \
520 if (__ret) for (;__i < count && (spin)->lock; __i++); \
524 #define DRM_SPINUNLOCK(spin,val) \
526 DRM_CAS_RESULT(__ret); \
527 if ((*spin).lock == val) { /* else server stole lock */ \
529 DRM_CAS(spin,val,0,__ret); \
536 /* General user-level programmer's API: unprivileged */
537 extern int drmAvailable(void);
538 extern int drmOpen(const char *name, const char *busid);
539 extern int drmOpenControl(int minor);
540 extern int drmClose(int fd);
541 extern drmVersionPtr drmGetVersion(int fd);
542 extern drmVersionPtr drmGetLibVersion(int fd);
543 extern void drmFreeVersion(drmVersionPtr);
544 extern int drmGetMagic(int fd, drm_magic_t * magic);
545 extern char *drmGetBusid(int fd);
546 extern int drmGetInterruptFromBusID(int fd, int busnum, int devnum,
548 extern int drmGetMap(int fd, int idx, drm_handle_t *offset,
549 drmSize *size, drmMapType *type,
550 drmMapFlags *flags, drm_handle_t *handle,
552 extern int drmGetClient(int fd, int idx, int *auth, int *pid,
553 int *uid, unsigned long *magic,
554 unsigned long *iocs);
555 extern int drmGetStats(int fd, drmStatsT *stats);
556 extern int drmSetInterfaceVersion(int fd, drmSetVersion *version);
557 extern int drmCommandNone(int fd, unsigned long drmCommandIndex);
558 extern int drmCommandRead(int fd, unsigned long drmCommandIndex,
559 void *data, unsigned long size);
560 extern int drmCommandWrite(int fd, unsigned long drmCommandIndex,
561 void *data, unsigned long size);
562 extern int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
563 void *data, unsigned long size);
565 /* General user-level programmer's API: X server (root) only */
566 extern void drmFreeBusid(const char *busid);
567 extern int drmSetBusid(int fd, const char *busid);
568 extern int drmAuthMagic(int fd, drm_magic_t magic);
569 extern int drmAddMap(int fd,
574 drm_handle_t * handle);
575 extern int drmRmMap(int fd, drm_handle_t handle);
576 extern int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id,
577 drm_handle_t handle);
579 extern int drmAddBufs(int fd, int count, int size,
580 drmBufDescFlags flags,
582 extern int drmMarkBufs(int fd, double low, double high);
583 extern int drmCreateContext(int fd, drm_context_t * handle);
584 extern int drmSetContextFlags(int fd, drm_context_t context,
585 drm_context_tFlags flags);
586 extern int drmGetContextFlags(int fd, drm_context_t context,
587 drm_context_tFlagsPtr flags);
588 extern int drmAddContextTag(int fd, drm_context_t context, void *tag);
589 extern int drmDelContextTag(int fd, drm_context_t context);
590 extern void *drmGetContextTag(int fd, drm_context_t context);
591 extern drm_context_t * drmGetReservedContextList(int fd, int *count);
592 extern void drmFreeReservedContextList(drm_context_t *);
593 extern int drmSwitchToContext(int fd, drm_context_t context);
594 extern int drmDestroyContext(int fd, drm_context_t handle);
595 extern int drmCreateDrawable(int fd, drm_drawable_t * handle);
596 extern int drmDestroyDrawable(int fd, drm_drawable_t handle);
597 extern int drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
598 drm_drawable_info_type_t type,
599 unsigned int num, void *data);
600 extern int drmCtlInstHandler(int fd, int irq);
601 extern int drmCtlUninstHandler(int fd);
603 /* General user-level programmer's API: authenticated client and/or X */
604 extern int drmMap(int fd,
607 drmAddressPtr address);
608 extern int drmUnmap(drmAddress address, drmSize size);
609 extern drmBufInfoPtr drmGetBufInfo(int fd);
610 extern drmBufMapPtr drmMapBufs(int fd);
611 extern int drmUnmapBufs(drmBufMapPtr bufs);
612 extern int drmDMA(int fd, drmDMAReqPtr request);
613 extern int drmFreeBufs(int fd, int count, int *list);
614 extern int drmGetLock(int fd,
615 drm_context_t context,
617 extern int drmUnlock(int fd, drm_context_t context);
618 extern int drmFinish(int fd, int context, drmLockFlags flags);
619 extern int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id,
620 drm_handle_t * handle);
622 /* AGP/GART support: X server (root) only */
623 extern int drmAgpAcquire(int fd);
624 extern int drmAgpRelease(int fd);
625 extern int drmAgpEnable(int fd, unsigned long mode);
626 extern int drmAgpAlloc(int fd, unsigned long size,
627 unsigned long type, unsigned long *address,
628 drm_handle_t *handle);
629 extern int drmAgpFree(int fd, drm_handle_t handle);
630 extern int drmAgpBind(int fd, drm_handle_t handle,
631 unsigned long offset);
632 extern int drmAgpUnbind(int fd, drm_handle_t handle);
634 /* AGP/GART info: authenticated client and/or X */
635 extern int drmAgpVersionMajor(int fd);
636 extern int drmAgpVersionMinor(int fd);
637 extern unsigned long drmAgpGetMode(int fd);
638 extern unsigned long drmAgpBase(int fd); /* Physical location */
639 extern unsigned long drmAgpSize(int fd); /* Bytes */
640 extern unsigned long drmAgpMemoryUsed(int fd);
641 extern unsigned long drmAgpMemoryAvail(int fd);
642 extern unsigned int drmAgpVendorId(int fd);
643 extern unsigned int drmAgpDeviceId(int fd);
645 /* PCI scatter/gather support: X server (root) only */
646 extern int drmScatterGatherAlloc(int fd, unsigned long size,
647 drm_handle_t *handle);
648 extern int drmScatterGatherFree(int fd, drm_handle_t handle);
650 extern int drmWaitVBlank(int fd, drmVBlankPtr vbl);
652 /* Support routines */
653 extern void drmSetServerInfo(drmServerInfoPtr info);
654 extern int drmError(int err, const char *label);
655 extern void *drmMalloc(int size);
656 extern void drmFree(void *pt);
658 /* Hash table routines */
659 extern void *drmHashCreate(void);
660 extern int drmHashDestroy(void *t);
661 extern int drmHashLookup(void *t, unsigned long key, void **value);
662 extern int drmHashInsert(void *t, unsigned long key, void *value);
663 extern int drmHashDelete(void *t, unsigned long key);
664 extern int drmHashFirst(void *t, unsigned long *key, void **value);
665 extern int drmHashNext(void *t, unsigned long *key, void **value);
668 extern void *drmRandomCreate(unsigned long seed);
669 extern int drmRandomDestroy(void *state);
670 extern unsigned long drmRandom(void *state);
671 extern double drmRandomDouble(void *state);
673 /* Skip list routines */
675 extern void *drmSLCreate(void);
676 extern int drmSLDestroy(void *l);
677 extern int drmSLLookup(void *l, unsigned long key, void **value);
678 extern int drmSLInsert(void *l, unsigned long key, void *value);
679 extern int drmSLDelete(void *l, unsigned long key);
680 extern int drmSLNext(void *l, unsigned long *key, void **value);
681 extern int drmSLFirst(void *l, unsigned long *key, void **value);
682 extern void drmSLDump(void *l);
683 extern int drmSLLookupNeighbors(void *l, unsigned long key,
684 unsigned long *prev_key, void **prev_value,
685 unsigned long *next_key, void **next_value);
687 extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened);
688 extern void drmCloseOnce(int fd);
689 extern void drmMsg(const char *format, ...);
691 extern int drmSetMaster(int fd);
692 extern int drmDropMaster(int fd);
694 #define DRM_EVENT_CONTEXT_VERSION 1
696 typedef struct _drmEventContext {
698 /* This struct is versioned so we can add more pointers if we
699 * add more events. */
702 void (*vblank_handler)(int fd,
703 unsigned int sequence,
705 unsigned int tv_usec,
708 } drmEventContext, *drmEventContextPtr;
710 extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
712 extern char *drmGetDeviceNameFromFd(int fd);