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

Add Device::syncobj_eventfd #193

Merged
merged 1 commit 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
2 changes: 2 additions & 0 deletions drm-ffi/src/ioctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,6 @@ pub(crate) mod syncobj {
0xCD,
drm_syncobj_timeline_array
);
/// Register an eventfd to be signalled by a syncobj.
ioctl_readwrite!(eventfd, DRM_IOCTL_BASE, 0xCF, drm_syncobj_eventfd);
}
28 changes: 28 additions & 0 deletions drm-ffi/src/syncobj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,31 @@ pub fn timeline_signal(

Ok(args)
}

/// Register an eventfd to be signalled by a syncobj.
pub fn eventfd(
fd: BorrowedFd<'_>,
handle: u32,
point: u64,
eventfd: BorrowedFd<'_>,
wait_available: bool,
) -> io::Result<drm_syncobj_eventfd> {
let flags = if wait_available {
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE
} else {
0
};
let mut args = drm_syncobj_eventfd {
handle,
point,
flags,
fd: eventfd.as_raw_fd(),
pad: 0,
};

unsafe {
ioctl::syncobj::eventfd(fd, &mut args)?;
}

Ok(args)
}
12 changes: 12 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 @@ -954,6 +954,18 @@
Ok(())
}

/// Register an eventfd to be signalled by a syncobj.
fn syncobj_eventfd(
&self,
handle: syncobj::Handle,
point: u64,
eventfd: BorrowedFd<'_>,
wait_available: bool,
) -> io::Result<()> {
ffi::syncobj::eventfd(self.as_fd(), handle.into(), point, eventfd, wait_available)?;
Ok(())
}

/// Create a drm lease
fn create_lease(
&self,
Expand Down
Loading