Skip to content

Commit

Permalink
Add DRM node abstraction (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisduerr authored Sep 24, 2024
1 parent 0db7924 commit 6dcff91
Show file tree
Hide file tree
Showing 8 changed files with 436 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
command: update
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.65.0
toolchain: 1.66.0
profile: minimal
components: clippy
default: true
Expand All @@ -88,12 +88,12 @@ jobs:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-rust_1.65.0-${{ hashFiles('**/Cargo.toml') }}
key: ${{ runner.os }}-cargo-rust_1.66.0-${{ hashFiles('**/Cargo.toml') }}
- name: Build cache
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-build-rust_1.65.0-check-${{ hashFiles('**/Cargo.toml') }}
key: ${{ runner.os }}-build-rust_1.66.0-check-${{ hashFiles('**/Cargo.toml') }}
- name: Clippy
uses: actions-rs/clippy-check@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "0.12.0"
license = "MIT"
authors = ["Tyler Slabinski <[email protected]>", "Victoria Brekenfeld <[email protected]>"]
exclude = [".gitignore", ".github"]
rust-version = "1.65"
rust-version = "1.66"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion drm-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository = "https://github.com/Smithay/drm-rs"
version = "0.8.0"
license = "MIT"
authors = ["Tyler Slabinski <[email protected]>"]
rust-version = "1.65"
rust-version = "1.66"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion drm-ffi/drm-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "0.7.0"
authors = ["Tyler Slabinski <[email protected]>"]
license = "MIT"
build = "build.rs"
rust-version = "1.65"
rust-version = "1.66"
edition = "2021"

[features]
Expand Down
10 changes: 2 additions & 8 deletions drm-ffi/src/mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ pub fn get_connector(
} else {
&tmp_mode as *const _ as _
},
count_modes: if force_probe { 0 } else { 1 },
count_modes: u32::from(!force_probe),
..Default::default()
};

Expand Down Expand Up @@ -427,13 +427,7 @@ pub fn get_connector(
prop_values_ptr: map_ptr!(&prop_values),
count_modes: match &modes {
Some(b) => b.capacity() as _,
None => {
if force_probe {
0
} else {
1
}
}
None => u32::from(!force_probe),
},
count_props: map_len!(&props),
count_encoders: map_len!(&encoders),
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub(crate) mod util;

pub mod buffer;
pub mod control;
pub mod node;

use std::ffi::{OsStr, OsString};
use std::time::Duration;
Expand Down
45 changes: 45 additions & 0 deletions src/node/constants.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//! OS-Specific DRM constants.
/// DRM major value.
#[cfg(target_os = "dragonfly")]
pub const DRM_MAJOR: u32 = 145;

/// DRM major value.
#[cfg(target_os = "netbsd")]
pub const DRM_MAJOR: u32 = 34;

/// DRM major value.
#[cfg(all(target_os = "openbsd", target_arch = "x86"))]
pub const DRM_MAJOR: u32 = 88;

/// DRM major value.
#[cfg(all(target_os = "openbsd", not(target_arch = "x86")))]
pub const DRM_MAJOR: u32 = 87;

/// DRM major value.
#[cfg(not(any(target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd")))]
pub const DRM_MAJOR: u32 = 226;

/// Primary DRM node prefix.
#[cfg(not(target_os = "openbsd"))]
pub const PRIMARY_NAME: &str = "card";

/// Primary DRM node prefix.
#[cfg(target_os = "openbsd")]
pub const PRIMARY_NAME: &str = "drm";

/// Control DRM node prefix.
#[cfg(not(target_os = "openbsd"))]
pub const CONTROL_NAME: &str = "controlD";

/// Control DRM node prefix.
#[cfg(target_os = "openbsd")]
pub const CONTROL_NAME: &str = "drmC";

/// Render DRM node prefix.
#[cfg(not(target_os = "openbsd"))]
pub const RENDER_NAME: &str = "renderD";

/// Render DRM node prefix.
#[cfg(target_os = "openbsd")]
pub const RENDER_NAME: &str = "drmR";
Loading

0 comments on commit 6dcff91

Please sign in to comment.