[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250305230406.567126-31-lyude@redhat.com>
Date: Wed, 5 Mar 2025 17:59:46 -0500
From: Lyude Paul <lyude@...hat.com>
To: dri-devel@...ts.freedesktop.org,
rust-for-linux@...r.kernel.org
Cc: Danilo Krummrich <dakr@...nel.org>,
mcanal@...lia.com,
Alice Ryhl <aliceryhl@...gle.com>,
Maxime Ripard <mripard@...nel.org>,
Simona Vetter <sima@...ll.ch>,
Daniel Almeida <daniel.almeida@...labora.com>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>,
linux-kernel@...r.kernel.org (open list)
Subject: [RFC v3 30/33] rust: drm/kms: Add Device::num_crtcs()
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@...hat.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
Powered by blists - more mailing lists