aes3k: Port aes3500 and aes4000 drivers to new API

This commit is contained in:
Benjamin Berg 2019-07-08 14:48:56 +02:00
parent 0169fe8cf6
commit 7ef64b5f5f
7 changed files with 223 additions and 250 deletions

View file

@ -29,8 +29,6 @@
#define FP_COMPONENT "aes3500" #define FP_COMPONENT "aes3500"
#include "drivers_api.h"
#include "aeslib.h"
#include "aes3k.h" #include "aes3k.h"
#define DATA_BUFLEN 0x2089 #define DATA_BUFLEN 0x2089
@ -117,67 +115,39 @@ static struct aes_regwrite init_reqs[] = {
{ 0x81, 0x00 }, { 0x81, 0x00 },
}; };
static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) struct _FpiDeviceAes3500 {
{ FpiDeviceAes3k parent;
int r; };
struct aes3k_dev *aesdev; G_DECLARE_FINAL_TYPE(FpiDeviceAes3500, fpi_device_aes3500, FPI,
DEVICE_AES3500, FpiDeviceAes3k);
r = libusb_claim_interface(fpi_dev_get_usb_dev(FP_DEV(dev)), 0); G_DEFINE_TYPE(FpiDeviceAes3500, fpi_device_aes3500, FPI_TYPE_DEVICE_AES3K);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
aesdev = g_malloc0(sizeof(struct aes3k_dev));
fp_dev_set_instance_data(FP_DEV(dev), aesdev);
if (!aesdev)
return -ENOMEM;
aesdev->data_buflen = DATA_BUFLEN;
aesdev->frame_width = FRAME_WIDTH;
aesdev->frame_size = FRAME_SIZE;
aesdev->frame_number = FRAME_NUMBER;
aesdev->enlarge_factor = ENLARGE_FACTOR;
aesdev->init_reqs = init_reqs;
aesdev->init_reqs_len = G_N_ELEMENTS(init_reqs);
fpi_imgdev_open_complete(dev, 0);
return r;
}
static void dev_deinit(struct fp_img_dev *dev)
{
struct aes3k_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
g_free(aesdev);
libusb_release_interface(fpi_dev_get_usb_dev(FP_DEV(dev)), 0);
fpi_imgdev_close_complete(dev);
}
static const struct usb_id id_table[] = { static const FpIdEntry id_table [ ] = {
{ .vendor = 0x08ff, .product = 0x5731 }, { .vid = 0x08ff, .pid = 0x5731 },
{ 0, 0, 0, }, { .vid = 0, .pid = 0, .driver_data = 0 },
}; };
struct fp_img_driver aes3500_driver = { static void fpi_device_aes3500_init(FpiDeviceAes3500 *self) {
.driver = { }
.id = AES3500_ID,
.name = FP_COMPONENT,
.full_name = "AuthenTec AES3500",
.id_table = id_table,
.scan_type = FP_SCAN_TYPE_PRESS,
},
.flags = 0,
.img_height = FRAME_WIDTH * ENLARGE_FACTOR,
.img_width = FRAME_WIDTH * ENLARGE_FACTOR,
/* temporarily lowered until image quality improves */ static void fpi_device_aes3500_class_init(FpiDeviceAes3500Class *klass) {
.bz3_threshold = 9, FpDeviceClass *dev_class = FP_DEVICE_CLASS(klass);
FpImageDeviceClass *img_class = FP_IMAGE_DEVICE_CLASS(klass);
FpiDeviceAes3kClass *aes_class = FPI_DEVICE_AES3K_CLASS (klass);
.open = dev_init, dev_class->id = "aes3500";
.close = dev_deinit, dev_class->full_name = "AuthenTec AES3500";
.activate = aes3k_dev_activate, dev_class->id_table = id_table;
.deactivate = aes3k_dev_deactivate,
};
img_class->img_height = FRAME_WIDTH * ENLARGE_FACTOR;
img_class->img_width = FRAME_WIDTH * ENLARGE_FACTOR;
aes_class->data_buflen = DATA_BUFLEN;
aes_class->frame_width = FRAME_WIDTH;
aes_class->frame_size = FRAME_SIZE;
aes_class->frame_number = FRAME_NUMBER;
aes_class->enlarge_factor = ENLARGE_FACTOR;
aes_class->init_reqs = init_reqs;
aes_class->init_reqs_len = G_N_ELEMENTS(init_reqs);
}

