Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update drm sys to get new caps #190

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/fetch_headers.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 12 additions & 1 deletion drm-ffi/drm-sys/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)]
Expand All @@ -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)]
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions drm-ffi/src/syncobj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub fn wait(
},
first_signaled: 0,
pad: 0,
deadline_nsec: 0,
};

unsafe {
Expand Down Expand Up @@ -181,6 +182,7 @@ pub fn timeline_wait(
},
first_signaled: 0,
pad: 0,
deadline_nsec: 0,
};

unsafe {
Expand Down
4 changes: 4 additions & 0 deletions src/control/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
use super::util::*;

use std::collections::HashMap;
use std::convert::TryFrom;

Check warning on line 54 in src/control/mod.rs

View workflow job for this annotation

GitHub Actions / check-minimal

the item `TryFrom` is imported redundantly

Check warning on line 54 in src/control/mod.rs

View workflow job for this annotation

GitHub Actions / test (channels, ubuntu-22.04, beta, x86_64-unknown-linux-gnu)

the item `TryFrom` is imported redundantly

Check warning on line 54 in src/control/mod.rs

View workflow job for this annotation

GitHub Actions / test (channels, ubuntu-22.04, beta, x86_64-unknown-linux-gnu)

the item `TryFrom` is imported redundantly

Check warning on line 54 in src/control/mod.rs

View workflow job for this annotation

GitHub Actions / test (channels, ubuntu-22.04, nightly, x86_64-unknown-linux-gnu)

the item `TryFrom` is imported redundantly

Check warning on line 54 in src/control/mod.rs

View workflow job for this annotation

GitHub Actions / test (channels, ubuntu-22.04, nightly, x86_64-unknown-linux-gnu)

the item `TryFrom` is imported redundantly
use std::error;
use std::fmt;
use std::io;
Expand Down Expand Up @@ -1129,6 +1129,8 @@
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 {
Expand All @@ -1143,6 +1145,8 @@
}))
}
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 {
Expand Down
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading