Exemplo n.º 1
0
static void sm_exec_cmd(struct fpi_ssm *ssm, unsigned char cmd,
	unsigned char param)
{
	struct fp_img_dev *dev = ssm->priv;
	struct libusb_transfer *transfer = libusb_alloc_transfer(0);
	unsigned char *data;
	int r;
	
	if (!transfer) {
		fpi_ssm_mark_aborted(ssm, -ENOMEM);
		return;
	}

	fp_dbg("cmd %02x param %02x", cmd, param);
	data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE);
	libusb_fill_control_setup(data, CTRL_IN, cmd, param, 0, 0);
	libusb_fill_control_transfer(transfer, dev->udev, data, sm_exec_cmd_cb,
		ssm, CTRL_TIMEOUT);
	r = libusb_submit_transfer(transfer);
	if (r < 0) {
		g_free(data);
		libusb_free_transfer(transfer);
		fpi_ssm_mark_aborted(ssm, r);
	}
}
Exemplo n.º 2
0
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 libusb_transfer *transfer = libusb_alloc_transfer(0);
	unsigned char *data;
	int r;

	if (!transfer) {
		fpi_ssm_mark_aborted(ssm, -ENOMEM);
		return;
	}

	data = g_malloc(buf_len);
	libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN,
		data, buf_len,
		callback, ssm, BULK_TIMEOUT);

	r = libusb_submit_transfer(transfer);
	if (r < 0) {
		fp_dbg("Failed to submit rx transfer: %d\n", r);
		g_free(data);
		libusb_free_transfer(transfer);
		fpi_ssm_mark_aborted(ssm, r);
	}
}
Exemplo n.º 3
0
static void sm_write_reg(struct fpi_ssm *ssm, unsigned char reg,
	unsigned char value)
{
	struct fp_img_dev *dev = ssm->priv;
	struct libusb_transfer *transfer = libusb_alloc_transfer(0);
	unsigned char *data;
	int r;
	
	if (!transfer) {
		fpi_ssm_mark_aborted(ssm, -ENOMEM);
		return;
	}

	fp_dbg("set %02x=%02x", reg, value);
	data = g_malloc(LIBUSB_CONTROL_SETUP_SIZE);
	libusb_fill_control_setup(data, CTRL_OUT, reg, value, 0, 0);
	libusb_fill_control_transfer(transfer, dev->udev, data, sm_write_reg_cb,
		ssm, CTRL_TIMEOUT);
	r = libusb_submit_transfer(transfer);
	if (r < 0) {
		g_free(data);
		libusb_free_transfer(transfer);
		fpi_ssm_mark_aborted(ssm, r);
	}
}
Exemplo n.º 4
0
static void capture_read_data_cb(struct libusb_transfer *transfer)
{
	struct fpi_ssm *ssm = transfer->user_data;
	struct fp_img_dev *dev = ssm->priv;
	unsigned char *data = transfer->buffer;
	struct fp_img *img;

	if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
		fp_dbg("request is not completed, %d", transfer->status);
		fpi_ssm_mark_aborted(ssm, -EIO);
		goto out;
	} else if (transfer->length != transfer->actual_length) {
		fp_dbg("expected %d, sent %d bytes", transfer->length, transfer->actual_length);
		fpi_ssm_mark_aborted(ssm, -EPROTO);
		goto out;
	}

	img = fpi_img_new(IMAGE_SIZE);
	memcpy(img->data, data, IMAGE_SIZE);
	fpi_imgdev_image_captured(dev, img);
	fpi_imgdev_report_finger_status(dev, FALSE);
	fpi_ssm_mark_completed(ssm);