View file

@ -40,11 +40,18 @@
#include "aeslib.h" #include "aeslib.h"
#include "aes3k.h" #include "aes3k.h"
#define CTRL_TIMEOUT 1000 typedef struct {
#define EP_IN (1 | LIBUSB_ENDPOINT_IN) FpiUsbTransfer *img_trf;
#define EP_OUT (2 | LIBUSB_ENDPOINT_OUT) gboolean deactivating;
} FpiDeviceAes3kPrivate;
static void do_capture(struct fp_img_dev *dev); #define CTRL_TIMEOUT 1000
#define EP_IN (1 | FPI_USB_ENDPOINT_IN)
#define EP_OUT (2 | FPI_USB_ENDPOINT_OUT)
static void do_capture(FpImageDevice *dev);
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(FpiDeviceAes3k, fpi_device_aes3k, FP_TYPE_IMAGE_DEVICE);
static void aes3k_assemble_image(unsigned char *input, size_t width, size_t height, static void aes3k_assemble_image(unsigned char *input, size_t width, size_t height,
unsigned char *output) unsigned char *output)
@ -60,99 +67,142 @@ static void aes3k_assemble_image(unsigned char *input, size_t width, size_t heig
} }
} }
static void img_cb(struct libusb_transfer *transfer) static void img_cb(FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
{ {
struct fp_img_dev *dev = transfer->user_data; FpImageDevice *dev = FP_IMAGE_DEVICE (device);
struct aes3k_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev)); FpiDeviceAes3k *self = FPI_DEVICE_AES3K (device);
FpiDeviceAes3kPrivate *priv = fpi_device_aes3k_get_instance_private (self);
FpiDeviceAes3kClass *cls = FPI_DEVICE_AES3K_GET_CLASS (self);
unsigned char *ptr = transfer->buffer; unsigned char *ptr = transfer->buffer;
struct fp_img *tmp; FpImage *tmp;
struct fp_img *img; FpImage *img;
int i; int i;
if (transfer->status == LIBUSB_TRANSFER_CANCELLED) { priv->img_trf = NULL;
goto err;
} else if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { if (error) {
fpi_imgdev_session_error(dev, -EIO); if (g_error_matches (error,
goto err; G_IO_ERROR,
} else if (transfer->length != transfer->actual_length) { G_IO_ERROR_CANCELLED)) {
fpi_imgdev_session_error(dev, -EPROTO); /* Deactivation was completed. */
goto err; g_error_free (error);
if (priv->deactivating)
fpi_image_device_deactivate_complete(dev, NULL);
return;
}
fpi_image_device_session_error (dev, error);
} }
fpi_imgdev_report_finger_status(dev, TRUE); fpi_image_device_report_finger_status(dev, TRUE);
tmp = fpi_img_new(aesdev->frame_width * aesdev->frame_width); tmp = fp_image_new(cls->frame_width, cls->frame_width);
tmp->width = aesdev->frame_width; tmp->width = cls->frame_width;
tmp->height = aesdev->frame_width; tmp->height = cls->frame_width;
tmp->flags = FP_IMG_COLORS_INVERTED | FP_IMG_V_FLIPPED | FP_IMG_H_FLIPPED; tmp->flags = FPI_IMAGE_COLORS_INVERTED | FPI_IMAGE_V_FLIPPED | FPI_IMAGE_H_FLIPPED;
for (i = 0; i < aesdev->frame_number; i++) { for (i = 0; i < cls->frame_number; i++) {
fp_dbg("frame header byte %02x", *ptr); fp_dbg("frame header byte %02x", *ptr);
ptr++; ptr++;
aes3k_assemble_image(ptr, aesdev->frame_width, AES3K_FRAME_HEIGHT, tmp->data + (i * aesdev->frame_width * AES3K_FRAME_HEIGHT)); aes3k_assemble_image(ptr, cls->frame_width, AES3K_FRAME_HEIGHT, tmp->data + (i * cls->frame_width * AES3K_FRAME_HEIGHT));
ptr += aesdev->frame_size; ptr += cls->frame_size;
} }
/* FIXME: this is an ugly hack to make the image big enough for NBIS /* FIXME: this is an ugly hack to make the image big enough for NBIS
* to process reliably */ * to process reliably */
img = fpi_img_resize(tmp, aesdev->enlarge_factor, aesdev->enlarge_factor); img = fpi_image_resize(tmp, cls->enlarge_factor, cls->enlarge_factor);
fp_img_free(tmp); g_object_unref (tmp);
fpi_imgdev_image_captured(dev, img); fpi_image_device_image_captured(dev, img);
/* FIXME: rather than assuming finger has gone, we should poll regs until /* FIXME: rather than assuming finger has gone, we should poll regs until
* it really has, then restart the capture */ * it really has, then restart the capture */
fpi_imgdev_report_finger_status(dev, FALSE); fpi_image_device_report_finger_status(dev, FALSE);
do_capture(dev); do_capture(dev);
err:
g_free(transfer->buffer);
aesdev->img_trf = NULL;
libusb_free_transfer(transfer);
} }
static void do_capture(struct fp_img_dev *dev) static void do_capture(FpImageDevice *dev)
{ {
struct aes3k_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev)); FpiDeviceAes3k *self = FPI_DEVICE_AES3K (dev);
unsigned char *data; FpiDeviceAes3kPrivate *priv = fpi_device_aes3k_get_instance_private (self);
int r; FpiDeviceAes3kClass *cls = FPI_DEVICE_AES3K_GET_CLASS (self);
aesdev->img_trf = fpi_usb_alloc(); priv->img_trf = fpi_usb_transfer_new (FP_DEVICE (dev));
data = g_malloc(aesdev->data_buflen); fpi_usb_transfer_fill_bulk(priv->img_trf, EP_IN, cls->data_buflen);
libusb_fill_bulk_transfer(aesdev->img_trf, fpi_dev_get_usb_dev(FP_DEV(dev)), EP_IN, data, priv->img_trf->short_is_error = TRUE;
aesdev->data_buflen, img_cb, dev, 0); fpi_usb_transfer_submit(priv->img_trf, 0,
fpi_device_get_cancellable (FP_DEVICE (dev)),
r = libusb_submit_transfer(aesdev->img_trf); img_cb, NULL);
if (r < 0) { fpi_usb_transfer_unref(priv->img_trf);
g_free(data);
libusb_free_transfer(aesdev->img_trf);
aesdev->img_trf = NULL;
fpi_imgdev_session_error(dev, r);
}
} }
static void init_reqs_cb(struct fp_img_dev *dev, int result, void *user_data) static void init_reqs_cb(FpImageDevice *dev, GError *result, void *user_data)
{ {
fpi_imgdev_activate_complete(dev, result); fpi_image_device_activate_complete (dev, result);
if (result == 0) if (!result)
do_capture(dev); do_capture(dev);
} }
int aes3k_dev_activate(struct fp_img_dev *dev) static void aes3k_dev_activate(FpImageDevice *dev)
{ {
struct aes3k_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev)); FpiDeviceAes3k *self = FPI_DEVICE_AES3K (dev);
aes_write_regv(dev, aesdev->init_reqs, aesdev->init_reqs_len, init_reqs_cb, NULL); FpiDeviceAes3kPrivate *priv = fpi_device_aes3k_get_instance_private (self);
return 0; FpiDeviceAes3kClass *cls = FPI_DEVICE_AES3K_GET_CLASS (self);
priv->deactivating = FALSE;
aes_write_regv(dev, cls->init_reqs, cls->init_reqs_len, init_reqs_cb, NULL);
} }
void aes3k_dev_deactivate(struct fp_img_dev *dev) static void aes3k_dev_deactivate(FpImageDevice *dev)
{ {
struct aes3k_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev)); FpiDeviceAes3k *self = FPI_DEVICE_AES3K (dev);
FpiDeviceAes3kPrivate *priv = fpi_device_aes3k_get_instance_private (self);
/* FIXME: should wait for cancellation to complete before returning priv->deactivating = TRUE;
* from deactivation, otherwise app may legally exit before we've if (priv->img_trf)
* cleaned up */ return;
if (aesdev->img_trf) fpi_image_device_deactivate_complete(dev, NULL);
libusb_cancel_transfer(aesdev->img_trf);
fpi_imgdev_deactivate_complete(dev);
} }
static void fpi_device_aes3k_init(FpiDeviceAes3k *self) {
}
static void aes3k_dev_init(FpImageDevice *dev)
{
GError *error = NULL;
if (!g_usb_device_claim_interface(fpi_device_get_usb_device(FP_DEVICE(dev)), 0, 0, &error)) {
fpi_image_device_open_complete(dev, error);
return;
}
fpi_image_device_open_complete(dev, NULL);
}
static void aes3k_dev_deinit(FpImageDevice *dev)
{
GError *error = NULL;
g_usb_device_release_interface(fpi_device_get_usb_device(FP_DEVICE(dev)),
0, 0, &error);
fpi_image_device_close_complete(dev, error);
}
static void fpi_device_aes3k_class_init(FpiDeviceAes3kClass *klass) {
FpDeviceClass *dev_class = FP_DEVICE_CLASS(klass);
FpImageDeviceClass *img_class = FP_IMAGE_DEVICE_CLASS(klass);
dev_class->type = FP_DEVICE_TYPE_USB;
dev_class->scan_type = FP_SCAN_TYPE_PRESS;
img_class->img_open = aes3k_dev_init;
img_class->img_close = aes3k_dev_deinit;
img_class->activate = aes3k_dev_activate;
img_class->deactivate = aes3k_dev_deactivate;
/* Extremely low due to low image quality. */
img_class->bz3_threshold = 9;
/* Everything else is set by the subclasses. */
}

