On 02/18/14 22:12, pietrek -- wrote:
Hi all,
I recently had some free time so I added AES3400 support for libfprint
and fixed continously scanning on aes3k.
It's tested on only AES3400, but should work with other sensors.

Patch contains:
-AES 3400 support added
-fixed continously scanning on aes3k

    Piotr Jarosz

Hi again,
I fixed my patch. Scanning sometimes misbehaved on error retrying( like FP_ENROLL_PASS ).
   Piotr Jarosz

diff --git a/configure.ac b/configure.ac
index 34f2eb1..0fd6483 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@ AC_SUBST(lt_major)
 AC_SUBST(lt_revision)
 AC_SUBST(lt_age)
 
-all_drivers="upekts upektc upeksonly vcom5s uru4000 fdu2000 aes1610 aes1660 aes2501 aes2550 aes2660 aes3500 aes4000 vfs101 vfs301 upektc_img etes603"
+all_drivers="upekts upektc upeksonly vcom5s uru4000 fdu2000 aes1610 aes1660 aes2501 aes2550 aes2660 aes3400 aes3500 aes4000 vfs101 vfs301 upektc_img etes603"
 
 require_imaging='no'
 require_aeslib='no'
@@ -41,6 +41,7 @@ enable_aes1660='no'
 enable_aes2501='no'
 enable_aes2550='no'
 enable_aes2660='no'
+enable_aes3400='no'
 enable_aes3500='no'
 enable_aes4000='no'
 enable_vfs101='no'
@@ -115,6 +116,13 @@ for driver in `echo ${drivers} | sed -e 's/,/ /g' -e 's/,$//g'`; do
 			require_aesX660="yes"
 			enable_aes2660="yes"
 		;;
+		aes3400)
+            AC_DEFINE([ENABLE_AES3400], [], [Build AuthenTec AES3400 driver])
+            require_aeslib="yes"
+            require_imaging="yes"
+            require_aes3k="yes"
+            enable_aes3400="yes"
+        ;;
 		aes3500)
 			AC_DEFINE([ENABLE_AES3500], [], [Build AuthenTec AES3500 driver])
 			require_aeslib="yes"
@@ -160,6 +168,7 @@ AM_CONDITIONAL([ENABLE_AES1660], [test "$enable_aes1660" = "yes"])
 AM_CONDITIONAL([ENABLE_AES2501], [test "$enable_aes2501" = "yes"])
 AM_CONDITIONAL([ENABLE_AES2550], [test "$enable_aes2550" = "yes"])
 AM_CONDITIONAL([ENABLE_AES2660], [test "$enable_aes2660" = "yes"])
+AM_CONDITIONAL([ENABLE_AES3400], [test "$enable_aes3400" = "yes"])
 AM_CONDITIONAL([ENABLE_AES3500], [test "$enable_aes3500" = "yes"])
 AM_CONDITIONAL([ENABLE_AES4000], [test "$enable_aes4000" = "yes"])
 AM_CONDITIONAL([REQUIRE_AESLIB], [test "$require_aeslib" = "yes"])
@@ -355,6 +364,11 @@ if test x$enable_aes2660 != xno ; then
 else
 	AC_MSG_NOTICE([   aes2660 driver disabled])
 fi
+if test x$enable_aes3400 != xno ; then
+    AC_MSG_NOTICE([** aes3400 driver enabled])
+else
+    AC_MSG_NOTICE([   aes3400 driver disabled])
+fi
 if test x$enable_aes3500 != xno ; then
 	AC_MSG_NOTICE([** aes3500 driver enabled])
 else
diff --git a/libfprint/Makefile.am b/libfprint/Makefile.am
index c216d49..846749d 100644
--- a/libfprint/Makefile.am
+++ b/libfprint/Makefile.am
@@ -12,6 +12,7 @@ AES1660_SRC = drivers/aes1660.c drivers/aes1660.h
 AES2501_SRC = drivers/aes2501.c drivers/aes2501.h
 AES2550_SRC = drivers/aes2550.c drivers/aes2550.h
 AES2660_SRC = drivers/aes2660.c drivers/aes2660.h
