summaryrefslogtreecommitdiff
path: root/src/static_libs/libdrm
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2017-06-09 13:44:52 -0400
committerChris Michael <cp.michael@samsung.com>2017-06-09 13:44:52 -0400
commit434bb09b17969cc908c64452d7f4b759fbf99216 (patch)
tree86ed59310f70d1cc81eba09cddba1cd865d331b3 /src/static_libs/libdrm
parentcb94befb9da6ab48195b8f0f535fb81bd83959be (diff)
static_libs: Add xf86drm headers to libdrm static_libs
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/static_libs/libdrm')
-rw-r--r--src/static_libs/libdrm/xf86drm.h860
-rw-r--r--src/static_libs/libdrm/xf86drmMode.h528
2 files changed, 1388 insertions, 0 deletions
diff --git a/src/static_libs/libdrm/xf86drm.h b/src/static_libs/libdrm/xf86drm.h
new file mode 100644
index 0000000000..74f54f1733
--- /dev/null
+++ b/src/static_libs/libdrm/xf86drm.h
@@ -0,0 +1,860 @@
1/**
2 * \file xf86drm.h
3 * OS-independent header for DRM user-level library interface.
4 *
5 * \author Rickard E. (Rik) Faith <faith@valinux.com>
6 */
7
8/*
9 * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
10 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
11 * All Rights Reserved.
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice (including the next
21 * paragraph) shall be included in all copies or substantial portions of the
22 * Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
28 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 * DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34#ifndef _XF86DRM_H_
35#define _XF86DRM_H_
36
37#include <stdarg.h>
38#include <sys/types.h>
39#include <stdint.h>
40#include <drm.h>
41
42#if defined(__cplusplus)
43extern "C" {
44#endif
45
46#ifndef DRM_MAX_MINOR
47#define DRM_MAX_MINOR 16
48#endif
49
50#if defined(__linux__)
51
52#define DRM_IOCTL_NR(n) _IOC_NR(n)
53#define DRM_IOC_VOID _IOC_NONE
54#define DRM_IOC_READ _IOC_READ
55#define DRM_IOC_WRITE _IOC_WRITE
56#define DRM_IOC_READWRITE _IOC_READ|_IOC_WRITE
57#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
58
59#else /* One of the *BSDs */
60
61#include <sys/ioccom.h>
62#define DRM_IOCTL_NR(n) ((n) & 0xff)
63#define DRM_IOC_VOID IOC_VOID
64#define DRM_IOC_READ IOC_OUT
65#define DRM_IOC_WRITE IOC_IN
66#define DRM_IOC_READWRITE IOC_INOUT
67#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
68
69#endif
70
71 /* Defaults, if nothing set in xf86config */
72#define DRM_DEV_UID 0
73#define DRM_DEV_GID 0
74/* Default /dev/dri directory permissions 0755 */
75#define DRM_DEV_DIRMODE \
76 (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
77#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
78
79#ifdef __OpenBSD__
80#define DRM_DIR_NAME "/dev"
81#define DRM_DEV_NAME "%s/drm%d"
82#define DRM_CONTROL_DEV_NAME "%s/drmC%d"
83#define DRM_RENDER_DEV_NAME "%s/drmR%d"
84#else
85#define DRM_DIR_NAME "/dev/dri"
86#define DRM_DEV_NAME "%s/card%d"
87#define DRM_CONTROL_DEV_NAME "%s/controlD%d"
88#define DRM_RENDER_DEV_NAME "%s/renderD%d"
89#define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
90#endif
91
92#define DRM_ERR_NO_DEVICE (-1001)
93#define DRM_ERR_NO_ACCESS (-1002)
94#define DRM_ERR_NOT_ROOT (-1003)
95#define DRM_ERR_INVALID (-1004)
96#define DRM_ERR_NO_FD (-1005)
97
98#define DRM_AGP_NO_HANDLE 0
99
100typedef unsigned int drmSize, *drmSizePtr; /**< For mapped regions */
101typedef void *drmAddress, **drmAddressPtr; /**< For mapped regions */
102
103#if (__GNUC__ >= 3)
104#define DRM_PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
105#else
106#define DRM_PRINTFLIKE(f, a)
107#endif
108
109typedef struct _drmServerInfo {
110 int (*debug_print)(const char *format, va_list ap) DRM_PRINTFLIKE(1,0);
111 int (*load_module)(const char *name);
112 void (*get_perms)(gid_t *, mode_t *);
113} drmServerInfo, *drmServerInfoPtr;
114
115typedef struct drmHashEntry {
116 int fd;
117 void (*f)(int, void *, void *);
118 void *tagTable;
119} drmHashEntry;
120
121extern int drmIoctl(int fd, unsigned long request, void *arg);
122extern void *drmGetHashTable(void);
123extern drmHashEntry *drmGetEntry(int fd);
124
125/**
126 * Driver version information.
127 *
128 * \sa drmGetVersion() and drmSetVersion().
129 */
130typedef struct _drmVersion {
131 int version_major; /**< Major version */
132 int version_minor; /**< Minor version */
133 int version_patchlevel; /**< Patch level */
134 int name_len; /**< Length of name buffer */
135 char *name; /**< Name of driver */
136 int date_len; /**< Length of date buffer */
137 char *date; /**< User-space buffer to hold date */
138 int desc_len; /**< Length of desc buffer */
139 char *desc; /**< User-space buffer to hold desc */
140} drmVersion, *drmVersionPtr;
141
142typedef struct _drmStats {
143 unsigned long count; /**< Number of data */
144 struct {
145 unsigned long value; /**< Value from kernel */
146 const char *long_format; /**< Suggested format for long_name */
147 const char *long_name; /**< Long name for value */
148 const char *rate_format; /**< Suggested format for rate_name */
149 const char *rate_name; /**< Short name for value per second */
150 int isvalue; /**< True if value (vs. counter) */
151 const char *mult_names; /**< Multiplier names (e.g., "KGM") */
152 int mult; /**< Multiplier value (e.g., 1024) */
153 int verbose; /**< Suggest only in verbose output */
154 } data[15];
155} drmStatsT;
156
157
158 /* All of these enums *MUST* match with the
159 kernel implementation -- so do *NOT*
160 change them! (The drmlib implementation
161 will just copy the flags instead of
162 translating them.) */
163typedef enum {
164 DRM_FRAME_BUFFER = 0, /**< WC, no caching, no core dump */
165 DRM_REGISTERS = 1, /**< no caching, no core dump */
166 DRM_SHM = 2, /**< shared, cached */
167 DRM_AGP = 3, /**< AGP/GART */
168 DRM_SCATTER_GATHER = 4, /**< PCI scatter/gather */
169 DRM_CONSISTENT = 5 /**< PCI consistent */
170} drmMapType;
171
172typedef enum {
173 DRM_RESTRICTED = 0x0001, /**< Cannot be mapped to client-virtual */
174 DRM_READ_ONLY = 0x0002, /**< Read-only in client-virtual */
175 DRM_LOCKED = 0x0004, /**< Physical pages locked */
176 DRM_KERNEL = 0x0008, /**< Kernel requires access */
177 DRM_WRITE_COMBINING = 0x0010, /**< Use write-combining, if available */
178 DRM_CONTAINS_LOCK = 0x0020, /**< SHM page that contains lock */
179 DRM_REMOVABLE = 0x0040 /**< Removable mapping */
180} drmMapFlags;
181
182/**
183 * \warning These values *MUST* match drm.h
184 */
185typedef enum {
186 /** \name Flags for DMA buffer dispatch */
187 /*@{*/
188 DRM_DMA_BLOCK = 0x01, /**<
189 * Block until buffer dispatched.
190 *
191 * \note the buffer may not yet have been
192 * processed by the hardware -- getting a
193 * hardware lock with the hardware quiescent
194 * will ensure that the buffer has been
195 * processed.
196 */
197 DRM_DMA_WHILE_LOCKED = 0x02, /**< Dispatch while lock held */
198 DRM_DMA_PRIORITY = 0x04, /**< High priority dispatch */
199 /*@}*/
200
201 /** \name Flags for DMA buffer request */
202 /*@{*/
203 DRM_DMA_WAIT = 0x10, /**< Wait for free buffers */
204 DRM_DMA_SMALLER_OK = 0x20, /**< Smaller-than-requested buffers OK */
205 DRM_DMA_LARGER_OK = 0x40 /**< Larger-than-requested buffers OK */
206 /*@}*/
207} drmDMAFlags;
208
209typedef enum {
210 DRM_PAGE_ALIGN = 0x01,
211 DRM_AGP_BUFFER = 0x02,
212 DRM_SG_BUFFER = 0x04,
213 DRM_FB_BUFFER = 0x08,
214 DRM_PCI_BUFFER_RO = 0x10
215} drmBufDescFlags;
216
217typedef enum {
218 DRM_LOCK_READY = 0x01, /**< Wait until hardware is ready for DMA */
219 DRM_LOCK_QUIESCENT = 0x02, /**< Wait until hardware quiescent */
220 DRM_LOCK_FLUSH = 0x04, /**< Flush this context's DMA queue first */
221 DRM_LOCK_FLUSH_ALL = 0x08, /**< Flush all DMA queues first */
222 /* These *HALT* flags aren't supported yet
223 -- they will be used to support the
224 full-screen DGA-like mode. */
225 DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */
226 DRM_HALT_CUR_QUEUES = 0x20 /**< Halt all current queues */
227} drmLockFlags;
228
229typedef enum {
230 DRM_CONTEXT_PRESERVED = 0x01, /**< This context is preserved and
231 never swapped. */
232 DRM_CONTEXT_2DONLY = 0x02 /**< This context is for 2D rendering only. */
233} drm_context_tFlags, *drm_context_tFlagsPtr;
234
235typedef struct _drmBufDesc {
236 int count; /**< Number of buffers of this size */
237 int size; /**< Size in bytes */
238 int low_mark; /**< Low water mark */
239 int high_mark; /**< High water mark */
240} drmBufDesc, *drmBufDescPtr;
241
242typedef struct _drmBufInfo {
243 int count; /**< Number of buffers described in list */
244 drmBufDescPtr list; /**< List of buffer descriptions */
245} drmBufInfo, *drmBufInfoPtr;
246
247typedef struct _drmBuf {
248 int idx; /**< Index into the master buffer list */
249 int total; /**< Buffer size */
250 int used; /**< Amount of buffer in use (for DMA) */
251 drmAddress address; /**< Address */
252} drmBuf, *drmBufPtr;
253
254/**
255 * Buffer mapping information.
256 *
257 * Used by drmMapBufs() and drmUnmapBufs() to store information about the
258 * mapped buffers.
259 */
260typedef struct _drmBufMap {
261 int count; /**< Number of buffers mapped */
262 drmBufPtr list; /**< Buffers */
263} drmBufMap, *drmBufMapPtr;
264
265typedef struct _drmLock {
266 volatile unsigned int lock;
267 char padding[60];
268 /* This is big enough for most current (and future?) architectures:
269 DEC Alpha: 32 bytes
270 Intel Merced: ?
271 Intel P5/PPro/PII/PIII: 32 bytes
272 Intel StrongARM: 32 bytes
273 Intel i386/i486: 16 bytes
274 MIPS: 32 bytes (?)
275 Motorola 68k: 16 bytes
276 Motorola PowerPC: 32 bytes
277 Sun SPARC: 32 bytes
278 */
279} drmLock, *drmLockPtr;
280
281/**
282 * Indices here refer to the offset into
283 * list in drmBufInfo
284 */
285typedef struct _drmDMAReq {
286 drm_context_t context; /**< Context handle */
287 int send_count; /**< Number of buffers to send */
288 int *send_list; /**< List of handles to buffers */
289 int *send_sizes; /**< Lengths of data to send, in bytes */
290 drmDMAFlags flags; /**< Flags */
291 int request_count; /**< Number of buffers requested */
292 int request_size; /**< Desired size of buffers requested */
293 int *request_list; /**< Buffer information */
294 int *request_sizes; /**< Minimum acceptable sizes */
295 int granted_count; /**< Number of buffers granted at this size */
296} drmDMAReq, *drmDMAReqPtr;
297
298typedef struct _drmRegion {
299 drm_handle_t handle;
300 unsigned int offset;
301 drmSize size;
302 drmAddress map;
303} drmRegion, *drmRegionPtr;
304
305typedef struct _drmTextureRegion {
306 unsigned char next;
307 unsigned char prev;
308 unsigned char in_use;
309 unsigned char padding; /**< Explicitly pad this out */
310 unsigned int age;
311} drmTextureRegion, *drmTextureRegionPtr;
312
313
314typedef enum {
315 DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */
316 DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */
317 /* bits 1-6 are reserved for high crtcs */
318 DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e,
319 DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */
320 DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */
321 DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */
322 DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */
323 DRM_VBLANK_SIGNAL = 0x40000000 /* Send signal instead of blocking */
324} drmVBlankSeqType;
325#define DRM_VBLANK_HIGH_CRTC_SHIFT 1
326
327typedef struct _drmVBlankReq {
328 drmVBlankSeqType type;
329 unsigned int sequence;
330 unsigned long signal;
331} drmVBlankReq, *drmVBlankReqPtr;
332
333typedef struct _drmVBlankReply {
334 drmVBlankSeqType type;
335 unsigned int sequence;
336 long tval_sec;
337 long tval_usec;
338} drmVBlankReply, *drmVBlankReplyPtr;
339
340typedef union _drmVBlank {
341 drmVBlankReq request;
342 drmVBlankReply reply;
343} drmVBlank, *drmVBlankPtr;
344
345typedef struct _drmSetVersion {
346 int drm_di_major;
347 int drm_di_minor;
348 int drm_dd_major;
349 int drm_dd_minor;
350} drmSetVersion, *drmSetVersionPtr;
351
352#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
353
354#define DRM_LOCK_HELD 0x80000000U /**< Hardware lock is held */
355#define DRM_LOCK_CONT 0x40000000U /**< Hardware lock is contended */
356
357#if defined(__GNUC__) && (__GNUC__ >= 2)
358# if defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
359 /* Reflect changes here to drmP.h */
360#define DRM_CAS(lock,old,new,__ret) \
361 do { \
362 int __dummy; /* Can't mark eax as clobbered */ \
363 __asm__ __volatile__( \
364 "lock ; cmpxchg %4,%1\n\t" \
365 "setnz %0" \
366 : "=d" (__ret), \
367 "=m" (__drm_dummy_lock(lock)), \
368 "=a" (__dummy) \
369 : "2" (old), \
370 "r" (new)); \
371 } while (0)
372
373#elif defined(__alpha__)
374
375#define DRM_CAS(lock, old, new, ret) \
376 do { \
377 int tmp, old32; \
378 __asm__ __volatile__( \
379 " addl $31, %5, %3\n" \
380 "1: ldl_l %0, %2\n" \
381 " cmpeq %0, %3, %1\n" \
382 " beq %1, 2f\n" \
383 " mov %4, %0\n" \
384 " stl_c %0, %2\n" \
385 " beq %0, 3f\n" \
386 " mb\n" \
387 "2: cmpeq %1, 0, %1\n" \
388 ".subsection 2\n" \
389 "3: br 1b\n" \
390 ".previous" \
391 : "=&r"(tmp), "=&r"(ret), \
392 "=m"(__drm_dummy_lock(lock)), \
393 "=&r"(old32) \
394 : "r"(new), "r"(old) \
395 : "memory"); \
396 } while (0)
397
398#elif defined(__sparc__)
399
400#define DRM_CAS(lock,old,new,__ret) \
401do { register unsigned int __old __asm("o0"); \
402 register unsigned int __new __asm("o1"); \
403 register volatile unsigned int *__lock __asm("o2"); \
404 __old = old; \
405 __new = new; \
406 __lock = (volatile unsigned int *)lock; \
407 __asm__ __volatile__( \
408 /*"cas [%2], %3, %0"*/ \
409 ".word 0xd3e29008\n\t" \
410 /*"membar #StoreStore | #StoreLoad"*/ \
411 ".word 0x8143e00a" \
412 : "=&r" (__new) \
413 : "0" (__new), \
414 "r" (__lock), \
415 "r" (__old) \
416 : "memory"); \
417 __ret = (__new != __old); \
418} while(0)
419
420#elif defined(__ia64__)
421
422#ifdef __INTEL_COMPILER
423/* this currently generates bad code (missing stop bits)... */
424#include <ia64intrin.h>
425
426#define DRM_CAS(lock,old,new,__ret) \
427 do { \
428 unsigned long __result, __old = (old) & 0xffffffff; \
429 __mf(); \
430 __result = _InterlockedCompareExchange_acq(&__drm_dummy_lock(lock), (new), __old);\
431 __ret = (__result) != (__old); \
432/* __ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \
433 (old), (new)) \
434 != (old)); */\
435 } while (0)
436
437#else
438#define DRM_CAS(lock,old,new,__ret) \
439 do { \
440 unsigned int __result, __old = (old); \
441 __asm__ __volatile__( \
442 "mf\n" \
443 "mov ar.ccv=%2\n" \
444 ";;\n" \
445 "cmpxchg4.acq %0=%1,%3,ar.ccv" \
446 : "=r" (__result), "=m" (__drm_dummy_lock(lock)) \
447 : "r" ((unsigned long)__old), "r" (new) \
448 : "memory"); \
449 __ret = (__result) != (__old); \
450 } while (0)
451
452#endif
453
454#elif defined(__powerpc__)
455
456#define DRM_CAS(lock,old,new,__ret) \
457 do { \
458 __asm__ __volatile__( \
459 "sync;" \
460 "0: lwarx %0,0,%1;" \
461 " xor. %0,%3,%0;" \
462 " bne 1f;" \
463 " stwcx. %2,0,%1;" \
464 " bne- 0b;" \
465 "1: " \
466 "sync;" \
467 : "=&r"(__ret) \
468 : "r"(lock), "r"(new), "r"(old) \
469 : "cr0", "memory"); \
470 } while (0)
471
472#endif /* architecture */
473#endif /* __GNUC__ >= 2 */
474
475#ifndef DRM_CAS
476#define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
477#endif
478
479#if defined(__alpha__)
480#define DRM_CAS_RESULT(_result) long _result
481#elif defined(__powerpc__)
482#define DRM_CAS_RESULT(_result) int _result
483#else
484#define DRM_CAS_RESULT(_result) char _result
485#endif
486
487#define DRM_LIGHT_LOCK(fd,lock,context) \
488 do { \
489 DRM_CAS_RESULT(__ret); \
490 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
491 if (__ret) drmGetLock(fd,context,0); \
492 } while(0)
493
494 /* This one counts fast locks -- for
495 benchmarking only. */
496#define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count) \
497 do { \
498 DRM_CAS_RESULT(__ret); \
499 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
500 if (__ret) drmGetLock(fd,context,0); \
501 else ++count; \
502 } while(0)
503
504#define DRM_LOCK(fd,lock,context,flags) \
505 do { \
506 if (flags) drmGetLock(fd,context,flags); \
507 else DRM_LIGHT_LOCK(fd,lock,context); \
508 } while(0)
509
510#define DRM_UNLOCK(fd,lock,context) \
511 do { \
512 DRM_CAS_RESULT(__ret); \
513 DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret); \
514 if (__ret) drmUnlock(fd,context); \
515 } while(0)
516
517 /* Simple spin locks */
518#define DRM_SPINLOCK(spin,val) \
519 do { \
520 DRM_CAS_RESULT(__ret); \
521 do { \
522 DRM_CAS(spin,0,val,__ret); \
523 if (__ret) while ((spin)->lock); \
524 } while (__ret); \
525 } while(0)
526
527#define DRM_SPINLOCK_TAKE(spin,val) \
528 do { \
529 DRM_CAS_RESULT(__ret); \
530 int cur; \
531 do { \
532 cur = (*spin).lock; \
533 DRM_CAS(spin,cur,val,__ret); \
534 } while (__ret); \
535 } while(0)
536
537#define DRM_SPINLOCK_COUNT(spin,val,count,__ret) \
538 do { \
539 int __i; \
540 __ret = 1; \
541 for (__i = 0; __ret && __i < count; __i++) { \
542 DRM_CAS(spin,0,val,__ret); \
543 if (__ret) for (;__i < count && (spin)->lock; __i++); \
544 } \
545 } while(0)
546
547#define DRM_SPINUNLOCK(spin,val) \
548 do { \
549 DRM_CAS_RESULT(__ret); \
550 if ((*spin).lock == val) { /* else server stole lock */ \
551 do { \
552 DRM_CAS(spin,val,0,__ret); \
553 } while (__ret); \
554 } \
555 } while(0)
556
557
558
559/* General user-level programmer's API: unprivileged */
560extern int drmAvailable(void);
561extern int drmOpen(const char *name, const char *busid);
562
563#define DRM_NODE_PRIMARY 0
564#define DRM_NODE_CONTROL 1
565#define DRM_NODE_RENDER 2
566#define DRM_NODE_MAX 3
567
568extern int drmOpenWithType(const char *name, const char *busid,
569 int type);
570
571extern int drmOpenControl(int minor);
572extern int drmOpenRender(int minor);
573extern int drmClose(int fd);
574extern drmVersionPtr drmGetVersion(int fd);
575extern drmVersionPtr drmGetLibVersion(int fd);
576extern int drmGetCap(int fd, uint64_t capability, uint64_t *value);
577extern void drmFreeVersion(drmVersionPtr);
578extern int drmGetMagic(int fd, drm_magic_t * magic);
579extern char *drmGetBusid(int fd);
580extern int drmGetInterruptFromBusID(int fd, int busnum, int devnum,
581 int funcnum);
582extern int drmGetMap(int fd, int idx, drm_handle_t *offset,
583 drmSize *size, drmMapType *type,
584 drmMapFlags *flags, drm_handle_t *handle,
585 int *mtrr);
586extern int drmGetClient(int fd, int idx, int *auth, int *pid,
587 int *uid, unsigned long *magic,
588 unsigned long *iocs);
589extern int drmGetStats(int fd, drmStatsT *stats);
590extern int drmSetInterfaceVersion(int fd, drmSetVersion *version);
591extern int drmCommandNone(int fd, unsigned long drmCommandIndex);
592extern int drmCommandRead(int fd, unsigned long drmCommandIndex,
593 void *data, unsigned long size);
594extern int drmCommandWrite(int fd, unsigned long drmCommandIndex,
595 void *data, unsigned long size);
596extern int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
597 void *data, unsigned long size);
598
599/* General user-level programmer's API: X server (root) only */
600extern void drmFreeBusid(const char *busid);
601extern int drmSetBusid(int fd, const char *busid);
602extern int drmAuthMagic(int fd, drm_magic_t magic);
603extern int drmAddMap(int fd,
604 drm_handle_t offset,
605 drmSize size,
606 drmMapType type,
607 drmMapFlags flags,
608 drm_handle_t * handle);
609extern int drmRmMap(int fd, drm_handle_t handle);
610extern int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id,
611 drm_handle_t handle);
612
613extern int drmAddBufs(int fd, int count, int size,
614 drmBufDescFlags flags,
615 int agp_offset);
616extern int drmMarkBufs(int fd, double low, double high);
617extern int drmCreateContext(int fd, drm_context_t * handle);
618extern int drmSetContextFlags(int fd, drm_context_t context,
619 drm_context_tFlags flags);
620extern int drmGetContextFlags(int fd, drm_context_t context,
621 drm_context_tFlagsPtr flags);
622extern int drmAddContextTag(int fd, drm_context_t context, void *tag);
623extern int drmDelContextTag(int fd, drm_context_t context);
624extern void *drmGetContextTag(int fd, drm_context_t context);
625extern drm_context_t * drmGetReservedContextList(int fd, int *count);
626extern void drmFreeReservedContextList(drm_context_t *);
627extern int drmSwitchToContext(int fd, drm_context_t context);
628extern int drmDestroyContext(int fd, drm_context_t handle);
629extern int drmCreateDrawable(int fd, drm_drawable_t * handle);
630extern int drmDestroyDrawable(int fd, drm_drawable_t handle);
631extern int drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
632 drm_drawable_info_type_t type,
633 unsigned int num, void *data);
634extern int drmCtlInstHandler(int fd, int irq);
635extern int drmCtlUninstHandler(int fd);
636extern int drmSetClientCap(int fd, uint64_t capability,
637 uint64_t value);
638
639/* General user-level programmer's API: authenticated client and/or X */
640extern int drmMap(int fd,
641 drm_handle_t handle,
642 drmSize size,
643 drmAddressPtr address);
644extern int drmUnmap(drmAddress address, drmSize size);
645extern drmBufInfoPtr drmGetBufInfo(int fd);
646extern drmBufMapPtr drmMapBufs(int fd);
647extern int drmUnmapBufs(drmBufMapPtr bufs);
648extern int drmDMA(int fd, drmDMAReqPtr request);
649extern int drmFreeBufs(int fd, int count, int *list);
650extern int drmGetLock(int fd,
651 drm_context_t context,
652 drmLockFlags flags);
653extern int drmUnlock(int fd, drm_context_t context);
654extern int drmFinish(int fd, int context, drmLockFlags flags);
655extern int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id,
656 drm_handle_t * handle);
657
658/* AGP/GART support: X server (root) only */
659extern int drmAgpAcquire(int fd);
660extern int drmAgpRelease(int fd);
661extern int drmAgpEnable(int fd, unsigned long mode);
662extern int drmAgpAlloc(int fd, unsigned long size,
663 unsigned long type, unsigned long *address,
664 drm_handle_t *handle);
665extern int drmAgpFree(int fd, drm_handle_t handle);
666extern int drmAgpBind(int fd, drm_handle_t handle,
667 unsigned long offset);
668extern int drmAgpUnbind(int fd, drm_handle_t handle);
669
670/* AGP/GART info: authenticated client and/or X */
671extern int drmAgpVersionMajor(int fd);
672extern int drmAgpVersionMinor(int fd);
673extern unsigned long drmAgpGetMode(int fd);
674extern unsigned long drmAgpBase(int fd); /* Physical location */
675extern unsigned long drmAgpSize(int fd); /* Bytes */
676extern unsigned long drmAgpMemoryUsed(int fd);
677extern unsigned long drmAgpMemoryAvail(int fd);
678extern unsigned int drmAgpVendorId(int fd);
679extern unsigned int drmAgpDeviceId(int fd);
680
681/* PCI scatter/gather support: X server (root) only */
682extern int drmScatterGatherAlloc(int fd, unsigned long size,
683 drm_handle_t *handle);
684extern int drmScatterGatherFree(int fd, drm_handle_t handle);
685
686extern int drmWaitVBlank(int fd, drmVBlankPtr vbl);
687
688/* Support routines */
689extern void drmSetServerInfo(drmServerInfoPtr info);
690extern int drmError(int err, const char *label);
691extern void *drmMalloc(int size);
692extern void drmFree(void *pt);
693
694/* Hash table routines */
695extern void *drmHashCreate(void);
696extern int drmHashDestroy(void *t);
697extern int drmHashLookup(void *t, unsigned long key, void **value);
698extern int drmHashInsert(void *t, unsigned long key, void *value);
699extern int drmHashDelete(void *t, unsigned long key);
700extern int drmHashFirst(void *t, unsigned long *key, void **value);
701extern int drmHashNext(void *t, unsigned long *key, void **value);
702
703/* PRNG routines */
704extern void *drmRandomCreate(unsigned long seed);
705extern int drmRandomDestroy(void *state);
706extern unsigned long drmRandom(void *state);
707extern double drmRandomDouble(void *state);
708
709/* Skip list routines */
710
711extern void *drmSLCreate(void);
712extern int drmSLDestroy(void *l);
713extern int drmSLLookup(void *l, unsigned long key, void **value);
714extern int drmSLInsert(void *l, unsigned long key, void *value);
715extern int drmSLDelete(void *l, unsigned long key);
716extern int drmSLNext(void *l, unsigned long *key, void **value);
717extern int drmSLFirst(void *l, unsigned long *key, void **value);
718extern void drmSLDump(void *l);
719extern int drmSLLookupNeighbors(void *l, unsigned long key,
720 unsigned long *prev_key, void **prev_value,
721 unsigned long *next_key, void **next_value);
722
723extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened);
724extern int drmOpenOnceWithType(const char *BusID, int *newlyopened, int type);
725extern void drmCloseOnce(int fd);
726extern void drmMsg(const char *format, ...) DRM_PRINTFLIKE(1, 2);
727
728extern int drmSetMaster(int fd);
729extern int drmDropMaster(int fd);
730
731#define DRM_EVENT_CONTEXT_VERSION 3
732
733typedef struct _drmEventContext {
734
735 /* This struct is versioned so we can add more pointers if we
736 * add more events. */
737 int version;
738
739 void (*vblank_handler)(int fd,
740 unsigned int sequence,
741 unsigned int tv_sec,
742 unsigned int tv_usec,
743 void *user_data);
744
745 void (*page_flip_handler)(int fd,
746 unsigned int sequence,
747 unsigned int tv_sec,
748 unsigned int tv_usec,
749 void *user_data);
750
751 void (*page_flip_handler2)(int fd,
752 unsigned int sequence,
753 unsigned int tv_sec,
754 unsigned int tv_usec,
755 unsigned int crtc_id,
756 void *user_data);
757
758} drmEventContext, *drmEventContextPtr;
759
760extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
761
762extern char *drmGetDeviceNameFromFd(int fd);
763
764/* Improved version of drmGetDeviceNameFromFd which attributes for any type of
765 * device/node - card, control or renderD.
766 */
767extern char *drmGetDeviceNameFromFd2(int fd);
768extern int drmGetNodeTypeFromFd(int fd);
769
770extern int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd);
771extern int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle);
772
773extern char *drmGetPrimaryDeviceNameFromFd(int fd);
774extern char *drmGetRenderDeviceNameFromFd(int fd);
775
776#define DRM_BUS_PCI 0
777#define DRM_BUS_USB 1
778#define DRM_BUS_PLATFORM 2
779#define DRM_BUS_HOST1X 3
780
781typedef struct _drmPciBusInfo {
782 uint16_t domain;
783 uint8_t bus;
784 uint8_t dev;
785 uint8_t func;
786} drmPciBusInfo, *drmPciBusInfoPtr;
787
788typedef struct _drmPciDeviceInfo {
789 uint16_t vendor_id;
790 uint16_t device_id;
791 uint16_t subvendor_id;
792 uint16_t subdevice_id;
793 uint8_t revision_id;
794} drmPciDeviceInfo, *drmPciDeviceInfoPtr;
795
796typedef struct _drmUsbBusInfo {
797 uint8_t bus;
798 uint8_t dev;
799} drmUsbBusInfo, *drmUsbBusInfoPtr;
800
801typedef struct _drmUsbDeviceInfo {
802 uint16_t vendor;
803 uint16_t product;
804} drmUsbDeviceInfo, *drmUsbDeviceInfoPtr;
805
806#define DRM_PLATFORM_DEVICE_NAME_LEN 512
807
808typedef struct _drmPlatformBusInfo {
809 char fullname[DRM_PLATFORM_DEVICE_NAME_LEN];
810} drmPlatformBusInfo, *drmPlatformBusInfoPtr;
811
812typedef struct _drmPlatformDeviceInfo {
813 char **compatible; /* NULL terminated list of compatible strings */
814} drmPlatformDeviceInfo, *drmPlatformDeviceInfoPtr;
815
816#define DRM_HOST1X_DEVICE_NAME_LEN 512
817
818typedef struct _drmHost1xBusInfo {
819 char fullname[DRM_HOST1X_DEVICE_NAME_LEN];
820} drmHost1xBusInfo, *drmHost1xBusInfoPtr;
821
822typedef struct _drmHost1xDeviceInfo {
823 char **compatible; /* NULL terminated list of compatible strings */
824} drmHost1xDeviceInfo, *drmHost1xDeviceInfoPtr;
825
826typedef struct _drmDevice {
827 char **nodes; /* DRM_NODE_MAX sized array */
828 int available_nodes; /* DRM_NODE_* bitmask */
829 int bustype;
830 union {
831 drmPciBusInfoPtr pci;
832 drmUsbBusInfoPtr usb;
833 drmPlatformBusInfoPtr platform;
834 drmHost1xBusInfoPtr host1x;
835 } businfo;
836 union {
837 drmPciDeviceInfoPtr pci;
838 drmUsbDeviceInfoPtr usb;
839 drmPlatformDeviceInfoPtr platform;
840 drmHost1xDeviceInfoPtr host1x;
841 } deviceinfo;
842} drmDevice, *drmDevicePtr;
843
844extern int drmGetDevice(int fd, drmDevicePtr *device);
845extern void drmFreeDevice(drmDevicePtr *device);
846
847extern int drmGetDevices(drmDevicePtr devices[], int max_devices);
848extern void drmFreeDevices(drmDevicePtr devices[], int count);
849
850#define DRM_DEVICE_GET_PCI_REVISION (1 << 0)
851extern int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device);
852extern int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices);
853
854extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b);
855
856#if defined(__cplusplus)
857}
858#endif
859
860#endif
diff --git a/src/static_libs/libdrm/xf86drmMode.h b/src/static_libs/libdrm/xf86drmMode.h
new file mode 100644
index 0000000000..5b390d9fbe
--- /dev/null
+++ b/src/static_libs/libdrm/xf86drmMode.h
@@ -0,0 +1,528 @@
1/*
2 * \file xf86drmMode.h
3 * Header for DRM modesetting interface.
4 *
5 * \author Jakob Bornecrantz <wallbraker@gmail.com>
6 *
7 * \par Acknowledgements:
8 * Feb 2007, Dave Airlie <airlied@linux.ie>
9 */
10
11/*
12 * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
13 * Copyright (c) 2007-2008 Dave Airlie <airlied@linux.ie>
14 * Copyright (c) 2007-2008 Jakob Bornecrantz <wallbraker@gmail.com>
15 *
16 * Permission is hereby granted, free of charge, to any person obtaining a
17 * copy of this software and associated documentation files (the "Software"),
18 * to deal in the Software without restriction, including without limitation
19 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
20 * and/or sell copies of the Software, and to permit persons to whom the
21 * Software is furnished to do so, subject to the following conditions:
22 *
23 * The above copyright notice and this permission notice shall be included in
24 * all copies or substantial portions of the Software.
25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
32 * IN THE SOFTWARE.
33 *
34 */
35
36#ifndef _XF86DRMMODE_H_
37#define _XF86DRMMODE_H_
38
39#if defined(__cplusplus)
40extern "C" {
41#endif
42
43#include <drm.h>
44
45/*
46 * This is the interface for modesetting for drm.
47 *
48 * In order to use this interface you must include either <stdint.h> or another
49 * header defining uint32_t, int32_t and uint16_t.
50 *
51 * It aims to provide a randr1.2 compatible interface for modesettings in the
52 * kernel, the interface is also ment to be used by libraries like EGL.
53 *
54 * More information can be found in randrproto.txt which can be found here:
55 * http://gitweb.freedesktop.org/?p=xorg/proto/randrproto.git
56 *
57 * There are some major diffrences to be noted. Unlike the randr1.2 proto you
58 * need to create the memory object of the framebuffer yourself with the ttm
59 * buffer object interface. This object needs to be pinned.
60 */
61
62/*
63 * If we pickup an old version of drm.h which doesn't include drm_mode.h
64 * we should redefine defines. This is so that builds doesn't breaks with
65 * new libdrm on old kernels.
66 */
67#ifndef _DRM_MODE_H
68
69#define DRM_DISPLAY_INFO_LEN 32
70#define DRM_CONNECTOR_NAME_LEN 32
71#define DRM_DISPLAY_MODE_LEN 32
72#define DRM_PROP_NAME_LEN 32
73
74#define DRM_MODE_TYPE_BUILTIN (1<<0)
75#define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN)
76#define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN)
77#define DRM_MODE_TYPE_PREFERRED (1<<3)
78#define DRM_MODE_TYPE_DEFAULT (1<<4)
79#define DRM_MODE_TYPE_USERDEF (1<<5)
80#define DRM_MODE_TYPE_DRIVER (1<<6)
81
82/* Video mode flags */
83/* bit compatible with the xorg definitions. */
84#define DRM_MODE_FLAG_PHSYNC (1<<0)
85#define DRM_MODE_FLAG_NHSYNC (1<<1)
86#define DRM_MODE_FLAG_PVSYNC (1<<2)
87#define DRM_MODE_FLAG_NVSYNC (1<<3)
88#define DRM_MODE_FLAG_INTERLACE (1<<4)
89#define DRM_MODE_FLAG_DBLSCAN (1<<5)
90#define DRM_MODE_FLAG_CSYNC (1<<6)
91#define DRM_MODE_FLAG_PCSYNC (1<<7)
92#define DRM_MODE_FLAG_NCSYNC (1<<8)
93#define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */
94#define DRM_MODE_FLAG_BCAST (1<<10)
95#define DRM_MODE_FLAG_PIXMUX (1<<11)
96#define DRM_MODE_FLAG_DBLCLK (1<<12)
97#define DRM_MODE_FLAG_CLKDIV2 (1<<13)
98#define DRM_MODE_FLAG_3D_MASK (0x1f<<14)
99#define DRM_MODE_FLAG_3D_NONE (0<<14)
100#define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14)
101#define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (2<<14)
102#define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (3<<14)
103#define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL (4<<14)
104#define DRM_MODE_FLAG_3D_L_DEPTH (5<<14)
105#define DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH (6<<14)
106#define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (7<<14)
107#define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (8<<14)
108
109/* DPMS flags */
110/* bit compatible with the xorg definitions. */
111#define DRM_MODE_DPMS_ON 0
112#define DRM_MODE_DPMS_STANDBY 1
113#define DRM_MODE_DPMS_SUSPEND 2
114#define DRM_MODE_DPMS_OFF 3
115
116/* Scaling mode options */
117#define DRM_MODE_SCALE_NON_GPU 0
118#define DRM_MODE_SCALE_FULLSCREEN 1
119#define DRM_MODE_SCALE_NO_SCALE 2
120#define DRM_MODE_SCALE_ASPECT 3
121
122/* Dithering mode options */
123#define DRM_MODE_DITHERING_OFF 0
124#define DRM_MODE_DITHERING_ON 1
125
126#define DRM_MODE_ENCODER_NONE 0
127#define DRM_MODE_ENCODER_DAC 1
128#define DRM_MODE_ENCODER_TMDS 2
129#define DRM_MODE_ENCODER_LVDS 3
130#define DRM_MODE_ENCODER_TVDAC 4
131#define DRM_MODE_ENCODER_VIRTUAL 5
132#define DRM_MODE_ENCODER_DSI 6
133#define DRM_MODE_ENCODER_DPMST 7
134#define DRM_MODE_ENCODER_DPI 8
135
136#define DRM_MODE_SUBCONNECTOR_Automatic 0
137#define DRM_MODE_SUBCONNECTOR_Unknown 0
138#define DRM_MODE_SUBCONNECTOR_DVID 3
139#define DRM_MODE_SUBCONNECTOR_DVIA 4
140#define DRM_MODE_SUBCONNECTOR_Composite 5
141#define DRM_MODE_SUBCONNECTOR_SVIDEO 6
142#define DRM_MODE_SUBCONNECTOR_Component 8
143#define DRM_MODE_SUBCONNECTOR_SCART 9
144
145#define DRM_MODE_CONNECTOR_Unknown 0
146#define DRM_MODE_CONNECTOR_VGA 1
147#define DRM_MODE_CONNECTOR_DVII 2
148#define DRM_MODE_CONNECTOR_DVID 3
149#define DRM_MODE_CONNECTOR_DVIA 4
150#define DRM_MODE_CONNECTOR_Composite 5
151#define DRM_MODE_CONNECTOR_SVIDEO 6
152#define DRM_MODE_CONNECTOR_LVDS 7
153#define DRM_MODE_CONNECTOR_Component 8
154#define DRM_MODE_CONNECTOR_9PinDIN 9
155#define DRM_MODE_CONNECTOR_DisplayPort 10
156#define DRM_MODE_CONNECTOR_HDMIA 11
157#define DRM_MODE_CONNECTOR_HDMIB 12
158#define DRM_MODE_CONNECTOR_TV 13
159#define DRM_MODE_CONNECTOR_eDP 14
160#define DRM_MODE_CONNECTOR_VIRTUAL 15
161#define DRM_MODE_CONNECTOR_DSI 16
162#define DRM_MODE_CONNECTOR_DPI 17
163
164#define DRM_MODE_PROP_PENDING (1<<0)
165#define DRM_MODE_PROP_RANGE (1<<1)
166#define DRM_MODE_PROP_IMMUTABLE (1<<2)
167#define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
168#define DRM_MODE_PROP_BLOB (1<<4)
169
170#define DRM_MODE_CURSOR_BO (1<<0)
171#define DRM_MODE_CURSOR_MOVE (1<<1)
172
173#endif /* _DRM_MODE_H */
174
175
176/*
177 * Feature defines
178 *
179 * Just because these are defined doesn't mean that the kernel
180 * can do that feature, its just for new code vs old libdrm.
181 */
182#define DRM_MODE_FEATURE_KMS 1
183#define DRM_MODE_FEATURE_DIRTYFB 1
184
185
186typedef struct _drmModeRes {
187
188 int count_fbs;
189 uint32_t *fbs;
190
191 int count_crtcs;
192 uint32_t *crtcs;
193
194 int count_connectors;
195 uint32_t *connectors;
196
197 int count_encoders;
198 uint32_t *encoders;
199
200 uint32_t min_width, max_width;
201 uint32_t min_height, max_height;
202} drmModeRes, *drmModeResPtr;
203
204typedef struct _drmModeModeInfo {
205 uint32_t clock;
206 uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew;
207 uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan;
208
209 uint32_t vrefresh;
210
211 uint32_t flags;
212 uint32_t type;
213 char name[DRM_DISPLAY_MODE_LEN];
214} drmModeModeInfo, *drmModeModeInfoPtr;
215
216typedef struct _drmModeFB {
217 uint32_t fb_id;
218 uint32_t width, height;
219 uint32_t pitch;
220 uint32_t bpp;
221 uint32_t depth;
222 /* driver specific handle */
223 uint32_t handle;
224} drmModeFB, *drmModeFBPtr;
225
226typedef struct drm_clip_rect drmModeClip, *drmModeClipPtr;
227
228typedef struct _drmModePropertyBlob {
229 uint32_t id;
230 uint32_t length;
231 void *data;
232} drmModePropertyBlobRes, *drmModePropertyBlobPtr;
233
234typedef struct _drmModeProperty {
235 uint32_t prop_id;
236 uint32_t flags;
237 char name[DRM_PROP_NAME_LEN];
238 int count_values;
239 uint64_t *values; /* store the blob lengths */
240 int count_enums;
241 struct drm_mode_property_enum *enums;
242 int count_blobs;
243 uint32_t *blob_ids; /* store the blob IDs */
244} drmModePropertyRes, *drmModePropertyPtr;
245
246static __inline int drm_property_type_is(drmModePropertyPtr property,
247 uint32_t type)
248{
249 /* instanceof for props.. handles extended type vs original types: */
250 if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE)
251 return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type;
252 return property->flags & type;
253}
254
255typedef struct _drmModeCrtc {
256 uint32_t crtc_id;
257 uint32_t buffer_id; /**< FB id to connect to 0 = disconnect */
258
259 uint32_t x, y; /**< Position on the framebuffer */
260 uint32_t width, height;
261 int mode_valid;
262 drmModeModeInfo mode;
263
264 int gamma_size; /**< Number of gamma stops */
265
266} drmModeCrtc, *drmModeCrtcPtr;
267
268typedef struct _drmModeEncoder {
269 uint32_t encoder_id;
270 uint32_t encoder_type;
271 uint32_t crtc_id;
272 uint32_t possible_crtcs;
273 uint32_t possible_clones;
274} drmModeEncoder, *drmModeEncoderPtr;
275
276typedef enum {
277 DRM_MODE_CONNECTED = 1,
278 DRM_MODE_DISCONNECTED = 2,
279 DRM_MODE_UNKNOWNCONNECTION = 3
280} drmModeConnection;
281
282typedef enum {
283 DRM_MODE_SUBPIXEL_UNKNOWN = 1,
284 DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2,
285 DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3,
286 DRM_MODE_SUBPIXEL_VERTICAL_RGB = 4,
287 DRM_MODE_SUBPIXEL_VERTICAL_BGR = 5,
288 DRM_MODE_SUBPIXEL_NONE = 6
289} drmModeSubPixel;
290
291typedef struct _drmModeConnector {
292 uint32_t connector_id;
293 uint32_t encoder_id; /**< Encoder currently connected to */
294 uint32_t connector_type;
295 uint32_t connector_type_id;
296 drmModeConnection connection;
297 uint32_t mmWidth, mmHeight; /**< HxW in millimeters */
298 drmModeSubPixel subpixel;
299
300 int count_modes;
301 drmModeModeInfoPtr modes;
302
303 int count_props;
304 uint32_t *props; /**< List of property ids */
305 uint64_t *prop_values; /**< List of property values */
306
307 int count_encoders;
308 uint32_t *encoders; /**< List of encoder ids */
309} drmModeConnector, *drmModeConnectorPtr;
310
311#define DRM_PLANE_TYPE_OVERLAY 0
312#define DRM_PLANE_TYPE_PRIMARY 1
313#define DRM_PLANE_TYPE_CURSOR 2
314
315typedef struct _drmModeObjectProperties {
316 uint32_t count_props;
317 uint32_t *props;
318 uint64_t *prop_values;
319} drmModeObjectProperties, *drmModeObjectPropertiesPtr;
320
321typedef struct _drmModePlane {
322 uint32_t count_formats;
323 uint32_t *formats;
324 uint32_t plane_id;
325
326 uint32_t crtc_id;
327 uint32_t fb_id;
328
329 uint32_t crtc_x, crtc_y;
330 uint32_t x, y;
331
332 uint32_t possible_crtcs;
333 uint32_t gamma_size;
334} drmModePlane, *drmModePlanePtr;
335
336typedef struct _drmModePlaneRes {
337 uint32_t count_planes;
338 uint32_t *planes;
339} drmModePlaneRes, *drmModePlaneResPtr;
340
341extern void drmModeFreeModeInfo( drmModeModeInfoPtr ptr );
342extern void drmModeFreeResources( drmModeResPtr ptr );
343extern void drmModeFreeFB( drmModeFBPtr ptr );
344extern void drmModeFreeCrtc( drmModeCrtcPtr ptr );
345extern void drmModeFreeConnector( drmModeConnectorPtr ptr );
346extern void drmModeFreeEncoder( drmModeEncoderPtr ptr );
347extern void drmModeFreePlane( drmModePlanePtr ptr );
348extern void drmModeFreePlaneResources(drmModePlaneResPtr ptr);
349
350/**
351 * Retrives all of the resources associated with a card.
352 */
353extern drmModeResPtr drmModeGetResources(int fd);
354
355/*
356 * FrameBuffer manipulation.
357 */
358
359/**
360 * Retrive information about framebuffer bufferId
361 */
362extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId);
363
364/**
365 * Creates a new framebuffer with an buffer object as its scanout buffer.
366 */
367extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
368 uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
369 uint32_t *buf_id);
370/* ...with a specific pixel format */
371extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
372 uint32_t pixel_format, uint32_t bo_handles[4],
373 uint32_t pitches[4], uint32_t offsets[4],
374 uint32_t *buf_id, uint32_t flags);
375
376/* ...with format modifiers */
377int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
378 uint32_t pixel_format, uint32_t bo_handles[4],
379 uint32_t pitches[4], uint32_t offsets[4],
380 uint64_t modifier[4], uint32_t *buf_id, uint32_t flags);
381
382/**
383 * Destroies the given framebuffer.
384 */
385extern int drmModeRmFB(int fd, uint32_t bufferId);
386
387/**
388 * Mark a region of a framebuffer as dirty.
389 */
390extern int drmModeDirtyFB(int fd, uint32_t bufferId,
391 drmModeClipPtr clips, uint32_t num_clips);
392
393
394/*
395 * Crtc functions
396 */
397
398/**
399 * Retrive information about the ctrt crtcId
400 */
401extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId);
402
403/**
404 * Set the mode on a crtc crtcId with the given mode modeId.
405 */
406int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
407 uint32_t x, uint32_t y, uint32_t *connectors, int count,
408 drmModeModeInfoPtr mode);
409
410/*
411 * Cursor functions
412 */
413
414/**
415 * Set the cursor on crtc
416 */
417int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height);
418
419int drmModeSetCursor2(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height, int32_t hot_x, int32_t hot_y);
420/**
421 * Move the cursor on crtc
422 */
423int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y);
424
425/**
426 * Encoder functions
427 */
428drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id);
429
430/*
431 * Connector manipulation
432 */
433
434/**
435 * Retrieve all information about the connector connectorId. This will do a
436 * forced probe on the connector to retrieve remote information such as EDIDs
437 * from the display device.
438 */
439extern drmModeConnectorPtr drmModeGetConnector(int fd,
440 uint32_t connectorId);
441
442/**
443 * Retrieve current information, i.e the currently active mode and encoder,
444 * about the connector connectorId. This will not do any probing on the
445 * connector or remote device, and only reports what is currently known.
446 * For the complete set of modes and encoders associated with the connector
447 * use drmModeGetConnector() which will do a probe to determine any display
448 * link changes first.
449 */
450extern drmModeConnectorPtr drmModeGetConnectorCurrent(int fd,
451 uint32_t connector_id);
452
453/**
454 * Attaches the given mode to an connector.
455 */
456extern int drmModeAttachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info);
457
458/**
459 * Detaches a mode from the connector
460 * must be unused, by the given mode.
461 */
462extern int drmModeDetachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info);
463
464extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId);
465extern void drmModeFreeProperty(drmModePropertyPtr ptr);
466
467extern drmModePropertyBlobPtr drmModeGetPropertyBlob(int fd, uint32_t blob_id);
468extern void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr);
469extern int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id,
470 uint64_t value);
471extern int drmCheckModesettingSupported(const char *busid);
472
473extern int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
474 uint16_t *red, uint16_t *green, uint16_t *blue);
475extern int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
476 uint16_t *red, uint16_t *green, uint16_t *blue);
477extern int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id,
478 uint32_t flags, void *user_data);
479extern int drmModePageFlipTarget(int fd, uint32_t crtc_id, uint32_t fb_id,
480 uint32_t flags, void *user_data,
481 uint32_t target_vblank);
482
483extern drmModePlaneResPtr drmModeGetPlaneResources(int fd);
484extern drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id);
485extern int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
486 uint32_t fb_id, uint32_t flags,
487 int32_t crtc_x, int32_t crtc_y,
488 uint32_t crtc_w, uint32_t crtc_h,
489 uint32_t src_x, uint32_t src_y,
490 uint32_t src_w, uint32_t src_h);
491
492extern drmModeObjectPropertiesPtr drmModeObjectGetProperties(int fd,
493 uint32_t object_id,
494 uint32_t object_type);
495extern void drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr);
496extern int drmModeObjectSetProperty(int fd, uint32_t object_id,
497 uint32_t object_type, uint32_t property_id,
498 uint64_t value);
499
500
501typedef struct _drmModeAtomicReq drmModeAtomicReq, *drmModeAtomicReqPtr;
502
503extern drmModeAtomicReqPtr drmModeAtomicAlloc(void);
504extern drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr req);
505extern int drmModeAtomicMerge(drmModeAtomicReqPtr base,
506 drmModeAtomicReqPtr augment);
507extern void drmModeAtomicFree(drmModeAtomicReqPtr req);
508extern int drmModeAtomicGetCursor(drmModeAtomicReqPtr req);
509extern void drmModeAtomicSetCursor(drmModeAtomicReqPtr req, int cursor);
510extern int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
511 uint32_t object_id,
512 uint32_t property_id,
513 uint64_t value);
514extern int drmModeAtomicCommit(int fd,
515 drmModeAtomicReqPtr req,
516 uint32_t flags,
517 void *user_data);
518
519extern int drmModeCreatePropertyBlob(int fd, const void *data, size_t size,
520 uint32_t *id);
521extern int drmModeDestroyPropertyBlob(int fd, uint32_t id);
522
523
524#if defined(__cplusplus)
525}
526#endif
527
528#endif