mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-09-10 21:06:51 +00:00
Uncrustify everything except for nbis
This commit is contained in:
committed by
Benjamin Berg
parent
fd5f511b33
commit
d1fb1e26f3
+137
-118
@@ -40,169 +40,188 @@
|
||||
#include "aeslib.h"
|
||||
#include "aes3k.h"
|
||||
|
||||
typedef struct {
|
||||
FpiUsbTransfer *img_trf;
|
||||
gboolean deactivating;
|
||||
typedef struct
|
||||
{
|
||||
FpiUsbTransfer *img_trf;
|
||||
gboolean deactivating;
|
||||
} FpiDeviceAes3kPrivate;
|
||||
|
||||
#define CTRL_TIMEOUT 1000
|
||||
#define EP_IN (1 | FPI_USB_ENDPOINT_IN)
|
||||
#define EP_OUT (2 | FPI_USB_ENDPOINT_OUT)
|
||||
#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);
|
||||
static void do_capture (FpImageDevice *dev);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(FpiDeviceAes3k, fpi_device_aes3k, FP_TYPE_IMAGE_DEVICE);
|
||||
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,
|
||||
unsigned char *output)
|
||||
static void
|
||||
aes3k_assemble_image (unsigned char *input, size_t width, size_t height,
|
||||
unsigned char *output)
|
||||
{
|
||||
size_t row, column;
|
||||
size_t row, column;
|
||||
|
||||
for (column = 0; column < width; column++) {
|
||||
for (row = 0; row < height; row += 2) {
|
||||
output[width * row + column] = (*input & 0x0f) * 17;
|
||||
output[width * (row + 1) + column] = ((*input & 0xf0) >> 4) * 17;
|
||||
input++;
|
||||
}
|
||||
}
|
||||
for (column = 0; column < width; column++)
|
||||
{
|
||||
for (row = 0; row < height; row += 2)
|
||||
{
|
||||
output[width * row + column] = (*input & 0x0f) * 17;
|
||||
output[width * (row + 1) + column] = ((*input & 0xf0) >> 4) * 17;
|
||||
input++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void img_cb(FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
static void
|
||||
img_cb (FpiUsbTransfer *transfer, FpDevice *device,
|
||||
gpointer user_data, GError *error)
|
||||
{
|
||||
FpImageDevice *dev = FP_IMAGE_DEVICE (device);
|
||||
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;
|
||||
FpImage *tmp;
|
||||
FpImage *img;
|
||||
int i;
|
||||
FpImageDevice *dev = FP_IMAGE_DEVICE (device);
|
||||
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;
|
||||
FpImage *tmp;
|
||||
FpImage *img;
|
||||
int i;
|
||||
|
||||
priv->img_trf = NULL;
|
||||
priv->img_trf = NULL;
|
||||
|
||||
if (error) {
|
||||
if (g_error_matches (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_CANCELLED)) {
|
||||
/* Deactivation was completed. */
|
||||
g_error_free (error);
|
||||
if (priv->deactivating)
|
||||
fpi_image_device_deactivate_complete(dev, NULL);
|
||||
return;
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
if (g_error_matches (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_CANCELLED))
|
||||
{
|
||||
/* Deactivation was completed. */
|
||||
g_error_free (error);
|
||||
if (priv->deactivating)
|
||||
fpi_image_device_deactivate_complete (dev, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
fpi_image_device_session_error (dev, error);
|
||||
}
|
||||
fpi_image_device_session_error (dev, error);
|
||||
}
|
||||
|
||||
fpi_image_device_report_finger_status(dev, TRUE);
|
||||
fpi_image_device_report_finger_status (dev, TRUE);
|
||||
|
||||
tmp = fp_image_new(cls->frame_width, cls->frame_width);
|
||||
tmp->width = cls->frame_width;
|
||||
tmp->height = cls->frame_width;
|
||||
tmp->flags = FPI_IMAGE_COLORS_INVERTED | FPI_IMAGE_V_FLIPPED | FPI_IMAGE_H_FLIPPED;
|
||||
for (i = 0; i < cls->frame_number; i++) {
|
||||
fp_dbg("frame header byte %02x", *ptr);
|
||||
ptr++;
|
||||
aes3k_assemble_image(ptr, cls->frame_width, AES3K_FRAME_HEIGHT, tmp->data + (i * cls->frame_width * AES3K_FRAME_HEIGHT));
|
||||
ptr += cls->frame_size;
|
||||
}
|
||||
tmp = fp_image_new (cls->frame_width, cls->frame_width);
|
||||
tmp->width = cls->frame_width;
|
||||
tmp->height = cls->frame_width;
|
||||
tmp->flags = FPI_IMAGE_COLORS_INVERTED | FPI_IMAGE_V_FLIPPED | FPI_IMAGE_H_FLIPPED;
|
||||
for (i = 0; i < cls->frame_number; i++)
|
||||
{
|
||||
fp_dbg ("frame header byte %02x", *ptr);
|
||||
ptr++;
|
||||
aes3k_assemble_image (ptr, cls->frame_width, AES3K_FRAME_HEIGHT, tmp->data + (i * cls->frame_width * AES3K_FRAME_HEIGHT));
|
||||
ptr += cls->frame_size;
|
||||
}
|
||||
|
||||
/* FIXME: this is an ugly hack to make the image big enough for NBIS
|
||||
* to process reliably */
|
||||
img = fpi_image_resize(tmp, cls->enlarge_factor, cls->enlarge_factor);
|
||||
g_object_unref (tmp);
|
||||
fpi_image_device_image_captured(dev, img);
|
||||
/* FIXME: this is an ugly hack to make the image big enough for NBIS
|
||||
* to process reliably */
|
||||
img = fpi_image_resize (tmp, cls->enlarge_factor, cls->enlarge_factor);
|
||||
g_object_unref (tmp);
|
||||
fpi_image_device_image_captured (dev, img);
|
||||
|
||||
/* FIXME: rather than assuming finger has gone, we should poll regs until
|
||||
* it really has, then restart the capture */
|
||||
fpi_image_device_report_finger_status(dev, FALSE);
|
||||
/* FIXME: rather than assuming finger has gone, we should poll regs until
|
||||
* it really has, then restart the capture */
|
||||
fpi_image_device_report_finger_status (dev, FALSE);
|
||||
|
||||
do_capture(dev);
|
||||
do_capture (dev);
|
||||
}
|
||||
|
||||
static void do_capture(FpImageDevice *dev)
|
||||
static void
|
||||
do_capture (FpImageDevice *dev)
|
||||
{
|
||||
FpiDeviceAes3k *self = FPI_DEVICE_AES3K (dev);
|
||||
FpiDeviceAes3kPrivate *priv = fpi_device_aes3k_get_instance_private (self);
|
||||
FpiDeviceAes3kClass *cls = FPI_DEVICE_AES3K_GET_CLASS (self);
|
||||
FpiDeviceAes3k *self = FPI_DEVICE_AES3K (dev);
|
||||
FpiDeviceAes3kPrivate *priv = fpi_device_aes3k_get_instance_private (self);
|
||||
FpiDeviceAes3kClass *cls = FPI_DEVICE_AES3K_GET_CLASS (self);
|
||||
|
||||
priv->img_trf = fpi_usb_transfer_new (FP_DEVICE (dev));
|
||||
fpi_usb_transfer_fill_bulk(priv->img_trf, EP_IN, cls->data_buflen);
|
||||
priv->img_trf->short_is_error = TRUE;
|
||||
fpi_usb_transfer_submit(priv->img_trf, 0,
|
||||
fpi_device_get_cancellable (FP_DEVICE (dev)),
|
||||
img_cb, NULL);
|
||||
fpi_usb_transfer_unref(priv->img_trf);
|
||||
priv->img_trf = fpi_usb_transfer_new (FP_DEVICE (dev));
|
||||
fpi_usb_transfer_fill_bulk (priv->img_trf, EP_IN, cls->data_buflen);
|
||||
priv->img_trf->short_is_error = TRUE;
|
||||
fpi_usb_transfer_submit (priv->img_trf, 0,
|
||||
fpi_device_get_cancellable (FP_DEVICE (dev)),
|
||||
img_cb, NULL);
|
||||
fpi_usb_transfer_unref (priv->img_trf);
|
||||
}
|
||||
|
||||
static void init_reqs_cb(FpImageDevice *dev, GError *result, void *user_data)
|
||||
static void
|
||||
init_reqs_cb (FpImageDevice *dev, GError *result, void *user_data)
|
||||
{
|
||||
fpi_image_device_activate_complete (dev, result);
|
||||
if (!result)
|
||||
do_capture(dev);
|
||||
fpi_image_device_activate_complete (dev, result);
|
||||
if (!result)
|
||||
do_capture (dev);
|
||||
}
|
||||
|
||||
static void aes3k_dev_activate(FpImageDevice *dev)
|
||||
static void
|
||||
aes3k_dev_activate (FpImageDevice *dev)
|
||||
{
|
||||
FpiDeviceAes3k *self = FPI_DEVICE_AES3K (dev);
|
||||
FpiDeviceAes3kPrivate *priv = fpi_device_aes3k_get_instance_private (self);
|
||||
FpiDeviceAes3kClass *cls = FPI_DEVICE_AES3K_GET_CLASS (self);
|
||||
FpiDeviceAes3k *self = FPI_DEVICE_AES3K (dev);
|
||||
FpiDeviceAes3kPrivate *priv = fpi_device_aes3k_get_instance_private (self);
|
||||
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);
|
||||
priv->deactivating = FALSE;
|
||||
aes_write_regv (dev, cls->init_reqs, cls->init_reqs_len, init_reqs_cb, NULL);
|
||||
}
|
||||
|
||||
static void aes3k_dev_deactivate(FpImageDevice *dev)
|
||||
static void
|
||||
aes3k_dev_deactivate (FpImageDevice *dev)
|
||||
{
|
||||
FpiDeviceAes3k *self = FPI_DEVICE_AES3K (dev);
|
||||
FpiDeviceAes3kPrivate *priv = fpi_device_aes3k_get_instance_private (self);
|
||||
FpiDeviceAes3k *self = FPI_DEVICE_AES3K (dev);
|
||||
FpiDeviceAes3kPrivate *priv = fpi_device_aes3k_get_instance_private (self);
|
||||
|
||||
priv->deactivating = TRUE;
|
||||
if (priv->img_trf)
|
||||
return;
|
||||
fpi_image_device_deactivate_complete(dev, NULL);
|
||||
priv->deactivating = TRUE;
|
||||
if (priv->img_trf)
|
||||
return;
|
||||
fpi_image_device_deactivate_complete (dev, NULL);
|
||||
}
|
||||
|
||||
static void fpi_device_aes3k_init(FpiDeviceAes3k *self) {
|
||||
}
|
||||
|
||||
static void aes3k_dev_init(FpImageDevice *dev)
|
||||
static void
|
||||
fpi_device_aes3k_init (FpiDeviceAes3k *self)
|
||||
{
|
||||
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)
|
||||
static void
|
||||
aes3k_dev_init (FpImageDevice *dev)
|
||||
{
|
||||
GError *error = NULL;
|
||||
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);
|
||||
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);
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
/* Extremely low due to low image quality. */
|
||||
img_class->bz3_threshold = 9;
|
||||
|
||||
/* Everything else is set by the subclasses. */
|
||||
/* Everything else is set by the subclasses. */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user