diff options
Diffstat (limited to 'driver/fingerprint/fpc/bep')
-rw-r--r-- | driver/fingerprint/fpc/bep/build.mk | 17 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc1025_private.h | 49 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc1035_private.h | 49 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc_bio_algorithm.h | 136 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc_misc.c | 51 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc_private.c | 268 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc_private.h | 40 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc_sensor_spi.c | 94 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc_sensor_spi.h | 99 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc_timebase.c | 29 | ||||
-rw-r--r-- | driver/fingerprint/fpc/bep/fpc_timebase.h | 48 |
11 files changed, 0 insertions, 880 deletions
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 a94ba2ab06..0000000000 --- a/driver/fingerprint/fpc/bep/fpc_private.c +++ /dev/null @@ -1,268 +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 "gpio.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] __aligned(4) = {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); -} - -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()); - - errors = FP_ERROR_DEAD_PIXELS_UNKNOWN; - - 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; -} - -int fp_maintenance(void) -{ - return fpc_fp_maintenance(&errors); -} diff --git a/driver/fingerprint/fpc/bep/fpc_private.h b/driver/fingerprint/fpc/bep/fpc_private.h deleted file mode 100644 index 9a9acfd42a..0000000000 --- a/driver/fingerprint/fpc/bep/fpc_private.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright 2020 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 - -#include <stdint.h> - -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/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 25d29d77a3..0000000000 --- a/driver/fingerprint/fpc/bep/fpc_sensor_spi.h +++ /dev/null @@ -1,99 +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 controller. - * - * Driver for SPI controller. 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 controller. - * - * @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 */ |