Ejemplo n.º 1
0
static long jpeg_ioctl(struct file *file,
			unsigned int cmd, unsigned long arg)
{
	int ret;
	struct jpeg_control	*ctrl;

	ctrl  = (struct jpeg_control *)file->private_data;
	if (!ctrl) {
		jpeg_err("jpeg invalid input argument\n");
		return -1;
	}

	switch (cmd) {

	case IOCTL_JPEG_DEC_EXE:
		ret = copy_from_user(&ctrl->dec_param,
			(struct jpeg_dec_param *)arg,
			sizeof(struct jpeg_dec_param));

		jpeg_exe_dec(ctrl);
		ret = copy_to_user((void *)arg,
			(void *) &ctrl->dec_param,
			sizeof(struct jpeg_dec_param));
		break;

	case IOCTL_JPEG_ENC_EXE:
		ret = copy_from_user(&ctrl->enc_param,
			(struct jpeg_enc_param *)arg,
			sizeof(struct jpeg_enc_param));

		jpeg_exe_enc(ctrl);
		ret = copy_to_user((void *)arg,
			(void *) &ctrl->enc_param,
			sizeof(struct jpeg_enc_param));
		break;

	case IOCTL_GET_DEC_IN_BUF:
	case IOCTL_GET_ENC_OUT_BUF:
		return jpeg_get_stream_buf(arg);

	case IOCTL_GET_DEC_OUT_BUF:
	case IOCTL_GET_ENC_IN_BUF:
		return jpeg_get_frame_buf(arg);

	case IOCTL_GET_PHYADDR:
		return jpeg_ctrl->mem.frame_data_addr;

	case IOCTL_GET_PHYMEM_BASE:
#ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG
		if (copy_to_user((void *)arg, &jpeg_ctrl->mem.base, sizeof(unsigned int))) {
			jpeg_err("IOCTL_GET_PHYMEM_BASE:::copy_to_user error\n");
			return -1;
		}
		return 0;
#else
		return -1;
#endif

	case IOCTL_GET_PHYMEM_SIZE:
#ifdef CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG
		ret = CONFIG_VIDEO_SAMSUNG_MEMSIZE_JPEG * 1024;
		if (copy_to_user((void *)arg, &ret, sizeof(unsigned int))) {
			jpeg_err("IOCTL_GET_PHYMEM_SIZE:::copy_to_user error\n");
			return -1;
		}
		return 0;
#else
		return -1;
#endif

	case IOCTL_SET_DEC_PARAM:
		ret = copy_from_user(&ctrl->dec_param,
			(struct jpeg_dec_param *)arg,
			sizeof(struct jpeg_dec_param));

		ret = jpeg_set_dec_param(ctrl);

		break;

	case IOCTL_SET_ENC_PARAM:
		ret = copy_from_user(&ctrl->enc_param,
			(struct jpeg_enc_param *)arg,
			sizeof(struct jpeg_enc_param));

		ret = jpeg_set_enc_param(ctrl);
		break;

	default:
		break;
	}
	return 0;
}
Ejemplo n.º 2
0
static long jpeg_ioctl(struct file *file,
			unsigned int cmd, unsigned long arg)
{
	int ret;
	struct jpeg_control	*ctrl;

	ctrl  = (struct jpeg_control *)file->private_data;
	if (!ctrl) {
		jpeg_err("jpeg invalid input argument\n");
		return -1;
	}

	switch (cmd) {

	case IOCTL_JPEG_DEC_EXE:
		ret = copy_from_user(&ctrl->dec_param,
			(struct jpeg_dec_param *)arg,
			sizeof(struct jpeg_dec_param));

		jpeg_exe_dec(ctrl);
		ret = copy_to_user((void *)arg,
			(void *) &ctrl->dec_param,
			sizeof(struct jpeg_dec_param));
		break;

	case IOCTL_JPEG_ENC_EXE:
		ret = copy_from_user(&ctrl->enc_param,
			(struct jpeg_enc_param *)arg,
			sizeof(struct jpeg_enc_param));

		jpeg_exe_enc(ctrl);
		ret = copy_to_user((void *)arg,
			(void *) &ctrl->enc_param,
			sizeof(struct jpeg_enc_param));
		break;

	case IOCTL_GET_DEC_IN_BUF:
	case IOCTL_GET_ENC_OUT_BUF:
		return jpeg_get_stream_buf(arg);

	case IOCTL_GET_DEC_OUT_BUF:
	case IOCTL_GET_ENC_IN_BUF:
		return jpeg_get_frame_buf(arg);

	case IOCTL_SET_DEC_PARAM:
		ret = copy_from_user(&ctrl->dec_param,
			(struct jpeg_dec_param *)arg,
			sizeof(struct jpeg_dec_param));

		ret = jpeg_set_dec_param(ctrl);

		break;

	case IOCTL_SET_ENC_PARAM:
		ret = copy_from_user(&ctrl->enc_param,
			(struct jpeg_enc_param *)arg,
			sizeof(struct jpeg_enc_param));

		ret = jpeg_set_enc_param(ctrl);
		break;

	default:
		break;
	}
	return 0;
}