コード例 #1
0
static long fimg2d_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	int ret = 0;
	struct fimg2d_context *ctx;
	struct fimg2d_platdata *pdata;
	union {
		struct fimg2d_blit *blit;
		struct fimg2d_version ver;
	} u;

	ctx = file->private_data;
	if (!ctx) {
		printk(KERN_ERR "[%s] missing ctx\n", __func__);
		return -EFAULT;
	}

	switch (cmd) {
	case FIMG2D_BITBLT_BLIT:
		fimg2d_debug("FIMG2D_BITBLT_BLIT ctx: %p\n", ctx);
		u.blit = (struct fimg2d_blit *)arg;

		ret = fimg2d_add_command(info, ctx, u.blit);
		if (!ret)
			fimg2d_request_bitblt(ctx);
#ifdef PERF_PROFILE
		perf_print(ctx, u.blit->seq_no);
		perf_clear(ctx);
#endif
		break;

	case FIMG2D_BITBLT_SYNC:
		fimg2d_debug("FIMG2D_BITBLT_SYNC ctx: %p\n", ctx);
		/* FIXME: */
		break;

	case FIMG2D_BITBLT_VERSION:
		fimg2d_debug("FIMG2D_BITBLT_VERSION ctx: %p\n", ctx);
		pdata = to_fimg2d_plat(info->dev);
		u.ver.hw = pdata->hw_ver;
		u.ver.sw = 0;
		fimg2d_debug("fimg2d version, hw: 0x%x sw: 0x%x\n", u.ver.hw, u.ver.sw);
		if (copy_to_user((void *)arg, &u.ver, sizeof(u.ver)))
			return -EFAULT;
		break;

	default:
		printk(KERN_ERR "[%s] unknown ioctl\n", __func__);
		ret = -EFAULT;
		break;
	}

	return ret;
}
コード例 #2
0
static long fimg2d_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	int ret = 0;
	struct fimg2d_context *ctx;
	struct fimg2d_platdata *pdata;
	struct fimg2d_blit blit;
	struct fimg2d_version ver;
	struct fimg2d_image dst;

	ctx = file->private_data;
	if (!ctx) {
		printk(KERN_ERR "[%s] missing ctx\n", __func__);
		return -EFAULT;
	}

	switch (cmd) {
	case FIMG2D_BITBLT_BLIT:
		if (info->secure)
			return -EFAULT;
		if (copy_from_user(&blit, (void *)arg, sizeof(blit)))
			return -EFAULT;
		if (blit.dst)
			if (copy_from_user(&dst, (void *)blit.dst, sizeof(dst)))
				return -EFAULT;

#ifdef CONFIG_BUSFREQ_OPP
#if defined(CONFIG_CPU_EXYNOS4212) || defined(CONFIG_CPU_EXYNOS4412)
			dev_lock(info->bus_dev, info->dev, 160160);
#endif
#endif
		if ((blit.dst) && (dst.addr.type == ADDR_USER))
			if (!down_write_trylock(&page_alloc_slow_rwsem))
				ret = -EAGAIN;

		if (ret != -EAGAIN)
			ret = fimg2d_add_command(info, ctx, &blit, dst.addr.type);

		if (!ret) {
			fimg2d_request_bitblt(ctx);
		}

#ifdef PERF_PROFILE
		perf_print(ctx, blit.seq_no);
		perf_clear(ctx);
#endif
		if ((blit.dst) && (dst.addr.type == ADDR_USER) && ret != -EAGAIN)
			up_write(&page_alloc_slow_rwsem);

#ifdef CONFIG_BUSFREQ_OPP
#if defined(CONFIG_CPU_EXYNOS4212) || defined(CONFIG_CPU_EXYNOS4412)
			dev_unlock(info->bus_dev, info->dev);
#endif
#endif
		break;

	case FIMG2D_BITBLT_SYNC:
		fimg2d_debug("FIMG2D_BITBLT_SYNC ctx: %p\n", ctx);
		/* FIXME: */
		break;

	case FIMG2D_BITBLT_VERSION:
		pdata = to_fimg2d_plat(info->dev);
		ver.hw = pdata->hw_ver;
		ver.sw = 0;
		fimg2d_debug("fimg2d version, hw: 0x%x sw: 0x%x\n",
				ver.hw, ver.sw);
		if (copy_to_user((void *)arg, &ver, sizeof(ver)))
			return -EFAULT;
		break;

	case FIMG2D_BITBLT_SECURE:
		if (copy_from_user(&info->secure,
				   (unsigned int *)arg,
				   sizeof(unsigned int))) {
			printk(KERN_ERR
				"[%s] failed to FIMG2D_BITBLT_SECURE: copy_from_user error\n\n",
				__func__);
			return -EFAULT;
		}

		while (1) {
			if (fimg2d_queue_is_empty(&info->cmd_q))
				break;
			mdelay(2);
		}

		break;

	default:
		printk(KERN_ERR "[%s] unknown ioctl\n", __func__);
		ret = -EFAULT;
		break;
	}

	return ret;
}