out:
	g_free(transfer->buffer);
	libusb_free_transfer(transfer);
}
Exemplo n.º 5
0
static void et_write_init_cb(struct libusb_transfer* transfer)
{
 struct init_data* adata=transfer->user_data;
 if(transfer->status!=LIBUSB_TRANSFER_COMPLETED)
 {
  fpi_ssm_mark_aborted(adata->ssm,-EIO);
 }
 else if(transfer->length!=transfer->actual_length)
 {
  fpi_ssm_mark_aborted(adata->ssm,-EPROTO);
 }
 else
 {
  switch(adata->init->stage)
  {
   case 3:
   case 5:
   case 7:
   case 11:
   case 13:
   case 15:
   case 17:
   case 36:
   case 40:
   case 42:
   case 44:
   case 46:
   case 48:
   case 50:
   if(!adata->init->rstage)
   {
    //fp_dbg("(%02d) ->: %s",adata->init->stage,print_cmd_buf());
    adata->init->rstage++;
    fpi_ssm_jump_to_state(adata->ssm,adata->init->ssm_state);
    goto _wicb;
   }
   else
   {
    adata->init->rstage=0;
    //fp_dbg("(%02d) ->: RETURN BUF %d",adata->init->stage,transfer->actual_length);
    goto _wicbn;
   }
   break;
  }
  //fp_dbg("(%02d) ->: %s",adata->init->stage,print_cmd_buf());
_wicbn:  
  fpi_ssm_next_state(adata->ssm);
 }
_wicb: 
 libusb_free_transfer(transfer);
}
Exemplo n.º 6
0
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 aesX660_dev *aesdev = dev->priv;
	unsigned char *data = transfer->buffer;

	if ((transfer->status != LIBUSB_TRANSFER_COMPLETED) ||
		(transfer->length != transfer->actual_length)) {
		fp_dbg("read_id cmd failed\n");
		fpi_ssm_mark_aborted(ssm, -EIO);
		goto out;
	}
	/* ID was read correctly */
	if (data[0] == 0x07) {
		fp_dbg("Sensor device id: %.2x%2x, bcdDevice: %.2x.%.2x, init status: %.2x\n",
			data[4], data[3], data[5], data[6], data[7]);
	} else {
		fp_dbg("Bogus read ID response: %.2x\n", data[AESX660_RESPONSE_TYPE_OFFSET]);
		fpi_ssm_mark_aborted(ssm, -EPROTO);
		goto out;
	}

	switch (aesdev->init_seq_idx) {
	case 0:
		aesdev->init_seq = aesdev->init_seqs[0];
		aesdev->init_seq_len = aesdev->init_seqs_len[0];
		aesdev->init_seq_idx = 1;
		aesdev->init_cmd_idx = 0;
		/* Do calibration only after 1st init sequence */
		fpi_ssm_jump_to_state(ssm, ACTIVATE_SEND_INIT_CMD);
		break;
	case 1:
		aesdev->init_seq = aesdev->init_seqs[1];
		aesdev->init_seq_len = aesdev->init_seqs_len[1];
		aesdev->init_seq_idx = 2;
		aesdev->init_cmd_idx = 0;
		fpi_ssm_next_state(ssm);
		break;
	default:
		fp_dbg("Failed to init device! init status: %.2x\n", data[7]);
		fpi_ssm_mark_aborted(ssm, -EPROTO);
		break;

	}

