aes1610: Port driver to new API

This commit is contained in:
Benjamin Berg 2019-07-08 15:38:46 +02:00
parent 7ef64b5f5f
commit 5e05afecf2
2 changed files with 188 additions and 214 deletions

View file

@ -28,8 +28,8 @@
#include "drivers_api.h" #include "drivers_api.h"
#include "aeslib.h" #include "aeslib.h"
static void start_capture(struct fp_img_dev *dev); static void start_capture(FpImageDevice *dev);
static void complete_deactivation(struct fp_img_dev *dev); static void complete_deactivation(FpImageDevice *dev);
static int adjust_gain(unsigned char *buffer, int status); static int adjust_gain(unsigned char *buffer, int status);
#define FIRST_AES1610_REG 0x1B #define FIRST_AES1610_REG 0x1B
@ -39,8 +39,8 @@ static int adjust_gain(unsigned char *buffer, int status);
#define GAIN_STATUS_NORMAL 2 #define GAIN_STATUS_NORMAL 2
/* FIXME these need checking */ /* FIXME these need checking */
#define EP_IN (1 | LIBUSB_ENDPOINT_IN) #define EP_IN (1 | FPI_USB_ENDPOINT_IN)
#define EP_OUT (2 | LIBUSB_ENDPOINT_OUT) #define EP_OUT (2 | FPI_USB_ENDPOINT_OUT)
#define BULK_TIMEOUT 4000 #define BULK_TIMEOUT 4000
@ -69,13 +69,18 @@ static int adjust_gain(unsigned char *buffer, int status);
/****** GENERAL FUNCTIONS ******/ /****** GENERAL FUNCTIONS ******/
struct aes1610_dev { struct _FpiDeviceAes1610 {
uint8_t read_regs_retry_count; FpImageDevice parent;
guint8 read_regs_retry_count;
GSList *strips; GSList *strips;
size_t strips_len; gsize strips_len;
gboolean deactivating; gboolean deactivating;
uint8_t blanks_count; guint8 blanks_count;
}; };
G_DECLARE_FINAL_TYPE(FpiDeviceAes1610, fpi_device_aes1610, FPI, DEVICE_AES1610,
FpImageDevice);
G_DEFINE_TYPE(FpiDeviceAes1610, fpi_device_aes1610, FP_TYPE_IMAGE_DEVICE);
static struct fpi_frame_asmbl_ctx assembling_ctx = { static struct fpi_frame_asmbl_ctx assembling_ctx = {
.frame_width = FRAME_WIDTH, .frame_width = FRAME_WIDTH,
@ -84,67 +89,62 @@ static struct fpi_frame_asmbl_ctx assembling_ctx = {
.get_pixel = aes_get_pixel, .get_pixel = aes_get_pixel,
}; };
typedef void (*aes1610_read_regs_cb)(struct fp_img_dev *dev, int status, typedef void (*aes1610_read_regs_cb)(FpImageDevice *dev, int status,
unsigned char *regs, void *user_data); unsigned char *regs, void *user_data);
struct aes1610_read_regs { struct aes1610_read_regs {
struct fp_img_dev *dev; FpImageDevice *dev;
aes1610_read_regs_cb callback; aes1610_read_regs_cb callback;
struct aes_regwrite *regwrite; struct aes_regwrite *regwrite;
void *user_data; void *user_data;
}; };
/* FIXME: what to do here? */ /* FIXME: what to do here? */
static void stub_capture_stop_cb(struct fp_img_dev *dev, int result, void *user_data) static void stub_capture_stop_cb(FpImageDevice *dev, GError *error,
void *user_data)
{ {
if (error) {
fp_warn ("Error stopping capture: %s", error->message);
g_error_free (error);
}
} }
/* check that read succeeded but ignore all data */ /* check that read succeeded but ignore all data */
static void generic_ignore_data_cb(struct libusb_transfer *transfer) static void generic_ignore_data_cb(FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
{ {
fpi_ssm *ssm = transfer->user_data; if (error)
fpi_ssm_mark_failed(transfer->ssm, error);
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
fpi_ssm_mark_failed(ssm, -EIO);
else if (transfer->length != transfer->actual_length)
fpi_ssm_mark_failed(ssm, -EPROTO);
else else
fpi_ssm_next_state(ssm); fpi_ssm_next_state(transfer->ssm);
g_free(transfer->buffer);
libusb_free_transfer(transfer);
} }
static void generic_write_regv_cb(struct fp_img_dev *dev, int result, static void generic_write_regv_cb(FpImageDevice *dev, GError *error,
void *user_data) void *user_data)
{ {
fpi_ssm *ssm = user_data; FpiSsm *ssm = user_data;
if (result == 0) if (!error)
fpi_ssm_next_state(ssm); fpi_ssm_next_state(ssm);
else else
fpi_ssm_mark_failed(ssm, result); fpi_ssm_mark_failed(ssm, error);
} }
/* read the specified number of bytes from the IN endpoint but throw them /* read the specified number of bytes from the IN endpoint but throw them
* away, then increment the SSM */ * away, then increment the SSM */
static void generic_read_ignore_data(fpi_ssm *ssm, struct fp_dev *dev, size_t bytes) static void generic_read_ignore_data(FpiSsm *ssm, FpDevice *dev,
size_t bytes)
{ {
struct libusb_transfer *transfer = fpi_usb_alloc(); FpiUsbTransfer *transfer = fpi_usb_transfer_new(dev);
unsigned char *data; unsigned char *data;
int r;
data = g_malloc(bytes); data = g_malloc(bytes);
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(dev), EP_IN, data, bytes, fpi_usb_transfer_fill_bulk_full(transfer, EP_IN, data, bytes, NULL);
generic_ignore_data_cb, ssm, BULK_TIMEOUT); transfer->ssm = ssm;
transfer->short_is_error = TRUE;
r = libusb_submit_transfer(transfer); fpi_usb_transfer_submit(transfer, BULK_TIMEOUT, NULL,
if (r < 0) { generic_ignore_data_cb, NULL);
g_free(data); fpi_usb_transfer_unref(transfer);
libusb_free_transfer(transfer);
fpi_ssm_mark_failed(ssm, r);
}
} }
/****** FINGER PRESENCE DETECTION ******/ /****** FINGER PRESENCE DETECTION ******/
@ -175,21 +175,19 @@ static const struct aes_regwrite finger_det_reqs[] = {
{ 0x81, 0x04 } { 0x81, 0x04 }
}; };
static void start_finger_detection(struct fp_img_dev *dev); static void start_finger_detection(FpImageDevice *dev);
static void finger_det_data_cb(struct libusb_transfer *transfer) static void finger_det_data_cb(FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
{ {
struct fp_img_dev *dev = transfer->user_data; FpImageDevice *dev = FP_IMAGE_DEVICE(device);
unsigned char *data = transfer->buffer; unsigned char *data = transfer->buffer;
int i; int i;
int sum = 0; int sum = 0;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { if (error) {
fpi_imgdev_session_error(dev, -EIO); fpi_image_device_session_error (dev, error);
goto out; return;
} else if (transfer->length != transfer->actual_length) {
fpi_imgdev_session_error(dev, -EPROTO);
goto out;
} }
/* examine histogram to determine finger presence */ /* examine histogram to determine finger presence */
@ -199,48 +197,37 @@ static void finger_det_data_cb(struct libusb_transfer *transfer)
/* reset default gain */ /* reset default gain */
adjust_gain(data,GAIN_STATUS_FIRST); adjust_gain(data,GAIN_STATUS_FIRST);
/* finger present, start capturing */ /* finger present, start capturing */
fpi_imgdev_report_finger_status(dev, TRUE); fpi_image_device_report_finger_status(dev, TRUE);
start_capture(dev); start_capture(dev);
} else { } else {
/* no finger, poll for a new histogram */ /* no finger, poll for a new histogram */
start_finger_detection(dev); start_finger_detection(dev);
} }
out:
g_free(data);
libusb_free_transfer(transfer);
} }
static void finger_det_reqs_cb(struct fp_img_dev *dev, int result, void *user_data) static void finger_det_reqs_cb(FpImageDevice *dev, GError *error,
void *user_data)
{ {
struct libusb_transfer *transfer; FpiUsbTransfer *transfer;
unsigned char *data;
int r;
if (result) { if (error) {
fpi_imgdev_session_error(dev, result); fpi_image_device_session_error(dev, error);
return; return;
} }
transfer = fpi_usb_alloc(); transfer = fpi_usb_transfer_new(FP_DEVICE(dev));
data = g_malloc(FINGER_DETECTION_LEN); fpi_usb_transfer_fill_bulk (transfer, EP_IN, FINGER_DETECTION_LEN);
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, FINGER_DETECTION_LEN, transfer->short_is_error = TRUE;
finger_det_data_cb, dev, BULK_TIMEOUT); fpi_usb_transfer_submit(transfer, BULK_TIMEOUT, NULL,
finger_det_data_cb, NULL);
r = libusb_submit_transfer(transfer); fpi_usb_transfer_unref(transfer);
if (r < 0) {
g_free(data);
libusb_free_transfer(transfer);
fpi_imgdev_session_error(dev, r);
}
} }
static void start_finger_detection(struct fp_img_dev *dev) static void start_finger_detection(FpImageDevice *dev)
{ {
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev)); FpiDeviceAes1610 *self = FPI_DEVICE_AES1610(dev);
if (aesdev->deactivating) { if (self->deactivating) {
complete_deactivation(dev); complete_deactivation(dev);
return; return;
} }
@ -545,21 +532,18 @@ enum capture_states {
CAPTURE_NUM_STATES, CAPTURE_NUM_STATES,
}; };
static void capture_read_strip_cb(struct libusb_transfer *transfer) static void capture_read_strip_cb(FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
{ {
unsigned char *stripdata; unsigned char *stripdata;
fpi_ssm *ssm = transfer->user_data; FpImageDevice *dev = FP_IMAGE_DEVICE (device);
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm); FpiDeviceAes1610 *self = FPI_DEVICE_AES1610(dev);
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
unsigned char *data = transfer->buffer; unsigned char *data = transfer->buffer;
int sum, i; gint sum, i;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { if (error) {
fpi_ssm_mark_failed(ssm, -EIO); fpi_ssm_mark_failed (transfer->ssm, error);
goto out; return;
} else if (transfer->length != transfer->actual_length) {
fpi_ssm_mark_failed(ssm, -EPROTO);
goto out;
} }
/* FIXME: would preallocating strip buffers be a decent optimization? */ /* FIXME: would preallocating strip buffers be a decent optimization? */
@ -572,6 +556,7 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
sum += data[i]; sum += data[i];
} }
fp_dbg("sum=%d", sum);
if (sum > 0) { if (sum > 0) {
/* FIXME: would preallocating strip buffers be a decent optimization? */ /* FIXME: would preallocating strip buffers be a decent optimization? */
struct fpi_frame *stripe = g_malloc(FRAME_WIDTH * (FRAME_HEIGHT / 2) + sizeof(struct fpi_frame)); struct fpi_frame *stripe = g_malloc(FRAME_WIDTH * (FRAME_HEIGHT / 2) + sizeof(struct fpi_frame));
@ -579,66 +564,57 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
stripe->delta_y = 0; stripe->delta_y = 0;
stripdata = stripe->data; stripdata = stripe->data;
memcpy(stripdata, data + 1, FRAME_WIDTH * (FRAME_HEIGHT / 2)); memcpy(stripdata, data + 1, FRAME_WIDTH * (FRAME_HEIGHT / 2));
aesdev->strips = g_slist_prepend(aesdev->strips, stripe); self->strips = g_slist_prepend(self->strips, stripe);
aesdev->strips_len++; self->strips_len++;
aesdev->blanks_count = 0; self->blanks_count = 0;
} } else {
/* FIXME: 0 might be too low as a threshold */
/* FIXME: sometimes we get 0 in the middle of a scan, should we wait for
* a few consecutive zeroes? */
if (sum < 0) { /* sum cannot be negative, so is 0 */
fpi_ssm_mark_failed(ssm, sum); self->blanks_count++;
goto out;
}
fp_dbg("sum=%d", sum);
/* FIXME: 0 might be too low as a threshold */
/* FIXME: sometimes we get 0 in the middle of a scan, should we wait for
* a few consecutive zeroes? */
/* If sum is 0 for a reasonable # of frames, finger has been removed */
if (sum == 0) {
aesdev->blanks_count++;
fp_dbg("got blank frame"); fp_dbg("got blank frame");
} }
/* use histogram data above for gain calibration (0xbd, 0xbe, 0x29 and 0x2A ) */ /* use histogram data above for gain calibration (0xbd, 0xbe, 0x29 and 0x2A ) */
adjust_gain(data, GAIN_STATUS_NORMAL); adjust_gain(data, GAIN_STATUS_NORMAL);
/* stop capturing if MAX_FRAMES is reached */ /* stop capturing if MAX_FRAMES is reached */
if (aesdev->blanks_count > 10 || g_slist_length(aesdev->strips) >= MAX_FRAMES) { if (self->blanks_count > 10 || g_slist_length(self->strips) >= MAX_FRAMES) {
struct fp_img *img; FpImage *img;
fp_dbg("sending stop capture.... blanks=%d frames=%d", aesdev->blanks_count, g_slist_length(aesdev->strips)); fp_dbg("sending stop capture.... blanks=%d frames=%d",
self->blanks_count, g_slist_length(self->strips));
/* send stop capture bits */ /* send stop capture bits */
aes_write_regv(dev, capture_stop, G_N_ELEMENTS(capture_stop), stub_capture_stop_cb, NULL); aes_write_regv(dev, capture_stop, G_N_ELEMENTS(capture_stop), stub_capture_stop_cb, NULL);
aesdev->strips = g_slist_reverse(aesdev->strips); self->strips = g_slist_reverse(self->strips);
fpi_do_movement_estimation(&assembling_ctx, aesdev->strips, aesdev->strips_len); fpi_do_movement_estimation(&assembling_ctx, self->strips,
img = fpi_assemble_frames(&assembling_ctx, aesdev->strips, aesdev->strips_len); self->strips_len);
img->flags |= FP_IMG_PARTIAL; img = fpi_assemble_frames(&assembling_ctx, self->strips,
g_slist_free_full(aesdev->strips, g_free); self->strips_len);
aesdev->strips = NULL;
aesdev->strips_len = 0; g_slist_free_full(self->strips, g_free);
aesdev->blanks_count = 0; self->strips = NULL;
fpi_imgdev_image_captured(dev, img); self->strips_len = 0;
fpi_imgdev_report_finger_status(dev, FALSE); self->blanks_count = 0;
fpi_image_device_image_captured(dev, img);
fpi_image_device_report_finger_status(dev, FALSE);
/* marking machine complete will re-trigger finger detection loop */ /* marking machine complete will re-trigger finger detection loop */
fpi_ssm_mark_completed(ssm); fpi_ssm_mark_completed(transfer->ssm);
/* Acquisition finished: restore default gain values */ /* Acquisition finished: restore default gain values */
restore_gain(); restore_gain();
} else { } else {
/* obtain next strip */ /* obtain next strip */
fpi_ssm_jump_to_state(ssm, CAPTURE_REQUEST_STRIP); fpi_ssm_jump_to_state(transfer->ssm, CAPTURE_REQUEST_STRIP);
} }
out:
g_free(data);
libusb_free_transfer(transfer);
} }
static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data) static void capture_run_state(FpiSsm *ssm, FpDevice *_dev, void *user_data)
{ {
struct fp_img_dev *dev = user_data; FpImageDevice *dev = user_data;
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(_dev); FpiDeviceAes1610 *self = FPI_DEVICE_AES1610(_dev);
int r;
switch (fpi_ssm_get_cur_state(ssm)) { switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_WRITE_REQS: case CAPTURE_WRITE_REQS:
@ -652,56 +628,56 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
break; break;
case CAPTURE_REQUEST_STRIP: case CAPTURE_REQUEST_STRIP:
fp_dbg("request strip"); fp_dbg("request strip");
if (aesdev->deactivating) if (self->deactivating)
fpi_ssm_mark_completed(ssm); fpi_ssm_mark_completed(ssm);
else else
aes_write_regv(dev, strip_scan_reqs, G_N_ELEMENTS(strip_scan_reqs), aes_write_regv(dev, strip_scan_reqs, G_N_ELEMENTS(strip_scan_reqs),
generic_write_regv_cb, ssm); generic_write_regv_cb, ssm);
break; break;
case CAPTURE_READ_STRIP: ; case CAPTURE_READ_STRIP: ;
struct libusb_transfer *transfer = fpi_usb_alloc(); FpiUsbTransfer *transfer = fpi_usb_transfer_new(_dev);
unsigned char *data;
data = g_malloc(STRIP_CAPTURE_LEN); fpi_usb_transfer_fill_bulk (transfer, EP_IN, STRIP_CAPTURE_LEN);
libusb_fill_bulk_transfer(transfer, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, STRIP_CAPTURE_LEN, transfer->ssm = ssm;
capture_read_strip_cb, ssm, BULK_TIMEOUT); transfer->short_is_error = TRUE;
fpi_usb_transfer_submit(transfer, BULK_TIMEOUT, NULL,
r = libusb_submit_transfer(transfer); capture_read_strip_cb, NULL);
if (r < 0) { fpi_usb_transfer_unref(transfer);
g_free(data);
libusb_free_transfer(transfer);
fpi_ssm_mark_failed(ssm, r);
}
break; break;
}; };
} }
static void capture_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data) static void capture_sm_complete(FpiSsm *ssm, FpDevice *_dev, void *user_data,
GError *error)
{ {
struct fp_img_dev *dev = user_data; FpImageDevice *dev = user_data;
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(_dev); FpiDeviceAes1610 *self = FPI_DEVICE_AES1610(_dev);
G_DEBUG_HERE(); G_DEBUG_HERE();
if (aesdev->deactivating) if (self->deactivating) {
complete_deactivation(dev); complete_deactivation(dev);
else if (fpi_ssm_get_error(ssm)) if (error)
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm)); g_error_free (error);
else } else if (error) {
fpi_image_device_session_error(dev, error);
} else {
start_finger_detection(dev); start_finger_detection(dev);
}
fpi_ssm_free(ssm); fpi_ssm_free(ssm);
} }
static void start_capture(struct fp_img_dev *dev) static void start_capture(FpImageDevice *dev)
{ {
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev)); FpiDeviceAes1610 *self = FPI_DEVICE_AES1610(dev);
fpi_ssm *ssm; FpiSsm *ssm;
if (aesdev->deactivating) { if (self->deactivating) {
complete_deactivation(dev); complete_deactivation(dev);
return; return;
} }
ssm = fpi_ssm_new(FP_DEV(dev), capture_run_state, CAPTURE_NUM_STATES, dev); ssm = fpi_ssm_new(FP_DEVICE(dev), capture_run_state,
CAPTURE_NUM_STATES, dev);
G_DEBUG_HERE(); G_DEBUG_HERE();
fpi_ssm_start(ssm, capture_sm_complete); fpi_ssm_start(ssm, capture_sm_complete);
} }
@ -723,9 +699,9 @@ enum activate_states {
ACTIVATE_NUM_STATES, ACTIVATE_NUM_STATES,
}; };
static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data) static void activate_run_state(FpiSsm *ssm, FpDevice *_dev, void *user_data)
{ {
struct fp_img_dev *dev = user_data; FpImageDevice *dev = user_data;
/* activation on aes1610 seems much more straightforward compared to aes2501 */ /* activation on aes1610 seems much more straightforward compared to aes2501 */
/* verify there's anything missing here */ /* verify there's anything missing here */
@ -738,100 +714,98 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
} }
/* jump to finger detection */ /* jump to finger detection */
static void activate_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data) static void activate_sm_complete(FpiSsm *ssm, FpDevice *_dev,
void *user_data, GError *error)
{ {
struct fp_img_dev *dev = user_data; FpImageDevice *dev = user_data;
fp_dbg("status %d", fpi_ssm_get_error(ssm)); fpi_image_device_activate_complete(dev, error);
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
if (!fpi_ssm_get_error(ssm)) if (!error)
start_finger_detection(dev); start_finger_detection(dev);
fpi_ssm_free(ssm); fpi_ssm_free(ssm);
} }
static int dev_activate(struct fp_img_dev *dev) static void dev_activate(FpImageDevice *dev)
{ {
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev)); FpiDeviceAes1610 *self = FPI_DEVICE_AES1610(dev);
fpi_ssm *ssm = fpi_ssm_new(FP_DEV(dev), activate_run_state, FpiSsm *ssm = fpi_ssm_new(FP_DEVICE(dev), activate_run_state,
ACTIVATE_NUM_STATES, dev); ACTIVATE_NUM_STATES, dev);
aesdev->read_regs_retry_count = 0; self->read_regs_retry_count = 0;
fpi_ssm_start(ssm, activate_sm_complete); fpi_ssm_start(ssm, activate_sm_complete);
return 0;
} }
static void dev_deactivate(struct fp_img_dev *dev) static void dev_deactivate(FpImageDevice *dev)
{ {
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev)); FpiDeviceAes1610 *self = FPI_DEVICE_AES1610(dev);
/* FIXME: audit cancellation points, probably need more, specifically /* FIXME: audit cancellation points, probably need more, specifically
* in error handling paths? */ * in error handling paths? */
aesdev->deactivating = TRUE; self->deactivating = TRUE;
} }
static void complete_deactivation(struct fp_img_dev *dev) static void complete_deactivation(FpImageDevice *dev)
{ {
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev)); FpiDeviceAes1610 *self = FPI_DEVICE_AES1610(dev);
G_DEBUG_HERE(); G_DEBUG_HERE();
/* FIXME: if we're in the middle of a scan, we should cancel the scan. /* FIXME: if we're in the middle of a scan, we should cancel the scan.
* maybe we can do this with a master reset, unconditionally? */ * maybe we can do this with a master reset, unconditionally? */
aesdev->deactivating = FALSE; self->deactivating = FALSE;
g_slist_free(aesdev->strips); g_slist_free(self->strips);
aesdev->strips = NULL; self->strips = NULL;
aesdev->strips_len = 0; self->strips_len = 0;
aesdev->blanks_count = 0; self->blanks_count = 0;
fpi_imgdev_deactivate_complete(dev); fpi_image_device_deactivate_complete(dev, NULL);
} }
static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) static void dev_init(FpImageDevice *dev)
{ {
GError *error = NULL;
/* FIXME check endpoints */ /* FIXME check endpoints */
int r;
struct aes1610_dev *aesdev;
r = libusb_claim_interface(fpi_dev_get_usb_dev(FP_DEV(dev)), 0); if (!g_usb_device_claim_interface(fpi_device_get_usb_device(FP_DEVICE(dev)), 0, 0, &error)) {
if (r < 0) { fpi_image_device_open_complete(dev, error);
fp_err("could not claim interface 0: %s", libusb_error_name(r)); return;
return r;
} }
aesdev = g_malloc0(sizeof(struct aes1610_dev)); fpi_image_device_open_complete(dev, NULL);
fp_dev_set_instance_data(FP_DEV(dev), aesdev);
fpi_imgdev_open_complete(dev, 0);
return 0;
} }
static void dev_deinit(struct fp_img_dev *dev) static void dev_deinit(FpImageDevice *dev)
{ {
struct aes1610_dev *aesdev; GError *error = NULL;
aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
g_free(aesdev); g_usb_device_release_interface(fpi_device_get_usb_device(FP_DEVICE(dev)),
libusb_release_interface(fpi_dev_get_usb_dev(FP_DEV(dev)), 0); 0, 0, &error);
fpi_imgdev_close_complete(dev); fpi_image_device_close_complete(dev, error);
} }
static const struct usb_id id_table[] = { static const FpIdEntry id_table [ ] = {
{ .vendor = 0x08ff, .product = 0x1600 }, /* AES1600 */ { .vid = 0x08ff, .pid = 0x1600,
{ 0, 0, 0, }, }, /* AES1600 */
{ .vid = 0, .pid = 0, .driver_data = 0 },
}; };
struct fp_img_driver aes1610_driver = { static void fpi_device_aes1610_init(FpiDeviceAes1610 *self) {
.driver = { }
.id = AES1610_ID, static void fpi_device_aes1610_class_init(FpiDeviceAes1610Class *klass) {
.name = FP_COMPONENT, FpDeviceClass *dev_class = FP_DEVICE_CLASS(klass);
.full_name = "AuthenTec AES1610", FpImageDeviceClass *img_class = FP_IMAGE_DEVICE_CLASS(klass);
.id_table = id_table,
.scan_type = FP_SCAN_TYPE_SWIPE,
},
.flags = 0,
.img_height = -1,
.img_width = IMAGE_WIDTH,
.bz3_threshold = 20, dev_class->id = "aes1610";
dev_class->full_name = "AuthenTec AES1610";
dev_class->type = FP_DEVICE_TYPE_USB;
dev_class->id_table = id_table;
dev_class->scan_type = FP_SCAN_TYPE_SWIPE;
.open = dev_init, img_class->img_open = dev_init;
.close = dev_deinit, img_class->img_close = dev_deinit;
.activate = dev_activate, img_class->activate = dev_activate;
.deactivate = dev_deactivate, img_class->deactivate = dev_deactivate;
};
img_class->bz3_threshold = 20;
img_class->img_width = IMAGE_WIDTH;
img_class->img_height = -1;
}

