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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
use libc::*;
use byteorder::{ByteOrder, NativeEndian};
use util::*;
pub const DRM_NAME: &'static str = "drm";
pub const DRM_MIN_ORDER: c_int = 5;
pub const DRM_MAX_ORDER: u8 = 22;
pub const DRM_RAM_PERCENT: c_int = 10;
#[macro_export]
macro_rules! drm_io { ($nr:expr) => (io!(100, $nr)); }
#[macro_export]
macro_rules! drm_iow { ($nr:expr, $ty:expr) => (iow!(100, $nr, $ty)); }
#[macro_export]
macro_rules! drm_ior { ($nr:expr, $ty:expr) => (ior!(100, $nr, $ty)); }
#[macro_export]
macro_rules! drm_iowr { ($nr:expr, $ty:expr) => (iorw!(100, $nr, $ty)); }
#[macro_export]
macro_rules! drm_ioctl_version { () => (drm_iowr!(0x00, drm_version)); }
#[macro_export]
macro_rules! drm_ioctl_get_unique { () => (drm_iowr!(0x01, drm_unique)); }
#[macro_export]
macro_rules! drm_ioctl_get_magic { () => (drm_ior!( 0x02, drm_auth)); }
#[macro_export]
macro_rules! drm_ioctl_irq_busid { () => (drm_iowr!(0x03, drm_irq_busid)); }
#[macro_export]
macro_rules! drm_ioctl_get_map { () => (drm_iowr!(0x04, drm_map)); }
#[macro_export]
macro_rules! drm_ioctl_get_client { () => (drm_iowr!(0x05, drm_client)); }
#[macro_export]
macro_rules! drm_ioctl_get_stats { () => (drm_ior!( 0x06, drm_stats)); }
#[macro_export]
macro_rules! drm_ioctl_set_version { () => (drm_iowr!(0x07, drm_set_version)); }
#[macro_export]
macro_rules! drm_ioctl_modeset_ctl { () => (drm_iow!(0x08, drm_modeset_ctl)); }
#[macro_export]
macro_rules! drm_ioctl_gem_close { () => (drm_iow!(0x09, drm_gem_close)); }
#[macro_export]
macro_rules! drm_ioctl_gem_flink { () => (drm_iowr!(0x0a, drm_gem_flink)); }
#[macro_export]
macro_rules! drm_ioctl_gem_open { () => (drm_iowr!(0x0b, drm_gem_open)); }
#[macro_export]
macro_rules! drm_ioctl_get_cap { () => (drm_iowr!(0x0c, drm_get_cap)); }
#[macro_export]
macro_rules! drm_ioctl_set_client_cap { () => (drm_iow!( 0x0d, drm_set_client_cap)); }
#[macro_export]
macro_rules! drm_ioctl_set_unique { () => (drm_iow!( 0x10, drm_unique)); }
#[macro_export]
macro_rules! drm_ioctl_auth_magic { () => (drm_iow!( 0x11, drm_auth)); }
#[macro_export]
macro_rules! drm_ioctl_block { () => (drm_iowr!(0x12, drm_block)); }
#[macro_export]
macro_rules! drm_ioctl_unblock { () => (drm_iowr!(0x13, drm_block)); }
#[macro_export]
macro_rules! drm_ioctl_control { () => (drm_iow!( 0x14, drm_control)); }
#[macro_export]
macro_rules! drm_ioctl_add_map { () => (drm_iowr!(0x15, drm_map)); }
#[macro_export]
macro_rules! drm_ioctl_add_bufs { () => (drm_iowr!(0x16, drm_buf_desc)); }
#[macro_export]
macro_rules! drm_ioctl_mark_bufs { () => (drm_iow!( 0x17, drm_buf_desc)); }
#[macro_export]
macro_rules! drm_ioctl_info_bufs { () => (drm_iowr!(0x18, drm_buf_info)); }
#[macro_export]
macro_rules! drm_ioctl_map_bufs { () => (drm_iowr!(0x19, drm_buf_map)); }
#[macro_export]
macro_rules! drm_ioctl_free_bufs { () => (drm_iow!( 0x1a, drm_buf_free)); }
#[macro_export]
macro_rules! drm_ioctl_rm_map { () => (drm_iow!( 0x1b, drm_map)); }
#[macro_export]
macro_rules! drm_ioctl_set_sarea_ctx { () => (drm_iow!( 0x1c, drm_ctx_priv_map)); }
#[macro_export]
macro_rules! drm_ioctl_get_sarea_ctx { () => (drm_iowr!(0x1d, drm_ctx_priv_map)); }
#[macro_export]
macro_rules! drm_ioctl_set_master { () => (drm_io!(0x1e)); }
#[macro_export]
macro_rules! drm_ioctl_drop_master { () => (drm_io!(0x1f)); }
#[macro_export]
macro_rules! drm_ioctl_add_ctx { () => (drm_iowr!(0x20, drm_ctx)); }
#[macro_export]
macro_rules! drm_ioctl_rm_ctx { () => (drm_iowr!(0x21, drm_ctx)); }
#[macro_export]
macro_rules! drm_ioctl_mod_ctx { () => (drm_iow!( 0x22, drm_ctx)); }
#[macro_export]
macro_rules! drm_ioctl_get_ctx { () => (drm_iowr!(0x23, drm_ctx)); }
#[macro_export]
macro_rules! drm_ioctl_switch_ctx { () => (drm_iow!( 0x24, drm_ctx)); }
#[macro_export]
macro_rules! drm_ioctl_new_ctx { () => (drm_iow!( 0x25, drm_ctx)); }
#[macro_export]
macro_rules! drm_ioctl_res_ctx { () => (drm_iowr!(0x26, drm_ctx_res)); }
#[macro_export]
macro_rules! drm_ioctl_add_draw { () => (drm_iowr!(0x27, drm_draw)); }
#[macro_export]
macro_rules! drm_ioctl_rm_draw { () => (drm_iowr!(0x28, drm_draw)); }
#[macro_export]
macro_rules! drm_ioctl_dma { () => (drm_iowr!(0x29, drm_dma)); }
#[macro_export]
macro_rules! drm_ioctl_lock { () => (drm_iow!( 0x2a, drm_lock)); }
#[macro_export]
macro_rules! drm_ioctl_unlock { () => (drm_iow!( 0x2b, drm_lock)); }
#[macro_export]
macro_rules! drm_ioctl_finish { () => (drm_iow!( 0x2c, drm_lock)); }
#[macro_export]
macro_rules! drm_ioctl_prime_handle_to_fd { () => (drm_iowr!(0x2d, drm_prime_handle)); }
#[macro_export]
macro_rules! drm_ioctl_prime_fd_to_handle { () => (drm_iowr!(0x2e, drm_prime_handle)); }
#[macro_export]
macro_rules! drm_ioctl_agp_acquire { () => (drm_io!( 0x30)); }
#[macro_export]
macro_rules! drm_ioctl_agp_release { () => (drm_io!( 0x31)); }
#[macro_export]
macro_rules! drm_ioctl_agp_enable { () => (drm_iow!( 0x32, drm_agp_mode)); }
#[macro_export]
macro_rules! drm_ioctl_agp_info { () => (drm_ior!( 0x33, drm_agp_info)); }
#[macro_export]
macro_rules! drm_ioctl_agp_alloc { () => (drm_iowr!(0x34, drm_agp_buffer)); }
#[macro_export]
macro_rules! drm_ioctl_agp_free { () => (drm_iow!( 0x35, drm_agp_buffer)); }
#[macro_export]
macro_rules! drm_ioctl_agp_bind { () => (drm_iow!( 0x36, drm_agp_binding)); }
#[macro_export]
macro_rules! drm_ioctl_agp_unbind { () => (drm_iow!( 0x37, drm_agp_binding)); }
#[macro_export]
macro_rules! drm_ioctl_sg_alloc { () => (drm_iowr!(0x38, drm_scatter_gather)); }
#[macro_export]
macro_rules! drm_ioctl_sg_free { () => (drm_iow!(0x39, drm_scatter_gather)); }
#[macro_export]
macro_rules! drm_ioctl_wait_vblank { () => (drm_iowr!(0x3a, drm_wait_vblank)); }
#[macro_export]
macro_rules! drm_ioctl_update_draw { () => (drm_iow!(0x3f, drm_update_draw)); }
#[macro_export]
macro_rules! drm_ioctl_mode_getresources { () => (drm_iowr!(0xA0, drm_mode_card_res)); }
#[macro_export]
macro_rules! drm_ioctl_mode_getcrtc { () => (drm_iowr!(0xA1, drm_mode_crtc)); }
#[macro_export]
macro_rules! drm_ioctl_mode_setcrtc { () => (drm_iowr!(0xA2, drm_mode_crtc)); }
#[macro_export]
macro_rules! drm_ioctl_mode_cursor { () => (drm_iowr!(0xA3, drm_mode_cursor)); }
#[macro_export]
macro_rules! drm_ioctl_mode_getgamma { () => (drm_iowr!(0xA4, drm_mode_crtc_lut)); }
#[macro_export]
macro_rules! drm_ioctl_mode_setgamma { () => (drm_iowr!(0xA5, drm_mode_crtc_lut)); }
#[macro_export]
macro_rules! drm_ioctl_mode_getencoder { () => (drm_iowr!(0xA6, drm_mode_get_encoder)); }
#[macro_export]
macro_rules! drm_ioctl_mode_getconnector { () => (drm_iowr!(0xA7, drm_mode_get_connector)); }
#[macro_export]
macro_rules! drm_ioctl_mode_attachmode { () => (drm_iowr!(0xA8, drm_mode_mode_cmd)); }
#[macro_export]
macro_rules! drm_ioctl_mode_detachmode { () => (drm_iowr!(0xA9, drm_mode_mode_cmd)); }
#[macro_export]
macro_rules! drm_ioctl_mode_getproperty { () => (drm_iowr!(0xAA, drm_mode_get_property)); }
#[macro_export]
macro_rules! drm_ioctl_mode_setproperty { () => (drm_iowr!(0xAB, drm_mode_connector_set_property)); }
#[macro_export]
macro_rules! drm_ioctl_mode_getpropblob { () => (drm_iowr!(0xAC, drm_mode_get_blob)); }
#[macro_export]
macro_rules! drm_ioctl_mode_getfb { () => (drm_iowr!(0xAD, drm_mode_fb_cmd)); }
#[macro_export]
macro_rules! drm_ioctl_mode_addfb { () => (drm_iowr!(0xAE, drm_mode_fb_cmd)); }
#[macro_export]
macro_rules! drm_ioctl_mode_addfb { () => (drm_iowr!(0xAE, c_uint)); }
#[macro_export]
macro_rules! drm_ioctl_mode_page_flip { () => (drm_iowr!(0xB0, drm_mode_crtc_page_flip)); }
#[macro_export]
macro_rules! drm_ioctl_mode_dirtyfb { () => (drm_iowr!(0xB1, drm_mode_fb_dirty_cmd)); }
#[macro_export]
macro_rules! drm_ioctl_mode_create_dumb { () => (drm_iowr!(0xB2, drm_mode_create_dumb)); }
#[macro_export]
macro_rules! drm_ioctl_mode_map_dumb { () => (drm_iowr!(0xB3, drm_mode_map_dumb)); }
#[macro_export]
macro_rules! drm_ioctl_mode_destroy_dumb { () => (drm_iowr!(0xB4, drm_mode_destroy_dumb)); }
#[macro_export]
macro_rules! drm_ioctl_mode_getplaneresources { () => (drm_iowr!(0xB5, drm_mode_get_plane_res)); }
#[macro_export]
macro_rules! drm_ioctl_mode_getplane { () => (drm_iowr!(0xB6, drm_mode_get_plane)); }
#[macro_export]
macro_rules! drm_ioctl_mode_setplane { () => (drm_iowr!(0xB7, drm_mode_set_plane)); }
#[macro_export]
macro_rules! drm_ioctl_mode_addfb2 { () => (drm_iowr!(0xB8, drm_mode_fb_cmd2)); }
#[macro_export]
macro_rules! drm_ioctl_mode_obj_getproperties { () => (drm_iowr!(0xB9, drm_mode_obj_get_properties)); }
#[macro_export]
macro_rules! drm_ioctl_mode_obj_setproperty { () => (drm_iowr!(0xBA, drm_mode_obj_set_property)); }
#[macro_export]
macro_rules! drm_ioctl_mode_cursor2 { () => (drm_iowr!(0xBB, drm_mode_cursor2)); }
#[macro_export]
macro_rules! drm_ioctl_mode_atomic { () => (drm_iowr!(0xBC, drm_mode_atomic)); }
#[macro_export]
macro_rules! drm_ioctl_mode_createpropblob { () => (drm_iowr!(0xBD, drm_mode_create_blob)); }
#[macro_export]
macro_rules! drm_ioctl_mode_destroypropblob { () => (drm_iowr!(0xBE, drm_mode_destroy_blob)); }
pub type drm_context_t = c_uint;
pub type drm_drawable_t = c_uint;
pub type drm_magic_t = c_uint;
#[repr(C)]
pub struct drm_clip_rect {
pub x1: c_ushort,
pub y1: c_ushort,
pub x2: c_ushort,
pub y2: c_ushort
}
impl ::std::default::Default for drm_clip_rect {
fn default() -> drm_clip_rect { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_drawable_info {
pub num_rects: c_uint,
pub rects: *mut drm_clip_rect
}
impl ::std::default::Default for drm_drawable_info {
fn default() -> drm_drawable_info { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_tex_region {
pub next: c_uchar,
pub prev: c_uchar,
pub in_use: c_uchar,
pub padding: c_uchar,
pub age: c_uint
}
impl ::std::default::Default for drm_tex_region {
fn default() -> drm_tex_region { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_hw_lock {
pub lock: VolatileCell<c_uint>,
pub padding: [c_char; 60]
}
impl ::std::default::Default for drm_hw_lock {
fn default() -> drm_hw_lock { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_version {
pub version_major: c_int,
pub version_minor: c_int,
pub version_patchlevel: c_int,
pub name_len: KernelSizeT,
pub name: *mut c_char,
pub date_len: KernelSizeT,
pub date: *mut c_char,
pub desc_len: KernelSizeT,
pub desc: *mut c_char
}
impl ::std::default::Default for drm_version {
fn default() -> drm_version { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_unique {
pub unique_len: KernelSizeT,
pub unique: *mut c_char
}
impl ::std::default::Default for drm_unique {
fn default() -> drm_unique { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_list {
pub count: c_int,
pub version: *mut drm_version
}
impl ::std::default::Default for drm_list {
fn default() -> drm_list { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_block {
pub unused: c_int
}
impl ::std::default::Default for drm_block {
fn default() -> drm_block { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub enum drm_control_func {
DRM_ADD_COMMAND,
DRM_RM_COMMAND,
DRM_INST_HANDLER,
DRM_UNINST_HANDLER
}
#[repr(C)]
pub struct drm_control {
pub func: drm_control_func,
pub irq: c_int
}
impl ::std::default::Default for drm_control {
fn default() -> drm_control { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub enum drm_map_type {
_DRM_FRAME_BUFFER = 0,
_DRM_REGISTERS = 1,
_DRM_SHM = 2,
_DRM_AGP = 3,
_DRM_SCATTER_GATHER = 4,
_DRM_CONSISTENT = 5
}
#[repr(C)]
pub enum drm_map_flags {
_DRM_RESTRICTED = 0x01,
_DRM_READ_ONLY = 0x02,
_DRM_LOCKED = 0x04,
_DRM_KERNEL = 0x08,
_DRM_WRITE_COMBINING = 0x10,
_DRM_CONTAINS_LOCK = 0x20,
_DRM_REMOVABLE = 0x40,
_DRM_DRIVER = 0x80
}
#[repr(C)]
pub struct drm_ctx_priv_map {
ctx_id: c_uint,
handle: *mut c_void
}
impl ::std::default::Default for drm_ctx_priv_map {
fn default() -> drm_ctx_priv_map { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_map {
offset: c_ulong,
size: c_ulong,
map_type: drm_map_type,
flags: drm_map_flags,
handle: *mut c_void,
mtrr: c_int
}
impl ::std::default::Default for drm_map {
fn default() -> drm_map { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_client {
pub idx: c_int,
pub auth: c_int,
pub pid: c_ulong,
pub uid: c_ulong,
pub magic: c_ulong,
pub iocs: c_ulong
}
impl ::std::default::Default for drm_client {
fn default() -> drm_client { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub enum drm_stat_type {
_DRM_STAT_LOCK,
_DRM_STAT_OPENS,
_DRM_STAT_CLOSES,
_DRM_STAT_IOCTLS,
_DRM_STAT_LOCKS,
_DRM_STAT_UNLOCKS,
_DRM_STAT_VALUE,
_DRM_STAT_BYTE,
_DRM_STAT_COUNT,
_DRM_STAT_IRQ,
_DRM_STAT_PRIMARY,
_DRM_STAT_SECONDARY,
_DRM_STAT_DMA,
_DRM_STAT_SPECIAL,
_DRM_STAT_MISSED
}
#[repr(C)]
pub struct drm_stats_data {
value: c_ulong,
stat_type: drm_stat_type
}
impl ::std::default::Default for drm_stats_data {
fn default() -> drm_stats_data { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_stats {
pub count: c_ulong,
pub data: [drm_stats_data; 15]
}
impl ::std::default::Default for drm_stats {
fn default() -> drm_stats { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub enum drm_lock_flags {
_DRM_LOCK_READY = 0x01,
_DRM_LOCK_QUIESCENT = 0x02,
_DRM_LOCK_FLUSH = 0x04,
_DRM_LOCK_FLUSH_ALL = 0x08,
_DRM_HALT_ALL_QUEUES = 0x10,
_DRM_HALT_CUR_QUEUES = 0x20
}
#[repr(C)]
pub struct drm_lock {
pub context: c_int,
pub flags: drm_lock_flags
}
impl ::std::default::Default for drm_lock {
fn default() -> drm_lock { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub enum drm_dma_flags {
_DRM_DMA_BLOCK = 0x01,
_DRM_DMA_WHILE_LOCKED = 0x02,
_DRM_DMA_PRIORITY = 0x04,
_DRM_DMA_WAIT = 0x10,
_DRM_DMA_SMALLER_OK = 0x20,
_DRM_DMA_LARGER_OK = 0x40
}
#[repr(C)]
pub enum drm_buf_desc_flags {
_DRM_PAGE_ALIGN = 0x01,
_DRM_AGP_BUFFER = 0x02,
_DRM_SG_BUFFER = 0x04,
_DRM_FB_BUFFER = 0x08,
_DRM_PCI_BUFFER_RO = 0x10
}
#[repr(C)]
pub struct drm_buf_desc {
pub count: c_int,
pub size: c_int,
pub low_mark: c_int,
pub high_mark: c_int,
pub flags: drm_buf_desc_flags,
pub agp_start: c_ulong
}
impl ::std::default::Default for drm_buf_desc {
fn default() -> drm_buf_desc { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_buf_info {
pub count: c_int,
pub list: *mut drm_buf_desc
}
impl ::std::default::Default for drm_buf_info {
fn default() -> drm_buf_info { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_buf_free {
pub count: c_int,
pub list: *mut c_int
}
impl ::std::default::Default for drm_buf_free {
fn default() -> drm_buf_free { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_buf_pub {
pub idx: c_int,
pub total: c_int,
pub used: c_int,
pub address: *mut c_void
}
impl ::std::default::Default for drm_buf_pub {
fn default() -> drm_buf_pub { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_buf_map {
pub count: c_int,
pub virtual_address: *mut c_void,
pub list: *mut drm_buf_pub
}
impl ::std::default::Default for drm_buf_map {
fn default() -> drm_buf_map { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_dma {
pub context: c_int,
pub send_count: c_int,
pub send_indices: *mut c_int,
pub send_sizes: *mut c_int,
pub flags: drm_dma_flags,
pub request_count: c_int,
pub request_size: c_int,
pub request_indices: *mut c_int,
pub request_sizes: *mut c_int,
pub granted_count: c_int
}
impl ::std::default::Default for drm_dma {
fn default() -> drm_dma { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub enum drm_ctx_flags {
_DRM_CONTEXT_PRESERVED = 0x01,
_DRM_CONTEXT_2DONLY = 0x02
}
#[repr(C)]
pub struct drm_ctx {
pub handle: drm_context_t,
pub flags: drm_ctx_flags
}
impl ::std::default::Default for drm_ctx {
fn default() -> drm_ctx { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_ctx_res {
pub count: c_int,
pub contexts: *mut drm_ctx
}
impl ::std::default::Default for drm_ctx_res {
fn default() -> drm_ctx_res { unsafe { ::std::mem::zeroed() } }
}
struct drm_draw {
pub handle: drm_drawable_t
}
#[repr(C)]
pub enum drm_drawable_info_type_t {
DRM_DRAWABLE_CLIPRECTS
}
#[repr(C)]
pub struct drm_update_draw {
pub handle: drm_drawable_t,
pub update_type: c_uint,
pub num: c_uint,
pub data: c_ulonglong
}
impl ::std::default::Default for drm_update_draw {
fn default() -> drm_update_draw { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_auth {
pub magic: drm_magic_t
}
impl ::std::default::Default for drm_auth {
fn default() -> drm_auth { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_irq_busid {
pub irq: c_int,
pub busnum: c_int,
pub devnum: c_int,
pub funcnum: c_int
}
impl ::std::default::Default for drm_irq_busid {
fn default() -> drm_irq_busid { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub enum drm_vblank_seq_type {
_DRM_VBLANK_ABSOLUTE = 0x0,
_DRM_VBLANK_RELATIVE = 0x1,
_DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e,
_DRM_VBLANK_EVENT = 0x4000000,
_DRM_VBLANK_FLIP = 0x8000000,
_DRM_VBLANK_NEXTONMISS = 0x10000000,
_DRM_VBLANK_SECONDARY = 0x20000000,
_DRM_VBLANK_SIGNAL = 0x40000000
}
impl drm_vblank_seq_type {
fn from_u32(n: u32) -> drm_vblank_seq_type {
match n {
0x0 => drm_vblank_seq_type::_DRM_VBLANK_ABSOLUTE,
0x1 => drm_vblank_seq_type::_DRM_VBLANK_RELATIVE,
0x0000003e => drm_vblank_seq_type::_DRM_VBLANK_HIGH_CRTC_MASK,
0x04000000 => drm_vblank_seq_type::_DRM_VBLANK_EVENT,
0x08000000 => drm_vblank_seq_type::_DRM_VBLANK_FLIP,
0x10000000 => drm_vblank_seq_type::_DRM_VBLANK_NEXTONMISS,
0x20000000 => drm_vblank_seq_type::_DRM_VBLANK_SECONDARY,
0x40000000 => drm_vblank_seq_type::_DRM_VBLANK_SIGNAL,
_ => drm_vblank_seq_type::_DRM_VBLANK_ABSOLUTE
}
}
}
pub const _DRM_VBLANK_HIGH_CRTC_SHIFT: c_int = 1;
#[repr(C)]
pub struct drm_wait_vblank_request {
pub request_type: drm_vblank_seq_type,
pub sequence: c_uint,
pub signal: c_ulong,
}
impl ::std::default::Default for drm_wait_vblank_request {
fn default() -> drm_wait_vblank_request { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_wait_vblank_reply {
pub reply_type: drm_vblank_seq_type,
pub sequence: c_uint,
pub tval_sec: c_long,
pub tval_usec: c_long
}
impl ::std::default::Default for drm_wait_vblank_reply {
fn default() -> drm_wait_vblank_reply { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_wait_vblank {
pub data: [u8; 24]
}
impl ::std::default::Default for drm_wait_vblank {
fn default() -> drm_wait_vblank { unsafe { ::std::mem::zeroed() } }
}
impl drm_wait_vblank {
#[cfg(target_pointer_width = "32")]
fn request (&self) -> drm_wait_vblank_request {
let req = drm_wait_vblank_request {
request_type: drm_vblank_seq_type::from_u32(NativeEndian::read_u32(&self.data[0..4])),
sequence: NativeEndian::read_u32(&self.data[5..8]),
signal: NativeEndian::read_u32(&self.data[9..16])
};
req
}
#[cfg(target_pointer_width = "32")]
fn reply (&self) -> drm_wait_vblank_reply {
let reply = drm_wait_vblank_reply {
reply_type: drm_vblank_seq_type::from_u32(NativeEndian::read_u32(&self.data[0..4])),
sequence: NativeEndian::read_u32(&self.data[5..8]),
tval_sec: NativeEndian::read_i32(&self.data[9..16]),
tval_usec: NativeEndian::read_i32(&self.data[17..24])
};
reply
}
#[cfg(target_pointer_width = "64")]
fn request (&self) -> drm_wait_vblank_request {
let req = drm_wait_vblank_request {
request_type: drm_vblank_seq_type::from_u32(NativeEndian::read_u32(&self.data[0..4])),
sequence: NativeEndian::read_u32(&self.data[5..8]),
signal: NativeEndian::read_u64(&self.data[9..16])
};
req
}
#[cfg(target_pointer_width = "64")]
fn reply (&self) -> drm_wait_vblank_reply {
let reply = drm_wait_vblank_reply {
reply_type: drm_vblank_seq_type::from_u32(NativeEndian::read_u32(&self.data[0..4])),
sequence: NativeEndian::read_u32(&self.data[5..8]),
tval_sec: NativeEndian::read_i64(&self.data[9..16]),
tval_usec: NativeEndian::read_i64(&self.data[17..24])
};
reply
}
}
pub const _DRM_PRE_MODESET: c_int = 1;
pub const _DRM_POST_MODESET: c_int = 2;
#[repr(C)]
pub struct drm_modeset_ctl {
pub crtc: u32,
pub cmd: u32
}
impl ::std::default::Default for drm_modeset_ctl {
fn default() -> drm_modeset_ctl { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_agp_mode {
pub mode: c_ulong
}
impl ::std::default::Default for drm_agp_mode {
fn default() -> drm_agp_mode { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_agp_buffer {
pub size: c_ulong,
pub handle: c_ulong,
pub buffer_type: c_ulong,
pub physical: c_ulong
}
impl ::std::default::Default for drm_agp_buffer {
fn default() -> drm_agp_buffer { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_agp_binding {
pub handle: c_ulong,
pub offset: c_ulong
}
impl ::std::default::Default for drm_agp_binding {
fn default() -> drm_agp_binding { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_agp_info {
pub agp_version_major: c_int,
pub agp_version_minor: c_int,
pub mode: c_ulong,
pub aperture_base: c_ulong,
pub aperture_size: c_ulong,
pub memory_allowed: c_ulong,
pub memory_used: c_ulong,
pub id_vendor: c_ushort,
pub id_device: c_ushort
}
impl ::std::default::Default for drm_agp_info {
fn default() -> drm_agp_info { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_scatter_gather {
pub size: c_ulong,
pub handle: c_ulong
}
impl ::std::default::Default for drm_scatter_gather {
fn default() -> drm_scatter_gather { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_set_version {
pub drm_di_major: c_int,
pub drm_di_minor: c_int,
pub drm_dd_major: c_int,
pub drm_dd_minor: c_int
}
impl ::std::default::Default for drm_set_version {
fn default() -> drm_set_version { unsafe { ::std::mem::zeroed() } }
}
struct drm_gem_close {
pub handle: u32,
pub pad: u32
}
#[repr(C)]
pub struct drm_gem_flink {
pub handle: u32,
pub name: u32
}
impl ::std::default::Default for drm_gem_flink {
fn default() -> drm_gem_flink { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
pub struct drm_gem_open {
pub name: u32,
pub handle: u32,
pub size: u64
}
impl ::std::default::Default for drm_gem_open {
fn default() -> drm_gem_open { unsafe { ::std::mem::zeroed() } }
}
pub const DRM_CAP_DUMB_BUFFER: c_int = 0x1;
pub const DRM_CAP_VBLANK_HIGH_CRTC: c_int = 0x2;
pub const DRM_CAP_DUMB_PREFERRED_DEPTH: c_int = 0x3;
pub const DRM_CAP_DUMB_PREFER_SHADOW: c_int = 0x4;
pub const DRM_CAP_PRIME: c_int = 0x5;
pub const DRM_PRIME_CAP_IMPORT: c_int = 0x1;
pub const DRM_PRIME_CAP_EXPORT: c_int = 0x2;
pub const DRM_CAP_TIMESTAMP_MONOTONIC: c_int = 0x6;
pub const DRM_CAP_ASYNC_PAGE_FLIP: c_int = 0x7;
pub const DRM_CAP_CURSOR_WIDTH: c_int = 0x8;
pub const DRM_CAP_CURSOR_HEIGHT: c_int = 0x9;
pub const DRM_CAP_ADDFB2_MODIFIERS: c_int = 0x10;
#[repr(C)]
pub struct drm_get_cap {
pub capability: u64,
pub value: u64
}
impl ::std::default::Default for drm_get_cap {
fn default() -> drm_get_cap { unsafe { ::std::mem::zeroed() } }
}
pub const DRM_CLIENT_CAP_STEREO_3D: c_int = 1;
pub const DRM_CLIENT_CAP_UNIVERSAL_PLANES: c_int = 2;
pub const DRM_CLIENT_CAP_ATOMIC: c_int = 3;
#[repr(C)]
pub struct drm_set_client_cap {
pub capability: u64,
pub value: u64
}
impl ::std::default::Default for drm_set_client_cap {
fn default() -> drm_set_client_cap { unsafe { ::std::mem::zeroed() } }
}
pub const DRM_RDWR: c_int = O_RDWR;
#[repr(C)]
pub struct drm_prime_handle {
pub handle: u32,
pub flags: u32,
pub fd: i32
}
impl ::std::default::Default for drm_prime_handle {
fn default() -> drm_prime_handle { unsafe { ::std::mem::zeroed() } }
}
pub const DRM_COMMAND_BASE: c_int = 0x40;
pub const DRM_COMMAND_END: c_int = 0xA0;
#[repr(C)]
pub struct drm_event {
pub event_type: u32,
pub length: u32
}
impl ::std::default::Default for drm_event {
fn default() -> drm_event { unsafe { ::std::mem::zeroed() } }
}
pub const DRM_EVENT_VBLANK: c_int = 0x01;
pub const DRM_EVENT_FLIP_COMPLETE: c_int = 0x02;
#[repr(C)]
pub struct drm_event_vblank {
pub base: drm_event,
pub user_data: u64,
pub tv_sec: u32,
pub tv_usec: u32,
pub sequence: u32,
pub reserved: u32
}
impl ::std::default::Default for drm_event_vblank {
fn default() -> drm_event_vblank { unsafe { ::std::mem::zeroed() } }
}
type drm_clip_rect_t = drm_clip_rect;
type drm_drawable_info_t = drm_drawable_info;
type drm_tex_region_t = drm_tex_region;
type drm_hw_lock_t = drm_hw_lock;
type drm_version_t = drm_version;
type drm_unique_t = drm_unique;
type drm_list_t = drm_list;
type drm_block_t = drm_block;
type drm_control_t = drm_control;
type drm_map_type_t = drm_map_type;
type drm_map_flags_t = drm_map_flags;
type drm_ctx_priv_map_t = drm_ctx_priv_map;
type drm_map_t = drm_map;
type drm_client_t = drm_client;
type drm_stat_type_t = drm_stat_type;
type drm_stats_t = drm_stats;
type drm_lock_flags_t = drm_lock_flags;
type drm_lock_t = drm_lock;
type drm_dma_flags_t = drm_dma_flags;
type drm_buf_desc_t = drm_buf_desc;
type drm_buf_info_t = drm_buf_info;
type drm_buf_free_t = drm_buf_free;
type drm_buf_pub_t = drm_buf_pub;
type drm_buf_map_t = drm_buf_map;
type drm_dma_t = drm_dma;
type drm_wait_vblank_t = drm_wait_vblank;
type drm_agp_mode_t = drm_agp_mode;
type drm_ctx_flags_t = drm_ctx_flags;
type drm_ctx_t = drm_ctx;
type drm_ctx_res_t = drm_ctx_res;
type drm_draw_t = drm_draw;
type drm_update_draw_t = drm_update_draw;
type drm_auth_t = drm_auth;
type drm_irq_busid_t = drm_irq_busid;
type drm_vblank_seq_type_t = drm_vblank_seq_type;
type drm_agp_buffer_t = drm_agp_buffer;
type drm_agp_binding_t = drm_agp_binding;
type drm_agp_info_t = drm_agp_info;
type drm_scatter_gather_t = drm_scatter_gather;
type drm_set_version_t = drm_set_version;