diff --git a/drm-ffi/src/ioctl.rs b/drm-ffi/src/ioctl.rs index 0f46801..c053ede 100644 --- a/drm-ffi/src/ioctl.rs +++ b/drm-ffi/src/ioctl.rs @@ -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); } diff --git a/drm-ffi/src/syncobj.rs b/drm-ffi/src/syncobj.rs index cc9863e..5334944 100644 --- a/drm-ffi/src/syncobj.rs +++ b/drm-ffi/src/syncobj.rs @@ -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 { + 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) +} diff --git a/src/control/mod.rs b/src/control/mod.rs index beeb6e5..b534248 100644 --- a/src/control/mod.rs +++ b/src/control/mod.rs @@ -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,