summaryrefslogtreecommitdiff
path: root/common/body_detection.c
Commit message (Collapse)AuthorAgeFilesLines
* common: body_detection: using bypass_fifo flagChing-Kang Yen2021-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Originally, the body_detection will set MOTIONSENSE_SENSOR_FLAG_WAKEUP when changing state, which disable suspension of device. Thus, there was a commit [crrev.com/c/2631887] that just simply unset the MOTIONSENSE_SENSOR_FLAG_WAKEUP, which make body_detection not work properly. So, this commit will resolve the problem by setting the BYPASS_FIFO flag. BRANCH=None BUG=b:123434029 BUG=b:176399952 TEST=powerd_dbus_suspend # See if the device wake up after suspend TEST=make buildall; Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: Ia911f4b27c15891d4e04eedbd524d019e0f334f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2780862 Commit-Queue: Ching-Kang Yen <chingkang@chromium.org> Tested-by: Ching-Kang Yen <chingkang@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* Revert "common: body_detection: prevent AP from unexpected waking up"Ching-Kang Yen2021-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit bca7737997eecb517dbbc94fd95d034f0f5cde56. Reason for revert: This commit is just a workaround, and causes another problem. The actual fix will be in the following commit. Original change's description: > common: body_detection: prevent AP from unexpected waking up > > Current body_detection will make AP resume after enter S3. Cause the AP > wake up in a short time after suspend. > This CL will prevent this from happening. > > BRANCH=None > BUG=b:176399952 > TEST=powerd_dbus_suspend # See if the device wake up after suspend > > Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> > Change-Id: Id208800a66e4e2d433a555210ece50af85c908ec > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2631887 > Reviewed-by: Wai-Hong Tam <waihong@google.com> BRANCH=None BUG=b:176399952 TEST=None Cq-Depend: chromium:2780862 Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I904ff718ff41336dca3c85c99a424a69483740f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2721328 Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* common: body_detection: prevent AP from unexpected waking upChing-Kang Yen2021-01-161-1/+1
| | | | | | | | | | | | | | | Current body_detection will make AP resume after enter S3. Cause the AP wake up in a short time after suspend. This CL will prevent this from happening. BRANCH=None BUG=b:176399952 TEST=powerd_dbus_suspend # See if the device wake up after suspend Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: Id208800a66e4e2d433a555210ece50af85c908ec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2631887 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* ec_commands: add struct ec_response_activity_dataChing-Kang Yen2020-12-111-2/+4
| | | | | | | | | | | | | | Add struct ec_response_activity_data to handle activity data in include/ec_commands.h. BRANCH=None BUG=b:169374265 TEST=make buildall Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I5f40d45d656ae91acc6e9364261c548f302383ae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2581708 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* common: motion_sense: Add spoofing activityChing-Kang Yen2020-11-131-5/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | make spoof command able to spoof activity state: ectool motionsense spoof -- NUM activity ACT [EN] [0/1] This commit also remove unused parameter |sensor_num| from list_activities, set_activity, get_activity in ectool. BRANCH=None BUG=b:123434029 TEST=buildall TEST=ectool motionsense spoof 4 activity 4 1 0 ectool motionsense spoof 4 activity 4 ectool motionsense get_activity 4 ectool motionsense spoof 4 activity 4 1 1 ectool motionsense get_activity 4 ectool motionsense spoof 4 activity 4 0 ectool motionsense get_activity 4 ectool motionsense spoof 4 activity 4 1 ectool motionsense get_activity 4 Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I819c156ae7fe50c5cf6216d0f44012d192fb528e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2477393 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* motion_sense: Make change in range permanentGwendal Grignou2020-11-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | When AP changes range, unlike offset or ODR, it was not surviving init() call. If the sensor is powered off in S3, at resume the range would be back to the default. To make it consistent with other attributes, remember range change until EC powers down. - remove get_range - add current_range to store the range currently used. This is modifiable by the AP - when the AP shutdown, revert current_range to default_range - Remove const attribute for sensor structure when init and set_range is called. BUG=chromium:1083791 BRANCH=none TEST=One eve branch, check range is preserved even after 'shutdown -h 0' Change-Id: Ia7126ac0cc9c3fef60b4464d95d6dd15e64b0fc4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215751 Reviewed-by: Yuval Peress <peress@chromium.org>
* common: body_detection: modify variance updating formulaChing-Kang Yen2020-11-061-6/+6
| | | | | | | | | | | | | | | Modify the variance formula to speed up body detection. BRANCH=None BUG=b:123434029 TEST=make buildall; TEST=make BOARD=ampton, re-flash the DUT, see if the body detection works Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: Ib444abb6bdfbc637539103d563b515817865acc9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2452133 Reviewed-by: Heng-ruey Hsu <henryhsu@chromium.org>
* common: body: Use IS_ENABLEDGwendal Grignou2020-11-061-11/+11
| | | | | | | | | | | BUG=chromium:1140877 BRANCH=none TEST=buildall Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: Iac63ec83258d1194d2b035c1dd67b6f915d37c16 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2489462 Reviewed-by: Ching-Kang Yen <chingkang@chromium.org>
* common: body_detection: modify calculation of noise levelChing-Kang Yen2020-09-291-1/+10
| | | | | | | | | | | | | | | | | | | We used rms_noise^2 as noise level for body_detection. But, there are still some different noise level based on different devices. Add the CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR to adjust the noise_level. Default value is 120%, since the 100% of the rms_noise^2 is not enough, especially in 200Hz. BRANCH=None BUG=b:123434029 TEST=make buildall; make BOARD=ampton, re-flash the DUT, see if the body detection works Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I2a7416b0bd8d0aac51d16c3aed9d962837f52c0b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2416477 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Heng-ruey Hsu <henryhsu@chromium.org>
* common: implement body_detection state machineChing-Kang Yen2020-09-031-0/+226
Implement body_detection state machine. Detect whether the user is close to the devices or not. Use the variance of acceleration from accelerometer to compute the motion confidence. If motion confidence is high enough, set the motion state to ON_BODY. If low enough, set it to OFF_BODY. Also, make gesture_cal() be called only when the gesture sensor data is updated. BRANCH=None BUG=b:123434029 TEST=make buildall, flash the ec, watch the ec console log Change-Id: If886b7f9fc505ef4db4d7abb08194b8f866121bb Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2230938 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>