summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2016-09-13 16:47:31 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-09-21 06:36:31 +0000
commit1ccfbfc17ae9d9a17c839c3409c7e3338a5343ca (patch)
tree1cc86fe8ab3dbd67f4eb3493e32b8f5244fbefd1
parenta3af2e647824aa53d7364becf6ed2d1db89b1c7a (diff)
downloadchrome-ec-1ccfbfc17ae9d9a17c839c3409c7e3338a5343ca.tar.gz
UPSTREAM: motion: Add minimum to oversample.
In case the AP is asking for a ODR frequency the sensor can not achieve (for instance over 76Hz for BMP280), be sure we do not set oversampling to 0. Otherwise, no sensor data will be sent to the AP. BUG=b:27849483,b:27849483,b:31609073 BRANCH=oak TEST=Check Androsensor reports presure information even when frequency is set at 100Hz. Change-Id: Idb849782daa96531cc33d21ea6780fd7f1f299d5 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/385081 Commit-Ready: Gwendal Grignou <gwendal@google.com> Tested-by: Gwendal Grignou <gwendal@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 51c5fd5c150dd1bad2660dbb38d432e7234910f0) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/387163 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r--common/motion_sense.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 89b33bc61c..d759084d9f 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -177,7 +177,7 @@ static inline int motion_sensor_time_to_read(const timestamp_t *ts,
if (rate_mhz == 0)
return 0;
/*
- * converting from kHz to us.
+ * converting from mHz to us.
* If within 95% of the time, check sensor.
*/
return time_after(ts->le.lo,
@@ -235,8 +235,12 @@ int motion_sense_set_data_rate(struct motion_sensor_t *sensor)
BASE_ODR(sensor->config[SENSOR_CONFIG_AP].odr));
mutex_lock(&g_sensor_mutex);
if (ap_odr_mhz)
- sensor->oversampling_ratio =
- sensor->drv->get_data_rate(sensor) / ap_odr_mhz;
+ /*
+ * In case the AP want to run the sensors faster than it can,
+ * be sure we don't see the ratio to 0.
+ */
+ sensor->oversampling_ratio = MIN(1,
+ sensor->drv->get_data_rate(sensor) / ap_odr_mhz);
else
sensor->oversampling_ratio = 0;
@@ -260,6 +264,10 @@ static int motion_sense_set_ec_rate_from_ap(
return 0;
#ifdef CONFIG_ACCEL_FORCE_MODE_MASK
if (CONFIG_ACCEL_FORCE_MODE_MASK & (1 << (sensor - motion_sensors)))
+ /*
+ * AP EC sampling rate does not matter: we will collect at the
+ * requested sensor frequency.
+ */
goto end_set_ec_rate_from_ap;
#endif
if (odr_mhz == 0)