summaryrefslogtreecommitdiff
path: root/driver/accelgyro_bmi160.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2016-12-16 18:24:08 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-01-07 13:29:52 -0800
commitb3a9e1b64c25a4e35345903f5e20a841817962f6 (patch)
tree9828541d43e306b7f45b8e55be061c53a42a3448 /driver/accelgyro_bmi160.c
parent7db78001c2c262f332f5e00fdf6d86cf05ff897e (diff)
downloadchrome-ec-b3a9e1b64c25a4e35345903f5e20a841817962f6.tar.gz
motion_sense: Add "spoof" mode
This commit adds a "spoof" mode feature to the motionsense stack. It allows the user to arbitrarily set the outputs of the sensor in order to "spoof" the readings of the sensor. This can be useful in emulating tablet mode or device rotations. A command is available from the EC console named `accelspoof` and there is a corresponding motionsense command in ectool called `spoof`. The usage is as follows: - EC console > accelspoof [id] [on/off] [X Y Z] - ectool # ectool motionsense spoof -- [id] [0/1] [X Y Z] If on or off(or 0/1) is not specified, the current spoof mode status of the sensor is returned. If on is specified, but no components are provided, the sensor will lock the current values and provide those as the spoofed values. If the components are provided, those will be used as the spoofed values. BUG=chromium:675263 BRANCH=cyan,glados,gru,oak TEST=Flash a DUT with accels. From AP console, run `ectool motionsense lid_angle` in a loop, use 'accelspoof' EC console command to set spoofed values. Verify that the angle is fixed regardless of the actual angle of the DUT. TEST=Flash a DUT with accels. From AP console, use `ectool motionsense spoof` to spoof values and verify that `ectool motionsense` reflects the spoofed values. Test with both provided component values and no component values. Change-Id: Ie30688d22f38054e7243b1af493a3092b2cdfb72 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/421280 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'driver/accelgyro_bmi160.c')
-rw-r--r--driver/accelgyro_bmi160.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index 0348e51bd9..a92cc1f54c 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -927,6 +927,10 @@ static int bmi160_decode_header(struct motion_sensor_t *s,
int *v = (s + i)->raw_xyz;
vector.flags = 0;
normalize(s + i, v, *bp);
+#ifdef CONFIG_ACCEL_SPOOF_MODE
+ if ((s+i)->in_spoof_mode)
+ v = (s+i)->spoof_xyz;
+#endif /* defined(CONFIG_ACCEL_SPOOF_MODE) */
vector.data[X] = v[X];
vector.data[Y] = v[Y];
vector.data[Z] = v[Z];