Half of the patches arre for the UPEX TouchStrip and half for the PAM module.

upeksonly.c - The first patch avoids distortion in case of lost Image
packets. Without this patch scans from my laptops integrated reader
were recognized perhaps in one case out of 10. With it, its more like
8 out of 10 and the 2 that fail are usually just bad scans.

Second patch corrects the 2 pixel rollover on image handover instead
of trying to do it on read where it gets in the way of the corrective
action added by the first patch.

PAM module - First patch addresses bad scans on PAM side. Theres no
point calling it quits on first mismatch and no harm letting the user
have same amount of retries as with any other failure. the second
patch is a build fix. Makefiles generated by automake wont work
without this at least when prefix is set to /opt.

Hopefully you will find them of use.

Best,
--Alexia
From a1d8a288f74b86079eb115371a8970c4bfe4e859 Mon Sep 17 00:00:00 2001
From: Alexia Death <[email protected]>
Date: Thu, 24 Dec 2009 21:42:01 +0200
Subject: [PATCH 1/2] Add some corrective action if there are missing packets in image stream

If a packet goes missing, use the data from previous row to minimize distortion.
---
 libfprint/drivers/upeksonly.c |   59 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/libfprint/drivers/upeksonly.c b/libfprint/drivers/upeksonly.c
index f41a6be..65e7940 100644
--- a/libfprint/drivers/upeksonly.c
+++ b/libfprint/drivers/upeksonly.c
@@ -248,6 +248,7 @@ static void add_to_rowbuf(struct fp_img_dev *dev, unsigned char *data, int size)
 	sdev->rowbuf_offset += size;
 	if (sdev->rowbuf_offset >= IMG_WIDTH)
 		row_complete(dev);
+
 }
 
 static void start_new_row(struct sonly_dev *sdev, unsigned char *data, int size)
@@ -282,11 +283,60 @@ static void handle_packet(struct fp_img_dev *dev, unsigned char *data)
 	int for_rowbuf;
 	int next_row_addr;
 	int diff;
