mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-03-26 17:10:42 +01:00
secugen: Use persistent bulk buffer instead of SSM transfer data
Store bulk read results in a reusable device struct buffer rather than passing FpiUsbTransfer references through fpi_ssm_set_data/get_data. This simplifies the capture and detect callbacks and makes the bulk data lifetime explicit.
This commit is contained in:
parent
84517b5b18
commit
b2fea5dc6b
2 changed files with 27 additions and 25 deletions
|
|
@ -1218,15 +1218,25 @@ capture_bulk_cb (FpiUsbTransfer *transfer,
|
|||
gpointer user_data,
|
||||
GError *error)
|
||||
{
|
||||
FpiDeviceSecugen *self = FPI_DEVICE_SECUGEN (dev);
|
||||
|
||||
if (error)
|
||||
{
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
return;
|
||||
}
|
||||
|
||||
fpi_ssm_set_data (transfer->ssm,
|
||||
fpi_usb_transfer_ref (transfer),
|
||||
(GDestroyNotify) fpi_usb_transfer_unref);
|
||||
if ((gsize) transfer->actual_length < SECUGEN_RAW_SIZE)
|
||||
{
|
||||
fp_warn ("Short image data: got %lu, expected %d",
|
||||
(unsigned long) transfer->actual_length, SECUGEN_RAW_SIZE);
|
||||
fpi_ssm_mark_failed (transfer->ssm,
|
||||
fpi_device_error_new (FP_DEVICE_ERROR_PROTO));
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy (self->bulk_buffer, transfer->buffer,
|
||||
MIN ((gsize) transfer->actual_length, (gsize) SECUGEN_BULK_BUF_SIZE));
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
}
|
||||
|
||||
|
|
@ -1282,28 +1292,17 @@ capture_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
|
||||
case CAPTURE_DONE:
|
||||
{
|
||||
FpiUsbTransfer *img_transfer = fpi_ssm_get_data (ssm);
|
||||
FpImage *img;
|
||||
guint8 *raw;
|
||||
int i;
|
||||
|
||||
if (!img_transfer || img_transfer->actual_length < SECUGEN_RAW_SIZE)
|
||||
{
|
||||
fp_warn ("Short image data: got %ld, expected %d",
|
||||
img_transfer ? (long) img_transfer->actual_length : 0,
|
||||
SECUGEN_RAW_SIZE);
|
||||
fpi_ssm_mark_failed (ssm,
|
||||
fpi_device_error_new (FP_DEVICE_ERROR_PROTO));
|
||||
return;
|
||||
}
|
||||
|
||||
img = fp_image_new (SECUGEN_IMG_WIDTH, SECUGEN_IMG_HEIGHT);
|
||||
img->ppmm = SECUGEN_PPMM;
|
||||
img->flags = FPI_IMAGE_V_FLIPPED | FPI_IMAGE_H_FLIPPED;
|
||||
|
||||
/* Work on a copy of the raw 956x688 sensor data */
|
||||
raw = g_malloc (SECUGEN_RAW_SIZE);
|
||||
memcpy (raw, img_transfer->buffer, SECUGEN_RAW_SIZE);
|
||||
memcpy (raw, self->bulk_buffer, SECUGEN_RAW_SIZE);
|
||||
|
||||
/*
|
||||
* SDK-matching image processing pipeline:
|
||||
|
|
@ -1428,15 +1427,16 @@ detect_bulk_cb (FpiUsbTransfer *transfer,
|
|||
gpointer user_data,
|
||||
GError *error)
|
||||
{
|
||||
FpiDeviceSecugen *self = FPI_DEVICE_SECUGEN (dev);
|
||||
|
||||
if (error)
|
||||
{
|
||||
fpi_ssm_mark_failed (transfer->ssm, error);
|
||||
return;
|
||||
}
|
||||
|
||||
fpi_ssm_set_data (transfer->ssm,
|
||||
fpi_usb_transfer_ref (transfer),
|
||||
(GDestroyNotify) fpi_usb_transfer_unref);
|
||||
memcpy (self->bulk_buffer, transfer->buffer,
|
||||
MIN ((gsize) transfer->actual_length, (gsize) SECUGEN_BULK_BUF_SIZE));
|
||||
fpi_ssm_next_state (transfer->ssm);
|
||||
}
|
||||
|
||||
|
|
@ -1482,7 +1482,6 @@ detect_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
|
||||
case DETECT_ANALYZE:
|
||||
{
|
||||
FpiUsbTransfer *img_transfer = fpi_ssm_get_data (ssm);
|
||||
guint64 sum = 0;
|
||||
/* Use central 50% of the 956x688 raw sensor area */
|
||||
int start_row = SECUGEN_RAW_HEIGHT / 4;
|
||||
|
|
@ -1499,10 +1498,9 @@ detect_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
{
|
||||
int idx = y * SECUGEN_RAW_WIDTH + x;
|
||||
|
||||
if (idx < (int) img_transfer->actual_length &&
|
||||
idx < SECUGEN_BULK_BUF_SIZE)
|
||||
if (idx < SECUGEN_BULK_BUF_SIZE)
|
||||
{
|
||||
int val = (int) img_transfer->buffer[idx] -
|
||||
int val = (int) self->bulk_buffer[idx] -
|
||||
(int) self->cal_raw[idx];
|
||||
|
||||
if (val < 0)
|
||||
|
|
@ -1529,9 +1527,8 @@ detect_run_state (FpiSsm *ssm, FpDevice *_dev)
|
|||
* the reference with partial finger touches.
|
||||
*/
|
||||
if (mean <= 5)
|
||||
memcpy (self->cal_raw, img_transfer->buffer,
|
||||
MIN ((gsize) img_transfer->actual_length,
|
||||
(gsize) SECUGEN_BULK_BUF_SIZE));
|
||||
memcpy (self->cal_raw, self->bulk_buffer,
|
||||
SECUGEN_BULK_BUF_SIZE);
|
||||
|
||||
/* Schedule another poll */
|
||||
self->finger_poll_source =
|
||||
|
|
@ -1645,6 +1642,7 @@ dev_init (FpImageDevice *dev)
|
|||
|
||||
/* Allocate buffers */
|
||||
self->cal_raw = g_malloc0 (SECUGEN_BULK_BUF_SIZE);
|
||||
self->bulk_buffer = g_malloc0 (SECUGEN_BULK_BUF_SIZE);
|
||||
self->fw_data = g_malloc0 (SECUGEN_FW_DATA_SIZE);
|
||||
self->fw_data_len = 0;
|
||||
self->ref_image = NULL;
|
||||
|
|
@ -1664,6 +1662,7 @@ dev_deinit (FpImageDevice *dev)
|
|||
GError *error = NULL;
|
||||
|
||||
g_clear_pointer (&self->cal_raw, g_free);
|
||||
g_clear_pointer (&self->bulk_buffer, g_free);
|
||||
g_clear_pointer (&self->fw_data, g_free);
|
||||
g_clear_pointer (&self->ref_image, g_free);
|
||||
self->has_ref_image = FALSE;
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ struct _FpiDeviceSecugen
|
|||
guint8 sharpen_limit; /* Overall scaling factor (/10) */
|
||||
gboolean sharpen_enabled; /* Whether post-resize sharpening is active */
|
||||
|
||||
/* Bulk read buffer for capture/detect frames */
|
||||
guint8 *bulk_buffer; /* Reusable buffer for 657KB bulk reads */
|
||||
|
||||
/* Capture state */
|
||||
guint16 exposure; /* Current exposure value */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue