Reset EC config on Fn+Esc during power on
This commit is contained in:
parent
46ca5e0a12
commit
9afec7af27
@ -3,8 +3,16 @@
|
||||
#include <board/config.h>
|
||||
|
||||
#include <board/battery.h>
|
||||
#include <board/kbscan.h>
|
||||
#include <common/debug.h>
|
||||
|
||||
/**
|
||||
* Test if the EC should reset its configuration.
|
||||
*/
|
||||
bool config_should_reset(void) {
|
||||
return kbscan_fn_held && kbscan_esc_held;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the EC configuration data.
|
||||
*/
|
||||
|
@ -3,6 +3,9 @@
|
||||
#ifndef _BOARD_CONFIG_H
|
||||
#define _BOARD_CONFIG_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool config_should_reset(void);
|
||||
void config_reset(void);
|
||||
|
||||
#endif // _BOARD_CONFIG_H
|
||||
|
@ -7,6 +7,10 @@
|
||||
|
||||
#include <ec/kbscan.h>
|
||||
|
||||
// EC config reset key combo: Fn+Esc
|
||||
extern bool kbscan_fn_held;
|
||||
extern bool kbscan_esc_held;
|
||||
|
||||
extern bool kbscan_enabled;
|
||||
|
||||
// ms between repeating key
|
||||
|
@ -18,6 +18,9 @@
|
||||
#define KM_NKEY 0
|
||||
#endif // KM_NKEY
|
||||
|
||||
bool kbscan_fn_held = false;
|
||||
bool kbscan_esc_held = false;
|
||||
|
||||
bool kbscan_enabled = false;
|
||||
uint16_t kbscan_repeat_period = 91;
|
||||
uint16_t kbscan_repeat_delay = 500;
|
||||
@ -182,12 +185,16 @@ bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) {
|
||||
case (KT_NORMAL):
|
||||
if (kbscan_enabled) {
|
||||
kbc_scancode(&KBC, key, pressed);
|
||||
if ((key & 0xFF) == K_ESC)
|
||||
kbscan_esc_held = pressed;
|
||||
}
|
||||
break;
|
||||
case (KT_FN):
|
||||
if (layer != NULL) {
|
||||
if (pressed) *layer = 1;
|
||||
else *layer = 0;
|
||||
|
||||
kbscan_fn_held = pressed;
|
||||
} else {
|
||||
// In the case no layer can be set, reset bit
|
||||
return false;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <board/acpi.h>
|
||||
#include <board/battery.h>
|
||||
#include <board/board.h>
|
||||
#include <board/config.h>
|
||||
#include <board/gpio.h>
|
||||
#include <board/kbled.h>
|
||||
#include <board/lid.h>
|
||||
@ -405,6 +406,8 @@ void power_event(void) {
|
||||
// Enable S5 power if necessary, before sending PWR_BTN
|
||||
update_power_state();
|
||||
if (power_state == POWER_STATE_DS5) {
|
||||
if (config_should_reset())
|
||||
config_reset();
|
||||
power_on_s5();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user