-
+	unsigned char dummy_data[62];
+	
+	/*Init dummy data to something neutral*/
+	for (int i = 0; i < 62; i++) dummy_data[i] = 204;
+	
 	data += 2; /* skip sequence number */
 	if (seqnum != sdev->last_seqnum + 1) {
 		if (seqnum != 0 && sdev->last_seqnum != 16383)
-			fp_warn("lost some data");
+			{
+			 	int missing_data = seqnum - sdev->last_seqnum;
+				fp_warn("lost %d packets of data between %d and %d", missing_data, sdev->last_seqnum, seqnum );
+				/* Minimize distortions for readers that lose a lot of packets */
+				for (int i =1; i < missing_data; i++)
+					{
+						abs_base_addr = (sdev->last_seqnum + 1) * 62;
+						
+						/* If possible take the replacement data from last row */
+						if (sdev->num_rows > 1)
+							{
+								int row_left = IMG_WIDTH - sdev->rowbuf_offset;
+								unsigned char *last_row = g_slist_nth_data (sdev->rows, 0);
+
+								if (row_left >= 62) {
+									memcpy(dummy_data, last_row + sdev->rowbuf_offset, 62);
+								}
+								else {
+									memcpy(dummy_data, last_row + sdev->rowbuf_offset, row_left);
+									memcpy(dummy_data + row_left, last_row , 62 - row_left);
+								}
+							}
+
+						fp_warn("adding dummy input for %d, i=%d", sdev->last_seqnum + i, i);
+						for_rowbuf = rowbuf_remaining(sdev);
+						if (for_rowbuf != -1) {
+							add_to_rowbuf(dev, dummy_data, for_rowbuf);
+							/*row boundary*/
+							if (for_rowbuf < 62) {
+								start_new_row(sdev, dummy_data + for_rowbuf, 62 - for_rowbuf);
+							}
+						}
+						else if (abs_base_addr % IMG_WIDTH == 0) {
+							start_new_row(sdev, dummy_data, 62);
+						}
+						else {
+							/* does the data in the packet reside on a row boundary?
+							 * if so capture it*/
+								next_row_addr = ((abs_base_addr / IMG_WIDTH) + 1) * IMG_WIDTH;
+								diff = next_row_addr - abs_base_addr;
+								if (diff < 62)
+									start_new_row(sdev, dummy_data + diff, 62 - diff);
+						}
+						sdev->last_seqnum = sdev->last_seqnum + 1;
+					}
+			}
 	}
 	if (seqnum <= sdev->last_seqnum) {
 		fp_dbg("detected wraparound");
@@ -302,7 +352,10 @@ static void handle_packet(struct fp_img_dev *dev, unsigned char *data)
 	for_rowbuf = rowbuf_remaining(sdev);
 	if (for_rowbuf != -1) {
 		add_to_rowbuf(dev, data, for_rowbuf);
-		/* FIXME: we drop a row here */
+		/*row boundary*/
+		if (for_rowbuf < 62) {
+			start_new_row(sdev, data + for_rowbuf, 62 - for_rowbuf);
+		}
 		return;
 	}
 
-- 
1.6.3.3

From 01c40fee753394cd9cb1eecbd3d37a1f45cc1edf Mon Sep 17 00:00:00 2001
From: Alexia Death <[email protected]>
Date: Fri, 25 Dec 2009 00:04:55 +0200
Subject: [PATCH 2/2] Make the +2 right shift correction happen on image handoff.

Doing it there seems a lot more sensible and does not
get in the way of minimizing the impact of lost USB packages.
---
 libfprint/drivers/upeksonly.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/libfprint/drivers/upeksonly.c b/libfprint/drivers/upeksonly.c
index 65e7940..ff2cb5a 100644
--- a/libfprint/drivers/upeksonly.c
+++ b/libfprint/drivers/upeksonly.c
@@ -168,8 +168,13 @@ static void handoff_img(struct fp_img_dev *dev)
 	fp_dbg("%d rows", sdev->num_rows);
 	img->height = sdev->num_rows;
 
+/* The scans from this device are rolled right by two colums
+ * It feels a lot smarter to correct here than mess with it at
+ * read time*/
+
 	do {
-		memcpy(img->data + offset, elem->data, IMG_WIDTH);
+		memcpy(img->data + offset, elem->data + 2, IMG_WIDTH - 2);
+		memcpy(img->data + offset + IMG_WIDTH - 2, elem->data,  2);
 		g_free(elem->data);
 		offset += IMG_WIDTH;
 	} while ((elem = g_slist_next(elem)) != NULL);
@@ -255,8 +260,7 @@ static void start_new_row(struct sonly_dev *sdev, unsigned char *data, int size)
 {
 	if (!sdev->rowbuf)
 		sdev->rowbuf = g_malloc(IMG_WIDTH);
-	memcpy(sdev->rowbuf + IMG_WIDTH - 2, data, 2);
-	memcpy(sdev->rowbuf, data + 2, size - 2);
+	memcpy(sdev->rowbuf, data, size);
 	sdev->rowbuf_offset = size;
 }
 
-- 
1.6.3.3

From e39e66c6a56392f1cfaa4625f52a2e47d5e675b8 Mon Sep 17 00:00:00 2001
From: Alexia Death <[email protected]>
Date: Fri, 25 Dec 2009 00:39:23 +0200
Subject: [PATCH 1/2] Make match failure subject to 5 retries like all other failures.

Swipe finger over sensor type reading is not that exact.
Allowing few retries makes the reading usable.
---
 src/pam_fprint.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/pam_fprint.c b/src/pam_fprint.c
index 24fc104..fda7b41 100644
--- a/src/pam_fprint.c
+++ b/src/pam_fprint.c
@@ -163,14 +163,14 @@ static int do_identify(pam_handle_t *pamh, struct fp_dev *dev,
 
 		
 		if (fp_dev_supports_identification(dev)) {
-		    snprintf(msg, sizeof(msg), "Scan finger on %s", driver_name);
+		    snprintf(msg, sizeof(msg), "Scan finger on %s, you have %d tries.", driver_name, max_tries);
 		    msg[sizeof(msg) - 1] = 0;
 		    send_info_msg(pamh, msg);
 		    r = fp_identify_finger(dev, gallery, &offset);
 		    
 		}
 		else {
-		    snprintf(msg, sizeof(msg), "Scan %s finger on %s", fstr, driver_name);
+		    snprintf(msg, sizeof(msg), "Scan %s finger on %s, you have %d tries.", fstr, driver_name, max_tries);
 		    msg[sizeof(msg) - 1] = 0;
 		    send_info_msg(pamh, msg);
 		    r = fp_verify_finger(dev, gallery[0]);
@@ -183,7 +183,8 @@ static int do_identify(pam_handle_t *pamh, struct fp_dev *dev,
 		}
 		switch (r) {
 		case FP_VERIFY_NO_MATCH:
-			return PAM_AUTH_ERR;
+			if (max_tries == 1) return PAM_AUTH_ERR;
+			break;
 		case FP_VERIFY_MATCH:
 			return PAM_SUCCESS;
 		case FP_VERIFY_RETRY:
-- 
1.6.3.3

From a102a8e395e0bf3b68c07924516ba3b7df087468 Mon Sep 17 00:00:00 2001
From: Alexia Death <[email protected]>
Date: Fri, 25 Dec 2009 00:41:16 +0200
Subject: [PATCH 2/2] Fix the header reference to fit the current make file environment

---
 src/pam_fprint_enroll.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/pam_fprint_enroll.c b/src/pam_fprint_enroll.c
index fa04fcc..976f66e 100644
--- a/src/pam_fprint_enroll.c
+++ b/src/pam_fprint_enroll.c
@@ -26,7 +26,7 @@
 #include <unistd.h>
 #include <getopt.h>
 
-#include <libfprint/fprint.h>
+#include <fprint.h>
 
 static const char *finger_names[] = {
 	[LEFT_THUMB] = "Left Thumb",
-- 
1.6.3.3

_______________________________________________
fprint mailing list
[email protected]
http://lists.reactivated.net/mailman/listinfo/fprint

Reply via email to