out:
	g_free(transfer->buffer);
	libusb_free_transfer(transfer);
}
Exemplo n.º 7
0
static void activate_run_state(struct fpi_ssm *ssm)
{
	struct fp_img_dev *dev = ssm->priv;
	struct upektc_dev *upekdev = dev->priv;
	int r;

	switch (ssm->cur_state) {
	case WRITE_INIT:
	{
		struct libusb_transfer *transfer = libusb_alloc_transfer(0);
		if (!transfer) {
			fpi_ssm_mark_aborted(ssm, -ENOMEM);
			return;
		}
		libusb_fill_bulk_transfer(transfer, dev->udev, upekdev->ep_out,
			(unsigned char*)upekdev->setup_commands[upekdev->init_idx].cmd,
			UPEKTC_CMD_LEN, write_init_cb, ssm, BULK_TIMEOUT);
		r = libusb_submit_transfer(transfer);
		if (r < 0) {
			libusb_free_transfer(transfer);
			fpi_ssm_mark_aborted(ssm, -ENOMEM);
		}
	}
	break;
	case READ_DATA:
	{
		struct libusb_transfer *transfer = libusb_alloc_transfer(0);
		unsigned char *data;

		if (!transfer) {
			fpi_ssm_mark_aborted(ssm, -ENOMEM);
			break;
		}

		data = g_malloc(upekdev->setup_commands[upekdev->init_idx].response_len);
		libusb_fill_bulk_transfer(transfer, dev->udev, upekdev->ep_in, data,
			upekdev->setup_commands[upekdev->init_idx].response_len,
			read_init_data_cb, ssm, BULK_TIMEOUT);

		r = libusb_submit_transfer(transfer);
		if (r < 0) {
			g_free(data);
			libusb_free_transfer(transfer);
			fpi_ssm_mark_aborted(ssm, r);
		}
	}
	break;
	}
}
Exemplo n.º 8
0
static void capture_run_state(struct fpi_ssm *ssm)
{
	struct fp_img_dev *dev = ssm->priv;
	struct upektc_dev *upekdev = dev->priv;
	int r;

	switch (ssm->cur_state) {
	case CAPTURE_WRITE_CMD:
	{
		struct libusb_transfer *transfer = libusb_alloc_transfer(0);
		if (!transfer) {
			fpi_ssm_mark_aborted(ssm, -ENOMEM);
			return;
		}
		libusb_fill_bulk_transfer(transfer, dev->udev, upekdev->ep_out,
			(unsigned char *)scan_cmd, UPEKTC_CMD_LEN,
			capture_cmd_cb, ssm, BULK_TIMEOUT);
		r = libusb_submit_transfer(transfer);
		if (r < 0) {
			libusb_free_transfer(transfer);
			fpi_ssm_mark_aborted(ssm, -ENOMEM);
		}
	}
	break;
	case CAPTURE_READ_DATA:
	{
		struct libusb_transfer *transfer = libusb_alloc_transfer(0);
		unsigned char *data;

		if (!transfer) {
			fpi_ssm_mark_aborted(ssm, -ENOMEM);
			break;
		}

		data = g_malloc(IMAGE_SIZE);
		libusb_fill_bulk_transfer(transfer, dev->udev, upekdev->ep_in, data, IMAGE_SIZE,
			capture_read_data_cb, ssm, BULK_TIMEOUT);

		r = libusb_submit_transfer(transfer);
		if (r < 0) {
			g_free(data);
			libusb_free_transfer(transfer);
			fpi_ssm_mark_aborted(ssm, r);
		}
	}
	break;
	};
}
Exemplo n.º 9
0
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 aesX660_dev *aesdev = dev->priv;

	if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
		(transfer->length == transfer->actual_length)) {
		struct fp_img *img;

		aesdev->strips = g_slist_reverse(aesdev->strips);
		img = fpi_assemble_frames(aesdev->assembling_ctx, aesdev->strips, aesdev->strips_len);
		img->flags |= aesdev->extra_img_flags;
		g_slist_foreach(aesdev->strips, (GFunc) g_free, NULL);
		g_slist_free(aesdev->strips);
		aesdev->strips = NULL;
		aesdev->strips_len = 0;
		fpi_imgdev_image_captured(dev, img);
		fpi_imgdev_report_finger_status(dev, FALSE);
		fpi_ssm_mark_completed(ssm);
	} else {
		fpi_ssm_mark_aborted(ssm, -EIO);
	}
	libusb_free_transfer(transfer);
}
Exemplo n.º 10
0
static void capture_cb(struct libusb_transfer *transfer)
{
	struct fpi_ssm *ssm = transfer->user_data;
	struct fp_img_dev *dev = ssm->priv;
	struct v5s_dev *vdev = dev->priv;

	if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
		fpi_ssm_mark_aborted(ssm, -EIO);
		goto out;
	}

	if (++vdev->capture_iteration == NR_REQS) {
		struct fp_img *img = vdev->capture_img;
		/* must clear this early, otherwise the call chain takes us into
		 * loopsm_complete where we would free it, when in fact we are
		 * supposed to be handing off this image */
		vdev->capture_img = NULL;

		fpi_imgdev_report_finger_status(dev, finger_is_present(img->data));
		fpi_imgdev_image_captured(dev, img);
		fpi_ssm_next_state(ssm);
	} else {
		capture_iterate(ssm);
	}

