Skip to content
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
21 changes: 13 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ jobs:
components: clippy
default: true
override: true
- name: Downgrade home
run: cargo update -p home --precise 0.5.5
- name: Downgrade (transitive) dependencies
run: |
cargo update -p home --precise 0.5.5
cargo update -p fdeflate --precise 0.3.5
cargo update -p flate2 --precise 1.0.35
- name: Cargo cache
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -234,9 +237,9 @@ jobs:
run: cp drm-ffi/drm-sys/src/bindings.rs bindings-${{ matrix.target }}.rs
- name: Upload bindings
if: matrix.task == 'bindings'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bindings
name: bindings-${{ matrix.target }}-${{ matrix.rust }}
path: bindings-*.rs
- name: Build
uses: actions-rs/cargo@v1
Expand All @@ -259,9 +262,10 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: download bindings
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings
pattern: bindings-*
merge-multiple: true
- name: compare
run: |
code=0
Expand All @@ -286,9 +290,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: download bindings
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bindings
pattern: bindings-*
merge-multiple: true
- name: Copy x86_64 bindings
run: |
cp bindings-x86_64-unknown-linux-gnu.rs drm-ffi/drm-sys/src/bindings.rs
Expand Down
12 changes: 6 additions & 6 deletions drm-ffi/drm-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod use_bindgen {
}

