[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <6F230886-172E-4F2E-9107-9C6D11C39CB6@collabora.com>
Date: Wed, 27 Nov 2024 16:29:09 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Lyude Paul <lyude@...hat.com>
Cc: dri-devel@...ts.freedesktop.org,
rust-for-linux@...r.kernel.org,
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>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [WIP RFC v2 17/35] rust: drm/kms: Add RawCrtc and RawCrtcState
Hi Lyude,
> On 30 Sep 2024, at 20:10, Lyude Paul <lyude@...hat.com> wrote:
>
> Same thing as RawConnector and RawConnectorState, just for CRTCs now.
>
> Signed-off-by: Lyude Paul <lyude@...hat.com>
> ---
> rust/kernel/drm/kms/crtc.rs | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/rust/kernel/drm/kms/crtc.rs b/rust/kernel/drm/kms/crtc.rs
> index 1a3c9c448afcc..246d15a15c14d 100644
> --- a/rust/kernel/drm/kms/crtc.rs
> +++ b/rust/kernel/drm/kms/crtc.rs
> @@ -302,6 +302,25 @@ unsafe fn from_raw<'a>(ptr: *mut bindings::drm_crtc) -> &'a Self {
> }
> }
>
> +/// Common methods available on any type which implements [`AsRawCrtc`].
> +///
> +/// This is implemented internally by DRM, and provides many of the basic methods for working with
> +/// CRTCs.
> +pub trait RawCrtc: AsRawCrtc {
> + /// Return the index of this CRTC.
> + fn index(&self) -> u32 {
> + // SAFETY: The index is initialized by the time we expose Crtc objects to users, and is
> + // invariant throughout the lifetime of the Crtc
> + unsafe { (*self.as_raw()).index }
> + }
> +
> + /// Return the index of this DRM CRTC in the form of a bitmask.
> + fn mask(&self) -> u32 {
> + 1 << self.index()
> + }
> +}
> +impl<T: AsRawCrtc> RawCrtc for T {}
> +
> /// A [`struct drm_crtc`] without a known [`DriverCrtc`] implementation.
> ///
> /// This is mainly for situations where our bindings can't infer the [`DriverCrtc`] implementation
> @@ -447,8 +466,10 @@ pub trait AsRawCrtcState {
>
> pub(super) use private::AsRawCrtcState as AsRawCrtcStatePrivate;
>
> -/// A trait for providing common methods which can be used on any type that can be used as an atomic
> -/// CRTC state.
> +/// Common methods available on any type which implements [`AsRawCrtcState`].
> +///
> +/// This is implemented internally by DRM, and provides many of the basic methods for working with
> +/// the atomic state of [`Crtc`]s.
> pub trait RawCrtcState: AsRawCrtcState {
> /// Return the CRTC that owns this state.
> fn crtc(&self) -> &Self::Crtc {
> --
> 2.46.1
This also looks good.
— Daniel
Powered by blists - more mailing lists