Exemplo n.º 1
0
long mdp_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
{
    int rc = 0;
    if (!sd) {
        WFD_MSG_ERR("Invalid arguments\n");
        return -EINVAL;
    }
    switch (cmd) {
    case MDP_Q_BUFFER:
        rc = mdp_q_buffer(sd, arg);
        break;
    case MDP_DQ_BUFFER:
        rc = mdp_dq_buffer(sd, arg);
        break;
    case MDP_OPEN:
        rc = mdp_open(sd, arg);
        break;
    case MDP_START:
        rc = mdp_start(sd, arg);
        break;
    case MDP_STOP:
        rc = mdp_stop(sd, arg);
        break;
    case MDP_SET_PROP:
        rc = mdp_set_prop(sd, arg);
        break;
    case MDP_CLOSE:
        rc = mdp_close(sd, arg);
        break;
    default:
        WFD_MSG_ERR("IOCTL: %u not supported\n", cmd);
        rc = -EINVAL;
        break;
    }
    return rc;
}
Exemplo n.º 2
0
int mdp_stop(struct v4l2_subdev *sd, void *arg)
{
	struct mdp_instance *inst = arg;
	int rc = 0;
	struct fb_info *fbi = NULL;
	if (inst) {
		rc = msm_fb_writeback_stop(inst->mdp);
		if (rc) {
			WFD_MSG_ERR("Failed to stop writeback mode\n");
			return rc;
		}
		fbi = (struct fb_info *)inst->mdp;
	}
	return 0;
}
Exemplo n.º 3
0
int mdp_open(struct v4l2_subdev *sd, void *arg)
{
	struct mdp_instance *inst = kzalloc(sizeof(struct mdp_instance),
					GFP_KERNEL);
	struct mdp_msg_ops *mops = arg;
	int rc = 0;
	struct fb_info *fbi = NULL;

	if (!inst) {
		WFD_MSG_ERR("Out of memory\n");
		rc = -ENOMEM;
		goto mdp_open_fail;
	} else if (!mops) {
		WFD_MSG_ERR("Invalid arguments\n");
		rc = -EINVAL;
		goto mdp_open_fail;
	}

	fbi = msm_fb_get_writeback_fb();
	if (!fbi) {
		WFD_MSG_ERR("Failed to acquire mdp instance\n");
		rc = -ENODEV;
		goto mdp_open_fail;
	}

	msm_fb_writeback_init(fbi);
	inst->mdp = fbi;
	inst->secure = mops->secure;
	inst->uses_iommu_split_domain = mops->iommu_split_domain;

	mops->cookie = inst;
	return rc;
mdp_open_fail:
	kfree(inst);
	return rc;
}
Exemplo n.º 4
0
int mdp_start(struct v4l2_subdev *sd, void *arg)
{
	struct mdp_instance *inst = arg;
	int rc = 0;
	struct fb_info *fbi = NULL;
	if (inst) {
		rc = msm_fb_writeback_start(inst->mdp);
		if (rc) {
			WFD_MSG_ERR("Failed to start MDP mode\n");
			goto exit;
		}
		fbi = msm_fb_get_writeback_fb();
		if (!fbi) {
			WFD_MSG_ERR("Failed to acquire mdp instance\n");
			rc = -ENODEV;
			goto exit;
		}
		rc = kobject_uevent(&fbi->dev->kobj, KOBJ_ONLINE);
		if (rc)
			WFD_MSG_ERR("Failed to send ONLINE event\n");
	}
exit:
	return rc;
}
static int mdp_secure(struct v4l2_subdev *sd, void *arg)
{
	struct mdp_instance *inst = NULL;
	int rc = 0;

	if (!arg) {
		WFD_MSG_ERR("Invalid argument\n");
		return -EINVAL;
	}

	inst = arg;
	rc = msm_fb_writeback_set_secure(inst->mdp, true);
	if (!rc)
		inst->secure = true;

	return rc;
}
static int mdp_open(struct v4l2_subdev *sd, void *arg)
{
	struct mdp_instance *inst = kzalloc(sizeof(struct mdp_instance),
					GFP_KERNEL);
	void **cookie = (void **)arg;
	int rc = 0;

	if (!inst) {
		WFD_MSG_ERR("Out of memory\n");
		return -ENOMEM;
	}

	INIT_LIST_HEAD(&inst->mdp_bufs.node);
	mutex_init(&inst->mutex);
	*cookie = inst;
	return rc;
}
Exemplo n.º 7
0
int mdp_stop(struct v4l2_subdev *sd, void *arg)
{
	struct mdp_instance *inst = arg;
	int rc = 0;
	struct fb_info *fbi = NULL;
	if (inst) {
		rc = msm_fb_writeback_stop(inst->mdp);
		if (rc) {
			WFD_MSG_ERR("Failed to stop writeback mode\n");
			return rc;
		}
		fbi = (struct fb_info *)inst->mdp;
		switch_set_state(&inst->sdev, false);
		WFD_MSG_DBG("wfd state switched to %d\n", inst->sdev.state);
	}
	return 0;
}
Exemplo n.º 8
0
static int __devexit __wfd_remove(struct platform_device *pdev)
{
	struct wfd_device *wfd_dev;
	wfd_dev = (struct wfd_device *)pdev->dev.platform_data;

	WFD_MSG_DBG("Inside wfd_remove\n");
	if (!wfd_dev) {
		WFD_MSG_ERR("Error removing WFD device");
		return -ENODEV;
	}

	v4l2_device_unregister_subdev(&wfd_dev->mdp_sdev);
	video_unregister_device(wfd_dev->pvdev);
	video_device_release(wfd_dev->pvdev);
	v4l2_device_unregister(&wfd_dev->v4l2_dev);
	kfree(wfd_dev);
	return 0;
}
int wfd_stats_deinit(struct wfd_stats *stats)
{
	WFD_MSG_ERR("Latencies: avg enc. latency %d",
			stats->enc_avg_latency);
	/* Delete all debugfs files in one shot :) */
	if (stats->d_parent)
		debugfs_remove_recursive(stats->d_parent);

	stats->d_parent =
	stats->d_v4l2_buf_count =
	stats->d_mdp_buf_count =
	stats->d_vsg_buf_count =
	stats->d_enc_buf_count =
	stats->d_frames_encoded =
	stats->d_mdp_updates =
	stats->d_enc_avg_latency = NULL;

	return 0;
}
Exemplo n.º 10
0
void wfd_vidbuf_buf_cleanup(struct vb2_buffer *vb)
{
	int rc = 0;
	struct vb2_queue *q = vb->vb2_queue;
	struct file *priv_data = (struct file *)(q->drv_priv);
	struct wfd_device *wfd_dev =
		(struct wfd_device *)video_drvdata(priv_data);
	struct wfd_inst *inst = (struct wfd_inst *)priv_data->private_data;
	struct mdp_buf_info buf = {
					inst->mdp_inst,
					vb,
					inst->minfo[vb->v4l2_buf.index]->fd,
					inst->minfo[vb->v4l2_buf.index]->offset
					};
	WFD_MSG_DBG("Releasing buffer\n");
	rc = v4l2_subdev_call(&wfd_dev->mdp_sdev, core, ioctl,
			 MDP_RELEASE_BUF, (void *)&buf);
	if (rc)
		WFD_MSG_ERR("Failed to release the buffer\n");
}
Exemplo n.º 11
0
int wfd_vidbuf_buf_init(struct vb2_buffer *vb)
{
	int rc = 0;
	struct vb2_queue *q = vb->vb2_queue;
	struct file *priv_data = (struct file *)(q->drv_priv);
	struct wfd_inst *inst = (struct wfd_inst *)priv_data->private_data;
	struct wfd_device *wfd_dev =
		(struct wfd_device *)video_drvdata(priv_data);
	struct mdp_buf_info buf = {
					inst->mdp_inst,
					vb,
					inst->minfo[vb->v4l2_buf.index]->fd,
					inst->minfo[vb->v4l2_buf.index]->offset
					};

	if (inst && !inst->vid_bufq.streaming) {
		rc = v4l2_subdev_call(&wfd_dev->mdp_sdev, core,
				ioctl, MDP_PREPARE_BUF, (void *)&buf);
		if (rc)
			WFD_MSG_ERR("Unable to prepare/register the buffer\n");
	}
	return rc;
}
Exemplo n.º 12
0
int wfd_stats_init(struct wfd_stats *stats, int device)
{
	char device_str[NAME_MAX] = "";
	int rc = 0;

	if (!stats) {
		rc = -EINVAL;
		goto wfd_stats_init_fail;
	} else if (!wfd_debugfs_root) {
		WFD_MSG_ERR("wfd debugfs root does not exist\n");
		rc = -ENOENT;
		goto wfd_stats_init_fail;
	}

	memset(stats, 0, sizeof(*stats));
	INIT_LIST_HEAD(&stats->enc_queue);
	mutex_init(&stats->mutex);

	snprintf(device_str, sizeof(device_str), "%d", device);
	stats->d_parent = debugfs_create_dir(device_str, wfd_debugfs_root);
	if (IS_ERR(stats->d_parent)) {
		rc = PTR_ERR(stats->d_parent);
		stats->d_parent = NULL;
		goto wfd_stats_init_fail;
	}

	stats->d_v4l2_buf_count = debugfs_create_u32("v4l2_buf_count", S_IRUGO,
			stats->d_parent, &stats->v4l2_buf_count);
	if (IS_ERR(stats->d_v4l2_buf_count)) {
		rc = PTR_ERR(stats->d_v4l2_buf_count);
		stats->d_v4l2_buf_count = NULL;
		goto wfd_stats_init_fail;
	}

	stats->d_mdp_buf_count = debugfs_create_u32("mdp_buf_count", S_IRUGO,
			stats->d_parent, &stats->mdp_buf_count);
	if (IS_ERR(stats->d_mdp_buf_count)) {
		rc = PTR_ERR(stats->d_mdp_buf_count);
		stats->d_mdp_buf_count = NULL;
		goto wfd_stats_init_fail;
	}

	stats->d_vsg_buf_count = debugfs_create_u32("vsg_buf_count", S_IRUGO,
			stats->d_parent, &stats->vsg_buf_count);
	if (IS_ERR(stats->d_vsg_buf_count)) {
		rc = PTR_ERR(stats->d_vsg_buf_count);
		stats->d_vsg_buf_count = NULL;
		goto wfd_stats_init_fail;
	}

	stats->d_enc_buf_count = debugfs_create_u32("enc_buf_count", S_IRUGO,
			stats->d_parent, &stats->enc_buf_count);
	if (IS_ERR(stats->d_enc_buf_count)) {
		rc = PTR_ERR(stats->d_enc_buf_count);
		stats->d_enc_buf_count = NULL;
		goto wfd_stats_init_fail;
	}

	stats->d_frames_encoded = debugfs_create_u32("frames_encoded", S_IRUGO,
			stats->d_parent, &stats->frames_encoded);
	if (IS_ERR(stats->d_frames_encoded)) {
		rc = PTR_ERR(stats->d_frames_encoded);
		stats->d_frames_encoded = NULL;
		goto wfd_stats_init_fail;
	}

	stats->d_mdp_updates = debugfs_create_u32("mdp_updates", S_IRUGO,
			stats->d_parent, &stats->mdp_updates);
	if (IS_ERR(stats->d_mdp_updates)) {
		rc = PTR_ERR(stats->d_mdp_updates);
		stats->d_mdp_updates = NULL;
		goto wfd_stats_init_fail;
	}

	stats->d_enc_avg_latency = debugfs_create_u32("enc_avg_latency",
			S_IRUGO, stats->d_parent, &stats->enc_avg_latency);
	if (IS_ERR(stats->d_enc_avg_latency)) {
		rc = PTR_ERR(stats->d_enc_avg_latency);
		stats->d_enc_avg_latency = NULL;
		goto wfd_stats_init_fail;
	}

	return rc;
wfd_stats_init_fail:
	return rc;
}