Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ad70ced authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

[media] media/platform: convert drivers to use the new vb2_queue dev field



Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent dce57314
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -136,7 +136,6 @@ struct deinterlace_dev {
	struct dma_chan		*dma_chan;

	struct v4l2_m2m_dev	*m2m_dev;
	struct vb2_alloc_ctx	*alloc_ctx;
};

struct deinterlace_ctx {
@@ -820,8 +819,6 @@ static int deinterlace_queue_setup(struct vb2_queue *vq,
	*nbuffers = count;
	sizes[0] = size;

	alloc_ctxs[0] = ctx->dev->alloc_ctx;

	dprintk(ctx->dev, "get %d buffer(s) of size %d each.\n", count, size);

	return 0;
@@ -874,6 +871,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
	src_vq->ops = &deinterlace_qops;
	src_vq->mem_ops = &vb2_dma_contig_memops;
	src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
	src_vq->dev = ctx->dev->v4l2_dev.dev;
	q_data[V4L2_M2M_SRC].fmt = &formats[0];
	q_data[V4L2_M2M_SRC].width = 640;
	q_data[V4L2_M2M_SRC].height = 480;
@@ -891,6 +889,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
	dst_vq->ops = &deinterlace_qops;
	dst_vq->mem_ops = &vb2_dma_contig_memops;
	dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
	dst_vq->dev = ctx->dev->v4l2_dev.dev;
	q_data[V4L2_M2M_DST].fmt = &formats[0];
	q_data[V4L2_M2M_DST].width = 640;
	q_data[V4L2_M2M_DST].height = 480;
@@ -1046,13 +1045,6 @@ static int deinterlace_probe(struct platform_device *pdev)

	platform_set_drvdata(pdev, pcdev);

	pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
	if (IS_ERR(pcdev->alloc_ctx)) {
		v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n");
		ret = PTR_ERR(pcdev->alloc_ctx);
		goto err_ctx;
	}

	pcdev->m2m_dev = v4l2_m2m_init(&m2m_ops);
	if (IS_ERR(pcdev->m2m_dev)) {
		v4l2_err(&pcdev->v4l2_dev, "Failed to init mem2mem device\n");
@@ -1064,8 +1056,6 @@ static int deinterlace_probe(struct platform_device *pdev)

err_m2m:
	video_unregister_device(&pcdev->vfd);
err_ctx:
	vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx);
unreg_dev:
	v4l2_device_unregister(&pcdev->v4l2_dev);
rel_dma:
@@ -1082,7 +1072,6 @@ static int deinterlace_remove(struct platform_device *pdev)
	v4l2_m2m_release(pcdev->m2m_dev);
	video_unregister_device(&pcdev->vfd);
	v4l2_device_unregister(&pcdev->v4l2_dev);
	vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx);
	dma_release_channel(pcdev->dma_chan);

	return 0;
+1 −23
Original line number Diff line number Diff line
@@ -1059,10 +1059,6 @@ static int mcam_vb_queue_setup(struct vb2_queue *vq,

	if (*nbufs < minbufs)
		*nbufs = minbufs;
	if (cam->buffer_mode == B_DMA_contig)
		alloc_ctxs[0] = cam->vb_alloc_ctx;
	else if (cam->buffer_mode == B_DMA_sg)
		alloc_ctxs[0] = cam->vb_alloc_ctx_sg;

	if (*num_planes)
		return sizes[0] < size ? -EINVAL : 0;
@@ -1271,6 +1267,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
	vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
	vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
	vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
	vq->dev = cam->dev;
	INIT_LIST_HEAD(&cam->buffers);
	switch (cam->buffer_mode) {
	case B_DMA_contig:
@@ -1279,9 +1276,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
		vq->mem_ops = &vb2_dma_contig_memops;
		cam->dma_setup = mcam_ctlr_dma_contig;
		cam->frame_complete = mcam_dma_contig_done;
		cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev);
		if (IS_ERR(cam->vb_alloc_ctx))
			return PTR_ERR(cam->vb_alloc_ctx);
#endif
		break;
	case B_DMA_sg:
@@ -1290,9 +1284,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
		vq->mem_ops = &vb2_dma_sg_memops;
		cam->dma_setup = mcam_ctlr_dma_sg;
		cam->frame_complete = mcam_dma_sg_done;
		cam->vb_alloc_ctx_sg = vb2_dma_sg_init_ctx(cam->dev);
		if (IS_ERR(cam->vb_alloc_ctx_sg))
			return PTR_ERR(cam->vb_alloc_ctx_sg);
#endif
		break;
	case B_vmalloc:
@@ -1309,18 +1300,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
	return vb2_queue_init(vq);
}

static void mcam_cleanup_vb2(struct mcam_camera *cam)
{
#ifdef MCAM_MODE_DMA_CONTIG
	if (cam->buffer_mode == B_DMA_contig)
		vb2_dma_contig_cleanup_ctx(cam->vb_alloc_ctx);
#endif
#ifdef MCAM_MODE_DMA_SG
	if (cam->buffer_mode == B_DMA_sg)
		vb2_dma_sg_cleanup_ctx(cam->vb_alloc_ctx_sg);
#endif
}


/* ---------------------------------------------------------------------- */
/*
@@ -1875,7 +1854,6 @@ void mccic_shutdown(struct mcam_camera *cam)
		cam_warn(cam, "Removing a device with users!\n");
		mcam_ctlr_power_down(cam);
	}
	mcam_cleanup_vb2(cam);
	if (cam->buffer_mode == B_vmalloc)
		mcam_free_dma_bufs(cam);
	video_unregister_device(&cam->vdev);
+0 −2
Original line number Diff line number Diff line
@@ -176,8 +176,6 @@ struct mcam_camera {

	/* DMA buffers - DMA modes */
	struct mcam_vb_buffer *vb_bufs[MAX_DMA_BUFS];
	struct vb2_alloc_ctx *vb_alloc_ctx;
	struct vb2_alloc_ctx *vb_alloc_ctx_sg;

