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;
7use starnix_core::vfs::{FileOps, NamespaceNode};
8use starnix_logging::log_error;
9use starnix_sync::{FileOpsCore, LockEqualOrBefore, Locked};
10use starnix_uapi::device_type::DeviceType;
11use starnix_uapi::error;
12use starnix_uapi::errors::Errno;
13use starnix_uapi::open_flags::OpenFlags;
14
15fn create_gpu_device(
16    _locked: &mut Locked<FileOpsCore>,
17    _current_task: &CurrentTask,
18    _id: DeviceType,
19    _node: &NamespaceNode,
20    _flags: OpenFlags,
21) -> Result<Box<dyn FileOps>, Errno> {
22    log_error!("virtio-gpu unsupported");
23    error!(ENOTSUP)
24}
25
26pub fn gpu_device_init<L>(locked: &mut Locked<L>, current_task: &CurrentTask)
27where
28    L: LockEqualOrBefore<FileOpsCore>,
29{
30    let kernel = current_task.kernel();
31    let registry = &kernel.device_registry;
32
33    let _ = RutabagaBuilder::new(RutabagaComponentType::Gfxstream, 0)
34        .build(RutabagaFenceHandler::new(move |_| {}), std::option::Option::None);
35
36    registry
37        .register_dyn_device(
38            locked,
39            current_task,
40            "virtio-gpu".into(),
41            registry.objects.starnix_class(),
42            create_gpu_device,
43        )
44        .expect("can register virtio-gpu");
45}