[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b41f707d-7e06-4c1a-93f0-d74ee242b650@proton.me>
Date: Wed, 27 Mar 2024 21:06:42 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Lyude Paul <lyude@...hat.com>, dri-devel@...ts.freedesktop.org
Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>, David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>, 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>, Andreas Hindborg <a.hindborg@...sung.com>, Alice Ryhl <aliceryhl@...gle.com>, linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH 2/4] WIP: drm: Introduce rvkms
On 22.03.24 23:03, Lyude Paul wrote:
> diff --git a/drivers/gpu/drm/rvkms/connector.rs b/drivers/gpu/drm/rvkms/connector.rs
> new file mode 100644
> index 0000000000000..40f84d38437ee
> --- /dev/null
> +++ b/drivers/gpu/drm/rvkms/connector.rs
> @@ -0,0 +1,55 @@
> +// TODO: License and stuff
> +// Contain's rvkms's drm_connector implementation
> +
> +use super::{RvkmsDriver, RvkmsDevice, MAX_RES, DEFAULT_RES};
> +use kernel::{
> + prelude::*,
> + drm::{
> + device::Device,
> + kms::{
> + connector::{self, ConnectorGuard},
> + ModeConfigGuard
> + }
> + },
> + prelude::*
> +};
> +use core::marker::PhantomPinned;
> +
> +#[pin_data]
> +pub(crate) struct DriverConnector {
> + #[pin]
> + _p: PhantomPinned
> +}
This struct does not need to be annotated with `#[pin_data]`, this
should just work:
pub(crate) struct DriverConnector;
> +
> +pub(crate) type Connector = connector::Connector<DriverConnector>;
> +
> +impl connector::DriverConnector for DriverConnector {
> + type Initializer = impl PinInit<Self, Error>;
> +
> + type State = ConnectorState;
> +
> + type Driver = RvkmsDriver;
> +
> + type Args = ();
> +
> + fn new(dev: &Device<Self::Driver>, args: Self::Args) -> Self::Initializer {
And then here just return `Self`.
This works, since there is a blanket impl `PinInit<T, E> for T`.
Looking at how you use this API, I am not sure if you actually need
pin-init for the type that implements `DriverConnector`.
Do you need to store eg `Mutex<T>` or something else that needs
pin-init in here in a more complex driver?
--
Cheers,
Benno
> + try_pin_init!(Self { _p: PhantomPinned })
> + }
> +
> + fn get_modes(
> + connector: ConnectorGuard<'_, Self>,
> + _guard: &ModeConfigGuard<'_, Self::Driver>
> + ) -> i32 {
> + let count = connector.add_modes_noedid(MAX_RES);
> +
> + connector.set_preferred_mode(DEFAULT_RES);
> + count
> + }
> +}
> +
> +#[derive(Clone, Default)]
> +pub(crate) struct ConnectorState;
> +
> +impl connector::DriverConnectorState for ConnectorState {
> + type Connector = DriverConnector;
> +}
Powered by blists - more mailing lists