starnix_modules_gralloc/
device.rs1use super::file::GrallocFile;
6use starnix_core::device::DeviceOps;
7use starnix_core::task::{CurrentTask, Kernel};
8use starnix_core::vfs::{FileOps, NamespaceNode};
9
10use starnix_uapi::device_id::DeviceId;
11use starnix_uapi::errors::Errno;
12use starnix_uapi::open_flags::OpenFlags;
13
14#[derive(Clone)]
15struct GrallocDevice;
16
17impl DeviceOps for GrallocDevice {
18 fn open(
19 &self,
20 current_task: &CurrentTask,
21 _id: DeviceId,
22 _node: &NamespaceNode,
23 _flags: OpenFlags,
24 ) -> Result<Box<dyn FileOps>, Errno> {
25 GrallocFile::new_file(current_task)
26 }
27}
28
29pub fn gralloc_device_init(kernel: &Kernel) {
30 let registry = &kernel.device_registry;
31 registry
32 .register_dyn_device(
33 kernel,
34 "virtgralloc0".into(),
35 registry.objects.starnix_class(),
36 GrallocDevice,
37 )
38 .expect("can register virtgralloc0");
39}