summary refs log tree commit diff
path: root/devices/src/virtio/resource_bridge.rs
diff options
context:
space:
mode:
authorKeiichi Watanabe <keiichiw@chromium.org>2020-02-10 17:06:34 +0900
committerCommit Bot <commit-bot@chromium.org>2020-03-06 13:27:50 +0000
commit9515b05c086c55b9e3fbddbc56fb6eb3e9a510a8 (patch)
tree5e18622a0bb8e4813af1217463cb23caf7204dd9 /devices/src/virtio/resource_bridge.rs
parent3f3c0a3f6ab82779b269446232e9134aa57ad7bc (diff)
downloadcrosvm-9515b05c086c55b9e3fbddbc56fb6eb3e9a510a8.tar
crosvm-9515b05c086c55b9e3fbddbc56fb6eb3e9a510a8.tar.gz
crosvm-9515b05c086c55b9e3fbddbc56fb6eb3e9a510a8.tar.bz2
crosvm-9515b05c086c55b9e3fbddbc56fb6eb3e9a510a8.tar.lz
crosvm-9515b05c086c55b9e3fbddbc56fb6eb3e9a510a8.tar.xz
crosvm-9515b05c086c55b9e3fbddbc56fb6eb3e9a510a8.tar.zst
crosvm-9515b05c086c55b9e3fbddbc56fb6eb3e9a510a8.zip
devices: virtio: resource_bridge: Transfer plane metadata
Transfer plane offsets and strides for exported GPU resource over resource
bridge as well as a resource itself.
These metadata will be required by virtio-video decoder and encoder.

BUG=b:120456557
TEST=Start ARCVM on atlas

Change-Id: Iaf539857c0f8525bd5be294521e75ad32cae05e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1787032
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Diffstat (limited to 'devices/src/virtio/resource_bridge.rs')
-rw-r--r--devices/src/virtio/resource_bridge.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/devices/src/virtio/resource_bridge.rs b/devices/src/virtio/resource_bridge.rs
index aaf776c..2a2343f 100644
--- a/devices/src/virtio/resource_bridge.rs
+++ b/devices/src/virtio/resource_bridge.rs
@@ -16,9 +16,22 @@ pub enum ResourceRequest {
     GetResource { id: u32 },
 }
 
+#[derive(MsgOnSocket, Clone)]
+pub struct PlaneInfo {
+    pub offset: u32,
+    pub stride: u32,
+}
+
+const RESOURE_PLANE_NUM: usize = 4;
+#[derive(MsgOnSocket)]
+pub struct ResourceInfo {
+    pub file: File,
+    pub planes: [PlaneInfo; RESOURE_PLANE_NUM],
+}
+
 #[derive(MsgOnSocket)]
 pub enum ResourceResponse {
-    Resource(File),
+    Resource(ResourceInfo),
     Invalid,
 }
 
@@ -58,16 +71,16 @@ impl fmt::Display for ResourceBridgeError {
 
 impl std::error::Error for ResourceBridgeError {}
 
-pub fn get_resource_fd(
+pub fn get_resource_info(
     sock: &ResourceRequestSocket,
     id: u32,
-) -> std::result::Result<File, ResourceBridgeError> {
+) -> std::result::Result<ResourceInfo, ResourceBridgeError> {
     if let Err(e) = sock.send(&ResourceRequest::GetResource { id }) {
         return Err(ResourceBridgeError::SendFailure(id, e));
     }
 
     match sock.recv() {
-        Ok(ResourceResponse::Resource(bridged_file)) => Ok(bridged_file),
+        Ok(ResourceResponse::Resource(info)) => Ok(info),
         Ok(ResourceResponse::Invalid) => Err(ResourceBridgeError::InvalidResource(id)),
         Err(e) => Err(ResourceBridgeError::RecieveFailure(id, e)),
     }