1use crate::control;
16use drm_ffi as ffi;
17
18#[repr(transparent)]
20#[derive(Copy, Clone, Hash, PartialEq, Eq)]
21pub struct Handle(control::RawResourceHandle);
22
23unsafe impl bytemuck::ZeroableInOption for Handle {}
25unsafe impl bytemuck::PodInOption for Handle {}
26
27impl From<Handle> for control::RawResourceHandle {
28 fn from(handle: Handle) -> Self {
29 handle.0
30 }
31}
32
33impl From<Handle> for u32 {
34 fn from(handle: Handle) -> Self {
35 handle.0.into()
36 }
37}
38
39impl From<control::RawResourceHandle> for Handle {
40 fn from(handle: control::RawResourceHandle) -> Self {
41 Handle(handle)
42 }
43}
44
45impl control::ResourceHandle for Handle {
46 const FFI_TYPE: u32 = ffi::DRM_MODE_OBJECT_CRTC;
47}
48
49impl std::fmt::Debug for Handle {
50 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
51 f.debug_tuple("crtc::Handle").field(&self.0).finish()
52 }
53}
54
55#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
57pub struct Info {
58 pub(crate) handle: Handle,
59 pub(crate) position: (u32, u32),
60 pub(crate) mode: Option<control::Mode>,
61 pub(crate) fb: Option<control::framebuffer::Handle>,
62 pub(crate) gamma_length: u32,
63}
64
65impl Info {
66 pub fn handle(&self) -> Handle {
68 self.handle
69 }
70
71 pub fn position(&self) -> (u32, u32) {
73 self.position
74 }
75
76 pub fn mode(&self) -> Option<control::Mode> {
78 self.mode
79 }
80
81 pub fn framebuffer(&self) -> Option<control::framebuffer::Handle> {
83 self.fb
84 }
85
86 pub fn gamma_length(&self) -> u32 {
88 self.gamma_length
89 }
90}