[RFC v3 30/33] rust: drm/kms: Add Device::num_crtcs()
Lyude Paul
lyude at redhat.com
Wed Mar 5 22:59:46 UTC 2025
A binding for checking drm_device.num_crtcs. We'll need this in a moment
for vblank support, since setting it up requires knowing the number of
CRTCs that a driver has initialized.
Signed-off-by: Lyude Paul <lyude at redhat.com>
---
rust/kernel/drm/kms.rs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/rust/kernel/drm/kms.rs b/rust/kernel/drm/kms.rs
index 429ce28229c9e..36a0b4c4454ba 100644
--- a/rust/kernel/drm/kms.rs
+++ b/rust/kernel/drm/kms.rs
@@ -311,6 +311,17 @@ pub fn mode_config_lock(&self) -> ModeConfigGuard<'_, T> {
// held throughout ModeConfigGuard's lifetime.
ModeConfigGuard(self.mode_config_mutex().lock(), PhantomData)
}
+
+ /// Return the number of registered CRTCs
+ #[inline]
+ pub fn num_crtcs(&self) -> u32 {
+ // SAFETY:
+ // * This can only be modified during the single-threaded context before registration, so
+ // this is safe
+ // * num_crtc could be >= 0, but no less - so casting to u32 is fine (and better to prevent
+ // errors)
+ unsafe { (*self.as_raw()).mode_config.num_crtc as u32 }
+ }
}
/// A modesetting object in DRM.
--
2.48.1
More information about the dri-devel
mailing list