+AES3400_SRC = drivers/aes3400.c
 AES3500_SRC = drivers/aes3500.c
 AES4000_SRC = drivers/aes4000.c
 FDU2000_SRC = drivers/fdu2000.c
@@ -152,6 +153,10 @@ if ENABLE_AES2660
 DRIVER_SRC += $(AES2660_SRC)
 endif
 
+if ENABLE_AES3400
+DRIVER_SRC += $(AES3400_SRC)
+endif
+
 if ENABLE_AES3500
 DRIVER_SRC += $(AES3500_SRC)
 endif
diff --git a/libfprint/core.c b/libfprint/core.c
index cde8f48..ea69b74 100644
--- a/libfprint/core.c
+++ b/libfprint/core.c
@@ -349,6 +349,9 @@ static struct fp_driver * const primitive_drivers[] = {
 };
 
 static struct fp_img_driver * const img_drivers[] = {
+#ifdef ENABLE_AES3400
+    &aes3400_driver,
+#endif
 #ifdef ENABLE_AES3500
 	&aes3500_driver,
 #endif
diff --git a/libfprint/drivers/aes3400.c b/libfprint/drivers/aes3400.c
index e69de29..ff02719 100644
--- a/libfprint/drivers/aes3400.c
+++ b/libfprint/drivers/aes3400.c
@@ -0,0 +1,206 @@
+/*
+ * AuthenTec AES3400 driver for libfprint
+ *
+ * AES3400 is a press-typed sensor, which captures image in 128x128
+ * pixels.
+ *
+ * Adapted from AES3500 by Piotr Jarosz <pietre...@gmail.com>
+ *
+ * This work is derived from Daniel Drake's AES4000 driver.
+ *
+ * Copyright (C) 2011-2013 Juvenn Woo <mach...@gmail.com>
+ * Copyright (C) 2007-2008 Daniel Drake <d...@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
+ */
+
+#define FP_COMPONENT "aes3400"
+
+#include <errno.h>
+
+#include <glib.h>
+#include <libusb.h>
+
+#include <aeslib.h>
+#include <fp_internal.h>
+
+#include "aes3k.h"
+#include "driver_ids.h"
+
+#define DATA_BUFLEN 0x2051
+
+/* image size = FRAME_WIDTH x FRAME_WIDTH */
+#define FRAME_WIDTH     128
+#define FRAME_SIZE  (FRAME_WIDTH * AES3K_FRAME_HEIGHT / 2)
+#define FRAME_NUMBER    (FRAME_WIDTH / AES3K_FRAME_HEIGHT)
+#define ENLARGE_FACTOR  2
+
+
+static struct aes_regwrite init_reqs[] = {
+    /* master reset */
+    { 0x80, 0x01 },
+    { 0, 0 },
+    { 0x80, 0x00 },
+    { 0, 0 },
+
+    { 0x81, 0x00 },
+    { 0x80, 0x00 },
+    { 0, 0 },
+
+    /* scan reset */
+    { 0x80, 0x02 },
+    { 0, 0 },
+    { 0x80, 0x00 },
+    { 0, 0 },
+
+    /* disable register buffering */
+    { 0x80, 0x02 },
+    { 0, 0 },
+    { 0x80, 0x00 },
+    { 0, 0 },
+
+    { 0x81, 0x00 },
+    { 0, 0 },
+    /* windows driver reads registers now (81 02) */
+    { 0x80, 0x02 },
+    { 0x81, 0x00 },
+
+    /* set excitation bias current: 2mhz drive ring frequency,
+     * 4V drive ring voltage, 16.5mA excitation bias */
+    { 0x82, 0x04 },
+
+    /* continuously sample drive ring for finger detection,
+     * 62.50ms debounce delay */
+    { 0x83, 0x13 },
+
+    { 0x84, 0x07 }, /* set calibration resistance to 12 kiloohms */
+    { 0x85, 0x3d }, /* set calibration capacitance */
+    { 0x86, 0x03 }, /* detect drive voltage */
+    { 0x87, 0x01 }, /* set detection frequency to 125khz */
+    { 0x88, 0x02 }, /* set column scan period */
+    { 0x89, 0x02 }, /* set measure drive */
+    { 0x8a, 0x05 }, /* set measure frequency and sense amplifier bias */
+    { 0x8b, 0x33 }, /* set matrix pattern */
+    { 0x8c, 0x21 }, /* set demodulation phase 1 */
+    { 0x8d, 0x00 }, /* set demodulation phase 2 */
+    { 0x8e, 0x03 }, /* set sensor gain */
+    { 0x8f, 0x07 }, /* set image parameters */
+    { 0x90, 0x00 }, /* carrier offset null */
+    { 0x91, 0x70 }, /* set A/D reference high */
+    { 0x92, 0x11 }, /* set A/D reference low */
+    { 0x93, 0x00 }, /* set start row to 0 */
+    { 0x94, 0x1f }, /* set end row */
+    { 0x95, 0x00 }, /* set start column to 0 */
+    { 0x96, 0x1f }, /* set end column */
+    { 0x97, 0x04 }, /* data format and thresholds */
+    { 0x98, 0x00 }, /* image data control */
+    { 0x99, 0x00 }, /* disable general purpose outputs */
+    { 0x9a, 0x0b }, /* set initial scan state */
+    { 0x9b, 0x01 }, /* clear challenge word bits */
+    { 0x9c, 0x48 }, /* clear challenge word bits */
+    { 0x9d, 0x06 }, /* set some challenge word bits */
+    { 0x9e, 0x07 }, /* clear challenge word bits */
+    { 0x9f, 0x68 }, /* set some challenge word bits */
+    { 0, 0 },
+
+    { 0x80, 0x02 },
+    { 0x81, 0x00 },
+    { 0, 0 },
+    { 0x81, 0x00 },
+    { 0, 0 },
+    { 0x81, 0x04 }, /* oneshot scan */
+//    { 0x81, 0x01 }, /* continous scan */
+};
+
+static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
+{
+	int r;
+	struct aes3k_dev *aesdev;
+
+	r = libusb_claim_interface(dev->udev, 0);
+	if (r < 0)
+		fp_err("could not claim interface 0");
+
+	aesdev = dev->priv = g_malloc0(sizeof(struct aes3k_dev));
+
+	if (!aesdev)
+		return -ENOMEM;
+
+	if (r == 0)
+		aesdev->data_buflen = DATA_BUFLEN;
+		aesdev->frame_width = FRAME_WIDTH;
+		aesdev->frame_size = FRAME_SIZE;
+		aesdev->frame_number = FRAME_NUMBER;
+		aesdev->enlarge_factor = ENLARGE_FACTOR;
+		aesdev->init_reqs = init_reqs;
+		aesdev->init_reqs_len = G_N_ELEMENTS(init_reqs);
+		fpi_imgdev_open_complete(dev, 0);
+
+	return r;
+}
+
+static void dev_deinit(struct fp_img_dev *dev)
+{
+	struct aes3k_dev *aesdev = dev->priv;
+	g_free(aesdev);
+	libusb_release_interface(dev->udev, 0);
+	fpi_imgdev_close_complete(dev);
+}
+
+
+// so many ids to suport all possible strange product ids
+static const struct usb_id id_table[] = {
+    { .vendor = 0x08ff, .product = 0x3400 },
+    { .vendor = 0x08ff, .product = 0x3401 },
+    { .vendor = 0x08ff, .product = 0x3402 },
+    { .vendor = 0x08ff, .product = 0x3403 },
+    { .vendor = 0x08ff, .product = 0x3404 },
+    { .vendor = 0x08ff, .product = 0x3405 },
+    { .vendor = 0x08ff, .product = 0x3406 },
+    { .vendor = 0x08ff, .product = 0x3407 },
+    { .vendor = 0x08ff, .product = 0x3408 },
+    { .vendor = 0x08ff, .product = 0x3409 },
+    { .vendor = 0x08ff, .product = 0x340a },
+    { .vendor = 0x08ff, .product = 0x340b },
+    { .vendor = 0x08ff, .product = 0x340c },
+    { .vendor = 0x08ff, .product = 0x340d },
+    { .vendor = 0x08ff, .product = 0x340e },
+    { .vendor = 0x08ff, .product = 0x340f },
+    { .vendor = 0x08ff, .product = 0x3410 },
+    { 0, 0, 0, },
+};
+
+struct fp_img_driver aes3400_driver = {
+	.driver = {
+		.id = AES3400_ID,
+		.name = FP_COMPONENT,
+		.full_name = "AuthenTec AES3400",
+		.id_table = id_table,
+		.scan_type = FP_SCAN_TYPE_PRESS,
+	},
+	.flags = 0,
+	.img_height = FRAME_WIDTH * ENLARGE_FACTOR,
+	.img_width = FRAME_WIDTH * ENLARGE_FACTOR,
+
+	/* temporarily lowered until image quality improves */
+	.bz3_threshold = 9,
+
+	.open = dev_init,
+	.close = dev_deinit,
+	.activate = aes3k_dev_activate,
+	.deactivate = aes3k_dev_deactivate,
+};
+
diff --git a/libfprint/drivers/aes3k.c b/libfprint/drivers/aes3k.c
index fefba3c..0f6c973 100644
--- a/libfprint/drivers/aes3k.c
+++ b/libfprint/drivers/aes3k.c
@@ -50,6 +50,16 @@
 #define EP_IN		(1 | LIBUSB_ENDPOINT_IN)
 #define EP_OUT		(2 | LIBUSB_ENDPOINT_OUT)
 
+/* ask for san next image */
+static struct aes_regwrite imgask_reqs[] = {
+    { 0x81, 0x00 },
+    { 0x80, 0x00 },
+    { 0, 0 },
+    { 0x81, 0x04 }, /* ask for oneshot */
+    { 0, 0 },
+    { 0x81, 0x00 },
+};
+
 static void do_capture(struct fp_img_dev *dev);
 
 static void img_cb(struct libusb_transfer *transfer)
@@ -93,8 +103,25 @@ static void img_cb(struct libusb_transfer *transfer)
 	/* FIXME: rather than assuming finger has gone, we should poll regs until
 	 * it really has, then restart the capture */
 	fpi_imgdev_report_finger_status(dev, FALSE);
-
-	do_capture(dev);
+    
+    /* detect if rescan needed and ask for it to device */
+    int rescan=0;
+    switch( dev->action )
+     {
+        case IMG_ACTION_ENROLL:
+            if ( dev->action_result != FP_ENROLL_COMPLETE ) rescan = 1;
+            break;
+        case IMG_ACTION_VERIFY:
+        case IMG_ACTION_IDENTIFY:
+            if ( dev->action_result > FP_VERIFY_MATCH ) rescan = 1;
+            break;
+        case IMG_ACTION_CAPTURE:
+            break;
+     }
+    if ( rescan )
+        aes_write_regv(dev, imgask_reqs, G_N_ELEMENTS(imgask_reqs), (aes_write_regv_cb) do_capture, dev);
+      else
+       do_capture(dev);
 
 err:
 	g_free(transfer->buffer);
diff --git a/libfprint/drivers/driver_ids.h b/libfprint/drivers/driver_ids.h
index b3c6ee6..5c2d378 100644
--- a/libfprint/drivers/driver_ids.h
+++ b/libfprint/drivers/driver_ids.h
@@ -39,6 +39,7 @@ enum {
 	AES3500_ID	= 16,
 	UPEKTC_IMG_ID	= 17,
 	ETES603_ID	= 18,
+    AES3400_ID  = 19,
 };
 
 #endif
diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h
index 6910b64..4243c9f 100644
--- a/libfprint/fp_internal.h
+++ b/libfprint/fp_internal.h
@@ -278,6 +278,9 @@ extern struct fp_img_driver aes2550_driver;
 #ifdef ENABLE_AES2660
 extern struct fp_img_driver aes2660_driver;
 #endif
+#ifdef ENABLE_AES3400
+extern struct fp_img_driver aes3400_driver;
+#endif
 #ifdef ENABLE_AES3500
 extern struct fp_img_driver aes3500_driver;
 #endif
_______________________________________________
fprint mailing list
fprint@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/fprint

Reply via email to