Re: [RFC v3 27/33] rust: drm/kms: Add DriverCrtc::atomic_begin() and atomic_flush()
From: Maxime Ripard
Date: Fri Mar 14 2025 - 08:27:50 EST
On Wed, Mar 05, 2025 at 05:59:43PM -0500, Lyude Paul wrote:
> Optional trait methods for implementing the atomic_begin and atomic_flush
> callbacks for a CRTC.
>
> Signed-off-by: Lyude Paul <lyude@xxxxxxxxxx>
> ---
> rust/kernel/drm/kms/crtc.rs | 90 ++++++++++++++++++++++++++++++++++++-
> 1 file changed, 88 insertions(+), 2 deletions(-)
>
> diff --git a/rust/kernel/drm/kms/crtc.rs b/rust/kernel/drm/kms/crtc.rs
> index aaa208b35c3c1..131d10505ba07 100644
> --- a/rust/kernel/drm/kms/crtc.rs
> +++ b/rust/kernel/drm/kms/crtc.rs
> @@ -90,8 +90,16 @@ pub trait DriverCrtc: Send + Sync + Sized {
> mode_set: None,
> mode_valid: None,
> mode_fixup: None,
> - atomic_begin: None,
> - atomic_flush: None,
> + atomic_begin: if Self::HAS_ATOMIC_BEGIN {
> + Some(atomic_begin_callback::<Self>)
> + } else {
> + None
> + },
> + atomic_flush: if Self::HAS_ATOMIC_FLUSH {
> + Some(atomic_flush_callback::<Self>)
> + } else {
> + None
> + },
> mode_set_nofb: None,
> mode_set_base: None,
> mode_set_base_atomic: None,
> @@ -132,6 +140,36 @@ fn atomic_check(
> ) -> Result {
> build_error::build_error("This should not be reachable")
> }
> +
> + /// The optional [`drm_crtc_helper_funcs.atomic_begin`] hook.
> + ///
> + /// This hook will be called before a set of [`Plane`] updates are performed for the given
> + /// [`Crtc`].
> + ///
> + /// [`drm_crtc_helper_funcs.atomic_begin`]: srctree/include/drm/drm_modeset_helper_vtables.h
> + fn atomic_begin(
> + _crtc: &Crtc<Self>,
> + _old_state: &CrtcState<Self::State>,
> + _new_state: CrtcStateMutator<'_, CrtcState<Self::State>>,
> + _state: &AtomicStateMutator<Self::Driver>,
> + ) {
> + build_error::build_error("This should not be reachable")
> + }
Another dumb question I guess. If it's optional, and the default
implementation of a trait errors out at build time, how can it not break
if we don't implement the method?
Maxime
Attachment:
signature.asc
Description: PGP signature