summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2016-12-28 10:59:19 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-01-04 18:07:12 -0800
commit1523e8b3ef04894d17dec57babed3da02f52fc6c (patch)
tree5b7c8fe616e84a01a380c2556c5812ea33b11f0b /common
parent4234992812588e2901192ca9ec8d94b074c6f5f5 (diff)
downloadchrome-ec-1523e8b3ef04894d17dec57babed3da02f52fc6c.tar.gz
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>
Diffstat (limited to 'common')
-rw-r--r--common/motion_lid.c1
-rw-r--r--common/motion_sense.c10
-rw-r--r--common/tablet_mode.c7
3 files changed, 16 insertions, 2 deletions
diff --git a/common/motion_lid.c b/common/motion_lid.c
index f2c6863b80..a5183e008d 100644
--- a/common/motion_lid.c
+++ b/common/motion_lid.c
@@ -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--;
diff --git a/common/motion_sense.c b/common/motion_sense.c
index d64cb1055f..6715947ffb 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -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 {
diff --git a/common/tablet_mode.c b/common/tablet_mode.c
index c2937250da..4a9a0b2364 100644
--- a/common/tablet_mode.c
+++ b/common/tablet_mode.c
@@ -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);
+ }
}