summaryrefslogtreecommitdiff
path: root/driver/fingerprint/fpc
diff options
context:
space:
mode:
authorYicheng Li <yichengli@chromium.org>2021-03-02 15:38:17 -0800
committerCommit Bot <commit-bot@chromium.org>2021-04-02 23:16:12 +0000
commitac08c9d1dbc9f587df3ee6b15d58c0203f7e356e (patch)
tree04cd12d6787ce1b0b99b1d4e0aff504ccfa2c35e /driver/fingerprint/fpc
parente3cbbc3461c83d2d97b78447c53db1c6540cb3be (diff)
downloadchrome-ec-ac08c9d1dbc9f587df3ee6b15d58c0203f7e356e.tar.gz
fpsensor: Support building firmware that works for both sensors
This is a refactoring to allow building FPMCU firmware that works for one FPC sensor and one ELAN sensor. 1. When both drivers implement our common functions, e.g. fp_sensor_init(), rename them to fp_sensor_init_fpc() and fp_sensor_init_elan(). 2. There are a few functions implemented not in FPC driver but in FPC private library, e.g. fp_sensor_finger_status(). I kept this as-is for FPC but renamed the one in ELAN driver to fp_sensor_finger_status_elan() 3. If building for ELAN, need to hardcode elan=1 in hatch_fp/board.c because the sensor type GPIO always says FPC. BRANCH=none BUG=b:175158241 TEST=make run-fpsensor; make run-fpsensor_status; make run-fpsensor_crypto TEST=make -j BOARD=dartmonkey TEST=add CONFIG_FP_SENSOR_ELAN515 to board/hatch_fp/board.h; make -j BOARD=bloonchipper Firmware binary fully works on Dragonair (FPC) and Voema (ELAN) TEST=run device tests with http://crrev/c/2750547 and http://crrev/i/3654297 on Dragonclaw, all pass Change-Id: I789090dbdfe35ac6aefd6a629fa4c7bde89dc437 Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2727971 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Commit-Queue: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'driver/fingerprint/fpc')
-rw-r--r--driver/fingerprint/fpc/bep/fpc1025_private.h12
-rw-r--r--driver/fingerprint/fpc/bep/fpc_private.c56
-rw-r--r--driver/fingerprint/fpc/fpc_sensor.c2
-rw-r--r--driver/fingerprint/fpc/libfp/fpc1145_private.h10
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_private.c50
5 files changed, 90 insertions, 40 deletions
diff --git a/driver/fingerprint/fpc/bep/fpc1025_private.h b/driver/fingerprint/fpc/bep/fpc1025_private.h
index 2da127741f..42dc44130c 100644
--- a/driver/fingerprint/fpc/bep/fpc1025_private.h
+++ b/driver/fingerprint/fpc/bep/fpc1025_private.h
@@ -13,8 +13,8 @@
#define FP_SENSOR_NAME "FPC1025"
/* Sensor pixel resolution */
-#define FP_SENSOR_RES_X (160) /**< Sensor width */
-#define FP_SENSOR_RES_Y (160) /**< Sensor height */
+#define FP_SENSOR_RES_X_FPC (160) /**< Sensor width */
+#define FP_SENSOR_RES_Y_FPC (160) /**< Sensor height */
#define FP_SENSOR_RES_BPP (8) /**< Resolution bits per pixel */
/*
@@ -22,8 +22,8 @@
*
* Value from fpc_bep_image_get_buffer_size(): (160*160)+660
*/
-#define FP_SENSOR_IMAGE_SIZE (26260)
-#define FP_SENSOR_REAL_IMAGE_SIZE (FP_SENSOR_RES_X * FP_SENSOR_RES_Y)
+#define FP_SENSOR_IMAGE_SIZE_FPC (26260)
+#define FP_SENSOR_REAL_IMAGE_SIZE (FP_SENSOR_RES_X_FPC * FP_SENSOR_RES_Y_FPC)
/* Offset of image data in fp_buffer */
#define FP_SENSOR_IMAGE_OFFSET (400)
@@ -41,9 +41,11 @@
*
* Template size + alignment padding + size of template size variable
*/
-#define FP_ALGORITHM_TEMPLATE_SIZE (5088 + 0 + 4)
+#define FP_ALGORITHM_TEMPLATE_SIZE_FPC (5088 + 0 + 4)
/* Max number of templates stored / matched against */
+#ifndef FP_MAX_FINGER_COUNT
#define FP_MAX_FINGER_COUNT (5)
+#endif
#endif /* __CROS_EC_FPC1025_PRIVATE_H */
diff --git a/driver/fingerprint/fpc/bep/fpc_private.c b/driver/fingerprint/fpc/bep/fpc_private.c
index 36ca0fe1b9..7df21c223c 100644
--- a/driver/fingerprint/fpc/bep/fpc_private.c
+++ b/driver/fingerprint/fpc/bep/fpc_private.c
@@ -8,6 +8,7 @@
#include "fpc_bio_algorithm.h"
#include "fpsensor.h"
+#include "fpsensor_fpc.h"
#include "gpio.h"
#include "spi.h"
#include "system.h"
@@ -42,10 +43,10 @@ static struct ec_response_fp_info ec_fp_sensor_info = {
.model_id = 1,
.version = 1,
/* Image frame characteristics */
- .frame_size = FP_SENSOR_IMAGE_SIZE,
+ .frame_size = FP_SENSOR_IMAGE_SIZE_FPC,
.pixel_format = V4L2_PIX_FMT_GREY,
- .width = FP_SENSOR_RES_X,
- .height = FP_SENSOR_RES_Y,
+ .width = FP_SENSOR_RES_X_FPC,
+ .height = FP_SENSOR_RES_Y_FPC,
.bpp = FP_SENSOR_RES_BPP,
};
@@ -63,12 +64,12 @@ extern const fpc_bep_algorithm_t fpc_bep_algorithm_pfe_1025;
const fpc_sensor_info_t fpc_sensor_info = {
.sensor = &fpc_bep_sensor_1025,
- .image_buffer_size = FP_SENSOR_IMAGE_SIZE,
+ .image_buffer_size = FP_SENSOR_IMAGE_SIZE_FPC,
};
const fpc_bio_info_t fpc_bio_info = {
.algorithm = &fpc_bep_algorithm_pfe_1025,
- .template_size = FP_ALGORITHM_TEMPLATE_SIZE,
+ .template_size = FP_ALGORITHM_TEMPLATE_SIZE_FPC,
};
#elif defined(CONFIG_FP_SENSOR_FPC1035)
@@ -109,7 +110,7 @@ static int fpc_send_cmd(const uint8_t cmd)
SPI_READBACK_ALL);
}
-void fp_sensor_low_power(void)
+void fp_sensor_low_power_fpc(void)
{
fpc_send_cmd(FPC_CMD_DEEPSLEEP);
}
@@ -139,7 +140,7 @@ static int fpc_check_hwid(void)
}
/* Reset and initialize the sensor IC */
-int fp_sensor_init(void)
+int fp_sensor_init_fpc(void)
{
int rc;
@@ -172,13 +173,13 @@ int fp_sensor_init(void)
}
/* Go back to low power */
- fp_sensor_low_power();
+ fp_sensor_low_power_fpc();
return EC_SUCCESS;
}
/* Deinitialize the sensor IC */
-int fp_sensor_deinit(void)
+int fp_sensor_deinit_fpc(void)
{
int rc;
@@ -193,7 +194,7 @@ int fp_sensor_deinit(void)
return rc;
}
-int fp_sensor_get_info(struct ec_response_fp_info *resp)
+int fp_sensor_get_info_fpc(struct ec_response_fp_info *resp)
{
int rc;
@@ -212,8 +213,8 @@ int fp_sensor_get_info(struct ec_response_fp_info *resp)
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 fp_finger_match_fpc(void *templ, uint32_t templ_count, uint8_t *image,
+ int32_t *match_index, uint32_t *update_bitmap)
{
int rc;
@@ -226,7 +227,7 @@ int fp_finger_match(void *templ, uint32_t templ_count, uint8_t *image,
return rc;
}
-int fp_enrollment_begin(void)
+int fp_enrollment_begin_fpc(void)
{
int rc;
bio_enrollment_t bio_enroll = enroll_ctx;
@@ -238,7 +239,7 @@ int fp_enrollment_begin(void)
return rc;
}
-int fp_enrollment_finish(void *templ)
+int fp_enrollment_finish_fpc(void *templ)
{
int rc;
bio_enrollment_t bio_enroll = enroll_ctx;
@@ -251,7 +252,7 @@ int fp_enrollment_finish(void *templ)
return rc;
}
-int fp_finger_enroll(uint8_t *image, int *completion)
+int fp_finger_enroll_fpc(uint8_t *image, int *completion)
{
int rc;
bio_enrollment_t bio_enroll = enroll_ctx;
@@ -268,7 +269,30 @@ int fp_finger_enroll(uint8_t *image, int *completion)
return rc;
}
-int fp_maintenance(void)
+int fp_maintenance_fpc(void)
{
return fpc_fp_maintenance(&errors);
}
+
+struct fp_sensor_interface fp_driver_fpc = {
+ .sensor_type = FP_SENSOR_TYPE_FPC,
+ .fp_sensor_init = &fp_sensor_init_fpc,
+ .fp_sensor_deinit = &fp_sensor_deinit_fpc,
+ .fp_sensor_get_info = &fp_sensor_get_info_fpc,
+ .fp_sensor_low_power = &fp_sensor_low_power_fpc,
+ .fp_sensor_configure_detect_ = &fp_sensor_configure_detect,
+ .fp_sensor_finger_status_ = &fp_sensor_finger_status,
+ .fp_sensor_acquire_image_with_mode_ =
+ &fp_sensor_acquire_image_with_mode,
+ .fp_finger_enroll = &fp_finger_enroll_fpc,
+ .fp_finger_match = &fp_finger_match_fpc,
+ .fp_enrollment_begin = &fp_enrollment_begin_fpc,
+ .fp_enrollment_finish = &fp_enrollment_finish_fpc,
+ .fp_maintenance = &fp_maintenance_fpc,
+ .algorithm_template_size = FP_ALGORITHM_TEMPLATE_SIZE_FPC,
+ .encrypted_template_size =
+ FP_ALGORITHM_TEMPLATE_SIZE_FPC + FP_POSITIVE_MATCH_SALT_BYTES +
+ sizeof(struct ec_fp_template_encryption_metadata),
+ .res_x = FP_SENSOR_RES_X_FPC,
+ .res_y = FP_SENSOR_RES_Y_FPC
+};
diff --git a/driver/fingerprint/fpc/fpc_sensor.c b/driver/fingerprint/fpc/fpc_sensor.c
index a15502521f..9184492382 100644
--- a/driver/fingerprint/fpc/fpc_sensor.c
+++ b/driver/fingerprint/fpc/fpc_sensor.c
@@ -33,7 +33,7 @@ int fpc_fp_maintenance(uint16_t *error_state)
if (error_state == NULL)
return EC_ERROR_INVAL;
- rv = fp_sensor_maintenance(fp_buffer, &sensor_info);
+ rv = fp_sensor_maintenance((uint8_t *)&fp_buffer, &sensor_info);
CPRINTS("Maintenance took %d ms", time_since32(start) / MSEC);
if (rv != 0) {
diff --git a/driver/fingerprint/fpc/libfp/fpc1145_private.h b/driver/fingerprint/fpc/libfp/fpc1145_private.h
index 399c75118b..69984c864a 100644
--- a/driver/fingerprint/fpc/libfp/fpc1145_private.h
+++ b/driver/fingerprint/fpc/libfp/fpc1145_private.h
@@ -21,9 +21,9 @@
#define FP_SENSOR_NAME "FPC1145"
/* Sensor pixel resolution */
-#define FP_SENSOR_RES_Y 192
-#define FP_SENSOR_RES_X 56
-#define FP_SENSOR_RES_BPP 8
+#define FP_SENSOR_RES_Y_FPC 192
+#define FP_SENSOR_RES_X_FPC 56
+#define FP_SENSOR_RES_BPP 8
/* Acquired finger frame definitions */
#define FP_SENSOR_IMAGE_SIZE_MODE_VENDOR (35460)
@@ -35,7 +35,7 @@
*/
#define FP_SENSOR_IMAGE_SIZE_MODE_QUAL (24408)
-#define FP_SENSOR_IMAGE_SIZE FP_SENSOR_IMAGE_SIZE_MODE_VENDOR
+#define FP_SENSOR_IMAGE_SIZE_FPC FP_SENSOR_IMAGE_SIZE_MODE_VENDOR
#define FP_SENSOR_IMAGE_OFFSET 2340
/* Opaque FPC context */
@@ -43,7 +43,7 @@
/* Algorithm buffer sizes */
#define FP_ALGORITHM_ENROLLMENT_SIZE 28
-#define FP_ALGORITHM_TEMPLATE_SIZE 47552
+#define FP_ALGORITHM_TEMPLATE_SIZE_FPC 47552
/* Max number of templates stored / matched against */
#define FP_MAX_FINGER_COUNT 5
diff --git a/driver/fingerprint/fpc/libfp/fpc_private.c b/driver/fingerprint/fpc/libfp/fpc_private.c
index 8c11849c8f..a20ff858d3 100644
--- a/driver/fingerprint/fpc/libfp/fpc_private.c
+++ b/driver/fingerprint/fpc/libfp/fpc_private.c
@@ -10,6 +10,7 @@
#include "fpc_bio_algorithm.h"
#include "fpc_private.h"
#include "fpsensor.h"
+#include "fpsensor_fpc.h"
#include "gpio.h"
#include "link_defs.h"
#include "spi.h"
@@ -55,10 +56,10 @@ static struct ec_response_fp_info fpc1145_info = {
.model_id = 1,
.version = 1,
/* Image frame characteristics */
- .frame_size = FP_SENSOR_IMAGE_SIZE,
+ .frame_size = FP_SENSOR_IMAGE_SIZE_FPC,
.pixel_format = V4L2_PIX_FMT_GREY,
- .width = FP_SENSOR_RES_X,
- .height = FP_SENSOR_RES_Y,
+ .width = FP_SENSOR_RES_X_FPC,
+ .height = FP_SENSOR_RES_Y_FPC,
.bpp = FP_SENSOR_RES_BPP,
};
@@ -87,7 +88,7 @@ static int fpc_send_cmd(const uint8_t cmd)
SPI_READBACK_ALL);
}
-void fp_sensor_low_power(void)
+void fp_sensor_low_power_fpc(void)
{
/*
* TODO(b/117620462): verify that sleep mode is WAI (no increased
@@ -175,7 +176,7 @@ static int fpc_pulse_hw_reset(void)
}
/* Reset and initialize the sensor IC */
-int fp_sensor_init(void)
+int fp_sensor_init_fpc(void)
{
int res;
int attempt;
@@ -245,13 +246,13 @@ int fp_sensor_init(void)
errors |= FP_ERROR_INIT_FAIL;
/* Go back to low power */
- fp_sensor_low_power();
+ fp_sensor_low_power_fpc();
return EC_SUCCESS;
}
/* Deinitialize the sensor IC */
-int fp_sensor_deinit(void)
+int fp_sensor_deinit_fpc(void)
{
/*
* TODO(tomhughes): libfp doesn't have fp_sensor_close like BEP does.
@@ -262,7 +263,7 @@ int fp_sensor_deinit(void)
return EC_SUCCESS;
}
-int fp_sensor_get_info(struct ec_response_fp_info *resp)
+int fp_sensor_get_info_fpc(struct ec_response_fp_info *resp)
{
int rc;
@@ -279,14 +280,14 @@ int fp_sensor_get_info(struct ec_response_fp_info *resp)
return EC_SUCCESS;
}
-int fp_finger_match(void *templ, uint32_t templ_count, uint8_t *image,
+int fp_finger_match_fpc(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 fp_enrollment_begin_fpc(void)
{
int rc;
bio_enrollment_t p = enroll_ctx;
@@ -297,14 +298,14 @@ int fp_enrollment_begin(void)
return rc;
}
-int fp_enrollment_finish(void *templ)
+int fp_enrollment_finish_fpc(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 fp_finger_enroll_fpc(uint8_t *image, int *completion)
{
int rc = bio_enrollment_add_image(enroll_ctx, image);
@@ -314,7 +315,30 @@ int fp_finger_enroll(uint8_t *image, int *completion)
return rc;
}
-int fp_maintenance(void)
+int fp_maintenance_fpc(void)
{
return fpc_fp_maintenance(&errors);
}
+
+struct fp_sensor_interface fp_driver_fpc = {
+ .sensor_type = FP_SENSOR_TYPE_FPC,
+ .fp_sensor_init = &fp_sensor_init_fpc,
+ .fp_sensor_deinit = &fp_sensor_deinit_fpc,
+ .fp_sensor_get_info = &fp_sensor_get_info_fpc,
+ .fp_sensor_low_power = &fp_sensor_low_power_fpc,
+ .fp_sensor_configure_detect_ = &fp_sensor_configure_detect,
+ .fp_sensor_finger_status_ = &fp_sensor_finger_status,
+ .fp_sensor_acquire_image_with_mode_ =
+ &fp_sensor_acquire_image_with_mode,
+ .fp_finger_enroll = &fp_finger_enroll_fpc,
+ .fp_finger_match = &fp_finger_match_fpc,
+ .fp_enrollment_begin = &fp_enrollment_begin_fpc,
+ .fp_enrollment_finish = &fp_enrollment_finish_fpc,
+ .fp_maintenance = &fp_maintenance_fpc,
+ .algorithm_template_size = FP_ALGORITHM_TEMPLATE_SIZE_FPC,
+ .encrypted_template_size =
+ FP_ALGORITHM_TEMPLATE_SIZE_FPC + FP_POSITIVE_MATCH_SALT_BYTES +
+ sizeof(struct ec_fp_template_encryption_metadata),
+ .res_x = FP_SENSOR_RES_X_FPC,
+ .res_y = FP_SENSOR_RES_Y_FPC
+};