Commit 2709c6dc authored by Daniel Drake's avatar Daniel Drake

Basic image driver foundations

The basic model is that image drivers declare a fp_img_driver structure
rather than a fp_driver struct. fp_img_driver will contain primitive imaging
operations such as 'scan finger and return image'. The imgdev layer will
generically implement the primitive fp_driver operations, and the imgdev
layer will fix up the enroll/verify/etc pointers at driver registration
time.

Removed const from all fp_driver declarations, as these are now modified
dynamically in the case of imaging drivers.
parent c97f4bb1
......@@ -30,7 +30,7 @@ struct fp_dscv_dev *discover_device(struct fp_dscv_dev **discovered_devs)
int i;
for (i = 0; ddev = discovered_devs[i]; i++) {
const struct fp_driver *drv = fp_dscv_dev_get_driver(ddev);
struct fp_driver *drv = fp_dscv_dev_get_driver(ddev);
printf("Found device claimed by %s driver\n",
fp_driver_get_full_name(drv));
return ddev;
......
......@@ -30,7 +30,7 @@ struct fp_dscv_dev *discover_device(struct fp_dscv_dev **discovered_devs)
int i;
for (i = 0; ddev = discovered_devs[i]; i++) {
const struct fp_driver *drv = fp_dscv_dev_get_driver(ddev);
struct fp_driver *drv = fp_dscv_dev_get_driver(ddev);
printf("Found device claimed by %s driver\n",
fp_driver_get_full_name(drv));
return ddev;
......
......@@ -29,7 +29,7 @@ struct fp_dscv_dev *discover_device(struct fp_dscv_dev **discovered_devs)
int i;
for (i = 0; ddev = discovered_devs[i]; i++) {
const struct fp_driver *drv = fp_dscv_dev_get_driver(ddev);
struct fp_driver *drv = fp_dscv_dev_get_driver(ddev);
printf("Found device claimed by %s driver\n",
fp_driver_get_full_name(drv));
return ddev;
......
......@@ -11,5 +11,6 @@ libfprint_la_LIBADD = $(LIBUSB_LIBS) $(GLIB_LIBS)
libfprint_la_SOURCES = \
core.c \
data.c \
imgdev.c \
$(DRIVER_SRC)
......@@ -67,30 +67,40 @@ void fpi_log(enum fpi_log_level level, const char *component,
fprintf(stream, "\n");
}
static void register_driver(const struct fp_driver *drv)
static void register_driver(struct fp_driver *drv)
{
registered_drivers = g_list_prepend(registered_drivers, (gpointer) drv);
fp_dbg("registered driver %s", drv->name);
}
static const struct fp_driver * const drivers[] = {
static struct fp_driver * const primitive_drivers[] = {
&upekts_driver,
};
static struct fp_img_driver * const img_drivers[] = {
&uru4000_driver,
};
static void register_drivers(void)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(drivers); i++)
register_driver(drivers[i]);
for (i = 0; i < ARRAY_SIZE(primitive_drivers); i++)
register_driver(primitive_drivers[i]);
for (i = 0; i < ARRAY_SIZE(img_drivers); i++) {
struct fp_img_driver *imgdriver = img_drivers[i];
fpi_img_driver_setup(imgdriver);
register_driver(&imgdriver->driver);
}
}
static const struct fp_driver *find_supporting_driver(struct usb_device *udev)
static struct fp_driver *find_supporting_driver(struct usb_device *udev)
{
GList *elem = registered_drivers;
do {
const struct fp_driver *drv = elem->data;
struct fp_driver *drv = elem->data;
const struct usb_id *id;
for (id = drv->id_table; id->vendor; id++)
......@@ -125,7 +135,7 @@ API_EXPORTED struct fp_dscv_dev **fp_discover_devs(void)
* sets of drivers against small sets of USB devices */
for (bus = usb_get_busses(); bus; bus = bus->next)
for (udev = bus->devices; udev; udev = udev->next) {
const struct fp_driver *drv = find_supporting_driver(udev);
struct fp_driver *drv = find_supporting_driver(udev);
struct fp_dscv_dev *ddev;
if (!drv)
continue;
......@@ -163,7 +173,7 @@ API_EXPORTED void fp_dscv_devs_free(struct fp_dscv_dev **devs)
g_free(devs);
}
API_EXPORTED const struct fp_driver *fp_dscv_dev_get_driver(struct fp_dscv_dev *dev)
API_EXPORTED struct fp_driver *fp_dscv_dev_get_driver(struct fp_dscv_dev *dev)
{
return dev->drv;
}
......@@ -171,7 +181,7 @@ API_EXPORTED const struct fp_driver *fp_dscv_dev_get_driver(struct fp_dscv_dev *
API_EXPORTED struct fp_dev *fp_dev_open(struct fp_dscv_dev *ddev)
{
struct fp_dev *dev;
const struct fp_driver *drv = ddev->drv;
struct fp_driver *drv = ddev->drv;
int r;
usb_dev_handle *udevh = usb_open(ddev->udev);
......@@ -208,7 +218,7 @@ API_EXPORTED void fp_dev_close(struct fp_dev *dev)
g_free(dev);
}
API_EXPORTED const struct fp_driver *fp_dev_get_driver(struct fp_dev *dev)
API_EXPORTED struct fp_driver *fp_dev_get_driver(struct fp_dev *dev)
{
return dev->drv;
}
......@@ -218,12 +228,12 @@ API_EXPORTED int fp_dev_get_nr_enroll_stages(struct fp_dev *dev)
return dev->nr_enroll_stages;
}
API_EXPORTED const char *fp_driver_get_name(const struct fp_driver *drv)
API_EXPORTED const char *fp_driver_get_name(struct fp_driver *drv)
{
return drv->name;
}
API_EXPORTED const char *fp_driver_get_full_name(const struct fp_driver *drv)
API_EXPORTED const char *fp_driver_get_full_name(struct fp_driver *drv)
{
return drv->full_name;
}
......@@ -231,7 +241,7 @@ API_EXPORTED const char *fp_driver_get_full_name(const struct fp_driver *drv)
API_EXPORTED int fp_enroll_finger(struct fp_dev *dev,
struct fp_print_data **print_data)
{
const struct fp_driver *drv = dev->drv;
struct fp_driver *drv = dev->drv;
int ret;
int stage = dev->__enroll_stage;
gboolean initial = FALSE;
......@@ -298,7 +308,7 @@ API_EXPORTED int fp_enroll_finger(struct fp_dev *dev,
API_EXPORTED int fp_verify_finger(struct fp_dev *dev,
struct fp_print_data *enrolled_print)
{
const struct fp_driver *drv = dev->drv;
struct fp_driver *drv = dev->drv;
int r;
if (!enrolled_print) {
......
......@@ -774,7 +774,7 @@ static const struct usb_id id_table[] = {
{ 0, 0, 0, }, /* terminating entry */
};
const struct fp_driver upekts_driver = {
struct fp_driver upekts_driver = {
.name = FP_COMPONENT,
.full_name = "UPEK TouchStrip",
.id_table = id_table,
......
......@@ -72,7 +72,7 @@ void fpi_log(enum fpi_log_level, const char *component, const char *function,
#define fp_err(fmt...) _fpi_log(LOG_LEVEL_ERROR, fmt)
struct fp_dev {
const struct fp_driver *drv;
struct fp_driver *drv;
usb_dev_handle *udev;
void *priv;
......@@ -88,10 +88,18 @@ struct usb_id {
unsigned long driver_data;
};
enum fp_driver_type {
DRIVER_PRIMITIVE = 0,
DRIVER_IMAGING = 1,
};
struct fp_driver {
const char *name;
const char *full_name;
const struct usb_id * const id_table;
enum fp_driver_type type;
void *priv;
/* Device operations */
int (*init)(struct fp_dev *dev);
......@@ -101,11 +109,20 @@ struct fp_driver {
int (*verify)(struct fp_dev *dev, struct fp_print_data *data);
};
extern const struct fp_driver upekts_driver;
struct fp_img_driver {
struct fp_driver driver;
/* Device operations */
};
extern struct fp_driver upekts_driver;
extern struct fp_img_driver uru4000_driver;
void fpi_img_driver_setup(struct fp_img_driver *idriver);
struct fp_dscv_dev {
struct usb_device *udev;
const struct fp_driver *drv;
struct fp_driver *drv;
};
struct fp_print_data {
......
......@@ -43,17 +43,17 @@ enum fp_finger {
/* Device discovery */
struct fp_dscv_dev **fp_discover_devs(void);
void fp_dscv_devs_free(struct fp_dscv_dev **devs);
const struct fp_driver *fp_dscv_dev_get_driver(struct fp_dscv_dev *dev);
struct fp_driver *fp_dscv_dev_get_driver(struct fp_dscv_dev *dev);
/* Device handling */
struct fp_dev *fp_dev_open(struct fp_dscv_dev *ddev);
void fp_dev_close(struct fp_dev *dev);
const struct fp_driver *fp_dev_get_driver(struct fp_dev *dev);
struct fp_driver *fp_dev_get_driver(struct fp_dev *dev);
int fp_dev_get_nr_enroll_stages(struct fp_dev *dev);
/* Drivers */
const char *fp_driver_get_name(const struct fp_driver *drv);
const char *fp_driver_get_full_name(const struct fp_driver *drv);
const char *fp_driver_get_name(struct fp_driver *drv);
const char *fp_driver_get_full_name(struct fp_driver *drv);
/* Enrollment */
enum fp_enroll_result {
......
/*
* Core imaging functions for libfprint
* Copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
*
* 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 <glib.h>
#include "fp_internal.h"
void fpi_img_driver_setup(struct fp_img_driver *idriver)
{
idriver->driver.type = DRIVER_IMAGING;
/* FIXME fill in primitive operations */
}
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