diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-04-08 10:28:29 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-04-10 00:10:07 +0000 |
commit | 0abb7a45d973a5d612d901726588db78e4679720 (patch) | |
tree | 0f2e1c72f7b8699fafdda85c3068dd39e4283b9d /include | |
parent | da755350cfddfc0483cb4d95d5899027f70c5436 (diff) | |
download | chrome-ec-0abb7a45d973a5d612d901726588db78e4679720.tar.gz |
accel: Add host cmd for setting lid angle threshold for disabling keyboard wake
Added a sub-command to the motionsense host command (0x2b) for getting/setting
the lid angle at which the keyboard is disabled as a wake source in S3. The
value can be anywhere from 0 to 360 degrees, default set to 180. Note, this
only takes affect for boards that have CONFIG_LID_ANGLE_KEY_SCAN defined.
Modified ectool motionsense command to use new host sub-command.
Also modified the lid angle measurement in the EC to be in the range [0, 360],
instead of [-180, 180], and changed casting of lid angle as an int to round
to nearest.
BUG=none
BRANCH=rambi
TEST=Tested on a glimmer:
Using default keyboard disable lid angle of 180, made sure that when lid
angle is past 180, key presses do not wake system, and when lid angle is
less than 180, key presses do wake up system.
Used ectool motionsense kb_wake to set the keyboard disable lid angle to 0.
Made sure that keyboard never wakes up the system. Set keyboard disable lid
angle to 360 and made sure that the keyboard always wakes up the system.
Change-Id: I437164c6e38c29169ef6e20e86c9cf2a1c78f86e
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193663
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 5 | ||||
-rw-r--r-- | include/ec_commands.h | 21 | ||||
-rw-r--r-- | include/lid_angle.h | 8 | ||||
-rw-r--r-- | include/motion_sense.h | 5 |
4 files changed, 28 insertions, 11 deletions
diff --git a/include/config.h b/include/config.h index 048033d793..73ca90fc83 100644 --- a/include/config.h +++ b/include/config.h @@ -536,11 +536,6 @@ /* * Allows using the lid angle measurement to determine if key scanning should * be enabled or disabled when chipset is suspended. - * - * Any board that defines this must also define two macros: - * LID_IN_RANGE_TO_ACCEPT_KEYS(angle), LID_IN_RANGE_TO_IGNORE_KEYS(angle). - * These macros should return true if the given angle argument is in range - * to accept or ignore key presses. */ #undef CONFIG_LID_ANGLE_KEY_SCAN diff --git a/include/ec_commands.h b/include/ec_commands.h index f71848a707..de47135d53 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -1190,6 +1190,15 @@ enum motionsense_command { */ MOTIONSENSE_CMD_SENSOR_RANGE = 4, + /* + * Setter/getter command for the keyboard wake angle. When the lid + * angle is greater than this value, keyboard wake is disabled in S3, + * and when the lid angle goes less than this value, keyboard wake is + * enabled. Note, the lid angle measurement is an approximate, + * un-calibrated value, hence the wake angle isn't exact. + */ + MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5, + /* Number of motionsense sub-commands. */ MOTIONSENSE_NUM_CMDS }; @@ -1244,11 +1253,14 @@ struct ec_params_motion_sense { /* no args */ } dump; - /* Used for MOTIONSENSE_CMD_EC_RATE. */ + /* + * Used for MOTIONSENSE_CMD_EC_RATE and + * MOTIONSENSE_CMD_KB_WAKE_ANGLE. + */ struct { /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */ int16_t data; - } ec_rate; + } ec_rate, kb_wake_angle; /* Used for MOTIONSENSE_CMD_INFO. */ struct { @@ -1303,12 +1315,13 @@ struct ec_response_motion_sense { /* * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR, - * and MOTIONSENSE_CMD_SENSOR_RANGE. + * MOTIONSENSE_CMD_SENSOR_RANGE, and + * MOTIONSENSE_CMD_KB_WAKE_ANGLE. */ struct { /* Current value of the parameter queried. */ int32_t ret; - } ec_rate, sensor_odr, sensor_range; + } ec_rate, sensor_odr, sensor_range, kb_wake_angle; }; } __packed; diff --git a/include/lid_angle.h b/include/lid_angle.h index bd60b90907..cd13265c93 100644 --- a/include/lid_angle.h +++ b/include/lid_angle.h @@ -17,4 +17,12 @@ */ void lidangle_keyscan_update(float lid_ang); +/** + * Getter and setter methods for the keyboard wake angle. In S3, when the + * lid angle is greater than this value, the keyboard is disabled, and when + * the lid angle is smaller than this value, the keyboard is enabled. + */ +int lid_angle_get_kb_wake_angle(void); +void lid_angle_set_kb_wake_angle(int ang); + #endif /* __CROS_EC_LID_ANGLE_H */ diff --git a/include/motion_sense.h b/include/motion_sense.h index d0c2774254..3a3b9b5121 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -53,9 +53,10 @@ struct accel_orientation acc_orient; /** - * Get last calculated lid angle. + * Get last calculated lid angle. Note, the lid angle calculated by the EC + * is un-calibrated and is an approximate angle. * - * @return lid angle in degrees in range [-180, 180]. + * @return lid angle in degrees in range [0, 360]. */ int motion_get_lid_angle(void); |