lib: Make fpi_ssm opaque for drivers

We shouldn't access fpi_ssm struct fields directly in drivers, so add
accessor and setter functions for the common uses.
This commit is contained in:
Bastien Nocera 2018-05-28 12:40:22 +02:00
parent 17577175f8
commit 2e035a7f45
18 changed files with 404 additions and 373 deletions

View file

@ -130,6 +130,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
struct fp_dev *dev;
int r;
if (!transfer) {
@ -138,7 +139,8 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
}
data = g_malloc(bytes);
libusb_fill_bulk_transfer(transfer, ssm->dev->udev, EP_IN, data, bytes,
dev = fpi_ssm_get_dev(ssm);
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, bytes,
generic_ignore_data_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -556,7 +558,7 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
{
unsigned char *stripdata;
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes1610_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
int sum, i;
@ -643,11 +645,11 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes1610_dev *aesdev = dev->priv;
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_WRITE_REQS:
fp_dbg("write reqs");
aes_write_regv(dev, capture_reqs, G_N_ELEMENTS(capture_reqs),
@ -690,14 +692,14 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes1610_dev *aesdev = dev->priv;
G_DEBUG_HERE();
if (aesdev->deactivating)
complete_deactivation(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else
start_finger_detection(dev);
fpi_ssm_free(ssm);
@ -715,7 +717,7 @@ static void start_capture(struct fp_img_dev *dev)
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
@ -738,11 +740,11 @@ enum activate_states {
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
/* activation on aes1610 seems much more straightforward compared to aes2501 */
/* verify theres anything missing here */
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case WRITE_INIT:
fp_dbg("write init");
aes_write_regv(dev, init, G_N_ELEMENTS(init), generic_write_regv_cb, ssm);
@ -753,11 +755,11 @@ static void activate_run_state(struct fpi_ssm *ssm)
/* jump to finger detection */
static void activate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
fp_dbg("status %d", ssm->error);
fpi_imgdev_activate_complete(dev, ssm->error);
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
fp_dbg("status %d", fpi_ssm_get_error(ssm));
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
if (!ssm->error)
if (!fpi_ssm_get_error(ssm))
start_finger_detection(dev);
fpi_ssm_free(ssm);
}
@ -767,7 +769,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
struct aes1610_dev *aesdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
aesdev->read_regs_retry_count = 0;
fpi_ssm_start(ssm, activate_sm_complete);
return 0;

View file

@ -209,6 +209,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
int r;
if (!transfer) {
@ -217,7 +218,7 @@ static void generic_read_ignore_data(struct fpi_ssm *ssm, size_t bytes)
}
data = g_malloc(bytes);
libusb_fill_bulk_transfer(transfer, ssm->dev->udev, EP_IN, data, bytes,
libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, bytes,
generic_ignore_data_cb, ssm, BULK_TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -436,7 +437,7 @@ static void capture_read_strip_cb(struct libusb_transfer *transfer)
{
unsigned char *stripdata;
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2501_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
int sum;
@ -521,11 +522,11 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2501_dev *aesdev = dev->priv;
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_WRITE_REQS_1:
aes_write_regv(dev, capture_reqs_1, G_N_ELEMENTS(capture_reqs_1),
generic_write_regv_cb, ssm);
@ -572,14 +573,14 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2501_dev *aesdev = dev->priv;
G_DEBUG_HERE();
if (aesdev->deactivating)
complete_deactivation(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else
start_finger_detection(dev);
fpi_ssm_free(ssm);
@ -600,7 +601,7 @@ static void start_capture(struct fp_img_dev *dev)
strip_scan_reqs[4].value = AES2501_ADREFHI_MAX_VALUE;
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
@ -738,7 +739,7 @@ static void activate_init3_cb(struct fp_img_dev *dev, int result,
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
/* This state machine isn't as linear as it may appear. After doing init1
* and init2 register configuration writes, we have to poll a register
@ -759,7 +760,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
aes_write_regv(init_4);
*/
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case WRITE_INIT_1:
aes_write_regv(dev, init_1, G_N_ELEMENTS(init_1),
generic_write_regv_cb, ssm);
@ -792,11 +793,11 @@ static void activate_run_state(struct fpi_ssm *ssm)
static void activate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
fp_dbg("status %d", ssm->error);
fpi_imgdev_activate_complete(dev, ssm->error);
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
fp_dbg("status %d", fpi_ssm_get_error(ssm));
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
if (!ssm->error)
if (!fpi_ssm_get_error(ssm))
start_finger_detection(dev);
fpi_ssm_free(ssm);
}
@ -806,7 +807,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
struct aes2501_dev *aesdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
aesdev->read_regs_retry_count = 0;
fpi_ssm_start(ssm, activate_sm_complete);
return 0;

View file

@ -203,7 +203,7 @@ enum capture_states {
static int process_strip_data(struct fpi_ssm *ssm, unsigned char *data)
{
unsigned char *stripdata;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
struct fpi_frame *stripe;
int len;
@ -245,7 +245,7 @@ static void capture_reqs_cb(struct libusb_transfer *transfer)
static void capture_set_idle_reqs_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
@ -273,7 +273,7 @@ static void capture_set_idle_reqs_cb(struct libusb_transfer *transfer)
static void capture_read_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
int r;
@ -325,10 +325,10 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_WRITE_REQS:
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
@ -388,14 +388,14 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = dev->priv;
fp_dbg("Capture completed");
if (aesdev->deactivating)
complete_deactivation(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else
start_finger_detection(dev);
fpi_ssm_free(ssm);
@ -414,7 +414,7 @@ static void start_capture(struct fp_img_dev *dev)
aesdev->heartbeat_cnt = 0;
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
@ -485,10 +485,10 @@ static void calibrate_read_data_cb(struct libusb_transfer *transfer)
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case WRITE_INIT:
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
@ -570,11 +570,11 @@ static void activate_run_state(struct fpi_ssm *ssm)
static void activate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
fp_dbg("status %d", ssm->error);
fpi_imgdev_activate_complete(dev, ssm->error);
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
fp_dbg("status %d", fpi_ssm_get_error(ssm));
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
if (!ssm->error)
if (!fpi_ssm_get_error(ssm))
start_finger_detection(dev);
fpi_ssm_free(ssm);
}
@ -583,7 +583,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_sm_complete);
return 0;
}

View file

@ -40,7 +40,7 @@ static void complete_deactivation(struct fp_img_dev *dev);
static void aesX660_send_cmd_timeout(struct fpi_ssm *ssm, const unsigned char *cmd,
size_t cmd_len, libusb_transfer_cb_fn callback, int timeout)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
int r;
@ -69,7 +69,7 @@ static void aesX660_send_cmd(struct fpi_ssm *ssm, const unsigned char *cmd,
static void aesX660_read_response(struct fpi_ssm *ssm, size_t buf_len,
libusb_transfer_cb_fn callback)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
@ -144,7 +144,7 @@ enum finger_det_states {
static void finger_det_read_fd_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
@ -197,9 +197,9 @@ static void finger_det_set_idle_cmd_cb(struct libusb_transfer *transfer)
static void finger_det_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
int err = ssm->error;
int err = fpi_ssm_get_error(ssm);
fp_dbg("Finger detection completed");
fpi_imgdev_report_finger_status(dev, TRUE);
@ -217,7 +217,7 @@ static void finger_det_sm_complete(struct fpi_ssm *ssm)
static void finger_det_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case FINGER_DET_SEND_LED_CMD:
aesX660_send_cmd(ssm, led_blink_cmd, sizeof(led_blink_cmd),
aesX660_send_cmd_cb);
@ -248,7 +248,7 @@ static void start_finger_detection(struct fp_img_dev *dev)
}
ssm = fpi_ssm_new(dev->dev, finger_det_run_state, FINGER_DET_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, finger_det_sm_complete);
}
@ -267,7 +267,7 @@ static int process_stripe_data(struct fpi_ssm *ssm, unsigned char *data)
{
struct fpi_frame *stripe;
unsigned char *stripdata;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
stripe = g_malloc(aesdev->assembling_ctx->frame_width * FRAME_HEIGHT / 2 + sizeof(struct fpi_frame)); /* 4 bpp */
@ -295,7 +295,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;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
@ -321,7 +321,7 @@ static void capture_set_idle_cmd_cb(struct libusb_transfer *transfer)
static void capture_read_stripe_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
int finger_missing = 0;
@ -373,10 +373,10 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_SEND_LED_CMD:
aesX660_send_cmd(ssm, led_solid_cmd, sizeof(led_solid_cmd),
aesX660_send_cmd_cb);
@ -402,9 +402,9 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
int err = ssm->error;
int err = fpi_ssm_get_error(ssm);
fp_dbg("Capture completed");
fpi_ssm_free(ssm);
@ -429,7 +429,7 @@ static void start_capture(struct fp_img_dev *dev)
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
@ -449,7 +449,7 @@ enum activate_states {
static void activate_read_id_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
@ -500,7 +500,7 @@ out:
static void activate_read_init_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
@ -536,10 +536,10 @@ out:
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case ACTIVATE_SET_IDLE:
aesdev->init_seq_idx = 0;
fp_dbg("Activate: set idle\n");
@ -582,8 +582,8 @@ static void activate_run_state(struct fpi_ssm *ssm)
static void activate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
int err = ssm->error;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
int err = fpi_ssm_get_error(ssm);
fp_dbg("status %d", err);
fpi_imgdev_activate_complete(dev, err);
fpi_ssm_free(ssm);
@ -596,7 +596,7 @@ int aesX660_dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
{
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_sm_complete);
return 0;
}

View file

@ -161,7 +161,7 @@ static void elan_submit_image(struct fp_img_dev *dev)
static void elan_cmd_done(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
@ -176,7 +176,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;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
@ -218,7 +218,7 @@ static void elan_cmd_cb(struct libusb_transfer *transfer)
static void elan_cmd_read(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
int response_len = elandev->cmds[elandev->cmd_idx].response_len;
@ -251,7 +251,7 @@ static void elan_cmd_read(struct fpi_ssm *ssm)
static void elan_run_next_cmd(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
@ -278,7 +278,7 @@ static void elan_run_next_cmd(struct fpi_ssm *ssm)
static void elan_run_cmds(struct fpi_ssm *ssm, const struct elan_cmd *cmds,
size_t cmds_len, int cmd_timeout)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
@ -298,7 +298,7 @@ enum deactivate_states {
static void elan_deactivate_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case DEACTIVATE:
elan_run_cmds(ssm, deactivate_cmds, deactivate_cmds_len,
ELAN_CMD_TIMEOUT);
@ -308,7 +308,7 @@ static void elan_deactivate_run_state(struct fpi_ssm *ssm)
static void deactivate_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
fpi_imgdev_deactivate_complete(dev);
}
@ -323,7 +323,7 @@ static void elan_deactivate(struct fp_img_dev *dev)
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, elan_deactivate_run_state,
DEACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, deactivate_complete);
}
@ -337,10 +337,10 @@ enum capture_states {
static void elan_capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_START:
elan_run_cmds(ssm, capture_start_cmds, capture_start_cmds_len,
ELAN_CMD_TIMEOUT);
@ -377,7 +377,7 @@ static void elan_capture_async(void *data)
static void capture_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
@ -386,9 +386,9 @@ static void capture_complete(struct fpi_ssm *ssm)
elan_deactivate(dev);
/* either max frames captured or timed out waiting for the next frame */
else if (!ssm->error
|| (ssm->error == -ETIMEDOUT
&& ssm->cur_state == CAPTURE_WAIT_FINGER))
else if (!fpi_ssm_get_error(ssm)
|| (fpi_ssm_get_error(ssm) == -ETIMEDOUT
&& fpi_ssm_get_cur_state(ssm) == CAPTURE_WAIT_FINGER))
if (elandev->num_frames >= ELAN_MIN_FRAMES) {
elan_submit_image(dev);
fpi_imgdev_report_finger_status(dev, FALSE);
@ -422,7 +422,7 @@ static void elan_capture(struct fp_img_dev *dev)
elan_dev_reset(elandev);
struct fpi_ssm *ssm =
fpi_ssm_new(dev->dev, elan_capture_run_state, CAPTURE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_complete);
}
@ -438,7 +438,7 @@ enum calibrate_states {
static void elan_calibrate_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CALIBRATE_START_1:
case CALIBRATE_START_2:
elan_run_cmds(ssm, calibrate_start_cmds,
@ -457,17 +457,17 @@ static void elan_calibrate_run_state(struct fpi_ssm *ssm)
static void calibrate_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
if (elandev->deactivating)
elan_deactivate(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else {
fpi_imgdev_activate_complete(dev, ssm->error);
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
elan_capture(dev);
}
fpi_ssm_free(ssm);
@ -482,7 +482,7 @@ static void elan_calibrate(struct fp_img_dev *dev)
elan_dev_reset(elandev);
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, elan_calibrate_run_state,
CALIBRATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, calibrate_complete);
}
@ -497,10 +497,10 @@ enum activate_states {
static void elan_activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case ACTIVATE_GET_SENSOR_DIM:
elan_run_cmds(ssm, get_sensor_dim_cmds, get_sensor_dim_cmds_len,
ELAN_CMD_TIMEOUT);
@ -527,15 +527,15 @@ static void elan_activate_run_state(struct fpi_ssm *ssm)
static void activate_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = dev->priv;
G_DEBUG_HERE();
if (elandev->deactivating)
elan_deactivate(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else
elan_calibrate(dev);
fpi_ssm_free(ssm);
@ -550,7 +550,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
elan_dev_reset(elandev);
struct fpi_ssm *ssm =
fpi_ssm_new(dev->dev, elan_activate_run_state, ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_complete);
return 0;

View file

@ -670,7 +670,7 @@ 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;
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
@ -701,10 +701,10 @@ static void async_tx_cb(struct libusb_transfer *transfer)
static void m_exit_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case EXIT_SET_REGS_REQ:
msg_set_regs(dev, 4, REG_VCO_CONTROL, REG_VCO_IDLE,
REG_MODE_CONTROL, REG_MODE_SLEEP);
@ -717,7 +717,7 @@ static void m_exit_state(struct fpi_ssm *ssm)
fpi_ssm_mark_completed(ssm);
break;
default:
fp_err("Unknown state %d", ssm->cur_state);
fp_err("Unknown state %d", fpi_ssm_get_cur_state(ssm));
goto err;
break;
}
@ -729,9 +729,9 @@ err:
static void m_exit_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
if (ssm->error) {
if (fpi_ssm_get_error(ssm)) {
fp_err("Error switching the device to idle state");
} else {
fp_dbg("The device is now in idle state");
@ -745,13 +745,13 @@ static void m_exit_start(struct fp_img_dev *idev)
struct fpi_ssm *ssm = fpi_ssm_new(idev->dev, m_exit_state,
EXIT_NUM_STATES);
fp_dbg("Switching device to idle mode");
ssm->priv = idev;
fpi_ssm_set_user_data(ssm, idev);
fpi_ssm_start(ssm, m_exit_complete);
}
static void m_capture_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
if (dev->is_active == FALSE) {
@ -759,7 +759,7 @@ static void m_capture_state(struct fpi_ssm *ssm)
return;
}
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAP_FP_INIT_SET_REG10_REQ:
/* Reset fingerprint */
fp_dbg("Capturing a fingerprint...");
@ -820,7 +820,7 @@ static void m_capture_state(struct fpi_ssm *ssm)
}
break;
default:
fp_err("Unknown state %d", ssm->cur_state);
fp_err("Unknown state %d", fpi_ssm_get_cur_state(ssm));
goto err;
break;
}
@ -832,14 +832,14 @@ err:
static void m_capture_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
if (ssm->error) {
if (fpi_ssm_get_error(ssm)) {
if (idev->action_state != IMG_ACQUIRE_STATE_DEACTIVATING) {
fp_err("Error while capturing fingerprint "
"(ssm->error=%d)", ssm->error);
fpi_imgdev_session_error(idev, ssm->error);
"(fpi_ssm_get_error(ssm)=%d)", fpi_ssm_get_error(ssm));
fpi_imgdev_session_error(idev, fpi_ssm_get_error(ssm));
}
}
fpi_ssm_free(ssm);
@ -854,7 +854,7 @@ static void m_capture_complete(struct fpi_ssm *ssm)
static void m_finger_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
if (dev->is_active == FALSE) {
@ -862,7 +862,7 @@ static void m_finger_state(struct fpi_ssm *ssm)
return;
}
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case FGR_FPA_INIT_SET_MODE_SLEEP_REQ:
msg_set_mode_control(dev, REG_MODE_SLEEP);
if (async_tx(idev, EP_OUT, async_tx_cb, ssm))
@ -938,7 +938,7 @@ static void m_finger_state(struct fpi_ssm *ssm)
}
break;
default:
fp_err("Unknown state %d", ssm->cur_state);
fp_err("Unknown state %d", fpi_ssm_get_cur_state(ssm));
goto err;
break;
}
@ -950,19 +950,19 @@ err:
static void m_finger_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
if (!ssm->error) {
if (!fpi_ssm_get_error(ssm)) {
struct fpi_ssm *ssm_cap;
ssm_cap = fpi_ssm_new(idev->dev, m_capture_state,
CAP_NUM_STATES);
ssm_cap->priv = idev;
fpi_ssm_set_user_data(ssm_cap, idev);
fpi_ssm_start(ssm_cap, m_capture_complete);
} else {
if (idev->action_state != IMG_ACQUIRE_STATE_DEACTIVATING) {
fp_err("Error while capturing fingerprint "
"(ssm->error=%d)", ssm->error);
"(fpi_ssm_get_error(ssm)=%d)", fpi_ssm_get_error(ssm));
fpi_imgdev_session_error(idev, -4);
}
dev->is_active = FALSE;
@ -975,7 +975,7 @@ static void m_start_fingerdetect(struct fp_img_dev *idev)
{
struct fpi_ssm *ssmf;
ssmf = fpi_ssm_new(idev->dev, m_finger_state, FGR_NUM_STATES);
ssmf->priv = idev;
fpi_ssm_set_user_data(ssmf, idev);
fpi_ssm_start(ssmf, m_finger_complete);
}
@ -984,7 +984,7 @@ static void m_start_fingerdetect(struct fp_img_dev *idev)
*/
static void m_tunevrb_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
float hist[5];
@ -993,7 +993,7 @@ static void m_tunevrb_state(struct fpi_ssm *ssm)
return;
}
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case TUNEVRB_INIT:
fp_dbg("Tuning of VRT/VRB");
g_assert(dev->dcoffset);
@ -1124,7 +1124,7 @@ static void m_tunevrb_state(struct fpi_ssm *ssm)
fpi_ssm_mark_completed(ssm);
break;
default:
fp_err("Unknown state %d", ssm->cur_state);
fp_err("Unknown state %d", fpi_ssm_get_cur_state(ssm));
goto err;
break;
}
@ -1136,10 +1136,10 @@ err:
static void m_tunevrb_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
fpi_imgdev_activate_complete(idev, ssm->error != 0);
if (!ssm->error) {
fpi_imgdev_activate_complete(idev, fpi_ssm_get_error(ssm) != 0);
if (!fpi_ssm_get_error(ssm)) {
fp_dbg("Tuning is done. Starting finger detection.");
m_start_fingerdetect(idev);
} else {
@ -1158,7 +1158,7 @@ static void m_tunevrb_complete(struct fpi_ssm *ssm)
*/
static void m_tunedc_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
if (dev->is_active == FALSE) {
@ -1170,7 +1170,7 @@ static void m_tunedc_state(struct fpi_ssm *ssm)
* captured traffic to make sure that the value is correct. */
/* The default gain should work but it may reach a DCOffset limit so in
* this case we decrease the gain. */
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case TUNEDC_INIT:
/* reg_e0 = 0x23 is sensor normal/small gain */
dev->gain = GAIN_SMALL_INIT;
@ -1248,7 +1248,7 @@ static void m_tunedc_state(struct fpi_ssm *ssm)
fpi_ssm_mark_completed(ssm);
break;
default:
fp_err("Unknown state %d", ssm->cur_state);
fp_err("Unknown state %d", fpi_ssm_get_cur_state(ssm));
goto err;
break;
}
@ -1261,12 +1261,12 @@ err:
static void m_tunedc_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
if (!ssm->error) {
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
if (!fpi_ssm_get_error(ssm)) {
struct fpi_ssm *ssm_tune;
ssm_tune = fpi_ssm_new(idev->dev, m_tunevrb_state,
TUNEVRB_NUM_STATES);
ssm_tune->priv = idev;
fpi_ssm_set_user_data(ssm_tune, idev);
fpi_ssm_start(ssm_tune, m_tunevrb_complete);
} else {
struct etes603_dev *dev = idev->priv;
@ -1280,7 +1280,7 @@ static void m_tunedc_complete(struct fpi_ssm *ssm)
static void m_init_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct etes603_dev *dev = idev->priv;
if (dev->is_active == FALSE) {
@ -1288,7 +1288,7 @@ static void m_init_state(struct fpi_ssm *ssm)
return;
}
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case INIT_CHECK_INFO_REQ:
msg_get_regs(dev, 4, REG_INFO0, REG_INFO1, REG_INFO2,
REG_INFO3);
@ -1368,7 +1368,7 @@ static void m_init_state(struct fpi_ssm *ssm)
fpi_ssm_mark_completed(ssm);
break;
default:
fp_err("Unknown state %d", ssm->cur_state);
fp_err("Unknown state %d", fpi_ssm_get_cur_state(ssm));
goto err;
break;
}
@ -1381,12 +1381,12 @@ err:
static void m_init_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
if (!ssm->error) {
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
if (!fpi_ssm_get_error(ssm)) {
struct fpi_ssm *ssm_tune;
ssm_tune = fpi_ssm_new(idev->dev, m_tunedc_state,
TUNEDC_NUM_STATES);
ssm_tune->priv = idev;
fpi_ssm_set_user_data(ssm_tune, idev);
fpi_ssm_start(ssm_tune, m_tunedc_complete);
} else {
struct etes603_dev *dev = idev->priv;
@ -1417,7 +1417,7 @@ static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
if (dev->dcoffset == 0) {
fp_dbg("Tuning device...");
ssm = fpi_ssm_new(idev->dev, m_init_state, INIT_NUM_STATES);
ssm->priv = idev;
fpi_ssm_set_user_data(ssm, idev);
fpi_ssm_start(ssm, m_init_complete);
} else {
fp_dbg("Using previous tuning (DCOFFSET=0x%02X,VRT=0x%02X,"
@ -1425,7 +1425,7 @@ static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
dev->vrb, dev->gain);
fpi_imgdev_activate_complete(idev, 0);
ssm = fpi_ssm_new(idev->dev, m_finger_state, FGR_NUM_STATES);
ssm->priv = idev;
fpi_ssm_set_user_data(ssm, idev);
fpi_ssm_start(ssm, m_finger_complete);
}
return 0;

View file

@ -579,6 +579,7 @@ static void sm_write_regs(struct fpi_ssm *ssm,
{
struct write_regs_data *wrdata = g_malloc(sizeof(*wrdata));
unsigned char *data;
struct fp_dev *dev;
wrdata->transfer = libusb_alloc_transfer(0);
if (!wrdata->transfer) {
@ -589,7 +590,8 @@ static void sm_write_regs(struct fpi_ssm *ssm,
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
libusb_fill_control_setup(data, 0x40, 0x0c, 0, 0, 1);
libusb_fill_control_transfer(wrdata->transfer, ssm->dev->udev, data,
dev = fpi_ssm_get_dev(ssm);
libusb_fill_control_transfer(wrdata->transfer, dev->udev, data,
write_regs_cb, wrdata, CTRL_TIMEOUT);
wrdata->transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK;
@ -613,7 +615,7 @@ static void sm_write_reg_cb(struct libusb_transfer *transfer)
static void sm_write_reg(struct fpi_ssm *ssm, uint8_t reg, uint8_t value)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
@ -644,7 +646,7 @@ static void sm_write_reg(struct fpi_ssm *ssm, uint8_t reg, uint8_t value)
static void sm_read_reg_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
@ -660,7 +662,7 @@ static void sm_read_reg_cb(struct libusb_transfer *transfer)
static void sm_read_reg(struct fpi_ssm *ssm, uint8_t reg)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
@ -689,7 +691,7 @@ static void sm_read_reg(struct fpi_ssm *ssm, uint8_t reg)
static void sm_await_intr_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
@ -710,7 +712,7 @@ static void sm_await_intr_cb(struct libusb_transfer *transfer)
static void sm_await_intr(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
@ -759,10 +761,10 @@ enum awfsm_1000_states {
static void awfsm_2016_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case AWFSM_2016_WRITEV_1:
sm_write_regs(ssm, awfsm_2016_writev_1, G_N_ELEMENTS(awfsm_2016_writev_1));
break;
@ -806,7 +808,7 @@ static void awfsm_2016_run_state(struct fpi_ssm *ssm)
static void awfsm_1000_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case AWFSM_1000_WRITEV_1:
sm_write_regs(ssm, awfsm_1000_writev_1, G_N_ELEMENTS(awfsm_1000_writev_1));
break;
@ -847,7 +849,7 @@ enum capsm_1001_states {
static void capsm_fire_bulk(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
int i;
for (i = 0; i < NUM_BULK_TRANSFERS; i++) {
@ -877,10 +879,10 @@ static void capsm_fire_bulk(struct fpi_ssm *ssm)
static void capsm_2016_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPSM_2016_INIT:
sdev->rowbuf_offset = -1;
sdev->num_rows = 0;
@ -909,10 +911,10 @@ static void capsm_2016_run_state(struct fpi_ssm *ssm)
static void capsm_1000_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPSM_1000_INIT:
sdev->rowbuf_offset = -1;
sdev->num_rows = 0;
@ -935,10 +937,10 @@ static void capsm_1000_run_state(struct fpi_ssm *ssm)
static void capsm_1001_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPSM_1001_INIT:
sdev->rowbuf_offset = -1;
sdev->num_rows = 0;
@ -990,7 +992,7 @@ enum deinitsm_1001_states {
static void deinitsm_2016_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case DEINITSM_2016_WRITEV:
sm_write_regs(ssm, deinitsm_2016_writev, G_N_ELEMENTS(deinitsm_2016_writev));
break;
@ -999,7 +1001,7 @@ static void deinitsm_2016_run_state(struct fpi_ssm *ssm)
static void deinitsm_1000_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case DEINITSM_1000_WRITEV:
sm_write_regs(ssm, deinitsm_1000_writev, G_N_ELEMENTS(deinitsm_1000_writev));
break;
@ -1008,7 +1010,7 @@ static void deinitsm_1000_run_state(struct fpi_ssm *ssm)
static void deinitsm_1001_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case DEINITSM_1001_WRITEV:
sm_write_regs(ssm, deinitsm_1001_writev, G_N_ELEMENTS(deinitsm_1001_writev));
break;
@ -1044,10 +1046,10 @@ enum initsm_1001_states {
static void initsm_2016_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case INITSM_2016_WRITEV_1:
sm_write_regs(ssm, initsm_2016_writev_1, G_N_ELEMENTS(initsm_2016_writev_1));
break;
@ -1074,7 +1076,7 @@ static void initsm_2016_run_state(struct fpi_ssm *ssm)
static void initsm_1000_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case INITSM_1000_WRITEV_1:
sm_write_regs(ssm, initsm_1000_writev_1, G_N_ELEMENTS(initsm_1000_writev_1));
break;
@ -1083,7 +1085,7 @@ static void initsm_1000_run_state(struct fpi_ssm *ssm)
static void initsm_1001_run_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case INITSM_1001_WRITEV_1:
sm_write_regs(ssm, initsm_1001_writev_1, G_N_ELEMENTS(initsm_1001_writev_1));
break;
@ -1116,10 +1118,10 @@ enum loopsm_states {
static void loopsm_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case LOOPSM_RUN_AWFSM: ;
switch (sdev->dev_model) {
case UPEKSONLY_1001:
@ -1144,7 +1146,7 @@ static void loopsm_run_state(struct fpi_ssm *ssm)
AWFSM_1000_NUM_STATES);
break;
}
awfsm->priv = dev;
fpi_ssm_set_user_data(awfsm, dev);
fpi_ssm_start_subsm(ssm, awfsm);
}
break;
@ -1176,7 +1178,7 @@ static void loopsm_run_state(struct fpi_ssm *ssm)
CAPSM_1001_NUM_STATES);
break;
}
capsm->priv = dev;
fpi_ssm_set_user_data(capsm, dev);
fpi_ssm_start_subsm(ssm, capsm);
break;
case LOOPSM_CAPTURE:
@ -1198,7 +1200,7 @@ static void loopsm_run_state(struct fpi_ssm *ssm)
break;
}
sdev->capturing = FALSE;
deinitsm->priv = dev;
fpi_ssm_set_user_data(deinitsm, dev);
fpi_ssm_start_subsm(ssm, deinitsm);
break;
case LOOPSM_FINAL:
@ -1244,9 +1246,9 @@ static void dev_deactivate(struct fp_img_dev *dev)
static void loopsm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
int r = ssm->error;
int r = fpi_ssm_get_error(ssm);
fpi_ssm_free(ssm);
@ -1263,9 +1265,9 @@ static void loopsm_complete(struct fpi_ssm *ssm)
static void initsm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct sonly_dev *sdev = dev->priv;
int r = ssm->error;
int r = fpi_ssm_get_error(ssm);
fpi_ssm_free(ssm);
fpi_imgdev_activate_complete(dev, r);
@ -1273,7 +1275,7 @@ static void initsm_complete(struct fpi_ssm *ssm)
return;
sdev->loopsm = fpi_ssm_new(dev->dev, loopsm_run_state, LOOPSM_NUM_STATES);
sdev->loopsm->priv = dev;
fpi_ssm_set_user_data(sdev->loopsm, dev);
fpi_ssm_start(sdev->loopsm, loopsm_complete);
}
@ -1316,7 +1318,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
ssm = fpi_ssm_new(dev->dev, initsm_1001_run_state, INITSM_1001_NUM_STATES);
break;
}
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, initsm_complete);
return 0;
}

View file

@ -58,7 +58,7 @@ enum activate_states {
static void upektc_next_init_cmd(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_dev *upekdev = dev->priv;
upekdev->init_idx += 1;
@ -71,7 +71,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;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_dev *upekdev = dev->priv;
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
@ -100,11 +100,11 @@ static void read_init_data_cb(struct libusb_transfer *transfer)
static void activate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_dev *upekdev = dev->priv;
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case WRITE_INIT:
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
@ -150,11 +150,11 @@ static void activate_run_state(struct fpi_ssm *ssm)
static void activate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
fp_dbg("status %d", ssm->error);
fpi_imgdev_activate_complete(dev, ssm->error);
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
fp_dbg("status %d", fpi_ssm_get_error(ssm));
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
if (!ssm->error)
if (!fpi_ssm_get_error(ssm))
start_finger_detection(dev);
fpi_ssm_free(ssm);
}
@ -297,7 +297,7 @@ static void capture_cmd_cb(struct libusb_transfer *transfer)
static void capture_read_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
unsigned char *data = transfer->buffer;
struct fp_img *img;
@ -323,11 +323,11 @@ out:
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_dev *upekdev = dev->priv;
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_WRITE_CMD:
{
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
@ -372,14 +372,14 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_dev *upekdev = dev->priv;
fp_dbg("Capture completed");
if (upekdev->deactivating)
complete_deactivation(dev);
else if (ssm->error)
fpi_imgdev_session_error(dev, ssm->error);
else if (fpi_ssm_get_error(ssm))
fpi_imgdev_session_error(dev, fpi_ssm_get_error(ssm));
else
start_finger_detection(dev);
fpi_ssm_free(ssm);
@ -397,7 +397,7 @@ static void start_capture(struct fp_img_dev *dev)
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
G_DEBUG_HERE();
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
@ -406,7 +406,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
struct upektc_dev *upekdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
upekdev->init_idx = 0;
fpi_ssm_start(ssm, activate_sm_complete);
return 0;

View file

@ -118,7 +118,7 @@ static void upektc_img_submit_req(struct fpi_ssm *ssm,
const unsigned char *buf, size_t buf_size, unsigned char seq,
libusb_transfer_cb_fn cb)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
int r;
@ -149,7 +149,7 @@ static void upektc_img_submit_req(struct fpi_ssm *ssm,
static void upektc_img_read_data(struct 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 = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
int r;
@ -194,7 +194,7 @@ static void capture_reqs_cb(struct libusb_transfer *transfer)
fpi_ssm_mark_aborted(ssm, -EIO);
return;
}
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_ACK_00_28_TERM:
fpi_ssm_jump_to_state(ssm, CAPTURE_READ_DATA_TERM);
break;
@ -225,7 +225,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;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
unsigned char *data = upekdev->response;
struct fp_img *img;
@ -245,11 +245,11 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
fp_dbg("request completed, len: %.4x", transfer->actual_length);
if (transfer->actual_length == 0) {
fpi_ssm_jump_to_state(ssm, ssm->cur_state);
fpi_ssm_jump_to_state(ssm, fpi_ssm_get_cur_state(ssm));
return;
}
if (ssm->cur_state == CAPTURE_READ_DATA_TERM) {
if (fpi_ssm_get_cur_state(ssm) == CAPTURE_READ_DATA_TERM) {
fp_dbg("Terminating SSM\n");
fpi_ssm_mark_completed(ssm);
return;
@ -349,10 +349,10 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
static void capture_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_INIT_CAPTURE:
upektc_img_submit_req(ssm, upek2020_init_capture, sizeof(upek2020_init_capture),
upekdev->seq, capture_reqs_cb);
@ -386,9 +386,9 @@ static void capture_run_state(struct fpi_ssm *ssm)
static void capture_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
int err = ssm->error;
int err = fpi_ssm_get_error(ssm);
fp_dbg("Capture completed, %d", err);
fpi_ssm_free(ssm);
@ -409,7 +409,7 @@ static void start_capture(struct fp_img_dev *dev)
upekdev->image_size = 0;
ssm = fpi_ssm_new(dev->dev, capture_run_state, CAPTURE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, capture_sm_complete);
}
@ -447,10 +447,10 @@ static void deactivate_read_data_cb(struct libusb_transfer *transfer)
static void deactivate_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case DEACTIVATE_DEINIT:
upektc_img_submit_req(ssm, upek2020_deinit, sizeof(upek2020_deinit),
upekdev->seq, deactivate_reqs_cb);
@ -464,9 +464,9 @@ static void deactivate_run_state(struct fpi_ssm *ssm)
static void deactivate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = dev->priv;
int err = ssm->error;
int err = fpi_ssm_get_error(ssm);
fp_dbg("Deactivate completed");
fpi_ssm_free(ssm);
@ -488,7 +488,7 @@ static void start_deactivation(struct fp_img_dev *dev)
upekdev->image_size = 0;
ssm = fpi_ssm_new(dev->dev, deactivate_run_state, DEACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, deactivate_sm_complete);
}
@ -546,11 +546,12 @@ static void init_read_data_cb(struct libusb_transfer *transfer)
static void activate_run_state(struct fpi_ssm *ssm)
{
struct libusb_transfer *transfer;
struct fp_img_dev *dev = ssm->priv;
struct upektc_img_dev *upekdev = dev->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct upektc_img_dev *upekdev = idev->priv;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case ACTIVATE_CONTROL_REQ_1:
case ACTIVATE_CONTROL_REQ_2:
{
@ -567,7 +568,7 @@ static void activate_run_state(struct fpi_ssm *ssm)
data = g_malloc0(LIBUSB_CONTROL_SETUP_SIZE + 1);
libusb_fill_control_setup(data,
LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, 0x0c, 0x100, 0x0400, 1);
libusb_fill_control_transfer(transfer, ssm->dev->udev, data,
libusb_fill_control_transfer(transfer, dev->udev, data,
init_reqs_ctrl_cb, ssm, CTRL_TIMEOUT);
r = libusb_submit_transfer(transfer);
if (r < 0) {
@ -608,8 +609,8 @@ static void activate_run_state(struct fpi_ssm *ssm)
static void activate_sm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
int err = ssm->error;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
int err = fpi_ssm_get_error(ssm);
fpi_ssm_free(ssm);
fp_dbg("%s status %d", __func__, err);
@ -624,7 +625,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
struct upektc_img_dev *upekdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, activate_run_state,
ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
upekdev->seq = 0;
fpi_ssm_start(ssm, activate_sm_complete);
return 0;

View file

@ -529,23 +529,23 @@ static void initsm_read_msg_response_cb(struct fpi_ssm *ssm,
enum read_msg_status status, uint8_t seq,
unsigned char expect_subcmd, unsigned char subcmd)
{
struct fp_dev *dev = ssm->dev;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
struct upekts_dev *upekdev = dev->priv;
if (status != READ_MSG_RESPONSE) {
fp_err("expected response, got %d seq=%x in state %d", status, seq,
ssm->cur_state);
fpi_ssm_get_cur_state(ssm));
fpi_ssm_mark_aborted(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, ssm->cur_state);
"state %d", expect_subcmd, subcmd, fpi_ssm_get_cur_state(ssm));
fpi_ssm_mark_aborted(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, ssm->cur_state);
"in state %d", upekdev->seq, seq, fpi_ssm_get_cur_state(ssm));
fpi_ssm_mark_aborted(ssm, -1);
} else {
fp_dbg("state %d completed", ssm->cur_state);
fp_dbg("state %d completed", fpi_ssm_get_cur_state(ssm));
fpi_ssm_next_state(ssm);
}
}
@ -593,7 +593,7 @@ static void read28_06_cb(struct fp_dev *dev, enum read_msg_status status,
static void initsm_read_msg_cmd_cb(struct fpi_ssm *ssm,
enum read_msg_status status, uint8_t expect_seq, uint8_t seq)
{
struct fp_dev *dev = ssm->dev;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
struct upekts_dev *upekdev = dev->priv;
if (status == READ_MSG_ERROR) {
@ -601,14 +601,14 @@ static void initsm_read_msg_cmd_cb(struct fpi_ssm *ssm,
return;
} else if (status != READ_MSG_CMD) {
fp_err("expected command, got %d seq=%x in state %d", status, seq,
ssm->cur_state);
fpi_ssm_get_cur_state(ssm));
fpi_ssm_mark_aborted(ssm, -1);
return;
}
upekdev->seq = seq;
if (seq != expect_seq) {
fp_err("expected seq=%x, got %x in state %d", expect_seq, seq,
ssm->cur_state);
fpi_ssm_get_cur_state(ssm));
fpi_ssm_mark_aborted(ssm, -1);
return;
}
@ -645,9 +645,9 @@ static void ctrl400_cb(struct libusb_transfer *transfer)
static void initsm_read_msg_handler(struct fpi_ssm *ssm,
read_msg_cb_fn callback)
{
int r = read_msg_async(ssm->dev, callback, ssm);
int r = read_msg_async(fpi_ssm_get_dev(ssm), callback, ssm);
if (r < 0) {
fp_err("async read msg failed in state %d", ssm->cur_state);
fp_err("async read msg failed in state %d", fpi_ssm_get_cur_state(ssm));
fpi_ssm_mark_aborted(ssm, r);
}
}
@ -657,10 +657,10 @@ static void initsm_send_msg_cb(struct libusb_transfer *transfer)
struct fpi_ssm *ssm = transfer->user_data;
if (transfer->status == LIBUSB_TRANSFER_COMPLETED
&& transfer->length == transfer->actual_length) {
fp_dbg("state %d completed", ssm->cur_state);
fp_dbg("state %d completed", fpi_ssm_get_cur_state(ssm));
fpi_ssm_next_state(ssm);
} else {
fp_err("failed, state=%d rqlength=%d actual_length=%d", ssm->cur_state,
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);
}
@ -670,7 +670,7 @@ static void initsm_send_msg_cb(struct libusb_transfer *transfer)
static void initsm_send_msg28_handler(struct fpi_ssm *ssm,
unsigned char subcmd, const unsigned char *data, uint16_t innerlen)
{
struct fp_dev *dev = ssm->dev;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
struct libusb_transfer *transfer;
int r;
@ -683,7 +683,7 @@ static void initsm_send_msg28_handler(struct fpi_ssm *ssm,
r = libusb_submit_transfer(transfer);
if (r < 0) {
fp_err("urb submission failed error %d in state %d", r, ssm->cur_state);
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);
@ -692,12 +692,12 @@ static void initsm_send_msg28_handler(struct fpi_ssm *ssm,
static void initsm_run_state(struct fpi_ssm *ssm)
{
struct fp_dev *dev = ssm->dev;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
struct upekts_dev *upekdev = dev->priv;
struct libusb_transfer *transfer;
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case WRITE_CTRL400: ;
unsigned char *data;
@ -710,7 +710,7 @@ static void initsm_run_state(struct fpi_ssm *ssm)
data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
libusb_fill_control_setup(data,
LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, 0x0c, 0x100, 0x0400, 1);
libusb_fill_control_transfer(transfer, ssm->dev->udev, data,
libusb_fill_control_transfer(transfer, dev->udev, data,
ctrl400_cb, ssm, TIMEOUT);
r = libusb_submit_transfer(transfer);
@ -827,10 +827,10 @@ static void read_msg01_cb(struct fp_dev *dev, enum read_msg_status status,
static void deinitsm_state_handler(struct fpi_ssm *ssm)
{
struct fp_dev *dev = ssm->dev;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case SEND_RESP07: ;
struct libusb_transfer *transfer;
unsigned char dummy = 0;
@ -909,8 +909,8 @@ enum enroll_start_sm_states {
/* Called when the device initialization state machine completes */
static void enroll_start_sm_cb_initsm(struct fpi_ssm *initsm)
{
struct fpi_ssm *enroll_start_ssm = initsm->priv;
int error = initsm->error;
struct fpi_ssm *enroll_start_ssm = fpi_ssm_get_user_data(initsm);
int error = fpi_ssm_get_error(initsm);
fpi_ssm_free(initsm);
if (error)
@ -957,13 +957,13 @@ static void enroll_start_sm_cb_msg28(struct fp_dev *dev,
static void enroll_start_sm_run_state(struct fpi_ssm *ssm)
{
struct fp_dev *dev = ssm->dev;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case RUN_INITSM: ;
struct fpi_ssm *initsm = initsm_new(dev);
initsm->priv = ssm;
fpi_ssm_set_user_data(initsm, ssm);
fpi_ssm_start(initsm, enroll_start_sm_cb_initsm);
break;
case ENROLL_INIT: ;
@ -1150,10 +1150,10 @@ static void enroll_iterate(struct fp_dev *dev)
static void enroll_started(struct fpi_ssm *ssm)
{
struct fp_dev *dev = ssm->dev;
fpi_drvcb_enroll_started(dev, ssm->error);
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
fpi_drvcb_enroll_started(dev, fpi_ssm_get_error(ssm));
if (!ssm->error)
if (!fpi_ssm_get_error(ssm))
enroll_iterate(dev);
fpi_ssm_free(ssm);
@ -1175,7 +1175,7 @@ static int enroll_start(struct fp_dev *dev)
static void enroll_stop_deinit_cb(struct fpi_ssm *ssm)
{
/* don't really care about errors */
fpi_drvcb_enroll_stopped(ssm->dev);
fpi_drvcb_enroll_stopped(fpi_ssm_get_dev(ssm));
fpi_ssm_free(ssm);
}
@ -1189,7 +1189,7 @@ static int enroll_stop(struct fp_dev *dev)
static void verify_stop_deinit_cb(struct fpi_ssm *ssm)
{
/* don't really care about errors */
fpi_drvcb_verify_stopped(ssm->dev);
fpi_drvcb_verify_stopped(fpi_ssm_get_dev(ssm));
fpi_ssm_free(ssm);
}
@ -1214,9 +1214,12 @@ enum {
/* Called when the device initialization state machine completes */
static void verify_start_sm_cb_initsm(struct fpi_ssm *initsm)
{
struct fpi_ssm *verify_start_ssm = initsm->priv;
if (initsm->error)
fpi_ssm_mark_aborted(verify_start_ssm, initsm->error);
struct 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);
else
fpi_ssm_next_state(verify_start_ssm);
fpi_ssm_free(initsm);
@ -1236,13 +1239,13 @@ static void verify_init_2803_cb(struct libusb_transfer *transfer)
static void verify_start_sm_run_state(struct fpi_ssm *ssm)
{
struct fp_dev *dev = ssm->dev;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
int r;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case VERIFY_RUN_INITSM: ;
struct fpi_ssm *initsm = initsm_new(dev);
initsm->priv = ssm;
fpi_ssm_set_user_data(initsm, ssm);
fpi_ssm_start(initsm, verify_start_sm_cb_initsm);
break;
case VERIFY_INIT: ;
@ -1426,11 +1429,11 @@ static void verify_iterate(struct fp_dev *dev)
static void verify_started(struct fpi_ssm *ssm)
{
struct fp_dev *dev = ssm->dev;
struct fp_dev *dev = fpi_ssm_get_dev(ssm);
struct upekts_dev *upekdev = dev->priv;
fpi_drvcb_verify_started(dev, ssm->error);
if (!ssm->error) {
fpi_drvcb_verify_started(dev, fpi_ssm_get_error(ssm));
if (!fpi_ssm_get_error(ssm)) {
upekdev->first_verify_iteration = TRUE;
verify_iterate(dev);
}

View file

@ -356,7 +356,7 @@ static void challenge_cb(struct fp_img_dev *dev, int status,
*/
static void sm_do_challenge_response(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
int r;
G_DEBUG_HERE();
@ -519,7 +519,7 @@ static void sm_write_reg_cb(struct fp_img_dev *dev, int result, void *user_data)
static void sm_write_regs(struct fpi_ssm *ssm, uint16_t first_reg, uint16_t num_regs,
void *data)
{
struct fp_img_dev *dev = ssm->priv;
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);
@ -548,7 +548,7 @@ 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)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
int r;
@ -689,7 +689,7 @@ static int calc_dev2(struct uru4k_image *img)
static void imaging_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
struct uru4k_image *img = urudev->img_data;
struct fp_img *fpimg;
@ -698,7 +698,7 @@ static void imaging_run_state(struct fpi_ssm *ssm)
int i, r, to, dev2;
char buf[5];
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case IMAGING_CAPTURE:
urudev->img_lines_done = 0;
urudev->img_block = 0;
@ -812,9 +812,9 @@ static void imaging_run_state(struct fpi_ssm *ssm)
static void imaging_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
int r = ssm->error;
int r = fpi_ssm_get_error(ssm);
fpi_ssm_free(ssm);
/* Report error before exiting imaging loop - the error handler
@ -863,7 +863,7 @@ enum rebootpwr_states {
static void rebootpwr_pause_cb(void *data)
{
struct fpi_ssm *ssm = data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
if (!--urudev->rebootpwr_ctr) {
@ -876,10 +876,10 @@ static void rebootpwr_pause_cb(void *data)
static void rebootpwr_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case REBOOTPWR_SET_HWSTAT:
urudev->rebootpwr_ctr = 100;
sm_set_hwstat(ssm, urudev->last_hwstat & 0xf);
@ -940,7 +940,7 @@ enum powerup_states {
static void powerup_pause_cb(void *data)
{
struct fpi_ssm *ssm = data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
if (!--urudev->powerup_ctr) {
@ -955,10 +955,10 @@ static void powerup_pause_cb(void *data)
static void powerup_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case POWERUP_INIT:
urudev->powerup_ctr = 100;
urudev->powerup_hwstat = urudev->last_hwstat & 0xf;
@ -1031,7 +1031,7 @@ static void init_scanpwr_irq_cb(struct fp_img_dev *dev, int status,
fpi_ssm_mark_aborted(ssm, status);
else if (type != IRQDATA_SCANPWR_ON)
fp_dbg("ignoring interrupt");
else if (ssm->cur_state != INIT_AWAIT_SCAN_POWER) {
else if (fpi_ssm_get_cur_state(ssm) != INIT_AWAIT_SCAN_POWER) {
fp_dbg("early scanpwr interrupt");
urudev->scanpwr_irq_timeouts = -1;
} else {
@ -1043,7 +1043,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;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
fp_warn("powerup timed out");
@ -1060,10 +1060,10 @@ static void init_scanpwr_timeout(void *user_data)
static void init_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct uru4k_dev *urudev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case INIT_GET_HWSTAT:
sm_read_reg(ssm, REG_HWSTAT);
break;
@ -1077,7 +1077,7 @@ static void init_run_state(struct fpi_ssm *ssm)
case INIT_REBOOT_POWER: ;
struct fpi_ssm *rebootsm = fpi_ssm_new(dev->dev, rebootpwr_run_state,
REBOOTPWR_NUM_STATES);
rebootsm->priv = dev;
fpi_ssm_set_user_data(rebootsm, dev);
fpi_ssm_start_subsm(ssm, rebootsm);
break;
case INIT_CHECK_HWSTAT_POWERDOWN:
@ -1096,7 +1096,7 @@ static void init_run_state(struct fpi_ssm *ssm)
struct fpi_ssm *powerupsm = fpi_ssm_new(dev->dev, powerup_run_state,
POWERUP_NUM_STATES);
powerupsm->priv = dev;
fpi_ssm_set_user_data(powerupsm, dev);
fpi_ssm_start_subsm(ssm, powerupsm);
break;
case INIT_AWAIT_SCAN_POWER:
@ -1140,8 +1140,8 @@ static void init_run_state(struct fpi_ssm *ssm)
static void activate_initsm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
int r = ssm->error;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
int r = fpi_ssm_get_error(ssm);
fpi_ssm_free(ssm);
if (r) {
@ -1170,7 +1170,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
urudev->scanpwr_irq_timeouts = 0;
urudev->activate_state = state;
ssm = fpi_ssm_new(dev->dev, init_run_state, INIT_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, activate_initsm_complete);
return 0;
}
@ -1224,7 +1224,7 @@ static int execute_state_change(struct fp_img_dev *dev)
urudev->img_enc_seed = rand();
ssm = fpi_ssm_new(dev->dev, imaging_run_state, IMAGING_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, imaging_complete);
return write_reg(dev, REG_MODE, MODE_CAPTURE,

View file

@ -88,7 +88,7 @@ static void sm_write_reg_cb(struct libusb_transfer *transfer)
static void sm_write_reg(struct fpi_ssm *ssm, unsigned char reg,
unsigned char value)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
@ -127,7 +127,7 @@ static void sm_exec_cmd_cb(struct libusb_transfer *transfer)
static void sm_exec_cmd(struct fpi_ssm *ssm, unsigned char cmd,
unsigned char param)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
@ -192,7 +192,7 @@ static void capture_iterate(struct fpi_ssm *ssm);
static void capture_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct v5s_dev *vdev = dev->priv;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
@ -220,7 +220,7 @@ out:
static void capture_iterate(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct v5s_dev *vdev = dev->priv;
int iteration = vdev->capture_iteration;
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
@ -245,7 +245,7 @@ static void capture_iterate(struct fpi_ssm *ssm)
static void sm_do_capture(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct v5s_dev *vdev = dev->priv;
G_DEBUG_HERE();
@ -267,10 +267,10 @@ enum loop_states {
static void loop_run_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct v5s_dev *vdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case LOOP_SET_CONTRAST:
sm_write_reg(ssm, REG_CONTRAST, 0x01);
break;
@ -295,9 +295,9 @@ static void loop_run_state(struct fpi_ssm *ssm)
static void loopsm_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct v5s_dev *vdev = dev->priv;
int r = ssm->error;
int r = fpi_ssm_get_error(ssm);
fpi_ssm_free(ssm);
fp_img_free(vdev->capture_img);
@ -316,7 +316,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
struct v5s_dev *vdev = dev->priv;
struct fpi_ssm *ssm = fpi_ssm_new(dev->dev, loop_run_state,
LOOP_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
vdev->deactivating = FALSE;
fpi_ssm_start(ssm, loopsm_complete);
vdev->loop_running = TRUE;

View file

@ -28,7 +28,7 @@
static void async_write_callback(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
int transferred = transfer->actual_length, error =
transfer->status, len = transfer->length;
@ -53,7 +53,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)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct libusb_device_handle *udev = idev->udev;
struct vfs_dev_t *vdev = idev->priv;
@ -68,7 +68,7 @@ static void async_write(struct fpi_ssm *ssm, void *data, int len)
static void async_read_callback(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
int transferred = transfer->actual_length, error =
transfer->status, len = transfer->length;
@ -95,7 +95,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)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct libusb_device_handle *udev = idev->udev;
struct vfs_dev_t *vdev = idev->priv;
@ -120,7 +120,7 @@ static void async_read(struct fpi_ssm *ssm, int ep, void *data, int len)
static void async_abort_callback(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
int transferred = transfer->actual_length, error = transfer->status;
int ep = transfer->endpoint;
@ -143,13 +143,13 @@ static void async_abort_callback(struct libusb_transfer *transfer)
fp_warn("Endpoint %d had extra %d bytes", ep - 0x80,
transferred);
fpi_ssm_jump_to_state(ssm, ssm->cur_state);
fpi_ssm_jump_to_state(ssm, fpi_ssm_get_cur_state(ssm));
}
/* Receive data from the given ep and compare with expected */
static void async_abort(struct fpi_ssm *ssm, int ep)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct libusb_device_handle *udev = idev->udev;
struct vfs_dev_t *vdev = idev->priv;
@ -281,12 +281,12 @@ static void submit_image(struct fp_img_dev *idev)
/* SSM loop for clear_ep2 */
static void clear_ep2_ssm(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
short result;
char command04 = 0x04;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case SUBSM1_COMMAND_04:
async_write(ssm, &command04, sizeof(command04));
break;
@ -309,23 +309,23 @@ static void clear_ep2_ssm(struct fpi_ssm *ssm)
/* Send command to clear EP2 */
static void clear_ep2(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fpi_ssm *subsm =
fpi_ssm_new(idev->dev, clear_ep2_ssm, SUBSM1_STATES);
subsm->priv = idev;
fpi_ssm_set_user_data(subsm, idev);
fpi_ssm_start_subsm(ssm, subsm);
}
static void send_control_packet_ssm(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct vfs_dev_t *vdev = idev->priv;
short result;
unsigned char *commit_result = NULL;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case SUBSM2_SEND_CONTROL:
async_write(ssm, vdev->control_packet, VFS_CONTROL_PACKET_SIZE);
break;
@ -387,11 +387,11 @@ static void send_control_packet_ssm(struct fpi_ssm *ssm)
/* Send device state control packet */
static void send_control_packet(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fpi_ssm *subsm =
fpi_ssm_new(idev->dev, send_control_packet_ssm, SUBSM2_STATES);
subsm->priv = idev;
fpi_ssm_set_user_data(subsm, idev);
fpi_ssm_start_subsm(ssm, subsm);
}
@ -407,7 +407,7 @@ static void clear_data(struct vfs_dev_t *vdev)
static void interrupt_callback(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct vfs_dev_t *vdev = idev->priv;
char *interrupt = vdev->interrupt;
@ -467,7 +467,7 @@ static void interrupt_callback(struct libusb_transfer *transfer)
static void receive_callback(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct vfs_dev_t *vdev = idev->priv;
int transferred = transfer->actual_length, error = transfer->status;
@ -487,7 +487,7 @@ static void receive_callback(struct libusb_transfer *transfer)
vdev->bytes += transferred;
/* We need more data */
fpi_ssm_jump_to_state(ssm, ssm->cur_state);
fpi_ssm_jump_to_state(ssm, fpi_ssm_get_cur_state(ssm));
}
}
@ -495,12 +495,12 @@ static void receive_callback(struct libusb_transfer *transfer)
static void wait_interrupt(void *data)
{
struct fpi_ssm *ssm = data;
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct vfs_dev_t *vdev = idev->priv;
/* Keep sleeping while this flag is on */
if (vdev->wait_interrupt)
fpi_ssm_jump_to_state(ssm, ssm->cur_state);
fpi_ssm_jump_to_state(ssm, fpi_ssm_get_cur_state(ssm));
}
/* SSM stub to prepare device to another scan after orange light was on */
@ -520,11 +520,11 @@ static void scan_completed(void *data)
/* Main SSM loop */
static void activate_ssm(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct libusb_device_handle *udev = idev->udev;
struct vfs_dev_t *vdev = idev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case SSM_INITIAL_ABORT_1:
async_abort(ssm, 1);
break;
@ -673,7 +673,7 @@ static void activate_ssm(struct fpi_ssm *ssm)
/* Callback for dev_activate ssm */
static void dev_activate_callback(struct fpi_ssm *ssm)
{
struct fp_img_dev *idev = ssm->priv;
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct vfs_dev_t *vdev = idev->priv;
vdev->ssm_active = 0;
@ -692,7 +692,7 @@ static int dev_activate(struct fp_img_dev *idev, enum fp_imgdev_state state)
vdev->ssm_active = 1;
struct fpi_ssm *ssm = fpi_ssm_new(idev->dev, activate_ssm, SSM_STATES);
ssm->priv = idev;
fpi_ssm_set_user_data(ssm, idev);
fpi_ssm_start(ssm, dev_activate_callback);
return 0;
}
@ -716,7 +716,7 @@ static void dev_deactivate(struct fp_img_dev *idev)
static void dev_open_callback(struct fpi_ssm *ssm)
{
/* Notify open complete */
fpi_imgdev_open_complete((struct fp_img_dev *)ssm->priv, 0);
fpi_imgdev_open_complete(fpi_ssm_get_user_data(ssm), 0);
fpi_ssm_free(ssm);
}
@ -737,7 +737,7 @@ static int dev_open(struct fp_img_dev *idev, unsigned long driver_data)
/* Clearing previous device state */
struct fpi_ssm *ssm = fpi_ssm_new(idev->dev, activate_ssm, SSM_STATES);
ssm->priv = idev;
fpi_ssm_set_user_data(ssm, idev);
fpi_ssm_start(ssm, dev_open_callback);
return 0;
}

View file

@ -200,7 +200,7 @@ static int result_code(struct fp_img_dev *dev, int result)
static void async_send_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
/* Cleanup transfer */
@ -244,7 +244,7 @@ out:
/* Submit asynchronous send */
static void async_send(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
int r;
@ -284,7 +284,7 @@ static void async_send(struct fpi_ssm *ssm)
static void async_recv_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
/* Cleanup transfer */
@ -331,7 +331,7 @@ out:
/* Submit asynchronous recv */
static void async_recv(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
int r;
@ -368,7 +368,7 @@ static void async_load(struct fpi_ssm *ssm);
static void async_load_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
/* Cleanup transfer */
@ -432,7 +432,7 @@ out:
/* Submit asynchronous load */
static void async_load(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
unsigned char *buffer;
int r;
@ -471,7 +471,7 @@ static void async_load(struct fpi_ssm *ssm)
static void async_sleep_cb(void *data)
{
struct fpi_ssm *ssm = data;
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
/* Cleanup timeout */
@ -483,7 +483,7 @@ static void async_sleep_cb(void *data)
/* Submit asynchronous sleep */
static void async_sleep(unsigned int msec, struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
/* Add timeout */
@ -509,7 +509,7 @@ enum
/* Exec swap sequential state machine */
static void m_swap_state(struct fpi_ssm *ssm)
{
switch (ssm->cur_state)
switch (fpi_ssm_get_cur_state(ssm))
{
case M_SWAP_SEND:
/* Send data */
@ -526,7 +526,7 @@ 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)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct fpi_ssm *subsm;
@ -537,7 +537,7 @@ static void m_swap(struct fpi_ssm *ssm, unsigned char *data, size_t length)
/* Start swap ssm */
subsm = fpi_ssm_new(dev->dev, m_swap_state, M_SWAP_NUM_STATES);
subsm->priv = dev;
fpi_ssm_set_user_data(subsm, dev);
fpi_ssm_start_subsm(ssm, subsm);
}
@ -625,7 +625,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)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
G_DEBUG_HERE();
@ -756,7 +756,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)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct fp_img *img;
@ -914,7 +914,7 @@ enum
/* Exec loop sequential state machine */
static void m_loop_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
/* Check action state */
@ -925,7 +925,7 @@ static void m_loop_state(struct fpi_ssm *ssm)
return;
}
switch (ssm->cur_state)
switch (fpi_ssm_get_cur_state(ssm))
{
case M_LOOP_0_GET_PRINT:
/* Send get print command to the reader */
@ -1178,7 +1178,7 @@ enum
/* Exec init sequential state machine */
static void m_init_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
/* Check action state */
@ -1189,7 +1189,7 @@ static void m_init_state(struct fpi_ssm *ssm)
return;
}
switch (ssm->cur_state)
switch (fpi_ssm_get_cur_state(ssm))
{
case M_INIT_0_RECV_DIRTY:
/* Recv eventualy dirty data */
@ -1419,18 +1419,18 @@ static void m_init_state(struct fpi_ssm *ssm)
/* Complete init sequential state machine */
static void m_init_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs101_dev *vdev = dev->priv;
struct fpi_ssm *ssm_loop;
if (!ssm->error && vdev->active)
if (!fpi_ssm_get_error(ssm) && vdev->active)
{
/* Notify activate complete */
fpi_imgdev_activate_complete(dev, 0);
/* Start loop ssm */
ssm_loop = fpi_ssm_new(dev->dev, m_loop_state, M_LOOP_NUM_STATES);
ssm_loop->priv = dev;
fpi_ssm_set_user_data(ssm_loop, dev);
fpi_ssm_start(ssm_loop, m_loop_complete);
}
@ -1465,7 +1465,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
/* Start init ssm */
ssm = fpi_ssm_new(dev->dev, m_init_state, M_INIT_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, m_init_complete);
return 0;

View file

@ -37,7 +37,7 @@ static void async_sleep_cb(void *data)
/* Submit asynchronous sleep */
static void async_sleep(unsigned int msec, struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fpi_timeout *timeout;
/* Add timeout */
@ -53,7 +53,7 @@ static void async_sleep(unsigned int msec, struct fpi_ssm *ssm)
static int submit_image(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
vfs301_dev_t *vdev = dev->priv;
int height;
struct fp_img *img;
@ -105,10 +105,10 @@ enum
/* Exec loop sequential state machine */
static void m_loop_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
vfs301_dev_t *vdev = dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case M_REQUEST_PRINT:
vfs301_proto_request_fingerprint(dev->udev, vdev);
fpi_ssm_next_state(ssm);
@ -170,10 +170,10 @@ static void m_loop_complete(struct fpi_ssm *ssm)
/* Exec init sequential state machine */
static void m_init_state(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
vfs301_dev_t *vdev = dev->priv;
g_assert(ssm->cur_state == 0);
g_assert(fpi_ssm_get_cur_state(ssm) == 0);
vfs301_proto_init(dev->udev, vdev);
@ -183,16 +183,16 @@ static void m_init_state(struct fpi_ssm *ssm)
/* Complete init sequential state machine */
static void m_init_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fpi_ssm *ssm_loop;
if (!ssm->error) {
if (!fpi_ssm_get_error(ssm)) {
/* Notify activate complete */
fpi_imgdev_activate_complete(dev, 0);
/* Start loop ssm */
ssm_loop = fpi_ssm_new(dev->dev, m_loop_state, M_LOOP_NUM_STATES);
ssm_loop->priv = dev;
fpi_ssm_set_user_data(ssm_loop, dev);
fpi_ssm_start(ssm_loop, m_loop_complete);
}
@ -207,7 +207,7 @@ static int dev_activate(struct fp_img_dev *dev, enum fp_imgdev_state state)
/* Start init ssm */
ssm = fpi_ssm_new(dev->dev, m_init_state, 1);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, m_init_complete);
return 0;

View file

@ -76,17 +76,17 @@ 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;
struct usbexchange_data *data = (struct usbexchange_data *)ssm->priv;
struct usbexchange_data *data = fpi_ssm_get_user_data(ssm);
struct usb_action *action;
if (ssm->cur_state >= data->stepcount) {
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);
goto out;
}
action = &data->actions[ssm->cur_state];
action = &data->actions[fpi_ssm_get_cur_state(ssm)];
if (action->type != ACTION_SEND) {
fp_err("Radiation detected!");
fpi_imgdev_session_error(data->device, -EINVAL);
@ -120,7 +120,7 @@ out:
static void async_recv_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct usbexchange_data *data = (struct usbexchange_data *)ssm->priv;
struct usbexchange_data *data = fpi_ssm_get_user_data(ssm);
struct usb_action *action;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
@ -131,14 +131,14 @@ static void async_recv_cb(struct libusb_transfer *transfer)
goto out;
}
if (ssm->cur_state >= data->stepcount) {
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);
goto out;
}
action = &data->actions[ssm->cur_state];
action = &data->actions[fpi_ssm_get_cur_state(ssm)];
if (action->type != ACTION_RECEIVE) {
fp_err("Radiation detected!");
fpi_imgdev_session_error(data->device, -EINVAL);
@ -173,16 +173,16 @@ out:
static void usbexchange_loop(struct fpi_ssm *ssm)
{
struct usbexchange_data *data = (struct usbexchange_data *)ssm->priv;
if (ssm->cur_state >= data->stepcount) {
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",
ssm->cur_state, data->stepcount);
fpi_ssm_get_cur_state(ssm), data->stepcount);
fpi_imgdev_session_error(data->device, -EINVAL);
fpi_ssm_mark_aborted(ssm, -EINVAL);
return;
}
struct usb_action *action = &data->actions[ssm->cur_state];
struct usb_action *action = &data->actions[fpi_ssm_get_cur_state(ssm)];
struct libusb_transfer *transfer;
int ret = -EINVAL;
@ -239,7 +239,7 @@ static void usb_exchange_async(struct fpi_ssm *ssm,
struct fpi_ssm *subsm = fpi_ssm_new(data->device->dev,
usbexchange_loop,
data->stepcount);
subsm->priv = data;
fpi_ssm_set_user_data(subsm, data);
fpi_ssm_start_subsm(ssm, subsm);
}
@ -397,7 +397,7 @@ static int process_chunk(struct vfs5011_data *data, int transferred)
void submit_image(struct fpi_ssm *ssm, struct vfs5011_data *data)
{
struct fp_img_dev *dev = (struct fp_img_dev *)ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img *img;
data->rows = g_slist_reverse(data->rows);
@ -415,7 +415,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;
struct fp_img_dev *dev = (struct fp_img_dev *)ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) ||
@ -659,12 +659,12 @@ static void activate_loop(struct fpi_ssm *ssm)
{
enum {READ_TIMEOUT = 0};
struct fp_img_dev *dev = (struct fp_img_dev *)ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
int r;
struct fpi_timeout *timeout;
fp_dbg("main_loop: state %d", ssm->cur_state);
fp_dbg("main_loop: state %d", fpi_ssm_get_cur_state(ssm));
if (data->deactivating) {
fp_dbg("deactivating, marking completed");
@ -672,7 +672,7 @@ static void activate_loop(struct fpi_ssm *ssm)
return;
}
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case DEV_ACTIVATE_REQUEST_FPRINT:
data->init_sequence.stepcount =
array_n_elements(vfs5011_initiate_capture);
@ -732,9 +732,9 @@ static void activate_loop(struct fpi_ssm *ssm)
static void activate_loop_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = (struct fp_img_dev *)ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
int r = ssm->error;
int r = fpi_ssm_get_error(ssm);
fp_dbg("finishing");
if (data->init_sequence.receive_buf != NULL)
@ -760,10 +760,10 @@ static void activate_loop_complete(struct fpi_ssm *ssm)
static void open_loop(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = (struct fp_img_dev *)ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
switch (ssm->cur_state) {
switch (fpi_ssm_get_cur_state(ssm)) {
case DEV_OPEN_START:
data->init_sequence.stepcount =
array_n_elements(vfs5011_initialization);
@ -779,7 +779,7 @@ static void open_loop(struct fpi_ssm *ssm)
static void open_loop_complete(struct fpi_ssm *ssm)
{
struct fp_img_dev *dev = (struct fp_img_dev *)ssm->priv;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct vfs5011_data *data = (struct vfs5011_data *)dev->priv;
g_free(data->init_sequence.receive_buf);
@ -814,7 +814,7 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data)
struct fpi_ssm *ssm;
ssm = fpi_ssm_new(dev->dev, open_loop, DEV_OPEN_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fpi_ssm_start(ssm, open_loop_complete);
return 0;
@ -840,7 +840,7 @@ static void start_scan(struct fp_img_dev *dev)
data->loop_running = TRUE;
fp_dbg("creating ssm");
ssm = fpi_ssm_new(dev->dev, activate_loop, DEV_ACTIVATE_NUM_STATES);
ssm->priv = dev;
fpi_ssm_set_user_data(ssm, dev);
fp_dbg("starting ssm");
fpi_ssm_start(ssm, activate_loop_complete);
fp_dbg("ssm done, getting out");

View file

@ -354,18 +354,6 @@ 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,
@ -380,6 +368,12 @@ 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);

View file

@ -83,6 +83,25 @@ struct fpi_ssm *fpi_ssm_new(struct fp_dev *dev, ssm_handler_fn handler,
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)
{
@ -169,3 +188,12 @@ void fpi_ssm_jump_to_state(struct fpi_ssm *machine, int 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;
}