1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36#ifndef _DRM_H_
37#define _DRM_H_
38
39#if defined(__linux__)
40#if defined(__KERNEL__)
41#endif
42#include <asm/ioctl.h>
43#define DRM_IOCTL_NR(n) _IOC_NR(n)
44#define DRM_IOC_VOID _IOC_NONE
45#define DRM_IOC_READ _IOC_READ
46#define DRM_IOC_WRITE _IOC_WRITE
47#define DRM_IOC_READWRITE _IOC_READ|_IOC_WRITE
48#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
49#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
50#if defined(__FreeBSD__) && defined(IN_MODULE)
51
52#undef ioctl
53#include <sys/ioccom.h>
54#define ioctl(a,b,c) xf86ioctl(a,b,c)
55#else
56#include <sys/ioccom.h>
57#endif
58#define DRM_IOCTL_NR(n) ((n) & 0xff)
59#define DRM_IOC_VOID IOC_VOID
60#define DRM_IOC_READ IOC_OUT
61#define DRM_IOC_WRITE IOC_IN
62#define DRM_IOC_READWRITE IOC_INOUT
63#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
64#endif
65
66#define DRM_MAJOR 226
67#define DRM_MAX_MINOR 15
68
69#define DRM_NAME "drm"
70#define DRM_MIN_ORDER 5
71#define DRM_MAX_ORDER 22
72#define DRM_RAM_PERCENT 10
73
74#define _DRM_LOCK_HELD 0x80000000U
75#define _DRM_LOCK_CONT 0x40000000U
76#define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)
77#define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)
78#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
79
80typedef unsigned int drm_handle_t;
81typedef unsigned int drm_context_t;
82typedef unsigned int drm_drawable_t;
83typedef unsigned int drm_magic_t;
84
85
86
87
88
89
90
91
92
93
94struct drm_clip_rect {
95 unsigned short x1;
96 unsigned short y1;
97 unsigned short x2;
98 unsigned short y2;
99};
100
101
102
103
104struct drm_drawable_info {
105 unsigned int num_rects;
106 struct drm_clip_rect *rects;
107};
108
109
110
111
112struct drm_tex_region {
113 unsigned char next;
114 unsigned char prev;
115 unsigned char in_use;
116 unsigned char padding;
117 unsigned int age;
118};
119
120
121
122
123
124
125
126
127struct drm_hw_lock {
128 __volatile__ unsigned int lock;
129 char padding[60];
130};
131
132
133
134
135
136
137struct drm_version {
138 int version_major;
139 int version_minor;
140 int version_patchlevel;
141 size_t name_len;
142 char __user *name;
143 size_t date_len;
144 char __user *date;
145 size_t desc_len;
146 char __user *desc;
147};
148
149
150
151
152
153
154struct drm_unique {
155 size_t unique_len;
156 char __user *unique;
157};
158
159struct drm_list {
160 int count;
161 struct drm_version __user *version;
162};
163
164struct drm_block {
165 int unused;
166};
167
168
169
170
171
172
173struct drm_control {
174 enum {
175 DRM_ADD_COMMAND,
176 DRM_RM_COMMAND,
177 DRM_INST_HANDLER,
178 DRM_UNINST_HANDLER
179 } func;
180 int irq;
181};
182
183
184
185
186enum drm_map_type {
187 _DRM_FRAME_BUFFER = 0,
188 _DRM_REGISTERS = 1,
189 _DRM_SHM = 2,
190 _DRM_AGP = 3,
191 _DRM_SCATTER_GATHER = 4,
192 _DRM_CONSISTENT = 5,
193};
194
195
196
197
198enum drm_map_flags {
199 _DRM_RESTRICTED = 0x01,
200 _DRM_READ_ONLY = 0x02,
201 _DRM_LOCKED = 0x04,
202 _DRM_KERNEL = 0x08,
203 _DRM_WRITE_COMBINING = 0x10,
204 _DRM_CONTAINS_LOCK = 0x20,
205 _DRM_REMOVABLE = 0x40,
206 _DRM_DRIVER = 0x80
207};
208
209struct drm_ctx_priv_map {
210 unsigned int ctx_id;
211 void *handle;
212};
213
214
215
216
217
218
219
220struct drm_map {
221 unsigned long offset;
222 unsigned long size;
223 enum drm_map_type type;
224 enum drm_map_flags flags;
225 void *handle;
226
227 int mtrr;
228
229};
230
231
232
233
234struct drm_client {
235 int idx;
236 int auth;
237 unsigned long pid;
238 unsigned long uid;
239 unsigned long magic;
240 unsigned long iocs;
241};
242
243enum drm_stat_type {
244 _DRM_STAT_LOCK,
245 _DRM_STAT_OPENS,
246 _DRM_STAT_CLOSES,
247 _DRM_STAT_IOCTLS,
248 _DRM_STAT_LOCKS,
249 _DRM_STAT_UNLOCKS,
250 _DRM_STAT_VALUE,
251 _DRM_STAT_BYTE,
252 _DRM_STAT_COUNT,
253
254 _DRM_STAT_IRQ,
255 _DRM_STAT_PRIMARY,
256 _DRM_STAT_SECONDARY,
257 _DRM_STAT_DMA,
258 _DRM_STAT_SPECIAL,
259 _DRM_STAT_MISSED
260
261};
262
263
264
265
266struct drm_stats {
267 unsigned long count;
268 struct {
269 unsigned long value;
270 enum drm_stat_type type;
271 } data[15];
272};
273
274
275
276
277enum drm_lock_flags {
278 _DRM_LOCK_READY = 0x01,
279 _DRM_LOCK_QUIESCENT = 0x02,
280 _DRM_LOCK_FLUSH = 0x04,
281 _DRM_LOCK_FLUSH_ALL = 0x08,
282
283
284
285 _DRM_HALT_ALL_QUEUES = 0x10,
286 _DRM_HALT_CUR_QUEUES = 0x20
287};
288
289
290
291
292
293
294struct drm_lock {
295 int context;
296 enum drm_lock_flags flags;
297};
298
299
300
301
302
303
304
305
306
307enum drm_dma_flags {
308
309 _DRM_DMA_BLOCK = 0x01,
310
311
312
313
314
315
316
317
318
319 _DRM_DMA_WHILE_LOCKED = 0x02,
320 _DRM_DMA_PRIORITY = 0x04,
321
322
323 _DRM_DMA_WAIT = 0x10,
324 _DRM_DMA_SMALLER_OK = 0x20,
325 _DRM_DMA_LARGER_OK = 0x40
326};
327
328
329
330
331
332
333struct drm_buf_desc {
334 int count;
335 int size;
336 int low_mark;
337 int high_mark;
338 enum {
339 _DRM_PAGE_ALIGN = 0x01,
340 _DRM_AGP_BUFFER = 0x02,
341 _DRM_SG_BUFFER = 0x04,
342 _DRM_FB_BUFFER = 0x08,
343 _DRM_PCI_BUFFER_RO = 0x10
344 } flags;
345 unsigned long agp_start;
346
347
348
349};
350
351
352
353
354struct drm_buf_info {
355 int count;
356 struct drm_buf_desc __user *list;
357};
358
359
360
361
362struct drm_buf_free {
363 int count;
364 int __user *list;
365};
366
367
368
369
370
371
372struct drm_buf_pub {
373 int idx;
374 int total;
375 int used;
376 void __user *address;
377};
378
379
380
381
382struct drm_buf_map {
383 int count;
384 void __user *virtual;
385 struct drm_buf_pub __user *list;
386};
387
388
389
390
391
392
393
394
395struct drm_dma {
396 int context;
397 int send_count;
398 int __user *send_indices;
399 int __user *send_sizes;
400 enum drm_dma_flags flags;
401 int request_count;
402 int request_size;
403 int __user *request_indices;
404 int __user *request_sizes;
405 int granted_count;
406};
407
408enum drm_ctx_flags {
409 _DRM_CONTEXT_PRESERVED = 0x01,
410 _DRM_CONTEXT_2DONLY = 0x02
411};
412
413
414
415
416
417
418struct drm_ctx {
419 drm_context_t handle;
420 enum drm_ctx_flags flags;
421};
422
423
424
425
426struct drm_ctx_res {
427 int count;
428 struct drm_ctx __user *contexts;
429};
430
431
432
433
434struct drm_draw {
435 drm_drawable_t handle;
436};
437
438
439
440
441typedef enum {
442 DRM_DRAWABLE_CLIPRECTS,
443} drm_drawable_info_type_t;
444
445struct drm_update_draw {
446 drm_drawable_t handle;
447 unsigned int type;
448 unsigned int num;
449 unsigned long long data;
450};
451
452
453
454
455struct drm_auth {
456 drm_magic_t magic;
457};
458
459
460
461
462
463
464struct drm_irq_busid {
465 int irq;
466 int busnum;
467 int devnum;
468 int funcnum;
469};
470
471enum drm_vblank_seq_type {
472 _DRM_VBLANK_ABSOLUTE = 0x0,
473 _DRM_VBLANK_RELATIVE = 0x1,
474 _DRM_VBLANK_NEXTONMISS = 0x10000000,
475 _DRM_VBLANK_SECONDARY = 0x20000000,
476 _DRM_VBLANK_SIGNAL = 0x40000000
477};
478
479#define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE)
480#define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_SIGNAL | _DRM_VBLANK_SECONDARY | \
481 _DRM_VBLANK_NEXTONMISS)
482
483struct drm_wait_vblank_request {
484 enum drm_vblank_seq_type type;
485 unsigned int sequence;
486 unsigned long signal;
487};
488
489struct drm_wait_vblank_reply {
490 enum drm_vblank_seq_type type;
491 unsigned int sequence;
492 long tval_sec;
493 long tval_usec;
494};
495
496
497
498
499
500
501union drm_wait_vblank {
502 struct drm_wait_vblank_request request;
503 struct drm_wait_vblank_reply reply;
504};
505
506
507
508
509
510
511struct drm_agp_mode {
512 unsigned long mode;
513};
514
515
516
517
518
519
520struct drm_agp_buffer {
521 unsigned long size;
522 unsigned long handle;
523 unsigned long type;
524 unsigned long physical;
525};
526
527
528
529
530
531
532struct drm_agp_binding {
533 unsigned long handle;
534 unsigned long offset;
535};
536
537
538
539
540
541
542
543
544struct drm_agp_info {
545 int agp_version_major;
546 int agp_version_minor;
547 unsigned long mode;
548 unsigned long aperture_base;
549 unsigned long aperture_size;
550 unsigned long memory_allowed;
551 unsigned long memory_used;
552
553
554 unsigned short id_vendor;
555 unsigned short id_device;
556};
557
558
559
560
561struct drm_scatter_gather {
562 unsigned long size;
563 unsigned long handle;
564};
565
566
567
568
569struct drm_set_version {
570 int drm_di_major;
571 int drm_di_minor;
572 int drm_dd_major;
573 int drm_dd_minor;
574};
575
576#define DRM_IOCTL_BASE 'd'
577#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
578#define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type)
579#define DRM_IOW(nr,type) _IOW(DRM_IOCTL_BASE,nr,type)
580#define DRM_IOWR(nr,type) _IOWR(DRM_IOCTL_BASE,nr,type)
581
582#define DRM_IOCTL_VERSION DRM_IOWR(0x00, struct drm_version)
583#define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, struct drm_unique)
584#define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, struct drm_auth)
585#define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, struct drm_irq_busid)
586#define DRM_IOCTL_GET_MAP DRM_IOWR(0x04, struct drm_map)
587#define DRM_IOCTL_GET_CLIENT DRM_IOWR(0x05, struct drm_client)
588#define DRM_IOCTL_GET_STATS DRM_IOR( 0x06, struct drm_stats)
589#define DRM_IOCTL_SET_VERSION DRM_IOWR(0x07, struct drm_set_version)
590
591#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, struct drm_unique)
592#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, struct drm_auth)
593#define DRM_IOCTL_BLOCK DRM_IOWR(0x12, struct drm_block)
594#define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, struct drm_block)
595#define DRM_IOCTL_CONTROL DRM_IOW( 0x14, struct drm_control)
596#define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, struct drm_map)
597#define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, struct drm_buf_desc)
598#define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, struct drm_buf_desc)
599#define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, struct drm_buf_info)
600#define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, struct drm_buf_map)
601#define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, struct drm_buf_free)
602
603#define DRM_IOCTL_RM_MAP DRM_IOW( 0x1b, struct drm_map)
604
605#define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, struct drm_ctx_priv_map)
606#define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, struct drm_ctx_priv_map)
607
608#define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, struct drm_ctx)
609#define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, struct drm_ctx)
610#define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, struct drm_ctx)
611#define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, struct drm_ctx)
612#define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, struct drm_ctx)
613#define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, struct drm_ctx)
614#define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, struct drm_ctx_res)
615#define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, struct drm_draw)
616#define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, struct drm_draw)
617#define DRM_IOCTL_DMA DRM_IOWR(0x29, struct drm_dma)
618#define DRM_IOCTL_LOCK DRM_IOW( 0x2a, struct drm_lock)
619#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, struct drm_lock)
620#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, struct drm_lock)
621
622#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
623#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)
624#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, struct drm_agp_mode)
625#define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, struct drm_agp_info)
626#define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, struct drm_agp_buffer)
627#define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, struct drm_agp_buffer)
628#define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, struct drm_agp_binding)
629#define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, struct drm_agp_binding)
630
631#define DRM_IOCTL_SG_ALLOC DRM_IOW( 0x38, struct drm_scatter_gather)
632#define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, struct drm_scatter_gather)
633
634#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, union drm_wait_vblank)
635
636#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw)
637
638
639
640
641
642
643
644
645
646#define DRM_COMMAND_BASE 0x40
647#define DRM_COMMAND_END 0xA0
648
649
650#ifndef __KERNEL__
651typedef struct drm_clip_rect drm_clip_rect_t;
652typedef struct drm_drawable_info drm_drawable_info_t;
653typedef struct drm_tex_region drm_tex_region_t;
654typedef struct drm_hw_lock drm_hw_lock_t;
655typedef struct drm_version drm_version_t;
656typedef struct drm_unique drm_unique_t;
657typedef struct drm_list drm_list_t;
658typedef struct drm_block drm_block_t;
659typedef struct drm_control drm_control_t;
660typedef enum drm_map_type drm_map_type_t;
661typedef enum drm_map_flags drm_map_flags_t;
662typedef struct drm_ctx_priv_map drm_ctx_priv_map_t;
663typedef struct drm_map drm_map_t;
664typedef struct drm_client drm_client_t;
665typedef enum drm_stat_type drm_stat_type_t;
666typedef struct drm_stats drm_stats_t;
667typedef enum drm_lock_flags drm_lock_flags_t;
668typedef struct drm_lock drm_lock_t;
669typedef enum drm_dma_flags drm_dma_flags_t;
670typedef struct drm_buf_desc drm_buf_desc_t;
671typedef struct drm_buf_info drm_buf_info_t;
672typedef struct drm_buf_free drm_buf_free_t;
673typedef struct drm_buf_pub drm_buf_pub_t;
674typedef struct drm_buf_map drm_buf_map_t;
675typedef struct drm_dma drm_dma_t;
676typedef union drm_wait_vblank drm_wait_vblank_t;
677typedef struct drm_agp_mode drm_agp_mode_t;
678typedef enum drm_ctx_flags drm_ctx_flags_t;
679typedef struct drm_ctx drm_ctx_t;
680typedef struct drm_ctx_res drm_ctx_res_t;
681typedef struct drm_draw drm_draw_t;
682typedef struct drm_update_draw drm_update_draw_t;
683typedef struct drm_auth drm_auth_t;
684typedef struct drm_irq_busid drm_irq_busid_t;
685typedef enum drm_vblank_seq_type drm_vblank_seq_type_t;
686
687typedef struct drm_agp_buffer drm_agp_buffer_t;
688typedef struct drm_agp_binding drm_agp_binding_t;
689typedef struct drm_agp_info drm_agp_info_t;
690typedef struct drm_scatter_gather drm_scatter_gather_t;
691typedef struct drm_set_version drm_set_version_t;
692#endif
693
694#endif
695