mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-08 16:41:55 +00:00
common: motion: Add double tap gesture host interface
Allow the host to enable/disable double tap. Send event when double tap is present. Also fix a bug when scanning for gestures. BRANCH=smaug BUG=chrome-os-partner:44754 TEST=compile. Check on Ryu. Change-Id: I50d008cd3823072ab1c1e2d21f1276cd2185d797 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/298683
This commit is contained in:
committed by
chrome-bot
parent
6f06cd5f7b
commit
4e8120a364
@@ -363,14 +363,14 @@ static void motion_sense_shutdown(void)
|
||||
#ifdef CONFIG_GESTURE_DETECTION_MASK
|
||||
mask = CONFIG_GESTURE_DETECTION_MASK;
|
||||
while (mask) {
|
||||
i = 31 - __builtin_clz(mask);
|
||||
mask &= (1 << mask);
|
||||
i = get_next_bit(&mask);
|
||||
sensor = &motion_sensors[i];
|
||||
sensor->drv->list_activities(sensor,
|
||||
&enabled, &disabled);
|
||||
/* exclude double tap, it is used internally. */
|
||||
enabled &= ~(1 << MOTIONSENSE_ACTIVITY_DOUBLE_TAP);
|
||||
while (enabled) {
|
||||
int activity = 31 - __builtin_clz(enabled);
|
||||
enabled &= ~(1 << activity);
|
||||
int activity = get_next_bit(&enabled);
|
||||
sensor->drv->manage_activity(sensor, activity, 0, NULL);
|
||||
}
|
||||
}
|
||||
@@ -612,6 +612,20 @@ void motion_sense_task(void)
|
||||
#endif
|
||||
#ifdef CONFIG_GESTURE_SENSOR_BATTERY_TAP
|
||||
if (event & CONFIG_GESTURE_TAP_EVENT) {
|
||||
#ifdef CONFIG_ACCEL_FIFO
|
||||
struct ec_response_motion_sensor_data vector;
|
||||
|
||||
/*
|
||||
* Send events to the FIFO
|
||||
* AP is ignoring double tap event, do no wake up and no
|
||||
* automatic disable.
|
||||
*/
|
||||
vector.flags = 0;
|
||||
vector.activity = MOTIONSENSE_ACTIVITY_DOUBLE_TAP;
|
||||
vector.state = 1; /* triggered */
|
||||
vector.sensor_num = MOTION_SENSE_ACTIVITY_SENSOR_ID;
|
||||
motion_sense_fifo_add_unit(&vector, NULL, 0);
|
||||
#endif
|
||||
CPRINTS("double tap!");
|
||||
lightbar_sequence(LIGHTBAR_TAP);
|
||||
}
|
||||
@@ -622,7 +636,6 @@ void motion_sense_task(void)
|
||||
#ifdef CONFIG_ACCEL_FIFO
|
||||
struct ec_response_motion_sensor_data vector;
|
||||
|
||||
CPRINTS("significant motion");
|
||||
/* Send events to the FIFO */
|
||||
vector.flags = MOTIONSENSE_SENSOR_FLAG_WAKEUP;
|
||||
vector.activity = MOTIONSENSE_ACTIVITY_SIG_MOTION;
|
||||
@@ -630,6 +643,7 @@ void motion_sense_task(void)
|
||||
vector.sensor_num = MOTION_SENSE_ACTIVITY_SENSOR_ID;
|
||||
motion_sense_fifo_add_unit(&vector, NULL, 0);
|
||||
#endif
|
||||
CPRINTS("significant motion");
|
||||
/* Disable further detection */
|
||||
activity_sensor = &motion_sensors[CONFIG_GESTURE_SIGMO];
|
||||
activity_sensor->drv->manage_activity(
|
||||
@@ -1022,8 +1036,7 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args)
|
||||
ret = EC_RES_SUCCESS;
|
||||
mask = CONFIG_GESTURE_DETECTION_MASK;
|
||||
while (mask && ret == EC_RES_SUCCESS) {
|
||||
i = 31 - __builtin_clz(mask);
|
||||
mask &= (1 << mask);
|
||||
i = get_next_bit(&mask);
|
||||
sensor = &motion_sensors[i];
|
||||
ret = sensor->drv->list_activities(sensor,
|
||||
&enabled, &disabled);
|
||||
@@ -1044,8 +1057,7 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args)
|
||||
return EC_RES_INVALID_PARAM;
|
||||
mask = CONFIG_GESTURE_DETECTION_MASK;
|
||||
while (mask && ret == EC_RES_SUCCESS) {
|
||||
i = 31 - __builtin_clz(mask);
|
||||
mask &= (1 << mask);
|
||||
i = get_next_bit(&mask);
|
||||
sensor = &motion_sensors[i];
|
||||
sensor->drv->list_activities(sensor,
|
||||
&enabled, &disabled);
|
||||
|
||||
@@ -1788,6 +1788,7 @@ struct ec_response_motion_sense_fifo_data {
|
||||
enum motionsensor_activity {
|
||||
MOTIONSENSE_ACTIVITY_RESERVED = 0,
|
||||
MOTIONSENSE_ACTIVITY_SIG_MOTION = 1,
|
||||
MOTIONSENSE_ACTIVITY_DOUBLE_TAP = 2,
|
||||
};
|
||||
|
||||
struct ec_motion_sense_activity {
|
||||
|
||||
@@ -3271,6 +3271,9 @@ static void motionsense_display_activities(uint32_t activities)
|
||||
if (activities & (1 << MOTIONSENSE_ACTIVITY_SIG_MOTION))
|
||||
printf("%d: Significant motion\n",
|
||||
MOTIONSENSE_ACTIVITY_SIG_MOTION);
|
||||
if (activities & (1 << MOTIONSENSE_ACTIVITY_DOUBLE_TAP))
|
||||
printf("%d: Double tap\n",
|
||||
MOTIONSENSE_ACTIVITY_DOUBLE_TAP);
|
||||
}
|
||||
|
||||
static int cmd_motionsense(int argc, char **argv)
|
||||
|
||||
Reference in New Issue
Block a user