summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2015-08-06 11:21:34 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-08-01 16:37:33 +0000
commit8abd6173428c8e9d4527408b3888cb72a0358163 (patch)
tree237a639e52e86a91742f3d279be331c828d34977
parent4915e6da6c25a5d116493dea6e81042befc0c596 (diff)
downloadchrome-ec-8abd6173428c8e9d4527408b3888cb72a0358163.tar.gz
UPSTREAM: motion_sense: Reduce condition for lid angle calc.
The motion sense task was checking to see that every single motion sensor was ready (active, initialized, and reading), before performing the lid angle calculations. This amount of checking is unnecessary. This commit reduces the condition to only check if the sensors required for lid angle calculation are ready. BUG=chrome-os-partner:3613, b:27849483 BRANCH=cyan TEST=Build and flash on samus. Verify that the lid still works. TEST=make -j buildall tests Change-Id: Ibaa5cc8358cdcc6023a50aed247fce2e599fef58 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/291301 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 3a659c1fedb3536a6f04b80b65ff18df6ddb653f) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359326
-rw-r--r--common/motion_sense.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 465674fb56..cad99aa633 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -411,8 +411,12 @@ void motion_sense_task(void)
int i, ret, wait_us, fifo_flush_needed = 0;
timestamp_t ts_begin_task, ts_end_task;
uint32_t event = 0;
- int rd_cnt;
+ uint16_t ready_status;
struct motion_sensor_t *sensor;
+#ifdef CONFIG_LID_ANGLE
+ const uint16_t lid_angle_sensors = ((1 << CONFIG_LID_ANGLE_SENSOR_BASE)|
+ (1 << CONFIG_LID_ANGLE_SENSOR_LID));
+#endif
#ifdef CONFIG_ACCEL_FIFO
timestamp_t ts_last_int;
#endif
@@ -431,7 +435,7 @@ void motion_sense_task(void)
#endif
do {
ts_begin_task = get_time();
- rd_cnt = 0;
+ ready_status = 0;
for (i = 0; i < motion_sensor_count; ++i) {
sensor = &motion_sensors[i];
@@ -450,7 +454,7 @@ void motion_sense_task(void)
&fifo_flush_needed);
if (ret != EC_SUCCESS)
continue;
- rd_cnt++;
+ ready_status |= (1 << i);
mutex_lock(&g_sensor_mutex);
memcpy(sensor->xyz, sensor->raw_xyz,
sizeof(sensor->xyz));
@@ -464,12 +468,11 @@ void motion_sense_task(void)
#endif
#ifdef CONFIG_LID_ANGLE
/*
- * TODO (crosbug.com/p/36132): Checking for ALL sensors on is
- * overkill. It should just check for ACCEL in BASE and ACCEL
- * in LID, since those are the only ones needed for the lid
- * calculation.
+ * Check to see that the sensors required for lid angle
+ * calculation are ready.
*/
- if (rd_cnt == motion_sensor_count)
+ ready_status &= lid_angle_sensors;
+ if (ready_status == lid_angle_sensors)
motion_lid_calc();
#endif
#ifdef CONFIG_CMD_ACCEL_INFO