1 // Copyright 2024 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 mod kumquat;
6 mod kumquat_gpu;
7
8 use clap::Parser;
9 use kumquat::KumquatBuilder;
10 use rutabaga_gfx::kumquat_support::RutabagaWritePipe;
11 use rutabaga_gfx::RutabagaIntoRawDescriptor;
12 use rutabaga_gfx::RutabagaResult;
13
14 #[derive(Parser, Debug)]
15 #[command(version, about = None, long_about = None)]
16 struct Args {
17 /// Colon-separated list of virtio-gpu capsets. For example,
18 /// "--capset-names=gfxstream-vulkan:cross-domain"
19 #[arg(long, default_value = "gfxstream-vulkan")]
20 capset_names: String,
21
22 /// Path to the emulated virtio-gpu socket.
23 #[arg(long, default_value = "/tmp/kumquat-gpu-0")]
24 gpu_socket_path: String,
25
26 /// Opaque renderer specific features
27 #[arg(long, default_value = "")]
28 renderer_features: String,
29
30 /// An OS-specific pipe descriptor to the parent process
31 #[arg(long, default_value = "0")]
32 pipe_descriptor: i64,
33 }
34
main() -> RutabagaResult<()>35 fn main() -> RutabagaResult<()> {
36 let args = Args::parse();
37
38 let mut kumquat = KumquatBuilder::new()
39 .set_capset_names(args.capset_names)
40 .set_gpu_socket((!args.gpu_socket_path.is_empty()).then(|| args.gpu_socket_path))
41 .set_renderer_features(args.renderer_features)
42 .build()?;
43
44 if args.pipe_descriptor != 0 {
45 let write_pipe = RutabagaWritePipe::new(args.pipe_descriptor.into_raw_descriptor());
46 write_pipe.write(&1u64.to_ne_bytes())?;
47 }
48
49 loop {
50 kumquat.run()?;
51 }
52 }
53