summaryrefslogtreecommitdiff
path: root/include/motion_sense_fifo.h
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2019-10-01 16:50:33 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-02 11:08:29 +0000
commit63f8741f4605b163c06a3629da890c12051c3d7f (patch)
tree2ebe99ac47f62e35bf7cc45045e479d957ec91ee /include/motion_sense_fifo.h
parent8989576dae8b5f45d2b591b5d76bb320a5ecffb1 (diff)
downloadchrome-ec-63f8741f4605b163c06a3629da890c12051c3d7f.tar.gz
Revert "common: Refactor motion_sense_fifo"
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>
Diffstat (limited to 'include/motion_sense_fifo.h')
-rw-r--r--include/motion_sense_fifo.h80
1 files changed, 33 insertions, 47 deletions
diff --git a/include/motion_sense_fifo.h b/include/motion_sense_fifo.h
index d47c23af94..6b306b5f29 100644
--- a/include/motion_sense_fifo.h
+++ b/include/motion_sense_fifo.h
@@ -7,8 +7,14 @@
#define __CROS_EC_MOTION_SENSE_FIFO_H
#include "motion_sense.h"
+#include "task.h"
+
+extern struct queue motion_sense_fifo;
+extern int wake_up_needed;
+extern int fifo_int_enabled;
+extern int fifo_queue_count;
+extern int motion_sense_fifo_lost;
-/** Allowed async events. */
enum motion_sense_async_event {
ASYNC_EVENT_FLUSH = MOTIONSENSE_SENSOR_FLAG_FLUSH |
MOTIONSENSE_SENSOR_FLAG_TIMESTAMP,
@@ -16,26 +22,6 @@ enum motion_sense_async_event {
MOTIONSENSE_SENSOR_FLAG_TIMESTAMP,
};
-/** Whether or not we need to wake up the AP. */
-extern int motion_sense_fifo_wake_up_needed;
-
-/**
- * Insert an async event into the fifo.
- *
- * @param sensor The sensor that generated the async event.
- * @param event The event to insert.
- */
-void motion_sense_fifo_insert_async_event(
- struct motion_sensor_t *sensor,
- enum motion_sense_async_event event);
-
-/**
- * Insert a timestamp into the fifo.
- *
- * @param timestamp The timestamp to insert.
- */
-void motion_sense_fifo_add_timestamp(uint32_t timestamp);
-
/**
* Stage data to the fifo, including a timestamp. This data will not be
* available to the AP until motion_sense_fifo_commit_data is called.
@@ -46,46 +32,46 @@ void motion_sense_fifo_add_timestamp(uint32_t timestamp);
* @param time accurate time (ideally measured in an interrupt) the sample
* was taken at
*/
-void motion_sense_fifo_stage_data(
- struct ec_response_motion_sensor_data *data,
- struct motion_sensor_t *sensor,
- int valid_data,
- uint32_t time);
+void motion_sense_fifo_stage_data(struct ec_response_motion_sensor_data *data,
+ struct motion_sensor_t *sensor,
+ int valid_data,
+ uint32_t time);
/**
- * Commit all the currently staged data to the fifo. Doing so makes it readable
- * to the AP.
+ * Commits all staged data to the fifo. If multiple readings were placed using
+ * the same timestamps, they will be spread out.
*/
void motion_sense_fifo_commit_data(void);
/**
- * Get information about the fifo.
+ * Insert an async event into the fifo.
*
- * @param fifo_info The struct to modify with the current information about the
- * fifo.
- * @param reset Whether or not to reset statistics after reading them.
+ * @param sensor Pointer to the sensor generating the event.
+ * @param evt The event to insert.
*/
-void motion_sense_fifo_get_info(
- struct ec_response_motion_sense_fifo_info *fifo_info,
- int reset);
+void motion_sense_insert_async_event(struct motion_sensor_t *sensor,
+ enum motion_sense_async_event evt);
/**
- * Check whether or not the fifo has gone over its threshold.
+ * Stage a timestamp into the fifo.
+ *
+ * @param timestamp The timestamp to stage.
+ */
+void motion_sense_fifo_stage_timestamp(uint32_t timestamp);
+
+/**
+ * Get information about the fifo.
*
- * @return 1 if yes, 0 for no.
+ * @param fifo_info The struct to store the info.
*/
-int motion_sense_fifo_over_thres(void);
+void motion_sense_get_fifo_info(
+ struct ec_response_motion_sense_fifo_info *fifo_info);
/**
- * Read available committed entries from the fifo.
+ * Checks if either the AP should be woken up due to the fifo.
*
- * @param capacity_bytes The number of bytes available to be written to `out`.
- * @param max_count The maximum number of entries to be placed in `out`.
- * @param out The target to copy the data into.
- * @param out_size The number of bytes written to `out`.
- * @return The number of entries written to `out`.
+ * @return 1 if the AP should be woken up, 0 otherwise.
*/
-int motion_sense_fifo_read(int capacity_bytes, int max_count, void *out,
- uint16_t *out_size);
+int motion_sense_fifo_is_wake_up_needed(void);
-#endif /*__CROS_EC_MOTION_SENSE_FIFO_H */
+#endif /* __CROS_EC_MOTION_SENSE_FIFO_H */