View file

@ -34,25 +34,26 @@
* *
*/ */
#ifndef __AES3K_H #pragma once
#define __AES3K_H #include "fpi-image-device.h"
#include "aeslib.h"
#define AES3K_FRAME_HEIGHT 16 #define AES3K_FRAME_HEIGHT 16
struct aes3k_dev { G_DECLARE_DERIVABLE_TYPE(FpiDeviceAes3k, fpi_device_aes3k, FPI,
struct libusb_transfer *img_trf; DEVICE_AES3K, FpImageDevice)
size_t frame_width; /* image size = frame_width x frame_width */
size_t frame_size; /* 4 bits/pixel: frame_width x AES3K_FRAME_HEIGHT / 2 */
size_t frame_number; /* number of frames */
size_t enlarge_factor;
size_t data_buflen; /* buffer length of usb bulk transfer */ #define FPI_TYPE_DEVICE_AES3K (fpi_device_aes3k_get_type ())
struct _FpiDeviceAes3kClass {
FpImageDeviceClass parent;
gsize frame_width; /* image size = frame_width x frame_width */
gsize frame_size; /* 4 bits/pixel: frame_width x AES3K_FRAME_HEIGHT / 2 */
gsize frame_number; /* number of frames */
gsize enlarge_factor;
gsize data_buflen; /* buffer length of usb bulk transfer */
struct aes_regwrite *init_reqs; /* initial values sent to device */ struct aes_regwrite *init_reqs; /* initial values sent to device */
size_t init_reqs_len; gsize init_reqs_len;
}; };
int aes3k_dev_activate(struct fp_img_dev *dev);
void aes3k_dev_deactivate(struct fp_img_dev *dev);
#endif

