summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2021-01-05 13:48:58 -0800
committerCommit Bot <commit-bot@chromium.org>2021-01-06 21:56:57 +0000
commit8c0e2f3c9164c95b9262d558aa6a667d310e3bf9 (patch)
tree4375ac8cf217855f7ce8921d0d528237744e2115
parent7103bc89ed2a4460a606b62b63df02e7f0ecb3df (diff)
downloadchrome-ec-8c0e2f3c9164c95b9262d558aa6a667d310e3bf9.tar.gz
coil: remove fingerprint support
This code uses coil terms we're removing, but we don't use it in platform/cr50. Remove the code instead of replacing the terms. BUG=b:175244613 TEST=make buildall -j Change-Id: I909e21693d839cb3769e680c58d9d34017802aa1 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2613136 Reviewed-by: Namyoon Woo <namyoon@chromium.org>
-rw-r--r--board/host/board.c6
-rw-r--r--board/host/board.h1
-rw-r--r--board/host/gpio.inc5
-rw-r--r--common/build.mk2
-rw-r--r--common/fpsensor/build.mk12
-rw-r--r--common/fpsensor/fpsensor.c833
-rw-r--r--common/fpsensor/fpsensor_crypto.c286
-rw-r--r--common/fpsensor/fpsensor_private.h14
-rw-r--r--common/fpsensor/fpsensor_state.c313
-rw-r--r--driver/build.mk3
-rw-r--r--driver/fingerprint/build.mk10
-rw-r--r--driver/fingerprint/fpc/bep/build.mk17
-rw-r--r--driver/fingerprint/fpc/bep/fpc1025_private.h49
-rw-r--r--driver/fingerprint/fpc/bep/fpc1035_private.h49
-rw-r--r--driver/fingerprint/fpc/bep/fpc_bio_algorithm.h136
-rw-r--r--driver/fingerprint/fpc/bep/fpc_misc.c51
-rw-r--r--driver/fingerprint/fpc/bep/fpc_private.c260
-rw-r--r--driver/fingerprint/fpc/bep/fpc_sensor_spi.c94
-rw-r--r--driver/fingerprint/fpc/bep/fpc_sensor_spi.h98
-rw-r--r--driver/fingerprint/fpc/bep/fpc_timebase.c29
-rw-r--r--driver/fingerprint/fpc/bep/fpc_timebase.h48
-rw-r--r--driver/fingerprint/fpc/build.mk16
-rw-r--r--driver/fingerprint/fpc/fpc_sensor.h21
-rw-r--r--driver/fingerprint/fpc/libfp/build.mk15
-rw-r--r--driver/fingerprint/fpc/libfp/fpc1145_private.h45
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h265
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_private.c315
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_private.h104
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_sensor_pal.c60
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_sensor_pal.h118
-rw-r--r--driver/fingerprint/fpsensor.h26
-rw-r--r--fuzz/host_command_fuzz.mocklist2
-rw-r--r--fuzz/host_command_fuzz.tasklist3
-rw-r--r--include/config.h6
-rw-r--r--include/ec_commands.h297
-rw-r--r--include/fpsensor.h157
-rw-r--r--include/fpsensor_crypto.h95
-rw-r--r--include/fpsensor_state.h139
38 files changed, 1 insertions, 3999 deletions
diff --git a/board/host/board.c b/board/host/board.c
index cccb6f15ec..cc13414597 100644
--- a/board/host/board.c
+++ b/board/host/board.c
@@ -47,10 +47,6 @@ test_mockable void button_interrupt(enum gpio_signal signal)
{
}
-test_mockable void fps_event(enum gpio_signal signal)
-{
-}
-
#ifdef CONFIG_I2C
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
@@ -67,8 +63,6 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
#ifdef CONFIG_SPI_MASTER
/* SPI devices */
const struct spi_device_t spi_devices[] = {
- /* Fingerprint sensor (SCLK at 4Mhz) */
- { CONFIG_SPI_FP_PORT, 3, GPIO_SPI1_NSS },
};
const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
diff --git a/board/host/board.h b/board/host/board.h
index 8ccdd40b80..e104872a14 100644
--- a/board/host/board.h
+++ b/board/host/board.h
@@ -89,7 +89,6 @@ enum {
};
#define CONFIG_RNG
-void fps_event(enum gpio_signal signal);
/* Let the tests always check the other NVMEM slot. */
static inline int board_nvmem_legacy_check_needed(void){ return 1; }
diff --git a/board/host/gpio.inc b/board/host/gpio.inc
index bf2f974bd3..21b95e4c3e 100644
--- a/board/host/gpio.inc
+++ b/board/host/gpio.inc
@@ -14,8 +14,6 @@ GPIO_INT(AC_PRESENT, PIN(0, 2), GPIO_INT_BOTH, extpower_interrupt)
GPIO_INT(VOLUME_DOWN_L, PIN(0, 3), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(VOLUME_UP_L, PIN(0, 4), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(CHARGE_DONE, PIN(0, 5), GPIO_INT_BOTH, inductive_charging_interrupt)
-/* Fingerprint */
-GPIO_INT(FPS_INT, PIN(0, 14), GPIO_INT_RISING, fps_event)
/* GPIOs for EC-CR50 communication */
GPIO_INT(EC_PACKET_MODE_EN, PIN(0, 16), GPIO_INT_RISING,
ec_comm_packet_mode_en)
@@ -32,7 +30,4 @@ GPIO(ENABLE_BACKLIGHT, PIN(0, 10), 0)
GPIO(CHARGE_EN, PIN(0, 11), 0)
GPIO(BASE_CHG_VDD_EN, PIN(0, 12), 0)
-/* Fingerprint */
-GPIO(SPI1_NSS, PIN(0, 13), GPIO_OUT_HIGH)
-
GPIO(USB_C0_DISCHARGE, PIN(0, 15), 0)
diff --git a/common/build.mk b/common/build.mk
index aaa3146d11..343c8e58ef 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -268,7 +268,5 @@ $(out)/$(PROJECT).exe: LDFLAGS_EXTRA += $(CRYPTOC_LDFLAGS)
$(out)/$(PROJECT).exe: $(out)/cryptoc/libcryptoc.a
endif
-include $(_common_dir)fpsensor/build.mk
-
include $(_common_dir)mock/build.mk
common-y+=$(foreach m,$(mock-y),mock/$(m))
diff --git a/common/fpsensor/build.mk b/common/fpsensor/build.mk
deleted file mode 100644
index a1eeaa9932..0000000000
--- a/common/fpsensor/build.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2019 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.
-
-# Build for fingerprint sensor
-
-# Note that this variable includes the trailing "/"
-_fpsensor_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
-
-all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_state.o
-all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor_crypto.o
-all-obj-$(HAS_TASK_FPSENSOR)+=$(_fpsensor_dir)fpsensor.o
diff --git a/common/fpsensor/fpsensor.c b/common/fpsensor/fpsensor.c
deleted file mode 100644
index 8aa9a1d09e..0000000000
--- a/common/fpsensor/fpsensor.c
+++ /dev/null
@@ -1,833 +0,0 @@
-/* Copyright 2017 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.
- */
-
-#include "atomic.h"
-#include "clock.h"
-#include "common.h"
-#include "console.h"
-#include "cryptoc/util.h"
-#include "ec_commands.h"
-#include "fpsensor.h"
-#include "fpsensor_crypto.h"
-#include "fpsensor_private.h"
-#include "fpsensor_state.h"
-#include "gpio.h"
-#include "host_command.h"
-#include "link_defs.h"
-#include "mkbp_event.h"
-#include "spi.h"
-#include "system.h"
-#include "task.h"
-#include "trng.h"
-#include "util.h"
-#include "watchdog.h"
-
-#if !defined(CONFIG_RNG)
-#error "fpsensor requires RNG"
-#endif
-
-/* Ready to encrypt a template. */
-static timestamp_t encryption_deadline;
-
-/* raw image offset inside the acquired frame */
-#ifndef FP_SENSOR_IMAGE_OFFSET
-#define FP_SENSOR_IMAGE_OFFSET 0
-#endif
-
-#define FP_MODE_ANY_CAPTURE (FP_MODE_CAPTURE | FP_MODE_ENROLL_IMAGE | \
- FP_MODE_MATCH)
-#define FP_MODE_ANY_DETECT_FINGER (FP_MODE_FINGER_DOWN | FP_MODE_FINGER_UP | \
- FP_MODE_ANY_CAPTURE)
-#define FP_MODE_ANY_WAIT_IRQ (FP_MODE_FINGER_DOWN | FP_MODE_ANY_CAPTURE)
-
-/* Delay between 2 s of the sensor to detect finger removal */
-#define FINGER_POLLING_DELAY (100*MSEC)
-
-/* Timing statistics. */
-static uint32_t capture_time_us;
-static uint32_t matching_time_us;
-static uint32_t overall_time_us;
-static timestamp_t overall_t0;
-static uint8_t timestamps_invalid;
-
-BUILD_ASSERT(sizeof(struct ec_fp_template_encryption_metadata) % 4 == 0);
-
-/* Interrupt line from the fingerprint sensor */
-void fps_event(enum gpio_signal signal)
-{
- task_set_event(TASK_ID_FPSENSOR, TASK_EVENT_SENSOR_IRQ, 0);
-}
-
-static void send_mkbp_event(uint32_t event)
-{
- atomic_or(&fp_events, event);
- mkbp_send_event(EC_MKBP_EVENT_FINGERPRINT);
-}
-
-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);
-}
-
-#ifdef HAVE_FP_PRIVATE_DRIVER
-static inline int is_test_capture(uint32_t mode)
-{
- int capture_type = FP_CAPTURE_TYPE(mode);
-
- return (mode & FP_MODE_CAPTURE)
- && (capture_type == FP_CAPTURE_PATTERN0
- || capture_type == FP_CAPTURE_PATTERN1
- || capture_type == FP_CAPTURE_RESET_TEST);
-}
-
-/*
- * contains the bit FP_MODE_ENROLL_SESSION if a finger enrollment is on-going.
- * It is used to detect the ENROLL_SESSION transition when sensor_mode is
- * updated by the host.
- */
-static uint32_t enroll_session;
-
-static uint32_t fp_process_enroll(void)
-{
- int percent = 0;
- int res;
-
- if (template_newly_enrolled != FP_NO_SUCH_TEMPLATE)
- CPRINTS("Warning: previously enrolled template has not been "
- "read yet.");
-
- /* begin/continue enrollment */
- CPRINTS("[%d]Enrolling ...", templ_valid);
- 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_enrollment_finish(fp_template[templ_valid]);
- if (res) {
- res = EC_MKBP_FP_ERR_ENROLL_INTERNAL;
- } else {
- template_newly_enrolled = templ_valid;
- fp_enable_positive_match_secret(templ_valid,
- &positive_match_secret_state);
- templ_valid++;
- }
- sensor_mode &= ~FP_MODE_ENROLL_SESSION;
- enroll_session &= ~FP_MODE_ENROLL_SESSION;
- }
- return EC_MKBP_FP_ENROLL | EC_MKBP_FP_ERRCODE(res)
- | (percent << EC_MKBP_FP_ENROLL_PROGRESS_OFFSET);
-}
-
-static uint32_t fp_process_match(void)
-{
- timestamp_t t0 = get_time();
- int res = -1;
- uint32_t updated = 0;
- int32_t fgr = FP_NO_SUCH_TEMPLATE;
-
- /* match finger against current templates */
- fp_disable_positive_match_secret(&positive_match_secret_state);
- CPRINTS("Matching/%d ...", templ_valid);
- if (templ_valid) {
- 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;
- timestamps_invalid |= FPSTATS_MATCHING_INV;
- } else {
- fp_enable_positive_match_secret(fgr,
- &positive_match_secret_state);
- }
- if (res == EC_MKBP_FP_ERR_MATCH_YES_UPDATED)
- templ_dirty |= updated;
- } else {
- CPRINTS("No enrolled templates");
- res = EC_MKBP_FP_ERR_MATCH_NO_TEMPLATES;
- timestamps_invalid |= FPSTATS_MATCHING_INV;
- }
- matching_time_us = time_since32(t0);
- return EC_MKBP_FP_MATCH | EC_MKBP_FP_ERRCODE(res)
- | ((fgr << EC_MKBP_FP_MATCH_IDX_OFFSET) & EC_MKBP_FP_MATCH_IDX_MASK);
-}
-
-static void fp_process_finger(void)
-{
- timestamp_t t0 = get_time();
- 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;
-
- /* Clean up SPI before clocking up to avoid hang on the dsb
- * in dma_go. Ignore the return value to let the WDT reboot
- * the MCU (and avoid getting trapped in the loop).
- * b/112781659 */
- res = spi_transaction_flush(&spi_devices[0]);
- if (res)
- CPRINTS("Failed to flush SPI: 0x%x", res);
- /* we need CPU power to do the computations */
- clock_enable_module(MODULE_FAST_CPU, 1);
-
- if (sensor_mode & FP_MODE_ENROLL_IMAGE)
- evt = fp_process_enroll();
- else if (sensor_mode & FP_MODE_MATCH)
- evt = fp_process_match();
-
- sensor_mode &= ~FP_MODE_ANY_CAPTURE;
- overall_time_us = time_since32(overall_t0);
- send_mkbp_event(evt);
-
- /* go back to lower power mode */
- clock_enable_module(MODULE_FAST_CPU, 0);
- } else {
- timestamps_invalid |= FPSTATS_CAPTURE_INV;
- }
-}
-#endif /* HAVE_FP_PRIVATE_DRIVER */
-
-void fp_task(void)
-{
- int timeout_us = -1;
-
- /* configure the SPI controller (also ensure that CS_N is high) */
- gpio_config_module(MODULE_SPI_MASTER, 1);
- spi_enable(CONFIG_SPI_FP_PORT, 1);
-
-#ifdef HAVE_FP_PRIVATE_DRIVER
- /* Reset and initialize the sensor IC */
- fp_sensor_init();
-
- while (1) {
- uint32_t evt;
- enum finger_state st = FINGER_NONE;
-
- /* Wait for a sensor IRQ or a new mode configuration */
- evt = task_wait_event(timeout_us);
-
- if (evt & TASK_EVENT_UPDATE_CONFIG) {
- uint32_t mode = sensor_mode;
-
- gpio_disable_interrupt(GPIO_FPS_INT);
- if ((mode ^ enroll_session) & FP_MODE_ENROLL_SESSION) {
- if (mode & FP_MODE_ENROLL_SESSION) {
- if (fp_enrollment_begin())
- sensor_mode &=
- ~FP_MODE_ENROLL_SESSION;
- } else {
- fp_enrollment_finish(NULL);
- }
- enroll_session =
- sensor_mode & FP_MODE_ENROLL_SESSION;
- }
- if (is_test_capture(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_sensor_configure_detect();
- }
- if (sensor_mode & FP_MODE_DEEPSLEEP)
- /* Shutdown the sensor */
- fp_sensor_low_power();
- if (sensor_mode & FP_MODE_FINGER_UP)
- /* Poll the sensor to detect finger removal */
- timeout_us = FINGER_POLLING_DELAY;
- else
- timeout_us = -1;
- if (mode & FP_MODE_ANY_WAIT_IRQ) {
- gpio_enable_interrupt(GPIO_FPS_INT);
- } else if (mode & FP_MODE_RESET_SENSOR) {
- fp_reset_and_clear_context();
- sensor_mode &= ~FP_MODE_RESET_SENSOR;
- } else {
- 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_sensor_finger_status();
- if (st == FINGER_PRESENT &&
- sensor_mode & FP_MODE_FINGER_DOWN) {
- CPRINTS("Finger!");
- sensor_mode &= ~FP_MODE_FINGER_DOWN;
- send_mkbp_event(EC_MKBP_FP_FINGER_DOWN);
- }
- if (st == FINGER_NONE &&
- sensor_mode & FP_MODE_FINGER_UP) {
- sensor_mode &= ~FP_MODE_FINGER_UP;
- timeout_us = -1;
- send_mkbp_event(EC_MKBP_FP_FINGER_UP);
- }
- }
-
- if (st == FINGER_PRESENT &&
- sensor_mode & FP_MODE_ANY_CAPTURE)
- fp_process_finger();
-
- if (sensor_mode & FP_MODE_ANY_WAIT_IRQ) {
- fp_sensor_configure_detect();
- gpio_enable_interrupt(GPIO_FPS_INT);
- } else {
- fp_sensor_low_power();
- }
- }
- }
-#else /* !HAVE_FP_PRIVATE_DRIVER */
- while (1) {
- uint32_t evt = task_wait_event(timeout_us);
-
- send_mkbp_event(evt);
- }
-#endif /* !HAVE_FP_PRIVATE_DRIVER */
-}
-
-static enum ec_status fp_command_passthru(struct host_cmd_handler_args *args)
-{
- const struct ec_params_fp_passthru *params = args->params;
- void *out = args->response;
- int rc;
- int ret = EC_RES_SUCCESS;
-
- if (system_is_locked())
- return EC_RES_ACCESS_DENIED;
-
- if (params->len > args->params_size +
- offsetof(struct ec_params_fp_passthru, data) ||
- params->len > args->response_max)
- return EC_RES_INVALID_PARAM;
-
- rc = spi_transaction_async(&spi_devices[0], params->data,
- params->len, out, SPI_READBACK_ALL);
- if (params->flags & EC_FP_FLAG_NOT_COMPLETE)
- rc |= spi_transaction_wait(&spi_devices[0]);
- else
- rc |= spi_transaction_flush(&spi_devices[0]);
-
- if (rc == EC_ERROR_TIMEOUT)
- ret = EC_RES_TIMEOUT;
- else if (rc)
- ret = EC_RES_ERROR;
-
- args->response_size = params->len;
- return ret;
-}
-DECLARE_HOST_COMMAND(EC_CMD_FP_PASSTHRU, fp_command_passthru, EC_VER_MASK(0));
-
-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_sensor_get_info(r) < 0)
-#endif
- return EC_RES_UNAVAILABLE;
-
- 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;
- r->template_version = FP_TEMPLATE_FORMAT_VERSION;
-
- /* V1 is identical to V0 with more information appended */
- args->response_size = args->version ? sizeof(*r) :
- sizeof(struct ec_response_fp_info_v0);
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_FP_INFO, fp_command_info,
- EC_VER_MASK(0) | EC_VER_MASK(1));
-
-BUILD_ASSERT(FP_CONTEXT_NONCE_BYTES == 12);
-
-static int validate_fp_buffer_offset(const uint32_t buffer_size,
- const uint32_t offset, const uint32_t size)
-{
- if (size > buffer_size || offset > buffer_size ||
- size + offset > buffer_size)
- return EC_ERROR_INVAL;
- return EC_SUCCESS;
-}
-
-static enum ec_status fp_command_frame(struct host_cmd_handler_args *args)
-{
- const struct ec_params_fp_frame *params = args->params;
- void *out = args->response;
- uint32_t idx = FP_FRAME_GET_BUFFER_INDEX(params->offset);
- uint32_t offset = params->offset & FP_FRAME_OFFSET_MASK;
- uint32_t size = params->size;
- uint32_t fgr;
- uint8_t key[SBP_ENC_KEY_LEN];
- struct ec_fp_template_encryption_metadata *enc_info;
- int ret;
-
- if (size > args->response_max)
- return EC_RES_INVALID_PARAM;
-
- if (idx == FP_FRAME_INDEX_RAW_IMAGE) {
- /* The host requested a frame. */
- if (system_is_locked())
- return EC_RES_ACCESS_DENIED;
- if (!is_raw_capture(sensor_mode))
- offset += FP_SENSOR_IMAGE_OFFSET;
-
- ret = validate_fp_buffer_offset(sizeof(fp_buffer), offset,
- size);
- if (ret != EC_SUCCESS)
- return EC_RES_INVALID_PARAM;
-
- memcpy(out, fp_buffer + offset, size);
- args->response_size = size;
- return EC_RES_SUCCESS;
- }
-
- /* The host requested a template. */
-
- /* Templates are numbered from 1 in this host request. */
- fgr = idx - FP_FRAME_INDEX_TEMPLATE;
-
- if (fgr >= FP_MAX_FINGER_COUNT)
- return EC_RES_INVALID_PARAM;
- if (fgr >= templ_valid)
- return EC_RES_UNAVAILABLE;
- ret = validate_fp_buffer_offset(sizeof(fp_enc_buffer), offset, size);
- if (ret != EC_SUCCESS)
- return EC_RES_INVALID_PARAM;
-
- if (!offset) {
- /* Host has requested the first chunk, do the encryption. */
- timestamp_t now = get_time();
- /* Encrypted template is after the metadata. */
- uint8_t *encrypted_template = fp_enc_buffer + sizeof(*enc_info);
- /* Positive match salt is after the template. */
- uint8_t *positive_match_salt =
- 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))
- return EC_RES_BUSY;
- encryption_deadline.val = now.val + (1 * SECOND);
-
- memset(fp_enc_buffer, 0, sizeof(fp_enc_buffer));
- /*
- * The beginning of the buffer contains nonce, encryption_salt
- * and tag.
- */
- enc_info = (void *)fp_enc_buffer;
- enc_info->struct_version = FP_TEMPLATE_FORMAT_VERSION;
- init_trng();
- rand_bytes(enc_info->nonce, FP_CONTEXT_NONCE_BYTES);
- rand_bytes(enc_info->encryption_salt,
- FP_CONTEXT_ENCRYPTION_SALT_BYTES);
- exit_trng();
-
- if (fgr == template_newly_enrolled) {
- /*
- * Newly enrolled templates need new positive match
- * salt, new positive match secret and new validation
- * value.
- */
- template_newly_enrolled = FP_NO_SUCH_TEMPLATE;
- init_trng();
- rand_bytes(fp_positive_match_salt[fgr],
- FP_POSITIVE_MATCH_SALT_BYTES);
- exit_trng();
- }
-
- ret = derive_encryption_key(key, enc_info->encryption_salt);
- if (ret != EC_SUCCESS) {
- CPRINTS("fgr%d: Failed to derive key", fgr);
- return EC_RES_UNAVAILABLE;
- }
-
- /*
- * Copy the payload to |fp_enc_buffer| where it will be
- * encrypted in-place.
- */
- 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]));
-
- /* Encrypt the secret blob in-place. */
- ret = aes_gcm_encrypt(key, SBP_ENC_KEY_LEN, encrypted_template,
- encrypted_template,
- encrypted_blob_size,
- enc_info->nonce, FP_CONTEXT_NONCE_BYTES,
- enc_info->tag, FP_CONTEXT_TAG_BYTES);
- always_memset(key, 0, sizeof(key));
- if (ret != EC_SUCCESS) {
- CPRINTS("fgr%d: Failed to encrypt template", fgr);
- return EC_RES_UNAVAILABLE;
- }
- templ_dirty &= ~BIT(fgr);
- }
- memcpy(out, fp_enc_buffer + offset, size);
- args->response_size = size;
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_FP_FRAME, fp_command_frame, EC_VER_MASK(0));
-
-static enum ec_status fp_command_stats(struct host_cmd_handler_args *args)
-{
- struct ec_response_fp_stats *r = args->response;
-
- r->capture_time_us = capture_time_us;
- r->matching_time_us = matching_time_us;
- r->overall_time_us = overall_time_us;
- r->overall_t0.lo = overall_t0.le.lo;
- r->overall_t0.hi = overall_t0.le.hi;
- r->timestamps_invalid = timestamps_invalid;
- /*
- * Note that this is set to FP_NO_SUCH_TEMPLATE when positive match
- * secret is read/disabled, and we are not using this field in biod.
- */
- r->template_matched = positive_match_secret_state.template_matched;
-
- args->response_size = sizeof(*r);
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_FP_STATS, fp_command_stats, EC_VER_MASK(0));
-
-static bool template_needs_validation_value(
- struct ec_fp_template_encryption_metadata *enc_info)
-{
- return enc_info->struct_version == 3
- && FP_TEMPLATE_FORMAT_VERSION == 4;
-}
-
-static int validate_template_format(
- struct ec_fp_template_encryption_metadata *enc_info)
-{
- if (template_needs_validation_value(enc_info))
- /* The host requested migration to v4. */
- return EC_RES_SUCCESS;
-
- if (enc_info->struct_version != FP_TEMPLATE_FORMAT_VERSION) {
- CPRINTS("Invalid template format %d", enc_info->struct_version);
- return EC_RES_INVALID_PARAM;
- }
- return EC_RES_SUCCESS;
-}
-
-static enum ec_status fp_command_template(struct host_cmd_handler_args *args)
-{
- const struct ec_params_fp_template *params = args->params;
- uint32_t size = params->size & ~FP_TEMPLATE_COMMIT;
- int xfer_complete = params->size & FP_TEMPLATE_COMMIT;
- uint32_t offset = params->offset;
- uint32_t idx = templ_valid;
- uint8_t key[SBP_ENC_KEY_LEN];
- struct ec_fp_template_encryption_metadata *enc_info;
- int ret;
-
- /* Can we store one more template ? */
- if (idx >= FP_MAX_FINGER_COUNT)
- return EC_RES_OVERFLOW;
-
- if (args->params_size !=
- size + offsetof(struct ec_params_fp_template, data))
- return EC_RES_INVALID_PARAM;
- ret = validate_fp_buffer_offset(sizeof(fp_enc_buffer), offset, size);
- if (ret != EC_SUCCESS)
- return EC_RES_INVALID_PARAM;
-
- memcpy(&fp_enc_buffer[offset], params->data, size);
-
- if (xfer_complete) {
- /* Encrypted template is after the metadata. */
- uint8_t *encrypted_template = fp_enc_buffer + sizeof(*enc_info);
- /* Positive match salt is after the template. */
- uint8_t *positive_match_salt =
- encrypted_template + sizeof(fp_template[0]);
- size_t encrypted_blob_size;
-
- /*
- * The complete encrypted template has been received, start
- * decryption.
- */
- fp_clear_finger_context(idx);
- /*
- * The beginning of the buffer contains nonce, encryption_salt
- * and tag.
- */
- enc_info = (void *)fp_enc_buffer;
- ret = validate_template_format(enc_info);
- if (ret != EC_RES_SUCCESS) {
- CPRINTS("fgr%d: Template format not supported", idx);
- return EC_RES_INVALID_PARAM;
- }
-
- if (enc_info->struct_version <= 3) {
- encrypted_blob_size = sizeof(fp_template[0]);
- } else {
- encrypted_blob_size =
- sizeof(fp_template[0]) +
- sizeof(fp_positive_match_salt[0]);
- }
-
- ret = derive_encryption_key(key, enc_info->encryption_salt);
- if (ret != EC_SUCCESS) {
- CPRINTS("fgr%d: Failed to derive key", idx);
- return EC_RES_UNAVAILABLE;
- }
-
- /* Decrypt the secret blob in-place. */
- ret = aes_gcm_decrypt(key, SBP_ENC_KEY_LEN, encrypted_template,
- encrypted_template,
- encrypted_blob_size,
- enc_info->nonce, FP_CONTEXT_NONCE_BYTES,
- enc_info->tag, FP_CONTEXT_TAG_BYTES);
- always_memset(key, 0, sizeof(key));
- if (ret != EC_SUCCESS) {
- CPRINTS("fgr%d: Failed to decipher template", idx);
- /* Don't leave bad data in the template buffer */
- fp_clear_finger_context(idx);
- return EC_RES_UNAVAILABLE;
- }
- 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();
- rand_bytes(positive_match_salt,
- FP_POSITIVE_MATCH_SALT_BYTES);
- exit_trng();
- }
- 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], 0,
- sizeof(fp_template[0]));
- return EC_RES_INVALID_PARAM;
- }
- memcpy(fp_positive_match_salt[idx], positive_match_salt,
- sizeof(fp_positive_match_salt[0]));
-
- templ_valid++;
- }
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_FP_TEMPLATE, fp_command_template, EC_VER_MASK(0));
-
-#ifdef CONFIG_CMD_FPSENSOR_DEBUG
-/* --- Debug console commands --- */
-
-/*
- * Send the current Fingerprint buffer to the host
- * it is formatted as an 8-bpp PGM ASCII file.
- *
- * In addition, it prepends a short Z-Modem download signature,
- * which triggers automatically your preferred viewer if you configure it
- * properly in "File transfer protocols" in the Minicom options menu.
- * (as triggered by Ctrl-A O)
- * +--------------------------------------------------------------------------+
- * | Name Program Name U/D FullScr IO-Red. Multi |
- * | A zmodem /usr/bin/sz -vv -b Y U N Y Y |
- * [...]
- * | L pgm /usr/bin/display_pgm N D N Y N |
- * | M Zmodem download string activates... L |
- *
- * My /usr/bin/display_pgm looks like this:
- * #!/bin/sh
- * TMPF=$(mktemp)
- * ascii-xfr -rdv ${TMPF}
- * display ${TMPF}
- *
- * Alternative (if you're using screen as your terminal):
- *
- * From *outside* the chroot:
- *
- * Install ascii-xfr: sudo apt-get install minicom
- * Install imagemagick: sudo apt-get install imagemagick
- *
- * Add the following to your ${HOME}/.screenrc:
- *
- * zmodem catch
- * zmodem recvcmd '!!! bash -c "ascii-xfr -rdv /tmp/finger.pgm && display /tmp/finger.pgm"'
- *
- * From *outside the chroot*, use screen to connect to UART console:
- *
- * sudo screen -c ${HOME}/.screenrc /dev/pts/NN 115200
- *
- */
-static void upload_pgm_image(uint8_t *frame)
-{
- int x, y;
- uint8_t *ptr = frame;
-
- /* fake Z-modem ZRQINIT signature */
- 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_SENSOR_RES_X, FP_SENSOR_RES_Y);
-
- for (y = 0; y < FP_SENSOR_RES_Y; y++) {
- watchdog_reload();
- for (x = 0; x < FP_SENSOR_RES_X; x++, ptr++)
- CPRINTF("%d ", *ptr);
- CPRINTF("\n");
- cflush();
- }
-
- CPRINTF("\x04"); /* End Of Transmission */
-}
-
-static enum ec_error_list fp_console_action(uint32_t mode)
-{
- int tries = 200;
- uint32_t mode_output = 0;
- int rc = 0;
-
- if (!(sensor_mode & FP_MODE_RESET_SENSOR))
- CPRINTS("Waiting for finger ...");
-
- rc = fp_set_sensor_mode(mode, &mode_output);
-
- if (rc != EC_RES_SUCCESS) {
- /*
- * EC host command errors do not directly map to console command
- * errors.
- */
- return EC_ERROR_UNKNOWN;
- }
-
- while (tries--) {
- if (!(sensor_mode & FP_MODE_ANY_CAPTURE)) {
- CPRINTS("done (events:%x)", fp_events);
- return 0;
- }
- usleep(100 * MSEC);
- }
- return EC_ERROR_TIMEOUT;
-}
-
-int command_fpcapture(int argc, char **argv)
-{
- int capture_type = FP_CAPTURE_SIMPLE_IMAGE;
- uint32_t mode;
- enum ec_error_list rc;
-
- /*
- * TODO(b/142944002): Remove this redundant check for system_is_locked
- * once we have unit-tests/integration-tests in place.
- */
- if (system_is_locked())
- return EC_ERROR_ACCESS_DENIED;
-
- if (argc >= 2) {
- char *e;
-
- capture_type = strtoi(argv[1], &e, 0);
- if (*e || capture_type < 0)
- return EC_ERROR_PARAM1;
- }
- mode = FP_MODE_CAPTURE | ((capture_type << FP_MODE_CAPTURE_TYPE_SHIFT)
- & FP_MODE_CAPTURE_TYPE_MASK);
-
- rc = fp_console_action(mode);
- if (rc == EC_SUCCESS)
- upload_pgm_image(fp_buffer + FP_SENSOR_IMAGE_OFFSET);
-
- return rc;
-}
-DECLARE_CONSOLE_COMMAND_FLAGS(fpcapture, command_fpcapture, NULL,
- "Capture fingerprint in PGM format",
- CMD_FLAG_RESTRICTED);
-
-int command_fpenroll(int argc, char **argv)
-{
- enum ec_error_list rc;
- int percent = 0;
- uint32_t event;
- static const char * const enroll_str[] = {"OK", "Low Quality",
- "Immobile", "Low Coverage"};
-
- /*
- * TODO(b/142944002): Remove this redundant check for system_is_locked
- * once we have unit-tests/integration-tests in place.
- */
- if (system_is_locked())
- return EC_ERROR_ACCESS_DENIED;
-
- do {
- int tries = 1000;
-
- rc = fp_console_action(FP_MODE_ENROLL_SESSION |
- FP_MODE_ENROLL_IMAGE);
- if (rc != EC_SUCCESS)
- break;
- event = atomic_read_clear(&fp_events);
- percent = EC_MKBP_FP_ENROLL_PROGRESS(event);
- CPRINTS("Enroll capture: %s (%d%%)",
- enroll_str[EC_MKBP_FP_ERRCODE(event) & 3], percent);
- /* wait for finger release between captures */
- sensor_mode = FP_MODE_ENROLL_SESSION | FP_MODE_FINGER_UP;
- task_set_event(TASK_ID_FPSENSOR, TASK_EVENT_UPDATE_CONFIG, 0);
- while (tries-- && sensor_mode & FP_MODE_FINGER_UP)
- usleep(20 * MSEC);
- } while (percent < 100);
- sensor_mode = 0; /* reset FP_MODE_ENROLL_SESSION */
- task_set_event(TASK_ID_FPSENSOR, TASK_EVENT_UPDATE_CONFIG, 0);
-
- return rc;
-}
-DECLARE_CONSOLE_COMMAND_FLAGS(fpenroll, command_fpenroll, NULL,
- "Enroll a new fingerprint",
- CMD_FLAG_RESTRICTED);
-
-
-int command_fpmatch(int argc, char **argv)
-{
- enum ec_error_list rc = fp_console_action(FP_MODE_MATCH);
- uint32_t event = atomic_read_clear(&fp_events);
-
- if (rc == EC_SUCCESS && event & EC_MKBP_FP_MATCH) {
- uint32_t errcode = EC_MKBP_FP_ERRCODE(event);
-
- CPRINTS("Match: %s (%d)",
- errcode & EC_MKBP_FP_ERR_MATCH_YES ? "YES" : "NO",
- errcode);
- }
-
- return rc;
-}
-DECLARE_CONSOLE_COMMAND(fpmatch, command_fpmatch, NULL,
- "Run match algorithm against finger");
-
-int command_fpclear(int argc, char **argv)
-{
- /*
- * We intentionally run this on the fp_task so that we use the
- * same code path as host commands.
- */
- enum ec_error_list rc = fp_console_action(FP_MODE_RESET_SENSOR);
-
- if (rc < 0)
- CPRINTS("Failed to clear fingerprint context: %d", rc);
-
- atomic_read_clear(&fp_events);
-
- return rc;
-}
-DECLARE_CONSOLE_COMMAND(fpclear, command_fpclear, NULL,
- "Clear fingerprint sensor context");
-
-#endif /* CONFIG_CMD_FPSENSOR_DEBUG */
diff --git a/common/fpsensor/fpsensor_crypto.c b/common/fpsensor/fpsensor_crypto.c
deleted file mode 100644
index 73d7aca681..0000000000
--- a/common/fpsensor/fpsensor_crypto.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/* Copyright 2019 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.
- */
-#include <stdbool.h>
-
-#include "aes.h"
-#include "aes-gcm.h"
-#include "cryptoc/util.h"
-#include "fpsensor_crypto.h"
-#include "fpsensor_private.h"
-#include "fpsensor_state.h"
-#include "rollback.h"
-
-#if !defined(CONFIG_AES) || !defined(CONFIG_AES_GCM) || \
- !defined(CONFIG_ROLLBACK_SECRET_SIZE)
-#error "fpsensor requires AES, AES_GCM and ROLLBACK_SECRET_SIZE"
-#endif
-
-static int get_ikm(uint8_t *ikm)
-{
- int ret;
-
- if (!fp_tpm_seed_is_set()) {
- CPRINTS("Seed hasn't been set.");
- return EC_ERROR_ACCESS_DENIED;
- }
-
- /*
- * The first CONFIG_ROLLBACK_SECRET_SIZE bytes of IKM are read from the
- * anti-rollback blocks.
- */
- ret = rollback_get_secret(ikm);
- if (ret != EC_SUCCESS) {
- CPRINTS("Failed to read rollback secret: %d", ret);
- return EC_ERROR_HW_INTERNAL;
- }
- /*
- * IKM is the concatenation of the rollback secret and the seed from
- * the TPM.
- */
- memcpy(ikm + CONFIG_ROLLBACK_SECRET_SIZE, tpm_seed, sizeof(tpm_seed));
-
- return EC_SUCCESS;
-}
-
-static void hkdf_extract(uint8_t *prk, const uint8_t *salt, size_t salt_size,
- const uint8_t *ikm, size_t ikm_size)
-{
- /*
- * Derive a key with the "extract" step of HKDF
- * https://tools.ietf.org/html/rfc5869#section-2.2
- */
- hmac_SHA256(prk, salt, salt_size, ikm, ikm_size);
-}
-
-static int hkdf_expand_one_step(uint8_t *out_key, size_t out_key_size,
- uint8_t *prk, size_t prk_size,
- uint8_t *info, size_t info_size)
-{
- uint8_t key_buf[SHA256_DIGEST_SIZE];
- uint8_t message_buf[SHA256_DIGEST_SIZE + 1];
-
- if (out_key_size > SHA256_DIGEST_SIZE) {
- CPRINTS("Deriving key material longer than SHA256_DIGEST_SIZE "
- "requires more steps of HKDF expand.");
- return EC_ERROR_INVAL;
- }
-
- if (info_size > SHA256_DIGEST_SIZE) {
- CPRINTS("Info size too big for HKDF.");
- return EC_ERROR_INVAL;
- }
-
- memcpy(message_buf, info, info_size);
- /* 1 step, set the counter byte to 1. */
- message_buf[info_size] = 0x01;
- hmac_SHA256(key_buf, prk, prk_size, message_buf, info_size + 1);
-
- memcpy(out_key, key_buf, out_key_size);
- always_memset(key_buf, 0, sizeof(key_buf));
-
- return EC_SUCCESS;
-}
-
-int hkdf_expand(uint8_t *out_key, size_t L, const uint8_t *prk,
- size_t prk_size, const uint8_t *info, size_t info_size)
-{
- /*
- * "Expand" step of HKDF.
- * https://tools.ietf.org/html/rfc5869#section-2.3
- */
-#define HASH_LEN SHA256_DIGEST_SIZE
- uint8_t count = 1;
- const uint8_t *T = out_key;
- size_t T_len = 0;
- uint8_t T_buffer[HASH_LEN];
- /* Number of blocks. */
- const uint32_t N = DIV_ROUND_UP(L, HASH_LEN);
- uint8_t info_buffer[HASH_LEN + HKDF_MAX_INFO_SIZE + sizeof(count)];
- bool arguments_valid = false;
-
- if (out_key == NULL || L == 0)
- CPRINTS("HKDF expand: output buffer not valid.");
- else if (prk == NULL)
- CPRINTS("HKDF expand: prk is NULL.");
- else if (info == NULL && info_size > 0)
- CPRINTS("HKDF expand: info is NULL but info size is not zero.");
- else if (info_size > HKDF_MAX_INFO_SIZE)
- CPRINTF("HKDF expand: info size larger than %d bytes.\n",
- HKDF_MAX_INFO_SIZE);
- else if (N > HKDF_SHA256_MAX_BLOCK_COUNT)
- CPRINTS("HKDF expand: output key size too large.");
- else
- arguments_valid = true;
-
- if (!arguments_valid)
- return EC_ERROR_INVAL;
-
- while (L > 0) {
- const size_t block_size = L < HASH_LEN ? L : HASH_LEN;
-
- memcpy(info_buffer, T, T_len);
- memcpy(info_buffer + T_len, info, info_size);
- info_buffer[T_len + info_size] = count;
- hmac_SHA256(T_buffer, prk, prk_size, info_buffer,
- T_len + info_size + sizeof(count));
- memcpy(out_key, T_buffer, block_size);
-
- T += T_len;
- T_len = HASH_LEN;
- count++;
- out_key += block_size;
- L -= block_size;
- }
- always_memset(T_buffer, 0, sizeof(T_buffer));
- always_memset(info_buffer, 0, sizeof(info_buffer));
- return EC_SUCCESS;
-#undef HASH_LEN
-}
-
-int derive_positive_match_secret(uint8_t *output,
- const uint8_t *input_positive_match_salt)
-{
- int ret;
- uint8_t ikm[CONFIG_ROLLBACK_SECRET_SIZE + sizeof(tpm_seed)];
- uint8_t prk[SHA256_DIGEST_SIZE];
- static const char info_prefix[] = "positive_match_secret for user ";
- uint8_t info[sizeof(info_prefix) - 1 + sizeof(user_id)];
-
- if (bytes_are_trivial(input_positive_match_salt,
- FP_POSITIVE_MATCH_SALT_BYTES)) {
- CPRINTS("Failed to derive positive match secret: "
- "salt bytes are trivial.");
- return EC_ERROR_INVAL;
- }
-
- ret = get_ikm(ikm);
- if (ret != EC_SUCCESS) {
- CPRINTS("Failed to get IKM: %d", ret);
- return ret;
- }
-
- /* "Extract" step of HKDF. */
- hkdf_extract(prk, input_positive_match_salt,
- FP_POSITIVE_MATCH_SALT_BYTES, ikm, sizeof(ikm));
- always_memset(ikm, 0, sizeof(ikm));
-
- memcpy(info, info_prefix, strlen(info_prefix));
- memcpy(info + strlen(info_prefix), user_id, sizeof(user_id));
-
- /* "Expand" step of HKDF. */
- ret = hkdf_expand(output, FP_POSITIVE_MATCH_SECRET_BYTES, prk,
- sizeof(prk), info, sizeof(info));
- always_memset(prk, 0, sizeof(prk));
-
- /* Check that secret is not full of 0x00 or 0xff. */
- if (bytes_are_trivial(output, FP_POSITIVE_MATCH_SECRET_BYTES)) {
- CPRINTS("Failed to derive positive match secret: "
- "derived secret bytes are trivial.");
- ret = EC_ERROR_HW_INTERNAL;
- }
- return ret;
-}
-
-int derive_encryption_key(uint8_t *out_key, const uint8_t *salt)
-{
- int ret;
- uint8_t ikm[CONFIG_ROLLBACK_SECRET_SIZE + sizeof(tpm_seed)];
- uint8_t prk[SHA256_DIGEST_SIZE];
-
- BUILD_ASSERT(SBP_ENC_KEY_LEN <= SHA256_DIGEST_SIZE);
- BUILD_ASSERT(SBP_ENC_KEY_LEN <= CONFIG_ROLLBACK_SECRET_SIZE);
- BUILD_ASSERT(sizeof(user_id) == SHA256_DIGEST_SIZE);
-
- ret = get_ikm(ikm);
- if (ret != EC_SUCCESS) {
- CPRINTS("Failed to get IKM: %d", ret);
- return ret;
- }
-
- /* "Extract step of HKDF. */
- hkdf_extract(prk, salt, FP_CONTEXT_ENCRYPTION_SALT_BYTES, ikm,
- sizeof(ikm));
- always_memset(ikm, 0, sizeof(ikm));
-
- /*
- * Only 1 "expand" step of HKDF since the size of the "info" context
- * (user_id in our case) is exactly SHA256_DIGEST_SIZE.
- * https://tools.ietf.org/html/rfc5869#section-2.3
- */
- ret = hkdf_expand_one_step(out_key, SBP_ENC_KEY_LEN, prk, sizeof(prk),
- (uint8_t *)user_id, sizeof(user_id));
- always_memset(prk, 0, sizeof(prk));
-
- return ret;
-}
-
-int aes_gcm_encrypt(const uint8_t *key, int key_size,
- const uint8_t *plaintext,
- uint8_t *ciphertext, int text_size,
- const uint8_t *nonce, int nonce_size,
- uint8_t *tag, int tag_size)
-{
- int res;
- AES_KEY aes_key;
- GCM128_CONTEXT ctx;
-
- if (nonce_size != FP_CONTEXT_NONCE_BYTES) {
- CPRINTS("Invalid nonce size %d bytes", nonce_size);
- return EC_ERROR_INVAL;
- }
-
- res = AES_set_encrypt_key(key, 8 * key_size, &aes_key);
- if (res) {
- CPRINTS("Failed to set encryption key: %d", res);
- return EC_ERROR_UNKNOWN;
- }
- CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
- CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
- /* CRYPTO functions return 1 on success, 0 on error. */
- res = CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, ciphertext,
- text_size);
- if (!res) {
- CPRINTS("Failed to encrypt: %d", res);
- return EC_ERROR_UNKNOWN;
- }
- CRYPTO_gcm128_tag(&ctx, tag, tag_size);
- return EC_SUCCESS;
-}
-
-int aes_gcm_decrypt(const uint8_t *key, int key_size, uint8_t *plaintext,
- const uint8_t *ciphertext, int text_size,
- const uint8_t *nonce, int nonce_size,
- const uint8_t *tag, int tag_size)
-{
- int res;
- AES_KEY aes_key;
- GCM128_CONTEXT ctx;
-
- if (nonce_size != FP_CONTEXT_NONCE_BYTES) {
- CPRINTS("Invalid nonce size %d bytes", nonce_size);
- return EC_ERROR_INVAL;
- }
-
- res = AES_set_encrypt_key(key, 8 * key_size, &aes_key);
- if (res) {
- CPRINTS("Failed to set decryption key: %d", res);
- return EC_ERROR_UNKNOWN;
- }
- CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
- CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
- /* CRYPTO functions return 1 on success, 0 on error. */
- res = CRYPTO_gcm128_decrypt(&ctx, &aes_key, ciphertext, plaintext,
- text_size);
- if (!res) {
- CPRINTS("Failed to decrypt: %d", res);
- return EC_ERROR_UNKNOWN;
- }
- res = CRYPTO_gcm128_finish(&ctx, tag, tag_size);
- if (!res) {
- CPRINTS("Found incorrect tag: %d", res);
- return EC_ERROR_UNKNOWN;
- }
- return EC_SUCCESS;
-}
diff --git a/common/fpsensor/fpsensor_private.h b/common/fpsensor/fpsensor_private.h
deleted file mode 100644
index fb97fb3bfd..0000000000
--- a/common/fpsensor/fpsensor_private.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Copyright 2019 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.
- */
-
-/* Internal header file for common/fpsensor directory */
-
-#ifndef __CROS_EC_FPSENSOR_PRIVATE_H
-#define __CROS_EC_FPSENSOR_PRIVATE_H
-
-#define CPRINTF(format, args...) cprintf(CC_FP, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_FP, format, ## args)
-
-#endif /* __CROS_EC_FPSENSOR_PRIVATE_H */
diff --git a/common/fpsensor/fpsensor_state.c b/common/fpsensor/fpsensor_state.c
deleted file mode 100644
index ec4ddb4fd9..0000000000
--- a/common/fpsensor/fpsensor_state.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/* Copyright 2019 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.
- */
-
-#include "common.h"
-#include "cryptoc/util.h"
-#include "ec_commands.h"
-#include "fpsensor.h"
-#include "fpsensor_crypto.h"
-#include "fpsensor_private.h"
-#include "fpsensor_state.h"
-#include "host_command.h"
-#include "system.h"
-#include "task.h"
-#include "util.h"
-
-/* Last acquired frame (aligned as it is used by arbitrary binary libraries) */
-uint8_t fp_buffer[FP_SENSOR_IMAGE_SIZE] FP_FRAME_SECTION __aligned(4);
-/* Fingers templates for the current user */
-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_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];
-
-struct positive_match_secret_state positive_match_secret_state = {
- .template_matched = FP_NO_SUCH_TEMPLATE,
- .readable = false,
- .deadline.val = 0,
-};
-
-/* Index of the last enrolled but not retrieved template. */
-int8_t template_newly_enrolled = FP_NO_SUCH_TEMPLATE;
-/* Number of used templates */
-uint32_t templ_valid;
-/* Bitmap of the templates with local modifications */
-uint32_t templ_dirty;
-/* Current user ID */
-uint32_t user_id[FP_CONTEXT_USERID_WORDS];
-/* Part of the IKM used to derive encryption keys received from the TPM. */
-uint8_t tpm_seed[FP_CONTEXT_TPM_BYTES];
-/* Status of the FP encryption engine. */
-static uint32_t fp_encryption_status;
-
-uint32_t fp_events;
-
-uint32_t sensor_mode;
-
-void fp_task_simulate(void)
-{
- int timeout_us = -1;
-
- while (1)
- task_wait_event(timeout_us);
-}
-
-void fp_clear_finger_context(int idx)
-{
- always_memset(fp_template[idx], 0, sizeof(fp_template[0]));
- always_memset(fp_positive_match_salt[idx], 0,
- sizeof(fp_positive_match_salt[0]));
-}
-
-/**
- * @warning |fp_buffer| contains data used by the matching algorithm that must
- * be released by calling fp_sensor_deinit() first. Call
- * fp_reset_and_clear_context instead of calling this directly.
- */
-static void _fp_clear_context(void)
-{
- int idx;
-
- templ_valid = 0;
- templ_dirty = 0;
- always_memset(fp_buffer, 0, sizeof(fp_buffer));
- always_memset(fp_enc_buffer, 0, sizeof(fp_enc_buffer));
- always_memset(user_id, 0, sizeof(user_id));
- fp_disable_positive_match_secret(&positive_match_secret_state);
- for (idx = 0; idx < FP_MAX_FINGER_COUNT; idx++)
- fp_clear_finger_context(idx);
-}
-
-void fp_reset_and_clear_context(void)
-{
- if (fp_sensor_deinit() != EC_SUCCESS)
- CPRINTS("Failed to deinit sensor");
- _fp_clear_context();
- if (fp_sensor_init() != EC_SUCCESS)
- CPRINTS("Failed to init sensor");
-}
-
-int fp_get_next_event(uint8_t *out)
-{
- uint32_t event_out = atomic_read_clear(&fp_events);
-
- memcpy(out, &event_out, sizeof(event_out));
-
- return sizeof(event_out);
-}
-DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_FINGERPRINT, fp_get_next_event);
-
-static enum ec_status fp_command_tpm_seed(struct host_cmd_handler_args *args)
-{
- const struct ec_params_fp_seed *params = args->params;
-
- if (params->struct_version != FP_TEMPLATE_FORMAT_VERSION) {
- CPRINTS("Invalid seed format %d", params->struct_version);
- return EC_RES_INVALID_PARAM;
- }
-
- if (fp_encryption_status & FP_ENC_STATUS_SEED_SET) {
- CPRINTS("Seed has already been set.");
- return EC_RES_ACCESS_DENIED;
- }
- memcpy(tpm_seed, params->seed, sizeof(tpm_seed));
- fp_encryption_status |= FP_ENC_STATUS_SEED_SET;
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_FP_SEED, fp_command_tpm_seed, EC_VER_MASK(0));
-
-int fp_tpm_seed_is_set(void)
-{
- return fp_encryption_status & FP_ENC_STATUS_SEED_SET;
-}
-
-static enum ec_status
-fp_command_encryption_status(struct host_cmd_handler_args *args)
-{
- struct ec_response_fp_encryption_status *r = args->response;
-
- r->valid_flags = FP_ENC_STATUS_SEED_SET;
- r->status = fp_encryption_status;
- args->response_size = sizeof(*r);
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_FP_ENC_STATUS, fp_command_encryption_status,
- EC_VER_MASK(0));
-
-static int validate_fp_mode(const uint32_t mode)
-{
- uint32_t capture_type = FP_CAPTURE_TYPE(mode);
- uint32_t algo_mode = mode & ~FP_MODE_CAPTURE_TYPE_MASK;
- uint32_t cur_mode = sensor_mode;
-
- if (capture_type >= FP_CAPTURE_TYPE_MAX)
- return EC_ERROR_INVAL;
-
- if (algo_mode & ~FP_VALID_MODES)
- return EC_ERROR_INVAL;
-
- if ((mode & FP_MODE_ENROLL_SESSION) &&
- templ_valid >= FP_MAX_FINGER_COUNT) {
- CPRINTS("Maximum number of fingers already enrolled: %d",
- FP_MAX_FINGER_COUNT);
- return EC_ERROR_INVAL;
- }
-
- /* Don't allow sensor reset if any other mode is
- * set (including FP_MODE_RESET_SENSOR itself).
- */
- if (mode & FP_MODE_RESET_SENSOR) {
- if (cur_mode & FP_VALID_MODES)
- return EC_ERROR_INVAL;
- }
-
- return EC_SUCCESS;
-}
-
-int fp_set_sensor_mode(uint32_t mode, uint32_t *mode_output)
-{
- int ret;
-
- if (mode_output == NULL)
- return EC_RES_INVALID_PARAM;
-
- ret = validate_fp_mode(mode);
- if (ret != EC_SUCCESS) {
- CPRINTS("Invalid FP mode 0x%x", mode);
- return EC_RES_INVALID_PARAM;
- }
-
- if (!(mode & FP_MODE_DONT_CHANGE)) {
- sensor_mode = mode;
- task_set_event(TASK_ID_FPSENSOR, TASK_EVENT_UPDATE_CONFIG, 0);
- }
-
- *mode_output = sensor_mode;
- return EC_RES_SUCCESS;
-}
-
-static enum ec_status fp_command_mode(struct host_cmd_handler_args *args)
-{
- const struct ec_params_fp_mode *p = args->params;
- struct ec_response_fp_mode *r = args->response;
-
- int ret = fp_set_sensor_mode(p->mode, &r->mode);
-
- if (ret == EC_RES_SUCCESS)
- args->response_size = sizeof(*r);
-
- return ret;
-}
-DECLARE_HOST_COMMAND(EC_CMD_FP_MODE, fp_command_mode, EC_VER_MASK(0));
-
-static enum ec_status fp_command_context(struct host_cmd_handler_args *args)
-{
- const struct ec_params_fp_context_v1 *p = args->params;
- uint32_t mode_output;
-
- switch (p->action) {
- case FP_CONTEXT_ASYNC:
- if (sensor_mode & FP_MODE_RESET_SENSOR)
- return EC_RES_BUSY;
-
- /**
- * Trigger a call to fp_reset_and_clear_context() by
- * requesting a reset. Since that function triggers a call to
- * fp_sensor_open(), this must be asynchronous because
- * fp_sensor_open() can take ~175 ms. See http://b/137288498.
- */
- return fp_set_sensor_mode(FP_MODE_RESET_SENSOR, &mode_output);
-
- case FP_CONTEXT_GET_RESULT:
- if (sensor_mode & FP_MODE_RESET_SENSOR)
- return EC_RES_BUSY;
-
- memcpy(user_id, p->userid, sizeof(user_id));
- return EC_RES_SUCCESS;
- }
-
- return EC_RES_INVALID_PARAM;
-}
-DECLARE_HOST_COMMAND(EC_CMD_FP_CONTEXT, fp_command_context, EC_VER_MASK(1));
-
-int fp_enable_positive_match_secret(uint32_t fgr,
- struct positive_match_secret_state *state)
-{
- timestamp_t now;
-
- if (state->readable) {
- CPRINTS("Error: positive match secret already readable.");
- fp_disable_positive_match_secret(state);
- return EC_ERROR_UNKNOWN;
- }
-
- now = get_time();
- state->template_matched = fgr;
- state->readable = true;
- state->deadline.val = now.val + (5 * SECOND);
- return EC_SUCCESS;
-}
-
-void fp_disable_positive_match_secret(
- struct positive_match_secret_state *state)
-{
- state->template_matched = FP_NO_SUCH_TEMPLATE;
- state->readable = false;
- state->deadline.val = 0;
-}
-
-static enum ec_status fp_command_read_match_secret(
- struct host_cmd_handler_args *args)
-{
- const struct ec_params_fp_read_match_secret *params = args->params;
- struct ec_response_fp_read_match_secret *response = args->response;
- int8_t fgr = params->fgr;
- timestamp_t now = get_time();
- struct positive_match_secret_state state_copy
- = positive_match_secret_state;
-
- fp_disable_positive_match_secret(&positive_match_secret_state);
-
- if (fgr < 0 || fgr >= FP_MAX_FINGER_COUNT) {
- CPRINTS("Invalid finger number %d", fgr);
- return EC_RES_INVALID_PARAM;
- }
- if (timestamp_expired(state_copy.deadline, &now)) {
- CPRINTS("Reading positive match secret disallowed: "
- "deadline has passed.");
- return EC_RES_TIMEOUT;
- }
- if (fgr != state_copy.template_matched || !state_copy.readable) {
- CPRINTS("Positive match secret for finger %d is not meant to "
- "be read now.", fgr);
- return EC_RES_ACCESS_DENIED;
- }
-
- if (derive_positive_match_secret(response->positive_match_secret,
- fp_positive_match_salt[fgr])
- != EC_SUCCESS) {
- CPRINTS("Failed to derive positive match secret for finger %d",
- fgr);
- /* Keep the template and encryption salt. */
- return EC_RES_ERROR;
- }
- CPRINTS("Derived positive match secret for finger %d", fgr);
- args->response_size = sizeof(*response);
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_FP_READ_MATCH_SECRET, fp_command_read_match_secret,
- EC_VER_MASK(0));
diff --git a/driver/build.mk b/driver/build.mk
index db6949f8ca..a98eaa763c 100644
--- a/driver/build.mk
+++ b/driver/build.mk
@@ -75,9 +75,6 @@ driver-$(CONFIG_CHARGER_RT9466)+=charger/rt946x.o
driver-$(CONFIG_CHARGER_RT9467)+=charger/rt946x.o
driver-$(CONFIG_CHARGER_SY21612)+=charger/sy21612.o
-# Fingerprint Sensors
-include $(_driver_cur_dir)fingerprint/build.mk
-
# I/O expander
driver-$(CONFIG_IO_EXPANDER_IT8801)+=ioexpander/it8801.o
driver-$(CONFIG_IO_EXPANDER_PCA9534)+=ioexpander/pca9534.o
diff --git a/driver/fingerprint/build.mk b/driver/fingerprint/build.mk
deleted file mode 100644
index 862fa29914..0000000000
--- a/driver/fingerprint/build.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2019 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.
-
-# Build fingerprint drivers
-
-# Note that this variable includes the trailing "/"
-_fingerprint_cur_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
-
-include $(_fingerprint_cur_dir)fpc/build.mk
diff --git a/driver/fingerprint/fpc/bep/build.mk b/driver/fingerprint/fpc/bep/build.mk
deleted file mode 100644
index ac7f05fb60..0000000000
--- a/driver/fingerprint/fpc/bep/build.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2019 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.
-
-# FPC BEP source files build
-
-# Note that this variable includes the trailing "/"
-_bep_cur_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
-
-# Make sure output directory is created (in build directory)
-dirs-y+="$(_bep_cur_dir)"
-
-# Only build for these objects for the RW image
-all-obj-rw+=$(_bep_cur_dir)fpc_misc.o \
- $(_bep_cur_dir)fpc_private.o \
- $(_bep_cur_dir)fpc_sensor_spi.o \
- $(_bep_cur_dir)fpc_timebase.o
diff --git a/driver/fingerprint/fpc/bep/fpc1025_private.h b/driver/fingerprint/fpc/bep/fpc1025_private.h
deleted file mode 100644
index 2da127741f..0000000000
--- a/driver/fingerprint/fpc/bep/fpc1025_private.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright 2019 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.
- */
-
-#ifndef __CROS_EC_FPC1025_PRIVATE_H
-#define __CROS_EC_FPC1025_PRIVATE_H
-
-/* The 16-bit hardware ID is 0x021y */
-#define FP_SENSOR_HWID 0x021
-
-/* Sensor type name */
-#define FP_SENSOR_NAME "FPC1025"
-
-/* Sensor pixel resolution */
-#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 */
-
-/*
- * Sensor image size
- *
- * Value from fpc_bep_image_get_buffer_size(): (160*160)+660
- */
-#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)
-
-/*
- * Constant value for the enrollment data size
- *
- * Size of private fp_bio_enrollment_t
- */
-#define FP_ALGORITHM_ENROLLMENT_SIZE (4)
-
-/*
- * Constant value corresponding to the maximum template size
- * for FPC1025 sensor. Client template memory allocation must
- * have this size. This includes extra memory for template update.
- *
- * Template size + alignment padding + size of template size variable
- */
-#define FP_ALGORITHM_TEMPLATE_SIZE (5088 + 0 + 4)
-
-/* Max number of templates stored / matched against */
-#define FP_MAX_FINGER_COUNT (5)
-
-#endif /* __CROS_EC_FPC1025_PRIVATE_H */
diff --git a/driver/fingerprint/fpc/bep/fpc1035_private.h b/driver/fingerprint/fpc/bep/fpc1035_private.h
deleted file mode 100644
index 695228898b..0000000000
--- a/driver/fingerprint/fpc/bep/fpc1035_private.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright 2019 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.
- */
-
-#ifndef __CROS_EC_FPC1035_PRIVATE_H
-#define __CROS_EC_FPC1035_PRIVATE_H
-
-/* The 16-bit hardware ID is 0x011y */
-#define FP_SENSOR_HWID 0x011
-
-/* Sensor type name */
-#define FP_SENSOR_NAME "FPC1035"
-
-/* Sensor pixel resolution */
-#define FP_SENSOR_RES_X (112) /**< Sensor width */
-#define FP_SENSOR_RES_Y (88) /**< Sensor height */
-#define FP_SENSOR_RES_BPP (8) /**< Resolution bits per pixel */
-
-/*
- * Sensor image size
- *
- * Value from fpc_bep_image_get_buffer_size(): (112*88)+660
- */
-#define FP_SENSOR_IMAGE_SIZE (10516)
-#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)
-
-/*
- * Constant value for the enrollment data size
- *
- * Size of private fp_bio_enrollment_t
- */
-#define FP_ALGORITHM_ENROLLMENT_SIZE (4)
-
-/*
- * Constant value corresponding to the maximum template size
- * for FPC1035 sensor. Client template memory allocation must
- * have this size. This includes extra memory for template update.
- *
- * Template size + alignment padding + size of template size variable
- */
-#define FP_ALGORITHM_TEMPLATE_SIZE (14373 + 3 + 4)
-
-/* Max number of templates stored / matched against */
-#define FP_MAX_FINGER_COUNT (5)
-
-#endif /* __CROS_EC_FPC1035_PRIVATE_H */
diff --git a/driver/fingerprint/fpc/bep/fpc_bio_algorithm.h b/driver/fingerprint/fpc/bep/fpc_bio_algorithm.h
deleted file mode 100644
index 1bf598a3ee..0000000000
--- a/driver/fingerprint/fpc/bep/fpc_bio_algorithm.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright 2019 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.
- */
-
-#ifndef __CROS_EC_FPC_BIO_ALGORITHM_H
-#define __CROS_EC_FPC_BIO_ALGORITHM_H
-
-#include <stdint.h>
-
-/*
- * An opaque pointer representing an image (scan).
- */
-typedef void *bio_image_t;
-/*
- * An opaque pointer representing/uniquely identifying an (serialized) enrolled
- * template.
- */
-typedef void *bio_template_t;
-/*
- * An opaque pointer representing/uniquely identifying enrollment attempt.
- */
-typedef void *bio_enrollment_t;
-/*
- * An opaque struct representing algorithm.
- */
-typedef struct fpc_bep_algorithm fpc_bep_algorithm_t;
-/*
- * Struct with biometric algorithm information.
- */
-typedef struct {
- const fpc_bep_algorithm_t *algorithm;
- uint32_t template_size;
-} fpc_bio_info_t;
-/*
- * Initializes biometric algorithm library. Should be the very first function
- * to be invoked by the biometric daemon.
- *
- * Returns 0 on success, negative error code (such as -ENOMEM) on failure.
- */
-int bio_algorithm_init(void);
-/*
- * Instructs the biometric library to release all resources in preparation
- * for the process termination (or unloading the library). Regardless of
- * the returned error code the action is considered unrecoverable.
- *
- * Returns 0 on success, negative error code (such as -ENOMEM) on failure.
- */
-int bio_algorithm_exit(void);
-/*
- * Compares given biometric image against a list of enrolled template(s).
- * In case the image match a template the match_index will indicate which
- * template in the list that matched.
- * The algorithm library can update templates with additional biometric data
- * from the image, if it chooses to do so. The updated template(s) will be
- * indicated by the out parameter 'updated_templates', a bit-field where
- * updated template(s) indicated by the corresponding bit being set
- * Returns:
- * - negative value on error
- * - BIO_TEMPLATE_NO_MATCH on non-match
- * - BIO_TEMPLATE_MATCH for match when template was not updated with new data
- * - BIO_TEMPLATE_MATCH_UPDATED for match when template was updated
- * - BIO_TEMPLATE_MATCH_UPDATE_FAILED match, but update failed (do not save)
- * - BIO_TEMPLATE_LOW_QUALITY when matching could not be performed due to low
- * image quality
- * - BIO_TEMPLATE_LOW_COVERAGE when matching could not be performed due to
- * finger covering too little area of the sensor
- */
-#define BIO_TEMPLATE_NO_MATCH 0
-#define BIO_TEMPLATE_MATCH 1
-#define BIO_TEMPLATE_MATCH_UPDATED 3
-#define BIO_TEMPLATE_MATCH_UPDATE_FAILED 5
-#define BIO_TEMPLATE_LOW_QUALITY 2
-#define BIO_TEMPLATE_LOW_COVERAGE 4
-
-int bio_template_image_match_list(bio_template_t templ, uint32_t num_templ,
- bio_image_t image, int32_t *match_index,
- uint32_t *updated_templ);
-/*
- * Initiates biometric data enrollment process. Algorithm library returns
- * 'enrollment handle' that is used for all subsequent enrollment operations.
- *
- * Returns 0 on success, negative error code (such as -ENOMEM) on failure.
- */
-int bio_enrollment_begin(bio_enrollment_t *enrollment);
-/*
- * Adds fingerprint image to an enrollment.
- *
- * The library should expect to copy any relevant data from the “image”
- * as it is likely to be destroyed (via bio_image_destroy() call) shortly after
- * this call completes.
- *
- * Returns:
- * - negative value on error
- * - BIO_ENROLLMENT_OK when image was successfully enrolled
- * - BIO_ENROLLMENT_LOW_QUALITY when image could not be used due to low
- * image quality
- * - BIO_ENROLLMENT_IMMOBILE when image added, but user should be advised
- * to move finger
- * - BIO_ENROLLMENT_LOW_COVERAGE when image could not be used due to
- * finger covering too little area of the sensor
- * - BIO_ENROLLMENT_INTERNAL_ERROR when an internal error occurred
- */
-#define BIO_ENROLLMENT_OK 0
-#define BIO_ENROLLMENT_LOW_QUALITY 1
-#define BIO_ENROLLMENT_IMMOBILE 2
-#define BIO_ENROLLMENT_LOW_COVERAGE 3
-#define BIO_ENROLLMENT_INTERNAL_ERROR 5
-
-/* Can be used to detect if image was usable for enrollment or not. */
-#define BIO_ENROLLMENT_PROBLEM_MASK 1
-int bio_enrollment_add_image(bio_enrollment_t enrollment, bio_image_t image);
-/*
- * Returns percent of coverage accumulated during enrollment process.
- * Optional method. Regardless of value returned by this call user should call
- * bio_enrollment_is_complete() to check if algorithm library accumulated enough
- * data to create a template.
- *
- * Returns value in the range 0..100, or negative error (such as -EINVAL);
- */
-int bio_enrollment_get_percent_complete(bio_enrollment_t enrollment);
-/*
- * Indicates that given enrollment process is complete, and algorithm library
- * should generate an active template that can be used in subsequent calls
- * to bio_image_match() and bio_template_serialize() from enrollment data.
- * After the template is created the library should release all resources
- * associated with this enrollment.
- *
- * Argument 'templ' is optional and can be set to NULL if caller wishes to
- * abort enrollment process.
- *
- * Returns 0 on success, negative error code (such as -EINVAL) on failure.
- */
-int bio_enrollment_finish(bio_enrollment_t enrollment, bio_template_t *templ);
-
-#endif /* __CROS_EC_FPC_BIO_ALGORITHM_H */
diff --git a/driver/fingerprint/fpc/bep/fpc_misc.c b/driver/fingerprint/fpc/bep/fpc_misc.c
deleted file mode 100644
index c4c779b702..0000000000
--- a/driver/fingerprint/fpc/bep/fpc_misc.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright 2019 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.
- */
-
-/* FPC Platform Abstraction Layer */
-
-#include <stdint.h>
-#include <stddef.h>
-
-#include "shared_mem.h"
-#include "uart.h"
-
-void __unused *fpc_malloc(uint32_t size)
-{
- char *data;
- int rc;
-
- rc = shared_mem_acquire(size, (char **)&data);
-
- if (rc == 0)
- return data;
- else
- return NULL;
-}
-
-void __unused fpc_free(void *data)
-{
- shared_mem_release(data);
-}
-
-/* Not in release */
-void __unused fpc_assert_fail(const char *file, uint32_t line, const char *func,
- const char *expr)
-{
-}
-
-void __unused fpc_log_var(const char *source, uint8_t level, const char *format,
- ...)
-{
- va_list args;
-
- va_start(args, format);
- uart_vprintf(format, args);
- va_end(args);
-}
-
-uint32_t abs(int32_t a)
-{
- return (a < 0) ? (uint32_t)(-a) : (uint32_t)a;
-}
diff --git a/driver/fingerprint/fpc/bep/fpc_private.c b/driver/fingerprint/fpc/bep/fpc_private.c
deleted file mode 100644
index 9bcd4f65ff..0000000000
--- a/driver/fingerprint/fpc/bep/fpc_private.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/* Copyright 2019 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.
- */
-
-#include <stdint.h>
-#include <stddef.h>
-
-#include "fpc_bio_algorithm.h"
-#include "fpsensor.h"
-#include "spi.h"
-#include "system.h"
-#include "util.h"
-
-#include "driver/fingerprint/fpc/fpc_sensor.h"
-
-/* Console output macros */
-#define CPRINTF(format, args...) cprintf(CC_FP, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_FP, format, ## args)
-
-static uint8_t enroll_ctx[FP_ALGORITHM_ENROLLMENT_SIZE] = {0};
-
-/* Recorded error flags */
-static uint16_t errors;
-
-/* FPC specific initialization and de-initialization functions */
-int fp_sensor_open(void);
-int fp_sensor_close(void);
-
-/* Get FPC library version code.*/
-const char *fp_sensor_get_version(void);
-
-/* Get FPC library build info.*/
-const char *fp_sensor_get_build_info(void);
-
-/* Sensor description */
-static struct ec_response_fp_info ec_fp_sensor_info = {
- /* Sensor identification */
- .vendor_id = FOURCC('F', 'P', 'C', ' '),
- .product_id = 9,
- .model_id = 1,
- .version = 1,
- /* Image frame characteristics */
- .frame_size = FP_SENSOR_IMAGE_SIZE,
- .pixel_format = V4L2_PIX_FMT_GREY,
- .width = FP_SENSOR_RES_X,
- .height = FP_SENSOR_RES_Y,
- .bpp = FP_SENSOR_RES_BPP,
-};
-
-typedef struct fpc_bep_sensor fpc_bep_sensor_t;
-
-typedef struct {
- const fpc_bep_sensor_t *sensor;
- uint32_t image_buffer_size;
-} fpc_sensor_info_t;
-
-#if defined(CONFIG_FP_SENSOR_FPC1025)
-
-extern const fpc_bep_sensor_t fpc_bep_sensor_1025;
-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,
-};
-
-const fpc_bio_info_t fpc_bio_info = {
- .algorithm = &fpc_bep_algorithm_pfe_1025,
- .template_size = FP_ALGORITHM_TEMPLATE_SIZE,
-};
-
-#elif defined(CONFIG_FP_SENSOR_FPC1035)
-
-extern const fpc_bep_sensor_t fpc_bep_sensor_1035;
-extern const fpc_bep_algorithm_t fpc_bep_algorithm_pfe_1035;
-
-const fpc_sensor_info_t fpc_sensor_info = {
- .sensor = &fpc_bep_sensor_1035,
- .image_buffer_size = FP_SENSOR_IMAGE_SIZE,
-};
-
-const fpc_bio_info_t fpc_bio_info = {
- .algorithm = &fpc_bep_algorithm_pfe_1035,
- .template_size = FP_ALGORITHM_TEMPLATE_SIZE,
-};
-#else
-#error "Sensor type not defined!"
-#endif
-
-/* Sensor IC commands */
-enum fpc_cmd {
- FPC_CMD_DEEPSLEEP = 0x2C,
- FPC_CMD_HW_ID = 0xFC,
-};
-
-/* Maximum size of a sensor command SPI transfer */
-#define MAX_CMD_SPI_TRANSFER_SIZE 3
-
-/* Memory for the SPI transfer buffer */
-static uint8_t spi_buf[MAX_CMD_SPI_TRANSFER_SIZE];
-
-static int fpc_send_cmd(const uint8_t cmd)
-{
- spi_buf[0] = cmd;
-
- return spi_transaction(SPI_FP_DEVICE, spi_buf, 1, spi_buf,
- SPI_READBACK_ALL);
-}
-
-void fp_sensor_low_power(void)
-{
- fpc_send_cmd(FPC_CMD_DEEPSLEEP);
-}
-
-static int fpc_check_hwid(void)
-{
- uint16_t id;
- int rc;
-
- spi_buf[0] = FPC_CMD_HW_ID;
-
- rc = spi_transaction(SPI_FP_DEVICE, spi_buf, 3, spi_buf,
- SPI_READBACK_ALL);
- if (rc) {
- CPRINTS("FPC HW ID read failed %d", rc);
- return FP_ERROR_SPI_COMM;
- }
-
- id = (spi_buf[1] << 8) | spi_buf[2];
- if ((id >> 4) != FP_SENSOR_HWID) {
- CPRINTS("FPC unknown silicon 0x%04x", id);
- return FP_ERROR_BAD_HWID;
- }
- CPRINTS(FP_SENSOR_NAME " id 0x%04x", id);
-
- return EC_SUCCESS;
-}
-
-/* Reset and initialize the sensor IC */
-int fp_sensor_init(void)
-{
- int rc;
-
- /* Print the binary libfpbep.a library version */
- CPRINTS("FPC libfpbep.a %s", fp_sensor_get_version());
-
- /* Print the BEP version and build time of the library */
- CPRINTS("Build information - %s", fp_sensor_get_build_info());
-
- rc = fp_sensor_open();
- if (rc) {
- errors |= FP_ERROR_INIT_FAIL;
- CPRINTS("Error: fp_sensor_open() failed, result=%d", rc);
- }
-
- errors |= fpc_check_hwid();
-
- rc = bio_algorithm_init();
- if (rc < 0) {
- errors |= FP_ERROR_INIT_FAIL;
- CPRINTS("Error: bio_algorithm_init() failed, result=%d", rc);
- }
-
- /* Go back to low power */
- fp_sensor_low_power();
-
- return EC_SUCCESS;
-}
-
-/* Deinitialize the sensor IC */
-int fp_sensor_deinit(void)
-{
- int rc;
-
- rc = bio_algorithm_exit();
- if (rc < 0)
- CPRINTS("Error: bio_algorithm_exit() failed, result=%d", rc);
-
- rc = fp_sensor_close();
- if (rc < 0)
- CPRINTS("Error: fp_sensor_close() failed, result=%d", rc);
-
- return rc;
-}
-
-int fp_sensor_get_info(struct ec_response_fp_info *resp)
-{
- int rc;
-
- spi_buf[0] = FPC_CMD_HW_ID;
-
- memcpy(resp, &ec_fp_sensor_info, sizeof(struct ec_response_fp_info));
-
- rc = spi_transaction(SPI_FP_DEVICE, spi_buf, 3, spi_buf,
- SPI_READBACK_ALL);
- if (rc)
- return EC_RES_ERROR;
-
- resp->model_id = (spi_buf[1] << 8) | spi_buf[2];
- resp->errors = errors;
-
- return EC_SUCCESS;
-}
-
-int fp_finger_match(void *templ, uint32_t templ_count, uint8_t *image,
- int32_t *match_index, uint32_t *update_bitmap)
-{
- int rc;
-
- rc = bio_template_image_match_list(templ, templ_count, image,
- match_index, update_bitmap);
- if (rc < 0)
- CPRINTS("Error: bio_template_image_match_list() failed, result=%d",
- rc);
-
- return rc;
-}
-
-int fp_enrollment_begin(void)
-{
- int rc;
- bio_enrollment_t bio_enroll = enroll_ctx;
-
- rc = bio_enrollment_begin(&bio_enroll);
- if (rc < 0)
- CPRINTS("Error: bio_enrollment_begin() failed, result=%d", rc);
-
- return rc;
-}
-
-int fp_enrollment_finish(void *templ)
-{
- int rc;
- bio_enrollment_t bio_enroll = enroll_ctx;
- bio_template_t bio_templ = templ;
-
- rc = bio_enrollment_finish(bio_enroll, templ ? &bio_templ : NULL);
- if (rc < 0)
- CPRINTS("Error: bio_enrollment_finish() failed, result=%d", rc);
-
- return rc;
-}
-
-int fp_finger_enroll(uint8_t *image, int *completion)
-{
- int rc;
- bio_enrollment_t bio_enroll = enroll_ctx;
-
- rc = bio_enrollment_add_image(bio_enroll, image);
- if (rc < 0) {
- CPRINTS("Error: bio_enrollment_add_image() failed, result=%d",
- rc);
- return rc;
- }
-
- *completion = bio_enrollment_get_percent_complete(bio_enroll);
-
- return rc;
-}
diff --git a/driver/fingerprint/fpc/bep/fpc_sensor_spi.c b/driver/fingerprint/fpc/bep/fpc_sensor_spi.c
deleted file mode 100644
index 225752bdb6..0000000000
--- a/driver/fingerprint/fpc/bep/fpc_sensor_spi.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Copyright 2019 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.
- */
-
-/* FPC Platform Abstraction Layer */
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-#include "console.h"
-#include "fpsensor.h"
-#include "fpc_sensor_spi.h"
-#include "gpio.h"
-#include "spi.h"
-#include "util.h"
-
-#include "driver/fingerprint/fpc/fpc_sensor.h"
-
-/* Console output macros */
-#define CPRINTF(format, args...) cprintf(CC_FP, format, ##args)
-#define CPRINTS(format, args...) cprints(CC_FP, format, ##args)
-
-#define SPI_BUF_SIZE (1024)
-
-#define FPC_RESULT_OK (0)
-#define FPC_RESULT_IO_ERROR (-8)
-
-static uint8_t spi_buf[SPI_BUF_SIZE] FP_FRAME_SECTION __aligned(4);
-
-int __unused fpc_sensor_spi_write_read(uint8_t *write, uint8_t *read,
- size_t size, bool leave_cs_asserted)
-{
- int rc = 0;
-
- if (size == FP_SENSOR_REAL_IMAGE_SIZE) {
- rc |= spi_transaction(SPI_FP_DEVICE, write, size, read,
- SPI_READBACK_ALL);
- spi_transaction_flush(SPI_FP_DEVICE);
- } else if (size <= SPI_BUF_SIZE) {
- memcpy(spi_buf, write, size);
- rc |= spi_transaction_async(SPI_FP_DEVICE, spi_buf, size,
- spi_buf, SPI_READBACK_ALL);
-
- /* De-asserting the sensor chip-select will clear the sensor
- * internal command state. To run multiple sensor transactions
- * in the same command state (typically image capture), leave
- * chip-select asserted. Make sure chip-select is de-asserted
- * when all transactions are finished.
- */
- if (!leave_cs_asserted)
- spi_transaction_flush(SPI_FP_DEVICE);
- else
- spi_transaction_wait(SPI_FP_DEVICE);
-
- memcpy(read, spi_buf, size);
- } else {
- rc = -1;
- }
-
- if (rc == 0) {
- return FPC_RESULT_OK;
- } else {
- CPRINTS("Error: spi_transaction()/spi_transaction_async() failed, result=%d",
- rc);
- return FPC_RESULT_IO_ERROR;
- }
-}
-
-bool __unused fpc_sensor_spi_check_irq(void)
-{
- return (gpio_get_level(GPIO_FPS_INT) == 1);
-}
-
-bool __unused fpc_sensor_spi_read_irq(void)
-{
- return (gpio_get_level(GPIO_FPS_INT) == 1);
-}
-
-void __unused fpc_sensor_spi_reset(bool state)
-{
- gpio_set_level(GPIO_FP_RST_ODL, state ? 0 : 1);
-}
-
-void __unused fpc_sensor_spi_init(uint32_t speed_hz)
-{
-}
-
-int __unused fpc_sensor_wfi(uint16_t timeout_ms, fpc_wfi_check_t enter_wfi,
- bool enter_wfi_mode)
-{
- return FPC_RESULT_OK;
-}
diff --git a/driver/fingerprint/fpc/bep/fpc_sensor_spi.h b/driver/fingerprint/fpc/bep/fpc_sensor_spi.h
deleted file mode 100644
index 4b9bcd63a8..0000000000
--- a/driver/fingerprint/fpc/bep/fpc_sensor_spi.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright 2019 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.
- */
-
-#ifndef __CROS_EC_FPC_SENSOR_SPI_H
-#define __CROS_EC_FPC_SENSOR_SPI_H
-
-/**
- * @file fpc_sensor_spi.h
- * @brief Driver for SPI master.
- *
- * Driver for SPI master. Intended for communication with fingerprint sensor.
- */
-
-#include <stdint.h>
-#include <stdbool.h>
-
-typedef bool (*fpc_wfi_check_t)(void);
-
-/**
- * @brief Writes and reads SPI data.
- *
- * Writes data to SPI interface and reads data from SPI interface, with chip
- * select control. The caller is blocked until the operation is complete. By use
- * of the chip select control parameter a single SPI transaction can be split in
- * several calls.
- *
- * @param[in] write Data to write. Must not be NULL if size > 0.
- * @param[in,out] read Receive data buffer. The caller is responsible for
- * allocating buffer. NULL => response is thrown away.
- * @param[in] size Number of bytes to write (same as bytes received).
- * 0 => Only chip select control.
- * @param[in] leave_cs_asserted True => chip select is left in asserted
- * state.
- * False => chip select is de-asserted before
- * return.
- * @return ::fpc_bep_result_t
- */
-int __unused fpc_sensor_spi_write_read(uint8_t *write, uint8_t *read,
- size_t size, bool leave_cs_asserted);
-
-/**
- * @brief Read sensor IRQ status.
- *
- * Returns status of the sensor IRQ.
- *
- * @return true if the sensor IRQ is currently active, otherwise false.
- */
-bool __unused fpc_sensor_spi_check_irq(void);
-
-/**
- * @brief Read sensor IRQ status and then set status to false.
- *
- * Returns status of the sensor IRQ and sets the status to false.
- *
- * @return true if the sensor IRQ has been active, otherwise false.
- */
-bool __unused fpc_sensor_spi_read_irq(void);
-
-/**
- * @brief Set sensor reset state.
- *
- * Set sensor reset state.
- *
- * @param[in] state Reset state.
- * true => reset sensor, i.e. low GPIO state
- * false => normal operation, i.e. high GPIO state
- */
-void __unused fpc_sensor_spi_reset(bool state);
-
-/**
- * @brief Initializes SPI master.
- *
- * @param[in] speed_hz Maximum SPI clock speed according to sensor HW spec
- * (unit Hz).
- *
- */
-void __unused fpc_sensor_spi_init(uint32_t speed_hz);
-
-/**
- * @brief Set system in WFI mode while waiting sensor IRQ.
- *
- * @note This mode only requires the system to be able to wake up from Sensor
- * IRQ pin, all other peripheral can be turned off.
- *
- * @note The system time must be adjusted upon WFI return.
- *
- * @param[in] timeout_ms Time in ms before waking up, 0 if no timeout.
- * @param[in] enter_wfi Function pointer to check WFI entry.
- * @param[in] enter_wfi_mode Bool that is used when comparing the value returned
- * by enter_wfi.
- * @return FPC_RESULT_OK, FPC_RESULT_TIMEOUT
- */
-int __unused fpc_sensor_wfi(uint16_t timeout_ms, fpc_wfi_check_t enter_wfi,
- bool enter_wfi_mode);
-
-#endif /* __CROS_EC_FPC_SENSOR_SPI_H */
diff --git a/driver/fingerprint/fpc/bep/fpc_timebase.c b/driver/fingerprint/fpc/bep/fpc_timebase.c
deleted file mode 100644
index 113e150ed9..0000000000
--- a/driver/fingerprint/fpc/bep/fpc_timebase.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2019 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.
- */
-
-/* FPC Platform Abstraction Layer */
-
-#include <stdint.h>
-
-#include "fpc_timebase.h"
-#include "timer.h"
-
-uint32_t __unused fpc_timebase_get_tick(void)
-{
- clock_t time;
-
- time = clock();
-
- return (uint32_t)time;
-}
-
-void __unused fpc_timebase_busy_wait(uint32_t ms)
-{
- udelay(ms * 1000);
-}
-
-void __unused fpc_timebase_init(void)
-{
-}
diff --git a/driver/fingerprint/fpc/bep/fpc_timebase.h b/driver/fingerprint/fpc/bep/fpc_timebase.h
deleted file mode 100644
index 388d13293e..0000000000
--- a/driver/fingerprint/fpc/bep/fpc_timebase.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright 2019 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.
- */
-
-#ifndef __CROS_EC_FPC_TIMEBASE_H
-#define __CROS_EC_FPC_TIMEBASE_H
-
-/**
- * @file fpc_timebase.h
- * @brief Timebase based on a system tick.
- *
- * Supplies tick counter and wait operation(s).
- */
-
-#include <stdint.h>
-
-#include "common.h"
-
-/**
- * @brief Reads the system tick counter.
- *
- * @details To handle tick counter wrap around when checking for timeout, make
- * sure to do the calculation in the following manner:
- * "if ((current_tick - old_tick) > timeout) {"
- * Example: current time (uint32_t) = 10 ticks
- * old time (uint32_t) = 30 ticks before overflow of uint32_t
- * current_time - old_time = 10 - (2**32 - 30) -> wraps around to 40
- *
- * @return Tick count since fpc_timebase_init() call. [ms]
- */
-uint32_t __unused fpc_timebase_get_tick(void);
-
-/**
- * @brief Busy wait.
- *
- * @param[in] ms Time to wait [ms].
- * 0 => return immediately
- * 1 => wait at least 1ms etc.
- */
-void __unused fpc_timebase_busy_wait(uint32_t ms);
-
-/**
- * @brief Initializes timebase. Starts system tick counter.
- */
-void __unused fpc_timebase_init(void);
-
-#endif /* __CROS_EC_FPC_TIMEBASE_H */
diff --git a/driver/fingerprint/fpc/build.mk b/driver/fingerprint/fpc/build.mk
deleted file mode 100644
index ab6a6a4b9c..0000000000
--- a/driver/fingerprint/fpc/build.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2019 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.
-
-# Build for FPC fingerprint drivers
-
-# Note that this variable includes the trailing "/"
-_fpc_cur_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
-
-ifeq ($(CONFIG_FP_SENSOR_FPC1145),rw)
-include $(_fpc_cur_dir)libfp/build.mk
-else ifeq ($(CONFIG_FP_SENSOR_FPC1025),rw)
-include $(_fpc_cur_dir)bep/build.mk
-else ifeq ($(CONFIG_FP_SENSOR_FPC1035),rw)
-include $(_fpc_cur_dir)bep/build.mk
-endif
diff --git a/driver/fingerprint/fpc/fpc_sensor.h b/driver/fingerprint/fpc/fpc_sensor.h
deleted file mode 100644
index da67696a0c..0000000000
--- a/driver/fingerprint/fpc/fpc_sensor.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2019 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.
- */
-
-#ifndef __CROS_EC_DRIVER_FINGERPRINT_FPC_FPC_SENSOR_H_
-#define __CROS_EC_DRIVER_FINGERPRINT_FPC_FPC_SENSOR_H_
-
-#include "common.h"
-
-#if defined(CONFIG_FP_SENSOR_FPC1025)
-#include "bep/fpc1025_private.h"
-#elif defined(CONFIG_FP_SENSOR_FPC1035)
-#include "bep/fpc1035_private.h"
-#elif defined(CONFIG_FP_SENSOR_FPC1145)
-#include "libfp/fpc1145_private.h"
-#else
-#error "Sensor type not defined!"
-#endif
-
-#endif /* __CROS_EC_DRIVER_FINGERPRINT_FPC_FPC_SENSOR_H_ */
diff --git a/driver/fingerprint/fpc/libfp/build.mk b/driver/fingerprint/fpc/libfp/build.mk
deleted file mode 100644
index 3fabab38e9..0000000000
--- a/driver/fingerprint/fpc/libfp/build.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2019 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.
-
-# FPC libfp source files build
-
-# Note that this variable includes the trailing "/"
-libfp_cur_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
-
-# Make sure output directory is created (in build directory)
-dirs-y+="$(libfp_cur_dir)"
-
-# Only build for these objects for the RW image
-all-obj-rw+=$(libfp_cur_dir)fpc_sensor_pal.o \
- $(libfp_cur_dir)fpc_private.o
diff --git a/driver/fingerprint/fpc/libfp/fpc1145_private.h b/driver/fingerprint/fpc/libfp/fpc1145_private.h
deleted file mode 100644
index 91b072d6a2..0000000000
--- a/driver/fingerprint/fpc/libfp/fpc1145_private.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Copyright 2017 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.
- */
-
-#ifndef __CROS_EC_FPC1145_PRIVATE_H
-#define __CROS_EC_FPC1145_PRIVATE_H
-
-#include <stdint.h>
-
-/* The 16-bit hardware ID is 0x140y */
-#define FP_SENSOR_HWID 0x140
-
-/* Sensor type name */
-#define FP_SENSOR_NAME "FPC1145"
-
-/* Sensor pixel resolution */
-#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)
-#define FP_SENSOR_IMAGE_SIZE_MODE_SIMPLE (13356)
-/*
- * Size of the captured image in MQT mode. If you this is modified the
- * corresponding value in the MQT tool fputils.py must be changed too.
- * See b/111443750 for context.
- */
-#define FP_SENSOR_IMAGE_SIZE_MODE_QUAL (24408)
-
-#define FP_SENSOR_IMAGE_SIZE FP_SENSOR_IMAGE_SIZE_MODE_VENDOR
-#define FP_SENSOR_IMAGE_OFFSET 2340
-
-/* Opaque FPC context */
-#define FP_SENSOR_CONTEXT_SIZE 4944
-
-/* Algorithm buffer sizes */
-#define FP_ALGORITHM_ENROLLMENT_SIZE 28
-#define FP_ALGORITHM_TEMPLATE_SIZE 47552
-
-/* Max number of templates stored / matched against */
-#define FP_MAX_FINGER_COUNT 5
-
-#endif /* __CROS_EC_FPC1145_PRIVATE_H */
diff --git a/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h b/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h
deleted file mode 100644
index 9c00b14640..0000000000
--- a/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/* Copyright 2016 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.
- */
-#ifndef BIOD_BIO_ALGORITHM_H_
-#define BIOD_BIO_ALGORITHM_H_
-
-#include <stdint.h>
-
-enum bio_algorithm_type {
- BIO_ALGORITHM_FINGERPRINT,
- BIO_ALGORITHM_IRIS,
-};
-/*
- * An opaque pointer representing/uniquely identifying a sensor.
- */
-typedef void *bio_sensor_t;
-/*
- * An opaque pointer representing an image (scan).
- */
-typedef void *bio_image_t;
-/*
- * An opaque pointer representing/uniquely identifying an (serialized) enrolled
- * template.
- */
-typedef void *bio_template_t;
-/*
- * An opaque pointer representing/uniquely identifying enrollment attempt.
- */
-typedef void *bio_enrollment_t;
-/*
- * Initializes biometric algorithm library. Should be the very first function
- * to be invoked by the biometric daemon.
- *
- * Returns 0 on success, negative error code (such as -ENOMEM) on failure.
- */
-int bio_algorithm_init(void);
-/*
- * Instructs the biometric library to release all resources in preparation
- * for the process termination (or unloading the library). Regardless of
- * the returned error code the action is considered unrecoverable.
- *
- * Returns 0 on success, negative error code (such as -ENOMEM) on failure.
- */
-int bio_algorithm_exit(void);
-/*
- * Used to retrieve type of the algorithm library. Might be used by
- * configuration processor module to match sensors and algorithm libraries.
- */
-enum bio_algorithm_type bio_algorithm_get_type(void);
-/*
- * Used to retrieve name of the algorithm library, to be used in diagnostics.
- * Also might be used by configuration processor module to match sensors and
- * algorithm libraries.
- */
-const char *bio_algorithm_get_name(void);
-/*
- * Used to retrieve version of the algorithm library, to be used in diagnostics.
- */
-const char *bio_algorithm_get_version(void);
-/*
- * Used to retrieve additional information from the algorithm library, to be
- * used in diagnostics.
- */
-const char *bio_algorithm_get_banner(void);
-/*
- * Initializes a new sensor structure and returns its handle that will be used
- * in other calls to identify the sensor involved in the operation.
- *
- * Returns 0 on success, negative error code (such as -ENOMEM) on failure.
- */
-int bio_sensor_create(bio_sensor_t *sensor);
-/*
- * Releases all resources held by the library in conjunction with given sensor.
- *
- * Returns 0 on success, negative error code (such as -EINVAL) on failure.
- */
-int bio_sensor_destroy(bio_sensor_t sensor);
-/*
- * Communicates particulars of a given sensor so that algorithm library can
- * adjust its behavior as needed.
- *
- * Returns 0 on success, negative error code (such as -EINVAL) on failure.
- */
-int bio_sensor_set_model(bio_sensor_t sensor, uint32_t vendor_id,
- uint32_t product_id, uint32_t model_id,
- uint32_t version);
-/*
- * Communicates format of data used by given sensor to the algorithm library.
- * This is a fourcc value defined by V4L2 API.
- * Could be a new define for biometric sensors or V4L2_PIX_FMT_GREY.
- * Algorithm library will return error if it can not work with given format.
- *
- * Returns 0 on success, negative error code (such as -EINVAL) on failure.
- */
-int bio_sensor_set_format(bio_sensor_t sensor, uint32_t pixel_format);
-/*
- * Communicates dimensions of given sensor to the algorithm library.
- *
- * Returns 0 on success, negative error code (such as -EINVAL) on failure.
- */
-int bio_sensor_set_size(bio_sensor_t sensor, uint32_t width, uint32_t height);
-/*
- * Instructs the algorithm library to initialize a new structure to hold
- * biometric image of given dimensions acquired from given sensor.
- * It will return image handle that will be used in other calls to identify
- * the image involved in the operation.
- *
- * Returns 0 on success, negative error code (such as -ENOMEM) on failure.
- */
-int bio_image_create(bio_sensor_t sensor, uint32_t width, uint32_t height,
- bio_image_t *image);
-/*
- * Communicates dimensions of image to the algorithm library.
- * Can be used if image is less than full sensor resolution.
- *
- * Returns 0 on success, negative error code (such as -EINVAL) on failure.
- */
-int bio_image_set_size(bio_image_t image, uint32_t width, uint32_t height);
-/*
- * Attaches data from biometric sensor to image structure. The caller must
- * ensure that there is enough of data for given image dimensions for given
- * format used by the sensor.
- *
- * It is assumes that the data pointer stays valid until bio_image_destroy()
- * is called.
- *
- * Returns 0 on success, negative error code (such as -EINVAL) on failure.
- */
-int bio_image_set_data(bio_image_t image, const uint8_t *data, size_t size);
-/*
- * Releases all resources held by the library in conjunction with given image.
- *
- * Returns 0 on success, negative error code (such as -EINVAL) on failure.
- */
-int bio_image_destroy(bio_image_t image);
-
-/*
- * Compares given biometric image against a list of enrolled template(s).
- * In case the image match a template the match_index will indicate which
- * template in the list that matched.
- * The algorithm library can update templates with additional biometric data
- * from the image, if it chooses to do so. The updated template(s) will be
- * indicated by the out parameter 'updated_templates', a bit-field where
- * updated template(s) indicated by the corresponding bit being set
- * Returns:
- * - negative value on error
- * - BIO_TEMPLATE_NO_MATCH on non-match
- * - BIO_TEMPLATE_MATCH for match when template was not updated with new data
- * - BIO_TEMPLATE_MATCH_UPDATED for match when template was updated
- * - BIO_TEMPLATE_MATCH_UPDATE_FAILED match, but update failed (do not save)
- * - BIO_TEMPLATE_LOW_QUALITY when matching could not be performed due to low
- * image quality
- * - BIO_TEMPLATE_LOW_COVERAGE when matching could not be performed due to
- * finger covering too little area of the sensor
- */
-int bio_template_image_match_list(bio_template_t tmpl, uint32_t num_templates,
- bio_image_t image, int32_t *match_index,
- uint32_t *updated_templates);
-int bio_template_image_match(bio_template_t tmpl, bio_image_t image);
-/*
- * Returns size of template data in serialized form.
- *
- * Returns negative error code (such as -EINVAL) on failure, or size of the
- * serialized form in bytes.
- */
-ssize_t bio_template_get_serialized_size(bio_template_t tmpl);
-/*
- * Releases all resources held by the library in conjunction with given
- * template.
- *
- * Returns 0 on success, negative error code (such as -EINVAL) on failure.
- */
-int bio_template_destroy(bio_template_t tmpl);
-/*
- * Initiates biometric data enrollment process. Algorithm library returns
- * 'enrollment handle' that is used for all subsequent enrollment operations.
- *
- * Returns 0 on success, negative error code (such as -ENOMEM) on failure.
- */
-int bio_enrollment_begin(bio_sensor_t sensor, bio_enrollment_t *enrollment);
-/*
- * Adds fingerprint image to an enrollment.
- *
- * The library should expect to copy any relevant data from the “image”
- * as it is likely to be destroyed (via bio_image_destroy() call) shortly after
- * this call completes.
- *
- * Returns:
- * - negative value on error
- * - BIO_ENROLLMENT_OK when image was successfully enrolled
- * - BIO_ENROLLMENT_IMMOBILE when image added, but user should be advised
- * to move finger
- * - BIO_ENROLLMENT_LOW_QUALITY when image could not be used due to low
- * image quality
- * - BIO_ENROLLMENT_LOW_COVERAGE when image could not be used due to
- * finger covering too little area of the sensor
- */
-#define BIO_ENROLLMENT_OK 0
-#define BIO_ENROLLMENT_IMMOBILE 2
-#define BIO_ENROLLMENT_LOW_QUALITY 1
-#define BIO_ENROLLMENT_LOW_COVERAGE 3
-/* Can be used to detect if image was usable for enrollment or not. */
-#define BIO_ENROLLMENT_PROBLEM_MASK 1
-int bio_enrollment_add_image(bio_enrollment_t enrollment, bio_image_t image);
-/*
- * Indicates whether there is enough data in the enrollment for it to be
- * converted into a template to be used for identification.
- *
- * Returns 0 for if enrollment does not have enough data yet, 1 if enrollment
- * is complete, or negative error code (such as -EINVAL) on failure.
- *
- */
-int bio_enrollment_is_complete(bio_enrollment_t enrollment);
-/*
- * Returns percent of coverage accumulated during enrollment process.
- * Optional method. Regardless of value returned by this call user should call
- * bio_enrollment_is_complete() to check if algorithm library accumulated enough
- * data to create a template.
- *
- * Returns value in the range 0..100, or negative error (such as -EINVAL);
- */
-int bio_enrollment_get_percent_complete(bio_enrollment_t enrollment);
-/*
- * Indicates that given enrollment process is complete, and algorithm library
- * should generate an active template that can be used in subsequent calls
- * to bio_image_match() and bio_template_serialize() from enrollment data.
- * After the template is created the library should release all resources
- * associated with this enrollment.
- *
- * Argument 'tmpl' is optional and can be set to NULL if caller wishes to
- * abort enrollment process.
- *
- * Returns 0 on success, negative error code (such as -EINVAL) on failure.
- */
-int bio_enrollment_finish(bio_enrollment_t enrollment, bio_template_t *tmpl);
-
-typedef struct {
- int32_t coverage; /* Sensor coverage in range [0..100] */
- int32_t quality; /* Image quality in range [0..100] */
- int32_t min_coverage; /* Minimum coverage accepted by enroll */
- int32_t min_quality; /* Minimum image quality accepted by enroll */
-} bio_image_status_t;
-
-/*
- * Get the image quality and threshold values for a bio_image_t
- *
- * @param[in] image Image data as acquired by
- * fp_sensor_acquire_image_with_mode
- * @param[out] image_status Populated structure with quality/coverage values
- * and corresponding threshold values
- *
- * @note This function will alter the internal states of the bio algorithm
- * library and must not be used during an enroll sequence. The typical
- * use case for this function is to qualify images during image
- * collection.
- *
- * @return negative on error.
- * @return 0 if the quality and coverage threshold values aren't reached.
- * @return 1 if the quality and coverage threshold values are reached.
- */
-int bio_sensor_get_image_status(bio_image_t image,
- bio_image_status_t *image_status);
-
-#endif /* BIOD_BIO_ALGORITHM_H_ */
diff --git a/driver/fingerprint/fpc/libfp/fpc_private.c b/driver/fingerprint/fpc/libfp/fpc_private.c
deleted file mode 100644
index e734a94734..0000000000
--- a/driver/fingerprint/fpc/libfp/fpc_private.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/* Copyright 2017 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.
- */
-
-#include <stddef.h>
-#include "common.h"
-#include "console.h"
-#include "endian.h"
-#include "fpc_bio_algorithm.h"
-#include "fpc_private.h"
-#include "fpsensor.h"
-#include "gpio.h"
-#include "link_defs.h"
-#include "spi.h"
-#include "system.h"
-#include "timer.h"
-#include "util.h"
-
-#include "driver/fingerprint/fpc/fpc_sensor.h"
-
-#define CPRINTF(format, args...) cprintf(CC_FP, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_FP, format, ## args)
-
-/* Minimum reset duration */
-#define FP_SENSOR_RESET_DURATION_US (10 * MSEC)
-/* Maximum delay for the interrupt to be asserted after the sensor is reset */
-#define FP_SENSOR_IRQ_MAX_DELAY_US (5 * MSEC)
-/* Maximum number of attempts to initialise the sensor */
-#define FP_SENSOR_MAX_INIT_ATTEMPTS 10
-/* Delay between failed attempts of fp_sensor_open() */
-#define FP_SENSOR_OPEN_DELAY_US (500 * MSEC)
-
-/* Decode internal error codes from FPC's sensor library */
-#define FPC_GET_INTERNAL_CODE(res) (((res) & 0x000fc000) >> 14)
-/* There was a finger on the sensor when calibrating finger detect */
-#define FPC_INTERNAL_FINGER_DFD FPC_ERROR_INTERNAL_38
-
-/*
- * The sensor context is uncached as it contains the SPI buffers,
- * the binary library assumes that it is aligned.
- */
-static uint8_t ctx[FP_SENSOR_CONTEXT_SIZE] __uncached __aligned(4);
-static bio_sensor_t bio_sensor;
-static uint8_t enroll_ctx[FP_ALGORITHM_ENROLLMENT_SIZE];
-
-/* recorded error flags */
-static uint16_t errors;
-
-/* Sensor description */
-static struct ec_response_fp_info fpc1145_info = {
- /* Sensor identification */
- .vendor_id = FOURCC('F', 'P', 'C', ' '),
- .product_id = 9,
- .model_id = 1,
- .version = 1,
- /* Image frame characteristics */
- .frame_size = FP_SENSOR_IMAGE_SIZE,
- .pixel_format = V4L2_PIX_FMT_GREY,
- .width = FP_SENSOR_RES_X,
- .height = FP_SENSOR_RES_Y,
- .bpp = FP_SENSOR_RES_BPP,
-};
-
-/* Sensor IC commands */
-enum fpc_cmd {
- FPC_CMD_STATUS = 0x14,
- FPC_CMD_INT_STS = 0x18,
- FPC_CMD_INT_CLR = 0x1C,
- FPC_CMD_FINGER_QUERY = 0x20,
- FPC_CMD_SLEEP = 0x28,
- FPC_CMD_DEEPSLEEP = 0x2C,
- FPC_CMD_SOFT_RESET = 0xF8,
- FPC_CMD_HW_ID = 0xFC,
-};
-
-/* Maximum size of a sensor command SPI transfer */
-#define MAX_CMD_SPI_TRANSFER_SIZE 3
-
-/* Uncached memory for the SPI transfer buffer */
-static uint8_t spi_buf[MAX_CMD_SPI_TRANSFER_SIZE] __uncached;
-
-static int fpc_send_cmd(const uint8_t cmd)
-{
- spi_buf[0] = cmd;
- return spi_transaction(SPI_FP_DEVICE, spi_buf, 1, spi_buf,
- SPI_READBACK_ALL);
-}
-
-void fp_sensor_low_power(void)
-{
- /*
- * TODO(b/117620462): verify that sleep mode is WAI (no increased
- * latency, expected power consumption).
- */
- if (0)
- fpc_send_cmd(FPC_CMD_SLEEP);
-}
-
-static int fpc_check_hwid(void)
-{
- uint16_t id;
- int rc;
-
- /* Clear previous occurences of relevant |errors| flags. */
- errors &= (~FP_ERROR_SPI_COMM & ~FP_ERROR_BAD_HWID);
-
- spi_buf[0] = FPC_CMD_HW_ID;
- rc = spi_transaction(SPI_FP_DEVICE, spi_buf, 3, spi_buf,
- SPI_READBACK_ALL);
- if (rc) {
- CPRINTS("FPC ID read failed %d", rc);
- errors |= FP_ERROR_SPI_COMM;
- return EC_ERROR_HW_INTERNAL;
- }
- id = (spi_buf[1] << 8) | spi_buf[2];
- if ((id >> 4) != FP_SENSOR_HWID) {
- CPRINTS("FPC unknown silicon 0x%04x", id);
- errors |= FP_ERROR_BAD_HWID;
- return EC_ERROR_HW_INTERNAL;
- }
- CPRINTS(FP_SENSOR_NAME " id 0x%04x", id);
-
- return EC_SUCCESS;
-}
-
-static uint8_t fpc_read_clear_int(void)
-{
- spi_buf[0] = FPC_CMD_INT_CLR;
- spi_buf[1] = 0xff;
- if (spi_transaction(SPI_FP_DEVICE, spi_buf, 2, spi_buf,
- SPI_READBACK_ALL))
- return 0xff;
- return spi_buf[1];
-}
-
-/*
- * Toggle the h/w reset pins and clear any pending IRQs before initializing the
- * sensor contexts.
- * Returns:
- * - EC_SUCCESS on success.
- * - EC_ERROR_HW_INTERNAL on failure (and |errors| variable is updated where
- * appropriate).
- */
-static int fpc_pulse_hw_reset(void)
-{
- int ret;
- int rc = EC_SUCCESS;
- /* Clear previous occurrence of possible error flags. */
- errors &= ~FP_ERROR_NO_IRQ;
-
- /* Ensure we pulse reset low to initiate the startup */
- gpio_set_level(GPIO_FP_RST_ODL, 0);
- usleep(FP_SENSOR_RESET_DURATION_US);
- gpio_set_level(GPIO_FP_RST_ODL, 1);
- /* the IRQ line should be set high by the sensor */
- usleep(FP_SENSOR_IRQ_MAX_DELAY_US);
- if (!gpio_get_level(GPIO_FPS_INT)) {
- CPRINTS("Sensor IRQ not ready");
- errors |= FP_ERROR_NO_IRQ;
- rc = EC_ERROR_HW_INTERNAL;
- }
-
- /* Check the Hardware ID */
- ret = fpc_check_hwid();
- if (ret != EC_SUCCESS) {
- CPRINTS("Failed to verify HW ID");
- rc = EC_ERROR_HW_INTERNAL;
- }
-
- /* clear the pending 'ready' IRQ before enabling interrupts */
- fpc_read_clear_int();
-
- return rc;
-}
-
-/* Reset and initialize the sensor IC */
-int fp_sensor_init(void)
-{
- int res;
- int attempt;
-
- errors = FP_ERROR_DEAD_PIXELS_UNKNOWN;
-
- /* Release any previously held resources from earlier iterations */
- res = bio_sensor_destroy(bio_sensor);
- if (res)
- CPRINTS("FPC Sensor resources release failed: %d", res);
- bio_sensor = NULL;
-
- res = bio_algorithm_exit();
- if (res)
- CPRINTS("FPC Algorithm resources release failed: %d", res);
-
- /* Print the binary libfpsensor.a library version */
- CPRINTF("FPC libfpsensor.a v%s\n", fp_sensor_get_version());
- cflush();
-
- attempt = 0;
- do {
- attempt++;
-
- res = fpc_pulse_hw_reset();
- if (res != EC_SUCCESS) {
- /* In case of failure, retry after a delay. */
- CPRINTS("H/W sensor reset failed, error flags: 0x%x",
- errors);
- cflush();
- usleep(FP_SENSOR_OPEN_DELAY_US);
- continue;
- }
-
- /*
- * Ensure that any previous context data is obliterated in case
- * of a sensor reset.
- */
- memset(ctx, 0, FP_SENSOR_CONTEXT_SIZE);
-
- res = fp_sensor_open(ctx, FP_SENSOR_CONTEXT_SIZE);
- /* Flush messages from the PAL if any */
- cflush();
- CPRINTS("Sensor init (attempt %d): 0x%x", attempt, res);
- /*
- * Retry on failure. This typically happens if the user has left
- * their finger on the sensor after powering up the device, DFD
- * will fail in that case. We've seen other error modes in the
- * field, retry in all cases to be more resilient.
- */
- if (!res)
- break;
- usleep(FP_SENSOR_OPEN_DELAY_US);
- } while (attempt < FP_SENSOR_MAX_INIT_ATTEMPTS);
- if (res)
- errors |= FP_ERROR_INIT_FAIL;
-
- res = bio_algorithm_init();
- /* the PAL might have spewed a lot of traces, ensure they are visible */
- cflush();
- CPRINTS("Algorithm init: 0x%x", res);
- if (res < 0)
- errors |= FP_ERROR_INIT_FAIL;
- res = bio_sensor_create(&bio_sensor);
- CPRINTS("Sensor create: 0x%x", res);
- if (res < 0)
- errors |= FP_ERROR_INIT_FAIL;
-
- /* Go back to low power */
- fp_sensor_low_power();
-
- return EC_SUCCESS;
-}
-
-/* Deinitialize the sensor IC */
-int fp_sensor_deinit(void)
-{
- /*
- * TODO(tomhughes): libfp doesn't have fp_sensor_close like BEP does.
- * We'll need FPC to either add it or verify that we don't have the same
- * problem with the libfp library as described in:
- * b/124773209#comment46
- */
- return EC_SUCCESS;
-}
-
-int fp_sensor_get_info(struct ec_response_fp_info *resp)
-{
- int rc;
-
- memcpy(resp, &fpc1145_info, sizeof(*resp));
-
- spi_buf[0] = FPC_CMD_HW_ID;
- rc = spi_transaction(SPI_FP_DEVICE, spi_buf, 3, spi_buf,
- SPI_READBACK_ALL);
- if (rc)
- return EC_RES_ERROR;
- resp->model_id = (spi_buf[1] << 8) | spi_buf[2];
- resp->errors = errors;
-
- return EC_SUCCESS;
-}
-
-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(void)
-{
- int rc;
- bio_enrollment_t p = enroll_ctx;
-
- rc = bio_enrollment_begin(bio_sensor, &p);
- if (rc < 0)
- CPRINTS("begin failed %d", rc);
- return rc;
-}
-
-int fp_enrollment_finish(void *templ)
-{
- bio_template_t pt = templ;
-
- return bio_enrollment_finish(enroll_ctx, templ ? &pt : NULL);
-}
-
-int fp_finger_enroll(uint8_t *image, int *completion)
-{
- int rc = bio_enrollment_add_image(enroll_ctx, image);
-
- if (rc < 0)
- return rc;
- *completion = bio_enrollment_get_percent_complete(enroll_ctx);
- return rc;
-}
diff --git a/driver/fingerprint/fpc/libfp/fpc_private.h b/driver/fingerprint/fpc/libfp/fpc_private.h
deleted file mode 100644
index 6ec09ee0ee..0000000000
--- a/driver/fingerprint/fpc/libfp/fpc_private.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* Copyright 2018 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.
- */
-
-/* Private sensor interface */
-
-#ifndef __CROS_EC_FPC_PRIVATE_H
-#define __CROS_EC_FPC_PRIVATE_H
-
-/* External error codes from FPC's sensor library */
-enum fpc_error_code_external {
- FPC_ERROR_NONE = 0,
- FPC_ERROR_NOT_FOUND = 1,
- FPC_ERROR_CAN_BE_USED_2 = 2,
- FPC_ERROR_CAN_BE_USED_3 = 3,
- FPC_ERROR_CAN_BE_USED_4 = 4,
- FPC_ERROR_PAL = 5,
- FPC_ERROR_IO = 6,
- FPC_ERROR_CANCELLED = 7,
- FPC_ERROR_UNKNOWN = 8,
- FPC_ERROR_MEMORY = 9,
- FPC_ERROR_PARAMETER = 10,
- FPC_ERROR_TEST_FAILED = 11,
- FPC_ERROR_TIMEDOUT = 12,
- FPC_ERROR_SENSOR = 13,
- FPC_ERROR_SPI = 14,
- FPC_ERROR_NOT_SUPPORTED = 15,
- FPC_ERROR_OTP = 16,
- FPC_ERROR_STATE = 17,
- FPC_ERROR_PN = 18,
- FPC_ERROR_DEAD_PIXELS = 19,
- FPC_ERROR_TEMPLATE_CORRUPTED = 20,
- FPC_ERROR_CRC = 21,
- FPC_ERROR_STORAGE = 22, /**< Errors related to storage **/
- FPC_ERROR_MAXIMUM_REACHED = 23, /**< The allowed maximum has been reached **/
- FPC_ERROR_MINIMUM_NOT_REACHED = 24, /**< The required minimum was not reached **/
- FPC_ERROR_SENSOR_LOW_COVERAGE = 25, /**< Minimum sensor coverage was not reached **/
- FPC_ERROR_SENSOR_LOW_QUALITY = 26, /**< Sensor image is considered low quality **/
- FPC_ERROR_SENSOR_FINGER_NOT_STABLE = 27, /**< Finger was not stable during image capture **/
-};
-
-/* Internal error codes from FPC's sensor library */
-enum fpc_error_code_internal {
- FPC_ERROR_INTERNAL_0 = 0, /* Indicates that no internal code was set. */
- FPC_ERROR_INTERNAL_1 = 1, /* Not supported by sensor. */
- FPC_ERROR_INTERNAL_2 = 2, /* Sensor got a NULL response (from other module). */
- FPC_ERROR_INTERNAL_3 = 3, /* Runtime config not supported by firmware. */
- FPC_ERROR_INTERNAL_4 = 4, /* CAC has not been created. */
- FPC_ERROR_INTERNAL_5 = 5, /* CAC returned an error to the sensor. */
- FPC_ERROR_INTERNAL_6 = 6, /* CAC fasttap image capture failed. */
- FPC_ERROR_INTERNAL_7 = 7, /* CAC fasttap image capture failed. */
- FPC_ERROR_INTERNAL_8 = 8, /* CAC Simple image capture failed. */
- FPC_ERROR_INTERNAL_9 = 9, /* CAC custom image capture failed. */
- FPC_ERROR_INTERNAL_10 = 10, /* CAC MQT image capture failed. */
- FPC_ERROR_INTERNAL_11 = 11, /* CAC PN image capture failed. */
- FPC_ERROR_INTERNAL_12 = 12, /* Reading CAC context size. */
- FPC_ERROR_INTERNAL_13 = 13, /* Reading CAC context size. */
- FPC_ERROR_INTERNAL_14 = 14, /* Sensor context invalid. */
- FPC_ERROR_INTERNAL_15 = 15, /* Buffer reference is invalid. */
- FPC_ERROR_INTERNAL_16 = 16, /* Buffer size reference is invalid. */
- FPC_ERROR_INTERNAL_17 = 17, /* Image data reference is invalid. */
- FPC_ERROR_INTERNAL_18 = 18, /* Capture type specified is invalid. */
- FPC_ERROR_INTERNAL_19 = 19, /* Capture config specified is invalid. */
- FPC_ERROR_INTERNAL_20 = 20, /* Sensor type in hw desc could not be extracted. */
- FPC_ERROR_INTERNAL_21 = 21, /* Failed to create BNC component. */
- FPC_ERROR_INTERNAL_22 = 22, /* BN calibration failed. */
- FPC_ERROR_INTERNAL_23 = 23, /* BN memory allocation failed. */
- FPC_ERROR_INTERNAL_24 = 24, /* Companion type in hw desc could not be extracted. */
- FPC_ERROR_INTERNAL_25 = 25, /* Coating type in hw desc could not be extracted. */
- FPC_ERROR_INTERNAL_26 = 26, /* Sensor mode type is invalid. */
- FPC_ERROR_INTERNAL_27 = 27, /* Wrong Sensor state in OTP read. */
- FPC_ERROR_INTERNAL_28 = 28, /* Mismatch of register size in overlay vs rrs. */
- FPC_ERROR_INTERNAL_29 = 29, /* Checkerboard capture failed. */
- FPC_ERROR_INTERNAL_30 = 30, /* Error converting to fpc_image in dp calibration. */
- FPC_ERROR_INTERNAL_31 = 31, /* Failed to capture reset pixel image. */
- FPC_ERROR_INTERNAL_32 = 32, /* API level not support in dp calibration. */
- FPC_ERROR_INTERNAL_33 = 33, /* The image data in parameter is invalid. */
- FPC_ERROR_INTERNAL_34 = 34, /* PAL delay function has failed. */
- FPC_ERROR_INTERNAL_35 = 35, /* AFD sensor commad did not complete. */
- FPC_ERROR_INTERNAL_36 = 36, /* AFD wrong runlevel detected after calibration. */
- FPC_ERROR_INTERNAL_37 = 37, /* Wrong rrs size. */
- FPC_ERROR_INTERNAL_38 = 38, /* There was a finger on the sensor when calibrating finger detect. */
- FPC_ERROR_INTERNAL_39 = 39, /* The calculated calibration value is larger than max. */
- FPC_ERROR_INTERNAL_40 = 40, /* The sensor fifo always underflows */
- FPC_ERROR_INTERNAL_41 = 41, /* The oscillator calibration resulted in a too high or low value */
- FPC_ERROR_INTERNAL_42 = 42, /* Sensor driver was opened with NULL configuration */
- FPC_ERROR_INTERNAL_43 = 43, /* Sensor driver as opened with NULL hw descriptor */
- FPC_ERROR_INTERNAL_44 = 44, /* Error occured during image drive test */
-};
-
-/* FPC specific initialization function to fill their context */
-int fp_sensor_open(void *ctx, uint32_t ctx_size);
-
-/*
- * Get library version code.
- * version code contains three digits. x.y.z
- * x - major version
- * y - minor version
- * z - build index
- */
-const char *fp_sensor_get_version(void);
-
-#endif /* __CROS_EC_FPC_PRIVATE_H */
diff --git a/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c b/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c
deleted file mode 100644
index 35c07b464a..0000000000
--- a/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright 2017 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.
- */
-/* FPC Platform Abstraction Layer callbacks */
-
-#include "common.h"
-#include "console.h"
-#include "fpsensor.h"
-#include "fpc_sensor_pal.h"
-#include "shared_mem.h"
-#include "spi.h"
-#include "timer.h"
-#include "uart.h"
-#include "util.h"
-
-#define CPRINTF(format, args...) cprintf(CC_FP, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_FP, format, ## args)
-
-void fpc_pal_log_entry(const char *tag, int log_level, const char *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- uart_puts(tag);
- uart_vprintf(format, args);
- va_end(args);
-}
-
-int fpc_pal_delay_us(uint64_t us)
-{
- if (us > 250)
- usleep(us);
- else
- udelay(us);
- return 0;
-}
-
-int fpc_pal_spi_writeread(fpc_device_t device, uint8_t *tx_buf, uint8_t *rx_buf,
- uint32_t size)
-{
- return spi_transaction(SPI_FP_DEVICE, tx_buf, size, rx_buf,
- SPI_READBACK_ALL);
-}
-
-int fpc_pal_wait_irq(fpc_device_t device, fpc_pal_irq_t irq_type)
-{
- /* TODO: b/72360575 */
- return EC_SUCCESS; /* just lie about it, libfpsensor prefers... */
-}
-
-int32_t FpcMalloc(void **data, size_t size)
-{
- return shared_mem_acquire(size, (char **)data);
-}
-
-void FpcFree(void **data)
-{
- shared_mem_release(*data);
-}
diff --git a/driver/fingerprint/fpc/libfp/fpc_sensor_pal.h b/driver/fingerprint/fpc/libfp/fpc_sensor_pal.h
deleted file mode 100644
index 78376863f1..0000000000
--- a/driver/fingerprint/fpc/libfp/fpc_sensor_pal.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright 2017 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.
- */
-
-#ifndef FPC_PAL_SENSOR_H_
-#define FPC_PAL_SENSOR_H_
-
-#include <stdint.h>
-
-typedef void *fpc_device_t;
-
-/**
- * @brief Used to describe an interrupt
- */
-typedef enum {
- IRQ_INT_TRIG = 0x01, /**< Internally triggered by sensor (fast interrupt) **/
- IRQ_EXT_TRIG = 0x02 /**< Externally triggered by event outside sensor (may take long time) **/
-} fpc_pal_irq_t;
-
-/**
- * @brief Write sensor access buffer to SPI interface
- *
- * @param[in] device Client's device handle.
- * @param[in] access_buffer Buffer holding data to write.
- * @param[in] access_buffer_size Size of the access buffer.
- *
- * @return 0 on success.
- * negative value on error.
- */
-int fpc_pal_spi_write(fpc_device_t device, uint8_t *access_buffer,
- uint32_t access_buffer_size);
-
-/**
- * @brief Write and read sensor access buffer to SPI interface
- *
- * SPI transfers always write the same number of bytes as they read,
- * hence the size of tx_buffer and rx_buffer must be the same.
- *
- * @param[in] device Client's device handle.
- * @param[in] tx_buffer Buffer holding data to write.
- * @param[in] rx_buffer Buffer where read data will be stored.
- * @param[in] size Size of tx and rx buffer.
- *
- * @return 0 on success.
- * negative value on error.
- */
-int fpc_pal_spi_writeread(fpc_device_t device, uint8_t *tx_buffer,
- uint8_t *rx_buffer, uint32_t size);
-
-/**
- * @brief Wait for IRQ
- *
- * @param[in] device Client's device handle.
- * @param[in] irq_type The expected IRQ type.
- *
- * @return 0 on success.
- * negative value on error.
- */
-int fpc_pal_wait_irq(fpc_device_t device, fpc_pal_irq_t irq_type);
-
-/**
- * @brief Get time
- *
- * @param[out] time_us Timestamp in microseconds.
- *
- * Not all platforms have microsecond resolution. These should
- * return time in terms of hole milliseconds.
- *
- * @return 0 on success.
- * negative value on error.
- */
-int fpc_pal_get_time(uint64_t *time_us);
-
-/**
- * @brief Delay function
- *
- * @param[in] us Delay in microseconds.
- *
- * Not all platforms have microsecond resolution. These should
- * delay in terms of hole milliseconds.
- *
- * @return 0 on success.
- * negative value on error.
- */
-int fpc_pal_delay_us(uint64_t us);
-
-/**
- * @brief Get platform SPI clock frequency
- *
- * @param[in] device Client's device handle.
- * @param[out] speed_hz SPI frequency in hertz.
- *
- * Required by platform for adaptive SPI calculations.
- *
- * @return 0 on success.
- * negative value on error.
- */
-int fpc_pal_spi_get_speed_hz(fpc_device_t device, uint32_t *speed_hz);
-
-/**
- * @brief Print SDK log strings
- *
- * @param[in] tag sensor sdk log prefix
- * @param[in] log_level FPC_SENSOR_SDK_LOG_LEVEL_DEBUG - debug print
- * FPC_SENSOR_SDK_LOG_LEVEL_INFO - information print
- * FPC_SENSOR_SDK_LOG_LEVEL_ERROR - error print
- * @param[in] format the format specifier.
- * @param[in] ... additional arguments.
- *
- */
-#define FPC_SENSOR_SDK_LOG_LEVEL_DEBUG (1)
-#define FPC_SENSOR_SDK_LOG_LEVEL_INFO (2)
-#define FPC_SENSOR_SDK_LOG_LEVEL_ERROR (3)
-#define FPC_SENSOR_SDK_LOG_LEVEL_DISABLED (4)
-void fpc_pal_log_entry(const char *tag, int log_level, const char *format, ...);
-
-#endif // FPC_PAL_SENSOR_H_
diff --git a/driver/fingerprint/fpsensor.h b/driver/fingerprint/fpsensor.h
deleted file mode 100644
index be7565c5d4..0000000000
--- a/driver/fingerprint/fpsensor.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright 2019 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.
- */
-
-#ifndef __CROS_EC_DRIVER_FINGERPRINT_FPSENSOR_H_
-#define __CROS_EC_DRIVER_FINGERPRINT_FPSENSOR_H_
-
-#if defined(HAVE_PRIVATE) && !defined(TEST_BUILD)
-#define HAVE_FP_PRIVATE_DRIVER
-#include "fpc/fpc_sensor.h"
-#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
-
-#ifdef TEST_BUILD
-/* This represents the mock of the private */
-#define HAVE_FP_PRIVATE_DRIVER
-#endif
-
-#endif /* __CROS_EC_DRIVER_FINGERPRINT_FPSENSOR_H_ */
diff --git a/fuzz/host_command_fuzz.mocklist b/fuzz/host_command_fuzz.mocklist
index be1527bff0..84c6d081c5 100644
--- a/fuzz/host_command_fuzz.mocklist
+++ b/fuzz/host_command_fuzz.mocklist
@@ -4,6 +4,4 @@
*/
#define CONFIG_TEST_MOCK_LIST \
- MOCK(FP_SENSOR) \
- MOCK(MKBP_EVENTS) \
MOCK(ROLLBACK)
diff --git a/fuzz/host_command_fuzz.tasklist b/fuzz/host_command_fuzz.tasklist
index 2ff8a94d98..3211d1a401 100644
--- a/fuzz/host_command_fuzz.tasklist
+++ b/fuzz/host_command_fuzz.tasklist
@@ -6,5 +6,4 @@
/**
* See CONFIG_TASK_LIST in config.h for details.
*/
-#define CONFIG_TEST_TASK_LIST \
- TASK_TEST(FPSENSOR, fp_task, NULL, TASK_STACK_SIZE)
+ #define CONFIG_TEST_TASK_LIST
diff --git a/include/config.h b/include/config.h
index e82af70e28..2cd6cb4a96 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1757,12 +1757,6 @@
#undef CONFIG_EC_WRITABLE_STORAGE_SIZE
/*****************************************************************************/
-/* Fingerprint Sensor Configuration */
-#undef CONFIG_FP_SENSOR_FPC1025
-#undef CONFIG_FP_SENSOR_FPC1035
-#undef CONFIG_FP_SENSOR_FPC1145
-
-/*****************************************************************************/
/* NvMem Configuration */
/* Enable NV Memory module within flash */
#undef CONFIG_FLASH_NVMEM
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 29278ddebe..64b77d3e3b 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -3606,40 +3606,6 @@ struct ec_response_keyboard_factory_test {
uint16_t shorted; /* Keyboard pins are shorted */
} __ec_align2;
-/* Fingerprint events in 'fp_events' for EC_MKBP_EVENT_FINGERPRINT */
-#define EC_MKBP_FP_RAW_EVENT(fp_events) ((fp_events) & 0x00FFFFFF)
-#define EC_MKBP_FP_ERRCODE(fp_events) ((fp_events) & 0x0000000F)
-#define EC_MKBP_FP_ENROLL_PROGRESS_OFFSET 4
-#define EC_MKBP_FP_ENROLL_PROGRESS(fpe) (((fpe) & 0x00000FF0) \
- >> EC_MKBP_FP_ENROLL_PROGRESS_OFFSET)
-#define EC_MKBP_FP_MATCH_IDX_OFFSET 12
-#define EC_MKBP_FP_MATCH_IDX_MASK 0x0000F000
-#define EC_MKBP_FP_MATCH_IDX(fpe) (((fpe) & EC_MKBP_FP_MATCH_IDX_MASK) \
- >> EC_MKBP_FP_MATCH_IDX_OFFSET)
-#define EC_MKBP_FP_ENROLL BIT(27)
-#define EC_MKBP_FP_MATCH BIT(28)
-#define EC_MKBP_FP_FINGER_DOWN BIT(29)
-#define EC_MKBP_FP_FINGER_UP BIT(30)
-#define EC_MKBP_FP_IMAGE_READY BIT(31)
-/* code given by EC_MKBP_FP_ERRCODE() when EC_MKBP_FP_ENROLL is set */
-#define EC_MKBP_FP_ERR_ENROLL_OK 0
-#define EC_MKBP_FP_ERR_ENROLL_LOW_QUALITY 1
-#define EC_MKBP_FP_ERR_ENROLL_IMMOBILE 2
-#define EC_MKBP_FP_ERR_ENROLL_LOW_COVERAGE 3
-#define EC_MKBP_FP_ERR_ENROLL_INTERNAL 5
-/* Can be used to detect if image was usable for enrollment or not. */
-#define EC_MKBP_FP_ERR_ENROLL_PROBLEM_MASK 1
-/* code given by EC_MKBP_FP_ERRCODE() when EC_MKBP_FP_MATCH is set */
-#define EC_MKBP_FP_ERR_MATCH_NO 0
-#define EC_MKBP_FP_ERR_MATCH_NO_INTERNAL 6
-#define EC_MKBP_FP_ERR_MATCH_NO_TEMPLATES 7
-#define EC_MKBP_FP_ERR_MATCH_NO_LOW_QUALITY 2
-#define EC_MKBP_FP_ERR_MATCH_NO_LOW_COVERAGE 4
-#define EC_MKBP_FP_ERR_MATCH_YES 1
-#define EC_MKBP_FP_ERR_MATCH_YES_UPDATED 3
-#define EC_MKBP_FP_ERR_MATCH_YES_UPDATE_FAILED 5
-
-
#define EC_CMD_MKBP_WAKE_MASK 0x0069
enum ec_mkbp_event_mask_action {
/* Retrieve the value of a wake mask. */
@@ -5776,269 +5742,6 @@ struct ec_response_locate_chip {
/*****************************************************************************/
/* Fingerprint MCU commands: range 0x0400-0x040x */
-/* Fingerprint SPI sensor passthru command: prototyping ONLY */
-#define EC_CMD_FP_PASSTHRU 0x0400
-
-#define EC_FP_FLAG_NOT_COMPLETE 0x1
-
-struct ec_params_fp_passthru {
- uint16_t len; /* Number of bytes to write then read */
- uint16_t flags; /* EC_FP_FLAG_xxx */
- uint8_t data[]; /* Data to send */
-} __ec_align2;
-
-/* Configure the Fingerprint MCU behavior */
-#define EC_CMD_FP_MODE 0x0402
-
-/* Put the sensor in its lowest power mode */
-#define FP_MODE_DEEPSLEEP BIT(0)
-/* Wait to see a finger on the sensor */
-#define FP_MODE_FINGER_DOWN BIT(1)
-/* Poll until the finger has left the sensor */
-#define FP_MODE_FINGER_UP BIT(2)
-/* Capture the current finger image */
-#define FP_MODE_CAPTURE BIT(3)
-/* Finger enrollment session on-going */
-#define FP_MODE_ENROLL_SESSION BIT(4)
-/* Enroll the current finger image */
-#define FP_MODE_ENROLL_IMAGE BIT(5)
-/* Try to match the current finger image */
-#define FP_MODE_MATCH BIT(6)
-/* Reset and re-initialize the sensor. */
-#define FP_MODE_RESET_SENSOR BIT(7)
-/* special value: don't change anything just read back current mode */
-#define FP_MODE_DONT_CHANGE BIT(31)
-
-#define FP_VALID_MODES (FP_MODE_DEEPSLEEP | \
- FP_MODE_FINGER_DOWN | \
- FP_MODE_FINGER_UP | \
- FP_MODE_CAPTURE | \
- FP_MODE_ENROLL_SESSION | \
- FP_MODE_ENROLL_IMAGE | \
- FP_MODE_MATCH | \
- FP_MODE_RESET_SENSOR | \
- FP_MODE_DONT_CHANGE)
-
-/* Capture types defined in bits [30..28] */
-#define FP_MODE_CAPTURE_TYPE_SHIFT 28
-#define FP_MODE_CAPTURE_TYPE_MASK (0x7 << FP_MODE_CAPTURE_TYPE_SHIFT)
-/*
- * This enum must remain ordered, if you add new values you must ensure that
- * FP_CAPTURE_TYPE_MAX is still the last one.
- */
-enum fp_capture_type {
- /* Full blown vendor-defined capture (produces 'frame_size' bytes) */
- FP_CAPTURE_VENDOR_FORMAT = 0,
- /* Simple raw image capture (produces width x height x bpp bits) */
- FP_CAPTURE_SIMPLE_IMAGE = 1,
- /* Self test pattern (e.g. checkerboard) */
- FP_CAPTURE_PATTERN0 = 2,
- /* Self test pattern (e.g. inverted checkerboard) */
- FP_CAPTURE_PATTERN1 = 3,
- /* Capture for Quality test with fixed contrast */
- FP_CAPTURE_QUALITY_TEST = 4,
- /* Capture for pixel reset value test */
- FP_CAPTURE_RESET_TEST = 5,
- FP_CAPTURE_TYPE_MAX,
-};
-/* Extracts the capture type from the sensor 'mode' word */
-#define FP_CAPTURE_TYPE(mode) (((mode) & FP_MODE_CAPTURE_TYPE_MASK) \
- >> FP_MODE_CAPTURE_TYPE_SHIFT)
-
-struct ec_params_fp_mode {
- uint32_t mode; /* as defined by FP_MODE_ constants */
-} __ec_align4;
-
-struct ec_response_fp_mode {
- uint32_t mode; /* as defined by FP_MODE_ constants */
-} __ec_align4;
-
-/* Retrieve Fingerprint sensor information */
-#define EC_CMD_FP_INFO 0x0403
-
-/* 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 BIT(12)
-/* SPI communication error */
-#define FP_ERROR_SPI_COMM BIT(13)
-/* Invalid sensor Hardware ID */
-#define FP_ERROR_BAD_HWID BIT(14)
-/* Sensor initialization failed */
-#define FP_ERROR_INIT_FAIL BIT(15)
-
-struct ec_response_fp_info_v0 {
- /* Sensor identification */
- uint32_t vendor_id;
- uint32_t product_id;
- uint32_t model_id;
- uint32_t version;
- /* Image frame characteristics */
- uint32_t frame_size;
- uint32_t pixel_format; /* using V4L2_PIX_FMT_ */
- uint16_t width;
- uint16_t height;
- uint16_t bpp;
- uint16_t errors; /* see FP_ERROR_ flags above */
-} __ec_align4;
-
-struct ec_response_fp_info {
- /* Sensor identification */
- uint32_t vendor_id;
- uint32_t product_id;
- uint32_t model_id;
- uint32_t version;
- /* Image frame characteristics */
- uint32_t frame_size;
- uint32_t pixel_format; /* using V4L2_PIX_FMT_ */
- uint16_t width;
- uint16_t height;
- uint16_t bpp;
- uint16_t errors; /* see FP_ERROR_ flags above */
- /* Template/finger current information */
- uint32_t template_size; /* max template size in bytes */
- uint16_t template_max; /* maximum number of fingers/templates */
- uint16_t template_valid; /* number of valid fingers/templates */
- uint32_t template_dirty; /* bitmap of templates with MCU side changes */
- uint32_t template_version; /* version of the template format */
-} __ec_align4;
-
-/* Get the last captured finger frame or a template content */
-#define EC_CMD_FP_FRAME 0x0404
-
-/* constants defining the 'offset' field which also contains the frame index */
-#define FP_FRAME_INDEX_SHIFT 28
-/* Frame buffer where the captured image is stored */
-#define FP_FRAME_INDEX_RAW_IMAGE 0
-/* First frame buffer holding a template */
-#define FP_FRAME_INDEX_TEMPLATE 1
-#define FP_FRAME_GET_BUFFER_INDEX(offset) ((offset) >> FP_FRAME_INDEX_SHIFT)
-#define FP_FRAME_OFFSET_MASK 0x0FFFFFFF
-
-/* Version of the format of the encrypted templates. */
-#define FP_TEMPLATE_FORMAT_VERSION 4
-
-/* Constants for encryption parameters */
-#define FP_CONTEXT_NONCE_BYTES 12
-#define FP_CONTEXT_USERID_WORDS (32 / sizeof(uint32_t))
-#define FP_CONTEXT_TAG_BYTES 16
-#define FP_CONTEXT_ENCRYPTION_SALT_BYTES 16
-#define FP_CONTEXT_TPM_BYTES 32
-
-/* Constants for positive match parameters. */
-#define FP_POSITIVE_MATCH_SALT_BYTES 16
-
-struct ec_fp_template_encryption_metadata {
- /*
- * Version of the structure format (N=3).
- */
- uint16_t struct_version;
- /* Reserved bytes, set to 0. */
- uint16_t reserved;
- /*
- * The salt is *only* ever used for key derivation. The nonce is unique,
- * a different one is used for every message.
- */
- uint8_t nonce[FP_CONTEXT_NONCE_BYTES];
- uint8_t encryption_salt[FP_CONTEXT_ENCRYPTION_SALT_BYTES];
- uint8_t tag[FP_CONTEXT_TAG_BYTES];
-};
-
-struct ec_params_fp_frame {
- /*
- * The offset contains the template index or FP_FRAME_INDEX_RAW_IMAGE
- * in the high nibble, and the real offset within the frame in
- * FP_FRAME_OFFSET_MASK.
- */
- uint32_t offset;
- uint32_t size;
-} __ec_align4;
-
-/* Load a template into the MCU */
-#define EC_CMD_FP_TEMPLATE 0x0405
-
-/* Flag in the 'size' field indicating that the full template has been sent */
-#define FP_TEMPLATE_COMMIT 0x80000000
-
-struct ec_params_fp_template {
- uint32_t offset;
- uint32_t size;
- uint8_t data[];
-} __ec_align4;
-
-/* Clear the current fingerprint user context and set a new one */
-#define EC_CMD_FP_CONTEXT 0x0406
-
-struct ec_params_fp_context {
- uint32_t userid[FP_CONTEXT_USERID_WORDS];
-} __ec_align4;
-
-enum fp_context_action {
- FP_CONTEXT_ASYNC = 0,
- FP_CONTEXT_GET_RESULT = 1,
-};
-
-/* Version 1 of the command is "asynchronous". */
-struct ec_params_fp_context_v1 {
- uint8_t action; /**< enum fp_context_action */
- uint8_t reserved[3]; /**< padding for alignment */
- uint32_t userid[FP_CONTEXT_USERID_WORDS];
-} __ec_align4;
-
-#define EC_CMD_FP_STATS 0x0407
-
-#define FPSTATS_CAPTURE_INV BIT(0)
-#define FPSTATS_MATCHING_INV BIT(1)
-
-struct 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;
-} __ec_align2;
-
-#define EC_CMD_FP_SEED 0x0408
-struct ec_params_fp_seed {
- /*
- * Version of the structure format (N=3).
- */
- uint16_t struct_version;
- /* Reserved bytes, set to 0. */
- uint16_t reserved;
- /* Seed from the TPM. */
- uint8_t seed[FP_CONTEXT_TPM_BYTES];
-} __ec_align4;
-
-#define EC_CMD_FP_ENC_STATUS 0x0409
-
-/* FP TPM seed has been set or not */
-#define FP_ENC_STATUS_SEED_SET BIT(0)
-
-struct ec_response_fp_encryption_status {
- /* Used bits in encryption engine status */
- uint32_t valid_flags;
- /* Encryption engine status */
- uint32_t status;
-} __ec_align4;
-
-#define EC_CMD_FP_READ_MATCH_SECRET 0x040A
-struct ec_params_fp_read_match_secret {
- uint16_t fgr;
-} __ec_align4;
-
-/* The positive match secret has the length of the SHA256 digest. */
-#define FP_POSITIVE_MATCH_SECRET_BYTES 32
-struct ec_response_fp_read_match_secret {
- uint8_t positive_match_secret[FP_POSITIVE_MATCH_SECRET_BYTES];
-} __ec_align4;
-
/*****************************************************************************/
/* Touchpad MCU commands: range 0x0500-0x05FF */
diff --git a/include/fpsensor.h b/include/fpsensor.h
deleted file mode 100644
index ce8abaf870..0000000000
--- a/include/fpsensor.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/* Copyright 2017 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_H
-#define __CROS_EC_FPSENSOR_H
-
-#include <stdint.h>
-#include "common.h"
-#include "ec_commands.h"
-
-#ifndef SPI_FP_DEVICE
-#define SPI_FP_DEVICE (&spi_devices[0])
-#endif
-
-/* Four-character-code */
-#define FOURCC(a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \
- ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
-
-/* 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,
-};
-enum finger_state fp_sensor_finger_status(void);
-
-/*
- * Acquires a fingerprint image.
- *
- * This function is called once the finger has been detected and cover enough
- * area of the sensor (ie fp_sensor_finger_status returned FINGER_PRESENT).
- * It does the acquisition immediately.
- * The image_data parameter points to an image data buffer of size
- *
- * FP_SENSOR_IMAGE_SIZE allocated by the caller.
- * Returns:
- * - 0 on success
- * - negative value on error
- * - FP_SENSOR_LOW_IMAGE_QUALITY on image captured but quality is too low
- * - FP_SENSOR_TOO_FAST on finger removed before image was captured
- * - FP_SENSOR_LOW_SENSOR_COVERAGE on sensor not fully covered by finger
- */
-#define FP_SENSOR_LOW_IMAGE_QUALITY 1
-#define FP_SENSOR_TOO_FAST 2
-#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);
-
-#endif /* __CROS_EC_FPSENSOR_H */
diff --git a/include/fpsensor_crypto.h b/include/fpsensor_crypto.h
deleted file mode 100644
index b6252b3fd2..0000000000
--- a/include/fpsensor_crypto.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright 2019 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 crypto operations */
-
-#ifndef __CROS_EC_FPSENSOR_CRYPTO_H
-#define __CROS_EC_FPSENSOR_CRYPTO_H
-
-#include <stddef.h>
-
-#include "sha256.h"
-
-#define HKDF_MAX_INFO_SIZE 128
-#define HKDF_SHA256_MAX_BLOCK_COUNT 255
-
-/**
- * Expand hkdf pseudorandom key |prk| to length |out_key_size|.
- *
- * @param out_key the buffer to hold output key material.
- * @param out_key_size length of output key in bytes. Must be less than
- * or equal to HKDF_SHA256_MAX_BLOCK_COUNT * SHA256_DIGEST_SIZE bytes.
- * @param prk pseudorandom key.
- * @param prk_size length of |prk| in bytes.
- * @param info optional context.
- * @param info_size size of |info| in bytes, must be less than or equal to
- * HKDF_MAX_INFO_SIZE bytes.
- * @return EC_SUCCESS on success and error code otherwise.
- */
-int hkdf_expand(uint8_t *out_key, size_t out_key_size, const uint8_t *prk,
- size_t prk_size, const uint8_t *info, size_t info_size);
-
-/**
- * Derive hardware encryption key from rollback secret and |salt|.
- *
- * @param outkey the pointer to buffer holding the output key.
- * @param salt the salt to use in HKDF.
- * @return EC_SUCCESS on success and error code otherwise.
- */
-int derive_encryption_key(uint8_t *out_key, const uint8_t *salt);
-
-/**
- * Derive positive match secret from |input_positive_match_salt| and
- * SBP_Src_Key.
- *
- * @param output buffer to store positive match secret, must be at least
- * FP_POSITIVE_MATCH_SECRET_BYTES in size.
- * @param input_positive_match_salt the salt for deriving secret, must be at
- * least FP_POSITIVE_MATCH_SALT_BYTES in size.
- * @return EC_SUCCESS on success and error code otherwise.
- */
-int derive_positive_match_secret(uint8_t *output,
- const uint8_t *input_positive_match_salt);
-
-/**
- * Encrypt |plaintext| using AES-GCM128.
- *
- * @param key the key to use in AES.
- * @param key_size the size of |key| in bytes.
- * @param plaintext the plain text to encrypt.
- * @param ciphertext buffer to hold encryption result.
- * @param text_size size of both |plaintext| and output ciphertext in bytes.
- * @param nonce the nonce value to use in GCM128.
- * @param nonce_size the size of |nonce| in bytes.
- * @param tag the tag to hold the authenticator after encryption.
- * @param tag_size the size of |tag|.
- * @return EC_SUCCESS on success and error code otherwise.
- */
-int aes_gcm_encrypt(const uint8_t *key, int key_size,
- const uint8_t *plaintext,
- uint8_t *ciphertext, int text_size,
- const uint8_t *nonce, int nonce_size,
- uint8_t *tag, int tag_size);
-
-/**
- * Decrypt |plaintext| using AES-GCM128.
- *
- * @param key the key to use in AES.
- * @param key_size the size of |key| in bytes.
- * @param ciphertext the cipher text to decrypt.
- * @param plaintext buffer to hold decryption result.
- * @param text_size size of both |ciphertext| and output plaintext in bytes.
- * @param nonce the nonce value to use in GCM128.
- * @param nonce_size the size of |nonce| in bytes.
- * @param tag the tag to compare against when decryption finishes.
- * @param tag_size the length of tag to compare against.
- * @return EC_SUCCESS on success and error code otherwise.
- */
-int aes_gcm_decrypt(const uint8_t *key, int key_size, uint8_t *plaintext,
- const uint8_t *ciphertext, int text_size,
- const uint8_t *nonce, int nonce_size,
- const uint8_t *tag, int tag_size);
-
-#endif /* __CROS_EC_FPSENSOR_CRYPTO_H */
diff --git a/include/fpsensor_state.h b/include/fpsensor_state.h
deleted file mode 100644
index 6b752bc86d..0000000000
--- a/include/fpsensor_state.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Copyright 2019 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_STATE_H
-#define __CROS_EC_FPSENSOR_STATE_H
-
-#include <stdbool.h>
-#include <stdint.h>
-#include "common.h"
-#include "ec_commands.h"
-#include "link_defs.h"
-#include "timer.h"
-
-#include "driver/fingerprint/fpsensor.h"
-
-/* if no special memory regions are defined, fallback on regular SRAM */
-#ifndef FP_FRAME_SECTION
-#define FP_FRAME_SECTION
-#endif
-#ifndef FP_TEMPLATE_SECTION
-#define FP_TEMPLATE_SECTION
-#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)
-#define TASK_EVENT_UPDATE_CONFIG TASK_EVENT_CUSTOM_BIT(1)
-
-#define FP_NO_SUCH_TEMPLATE -1
-
-/* --- 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];
-/* Fingers templates for the current user */
-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.
- */
-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];
-/* Index of the last enrolled but not retrieved template. */
-extern int8_t template_newly_enrolled;
-/* Number of used templates */
-extern uint32_t templ_valid;
-/* Bitmap of the templates with local modifications */
-extern uint32_t templ_dirty;
-/* Current user ID */
-extern uint32_t user_id[FP_CONTEXT_USERID_WORDS];
-/* Part of the IKM used to derive encryption keys received from the TPM. */
-extern uint8_t tpm_seed[FP_CONTEXT_TPM_BYTES];
-
-extern uint32_t fp_events;
-
-extern uint32_t sensor_mode;
-
-struct positive_match_secret_state {
- /* Index of the most recently matched template. */
- int8_t template_matched;
- /* Flag indicating positive match secret can be read. */
- bool readable;
- /* Deadline to read positive match secret. */
- timestamp_t deadline;
-};
-
-extern struct positive_match_secret_state positive_match_secret_state;
-
-/* Simulation for unit tests. */
-void fp_task_simulate(void);
-
-/*
- * Clear one fingerprint template.
- *
- * @param idx the index of the template to clear.
- */
-void fp_clear_finger_context(int idx);
-
-/**
- * Clear all fingerprint templates associated with the current user id and
- * reset the sensor.
- */
-void fp_reset_and_clear_context(void);
-
-/*
- * Get the next FP event.
- *
- * @param out the pointer to the output event.
- */
-int fp_get_next_event(uint8_t *out);
-
-/*
- * Check if FP TPM seed has been set.
- *
- * @return 1 if the seed has been set, 0 otherwise.
- */
-int fp_tpm_seed_is_set(void);
-
-/**
- * Change the sensor mode.
- *
- * @param mode new mode to change to
- * @param mode_output resulting mode
- * @return EC_RES_SUCCESS on success. Error code on failure.
- */
-int fp_set_sensor_mode(uint32_t mode, uint32_t *mode_output);
-
-/**
- * Allow reading positive match secret for |fgr| in the next 5 seconds.
- *
- * @param fgr the index of template to enable positive match secret.
- * @param state the state of positive match secret, e.g. readable or not.
- * @return EC_SUCCESS if the request is valid, error code otherwise.
- */
-int fp_enable_positive_match_secret(uint32_t fgr,
- struct positive_match_secret_state *state);
-
-/**
- * Disallow positive match secret for any finger to be read.
- *
- * @param state the state of positive match secret, e.g. readable or not.
- */
-void fp_disable_positive_match_secret(
- struct positive_match_secret_state *state);
-
-#endif /* __CROS_EC_FPSENSOR_STATE_H */