Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 1 | /* |
| 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 Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 23 | typedef enum fingerprint_msg_type { |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 24 | FINGERPRINT_ERROR = -1, |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 25 | FINGERPRINT_SCANNED = 1, |
Sasha Levitskiy | 0d1cd3f | 2014-04-30 13:29:43 -0700 | [diff] [blame] | 26 | FINGERPRINT_TEMPLATE_ENROLLING = 2, |
| 27 | FINGERPRINT_TEMPLATE_REMOVED = 4 |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 28 | } fingerprint_msg_type_t; |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 29 | |
| 30 | typedef enum fingerprint_error { |
| 31 | FINGERPRINT_ERROR_HW_UNAVAILABLE = 1, |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 32 | FINGERPRINT_ERROR_BAD_CAPTURE = 2, |
Sasha Levitskiy | 0d1cd3f | 2014-04-30 13:29:43 -0700 | [diff] [blame] | 33 | FINGERPRINT_ERROR_TIMEOUT = 3, |
| 34 | FINGERPRINT_ERROR_NO_SPACE = 4 /* No space available to store a template */ |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 35 | } fingerprint_error_t; |
| 36 | |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 37 | typedef struct fingerprint_enroll { |
| 38 | uint32_t id; |
Sasha Levitskiy | 3b9ee8d | 2014-04-23 10:04:57 -0700 | [diff] [blame] | 39 | /* samples_remaining goes from N (no data collected, but N scans needed) |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 40 | * to 0 (no more data is needed to build a template) |
| 41 | * If HAL fails to decrement samples_remaining between calls the client |
| 42 | * will declare template collection a failure and should abort the operation |
Sasha Levitskiy | 3b9ee8d | 2014-04-23 10:04:57 -0700 | [diff] [blame] | 43 | * by calling module->common.methods->close() */ |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 44 | uint32_t samples_remaining; |
| 45 | } fingerprint_enroll_t; |
| 46 | |
Sasha Levitskiy | 0d1cd3f | 2014-04-30 13:29:43 -0700 | [diff] [blame] | 47 | typedef struct fingerprint_removed { |
| 48 | uint32_t id; |
| 49 | } fingerprint_removed_t; |
| 50 | |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 51 | typedef struct fingerprint_scanned { |
| 52 | uint32_t id; /* 0 is a special id and means no match */ |
| 53 | uint32_t confidence; /* Goes form 0 (no match) to 0xffffFFFF (100% sure) */ |
Sasha Levitskiy | cc14f23 | 2014-04-24 09:52:47 -0700 | [diff] [blame] | 54 | } fingerprint_scanned_t; |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 55 | |
| 56 | typedef struct fingerprint_msg { |
| 57 | fingerprint_msg_type_t type; |
| 58 | union { |
| 59 | uint64_t raw; |
| 60 | fingerprint_error_t error; |
| 61 | fingerprint_enroll_t enroll; |
Sasha Levitskiy | 0d1cd3f | 2014-04-30 13:29:43 -0700 | [diff] [blame] | 62 | fingerprint_removed_t removed; |
Sasha Levitskiy | cc14f23 | 2014-04-24 09:52:47 -0700 | [diff] [blame] | 63 | fingerprint_scanned_t scan; |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 64 | } data; |
| 65 | } fingerprint_msg_t; |
| 66 | |
| 67 | /* Callback function type */ |
| 68 | typedef void (*fingerprint_notify_t)(fingerprint_msg_t msg); |
| 69 | |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 70 | /* Synchronous operation */ |
| 71 | typedef struct fingerprint_device { |
| 72 | struct hw_device_t common; |
| 73 | |
| 74 | /* |
Sasha Levitskiy | 3b9ee8d | 2014-04-23 10:04:57 -0700 | [diff] [blame] | 75 | * Fingerprint enroll request: |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 76 | * Switches the HAL state machine to collect and store a new fingerprint |
| 77 | * template. Switches back as soon as enroll is complete |
Sasha Levitskiy | 0d1cd3f | 2014-04-30 13:29:43 -0700 | [diff] [blame] | 78 | * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING && |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 79 | * fingerprint_msg.data.enroll.samples_remaining == 0) |
Sasha Levitskiy | 3b9ee8d | 2014-04-23 10:04:57 -0700 | [diff] [blame] | 80 | * or after timeout_sec seconds. |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 81 | * |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 82 | * Function return: 0 if enrollment process can be successfully started |
Sasha Levitskiy | 0d1cd3f | 2014-04-30 13:29:43 -0700 | [diff] [blame] | 83 | * -1 otherwise. A notify() function may be called |
| 84 | * indicating the error condition. |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 85 | */ |
Sasha Levitskiy | 3b9ee8d | 2014-04-23 10:04:57 -0700 | [diff] [blame] | 86 | int (*enroll)(struct fingerprint_device *dev, uint32_t timeout_sec); |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 87 | |
| 88 | /* |
Sasha Levitskiy | 3b9ee8d | 2014-04-23 10:04:57 -0700 | [diff] [blame] | 89 | * Fingerprint remove request: |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 90 | * deletes a fingerprint template. |
| 91 | * If the fingerprint id is 0 the entire template database will be removed. |
Sasha Levitskiy | 0d1cd3f | 2014-04-30 13:29:43 -0700 | [diff] [blame] | 92 | * notify() will be called for each template deleted with |
| 93 | * fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED and |
| 94 | * fingerprint_msg.data.removed.id indicating each template id removed. |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 95 | * |
Sasha Levitskiy | 0d1cd3f | 2014-04-30 13:29:43 -0700 | [diff] [blame] | 96 | * Function return: 0 if fingerprint template(s) can be successfully deleted |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 97 | * -1 otherwise. |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 98 | */ |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 99 | int (*remove)(struct fingerprint_device *dev, uint32_t fingerprint_id); |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 100 | |
| 101 | /* |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 102 | * Set notification callback: |
| 103 | * Registers a user function that would receive notifications from the HAL |
| 104 | * The call will block if the HAL state machine is in busy state until HAL |
| 105 | * leaves the busy state. |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 106 | * |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 107 | * Function return: 0 if callback function is successfuly registered |
| 108 | * -1 otherwise. |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 109 | */ |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 110 | int (*set_notify)(struct fingerprint_device *dev, |
| 111 | fingerprint_notify_t notify); |
| 112 | |
| 113 | /* |
| 114 | * Client provided callback function to receive notifications. |
| 115 | * Do not set by hand, use the function above instead. |
| 116 | */ |
| 117 | fingerprint_notify_t notify; |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 118 | |
| 119 | /* Reserved for future use. Must be NULL. */ |
Sasha Levitskiy | 7308284 | 2014-04-18 11:14:11 -0700 | [diff] [blame] | 120 | void* reserved[8 - 4]; |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 121 | } fingerprint_device_t; |
| 122 | |
| 123 | typedef struct fingerprint_module { |
| 124 | struct hw_module_t common; |
| 125 | } fingerprint_module_t; |
| 126 | |
Sasha Levitskiy | a747c06 | 2014-03-24 16:14:42 -0700 | [diff] [blame] | 127 | #endif /* ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H */ |