View file

@ -26,8 +26,6 @@
#define FP_COMPONENT "aes4000" #define FP_COMPONENT "aes4000"
#include "drivers_api.h"
#include "aeslib.h"
#include "aes3k.h" #include "aes3k.h"
#define DATA_BUFLEN 0x1259 #define DATA_BUFLEN 0x1259
@ -114,67 +112,39 @@ static struct aes_regwrite init_reqs[] = {
{ 0x81, 0x00 }, { 0x81, 0x00 },
}; };
static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) struct _FpiDeviceAes4000 {
{ FpiDeviceAes3k parent;
int r; };
struct aes3k_dev *aesdev; G_DECLARE_FINAL_TYPE(FpiDeviceAes4000, fpi_device_aes4000, FPI,
DEVICE_AES4000, FpiDeviceAes3k);
r = libusb_claim_interface(fpi_dev_get_usb_dev(FP_DEV(dev)), 0); G_DEFINE_TYPE(FpiDeviceAes4000, fpi_device_aes4000, FPI_TYPE_DEVICE_AES3K);
if (r < 0) {
fp_err("could not claim interface 0: %s", libusb_error_name(r));
return r;
}
aesdev = g_malloc0(sizeof(struct aes3k_dev));
fp_dev_set_instance_data(FP_DEV(dev), aesdev);
if (!aesdev)
return -ENOMEM;
aesdev->data_buflen = DATA_BUFLEN;
aesdev->frame_width = FRAME_WIDTH;
aesdev->frame_size = FRAME_SIZE;
aesdev->frame_number = FRAME_NUMBER;
aesdev->enlarge_factor = ENLARGE_FACTOR;
aesdev->init_reqs = init_reqs;
aesdev->init_reqs_len = G_N_ELEMENTS(init_reqs);
fpi_imgdev_open_complete(dev, 0);
return r;
}
static void dev_deinit(struct fp_img_dev *dev)
{
struct aes3k_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
g_free(aesdev);
libusb_release_interface(fpi_dev_get_usb_dev(FP_DEV(dev)), 0);
fpi_imgdev_close_complete(dev);
}
static const struct usb_id id_table[] = { static const FpIdEntry id_table [ ] = {
{ .vendor = 0x08ff, .product = 0x5501 }, { .pid = 0x08ff, .vid = 0x5501 },
{ 0, 0, 0, }, { .vid = 0, .pid = 0, .driver_data = 0 },
}; };
struct fp_img_driver aes4000_driver = { static void fpi_device_aes4000_init(FpiDeviceAes4000 *self) {
.driver = { }
.id = AES4000_ID,
.name = FP_COMPONENT,
.full_name = "AuthenTec AES4000",
.id_table = id_table,
.scan_type = FP_SCAN_TYPE_PRESS,
},
.flags = 0,
.img_height = FRAME_WIDTH * ENLARGE_FACTOR,
.img_width = FRAME_WIDTH * ENLARGE_FACTOR,
/* temporarily lowered until image quality improves */ static void fpi_device_aes4000_class_init(FpiDeviceAes4000Class *klass) {
.bz3_threshold = 9, FpDeviceClass *dev_class = FP_DEVICE_CLASS(klass);
FpImageDeviceClass *img_class = FP_IMAGE_DEVICE_CLASS(klass);
FpiDeviceAes3kClass *aes_class = FPI_DEVICE_AES3K_CLASS (klass);
.open = dev_init, dev_class->id = "aes4000";
.close = dev_deinit, dev_class->full_name = "AuthenTec AES4000";
.activate = aes3k_dev_activate, dev_class->id_table = id_table;
.deactivate = aes3k_dev_deactivate,
};
img_class->img_height = FRAME_WIDTH * ENLARGE_FACTOR;
img_class->img_width = FRAME_WIDTH * ENLARGE_FACTOR;
aes_class->data_buflen = DATA_BUFLEN;
aes_class->frame_width = FRAME_WIDTH;
aes_class->frame_size = FRAME_SIZE;
aes_class->frame_number = FRAME_NUMBER;
aes_class->enlarge_factor = ENLARGE_FACTOR;
aes_class->init_reqs = init_reqs;
aes_class->init_reqs_len = G_N_ELEMENTS(init_reqs);
}

