lib: Make fp_img_dev structure opaque

This commit is contained in:
Bastien Nocera 2018-05-28 16:06:02 +02:00
parent d83d92adf2
commit f40f231a63
23 changed files with 518 additions and 416 deletions

View file

@ -233,7 +233,7 @@ static void finger_det_reqs_cb(struct fp_img_dev *dev, int result, void *user_da
}
data = g_malloc(19);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, 19,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN, data, 19,
finger_det_data_cb, dev, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -247,7 +247,7 @@ static void finger_det_reqs_cb(struct fp_img_dev *dev, int result, void *user_da
static void start_finger_detection(struct fp_img_dev *dev)
{
struct aes1610_dev *aesdev = dev->priv;
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
if (aesdev->deactivating) {
complete_deactivation(dev);
@ -559,7 +559,7 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
unsigned char *stripdata;
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes1610_dev *aesdev = dev->priv;
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
unsigned char *data = transfer->buffer;
int sum, i;
@ -646,7 +646,7 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes1610_dev *aesdev = dev->priv;
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
int r;
switch (fpi_ssm_get_cur_state(ssm)) {
@ -677,7 +677,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
}
data = g_malloc(665);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, 665,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN, data, 665,
capture_read_strip_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -693,7 +693,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes1610_dev *aesdev = dev->priv;
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
if (aesdev->deactivating)
@ -707,7 +707,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
static void start_capture(struct fp_img_dev *dev)
{
struct aes1610_dev *aesdev = dev->priv;
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm;
if (aesdev->deactivating) {
@ -715,7 +715,7 @@ static void start_capture(struct fp_img_dev *dev)
return;
}
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
@ -766,8 +766,8 @@ static void activate_sm_complete(struct fpi_ssm *ssm)
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct aes1610_dev *aesdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
ACTIVATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
aesdev->read_regs_retry_count = 0;
@ -777,7 +777,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
static void dev_deactivate(struct fp_img_dev *dev)
{
struct aes1610_dev *aesdev = dev->priv;
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
/* FIXME: audit cancellation points, probably need more, specifically
* in error handling paths? */
aesdev->deactivating = TRUE;
@ -785,7 +785,7 @@ static void dev_deactivate(struct fp_img_dev *dev)
static void complete_deactivation(struct fp_img_dev *dev)
{
struct aes1610_dev *aesdev = dev->priv;
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
/* FIXME: if we're in the middle of a scan, we should cancel the scan.
@ -803,22 +803,26 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
{
/* FIXME check endpoints */
int r;
struct aes1610_dev *aesdev;
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
dev->priv = g_malloc0(sizeof(struct aes1610_dev));
aesdev = g_malloc0(sizeof(struct aes1610_dev));
fpi_imgdev_set_user_data(dev, aesdev);
fpi_imgdev_open_complete(dev, 0);
return 0;
}
static void dev_deinit(struct fp_img_dev *dev)
{
g_free(dev->priv);
libusb_release_interface(dev->udev, 0);
struct aes1610_dev *aesdev;
aesdev = fpi_imgdev_get_user_data(dev);
g_free(aesdev);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -40,13 +40,14 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
int r;
struct aesX660_dev *aesdev;
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
dev->priv = aesdev = g_malloc0(sizeof(struct aesX660_dev));
aesdev = g_malloc0(sizeof(struct aesX660_dev));
fpi_imgdev_set_user_data(dev, aesdev);
aesdev->buffer = g_malloc0(AES1660_FRAME_SIZE + AESX660_HEADER_SIZE);
aesdev->init_seqs[0] = aes1660_init_1;
aesdev->init_seqs_len[0] = array_n_elements(aes1660_init_1);
@ -63,10 +64,10 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
static void dev_deinit(struct fp_img_dev *dev)
{
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
g_free(aesdev->buffer);
g_free(aesdev);
libusb_release_interface(dev->udev, 0);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -122,7 +122,7 @@ static void read_regs_rq_cb(struct fp_img_dev *dev, int result, void *user_data)
}
data = g_malloc(126);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, 126,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN, data, 126,
read_regs_data_cb, rdata, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -333,7 +333,7 @@ static void finger_det_reqs_cb(struct fp_img_dev *dev, int result,
}
data = g_malloc(20);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, 20,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN, data, 20,
finger_det_data_cb, dev, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -346,7 +346,7 @@ static void finger_det_reqs_cb(struct fp_img_dev *dev, int result,
static void start_finger_detection(struct fp_img_dev *dev)
{
struct aes2501_dev *aesdev = dev->priv;
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
if (aesdev->deactivating) {
@ -438,7 +438,7 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
unsigned char *stripdata;
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2501_dev *aesdev = dev->priv;
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
unsigned char *data = transfer->buffer;
int sum;
int threshold;
@ -523,7 +523,7 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2501_dev *aesdev = dev->priv;
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
int r;
switch (fpi_ssm_get_cur_state(ssm)) {
@ -558,7 +558,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
}
data = g_malloc(1705);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, 1705,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN, data, 1705,
capture_read_strip_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -574,7 +574,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2501_dev *aesdev = dev->priv;
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
if (aesdev->deactivating)
@ -588,7 +588,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
static void start_capture(struct fp_img_dev *dev)
{
struct aes2501_dev *aesdev = dev->priv;
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm;
if (aesdev->deactivating) {
@ -599,7 +599,7 @@ static void start_capture(struct fp_img_dev *dev)
aesdev->no_finger_cnt = 0;
/* Reset gain */
strip_scan_reqs[4].value = AES2501_ADREFHI_MAX_VALUE;
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
@ -714,7 +714,7 @@ void activate_read_regs_cb(struct fp_img_dev *dev, int status,
unsigned char *regs, void *user_data)
{
struct fpi_ssm *ssm = user_data;
struct aes2501_dev *aesdev = dev->priv;
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
if (status != 0) {
fpi_ssm_mark_aborted(ssm, status);
@ -804,8 +804,8 @@ static void activate_sm_complete(struct fpi_ssm *ssm)
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct aes2501_dev *aesdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
ACTIVATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
aesdev->read_regs_retry_count = 0;
@ -815,7 +815,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
static void dev_deactivate(struct fp_img_dev *dev)
{
struct aes2501_dev *aesdev = dev->priv;
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
/* FIXME: audit cancellation points, probably need more, specifically
* in error handling paths? */
aesdev->deactivating = TRUE;
@ -823,7 +823,7 @@ static void dev_deactivate(struct fp_img_dev *dev)
static void complete_deactivation(struct fp_img_dev *dev)
{
struct aes2501_dev *aesdev = dev->priv;
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
/* FIXME: if we're in the middle of a scan, we should cancel the scan.
@ -840,22 +840,25 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
{
/* FIXME check endpoints */
int r;
struct aes2501_dev *aesdev;
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
dev->priv = g_malloc0(sizeof(struct aes2501_dev));
aesdev = g_malloc0(sizeof(struct aes2501_dev));
fpi_imgdev_set_user_data(dev, aesdev);
fpi_imgdev_open_complete(dev, 0);
return 0;
}
static void dev_deinit(struct fp_img_dev *dev)
{
g_free(dev->priv);
libusb_release_interface(dev->udev, 0);
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
g_free(aesdev);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -133,7 +133,7 @@ static void finger_det_reqs_cb(struct libusb_transfer *t)
/* 2 bytes of result */
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, AES2550_EP_IN_BUF_SIZE,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
finger_det_data_cb, dev, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -149,7 +149,7 @@ exit_free_transfer:
static void start_finger_detection(struct fp_img_dev *dev)
{
int r;
struct aes2550_dev *aesdev = dev->priv;
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
struct libusb_transfer *transfer;
G_DEBUG_HERE();
@ -163,7 +163,7 @@ static void start_finger_detection(struct fp_img_dev *dev)
fpi_imgdev_session_error(dev, -ENOMEM);
return;
}
libusb_fill_bulk_transfer(transfer, dev->udev, EP_OUT, finger_det_reqs,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT, finger_det_reqs,
sizeof(finger_det_reqs), finger_det_reqs_cb, dev, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
if (r < 0) {
@ -204,7 +204,7 @@ static int process_strip_data(struct fpi_ssm *ssm, unsigned char *data)
{
unsigned char *stripdata;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
struct fpi_frame *stripe;
int len;
@ -246,7 +246,7 @@ static void capture_set_idle_reqs_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
(transfer->length == transfer->actual_length) &&
@ -274,7 +274,7 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
unsigned char *data = transfer->buffer;
int r;
@ -336,7 +336,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
fpi_ssm_mark_aborted(ssm, -ENOMEM);
return;
}
libusb_fill_bulk_transfer(transfer, dev->udev, EP_OUT, capture_reqs,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT, capture_reqs,
sizeof(capture_reqs), capture_reqs_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
if (r < 0) {
@ -356,7 +356,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
}
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, AES2550_EP_IN_BUF_SIZE,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
capture_read_data_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -374,7 +374,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
fpi_ssm_mark_aborted(ssm, -ENOMEM);
return;
}
libusb_fill_bulk_transfer(transfer, dev->udev, EP_OUT, capture_set_idle_reqs,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT, capture_set_idle_reqs,
sizeof(capture_set_idle_reqs), capture_set_idle_reqs_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
if (r < 0) {
@ -389,7 +389,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
fp_dbg("Capture completed");
if (aesdev->deactivating)
@ -403,7 +403,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
static void start_capture(struct fp_img_dev *dev)
{
struct aes2550_dev *aesdev = dev->priv;
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm;
if (aesdev->deactivating) {
@ -412,7 +412,7 @@ static void start_capture(struct fp_img_dev *dev)
}
aesdev->heartbeat_cnt = 0;
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
@ -496,7 +496,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
fpi_ssm_mark_aborted(ssm, -ENOMEM);
return;
}
libusb_fill_bulk_transfer(transfer, dev->udev, EP_OUT, init_reqs,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT, init_reqs,
sizeof(init_reqs), init_reqs_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
if (r < 0) {
@ -516,7 +516,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
}
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, AES2550_EP_IN_BUF_SIZE,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
init_read_data_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -534,7 +534,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
fpi_ssm_mark_aborted(ssm, -ENOMEM);
return;
}
libusb_fill_bulk_transfer(transfer, dev->udev, EP_OUT, calibrate_reqs,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT, calibrate_reqs,
sizeof(calibrate_reqs), init_reqs_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
if (r < 0) {
@ -554,7 +554,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
}
data = g_malloc(AES2550_EP_IN_BUF_SIZE);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, AES2550_EP_IN_BUF_SIZE,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN, data, AES2550_EP_IN_BUF_SIZE,
calibrate_read_data_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -581,7 +581,7 @@ static void activate_sm_complete(struct fpi_ssm *ssm)
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
ACTIVATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_sm_complete);
@ -590,14 +590,14 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
static void dev_deactivate(struct fp_img_dev *dev)
{
struct aes2550_dev *aesdev = dev->priv;
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
aesdev->deactivating = TRUE;
}
static void complete_deactivation(struct fp_img_dev *dev)
{
struct aes2550_dev *aesdev = dev->priv;
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
aesdev->deactivating = FALSE;
@ -611,22 +611,26 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
{
/* TODO check that device has endpoints we're using */
int r;
struct aes2550_dev *aes2550_dev;
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
dev->priv = g_malloc0(sizeof(struct aes2550_dev));
aes2550_dev = g_malloc0(sizeof(struct aes2550_dev));
fpi_imgdev_set_user_data(dev, aes2550_dev);
fpi_imgdev_open_complete(dev, 0);
return 0;
}
static void dev_deinit(struct fp_img_dev *dev)
{
g_free(dev->priv);
libusb_release_interface(dev->udev, 0);
struct aes2550_dev *aesdev;
aesdev = fpi_imgdev_get_user_data(dev);
g_free(aesdev);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -40,13 +40,14 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
int r;
struct aesX660_dev *aesdev;
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
dev->priv = aesdev = g_malloc0(sizeof(struct aesX660_dev));
aesdev = g_malloc0(sizeof(struct aesX660_dev));
fpi_imgdev_set_user_data(dev, aesdev);
aesdev->buffer = g_malloc0(AES2660_FRAME_SIZE + AESX660_HEADER_SIZE);
/* No scaling for AES2660 */
aesdev->init_seqs[0] = aes2660_init_1;
@ -64,10 +65,11 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
static void dev_deinit(struct fp_img_dev *dev)
{
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev;
aesdev = fpi_imgdev_get_user_data(dev);
g_free(aesdev->buffer);
g_free(aesdev);
libusb_release_interface(dev->udev, 0);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -122,13 +122,14 @@ 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);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
aesdev = dev->priv = g_malloc0(sizeof(struct aes3k_dev));
aesdev = g_malloc0(sizeof(struct aes3k_dev));
fpi_imgdev_set_user_data(dev, aesdev);
if (!aesdev)
return -ENOMEM;
@ -147,9 +148,9 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
static void dev_deinit(struct fp_img_dev *dev)
{
struct aes3k_dev *aesdev = dev->priv;
struct aes3k_dev *aesdev = fpi_imgdev_get_user_data(dev);
g_free(aesdev);
libusb_release_interface(dev->udev, 0);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -63,7 +63,7 @@ static void aes3k_assemble_image(unsigned char *input, size_t width, size_t heig
static void img_cb(struct libusb_transfer *transfer)
{
struct fp_img_dev *dev = transfer->user_data;
struct aes3k_dev *aesdev = dev->priv;
struct aes3k_dev *aesdev = fpi_imgdev_get_user_data(dev);
unsigned char *ptr = transfer->buffer;
struct fp_img *tmp;
struct fp_img *img;
@ -112,7 +112,7 @@ err:
static void do_capture(struct fp_img_dev *dev)
{
struct aes3k_dev *aesdev = dev->priv;
struct aes3k_dev *aesdev = fpi_imgdev_get_user_data(dev);
unsigned char *data;
int r;
@ -123,7 +123,7 @@ static void do_capture(struct fp_img_dev *dev)
}
data = g_malloc(aesdev->data_buflen);
libusb_fill_bulk_transfer(aesdev->img_trf, dev->udev, EP_IN, data,
libusb_fill_bulk_transfer(aesdev->img_trf, fpi_imgdev_get_usb_dev(dev), EP_IN, data,
aesdev->data_buflen, img_cb, dev, 0);
r = libusb_submit_transfer(aesdev->img_trf);
@ -144,14 +144,14 @@ static void init_reqs_cb(struct fp_img_dev *dev, int result, void *user_data)
int aes3k_dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct aes3k_dev *aesdev = dev->priv;
struct aes3k_dev *aesdev = fpi_imgdev_get_user_data(dev);
aes_write_regv(dev, aesdev->init_reqs, aesdev->init_reqs_len, init_reqs_cb, NULL);
return 0;
}
void aes3k_dev_deactivate(struct fp_img_dev *dev)
{
struct aes3k_dev *aesdev = dev->priv;
struct aes3k_dev *aesdev = fpi_imgdev_get_user_data(dev);
/* FIXME: should wait for cancellation to complete before returning
* from deactivation, otherwise app may legally exit before we've

View file

@ -119,13 +119,14 @@ 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);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
aesdev = dev->priv = g_malloc0(sizeof(struct aes3k_dev));
aesdev = g_malloc0(sizeof(struct aes3k_dev));
fpi_imgdev_set_user_data(dev, aesdev);
if (!aesdev)
return -ENOMEM;
@ -144,9 +145,9 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
static void dev_deinit(struct fp_img_dev *dev)
{
struct aes3k_dev *aesdev = dev->priv;
struct aes3k_dev *aesdev = fpi_imgdev_get_user_data(dev);
g_free(aesdev);
libusb_release_interface(dev->udev, 0);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -49,7 +49,7 @@ static void aesX660_send_cmd_timeout(struct fpi_ssm *ssm, const unsigned char *c
return;
}
libusb_fill_bulk_transfer(transfer, dev->udev, EP_OUT,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT,
(unsigned char *)cmd, cmd_len,
callback, ssm, timeout);
r = libusb_submit_transfer(transfer);
@ -80,7 +80,7 @@ static void aesX660_read_response(struct fpi_ssm *ssm, size_t buf_len,
}
data = g_malloc(buf_len);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN,
data, buf_len,
callback, ssm, BULK_TIMEOUT);
@ -145,7 +145,7 @@ static void finger_det_read_fd_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
unsigned char *data = transfer->buffer;
aesdev->fd_data_transfer = NULL;
@ -198,7 +198,7 @@ static void finger_det_set_idle_cmd_cb(struct libusb_transfer *transfer)
static void finger_det_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
int err = fpi_ssm_get_error(ssm);
fp_dbg("Finger detection completed");
@ -240,14 +240,14 @@ static void finger_det_run_state(struct fpi_ssm *ssm)
static void start_finger_detection(struct fp_img_dev *dev)
{
struct fpi_ssm *ssm;
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
if (aesdev->deactivating) {
complete_deactivation(dev);
return;
}
ssm = fpi_ssm_new(dev->dev, finger_det_run_state, FINGER_DET_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), finger_det_run_state, FINGER_DET_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, finger_det_sm_complete);
}
@ -268,7 +268,7 @@ static int process_stripe_data(struct fpi_ssm *ssm, unsigned char *data)
struct fpi_frame *stripe;
unsigned char *stripdata;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
stripe = g_malloc(aesdev->assembling_ctx->frame_width * FRAME_HEIGHT / 2 + sizeof(struct fpi_frame)); /* 4 bpp */
stripdata = stripe->data;
@ -296,7 +296,7 @@ static void capture_set_idle_cmd_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
(transfer->length == transfer->actual_length)) {
@ -322,7 +322,7 @@ static void capture_read_stripe_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
unsigned char *data = transfer->buffer;
int finger_missing = 0;
size_t copied, actual_len = transfer->actual_length;
@ -374,7 +374,7 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_SEND_LED_CMD:
@ -403,7 +403,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
int err = fpi_ssm_get_error(ssm);
fp_dbg("Capture completed");
@ -419,7 +419,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
static void start_capture(struct fp_img_dev *dev)
{
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm;
if (aesdev->deactivating) {
@ -427,7 +427,7 @@ static void start_capture(struct fp_img_dev *dev)
return;
}
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
@ -450,7 +450,7 @@ static void activate_read_id_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
unsigned char *data = transfer->buffer;
if ((transfer->status != LIBUSB_TRANSFER_COMPLETED) ||
@ -501,7 +501,7 @@ static void activate_read_init_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
unsigned char *data = transfer->buffer;
fp_dbg("read_init_cb\n");
@ -537,7 +537,7 @@ out:
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case ACTIVATE_SET_IDLE:
@ -594,7 +594,7 @@ static void activate_sm_complete(struct fpi_ssm *ssm)
int aesX660_dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
ACTIVATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_sm_complete);
@ -603,7 +603,7 @@ int aesX660_dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
void aesX660_dev_deactivate(struct fp_img_dev *dev)
{
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
if (aesdev->fd_data_transfer)
libusb_cancel_transfer(aesdev->fd_data_transfer);
@ -613,7 +613,7 @@ void aesX660_dev_deactivate(struct fp_img_dev *dev)
static void complete_deactivation(struct fp_img_dev *dev)
{
struct aesX660_dev *aesdev = dev->priv;
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
aesdev->deactivating = FALSE;

View file

@ -76,7 +76,7 @@ static void elan_dev_reset(struct elan_dev *elandev)
static void elan_save_frame(struct fp_img_dev *dev)
{
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
unsigned char raw_height = elandev->frame_width;
unsigned char raw_width = elandev->raw_frame_width;
unsigned short *frame =
@ -137,7 +137,7 @@ static void elan_process_frame(unsigned short *raw_frame, GSList ** frames)
static void elan_submit_image(struct fp_img_dev *dev)
{
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
GSList *frames = NULL;
struct fp_img *img;
@ -162,7 +162,7 @@ static void elan_submit_image(struct fp_img_dev *dev)
static void elan_cmd_done(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
@ -177,7 +177,7 @@ static void elan_cmd_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
@ -219,7 +219,7 @@ static void elan_cmd_cb(struct libusb_transfer *transfer)
static void elan_cmd_read(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
int response_len = elandev->cmds[elandev->cmd_idx].response_len;
G_DEBUG_HERE();
@ -239,7 +239,7 @@ static void elan_cmd_read(struct fpi_ssm *ssm)
g_free(elandev->last_read);
elandev->last_read = g_malloc(response_len);
libusb_fill_bulk_transfer(transfer, dev->udev,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev),
elandev->cmds[elandev->cmd_idx].response_in,
elandev->last_read, response_len, elan_cmd_cb,
ssm, elandev->cmd_timeout);
@ -252,7 +252,7 @@ static void elan_cmd_read(struct fpi_ssm *ssm)
static void elan_run_next_cmd(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
@ -263,7 +263,7 @@ static void elan_run_next_cmd(struct fpi_ssm *ssm)
}
elandev->cur_transfer = transfer;
libusb_fill_bulk_transfer(transfer, dev->udev, ELAN_EP_CMD_OUT,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), ELAN_EP_CMD_OUT,
(unsigned char *)elandev->cmds[elandev->
cmd_idx].cmd,
ELAN_CMD_LEN, elan_cmd_cb, ssm,
@ -279,7 +279,7 @@ static void elan_run_cmds(struct fpi_ssm *ssm, const struct elan_cmd *cmds,
size_t cmds_len, int cmd_timeout)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
@ -315,13 +315,13 @@ static void deactivate_complete(struct fpi_ssm *ssm)
static void elan_deactivate(struct fp_img_dev *dev)
{
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
elan_dev_reset(elandev);
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, elan_deactivate_run_state,
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), elan_deactivate_run_state,
DEACTIVATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, deactivate_complete);
@ -338,7 +338,7 @@ enum capture_states {
static void elan_capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_START:
@ -378,7 +378,7 @@ static void elan_capture_async(void *data)
static void capture_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
@ -406,7 +406,7 @@ static void capture_complete(struct fpi_ssm *ssm)
* completed, so we need to keep feeding it images till it's had enough.
* But after that it can't finalize enrollemnt until this callback exits.
* That's why we schedule elan_capture instead of running it directly. */
if (fpi_dev_get_dev_state(dev->dev) == DEV_STATE_ENROLLING
if (fpi_dev_get_dev_state(fpi_imgdev_get_dev(dev)) == DEV_STATE_ENROLLING
&& !fpi_timeout_add(10, elan_capture_async, dev))
fpi_imgdev_session_error(dev, -ETIME);
@ -415,13 +415,13 @@ static void capture_complete(struct fpi_ssm *ssm)
static void elan_capture(struct fp_img_dev *dev)
{
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
elan_dev_reset(elandev);
struct fpi_ssm *ssm =
fpi_ssm_new(dev->dev, elan_capture_run_state, CAPTURE_NUM_STATES);
fpi_ssm_new(fpi_imgdev_get_dev(dev), elan_capture_run_state, CAPTURE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_complete);
}
@ -458,7 +458,7 @@ static void elan_calibrate_run_state(struct fpi_ssm *ssm)
static void calibrate_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
@ -475,12 +475,12 @@ static void calibrate_complete(struct fpi_ssm *ssm)
static void elan_calibrate(struct fp_img_dev *dev)
{
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
elan_dev_reset(elandev);
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, elan_calibrate_run_state,
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), elan_calibrate_run_state,
CALIBRATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, calibrate_complete);
@ -498,7 +498,7 @@ enum activate_states {
static void elan_activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case ACTIVATE_GET_SENSOR_DIM:
@ -528,7 +528,7 @@ static void elan_activate_run_state(struct fpi_ssm *ssm)
static void activate_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
@ -543,13 +543,13 @@ static void activate_complete(struct fpi_ssm *ssm)
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
elan_dev_reset(elandev);
struct fpi_ssm *ssm =
fpi_ssm_new(dev->dev, elan_activate_run_state, ACTIVATE_NUM_STATES);
fpi_ssm_new(fpi_imgdev_get_dev(dev), elan_activate_run_state, ACTIVATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_complete);
@ -563,32 +563,33 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
G_DEBUG_HERE();
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
dev->priv = elandev = g_malloc0(sizeof(struct elan_dev));
elandev = g_malloc0(sizeof(struct elan_dev));
fpi_imgdev_set_user_data(dev, elandev);
fpi_imgdev_open_complete(dev, 0);
return 0;
}
static void dev_deinit(struct fp_img_dev *dev)
{
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
elan_dev_reset(elandev);
g_free(elandev);
libusb_release_interface(dev->udev, 0);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}
static void dev_deactivate(struct fp_img_dev *dev)
{
struct elan_dev *elandev = dev->priv;
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();

View file

@ -639,7 +639,7 @@ enum {
static int async_tx(struct fp_img_dev *idev, unsigned int ep, void *cb,
void *cb_arg)
{
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *buffer;
int length;
@ -656,7 +656,7 @@ static int async_tx(struct fp_img_dev *idev, unsigned int ep, void *cb,
} else {
return -EIO;
}
libusb_fill_bulk_transfer(transfer, idev->udev, ep, buffer, length,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(idev), ep, buffer, length,
cb, cb_arg, BULK_TIMEOUT);
if (libusb_submit_transfer(transfer)) {
@ -671,7 +671,7 @@ static void async_tx_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fp_warn("transfer is not completed (status=%d)",
@ -702,7 +702,7 @@ static void async_tx_cb(struct libusb_transfer *transfer)
static void m_exit_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
switch (fpi_ssm_get_cur_state(ssm)) {
case EXIT_SET_REGS_REQ:
@ -742,7 +742,7 @@ static void m_exit_complete(struct fpi_ssm *ssm)
static void m_exit_start(struct fp_img_dev *idev)
{
struct fpi_ssm *ssm = fpi_ssm_new(idev->dev, m_exit_state,
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_exit_state,
EXIT_NUM_STATES);
fp_dbg("Switching device to idle mode");
fpi_ssm_set_user_data(ssm, idev);
@ -752,7 +752,7 @@ static void m_exit_start(struct fp_img_dev *idev)
static void m_capture_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
if (dev->is_active == FALSE) {
fpi_ssm_mark_completed(ssm);
@ -833,10 +833,10 @@ err:
static void m_capture_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
if (fpi_ssm_get_error(ssm)) {
if (idev->action_state != IMG_ACQUIRE_STATE_DEACTIVATING) {
if (fpi_imgdev_get_action_state(idev) != IMG_ACQUIRE_STATE_DEACTIVATING) {
fp_err("Error while capturing fingerprint "
"(fpi_ssm_get_error(ssm)=%d)", fpi_ssm_get_error(ssm));
fpi_imgdev_session_error(idev, fpi_ssm_get_error(ssm));
@ -855,7 +855,7 @@ static void m_capture_complete(struct fpi_ssm *ssm)
static void m_finger_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
if (dev->is_active == FALSE) {
fpi_ssm_mark_completed(ssm);
@ -951,16 +951,16 @@ err:
static void m_finger_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
if (!fpi_ssm_get_error(ssm)) {
struct fpi_ssm *ssm_cap;
ssm_cap = fpi_ssm_new(idev->dev, m_capture_state,
ssm_cap = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_capture_state,
CAP_NUM_STATES);
fpi_ssm_set_user_data(ssm_cap, idev);
fpi_ssm_start(ssm_cap, m_capture_complete);
} else {
if (idev->action_state != IMG_ACQUIRE_STATE_DEACTIVATING) {
if (fpi_imgdev_get_action_state(idev) != IMG_ACQUIRE_STATE_DEACTIVATING) {
fp_err("Error while capturing fingerprint "
"(fpi_ssm_get_error(ssm)=%d)", fpi_ssm_get_error(ssm));
fpi_imgdev_session_error(idev, -4);
@ -974,7 +974,7 @@ static void m_finger_complete(struct fpi_ssm *ssm)
static void m_start_fingerdetect(struct fp_img_dev *idev)
{
struct fpi_ssm *ssmf;
ssmf = fpi_ssm_new(idev->dev, m_finger_state, FGR_NUM_STATES);
ssmf = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_finger_state, FGR_NUM_STATES);
fpi_ssm_set_user_data(ssmf, idev);
fpi_ssm_start(ssmf, m_finger_complete);
}
@ -985,7 +985,7 @@ static void m_start_fingerdetect(struct fp_img_dev *idev)
static void m_tunevrb_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
float hist[5];
if (dev->is_active == FALSE) {
@ -1143,7 +1143,7 @@ static void m_tunevrb_complete(struct fpi_ssm *ssm)
fp_dbg("Tuning is done. Starting finger detection.");
m_start_fingerdetect(idev);
} else {
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
fp_err("Error while tuning VRT");
dev->is_active = FALSE;
reset_param(dev);
@ -1159,7 +1159,7 @@ static void m_tunevrb_complete(struct fpi_ssm *ssm)
static void m_tunedc_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
if (dev->is_active == FALSE) {
fpi_ssm_mark_completed(ssm);
@ -1264,12 +1264,12 @@ static void m_tunedc_complete(struct fpi_ssm *ssm)
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
if (!fpi_ssm_get_error(ssm)) {
struct fpi_ssm *ssm_tune;
ssm_tune = fpi_ssm_new(idev->dev, m_tunevrb_state,
ssm_tune = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_tunevrb_state,
TUNEVRB_NUM_STATES);
fpi_ssm_set_user_data(ssm_tune, idev);
fpi_ssm_start(ssm_tune, m_tunevrb_complete);
} else {
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
fp_err("Error while tuning DCOFFSET");
dev->is_active = FALSE;
reset_param(dev);
@ -1281,7 +1281,7 @@ static void m_tunedc_complete(struct fpi_ssm *ssm)
static void m_init_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
if (dev->is_active == FALSE) {
fpi_ssm_mark_completed(ssm);
@ -1384,12 +1384,12 @@ static void m_init_complete(struct fpi_ssm *ssm)
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
if (!fpi_ssm_get_error(ssm)) {
struct fpi_ssm *ssm_tune;
ssm_tune = fpi_ssm_new(idev->dev, m_tunedc_state,
ssm_tune = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_tunedc_state,
TUNEDC_NUM_STATES);
fpi_ssm_set_user_data(ssm_tune, idev);
fpi_ssm_start(ssm_tune, m_tunedc_complete);
} else {
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
fp_err("Error initializing the device");
dev->is_active = FALSE;
reset_param(dev);
@ -1400,7 +1400,7 @@ static void m_init_complete(struct fpi_ssm *ssm)
static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
{
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
struct fpi_ssm *ssm;
g_assert(dev);
@ -1416,7 +1416,7 @@ static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
if (dev->dcoffset == 0) {
fp_dbg("Tuning device...");
ssm = fpi_ssm_new(idev->dev, m_init_state, INIT_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_init_state, INIT_NUM_STATES);
fpi_ssm_set_user_data(ssm, idev);
fpi_ssm_start(ssm, m_init_complete);
} else {
@ -1424,7 +1424,7 @@ static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
"VRB=0x%02X,GAIN=0x%02X).", dev->dcoffset, dev->vrt,
dev->vrb, dev->gain);
fpi_imgdev_activate_complete(idev, 0);
ssm = fpi_ssm_new(idev->dev, m_finger_state, FGR_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_finger_state, FGR_NUM_STATES);
fpi_ssm_set_user_data(ssm, idev);
fpi_ssm_start(ssm, m_finger_complete);
}
@ -1433,7 +1433,7 @@ static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
static void dev_deactivate(struct fp_img_dev *idev)
{
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
fp_dbg("deactivating");
@ -1450,13 +1450,13 @@ static int dev_open(struct fp_img_dev *idev, unsigned long driver_data)
struct etes603_dev *dev;
dev = g_malloc0(sizeof(struct etes603_dev));
idev->priv = dev;
fpi_imgdev_set_user_data(idev, dev);
dev->req = g_malloc(sizeof(struct egis_msg));
dev->ans = g_malloc(FE_SIZE);
dev->fp = g_malloc(FE_SIZE * 4);
ret = libusb_claim_interface(idev->udev, 0);
ret = libusb_claim_interface(fpi_imgdev_get_usb_dev(idev), 0);
if (ret != LIBUSB_SUCCESS) {
fp_err("libusb_claim_interface failed on interface 0: %s", libusb_error_name(ret));
return ret;
@ -1468,14 +1468,14 @@ static int dev_open(struct fp_img_dev *idev, unsigned long driver_data)
static void dev_close(struct fp_img_dev *idev)
{
struct etes603_dev *dev = idev->priv;
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
g_free(dev->req);
g_free(dev->ans);
g_free(dev->fp);
g_free(dev);
libusb_release_interface(idev->udev, 0);
libusb_release_interface(fpi_imgdev_get_usb_dev(idev), 0);
fpi_imgdev_close_complete(idev);
}

View file

@ -169,25 +169,25 @@ capture(struct fp_img_dev *dev, gboolean unconditional,
image = g_malloc0(RAW_IMAGE_SIZE);
if ((r = bulk_write_safe(dev->udev, LED_ON))) {
if ((r = bulk_write_safe(fpi_imgdev_get_usb_dev(dev), LED_ON))) {
fp_err("Command: LED_ON");
goto out;
}
if ((r = bulk_write_safe(dev->udev, CAPTURE_READY))) {
if ((r = bulk_write_safe(fpi_imgdev_get_usb_dev(dev), CAPTURE_READY))) {
fp_err("Command: CAPTURE_READY");
goto out;
}
read:
if ((r = bulk_write_safe(dev->udev, CAPTURE_READ))) {
if ((r = bulk_write_safe(fpi_imgdev_get_usb_dev(dev), CAPTURE_READ))) {
fp_err("Command: CAPTURE_READ");
goto out;
}
/* Now we are ready to read from dev */
r = libusb_bulk_transfer(dev->udev, &msg, &bytes, BULK_TIMEOUT * 10);
r = libusb_bulk_transfer(fpi_imgdev_get_usb_dev(dev), &msg, &bytes, BULK_TIMEOUT * 10);
if (r < 0 || bytes < 1)
goto read;
@ -228,12 +228,12 @@ read:
}
}
if ((r = bulk_write_safe(dev->udev, CAPTURE_END))) {
if ((r = bulk_write_safe(fpi_imgdev_get_usb_dev(dev), CAPTURE_END))) {
fp_err("Command: CAPTURE_END");
goto out;
}
if ((r = bulk_write_safe(dev->udev, LED_OFF))) {
if ((r = bulk_write_safe(fpi_imgdev_get_usb_dev(dev), LED_OFF))) {
fp_err("Command: LED_OFF");
goto out;
}
@ -254,27 +254,27 @@ static
gint dev_init(struct fp_img_dev *dev, unsigned long driver_data)
{
gint r;
//if ( (r = usb_set_configuration(dev->udev, 1)) < 0 )
//if ( (r = usb_set_configuration(fpi_imgdev_get_usb_dev(dev), 1)) < 0 )
// goto out;
if ( (r = libusb_claim_interface(dev->udev, 0)) < 0 ) {
if ( (r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0)) < 0 ) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
//if ( (r = usb_set_altinterface(dev->udev, 1)) < 0 )
//if ( (r = usb_set_altinterface(fpi_imgdev_get_usb_dev(dev), 1)) < 0 )
// goto out;
//if ( (r = usb_clear_halt(dev->udev, EP_CMD)) < 0 )
//if ( (r = usb_clear_halt(fpi_imgdev_get_usb_dev(dev), EP_CMD)) < 0 )
// goto out;
/* Make sure sensor mode is not capture_{ready|read} */
if ((r = bulk_write_safe(dev->udev, CAPTURE_END))) {
if ((r = bulk_write_safe(fpi_imgdev_get_usb_dev(dev), CAPTURE_END))) {
fp_err("Command: CAPTURE_END");
goto out;
}
if ((r = bulk_write_safe(dev->udev, LED_OFF))) {
if ((r = bulk_write_safe(fpi_imgdev_get_usb_dev(dev), LED_OFF))) {
fp_err("Command: LED_OFF");
goto out;
}
@ -289,10 +289,10 @@ out:
static
void dev_exit(struct fp_img_dev *dev)
{
if (bulk_write_safe(dev->udev, CAPTURE_END))
if (bulk_write_safe(fpi_imgdev_get_usb_dev(dev), CAPTURE_END))
fp_err("Command: CAPTURE_END");
libusb_release_interface(dev->udev, 0);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
}
static const struct usb_id id_table[] = {

View file

@ -176,7 +176,7 @@ static void free_img_transfers(struct sonly_dev *sdev)
static void last_transfer_killed(struct fp_img_dev *dev)
{
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
switch (sdev->killing_transfers) {
case ABORT_SSM:
fp_dbg("abort ssm error %d", sdev->kill_status_code);
@ -197,7 +197,7 @@ static void last_transfer_killed(struct fp_img_dev *dev)
static void cancel_img_transfers(struct fp_img_dev *dev)
{
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
int i;
if (sdev->num_flying == 0) {
@ -224,7 +224,7 @@ static gboolean is_capturing(struct sonly_dev *sdev)
static void handoff_img(struct fp_img_dev *dev)
{
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
struct fp_img *img;
GSList *elem = sdev->rows;
@ -252,7 +252,7 @@ static void handoff_img(struct fp_img_dev *dev)
static void row_complete(struct fp_img_dev *dev)
{
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
sdev->rowbuf_offset = -1;
if (sdev->num_rows > 0) {
@ -340,7 +340,7 @@ static void row_complete(struct fp_img_dev *dev)
/* add data to row buffer */
static void add_to_rowbuf(struct fp_img_dev *dev, unsigned char *data, int size)
{
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
memcpy(sdev->rowbuf + sdev->rowbuf_offset, data, size);
sdev->rowbuf_offset += size;
@ -374,7 +374,7 @@ static int rowbuf_remaining(struct sonly_dev *sdev)
static void handle_packet(struct fp_img_dev *dev, unsigned char *data)
{
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
uint16_t seqnum = data[0] << 8 | data[1];
int abs_base_addr;
int for_rowbuf;
@ -470,7 +470,7 @@ static void img_data_cb(struct libusb_transfer *transfer)
{
struct img_transfer_data *idata = transfer->user_data;
struct fp_img_dev *dev = idata->dev;
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
int i;
idata->flying = FALSE;
@ -629,7 +629,8 @@ static void sm_write_reg(struct fpi_ssm *ssm, uint8_t reg, uint8_t value)
fp_dbg("set %02x=%02x", reg, value);
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
libusb_fill_control_setup(data, 0x40, 0x0c, 0, reg, 1);
libusb_fill_control_transfer(transfer, dev->udev, data, sm_write_reg_cb,
libusb_fill_control_transfer(transfer, fpi_imgdev_get_usb_dev(dev),
data, sm_write_reg_cb,
ssm, CTRL_TIMEOUT);
data[LIBUSB_CONTROL_SETUP_SIZE] = value;
@ -648,7 +649,7 @@ static void sm_read_reg_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fpi_ssm_mark_aborted(ssm, -EIO);
@ -676,7 +677,8 @@ static void sm_read_reg(struct fpi_ssm *ssm, uint8_t reg)
fp_dbg("read reg %02x", reg);
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 8);
libusb_fill_control_setup(data, 0xc0, 0x0c, 0, reg, 8);
libusb_fill_control_transfer(transfer, dev->udev, data, sm_read_reg_cb,
libusb_fill_control_transfer(transfer, fpi_imgdev_get_usb_dev(dev),
data, sm_read_reg_cb,
ssm, CTRL_TIMEOUT);
transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK |
LIBUSB_TRANSFER_FREE_TRANSFER;
@ -693,7 +695,7 @@ static void sm_await_intr_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
g_free(transfer->buffer);
@ -725,7 +727,8 @@ static void sm_await_intr(struct fpi_ssm *ssm)
G_DEBUG_HERE();
data = g_malloc(4);
libusb_fill_interrupt_transfer(transfer, dev->udev, 0x83, data, 4,
libusb_fill_interrupt_transfer(transfer, fpi_imgdev_get_usb_dev(dev),
0x83, data, 4,
sm_await_intr_cb, ssm, 0);
transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK |
LIBUSB_TRANSFER_FREE_TRANSFER;
@ -763,7 +766,7 @@ enum awfsm_1000_states {
static void awfsm_2016_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case AWFSM_2016_WRITEV_1:
@ -851,7 +854,7 @@ enum capsm_1001_states {
static void capsm_fire_bulk(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
int i;
for (i = 0; i < NUM_BULK_TRANSFERS; i++) {
int r = libusb_submit_transfer(sdev->img_transfer[i]);
@ -881,7 +884,7 @@ static void capsm_fire_bulk(struct fpi_ssm *ssm)
static void capsm_2016_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPSM_2016_INIT:
@ -913,7 +916,7 @@ static void capsm_2016_run_state(struct fpi_ssm *ssm)
static void capsm_1000_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPSM_1000_INIT:
@ -939,7 +942,7 @@ static void capsm_1000_run_state(struct fpi_ssm *ssm)
static void capsm_1001_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPSM_1001_INIT:
@ -1048,7 +1051,7 @@ enum initsm_1001_states {
static void initsm_2016_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case INITSM_2016_WRITEV_1:
@ -1120,7 +1123,7 @@ enum loopsm_states {
static void loopsm_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case LOOPSM_RUN_AWFSM: ;
@ -1139,11 +1142,11 @@ static void loopsm_run_state(struct fpi_ssm *ssm)
struct fpi_ssm *awfsm = NULL;
switch (sdev->dev_model) {
case UPEKSONLY_2016:
awfsm = fpi_ssm_new(dev->dev, awfsm_2016_run_state,
awfsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), awfsm_2016_run_state,
AWFSM_2016_NUM_STATES);
break;
case UPEKSONLY_1000:
awfsm = fpi_ssm_new(dev->dev, awfsm_1000_run_state,
awfsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), awfsm_1000_run_state,
AWFSM_1000_NUM_STATES);
break;
}
@ -1167,15 +1170,15 @@ static void loopsm_run_state(struct fpi_ssm *ssm)
struct fpi_ssm *capsm = NULL;
switch (sdev->dev_model) {
case UPEKSONLY_2016:
capsm = fpi_ssm_new(dev->dev, capsm_2016_run_state,
capsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), capsm_2016_run_state,
CAPSM_2016_NUM_STATES);
break;
case UPEKSONLY_1000:
capsm = fpi_ssm_new(dev->dev, capsm_1000_run_state,
capsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), capsm_1000_run_state,
CAPSM_1000_NUM_STATES);
break;
case UPEKSONLY_1001:
capsm = fpi_ssm_new(dev->dev, capsm_1001_run_state,
capsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), capsm_1001_run_state,
CAPSM_1001_NUM_STATES);
break;
}
@ -1188,15 +1191,15 @@ static void loopsm_run_state(struct fpi_ssm *ssm)
struct fpi_ssm *deinitsm = NULL;
switch (sdev->dev_model) {
case UPEKSONLY_2016:
deinitsm = fpi_ssm_new(dev->dev, deinitsm_2016_run_state,
deinitsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), deinitsm_2016_run_state,
DEINITSM_2016_NUM_STATES);
break;
case UPEKSONLY_1000:
deinitsm = fpi_ssm_new(dev->dev, deinitsm_1000_run_state,
deinitsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), deinitsm_1000_run_state,
DEINITSM_1000_NUM_STATES);
break;
case UPEKSONLY_1001:
deinitsm = fpi_ssm_new(dev->dev, deinitsm_1001_run_state,
deinitsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), deinitsm_1001_run_state,
DEINITSM_1001_NUM_STATES);
break;
}
@ -1215,7 +1218,7 @@ static void loopsm_run_state(struct fpi_ssm *ssm)
static void deactivate_done(struct fp_img_dev *dev)
{
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
free_img_transfers(sdev);
@ -1232,7 +1235,7 @@ static void deactivate_done(struct fp_img_dev *dev)
static void dev_deactivate(struct fp_img_dev *dev)
{
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
if (!sdev->capturing) {
deactivate_done(dev);
@ -1248,7 +1251,7 @@ static void dev_deactivate(struct fp_img_dev *dev)
static void loopsm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
int r = fpi_ssm_get_error(ssm);
fpi_ssm_free(ssm);
@ -1267,7 +1270,7 @@ static void loopsm_complete(struct fpi_ssm *ssm)
static void initsm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
int r = fpi_ssm_get_error(ssm);
fpi_ssm_free(ssm);
@ -1275,14 +1278,14 @@ static void initsm_complete(struct fpi_ssm *ssm)
if (r != 0)
return;
sdev->loopsm = fpi_ssm_new(dev->dev, loopsm_run_state, LOOPSM_NUM_STATES);
sdev->loopsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), loopsm_run_state, LOOPSM_NUM_STATES);
fpi_ssm_set_user_data(sdev->loopsm, dev);
fpi_ssm_start(sdev->loopsm, loopsm_complete);
}
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct sonly_dev *sdev = dev->priv;
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm = NULL;
int i;
@ -1304,19 +1307,20 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
sdev->img_transfer_data[i].idx = i;
sdev->img_transfer_data[i].dev = dev;
data = g_malloc(4096);
libusb_fill_bulk_transfer(sdev->img_transfer[i], dev->udev, 0x81, data,
libusb_fill_bulk_transfer(sdev->img_transfer[i], fpi_imgdev_get_usb_dev(dev),
0x81, data,
4096, img_data_cb, &sdev->img_transfer_data[i], 0);
}
switch (sdev->dev_model) {
case UPEKSONLY_2016:
ssm = fpi_ssm_new(dev->dev, initsm_2016_run_state, INITSM_2016_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), initsm_2016_run_state, INITSM_2016_NUM_STATES);
break;
case UPEKSONLY_1000:
ssm = fpi_ssm_new(dev->dev, initsm_1000_run_state, INITSM_1000_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), initsm_1000_run_state, INITSM_1000_NUM_STATES);
break;
case UPEKSONLY_1001:
ssm = fpi_ssm_new(dev->dev, initsm_1001_run_state, INITSM_1001_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), initsm_1001_run_state, INITSM_1001_NUM_STATES);
break;
}
fpi_ssm_set_user_data(ssm, dev);
@ -1329,19 +1333,20 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
int r;
struct sonly_dev *sdev;
r = libusb_set_configuration(dev->udev, 1);
r = libusb_set_configuration(fpi_imgdev_get_usb_dev(dev), 1);
if (r < 0) {
fp_err("could not set configuration 1");
return r;
}
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
sdev = dev->priv = g_malloc0(sizeof(struct sonly_dev));
sdev = g_malloc0(sizeof(struct sonly_dev));
fpi_imgdev_set_user_data(dev, sdev);
sdev->dev_model = (int)driver_data;
switch (driver_data) {
case UPEKSONLY_1000:
@ -1367,8 +1372,10 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
static void dev_deinit(struct fp_img_dev *dev)
{
g_free(dev->priv);
libusb_release_interface(dev->udev, 0);
void *user_data;
user_data = fpi_imgdev_get_user_data(dev);
g_free(user_data);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -59,7 +59,7 @@ enum activate_states {
static void upektc_next_init_cmd(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
upekdev->init_idx += 1;
if (upekdev->init_idx == upekdev->setup_commands_len)
@ -72,7 +72,7 @@ static void write_init_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
(transfer->length == transfer->actual_length)) {
@ -101,7 +101,7 @@ static void read_init_data_cb(struct libusb_transfer *transfer)
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
int r;
switch (fpi_ssm_get_cur_state(ssm)) {
@ -112,7 +112,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
fpi_ssm_mark_aborted(ssm, -ENOMEM);
return;
}
libusb_fill_bulk_transfer(transfer, dev->udev, upekdev->ep_out,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), upekdev->ep_out,
(unsigned char*)upekdev->setup_commands[upekdev->init_idx].cmd,
UPEKTC_CMD_LEN, write_init_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -133,7 +133,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
}
data = g_malloc(upekdev->setup_commands[upekdev->init_idx].response_len);
libusb_fill_bulk_transfer(transfer, dev->udev, upekdev->ep_in, data,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), upekdev->ep_in, data,
upekdev->setup_commands[upekdev->init_idx].response_len,
read_init_data_cb, ssm, BULK_TIMEOUT);
@ -181,7 +181,7 @@ static int finger_present(unsigned char *img, size_t len, int sum_threshold)
static void finger_det_data_cb(struct libusb_transfer *transfer)
{
struct fp_img_dev *dev = transfer->user_data;
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
unsigned char *data = transfer->buffer;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
@ -214,7 +214,7 @@ static void finger_det_cmd_cb(struct libusb_transfer *t)
unsigned char *data;
int r;
struct fp_img_dev *dev = t->user_data;
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
if (t->status != LIBUSB_TRANSFER_COMPLETED) {
fp_dbg("req transfer status %d\n", t->status);
@ -233,7 +233,7 @@ static void finger_det_cmd_cb(struct libusb_transfer *t)
}
data = g_malloc(IMAGE_SIZE);
libusb_fill_bulk_transfer(transfer, dev->udev, upekdev->ep_in, data, IMAGE_SIZE,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), upekdev->ep_in, data, IMAGE_SIZE,
finger_det_data_cb, dev, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -249,7 +249,7 @@ exit_free_transfer:
static void start_finger_detection(struct fp_img_dev *dev)
{
int r;
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
struct libusb_transfer *transfer;
G_DEBUG_HERE();
@ -263,7 +263,7 @@ static void start_finger_detection(struct fp_img_dev *dev)
fpi_imgdev_session_error(dev, -ENOMEM);
return;
}
libusb_fill_bulk_transfer(transfer, dev->udev, upekdev->ep_out,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), upekdev->ep_out,
(unsigned char *)scan_cmd, UPEKTC_CMD_LEN,
finger_det_cmd_cb, dev, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -324,7 +324,7 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
int r;
switch (fpi_ssm_get_cur_state(ssm)) {
@ -335,7 +335,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
fpi_ssm_mark_aborted(ssm, -ENOMEM);
return;
}
libusb_fill_bulk_transfer(transfer, dev->udev, upekdev->ep_out,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), upekdev->ep_out,
(unsigned char *)scan_cmd, UPEKTC_CMD_LEN,
capture_cmd_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -356,7 +356,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
}
data = g_malloc(IMAGE_SIZE);
libusb_fill_bulk_transfer(transfer, dev->udev, upekdev->ep_in, data, IMAGE_SIZE,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), upekdev->ep_in, data, IMAGE_SIZE,
capture_read_data_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -373,7 +373,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
fp_dbg("Capture completed");
if (upekdev->deactivating)
@ -387,7 +387,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
static void start_capture(struct fp_img_dev *dev)
{
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm;
if (upekdev->deactivating) {
@ -395,7 +395,7 @@ static void start_capture(struct fp_img_dev *dev)
return;
}
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
@ -403,8 +403,8 @@ static void start_capture(struct fp_img_dev *dev)
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct upektc_dev *upekdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
ACTIVATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
upekdev->init_idx = 0;
@ -414,14 +414,14 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
static void dev_deactivate(struct fp_img_dev *dev)
{
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
upekdev->deactivating = TRUE;
}
static void complete_deactivation(struct fp_img_dev *dev)
{
struct upektc_dev *upekdev = dev->priv;
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
upekdev->deactivating = FALSE;
@ -434,13 +434,14 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
int r;
struct upektc_dev *upekdev;
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
dev->priv = upekdev = g_malloc0(sizeof(struct upektc_dev));
upekdev = g_malloc0(sizeof(struct upektc_dev));
fpi_imgdev_set_user_data(dev, upekdev);
switch (driver_data) {
case UPEKTC_2015:
upekdev->ep_in = UPEKTC_EP_IN;
@ -459,7 +460,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
default:
fp_err("Device variant %lu is not known\n", driver_data);
g_free(upekdev);
dev->priv = NULL;
fpi_imgdev_set_user_data(dev, NULL);
return -ENODEV;
break;
}
@ -469,8 +470,10 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
static void dev_deinit(struct fp_img_dev *dev)
{
g_free(dev->priv);
libusb_release_interface(dev->udev, 0);
void *user_data;
user_data = fpi_imgdev_get_user_data(dev);
g_free(user_data);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -119,7 +119,7 @@ static void upektc_img_submit_req(struct fpi_ssm *ssm,
libusb_transfer_cb_fn cb)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
int r;
@ -136,7 +136,7 @@ static void upektc_img_submit_req(struct fpi_ssm *ssm,
upektc_img_cmd_fix_seq(upekdev->cmd, seq);
upektc_img_cmd_update_crc(upekdev->cmd, buf_size);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_OUT, upekdev->cmd, buf_size,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT, upekdev->cmd, buf_size,
cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -150,7 +150,7 @@ static void upektc_img_read_data(struct fpi_ssm *ssm, size_t buf_size, size_t bu
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
int r;
if (!transfer) {
@ -162,7 +162,7 @@ static void upektc_img_read_data(struct fpi_ssm *ssm, size_t buf_size, size_t bu
transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, upekdev->response + buf_offset, buf_size,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN, upekdev->response + buf_offset, buf_size,
cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -226,7 +226,7 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
unsigned char *data = upekdev->response;
struct fp_img *img;
size_t response_size;
@ -350,7 +350,7 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_INIT_CAPTURE:
@ -387,7 +387,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
int err = fpi_ssm_get_error(ssm);
fp_dbg("Capture completed, %d", err);
@ -403,12 +403,12 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
static void start_capture(struct fp_img_dev *dev)
{
struct upektc_img_dev *upekdev = dev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm;
upekdev->image_size = 0;
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), capture_run_state, CAPTURE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
@ -448,7 +448,7 @@ static void deactivate_read_data_cb(struct libusb_transfer *transfer)
static void deactivate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case DEACTIVATE_DEINIT:
@ -465,7 +465,7 @@ static void deactivate_run_state(struct fpi_ssm *ssm)
static void deactivate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
int err = fpi_ssm_get_error(ssm);
fp_dbg("Deactivate completed");
@ -482,12 +482,12 @@ static void deactivate_sm_complete(struct fpi_ssm *ssm)
static void start_deactivation(struct fp_img_dev *dev)
{
struct upektc_img_dev *upekdev = dev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm;
upekdev->image_size = 0;
ssm = fpi_ssm_new(dev->dev, deactivate_run_state, DEACTIVATE_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), deactivate_run_state, DEACTIVATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, deactivate_sm_complete);
}
@ -547,7 +547,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
{
struct libusb_transfer *transfer;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = idev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(idev);
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
int r;
@ -622,8 +622,8 @@ static void activate_sm_complete(struct fpi_ssm *ssm)
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct upektc_img_dev *upekdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
ACTIVATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
upekdev->seq = 0;
@ -633,7 +633,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
static void dev_deactivate(struct fp_img_dev *dev)
{
struct upektc_img_dev *upekdev = dev->priv;
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
upekdev->deactivating = TRUE;
}
@ -642,22 +642,25 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
{
/* TODO check that device has endpoints we're using */
int r;
struct upektc_img_dev *upekdev;
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
dev->priv = g_malloc0(sizeof(struct upektc_img_dev));
upekdev = g_malloc0(sizeof(struct upektc_img_dev));
fpi_imgdev_set_user_data(dev, upekdev);
fpi_imgdev_open_complete(dev, 0);
return 0;
}
static void dev_deinit(struct fp_img_dev *dev)
{
g_free(dev->priv);
libusb_release_interface(dev->udev, 0);
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
g_free(upekdev);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -201,7 +201,7 @@ static int write_regs(struct fp_img_dev *dev, uint16_t first_reg,
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + num_regs);
memcpy(data + LIBUSB_CONTROL_SETUP_SIZE, values, num_regs);
libusb_fill_control_setup(data, CTRL_OUT, USB_RQ, first_reg, 0, num_regs);
libusb_fill_control_transfer(transfer, dev->udev, data, write_regs_cb,
libusb_fill_control_transfer(transfer, fpi_imgdev_get_usb_dev(dev), data, write_regs_cb,
wrdata, CTRL_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -267,7 +267,7 @@ static int read_regs(struct fp_img_dev *dev, uint16_t first_reg,
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + num_regs);
libusb_fill_control_setup(data, CTRL_IN, USB_RQ, first_reg, 0, num_regs);
libusb_fill_control_transfer(transfer, dev->udev, data, read_regs_cb,
libusb_fill_control_transfer(transfer, fpi_imgdev_get_usb_dev(dev), data, read_regs_cb,
rrdata, CTRL_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -317,7 +317,7 @@ static void challenge_cb(struct fp_img_dev *dev, int status,
uint16_t num_regs, unsigned char *data, void *user_data)
{
struct fpi_ssm *ssm = user_data;
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
unsigned char *respdata;
PK11Context *ctx;
int r, outlen;
@ -374,7 +374,7 @@ static int start_irq_handler(struct fp_img_dev *dev);
static void irq_handler(struct libusb_transfer *transfer)
{
struct fp_img_dev *dev = transfer->user_data;
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
unsigned char *data = transfer->buffer;
uint16_t type;
int r = 0;
@ -426,7 +426,7 @@ out:
static int start_irq_handler(struct fp_img_dev *dev)
{
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
@ -435,7 +435,7 @@ static int start_irq_handler(struct fp_img_dev *dev)
return -ENOMEM;
data = g_malloc(IRQ_LENGTH);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_INTR, data, IRQ_LENGTH,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_INTR, data, IRQ_LENGTH,
irq_handler, dev, 0);
urudev->irq_transfer = transfer;
@ -450,7 +450,7 @@ static int start_irq_handler(struct fp_img_dev *dev)
static void stop_irq_handler(struct fp_img_dev *dev, irqs_stopped_cb_fn cb)
{
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
struct libusb_transfer *transfer = urudev->irq_transfer;
if (transfer) {
libusb_cancel_transfer(transfer);
@ -484,7 +484,7 @@ static void change_state_write_reg_cb(struct fp_img_dev *dev, int status,
static int dev_change_state(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
switch (state) {
case IMGDEV_STATE_INACTIVE:
@ -535,7 +535,7 @@ static void sm_read_reg_cb(struct fp_img_dev *dev, int result,
uint16_t num_regs, unsigned char *data, void *user_data)
{
struct fpi_ssm *ssm = user_data;
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
if (result) {
fpi_ssm_mark_aborted(ssm, result);
@ -549,7 +549,7 @@ static void sm_read_reg_cb(struct fp_img_dev *dev, int result,
static void sm_read_regs(struct fpi_ssm *ssm, uint16_t reg, uint16_t num_regs)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
int r;
if (num_regs > sizeof(urudev->last_reg_rd)) {
@ -690,7 +690,7 @@ static int calc_dev2(struct uru4k_image *img)
static void imaging_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
struct uru4k_image *img = urudev->img_data;
struct fp_img *fpimg;
uint32_t key;
@ -702,7 +702,7 @@ static void imaging_run_state(struct fpi_ssm *ssm)
case IMAGING_CAPTURE:
urudev->img_lines_done = 0;
urudev->img_block = 0;
libusb_fill_bulk_transfer(urudev->img_transfer, dev->udev, EP_DATA,
libusb_fill_bulk_transfer(urudev->img_transfer, fpi_imgdev_get_usb_dev(dev), EP_DATA,
urudev->img_data, sizeof(struct uru4k_image), image_transfer_cb, ssm, 0);
r = libusb_submit_transfer(urudev->img_transfer);
if (r < 0)
@ -813,7 +813,7 @@ static void imaging_run_state(struct fpi_ssm *ssm)
static void imaging_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
int r = fpi_ssm_get_error(ssm);
fpi_ssm_free(ssm);
@ -864,7 +864,7 @@ static void rebootpwr_pause_cb(void *data)
{
struct fpi_ssm *ssm = data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
if (!--urudev->rebootpwr_ctr) {
fp_err("could not reboot device power");
@ -877,7 +877,7 @@ static void rebootpwr_pause_cb(void *data)
static void rebootpwr_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case REBOOTPWR_SET_HWSTAT:
@ -941,7 +941,7 @@ static void powerup_pause_cb(void *data)
{
struct fpi_ssm *ssm = data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
if (!--urudev->powerup_ctr) {
fp_err("could not power device up");
@ -956,7 +956,7 @@ static void powerup_pause_cb(void *data)
static void powerup_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case POWERUP_INIT:
@ -1025,7 +1025,7 @@ static void init_scanpwr_irq_cb(struct fp_img_dev *dev, int status,
uint16_t type, void *user_data)
{
struct fpi_ssm *ssm = user_data;
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
if (status)
fpi_ssm_mark_aborted(ssm, status);
@ -1044,7 +1044,7 @@ static void init_scanpwr_timeout(void *user_data)
{
struct fpi_ssm *ssm = user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
fp_warn("powerup timed out");
urudev->irq_cb = NULL;
@ -1061,7 +1061,7 @@ static void init_scanpwr_timeout(void *user_data)
static void init_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case INIT_GET_HWSTAT:
@ -1075,7 +1075,7 @@ static void init_run_state(struct fpi_ssm *ssm)
fpi_ssm_jump_to_state(ssm, INIT_CHECK_HWSTAT_POWERDOWN);
break;
case INIT_REBOOT_POWER: ;
struct fpi_ssm *rebootsm = fpi_ssm_new(dev->dev, rebootpwr_run_state,
struct fpi_ssm *rebootsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), rebootpwr_run_state,
REBOOTPWR_NUM_STATES);
fpi_ssm_set_user_data(rebootsm, dev);
fpi_ssm_start_subsm(ssm, rebootsm);
@ -1094,7 +1094,7 @@ static void init_run_state(struct fpi_ssm *ssm)
urudev->irq_cb_data = ssm;
urudev->irq_cb = init_scanpwr_irq_cb;
struct fpi_ssm *powerupsm = fpi_ssm_new(dev->dev, powerup_run_state,
struct fpi_ssm *powerupsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), powerup_run_state,
POWERUP_NUM_STATES);
fpi_ssm_set_user_data(powerupsm, dev);
fpi_ssm_start_subsm(ssm, powerupsm);
@ -1159,7 +1159,7 @@ static void activate_initsm_complete(struct fpi_ssm *ssm)
* call. */
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm;
int r;
@ -1169,7 +1169,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
urudev->scanpwr_irq_timeouts = 0;
urudev->activate_state = state;
ssm = fpi_ssm_new(dev->dev, init_run_state, INIT_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), init_run_state, INIT_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_initsm_complete);
return 0;
@ -1195,7 +1195,7 @@ static void dev_deactivate(struct fp_img_dev *dev)
static int execute_state_change(struct fp_img_dev *dev)
{
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm;
switch (urudev->activate_state) {
@ -1223,7 +1223,7 @@ static int execute_state_change(struct fp_img_dev *dev)
urudev->img_data = g_malloc(sizeof(struct uru4k_image));
urudev->img_enc_seed = rand();
ssm = fpi_ssm_new(dev->dev, imaging_run_state, IMAGING_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), imaging_run_state, IMAGING_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, imaging_complete);
@ -1257,7 +1257,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
int r;
/* Find fingerprint interface */
r = libusb_get_config_descriptor(libusb_get_device(dev->udev), 0, &config);
r = libusb_get_config_descriptor(libusb_get_device(fpi_imgdev_get_usb_dev(dev)), 0, &config);
if (r < 0) {
fp_err("Failed to get config descriptor");
return r;
@ -1311,7 +1311,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
/* Device looks like a supported reader */
r = libusb_claim_interface(dev->udev, iface_desc->bInterfaceNumber);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), iface_desc->bInterfaceNumber);
if (r < 0) {
fp_err("interface claim failed: %s", libusb_error_name(r));
goto out;
@ -1351,7 +1351,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
}
urudev->param = PK11_ParamFromIV(urudev->cipher, NULL);
dev->priv = urudev;
fpi_imgdev_set_user_data(dev, urudev);
fpi_imgdev_open_complete(dev, 0);
out:
@ -1361,14 +1361,14 @@ out:
static void dev_deinit(struct fp_img_dev *dev)
{
struct uru4k_dev *urudev = dev->priv;
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
if (urudev->symkey)
PK11_FreeSymKey (urudev->symkey);
if (urudev->param)
SECITEM_FreeItem(urudev->param, PR_TRUE);
if (urudev->slot)
PK11_FreeSlot(urudev->slot);
libusb_release_interface(dev->udev, urudev->interface);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), urudev->interface);
g_free(urudev);
fpi_imgdev_close_complete(dev);
}

View file

@ -101,7 +101,7 @@ static void sm_write_reg(struct fpi_ssm *ssm, unsigned char reg,
fp_dbg("set %02x=%02x", reg, value);
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE);
libusb_fill_control_setup(data, CTRL_OUT, reg, value, 0, 0);
libusb_fill_control_transfer(transfer, dev->udev, data, sm_write_reg_cb,
libusb_fill_control_transfer(transfer, fpi_imgdev_get_usb_dev(dev), data, sm_write_reg_cb,
ssm, CTRL_TIMEOUT);
r = libusb_submit_transfer(transfer);
if (r < 0) {
@ -140,7 +140,7 @@ static void sm_exec_cmd(struct fpi_ssm *ssm, unsigned char cmd,
fp_dbg("cmd %02x param %02x", cmd, param);
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE);
libusb_fill_control_setup(data, CTRL_IN, cmd, param, 0, 0);
libusb_fill_control_transfer(transfer, dev->udev, data, sm_exec_cmd_cb,
libusb_fill_control_transfer(transfer, fpi_imgdev_get_usb_dev(dev), data, sm_exec_cmd_cb,
ssm, CTRL_TIMEOUT);
r = libusb_submit_transfer(transfer);
if (r < 0) {
@ -193,7 +193,7 @@ static void capture_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct v5s_dev *vdev = dev->priv;
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fpi_ssm_mark_aborted(ssm, -EIO);
@ -221,7 +221,7 @@ out:
static void capture_iterate(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct v5s_dev *vdev = dev->priv;
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
int iteration = vdev->capture_iteration;
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
int r;
@ -231,7 +231,7 @@ static void capture_iterate(struct fpi_ssm *ssm)
return;
}
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_IN,
vdev->capture_img->data + (RQ_SIZE * iteration), RQ_SIZE,
capture_cb, ssm, CTRL_TIMEOUT);
transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK;
@ -246,7 +246,7 @@ static void capture_iterate(struct fpi_ssm *ssm)
static void sm_do_capture(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct v5s_dev *vdev = dev->priv;
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
vdev->capture_img = fpi_img_new_for_imgdev(dev);
@ -268,7 +268,7 @@ enum loop_states {
static void loop_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct v5s_dev *vdev = dev->priv;
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case LOOP_SET_CONTRAST:
@ -296,7 +296,7 @@ static void loop_run_state(struct fpi_ssm *ssm)
static void loopsm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct v5s_dev *vdev = dev->priv;
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
int r = fpi_ssm_get_error(ssm);
fpi_ssm_free(ssm);
@ -313,8 +313,8 @@ static void loopsm_complete(struct fpi_ssm *ssm)
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct v5s_dev *vdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, loop_run_state,
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), loop_run_state,
LOOP_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
vdev->deactivating = FALSE;
@ -326,7 +326,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
static void dev_deactivate(struct fp_img_dev *dev)
{
struct v5s_dev *vdev = dev->priv;
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
if (vdev->loop_running)
vdev->deactivating = TRUE;
else
@ -336,9 +336,12 @@ static void dev_deactivate(struct fp_img_dev *dev)
static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
{
int r;
dev->priv = g_malloc0(sizeof(struct v5s_dev));
struct v5s_dev *v5s_dev;
r = libusb_claim_interface(dev->udev, 0);
v5s_dev = g_malloc0(sizeof(struct v5s_dev));
fpi_imgdev_set_user_data(dev, v5s_dev);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0)
fp_err("could not claim interface 0: %s", libusb_error_name(r));
@ -350,8 +353,10 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data)
static void dev_deinit(struct fp_img_dev *dev)
{
g_free(dev->priv);
libusb_release_interface(dev->udev, 0);
struct v5s_dev *v5s_dev;
v5s_dev = fpi_imgdev_get_user_data(dev);
g_free(v5s_dev);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
fpi_imgdev_close_complete(dev);
}

View file

@ -54,8 +54,8 @@ static void async_write_callback(struct libusb_transfer *transfer)
static void async_write(struct fpi_ssm *ssm, void *data, int len)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct libusb_device_handle *udev = idev->udev;
struct vfs_dev_t *vdev = idev->priv;
struct libusb_device_handle *udev = fpi_imgdev_get_usb_dev(idev);
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
vdev->transfer = libusb_alloc_transfer(0);
vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER;
@ -96,8 +96,8 @@ static void async_read_callback(struct libusb_transfer *transfer)
static void async_read(struct fpi_ssm *ssm, int ep, void *data, int len)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct libusb_device_handle *udev = idev->udev;
struct vfs_dev_t *vdev = idev->priv;
struct libusb_device_handle *udev = fpi_imgdev_get_usb_dev(idev);
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
ep |= LIBUSB_ENDPOINT_IN;
@ -150,8 +150,8 @@ static void async_abort_callback(struct libusb_transfer *transfer)
static void async_abort(struct fpi_ssm *ssm, int ep)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct libusb_device_handle *udev = idev->udev;
struct vfs_dev_t *vdev = idev->priv;
struct libusb_device_handle *udev = fpi_imgdev_get_usb_dev(idev);
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
int len = VFS_USB_BUFFER_SIZE;
unsigned char *data = g_malloc(VFS_USB_BUFFER_SIZE);
@ -259,7 +259,7 @@ static struct fp_img *prepare_image(struct vfs_dev_t *vdev)
/* Processes and submits image after fingerprint received */
static void submit_image(struct fp_img_dev *idev)
{
struct vfs_dev_t *vdev = idev->priv;
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
/* We were not asked to submit image actually */
if (!vdev->active)
@ -312,7 +312,7 @@ static void clear_ep2(struct fpi_ssm *ssm)
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fpi_ssm *subsm =
fpi_ssm_new(idev->dev, clear_ep2_ssm, SUBSM1_STATES);
fpi_ssm_new(fpi_imgdev_get_dev(idev), clear_ep2_ssm, SUBSM1_STATES);
fpi_ssm_set_user_data(subsm, idev);
fpi_ssm_start_subsm(ssm, subsm);
}
@ -320,7 +320,7 @@ static void clear_ep2(struct fpi_ssm *ssm)
static void send_control_packet_ssm(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct vfs_dev_t *vdev = idev->priv;
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
short result;
unsigned char *commit_result = NULL;
@ -390,7 +390,7 @@ static void send_control_packet(struct fpi_ssm *ssm)
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fpi_ssm *subsm =
fpi_ssm_new(idev->dev, send_control_packet_ssm, SUBSM2_STATES);
fpi_ssm_new(fpi_imgdev_get_dev(idev), send_control_packet_ssm, SUBSM2_STATES);
fpi_ssm_set_user_data(subsm, idev);
fpi_ssm_start_subsm(ssm, subsm);
}
@ -408,7 +408,7 @@ static void interrupt_callback(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct vfs_dev_t *vdev = idev->priv;
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
char *interrupt = vdev->interrupt;
int error = transfer->status, transferred = transfer->actual_length;
@ -468,7 +468,7 @@ static void receive_callback(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct vfs_dev_t *vdev = idev->priv;
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
int transferred = transfer->actual_length, error = transfer->status;
@ -496,7 +496,7 @@ static void wait_interrupt(void *data)
{
struct fpi_ssm *ssm = data;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct vfs_dev_t *vdev = idev->priv;
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
/* Keep sleeping while this flag is on */
if (vdev->wait_interrupt)
@ -521,8 +521,8 @@ static void scan_completed(void *data)
static void activate_ssm(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct libusb_device_handle *udev = idev->udev;
struct vfs_dev_t *vdev = idev->priv;
struct libusb_device_handle *udev = fpi_imgdev_get_usb_dev(idev);
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
switch (fpi_ssm_get_cur_state(ssm)) {
case SSM_INITIAL_ABORT_1:
@ -674,7 +674,7 @@ static void activate_ssm(struct fpi_ssm *ssm)
static void dev_activate_callback(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct vfs_dev_t *vdev = idev->priv;
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
vdev->ssm_active = 0;
@ -684,14 +684,14 @@ static void dev_activate_callback(struct fpi_ssm *ssm)
/* Activate device */
static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
{
struct vfs_dev_t *vdev = idev->priv;
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
/* Initialize flags */
vdev->active = 1;
vdev->need_report = 1;
vdev->ssm_active = 1;
struct fpi_ssm *ssm = fpi_ssm_new(idev->dev, activate_ssm, SSM_STATES);
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), activate_ssm, SSM_STATES);
fpi_ssm_set_user_data(ssm, idev);
fpi_ssm_start(ssm, dev_activate_callback);
return 0;
@ -700,7 +700,7 @@ static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
/* Deactivate device */
static void dev_deactivate(struct fp_img_dev *idev)
{
struct vfs_dev_t *vdev = idev->priv;
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
if (!vdev->ssm_active) {
fpi_imgdev_deactivate_complete(idev);
@ -723,8 +723,10 @@ static void dev_open_callback(struct fpi_ssm *ssm)
/* Open device */
static int dev_open(struct fp_img_dev *idev, unsigned long driver_data)
{
struct vfs_dev_t *vdev;
/* Claim usb interface */
int error = libusb_claim_interface(idev->udev, 0);
int error = libusb_claim_interface(fpi_imgdev_get_usb_dev(idev), 0);
if (error < 0) {
/* Interface not claimed, return error */
fp_err("could not claim interface 0");
@ -732,11 +734,11 @@ static int dev_open(struct fp_img_dev *idev, unsigned long driver_data)
}
/* Initialize private structure */
struct vfs_dev_t *vdev = g_malloc0(sizeof(struct vfs_dev_t));
idev->priv = vdev;
vdev = g_malloc0(sizeof(struct vfs_dev_t));
fpi_imgdev_set_user_data(idev, vdev);
/* Clearing previous device state */
struct fpi_ssm *ssm = fpi_ssm_new(idev->dev, activate_ssm, SSM_STATES);
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), activate_ssm, SSM_STATES);
fpi_ssm_set_user_data(ssm, idev);
fpi_ssm_start(ssm, dev_open_callback);
return 0;
@ -745,11 +747,14 @@ static int dev_open(struct fp_img_dev *idev, unsigned long driver_data)
/* Close device */
static void dev_close(struct fp_img_dev *idev)
{
struct vfs_dev_t *vdev;
/* Release private structure */
g_free(idev->priv);
vdev = fpi_imgdev_get_user_data(idev);
g_free(vdev);
/* Release usb interface */
libusb_release_interface(idev->udev, 0);
libusb_release_interface(fpi_imgdev_get_usb_dev(idev), 0);
/* Notify close complete */
fpi_imgdev_close_complete(idev);

View file

@ -184,7 +184,7 @@ static int result_code(struct fp_img_dev *dev, int result)
return result;
/* Return result code */
if (dev->action == IMG_ACTION_ENROLL)
if (fpi_imgdev_get_action(dev) == IMG_ACTION_ENROLL)
return result_codes[0][result];
else
return result_codes[1][result];
@ -201,7 +201,7 @@ static void async_send_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
/* Cleanup transfer */
vdev->transfer = NULL;
@ -245,7 +245,7 @@ out:
static void async_send(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
int r;
/* Allocation of transfer */
@ -265,7 +265,7 @@ static void async_send(struct fpi_ssm *ssm)
vdev->buffer[1] = byte(1, vdev->seqnum);
/* Prepare bulk transfer */
libusb_fill_bulk_transfer(vdev->transfer, dev->udev, EP_OUT(1), vdev->buffer, vdev->length, async_send_cb, ssm, BULK_TIMEOUT);
libusb_fill_bulk_transfer(vdev->transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT(1), vdev->buffer, vdev->length, async_send_cb, ssm, BULK_TIMEOUT);
/* Submit transfer */
r = libusb_submit_transfer(vdev->transfer);
@ -285,7 +285,7 @@ static void async_recv_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
/* Cleanup transfer */
vdev->transfer = NULL;
@ -332,7 +332,7 @@ out:
static void async_recv(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
int r;
/* Allocation of transfer */
@ -347,7 +347,7 @@ static void async_recv(struct fpi_ssm *ssm)
}
/* Prepare bulk transfer */
libusb_fill_bulk_transfer(vdev->transfer, dev->udev, EP_IN(1), vdev->buffer, 0x0f, async_recv_cb, ssm, BULK_TIMEOUT);
libusb_fill_bulk_transfer(vdev->transfer, fpi_imgdev_get_usb_dev(dev), EP_IN(1), vdev->buffer, 0x0f, async_recv_cb, ssm, BULK_TIMEOUT);
/* Submit transfer */
r = libusb_submit_transfer(vdev->transfer);
@ -369,7 +369,7 @@ static void async_load_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
/* Cleanup transfer */
vdev->transfer = NULL;
@ -433,7 +433,7 @@ out:
static void async_load(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
unsigned char *buffer;
int r;
@ -452,7 +452,7 @@ static void async_load(struct fpi_ssm *ssm)
buffer = vdev->buffer + vdev->length;
/* Prepare bulk transfer */
libusb_fill_bulk_transfer(vdev->transfer, dev->udev, EP_IN(2), buffer, VFS_BLOCK_SIZE, async_load_cb, ssm, BULK_TIMEOUT);
libusb_fill_bulk_transfer(vdev->transfer, fpi_imgdev_get_usb_dev(dev), EP_IN(2), buffer, VFS_BLOCK_SIZE, async_load_cb, ssm, BULK_TIMEOUT);
/* Submit transfer */
r = libusb_submit_transfer(vdev->transfer);
@ -472,7 +472,7 @@ static void async_sleep_cb(void *data)
{
struct fpi_ssm *ssm = data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
/* Cleanup timeout */
vdev->timeout = NULL;
@ -484,7 +484,7 @@ static void async_sleep_cb(void *data)
static void async_sleep(unsigned int msec, struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
/* Add timeout */
vdev->timeout = fpi_timeout_add(msec, async_sleep_cb, ssm);
@ -527,7 +527,7 @@ static void m_swap_state(struct fpi_ssm *ssm)
static void m_swap(struct fpi_ssm *ssm, unsigned char *data, size_t length)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *subsm;
/* Prepare data for sending */
@ -536,7 +536,7 @@ static void m_swap(struct fpi_ssm *ssm, unsigned char *data, size_t length)
vdev->length = length;
/* Start swap ssm */
subsm = fpi_ssm_new(dev->dev, m_swap_state, M_SWAP_NUM_STATES);
subsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), m_swap_state, M_SWAP_NUM_STATES);
fpi_ssm_set_user_data(subsm, dev);
fpi_ssm_start_subsm(ssm, subsm);
}
@ -626,7 +626,7 @@ static void vfs_get_finger_state(struct fpi_ssm *ssm)
static void vfs_img_load(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
G_DEBUG_HERE();
@ -644,10 +644,10 @@ static void vfs_img_load(struct fpi_ssm *ssm)
/* Check if action is completed */
static int action_completed(struct fp_img_dev *dev)
{
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
if ((dev->action == IMG_ACTION_ENROLL) &&
(vdev->enroll_stage < fpi_dev_get_nr_enroll_stages(dev->dev)))
if ((fpi_imgdev_get_action(dev) == IMG_ACTION_ENROLL) &&
(vdev->enroll_stage < fpi_dev_get_nr_enroll_stages(fpi_imgdev_get_dev(dev))))
/* Enroll not completed, return false */
return FALSE;
@ -757,7 +757,7 @@ static void img_copy(struct vfs101_dev *vdev, struct fp_img *img)
static void img_extract(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
struct fp_img *img;
/* Screen image to remove noise and find top and bottom line */
@ -787,28 +787,28 @@ static void img_extract(struct fpi_ssm *ssm)
fpi_imgdev_image_captured(dev, img);
/* Check captured result */
if (dev->action_result >= 0 &&
dev->action_result != FP_ENROLL_RETRY &&
dev->action_result != FP_VERIFY_RETRY)
if (fpi_imgdev_get_action_result(dev) >= 0 &&
fpi_imgdev_get_action_result(dev) != FP_ENROLL_RETRY &&
fpi_imgdev_get_action_result(dev) != FP_VERIFY_RETRY)
{
/* Image captured, increase enroll stage */
vdev->enroll_stage++;
/* Check if action is completed */
if (!action_completed(dev))
dev->action_result = FP_ENROLL_PASS;
fpi_imgdev_set_action_result(dev, FP_ENROLL_PASS);
}
else
{
/* Image capture failed */
if (dev->action == IMG_ACTION_ENROLL)
if (fpi_imgdev_get_action(dev) == IMG_ACTION_ENROLL)
/* Return retry */
dev->action_result = result_code(dev, RESULT_RETRY);
fpi_imgdev_set_action_result(dev, result_code(dev, RESULT_RETRY));
else
{
/* Return no match */
vdev->enroll_stage++;
dev->action_result = FP_VERIFY_NO_MATCH;
fpi_imgdev_set_action_result(dev, FP_VERIFY_NO_MATCH);
}
}
@ -915,7 +915,7 @@ enum
static void m_loop_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
/* Check action state */
if (!vdev->active)
@ -1179,7 +1179,7 @@ enum
static void m_init_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
/* Check action state */
if (!vdev->active)
@ -1420,7 +1420,7 @@ static void m_init_state(struct fpi_ssm *ssm)
static void m_init_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm_loop;
if (!fpi_ssm_get_error(ssm) && vdev->active)
@ -1429,7 +1429,7 @@ static void m_init_complete(struct fpi_ssm *ssm)
fpi_imgdev_activate_complete(dev, 0);
/* Start loop ssm */
ssm_loop = fpi_ssm_new(dev->dev, m_loop_state, M_LOOP_NUM_STATES);
ssm_loop = fpi_ssm_new(fpi_imgdev_get_dev(dev), m_loop_state, M_LOOP_NUM_STATES);
fpi_ssm_set_user_data(ssm_loop, dev);
fpi_ssm_start(ssm_loop, m_loop_complete);
}
@ -1441,7 +1441,7 @@ static void m_init_complete(struct fpi_ssm *ssm)
/* Activate device */
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
struct fpi_ssm *ssm;
/* Check if already active */
@ -1464,7 +1464,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
vdev->enroll_stage = 0;
/* Start init ssm */
ssm = fpi_ssm_new(dev->dev, m_init_state, M_INIT_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), m_init_state, M_INIT_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, m_init_complete);
@ -1474,7 +1474,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
/* Deactivate device */
static void dev_deactivate(struct fp_img_dev *dev)
{
struct vfs101_dev *vdev = dev->priv;
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
/* Reset active state */
vdev->active = FALSE;
@ -1494,7 +1494,7 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
int r;
/* Claim usb interface */
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0)
{
/* Interface not claimed, return error */
@ -1505,7 +1505,7 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
/* Initialize private structure */
vdev = g_malloc0(sizeof(struct vfs101_dev));
vdev->seqnum = -1;
dev->priv = vdev;
fpi_imgdev_set_user_data(dev, vdev);
/* Notify open complete */
fpi_imgdev_open_complete(dev, 0);
@ -1516,11 +1516,14 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
/* Close device */
static void dev_close(struct fp_img_dev *dev)
{
struct vfs101_dev *vdev;
/* Release private structure */
g_free(dev->priv);
vdev = fpi_imgdev_get_user_data(dev);
g_free(vdev);
/* Release usb interface */
libusb_release_interface(dev->udev, 0);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
/* Notify close complete */
fpi_imgdev_close_complete(dev);

View file

@ -54,7 +54,7 @@ static void async_sleep(unsigned int msec, struct fpi_ssm *ssm)
static int submit_image(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
vfs301_dev_t *vdev = dev->priv;
vfs301_dev_t *vdev = fpi_imgdev_get_user_data(dev);
int height;
struct fp_img *img;
@ -106,11 +106,11 @@ enum
static void m_loop_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
vfs301_dev_t *vdev = dev->priv;
vfs301_dev_t *vdev = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case M_REQUEST_PRINT:
vfs301_proto_request_fingerprint(dev->udev, vdev);
vfs301_proto_request_fingerprint(fpi_imgdev_get_usb_dev(dev), vdev);
fpi_ssm_next_state(ssm);
break;
@ -120,7 +120,7 @@ static void m_loop_state(struct fpi_ssm *ssm)
break;
case M_CHECK_PRINT:
if (!vfs301_proto_peek_event(dev->udev, vdev))
if (!vfs301_proto_peek_event(fpi_imgdev_get_usb_dev(dev), vdev))
fpi_ssm_jump_to_state(ssm, M_WAIT_PRINT);
else
fpi_ssm_next_state(ssm);
@ -128,7 +128,7 @@ static void m_loop_state(struct fpi_ssm *ssm)
case M_READ_PRINT_START:
fpi_imgdev_report_finger_status(dev, TRUE);
vfs301_proto_process_event_start(dev->udev, vdev);
vfs301_proto_process_event_start(fpi_imgdev_get_usb_dev(dev), vdev);
fpi_ssm_next_state(ssm);
break;
@ -139,7 +139,7 @@ static void m_loop_state(struct fpi_ssm *ssm)
case M_READ_PRINT_POLL:
{
int rv = vfs301_proto_process_event_poll(dev->udev, vdev);
int rv = vfs301_proto_process_event_poll(fpi_imgdev_get_usb_dev(dev), vdev);
g_assert(rv != VFS301_FAILURE);
if (rv == VFS301_ONGOING)
fpi_ssm_jump_to_state(ssm, M_READ_PRINT_WAIT);
@ -171,11 +171,11 @@ static void m_loop_complete(struct fpi_ssm *ssm)
static void m_init_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
vfs301_dev_t *vdev = dev->priv;
vfs301_dev_t *vdev = fpi_imgdev_get_user_data(dev);
g_assert(fpi_ssm_get_cur_state(ssm) == 0);
vfs301_proto_init(dev->udev, vdev);
vfs301_proto_init(fpi_imgdev_get_usb_dev(dev), vdev);
fpi_ssm_mark_completed(ssm);
}
@ -191,7 +191,7 @@ static void m_init_complete(struct fpi_ssm *ssm)
fpi_imgdev_activate_complete(dev, 0);
/* Start loop ssm */
ssm_loop = fpi_ssm_new(dev->dev, m_loop_state, M_LOOP_NUM_STATES);
ssm_loop = fpi_ssm_new(fpi_imgdev_get_dev(dev), m_loop_state, M_LOOP_NUM_STATES);
fpi_ssm_set_user_data(ssm_loop, dev);
fpi_ssm_start(ssm_loop, m_loop_complete);
}
@ -206,7 +206,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
struct fpi_ssm *ssm;
/* Start init ssm */
ssm = fpi_ssm_new(dev->dev, m_init_state, 1);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), m_init_state, 1);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, m_init_complete);
@ -225,7 +225,7 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
int r;
/* Claim usb interface */
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r < 0) {
/* Interface not claimed, return error */
fp_err("could not claim interface 0: %s", libusb_error_name(r));
@ -234,7 +234,7 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
/* Initialize private structure */
vdev = g_malloc0(sizeof(vfs301_dev_t));
dev->priv = vdev;
fpi_imgdev_set_user_data(dev, vdev);
vdev->scanline_buf = malloc(0);
vdev->scanline_count = 0;
@ -247,12 +247,15 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
static void dev_close(struct fp_img_dev *dev)
{
vfs301_dev_t *vdev;
/* Release private structure */
free(((vfs301_dev_t*)dev->priv)->scanline_buf);
g_free(dev->priv);
vdev = fpi_imgdev_get_user_data(dev);
free(vdev->scanline_buf);
g_free(vdev);
/* Release usb interface */
libusb_release_interface(dev->udev, 0);
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
/* Notify close complete */
fpi_imgdev_close_complete(dev);

View file

@ -196,7 +196,7 @@ static void usbexchange_loop(struct fpi_ssm *ssm)
fpi_ssm_mark_aborted(ssm, -ENOMEM);
return;
}
libusb_fill_bulk_transfer(transfer, data->device->udev,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(data->device),
action->endpoint, action->data,
action->size, async_send_cb, ssm,
data->timeout);
@ -212,7 +212,7 @@ static void usbexchange_loop(struct fpi_ssm *ssm)
fpi_ssm_mark_aborted(ssm, -ENOMEM);
return;
}
libusb_fill_bulk_transfer(transfer, data->device->udev,
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(data->device),
action->endpoint, data->receive_buf,
action->size, async_recv_cb, ssm,
data->timeout);
@ -236,7 +236,7 @@ static void usbexchange_loop(struct fpi_ssm *ssm)
static void usb_exchange_async(struct fpi_ssm *ssm,
struct usbexchange_data *data)
{
struct fpi_ssm *subsm = fpi_ssm_new(data->device->dev,
struct fpi_ssm *subsm = fpi_ssm_new(fpi_imgdev_get_dev(data->device),
usbexchange_loop,
data->stepcount);
fpi_ssm_set_user_data(subsm, data);
@ -416,7 +416,9 @@ static void chunk_capture_callback(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = (struct fpi_ssm *)transfer->user_data;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
struct vfs5011_data *data;
data = fpi_imgdev_get_user_data(dev);
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) ||
(transfer->status == LIBUSB_TRANSFER_TIMED_OUT)) {
@ -660,10 +662,12 @@ static void activate_loop(struct fpi_ssm *ssm)
enum {READ_TIMEOUT = 0};
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
struct vfs5011_data *data;
int r;
struct fpi_timeout *timeout;
data = fpi_imgdev_get_user_data(dev);
fp_dbg("main_loop: state %d", fpi_ssm_get_cur_state(ssm));
if (data->deactivating) {
@ -695,7 +699,7 @@ static void activate_loop(struct fpi_ssm *ssm)
break;
case DEV_ACTIVATE_READ_DATA:
r = capture_chunk_async(data, dev->udev, CAPTURE_LINES,
r = capture_chunk_async(data, fpi_imgdev_get_usb_dev(dev), CAPTURE_LINES,
READ_TIMEOUT, ssm);
if (r != 0) {
fp_err("Failed to capture data");
@ -733,9 +737,11 @@ static void activate_loop(struct fpi_ssm *ssm)
static void activate_loop_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
struct vfs5011_data *data;
int r = fpi_ssm_get_error(ssm);
data = fpi_imgdev_get_user_data(dev);
fp_dbg("finishing");
if (data->init_sequence.receive_buf != NULL)
g_free(data->init_sequence.receive_buf);
@ -761,7 +767,9 @@ static void activate_loop_complete(struct fpi_ssm *ssm)
static void open_loop(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
struct vfs5011_data *data;
data = fpi_imgdev_get_user_data(dev);
switch (fpi_ssm_get_cur_state(ssm)) {
case DEV_OPEN_START:
@ -780,8 +788,9 @@ static void open_loop(struct fpi_ssm *ssm)
static void open_loop_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
struct vfs5011_data *data;
data = fpi_imgdev_get_user_data(dev);
g_free(data->init_sequence.receive_buf);
data->init_sequence.receive_buf = NULL;
@ -798,22 +807,22 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
data = (struct vfs5011_data *)g_malloc0(sizeof(*data));
data->capture_buffer =
(unsigned char *)g_malloc0(CAPTURE_LINES * VFS5011_LINE_SIZE);
dev->priv = data;
fpi_imgdev_set_user_data(dev, data);
r = libusb_reset_device(dev->udev);
r = libusb_reset_device(fpi_imgdev_get_usb_dev(dev));
if (r != 0) {
fp_err("Failed to reset the device");
return r;
}
r = libusb_claim_interface(dev->udev, 0);
r = libusb_claim_interface(fpi_imgdev_get_usb_dev(dev), 0);
if (r != 0) {
fp_err("Failed to claim interface: %s", libusb_error_name(r));
return r;
}
struct fpi_ssm *ssm;
ssm = fpi_ssm_new(dev->dev, open_loop, DEV_OPEN_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), open_loop, DEV_OPEN_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, open_loop_complete);
@ -822,8 +831,9 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
static void dev_close(struct fp_img_dev *dev)
{
libusb_release_interface(dev->udev, 0);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
libusb_release_interface(fpi_imgdev_get_usb_dev(dev), 0);
struct vfs5011_data *data;
data = fpi_imgdev_get_user_data(dev);
if (data != NULL) {
g_free(data->capture_buffer);
g_slist_free_full(data->rows, g_free);
@ -834,12 +844,13 @@ static void dev_close(struct fp_img_dev *dev)
static void start_scan(struct fp_img_dev *dev)
{
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
struct vfs5011_data *data;
struct fpi_ssm *ssm;
data = fpi_imgdev_get_user_data(dev);
data->loop_running = TRUE;
fp_dbg("creating ssm");
ssm = fpi_ssm_new(dev->dev, activate_loop, DEV_ACTIVATE_NUM_STATES);
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_loop, DEV_ACTIVATE_NUM_STATES);
fpi_ssm_set_user_data(ssm, dev);
fp_dbg("starting ssm");
fpi_ssm_start(ssm, activate_loop_complete);
@ -848,8 +859,9 @@ static void start_scan(struct fp_img_dev *dev)
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
struct vfs5011_data *data;
data = fpi_imgdev_get_user_data(dev);
fp_dbg("device initialized");
data->deactivating = FALSE;
@ -861,7 +873,9 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
static void dev_deactivate(struct fp_img_dev *dev)
{
int r;
struct vfs5011_data *data = dev->priv;
struct vfs5011_data *data;
data = fpi_imgdev_get_user_data(dev);
if (data->loop_running) {
data->deactivating = TRUE;
if (data->flying_transfer) {

View file

@ -110,24 +110,16 @@ enum fp_imgdev_verify_state {
IMG_VERIFY_STATE_ACTIVATING
};
struct fp_img_dev {
struct fp_dev *dev;
libusb_device_handle *udev;
enum fp_imgdev_action action;
int action_state;
struct fp_print_data *acquire_data;
struct fp_print_data *enroll_data;
struct fp_img *acquire_img;
int enroll_stage;
int action_result;
/* FIXME: better place to put this? */
size_t identify_match_offset;
void *priv;
};
struct fp_img_dev;
libusb_device_handle *fpi_imgdev_get_usb_dev(struct fp_img_dev *dev);
void fpi_imgdev_set_user_data(struct fp_img_dev *imgdev,
void *user_data);
void *fpi_imgdev_get_user_data(struct fp_img_dev *imgdev);
struct fp_dev *fpi_imgdev_get_dev(struct fp_img_dev *imgdev);
enum fp_imgdev_enroll_state fpi_imgdev_get_action_state(struct fp_img_dev *imgdev);
enum fp_imgdev_action fpi_imgdev_get_action(struct fp_img_dev *imgdev);
int fpi_imgdev_get_action_result(struct fp_img_dev *imgdev);
void fpi_imgdev_set_action_result(struct fp_img_dev *imgdev, int action_result);
int fpi_imgdev_get_img_width(struct fp_img_dev *imgdev);
int fpi_imgdev_get_img_height(struct fp_img_dev *imgdev);

View file

@ -536,6 +536,56 @@ API_EXPORTED struct fp_minutia **fp_img_get_minutiae(struct fp_img *img,
return img->minutiae->list;
}
libusb_device_handle *
fpi_imgdev_get_usb_dev(struct fp_img_dev *dev)
{
return dev->udev;
}
void
fpi_imgdev_set_user_data(struct fp_img_dev *imgdev,
void *user_data)
{
imgdev->priv = user_data;
}
void *
fpi_imgdev_get_user_data(struct fp_img_dev *imgdev)
{
return imgdev->priv;
}
struct fp_dev *
fpi_imgdev_get_dev(struct fp_img_dev *imgdev)
{
return imgdev->dev;
}
enum fp_imgdev_enroll_state
fpi_imgdev_get_action_state(struct fp_img_dev *imgdev)
{
return imgdev->action_state;
}
enum fp_imgdev_action
fpi_imgdev_get_action(struct fp_img_dev *imgdev)
{
return imgdev->action;
}
int
fpi_imgdev_get_action_result(struct fp_img_dev *imgdev)
{
return imgdev->action_result;
}
void
fpi_imgdev_set_action_result(struct fp_img_dev *imgdev,
int action_result)
{
imgdev->action_result = action_result;
}
/* Calculate squared standand deviation */
int fpi_std_sq_dev(const unsigned char *buf, int size)
{