Refactor print connector and connectors
This commit is contained in:
parent
0860a4cd7b
commit
17d4e59f76
1 changed files with 18 additions and 12 deletions
30
src/main.rs
30
src/main.rs
|
@ -11,26 +11,32 @@ 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);
|
||||||
Ok(connector) => {
|
|
||||||
println!("\t{} ({:?})", connector.interface().as_str(), connector.state());
|
|
||||||
|
|
||||||
let encoder_info = format_encoder(&gpu, connector.current_encoder());
|
|
||||||
|
|
||||||
println!("\t\tEncoder: {}", encoder_info);
|
|
||||||
|
|
||||||
println!(""); // Add blank line
|
|
||||||
},
|
|
||||||
Err(_) => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_connector(gpu: &card::Card, connector_handle: &drm::control::connector::Handle) {
|
||||||
|
match gpu.get_connector(*connector_handle, false) {
|
||||||
|
Ok(connector) => {
|
||||||
|
println!("\t{} ({:?})", connector.interface().as_str(), connector.state());
|
||||||
|
|
||||||
|
let encoder_info = format_encoder(&gpu, connector.current_encoder());
|
||||||
|
|
||||||
|
println!("\t\tEncoder: {}", encoder_info);
|
||||||
|
println!(""); // Add blank line
|
||||||
|
},
|
||||||
|
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 {
|
||||||
match encoder_handle.and_then(|handle| gpu.get_encoder(handle).ok()) {
|
match encoder_handle.and_then(|handle| gpu.get_encoder(handle).ok()) {
|
||||||
Some(encoder) => {
|
Some(encoder) => {
|
||||||
|
|
Loading…
Reference in a new issue