out:
	libusb_free_transfer(transfer);
}
Exemplo n.º 11
0
static void read_init_data_cb(struct libusb_transfer *transfer)
{
	struct fpi_ssm *ssm = transfer->user_data;

	if (transfer->status == LIBUSB_TRANSFER_COMPLETED)
		upektc_next_init_cmd(ssm);
	else
		fpi_ssm_mark_aborted(ssm, -EIO);
	g_free(transfer->buffer);
	libusb_free_transfer(transfer);
}
Exemplo n.º 12
0
static void capture_cmd_cb(struct libusb_transfer *transfer)
{
	struct fpi_ssm *ssm = transfer->user_data;

	if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
		(transfer->length == transfer->actual_length)) {
		fpi_ssm_next_state(ssm);
	} else {
		fpi_ssm_mark_aborted(ssm, -EIO);
	}
	libusb_free_transfer(transfer);
}
Exemplo n.º 13
0
static void sm_write_reg_cb(struct libusb_transfer *transfer)
{
	struct fpi_ssm *ssm = transfer->user_data;

	if (transfer->status != LIBUSB_TRANSFER_COMPLETED)
		fpi_ssm_mark_aborted(ssm, -EIO);
	else
		fpi_ssm_next_state(ssm);

	g_free(transfer->buffer);
	libusb_free_transfer(transfer);
}
Exemplo n.º 14
0
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 aesX660_dev *aesdev = dev->priv;
	unsigned char *data = transfer->buffer;

	aesdev->fd_data_transfer = NULL;

	if (transfer->status == LIBUSB_TRANSFER_CANCELLED) {
		fp_dbg("Cancelling transfer...\n");
		fpi_ssm_next_state(ssm);
		goto out;
	}

	if ((transfer->status != LIBUSB_TRANSFER_COMPLETED) ||
	   (transfer->length != transfer->actual_length)) {
		fp_dbg("Failed to read FD data\n");
		fpi_ssm_mark_aborted(ssm, -EIO);
		goto out;
	}

	if (data[AESX660_RESPONSE_TYPE_OFFSET] != AESX660_FINGER_DET_RESPONSE) {
		fp_dbg("Bogus FD response: %.2x\n", data[0]);
		fpi_ssm_mark_aborted(ssm, -EPROTO);
		goto out;
	}

	if (data[AESX660_FINGER_PRESENT_OFFSET] == AESX660_FINGER_PRESENT || aesdev->deactivating) {
		/* Finger present or we're deactivating... */
		fpi_ssm_next_state(ssm);
	} else {
		fp_dbg("Wait for finger returned %.2x as result\n",
			data[AESX660_FINGER_PRESENT_OFFSET]);
		fpi_ssm_jump_to_state(ssm, FINGER_DET_SEND_FD_CMD);
	}
out:
	g_free(data);
	libusb_free_transfer(transfer);
}
Exemplo n.º 15
0
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 aesX660_dev *aesdev = dev->priv;
	unsigned char *data = transfer->buffer;
	int finger_missing = 0;
	size_t copied, actual_len = transfer->actual_length;

	if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
		fpi_ssm_mark_aborted(ssm, -EIO);
		goto out;
	}

	fp_dbg("Got %d bytes of data", actual_len);
	do {
		copied = min(aesdev->buffer_max - aesdev->buffer_size, actual_len);
		memcpy(aesdev->buffer + aesdev->buffer_size,
			data,
			copied);
		actual_len -= copied;
		data += copied;
		aesdev->buffer_size += copied;
		fp_dbg("Copied %.4x bytes into internal buffer",
			copied);
		if (aesdev->buffer_size == aesdev->buffer_max) {
			if (aesdev->buffer_max == AESX660_HEADER_SIZE) {
				aesdev->buffer_max = aesdev->buffer[AESX660_RESPONSE_SIZE_LSB_OFFSET] +
					(aesdev->buffer[AESX660_RESPONSE_SIZE_MSB_OFFSET] << 8) + AESX660_HEADER_SIZE;
				fp_dbg("Got frame, type %.2x size %.4x",
					aesdev->buffer[AESX660_RESPONSE_TYPE_OFFSET],
					aesdev->buffer_max);
				continue;
			} else {
				finger_missing |= process_stripe_data(ssm, aesdev->buffer);
				aesdev->buffer_max = AESX660_HEADER_SIZE;
				aesdev->buffer_size = 0;
			}
		}
	} while (actual_len);

	fp_dbg("finger %s\n", finger_missing ? "missing" : "present");

	if (finger_missing) {
		fpi_ssm_next_state(ssm);
	} else {
		fpi_ssm_jump_to_state(ssm, CAPTURE_READ_STRIPE_DATA);
	}
