diff options
author | Furquan Shaikh <furquan@google.com> | 2018-11-20 21:57:50 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-11-29 04:31:49 -0800 |
commit | 625a4d856d767c3226e6869f5d38ca3c70b2b95c (patch) | |
tree | f96db72812182d06a46872c4139fc9ab791f2992 /common/tablet_mode.c | |
parent | fd6412f0ec89fd5570279d6081ae425107b3c9ea (diff) | |
download | chrome-ec-625a4d856d767c3226e6869f5d38ca3c70b2b95c.tar.gz |
tablet_mode: Introduce hall sensor specific handling
This change performs the following renaming:
1. CONFIG_TABLET_SWITCH -> CONFIG_HALL_SENSOR
Indicates if a device has hall sensor
2. TABLET_MODE_GPIO_L -> HALL_SENSOR_GPIO_L
Provides the interrupt line from hall sensor to EC.
3. tablet_mode_isr -> hall_sensor_isr
Interrupt routine that gets control on hall sensor interrupt.
4. tablet_mode_init -> hall_sensor_init
Init routine for initializing hall sensor interrupt.
5. tablet_switch_disable -> hall_sensor_disable
Disable hall sensor interrupt and tablet mode sub-system.
This is done to separate hall sensor interrupt from tablet mode
handling. It is another step towards aligning tablet mode detection on
EC with Chrome. Hall sensor interrupt occurs when the lid is in
360-degree flipped mode. If tablet mode is not already triggered by
lid motion driver, then hall_sensor_isr will set tablet mode and take
necessary actions to disable input peripherals.
CQ-DEPEND=CL:1351518
BUG=b:120050761
BRANCH=octopus
TEST=make -j buildall
Change-Id: I5841f6875d538a624cb888bc048f252397ab457c
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1350469
Commit-Ready: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common/tablet_mode.c')
-rw-r--r-- | common/tablet_mode.c | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/common/tablet_mode.c b/common/tablet_mode.c index 5185895ce4..e9667dfbcc 100644 --- a/common/tablet_mode.c +++ b/common/tablet_mode.c @@ -39,52 +39,66 @@ void tablet_set_mode(int mode) } /* This ifdef can be removed once we clean up past projects which do own init */ -#ifdef CONFIG_TABLET_SWITCH -#ifndef TABLET_MODE_GPIO_L -#error TABLET_MODE_GPIO_L must be defined +#ifdef CONFIG_HALL_SENSOR +#ifndef HALL_SENSOR_GPIO_L +#error HALL_SENSOR_GPIO_L must be defined #endif -static void tablet_mode_debounce(void) +static void hall_sensor_interrupt_debounce(void) { - /* We won't reach here on boards without a dedicated tablet switch */ - tablet_set_mode(!gpio_get_level(TABLET_MODE_GPIO_L)); + int flipped_360_mode = !gpio_get_level(HALL_SENSOR_GPIO_L); + + /* + * 1. Peripherals are disabled only when lid reaches 360 position (It's + * probably already disabled by motion_sense task). We deliberately do + * not enable peripherals when the lid is leaving 360 position. Instead, + * we let motion sense task enable it once it is reaches laptop zone + * (180 or less). + * 2. Similarly, tablet mode is set here when lid reaches 360 + * position. It should already be set by motion lid driver. We + * deliberately do not clear tablet mode when lid is leaving 360 + * position(if motion lid driver is used). Instead, we let motion lid + * driver to clear it when lid goes into laptop zone. + */ + +#ifdef CONFIG_LID_ANGLE + if (flipped_360_mode) +#endif /* CONFIG_LID_ANGLE */ + tablet_set_mode(flipped_360_mode); #ifdef CONFIG_LID_ANGLE_UPDATE - /* Then, we disable peripherals only when the lid reaches 360 position. - * (It's probably already disabled by motion_sense_task.) - * We deliberately do not enable peripherals when the lid is leaving - * 360 position. Instead, we let motion_sense_task enable it once it - * reaches laptop zone (180 or less). */ - if (tablet_mode) + if (flipped_360_mode) lid_angle_peripheral_enable(0); #endif /* CONFIG_LID_ANGLE_UPDATE */ } -DECLARE_DEFERRED(tablet_mode_debounce); +DECLARE_DEFERRED(hall_sensor_interrupt_debounce); -#define TABLET_DEBOUNCE_US (30 * MSEC) /* Debounce time for tablet switch */ +/* Debounce time for hall sensor interrupt */ +#define HALL_SENSOR_DEBOUNCE_US (30 * MSEC) -void tablet_mode_isr(enum gpio_signal signal) +void hall_sensor_isr(enum gpio_signal signal) { - hook_call_deferred(&tablet_mode_debounce_data, TABLET_DEBOUNCE_US); + hook_call_deferred(&hall_sensor_interrupt_debounce_data, + HALL_SENSOR_DEBOUNCE_US); } -static void tablet_mode_init(void) +static void hall_sensor_init(void) { /* If this sub-system was disabled before initializing, honor that. */ if (disabled) return; - gpio_enable_interrupt(TABLET_MODE_GPIO_L); + gpio_enable_interrupt(HALL_SENSOR_GPIO_L); /* Ensure tablet mode is initialized according to the hardware state * so that the cached state reflects reality. */ - tablet_mode_debounce(); + hall_sensor_interrupt_debounce(); } -DECLARE_HOOK(HOOK_INIT, tablet_mode_init, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_INIT, hall_sensor_init, HOOK_PRIO_DEFAULT); -void tablet_disable_switch(void) +void hall_sensor_disable(void) { - gpio_disable_interrupt(TABLET_MODE_GPIO_L); + gpio_disable_interrupt(HALL_SENSOR_GPIO_L); /* Cancel any pending debounce calls */ - hook_call_deferred(&tablet_mode_debounce_data, -1); + hook_call_deferred(&hall_sensor_interrupt_debounce_data, -1); tablet_set_mode(0); disabled = 1; } |