diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..34be9779 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,304 @@ +name: Rust +on: + push: + branches: + - master + - develop + 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') }} + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all --all-features + + 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-${{ hashFiles('**/Cargo.toml') }} + - name: Build cache + uses: actions/cache@v2 + with: + path: target + key: ${{ runner.os }}-build-rust_nightly-check-minimal-${{ hashFiles('**/Cargo.toml') }} + - uses: actions-rs/cargo@v1 + with: + command: check + args: --all --all-features -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 + - 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} 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 + 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 drm-ffi/drm-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: | + drm-ffi/drm-sys/${{ env.DRM_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/drm-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 9bca8176..bf424c50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ repository = "https://github.com/Smithay/drm-rs" version = "0.0.0" license = "MIT" authors = ["Tyler Slabinski "] +exclude = [".gitignore", ".github"] [dependencies] drm-ffi = { path = "drm-ffi" } diff --git a/drm-ffi/drm-sys/Cargo.toml b/drm-ffi/drm-sys/Cargo.toml index 2aaaa1cf..bdad4d18 100644 --- a/drm-ffi/drm-sys/Cargo.toml +++ b/drm-ffi/drm-sys/Cargo.toml @@ -12,6 +12,7 @@ libc = { version = "^0.2.29", default-features = false } [features] default = [] use_bindgen = ["bindgen", "pkg-config"] +update_bindings = ["use_bindgen"] [build-dependencies] bindgen = { version = "^0.57.0", optional = true } diff --git a/drm-ffi/drm-sys/build.rs b/drm-ffi/drm-sys/build.rs index 4aebd1bf..8fa4356e 100644 --- a/drm-ffi/drm-sys/build.rs +++ b/drm-ffi/drm-sys/build.rs @@ -16,9 +16,11 @@ mod use_bindgen { let config = CodegenConfig::all(); Builder::default() - .clang_args(lib.include_paths.into_iter().map(| path | { - "-I".to_string() + &path.into_os_string().into_string().unwrap() - })) + .clang_args( + lib.include_paths + .into_iter() + .map(|path| "-I".to_string() + &path.into_os_string().into_string().unwrap()), + ) .header_contents("bindings.h", contents) .ctypes_prefix("libc") .with_codegen_config(config) @@ -38,27 +40,19 @@ mod use_bindgen { const TMP_BIND_PREFIX: &str = "__BINDGEN_TMP_"; const TMP_BIND_PREFIX_REG: &str = "_BINDGEN_TMP_.*"; - const INCLUDES: &'static [&str] = &[ - "drm.h", - "drm_mode.h" - ]; + const INCLUDES: &'static [&str] = &["drm.h", "drm_mode.h"]; - const MACROS: &'static [&str] = &[ - "DRM_MODE_PROP_SIGNED_RANGE", - "DRM_MODE_PROP_OBJECT" - ]; + const MACROS: &'static [&str] = &["DRM_MODE_PROP_SIGNED_RANGE", "DRM_MODE_PROP_OBJECT"]; // 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 @@ -90,21 +84,20 @@ mod use_bindgen { // 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) } - pub fn generate_bindings() { let bindings = create_builder(&create_header()) .blacklist_type(TMP_BIND_PREFIX_REG) @@ -128,14 +121,67 @@ mod use_bindgen { let out_path = String::from(var("OUT_DIR").unwrap()); let bind_file = PathBuf::from(out_path).join("bindings.rs"); - bindings.write_to_file(bind_file).expect("Could not write bindings"); + bindings + .write_to_file(bind_file) + .expect("Could not write bindings"); + } + + #[cfg(feature = "update_bindings")] + pub fn update_bindings() { + use std::{fs, io::Write}; + + let out_path = String::from(var("OUT_DIR").unwrap()); + let bind_file = PathBuf::from(out_path).join("bindings.rs"); + let dest_dir = PathBuf::from("src") + .join("platforms") + .join(var("CARGO_CFG_TARGET_OS").unwrap()) + .join(var("CARGO_CFG_TARGET_ARCH").unwrap()); + let dest_file = dest_dir.join("bindings.rs"); + + fs::create_dir_all(&dest_dir).unwrap(); + fs::copy(&bind_file, &dest_file).unwrap(); + + if let Ok(github_env) = var("GITHUB_ENV") { + let mut env_file = fs::OpenOptions::new() + .create(true) + .append(true) + .open(github_env) + .unwrap(); + writeln!(env_file, "DRM_SYS_BINDINGS_FILE={}", dest_file.display()).unwrap(); + } } } #[cfg(feature = "use_bindgen")] pub fn main() { use_bindgen::generate_bindings(); + + #[cfg(feature = "update_bindings")] + use_bindgen::update_bindings(); } #[cfg(not(feature = "use_bindgen"))] -pub fn main() {} +pub fn main() { + use std::{env::var, path::Path}; + + let target_os = var("CARGO_CFG_TARGET_OS").unwrap(); + let target_arch = var("CARGO_CFG_TARGET_ARCH").unwrap(); + + let bindings_file = Path::new("src") + .join("platforms") + .join(&target_os) + .join(&target_arch) + .join("bindings.rs"); + + if bindings_file.is_file() { + println!( + "cargo:rustc-env=DRM_SYS_BINDINGS_PATH={}/{}", + target_os, target_arch + ); + } else { + panic!( + "No prebuilt bindings for target OS `{}` and/or architecture `{}`. Try `use_bindgen` feature.", + target_os, target_arch + ); + } +} diff --git a/drm-ffi/drm-sys/src/lib.rs b/drm-ffi/drm-sys/src/lib.rs index 4c60042d..f5551045 100644 --- a/drm-ffi/drm-sys/src/lib.rs +++ b/drm-ffi/drm-sys/src/lib.rs @@ -8,21 +8,13 @@ extern crate libc; #[cfg(feature = "use_bindgen")] include!(concat!(env!("OUT_DIR"), "/bindings.rs")); -#[cfg(all(not(feature = "use_bindgen"), - target_os="linux", - target_arch="x86_64"))] -include!(concat!("platforms/linux/x86_64/bindings.rs")); - -#[cfg(all(not(feature = "use_bindgen"), - target_os="linux", - target_arch="aarch64"))] -include!(concat!("platforms/linux/aarch64//bindings.rs")); - -#[cfg(all(not(feature = "use_bindgen"), - target_os="freebsd", - target_arch="x86_64"))] -include!(concat!("platforms/freebsd/x86_64/bindings.rs")); +#[cfg(not(feature = "use_bindgen"))] +include!(concat!( + "platforms/", + env!("DRM_SYS_BINDINGS_PATH"), + "/bindings.rs" +)); pub const DRM_PLANE_TYPE_OVERLAY: u32 = 0; pub const DRM_PLANE_TYPE_PRIMARY: u32 = 1; -pub const DRM_PLANE_TYPE_CURSOR: u32 = 2; +pub const DRM_PLANE_TYPE_CURSOR: u32 = 2; diff --git a/drm-ffi/drm-sys/src/platforms/linux/aarch64/bindings.rs b/drm-ffi/drm-sys/src/platforms/linux/aarch64/bindings.rs index 1990cf3e..9dc94585 100644 --- a/drm-ffi/drm-sys/src/platforms/linux/aarch64/bindings.rs +++ b/drm-ffi/drm-sys/src/platforms/linux/aarch64/bindings.rs @@ -143,7 +143,6 @@ pub const DRM_MODE_CONNECTOR_VIRTUAL: u32 = 15; pub const DRM_MODE_CONNECTOR_DSI: u32 = 16; pub const DRM_MODE_CONNECTOR_DPI: u32 = 17; pub const DRM_MODE_CONNECTOR_WRITEBACK: u32 = 18; -pub const DRM_MODE_CONNECTOR_SPI: u32 = 19; pub const DRM_MODE_PROP_PENDING: u32 = 1; pub const DRM_MODE_PROP_RANGE: u32 = 2; pub const DRM_MODE_PROP_IMMUTABLE: u32 = 4; @@ -885,17 +884,12 @@ pub mod drm_mode_subconnector { pub type Type = libc::c_uint; pub const DRM_MODE_SUBCONNECTOR_Automatic: Type = 0; pub const DRM_MODE_SUBCONNECTOR_Unknown: Type = 0; - pub const DRM_MODE_SUBCONNECTOR_VGA: Type = 1; pub const DRM_MODE_SUBCONNECTOR_DVID: Type = 3; pub const DRM_MODE_SUBCONNECTOR_DVIA: Type = 4; pub const DRM_MODE_SUBCONNECTOR_Composite: Type = 5; pub const DRM_MODE_SUBCONNECTOR_SVIDEO: Type = 6; pub const DRM_MODE_SUBCONNECTOR_Component: Type = 8; pub const DRM_MODE_SUBCONNECTOR_SCART: Type = 9; - pub const DRM_MODE_SUBCONNECTOR_DisplayPort: Type = 10; - pub const DRM_MODE_SUBCONNECTOR_HDMIA: Type = 11; - pub const DRM_MODE_SUBCONNECTOR_Native: Type = 15; - pub const DRM_MODE_SUBCONNECTOR_Wireless: Type = 18; } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] @@ -1052,12 +1046,6 @@ pub struct drm_color_lut { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct hdr_metadata_infoframe__bindgen_ty_1 { - pub x: __u16, - pub y: __u16, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct drm_mode_crtc_page_flip { pub crtc_id: __u32, pub fb_id: __u32, diff --git a/drm-ffi/drm-sys/src/platforms/linux/arm/bindings.rs b/drm-ffi/drm-sys/src/platforms/linux/arm/bindings.rs new file mode 100644 index 00000000..7c460264 --- /dev/null +++ b/drm-ffi/drm-sys/src/platforms/linux/arm/bindings.rs @@ -0,0 +1,1230 @@ +/* automatically generated by rust-bindgen 0.57.0 */ + +pub const DRM_NAME: &'static [u8; 4usize] = b"drm\0"; +pub const DRM_MIN_ORDER: u32 = 5; +pub const DRM_MAX_ORDER: u32 = 22; +pub const DRM_RAM_PERCENT: u32 = 10; +pub const DRM_CAP_DUMB_BUFFER: u32 = 1; +pub const DRM_CAP_VBLANK_HIGH_CRTC: u32 = 2; +pub const DRM_CAP_DUMB_PREFERRED_DEPTH: u32 = 3; +pub const DRM_CAP_DUMB_PREFER_SHADOW: u32 = 4; +pub const DRM_CAP_PRIME: u32 = 5; +pub const DRM_PRIME_CAP_IMPORT: u32 = 1; +pub const DRM_PRIME_CAP_EXPORT: u32 = 2; +pub const DRM_CAP_TIMESTAMP_MONOTONIC: u32 = 6; +pub const DRM_CAP_ASYNC_PAGE_FLIP: u32 = 7; +pub const DRM_CAP_CURSOR_WIDTH: u32 = 8; +pub const DRM_CAP_CURSOR_HEIGHT: u32 = 9; +pub const DRM_CAP_ADDFB2_MODIFIERS: u32 = 16; +pub const DRM_CAP_PAGE_FLIP_TARGET: u32 = 17; +pub const DRM_CAP_CRTC_IN_VBLANK_EVENT: u32 = 18; +pub const DRM_CAP_SYNCOBJ: u32 = 19; +pub const DRM_CAP_SYNCOBJ_TIMELINE: u32 = 20; +pub const DRM_CLIENT_CAP_STEREO_3D: u32 = 1; +pub const DRM_CLIENT_CAP_UNIVERSAL_PLANES: u32 = 2; +pub const DRM_CLIENT_CAP_ATOMIC: u32 = 3; +pub const DRM_CLIENT_CAP_ASPECT_RATIO: u32 = 4; +pub const DRM_CLIENT_CAP_WRITEBACK_CONNECTORS: u32 = 5; +pub const DRM_SYNCOBJ_CREATE_SIGNALED: u32 = 1; +pub const DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE: u32 = 1; +pub const DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE: u32 = 1; +pub const DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL: u32 = 1; +pub const DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT: u32 = 2; +pub const DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE: u32 = 4; +pub const DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED: u32 = 1; +pub const DRM_CRTC_SEQUENCE_RELATIVE: u32 = 1; +pub const DRM_CRTC_SEQUENCE_NEXT_ON_MISS: u32 = 2; +pub const DRM_CONNECTOR_NAME_LEN: u32 = 32; +pub const DRM_DISPLAY_MODE_LEN: u32 = 32; +pub const DRM_PROP_NAME_LEN: u32 = 32; +pub const DRM_MODE_TYPE_BUILTIN: u32 = 1; +pub const DRM_MODE_TYPE_CLOCK_C: u32 = 3; +pub const DRM_MODE_TYPE_CRTC_C: u32 = 5; +pub const DRM_MODE_TYPE_PREFERRED: u32 = 8; +pub const DRM_MODE_TYPE_DEFAULT: u32 = 16; +pub const DRM_MODE_TYPE_USERDEF: u32 = 32; +pub const DRM_MODE_TYPE_DRIVER: u32 = 64; +pub const DRM_MODE_TYPE_ALL: u32 = 104; +pub const DRM_MODE_FLAG_PHSYNC: u32 = 1; +pub const DRM_MODE_FLAG_NHSYNC: u32 = 2; +pub const DRM_MODE_FLAG_PVSYNC: u32 = 4; +pub const DRM_MODE_FLAG_NVSYNC: u32 = 8; +pub const DRM_MODE_FLAG_INTERLACE: u32 = 16; +pub const DRM_MODE_FLAG_DBLSCAN: u32 = 32; +pub const DRM_MODE_FLAG_CSYNC: u32 = 64; +pub const DRM_MODE_FLAG_PCSYNC: u32 = 128; +pub const DRM_MODE_FLAG_NCSYNC: u32 = 256; +pub const DRM_MODE_FLAG_HSKEW: u32 = 512; +pub const DRM_MODE_FLAG_BCAST: u32 = 1024; +pub const DRM_MODE_FLAG_PIXMUX: u32 = 2048; +pub const DRM_MODE_FLAG_DBLCLK: u32 = 4096; +pub const DRM_MODE_FLAG_CLKDIV2: u32 = 8192; +pub const DRM_MODE_FLAG_3D_MASK: u32 = 507904; +pub const DRM_MODE_FLAG_3D_NONE: u32 = 0; +pub const DRM_MODE_FLAG_3D_FRAME_PACKING: u32 = 16384; +pub const DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE: u32 = 32768; +pub const DRM_MODE_FLAG_3D_LINE_ALTERNATIVE: u32 = 49152; +pub const DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL: u32 = 65536; +pub const DRM_MODE_FLAG_3D_L_DEPTH: u32 = 81920; +pub const DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH: u32 = 98304; +pub const DRM_MODE_FLAG_3D_TOP_AND_BOTTOM: u32 = 114688; +pub const DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF: u32 = 131072; +pub const DRM_MODE_PICTURE_ASPECT_NONE: u32 = 0; +pub const DRM_MODE_PICTURE_ASPECT_4_3: u32 = 1; +pub const DRM_MODE_PICTURE_ASPECT_16_9: u32 = 2; +pub const DRM_MODE_PICTURE_ASPECT_64_27: u32 = 3; +pub const DRM_MODE_PICTURE_ASPECT_256_135: u32 = 4; +pub const DRM_MODE_CONTENT_TYPE_NO_DATA: u32 = 0; +pub const DRM_MODE_CONTENT_TYPE_GRAPHICS: u32 = 1; +pub const DRM_MODE_CONTENT_TYPE_PHOTO: u32 = 2; +pub const DRM_MODE_CONTENT_TYPE_CINEMA: u32 = 3; +pub const DRM_MODE_CONTENT_TYPE_GAME: u32 = 4; +pub const DRM_MODE_FLAG_PIC_AR_MASK: u32 = 7864320; +pub const DRM_MODE_FLAG_PIC_AR_NONE: u32 = 0; +pub const DRM_MODE_FLAG_PIC_AR_4_3: u32 = 524288; +pub const DRM_MODE_FLAG_PIC_AR_16_9: u32 = 1048576; +pub const DRM_MODE_FLAG_PIC_AR_64_27: u32 = 1572864; +pub const DRM_MODE_FLAG_PIC_AR_256_135: u32 = 2097152; +pub const DRM_MODE_FLAG_ALL: u32 = 521215; +pub const DRM_MODE_DPMS_ON: u32 = 0; +pub const DRM_MODE_DPMS_STANDBY: u32 = 1; +pub const DRM_MODE_DPMS_SUSPEND: u32 = 2; +pub const DRM_MODE_DPMS_OFF: u32 = 3; +pub const DRM_MODE_SCALE_NONE: u32 = 0; +pub const DRM_MODE_SCALE_FULLSCREEN: u32 = 1; +pub const DRM_MODE_SCALE_CENTER: u32 = 2; +pub const DRM_MODE_SCALE_ASPECT: u32 = 3; +pub const DRM_MODE_DITHERING_OFF: u32 = 0; +pub const DRM_MODE_DITHERING_ON: u32 = 1; +pub const DRM_MODE_DITHERING_AUTO: u32 = 2; +pub const DRM_MODE_DIRTY_OFF: u32 = 0; +pub const DRM_MODE_DIRTY_ON: u32 = 1; +pub const DRM_MODE_DIRTY_ANNOTATE: u32 = 2; +pub const DRM_MODE_LINK_STATUS_GOOD: u32 = 0; +pub const DRM_MODE_LINK_STATUS_BAD: u32 = 1; +pub const DRM_MODE_ROTATE_0: u32 = 1; +pub const DRM_MODE_ROTATE_90: u32 = 2; +pub const DRM_MODE_ROTATE_180: u32 = 4; +pub const DRM_MODE_ROTATE_270: u32 = 8; +pub const DRM_MODE_ROTATE_MASK: u32 = 15; +pub const DRM_MODE_REFLECT_X: u32 = 16; +pub const DRM_MODE_REFLECT_Y: u32 = 32; +pub const DRM_MODE_REFLECT_MASK: u32 = 48; +pub const DRM_MODE_CONTENT_PROTECTION_UNDESIRED: u32 = 0; +pub const DRM_MODE_CONTENT_PROTECTION_DESIRED: u32 = 1; +pub const DRM_MODE_CONTENT_PROTECTION_ENABLED: u32 = 2; +pub const DRM_MODE_PRESENT_TOP_FIELD: u32 = 1; +pub const DRM_MODE_PRESENT_BOTTOM_FIELD: u32 = 2; +pub const DRM_MODE_ENCODER_NONE: u32 = 0; +pub const DRM_MODE_ENCODER_DAC: u32 = 1; +pub const DRM_MODE_ENCODER_TMDS: u32 = 2; +pub const DRM_MODE_ENCODER_LVDS: u32 = 3; +pub const DRM_MODE_ENCODER_TVDAC: u32 = 4; +pub const DRM_MODE_ENCODER_VIRTUAL: u32 = 5; +pub const DRM_MODE_ENCODER_DSI: u32 = 6; +pub const DRM_MODE_ENCODER_DPMST: u32 = 7; +pub const DRM_MODE_ENCODER_DPI: u32 = 8; +pub const DRM_MODE_CONNECTOR_Unknown: u32 = 0; +pub const DRM_MODE_CONNECTOR_VGA: u32 = 1; +pub const DRM_MODE_CONNECTOR_DVII: u32 = 2; +pub const DRM_MODE_CONNECTOR_DVID: u32 = 3; +pub const DRM_MODE_CONNECTOR_DVIA: u32 = 4; +pub const DRM_MODE_CONNECTOR_Composite: u32 = 5; +pub const DRM_MODE_CONNECTOR_SVIDEO: u32 = 6; +pub const DRM_MODE_CONNECTOR_LVDS: u32 = 7; +pub const DRM_MODE_CONNECTOR_Component: u32 = 8; +pub const DRM_MODE_CONNECTOR_9PinDIN: u32 = 9; +pub const DRM_MODE_CONNECTOR_DisplayPort: u32 = 10; +pub const DRM_MODE_CONNECTOR_HDMIA: u32 = 11; +pub const DRM_MODE_CONNECTOR_HDMIB: u32 = 12; +pub const DRM_MODE_CONNECTOR_TV: u32 = 13; +pub const DRM_MODE_CONNECTOR_eDP: u32 = 14; +pub const DRM_MODE_CONNECTOR_VIRTUAL: u32 = 15; +pub const DRM_MODE_CONNECTOR_DSI: u32 = 16; +pub const DRM_MODE_CONNECTOR_DPI: u32 = 17; +pub const DRM_MODE_CONNECTOR_WRITEBACK: u32 = 18; +pub const DRM_MODE_PROP_PENDING: u32 = 1; +pub const DRM_MODE_PROP_RANGE: u32 = 2; +pub const DRM_MODE_PROP_IMMUTABLE: u32 = 4; +pub const DRM_MODE_PROP_ENUM: u32 = 8; +pub const DRM_MODE_PROP_BLOB: u32 = 16; +pub const DRM_MODE_PROP_BITMASK: u32 = 32; +pub const DRM_MODE_PROP_LEGACY_TYPE: u32 = 58; +pub const DRM_MODE_PROP_EXTENDED_TYPE: u32 = 65472; +pub const DRM_MODE_PROP_ATOMIC: u32 = 2147483648; +pub const DRM_MODE_OBJECT_CRTC: u32 = 3435973836; +pub const DRM_MODE_OBJECT_CONNECTOR: u32 = 3233857728; +pub const DRM_MODE_OBJECT_ENCODER: u32 = 3772834016; +pub const DRM_MODE_OBJECT_MODE: u32 = 3739147998; +pub const DRM_MODE_OBJECT_PROPERTY: u32 = 2964369584; +pub const DRM_MODE_OBJECT_FB: u32 = 4227595259; +pub const DRM_MODE_OBJECT_BLOB: u32 = 3149642683; +pub const DRM_MODE_OBJECT_PLANE: u32 = 4008636142; +pub const DRM_MODE_OBJECT_ANY: u32 = 0; +pub const DRM_MODE_FB_INTERLACED: u32 = 1; +pub const DRM_MODE_FB_MODIFIERS: u32 = 2; +pub const DRM_MODE_FB_DIRTY_ANNOTATE_COPY: u32 = 1; +pub const DRM_MODE_FB_DIRTY_ANNOTATE_FILL: u32 = 2; +pub const DRM_MODE_FB_DIRTY_FLAGS: u32 = 3; +pub const DRM_MODE_FB_DIRTY_MAX_CLIPS: u32 = 256; +pub const DRM_MODE_CURSOR_BO: u32 = 1; +pub const DRM_MODE_CURSOR_MOVE: u32 = 2; +pub const DRM_MODE_CURSOR_FLAGS: u32 = 3; +pub const DRM_MODE_PAGE_FLIP_EVENT: u32 = 1; +pub const DRM_MODE_PAGE_FLIP_ASYNC: u32 = 2; +pub const DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE: u32 = 4; +pub const DRM_MODE_PAGE_FLIP_TARGET_RELATIVE: u32 = 8; +pub const DRM_MODE_PAGE_FLIP_TARGET: u32 = 12; +pub const DRM_MODE_PAGE_FLIP_FLAGS: u32 = 15; +pub const DRM_MODE_ATOMIC_TEST_ONLY: u32 = 256; +pub const DRM_MODE_ATOMIC_NONBLOCK: u32 = 512; +pub const DRM_MODE_ATOMIC_ALLOW_MODESET: u32 = 1024; +pub const DRM_MODE_ATOMIC_FLAGS: u32 = 1795; +pub const DRM_IOCTL_BASE: u8 = 100u8; +pub const DRM_COMMAND_BASE: u32 = 64; +pub const DRM_COMMAND_END: u32 = 160; +pub const DRM_EVENT_VBLANK: u32 = 1; +pub const DRM_EVENT_FLIP_COMPLETE: u32 = 2; +pub const DRM_EVENT_CRTC_SEQUENCE: u32 = 3; +pub type __u16 = libc::c_ushort; +pub type __s32 = libc::c_int; +pub type __u32 = libc::c_uint; +pub type __s64 = libc::c_longlong; +pub type __u64 = libc::c_ulonglong; +pub type __kernel_size_t = libc::c_uint; +pub type drm_handle_t = libc::c_uint; +pub type drm_context_t = libc::c_uint; +pub type drm_drawable_t = libc::c_uint; +pub type drm_magic_t = libc::c_uint; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_clip_rect { + pub x1: libc::c_ushort, + pub y1: libc::c_ushort, + pub x2: libc::c_ushort, + pub y2: libc::c_ushort, +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_drawable_info { + pub num_rects: libc::c_uint, + pub rects: *mut drm_clip_rect, +} +impl Default for drm_drawable_info { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_tex_region { + pub next: libc::c_uchar, + pub prev: libc::c_uchar, + pub in_use: libc::c_uchar, + pub padding: libc::c_uchar, + pub age: libc::c_uint, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct drm_hw_lock { + pub lock: libc::c_uint, + pub padding: [libc::c_char; 60usize], +} +impl Default for drm_hw_lock { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_version { + pub version_major: libc::c_int, + pub version_minor: libc::c_int, + pub version_patchlevel: libc::c_int, + pub name_len: __kernel_size_t, + pub name: *mut libc::c_char, + pub date_len: __kernel_size_t, + pub date: *mut libc::c_char, + pub desc_len: __kernel_size_t, + pub desc: *mut libc::c_char, +} +impl Default for drm_version { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_unique { + pub unique_len: __kernel_size_t, + pub unique: *mut libc::c_char, +} +impl Default for drm_unique { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_list { + pub count: libc::c_int, + pub version: *mut drm_version, +} +impl Default for drm_list { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_block { + pub unused: libc::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_control { + pub func: drm_control__bindgen_ty_1::Type, + pub irq: libc::c_int, +} +pub mod drm_control__bindgen_ty_1 { + pub type Type = libc::c_uint; + pub const DRM_ADD_COMMAND: Type = 0; + pub const DRM_RM_COMMAND: Type = 1; + pub const DRM_INST_HANDLER: Type = 2; + pub const DRM_UNINST_HANDLER: Type = 3; +} +impl Default for drm_control { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +pub mod drm_map_type { + pub type Type = libc::c_uint; + pub const _DRM_FRAME_BUFFER: Type = 0; + pub const _DRM_REGISTERS: Type = 1; + pub const _DRM_SHM: Type = 2; + pub const _DRM_AGP: Type = 3; + pub const _DRM_SCATTER_GATHER: Type = 4; + pub const _DRM_CONSISTENT: Type = 5; +} +pub mod drm_map_flags { + pub type Type = libc::c_uint; + pub const _DRM_RESTRICTED: Type = 1; + pub const _DRM_READ_ONLY: Type = 2; + pub const _DRM_LOCKED: Type = 4; + pub const _DRM_KERNEL: Type = 8; + pub const _DRM_WRITE_COMBINING: Type = 16; + pub const _DRM_CONTAINS_LOCK: Type = 32; + pub const _DRM_REMOVABLE: Type = 64; + pub const _DRM_DRIVER: Type = 128; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_ctx_priv_map { + pub ctx_id: libc::c_uint, + pub handle: *mut libc::c_void, +} +impl Default for drm_ctx_priv_map { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_map { + pub offset: libc::c_ulong, + pub size: libc::c_ulong, + pub type_: drm_map_type::Type, + pub flags: drm_map_flags::Type, + pub handle: *mut libc::c_void, + pub mtrr: libc::c_int, +} +impl Default for drm_map { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_client { + pub idx: libc::c_int, + pub auth: libc::c_int, + pub pid: libc::c_ulong, + pub uid: libc::c_ulong, + pub magic: libc::c_ulong, + pub iocs: libc::c_ulong, +} +pub mod drm_stat_type { + pub type Type = libc::c_uint; + pub const _DRM_STAT_LOCK: Type = 0; + pub const _DRM_STAT_OPENS: Type = 1; + pub const _DRM_STAT_CLOSES: Type = 2; + pub const _DRM_STAT_IOCTLS: Type = 3; + pub const _DRM_STAT_LOCKS: Type = 4; + pub const _DRM_STAT_UNLOCKS: Type = 5; + pub const _DRM_STAT_VALUE: Type = 6; + pub const _DRM_STAT_BYTE: Type = 7; + pub const _DRM_STAT_COUNT: Type = 8; + pub const _DRM_STAT_IRQ: Type = 9; + pub const _DRM_STAT_PRIMARY: Type = 10; + pub const _DRM_STAT_SECONDARY: Type = 11; + pub const _DRM_STAT_DMA: Type = 12; + pub const _DRM_STAT_SPECIAL: Type = 13; + pub const _DRM_STAT_MISSED: Type = 14; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_stats { + pub count: libc::c_ulong, + pub data: [drm_stats__bindgen_ty_1; 15usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_stats__bindgen_ty_1 { + pub value: libc::c_ulong, + pub type_: drm_stat_type::Type, +} +impl Default for drm_stats__bindgen_ty_1 { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +impl Default for drm_stats { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +pub mod drm_lock_flags { + pub type Type = libc::c_uint; + pub const _DRM_LOCK_READY: Type = 1; + pub const _DRM_LOCK_QUIESCENT: Type = 2; + pub const _DRM_LOCK_FLUSH: Type = 4; + pub const _DRM_LOCK_FLUSH_ALL: Type = 8; + pub const _DRM_HALT_ALL_QUEUES: Type = 16; + pub const _DRM_HALT_CUR_QUEUES: Type = 32; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_lock { + pub context: libc::c_int, + pub flags: drm_lock_flags::Type, +} +impl Default for drm_lock { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +pub mod drm_dma_flags { + pub type Type = libc::c_uint; + pub const _DRM_DMA_BLOCK: Type = 1; + pub const _DRM_DMA_WHILE_LOCKED: Type = 2; + pub const _DRM_DMA_PRIORITY: Type = 4; + pub const _DRM_DMA_WAIT: Type = 16; + pub const _DRM_DMA_SMALLER_OK: Type = 32; + pub const _DRM_DMA_LARGER_OK: Type = 64; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_buf_desc { + pub count: libc::c_int, + pub size: libc::c_int, + pub low_mark: libc::c_int, + pub high_mark: libc::c_int, + pub flags: drm_buf_desc__bindgen_ty_1::Type, + pub agp_start: libc::c_ulong, +} +pub mod drm_buf_desc__bindgen_ty_1 { + pub type Type = libc::c_uint; + pub const _DRM_PAGE_ALIGN: Type = 1; + pub const _DRM_AGP_BUFFER: Type = 2; + pub const _DRM_SG_BUFFER: Type = 4; + pub const _DRM_FB_BUFFER: Type = 8; + pub const _DRM_PCI_BUFFER_RO: Type = 16; +} +impl Default for drm_buf_desc { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_buf_info { + pub count: libc::c_int, + pub list: *mut drm_buf_desc, +} +impl Default for drm_buf_info { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_buf_free { + pub count: libc::c_int, + pub list: *mut libc::c_int, +} +impl Default for drm_buf_free { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_buf_pub { + pub idx: libc::c_int, + pub total: libc::c_int, + pub used: libc::c_int, + pub address: *mut libc::c_void, +} +impl Default for drm_buf_pub { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_buf_map { + pub count: libc::c_int, + pub virtual_: *mut libc::c_void, + pub list: *mut drm_buf_pub, +} +impl Default for drm_buf_map { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_dma { + pub context: libc::c_int, + pub send_count: libc::c_int, + pub send_indices: *mut libc::c_int, + pub send_sizes: *mut libc::c_int, + pub flags: drm_dma_flags::Type, + pub request_count: libc::c_int, + pub request_size: libc::c_int, + pub request_indices: *mut libc::c_int, + pub request_sizes: *mut libc::c_int, + pub granted_count: libc::c_int, +} +impl Default for drm_dma { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +pub mod drm_ctx_flags { + pub type Type = libc::c_uint; + pub const _DRM_CONTEXT_PRESERVED: Type = 1; + pub const _DRM_CONTEXT_2DONLY: Type = 2; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_ctx { + pub handle: drm_context_t, + pub flags: drm_ctx_flags::Type, +} +impl Default for drm_ctx { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_ctx_res { + pub count: libc::c_int, + pub contexts: *mut drm_ctx, +} +impl Default for drm_ctx_res { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_draw { + pub handle: drm_drawable_t, +} +pub mod drm_drawable_info_type_t { + pub type Type = libc::c_uint; + pub const DRM_DRAWABLE_CLIPRECTS: Type = 0; +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_update_draw { + pub handle: drm_drawable_t, + pub type_: libc::c_uint, + pub num: libc::c_uint, + pub data: libc::c_ulonglong, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_auth { + pub magic: drm_magic_t, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_irq_busid { + pub irq: libc::c_int, + pub busnum: libc::c_int, + pub devnum: libc::c_int, + pub funcnum: libc::c_int, +} +pub mod drm_vblank_seq_type { + pub type Type = libc::c_uint; + pub const _DRM_VBLANK_ABSOLUTE: Type = 0; + pub const _DRM_VBLANK_RELATIVE: Type = 1; + pub const _DRM_VBLANK_HIGH_CRTC_MASK: Type = 62; + pub const _DRM_VBLANK_EVENT: Type = 67108864; + pub const _DRM_VBLANK_FLIP: Type = 134217728; + pub const _DRM_VBLANK_NEXTONMISS: Type = 268435456; + pub const _DRM_VBLANK_SECONDARY: Type = 536870912; + pub const _DRM_VBLANK_SIGNAL: Type = 1073741824; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_wait_vblank_request { + pub type_: drm_vblank_seq_type::Type, + pub sequence: libc::c_uint, + pub signal: libc::c_ulong, +} +impl Default for drm_wait_vblank_request { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_wait_vblank_reply { + pub type_: drm_vblank_seq_type::Type, + pub sequence: libc::c_uint, + pub tval_sec: libc::c_long, + pub tval_usec: libc::c_long, +} +impl Default for drm_wait_vblank_reply { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union drm_wait_vblank { + pub request: drm_wait_vblank_request, + pub reply: drm_wait_vblank_reply, + _bindgen_union_align: [u32; 4usize], +} +impl Default for drm_wait_vblank { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_modeset_ctl { + pub crtc: __u32, + pub cmd: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_agp_mode { + pub mode: libc::c_ulong, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_agp_buffer { + pub size: libc::c_ulong, + pub handle: libc::c_ulong, + pub type_: libc::c_ulong, + pub physical: libc::c_ulong, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_agp_binding { + pub handle: libc::c_ulong, + pub offset: libc::c_ulong, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_agp_info { + pub agp_version_major: libc::c_int, + pub agp_version_minor: libc::c_int, + pub mode: libc::c_ulong, + pub aperture_base: libc::c_ulong, + pub aperture_size: libc::c_ulong, + pub memory_allowed: libc::c_ulong, + pub memory_used: libc::c_ulong, + pub id_vendor: libc::c_ushort, + pub id_device: libc::c_ushort, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_scatter_gather { + pub size: libc::c_ulong, + pub handle: libc::c_ulong, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_set_version { + pub drm_di_major: libc::c_int, + pub drm_di_minor: libc::c_int, + pub drm_dd_major: libc::c_int, + pub drm_dd_minor: libc::c_int, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_gem_close { + pub handle: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_gem_flink { + pub handle: __u32, + pub name: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_gem_open { + pub name: __u32, + pub handle: __u32, + pub size: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_get_cap { + pub capability: __u64, + pub value: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_set_client_cap { + pub capability: __u64, + pub value: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_prime_handle { + pub handle: __u32, + pub flags: __u32, + pub fd: __s32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_create { + pub handle: __u32, + pub flags: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_destroy { + pub handle: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_handle { + pub handle: __u32, + pub flags: __u32, + pub fd: __s32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_transfer { + pub src_handle: __u32, + pub dst_handle: __u32, + pub src_point: __u64, + pub dst_point: __u64, + pub flags: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_wait { + pub handles: __u64, + pub timeout_nsec: __s64, + pub count_handles: __u32, + pub flags: __u32, + pub first_signaled: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_timeline_wait { + pub handles: __u64, + pub points: __u64, + pub timeout_nsec: __s64, + pub count_handles: __u32, + pub flags: __u32, + pub first_signaled: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_array { + pub handles: __u64, + pub count_handles: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_timeline_array { + pub handles: __u64, + pub points: __u64, + pub count_handles: __u32, + pub flags: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_crtc_get_sequence { + pub crtc_id: __u32, + pub active: __u32, + pub sequence: __u64, + pub sequence_ns: __s64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_crtc_queue_sequence { + pub crtc_id: __u32, + pub flags: __u32, + pub sequence: __u64, + pub user_data: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_modeinfo { + pub clock: __u32, + pub hdisplay: __u16, + pub hsync_start: __u16, + pub hsync_end: __u16, + pub htotal: __u16, + pub hskew: __u16, + pub vdisplay: __u16, + pub vsync_start: __u16, + pub vsync_end: __u16, + pub vtotal: __u16, + pub vscan: __u16, + pub vrefresh: __u32, + pub flags: __u32, + pub type_: __u32, + pub name: [libc::c_char; 32usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_card_res { + pub fb_id_ptr: __u64, + pub crtc_id_ptr: __u64, + pub connector_id_ptr: __u64, + pub encoder_id_ptr: __u64, + pub count_fbs: __u32, + pub count_crtcs: __u32, + pub count_connectors: __u32, + pub count_encoders: __u32, + pub min_width: __u32, + pub max_width: __u32, + pub min_height: __u32, + pub max_height: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_crtc { + pub set_connectors_ptr: __u64, + pub count_connectors: __u32, + pub crtc_id: __u32, + pub fb_id: __u32, + pub x: __u32, + pub y: __u32, + pub gamma_size: __u32, + pub mode_valid: __u32, + pub mode: drm_mode_modeinfo, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_set_plane { + pub plane_id: __u32, + pub crtc_id: __u32, + pub fb_id: __u32, + pub flags: __u32, + pub crtc_x: __s32, + pub crtc_y: __s32, + pub crtc_w: __u32, + pub crtc_h: __u32, + pub src_x: __u32, + pub src_y: __u32, + pub src_h: __u32, + pub src_w: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_plane { + pub plane_id: __u32, + pub crtc_id: __u32, + pub fb_id: __u32, + pub possible_crtcs: __u32, + pub gamma_size: __u32, + pub count_format_types: __u32, + pub format_type_ptr: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_plane_res { + pub plane_id_ptr: __u64, + pub count_planes: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_encoder { + pub encoder_id: __u32, + pub encoder_type: __u32, + pub crtc_id: __u32, + pub possible_crtcs: __u32, + pub possible_clones: __u32, +} +pub mod drm_mode_subconnector { + pub type Type = libc::c_uint; + pub const DRM_MODE_SUBCONNECTOR_Automatic: Type = 0; + pub const DRM_MODE_SUBCONNECTOR_Unknown: Type = 0; + pub const DRM_MODE_SUBCONNECTOR_DVID: Type = 3; + pub const DRM_MODE_SUBCONNECTOR_DVIA: Type = 4; + pub const DRM_MODE_SUBCONNECTOR_Composite: Type = 5; + pub const DRM_MODE_SUBCONNECTOR_SVIDEO: Type = 6; + pub const DRM_MODE_SUBCONNECTOR_Component: Type = 8; + pub const DRM_MODE_SUBCONNECTOR_SCART: Type = 9; +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_connector { + pub encoders_ptr: __u64, + pub modes_ptr: __u64, + pub props_ptr: __u64, + pub prop_values_ptr: __u64, + pub count_modes: __u32, + pub count_props: __u32, + pub count_encoders: __u32, + pub encoder_id: __u32, + pub connector_id: __u32, + pub connector_type: __u32, + pub connector_type_id: __u32, + pub connection: __u32, + pub mm_width: __u32, + pub mm_height: __u32, + pub subpixel: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_property_enum { + pub value: __u64, + pub name: [libc::c_char; 32usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_property { + pub values_ptr: __u64, + pub enum_blob_ptr: __u64, + pub prop_id: __u32, + pub flags: __u32, + pub name: [libc::c_char; 32usize], + pub count_values: __u32, + pub count_enum_blobs: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_connector_set_property { + pub value: __u64, + pub prop_id: __u32, + pub connector_id: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_obj_get_properties { + pub props_ptr: __u64, + pub prop_values_ptr: __u64, + pub count_props: __u32, + pub obj_id: __u32, + pub obj_type: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_obj_set_property { + pub value: __u64, + pub prop_id: __u32, + pub obj_id: __u32, + pub obj_type: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_blob { + pub blob_id: __u32, + pub length: __u32, + pub data: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_fb_cmd { + pub fb_id: __u32, + pub width: __u32, + pub height: __u32, + pub pitch: __u32, + pub bpp: __u32, + pub depth: __u32, + pub handle: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_fb_cmd2 { + pub fb_id: __u32, + pub width: __u32, + pub height: __u32, + pub pixel_format: __u32, + pub flags: __u32, + pub handles: [__u32; 4usize], + pub pitches: [__u32; 4usize], + pub offsets: [__u32; 4usize], + pub modifier: [__u64; 4usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_fb_dirty_cmd { + pub fb_id: __u32, + pub flags: __u32, + pub color: __u32, + pub num_clips: __u32, + pub clips_ptr: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_mode_cmd { + pub connector_id: __u32, + pub mode: drm_mode_modeinfo, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_cursor { + pub flags: __u32, + pub crtc_id: __u32, + pub x: __s32, + pub y: __s32, + pub width: __u32, + pub height: __u32, + pub handle: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_cursor2 { + pub flags: __u32, + pub crtc_id: __u32, + pub x: __s32, + pub y: __s32, + pub width: __u32, + pub height: __u32, + pub handle: __u32, + pub hot_x: __s32, + pub hot_y: __s32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_crtc_lut { + pub crtc_id: __u32, + pub gamma_size: __u32, + pub red: __u64, + pub green: __u64, + pub blue: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_color_ctm { + pub matrix: [__u64; 9usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_color_lut { + pub red: __u16, + pub green: __u16, + pub blue: __u16, + pub reserved: __u16, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_crtc_page_flip { + pub crtc_id: __u32, + pub fb_id: __u32, + pub flags: __u32, + pub reserved: __u32, + pub user_data: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_crtc_page_flip_target { + pub crtc_id: __u32, + pub fb_id: __u32, + pub flags: __u32, + pub sequence: __u32, + pub user_data: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_create_dumb { + pub height: __u32, + pub width: __u32, + pub bpp: __u32, + pub flags: __u32, + pub handle: __u32, + pub pitch: __u32, + pub size: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_map_dumb { + pub handle: __u32, + pub pad: __u32, + pub offset: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_destroy_dumb { + pub handle: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_atomic { + pub flags: __u32, + pub count_objs: __u32, + pub objs_ptr: __u64, + pub count_props_ptr: __u64, + pub props_ptr: __u64, + pub prop_values_ptr: __u64, + pub reserved: __u64, + pub user_data: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_format_modifier_blob { + pub version: __u32, + pub flags: __u32, + pub count_formats: __u32, + pub formats_offset: __u32, + pub count_modifiers: __u32, + pub modifiers_offset: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_format_modifier { + pub formats: __u64, + pub offset: __u32, + pub pad: __u32, + pub modifier: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_create_blob { + pub data: __u64, + pub length: __u32, + pub blob_id: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_destroy_blob { + pub blob_id: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_create_lease { + pub object_ids: __u64, + pub object_count: __u32, + pub flags: __u32, + pub lessee_id: __u32, + pub fd: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_list_lessees { + pub count_lessees: __u32, + pub pad: __u32, + pub lessees_ptr: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_lease { + pub count_objects: __u32, + pub pad: __u32, + pub objects_ptr: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_revoke_lease { + pub lessee_id: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_rect { + pub x1: __s32, + pub y1: __s32, + pub x2: __s32, + pub y2: __s32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_event { + pub type_: __u32, + pub length: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_event_vblank { + pub base: drm_event, + pub user_data: __u64, + pub tv_sec: __u32, + pub tv_usec: __u32, + pub sequence: __u32, + pub crtc_id: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_event_crtc_sequence { + pub base: drm_event, + pub user_data: __u64, + pub time_ns: __s64, + pub sequence: __u64, +} +pub type drm_clip_rect_t = drm_clip_rect; +pub type drm_drawable_info_t = drm_drawable_info; +pub type drm_tex_region_t = drm_tex_region; +pub type drm_hw_lock_t = drm_hw_lock; +pub type drm_version_t = drm_version; +pub type drm_unique_t = drm_unique; +pub type drm_list_t = drm_list; +pub type drm_block_t = drm_block; +pub type drm_control_t = drm_control; +pub use self::drm_map_flags::Type as drm_map_flags_t; +pub use self::drm_map_type::Type as drm_map_type_t; +pub type drm_ctx_priv_map_t = drm_ctx_priv_map; +pub type drm_map_t = drm_map; +pub type drm_client_t = drm_client; +pub use self::drm_stat_type::Type as drm_stat_type_t; +pub type drm_stats_t = drm_stats; +pub use self::drm_lock_flags::Type as drm_lock_flags_t; +pub type drm_lock_t = drm_lock; +pub use self::drm_dma_flags::Type as drm_dma_flags_t; +pub type drm_buf_desc_t = drm_buf_desc; +pub type drm_buf_info_t = drm_buf_info; +pub type drm_buf_free_t = drm_buf_free; +pub type drm_buf_pub_t = drm_buf_pub; +pub type drm_buf_map_t = drm_buf_map; +pub type drm_dma_t = drm_dma; +pub type drm_wait_vblank_t = drm_wait_vblank; +pub type drm_agp_mode_t = drm_agp_mode; +pub use self::drm_ctx_flags::Type as drm_ctx_flags_t; +pub type drm_ctx_t = drm_ctx; +pub type drm_ctx_res_t = drm_ctx_res; +pub type drm_draw_t = drm_draw; +pub type drm_update_draw_t = drm_update_draw; +pub type drm_auth_t = drm_auth; +pub type drm_irq_busid_t = drm_irq_busid; +pub use self::drm_vblank_seq_type::Type as drm_vblank_seq_type_t; +pub type drm_agp_buffer_t = drm_agp_buffer; +pub type drm_agp_binding_t = drm_agp_binding; +pub type drm_agp_info_t = drm_agp_info; +pub type drm_scatter_gather_t = drm_scatter_gather; +pub type drm_set_version_t = drm_set_version; +pub const DRM_MODE_PROP_SIGNED_RANGE: libc::c_uint = 128; +pub const DRM_MODE_PROP_OBJECT: libc::c_uint = 64; diff --git a/drm-ffi/drm-sys/src/platforms/linux/x86/bindings.rs b/drm-ffi/drm-sys/src/platforms/linux/x86/bindings.rs new file mode 100644 index 00000000..7c460264 --- /dev/null +++ b/drm-ffi/drm-sys/src/platforms/linux/x86/bindings.rs @@ -0,0 +1,1230 @@ +/* automatically generated by rust-bindgen 0.57.0 */ + +pub const DRM_NAME: &'static [u8; 4usize] = b"drm\0"; +pub const DRM_MIN_ORDER: u32 = 5; +pub const DRM_MAX_ORDER: u32 = 22; +pub const DRM_RAM_PERCENT: u32 = 10; +pub const DRM_CAP_DUMB_BUFFER: u32 = 1; +pub const DRM_CAP_VBLANK_HIGH_CRTC: u32 = 2; +pub const DRM_CAP_DUMB_PREFERRED_DEPTH: u32 = 3; +pub const DRM_CAP_DUMB_PREFER_SHADOW: u32 = 4; +pub const DRM_CAP_PRIME: u32 = 5; +pub const DRM_PRIME_CAP_IMPORT: u32 = 1; +pub const DRM_PRIME_CAP_EXPORT: u32 = 2; +pub const DRM_CAP_TIMESTAMP_MONOTONIC: u32 = 6; +pub const DRM_CAP_ASYNC_PAGE_FLIP: u32 = 7; +pub const DRM_CAP_CURSOR_WIDTH: u32 = 8; +pub const DRM_CAP_CURSOR_HEIGHT: u32 = 9; +pub const DRM_CAP_ADDFB2_MODIFIERS: u32 = 16; +pub const DRM_CAP_PAGE_FLIP_TARGET: u32 = 17; +pub const DRM_CAP_CRTC_IN_VBLANK_EVENT: u32 = 18; +pub const DRM_CAP_SYNCOBJ: u32 = 19; +pub const DRM_CAP_SYNCOBJ_TIMELINE: u32 = 20; +pub const DRM_CLIENT_CAP_STEREO_3D: u32 = 1; +pub const DRM_CLIENT_CAP_UNIVERSAL_PLANES: u32 = 2; +pub const DRM_CLIENT_CAP_ATOMIC: u32 = 3; +pub const DRM_CLIENT_CAP_ASPECT_RATIO: u32 = 4; +pub const DRM_CLIENT_CAP_WRITEBACK_CONNECTORS: u32 = 5; +pub const DRM_SYNCOBJ_CREATE_SIGNALED: u32 = 1; +pub const DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE: u32 = 1; +pub const DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE: u32 = 1; +pub const DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL: u32 = 1; +pub const DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT: u32 = 2; +pub const DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE: u32 = 4; +pub const DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED: u32 = 1; +pub const DRM_CRTC_SEQUENCE_RELATIVE: u32 = 1; +pub const DRM_CRTC_SEQUENCE_NEXT_ON_MISS: u32 = 2; +pub const DRM_CONNECTOR_NAME_LEN: u32 = 32; +pub const DRM_DISPLAY_MODE_LEN: u32 = 32; +pub const DRM_PROP_NAME_LEN: u32 = 32; +pub const DRM_MODE_TYPE_BUILTIN: u32 = 1; +pub const DRM_MODE_TYPE_CLOCK_C: u32 = 3; +pub const DRM_MODE_TYPE_CRTC_C: u32 = 5; +pub const DRM_MODE_TYPE_PREFERRED: u32 = 8; +pub const DRM_MODE_TYPE_DEFAULT: u32 = 16; +pub const DRM_MODE_TYPE_USERDEF: u32 = 32; +pub const DRM_MODE_TYPE_DRIVER: u32 = 64; +pub const DRM_MODE_TYPE_ALL: u32 = 104; +pub const DRM_MODE_FLAG_PHSYNC: u32 = 1; +pub const DRM_MODE_FLAG_NHSYNC: u32 = 2; +pub const DRM_MODE_FLAG_PVSYNC: u32 = 4; +pub const DRM_MODE_FLAG_NVSYNC: u32 = 8; +pub const DRM_MODE_FLAG_INTERLACE: u32 = 16; +pub const DRM_MODE_FLAG_DBLSCAN: u32 = 32; +pub const DRM_MODE_FLAG_CSYNC: u32 = 64; +pub const DRM_MODE_FLAG_PCSYNC: u32 = 128; +pub const DRM_MODE_FLAG_NCSYNC: u32 = 256; +pub const DRM_MODE_FLAG_HSKEW: u32 = 512; +pub const DRM_MODE_FLAG_BCAST: u32 = 1024; +pub const DRM_MODE_FLAG_PIXMUX: u32 = 2048; +pub const DRM_MODE_FLAG_DBLCLK: u32 = 4096; +pub const DRM_MODE_FLAG_CLKDIV2: u32 = 8192; +pub const DRM_MODE_FLAG_3D_MASK: u32 = 507904; +pub const DRM_MODE_FLAG_3D_NONE: u32 = 0; +pub const DRM_MODE_FLAG_3D_FRAME_PACKING: u32 = 16384; +pub const DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE: u32 = 32768; +pub const DRM_MODE_FLAG_3D_LINE_ALTERNATIVE: u32 = 49152; +pub const DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL: u32 = 65536; +pub const DRM_MODE_FLAG_3D_L_DEPTH: u32 = 81920; +pub const DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH: u32 = 98304; +pub const DRM_MODE_FLAG_3D_TOP_AND_BOTTOM: u32 = 114688; +pub const DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF: u32 = 131072; +pub const DRM_MODE_PICTURE_ASPECT_NONE: u32 = 0; +pub const DRM_MODE_PICTURE_ASPECT_4_3: u32 = 1; +pub const DRM_MODE_PICTURE_ASPECT_16_9: u32 = 2; +pub const DRM_MODE_PICTURE_ASPECT_64_27: u32 = 3; +pub const DRM_MODE_PICTURE_ASPECT_256_135: u32 = 4; +pub const DRM_MODE_CONTENT_TYPE_NO_DATA: u32 = 0; +pub const DRM_MODE_CONTENT_TYPE_GRAPHICS: u32 = 1; +pub const DRM_MODE_CONTENT_TYPE_PHOTO: u32 = 2; +pub const DRM_MODE_CONTENT_TYPE_CINEMA: u32 = 3; +pub const DRM_MODE_CONTENT_TYPE_GAME: u32 = 4; +pub const DRM_MODE_FLAG_PIC_AR_MASK: u32 = 7864320; +pub const DRM_MODE_FLAG_PIC_AR_NONE: u32 = 0; +pub const DRM_MODE_FLAG_PIC_AR_4_3: u32 = 524288; +pub const DRM_MODE_FLAG_PIC_AR_16_9: u32 = 1048576; +pub const DRM_MODE_FLAG_PIC_AR_64_27: u32 = 1572864; +pub const DRM_MODE_FLAG_PIC_AR_256_135: u32 = 2097152; +pub const DRM_MODE_FLAG_ALL: u32 = 521215; +pub const DRM_MODE_DPMS_ON: u32 = 0; +pub const DRM_MODE_DPMS_STANDBY: u32 = 1; +pub const DRM_MODE_DPMS_SUSPEND: u32 = 2; +pub const DRM_MODE_DPMS_OFF: u32 = 3; +pub const DRM_MODE_SCALE_NONE: u32 = 0; +pub const DRM_MODE_SCALE_FULLSCREEN: u32 = 1; +pub const DRM_MODE_SCALE_CENTER: u32 = 2; +pub const DRM_MODE_SCALE_ASPECT: u32 = 3; +pub const DRM_MODE_DITHERING_OFF: u32 = 0; +pub const DRM_MODE_DITHERING_ON: u32 = 1; +pub const DRM_MODE_DITHERING_AUTO: u32 = 2; +pub const DRM_MODE_DIRTY_OFF: u32 = 0; +pub const DRM_MODE_DIRTY_ON: u32 = 1; +pub const DRM_MODE_DIRTY_ANNOTATE: u32 = 2; +pub const DRM_MODE_LINK_STATUS_GOOD: u32 = 0; +pub const DRM_MODE_LINK_STATUS_BAD: u32 = 1; +pub const DRM_MODE_ROTATE_0: u32 = 1; +pub const DRM_MODE_ROTATE_90: u32 = 2; +pub const DRM_MODE_ROTATE_180: u32 = 4; +pub const DRM_MODE_ROTATE_270: u32 = 8; +pub const DRM_MODE_ROTATE_MASK: u32 = 15; +pub const DRM_MODE_REFLECT_X: u32 = 16; +pub const DRM_MODE_REFLECT_Y: u32 = 32; +pub const DRM_MODE_REFLECT_MASK: u32 = 48; +pub const DRM_MODE_CONTENT_PROTECTION_UNDESIRED: u32 = 0; +pub const DRM_MODE_CONTENT_PROTECTION_DESIRED: u32 = 1; +pub const DRM_MODE_CONTENT_PROTECTION_ENABLED: u32 = 2; +pub const DRM_MODE_PRESENT_TOP_FIELD: u32 = 1; +pub const DRM_MODE_PRESENT_BOTTOM_FIELD: u32 = 2; +pub const DRM_MODE_ENCODER_NONE: u32 = 0; +pub const DRM_MODE_ENCODER_DAC: u32 = 1; +pub const DRM_MODE_ENCODER_TMDS: u32 = 2; +pub const DRM_MODE_ENCODER_LVDS: u32 = 3; +pub const DRM_MODE_ENCODER_TVDAC: u32 = 4; +pub const DRM_MODE_ENCODER_VIRTUAL: u32 = 5; +pub const DRM_MODE_ENCODER_DSI: u32 = 6; +pub const DRM_MODE_ENCODER_DPMST: u32 = 7; +pub const DRM_MODE_ENCODER_DPI: u32 = 8; +pub const DRM_MODE_CONNECTOR_Unknown: u32 = 0; +pub const DRM_MODE_CONNECTOR_VGA: u32 = 1; +pub const DRM_MODE_CONNECTOR_DVII: u32 = 2; +pub const DRM_MODE_CONNECTOR_DVID: u32 = 3; +pub const DRM_MODE_CONNECTOR_DVIA: u32 = 4; +pub const DRM_MODE_CONNECTOR_Composite: u32 = 5; +pub const DRM_MODE_CONNECTOR_SVIDEO: u32 = 6; +pub const DRM_MODE_CONNECTOR_LVDS: u32 = 7; +pub const DRM_MODE_CONNECTOR_Component: u32 = 8; +pub const DRM_MODE_CONNECTOR_9PinDIN: u32 = 9; +pub const DRM_MODE_CONNECTOR_DisplayPort: u32 = 10; +pub const DRM_MODE_CONNECTOR_HDMIA: u32 = 11; +pub const DRM_MODE_CONNECTOR_HDMIB: u32 = 12; +pub const DRM_MODE_CONNECTOR_TV: u32 = 13; +pub const DRM_MODE_CONNECTOR_eDP: u32 = 14; +pub const DRM_MODE_CONNECTOR_VIRTUAL: u32 = 15; +pub const DRM_MODE_CONNECTOR_DSI: u32 = 16; +pub const DRM_MODE_CONNECTOR_DPI: u32 = 17; +pub const DRM_MODE_CONNECTOR_WRITEBACK: u32 = 18; +pub const DRM_MODE_PROP_PENDING: u32 = 1; +pub const DRM_MODE_PROP_RANGE: u32 = 2; +pub const DRM_MODE_PROP_IMMUTABLE: u32 = 4; +pub const DRM_MODE_PROP_ENUM: u32 = 8; +pub const DRM_MODE_PROP_BLOB: u32 = 16; +pub const DRM_MODE_PROP_BITMASK: u32 = 32; +pub const DRM_MODE_PROP_LEGACY_TYPE: u32 = 58; +pub const DRM_MODE_PROP_EXTENDED_TYPE: u32 = 65472; +pub const DRM_MODE_PROP_ATOMIC: u32 = 2147483648; +pub const DRM_MODE_OBJECT_CRTC: u32 = 3435973836; +pub const DRM_MODE_OBJECT_CONNECTOR: u32 = 3233857728; +pub const DRM_MODE_OBJECT_ENCODER: u32 = 3772834016; +pub const DRM_MODE_OBJECT_MODE: u32 = 3739147998; +pub const DRM_MODE_OBJECT_PROPERTY: u32 = 2964369584; +pub const DRM_MODE_OBJECT_FB: u32 = 4227595259; +pub const DRM_MODE_OBJECT_BLOB: u32 = 3149642683; +pub const DRM_MODE_OBJECT_PLANE: u32 = 4008636142; +pub const DRM_MODE_OBJECT_ANY: u32 = 0; +pub const DRM_MODE_FB_INTERLACED: u32 = 1; +pub const DRM_MODE_FB_MODIFIERS: u32 = 2; +pub const DRM_MODE_FB_DIRTY_ANNOTATE_COPY: u32 = 1; +pub const DRM_MODE_FB_DIRTY_ANNOTATE_FILL: u32 = 2; +pub const DRM_MODE_FB_DIRTY_FLAGS: u32 = 3; +pub const DRM_MODE_FB_DIRTY_MAX_CLIPS: u32 = 256; +pub const DRM_MODE_CURSOR_BO: u32 = 1; +pub const DRM_MODE_CURSOR_MOVE: u32 = 2; +pub const DRM_MODE_CURSOR_FLAGS: u32 = 3; +pub const DRM_MODE_PAGE_FLIP_EVENT: u32 = 1; +pub const DRM_MODE_PAGE_FLIP_ASYNC: u32 = 2; +pub const DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE: u32 = 4; +pub const DRM_MODE_PAGE_FLIP_TARGET_RELATIVE: u32 = 8; +pub const DRM_MODE_PAGE_FLIP_TARGET: u32 = 12; +pub const DRM_MODE_PAGE_FLIP_FLAGS: u32 = 15; +pub const DRM_MODE_ATOMIC_TEST_ONLY: u32 = 256; +pub const DRM_MODE_ATOMIC_NONBLOCK: u32 = 512; +pub const DRM_MODE_ATOMIC_ALLOW_MODESET: u32 = 1024; +pub const DRM_MODE_ATOMIC_FLAGS: u32 = 1795; +pub const DRM_IOCTL_BASE: u8 = 100u8; +pub const DRM_COMMAND_BASE: u32 = 64; +pub const DRM_COMMAND_END: u32 = 160; +pub const DRM_EVENT_VBLANK: u32 = 1; +pub const DRM_EVENT_FLIP_COMPLETE: u32 = 2; +pub const DRM_EVENT_CRTC_SEQUENCE: u32 = 3; +pub type __u16 = libc::c_ushort; +pub type __s32 = libc::c_int; +pub type __u32 = libc::c_uint; +pub type __s64 = libc::c_longlong; +pub type __u64 = libc::c_ulonglong; +pub type __kernel_size_t = libc::c_uint; +pub type drm_handle_t = libc::c_uint; +pub type drm_context_t = libc::c_uint; +pub type drm_drawable_t = libc::c_uint; +pub type drm_magic_t = libc::c_uint; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_clip_rect { + pub x1: libc::c_ushort, + pub y1: libc::c_ushort, + pub x2: libc::c_ushort, + pub y2: libc::c_ushort, +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_drawable_info { + pub num_rects: libc::c_uint, + pub rects: *mut drm_clip_rect, +} +impl Default for drm_drawable_info { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_tex_region { + pub next: libc::c_uchar, + pub prev: libc::c_uchar, + pub in_use: libc::c_uchar, + pub padding: libc::c_uchar, + pub age: libc::c_uint, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct drm_hw_lock { + pub lock: libc::c_uint, + pub padding: [libc::c_char; 60usize], +} +impl Default for drm_hw_lock { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_version { + pub version_major: libc::c_int, + pub version_minor: libc::c_int, + pub version_patchlevel: libc::c_int, + pub name_len: __kernel_size_t, + pub name: *mut libc::c_char, + pub date_len: __kernel_size_t, + pub date: *mut libc::c_char, + pub desc_len: __kernel_size_t, + pub desc: *mut libc::c_char, +} +impl Default for drm_version { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_unique { + pub unique_len: __kernel_size_t, + pub unique: *mut libc::c_char, +} +impl Default for drm_unique { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_list { + pub count: libc::c_int, + pub version: *mut drm_version, +} +impl Default for drm_list { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_block { + pub unused: libc::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_control { + pub func: drm_control__bindgen_ty_1::Type, + pub irq: libc::c_int, +} +pub mod drm_control__bindgen_ty_1 { + pub type Type = libc::c_uint; + pub const DRM_ADD_COMMAND: Type = 0; + pub const DRM_RM_COMMAND: Type = 1; + pub const DRM_INST_HANDLER: Type = 2; + pub const DRM_UNINST_HANDLER: Type = 3; +} +impl Default for drm_control { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +pub mod drm_map_type { + pub type Type = libc::c_uint; + pub const _DRM_FRAME_BUFFER: Type = 0; + pub const _DRM_REGISTERS: Type = 1; + pub const _DRM_SHM: Type = 2; + pub const _DRM_AGP: Type = 3; + pub const _DRM_SCATTER_GATHER: Type = 4; + pub const _DRM_CONSISTENT: Type = 5; +} +pub mod drm_map_flags { + pub type Type = libc::c_uint; + pub const _DRM_RESTRICTED: Type = 1; + pub const _DRM_READ_ONLY: Type = 2; + pub const _DRM_LOCKED: Type = 4; + pub const _DRM_KERNEL: Type = 8; + pub const _DRM_WRITE_COMBINING: Type = 16; + pub const _DRM_CONTAINS_LOCK: Type = 32; + pub const _DRM_REMOVABLE: Type = 64; + pub const _DRM_DRIVER: Type = 128; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_ctx_priv_map { + pub ctx_id: libc::c_uint, + pub handle: *mut libc::c_void, +} +impl Default for drm_ctx_priv_map { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_map { + pub offset: libc::c_ulong, + pub size: libc::c_ulong, + pub type_: drm_map_type::Type, + pub flags: drm_map_flags::Type, + pub handle: *mut libc::c_void, + pub mtrr: libc::c_int, +} +impl Default for drm_map { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_client { + pub idx: libc::c_int, + pub auth: libc::c_int, + pub pid: libc::c_ulong, + pub uid: libc::c_ulong, + pub magic: libc::c_ulong, + pub iocs: libc::c_ulong, +} +pub mod drm_stat_type { + pub type Type = libc::c_uint; + pub const _DRM_STAT_LOCK: Type = 0; + pub const _DRM_STAT_OPENS: Type = 1; + pub const _DRM_STAT_CLOSES: Type = 2; + pub const _DRM_STAT_IOCTLS: Type = 3; + pub const _DRM_STAT_LOCKS: Type = 4; + pub const _DRM_STAT_UNLOCKS: Type = 5; + pub const _DRM_STAT_VALUE: Type = 6; + pub const _DRM_STAT_BYTE: Type = 7; + pub const _DRM_STAT_COUNT: Type = 8; + pub const _DRM_STAT_IRQ: Type = 9; + pub const _DRM_STAT_PRIMARY: Type = 10; + pub const _DRM_STAT_SECONDARY: Type = 11; + pub const _DRM_STAT_DMA: Type = 12; + pub const _DRM_STAT_SPECIAL: Type = 13; + pub const _DRM_STAT_MISSED: Type = 14; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_stats { + pub count: libc::c_ulong, + pub data: [drm_stats__bindgen_ty_1; 15usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_stats__bindgen_ty_1 { + pub value: libc::c_ulong, + pub type_: drm_stat_type::Type, +} +impl Default for drm_stats__bindgen_ty_1 { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +impl Default for drm_stats { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +pub mod drm_lock_flags { + pub type Type = libc::c_uint; + pub const _DRM_LOCK_READY: Type = 1; + pub const _DRM_LOCK_QUIESCENT: Type = 2; + pub const _DRM_LOCK_FLUSH: Type = 4; + pub const _DRM_LOCK_FLUSH_ALL: Type = 8; + pub const _DRM_HALT_ALL_QUEUES: Type = 16; + pub const _DRM_HALT_CUR_QUEUES: Type = 32; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_lock { + pub context: libc::c_int, + pub flags: drm_lock_flags::Type, +} +impl Default for drm_lock { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +pub mod drm_dma_flags { + pub type Type = libc::c_uint; + pub const _DRM_DMA_BLOCK: Type = 1; + pub const _DRM_DMA_WHILE_LOCKED: Type = 2; + pub const _DRM_DMA_PRIORITY: Type = 4; + pub const _DRM_DMA_WAIT: Type = 16; + pub const _DRM_DMA_SMALLER_OK: Type = 32; + pub const _DRM_DMA_LARGER_OK: Type = 64; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_buf_desc { + pub count: libc::c_int, + pub size: libc::c_int, + pub low_mark: libc::c_int, + pub high_mark: libc::c_int, + pub flags: drm_buf_desc__bindgen_ty_1::Type, + pub agp_start: libc::c_ulong, +} +pub mod drm_buf_desc__bindgen_ty_1 { + pub type Type = libc::c_uint; + pub const _DRM_PAGE_ALIGN: Type = 1; + pub const _DRM_AGP_BUFFER: Type = 2; + pub const _DRM_SG_BUFFER: Type = 4; + pub const _DRM_FB_BUFFER: Type = 8; + pub const _DRM_PCI_BUFFER_RO: Type = 16; +} +impl Default for drm_buf_desc { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_buf_info { + pub count: libc::c_int, + pub list: *mut drm_buf_desc, +} +impl Default for drm_buf_info { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_buf_free { + pub count: libc::c_int, + pub list: *mut libc::c_int, +} +impl Default for drm_buf_free { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_buf_pub { + pub idx: libc::c_int, + pub total: libc::c_int, + pub used: libc::c_int, + pub address: *mut libc::c_void, +} +impl Default for drm_buf_pub { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_buf_map { + pub count: libc::c_int, + pub virtual_: *mut libc::c_void, + pub list: *mut drm_buf_pub, +} +impl Default for drm_buf_map { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_dma { + pub context: libc::c_int, + pub send_count: libc::c_int, + pub send_indices: *mut libc::c_int, + pub send_sizes: *mut libc::c_int, + pub flags: drm_dma_flags::Type, + pub request_count: libc::c_int, + pub request_size: libc::c_int, + pub request_indices: *mut libc::c_int, + pub request_sizes: *mut libc::c_int, + pub granted_count: libc::c_int, +} +impl Default for drm_dma { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +pub mod drm_ctx_flags { + pub type Type = libc::c_uint; + pub const _DRM_CONTEXT_PRESERVED: Type = 1; + pub const _DRM_CONTEXT_2DONLY: Type = 2; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_ctx { + pub handle: drm_context_t, + pub flags: drm_ctx_flags::Type, +} +impl Default for drm_ctx { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_ctx_res { + pub count: libc::c_int, + pub contexts: *mut drm_ctx, +} +impl Default for drm_ctx_res { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_draw { + pub handle: drm_drawable_t, +} +pub mod drm_drawable_info_type_t { + pub type Type = libc::c_uint; + pub const DRM_DRAWABLE_CLIPRECTS: Type = 0; +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_update_draw { + pub handle: drm_drawable_t, + pub type_: libc::c_uint, + pub num: libc::c_uint, + pub data: libc::c_ulonglong, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_auth { + pub magic: drm_magic_t, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_irq_busid { + pub irq: libc::c_int, + pub busnum: libc::c_int, + pub devnum: libc::c_int, + pub funcnum: libc::c_int, +} +pub mod drm_vblank_seq_type { + pub type Type = libc::c_uint; + pub const _DRM_VBLANK_ABSOLUTE: Type = 0; + pub const _DRM_VBLANK_RELATIVE: Type = 1; + pub const _DRM_VBLANK_HIGH_CRTC_MASK: Type = 62; + pub const _DRM_VBLANK_EVENT: Type = 67108864; + pub const _DRM_VBLANK_FLIP: Type = 134217728; + pub const _DRM_VBLANK_NEXTONMISS: Type = 268435456; + pub const _DRM_VBLANK_SECONDARY: Type = 536870912; + pub const _DRM_VBLANK_SIGNAL: Type = 1073741824; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_wait_vblank_request { + pub type_: drm_vblank_seq_type::Type, + pub sequence: libc::c_uint, + pub signal: libc::c_ulong, +} +impl Default for drm_wait_vblank_request { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_wait_vblank_reply { + pub type_: drm_vblank_seq_type::Type, + pub sequence: libc::c_uint, + pub tval_sec: libc::c_long, + pub tval_usec: libc::c_long, +} +impl Default for drm_wait_vblank_reply { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union drm_wait_vblank { + pub request: drm_wait_vblank_request, + pub reply: drm_wait_vblank_reply, + _bindgen_union_align: [u32; 4usize], +} +impl Default for drm_wait_vblank { + fn default() -> Self { + unsafe { ::core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_modeset_ctl { + pub crtc: __u32, + pub cmd: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_agp_mode { + pub mode: libc::c_ulong, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_agp_buffer { + pub size: libc::c_ulong, + pub handle: libc::c_ulong, + pub type_: libc::c_ulong, + pub physical: libc::c_ulong, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_agp_binding { + pub handle: libc::c_ulong, + pub offset: libc::c_ulong, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_agp_info { + pub agp_version_major: libc::c_int, + pub agp_version_minor: libc::c_int, + pub mode: libc::c_ulong, + pub aperture_base: libc::c_ulong, + pub aperture_size: libc::c_ulong, + pub memory_allowed: libc::c_ulong, + pub memory_used: libc::c_ulong, + pub id_vendor: libc::c_ushort, + pub id_device: libc::c_ushort, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_scatter_gather { + pub size: libc::c_ulong, + pub handle: libc::c_ulong, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_set_version { + pub drm_di_major: libc::c_int, + pub drm_di_minor: libc::c_int, + pub drm_dd_major: libc::c_int, + pub drm_dd_minor: libc::c_int, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_gem_close { + pub handle: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_gem_flink { + pub handle: __u32, + pub name: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_gem_open { + pub name: __u32, + pub handle: __u32, + pub size: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_get_cap { + pub capability: __u64, + pub value: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_set_client_cap { + pub capability: __u64, + pub value: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_prime_handle { + pub handle: __u32, + pub flags: __u32, + pub fd: __s32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_create { + pub handle: __u32, + pub flags: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_destroy { + pub handle: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_handle { + pub handle: __u32, + pub flags: __u32, + pub fd: __s32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_transfer { + pub src_handle: __u32, + pub dst_handle: __u32, + pub src_point: __u64, + pub dst_point: __u64, + pub flags: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_wait { + pub handles: __u64, + pub timeout_nsec: __s64, + pub count_handles: __u32, + pub flags: __u32, + pub first_signaled: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_timeline_wait { + pub handles: __u64, + pub points: __u64, + pub timeout_nsec: __s64, + pub count_handles: __u32, + pub flags: __u32, + pub first_signaled: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_array { + pub handles: __u64, + pub count_handles: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_syncobj_timeline_array { + pub handles: __u64, + pub points: __u64, + pub count_handles: __u32, + pub flags: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_crtc_get_sequence { + pub crtc_id: __u32, + pub active: __u32, + pub sequence: __u64, + pub sequence_ns: __s64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_crtc_queue_sequence { + pub crtc_id: __u32, + pub flags: __u32, + pub sequence: __u64, + pub user_data: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_modeinfo { + pub clock: __u32, + pub hdisplay: __u16, + pub hsync_start: __u16, + pub hsync_end: __u16, + pub htotal: __u16, + pub hskew: __u16, + pub vdisplay: __u16, + pub vsync_start: __u16, + pub vsync_end: __u16, + pub vtotal: __u16, + pub vscan: __u16, + pub vrefresh: __u32, + pub flags: __u32, + pub type_: __u32, + pub name: [libc::c_char; 32usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_card_res { + pub fb_id_ptr: __u64, + pub crtc_id_ptr: __u64, + pub connector_id_ptr: __u64, + pub encoder_id_ptr: __u64, + pub count_fbs: __u32, + pub count_crtcs: __u32, + pub count_connectors: __u32, + pub count_encoders: __u32, + pub min_width: __u32, + pub max_width: __u32, + pub min_height: __u32, + pub max_height: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_crtc { + pub set_connectors_ptr: __u64, + pub count_connectors: __u32, + pub crtc_id: __u32, + pub fb_id: __u32, + pub x: __u32, + pub y: __u32, + pub gamma_size: __u32, + pub mode_valid: __u32, + pub mode: drm_mode_modeinfo, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_set_plane { + pub plane_id: __u32, + pub crtc_id: __u32, + pub fb_id: __u32, + pub flags: __u32, + pub crtc_x: __s32, + pub crtc_y: __s32, + pub crtc_w: __u32, + pub crtc_h: __u32, + pub src_x: __u32, + pub src_y: __u32, + pub src_h: __u32, + pub src_w: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_plane { + pub plane_id: __u32, + pub crtc_id: __u32, + pub fb_id: __u32, + pub possible_crtcs: __u32, + pub gamma_size: __u32, + pub count_format_types: __u32, + pub format_type_ptr: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_plane_res { + pub plane_id_ptr: __u64, + pub count_planes: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_encoder { + pub encoder_id: __u32, + pub encoder_type: __u32, + pub crtc_id: __u32, + pub possible_crtcs: __u32, + pub possible_clones: __u32, +} +pub mod drm_mode_subconnector { + pub type Type = libc::c_uint; + pub const DRM_MODE_SUBCONNECTOR_Automatic: Type = 0; + pub const DRM_MODE_SUBCONNECTOR_Unknown: Type = 0; + pub const DRM_MODE_SUBCONNECTOR_DVID: Type = 3; + pub const DRM_MODE_SUBCONNECTOR_DVIA: Type = 4; + pub const DRM_MODE_SUBCONNECTOR_Composite: Type = 5; + pub const DRM_MODE_SUBCONNECTOR_SVIDEO: Type = 6; + pub const DRM_MODE_SUBCONNECTOR_Component: Type = 8; + pub const DRM_MODE_SUBCONNECTOR_SCART: Type = 9; +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_connector { + pub encoders_ptr: __u64, + pub modes_ptr: __u64, + pub props_ptr: __u64, + pub prop_values_ptr: __u64, + pub count_modes: __u32, + pub count_props: __u32, + pub count_encoders: __u32, + pub encoder_id: __u32, + pub connector_id: __u32, + pub connector_type: __u32, + pub connector_type_id: __u32, + pub connection: __u32, + pub mm_width: __u32, + pub mm_height: __u32, + pub subpixel: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_property_enum { + pub value: __u64, + pub name: [libc::c_char; 32usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_property { + pub values_ptr: __u64, + pub enum_blob_ptr: __u64, + pub prop_id: __u32, + pub flags: __u32, + pub name: [libc::c_char; 32usize], + pub count_values: __u32, + pub count_enum_blobs: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_connector_set_property { + pub value: __u64, + pub prop_id: __u32, + pub connector_id: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_obj_get_properties { + pub props_ptr: __u64, + pub prop_values_ptr: __u64, + pub count_props: __u32, + pub obj_id: __u32, + pub obj_type: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_obj_set_property { + pub value: __u64, + pub prop_id: __u32, + pub obj_id: __u32, + pub obj_type: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_blob { + pub blob_id: __u32, + pub length: __u32, + pub data: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_fb_cmd { + pub fb_id: __u32, + pub width: __u32, + pub height: __u32, + pub pitch: __u32, + pub bpp: __u32, + pub depth: __u32, + pub handle: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_fb_cmd2 { + pub fb_id: __u32, + pub width: __u32, + pub height: __u32, + pub pixel_format: __u32, + pub flags: __u32, + pub handles: [__u32; 4usize], + pub pitches: [__u32; 4usize], + pub offsets: [__u32; 4usize], + pub modifier: [__u64; 4usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_fb_dirty_cmd { + pub fb_id: __u32, + pub flags: __u32, + pub color: __u32, + pub num_clips: __u32, + pub clips_ptr: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_mode_cmd { + pub connector_id: __u32, + pub mode: drm_mode_modeinfo, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_cursor { + pub flags: __u32, + pub crtc_id: __u32, + pub x: __s32, + pub y: __s32, + pub width: __u32, + pub height: __u32, + pub handle: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_cursor2 { + pub flags: __u32, + pub crtc_id: __u32, + pub x: __s32, + pub y: __s32, + pub width: __u32, + pub height: __u32, + pub handle: __u32, + pub hot_x: __s32, + pub hot_y: __s32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_crtc_lut { + pub crtc_id: __u32, + pub gamma_size: __u32, + pub red: __u64, + pub green: __u64, + pub blue: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_color_ctm { + pub matrix: [__u64; 9usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_color_lut { + pub red: __u16, + pub green: __u16, + pub blue: __u16, + pub reserved: __u16, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_crtc_page_flip { + pub crtc_id: __u32, + pub fb_id: __u32, + pub flags: __u32, + pub reserved: __u32, + pub user_data: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_crtc_page_flip_target { + pub crtc_id: __u32, + pub fb_id: __u32, + pub flags: __u32, + pub sequence: __u32, + pub user_data: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_create_dumb { + pub height: __u32, + pub width: __u32, + pub bpp: __u32, + pub flags: __u32, + pub handle: __u32, + pub pitch: __u32, + pub size: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_map_dumb { + pub handle: __u32, + pub pad: __u32, + pub offset: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_destroy_dumb { + pub handle: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_atomic { + pub flags: __u32, + pub count_objs: __u32, + pub objs_ptr: __u64, + pub count_props_ptr: __u64, + pub props_ptr: __u64, + pub prop_values_ptr: __u64, + pub reserved: __u64, + pub user_data: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_format_modifier_blob { + pub version: __u32, + pub flags: __u32, + pub count_formats: __u32, + pub formats_offset: __u32, + pub count_modifiers: __u32, + pub modifiers_offset: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_format_modifier { + pub formats: __u64, + pub offset: __u32, + pub pad: __u32, + pub modifier: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_create_blob { + pub data: __u64, + pub length: __u32, + pub blob_id: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_destroy_blob { + pub blob_id: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_create_lease { + pub object_ids: __u64, + pub object_count: __u32, + pub flags: __u32, + pub lessee_id: __u32, + pub fd: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_list_lessees { + pub count_lessees: __u32, + pub pad: __u32, + pub lessees_ptr: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_get_lease { + pub count_objects: __u32, + pub pad: __u32, + pub objects_ptr: __u64, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_revoke_lease { + pub lessee_id: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_rect { + pub x1: __s32, + pub y1: __s32, + pub x2: __s32, + pub y2: __s32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_event { + pub type_: __u32, + pub length: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_event_vblank { + pub base: drm_event, + pub user_data: __u64, + pub tv_sec: __u32, + pub tv_usec: __u32, + pub sequence: __u32, + pub crtc_id: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_event_crtc_sequence { + pub base: drm_event, + pub user_data: __u64, + pub time_ns: __s64, + pub sequence: __u64, +} +pub type drm_clip_rect_t = drm_clip_rect; +pub type drm_drawable_info_t = drm_drawable_info; +pub type drm_tex_region_t = drm_tex_region; +pub type drm_hw_lock_t = drm_hw_lock; +pub type drm_version_t = drm_version; +pub type drm_unique_t = drm_unique; +pub type drm_list_t = drm_list; +pub type drm_block_t = drm_block; +pub type drm_control_t = drm_control; +pub use self::drm_map_flags::Type as drm_map_flags_t; +pub use self::drm_map_type::Type as drm_map_type_t; +pub type drm_ctx_priv_map_t = drm_ctx_priv_map; +pub type drm_map_t = drm_map; +pub type drm_client_t = drm_client; +pub use self::drm_stat_type::Type as drm_stat_type_t; +pub type drm_stats_t = drm_stats; +pub use self::drm_lock_flags::Type as drm_lock_flags_t; +pub type drm_lock_t = drm_lock; +pub use self::drm_dma_flags::Type as drm_dma_flags_t; +pub type drm_buf_desc_t = drm_buf_desc; +pub type drm_buf_info_t = drm_buf_info; +pub type drm_buf_free_t = drm_buf_free; +pub type drm_buf_pub_t = drm_buf_pub; +pub type drm_buf_map_t = drm_buf_map; +pub type drm_dma_t = drm_dma; +pub type drm_wait_vblank_t = drm_wait_vblank; +pub type drm_agp_mode_t = drm_agp_mode; +pub use self::drm_ctx_flags::Type as drm_ctx_flags_t; +pub type drm_ctx_t = drm_ctx; +pub type drm_ctx_res_t = drm_ctx_res; +pub type drm_draw_t = drm_draw; +pub type drm_update_draw_t = drm_update_draw; +pub type drm_auth_t = drm_auth; +pub type drm_irq_busid_t = drm_irq_busid; +pub use self::drm_vblank_seq_type::Type as drm_vblank_seq_type_t; +pub type drm_agp_buffer_t = drm_agp_buffer; +pub type drm_agp_binding_t = drm_agp_binding; +pub type drm_agp_info_t = drm_agp_info; +pub type drm_scatter_gather_t = drm_scatter_gather; +pub type drm_set_version_t = drm_set_version; +pub const DRM_MODE_PROP_SIGNED_RANGE: libc::c_uint = 128; +pub const DRM_MODE_PROP_OBJECT: libc::c_uint = 64; diff --git a/drm-ffi/drm-sys/src/platforms/linux/x86_64/bindings.rs b/drm-ffi/drm-sys/src/platforms/linux/x86_64/bindings.rs index 1990cf3e..9dc94585 100644 --- a/drm-ffi/drm-sys/src/platforms/linux/x86_64/bindings.rs +++ b/drm-ffi/drm-sys/src/platforms/linux/x86_64/bindings.rs @@ -143,7 +143,6 @@ pub const DRM_MODE_CONNECTOR_VIRTUAL: u32 = 15; pub const DRM_MODE_CONNECTOR_DSI: u32 = 16; pub const DRM_MODE_CONNECTOR_DPI: u32 = 17; pub const DRM_MODE_CONNECTOR_WRITEBACK: u32 = 18; -pub const DRM_MODE_CONNECTOR_SPI: u32 = 19; pub const DRM_MODE_PROP_PENDING: u32 = 1; pub const DRM_MODE_PROP_RANGE: u32 = 2; pub const DRM_MODE_PROP_IMMUTABLE: u32 = 4; @@ -885,17 +884,12 @@ pub mod drm_mode_subconnector { pub type Type = libc::c_uint; pub const DRM_MODE_SUBCONNECTOR_Automatic: Type = 0; pub const DRM_MODE_SUBCONNECTOR_Unknown: Type = 0; - pub const DRM_MODE_SUBCONNECTOR_VGA: Type = 1; pub const DRM_MODE_SUBCONNECTOR_DVID: Type = 3; pub const DRM_MODE_SUBCONNECTOR_DVIA: Type = 4; pub const DRM_MODE_SUBCONNECTOR_Composite: Type = 5; pub const DRM_MODE_SUBCONNECTOR_SVIDEO: Type = 6; pub const DRM_MODE_SUBCONNECTOR_Component: Type = 8; pub const DRM_MODE_SUBCONNECTOR_SCART: Type = 9; - pub const DRM_MODE_SUBCONNECTOR_DisplayPort: Type = 10; - pub const DRM_MODE_SUBCONNECTOR_HDMIA: Type = 11; - pub const DRM_MODE_SUBCONNECTOR_Native: Type = 15; - pub const DRM_MODE_SUBCONNECTOR_Wireless: Type = 18; } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] @@ -1052,12 +1046,6 @@ pub struct drm_color_lut { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] -pub struct hdr_metadata_infoframe__bindgen_ty_1 { - pub x: __u16, - pub y: __u16, -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct drm_mode_crtc_page_flip { pub crtc_id: __u32, pub fb_id: __u32, diff --git a/drm-ffi/src/ioctl.rs b/drm-ffi/src/ioctl.rs index d3c949bb..e1f010f2 100644 --- a/drm-ffi/src/ioctl.rs +++ b/drm-ffi/src/ioctl.rs @@ -100,7 +100,12 @@ pub(crate) mod mode { /// Modesetting resources ioctl_readwrite!(get_resources, DRM_IOCTL_BASE, 0xA0, drm_mode_card_res); - ioctl_readwrite!(get_plane_resources, DRM_IOCTL_BASE, 0xB5, drm_mode_get_plane_res); + ioctl_readwrite!( + get_plane_resources, + DRM_IOCTL_BASE, + 0xB5, + drm_mode_get_plane_res + ); /// Connector related functions ioctl_readwrite!(get_connector, DRM_IOCTL_BASE, 0xA7, drm_mode_get_connector); @@ -143,11 +148,26 @@ pub(crate) mod mode { /// Property related functions ioctl_readwrite!(get_property, DRM_IOCTL_BASE, 0xAA, drm_mode_get_property); - ioctl_readwrite!(connector_set_property, DRM_IOCTL_BASE, 0xAB, drm_mode_connector_set_property); - - ioctl_readwrite!(obj_get_properties, DRM_IOCTL_BASE, 0xB9, drm_mode_obj_get_properties); - - ioctl_readwrite!(obj_set_property, DRM_IOCTL_BASE, 0xBA, drm_mode_obj_set_property); + ioctl_readwrite!( + connector_set_property, + DRM_IOCTL_BASE, + 0xAB, + drm_mode_connector_set_property + ); + + ioctl_readwrite!( + obj_get_properties, + DRM_IOCTL_BASE, + 0xB9, + drm_mode_obj_get_properties + ); + + ioctl_readwrite!( + obj_set_property, + DRM_IOCTL_BASE, + 0xBA, + drm_mode_obj_set_property + ); /// Property blobs ioctl_readwrite!(get_blob, DRM_IOCTL_BASE, 0xAC, drm_mode_get_blob); @@ -159,7 +179,12 @@ pub(crate) mod mode { ioctl_readwrite!(destroy_blob, DRM_IOCTL_BASE, 0xBE, drm_mode_destroy_blob); /// Atomic modesetting related functions - ioctl_readwrite!(crtc_page_flip, DRM_IOCTL_BASE, 0xB0, drm_mode_crtc_page_flip); + ioctl_readwrite!( + crtc_page_flip, + DRM_IOCTL_BASE, + 0xB0, + drm_mode_crtc_page_flip + ); ioctl_readwrite!(dirty_fb, DRM_IOCTL_BASE, 0xB1, drm_mode_fb_dirty_cmd); diff --git a/drm-ffi/src/lib.rs b/drm-ffi/src/lib.rs index b8754b18..e73e6317 100644 --- a/drm-ffi/src/lib.rs +++ b/drm-ffi/src/lib.rs @@ -18,8 +18,8 @@ pub(crate) mod utils; use result::SystemError as Error; pub mod gem; pub mod ioctl; -pub mod result; pub mod mode; +pub mod result; use nix::libc::*; use std::os::unix::io::RawFd; diff --git a/drm-ffi/src/mode.rs b/drm-ffi/src/mode.rs index acebaf2b..dce2428c 100644 --- a/drm-ffi/src/mode.rs +++ b/drm-ffi/src/mode.rs @@ -143,7 +143,11 @@ pub fn rm_fb(fd: RawFd, mut id: u32) -> Result<(), Error> { } /// Mark a framebuffer as dirty. -pub fn dirty_fb(fd: RawFd, id: u32, clips: &[drm_clip_rect]) -> Result { +pub fn dirty_fb( + fd: RawFd, + id: u32, + clips: &[drm_clip_rect], +) -> Result { let mut dirty = drm_mode_fb_dirty_cmd { fb_id: id, clips_ptr: clips.as_ptr() as _, @@ -260,7 +264,13 @@ pub fn set_gamma( /// The buffer must be allocated using the buffer manager of the driver (GEM or TTM). It is not /// allowed to be a dumb buffer. #[deprecated = "use a cursor plane instead"] -pub fn set_cursor(fd: RawFd, id: u32, buf_id: u32, w: u32, h: u32) -> Result { +pub fn set_cursor( + fd: RawFd, + id: u32, + buf_id: u32, + w: u32, + h: u32, +) -> Result { let mut cursor = drm_mode_cursor { flags: DRM_MODE_CURSOR_BO, crtc_id: id, @@ -339,7 +349,6 @@ pub fn get_connector( mut modes: Option<&mut Vec>, encoders: Option<&mut &mut [u32]>, ) -> Result { - let modes_count = if modes.is_some() { let mut info = drm_mode_get_connector { connector_id: id, @@ -349,10 +358,12 @@ pub fn get_connector( unsafe { ioctl::mode::get_connector(fd, &mut info)?; } - + info.count_modes - } else { 0 }; - + } else { + 0 + }; + let mut info = drm_mode_get_connector { connector_id: id, props_ptr: map_ptr!(&props), @@ -362,7 +373,7 @@ pub fn get_connector( modes.clear(); modes.reserve_exact(modes_count as usize); modes.as_ptr() as _ - }, + } None => 0 as _, }, encoders_ptr: map_ptr!(&encoders), @@ -510,7 +521,11 @@ pub fn set_connector_property( } /// Get the value of a property blob -pub fn get_property_blob(fd: RawFd, id: u32, data: Option<&mut &mut [u64]>) -> Result { +pub fn get_property_blob( + fd: RawFd, + id: u32, + data: Option<&mut &mut [u64]>, +) -> Result { let mut blob = drm_mode_get_blob { blob_id: id, length: map_len!(&data), diff --git a/drm-ffi/src/result.rs b/drm-ffi/src/result.rs index c888f094..e2f122c9 100644 --- a/drm-ffi/src/result.rs +++ b/drm-ffi/src/result.rs @@ -52,14 +52,19 @@ pub enum SystemError { impl fmt::Display for SystemError { fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> fmt::Result { - write!(fmt, "{}", match self { - SystemError::InvalidFileDescriptor => "invalid file descriptor", - SystemError::MemoryFault => "invalid memory access", - SystemError::InvalidArgument => "invalid argument", - SystemError::InvalidFileType => "invalid file type", - SystemError::PermissionDenied => "permission denied", - SystemError::Unknown { errno } => return write!(fmt, "unknown system error: {}", errno), - }) + write!( + fmt, + "{}", + match self { + SystemError::InvalidFileDescriptor => "invalid file descriptor", + SystemError::MemoryFault => "invalid memory access", + SystemError::InvalidArgument => "invalid argument", + SystemError::InvalidFileType => "invalid file type", + SystemError::PermissionDenied => "permission denied", + SystemError::Unknown { errno } => + return write!(fmt, "unknown system error: {}", errno), + } + ) } } diff --git a/examples/atomic_modeset.rs b/examples/atomic_modeset.rs index 30af3e36..3f340b5a 100644 --- a/examples/atomic_modeset.rs +++ b/examples/atomic_modeset.rs @@ -12,30 +12,45 @@ use drm::buffer::DrmFourcc; use drm::control::ResourceHandle; use drm::control::{self, atomic, connector, crtc, property, AtomicCommitFlags}; -fn find_prop_id(card: &Card, handle: T, name: &'static str) -> Option { - let props = card.get_properties(handle).expect("Could not get props of connector"); +fn find_prop_id( + card: &Card, + handle: T, + name: &'static str, +) -> Option { + let props = card + .get_properties(handle) + .expect("Could not get props of connector"); let (ids, _vals) = props.as_props_and_values(); - ids.iter().find(|&id| { - let info = card.get_property(*id).unwrap(); - info.name().to_str().map(|x| x == name).unwrap_or(false) - }).map(|x| *x) + ids.iter() + .find(|&id| { + let info = card.get_property(*id).unwrap(); + info.name().to_str().map(|x| x == name).unwrap_or(false) + }) + .map(|x| *x) } pub fn main() { let card = Card::open_global(); card.set_client_capability(drm::ClientCapability::UniversalPlanes, true) - .expect("Unable to request UniversalPlanes capability"); + .expect("Unable to request UniversalPlanes capability"); card.set_client_capability(drm::ClientCapability::Atomic, true) - .expect("Unable to request Atomic capability"); - + .expect("Unable to request Atomic capability"); // Load the information. let res = card .resource_handles() .expect("Could not load normal resource ids."); - let coninfo: Vec = res.connectors().iter().flat_map(|con| card.get_connector(*con)).collect(); - let crtcinfo: Vec = res.crtcs().iter().flat_map(|crtc| card.get_crtc(*crtc)).collect(); + let coninfo: Vec = res + .connectors() + .iter() + .flat_map(|con| card.get_connector(*con)) + .collect(); + let crtcinfo: Vec = res + .crtcs() + .iter() + .flat_map(|crtc| card.get_crtc(*crtc)) + .collect(); // Filter each connector until we find one that's connected. let con = coninfo @@ -51,8 +66,8 @@ pub fn main() { .next() .expect("No modes found on connector"); - let (disp_width, disp_height) = mode.size(); - + let (disp_width, disp_height) = mode.size(); + // Find a crtc and FB let crtc = crtcinfo.iter().next().expect("No crtcs found"); @@ -62,44 +77,54 @@ pub fn main() { // Create a DB // If buffer resolution is above display resolution, a ENOSPC (not enough GPU memory) error may // occur - let mut db = card.create_dumb_buffer((disp_width.into(), disp_height.into()), fmt, 32) + let mut db = card + .create_dumb_buffer((disp_width.into(), disp_height.into()), fmt, 32) .expect("Could not create dumb buffer"); // Map it and grey it out. { - let mut map = card.map_dumb_buffer(&mut db).expect("Could not map dumbbuffer"); + let mut map = card + .map_dumb_buffer(&mut db) + .expect("Could not map dumbbuffer"); for b in map.as_mut() { *b = 128; } } // Create an FB: - let fb = card.add_framebuffer(&db, 1, 32).expect("Could not create FB"); + let fb = card + .add_framebuffer(&db, 1, 32) + .expect("Could not create FB"); let planes = card.plane_handles().expect("Could not list planes"); - let (better_planes, compatible_planes): (Vec, Vec) = - planes.planes() - .iter() - .map(|x| *x) - .filter(|plane| { - card.get_plane(*plane).map(|plane_info| { + let (better_planes, compatible_planes): ( + Vec, + Vec, + ) = planes + .planes() + .iter() + .map(|x| *x) + .filter(|plane| { + card.get_plane(*plane) + .map(|plane_info| { let compatible_crtcs = res.filter_crtcs(plane_info.possible_crtcs()); compatible_crtcs.contains(&crtc.handle()) - }).unwrap_or(false) - }) - .partition(|plane| { - if let Ok(props) = card.get_properties(*plane) { - let (ids, vals) = props.as_props_and_values(); - for (&id, &val) in ids.iter().zip(vals.iter()){ - if let Ok(info) = card.get_property(id) { - if info.name().to_str().map(|x| x == "type").unwrap_or(false) { - return val == (drm::control::PlaneType::Primary as u32).into() - } + }) + .unwrap_or(false) + }) + .partition(|plane| { + if let Ok(props) = card.get_properties(*plane) { + let (ids, vals) = props.as_props_and_values(); + for (&id, &val) in ids.iter().zip(vals.iter()) { + if let Ok(info) = card.get_property(id) { + if info.name().to_str().map(|x| x == "type").unwrap_or(false) { + return val == (drm::control::PlaneType::Primary as u32).into(); } } } - false - }); + } + false + }); let plane = *better_planes.get(0).unwrap_or(&compatible_planes[0]); println!("{:#?}", mode); @@ -111,13 +136,15 @@ pub fn main() { atomic_req.add_property( con.handle(), find_prop_id(&card, con.handle(), "CRTC_ID").expect("Could not get CRTC_ID"), - property::Value::CRTC(Some(crtc.handle())) + property::Value::CRTC(Some(crtc.handle())), ); - let blob = card.create_property_blob(mode).expect("Failed to create blob"); + let blob = card + .create_property_blob(mode) + .expect("Failed to create blob"); atomic_req.add_property( crtc.handle(), find_prop_id(&card, crtc.handle(), "MODE_ID").expect("Could not get MODE_ID"), - blob + blob, ); atomic_req.add_property( crtc.handle(), @@ -132,7 +159,7 @@ pub fn main() { atomic_req.add_property( plane, find_prop_id(&card, plane, "CRTC_ID").expect("Could not get CRTC_ID"), - property::Value::CRTC(Some(crtc.handle())) + property::Value::CRTC(Some(crtc.handle())), ); atomic_req.add_property( plane, @@ -147,13 +174,12 @@ pub fn main() { atomic_req.add_property( plane, find_prop_id(&card, plane, "SRC_W").expect("Could not get SRC_W"), - property::Value::UnsignedRange((mode.size().0 as u64) << 16) + property::Value::UnsignedRange((mode.size().0 as u64) << 16), ); atomic_req.add_property( plane, find_prop_id(&card, plane, "SRC_H").expect("Could not get SRC_H"), - property::Value::UnsignedRange((mode.size().1 as u64) << 16) - + property::Value::UnsignedRange((mode.size().1 as u64) << 16), ); atomic_req.add_property( plane, @@ -168,17 +194,18 @@ pub fn main() { atomic_req.add_property( plane, find_prop_id(&card, plane, "CRTC_W").expect("Could not get CRTC_W"), - property::Value::UnsignedRange(mode.size().0 as u64) + property::Value::UnsignedRange(mode.size().0 as u64), ); atomic_req.add_property( plane, find_prop_id(&card, plane, "CRTC_H").expect("Could not get CRTC_H"), - property::Value::UnsignedRange(mode.size().1 as u64) + property::Value::UnsignedRange(mode.size().1 as u64), ); // Set the crtc // On many setups, this requires root access. - card.atomic_commit(&[AtomicCommitFlags::AllowModeset], atomic_req).expect("Failed to set mode"); + card.atomic_commit(&[AtomicCommitFlags::AllowModeset], atomic_req) + .expect("Failed to set mode"); let five_seconds = ::std::time::Duration::from_millis(5000); ::std::thread::sleep(five_seconds); diff --git a/examples/kms_interactive.rs b/examples/kms_interactive.rs index 39a92a0c..1501c8a9 100644 --- a/examples/kms_interactive.rs +++ b/examples/kms_interactive.rs @@ -26,13 +26,15 @@ fn run_repl(card: &Card) { images::load_image("1.png"), images::load_image("2.png"), images::load_image("3.png"), - images::load_image("4.png") + images::load_image("4.png"), ]; for image in &images { // Create the Dumbbuffer let fmt = drm::buffer::DrmFourcc::Argb8888; - let mut db = card.create_dumb_buffer(image.dimensions(), fmt, 32).unwrap(); + let mut db = card + .create_dumb_buffer(image.dimensions(), fmt, 32) + .unwrap(); // Create a Framebuffer to represent it let _fb = card.add_framebuffer(&db, 1, 32).unwrap(); @@ -69,20 +71,19 @@ fn run_repl(card: &Card) { let args: Vec<_> = line.split_whitespace().collect(); match &args[..] { ["Quit"] => break, - args => println!("{:?}", args) + args => println!("{:?}", args), } } - }, + } // Destroying a framebuffer ["DestroyFramebuffer", handle] => { let handle: u32 = str::parse(handle).unwrap(); - let handle: drm::control::framebuffer::Handle = unsafe { - std::mem::transmute(handle) - }; + let handle: drm::control::framebuffer::Handle = + unsafe { std::mem::transmute(handle) }; if let Err(err) = card.destroy_framebuffer(handle) { println!("Unable to destroy framebuffer ({:?}): {}", handle, err); } - }, + } // Print out all resources ["GetResources"] => { let resources = card.resource_handles().unwrap(); @@ -92,48 +93,39 @@ fn run_repl(card: &Card) { println!("\tFramebuffers: {:?}", resources.framebuffers()); let planes = card.plane_handles().unwrap(); println!("\tPlanes: {:?}", planes.planes()); - }, + } // Print out the values of a specific property ["GetProperty", handle] => { let handle: u32 = str::parse(handle).unwrap(); - let handle: drm::control::property::Handle = unsafe { - std::mem::transmute(handle) - }; + let handle: drm::control::property::Handle = unsafe { std::mem::transmute(handle) }; let property = card.get_property(handle).unwrap(); println!("\tName: {:?}", property.name()); println!("\tMutable: {:?}", property.mutable()); println!("\tAtomic: {:?}", property.atomic()); println!("\tValue: {:#?}", property.value_type()); - }, + } // Get the property-value pairs of a single resource - ["GetProperties", handle] => { - match HandleWithProperties::from_str(card, handle) { - Ok(handle) => { - let props = match handle { - HandleWithProperties::Connector(handle) => { - card.get_properties(handle).unwrap() - }, - HandleWithProperties::CRTC(handle) => { - card.get_properties(handle).unwrap() - }, - HandleWithProperties::Plane(handle) => { - card.get_properties(handle).unwrap() - } - }; - let (ids, vals) = props.as_props_and_values(); - for (id, val) in ids.iter().zip(vals.iter()) { - println!("\tProperty: {:?}\tValue: {:?}", id, val); + ["GetProperties", handle] => match HandleWithProperties::from_str(card, handle) { + Ok(handle) => { + let props = match handle { + HandleWithProperties::Connector(handle) => { + card.get_properties(handle).unwrap() } - }, - Err(_) => println!("Unknown handle or handle has no properties") + HandleWithProperties::CRTC(handle) => card.get_properties(handle).unwrap(), + HandleWithProperties::Plane(handle) => card.get_properties(handle).unwrap(), + }; + let (ids, vals) = props.as_props_and_values(); + for (id, val) in ids.iter().zip(vals.iter()) { + println!("\tProperty: {:?}\tValue: {:?}", id, val); + } } + Err(_) => println!("Unknown handle or handle has no properties"), }, // Set a property's value on a resource ["SetProperty", handle, property, value] => { let property: u32 = str::parse(property).unwrap(); - let property: drm::control::property::Handle = unsafe { - std::mem::transmute(property) - }; + let property: drm::control::property::Handle = + unsafe { std::mem::transmute(property) }; let value: u64 = str::parse(value).unwrap(); match HandleWithProperties::from_str(card, handle) { @@ -141,30 +133,28 @@ fn run_repl(card: &Card) { match handle { HandleWithProperties::Connector(handle) => { println!("\t{:?}", card.set_property(handle, property, value)); - }, + } HandleWithProperties::CRTC(handle) => { println!("\t{:?}", card.set_property(handle, property, value)); - }, + } HandleWithProperties::Plane(handle) => { println!("\t{:?}", card.set_property(handle, property, value)); } }; - }, - Err(_) => println!("Unknown handle or handle has no properties") + } + Err(_) => println!("Unknown handle or handle has no properties"), }; - }, - ["GetModes", handle] => { - match HandleWithProperties::from_str(card, handle) { - Ok(HandleWithProperties::Connector(handle)) => { - let modes = card.get_modes(handle).unwrap(); - for mode in modes { - println!("\tName:\t{:?}", mode.name()); - println!("\t\tSize:\t{:?}", mode.size()); - println!("\t\tRefresh:\t{:?}", mode.vrefresh()); - } - }, - _ => println!("Unknown handle or handle is not a connector") + } + ["GetModes", handle] => match HandleWithProperties::from_str(card, handle) { + Ok(HandleWithProperties::Connector(handle)) => { + let modes = card.get_modes(handle).unwrap(); + for mode in modes { + println!("\tName:\t{:?}", mode.name()); + println!("\t\tSize:\t{:?}", mode.size()); + println!("\t\tRefresh:\t{:?}", mode.vrefresh()); + } } + _ => println!("Unknown handle or handle is not a connector"), }, ["help"] => { println!("CreateAtomicSet"); @@ -176,10 +166,10 @@ fn run_repl(card: &Card) { println!("GetModes "); } ["quit"] => break, - [ ] => (), + [] => (), _ => { println!("Unknown command"); - }, + } } } } diff --git a/examples/legacy_modeset.rs b/examples/legacy_modeset.rs index 328766c4..ab07f7cf 100644 --- a/examples/legacy_modeset.rs +++ b/examples/legacy_modeset.rs @@ -17,8 +17,16 @@ pub fn main() { let res = card .resource_handles() .expect("Could not load normal resource ids."); - let coninfo: Vec = res.connectors().iter().flat_map(|con| card.get_connector(*con)).collect(); - let crtcinfo: Vec = res.crtcs().iter().flat_map(|crtc| card.get_crtc(*crtc)).collect(); + let coninfo: Vec = res + .connectors() + .iter() + .flat_map(|con| card.get_connector(*con)) + .collect(); + let crtcinfo: Vec = res + .crtcs() + .iter() + .flat_map(|crtc| card.get_crtc(*crtc)) + .collect(); // Filter each connector until we find one that's connected. let con = coninfo @@ -34,8 +42,8 @@ pub fn main() { .next() .expect("No modes found on connector"); - let (disp_width, disp_height) = mode.size(); - + let (disp_width, disp_height) = mode.size(); + // Find a crtc and FB let crtc = crtcinfo.iter().next().expect("No crtcs found"); @@ -45,19 +53,24 @@ pub fn main() { // Create a DB // If buffer resolution is larger than display resolution, an ENOSPC (not enough video memory) // error may occur - let mut db = card.create_dumb_buffer((disp_width.into(), disp_height.into()), fmt, 32) + let mut db = card + .create_dumb_buffer((disp_width.into(), disp_height.into()), fmt, 32) .expect("Could not create dumb buffer"); // Map it and grey it out. { - let mut map = card.map_dumb_buffer(&mut db).expect("Could not map dumbbuffer"); + let mut map = card + .map_dumb_buffer(&mut db) + .expect("Could not map dumbbuffer"); for b in map.as_mut() { *b = 128; } } // Create an FB: - let fb = card.add_framebuffer(&db, 1, 32).expect("Could not create FB"); + let fb = card + .add_framebuffer(&db, 1, 32) + .expect("Could not create FB"); println!("{:#?}", mode); println!("{:#?}", fb); @@ -65,14 +78,8 @@ pub fn main() { // Set the crtc // On many setups, this requires root access. - card.set_crtc( - crtc.handle(), - Some(fb), - (0, 0), - &[con.handle()], - Some(mode), - ) - .expect("Could not set CRTC"); + card.set_crtc(crtc.handle(), Some(fb), (0, 0), &[con.handle()], Some(mode)) + .expect("Could not set CRTC"); let five_seconds = ::std::time::Duration::from_millis(5000); ::std::thread::sleep(five_seconds); diff --git a/examples/utils/mod.rs b/examples/utils/mod.rs index c1b4bc15..fa205edd 100644 --- a/examples/utils/mod.rs +++ b/examples/utils/mod.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] -pub use drm::Device; pub use drm::control::Device as ControlDevice; +pub use drm::Device; -pub use drm::control::ResourceHandle; pub use drm::control::property::*; +pub use drm::control::ResourceHandle; #[derive(Debug)] /// A simple wrapper for a device node. @@ -38,11 +38,7 @@ impl Card { pub mod capabilities { use drm::ClientCapability as CC; - pub const CLIENT_CAP_ENUMS: &[CC] = &[ - CC::Stereo3D, - CC::UniversalPlanes, - CC::Atomic - ]; + pub const CLIENT_CAP_ENUMS: &[CC] = &[CC::Stereo3D, CC::UniversalPlanes, CC::Atomic]; use drm::DriverCapability as DC; pub const DRIVER_CAP_ENUMS: &[DC] = &[ @@ -70,4 +66,3 @@ pub mod images { image::open(path).unwrap().to_rgba8() } } - diff --git a/src/buffer/mod.rs b/src/buffer/mod.rs index 0030dbf9..bc5700c0 100644 --- a/src/buffer/mod.rs +++ b/src/buffer/mod.rs @@ -24,7 +24,7 @@ //! like a regular one. This allows better control and security, and is the //! recommended method of sharing buffers. -pub use drm_fourcc::{DrmFourcc, UnrecognizedFourcc, DrmModifier, DrmVendor, UnrecognizedVendor}; +pub use drm_fourcc::{DrmFourcc, DrmModifier, DrmVendor, UnrecognizedFourcc, UnrecognizedVendor}; /// A handle to a GEM buffer. /// @@ -37,15 +37,15 @@ pub use drm_fourcc::{DrmFourcc, UnrecognizedFourcc, DrmModifier, DrmVendor, Unre #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub struct Handle(::control::RawResourceHandle); -impl Into<::control::RawResourceHandle> for Handle { - fn into(self) -> ::control::RawResourceHandle { - self.0 +impl From for ::control::RawResourceHandle { + fn from(handle: Handle) -> Self { + handle.0 } } -impl Into for Handle { - fn into(self) -> u32 { - self.0.into() +impl From for u32 { + fn from(handle: Handle) -> Self { + handle.0.into() } } @@ -57,9 +57,7 @@ impl From<::control::RawResourceHandle> for Handle { impl std::fmt::Debug for Handle { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_tuple("buffer::Handle") - .field(&self.0) - .finish() + f.debug_tuple("buffer::Handle").field(&self.0).finish() } } @@ -74,17 +72,15 @@ impl std::fmt::Debug for Handle { #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub struct Name(u32); -impl Into for Name { - fn into(self) -> u32 { - self.0.into() +impl From for u32 { + fn from(name: Name) -> u32 { + name.0 } } impl std::fmt::Debug for Name { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_tuple("buffer::Name") - .field(&self.0) - .finish() + f.debug_tuple("buffer::Name").field(&self.0).finish() } } @@ -136,4 +132,4 @@ impl PlanarBuffer for B { fn offsets(&self) -> [u32; 4] { [0; 4] } -} \ No newline at end of file +} diff --git a/src/control/atomic.rs b/src/control/atomic.rs index 1a5470a2..761d9909 100644 --- a/src/control/atomic.rs +++ b/src/control/atomic.rs @@ -11,9 +11,8 @@ pub struct AtomicModeReq { pub(super) values: Vec, } -impl AtomicModeReq { - /// Create a new and empty atomic commit request - pub fn new() -> AtomicModeReq { +impl Default for AtomicModeReq { + fn default() -> Self { AtomicModeReq { objects: Vec::new(), count_props_per_object: Vec::new(), @@ -21,6 +20,13 @@ impl AtomicModeReq { values: Vec::new(), } } +} + +impl AtomicModeReq { + /// Create a new and empty atomic commit request + pub fn new() -> AtomicModeReq { + Self::default() + } /// Add a property and value pair for a given raw resource to the request pub fn add_raw_property( @@ -31,33 +37,33 @@ impl AtomicModeReq { ) { // add object if missing (also to count_props_per_object) let (idx, prop_count) = match self.objects.binary_search(&obj_id) { - Ok(idx) => { - (idx, self.count_props_per_object[idx]) - }, + Ok(idx) => (idx, self.count_props_per_object[idx]), Err(new_idx) => { self.objects.insert(new_idx, obj_id); self.count_props_per_object.insert(new_idx, 0); (new_idx, 0) - }, + } }; // get start of our objects props - let prop_slice_start = self.count_props_per_object.iter().take(idx).fold(0, |acc, x| acc + x) as usize; + let prop_slice_start = self.count_props_per_object.iter().take(idx).sum::() as usize; // get end let prop_slice_end = prop_slice_start + prop_count as usize; // search for existing prop entry - match self.props[prop_slice_start..prop_slice_end].binary_search_by_key(&Into::::into(prop_id), |x| (*x).into()) { + match self.props[prop_slice_start..prop_slice_end] + .binary_search_by_key(&Into::::into(prop_id), |x| (*x).into()) + { // prop exists, override Ok(prop_idx) => { self.values[prop_slice_start + prop_idx] = value; - }, + } Err(prop_idx) => { // increase prop count self.count_props_per_object[idx] += 1; // insert prop, insert value self.props.insert(prop_slice_start + prop_idx, prop_id); - self.values.insert(prop_slice_start + prop_idx, value); + self.values.insert(prop_slice_start + prop_idx, value); } } } @@ -69,8 +75,8 @@ impl AtomicModeReq { property: control::property::Handle, value: control::property::Value, ) where - H: control::ResourceHandle + H: control::ResourceHandle, { self.add_raw_property(handle.into(), property, value.into()) } -} \ No newline at end of file +} diff --git a/src/control/connector.rs b/src/control/connector.rs index 94461991..0d8e8b81 100644 --- a/src/control/connector.rs +++ b/src/control/connector.rs @@ -14,15 +14,15 @@ use drm_ffi as ffi; #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub struct Handle(control::RawResourceHandle); -impl Into for Handle { - fn into(self) -> control::RawResourceHandle { - self.0 +impl From for control::RawResourceHandle { + fn from(handle: Handle) -> Self { + handle.0 } } -impl Into for Handle { - fn into(self) -> u32 { - self.0.into() +impl From for u32 { + fn from(handle: Handle) -> Self { + handle.0.into() } } @@ -38,9 +38,7 @@ impl control::ResourceHandle for Handle { impl std::fmt::Debug for Handle { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_tuple("connector::Handle") - .field(&self.0) - .finish() + f.debug_tuple("connector::Handle").field(&self.0).finish() } } @@ -92,7 +90,7 @@ impl Info { } /// Returns a list of modes this connector reports as supported. - pub fn modes(&self) -> &[control::Mode] { + pub fn modes(&self) -> &[control::Mode] { &self.modes } @@ -104,6 +102,7 @@ impl Info { /// A physical interface type. #[allow(missing_docs)] +#[allow(clippy::upper_case_acronyms)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum Interface { Unknown, @@ -152,9 +151,9 @@ impl From for Interface { } } -impl Into for Interface { - fn into(self) -> u32 { - match self { +impl From for u32 { + fn from(interface: Interface) -> Self { + match interface { Interface::Unknown => ffi::DRM_MODE_CONNECTOR_Unknown, Interface::VGA => ffi::DRM_MODE_CONNECTOR_VGA, Interface::DVII => ffi::DRM_MODE_CONNECTOR_DVII, @@ -198,11 +197,11 @@ impl From for State { } } -impl Into for State { - fn into(self) -> u32 { +impl From for u32 { + fn from(state: State) -> Self { // These variables are not defined in drm_mode.h for some reason. // They were copied from libdrm's xf86DrmMode.h - match self { + match state { State::Connected => 1, State::Disconnected => 2, State::Unknown => 3, diff --git a/src/control/crtc.rs b/src/control/crtc.rs index 2e300532..30bc71fd 100644 --- a/src/control/crtc.rs +++ b/src/control/crtc.rs @@ -19,15 +19,15 @@ use drm_ffi as ffi; #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub struct Handle(control::RawResourceHandle); -impl Into for Handle { - fn into(self) -> control::RawResourceHandle { - self.0 +impl From for control::RawResourceHandle { + fn from(handle: Handle) -> Self { + handle.0 } } -impl Into for Handle { - fn into(self) -> u32 { - self.0.into() +impl From for u32 { + fn from(handle: Handle) -> Self { + handle.0.into() } } @@ -43,9 +43,7 @@ impl control::ResourceHandle for Handle { impl std::fmt::Debug for Handle { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_tuple("crtc::Handle") - .field(&self.0) - .finish() + f.debug_tuple("crtc::Handle").field(&self.0).finish() } } diff --git a/src/control/encoder.rs b/src/control/encoder.rs index 60e0f76b..8d4fa4f3 100644 --- a/src/control/encoder.rs +++ b/src/control/encoder.rs @@ -10,15 +10,15 @@ use drm_ffi as ffi; #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub struct Handle(control::RawResourceHandle); -impl Into for Handle { - fn into(self) -> control::RawResourceHandle { - self.0 +impl From for control::RawResourceHandle { + fn from(handle: Handle) -> Self { + handle.0 } } -impl Into for Handle { - fn into(self) -> u32 { - self.0.into() +impl From for u32 { + fn from(handle: Handle) -> Self { + handle.0.into() } } @@ -34,9 +34,7 @@ impl control::ResourceHandle for Handle { impl std::fmt::Debug for Handle { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_tuple("encoder::Handle") - .field(&self.0) - .finish() + f.debug_tuple("encoder::Handle").field(&self.0).finish() } } @@ -79,6 +77,7 @@ impl Info { /// The type of encoder. #[allow(missing_docs)] +#[allow(clippy::upper_case_acronyms)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum Kind { None, @@ -109,9 +108,9 @@ impl From for Kind { } } -impl Into for Kind { - fn into(self) -> u32 { - match self { +impl From for u32 { + fn from(kind: Kind) -> Self { + match kind { Kind::None => ffi::DRM_MODE_ENCODER_NONE, Kind::DAC => ffi::DRM_MODE_ENCODER_DAC, Kind::TMDS => ffi::DRM_MODE_ENCODER_TMDS, diff --git a/src/control/framebuffer.rs b/src/control/framebuffer.rs index 3746c24a..9c178e2c 100644 --- a/src/control/framebuffer.rs +++ b/src/control/framebuffer.rs @@ -10,15 +10,15 @@ use drm_ffi as ffi; #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub struct Handle(control::RawResourceHandle); -impl Into for Handle { - fn into(self) -> control::RawResourceHandle { - self.0 +impl From for control::RawResourceHandle { + fn from(handle: Handle) -> Self { + handle.0 } } -impl Into for Handle { - fn into(self) -> u32 { - self.0.into() +impl From for u32 { + fn from(handle: Handle) -> Self { + handle.0.into() } } @@ -34,9 +34,7 @@ impl control::ResourceHandle for Handle { impl std::fmt::Debug for Handle { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_tuple("framebuffer::Handle") - .field(&self.0) - .finish() + f.debug_tuple("framebuffer::Handle").field(&self.0).finish() } } diff --git a/src/control/mod.rs b/src/control/mod.rs index 471ae822..4b1f66a3 100644 --- a/src/control/mod.rs +++ b/src/control/mod.rs @@ -55,7 +55,9 @@ use core::num::NonZeroU32; pub type RawResourceHandle = NonZeroU32; /// Handle for a drm resource -pub trait ResourceHandle : From + Into + Into + Copy + Sized { +pub trait ResourceHandle: + From + Into + Into + Copy + Sized +{ /// Associated encoded object type const FFI_TYPE: u32; } @@ -64,7 +66,7 @@ pub trait ResourceHandle : From + Into + I /// /// Note: This does no verification on the validity of the original value pub fn from_u32(raw: u32) -> Option { - RawResourceHandle::new(raw).map(|n| T::from(n)) + RawResourceHandle::new(raw).map(T::from) } /// This trait should be implemented by any object that acts as a DRM device and @@ -74,7 +76,7 @@ pub fn from_u32(raw: u32) -> Option { /// provide a concrete object for this trait. /// /// # Example -/// ``` +/// ```ignore /// use drm::control::Device as ControlDevice; /// /// // Assuming the `Card` wrapper already implements drm::Device @@ -99,7 +101,7 @@ pub trait Device: super::Device { Some(&mut crtc_slice), Some(&mut conn_slice), Some(&mut enc_slice), - )?; + )?; let fb_len = fb_slice.len(); let crtc_len = crtc_slice.len(); @@ -108,13 +110,13 @@ pub trait Device: super::Device { let res = ResourceHandles { fbs: unsafe { mem::transmute(fbs) }, - fb_len: fb_len, + fb_len, crtcs: unsafe { mem::transmute(crtcs) }, - crtc_len: crtc_len, + crtc_len, connectors: unsafe { mem::transmute(connectors) }, - conn_len: conn_len, + conn_len, encoders: unsafe { mem::transmute(encoders) }, - enc_len: enc_len, + enc_len, width: (ffi_res.min_width, ffi_res.max_width), height: (ffi_res.min_height, ffi_res.max_height), }; @@ -133,7 +135,7 @@ pub trait Device: super::Device { let res = PlaneResourceHandles { planes: unsafe { mem::transmute(planes) }, - plane_len: plane_len, + plane_len, }; Ok(res) @@ -153,10 +155,10 @@ pub trait Device: super::Device { None, Some(&mut modes), Some(&mut enc_slice), - )?; + )?; let connector = connector::Info { - handle: handle, + handle, interface: connector::Interface::from(ffi_info.connector_type), interface_id: ffi_info.connector_type_id, connection: connector::State::from(ffi_info.connection), @@ -174,13 +176,10 @@ pub trait Device: super::Device { /// Returns information about a specific encoder fn get_encoder(&self, handle: encoder::Handle) -> Result { - let info = ffi::mode::get_encoder( - self.as_raw_fd(), - handle.into(), - )?; + let info = ffi::mode::get_encoder(self.as_raw_fd(), handle.into())?; let enc = encoder::Info { - handle: handle, + handle, enc_type: encoder::Kind::from(info.encoder_type), crtc: from_u32(info.crtc_id), pos_crtcs: info.possible_crtcs, @@ -192,13 +191,10 @@ pub trait Device: super::Device { /// Returns information about a specific CRTC fn get_crtc(&self, handle: crtc::Handle) -> Result { - let info = ffi::mode::get_crtc( - self.as_raw_fd(), - handle.into(), - )?; + let info = ffi::mode::get_crtc(self.as_raw_fd(), handle.into())?; let crtc = crtc::Info { - handle: handle, + handle, position: (info.x, info.y), mode: match info.mode_valid { 0 => None, @@ -224,8 +220,9 @@ pub trait Device: super::Device { self.as_raw_fd(), handle.into(), framebuffer.map(|x| x.into()).unwrap_or(0), - pos.0, pos.1, - unsafe { mem::transmute(conns) }, + pos.0, + pos.1, + unsafe { &*(conns as *const _ as *const [u32]) }, unsafe { mem::transmute(mode) }, )?; @@ -236,14 +233,11 @@ pub trait Device: super::Device { fn get_framebuffer( &self, handle: framebuffer::Handle, - ) -> Result { - let info = ffi::mode::get_framebuffer( - self.as_raw_fd(), - handle.into(), - )?; + ) -> Result { + let info = ffi::mode::get_framebuffer(self.as_raw_fd(), handle.into())?; let fb = framebuffer::Info { - handle: handle, + handle, size: (info.width, info.height), pitch: info.pitch, bpp: info.bpp, @@ -267,7 +261,8 @@ pub trait Device: super::Device { let (w, h) = buffer.size(); let info = ffi::mode::add_fb( self.as_raw_fd(), - w, h, + w, + h, buffer.pitch(), bpp, depth, @@ -276,7 +271,7 @@ pub trait Device: super::Device { Ok(unsafe { mem::transmute(info.fb_id) }) } - + /// Add framebuffer (with modifiers) fn add_planar_framebuffer( &self, @@ -304,7 +299,8 @@ pub trait Device: super::Device { let info = ffi::mode::add_fb2( self.as_raw_fd(), - w, h, + w, + h, planar_buffer.format() as u32, &handles, &planar_buffer.pitches(), @@ -317,7 +313,11 @@ pub trait Device: super::Device { } /// Mark parts of a framebuffer dirty - fn dirty_framebuffer(&self, handle: framebuffer::Handle, clips: &[ClipRect]) -> Result<(), SystemError> { + fn dirty_framebuffer( + &self, + handle: framebuffer::Handle, + clips: &[ClipRect], + ) -> Result<(), SystemError> { ffi::mode::dirty_fb(self.as_raw_fd(), handle.into(), &clips)?; Ok(()) } @@ -332,28 +332,24 @@ pub trait Device: super::Device { let mut formats = [0u32; 8]; let mut fmt_slice = &mut formats[..]; - let info = ffi::mode::get_plane( - self.as_raw_fd(), - handle.into(), - Some(&mut fmt_slice) - )?; + let info = ffi::mode::get_plane(self.as_raw_fd(), handle.into(), Some(&mut fmt_slice))?; let fmt_len = fmt_slice.len(); let plane = plane::Info { - handle: handle, + handle, crtc: from_u32(info.crtc_id), fb: from_u32(info.fb_id), pos_crtcs: info.possible_crtcs, - formats: formats, - fmt_len: fmt_len + formats, + fmt_len, }; Ok(plane) } /// Set plane state. - /// + /// /// Providing no framebuffer clears the plane. fn set_plane( &self, @@ -370,8 +366,14 @@ pub trait Device: super::Device { crtc.into(), framebuffer.map(Into::into).unwrap_or(0), flags, - crtc_rect.0, crtc_rect.1, crtc_rect.2, crtc_rect.3, - src_rect.0, src_rect.1, src_rect.2, src_rect.3, + crtc_rect.0, + crtc_rect.1, + crtc_rect.2, + crtc_rect.3, + src_rect.0, + src_rect.1, + src_rect.2, + src_rect.3, )?; Ok(()) @@ -389,8 +391,8 @@ pub trait Device: super::Device { self.as_raw_fd(), handle.into(), Some(&mut val_slice), - Some(&mut enum_slice) - )?; + Some(&mut enum_slice), + )?; let val_len = val_slice.len(); @@ -404,7 +406,7 @@ pub trait Device: super::Device { match (min, max) { (0, 1) => ValueType::Boolean, - (min, max) => ValueType::UnsignedRange(min, max) + (min, max) => ValueType::UnsignedRange(min, max), } } else if flags & ffi::DRM_MODE_PROP_SIGNED_RANGE != 0 { let min = values[0]; @@ -413,9 +415,9 @@ pub trait Device: super::Device { ValueType::SignedRange(min as i64, max as i64) } else if flags & ffi::DRM_MODE_PROP_ENUM != 0 { let enum_values = self::property::EnumValues { - values: values, + values, enums: unsafe { mem::transmute(enums) }, - length: val_len + length: val_len, }; ValueType::Enum(enum_values) @@ -441,11 +443,11 @@ pub trait Device: super::Device { }; let property = property::Info { - handle: handle, - val_type: val_type, + handle, + val_type, mutable: info.flags & ffi::DRM_MODE_PROP_IMMUTABLE == 0, atomic: info.flags & ffi::DRM_MODE_PROP_ATOMIC == 0, - info: info + info, }; Ok(property) @@ -456,16 +458,15 @@ pub trait Device: super::Device { &self, handle: T, prop: property::Handle, - value: property::RawValue - ) -> Result<(), SystemError> { - + value: property::RawValue, + ) -> Result<(), SystemError> { ffi::mode::set_property( self.as_raw_fd(), prop.into(), handle.into(), T::FFI_TYPE, - value - )?; + value, + )?; Ok(()) } @@ -475,14 +476,11 @@ pub trait Device: super::Device { let mut raw_mode: ffi::drm_mode_modeinfo = mode.into(); let data = unsafe { std::slice::from_raw_parts_mut( - mem::transmute(&mut raw_mode as *mut ffi::drm_mode_modeinfo), - mem::size_of::() + &mut raw_mode as *mut _ as *mut u64, + mem::size_of::(), ) }; - let blob = ffi::mode::create_property_blob( - self.as_raw_fd(), - data, - )?; + let blob = ffi::mode::create_property_blob(self.as_raw_fd(), data)?; Ok(property::Value::Blob(blob.blob_id.into())) } @@ -505,13 +503,16 @@ pub trait Device: super::Device { None, Some(&mut modes), None, - )?; + )?; Ok(unsafe { mem::transmute(modes) }) } /// Gets a list of property handles and values for this resource. - fn get_properties(&self, handle: T) -> Result { + fn get_properties( + &self, + handle: T, + ) -> Result { let mut prop_ids = [0u32; 32]; let mut prop_vals = [0u64; 32]; @@ -524,25 +525,31 @@ pub trait Device: super::Device { T::FFI_TYPE, Some(&mut prop_id_slice), Some(&mut prop_val_slice), - )?; + )?; let prop_len = prop_id_slice.len(); let prop_val_set = PropertyValueSet { prop_ids: unsafe { mem::transmute(prop_ids) }, prop_vals: unsafe { mem::transmute(prop_vals) }, - len: prop_len + len: prop_len, }; Ok(prop_val_set) } - + /// Receive the currently set gamma ramp of a crtc - fn get_gamma(&self, crtc: crtc::Handle, red: &mut [u16], green: &mut [u16], blue: &mut [u16]) -> Result<(), SystemError> { + fn get_gamma( + &self, + crtc: crtc::Handle, + red: &mut [u16], + green: &mut [u16], + blue: &mut [u16], + ) -> Result<(), SystemError> { let crtc_info = self.get_crtc(crtc)?; - if crtc_info.gamma_length as usize > red.len() || - crtc_info.gamma_length as usize > green.len() || - crtc_info.gamma_length as usize > blue.len() + if crtc_info.gamma_length as usize > red.len() + || crtc_info.gamma_length as usize > green.len() + || crtc_info.gamma_length as usize > blue.len() { return Err(SystemError::InvalidArgument); } @@ -553,29 +560,35 @@ pub trait Device: super::Device { crtc_info.gamma_length as usize, red, green, - blue + blue, )?; Ok(()) } /// Set a gamma ramp for the given crtc - fn set_gamma(&self, crtc: crtc::Handle, red: &[u16], green: &[u16], blue: &[u16]) -> Result<(), SystemError> { + fn set_gamma( + &self, + crtc: crtc::Handle, + red: &[u16], + green: &[u16], + blue: &[u16], + ) -> Result<(), SystemError> { let crtc_info = self.get_crtc(crtc)?; - if crtc_info.gamma_length as usize > red.len() || - crtc_info.gamma_length as usize > green.len() || - crtc_info.gamma_length as usize > blue.len() + if crtc_info.gamma_length as usize > red.len() + || crtc_info.gamma_length as usize > green.len() + || crtc_info.gamma_length as usize > blue.len() { return Err(SystemError::InvalidArgument); } - + ffi::mode::set_gamma( self.as_raw_fd(), crtc.into(), crtc_info.gamma_length as usize, red, green, - blue + blue, )?; Ok(()) @@ -592,7 +605,7 @@ pub trait Device: super::Device { let _info = drm_ffi::gem::close(self.as_raw_fd(), handle.into())?; Ok(()) } - + /// Create a new dumb buffer with a given size and pixel format fn create_dumb_buffer( &self, @@ -613,17 +626,20 @@ pub trait Device: super::Device { Ok(dumb) } /// Map the buffer for access - fn map_dumb_buffer<'a>(&self, buffer: &'a mut DumbBuffer) -> Result, SystemError> { + fn map_dumb_buffer<'a>( + &self, + buffer: &'a mut DumbBuffer, + ) -> Result, SystemError> { let info = drm_ffi::mode::dumbbuffer::map(self.as_raw_fd(), buffer.handle.into(), 0, 0)?; let map = { - use ::nix::sys::mman; + use nix::sys::mman; let addr = core::ptr::null_mut(); let prot = mman::ProtFlags::PROT_READ | mman::ProtFlags::PROT_WRITE; let flags = mman::MapFlags::MAP_SHARED; let length = buffer.length; let fd = self.as_raw_fd(); - let offset = info.offset as i64; + let offset = info.offset as _; unsafe { mman::mmap(addr, length, prot, flags, fd, offset)? } }; @@ -668,7 +684,12 @@ pub trait Device: super::Device { /// A buffer argument of `None` will clear the cursor. #[deprecated(note = "Usage of deprecated ioctl set_cursor2: use a cursor plane instead")] #[allow(deprecated)] - fn set_cursor2(&self, crtc: crtc::Handle, buffer: Option<&B>, hotspot: (i32, i32)) -> Result<(), SystemError> + fn set_cursor2( + &self, + crtc: crtc::Handle, + buffer: Option<&B>, + hotspot: (i32, i32), + ) -> Result<(), SystemError> where B: buffer::Buffer + ?Sized, { @@ -678,7 +699,15 @@ pub trait Device: super::Device { (buf.handle().into(), w, h) }) .unwrap_or((0, 0, 0)); - drm_ffi::mode::set_cursor2(self.as_raw_fd(), crtc.into(), id, w, h, hotspot.0, hotspot.1)?; + drm_ffi::mode::set_cursor2( + self.as_raw_fd(), + crtc.into(), + id, + w, + h, + hotspot.0, + hotspot.1, + )?; Ok(()) } @@ -693,15 +722,17 @@ pub trait Device: super::Device { } /// Request an atomic commit with given flags and property-value pair for a list of objects. - fn atomic_commit(&self, flags: &[AtomicCommitFlags], mut req: atomic::AtomicModeReq) -> Result<(), SystemError> { - use std::mem::transmute as tm; - + fn atomic_commit( + &self, + flags: &[AtomicCommitFlags], + mut req: atomic::AtomicModeReq, + ) -> Result<(), SystemError> { drm_ffi::mode::atomic_commit( self.as_raw_fd(), flags.iter().fold(0, |acc, x| acc | *x as u32), - unsafe { tm(&mut *req.objects) }, + unsafe { &mut *(&mut *req.objects as *mut _ as *mut [u32]) }, &mut *req.count_props_per_object, - unsafe { tm(&mut *req.props) }, + unsafe { &mut *(&mut *req.props as *mut _ as *mut [u32]) }, &mut *req.values, ) } @@ -717,16 +748,16 @@ pub trait Device: super::Device { let info = ffi::gem::handle_to_fd(self.as_raw_fd(), handle.into(), flags)?; Ok(info.fd) } - + /// Queue a page flip on the given crtc fn page_flip( &self, handle: crtc::Handle, framebuffer: framebuffer::Handle, flags: &[PageFlipFlags], - target: Option + target: Option, ) -> Result<(), SystemError> { - let mut flags = flags.into_iter().fold(0, |val, flag| val | *flag as u32); + let mut flags = flags.iter().fold(0, |val, flag| val | *flag as u32); if target.is_some() { flags |= ffi::drm_sys::DRM_MODE_PAGE_FLIP_TARGET; } @@ -744,11 +775,12 @@ pub trait Device: super::Device { /// Receive pending events fn receive_events(&self) -> Result - where Self: Sized + where + Self: Sized, { let mut event_buf: [u8; 1024] = [0; 1024]; let amount = ::nix::unistd::read(self.as_raw_fd(), &mut event_buf)?; - + Ok(Events { event_buf, amount, @@ -757,7 +789,6 @@ pub trait Device: super::Device { } } - #[repr(u32)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] /// Flags to alter the behaviour of a page flip @@ -820,26 +851,42 @@ impl Iterator for Events { fn next(&mut self) -> Option { if self.amount > 0 && self.i < self.amount { - let event = unsafe { &*(self.event_buf.as_ptr().offset(self.i as isize) as *const ffi::drm_event) }; + let event = unsafe { &*(self.event_buf.as_ptr().add(self.i) as *const ffi::drm_event) }; self.i += event.length as usize; match event.type_ { x if x == ffi::DRM_EVENT_VBLANK => { - let vblank_event: &ffi::drm_event_vblank = unsafe { mem::transmute(event) }; + let vblank_event = + unsafe { &*(event as *const _ as *const ffi::drm_event_vblank) }; Some(Event::Vblank(VblankEvent { frame: vblank_event.sequence, - duration: Duration::new(vblank_event.tv_sec as u64, vblank_event.tv_usec * 100), + duration: Duration::new( + vblank_event.tv_sec as u64, + vblank_event.tv_usec * 100, + ), crtc: unsafe { mem::transmute(vblank_event.user_data as u32) }, })) - }, + } x if x == ffi::DRM_EVENT_FLIP_COMPLETE => { - let vblank_event: &ffi::drm_event_vblank = unsafe { mem::transmute(event) }; + let vblank_event = + unsafe { &*(event as *const _ as *const ffi::drm_event_vblank) }; Some(Event::PageFlip(PageFlipEvent { frame: vblank_event.sequence, - duration: Duration::new(vblank_event.tv_sec as u64, vblank_event.tv_usec * 1000), - crtc: unsafe { mem::transmute(if vblank_event.crtc_id != 0 { vblank_event.crtc_id } else { vblank_event.user_data as u32 }) }, + duration: Duration::new( + vblank_event.tv_sec as u64, + vblank_event.tv_usec * 1000, + ), + crtc: unsafe { + mem::transmute(if vblank_event.crtc_id != 0 { + vblank_event.crtc_id + } else { + vblank_event.user_data as u32 + }) + }, })) - }, - _ => Some(Event::Unknown(self.event_buf[self.i-(event.length as usize)..self.i].to_vec())), + } + _ => Some(Event::Unknown( + self.event_buf[self.i - (event.length as usize)..self.i].to_vec(), + )), } } else { None @@ -867,25 +914,25 @@ impl ResourceHandles { /// Returns the set of [connector::Handle] pub fn connectors(&self) -> &[connector::Handle] { let buf_len = std::cmp::min(self.connectors.len(), self.conn_len); - unsafe { mem::transmute(&self.connectors[..buf_len]) } + unsafe { &*(&self.connectors[..buf_len] as *const _ as *const [connector::Handle]) } } /// Returns the set of [encoder::Handle] pub fn encoders(&self) -> &[encoder::Handle] { let buf_len = std::cmp::min(self.encoders.len(), self.enc_len); - unsafe { mem::transmute(&self.encoders[..buf_len]) } + unsafe { &*(&self.encoders[..buf_len] as *const _ as *const [encoder::Handle]) } } /// Returns the set of [crtc::Handle] pub fn crtcs(&self) -> &[crtc::Handle] { let buf_len = std::cmp::min(self.crtcs.len(), self.crtc_len); - unsafe { mem::transmute(&self.crtcs[..buf_len]) } + unsafe { &*(&self.crtcs[..buf_len] as *const _ as *const [crtc::Handle]) } } /// Returns the set of [framebuffer::Handle] pub fn framebuffers(&self) -> &[framebuffer::Handle] { let buf_len = std::cmp::min(self.fbs.len(), self.fb_len); - unsafe { mem::transmute(&self.fbs[..buf_len]) } + unsafe { &*(&self.fbs[..buf_len] as *const _ as *const [framebuffer::Handle]) } } /// Apply a filter the all crtcs of these resources, resulting in a list of crtcs allowed. @@ -924,7 +971,7 @@ impl PlaneResourceHandles { /// Returns the set of [plane::Handle] pub fn planes(&self) -> &[plane::Handle] { let buf_len = std::cmp::min(self.planes.len(), self.plane_len); - unsafe { mem::transmute(&self.planes[..buf_len]) } + unsafe { &*(&self.planes[..buf_len] as *const _ as *const [plane::Handle]) } } } @@ -999,9 +1046,9 @@ impl From for Mode { } } -impl Into for Mode { - fn into(self) -> ffi::drm_mode_modeinfo { - self.mode +impl From for ffi::drm_mode_modeinfo { + fn from(mode: Mode) -> Self { + mode.mode } } @@ -1037,20 +1084,25 @@ pub enum PlaneType { pub struct PropertyValueSet { prop_ids: [Option; 32], prop_vals: [property::RawValue; 32], - len: usize + len: usize, } impl PropertyValueSet { /// Returns a pair representing a set of [property::Handle] and their raw values pub fn as_props_and_values(&self) -> (&[property::Handle], &[property::RawValue]) { unsafe { - mem::transmute((&self.prop_ids[..self.len], &self.prop_vals[..self.len])) + ( + &*(&self.prop_ids[..self.len] as *const _ as *const [property::Handle]), + &*(&self.prop_vals[..self.len] as *const _ as *const [property::RawValue]), + ) } } } type ClipRect = ffi::drm_sys::drm_clip_rect; +/// Commit flags for atomic mode setting +#[allow(missing_docs)] #[repr(u32)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] /// Flags for an atomic commit @@ -1058,7 +1110,7 @@ pub enum AtomicCommitFlags { /// Test only validity of the request, do not actually apply the requested changes. TestOnly = ffi::drm_sys::DRM_MODE_ATOMIC_TEST_ONLY, /// Do not block on the request and return early. - Nonblock = ffi::drm_sys::DRM_MODE_ATOMIC_NONBLOCK, + Nonblock = ffi::drm_sys::DRM_MODE_ATOMIC_NONBLOCK, /// Allow the changes to trigger a modeset, if necessary. /// /// Changes requiring a modeset are rejected otherwise. diff --git a/src/control/plane.rs b/src/control/plane.rs index ff637236..e81b61d5 100644 --- a/src/control/plane.rs +++ b/src/control/plane.rs @@ -23,15 +23,15 @@ use drm_ffi as ffi; #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub struct Handle(control::RawResourceHandle); -impl Into for Handle { - fn into(self) -> control::RawResourceHandle { - self.0 +impl From for control::RawResourceHandle { + fn from(handle: Handle) -> Self { + handle.0 } } -impl Into for Handle { - fn into(self) -> u32 { - self.0.into() +impl From for u32 { + fn from(handle: Handle) -> Self { + handle.0.into() } } @@ -47,9 +47,7 @@ impl control::ResourceHandle for Handle { impl std::fmt::Debug for Handle { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_tuple("plane::Handle") - .field(&self.0) - .finish() + f.debug_tuple("plane::Handle").field(&self.0).finish() } } @@ -61,7 +59,7 @@ pub struct Info { pub(crate) fb: Option, pub(crate) pos_crtcs: u32, pub(crate) formats: [u32; 8], - pub(crate) fmt_len: usize + pub(crate) fmt_len: usize, } impl Info { diff --git a/src/control/property.rs b/src/control/property.rs index 71e6968b..aa7d9b50 100644 --- a/src/control/property.rs +++ b/src/control/property.rs @@ -22,15 +22,15 @@ pub type RawValue = u64; #[derive(Copy, Clone, Hash, PartialEq, Eq)] pub struct Handle(control::RawResourceHandle); -impl Into for Handle { - fn into(self) -> control::RawResourceHandle { - self.0 +impl From for control::RawResourceHandle { + fn from(handle: Handle) -> Self { + handle.0 } } -impl Into for Handle { - fn into(self) -> u32 { - self.0.into() +impl From for u32 { + fn from(handle: Handle) -> Self { + handle.0.into() } } @@ -46,9 +46,7 @@ impl control::ResourceHandle for Handle { impl std::fmt::Debug for Handle { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_tuple("property::Handle") - .field(&self.0) - .finish() + f.debug_tuple("property::Handle").field(&self.0).finish() } } @@ -59,7 +57,7 @@ pub struct Info { pub(crate) val_type: ValueType, pub(crate) mutable: bool, pub(crate) atomic: bool, - pub(crate) info: ffi::drm_mode_get_property + pub(crate) info: ffi::drm_mode_get_property, } impl Info { @@ -85,6 +83,7 @@ impl Info { } /// A `ValueType` describes the types of value that a property uses. +#[allow(clippy::upper_case_acronyms)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum ValueType { /// A catch-all for any unknown types @@ -132,16 +131,18 @@ impl ValueType { ValueType::Blob => Value::Blob(value), ValueType::Object => Value::Object(unsafe { tm(value as u32) }), ValueType::CRTC => Value::CRTC(unsafe { tm(value as u32) }), - ValueType::Connector => Value::Connector(unsafe { tm (value as u32) }), - ValueType::Encoder => Value::Encoder(unsafe { tm (value as u32) }), - ValueType::Framebuffer => Value::Framebuffer(unsafe { tm (value as u32) }), - ValueType::Plane => Value::Plane(unsafe { tm (value as u32) }), - ValueType::Property => Value::Property(unsafe { tm (value as u32) }), + ValueType::Connector => Value::Connector(unsafe { tm(value as u32) }), + ValueType::Encoder => Value::Encoder(unsafe { tm(value as u32) }), + ValueType::Framebuffer => Value::Framebuffer(unsafe { tm(value as u32) }), + ValueType::Plane => Value::Plane(unsafe { tm(value as u32) }), + ValueType::Property => Value::Property(unsafe { tm(value as u32) }), } } } /// The value of a property, in a typed format +#[allow(missing_docs)] +#[allow(clippy::upper_case_acronyms)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum Value<'a> { /// Unknown value @@ -174,13 +175,19 @@ pub enum Value<'a> { Property(Option), } -impl<'a> Into for Value<'a> { - fn into(self) -> RawValue { +impl<'a> From> for RawValue { + fn from(value: Value<'a>) -> Self { use std::mem::transmute as tm; - match self { + match value { Value::Unknown(x) => x, - Value::Boolean(x) => if x { 1 } else { 0 }, + Value::Boolean(x) => { + if x { + 1 + } else { + 0 + } + } Value::UnsignedRange(x) => x, Value::SignedRange(x) => x as u64, Value::Enum(val) => val.value(), @@ -256,4 +263,3 @@ impl std::fmt::Debug for EnumValues { .finish() } } - diff --git a/src/lib.rs b/src/lib.rs index 28d3a737..a7ed007f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,13 +31,13 @@ extern crate core; extern crate drm_ffi; -extern crate nix; extern crate drm_fourcc; +extern crate nix; pub(crate) mod util; -pub mod control; pub mod buffer; +pub mod control; use std::os::unix::io::AsRawFd; @@ -204,11 +204,7 @@ pub trait Device: AsRawFd { let date = SmallOsString::from_i8_buffer(date, date_len); let desc = SmallOsString::from_i8_buffer(desc, desc_len); - let driver = Driver { - name: name, - date: date, - desc: desc, - }; + let driver = Driver { name, date, desc }; Ok(driver) } diff --git a/src/util.rs b/src/util.rs index ef65c22f..c1e4f27e 100644 --- a/src/util.rs +++ b/src/util.rs @@ -15,10 +15,7 @@ pub struct SmallOsString { impl SmallOsString { pub fn from_u8_buffer(data: [u8; 32], len: usize) -> Self { - Self { - data: data, - len: len, - } + Self { data, len } } pub fn from_i8_buffer(data: [i8; 32], len: usize) -> Self { @@ -59,19 +56,19 @@ impl fmt::Display for SmallOsString { match ::std::str::from_utf8(input) { Ok(valid) => { write!(f, "{}", valid)?; - break + break; } Err(error) => { let (valid, after_valid) = input.split_at(error.valid_up_to()); unsafe { write!(f, "{}", ::std::str::from_utf8_unchecked(valid))?; } - write!(f, "{}", "\u{FFFD}")?; + write!(f, "\u{FFFD}")?; if let Some(invalid_sequence_length) = error.error_len() { input = &after_valid[invalid_sequence_length..] } else { - break + break; } } }