out:
	g_free(transfer->buffer);
	libusb_free_transfer(transfer);
}
Exemplo n.º 16
0
static void et_write_enroll_cb(struct libusb_transfer* transfer)
{
 struct init_data* adata=transfer->user_data;
 
 if(transfer->status!=LIBUSB_TRANSFER_COMPLETED)
 {
  fpi_ssm_mark_aborted(adata->ssm,-EIO);
 }
 else if(transfer->length!=transfer->actual_length)
 {
  fpi_ssm_mark_aborted(adata->ssm,-EPROTO);
 }
 else
 {
  switch(adata->init->stage)
  {
   case 26:
   case 29:
   case 31:
   if(!adata->init->rstage)
   {
    adata->init->rstage++;
    fpi_ssm_jump_to_state(adata->ssm,adata->init->ssm_state);
    goto _out;
   }
   else
   {
    adata->init->rstage=0;
    goto _wedcbn;
   }
   break;
  }
  //fp_dbg("(%02d) ->: %s",adata->init->stage,print_cmd_buf());
_wedcbn:  
  fpi_ssm_next_state(adata->ssm);
 }
_out: 
 libusb_free_transfer(transfer);
}
Exemplo n.º 17
0
static void aesX660_read_calibrate_data_cb(struct libusb_transfer *transfer)
{
	struct fpi_ssm *ssm = transfer->user_data;
	unsigned char *data = transfer->buffer;

	if ((transfer->status != LIBUSB_TRANSFER_COMPLETED) ||
		(transfer->length != transfer->actual_length)) {
		fpi_ssm_mark_aborted(ssm, -EIO);
		goto out;
	}
	/* Calibrate response was read correctly? */
	if (data[AESX660_RESPONSE_TYPE_OFFSET] != AESX660_CALIBRATE_RESPONSE) {
		fp_dbg("Bogus calibrate response: %.2x\n", data[0]);
		fpi_ssm_mark_aborted(ssm, -EPROTO);
		goto out;
	}

	fpi_ssm_next_state(ssm);
out:
	g_free(transfer->buffer);
	libusb_free_transfer(transfer);
}
Exemplo n.º 18
0
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 libusb_transfer *transfer = libusb_alloc_transfer(0);
	int r;

	if (!transfer) {
		fpi_ssm_mark_aborted(ssm, -ENOMEM);
		return;
	}

	libusb_fill_bulk_transfer(transfer, dev->udev, EP_OUT,
		(unsigned char *)cmd, cmd_len,
		callback, ssm, timeout);
	r = libusb_submit_transfer(transfer);
	if (r < 0) {
		fp_dbg("failed to submit transfer\n");
		libusb_free_transfer(transfer);
		fpi_ssm_mark_aborted(ssm, -ENOMEM);
	}
}
Exemplo n.º 19
0
static void capture_iterate(struct fpi_ssm *ssm)
{
	struct fp_img_dev *dev = ssm->priv;
	struct v5s_dev *vdev = dev->priv;
	int iteration = vdev->capture_iteration;
	struct libusb_transfer *transfer = libusb_alloc_transfer(0);
	int r;

	if (!transfer) {
		fpi_ssm_mark_aborted(ssm, -ENOMEM);
		return;
	}

	libusb_fill_bulk_transfer(transfer, dev->udev, EP_IN,
		vdev->capture_img->data + (RQ_SIZE * iteration), RQ_SIZE,
		capture_cb, ssm, CTRL_TIMEOUT);
	transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK;
	r = libusb_submit_transfer(transfer);
	if (r < 0) {
		libusb_free_transfer(transfer);
		fpi_ssm_mark_aborted(ssm, r);
	}
}
Exemplo n.º 20
0
static void aesX660_send_cmd_cb(struct libusb_transfer *transfer)
{
	struct fpi_ssm *ssm = transfer->user_data;

	if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
		(transfer->length == transfer->actual_length)) {
		fpi_ssm_next_state(ssm);
	} else {
		fp_dbg("tx transfer status: %d, actual_len: %.4x\n",
			transfer->status, transfer->actual_length);
		fpi_ssm_mark_aborted(ssm, -EIO);
	}
	libusb_free_transfer(transfer);
}
Exemplo n.º 21
0
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 aesX660_dev *aesdev = dev->priv;
	unsigned char *data = transfer->buffer;

	fp_dbg("read_init_cb\n");

	if ((transfer->status != LIBUSB_TRANSFER_COMPLETED) ||
		(transfer->length != transfer->actual_length)) {
		fp_dbg("read_init transfer status: %d, actual_len: %d\n", transfer->status, transfer->actual_length);
		fpi_ssm_mark_aborted(ssm, -EIO);
		goto out;
	}
	/* ID was read correctly */
	if (data[0] != 0x42 || data[3] != 0x01) {
		fp_dbg("Bogus read init response: %.2x %.2x\n", data[0],
			data[3]);
		fpi_ssm_mark_aborted(ssm, -EPROTO);
		goto out;
	}
	aesdev->init_cmd_idx++;
	if (aesdev->init_cmd_idx == aesdev->init_seq_len) {
		if (aesdev->init_seq_idx < 2)
			fpi_ssm_jump_to_state(ssm, ACTIVATE_SEND_READ_ID_CMD);
		else
			fpi_ssm_mark_completed(ssm);
		goto out;
	}

	fpi_ssm_jump_to_state(ssm, ACTIVATE_SEND_INIT_CMD);
