diff options
author | Yicheng Li <yichengli@chromium.org> | 2021-03-02 15:38:17 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-02 23:16:12 +0000 |
commit | ac08c9d1dbc9f587df3ee6b15d58c0203f7e356e (patch) | |
tree | 04cd12d6787ce1b0b99b1d4e0aff504ccfa2c35e /include/fpsensor_state.h | |
parent | e3cbbc3461c83d2d97b78447c53db1c6540cb3be (diff) | |
download | chrome-ec-ac08c9d1dbc9f587df3ee6b15d58c0203f7e356e.tar.gz |
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>
Diffstat (limited to 'include/fpsensor_state.h')
-rw-r--r-- | include/fpsensor_state.h | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/include/fpsensor_state.h b/include/fpsensor_state.h index 6b752bc86d..6f61b03d09 100644 --- a/include/fpsensor_state.h +++ b/include/fpsensor_state.h @@ -14,6 +14,7 @@ #include "ec_commands.h" #include "link_defs.h" #include "timer.h" +#include "util.h" #include "driver/fingerprint/fpsensor.h" @@ -26,10 +27,6 @@ #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) @@ -40,16 +37,44 @@ /* --- Global variables defined in fpsensor_state.c --- */ /* Last acquired frame (aligned as it is used by arbitrary binary libraries) */ -extern uint8_t fp_buffer[FP_SENSOR_IMAGE_SIZE]; +#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]; + /* Fingers templates for the current user */ -extern uint8_t fp_template[FP_MAX_FINGER_COUNT][FP_ALGORITHM_TEMPLATE_SIZE]; +#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; + /* 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. */ -extern uint8_t fp_enc_buffer[FP_ALGORITHM_ENCRYPTED_TEMPLATE_SIZE]; +#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]; + /* Salt used in derivation of positive match secret. */ extern uint8_t fp_positive_match_salt [FP_MAX_FINGER_COUNT][FP_POSITIVE_MATCH_SALT_BYTES]; |