summaryrefslogtreecommitdiff
path: root/driver/fingerprint/fpc/libfp
diff options
context:
space:
mode:
Diffstat (limited to 'driver/fingerprint/fpc/libfp')
-rw-r--r--driver/fingerprint/fpc/libfp/build.mk15
-rw-r--r--driver/fingerprint/fpc/libfp/fpc1145_private.h51
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h265
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_private.c320
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_private.h131
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_sensor_pal.c60
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_sensor_pal.h118
7 files changed, 0 insertions, 960 deletions
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 399c75118b..0000000000
--- a/driver/fingerprint/fpc/libfp/fpc1145_private.h
+++ /dev/null
@@ -1,51 +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 hardware ID is 16-bits. All 114x FPC sensors (including FPC1145) are
- * detected with the pattern 0x1400 and mask 0xFFF0. All supported variants of
- * the 1145 (0x140B, 0x140C, and 0x1401) should be detected as part of the FPC
- * 1140 family with identical functionality.
- * See http://b/150407388 for additional details.
- */
-#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 34fc61f66c..0000000000
--- a/driver/fingerprint/fpc/libfp/fpc_private.c
+++ /dev/null
@@ -1,320 +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] __aligned(4);
-
-/* 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);
-}
-
-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;
-}
-
-int fp_maintenance(void)
-{
- return fpc_fp_maintenance(&errors);
-}
diff --git a/driver/fingerprint/fpc/libfp/fpc_private.h b/driver/fingerprint/fpc/libfp/fpc_private.h
deleted file mode 100644
index 95313726f6..0000000000
--- a/driver/fingerprint/fpc/libfp/fpc_private.h
+++ /dev/null
@@ -1,131 +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);
-
-typedef struct {
- uint32_t num_defective_pixels;
-} fp_sensor_info_t;
-
-/**
- * fp_sensor_maintenance runs a test for defective pixels and should
- * be triggered periodically by the client. Internally, a defective
- * pixel list is maintained and the algorithm will compensate for
- * any defect pixels when matching towards a template.
- *
- * The defective pixel update will abort and return an error if any of
- * the finger detect zones are covered. A client can call
- * fp_sensor_finger_status to determine the current status.
- *
- * @param[in] image_data pointer to FP_SENSOR_IMAGE_SIZE bytes of memory
- * @param[out] fp_sensor_info Structure containing output data.
- *
- * @return
- * - 0 on success
- * - negative value on error
- */
-int fp_sensor_maintenance(uint8_t *image_data,
- fp_sensor_info_t *fp_sensor_info);
-
-/* Read the HWID from the sensor. */
-int fpc_check_hwid(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_