File Index
Files and directories
Sign in
FILE

driver.rs

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/nova/driver.rs RUST
 1// SPDX-License-Identifier: GPL-2.0
 2
 3use kernel::{
 4    auxiliary, c_str, device::Core, drm, drm::gem, drm::ioctl, prelude::*, sync::aref::ARef,
 5};
 6
 7use crate::file::File;
 8use crate::gem::NovaObject;
 9
10pub(crate) struct NovaDriver {
11    #[expect(unused)]
12    drm: ARef<drm::Device<Self>>,
13}
14
15/// Convienence type alias for the DRM device type for this driver
16pub(crate) type NovaDevice = drm::Device<NovaDriver>;
17
18#[pin_data]
19pub(crate) struct NovaData {
20    pub(crate) adev: ARef<auxiliary::Device>,
21}
22
23const INFO: drm::DriverInfo = drm::DriverInfo {
24    major: 0,
25    minor: 0,
26    patchlevel: 0,
27    name: c_str!("nova"),
28    desc: c_str!("Nvidia Graphics"),
29};
30
31const NOVA_CORE_MODULE_NAME: &CStr = c_str!("NovaCore");
32const AUXILIARY_NAME: &CStr = c_str!("nova-drm");
33
34kernel::auxiliary_device_table!(
35    AUX_TABLE,
36    MODULE_AUX_TABLE,
37    <NovaDriver as auxiliary::Driver>::IdInfo,
38    [(
39        auxiliary::DeviceId::new(NOVA_CORE_MODULE_NAME, AUXILIARY_NAME),
40        ()
41    )]
42);
43
44impl auxiliary::Driver for NovaDriver {
45    type IdInfo = ();
46    const ID_TABLE: auxiliary::IdTable<Self::IdInfo> = &AUX_TABLE;
47
48    fn probe(adev: &auxiliary::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, Error> {
49        let data = try_pin_init!(NovaData { adev: adev.into() });
50
51        let drm = drm::Device::<Self>::new(adev.as_ref(), data)?;
52        drm::Registration::new_foreign_owned(&drm, adev.as_ref(), 0)?;
53
54        Ok(Self { drm })
55    }
56}
57
58#[vtable]
59impl drm::Driver for NovaDriver {
60    type Data = NovaData;
61    type File = File;
62    type Object = gem::Object<NovaObject>;
63
64    const INFO: drm::DriverInfo = INFO;
65
66    kernel::declare_drm_ioctls! {
67        (NOVA_GETPARAM, drm_nova_getparam, ioctl::RENDER_ALLOW, File::get_param),
68        (NOVA_GEM_CREATE, drm_nova_gem_create, ioctl::AUTH | ioctl::RENDER_ALLOW, File::gem_create),
69        (NOVA_GEM_INFO, drm_nova_gem_info, ioctl::AUTH | ioctl::RENDER_ALLOW, File::gem_info),
70    }
71}
~/ Read-only file preview.