From ed88b0ef5eff1845fe266b620b1866fe85ba2532 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Thu, 6 Jun 2019 17:34:07 -0700 Subject: devices: gpu: advertise support for capset 3 Useful for prototyping new features. BUG=chromium:924405 TEST=compile Change-Id: Ibdc4a70761493939ca96b92540b9e0cca88c17a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1650290 Tested-by: Gurchetan Singh Tested-by: kokoro Reviewed-by: Zach Reizner Commit-Queue: Gurchetan Singh Auto-Submit: Gurchetan Singh --- devices/src/virtio/gpu/backend.rs | 5 ++++- devices/src/virtio/gpu/mod.rs | 2 +- devices/src/virtio/gpu/protocol.rs | 1 + gpu_renderer/src/lib.rs | 5 +++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/devices/src/virtio/gpu/backend.rs b/devices/src/virtio/gpu/backend.rs index 475cb10..8f693cc 100644 --- a/devices/src/virtio/gpu/backend.rs +++ b/devices/src/virtio/gpu/backend.rs @@ -25,7 +25,8 @@ use gpu_renderer::{ }; use super::protocol::{ - GpuResponse, GpuResponsePlaneInfo, VIRTIO_GPU_CAPSET_VIRGL, VIRTIO_GPU_CAPSET_VIRGL2, + GpuResponse, GpuResponsePlaneInfo, VIRTIO_GPU_CAPSET3, VIRTIO_GPU_CAPSET_VIRGL, + VIRTIO_GPU_CAPSET_VIRGL2, }; use crate::virtio::resource_bridge::*; use vm_control::VmMemoryControlRequestSocket; @@ -631,8 +632,10 @@ impl Backend { let id = match index { 0 => VIRTIO_GPU_CAPSET_VIRGL, 1 => VIRTIO_GPU_CAPSET_VIRGL2, + 2 => VIRTIO_GPU_CAPSET3, _ => return GpuResponse::ErrInvalidParameter, }; + let (version, size) = self.renderer.get_cap_set_info(id); GpuResponse::OkCapsetInfo { id, version, size } } diff --git a/devices/src/virtio/gpu/mod.rs b/devices/src/virtio/gpu/mod.rs index 0031b73..0ab83fd 100644 --- a/devices/src/virtio/gpu/mod.rs +++ b/devices/src/virtio/gpu/mod.rs @@ -643,7 +643,7 @@ impl Gpu { events_read: Le32::from(events_read), events_clear: Le32::from(0), num_scanouts: Le32::from(1), - num_capsets: Le32::from(2), + num_capsets: Le32::from(3), } } } diff --git a/devices/src/virtio/gpu/protocol.rs b/devices/src/virtio/gpu/protocol.rs index 008283b..3649e10 100644 --- a/devices/src/virtio/gpu/protocol.rs +++ b/devices/src/virtio/gpu/protocol.rs @@ -377,6 +377,7 @@ unsafe impl DataInit for virtio_gpu_cmd_submit {} pub const VIRTIO_GPU_CAPSET_VIRGL: u32 = 1; pub const VIRTIO_GPU_CAPSET_VIRGL2: u32 = 2; +pub const VIRTIO_GPU_CAPSET3: u32 = 3; /* VIRTIO_GPU_CMD_GET_CAPSET_INFO */ #[derive(Copy, Clone, Debug)] diff --git a/gpu_renderer/src/lib.rs b/gpu_renderer/src/lib.rs index 726f912..270dc93 100644 --- a/gpu_renderer/src/lib.rs +++ b/gpu_renderer/src/lib.rs @@ -41,6 +41,7 @@ pub use crate::generated::virglrenderer::{ virgl_renderer_resource_create_args, virgl_renderer_resource_info, VIRGL_RES_BIND_SCANOUT, VIRGL_RES_BIND_SHARED, }; +pub use crate::generated::virtgpu_hw::virtgpu_caps; pub use crate::pipe_format_fourcc::pipe_format_fourcc as format_fourcc; /// Arguments used in `Renderer::create_resource`.. @@ -421,6 +422,10 @@ impl Renderer { /// Gets the version and size for the given capability set ID. pub fn get_cap_set_info(&self, id: u32) -> (u32, u32) { + if id == 3 { + return (0 as u32, size_of::() as u32); + } + let mut version = 0; let mut size = 0; // Safe because virglrenderer is initialized by now and properly size stack variables are -- cgit 1.4.1