summaryrefslogtreecommitdiff
path: root/driver/fingerprint
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2020-06-12 11:47:20 -0700
committerCommit Bot <commit-bot@chromium.org>2020-08-06 19:49:15 +0000
commit69bab88511023f0742aa2794698b3cab7f816eb6 (patch)
tree1168e999fc5352991aaa41d291b553e97dc7b7d6 /driver/fingerprint
parent821d9748590b7fc4bde0ecb40037677b44d4186b (diff)
downloadchrome-ec-69bab88511023f0742aa2794698b3cab7f816eb6.tar.gz
driver/fingerprint: Add a common sensor maintenance function
Add a new console command "fpmaintenance" for testing. BRANCH=none BUG=b:76037094 TEST=With dragonclaw v0.2 connected to Segger J-Trace and servo micro: ./util/flash_jlink.py On FP console: > fpmaintenance Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I7125f8783d3dd7e815612d20742c9d949d00ba71 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2323709 Reviewed-by: Yicheng Li <yichengli@chromium.org>
Diffstat (limited to 'driver/fingerprint')
-rw-r--r--driver/fingerprint/fpc/bep/fpc_private.c5
-rw-r--r--driver/fingerprint/fpc/build.mk8
-rw-r--r--driver/fingerprint/fpc/fpc_sensor.c44
-rw-r--r--driver/fingerprint/fpc/fpc_sensor.h2
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_private.c5
5 files changed, 64 insertions, 0 deletions
diff --git a/driver/fingerprint/fpc/bep/fpc_private.c b/driver/fingerprint/fpc/bep/fpc_private.c
index 7621edabd3..36ca0fe1b9 100644
--- a/driver/fingerprint/fpc/bep/fpc_private.c
+++ b/driver/fingerprint/fpc/bep/fpc_private.c
@@ -267,3 +267,8 @@ int fp_finger_enroll(uint8_t *image, int *completion)
return rc;
}
+
+int fp_maintenance(void)
+{
+ return fpc_fp_maintenance(&errors);
+}
diff --git a/driver/fingerprint/fpc/build.mk b/driver/fingerprint/fpc/build.mk
index ab6a6a4b9c..d5e3ede14e 100644
--- a/driver/fingerprint/fpc/build.mk
+++ b/driver/fingerprint/fpc/build.mk
@@ -14,3 +14,11 @@ include $(_fpc_cur_dir)bep/build.mk
else ifeq ($(CONFIG_FP_SENSOR_FPC1035),rw)
include $(_fpc_cur_dir)bep/build.mk
endif
+
+ifeq ($(CONFIG_FP_SENSOR),rw)
+# Make sure output directory is created (in build directory)
+dirs-y+="$(_fpc_cur_dir)"
+
+# Only build these objects for the RW image
+all-obj-rw+=$(_fpc_cur_dir)fpc_sensor.o
+endif
diff --git a/driver/fingerprint/fpc/fpc_sensor.c b/driver/fingerprint/fpc/fpc_sensor.c
new file mode 100644
index 0000000000..92a3db51c9
--- /dev/null
+++ b/driver/fingerprint/fpc/fpc_sensor.c
@@ -0,0 +1,44 @@
+/* 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.
+ */
+
+#include <stddef.h>
+#include <include/fpsensor.h>
+#include <include/fpsensor_state.h>
+#include <common/fpsensor/fpsensor_private.h>
+#if defined(CONFIG_FP_SENSOR_FPC1025) || defined(CONFIG_FP_SENSOR_FPC1035)
+#include "bep/fpc_private.h"
+#elif defined(CONFIG_FP_SENSOR_FPC1145)
+#include "libfp/fpc_private.h"
+#else
+#error "Sensor type not defined!"
+#endif
+#include "fpc_sensor.h"
+
+int fpc_fp_maintenance(uint16_t *error_state)
+{
+ int rv;
+ fp_sensor_info_t sensor_info;
+ timestamp_t start = get_time();
+
+ if (error_state == NULL)
+ return EC_ERROR_INVAL;
+
+ rv = fp_sensor_maintenance(fp_buffer, &sensor_info);
+ CPRINTS("Maintenance took %d ms", time_since32(start) / MSEC);
+
+ if (rv != 0) {
+ /*
+ * Failure can occur if any of the fingerprint detection zones
+ * are covered (i.e., finger is on sensor).
+ */
+ CPRINTS("Failed to run maintenance: %d", rv);
+ return EC_ERROR_HW_INTERNAL;
+ }
+
+ *error_state |= FP_ERROR_DEAD_PIXELS(sensor_info.num_defective_pixels);
+ CPRINTS("num_defective_pixels: %d", sensor_info.num_defective_pixels);
+
+ return EC_SUCCESS;
+}
diff --git a/driver/fingerprint/fpc/fpc_sensor.h b/driver/fingerprint/fpc/fpc_sensor.h
index da67696a0c..2ab9248eeb 100644
--- a/driver/fingerprint/fpc/fpc_sensor.h
+++ b/driver/fingerprint/fpc/fpc_sensor.h
@@ -18,4 +18,6 @@
#error "Sensor type not defined!"
#endif
+int fpc_fp_maintenance(uint16_t *error_state);
+
#endif /* __CROS_EC_DRIVER_FINGERPRINT_FPC_FPC_SENSOR_H_ */
diff --git a/driver/fingerprint/fpc/libfp/fpc_private.c b/driver/fingerprint/fpc/libfp/fpc_private.c
index e734a94734..8c11849c8f 100644
--- a/driver/fingerprint/fpc/libfp/fpc_private.c
+++ b/driver/fingerprint/fpc/libfp/fpc_private.c
@@ -313,3 +313,8 @@ int fp_finger_enroll(uint8_t *image, int *completion)
*completion = bio_enrollment_get_percent_complete(enroll_ctx);
return rc;
}
+
+int fp_maintenance(void)
+{
+ return fpc_fp_maintenance(&errors);
+}