diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2018-02-14 12:24:16 +0100 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-02-16 18:47:47 -0800 |
commit | 59c68a1d4bf82362062f5185214f7604c55b7efa (patch) | |
tree | 83ecb5c1ef2fceef3552bbff5431506eff4e8940 | |
parent | 074acb0cd7f35ae4d3058f5453fbb84cadf2082f (diff) | |
download | chrome-ec-59c68a1d4bf82362062f5185214f7604c55b7efa.tar.gz |
fpsensor: add quality test capture type
Add support for an additional finger image capture type
used for quality testing.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=b:72360575, b:71770455
TEST=On Meowth, run 'ectool --name=cros_fp fpmode capture qual'
then 'ectool --name=cros_fp fpframe raw > finger_mq.bin'
Change-Id: I1b9525dc2adf0b91aef2f7124803c90d6a3bb0ca
Reviewed-on: https://chromium-review.googlesource.com/924124
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Nicolas Norvez <norvez@chromium.org>
-rw-r--r-- | common/fpsensor.c | 10 | ||||
-rw-r--r-- | include/ec_commands.h | 2 | ||||
-rw-r--r-- | util/ectool.c | 35 |
3 files changed, 29 insertions, 18 deletions
diff --git a/common/fpsensor.c b/common/fpsensor.c index b1016e217d..bf342f3cce 100644 --- a/common/fpsensor.c +++ b/common/fpsensor.c @@ -67,6 +67,14 @@ static inline int is_test_capture(uint32_t mode) || capture_type == FP_CAPTURE_PATTERN1); } +static inline int is_raw_capture(uint32_t mode) +{ + int capture_type = FP_CAPTURE_TYPE(mode); + + return (capture_type == FP_CAPTURE_VENDOR_FORMAT + || capture_type == FP_CAPTURE_QUALITY_TEST); +} + static void send_mkbp_event(uint32_t event) { atomic_or(&fp_events, event); @@ -245,7 +253,7 @@ static int fp_command_frame(struct host_cmd_handler_args *args) void *out = args->response; uint32_t offset = params->offset; - if (FP_CAPTURE_TYPE(sensor_mode) != FP_CAPTURE_VENDOR_FORMAT) + if (!is_raw_capture(sensor_mode)) offset += FP_SENSOR_IMAGE_OFFSET; if (offset + params->size > sizeof(fp_buffer) || diff --git a/include/ec_commands.h b/include/ec_commands.h index 7a6f7648e6..1d8761be8b 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -4690,6 +4690,8 @@ struct __ec_align2 ec_params_fp_sensor_config { #define FP_CAPTURE_PATTERN0 2 /* Self test pattern (e.g. inverted checkerboard) */ #define FP_CAPTURE_PATTERN1 3 +/* Capture for Quality test with fixed contrast */ +#define FP_CAPTURE_QUALITY_TEST 4 /* Extracts the capture type from the sensor 'mode' word */ #define FP_CAPTURE_TYPE(mode) (((mode) >> FP_MODE_CAPTURE_TYPE_SHIFT) \ & FP_MODE_CAPTURE_TYPE_MASK) diff --git a/util/ectool.c b/util/ectool.c index 71fb90428f..15b904c23d 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -1083,7 +1083,7 @@ int cmd_rwsig_action(int argc, char *argv[]) return ec_command(EC_CMD_RWSIG_ACTION, 0, &req, sizeof(req), NULL, 0); } -static void *fp_download_frame(struct ec_response_fp_info *info) +static void *fp_download_frame(struct ec_response_fp_info *info, int all) { struct ec_params_fp_frame p; int rv = 0; @@ -1095,20 +1095,11 @@ static void *fp_download_frame(struct ec_response_fp_info *info) if (rv < 0) return NULL; - stride = (size_t)info->width * info->bpp/8; - if (stride > ec_max_insize) { - fprintf(stderr, "Not implemented for line size %zu B " - "(%u pixels) > EC transfer size %d\n", - stride, info->width, ec_max_insize); - return NULL; - } - if (info->bpp != 8) { - fprintf(stderr, "Not implemented for BPP = %d != 8\n", - info->bpp); - return NULL; - } + if (all) + size = info->frame_size; + else + size = (size_t)info->width * info->bpp/8 * info->height; - size = stride * info->height; buffer = malloc(size); if (!buffer) { fprintf(stderr, "Cannot allocate memory for the image\n"); @@ -1117,8 +1108,9 @@ static void *fp_download_frame(struct ec_response_fp_info *info) ptr = buffer; p.offset = 0; - p.size = stride; while (size) { + stride = MIN(ec_max_insize, size); + p.size = stride; rv = ec_command(EC_CMD_FP_FRAME, 0, &p, sizeof(p), ptr, stride); if (rv < 0) { @@ -1152,7 +1144,7 @@ static int fp_pattern_frame(int capt_type, const char *title, int inv) return -1; /* ensure the capture has happened without using event support */ usleep(200000); - pattern = fp_download_frame(&info); + pattern = fp_download_frame(&info, 0); if (!pattern) return -1; @@ -1247,6 +1239,8 @@ int cmd_fp_mode(int argc, char *argv[]) capture_type = FP_CAPTURE_PATTERN0; else if (!strncmp(argv[i], "pattern1", 8)) capture_type = FP_CAPTURE_PATTERN1; + else if (!strncmp(argv[i], "qual", 4)) + capture_type = FP_CAPTURE_QUALITY_TEST; } if (mode & FP_MODE_CAPTURE) mode |= capture_type << FP_MODE_CAPTURE_TYPE_SHIFT; @@ -1294,7 +1288,8 @@ int cmd_fp_info(int argc, char *argv[]) int cmd_fp_frame(int argc, char *argv[]) { struct ec_response_fp_info r; - void *buffer = fp_download_frame(&r); + int raw = (argc == 2 && !strcasecmp(argv[1], "raw")); + void *buffer = fp_download_frame(&r, raw); uint8_t *ptr = buffer; int x, y; @@ -1303,6 +1298,11 @@ int cmd_fp_frame(int argc, char *argv[]) return -1; } + if (raw) { + fwrite(buffer, r.frame_size, 1, stdout); + goto frame_done; + } + /* Print 8-bpp PGM ASCII header */ printf("P2\n%d %d\n%d\n", r.width, r.height, (1 << r.bpp) - 1); @@ -1312,6 +1312,7 @@ int cmd_fp_frame(int argc, char *argv[]) printf("\n"); } printf("# END OF FILE\n"); +frame_done: free(buffer); return 0; } |