dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust
@ 2025-08-18  5:04 Rahul Rameshbabu
  2025-08-18  5:04 ` [RFC PATCH 1/3] rust: drm: fix C header references in doc comments Rahul Rameshbabu
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Rahul Rameshbabu @ 2025-08-18  5:04 UTC (permalink / raw)
  To: rust-for-linux, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Rahul Rameshbabu

Hello,

I am working on a drm_connector scoped backlight API in Rust. I have been
looking through Hans de Goede's previous efforts on this topic to help
guide my design. My hope is to enable backlight control over external
displays through DDC or USB Monitor Control Class while also supporting
internal panels. In parallel, I would like to improve the driver
probing/selection mechanism when there are different candidates for driving
a backlight device. This initial RFC is mainly intended to sanity check
that the plumbing I have chosen for extending the DRM connector
functionality in Rust seems reasonable.

I did toss in two doc comment cleanup patches in the mix. If these need to
be re-sent individually or split due to the multiple Fixes: tags, do not
hesitate to let me know.

Thanks,
Rahul Rameshbabu

Link: https://lore.kernel.org/rust-for-linux/20250808061223.3770-1-sergeantsagara@protonmail.com/
Link: https://binary-eater.github.io/tags/usb-monitor-control/
Link: https://lpc.events/event/16/contributions/1390/attachments/990/1916/kernel-recipes-backlight-2022-16x9.pdf

Rahul Rameshbabu (3):
  rust: drm: fix C header references in doc comments
  rust: pci: fix incorrect platform references in doc comments
  rust: drm: Introduce a Connector abstraction

 drivers/gpu/drm/drm_connector.c |   9 +++
 include/drm/drm_connector.h     |  20 +++++++
 rust/bindings/bindings_helper.h |   1 +
 rust/kernel/drm/connector.rs    | 103 ++++++++++++++++++++++++++++++++
 rust/kernel/drm/device.rs       |   2 +-
 rust/kernel/drm/driver.rs       |   2 +-
 rust/kernel/drm/file.rs         |   2 +-
 rust/kernel/drm/gem/mod.rs      |   2 +-
 rust/kernel/drm/ioctl.rs        |   2 +-
 rust/kernel/drm/mod.rs          |   2 +
 rust/kernel/pci.rs              |   6 +-
 11 files changed, 143 insertions(+), 8 deletions(-)
 create mode 100644 rust/kernel/drm/connector.rs


base-commit: c17b750b3ad9f45f2b6f7e6f7f4679844244f0b9
-- 
2.49.0



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [RFC PATCH 1/3] rust: drm: fix C header references in doc comments
  2025-08-18  5:04 [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust Rahul Rameshbabu
@ 2025-08-18  5:04 ` Rahul Rameshbabu
  2025-08-18  7:58   ` Miguel Ojeda
  2025-08-18  5:04 ` [RFC PATCH 2/3] rust: pci: fix incorrect platform " Rahul Rameshbabu
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Rahul Rameshbabu @ 2025-08-18  5:04 UTC (permalink / raw)
  To: rust-for-linux, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Rahul Rameshbabu

The Rust DRM abstractions would incorrectly reference headers using the
non-existent path include/linux/drm. Correct the path to include/drm.

Signed-off-by: Rahul Rameshbabu <sergeantsagara@protonmail.com>
Fixes: 9a69570682b1 ("rust: drm: ioctl: Add DRM ioctl abstraction")
Fixes: 07c9016085f9 ("rust: drm: add driver abstractions")
Fixes: 1e4b8896c0f3 ("rust: drm: add device abstraction")
Fixes: a98a73be9ee9 ("rust: drm: file: Add File abstraction")
Fixes: c284d3e42338 ("rust: drm: gem: Add GEM object abstraction")
---
 rust/kernel/drm/device.rs  | 2 +-
 rust/kernel/drm/driver.rs  | 2 +-
 rust/kernel/drm/file.rs    | 2 +-
 rust/kernel/drm/gem/mod.rs | 2 +-
 rust/kernel/drm/ioctl.rs   | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs
