drm/ffi/
xf86drm.rs

1/*
2 * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 *
25 */
26
27use libc::*;
28use byteorder::{ByteOrder, NativeEndian};
29
30use ffi::drm::*;
31use ffi::util::VolatileCell;
32
33pub type va_list = c_void;
34
35#[repr(C)]
36pub enum drmMapType {
37    DRM_FRAME_BUFFER    = 0,
38    DRM_REGISTERS       = 1,
39    DRM_SHM             = 2,
40    DRM_AGP             = 3,
41    DRM_SCATTER_GATHER  = 4,
42    DRM_CONSISTENT      = 5
43}
44
45#[repr(C)]
46pub enum drmMapFlags {
47    DRM_RESTRICTED      = 0x0001,
48    DRM_READ_ONLY       = 0x0002,
49    DRM_LOCKED          = 0x0004,
50    DRM_KERNEL          = 0x0008,
51    DRM_WRITE_COMBINING = 0x0010,
52    DRM_CONTAINS_LOCK   = 0x0020,
53    DRM_REMOVABLE	  = 0x0040
54}
55
56/**
57 * \warning These values *MUST* match drm.h
58 */
59 #[repr(C)]
60pub enum drmDMAFlags {
61
62    /*@{*/
63    DRM_DMA_BLOCK        = 0x01, /**<
64				  * Block until buffer dispatched.
65				  *
66				  * \note the buffer may not yet have been
67				  * processed by the hardware -- getting a
68				  * hardware lock with the hardware quiescent
69				  * will ensure that the buffer has been
70				  * processed.
71				  */
72    DRM_DMA_WHILE_LOCKED = 0x02,
73    DRM_DMA_PRIORITY     = 0x04,
74    /*@}*/
75
76
77    /*@{*/
78    DRM_DMA_WAIT         = 0x10,
79    DRM_DMA_SMALLER_OK   = 0x20,
80    DRM_DMA_LARGER_OK    = 0x40
81    /*@}*/
82}
83
84#[repr(C)]
85pub enum drmBufDescFlags {
86    DRM_PAGE_ALIGN       = 0x01,
87    DRM_AGP_BUFFER       = 0x02,
88    DRM_SG_BUFFER        = 0x04,
89    DRM_FB_BUFFER        = 0x08,
90    DRM_PCI_BUFFER_RO    = 0x10
91}
92
93#[repr(C)]
94pub enum drmLockFlags {
95    DRM_LOCK_READY      = 0x01,
96    DRM_LOCK_QUIESCENT  = 0x02,
97    DRM_LOCK_FLUSH      = 0x04,
98    DRM_LOCK_FLUSH_ALL  = 0x08,
99				/* These *HALT* flags aren't supported yet
100                                   -- they will be used to support the
101                                   full-screen DGA-like mode. */
102    DRM_HALT_ALL_QUEUES = 0x10,
103    DRM_HALT_CUR_QUEUES = 0x20
104}
105
106#[repr(C)]
107pub enum drm_context_tFlags {
108    DRM_CONTEXT_PRESERVED = 0x01,
109    DRM_CONTEXT_2DONLY    = 0x02
110}
111pub type drm_context_tFlagsPtr = *mut drm_context_tFlags;
112
113#[repr(C)]
114pub struct drmBufDesc {
115    count: c_int,	  /**< Number of buffers of this size */
116    size: c_int,	  /**< Size in bytes */
117    low_mark: c_int,  /**< Low water mark */
118    high_mark: c_int
119}
120impl ::std::default::Default for drmBufDesc {
121    fn default() -> drmBufDesc { unsafe { ::std::mem::zeroed() } }
122}
123
124pub type drmBufDescPtr = *mut drmBufDesc;
125
126#[repr(C)]
127pub struct drmBufInfo {
128    count: c_int,	        /**< Number of buffers described in list */
129    list: *mut drmBufDesc
130}
131impl ::std::default::Default for drmBufInfo {
132    fn default() -> drmBufInfo { unsafe { ::std::mem::zeroed() } }
133}
134
135pub type drmBufInfoPtr = *mut drmBufInfo;
136
137#[repr(C)]
138pub struct drmBuf {
139    idx: c_int,	        /**< Index into the master buffer list */
140    total: c_int,	    /**< Buffer size */
141    used: c_int,	    /**< Amount of buffer in use (for DMA) */
142    address: drmAddress
143}
144impl ::std::default::Default for drmBuf {
145    fn default() -> drmBuf { unsafe { ::std::mem::zeroed() } }
146}
147
148pub type drmBufPtr = *mut drmBuf;
149
150/**
151 * Buffer mapping information.
152 *
153 * Used by drmMapBufs() and drmUnmapBufs() to store information about the
154 * mapped buffers.
155 */
156#[repr(C)]
157pub struct drmBufMap {
158    count: c_int,	  /**< Number of buffers mapped */
159    list: drmBufPtr
160}
161impl ::std::default::Default for drmBufMap {
162    fn default() -> drmBufMap { unsafe { ::std::mem::zeroed() } }
163}
164
165pub type drmBufMapPtr = *mut drmBufMap;
166
167#[repr(C)]
168pub struct drmLock {
169    lock: VolatileCell<c_uint>,
170    padding: [c_char; 60]
171    /* This is big enough for most current (and future?) architectures:
172       DEC Alpha:              32 bytes
173       Intel Merced:           ?
174       Intel P5/PPro/PII/PIII: 32 bytes
175       Intel StrongARM:        32 bytes
176       Intel i386/i486:        16 bytes
177       MIPS:                   32 bytes (?)
178       Motorola 68k:           16 bytes
179       Motorola PowerPC:       32 bytes
180       Sun SPARC:              32 bytes
181    */
182}
183impl ::std::default::Default for drmLock {
184    fn default() -> drmLock { unsafe { ::std::mem::zeroed() } }
185}
186
187pub type drmLockPtr = *mut drmLock;
188
189/**
190 * Indices here refer to the offset into
191 * list in drmBufInfo
192 */
193 #[repr(C)]
194pub struct drmDMAReq {
195    context: drm_context_t,  	  /**< Context handle */
196    send_count: c_int,            /**< Number of buffers to send */
197    send_list: *mut c_int,        /**< List of handles to buffers */
198    send_sizes: *mut c_int,       /**< Lengths of data to send, in bytes */
199    flags: drmDMAFlags,           /**< Flags */
200    request_count: c_int,         /**< Number of buffers requested */
201    request_size: c_int,          /**< Desired size of buffers requested */
202    request_list: *mut c_int,     /**< Buffer information */
203    request_sizes: *mut c_int,    /**< Minimum acceptable sizes */
204    granted_count: c_int
205}
206impl ::std::default::Default for drmDMAReq {
207    fn default() -> drmDMAReq { unsafe { ::std::mem::zeroed() } }
208}
209
210pub type drmDMAReqPtr = *mut drmDMAReq;
211
212#[repr(C)]
213pub struct drmRegion {
214    handle: drm_handle_t,
215    offset: c_uint,
216    size: drmSize,
217    map: drmAddress
218}
219impl ::std::default::Default for drmRegion {
220    fn default() -> drmRegion { unsafe { ::std::mem::zeroed() } }
221}
222
223pub type drmRegionPtr = *mut drmRegion;
224
225#[repr(C)]
226pub struct drmTextureRegion {
227    next: c_uchar,
228    prev: c_uchar,
229    in_use: c_uchar,
230    padding: c_uchar,	/**< Explicitly pad this out */
231    age: c_uint
232}
233impl ::std::default::Default for drmTextureRegion {
234    fn default() -> drmTextureRegion { unsafe { ::std::mem::zeroed() } }
235}
236
237pub type drmTextureRegionPtr = *mut drmTextureRegion;
238
239#[repr(C)]
240pub struct drmPciBusInfo {
241    domain: uint16_t,
242    bus: uint8_t,
243    dev: uint8_t,
244    func: uint8_t,
245}
246impl ::std::default::Default for drmPciBusInfo {
247    fn default() -> drmPciBusInfo { unsafe { ::std::mem::zeroed() } }
248}
249
250pub type drmPciBusInfoPtr = *mut drmPciBusInfo;
251
252#[repr(C)]
253pub struct drmPciDeviceInfo {
254    vendor_id: uint16_t,
255    device_id: uint16_t,
256    subvendor_id: uint16_t,
257    subdevice_id: uint16_t,
258    revision_id: uint8_t,
259}
260impl ::std::default::Default for drmPciDeviceInfo {
261    fn default() -> drmPciDeviceInfo { unsafe { ::std::mem::zeroed() } }
262}
263
264pub type drmPciDeviceInfoPtr = *mut drmPciDeviceInfo;
265
266#[repr(C)]
267pub struct businfo {
268    pci: drmPciBusInfoPtr
269}
270impl ::std::default::Default for businfo {
271    fn default() -> businfo { unsafe { ::std::mem::zeroed() } }
272}
273
274
275#[repr(C)]
276pub struct deviceinfo {
277    pci: drmPciDeviceInfoPtr
278}
279impl ::std::default::Default for deviceinfo {
280    fn default() -> deviceinfo { unsafe { ::std::mem::zeroed() } }
281}
282
283
284#[repr(C)]
285pub struct drmDevice {
286    nodes: *mut *mut c_char, /* DRM_NODE_MAX sized array */
287    available_nodes: c_int, /* DRM_NODE_* bitmask */
288    bustype: c_int,
289    businfo: businfo,
290    deviceinfo: deviceinfo
291}
292impl ::std::default::Default for drmDevice {
293    fn default() -> drmDevice { unsafe { ::std::mem::zeroed() } }
294}
295
296pub type drmDevicePtr = *mut drmDevice;
297
298#[repr(C)]
299pub struct drmEventContext {
300    // This struct is versioned so we can add more pointers if we add more events.
301    pub version: c_int,
302
303    pub vblank_handler: extern fn(fd: c_int,
304                                  sequence: c_uint,
305                                  tv_sec: c_uint,
306                                  tv_usec: c_uint,
307                                  user_data: *mut c_void),
308
309    pub page_flip_handler: extern fn(fd: c_int,
310                                     sequence: c_uint,
311                                     tv_sec: c_uint,
312                                     tv_usec: c_uint,
313                                     user_data: *mut c_void),
314}
315
316impl ::std::default::Default for drmEventContext {
317    fn default() -> drmEventContext { unsafe { ::std::mem::zeroed() } }
318}
319
320pub type drmEventContextPtr = *const drmEventContext;
321
322#[repr(C)]
323pub enum drmVBlankSeqType {
324    DRM_VBLANK_ABSOLUTE = 0x0,
325    DRM_VBLANK_RELATIVE = 0x1,
326    /* bits 1-6 are reserved for high crtcs */
327    DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e,
328    DRM_VBLANK_EVENT = 0x4000000,
329    DRM_VBLANK_FLIP = 0x8000000,
330    DRM_VBLANK_NEXTONMISS = 0x10000000,
331    DRM_VBLANK_SECONDARY = 0x20000000,
332    DRM_VBLANK_SIGNAL   = 0x40000000	/* Send signal instead of blocking */
333}
334const DRM_VBLANK_HIGH_CRTC_SHIFT : u8 = 1;
335impl drmVBlankSeqType {
336    fn from_u32(n: u32) -> drmVBlankSeqType {
337        match n {
338            0x0         => drmVBlankSeqType::DRM_VBLANK_ABSOLUTE,
339            0x1         => drmVBlankSeqType::DRM_VBLANK_RELATIVE,
340            0x0000003e  => drmVBlankSeqType::DRM_VBLANK_HIGH_CRTC_MASK,
341            0x04000000  => drmVBlankSeqType::DRM_VBLANK_EVENT,
342            0x08000000  => drmVBlankSeqType::DRM_VBLANK_FLIP,
343            0x10000000  => drmVBlankSeqType::DRM_VBLANK_NEXTONMISS,
344            0x20000000  => drmVBlankSeqType::DRM_VBLANK_SECONDARY,
345            0x40000000  => drmVBlankSeqType::DRM_VBLANK_SIGNAL,
346            _           => drmVBlankSeqType::DRM_VBLANK_ABSOLUTE
347        }
348    }
349}
350
351#[repr(C)]
352pub struct drmVBlankReq {
353	request_type: drmVBlankSeqType,
354	sequence: c_uint,
355	signal: c_ulong,
356}
357impl ::std::default::Default for drmVBlankReq {
358    fn default() -> drmVBlankReq { unsafe { ::std::mem::zeroed() } }
359}
360
361pub type drmVBlankReqPtr = *mut drmVBlankReq;
362
363#[repr(C)]
364pub struct drmVBlankReply {
365	reply_type: drmVBlankSeqType,
366	sequence: c_uint,
367	tval_sec: c_long,
368	tval_usec: c_long
369}
370impl ::std::default::Default for drmVBlankReply {
371    fn default() -> drmVBlankReply { unsafe { ::std::mem::zeroed() } }
372}
373
374pub type drmVBlankReplyPtr = *mut drmVBlankReply;
375
376#[repr(C)]
377pub struct drmVBlank {
378    data: [u8; 24]
379}
380impl ::std::default::Default for drmVBlank {
381    fn default() -> drmVBlank { unsafe { ::std::mem::zeroed() } }
382}
383
384pub type drmVBlankPtr = *mut drmVBlank;
385
386impl drmVBlank {
387    #[cfg(target_pointer_width = "32")]
388    fn request (&self) -> drmVBlankReq {
389        let req = drmVBlankReq {
390            request_type: drmVBlankSeqType::from_u32(NativeEndian::read_u32(&self.data[0..4])),
391            sequence: NativeEndian::read_u32(&self.data[5..8]),
392            signal: NativeEndian::read_u32(&self.data[9..16])
393        };
394
395        req
396    }
397
398    #[cfg(target_pointer_width = "32")]
399    fn reply (&self) -> drmVBlankReply {
400        let reply = drmVBlankReply {
401            reply_type: drmVBlankSeqType::from_u32(NativeEndian::read_u32(&self.data[0..4])),
402            sequence: NativeEndian::read_u32(&self.data[5..8]),
403            tval_sec: NativeEndian::read_i32(&self.data[9..16]),
404            tval_usec: NativeEndian::read_i32(&self.data[17..24])
405        };
406
407        reply
408    }
409
410    #[cfg(target_pointer_width = "64")]
411    fn request (&self) -> drmVBlankReq {
412        let req = drmVBlankReq {
413            request_type: drmVBlankSeqType::from_u32(NativeEndian::read_u32(&self.data[0..4])),
414            sequence: NativeEndian::read_u32(&self.data[5..8]),
415            signal: NativeEndian::read_u64(&self.data[9..16])
416        };
417
418        req
419    }
420
421    #[cfg(target_pointer_width = "64")]
422    fn reply (&self) -> drmVBlankReply {
423        let reply = drmVBlankReply {
424            reply_type: drmVBlankSeqType::from_u32(NativeEndian::read_u32(&self.data[0..4])),
425            sequence: NativeEndian::read_u32(&self.data[5..8]),
426            tval_sec: NativeEndian::read_i64(&self.data[9..16]),
427            tval_usec: NativeEndian::read_i64(&self.data[17..24])
428        };
429
430        reply
431    }
432}
433
434#[repr(C)]
435pub struct drmServerInfo {
436  debug_print: extern fn(format: *const c_char, ap: va_list) -> c_int,
437  load_module: extern fn(name: *const c_char) -> c_int,
438  get_perms: extern fn(gid: *mut gid_t, mode: *mut mode_t) -> c_void
439}
440impl ::std::default::Default for drmServerInfo {
441    fn default() -> drmServerInfo { unsafe { ::std::mem::zeroed() } }
442}
443
444pub type drmServerInfoPtr = *mut drmServerInfo;
445
446#[repr(C)]
447pub struct drmHashEntry {
448    fd: c_int,
449    f: extern fn(num: c_int, ptr1: *mut c_void, ptr2: *mut c_void) -> c_void,
450    tag_table: *mut c_void
451}
452impl ::std::default::Default for drmHashEntry {
453    fn default() -> drmHashEntry { unsafe { ::std::mem::zeroed() } }
454}
455
456
457#[repr(C)]
458pub struct drmVersion {
459    version_major:      c_int,          /**< Major version */
460    version_minor:      c_int,          /**< Minor version */
461    version_patchlevel: c_int,          /**< Patch level */
462    name_len:           c_int,          /**< Length of name buffer */
463    name:               *mut c_char,    /**< Name of driver */
464    date_len:           c_int,          /**< Length of date buffer */
465    date:               *mut c_char,    /**< User-space buffer to hold date */
466    desc_len:           c_int,          /**< Length of desc buffer */
467    desc:               *mut c_char
468}
469impl ::std::default::Default for drmVersion {
470    fn default() -> drmVersion { unsafe { ::std::mem::zeroed() } }
471}
472
473pub type drmVersionPtr = *mut drmVersion;
474
475#[repr(C)]
476pub struct drmSetVersion {
477	drm_di_major: c_int,
478	drm_di_minor: c_int,
479	drm_dd_major: c_int,
480	drm_dd_minor: c_int
481}
482impl ::std::default::Default for drmSetVersion {
483    fn default() -> drmSetVersion { unsafe { ::std::mem::zeroed() } }
484}
485
486pub type drmSetVersionPtr = *mut drmSetVersion;
487
488#[repr(C)]
489pub struct drmStatsTData {
490    value: c_ulong,
491    long_format: *const c_char,
492    long_name: *const c_char,
493    rate_format: *const c_char,
494    rate_name: *const c_char,
495    isvalue: c_int,
496    mult_names: *const c_char,
497    mult: c_int,
498    verbose: c_int
499}
500impl ::std::default::Default for drmStatsTData {
501    fn default() -> drmStatsTData { unsafe { ::std::mem::zeroed() } }
502}
503
504
505#[repr(C)]
506pub struct drmStatsT {
507    count: c_ulong,
508    data: *mut [drmStatsTData; 15]
509}
510impl ::std::default::Default for drmStatsT {
511    fn default() -> drmStatsT { unsafe { ::std::mem::zeroed() } }
512}
513
514
515pub type drm_handle_t = c_uint;
516
517pub type drmSize = c_uint;
518pub type drmSizePtr = *mut drmSize;
519pub type drmAddress = *mut c_void;
520pub type drmAddressPtr = *mut drmAddress;
521
522pub const DRM_NODE_PRIMARY : u8 = 0;
523pub const DRM_NODE_CONTROL : u8 = 1;
524pub const DRM_NODE_RENDER : u8 = 2;
525pub const DRM_NODE_MAX : u8 = 3;
526pub const DRM_EVENT_CONTEXT_VERSION: i32 = 2;
527pub const DRM_BUS_PCI : u8 = 0;
528
529#[link(name = "drm")]
530#[allow(dead_code)]
531extern {
532    fn drmIoctl(fc: c_int, request: c_ulong, arg: *mut c_void) -> c_int;
533    fn drmGetHashTable() -> *mut c_void;
534    fn drmGetEntry(fd: c_int) -> *mut drmHashEntry;
535    /* General user-level programmer's API: unprivileged */
536    pub fn drmAvailable() -> c_int;
537    pub fn drmOpen(name: *const c_char, busid: *const c_char) -> c_int;
538    pub fn drmOpenWithType(name: *const c_char, busid: *const c_char, open_type: c_int) -> c_int;
539    pub fn drmOpenControl(minor: c_int) -> c_int;
540    pub fn drmOpenRender(minor: c_int) -> c_int;
541    pub fn drmClose(fd: c_int) -> c_int;
542    pub fn drmGetVersion(fd: c_int) -> drmVersionPtr;
543    pub fn drmGetLibVersion(fd: c_int)-> drmVersionPtr;
544    pub fn drmGetCap(fd: c_int, capability: uint64_t, value: *mut uint64_t) -> c_int;
545    pub fn drmFreeVersion(ptr: drmVersionPtr) -> c_void;
546    pub fn drmGetMagic(fd: c_int, magic: *mut drm_magic_t) -> c_int;
547    pub fn drmGetBusid(fd: c_int) -> c_char;
548    pub fn drmGetInterruptFromBusID(fd: c_int, busnum: c_int, devnum: c_int, funcnum: c_int) -> c_int;
549    pub fn drmGetMap(fd: c_int, idx: c_int, offset: *mut drm_handle_t,
550        size: drmSizePtr, map_type: *mut drmMapType,
551        flags: *mut drmMapFlags, handle: *mut drm_handle_t,
552        mtrr: *mut c_int) -> c_int;
553    pub fn drmGetClient(fd: c_int, idx: c_int, auth: *mut c_int, pid: *mut c_int,
554	    uid: *mut c_int, magic: *mut c_ulong,
555	    iocs: *mut c_ulong) -> c_int;
556    pub fn drmGetStats(fd: c_int, stats: *mut drmStatsT) -> c_int;
557    pub fn drmSetInterfaceVersion(fd: c_int, version: drmSetVersionPtr) -> c_int;
558    pub fn drmCommandNone(fd: c_int, drmCommandIndex: c_long) -> c_int;
559    pub fn drmCommandRead(fd: c_int, drmCommandIndex: c_ulong,
560        data: *mut c_void, size: c_ulong) -> c_int;
561    pub fn drmCommandWrite(fd: c_int, drmCommandIndex: c_ulong,
562        data: *mut c_void, size: c_ulong) -> c_int;
563    pub fn drmCommandWriteRead(fd: c_int, drmCommandIndex: c_ulong,
564        data: *mut c_void, size: c_ulong) -> c_int;
565
566/* General user-level programmer's API: X server (root) only  */
567    pub fn drmFreeBusid(busid: *const c_char) -> c_void;
568    pub fn drmSetBusid(fd: c_int, busid: *const c_char) -> c_int;
569    pub fn drmAuthMagic(fd: c_int, magic: drm_magic_t) -> c_int;
570    pub fn drmAddMap(fd: c_int,
571        offset: drm_handle_t,
572        size: drmSize,
573        map_type: drmMapType,
574        flags: drmMapFlags,
575        handle: *mut drm_handle_t) -> c_int;
576    pub fn drmRmMap(fd: c_int, handle: drm_handle_t) -> c_int;
577    pub fn drmAddContextPrivateMapping(fd: c_int, ctx_id: drm_context_t,
578        handle: drm_handle_t) -> c_int;
579    pub fn drmAddBufs(fd: c_int, count: c_int, size: c_int, flags: drmBufDescFlags,
580		agp_offset: c_int) -> c_int;
581    pub fn drmMarkBufs(fd: c_int, low: c_double, high: c_double) -> c_int;
582    pub fn drmCreateContext(fd: c_int, handle: *mut drm_context_t) -> c_int;
583    pub fn drmSetContextFlags(fd: c_int, context: drm_context_t,
584		flags: drm_context_tFlags) -> c_int;
585    pub fn drmGetContextFlags(fd: c_int, context: drm_context_t,
586		flags: *mut drm_context_tFlags) -> c_int;
587    pub fn drmAddContextTag(fd: c_int, context: drm_context_t, tag: *mut c_void) -> c_int;
588    pub fn drmDelContextTag(fd: c_int, context: drm_context_t) -> c_int;
589    pub fn drmGetContextTag(fd: c_int, context: drm_context_t) -> *mut c_void;
590    pub fn drmGetReservedContextList(fd: c_int, count: *mut c_int) -> *mut drm_context_t;
591    pub fn drmFreeReservedContextList(context: *mut drm_context_t) -> c_void;
592    pub fn drmSwitchToContext(fd: c_int, context: drm_context_t) -> c_int;
593    pub fn drmDestroyContext(fd: c_int, handle: drm_context_t) -> c_int;
594    pub fn drmCreateDrawable(fd: c_int, handle: *mut drm_drawable_t) -> c_int;
595    pub fn drmDestroyDrawable(fd: c_int, handle: drm_drawable_t) -> c_int;
596    pub fn drmUpdateDrawableInfo(fd: c_int, handle: drm_drawable_t,
597		drawable_info_type: drm_drawable_info_type_t,
598		num: c_uint, data: *mut c_void) -> c_int;
599    pub fn drmCtlInstHandler(fd: c_int, irq: c_int) -> c_int;
600    pub fn drmCtlUninstHandler(fd: c_int) -> c_int;
601    pub fn drmSetClientCap(fd: c_int, capability: uint64_t, value: uint64_t) -> c_int;
602
603/* General user-level programmer's API: authenticated client and/or X */
604    pub fn drmMap(fd: c_int, handle: drm_handle_t, size: drmSize,
605		address: drmAddressPtr) -> c_int;
606    pub fn drmUnmap(address: drmAddress, size: drmSize) -> c_int;
607    pub fn drmGetBufInfo(fd: c_int) -> drmBufInfoPtr;
608    pub fn drmMapBufs(fd: c_int) -> drmBufMapPtr;
609    pub fn drmUnmapBufs(bufs: drmBufMapPtr) -> c_int;
610    pub fn drmDMA(fd: c_int, request: drmDMAReqPtr) -> c_int;
611    pub fn drmFreeBufs(fd: c_int, count: c_int, list: *mut c_int) -> c_int;
612    pub fn drmGetLock(fd: c_int, context: drm_context_t, flags: drmLockFlags) -> c_int;
613    pub fn drmUnlock(fd: c_int, context: drm_context_t) -> c_int;
614    pub fn drmFinish(fd: c_int, context: c_int, flags: drmLockFlags) -> c_int;
615    pub fn drmGetContextPrivateMapping(fd: c_int, ctx_id: drm_context_t,
616		handle: *mut drm_handle_t) -> c_int;
617
618/* AGP/GART support: X server (root) only */
619    pub fn drmAgpAcquire(fd: c_int) -> c_int;
620    pub fn drmAgpRelease(fd: c_int) -> c_int;
621    pub fn drmAgpEnable(fd: c_int, mode: c_ulong) -> c_int;
622    pub fn drmAgpAlloc(fd: c_int, size: c_ulong,
623        agp_alloc_type: c_ulong, address: *mut c_ulong,
624		handle: *mut drm_handle_t) -> c_int;
625    pub fn drmAgpFree(fd: c_int, handle: drm_handle_t) -> c_int;
626    pub fn drmAgpBind(fd: c_int, handle: drm_handle_t,
627        offset: c_ulong) -> c_int;
628    pub fn drmAgpUnbind(fd: c_int, handle: drm_handle_t) -> c_int;
629
630/* AGP/GART info: authenticated client and/or X */
631    pub fn drmAgpVersionMajor(fd: c_int) -> c_int;
632    pub fn drmAgpVersionMinor(fd: c_int) -> c_int;
633    pub fn drmAgpGetMode(fd: c_int) -> c_ulong;
634    pub fn drmAgpBase(fd: c_int) -> c_ulong; /* Physical location */
635    pub fn drmAgpSize(fd: c_int) -> c_ulong; /* Bytes */
636    pub fn drmAgpMemoryUsed(fd: c_int) -> c_ulong;
637    pub fn drmAgpMemoryAvail(fd: c_int) -> c_ulong;
638    pub fn drmAgpVendorId(fd: c_int) -> c_uint;
639    pub fn drmAgpDeviceId(fd: c_int) -> c_uint;
640
641/* PCI scatter/gather support: X server (root) only */
642    pub fn drmScatterGatherAlloc(fd: c_int, size: c_ulong,
643        handle: *mut drm_handle_t) -> c_int;
644    pub fn drmScatterGatherFree(fd: c_int, handle: drm_handle_t) -> c_int;
645    pub fn drmWaitVBlank(fd: c_int, vbl: *mut drmVBlank) -> c_int;
646
647/* Support routines */
648    pub fn drmSetServerInfo(info: drmServerInfoPtr) -> c_void;
649    pub fn drmError(err: c_int, label: *const c_char) -> c_int;
650    pub fn drmMalloc(size: c_int) -> *mut c_void;
651    pub fn drmFree(pt: *mut c_void) -> c_void;
652
653/* Hash table routines */
654    pub fn drmHashCreate() -> *mut c_void;
655    pub fn drmHashDestroy(t: *mut c_void) -> c_int;
656    pub fn drmHashLookup(t: *mut c_void, key: c_ulong, value: *mut *mut c_void) -> c_int;
657    pub fn drmHashInsert(t: *mut c_void, key: c_ulong, value: *mut c_void) -> c_int;
658    pub fn drmHashDelete(t: *mut c_void, key: c_ulong) -> c_int;
659    pub fn drmHashFirst(t: *mut c_void, key: c_ulong, value: *mut *mut c_void) -> c_int;
660    pub fn drmHashNext(t: *mut c_void, key: *mut c_ulong,
661        value: *mut *mut c_void) -> c_int;
662
663/* PRNG routines */
664    pub fn drmRandomCreate(seed: c_ulong) -> *mut c_void;
665    pub fn drmRandomDestroy(state: *mut c_void) -> c_int;
666    pub fn drmRandom(state: *mut c_void) -> c_ulong;
667    pub fn drmRandomDouble(state: *mut c_void) -> c_double;
668
669/* Skip list routines */
670
671    pub fn drmSLCreate() -> *mut c_void;
672    pub fn drmSLDestroy(l: *mut c_void) -> c_int;
673    pub fn drmSLLookup(l: *mut c_void, key: c_ulong, value: *mut *mut c_void) -> c_int;
674    pub fn drmSLInsert(l: *mut c_void, key: c_ulong, value: *mut c_void) -> c_int;
675    pub fn drmSLDelete(l: *mut c_void, key: c_ulong) -> c_int;
676    pub fn drmSLNext(l: *mut c_void, key: *mut c_ulong, value: *mut *mut c_void) -> c_int;
677    pub fn drmSLFirst(l: *mut c_void, key: *mut c_ulong, value: *mut *mut c_void) -> c_int;
678    pub fn drmSLDump(l: *mut c_void) -> c_void;
679    pub fn drmSLLookupNeighbors(l: *mut c_void, key: c_ulong,
680        prev_key: *mut c_ulong, prev_value: *mut *mut c_void,
681		next_key: *mut c_ulong, next_value: *mut *mut c_void) -> c_int;
682
683    pub fn drmOpenOnce(unused: *mut c_void, BusID: *const c_char,
684        newlyopened: *mut c_int) -> c_int;
685    pub fn drmOpenOnceWithType(BusID: *const c_char, newlyopened: *mut c_int,
686        open_type: c_int) -> c_int;
687    pub fn drmCloseOnce(fd: c_int) -> c_void;
688    pub fn drmMsg(format: *const c_char, ...) -> c_void;
689
690    pub fn drmSetMaster(fd: c_int) -> c_int;
691    pub fn drmDropMaster(fd: c_int) -> c_int;
692
693    pub fn drmHandleEvent(fd: c_int, evctx: drmEventContextPtr) -> c_int;
694
695    pub fn drmGetDeviceNameFromFd(fd: c_int) -> *mut c_char;
696    pub fn drmGetNodeTypeFromFd(fd: c_int) -> c_int;
697
698    pub fn drmPrimeHandleToFD(fd: c_int, handle: uint32_t, flags: uint32_t,
699        prime_fd: *mut c_int) -> c_int;
700    pub fn drmPrimeFDToHandle(fd: c_int, prime_fd: c_int, handle: *mut uint32_t) -> c_int;
701
702    pub fn drmGetPrimaryDeviceNameFromFd(fd: c_int) -> *mut c_char;
703    pub fn drmGetRenderDeviceNameFromFd(fd: c_int) -> *mut c_char;
704
705    pub fn drmGetDevice(fd: c_int, device: *mut drmDevicePtr) -> c_int;
706    pub fn drmFreeDevice(device: *mut drmDevicePtr) -> c_void;
707
708    pub fn drmGetDevices(devices: *const drmDevicePtr, max_devices: c_int) -> c_int;
709    pub fn drmFreeDevices(devices: *const drmDevicePtr, count: c_int) -> c_void;
710}