fn create_builder(contents: &str) -> Builder {
println!("{}", contents);
println!("{contents}");

let pkgconf = pkg_config::Config::new();
let include_paths = if let Ok(value) = var("LIBDRM_INCLUDE_PATH") {
Expand Down Expand Up @@ -82,27 +82,27 @@ mod use_bindgen {

// Create a name for a temporary value
fn tmp_val(name: &str) -> String {
format!("{}{}", TMP_BIND_PREFIX, name)
format!("{TMP_BIND_PREFIX}{name}")
}

// Create a C include directive
fn include(header: &str) -> String {
format!("#include <{}>", header)
format!("#include <{header}>")
}

// Create a C constant
fn decl_const(ty: &str, name: &str, value: &str) -> String {
format!("const {} {} = {};", ty, name, value)
format!("const {ty} {name} = {value};")
}

// Create a C macro definition
fn define_macro(name: &str, val: &str) -> String {
format!("#define {} {}", name, val)
format!("#define {name} {val}")
}

// Create a C undefinition
fn undefine_macro(name: &str) -> String {
format!("#undef {}", name)
format!("#undef {name}")
}

// Rebind a C macro as a constant
Expand Down
12 changes: 11 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.4 */
/* automatically generated by rust-bindgen 0.69.5 */

pub const DRM_NAME: &[u8; 4] = b"drm\0";
pub const DRM_MIN_ORDER: u32 = 5;
Expand Down Expand Up @@ -34,14 +34,17 @@ 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_FD_TO_HANDLE_FLAGS_TIMELINE: u32 = 2;
pub const DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE: u32 = 1;
pub const DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_TIMELINE: u32 = 2;
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;
pub const DRM_CLIENT_NAME_MAX_LEN: u32 = 64;
pub const DRM_CONNECTOR_NAME_LEN: u32 = 32;
pub const DRM_DISPLAY_MODE_LEN: u32 = 32;
pub const DRM_PROP_NAME_LEN: u32 = 32;
Expand Down Expand Up @@ -822,6 +825,7 @@ pub struct drm_syncobj_handle {
pub flags: __u32,
pub fd: __s32,
pub pad: __u32,
pub point: __u64,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down Expand Up @@ -898,6 +902,12 @@ pub struct drm_crtc_queue_sequence {
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct drm_set_client_name {
pub name_len: __u64,
pub name: __u64,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
pub struct drm_mode_modeinfo {
pub clock: __u32,
pub hdisplay: __u16,
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 @@ -54,6 +54,7 @@ pub fn handle_to_fd(
},
fd: 0,
pad: 0,
point: 0, // TODO: Add support for TIMELINE sync files
};

unsafe {
Expand All @@ -78,6 +79,7 @@ pub fn fd_to_handle(
},
fd: syncobj_fd.as_raw_fd(),
pad: 0,
point: 0, // TODO: Add support for TIMELINE sync files
};

unsafe {
Expand Down
8 changes: 4 additions & 4 deletions examples/atomic_modeset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ pub fn main() {
});
let plane = *better_planes.first().unwrap_or(&compatible_planes[0]);

println!("{:#?}", mode);
println!("{:#?}", fb);
println!("{:#?}", db);
println!("{:#?}", plane);
println!("{mode:#?}");
println!("{fb:#?}");
println!("{db:#?}");
println!("{plane:#?}");

let con_props = card
.get_properties(con.handle())
Expand Down
10 changes: 5 additions & 5 deletions examples/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ impl Card {
fn print_busid(fd: BorrowedFd<'_>) {
let mut buffer = Vec::new();
let busid = ffi::get_bus_id(fd, Some(&mut buffer));
println!("{:#?}", busid);
println!("{busid:#?}");
}

fn print_client(fd: BorrowedFd<'_>) {
let client = ffi::get_client(fd, 0);
println!("{:#?}", client);
println!("{client:#?}");
}

fn print_version(fd: BorrowedFd<'_>) {
Expand All @@ -45,22 +45,22 @@ fn print_version(fd: BorrowedFd<'_>) {

let version = ffi::get_version(fd, Some(&mut name), Some(&mut date), Some(&mut desc));

println!("{:#?}", version);
println!("{version:#?}");
}

fn print_capabilities(fd: BorrowedFd<'_>) {
for cty in 1.. {
let cap = ffi::get_capability(fd, cty);
match cap {
Ok(_) => println!("{:#?}", cap),
Ok(_) => println!("{cap:#?}"),
Err(_) => break,
}
}
}

fn print_token(fd: BorrowedFd<'_>) {
let token = ffi::auth::get_magic_token(fd);
println!("{:#?}", token);
println!("{token:#?}");
}

fn main() {
Expand Down
10 changes: 5 additions & 5 deletions examples/kms_interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub fn main() {
// Enable all possible client capabilities
for &cap in capabilities::CLIENT_CAP_ENUMS {
if let Err(e) = card.set_client_capability(cap, true) {
eprintln!("Unable to activate capability {:?}: {}", cap, e);
eprintln!("Unable to activate capability {cap:?}: {e}");
return;
}
}
Expand Down Expand Up @@ -69,7 +69,7 @@ fn run_repl(card: &Card) {
let args: Vec<_> = line.split_whitespace().collect();
match &args[..] {
["Quit"] => break,
args => println!("{:?}", args),
args => println!("{args:?}"),
}
}
}
Expand All @@ -78,7 +78,7 @@ fn run_repl(card: &Card) {
let handle: u32 = str::parse(handle).unwrap();
let handle: drm::control::framebuffer::Handle = from_u32(handle).unwrap();
if let Err(err) = card.destroy_framebuffer(handle) {
println!("Unable to destroy framebuffer ({:?}): {}", handle, err);
println!("Unable to destroy framebuffer ({handle:?}): {err}");
}
}
// Print out all resources
Expand All @@ -89,7 +89,7 @@ fn run_repl(card: &Card) {
println!("\tCRTCS: {:?}", resources.crtcs());
println!("\tFramebuffers: {:?}", resources.framebuffers());
let planes = card.plane_handles().unwrap();
println!("\tPlanes: {:?}", planes);
println!("\tPlanes: {planes:?}");
}
// Print out the values of a specific property
["GetProperty", handle] => {
Expand All @@ -112,7 +112,7 @@ fn run_repl(card: &Card) {
HandleWithProperties::Plane(handle) => card.get_properties(handle).unwrap(),
};
for (id, val) in props.iter() {
println!("\tProperty: {:?}\tValue: {:?}", id, val);
println!("\tProperty: {id:?}\tValue: {val:?}");
}
}
Err(_) => println!("Unknown handle or handle has no properties"),
Expand Down
6 changes: 3 additions & 3 deletions examples/legacy_modeset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ pub fn main() {
.add_framebuffer(&db, 24, 32)
.expect("Could not create FB");

println!("{:#?}", mode);
println!("{:#?}", fb);
println!("{:#?}", db);
println!("{mode:#?}");
println!("{fb:#?}");
println!("{db:#?}");

// Set the crtc
// On many setups, this requires root access.
Expand Down
4 changes: 2 additions & 2 deletions examples/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn print_properties<T: drm::control::ResourceHandle>(card: &Card, handle: T) {
let props = card.get_properties(handle).unwrap();

for (&id, &val) in props.iter() {
println!("Property: {:?}", id);
println!("Property: {id:?}");
let info = card.get_property(id).unwrap();
println!("{:?}", info.name());
println!("{:#?}", info.value_type());
Expand All @@ -23,7 +23,7 @@ pub fn main() {
// Enable all possible client capabilities
for &cap in capabilities::CLIENT_CAP_ENUMS {
if let Err(e) = card.set_client_capability(cap, true) {
eprintln!("Unable to activate capability {:?}: {}", cap, e);
eprintln!("Unable to activate capability {cap:?}: {e}");
return;
}
}
Expand Down
16 changes: 8 additions & 8 deletions examples/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn main() {
// Enable all possible client capabilities
for &cap in capabilities::CLIENT_CAP_ENUMS {
if let Err(e) = card.set_client_capability(cap, true) {
eprintln!("Unable to activate capability {:?}: {}", cap, e);
eprintln!("Unable to activate capability {cap:?}: {e}");
return;
}
}
Expand All @@ -21,34 +21,34 @@ pub fn main() {
println!("Encoders:\t{:?}", resources.encoders());
println!("CRTCs:\t\t{:?}", resources.crtcs());
println!("Framebuffers:\t{:?}", resources.framebuffers());
println!("Planes:\t\t{:?}", plane_res);
println!("Planes:\t\t{plane_res:?}");

for &handle in resources.connectors() {
let info = card.get_connector(handle, false).unwrap();
println!("Connector: {:?}", handle);
println!("Connector: {handle:?}");
println!("\t{:?}-{}", info.interface(), info.interface_id());
println!("\t{:?}", info.state());
println!("\t{:?}", info.size());
println!("\t{:?}", info.encoders());
println!("\t{:?}", info.current_encoder());

for mode in card.get_modes(handle).unwrap() {
println!("{:?}", mode);
println!("{mode:?}");
}
}
println!("\n");

for &handle in resources.encoders() {
let info = card.get_encoder(handle).unwrap();
println!("Encoder: {:?}", handle);
println!("Encoder: {handle:?}");
println!("\t{:?}", info.kind());
println!("\t{:?}", info.crtc());
}
println!("\n");

for &handle in resources.crtcs() {
let info = card.get_crtc(handle).unwrap();
println!("CRTC: {:?}", handle);
println!("CRTC: {handle:?}");
println!("\tPosition: {:?}", info.position());
println!("\tMode: {:?}", info.mode());
println!("\tFramebuffer: {:?}", info.framebuffer());
Expand All @@ -58,7 +58,7 @@ pub fn main() {

for &handle in resources.framebuffers() {
let info = card.get_framebuffer(handle).unwrap();
println!("Framebuffer: {:?}", handle);
println!("Framebuffer: {handle:?}");
println!("\tSize: {:?}", info.size());
println!("\tPitch: {:?}", info.pitch());
println!("\tBPP: {:?}", info.bpp());
Expand All @@ -69,7 +69,7 @@ pub fn main() {

for handle in plane_res {
let info = card.get_plane(handle).unwrap();
println!("Plane: {:?}", handle);
println!("Plane: {handle:?}");
println!("\tCRTC: {:?}", info.crtc());
println!("\tFramebuffer: {:?}", info.framebuffer());
println!("\tFormats: {:?}", info.formats());
Expand Down
2 changes: 1 addition & 1 deletion examples/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub mod images {
use image;

pub fn load_image(name: &str) -> image::RgbaImage {
let path = format!("examples/images/{}", name);
let path = format!("examples/images/{name}");
image::open(path).unwrap().to_rgba8()
}
}
10 changes: 5 additions & 5 deletions src/buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
//! There are two methods of sharing a GEM handle between processes:
//!
//! 1. Using `Flink` to globally publish a handle using a 32-bit 'name'. This
//! requires either holding the DRM Master lock or having the process'
//! [`AuthToken`](struct@crate::AuthToken) authenticated. However, any process can
//! open these handles if they know (or even guess) the global name.
//! requires either holding the DRM Master lock or having the process'
//! [`AuthToken`](struct@crate::AuthToken) authenticated. However, any process can
//! open these handles if they know (or even guess) the global name.
//!
//! 2. Converting the GEM handle into a PRIME file descriptor, and passing it
//! like a regular one. This allows better control and security, and is the
//! recommended method of sharing buffers.
//! like a regular one. This allows better control and security, and is the
//! recommended method of sharing buffers.

use crate::control;
pub use drm_fourcc::{DrmFourcc, DrmModifier, DrmVendor, UnrecognizedFourcc, UnrecognizedVendor};
Expand Down
2 changes: 1 addition & 1 deletion src/control/dumbbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl DerefMut for DumbMapping<'_> {
}
}

impl<'a> Drop for DumbMapping<'a> {
impl Drop for DumbMapping<'_> {
fn drop(&mut self) {
unsafe {
rustix::mm::munmap(self.map.as_mut_ptr() as *mut _, self.map.len())
Expand Down
Loading
Loading