From 1a80972f89be03553fdad0b0286a217881b0d079 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 26 Apr 2018 16:14:08 +0200 Subject: [PATCH] lib: Add new bus types for drivers Add a way for drivers to declare they support a bus type other than USB. We have declarations for SPI and virtual drivers, though no discovery is done just yet. https://bugs.freedesktop.org/show_bug.cgi?id=106279 --- libfprint/aeslib.c | 2 +- libfprint/async.c | 14 +++++++++--- libfprint/core.c | 23 ++++++++++++++----- libfprint/drivers/aes1610.c | 13 ++++++----- libfprint/drivers/aes1660.c | 7 +++--- libfprint/drivers/aes2501.c | 15 +++++++------ libfprint/drivers/aes2550.c | 25 +++++++++++---------- libfprint/drivers/aes2660.c | 7 +++--- libfprint/drivers/aes3500.c | 7 +++--- libfprint/drivers/aes3k.c | 2 +- libfprint/drivers/aes4000.c | 7 +++--- libfprint/drivers/aesx660.c | 4 ++-- libfprint/drivers/elan.c | 11 ++++----- libfprint/drivers/etes603.c | 9 ++++---- libfprint/drivers/fdu2000.c | 31 ++++++++++++------------- libfprint/drivers/upeke2.c | 17 +++++++------- libfprint/drivers/upeksonly.c | 21 ++++++++--------- libfprint/drivers/upektc.c | 19 ++++++++-------- libfprint/drivers/upektc_img.c | 15 +++++++------ libfprint/drivers/upekts.c | 15 +++++++------ libfprint/drivers/uru4000.c | 17 +++++++------- libfprint/drivers/vcom5s.c | 13 ++++++----- libfprint/drivers/vfs0050.c | 25 +++++++++------------ libfprint/drivers/vfs101.c | 13 ++++++----- libfprint/drivers/vfs301.c | 17 +++++++------- libfprint/drivers/vfs5011.c | 15 +++++++------ libfprint/fp_internal.h | 36 +++++++++++++++++++++++++----- libfprint/fprint-list-udev-rules.c | 21 +++++++++++------ libfprint/imgdev.c | 4 +++- 29 files changed, 249 insertions(+), 176 deletions(-) diff --git a/libfprint/aeslib.c b/libfprint/aeslib.c index 978454d..7a52ec8 100644 --- a/libfprint/aeslib.c +++ b/libfprint/aeslib.c @@ -86,7 +86,7 @@ static int do_write_regv(struct write_regv_data *wdata, int upper_bound) data[data_offset++] = regwrite->value; } - libusb_fill_bulk_transfer(transfer, wdata->imgdev->udev, EP_OUT, data, + libusb_fill_bulk_transfer(transfer, USB_DEV(wdata->imgdev), EP_OUT, data, alloc_size, write_regv_trf_complete, wdata, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); if (r < 0) { diff --git a/libfprint/async.c b/libfprint/async.c index 128b7e9..2b752ee 100644 --- a/libfprint/async.c +++ b/libfprint/async.c @@ -45,7 +45,13 @@ API_EXPORTED int fp_async_dev_open(struct fp_dscv_dev *ddev, fp_dev_open_cb cb, int r; fp_dbg(""); - r = libusb_open(ddev->udev, &udevh); + + if (ddev->bus != DRIVER_TYPE_USB) { + fp_err("bus type '%d' not supported yet", ddev->bus); + return -1; + } + + r = libusb_open(ddev->dev.usb_dev, &udevh); if (r < 0) { fp_err("usb_open failed, error %d", r); return r; @@ -53,7 +59,8 @@ API_EXPORTED int fp_async_dev_open(struct fp_dscv_dev *ddev, fp_dev_open_cb cb, dev = g_malloc0(sizeof(*dev)); dev->drv = drv; - dev->udev = udevh; + dev->bus = ddev->bus; + dev->desc.usb_dev = udevh; dev->__enroll_stage = -1; dev->state = DEV_STATE_INITIALIZING; dev->open_cb = cb; @@ -80,8 +87,9 @@ void fpi_drvcb_close_complete(struct fp_dev *dev) { fp_dbg(""); BUG_ON(dev->state != DEV_STATE_DEINITIALIZING); + BUG_ON(dev->bus != DRIVER_TYPE_USB); dev->state = DEV_STATE_DEINITIALIZED; - libusb_close(dev->udev); + libusb_close(USB_DEV(dev)); if (dev->close_cb) dev->close_cb(dev, dev->close_cb_data); g_free(dev); diff --git a/libfprint/core.c b/libfprint/core.c index 97aa5fd..d9c1ba4 100644 --- a/libfprint/core.c +++ b/libfprint/core.c @@ -468,10 +468,13 @@ static struct fp_driver *find_supporting_driver(libusb_device *udev, uint32_t type = 0; const struct usb_id *id; - for (id = drv->id_table; id->vendor; id++) { + if (drv->bus != DRIVER_TYPE_USB) + continue; + + for (id = drv->driver_id.usb_id_table; id->vendor; id++) { if (dsc.idVendor == id->vendor && dsc.idProduct == id->product) { - if (drv->discover) { - int r = drv->discover(&dsc, &type); + if (drv->usb_discover) { + int r = drv->usb_discover(&dsc, &type); if (r < 0) fp_err("%s discover failed, code %d", drv->name, r); if (r <= 0) @@ -521,7 +524,8 @@ static struct fp_dscv_dev *discover_dev(libusb_device *udev) ddev = g_malloc0(sizeof(*ddev)); ddev->drv = drv; - ddev->udev = udev; + ddev->bus = drv->bus; + ddev->dev.usb_dev = udev; ddev->driver_data = usb_id->driver_data; ddev->devtype = devtype; return ddev; @@ -599,7 +603,16 @@ API_EXPORTED void fp_dscv_devs_free(struct fp_dscv_dev **devs) return; for (i = 0; devs[i]; i++) { - libusb_unref_device(devs[i]->udev); + switch (devs[i]->bus) { + case DRIVER_TYPE_USB: + libusb_unref_device(devs[i]->dev.usb_dev); + break; + case DRIVER_TYPE_SPI: + g_free (devs[i]->dev.spi_path); + break; + default: + ;; + } g_free(devs[i]); } g_free(devs); diff --git a/libfprint/drivers/aes1610.c b/libfprint/drivers/aes1610.c index 50bc483..25febfa 100644 --- a/libfprint/drivers/aes1610.c +++ b/libfprint/drivers/aes1610.c @@ -146,7 +146,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes) } data = g_malloc(bytes); - libusb_fill_bulk_transfer(transfer, ssm->dev->udev, EP_IN, data, bytes, + libusb_fill_bulk_transfer(transfer, USB_DEV(ssm->dev), EP_IN, data, bytes, generic_ignore_data_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -239,7 +239,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, USB_DEV(dev), EP_IN, data, 19, finger_det_data_cb, dev, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -683,7 +683,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, USB_DEV(dev), EP_IN, data, 665, capture_read_strip_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -809,7 +809,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) /* FIXME check endpoints */ int r; - r = libusb_claim_interface(dev->udev, 0); + r = libusb_claim_interface(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -823,7 +823,7 @@ 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); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -837,7 +837,8 @@ struct fp_img_driver aes1610_driver = { .id = AES1610_ID, .name = FP_COMPONENT, .full_name = "AuthenTec AES1610", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, .flags = 0, diff --git a/libfprint/drivers/aes1660.c b/libfprint/drivers/aes1660.c index 32bea4e..c450113 100644 --- a/libfprint/drivers/aes1660.c +++ b/libfprint/drivers/aes1660.c @@ -51,7 +51,7 @@ 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(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -77,7 +77,7 @@ static void dev_deinit(struct fp_img_dev *dev) struct aesX660_dev *aesdev = dev->priv; g_free(aesdev->buffer); g_free(aesdev); - libusb_release_interface(dev->udev, 0); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -107,7 +107,8 @@ struct fp_img_driver aes1660_driver = { .id = AES1660_ID, .name = FP_COMPONENT, .full_name = "AuthenTec AES1660", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, .flags = 0, diff --git a/libfprint/drivers/aes2501.c b/libfprint/drivers/aes2501.c index f6e3edf..5a8c103 100644 --- a/libfprint/drivers/aes2501.c +++ b/libfprint/drivers/aes2501.c @@ -130,7 +130,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, USB_DEV(dev), EP_IN, data, 126, read_regs_data_cb, rdata, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -225,7 +225,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes) } data = g_malloc(bytes); - libusb_fill_bulk_transfer(transfer, ssm->dev->udev, EP_IN, data, bytes, + libusb_fill_bulk_transfer(transfer, USB_DEV(ssm->dev), EP_IN, data, bytes, generic_ignore_data_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -340,7 +340,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, USB_DEV(dev), EP_IN, data, 20, finger_det_data_cb, dev, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -565,7 +565,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, USB_DEV(dev), EP_IN, data, 1705, capture_read_strip_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -848,7 +848,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) /* FIXME check endpoints */ int r; - r = libusb_claim_interface(dev->udev, 0); + r = libusb_claim_interface(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -862,7 +862,7 @@ 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); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -877,7 +877,8 @@ struct fp_img_driver aes2501_driver = { .id = AES2501_ID, .name = FP_COMPONENT, .full_name = "AuthenTec AES2501", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, .flags = 0, diff --git a/libfprint/drivers/aes2550.c b/libfprint/drivers/aes2550.c index 387967e..14c6e43 100644 --- a/libfprint/drivers/aes2550.c +++ b/libfprint/drivers/aes2550.c @@ -141,7 +141,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, USB_DEV(dev), EP_IN, data, AES2550_EP_IN_BUF_SIZE, finger_det_data_cb, dev, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -171,7 +171,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, 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) { @@ -344,7 +344,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, USB_DEV(dev), EP_OUT, capture_reqs, sizeof(capture_reqs), capture_reqs_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); if (r < 0) { @@ -364,7 +364,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, USB_DEV(dev), EP_IN, data, AES2550_EP_IN_BUF_SIZE, capture_read_data_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -382,7 +382,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, 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) { @@ -504,7 +504,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, USB_DEV(dev), EP_OUT, init_reqs, sizeof(init_reqs), init_reqs_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); if (r < 0) { @@ -524,7 +524,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, USB_DEV(dev), EP_IN, data, AES2550_EP_IN_BUF_SIZE, init_read_data_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -542,7 +542,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, USB_DEV(dev), EP_OUT, calibrate_reqs, sizeof(calibrate_reqs), init_reqs_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); if (r < 0) { @@ -562,7 +562,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, USB_DEV(dev), EP_IN, data, AES2550_EP_IN_BUF_SIZE, calibrate_read_data_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -620,7 +620,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) /* TODO check that device has endpoints we're using */ int r; - r = libusb_claim_interface(dev->udev, 0); + r = libusb_claim_interface(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -634,7 +634,7 @@ 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); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -649,7 +649,8 @@ struct fp_img_driver aes2550_driver = { .id = AES2550_ID, .name = FP_COMPONENT, .full_name = "AuthenTec AES2550/AES2810", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, .flags = 0, diff --git a/libfprint/drivers/aes2660.c b/libfprint/drivers/aes2660.c index efe9670..61ec5ee 100644 --- a/libfprint/drivers/aes2660.c +++ b/libfprint/drivers/aes2660.c @@ -51,7 +51,7 @@ 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(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -78,7 +78,7 @@ static void dev_deinit(struct fp_img_dev *dev) struct aesX660_dev *aesdev = dev->priv; g_free(aesdev->buffer); g_free(aesdev); - libusb_release_interface(dev->udev, 0); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -109,7 +109,8 @@ struct fp_img_driver aes2660_driver = { .id = AES2660_ID, .name = FP_COMPONENT, .full_name = "AuthenTec AES2660", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, .flags = 0, diff --git a/libfprint/drivers/aes3500.c b/libfprint/drivers/aes3500.c index f229a1a..806159f 100644 --- a/libfprint/drivers/aes3500.c +++ b/libfprint/drivers/aes3500.c @@ -129,7 +129,7 @@ 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(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -156,7 +156,7 @@ static void dev_deinit(struct fp_img_dev *dev) { struct aes3k_dev *aesdev = dev->priv; g_free(aesdev); - libusb_release_interface(dev->udev, 0); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -171,7 +171,8 @@ struct fp_img_driver aes3500_driver = { .id = AES3500_ID, .name = FP_COMPONENT, .full_name = "AuthenTec AES3500", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_PRESS, }, .flags = 0, diff --git a/libfprint/drivers/aes3k.c b/libfprint/drivers/aes3k.c index ba96901..4d5f9a8 100644 --- a/libfprint/drivers/aes3k.c +++ b/libfprint/drivers/aes3k.c @@ -129,7 +129,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, USB_DEV(dev), EP_IN, data, aesdev->data_buflen, img_cb, dev, 0); r = libusb_submit_transfer(aesdev->img_trf); diff --git a/libfprint/drivers/aes4000.c b/libfprint/drivers/aes4000.c index d4f90b7..a872cfb 100644 --- a/libfprint/drivers/aes4000.c +++ b/libfprint/drivers/aes4000.c @@ -126,7 +126,7 @@ 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(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -153,7 +153,7 @@ static void dev_deinit(struct fp_img_dev *dev) { struct aes3k_dev *aesdev = dev->priv; g_free(aesdev); - libusb_release_interface(dev->udev, 0); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -168,7 +168,8 @@ struct fp_img_driver aes4000_driver = { .id = AES4000_ID, .name = FP_COMPONENT, .full_name = "AuthenTec AES4000", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_PRESS, }, .flags = 0, diff --git a/libfprint/drivers/aesx660.c b/libfprint/drivers/aesx660.c index 278fe81..d5004b2 100644 --- a/libfprint/drivers/aesx660.c +++ b/libfprint/drivers/aesx660.c @@ -58,7 +58,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, USB_DEV(dev), EP_OUT, (unsigned char *)cmd, cmd_len, callback, ssm, timeout); r = libusb_submit_transfer(transfer); @@ -89,7 +89,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, USB_DEV(dev), EP_IN, data, buf_len, callback, ssm, BULK_TIMEOUT); diff --git a/libfprint/drivers/elan.c b/libfprint/drivers/elan.c index 976ce07..8861aff 100644 --- a/libfprint/drivers/elan.c +++ b/libfprint/drivers/elan.c @@ -245,7 +245,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, USB_DEV(dev), elandev->cmds[elandev->cmd_idx].response_in, elandev->last_read, response_len, elan_cmd_cb, ssm, elandev->cmd_timeout); @@ -269,7 +269,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, USB_DEV(dev), ELAN_EP_CMD_OUT, (unsigned char *)elandev->cmds[elandev-> cmd_idx].cmd, ELAN_CMD_LEN, elan_cmd_cb, ssm, @@ -569,7 +569,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) fp_dbg(""); - r = libusb_claim_interface(dev->udev, 0); + r = libusb_claim_interface(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -588,7 +588,7 @@ static void dev_deinit(struct fp_img_dev *dev) elan_dev_reset(elandev); g_free(elandev); - libusb_release_interface(dev->udev, 0); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -616,7 +616,8 @@ struct fp_img_driver elan_driver = { .id = ELAN_ID, .name = FP_COMPONENT, .full_name = "ElanTech Fingerprint Sensor", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, .flags = 0, diff --git a/libfprint/drivers/etes603.c b/libfprint/drivers/etes603.c index 9795757..d764370 100644 --- a/libfprint/drivers/etes603.c +++ b/libfprint/drivers/etes603.c @@ -663,7 +663,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, USB_DEV(idev), ep, buffer, length, cb, cb_arg, BULK_TIMEOUT); if (libusb_submit_transfer(transfer)) { @@ -1463,7 +1463,7 @@ static int dev_open(struct fp_img_dev *idev, unsigned long driver_data) dev->ans = g_malloc(FE_SIZE); dev->fp = g_malloc(FE_SIZE * 4); - ret = libusb_claim_interface(idev->udev, 0); + ret = libusb_claim_interface(USB_DEV(idev), 0); if (ret != LIBUSB_SUCCESS) { fp_err("libusb_claim_interface failed on interface 0: %s", libusb_error_name(ret)); return ret; @@ -1482,7 +1482,7 @@ static void dev_close(struct fp_img_dev *idev) g_free(dev->fp); g_free(dev); - libusb_release_interface(idev->udev, 0); + libusb_release_interface(USB_DEV(idev), 0); fpi_imgdev_close_complete(idev); } @@ -1497,7 +1497,8 @@ struct fp_img_driver etes603_driver = { .id = ETES603_ID, .name = FP_COMPONENT, .full_name = "EgisTec ES603", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, .flags = 0, diff --git a/libfprint/drivers/fdu2000.c b/libfprint/drivers/fdu2000.c index e14b860..6ab241b 100644 --- a/libfprint/drivers/fdu2000.c +++ b/libfprint/drivers/fdu2000.c @@ -176,25 +176,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(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(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(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(USB_DEV(dev), &msg, &bytes, BULK_TIMEOUT * 10); if (r < 0 || bytes < 1) goto read; @@ -235,12 +235,12 @@ read: } } - if ((r = bulk_write_safe(dev->udev, CAPTURE_END))) { + if ((r = bulk_write_safe(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(USB_DEV(dev), LED_OFF))) { fp_err("Command: LED_OFF"); goto out; } @@ -261,27 +261,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(USB_DEV(dev), 1)) < 0 ) // goto out; - if ( (r = libusb_claim_interface(dev->udev, 0)) < 0 ) { + if ( (r = libusb_claim_interface(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(USB_DEV(dev), 1)) < 0 ) // goto out; - //if ( (r = usb_clear_halt(dev->udev, EP_CMD)) < 0 ) + //if ( (r = usb_clear_halt(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(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(USB_DEV(dev), LED_OFF))) { fp_err("Command: LED_OFF"); goto out; } @@ -296,10 +296,10 @@ out: static void dev_exit(struct fp_img_dev *dev) { - if (bulk_write_safe(dev->udev, CAPTURE_END)) + if (bulk_write_safe(USB_DEV(dev), CAPTURE_END)) fp_err("Command: CAPTURE_END"); - libusb_release_interface(dev->udev, 0); + libusb_release_interface(USB_DEV(dev), 0); } static const struct usb_id id_table[] = { @@ -312,7 +312,8 @@ struct fp_img_driver fdu2000_driver = { .id = FDU2000_ID, .name = FP_COMPONENT, .full_name = "Secugen FDU 2000", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_PRESS, }, .img_height = RAW_IMAGE_HEIGTH, diff --git a/libfprint/drivers/upeke2.c b/libfprint/drivers/upeke2.c index 3f05e80..f77a267 100644 --- a/libfprint/drivers/upeke2.c +++ b/libfprint/drivers/upeke2.c @@ -179,7 +179,7 @@ static struct libusb_transfer *alloc_send_cmd_transfer(struct fp_dev *dev, buf[urblen - 2] = crc >> 8; buf[urblen - 1] = crc & 0xff; - libusb_fill_bulk_transfer(transfer, dev->udev, EP_OUT, buf, urblen, + libusb_fill_bulk_transfer(transfer, USB_DEV(dev), EP_OUT, buf, urblen, callback, user_data, TIMEOUT); return transfer; } @@ -430,7 +430,7 @@ static void read_msg_cb(struct libusb_transfer *transfer) fp_dbg("didn't fit in buffer, need to extend by %d bytes", needed); data = g_realloc((gpointer) data, MSG_READ_BUF_SIZE + needed); - libusb_fill_bulk_transfer(etransfer, udata->dev->udev, EP_IN, + libusb_fill_bulk_transfer(etransfer, USB_DEV(udata->dev), EP_IN, data + MSG_READ_BUF_SIZE, needed, read_msg_extend_cb, udata, TIMEOUT); @@ -469,7 +469,7 @@ static int __read_msg_async(struct read_msg_data *udata) return -ENOMEM; } - libusb_fill_bulk_transfer(transfer, udata->dev->udev, EP_IN, buf, + libusb_fill_bulk_transfer(transfer, USB_DEV(udata->dev), EP_IN, buf, MSG_READ_BUF_SIZE, read_msg_cb, udata, TIMEOUT); r = libusb_submit_transfer(transfer); if (r < 0) { @@ -703,7 +703,7 @@ static void initsm_run_state(struct fpi_ssm *ssm) data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1); libusb_fill_control_setup(data, LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, 0x0c, 0x100, 0x0400, 1); - libusb_fill_control_transfer(transfer, ssm->dev->udev, data, + libusb_fill_control_transfer(transfer, USB_DEV(ssm->dev), data, ctrl400_cb, ssm, TIMEOUT); r = libusb_submit_transfer(transfer); @@ -863,7 +863,7 @@ static int dev_init(struct fp_dev *dev, unsigned long driver_data) struct upeke2_dev *upekdev = NULL; int r; - r = libusb_claim_interface(dev->udev, 0); + r = libusb_claim_interface(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -880,7 +880,7 @@ static int dev_init(struct fp_dev *dev, unsigned long driver_data) static void dev_exit(struct fp_dev *dev) { - libusb_release_interface(dev->udev, 0); + libusb_release_interface(USB_DEV(dev), 0); g_free(dev->priv); fpi_drvcb_close_complete(dev); } @@ -1470,9 +1470,10 @@ struct fp_driver upeke2_driver = { .id = UPEKE2_ID, .name = FP_COMPONENT, .full_name = "UPEK Eikon 2", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, - .discover = discover, + .usb_discover = discover, .open = dev_init, .close = dev_exit, .enroll_start = enroll_start, diff --git a/libfprint/drivers/upeksonly.c b/libfprint/drivers/upeksonly.c index e4dce7c..35624ba 100644 --- a/libfprint/drivers/upeksonly.c +++ b/libfprint/drivers/upeksonly.c @@ -599,7 +599,7 @@ static void sm_write_regs(struct fpi_ssm *ssm, data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1); libusb_fill_control_setup(data, 0x40, 0x0c, 0, 0, 1); - libusb_fill_control_transfer(wrdata->transfer, ssm->dev->udev, data, + libusb_fill_control_transfer(wrdata->transfer, USB_DEV(ssm->dev), data, write_regs_cb, wrdata, CTRL_TIMEOUT); wrdata->transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK; @@ -636,7 +636,7 @@ 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, USB_DEV(dev), data, sm_write_reg_cb, ssm, CTRL_TIMEOUT); data[LIBUSB_CONTROL_SETUP_SIZE] = value; @@ -683,7 +683,7 @@ 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, USB_DEV(dev), data, sm_read_reg_cb, ssm, CTRL_TIMEOUT); transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK | LIBUSB_TRANSFER_FREE_TRANSFER; @@ -732,7 +732,7 @@ static void sm_await_intr(struct fpi_ssm *ssm) fp_dbg(""); data = g_malloc(4); - libusb_fill_interrupt_transfer(transfer, dev->udev, 0x83, data, 4, + libusb_fill_interrupt_transfer(transfer, USB_DEV(dev), 0x83, data, 4, sm_await_intr_cb, ssm, 0); transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK | LIBUSB_TRANSFER_FREE_TRANSFER; @@ -1311,7 +1311,7 @@ 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], USB_DEV(dev), 0x81, data, 4096, img_data_cb, &sdev->img_transfer_data[i], 0); } @@ -1336,13 +1336,13 @@ 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(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(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -1375,7 +1375,7 @@ 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); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -1408,9 +1408,10 @@ struct fp_img_driver upeksonly_driver = { .id = UPEKSONLY_ID, .name = FP_COMPONENT, .full_name = "UPEK TouchStrip Sensor-Only", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, - .discover = dev_discover, + .usb_discover = dev_discover, }, .flags = 0, .img_width = -1, diff --git a/libfprint/drivers/upektc.c b/libfprint/drivers/upektc.c index f3d9b8a..c2e2943 100644 --- a/libfprint/drivers/upektc.c +++ b/libfprint/drivers/upektc.c @@ -117,7 +117,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, 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); @@ -138,7 +138,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, USB_DEV(dev), upekdev->ep_in, data, upekdev->setup_commands[upekdev->init_idx].response_len, read_init_data_cb, ssm, BULK_TIMEOUT); @@ -238,7 +238,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, USB_DEV(dev), upekdev->ep_in, data, IMAGE_SIZE, finger_det_data_cb, dev, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -268,7 +268,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, 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); @@ -340,7 +340,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, USB_DEV(dev), upekdev->ep_out, (unsigned char *)scan_cmd, UPEKTC_CMD_LEN, capture_cmd_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -361,7 +361,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, USB_DEV(dev), upekdev->ep_in, data, IMAGE_SIZE, capture_read_data_cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -439,7 +439,7 @@ 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(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -475,7 +475,7 @@ 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); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -490,7 +490,8 @@ struct fp_img_driver upektc_driver = { .id = UPEKTC_ID, .name = FP_COMPONENT, .full_name = "UPEK TouchChip/Eikon Touch 300", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_PRESS, }, .flags = 0, diff --git a/libfprint/drivers/upektc_img.c b/libfprint/drivers/upektc_img.c index 18e271b..15173e4 100644 --- a/libfprint/drivers/upektc_img.c +++ b/libfprint/drivers/upektc_img.c @@ -143,7 +143,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, USB_DEV(dev), EP_OUT, upekdev->cmd, buf_size, cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -169,7 +169,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, USB_DEV(dev), EP_IN, upekdev->response + buf_offset, buf_size, cb, ssm, BULK_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -574,7 +574,7 @@ static void activate_run_state(struct fpi_ssm *ssm) data = g_malloc0(LIBUSB_CONTROL_SETUP_SIZE + 1); libusb_fill_control_setup(data, LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, 0x0c, 0x100, 0x0400, 1); - libusb_fill_control_transfer(transfer, ssm->dev->udev, data, + libusb_fill_control_transfer(transfer, USB_DEV(ssm->dev), data, init_reqs_ctrl_cb, ssm, CTRL_TIMEOUT); r = libusb_submit_transfer(transfer); if (r < 0) { @@ -649,7 +649,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) /* TODO check that device has endpoints we're using */ int r; - r = libusb_claim_interface(dev->udev, 0); + r = libusb_claim_interface(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -663,7 +663,7 @@ 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); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -692,9 +692,10 @@ struct fp_img_driver upektc_img_driver = { .id = UPEKTC_IMG_ID, .name = FP_COMPONENT, .full_name = "Upek TouchChip Fingerprint Coprocessor", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, - .discover = discover, + .usb_discover = discover, }, .flags = 0, .img_height = IMAGE_HEIGHT, diff --git a/libfprint/drivers/upekts.c b/libfprint/drivers/upekts.c index b297127..e0332c6 100644 --- a/libfprint/drivers/upekts.c +++ b/libfprint/drivers/upekts.c @@ -173,7 +173,7 @@ static struct libusb_transfer *alloc_send_cmd_transfer(struct fp_dev *dev, buf[urblen - 2] = crc >> 8; buf[urblen - 1] = crc & 0xff; - libusb_fill_bulk_transfer(transfer, dev->udev, EP_OUT, buf, urblen, + libusb_fill_bulk_transfer(transfer, USB_DEV(dev), EP_OUT, buf, urblen, callback, user_data, TIMEOUT); return transfer; } @@ -424,7 +424,7 @@ static void read_msg_cb(struct libusb_transfer *transfer) fp_dbg("didn't fit in buffer, need to extend by %d bytes", needed); data = g_realloc((gpointer) data, MSG_READ_BUF_SIZE + needed); - libusb_fill_bulk_transfer(etransfer, udata->dev->udev, EP_IN, + libusb_fill_bulk_transfer(etransfer, USB_DEV(udata->dev), EP_IN, data + MSG_READ_BUF_SIZE, needed, read_msg_extend_cb, udata, TIMEOUT); @@ -463,7 +463,7 @@ static int __read_msg_async(struct read_msg_data *udata) return -ENOMEM; } - libusb_fill_bulk_transfer(transfer, udata->dev->udev, EP_IN, buf, + libusb_fill_bulk_transfer(transfer, USB_DEV(udata->dev), EP_IN, buf, MSG_READ_BUF_SIZE, read_msg_cb, udata, TIMEOUT); r = libusb_submit_transfer(transfer); if (r < 0) { @@ -717,7 +717,7 @@ static void initsm_run_state(struct fpi_ssm *ssm) data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1); libusb_fill_control_setup(data, LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, 0x0c, 0x100, 0x0400, 1); - libusb_fill_control_transfer(transfer, ssm->dev->udev, data, + libusb_fill_control_transfer(transfer, USB_DEV(ssm->dev), data, ctrl400_cb, ssm, TIMEOUT); r = libusb_submit_transfer(transfer); @@ -874,7 +874,7 @@ static int dev_init(struct fp_dev *dev, unsigned long driver_data) struct upekts_dev *upekdev = NULL; int r; - r = libusb_claim_interface(dev->udev, 0); + r = libusb_claim_interface(USB_DEV(dev), 0); if (r < 0) { fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; @@ -891,7 +891,7 @@ static int dev_init(struct fp_dev *dev, unsigned long driver_data) static void dev_exit(struct fp_dev *dev) { - libusb_release_interface(dev->udev, 0); + libusb_release_interface(USB_DEV(dev), 0); g_free(dev->priv); fpi_drvcb_close_complete(dev); } @@ -1475,7 +1475,8 @@ struct fp_driver upekts_driver = { .id = UPEKTS_ID, .name = FP_COMPONENT, .full_name = "UPEK TouchStrip", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, .open = dev_init, .close = dev_exit, diff --git a/libfprint/drivers/uru4000.c b/libfprint/drivers/uru4000.c index ae32a6b..aa6a9b8 100644 --- a/libfprint/drivers/uru4000.c +++ b/libfprint/drivers/uru4000.c @@ -208,7 +208,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, USB_DEV(dev), data, write_regs_cb, wrdata, CTRL_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -274,7 +274,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, USB_DEV(dev), data, read_regs_cb, rrdata, CTRL_TIMEOUT); r = libusb_submit_transfer(transfer); @@ -442,7 +442,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, USB_DEV(dev), EP_INTR, data, IRQ_LENGTH, irq_handler, dev, 0); urudev->irq_transfer = transfer; @@ -709,7 +709,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, 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) @@ -1264,7 +1264,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(USB_DEV(dev)), 0, &config); if (r < 0) { fp_err("Failed to get config descriptor"); return r; @@ -1318,7 +1318,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(USB_DEV(dev), iface_desc->bInterfaceNumber); if (r < 0) { fp_err("interface claim failed: %s", libusb_error_name(r)); goto out; @@ -1375,7 +1375,7 @@ static void dev_deinit(struct fp_img_dev *dev) SECITEM_FreeItem(urudev->param, PR_TRUE); if (urudev->slot) PK11_FreeSlot(urudev->slot); - libusb_release_interface(dev->udev, urudev->interface); + libusb_release_interface(USB_DEV(dev), urudev->interface); g_free(urudev); fpi_imgdev_close_complete(dev); } @@ -1411,7 +1411,8 @@ struct fp_img_driver uru4000_driver = { .id = URU4000_ID, .name = FP_COMPONENT, .full_name = "Digital Persona U.are.U 4000/4000B/4500", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_PRESS, }, .flags = FP_IMGDRV_SUPPORTS_UNCONDITIONAL_CAPTURE, diff --git a/libfprint/drivers/vcom5s.c b/libfprint/drivers/vcom5s.c index 1f127a8..0431ea9 100644 --- a/libfprint/drivers/vcom5s.c +++ b/libfprint/drivers/vcom5s.c @@ -109,7 +109,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, USB_DEV(dev), data, sm_write_reg_cb, ssm, CTRL_TIMEOUT); r = libusb_submit_transfer(transfer); if (r < 0) { @@ -148,7 +148,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, USB_DEV(dev), data, sm_exec_cmd_cb, ssm, CTRL_TIMEOUT); r = libusb_submit_transfer(transfer); if (r < 0) { @@ -239,7 +239,7 @@ static void capture_iterate(struct fpi_ssm *ssm) return; } - libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, + libusb_fill_bulk_transfer(transfer, 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; @@ -346,7 +346,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) int r; dev->priv = g_malloc0(sizeof(struct v5s_dev)); - r = libusb_claim_interface(dev->udev, 0); + r = libusb_claim_interface(USB_DEV(dev), 0); if (r < 0) fp_err("could not claim interface 0: %s", libusb_error_name(r)); @@ -359,7 +359,7 @@ 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); + libusb_release_interface(USB_DEV(dev), 0); fpi_imgdev_close_complete(dev); } @@ -373,7 +373,8 @@ struct fp_img_driver vcom5s_driver = { .id = VCOM5S_ID, .name = FP_COMPONENT, .full_name = "Veridicom 5thSense", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_PRESS, }, .flags = 0, diff --git a/libfprint/drivers/vfs0050.c b/libfprint/drivers/vfs0050.c index 31d793c..57b544a 100644 --- a/libfprint/drivers/vfs0050.c +++ b/libfprint/drivers/vfs0050.c @@ -59,12 +59,11 @@ 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 = ssm->priv; - struct libusb_device_handle *udev = idev->udev; struct vfs_dev_t *vdev = idev->priv; vdev->transfer = libusb_alloc_transfer(0); vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER; - libusb_fill_bulk_transfer(vdev->transfer, udev, 0x01, data, len, + libusb_fill_bulk_transfer(vdev->transfer, USB_DEV(idev), 0x01, data, len, async_write_callback, ssm, VFS_USB_TIMEOUT); libusb_submit_transfer(vdev->transfer); } @@ -101,7 +100,6 @@ 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 = ssm->priv; - struct libusb_device_handle *udev = idev->udev; struct vfs_dev_t *vdev = idev->priv; ep |= LIBUSB_ENDPOINT_IN; @@ -111,11 +109,11 @@ static void async_read(struct fpi_ssm *ssm, int ep, void *data, int len) /* 0x83 is the only interrupt endpoint */ if (ep == EP3_IN) - libusb_fill_interrupt_transfer(vdev->transfer, udev, ep, data, + libusb_fill_interrupt_transfer(vdev->transfer, USB_DEV(idev), ep, data, len, async_read_callback, ssm, VFS_USB_TIMEOUT); else - libusb_fill_bulk_transfer(vdev->transfer, udev, ep, data, len, + libusb_fill_bulk_transfer(vdev->transfer, USB_DEV(idev), ep, data, len, async_read_callback, ssm, VFS_USB_TIMEOUT); libusb_submit_transfer(vdev->transfer); @@ -155,7 +153,6 @@ static void async_abort_callback(struct libusb_transfer *transfer) static void async_abort(struct fpi_ssm *ssm, int ep) { struct fp_img_dev *idev = ssm->priv; - struct libusb_device_handle *udev = idev->udev; struct vfs_dev_t *vdev = idev->priv; int len = VFS_USB_BUFFER_SIZE; @@ -169,11 +166,11 @@ static void async_abort(struct fpi_ssm *ssm, int ep) /* 0x83 is the only interrupt endpoint */ if (ep == EP3_IN) - libusb_fill_interrupt_transfer(vdev->transfer, udev, ep, data, + libusb_fill_interrupt_transfer(vdev->transfer, USB_DEV(idev), ep, data, len, async_abort_callback, ssm, VFS_USB_ABORT_TIMEOUT); else - libusb_fill_bulk_transfer(vdev->transfer, udev, ep, data, len, + libusb_fill_bulk_transfer(vdev->transfer, USB_DEV(idev), ep, data, len, async_abort_callback, ssm, VFS_USB_ABORT_TIMEOUT); libusb_submit_transfer(vdev->transfer); @@ -526,7 +523,6 @@ static void scan_completed(void *data) static void activate_ssm(struct fpi_ssm *ssm) { struct fp_img_dev *idev = ssm->priv; - struct libusb_device_handle *udev = idev->udev; struct vfs_dev_t *vdev = idev->priv; switch (ssm->cur_state) { @@ -582,7 +578,7 @@ static void activate_ssm(struct fpi_ssm *ssm) /* Asyncronously enquire an interrupt */ vdev->transfer = libusb_alloc_transfer(0); vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER; - libusb_fill_interrupt_transfer(vdev->transfer, udev, 0x83, + libusb_fill_interrupt_transfer(vdev->transfer, USB_DEV(idev), 0x83, vdev->interrupt, VFS_INTERRUPT_SIZE, interrupt_callback, ssm, 0); @@ -632,7 +628,7 @@ static void activate_ssm(struct fpi_ssm *ssm) /* Receive chunk of data */ vdev->transfer = libusb_alloc_transfer(0); vdev->transfer->flags |= LIBUSB_TRANSFER_FREE_TRANSFER; - libusb_fill_bulk_transfer(vdev->transfer, udev, 0x82, + libusb_fill_bulk_transfer(vdev->transfer, USB_DEV(idev), 0x82, (void *)vdev->lines_buffer + vdev->bytes, VFS_USB_BUFFER_SIZE, receive_callback, ssm, @@ -729,7 +725,7 @@ static void dev_open_callback(struct fpi_ssm *ssm) static int dev_open(struct fp_img_dev *idev, unsigned long driver_data) { /* Claim usb interface */ - int error = libusb_claim_interface(idev->udev, 0); + int error = libusb_claim_interface(USB_DEV(idev), 0); if (error < 0) { /* Interface not claimed, return error */ fp_err("could not claim interface 0"); @@ -754,7 +750,7 @@ static void dev_close(struct fp_img_dev *idev) g_free(idev->priv); /* Release usb interface */ - libusb_release_interface(idev->udev, 0); + libusb_release_interface(USB_DEV(idev), 0); /* Notify close complete */ fpi_imgdev_close_complete(idev); @@ -773,7 +769,8 @@ struct fp_img_driver vfs0050_driver = { .id = VFS0050_ID, .name = FP_COMPONENT, .full_name = "Validity VFS0050", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, diff --git a/libfprint/drivers/vfs101.c b/libfprint/drivers/vfs101.c index 3ee13e3..0f0c8dd 100644 --- a/libfprint/drivers/vfs101.c +++ b/libfprint/drivers/vfs101.c @@ -271,7 +271,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, USB_DEV(dev), EP_OUT(1), vdev->buffer, vdev->length, async_send_cb, ssm, BULK_TIMEOUT); /* Submit transfer */ r = libusb_submit_transfer(vdev->transfer); @@ -353,7 +353,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, USB_DEV(dev), EP_IN(1), vdev->buffer, 0x0f, async_recv_cb, ssm, BULK_TIMEOUT); /* Submit transfer */ r = libusb_submit_transfer(vdev->transfer); @@ -458,7 +458,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, USB_DEV(dev), EP_IN(2), buffer, VFS_BLOCK_SIZE, async_load_cb, ssm, BULK_TIMEOUT); /* Submit transfer */ r = libusb_submit_transfer(vdev->transfer); @@ -1500,7 +1500,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(USB_DEV(dev), 0); if (r < 0) { /* Interface not claimed, return error */ @@ -1526,7 +1526,7 @@ static void dev_close(struct fp_img_dev *dev) g_free(dev->priv); /* Release usb interface */ - libusb_release_interface(dev->udev, 0); + libusb_release_interface(USB_DEV(dev), 0); /* Notify close complete */ fpi_imgdev_close_complete(dev); @@ -1548,7 +1548,8 @@ struct fp_img_driver vfs101_driver = .id = VFS101_ID, .name = FP_COMPONENT, .full_name = "Validity VFS101", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, diff --git a/libfprint/drivers/vfs301.c b/libfprint/drivers/vfs301.c index 833c05b..c8b6e25 100644 --- a/libfprint/drivers/vfs301.c +++ b/libfprint/drivers/vfs301.c @@ -122,7 +122,7 @@ static void m_loop_state(struct fpi_ssm *ssm) switch (ssm->cur_state) { case M_REQUEST_PRINT: - vfs301_proto_request_fingerprint(dev->udev, vdev); + vfs301_proto_request_fingerprint(USB_DEV(dev), vdev); fpi_ssm_next_state(ssm); break; @@ -132,7 +132,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(USB_DEV(dev), vdev)) fpi_ssm_jump_to_state(ssm, M_WAIT_PRINT); else fpi_ssm_next_state(ssm); @@ -140,7 +140,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(USB_DEV(dev), vdev); fpi_ssm_next_state(ssm); break; @@ -151,7 +151,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(USB_DEV(dev), vdev); assert(rv != VFS301_FAILURE); if (rv == VFS301_ONGOING) fpi_ssm_jump_to_state(ssm, M_READ_PRINT_WAIT); @@ -187,7 +187,7 @@ static void m_init_state(struct fpi_ssm *ssm) assert(ssm->cur_state == 0); - vfs301_proto_init(dev->udev, vdev); + vfs301_proto_init(USB_DEV(dev), vdev); fpi_ssm_mark_completed(ssm); } @@ -237,7 +237,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(USB_DEV(dev), 0); if (r < 0) { /* Interface not claimed, return error */ fp_err("could not claim interface 0: %s", libusb_error_name(r)); @@ -264,7 +264,7 @@ static void dev_close(struct fp_img_dev *dev) g_free(dev->priv); /* Release usb interface */ - libusb_release_interface(dev->udev, 0); + libusb_release_interface(USB_DEV(dev), 0); /* Notify close complete */ fpi_imgdev_close_complete(dev); @@ -287,7 +287,8 @@ struct fp_img_driver vfs301_driver = .id = VFS301_ID, .name = FP_COMPONENT, .full_name = "Validity VFS301", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, diff --git a/libfprint/drivers/vfs5011.c b/libfprint/drivers/vfs5011.c index facb32c..fc5db0e 100644 --- a/libfprint/drivers/vfs5011.c +++ b/libfprint/drivers/vfs5011.c @@ -203,7 +203,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, data->device->desc.usb_dev, action->endpoint, action->data, action->size, async_send_cb, ssm, data->timeout); @@ -219,7 +219,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, data->device->desc.usb_dev, action->endpoint, data->receive_buf, action->size, async_recv_cb, ssm, data->timeout); @@ -702,7 +702,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, USB_DEV(dev), CAPTURE_LINES, READ_TIMEOUT, ssm); if (r != 0) { fp_err("Failed to capture data"); @@ -807,13 +807,13 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data) (unsigned char *)g_malloc0(CAPTURE_LINES * VFS5011_LINE_SIZE); dev->priv = data; - r = libusb_reset_device(dev->udev); + r = libusb_reset_device(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(USB_DEV(dev), 0); if (r != 0) { fp_err("Failed to claim interface: %s", libusb_error_name(r)); return r; @@ -829,7 +829,7 @@ 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); + libusb_release_interface(USB_DEV(dev), 0); struct vfs5011_data *data = (struct vfs5011_data *)dev->priv; if (data != NULL) { g_free(data->capture_buffer); @@ -893,7 +893,8 @@ struct fp_img_driver vfs5011_driver = { .id = VFS5011_ID, .name = "vfs5011", .full_name = "Validity VFS5011", - .id_table = id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = id_table, .scan_type = FP_SCAN_TYPE_SWIPE, }, diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h index 7897a2e..163b48a 100644 --- a/libfprint/fp_internal.h +++ b/libfprint/fp_internal.h @@ -97,11 +97,24 @@ enum fp_dev_state { DEV_STATE_CAPTURE_STOPPING, }; +enum fp_bus { + DRIVER_TYPE_USB, + DRIVER_TYPE_SPI, + DRIVER_TYPE_VIRTUAL +}; + struct fp_driver **fprint_get_drivers (void); +#define USB_DEV(dev) dev->desc.usb_dev +#define I2C_DEV(dev) dev->desc.i2c_dev + struct fp_dev { struct fp_driver *drv; - libusb_device_handle *udev; + enum fp_bus bus; + union { + libusb_device_handle *usb_dev; + int i2c_dev; + } desc; uint32_t devtype; void *priv; @@ -174,7 +187,11 @@ enum fp_imgdev_verify_state { struct fp_img_dev { struct fp_dev *dev; - libusb_device_handle *udev; + enum fp_bus bus; + union { + libusb_device_handle *usb_dev; + int i2cdev; + } desc; enum fp_imgdev_action action; int action_state; @@ -208,14 +225,19 @@ struct fp_driver { const uint16_t id; const char *name; const char *full_name; - const struct usb_id * const id_table; + enum fp_bus bus; + union { + const struct usb_id * const usb_id_table; + const char * const *i2c_id_table; + const char * virtual_envvar; + } driver_id; enum fp_driver_type type; enum fp_scan_type scan_type; void *priv; /* Device operations */ - int (*discover)(struct libusb_device_descriptor *dsc, uint32_t *devtype); + int (*usb_discover)(struct libusb_device_descriptor *dsc, uint32_t *devtype); int (*open)(struct fp_dev *dev, unsigned long driver_data); void (*close)(struct fp_dev *dev); int (*enroll_start)(struct fp_dev *dev); @@ -321,7 +343,11 @@ void fpi_img_driver_setup(struct fp_img_driver *idriver); container_of((drv), struct fp_img_driver, driver) struct fp_dscv_dev { - struct libusb_device *udev; + enum fp_bus bus; + union { + struct libusb_device *usb_dev; + char *spi_path; + } dev; struct fp_driver *drv; unsigned long driver_data; uint32_t devtype; diff --git a/libfprint/fprint-list-udev-rules.c b/libfprint/fprint-list-udev-rules.c index f78ede1..66ed6f0 100644 --- a/libfprint/fprint-list-udev-rules.c +++ b/libfprint/fprint-list-udev-rules.c @@ -44,7 +44,8 @@ static const struct usb_id blacklist_id_table[] = { }; struct fp_driver whitelist = { - .id_table = whitelist_id_table, + .bus = DRIVER_TYPE_USB, + .driver_id.usb_id_table = whitelist_id_table, .full_name = "Hardcoded whitelist" }; @@ -53,16 +54,22 @@ GHashTable *printed = NULL; static void print_driver (struct fp_driver *driver) { int i, j, blacklist, num_printed; + const struct usb_id * usb_id_table; num_printed = 0; - for (i = 0; driver->id_table[i].vendor != 0; i++) { + if (driver->bus != DRIVER_TYPE_USB) + return; + + usb_id_table = driver->driver_id.usb_id_table; + + for (i = 0; usb_id_table[i].vendor != 0; i++) { char *key; blacklist = 0; for (j = 0; blacklist_id_table[j].vendor != 0; j++) { - if (driver->id_table[i].vendor == blacklist_id_table[j].vendor && - driver->id_table[i].product == blacklist_id_table[j].product) { + if (usb_id_table[i].vendor == blacklist_id_table[j].vendor && + usb_id_table[i].product == blacklist_id_table[j].product) { blacklist = 1; break; } @@ -70,7 +77,7 @@ static void print_driver (struct fp_driver *driver) if (blacklist) continue; - key = g_strdup_printf ("%04x:%04x", driver->id_table[i].vendor, driver->id_table[i].product); + key = g_strdup_printf ("%04x:%04x", usb_id_table[i].vendor, usb_id_table[i].product); if (g_hash_table_lookup (printed, key) != NULL) { g_free (key); @@ -82,8 +89,8 @@ static void print_driver (struct fp_driver *driver) if (num_printed == 0) printf ("# %s\n", driver->full_name); - printf ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ATTRS{dev}==\"*\", TEST==\"power/control\", ATTR{power/control}=\"auto\"\n", driver->id_table[i].vendor, driver->id_table[i].product); - printf ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ENV{LIBFPRINT_DRIVER}=\"%s\"\n", driver->id_table[i].vendor, driver->id_table[i].product, driver->full_name); + printf ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ATTRS{dev}==\"*\", TEST==\"power/control\", ATTR{power/control}=\"auto\"\n", usb_id_table[i].vendor, usb_id_table[i].product); + printf ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ENV{LIBFPRINT_DRIVER}=\"%s\"\n", usb_id_table[i].vendor, usb_id_table[i].product, driver->full_name); num_printed++; } diff --git a/libfprint/imgdev.c b/libfprint/imgdev.c index 4408c23..b363f2f 100644 --- a/libfprint/imgdev.c +++ b/libfprint/imgdev.c @@ -34,12 +34,14 @@ static int img_dev_open(struct fp_dev *dev, unsigned long driver_data) int r = 0; imgdev->dev = dev; + imgdev->bus = dev->bus; imgdev->enroll_stage = 0; dev->priv = imgdev; dev->nr_enroll_stages = IMG_ENROLL_STAGES; /* for consistency in driver code, allow udev access through imgdev */ - imgdev->udev = dev->udev; + if (imgdev->bus == DRIVER_TYPE_USB) + USB_DEV(imgdev) = USB_DEV(dev); if (imgdrv->open) { r = imgdrv->open(imgdev, driver_data); -- 2.17.0