out:
	g_free(transfer->buffer);
	libusb_free_transfer(transfer);
}
Exemplo n.º 22
0
/* Submit asynchronous sleep */
static void async_sleep(unsigned int msec, struct fpi_ssm *ssm)
{
	struct fp_img_dev *dev = ssm->priv;
	struct fpi_timeout *timeout;

	/* Add timeout */
	timeout = fpi_timeout_add(msec, async_sleep_cb, ssm);

	if (timeout == NULL) {
		/* Failed to add timeout */
		fp_err("failed to add timeout");
		fpi_imgdev_session_error(dev, -ETIME);
		fpi_ssm_mark_aborted(ssm, -ETIME);
	}
}
Exemplo n.º 23
0
static void write_init_cb(struct libusb_transfer *transfer)
{
	struct fpi_ssm *ssm = transfer->user_data;
	struct fp_img_dev *dev = ssm->priv;
	struct upektc_dev *upekdev = dev->priv;

	if ((transfer->status == LIBUSB_TRANSFER_COMPLETED) &&
		(transfer->length == transfer->actual_length)) {
		if (upekdev->setup_commands[upekdev->init_idx].response_len)
			fpi_ssm_next_state(ssm);
		else
			upektc_next_init_cmd(ssm);
	} else {
		fpi_ssm_mark_aborted(ssm, -EIO);
	}
	libusb_free_transfer(transfer);
}
Exemplo n.º 24
0
static void activate_run_state(struct fpi_ssm *ssm)
{
	int r;
	struct fp_img_dev *dev = ssm->priv;

	/* Activation process of SS801U is not understandable at
	the moment. Simply repeats captured protocol.
	And, I don't know how to enter in initial state without device reset
	 */
	switch (ssm->cur_state)
	{
	 case 0:
	 //Reset device
	 libusb_release_interface(dev->udev,0);
	 r=libusb_reset_device(dev->udev);
	 if(r<0)
	 {
_eop:
	  fpi_ssm_mark_aborted(ssm,r);
	  return;
	 }
	 r=libusb_claim_interface(dev->udev,0);
	 if(r) goto _eop;
	 memset(&einit,0,sizeof(struct et_init));
	 einit.stage=1;
	 case 2:
	 case 4:
	 case 6:
	 case 8:
	 case 10:
	 case 12:
	 case 14:
	 case 16:
	 case 18:
	 case 20:
	 case 22:
	 case 24:
	 case 26:
	 case 28:
	 case 30:
	 case 32:
	 case 34:
	 case 36:
	 case 38:
	 case 40:
	 case 42:
	 case 44:
	 case 46:
	 case 48:
	 case 50:
	 case 52:
	 case 54:
	 case 56:
	 case 58:
	 case 60:
	 case 62:
	 case 64:
	 case 66:
	 case 68:
	 case 70:
	 case 72:
	 case 74:
	 case 76:
	 case 78:
	 case 80:
	 case 82:
	 case 84:
	 case 86:
	 case 88:
	 case 90:
	 case 92:
	 case 94:
	 case 96:
	 case 98:
	 case 100:
	 case 102:
	 case 104:
	 case 106:
	 case 108:
	 case 110:
	 case 112:
	 case 114:
	 case 116:
	 einit.ssm_state=ssm->cur_state;
	 r=et_write_init(dev,&einit,ssm);
	 if(r)
	 {
_mabort:
	  fpi_ssm_mark_aborted(ssm,r);
	 }
	 break;
	 
	 case 1:
	 case 3:
	 case 5:
	 case 7:
	 case 9:
	 case 11:
	 case 13:
	 case 15:
	 case 17:
	 case 19:
	 case 21:
	 case 23:
	 case 25:
	 case 27:
	 case 29:
	 case 31:
	 case 33:
	 case 35:
	 case 37:
	 case 39:
	 case 41:
	 case 43:
	 case 45:
	 case 47:
	 case 49:
	 case 51:
	 case 53:
	 case 55:
	 case 57:
	 case 59:
	 case 61:
	 case 63:
	 case 65:
	 case 67:
	 case 69:
	 case 71:
	 case 73:
	 case 75:
	 case 77:
	 case 79:
	 case 81:
	 case 83:
	 case 85:
	 case 87:
	 case 89:
	 case 91:
	 case 93:
	 case 95:
	 case 97:
	 case 99:
	 case 101:
	 case 103:
	 case 105:
	 case 107:
	 case 109:
	 case 111:
	 case 113:
	 case 115:
	 case 117:
	 einit.ssm_state=ssm->cur_state;
	 r=et_read_answer(dev,&einit,ssm);
	 if(r) goto _mabort;
	 break;
	
        }
}
Exemplo n.º 25
0
static void et_read_enroll_cb(struct libusb_transfer* transfer)
{
 int r;
 int len;
 int comb=0; //Combined buffer (data+result) flag
 char* result;
 
 
 struct init_data* adata=transfer->user_data;
 if(transfer->status!=LIBUSB_TRANSFER_COMPLETED)
 {
  fpi_ssm_mark_aborted(adata->ssm,-EIO);
 }
 else
 {
  if((transfer->actual_length%2) && transfer->actual_length!=13) comb=1;
  if(comb) 
  {
   len=transfer->actual_length-13;
   //fp_dbg("<-: Read %d (combined)",transfer->actual_length-13);
  }
  else 
  {
   len=transfer->actual_length;
   //fp_dbg("<-: Read %d",transfer->actual_length);
  }
  //Data buffer received
  if(len!=13) r=et_verify_enroll_data(adata->init,len);
  else 
  {
   //fp_dbg("Result: %s",print_buf(ret_buf));
   r=et_verify_result(ret_buf);
   if(r) goto _erv;
   goto _ern;
  }
  //fp_dbg("verified");
  if(r)
  {
_erv:
   fpi_ssm_mark_aborted(adata->ssm,r);
   goto _eret;
  }
  adata->init->rstage++;
  if(!comb && len!=13) 
  {
   fp_dbg("We should not be here!");
   fpi_ssm_mark_aborted(adata->ssm,-EPROTO);
   //fpi_ssm_jump_to_state(adata->ssm,adata->init->ssm_state); //Jump back, and receive result
  }
  else
  {
   //Result received at the end of data
   switch(adata->init->stage)
   {
    case 17:
    case 18:
    case 19:
    case 20:
    case 21:
    case 22:
    case 23:
    case 24:
    //fp_dbg("Piece %d: %s",(adata->init->stage-17)+1,print_buf(et_img_buf[adata->init->stage-17]));
    result=(char*)&et_img_buf[adata->init->stage-17][len];
    break;
    
    default:
    result=(char*)&ret_buf[len];
    break;
   }
   r=et_verify_result(result);
   if(r) goto _erv;
_ern:    
   adata->init->rstage=0;
   adata->init->stage++;
   fpi_ssm_next_state(adata->ssm);
  }
 }
_eret:
 libusb_free_transfer(transfer); 
}
Exemplo n.º 26
0
static void capture_run_state(struct fpi_ssm *ssm)
{
	struct fp_img_dev *dev = ssm->priv;
	int r;

	switch(ssm->cur_state)
	{
	 case 0:
	 //fp_dbg("Initializing before get image data");
	 memset(&einit,0,sizeof(struct et_init));
	 einit.stage=1;
	 case 2:
	 case 4:
	 case 6:
	 case 8:
	 case 10:
	 case 12:
	 case 14:
	 case 16:
	 case 18:
	 case 20:
	 case 22:
	 case 24:
	 case 26:
	 case 28:
	 case 30:
	 case 32:
	 //fp_dbg("Get image from scanner");
	 case 34:
	 case 36:
	 case 38:
	 case 40:
	 case 42:
	 case 44:
	 case 46:
	 goto _castate;
	 case 48:
	 fp_dbg("Image captured, send stop and reinit");
	 case 50:
	 case 52:
	 case 54:
	 case 56:
	 case 58:
	 case 60:
	 case 62:
	 case 64:
	 case 66:
	 case 68:
	 case 70:
	 case 72:
	 case 74:
	 case 76:
	 case 78:
	 case 80:
_castate:	 
	 einit.ssm_state=ssm->cur_state;
	 r=et_write_enroll_data(dev,&einit,ssm);
	 if(r)
	 {
_cabort:
	  fpi_ssm_mark_aborted(ssm,r);	 
	 }
	 break;
	 
	 case 1:
	 case 3:
	 case 5:
	 case 7:
	 case 9:
	 case 11:
	 case 13:
	 case 15:
	 case 17:
	 case 19:
	 case 21:
	 case 23:
	 case 25:
	 case 27:
	 case 29:
	 case 31:
	 case 33:
	 case 35:
	 case 37:
	 case 39:
	 case 41:
	 case 43:
	 case 45:
	 case 47:
	 case 49:
	 case 51:
	 case 53:
	 case 55:
	 case 57:
	 case 59:
	 case 61:
	 case 63:
	 case 65:
	 case 67:
	 case 69:
	 case 71:
	 case 73:
	 case 75:
	 case 77:
	 case 79:
	 case 81:
	 r=et_read_enroll_data(dev,&einit,ssm);
	 if(r) goto _cabort;
	 break;
	}
}
Exemplo n.º 27
0
static void et_read_answer_cb(struct libusb_transfer* transfer)
{
 int r;
 int len;
 int comb=0; //Combined buffer (answer+data) flag
 char* result;
 
 
 struct init_data* adata=transfer->user_data;
 if(transfer->status!=LIBUSB_TRANSFER_COMPLETED)
 {
  fpi_ssm_mark_aborted(adata->ssm,-EIO);
 }
 else
 {
  if((transfer->actual_length%2) && transfer->actual_length!=13) comb=1;
  if(comb) 
  {
   len=transfer->actual_length-13;
   //fp_dbg("<-: Read %d (combined)",transfer->actual_length-13);
  }
  else 
  {
   len=transfer->actual_length;
   //fp_dbg("<-: Read %d",transfer->actual_length);
  }
  if(!adata->init->rstage)
  {
   //Data buffer received
   if(len!=13) r=et_verify_answer(adata->init,len);
   else 
   {
    //fp_dbg("Result: %s",print_buf(ret_buf));
    r=et_verify_result(ret_buf);
    if(r) goto _erv;
    goto _ern;
   }
   //fp_dbg("verified");
   if(r)
   {
_erv:
    fpi_ssm_mark_aborted(adata->ssm,r);
    goto _eret;
   }
   adata->init->rstage++;
   if(!comb && len!=13) fpi_ssm_jump_to_state(adata->ssm,adata->init->ssm_state); //Jump back, and receive result
   else
   {
    //Result received at the end of data
    result=(char*)&ret_buf[len];
    r=et_verify_result(result);
    if(r) goto _erv;
_ern:    
    adata->init->rstage=0;
    adata->init->stage++;
    fpi_ssm_next_state(adata->ssm);
   }
  }
  else
  {
   //Result received
   if(len!=13) { r=-EPROTO; goto _erv; }
   r=et_verify_result(ret_buf);
   if(r) goto _erv;
   adata->init->stage++;
   adata->init->rstage=0;
   fpi_ssm_next_state(adata->ssm);
  }
 }
_eret: 
 libusb_free_transfer(transfer);
}