summary refs log tree commit diff
path: root/gpu_buffer
diff options
context:
space:
mode:
authorDavid Reveman <reveman@chromium.org>2018-05-24 06:48:19 -0400
committerchrome-bot <chrome-bot@chromium.org>2018-05-26 10:19:50 -0700
commit5f5e7ec3ba04e29b68244e56f1bce0d87ff6f7d9 (patch)
tree1fddde72ff3e67deed979dc70794cf83fa468512 /gpu_buffer
parent8608eb044b8b00f3309804de3b86758ed8184963 (diff)
downloadcrosvm-5f5e7ec3ba04e29b68244e56f1bce0d87ff6f7d9.tar
crosvm-5f5e7ec3ba04e29b68244e56f1bce0d87ff6f7d9.tar.gz
crosvm-5f5e7ec3ba04e29b68244e56f1bce0d87ff6f7d9.tar.bz2
crosvm-5f5e7ec3ba04e29b68244e56f1bce0d87ff6f7d9.tar.lz
crosvm-5f5e7ec3ba04e29b68244e56f1bce0d87ff6f7d9.tar.xz
crosvm-5f5e7ec3ba04e29b68244e56f1bce0d87ff6f7d9.tar.zst
crosvm-5f5e7ec3ba04e29b68244e56f1bce0d87ff6f7d9.zip
virtwl: better multi-plane DMABuf support
Multi-plane DMABufs are useful for efficient video playback. The
guest can already use this but has to guess the stride and offsets
for the second and third plane as they are not passed by virtwl
to the guest kernel.

This extracts the correct strides and offsets for each buffer and
passes them back to the guest in the allocation response message.

BUG=chromium:837209
TEST=sommelier can use nv12 buffers without guessing stride/offset

Change-Id: I36ae2fad6605293c907802121676296cbc607a57
Reviewed-on: https://chromium-review.googlesource.com/1070799
Commit-Ready: David Reveman <reveman@chromium.org>
Tested-by: David Reveman <reveman@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'gpu_buffer')
-rw-r--r--gpu_buffer/src/lib.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/gpu_buffer/src/lib.rs b/gpu_buffer/src/lib.rs
index fb69eeb..449ab53 100644
--- a/gpu_buffer/src/lib.rs
+++ b/gpu_buffer/src/lib.rs
@@ -292,6 +292,24 @@ impl Buffer {
         unsafe { gbm_bo_get_num_planes(self.0) }
     }
 
+    /// Handle as u64 for the given plane.
+    pub fn plane_handle(&self, plane: usize) -> u64 {
+        // This is always safe to call with a valid gbm_bo pointer.
+        unsafe { gbm_bo_get_plane_handle(self.0, plane).u64 }
+    }
+
+    /// Offset in bytes for the given plane.
+    pub fn plane_offset(&self, plane: usize) -> u32 {
+        // This is always safe to call with a valid gbm_bo pointer.
+        unsafe { gbm_bo_get_plane_offset(self.0, plane) }
+    }
+
+    /// Length in bytes of one row for the given plane.
+    pub fn plane_stride(&self, plane: usize) -> u32 {
+        // This is always safe to call with a valid gbm_bo pointer.
+        unsafe { gbm_bo_get_plane_stride(self.0, plane) }
+    }
+
     /// Exports a new dmabuf/prime file descriptor for the given plane.
     pub fn export_plane_fd(&self, plane: usize) -> Result<File, i32> {
         // This is always safe to call with a valid gbm_bo pointer.