memory/dmabuf: provide map() method
Provide a portable way to mmap dmabuf handles, which can come in handy.
diff --git a/src/memory/dmabuf.rs b/src/memory/dmabuf.rs
index a4c2ca4..df63176 100644
--- a/src/memory/dmabuf.rs
+++ b/src/memory/dmabuf.rs
@@ -1,6 +1,6 @@
//! Operations specific to DMABuf-type buffers.
use super::*;
-use crate::bindings;
+use crate::{bindings, ioctl};
use std::os::unix::io::AsRawFd;
pub struct DMABuf;
@@ -56,3 +56,11 @@
buffer.length = plane.length;
}
}
+
+impl<T: DMABufSource> DMABufHandle<T> {
+ pub fn map(&self) -> Result<PlaneMapping, ioctl::MMAPError> {
+ let len = self.0.len();
+
+ ioctl::mmap(&self.0, 0, len as u32)
+ }
+}