index 3bb7c83966cf..88787a32045f 100644
--- a/rust/kernel/drm/device.rs
+++ b/rust/kernel/drm/device.rs
@@ -2,7 +2,7 @@
 
 //! DRM device.
 //!
-//! C header: [`include/linux/drm/drm_device.h`](srctree/include/linux/drm/drm_device.h)
+//! C header: [`include/drm/drm_device.h`](srctree/include/drm/drm_device.h)
 
 use crate::{
     bindings, device, drm,
diff --git a/rust/kernel/drm/driver.rs b/rust/kernel/drm/driver.rs
index fe7e8d06961a..d2dad77274c4 100644
--- a/rust/kernel/drm/driver.rs
+++ b/rust/kernel/drm/driver.rs
@@ -2,7 +2,7 @@
 
 //! DRM driver core.
 //!
-//! C header: [`include/linux/drm/drm_drv.h`](srctree/include/linux/drm/drm_drv.h)
+//! C header: [`include/drm/drm_drv.h`](srctree/include/drm/drm_drv.h)
 
 use crate::{
     bindings, device, devres, drm,
diff --git a/rust/kernel/drm/file.rs b/rust/kernel/drm/file.rs
index e8789c9110d6..8c46f8d51951 100644
--- a/rust/kernel/drm/file.rs
+++ b/rust/kernel/drm/file.rs
@@ -2,7 +2,7 @@
 
 //! DRM File objects.
 //!
-//! C header: [`include/linux/drm/drm_file.h`](srctree/include/linux/drm/drm_file.h)
+//! C header: [`include/drm/drm_file.h`](srctree/include/drm/drm_file.h)
 
 use crate::{bindings, drm, error::Result, prelude::*, types::Opaque};
 use core::marker::PhantomData;
diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index b71821cfb5ea..b9f3248876ba 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -2,7 +2,7 @@
 
 //! DRM GEM API
 //!
-//! C header: [`include/linux/drm/drm_gem.h`](srctree/include/linux/drm/drm_gem.h)
+//! C header: [`include/drm/drm_gem.h`](srctree/include/drm/drm_gem.h)
 
 use crate::{
     alloc::flags::*,
diff --git a/rust/kernel/drm/ioctl.rs b/rust/kernel/drm/ioctl.rs
index fdec01c37168..8431cdcd3ae0 100644
--- a/rust/kernel/drm/ioctl.rs
+++ b/rust/kernel/drm/ioctl.rs
@@ -2,7 +2,7 @@
 
 //! DRM IOCTL definitions.
 //!
-//! C header: [`include/linux/drm/drm_ioctl.h`](srctree/include/linux/drm/drm_ioctl.h)
+//! C header: [`include/drm/drm_ioctl.h`](srctree/include/drm/drm_ioctl.h)
 
 use crate::ioctl;
 
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 2/3] rust: pci: fix incorrect platform references in doc comments
  2025-08-18  5:04 [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust Rahul Rameshbabu
  2025-08-18  5:04 ` [RFC PATCH 1/3] rust: drm: fix C header references in doc comments Rahul Rameshbabu
@ 2025-08-18  5:04 ` Rahul Rameshbabu
  2025-08-18  5:04 ` [RFC PATCH 3/3] rust: drm: Introduce a Connector abstraction Rahul Rameshbabu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Rahul Rameshbabu @ 2025-08-18  5:04 UTC (permalink / raw)
  To: rust-for-linux, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Rahul Rameshbabu

Substitute 'platform' with 'pci' where appropriate in the comments.

Signed-off-by: Rahul Rameshbabu <sergeantsagara@protonmail.com>
Fixes: 1bd8b6b2c5d3 ("rust: pci: add basic PCI device / driver abstractions")
Fixes: 18ebb25dfa18 ("rust: pci: implement Driver::unbind()")
---
 rust/kernel/pci.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index 887ee611b553..658e806a5da7 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -240,11 +240,11 @@ pub trait Driver: Send {
 
     /// PCI driver probe.
     ///
-    /// Called when a new platform device is added or discovered.
-    /// Implementers should attempt to initialize the device here.
+    /// Called when a new pci device is added or discovered. Implementers should
+    /// attempt to initialize the device here.
     fn probe(dev: &Device<device::Core>, id_info: &Self::IdInfo) -> Result<Pin<KBox<Self>>>;
 
-    /// Platform driver unbind.
+    /// PCI driver unbind.
     ///
     /// Called when a [`Device`] is unbound from its bound [`Driver`]. Implementing this callback
     /// is optional.
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [RFC PATCH 3/3] rust: drm: Introduce a Connector abstraction
  2025-08-18  5:04 [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust Rahul Rameshbabu
  2025-08-18  5:04 ` [RFC PATCH 1/3] rust: drm: fix C header references in doc comments Rahul Rameshbabu
  2025-08-18  5:04 ` [RFC PATCH 2/3] rust: pci: fix incorrect platform " Rahul Rameshbabu
@ 2025-08-18  5:04 ` Rahul Rameshbabu
  2025-08-18  8:23 ` [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust Miguel Ojeda
  2025-08-19  9:06 ` Maxime Ripard
  4 siblings, 0 replies; 9+ messages in thread
From: Rahul Rameshbabu @ 2025-08-18  5:04 UTC (permalink / raw)
  To: rust-for-linux, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Rahul Rameshbabu

This abstraction enables implementing new DRM connector APIs in Rust.
Interfaces can be exported to both C and Rust consumers. The initial
intention is to implement a new DRM connector level backlight API to handle
multiple panels with backlight controls on a single system. Ideally,
various functionalities exposed through DDC and USB Monitor Control Class
will be plumbed through a Rust DRM Connector abstraction.

Signed-off-by: Rahul Rameshbabu <sergeantsagara@protonmail.com>
Link: https://binary-eater.github.io/tags/usb-monitor-control/
---
 drivers/gpu/drm/drm_connector.c |   9 +++
 include/drm/drm_connector.h     |  20 +++++++
 rust/bindings/bindings_helper.h |   1 +
 rust/kernel/drm/connector.rs    | 103 ++++++++++++++++++++++++++++++++
 rust/kernel/drm/mod.rs          |   2 +
 5 files changed, 135 insertions(+)
 create mode 100644 rust/kernel/drm/connector.rs

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 272d6254ea47..8e6a89ad736f 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -272,6 +272,10 @@ static int drm_connector_init_only(struct drm_device *dev,
 		goto out_put_type_id;
 	}
 
+	ret = drm_connector_init_rust(connector);
+	if (ret)
+		goto out_put_name;
+
 	/* provide ddc symlink in sysfs */
 	connector->ddc = ddc;
 
@@ -317,6 +321,9 @@ static int drm_connector_init_only(struct drm_device *dev,
 	}
 
 	connector->debugfs_entry = NULL;
+out_put_name:
+	if (ret)
+		kfree(connector->name);
 out_put_type_id:
 	if (ret)
 		ida_free(connector_ida, connector->connector_type_id);
@@ -761,6 +768,8 @@ void drm_connector_cleanup(struct drm_connector *connector)
 		    DRM_CONNECTOR_REGISTERED))
 		drm_connector_unregister(connector);
 
+	drm_connector_cleanup_rust(connector);
+
 	platform_device_unregister(connector->hdmi_audio.codec_pdev);
 
 	if (connector->privacy_screen) {
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 8f34f4b8183d..8e2a062a7151 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -2305,6 +2305,11 @@ struct drm_connector {
 	 * @cec: CEC-related data.
 	 */
 	struct drm_connector_cec cec;
+
+	/**
+	 * @rust: private data for Rust connector API.
+	 */
+	void *rust;
 };
 
 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
@@ -2346,6 +2351,21 @@ int drm_connector_attach_encoder(struct drm_connector *connector,
 
 void drm_connector_cleanup(struct drm_connector *connector);
 
+#if IS_ENABLED(CONFIG_RUST)
+int drm_connector_init_rust(struct drm_connector *connector);
+void drm_connector_cleanup_rust(struct drm_connector *connector);
+#else
+static inline int drm_connector_init_rust(struct drm_connector *connector)
+{
+	return 0;
+}
+
+static inline void drm_connector_cleanup_rust(struct drm_connector *connector)
+{
+}
+#endif
+
+
 static inline unsigned int drm_connector_index(const struct drm_connector *connector)
 {
 	return connector->index;
diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index 84d60635e8a9..c9d0d863c229 100644
--- a/rust/bindings/bindings_helper.h
+++ b/rust/bindings/bindings_helper.h
@@ -29,6 +29,7 @@
 #include <linux/hrtimer_types.h>
 
 #include <linux/acpi.h>
+#include <drm/drm_connector.h>
 #include <drm/drm_device.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_file.h>
diff --git a/rust/kernel/drm/connector.rs b/rust/kernel/drm/connector.rs
new file mode 100644
index 000000000000..a65141478d73
--- /dev/null
+++ b/rust/kernel/drm/connector.rs
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+
+//! DRM connector.
+//!
+//! C header: [`include/drm/drm_connector.h`](srctree/include/drm/drm_connector.h)
+
+use core::marker::PhantomPinned;
+use kernel::prelude::*;
+use kernel::types::{ForeignOwnable, Opaque};
+
+/// A DRM connector representation that extends `struct drm_connector`.
+///
+/// This connector implementation enables DRM connector API development in Rust
+/// and exposing said functionality to both C and Rust DRM consumers.
+///
+/// # Invariants
+///
+/// `raw_connector` is a valid pointer to a `struct drm_connector`.
+///
+/// [`struct drm_connector`]: srctree/include/drm/drm_connector.h
+#[pin_data]
+pub struct Connector {
+    #[pin]
+    raw_connector: Opaque<*mut bindings::drm_connector>,
+    rust_only_attribute: bool,
+
+    /// A connector needs to be pinned since it is referred to using a raw
+    /// pointer field `rust` in the C DRM `struct drm_connector` implementation.
+    ///
+    /// [`struct drm_connector`]: srctree/include/drm/drm_connector.h
+    #[pin]
+    _pin: PhantomPinned,
+}
+
+/// C entry point for initializing the Rust extension for a DRM connector.
+///
+/// When a DRM connector is being initialized in the core C stack, the Rust
+/// `Connector` extension needs to be allocated and initialized.
+///
+/// * `raw_connector`: A pointer to `struct drm_connector`, the C DRM connector
+///   implementation.
+///
+/// # Safety
+///
+/// * `raw_connector` must point to a valid, though partially initialized,
+///   `struct drm_connector` where the `rust` field is not already initialized.
+///
+/// `raw_connector` must point to a valid `struct drm_connector` for the
+/// duration of the function call.
+///
+/// [`struct drm_connector`]: srctree/include/drm/drm_connector.h
+#[export]
+pub unsafe extern "C" fn drm_connector_init_rust(
+    raw_connector: *mut bindings::drm_connector,
+) -> kernel::ffi::c_int {
+    let connector = match KBox::pin_init(
+        try_pin_init!(Connector{
+            raw_connector <- Opaque::new(raw_connector),
+            rust_only_attribute: true,
+            _pin: PhantomPinned,
+        }),
+        GFP_KERNEL,
+    ) {
+        Ok(kbox) => kbox,
+        Err(_) => return -ENOMEM.to_errno(),
+    };
+
+    // Provide the C `struct drm_connector` instance a handle to the Rust
+    // `drm::connector:Connector` implementation for Rust connector APIs and the
+    // `drm_connector_cleanup_rust` cleanup call.
+    //
+    // SAFETY: `raw_connector` is a valid pointer with a `rust` field that does
+    // not already point to an initialized `drm::connector::Connector`
+    unsafe { (*raw_connector).rust = connector.into_foreign() };
+
+    0
+}
+
+/// C entry point for tearing down the Rust extension for a DRM connector.
+///
+/// When a DRM connector is being cleaned up from the core C stack, the Rust
+/// `Connector` extension instance needs to be dropped.
+///
+/// * `raw_connector`: A pointer to `struct drm_connector`, the C DRM connector
+///   implementation.
+///
+/// # Safety
+///
+/// * `raw_connector` must be valid and have the `rust` field initialized by
+///   `drm_connector_init_rust()`.
+///
+/// `raw_connector` must remain valid for the duration of the function call and
+/// the `rust` field must be preserved since the `drm_connector_init_rust()`
+/// invocation.
+///
+/// [`struct drm_connector`]: srctree/include/drm/drm_connector.h
+#[export]
+pub unsafe extern "C" fn drm_connector_cleanup_rust(raw_connector: *mut bindings::drm_connector) {
+    // SAFETY: By the safety requirements of this function, the `rust` field of
+    // `raw_connector`, a valid pointer, is initialized by the `into_foreign()`
+    // call made by `drm_connector_init_rust()`.
+    drop(unsafe { <Pin<KBox<Connector>>>::from_foreign((*raw_connector).rust) });
+}
diff --git a/rust/kernel/drm/mod.rs b/rust/kernel/drm/mod.rs
index 1b82b6945edf..826fbc4da450 100644
--- a/rust/kernel/drm/mod.rs
+++ b/rust/kernel/drm/mod.rs
@@ -2,12 +2,14 @@
 
 //! DRM subsystem abstractions.
 
+pub mod connector;
 pub mod device;
 pub mod driver;
 pub mod file;
 pub mod gem;
 pub mod ioctl;
 
+pub use self::connector::Connector;
 pub use self::device::Device;
 pub use self::driver::Driver;
 pub use self::driver::DriverInfo;
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH 1/3] rust: drm: fix C header references in doc comments
  2025-08-18  5:04 ` [RFC PATCH 1/3] rust: drm: fix C header references in doc comments Rahul Rameshbabu
@ 2025-08-18  7:58   ` Miguel Ojeda
  0 siblings, 0 replies; 9+ messages in thread
From: Miguel Ojeda @ 2025-08-18  7:58 UTC (permalink / raw)
  To: Rahul Rameshbabu
  Cc: rust-for-linux, dri-devel, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich

On Mon, Aug 18, 2025 at 7:04 AM Rahul Rameshbabu
<sergeantsagara@protonmail.com> wrote:
>
> The Rust DRM abstractions would incorrectly reference headers using the
> non-existent path include/linux/drm. Correct the path to include/drm.
>
> Signed-off-by: Rahul Rameshbabu <sergeantsagara@protonmail.com>
> Fixes: 9a69570682b1 ("rust: drm: ioctl: Add DRM ioctl abstraction")
> Fixes: 07c9016085f9 ("rust: drm: add driver abstractions")
> Fixes: 1e4b8896c0f3 ("rust: drm: add device abstraction")
> Fixes: a98a73be9ee9 ("rust: drm: file: Add File abstraction")
> Fixes: c284d3e42338 ("rust: drm: gem: Add GEM object abstraction")

This is https://lore.kernel.org/rust-for-linux/20250730130716.3278285-3-ojeda@kernel.org/

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust
  2025-08-18  5:04 [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust Rahul Rameshbabu
                   ` (2 preceding siblings ...)
  2025-08-18  5:04 ` [RFC PATCH 3/3] rust: drm: Introduce a Connector abstraction Rahul Rameshbabu
@ 2025-08-18  8:23 ` Miguel Ojeda
  2025-08-19  9:06 ` Maxime Ripard
  4 siblings, 0 replies; 9+ messages in thread
From: Miguel Ojeda @ 2025-08-18  8:23 UTC (permalink / raw)
  To: Rahul Rameshbabu
  Cc: rust-for-linux, dri-devel, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich

On Mon, Aug 18, 2025 at 7:04 AM Rahul Rameshbabu
<sergeantsagara@protonmail.com> wrote:
>
> I did toss in two doc comment cleanup patches in the mix. If these need to
> be re-sent individually or split due to the multiple Fixes: tags, do not
> hesitate to let me know.

Thanks!

Normally, if they are independent, like in this case, they would
normally go separately. It is typically important for fixes (and
especially so urgent ones, of course), since those may get applied
into the current cycle rather than during the merge window. It depends
on the timing, the subsystem, the fix...

For the second one here, for instance, since it is not critical, we
can simply land the entire cleanup in the other series soon, but it is
definitely possible to get the fixes in earlier too.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust
  2025-08-18  5:04 [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust Rahul Rameshbabu
                   ` (3 preceding siblings ...)
  2025-08-18  8:23 ` [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust Miguel Ojeda
@ 2025-08-19  9:06 ` Maxime Ripard
  2025-08-20  4:46   ` Rahul Rameshbabu
  4 siblings, 1 reply; 9+ messages in thread
From: Maxime Ripard @ 2025-08-19  9:06 UTC (permalink / raw)
  To: Rahul Rameshbabu
  Cc: rust-for-linux, dri-devel, Maarten Lankhorst, Thomas Zimmermann,
	David Airlie, Simona Vetter, Miguel Ojeda, Alex Gaynor,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich

[-- Attachment #1: Type: text/plain, Size: 862 bytes --]

Hi Rahul,

On Mon, Aug 18, 2025 at 05:04:15AM +0000, Rahul Rameshbabu wrote:
> I am working on a drm_connector scoped backlight API in Rust. I have been
> looking through Hans de Goede's previous efforts on this topic to help
> guide my design. My hope is to enable backlight control over external
> displays through DDC or USB Monitor Control Class while also supporting
> internal panels. In parallel, I would like to improve the driver
> probing/selection mechanism when there are different candidates for driving
> a backlight device. This initial RFC is mainly intended to sanity check
> that the plumbing I have chosen for extending the DRM connector
> functionality in Rust seems reasonable.

It's a great goal, and I had that same discussion with Hans recently
too, but I can't find the link between backling/DDC CI, and Rust. Can
you elaborate?

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust
  2025-08-19  9:06 ` Maxime Ripard
@ 2025-08-20  4:46   ` Rahul Rameshbabu
  2025-08-27  6:57     ` Maxime Ripard
  0 siblings, 1 reply; 9+ messages in thread
From: Rahul Rameshbabu @ 2025-08-20  4:46 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: rust-for-linux, dri-devel, Maarten Lankhorst, Thomas Zimmermann,
	David Airlie, Simona Vetter, Miguel Ojeda, Alex Gaynor,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich

On Tue, 19 Aug, 2025 11:06:40 +0200 "Maxime Ripard" <mripard@kernel.org> wrote:
> Hi Rahul,
>
> On Mon, Aug 18, 2025 at 05:04:15AM +0000, Rahul Rameshbabu wrote:
>> I am working on a drm_connector scoped backlight API in Rust. I have been
>> looking through Hans de Goede's previous efforts on this topic to help
>> guide my design. My hope is to enable backlight control over external
>> displays through DDC or USB Monitor Control Class while also supporting
>> internal panels. In parallel, I would like to improve the driver
>> probing/selection mechanism when there are different candidates for driving
>> a backlight device. This initial RFC is mainly intended to sanity check
>> that the plumbing I have chosen for extending the DRM connector
>> functionality in Rust seems reasonable.
>
> It's a great goal, and I had that same discussion with Hans recently
> too, but I can't find the link between backling/DDC CI, and Rust. Can
> you elaborate?

Hi Maxime,

Sure, let me elaborate on this. You are right that plumbing DDC
CI/backlight support at the DRM connector level does not need to be
implemented in Rust.

If we look at Hans's proposal, the suggested phase 2 was to add a
drm_connector helper function for plumbing a pointer to the backlight
device implementation. I had some model differences with regards to how
the API would look like, mostly stemming from concerns about providing
better runtime overriding of the acpi_video_get_backlight_type based
backlight selection. However, I am aligned with the direction of scoping
at the drm_connector level. I basically was interested in implementing
this helper functionality in Rust instead of C, which is where Rust came
into play.

I was also interested in declaring and attaching a drm_property in Rust
for controlling properties such as backlight rather than updating the
drm_connector declaration in C as an experiment.

Let me know if you feel like this work would be better off as a C
implementation. I can also send out a detailed architecture proposal to
the mailing list if that would help.

Link: https://lore.freedesktop.org/wayland-devel/0d188965-d809-81b5-74ce-7d30c49fee2d@redhat.com/

Thanks,
Rahul Rameshbabu

>
> Maxime


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust
  2025-08-20  4:46   ` Rahul Rameshbabu
@ 2025-08-27  6:57     ` Maxime Ripard
  0 siblings, 0 replies; 9+ messages in thread
From: Maxime Ripard @ 2025-08-27  6:57 UTC (permalink / raw)
  To: Rahul Rameshbabu
  Cc: rust-for-linux, dri-devel, Maarten Lankhorst, Thomas Zimmermann,
	David Airlie, Simona Vetter, Miguel Ojeda, Alex Gaynor,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich

[-- Attachment #1: Type: text/plain, Size: 2892 bytes --]

Hi Rahul,

On Wed, Aug 20, 2025 at 04:46:52AM +0000, Rahul Rameshbabu wrote:
> On Tue, 19 Aug, 2025 11:06:40 +0200 "Maxime Ripard" <mripard@kernel.org> wrote:
> > Hi Rahul,
> >
> > On Mon, Aug 18, 2025 at 05:04:15AM +0000, Rahul Rameshbabu wrote:
> >> I am working on a drm_connector scoped backlight API in Rust. I have been
> >> looking through Hans de Goede's previous efforts on this topic to help
> >> guide my design. My hope is to enable backlight control over external
> >> displays through DDC or USB Monitor Control Class while also supporting
> >> internal panels. In parallel, I would like to improve the driver
> >> probing/selection mechanism when there are different candidates for driving
> >> a backlight device. This initial RFC is mainly intended to sanity check
> >> that the plumbing I have chosen for extending the DRM connector
> >> functionality in Rust seems reasonable.
> >
> > It's a great goal, and I had that same discussion with Hans recently
> > too, but I can't find the link between backling/DDC CI, and Rust. Can
> > you elaborate?
> 
> Hi Maxime,
> 
> Sure, let me elaborate on this. You are right that plumbing DDC
> CI/backlight support at the DRM connector level does not need to be
> implemented in Rust.
> 
> If we look at Hans's proposal, the suggested phase 2 was to add a
> drm_connector helper function for plumbing a pointer to the backlight
> device implementation. I had some model differences with regards to how
> the API would look like, mostly stemming from concerns about providing
> better runtime overriding of the acpi_video_get_backlight_type based
> backlight selection. However, I am aligned with the direction of scoping
> at the drm_connector level. I basically was interested in implementing
> this helper functionality in Rust instead of C, which is where Rust came
> into play.
> 
> I was also interested in declaring and attaching a drm_property in Rust
> for controlling properties such as backlight rather than updating the
> drm_connector declaration in C as an experiment.
> 
> Let me know if you feel like this work would be better off as a C
> implementation. I can also send out a detailed architecture proposal to
> the mailing list if that would help.
> 
> Link: https://lore.freedesktop.org/wayland-devel/0d188965-d809-81b5-74ce-7d30c49fee2d@redhat.com/

Thanks for the explanation.

I'm not sure Rust is at the point where we can use it for the framework.
If we want to make this work useful, we have to make it consistent and
usable across all drivers, but we do have drivers for architectures that
aren't supported by Rust yet (let alone tier 1).

So it feels to me that it would be a bit premature for that work to be
in Rust. If you do want to use it from a Rust driver though, feel free
to write bindings for it, that would be a great addition.

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-08-27  6:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18  5:04 [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust Rahul Rameshbabu
2025-08-18  5:04 ` [RFC PATCH 1/3] rust: drm: fix C header references in doc comments Rahul Rameshbabu
2025-08-18  7:58   ` Miguel Ojeda
2025-08-18  5:04 ` [RFC PATCH 2/3] rust: pci: fix incorrect platform " Rahul Rameshbabu
2025-08-18  5:04 ` [RFC PATCH 3/3] rust: drm: Introduce a Connector abstraction Rahul Rameshbabu
2025-08-18  8:23 ` [RFC PATCH 0/3] Initial plumbing for implementing DRM connector APIs in Rust Miguel Ojeda
2025-08-19  9:06 ` Maxime Ripard
2025-08-20  4:46   ` Rahul Rameshbabu
2025-08-27  6:57     ` Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).