From 73ac09f173f878dbce6efc4c0234346ab734f466 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 20 Mar 2024 12:26:37 -0700 Subject: [PATCH] Add `Device::syncobj_eventfd` --- drm-ffi/src/ioctl.rs | 2 ++ drm-ffi/src/syncobj.rs | 28 ++++++++++++++++++++++++++++ src/control/mod.rs | 12 ++++++++++++ 3 files changed, 42 insertions(+) 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 6cb45a9..676e941 100644 --- a/drm-ffi/src/syncobj.rs +++ b/drm-ffi/src/syncobj.rs @@ -262,3 +262,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 2b6f946..8520548 100644 --- a/src/control/mod.rs +++ b/src/control/mod.rs @@ -952,6 +952,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,