summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-08-03 10:42:36 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-12-08 02:14:29 +0000
commit02efd15c09ba834721b526952ca09bf29efc526b (patch)
treec8d5a25a48cf6518be76a90e1bbdefd5225cd8c8
parent0036aa2ef97e676917cdff31e771c614b73f0b32 (diff)
downloadchrome-ec-02efd15c09ba834721b526952ca09bf29efc526b.tar.gz
fpsensor: Add timing statistics.
This commit adds some basic timing statistics around fingerprint capture, matching, and overall timing for returning a response for a fingerprint. A new host command is added, EC_CMD_FP_STATS, which returns these metrics. Additionally, ectool has been extended with the `fpstats` to command retrieve these metrics. BUG=b:111316382 BRANCH=None TEST=Flash nocturne_fp, perform capture and match, view results using ectool and verify that they are reasonable. Change-Id: Ib675116eebc8131d7b30e721d00eccfdb8905821 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/1162961 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Nicolas Norvez <norvez@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1364311 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: YH Lin <yueherngl@chromium.org> Commit-Queue: YH Lin <yueherngl@chromium.org> Tested-by: YH Lin <yueherngl@chromium.org>
-rw-r--r--include/ec_commands.h17
-rw-r--r--util/ectool.c37
2 files changed, 54 insertions, 0 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 2411bbfbd3..52197e2a05 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -4989,6 +4989,23 @@ struct __ec_align4 ec_response_fp_context {
uint32_t nonce[FP_CONTEXT_NONCE_WORDS];
};
+#define EC_CMD_FP_STATS 0x0407
+
+#define FPSTATS_CAPTURE_INV (1 << 0)
+#define FPSTATS_MATCHING_INV (1 << 1)
+
+struct __ec_align2 ec_response_fp_stats {
+ uint32_t capture_time_us;
+ uint32_t matching_time_us;
+ uint32_t overall_time_us;
+ struct {
+ uint32_t lo;
+ uint32_t hi;
+ } overall_t0;
+ uint8_t timestamps_invalid;
+ int8_t template_matched;
+};
+
/*****************************************************************************/
/* Touchpad MCU commands: range 0x0500-0x05FF */
diff --git a/util/ectool.c b/util/ectool.c
index 9e6c7673eb..2164cae0ec 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -129,6 +129,8 @@ const char help_str[] =
" Prints information about the Fingerprint sensor\n"
" fpmode [capture|deepsleep|fingerdown|fingerup]\n"
" Configure/Read the fingerprint sensor current mode\n"
+ " fpstats\n"
+ " Prints timing statisitcs relating to capture and matching\n"
" fptemplate [<infile>|<index 0..2>]\n"
" Add a template if <infile> is provided, else dump it\n"
" forcelidopen <enable>\n"
@@ -1278,6 +1280,40 @@ int cmd_fp_mode(int argc, char *argv[])
return 0;
}
+int cmd_fp_stats(int argc, char *argv[])
+{
+ struct ec_response_fp_stats r;
+ int rv;
+ unsigned long long ts;
+
+ rv = ec_command(EC_CMD_FP_STATS, 0, NULL, 0, &r, sizeof(r));
+ if (rv < 0)
+ return rv;
+
+ ts = (uint64_t)r.overall_t0.hi << 32 | r.overall_t0.lo;
+ printf("FP stats (t0=%llu us):\n", ts);
+ printf("Last capture time: ");
+ if (r.timestamps_invalid & FPSTATS_CAPTURE_INV)
+ printf("Invalid\n");
+ else
+ printf("%d us\n", r.capture_time_us);
+
+ printf("Last matching time: ");
+ if (r.timestamps_invalid & FPSTATS_MATCHING_INV)
+ printf("Invalid\n");
+ else
+ printf("%d us (finger: %d)\n", r.matching_time_us,
+ r.template_matched);
+
+ printf("Last overall time: ");
+ if (r.timestamps_invalid)
+ printf("Invalid\n");
+ else
+ printf("%d us\n", r.overall_time_us);
+
+ return 0;
+}
+
int cmd_fp_info(int argc, char *argv[])
{
struct ec_response_fp_info r;
@@ -8070,6 +8106,7 @@ const struct command commands[] = {
{"fpframe", cmd_fp_frame},
{"fpinfo", cmd_fp_info},
{"fpmode", cmd_fp_mode},
+ {"fpstats", cmd_fp_stats},
{"fptemplate", cmd_fp_template},
{"gpioget", cmd_gpio_get},
{"gpioset", cmd_gpio_set},