summaryrefslogtreecommitdiff
path: root/common/motion_sense_fifo.c
Commit message (Collapse)AuthorAgeFilesLines
* common: motionsense fifo: Reset the initialized bits after commitYuval Peress2021-05-041-0/+6
| | | | | | | | | | | | | | | | | | | | | Previously once we had one sample from a sensor, we considered the fifo initialized. Meaning we would use our computed next timestamp to spread the timestamps. This was causing issues with some devices that ended up causing the timestamps to run ahead. Reset next_timestamp_initialized back to 0 after each commit. This will allow repeated timestamps but only if a driver stages/commits the same timestamp twice. Staging the same timestamp with only a single commit will still work as before (which is the expected path). BRANCH=none BUG=b:168335284 TEST=make run-motion_sense_fifo Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ib7c566f69d7c1e4e898050b67105555dd05376e5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2871055 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* common: motion_sense: Prevent on/off body from waking up deviceGwendal Grignou2021-03-291-1/+17
| | | | | | | | | | | | | | | | | | | | Introduce a new flag: BYPASS_FIFO to raise an interrupt to the AP when an event is sent. It is not as strong as WAKEUP, as it does not wake up the AP. BYPASS_FIFO must be set when WAKEUP is set. It is applied to sync sensor as well as gesture/activity sensor. BUG=b:123434029 BRANCH=trogdor TEST=Compile Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: Id5aba71e6d11ef31f7fa2c67ba2e07178d088b1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2780834 Reviewed-by: Ching-Kang Yen <chingkang@chromium.org> Tested-by: Ching-Kang Yen <chingkang@chromium.org> Commit-Queue: Ching-Kang Yen <chingkang@chromium.org>
* common: motion: move read fifo console commandGwendal Grignou2021-01-291-0/+34
| | | | | | | | | | | | | | Move command in _fifo.c, as the fifo data structure is a static in this file. BUG=none BRANCH=none TEST=Add CONFIG_CMD_ACCEL_FIFO to baseboard volteer, check it compiles. Change-Id: I6f9efafeaf450309ce48182396f3398fa4276d46 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2485909 Reviewed-by: Yuval Peress <peress@chromium.org>
* common: motion_sense_fifo: modify SENSOR_COUNTChing-Kang Yen2020-09-031-6/+6
| | | | | | | | | | | | | | | | | | | | When the CONFIG_GESTURE_HOST_DETECTION is defined, there will be an extra activity sensor. However, the motion_sense_fifo only use SENSOR_NUM for the number of sensors. This might cause overflow issues. Introduce a new variable MAX_MOTION_SENSORS that represents the SENSOR_COUNT (+ 1 when activity sensor is available). Replace all SENSOR_COUNT in motion_sensor_fifo.c to MAX_MOTION_SENSORS. BRANCH=None BUG=b:123434029 TEST=make buildall Signed-off-by: Ching-Kang Yen <chingkang@chromium.org> Change-Id: I39fc9d77c0aa9a23f9931d4b27905b678081d3bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2329110 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Heng-ruey Hsu <henryhsu@chromium.org>
* common: motion_sense_fifo: fix iteration bugYuval Peress2020-02-141-2/+24
| | | | | | | | | | | | | | | Fix potential bug when iterating over FIFO entries for commit. This bug can manifest when non-timestamp/non-data entries are inserted into the FIFO. TEST=Added unit tests BRANCH=None BUG=b:138303429,chromium:1023858 Change-Id: I64855db2141f7ad6aafb3f3a84632a1dabef11f4 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2012846 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* common: Migrate online calibration to own moduleYuval Peress2020-02-131-49/+58
| | | | | | | | | | | | | | | This change moves the code that handles caching the temperature (which is the first step in online calibration) into a new compilational unit. TEST=None BRANCH=None BUG=b:138303429,chromium:1023858 Change-Id: Ib1fe3d2234dc2436e2bbfd4febd22196e5cdafef Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1906340 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common: motion_sense_fifo: Read temperature on stageYuval Peress2020-01-111-0/+43
| | | | | | | | | | | | | | | | Assuming online calibration is enabled, and the driver implements the get_temp function. When a driver stages data, if this is the first staged sample, read the current internal sensor temperature and cache it (will later be used in commit_data()). BUG=b:138303429,chromium:1023858 BRANCH=None TEST=buildall Change-Id: I8e5404e628d3e8ded7c2d75b1b5cbac8166e97aa Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1867225 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common/motion_sense: fix compilation issue when MKBP is not setGwendal Grignou2020-01-091-0/+2
| | | | | | | | | | | | | | When testing on nucleo board (not host attached), MKBP is not compiled in. Be sure sensor code is not using any code from MKBP. BUG=none BRANCH=none TEST=board nucleo-f072rb_iks01a2 compile. Change-Id: Ic1e1a277affa3d0798e62171d4d477e2cb17366b Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1992799 Reviewed-by: Yuval Peress <peress@chromium.org>
* common: Refactor motion_sense_fifoYuval Peress2019-11-111-118/+233
| | | | | | | | | | | | | | | | | This change refactors the motion_sense_fifo to uniformly prefix all the functions to avoid collisions. It also adds several unit tests and fixes a few bugs with the fifo logic. BUG=b:137758297 BRANCH=kukui TEST=buildall TEST=run CTS on arcada, kohaku, and kukui TEST=boot kohaku (verify tablet mode works as expected) Change-Id: I6e8492ae5fa474d0aa870088ab56f76b220a73e3 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1835221 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Revert "common: Refactor motion_sense_fifo"Scott Collyer2019-10-021-161/+97
| | | | | | | | | | | | | | | | | | | | | | This reverts commit 36b47ab3c06e477f5e95d6d9e84a5220248784e6. With this CL the lid angle calculation on hatch devices reports 500 which is what's used for can't caluclate a meaninfgul value. BUG=b:141840539 BRANCH=None TEST=On helios tested with this CL and saw that lid angle calculations returned 500 for lid angle. Then reverted the CL and verifed that lid angle calculations were correct. Used 'accelinfo on 10000' to check the EC reported lid angle. Change-Id: Id4e36219792d00357d2885e9944c58fe0e15c5ca Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1834705 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
* common: Refactor motion_sense_fifoYuval Peress2019-09-271-97/+161
| | | | | | | | | | | | | | | This change refactors the motion_sense_fifo to uniformly prefix all the functions to avoid collisions. It also adds several unit tests and fixes a few bugs with the fifo logic. BUG=b:137758297 BRANCH=None TEST=buildall & run CTS on arcada Change-Id: I7aae45382b07d6c8858e07215c33e710c7ed27ec Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704166 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* config: Refactor CONFIG_ACCEL_FIFO to enable use of IS_ENABLEDYuval Peress2019-09-031-1/+6
| | | | | | | | | | | | | | | This change allows us to use the IS_ENABLED condition to replace the various ifdef guards around the CONFIG_ACCEL_FIFO BUG=b:137758297,chromium:981990 BRANCH=None TEST=buildall and CTS tests on Arcada Change-Id: I65d36bac19855e51c830a33e6f3812575e8d15d9 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704164 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* common: Move fifo logic out of motion_sense.cYuval Peress2019-08-231-0/+403
This change is needed to allow better testing of the fifo behavior. Additionally, motion_sense_fifo.c will only be compiled if CONFIG_ACCEL_FIFO is defined. This behaviour requires a few small changes to several boards and baseboards to make sure that we only define CONFIG_ACCEL_FIFO when the MOTIONSENSE task is present (some times that may be only in one section RW or RO). BUG=b:137758297 BRANCH=None TEST=buildall and ran CTS on arcada Change-Id: I2f7e4e436ba9568a35b7a0b2c8d53a73f198ba73 Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704163 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Commit-Queue: Alexandru M Stan <amstan@chromium.org>