summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-08-25 22:58:41 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-08-29 01:34:15 -0700
commit32867104da45ae38e37163ba6d04f847bc15e6bc (patch)
treee33a7142343d43eeeabaed6a097304459cde4a83
parent4e7e1bb796190e658ea2de8d4e391efa59b0d643 (diff)
downloadchrome-ec-32867104da45ae38e37163ba6d04f847bc15e6bc.tar.gz
samus: Use new config, fix gesture
Use new config table. Move ODR setting in motion sense, fix variable names. BRANCH=samus BUG=chromium:513458 TEST=Test accelerator and double tap on Samus Change-Id: I341add11a18de8e4cc97c57da29f9114bd2014cf Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295638 Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r--board/samus/board.c80
-rw-r--r--common/gesture.c13
-rw-r--r--include/gesture.h7
-rw-r--r--include/motion_sense.h9
4 files changed, 73 insertions, 36 deletions
diff --git a/board/samus/board.c b/board/samus/board.c
index 35365754dc..e9d71de370 100644
--- a/board/samus/board.c
+++ b/board/samus/board.c
@@ -20,6 +20,7 @@
#include "driver/temp_sensor/tmp006.h"
#include "extpower.h"
#include "fan.h"
+#include "gesture.h"
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
@@ -307,11 +308,28 @@ struct motion_sensor_t motion_sensors[] = {
.drv_data = &g_saved_data[0],
.addr = LSM6DS0_ADDR1,
.rot_standard_ref = &base_standard_ref,
- .default_config = {
- .odr = 119000,
- .range = 2,
- .ec_rate = SUSPEND_SAMPLING_INTERVAL,
- }
+ .default_range = 2, /* g, enough for laptop. */
+ .config = {
+ /* AP: by default shutdown all sensors */
+ [SENSOR_CONFIG_AP] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 119000 | ROUND_UP_FLAG,
+ .ec_rate = 100,
+ },
+ /* Used for double tap */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = TAP_ODR | ROUND_UP_FLAG,
+ .ec_rate = CONFIG_GESTURE_SAMPLING_INTERVAL_MS
+ },
+ [SENSOR_CONFIG_EC_S5] = {
+ .odr = TAP_ODR | ROUND_UP_FLAG,
+ .ec_rate = CONFIG_GESTURE_SAMPLING_INTERVAL_MS
+ },
+ },
},
{.name = "Lid",
@@ -324,11 +342,28 @@ struct motion_sensor_t motion_sensors[] = {
.drv_data = &g_kxcj9_data,
.addr = KXCJ9_ADDR0,
.rot_standard_ref = &lid_standard_ref,
- .default_config = {
- .odr = 100000,
- .range = 2,
- .ec_rate = SUSPEND_SAMPLING_INTERVAL,
- }
+ .default_range = 2, /* g, enough for laptop. */
+ .config = {
+ /* AP: by default shutdown all sensors */
+ [SENSOR_CONFIG_AP] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 100000 | ROUND_UP_FLAG,
+ .ec_rate = 100,
+ },
+ /* unused */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ [SENSOR_CONFIG_EC_S5] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ },
},
{.name = "Base Gyro",
@@ -341,10 +376,27 @@ struct motion_sensor_t motion_sensors[] = {
.drv_data = &g_saved_data[1],
.addr = LSM6DS0_ADDR1,
.rot_standard_ref = NULL,
- .default_config = {
- .odr = 119000,
- .range = 2000,
- .ec_rate = SUSPEND_SAMPLING_INTERVAL,
+ .default_range = 2000, /* g, enough for laptop. */
+ .config = {
+ /* AP: by default shutdown all sensors */
+ [SENSOR_CONFIG_AP] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ /* EC use accel for angle detection */
+ [SENSOR_CONFIG_EC_S0] = {
+ .odr = 119000 | ROUND_UP_FLAG,
+ .ec_rate = 100,
+ },
+ /* unused */
+ [SENSOR_CONFIG_EC_S3] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
+ [SENSOR_CONFIG_EC_S5] = {
+ .odr = 0,
+ .ec_rate = 0,
+ },
}
},
diff --git a/common/gesture.c b/common/gesture.c
index 51a77ce0ab..b1858ba311 100644
--- a/common/gesture.c
+++ b/common/gesture.c
@@ -22,12 +22,6 @@
#define CPRINTS(format, args...) cprints(CC_GESTURE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_GESTURE, format, ## args)
-/* Output datarate for tap sensor (in milli-Hz) */
-/*
- * Note: lsm6ds0 accel needs twice the expected data rate in order to guarantee
- * that we have a new data sample every reading.
- */
-#define TAP_ODR (2 * (1000000 / CONFIG_GESTURE_SAMPLING_INTERVAL_MS))
/*
* Double tap detection parameters
@@ -287,13 +281,6 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, gesture_chipset_resume,
static void gesture_chipset_suspend(void)
{
/*
- * Set ODR to desired value
- * We assume EC rate set correctly: it works because the sensor used
- * is never offlined/suspened.
- */
- sensor->drv->set_data_rate(sensor, TAP_ODR, 1);
-
- /*
* Clear tap init and history initialized so that we have to
* record a whole new set of data, and enable tap detection
*/
diff --git a/include/gesture.h b/include/gesture.h
index 901f881b50..d98dc8cdf8 100644
--- a/include/gesture.h
+++ b/include/gesture.h
@@ -16,4 +16,11 @@ void gesture_calc(void);
/* gesture hooks are triggered after the motion sense hooks. */
#define GESTURE_HOOK_PRIO (MOTION_SENSE_HOOK_PRIO + 10)
+/* Output datarate for tap sensor (in milli-Hz) */
+/*
+ * Note: lsm6ds0 accel needs twice the expected data rate in order to guarantee
+ * that we have a new data sample every reading.
+ */
+#define TAP_ODR (2 * (1000000 / CONFIG_GESTURE_SAMPLING_INTERVAL_MS))
+
#endif /* __CROS_EC_GESTURE_H */
diff --git a/include/motion_sense.h b/include/motion_sense.h
index 6541893d67..d01c2b907e 100644
--- a/include/motion_sense.h
+++ b/include/motion_sense.h
@@ -42,15 +42,6 @@ enum sensor_config {
/* Next 8 events for sensor interrupt lines */
#define TASK_EVENT_MOTION_INTERRUPT_MASK (0xff << 2)
-/* Define sensor sampling interval in suspend. */
-#ifdef CONFIG_GESTURE_DETECTION
-#define SUSPEND_SAMPLING_INTERVAL (CONFIG_GESTURE_SAMPLING_INTERVAL_MS * MSEC)
-#elif defined(CONFIG_ACCEL_FIFO)
-#define SUSPEND_SAMPLING_INTERVAL (1000 * MSEC)
-#else
-#define SUSPEND_SAMPLING_INTERVAL (100 * MSEC)
-#endif
-
/* Minimum time in between running motion sense task loop. */
#define MIN_MOTION_SENSE_WAIT_TIME (3 * MSEC)
#define MAX_MOTION_SENSE_WAIT_TIME (60000 * MSEC)