Skip to content

Commit f706bb5

Browse files
committed
--pdports: Decode DP alt mode bits
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 43f1ab0 commit f706bb5

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

framework_lib/src/power.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,35 @@ pub fn get_and_print_cypd_pd_info(ec: &CrosEc) {
867867
" Active Port: {}",
868868
if info.active_port != 0 { "Yes" } else { "No" }
869869
);
870-
println!(" Alt Mode: 0x{:02X}", info.pd_alt_mode_status);
870+
let alt = info.pd_alt_mode_status;
871+
if connected && alt != 0 {
872+
let mut modes = vec![];
873+
if alt & 0x01 != 0 {
874+
modes.push("DFP_D Connected");
875+
}
876+
if alt & 0x02 != 0 {
877+
modes.push("UFP_D Connected");
878+
}
879+
if alt & 0x04 != 0 {
880+
modes.push("Power Low");
881+
}
882+
if alt & 0x08 != 0 {
883+
modes.push("Enabled");
884+
}
885+
if alt & 0x10 != 0 {
886+
modes.push("Multi-Function");
887+
}
888+
if alt & 0x20 != 0 {
889+
modes.push("USB Config");
890+
}
891+
if alt & 0x40 != 0 {
892+
modes.push("Exit Request");
893+
}
894+
if alt & 0x80 != 0 {
895+
modes.push("HPD High");
896+
}
897+
println!(" DP Alt Mode: {} (0x{:02X})", modes.join(", "), alt);
898+
}
871899
}
872900
Err(e) => {
873901
print_err::<()>(Err(e));

0 commit comments

Comments
 (0)