Refactor encoder info
This commit is contained in:
parent
f479143eba
commit
0860a4cd7b
1 changed files with 12 additions and 13 deletions
25
src/main.rs
25
src/main.rs
|
@ -20,19 +20,7 @@ fn main() {
|
|||
Ok(connector) => {
|
||||
println!("\t{} ({:?})", connector.interface().as_str(), connector.state());
|
||||
|
||||
let current_encoder = connector
|
||||
.current_encoder()
|
||||
.and_then(|encoder_handle| gpu.get_encoder(encoder_handle).ok());
|
||||
|
||||
let encoder_info = match current_encoder {
|
||||
Some(encoder) => {
|
||||
|
||||
let crtc_info = format_crtc(&gpu, encoder.crtc());
|
||||
|
||||
format!("{:?}, {}", encoder.kind(), crtc_info)
|
||||
}
|
||||
None => format!("No encoder found")
|
||||
};
|
||||
let encoder_info = format_encoder(&gpu, connector.current_encoder());
|
||||
|
||||
println!("\t\tEncoder: {}", encoder_info);
|
||||
|
||||
|
@ -43,6 +31,17 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
Some(encoder) => {
|
||||
let crtc_info = format_crtc(&gpu, encoder.crtc());
|
||||
|
||||
format!("{:?}, {}", encoder.kind(), crtc_info)
|
||||
}
|
||||
None => format!("No encoder found")
|
||||
}
|
||||
}
|
||||
|
||||
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),
|
||||
|
|
Loading…
Reference in a new issue