From 05dca540f955c5fdcac58533bd1db2f8a3069ff7 Mon Sep 17 00:00:00 2001 From: K Date: Mon, 19 Apr 2021 13:43:16 +0500 Subject: [PATCH 01/12] Apply cargo fmt --all --- .rustfmt.toml | 9 --- gbm-sys/build.rs | 29 +++---- gbm-sys/src/lib.rs | 6 +- src/buffer_object.rs | 183 ++++++++++++++++++++++++++++++++----------- src/device.rs | 68 +++++++--------- src/lib.rs | 4 +- src/surface.rs | 9 ++- 7 files changed, 190 insertions(+), 118 deletions(-) delete mode 100644 .rustfmt.toml diff --git a/.rustfmt.toml b/.rustfmt.toml deleted file mode 100644 index 339cbef..0000000 --- a/.rustfmt.toml +++ /dev/null @@ -1,9 +0,0 @@ -error_on_line_overflow = false -format_strings = false -reorder_imports = true -reorder_imported_names = true -report_todo = "Always" -report_fixme = "Always" -normalize_comments = true -use_try_shorthand = true -max_width = 110 diff --git a/gbm-sys/build.rs b/gbm-sys/build.rs index 395b328..77ab351 100644 --- a/gbm-sys/build.rs +++ b/gbm-sys/build.rs @@ -10,14 +10,11 @@ use std::path::Path; fn main() {} #[cfg(feature = "gen")] -fn main() -{ +fn main() { const TMP_BIND_PREFIX: &str = "__BINDGEN_TMP_"; const TMP_BIND_PREFIX_REG: &str = "_BINDGEN_TMP_.*"; - const INCLUDES: &'static [&str] = &[ - "gbm.h", - ]; + const INCLUDES: &'static [&str] = &["gbm.h"]; const MACROS: &'static [&str] = &[ "GBM_BO_IMPORT_WL_BUFFER", @@ -29,14 +26,12 @@ fn main() // Applies a formatting function over a slice of strings, // concatenating them on separate lines into a single String fn apply_formatting(iter: I, f: F) -> String - where + where I: Iterator, I::Item: AsRef, - F: Fn(&str) -> String + F: Fn(&str) -> String, { - iter.fold(String::new(), | acc, x | { - acc + &f(x.as_ref()) + "\n" - }) + iter.fold(String::new(), |acc, x| acc + &f(x.as_ref()) + "\n") } // Create a name for a temporary value @@ -68,18 +63,18 @@ fn main() // Required for some macros that won't get generated fn rebind_macro(name: &str) -> String { let tmp_name = tmp_val(name); - format!("{}\n{}\n{}\n{}", - decl_const("unsigned int", &tmp_name, name), - undefine_macro(name), - decl_const("unsigned int", name, &tmp_name), - define_macro(name, name) + format!( + "{}\n{}\n{}\n{}", + decl_const("unsigned int", &tmp_name, name), + undefine_macro(name), + decl_const("unsigned int", name, &tmp_name), + define_macro(name, name) ) } // Fully create the header fn create_header() -> String { - apply_formatting(INCLUDES.iter(), include) + - &apply_formatting(MACROS.iter(), rebind_macro) + apply_formatting(INCLUDES.iter(), include) + &apply_formatting(MACROS.iter(), rebind_macro) } // Setup bindings builder diff --git a/gbm-sys/src/lib.rs b/gbm-sys/src/lib.rs index ab4f65b..a497ab3 100644 --- a/gbm-sys/src/lib.rs +++ b/gbm-sys/src/lib.rs @@ -5,10 +5,8 @@ extern crate libc; #[cfg(feature = "gen")] include!(concat!(env!("OUT_DIR"), "/gen.rs")); -#[cfg(all(not(feature = "gen"), - target_os="linux", - target_arch="x86_64"))] +#[cfg(all(not(feature = "gen"), target_os = "linux", target_arch = "x86_64"))] include!(concat!("platforms/linux/x86_64/gen.rs")); #[link(name = "gbm")] -extern {} +extern "C" {} diff --git a/src/buffer_object.rs b/src/buffer_object.rs index 1448a43..283c548 100644 --- a/src/buffer_object.rs +++ b/src/buffer_object.rs @@ -1,7 +1,7 @@ use {AsRaw, Device, DeviceDestroyedError, Format, Modifier, Ptr, WeakPtr}; #[cfg(feature = "drm-support")] -use drm::buffer::{Buffer as DrmBuffer, PlanarBuffer as DrmPlanarBuffer, Handle}; +use drm::buffer::{Buffer as DrmBuffer, Handle, PlanarBuffer as DrmPlanarBuffer}; use std::error; use std::fmt; @@ -189,8 +189,10 @@ impl BufferObject { let device = self._device.upgrade(); if device.is_some() { use std::convert::TryFrom; - Ok(Format::try_from(unsafe { ::ffi::gbm_bo_get_format(*self.ffi) }) - .expect("libgbm returned invalid buffer format")) + Ok( + Format::try_from(unsafe { ::ffi::gbm_bo_get_format(*self.ffi) }) + .expect("libgbm returned invalid buffer format"), + ) } else { Err(DeviceDestroyedError) } @@ -230,7 +232,9 @@ impl BufferObject { pub fn modifier(&self) -> Result { let device = self._device.upgrade(); if device.is_some() { - Ok(Modifier::from(unsafe { ::ffi::gbm_bo_get_modifier(*self.ffi) })) + Ok(Modifier::from(unsafe { + ::ffi::gbm_bo_get_modifier(*self.ffi) + })) } else { Err(DeviceDestroyedError) } @@ -280,17 +284,27 @@ impl BufferObject { /// Map a region of a GBM buffer object for cpu access /// /// This function maps a region of a GBM bo for cpu read access. - pub fn map<'a, D, F, S>(&'a self, device: &Device, x: u32, y: u32, width: u32, height: u32, f: F) -> Result, WrongDeviceError> - where - D: AsRawFd + 'static, - F: FnOnce(&MappedBufferObject<'a, T>) -> S, + pub fn map<'a, D, F, S>( + &'a self, + device: &Device, + x: u32, + y: u32, + width: u32, + height: u32, + f: F, + ) -> Result, WrongDeviceError> + where + D: AsRawFd + 'static, + F: FnOnce(&MappedBufferObject<'a, T>) -> S, { let device_ref = self._device.upgrade(); if let Some(_device) = device_ref { - if *_device != device.as_raw_mut() { // not matching + if *_device != device.as_raw_mut() { + // not matching return Err(WrongDeviceError); } - } else { // not matching + } else { + // not matching return Err(WrongDeviceError); } @@ -313,10 +327,7 @@ impl BufferObject { } else { Ok(Ok(f(&MappedBufferObject { bo: BORef::Ref(self), - buffer: slice::from_raw_parts_mut( - ptr as *mut _, - (height * stride) as usize, - ), + buffer: slice::from_raw_parts_mut(ptr as *mut _, (height * stride) as usize), data, stride, height, @@ -340,16 +351,18 @@ impl BufferObject { height: u32, f: F, ) -> Result, WrongDeviceError> - where - D: AsRawFd + 'static, - F: FnOnce(&mut MappedBufferObject<'a, T>) -> S, + where + D: AsRawFd + 'static, + F: FnOnce(&mut MappedBufferObject<'a, T>) -> S, { let device_ref = self._device.upgrade(); if let Some(_device) = device_ref { - if *_device != device.as_raw_mut() { // not matching + if *_device != device.as_raw_mut() { + // not matching return Err(WrongDeviceError); } - } else { // not matching + } else { + // not matching return Err(WrongDeviceError); } @@ -372,10 +385,7 @@ impl BufferObject { } else { Ok(Ok(f(&mut MappedBufferObject { bo: BORef::Mut(self), - buffer: slice::from_raw_parts_mut( - ptr as *mut _, - (height * stride) as usize, - ), + buffer: slice::from_raw_parts_mut(ptr as *mut _, (height * stride) as usize), data, stride, height, @@ -397,7 +407,9 @@ impl BufferObject { pub fn write(&mut self, buffer: &[u8]) -> Result, DeviceDestroyedError> { let device = self._device.upgrade(); if device.is_some() { - let result = unsafe { ::ffi::gbm_bo_write(*self.ffi, buffer.as_ptr() as *const _, buffer.len() as u64) }; + let result = unsafe { + ::ffi::gbm_bo_write(*self.ffi, buffer.as_ptr() as *const _, buffer.len() as u64) + }; if result != 0 { Ok(Err(IoError::last_os_error())) } else { @@ -418,7 +430,11 @@ impl BufferObject { let boxed = Box::new(userdata); unsafe { - ::ffi::gbm_bo_set_user_data(*self.ffi, Box::into_raw(boxed) as *mut _, Some(destroy::)); + ::ffi::gbm_bo_set_user_data( + *self.ffi, + Box::into_raw(boxed) as *mut _, + Some(destroy::), + ); } old @@ -492,7 +508,10 @@ impl BufferObject { } } - pub(crate) unsafe fn new(ffi: *mut ::ffi::gbm_bo, device: WeakPtr<::ffi::gbm_device>) -> BufferObject { + pub(crate) unsafe fn new( + ffi: *mut ::ffi::gbm_bo, + device: WeakPtr<::ffi::gbm_device>, + ) -> BufferObject { BufferObject { ffi: Ptr::<::ffi::gbm_bo>::new(ffi, |ptr| ::ffi::gbm_bo_destroy(ptr)), _device: device, @@ -516,7 +535,10 @@ impl AsRaw<::ffi::gbm_bo> for BufferObject { #[cfg(feature = "drm-support")] impl DrmBuffer for BufferObject { fn size(&self) -> (u32, u32) { - (self.width().expect("GbmDevice does not exist anymore"), self.height().expect("GbmDevice does not exist anymore")) + ( + self.width().expect("GbmDevice does not exist anymore"), + self.height().expect("GbmDevice does not exist anymore"), + ) } fn format(&self) -> Format { @@ -529,45 +551,111 @@ impl DrmBuffer for BufferObject { fn handle(&self) -> Handle { use std::num::NonZeroU32; - unsafe { Handle::from(NonZeroU32::new_unchecked(self.handle().expect("GbmDevice does not exist anymore").u32_)) } + unsafe { + Handle::from(NonZeroU32::new_unchecked( + self.handle() + .expect("GbmDevice does not exist anymore") + .u32_, + )) + } } } #[cfg(feature = "drm-support")] impl DrmPlanarBuffer for BufferObject { fn size(&self) -> (u32, u32) { - (self.width().expect("GbmDevice does not exist anymore"), self.height().expect("GbmDevice does not exist anymore")) + ( + self.width().expect("GbmDevice does not exist anymore"), + self.height().expect("GbmDevice does not exist anymore"), + ) } fn format(&self) -> Format { BufferObject::::format(self).expect("GbmDevice does not exist anymore") } fn pitches(&self) -> [u32; 4] { - let num = self.plane_count().expect("GbmDevice does not exist anymore"); + let num = self + .plane_count() + .expect("GbmDevice does not exist anymore"); [ BufferObject::::stride_for_plane(self, 0).unwrap(), - if num > 1 { BufferObject::::stride_for_plane(self, 1).unwrap() } else { 0 }, - if num > 2 { BufferObject::::stride_for_plane(self, 2).unwrap() } else { 0 }, - if num > 3 { BufferObject::::stride_for_plane(self, 3).unwrap() } else { 0 }, + if num > 1 { + BufferObject::::stride_for_plane(self, 1).unwrap() + } else { + 0 + }, + if num > 2 { + BufferObject::::stride_for_plane(self, 2).unwrap() + } else { + 0 + }, + if num > 3 { + BufferObject::::stride_for_plane(self, 3).unwrap() + } else { + 0 + }, ] } fn handles(&self) -> [Option; 4] { use std::num::NonZeroU32; - let num = self.plane_count().expect("GbmDevice does not exist anymore"); + let num = self + .plane_count() + .expect("GbmDevice does not exist anymore"); [ - Some(unsafe { Handle::from(NonZeroU32::new_unchecked(BufferObject::::handle_for_plane(self, 0).unwrap().u32_)) }), - if num > 1 { Some(unsafe { Handle::from(NonZeroU32::new_unchecked(BufferObject::::handle_for_plane(self, 1).unwrap().u32_)) }) } else { None }, - if num > 2 { Some(unsafe { Handle::from(NonZeroU32::new_unchecked(BufferObject::::handle_for_plane(self, 2).unwrap().u32_)) }) } else { None }, - if num > 3 { Some(unsafe { Handle::from(NonZeroU32::new_unchecked(BufferObject::::handle_for_plane(self, 3).unwrap().u32_)) }) } else { None }, + Some(unsafe { + Handle::from(NonZeroU32::new_unchecked( + BufferObject::::handle_for_plane(self, 0).unwrap().u32_, + )) + }), + if num > 1 { + Some(unsafe { + Handle::from(NonZeroU32::new_unchecked( + BufferObject::::handle_for_plane(self, 1).unwrap().u32_, + )) + }) + } else { + None + }, + if num > 2 { + Some(unsafe { + Handle::from(NonZeroU32::new_unchecked( + BufferObject::::handle_for_plane(self, 2).unwrap().u32_, + )) + }) + } else { + None + }, + if num > 3 { + Some(unsafe { + Handle::from(NonZeroU32::new_unchecked( + BufferObject::::handle_for_plane(self, 3).unwrap().u32_, + )) + }) + } else { + None + }, ] - } fn offsets(&self) -> [u32; 4] { - let num = self.plane_count().expect("GbmDevice does not exist anymore"); + let num = self + .plane_count() + .expect("GbmDevice does not exist anymore"); [ BufferObject::::offset(self, 0).unwrap(), - if num > 1 { BufferObject::::offset(self, 1).unwrap() } else { 0 }, - if num > 2 { BufferObject::::offset(self, 2).unwrap() } else { 0 }, - if num > 3 { BufferObject::::offset(self, 3).unwrap() } else { 0 }, + if num > 1 { + BufferObject::::offset(self, 1).unwrap() + } else { + 0 + }, + if num > 2 { + BufferObject::::offset(self, 2).unwrap() + } else { + 0 + }, + if num > 3 { + BufferObject::::offset(self, 3).unwrap() + } else { + 0 + }, ] } } @@ -578,10 +666,15 @@ pub struct WrongDeviceError; impl fmt::Display for WrongDeviceError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "The gbm device specified is not the one this buffer object belongs to") + write!( + f, + "The gbm device specified is not the one this buffer object belongs to" + ) } } impl error::Error for WrongDeviceError { - fn cause(&self) -> Option<&dyn error::Error> { None } + fn cause(&self) -> Option<&dyn error::Error> { + None + } } diff --git a/src/device.rs b/src/device.rs index e08dc26..8355154 100644 --- a/src/device.rs +++ b/src/device.rs @@ -1,4 +1,4 @@ -use {AsRaw, BufferObject, BufferObjectFlags, Format, Modifier, Surface, Ptr}; +use {AsRaw, BufferObject, BufferObjectFlags, Format, Modifier, Ptr, Surface}; use libc::c_void; @@ -6,8 +6,8 @@ use std::error; use std::ffi::CStr; use std::fmt; use std::io::{Error as IoError, Result as IoResult}; -use std::os::unix::io::{AsRawFd, RawFd}; use std::ops::{Deref, DerefMut}; +use std::os::unix::io::{AsRawFd, RawFd}; #[cfg(feature = "import-wayland")] use wayland_server::protocol::wl_buffer::WlBuffer; @@ -16,10 +16,10 @@ use wayland_server::protocol::wl_buffer::WlBuffer; /// An EGLImage handle pub type EGLImage = *mut c_void; -#[cfg(feature = "drm-support")] -use drm::Device as DrmDevice; #[cfg(feature = "drm-support")] use drm::control::Device as DrmControlDevice; +#[cfg(feature = "drm-support")] +use drm::Device as DrmDevice; /// Type wrapping a foreign file destructor pub struct FdWrapper(RawFd); @@ -110,7 +110,9 @@ impl Device { } else { Ok(Device { fd, - ffi: Ptr::<::ffi::gbm_device>::new(ptr, |ptr| unsafe { ::ffi::gbm_device_destroy(ptr) }), + ffi: Ptr::<::ffi::gbm_device>::new(ptr, |ptr| unsafe { + ::ffi::gbm_device_destroy(ptr) + }), }) } } @@ -127,11 +129,7 @@ impl Device { /// Test if a format is supported for a given set of usage flags pub fn is_format_supported(&self, format: Format, usage: BufferObjectFlags) -> bool { unsafe { - ::ffi::gbm_device_is_format_supported( - *self.ffi, - format as u32, - usage.bits(), - ) != 0 + ::ffi::gbm_device_is_format_supported(*self.ffi, format as u32, usage.bits()) != 0 } } @@ -144,13 +142,7 @@ impl Device { usage: BufferObjectFlags, ) -> IoResult> { let ptr = unsafe { - ::ffi::gbm_surface_create( - *self.ffi, - width, - height, - format as u32, - usage.bits(), - ) + ::ffi::gbm_surface_create(*self.ffi, width, height, format as u32, usage.bits()) }; if ptr.is_null() { Err(IoError::last_os_error()) @@ -165,9 +157,12 @@ impl Device { width: u32, height: u32, format: Format, - modifiers: impl Iterator, + modifiers: impl Iterator, ) -> IoResult> { - let mods = modifiers.take(::ffi::GBM_MAX_PLANES as usize).map(|m| m.into()).collect::>(); + let mods = modifiers + .take(::ffi::GBM_MAX_PLANES as usize) + .map(|m| m.into()) + .collect::>(); let ptr = unsafe { ::ffi::gbm_surface_create_with_modifiers( *self.ffi, @@ -193,15 +188,8 @@ impl Device { format: Format, usage: BufferObjectFlags, ) -> IoResult> { - let ptr = unsafe { - ::ffi::gbm_bo_create( - *self.ffi, - width, - height, - format as u32, - usage.bits(), - ) - }; + let ptr = + unsafe { ::ffi::gbm_bo_create(*self.ffi, width, height, format as u32, usage.bits()) }; if ptr.is_null() { Err(IoError::last_os_error()) } else { @@ -215,9 +203,12 @@ impl Device { width: u32, height: u32, format: Format, - modifiers: impl Iterator, + modifiers: impl Iterator, ) -> IoResult> { - let mods = modifiers.take(::ffi::GBM_MAX_PLANES as usize).map(|m| m.into()).collect::>(); + let mods = modifiers + .take(::ffi::GBM_MAX_PLANES as usize) + .map(|m| m.into()) + .collect::>(); let ptr = unsafe { ::ffi::gbm_bo_create_with_modifiers( *self.ffi, @@ -283,13 +274,12 @@ impl Device { buffer: EGLImage, usage: BufferObjectFlags, ) -> IoResult> { - let ptr = - ::ffi::gbm_bo_import( - *self.ffi, - ::ffi::GBM_BO_IMPORT_EGL_IMAGE as u32, - buffer, - usage.bits(), - ); + let ptr = ::ffi::gbm_bo_import( + *self.ffi, + ::ffi::GBM_BO_IMPORT_EGL_IMAGE as u32, + buffer, + usage.bits(), + ); if ptr.is_null() { Err(IoError::last_os_error()) } else { @@ -401,5 +391,7 @@ impl fmt::Display for DeviceDestroyedError { } impl error::Error for DeviceDestroyedError { - fn cause(&self) -> Option<&dyn error::Error> { None } + fn cause(&self) -> Option<&dyn error::Error> { + None + } } diff --git a/src/lib.rs b/src/lib.rs index f3a2567..2444d2f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -99,14 +99,14 @@ extern crate drm_fourcc; #[macro_use] extern crate bitflags; -mod device; mod buffer_object; +mod device; mod surface; -pub use drm_fourcc::{DrmFourcc as Format, DrmModifier as Modifier}; pub use self::buffer_object::*; pub use self::device::*; pub use self::surface::*; +pub use drm_fourcc::{DrmFourcc as Format, DrmModifier as Modifier}; use std::sync::{Arc, Weak}; diff --git a/src/surface.rs b/src/surface.rs index d30a72d..3fb8284 100644 --- a/src/surface.rs +++ b/src/surface.rs @@ -1,7 +1,7 @@ -use {AsRaw, BufferObject, DeviceDestroyedError, Ptr, WeakPtr}; use std::error; use std::fmt; use std::marker::PhantomData; +use {AsRaw, BufferObject, DeviceDestroyedError, Ptr, WeakPtr}; /// A GBM rendering surface pub struct Surface { @@ -99,7 +99,10 @@ impl Surface { } } - pub(crate) unsafe fn new(ffi: *mut ::ffi::gbm_surface, device: WeakPtr<::ffi::gbm_device>) -> Surface { + pub(crate) unsafe fn new( + ffi: *mut ::ffi::gbm_surface, + device: WeakPtr<::ffi::gbm_device>, + ) -> Surface { Surface { ffi: Ptr::new(ffi, |ptr| ::ffi::gbm_surface_destroy(ptr)), _device: device, @@ -112,4 +115,4 @@ impl AsRaw<::ffi::gbm_surface> for Surface { fn as_raw(&self) -> *const ::ffi::gbm_surface { *self.ffi } -} \ No newline at end of file +} From 2611ef2c4a7f3e5ae9df01197764b055348d7744 Mon Sep 17 00:00:00 2001 From: K Date: Thu, 25 Mar 2021 09:58:16 +0500 Subject: [PATCH 02/12] Added CI workflow config --- .github/workflows/ci.yml | 307 +++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- 2 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..666384f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,307 @@ +name: Rust +on: + push: + branches: + - master + - develop # TODO: remove before merging to master + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + pull_request: + +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + components: rustfmt + default: true + override: true + - name: Cargo cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-rust_stable-${{ hashFiles('**/Cargo.toml') }} + - name: Format + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + doc: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + components: rust-docs + default: true + override: true + - name: Cargo cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-rust_nightly-${{ hashFiles('**/Cargo.toml') }} + - name: Documentation + uses: actions-rs/cargo@v1 + env: + DOCS_RS: 1 + with: + command: doc + + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - run: sudo apt-get install -y libdrm-dev + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + profile: minimal + components: clippy + default: true + override: true + - name: Cargo cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-rust_nightly-${{ hashFiles('**/Cargo.toml') }} + - name: Build cache + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-build-rust_nightly-check-${{ hashFiles('**/Cargo.toml') }} + - name: Clippy check + uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all --all-features --all-targets -- -D warnings -A clippy::redundant_static_lifetimes + + check-minimal: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - run: sudo apt-get install -y libdrm-dev + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + profile: minimal + default: true + override: true + - name: Cargo cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-rust_nightly-check-minimal-versions-${{ hashFiles('**/Cargo.toml') }} + - name: Build cache + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-build-rust_nightly-check-minimal-versions-${{ hashFiles('**/Cargo.toml') }} + - uses: actions-rs/cargo@v1 + with: + command: check + args: --all --all-features --all-targets -Z minimal-versions + + test: + needs: + - format + - doc + - check + strategy: + fail-fast: ${{ startsWith(github.ref, 'refs/tags/') }} + matrix: + include: + # Generate bindings + - task: bindings + os: ubuntu-latest + rust: stable + target: i686-unknown-linux-gnu + - task: bindings + os: ubuntu-latest + rust: stable + target: x86_64-unknown-linux-gnu + - task: bindings + os: ubuntu-latest + rust: stable + target: arm-unknown-linux-gnueabihf + - task: bindings + os: ubuntu-latest + rust: stable + target: armv7-unknown-linux-gnueabihf + - task: bindings + os: ubuntu-latest + rust: stable + target: aarch64-unknown-linux-gnu + # Test channels + - task: channels + os: ubuntu-latest + rust: stable + target: x86_64-unknown-linux-gnu + - task: channels + os: ubuntu-latest + rust: beta + target: x86_64-unknown-linux-gnu + - task: channels + os: ubuntu-latest + rust: nightly + target: x86_64-unknown-linux-gnu + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: Setup linux toolchain + if: contains(matrix.target, '-linux-') && startsWith(matrix.target, 'x86_64-') + run: | + sudo apt-get update -y + sudo apt-get install -y libdrm-dev libgbm-dev + - name: Setup cross linux toolchain + if: contains(matrix.target, '-linux-') && !startsWith(matrix.target, 'x86_64-') + run: | + case "${{ matrix.target }}" in + i686-*) SYSTEM_ARCH=i386 ;; + arm*) SYSTEM_ARCH=armhf ;; + aarch64*) SYSTEM_ARCH=arm64 ;; + esac + GCC_TARGET=$(printf "${{ matrix.target }}" | sed 's/-unknown-/-/' | sed 's/arm[^-]*/arm/g') + ENV_TARGET=$(printf "${{ matrix.target }}" | tr '-' '_') + ENV_TARGET_UC=$(printf "${ENV_TARGET}" | tr '[[:lower:]]' '[[:upper:]]') + sudo rm -f /etc/apt/sources.list.d/*.list + case "${{ matrix.target }}" in + arm* | aarch64*) + sudo tee /etc/apt/sources.list << EOF + deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ focal main universe + deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ focal-updates main universe + deb [arch=i386,amd64] http://security.ubuntu.com/ubuntu/ focal-security main universe + deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ focal main universe + deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main universe + deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-security main universe + EOF + ;; + esac + sudo dpkg --add-architecture ${SYSTEM_ARCH} + dpkg --print-foreign-architectures + sudo apt-get update -y + sudo apt-get upgrade -y --fix-broken + sudo apt-get install -y libdrm-dev:${SYSTEM_ARCH} libgbm-dev:${SYSTEM_ARCH} gcc-${GCC_TARGET} pkg-config-${GCC_TARGET} + echo "CARGO_TARGET_${ENV_TARGET_UC}_LINKER=${GCC_TARGET}-gcc" >> $GITHUB_ENV + echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV + echo "PKG_CONFIG_${ENV_TARGET}=${GCC_TARGET}-pkg-config" >> $GITHUB_ENV + echo "PKG_CONFIG=${GCC_TARGET}-pkg-config" >> $GITHUB_ENV + echo "BINDGEN_EXTRA_CLANG_ARGS=--sysroot=/usr/${GCC_TARGET}" >> $GITHUB_ENV + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + target: ${{ matrix.target }} + profile: minimal + components: rustfmt + default: true + override: true + - name: Cargo cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-rust_${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }} + - name: Build cache + if: | + runner.os != 'macOS' + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-build-rust_${{ matrix.rust }}-target_${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }} + - name: Update deps + uses: actions-rs/cargo@v1 + with: + command: update + - name: Build sys + uses: actions-rs/cargo@v1 + env: + RUST_LOG: bindgen=warn,bindgen::ir=error,bindgen::codegen=error + with: + command: build + args: --manifest-path gbm-sys/Cargo.toml --target ${{ matrix.target }} --features update_bindings + - name: Upload bindings + if: matrix.task == 'bindings' + uses: actions/upload-artifact@v2 + with: + name: bindings + path: | + gbm-sys/${{ env.GBM_SYS_BINDINGS_FILE }} + LICENSE + README.md + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --target ${{ matrix.target }} + - name: Test + if: contains(matrix.target, '-linux-') && (startsWith(matrix.target, 'x86_64-') || startsWith(matrix.target, 'i686-')) + uses: actions-rs/cargo@v1 + timeout-minutes: 12 + env: + RUST_BACKTRACE: full + with: + command: test + args: --all --target ${{ matrix.target }} + + update-bindings: + if: ${{ github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/tags/') }} + needs: + - test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Download bindings + uses: actions/download-artifact@v2 + with: + name: bindings + - name: Create pull request + uses: peter-evans/create-pull-request@v3 + with: + base: ${{ github.head_ref }} + commit-message: Updated bindings + branch: update-bindings + delete-branch: true + title: Update bindings + body: | + Bindings should be updated to be consistent with latest changes + + publish: + if: github.repository == 'Smithay/gbm.rs' && startsWith(github.ref, 'refs/tags/v') + needs: + - format + - doc + - check + - check-minimal + - test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Publish crates + uses: katyo/publish-crates@v1 + with: + registry-token: ${{ secrets.CRATES_TOKEN }} + args: --no-verify + #dry-run: true diff --git a/Cargo.toml b/Cargo.toml index 57a5f96..35e6e49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ version = "0.6.0" keywords = ["wayland", "gbm", "drm", "bindings"] categories = ["external-ffi-bindings"] authors = ["Victor Brekenfeld "] -exclude = [".travis.yml", ".rustfmt.toml"] +exclude = [".gitignore", ".travis.yml", ".rustfmt.toml", ".github"] [dependencies] gbm-sys = { version = "0.1", path = "./gbm-sys" } From 556a4e6395fcfa71de48fe57a283cabc8e218a1c Mon Sep 17 00:00:00 2001 From: K Date: Thu, 25 Mar 2021 16:25:09 +0500 Subject: [PATCH 03/12] Prebuilt bindings selection using build env --- gbm-sys/build.rs | 28 +++++++++++++++++++++++----- gbm-sys/src/lib.rs | 8 ++++++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/gbm-sys/build.rs b/gbm-sys/build.rs index 77ab351..0a564ab 100644 --- a/gbm-sys/build.rs +++ b/gbm-sys/build.rs @@ -1,13 +1,31 @@ #[cfg(feature = "gen")] extern crate bindgen; -#[cfg(feature = "gen")] -use std::env; -#[cfg(feature = "gen")] -use std::path::Path; +use std::{env, path::Path}; #[cfg(not(feature = "gen"))] -fn main() {} +fn main() { + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + + let bindings_file = Path::new("src") + .join("platforms") + .join(&target_os) + .join(&target_arch) + .join("gen.rs"); + + if bindings_file.is_file() { + println!( + "cargo:rustc-env=GBM_SYS_BINDINGS_PATH={}/{}", + target_os, target_arch + ); + } else { + panic!( + "No prebuilt bindings for target OS `{}` and/or architecture `{}`. Try `gen` feature.", + target_os, target_arch + ); + } +} #[cfg(feature = "gen")] fn main() { diff --git a/gbm-sys/src/lib.rs b/gbm-sys/src/lib.rs index a497ab3..7e201e8 100644 --- a/gbm-sys/src/lib.rs +++ b/gbm-sys/src/lib.rs @@ -5,8 +5,12 @@ extern crate libc; #[cfg(feature = "gen")] include!(concat!(env!("OUT_DIR"), "/gen.rs")); -#[cfg(all(not(feature = "gen"), target_os = "linux", target_arch = "x86_64"))] -include!(concat!("platforms/linux/x86_64/gen.rs")); +#[cfg(not(feature = "gen"))] +include!(concat!( + "platforms/", + env!("GBM_SYS_BINDINGS_PATH"), + "/gen.rs" +)); #[link(name = "gbm")] extern "C" {} From 978544a90fcbd4f321fd98d8be1110d5e9085d70 Mon Sep 17 00:00:00 2001 From: K Date: Mon, 19 Apr 2021 14:17:50 +0500 Subject: [PATCH 04/12] Added helper for updating pre-built bindings --- Cargo.toml | 5 +++++ gbm-sys/Cargo.toml | 1 + gbm-sys/build.rs | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 35e6e49..0432393 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,3 +27,8 @@ import-wayland = ["wayland-server"] import-egl = [] drm-support = ["drm"] gen = ["gbm-sys/gen"] + +[workspace] +members = [ + "gbm-sys" +] diff --git a/gbm-sys/Cargo.toml b/gbm-sys/Cargo.toml index 0b68934..720d9f0 100644 --- a/gbm-sys/Cargo.toml +++ b/gbm-sys/Cargo.toml @@ -21,3 +21,4 @@ libc = "0.2" [features] gen = ["bindgen"] +update_bindings = ["gen"] diff --git a/gbm-sys/build.rs b/gbm-sys/build.rs index 0a564ab..11dfb7a 100644 --- a/gbm-sys/build.rs +++ b/gbm-sys/build.rs @@ -114,4 +114,28 @@ fn main() { let dest_path = Path::new(&out_dir).join("gen.rs"); generated.write_to_file(dest_path).unwrap(); + + #[cfg(feature = "update_bindings")] + { + use std::{fs, io::Write}; + + let bind_file = Path::new(&out_dir).join("gen.rs"); + let dest_dir = Path::new("src") + .join("platforms") + .join(env::var("CARGO_CFG_TARGET_OS").unwrap()) + .join(env::var("CARGO_CFG_TARGET_ARCH").unwrap()); + let dest_file = dest_dir.join("gen.rs"); + + fs::create_dir_all(&dest_dir).unwrap(); + fs::copy(&bind_file, &dest_file).unwrap(); + + if let Ok(github_env) = env::var("GITHUB_ENV") { + let mut env_file = fs::OpenOptions::new() + .create(true) + .append(true) + .open(github_env) + .unwrap(); + writeln!(env_file, "GBM_SYS_BINDINGS_FILE={}", dest_file.display()).unwrap(); + } + } } From cc596b22324098bc09f45cbff35227ce6755a1c7 Mon Sep 17 00:00:00 2001 From: K Date: Tue, 20 Apr 2021 23:30:09 +0500 Subject: [PATCH 05/12] Fixed build.rs * Removed redundant 'static lifitimes * Added `include` to clang's include dirs --- gbm-sys/build.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gbm-sys/build.rs b/gbm-sys/build.rs index 11dfb7a..bd9c13e 100644 --- a/gbm-sys/build.rs +++ b/gbm-sys/build.rs @@ -32,9 +32,9 @@ fn main() { const TMP_BIND_PREFIX: &str = "__BINDGEN_TMP_"; const TMP_BIND_PREFIX_REG: &str = "_BINDGEN_TMP_.*"; - const INCLUDES: &'static [&str] = &["gbm.h"]; + const INCLUDES: &[&str] = &["gbm.h"]; - const MACROS: &'static [&str] = &[ + const MACROS: &[&str] = &[ "GBM_BO_IMPORT_WL_BUFFER", "GBM_BO_IMPORT_EGL_IMAGE", "GBM_BO_IMPORT_FD", @@ -97,6 +97,7 @@ fn main() { // Setup bindings builder let generated = bindgen::builder() + .clang_arg("-Iinclude") .header_contents("bindings.h", &create_header()) .blacklist_type(TMP_BIND_PREFIX_REG) .ctypes_prefix("libc") From 2643f920f0328f4d1a99b467e9c648ea8eea7ebb Mon Sep 17 00:00:00 2001 From: K Date: Tue, 20 Apr 2021 23:31:23 +0500 Subject: [PATCH 06/12] Applied clippy suggested fixes --- src/buffer_object.rs | 12 ++++++------ src/device.rs | 1 + src/surface.rs | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/buffer_object.rs b/src/buffer_object.rs index 283c548..5746202 100644 --- a/src/buffer_object.rs +++ b/src/buffer_object.rs @@ -111,8 +111,8 @@ impl<'a, T: 'static> Deref for MappedBufferObject<'a, T> { type Target = BufferObject; fn deref(&self) -> &BufferObject { match &self.bo { - &BORef::Ref(bo) => bo, - &BORef::Mut(ref bo) => bo, + BORef::Ref(bo) => bo, + BORef::Mut(bo) => bo, } } } @@ -120,8 +120,8 @@ impl<'a, T: 'static> Deref for MappedBufferObject<'a, T> { impl<'a, T: 'static> DerefMut for MappedBufferObject<'a, T> { fn deref_mut(&mut self) -> &mut BufferObject { match &mut self.bo { - &mut BORef::Ref(_) => unreachable!(), - &mut BORef::Mut(ref mut bo) => bo, + BORef::Ref(_) => unreachable!(), + BORef::Mut(bo) => bo, } } } @@ -129,8 +129,8 @@ impl<'a, T: 'static> DerefMut for MappedBufferObject<'a, T> { impl<'a, T: 'static> Drop for MappedBufferObject<'a, T> { fn drop(&mut self) { let ffi = match &self.bo { - &BORef::Ref(bo) => &bo.ffi, - &BORef::Mut(ref bo) => &bo.ffi, + BORef::Ref(bo) => &bo.ffi, + BORef::Mut(bo) => &bo.ffi, }; unsafe { ::ffi::gbm_bo_unmap(**ffi, self.data) } } diff --git a/src/device.rs b/src/device.rs index 8355154..834307a 100644 --- a/src/device.rs +++ b/src/device.rs @@ -335,6 +335,7 @@ impl Device { /// /// The GBM bo shares the underlying pixels but its life-time is /// independent of the foreign object. + #[allow(clippy::too_many_arguments)] pub fn import_buffer_object_from_dma_buf_with_modifiers( &self, len: u32, diff --git a/src/surface.rs b/src/surface.rs index 3fb8284..2849d1c 100644 --- a/src/surface.rs +++ b/src/surface.rs @@ -77,7 +77,7 @@ impl Surface { if ::ffi::gbm_surface_has_free_buffers(*self.ffi) != 0 { let buffer_ptr = ::ffi::gbm_surface_lock_front_buffer(*self.ffi); if !buffer_ptr.is_null() { - let surface_ptr = self.ffi.downgrade().clone(); + let surface_ptr = self.ffi.downgrade(); let buffer = BufferObject { ffi: Ptr::new(buffer_ptr, move |ptr| { if let Some(surface) = surface_ptr.upgrade() { From b6905606d3b01ebc779f9bb21750bfd26388686d Mon Sep 17 00:00:00 2001 From: K Date: Tue, 20 Apr 2021 23:48:42 +0500 Subject: [PATCH 07/12] Added workaround for bindgen tests checking --- gbm-sys/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gbm-sys/src/lib.rs b/gbm-sys/src/lib.rs index 7e201e8..b35256e 100644 --- a/gbm-sys/src/lib.rs +++ b/gbm-sys/src/lib.rs @@ -1,4 +1,8 @@ #![allow(non_camel_case_types, non_upper_case_globals)] +// Allowed this because some bindgen tests looks like +// it tries to dereference null pointers but actually +// it is not so. +#![cfg_attr(test, allow(deref_nullptr))] extern crate libc; From d33f0747ad084729282638e3e88607f657e18059 Mon Sep 17 00:00:00 2001 From: K Date: Wed, 21 Apr 2021 00:14:22 +0500 Subject: [PATCH 08/12] Fixed doc tests --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2444d2f..2b783ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,7 +53,7 @@ //! // create a 4x4 buffer //! let mut bo = gbm.create_buffer_object::<()>( //! 1280, 720, -//! Format::ARGB8888, +//! Format::Argb8888, //! BufferObjectFlags::SCANOUT | BufferObjectFlags::WRITE, //! ).unwrap(); //! @@ -70,7 +70,7 @@ //! bo.write(&buffer).unwrap(); //! //! // create a framebuffer from our buffer -//! let fb = gbm.add_framebuffer(&bo).unwrap(); +//! let fb = gbm.add_framebuffer(&bo, 32, 32).unwrap(); //! //! # let res_handles = gbm.resource_handles().unwrap(); //! # let con = *res_handles.connectors().iter().next().unwrap(); From 46ab0cd902c1e6c23e8200ea85378ba8206a25d2 Mon Sep 17 00:00:00 2001 From: K Date: Wed, 21 Apr 2021 08:53:50 +0500 Subject: [PATCH 09/12] Updated dependencies --- Cargo.toml | 23 ++++++++++++++++++----- gbm-sys/Cargo.toml | 5 +++-- gbm-sys/build.rs | 8 ++++---- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0432393..124acdf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,15 +11,28 @@ authors = ["Victor Brekenfeld "] exclude = [".gitignore", ".travis.yml", ".rustfmt.toml", ".github"] [dependencies] -gbm-sys = { version = "0.1", path = "./gbm-sys" } libc = "0.2" bitflags = "1.2" -wayland-server = { version = "0.28", optional = true } -drm = { version = "0.4.0-alpha1", git = "https://github.com/Drakulix/drm-rs", branch = "next", optional = true } drm-fourcc = "2.0" -[dev-dependencies] -drm = { version = "0.4.0-alpha1", git = "https://github.com/Drakulix/drm-rs", branch = "next" } +[dependencies.gbm-sys] +version = "0.1" +path = "./gbm-sys" + +[dependencies.drm] +#version = "0.4.0-alpha1" +git = "https://github.com/Smithay/drm-rs" +branch = "develop" +optional = true + +[dependencies.wayland-server] +version = "0.28.5" +optional = true + +[dev-dependencies.drm] +#version = "0.4.0-alpha1" +git = "https://github.com/Smithay/drm-rs" +branch = "develop" [features] default = ["import-wayland", "import-egl", "drm-support"] diff --git a/gbm-sys/Cargo.toml b/gbm-sys/Cargo.toml index 720d9f0..2330a19 100644 --- a/gbm-sys/Cargo.toml +++ b/gbm-sys/Cargo.toml @@ -13,8 +13,9 @@ license = "MIT" [lib] path = "src/lib.rs" -[build-dependencies] -bindgen = { version = "0.57", optional = true } +[build-dependencies.bindgen] +version = "0.58" +optional = true [dependencies] libc = "0.2" diff --git a/gbm-sys/build.rs b/gbm-sys/build.rs index bd9c13e..225e223 100644 --- a/gbm-sys/build.rs +++ b/gbm-sys/build.rs @@ -99,11 +99,11 @@ fn main() { let generated = bindgen::builder() .clang_arg("-Iinclude") .header_contents("bindings.h", &create_header()) - .blacklist_type(TMP_BIND_PREFIX_REG) + .blocklist_type(TMP_BIND_PREFIX_REG) .ctypes_prefix("libc") - .whitelist_type(r"^gbm_.*$") - .whitelist_function(r"^gbm_.*$") - .whitelist_var("GBM_.*|gbm_.*") + .allowlist_type(r"^gbm_.*$") + .allowlist_function(r"^gbm_.*$") + .allowlist_var("GBM_.*|gbm_.*") .constified_enum_module(r"^gbm_.*$") .generate() .unwrap(); From d27288fdd39fe49aad7b6c73c5c9a1af4228d336 Mon Sep 17 00:00:00 2001 From: K Date: Wed, 21 Apr 2021 09:00:40 +0500 Subject: [PATCH 10/12] Fixed 32-bit OS support --- src/buffer_object.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buffer_object.rs b/src/buffer_object.rs index 5746202..0969641 100644 --- a/src/buffer_object.rs +++ b/src/buffer_object.rs @@ -408,7 +408,7 @@ impl BufferObject { let device = self._device.upgrade(); if device.is_some() { let result = unsafe { - ::ffi::gbm_bo_write(*self.ffi, buffer.as_ptr() as *const _, buffer.len() as u64) + ::ffi::gbm_bo_write(*self.ffi, buffer.as_ptr() as *const _, buffer.len() as _) }; if result != 0 { Ok(Err(IoError::last_os_error())) From dc4d6a565c1ffafe82d78f19e240df5967e286e6 Mon Sep 17 00:00:00 2001 From: katyo Date: Wed, 21 Apr 2021 04:14:58 +0000 Subject: [PATCH 11/12] Updated bindings --- gbm-sys/src/platforms/linux/aarch64/gen.rs | 539 +++++++++++++++++++++ gbm-sys/src/platforms/linux/arm/gen.rs | 539 +++++++++++++++++++++ gbm-sys/src/platforms/linux/x86/gen.rs | 539 +++++++++++++++++++++ gbm-sys/src/platforms/linux/x86_64/gen.rs | 79 ++- 4 files changed, 1685 insertions(+), 11 deletions(-) create mode 100644 gbm-sys/src/platforms/linux/aarch64/gen.rs create mode 100644 gbm-sys/src/platforms/linux/arm/gen.rs create mode 100644 gbm-sys/src/platforms/linux/x86/gen.rs diff --git a/gbm-sys/src/platforms/linux/aarch64/gen.rs b/gbm-sys/src/platforms/linux/aarch64/gen.rs new file mode 100644 index 0000000..8bf5580 --- /dev/null +++ b/gbm-sys/src/platforms/linux/aarch64/gen.rs @@ -0,0 +1,539 @@ +/* automatically generated by rust-bindgen 0.58.1 */ + +pub const GBM_FORMAT_BIG_ENDIAN: u32 = 2147483648; +pub const GBM_BO_IMPORT_WL_BUFFER: u32 = 21761; +pub const GBM_BO_IMPORT_EGL_IMAGE: u32 = 21762; +pub const GBM_BO_IMPORT_FD: u32 = 21763; +pub const GBM_BO_IMPORT_FD_MODIFIER: u32 = 21764; +pub const GBM_MAX_PLANES: u32 = 4; +pub type size_t = libc::c_ulong; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __int64_t = libc::c_long; +pub type __uint64_t = libc::c_ulong; +#[doc = " \\file gbm.h"] +#[doc = " \\brief Generic Buffer Manager"] +#[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], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_surface { + _unused: [u8; 0], +} +#[doc = " Abstraction representing the handle to a buffer allocated by the"] +#[doc = " manager"] +#[repr(C)] +#[derive(Copy, Clone)] +pub union gbm_bo_handle { + pub ptr: *mut libc::c_void, + pub s32: i32, + pub u32_: u32, + pub s64: i64, + pub u64_: u64, +} +#[test] +fn bindgen_test_layout_gbm_bo_handle() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(gbm_bo_handle)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(gbm_bo_handle)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ptr as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(ptr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).s32 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(s32) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).u32_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(u32_) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).s64 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(s64) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).u64_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(u64_) + ) + ); +} +pub mod gbm_bo_format { + #[doc = " Format of the allocated buffer"] + pub type Type = libc::c_uint; + #[doc = " RGB with 8 bits per channel in a 32 bit value"] + pub const GBM_BO_FORMAT_XRGB8888: Type = 0; + #[doc = " ARGB with 8 bits per channel in a 32 bit value"] + pub const GBM_BO_FORMAT_ARGB8888: Type = 1; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_format_name_desc { + pub name: [libc::c_char; 5usize], +} +#[test] +fn bindgen_test_layout_gbm_format_name_desc() { + assert_eq!( + ::std::mem::size_of::(), + 5usize, + concat!("Size of: ", stringify!(gbm_format_name_desc)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(gbm_format_name_desc)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_format_name_desc), + "::", + stringify!(name) + ) + ); +} +pub mod gbm_bo_flags { + #[doc = " Flags to indicate the intended use for the buffer - these are passed into"] + #[doc = " gbm_bo_create(). The caller must set the union of all the flags that are"] + #[doc = " appropriate"] + #[doc = ""] + #[doc = " \\sa Use gbm_device_is_format_supported() to check if the combination of format"] + #[doc = " and use flags are supported"] + pub type Type = libc::c_uint; + #[doc = " Buffer is going to be presented to the screen using an API such as KMS"] + pub const GBM_BO_USE_SCANOUT: Type = 1; + #[doc = " Buffer is going to be used as cursor"] + pub const GBM_BO_USE_CURSOR: Type = 2; + #[doc = " Deprecated"] + pub const GBM_BO_USE_CURSOR_64X64: Type = 2; + #[doc = " Buffer is to be used for rendering - for example it is going to be used"] + #[doc = " as the storage for a color buffer"] + pub const GBM_BO_USE_RENDERING: Type = 4; + #[doc = " Buffer can be used for gbm_bo_write. This is guaranteed to work"] + #[doc = " with GBM_BO_USE_CURSOR, but may not work for other combinations."] + pub const GBM_BO_USE_WRITE: Type = 8; + #[doc = " Buffer is linear, i.e. not tiled."] + pub const GBM_BO_USE_LINEAR: Type = 16; + #[doc = " Buffer is protected, i.e. encrypted and not readable by CPU or any"] + #[doc = " other non-secure / non-trusted components nor by non-trusted OpenGL,"] + #[doc = " OpenCL, and Vulkan applications."] + pub const GBM_BO_USE_PROTECTED: Type = 32; +} +extern "C" { + pub fn gbm_device_get_fd(gbm: *mut gbm_device) -> libc::c_int; +} +extern "C" { + pub fn gbm_device_get_backend_name(gbm: *mut gbm_device) -> *const libc::c_char; +} +extern "C" { + pub fn gbm_device_is_format_supported( + gbm: *mut gbm_device, + format: u32, + usage: u32, + ) -> libc::c_int; +} +extern "C" { + pub fn gbm_device_get_format_modifier_plane_count( + gbm: *mut gbm_device, + format: u32, + modifier: u64, + ) -> libc::c_int; +} +extern "C" { + pub fn gbm_device_destroy(gbm: *mut gbm_device); +} +extern "C" { + pub fn gbm_create_device(fd: libc::c_int) -> *mut gbm_device; +} +extern "C" { + pub fn gbm_bo_create( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + flags: u32, + ) -> *mut gbm_bo; +} +extern "C" { + pub fn gbm_bo_create_with_modifiers( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + modifiers: *const u64, + count: libc::c_uint, + ) -> *mut gbm_bo; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_import_fd_data { + pub fd: libc::c_int, + pub width: u32, + pub height: u32, + pub stride: u32, + pub format: u32, +} +#[test] +fn bindgen_test_layout_gbm_import_fd_data() { + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(gbm_import_fd_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(gbm_import_fd_data)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(fd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).width as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).height as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(height) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).stride as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(stride) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).format as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(format) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_import_fd_modifier_data { + pub width: u32, + pub height: u32, + pub format: u32, + pub num_fds: u32, + pub fds: [libc::c_int; 4usize], + pub strides: [libc::c_int; 4usize], + pub offsets: [libc::c_int; 4usize], + pub modifier: u64, +} +#[test] +fn bindgen_test_layout_gbm_import_fd_modifier_data() { + assert_eq!( + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(gbm_import_fd_modifier_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(gbm_import_fd_modifier_data)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).width as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).height as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(height) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).format as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(format) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).num_fds as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(num_fds) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).fds as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(fds) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).strides as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(strides) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).offsets as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(offsets) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).modifier as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(modifier) + ) + ); +} +extern "C" { + pub fn gbm_bo_import( + gbm: *mut gbm_device, + type_: u32, + buffer: *mut libc::c_void, + usage: u32, + ) -> *mut gbm_bo; +} +pub mod gbm_bo_transfer_flags { + #[doc = " Flags to indicate the type of mapping for the buffer - these are"] + #[doc = " passed into gbm_bo_map(). The caller must set the union of all the"] + #[doc = " flags that are appropriate."] + #[doc = ""] + #[doc = " These flags are independent of the GBM_BO_USE_* creation flags. However,"] + #[doc = " mapping the buffer may require copying to/from a staging buffer."] + #[doc = ""] + #[doc = " See also: pipe_map_flags"] + pub type Type = libc::c_uint; + #[doc = " Buffer contents read back (or accessed directly) at transfer"] + #[doc = " create time."] + pub const GBM_BO_TRANSFER_READ: Type = 1; + #[doc = " Buffer contents will be written back at unmap time"] + #[doc = " (or modified as a result of being accessed directly)."] + pub const GBM_BO_TRANSFER_WRITE: Type = 2; + #[doc = " Read/modify/write"] + pub const GBM_BO_TRANSFER_READ_WRITE: Type = 3; +} +extern "C" { + pub fn gbm_bo_map( + bo: *mut gbm_bo, + x: u32, + y: u32, + width: u32, + height: u32, + flags: u32, + stride: *mut u32, + map_data: *mut *mut libc::c_void, + ) -> *mut libc::c_void; +} +extern "C" { + pub fn gbm_bo_unmap(bo: *mut gbm_bo, map_data: *mut libc::c_void); +} +extern "C" { + pub fn gbm_bo_get_width(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_height(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_stride(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_stride_for_plane(bo: *mut gbm_bo, plane: libc::c_int) -> u32; +} +extern "C" { + pub fn gbm_bo_get_format(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_bpp(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_offset(bo: *mut gbm_bo, plane: libc::c_int) -> u32; +} +extern "C" { + pub fn gbm_bo_get_device(bo: *mut gbm_bo) -> *mut gbm_device; +} +extern "C" { + pub fn gbm_bo_get_handle(bo: *mut gbm_bo) -> gbm_bo_handle; +} +extern "C" { + pub fn gbm_bo_get_fd(bo: *mut gbm_bo) -> libc::c_int; +} +extern "C" { + pub fn gbm_bo_get_modifier(bo: *mut gbm_bo) -> u64; +} +extern "C" { + pub fn gbm_bo_get_plane_count(bo: *mut gbm_bo) -> libc::c_int; +} +extern "C" { + pub fn gbm_bo_get_handle_for_plane(bo: *mut gbm_bo, plane: libc::c_int) -> gbm_bo_handle; +} +extern "C" { + pub fn gbm_bo_write(bo: *mut gbm_bo, buf: *const libc::c_void, count: size_t) -> libc::c_int; +} +extern "C" { + pub fn gbm_bo_set_user_data( + bo: *mut gbm_bo, + data: *mut libc::c_void, + destroy_user_data: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut gbm_bo, arg2: *mut libc::c_void), + >, + ); +} +extern "C" { + pub fn gbm_bo_get_user_data(bo: *mut gbm_bo) -> *mut libc::c_void; +} +extern "C" { + pub fn gbm_bo_destroy(bo: *mut gbm_bo); +} +extern "C" { + pub fn gbm_surface_create( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + flags: u32, + ) -> *mut gbm_surface; +} +extern "C" { + pub fn gbm_surface_create_with_modifiers( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + modifiers: *const u64, + count: libc::c_uint, + ) -> *mut gbm_surface; +} +extern "C" { + pub fn gbm_surface_lock_front_buffer(surface: *mut gbm_surface) -> *mut gbm_bo; +} +extern "C" { + pub fn gbm_surface_release_buffer(surface: *mut gbm_surface, bo: *mut gbm_bo); +} +extern "C" { + pub fn gbm_surface_has_free_buffers(surface: *mut gbm_surface) -> libc::c_int; +} +extern "C" { + pub fn gbm_surface_destroy(surface: *mut gbm_surface); +} +extern "C" { + pub fn gbm_format_get_name( + gbm_format: u32, + desc: *mut gbm_format_name_desc, + ) -> *mut libc::c_char; +} diff --git a/gbm-sys/src/platforms/linux/arm/gen.rs b/gbm-sys/src/platforms/linux/arm/gen.rs new file mode 100644 index 0000000..398f0a2 --- /dev/null +++ b/gbm-sys/src/platforms/linux/arm/gen.rs @@ -0,0 +1,539 @@ +/* automatically generated by rust-bindgen 0.58.1 */ + +pub const GBM_FORMAT_BIG_ENDIAN: u32 = 2147483648; +pub const GBM_BO_IMPORT_WL_BUFFER: u32 = 21761; +pub const GBM_BO_IMPORT_EGL_IMAGE: u32 = 21762; +pub const GBM_BO_IMPORT_FD: u32 = 21763; +pub const GBM_BO_IMPORT_FD_MODIFIER: u32 = 21764; +pub const GBM_MAX_PLANES: u32 = 4; +pub type size_t = libc::c_uint; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __int64_t = libc::c_longlong; +pub type __uint64_t = libc::c_ulonglong; +#[doc = " \\file gbm.h"] +#[doc = " \\brief Generic Buffer Manager"] +#[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], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_surface { + _unused: [u8; 0], +} +#[doc = " Abstraction representing the handle to a buffer allocated by the"] +#[doc = " manager"] +#[repr(C)] +#[derive(Copy, Clone)] +pub union gbm_bo_handle { + pub ptr: *mut libc::c_void, + pub s32: i32, + pub u32_: u32, + pub s64: i64, + pub u64_: u64, +} +#[test] +fn bindgen_test_layout_gbm_bo_handle() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(gbm_bo_handle)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(gbm_bo_handle)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ptr as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(ptr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).s32 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(s32) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).u32_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(u32_) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).s64 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(s64) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).u64_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(u64_) + ) + ); +} +pub mod gbm_bo_format { + #[doc = " Format of the allocated buffer"] + pub type Type = libc::c_uint; + #[doc = " RGB with 8 bits per channel in a 32 bit value"] + pub const GBM_BO_FORMAT_XRGB8888: Type = 0; + #[doc = " ARGB with 8 bits per channel in a 32 bit value"] + pub const GBM_BO_FORMAT_ARGB8888: Type = 1; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_format_name_desc { + pub name: [libc::c_char; 5usize], +} +#[test] +fn bindgen_test_layout_gbm_format_name_desc() { + assert_eq!( + ::std::mem::size_of::(), + 5usize, + concat!("Size of: ", stringify!(gbm_format_name_desc)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(gbm_format_name_desc)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_format_name_desc), + "::", + stringify!(name) + ) + ); +} +pub mod gbm_bo_flags { + #[doc = " Flags to indicate the intended use for the buffer - these are passed into"] + #[doc = " gbm_bo_create(). The caller must set the union of all the flags that are"] + #[doc = " appropriate"] + #[doc = ""] + #[doc = " \\sa Use gbm_device_is_format_supported() to check if the combination of format"] + #[doc = " and use flags are supported"] + pub type Type = libc::c_uint; + #[doc = " Buffer is going to be presented to the screen using an API such as KMS"] + pub const GBM_BO_USE_SCANOUT: Type = 1; + #[doc = " Buffer is going to be used as cursor"] + pub const GBM_BO_USE_CURSOR: Type = 2; + #[doc = " Deprecated"] + pub const GBM_BO_USE_CURSOR_64X64: Type = 2; + #[doc = " Buffer is to be used for rendering - for example it is going to be used"] + #[doc = " as the storage for a color buffer"] + pub const GBM_BO_USE_RENDERING: Type = 4; + #[doc = " Buffer can be used for gbm_bo_write. This is guaranteed to work"] + #[doc = " with GBM_BO_USE_CURSOR, but may not work for other combinations."] + pub const GBM_BO_USE_WRITE: Type = 8; + #[doc = " Buffer is linear, i.e. not tiled."] + pub const GBM_BO_USE_LINEAR: Type = 16; + #[doc = " Buffer is protected, i.e. encrypted and not readable by CPU or any"] + #[doc = " other non-secure / non-trusted components nor by non-trusted OpenGL,"] + #[doc = " OpenCL, and Vulkan applications."] + pub const GBM_BO_USE_PROTECTED: Type = 32; +} +extern "C" { + pub fn gbm_device_get_fd(gbm: *mut gbm_device) -> libc::c_int; +} +extern "C" { + pub fn gbm_device_get_backend_name(gbm: *mut gbm_device) -> *const libc::c_char; +} +extern "C" { + pub fn gbm_device_is_format_supported( + gbm: *mut gbm_device, + format: u32, + usage: u32, + ) -> libc::c_int; +} +extern "C" { + pub fn gbm_device_get_format_modifier_plane_count( + gbm: *mut gbm_device, + format: u32, + modifier: u64, + ) -> libc::c_int; +} +extern "C" { + pub fn gbm_device_destroy(gbm: *mut gbm_device); +} +extern "C" { + pub fn gbm_create_device(fd: libc::c_int) -> *mut gbm_device; +} +extern "C" { + pub fn gbm_bo_create( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + flags: u32, + ) -> *mut gbm_bo; +} +extern "C" { + pub fn gbm_bo_create_with_modifiers( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + modifiers: *const u64, + count: libc::c_uint, + ) -> *mut gbm_bo; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_import_fd_data { + pub fd: libc::c_int, + pub width: u32, + pub height: u32, + pub stride: u32, + pub format: u32, +} +#[test] +fn bindgen_test_layout_gbm_import_fd_data() { + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(gbm_import_fd_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(gbm_import_fd_data)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(fd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).width as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).height as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(height) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).stride as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(stride) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).format as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(format) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_import_fd_modifier_data { + pub width: u32, + pub height: u32, + pub format: u32, + pub num_fds: u32, + pub fds: [libc::c_int; 4usize], + pub strides: [libc::c_int; 4usize], + pub offsets: [libc::c_int; 4usize], + pub modifier: u64, +} +#[test] +fn bindgen_test_layout_gbm_import_fd_modifier_data() { + assert_eq!( + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(gbm_import_fd_modifier_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(gbm_import_fd_modifier_data)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).width as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).height as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(height) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).format as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(format) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).num_fds as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(num_fds) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).fds as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(fds) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).strides as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(strides) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).offsets as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(offsets) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).modifier as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(modifier) + ) + ); +} +extern "C" { + pub fn gbm_bo_import( + gbm: *mut gbm_device, + type_: u32, + buffer: *mut libc::c_void, + usage: u32, + ) -> *mut gbm_bo; +} +pub mod gbm_bo_transfer_flags { + #[doc = " Flags to indicate the type of mapping for the buffer - these are"] + #[doc = " passed into gbm_bo_map(). The caller must set the union of all the"] + #[doc = " flags that are appropriate."] + #[doc = ""] + #[doc = " These flags are independent of the GBM_BO_USE_* creation flags. However,"] + #[doc = " mapping the buffer may require copying to/from a staging buffer."] + #[doc = ""] + #[doc = " See also: pipe_map_flags"] + pub type Type = libc::c_uint; + #[doc = " Buffer contents read back (or accessed directly) at transfer"] + #[doc = " create time."] + pub const GBM_BO_TRANSFER_READ: Type = 1; + #[doc = " Buffer contents will be written back at unmap time"] + #[doc = " (or modified as a result of being accessed directly)."] + pub const GBM_BO_TRANSFER_WRITE: Type = 2; + #[doc = " Read/modify/write"] + pub const GBM_BO_TRANSFER_READ_WRITE: Type = 3; +} +extern "C" { + pub fn gbm_bo_map( + bo: *mut gbm_bo, + x: u32, + y: u32, + width: u32, + height: u32, + flags: u32, + stride: *mut u32, + map_data: *mut *mut libc::c_void, + ) -> *mut libc::c_void; +} +extern "C" { + pub fn gbm_bo_unmap(bo: *mut gbm_bo, map_data: *mut libc::c_void); +} +extern "C" { + pub fn gbm_bo_get_width(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_height(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_stride(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_stride_for_plane(bo: *mut gbm_bo, plane: libc::c_int) -> u32; +} +extern "C" { + pub fn gbm_bo_get_format(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_bpp(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_offset(bo: *mut gbm_bo, plane: libc::c_int) -> u32; +} +extern "C" { + pub fn gbm_bo_get_device(bo: *mut gbm_bo) -> *mut gbm_device; +} +extern "C" { + pub fn gbm_bo_get_handle(bo: *mut gbm_bo) -> gbm_bo_handle; +} +extern "C" { + pub fn gbm_bo_get_fd(bo: *mut gbm_bo) -> libc::c_int; +} +extern "C" { + pub fn gbm_bo_get_modifier(bo: *mut gbm_bo) -> u64; +} +extern "C" { + pub fn gbm_bo_get_plane_count(bo: *mut gbm_bo) -> libc::c_int; +} +extern "C" { + pub fn gbm_bo_get_handle_for_plane(bo: *mut gbm_bo, plane: libc::c_int) -> gbm_bo_handle; +} +extern "C" { + pub fn gbm_bo_write(bo: *mut gbm_bo, buf: *const libc::c_void, count: size_t) -> libc::c_int; +} +extern "C" { + pub fn gbm_bo_set_user_data( + bo: *mut gbm_bo, + data: *mut libc::c_void, + destroy_user_data: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut gbm_bo, arg2: *mut libc::c_void), + >, + ); +} +extern "C" { + pub fn gbm_bo_get_user_data(bo: *mut gbm_bo) -> *mut libc::c_void; +} +extern "C" { + pub fn gbm_bo_destroy(bo: *mut gbm_bo); +} +extern "C" { + pub fn gbm_surface_create( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + flags: u32, + ) -> *mut gbm_surface; +} +extern "C" { + pub fn gbm_surface_create_with_modifiers( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + modifiers: *const u64, + count: libc::c_uint, + ) -> *mut gbm_surface; +} +extern "C" { + pub fn gbm_surface_lock_front_buffer(surface: *mut gbm_surface) -> *mut gbm_bo; +} +extern "C" { + pub fn gbm_surface_release_buffer(surface: *mut gbm_surface, bo: *mut gbm_bo); +} +extern "C" { + pub fn gbm_surface_has_free_buffers(surface: *mut gbm_surface) -> libc::c_int; +} +extern "C" { + pub fn gbm_surface_destroy(surface: *mut gbm_surface); +} +extern "C" { + pub fn gbm_format_get_name( + gbm_format: u32, + desc: *mut gbm_format_name_desc, + ) -> *mut libc::c_char; +} diff --git a/gbm-sys/src/platforms/linux/x86/gen.rs b/gbm-sys/src/platforms/linux/x86/gen.rs new file mode 100644 index 0000000..9d4e72a --- /dev/null +++ b/gbm-sys/src/platforms/linux/x86/gen.rs @@ -0,0 +1,539 @@ +/* automatically generated by rust-bindgen 0.58.1 */ + +pub const GBM_FORMAT_BIG_ENDIAN: u32 = 2147483648; +pub const GBM_BO_IMPORT_WL_BUFFER: u32 = 21761; +pub const GBM_BO_IMPORT_EGL_IMAGE: u32 = 21762; +pub const GBM_BO_IMPORT_FD: u32 = 21763; +pub const GBM_BO_IMPORT_FD_MODIFIER: u32 = 21764; +pub const GBM_MAX_PLANES: u32 = 4; +pub type size_t = libc::c_uint; +pub type __int32_t = libc::c_int; +pub type __uint32_t = libc::c_uint; +pub type __int64_t = libc::c_longlong; +pub type __uint64_t = libc::c_ulonglong; +#[doc = " \\file gbm.h"] +#[doc = " \\brief Generic Buffer Manager"] +#[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], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_surface { + _unused: [u8; 0], +} +#[doc = " Abstraction representing the handle to a buffer allocated by the"] +#[doc = " manager"] +#[repr(C)] +#[derive(Copy, Clone)] +pub union gbm_bo_handle { + pub ptr: *mut libc::c_void, + pub s32: i32, + pub u32_: u32, + pub s64: i64, + pub u64_: u64, +} +#[test] +fn bindgen_test_layout_gbm_bo_handle() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(gbm_bo_handle)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(gbm_bo_handle)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).ptr as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(ptr) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).s32 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(s32) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).u32_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(u32_) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).s64 as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(s64) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).u64_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_bo_handle), + "::", + stringify!(u64_) + ) + ); +} +pub mod gbm_bo_format { + #[doc = " Format of the allocated buffer"] + pub type Type = libc::c_uint; + #[doc = " RGB with 8 bits per channel in a 32 bit value"] + pub const GBM_BO_FORMAT_XRGB8888: Type = 0; + #[doc = " ARGB with 8 bits per channel in a 32 bit value"] + pub const GBM_BO_FORMAT_ARGB8888: Type = 1; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_format_name_desc { + pub name: [libc::c_char; 5usize], +} +#[test] +fn bindgen_test_layout_gbm_format_name_desc() { + assert_eq!( + ::std::mem::size_of::(), + 5usize, + concat!("Size of: ", stringify!(gbm_format_name_desc)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(gbm_format_name_desc)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_format_name_desc), + "::", + stringify!(name) + ) + ); +} +pub mod gbm_bo_flags { + #[doc = " Flags to indicate the intended use for the buffer - these are passed into"] + #[doc = " gbm_bo_create(). The caller must set the union of all the flags that are"] + #[doc = " appropriate"] + #[doc = ""] + #[doc = " \\sa Use gbm_device_is_format_supported() to check if the combination of format"] + #[doc = " and use flags are supported"] + pub type Type = libc::c_uint; + #[doc = " Buffer is going to be presented to the screen using an API such as KMS"] + pub const GBM_BO_USE_SCANOUT: Type = 1; + #[doc = " Buffer is going to be used as cursor"] + pub const GBM_BO_USE_CURSOR: Type = 2; + #[doc = " Deprecated"] + pub const GBM_BO_USE_CURSOR_64X64: Type = 2; + #[doc = " Buffer is to be used for rendering - for example it is going to be used"] + #[doc = " as the storage for a color buffer"] + pub const GBM_BO_USE_RENDERING: Type = 4; + #[doc = " Buffer can be used for gbm_bo_write. This is guaranteed to work"] + #[doc = " with GBM_BO_USE_CURSOR, but may not work for other combinations."] + pub const GBM_BO_USE_WRITE: Type = 8; + #[doc = " Buffer is linear, i.e. not tiled."] + pub const GBM_BO_USE_LINEAR: Type = 16; + #[doc = " Buffer is protected, i.e. encrypted and not readable by CPU or any"] + #[doc = " other non-secure / non-trusted components nor by non-trusted OpenGL,"] + #[doc = " OpenCL, and Vulkan applications."] + pub const GBM_BO_USE_PROTECTED: Type = 32; +} +extern "C" { + pub fn gbm_device_get_fd(gbm: *mut gbm_device) -> libc::c_int; +} +extern "C" { + pub fn gbm_device_get_backend_name(gbm: *mut gbm_device) -> *const libc::c_char; +} +extern "C" { + pub fn gbm_device_is_format_supported( + gbm: *mut gbm_device, + format: u32, + usage: u32, + ) -> libc::c_int; +} +extern "C" { + pub fn gbm_device_get_format_modifier_plane_count( + gbm: *mut gbm_device, + format: u32, + modifier: u64, + ) -> libc::c_int; +} +extern "C" { + pub fn gbm_device_destroy(gbm: *mut gbm_device); +} +extern "C" { + pub fn gbm_create_device(fd: libc::c_int) -> *mut gbm_device; +} +extern "C" { + pub fn gbm_bo_create( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + flags: u32, + ) -> *mut gbm_bo; +} +extern "C" { + pub fn gbm_bo_create_with_modifiers( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + modifiers: *const u64, + count: libc::c_uint, + ) -> *mut gbm_bo; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_import_fd_data { + pub fd: libc::c_int, + pub width: u32, + pub height: u32, + pub stride: u32, + pub format: u32, +} +#[test] +fn bindgen_test_layout_gbm_import_fd_data() { + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(gbm_import_fd_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(gbm_import_fd_data)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(fd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).width as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).height as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(height) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).stride as *const _ as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(stride) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).format as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_data), + "::", + stringify!(format) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct gbm_import_fd_modifier_data { + pub width: u32, + pub height: u32, + pub format: u32, + pub num_fds: u32, + pub fds: [libc::c_int; 4usize], + pub strides: [libc::c_int; 4usize], + pub offsets: [libc::c_int; 4usize], + pub modifier: u64, +} +#[test] +fn bindgen_test_layout_gbm_import_fd_modifier_data() { + assert_eq!( + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(gbm_import_fd_modifier_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(gbm_import_fd_modifier_data)) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).width as *const _ as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(width) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).height as *const _ as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(height) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).format as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(format) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).num_fds as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(num_fds) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).fds as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(fds) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).strides as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(strides) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).offsets as *const _ as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(offsets) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).modifier as *const _ as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(gbm_import_fd_modifier_data), + "::", + stringify!(modifier) + ) + ); +} +extern "C" { + pub fn gbm_bo_import( + gbm: *mut gbm_device, + type_: u32, + buffer: *mut libc::c_void, + usage: u32, + ) -> *mut gbm_bo; +} +pub mod gbm_bo_transfer_flags { + #[doc = " Flags to indicate the type of mapping for the buffer - these are"] + #[doc = " passed into gbm_bo_map(). The caller must set the union of all the"] + #[doc = " flags that are appropriate."] + #[doc = ""] + #[doc = " These flags are independent of the GBM_BO_USE_* creation flags. However,"] + #[doc = " mapping the buffer may require copying to/from a staging buffer."] + #[doc = ""] + #[doc = " See also: pipe_map_flags"] + pub type Type = libc::c_uint; + #[doc = " Buffer contents read back (or accessed directly) at transfer"] + #[doc = " create time."] + pub const GBM_BO_TRANSFER_READ: Type = 1; + #[doc = " Buffer contents will be written back at unmap time"] + #[doc = " (or modified as a result of being accessed directly)."] + pub const GBM_BO_TRANSFER_WRITE: Type = 2; + #[doc = " Read/modify/write"] + pub const GBM_BO_TRANSFER_READ_WRITE: Type = 3; +} +extern "C" { + pub fn gbm_bo_map( + bo: *mut gbm_bo, + x: u32, + y: u32, + width: u32, + height: u32, + flags: u32, + stride: *mut u32, + map_data: *mut *mut libc::c_void, + ) -> *mut libc::c_void; +} +extern "C" { + pub fn gbm_bo_unmap(bo: *mut gbm_bo, map_data: *mut libc::c_void); +} +extern "C" { + pub fn gbm_bo_get_width(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_height(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_stride(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_stride_for_plane(bo: *mut gbm_bo, plane: libc::c_int) -> u32; +} +extern "C" { + pub fn gbm_bo_get_format(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_bpp(bo: *mut gbm_bo) -> u32; +} +extern "C" { + pub fn gbm_bo_get_offset(bo: *mut gbm_bo, plane: libc::c_int) -> u32; +} +extern "C" { + pub fn gbm_bo_get_device(bo: *mut gbm_bo) -> *mut gbm_device; +} +extern "C" { + pub fn gbm_bo_get_handle(bo: *mut gbm_bo) -> gbm_bo_handle; +} +extern "C" { + pub fn gbm_bo_get_fd(bo: *mut gbm_bo) -> libc::c_int; +} +extern "C" { + pub fn gbm_bo_get_modifier(bo: *mut gbm_bo) -> u64; +} +extern "C" { + pub fn gbm_bo_get_plane_count(bo: *mut gbm_bo) -> libc::c_int; +} +extern "C" { + pub fn gbm_bo_get_handle_for_plane(bo: *mut gbm_bo, plane: libc::c_int) -> gbm_bo_handle; +} +extern "C" { + pub fn gbm_bo_write(bo: *mut gbm_bo, buf: *const libc::c_void, count: size_t) -> libc::c_int; +} +extern "C" { + pub fn gbm_bo_set_user_data( + bo: *mut gbm_bo, + data: *mut libc::c_void, + destroy_user_data: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut gbm_bo, arg2: *mut libc::c_void), + >, + ); +} +extern "C" { + pub fn gbm_bo_get_user_data(bo: *mut gbm_bo) -> *mut libc::c_void; +} +extern "C" { + pub fn gbm_bo_destroy(bo: *mut gbm_bo); +} +extern "C" { + pub fn gbm_surface_create( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + flags: u32, + ) -> *mut gbm_surface; +} +extern "C" { + pub fn gbm_surface_create_with_modifiers( + gbm: *mut gbm_device, + width: u32, + height: u32, + format: u32, + modifiers: *const u64, + count: libc::c_uint, + ) -> *mut gbm_surface; +} +extern "C" { + pub fn gbm_surface_lock_front_buffer(surface: *mut gbm_surface) -> *mut gbm_bo; +} +extern "C" { + pub fn gbm_surface_release_buffer(surface: *mut gbm_surface, bo: *mut gbm_bo); +} +extern "C" { + pub fn gbm_surface_has_free_buffers(surface: *mut gbm_surface) -> libc::c_int; +} +extern "C" { + pub fn gbm_surface_destroy(surface: *mut gbm_surface); +} +extern "C" { + pub fn gbm_format_get_name( + gbm_format: u32, + desc: *mut gbm_format_name_desc, + ) -> *mut libc::c_char; +} diff --git a/gbm-sys/src/platforms/linux/x86_64/gen.rs b/gbm-sys/src/platforms/linux/x86_64/gen.rs index 236313a..8bf5580 100644 --- a/gbm-sys/src/platforms/linux/x86_64/gen.rs +++ b/gbm-sys/src/platforms/linux/x86_64/gen.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.57.0 */ +/* automatically generated by rust-bindgen 0.58.1 */ pub const GBM_FORMAT_BIG_ENDIAN: u32 = 2147483648; pub const GBM_BO_IMPORT_WL_BUFFER: u32 = 21761; @@ -11,6 +11,8 @@ pub type __int32_t = libc::c_int; pub type __uint32_t = libc::c_uint; pub type __int64_t = libc::c_long; pub type __uint64_t = libc::c_ulong; +#[doc = " \\file gbm.h"] +#[doc = " \\brief Generic Buffer Manager"] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct gbm_device { @@ -26,6 +28,8 @@ pub struct gbm_bo { pub struct gbm_surface { _unused: [u8; 0], } +#[doc = " Abstraction representing the handle to a buffer allocated by the"] +#[doc = " manager"] #[repr(C)] #[derive(Copy, Clone)] pub union gbm_bo_handle { @@ -34,7 +38,6 @@ pub union gbm_bo_handle { pub u32_: u32, pub s64: i64, pub u64_: u64, - _bindgen_union_align: u64, } #[test] fn bindgen_test_layout_gbm_bo_handle() { @@ -100,8 +103,11 @@ fn bindgen_test_layout_gbm_bo_handle() { ); } pub mod gbm_bo_format { + #[doc = " Format of the allocated buffer"] pub type Type = libc::c_uint; + #[doc = " RGB with 8 bits per channel in a 32 bit value"] pub const GBM_BO_FORMAT_XRGB8888: Type = 0; + #[doc = " ARGB with 8 bits per channel in a 32 bit value"] pub const GBM_BO_FORMAT_ARGB8888: Type = 1; } #[repr(C)] @@ -133,13 +139,30 @@ fn bindgen_test_layout_gbm_format_name_desc() { ); } pub mod gbm_bo_flags { + #[doc = " Flags to indicate the intended use for the buffer - these are passed into"] + #[doc = " gbm_bo_create(). The caller must set the union of all the flags that are"] + #[doc = " appropriate"] + #[doc = ""] + #[doc = " \\sa Use gbm_device_is_format_supported() to check if the combination of format"] + #[doc = " and use flags are supported"] pub type Type = libc::c_uint; + #[doc = " Buffer is going to be presented to the screen using an API such as KMS"] pub const GBM_BO_USE_SCANOUT: Type = 1; + #[doc = " Buffer is going to be used as cursor"] pub const GBM_BO_USE_CURSOR: Type = 2; + #[doc = " Deprecated"] pub const GBM_BO_USE_CURSOR_64X64: Type = 2; + #[doc = " Buffer is to be used for rendering - for example it is going to be used"] + #[doc = " as the storage for a color buffer"] pub const GBM_BO_USE_RENDERING: Type = 4; + #[doc = " Buffer can be used for gbm_bo_write. This is guaranteed to work"] + #[doc = " with GBM_BO_USE_CURSOR, but may not work for other combinations."] pub const GBM_BO_USE_WRITE: Type = 8; + #[doc = " Buffer is linear, i.e. not tiled."] pub const GBM_BO_USE_LINEAR: Type = 16; + #[doc = " Buffer is protected, i.e. encrypted and not readable by CPU or any"] + #[doc = " other non-secure / non-trusted components nor by non-trusted OpenGL,"] + #[doc = " OpenCL, and Vulkan applications."] pub const GBM_BO_USE_PROTECTED: Type = 32; } extern "C" { @@ -149,7 +172,11 @@ extern "C" { pub fn gbm_device_get_backend_name(gbm: *mut gbm_device) -> *const libc::c_char; } extern "C" { - pub fn gbm_device_is_format_supported(gbm: *mut gbm_device, format: u32, usage: u32) -> libc::c_int; + pub fn gbm_device_is_format_supported( + gbm: *mut gbm_device, + format: u32, + usage: u32, + ) -> libc::c_int; } extern "C" { pub fn gbm_device_get_format_modifier_plane_count( @@ -280,7 +307,9 @@ fn bindgen_test_layout_gbm_import_fd_modifier_data() { concat!("Alignment of ", stringify!(gbm_import_fd_modifier_data)) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).width as *const _ as usize }, + unsafe { + &(*(::std::ptr::null::())).width as *const _ as usize + }, 0usize, concat!( "Offset of field: ", @@ -290,7 +319,9 @@ fn bindgen_test_layout_gbm_import_fd_modifier_data() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).height as *const _ as usize }, + unsafe { + &(*(::std::ptr::null::())).height as *const _ as usize + }, 4usize, concat!( "Offset of field: ", @@ -300,7 +331,9 @@ fn bindgen_test_layout_gbm_import_fd_modifier_data() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).format as *const _ as usize }, + unsafe { + &(*(::std::ptr::null::())).format as *const _ as usize + }, 8usize, concat!( "Offset of field: ", @@ -310,7 +343,9 @@ fn bindgen_test_layout_gbm_import_fd_modifier_data() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).num_fds as *const _ as usize }, + unsafe { + &(*(::std::ptr::null::())).num_fds as *const _ as usize + }, 12usize, concat!( "Offset of field: ", @@ -330,7 +365,9 @@ fn bindgen_test_layout_gbm_import_fd_modifier_data() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).strides as *const _ as usize }, + unsafe { + &(*(::std::ptr::null::())).strides as *const _ as usize + }, 32usize, concat!( "Offset of field: ", @@ -340,7 +377,9 @@ fn bindgen_test_layout_gbm_import_fd_modifier_data() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).offsets as *const _ as usize }, + unsafe { + &(*(::std::ptr::null::())).offsets as *const _ as usize + }, 48usize, concat!( "Offset of field: ", @@ -350,7 +389,9 @@ fn bindgen_test_layout_gbm_import_fd_modifier_data() { ) ); assert_eq!( - unsafe { &(*(::std::ptr::null::())).modifier as *const _ as usize }, + unsafe { + &(*(::std::ptr::null::())).modifier as *const _ as usize + }, 64usize, concat!( "Offset of field: ", @@ -369,9 +410,22 @@ extern "C" { ) -> *mut gbm_bo; } pub mod gbm_bo_transfer_flags { + #[doc = " Flags to indicate the type of mapping for the buffer - these are"] + #[doc = " passed into gbm_bo_map(). The caller must set the union of all the"] + #[doc = " flags that are appropriate."] + #[doc = ""] + #[doc = " These flags are independent of the GBM_BO_USE_* creation flags. However,"] + #[doc = " mapping the buffer may require copying to/from a staging buffer."] + #[doc = ""] + #[doc = " See also: pipe_map_flags"] pub type Type = libc::c_uint; + #[doc = " Buffer contents read back (or accessed directly) at transfer"] + #[doc = " create time."] pub const GBM_BO_TRANSFER_READ: Type = 1; + #[doc = " Buffer contents will be written back at unmap time"] + #[doc = " (or modified as a result of being accessed directly)."] pub const GBM_BO_TRANSFER_WRITE: Type = 2; + #[doc = " Read/modify/write"] pub const GBM_BO_TRANSFER_READ_WRITE: Type = 3; } extern "C" { @@ -478,5 +532,8 @@ extern "C" { pub fn gbm_surface_destroy(surface: *mut gbm_surface); } extern "C" { - pub fn gbm_format_get_name(gbm_format: u32, desc: *mut gbm_format_name_desc) -> *mut libc::c_char; + pub fn gbm_format_get_name( + gbm_format: u32, + desc: *mut gbm_format_name_desc, + ) -> *mut libc::c_char; } From fe682b49279e09945f03a2924727c72552c49658 Mon Sep 17 00:00:00 2001 From: K Date: Sun, 2 May 2021 21:54:26 +0500 Subject: [PATCH 12/12] Removed Travis-CI config --- .travis.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e826ffd..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: rust -addons: - apt: - sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'libgbm-dev', 'gcc-5' ] - -rust: - - stable - - beta - - nightly - -matrix: - allow_failures: - - rust: nightly - -cache: - directories: - - $HOME/.cargo - -before_install: -- wget http://llvm.org/releases/3.9.0/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz -- tar xf clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz - -script: -- cargo build -- env LIBCLANG_PATH=`pwd`/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-14.04/lib CLANG_PATH=`pwd`/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang cargo build --features gen -- diff -q gbm-sys/src/platforms/linux/x86_64/gen.rs $(find target -name gen.rs)