summary refs log tree commit diff
path: root/devices/src/virtio/resource_bridge.rs
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2018-08-15 10:46:32 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-12-11 19:33:56 -0800
commitaa5756669a8331420b84a22e29ddbfc13b791da5 (patch)
tree3a2767b6ecc2779ca1e9f64ff7c60d8ae3bf8fdf /devices/src/virtio/resource_bridge.rs
parent42c409c4d7c661ead9794c54811ce5fadf0ae8e7 (diff)
downloadcrosvm-aa5756669a8331420b84a22e29ddbfc13b791da5.tar
crosvm-aa5756669a8331420b84a22e29ddbfc13b791da5.tar.gz
crosvm-aa5756669a8331420b84a22e29ddbfc13b791da5.tar.bz2
crosvm-aa5756669a8331420b84a22e29ddbfc13b791da5.tar.lz
crosvm-aa5756669a8331420b84a22e29ddbfc13b791da5.tar.xz
crosvm-aa5756669a8331420b84a22e29ddbfc13b791da5.tar.zst
crosvm-aa5756669a8331420b84a22e29ddbfc13b791da5.zip
devices: allow virtio-wayland to use virtgpu resources
This change uses the resource bridge between virtio-gpu and virtio-cpu
to send resources over the host wayland connection that originated from
the virtio-gpu device. This will help support gpu accelerated wayland
surfaces.

BUG=chromium:875998
TEST=wayland-simple-egl

Change-Id: I3340ecef438779be5cb3643b2de8bb8c33097d75
Reviewed-on: https://chromium-review.googlesource.com/1182793
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'devices/src/virtio/resource_bridge.rs')
-rw-r--r--devices/src/virtio/resource_bridge.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/devices/src/virtio/resource_bridge.rs b/devices/src/virtio/resource_bridge.rs
new file mode 100644
index 0000000..d3a3375
--- /dev/null
+++ b/devices/src/virtio/resource_bridge.rs
@@ -0,0 +1,30 @@
+// Copyright 2018 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+//! This module defines the protocol between `virtio-wayland` and `virtio-gpu` for sharing resources
+//! that are backed by file descriptors.
+
+use std::fs::File;
+use std::io::Result;
+
+use msg_on_socket_derive::MsgOnSocket;
+use msg_socket::MsgSocket;
+
+#[derive(MsgOnSocket)]
+pub enum ResourceRequest {
+    GetResource { id: u32 },
+}
+
+#[derive(MsgOnSocket)]
+pub enum ResourceResponse {
+    Resource(File),
+    Invalid,
+}
+
+pub type ResourceRequestSocket = MsgSocket<ResourceRequest, ResourceResponse>;
+pub type ResourceResponseSocket = MsgSocket<ResourceResponse, ResourceRequest>;
+
+pub fn pair() -> Result<(ResourceRequestSocket, ResourceResponseSocket)> {
+    msg_socket::pair()
+}