[WIP RFC v2 09/35] WIP: rust: drm/kms: Add Connector.attach_encoder()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds a simple binding for completing the last step of creating a DRM
connector - attaching its encoder. This function should only be called
before the connector is registered, and DRM should enforce this itself by
returning an error if a driver tries to add an encoder to an
already-registered DRM connector.

Note that unlike most of the methods we'll be adding to DRM mode objects,
this is directly implemented on the Connector<T> type since I don't really
think it would make sense for us to allow this operation on an
OpaqueConnector (a DRM connector without a known DriverConnector
implementation, something we'll be adding in the next few commits).

Signed-off-by: Lyude Paul <lyude@xxxxxxxxxx>

---

TODO:
* Figure out a solution for making sure that this can only be called when a
  Connector is unregistered, probably via an UnregisteredConnector type.

Signed-off-by: Lyude Paul <lyude@xxxxxxxxxx>
---
 rust/kernel/drm/kms/connector.rs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/rust/kernel/drm/kms/connector.rs b/rust/kernel/drm/kms/connector.rs
index 0fa927a3743b2..54457b327c365 100644
--- a/rust/kernel/drm/kms/connector.rs
+++ b/rust/kernel/drm/kms/connector.rs
@@ -28,6 +28,7 @@
 use super::{
     ModeObject,
     RcModeObject,
+    encoder::*,
     KmsDriver,
 };
 use macros::pin_data;
@@ -227,6 +228,20 @@ pub fn new(
             ARef::from_raw(NonNull::new_unchecked(Box::into_raw(Pin::into_inner_unchecked(new))))
         })
     }
+
+    /// Attach an encoder to this [`Connector`].
+    ///
+    /// TODO: Move this to an `UnregisteredConnector` interface somehow…
+    #[must_use]
+    pub fn attach_encoder<E>(&self, encoder: &Encoder<E>) -> Result
+    where
+        E: DriverEncoder<Driver = T::Driver>
+    {
+        // SAFETY: FFI call with no special requirements
+        to_result(unsafe {
+            bindings::drm_connector_attach_encoder(self.as_raw(), encoder.as_raw())
+        })
+    }
 }
 
 /// A trait implemented by any type that acts as a [`struct drm_connector`] interface.
-- 
2.46.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux