aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2016-02-16 04:30:19 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-08 13:42:48 -0400
commit2548fee63d9eb43299dacd0ca30dd9d8f407d795 (patch)
tree95f791b18feeac6321c66e00ba2b2988cf4040a5
parentc781e4a565a6791d3b516d64d9693804ef4a49b8 (diff)
[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: 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>
-rw-r--r--drivers/media/platform/exynos4-is/fimc-capture.c7
-rw-r--r--drivers/media/platform/exynos4-is/fimc-core.c10
-rw-r--r--drivers/media/platform/exynos4-is/fimc-core.h3
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is.c13
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is.h2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-isp-video.c9
-rw-r--r--drivers/media/platform/exynos4-is/fimc-isp.h2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.c18
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.h2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-m2m.c6
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c18
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_common.h2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_dec.c10
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c14
14 files changed, 22 insertions, 94 deletions
diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c
index bf47d3b9cbe7..512b254914bc 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -354,11 +354,9 @@ static int queue_setup(struct vb2_queue *vq,
354 if (*num_planes) { 354 if (*num_planes) {
355 if (*num_planes != fmt->memplanes) 355 if (*num_planes != fmt->memplanes)
356 return -EINVAL; 356 return -EINVAL;
357 for (i = 0; i < *num_planes; i++) { 357 for (i = 0; i < *num_planes; i++)
358 if (sizes[i] < (wh * fmt->depth[i]) / 8) 358 if (sizes[i] < (wh * fmt->depth[i]) / 8)
359 return -EINVAL; 359 return -EINVAL;
360 allocators[i] = ctx->fimc_dev->alloc_ctx;
361 }
362 return 0; 360 return 0;
363 } 361 }
364 362
@@ -371,8 +369,6 @@ static int queue_setup(struct vb2_queue *vq,
371 sizes[i] = frame->payload[i]; 369 sizes[i] = frame->payload[i];
372 else 370 else
373 sizes[i] = max_t(u32, size, frame->payload[i]); 371 sizes[i] = max_t(u32, size, frame->payload[i]);
374
375 allocators[i] = ctx->fimc_dev->alloc_ctx;
376 } 372 }
377 373
378 return 0; 374 return 0;
@@ -1779,6 +1775,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc,
1779 q->buf_struct_size = sizeof(struct fimc_vid_buffer); 1775 q->buf_struct_size = sizeof(struct fimc_vid_buffer);
1780 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1776 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1781 q->lock = &fimc->lock; 1777 q->lock = &fimc->lock;
1778 q->dev = &fimc->pdev->dev;
1782 1779
1783 ret = vb2_queue_init(q); 1780 ret = vb2_queue_init(q);
1784 if (ret) 1781 if (ret)
diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c
index 368f44f24d4c..8f89ca21b631 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -1018,20 +1018,11 @@ static int fimc_probe(struct platform_device *pdev)
1018 goto err_sd; 1018 goto err_sd;
1019 } 1019 }
1020 1020
1021 /* Initialize contiguous memory allocator */
1022 vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32)); 1021 vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
1023 fimc->alloc_ctx = vb2_dma_contig_init_ctx(dev);
1024 if (IS_ERR(fimc->alloc_ctx)) {
1025 ret = PTR_ERR(fimc->alloc_ctx);
1026 goto err_gclk;
1027 }
1028 1022
1029 dev_dbg(dev, "FIMC.%d registered successfully\n", fimc->id); 1023 dev_dbg(dev, "FIMC.%d registered successfully\n", fimc->id);
1030 return 0; 1024 return 0;
1031 1025
1032err_gclk:
1033 if (!pm_runtime_enabled(dev))
1034 clk_disable(fimc->clock[CLK_GATE]);
1035err_sd: 1026err_sd:
1036 fimc_unregister_capture_subdev(fimc); 1027 fimc_unregister_capture_subdev(fimc);
1037err_sclk: 1028err_sclk:
@@ -1124,7 +1115,6 @@ static int fimc_remove(struct platform_device *pdev)
1124 pm_runtime_set_suspended(&pdev->dev); 1115 pm_runtime_set_suspended(&pdev->dev);
1125 1116
1126 fimc_unregister_capture_subdev(fimc); 1117 fimc_unregister_capture_subdev(fimc);
1127 vb2_dma_contig_cleanup_ctx(fimc->alloc_ctx);
1128 vb2_dma_contig_clear_max_seg_size(&pdev->dev); 1118 vb2_dma_contig_clear_max_seg_size(&pdev->dev);
1129 1119
1130 clk_disable(fimc->clock[CLK_BUS]); 1120 clk_disable(fimc->clock[CLK_BUS]);
diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h
index 6b7435453d2a..5615fefbf7af 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.h
+++ b/drivers/media/platform/exynos4-is/fimc-core.h
@@ -307,7 +307,6 @@ struct fimc_m2m_device {
307 */ 307 */
308struct fimc_vid_cap { 308struct fimc_vid_cap {
309 struct fimc_ctx *ctx; 309 struct fimc_ctx *ctx;
310 struct vb2_alloc_ctx *alloc_ctx;
311 struct v4l2_subdev subdev; 310 struct v4l2_subdev subdev;
312 struct exynos_video_entity ve; 311 struct exynos_video_entity ve;
313 struct media_pad vd_pad; 312 struct media_pad vd_pad;
@@ -417,7 +416,6 @@ struct fimc_ctx;
417 * @m2m: memory-to-memory V4L2 device information 416 * @m2m: memory-to-memory V4L2 device information
418 * @vid_cap: camera capture device information 417 * @vid_cap: camera capture device information
419 * @state: flags used to synchronize m2m and capture mode operation 418 * @state: flags used to synchronize m2m and capture mode operation
420 * @alloc_ctx: videobuf2 memory allocator context
421 * @pipeline: fimc video capture pipeline data structure 419 * @pipeline: fimc video capture pipeline data structure
422 */ 420 */
423struct fimc_dev { 421struct fimc_dev {
@@ -436,7 +434,6 @@ struct fimc_dev {
436 struct fimc_m2m_device m2m; 434 struct fimc_m2m_device m2m;
437 struct fimc_vid_cap vid_cap; 435 struct fimc_vid_cap vid_cap;
438 unsigned long state; 436 unsigned long state;
439 struct vb2_alloc_ctx *alloc_ctx;
440}; 437};
441 438
442/** 439/**
diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index bd98b56318b7..32ca55f16677 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -204,9 +204,6 @@ static int fimc_is_register_subdevs(struct fimc_is *is)
204 if (ret < 0) 204 if (ret < 0)
205 return ret; 205 return ret;
206 206
207 /* Initialize memory allocator context for the ISP DMA. */
208 is->isp.alloc_ctx = is->alloc_ctx;
209
210 for_each_compatible_node(i2c_bus, NULL, FIMC_IS_I2C_COMPATIBLE) { 207 for_each_compatible_node(i2c_bus, NULL, FIMC_IS_I2C_COMPATIBLE) {
211 for_each_available_child_of_node(i2c_bus, child) { 208 for_each_available_child_of_node(i2c_bus, child) {
212 ret = fimc_is_parse_sensor_config(is, index, child); 209 ret = fimc_is_parse_sensor_config(is, index, child);
@@ -848,18 +845,13 @@ static int fimc_is_probe(struct platform_device *pdev)
848 goto err_pm; 845 goto err_pm;
849 846
850 vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32)); 847 vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
851 is->alloc_ctx = vb2_dma_contig_init_ctx(dev);
852 if (IS_ERR(is->alloc_ctx)) {
853 ret = PTR_ERR(is->alloc_ctx);
854 goto err_pm;
855 }
856 /* 848 /*
857 * Register FIMC-IS V4L2 subdevs to this driver. The video nodes 849 * Register FIMC-IS V4L2 subdevs to this driver. The video nodes
858 * will be created within the subdev's registered() callback. 850 * will be created within the subdev's registered() callback.
859 */ 851 */
860 ret = fimc_is_register_subdevs(is); 852 ret = fimc_is_register_subdevs(is);
861 if (ret < 0) 853 if (ret < 0)
862 goto err_vb; 854 goto err_pm;
863 855
864 ret = fimc_is_debugfs_create(is); 856 ret = fimc_is_debugfs_create(is);
865 if (ret < 0) 857 if (ret < 0)
@@ -878,8 +870,6 @@ err_dfs:
878 fimc_is_debugfs_remove(is); 870 fimc_is_debugfs_remove(is);
879err_sd: 871err_sd:
880 fimc_is_unregister_subdevs(is); 872 fimc_is_unregister_subdevs(is);
881err_vb:
882 vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
883err_pm: 873err_pm:
884 if (!pm_runtime_enabled(dev)) 874 if (!pm_runtime_enabled(dev))
885 fimc_is_runtime_suspend(dev); 875 fimc_is_runtime_suspend(dev);
@@ -940,7 +930,6 @@ static int fimc_is_remove(struct platform_device *pdev)
940 fimc_is_runtime_suspend(dev); 930 fimc_is_runtime_suspend(dev);
941 free_irq(is->irq, is); 931 free_irq(is->irq, is);
942 fimc_is_unregister_subdevs(is); 932 fimc_is_unregister_subdevs(is);
943 vb2_dma_contig_cleanup_ctx(is->alloc_ctx);
944 vb2_dma_contig_clear_max_seg_size(dev); 933 vb2_dma_contig_clear_max_seg_size(dev);
945 fimc_is_put_clocks(is); 934 fimc_is_put_clocks(is);
946 fimc_is_debugfs_remove(is); 935 fimc_is_debugfs_remove(is);
diff --git a/drivers/media/platform/exynos4-is/fimc-is.h b/drivers/media/platform/exynos4-is/fimc-is.h
index 386eb49ece7e..3a82c6a214c7 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.h
+++ b/drivers/media/platform/exynos4-is/fimc-is.h
@@ -233,7 +233,6 @@ struct chain_config {
233 * @pdev: pointer to FIMC-IS platform device 233 * @pdev: pointer to FIMC-IS platform device
234 * @pctrl: pointer to pinctrl structure for this device 234 * @pctrl: pointer to pinctrl structure for this device
235 * @v4l2_dev: pointer to top the level v4l2_device 235 * @v4l2_dev: pointer to top the level v4l2_device
236 * @alloc_ctx: videobuf2 memory allocator context
237 * @lock: mutex serializing video device and the subdev operations 236 * @lock: mutex serializing video device and the subdev operations
238 * @slock: spinlock protecting this data structure and the hw registers 237 * @slock: spinlock protecting this data structure and the hw registers
239 * @clocks: FIMC-LITE gate clock 238 * @clocks: FIMC-LITE gate clock
@@ -256,7 +255,6 @@ struct fimc_is {
256 struct fimc_is_sensor sensor[FIMC_IS_SENSORS_NUM]; 255 struct fimc_is_sensor sensor[FIMC_IS_SENSORS_NUM];
257 struct fimc_is_setfile setfile; 256 struct fimc_is_setfile setfile;
258 257
259 struct vb2_alloc_ctx *alloc_ctx;
260 struct v4l2_ctrl_handler ctrl_handler; 258 struct v4l2_ctrl_handler ctrl_handler;
261 259
262 struct mutex lock; 260 struct mutex lock;
diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c
index c0816728cbfe..abc338962d80 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
@@ -57,20 +57,16 @@ static int isp_video_capture_queue_setup(struct vb2_queue *vq,
57 if (*num_planes) { 57 if (*num_planes) {
58 if (*num_planes != fmt->memplanes) 58 if (*num_planes != fmt->memplanes)
59 return -EINVAL; 59 return -EINVAL;
60 for (i = 0; i < *num_planes; i++) { 60 for (i = 0; i < *num_planes; i++)
61 if (sizes[i] < (wh * fmt->depth[i]) / 8) 61 if (sizes[i] < (wh * fmt->depth[i]) / 8)
62 return -EINVAL; 62 return -EINVAL;
63 allocators[i] = isp->alloc_ctx;
64 }
65 return 0; 63 return 0;
66 } 64 }
67 65
68 *num_planes = fmt->memplanes; 66 *num_planes = fmt->memplanes;
69 67
70 for (i = 0; i < fmt->memplanes; i++) { 68 for (i = 0; i < fmt->memplanes; i++)
71 sizes[i] = (wh * fmt->depth[i]) / 8; 69 sizes[i] = (wh * fmt->depth[i]) / 8;
72 allocators[i] = isp->alloc_ctx;
73 }
74 70
75 return 0; 71 return 0;
76} 72}
@@ -597,6 +593,7 @@ int fimc_isp_video_device_register(struct fimc_isp *isp,
597 q->drv_priv = isp; 593 q->drv_priv = isp;
598 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 594 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
599 q->lock = &isp->video_lock; 595 q->lock = &isp->video_lock;
596 q->dev = &isp->pdev->dev;
600 597
601 ret = vb2_queue_init(q); 598 ret = vb2_queue_init(q);
602 if (ret < 0) 599 if (ret < 0)
diff --git a/drivers/media/platform/exynos4-is/fimc-isp.h b/drivers/media/platform/exynos4-is/fimc-isp.h
index e0686b5f1bf8..3cdd52491294 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp.h
+++ b/drivers/media/platform/exynos4-is/fimc-isp.h
@@ -148,7 +148,6 @@ struct fimc_is_video {
148/** 148/**
149 * struct fimc_isp - FIMC-IS ISP data structure 149 * struct fimc_isp - FIMC-IS ISP data structure
150 * @pdev: pointer to FIMC-IS platform device 150 * @pdev: pointer to FIMC-IS platform device
151 * @alloc_ctx: videobuf2 memory allocator context
152 * @subdev: ISP v4l2_subdev 151 * @subdev: ISP v4l2_subdev
153 * @subdev_pads: the ISP subdev media pads 152 * @subdev_pads: the ISP subdev media pads
154 * @test_pattern: test pattern controls 153 * @test_pattern: test pattern controls
@@ -161,7 +160,6 @@ struct fimc_is_video {
161 */ 160 */
162struct fimc_isp { 161struct fimc_isp {
163 struct platform_device *pdev; 162 struct platform_device *pdev;
164 struct vb2_alloc_ctx *alloc_ctx;
165 struct v4l2_subdev subdev; 163 struct v4l2_subdev subdev;
166 struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM]; 164 struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM];
167 struct v4l2_mbus_framefmt src_fmt; 165 struct v4l2_mbus_framefmt src_fmt;
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index 27cb620cb714..f5a27a90e9d1 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -371,20 +371,16 @@ static int queue_setup(struct vb2_queue *vq,
371 if (*num_planes) { 371 if (*num_planes) {
372 if (*num_planes != fmt->memplanes) 372 if (*num_planes != fmt->memplanes)
373 return -EINVAL; 373 return -EINVAL;
374 for (i = 0; i < *num_planes; i++) { 374 for (i = 0; i < *num_planes; i++)
375 if (sizes[i] < (wh * fmt->depth[i]) / 8) 375 if (sizes[i] < (wh * fmt->depth[i]) / 8)
376 return -EINVAL; 376 return -EINVAL;
377 allocators[i] = fimc->alloc_ctx;
378 }
379 return 0; 377 return 0;
380 } 378 }
381 379
382 *num_planes = fmt->memplanes; 380 *num_planes = fmt->memplanes;
383 381
384 for (i = 0; i < fmt->memplanes; i++) { 382 for (i = 0; i < fmt->memplanes; i++)
385 sizes[i] = (wh * fmt->depth[i]) / 8; 383 sizes[i] = (wh * fmt->depth[i]) / 8;
386 allocators[i] = fimc->alloc_ctx;
387 }
388 384
389 return 0; 385 return 0;
390} 386}
@@ -1300,6 +1296,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)
1300 q->drv_priv = fimc; 1296 q->drv_priv = fimc;
1301 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1297 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1302 q->lock = &fimc->lock; 1298 q->lock = &fimc->lock;
1299 q->dev = &fimc->pdev->dev;
1303 1300
1304 ret = vb2_queue_init(q); 1301 ret = vb2_queue_init(q);
1305 if (ret < 0) 1302 if (ret < 0)
@@ -1552,11 +1549,6 @@ static int fimc_lite_probe(struct platform_device *pdev)
1552 } 1549 }
1553 1550
1554 vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32)); 1551 vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));
1555 fimc->alloc_ctx = vb2_dma_contig_init_ctx(dev);
1556 if (IS_ERR(fimc->alloc_ctx)) {
1557 ret = PTR_ERR(fimc->alloc_ctx);
1558 goto err_clk_dis;
1559 }
1560 1552
1561 fimc_lite_set_default_config(fimc); 1553 fimc_lite_set_default_config(fimc);
1562 1554
@@ -1564,9 +1556,6 @@ static int fimc_lite_probe(struct platform_device *pdev)
1564 fimc->index); 1556 fimc->index);
1565 return 0; 1557 return 0;
1566 1558
1567err_clk_dis:
1568 if (!pm_runtime_enabled(dev))
1569 clk_disable(fimc->clock);
1570err_sd: 1559err_sd:
1571 fimc_lite_unregister_capture_subdev(fimc); 1560 fimc_lite_unregister_capture_subdev(fimc);
1572err_clk_put: 1561err_clk_put:
@@ -1652,7 +1641,6 @@ static int fimc_lite_remove(struct platform_device *pdev)
1652 pm_runtime_disable(dev); 1641 pm_runtime_disable(dev);
1653 pm_runtime_set_suspended(dev); 1642 pm_runtime_set_suspended(dev);
1654 fimc_lite_unregister_capture_subdev(fimc); 1643 fimc_lite_unregister_capture_subdev(fimc);
1655 vb2_dma_contig_cleanup_ctx(fimc->alloc_ctx);
1656 vb2_dma_contig_clear_max_seg_size(dev); 1644 vb2_dma_contig_clear_max_seg_size(dev);
1657 fimc_lite_clk_put(fimc); 1645 fimc_lite_clk_put(fimc);
1658 1646
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h b/drivers/media/platform/exynos4-is/fimc-lite.h
index 11690d563e06..9ae1e96a1bc7 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.h
+++ b/drivers/media/platform/exynos4-is/fimc-lite.h
@@ -113,7 +113,6 @@ struct flite_buffer {
113 * @ve: exynos video device entity structure 113 * @ve: exynos video device entity structure
114 * @v4l2_dev: pointer to top the level v4l2_device 114 * @v4l2_dev: pointer to top the level v4l2_device
115 * @fh: v4l2 file handle 115 * @fh: v4l2 file handle
116 * @alloc_ctx: videobuf2 memory allocator context
117 * @subdev: FIMC-LITE subdev 116 * @subdev: FIMC-LITE subdev
118 * @vd_pad: media (sink) pad for the capture video node 117 * @vd_pad: media (sink) pad for the capture video node
119 * @subdev_pads: the subdev media pads 118 * @subdev_pads: the subdev media pads
@@ -148,7 +147,6 @@ struct fimc_lite {
148 struct exynos_video_entity ve; 147 struct exynos_video_entity ve;
149 struct v4l2_device *v4l2_dev; 148 struct v4l2_device *v4l2_dev;
150 struct v4l2_fh fh; 149 struct v4l2_fh fh;
151 struct vb2_alloc_ctx *alloc_ctx;
152 struct v4l2_subdev subdev; 150 struct v4l2_subdev subdev;
153 struct media_pad vd_pad; 151 struct media_pad vd_pad;
154 struct media_pad subdev_pads[FLITE_SD_PADS_NUM]; 152 struct media_pad subdev_pads[FLITE_SD_PADS_NUM];
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c
index ec1c762b91d5..f4f76225ffed 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -191,10 +191,8 @@ static int fimc_queue_setup(struct vb2_queue *vq,
191 return -EINVAL; 191 return -EINVAL;
192 192
193 *num_planes = f->fmt->memplanes; 193 *num_planes = f->fmt->memplanes;
194 for (i = 0; i < f->fmt->memplanes; i++) { 194 for (i = 0; i < f->fmt->memplanes; i++)
195 sizes[i] = f->payload[i]; 195 sizes[i] = f->payload[i];
196 allocators[i] = ctx->fimc_dev->alloc_ctx;
197 }
198 return 0; 196 return 0;
199} 197}
200 198
@@ -558,6 +556,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
558 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 556 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
559 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 557 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
560 src_vq->lock = &ctx->fimc_dev->lock; 558 src_vq->lock = &ctx->fimc_dev->lock;
559 src_vq->dev = &ctx->fimc_dev->pdev->dev;
561 560
562 ret = vb2_queue_init(src_vq); 561 ret = vb2_queue_init(src_vq);
563 if (ret) 562 if (ret)
@@ -571,6 +570,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
571 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 570 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
572 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 571 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
573 dst_vq->lock = &ctx->fimc_dev->lock; 572 dst_vq->lock = &ctx->fimc_dev->lock;
573 dst_vq->dev = &ctx->fimc_dev->pdev->dev;
574 574
575 return vb2_queue_init(dst_vq); 575 return vb2_queue_init(dst_vq);
576} 576}
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index c6f92c464378..e3f104fafd0a 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -1192,23 +1192,13 @@ static int s5p_mfc_probe(struct platform_device *pdev)
1192 } 1192 }
1193 1193
1194 vb2_dma_contig_set_max_seg_size(dev->mem_dev_l, DMA_BIT_MASK(32)); 1194 vb2_dma_contig_set_max_seg_size(dev->mem_dev_l, DMA_BIT_MASK(32));
1195 dev->alloc_ctx[0] = vb2_dma_contig_init_ctx(dev->mem_dev_l);
1196 if (IS_ERR(dev->alloc_ctx[0])) {
1197 ret = PTR_ERR(dev->alloc_ctx[0]);
1198 goto err_res;
1199 }
1200 vb2_dma_contig_set_max_seg_size(dev->mem_dev_r, DMA_BIT_MASK(32)); 1195 vb2_dma_contig_set_max_seg_size(dev->mem_dev_r, DMA_BIT_MASK(32));
1201 dev->alloc_ctx[1] = vb2_dma_contig_init_ctx(dev->mem_dev_r);
1202 if (IS_ERR(dev->alloc_ctx[1])) {
1203 ret = PTR_ERR(dev->alloc_ctx[1]);
1204 goto err_mem_init_ctx_1;
1205 }
1206 1196
1207 mutex_init(&dev->mfc_mutex); 1197 mutex_init(&dev->mfc_mutex);
1208 1198
1209 ret = s5p_mfc_alloc_firmware(dev); 1199 ret = s5p_mfc_alloc_firmware(dev);
1210 if (ret) 1200 if (ret)
1211 goto err_alloc_fw; 1201 goto err_res;
1212 1202
1213 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); 1203 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
1214 if (ret) 1204 if (ret)
@@ -1294,10 +1284,6 @@ err_dec_alloc:
1294 v4l2_device_unregister(&dev->v4l2_dev); 1284 v4l2_device_unregister(&dev->v4l2_dev);
1295err_v4l2_dev_reg: 1285err_v4l2_dev_reg:
1296 s5p_mfc_release_firmware(dev); 1286 s5p_mfc_release_firmware(dev);
1297err_alloc_fw:
1298 vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[1]);
1299err_mem_init_ctx_1:
1300 vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]);
1301err_res: 1287err_res:
1302 s5p_mfc_final_pm(dev); 1288 s5p_mfc_final_pm(dev);
1303err_dma: 1289err_dma:
@@ -1325,8 +1311,6 @@ static int s5p_mfc_remove(struct platform_device *pdev)
1325 video_device_release(dev->vfd_dec); 1311 video_device_release(dev->vfd_dec);
1326 v4l2_device_unregister(&dev->v4l2_dev); 1312 v4l2_device_unregister(&dev->v4l2_dev);
1327 s5p_mfc_release_firmware(dev); 1313 s5p_mfc_release_firmware(dev);
1328 vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]);
1329 vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[1]);
1330 s5p_mfc_unconfigure_dma_memory(dev); 1314 s5p_mfc_unconfigure_dma_memory(dev);
1331 vb2_dma_contig_clear_max_seg_size(dev->mem_dev_l); 1315 vb2_dma_contig_clear_max_seg_size(dev->mem_dev_l);
1332 vb2_dma_contig_clear_max_seg_size(dev->mem_dev_r); 1316 vb2_dma_contig_clear_max_seg_size(dev->mem_dev_r);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index a10dcd244ff0..373e346fce3e 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -287,7 +287,6 @@ struct s5p_mfc_priv_buf {
287 * @watchdog_cnt: counter for the watchdog 287 * @watchdog_cnt: counter for the watchdog
288 * @watchdog_workqueue: workqueue for the watchdog 288 * @watchdog_workqueue: workqueue for the watchdog
289 * @watchdog_work: worker for the watchdog 289 * @watchdog_work: worker for the watchdog
290 * @alloc_ctx: videobuf2 allocator contexts for two memory banks
291 * @enter_suspend: flag set when entering suspend 290 * @enter_suspend: flag set when entering suspend
292 * @ctx_buf: common context memory (MFCv6) 291 * @ctx_buf: common context memory (MFCv6)
293 * @warn_start: hardware error code from which warnings start 292 * @warn_start: hardware error code from which warnings start
@@ -330,7 +329,6 @@ struct s5p_mfc_dev {
330 struct timer_list watchdog_timer; 329 struct timer_list watchdog_timer;
331 struct workqueue_struct *watchdog_workqueue; 330 struct workqueue_struct *watchdog_workqueue;
332 struct work_struct watchdog_work; 331 struct work_struct watchdog_work;
333 void *alloc_ctx[2];
334 unsigned long enter_suspend; 332 unsigned long enter_suspend;
335 333
336 struct s5p_mfc_priv_buf ctx_buf; 334 struct s5p_mfc_priv_buf ctx_buf;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 889d1c8c91e3..ae98a5568b69 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -931,16 +931,14 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
931 psize[1] = ctx->chroma_size; 931 psize[1] = ctx->chroma_size;
932 932
933 if (IS_MFCV6_PLUS(dev)) 933 if (IS_MFCV6_PLUS(dev))
934 allocators[0] = 934 allocators[0] = &ctx->dev->mem_dev_l;
935 ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX];
936 else 935 else
937 allocators[0] = 936 allocators[0] = &ctx->dev->mem_dev_r;
938 ctx->dev->alloc_ctx[MFC_BANK2_ALLOC_CTX]; 937 allocators[1] = &ctx->dev->mem_dev_l;
939 allocators[1] = ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX];
940 } else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && 938 } else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
941 ctx->state == MFCINST_INIT) { 939 ctx->state == MFCINST_INIT) {
942 psize[0] = ctx->dec_src_buf_size; 940 psize[0] = ctx->dec_src_buf_size;
943 allocators[0] = ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX]; 941 allocators[0] = &ctx->dev->mem_dev_l;
944 } else { 942 } else {
945 mfc_err("This video node is dedicated to decoding. Decoding not initialized\n"); 943 mfc_err("This video node is dedicated to decoding. Decoding not initialized\n");
946 return -EINVAL; 944 return -EINVAL;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index fd961515a908..b95796a0cc33 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1832,7 +1832,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
1832 if (*buf_count > MFC_MAX_BUFFERS) 1832 if (*buf_count > MFC_MAX_BUFFERS)
1833 *buf_count = MFC_MAX_BUFFERS; 1833 *buf_count = MFC_MAX_BUFFERS;
1834 psize[0] = ctx->enc_dst_buf_size; 1834 psize[0] = ctx->enc_dst_buf_size;
1835 allocators[0] = ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX]; 1835 allocators[0] = &ctx->dev->mem_dev_l;
1836 } else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 1836 } else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
1837 if (ctx->src_fmt) 1837 if (ctx->src_fmt)
1838 *plane_count = ctx->src_fmt->num_planes; 1838 *plane_count = ctx->src_fmt->num_planes;
@@ -1848,15 +1848,11 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
1848 psize[1] = ctx->chroma_size; 1848 psize[1] = ctx->chroma_size;
1849 1849
1850 if (IS_MFCV6_PLUS(dev)) { 1850 if (IS_MFCV6_PLUS(dev)) {
1851 allocators[0] = 1851 allocators[0] = &ctx->dev->mem_dev_l;
1852 ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX]; 1852 allocators[1] = &ctx->dev->mem_dev_l;
1853 allocators[1] =
1854 ctx->dev->alloc_ctx[MFC_BANK1_ALLOC_CTX];
1855 } else { 1853 } else {
1856 allocators[0] = 1854 allocators[0] = &ctx->dev->mem_dev_r;
1857 ctx->dev->alloc_ctx[MFC_BANK2_ALLOC_CTX]; 1855 allocators[1] = &ctx->dev->mem_dev_r;
1858 allocators[1] =
1859 ctx->dev->alloc_ctx[MFC_BANK2_ALLOC_CTX];
1860 } 1856 }
1861 } else { 1857 } else {
1862 mfc_err("invalid queue type: %d\n", vq->type); 1858 mfc_err("invalid queue type: %d\n", vq->type);