diff --git a/EXAMPLES.md b/EXAMPLES.md index 420d06e..eda71ae 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -80,9 +80,9 @@ Options: --intrusion Show status of intrusion switch --inputdeck - Show status of the input modules (Framework 16 only) + Show status of the input modules --inputdeck-mode - Set input deck power mode [possible values: auto, off, on] (Framework 16 only) [possible values: auto, off, on] + Set input deck power mode [possible values: auto, off, on] (Laptop 12, 13, 16) [possible values: auto, off, on] --expansion-bay Show status of the expansion bay (Framework 16 only) --charge-limit [] @@ -349,9 +349,12 @@ ESRT Entry 3 > framework_tool --inputdeck Input Deck Chassis Closed: true - Power Button Board: Present - Audio Daughterboard: Present - Touchpad: Present + Power Button Board: Present (10) + ADC Value 1655mV + Audio Daughterboard: Present (2) + ADC Value 0302mV + Touchpad: Present (10) + ADC Value 1655mV ``` ### On Framework 13 @@ -360,8 +363,12 @@ Input Deck > framework_tool --inputdeck Input Deck Chassis Closed: true - Audio Daughterboard: Present - Touchpad: Present + Audio Daughterboard: Present (7) + ADC Value 1056mV + Touchpad: Present (7) + ADC Value 1042mV + Deck State: On + Touchpad present: true ``` ### On Framework 16 diff --git a/framework_lib/src/chromium_ec/command.rs b/framework_lib/src/chromium_ec/command.rs index 07bf4d3..5e7351a 100644 --- a/framework_lib/src/chromium_ec/command.rs +++ b/framework_lib/src/chromium_ec/command.rs @@ -90,7 +90,7 @@ pub enum EcCommands { PriavcySwitchesCheckMode = 0x3E14, /// Not used by this library ChassisCounter = 0x3E15, - /// On Framework 16, check the status of the input module deck + /// Check the status of the input module deck (Laptop 12, 13, 16) CheckDeckState = 0x3E16, /// Not used by this library GetSimpleVersion = 0x3E17, diff --git a/framework_lib/src/chromium_ec/input_deck.rs b/framework_lib/src/chromium_ec/input_deck.rs index 28a20df..6892068 100644 --- a/framework_lib/src/chromium_ec/input_deck.rs +++ b/framework_lib/src/chromium_ec/input_deck.rs @@ -136,6 +136,7 @@ pub struct InputDeckStatus { pub state: InputDeckState, pub hubboard_present: bool, pub touchpad_present: bool, + pub touchpad_id: u8, pub top_row: TopRowPositions, } @@ -177,16 +178,20 @@ impl InputDeckStatus { impl From for InputDeckStatus { fn from(item: EcResponseDeckState) -> Self { + let tp_id = InputModuleType::from(item.board_id[InputDeckMux::Touchpad as usize]); + let tp_present = !matches!( + tp_id, + InputModuleType::Short | InputModuleType::Disconnected + ); + InputDeckStatus { state: InputDeckState::from(item.deck_state), hubboard_present: matches!( InputModuleType::from(item.board_id[InputDeckMux::HubBoard as usize],), InputModuleType::HubBoard ), - touchpad_present: matches!( - InputModuleType::from(item.board_id[InputDeckMux::Touchpad as usize],), - InputModuleType::Touchpad - ), + touchpad_present: tp_present, + touchpad_id: item.board_id[InputDeckMux::Touchpad as usize], top_row: TopRowPositions { pos0: InputModuleType::from(item.board_id[InputDeckMux::TopRow0 as usize]), pos1: InputModuleType::from(item.board_id[InputDeckMux::TopRow1 as usize]), diff --git a/framework_lib/src/chromium_ec/mod.rs b/framework_lib/src/chromium_ec/mod.rs index 7921830..5709729 100644 --- a/framework_lib/src/chromium_ec/mod.rs +++ b/framework_lib/src/chromium_ec/mod.rs @@ -638,17 +638,52 @@ impl CrosEc { pub fn print_fw12_inputdeck_status(&self) -> EcResult<()> { let intrusion = self.get_intrusion_status()?; - let pwrbtn = self.read_board_id(Framework12Adc::PowerButtonBoardId as u8)?; - let audio = self.read_board_id(Framework12Adc::AudioBoardId as u8)?; - let tp = self.read_board_id(Framework12Adc::TouchpadBoardId as u8)?; + let pwrbtn = self.read_board_id_npc_db(Framework12Adc::PowerButtonBoardId as u8)?; + let audio = self.read_board_id_npc_db(Framework12Adc::AudioBoardId as u8)?; + let tp = self.read_board_id_npc_db(Framework12Adc::TouchpadBoardId as u8)?; let is_present = |p| if p { "Present" } else { "Missing" }; println!("Input Deck"); println!(" Chassis Closed: {}", !intrusion.currently_open); - println!(" Power Button Board: {}", is_present(pwrbtn.is_some())); - println!(" Audio Daughterboard: {}", is_present(audio.is_some())); - println!(" Touchpad: {}", is_present(tp.is_some())); + println!( + " Power Button Board: {}", + if let Some(pwrbtn) = pwrbtn { + format!("{} ({})", is_present(true), pwrbtn) + } else { + is_present(false).to_string() + } + ); + if let Ok(adc) = self.adc_read(Framework12Adc::PowerButtonBoardId as u8) { + println!(" ADC Value {:04}mV", adc); + } + println!( + " Audio Daughterboard: {}", + if let Some(audio) = audio { + format!("{} ({})", is_present(true), audio) + } else { + is_present(false).to_string() + } + ); + if let Ok(adc) = self.adc_read(Framework12Adc::AudioBoardId as u8) { + println!(" ADC Value {:04}mV", adc); + } + println!( + " Touchpad: {}", + if let Some(tp) = tp { + format!("{} ({})", is_present(true), tp) + } else { + is_present(false).to_string() + } + ); + if let Ok(adc) = self.adc_read(Framework12Adc::TouchpadBoardId as u8) { + println!(" ADC Value {:04}mV", adc); + } + + if let Ok(status) = self.get_input_deck_status() { + println!(" Deck State: {:?}", status.state); + println!(" Touchpad present: {}", status.touchpad_present); + } Ok(()) } @@ -674,6 +709,7 @@ impl CrosEc { println!("Input Deck"); println!(" Chassis Closed: {}", !intrusion.currently_open); + println!( " Audio Daughterboard: {}", if let Some(audio) = audio { @@ -682,10 +718,9 @@ impl CrosEc { is_present(false).to_string() } ); - println!( - " ADC Value (mV) {:?}", - self.adc_read(Framework13Adc::AudioBoardId as u8) - ); + if let Ok(adc) = self.adc_read(Framework13Adc::AudioBoardId as u8) { + println!(" ADC Value {:04}mV", adc); + } println!( " Touchpad: {}", if let Some(tp) = tp { @@ -694,10 +729,14 @@ impl CrosEc { is_present(false).to_string() } ); - println!( - " ADC Value (mV) {:?}", - self.adc_read(Framework13Adc::TouchpadBoardId as u8) - ); + if let Ok(adc) = self.adc_read(Framework13Adc::TouchpadBoardId as u8) { + println!(" ADC Value {:04}mV", adc); + } + + if let Ok(status) = self.get_input_deck_status() { + println!(" Deck State: {:?}", status.state); + println!(" Touchpad present: {}", status.touchpad_present); + } Ok(()) } diff --git a/framework_lib/src/commandline/clap_std.rs b/framework_lib/src/commandline/clap_std.rs index df1bb77..f435f8c 100644 --- a/framework_lib/src/commandline/clap_std.rs +++ b/framework_lib/src/commandline/clap_std.rs @@ -163,11 +163,11 @@ struct ClapCli { #[arg(long)] intrusion: bool, - /// Show status of the input modules (Framework 16 only) + /// Show status of the input modules #[arg(long)] inputdeck: bool, - /// Set input deck power mode [possible values: auto, off, on] (Framework 16 only) + /// Set input deck power mode [possible values: auto, off, on] (Laptop 12, 13, 16) #[arg(long)] inputdeck_mode: Option, diff --git a/framework_lib/src/commandline/mod.rs b/framework_lib/src/commandline/mod.rs index fa47287..ea2b99b 100644 --- a/framework_lib/src/commandline/mod.rs +++ b/framework_lib/src/commandline/mod.rs @@ -1360,7 +1360,15 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 { if ec.get_gpio("sleep_l").is_ok() { ec.print_fw16_inputdeck_status() } else { - println!(" Unable to tell"); + if let Ok(status) = ec.get_input_deck_status() { + println!(" Deck State: {:?}", status.state); + println!( + " Touchpad present: {} ({})", + status.touchpad_present, status.touchpad_id + ); + } else { + println!(" Unable to tell"); + } Ok(()) } } @@ -1855,7 +1863,7 @@ Options: --s0ix-counter Show S0ix counter --intrusion Show status of intrusion switch --inputdeck Show status of the input deck - --inputdeck-mode Set input deck power mode [possible values: auto, off, on] (Framework 16 only) + --inputdeck-mode Set input deck power mode [possible values: auto, off, on] (Framework 12, 13, 16) --expansion-bay Show status of the expansion bay (Framework 16 only) --nvidia Show NVIDIA GPU information (Framework 16 only) --charge-limit [] Get or set battery charge limit (Percentage number as arg, e.g. '100') diff --git a/framework_tool/completions/fish/framework_tool.fish b/framework_tool/completions/fish/framework_tool.fish index 9bb27b5..7ae87da 100644 --- a/framework_tool/completions/fish/framework_tool.fish +++ b/framework_tool/completions/fish/framework_tool.fish @@ -26,7 +26,7 @@ complete -c framework_tool -l flash-full-ec -d 'Flash full EC flash with new fir complete -c framework_tool -l flash-ec -d 'Flash EC (RO+RW) with new firmware from file - may render your hardware unbootable!' -r -F complete -c framework_tool -l flash-ro-ec -d 'Flash EC with new RO firmware from file - may render your hardware unbootable!' -r -F complete -c framework_tool -l flash-rw-ec -d 'Flash EC with new RW firmware from file' -r -F -complete -c framework_tool -l inputdeck-mode -d 'Set input deck power mode [possible values: auto, off, on] (Framework 16 only)' -r -f -a "auto\t'' +complete -c framework_tool -l inputdeck-mode -d 'Set input deck power mode [possible values: auto, off, on] (Laptop 12, 13, 16)' -r -f -a "auto\t'' off\t'' on\t''" complete -c framework_tool -l charge-limit -d 'Get or set max charge limit' -r @@ -87,7 +87,7 @@ complete -c framework_tool -l dp-hdmi-info -d 'Show details about connected DP o complete -c framework_tool -l audio-card-info -d 'Show details about connected Audio Expansion Cards (Needs root privileges)' complete -c framework_tool -l privacy -d 'Show privacy switch statuses (camera and microphone)' complete -c framework_tool -l intrusion -d 'Show status of intrusion switch' -complete -c framework_tool -l inputdeck -d 'Show status of the input modules (Framework 16 only)' +complete -c framework_tool -l inputdeck -d 'Show status of the input modules' complete -c framework_tool -l expansion-bay -d 'Show status of the expansion bay (Framework 16 only)' complete -c framework_tool -l stylus-battery -d 'Check stylus battery level (USI 2.0 stylus only)' complete -c framework_tool -l uptimeinfo diff --git a/framework_tool/completions/zsh/_framework_tool b/framework_tool/completions/zsh/_framework_tool index 6a67a10..aeeedb7 100644 --- a/framework_tool/completions/zsh/_framework_tool +++ b/framework_tool/completions/zsh/_framework_tool @@ -36,7 +36,7 @@ _framework_tool() { '--flash-ec=[Flash EC (RO+RW) with new firmware from file - may render your hardware unbootable!]:FLASH_EC:_files' \ '--flash-ro-ec=[Flash EC with new RO firmware from file - may render your hardware unbootable!]:FLASH_RO_EC:_files' \ '--flash-rw-ec=[Flash EC with new RW firmware from file]:FLASH_RW_EC:_files' \ -'--inputdeck-mode=[Set input deck power mode \[possible values\: auto, off, on\] (Framework 16 only)]:INPUTDECK_MODE:(auto off on)' \ +'--inputdeck-mode=[Set input deck power mode \[possible values\: auto, off, on\] (Laptop 12, 13, 16)]:INPUTDECK_MODE:(auto off on)' \ '--charge-limit=[Get or set max charge limit]::CHARGE_LIMIT:_default' \ '*--charge-current-limit=[Set max charge current limit]:CHARGE_CURRENT_LIMIT:_default' \ '*--charge-rate-limit=[Set max charge current limit]:CHARGE_RATE_LIMIT:_default' \ @@ -78,7 +78,7 @@ _framework_tool() { '--audio-card-info[Show details about connected Audio Expansion Cards (Needs root privileges)]' \ '--privacy[Show privacy switch statuses (camera and microphone)]' \ '--intrusion[Show status of intrusion switch]' \ -'--inputdeck[Show status of the input modules (Framework 16 only)]' \ +'--inputdeck[Show status of the input modules]' \ '--expansion-bay[Show status of the expansion bay (Framework 16 only)]' \ '--stylus-battery[Check stylus battery level (USI 2.0 stylus only)]' \ '--uptimeinfo[]' \ diff --git a/support-matrices.md b/support-matrices.md index faf7bf5..32f9d37 100644 --- a/support-matrices.md +++ b/support-matrices.md @@ -42,7 +42,7 @@ | `--privacy` | EC Communication | All Laptops | | `--intrusion` | EC Communication | All Laptops | | `--inputdeck` | EC Communication | All Laptops | -| `--inputdeck-mode` | EC Communication | Framework 16 | +| `--inputdeck-mode` | EC Communication | Framework 13, 16 | | `--console` | EC Communication | All | | `--get-gpio` | EC Communication | All | | `--kblight` | EC Communication | Framework 13 |