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
);
116 int (*verify
)(struct fp_dev
*dev
, struct fp_print_data
*data
);
119 enum fp_print_data_type
fpi_driver_get_data_type(struct fp_driver
*drv
);
121 /* flags for fp_img_driver.flags */
122 #define FP_IMGDRV_SUPPORTS_UNCONDITIONAL_CAPTURE (1 << 0)
124 struct fp_img_driver
{
125 struct fp_driver driver
;
129 unsigned int enlarge_factor
;
132 /* Device operations */
133 int (*init
)(struct fp_img_dev
*dev
, unsigned long driver_data
);
134 void (*exit
)(struct fp_img_dev
*dev
);
135 int (*await_finger_on
)(struct fp_img_dev
*dev
);
136 int (*await_finger_off
)(struct fp_img_dev
*dev
);
137 int (*capture
)(struct fp_img_dev
*dev
, gboolean unconditional
,
138 struct fp_img
**image
);
141 extern struct fp_driver upekts_driver
;
142 extern struct fp_img_driver uru4000_driver
;
143 extern struct fp_img_driver aes4000_driver
;
145 void fpi_img_driver_setup(struct fp_img_driver
*idriver
);
147 #define fpi_driver_to_img_driver(drv) \
148 container_of((drv), struct fp_img_driver, driver)
151 struct usb_device
*udev
;
152 struct fp_driver
*drv
;
153 unsigned long driver_data
;
157 struct fp_dscv_print
{
160 enum fp_finger finger
;
164 enum fp_print_data_type
{
165 PRINT_DATA_RAW
= 0, /* memset-imposed default */
166 PRINT_DATA_NBIS_MINUTIAE
,
169 struct fp_print_data
{
172 enum fp_print_data_type type
;
174 unsigned char data
[0];
177 struct fpi_print_data_fp1
{
181 unsigned char data_type
;
182 unsigned char data
[0];
183 } __attribute__((__packed__
));
185 void fpi_data_exit(void);
186 struct fp_print_data
*fpi_print_data_new(struct fp_dev
*dev
, size_t length
);
187 gboolean
fpi_print_data_compatible(uint16_t driver_id1
, uint32_t devtype1
,
188 enum fp_print_data_type type1
, uint16_t driver_id2
, uint32_t devtype2
,
189 enum fp_print_data_type type2
);
191 /* bit values for fp_img.flags */
192 #define FP_IMG_V_FLIPPED (1<<0)
193 #define FP_IMG_H_FLIPPED (1<<1)
194 #define FP_IMG_COLORS_INVERTED (1<<2)
201 unsigned char data
[0];
204 struct fp_img
*fpi_img_new(size_t length
);
205 struct fp_img
*fpi_img_new_for_imgdev(struct fp_img_dev
*dev
);
206 struct fp_img
*fpi_img_resize(struct fp_img
*img
, size_t newsize
);
207 gboolean
fpi_img_is_sane(struct fp_img
*img
);
208 int fpi_img_detect_minutiae(struct fp_img_dev
*imgdev
, struct fp_img
*img
,
209 struct fp_print_data
**ret
);
210 int fpi_img_compare_print_data(struct fp_print_data
*enrolled_print
,
211 struct fp_print_data
*new_print
);