@@ -129,6 +129,16 @@ struct Encoder {
129129 // index: u32,
130130}
131131
132+ impl Encoder {
133+ pub fn new ( object_id : u32 ) -> Arc < Self > {
134+ Arc :: new_cyclic ( |sref| Self {
135+ sref : sref. clone ( ) ,
136+
137+ object_id,
138+ } )
139+ }
140+ }
141+
132142impl ModeObject for Encoder {
133143 fn id ( & self ) -> u32 {
134144 self . object_id
@@ -144,13 +154,31 @@ impl ModeObject for Encoder {
144154struct Connector {
145155 sref : Weak < Self > ,
146156
157+ /// The current status of the connector.
158+ status : DrmModeConStatus ,
159+ /// The current encoder for this connector.
160+ current_encoder : Arc < Encoder > ,
161+ /// A vector contaning all the possible encoders for this connector.
162+ possible_encoders : Vec < Arc < Encoder > > ,
163+ connector_typ : u32 ,
164+
147165 object_id : u32 ,
148166}
149167
150168impl Connector {
151- pub fn new ( object_id : u32 ) -> Arc < Self > {
169+ pub fn new (
170+ current_encoder : Arc < Encoder > ,
171+ possible_encoders : Vec < Arc < Encoder > > ,
172+ status : DrmModeConStatus ,
173+ object_id : u32 ,
174+ ) -> Arc < Self > {
152175 Arc :: new_cyclic ( |sref| Self {
153176 sref : sref. clone ( ) ,
177+
178+ status,
179+ current_encoder,
180+ possible_encoders,
181+ connector_typ : 0 , // todo
154182 object_id,
155183 } )
156184 }
@@ -378,6 +406,35 @@ impl INodeInterface for Drm {
378406
379407 let object = self . find_object ( struc. connector_id ) . unwrap ( ) . as_connector ( ) ;
380408
409+ // Fill in the array contaning all of the possible encoders and its length.
410+ let encoder_ids_ptr = struc. encoders_ptr as * mut u32 ;
411+ let mut encoder_count = 0 ;
412+
413+ copy_field :: < u32 > (
414+ encoder_ids_ptr,
415+ & mut encoder_count,
416+ object
417+ . possible_encoders
418+ . iter ( )
419+ . map ( |e| e. id ( ) )
420+ . collect :: < Vec < _ > > ( )
421+ . as_slice ( ) ,
422+ ) ;
423+
424+ struc. count_encoders = encoder_count as _ ;
425+
426+ struc. encoder_id = object. current_encoder . id ( ) ;
427+ struc. connector_type = object. connector_typ ;
428+ struc. connector_type_id = 0 ; // todo
429+ struc. connection = object. status as _ ;
430+
431+ // NOTE: The physical size will come from the EDID.
432+ struc. mm_width = 0 ; // todo
433+ struc. mm_height = 0 ; // todo
434+ struc. subpixel = 0 ; // todo
435+ struc. count_modes = 0 ; // todo
436+ struc. modes_ptr = 0 ; // todo
437+
381438 Ok ( 0 )
382439 }
383440
0 commit comments