summaryrefslogtreecommitdiff
path: root/driver/fingerprint/elan/elan_setting.h
diff options
context:
space:
mode:
authorChiehchun Yu <chiehchun.yu@elan.corp-partner.google.com>2020-01-16 14:44:50 +0800
committerCommit Bot <commit-bot@chromium.org>2021-01-12 20:47:52 +0000
commit3775fdbf7e863603eb65ec52348a45d7139db628 (patch)
tree9b9bc902067543a51db1d7772e348a2a15f9e437 /driver/fingerprint/elan/elan_setting.h
parent4167ccc6fc40b865d5eb9f6e13b7a95f9aba0f19 (diff)
downloadchrome-ec-3775fdbf7e863603eb65ec52348a45d7139db628.tar.gz
elan_private: Implement elan sensor driver
This patch provides ELAN FP APIs that used to control ELAN FP sensor and matching algorithm. BRANCH=None BUG=None TEST=We build on nami_fp, and testing Elan sensor with libelan_515.a and libelan_80.a successfully. Change-Id: I7a58025106f8ed570860b758323bf2047cde0731 Signed-off-by: Chiehchun Yu <chiehchun.yu@elan.corp-partner.google.com> Signed-off-by: herman lin <herman.lin@emc.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2002994 Reviewed-by: Yicheng Li <yichengli@chromium.org> Tested-by: Yicheng Li <yichengli@chromium.org> Commit-Queue: Yicheng Li <yichengli@chromium.org>
Diffstat (limited to 'driver/fingerprint/elan/elan_setting.h')
-rw-r--r--driver/fingerprint/elan/elan_setting.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/driver/fingerprint/elan/elan_setting.h b/driver/fingerprint/elan/elan_setting.h
new file mode 100644
index 0000000000..f7b16627b6
--- /dev/null
+++ b/driver/fingerprint/elan/elan_setting.h
@@ -0,0 +1,101 @@
+/* Copyright 2021 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 ELAN_SETTING_H
+#define ELAN_SETTING_H
+
+#include <stdint.h>
+
+/* The hardware ID information and FW version */
+#define VID 0x04F3
+#define PID 0x0903
+#define MID 0x01
+#define VERSION 0x100A
+
+/* SPI tx and rx buffer size */
+#define CONFIG_SPI_TX_BUF_SIZE 1024
+#define CONFIG_SPI_RX_BUF_SIZE 5120
+
+/**
+ * Elan sensor operation is controlled by sending commands and receiving
+ * through the SPI interface. There are several SPI command codes for
+ * controlling FP sensor:
+ *
+ * - START_SCAN Start scan
+ * - START_READ_IMAGE Start read the image
+ * - SRST Software reset
+ * - FUSE_LOAD Load OTP trims data to control registers
+ * - READ_REG_HEAD Register single read
+ * - WRITE_REG_HEAD Register burst write
+ * - READ_SERIER_REG_HEAD Register burst read
+ * - PAGE_SEL Register page selection
+ * - SENSOR_STATUS Read sensor status
+ */
+#define START_SCAN 0x01
+#define START_READ_IMAGE 0x10
+#define SRST 0x31
+#define FUSE_LOAD 0x04
+#define READ_REG_HEAD 0x40
+#define WRITE_REG_HEAD 0x80
+#define READ_SERIER_REG_HEAD 0xC0
+#define PAGE_SEL 0x07
+#define SENSOR_STATUS 0x03
+
+/* Sensor type name */
+#define EFSA515 1
+#define EFSA80SC 2
+#if defined(CONFIG_FP_SENSOR_ELAN80)
+#define IC_SELECTION EFSA80SC
+#elif defined(CONFIG_FP_SENSOR_ELAN515)
+#define IC_SELECTION EFSA515
+#endif
+
+/* Sensor pixel resolution */
+#if (IC_SELECTION == EFSA80SC)
+#define IMAGE_WIDTH 80
+#define IMAGE_HEIGHT 80
+#elif (IC_SELECTION == EFSA515)
+#define IMAGE_WIDTH 150
+#define IMAGE_HEIGHT 52
+#endif
+
+/**
+ * Sensor real image size:
+ * ((IMAGE_HEIGHT * ONE_PIXEL_BYTE) + FP_DUMMY_BYTE) * IMAGE_WIDTH
+ */
+#define FP_DUMMY_BYTE 2
+#define ONE_PIXEL_BYTE 2
+#define IMAGE_TOTAL_PIXEL (IMAGE_WIDTH * IMAGE_HEIGHT)
+#define RAW_PIXEL_SIZE (IMAGE_HEIGHT * ONE_PIXEL_BYTE)
+#define RAW_DATA_SIZE (RAW_PIXEL_SIZE + FP_DUMMY_BYTE)
+#define IMG_BUF_SIZE (RAW_DATA_SIZE * IMAGE_WIDTH)
+
+/* Polling scan status counter */
+#define POLLING_SCAN_TIMER 10000
+
+/* Re-calibration timer */
+#define REK_TIMES 3
+
+/* Console output macros */
+#define LOGE_SA(format, args...) cprints(CC_FP, format, ##args)
+
+/**
+ * Set ELAN fingerprint sensor register initialization
+ *
+ * @return 0 on success.
+ * negative value on error.
+ */
+int register_initialization(void);
+
+/**
+ * To calibrate ELAN fingerprint sensor and keep the calibration results
+ * for correcting fingerprint image data
+ *
+ * @return 0 on success.
+ * negative value on error.
+ */
+int calibration(void);
+
+#endif /* _ELAN_SETTING_H */