/* automatically generated by rust-bindgen 0.72.1 */

pub const GBM_BO_IMPORT_FD: u32 = 21763;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct gbm_device {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct gbm_bo {
    _unused: [u8; 0],
}
pub const gbm_bo_flags_GBM_BO_USE_SCANOUT: gbm_bo_flags = 1;
pub const gbm_bo_flags_GBM_BO_USE_CURSOR: gbm_bo_flags = 2;
pub const gbm_bo_flags_GBM_BO_USE_CURSOR_64X64: gbm_bo_flags = 2;
pub const gbm_bo_flags_GBM_BO_USE_RENDERING: gbm_bo_flags = 4;
pub const gbm_bo_flags_GBM_BO_USE_WRITE: gbm_bo_flags = 8;
pub const gbm_bo_flags_GBM_BO_USE_LINEAR: gbm_bo_flags = 16;
pub const gbm_bo_flags_GBM_BO_USE_PROTECTED: gbm_bo_flags = 32;
pub const gbm_bo_flags_GBM_BO_USE_FRONT_RENDERING: gbm_bo_flags = 64;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_DEFAULT: gbm_bo_flags = 128;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_1BPC: gbm_bo_flags = 256;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_2BPC: gbm_bo_flags = 384;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_3BPC: gbm_bo_flags = 512;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_4BPC: gbm_bo_flags = 640;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_5BPC: gbm_bo_flags = 768;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_6BPC: gbm_bo_flags = 896;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_7BPC: gbm_bo_flags = 1024;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_8BPC: gbm_bo_flags = 1152;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_9BPC: gbm_bo_flags = 1280;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_10BPC: gbm_bo_flags = 1408;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_11BPC: gbm_bo_flags = 1536;
pub const gbm_bo_flags_GBM_BO_FIXED_COMPRESSION_12BPC: gbm_bo_flags = 1664;
pub type gbm_bo_flags = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct gbm_import_fd_data {
    pub fd: ::std::os::raw::c_int,
    pub width: u32,
    pub height: u32,
    pub stride: u32,
    pub format: u32,
}
#[test]
fn bindgen_test_layout_gbm_import_fd_data() {
    const UNINIT: ::std::mem::MaybeUninit<gbm_import_fd_data> = ::std::mem::MaybeUninit::uninit();
    let ptr = UNINIT.as_ptr();
    assert_eq!(
        ::std::mem::size_of::<gbm_import_fd_data>(),
        20usize,
        "Size of gbm_import_fd_data"
    );
    assert_eq!(
        ::std::mem::align_of::<gbm_import_fd_data>(),
        4usize,
        "Alignment of gbm_import_fd_data"
    );
    assert_eq!(
        unsafe { ::std::ptr::addr_of!((*ptr).fd) as usize - ptr as usize },
        0usize,
        "Offset of field: gbm_import_fd_data::fd"
    );
    assert_eq!(
        unsafe { ::std::ptr::addr_of!((*ptr).width) as usize - ptr as usize },
        4usize,
        "Offset of field: gbm_import_fd_data::width"
    );
    assert_eq!(
        unsafe { ::std::ptr::addr_of!((*ptr).height) as usize - ptr as usize },
        8usize,
        "Offset of field: gbm_import_fd_data::height"
    );
    assert_eq!(
        unsafe { ::std::ptr::addr_of!((*ptr).stride) as usize - ptr as usize },
        12usize,
        "Offset of field: gbm_import_fd_data::stride"
    );
    assert_eq!(
        unsafe { ::std::ptr::addr_of!((*ptr).format) as usize - ptr as usize },
        16usize,
        "Offset of field: gbm_import_fd_data::format"
    );
}
pub const gbm_bo_transfer_flags_GBM_BO_TRANSFER_READ: gbm_bo_transfer_flags = 1;
pub const gbm_bo_transfer_flags_GBM_BO_TRANSFER_WRITE: gbm_bo_transfer_flags = 2;
pub const gbm_bo_transfer_flags_GBM_BO_TRANSFER_READ_WRITE: gbm_bo_transfer_flags = 3;
pub type gbm_bo_transfer_flags = ::std::os::raw::c_uint;
pub struct gbm {
    __library: ::libloading::Library,
    pub gbm_device_get_backend_name:
        unsafe extern "C" fn(gbm: *mut gbm_device) -> *const ::std::os::raw::c_char,
    pub gbm_device_is_format_supported: unsafe extern "C" fn(
        gbm: *mut gbm_device,
        format: u32,
        flags: u32,
    ) -> ::std::os::raw::c_int,
    pub gbm_device_destroy: unsafe extern "C" fn(gbm: *mut gbm_device),
    pub gbm_create_device: unsafe extern "C" fn(fd: ::std::os::raw::c_int) -> *mut gbm_device,
    pub gbm_bo_create: unsafe extern "C" fn(
        gbm: *mut gbm_device,
        width: u32,
        height: u32,
        format: u32,
        flags: u32,
    ) -> *mut gbm_bo,
    pub gbm_bo_import: unsafe extern "C" fn(
        gbm: *mut gbm_device,
        type_: u32,
        buffer: *mut ::std::os::raw::c_void,
        flags: u32,
    ) -> *mut gbm_bo,
    pub gbm_bo_map: unsafe extern "C" fn(
        bo: *mut gbm_bo,
        x: u32,
        y: u32,
        width: u32,
        height: u32,
        flags: u32,
        stride: *mut u32,
        map_data: *mut *mut ::std::os::raw::c_void,
    ) -> *mut ::std::os::raw::c_void,
    pub gbm_bo_unmap: unsafe extern "C" fn(bo: *mut gbm_bo, map_data: *mut ::std::os::raw::c_void),
    pub gbm_bo_get_stride: unsafe extern "C" fn(bo: *mut gbm_bo) -> u32,
    pub gbm_bo_get_fd: unsafe extern "C" fn(bo: *mut gbm_bo) -> ::std::os::raw::c_int,
    pub gbm_bo_get_modifier: unsafe extern "C" fn(bo: *mut gbm_bo) -> u64,
    pub gbm_bo_destroy: unsafe extern "C" fn(bo: *mut gbm_bo),
}
impl gbm {
    pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
    where
        P: AsRef<::std::ffi::OsStr>,
    {
        let library = ::libloading::Library::new(path)?;
        Self::from_library(library)
    }
    pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
    where
        L: Into<::libloading::Library>,
    {
        let __library = library.into();
        let gbm_device_get_backend_name = __library
            .get(b"gbm_device_get_backend_name\0")
            .map(|sym| *sym)?;
        let gbm_device_is_format_supported = __library
            .get(b"gbm_device_is_format_supported\0")
            .map(|sym| *sym)?;
        let gbm_device_destroy = __library.get(b"gbm_device_destroy\0").map(|sym| *sym)?;
        let gbm_create_device = __library.get(b"gbm_create_device\0").map(|sym| *sym)?;
        let gbm_bo_create = __library.get(b"gbm_bo_create\0").map(|sym| *sym)?;
        let gbm_bo_import = __library.get(b"gbm_bo_import\0").map(|sym| *sym)?;
        let gbm_bo_map = __library.get(b"gbm_bo_map\0").map(|sym| *sym)?;
        let gbm_bo_unmap = __library.get(b"gbm_bo_unmap\0").map(|sym| *sym)?;
        let gbm_bo_get_stride = __library.get(b"gbm_bo_get_stride\0").map(|sym| *sym)?;
        let gbm_bo_get_fd = __library.get(b"gbm_bo_get_fd\0").map(|sym| *sym)?;
        let gbm_bo_get_modifier = __library.get(b"gbm_bo_get_modifier\0").map(|sym| *sym)?;
        let gbm_bo_destroy = __library.get(b"gbm_bo_destroy\0").map(|sym| *sym)?;
        Ok(gbm {
            __library,
            gbm_device_get_backend_name,
            gbm_device_is_format_supported,
            gbm_device_destroy,
            gbm_create_device,
            gbm_bo_create,
            gbm_bo_import,
            gbm_bo_map,
            gbm_bo_unmap,
            gbm_bo_get_stride,
            gbm_bo_get_fd,
            gbm_bo_get_modifier,
            gbm_bo_destroy,
        })
    }
    pub unsafe fn gbm_device_get_backend_name(
        &self,
        gbm: *mut gbm_device,
    ) -> *const ::std::os::raw::c_char {
        (self.gbm_device_get_backend_name)(gbm)
    }
    pub unsafe fn gbm_device_is_format_supported(
        &self,
        gbm: *mut gbm_device,
        format: u32,
        flags: u32,
    ) -> ::std::os::raw::c_int {
        (self.gbm_device_is_format_supported)(gbm, format, flags)
    }
    pub unsafe fn gbm_device_destroy(&self, gbm: *mut gbm_device) {
        (self.gbm_device_destroy)(gbm)
    }
    pub unsafe fn gbm_create_device(&self, fd: ::std::os::raw::c_int) -> *mut gbm_device {
        (self.gbm_create_device)(fd)
    }
    pub unsafe fn gbm_bo_create(
        &self,
        gbm: *mut gbm_device,
        width: u32,
        height: u32,
        format: u32,
        flags: u32,
    ) -> *mut gbm_bo {
        (self.gbm_bo_create)(gbm, width, height, format, flags)
    }
    pub unsafe fn gbm_bo_import(
        &self,
        gbm: *mut gbm_device,
        type_: u32,
        buffer: *mut ::std::os::raw::c_void,
        flags: u32,
    ) -> *mut gbm_bo {
        (self.gbm_bo_import)(gbm, type_, buffer, flags)
    }
    pub unsafe fn gbm_bo_map(
        &self,
        bo: *mut gbm_bo,
        x: u32,
        y: u32,
        width: u32,
        height: u32,
        flags: u32,
        stride: *mut u32,
        map_data: *mut *mut ::std::os::raw::c_void,
    ) -> *mut ::std::os::raw::c_void {
        (self.gbm_bo_map)(bo, x, y, width, height, flags, stride, map_data)
    }
    pub unsafe fn gbm_bo_unmap(&self, bo: *mut gbm_bo, map_data: *mut ::std::os::raw::c_void) {
        (self.gbm_bo_unmap)(bo, map_data)
    }
    pub unsafe fn gbm_bo_get_stride(&self, bo: *mut gbm_bo) -> u32 {
        (self.gbm_bo_get_stride)(bo)
    }
    pub unsafe fn gbm_bo_get_fd(&self, bo: *mut gbm_bo) -> ::std::os::raw::c_int {
        (self.gbm_bo_get_fd)(bo)
    }
    pub unsafe fn gbm_bo_get_modifier(&self, bo: *mut gbm_bo) -> u64 {
        (self.gbm_bo_get_modifier)(bo)
    }
    pub unsafe fn gbm_bo_destroy(&self, bo: *mut gbm_bo) {
        (self.gbm_bo_destroy)(bo)
    }
}
