Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions framework_lib/src/chromium_ec/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub enum EcCommands {
FlashNotified = 0x3E01,
/// Change charge limit
ChargeLimitControl = 0x3E03,
DisablePs2Emulation = 0x3E08,
/// Get/Set Fingerprint LED brightness
FpLedLevelControl = 0x3E0E,
/// Get information about the current chassis open/close status
Expand Down
11 changes: 11 additions & 0 deletions framework_lib/src/chromium_ec/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,17 @@ impl EcRequest<EcResponseChargeLimitControl> for EcRequestChargeLimitControl {
/// TODO: Use this
pub const EC_CHARGE_LIMIT_RESTORE: u8 = 0x7F;

#[repr(C, packed)]
pub struct EcRequestDisablePs2Emulation {
pub disable: u8,
}

impl EcRequest<()> for EcRequestDisablePs2Emulation {
fn command_id() -> EcCommands {
EcCommands::DisablePs2Emulation
}
}

#[repr(u8)]
#[derive(Debug, FromPrimitive)]
pub enum FpLedBrightnessLevel {
Expand Down
7 changes: 7 additions & 0 deletions framework_lib/src/chromium_ec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,13 @@ impl CrosEc {
Ok((kblight.duty / (PWM_MAX_DUTY / 100)) as u8)
}

pub fn ps2_emulation_enable(&self, enable: bool) -> EcResult<()> {
EcRequestDisablePs2Emulation {
disable: !enable as u8,
}
.send_command(self)
}

pub fn fan_set_rpm(&self, fan: Option<u32>, rpm: u32) -> EcResult<()> {
if let Some(fan_idx) = fan {
EcRequestPwmSetFanTargetRpmV1 { rpm, fan_idx }.send_command(self)
Expand Down
6 changes: 6 additions & 0 deletions framework_lib/src/commandline/clap_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ struct ClapCli {
#[arg(long, value_parser=maybe_hex::<u64>)]
rgbkbd: Vec<u64>,

/// Control PS2 touchpad emulation (DEBUG COMMAND, if touchpad not working, reboot system)
#[clap(value_enum, hide(true))]
#[arg(long)]
ps2_enable: Option<bool>,

/// Set tablet mode override
#[clap(value_enum)]
#[arg(long)]
Expand Down Expand Up @@ -393,6 +398,7 @@ pub fn parse(args: &[String]) -> Cli {
fp_brightness: args.fp_brightness,
kblight: args.kblight,
rgbkbd: args.rgbkbd,
ps2_enable: args.ps2_enable,
tablet_mode: args.tablet_mode,
touchscreen_enable: args.touchscreen_enable,
stylus_battery: args.stylus_battery,
Expand Down
3 changes: 3 additions & 0 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ pub struct Cli {
pub fp_brightness: Option<Option<u8>>,
pub kblight: Option<Option<u8>>,
pub rgbkbd: Vec<u64>,
pub ps2_enable: Option<bool>,
pub tablet_mode: Option<TabletModeArg>,
pub touchscreen_enable: Option<bool>,
pub stylus_battery: bool,
Expand Down Expand Up @@ -819,6 +820,8 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
});
ec.rgbkbd_set_color(start_key, colors.collect()).unwrap();
}
} else if let Some(enable) = args.ps2_enable {
print_err(ec.ps2_emulation_enable(enable));
} else if let Some(None) = args.kblight {
print!("Keyboard backlight: ");
if let Some(percentage) = print_err(ec.get_keyboard_backlight()) {
Expand Down
21 changes: 21 additions & 0 deletions framework_lib/src/commandline/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub fn parse(args: &[String]) -> Cli {
fp_brightness: None,
kblight: None,
rgbkbd: vec![],
ps2_enable: None,
tablet_mode: None,
touchscreen_enable: None,
stylus_battery: false,
Expand Down Expand Up @@ -361,6 +362,26 @@ pub fn parse(args: &[String]) -> Cli {
println!("--rgbkbd requires at least 2 arguments, the start key and an RGB value");
vec![]
}
} else if arg == "--ps2-enable" {
cli.ps2_enable = if args.len() > i + 1 {
let enable_arg = &args[i + 1];
if enable_arg == "true" {
Some(true)
} else if enable_arg == "false" {
Some(false)
} else {
println!(
"Need to provide a value for --ps2-enable: '{}'. {}",
args[i + 1],
"Must be `true` or `false`",
);
None
}
} else {
println!("Need to provide a value for --tablet-mode. One of: `auto`, `tablet` or `laptop`");
None
};
found_an_option = true;
} else if arg == "--tablet-mode" {
cli.tablet_mode = if args.len() > i + 1 {
let tablet_mode_arg = &args[i + 1];
Expand Down
Loading