Skip to content

Commit ab63d1c

Browse files
committed
--inputdeck-mode: Add reset command
To allow resetting the input deck in a single command. Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 0f190f6 commit ab63d1c

7 files changed

Lines changed: 26 additions & 9 deletions

File tree

EXAMPLES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Options:
8282
--inputdeck
8383
Show status of the input modules
8484
--inputdeck-mode <INPUTDECK_MODE>
85-
Set input deck power mode [possible values: auto, off, on] (Laptop 12, 13, 16) [possible values: auto, off, on]
85+
Set input deck power mode [possible values: auto, off, on, reset] (Laptop 12, 13, 16)
8686
--expansion-bay
8787
Show status of the expansion bay (Laptop 16 only)
8888
--charge-limit [<CHARGE_LIMIT>]
@@ -414,6 +414,9 @@ framework_tool --inputdeck-mode on
414414
415415
# Auto detect (Default behavior)
416416
framework_tool --inputdeck-mode auto
417+
418+
# Reset (Turn off and then auto)
419+
framework_tool --inputdeck-mode resets
417420
```
418421

419422
## Checking board ID

framework_lib/src/commandline/clap_std.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct ClapCli {
171171
#[arg(long)]
172172
inputdeck: bool,
173173

174-
/// Set input deck power mode [possible values: auto, off, on] (Laptop 12, 13, 16)
174+
/// Set input deck power mode [possible values: auto, off, on, reset] (Laptop 12, 13, 16)
175175
#[arg(long)]
176176
inputdeck_mode: Option<InputDeckModeArg>,
177177

framework_lib/src/commandline/mod.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,16 @@ pub enum InputDeckModeArg {
131131
Auto,
132132
Off,
133133
On,
134+
Reset,
134135
}
135136
impl From<InputDeckModeArg> for DeckStateMode {
136137
fn from(w: InputDeckModeArg) -> DeckStateMode {
137138
match w {
138139
InputDeckModeArg::Auto => DeckStateMode::Required,
139140
InputDeckModeArg::Off => DeckStateMode::ForceOff,
140141
InputDeckModeArg::On => DeckStateMode::ForceOn,
142+
// Actually should turn off first
143+
InputDeckModeArg::Reset => DeckStateMode::Required,
141144
}
142145
}
143146
}
@@ -1380,8 +1383,16 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
13801383
};
13811384
print_err(res);
13821385
} else if let Some(mode) = &args.inputdeck_mode {
1383-
println!("Set mode to: {:?}", mode);
1384-
ec.set_input_deck_mode((*mode).into()).unwrap();
1386+
if *mode == InputDeckModeArg::Reset {
1387+
println!("Resetting input deck (off => auto)");
1388+
ec.set_input_deck_mode(DeckStateMode::ForceOff).unwrap();
1389+
// Make sure it has time to fully turn off
1390+
os_specific::sleep(100);
1391+
ec.set_input_deck_mode(DeckStateMode::Required).unwrap();
1392+
} else {
1393+
println!("Set mode to: {:?}", mode);
1394+
ec.set_input_deck_mode((*mode).into()).unwrap();
1395+
}
13851396
} else if args.expansion_bay {
13861397
if let Err(err) = ec.check_bay_status() {
13871398
error!("{:?}", err);

framework_lib/src/commandline/uefi.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,15 @@ pub fn parse(args: &[String]) -> Cli {
256256
Some(InputDeckModeArg::Off)
257257
} else if inputdeck_mode == "on" {
258258
Some(InputDeckModeArg::On)
259+
} else if inputdeck_mode == "reset" {
260+
Some(InputDeckModeArg::Reset)
259261
} else {
260262
println!("Invalid value for --inputdeck-mode: {}", inputdeck_mode);
261263
None
262264
}
263265
} else {
264266
println!(
265-
"Need to provide a value for --inputdeck-mode. Either `auto`, `off`, or `on`"
267+
"Need to provide a value for --inputdeck-mode. Either `auto`, `off`, `on`, or `reset`"
266268
);
267269
None
268270
};

framework_tool/completions/bash/framework_tool

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ _framework_tool() {
114114
return 0
115115
;;
116116
--inputdeck-mode)
117-
COMPREPLY=($(compgen -W "auto off on" -- "${cur}"))
117+
COMPREPLY=($(compgen -W "auto off on reset" -- "${cur}"))
118118
return 0
119119
;;
120120
--charge-limit)

framework_tool/completions/fish/framework_tool.fish

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ complete -c framework_tool -l flash-full-ec -d 'Flash full EC flash with new fir
2626
complete -c framework_tool -l flash-ec -d 'Flash EC (RO+RW) with new firmware from file - may render your hardware unbootable!' -r -F
2727
complete -c framework_tool -l flash-ro-ec -d 'Flash EC with new RO firmware from file - may render your hardware unbootable!' -r -F
2828
complete -c framework_tool -l flash-rw-ec -d 'Flash EC with new RW firmware from file' -r -F
29-
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''
29+
complete -c framework_tool -l inputdeck-mode -d 'Set input deck power mode [possible values: auto, off, on, reset] (Laptop 12, 13, 16)' -r -f -a "auto\t''
3030
off\t''
31-
on\t''"
31+
on\t''
32+
reset\t''"
3233
complete -c framework_tool -l charge-limit -d 'Get or set max charge limit' -r
3334
complete -c framework_tool -l charge-current-limit -d 'Set max charge current limit' -r
3435
complete -c framework_tool -l charge-rate-limit -d 'Set max charge current limit' -r

framework_tool/completions/zsh/_framework_tool

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _framework_tool() {
3636
'--flash-ec=[Flash EC (RO+RW) with new firmware from file - may render your hardware unbootable!]:FLASH_EC:_files' \
3737
'--flash-ro-ec=[Flash EC with new RO firmware from file - may render your hardware unbootable!]:FLASH_RO_EC:_files' \
3838
'--flash-rw-ec=[Flash EC with new RW firmware from file]:FLASH_RW_EC:_files' \
39-
'--inputdeck-mode=[Set input deck power mode \[possible values\: auto, off, on\] (Laptop 12, 13, 16)]:INPUTDECK_MODE:(auto off on)' \
39+
'--inputdeck-mode=[Set input deck power mode \[possible values\: auto, off, on, reset\] (Laptop 12, 13, 16)]:INPUTDECK_MODE:(auto off on reset)' \
4040
'--charge-limit=[Get or set max charge limit]::CHARGE_LIMIT:_default' \
4141
'*--charge-current-limit=[Set max charge current limit]:CHARGE_CURRENT_LIMIT:_default' \
4242
'*--charge-rate-limit=[Set max charge current limit]:CHARGE_RATE_LIMIT:_default' \

0 commit comments

Comments
 (0)