Refactor format crtc

This commit is contained in:
Florian RICHER 2024-10-03 23:22:40 +02:00
parent 4319a48063
commit f479143eba
2 changed files with 11 additions and 7 deletions

View file

@ -56,4 +56,4 @@ impl Debug for Card {
}
}
impl ControlDevice for Card {}
impl ControlDevice for Card {}

View file

@ -27,10 +27,7 @@ fn main() {
let encoder_info = match current_encoder {
Some(encoder) => {
let crtc_info = encoder.crtc()
.and_then(|crtc_handle| gpu.get_crtc(crtc_handle).ok())
.and_then(|crtc| Some(format!("{:?}", crtc)))
.unwrap_or_else(|| format!("No CRTC data"));
let crtc_info = format_crtc(&gpu, encoder.crtc());
format!("{:?}, {}", encoder.kind(), crtc_info)
}
@ -38,10 +35,17 @@ fn main() {
};
println!("\t\tEncoder: {}", encoder_info);
println!(""); // Add blank line
},
Err(_) => {}
}
}
}
}
fn format_crtc(gpu: &card::Card, crtc_handle: Option<drm::control::crtc::Handle>) -> String {
match crtc_handle.and_then(|handle| Some(gpu.get_crtc(handle))) {
Some(crtc) => format!("{:?}", crtc),
None => format!("No CRTC data")
}
}