diff options
author | Tom Hughes <tomhughes@chromium.org> | 2019-09-06 15:58:44 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-02 11:32:35 +0000 |
commit | 4f71afc84acc79f137ee086220743c3c42096f90 (patch) | |
tree | 36932a50fe1a7be15383804c4f82ff091b46b57b /common/fpsensor/fpsensor_state.c | |
parent | 63f8741f4605b163c06a3629da890c12051c3d7f (diff) | |
download | chrome-ec-4f71afc84acc79f137ee086220743c3c42096f90.tar.gz |
fpsensor: Add async FP_CMD_CONTEXT
Setting the context now triggers a reset of the sensor library (see
I3e25bdf7eaaf99f3801547e11a6c524f924f4726), which in turn will end up
calling fp_sensor_open to re-initialize the sensor. Since some
calibration is performed in that command, it takes ~173 ms, which is
close enough to the EC command timeout (200 ms) that it often fails.
This change makes the command "asynchronous" so that userspace can poll
for the result and avoid the command timeout.
BRANCH=nocturne
BUG=b:137288498
TEST=make buildall -j
TEST=ectool --name=cros_fp fpcontext 01234567890123456789012345678901
Change-Id: I997bf9c5b9e90eceb5375dccffcb535529a86e47
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819115
Reviewed-by: Yicheng Li <yichengli@chromium.org>
Diffstat (limited to 'common/fpsensor/fpsensor_state.c')
-rw-r--r-- | common/fpsensor/fpsensor_state.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/common/fpsensor/fpsensor_state.c b/common/fpsensor/fpsensor_state.c index c395bd7af3..f7890f9cdc 100644 --- a/common/fpsensor/fpsensor_state.c +++ b/common/fpsensor/fpsensor_state.c @@ -199,12 +199,30 @@ DECLARE_HOST_COMMAND(EC_CMD_FP_MODE, fp_command_mode, EC_VER_MASK(0)); static enum ec_status fp_command_context(struct host_cmd_handler_args *args) { - const struct ec_params_fp_context *params = args->params; - - fp_reset_and_clear_context(); - - memcpy(user_id, params->userid, sizeof(user_id)); + const struct ec_params_fp_context_v1 *p = args->params; + uint32_t mode_output; + + switch (p->action) { + case FP_CONTEXT_ASYNC: + if (sensor_mode & FP_MODE_RESET_SENSOR) + return EC_RES_BUSY; + + /** + * Trigger a call to fp_reset_and_clear_context() by + * requesting a reset. Since that function triggers a call to + * fp_sensor_open(), this must be asynchronous because + * fp_sensor_open() can take ~175 ms. See http://b/137288498. + */ + return fp_set_sensor_mode(FP_MODE_RESET_SENSOR, &mode_output); + + case FP_CONTEXT_GET_RESULT: + if (sensor_mode & FP_MODE_RESET_SENSOR) + return EC_RES_BUSY; + + memcpy(user_id, p->userid, sizeof(user_id)); + return EC_RES_SUCCESS; + } - return EC_RES_SUCCESS; + return EC_RES_INVALID_PARAM; } -DECLARE_HOST_COMMAND(EC_CMD_FP_CONTEXT, fp_command_context, EC_VER_MASK(0)); +DECLARE_HOST_COMMAND(EC_CMD_FP_CONTEXT, fp_command_context, EC_VER_MASK(1)); |