static int rawchip_get_interrupt(struct rawchip_ctrl *raw_dev, void __user *arg)
{
	int rc = 0;
	struct rawchip_stats_event_ctrl se;
	int timeout;
	uint8_t interrupt_type;
	uint8_t interrupt0_type = 0;
	uint8_t interrupt1_type = 0;

	CDBG("%s\n", __func__);

	if (copy_from_user(&se, arg,
			sizeof(struct rawchip_stats_event_ctrl))) {
		pr_err("%s, ERR_COPY_FROM_USER\n", __func__);
		rc = -EFAULT;
		goto end;
	}

	timeout = (int)se.timeout_ms;

	CDBG("[CAM] %s: timeout %d\n", __func__, timeout);

	if (atomic_read(&rawchipCtrl->check_intr0)) {
		interrupt0_type = Yushan_parse_interrupt(INTERRUPT_PAD_0, rawchipCtrl->error_interrupt_times);
		atomic_set(&rawchipCtrl->check_intr0, 0);
	}
	if (atomic_read(&rawchipCtrl->check_intr1)) {
		interrupt1_type = Yushan_parse_interrupt(INTERRUPT_PAD_1, rawchipCtrl->error_interrupt_times);
		atomic_set(&rawchipCtrl->check_intr1, 0);
	}
	interrupt_type = interrupt0_type | interrupt1_type;

	if (interrupt_type & RAWCHIP_INT_TYPE_ERROR) {
		rawchipCtrl->total_error_interrupt_times++;
		if (rawchipCtrl->total_error_interrupt_times <= 10 || rawchipCtrl->total_error_interrupt_times % 1000 == 0) {
			Yushan_Status_Snapshot();
			if (!(interrupt_type & RAWCHIP_INT_TYPE_DXO_IP_ERROR))
				Yushan_dump_Dxo();
		}
	}
	se.type = 10;
	se.length = sizeof(interrupt_type);
	if (copy_to_user((void *)(se.data),
			&interrupt_type,
			se.length)) {
			pr_err("%s, ERR_COPY_TO_USER 1\n", __func__);
		rc = -EFAULT;
		goto end;
	}

	if (copy_to_user((void *)arg, &se, sizeof(se))) {
		pr_err("%s, ERR_COPY_TO_USER 2\n", __func__);
		rc = -EFAULT;
		goto end;
	}
end:
	return rc;
}
Exemplo n.º 2
0
static int rawchip_get_interrupt(struct rawchip_ctrl *raw_dev, void __user *arg)
{
	int rc = 0;
	struct rawchip_stats_event_ctrl se;
	int timeout;
	uint8_t interrupt_type;

	CDBG("%s\n", __func__);

	if (copy_from_user(&se, arg,
			sizeof(struct rawchip_stats_event_ctrl))) {
		pr_err("[CAM] %s, ERR_COPY_FROM_USER\n", __func__);
		rc = -EFAULT;
		goto end;
	}

	timeout = (int)se.timeout_ms;

	CDBG("[CAM] %s: timeout %d\n", __func__, timeout);

	interrupt_type = Yushan_parse_interrupt();
	se.type = 10;
	se.length = sizeof(interrupt_type);
	if (copy_to_user((void *)(se.data),
			&interrupt_type,
			se.length)) {
			pr_err("[CAM] %s, ERR_COPY_TO_USER 1\n", __func__);
		rc = -EFAULT;
		goto end;
	}

	if (copy_to_user((void *)arg, &se, sizeof(se))) {
		pr_err("[CAM] %s, ERR_COPY_TO_USER 2\n", __func__);
		rc = -EFAULT;
		goto end;
	}
end:
	return rc;
}