/// Driver use the GEM memory manager. This should be set for all modern drivers. pub(crate) const FEAT_GEM: u32 = bindings::drm_driver_feature_DRIVER_GEM;
/// Information data for a DRM Driver. pubstruct DriverInfo { /// Driver major version. pub major: i32, /// Driver minor version. pub minor: i32, /// Driver patchlevel version. pub patchlevel: i32, /// Driver name. pub name: &'static CStr, /// Driver description. pub desc: &'static CStr,
}
/// Trait for memory manager implementations. Implemented internally. pubtrait AllocImpl: super::private::Sealed + drm::gem::IntoGEMObject { /// The C callback operations for this memory manager. const ALLOC_OPS: AllocOps;
}
/// The DRM `Driver` trait. /// /// This trait must be implemented by drivers in order to create a `struct drm_device` and `struct /// drm_driver` to be registered in the DRM subsystem. #[vtable] pubtrait Driver { /// Context data associated with the DRM driver type Data: Sync + Send;
/// The type used to manage memory for this driver. type Object: AllocImpl;
/// The type used to represent a DRM File (client) type File: drm::file::DriverFile;
/// Driver metadata const INFO: DriverInfo;
/// IOCTL list. See `kernel::drm::ioctl::declare_drm_ioctls!{}`. const IOCTLS: &'static [drm::ioctl::DrmIoctlDescriptor];
}
/// The registration type of a `drm::Device`. /// /// Once the `Registration` structure is dropped, the device is unregistered. pubstruct Registration<T: Driver>(ARef<drm::Device<T>>);
impl<T: Driver> Registration<T> { /// Creates a new [`Registration`] and registers it. fn new(drm: &drm::Device<T>, flags: usize) -> Result<Self> { // SAFETY: `drm.as_raw()` is valid by the invariants of `drm::Device`.
to_result(unsafe { bindings::drm_dev_register(drm.as_raw(), flags) })?;
Ok(Self(drm.into()))
}
/// Same as [`Registration::new`}, but transfers ownership of the [`Registration`] to /// [`devres::register`]. pubfn new_foreign_owned(
drm: &drm::Device<T>,
dev: &device::Device<device::Bound>,
flags: usize,
) -> Result where
T: 'static,
{ if drm.as_ref().as_raw() != dev.as_raw() { return Err(EINVAL);
}
let reg = Registration::<T>::new(drm, flags)?;
devres::register(dev, reg, GFP_KERNEL)
}
/// Returns a reference to the `Device` instance for this registration. pubfn device(&self) -> &drm::Device<T> {
&self.0
}
}
// SAFETY: `Registration` doesn't offer any methods or access to fields when shared between // threads, hence it's safe to share it. unsafeimpl<T: Driver> Sync for Registration<T> {}
// SAFETY: Registration with and unregistration from the DRM subsystem can happen from any thread. unsafeimpl<T: Driver> Send for Registration<T> {}
impl<T: Driver> Drop for Registration<T> { fn drop(&mutself) { // SAFETY: Safe by the invariant of `ARef<drm::Device<T>>`. The existence of this // `Registration` also guarantees the this `drm::Device` is actually registered. unsafe { bindings::drm_dev_unregister(self.0.as_raw()) };
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-19)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.