diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-04-06 23:34:48 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-07 07:17:04 +0000 |
commit | 575d7686274bc97f3b7ddae2e3b5f4171290d6fd (patch) | |
tree | 05a58fb6dafa421c46a79597cdc32459f1959609 | |
parent | 7fba0e12ffa1d48c9f9f6da9d18125adc9aa75b4 (diff) | |
download | chrome-ec-575d7686274bc97f3b7ddae2e3b5f4171290d6fd.tar.gz |
Revert "fpsensor: Support building firmware that works for both sensors"
This reverts commit ac08c9d1dbc9f587df3ee6b15d58c0203f7e356e.
Reason for revert: Breaks public build
Original change's description:
> fpsensor: Support building firmware that works for both sensors
>
> This is a refactoring to allow building FPMCU firmware that works for
> one FPC sensor and one ELAN sensor.
>
> 1. When both drivers implement our common functions, e.g. fp_sensor_init(),
> rename them to fp_sensor_init_fpc() and fp_sensor_init_elan().
> 2. There are a few functions implemented not in FPC driver but in FPC
> private library, e.g. fp_sensor_finger_status(). I kept this as-is for
> FPC but renamed the one in ELAN driver to fp_sensor_finger_status_elan()
> 3. If building for ELAN, need to hardcode elan=1 in hatch_fp/board.c
> because the sensor type GPIO always says FPC.
>
> BRANCH=none
> BUG=b:175158241
> TEST=make run-fpsensor; make run-fpsensor_status;
> make run-fpsensor_crypto
> TEST=make -j BOARD=dartmonkey
> TEST=add CONFIG_FP_SENSOR_ELAN515 to board/hatch_fp/board.h;
> make -j BOARD=bloonchipper
> Firmware binary fully works on Dragonair (FPC) and Voema (ELAN)
> TEST=run device tests with http://crrev/c/2750547 and
> http://crrev/i/3654297 on Dragonclaw, all pass
>
> Change-Id: I789090dbdfe35ac6aefd6a629fa4c7bde89dc437
> Signed-off-by: Yicheng Li <yichengli@chromium.org>
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2727971
> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
> Commit-Queue: Tom Hughes <tomhughes@chromium.org>
Bug: b:175158241, b:184616069
Change-Id: I2a02a6eefc316e7e13aa188f1ae16672dce2babd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2809521
Auto-Submit: Tom Hughes <tomhughes@chromium.org>
Tested-by: Tom Hughes <tomhughes@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: caveh jalali <caveh@chromium.org>
-rw-r--r-- | board/hatch_fp/board_rw.c | 21 | ||||
-rw-r--r-- | board/nocturne_fp/board_rw.c | 4 | ||||
-rw-r--r-- | common/fpsensor/fpsensor.c | 109 | ||||
-rw-r--r-- | common/fpsensor/fpsensor_state.c | 18 | ||||
-rw-r--r-- | common/mock/fp_sensor_mock.c | 52 | ||||
-rw-r--r-- | driver/fingerprint/elan/elan_private.c | 55 | ||||
-rw-r--r-- | driver/fingerprint/elan/elan_sensor.h | 20 | ||||
-rw-r--r-- | driver/fingerprint/elan/elan_sensor_pal.c | 3 | ||||
-rw-r--r-- | driver/fingerprint/elan/elan_sensor_pal.h | 2 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc1025_private.h | 12 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc_private.c | 56 | ||||
-rw-r--r-- | driver/fingerprint/fpc/fpc_sensor.c | 2 | ||||
-rw-r--r-- | driver/fingerprint/fpc/libfp/fpc1145_private.h | 10 | ||||
-rw-r--r-- | driver/fingerprint/fpc/libfp/fpc_private.c | 50 | ||||
-rw-r--r-- | driver/fingerprint/fpsensor.h | 6 | ||||
-rw-r--r-- | fuzz/host_command_fuzz.c | 3 | ||||
-rw-r--r-- | include/fpsensor.h | 262 | ||||
-rw-r--r-- | include/fpsensor_elan.h | 129 | ||||
-rw-r--r-- | include/fpsensor_fpc.h | 129 | ||||
-rw-r--r-- | include/fpsensor_state.h | 39 | ||||
-rw-r--r-- | include/mock/fp_sensor_mock.h | 2 |
21 files changed, 257 insertions, 727 deletions
diff --git a/board/hatch_fp/board_rw.c b/board/hatch_fp/board_rw.c index a3dbcbf84f..40ab5092a7 100644 --- a/board/hatch_fp/board_rw.c +++ b/board/hatch_fp/board_rw.c @@ -5,10 +5,7 @@ #include "common.h" #include "console.h" -#include "fpsensor.h" #include "fpsensor_detect.h" -#include "fpsensor_elan.h" -#include "fpsensor_fpc.h" #include "gpio.h" #include "hooks.h" #include "registers.h" @@ -79,24 +76,6 @@ static void configure_fp_sensor_spi(void) void board_init_rw(void) { enum fp_transport_type ret_transport = get_fp_transport_type(); - enum fp_sensor_type sensor_type = get_fp_sensor_type(); - - if (sensor_type == FP_SENSOR_TYPE_ELAN) { - if (IS_ENABLED(CONFIG_FP_SENSOR_ELAN80) || - IS_ENABLED(CONFIG_FP_SENSOR_ELAN515)) { - fp_driver = &fp_driver_elan; - } - } else if (sensor_type == FP_SENSOR_TYPE_FPC) { - if (IS_ENABLED(CONFIG_FP_SENSOR_FPC1025) || - IS_ENABLED(CONFIG_FP_SENSOR_FPC1035) || - IS_ENABLED(CONFIG_FP_SENSOR_FPC1145)) { - fp_driver = &fp_driver_fpc; - } - } - - if (fp_driver == NULL) { - ccprints("Failed to get sensor type!"); - } if (ret_transport == FP_TRANSPORT_TYPE_UART) { /* diff --git a/board/nocturne_fp/board_rw.c b/board/nocturne_fp/board_rw.c index cafe972e8a..d0927f29ec 100644 --- a/board/nocturne_fp/board_rw.c +++ b/board/nocturne_fp/board_rw.c @@ -5,9 +5,7 @@ #include "common.h" #include "console.h" -#include "fpsensor.h" #include "fpsensor_detect.h" -#include "fpsensor_fpc.h" #include "gpio.h" #include "hooks.h" #include "registers.h" @@ -100,6 +98,4 @@ void board_init_rw(void) gpio_enable_interrupt(GPIO_PCH_SLP_S0_L); /* enable the SPI slave interface if the PCH is up */ hook_call_deferred(&ap_deferred_data, 0); - - fp_driver = &fp_driver_fpc; } diff --git a/common/fpsensor/fpsensor.c b/common/fpsensor/fpsensor.c index 7c032ddae8..08a456dc0e 100644 --- a/common/fpsensor/fpsensor.c +++ b/common/fpsensor/fpsensor.c @@ -51,9 +51,6 @@ static timestamp_t encryption_deadline; /* Delay between 2 s of the sensor to detect finger removal */ #define FINGER_POLLING_DELAY (100*MSEC) -/* Fp sensor driver interface. */ -struct fp_sensor_interface *fp_driver; - /* Timing statistics. */ static uint32_t capture_time_us; static uint32_t matching_time_us; @@ -112,17 +109,14 @@ static uint32_t fp_process_enroll(void) /* begin/continue enrollment */ CPRINTS("[%d]Enrolling ...", templ_valid); - res = fp_driver->fp_finger_enroll(fp_buffer, &percent); - + res = fp_finger_enroll(fp_buffer, &percent); CPRINTS("[%d]Enroll =>%d (%d%%)", templ_valid, res, percent); if (res < 0) return EC_MKBP_FP_ENROLL | EC_MKBP_FP_ERRCODE(EC_MKBP_FP_ERR_ENROLL_INTERNAL); templ_dirty |= BIT(templ_valid); if (percent == 100) { - res = fp_driver->fp_enrollment_finish( - fp_template + - templ_valid * fp_driver->algorithm_template_size); + res = fp_enrollment_finish(fp_template[templ_valid]); if (res) { res = EC_MKBP_FP_ERR_ENROLL_INTERNAL; } else { @@ -149,8 +143,8 @@ static uint32_t fp_process_match(void) fp_disable_positive_match_secret(&positive_match_secret_state); CPRINTS("Matching/%d ...", templ_valid); if (templ_valid) { - res = fp_driver->fp_finger_match(fp_template, templ_valid, - fp_buffer, &fgr, &updated); + res = fp_finger_match(fp_template[0], templ_valid, fp_buffer, + &fgr, &updated); CPRINTS("Match =>%d (finger %d)", res, fgr); if (res < 0 || fgr < 0 || fgr >= FP_MAX_FINGER_COUNT) { res = EC_MKBP_FP_ERR_MATCH_NO_INTERNAL; @@ -174,9 +168,8 @@ static uint32_t fp_process_match(void) static void fp_process_finger(void) { timestamp_t t0 = get_time(); - int res = fp_driver->fp_sensor_acquire_image_with_mode_( - fp_buffer, FP_CAPTURE_TYPE(sensor_mode)); - + int res = fp_sensor_acquire_image_with_mode(fp_buffer, + FP_CAPTURE_TYPE(sensor_mode)); capture_time_us = time_since32(t0); if (!res) { uint32_t evt = EC_MKBP_FP_IMAGE_READY; @@ -217,7 +210,7 @@ void fp_task(void) #ifdef HAVE_FP_PRIVATE_DRIVER /* Reset and initialize the sensor IC */ - fp_driver->fp_sensor_init(); + fp_sensor_init(); while (1) { uint32_t evt; @@ -232,29 +225,28 @@ void fp_task(void) gpio_disable_interrupt(GPIO_FPS_INT); if ((mode ^ enroll_session) & FP_MODE_ENROLL_SESSION) { if (mode & FP_MODE_ENROLL_SESSION) { - if (fp_driver->fp_enrollment_begin()) + if (fp_enrollment_begin()) sensor_mode &= ~FP_MODE_ENROLL_SESSION; } else { - fp_driver->fp_enrollment_finish(NULL); + fp_enrollment_finish(NULL); } enroll_session = sensor_mode & FP_MODE_ENROLL_SESSION; } if (is_test_capture(mode)) { - fp_driver->fp_sensor_acquire_image_with_mode_( - fp_buffer, FP_CAPTURE_TYPE(mode)); + fp_sensor_acquire_image_with_mode(fp_buffer, + FP_CAPTURE_TYPE(mode)); sensor_mode &= ~FP_MODE_CAPTURE; send_mkbp_event(EC_MKBP_FP_IMAGE_READY); continue; } else if (sensor_mode & FP_MODE_ANY_DETECT_FINGER) { /* wait for a finger on the sensor */ - fp_driver->fp_sensor_configure_detect_(); + fp_sensor_configure_detect(); } - if (sensor_mode & FP_MODE_DEEPSLEEP) { + if (sensor_mode & FP_MODE_DEEPSLEEP) /* Shutdown the sensor */ - fp_driver->fp_sensor_low_power(); - } + fp_sensor_low_power(); if (sensor_mode & FP_MODE_FINGER_UP) /* Poll the sensor to detect finger removal */ timeout_us = FINGER_POLLING_DELAY; @@ -266,17 +258,17 @@ void fp_task(void) fp_reset_and_clear_context(); sensor_mode &= ~FP_MODE_RESET_SENSOR; } else if (mode & FP_MODE_SENSOR_MAINTENANCE) { - fp_driver->fp_maintenance(); + fp_maintenance(); sensor_mode &= ~FP_MODE_SENSOR_MAINTENANCE; } else { - fp_driver->fp_sensor_low_power(); + fp_sensor_low_power(); } } else if (evt & (TASK_EVENT_SENSOR_IRQ | TASK_EVENT_TIMER)) { overall_t0 = get_time(); timestamps_invalid = 0; gpio_disable_interrupt(GPIO_FPS_INT); if (sensor_mode & FP_MODE_ANY_DETECT_FINGER) { - st = fp_driver->fp_sensor_finger_status_(); + st = fp_sensor_finger_status(); if (st == FINGER_PRESENT && sensor_mode & FP_MODE_FINGER_DOWN) { CPRINTS("Finger!"); @@ -296,10 +288,10 @@ void fp_task(void) fp_process_finger(); if (sensor_mode & FP_MODE_ANY_WAIT_IRQ) { - fp_driver->fp_sensor_configure_detect_(); + fp_sensor_configure_detect(); gpio_enable_interrupt(GPIO_FPS_INT); } else { - fp_driver->fp_sensor_low_power(); + fp_sensor_low_power(); } } } @@ -349,11 +341,11 @@ static enum ec_status fp_command_info(struct host_cmd_handler_args *args) struct ec_response_fp_info *r = args->response; #ifdef HAVE_FP_PRIVATE_DRIVER - if (fp_driver->fp_sensor_get_info(r) < 0) + if (fp_sensor_get_info(r) < 0) #endif return EC_RES_UNAVAILABLE; - r->template_size = fp_driver->encrypted_template_size; + r->template_size = FP_ALGORITHM_ENCRYPTED_TEMPLATE_SIZE; r->template_max = FP_MAX_FINGER_COUNT; r->template_valid = templ_valid; r->template_dirty = templ_dirty; @@ -405,12 +397,8 @@ static enum ec_status fp_command_frame(struct host_cmd_handler_args *args) if (!is_raw_capture(sensor_mode)) offset += FP_SENSOR_IMAGE_OFFSET; - /* - * Check the requested data is within the template size. - * This is stricter than checking buffer overflow. - */ - ret = validate_fp_buffer_offset( - fp_driver->algorithm_template_size, offset, size); + ret = validate_fp_buffer_offset(sizeof(fp_buffer), offset, + size); if (ret != EC_SUCCESS) return EC_RES_INVALID_PARAM; @@ -428,12 +416,7 @@ static enum ec_status fp_command_frame(struct host_cmd_handler_args *args) return EC_RES_INVALID_PARAM; if (fgr >= templ_valid) return EC_RES_UNAVAILABLE; - /* - * Check the requested data is within the encrypted template size. - * This is stricter than checking buffer overflow. - */ - ret = validate_fp_buffer_offset(fp_driver->encrypted_template_size, - offset, size); + ret = validate_fp_buffer_offset(sizeof(fp_enc_buffer), offset, size); if (ret != EC_SUCCESS) return EC_RES_INVALID_PARAM; @@ -444,10 +427,9 @@ static enum ec_status fp_command_frame(struct host_cmd_handler_args *args) uint8_t *encrypted_template = fp_enc_buffer + sizeof(*enc_info); /* Positive match salt is after the template. */ uint8_t *positive_match_salt = - encrypted_template + fp_driver->algorithm_template_size; - size_t encrypted_blob_size = - fp_driver->algorithm_template_size + - sizeof(fp_positive_match_salt[0]); + encrypted_template + sizeof(fp_template[0]); + size_t encrypted_blob_size = sizeof(fp_template[0]) + + sizeof(fp_positive_match_salt[0]); /* b/114160734: Not more than 1 encrypted message per second. */ if (!timestamp_expired(encryption_deadline, &now)) @@ -490,9 +472,8 @@ static enum ec_status fp_command_frame(struct host_cmd_handler_args *args) * Copy the payload to |fp_enc_buffer| where it will be * encrypted in-place. */ - memcpy(encrypted_template, - fp_template + fgr * fp_driver->algorithm_template_size, - fp_driver->algorithm_template_size); + memcpy(encrypted_template, fp_template[fgr], + sizeof(fp_template[0])); memcpy(positive_match_salt, fp_positive_match_salt[fgr], sizeof(fp_positive_match_salt[0])); @@ -576,12 +557,7 @@ static enum ec_status fp_command_template(struct host_cmd_handler_args *args) if (args->params_size != size + offsetof(struct ec_params_fp_template, data)) return EC_RES_INVALID_PARAM; - /* - * Check the received data fits within the encrypted template size. - * This is stricter than checking buffer overflow. - */ - ret = validate_fp_buffer_offset(fp_driver->encrypted_template_size, - offset, size); + ret = validate_fp_buffer_offset(sizeof(fp_enc_buffer), offset, size); if (ret != EC_SUCCESS) return EC_RES_INVALID_PARAM; @@ -592,7 +568,7 @@ static enum ec_status fp_command_template(struct host_cmd_handler_args *args) uint8_t *encrypted_template = fp_enc_buffer + sizeof(*enc_info); /* Positive match salt is after the template. */ uint8_t *positive_match_salt = - encrypted_template + fp_driver->algorithm_template_size; + encrypted_template + sizeof(fp_template[0]); size_t encrypted_blob_size; /* @@ -612,11 +588,10 @@ static enum ec_status fp_command_template(struct host_cmd_handler_args *args) } if (enc_info->struct_version <= 3) { - encrypted_blob_size = - fp_driver->algorithm_template_size; + encrypted_blob_size = sizeof(fp_template[0]); } else { encrypted_blob_size = - fp_driver->algorithm_template_size + + sizeof(fp_template[0]) + sizeof(fp_positive_match_salt[0]); } @@ -639,8 +614,8 @@ static enum ec_status fp_command_template(struct host_cmd_handler_args *args) fp_clear_finger_context(idx); return EC_RES_UNAVAILABLE; } - memcpy(fp_template + idx * fp_driver->algorithm_template_size, - encrypted_template, fp_driver->algorithm_template_size); + memcpy(fp_template[idx], encrypted_template, + sizeof(fp_template[0])); if (template_needs_validation_value(enc_info)) { CPRINTS("fgr%d: Generating positive match salt.", idx); init_trng(); @@ -651,10 +626,8 @@ static enum ec_status fp_command_template(struct host_cmd_handler_args *args) if (bytes_are_trivial(positive_match_salt, sizeof(fp_positive_match_salt[0]))) { CPRINTS("fgr%d: Trivial positive match salt.", idx); - always_memset( - fp_template + - idx * fp_driver->algorithm_template_size, - 0, fp_driver->algorithm_template_size); + always_memset(fp_template[idx], 0, + sizeof(fp_template[0])); return EC_RES_INVALID_PARAM; } memcpy(fp_positive_match_salt[idx], positive_match_salt, @@ -717,11 +690,11 @@ static void upload_pgm_image(uint8_t *frame) CPRINTF("#IGNORE for ZModem\r**\030B00"); msleep(2000); /* let the download program start */ /* Print 8-bpp PGM ASCII header */ - CPRINTF("P2\n%d %d\n255\n", fp_driver->res_x, fp_driver->res_y); + CPRINTF("P2\n%d %d\n255\n", FP_SENSOR_RES_X, FP_SENSOR_RES_Y); - for (y = 0; y < fp_driver->res_y; y++) { + for (y = 0; y < FP_SENSOR_RES_Y; y++) { watchdog_reload(); - for (x = 0; x < fp_driver->res_x; x++, ptr++) + for (x = 0; x < FP_SENSOR_RES_X; x++, ptr++) CPRINTF("%d ", *ptr); CPRINTF("\n"); cflush(); @@ -873,7 +846,7 @@ DECLARE_CONSOLE_COMMAND(fpclear, command_fpclear, NULL, int command_fpmaintenance(int argc, char **argv) { #ifdef HAVE_FP_PRIVATE_DRIVER - return fp_driver->fp_maintenance(); + return fp_maintenance(); #else return EC_SUCCESS; #endif /* #ifdef HAVE_FP_PRIVATE_DRIVER */ diff --git a/common/fpsensor/fpsensor_state.c b/common/fpsensor/fpsensor_state.c index 2d59670c60..db64110b56 100644 --- a/common/fpsensor/fpsensor_state.c +++ b/common/fpsensor/fpsensor_state.c @@ -16,19 +16,18 @@ #include "util.h" /* Last acquired frame (aligned as it is used by arbitrary binary libraries) */ -uint8_t fp_buffer[FP_SENSOR_IMAGE_MAX_SIZE] FP_FRAME_SECTION __aligned(4); +uint8_t fp_buffer[FP_SENSOR_IMAGE_SIZE] FP_FRAME_SECTION __aligned(4); /* Fingers templates for the current user */ -uint8_t fp_template[FP_ALGORITHM_TEMPLATE_MAX_SIZE * - FP_MAX_FINGER_COUNT] FP_TEMPLATE_SECTION; +uint8_t fp_template[FP_MAX_FINGER_COUNT][FP_ALGORITHM_TEMPLATE_SIZE] + FP_TEMPLATE_SECTION; /* Encryption/decryption buffer */ /* TODO: On-the-fly encryption/decryption without a dedicated buffer */ /* * Store the encryption metadata at the beginning of the buffer containing the * ciphered data. */ -uint8_t fp_enc_buffer - [FP_ALGORITHM_ENCRYPTED_TEMPLATE_MAX_SIZE] FP_TEMPLATE_SECTION; - +uint8_t fp_enc_buffer[FP_ALGORITHM_ENCRYPTED_TEMPLATE_SIZE] + FP_TEMPLATE_SECTION; /* Salt used in derivation of positive match secret. */ uint8_t fp_positive_match_salt [FP_MAX_FINGER_COUNT][FP_POSITIVE_MATCH_SALT_BYTES]; @@ -66,8 +65,7 @@ void fp_task_simulate(void) void fp_clear_finger_context(int idx) { - always_memset(fp_template + idx * fp_driver->algorithm_template_size, 0, - fp_driver->algorithm_template_size); + always_memset(fp_template[idx], 0, sizeof(fp_template[0])); always_memset(fp_positive_match_salt[idx], 0, sizeof(fp_positive_match_salt[0])); } @@ -93,10 +91,10 @@ static void _fp_clear_context(void) void fp_reset_and_clear_context(void) { - if (fp_driver->fp_sensor_deinit() != EC_SUCCESS) + if (fp_sensor_deinit() != EC_SUCCESS) CPRINTS("Failed to deinit sensor"); _fp_clear_context(); - if (fp_driver->fp_sensor_init() != EC_SUCCESS) + if (fp_sensor_init() != EC_SUCCESS) CPRINTS("Failed to init sensor"); } diff --git a/common/mock/fp_sensor_mock.c b/common/mock/fp_sensor_mock.c index f8da209aa7..363f092ff1 100644 --- a/common/mock/fp_sensor_mock.c +++ b/common/mock/fp_sensor_mock.c @@ -20,90 +20,68 @@ struct mock_ctrl_fp_sensor mock_ctrl_fp_sensor = MOCK_CTRL_DEFAULT_FP_SENSOR; -int fp_sensor_init_mock(void) +int fp_sensor_init(void) { return mock_ctrl_fp_sensor.fp_sensor_init_return; } -int fp_sensor_deinit_mock(void) +int fp_sensor_deinit(void) { return mock_ctrl_fp_sensor.fp_sensor_deinit_return; } -int fp_sensor_get_info_mock(struct ec_response_fp_info *resp) +int fp_sensor_get_info(struct ec_response_fp_info *resp) { resp->version = 0; return mock_ctrl_fp_sensor.fp_sensor_get_info_return; } -void fp_sensor_low_power_mock(void) +void fp_sensor_low_power(void) { } -void fp_sensor_configure_detect_mock(void) +void fp_sensor_configure_detect(void) { } -enum finger_state fp_sensor_finger_status_mock(void) +enum finger_state fp_sensor_finger_status(void) { return mock_ctrl_fp_sensor.fp_sensor_finger_status_return; } -int fp_sensor_acquire_image_mock(uint8_t *image_data) +int fp_sensor_acquire_image(uint8_t *image_data) { return mock_ctrl_fp_sensor.fp_sensor_acquire_image_return; } -int fp_sensor_acquire_image_with_mode_mock(uint8_t *image_data, int mode) +int fp_sensor_acquire_image_with_mode(uint8_t *image_data, int mode) { return mock_ctrl_fp_sensor.fp_sensor_acquire_image_with_mode_return; } -int fp_finger_match_mock(void *templ, uint32_t templ_count, uint8_t *image, - int32_t *match_index, uint32_t *update_bitmap) +int fp_finger_match(void *templ, uint32_t templ_count, + uint8_t *image, int32_t *match_index, + uint32_t *update_bitmap) { return mock_ctrl_fp_sensor.fp_finger_match_return; } -int fp_enrollment_begin_mock(void) +int fp_enrollment_begin(void) { return mock_ctrl_fp_sensor.fp_enrollment_begin_return; } -int fp_enrollment_finish_mock(void *templ) +int fp_enrollment_finish(void *templ) { return mock_ctrl_fp_sensor.fp_enrollment_finish_return; } -int fp_finger_enroll_mock(uint8_t *image, int *completion) +int fp_finger_enroll(uint8_t *image, int *completion) { return mock_ctrl_fp_sensor.fp_finger_enroll_return; } -int fp_maintenance_mock(void) +int fp_maintenance(void) { return mock_ctrl_fp_sensor.fp_maintenance_return; } - -struct fp_sensor_interface fp_driver_mock = { - .sensor_type = FP_SENSOR_TYPE_UNKNOWN, - .fp_sensor_init = &fp_sensor_init_mock, - .fp_sensor_deinit = &fp_sensor_deinit_mock, - .fp_sensor_get_info = &fp_sensor_get_info_mock, - .fp_sensor_low_power = &fp_sensor_low_power_mock, - .fp_sensor_configure_detect_ = &fp_sensor_configure_detect_mock, - .fp_sensor_finger_status_ = &fp_sensor_finger_status_mock, - .fp_sensor_acquire_image_with_mode_ = - &fp_sensor_acquire_image_with_mode_mock, - .fp_finger_enroll = &fp_finger_enroll_mock, - .fp_finger_match = &fp_finger_match_mock, - .fp_enrollment_begin = &fp_enrollment_begin_mock, - .fp_enrollment_finish = &fp_enrollment_finish_mock, - .fp_maintenance = &fp_maintenance_mock, - .algorithm_template_size = 0, - .encrypted_template_size = - FP_POSITIVE_MATCH_SALT_BYTES + - sizeof(struct ec_fp_template_encryption_metadata), - .res_x = 0, - .res_y = 0 -}; diff --git a/driver/fingerprint/elan/elan_private.c b/driver/fingerprint/elan/elan_private.c index bb6fad4972..555ad14ba0 100644 --- a/driver/fingerprint/elan/elan_private.c +++ b/driver/fingerprint/elan/elan_private.c @@ -34,17 +34,17 @@ static struct ec_response_fp_info ec_fp_sensor_info = { .model_id = MID, .version = VERSION, /* Image frame characteristics */ - .frame_size = FP_SENSOR_RES_X_ELAN * FP_SENSOR_RES_Y_ELAN, + .frame_size = FP_SENSOR_RES_X * FP_SENSOR_RES_Y, .pixel_format = V4L2_PIX_FMT_GREY, - .width = FP_SENSOR_RES_X_ELAN, - .height = FP_SENSOR_RES_Y_ELAN, + .width = FP_SENSOR_RES_X, + .height = FP_SENSOR_RES_Y, .bpp = FP_SENSOR_RES_BPP, }; /** * set fingerprint sensor into power saving mode */ -void fp_sensor_low_power_elan(void) +void fp_sensor_low_power(void) { elan_woe_mode(); } @@ -52,7 +52,7 @@ void fp_sensor_low_power_elan(void) /** * Reset and initialize the sensor IC */ -int fp_sensor_init_elan(void) +int fp_sensor_init(void) { CPRINTF("========%s=======\n", __func__); @@ -70,7 +70,7 @@ int fp_sensor_init_elan(void) /** * Deinitialize the sensor IC */ -int fp_sensor_deinit_elan(void) +int fp_sensor_deinit(void) { CPRINTF("========%s=======\n", __func__); return elan_fp_deinit(); @@ -83,7 +83,7 @@ int fp_sensor_deinit_elan(void) * * @return EC_SUCCESS on success otherwise error. */ -int fp_sensor_get_info_elan(struct ec_response_fp_info *resp) +int fp_sensor_get_info(struct ec_response_fp_info *resp) { int ret = 0; @@ -119,8 +119,8 @@ int fp_sensor_get_info_elan(struct ec_response_fp_info *resp) * - EC_MKBP_FP_ERR_MATCH_LOW_COVERAGE when matching could not be performed * due to finger covering too little area of the sensor */ -int fp_finger_match_elan(void *templ, uint32_t templ_count, uint8_t *image, - int32_t *match_index, uint32_t *update_bitmap) +int fp_finger_match(void *templ, uint32_t templ_count, uint8_t *image, + int32_t *match_index, uint32_t *update_bitmap) { CPRINTF("========%s=======\n", __func__); return elan_match(templ, templ_count, image, match_index, @@ -133,7 +133,7 @@ int fp_finger_match_elan(void *templ, uint32_t templ_count, uint8_t *image, * @return 0 on success. * */ -int fp_enrollment_begin_elan(void) +int fp_enrollment_begin(void) { CPRINTF("========%s=======\n", __func__); return elan_enrollment_begin(); @@ -149,7 +149,7 @@ int fp_enrollment_begin_elan(void) * * @return 0 on success or a negative error code. */ -int fp_enrollment_finish_elan(void *templ) +int fp_enrollment_finish(void *templ) { CPRINTF("========%s=======\n", __func__); return elan_enrollment_finish(templ); @@ -170,7 +170,7 @@ int fp_enrollment_finish_elan(void *templ) * - EC_MKBP_FP_ERR_ENROLL_LOW_COVERAGE when image could not be used due to * finger covering too little area of the sensor */ -int fp_finger_enroll_elan(uint8_t *image, int *completion) +int fp_finger_enroll(uint8_t *image, int *completion) { CPRINTF("========%s=======\n", __func__); return elan_enroll(image, completion); @@ -182,7 +182,7 @@ int fp_finger_enroll_elan(uint8_t *image, int *completion) * fp_sensor_configure_detect needs to be called to restore finger detection * functionality. */ -void fp_sensor_configure_detect_elan(void) +void fp_sensor_configure_detect(void) { CPRINTF("========%s=======\n", __func__); elan_woe_mode(); @@ -211,7 +211,7 @@ void fp_sensor_configure_detect_elan(void) * - FP_SENSOR_TOO_FAST on finger removed before image was captured * - FP_SENSOR_LOW_SENSOR_COVERAGE on sensor not fully covered by finger */ -int fp_sensor_acquire_image_with_mode_elan(uint8_t *image_data, int mode) +int fp_sensor_acquire_image_with_mode(uint8_t *image_data, int mode) { CPRINTF("========%s=======\n", __func__); return elan_sensor_acquire_image_with_mode(image_data, mode); @@ -225,7 +225,7 @@ int fp_sensor_acquire_image_with_mode_elan(uint8_t *image_data, int mode) * - FINGER_PARTIAL * - FINGER_PRESENT */ -enum finger_state fp_sensor_finger_status_elan(void) +enum finger_state fp_sensor_finger_status(void) { CPRINTF("========%s=======\n", __func__); return elan_sensor_finger_status(); @@ -240,31 +240,8 @@ enum finger_state fp_sensor_finger_status_elan(void) * @return EC_ERROR_HW_INTERNAL on error (such as finger on sensor) * @return EC_SUCCESS on success */ -int fp_maintenance_elan(void) +int fp_maintenance(void) { CPRINTF("========%s=======\n", __func__); return elan_fp_maintenance(&errors); } - -struct fp_sensor_interface fp_driver_elan = { - .sensor_type = FP_SENSOR_TYPE_ELAN, - .fp_sensor_init = &fp_sensor_init_elan, - .fp_sensor_deinit = &fp_sensor_deinit_elan, - .fp_sensor_get_info = &fp_sensor_get_info_elan, - .fp_sensor_low_power = &fp_sensor_low_power_elan, - .fp_sensor_configure_detect_ = &fp_sensor_configure_detect_elan, - .fp_sensor_finger_status_ = &fp_sensor_finger_status_elan, - .fp_sensor_acquire_image_with_mode_ = - &fp_sensor_acquire_image_with_mode_elan, - .fp_finger_enroll = &fp_finger_enroll_elan, - .fp_finger_match = &fp_finger_match_elan, - .fp_enrollment_begin = &fp_enrollment_begin_elan, - .fp_enrollment_finish = &fp_enrollment_finish_elan, - .fp_maintenance = &fp_maintenance_elan, - .algorithm_template_size = FP_ALGORITHM_TEMPLATE_SIZE_ELAN, - .encrypted_template_size = - FP_ALGORITHM_TEMPLATE_SIZE_ELAN + FP_POSITIVE_MATCH_SALT_BYTES + - sizeof(struct ec_fp_template_encryption_metadata), - .res_x = FP_SENSOR_RES_X_ELAN, - .res_y = FP_SENSOR_RES_Y_ELAN -}; diff --git a/driver/fingerprint/elan/elan_sensor.h b/driver/fingerprint/elan/elan_sensor.h index 7b6134817a..490b1acf16 100644 --- a/driver/fingerprint/elan/elan_sensor.h +++ b/driver/fingerprint/elan/elan_sensor.h @@ -9,23 +9,23 @@ /* Sensor pixel resolution */ #if defined(CONFIG_FP_SENSOR_ELAN80) -#define FP_SENSOR_IMAGE_SIZE_ELAN (80 * 80) -#define FP_SENSOR_RES_X_ELAN 80 -#define FP_SENSOR_RES_Y_ELAN 80 +#define FP_SENSOR_IMAGE_SIZE (80 * 80) +#define FP_SENSOR_RES_X 80 +#define FP_SENSOR_RES_Y 80 #if defined(CHIP_FAMILY_STM32F4) -#define FP_ALGORITHM_TEMPLATE_SIZE_ELAN 15000 +#define FP_ALGORITHM_TEMPLATE_SIZE 15000 #elif defined(CHIP_FAMILY_STM32H7) -#define FP_ALGORITHM_TEMPLATE_SIZE_ELAN 40960 +#define FP_ALGORITHM_TEMPLATE_SIZE 40960 #endif #define FP_MAX_FINGER_COUNT 3 #elif defined(CONFIG_FP_SENSOR_ELAN515) -#define FP_SENSOR_IMAGE_SIZE_ELAN (52 * 150) -#define FP_SENSOR_RES_X_ELAN 52 -#define FP_SENSOR_RES_Y_ELAN 150 +#define FP_SENSOR_IMAGE_SIZE (52 * 150) +#define FP_SENSOR_RES_X 52 +#define FP_SENSOR_RES_Y 150 #if defined(CHIP_FAMILY_STM32F4) -#define FP_ALGORITHM_TEMPLATE_SIZE_ELAN 15000 +#define FP_ALGORITHM_TEMPLATE_SIZE 15000 #elif defined(CHIP_FAMILY_STM32H7) -#define FP_ALGORITHM_TEMPLATE_SIZE_ELAN 67000 +#define FP_ALGORITHM_TEMPLATE_SIZE 67000 #endif #define FP_MAX_FINGER_COUNT 3 #endif diff --git a/driver/fingerprint/elan/elan_sensor_pal.c b/driver/fingerprint/elan/elan_sensor_pal.c index a185e655c4..b59368b835 100644 --- a/driver/fingerprint/elan/elan_sensor_pal.c +++ b/driver/fingerprint/elan/elan_sensor_pal.c @@ -225,8 +225,7 @@ int elan_fp_maintenance(uint16_t *error_state) *error_state &= 0xFC00; sensor_info.num_defective_pixels = 0; sensor_info.sensor_error_code = 0; - /* TODO(b/184289118): Rename to fp_sensor_maintenance_elan. */ - rv = elan_fp_sensor_maintenance(&sensor_info); + rv = fp_sensor_maintenance(&sensor_info); LOGE_SA("Maintenance took %d ms", time_since32(start) / MSEC); if (rv != 0) { diff --git a/driver/fingerprint/elan/elan_sensor_pal.h b/driver/fingerprint/elan/elan_sensor_pal.h index d47dd3bee0..067b693245 100644 --- a/driver/fingerprint/elan/elan_sensor_pal.h +++ b/driver/fingerprint/elan/elan_sensor_pal.h @@ -126,7 +126,7 @@ void elan_execute_reset(void); * @return 0 on success. * negative value on error. */ -int elan_fp_sensor_maintenance(fp_sensor_info_t *fp_sensor_info); +int fp_sensor_maintenance(fp_sensor_info_t *fp_sensor_info); /** * @brief Set sensor reset state. diff --git a/driver/fingerprint/fpc/bep/fpc1025_private.h b/driver/fingerprint/fpc/bep/fpc1025_private.h index 42dc44130c..2da127741f 100644 --- a/driver/fingerprint/fpc/bep/fpc1025_private.h +++ b/driver/fingerprint/fpc/bep/fpc1025_private.h @@ -13,8 +13,8 @@ #define FP_SENSOR_NAME "FPC1025" /* Sensor pixel resolution */ -#define FP_SENSOR_RES_X_FPC (160) /**< Sensor width */ -#define FP_SENSOR_RES_Y_FPC (160) /**< Sensor height */ +#define FP_SENSOR_RES_X (160) /**< Sensor width */ +#define FP_SENSOR_RES_Y (160) /**< Sensor height */ #define FP_SENSOR_RES_BPP (8) /**< Resolution bits per pixel */ /* @@ -22,8 +22,8 @@ * * Value from fpc_bep_image_get_buffer_size(): (160*160)+660 */ -#define FP_SENSOR_IMAGE_SIZE_FPC (26260) -#define FP_SENSOR_REAL_IMAGE_SIZE (FP_SENSOR_RES_X_FPC * FP_SENSOR_RES_Y_FPC) +#define FP_SENSOR_IMAGE_SIZE (26260) +#define FP_SENSOR_REAL_IMAGE_SIZE (FP_SENSOR_RES_X * FP_SENSOR_RES_Y) /* Offset of image data in fp_buffer */ #define FP_SENSOR_IMAGE_OFFSET (400) @@ -41,11 +41,9 @@ * * Template size + alignment padding + size of template size variable */ -#define FP_ALGORITHM_TEMPLATE_SIZE_FPC (5088 + 0 + 4) +#define FP_ALGORITHM_TEMPLATE_SIZE (5088 + 0 + 4) /* Max number of templates stored / matched against */ -#ifndef FP_MAX_FINGER_COUNT #define FP_MAX_FINGER_COUNT (5) -#endif #endif /* __CROS_EC_FPC1025_PRIVATE_H */ diff --git a/driver/fingerprint/fpc/bep/fpc_private.c b/driver/fingerprint/fpc/bep/fpc_private.c index 7df21c223c..36ca0fe1b9 100644 --- a/driver/fingerprint/fpc/bep/fpc_private.c +++ b/driver/fingerprint/fpc/bep/fpc_private.c @@ -8,7 +8,6 @@ #include "fpc_bio_algorithm.h" #include "fpsensor.h" -#include "fpsensor_fpc.h" #include "gpio.h" #include "spi.h" #include "system.h" @@ -43,10 +42,10 @@ static struct ec_response_fp_info ec_fp_sensor_info = { .model_id = 1, .version = 1, /* Image frame characteristics */ - .frame_size = FP_SENSOR_IMAGE_SIZE_FPC, + .frame_size = FP_SENSOR_IMAGE_SIZE, .pixel_format = V4L2_PIX_FMT_GREY, - .width = FP_SENSOR_RES_X_FPC, - .height = FP_SENSOR_RES_Y_FPC, + .width = FP_SENSOR_RES_X, + .height = FP_SENSOR_RES_Y, .bpp = FP_SENSOR_RES_BPP, }; @@ -64,12 +63,12 @@ extern const fpc_bep_algorithm_t fpc_bep_algorithm_pfe_1025; const fpc_sensor_info_t fpc_sensor_info = { .sensor = &fpc_bep_sensor_1025, - .image_buffer_size = FP_SENSOR_IMAGE_SIZE_FPC, + .image_buffer_size = FP_SENSOR_IMAGE_SIZE, }; const fpc_bio_info_t fpc_bio_info = { .algorithm = &fpc_bep_algorithm_pfe_1025, - .template_size = FP_ALGORITHM_TEMPLATE_SIZE_FPC, + .template_size = FP_ALGORITHM_TEMPLATE_SIZE, }; #elif defined(CONFIG_FP_SENSOR_FPC1035) @@ -110,7 +109,7 @@ static int fpc_send_cmd(const uint8_t cmd) SPI_READBACK_ALL); } -void fp_sensor_low_power_fpc(void) +void fp_sensor_low_power(void) { fpc_send_cmd(FPC_CMD_DEEPSLEEP); } @@ -140,7 +139,7 @@ static int fpc_check_hwid(void) } /* Reset and initialize the sensor IC */ -int fp_sensor_init_fpc(void) +int fp_sensor_init(void) { int rc; @@ -173,13 +172,13 @@ int fp_sensor_init_fpc(void) } /* Go back to low power */ - fp_sensor_low_power_fpc(); + fp_sensor_low_power(); return EC_SUCCESS; } /* Deinitialize the sensor IC */ -int fp_sensor_deinit_fpc(void) +int fp_sensor_deinit(void) { int rc; @@ -194,7 +193,7 @@ int fp_sensor_deinit_fpc(void) return rc; } -int fp_sensor_get_info_fpc(struct ec_response_fp_info *resp) +int fp_sensor_get_info(struct ec_response_fp_info *resp) { int rc; @@ -213,8 +212,8 @@ int fp_sensor_get_info_fpc(struct ec_response_fp_info *resp) return EC_SUCCESS; } -int fp_finger_match_fpc(void *templ, uint32_t templ_count, uint8_t *image, - int32_t *match_index, uint32_t *update_bitmap) +int fp_finger_match(void *templ, uint32_t templ_count, uint8_t *image, + int32_t *match_index, uint32_t *update_bitmap) { int rc; @@ -227,7 +226,7 @@ int fp_finger_match_fpc(void *templ, uint32_t templ_count, uint8_t *image, return rc; } -int fp_enrollment_begin_fpc(void) +int fp_enrollment_begin(void) { int rc; bio_enrollment_t bio_enroll = enroll_ctx; @@ -239,7 +238,7 @@ int fp_enrollment_begin_fpc(void) return rc; } -int fp_enrollment_finish_fpc(void *templ) +int fp_enrollment_finish(void *templ) { int rc; bio_enrollment_t bio_enroll = enroll_ctx; @@ -252,7 +251,7 @@ int fp_enrollment_finish_fpc(void *templ) return rc; } -int fp_finger_enroll_fpc(uint8_t *image, int *completion) +int fp_finger_enroll(uint8_t *image, int *completion) { int rc; bio_enrollment_t bio_enroll = enroll_ctx; @@ -269,30 +268,7 @@ int fp_finger_enroll_fpc(uint8_t *image, int *completion) return rc; } -int fp_maintenance_fpc(void) +int fp_maintenance(void) { return fpc_fp_maintenance(&errors); } - -struct fp_sensor_interface fp_driver_fpc = { - .sensor_type = FP_SENSOR_TYPE_FPC, - .fp_sensor_init = &fp_sensor_init_fpc, - .fp_sensor_deinit = &fp_sensor_deinit_fpc, - .fp_sensor_get_info = &fp_sensor_get_info_fpc, - .fp_sensor_low_power = &fp_sensor_low_power_fpc, - .fp_sensor_configure_detect_ = &fp_sensor_configure_detect, - .fp_sensor_finger_status_ = &fp_sensor_finger_status, - .fp_sensor_acquire_image_with_mode_ = - &fp_sensor_acquire_image_with_mode, - .fp_finger_enroll = &fp_finger_enroll_fpc, - .fp_finger_match = &fp_finger_match_fpc, - .fp_enrollment_begin = &fp_enrollment_begin_fpc, - .fp_enrollment_finish = &fp_enrollment_finish_fpc, - .fp_maintenance = &fp_maintenance_fpc, - .algorithm_template_size = FP_ALGORITHM_TEMPLATE_SIZE_FPC, - .encrypted_template_size = - FP_ALGORITHM_TEMPLATE_SIZE_FPC + FP_POSITIVE_MATCH_SALT_BYTES + - sizeof(struct ec_fp_template_encryption_metadata), - .res_x = FP_SENSOR_RES_X_FPC, - .res_y = FP_SENSOR_RES_Y_FPC -}; diff --git a/driver/fingerprint/fpc/fpc_sensor.c b/driver/fingerprint/fpc/fpc_sensor.c index 9184492382..a15502521f 100644 --- a/driver/fingerprint/fpc/fpc_sensor.c +++ b/driver/fingerprint/fpc/fpc_sensor.c @@ -33,7 +33,7 @@ int fpc_fp_maintenance(uint16_t *error_state) if (error_state == NULL) return EC_ERROR_INVAL; - rv = fp_sensor_maintenance((uint8_t *)&fp_buffer, &sensor_info); + rv = fp_sensor_maintenance(fp_buffer, &sensor_info); CPRINTS("Maintenance took %d ms", time_since32(start) / MSEC); if (rv != 0) { diff --git a/driver/fingerprint/fpc/libfp/fpc1145_private.h b/driver/fingerprint/fpc/libfp/fpc1145_private.h index 69984c864a..399c75118b 100644 --- a/driver/fingerprint/fpc/libfp/fpc1145_private.h +++ b/driver/fingerprint/fpc/libfp/fpc1145_private.h @@ -21,9 +21,9 @@ #define FP_SENSOR_NAME "FPC1145" /* Sensor pixel resolution */ -#define FP_SENSOR_RES_Y_FPC 192 -#define FP_SENSOR_RES_X_FPC 56 -#define FP_SENSOR_RES_BPP 8 +#define FP_SENSOR_RES_Y 192 +#define FP_SENSOR_RES_X 56 +#define FP_SENSOR_RES_BPP 8 /* Acquired finger frame definitions */ #define FP_SENSOR_IMAGE_SIZE_MODE_VENDOR (35460) @@ -35,7 +35,7 @@ */ #define FP_SENSOR_IMAGE_SIZE_MODE_QUAL (24408) -#define FP_SENSOR_IMAGE_SIZE_FPC FP_SENSOR_IMAGE_SIZE_MODE_VENDOR +#define FP_SENSOR_IMAGE_SIZE FP_SENSOR_IMAGE_SIZE_MODE_VENDOR #define FP_SENSOR_IMAGE_OFFSET 2340 /* Opaque FPC context */ @@ -43,7 +43,7 @@ /* Algorithm buffer sizes */ #define FP_ALGORITHM_ENROLLMENT_SIZE 28 -#define FP_ALGORITHM_TEMPLATE_SIZE_FPC 47552 +#define FP_ALGORITHM_TEMPLATE_SIZE 47552 /* Max number of templates stored / matched against */ #define FP_MAX_FINGER_COUNT 5 diff --git a/driver/fingerprint/fpc/libfp/fpc_private.c b/driver/fingerprint/fpc/libfp/fpc_private.c index a20ff858d3..8c11849c8f 100644 --- a/driver/fingerprint/fpc/libfp/fpc_private.c +++ b/driver/fingerprint/fpc/libfp/fpc_private.c @@ -10,7 +10,6 @@ #include "fpc_bio_algorithm.h" #include "fpc_private.h" #include "fpsensor.h" -#include "fpsensor_fpc.h" #include "gpio.h" #include "link_defs.h" #include "spi.h" @@ -56,10 +55,10 @@ static struct ec_response_fp_info fpc1145_info = { .model_id = 1, .version = 1, /* Image frame characteristics */ - .frame_size = FP_SENSOR_IMAGE_SIZE_FPC, + .frame_size = FP_SENSOR_IMAGE_SIZE, .pixel_format = V4L2_PIX_FMT_GREY, - .width = FP_SENSOR_RES_X_FPC, - .height = FP_SENSOR_RES_Y_FPC, + .width = FP_SENSOR_RES_X, + .height = FP_SENSOR_RES_Y, .bpp = FP_SENSOR_RES_BPP, }; @@ -88,7 +87,7 @@ static int fpc_send_cmd(const uint8_t cmd) SPI_READBACK_ALL); } -void fp_sensor_low_power_fpc(void) +void fp_sensor_low_power(void) { /* * TODO(b/117620462): verify that sleep mode is WAI (no increased @@ -176,7 +175,7 @@ static int fpc_pulse_hw_reset(void) } /* Reset and initialize the sensor IC */ -int fp_sensor_init_fpc(void) +int fp_sensor_init(void) { int res; int attempt; @@ -246,13 +245,13 @@ int fp_sensor_init_fpc(void) errors |= FP_ERROR_INIT_FAIL; /* Go back to low power */ - fp_sensor_low_power_fpc(); + fp_sensor_low_power(); return EC_SUCCESS; } /* Deinitialize the sensor IC */ -int fp_sensor_deinit_fpc(void) +int fp_sensor_deinit(void) { /* * TODO(tomhughes): libfp doesn't have fp_sensor_close like BEP does. @@ -263,7 +262,7 @@ int fp_sensor_deinit_fpc(void) return EC_SUCCESS; } -int fp_sensor_get_info_fpc(struct ec_response_fp_info *resp) +int fp_sensor_get_info(struct ec_response_fp_info *resp) { int rc; @@ -280,14 +279,14 @@ int fp_sensor_get_info_fpc(struct ec_response_fp_info *resp) return EC_SUCCESS; } -int fp_finger_match_fpc(void *templ, uint32_t templ_count, uint8_t *image, +int fp_finger_match(void *templ, uint32_t templ_count, uint8_t *image, int32_t *match_index, uint32_t *update_bitmap) { return bio_template_image_match_list(templ, templ_count, image, match_index, update_bitmap); } -int fp_enrollment_begin_fpc(void) +int fp_enrollment_begin(void) { int rc; bio_enrollment_t p = enroll_ctx; @@ -298,14 +297,14 @@ int fp_enrollment_begin_fpc(void) return rc; } -int fp_enrollment_finish_fpc(void *templ) +int fp_enrollment_finish(void *templ) { bio_template_t pt = templ; return bio_enrollment_finish(enroll_ctx, templ ? &pt : NULL); } -int fp_finger_enroll_fpc(uint8_t *image, int *completion) +int fp_finger_enroll(uint8_t *image, int *completion) { int rc = bio_enrollment_add_image(enroll_ctx, image); @@ -315,30 +314,7 @@ int fp_finger_enroll_fpc(uint8_t *image, int *completion) return rc; } -int fp_maintenance_fpc(void) +int fp_maintenance(void) { return fpc_fp_maintenance(&errors); } - -struct fp_sensor_interface fp_driver_fpc = { - .sensor_type = FP_SENSOR_TYPE_FPC, - .fp_sensor_init = &fp_sensor_init_fpc, - .fp_sensor_deinit = &fp_sensor_deinit_fpc, - .fp_sensor_get_info = &fp_sensor_get_info_fpc, - .fp_sensor_low_power = &fp_sensor_low_power_fpc, - .fp_sensor_configure_detect_ = &fp_sensor_configure_detect, - .fp_sensor_finger_status_ = &fp_sensor_finger_status, - .fp_sensor_acquire_image_with_mode_ = - &fp_sensor_acquire_image_with_mode, - .fp_finger_enroll = &fp_finger_enroll_fpc, - .fp_finger_match = &fp_finger_match_fpc, - .fp_enrollment_begin = &fp_enrollment_begin_fpc, - .fp_enrollment_finish = &fp_enrollment_finish_fpc, - .fp_maintenance = &fp_maintenance_fpc, - .algorithm_template_size = FP_ALGORITHM_TEMPLATE_SIZE_FPC, - .encrypted_template_size = - FP_ALGORITHM_TEMPLATE_SIZE_FPC + FP_POSITIVE_MATCH_SALT_BYTES + - sizeof(struct ec_fp_template_encryption_metadata), - .res_x = FP_SENSOR_RES_X_FPC, - .res_y = FP_SENSOR_RES_Y_FPC -}; diff --git a/driver/fingerprint/fpsensor.h b/driver/fingerprint/fpsensor.h index 9827c2caf6..ac7e31fb6a 100644 --- a/driver/fingerprint/fpsensor.h +++ b/driver/fingerprint/fpsensor.h @@ -10,15 +10,15 @@ #define HAVE_FP_PRIVATE_DRIVER #if defined(CONFIG_FP_SENSOR_ELAN80) || defined(CONFIG_FP_SENSOR_ELAN515) #include "elan/elan_sensor.h" -#endif -#if defined(CONFIG_FP_SENSOR_FPC1025) || defined(CONFIG_FP_SENSOR_FPC1035) || \ - defined(CONFIG_FP_SENSOR_FPC1145) +#else #include "fpc/fpc_sensor.h" #endif #else /* These values are used by the host (emulator) tests. */ +#define FP_SENSOR_IMAGE_SIZE 0 #define FP_SENSOR_RES_X 0 #define FP_SENSOR_RES_Y 0 +#define FP_ALGORITHM_TEMPLATE_SIZE 0 #define FP_MAX_FINGER_COUNT 5 #endif diff --git a/fuzz/host_command_fuzz.c b/fuzz/host_command_fuzz.c index 01a5818b63..4ca94ff616 100644 --- a/fuzz/host_command_fuzz.c +++ b/fuzz/host_command_fuzz.c @@ -12,7 +12,6 @@ #include "console.h" #include "host_command.h" #include "host_test.h" -#include "mock/fp_sensor_mock.h" #include "task.h" #include "test_util.h" #include "timer.h" @@ -135,8 +134,6 @@ static pthread_mutex_t lock; void run_test(int argc, char **argv) { ccprints("Fuzzing task started"); - /* Set the fingerprint driver to the mock to test fp_task. */ - fp_driver = &fp_driver_mock; wait_for_task_started(); while (1) { diff --git a/include/fpsensor.h b/include/fpsensor.h index 3470cb3386..2c5baa2679 100644 --- a/include/fpsensor.h +++ b/include/fpsensor.h @@ -11,7 +11,6 @@ #include <stdint.h> #include "common.h" #include "ec_commands.h" -#include "fpsensor_detect.h" #ifndef SPI_FP_DEVICE #define SPI_FP_DEVICE (&spi_devices[0]) @@ -24,157 +23,48 @@ /* 8-bit greyscale pixel format as defined by V4L2 headers */ #define V4L2_PIX_FMT_GREY FOURCC('G', 'R', 'E', 'Y') +/* --- functions provided by the sensor-specific driver --- */ + +/* Initialize the connected sensor hardware and put it in a low power mode. */ +int fp_sensor_init(void); + +/* De-initialize the sensor hardware. */ +int fp_sensor_deinit(void); + +/* + * Fill the 'ec_response_fp_info' buffer with the sensor information + * as required by the EC_CMD_FP_INFO host command. + * + * Put both the static information and the ones read from the sensor at runtime. + */ +int fp_sensor_get_info(struct ec_response_fp_info *resp); + +/* + * Put the sensor in its lowest power state. + * + * fp_sensor_configure_detect needs to be called to restore finger detection + * functionality. + */ +void fp_sensor_low_power(void); + +/* + * Configure finger detection. + * + * Send the settings to the sensor, so it is properly configured to detect + * the presence of a finger. + */ +void fp_sensor_configure_detect(void); + +/* + * Returns the status of the finger on the sensor. + * (assumes fp_sensor_configure_detect was called before) + */ enum finger_state { FINGER_NONE = 0, FINGER_PARTIAL = 1, FINGER_PRESENT = 2, }; - -/* --- functions provided by the sensor-specific driver --- */ - -struct fp_sensor_interface { - /* Whether there is an ELAN fingerprint sensor or FPC sensor. */ - enum fp_sensor_type sensor_type; - - /* - * Initialize the connected sensor hardware and put it in a low power - * mode. - */ - int (*fp_sensor_init)(void); - - /* De-initialize the sensor hardware. */ - int (*fp_sensor_deinit)(void); - - /* - * Fill the 'ec_response_fp_info' buffer with the sensor information - * as required by the EC_CMD_FP_INFO host command. - * - * Put both the static information and the ones read from the sensor at - * runtime. - */ - int (*fp_sensor_get_info)(struct ec_response_fp_info *resp); - - /* - * Put the sensor in its lowest power state. - * - * fp_sensor_configure_detect needs to be called to restore finger - * detection functionality. - */ - void (*fp_sensor_low_power)(void); - - /* - * Configure finger detection. - * - * Send the settings to the sensor, so it is properly configured to - * detect the presence of a finger. - */ - /* TODO(b/184101599): Remove "_" suffix. */ - void (*fp_sensor_configure_detect_)(void); - - /* - * Returns the status of the finger on the sensor. - * (assumes fp_sensor_configure_detect was called before) - */ - /* TODO(b/184101599): Remove "_" suffix. */ - enum finger_state (*fp_sensor_finger_status_)(void); - - /* - * Acquires a fingerprint image with specific capture mode. - * - * Same as the fp_sensor_acquire_image function above, - * excepted 'mode' can be set to one of the FP_CAPTURE_ constants - * to get a specific image type (e.g. a pattern) rather than the default - * one. - */ - /* TODO(b/184101599): Remove "_" suffix. */ - int (*fp_sensor_acquire_image_with_mode_)(uint8_t *image_data, - int mode); - - /* - * Adds fingerprint image to the current enrollment session. - * - * @return a negative value on error or one of the following codes: - * - EC_MKBP_FP_ERR_ENROLL_OK when image was successfully enrolled - * - EC_MKBP_FP_ERR_ENROLL_IMMOBILE when image added, but user should be - * advised to move finger - * - EC_MKBP_FP_ERR_ENROLL_LOW_QUALITY when image could not be used due - * to low image quality - * - EC_MKBP_FP_ERR_ENROLL_LOW_COVERAGE when image could not be used due - * to finger covering too little area of the sensor - */ - int (*fp_finger_enroll)(uint8_t *image, int *completion); - - /* - * Compares given finger image against enrolled templates. - * - * The matching algorithm can update the template with additional - * biometric data from the image, if it chooses to do so. - * - * @param templ a pointer to the array of template buffers. - * @param templ_count the number of buffers in the array of templates. - * @param image the buffer containing the finger image - * @param match_index index of the matched finger in the template array - * if any. - * @param update_bitmap contains one bit per template, the bit is set if - * the match has updated the given template. - * @return negative value on error, else one of the following code : - * - EC_MKBP_FP_ERR_MATCH_NO on non-match - * - EC_MKBP_FP_ERR_MATCH_YES for match when template was not updated - * with new data - * - EC_MKBP_FP_ERR_MATCH_YES_UPDATED for match when template was - * updated - * - EC_MKBP_FP_ERR_MATCH_YES_UPDATE_FAILED match, but update failed - * (not saved) - * - EC_MKBP_FP_ERR_MATCH_LOW_QUALITY when matching could not be - * performed due to low image quality - * - EC_MKBP_FP_ERR_MATCH_LOW_COVERAGE when matching could not be - * performed due to finger covering too little area of the sensor - */ - int (*fp_finger_match)(void *templ, uint32_t templ_count, - uint8_t *image, int32_t *match_index, - uint32_t *update_bitmap); - - /* - * Start a finger enrollment session. - * - * @return 0 on success or a negative error code. - */ - int (*fp_enrollment_begin)(void); - - /* - * Generate a template from the finger whose enrollment has just being - * completed. - * - * @param templ the buffer which will receive the template. - * templ can be set to NULL to abort the current enrollment process. - * - * @return 0 on success or a negative error code. - */ - int (*fp_enrollment_finish)(void *templ); - - /** - * Runs a test for defective pixels. - * - * Should be triggered periodically by the client. The maintenance - * command can take several hundred milliseconds to run. - * - * @return EC_ERROR_HW_INTERNAL on error (such as finger on sensor) - * @return EC_SUCCESS on success - */ - int (*fp_maintenance)(void); - - /* Size of one unencrypted fingerprint template. */ - int algorithm_template_size; - - /* Size of one encrypted fingerprint template sent to the AP. */ - int encrypted_template_size; - - /* Sensor resolution. */ - int res_x; - int res_y; -}; - -extern struct fp_sensor_interface *fp_driver; +enum finger_state fp_sensor_finger_status(void); /* * Acquires a fingerprint image. @@ -197,4 +87,82 @@ extern struct fp_sensor_interface *fp_driver; #define FP_SENSOR_LOW_SENSOR_COVERAGE 3 int fp_sensor_acquire_image(uint8_t *image_data); +/* + * Acquires a fingerprint image with specific capture mode. + * + * Same as the fp_sensor_acquire_image function above, + * excepted 'mode' can be set to one of the FP_CAPTURE_ constants + * to get a specific image type (e.g. a pattern) rather than the default one. + */ +int fp_sensor_acquire_image_with_mode(uint8_t *image_data, int mode); + +/* + * Compares given finger image against enrolled templates. + * + * The matching algorithm can update the template with additional biometric data + * from the image, if it chooses to do so. + * + * @param templ a pointer to the array of template buffers. + * @param templ_count the number of buffers in the array of templates. + * @param image the buffer containing the finger image + * @param match_index index of the matched finger in the template array if any. + * @param update_bitmap contains one bit per template, the bit is set if the + * match has updated the given template. + * @return negative value on error, else one of the following code : + * - EC_MKBP_FP_ERR_MATCH_NO on non-match + * - EC_MKBP_FP_ERR_MATCH_YES for match when template was not updated with + * new data + * - EC_MKBP_FP_ERR_MATCH_YES_UPDATED for match when template was updated + * - EC_MKBP_FP_ERR_MATCH_YES_UPDATE_FAILED match, but update failed (not saved) + * - EC_MKBP_FP_ERR_MATCH_LOW_QUALITY when matching could not be performed due + * to low image quality + * - EC_MKBP_FP_ERR_MATCH_LOW_COVERAGE when matching could not be performed + * due to finger covering too little area of the sensor + */ +int fp_finger_match(void *templ, uint32_t templ_count, uint8_t *image, + int32_t *match_index, uint32_t *update_bitmap); + +/* + * Start a finger enrollment session. + * + * @return 0 on success or a negative error code. + */ +int fp_enrollment_begin(void); + +/* + * Generate a template from the finger whose enrollment has just being + * completed. + * + * @param templ the buffer which will receive the template. + * templ can be set to NULL to abort the current enrollment process. + * + * @return 0 on success or a negative error code. + */ +int fp_enrollment_finish(void *templ); + +/* + * Adds fingerprint image to the current enrollment session. + * + * @return a negative value on error or one of the following codes: + * - EC_MKBP_FP_ERR_ENROLL_OK when image was successfully enrolled + * - EC_MKBP_FP_ERR_ENROLL_IMMOBILE when image added, but user should be + * advised to move finger + * - EC_MKBP_FP_ERR_ENROLL_LOW_QUALITY when image could not be used due to low + * image quality + * - EC_MKBP_FP_ERR_ENROLL_LOW_COVERAGE when image could not be used due to + * finger covering too little area of the sensor + */ +int fp_finger_enroll(uint8_t *image, int *completion); + +/** + * Runs a test for defective pixels. + * + * Should be triggered periodically by the client. The maintenance command can + * take several hundred milliseconds to run. + * + * @return EC_ERROR_HW_INTERNAL on error (such as finger on sensor) + * @return EC_SUCCESS on success + */ +int fp_maintenance(void); + #endif /* __CROS_EC_FPSENSOR_H */ diff --git a/include/fpsensor_elan.h b/include/fpsensor_elan.h deleted file mode 100644 index 008d0c3545..0000000000 --- a/include/fpsensor_elan.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Fingerprint sensor interface */ - -#ifndef __CROS_EC_FPSENSOR_ELAN_H -#define __CROS_EC_FPSENSOR_ELAN_H - -#include <stdint.h> - -extern struct fp_sensor_interface fp_driver_elan; - -/* Initialize the connected sensor hardware and put it in a low power mode. */ -int fp_sensor_init_elan(void); - -/* De-initialize the sensor hardware. */ -int fp_sensor_deinit_elan(void); - -/* - * Fill the 'ec_response_fp_info' buffer with the sensor information - * as required by the EC_CMD_FP_INFO host command. - * - * Put both the static information and the ones read from the sensor at runtime. - */ -int fp_sensor_get_info_elan(struct ec_response_fp_info *resp); - -/* - * Put the sensor in its lowest power state. - * - * fp_sensor_configure_detect needs to be called to restore finger detection - * functionality. - */ -void fp_sensor_low_power_elan(void); - -/* - * Configure finger detection. - * - * Send the settings to the sensor, so it is properly configured to detect - * the presence of a finger. - */ -void fp_sensor_configure_detect_elan(void); - -/* - * Returns the status of the finger on the sensor. - * (assumes fp_sensor_configure_detect was called before) - */ -enum finger_state fp_sensor_finger_status_elan(void); - -/* - * Acquires a fingerprint image with specific capture mode. - * - * Same as the fp_sensor_acquire_image function above, - * excepted 'mode' can be set to one of the FP_CAPTURE_ constants - * to get a specific image type (e.g. a pattern) rather than the default one. - */ -int fp_sensor_acquire_image_with_mode_elan(uint8_t *image_data, int mode); - -/* - * Adds fingerprint image to the current enrollment session. - * - * @return a negative value on error or one of the following codes: - * - EC_MKBP_FP_ERR_ENROLL_OK when image was successfully enrolled - * - EC_MKBP_FP_ERR_ENROLL_IMMOBILE when image added, but user should be - * advised to move finger - * - EC_MKBP_FP_ERR_ENROLL_LOW_QUALITY when image could not be used due to low - * image quality - * - EC_MKBP_FP_ERR_ENROLL_LOW_COVERAGE when image could not be used due to - * finger covering too little area of the sensor - */ -int fp_finger_enroll_elan(uint8_t *image, int *completion); - -/* - * Compares given finger image against enrolled templates. - * - * The matching algorithm can update the template with additional biometric data - * from the image, if it chooses to do so. - * - * @param templ a pointer to the array of template buffers. - * @param templ_count the number of buffers in the array of templates. - * @param image the buffer containing the finger image - * @param match_index index of the matched finger in the template array if any. - * @param update_bitmap contains one bit per template, the bit is set if the - * match has updated the given template. - * @return negative value on error, else one of the following code : - * - EC_MKBP_FP_ERR_MATCH_NO on non-match - * - EC_MKBP_FP_ERR_MATCH_YES for match when template was not updated with - * new data - * - EC_MKBP_FP_ERR_MATCH_YES_UPDATED for match when template was updated - * - EC_MKBP_FP_ERR_MATCH_YES_UPDATE_FAILED match, but update failed (not saved) - * - EC_MKBP_FP_ERR_MATCH_LOW_QUALITY when matching could not be performed due - * to low image quality - * - EC_MKBP_FP_ERR_MATCH_LOW_COVERAGE when matching could not be performed - * due to finger covering too little area of the sensor - */ -int fp_finger_match_elan(void *templ, uint32_t templ_count, uint8_t *image, - int32_t *match_index, uint32_t *update_bitmap); - -/* - * Start a finger enrollment session. - * - * @return 0 on success or a negative error code. - */ -int fp_enrollment_begin_elan(void); - -/* - * Generate a template from the finger whose enrollment has just being - * completed. - * - * @param templ the buffer which will receive the template. - * templ can be set to NULL to abort the current enrollment process. - * - * @return 0 on success or a negative error code. - */ -int fp_enrollment_finish_elan(void *templ); - -/** - * Runs a test for defective pixels. - * - * Should be triggered periodically by the client. The maintenance command can - * take several hundred milliseconds to run. - * - * @return EC_ERROR_HW_INTERNAL on error (such as finger on sensor) - * @return EC_SUCCESS on success - */ -int fp_maintenance_elan(void); - -#endif /* __CROS_EC_FPSENSOR_ELAN_H */ diff --git a/include/fpsensor_fpc.h b/include/fpsensor_fpc.h deleted file mode 100644 index 3cd28d5d45..0000000000 --- a/include/fpsensor_fpc.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Fingerprint sensor interface */ - -#ifndef __CROS_EC_FPSENSOR_FPC_H -#define __CROS_EC_FPSENSOR_FPC_H - -#include <stdint.h> - -extern struct fp_sensor_interface fp_driver_fpc; - -/* Initialize the connected sensor hardware and put it in a low power mode. */ -int fp_sensor_init_fpc(void); - -/* De-initialize the sensor hardware. */ -int fp_sensor_deinit_fpc(void); - -/* - * Fill the 'ec_response_fp_info' buffer with the sensor information - * as required by the EC_CMD_FP_INFO host command. - * - * Put both the static information and the ones read from the sensor at runtime. - */ -int fp_sensor_get_info_fpc(struct ec_response_fp_info *resp); - -/* - * Put the sensor in its lowest power state. - * - * fp_sensor_configure_detect needs to be called to restore finger detection - * functionality. - */ -void fp_sensor_low_power_fpc(void); - -/* - * Configure finger detection. - * - * Send the settings to the sensor, so it is properly configured to detect - * the presence of a finger. - */ -void fp_sensor_configure_detect(void); - -/* - * Returns the status of the finger on the sensor. - * (assumes fp_sensor_configure_detect was called before) - */ -enum finger_state fp_sensor_finger_status(void); - -/* - * Acquires a fingerprint image with specific capture mode. - * - * Same as the fp_sensor_acquire_image function above, - * excepted 'mode' can be set to one of the FP_CAPTURE_ constants - * to get a specific image type (e.g. a pattern) rather than the default one. - */ -int fp_sensor_acquire_image_with_mode(uint8_t *image_data, int mode); - -/* - * Adds fingerprint image to the current enrollment session. - * - * @return a negative value on error or one of the following codes: - * - EC_MKBP_FP_ERR_ENROLL_OK when image was successfully enrolled - * - EC_MKBP_FP_ERR_ENROLL_IMMOBILE when image added, but user should be - * advised to move finger - * - EC_MKBP_FP_ERR_ENROLL_LOW_QUALITY when image could not be used due to low - * image quality - * - EC_MKBP_FP_ERR_ENROLL_LOW_COVERAGE when image could not be used due to - * finger covering too little area of the sensor - */ -int fp_finger_enroll_fpc(uint8_t *image, int *completion); - -/* - * Compares given finger image against enrolled templates. - * - * The matching algorithm can update the template with additional biometric data - * from the image, if it chooses to do so. - * - * @param templ a pointer to the array of template buffers. - * @param templ_count the number of buffers in the array of templates. - * @param image the buffer containing the finger image - * @param match_index index of the matched finger in the template array if any. - * @param update_bitmap contains one bit per template, the bit is set if the - * match has updated the given template. - * @return negative value on error, else one of the following code : - * - EC_MKBP_FP_ERR_MATCH_NO on non-match - * - EC_MKBP_FP_ERR_MATCH_YES for match when template was not updated with - * new data - * - EC_MKBP_FP_ERR_MATCH_YES_UPDATED for match when template was updated - * - EC_MKBP_FP_ERR_MATCH_YES_UPDATE_FAILED match, but update failed (not saved) - * - EC_MKBP_FP_ERR_MATCH_LOW_QUALITY when matching could not be performed due - * to low image quality - * - EC_MKBP_FP_ERR_MATCH_LOW_COVERAGE when matching could not be performed - * due to finger covering too little area of the sensor - */ -int fp_finger_match_fpc(void *templ, uint32_t templ_count, uint8_t *image, - int32_t *match_index, uint32_t *update_bitmap); - -/* - * Start a finger enrollment session. - * - * @return 0 on success or a negative error code. - */ -int fp_enrollment_begin_fpc(void); - -/* - * Generate a template from the finger whose enrollment has just being - * completed. - * - * @param templ the buffer which will receive the template. - * templ can be set to NULL to abort the current enrollment process. - * - * @return 0 on success or a negative error code. - */ -int fp_enrollment_finish_fpc(void *templ); - -/** - * Runs a test for defective pixels. - * - * Should be triggered periodically by the client. The maintenance command can - * take several hundred milliseconds to run. - * - * @return EC_ERROR_HW_INTERNAL on error (such as finger on sensor) - * @return EC_SUCCESS on success - */ -int fp_maintenance_fpc(void); - -#endif /* __CROS_EC_FPSENSOR_FPC_H */ diff --git a/include/fpsensor_state.h b/include/fpsensor_state.h index 6f61b03d09..6b752bc86d 100644 --- a/include/fpsensor_state.h +++ b/include/fpsensor_state.h @@ -14,7 +14,6 @@ #include "ec_commands.h" #include "link_defs.h" #include "timer.h" -#include "util.h" #include "driver/fingerprint/fpsensor.h" @@ -27,6 +26,10 @@ #endif #define SBP_ENC_KEY_LEN 16 +#define FP_ALGORITHM_ENCRYPTED_TEMPLATE_SIZE \ + (FP_ALGORITHM_TEMPLATE_SIZE + \ + FP_POSITIVE_MATCH_SALT_BYTES + \ + sizeof(struct ec_fp_template_encryption_metadata)) /* Events for the FPSENSOR task */ #define TASK_EVENT_SENSOR_IRQ TASK_EVENT_CUSTOM_BIT(0) @@ -37,44 +40,16 @@ /* --- Global variables defined in fpsensor_state.c --- */ /* Last acquired frame (aligned as it is used by arbitrary binary libraries) */ -#ifndef FP_SENSOR_IMAGE_SIZE_FPC -#define FP_SENSOR_IMAGE_SIZE_FPC 0 -#endif -#ifndef FP_SENSOR_IMAGE_SIZE_ELAN -#define FP_SENSOR_IMAGE_SIZE_ELAN 0 -#endif - -#define FP_SENSOR_IMAGE_MAX_SIZE \ - GENERIC_MAX(FP_SENSOR_IMAGE_SIZE_FPC, FP_SENSOR_IMAGE_SIZE_ELAN) - -extern uint8_t fp_buffer[FP_SENSOR_IMAGE_MAX_SIZE]; - +extern uint8_t fp_buffer[FP_SENSOR_IMAGE_SIZE]; /* Fingers templates for the current user */ -#ifndef FP_ALGORITHM_TEMPLATE_SIZE_FPC -#define FP_ALGORITHM_TEMPLATE_SIZE_FPC 0 -#endif -#ifndef FP_ALGORITHM_TEMPLATE_SIZE_ELAN -#define FP_ALGORITHM_TEMPLATE_SIZE_ELAN 0 -#endif - -#define FP_ALGORITHM_TEMPLATE_MAX_SIZE \ - GENERIC_MAX(FP_ALGORITHM_TEMPLATE_SIZE_FPC, \ - FP_ALGORITHM_TEMPLATE_SIZE_ELAN) -extern uint8_t fp_template[FP_ALGORITHM_TEMPLATE_MAX_SIZE * - FP_MAX_FINGER_COUNT] FP_TEMPLATE_SECTION; - +extern uint8_t fp_template[FP_MAX_FINGER_COUNT][FP_ALGORITHM_TEMPLATE_SIZE]; /* Encryption/decryption buffer */ /* TODO: On-the-fly encryption/decryption without a dedicated buffer */ /* * Store the encryption metadata at the beginning of the buffer containing the * ciphered data. */ -#define FP_ALGORITHM_ENCRYPTED_TEMPLATE_MAX_SIZE \ - (FP_ALGORITHM_TEMPLATE_MAX_SIZE + FP_POSITIVE_MATCH_SALT_BYTES + \ - sizeof(struct ec_fp_template_encryption_metadata)) - -extern uint8_t fp_enc_buffer[FP_ALGORITHM_ENCRYPTED_TEMPLATE_MAX_SIZE]; - +extern uint8_t fp_enc_buffer[FP_ALGORITHM_ENCRYPTED_TEMPLATE_SIZE]; /* Salt used in derivation of positive match secret. */ extern uint8_t fp_positive_match_salt [FP_MAX_FINGER_COUNT][FP_POSITIVE_MATCH_SALT_BYTES]; diff --git a/include/mock/fp_sensor_mock.h b/include/mock/fp_sensor_mock.h index 7248cde3d3..432802348c 100644 --- a/include/mock/fp_sensor_mock.h +++ b/include/mock/fp_sensor_mock.h @@ -45,6 +45,4 @@ struct mock_ctrl_fp_sensor { extern struct mock_ctrl_fp_sensor mock_ctrl_fp_sensor; -extern struct fp_sensor_interface fp_driver_mock; - #endif /* __MOCK_FP_SENSOR_MOCK_H */ |