summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2017-10-10 15:53:39 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-11 16:11:09 -0700
commit0c7c687a1e0e0085c0af36f8ae90249d1f09ecba (patch)
treed73671aabc2ad512ce630636b8d97096398a1e72
parent465de629d3f627fb6378649330189bf033f645ad (diff)
downloadchrome-ec-0c7c687a1e0e0085c0af36f8ae90249d1f09ecba.tar.gz
motion_sense: Add CONFIG_DYNAMIC_MOTION_SENSOR_COUNT config option
Some projects, such as Coral use a common image to support different SKUs. In this case the number of motion sensors supported may need to be determined at runtime. CONFIG_DYNAMIC_MOTION_SENSOR_COUNT removes the const assumption for the global variable motion_sensor_count. Based on CL https://chromium-review.googlesource.com/444587 BUG=b:38271876 BRANCH=None TEST=make -j buildall Change-Id: I4dd3384d245641136f3329b60d1d941927366387 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/711194 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
-rw-r--r--include/config.h2
-rw-r--r--include/motion_sense.h4
2 files changed, 6 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h
index f60766d165..5709cfe1d2 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1385,6 +1385,8 @@
*/
#define CONFIG_MOTION_SENSE_SUSPEND_DELAY_US 0
+/* Define motion sensor count in board layer */
+#undef CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
/******************************************************************************/
/* Host to RAM (H2RAM) Memory Mapping */
diff --git a/include/motion_sense.h b/include/motion_sense.h
index 553cf0ca7e..478468022e 100644
--- a/include/motion_sense.h
+++ b/include/motion_sense.h
@@ -157,7 +157,11 @@ struct motion_sensor_t {
/* Defined at board level. */
extern struct motion_sensor_t motion_sensors[];
+#ifdef CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
+extern unsigned motion_sensor_count;
+#else
extern const unsigned motion_sensor_count;
+#endif
#if (!defined HAS_TASK_ALS) && (defined CONFIG_ALS)
/* Needed if reading ALS via LPC is needed */
extern const struct motion_sensor_t *motion_als_sensors[];