Commit 447b1f01 authored by Daniel Drake's avatar Daniel Drake

Print discovery

Add concept of "discovered prints" and flesh out the API. A discovered print
was found based on file name but has not been checked for file integrity,
and of course there is no guarantee that it is usable when you try to
use it later (might have been deleted, etc).

The .fprint directory structure was changed - instead of using mnemonics
like "rind" we use their numeric value in the fp_finger enum as the filename.
parent b96aade6
......@@ -101,7 +101,7 @@ static void register_drivers(void)
}
static struct fp_driver *find_supporting_driver(struct usb_device *udev,
unsigned long *driver_data)
const struct usb_id **usb_id)
{
GList *elem = registered_drivers;
......@@ -114,7 +114,7 @@ static struct fp_driver *find_supporting_driver(struct usb_device *udev,
udev->descriptor.idProduct == id->product) {
fp_dbg("driver %s supports USB device %04x:%04x",
drv->name, id->vendor, id->product);
*driver_data = id->driver_data;
*usb_id = id;
return drv;
}
} while (elem = g_list_next(elem));
......@@ -123,7 +123,7 @@ static struct fp_driver *find_supporting_driver(struct usb_device *udev,
static struct fp_dscv_dev *discover_dev(struct usb_device *udev)
{
struct usb_id *usb_id;
const struct usb_id *usb_id;
struct fp_driver *drv = find_supporting_driver(udev, &usb_id);
struct fp_dscv_dev *ddev;
uint32_t devtype = 0;
......@@ -212,6 +212,58 @@ API_EXPORTED uint32_t fp_dscv_dev_get_devtype(struct fp_dscv_dev *dev)
return dev->devtype;
}
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;
}
}
API_EXPORTED int fp_dscv_dev_supports_print_data(struct fp_dscv_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);
}
API_EXPORTED int fp_dscv_dev_supports_dscv_print(struct fp_dscv_dev *dev,
struct fp_dscv_print *data)
{
return fpi_print_data_compatible(dev->drv->id, dev->devtype, 0,
data->driver_id, data->devtype, 0);
}
API_EXPORTED struct fp_dscv_dev *fp_dscv_dev_for_print_data(struct fp_dscv_dev **devs,
struct fp_print_data *data)
{
struct fp_dscv_dev *ddev;
int i;
for (i = 0; ddev = devs[i]; i++)
if (fp_dscv_dev_supports_print_data(ddev, data))
return ddev;
return NULL;
}
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;
for (i = 0; ddev = devs[i]; i++)
if (fp_dscv_dev_supports_dscv_print(ddev, print))
return ddev;
return NULL;
}
API_EXPORTED struct fp_dev *fp_dev_open(struct fp_dscv_dev *ddev)
{
struct fp_dev *dev;
......@@ -267,6 +319,21 @@ API_EXPORTED uint32_t fp_dev_get_devtype(struct fp_dev *dev)
return dev->devtype;
}
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);
}
API_EXPORTED int fp_dev_supports_dscv_print(struct fp_dev *dev,
struct fp_dscv_print *data)
{
return fpi_print_data_compatible(dev->drv->id, dev->devtype,
0, data->driver_id, data->devtype, 0);
}
API_EXPORTED const char *fp_driver_get_name(struct fp_driver *drv)
{
return drv->name;
......@@ -372,7 +439,7 @@ API_EXPORTED int fp_verify_finger(struct fp_dev *dev,
return -EINVAL;
}
if (!fpi_print_data_compatible(enrolled_print, dev)) {
if (!fp_dev_supports_print_data(dev, enrolled_print)) {
fp_err("print is not compatible with device");
return -EINVAL;
}
......
This diff is collapsed.
......@@ -103,7 +103,7 @@ struct fp_driver {
void *priv;
/* Device operations */
int (*discover)(struct usb_id *usb_id, uint32_t *devtype);
int (*discover)(const struct usb_id *usb_id, uint32_t *devtype);
int (*init)(struct fp_dev *dev, unsigned long driver_data);
void (*exit)(struct fp_dev *dev);
int (*enroll)(struct fp_dev *dev, gboolean initial, int stage,
......@@ -111,6 +111,8 @@ struct fp_driver {
int (*verify)(struct fp_dev *dev, struct fp_print_data *data);
};
enum fp_print_data_type fpi_driver_get_data_type(struct fp_driver *drv);
/* flags for fp_img_driver.flags */
#define FP_IMGDRV_SUPPORTS_UNCONDITIONAL_CAPTURE (1 << 0)
......@@ -145,6 +147,13 @@ struct fp_dscv_dev {
uint32_t devtype;
};
struct fp_dscv_print {
uint16_t driver_id;
uint32_t devtype;
enum fp_finger finger;
char *path;
};
enum fp_print_data_type {
PRINT_DATA_RAW = 0, /* memset-imposed default */
PRINT_DATA_NBIS_MINUTIAE,
......@@ -167,8 +176,9 @@ struct fpi_print_data_fp1 {
} __attribute__((__packed__));
struct fp_print_data *fpi_print_data_new(struct fp_dev *dev, size_t length);
gboolean fpi_print_data_compatible(struct fp_print_data *data,
struct fp_dev *dev);
gboolean fpi_print_data_compatible(uint16_t driver_id1, uint32_t devtype1,
enum fp_print_data_type type1, uint16_t driver_id2, uint32_t devtype2,
enum fp_print_data_type type2);
/* bit values for fp_img.flags */
#define FP_IMG_V_FLIPPED (1<<0)
......
......@@ -20,8 +20,11 @@
#ifndef __FPRINT_H__
#define __FPRINT_H__
#include <stdint.h>
/* structs that applications are not allowed to peek into */
struct fp_dscv_dev;
struct fp_dscv_print;
struct fp_dev;
struct fp_driver;
struct fp_print_data;
......@@ -41,17 +44,37 @@ enum fp_finger {
RIGHT_LITTLE,
};
/* Drivers */
const char *fp_driver_get_name(struct fp_driver *drv);
const char *fp_driver_get_full_name(struct fp_driver *drv);
uint16_t fp_driver_get_driver_id(struct fp_driver *drv);
/* Device discovery */
struct fp_dscv_dev **fp_discover_devs(void);
void fp_dscv_devs_free(struct fp_dscv_dev **devs);
struct fp_driver *fp_dscv_dev_get_driver(struct fp_dscv_dev *dev);
uint32_t fp_dscv_dev_get_devtype(struct fp_dscv_dev *dev);
int fp_dscv_dev_supports_print_data(struct fp_dscv_dev *dev,
struct fp_print_data *print);
int fp_dscv_dev_supports_dscv_print(struct fp_dscv_dev *dev,
struct fp_dscv_print *print);
struct fp_dscv_dev *fp_dscv_dev_for_print_data(struct fp_dscv_dev **devs,
struct fp_print_data *print);
struct fp_dscv_dev *fp_dscv_dev_for_dscv_print(struct fp_dscv_dev **devs,
struct fp_dscv_print *print);
static inline 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));
}
/* Print discovery */
struct fp_dscv_print **fp_discover_prints(void);
void fp_dscv_prints_free(struct fp_dscv_print **prints);
uint16_t fp_dscv_print_get_driver_id(struct fp_dscv_print *print);
uint32_t fp_dscv_print_get_devtype(struct fp_dscv_print *print);
enum fp_finger fp_dscv_print_get_finger(struct fp_dscv_print *print);
/* Device handling */
struct fp_dev *fp_dev_open(struct fp_dscv_dev *ddev);
void fp_dev_close(struct fp_dev *dev);
......@@ -59,11 +82,8 @@ struct fp_driver *fp_dev_get_driver(struct fp_dev *dev);
int fp_dev_get_nr_enroll_stages(struct fp_dev *dev);
struct fp_img_dev *fp_dev_to_img_dev(struct fp_dev *dev);
uint32_t fp_dev_get_devtype(struct fp_dev *dev);
/* Drivers */
const char *fp_driver_get_name(struct fp_driver *drv);
const char *fp_driver_get_full_name(struct fp_driver *drv);
uint16_t fp_driver_get_driver_id(struct fp_driver *drv);
int fp_dev_supports_print_data(struct fp_dev *dev, struct fp_print_data *data);
int fp_dev_supports_dscv_print(struct fp_dev *dev, struct fp_dscv_print *print);
/* Enrollment */
enum fp_enroll_result {
......@@ -93,6 +113,8 @@ int fp_verify_finger(struct fp_dev *dev, struct fp_print_data *enrolled_print);
/* Data handling */
int fp_print_data_load(struct fp_dev *dev, enum fp_finger finger,
struct fp_print_data **data);
int fp_print_data_from_dscv_print(struct fp_dscv_print *print,
struct fp_print_data **data);
int fp_print_data_save(struct fp_print_data *data, enum fp_finger finger);
void fp_print_data_free(struct fp_print_data *data);
size_t fp_print_data_get_data(struct fp_print_data *data, unsigned char **ret);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment