2 * Internal/private definitions for libfprint
3 * Copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef __FPRINT_INTERNAL_H__
21 #define __FPRINT_INTERNAL_H__
31 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a))
33 #define container_of(ptr, type, member) ({ \
34 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
35 (type *)( (char *)__mptr - offsetof(type,member) );})
44 void fpi_log(enum fpi_log_level
, const char *component
, const char *function
,
45 const char *format
, ...);
48 #define FP_COMPONENT NULL
52 #define _fpi_log(level, fmt...) fpi_log(level, FP_COMPONENT, __FUNCTION__, fmt)
54 #define _fpi_log(level, fmt...)
57 #ifdef ENABLE_DEBUG_LOGGING
58 #define fp_dbg(fmt...) _fpi_log(LOG_LEVEL_DEBUG, fmt)
60 #define fp_dbg(fmt...)
63 #define fp_info(fmt...) _fpi_log(LOG_LEVEL_INFO, fmt)
64 #define fp_warn(fmt...) _fpi_log(LOG_LEVEL_WARNING, fmt)
65 #define fp_err(fmt...) _fpi_log(LOG_LEVEL_ERROR, fmt)
68 struct fp_driver
*drv
;
75 /* drivers should not mess with these */
85 int fpi_imgdev_capture(struct fp_img_dev
*imgdev
, int unconditional
,
86 struct fp_img
**image
);
87 int fpi_imgdev_get_img_width(struct fp_img_dev
*imgdev
);
88 int fpi_imgdev_get_img_height(struct fp_img_dev
*imgdev
);
93 unsigned long driver_data
;
104 const char *full_name
;
105 const struct usb_id
* const id_table
;
106 enum fp_driver_type type
;
110 /* Device operations */
111 int (*discover
)(const struct usb_id
*usb_id
, uint32_t *devtype
);
112 int (*init
)(struct fp_dev
*dev
, unsigned long driver_data
);
113 void (*exit
)(struct fp_dev
*dev
);
114 int (*enroll
)(struct fp_dev
*dev
, gboolean initial
, int stage
,
115 struct fp_print_data
**print_data
, struct fp_img
**img
);
116 int (*verify
)(struct fp_dev
*dev
, struct fp_print_data
*data
,
117 struct fp_img
**img
);
120 enum fp_print_data_type
fpi_driver_get_data_type(struct fp_driver
*drv
);
122 /* flags for fp_img_driver.flags */
123 #define FP_IMGDRV_SUPPORTS_UNCONDITIONAL_CAPTURE (1 << 0)
125 struct fp_img_driver
{
126 struct fp_driver driver
;
130 unsigned int enlarge_factor
;
133 /* Device operations */
134 int (*init
)(struct fp_img_dev
*dev
, unsigned long driver_data
);
135 void (*exit
)(struct fp_img_dev
*dev
);
136 int (*await_finger_on
)(struct fp_img_dev
*dev
);
137 int (*await_finger_off
)(struct fp_img_dev
*dev
);
138 int (*capture
)(struct fp_img_dev
*dev
, gboolean unconditional
,
139 struct fp_img
**image
);
142 extern struct fp_driver upekts_driver
;
143 extern struct fp_img_driver uru4000_driver
;
144 extern struct fp_img_driver aes2501_driver
;
145 extern struct fp_img_driver aes4000_driver
;
147 void fpi_img_driver_setup(struct fp_img_driver
*idriver
);
149 #define fpi_driver_to_img_driver(drv) \
150 container_of((drv), struct fp_img_driver, driver)
153 struct usb_device
*udev
;
154 struct fp_driver
*drv
;
155 unsigned long driver_data
;
159 struct fp_dscv_print
{
162 enum fp_finger finger
;
166 enum fp_print_data_type
{
167 PRINT_DATA_RAW
= 0, /* memset-imposed default */
168 PRINT_DATA_NBIS_MINUTIAE
,
171 struct fp_print_data
{
174 enum fp_print_data_type type
;
176 unsigned char data
[0];
179 struct fpi_print_data_fp1
{
183 unsigned char data_type
;
184 unsigned char data
[0];
185 } __attribute__((__packed__
));
187 void fpi_data_exit(void);
188 struct fp_print_data
*fpi_print_data_new(struct fp_dev
*dev
, size_t length
);
189 gboolean
fpi_print_data_compatible(uint16_t driver_id1
, uint32_t devtype1
,
190 enum fp_print_data_type type1
, uint16_t driver_id2
, uint32_t devtype2
,
191 enum fp_print_data_type type2
);
193 /* bit values for fp_img.flags */
194 #define FP_IMG_V_FLIPPED (1<<0)
195 #define FP_IMG_H_FLIPPED (1<<1)
196 #define FP_IMG_COLORS_INVERTED (1<<2)
203 unsigned char data
[0];
206 struct fp_img
*fpi_img_new(size_t length
);
207 struct fp_img
*fpi_img_new_for_imgdev(struct fp_img_dev
*dev
);
208 struct fp_img
*fpi_img_resize(struct fp_img
*img
, size_t newsize
);
209 gboolean
fpi_img_is_sane(struct fp_img
*img
);
210 int fpi_img_detect_minutiae(struct fp_img_dev
*imgdev
, struct fp_img
*img
,
211 struct fp_print_data
**ret
);
212 int fpi_img_compare_print_data(struct fp_print_data
*enrolled_print
,
213 struct fp_print_data
*new_print
);