View file

@ -51,7 +51,7 @@ mathlib_dep = cc.find_library('m', required: false)
drivers = get_option('drivers').split(',') drivers = get_option('drivers').split(',')
virtual_drivers = [ 'virtual_image' ] virtual_drivers = [ 'virtual_image' ]
#default_drivers = [ 'upekts', 'upektc', 'upeksonly', 'vcom5s', 'uru4000', 'aes1610', 'aes1660', 'aes2501', 'aes2550', 'aes2660', 'aes3500', 'aes4000', 'vfs101', 'vfs301', 'vfs5011', 'upektc_img', 'etes603', 'vfs0050', 'elan' ] #default_drivers = [ 'upekts', 'upektc', 'upeksonly', 'vcom5s', 'uru4000', 'aes1610', 'aes1660', 'aes2501', 'aes2550', 'aes2660', 'aes3500', 'aes4000', 'vfs101', 'vfs301', 'vfs5011', 'upektc_img', 'etes603', 'vfs0050', 'elan' ]
default_drivers = [ 'upektc_img', 'vfs5011', 'aes3500', 'aes4000' ] default_drivers = [ 'upektc_img', 'vfs5011', 'aes3500', 'aes4000', 'aes1610' ]
all_drivers = default_drivers + virtual_drivers all_drivers = default_drivers + virtual_drivers