diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dc8b2c..445a5ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,6 +67,8 @@ jobs: - run: | sudo apt-get update -y sudo apt-get install -y libdrm-dev + - name: Fetch drm headers + run: ./.github/workflows/fetch_headers.sh - name: Update deps uses: actions-rs/cargo@v1 with: @@ -105,6 +107,8 @@ jobs: - run: | sudo apt-get update -y sudo apt-get install -y libdrm-dev + - name: Fetch drm headers + run: ./.github/workflows/fetch_headers.sh - name: Update deps uses: actions-rs/cargo@v1 with: @@ -193,12 +197,7 @@ jobs: echo "CARGO_TARGET_${ENV_TARGET}_LINKER=${GCC_TARGET}-gcc" >> $GITHUB_ENV echo "BINDGEN_EXTRA_CLANG_ARGS=--sysroot=/usr/${GCC_TARGET}" >> $GITHUB_ENV - name: Fetch drm headers - run: | - mkdir drm - wget -O drm/drm.h https://github.com/torvalds/linux/raw/master/include/uapi/drm/drm.h - wget -O drm/drm_mode.h https://github.com/torvalds/linux/raw/master/include/uapi/drm/drm_mode.h - echo "LIBDRM_INCLUDE_PATH=${PWD}/drm" >> $GITHUB_ENV - echo "BINDGEN_EXTRA_CLANG_ARGS=-D __user= ${BINDGEN_EXTRA_CLANG_ARGS}" >> $GITHUB_ENV + run: ./.github/workflows/fetch_headers.sh - name: Setup Rust uses: actions-rs/toolchain@v1 with: diff --git a/.github/workflows/fetch_headers.sh b/.github/workflows/fetch_headers.sh new file mode 100755 index 0000000..ae4b416 --- /dev/null +++ b/.github/workflows/fetch_headers.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +mkdir drm +wget -O drm/drm.h https://github.com/torvalds/linux/raw/master/include/uapi/drm/drm.h +wget -O drm/drm_mode.h https://github.com/torvalds/linux/raw/master/include/uapi/drm/drm_mode.h +echo "LIBDRM_INCLUDE_PATH=${PWD}/drm" >> $GITHUB_ENV +echo "BINDGEN_EXTRA_CLANG_ARGS=-D __user= ${BINDGEN_EXTRA_CLANG_ARGS}" >> $GITHUB_ENV diff --git a/drm-ffi/drm-sys/src/bindings.rs b/drm-ffi/drm-sys/src/bindings.rs index d90c4b6..7ce9b66 100644 --- a/drm-ffi/drm-sys/src/bindings.rs +++ b/drm-ffi/drm-sys/src/bindings.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.69.1 */ +/* automatically generated by rust-bindgen 0.69.4 */ pub const DRM_NAME: &[u8; 4] = b"drm\0"; pub const DRM_MIN_ORDER: u32 = 5; @@ -25,17 +25,20 @@ 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_CAP_ATOMIC_ASYNC_PAGE_FLIP: u32 = 21; 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_CLIENT_CAP_CURSOR_PLANE_HOTSPOT: u32 = 6; 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_WAIT_FLAGS_WAIT_DEADLINE: u32 = 8; 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; @@ -839,6 +842,7 @@ pub struct drm_syncobj_wait { pub flags: __u32, pub first_signaled: __u32, pub pad: __u32, + pub deadline_nsec: __u64, } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] @@ -850,6 +854,7 @@ pub struct drm_syncobj_timeline_wait { pub flags: __u32, pub first_signaled: __u32, pub pad: __u32, + pub deadline_nsec: __u64, } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] @@ -1324,6 +1329,12 @@ pub struct drm_mode_rect { } #[repr(C)] #[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] +pub struct drm_mode_closefb { + pub fb_id: __u32, + pub pad: __u32, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)] pub struct drm_event { pub type_: __u32, pub length: __u32, diff --git a/drm-ffi/src/syncobj.rs b/drm-ffi/src/syncobj.rs index 6cb45a9..cc9863e 100644 --- a/drm-ffi/src/syncobj.rs +++ b/drm-ffi/src/syncobj.rs @@ -110,6 +110,7 @@ pub fn wait( }, first_signaled: 0, pad: 0, + deadline_nsec: 0, }; unsafe { @@ -181,6 +182,7 @@ pub fn timeline_wait( }, first_signaled: 0, pad: 0, + deadline_nsec: 0, }; unsafe { diff --git a/src/control/mod.rs b/src/control/mod.rs index 2b6f946..049e4ea 100644 --- a/src/control/mod.rs +++ b/src/control/mod.rs @@ -1129,6 +1129,8 @@ impl Iterator for Events { self.i += event.length as usize; match event.type_ { ffi::DRM_EVENT_VBLANK => { + #[allow(unknown_lints)] + #[allow(invalid_reference_casting)] let vblank_event = unsafe { &*(event as *const _ as *const ffi::drm_event_vblank) }; Some(Event::Vblank(VblankEvent { @@ -1143,6 +1145,8 @@ impl Iterator for Events { })) } ffi::DRM_EVENT_FLIP_COMPLETE => { + #[allow(unknown_lints)] + #[allow(invalid_reference_casting)] let vblank_event = unsafe { &*(event as *const _ as *const ffi::drm_event_vblank) }; Some(Event::PageFlip(PageFlipEvent { diff --git a/src/lib.rs b/src/lib.rs index 76e80c3..f5299a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -282,6 +282,8 @@ pub enum DriverCapability { MonotonicTimestamp = drm_ffi::DRM_CAP_TIMESTAMP_MONOTONIC as u64, /// Asynchronous page flipping support ASyncPageFlip = drm_ffi::DRM_CAP_ASYNC_PAGE_FLIP as u64, + /// Asynchronous page flipping support for atomic API + AtomicASyncPageFlip = drm_ffi::DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP as u64, /// Width of cursor buffers CursorWidth = drm_ffi::DRM_CAP_CURSOR_WIDTH as u64, /// Height of cursor buffers @@ -308,6 +310,24 @@ pub enum ClientCapability { UniversalPlanes = drm_ffi::DRM_CLIENT_CAP_UNIVERSAL_PLANES as u64, /// The driver provides atomic modesetting Atomic = drm_ffi::DRM_CLIENT_CAP_ATOMIC as u64, + /// If set to 1, the DRM core will provide aspect ratio information in modes. + AspectRatio = drm_ffi::DRM_CLIENT_CAP_ASPECT_RATIO as u64, + /// If set to 1, the DRM core will expose special connectors to be used for + /// writing back to memory the scene setup in the commit. + /// + /// The client must enable [`Self::Atomic`] first. + WritebackConnectors = drm_ffi::DRM_CLIENT_CAP_WRITEBACK_CONNECTORS as u64, + /// Drivers for para-virtualized hardware have additional restrictions for cursor planes e.g. + /// they need cursor planes to act like one would expect from a mouse + /// cursor and have correctly set hotspot properties. + /// If this client cap is not set the DRM core will hide cursor plane on + /// those virtualized drivers because not setting it implies that the + /// client is not capable of dealing with those extra restictions. + /// Clients which do set cursor hotspot and treat the cursor plane + /// like a mouse cursor should set this property. + /// + /// The client must enable [`Self::Atomic`] first. + CursorPlaneHotspot = drm_ffi::DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT as u64, } /// Used to specify a vblank sequence to wait for