2007-10-07 22:20:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Core functions for libfprint
|
2008-02-04 10:23:11 +00:00
|
|
|
|
* Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org>
|
2007-10-07 22:20:12 +00:00
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
2007-10-13 23:45:49 +00:00
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdio.h>
|
2008-11-20 17:23:04 +00:00
|
|
|
|
#include <stdlib.h>
|
2007-10-07 22:20:12 +00:00
|
|
|
|
|
2007-10-08 15:46:42 +00:00
|
|
|
|
#include <glib.h>
|
2008-01-30 14:16:35 +00:00
|
|
|
|
#include <libusb.h>
|
2007-10-08 15:46:42 +00:00
|
|
|
|
|
|
|
|
|
#include "fp_internal.h"
|
|
|
|
|
|
2008-07-03 04:27:37 +00:00
|
|
|
|
libusb_context *fpi_usb_ctx = NULL;
|
2008-02-26 18:04:54 +00:00
|
|
|
|
GSList *opened_devices = NULL;
|
|
|
|
|
|
2007-11-01 23:11:29 +00:00
|
|
|
|
/**
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* SECTION:discovery
|
|
|
|
|
* @title: Device discovery
|
2018-11-12 13:20:28 +00:00
|
|
|
|
* @short_description: Device discovery functions
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* These functions allow you to scan the system for supported fingerprint
|
|
|
|
|
* scanning hardware. This is your starting point when integrating libfprint
|
|
|
|
|
* into your software.
|
|
|
|
|
*
|
|
|
|
|
* When you've identified a discovered device that you would like to control,
|
|
|
|
|
* you can open it with fp_dev_open(). Note that discovered devices may no
|
|
|
|
|
* longer be available at the time when you want to open them, for example
|
|
|
|
|
* the user may have unplugged the device.
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:drv
|
|
|
|
|
* @title: Driver operations
|
2018-11-12 13:20:28 +00:00
|
|
|
|
* @short_description: Driver operation functions
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Internally, libfprint is abstracted into various drivers to communicate
|
|
|
|
|
* with the different types of supported fingerprint readers. libfprint works
|
|
|
|
|
* hard so that you don't have to care about these internal abstractions,
|
|
|
|
|
* however there are some situations where you may be interested in a little
|
|
|
|
|
* behind-the-scenes driver info.
|
|
|
|
|
*
|
|
|
|
|
* You can obtain the driver for a device using fp_dev_get_driver(), which
|
|
|
|
|
* you can pass to the functions documented on this page.
|
|
|
|
|
*/
|
2007-11-01 23:11:29 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* SECTION:dev
|
|
|
|
|
* @title: Devices operations
|
2018-11-12 13:20:28 +00:00
|
|
|
|
* @short_description: Device operation functions
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* In order to interact with fingerprint scanners, your software will
|
|
|
|
|
* interface primarily with libfprint's representation of devices, detailed
|
|
|
|
|
* on this page.
|
|
|
|
|
*
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* # Enrolling # {#enrolling}
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Enrolling is represented within libfprint as a multi-stage process. This
|
|
|
|
|
* slightly complicates things for application developers, but is required
|
|
|
|
|
* for a smooth process.
|
|
|
|
|
*
|
|
|
|
|
* Some devices require the user to scan their finger multiple times in
|
|
|
|
|
* order to complete the enrollment process. libfprint must return control
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* to your application in-between each scan in order for your application to
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* instruct the user to swipe their finger again. Each scan is referred to
|
|
|
|
|
* as a stage, so a device that requires 3 scans for enrollment corresponds
|
|
|
|
|
* to you running 3 enrollment stages using libfprint.
|
|
|
|
|
*
|
|
|
|
|
* The fp_dev_get_nr_enroll_stages() function can be used to find out how
|
|
|
|
|
* many enroll stages are needed.
|
|
|
|
|
*
|
|
|
|
|
* In order to complete an enroll stage, you call an enroll function such
|
|
|
|
|
* as fp_enroll_finger(). The return of this function does not necessarily
|
|
|
|
|
* indicate that a stage has completed though, as the user may not have
|
|
|
|
|
* produced a good enough scan. Each stage may have to be retried several
|
|
|
|
|
* times.
|
|
|
|
|
*
|
|
|
|
|
* The exact semantics of the enroll functions are described in the
|
|
|
|
|
* fp_enroll_finger() documentation. You should pay careful attention to the
|
|
|
|
|
* details.
|
|
|
|
|
*
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* # Imaging # {#imaging}
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* libfprint provides you with some ways to retrieve images of scanned
|
|
|
|
|
* fingers, such as the fp_dev_img_capture() function, or some enroll/verify
|
|
|
|
|
* function variants which provide images. You may wish to do something with
|
|
|
|
|
* such images in your application.
|
|
|
|
|
*
|
|
|
|
|
* However, you must be aware that not all hardware supported by libfprint
|
|
|
|
|
* operates like this. Most hardware does operate simply by sending
|
|
|
|
|
* fingerprint images to the host computer for further processing, but some
|
|
|
|
|
* devices do all fingerprint processing in hardware and do not present images
|
|
|
|
|
* to the host computer.
|
|
|
|
|
*
|
|
|
|
|
* You can use fp_dev_supports_imaging() to see if image capture is possible
|
|
|
|
|
* on a particular device. Your application must be able to cope with the
|
|
|
|
|
* fact that libfprint does support regular operations (e.g. enrolling and
|
|
|
|
|
* verification) on some devices which do not provide images.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-11-09 13:43:58 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:fpi-core
|
|
|
|
|
* @title: Driver structures
|
2018-11-12 13:20:28 +00:00
|
|
|
|
* @short_description: Driver structures
|
2018-11-09 13:43:58 +00:00
|
|
|
|
*
|
|
|
|
|
* Driver structures need to be defined inside each driver in
|
|
|
|
|
* order for the core library to know what function to call, and the capabilities
|
|
|
|
|
* of the driver and the devices it supports.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:fpi-core-img
|
|
|
|
|
* @title: Image driver structures
|
2018-11-12 13:20:28 +00:00
|
|
|
|
* @short_description: Image driver structures
|
2018-11-09 13:43:58 +00:00
|
|
|
|
*
|
|
|
|
|
* Image driver structures need to be defined inside each image driver in
|
|
|
|
|
* order for the core library to know what function to call, and the capabilities
|
|
|
|
|
* of the driver and the devices it supports. Its structure is based off the
|
|
|
|
|
* #fp_driver struct.
|
|
|
|
|
*/
|
|
|
|
|
|
2007-11-13 14:32:31 +00:00
|
|
|
|
static GSList *registered_drivers = NULL;
|
2007-10-08 15:46:42 +00:00
|
|
|
|
|
2007-10-23 22:24:21 +00:00
|
|
|
|
static void register_driver(struct fp_driver *drv)
|
2007-10-08 15:46:42 +00:00
|
|
|
|
{
|
2007-10-28 22:02:04 +00:00
|
|
|
|
if (drv->id == 0) {
|
2008-10-31 23:36:55 +00:00
|
|
|
|
fp_err("not registering driver %s: driver ID is 0", drv->name);
|
2007-10-28 22:02:04 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2007-11-13 14:32:31 +00:00
|
|
|
|
registered_drivers = g_slist_prepend(registered_drivers, (gpointer) drv);
|
2007-10-10 14:51:50 +00:00
|
|
|
|
fp_dbg("registered driver %s", drv->name);
|
2007-10-08 15:46:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-24 10:16:18 +00:00
|
|
|
|
#include "drivers_arrays.h"
|
2007-10-23 22:24:21 +00:00
|
|
|
|
|
2007-10-08 15:46:42 +00:00
|
|
|
|
static void register_drivers(void)
|
|
|
|
|
{
|
2007-10-13 14:52:50 +00:00
|
|
|
|
unsigned int i;
|
2007-10-08 15:46:42 +00:00
|
|
|
|
|
2007-11-17 23:47:06 +00:00
|
|
|
|
for (i = 0; i < G_N_ELEMENTS(primitive_drivers); i++)
|
2007-10-23 22:24:21 +00:00
|
|
|
|
register_driver(primitive_drivers[i]);
|
|
|
|
|
|
2007-11-17 23:47:06 +00:00
|
|
|
|
for (i = 0; i < G_N_ELEMENTS(img_drivers); i++) {
|
2007-10-23 22:24:21 +00:00
|
|
|
|
struct fp_img_driver *imgdriver = img_drivers[i];
|
|
|
|
|
fpi_img_driver_setup(imgdriver);
|
|
|
|
|
register_driver(&imgdriver->driver);
|
|
|
|
|
}
|
2007-10-08 15:46:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-30 15:02:52 +00:00
|
|
|
|
API_EXPORTED struct fp_driver **fprint_get_drivers (void)
|
|
|
|
|
{
|
|
|
|
|
GPtrArray *array;
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
array = g_ptr_array_new ();
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS(primitive_drivers); i++)
|
|
|
|
|
g_ptr_array_add (array, primitive_drivers[i]);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS(img_drivers); i++)
|
|
|
|
|
g_ptr_array_add (array, &(img_drivers[i]->driver));
|
|
|
|
|
|
|
|
|
|
/* Add a null item terminating the array */
|
|
|
|
|
g_ptr_array_add (array, NULL);
|
|
|
|
|
|
|
|
|
|
return (struct fp_driver **) g_ptr_array_free (array, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-10 11:35:58 +00:00
|
|
|
|
static struct fp_driver *find_supporting_driver(libusb_device *udev,
|
2010-08-17 22:14:18 +00:00
|
|
|
|
const struct usb_id **usb_id, uint32_t *devtype)
|
2007-10-08 15:55:50 +00:00
|
|
|
|
{
|
2008-05-12 22:24:05 +00:00
|
|
|
|
int ret;
|
2007-11-13 14:32:31 +00:00
|
|
|
|
GSList *elem = registered_drivers;
|
2008-05-12 22:24:05 +00:00
|
|
|
|
struct libusb_device_descriptor dsc;
|
|
|
|
|
|
2010-08-17 22:14:18 +00:00
|
|
|
|
const struct usb_id *best_usb_id;
|
|
|
|
|
struct fp_driver *best_drv;
|
|
|
|
|
uint32_t best_devtype;
|
|
|
|
|
int drv_score = 0;
|
|
|
|
|
|
2008-05-12 22:24:05 +00:00
|
|
|
|
ret = libusb_get_device_descriptor(udev, &dsc);
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
fp_err("Failed to get device descriptor");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2010-08-17 22:14:18 +00:00
|
|
|
|
|
|
|
|
|
best_drv = NULL;
|
|
|
|
|
best_devtype = 0;
|
|
|
|
|
|
2007-10-08 15:55:50 +00:00
|
|
|
|
do {
|
2007-10-23 22:24:21 +00:00
|
|
|
|
struct fp_driver *drv = elem->data;
|
2010-08-17 22:14:18 +00:00
|
|
|
|
uint32_t type = 0;
|
2007-10-08 15:55:50 +00:00
|
|
|
|
const struct usb_id *id;
|
|
|
|
|
|
2010-08-17 22:14:18 +00:00
|
|
|
|
for (id = drv->id_table; id->vendor; id++) {
|
2008-05-12 22:24:05 +00:00
|
|
|
|
if (dsc.idVendor == id->vendor && dsc.idProduct == id->product) {
|
2010-08-17 22:14:18 +00:00
|
|
|
|
if (drv->discover) {
|
|
|
|
|
int r = drv->discover(&dsc, &type);
|
|
|
|
|
if (r < 0)
|
|
|
|
|
fp_err("%s discover failed, code %d", drv->name, r);
|
|
|
|
|
if (r <= 0)
|
|
|
|
|
continue;
|
|
|
|
|
/* Has a discover function, and matched our device */
|
|
|
|
|
drv_score = 100;
|
|
|
|
|
} else {
|
|
|
|
|
/* Already got a driver as good */
|
|
|
|
|
if (drv_score >= 50)
|
|
|
|
|
continue;
|
|
|
|
|
drv_score = 50;
|
|
|
|
|
}
|
2007-10-10 14:51:50 +00:00
|
|
|
|
fp_dbg("driver %s supports USB device %04x:%04x",
|
|
|
|
|
drv->name, id->vendor, id->product);
|
2010-08-17 22:14:18 +00:00
|
|
|
|
best_usb_id = id;
|
|
|
|
|
best_drv = drv;
|
|
|
|
|
best_devtype = type;
|
|
|
|
|
|
|
|
|
|
/* We found the best possible driver */
|
|
|
|
|
if (drv_score == 100)
|
|
|
|
|
break;
|
2007-10-10 14:51:50 +00:00
|
|
|
|
}
|
2010-08-17 22:14:18 +00:00
|
|
|
|
}
|
2007-12-27 00:46:11 +00:00
|
|
|
|
} while ((elem = g_slist_next(elem)));
|
2010-08-17 22:14:18 +00:00
|
|
|
|
|
2010-08-18 10:17:20 +00:00
|
|
|
|
if (best_drv != NULL) {
|
|
|
|
|
fp_dbg("selected driver %s supports USB device %04x:%04x",
|
|
|
|
|
best_drv->name, dsc.idVendor, dsc.idProduct);
|
|
|
|
|
*devtype = best_devtype;
|
|
|
|
|
*usb_id = best_usb_id;
|
|
|
|
|
}
|
2010-08-17 22:14:18 +00:00
|
|
|
|
|
|
|
|
|
return best_drv;
|
2007-10-08 15:55:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-03-10 11:35:58 +00:00
|
|
|
|
static struct fp_dscv_dev *discover_dev(libusb_device *udev)
|
2007-10-30 22:15:45 +00:00
|
|
|
|
{
|
2007-10-31 13:12:04 +00:00
|
|
|
|
const struct usb_id *usb_id;
|
2010-08-17 22:14:18 +00:00
|
|
|
|
struct fp_driver *drv;
|
2007-10-30 22:15:45 +00:00
|
|
|
|
struct fp_dscv_dev *ddev;
|
2010-08-17 22:14:18 +00:00
|
|
|
|
uint32_t devtype;
|
|
|
|
|
|
|
|
|
|
drv = find_supporting_driver(udev, &usb_id, &devtype);
|
2007-10-30 22:15:45 +00:00
|
|
|
|
|
|
|
|
|
if (!drv)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
ddev = g_malloc0(sizeof(*ddev));
|
|
|
|
|
ddev->drv = drv;
|
|
|
|
|
ddev->udev = udev;
|
|
|
|
|
ddev->driver_data = usb_id->driver_data;
|
|
|
|
|
ddev->devtype = devtype;
|
|
|
|
|
return ddev;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_discover_devs:
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Scans the system and returns a list of discovered devices. This is your
|
|
|
|
|
* entry point into finding a fingerprint reader to operate.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
2018-09-04 13:58:23 +00:00
|
|
|
|
* Returns: a nul-terminated list of discovered devices. Must be freed with
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* fp_dscv_devs_free() after use.
|
|
|
|
|
*/
|
2007-10-08 15:55:50 +00:00
|
|
|
|
API_EXPORTED struct fp_dscv_dev **fp_discover_devs(void)
|
|
|
|
|
{
|
2018-04-26 14:25:18 +00:00
|
|
|
|
GPtrArray *tmparray;
|
2008-03-10 11:35:58 +00:00
|
|
|
|
libusb_device *udev;
|
|
|
|
|
libusb_device **devs;
|
|
|
|
|
int r;
|
|
|
|
|
int i = 0;
|
2007-10-08 15:55:50 +00:00
|
|
|
|
|
2018-10-11 12:58:04 +00:00
|
|
|
|
g_return_val_if_fail (registered_drivers != NULL, NULL);
|
2007-10-08 15:55:50 +00:00
|
|
|
|
|
2008-07-03 04:27:37 +00:00
|
|
|
|
r = libusb_get_device_list(fpi_usb_ctx, &devs);
|
2008-03-10 11:35:58 +00:00
|
|
|
|
if (r < 0) {
|
|
|
|
|
fp_err("couldn't enumerate USB devices, error %d", r);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2007-10-08 15:55:50 +00:00
|
|
|
|
|
2018-04-26 14:25:18 +00:00
|
|
|
|
tmparray = g_ptr_array_new ();
|
|
|
|
|
|
2007-10-08 15:55:50 +00:00
|
|
|
|
/* Check each device against each driver, temporarily storing successfully
|
2018-04-26 14:25:18 +00:00
|
|
|
|
* discovered devices in a GPtrArray. */
|
2008-03-10 11:35:58 +00:00
|
|
|
|
while ((udev = devs[i++]) != NULL) {
|
|
|
|
|
struct fp_dscv_dev *ddev = discover_dev(udev);
|
|
|
|
|
if (!ddev)
|
|
|
|
|
continue;
|
2018-03-10 18:14:42 +00:00
|
|
|
|
/* discover_dev() doesn't hold a reference to the udev,
|
|
|
|
|
* so increase the reference for ddev to hold this ref */
|
|
|
|
|
libusb_ref_device(udev);
|
2018-04-26 14:25:18 +00:00
|
|
|
|
g_ptr_array_add (tmparray, (gpointer) ddev);
|
2008-03-10 11:35:58 +00:00
|
|
|
|
}
|
2018-03-10 18:14:42 +00:00
|
|
|
|
libusb_free_device_list(devs, 1);
|
2007-10-08 15:55:50 +00:00
|
|
|
|
|
2018-04-26 14:25:18 +00:00
|
|
|
|
/* Convert our temporary array into a standard NULL-terminated pointer
|
2007-10-08 15:55:50 +00:00
|
|
|
|
* array. */
|
2018-04-26 14:25:18 +00:00
|
|
|
|
g_ptr_array_add (tmparray, NULL);
|
|
|
|
|
return (struct fp_dscv_dev **) g_ptr_array_free (tmparray, FALSE);
|
2007-10-08 15:55:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dscv_devs_free:
|
|
|
|
|
* @devs: the list of discovered devices. If %NULL, function simply
|
|
|
|
|
* returns.
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Free a list of discovered devices. This function destroys the list and all
|
|
|
|
|
* discovered devices that it included, so make sure you have opened your
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* discovered device <emphasis role="strong">before</emphasis> freeing the list.
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-08 15:55:50 +00:00
|
|
|
|
API_EXPORTED void fp_dscv_devs_free(struct fp_dscv_dev **devs)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
if (!devs)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-03-10 18:14:42 +00:00
|
|
|
|
for (i = 0; devs[i]; i++) {
|
|
|
|
|
libusb_unref_device(devs[i]->udev);
|
2007-10-08 15:55:50 +00:00
|
|
|
|
g_free(devs[i]);
|
2018-03-10 18:14:42 +00:00
|
|
|
|
}
|
2007-10-08 15:55:50 +00:00
|
|
|
|
g_free(devs);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dscv_dev_get_driver:
|
|
|
|
|
* @dev: the discovered device
|
|
|
|
|
*
|
2018-05-18 03:51:58 +00:00
|
|
|
|
* Gets the #fp_driver for a discovered device.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the driver backing the device
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-23 22:24:21 +00:00
|
|
|
|
API_EXPORTED struct fp_driver *fp_dscv_dev_get_driver(struct fp_dscv_dev *dev)
|
2007-10-08 16:05:58 +00:00
|
|
|
|
{
|
|
|
|
|
return dev->drv;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-22 14:56:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dscv_dev_get_driver_id:
|
|
|
|
|
* @dev: a discovered fingerprint device
|
|
|
|
|
*
|
2018-11-29 12:11:39 +00:00
|
|
|
|
* Returns a unique driver identifier for the underlying driver
|
|
|
|
|
* for that device.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the ID for #dev
|
2018-05-22 14:56:14 +00:00
|
|
|
|
*/
|
|
|
|
|
API_EXPORTED uint16_t fp_dscv_dev_get_driver_id(struct fp_dscv_dev *dev)
|
|
|
|
|
{
|
|
|
|
|
return fp_driver_get_driver_id(fp_dscv_dev_get_driver(dev));
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dscv_dev_get_devtype:
|
|
|
|
|
* @dev: the discovered device
|
|
|
|
|
*
|
|
|
|
|
* Gets the [devtype](advanced-topics.html#device-types) for a discovered device.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the devtype of the device
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-30 22:24:31 +00:00
|
|
|
|
API_EXPORTED uint32_t fp_dscv_dev_get_devtype(struct fp_dscv_dev *dev)
|
|
|
|
|
{
|
|
|
|
|
return dev->devtype;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-31 13:12:04 +00:00
|
|
|
|
enum fp_print_data_type fpi_driver_get_data_type(struct fp_driver *drv)
|
|
|
|
|
{
|
|
|
|
|
switch (drv->type) {
|
|
|
|
|
case DRIVER_PRIMITIVE:
|
|
|
|
|
return PRINT_DATA_RAW;
|
|
|
|
|
case DRIVER_IMAGING:
|
|
|
|
|
return PRINT_DATA_NBIS_MINUTIAE;
|
|
|
|
|
default:
|
|
|
|
|
fp_err("unrecognised drv type %d", drv->type);
|
|
|
|
|
return PRINT_DATA_RAW;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dscv_dev_supports_print_data:
|
|
|
|
|
* @dev: the discovered device
|
|
|
|
|
* @print: the print for compatibility checking
|
|
|
|
|
*
|
2018-05-18 03:51:58 +00:00
|
|
|
|
* Determines if a specific #fp_print_data stored print appears to be
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* compatible with a discovered device.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: 1 if the print is compatible with the device, 0 otherwise
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-31 13:12:04 +00:00
|
|
|
|
API_EXPORTED int fp_dscv_dev_supports_print_data(struct fp_dscv_dev *dev,
|
2018-05-17 00:58:59 +00:00
|
|
|
|
struct fp_print_data *print)
|
2007-10-31 13:12:04 +00:00
|
|
|
|
{
|
|
|
|
|
return fpi_print_data_compatible(dev->drv->id, dev->devtype,
|
2018-05-17 00:58:59 +00:00
|
|
|
|
fpi_driver_get_data_type(dev->drv), print->driver_id, print->devtype,
|
|
|
|
|
print->type);
|
2007-10-31 13:12:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dscv_dev_supports_dscv_print:
|
|
|
|
|
* @dev: the discovered device
|
|
|
|
|
* @print: the discovered print for compatibility checking
|
|
|
|
|
*
|
2018-05-18 03:51:58 +00:00
|
|
|
|
* Determines if a specific #fp_dscv_print discovered print appears to be
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* compatible with a discovered device.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: 1 if the print is compatible with the device, 0 otherwise
|
2018-05-24 11:21:40 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: Do not use.
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-31 13:12:04 +00:00
|
|
|
|
API_EXPORTED int fp_dscv_dev_supports_dscv_print(struct fp_dscv_dev *dev,
|
2018-05-17 00:58:59 +00:00
|
|
|
|
struct fp_dscv_print *print)
|
2007-10-31 13:12:04 +00:00
|
|
|
|
{
|
|
|
|
|
return fpi_print_data_compatible(dev->drv->id, dev->devtype, 0,
|
2018-05-17 00:58:59 +00:00
|
|
|
|
print->driver_id, print->devtype, 0);
|
2007-10-31 13:12:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dscv_dev_for_print_data:
|
|
|
|
|
* @devs: a list of discovered devices
|
|
|
|
|
* @print: the print under inspection
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Searches a list of discovered devices for a device that appears to be
|
2018-05-18 03:51:58 +00:00
|
|
|
|
* compatible with a #fp_print_data stored print.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the first discovered device that appears to support the print, or
|
|
|
|
|
* %NULL if no apparently compatible devices could be found
|
2018-05-24 11:21:40 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: Do not use.
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-31 13:12:04 +00:00
|
|
|
|
API_EXPORTED struct fp_dscv_dev *fp_dscv_dev_for_print_data(struct fp_dscv_dev **devs,
|
2018-05-17 00:58:59 +00:00
|
|
|
|
struct fp_print_data *print)
|
2007-10-31 13:12:04 +00:00
|
|
|
|
{
|
|
|
|
|
struct fp_dscv_dev *ddev;
|
|
|
|
|
int i;
|
|
|
|
|
|
2007-12-27 00:46:11 +00:00
|
|
|
|
for (i = 0; (ddev = devs[i]); i++)
|
2018-05-17 00:58:59 +00:00
|
|
|
|
if (fp_dscv_dev_supports_print_data(ddev, print))
|
2007-10-31 13:12:04 +00:00
|
|
|
|
return ddev;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dscv_dev_for_dscv_print:
|
|
|
|
|
* @devs: a list of discovered devices
|
|
|
|
|
* @print: the print under inspection
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Searches a list of discovered devices for a device that appears to be
|
2018-05-18 03:51:58 +00:00
|
|
|
|
* compatible with a #fp_dscv_print discovered print.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the first discovered device that appears to support the print, or
|
|
|
|
|
* %NULL if no apparently compatible devices could be found
|
2018-05-24 11:21:40 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: Do not use.
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-31 13:12:04 +00:00
|
|
|
|
API_EXPORTED struct fp_dscv_dev *fp_dscv_dev_for_dscv_print(struct fp_dscv_dev **devs,
|
|
|
|
|
struct fp_dscv_print *print)
|
|
|
|
|
{
|
|
|
|
|
struct fp_dscv_dev *ddev;
|
|
|
|
|
int i;
|
|
|
|
|
|
2018-05-25 11:45:13 +00:00
|
|
|
|
for (i = 0; (ddev = devs[i]); i++) {
|
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
2007-10-31 13:12:04 +00:00
|
|
|
|
if (fp_dscv_dev_supports_dscv_print(ddev, print))
|
|
|
|
|
return ddev;
|
2018-05-25 11:45:13 +00:00
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
}
|
2007-10-31 13:12:04 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dev_get_driver:
|
2018-10-23 08:18:41 +00:00
|
|
|
|
* @dev: the struct #fp_dev device
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
2018-05-18 03:51:58 +00:00
|
|
|
|
* Get the #fp_driver for a fingerprint device.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the driver controlling the device
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-23 22:24:21 +00:00
|
|
|
|
API_EXPORTED struct fp_driver *fp_dev_get_driver(struct fp_dev *dev)
|
2007-10-08 16:05:58 +00:00
|
|
|
|
{
|
|
|
|
|
return dev->drv;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dev_get_nr_enroll_stages:
|
2018-10-23 08:18:41 +00:00
|
|
|
|
* @dev: the struct #fp_dev device
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the number of [enroll stages](intro.html#enrollment) required to enroll a
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* fingerprint with the device.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the number of enroll stages
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-08 18:53:50 +00:00
|
|
|
|
API_EXPORTED int fp_dev_get_nr_enroll_stages(struct fp_dev *dev)
|
|
|
|
|
{
|
|
|
|
|
return dev->nr_enroll_stages;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dev_get_devtype:
|
2018-10-23 08:18:41 +00:00
|
|
|
|
* @dev: the struct #fp_dev device
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the [devtype](advanced-topics.html#device-types) for a device.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the devtype
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-30 22:24:31 +00:00
|
|
|
|
API_EXPORTED uint32_t fp_dev_get_devtype(struct fp_dev *dev)
|
|
|
|
|
{
|
|
|
|
|
return dev->devtype;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dev_supports_print_data:
|
2018-10-23 08:18:41 +00:00
|
|
|
|
* @dev: the struct #fp_dev device
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* @data: the stored print
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Determines if a stored print is compatible with a certain device.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: 1 if the print is compatible with the device, 0 if not
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-31 13:12:04 +00:00
|
|
|
|
API_EXPORTED int fp_dev_supports_print_data(struct fp_dev *dev,
|
|
|
|
|
struct fp_print_data *data)
|
|
|
|
|
{
|
|
|
|
|
return fpi_print_data_compatible(dev->drv->id, dev->devtype,
|
|
|
|
|
fpi_driver_get_data_type(dev->drv), data->driver_id, data->devtype,
|
|
|
|
|
data->type);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dev_supports_dscv_print:
|
2018-10-23 08:18:41 +00:00
|
|
|
|
* @dev: the struct #fp_dev device
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* @print: the discovered print
|
|
|
|
|
*
|
2018-05-18 03:51:58 +00:00
|
|
|
|
* Determines if a #fp_dscv_print discovered print appears to be compatible
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* with a certain device.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: 1 if the print is compatible with the device, 0 if not
|
2018-05-24 11:21:40 +00:00
|
|
|
|
*
|
|
|
|
|
* Deprecated: Do not use.
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-31 13:12:04 +00:00
|
|
|
|
API_EXPORTED int fp_dev_supports_dscv_print(struct fp_dev *dev,
|
2018-05-17 00:58:59 +00:00
|
|
|
|
struct fp_dscv_print *print)
|
2007-10-31 13:12:04 +00:00
|
|
|
|
{
|
|
|
|
|
return fpi_print_data_compatible(dev->drv->id, dev->devtype,
|
2018-05-17 00:58:59 +00:00
|
|
|
|
0, print->driver_id, print->devtype, 0);
|
2007-10-31 13:12:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_driver_get_name:
|
|
|
|
|
* @drv: the driver
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Retrieves the name of the driver. For example: "upekts"
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the driver name. Must not be modified or freed.
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-23 22:24:21 +00:00
|
|
|
|
API_EXPORTED const char *fp_driver_get_name(struct fp_driver *drv)
|
2007-10-08 16:05:58 +00:00
|
|
|
|
{
|
|
|
|
|
return drv->name;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_driver_get_full_name:
|
|
|
|
|
* @drv: the driver
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Retrieves a descriptive name of the driver. For example: "UPEK TouchStrip"
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the descriptive name. Must not be modified or freed.
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-23 22:24:21 +00:00
|
|
|
|
API_EXPORTED const char *fp_driver_get_full_name(struct fp_driver *drv)
|
2007-10-08 16:05:58 +00:00
|
|
|
|
{
|
|
|
|
|
return drv->full_name;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_driver_get_driver_id:
|
|
|
|
|
* @drv: the driver
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Retrieves the driver ID code for a driver.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the driver ID
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-30 22:24:31 +00:00
|
|
|
|
API_EXPORTED uint16_t fp_driver_get_driver_id(struct fp_driver *drv)
|
|
|
|
|
{
|
|
|
|
|
return drv->id;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_driver_get_scan_type:
|
|
|
|
|
* @drv: the driver
|
|
|
|
|
*
|
2008-11-20 14:40:01 +00:00
|
|
|
|
* Retrieves the scan type for the devices associated with the driver.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the scan type
|
2008-11-20 14:40:01 +00:00
|
|
|
|
*/
|
|
|
|
|
API_EXPORTED enum fp_scan_type fp_driver_get_scan_type(struct fp_driver *drv)
|
|
|
|
|
{
|
|
|
|
|
return drv->scan_type;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-11 13:00:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_driver_supports_imaging:
|
|
|
|
|
* @drv: the driver
|
|
|
|
|
*
|
|
|
|
|
* Determines if a driver has imaging capabilities. If a driver has imaging
|
|
|
|
|
* capabilities you are able to perform imaging operations such as retrieving
|
|
|
|
|
* scan images using fp_dev_img_capture(). However, not all drivers support
|
|
|
|
|
* imaging devices – some do all processing in hardware. This function will
|
|
|
|
|
* indicate which class a device in question falls into.
|
|
|
|
|
*
|
|
|
|
|
* Returns: 1 if the device is an imaging device, 0 if the device does not
|
|
|
|
|
* provide images to the host computer
|
|
|
|
|
*/
|
|
|
|
|
API_EXPORTED int fp_driver_supports_imaging(struct fp_driver *drv)
|
|
|
|
|
{
|
|
|
|
|
return drv->capture_start != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dev_supports_imaging:
|
2018-10-23 08:18:41 +00:00
|
|
|
|
* @dev: the struct #fp_dev device
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Determines if a device has imaging capabilities. If a device has imaging
|
|
|
|
|
* capabilities you are able to perform imaging operations such as retrieving
|
|
|
|
|
* scan images using fp_dev_img_capture(). However, not all devices are
|
2018-05-18 03:51:58 +00:00
|
|
|
|
* imaging devices – some do all processing in hardware. This function will
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* indicate which class a device in question falls into.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: 1 if the device is an imaging device, 0 if the device does not
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* provide images to the host computer
|
|
|
|
|
*/
|
2007-11-02 17:04:19 +00:00
|
|
|
|
API_EXPORTED int fp_dev_supports_imaging(struct fp_dev *dev)
|
|
|
|
|
{
|
2013-02-08 11:38:13 +00:00
|
|
|
|
return dev->drv->capture_start != NULL;
|
2007-11-02 17:04:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dev_supports_identification:
|
2018-10-23 08:18:41 +00:00
|
|
|
|
* @dev: the struct #fp_dev device
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Determines if a device is capable of [identification](intro.html#identification)
|
2007-11-20 21:52:10 +00:00
|
|
|
|
* through fp_identify_finger() and similar. Not all devices support this
|
|
|
|
|
* functionality.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: 1 if the device is capable of identification, 0 otherwise.
|
2007-11-20 21:52:10 +00:00
|
|
|
|
*/
|
|
|
|
|
API_EXPORTED int fp_dev_supports_identification(struct fp_dev *dev)
|
|
|
|
|
{
|
2008-02-04 10:23:11 +00:00
|
|
|
|
return dev->drv->identify_start != NULL;
|
2007-11-20 21:52:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dev_get_img_width:
|
2018-10-23 08:18:41 +00:00
|
|
|
|
* @dev: the struct #fp_dev device
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Gets the expected width of images that will be captured from the device.
|
|
|
|
|
* This function will return -1 for devices that are not
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* [imaging devices](libfprint-Devices-operations.html#imaging). If the width of images from this device
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* can vary, 0 will be returned.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the expected image width, or 0 for variable, or -1 for non-imaging
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* devices.
|
|
|
|
|
*/
|
2007-11-02 17:04:19 +00:00
|
|
|
|
API_EXPORTED int fp_dev_get_img_width(struct fp_dev *dev)
|
|
|
|
|
{
|
2018-09-14 23:20:59 +00:00
|
|
|
|
if (!dev->img_dev) {
|
2007-11-02 17:04:19 +00:00
|
|
|
|
fp_dbg("get image width for non-imaging device");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-14 23:20:59 +00:00
|
|
|
|
return fpi_imgdev_get_img_width(dev->img_dev);
|
2007-11-02 17:04:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_dev_get_img_height:
|
2018-10-23 08:18:41 +00:00
|
|
|
|
* @dev: the struct #fp_dev device
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Gets the expected height of images that will be captured from the device.
|
|
|
|
|
* This function will return -1 for devices that are not
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* [imaging devices](libfprint-Devices-operations.html#imaging). If the height of images from this device
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* can vary, 0 will be returned.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the expected image height, or 0 for variable, or -1 for non-imaging
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* devices.
|
|
|
|
|
*/
|
2007-11-02 17:04:19 +00:00
|
|
|
|
API_EXPORTED int fp_dev_get_img_height(struct fp_dev *dev)
|
|
|
|
|
{
|
2018-09-14 23:20:59 +00:00
|
|
|
|
if (!dev->img_dev) {
|
2007-11-02 17:04:19 +00:00
|
|
|
|
fp_dbg("get image height for non-imaging device");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-14 23:20:59 +00:00
|
|
|
|
return fpi_imgdev_get_img_height(dev->img_dev);
|
2007-11-02 17:04:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_set_debug:
|
|
|
|
|
* @level: the verbosity level
|
|
|
|
|
*
|
2018-05-23 15:48:55 +00:00
|
|
|
|
* This call does nothing, see fp_init() for details.
|
2008-11-20 17:23:04 +00:00
|
|
|
|
*/
|
|
|
|
|
API_EXPORTED void fp_set_debug(int level)
|
|
|
|
|
{
|
2018-05-23 15:48:55 +00:00
|
|
|
|
/* Nothing */
|
2008-11-20 17:23:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_init:
|
|
|
|
|
*
|
2007-11-01 23:11:29 +00:00
|
|
|
|
* Initialise libfprint. This function must be called before you attempt to
|
|
|
|
|
* use the library in any way.
|
2018-05-17 00:58:59 +00:00
|
|
|
|
*
|
2018-05-23 15:48:55 +00:00
|
|
|
|
* To enable debug output of libfprint specifically, use GLib's `G_MESSAGES_DEBUG`
|
|
|
|
|
* environment variable as explained in [Running and debugging GLib Applications](https://developer.gnome.org/glib/stable/glib-running.html#G_MESSAGES_DEBUG).
|
|
|
|
|
*
|
|
|
|
|
* The log domains used in libfprint are either `libfprint` or `libfprint-FP_COMPONENT`
|
|
|
|
|
* where `FP_COMPONENT` is defined in the source code for each driver, or component
|
|
|
|
|
* of the library. Starting with `all` and trimming down is advised.
|
|
|
|
|
*
|
|
|
|
|
* To enable debugging of libusb, for USB-based fingerprint reader drivers, use
|
|
|
|
|
* libusb's `LIBUSB_DEBUG` environment variable as explained in the
|
|
|
|
|
* [libusb-1.0 API Reference](http://libusb.sourceforge.net/api-1.0/#msglog).
|
|
|
|
|
*
|
|
|
|
|
* Example:
|
|
|
|
|
*
|
|
|
|
|
* ```
|
|
|
|
|
* LIBUSB_DEBUG=4 G_MESSAGES_DEBUG=all my-libfprint-application
|
|
|
|
|
* ```
|
|
|
|
|
*
|
2018-05-17 00:58:59 +00:00
|
|
|
|
* Returns: 0 on success, non-zero on error.
|
2007-11-01 23:11:29 +00:00
|
|
|
|
*/
|
2007-10-07 22:20:12 +00:00
|
|
|
|
API_EXPORTED int fp_init(void)
|
|
|
|
|
{
|
2008-01-30 14:16:35 +00:00
|
|
|
|
int r;
|
2018-05-23 16:26:22 +00:00
|
|
|
|
G_DEBUG_HERE();
|
2008-01-30 14:16:35 +00:00
|
|
|
|
|
2008-07-03 04:27:37 +00:00
|
|
|
|
r = libusb_init(&fpi_usb_ctx);
|
2008-01-30 14:16:35 +00:00
|
|
|
|
if (r < 0)
|
|
|
|
|
return r;
|
|
|
|
|
|
2007-10-08 15:46:42 +00:00
|
|
|
|
register_drivers();
|
2008-02-26 22:40:38 +00:00
|
|
|
|
fpi_poll_init();
|
2007-10-07 22:20:12 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-10-08 15:55:50 +00:00
|
|
|
|
|
2018-05-17 00:58:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* fp_exit:
|
|
|
|
|
*
|
2007-11-13 14:32:31 +00:00
|
|
|
|
* Deinitialise libfprint. This function should be called during your program
|
|
|
|
|
* exit sequence. You must not use any libfprint functions after calling this
|
|
|
|
|
* function, unless you call fp_init() again.
|
|
|
|
|
*/
|
|
|
|
|
API_EXPORTED void fp_exit(void)
|
|
|
|
|
{
|
2018-05-23 16:26:22 +00:00
|
|
|
|
G_DEBUG_HERE();
|
2007-11-13 14:32:31 +00:00
|
|
|
|
|
2008-02-26 18:04:54 +00:00
|
|
|
|
if (opened_devices) {
|
|
|
|
|
GSList *copy = g_slist_copy(opened_devices);
|
|
|
|
|
GSList *elem = copy;
|
|
|
|
|
fp_dbg("naughty app left devices open on exit!");
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
fp_dev_close((struct fp_dev *) elem->data);
|
|
|
|
|
while ((elem = g_slist_next(elem)));
|
|
|
|
|
|
|
|
|
|
g_slist_free(copy);
|
2007-11-13 14:32:31 +00:00
|
|
|
|
g_slist_free(opened_devices);
|
|
|
|
|
opened_devices = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fpi_data_exit();
|
2008-02-16 12:44:50 +00:00
|
|
|
|
fpi_poll_exit();
|
2007-11-13 14:32:31 +00:00
|
|
|
|
g_slist_free(registered_drivers);
|
|
|
|
|
registered_drivers = NULL;
|
2008-07-03 04:27:37 +00:00
|
|
|
|
libusb_exit(fpi_usb_ctx);
|
2007-11-13 14:32:31 +00:00
|
|
|
|
}
|
|
|
|
|
|