@@ -129,6 +129,16 @@ struct Encoder {
129
129
// index: u32,
130
130
}
131
131
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
+
132
142
impl ModeObject for Encoder {
133
143
fn id ( & self ) -> u32 {
134
144
self . object_id
@@ -144,13 +154,31 @@ impl ModeObject for Encoder {
144
154
struct Connector {
145
155
sref : Weak < Self > ,
146
156
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
+
147
165
object_id : u32 ,
148
166
}
149
167
150
168
impl 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 > {
152
175
Arc :: new_cyclic ( |sref| Self {
153
176
sref : sref. clone ( ) ,
177
+
178
+ status,
179
+ current_encoder,
180
+ possible_encoders,
181
+ connector_typ : 0 , // todo
154
182
object_id,
155
183
} )
156
184
}
@@ -378,6 +406,35 @@ impl INodeInterface for Drm {
378
406
379
407
let object = self . find_object ( struc. connector_id ) . unwrap ( ) . as_connector ( ) ;
380
408
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
+
381
438
Ok ( 0 )
382
439
}
383
440
0 commit comments