Skip to main content

starnix_modules_gpu/
device.rs

1// Copyright 2024 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use rutabaga_gfx::{RutabagaBuilder, RutabagaComponentType, RutabagaFenceHandler};
6use starnix_core::task::{CurrentTask, Kernel};
7use starnix_core::vfs::{FileOps, NamespaceNode};
8use starnix_logging::log_error;
9
10use starnix_uapi::device_id::DeviceId;
11use starnix_uapi::error;
12use starnix_uapi::errors::Errno;
13use starnix_uapi::open_flags::OpenFlags;
14
15fn create_gpu_device(
16    _current_task: &CurrentTask,
17    _id: DeviceId,
18    _node: &NamespaceNode,
19    _flags: OpenFlags,
20) -> Result<Box<dyn FileOps>, Errno> {
21    log_error!("virtio-gpu unsupported");
22    error!(ENOTSUP)
23}
24
25pub fn gpu_device_init(kernel: &Kernel) {
26    let registry = &kernel.device_registry;
27
28    let _ = RutabagaBuilder::new(0, RutabagaFenceHandler::new(move |_| {}))
29        .set_default_component(RutabagaComponentType::Gfxstream)
30        .build();
31
32    registry
33        .register_dyn_device(
34            kernel,
35            "virtio-gpu".into(),
36            registry.objects.starnix_class(),
37            create_gpu_device,
38        )
39        .expect("can register virtio-gpu");
40}