1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H
#define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H
#define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
#define FINGERPRINT_HARDWARE_MODULE_ID "fingerprint"
typedef enum fingerprint_msg_type {
FINGERPRINT_ERROR = -1,
FINGERPRINT_SCANNED = 1,
FINGERPRINT_TEMPLATE_ENROLLING = 2,
FINGERPRINT_TEMPLATE_REMOVED = 4
} fingerprint_msg_type_t;
typedef enum fingerprint_error {
FINGERPRINT_ERROR_HW_UNAVAILABLE = 1,
FINGERPRINT_ERROR_BAD_CAPTURE = 2,
FINGERPRINT_ERROR_TIMEOUT = 3,
FINGERPRINT_ERROR_NO_SPACE = 4 /* No space available to store a template */
} fingerprint_error_t;
typedef struct fingerprint_enroll {
uint32_t id;
/* samples_remaining goes from N (no data collected, but N scans needed)
* to 0 (no more data is needed to build a template)
* If HAL fails to decrement samples_remaining between calls the client
* will declare template collection a failure and should abort the operation
* by calling module->common.methods->close() */
uint32_t samples_remaining;
} fingerprint_enroll_t;
typedef struct fingerprint_removed {
uint32_t id;
} fingerprint_removed_t;
typedef struct fingerprint_scanned {
uint32_t id; /* 0 is a special id and means no match */
uint32_t confidence; /* Goes form 0 (no match) to 0xffffFFFF (100% sure) */
} fingerprint_scanned_t;
typedef struct fingerprint_msg {
fingerprint_msg_type_t type;
union {
uint64_t raw;
fingerprint_error_t error;
fingerprint_enroll_t enroll;
fingerprint_removed_t removed;
fingerprint_scanned_t scan;
} data;
} fingerprint_msg_t;
/* Callback function type */
typedef void (*fingerprint_notify_t)(fingerprint_msg_t msg);
/* Synchronous operation */
typedef struct fingerprint_device {
struct hw_device_t common;
/*
* Fingerprint enroll request:
* Switches the HAL state machine to collect and store a new fingerprint
* template. Switches back as soon as enroll is complete
* (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING &&
* fingerprint_msg.data.enroll.samples_remaining == 0)
* or after timeout_sec seconds.
*
* Function return: 0 if enrollment process can be successfully started
* -1 otherwise. A notify() function may be called
* indicating the error condition.
*/
int (*enroll)(struct fingerprint_device *dev, uint32_t timeout_sec);
/*
* Fingerprint remove request:
* deletes a fingerprint template.
* If the fingerprint id is 0 the entire template database will be removed.
* notify() will be called for each template deleted with
* fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED and
* fingerprint_msg.data.removed.id indicating each template id removed.
*
* Function return: 0 if fingerprint template(s) can be successfully deleted
* -1 otherwise.
*/
int (*remove)(struct fingerprint_device *dev, uint32_t fingerprint_id);
/*
* Set notification callback:
* Registers a user function that would receive notifications from the HAL
* The call will block if the HAL state machine is in busy state until HAL
* leaves the busy state.
*
* Function return: 0 if callback function is successfuly registered
* -1 otherwise.
*/
int (*set_notify)(struct fingerprint_device *dev,
fingerprint_notify_t notify);
/*
* Client provided callback function to receive notifications.
* Do not set by hand, use the function above instead.
*/
fingerprint_notify_t notify;
/* Reserved for future use. Must be NULL. */
void* reserved[8 - 4];
} fingerprint_device_t;
typedef struct fingerprint_module {
struct hw_module_t common;
} fingerprint_module_t;
#endif /* ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H */
|