Commit 9cc859a3 authored by Bastien Nocera's avatar Bastien Nocera

drivers: Diminish fpi_ssm_get_user_data() usage

Can't remove it yet, as libusb transfers and timeouts don't pass the
fp_dev or fp_img_dev separately.
parent 7dfc8f33
......@@ -643,7 +643,7 @@ out:
static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
int r;
......@@ -690,7 +690,7 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
static void capture_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct aes1610_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
G_DEBUG_HERE();
......@@ -737,7 +737,7 @@ enum activate_states {
static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
/* activation on aes1610 seems much more straightforward compared to aes2501 */
/* verify theres anything missing here */
......@@ -752,7 +752,7 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
/* jump to finger detection */
static void activate_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
fp_dbg("status %d", fpi_ssm_get_error(ssm));
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
......
......@@ -521,7 +521,7 @@ out:
static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct aes2501_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
int r;
......@@ -572,7 +572,7 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
static void capture_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct aes2501_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
G_DEBUG_HERE();
......@@ -737,7 +737,7 @@ static void activate_init3_cb(struct fp_img_dev *dev, int result,
static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
/* 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
......@@ -791,7 +791,7 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
static void activate_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
fp_dbg("status %d", fpi_ssm_get_error(ssm));
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
......
......@@ -200,10 +200,9 @@ enum capture_states {
};
/* Returns number of processed bytes */
static int process_strip_data(fpi_ssm *ssm, unsigned char *data)
static int process_strip_data(fpi_ssm *ssm, struct fp_img_dev *dev, unsigned char *data)
{
unsigned char *stripdata;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aes2550_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
struct fpi_frame *stripe;
int len;
......@@ -290,7 +289,7 @@ static void capture_read_data_cb(struct libusb_transfer *transfer)
switch (transfer->actual_length) {
case AES2550_STRIP_SIZE:
r = process_strip_data(ssm, data);
r = process_strip_data(ssm, dev, data);
if (r < 0) {
fp_dbg("Processing strip data failed: %d", r);
fpi_ssm_mark_failed(ssm, -EPROTO);
......@@ -325,7 +324,7 @@ out:
static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
int r;
switch (fpi_ssm_get_cur_state(ssm)) {
......@@ -388,7 +387,7 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
static void capture_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct aes2550_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
fp_dbg("Capture completed");
......@@ -484,7 +483,7 @@ static void calibrate_read_data_cb(struct libusb_transfer *transfer)
static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
int r;
switch (fpi_ssm_get_cur_state(ssm)) {
......@@ -569,7 +568,7 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
static void activate_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
fp_dbg("status %d", fpi_ssm_get_error(ssm));
fpi_imgdev_activate_complete(dev, fpi_ssm_get_error(ssm));
......
......@@ -37,10 +37,15 @@ static void complete_deactivation(struct fp_img_dev *dev);
#define min(a, b) (((a) < (b)) ? (a) : (b))
static void aesX660_send_cmd_timeout(fpi_ssm *ssm, const unsigned char *cmd,
size_t cmd_len, libusb_transfer_cb_fn callback, int timeout)
static void
aesX660_send_cmd_timeout(fpi_ssm *ssm,
struct fp_dev *_dev,
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);
struct fp_img_dev *dev = FP_IMG_DEV(_dev);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
int r;
......@@ -60,16 +65,23 @@ static void aesX660_send_cmd_timeout(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)
static void
aesX660_send_cmd(fpi_ssm *ssm,
struct fp_dev *dev,
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);
return aesX660_send_cmd_timeout(ssm, dev, cmd, cmd_len, callback, BULK_TIMEOUT);
}
static void aesX660_read_response(fpi_ssm *ssm, size_t buf_len,
libusb_transfer_cb_fn callback)
static void
aesX660_read_response(fpi_ssm *ssm,
struct fp_dev *_dev,
size_t buf_len,
libusb_transfer_cb_fn callback)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = FP_IMG_DEV(_dev);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
......@@ -197,7 +209,7 @@ static void finger_det_set_idle_cmd_cb(struct libusb_transfer *transfer)
static void finger_det_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct aesX660_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
int err = fpi_ssm_get_error(ssm);
......@@ -215,23 +227,23 @@ static void finger_det_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user
}
}
static void finger_det_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
static void finger_det_run_state(fpi_ssm *ssm, struct fp_dev *dev, void *user_data)
{
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(ssm, dev, led_blink_cmd, sizeof(led_blink_cmd),
aesX660_send_cmd_cb);
break;
case FINGER_DET_SEND_FD_CMD:
aesX660_send_cmd_timeout(ssm, wait_for_finger_cmd, sizeof(wait_for_finger_cmd),
aesX660_send_cmd_timeout(ssm, dev, wait_for_finger_cmd, sizeof(wait_for_finger_cmd),
aesX660_send_cmd_cb, 0);
break;
case FINGER_DET_READ_FD_DATA:
/* Should return 4 byte of response */
aesX660_read_response(ssm, 4, finger_det_read_fd_data_cb);
aesX660_read_response(ssm, dev, 4, finger_det_read_fd_data_cb);
break;
case FINGER_DET_SET_IDLE:
aesX660_send_cmd(ssm, set_idle_cmd, sizeof(set_idle_cmd),
aesX660_send_cmd(ssm, dev, set_idle_cmd, sizeof(set_idle_cmd),
finger_det_set_idle_cmd_cb);
break;
}
......@@ -262,11 +274,10 @@ enum capture_states {
};
/* Returns number of processed bytes */
static int process_stripe_data(fpi_ssm *ssm, unsigned char *data)
static int process_stripe_data(fpi_ssm *ssm, struct fp_img_dev *dev, unsigned char *data)
{
struct fpi_frame *stripe;
unsigned char *stripdata;
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct aesX660_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
stripe = g_malloc(aesdev->assembling_ctx->frame_width * FRAME_HEIGHT / 2 + sizeof(struct fpi_frame)); /* 4 bpp */
......@@ -351,7 +362,7 @@ static void capture_read_stripe_data_cb(struct libusb_transfer *transfer)
aesdev->buffer_max);
continue;
} else {
finger_missing |= process_stripe_data(ssm, aesdev->buffer);
finger_missing |= process_stripe_data(ssm, dev, aesdev->buffer);
aesdev->buffer_max = AESX660_HEADER_SIZE;
aesdev->buffer_size = 0;
}
......@@ -372,28 +383,28 @@ out:
static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct aesX660_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
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(ssm, _dev, led_solid_cmd, sizeof(led_solid_cmd),
aesX660_send_cmd_cb);
break;
case CAPTURE_SEND_CAPTURE_CMD:
aesdev->buffer_size = 0;
aesdev->buffer_max = AESX660_HEADER_SIZE;
aesX660_send_cmd(ssm, aesdev->start_imaging_cmd,
aesX660_send_cmd(ssm, _dev, aesdev->start_imaging_cmd,
aesdev->start_imaging_cmd_len,
aesX660_send_cmd_cb);
break;
case CAPTURE_READ_STRIPE_DATA:
aesX660_read_response(ssm, AESX660_BULK_TRANSFER_SIZE,
aesX660_read_response(ssm, _dev, AESX660_BULK_TRANSFER_SIZE,
capture_read_stripe_data_cb);
break;
case CAPTURE_SET_IDLE:
fp_dbg("Got %lu frames\n", aesdev->strips_len);
aesX660_send_cmd(ssm, set_idle_cmd, sizeof(set_idle_cmd),
aesX660_send_cmd(ssm, _dev, set_idle_cmd, sizeof(set_idle_cmd),
capture_set_idle_cmd_cb);
break;
}
......@@ -401,7 +412,7 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
static void capture_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct aesX660_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
int err = fpi_ssm_get_error(ssm);
......@@ -534,30 +545,30 @@ out:
static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct aesX660_dev *aesdev = FP_INSTANCE_DATA(FP_DEV(dev));
switch (fpi_ssm_get_cur_state(ssm)) {
case ACTIVATE_SET_IDLE:
aesdev->init_seq_idx = 0;
fp_dbg("Activate: set idle\n");
aesX660_send_cmd(ssm, set_idle_cmd, sizeof(set_idle_cmd),
aesX660_send_cmd(ssm, _dev, set_idle_cmd, sizeof(set_idle_cmd),
aesX660_send_cmd_cb);
break;
case ACTIVATE_SEND_READ_ID_CMD:
fp_dbg("Activate: read ID\n");
aesX660_send_cmd(ssm, read_id_cmd, sizeof(read_id_cmd),
aesX660_send_cmd(ssm, _dev, read_id_cmd, sizeof(read_id_cmd),
aesX660_send_cmd_cb);
break;
case ACTIVATE_READ_ID:
/* Should return 8-byte response */
aesX660_read_response(ssm, 8, activate_read_id_cb);
aesX660_read_response(ssm, _dev, 8, activate_read_id_cb);
break;
case ACTIVATE_SEND_INIT_CMD:
fp_dbg("Activate: send init seq #%d cmd #%d\n",
aesdev->init_seq_idx,
aesdev->init_cmd_idx);
aesX660_send_cmd(ssm,
aesX660_send_cmd(ssm, _dev,
aesdev->init_seq[aesdev->init_cmd_idx].cmd,
aesdev->init_seq[aesdev->init_cmd_idx].len,
aesX660_send_cmd_cb);
......@@ -565,22 +576,22 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
case ACTIVATE_READ_INIT_RESPONSE:
fp_dbg("Activate: read init response\n");
/* Should return 4-byte response */
aesX660_read_response(ssm, 4, activate_read_init_cb);
aesX660_read_response(ssm, _dev, 4, activate_read_init_cb);
break;
case ACTIVATE_SEND_CALIBRATE_CMD:
aesX660_send_cmd(ssm, calibrate_cmd, sizeof(calibrate_cmd),
aesX660_send_cmd(ssm, _dev, calibrate_cmd, sizeof(calibrate_cmd),
aesX660_send_cmd_cb);
break;
case ACTIVATE_READ_CALIBRATE_DATA:
/* Should return 4-byte response */
aesX660_read_response(ssm, 4, aesX660_read_calibrate_data_cb);
aesX660_read_response(ssm, _dev, 4, aesX660_read_calibrate_data_cb);
break;
}
}
static void activate_sm_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
int err = fpi_ssm_get_error(ssm);
fp_dbg("status %d", err);
fpi_imgdev_activate_complete(dev, err);
......
......@@ -343,7 +343,7 @@ static void elan_cmd_cb(struct libusb_transfer *transfer)
} else {
/* just finished sending */
G_DEBUG_HERE();
elan_cmd_read(ssm);
elan_cmd_read(ssm, dev);
}
break;
case LIBUSB_TRANSFER_CANCELLED:
......@@ -362,9 +362,8 @@ static void elan_cmd_cb(struct libusb_transfer *transfer)
}
}
static void elan_cmd_read(fpi_ssm *ssm)
static void elan_cmd_read(fpi_ssm *ssm, struct fp_img_dev *dev)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = FP_INSTANCE_DATA(FP_DEV(dev));
int response_len = elandev->cmd->response_len;
......@@ -401,10 +400,12 @@ static void elan_cmd_read(fpi_ssm *ssm)
fpi_ssm_mark_failed(ssm, r);
}
static void elan_run_cmd(fpi_ssm *ssm, const struct elan_cmd *cmd,
int cmd_timeout)
static void
elan_run_cmd(fpi_ssm *ssm,
struct fp_img_dev *dev,
const struct elan_cmd *cmd,
int cmd_timeout)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct elan_dev *elandev = FP_INSTANCE_DATA(FP_DEV(dev));
dbg_buf(cmd->cmd, 2);
......@@ -440,20 +441,20 @@ enum stop_capture_states {
STOP_CAPTURE_NUM_STATES,
};
static void stop_capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
static void stop_capture_run_state(fpi_ssm *ssm, struct fp_dev *dev, void *user_data)
{
G_DEBUG_HERE();
switch (fpi_ssm_get_cur_state(ssm)) {
case STOP_CAPTURE:
elan_run_cmd(ssm, &stop_cmd, ELAN_CMD_TIMEOUT);
elan_run_cmd(ssm, FP_IMG_DEV(dev), &stop_cmd, ELAN_CMD_TIMEOUT);
break;
}
}
static void stop_capture_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct elan_dev *elandev = FP_INSTANCE_DATA(FP_DEV(dev));
int error = fpi_ssm_get_error(ssm);
......@@ -501,16 +502,16 @@ enum capture_states {
static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct elan_dev *elandev = FP_INSTANCE_DATA(FP_DEV(dev));
int r;
switch (fpi_ssm_get_cur_state(ssm)) {
case CAPTURE_LED_ON:
elan_run_cmd(ssm, &led_on_cmd, ELAN_CMD_TIMEOUT);
elan_run_cmd(ssm, dev, &led_on_cmd, ELAN_CMD_TIMEOUT);
break;
case CAPTURE_WAIT_FINGER:
elan_run_cmd(ssm, &pre_scan_cmd, -1);
elan_run_cmd(ssm, dev, &pre_scan_cmd, -1);
break;
case CAPTURE_READ_DATA:
/* 0x55 - finger present
......@@ -518,7 +519,7 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
if (elandev->last_read && elandev->last_read[0] == 0x55) {
if (elandev->dev_state == IMGDEV_STATE_AWAIT_FINGER_ON)
fpi_imgdev_report_finger_status(dev, TRUE);
elan_run_cmd(ssm, &get_image_cmd, ELAN_CMD_TIMEOUT);
elan_run_cmd(ssm, dev, &get_image_cmd, ELAN_CMD_TIMEOUT);
} else
fpi_ssm_mark_failed(ssm, -EBADMSG);
break;
......@@ -539,7 +540,7 @@ static void capture_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
static void capture_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct elan_dev *elandev = FP_INSTANCE_DATA(FP_DEV(dev));
G_DEBUG_HERE();
......@@ -624,14 +625,14 @@ enum calibrate_states {
static void calibrate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct elan_dev *elandev = FP_INSTANCE_DATA(FP_DEV(dev));
G_DEBUG_HERE();
switch (fpi_ssm_get_cur_state(ssm)) {
case CALIBRATE_GET_BACKGROUND:
elan_run_cmd(ssm, &get_image_cmd, ELAN_CMD_TIMEOUT);
elan_run_cmd(ssm, dev, &get_image_cmd, ELAN_CMD_TIMEOUT);
break;
case CALIBRATE_SAVE_BACKGROUND:
elan_save_background(elandev);
......@@ -642,7 +643,7 @@ static void calibrate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_da
fpi_ssm_next_state(ssm);
break;
case CALIBRATE_GET_MEAN:
elan_run_cmd(ssm, &get_calib_mean_cmd, ELAN_CMD_TIMEOUT);
elan_run_cmd(ssm, dev, &get_calib_mean_cmd, ELAN_CMD_TIMEOUT);
break;
case CALIBRATE_CHECK_NEEDED:
if (elan_need_calibration(elandev)) {
......@@ -654,7 +655,7 @@ static void calibrate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_da
case CALIBRATE_GET_STATUS:
elandev->calib_atts_left -= 1;
if (elandev->calib_atts_left)
elan_run_cmd(ssm, &get_calib_status_cmd,
elan_run_cmd(ssm, dev, &get_calib_status_cmd,
ELAN_CMD_TIMEOUT);
else {
fp_dbg("calibration failed");
......@@ -689,7 +690,7 @@ static void calibrate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_da
static void calibrate_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
G_DEBUG_HERE();
......@@ -725,14 +726,14 @@ enum activate_states {
static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct elan_dev *elandev = FP_INSTANCE_DATA(FP_DEV(dev));
G_DEBUG_HERE();
switch (fpi_ssm_get_cur_state(ssm)) {
case ACTIVATE_GET_FW_VER:
elan_run_cmd(ssm, &get_fw_ver_cmd, ELAN_CMD_TIMEOUT);
elan_run_cmd(ssm, dev, &get_fw_ver_cmd, ELAN_CMD_TIMEOUT);
break;
case ACTIVATE_SET_FW_VER:
elandev->fw_ver =
......@@ -741,7 +742,7 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
fpi_ssm_next_state(ssm);
break;
case ACTIVATE_GET_SENSOR_DIM:
elan_run_cmd(ssm, &get_sensor_dim_cmd, ELAN_CMD_TIMEOUT);
elan_run_cmd(ssm, dev, &get_sensor_dim_cmd, ELAN_CMD_TIMEOUT);
break;
case ACTIVATE_SET_SENSOR_DIM:
/* see elan_save_frame for details */
......@@ -762,14 +763,14 @@ static void activate_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
break;
case ACTIVATE_CMD_1:
/* TODO: find out what this does, if we need it */
elan_run_cmd(ssm, &activate_cmd_1, ELAN_CMD_TIMEOUT);
elan_run_cmd(ssm, dev, &activate_cmd_1, ELAN_CMD_TIMEOUT);
break;
}
}
static void activate_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
G_DEBUG_HERE();
......
......@@ -211,7 +211,7 @@ static const struct usb_id elan_id_table[] = {
};
static void elan_cmd_done(fpi_ssm *ssm);
static void elan_cmd_read(fpi_ssm *ssm);
static void elan_cmd_read(fpi_ssm *ssm, struct fp_img_dev *dev);
static void elan_calibrate(struct fp_img_dev *dev);
static void elan_capture(struct fp_img_dev *dev);
......
......@@ -701,7 +701,7 @@ static void async_tx_cb(struct libusb_transfer *transfer)
static void m_exit_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
switch (fpi_ssm_get_cur_state(ssm)) {
......@@ -729,7 +729,7 @@ err:
static void m_exit_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
if (fpi_ssm_get_error(ssm)) {
fp_err("Error switching the device to idle state");
......@@ -750,7 +750,7 @@ static void m_exit_start(struct fp_img_dev *idev)
static void m_capture_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
if (dev->is_active == FALSE) {
......@@ -831,7 +831,7 @@ err:
static void m_capture_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
if (fpi_ssm_get_error(ssm)) {
......@@ -853,7 +853,7 @@ static void m_capture_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
static void m_finger_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
if (dev->is_active == FALSE) {
......@@ -949,7 +949,7 @@ err:
static void m_finger_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
if (!fpi_ssm_get_error(ssm)) {
......@@ -981,7 +981,7 @@ static void m_start_fingerdetect(struct fp_img_dev *idev)
*/
static void m_tunevrb_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
float hist[5];
......@@ -1133,7 +1133,7 @@ err:
static void m_tunevrb_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
fpi_imgdev_activate_complete(idev, fpi_ssm_get_error(ssm) != 0);
if (!fpi_ssm_get_error(ssm)) {
......@@ -1155,7 +1155,7 @@ static void m_tunevrb_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_dat
*/
static void m_tunedc_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
if (dev->is_active == FALSE) {
......@@ -1258,7 +1258,7 @@ err:
static void m_tunedc_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
if (!fpi_ssm_get_error(ssm)) {
fpi_ssm *ssm_tune;
ssm_tune = fpi_ssm_new(FP_DEV(idev), m_tunevrb_state,
......@@ -1276,7 +1276,7 @@ static void m_tunedc_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data
static void m_init_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
struct etes603_dev *dev = FP_INSTANCE_DATA(FP_DEV(idev));
if (dev->is_active == FALSE) {
......@@ -1377,7 +1377,7 @@ err:
static void m_init_complete(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *idev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *idev = user_data;
if (!fpi_ssm_get_error(ssm)) {
fpi_ssm *ssm_tune;
ssm_tune = fpi_ssm_new(FP_DEV(idev), m_tunedc_state,
......
......@@ -615,9 +615,12 @@ static void sm_write_reg_cb(struct libusb_transfer *transfer)
}
static void sm_write_reg(fpi_ssm *ssm, uint8_t reg, uint8_t value)
static void
sm_write_reg(fpi_ssm *ssm,
struct fp_img_dev *dev,
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);
unsigned char *data;
int r;
......@@ -663,9 +666,11 @@ static void sm_read_reg_cb(struct libusb_transfer *transfer)
g_free(transfer->buffer);
}
static void sm_read_reg(fpi_ssm *ssm, uint8_t reg)
static void
sm_read_reg(fpi_ssm *ssm,
struct fp_img_dev *dev,
uint8_t reg)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
......@@ -714,9 +719,10 @@ static void sm_await_intr_cb(struct libusb_transfer *transfer)
fpi_ssm_next_state(ssm);
}
static void sm_await_intr(fpi_ssm *ssm)
static void
sm_await_intr(fpi_ssm *ssm,
struct fp_img_dev *dev)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
unsigned char *data;
int r;
......@@ -766,7 +772,7 @@ enum awfsm_1000_states {
static void awfsm_2016_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_data)
{
struct fp_img_dev *dev = fpi_ssm_get_user_data(ssm);
struct fp_img_dev *dev = user_data;
struct sonly_dev *sdev = FP_INSTANCE_DATA(FP_DEV(dev));
switch (fpi_ssm_get_cur_state(ssm)) {
......@@ -774,36 +780,36 @@ static void awfsm_2016_run_state(fpi_ssm *ssm, struct fp_dev *_dev, void *user_d
sm_write_regs(ssm, _dev, awfsm_2016_writev_1, G_N_ELEMENTS(awfsm_2016_writev_1));
break;
case AWFSM_2016_READ_01:
sm_read_reg(ssm, 0x01);
sm_read_reg(ssm, dev, 0x01);
break;
case AWFSM_2016_WRITE_01:
if (sdev->read_reg_result != 0xc6)
sm_write_reg(ssm, 0x01, 0x46);
sm_write_reg(ssm, dev, 0x01, 0x46);
else
sm_write_reg(ssm, 0x01, 0xc6);
sm_write_reg(ssm, dev, 0x01, 0xc6);
break;
case AWFSM_2016_WRITEV_2:
sm_write_regs(ssm, _dev, awfsm_2016_writev_2, G_N_ELEMENTS(awfsm_2016_writev_2));
break;
case AWFSM_2016_READ_13:
sm_read_reg(ssm, 0x13);
sm_read_reg(ssm, dev, 0x13);
break;
case AWFSM_2016_WRITE_13:
if (sdev->read_reg_result != 0x45)
sm_write_reg(ssm, 0x13, 0x05);
sm_write_reg(ssm, dev, 0x13, 0x05);
else
sm_write_reg(ssm, 0x13, 0x45);
sm_write_reg(ssm, dev, 0x13, 0x45);
break;
case AWFSM_2016_WRITEV_3:
sm_write_regs(ssm, _dev, awfsm_2016_writev_3, G_N_ELEMENTS(awfsm_2016_writev_3));
break;
case AWFSM_2016_READ_07:
sm_read_reg(ssm, 0x07);
sm_read_reg(ssm, dev, 0x07);
break;
case AWFSM_2016_WRITE_07:
if (sdev->read_reg_result != 0x10 && sdev->read_reg_result != 0x90)
fp_warn("odd reg7 value %x", sdev->read_reg_result);
sm_write_reg(ssm, 0x07, sdev->read_reg_result);
sm_write_reg(ssm, dev, 0x07, sdev->read_reg_result);
break;
case AWFSM_2016_WRITEV_4:
sm_write_regs(ssm, _dev, awfsm_2016_writev_4, G_N_ELEMENTS(