|
|
|
@ -33,9 +33,11 @@ static int img_dev_open(struct fp_dev *dev, unsigned long driver_data)
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(dev->drv);
|
|
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
|
|
imgdev->dev = dev;
|
|
|
|
|
/* Set up back pointers */
|
|
|
|
|
dev->img_dev = imgdev;
|
|
|
|
|
imgdev->parent = dev;
|
|
|
|
|
|
|
|
|
|
imgdev->enroll_stage = 0;
|
|
|
|
|
dev->priv = imgdev;
|
|
|
|
|
dev->nr_enroll_stages = IMG_ENROLL_STAGES;
|
|
|
|
|
|
|
|
|
|
/* for consistency in driver code, allow udev access through imgdev */
|
|
|
|
@ -57,30 +59,29 @@ err:
|
|
|
|
|
|
|
|
|
|
void fpi_imgdev_open_complete(struct fp_img_dev *imgdev, int status)
|
|
|
|
|
{
|
|
|
|
|
fpi_drvcb_open_complete(imgdev->dev, status);
|
|
|
|
|
fpi_drvcb_open_complete(FP_DEV(imgdev), status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void img_dev_close(struct fp_dev *dev)
|
|
|
|
|
{
|
|
|
|
|
struct fp_img_dev *imgdev = dev->priv;
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(dev->drv);
|
|
|
|
|
|
|
|
|
|
if (imgdrv->close)
|
|
|
|
|
imgdrv->close(imgdev);
|
|
|
|
|
imgdrv->close(dev->img_dev);
|
|
|
|
|
else
|
|
|
|
|
fpi_drvcb_close_complete(dev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fpi_imgdev_close_complete(struct fp_img_dev *imgdev)
|
|
|
|
|
{
|
|
|
|
|
fpi_drvcb_close_complete(imgdev->dev);
|
|
|
|
|
fpi_drvcb_close_complete(FP_DEV(imgdev));
|
|
|
|
|
g_free(imgdev);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int dev_change_state(struct fp_img_dev *imgdev,
|
|
|
|
|
enum fp_imgdev_state state)
|
|
|
|
|
{
|
|
|
|
|
struct fp_driver *drv = imgdev->dev->drv;
|
|
|
|
|
struct fp_driver *drv = FP_DEV(imgdev)->drv;
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
|
|
|
|
|
|
|
|
|
|
if (!imgdrv->change_state)
|
|
|
|
@ -92,7 +93,7 @@ static int dev_change_state(struct fp_img_dev *imgdev,
|
|
|
|
|
* image after freeing the old one. */
|
|
|
|
|
static int sanitize_image(struct fp_img_dev *imgdev, struct fp_img **_img)
|
|
|
|
|
{
|
|
|
|
|
struct fp_driver *drv = imgdev->dev->drv;
|
|
|
|
|
struct fp_driver *drv = FP_DEV(imgdev)->drv;
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
|
|
|
|
|
struct fp_img *img = *_img;
|
|
|
|
|
|
|
|
|
@ -150,7 +151,7 @@ void fpi_imgdev_report_finger_status(struct fp_img_dev *imgdev,
|
|
|
|
|
if (r == FP_ENROLL_COMPLETE) {
|
|
|
|
|
imgdev->enroll_data = NULL;
|
|
|
|
|
}
|
|
|
|
|
fpi_drvcb_enroll_stage_completed(imgdev->dev, r,
|
|
|
|
|
fpi_drvcb_enroll_stage_completed(FP_DEV(imgdev), r,
|
|
|
|
|
r == FP_ENROLL_COMPLETE ? data : NULL,
|
|
|
|
|
img);
|
|
|
|
|
/* the callback can cancel enrollment, so recheck current
|
|
|
|
@ -163,18 +164,18 @@ void fpi_imgdev_report_finger_status(struct fp_img_dev *imgdev,
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_VERIFY:
|
|
|
|
|
fpi_drvcb_report_verify_result(imgdev->dev, r, img);
|
|
|
|
|
fpi_drvcb_report_verify_result(FP_DEV(imgdev), r, img);
|
|
|
|
|
imgdev->action_result = 0;
|
|
|
|
|
fp_print_data_free(data);
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_IDENTIFY:
|
|
|
|
|
fpi_drvcb_report_identify_result(imgdev->dev, r,
|
|
|
|
|
fpi_drvcb_report_identify_result(FP_DEV(imgdev), r,
|
|
|
|
|
imgdev->identify_match_offset, img);
|
|
|
|
|
imgdev->action_result = 0;
|
|
|
|
|
fp_print_data_free(data);
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_CAPTURE:
|
|
|
|
|
fpi_drvcb_report_capture_result(imgdev->dev, r, img);
|
|
|
|
|
fpi_drvcb_report_capture_result(FP_DEV(imgdev), r, img);
|
|
|
|
|
imgdev->action_result = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
@ -185,14 +186,14 @@ void fpi_imgdev_report_finger_status(struct fp_img_dev *imgdev,
|
|
|
|
|
|
|
|
|
|
static void verify_process_img(struct fp_img_dev *imgdev)
|
|
|
|
|
{
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(imgdev->dev->drv);
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(FP_DEV(imgdev)->drv);
|
|
|
|
|
int match_score = imgdrv->bz3_threshold;
|
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
if (match_score == 0)
|
|
|
|
|
match_score = BOZORTH3_DEFAULT_THRESHOLD;
|
|
|
|
|
|
|
|
|
|
r = fpi_img_compare_print_data(imgdev->dev->verify_data,
|
|
|
|
|
r = fpi_img_compare_print_data(FP_DEV(imgdev)->verify_data,
|
|
|
|
|
imgdev->acquire_data);
|
|
|
|
|
|
|
|
|
|
if (r >= match_score)
|
|
|
|
@ -205,7 +206,7 @@ static void verify_process_img(struct fp_img_dev *imgdev)
|
|
|
|
|
|
|
|
|
|
static void identify_process_img(struct fp_img_dev *imgdev)
|
|
|
|
|
{
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(imgdev->dev->drv);
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(FP_DEV(imgdev)->drv);
|
|
|
|
|
int match_score = imgdrv->bz3_threshold;
|
|
|
|
|
size_t match_offset;
|
|
|
|
|
int r;
|
|
|
|
@ -214,7 +215,7 @@ static void identify_process_img(struct fp_img_dev *imgdev)
|
|
|
|
|
match_score = BOZORTH3_DEFAULT_THRESHOLD;
|
|
|
|
|
|
|
|
|
|
r = fpi_img_compare_print_data_to_gallery(imgdev->acquire_data,
|
|
|
|
|
imgdev->dev->identify_gallery, match_score, &match_offset);
|
|
|
|
|
FP_DEV(imgdev)->identify_gallery, match_score, &match_offset);
|
|
|
|
|
|
|
|
|
|
imgdev->action_result = r;
|
|
|
|
|
imgdev->identify_match_offset = match_offset;
|
|
|
|
@ -272,7 +273,7 @@ void fpi_imgdev_image_captured(struct fp_img_dev *imgdev, struct fp_img *img)
|
|
|
|
|
switch (imgdev->action) {
|
|
|
|
|
case IMG_ACTION_ENROLL:
|
|
|
|
|
if (!imgdev->enroll_data) {
|
|
|
|
|
imgdev->enroll_data = fpi_print_data_new(imgdev->dev);
|
|
|
|
|
imgdev->enroll_data = fpi_print_data_new(FP_DEV(imgdev));
|
|
|
|
|
}
|
|
|
|
|
BUG_ON(g_slist_length(print->prints) != 1);
|
|
|
|
|
/* Move print data from acquire data into enroll_data */
|
|
|
|
@ -283,7 +284,7 @@ void fpi_imgdev_image_captured(struct fp_img_dev *imgdev, struct fp_img *img)
|
|
|
|
|
fp_print_data_free(imgdev->acquire_data);
|
|
|
|
|
imgdev->acquire_data = NULL;
|
|
|
|
|
imgdev->enroll_stage++;
|
|
|
|
|
if (imgdev->enroll_stage == imgdev->dev->nr_enroll_stages)
|
|
|
|
|
if (imgdev->enroll_stage == FP_DEV(imgdev)->nr_enroll_stages)
|
|
|
|
|
imgdev->action_result = FP_ENROLL_COMPLETE;
|
|
|
|
|
else
|
|
|
|
|
imgdev->action_result = FP_ENROLL_PASS;
|
|
|
|
@ -313,16 +314,16 @@ void fpi_imgdev_session_error(struct fp_img_dev *imgdev, int error)
|
|
|
|
|
BUG_ON(error == 0);
|
|
|
|
|
switch (imgdev->action) {
|
|
|
|
|
case IMG_ACTION_ENROLL:
|
|
|
|
|
fpi_drvcb_enroll_stage_completed(imgdev->dev, error, NULL, NULL);
|
|
|
|
|
fpi_drvcb_enroll_stage_completed(FP_DEV(imgdev), error, NULL, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_VERIFY:
|
|
|
|
|
fpi_drvcb_report_verify_result(imgdev->dev, error, NULL);
|
|
|
|
|
fpi_drvcb_report_verify_result(FP_DEV(imgdev), error, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_IDENTIFY:
|
|
|
|
|
fpi_drvcb_report_identify_result(imgdev->dev, error, 0, NULL);
|
|
|
|
|
fpi_drvcb_report_identify_result(FP_DEV(imgdev), error, 0, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_CAPTURE:
|
|
|
|
|
fpi_drvcb_report_capture_result(imgdev->dev, error, NULL);
|
|
|
|
|
fpi_drvcb_report_capture_result(FP_DEV(imgdev), error, NULL);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fp_err("unhandled action %d", imgdev->action);
|
|
|
|
@ -336,16 +337,16 @@ void fpi_imgdev_activate_complete(struct fp_img_dev *imgdev, int status)
|
|
|
|
|
|
|
|
|
|
switch (imgdev->action) {
|
|
|
|
|
case IMG_ACTION_ENROLL:
|
|
|
|
|
fpi_drvcb_enroll_started(imgdev->dev, status);
|
|
|
|
|
fpi_drvcb_enroll_started(FP_DEV(imgdev), status);
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_VERIFY:
|
|
|
|
|
fpi_drvcb_verify_started(imgdev->dev, status);
|
|
|
|
|
fpi_drvcb_verify_started(FP_DEV(imgdev), status);
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_IDENTIFY:
|
|
|
|
|
fpi_drvcb_identify_started(imgdev->dev, status);
|
|
|
|
|
fpi_drvcb_identify_started(FP_DEV(imgdev), status);
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_CAPTURE:
|
|
|
|
|
fpi_drvcb_capture_started(imgdev->dev, status);
|
|
|
|
|
fpi_drvcb_capture_started(FP_DEV(imgdev), status);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fp_err("unhandled action %d", imgdev->action);
|
|
|
|
@ -364,16 +365,16 @@ void fpi_imgdev_deactivate_complete(struct fp_img_dev *imgdev)
|
|
|
|
|
|
|
|
|
|
switch (imgdev->action) {
|
|
|
|
|
case IMG_ACTION_ENROLL:
|
|
|
|
|
fpi_drvcb_enroll_stopped(imgdev->dev);
|
|
|
|
|
fpi_drvcb_enroll_stopped(FP_DEV(imgdev));
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_VERIFY:
|
|
|
|
|
fpi_drvcb_verify_stopped(imgdev->dev);
|
|
|
|
|
fpi_drvcb_verify_stopped(FP_DEV(imgdev));
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_IDENTIFY:
|
|
|
|
|
fpi_drvcb_identify_stopped(imgdev->dev);
|
|
|
|
|
fpi_drvcb_identify_stopped(FP_DEV(imgdev));
|
|
|
|
|
break;
|
|
|
|
|
case IMG_ACTION_CAPTURE:
|
|
|
|
|
fpi_drvcb_capture_stopped(imgdev->dev);
|
|
|
|
|
fpi_drvcb_capture_stopped(FP_DEV(imgdev));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fp_err("unhandled action %d", imgdev->action);
|
|
|
|
@ -386,7 +387,7 @@ void fpi_imgdev_deactivate_complete(struct fp_img_dev *imgdev)
|
|
|
|
|
|
|
|
|
|
int fpi_imgdev_get_img_width(struct fp_img_dev *imgdev)
|
|
|
|
|
{
|
|
|
|
|
struct fp_driver *drv = imgdev->dev->drv;
|
|
|
|
|
struct fp_driver *drv = FP_DEV(imgdev)->drv;
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
|
|
|
|
|
int width = imgdrv->img_width;
|
|
|
|
|
|
|
|
|
@ -398,7 +399,7 @@ int fpi_imgdev_get_img_width(struct fp_img_dev *imgdev)
|
|
|
|
|
|
|
|
|
|
int fpi_imgdev_get_img_height(struct fp_img_dev *imgdev)
|
|
|
|
|
{
|
|
|
|
|
struct fp_driver *drv = imgdev->dev->drv;
|
|
|
|
|
struct fp_driver *drv = FP_DEV(imgdev)->drv;
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
|
|
|
|
|
int height = imgdrv->img_height;
|
|
|
|
|
|
|
|
|
@ -410,7 +411,7 @@ int fpi_imgdev_get_img_height(struct fp_img_dev *imgdev)
|
|
|
|
|
|
|
|
|
|
static int dev_activate(struct fp_img_dev *imgdev, enum fp_imgdev_state state)
|
|
|
|
|
{
|
|
|
|
|
struct fp_driver *drv = imgdev->dev->drv;
|
|
|
|
|
struct fp_driver *drv = FP_DEV(imgdev)->drv;
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
|
|
|
|
|
|
|
|
|
|
if (!imgdrv->activate)
|
|
|
|
@ -420,7 +421,7 @@ static int dev_activate(struct fp_img_dev *imgdev, enum fp_imgdev_state state)
|
|
|
|
|
|
|
|
|
|
static void dev_deactivate(struct fp_img_dev *imgdev)
|
|
|
|
|
{
|
|
|
|
|
struct fp_driver *drv = imgdev->dev->drv;
|
|
|
|
|
struct fp_driver *drv = FP_DEV(imgdev)->drv;
|
|
|
|
|
struct fp_img_driver *imgdrv = fpi_driver_to_img_driver(drv);
|
|
|
|
|
|
|
|
|
|
if (!imgdrv->deactivate)
|
|
|
|
@ -430,7 +431,7 @@ static void dev_deactivate(struct fp_img_dev *imgdev)
|
|
|
|
|
|
|
|
|
|
static int generic_acquire_start(struct fp_dev *dev, int action)
|
|
|
|
|
{
|
|
|
|
|
struct fp_img_dev *imgdev = dev->priv;
|
|
|
|
|
struct fp_img_dev *imgdev = dev->img_dev;
|
|
|
|
|
int r;
|
|
|
|
|
fp_dbg("action %d", action);
|
|
|
|
|
imgdev->action = action;
|
|
|
|
@ -484,7 +485,7 @@ static int img_dev_capture_start(struct fp_dev *dev)
|
|
|
|
|
|
|
|
|
|
static int img_dev_enroll_stop(struct fp_dev *dev)
|
|
|
|
|
{
|
|
|
|
|
struct fp_img_dev *imgdev = dev->priv;
|
|
|
|
|
struct fp_img_dev *imgdev = dev->img_dev;
|
|
|
|
|
BUG_ON(imgdev->action != IMG_ACTION_ENROLL);
|
|
|
|
|
generic_acquire_stop(imgdev);
|
|
|
|
|
return 0;
|
|
|
|
@ -492,7 +493,7 @@ static int img_dev_enroll_stop(struct fp_dev *dev)
|
|
|
|
|
|
|
|
|
|
static int img_dev_verify_stop(struct fp_dev *dev, gboolean iterating)
|
|
|
|
|
{
|
|
|
|
|
struct fp_img_dev *imgdev = dev->priv;
|
|
|
|
|
struct fp_img_dev *imgdev = dev->img_dev;
|
|
|
|
|
BUG_ON(imgdev->action != IMG_ACTION_VERIFY);
|
|
|
|
|
generic_acquire_stop(imgdev);
|
|
|
|
|
return 0;
|
|
|
|
@ -500,7 +501,7 @@ static int img_dev_verify_stop(struct fp_dev *dev, gboolean iterating)
|
|
|
|
|
|
|
|
|
|
static int img_dev_identify_stop(struct fp_dev *dev, gboolean iterating)
|
|
|
|
|
{
|
|
|
|
|
struct fp_img_dev *imgdev = dev->priv;
|
|
|
|
|
struct fp_img_dev *imgdev = dev->img_dev;
|
|
|
|
|
BUG_ON(imgdev->action != IMG_ACTION_IDENTIFY);
|
|
|
|
|
generic_acquire_stop(imgdev);
|
|
|
|
|
imgdev->identify_match_offset = 0;
|
|
|
|
@ -509,7 +510,7 @@ static int img_dev_identify_stop(struct fp_dev *dev, gboolean iterating)
|
|
|
|
|
|
|
|
|
|
static int img_dev_capture_stop(struct fp_dev *dev)
|
|
|
|
|
{
|
|
|
|
|
struct fp_img_dev *imgdev = dev->priv;
|
|
|
|
|
struct fp_img_dev *imgdev = dev->img_dev;
|
|
|
|
|
BUG_ON(imgdev->action != IMG_ACTION_CAPTURE);
|
|
|
|
|
generic_acquire_stop(imgdev);
|
|
|
|
|
return 0;
|
|
|
|
|