Refactor print connector and connectors

This commit is contained in:
Florian RICHER 2024-10-04 00:23:02 +02:00
parent 0860a4cd7b
commit 17d4e59f76

View file

@ -11,24 +11,30 @@ fn main() {
}; };
println!("{:?}", gpu); println!("{:?}", gpu);
print_connectors(&gpu);
}
fn print_connectors(gpu: &card::Card) {
let resource_handles = gpu.resource_handles().unwrap(); let resource_handles = gpu.resource_handles().unwrap();
println!("Connectors:"); println!("Connectors:");
for handle in resource_handles.connectors() { for handle in resource_handles.connectors() {
match gpu.get_connector(*handle, false) { print_connector(&gpu, handle);
}
}
fn print_connector(gpu: &card::Card, connector_handle: &drm::control::connector::Handle) {
match gpu.get_connector(*connector_handle, false) {
Ok(connector) => { Ok(connector) => {
println!("\t{} ({:?})", connector.interface().as_str(), connector.state()); println!("\t{} ({:?})", connector.interface().as_str(), connector.state());
let encoder_info = format_encoder(&gpu, connector.current_encoder()); let encoder_info = format_encoder(&gpu, connector.current_encoder());
println!("\t\tEncoder: {}", encoder_info); println!("\t\tEncoder: {}", encoder_info);
println!(""); // Add blank line println!(""); // Add blank line
}, },
Err(_) => {} Err(_) => {}
} };
}
} }
fn format_encoder(gpu: &card::Card, encoder_handle: Option<drm::control::encoder::Handle>) -> String { fn format_encoder(gpu: &card::Card, encoder_handle: Option<drm::control::encoder::Handle>) -> String {