Initial driver registration mechanism

Also added the basis of the upekts driver, which is the first I'll
implement.
This commit is contained in:
Daniel Drake 2007-10-08 16:46:42 +01:00
parent 7d3612d9f6
commit 046bdc0bda
5 changed files with 131 additions and 2 deletions

View file

@ -1,9 +1,14 @@
lib_LTLIBRARIES = libfprint.la lib_LTLIBRARIES = libfprint.la
UPEKTS_SRC = drivers/upekts.c
DRIVER_SRC = $(UPEKTS_SRC)
libfprint_la_CFLAGS = -fvisibility=hidden $(LIBUSB_CFLAGS) $(GLIB_CFLAGS) libfprint_la_CFLAGS = -fvisibility=hidden $(LIBUSB_CFLAGS) $(GLIB_CFLAGS)
libfprint_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@ libfprint_la_LDFLAGS = -version-info @lt_major@:@lt_revision@:@lt_age@
libfprint_la_LIBADD = $(LIBUSB_LIBS) $(GLIB_LIBS) libfprint_la_LIBADD = $(LIBUSB_LIBS) $(GLIB_LIBS)
libfprint_la_SOURCES = \ libfprint_la_SOURCES = \
core.c core.c \
$(DRIVER_SRC)

View file

@ -19,7 +19,31 @@
#include <config.h> #include <config.h>
#include <glib.h>
#include "fp_internal.h"
static GList *registered_drivers = NULL;
static void register_driver(const struct fp_driver *drv)
{
registered_drivers = g_list_prepend(registered_drivers, (gpointer) drv);
}
static const struct fp_driver * const drivers[] = {
&upekts_driver,
};
static void register_drivers(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(drivers); i++)
register_driver(drivers[i]);
}
API_EXPORTED int fp_init(void) API_EXPORTED int fp_init(void)
{ {
register_drivers();
return 0; return 0;
} }

View file

@ -0,0 +1,32 @@
/*
* UPEK TouchStrip driver 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 <fp_internal.h>
static const struct usb_id id_table[] = {
{ .vendor = 0x0483, .product = 0x2016 },
{ 0 }, /* terminating entry */
};
const struct fp_driver upekts_driver = {
.name = "upekts",
.full_name = "UPEK TouchStrip",
.id_table = id_table,
};

42
libfprint/fp_internal.h Normal file
View file

@ -0,0 +1,42 @@
/*
* Internal/private definitions 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
*/
#ifndef __FPRINT_INTERNAL_H__
#define __FPRINT_INTERNAL_H__
#include <stdint.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a))
struct usb_id {
uint16_t vendor;
uint16_t product;
unsigned long driver_data;
};
struct fp_driver {
const char *name;
const char *full_name;
const struct usb_id * const id_table;
};
extern const struct fp_driver upekts_driver;
#endif

26
libfprint/fprint.h Normal file
View file

@ -0,0 +1,26 @@
/*
* Main definitions 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
*/
#ifndef __FPRINT_H__
#define __FPRINT_H__
int fp_init(void);
#endif