[media] media/platform: convert drivers to use the new vb2_queue dev field
authorHans Verkuil <hans.verkuil@cisco.com>
Mon, 15 Feb 2016 15:09:10 +0000 (13:09 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 8 Jul 2016 17:39:21 +0000 (14:39 -0300)
Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Cc: Scott Jiang <scott.jiang.linux@gmail.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
13 files changed:
drivers/media/platform/am437x/am437x-vpfe.c
drivers/media/platform/am437x/am437x-vpfe.h
drivers/media/platform/blackfin/bfin_capture.c
drivers/media/platform/coda/coda-common.c
drivers/media/platform/coda/coda.h
drivers/media/platform/davinci/vpbe_display.c
drivers/media/platform/davinci/vpif_capture.c
drivers/media/platform/davinci/vpif_capture.h
drivers/media/platform/davinci/vpif_display.c
drivers/media/platform/davinci/vpif_display.h
drivers/media/platform/rcar-vin/rcar-dma.c
drivers/media/platform/rcar-vin/rcar-vin.h
include/media/davinci/vpbe_display.h

index e749eb7c3be98ccecfcf17dd8e79ae6d53003d76..d22b09db9fd005d996a0bce0b88adfeb80acfdb8 100644 (file)
@@ -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;
        }
 
index 777bf97fea572067da979c812d79ecbcde0d83b6..17d7aa426788b77e7aaaa1da4c5df259dfd4b2d0 100644 (file)
@@ -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 */
index d0092dae7a57e6ab391ccf1021eebd4591e28787..1e2442876d267d625a208568b395bece99f7a35d 100644 (file)
@@ -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 @@ err_free_handler:
        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;
index 133ab9f70f851c4a71b89bf0e4c19b039018bf78..3d57c352cefa87fd1f77f30962f793efea1e823f 100644 (file)
@@ -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 @@ rel_vfd:
        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)
