blob: 7f6fa28f62460129feabeca6ec6b9ff6d0a7e759 [file] [log] [blame]
Sasha Levitskiya747c062014-03-24 16:14:42 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H
18#define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H
19
20#define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
21#define FINGERPRINT_HARDWARE_MODULE_ID "fingerprint"
22
Sasha Levitskiy73082842014-04-18 11:14:11 -070023typedef enum fingerprint_msg_type {
Sasha Levitskiya747c062014-03-24 16:14:42 -070024 FINGERPRINT_ERROR = -1,
Sasha Levitskiy73082842014-04-18 11:14:11 -070025 FINGERPRINT_SCANNED = 1,
Sasha Levitskiy0d1cd3f2014-04-30 13:29:43 -070026 FINGERPRINT_TEMPLATE_ENROLLING = 2,
27 FINGERPRINT_TEMPLATE_REMOVED = 4
Sasha Levitskiy73082842014-04-18 11:14:11 -070028} fingerprint_msg_type_t;
Sasha Levitskiya747c062014-03-24 16:14:42 -070029
30typedef enum fingerprint_error {
31 FINGERPRINT_ERROR_HW_UNAVAILABLE = 1,
Sasha Levitskiy73082842014-04-18 11:14:11 -070032 FINGERPRINT_ERROR_BAD_CAPTURE = 2,
Sasha Levitskiy0d1cd3f2014-04-30 13:29:43 -070033 FINGERPRINT_ERROR_TIMEOUT = 3,
34 FINGERPRINT_ERROR_NO_SPACE = 4 /* No space available to store a template */
Sasha Levitskiya747c062014-03-24 16:14:42 -070035} fingerprint_error_t;
36
Sasha Levitskiy73082842014-04-18 11:14:11 -070037typedef struct fingerprint_enroll {
38 uint32_t id;
Sasha Levitskiy3b9ee8d2014-04-23 10:04:57 -070039 /* samples_remaining goes from N (no data collected, but N scans needed)
Sasha Levitskiy969466c2014-05-07 09:07:11 -070040 * to 0 (no more data is needed to build a template).
41 * The progress indication may be augmented by a bitmap encoded indication
42 * of finger area that needs to be presented by the user.
43 * Bit numbers mapped to physical location:
44 *
45 * distal
46 * +-+-+-+
47 * |2|1|0|
48 * |5|4|3|
49 * medial |8|7|6| lateral
50 * |b|a|9|
51 * |e|d|c|
52 * +-+-+-+
53 * proximal
54 *
55 */
56 uint16_t data_collected_bmp;
57 uint16_t samples_remaining;
Sasha Levitskiy73082842014-04-18 11:14:11 -070058} fingerprint_enroll_t;
59
Sasha Levitskiy0d1cd3f2014-04-30 13:29:43 -070060typedef struct fingerprint_removed {
61 uint32_t id;
62} fingerprint_removed_t;
63
Sasha Levitskiy73082842014-04-18 11:14:11 -070064typedef struct fingerprint_scanned {
65 uint32_t id; /* 0 is a special id and means no match */
Sasha Levitskiycc14f232014-04-24 09:52:47 -070066} fingerprint_scanned_t;
Sasha Levitskiy73082842014-04-18 11:14:11 -070067
68typedef struct fingerprint_msg {
69 fingerprint_msg_type_t type;
70 union {
71 uint64_t raw;
72 fingerprint_error_t error;
73 fingerprint_enroll_t enroll;
Sasha Levitskiy0d1cd3f2014-04-30 13:29:43 -070074 fingerprint_removed_t removed;
Sasha Levitskiycc14f232014-04-24 09:52:47 -070075 fingerprint_scanned_t scan;
Sasha Levitskiy73082842014-04-18 11:14:11 -070076 } data;
77} fingerprint_msg_t;
78
79/* Callback function type */
80typedef void (*fingerprint_notify_t)(fingerprint_msg_t msg);
81
Sasha Levitskiya747c062014-03-24 16:14:42 -070082/* Synchronous operation */
83typedef struct fingerprint_device {
Stewart Miles84d35492014-05-01 09:03:27 -070084 /**
85 * Common methods of the fingerprint device. This *must* be the first member of
86 * fingerprint_device as users of this structure will cast a hw_device_t to
87 * fingerprint_device pointer in contexts where it's known the hw_device_t references a
88 * fingerprint_device.
89 */
Sasha Levitskiya747c062014-03-24 16:14:42 -070090 struct hw_device_t common;
91
92 /*
Sasha Levitskiy3b9ee8d2014-04-23 10:04:57 -070093 * Fingerprint enroll request:
Sasha Levitskiy73082842014-04-18 11:14:11 -070094 * Switches the HAL state machine to collect and store a new fingerprint
95 * template. Switches back as soon as enroll is complete
Sasha Levitskiy0d1cd3f2014-04-30 13:29:43 -070096 * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING &&
Sasha Levitskiy73082842014-04-18 11:14:11 -070097 * fingerprint_msg.data.enroll.samples_remaining == 0)
Sasha Levitskiy3b9ee8d2014-04-23 10:04:57 -070098 * or after timeout_sec seconds.
Sasha Levitskiya747c062014-03-24 16:14:42 -070099 *
Sasha Levitskiy73082842014-04-18 11:14:11 -0700100 * Function return: 0 if enrollment process can be successfully started
Sasha Levitskiy0d1cd3f2014-04-30 13:29:43 -0700101 * -1 otherwise. A notify() function may be called
102 * indicating the error condition.
Sasha Levitskiya747c062014-03-24 16:14:42 -0700103 */
Sasha Levitskiy3b9ee8d2014-04-23 10:04:57 -0700104 int (*enroll)(struct fingerprint_device *dev, uint32_t timeout_sec);
Sasha Levitskiya747c062014-03-24 16:14:42 -0700105
106 /*
Sasha Levitskiy969466c2014-05-07 09:07:11 -0700107 * Cancel fingerprint enroll request:
108 * Switches the HAL state machine back to accept a fingerprint scan mode.
109 * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING &&
110 * fingerprint_msg.data.enroll.samples_remaining == 0)
111 * will indicate switch back to the scan mode.
112 *
113 * Function return: 0 if cancel request is accepted
114 * -1 otherwise.
115 */
116 int (*enroll_cancel)(struct fingerprint_device *dev);
117
118 /*
Sasha Levitskiy3b9ee8d2014-04-23 10:04:57 -0700119 * Fingerprint remove request:
Sasha Levitskiy73082842014-04-18 11:14:11 -0700120 * deletes a fingerprint template.
121 * If the fingerprint id is 0 the entire template database will be removed.
Sasha Levitskiy0d1cd3f2014-04-30 13:29:43 -0700122 * notify() will be called for each template deleted with
123 * fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED and
124 * fingerprint_msg.data.removed.id indicating each template id removed.
Sasha Levitskiya747c062014-03-24 16:14:42 -0700125 *
Sasha Levitskiy0d1cd3f2014-04-30 13:29:43 -0700126 * Function return: 0 if fingerprint template(s) can be successfully deleted
Sasha Levitskiy73082842014-04-18 11:14:11 -0700127 * -1 otherwise.
Sasha Levitskiya747c062014-03-24 16:14:42 -0700128 */
Sasha Levitskiy73082842014-04-18 11:14:11 -0700129 int (*remove)(struct fingerprint_device *dev, uint32_t fingerprint_id);
Sasha Levitskiya747c062014-03-24 16:14:42 -0700130
131 /*
Sasha Levitskiy73082842014-04-18 11:14:11 -0700132 * Set notification callback:
133 * Registers a user function that would receive notifications from the HAL
134 * The call will block if the HAL state machine is in busy state until HAL
135 * leaves the busy state.
Sasha Levitskiya747c062014-03-24 16:14:42 -0700136 *
Sasha Levitskiy73082842014-04-18 11:14:11 -0700137 * Function return: 0 if callback function is successfuly registered
138 * -1 otherwise.
Sasha Levitskiya747c062014-03-24 16:14:42 -0700139 */
Sasha Levitskiy73082842014-04-18 11:14:11 -0700140 int (*set_notify)(struct fingerprint_device *dev,
141 fingerprint_notify_t notify);
142
143 /*
144 * Client provided callback function to receive notifications.
145 * Do not set by hand, use the function above instead.
146 */
147 fingerprint_notify_t notify;
Sasha Levitskiya747c062014-03-24 16:14:42 -0700148
149 /* Reserved for future use. Must be NULL. */
Sasha Levitskiy73082842014-04-18 11:14:11 -0700150 void* reserved[8 - 4];
Sasha Levitskiya747c062014-03-24 16:14:42 -0700151} fingerprint_device_t;
152
153typedef struct fingerprint_module {
Stewart Miles84d35492014-05-01 09:03:27 -0700154 /**
155 * Common methods of the fingerprint module. This *must* be the first member of
156 * fingerprint_module as users of this structure will cast a hw_module_t to
157 * fingerprint_module pointer in contexts where it's known the hw_module_t references a
158 * fingerprint_module.
159 */
Sasha Levitskiya747c062014-03-24 16:14:42 -0700160 struct hw_module_t common;
161} fingerprint_module_t;
162
Sasha Levitskiya747c062014-03-24 16:14:42 -0700163#endif /* ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H */