summaryrefslogtreecommitdiff
path: root/include/motion_sense.h
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-08-25 18:52:19 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-08-29 01:34:14 -0700
commit4e7e1bb796190e658ea2de8d4e391efa59b0d643 (patch)
treec6927e9226f1853ce2602cc71d6399f7ad210860 /include/motion_sense.h
parent398bd9a0178c0120a2dbf3f58419d6a5360dfb3d (diff)
downloadchrome-ec-4e7e1bb796190e658ea2de8d4e391efa59b0d643.tar.gz
motion_sense: Add more complex EC/AP sensor rate support.
Add config settings for ODR and EC rate per requestor and per power state (1 for the AP, 3 for the EC). This way we can finely set ec rate and ODR depending on usage. On chromeos, AP is not setting frequency, so EC sets for different power state. On some platform, sensors can now be suspended in S3/S5. Allow EC oversampling when AP is only looking for a few samples. It is useful for double tap detection where high accelerator ODR is required. BRANCH=ryu TEST=Tested on Ryu BUG=chromium:513458 Change-Id: Ic3888a749699f07b10c5da3bc07204afd4de70da Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295637
Diffstat (limited to 'include/motion_sense.h')
-rw-r--r--include/motion_sense.h58
1 files changed, 46 insertions, 12 deletions
diff --git a/include/motion_sense.h b/include/motion_sense.h
index cbe311fdf6..6541893d67 100644
--- a/include/motion_sense.h
+++ b/include/motion_sense.h
@@ -22,6 +22,14 @@ enum sensor_state {
SENSOR_INIT_ERROR = 2
};
+enum sensor_config {
+ SENSOR_CONFIG_AP, /* Configuration requested/for the AP */
+ SENSOR_CONFIG_EC_S0, /* Configuration from the EC while device in S0 */
+ SENSOR_CONFIG_EC_S3, /* from the EC when device sleep */
+ SENSOR_CONFIG_EC_S5, /* from the EC when device powered off */
+ SENSOR_CONFIG_MAX,
+};
+
#define SENSOR_ACTIVE_S5 CHIPSET_STATE_SOFT_OFF
#define SENSOR_ACTIVE_S3 CHIPSET_STATE_SUSPEND
#define SENSOR_ACTIVE_S0 CHIPSET_STATE_ON
@@ -47,17 +55,21 @@ enum sensor_state {
#define MIN_MOTION_SENSE_WAIT_TIME (3 * MSEC)
#define MAX_MOTION_SENSE_WAIT_TIME (60000 * MSEC)
+#define ROUND_UP_FLAG (1 << 31)
+
struct motion_data_t {
- /* data rate the sensor will measure, in mHz */
- int odr;
- /* range of measurement in SI */
- int range;
+ /*
+ * data rate the sensor will measure, in mHz: 0 suspended.
+ * MSB is used to know if we are rounding up.
+ * */
+ unsigned odr;
/* delay between collection by EC, in ms.
* For non FIFO sensor, should be nead 1e6/odr to
* collect events.
* For sensor with FIFO, can be much longer.
+ * 0: no collection.
*/
- unsigned ec_rate;
+ unsigned short ec_rate;
};
struct motion_sensor_t {
@@ -74,11 +86,29 @@ struct motion_sensor_t {
uint8_t addr;
const matrix_3x3_t *rot_standard_ref;
- /* Default configuration parameters, RO only */
- struct motion_data_t default_config;
+ /*
+ * default_range: set by default by the EC.
+ * The host can change it, but rarely does.
+ */
+ int default_range;
- /* Run-Time configuration parameters */
- struct motion_data_t runtime_config;
+ /*
+ * There are 4 configuration parameters to deal with different
+ * configuration
+ *
+ * Power | S0 | S3 | S5
+ * --------+-------------------+-------------------+-----------------
+ * From AP | <------- SENSOR_CONFIG_AP ----------> |
+ * | Use for normal | While sleeping | Always disabled
+ * | operation: game, | iFor Activity |
+ * | screen rotatopm | Recognition |
+ * --------+-------------------+-------------------+------------------
+ * From EC |SENSOR_CONFIG_EC_S0|SENSOR_CONFIG_EC_S3|SENSOR_CONFIG_EC_S5
+ * | Background | Gesture Recognition (Double tap, ...)
+ * | Activity: compass,|
+ * | ambient light)|
+ */
+ struct motion_data_t config[SENSOR_CONFIG_MAX];
/* state parameters */
enum sensor_state state;
@@ -89,6 +119,11 @@ struct motion_sensor_t {
uint32_t flush_pending;
/*
+ * Allow EC to request an higher frequency for the sensors than the AP.
+ */
+ fp_t oversampling;
+
+ /*
* How many vector events are lost in the FIFO since last time
* FIFO info has been transmitted.
*/
@@ -109,10 +144,9 @@ extern struct motion_sensor_t motion_sensors[];
extern const unsigned motion_sensor_count;
/* For testing purposes: export the sampling interval. */
+extern enum chipset_state_mask sensor_active;
extern unsigned accel_interval;
-int motion_sense_set_accel_interval(
- struct motion_sensor_t *driving_sensor,
- unsigned data);
+int motion_sense_set_accel_interval(void);
/*
* Priority of the motion sense resume/suspend hooks, to be sure associated