Merge branch 'wip/hadess/fpi-ssm-docs' into 'master'
Add fpi_ssm API docs See merge request libfprint/libfprint!14
This commit is contained in:
commit
1102d6e478
25 changed files with 966 additions and 802 deletions
|
@ -24,7 +24,7 @@
|
|||
</part>
|
||||
|
||||
<part>
|
||||
<title>API Documentation</title>
|
||||
<title>Library API Documentation</title>
|
||||
<xi:include href="xml/events.xml"/>
|
||||
<xi:include href="xml/discovery.xml"/>
|
||||
|
||||
|
@ -36,11 +36,10 @@
|
|||
<xi:include href="xml/img.xml"/>
|
||||
</part>
|
||||
|
||||
<!--
|
||||
<part>
|
||||
<title>Writing Drivers</title>
|
||||
<xi:include href="xml/fpi-ssm.xml"/>
|
||||
</part>
|
||||
-->
|
||||
|
||||
<index id="api-index">
|
||||
<title>API Index</title>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<INCLUDE>fprint.h</INCLUDE>
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>fprint.h</INCLUDE>
|
||||
<FILE>events</FILE>
|
||||
<TITLE>Initialisation and events handling</TITLE>
|
||||
fp_set_debug
|
||||
|
@ -17,6 +17,7 @@ fp_set_pollfd_notifiers
|
|||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>fprint.h</INCLUDE>
|
||||
<FILE>discovery</FILE>
|
||||
<TITLE>Device discovery</TITLE>
|
||||
fp_dscv_dev
|
||||
|
@ -32,6 +33,7 @@ fp_dscv_dev_for_dscv_print
|
|||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>fprint.h</INCLUDE>
|
||||
<FILE>drv</FILE>
|
||||
fp_driver
|
||||
fp_driver_get_name
|
||||
|
@ -41,6 +43,7 @@ fp_driver_get_scan_type
|
|||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>fprint.h</INCLUDE>
|
||||
<FILE>dev</FILE>
|
||||
fp_dev
|
||||
fp_scan_type
|
||||
|
@ -91,6 +94,7 @@ fp_async_capture_stop
|
|||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>fprint.h</INCLUDE>
|
||||
<FILE>print_data</FILE>
|
||||
fp_finger
|
||||
fp_print_data
|
||||
|
@ -106,6 +110,7 @@ fp_print_data_get_devtype
|
|||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>fprint.h</INCLUDE>
|
||||
<FILE>dscv_print</FILE>
|
||||
fp_dscv_print
|
||||
fp_discover_prints
|
||||
|
@ -117,6 +122,7 @@ fp_dscv_print_delete
|
|||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>fprint.h</INCLUDE>
|
||||
<FILE>img</FILE>
|
||||
fp_img
|
||||
fp_minutia
|
||||
|
@ -131,5 +137,28 @@ fp_img_get_minutiae
|
|||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>fprint.h</INCLUDE>
|
||||
<FILE>poll</FILE>
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>fpi-ssm.h</INCLUDE>
|
||||
<FILE>fpi-ssm</FILE>
|
||||
fpi_ssm
|
||||
ssm_completed_fn
|
||||
ssm_handler_fn
|
||||
|
||||
fpi_ssm_new
|
||||
fpi_ssm_free
|
||||
fpi_ssm_start
|
||||
fpi_ssm_start_subsm
|
||||
|
||||
fpi_ssm_next_state
|
||||
fpi_ssm_jump_to_state
|
||||
fpi_ssm_mark_completed
|
||||
fpi_ssm_mark_failed
|
||||
fpi_ssm_set_user_data
|
||||
fpi_ssm_get_user_data
|
||||
fpi_ssm_get_error
|
||||
fpi_ssm_get_cur_state
|
||||
</SECTION>
|
||||
|
|
|
@ -101,12 +101,12 @@ static void stub_capture_stop_cb(struct fp_img_dev *dev, int result, void *user_
|
|||
/* check that read succeeded but ignore all data */
|
||||
static void generic_ignore_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
else if (transfer->length != transfer->actual_length)
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
else
|
||||
fpi_ssm_next_state(ssm);
|
||||
|
||||
|
@ -117,16 +117,16 @@ static void generic_ignore_data_cb(struct libusb_transfer *transfer)
|
|||
static void generic_write_regv_cb(struct fp_img_dev *dev, int result,
|
||||
void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
if (result == 0)
|
||||
fpi_ssm_next_state(ssm);
|
||||
else
|
||||
fpi_ssm_mark_aborted(ssm, result);
|
||||
fpi_ssm_mark_failed(ssm, result);
|
||||
}
|
||||
|
||||
/* read the specified number of bytes from the IN endpoint but throw them
|
||||
* away, then increment the SSM */
|
||||
static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
|
||||
static void generic_read_ignore_data(fpi_ssm *ssm, size_t bytes)
|
||||
{
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
unsigned char *data;
|
||||
|
@ -134,7 +134,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -557,17 +557,17 @@ enum capture_states {
|
|||
static void capture_read_strip_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
unsigned char *stripdata;
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
unsigned char *data = transfer->buffer;
|
||||
int sum, i;
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
} else if (transfer->length != transfer->actual_length) {
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -594,7 +594,7 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
|
|||
}
|
||||
|
||||
if (sum < 0) {
|
||||
fpi_ssm_mark_aborted(ssm, sum);
|
||||
fpi_ssm_mark_failed(ssm, sum);
|
||||
goto out;
|
||||
}
|
||||
fp_dbg("sum=%d", sum);
|
||||
|
@ -643,7 +643,7 @@ out:
|
|||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void capture_run_state(struct fpi_ssm *ssm)
|
||||
static void capture_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -672,7 +672,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
unsigned char *data;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -684,13 +684,13 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
static void capture_sm_complete(struct fpi_ssm *ssm)
|
||||
static void capture_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -708,7 +708,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
|
|||
static void start_capture(struct fp_img_dev *dev)
|
||||
{
|
||||
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
if (aesdev->deactivating) {
|
||||
complete_deactivation(dev);
|
||||
|
@ -738,7 +738,7 @@ enum activate_states {
|
|||
ACTIVATE_NUM_STATES,
|
||||
};
|
||||
|
||||
static void activate_run_state(struct fpi_ssm *ssm)
|
||||
static void activate_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
|
@ -753,7 +753,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
|
||||
/* jump to finger detection */
|
||||
static void activate_sm_complete(struct fpi_ssm *ssm)
|
||||
static void activate_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
fp_dbg("status %d", fpi_ssm_get_error(ssm));
|
||||
|
@ -767,7 +767,7 @@ static void activate_sm_complete(struct fpi_ssm *ssm)
|
|||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct aes1610_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
aesdev->read_regs_retry_count = 0;
|
||||
|
|
|
@ -180,22 +180,22 @@ static int regval_from_dump(unsigned char *data, uint8_t target)
|
|||
static void generic_write_regv_cb(struct fp_img_dev *dev, int result,
|
||||
void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
if (result == 0)
|
||||
fpi_ssm_next_state(ssm);
|
||||
else
|
||||
fpi_ssm_mark_aborted(ssm, result);
|
||||
fpi_ssm_mark_failed(ssm, result);
|
||||
}
|
||||
|
||||
/* check that read succeeded but ignore all data */
|
||||
static void generic_ignore_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
else if (transfer->length != transfer->actual_length)
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
else
|
||||
fpi_ssm_next_state(ssm);
|
||||
|
||||
|
@ -205,7 +205,7 @@ static void generic_ignore_data_cb(struct libusb_transfer *transfer)
|
|||
|
||||
/* read the specified number of bytes from the IN endpoint but throw them
|
||||
* away, then increment the SSM */
|
||||
static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
|
||||
static void generic_read_ignore_data(fpi_ssm *ssm, size_t bytes)
|
||||
{
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
unsigned char *data;
|
||||
|
@ -213,7 +213,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ enum capture_states {
|
|||
static void capture_read_strip_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
unsigned char *stripdata;
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
unsigned char *data = transfer->buffer;
|
||||
|
@ -444,23 +444,23 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
|
|||
int threshold;
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
} else if (transfer->length != transfer->actual_length) {
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
threshold = regval_from_dump(data + 1 + 192*8 + 1 + 16*2 + 1 + 8,
|
||||
AES2501_REG_DATFMT);
|
||||
if (threshold < 0) {
|
||||
fpi_ssm_mark_aborted(ssm, threshold);
|
||||
fpi_ssm_mark_failed(ssm, threshold);
|
||||
goto out;
|
||||
}
|
||||
|
||||
sum = sum_histogram_values(data + 1 + 192*8, threshold & 0x0f);
|
||||
if (sum < 0) {
|
||||
fpi_ssm_mark_aborted(ssm, sum);
|
||||
fpi_ssm_mark_failed(ssm, sum);
|
||||
goto out;
|
||||
}
|
||||
fp_dbg("sum=%d", sum);
|
||||
|
@ -520,7 +520,7 @@ out:
|
|||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void capture_run_state(struct fpi_ssm *ssm)
|
||||
static void capture_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -553,7 +553,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
unsigned char *data;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -565,13 +565,13 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
static void capture_sm_complete(struct fpi_ssm *ssm)
|
||||
static void capture_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -589,7 +589,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
|
|||
static void start_capture(struct fp_img_dev *dev)
|
||||
{
|
||||
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
if (aesdev->deactivating) {
|
||||
complete_deactivation(dev);
|
||||
|
@ -713,11 +713,11 @@ enum activate_states {
|
|||
void activate_read_regs_cb(struct fp_img_dev *dev, int status,
|
||||
unsigned char *regs, void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
if (status != 0) {
|
||||
fpi_ssm_mark_aborted(ssm, status);
|
||||
fpi_ssm_mark_failed(ssm, status);
|
||||
} else {
|
||||
fp_dbg("reg 0xaf = %x", regs[0x5f]);
|
||||
if (regs[0x5f] != 0x6b || ++aesdev->read_regs_retry_count == 13)
|
||||
|
@ -730,14 +730,14 @@ void activate_read_regs_cb(struct fp_img_dev *dev, int status,
|
|||
static void activate_init3_cb(struct fp_img_dev *dev, int result,
|
||||
void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
if (result == 0)
|
||||
fpi_ssm_jump_to_state(ssm, READ_REGS);
|
||||
else
|
||||
fpi_ssm_mark_aborted(ssm, result);
|
||||
fpi_ssm_mark_failed(ssm, result);
|
||||
}
|
||||
|
||||
static void activate_run_state(struct fpi_ssm *ssm)
|
||||
static void activate_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
|
@ -791,7 +791,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void activate_sm_complete(struct fpi_ssm *ssm)
|
||||
static void activate_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
fp_dbg("status %d", fpi_ssm_get_error(ssm));
|
||||
|
@ -805,7 +805,7 @@ static void activate_sm_complete(struct fpi_ssm *ssm)
|
|||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct aes2501_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
aesdev->read_regs_retry_count = 0;
|
||||
|
|
|
@ -200,7 +200,7 @@ enum capture_states {
|
|||
};
|
||||
|
||||
/* Returns number of processed bytes */
|
||||
static int process_strip_data(struct fpi_ssm *ssm, unsigned char *data)
|
||||
static int process_strip_data(fpi_ssm *ssm, unsigned char *data)
|
||||
{
|
||||
unsigned char *stripdata;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
@ -231,20 +231,20 @@ static int process_strip_data(struct fpi_ssm *ssm, unsigned char *data)
|
|||
|
||||
static void capture_reqs_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
|
||||
(transfer->length == transfer->actual_length)) {
|
||||
fpi_ssm_next_state(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void capture_set_idle_reqs_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
|
@ -265,14 +265,14 @@ static void capture_set_idle_reqs_cb(struct libusb_transfer *transfer)
|
|||
/* marking machine complete will re-trigger finger detection loop */
|
||||
fpi_ssm_mark_completed(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void capture_read_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
unsigned char *data = transfer->buffer;
|
||||
|
@ -280,7 +280,7 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
|
|||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
fp_dbg("request is not completed, %d", transfer->status);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,7 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
|
|||
r = process_strip_data(ssm, data);
|
||||
if (r < 0) {
|
||||
fp_dbg("Processing strip data failed: %d", r);
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
goto out;
|
||||
}
|
||||
aesdev->heartbeat_cnt = 0;
|
||||
|
@ -323,7 +323,7 @@ out:
|
|||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void capture_run_state(struct fpi_ssm *ssm)
|
||||
static void capture_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
int r;
|
||||
|
@ -333,7 +333,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
{
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT, capture_reqs,
|
||||
|
@ -341,7 +341,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
r = libusb_submit_transfer(transfer);
|
||||
if (r < 0) {
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -351,7 +351,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
unsigned char *data;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -371,7 +371,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
{
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT, capture_set_idle_reqs,
|
||||
|
@ -379,14 +379,14 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
r = libusb_submit_transfer(transfer);
|
||||
if (r < 0) {
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
}
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
static void capture_sm_complete(struct fpi_ssm *ssm)
|
||||
static void capture_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -404,7 +404,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
|
|||
static void start_capture(struct fp_img_dev *dev)
|
||||
{
|
||||
struct aes2550_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
if (aesdev->deactivating) {
|
||||
complete_deactivation(dev);
|
||||
|
@ -444,25 +444,25 @@ enum activate_states {
|
|||
|
||||
static void init_reqs_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
|
||||
(transfer->length == transfer->actual_length)) {
|
||||
fpi_ssm_next_state(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void init_read_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
|
||||
fpi_ssm_next_state(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
g_free(transfer->buffer);
|
||||
libusb_free_transfer(transfer);
|
||||
|
@ -472,18 +472,18 @@ static void init_read_data_cb(struct libusb_transfer *transfer)
|
|||
* need more info for implementaion */
|
||||
static void calibrate_read_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
|
||||
fpi_ssm_next_state(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
g_free(transfer->buffer);
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void activate_run_state(struct fpi_ssm *ssm)
|
||||
static void activate_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
int r;
|
||||
|
@ -493,7 +493,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
{
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT, init_reqs,
|
||||
|
@ -501,7 +501,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
r = libusb_submit_transfer(transfer);
|
||||
if (r < 0) {
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -511,7 +511,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
unsigned char *data;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -523,7 +523,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -531,7 +531,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
{
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), EP_OUT, calibrate_reqs,
|
||||
|
@ -539,7 +539,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
r = libusb_submit_transfer(transfer);
|
||||
if (r < 0) {
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -549,7 +549,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
unsigned char *data;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -561,14 +561,14 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void activate_sm_complete(struct fpi_ssm *ssm)
|
||||
static void activate_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
fp_dbg("status %d", fpi_ssm_get_error(ssm));
|
||||
|
@ -581,7 +581,7 @@ static void activate_sm_complete(struct fpi_ssm *ssm)
|
|||
|
||||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, activate_sm_complete);
|
||||
|
|
|
@ -37,7 +37,7 @@ static void complete_deactivation(struct fp_img_dev *dev);
|
|||
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
static void aesX660_send_cmd_timeout(struct fpi_ssm *ssm, const unsigned char *cmd,
|
||||
static void aesX660_send_cmd_timeout(fpi_ssm *ssm, const unsigned char *cmd,
|
||||
size_t cmd_len, libusb_transfer_cb_fn callback, int timeout)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
@ -45,7 +45,7 @@ static void aesX660_send_cmd_timeout(struct fpi_ssm *ssm, const unsigned char *c
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,17 +56,17 @@ static void aesX660_send_cmd_timeout(struct fpi_ssm *ssm, const unsigned char *c
|
|||
if (r < 0) {
|
||||
fp_dbg("failed to submit transfer\n");
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
}
|
||||
}
|
||||
|
||||
static void aesX660_send_cmd(struct fpi_ssm *ssm, const unsigned char *cmd,
|
||||
static void aesX660_send_cmd(fpi_ssm *ssm, const unsigned char *cmd,
|
||||
size_t cmd_len, libusb_transfer_cb_fn callback)
|
||||
{
|
||||
return aesX660_send_cmd_timeout(ssm, cmd, cmd_len, callback, BULK_TIMEOUT);
|
||||
}
|
||||
|
||||
static void aesX660_read_response(struct fpi_ssm *ssm, size_t buf_len,
|
||||
static void aesX660_read_response(fpi_ssm *ssm, size_t buf_len,
|
||||
libusb_transfer_cb_fn callback)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
@ -75,7 +75,7 @@ static void aesX660_read_response(struct fpi_ssm *ssm, size_t buf_len,
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -89,13 +89,13 @@ static void aesX660_read_response(struct fpi_ssm *ssm, size_t buf_len,
|
|||
fp_dbg("Failed to submit rx transfer: %d\n", r);
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
static void aesX660_send_cmd_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
|
||||
(transfer->length == transfer->actual_length)) {
|
||||
|
@ -103,25 +103,25 @@ static void aesX660_send_cmd_cb(struct libusb_transfer *transfer)
|
|||
} else {
|
||||
fp_dbg("tx transfer status: %d, actual_len: %.4x\n",
|
||||
transfer->status, transfer->actual_length);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void aesX660_read_calibrate_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
unsigned char *data = transfer->buffer;
|
||||
|
||||
if ((transfer->status != LIBUSB_TRANSFER_COMPLETED) ||
|
||||
(transfer->length != transfer->actual_length)) {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
/* Calibrate response was read correctly? */
|
||||
if (data[AESX660_RESPONSE_TYPE_OFFSET] != AESX660_CALIBRATE_RESPONSE) {
|
||||
fp_dbg("Bogus calibrate response: %.2x\n", data[0]);
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ enum finger_det_states {
|
|||
|
||||
static void finger_det_read_fd_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
unsigned char *data = transfer->buffer;
|
||||
|
@ -159,13 +159,13 @@ static void finger_det_read_fd_data_cb(struct libusb_transfer *transfer)
|
|||
if ((transfer->status != LIBUSB_TRANSFER_COMPLETED) ||
|
||||
(transfer->length != transfer->actual_length)) {
|
||||
fp_dbg("Failed to read FD data\n");
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (data[AESX660_RESPONSE_TYPE_OFFSET] != AESX660_FINGER_DET_RESPONSE) {
|
||||
fp_dbg("Bogus FD response: %.2x\n", data[0]);
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -184,18 +184,18 @@ out:
|
|||
|
||||
static void finger_det_set_idle_cmd_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
|
||||
(transfer->length == transfer->actual_length)) {
|
||||
fpi_ssm_mark_completed(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void finger_det_sm_complete(struct fpi_ssm *ssm)
|
||||
static void finger_det_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -215,7 +215,7 @@ static void finger_det_sm_complete(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void finger_det_run_state(struct fpi_ssm *ssm)
|
||||
static void finger_det_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case FINGER_DET_SEND_LED_CMD:
|
||||
|
@ -239,7 +239,7 @@ static void finger_det_run_state(struct fpi_ssm *ssm)
|
|||
|
||||
static void start_finger_detection(struct fp_img_dev *dev)
|
||||
{
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
if (aesdev->deactivating) {
|
||||
|
@ -263,7 +263,7 @@ enum capture_states {
|
|||
};
|
||||
|
||||
/* Returns number of processed bytes */
|
||||
static int process_stripe_data(struct fpi_ssm *ssm, unsigned char *data)
|
||||
static int process_stripe_data(fpi_ssm *ssm, unsigned char *data)
|
||||
{
|
||||
struct fpi_frame *stripe;
|
||||
unsigned char *stripdata;
|
||||
|
@ -294,7 +294,7 @@ static int process_stripe_data(struct fpi_ssm *ssm, unsigned char *data)
|
|||
|
||||
static void capture_set_idle_cmd_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
|
@ -313,14 +313,14 @@ static void capture_set_idle_cmd_cb(struct libusb_transfer *transfer)
|
|||
fpi_imgdev_report_finger_status(dev, FALSE);
|
||||
fpi_ssm_mark_completed(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void capture_read_stripe_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
unsigned char *data = transfer->buffer;
|
||||
|
@ -328,7 +328,7 @@ static void capture_read_stripe_data_cb(struct libusb_transfer *transfer)
|
|||
size_t copied, actual_len = transfer->actual_length;
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -371,7 +371,7 @@ out:
|
|||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void capture_run_state(struct fpi_ssm *ssm)
|
||||
static void capture_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -400,7 +400,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void capture_sm_complete(struct fpi_ssm *ssm)
|
||||
static void capture_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -420,7 +420,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
|
|||
static void start_capture(struct fp_img_dev *dev)
|
||||
{
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
if (aesdev->deactivating) {
|
||||
complete_deactivation(dev);
|
||||
|
@ -448,7 +448,7 @@ enum activate_states {
|
|||
|
||||
static void activate_read_id_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
unsigned char *data = transfer->buffer;
|
||||
|
@ -456,7 +456,7 @@ static void activate_read_id_cb(struct libusb_transfer *transfer)
|
|||
if ((transfer->status != LIBUSB_TRANSFER_COMPLETED) ||
|
||||
(transfer->length != transfer->actual_length)) {
|
||||
fp_dbg("read_id cmd failed\n");
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
/* ID was read correctly */
|
||||
|
@ -465,7 +465,7 @@ static void activate_read_id_cb(struct libusb_transfer *transfer)
|
|||
data[4], data[3], data[5], data[6], data[7]);
|
||||
} else {
|
||||
fp_dbg("Bogus read ID response: %.2x\n", data[AESX660_RESPONSE_TYPE_OFFSET]);
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ static void activate_read_id_cb(struct libusb_transfer *transfer)
|
|||
break;
|
||||
default:
|
||||
fp_dbg("Failed to init device! init status: %.2x\n", data[7]);
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ out:
|
|||
|
||||
static void activate_read_init_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
unsigned char *data = transfer->buffer;
|
||||
|
@ -509,14 +509,14 @@ static void activate_read_init_cb(struct libusb_transfer *transfer)
|
|||
if ((transfer->status != LIBUSB_TRANSFER_COMPLETED) ||
|
||||
(transfer->length != transfer->actual_length)) {
|
||||
fp_dbg("read_init transfer status: %d, actual_len: %d\n", transfer->status, transfer->actual_length);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
/* ID was read correctly */
|
||||
if (data[0] != 0x42 || data[3] != 0x01) {
|
||||
fp_dbg("Bogus read init response: %.2x %.2x\n", data[0],
|
||||
data[3]);
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
goto out;
|
||||
}
|
||||
aesdev->init_cmd_idx++;
|
||||
|
@ -534,7 +534,7 @@ out:
|
|||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void activate_run_state(struct fpi_ssm *ssm)
|
||||
static void activate_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct aesX660_dev *aesdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -580,7 +580,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void activate_sm_complete(struct fpi_ssm *ssm)
|
||||
static void activate_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
int err = fpi_ssm_get_error(ssm);
|
||||
|
@ -594,7 +594,7 @@ static void activate_sm_complete(struct fpi_ssm *ssm)
|
|||
|
||||
int aesX660_dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, activate_sm_complete);
|
||||
|
|
|
@ -313,7 +313,7 @@ static void elan_submit_image(struct fp_img_dev *dev)
|
|||
fpi_imgdev_image_captured(dev, img);
|
||||
}
|
||||
|
||||
static void elan_cmd_done(struct fpi_ssm *ssm)
|
||||
static void elan_cmd_done(fpi_ssm *ssm)
|
||||
{
|
||||
G_DEBUG_HERE();
|
||||
fpi_ssm_next_state(ssm);
|
||||
|
@ -321,7 +321,7 @@ static void elan_cmd_done(struct fpi_ssm *ssm)
|
|||
|
||||
static void elan_cmd_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
|
@ -335,7 +335,7 @@ static void elan_cmd_cb(struct libusb_transfer *transfer)
|
|||
fp_dbg("transfer length error: expected %d, got %d",
|
||||
transfer->length, transfer->actual_length);
|
||||
elan_dev_reset(elandev);
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
} else if (transfer->endpoint & LIBUSB_ENDPOINT_IN) {
|
||||
/* just finished receiving */
|
||||
dbg_buf(elandev->last_read, transfer->actual_length);
|
||||
|
@ -348,21 +348,21 @@ static void elan_cmd_cb(struct libusb_transfer *transfer)
|
|||
break;
|
||||
case LIBUSB_TRANSFER_CANCELLED:
|
||||
fp_dbg("transfer cancelled");
|
||||
fpi_ssm_mark_aborted(ssm, -ECANCELED);
|
||||
fpi_ssm_mark_failed(ssm, -ECANCELED);
|
||||
elan_deactivate(dev);
|
||||
break;
|
||||
case LIBUSB_TRANSFER_TIMED_OUT:
|
||||
fp_dbg("transfer timed out");
|
||||
fpi_ssm_mark_aborted(ssm, -ETIMEDOUT);
|
||||
fpi_ssm_mark_failed(ssm, -ETIMEDOUT);
|
||||
break;
|
||||
default:
|
||||
fp_dbg("transfer failed: %d", transfer->status);
|
||||
elan_dev_reset(elandev);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
static void elan_cmd_read(struct fpi_ssm *ssm)
|
||||
static void elan_cmd_read(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -383,7 +383,7 @@ static void elan_cmd_read(struct fpi_ssm *ssm)
|
|||
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
elandev->cur_transfer = transfer;
|
||||
|
@ -398,10 +398,10 @@ static void elan_cmd_read(struct fpi_ssm *ssm)
|
|||
transfer->flags = LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||
int r = libusb_submit_transfer(transfer);
|
||||
if (r < 0)
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
|
||||
static void elan_run_cmd(struct fpi_ssm *ssm, const struct elan_cmd *cmd,
|
||||
static void elan_run_cmd(fpi_ssm *ssm, const struct elan_cmd *cmd,
|
||||
int cmd_timeout)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
@ -421,7 +421,7 @@ static void elan_run_cmd(struct fpi_ssm *ssm, const struct elan_cmd *cmd,
|
|||
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
elandev->cur_transfer = transfer;
|
||||
|
@ -432,7 +432,7 @@ static void elan_run_cmd(struct fpi_ssm *ssm, const struct elan_cmd *cmd,
|
|||
transfer->flags = LIBUSB_TRANSFER_FREE_TRANSFER;
|
||||
int r = libusb_submit_transfer(transfer);
|
||||
if (r < 0)
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
|
||||
enum stop_capture_states {
|
||||
|
@ -440,7 +440,7 @@ enum stop_capture_states {
|
|||
STOP_CAPTURE_NUM_STATES,
|
||||
};
|
||||
|
||||
static void stop_capture_run_state(struct fpi_ssm *ssm)
|
||||
static void stop_capture_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
G_DEBUG_HERE();
|
||||
|
||||
|
@ -451,7 +451,7 @@ static void stop_capture_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void stop_capture_complete(struct fpi_ssm *ssm)
|
||||
static void stop_capture_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -485,7 +485,7 @@ static void elan_stop_capture(struct fp_img_dev *dev)
|
|||
|
||||
elan_dev_reset(elandev);
|
||||
|
||||
struct fpi_ssm *ssm =
|
||||
fpi_ssm *ssm =
|
||||
fpi_ssm_new(fpi_imgdev_get_dev(dev), stop_capture_run_state,
|
||||
STOP_CAPTURE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
|
@ -500,7 +500,7 @@ enum capture_states {
|
|||
CAPTURE_NUM_STATES,
|
||||
};
|
||||
|
||||
static void capture_run_state(struct fpi_ssm *ssm)
|
||||
static void capture_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -521,12 +521,12 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
fpi_imgdev_report_finger_status(dev, TRUE);
|
||||
elan_run_cmd(ssm, &get_image_cmd, ELAN_CMD_TIMEOUT);
|
||||
} else
|
||||
fpi_ssm_mark_aborted(ssm, -EBADMSG);
|
||||
fpi_ssm_mark_failed(ssm, -EBADMSG);
|
||||
break;
|
||||
case CAPTURE_CHECK_ENOUGH_FRAMES:
|
||||
r = elan_save_img_frame(elandev);
|
||||
if (r < 0)
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
else if (elandev->num_frames < ELAN_MAX_FRAMES) {
|
||||
/* quickly stop if finger is removed */
|
||||
elandev->cmd_timeout = ELAN_FINGER_TIMEOUT;
|
||||
|
@ -538,7 +538,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void capture_complete(struct fpi_ssm *ssm)
|
||||
static void capture_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -578,7 +578,7 @@ static void elan_capture(struct fp_img_dev *dev)
|
|||
G_DEBUG_HERE();
|
||||
|
||||
elan_dev_reset(elandev);
|
||||
struct fpi_ssm *ssm =
|
||||
fpi_ssm *ssm =
|
||||
fpi_ssm_new(fpi_imgdev_get_dev(dev), capture_run_state, CAPTURE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, capture_complete);
|
||||
|
@ -586,7 +586,7 @@ static void elan_capture(struct fp_img_dev *dev)
|
|||
|
||||
static void fpi_ssm_next_state_async(void *data)
|
||||
{
|
||||
fpi_ssm_next_state((struct fpi_ssm *)data);
|
||||
fpi_ssm_next_state((fpi_ssm *)data);
|
||||
}
|
||||
|
||||
/* this function needs to have elandev->background and elandev->last_read to be
|
||||
|
@ -624,7 +624,7 @@ enum calibrate_states {
|
|||
CALIBRATE_NUM_STATES,
|
||||
};
|
||||
|
||||
static void calibrate_run_state(struct fpi_ssm *ssm)
|
||||
static void calibrate_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -660,7 +660,7 @@ static void calibrate_run_state(struct fpi_ssm *ssm)
|
|||
ELAN_CMD_TIMEOUT);
|
||||
else {
|
||||
fp_dbg("calibration failed");
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
}
|
||||
break;
|
||||
case CALIBRATE_CHECK_STATUS:
|
||||
|
@ -680,7 +680,7 @@ static void calibrate_run_state(struct fpi_ssm *ssm)
|
|||
&& elandev->last_read[0] == 0x01)
|
||||
elandev->calib_status = 0x01;
|
||||
if (!fpi_timeout_add(50, fpi_ssm_next_state_async, ssm))
|
||||
fpi_ssm_mark_aborted(ssm, -ETIME);
|
||||
fpi_ssm_mark_failed(ssm, -ETIME);
|
||||
}
|
||||
break;
|
||||
case CALIBRATE_REPEAT_STATUS:
|
||||
|
@ -689,7 +689,7 @@ static void calibrate_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void calibrate_complete(struct fpi_ssm *ssm)
|
||||
static void calibrate_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
|
@ -711,7 +711,7 @@ static void elan_calibrate(struct fp_img_dev *dev)
|
|||
elan_dev_reset(elandev);
|
||||
elandev->calib_atts_left = ELAN_CALIBRATION_ATTEMPTS;
|
||||
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), calibrate_run_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), calibrate_run_state,
|
||||
CALIBRATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, calibrate_complete);
|
||||
|
@ -726,7 +726,7 @@ enum activate_states {
|
|||
ACTIVATE_NUM_STATES,
|
||||
};
|
||||
|
||||
static void activate_run_state(struct fpi_ssm *ssm)
|
||||
static void activate_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct elan_dev *elandev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -770,7 +770,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void activate_complete(struct fpi_ssm *ssm)
|
||||
static void activate_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
|
@ -790,7 +790,7 @@ static void elan_activate(struct fp_img_dev *dev)
|
|||
G_DEBUG_HERE();
|
||||
elan_dev_reset(elandev);
|
||||
|
||||
struct fpi_ssm *ssm =
|
||||
fpi_ssm *ssm =
|
||||
fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state, ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, activate_complete);
|
||||
|
|
|
@ -210,8 +210,8 @@ static const struct usb_id elan_id_table[] = {
|
|||
{0, 0, 0,},
|
||||
};
|
||||
|
||||
static void elan_cmd_done(struct fpi_ssm *ssm);
|
||||
static void elan_cmd_read(struct fpi_ssm *ssm);
|
||||
static void elan_cmd_done(fpi_ssm *ssm);
|
||||
static void elan_cmd_read(fpi_ssm *ssm);
|
||||
|
||||
static void elan_calibrate(struct fp_img_dev *dev);
|
||||
static void elan_capture(struct fp_img_dev *dev);
|
||||
|
|
|
@ -669,14 +669,14 @@ static int async_tx(struct fp_img_dev *idev, unsigned int ep, void *cb,
|
|||
|
||||
static void async_tx_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
fp_warn("transfer is not completed (status=%d)",
|
||||
transfer->status);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
libusb_free_transfer(transfer);
|
||||
} else {
|
||||
unsigned char endpoint = transfer->endpoint;
|
||||
|
@ -691,7 +691,7 @@ static void async_tx_cb(struct libusb_transfer *transfer)
|
|||
length, actual_length);
|
||||
/* Chained with the answer */
|
||||
if (async_tx(idev, EP_IN, async_tx_cb, ssm))
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
} else if (endpoint == EP_IN) {
|
||||
dev->ans_len = actual_length;
|
||||
fpi_ssm_next_state(ssm);
|
||||
|
@ -699,7 +699,7 @@ static void async_tx_cb(struct libusb_transfer *transfer)
|
|||
}
|
||||
}
|
||||
|
||||
static void m_exit_state(struct fpi_ssm *ssm)
|
||||
static void m_exit_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
|
||||
|
@ -724,10 +724,10 @@ static void m_exit_state(struct fpi_ssm *ssm)
|
|||
|
||||
return;
|
||||
err:
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
|
||||
static void m_exit_complete(struct fpi_ssm *ssm)
|
||||
static void m_exit_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
|
@ -742,14 +742,14 @@ static void m_exit_complete(struct fpi_ssm *ssm)
|
|||
|
||||
static void m_exit_start(struct fp_img_dev *idev)
|
||||
{
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_exit_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_exit_state,
|
||||
EXIT_NUM_STATES);
|
||||
fp_dbg("Switching device to idle mode");
|
||||
fpi_ssm_set_user_data(ssm, idev);
|
||||
fpi_ssm_start(ssm, m_exit_complete);
|
||||
}
|
||||
|
||||
static void m_capture_state(struct fpi_ssm *ssm)
|
||||
static void m_capture_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
|
||||
|
@ -827,10 +827,10 @@ static void m_capture_state(struct fpi_ssm *ssm)
|
|||
|
||||
return;
|
||||
err:
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
|
||||
static void m_capture_complete(struct fpi_ssm *ssm)
|
||||
static void m_capture_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
|
||||
|
@ -852,7 +852,7 @@ static void m_capture_complete(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void m_finger_state(struct fpi_ssm *ssm)
|
||||
static void m_finger_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
|
||||
|
@ -945,16 +945,16 @@ static void m_finger_state(struct fpi_ssm *ssm)
|
|||
|
||||
return;
|
||||
err:
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
|
||||
static void m_finger_complete(struct fpi_ssm *ssm)
|
||||
static void m_finger_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
|
||||
|
||||
if (!fpi_ssm_get_error(ssm)) {
|
||||
struct fpi_ssm *ssm_cap;
|
||||
fpi_ssm *ssm_cap;
|
||||
ssm_cap = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_capture_state,
|
||||
CAP_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm_cap, idev);
|
||||
|
@ -973,7 +973,7 @@ static void m_finger_complete(struct fpi_ssm *ssm)
|
|||
|
||||
static void m_start_fingerdetect(struct fp_img_dev *idev)
|
||||
{
|
||||
struct fpi_ssm *ssmf;
|
||||
fpi_ssm *ssmf;
|
||||
ssmf = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_finger_state, FGR_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssmf, idev);
|
||||
fpi_ssm_start(ssmf, m_finger_complete);
|
||||
|
@ -982,7 +982,7 @@ static void m_start_fingerdetect(struct fp_img_dev *idev)
|
|||
/*
|
||||
* Tune value of VRT and VRB for contrast and brightness.
|
||||
*/
|
||||
static void m_tunevrb_state(struct fpi_ssm *ssm)
|
||||
static void m_tunevrb_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
|
||||
|
@ -1131,10 +1131,10 @@ static void m_tunevrb_state(struct fpi_ssm *ssm)
|
|||
|
||||
return;
|
||||
err:
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
|
||||
static void m_tunevrb_complete(struct fpi_ssm *ssm)
|
||||
static void m_tunevrb_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
|
@ -1156,7 +1156,7 @@ static void m_tunevrb_complete(struct fpi_ssm *ssm)
|
|||
* This function tunes the DCoffset value and adjusts the gain value if
|
||||
* required.
|
||||
*/
|
||||
static void m_tunedc_state(struct fpi_ssm *ssm)
|
||||
static void m_tunedc_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
|
||||
|
@ -1255,15 +1255,15 @@ static void m_tunedc_state(struct fpi_ssm *ssm)
|
|||
|
||||
return;
|
||||
err:
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
|
||||
}
|
||||
|
||||
static void m_tunedc_complete(struct fpi_ssm *ssm)
|
||||
static void m_tunedc_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
if (!fpi_ssm_get_error(ssm)) {
|
||||
struct fpi_ssm *ssm_tune;
|
||||
fpi_ssm *ssm_tune;
|
||||
ssm_tune = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_tunevrb_state,
|
||||
TUNEVRB_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm_tune, idev);
|
||||
|
@ -1278,7 +1278,7 @@ static void m_tunedc_complete(struct fpi_ssm *ssm)
|
|||
fpi_ssm_free(ssm);
|
||||
}
|
||||
|
||||
static void m_init_state(struct fpi_ssm *ssm)
|
||||
static void m_init_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
|
||||
|
@ -1375,15 +1375,15 @@ static void m_init_state(struct fpi_ssm *ssm)
|
|||
|
||||
return;
|
||||
err:
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
|
||||
}
|
||||
|
||||
static void m_init_complete(struct fpi_ssm *ssm)
|
||||
static void m_init_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
if (!fpi_ssm_get_error(ssm)) {
|
||||
struct fpi_ssm *ssm_tune;
|
||||
fpi_ssm *ssm_tune;
|
||||
ssm_tune = fpi_ssm_new(fpi_imgdev_get_dev(idev), m_tunedc_state,
|
||||
TUNEDC_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm_tune, idev);
|
||||
|
@ -1401,7 +1401,7 @@ static void m_init_complete(struct fpi_ssm *ssm)
|
|||
static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct etes603_dev *dev = fpi_imgdev_get_user_data(idev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
g_assert(dev);
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ struct sonly_dev {
|
|||
int dev_model;
|
||||
int img_width;
|
||||
|
||||
struct fpi_ssm *loopsm;
|
||||
fpi_ssm *loopsm;
|
||||
struct libusb_transfer *img_transfer[NUM_BULK_TRANSFERS];
|
||||
struct img_transfer_data *img_transfer_data;
|
||||
int num_flying;
|
||||
|
@ -100,7 +100,7 @@ struct sonly_dev {
|
|||
enum sonly_kill_transfers_action killing_transfers;
|
||||
int kill_status_code;
|
||||
union {
|
||||
struct fpi_ssm *kill_ssm;
|
||||
fpi_ssm *kill_ssm;
|
||||
void (*kill_cb)(struct fp_img_dev *dev);
|
||||
};
|
||||
};
|
||||
|
@ -180,7 +180,7 @@ static void last_transfer_killed(struct fp_img_dev *dev)
|
|||
switch (sdev->killing_transfers) {
|
||||
case ABORT_SSM:
|
||||
fp_dbg("abort ssm error %d", sdev->kill_status_code);
|
||||
fpi_ssm_mark_aborted(sdev->kill_ssm, sdev->kill_status_code);
|
||||
fpi_ssm_mark_failed(sdev->kill_ssm, sdev->kill_status_code);
|
||||
return;
|
||||
case ITERATE_SSM:
|
||||
fp_dbg("iterate ssm");
|
||||
|
@ -520,7 +520,7 @@ static void img_data_cb(struct libusb_transfer *transfer)
|
|||
/***** STATE MACHINE HELPERS *****/
|
||||
|
||||
struct write_regs_data {
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
struct libusb_transfer *transfer;
|
||||
const struct sonly_regwrite *regs;
|
||||
size_t num_regs;
|
||||
|
@ -534,7 +534,7 @@ static void write_regs_finished(struct write_regs_data *wrdata, int result)
|
|||
if (result == 0)
|
||||
fpi_ssm_next_state(wrdata->ssm);
|
||||
else
|
||||
fpi_ssm_mark_aborted(wrdata->ssm, result);
|
||||
fpi_ssm_mark_failed(wrdata->ssm, result);
|
||||
g_free(wrdata);
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,7 @@ static void write_regs_cb(struct libusb_transfer *transfer)
|
|||
write_regs_iterate(wrdata);
|
||||
}
|
||||
|
||||
static void sm_write_regs(struct fpi_ssm *ssm,
|
||||
static void sm_write_regs(fpi_ssm *ssm,
|
||||
const struct sonly_regwrite *regs, size_t num_regs)
|
||||
{
|
||||
struct write_regs_data *wrdata = g_malloc(sizeof(*wrdata));
|
||||
|
@ -584,7 +584,7 @@ static void sm_write_regs(struct fpi_ssm *ssm,
|
|||
wrdata->transfer = libusb_alloc_transfer(0);
|
||||
if (!wrdata->transfer) {
|
||||
g_free(wrdata);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -605,16 +605,16 @@ static void sm_write_regs(struct fpi_ssm *ssm,
|
|||
|
||||
static void sm_write_reg_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
g_free(transfer->buffer);
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
else
|
||||
fpi_ssm_next_state(ssm);
|
||||
|
||||
}
|
||||
|
||||
static void sm_write_reg(struct fpi_ssm *ssm, uint8_t reg, uint8_t value)
|
||||
static void sm_write_reg(fpi_ssm *ssm, uint8_t reg, uint8_t value)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
|
@ -622,7 +622,7 @@ static void sm_write_reg(struct fpi_ssm *ssm, uint8_t reg, uint8_t value)
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -641,18 +641,18 @@ static void sm_write_reg(struct fpi_ssm *ssm, uint8_t reg, uint8_t value)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
static void sm_read_reg_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
} else {
|
||||
sdev->read_reg_result = libusb_control_transfer_get_data(transfer)[0];
|
||||
fp_dbg("read reg result = %02x", sdev->read_reg_result);
|
||||
|
@ -662,7 +662,7 @@ static void sm_read_reg_cb(struct libusb_transfer *transfer)
|
|||
g_free(transfer->buffer);
|
||||
}
|
||||
|
||||
static void sm_read_reg(struct fpi_ssm *ssm, uint8_t reg)
|
||||
static void sm_read_reg(fpi_ssm *ssm, uint8_t reg)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
|
@ -670,7 +670,7 @@ static void sm_read_reg(struct fpi_ssm *ssm, uint8_t reg)
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -687,19 +687,19 @@ static void sm_read_reg(struct fpi_ssm *ssm, uint8_t reg)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
static void sm_await_intr_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
g_free(transfer->buffer);
|
||||
fpi_ssm_mark_aborted(ssm, transfer->status);
|
||||
fpi_ssm_mark_failed(ssm, transfer->status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -713,7 +713,7 @@ static void sm_await_intr_cb(struct libusb_transfer *transfer)
|
|||
fpi_ssm_next_state(ssm);
|
||||
}
|
||||
|
||||
static void sm_await_intr(struct fpi_ssm *ssm)
|
||||
static void sm_await_intr(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
|
@ -721,7 +721,7 @@ static void sm_await_intr(struct fpi_ssm *ssm)
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -737,7 +737,7 @@ static void sm_await_intr(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
libusb_free_transfer(transfer);
|
||||
g_free(data);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -763,7 +763,7 @@ enum awfsm_1000_states {
|
|||
AWFSM_1000_NUM_STATES,
|
||||
};
|
||||
|
||||
static void awfsm_2016_run_state(struct fpi_ssm *ssm)
|
||||
static void awfsm_2016_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -810,7 +810,7 @@ static void awfsm_2016_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void awfsm_1000_run_state(struct fpi_ssm *ssm)
|
||||
static void awfsm_1000_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case AWFSM_1000_WRITEV_1:
|
||||
|
@ -851,7 +851,7 @@ enum capsm_1001_states {
|
|||
CAPSM_1001_NUM_STATES,
|
||||
};
|
||||
|
||||
static void capsm_fire_bulk(struct fpi_ssm *ssm)
|
||||
static void capsm_fire_bulk(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -861,7 +861,7 @@ static void capsm_fire_bulk(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
if (i == 0) {
|
||||
/* first one failed: easy peasy */
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -881,7 +881,7 @@ static void capsm_fire_bulk(struct fpi_ssm *ssm)
|
|||
fpi_ssm_next_state(ssm);
|
||||
}
|
||||
|
||||
static void capsm_2016_run_state(struct fpi_ssm *ssm)
|
||||
static void capsm_2016_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -913,7 +913,7 @@ static void capsm_2016_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void capsm_1000_run_state(struct fpi_ssm *ssm)
|
||||
static void capsm_1000_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -939,7 +939,7 @@ static void capsm_1000_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void capsm_1001_run_state(struct fpi_ssm *ssm)
|
||||
static void capsm_1001_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -994,7 +994,7 @@ enum deinitsm_1001_states {
|
|||
DEINITSM_1001_NUM_STATES,
|
||||
};
|
||||
|
||||
static void deinitsm_2016_run_state(struct fpi_ssm *ssm)
|
||||
static void deinitsm_2016_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case DEINITSM_2016_WRITEV:
|
||||
|
@ -1003,7 +1003,7 @@ static void deinitsm_2016_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void deinitsm_1000_run_state(struct fpi_ssm *ssm)
|
||||
static void deinitsm_1000_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case DEINITSM_1000_WRITEV:
|
||||
|
@ -1012,7 +1012,7 @@ static void deinitsm_1000_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void deinitsm_1001_run_state(struct fpi_ssm *ssm)
|
||||
static void deinitsm_1001_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case DEINITSM_1001_WRITEV:
|
||||
|
@ -1048,7 +1048,7 @@ enum initsm_1001_states {
|
|||
INITSM_1001_NUM_STATES,
|
||||
};
|
||||
|
||||
static void initsm_2016_run_state(struct fpi_ssm *ssm)
|
||||
static void initsm_2016_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -1078,7 +1078,7 @@ static void initsm_2016_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void initsm_1000_run_state(struct fpi_ssm *ssm)
|
||||
static void initsm_1000_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case INITSM_1000_WRITEV_1:
|
||||
|
@ -1087,7 +1087,7 @@ static void initsm_1000_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void initsm_1001_run_state(struct fpi_ssm *ssm)
|
||||
static void initsm_1001_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case INITSM_1001_WRITEV_1:
|
||||
|
@ -1120,7 +1120,7 @@ enum loopsm_states {
|
|||
LOOPSM_NUM_STATES,
|
||||
};
|
||||
|
||||
static void loopsm_run_state(struct fpi_ssm *ssm)
|
||||
static void loopsm_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -1139,7 +1139,7 @@ static void loopsm_run_state(struct fpi_ssm *ssm)
|
|||
if (sdev->deactivating) {
|
||||
fpi_ssm_mark_completed(ssm);
|
||||
} else {
|
||||
struct fpi_ssm *awfsm = NULL;
|
||||
fpi_ssm *awfsm = NULL;
|
||||
switch (sdev->dev_model) {
|
||||
case UPEKSONLY_2016:
|
||||
awfsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), awfsm_2016_run_state,
|
||||
|
@ -1167,7 +1167,7 @@ static void loopsm_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
break;
|
||||
case LOOPSM_RUN_CAPSM: ;
|
||||
struct fpi_ssm *capsm = NULL;
|
||||
fpi_ssm *capsm = NULL;
|
||||
switch (sdev->dev_model) {
|
||||
case UPEKSONLY_2016:
|
||||
capsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), capsm_2016_run_state,
|
||||
|
@ -1188,7 +1188,7 @@ static void loopsm_run_state(struct fpi_ssm *ssm)
|
|||
case LOOPSM_CAPTURE:
|
||||
break;
|
||||
case LOOPSM_RUN_DEINITSM: ;
|
||||
struct fpi_ssm *deinitsm = NULL;
|
||||
fpi_ssm *deinitsm = NULL;
|
||||
switch (sdev->dev_model) {
|
||||
case UPEKSONLY_2016:
|
||||
deinitsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), deinitsm_2016_run_state,
|
||||
|
@ -1248,7 +1248,7 @@ static void dev_deactivate(struct fp_img_dev *dev)
|
|||
cancel_img_transfers(dev);
|
||||
}
|
||||
|
||||
static void loopsm_complete(struct fpi_ssm *ssm)
|
||||
static void loopsm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -1267,7 +1267,7 @@ static void loopsm_complete(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void initsm_complete(struct fpi_ssm *ssm)
|
||||
static void initsm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -1286,7 +1286,7 @@ static void initsm_complete(struct fpi_ssm *ssm)
|
|||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct sonly_dev *sdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm = NULL;
|
||||
fpi_ssm *ssm = NULL;
|
||||
int i;
|
||||
|
||||
sdev->deactivating = FALSE;
|
||||
|
|
|
@ -56,7 +56,7 @@ enum activate_states {
|
|||
ACTIVATE_NUM_STATES,
|
||||
};
|
||||
|
||||
static void upektc_next_init_cmd(struct fpi_ssm *ssm)
|
||||
static void upektc_next_init_cmd(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -70,7 +70,7 @@ static void upektc_next_init_cmd(struct fpi_ssm *ssm)
|
|||
|
||||
static void write_init_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
|
@ -81,24 +81,24 @@ static void write_init_cb(struct libusb_transfer *transfer)
|
|||
else
|
||||
upektc_next_init_cmd(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void read_init_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status == LIBUSB_TRANSFER_COMPLETED)
|
||||
upektc_next_init_cmd(ssm);
|
||||
else
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
g_free(transfer->buffer);
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void activate_run_state(struct fpi_ssm *ssm)
|
||||
static void activate_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -109,7 +109,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
{
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), upekdev->ep_out,
|
||||
|
@ -118,7 +118,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
r = libusb_submit_transfer(transfer);
|
||||
if (r < 0) {
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -128,7 +128,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
unsigned char *data;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -141,14 +141,14 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void activate_sm_complete(struct fpi_ssm *ssm)
|
||||
static void activate_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
fp_dbg("status %d", fpi_ssm_get_error(ssm));
|
||||
|
@ -283,31 +283,31 @@ enum capture_states {
|
|||
|
||||
static void capture_cmd_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
|
||||
(transfer->length == transfer->actual_length)) {
|
||||
fpi_ssm_next_state(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void capture_read_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
unsigned char *data = transfer->buffer;
|
||||
struct fp_img *img;
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
fp_dbg("request is not completed, %d", transfer->status);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
} else if (transfer->length != transfer->actual_length) {
|
||||
fp_dbg("expected %d, sent %d bytes", transfer->length, transfer->actual_length);
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ out:
|
|||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void capture_run_state(struct fpi_ssm *ssm)
|
||||
static void capture_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -332,7 +332,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
{
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(dev), upekdev->ep_out,
|
||||
|
@ -341,7 +341,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
r = libusb_submit_transfer(transfer);
|
||||
if (r < 0) {
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -351,7 +351,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
unsigned char *data;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -363,14 +363,14 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
static void capture_sm_complete(struct fpi_ssm *ssm)
|
||||
static void capture_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -388,7 +388,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
|
|||
static void start_capture(struct fp_img_dev *dev)
|
||||
{
|
||||
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
if (upekdev->deactivating) {
|
||||
complete_deactivation(dev);
|
||||
|
@ -404,7 +404,7 @@ static void start_capture(struct fp_img_dev *dev)
|
|||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct upektc_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
upekdev->init_idx = 0;
|
||||
|
|
|
@ -71,7 +71,7 @@ static void upektc_img_cmd_update_crc(unsigned char *cmd_buf, size_t size)
|
|||
cmd_buf[size - 1] = (crc & 0xff00) >> 8;
|
||||
}
|
||||
|
||||
static void upektc_img_submit_req(struct fpi_ssm *ssm,
|
||||
static void upektc_img_submit_req(fpi_ssm *ssm,
|
||||
const unsigned char *buf, size_t buf_size, unsigned char seq,
|
||||
libusb_transfer_cb_fn cb)
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ static void upektc_img_submit_req(struct fpi_ssm *ssm,
|
|||
BUG_ON(buf_size > MAX_CMD_SIZE);
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -99,11 +99,11 @@ static void upektc_img_submit_req(struct fpi_ssm *ssm,
|
|||
r = libusb_submit_transfer(transfer);
|
||||
if (r < 0) {
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
static void upektc_img_read_data(struct fpi_ssm *ssm, size_t buf_size, size_t buf_offset, libusb_transfer_cb_fn cb)
|
||||
static void upektc_img_read_data(fpi_ssm *ssm, size_t buf_size, size_t buf_offset, libusb_transfer_cb_fn cb)
|
||||
{
|
||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
@ -111,7 +111,7 @@ static void upektc_img_read_data(struct fpi_ssm *ssm, size_t buf_size, size_t bu
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ static void upektc_img_read_data(struct fpi_ssm *ssm, size_t buf_size, size_t bu
|
|||
r = libusb_submit_transfer(transfer);
|
||||
if (r < 0) {
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,11 +144,11 @@ enum capture_states {
|
|||
|
||||
static void capture_reqs_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if ((transfer->status != LIBUSB_TRANSFER_COMPLETED) ||
|
||||
(transfer->length != transfer->actual_length)) {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
|
@ -181,7 +181,7 @@ static int upektc_img_process_image_frame(unsigned char *image_buf, unsigned cha
|
|||
|
||||
static void capture_read_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
unsigned char *data = upekdev->response;
|
||||
|
@ -190,7 +190,7 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
|
|||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
fp_dbg("request is not completed, %d", transfer->status);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
|
|||
break;
|
||||
default:
|
||||
fp_err("Uknown response!\n");
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -300,11 +300,11 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
|
|||
break;
|
||||
default:
|
||||
fp_err("Not handled response!\n");
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
static void capture_run_state(struct fpi_ssm *ssm)
|
||||
static void capture_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -341,7 +341,7 @@ static void capture_run_state(struct fpi_ssm *ssm)
|
|||
};
|
||||
}
|
||||
|
||||
static void capture_sm_complete(struct fpi_ssm *ssm)
|
||||
static void capture_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -361,7 +361,7 @@ static void capture_sm_complete(struct fpi_ssm *ssm)
|
|||
static void start_capture(struct fp_img_dev *dev)
|
||||
{
|
||||
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
upekdev->image_size = 0;
|
||||
|
||||
|
@ -380,29 +380,29 @@ enum deactivate_states {
|
|||
|
||||
static void deactivate_reqs_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
|
||||
(transfer->length == transfer->actual_length)) {
|
||||
fpi_ssm_jump_to_state(ssm, CAPTURE_READ_DATA);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: process response properly */
|
||||
static void deactivate_read_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
|
||||
fpi_ssm_mark_completed(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
static void deactivate_run_state(struct fpi_ssm *ssm)
|
||||
static void deactivate_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -419,7 +419,7 @@ static void deactivate_run_state(struct fpi_ssm *ssm)
|
|||
};
|
||||
}
|
||||
|
||||
static void deactivate_sm_complete(struct fpi_ssm *ssm)
|
||||
static void deactivate_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -440,7 +440,7 @@ static void deactivate_sm_complete(struct fpi_ssm *ssm)
|
|||
static void start_deactivation(struct fp_img_dev *dev)
|
||||
{
|
||||
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
upekdev->image_size = 0;
|
||||
|
||||
|
@ -467,40 +467,40 @@ enum activate_states {
|
|||
|
||||
static void init_reqs_ctrl_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
|
||||
fpi_ssm_next_state(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
static void init_reqs_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
|
||||
(transfer->length == transfer->actual_length)) {
|
||||
fpi_ssm_next_state(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: process response properly */
|
||||
static void init_read_data_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
|
||||
fpi_ssm_next_state(ssm);
|
||||
} else {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
static void activate_run_state(struct fpi_ssm *ssm)
|
||||
static void activate_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct libusb_transfer *transfer;
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
@ -516,7 +516,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
|
||||
transfer = libusb_alloc_transfer(0);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
transfer->flags |= LIBUSB_TRANSFER_FREE_BUFFER |
|
||||
|
@ -531,7 +531,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -564,7 +564,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void activate_sm_complete(struct fpi_ssm *ssm)
|
||||
static void activate_sm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
int err = fpi_ssm_get_error(ssm);
|
||||
|
@ -580,7 +580,7 @@ static void activate_sm_complete(struct fpi_ssm *ssm)
|
|||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct upektc_img_dev *upekdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), activate_run_state,
|
||||
ACTIVATE_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
upekdev->seq = 0;
|
||||
|
|
|
@ -484,7 +484,7 @@ enum initsm_states {
|
|||
INITSM_NUM_STATES,
|
||||
};
|
||||
|
||||
static void initsm_read_msg_response_cb(struct fpi_ssm *ssm,
|
||||
static void initsm_read_msg_response_cb(fpi_ssm *ssm,
|
||||
enum read_msg_status status, uint8_t seq,
|
||||
unsigned char expect_subcmd, unsigned char subcmd)
|
||||
{
|
||||
|
@ -494,15 +494,15 @@ static void initsm_read_msg_response_cb(struct fpi_ssm *ssm,
|
|||
if (status != READ_MSG_RESPONSE) {
|
||||
fp_err("expected response, got %d seq=%x in state %d", status, seq,
|
||||
fpi_ssm_get_cur_state(ssm));
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
} else if (subcmd != expect_subcmd) {
|
||||
fp_warn("expected response to subcmd 0x%02x, got response to %02x in "
|
||||
"state %d", expect_subcmd, subcmd, fpi_ssm_get_cur_state(ssm));
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
} else if (seq != upekdev->seq) {
|
||||
fp_err("expected response to cmd seq=%02x, got response to %02x "
|
||||
"in state %d", upekdev->seq, seq, fpi_ssm_get_cur_state(ssm));
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
} else {
|
||||
fp_dbg("state %d completed", fpi_ssm_get_cur_state(ssm));
|
||||
fpi_ssm_next_state(ssm);
|
||||
|
@ -513,7 +513,7 @@ static void read28_0b_cb(struct fp_dev *dev, enum read_msg_status status,
|
|||
uint8_t seq, unsigned char subcmd, unsigned char *data, size_t data_len,
|
||||
void *user_data)
|
||||
{
|
||||
initsm_read_msg_response_cb((struct fpi_ssm *) user_data, status, seq,
|
||||
initsm_read_msg_response_cb((fpi_ssm *) user_data, status, seq,
|
||||
0x0b, subcmd);
|
||||
}
|
||||
|
||||
|
@ -521,7 +521,7 @@ static void read28_0c_cb(struct fp_dev *dev, enum read_msg_status status,
|
|||
uint8_t seq, unsigned char subcmd, unsigned char *data, size_t data_len,
|
||||
void *user_data)
|
||||
{
|
||||
initsm_read_msg_response_cb((struct fpi_ssm *) user_data, status, seq,
|
||||
initsm_read_msg_response_cb((fpi_ssm *) user_data, status, seq,
|
||||
0x0c, subcmd);
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ static void read28_08_cb(struct fp_dev *dev, enum read_msg_status status,
|
|||
uint8_t seq, unsigned char subcmd, unsigned char *data, size_t data_len,
|
||||
void *user_data)
|
||||
{
|
||||
initsm_read_msg_response_cb((struct fpi_ssm *) user_data, status, seq,
|
||||
initsm_read_msg_response_cb((fpi_ssm *) user_data, status, seq,
|
||||
0x08, subcmd);
|
||||
}
|
||||
|
||||
|
@ -537,7 +537,7 @@ static void read28_07_cb(struct fp_dev *dev, enum read_msg_status status,
|
|||
uint8_t seq, unsigned char subcmd, unsigned char *data, size_t data_len,
|
||||
void *user_data)
|
||||
{
|
||||
initsm_read_msg_response_cb((struct fpi_ssm *) user_data, status, seq,
|
||||
initsm_read_msg_response_cb((fpi_ssm *) user_data, status, seq,
|
||||
0x07, subcmd);
|
||||
}
|
||||
|
||||
|
@ -545,30 +545,30 @@ static void read28_06_cb(struct fp_dev *dev, enum read_msg_status status,
|
|||
uint8_t seq, unsigned char subcmd, unsigned char *data, size_t data_len,
|
||||
void *user_data)
|
||||
{
|
||||
initsm_read_msg_response_cb((struct fpi_ssm *) user_data, status, seq,
|
||||
initsm_read_msg_response_cb((fpi_ssm *) user_data, status, seq,
|
||||
0x06, subcmd);
|
||||
}
|
||||
|
||||
static void initsm_read_msg_cmd_cb(struct fpi_ssm *ssm,
|
||||
static void initsm_read_msg_cmd_cb(fpi_ssm *ssm,
|
||||
enum read_msg_status status, uint8_t expect_seq, uint8_t seq)
|
||||
{
|
||||
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
|
||||
struct upekts_dev *upekdev = fpi_dev_get_user_data(dev);
|
||||
|
||||
if (status == READ_MSG_ERROR) {
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
return;
|
||||
} else if (status != READ_MSG_CMD) {
|
||||
fp_err("expected command, got %d seq=%x in state %d", status, seq,
|
||||
fpi_ssm_get_cur_state(ssm));
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
return;
|
||||
}
|
||||
upekdev->seq = seq;
|
||||
if (seq != expect_seq) {
|
||||
fp_err("expected seq=%x, got %x in state %d", expect_seq, seq,
|
||||
fpi_ssm_get_cur_state(ssm));
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -579,41 +579,41 @@ static void read_msg05_cb(struct fp_dev *dev, enum read_msg_status status,
|
|||
uint8_t seq, unsigned char subcmd, unsigned char *data, size_t data_len,
|
||||
void *user_data)
|
||||
{
|
||||
initsm_read_msg_cmd_cb((struct fpi_ssm *) user_data, status, 5, seq);
|
||||
initsm_read_msg_cmd_cb((fpi_ssm *) user_data, status, 5, seq);
|
||||
}
|
||||
|
||||
static void read_msg03_cb(struct fp_dev *dev, enum read_msg_status status,
|
||||
uint8_t seq, unsigned char subcmd, unsigned char *data, size_t data_len,
|
||||
void *user_data)
|
||||
{
|
||||
initsm_read_msg_cmd_cb((struct fpi_ssm *) user_data, status, 3, seq);
|
||||
initsm_read_msg_cmd_cb((fpi_ssm *) user_data, status, 3, seq);
|
||||
}
|
||||
|
||||
static void ctrl400_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
/* FIXME check length? */
|
||||
if (transfer->status == LIBUSB_TRANSFER_COMPLETED)
|
||||
fpi_ssm_next_state(ssm);
|
||||
else
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
g_free(transfer->buffer);
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void initsm_read_msg_handler(struct fpi_ssm *ssm,
|
||||
static void initsm_read_msg_handler(fpi_ssm *ssm,
|
||||
read_msg_cb_fn callback)
|
||||
{
|
||||
int r = read_msg_async(fpi_ssm_get_dev(ssm), callback, ssm);
|
||||
if (r < 0) {
|
||||
fp_err("async read msg failed in state %d", fpi_ssm_get_cur_state(ssm));
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
static void initsm_send_msg_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
if (transfer->status == LIBUSB_TRANSFER_COMPLETED
|
||||
&& transfer->length == transfer->actual_length) {
|
||||
fp_dbg("state %d completed", fpi_ssm_get_cur_state(ssm));
|
||||
|
@ -621,12 +621,12 @@ static void initsm_send_msg_cb(struct libusb_transfer *transfer)
|
|||
} else {
|
||||
fp_err("failed, state=%d rqlength=%d actual_length=%d", fpi_ssm_get_cur_state(ssm),
|
||||
transfer->length, transfer->actual_length);
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
}
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void initsm_send_msg28_handler(struct fpi_ssm *ssm,
|
||||
static void initsm_send_msg28_handler(fpi_ssm *ssm,
|
||||
unsigned char subcmd, const unsigned char *data, uint16_t innerlen)
|
||||
{
|
||||
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
|
||||
|
@ -636,7 +636,7 @@ static void initsm_send_msg28_handler(struct fpi_ssm *ssm,
|
|||
transfer = alloc_send_cmd28_transfer(dev, subcmd, data, innerlen,
|
||||
initsm_send_msg_cb, ssm);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -645,11 +645,11 @@ static void initsm_send_msg28_handler(struct fpi_ssm *ssm,
|
|||
fp_err("urb submission failed error %d in state %d", r, fpi_ssm_get_cur_state(ssm));
|
||||
g_free(transfer->buffer);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
static void initsm_run_state(struct fpi_ssm *ssm)
|
||||
static void initsm_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
|
||||
struct upekts_dev *upekdev = fpi_dev_get_user_data(dev);
|
||||
|
@ -662,7 +662,7 @@ static void initsm_run_state(struct fpi_ssm *ssm)
|
|||
|
||||
transfer = libusb_alloc_transfer(0);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -676,7 +676,7 @@ static void initsm_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
break;
|
||||
case READ_MSG03:
|
||||
|
@ -686,7 +686,7 @@ static void initsm_run_state(struct fpi_ssm *ssm)
|
|||
transfer = alloc_send_cmdresponse_transfer(dev, ++upekdev->seq,
|
||||
init_resp03, sizeof(init_resp03), initsm_send_msg_cb, ssm);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -694,7 +694,7 @@ static void initsm_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(transfer->buffer);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
break;
|
||||
case READ_MSG05:
|
||||
|
@ -736,7 +736,7 @@ static void initsm_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static struct fpi_ssm *initsm_new(struct fp_dev *dev)
|
||||
static fpi_ssm *initsm_new(struct fp_dev *dev)
|
||||
{
|
||||
return fpi_ssm_new(dev, initsm_run_state, INITSM_NUM_STATES);
|
||||
}
|
||||
|
@ -749,11 +749,11 @@ enum deinitsm_states {
|
|||
|
||||
static void send_resp07_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
else if (transfer->length != transfer->actual_length)
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
else
|
||||
fpi_ssm_next_state(ssm);
|
||||
libusb_free_transfer(transfer);
|
||||
|
@ -763,28 +763,28 @@ static void read_msg01_cb(struct fp_dev *dev, enum read_msg_status status,
|
|||
uint8_t seq, unsigned char subcmd, unsigned char *data, size_t data_len,
|
||||
void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
struct upekts_dev *upekdev = fpi_dev_get_user_data(dev);
|
||||
|
||||
if (status == READ_MSG_ERROR) {
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
return;
|
||||
} else if (status != READ_MSG_CMD) {
|
||||
fp_err("expected command, got %d seq=%x", status, seq);
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
return;
|
||||
}
|
||||
upekdev->seq = seq;
|
||||
if (seq != 1) {
|
||||
fp_err("expected seq=1, got %x", seq);
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
fpi_ssm_next_state(ssm);
|
||||
}
|
||||
|
||||
static void deinitsm_state_handler(struct fpi_ssm *ssm)
|
||||
static void deinitsm_state_handler(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
|
||||
int r;
|
||||
|
@ -797,7 +797,7 @@ static void deinitsm_state_handler(struct fpi_ssm *ssm)
|
|||
transfer = alloc_send_cmdresponse_transfer(dev, 0x07, &dummy, 1,
|
||||
send_resp07_cb, ssm);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -805,18 +805,18 @@ static void deinitsm_state_handler(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(transfer->buffer);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
break;
|
||||
case READ_MSG01: ;
|
||||
r = read_msg_async(dev, read_msg01_cb, ssm);
|
||||
if (r < 0)
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static struct fpi_ssm *deinitsm_new(struct fp_dev *dev)
|
||||
static fpi_ssm *deinitsm_new(struct fp_dev *dev)
|
||||
{
|
||||
return fpi_ssm_new(dev, deinitsm_state_handler, DEINITSM_NUM_STATES);
|
||||
}
|
||||
|
@ -868,14 +868,14 @@ enum enroll_start_sm_states {
|
|||
};
|
||||
|
||||
/* Called when the device initialization state machine completes */
|
||||
static void enroll_start_sm_cb_initsm(struct fpi_ssm *initsm)
|
||||
static void enroll_start_sm_cb_initsm(fpi_ssm *initsm)
|
||||
{
|
||||
struct fpi_ssm *enroll_start_ssm = fpi_ssm_get_user_data(initsm);
|
||||
fpi_ssm *enroll_start_ssm = fpi_ssm_get_user_data(initsm);
|
||||
int error = fpi_ssm_get_error(initsm);
|
||||
|
||||
fpi_ssm_free(initsm);
|
||||
if (error)
|
||||
fpi_ssm_mark_aborted(enroll_start_ssm, error);
|
||||
fpi_ssm_mark_failed(enroll_start_ssm, error);
|
||||
else
|
||||
fpi_ssm_next_state(enroll_start_ssm);
|
||||
}
|
||||
|
@ -883,11 +883,11 @@ static void enroll_start_sm_cb_initsm(struct fpi_ssm *initsm)
|
|||
/* called when enroll init URB has completed */
|
||||
static void enroll_start_sm_cb_init(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
else if (transfer->length != transfer->actual_length)
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
else
|
||||
fpi_ssm_next_state(ssm);
|
||||
libusb_free_transfer(transfer);
|
||||
|
@ -898,32 +898,32 @@ static void enroll_start_sm_cb_msg28(struct fp_dev *dev,
|
|||
unsigned char *data, size_t data_len, void *user_data)
|
||||
{
|
||||
struct upekts_dev *upekdev = fpi_dev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
|
||||
if (status != READ_MSG_RESPONSE) {
|
||||
fp_err("expected response, got %d seq=%x", status, seq);
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
} else if (subcmd != 0) {
|
||||
fp_warn("expected response to subcmd 0, got response to %02x",
|
||||
subcmd);
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
} else if (seq != upekdev->seq) {
|
||||
fp_err("expected response to cmd seq=%02x, got response to %02x",
|
||||
upekdev->seq, seq);
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
} else {
|
||||
fpi_ssm_next_state(ssm);
|
||||
}
|
||||
}
|
||||
|
||||
static void enroll_start_sm_run_state(struct fpi_ssm *ssm)
|
||||
static void enroll_start_sm_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
|
||||
int r;
|
||||
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case RUN_INITSM: ;
|
||||
struct fpi_ssm *initsm = initsm_new(dev);
|
||||
fpi_ssm *initsm = initsm_new(dev);
|
||||
fpi_ssm_set_user_data(initsm, ssm);
|
||||
fpi_ssm_start(initsm, enroll_start_sm_cb_initsm);
|
||||
break;
|
||||
|
@ -932,7 +932,7 @@ static void enroll_start_sm_run_state(struct fpi_ssm *ssm)
|
|||
transfer = alloc_send_cmd28_transfer(dev, 0x02, enroll_init,
|
||||
sizeof(enroll_init), enroll_start_sm_cb_init, ssm);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -940,7 +940,7 @@ static void enroll_start_sm_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(transfer->buffer);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
break;
|
||||
case READ_ENROLL_MSG28: ;
|
||||
|
@ -950,7 +950,7 @@ static void enroll_start_sm_run_state(struct fpi_ssm *ssm)
|
|||
* include a 30 01 poll somewhere? */
|
||||
r = read_msg_async(dev, enroll_start_sm_cb_msg28, ssm);
|
||||
if (r < 0)
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1112,7 +1112,7 @@ static void enroll_iterate(struct fp_dev *dev)
|
|||
}
|
||||
}
|
||||
|
||||
static void enroll_started(struct fpi_ssm *ssm)
|
||||
static void enroll_started(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
|
||||
fpi_drvcb_enroll_started(dev, fpi_ssm_get_error(ssm));
|
||||
|
@ -1128,7 +1128,7 @@ static int enroll_start(struct fp_dev *dev)
|
|||
struct upekts_dev *upekdev = fpi_dev_get_user_data(dev);
|
||||
|
||||
/* do_init state machine first */
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(dev, enroll_start_sm_run_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(dev, enroll_start_sm_run_state,
|
||||
ENROLL_START_NUM_STATES);
|
||||
|
||||
upekdev->enroll_passed = FALSE;
|
||||
|
@ -1136,7 +1136,7 @@ static int enroll_start(struct fp_dev *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void enroll_stop_deinit_cb(struct fpi_ssm *ssm)
|
||||
static void enroll_stop_deinit_cb(fpi_ssm *ssm)
|
||||
{
|
||||
/* don't really care about errors */
|
||||
fpi_drvcb_enroll_stopped(fpi_ssm_get_dev(ssm));
|
||||
|
@ -1145,12 +1145,12 @@ static void enroll_stop_deinit_cb(struct fpi_ssm *ssm)
|
|||
|
||||
static int enroll_stop(struct fp_dev *dev)
|
||||
{
|
||||
struct fpi_ssm *ssm = deinitsm_new(dev);
|
||||
fpi_ssm *ssm = deinitsm_new(dev);
|
||||
fpi_ssm_start(ssm, enroll_stop_deinit_cb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void verify_stop_deinit_cb(struct fpi_ssm *ssm)
|
||||
static void verify_stop_deinit_cb(fpi_ssm *ssm)
|
||||
{
|
||||
/* don't really care about errors */
|
||||
fpi_drvcb_verify_stopped(fpi_ssm_get_dev(ssm));
|
||||
|
@ -1159,7 +1159,7 @@ static void verify_stop_deinit_cb(struct fpi_ssm *ssm)
|
|||
|
||||
static void do_verify_stop(struct fp_dev *dev)
|
||||
{
|
||||
struct fpi_ssm *ssm = deinitsm_new(dev);
|
||||
fpi_ssm *ssm = deinitsm_new(dev);
|
||||
fpi_ssm_start(ssm, verify_stop_deinit_cb);
|
||||
}
|
||||
|
||||
|
@ -1176,14 +1176,14 @@ enum {
|
|||
};
|
||||
|
||||
/* Called when the device initialization state machine completes */
|
||||
static void verify_start_sm_cb_initsm(struct fpi_ssm *initsm)
|
||||
static void verify_start_sm_cb_initsm(fpi_ssm *initsm)
|
||||
{
|
||||
struct fpi_ssm *verify_start_ssm = fpi_ssm_get_user_data(initsm);
|
||||
fpi_ssm *verify_start_ssm = fpi_ssm_get_user_data(initsm);
|
||||
int err;
|
||||
|
||||
err = fpi_ssm_get_error(initsm);
|
||||
if (err)
|
||||
fpi_ssm_mark_aborted(verify_start_ssm, err);
|
||||
fpi_ssm_mark_failed(verify_start_ssm, err);
|
||||
else
|
||||
fpi_ssm_next_state(verify_start_ssm);
|
||||
fpi_ssm_free(initsm);
|
||||
|
@ -1191,24 +1191,24 @@ static void verify_start_sm_cb_initsm(struct fpi_ssm *initsm)
|
|||
|
||||
static void verify_init_2803_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
else if (transfer->length != transfer->actual_length)
|
||||
fpi_ssm_mark_aborted(ssm, -EPROTO);
|
||||
fpi_ssm_mark_failed(ssm, -EPROTO);
|
||||
else
|
||||
fpi_ssm_next_state(ssm);
|
||||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void verify_start_sm_run_state(struct fpi_ssm *ssm)
|
||||
static void verify_start_sm_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
|
||||
int r;
|
||||
|
||||
switch (fpi_ssm_get_cur_state(ssm)) {
|
||||
case VERIFY_RUN_INITSM: ;
|
||||
struct fpi_ssm *initsm = initsm_new(dev);
|
||||
fpi_ssm *initsm = initsm_new(dev);
|
||||
fpi_ssm_set_user_data(initsm, ssm);
|
||||
fpi_ssm_start(initsm, verify_start_sm_cb_initsm);
|
||||
break;
|
||||
|
@ -1225,7 +1225,7 @@ static void verify_start_sm_run_state(struct fpi_ssm *ssm)
|
|||
verify_init_2803_cb, ssm);
|
||||
g_free(data);
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1233,7 +1233,7 @@ static void verify_start_sm_run_state(struct fpi_ssm *ssm)
|
|||
if (r < 0) {
|
||||
g_free(transfer->buffer);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1391,7 +1391,7 @@ static void verify_iterate(struct fp_dev *dev)
|
|||
}
|
||||
}
|
||||
|
||||
static void verify_started(struct fpi_ssm *ssm)
|
||||
static void verify_started(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
|
||||
struct upekts_dev *upekdev = fpi_dev_get_user_data(dev);
|
||||
|
@ -1408,7 +1408,7 @@ static void verify_started(struct fpi_ssm *ssm)
|
|||
static int verify_start(struct fp_dev *dev)
|
||||
{
|
||||
struct upekts_dev *upekdev = fpi_dev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(dev, verify_start_sm_run_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(dev, verify_start_sm_run_state,
|
||||
VERIFY_NUM_STATES);
|
||||
upekdev->stop_verify = FALSE;
|
||||
fpi_ssm_start(ssm, verify_started);
|
||||
|
|
|
@ -306,17 +306,17 @@ static int read_regs(struct fp_img_dev *dev, uint16_t first_reg,
|
|||
|
||||
static void response_cb(struct fp_img_dev *dev, int status, void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
if (status == 0)
|
||||
fpi_ssm_next_state(ssm);
|
||||
else
|
||||
fpi_ssm_mark_aborted(ssm, status);
|
||||
fpi_ssm_mark_failed(ssm, status);
|
||||
}
|
||||
|
||||
static void challenge_cb(struct fp_img_dev *dev, int status,
|
||||
uint16_t num_regs, unsigned char *data, void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
unsigned char *respdata;
|
||||
PK11Context *ctx;
|
||||
|
@ -324,7 +324,7 @@ static void challenge_cb(struct fp_img_dev *dev, int status,
|
|||
|
||||
r = status;
|
||||
if (status != 0) {
|
||||
fpi_ssm_mark_aborted(ssm, status);
|
||||
fpi_ssm_mark_failed(ssm, status);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ static void challenge_cb(struct fp_img_dev *dev, int status,
|
|||
g_free(respdata);
|
||||
}
|
||||
if (r < 0)
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -354,7 +354,7 @@ static void challenge_cb(struct fp_img_dev *dev, int status,
|
|||
* authentication scheme, where the device challenges the authenticity of the
|
||||
* driver.
|
||||
*/
|
||||
static void sm_do_challenge_response(struct fpi_ssm *ssm)
|
||||
static void sm_do_challenge_response(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
int r;
|
||||
|
@ -362,7 +362,7 @@ static void sm_do_challenge_response(struct fpi_ssm *ssm)
|
|||
G_DEBUG_HERE();
|
||||
r = read_regs(dev, REG_CHALLENGE, CR_LENGTH, challenge_cb, ssm);
|
||||
if (r < 0)
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
|
||||
/***** INTERRUPT HANDLING *****/
|
||||
|
@ -508,24 +508,24 @@ static int dev_change_state(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
|||
|
||||
static void sm_write_reg_cb(struct fp_img_dev *dev, int result, void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
|
||||
if (result)
|
||||
fpi_ssm_mark_aborted(ssm, result);
|
||||
fpi_ssm_mark_failed(ssm, result);
|
||||
else
|
||||
fpi_ssm_next_state(ssm);
|
||||
}
|
||||
|
||||
static void sm_write_regs(struct fpi_ssm *ssm, uint16_t first_reg, uint16_t num_regs,
|
||||
static void sm_write_regs(fpi_ssm *ssm, uint16_t first_reg, uint16_t num_regs,
|
||||
void *data)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
int r = write_regs(dev, first_reg, num_regs, data, sm_write_reg_cb, ssm);
|
||||
if (r < 0)
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
|
||||
static void sm_write_reg(struct fpi_ssm *ssm, uint16_t reg,
|
||||
static void sm_write_reg(fpi_ssm *ssm, uint16_t reg,
|
||||
unsigned char value)
|
||||
{
|
||||
sm_write_regs(ssm, reg, 1, &value);
|
||||
|
@ -534,11 +534,11 @@ static void sm_write_reg(struct fpi_ssm *ssm, uint16_t reg,
|
|||
static void sm_read_reg_cb(struct fp_img_dev *dev, int result,
|
||||
uint16_t num_regs, unsigned char *data, void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
if (result) {
|
||||
fpi_ssm_mark_aborted(ssm, result);
|
||||
fpi_ssm_mark_failed(ssm, result);
|
||||
} else {
|
||||
memcpy(urudev->last_reg_rd, data, num_regs);
|
||||
fp_dbg("reg value %x", urudev->last_reg_rd[0]);
|
||||
|
@ -546,29 +546,29 @@ static void sm_read_reg_cb(struct fp_img_dev *dev, int result,
|
|||
}
|
||||
}
|
||||
|
||||
static void sm_read_regs(struct fpi_ssm *ssm, uint16_t reg, uint16_t num_regs)
|
||||
static void sm_read_regs(fpi_ssm *ssm, uint16_t reg, uint16_t num_regs)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
int r;
|
||||
|
||||
if (num_regs > sizeof(urudev->last_reg_rd)) {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
fp_dbg("read %d regs at %x", num_regs, reg);
|
||||
r = read_regs(dev, reg, num_regs, sm_read_reg_cb, ssm);
|
||||
if (r < 0)
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
|
||||
static void sm_read_reg(struct fpi_ssm *ssm, uint16_t reg)
|
||||
static void sm_read_reg(fpi_ssm *ssm, uint16_t reg)
|
||||
{
|
||||
sm_read_regs(ssm, reg, 1);
|
||||
}
|
||||
|
||||
static void sm_set_hwstat(struct fpi_ssm *ssm, unsigned char value)
|
||||
static void sm_set_hwstat(fpi_ssm *ssm, unsigned char value)
|
||||
{
|
||||
fp_dbg("set %02x", value);
|
||||
sm_write_reg(ssm, REG_HWSTAT, value);
|
||||
|
@ -587,14 +587,14 @@ enum imaging_states {
|
|||
|
||||
static void image_transfer_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status == LIBUSB_TRANSFER_CANCELLED) {
|
||||
fp_dbg("cancelled");
|
||||
fpi_ssm_mark_aborted(ssm, -ECANCELED);
|
||||
fpi_ssm_mark_failed(ssm, -ECANCELED);
|
||||
} else if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
fp_dbg("error");
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
} else {
|
||||
fpi_ssm_next_state(ssm);
|
||||
}
|
||||
|
@ -687,7 +687,7 @@ static int calc_dev2(struct uru4k_image *img)
|
|||
return res / IMAGE_WIDTH;
|
||||
}
|
||||
|
||||
static void imaging_run_state(struct fpi_ssm *ssm)
|
||||
static void imaging_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -706,7 +706,7 @@ static void imaging_run_state(struct fpi_ssm *ssm)
|
|||
urudev->img_data, sizeof(struct uru4k_image), image_transfer_cb, ssm, 0);
|
||||
r = libusb_submit_transfer(urudev->img_transfer);
|
||||
if (r < 0)
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
break;
|
||||
case IMAGING_SEND_INDEX:
|
||||
fp_dbg("hw header lines %d", img->num_lines);
|
||||
|
@ -810,7 +810,7 @@ static void imaging_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void imaging_complete(struct fpi_ssm *ssm)
|
||||
static void imaging_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -862,19 +862,19 @@ enum rebootpwr_states {
|
|||
|
||||
static void rebootpwr_pause_cb(void *data)
|
||||
{
|
||||
struct fpi_ssm *ssm = data;
|
||||
fpi_ssm *ssm = data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
if (!--urudev->rebootpwr_ctr) {
|
||||
fp_err("could not reboot device power");
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
} else {
|
||||
fpi_ssm_jump_to_state(ssm, REBOOTPWR_GET_HWSTAT);
|
||||
}
|
||||
}
|
||||
|
||||
static void rebootpwr_run_state(struct fpi_ssm *ssm)
|
||||
static void rebootpwr_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -896,7 +896,7 @@ static void rebootpwr_run_state(struct fpi_ssm *ssm)
|
|||
break;
|
||||
case REBOOTPWR_PAUSE:
|
||||
if (fpi_timeout_add(10, rebootpwr_pause_cb, ssm) == NULL)
|
||||
fpi_ssm_mark_aborted(ssm, -ETIME);
|
||||
fpi_ssm_mark_failed(ssm, -ETIME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -939,13 +939,13 @@ enum powerup_states {
|
|||
|
||||
static void powerup_pause_cb(void *data)
|
||||
{
|
||||
struct fpi_ssm *ssm = data;
|
||||
fpi_ssm *ssm = data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
if (!--urudev->powerup_ctr) {
|
||||
fp_err("could not power device up");
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
} else if (!urudev->profile->auth_cr) {
|
||||
fpi_ssm_jump_to_state(ssm, POWERUP_SET_HWSTAT);
|
||||
} else {
|
||||
|
@ -953,7 +953,7 @@ static void powerup_pause_cb(void *data)
|
|||
}
|
||||
}
|
||||
|
||||
static void powerup_run_state(struct fpi_ssm *ssm)
|
||||
static void powerup_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -979,7 +979,7 @@ static void powerup_run_state(struct fpi_ssm *ssm)
|
|||
break;
|
||||
case POWERUP_PAUSE:
|
||||
if (fpi_timeout_add(10, powerup_pause_cb, ssm) == NULL)
|
||||
fpi_ssm_mark_aborted(ssm, -ETIME);
|
||||
fpi_ssm_mark_failed(ssm, -ETIME);
|
||||
break;
|
||||
case POWERUP_CHALLENGE_RESPONSE:
|
||||
sm_do_challenge_response(ssm);
|
||||
|
@ -1024,11 +1024,11 @@ enum init_states {
|
|||
static void init_scanpwr_irq_cb(struct fp_img_dev *dev, int status,
|
||||
uint16_t type, void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
if (status)
|
||||
fpi_ssm_mark_aborted(ssm, status);
|
||||
fpi_ssm_mark_failed(ssm, status);
|
||||
else if (type != IRQDATA_SCANPWR_ON)
|
||||
fp_dbg("ignoring interrupt");
|
||||
else if (fpi_ssm_get_cur_state(ssm) != INIT_AWAIT_SCAN_POWER) {
|
||||
|
@ -1042,7 +1042,7 @@ static void init_scanpwr_irq_cb(struct fp_img_dev *dev, int status,
|
|||
|
||||
static void init_scanpwr_timeout(void *user_data)
|
||||
{
|
||||
struct fpi_ssm *ssm = user_data;
|
||||
fpi_ssm *ssm = user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
|
@ -1052,13 +1052,13 @@ static void init_scanpwr_timeout(void *user_data)
|
|||
|
||||
if (++urudev->scanpwr_irq_timeouts >= 3) {
|
||||
fp_err("powerup timed out 3 times, giving up");
|
||||
fpi_ssm_mark_aborted(ssm, -ETIMEDOUT);
|
||||
fpi_ssm_mark_failed(ssm, -ETIMEDOUT);
|
||||
} else {
|
||||
fpi_ssm_jump_to_state(ssm, INIT_GET_HWSTAT);
|
||||
}
|
||||
}
|
||||
|
||||
static void init_run_state(struct fpi_ssm *ssm)
|
||||
static void init_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -1075,7 +1075,7 @@ static void init_run_state(struct fpi_ssm *ssm)
|
|||
fpi_ssm_jump_to_state(ssm, INIT_CHECK_HWSTAT_POWERDOWN);
|
||||
break;
|
||||
case INIT_REBOOT_POWER: ;
|
||||
struct fpi_ssm *rebootsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), rebootpwr_run_state,
|
||||
fpi_ssm *rebootsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), rebootpwr_run_state,
|
||||
REBOOTPWR_NUM_STATES);
|
||||
fpi_ssm_set_user_data(rebootsm, dev);
|
||||
fpi_ssm_start_subsm(ssm, rebootsm);
|
||||
|
@ -1088,13 +1088,13 @@ static void init_run_state(struct fpi_ssm *ssm)
|
|||
break;
|
||||
case INIT_POWERUP: ;
|
||||
if (!IRQ_HANDLER_IS_RUNNING(urudev)) {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
break;
|
||||
}
|
||||
urudev->irq_cb_data = ssm;
|
||||
urudev->irq_cb = init_scanpwr_irq_cb;
|
||||
|
||||
struct fpi_ssm *powerupsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), powerup_run_state,
|
||||
fpi_ssm *powerupsm = fpi_ssm_new(fpi_imgdev_get_dev(dev), powerup_run_state,
|
||||
POWERUP_NUM_STATES);
|
||||
fpi_ssm_set_user_data(powerupsm, dev);
|
||||
fpi_ssm_start_subsm(ssm, powerupsm);
|
||||
|
@ -1111,7 +1111,7 @@ static void init_run_state(struct fpi_ssm *ssm)
|
|||
urudev->scanpwr_irq_timeout = fpi_timeout_add(300,
|
||||
init_scanpwr_timeout, ssm);
|
||||
if (!urudev->scanpwr_irq_timeout) {
|
||||
fpi_ssm_mark_aborted(ssm, -ETIME);
|
||||
fpi_ssm_mark_failed(ssm, -ETIME);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -1138,7 +1138,7 @@ static void init_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void activate_initsm_complete(struct fpi_ssm *ssm)
|
||||
static void activate_initsm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
int r = fpi_ssm_get_error(ssm);
|
||||
|
@ -1160,7 +1160,7 @@ static void activate_initsm_complete(struct fpi_ssm *ssm)
|
|||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
int r;
|
||||
|
||||
r = start_irq_handler(dev);
|
||||
|
@ -1196,7 +1196,7 @@ static void dev_deactivate(struct fp_img_dev *dev)
|
|||
static int execute_state_change(struct fp_img_dev *dev)
|
||||
{
|
||||
struct uru4k_dev *urudev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
switch (urudev->activate_state) {
|
||||
case IMGDEV_STATE_INACTIVE:
|
||||
|
|
|
@ -74,10 +74,10 @@ enum v5s_cmd {
|
|||
|
||||
static void sm_write_reg_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
else
|
||||
fpi_ssm_next_state(ssm);
|
||||
|
||||
|
@ -85,7 +85,7 @@ static void sm_write_reg_cb(struct libusb_transfer *transfer)
|
|||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void sm_write_reg(struct fpi_ssm *ssm, unsigned char reg,
|
||||
static void sm_write_reg(fpi_ssm *ssm, unsigned char reg,
|
||||
unsigned char value)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
@ -94,7 +94,7 @@ static void sm_write_reg(struct fpi_ssm *ssm, unsigned char reg,
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -107,16 +107,16 @@ static void sm_write_reg(struct fpi_ssm *ssm, unsigned char reg,
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
static void sm_exec_cmd_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
else
|
||||
fpi_ssm_next_state(ssm);
|
||||
|
||||
|
@ -124,7 +124,7 @@ static void sm_exec_cmd_cb(struct libusb_transfer *transfer)
|
|||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void sm_exec_cmd(struct fpi_ssm *ssm, unsigned char cmd,
|
||||
static void sm_exec_cmd(fpi_ssm *ssm, unsigned char cmd,
|
||||
unsigned char param)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
|
@ -133,7 +133,7 @@ static void sm_exec_cmd(struct fpi_ssm *ssm, unsigned char cmd,
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ static void sm_exec_cmd(struct fpi_ssm *ssm, unsigned char cmd,
|
|||
if (r < 0) {
|
||||
g_free(data);
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,16 +187,16 @@ static gboolean finger_is_present(unsigned char *data)
|
|||
|
||||
/***** IMAGE ACQUISITION *****/
|
||||
|
||||
static void capture_iterate(struct fpi_ssm *ssm);
|
||||
static void capture_iterate(fpi_ssm *ssm);
|
||||
|
||||
static void capture_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ out:
|
|||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void capture_iterate(struct fpi_ssm *ssm)
|
||||
static void capture_iterate(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -227,7 +227,7 @@ static void capture_iterate(struct fpi_ssm *ssm)
|
|||
int r;
|
||||
|
||||
if (!transfer) {
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -238,12 +238,12 @@ static void capture_iterate(struct fpi_ssm *ssm)
|
|||
r = libusb_submit_transfer(transfer);
|
||||
if (r < 0) {
|
||||
libusb_free_transfer(transfer);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void sm_do_capture(struct fpi_ssm *ssm)
|
||||
static void sm_do_capture(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -265,7 +265,7 @@ enum loop_states {
|
|||
LOOP_NUM_STATES,
|
||||
};
|
||||
|
||||
static void loop_run_state(struct fpi_ssm *ssm)
|
||||
static void loop_run_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -293,7 +293,7 @@ static void loop_run_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void loopsm_complete(struct fpi_ssm *ssm)
|
||||
static void loopsm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -314,7 +314,7 @@ static void loopsm_complete(struct fpi_ssm *ssm)
|
|||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct v5s_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), loop_run_state,
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), loop_run_state,
|
||||
LOOP_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
vdev->deactivating = FALSE;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
/* Callback for async_write */
|
||||
static void async_write_callback(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
int transferred = transfer->actual_length, error =
|
||||
|
@ -36,14 +36,14 @@ static void async_write_callback(struct libusb_transfer *transfer)
|
|||
if (error != 0) {
|
||||
fp_err("USB write transfer: %s", libusb_error_name(error));
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
if (transferred != len) {
|
||||
fp_err("Written only %d of %d bytes", transferred, len);
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ static void async_write_callback(struct libusb_transfer *transfer)
|
|||
}
|
||||
|
||||
/* Send data to EP1, the only out endpoint */
|
||||
static void async_write(struct fpi_ssm *ssm, void *data, int len)
|
||||
static void async_write(fpi_ssm *ssm, void *data, int len)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct libusb_device_handle *usb_dev = fpi_imgdev_get_usb_dev(idev);
|
||||
|
@ -67,7 +67,7 @@ static void async_write(struct fpi_ssm *ssm, void *data, int len)
|
|||
/* Callback for async_read */
|
||||
static void async_read_callback(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
int transferred = transfer->actual_length, error =
|
||||
|
@ -78,14 +78,14 @@ static void async_read_callback(struct libusb_transfer *transfer)
|
|||
fp_err("USB read transfer on endpoint %d: %s", ep - 0x80,
|
||||
libusb_error_name(error));
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
if (transferred != len) {
|
||||
fp_err("Received %d instead of %d bytes", transferred, len);
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ static void async_read_callback(struct libusb_transfer *transfer)
|
|||
}
|
||||
|
||||
/* Receive data from the given ep and compare with expected */
|
||||
static void async_read(struct fpi_ssm *ssm, int ep, void *data, int len)
|
||||
static void async_read(fpi_ssm *ssm, int ep, void *data, int len)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct libusb_device_handle *usb_dev = fpi_imgdev_get_usb_dev(idev);
|
||||
|
@ -119,7 +119,7 @@ static void async_read(struct fpi_ssm *ssm, int ep, void *data, int len)
|
|||
/* Callback for async_read */
|
||||
static void async_abort_callback(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
int transferred = transfer->actual_length, error = transfer->status;
|
||||
|
@ -134,7 +134,7 @@ static void async_abort_callback(struct libusb_transfer *transfer)
|
|||
if (error != 0) {
|
||||
fp_err("USB write transfer: %s", libusb_error_name(error));
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ static void async_abort_callback(struct libusb_transfer *transfer)
|
|||
}
|
||||
|
||||
/* Receive data from the given ep and compare with expected */
|
||||
static void async_abort(struct fpi_ssm *ssm, int ep)
|
||||
static void async_abort(fpi_ssm *ssm, int ep)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct libusb_device_handle *usb_dev = fpi_imgdev_get_usb_dev(idev);
|
||||
|
@ -279,7 +279,7 @@ static void submit_image(struct fp_img_dev *idev)
|
|||
/* Proto functions */
|
||||
|
||||
/* SSM loop for clear_ep2 */
|
||||
static void clear_ep2_ssm(struct fpi_ssm *ssm)
|
||||
static void clear_ep2_ssm(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
|
@ -302,22 +302,22 @@ static void clear_ep2_ssm(struct fpi_ssm *ssm)
|
|||
default:
|
||||
fp_err("Unknown SUBSM1 state");
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
/* Send command to clear EP2 */
|
||||
static void clear_ep2(struct fpi_ssm *ssm)
|
||||
static void clear_ep2(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
struct fpi_ssm *subsm =
|
||||
fpi_ssm *subsm =
|
||||
fpi_ssm_new(fpi_imgdev_get_dev(idev), clear_ep2_ssm, SUBSM1_STATES);
|
||||
fpi_ssm_set_user_data(subsm, idev);
|
||||
fpi_ssm_start_subsm(ssm, subsm);
|
||||
}
|
||||
|
||||
static void send_control_packet_ssm(struct fpi_ssm *ssm)
|
||||
static void send_control_packet_ssm(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
|
||||
|
@ -363,7 +363,7 @@ static void send_control_packet_ssm(struct fpi_ssm *ssm)
|
|||
(vdev->interrupt, empty_interrupt, VFS_INTERRUPT_SIZE)) {
|
||||
fp_err("Unknown SUBSM2 state");
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
break;
|
||||
}
|
||||
async_abort(ssm, 3);
|
||||
|
@ -380,16 +380,16 @@ static void send_control_packet_ssm(struct fpi_ssm *ssm)
|
|||
default:
|
||||
fp_err("Unknown SUBSM2 state");
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
/* Send device state control packet */
|
||||
static void send_control_packet(struct fpi_ssm *ssm)
|
||||
static void send_control_packet(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
|
||||
struct fpi_ssm *subsm =
|
||||
fpi_ssm *subsm =
|
||||
fpi_ssm_new(fpi_imgdev_get_dev(idev), send_control_packet_ssm, SUBSM2_STATES);
|
||||
fpi_ssm_set_user_data(subsm, idev);
|
||||
fpi_ssm_start_subsm(ssm, subsm);
|
||||
|
@ -406,7 +406,7 @@ static void clear_data(struct vfs_dev_t *vdev)
|
|||
/* After receiving interrupt from EP3 */
|
||||
static void interrupt_callback(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
|
||||
|
||||
|
@ -423,7 +423,7 @@ static void interrupt_callback(struct libusb_transfer *transfer)
|
|||
fp_err("USB read interrupt transfer: %s",
|
||||
libusb_error_name(error));
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -432,7 +432,7 @@ static void interrupt_callback(struct libusb_transfer *transfer)
|
|||
fp_err("Unknown interrupt size %d", transferred);
|
||||
/* Abort ssm */
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -461,12 +461,12 @@ static void interrupt_callback(struct libusb_transfer *transfer)
|
|||
|
||||
/* Abort ssm */
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
|
||||
static void receive_callback(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
|
||||
|
||||
|
@ -476,7 +476,7 @@ static void receive_callback(struct libusb_transfer *transfer)
|
|||
fp_err("USB read transfer: %s", libusb_error_name(error));
|
||||
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ static void receive_callback(struct libusb_transfer *transfer)
|
|||
/* Stub to keep SSM alive when waiting an interrupt */
|
||||
static void wait_interrupt(void *data)
|
||||
{
|
||||
struct fpi_ssm *ssm = data;
|
||||
fpi_ssm *ssm = data;
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
|
||||
|
||||
|
@ -506,19 +506,19 @@ static void wait_interrupt(void *data)
|
|||
/* SSM stub to prepare device to another scan after orange light was on */
|
||||
static void another_scan(void *data)
|
||||
{
|
||||
struct fpi_ssm *ssm = data;
|
||||
fpi_ssm *ssm = data;
|
||||
fpi_ssm_jump_to_state(ssm, SSM_TURN_ON);
|
||||
}
|
||||
|
||||
/* Another SSM stub to continue after waiting for probable vdev->active changes */
|
||||
static void scan_completed(void *data)
|
||||
{
|
||||
struct fpi_ssm *ssm = data;
|
||||
fpi_ssm *ssm = data;
|
||||
fpi_ssm_next_state(ssm);
|
||||
}
|
||||
|
||||
/* Main SSM loop */
|
||||
static void activate_ssm(struct fpi_ssm *ssm)
|
||||
static void activate_ssm(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct libusb_device_handle *usb_dev = fpi_imgdev_get_usb_dev(idev);
|
||||
|
@ -664,14 +664,14 @@ static void activate_ssm(struct fpi_ssm *ssm)
|
|||
default:
|
||||
fp_err("Unknown state");
|
||||
fpi_imgdev_session_error(idev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
|
||||
/* Driver functions */
|
||||
|
||||
/* Callback for dev_activate ssm */
|
||||
static void dev_activate_callback(struct fpi_ssm *ssm)
|
||||
static void dev_activate_callback(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs_dev_t *vdev = fpi_imgdev_get_user_data(idev);
|
||||
|
@ -691,7 +691,7 @@ static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
|
|||
vdev->need_report = 1;
|
||||
vdev->ssm_active = 1;
|
||||
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), activate_ssm, SSM_STATES);
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), activate_ssm, SSM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, idev);
|
||||
fpi_ssm_start(ssm, dev_activate_callback);
|
||||
return 0;
|
||||
|
@ -713,7 +713,7 @@ static void dev_deactivate(struct fp_img_dev *idev)
|
|||
}
|
||||
|
||||
/* Callback for dev_open ssm */
|
||||
static void dev_open_callback(struct fpi_ssm *ssm)
|
||||
static void dev_open_callback(fpi_ssm *ssm)
|
||||
{
|
||||
/* Notify open complete */
|
||||
fpi_imgdev_open_complete(fpi_ssm_get_user_data(ssm), 0);
|
||||
|
@ -738,7 +738,7 @@ static int dev_open(struct fp_img_dev *idev, unsigned long driver_data)
|
|||
fpi_imgdev_set_user_data(idev, vdev);
|
||||
|
||||
/* Clearing previous device state */
|
||||
struct fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), activate_ssm, SSM_STATES);
|
||||
fpi_ssm *ssm = fpi_ssm_new(fpi_imgdev_get_dev(idev), activate_ssm, SSM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, idev);
|
||||
fpi_ssm_start(ssm, dev_open_callback);
|
||||
return 0;
|
||||
|
|
|
@ -199,7 +199,7 @@ static int result_code(struct fp_img_dev *dev, int result)
|
|||
/* Callback of asynchronous send */
|
||||
static void async_send_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
|
@ -214,7 +214,7 @@ static void async_send_cb(struct libusb_transfer *transfer)
|
|||
/* Transfer not completed, return IO error */
|
||||
fp_err("transfer not completed, status = %d", transfer->status);
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ static void async_send_cb(struct libusb_transfer *transfer)
|
|||
fp_err("length mismatch, got %d, expected %d",
|
||||
transfer->actual_length, transfer->length);
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ out:
|
|||
}
|
||||
|
||||
/* Submit asynchronous send */
|
||||
static void async_send(struct fpi_ssm *ssm)
|
||||
static void async_send(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -255,7 +255,7 @@ static void async_send(struct fpi_ssm *ssm)
|
|||
/* Allocation transfer failed, return no memory error */
|
||||
fp_err("allocation of usb transfer failed");
|
||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ static void async_send(struct fpi_ssm *ssm)
|
|||
libusb_free_transfer(vdev->transfer);
|
||||
fp_err("submit of usb transfer failed");
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ static void async_send(struct fpi_ssm *ssm)
|
|||
/* Callback of asynchronous recv */
|
||||
static void async_recv_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
|
@ -298,7 +298,7 @@ static void async_recv_cb(struct libusb_transfer *transfer)
|
|||
/* Transfer not completed, return IO error */
|
||||
fp_err("transfer not completed, status = %d", transfer->status);
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ static void async_recv_cb(struct libusb_transfer *transfer)
|
|||
fp_err("seqnum mismatch, got %04x, expected %04x",
|
||||
get_seqnum(vdev->buffer[1], vdev->buffer[0]), vdev->seqnum);
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ out:
|
|||
}
|
||||
|
||||
/* Submit asynchronous recv */
|
||||
static void async_recv(struct fpi_ssm *ssm)
|
||||
static void async_recv(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -342,7 +342,7 @@ static void async_recv(struct fpi_ssm *ssm)
|
|||
/* Allocation transfer failed, return no memory error */
|
||||
fp_err("allocation of usb transfer failed");
|
||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -357,17 +357,17 @@ static void async_recv(struct fpi_ssm *ssm)
|
|||
libusb_free_transfer(vdev->transfer);
|
||||
fp_err("submit of usb transfer failed");
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void async_load(struct fpi_ssm *ssm);
|
||||
static void async_load(fpi_ssm *ssm);
|
||||
|
||||
/* Callback of asynchronous load */
|
||||
static void async_load_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
|
@ -382,7 +382,7 @@ static void async_load_cb(struct libusb_transfer *transfer)
|
|||
/* Transfer not completed */
|
||||
fp_err("transfer not completed, status = %d, length = %d", transfer->status, vdev->length);
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ static void async_load_cb(struct libusb_transfer *transfer)
|
|||
/* Received incomplete frame, return protocol error */
|
||||
fp_err("received incomplete frame");
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ static void async_load_cb(struct libusb_transfer *transfer)
|
|||
/* Buffer full, image too large, return no memory error */
|
||||
fp_err("buffer full, image too large");
|
||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
|
@ -430,7 +430,7 @@ out:
|
|||
}
|
||||
|
||||
/* Submit asynchronous load */
|
||||
static void async_load(struct fpi_ssm *ssm)
|
||||
static void async_load(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -444,7 +444,7 @@ static void async_load(struct fpi_ssm *ssm)
|
|||
/* Allocation transfer failed, return no memory error */
|
||||
fp_err("allocation of usb transfer failed");
|
||||
fpi_imgdev_session_error(dev, -ENOMEM);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -462,7 +462,7 @@ static void async_load(struct fpi_ssm *ssm)
|
|||
libusb_free_transfer(vdev->transfer);
|
||||
fp_err("submit of usb transfer failed");
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ static void async_load(struct fpi_ssm *ssm)
|
|||
/* Callback of asynchronous sleep */
|
||||
static void async_sleep_cb(void *data)
|
||||
{
|
||||
struct fpi_ssm *ssm = data;
|
||||
fpi_ssm *ssm = data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
||||
|
@ -481,7 +481,7 @@ static void async_sleep_cb(void *data)
|
|||
}
|
||||
|
||||
/* Submit asynchronous sleep */
|
||||
static void async_sleep(unsigned int msec, struct fpi_ssm *ssm)
|
||||
static void async_sleep(unsigned int msec, fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -494,7 +494,7 @@ static void async_sleep(unsigned int msec, struct fpi_ssm *ssm)
|
|||
/* Failed to add timeout */
|
||||
fp_err("failed to add timeout");
|
||||
fpi_imgdev_session_error(dev, -ETIME);
|
||||
fpi_ssm_mark_aborted(ssm, -ETIME);
|
||||
fpi_ssm_mark_failed(ssm, -ETIME);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ enum
|
|||
};
|
||||
|
||||
/* Exec swap sequential state machine */
|
||||
static void m_swap_state(struct fpi_ssm *ssm)
|
||||
static void m_swap_state(fpi_ssm *ssm)
|
||||
{
|
||||
switch (fpi_ssm_get_cur_state(ssm))
|
||||
{
|
||||
|
@ -524,11 +524,11 @@ static void m_swap_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
|
||||
/* Start swap sequential state machine */
|
||||
static void m_swap(struct fpi_ssm *ssm, unsigned char *data, size_t length)
|
||||
static void m_swap(fpi_ssm *ssm, unsigned char *data, size_t length)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *subsm;
|
||||
fpi_ssm *subsm;
|
||||
|
||||
/* Prepare data for sending */
|
||||
memcpy(vdev->buffer, data, length);
|
||||
|
@ -542,7 +542,7 @@ static void m_swap(struct fpi_ssm *ssm, unsigned char *data, size_t length)
|
|||
}
|
||||
|
||||
/* Retrieve fingerprint image */
|
||||
static void vfs_get_print(struct fpi_ssm *ssm, unsigned int param, int type)
|
||||
static void vfs_get_print(fpi_ssm *ssm, unsigned int param, int type)
|
||||
{
|
||||
unsigned char data[2][0x0e] = {
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
|
||||
|
@ -562,7 +562,7 @@ static void vfs_get_print(struct fpi_ssm *ssm, unsigned int param, int type)
|
|||
}
|
||||
|
||||
/* Set a parameter value on the device */
|
||||
static void vfs_set_param(struct fpi_ssm *ssm, unsigned int param, unsigned int value)
|
||||
static void vfs_set_param(fpi_ssm *ssm, unsigned int param, unsigned int value)
|
||||
{
|
||||
unsigned char data[0x0a] = { 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
|
@ -579,7 +579,7 @@ static void vfs_set_param(struct fpi_ssm *ssm, unsigned int param, unsigned int
|
|||
}
|
||||
|
||||
/* Abort previous print */
|
||||
static void vfs_abort_print(struct fpi_ssm *ssm)
|
||||
static void vfs_abort_print(fpi_ssm *ssm)
|
||||
{
|
||||
unsigned char data[0x06] = { 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00 };
|
||||
|
||||
|
@ -590,7 +590,7 @@ static void vfs_abort_print(struct fpi_ssm *ssm)
|
|||
}
|
||||
|
||||
/* Poke a value on a region */
|
||||
static void vfs_poke(struct fpi_ssm *ssm, unsigned int addr, unsigned int value, unsigned int size)
|
||||
static void vfs_poke(fpi_ssm *ssm, unsigned int addr, unsigned int value, unsigned int size)
|
||||
{
|
||||
unsigned char data[0x0f] = { 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
|
@ -612,7 +612,7 @@ static void vfs_poke(struct fpi_ssm *ssm, unsigned int addr, unsigned int value,
|
|||
}
|
||||
|
||||
/* Get current finger state */
|
||||
static void vfs_get_finger_state(struct fpi_ssm *ssm)
|
||||
static void vfs_get_finger_state(fpi_ssm *ssm)
|
||||
{
|
||||
unsigned char data[0x06] = { 0x00, 0x00, 0x00, 0x00, 0x16, 0x00 };
|
||||
|
||||
|
@ -623,7 +623,7 @@ static void vfs_get_finger_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
|
||||
/* Load raw image from reader */
|
||||
static void vfs_img_load(struct fpi_ssm *ssm)
|
||||
static void vfs_img_load(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -754,7 +754,7 @@ static void img_copy(struct vfs101_dev *vdev, struct fp_img *img)
|
|||
}
|
||||
|
||||
/* Extract fingerpint image from raw data */
|
||||
static void img_extract(struct fpi_ssm *ssm)
|
||||
static void img_extract(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -912,7 +912,7 @@ enum
|
|||
};
|
||||
|
||||
/* Exec loop sequential state machine */
|
||||
static void m_loop_state(struct fpi_ssm *ssm)
|
||||
static void m_loop_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -961,7 +961,7 @@ static void m_loop_state(struct fpi_ssm *ssm)
|
|||
/* Unknown state */
|
||||
fp_err("unknown device state 0x%02x", vdev->buffer[0x0a]);
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -1018,7 +1018,7 @@ static void m_loop_state(struct fpi_ssm *ssm)
|
|||
/* reach max loop counter, return protocol error */
|
||||
fp_err("finger not removed from the scanner");
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1108,7 +1108,7 @@ static void m_loop_state(struct fpi_ssm *ssm)
|
|||
/* reach max loop counter, return protocol error */
|
||||
fp_err("waiting abort reach max loop counter");
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1120,7 +1120,7 @@ static void m_loop_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
|
||||
/* Complete loop sequential state machine */
|
||||
static void m_loop_complete(struct fpi_ssm *ssm)
|
||||
static void m_loop_complete(fpi_ssm *ssm)
|
||||
{
|
||||
/* Free sequential state machine */
|
||||
fpi_ssm_free(ssm);
|
||||
|
@ -1176,7 +1176,7 @@ enum
|
|||
};
|
||||
|
||||
/* Exec init sequential state machine */
|
||||
static void m_init_state(struct fpi_ssm *ssm)
|
||||
static void m_init_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -1237,7 +1237,7 @@ static void m_init_state(struct fpi_ssm *ssm)
|
|||
/* reach max loop counter, return protocol error */
|
||||
fp_err("waiting abort reach max loop counter");
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ static void m_init_state(struct fpi_ssm *ssm)
|
|||
/* reach max loop counter, return protocol error */
|
||||
fp_err("finger not removed from the scanner");
|
||||
fpi_imgdev_session_error(dev, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1417,11 +1417,11 @@ static void m_init_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
|
||||
/* Complete init sequential state machine */
|
||||
static void m_init_complete(struct fpi_ssm *ssm)
|
||||
static void m_init_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm_loop;
|
||||
fpi_ssm *ssm_loop;
|
||||
|
||||
if (!fpi_ssm_get_error(ssm) && vdev->active)
|
||||
{
|
||||
|
@ -1442,7 +1442,7 @@ static void m_init_complete(struct fpi_ssm *ssm)
|
|||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct vfs101_dev *vdev = fpi_imgdev_get_user_data(dev);
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
/* Check if already active */
|
||||
if (vdev->active)
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
/* Callback of asynchronous sleep */
|
||||
static void async_sleep_cb(void *data)
|
||||
{
|
||||
struct fpi_ssm *ssm = data;
|
||||
fpi_ssm *ssm = data;
|
||||
|
||||
fpi_ssm_next_state(ssm);
|
||||
}
|
||||
|
||||
/* Submit asynchronous sleep */
|
||||
static void async_sleep(unsigned int msec, struct fpi_ssm *ssm)
|
||||
static void async_sleep(unsigned int msec, fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct fpi_timeout *timeout;
|
||||
|
@ -47,11 +47,11 @@ static void async_sleep(unsigned int msec, struct fpi_ssm *ssm)
|
|||
/* Failed to add timeout */
|
||||
fp_err("failed to add timeout");
|
||||
fpi_imgdev_session_error(dev, -ETIME);
|
||||
fpi_ssm_mark_aborted(ssm, -ETIME);
|
||||
fpi_ssm_mark_failed(ssm, -ETIME);
|
||||
}
|
||||
}
|
||||
|
||||
static int submit_image(struct fpi_ssm *ssm)
|
||||
static int submit_image(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
vfs301_dev_t *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -103,7 +103,7 @@ enum
|
|||
};
|
||||
|
||||
/* Exec loop sequential state machine */
|
||||
static void m_loop_state(struct fpi_ssm *ssm)
|
||||
static void m_loop_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
vfs301_dev_t *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -161,14 +161,14 @@ static void m_loop_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
|
||||
/* Complete loop sequential state machine */
|
||||
static void m_loop_complete(struct fpi_ssm *ssm)
|
||||
static void m_loop_complete(fpi_ssm *ssm)
|
||||
{
|
||||
/* Free sequential state machine */
|
||||
fpi_ssm_free(ssm);
|
||||
}
|
||||
|
||||
/* Exec init sequential state machine */
|
||||
static void m_init_state(struct fpi_ssm *ssm)
|
||||
static void m_init_state(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
vfs301_dev_t *vdev = fpi_imgdev_get_user_data(dev);
|
||||
|
@ -181,10 +181,10 @@ static void m_init_state(struct fpi_ssm *ssm)
|
|||
}
|
||||
|
||||
/* Complete init sequential state machine */
|
||||
static void m_init_complete(struct fpi_ssm *ssm)
|
||||
static void m_init_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct fpi_ssm *ssm_loop;
|
||||
fpi_ssm *ssm_loop;
|
||||
|
||||
if (!fpi_ssm_get_error(ssm)) {
|
||||
/* Notify activate complete */
|
||||
|
@ -203,7 +203,7 @@ static void m_init_complete(struct fpi_ssm *ssm)
|
|||
/* Activate device */
|
||||
static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
|
||||
{
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
/* Start init ssm */
|
||||
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), m_init_state, 1);
|
||||
|
|
|
@ -75,14 +75,14 @@ static void start_scan(struct fp_img_dev *dev);
|
|||
|
||||
static void async_send_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct usbexchange_data *data = fpi_ssm_get_user_data(ssm);
|
||||
struct usb_action *action;
|
||||
|
||||
if (fpi_ssm_get_cur_state(ssm) >= data->stepcount) {
|
||||
fp_err("Radiation detected!");
|
||||
fpi_imgdev_session_error(data->device, -EINVAL);
|
||||
fpi_ssm_mark_aborted(ssm, -EINVAL);
|
||||
fpi_ssm_mark_failed(ssm, -EINVAL);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ static void async_send_cb(struct libusb_transfer *transfer)
|
|||
if (action->type != ACTION_SEND) {
|
||||
fp_err("Radiation detected!");
|
||||
fpi_imgdev_session_error(data->device, -EINVAL);
|
||||
fpi_ssm_mark_aborted(ssm, -EINVAL);
|
||||
fpi_ssm_mark_failed(ssm, -EINVAL);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ static void async_send_cb(struct libusb_transfer *transfer)
|
|||
/* Transfer not completed, return IO error */
|
||||
fp_err("transfer not completed, status = %d", transfer->status);
|
||||
fpi_imgdev_session_error(data->device, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
if (transfer->length != transfer->actual_length) {
|
||||
|
@ -106,7 +106,7 @@ static void async_send_cb(struct libusb_transfer *transfer)
|
|||
fp_err("length mismatch, got %d, expected %d",
|
||||
transfer->actual_length, transfer->length);
|
||||
fpi_imgdev_session_error(data->device, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ out:
|
|||
|
||||
static void async_recv_cb(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = transfer->user_data;
|
||||
fpi_ssm *ssm = transfer->user_data;
|
||||
struct usbexchange_data *data = fpi_ssm_get_user_data(ssm);
|
||||
struct usb_action *action;
|
||||
|
||||
|
@ -127,14 +127,14 @@ static void async_recv_cb(struct libusb_transfer *transfer)
|
|||
/* Transfer not completed, return IO error */
|
||||
fp_err("transfer not completed, status = %d", transfer->status);
|
||||
fpi_imgdev_session_error(data->device, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (fpi_ssm_get_cur_state(ssm) >= data->stepcount) {
|
||||
fp_err("Radiation detected!");
|
||||
fpi_imgdev_session_error(data->device, -EINVAL);
|
||||
fpi_ssm_mark_aborted(ssm, -EINVAL);
|
||||
fpi_ssm_mark_failed(ssm, -EINVAL);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ static void async_recv_cb(struct libusb_transfer *transfer)
|
|||
if (action->type != ACTION_RECEIVE) {
|
||||
fp_err("Radiation detected!");
|
||||
fpi_imgdev_session_error(data->device, -EINVAL);
|
||||
fpi_ssm_mark_aborted(ssm, -EINVAL);
|
||||
fpi_ssm_mark_failed(ssm, -EINVAL);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -152,14 +152,14 @@ static void async_recv_cb(struct libusb_transfer *transfer)
|
|||
transfer->actual_length,
|
||||
action->correct_reply_size);
|
||||
fpi_imgdev_session_error(data->device, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
if (memcmp(transfer->buffer, action->data,
|
||||
action->correct_reply_size) != 0) {
|
||||
fp_dbg("Wrong reply:");
|
||||
fpi_imgdev_session_error(data->device, -EIO);
|
||||
fpi_ssm_mark_aborted(ssm, -EIO);
|
||||
fpi_ssm_mark_failed(ssm, -EIO);
|
||||
goto out;
|
||||
}
|
||||
} else
|
||||
|
@ -171,14 +171,14 @@ out:
|
|||
libusb_free_transfer(transfer);
|
||||
}
|
||||
|
||||
static void usbexchange_loop(struct fpi_ssm *ssm)
|
||||
static void usbexchange_loop(fpi_ssm *ssm)
|
||||
{
|
||||
struct usbexchange_data *data = fpi_ssm_get_user_data(ssm);
|
||||
if (fpi_ssm_get_cur_state(ssm) >= data->stepcount) {
|
||||
fp_err("Bug detected: state %d out of range, only %d steps",
|
||||
fpi_ssm_get_cur_state(ssm), data->stepcount);
|
||||
fpi_imgdev_session_error(data->device, -EINVAL);
|
||||
fpi_ssm_mark_aborted(ssm, -EINVAL);
|
||||
fpi_ssm_mark_failed(ssm, -EINVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ static void usbexchange_loop(struct fpi_ssm *ssm)
|
|||
if (transfer == NULL) {
|
||||
fp_err("Failed to allocate transfer");
|
||||
fpi_imgdev_session_error(data->device, -ENOMEM);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(data->device),
|
||||
|
@ -209,7 +209,7 @@ static void usbexchange_loop(struct fpi_ssm *ssm)
|
|||
if (transfer == NULL) {
|
||||
fp_err("Failed to allocate transfer");
|
||||
fpi_imgdev_session_error(data->device, -ENOMEM);
|
||||
fpi_ssm_mark_aborted(ssm, -ENOMEM);
|
||||
fpi_ssm_mark_failed(ssm, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
libusb_fill_bulk_transfer(transfer, fpi_imgdev_get_usb_dev(data->device),
|
||||
|
@ -222,21 +222,21 @@ static void usbexchange_loop(struct fpi_ssm *ssm)
|
|||
default:
|
||||
fp_err("Bug detected: invalid action %d", action->type);
|
||||
fpi_imgdev_session_error(data->device, -EINVAL);
|
||||
fpi_ssm_mark_aborted(ssm, -EINVAL);
|
||||
fpi_ssm_mark_failed(ssm, -EINVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
fp_err("USB transfer error: %s", strerror(ret));
|
||||
fpi_imgdev_session_error(data->device, ret);
|
||||
fpi_ssm_mark_aborted(ssm, ret);
|
||||
fpi_ssm_mark_failed(ssm, ret);
|
||||
}
|
||||
}
|
||||
|
||||
static void usb_exchange_async(struct fpi_ssm *ssm,
|
||||
static void usb_exchange_async(fpi_ssm *ssm,
|
||||
struct usbexchange_data *data)
|
||||
{
|
||||
struct fpi_ssm *subsm = fpi_ssm_new(fpi_imgdev_get_dev(data->device),
|
||||
fpi_ssm *subsm = fpi_ssm_new(fpi_imgdev_get_dev(data->device),
|
||||
usbexchange_loop,
|
||||
data->stepcount);
|
||||
fpi_ssm_set_user_data(subsm, data);
|
||||
|
@ -395,7 +395,7 @@ static int process_chunk(struct vfs5011_data *data, int transferred)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void submit_image(struct fpi_ssm *ssm, struct vfs5011_data *data)
|
||||
void submit_image(fpi_ssm *ssm, struct vfs5011_data *data)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct fp_img *img;
|
||||
|
@ -422,7 +422,7 @@ void submit_image(struct fpi_ssm *ssm, struct vfs5011_data *data)
|
|||
|
||||
static void chunk_capture_callback(struct libusb_transfer *transfer)
|
||||
{
|
||||
struct fpi_ssm *ssm = (struct fpi_ssm *)transfer->user_data;
|
||||
fpi_ssm *ssm = (fpi_ssm *)transfer->user_data;
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs5011_data *data;
|
||||
|
||||
|
@ -441,7 +441,7 @@ static void chunk_capture_callback(struct libusb_transfer *transfer)
|
|||
} else {
|
||||
if (!data->deactivating) {
|
||||
fp_err("Failed to capture data");
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
} else {
|
||||
fpi_ssm_mark_completed(ssm);
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ static void chunk_capture_callback(struct libusb_transfer *transfer)
|
|||
|
||||
static int capture_chunk_async(struct vfs5011_data *data,
|
||||
libusb_device_handle *handle, int nline,
|
||||
int timeout, struct fpi_ssm *ssm)
|
||||
int timeout, fpi_ssm *ssm)
|
||||
{
|
||||
fp_dbg("capture_chunk_async: capture %d lines, already have %d",
|
||||
nline, data->lines_recorded);
|
||||
|
@ -472,7 +472,7 @@ static int capture_chunk_async(struct vfs5011_data *data,
|
|||
|
||||
static void async_sleep_cb(void *data)
|
||||
{
|
||||
struct fpi_ssm *ssm = data;
|
||||
fpi_ssm *ssm = data;
|
||||
|
||||
fpi_ssm_next_state(ssm);
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ struct usb_action vfs5011_initiate_capture[] = {
|
|||
|
||||
/* ====================== lifprint interface ======================= */
|
||||
|
||||
static void activate_loop(struct fpi_ssm *ssm)
|
||||
static void activate_loop(fpi_ssm *ssm)
|
||||
{
|
||||
enum {READ_TIMEOUT = 0};
|
||||
|
||||
|
@ -712,7 +712,7 @@ static void activate_loop(struct fpi_ssm *ssm)
|
|||
if (r != 0) {
|
||||
fp_err("Failed to capture data");
|
||||
fpi_imgdev_session_error(dev, r);
|
||||
fpi_ssm_mark_aborted(ssm, r);
|
||||
fpi_ssm_mark_failed(ssm, r);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -723,7 +723,7 @@ static void activate_loop(struct fpi_ssm *ssm)
|
|||
/* Failed to add timeout */
|
||||
fp_err("failed to add timeout");
|
||||
fpi_imgdev_session_error(dev, -1);
|
||||
fpi_ssm_mark_aborted(ssm, -1);
|
||||
fpi_ssm_mark_failed(ssm, -1);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -742,7 +742,7 @@ static void activate_loop(struct fpi_ssm *ssm)
|
|||
}
|
||||
}
|
||||
|
||||
static void activate_loop_complete(struct fpi_ssm *ssm)
|
||||
static void activate_loop_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs5011_data *data;
|
||||
|
@ -772,7 +772,7 @@ static void activate_loop_complete(struct fpi_ssm *ssm)
|
|||
}
|
||||
|
||||
|
||||
static void open_loop(struct fpi_ssm *ssm)
|
||||
static void open_loop(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs5011_data *data;
|
||||
|
@ -793,7 +793,7 @@ static void open_loop(struct fpi_ssm *ssm)
|
|||
};
|
||||
}
|
||||
|
||||
static void open_loop_complete(struct fpi_ssm *ssm)
|
||||
static void open_loop_complete(fpi_ssm *ssm)
|
||||
{
|
||||
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
|
||||
struct vfs5011_data *data;
|
||||
|
@ -829,7 +829,7 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
|
|||
return r;
|
||||
}
|
||||
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
ssm = fpi_ssm_new(fpi_imgdev_get_dev(dev), open_loop, DEV_OPEN_NUM_STATES);
|
||||
fpi_ssm_set_user_data(ssm, dev);
|
||||
fpi_ssm_start(ssm, open_loop_complete);
|
||||
|
@ -853,7 +853,7 @@ static void dev_close(struct fp_img_dev *dev)
|
|||
static void start_scan(struct fp_img_dev *dev)
|
||||
{
|
||||
struct vfs5011_data *data;
|
||||
struct fpi_ssm *ssm;
|
||||
fpi_ssm *ssm;
|
||||
|
||||
data = fpi_imgdev_get_user_data(dev);
|
||||
data->loop_running = TRUE;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <libusb.h>
|
||||
|
||||
#include "fprint.h"
|
||||
#include "fpi-ssm.h"
|
||||
#include "assembling.h"
|
||||
#include "drivers/driver_ids.h"
|
||||
|
||||
|
@ -211,35 +212,6 @@ struct fpi_timeout *fpi_timeout_add(unsigned int msec, fpi_timeout_fn callback,
|
|||
void *data);
|
||||
void fpi_timeout_cancel(struct fpi_timeout *timeout);
|
||||
|
||||
/* async drv <--> lib comms */
|
||||
|
||||
struct fpi_ssm;
|
||||
typedef void (*ssm_completed_fn)(struct fpi_ssm *ssm);
|
||||
typedef void (*ssm_handler_fn)(struct fpi_ssm *ssm);
|
||||
|
||||
/* sequential state machine: state machine that iterates sequentially over
|
||||
* a predefined series of states. can be aborted by either completion or
|
||||
* abortion error conditions. */
|
||||
|
||||
/* for library and drivers */
|
||||
struct fpi_ssm *fpi_ssm_new(struct fp_dev *dev, ssm_handler_fn handler,
|
||||
int nr_states);
|
||||
void fpi_ssm_free(struct fpi_ssm *machine);
|
||||
void fpi_ssm_start(struct fpi_ssm *machine, ssm_completed_fn callback);
|
||||
void fpi_ssm_start_subsm(struct fpi_ssm *parent, struct fpi_ssm *child);
|
||||
|
||||
/* for drivers */
|
||||
void fpi_ssm_next_state(struct fpi_ssm *machine);
|
||||
void fpi_ssm_jump_to_state(struct fpi_ssm *machine, int state);
|
||||
void fpi_ssm_mark_completed(struct fpi_ssm *machine);
|
||||
void fpi_ssm_mark_aborted(struct fpi_ssm *machine, int error);
|
||||
struct fp_dev *fpi_ssm_get_dev(struct fpi_ssm *machine);
|
||||
void fpi_ssm_set_user_data(struct fpi_ssm *machine,
|
||||
void *user_data);
|
||||
void *fpi_ssm_get_user_data(struct fpi_ssm *machine);
|
||||
int fpi_ssm_get_error(struct fpi_ssm *machine);
|
||||
int fpi_ssm_get_cur_state(struct fpi_ssm *machine);
|
||||
|
||||
void fpi_drvcb_open_complete(struct fp_dev *dev, int status);
|
||||
void fpi_drvcb_close_complete(struct fp_dev *dev);
|
||||
|
||||
|
|
199
libfprint/drv.c
199
libfprint/drv.c
|
@ -1,199 +0,0 @@
|
|||
/*
|
||||
* Functions to assist with asynchronous driver <---> library communications
|
||||
* Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#define FP_COMPONENT "drv"
|
||||
|
||||
#include "fp_internal.h"
|
||||
|
||||
#include <config.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* SSM: sequential state machine
|
||||
* Asynchronous driver design encourages some kind of state machine behind it.
|
||||
* In most cases, the state machine is entirely linear - you only go to the
|
||||
* next state, you never jump or go backwards. The SSM functions help you
|
||||
* implement such a machine.
|
||||
*
|
||||
* e.g. S1 --> S2 --> S3 --> S4
|
||||
* S1 is the start state
|
||||
* There is also an implicit error state and an implicit accepting state
|
||||
* (both with implicit edges from every state).
|
||||
*
|
||||
* You can also jump to any arbitrary state (while marking completion of the
|
||||
* current state) while the machine is running. In other words there are
|
||||
* implicit edges linking one state to every other state. OK, we're stretching
|
||||
* the "state machine" description at this point.
|
||||
*
|
||||
* To create a ssm, you pass a state handler function and the total number of
|
||||
* states (4 in the above example).
|
||||
*
|
||||
* To start a ssm, you pass in a completion callback function which gets
|
||||
* called when the ssm completes (both on error and on failure).
|
||||
*
|
||||
* To iterate to the next state, call fpi_ssm_next_state(). It is legal to
|
||||
* attempt to iterate beyond the final state - this is equivalent to marking
|
||||
* the ssm as successfully completed.
|
||||
*
|
||||
* To mark successful completion of a SSM, either iterate beyond the final
|
||||
* state or call fpi_ssm_mark_completed() from any state.
|
||||
*
|
||||
* To mark failed completion of a SSM, call fpi_ssm_mark_aborted() from any
|
||||
* state. You must pass a non-zero error code.
|
||||
*
|
||||
* Your state handling function looks at ssm->cur_state in order to determine
|
||||
* the current state and hence which operations to perform (a switch statement
|
||||
* is appropriate).
|
||||
* Typically, the state handling function fires off an asynchronous libusb
|
||||
* transfer, and the callback function iterates the machine to the next state
|
||||
* upon success (or aborts the machine on transfer failure).
|
||||
*
|
||||
* Your completion callback should examine ssm->error in order to determine
|
||||
* whether the ssm completed or failed. An error code of zero indicates
|
||||
* successful completion.
|
||||
*/
|
||||
|
||||
/* Allocate a new ssm */
|
||||
struct fpi_ssm *fpi_ssm_new(struct fp_dev *dev, ssm_handler_fn handler,
|
||||
int nr_states)
|
||||
{
|
||||
struct fpi_ssm *machine;
|
||||
BUG_ON(nr_states < 1);
|
||||
|
||||
machine = g_malloc0(sizeof(*machine));
|
||||
machine->handler = handler;
|
||||
machine->nr_states = nr_states;
|
||||
machine->dev = dev;
|
||||
machine->completed = TRUE;
|
||||
return machine;
|
||||
}
|
||||
|
||||
struct fp_dev *
|
||||
fpi_ssm_get_dev(struct fpi_ssm *machine)
|
||||
{
|
||||
return machine->dev;
|
||||
}
|
||||
|
||||
void
|
||||
fpi_ssm_set_user_data(struct fpi_ssm *machine,
|
||||
void *user_data)
|
||||
{
|
||||
machine->priv = user_data;
|
||||
}
|
||||
|
||||
void *
|
||||
fpi_ssm_get_user_data(struct fpi_ssm *machine)
|
||||
{
|
||||
return machine->priv;
|
||||
}
|
||||
|
||||
/* Free a ssm */
|
||||
void fpi_ssm_free(struct fpi_ssm *machine)
|
||||
{
|
||||
if (!machine)
|
||||
return;
|
||||
g_free(machine);
|
||||
}
|
||||
|
||||
/* Invoke the state handler */
|
||||
static void __ssm_call_handler(struct fpi_ssm *machine)
|
||||
{
|
||||
fp_dbg("%p entering state %d", machine, machine->cur_state);
|
||||
machine->handler(machine);
|
||||
}
|
||||
|
||||
/* Start a ssm. You can also restart a completed or aborted ssm. */
|
||||
void fpi_ssm_start(struct fpi_ssm *ssm, ssm_completed_fn callback)
|
||||
{
|
||||
BUG_ON(!ssm->completed);
|
||||
ssm->callback = callback;
|
||||
ssm->cur_state = 0;
|
||||
ssm->completed = FALSE;
|
||||
ssm->error = 0;
|
||||
__ssm_call_handler(ssm);
|
||||
}
|
||||
|
||||
static void __subsm_complete(struct fpi_ssm *ssm)
|
||||
{
|
||||
struct fpi_ssm *parent = ssm->parentsm;
|
||||
BUG_ON(!parent);
|
||||
if (ssm->error)
|
||||
fpi_ssm_mark_aborted(parent, ssm->error);
|
||||
else
|
||||
fpi_ssm_next_state(parent);
|
||||
fpi_ssm_free(ssm);
|
||||
}
|
||||
|
||||
/* start a SSM as a child of another. if the child completes successfully, the
|
||||
* parent will be advanced to the next state. if the child aborts, the parent
|
||||
* will be aborted with the same error code. the child will be automatically
|
||||
* freed upon completion/abortion. */
|
||||
void fpi_ssm_start_subsm(struct fpi_ssm *parent, struct fpi_ssm *child)
|
||||
{
|
||||
child->parentsm = parent;
|
||||
fpi_ssm_start(child, __subsm_complete);
|
||||
}
|
||||
|
||||
/* Mark a ssm as completed successfully. */
|
||||
void fpi_ssm_mark_completed(struct fpi_ssm *machine)
|
||||
{
|
||||
BUG_ON(machine->completed);
|
||||
machine->completed = TRUE;
|
||||
fp_dbg("%p completed with status %d", machine, machine->error);
|
||||
if (machine->callback)
|
||||
machine->callback(machine);
|
||||
}
|
||||
|
||||
/* Mark a ssm as aborted with error. */
|
||||
void fpi_ssm_mark_aborted(struct fpi_ssm *machine, int error)
|
||||
{
|
||||
fp_dbg("error %d from state %d", error, machine->cur_state);
|
||||
BUG_ON(error == 0);
|
||||
machine->error = error;
|
||||
fpi_ssm_mark_completed(machine);
|
||||
}
|
||||
|
||||
/* Iterate to next state of a ssm */
|
||||
void fpi_ssm_next_state(struct fpi_ssm *machine)
|
||||
{
|
||||
BUG_ON(machine->completed);
|
||||
machine->cur_state++;
|
||||
if (machine->cur_state == machine->nr_states) {
|
||||
fpi_ssm_mark_completed(machine);
|
||||
} else {
|
||||
__ssm_call_handler(machine);
|
||||
}
|
||||
}
|
||||
|
||||
void fpi_ssm_jump_to_state(struct fpi_ssm *machine, int state)
|
||||
{
|
||||
BUG_ON(machine->completed);
|
||||
BUG_ON(state >= machine->nr_states);
|
||||
machine->cur_state = state;
|
||||
__ssm_call_handler(machine);
|
||||
}
|
||||
|
||||
int fpi_ssm_get_cur_state(struct fpi_ssm *machine)
|
||||
{
|
||||
return machine->cur_state;
|
||||
}
|
||||
|
||||
int fpi_ssm_get_error(struct fpi_ssm *machine)
|
||||
{
|
||||
return machine->error;
|
||||
}
|
|
@ -348,40 +348,6 @@ void fpi_poll_exit(void);
|
|||
|
||||
typedef void (*fpi_timeout_fn)(void *data);
|
||||
|
||||
/* async drv <--> lib comms */
|
||||
|
||||
struct fpi_ssm;
|
||||
typedef void (*ssm_completed_fn)(struct fpi_ssm *ssm);
|
||||
typedef void (*ssm_handler_fn)(struct fpi_ssm *ssm);
|
||||
|
||||
/* sequential state machine: state machine that iterates sequentially over
|
||||
* a predefined series of states. can be aborted by either completion or
|
||||
* abortion error conditions. */
|
||||
struct fpi_ssm {
|
||||
struct fp_dev *dev;
|
||||
struct fpi_ssm *parentsm;
|
||||
void *priv;
|
||||
int nr_states;
|
||||
int cur_state;
|
||||
gboolean completed;
|
||||
int error;
|
||||
ssm_completed_fn callback;
|
||||
ssm_handler_fn handler;
|
||||
};
|
||||
|
||||
|
||||
/* for library and drivers */
|
||||
struct fpi_ssm *fpi_ssm_new(struct fp_dev *dev, ssm_handler_fn handler,
|
||||
int nr_states);
|
||||
void fpi_ssm_free(struct fpi_ssm *machine);
|
||||
void fpi_ssm_start(struct fpi_ssm *machine, ssm_completed_fn callback);
|
||||
|
||||
/* for drivers */
|
||||
void fpi_ssm_next_state(struct fpi_ssm *machine);
|
||||
void fpi_ssm_jump_to_state(struct fpi_ssm *machine, int state);
|
||||
void fpi_ssm_mark_completed(struct fpi_ssm *machine);
|
||||
void fpi_ssm_mark_aborted(struct fpi_ssm *machine, int error);
|
||||
|
||||
void fpi_drvcb_open_complete(struct fp_dev *dev, int status);
|
||||
void fpi_drvcb_close_complete(struct fp_dev *dev);
|
||||
|
||||
|
|
317
libfprint/fpi-ssm.c
Normal file
317
libfprint/fpi-ssm.c
Normal file
|
@ -0,0 +1,317 @@
|
|||
/*
|
||||
* Functions to assist with asynchronous driver <---> library communications
|
||||
* Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#define FP_COMPONENT "drv"
|
||||
|
||||
#include "fp_internal.h"
|
||||
#include "fpi-ssm.h"
|
||||
|
||||
#include <config.h>
|
||||
#include <errno.h>
|
||||
|
||||
/**
|
||||
* SECTION:fpi-ssm
|
||||
* @title: Sequential state machine
|
||||
*
|
||||
* Asynchronous driver design encourages some kind of state machine behind it.
|
||||
* In most cases, the state machine is entirely linear - you only go to the
|
||||
* next state, you never jump or go backwards. The #fpi_ssm functions help you
|
||||
* implement such a machine.
|
||||
*
|
||||
* e.g. `S1` ↦ `S2` ↦ `S3` ↦ `S4`
|
||||
*
|
||||
* `S1` is the start state
|
||||
* There is also an implicit error state and an implicit accepting state
|
||||
* (both with implicit edges from every state).
|
||||
*
|
||||
* You can also jump to any arbitrary state (while marking completion of the
|
||||
* current state) while the machine is running. In other words there are
|
||||
* implicit edges linking one state to every other state.
|
||||
*
|
||||
* To create an #fpi_ssm, you pass a state handler function and the total number of
|
||||
* states (4 in the above example) to fpi_ssm_new(). Note that the state numbers
|
||||
* start at zero, making them match the first value in a C enumeration.
|
||||
*
|
||||
* To start a ssm, you pass in a completion callback function to fpi_ssm_start()
|
||||
* which gets called when the ssm completes (both on error and on failure).
|
||||
*
|
||||
* To iterate to the next state, call fpi_ssm_next_state(). It is legal to
|
||||
* attempt to iterate beyond the final state - this is equivalent to marking
|
||||
* the ssm as successfully completed.
|
||||
*
|
||||
* To mark successful completion of a SSM, either iterate beyond the final
|
||||
* state or call fpi_ssm_mark_completed() from any state.
|
||||
*
|
||||
* To mark failed completion of a SSM, call fpi_ssm_mark_failed() from any
|
||||
* state. You must pass a non-zero error code.
|
||||
*
|
||||
* Your state handling function looks at the return value of
|
||||
* fpi_ssm_get_cur_state() in order to determine the current state and hence
|
||||
* which operations to perform (a switch statement is appropriate).
|
||||
*
|
||||
* Typically, the state handling function fires off an asynchronous
|
||||
* communication with the device (such as a libsub transfer), and the
|
||||
* callback function iterates the machine to the next state
|
||||
* upon success (or fails).
|
||||
*
|
||||
* Your completion callback should examine the return value of
|
||||
* fpi_ssm_get_error() in order to determine whether the #fpi_ssm completed or
|
||||
* failed. An error code of zero indicates successful completion.
|
||||
*/
|
||||
|
||||
struct fpi_ssm {
|
||||
struct fp_dev *dev;
|
||||
fpi_ssm *parentsm;
|
||||
void *priv;
|
||||
int nr_states;
|
||||
int cur_state;
|
||||
gboolean completed;
|
||||
int error;
|
||||
ssm_completed_fn callback;
|
||||
ssm_handler_fn handler;
|
||||
};
|
||||
|
||||
/**
|
||||
* fpi_ssm_new:
|
||||
* @dev: a #fp_dev fingerprint device
|
||||
* @handler: the callback function
|
||||
* @nr_states: the number of states
|
||||
*
|
||||
* Allocate a new ssm, with @nr_states states. The @handler callback
|
||||
* will be called after each state transition.
|
||||
*
|
||||
* Returns: a new #fpi_ssm state machine
|
||||
*/
|
||||
fpi_ssm *fpi_ssm_new(struct fp_dev *dev, ssm_handler_fn handler,
|
||||
int nr_states)
|
||||
{
|
||||
fpi_ssm *machine;
|
||||
BUG_ON(nr_states < 1);
|
||||
|
||||
machine = g_malloc0(sizeof(*machine));
|
||||
machine->handler = handler;
|
||||
machine->nr_states = nr_states;
|
||||
machine->dev = dev;
|
||||
machine->completed = TRUE;
|
||||
return machine;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_get_dev:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
*
|
||||
* Returns the #fp_dev attached to the #fpi_ssm as passed
|
||||
* in fpi_ssm_new().
|
||||
*
|
||||
* Returns: a struct #fp_dev
|
||||
*/
|
||||
struct fp_dev *
|
||||
fpi_ssm_get_dev(fpi_ssm *machine)
|
||||
{
|
||||
return machine->dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_set_user_data:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
* @user_data: a pointer to user data
|
||||
*
|
||||
* Set a user data pointer in the #fpi_ssm structure, to be
|
||||
* retrieved with fpi_ssm_get_user_data() at a later point.
|
||||
*/
|
||||
void
|
||||
fpi_ssm_set_user_data(fpi_ssm *machine,
|
||||
void *user_data)
|
||||
{
|
||||
machine->priv = user_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_get_user_data:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
*
|
||||
* Retrieve the pointer to user data set with
|
||||
* fpi_ssm_set_user_data().
|
||||
*
|
||||
* Returns: a pointer
|
||||
*/
|
||||
void *
|
||||
fpi_ssm_get_user_data(fpi_ssm *machine)
|
||||
{
|
||||
return machine->priv;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_free:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
*
|
||||
* Frees a state machine. This does not call any error or success
|
||||
* callbacks, so you need to do this yourself.
|
||||
*/
|
||||
void fpi_ssm_free(fpi_ssm *machine)
|
||||
{
|
||||
if (!machine)
|
||||
return;
|
||||
g_free(machine);
|
||||
}
|
||||
|
||||
/* Invoke the state handler */
|
||||
static void __ssm_call_handler(fpi_ssm *machine)
|
||||
{
|
||||
fp_dbg("%p entering state %d", machine, machine->cur_state);
|
||||
machine->handler(machine);
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_start:
|
||||
* @ssm: an #fpi_ssm state machine
|
||||
* @callback: the #ssm_completed_fn callback to call on completion
|
||||
*
|
||||
* Starts a state machine. You can also use this function to restart
|
||||
* a completed or failed state machine. The @callback will be called
|
||||
* on completion.
|
||||
*/
|
||||
void fpi_ssm_start(fpi_ssm *ssm, ssm_completed_fn callback)
|
||||
{
|
||||
BUG_ON(!ssm->completed);
|
||||
ssm->callback = callback;
|
||||
ssm->cur_state = 0;
|
||||
ssm->completed = FALSE;
|
||||
ssm->error = 0;
|
||||
__ssm_call_handler(ssm);
|
||||
}
|
||||
|
||||
static void __subsm_complete(fpi_ssm *ssm)
|
||||
{
|
||||
fpi_ssm *parent = ssm->parentsm;
|
||||
BUG_ON(!parent);
|
||||
if (ssm->error)
|
||||
fpi_ssm_mark_failed(parent, ssm->error);
|
||||
else
|
||||
fpi_ssm_next_state(parent);
|
||||
fpi_ssm_free(ssm);
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_start_subsm:
|
||||
* @parent: an #fpi_ssm state machine
|
||||
* @child: an #fpi_ssm state machine
|
||||
*
|
||||
* Starts a state machine as a child of another. if the child completes
|
||||
* successfully, the parent will be advanced to the next state. if the
|
||||
* child fails, the parent will be marked as failed with the same error code.
|
||||
*
|
||||
* The child will be automatically freed upon completion or failure.
|
||||
*/
|
||||
void fpi_ssm_start_subsm(fpi_ssm *parent, fpi_ssm *child)
|
||||
{
|
||||
child->parentsm = parent;
|
||||
fpi_ssm_start(child, __subsm_complete);
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_mark_completed:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
*
|
||||
* Mark a ssm as completed successfully. The callback set when creating
|
||||
* the state machine with fpi_ssm_new() will be called synchronously.
|
||||
*/
|
||||
void fpi_ssm_mark_completed(fpi_ssm *machine)
|
||||
{
|
||||
BUG_ON(machine->completed);
|
||||
machine->completed = TRUE;
|
||||
fp_dbg("%p completed with status %d", machine, machine->error);
|
||||
if (machine->callback)
|
||||
machine->callback(machine);
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_mark_failed:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
* @error: the error code
|
||||
*
|
||||
* Mark a state machine as failed with @error as the error code.
|
||||
*/
|
||||
void fpi_ssm_mark_failed(fpi_ssm *machine, int error)
|
||||
{
|
||||
fp_dbg("error %d from state %d", error, machine->cur_state);
|
||||
BUG_ON(error == 0);
|
||||
machine->error = error;
|
||||
fpi_ssm_mark_completed(machine);
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_next_state:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
*
|
||||
* Iterate to next state of a state machine. If the current state is the
|
||||
* last state, then the state machine will be marked as completed, as
|
||||
* if calling fpi_ssm_mark_completed().
|
||||
*/
|
||||
void fpi_ssm_next_state(fpi_ssm *machine)
|
||||
{
|
||||
BUG_ON(machine->completed);
|
||||
machine->cur_state++;
|
||||
if (machine->cur_state == machine->nr_states) {
|
||||
fpi_ssm_mark_completed(machine);
|
||||
} else {
|
||||
__ssm_call_handler(machine);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_jump_to_state:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
* @state: the state to jump to
|
||||
*
|
||||
*/
|
||||
void fpi_ssm_jump_to_state(fpi_ssm *machine, int state)
|
||||
{
|
||||
BUG_ON(machine->completed);
|
||||
BUG_ON(state >= machine->nr_states);
|
||||
machine->cur_state = state;
|
||||
__ssm_call_handler(machine);
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_get_cur_state:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
*
|
||||
* Returns the value of the current state. Note that states are
|
||||
* 0-indexed, so a value of 0 means “the first state”.
|
||||
*
|
||||
* Returns: the current state.
|
||||
*/
|
||||
int fpi_ssm_get_cur_state(fpi_ssm *machine)
|
||||
{
|
||||
return machine->cur_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* fpi_ssm_get_error:
|
||||
* @machine: an #fpi_ssm state machine
|
||||
*
|
||||
* Returns the error code set by fpi_ssm_mark_failed().
|
||||
*
|
||||
* Returns: a error code
|
||||
*/
|
||||
int fpi_ssm_get_error(fpi_ssm *machine)
|
||||
{
|
||||
return machine->error;
|
||||
}
|
79
libfprint/fpi-ssm.h
Normal file
79
libfprint/fpi-ssm.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Driver API definitions
|
||||
* Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org>
|
||||
* Copyright (C) 2018 Bastien Nocera <hadess@hadess.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef __FPI_SSM_H__
|
||||
#define __FPI_SSM_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
#include <libusb.h>
|
||||
|
||||
/* async drv <--> lib comms */
|
||||
|
||||
/**
|
||||
* fpi_ssm:
|
||||
*
|
||||
* Sequential state machine that iterates sequentially over
|
||||
* a predefined series of states. Can be terminated by either completion or
|
||||
* failure error conditions.
|
||||
*/
|
||||
typedef struct fpi_ssm fpi_ssm;
|
||||
|
||||
/**
|
||||
* ssm_completed_fn:
|
||||
* @ssm: a #fpi_ssm state machine
|
||||
*
|
||||
* The callback called when a state machine completes successfully,
|
||||
* as set when calling fpi_ssm_start().
|
||||
*/
|
||||
typedef void (*ssm_completed_fn)(fpi_ssm *ssm);
|
||||
|
||||
/**
|
||||
* ssm_handler_fn:
|
||||
* @ssm: a #fpi_ssm state machine
|
||||
*
|
||||
* The callback called when a state machine transitions from one
|
||||
* state to the next, as set when calling fpi_ssm_new().
|
||||
*/
|
||||
typedef void (*ssm_handler_fn)(fpi_ssm *ssm);
|
||||
|
||||
/* for library and drivers */
|
||||
fpi_ssm *fpi_ssm_new(struct fp_dev *dev, ssm_handler_fn handler,
|
||||
int nr_states);
|
||||
void fpi_ssm_free(fpi_ssm *machine);
|
||||
void fpi_ssm_start(fpi_ssm *ssm, ssm_completed_fn callback);
|
||||
void fpi_ssm_start_subsm(fpi_ssm *parent, fpi_ssm *child);
|
||||
|
||||
/* for drivers */
|
||||
void fpi_ssm_next_state(fpi_ssm *machine);
|
||||
void fpi_ssm_jump_to_state(fpi_ssm *machine, int state);
|
||||
void fpi_ssm_mark_completed(fpi_ssm *machine);
|
||||
void fpi_ssm_mark_failed(fpi_ssm *machine, int error);
|
||||
struct fp_dev *fpi_ssm_get_dev(fpi_ssm *machine);
|
||||
void fpi_ssm_set_user_data(fpi_ssm *machine,
|
||||
void *user_data);
|
||||
void *fpi_ssm_get_user_data(fpi_ssm *machine);
|
||||
int fpi_ssm_get_error(fpi_ssm *machine);
|
||||
int fpi_ssm_get_cur_state(fpi_ssm *machine);
|
||||
|
||||
#endif
|
|
@ -4,7 +4,8 @@ libfprint_sources = [
|
|||
'async.c',
|
||||
'core.c',
|
||||
'data.c',
|
||||
'drv.c',
|
||||
'fpi-ssm.c',
|
||||
'fpi-ssm.h',
|
||||
'img.c',
|
||||
'imgdev.c',
|
||||
'poll.c',
|
||||
|
|
Loading…
Reference in a new issue