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