From: Gwendal Grignou <gwendal@chromium.org> To: enric.balletbo@collabora.com, bleung@chromium.org, groeck@chromium.org, lee.jones@linaro.org, jic23@kernel.org, broonie@kernel.org, cychiang@chromium.org, tiwai@suse.com Cc: linux-iio@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Gwendal Grignou <gwendal@chromium.org> Subject: [PATCH v3 26/30] mfd: cros_ec: Add API for Fingerprint support Date: Thu, 9 May 2019 14:13:49 -0700 Message-ID: <20190509211353.213194-27-gwendal@chromium.org> (raw) In-Reply-To: <20190509211353.213194-1-gwendal@chromium.org> Add API for fingerprint sensor presented by embedded controller. Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Acked-by: Benson Leung <bleung@chromium.org> Signed-off-by: Gwendal Grignou <gwendal@chromium.org> --- include/linux/mfd/cros_ec_commands.h | 228 +++++++++++++++++++++++++++ 1 file changed, 228 insertions(+) diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index 1d0311df44d3..4a9ac3861bdd 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h @@ -5043,6 +5043,234 @@ struct ec_response_pd_chip_info_v1 { }; } __ec_align2; +/*****************************************************************************/ +/* Fingerprint MCU commands: range 0x0400-0x040x */ + +/* Fingerprint SPI sensor passthru command: prototyping ONLY */ +#define EC_CMD_FP_PASSTHRU 0x0400 + +#define EC_FP_FLAG_NOT_COMPLETE 0x1 + +struct ec_params_fp_passthru { + uint16_t len; /* Number of bytes to write then read */ + uint16_t flags; /* EC_FP_FLAG_xxx */ + uint8_t data[]; /* Data to send */ +} __ec_align2; + +/* Configure the Fingerprint MCU behavior */ +#define EC_CMD_FP_MODE 0x0402 + +/* Put the sensor in its lowest power mode */ +#define FP_MODE_DEEPSLEEP BIT(0) +/* Wait to see a finger on the sensor */ +#define FP_MODE_FINGER_DOWN BIT(1) +/* Poll until the finger has left the sensor */ +#define FP_MODE_FINGER_UP BIT(2) +/* Capture the current finger image */ +#define FP_MODE_CAPTURE BIT(3) +/* Finger enrollment session on-going */ +#define FP_MODE_ENROLL_SESSION BIT(4) +/* Enroll the current finger image */ +#define FP_MODE_ENROLL_IMAGE BIT(5) +/* Try to match the current finger image */ +#define FP_MODE_MATCH BIT(6) +/* Reset and re-initialize the sensor. */ +#define FP_MODE_RESET_SENSOR BIT(7) +/* special value: don't change anything just read back current mode */ +#define FP_MODE_DONT_CHANGE BIT(31) + +#define FP_VALID_MODES (FP_MODE_DEEPSLEEP | \ + FP_MODE_FINGER_DOWN | \ + FP_MODE_FINGER_UP | \ + FP_MODE_CAPTURE | \ + FP_MODE_ENROLL_SESSION | \ + FP_MODE_ENROLL_IMAGE | \ + FP_MODE_MATCH | \ + FP_MODE_RESET_SENSOR | \ + FP_MODE_DONT_CHANGE) + +/* Capture types defined in bits [30..28] */ +#define FP_MODE_CAPTURE_TYPE_SHIFT 28 +#define FP_MODE_CAPTURE_TYPE_MASK (0x7 << FP_MODE_CAPTURE_TYPE_SHIFT) +/* + * This enum must remain ordered, if you add new values you must ensure that + * FP_CAPTURE_TYPE_MAX is still the last one. + */ +enum fp_capture_type { + /* Full blown vendor-defined capture (produces 'frame_size' bytes) */ + FP_CAPTURE_VENDOR_FORMAT = 0, + /* Simple raw image capture (produces width x height x bpp bits) */ + FP_CAPTURE_SIMPLE_IMAGE = 1, + /* Self test pattern (e.g. checkerboard) */ + FP_CAPTURE_PATTERN0 = 2, + /* Self test pattern (e.g. inverted checkerboard) */ + FP_CAPTURE_PATTERN1 = 3, + /* Capture for Quality test with fixed contrast */ + FP_CAPTURE_QUALITY_TEST = 4, + /* Capture for pixel reset value test */ + FP_CAPTURE_RESET_TEST = 5, + FP_CAPTURE_TYPE_MAX, +}; +/* Extracts the capture type from the sensor 'mode' word */ +#define FP_CAPTURE_TYPE(mode) (((mode) & FP_MODE_CAPTURE_TYPE_MASK) \ + >> FP_MODE_CAPTURE_TYPE_SHIFT) + +struct ec_params_fp_mode { + uint32_t mode; /* as defined by FP_MODE_ constants */ +} __ec_align4; + +struct ec_response_fp_mode { + uint32_t mode; /* as defined by FP_MODE_ constants */ +} __ec_align4; + +/* Retrieve Fingerprint sensor information */ +#define EC_CMD_FP_INFO 0x0403 + +/* Number of dead pixels detected on the last maintenance */ +#define FP_ERROR_DEAD_PIXELS(errors) ((errors) & 0x3FF) +/* Unknown number of dead pixels detected on the last maintenance */ +#define FP_ERROR_DEAD_PIXELS_UNKNOWN (0x3FF) +/* No interrupt from the sensor */ +#define FP_ERROR_NO_IRQ BIT(12) +/* SPI communication error */ +#define FP_ERROR_SPI_COMM BIT(13) +/* Invalid sensor Hardware ID */ +#define FP_ERROR_BAD_HWID BIT(14) +/* Sensor initialization failed */ +#define FP_ERROR_INIT_FAIL BIT(15) + +struct ec_response_fp_info_v0 { + /* Sensor identification */ + uint32_t vendor_id; + uint32_t product_id; + uint32_t model_id; + uint32_t version; + /* Image frame characteristics */ + uint32_t frame_size; + uint32_t pixel_format; /* using V4L2_PIX_FMT_ */ + uint16_t width; + uint16_t height; + uint16_t bpp; + uint16_t errors; /* see FP_ERROR_ flags above */ +} __ec_align4; + +struct ec_response_fp_info { + /* Sensor identification */ + uint32_t vendor_id; + uint32_t product_id; + uint32_t model_id; + uint32_t version; + /* Image frame characteristics */ + uint32_t frame_size; + uint32_t pixel_format; /* using V4L2_PIX_FMT_ */ + uint16_t width; + uint16_t height; + uint16_t bpp; + uint16_t errors; /* see FP_ERROR_ flags above */ + /* Template/finger current information */ + uint32_t template_size; /* max template size in bytes */ + uint16_t template_max; /* maximum number of fingers/templates */ + uint16_t template_valid; /* number of valid fingers/templates */ + uint32_t template_dirty; /* bitmap of templates with MCU side changes */ + uint32_t template_version; /* version of the template format */ +} __ec_align4; + +/* Get the last captured finger frame or a template content */ +#define EC_CMD_FP_FRAME 0x0404 + +/* constants defining the 'offset' field which also contains the frame index */ +#define FP_FRAME_INDEX_SHIFT 28 +/* Frame buffer where the captured image is stored */ +#define FP_FRAME_INDEX_RAW_IMAGE 0 +/* First frame buffer holding a template */ +#define FP_FRAME_INDEX_TEMPLATE 1 +#define FP_FRAME_GET_BUFFER_INDEX(offset) ((offset) >> FP_FRAME_INDEX_SHIFT) +#define FP_FRAME_OFFSET_MASK 0x0FFFFFFF + +/* Version of the format of the encrypted templates. */ +#define FP_TEMPLATE_FORMAT_VERSION 3 + +/* Constants for encryption parameters */ +#define FP_CONTEXT_NONCE_BYTES 12 +#define FP_CONTEXT_USERID_WORDS (32 / sizeof(uint32_t)) +#define FP_CONTEXT_TAG_BYTES 16 +#define FP_CONTEXT_SALT_BYTES 16 +#define FP_CONTEXT_TPM_BYTES 32 + +struct ec_fp_template_encryption_metadata { + /* + * Version of the structure format (N=3). + */ + uint16_t struct_version; + /* Reserved bytes, set to 0. */ + uint16_t reserved; + /* + * The salt is *only* ever used for key derivation. The nonce is unique, + * a different one is used for every message. + */ + uint8_t nonce[FP_CONTEXT_NONCE_BYTES]; + uint8_t salt[FP_CONTEXT_SALT_BYTES]; + uint8_t tag[FP_CONTEXT_TAG_BYTES]; +}; + +struct ec_params_fp_frame { + /* + * The offset contains the template index or FP_FRAME_INDEX_RAW_IMAGE + * in the high nibble, and the real offset within the frame in + * FP_FRAME_OFFSET_MASK. + */ + uint32_t offset; + uint32_t size; +} __ec_align4; + +/* Load a template into the MCU */ +#define EC_CMD_FP_TEMPLATE 0x0405 + +/* Flag in the 'size' field indicating that the full template has been sent */ +#define FP_TEMPLATE_COMMIT 0x80000000 + +struct ec_params_fp_template { + uint32_t offset; + uint32_t size; + uint8_t data[]; +} __ec_align4; + +/* Clear the current fingerprint user context and set a new one */ +#define EC_CMD_FP_CONTEXT 0x0406 + +struct ec_params_fp_context { + uint32_t userid[FP_CONTEXT_USERID_WORDS]; +} __ec_align4; + +#define EC_CMD_FP_STATS 0x0407 + +#define FPSTATS_CAPTURE_INV BIT(0) +#define FPSTATS_MATCHING_INV BIT(1) + +struct ec_response_fp_stats { + uint32_t capture_time_us; + uint32_t matching_time_us; + uint32_t overall_time_us; + struct { + uint32_t lo; + uint32_t hi; + } overall_t0; + uint8_t timestamps_invalid; + int8_t template_matched; +} __ec_align2; + +#define EC_CMD_FP_SEED 0x0408 +struct ec_params_fp_seed { + /* + * Version of the structure format (N=3). + */ + uint16_t struct_version; + /* Reserved bytes, set to 0. */ + uint16_t reserved; + /* Seed from the TPM. */ + uint8_t seed[FP_CONTEXT_TPM_BYTES]; +} __ec_align4; + /*****************************************************************************/ /* Touchpad MCU commands: range 0x0500-0x05FF */ -- 2.21.0.1020.gf2820cf01a-goog
next prev parent reply index Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-09 21:13 [PATCH v3 00/30] Update cros_ec_commands.h Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 01/30] mfd: cros_ec: Update license term Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 02/30] mfd: cros_ec: Zero BUILD_ macro Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 03/30] mfd: cros_ec: set comments properly Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 04/30] mfd: cros_ec: add ec_align macros Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 05/30] mfd: cros_ec: Define commands as 4-digit UPPER CASE hex values Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 06/30] mfd: cros_ec: use BIT macro Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 07/30] mfd: cros_ec: Update ACPI interface definition Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 08/30] mfd: cros_ec: move HDMI CEC API definition Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 09/30] mfd: cros_ec: Remove zero-size structs Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 10/30] mfd: cros_ec: Add Flash V2 commands API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 11/30] mfd: cros_ec: Add PWM_SET_DUTY API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 12/30] mfd: cros_ec: Add lightbar v2 API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 13/30] mfd: cros_ec: Expand hash API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 14/30] mfd: cros_ec: Add EC transport protocol v4 Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 15/30] mfd: cros_ec: Complete MEMS sensor API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 16/30] mfd: cros_ec: Fix event processing API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 17/30] mfd: cros_ec: Add fingerprint API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 18/30] mfd: cros_ec: Fix temperature API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 19/30] mfd: cros_ec: Complete Power and USB PD API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 20/30] mfd: cros_ec: Add API for keyboard testing Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 21/30] mfd: cros_ec: Add Hibernate API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 22/30] mfd: cros_ec: Add Smart Battery Firmware update API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 23/30] mfd: cros_ec: Add I2C passthru protection API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 24/30] mfd: cros_ec: Add API for EC-EC communication Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 25/30] mfd: cros_ec: Add API for Touchpad support Gwendal Grignou 2019-05-09 21:13 ` Gwendal Grignou [this message] 2019-05-09 21:13 ` [PATCH v3 27/30] mfd: cros_ec: Add API for rwsig Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 28/30] mfd: cros_ec: Add SKU ID and Secure storage API Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 29/30] mfd: cros_ec: Add Management API entry points Gwendal Grignou 2019-05-09 21:13 ` [PATCH v3 30/30] mfd: cros_ec: Update I2S API Gwendal Grignou 2019-05-17 22:48 ` [PATCH v3 00/30] Update cros_ec_commands.h Gwendal Grignou 2019-05-18 6:39 ` Lee Jones 2019-05-21 17:44 ` Benson Leung 2019-05-22 5:53 ` Lee Jones 2019-05-21 13:45 ` [alsa-devel] " Fabien Lahoudere 2019-05-22 5:53 ` Lee Jones 2019-06-03 12:53 ` Lee Jones
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190509211353.213194-27-gwendal@chromium.org \ --to=gwendal@chromium.org \ --cc=alsa-devel@alsa-project.org \ --cc=bleung@chromium.org \ --cc=broonie@kernel.org \ --cc=cychiang@chromium.org \ --cc=enric.balletbo@collabora.com \ --cc=groeck@chromium.org \ --cc=jic23@kernel.org \ --cc=lee.jones@linaro.org \ --cc=linux-iio@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=tiwai@suse.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-IIO Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \ linux-iio@vger.kernel.org public-inbox-index linux-iio Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio AGPL code for this site: git clone https://public-inbox.org/public-inbox.git