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 /* Darwin does endianness slightly differently */
32 #include <machine/endian.h>
33 #define __BYTE_ORDER BYTE_ORDER
34 #define __LITTLE_ENDIAN LITTLE_ENDIAN
35 #define __BIG_ENDIAN BIG_ENDIAN
42 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a))
44 #define container_of(ptr, type, member) ({ \
45 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
46 (type *)( (char *)__mptr - offsetof(type,member) );})
55 void fpi_log(enum fpi_log_level
, const char *component
, const char *function
,
56 const char *format
, ...);
59 #define FP_COMPONENT NULL
63 #define _fpi_log(level, fmt...) fpi_log(level, FP_COMPONENT, __FUNCTION__, fmt)
65 #define _fpi_log(level, fmt...)
68 #ifdef ENABLE_DEBUG_LOGGING
69 #define fp_dbg(fmt...) _fpi_log(LOG_LEVEL_DEBUG, fmt)
71 #define fp_dbg(fmt...)
74 #define fp_info(fmt...) _fpi_log(LOG_LEVEL_INFO, fmt)
75 #define fp_warn(fmt...) _fpi_log(LOG_LEVEL_WARNING, fmt)
76 #define fp_err(fmt...) _fpi_log(LOG_LEVEL_ERROR, fmt)
79 struct fp_driver
*drv
;
85 /* drivers should not mess with these */
98 unsigned long driver_data
;
101 enum fp_driver_type
{
102 DRIVER_PRIMITIVE
= 0,
108 const char *full_name
;
109 const struct usb_id
* const id_table
;
110 enum fp_driver_type type
;
114 /* Device operations */
115 int (*init
)(struct fp_dev
*dev
, unsigned long driver_data
);
116 void (*exit
)(struct fp_dev
*dev
);
117 int (*enroll
)(struct fp_dev
*dev
, gboolean initial
, int stage
,
118 struct fp_print_data
**print_data
);
119 int (*verify
)(struct fp_dev
*dev
, struct fp_print_data
*data
);
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
;
131 /* Device operations */
132 int (*init
)(struct fp_img_dev
*dev
, unsigned long driver_data
);
133 void (*exit
)(struct fp_img_dev
*dev
);
134 int (*await_finger_on
)(struct fp_img_dev
*dev
);
135 int (*await_finger_off
)(struct fp_img_dev
*dev
);
136 int (*capture
)(struct fp_img_dev
*dev
, gboolean unconditional
,
137 struct fp_img
**image
);
140 extern struct fp_driver upekts_driver
;
141 extern struct fp_img_driver uru4000_driver
;
142 extern struct fp_img_driver aes4000_driver
;
144 void fpi_img_driver_setup(struct fp_img_driver
*idriver
);
146 #define fpi_driver_to_img_driver(drv) \
147 container_of((drv), struct fp_img_driver, driver)
150 struct usb_device
*udev
;
151 struct fp_driver
*drv
;
152 unsigned long driver_data
;
155 struct fp_print_data
{
156 const char *driver_name
;
158 unsigned char buffer
[0];
161 struct fp_print_data
*fpi_print_data_new(struct fp_dev
*dev
, size_t length
);
162 int fpi_print_data_compatible(struct fp_dev
*dev
, struct fp_print_data
*data
);
164 /* bit values for fp_img.flags */
165 #define FP_IMG_V_FLIPPED (1<<0)
166 #define FP_IMG_H_FLIPPED (1<<1)
167 #define FP_IMG_COLORS_INVERTED (1<<2)
174 unsigned char data
[0];
177 struct fp_img
*fpi_img_new(size_t length
);
178 struct fp_img
*fpi_img_new_for_imgdev(struct fp_img_dev
*dev
);
179 struct fp_img
*fpi_img_resize(struct fp_img
*img
, size_t newsize
);
180 gboolean
fpi_img_is_sane(struct fp_img
*img
);
181 int fpi_img_detect_minutiae(struct fp_img_dev
*imgdev
, struct fp_img
*img
,
182 struct fp_print_data
**ret
);
183 int fpi_img_compare_print_data(struct fp_print_data
*enrolled_print
,
184 struct fp_print_data
*new_print
);
186 #define bswap16(x) (((x & 0xff) << 8) | (x >> 8))
187 #if __BYTE_ORDER == __LITTLE_ENDIAN
188 #define cpu_to_le16(x) (x)
189 #define le16_to_cpu(x) (x)
190 #define cpu_to_be16(x) bswap16(x)
191 #define be16_to_cpu(x) bswap16(x)
192 #elif __BYTE_ORDER == __BIG_ENDIAN
193 #define cpu_to_le16(x) bswap16(x)
194 #define le16_to_cpu(x) bswap16(x)
195 #define cpu_to_be16(x) (x)
196 #define be16_to_cpu(x) (x)
198 #error "Unrecognized endianness"