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