diff options
Diffstat (limited to 'devices/src/virtio/gpu/mod.rs')
-rw-r--r-- | devices/src/virtio/gpu/mod.rs | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/devices/src/virtio/gpu/mod.rs b/devices/src/virtio/gpu/mod.rs index b305089..2873b74 100644 --- a/devices/src/virtio/gpu/mod.rs +++ b/devices/src/virtio/gpu/mod.rs @@ -111,7 +111,7 @@ trait Backend { /// Constructs a backend. fn build( - possible_displays: &[DisplayBackend], + display: GpuDisplay, display_width: u32, display_height: u32, renderer_flags: RendererFlags, @@ -345,9 +345,28 @@ impl BackendKind { gpu_device_socket: VmMemoryControlRequestSocket, pci_bar: Alloc, ) -> Option<Box<dyn Backend>> { + let mut display_opt = None; + for display in possible_displays { + match display.build() { + Ok(c) => { + display_opt = Some(c); + break; + } + Err(e) => error!("failed to open display: {}", e), + }; + } + + let display = match display_opt { + Some(d) => d, + None => { + error!("failed to open any displays"); + return None; + } + }; + match self { BackendKind::Virtio2D => Virtio2DBackend::build( - possible_displays, + display, display_width, display_height, renderer_flags, @@ -356,7 +375,7 @@ impl BackendKind { pci_bar, ), BackendKind::Virtio3D => Virtio3DBackend::build( - possible_displays, + display, display_width, display_height, renderer_flags, @@ -366,7 +385,7 @@ impl BackendKind { ), #[cfg(feature = "gfxstream")] BackendKind::VirtioGfxStream => VirtioGfxStreamBackend::build( - possible_displays, + display, display_width, display_height, renderer_flags, @@ -977,10 +996,6 @@ impl DisplayBackend { DisplayBackend::Stub => GpuDisplay::open_stub(), } } - - fn is_x(&self) -> bool { - matches!(self, DisplayBackend::X(_)) - } } pub struct Gpu { |