@@ -5,7 +5,8 @@
//! C header: [`include/drm/drm_plane.h`](srctree/include/drm/drm_plane.h)
use super::{
- atomic::*, KmsDriver, ModeObject, ModeObjectVtable, StaticModeObject, UnregisteredKmsDevice,
+ atomic::*, crtc::*, KmsDriver, ModeObject, ModeObjectVtable, StaticModeObject,
+ UnregisteredKmsDevice,
};
use crate::{
alloc::KBox,
@@ -608,6 +609,16 @@ fn plane(&self) -> &Self::Plane {
// invariant throughout the lifetime of the Plane
unsafe { Self::Plane::from_raw(self.as_raw().plane) }
}
+
+ /// Return the current [`OpaqueCrtc`] assigned to this plane, if there is one.
+ fn crtc<'a, 'b: 'a, D>(&'a self) -> Option<&'b OpaqueCrtc<D>>
+ where
+ Self::Plane: ModeObject<Driver = D>,
+ D: KmsDriver,
+ {
+ // SAFETY: This cast is guaranteed safe by `OpaqueCrtc`s invariants.
+ NonNull::new(self.as_raw().crtc).map(|c| unsafe { OpaqueCrtc::from_raw(c.as_ptr()) })
+ }
}
impl<T: AsRawPlaneState + ?Sized> RawPlaneState for T {}
Add a binding for checking drm_plane_state.crtc. Note that we don't have a way of knowing what DriverCrtc implementation would be used here (and want to make this function also available on OpaquePlaneState types), so we return an OpaqueCrtc. Signed-off-by: Lyude Paul <lyude@redhat.com> --- rust/kernel/drm/kms/plane.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)