	/* Mode-specific ops, set at open time */
	void (*dma_setup)(struct mcam_camera *cam);
+3 −14
Original line number Diff line number Diff line
@@ -211,7 +211,6 @@ struct emmaprp_dev {
	struct clk		*clk_emma_ahb, *clk_emma_ipg;

	struct v4l2_m2m_dev	*m2m_dev;
	struct vb2_alloc_ctx	*alloc_ctx;
};

struct emmaprp_ctx {
@@ -710,8 +709,6 @@ static int emmaprp_queue_setup(struct vb2_queue *vq,
	*nbuffers = count;
	sizes[0] = size;

	alloc_ctxs[0] = ctx->dev->alloc_ctx;

	dprintk(ctx->dev, "get %d buffer(s) of size %d each.\n", count, size);

	return 0;
@@ -765,6 +762,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
	src_vq->ops = &emmaprp_qops;
	src_vq->mem_ops = &vb2_dma_contig_memops;
	src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
	src_vq->dev = ctx->dev->v4l2_dev.dev;

	ret = vb2_queue_init(src_vq);
	if (ret)
@@ -777,6 +775,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
	dst_vq->ops = &emmaprp_qops;
	dst_vq->mem_ops = &vb2_dma_contig_memops;
	dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
	dst_vq->dev = ctx->dev->v4l2_dev.dev;

	return vb2_queue_init(dst_vq);
}
@@ -948,18 +947,11 @@ static int emmaprp_probe(struct platform_device *pdev)
	if (ret)
		goto rel_vdev;

	pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
	if (IS_ERR(pcdev->alloc_ctx)) {
		v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n");
		ret = PTR_ERR(pcdev->alloc_ctx);
		goto rel_vdev;
	}

	pcdev->m2m_dev = v4l2_m2m_init(&m2m_ops);
	if (IS_ERR(pcdev->m2m_dev)) {
		v4l2_err(&pcdev->v4l2_dev, "Failed to init mem2mem device\n");
		ret = PTR_ERR(pcdev->m2m_dev);
		goto rel_ctx;
		goto rel_vdev;
	}

	ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
@@ -973,8 +965,6 @@ static int emmaprp_probe(struct platform_device *pdev)

rel_m2m:
	v4l2_m2m_release(pcdev->m2m_dev);
rel_ctx:
	vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx);
rel_vdev:
	video_device_release(vfd);
unreg_dev:
@@ -993,7 +983,6 @@ static int emmaprp_remove(struct platform_device *pdev)

	video_unregister_device(pcdev->vfd);
	v4l2_m2m_release(pcdev->m2m_dev);
	vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx);
	v4l2_device_unregister(&pcdev->v4l2_dev);
	mutex_destroy(&pcdev->dev_mutex);

+2 −10
Original line number Diff line number Diff line
@@ -342,8 +342,6 @@ static int isp_video_queue_setup(struct vb2_queue *queue,
	if (sizes[0] == 0)
		return -EINVAL;

	alloc_ctxs[0] = video->alloc_ctx;

	*count = min(*count, video->capture_mem / PAGE_ALIGN(sizes[0]));

	return 0;
@@ -1308,6 +1306,7 @@ static int isp_video_open(struct file *file)
	queue->mem_ops = &vb2_dma_contig_memops;
	queue->buf_struct_size = sizeof(struct isp_buffer);
	queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
	queue->dev = video->isp->dev;

	ret = vb2_queue_init(&handle->queue);
	if (ret < 0) {
@@ -1414,15 +1413,9 @@ int omap3isp_video_init(struct isp_video *video, const char *name)
		return -EINVAL;
	}

	video->alloc_ctx = vb2_dma_contig_init_ctx(video->isp->dev);
	if (IS_ERR(video->alloc_ctx))
		return PTR_ERR(video->alloc_ctx);

	ret = media_entity_pads_init(&video->video.entity, 1, &video->pad);
	if (ret < 0) {
		vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
	if (ret < 0)
		return ret;
	}

	mutex_init(&video->mutex);
	atomic_set(&video->active, 0);
@@ -1451,7 +1444,6 @@ int omap3isp_video_init(struct isp_video *video, const char *name)

void omap3isp_video_cleanup(struct isp_video *video)
{
	vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
	media_entity_cleanup(&video->video.entity);
	mutex_destroy(&video->queue_lock);
	mutex_destroy(&video->stream_lock);
Loading