From 5a1c7c47bbb53b18c0d0a1036b5c82d1005cee4a Mon Sep 17 00:00:00 2001 From: Nicolas Norvez Date: Fri, 20 Jul 2018 14:04:21 -0700 Subject: ectool: Handle "Dead pixels: UNKNOWN" in "fpinfo" The "Dead pixels" entry printed out after the "fpinfo" command is always returning 0 because b/76037094 hasn't been implemented yet. This is misleading since people assume that the feature has been implemented. Use the special value 0x3FF to report "UNKNOWN" rather than 0 dead pixels in that case. Signed-off-by: Nicolas Norvez BRANCH=None BUG=b:111695472 TEST=check output of "ectool --name=cros_fp fpinfo", both before and after updating the firmware Change-Id: I12b12123dbe95aa9b629a7c2747533571f0f99f0 Reviewed-on: https://chromium-review.googlesource.com/1145738 Commit-Ready: Nicolas Norvez Tested-by: Nicolas Norvez Reviewed-by: Nicolas Boichat Reviewed-on: https://chromium-review.googlesource.com/c/1363828 Reviewed-by: YH Lin Commit-Queue: YH Lin Tested-by: YH Lin --- include/ec_commands.h | 2 ++ util/ectool.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/ec_commands.h b/include/ec_commands.h index f604b7c20a..e56ffad9c1 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -4871,6 +4871,8 @@ struct __ec_align4 ec_response_fp_mode { /* Number of dead pixels detected on the last maintenance */ #define FP_ERROR_DEAD_PIXELS(errors) ((errors) & 0x3FF) +/* Unknown number of dead pixels detected on the last maintenance */ +#define FP_ERROR_DEAD_PIXELS_UNKNOWN (0x3FF) /* No interrupt from the sensor */ #define FP_ERROR_NO_IRQ (1 << 12) /* SPI communication error */ diff --git a/util/ectool.c b/util/ectool.c index 696ab4e834..19d5745b1f 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -1245,6 +1245,7 @@ int cmd_fp_info(int argc, char *argv[]) int cmdver = ec_cmd_version_supported(EC_CMD_FP_INFO, 1) ? 1 : 0; int rsize = cmdver == 1 ? sizeof(r) : sizeof(struct ec_response_fp_info_v0); + uint16_t dead; rv = ec_command(EC_CMD_FP_INFO, cmdver, NULL, 0, &r, rsize); if (rv < 0) @@ -1253,12 +1254,18 @@ int cmd_fp_info(int argc, char *argv[]) printf("Fingerprint sensor: vendor %x product %x model %x version %x\n", r.vendor_id, r.product_id, r.model_id, r.version); printf("Image: size %dx%d %d bpp\n", r.width, r.height, r.bpp); - printf("Error flags: %s%s%s%s\nDead pixels: %u\n", + printf("Error flags: %s%s%s%s\n", r.errors & FP_ERROR_NO_IRQ ? "NO_IRQ " : "", r.errors & FP_ERROR_SPI_COMM ? "SPI_COMM " : "", r.errors & FP_ERROR_BAD_HWID ? "BAD_HWID " : "", - r.errors & FP_ERROR_INIT_FAIL ? "INIT_FAIL " : "", - FP_ERROR_DEAD_PIXELS(r.errors)); + r.errors & FP_ERROR_INIT_FAIL ? "INIT_FAIL " : ""); + dead = FP_ERROR_DEAD_PIXELS(r.errors); + if (dead == FP_ERROR_DEAD_PIXELS_UNKNOWN) { + printf("Dead pixels: UNKNOWN\n"); + } else { + printf("Dead pixels: %u\n", dead); + } + if (cmdver == 1) { printf("Templates: size %d count %d/%d dirty bitmap %x\n", r.template_size, r.template_valid, r.template_max, -- cgit v1.2.1