View file

@ -24,20 +24,17 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <glib.h> #include "fpi-usb-transfer.h"
#include "fpi-usb.h"
#include "fpi-assembling.h" #include "fpi-assembling.h"
#include "aeslib.h" #include "aeslib.h"
#define MAX_REGWRITES_PER_REQUEST 16 #define MAX_REGWRITES_PER_REQUEST 16
#define BULK_TIMEOUT 4000 #define BULK_TIMEOUT 4000
#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)
struct write_regv_data { struct write_regv_data {
struct fp_img_dev *imgdev;
unsigned int num_regs; unsigned int num_regs;
const struct aes_regwrite *regs; const struct aes_regwrite *regs;
unsigned int offset; unsigned int offset;
@ -45,73 +42,62 @@ struct write_regv_data {
void *user_data; void *user_data;
}; };
static void continue_write_regv(struct write_regv_data *wdata); static void continue_write_regv(FpImageDevice *dev, struct write_regv_data *wdata);
/* libusb bulk callback for regv write completion transfer. continues the /* libusb bulk callback for regv write completion transfer. continues the
* transaction */ * transaction */
static void write_regv_trf_complete(struct libusb_transfer *transfer) static void write_regv_trf_complete(FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
{ {
struct write_regv_data *wdata = transfer->user_data; struct write_regv_data *wdata = user_data;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { if (error) {
wdata->callback(wdata->imgdev, -EIO, wdata->user_data); wdata->callback(FP_IMAGE_DEVICE (device), error, wdata->user_data);
g_free(wdata);
} else if (transfer->length != transfer->actual_length) {
wdata->callback(wdata->imgdev, -EPROTO, wdata->user_data);
g_free(wdata); g_free(wdata);
} else { } else {
continue_write_regv(wdata); continue_write_regv(FP_IMAGE_DEVICE (device), wdata);
} }
g_free(transfer->buffer);
libusb_free_transfer(transfer);
} }
/* write from wdata->offset to upper_bound (inclusive) of wdata->regs */ /* write from wdata->offset to upper_bound (inclusive) of wdata->regs */
static int do_write_regv(struct write_regv_data *wdata, int upper_bound) static void do_write_regv(FpImageDevice *dev, struct write_regv_data *wdata, int upper_bound)
{ {
unsigned int offset = wdata->offset; unsigned int offset = wdata->offset;
unsigned int num = upper_bound - offset + 1; unsigned int num = upper_bound - offset + 1;
size_t alloc_size = num * 2; size_t alloc_size = num * 2;
unsigned char *data = g_malloc(alloc_size);
unsigned int i; unsigned int i;
size_t data_offset = 0; size_t data_offset = 0;
struct libusb_transfer *transfer = fpi_usb_alloc(); FpiUsbTransfer *transfer = fpi_usb_transfer_new(FP_DEVICE (dev));
int r;
fpi_usb_transfer_fill_bulk (transfer, EP_OUT, alloc_size);
for (i = offset; i < offset + num; i++) { for (i = offset; i < offset + num; i++) {
const struct aes_regwrite *regwrite = &wdata->regs[i]; const struct aes_regwrite *regwrite = &wdata->regs[i];
data[data_offset++] = regwrite->reg; transfer->buffer[data_offset++] = regwrite->reg;
data[data_offset++] = regwrite->value; transfer->buffer[data_offset++] = regwrite->value;
} }
libusb_fill_bulk_transfer(transfer, FP_DEV(wdata->imgdev)->udev, EP_OUT, data, transfer->short_is_error = TRUE;
alloc_size, write_regv_trf_complete, wdata, BULK_TIMEOUT); fpi_usb_transfer_submit(transfer, BULK_TIMEOUT, NULL,
r = libusb_submit_transfer(transfer); write_regv_trf_complete, wdata);
if (r < 0) { fpi_usb_transfer_unref (transfer);
g_free(data);
libusb_free_transfer(transfer);
}
return r;
} }
/* write the next batch of registers to be written, or if there are no more, /* write the next batch of registers to be written, or if there are no more,
* indicate completion to the caller */ * indicate completion to the caller */
static void continue_write_regv(struct write_regv_data *wdata) static void continue_write_regv(FpImageDevice *dev, struct write_regv_data *wdata)
{ {
unsigned int offset = wdata->offset; unsigned int offset = wdata->offset;
unsigned int regs_remaining; unsigned int regs_remaining;
unsigned int limit; unsigned int limit;
unsigned int upper_bound; unsigned int upper_bound;
int i; int i;
int r;
/* skip all zeros and ensure there is still work to do */ /* skip all zeros and ensure there is still work to do */
while (TRUE) { while (TRUE) {
if (offset >= wdata->num_regs) { if (offset >= wdata->num_regs) {
fp_dbg("all registers written"); fp_dbg("all registers written");
wdata->callback(wdata->imgdev, 0, wdata->user_data); wdata->callback(dev, 0, wdata->user_data);
g_free(wdata); g_free(wdata);
return; return;
} }
@ -133,12 +119,7 @@ static void continue_write_regv(struct write_regv_data *wdata)
break; break;
} }
r = do_write_regv(wdata, upper_bound); do_write_regv(dev, wdata, upper_bound);
if (r < 0) {
wdata->callback(wdata->imgdev, r, wdata->user_data);
g_free(wdata);
return;
}
wdata->offset = upper_bound + 1; wdata->offset = upper_bound + 1;
} }
@ -146,20 +127,20 @@ static void continue_write_regv(struct write_regv_data *wdata)
/* write a load of registers to the device, combining multiple writes in a /* write a load of registers to the device, combining multiple writes in a
* single URB up to a limit. insert writes to non-existent register 0 to force * single URB up to a limit. insert writes to non-existent register 0 to force
* specific groups of writes to be separated by different URBs. */ * specific groups of writes to be separated by different URBs. */
void aes_write_regv(struct fp_img_dev *dev, const struct aes_regwrite *regs, void aes_write_regv(FpImageDevice *dev, const struct aes_regwrite *regs,
unsigned int num_regs, aes_write_regv_cb callback, void *user_data) unsigned int num_regs, aes_write_regv_cb callback,
void *user_data)
{ {
struct write_regv_data *wdata; struct write_regv_data *wdata;
fp_dbg("write %d regs", num_regs); fp_dbg("write %d regs", num_regs);
wdata = g_malloc(sizeof(*wdata)); wdata = g_malloc(sizeof(*wdata));
wdata->imgdev = dev;
wdata->num_regs = num_regs; wdata->num_regs = num_regs;
wdata->regs = regs; wdata->regs = regs;
wdata->offset = 0; wdata->offset = 0;
wdata->callback = callback; wdata->callback = callback;
wdata->user_data = user_data; wdata->user_data = user_data;
continue_write_regv(wdata); continue_write_regv(dev, wdata);
} }
unsigned char aes_get_pixel(struct fpi_frame_asmbl_ctx *ctx, unsigned char aes_get_pixel(struct fpi_frame_asmbl_ctx *ctx,

View file

@ -30,11 +30,12 @@ struct aes_regwrite {
struct fpi_frame; struct fpi_frame;
struct fpi_frame_asmbl_ctx; struct fpi_frame_asmbl_ctx;
typedef void (*aes_write_regv_cb)(struct fp_img_dev *dev, int result, typedef void (*aes_write_regv_cb)(FpImageDevice *dev, GError *error,
void *user_data); void *user_data);
void aes_write_regv(struct fp_img_dev *dev, const struct aes_regwrite *regs, void aes_write_regv(FpImageDevice *dev, const struct aes_regwrite *regs,
unsigned int num_regs, aes_write_regv_cb callback, void *user_data); unsigned int num_regs, aes_write_regv_cb callback,
void *user_data);
unsigned char aes_get_pixel(struct fpi_frame_asmbl_ctx *ctx, unsigned char aes_get_pixel(struct fpi_frame_asmbl_ctx *ctx,
struct fpi_frame *frame, struct fpi_frame *frame,

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' ] default_drivers = [ 'upektc_img', 'vfs5011', 'aes3500', 'aes4000' ]
all_drivers = default_drivers + virtual_drivers all_drivers = default_drivers + virtual_drivers