]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] media/platform: convert drivers to use the new vb2_queue dev field
authorHans Verkuil <hans.verkuil@cisco.com>
Tue, 16 Feb 2016 09:30:19 +0000 (07:30 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 8 Jul 2016 17:42:48 +0000 (14:42 -0300)
Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
14 files changed:
drivers/media/platform/exynos4-is/fimc-capture.c
drivers/media/platform/exynos4-is/fimc-core.c
drivers/media/platform/exynos4-is/fimc-core.h
drivers/media/platform/exynos4-is/fimc-is.c
drivers/media/platform/exynos4-is/fimc-is.h
drivers/media/platform/exynos4-is/fimc-isp-video.c
drivers/media/platform/exynos4-is/fimc-isp.h
drivers/media/platform/exynos4-is/fimc-lite.c
drivers/media/platform/exynos4-is/fimc-lite.h
drivers/media/platform/exynos4-is/fimc-m2m.c
drivers/media/platform/s5p-mfc/s5p_mfc.c
drivers/media/platform/s5p-mfc/s5p_mfc_common.h
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c

index bf47d3b9cbe77e5dce9b1955c8280070afb5e3d0..512b254914bcef49ff2a5a5baa75543b1bf5cb18 100644 (file)
@@ -354,11 +354,9 @@ static int queue_setup(struct vb2_queue *vq,
        if (*num_planes) {
                if (*num_planes != fmt->memplanes)
                        return -EINVAL;
-               for (i = 0; i < *num_planes; i++) {
+               for (i = 0; i < *num_planes; i++)
                        if (sizes[i] < (wh * fmt->depth[i]) / 8)
                                return -EINVAL;
-                       allocators[i] = ctx->fimc_dev->alloc_ctx;
-               }
                return 0;
        }
 
@@ -371,8 +369,6 @@ static int queue_setup(struct vb2_queue *vq,
                        sizes[i] = frame->payload[i];
                else
                        sizes[i] = max_t(u32, size, frame->payload[i]);
-
-               allocators[i] = ctx->fimc_dev->alloc_ctx;
        }
 
        return 0;
@@ -1779,6 +1775,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc,
        q->buf_struct_size = sizeof(struct fimc_vid_buffer);
        q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        q->lock = &fimc->lock;
+       q->dev = &fimc->pdev->dev;
 
        ret = vb2_queue_init(q);
        if (ret)
index 368f44f24d4c808db780a6b22b0442301240e820..8f89ca21b63193458e9e70d9c4e7ba0b76d20c86 100644 (file)
@@ -1018,20 +1018,11 @@ static int fimc_probe(struct platform_device *pdev)
                        goto err_sd;
        }
 
-       /* Initialize contiguous memory allocator */
        vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
-       fimc->alloc_ctx = vb2_dma_contig_init_ctx(dev);
-       if (IS_ERR(fimc->alloc_ctx)) {
-               ret = PTR_ERR(fimc->alloc_ctx);
-               goto err_gclk;
-       }
 
        dev_dbg(dev, "FIMC.%d registered successfully\n", fimc->id);
        return 0;
 
-err_gclk:
-       if (!pm_runtime_enabled(dev))
-               clk_disable(fimc->clock[CLK_GATE]);
 err_sd:
        fimc_unregister_capture_subdev(fimc);
 err_sclk:
@@ -1124,7 +1115,6 @@ static int fimc_remove(struct platform_device *pdev)
        pm_runtime_set_suspended(&pdev->dev);
 
        fimc_unregister_capture_subdev(fimc);
-       vb2_dma_contig_cleanup_ctx(fimc->alloc_ctx);
        vb2_dma_contig_clear_max_seg_size(&pdev->dev);
 
        clk_disable(fimc->clock[CLK_BUS]);
index 6b7435453d2a31e6282d17f99b7504611b154ef0..5615fefbf7af0eda5c117554ed69a9088c98ac85 100644 (file)
@@ -307,7 +307,6 @@ struct fimc_m2m_device {
  */
 struct fimc_vid_cap {
        struct fimc_ctx                 *ctx;
-       struct vb2_alloc_ctx            *alloc_ctx;
        struct v4l2_subdev              subdev;
        struct exynos_video_entity      ve;
        struct media_pad                vd_pad;
@@ -417,7 +416,6 @@ struct fimc_ctx;
  * @m2m:       memory-to-memory V4L2 device information
  * @vid_cap:   camera capture device information
  * @state:     flags used to synchronize m2m and capture mode operation
- * @alloc_ctx: videobuf2 memory allocator context
  * @pipeline:  fimc video capture pipeline data structure
  */
 struct fimc_dev {
@@ -436,7 +434,6 @@ struct fimc_dev {
        struct fimc_m2m_device          m2m;
        struct fimc_vid_cap             vid_cap;
        unsigned long                   state;
-       struct vb2_alloc_ctx            *alloc_ctx;
 };
 
 /**
index bd98b56318b70865d2f0590001b01612a0308ac1..32ca55f166778959dbd8b1f50853d528243f1e6c 100644 (file)
@@ -204,9 +204,6 @@ static int fimc_is_register_subdevs(struct fimc_is *is)
        if (ret < 0)
                return ret;
 
-       /* Initialize memory allocator context for the ISP DMA. */
-       is->isp.alloc_ctx = is->alloc_ctx;
-
        for_each_compatible_node(i2c_bus, NULL, FIMC_IS_I2C_COMPATIBLE) {
                for_each_available_child_of_node(i2c_bus, child) {
                        ret = fimc_is_parse_sensor_config(is, index, child);
@@ -848,18 +845,13 @@ static int fimc_is_probe(struct platform_device *pdev)
                goto err_pm;
 
        vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
-       is->alloc_ctx = vb2_dma_contig_init_ctx(dev);
-       if (IS_ERR(is->alloc_ctx)) {
-               ret = PTR_ERR(is->alloc_ctx);
-               goto err_pm;
-       }
        /*
         * Register FIMC-IS V4L2 subdevs to this driver. The video nodes
         * will be created within the subdev's registered() callback.
         */
        ret = fimc_is_register_subdevs(is);
        if (ret < 0)
-               goto err_vb;
+               goto err_pm;
 
        ret = fimc_is_debugfs_create(is);
        if (ret < 0)
@@ -878,8 +870,6 @@ err_dfs:
        fimc_is_debugfs_remove(is);
 err_sd:
        fimc_is_unregister_subdevs(is);
-err_vb:
-       vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
 err_pm:
        if (!pm_runtime_enabled(dev))
                fimc_is_runtime_suspend(dev);
@@ -940,7 +930,6 @@ static int fimc_is_remove(struct platform_device *pdev)
                fimc_is_runtime_suspend(dev);
        free_irq(is->irq, is);
        fimc_is_unregister_subdevs(is);
-       vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
        vb2_dma_contig_clear_max_seg_size(dev);
        fimc_is_put_clocks(is);
        fimc_is_debugfs_remove(is);
index 386eb49ece7e23bff138eecdcaf07bbc8249c16b..3a82c6a214c7df7b25f247d57829b5071de788bd 100644 (file)
@@ -233,7 +233,6 @@ struct chain_config {
  * @pdev: pointer to FIMC-IS platform device
  * @pctrl: pointer to pinctrl structure for this device
  * @v4l2_dev: pointer to top the level v4l2_device
- * @alloc_ctx: videobuf2 memory allocator context
  * @lock: mutex serializing video device and the subdev operations
  * @slock: spinlock protecting this data structure and the hw registers
  * @clocks: FIMC-LITE gate clock
@@ -256,7 +255,6 @@ struct fimc_is {
        struct fimc_is_sensor           sensor[FIMC_IS_SENSORS_NUM];
        struct fimc_is_setfile          setfile;
 
-       struct vb2_alloc_ctx            *alloc_ctx;
        struct v4l2_ctrl_handler        ctrl_handler;
 
        struct mutex                    lock;
index c0816728cbfe1d2be7c6eb5c987a4ac3b8213a74..abc338962d809ec5f722b40a3513aa336dd798e8 100644 (file)
@@ -57,20 +57,16 @@ static int isp_video_capture_queue_setup(struct vb2_queue *vq,
        if (*num_planes) {
                if (*num_planes != fmt->memplanes)
                        return -EINVAL;
-               for (i = 0; i < *num_planes; i++) {
+               for (i = 0; i < *num_planes; i++)
                        if (sizes[i] < (wh * fmt->depth[i]) / 8)
                                return -EINVAL;
-                       allocators[i] = isp->alloc_ctx;
-               }
                return 0;
        }
 
        *num_planes = fmt->memplanes;
 
-       for (i = 0; i < fmt->memplanes; i++) {
+       for (i = 0; i < fmt->memplanes; i++)
                sizes[i] = (wh * fmt->depth[i]) / 8;
-               allocators[i] = isp->alloc_ctx;
-       }
 
        return 0;
 }
@@ -597,6 +593,7 @@ int fimc_isp_video_device_register(struct fimc_isp *isp,
        q->drv_priv = isp;
        q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        q->lock = &isp->video_lock;
+       q->dev = &isp->pdev->dev;
 
        ret = vb2_queue_init(q);
        if (ret < 0)
index e0686b5f1bf8697660e66b7d529ecc9090e7a237..3cdd52491294321d30b9e73b19da1ec32e8c579c 100644 (file)
@@ -148,7 +148,6 @@ struct fimc_is_video {
 /**
  * struct fimc_isp - FIMC-IS ISP data structure
  * @pdev: pointer to FIMC-IS platform device
- * @alloc_ctx: videobuf2 memory allocator context
  * @subdev: ISP v4l2_subdev
  * @subdev_pads: the ISP subdev media pads
  * @test_pattern: test pattern controls
@@ -161,7 +160,6 @@ struct fimc_is_video {
  */
 struct fimc_isp {
        struct platform_device          *pdev;
-       struct vb2_alloc_ctx            *alloc_ctx;
        struct v4l2_subdev              subdev;
        struct media_pad                subdev_pads[FIMC_ISP_SD_PADS_NUM];
        struct v4l2_mbus_framefmt       src_fmt;
index 27cb620cb714d514ceecc7ecb7972c0ce09d338a..f5a27a90e9d10788e2087f1cbd4ed2fed22b9f42 100644 (file)
@@ -371,20 +371,16 @@ static int queue_setup(struct vb2_queue *vq,
        if (*num_planes) {
                if (*num_planes != fmt->memplanes)
                        return -EINVAL;
-               for (i = 0; i < *num_planes; i++) {
+               for (i = 0; i < *num_planes; i++)
                        if (sizes[i] < (wh * fmt->depth[i]) / 8)
                                return -EINVAL;
-                       allocators[i] = fimc->alloc_ctx;
-               }
                return 0;
        }
 
        *num_planes = fmt->memplanes;
 
-       for (i = 0; i < fmt->memplanes; i++) {
+       for (i = 0; i < fmt->memplanes; i++)
                sizes[i] = (wh * fmt->depth[i]) / 8;
-               allocators[i] = fimc->alloc_ctx;
-       }
 
        return 0;
 }
@@ -1300,6 +1296,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)
        q->drv_priv = fimc;
        q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
        q->lock = &fimc->lock;
+       q->dev = &fimc->pdev->dev;
 
        ret = vb2_queue_init(q);
        if (ret < 0)
@@ -1552,11 +1549,6 @@ static int fimc_lite_probe(struct platform_device *pdev)
        }
 
        vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
-       fimc->alloc_ctx = vb2_dma_contig_init_ctx(dev);
-       if (IS_ERR(fimc->alloc_ctx)) {
-               ret = PTR_ERR(fimc->alloc_ctx);
-               goto err_clk_dis;
-       }
 
        fimc_lite_set_default_config(fimc);
 
@@ -1564,9 +1556,6 @@ static int fimc_lite_probe(struct platform_device *pdev)
                fimc->index);
        return 0;
 
-err_clk_dis:
-       if (!pm_runtime_enabled(dev))
-               clk_disable(fimc->clock);
 err_sd:
        fimc_lite_unregister_capture_subdev(fimc);
 err_clk_put:
@@ -1652,7 +1641,6 @@ static int fimc_lite_remove(struct platform_device *pdev)
        pm_runtime_disable(dev);
        pm_runtime_set_suspended(dev);
        fimc_lite_unregister_capture_subdev(fimc);
-       vb2_dma_contig_cleanup_ctx(fimc->alloc_ctx);
        vb2_dma_contig_clear_max_seg_size(dev);
        fimc_lite_clk_put(fimc);
 
index 11690d563e06b7f830bca13a26daa75e2511d6b0..9ae1e96a1bc7b1f7d3ee00770379d5fd51c1aab1 100644 (file)
@@ -113,7 +113,6 @@ struct flite_buffer {
  * @ve: exynos video device entity structure
  * @v4l2_dev: pointer to top the level v4l2_device
  * @fh: v4l2 file handle
- * @alloc_ctx: videobuf2 memory allocator context
  * @subdev: FIMC-LITE subdev
  * @vd_pad: media (sink) pad for the capture video node
  * @subdev_pads: the subdev media pads
@@ -148,7 +147,6 @@ struct fimc_lite {
        struct exynos_video_entity ve;
        struct v4l2_device      *v4l2_dev;
        struct v4l2_fh          fh;
-       struct vb2_alloc_ctx    *alloc_ctx;
        struct v4l2_subdev      subdev;
        struct media_pad        vd_pad;
        struct media_pad        subdev_pads[FLITE_SD_PADS_NUM];
index ec1c762b91d5095029d2fe6a24d40df1a15fca55..f4f76225ffed612f49d62d22c4765e02cacfcc9a 100644 (file)
@@ -191,10 +191,8 @@ static int fimc_queue_setup(struct vb2_queue *vq,
                return -EINVAL;
 
        *num_planes = f->fmt->memplanes;
-       for (i = 0; i < f->fmt->memplanes; i++) {
+       for (i = 0; i < f->fmt->memplanes; i++)
                sizes[i] = f->payload[i];
-               allocators[i] = ctx->fimc_dev->alloc_ctx;
-       }
        return 0;
 }
 
@@ -558,6 +556,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
        src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
        src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
        src_vq->lock = &ctx->fimc_dev->lock;
+       src_vq->dev = &ctx->fimc_dev->pdev->dev;
 
        ret = vb2_queue_init(src_vq);
        if (ret)
@@ -571,6 +570,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
        dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
        dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
        dst_vq->lock = &ctx->fimc_dev->lock;
+       dst_vq->dev = &ctx->fimc_dev->pdev->dev;
 
        return vb2_queue_init(dst_vq);
 }
index c6f92c464378da0ea70d1dc495816b5192815507..e3f104fafd0ae864c2f4e5f955dee50ee6d4a5e5 100644 (file)
@@ -1192,23 +1192,13 @@ static int s5p_mfc_probe(struct platform_device *pdev)
        }
 
        vb2_dma_contig_set_max_seg_size(dev->mem_dev_l, DMA_BIT_MASK(32));
-       dev->alloc_ctx[0] = vb2_dma_contig_init_ctx(dev->mem_dev_l);
-       if (IS_ERR(dev->alloc_ctx[0])) {
-               ret = PTR_ERR(dev->alloc_ctx[0]);
-               goto err_res;
-       }
        vb2_dma_contig_set_max_seg_size(dev->mem_dev_r, DMA_BIT_MASK(32));
-       dev->alloc_ctx[1] = vb2_dma_contig_init_ctx(dev->mem_dev_r);
-       if (IS_ERR(dev->alloc_ctx[1])) {
-               ret = PTR_ERR(dev->alloc_ctx[1]);
-               goto err_mem_init_ctx_1;
-       }
 
        mutex_init(&dev->mfc_mutex);
 
        ret = s5p_mfc_alloc_firmware(dev);
        if (ret)
-               goto err_alloc_fw;
+               goto err_res;
 
        ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
        if (ret)
@@ -1294,10 +1284,6 @@ err_dec_alloc:
        v4l2_device_unregister(&dev->v4l2_dev);
 err_v4l2_dev_reg:
        s5p_mfc_release_firmware(dev);
-err_alloc_fw:
-       vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[1]);
-err_mem_init_ctx_1:
-       vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]);
 err_res:
        s5p_mfc_final_pm(dev);
 err_dma:
@@ -1325,8 +1311,6 @@ static int s5p_mfc_remove(struct platform_device *pdev)
        video_device_release(dev->vfd_dec);
        v4l2_device_unregister(&dev->v4l2_dev);
        s5p_mfc_release_firmware(dev);
-       vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]);
-       vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[1]);
        s5p_mfc_unconfigure_dma_memory(dev);
        vb2_dma_contig_clear_max_seg_size(dev->mem_dev_l);
        vb2_dma_contig_clear_max_seg_size(dev->mem_dev_r);
index a10dcd244ff0ef10b3bae2ceaf415cc5b252300b..373e346fce3e689ee42921aa15af60d0dd5c0507 100644 (file)
@@ -287,7 +287,6 @@ struct s5p_mfc_priv_buf {
  * @watchdog_cnt:      counter for the watchdog
  * @watchdog_workqueue:        workqueue for the watchdog
  * @watchdog_work:     worker for the watchdog
- * @alloc_ctx:         videobuf2 allocator contexts for two memory banks
  * @enter_suspend:     flag set when entering suspend
  * @ctx_buf:           common context memory (MFCv6)
  * @warn_start:                hardware error code from which warnings start
@@ -330,7 +329,6 @@ struct s5p_mfc_dev {
        struct timer_list watchdog_timer;
        struct workqueue_struct *watchdog_workqueue;
        struct work_struct watchdog_work;
-       void *alloc_ctx[2];
        unsigned long enter_suspend;
 
        struct s5p_mfc_priv_buf ctx_buf;
index 889d1c8c91e37aedc5d8c222a15b36ec8017f92a..ae98a5568b695583e8fc267907bc9c55cc7836ba 100644 (file)
@@ -931,16 +931,14 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
                psize[1] = ctx->chroma_size;
 
                if (IS_MFCV6_PLUS(dev))
-                       allocators[0] =
-                               ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX];
+                       allocators[0] = &ctx->dev->mem_dev_l;
                else
-                       allocators[0] =
-                               ctx->dev->alloc_ctx[MFC_BANK2_ALLOC_CTX];
-               allocators[1] = ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX];
+                       allocators[0] = &ctx->dev->mem_dev_r;
+               allocators[1] = &ctx->dev->mem_dev_l;
        } else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
                   ctx->state == MFCINST_INIT) {
                psize[0] = ctx->dec_src_buf_size;
-               allocators[0] = ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX];
+               allocators[0] = &ctx->dev->mem_dev_l;
        } else {
                mfc_err("This video node is dedicated to decoding. Decoding not initialized\n");
                return -EINVAL;
index fd961515a908408121e85debebe29ef29b6ffb67..b95796a0cc338388ce1f2078b4c953228b983eb6 100644 (file)
@@ -1832,7 +1832,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
                if (*buf_count > MFC_MAX_BUFFERS)
                        *buf_count = MFC_MAX_BUFFERS;
                psize[0] = ctx->enc_dst_buf_size;
-               allocators[0] = ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX];
+               allocators[0] = &ctx->dev->mem_dev_l;
        } else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
                if (ctx->src_fmt)
                        *plane_count = ctx->src_fmt->num_planes;
@@ -1848,15 +1848,11 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
                psize[1] = ctx->chroma_size;
 
                if (IS_MFCV6_PLUS(dev)) {
-                       allocators[0] =
-                               ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX];
-                       allocators[1] =
-                               ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX];
+                       allocators[0] = &ctx->dev->mem_dev_l;
+                       allocators[1] = &ctx->dev->mem_dev_l;
                } else {
-                       allocators[0] =
-                               ctx->dev->alloc_ctx[MFC_BANK2_ALLOC_CTX];
-                       allocators[1] =
-                               ctx->dev->alloc_ctx[MFC_BANK2_ALLOC_CTX];
+                       allocators[0] = &ctx->dev->mem_dev_r;
+                       allocators[1] = &ctx->dev->mem_dev_r;
                }
        } else {
                mfc_err("invalid queue type: %d\n", vq->type);