motion: Disable tablet mode if one accel is broken

We need 2 accelerometer for tablet mode. If one of them is not working,
disable tablet mode. We will stay in clamshell mode, lid angle will be
always unreliable.

BUG=chrome-os-partner:61141
TEST=On kevin with a single sensor. Check we are in clamshell mode
when rebooting the EC.
BRANCH=kevin

Change-Id: I7bf6cdc9d85370fce20e5183622b4bc18f4f5f99
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/424184
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Gwendal Grignou
2016-12-28 10:59:19 -08:00
committed by chrome-bot
parent 4234992812
commit 1523e8b3ef
3 changed files with 16 additions and 2 deletions

View File

@@ -253,7 +253,6 @@ static int calculate_lid_angle(const vector_3_t base, const vector_3_t lid,
tablet_mode_debounce_cnt =
TABLET_MODE_DEBOUNCE_COUNT;
tablet_set_mode(new_tablet_mode);
hook_notify(HOOK_TABLET_MODE_CHANGE);
return reliable;
}
tablet_mode_debounce_cnt--;

View File

@@ -436,6 +436,16 @@ static void motion_sense_switch_sensor_rate(void)
if (ret != EC_SUCCESS) {
CPRINTS("%s: %d: init failed: %d",
sensor->name, i, ret);
#ifdef CONFIG_LID_ANGLE_TABLET_MODE
/*
* No tablet mode allowed if an accel
* is not working.
*/
if (i == CONFIG_LID_ANGLE_SENSOR_BASE ||
i == CONFIG_LID_ANGLE_SENSOR_LID) {
tablet_set_mode(0);
}
#endif
}
}
} else {

View File

@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
#include "hooks.h"
/* Return 1 if in tablet mode, 0 otherwise */
static int tablet_mode = 1;
@@ -13,6 +15,9 @@ int tablet_get_mode(void)
void tablet_set_mode(int mode)
{
tablet_mode = mode;
if (tablet_mode != mode) {
tablet_mode = mode;
hook_notify(HOOK_TABLET_MODE_CHANGE);
}
}