[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240930233257.1189730-27-lyude@redhat.com>
Date: Mon, 30 Sep 2024 19:10:09 -0400
From: Lyude Paul <lyude@...hat.com>
To: dri-devel@...ts.freedesktop.org,
rust-for-linux@...r.kernel.org
Cc: Asahi Lina <lina@...hilina.net>,
Danilo Krummrich <dakr@...nel.org>,
mcanal@...lia.com,
airlied@...hat.com,
zhiw@...dia.com,
cjia@...dia.com,
jhubbard@...dia.com,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...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@...sung.com>,
Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>,
linux-kernel@...r.kernel.org (open list)
Subject: [WIP RFC v2 26/35] WIP: rust: drm/kms: Add RawPlaneState::atomic_helper_check()
Add a binding for drm_atomic_helper_check_plane_state(). Since we want to
make sure that the user is passing in the new state for a Crtc instead of
an old state, we explicitly ask for a reference to a BorrowedCrtcState.
Signed-off-by: Lyude Paul <lyude@...hat.com>
---
TODO:
* Add support for scaling options
Signed-off-by: Lyude Paul <lyude@...hat.com>
---
rust/kernel/drm/kms/plane.rs | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/rust/kernel/drm/kms/plane.rs b/rust/kernel/drm/kms/plane.rs
index 4d16d53179fca..cd5167e6441f1 100644
--- a/rust/kernel/drm/kms/plane.rs
+++ b/rust/kernel/drm/kms/plane.rs
@@ -496,6 +496,31 @@ fn crtc<'a, 'b: 'a>(&'a self) -> Option<&'b OpaqueCrtc<<Self::Plane as ModeObjec
// SAFETY: This cast is guaranteed safe by `OpaqueCrtc`s invariants.
NonNull::new(self.as_raw().crtc).map(|c| unsafe { OpaqueCrtc::from_raw(c.as_ptr()) })
}
+
+ /// Run the atomic check helper for this plane and the given CRTC state
+ fn atomic_helper_check<S>(
+ &mut self,
+ crtc_state: &BorrowedCrtcState<'_, S>,
+ can_position: bool,
+ can_update_disabled: bool
+ ) -> Result
+ where
+ S: FromRawCrtcState,
+ S::Crtc: AsRawCrtc<Driver = <Self::Plane as ModeObject>::Driver>
+ {
+ // SAFETY: We're passing the mutable reference from `self.as_raw_mut()` directly to DRM,
+ // which is safe.
+ to_result(unsafe {
+ bindings::drm_atomic_helper_check_plane_state(
+ self.as_raw_mut(),
+ crtc_state.as_raw(),
+ bindings::DRM_PLANE_NO_SCALING as _, // TODO: add parameters for scaling
+ bindings::DRM_PLANE_NO_SCALING as _,
+ can_position,
+ can_update_disabled
+ )
+ })
+ }
}
impl<T: AsRawPlaneState + ?Sized> RawPlaneState for T {}
--
2.46.1
Powered by blists - more mailing lists