Skip to content

Commit

Permalink
Add Device::syncobj_eventfd
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 authored and Drakulix committed Mar 27, 2024
1 parent d926544 commit 424981d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
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 @@ -954,6 +954,18 @@ pub trait Device: super::Device {
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

0 comments on commit 424981d

Please sign in to comment.