index 8f2c71e06966025af3f9dcc987b1ea66a132a309..53f96661683c63c7865967467d96585e48264252 100644 (file)
@@ -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;
index 0abcdfe97a6ceb1661d1262979a885a963b00460..2a4c2914d077ddbacad37dace8023742c5bbd377 100644 (file)
@@ -242,7 +242,6 @@ vpbe_buffer_queue_setup(struct vb2_queue *vq,
        /* Store number of buffers allocated in numbuffer member */
        if (vq->num_buffers + *nbuffers < VPBE_DEFAULT_NUM_BUFS)
                *nbuffers = VPBE_DEFAULT_NUM_BUFS - vq->num_buffers;
-       alloc_ctxs[0] = layer->alloc_ctx;
 
        if (*nplanes)
                return sizes[0] < layer->pix_fmt.sizeimage ? -EINVAL : 0;
@@ -1451,20 +1450,13 @@ static int vpbe_display_probe(struct platform_device *pdev)
                q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
                q->min_buffers_needed = 1;
                q->lock = &disp_dev->dev[i]->opslock;
+               q->dev = disp_dev->vpbe_dev->pdev;
                err = vb2_queue_init(q);
                if (err) {
                        v4l2_err(v4l2_dev, "vb2_queue_init() failed\n");
                        goto probe_out;
                }
 
-               disp_dev->dev[i]->alloc_ctx =
-                       vb2_dma_contig_init_ctx(disp_dev->vpbe_dev->pdev);
-               if (IS_ERR(disp_dev->dev[i]->alloc_ctx)) {
-                       v4l2_err(v4l2_dev, "Failed to get the context\n");
-                       err = PTR_ERR(disp_dev->dev[i]->alloc_ctx);
-                       goto probe_out;
-               }
-
                INIT_LIST_HEAD(&disp_dev->dev[i]->dma_queue);
 
                if (register_device(disp_dev->dev[i], disp_dev, pdev)) {
@@ -1482,7 +1474,6 @@ probe_out:
        for (k = 0; k < VPBE_DISPLAY_MAX_DEVICES; k++) {
                /* Unregister video device */
                if (disp_dev->dev[k] != NULL) {
-                       vb2_dma_contig_cleanup_ctx(disp_dev->dev[k]->alloc_ctx);
                        video_unregister_device(&disp_dev->dev[k]->video_dev);
                        kfree(disp_dev->dev[k]);
                }
@@ -1510,7 +1501,6 @@ static int vpbe_display_remove(struct platform_device *pdev)
        for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {
                /* Get the pointer to the layer object */
                vpbe_display_layer = disp_dev->dev[i];
-               vb2_dma_contig_cleanup_ctx(vpbe_display_layer->alloc_ctx);
                /* Unregister video device */
                video_unregister_device(&vpbe_display_layer->video_dev);
 
index 08f7028c7560af37064a9bf5875d6051534abd1b..d5afab0dd9e500deb249e5cd47e7b8caa6ddd2c7 100644 (file)
@@ -133,7 +133,6 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq,
 
        *nplanes = 1;
        sizes[0] = size;
-       alloc_ctxs[0] = common->alloc_ctx;
 
        /* Calculate the offset for Y and C data in the buffer */
        vpif_calculate_offsets(ch);
@@ -1371,6 +1370,7 @@ static int vpif_probe_complete(void)
                q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
                q->min_buffers_needed = 1;
                q->lock = &common->lock;
+               q->dev = vpif_dev;
 
                err = vb2_queue_init(q);
                if (err) {
@@ -1378,13 +1378,6 @@ static int vpif_probe_complete(void)
                        goto probe_out;
                }
 
-               common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev);
-               if (IS_ERR(common->alloc_ctx)) {
-                       vpif_err("Failed to get the context\n");
-                       err = PTR_ERR(common->alloc_ctx);
-                       goto probe_out;
-               }
-
                INIT_LIST_HEAD(&common->dma_queue);
 
                /* Initialize the video_device structure */
@@ -1412,7 +1405,6 @@ probe_out:
                /* Get the pointer to the channel object */
                ch = vpif_obj.dev[k];
                common = &ch->common[k];
-               vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
                /* Unregister video device */
                video_unregister_device(&ch->video_dev);
        }
@@ -1546,7 +1538,6 @@ static int vpif_remove(struct platform_device *device)
                /* Get the pointer to the channel object */
                ch = vpif_obj.dev[i];
                common = &ch->common[VPIF_VIDEO_INDEX];
-               vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
                /* Unregister video device */
                video_unregister_device(&ch->video_dev);
                kfree(vpif_obj.dev[i]);
index 4a7600929b61318f7808b85fbf8f9a14eefa290c..9e35b6771d22a04cc333938be45eb0dafa49b21f 100644 (file)
@@ -65,8 +65,6 @@ struct common_obj {
        struct v4l2_format fmt;
        /* 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;
        /* Used in video-buf */
index f40755cf1bf2650683583ab4c2684e72e10df175..5d77884b120ab0a933e33ec50204c457176b1190 100644 (file)
@@ -126,7 +126,6 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq,
 
        *nplanes = 1;
        sizes[0] = size;
-       alloc_ctxs[0] = common->alloc_ctx;
 
        /* Calculate the offset for Y and C data  in the buffer */
        vpif_calculate_offsets(ch);
@@ -1191,19 +1190,13 @@ static int vpif_probe_complete(void)
                q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
                q->min_buffers_needed = 1;
                q->lock = &common->lock;
+               q->dev = vpif_dev;
                err = vb2_queue_init(q);
                if (err) {
                        vpif_err("vpif_display: vb2_queue_init() failed\n");
                        goto probe_out;
                }
 
-               common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev);
-               if (IS_ERR(common->alloc_ctx)) {
-                       vpif_err("Failed to get the context\n");
-                       err = PTR_ERR(common->alloc_ctx);
-                       goto probe_out;
-               }
-
                INIT_LIST_HEAD(&common->dma_queue);
 
                /* register video device */
@@ -1233,7 +1226,6 @@ probe_out:
        for (k = 0; k < j; k++) {
                ch = vpif_obj.dev[k];
                common = &ch->common[k];
-               vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
                video_unregister_device(&ch->video_dev);
        }
        return err;
@@ -1355,7 +1347,6 @@ static int vpif_remove(struct platform_device *device)
                /* Get the pointer to the channel object */
                ch = vpif_obj.dev[i];
                common = &ch->common[VPIF_VIDEO_INDEX];
-               vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
                /* Unregister video device */
                video_unregister_device(&ch->video_dev);
                kfree(vpif_obj.dev[i]);
index e7a1723a1b7ab384fe745b8c7a237b6121321c1d..af2765fdcea8bb58ec184b46713a5e81a1551a27 100644 (file)
@@ -74,8 +74,6 @@ struct common_obj {
        struct v4l2_format fmt;                 /* Used to store the format */
        struct vb2_queue buffer_queue;          /* Buffer queue used in
                                                 * video-buf */
-       /* allocator-specific contexts for each plane */
-       struct vb2_alloc_ctx *alloc_ctx;
 
        struct list_head dma_queue;             /* Queue of filled frames */
        spinlock_t irqlock;                     /* Used in video-buf */
index dad3b031f7782813ba8640eb5e8b6a30d293a065..4c5c529aafa76943730c880d394008180e6a2a02 100644 (file)
@@ -979,7 +979,6 @@ static int rvin_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
 {
        struct rvin_dev *vin = vb2_get_drv_priv(vq);
 
-       alloc_ctxs[0] = vin->alloc_ctx;
        /* Make sure the image size is large enough. */
        if (*nplanes)
                return sizes[0] < vin->format.sizeimage ? -EINVAL : 0;
@@ -1129,9 +1128,6 @@ static struct vb2_ops rvin_qops = {
 
 void rvin_dma_remove(struct rvin_dev *vin)
 {
-       if (!IS_ERR_OR_NULL(vin->alloc_ctx))
-               vb2_dma_contig_cleanup_ctx(vin->alloc_ctx);
-
        mutex_destroy(&vin->lock);
 
        v4l2_device_unregister(&vin->v4l2_dev);
@@ -1158,12 +1154,6 @@ int rvin_dma_probe(struct rvin_dev *vin, int irq)
                vin->queue_buf[i] = NULL;
 
        /* buffer queue */
-       vin->alloc_ctx = vb2_dma_contig_init_ctx(vin->dev);
-       if (IS_ERR(vin->alloc_ctx)) {
-               ret = PTR_ERR(vin->alloc_ctx);
-               goto error;
-       }
-
        q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        q->io_modes = VB2_MMAP | VB2_READ | VB2_DMABUF;
        q->lock = &vin->lock;
@@ -1173,6 +1163,7 @@ int rvin_dma_probe(struct rvin_dev *vin, int irq)
        q->mem_ops = &vb2_dma_contig_memops;
        q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        q->min_buffers_needed = 2;
+       q->dev = vin->dev;
 
        ret = vb2_queue_init(q);
        if (ret < 0) {
index a6dd6db246ab924bf6f22ab91a797d8b98598c76..31ad39a39937c2a93afe29c411f25e18f8eb196e 100644 (file)
@@ -94,7 +94,6 @@ struct rvin_graph_entity {
  *
  * @lock:              protects @queue
  * @queue:             vb2 buffers queue
- * @alloc_ctx:         allocation context for the vb2 @queue
  *
  * @qlock:             protects @queue_buf, @buf_list, @continuous, @sequence
  *                     @state
@@ -125,7 +124,6 @@ struct rvin_dev {
 
        struct mutex lock;
        struct vb2_queue queue;
-       struct vb2_alloc_ctx *alloc_ctx;
 
        spinlock_t qlock;
        struct vb2_v4l2_buffer *queue_buf[HW_BUFFER_NUM];
index e14a9370b67e0fc713d0823b2230935f37982094..12783fd823f8a8974ba8f787c69a673809096a8d 100644 (file)
@@ -81,8 +81,6 @@ struct vpbe_layer {
         * 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;
        /* Used in video-buf */