2 * Core functions for libfprint
3 * Copyright (C) 2007-2008 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
27 #include "fp_internal.h"
29 libusb_context
*fpi_usb_ctx
= NULL
;
30 GSList
*opened_devices
= NULL
;
33 * \mainpage libfprint API Reference
34 * libfprint is an open source library to provide access to fingerprint
35 * scanning devices. For more info, see the
36 * <a href="http://www.reactivated.net/fprint/Libfprint">libfprint project
39 * This documentation is aimed at application developers who wish to integrate
40 * fingerprint-related functionality into their software. libfprint has been
41 * designed so that you only have to do this once - by integrating your
42 * software with libfprint, you'll be supporting all the fingerprint readers
43 * that we have got our hands on. As such, the API is rather general (and
44 * therefore hopefully easy to comprehend!), and does it's best to hide the
45 * technical details that required to operate the hardware.
47 * This documentation is not aimed at developers wishing to develop and
48 * contribute fingerprint device drivers to libfprint.
50 * Feedback on this API and it's associated documentation is appreciated. Was
51 * anything unclear? Does anything seem unreasonably complicated? Is anything
52 * missing? Let us know on the
53 * <a href="http://www.reactivated.net/fprint/Mailing_list">mailing list</a>.
55 * \section enrollment Enrollment
57 * Before you dive into the API, it's worth introducing a couple of concepts.
59 * The process of enrolling a finger is where you effectively scan your
60 * finger for the purposes of teaching the system what your finger looks like.
61 * This means that you scan your fingerprint, then the system processes it and
62 * stores some data about your fingerprint to refer to later.
64 * \section verification Verification
66 * Verification is what most people think of when they think about fingerprint
67 * scanning. The process of verification is effectively performing a fresh
68 * fingerprint scan, and then comparing that scan to a finger that was
69 * previously enrolled.
71 * As an example scenario, verification can be used to implement what people
72 * would picture as fingerprint login (i.e. fingerprint replaces password).
74 * - I enroll my fingerprint through some software that trusts I am who I say
75 * I am. This is a prerequisite before I can perform fingerprint-based
76 * login for my account.
77 * - Some time later, I want to login to my computer. I enter my username,
78 * but instead of prompting me for a password, it asks me to scan my finger.
80 * - The system compares the finger I just scanned to the one that was
81 * enrolled earlier. If the system decides that the fingerprints match,
82 * I am successfully logged in. Otherwise, the system informs me that I am
83 * not authorised to login as that user.
85 * \section identification Identification
87 * Identification is the process of comparing a freshly scanned fingerprint
88 * to a <em>collection</em> of previously enrolled fingerprints. For example,
89 * imagine there are 100 people in an organisation, and they all have enrolled
90 * their fingerprints. One user walks up to a fingerprint scanner and scans
91 * their finger. With <em>no other knowledge</em> of who that user might be,
92 * the system examines their fingerprint, looks in the database, and determines
93 * that the user is user number #61.
95 * In other words, verification might be seen as a one-to-one fingerprint
96 * comparison where you know the identity of the user that you wish to
97 * authenticate, whereas identification is a one-to-many comparison where you
98 * do not know the identity of the user that you wish to authenticate.
100 * \section compat_general Device and print compatibility
101 * Moving off generic conceptual ideas and onto libfprint-specific
102 * implementation details, here are some introductory notes regarding how
103 * libfprint copes with compatibility of fingerprints.
105 * libfprint deals with a whole variety of different fingerprint readers and
106 * the design includes considerations of compatibility and interoperability
107 * between multiple devices. Your application should also be prepared to
108 * work with more than one type of fingerprint reader and should consider that
109 * enrolled fingerprint X may not be compatible with the device the user has
112 * libfprint implements the principle that fingerprints from different devices
113 * are not necessarily compatible. For example, different devices may see
114 * significantly different areas of fingerprint surface, and comparing images
115 * between the devices would be unreliable. Also, devices can stretch and
116 * distort images in different ways.
118 * libfprint also implements the principle that in some cases, fingerprints
119 * <em>are</em> compatible between different devices. If you go and buy two
120 * identical fingerprint readers, it seems logical that you should be able
121 * to enroll on one and verify on another without problems.
123 * libfprint takes a fairly simplistic approach to these issues. Internally,
124 * fingerprint hardware is driven by individual drivers. libfprint enforces
125 * that a fingerprint that came from a device backed by driver X is never
126 * compared to a fingerprint that came from a device backed by driver Y.
128 * Additionally, libfprint is designed for the situation where a single driver
129 * may support a range of devices which differ in imaging or scanning
130 * properties. For example, a driver may support two ranges of devices which
131 * even though are programmed over the same interface, one device sees
132 * substantially less of the finger flesh, therefore images from the two
133 * device types should be incompatible despite being from the same driver. To
134 * implement this, each driver assigns a <em>device type</em> to each device
135 * that it detects based on its imaging characteristics. libfprint ensures that
136 * two prints being compared have the same device type.
138 * In summary, libfprint represents fingerprints in several internal structures
139 * and each representation will offer you a way of determining the
140 * \ref driver_id "driver ID" and \ref devtype "devtype" of the print in
141 * question. Prints are only compatible if the driver ID <b>and</b> devtypes
142 * match. libfprint does offer you some "is this print compatible?" helper
143 * functions, so you don't have to worry about these details too much.
145 * \section sync Synchronity/asynchronity
147 * Currently, all data acquisition operations are synchronous and can
148 * potentially block for extended periods of time. For example, the enroll
149 * function will block for an unpredictable amount of time until the user
150 * scans their finger.
152 * Alternative asynchronous/non-blocking functionality will be offered in
153 * future but has not been implemented yet.
155 * \section getting_started Getting started
157 * libfprint includes several simple functional examples under the examples/
158 * directory in the libfprint source distribution. Those are good starting
161 * Usually the first thing you want to do is determine which fingerprint
162 * devices are present. This is done through \ref dscv_dev "device discovery".
164 * Once you have found a device you would like to operate, you should open it.
165 * Refer to \ref dev "device operations". This section also details enrollment,
166 * image capture, and verification.
169 * That should be enough to get you started, but do remember there are
170 * documentation pages on other aspects of libfprint's API (see the modules
174 /** @defgroup core Core library operations */
177 * @defgroup dev Device operations
178 * In order to interact with fingerprint scanners, your software will
179 * interface primarily with libfprint's representation of devices, detailed
182 * \section enrolling Enrolling
183 * Enrolling is represented within libfprint as a multi-stage process. This
184 * slightly complicates things for application developers, but is required
185 * for a smooth process.
187 * Some devices require the user to scan their finger multiple times in
188 * order to complete the enrollment process. libfprint must return control
189 * to your application inbetween each scan in order for your application to
190 * instruct the user to swipe their finger again. Each scan is referred to
191 * as a stage, so a device that requires 3 scans for enrollment corresponds
192 * to you running 3 enrollment stages using libfprint.
194 * The fp_dev_get_nr_enroll_stages() function can be used to find out how
195 * many enroll stages are needed.
197 * In order to complete an enroll stage, you call an enroll function such
198 * as fp_enroll_finger(). The return of this function does not necessarily
199 * indicate that a stage has completed though, as the user may not have
200 * produced a good enough scan. Each stage may have to be retried several
203 * The exact semantics of the enroll functions are described in the
204 * fp_enroll_finger() documentation. You should pay careful attention to the
207 * \section imaging Imaging
208 * libfprint provides you with some ways to retrieve images of scanned
209 * fingers, such as the fp_dev_img_capture() function, or some enroll/verify
210 * function variants which provide images. You may wish to do something with
211 * such images in your application.
213 * However, you must be aware that not all hardware supported by libfprint
214 * operates like this. Most hardware does operate simply by sending
215 * fingerprint images to the host computer for further processing, but some
216 * devices do all fingerprint processing in hardware and do not present images
217 * to the host computer.
219 * You can use fp_dev_supports_imaging() to see if image capture is possible
220 * on a particular device. Your application must be able to cope with the
221 * fact that libfprint does support regular operations (e.g. enrolling and
222 * verification) on some devices which do not provide images.
224 * \section devtype Devtypes
225 * Internally, the \ref drv "driver" behind a device assigns a 32-bit
226 * <em>devtype</em> identifier to the device. This cannot be used as a unique
227 * ID for a specific device as many devices under the same range may share
228 * the same devtype. The devtype may even be 0 in all cases.
230 * The only reason you may be interested in retrieving the devtype for a
231 * device is for the purpose of checking if some print data is compatible
232 * with a device. libfprint uses the devtype as one way of checking that the
233 * print you are verifying is compatible with the device in question - the
234 * devtypes must be equal. This effectively allows drivers to support more
235 * than one type of device where the data from each one is not compatible with
236 * the other. Note that libfprint does provide you with helper functions to
237 * determine whether a print is compatible with a device, so under most
238 * circumstances, you don't have to worry about devtypes at all.
241 /** @defgroup dscv_dev Device discovery
242 * These functions allow you to scan the system for supported fingerprint
243 * scanning hardware. This is your starting point when integrating libfprint
244 * into your software.
246 * When you've identified a discovered device that you would like to control,
247 * you can open it with fp_dev_open(). Note that discovered devices may no
248 * longer be available at the time when you want to open them, for example
249 * the user may have unplugged the device.
252 /** @defgroup drv Driver operations
253 * Internally, libfprint is abstracted into various drivers to communicate
254 * with the different types of supported fingerprint readers. libfprint works
255 * hard so that you don't have to care about these internal abstractions,
256 * however there are some situations where you may be interested in a little
257 * behind-the-scenes driver info.
259 * You can obtain the driver for a device using fp_dev_get_driver(), which
260 * you can pass to the functions documented on this page.
262 * \section driver_id Driver IDs
263 * Each driver is assigned a unique ID by the project maintainer. These
265 * <a href="http://www.reactivated.net/fprint/Driver_ID_assignments">
266 * documented on the wiki</a> and will never change.
268 * The only reason you may be interested in retrieving the driver ID for a
269 * driver is for the purpose of checking if some print data is compatible
270 * with a device. libfprint uses the driver ID as one way of checking that
271 * the print you are trying to verify is compatible with the device in
272 * question - it ensures that enrollment data from one driver is never fed to
273 * another. Note that libfprint does provide you with helper functions to
274 * determine whether a print is compatible with a device, so under most
275 * circumstances, you don't have to worry about driver IDs at all.
278 static GSList
*registered_drivers
= NULL
;
280 void fpi_log(enum fpi_log_level level
, const char *component
,
281 const char *function
, const char *format
, ...)
284 FILE *stream
= stdout
;
291 case LOG_LEVEL_WARNING
:
295 case LOG_LEVEL_ERROR
:
299 case LOG_LEVEL_DEBUG
:
309 fprintf(stream
, "%s:%s [%s] ", component
? component
: "fp", prefix
,
312 va_start (args
, format
);
313 vfprintf(stream
, format
, args
);
316 fprintf(stream
, "\n");
319 static void register_driver(struct fp_driver
*drv
)
322 fp_err("not registering driver %s: driver ID is 0", drv
->name
);
325 registered_drivers
= g_slist_prepend(registered_drivers
, (gpointer
) drv
);
326 fp_dbg("registered driver %s", drv
->name
);
329 static struct fp_driver
* const primitive_drivers
[] = {
335 static struct fp_img_driver
* const img_drivers
[] = {
336 #ifdef ENABLE_AES4000
339 #ifdef ENABLE_AES2501
342 #ifdef ENABLE_URU4000
348 #ifdef ENABLE_UPEKSONLY
352 #ifdef ENABLE_AES1610
358 #ifdef ENABLE_FDU2000
364 static void register_drivers(void)
368 for (i
= 0; i
< G_N_ELEMENTS(primitive_drivers
); i
++)
369 register_driver(primitive_drivers
[i
]);
371 for (i
= 0; i
< G_N_ELEMENTS(img_drivers
); i
++) {
372 struct fp_img_driver
*imgdriver
= img_drivers
[i
];
373 fpi_img_driver_setup(imgdriver
);
374 register_driver(&imgdriver
->driver
);
378 API_EXPORTED
struct fp_driver
**fprint_get_drivers (void)
383 array
= g_ptr_array_new ();
384 for (i
= 0; i
< G_N_ELEMENTS(primitive_drivers
); i
++)
385 g_ptr_array_add (array
, primitive_drivers
[i
]);
387 for (i
= 0; i
< G_N_ELEMENTS(img_drivers
); i
++)
388 g_ptr_array_add (array
, &(img_drivers
[i
]->driver
));
390 /* Add a null item terminating the array */
391 g_ptr_array_add (array
, NULL
);
393 return (struct fp_driver
**) g_ptr_array_free (array
, FALSE
);
396 static struct fp_driver
*find_supporting_driver(libusb_device
*udev
,
397 const struct usb_id
**usb_id
)
400 GSList
*elem
= registered_drivers
;
401 struct libusb_device_descriptor dsc
;
403 ret
= libusb_get_device_descriptor(udev
, &dsc
);
405 fp_err("Failed to get device descriptor");
410 struct fp_driver
*drv
= elem
->data
;
411 const struct usb_id
*id
;
413 for (id
= drv
->id_table
; id
->vendor
; id
++)
414 if (dsc
.idVendor
== id
->vendor
&& dsc
.idProduct
== id
->product
) {
415 fp_dbg("driver %s supports USB device %04x:%04x",
416 drv
->name
, id
->vendor
, id
->product
);
420 } while ((elem
= g_slist_next(elem
)));
424 static struct fp_dscv_dev
*discover_dev(libusb_device
*udev
)
426 const struct usb_id
*usb_id
;
427 struct fp_driver
*drv
= find_supporting_driver(udev
, &usb_id
);
428 struct fp_dscv_dev
*ddev
;
429 uint32_t devtype
= 0;
435 int r
= drv
->discover(usb_id
, &devtype
);
437 fp_err("%s discover failed, code %d", drv
->name
, r
);
442 ddev
= g_malloc0(sizeof(*ddev
));
445 ddev
->driver_data
= usb_id
->driver_data
;
446 ddev
->devtype
= devtype
;
450 /** \ingroup dscv_dev
451 * Scans the system and returns a list of discovered devices. This is your
452 * entry point into finding a fingerprint reader to operate.
453 * \returns a NULL-terminated list of discovered devices. Must be freed with
454 * fp_dscv_devs_free() after use.
456 API_EXPORTED
struct fp_dscv_dev
**fp_discover_devs(void)
458 GSList
*tmplist
= NULL
;
459 struct fp_dscv_dev
**list
;
461 libusb_device
**devs
;
466 if (registered_drivers
== NULL
)
469 r
= libusb_get_device_list(fpi_usb_ctx
, &devs
);
471 fp_err("couldn't enumerate USB devices, error %d", r
);
475 /* Check each device against each driver, temporarily storing successfully
476 * discovered devices in a GSList.
478 * Quite inefficient but excusable as we'll only be dealing with small
479 * sets of drivers against small sets of USB devices */
480 while ((udev
= devs
[i
++]) != NULL
) {
481 struct fp_dscv_dev
*ddev
= discover_dev(udev
);
484 tmplist
= g_slist_prepend(tmplist
, (gpointer
) ddev
);
488 /* Convert our temporary GSList into a standard NULL-terminated pointer
490 list
= g_malloc(sizeof(*list
) * (dscv_count
+ 1));
491 if (dscv_count
> 0) {
492 GSList
*elem
= tmplist
;
495 list
[i
++] = elem
->data
;
496 } while ((elem
= g_slist_next(elem
)));
498 list
[dscv_count
] = NULL
; /* NULL-terminate */
500 g_slist_free(tmplist
);
504 /** \ingroup dscv_dev
505 * Free a list of discovered devices. This function destroys the list and all
506 * discovered devices that it included, so make sure you have opened your
507 * discovered device <b>before</b> freeing the list.
508 * \param devs the list of discovered devices. If NULL, function simply
511 API_EXPORTED
void fp_dscv_devs_free(struct fp_dscv_dev
**devs
)
517 for (i
= 0; devs
[i
]; i
++)
522 /** \ingroup dscv_dev
523 * Gets the \ref drv "driver" for a discovered device.
524 * \param dev the discovered device
525 * \returns the driver backing the device
527 API_EXPORTED
struct fp_driver
*fp_dscv_dev_get_driver(struct fp_dscv_dev
*dev
)
532 /** \ingroup dscv_dev
533 * Gets the \ref devtype "devtype" for a discovered device.
534 * \param dev the discovered device
535 * \returns the devtype of the device
537 API_EXPORTED
uint32_t fp_dscv_dev_get_devtype(struct fp_dscv_dev
*dev
)
542 enum fp_print_data_type
fpi_driver_get_data_type(struct fp_driver
*drv
)
545 case DRIVER_PRIMITIVE
:
546 return PRINT_DATA_RAW
;
548 return PRINT_DATA_NBIS_MINUTIAE
;
550 fp_err("unrecognised drv type %d", drv
->type
);
551 return PRINT_DATA_RAW
;
555 /** \ingroup dscv_dev
556 * Determines if a specific \ref print_data "stored print" appears to be
557 * compatible with a discovered device.
558 * \param dev the discovered device
559 * \param data the print for compatibility checking
560 * \returns 1 if the print is compatible with the device, 0 otherwise
562 API_EXPORTED
int fp_dscv_dev_supports_print_data(struct fp_dscv_dev
*dev
,
563 struct fp_print_data
*data
)
565 return fpi_print_data_compatible(dev
->drv
->id
, dev
->devtype
,
566 fpi_driver_get_data_type(dev
->drv
), data
->driver_id
, data
->devtype
,
570 /** \ingroup dscv_dev
571 * Determines if a specific \ref dscv_print "discovered print" appears to be
572 * compatible with a discovered device.
573 * \param dev the discovered device
574 * \param data the discovered print for compatibility checking
575 * \returns 1 if the print is compatible with the device, 0 otherwise
577 API_EXPORTED
int fp_dscv_dev_supports_dscv_print(struct fp_dscv_dev
*dev
,
578 struct fp_dscv_print
*data
)
580 return fpi_print_data_compatible(dev
->drv
->id
, dev
->devtype
, 0,
581 data
->driver_id
, data
->devtype
, 0);
584 /** \ingroup dscv_dev
585 * Searches a list of discovered devices for a device that appears to be
586 * compatible with a \ref print_data "stored print".
587 * \param devs a list of discovered devices
588 * \param data the print under inspection
589 * \returns the first discovered device that appears to support the print, or
590 * NULL if no apparently compatible devices could be found
592 API_EXPORTED
struct fp_dscv_dev
*fp_dscv_dev_for_print_data(struct fp_dscv_dev
**devs
,
593 struct fp_print_data
*data
)
595 struct fp_dscv_dev
*ddev
;
598 for (i
= 0; (ddev
= devs
[i
]); i
++)
599 if (fp_dscv_dev_supports_print_data(ddev
, data
))
604 /** \ingroup dscv_dev
605 * Searches a list of discovered devices for a device that appears to be
606 * compatible with a \ref dscv_print "discovered print".
607 * \param devs a list of discovered devices
608 * \param print the print under inspection
609 * \returns the first discovered device that appears to support the print, or
610 * NULL if no apparently compatible devices could be found
612 API_EXPORTED
struct fp_dscv_dev
*fp_dscv_dev_for_dscv_print(struct fp_dscv_dev
**devs
,
613 struct fp_dscv_print
*print
)
615 struct fp_dscv_dev
*ddev
;
618 for (i
= 0; (ddev
= devs
[i
]); i
++)
619 if (fp_dscv_dev_supports_dscv_print(ddev
, print
))
625 * Get the \ref drv "driver" for a fingerprint device.
626 * \param dev the device
627 * \returns the driver controlling the device
629 API_EXPORTED
struct fp_driver
*fp_dev_get_driver(struct fp_dev
*dev
)
635 * Gets the number of \ref enrolling "enroll stages" required to enroll a
636 * fingerprint with the device.
637 * \param dev the device
638 * \returns the number of enroll stages
640 API_EXPORTED
int fp_dev_get_nr_enroll_stages(struct fp_dev
*dev
)
642 return dev
->nr_enroll_stages
;
646 * Gets the \ref devtype "devtype" for a device.
647 * \param dev the device
648 * \returns the devtype
650 API_EXPORTED
uint32_t fp_dev_get_devtype(struct fp_dev
*dev
)
656 * Determines if a stored print is compatible with a certain device.
657 * \param dev the device
658 * \param data the stored print
659 * \returns 1 if the print is compatible with the device, 0 if not
661 API_EXPORTED
int fp_dev_supports_print_data(struct fp_dev
*dev
,
662 struct fp_print_data
*data
)
664 return fpi_print_data_compatible(dev
->drv
->id
, dev
->devtype
,
665 fpi_driver_get_data_type(dev
->drv
), data
->driver_id
, data
->devtype
,
670 * Determines if a \ref dscv_print "discovered print" appears to be compatible
671 * with a certain device.
672 * \param dev the device
673 * \param data the discovered print
674 * \returns 1 if the print is compatible with the device, 0 if not
676 API_EXPORTED
int fp_dev_supports_dscv_print(struct fp_dev
*dev
,
677 struct fp_dscv_print
*data
)
679 return fpi_print_data_compatible(dev
->drv
->id
, dev
->devtype
,
680 0, data
->driver_id
, data
->devtype
, 0);
684 * Retrieves the name of the driver. For example: "upekts"
685 * \param drv the driver
686 * \returns the driver name. Must not be modified or freed.
688 API_EXPORTED
const char *fp_driver_get_name(struct fp_driver
*drv
)
694 * Retrieves a descriptive name of the driver. For example: "UPEK TouchStrip"
695 * \param drv the driver
696 * \returns the descriptive name. Must not be modified or freed.
698 API_EXPORTED
const char *fp_driver_get_full_name(struct fp_driver
*drv
)
700 return drv
->full_name
;
704 * Retrieves the driver ID code for a driver.
705 * \param drv the driver
706 * \returns the driver ID
708 API_EXPORTED
uint16_t fp_driver_get_driver_id(struct fp_driver
*drv
)
713 static struct fp_img_dev
*dev_to_img_dev(struct fp_dev
*dev
)
715 if (dev
->drv
->type
!= DRIVER_IMAGING
)
721 * Determines if a device has imaging capabilities. If a device has imaging
722 * capabilities you are able to perform imaging operations such as retrieving
723 * scan images using fp_dev_img_capture(). However, not all devices are
724 * imaging devices - some do all processing in hardware. This function will
725 * indicate which class a device in question falls into.
726 * \param dev the fingerprint device
727 * \returns 1 if the device is an imaging device, 0 if the device does not
728 * provide images to the host computer
730 API_EXPORTED
int fp_dev_supports_imaging(struct fp_dev
*dev
)
732 return dev
->drv
->type
== DRIVER_IMAGING
;
736 * Determines if a device is capable of \ref identification "identification"
737 * through fp_identify_finger() and similar. Not all devices support this
739 * \param dev the fingerprint device
740 * \returns 1 if the device is capable of identification, 0 otherwise.
742 API_EXPORTED
int fp_dev_supports_identification(struct fp_dev
*dev
)
744 return dev
->drv
->identify_start
!= NULL
;
748 * Captures an \ref img "image" from a device. The returned image is the raw
749 * image provided by the device, you may wish to \ref img_std "standardize" it.
751 * If set, the <tt>unconditional</tt> flag indicates that the device should
752 * capture an image unconditionally, regardless of whether a finger is there
753 * or not. If unset, this function will block until a finger is detected on
756 * \param dev the device
757 * \param unconditional whether to unconditionally capture an image, or to only capture when a finger is detected
758 * \param image a location to return the captured image. Must be freed with
759 * fp_img_free() after use.
760 * \return 0 on success, non-zero on error. -ENOTSUP indicates that either the
761 * unconditional flag was set but the device does not support this, or that the
762 * device does not support imaging.
763 * \sa fp_dev_supports_imaging()
765 API_EXPORTED
int fp_dev_img_capture(struct fp_dev
*dev
, int unconditional
,
766 struct fp_img
**image
)
768 struct fp_img_dev
*imgdev
= dev_to_img_dev(dev
);
770 fp_dbg("image capture on non-imaging device");
774 //return fpi_imgdev_capture(imgdev, unconditional, image);
775 /* FIXME reimplement async */
780 * Gets the expected width of images that will be captured from the device.
781 * This function will return -1 for devices that are not
782 * \ref imaging "imaging devices". If the width of images from this device
783 * can vary, 0 will be returned.
784 * \param dev the device
785 * \returns the expected image width, or 0 for variable, or -1 for non-imaging
788 API_EXPORTED
int fp_dev_get_img_width(struct fp_dev
*dev
)
790 struct fp_img_dev
*imgdev
= dev_to_img_dev(dev
);
792 fp_dbg("get image width for non-imaging device");
796 return fpi_imgdev_get_img_width(imgdev
);
800 * Gets the expected height of images that will be captured from the device.
801 * This function will return -1 for devices that are not
802 * \ref imaging "imaging devices". If the height of images from this device
803 * can vary, 0 will be returned.
804 * \param dev the device
805 * \returns the expected image height, or 0 for variable, or -1 for non-imaging
808 API_EXPORTED
int fp_dev_get_img_height(struct fp_dev
*dev
)
810 struct fp_img_dev
*imgdev
= dev_to_img_dev(dev
);
812 fp_dbg("get image height for non-imaging device");
816 return fpi_imgdev_get_img_height(imgdev
);
820 * Initialise libfprint. This function must be called before you attempt to
821 * use the library in any way.
822 * \return 0 on success, non-zero on error.
824 API_EXPORTED
int fp_init(void)
829 r
= libusb_init(&fpi_usb_ctx
);
833 libusb_set_debug(fpi_usb_ctx
, 3);
840 * Deinitialise libfprint. This function should be called during your program
841 * exit sequence. You must not use any libfprint functions after calling this
842 * function, unless you call fp_init() again.
844 API_EXPORTED
void fp_exit(void)
848 if (opened_devices
) {
849 GSList
*copy
= g_slist_copy(opened_devices
);
851 fp_dbg("naughty app left devices open on exit!");
854 fp_dev_close((struct fp_dev
*) elem
->data
);
855 while ((elem
= g_slist_next(elem
)));
858 g_slist_free(opened_devices
);
859 opened_devices
= NULL
;
864 g_slist_free(registered_drivers
);
865 registered_drivers
= NULL
;
866 libusb_exit(fpi_usb_ctx
);