diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2022-10-19 16:18:16 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-28 22:20:41 +0000 |
commit | 537cc92760a06584118e994851dc8cc8f7ac3fa4 (patch) | |
tree | cd54edf717216ef6fb504a6f01285462ea82ac29 | |
parent | 143369c812eed703f9576a362b45bc8f104c7aa8 (diff) | |
download | chrome-ec-537cc92760a06584118e994851dc8cc8f7ac3fa4.tar.gz |
common: Add override for lid angle calculation
Allow board to prevent enumerating the lid angle device and
calculate a lid angle, even if it looks like there are 2 accelerometers
present in the device.
BUG=b:254328661
BRANCH=brya
TEST=compile
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Change-Id: Iaa2d54d1afb31a229ada4259c63f954606636657
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3967457
Reviewed-by: Boris Mittelberg <bmbm@google.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Tested-by: Scott Chao <scott_chao@wistron.corp-partner.google.com>
-rw-r--r-- | common/ec_features.c | 8 | ||||
-rw-r--r-- | common/motion_sense.c | 10 | ||||
-rw-r--r-- | include/motion_sense.h | 6 |
3 files changed, 21 insertions, 3 deletions
diff --git a/common/ec_features.c b/common/ec_features.c index 6778a3b36a..7a69575500 100644 --- a/common/ec_features.c +++ b/common/ec_features.c @@ -5,11 +5,12 @@ /* Present Chrome EC device features to the outside world */ +#include "board_config.h" #include "common.h" #include "config.h" #include "console.h" #include "ec_commands.h" -#include "board_config.h" +#include "motion_sense.h" uint32_t get_feature_flags0(void) { @@ -128,7 +129,10 @@ uint32_t get_feature_flags1(void) | EC_FEATURE_MASK_1(EC_FEATURE_MOTION_SENSE_TIGHT_TIMESTAMPS) #endif #if defined(CONFIG_LID_ANGLE) && defined(CONFIG_TABLET_MODE) - | EC_FEATURE_MASK_1(EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS) + | (sensor_board_is_lid_angle_available() ? + EC_FEATURE_MASK_1( + EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS) : + 0) #endif #ifdef CONFIG_VBOOT_EFS2 | EC_FEATURE_MASK_1(EC_FEATURE_EFS2) diff --git a/common/motion_sense.c b/common/motion_sense.c index c08909d24e..f6011ae6d5 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -81,6 +81,13 @@ static int init_sensor_mutex(const struct device *dev) SYS_INIT(init_sensor_mutex, POST_KERNEL, 50); #endif /* CONFIG_ZEPHYR */ +#ifdef CONFIG_LID_ANGLE +__attribute__((weak)) int sensor_board_is_lid_angle_available(void) +{ + return 1; +} +#endif + static inline int motion_sensor_in_forced_mode(const struct motion_sensor_t *sensor) { @@ -1422,7 +1429,8 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args) default: /* Call other users of the motion task */ if (IS_ENABLED(CONFIG_LID_ANGLE) && - (ret == EC_RES_INVALID_PARAM)) + (ret == EC_RES_INVALID_PARAM) && + sensor_board_is_lid_angle_available()) ret = host_cmd_motion_lid(args); return ret; } diff --git a/include/motion_sense.h b/include/motion_sense.h index 6033d52ff9..750208d5cf 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -283,6 +283,12 @@ int sensor_init_done(struct motion_sensor_t *sensor); void sensor_board_proc_double_tap(void); /** + * Board specific function to double check lid angle calculation is possible. + * + */ +int sensor_board_is_lid_angle_available(void); + +/** * Commit the data in a sensor's raw_xyz vector. This operation might have * different meanings depending on the CONFIG_ACCEL_FIFO flag. * |