Skip to content

Commit 867e4c6

Browse files
committed
--pdorts: Hide values depending on context
- VCONN and Negotiated only makes sense if there's a connection - On top of that Port Partner role, EPR and sink active only makes sense with pd contract - Rename Active Port to Sink Active to be clearer Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 67860c9 commit 867e4c6

2 files changed

Lines changed: 62 additions & 55 deletions

File tree

EXAMPLES.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -736,60 +736,60 @@ Alongside a 65W SDR adapter - which is not active, because the EC firmware switc
736736

737737
```
738738
USB-C Port 0:
739-
Port Partner: Source
740739
PD Contract: Yes
741740
Power Role: Sink
742741
Data Role: Dfp
743742
VCONN: Off
744743
Negotiated: 48.000 V, 5000 mA, 240.0 W
745-
EPR: Active (Supported)
746744
CC Polarity: CC1
747-
Active Port: Yes
748-
USB-C Port 1:
749745
Port Partner: Source
746+
EPR: Active (Supported)
747+
Sink Active: Yes
748+
USB-C Port 1:
750749
PD Contract: Yes
751750
Power Role: Sink
752751
Data Role: Ufp
753752
VCONN: Off
754753
Negotiated: 20.000 V, 3000 mA, 60.0 W
755-
EPR: Inactive
756754
CC Polarity: CC1
757-
Active Port: No
755+
Port Partner: Source
756+
EPR: Inactive
757+
Sink Active: No
758758
```
759759

760760
A 100W SDR power adapter connected:
761761

762762
```
763763
USB-C Port 0:
764-
Port Partner: Source
765764
PD Contract: Yes
766765
Power Role: Sink
767766
Data Role: Ufp
768767
VCONN: Off
769768
Negotiated: 20.000 V, 5000 mA, 100.0 W
770-
EPR: Inactive
771769
CC Polarity: CC1
772-
Active Port: Yes
770+
Port Partner: Source
771+
EPR: Inactive
772+
Sink Active: Yes
773773
```
774774

775775
A 65W (Framework) power adapter connected:
776776

777777
```
778778
USB-C Port 0:
779-
Port Partner: Source
780779
PD Contract: Yes
781780
Power Role: Sink
782781
Data Role: Dfp
783782
VCONN: On
784783
Negotiated: 20.000 V, 3250 mA, 65.0 W
785-
EPR: Inactive
786784
CC Polarity: CC2
787-
Active Port: Yes
785+
Port Partner: Source
786+
EPR: Inactive
787+
Sink Active: Yes
788788
```
789789

790790
### Devices
791791

792-
A USB2/3 device connected (even USB-A Expansion Card):
792+
A high power USB2/3 device connected:
793793

794794
```
795795
USB-C Port 2:
@@ -798,24 +798,32 @@ USB-C Port 2:
798798
Data Role: Dfp
799799
VCONN: Off
800800
Negotiated: 5.000 V, 3000 mA, 15.0 W
801-
EPR: Inactive
802801
CC Polarity: CC1
803-
Active Port: No
802+
```
803+
804+
A low power USB2/3 device connected (even USB-A Expansion Card):
805+
806+
```
807+
USB-C Port 3:
808+
PD Contract: No
809+
Power Role: Source
810+
Data Role: Dfp
811+
VCONN: Off
812+
Negotiated: 5.000 V, 1500 mA, 7.500 W
813+
CC Polarity: CC2
804814
```
805815

806816
A Display connected through Framework DisplayPort Expansion card:
807817

808818
```
809819
USB-C Port 1:
810-
Port Partner: Sink
811820
PD Contract: Yes
812821
Power Role: Source
813822
Data Role: Dfp
814823
VCONN: On
815824
Negotiated: 5.000 V, 410 mA, 2.50 W
816-
EPR: Inactive
817825
CC Polarity: CC1
818-
Active Port: No
826+
Port Partner: Sink
819827
DP Alt Mode: DFP_D Connected, HPD High (0x81)
820828
```
821829

@@ -826,8 +834,4 @@ USB-C Port 3:
826834
PD Contract: No
827835
Power Role: Sink
828836
Data Role: Ufp
829-
VCONN: Off
830-
Negotiated: 0.000 V, 0 mA, 0.0 W
831-
EPR: Inactive
832-
Active Port: No
833837
```

framework_lib/src/power.rs

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ impl From<u8> for CypdTypeCState {
745745
}
746746
}
747747

748-
#[derive(Debug)]
748+
#[derive(Debug, PartialEq)]
749749
enum CypdPdPowerRole {
750750
Sink,
751751
Source,
@@ -797,42 +797,27 @@ pub fn get_and_print_cypd_pd_info(ec: &CrosEc) {
797797
let voltage = { info.voltage };
798798
let current = { info.current };
799799
let watts_mw = voltage as u32 * current as u32 / 1000;
800+
let has_pd_contract = info.pd_state != 0;
800801

801-
if info.pd_state {
802-
println!(" Port Partner: {:?}", c_state);
803-
}
804802
println!(
805803
" PD Contract: {}",
806804
if info.pd_state != 0 { "Yes" } else { "No" }
807805
);
808806
println!(" Power Role: {:?}", power_role);
809807
println!(" Data Role: {:?}", data_role);
810-
println!(
811-
" VCONN: {}",
812-
if info.vconn != 0 { "On" } else { "Off" }
813-
);
814-
println!(
815-
" Negotiated: {}.{:03} V, {} mA, {}.{} W",
816-
voltage / 1000,
817-
voltage % 1000,
818-
current,
819-
watts_mw / 1000,
820-
watts_mw % 1000,
821-
);
822-
println!(
823-
" EPR: {}{}",
824-
if info.epr_active != 0 {
825-
"Active"
826-
} else {
827-
"Inactive"
828-
},
829-
if info.epr_support != 0 {
830-
" (Supported)"
831-
} else {
832-
""
833-
}
834-
);
835808
if connected {
809+
println!(
810+
" VCONN: {}",
811+
if info.vconn != 0 { "On" } else { "Off" }
812+
);
813+
println!(
814+
" Negotiated: {}.{:03} V, {} mA, {}.{} W",
815+
voltage / 1000,
816+
voltage % 1000,
817+
current,
818+
watts_mw / 1000,
819+
watts_mw % 1000,
820+
);
836821
println!(
837822
" CC Polarity: {}",
838823
match info.cc_polarity {
@@ -844,10 +829,28 @@ pub fn get_and_print_cypd_pd_info(ec: &CrosEc) {
844829
}
845830
);
846831
}
847-
println!(
848-
" Active Port: {}",
849-
if info.active_port != 0 { "Yes" } else { "No" }
850-
);
832+
if has_pd_contract {
833+
println!(" Port Partner: {:?}", c_state);
834+
println!(
835+
" EPR: {}{}",
836+
if info.epr_active != 0 {
837+
"Active"
838+
} else {
839+
"Inactive"
840+
},
841+
if info.epr_support != 0 {
842+
" (Supported)"
843+
} else {
844+
""
845+
}
846+
);
847+
if power_role == CypdPdPowerRole::Sink {
848+
println!(
849+
" Sink Active: {}",
850+
if info.active_port != 0 { "Yes" } else { "No" }
851+
);
852+
}
853+
}
851854
let alt = info.pd_alt_mode_status;
852855
// Bits 0-1 indicate DP alt mode is active (bit 0 = DFP_D/TBT,
853856
// bit 1 = UFP_D). Only show when actually in DP alt mode.

0 commit comments

Comments
 (0)