diff options
Diffstat (limited to 'common/tablet_mode.c')
-rw-r--r-- | common/tablet_mode.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/common/tablet_mode.c b/common/tablet_mode.c index 68d90ae772..3a5616ec3f 100644 --- a/common/tablet_mode.c +++ b/common/tablet_mode.c @@ -17,10 +17,10 @@ #define CPRINTF(format, args...) cprintf(CC_MOTION_LID, format, ## args) /* - * Other code modules assume that notebook mode (i.e. tablet_mode = false) at + * Other code modules assume that notebook mode (i.e. tablet_mode = 0) at * startup */ -static bool tablet_mode; +static uint32_t tablet_mode; /* * Console command can force the value of tablet_mode. If tablet_mode_force is @@ -39,7 +39,7 @@ static bool disabled; int tablet_get_mode(void) { - return tablet_mode; + return !!tablet_mode; } static inline void print_tablet_mode(void) @@ -61,13 +61,21 @@ static void notify_tablet_mode_change(void) } -void tablet_set_mode(int mode) +void tablet_set_mode(int mode, uint32_t trigger) { + uint32_t old_mode = tablet_mode; + /* If tablet_mode is forced via a console command, ignore set. */ if (tablet_mode_forced) return; - if (tablet_mode == !!mode) + if (mode) + tablet_mode |= trigger; + else + tablet_mode &= ~trigger; + + /* Boolean comparison */ + if (!tablet_mode == !old_mode) return; if (disabled) { @@ -81,14 +89,12 @@ void tablet_set_mode(int mode) return; } - tablet_mode = !!mode; - notify_tablet_mode_change(); } void tablet_disable(void) { - tablet_mode = false; + tablet_mode = 0; disabled = true; } @@ -131,7 +137,7 @@ static void gmr_tablet_switch_interrupt_debounce(void) */ if (!IS_ENABLED(CONFIG_LID_ANGLE) || gmr_sensor_at_360) - tablet_set_mode(gmr_sensor_at_360); + tablet_set_mode(gmr_sensor_at_360, TABLET_TRIGGER_LID); if (IS_ENABLED(CONFIG_LID_ANGLE_UPDATE) && gmr_sensor_at_360) lid_angle_peripheral_enable(0); @@ -182,10 +188,10 @@ static int command_settabletmode(int argc, char **argv) return EC_ERROR_PARAM_COUNT; if (argv[1][0] == 'o' && argv[1][1] == 'n') { - tablet_mode = true; + tablet_mode = TABLET_TRIGGER_LID; tablet_mode_forced = true; } else if (argv[1][0] == 'o' && argv[1][1] == 'f') { - tablet_mode = false; + tablet_mode = 0; tablet_mode_forced = true; } else if (argv[1][0] == 'r') { tablet_mode_forced = false; |