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

Commit 53ddcc68 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>
Acked-by: default avatarLad, Prabhakar <prabhakar.csengg@gmail.com>
Cc: Scott Jiang <scott.jiang.linux@gmail.com>
Acked-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 57813da4
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -1915,7 +1915,6 @@ static int vpfe_queue_setup(struct vb2_queue *vq,

	if (vq->num_buffers + *nbuffers < 3)
		*nbuffers = 3 - vq->num_buffers;
	alloc_ctxs[0] = vpfe->alloc_ctx;

	if (*nplanes) {
		if (sizes[0] < size)
@@ -2364,13 +2363,6 @@ static int vpfe_probe_complete(struct vpfe_device *vpfe)
		goto probe_out;

	/* Initialize videobuf2 queue as per the buffer type */
	vpfe->alloc_ctx = vb2_dma_contig_init_ctx(vpfe->pdev);
	if (IS_ERR(vpfe->alloc_ctx)) {
		vpfe_err(vpfe, "Failed to get the context\n");
		err = PTR_ERR(vpfe->alloc_ctx);
		goto probe_out;
	}

	q = &vpfe->buffer_queue;
	q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
@@ -2381,11 +2373,11 @@ static int vpfe_probe_complete(struct vpfe_device *vpfe)
	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
	q->lock = &vpfe->lock;
	q->min_buffers_needed = 1;
	q->dev = vpfe->pdev;

	err = vb2_queue_init(q);
	if (err) {
		vpfe_err(vpfe, "vb2_queue_init() failed\n");
		vb2_dma_contig_cleanup_ctx(vpfe->alloc_ctx);
		goto probe_out;
	}

+0 −2
Original line number Diff line number Diff line
@@ -264,8 +264,6 @@ struct vpfe_device {
	struct v4l2_rect crop;
	/* Buffer queue used in video-buf */
	struct vb2_queue buffer_queue;
	/* Allocator-specific contexts for each plane */
	struct vb2_alloc_ctx *alloc_ctx;
	/* Queue of filled frames */
	struct list_head dma_queue;
	/* IRQ lock for DMA queue */
+2 −13
Original line number Diff line number Diff line
@@ -91,8 +91,6 @@ struct bcap_device {
	struct bcap_buffer *cur_frm;
	/* buffer queue used in videobuf2 */
	struct vb2_queue buffer_queue;
	/* allocator-specific contexts for each plane */
	struct vb2_alloc_ctx *alloc_ctx;
	/* queue of filled frames */
	struct list_head dma_queue;
	/* used in videobuf2 callback */
@@ -209,7 +207,6 @@ static int bcap_queue_setup(struct vb2_queue *vq,

	if (vq->num_buffers + *nbuffers < 2)
		*nbuffers = 2;
	alloc_ctxs[0] = bcap_dev->alloc_ctx;

	if (*nplanes)
		return sizes[0] < bcap_dev->fmt.sizeimage ? -EINVAL : 0;
@@ -820,12 +817,6 @@ static int bcap_probe(struct platform_device *pdev)
	}
	bcap_dev->ppi->priv = bcap_dev;

	bcap_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
	if (IS_ERR(bcap_dev->alloc_ctx)) {
		ret = PTR_ERR(bcap_dev->alloc_ctx);
		goto err_free_ppi;
	}

	vfd = &bcap_dev->video_dev;
	/* initialize field of video device */
	vfd->release            = video_device_release_empty;
@@ -839,7 +830,7 @@ static int bcap_probe(struct platform_device *pdev)
	if (ret) {
		v4l2_err(pdev->dev.driver,
				"Unable to register v4l2 device\n");
		goto err_cleanup_ctx;
		goto err_free_ppi;
	}
	v4l2_info(&bcap_dev->v4l2_dev, "v4l2 device registered\n");

@@ -863,6 +854,7 @@ static int bcap_probe(struct platform_device *pdev)
	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
	q->lock = &bcap_dev->mutex;
	q->min_buffers_needed = 1;
	q->dev = &pdev->dev;

	ret = vb2_queue_init(q);
	if (ret)
@@ -967,8 +959,6 @@ static int bcap_probe(struct platform_device *pdev)
	v4l2_ctrl_handler_free(&bcap_dev->ctrl_handler);
err_unreg_v4l2:
	v4l2_device_unregister(&bcap_dev->v4l2_dev);
err_cleanup_ctx:
	vb2_dma_contig_cleanup_ctx(bcap_dev->alloc_ctx);
err_free_ppi:
	ppi_delete_instance(bcap_dev->ppi);
err_free_dev:
@@ -986,7 +976,6 @@ static int bcap_remove(struct platform_device *pdev)
	video_unregister_device(&bcap_dev->video_dev);
	v4l2_ctrl_handler_free(&bcap_dev->ctrl_handler);
	v4l2_device_unregister(v4l2_dev);
	vb2_dma_contig_cleanup_ctx(bcap_dev->alloc_ctx);
	ppi_delete_instance(bcap_dev->ppi);
	kfree(bcap_dev);
	return 0;
+2 −14
Original line number Diff line number Diff line
@@ -1151,9 +1151,6 @@ static int coda_queue_setup(struct vb2_queue *vq,
	*nplanes = 1;
	sizes[0] = size;

	/* Set to vb2-dma-contig allocator context, ignored by vb2-vmalloc */
	alloc_ctxs[0] = ctx->dev->alloc_ctx;

	v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev,
		 "get %d buffer(s) of size %d each.\n", *nbuffers, size);

@@ -1599,6 +1596,7 @@ static int coda_queue_init(struct coda_ctx *ctx, struct vb2_queue *vq)
	 * that videobuf2 will keep the value of bytesused intact.
	 */
	vq->allow_zero_bytesused = 1;
	vq->dev = &ctx->dev->plat_dev->dev;

	return vb2_queue_init(vq);
}
@@ -2040,16 +2038,10 @@ static void coda_fw_callback(const struct firmware *fw, void *context)
	if (ret < 0)
		goto put_pm;

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

	dev->m2m_dev = v4l2_m2m_init(&coda_m2m_ops);
	if (IS_ERR(dev->m2m_dev)) {
		v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem device\n");
		goto rel_ctx;
		goto put_pm;
	}

	for (i = 0; i < dev->devtype->num_vdevs; i++) {
@@ -2072,8 +2064,6 @@ static void coda_fw_callback(const struct firmware *fw, void *context)
	while (--i >= 0)
		video_unregister_device(&dev->vfd[i]);
	v4l2_m2m_release(dev->m2m_dev);
rel_ctx:
	vb2_dma_contig_cleanup_ctx(dev->alloc_ctx);
put_pm:
	pm_runtime_put_sync(&pdev->dev);
}
@@ -2324,8 +2314,6 @@ static int coda_remove(struct platform_device *pdev)
	if (dev->m2m_dev)
		v4l2_m2m_release(dev->m2m_dev);
	pm_runtime_disable(&pdev->dev);
	if (dev->alloc_ctx)
		vb2_dma_contig_cleanup_ctx(dev->alloc_ctx);
	v4l2_device_unregister(&dev->v4l2_dev);
	destroy_workqueue(dev->workqueue);
	if (dev->iram.vaddr)
+0 −1
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@ struct coda_dev {
	struct mutex		coda_mutex;
	struct workqueue_struct	*workqueue;
	struct v4l2_m2m_dev	*m2m_dev;
	struct vb2_alloc_ctx	*alloc_ctx;
	struct list_head	instances;
	unsigned long		instance_mask;
	struct dentry		*debugfs_root;
Loading