diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2016-02-15 10:41:51 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-07-08 13:40:50 -0400 |
commit | 1ad70ced1bdafa93938caf57edc2de2b461c539b (patch) | |
tree | 7e8156365fae544f2512da5f6cd29c1b44242aba | |
parent | dce57314b53760b6f9190c98287ce8f89c80d233 (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>
Reviewed-by: Laurent 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: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/media/platform/m2m-deinterlace.c | 15 | ||||
-rw-r--r-- | drivers/media/platform/marvell-ccic/mcam-core.c | 24 | ||||
-rw-r--r-- | drivers/media/platform/marvell-ccic/mcam-core.h | 2 | ||||
-rw-r--r-- | drivers/media/platform/mx2_emmaprp.c | 17 | ||||
-rw-r--r-- | drivers/media/platform/omap3isp/ispvideo.c | 12 | ||||
-rw-r--r-- | drivers/media/platform/omap3isp/ispvideo.h | 1 | ||||
-rw-r--r-- | drivers/media/platform/rcar_jpu.c | 22 | ||||
-rw-r--r-- | drivers/media/platform/sh_veu.c | 17 | ||||
-rw-r--r-- | drivers/media/platform/sh_vou.c | 14 |
9 files changed, 17 insertions, 107 deletions
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c index 7383818c2be6..15110ea89c56 100644 --- a/drivers/media/platform/m2m-deinterlace.c +++ b/drivers/media/platform/m2m-deinterlace.c | |||
@@ -136,7 +136,6 @@ struct deinterlace_dev { | |||
136 | struct dma_chan *dma_chan; | 136 | struct dma_chan *dma_chan; |
137 | 137 | ||
138 | struct v4l2_m2m_dev *m2m_dev; | 138 | struct v4l2_m2m_dev *m2m_dev; |
139 | struct vb2_alloc_ctx *alloc_ctx; | ||
140 | }; | 139 | }; |
141 | 140 | ||
142 | struct deinterlace_ctx { | 141 | struct deinterlace_ctx { |
@@ -820,8 +819,6 @@ static int deinterlace_queue_setup(struct vb2_queue *vq, | |||
820 | *nbuffers = count; | 819 | *nbuffers = count; |
821 | sizes[0] = size; | 820 | sizes[0] = size; |
822 | 821 | ||
823 | alloc_ctxs[0] = ctx->dev->alloc_ctx; | ||
824 | |||
825 | dprintk(ctx->dev, "get %d buffer(s) of size %d each.\n", count, size); | 822 | dprintk(ctx->dev, "get %d buffer(s) of size %d each.\n", count, size); |
826 | 823 | ||
827 | return 0; | 824 | return 0; |
@@ -874,6 +871,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, | |||
874 | src_vq->ops = &deinterlace_qops; | 871 | src_vq->ops = &deinterlace_qops; |
875 | src_vq->mem_ops = &vb2_dma_contig_memops; | 872 | src_vq->mem_ops = &vb2_dma_contig_memops; |
876 | src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 873 | src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
874 | src_vq->dev = ctx->dev->v4l2_dev.dev; | ||
877 | q_data[V4L2_M2M_SRC].fmt = &formats[0]; | 875 | q_data[V4L2_M2M_SRC].fmt = &formats[0]; |
878 | q_data[V4L2_M2M_SRC].width = 640; | 876 | q_data[V4L2_M2M_SRC].width = 640; |
879 | q_data[V4L2_M2M_SRC].height = 480; | 877 | q_data[V4L2_M2M_SRC].height = 480; |
@@ -891,6 +889,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, | |||
891 | dst_vq->ops = &deinterlace_qops; | 889 | dst_vq->ops = &deinterlace_qops; |
892 | dst_vq->mem_ops = &vb2_dma_contig_memops; | 890 | dst_vq->mem_ops = &vb2_dma_contig_memops; |
893 | dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 891 | dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
892 | dst_vq->dev = ctx->dev->v4l2_dev.dev; | ||
894 | q_data[V4L2_M2M_DST].fmt = &formats[0]; | 893 | q_data[V4L2_M2M_DST].fmt = &formats[0]; |
895 | q_data[V4L2_M2M_DST].width = 640; | 894 | q_data[V4L2_M2M_DST].width = 640; |
896 | q_data[V4L2_M2M_DST].height = 480; | 895 | q_data[V4L2_M2M_DST].height = 480; |
@@ -1046,13 +1045,6 @@ static int deinterlace_probe(struct platform_device *pdev) | |||
1046 | 1045 | ||
1047 | platform_set_drvdata(pdev, pcdev); | 1046 | platform_set_drvdata(pdev, pcdev); |
1048 | 1047 | ||
1049 | pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); | ||
1050 | if (IS_ERR(pcdev->alloc_ctx)) { | ||
1051 | v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n"); | ||
1052 | ret = PTR_ERR(pcdev->alloc_ctx); | ||
1053 | goto err_ctx; | ||
1054 | } | ||
1055 | |||
1056 | pcdev->m2m_dev = v4l2_m2m_init(&m2m_ops); | 1048 | pcdev->m2m_dev = v4l2_m2m_init(&m2m_ops); |
1057 | if (IS_ERR(pcdev->m2m_dev)) { | 1049 | if (IS_ERR(pcdev->m2m_dev)) { |
1058 | v4l2_err(&pcdev->v4l2_dev, "Failed to init mem2mem device\n"); | 1050 | v4l2_err(&pcdev->v4l2_dev, "Failed to init mem2mem device\n"); |
@@ -1064,8 +1056,6 @@ static int deinterlace_probe(struct platform_device *pdev) | |||
1064 | 1056 | ||
1065 | err_m2m: | 1057 | err_m2m: |
1066 | video_unregister_device(&pcdev->vfd); | 1058 | video_unregister_device(&pcdev->vfd); |
1067 | err_ctx: | ||
1068 | vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); | ||
1069 | unreg_dev: | 1059 | unreg_dev: |
1070 | v4l2_device_unregister(&pcdev->v4l2_dev); | 1060 | v4l2_device_unregister(&pcdev->v4l2_dev); |
1071 | rel_dma: | 1061 | rel_dma: |
@@ -1082,7 +1072,6 @@ static int deinterlace_remove(struct platform_device *pdev) | |||
1082 | v4l2_m2m_release(pcdev->m2m_dev); | 1072 | v4l2_m2m_release(pcdev->m2m_dev); |
1083 | video_unregister_device(&pcdev->vfd); | 1073 | video_unregister_device(&pcdev->vfd); |
1084 | v4l2_device_unregister(&pcdev->v4l2_dev); | 1074 | v4l2_device_unregister(&pcdev->v4l2_dev); |
1085 | vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); | ||
1086 | dma_release_channel(pcdev->dma_chan); | 1075 | dma_release_channel(pcdev->dma_chan); |
1087 | 1076 | ||
1088 | return 0; | 1077 | return 0; |
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index 9b878deb1437..8a1f12d08c0c 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c | |||
@@ -1059,10 +1059,6 @@ static int mcam_vb_queue_setup(struct vb2_queue *vq, | |||
1059 | 1059 | ||
1060 | if (*nbufs < minbufs) | 1060 | if (*nbufs < minbufs) |
1061 | *nbufs = minbufs; | 1061 | *nbufs = minbufs; |
1062 | if (cam->buffer_mode == B_DMA_contig) | ||
1063 | alloc_ctxs[0] = cam->vb_alloc_ctx; | ||
1064 | else if (cam->buffer_mode == B_DMA_sg) | ||
1065 | alloc_ctxs[0] = cam->vb_alloc_ctx_sg; | ||
1066 | 1062 | ||
1067 | if (*num_planes) | 1063 | if (*num_planes) |
1068 | return sizes[0] < size ? -EINVAL : 0; | 1064 | return sizes[0] < size ? -EINVAL : 0; |
@@ -1271,6 +1267,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam) | |||
1271 | vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | 1267 | vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
1272 | vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; | 1268 | vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; |
1273 | vq->buf_struct_size = sizeof(struct mcam_vb_buffer); | 1269 | vq->buf_struct_size = sizeof(struct mcam_vb_buffer); |
1270 | vq->dev = cam->dev; | ||
1274 | INIT_LIST_HEAD(&cam->buffers); | 1271 | INIT_LIST_HEAD(&cam->buffers); |
1275 | switch (cam->buffer_mode) { | 1272 | switch (cam->buffer_mode) { |
1276 | case B_DMA_contig: | 1273 | case B_DMA_contig: |
@@ -1279,9 +1276,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam) | |||
1279 | vq->mem_ops = &vb2_dma_contig_memops; | 1276 | vq->mem_ops = &vb2_dma_contig_memops; |
1280 | cam->dma_setup = mcam_ctlr_dma_contig; | 1277 | cam->dma_setup = mcam_ctlr_dma_contig; |
1281 | cam->frame_complete = mcam_dma_contig_done; | 1278 | cam->frame_complete = mcam_dma_contig_done; |
1282 | cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev); | ||
1283 | if (IS_ERR(cam->vb_alloc_ctx)) | ||
1284 | return PTR_ERR(cam->vb_alloc_ctx); | ||
1285 | #endif | 1279 | #endif |
1286 | break; | 1280 | break; |
1287 | case B_DMA_sg: | 1281 | case B_DMA_sg: |
@@ -1290,9 +1284,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam) | |||
1290 | vq->mem_ops = &vb2_dma_sg_memops; | 1284 | vq->mem_ops = &vb2_dma_sg_memops; |
1291 | cam->dma_setup = mcam_ctlr_dma_sg; | 1285 | cam->dma_setup = mcam_ctlr_dma_sg; |
1292 | cam->frame_complete = mcam_dma_sg_done; | 1286 | cam->frame_complete = mcam_dma_sg_done; |
1293 | cam->vb_alloc_ctx_sg = vb2_dma_sg_init_ctx(cam->dev); | ||
1294 | if (IS_ERR(cam->vb_alloc_ctx_sg)) | ||
1295 | return PTR_ERR(cam->vb_alloc_ctx_sg); | ||
1296 | #endif | 1287 | #endif |
1297 | break; | 1288 | break; |
1298 | case B_vmalloc: | 1289 | case B_vmalloc: |
@@ -1309,18 +1300,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam) | |||
1309 | return vb2_queue_init(vq); | 1300 | return vb2_queue_init(vq); |
1310 | } | 1301 | } |
1311 | 1302 | ||
1312 | static void mcam_cleanup_vb2(struct mcam_camera *cam) | ||
1313 | { | ||
1314 | #ifdef MCAM_MODE_DMA_CONTIG | ||
1315 | if (cam->buffer_mode == B_DMA_contig) | ||
1316 | vb2_dma_contig_cleanup_ctx(cam->vb_alloc_ctx); | ||
1317 | #endif | ||
1318 | #ifdef MCAM_MODE_DMA_SG | ||
1319 | if (cam->buffer_mode == B_DMA_sg) | ||
1320 | vb2_dma_sg_cleanup_ctx(cam->vb_alloc_ctx_sg); | ||
1321 | #endif | ||
1322 | } | ||
1323 | |||
1324 | 1303 | ||
1325 | /* ---------------------------------------------------------------------- */ | 1304 | /* ---------------------------------------------------------------------- */ |
1326 | /* | 1305 | /* |
@@ -1875,7 +1854,6 @@ void mccic_shutdown(struct mcam_camera *cam) | |||
1875 | cam_warn(cam, "Removing a device with users!\n"); | 1854 | cam_warn(cam, "Removing a device with users!\n"); |
1876 | mcam_ctlr_power_down(cam); | 1855 | mcam_ctlr_power_down(cam); |
1877 | } | 1856 | } |
1878 | mcam_cleanup_vb2(cam); | ||
1879 | if (cam->buffer_mode == B_vmalloc) | 1857 | if (cam->buffer_mode == B_vmalloc) |
1880 | mcam_free_dma_bufs(cam); | 1858 | mcam_free_dma_bufs(cam); |
1881 | video_unregister_device(&cam->vdev); | 1859 | video_unregister_device(&cam->vdev); |
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h b/drivers/media/platform/marvell-ccic/mcam-core.h index 35cd9e5aedf8..beb339f5561f 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.h +++ b/drivers/media/platform/marvell-ccic/mcam-core.h | |||
@@ -176,8 +176,6 @@ struct mcam_camera { | |||
176 | 176 | ||
177 | /* DMA buffers - DMA modes */ | 177 | /* DMA buffers - DMA modes */ |
178 | struct mcam_vb_buffer *vb_bufs[MAX_DMA_BUFS]; | 178 | struct mcam_vb_buffer *vb_bufs[MAX_DMA_BUFS]; |
179 | struct vb2_alloc_ctx *vb_alloc_ctx; | ||
180 | struct vb2_alloc_ctx *vb_alloc_ctx_sg; | ||
181 | 179 | ||
182 | /* Mode-specific ops, set at open time */ | 180 | /* Mode-specific ops, set at open time */ |
183 | void (*dma_setup)(struct mcam_camera *cam); | 181 | void (*dma_setup)(struct mcam_camera *cam); |
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c index 3c4012d42d69..88b3d982a2da 100644 --- a/drivers/media/platform/mx2_emmaprp.c +++ b/drivers/media/platform/mx2_emmaprp.c | |||
@@ -211,7 +211,6 @@ struct emmaprp_dev { | |||
211 | struct clk *clk_emma_ahb, *clk_emma_ipg; | 211 | struct clk *clk_emma_ahb, *clk_emma_ipg; |
212 | 212 | ||
213 | struct v4l2_m2m_dev *m2m_dev; | 213 | struct v4l2_m2m_dev *m2m_dev; |
214 | struct vb2_alloc_ctx *alloc_ctx; | ||
215 | }; | 214 | }; |
216 | 215 | ||
217 | struct emmaprp_ctx { | 216 | struct emmaprp_ctx { |
@@ -710,8 +709,6 @@ static int emmaprp_queue_setup(struct vb2_queue *vq, | |||
710 | *nbuffers = count; | 709 | *nbuffers = count; |
711 | sizes[0] = size; | 710 | sizes[0] = size; |
712 | 711 | ||
713 | alloc_ctxs[0] = ctx->dev->alloc_ctx; | ||
714 | |||
715 | dprintk(ctx->dev, "get %d buffer(s) of size %d each.\n", count, size); | 712 | dprintk(ctx->dev, "get %d buffer(s) of size %d each.\n", count, size); |
716 | 713 | ||
717 | return 0; | 714 | return 0; |
@@ -765,6 +762,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, | |||
765 | src_vq->ops = &emmaprp_qops; | 762 | src_vq->ops = &emmaprp_qops; |
766 | src_vq->mem_ops = &vb2_dma_contig_memops; | 763 | src_vq->mem_ops = &vb2_dma_contig_memops; |
767 | src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 764 | src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
765 | src_vq->dev = ctx->dev->v4l2_dev.dev; | ||
768 | 766 | ||
769 | ret = vb2_queue_init(src_vq); | 767 | ret = vb2_queue_init(src_vq); |
770 | if (ret) | 768 | if (ret) |
@@ -777,6 +775,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, | |||
777 | dst_vq->ops = &emmaprp_qops; | 775 | dst_vq->ops = &emmaprp_qops; |
778 | dst_vq->mem_ops = &vb2_dma_contig_memops; | 776 | dst_vq->mem_ops = &vb2_dma_contig_memops; |
779 | dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 777 | dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
778 | dst_vq->dev = ctx->dev->v4l2_dev.dev; | ||
780 | 779 | ||
781 | return vb2_queue_init(dst_vq); | 780 | return vb2_queue_init(dst_vq); |
782 | } | 781 | } |
@@ -948,18 +947,11 @@ static int emmaprp_probe(struct platform_device *pdev) | |||
948 | if (ret) | 947 | if (ret) |
949 | goto rel_vdev; | 948 | goto rel_vdev; |
950 | 949 | ||
951 | pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); | ||
952 | if (IS_ERR(pcdev->alloc_ctx)) { | ||
953 | v4l2_err(&pcdev->v4l2_dev, "Failed to alloc vb2 context\n"); | ||
954 | ret = PTR_ERR(pcdev->alloc_ctx); | ||
955 | goto rel_vdev; | ||
956 | } | ||
957 | |||
958 | pcdev->m2m_dev = v4l2_m2m_init(&m2m_ops); | 950 | pcdev->m2m_dev = v4l2_m2m_init(&m2m_ops); |
959 | if (IS_ERR(pcdev->m2m_dev)) { | 951 | if (IS_ERR(pcdev->m2m_dev)) { |
960 | v4l2_err(&pcdev->v4l2_dev, "Failed to init mem2mem device\n"); | 952 | v4l2_err(&pcdev->v4l2_dev, "Failed to init mem2mem device\n"); |
961 | ret = PTR_ERR(pcdev->m2m_dev); | 953 | ret = PTR_ERR(pcdev->m2m_dev); |
962 | goto rel_ctx; | 954 | goto rel_vdev; |
963 | } | 955 | } |
964 | 956 | ||
965 | ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); | 957 | ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); |
@@ -973,8 +965,6 @@ static int emmaprp_probe(struct platform_device *pdev) | |||
973 | 965 | ||
974 | rel_m2m: | 966 | rel_m2m: |
975 | v4l2_m2m_release(pcdev->m2m_dev); | 967 | v4l2_m2m_release(pcdev->m2m_dev); |
976 | rel_ctx: | ||
977 | vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); | ||
978 | rel_vdev: | 968 | rel_vdev: |
979 | video_device_release(vfd); | 969 | video_device_release(vfd); |
980 | unreg_dev: | 970 | unreg_dev: |
@@ -993,7 +983,6 @@ static int emmaprp_remove(struct platform_device *pdev) | |||
993 | 983 | ||
994 | video_unregister_device(pcdev->vfd); | 984 | video_unregister_device(pcdev->vfd); |
995 | v4l2_m2m_release(pcdev->m2m_dev); | 985 | v4l2_m2m_release(pcdev->m2m_dev); |
996 | vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); | ||
997 | v4l2_device_unregister(&pcdev->v4l2_dev); | 986 | v4l2_device_unregister(&pcdev->v4l2_dev); |
998 | mutex_destroy(&pcdev->dev_mutex); | 987 | mutex_destroy(&pcdev->dev_mutex); |
999 | 988 | ||
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index 1b1a95d546f6..486b8754110f 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c | |||
@@ -342,8 +342,6 @@ static int isp_video_queue_setup(struct vb2_queue *queue, | |||
342 | if (sizes[0] == 0) | 342 | if (sizes[0] == 0) |
343 | return -EINVAL; | 343 | return -EINVAL; |
344 | 344 | ||
345 | alloc_ctxs[0] = video->alloc_ctx; | ||
346 | |||
347 | *count = min(*count, video->capture_mem / PAGE_ALIGN(sizes[0])); | 345 | *count = min(*count, video->capture_mem / PAGE_ALIGN(sizes[0])); |
348 | 346 | ||
349 | return 0; | 347 | return 0; |
@@ -1308,6 +1306,7 @@ static int isp_video_open(struct file *file) | |||
1308 | queue->mem_ops = &vb2_dma_contig_memops; | 1306 | queue->mem_ops = &vb2_dma_contig_memops; |
1309 | queue->buf_struct_size = sizeof(struct isp_buffer); | 1307 | queue->buf_struct_size = sizeof(struct isp_buffer); |
1310 | queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | 1308 | queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
1309 | queue->dev = video->isp->dev; | ||
1311 | 1310 | ||
1312 | ret = vb2_queue_init(&handle->queue); | 1311 | ret = vb2_queue_init(&handle->queue); |
1313 | if (ret < 0) { | 1312 | if (ret < 0) { |
@@ -1414,15 +1413,9 @@ int omap3isp_video_init(struct isp_video *video, const char *name) | |||
1414 | return -EINVAL; | 1413 | return -EINVAL; |
1415 | } | 1414 | } |
1416 | 1415 | ||
1417 | video->alloc_ctx = vb2_dma_contig_init_ctx(video->isp->dev); | ||
1418 | if (IS_ERR(video->alloc_ctx)) | ||
1419 | return PTR_ERR(video->alloc_ctx); | ||
1420 | |||
1421 | ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); | 1416 | ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); |
1422 | if (ret < 0) { | 1417 | if (ret < 0) |
1423 | vb2_dma_contig_cleanup_ctx(video->alloc_ctx); | ||
1424 | return ret; | 1418 | return ret; |
1425 | } | ||
1426 | 1419 | ||
1427 | mutex_init(&video->mutex); | 1420 | mutex_init(&video->mutex); |
1428 | atomic_set(&video->active, 0); | 1421 | atomic_set(&video->active, 0); |
@@ -1451,7 +1444,6 @@ int omap3isp_video_init(struct isp_video *video, const char *name) | |||
1451 | 1444 | ||
1452 | void omap3isp_video_cleanup(struct isp_video *video) | 1445 | void omap3isp_video_cleanup(struct isp_video *video) |
1453 | { | 1446 | { |
1454 | vb2_dma_contig_cleanup_ctx(video->alloc_ctx); | ||
1455 | media_entity_cleanup(&video->video.entity); | 1447 | media_entity_cleanup(&video->video.entity); |
1456 | mutex_destroy(&video->queue_lock); | 1448 | mutex_destroy(&video->queue_lock); |
1457 | mutex_destroy(&video->stream_lock); | 1449 | mutex_destroy(&video->stream_lock); |
diff --git a/drivers/media/platform/omap3isp/ispvideo.h b/drivers/media/platform/omap3isp/ispvideo.h index 6a48d5879c56..f6a2082b4a0a 100644 --- a/drivers/media/platform/omap3isp/ispvideo.h +++ b/drivers/media/platform/omap3isp/ispvideo.h | |||
@@ -171,7 +171,6 @@ struct isp_video { | |||
171 | bool error; | 171 | bool error; |
172 | 172 | ||
173 | /* Video buffers queue */ | 173 | /* Video buffers queue */ |
174 | void *alloc_ctx; | ||
175 | struct vb2_queue *queue; | 174 | struct vb2_queue *queue; |
176 | struct mutex queue_lock; /* protects the queue */ | 175 | struct mutex queue_lock; /* protects the queue */ |
177 | spinlock_t irqlock; /* protects dmaqueue */ | 176 | spinlock_t irqlock; /* protects dmaqueue */ |
diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c index 552789a69c86..d81c41035bb6 100644 --- a/drivers/media/platform/rcar_jpu.c +++ b/drivers/media/platform/rcar_jpu.c | |||
@@ -203,7 +203,6 @@ | |||
203 | * @irq: JPEG IP irq | 203 | * @irq: JPEG IP irq |
204 | * @clk: JPEG IP clock | 204 | * @clk: JPEG IP clock |
205 | * @dev: JPEG IP struct device | 205 | * @dev: JPEG IP struct device |
206 | * @alloc_ctx: videobuf2 memory allocator's context | ||
207 | * @ref_count: reference counter | 206 | * @ref_count: reference counter |
208 | */ | 207 | */ |
209 | struct jpu { | 208 | struct jpu { |
@@ -220,7 +219,6 @@ struct jpu { | |||
220 | unsigned int irq; | 219 | unsigned int irq; |
221 | struct clk *clk; | 220 | struct clk *clk; |
222 | struct device *dev; | 221 | struct device *dev; |
223 | void *alloc_ctx; | ||
224 | int ref_count; | 222 | int ref_count; |
225 | }; | 223 | }; |
226 | 224 | ||
@@ -1033,17 +1031,14 @@ static int jpu_queue_setup(struct vb2_queue *vq, | |||
1033 | 1031 | ||
1034 | if (sizes[i] < q_size) | 1032 | if (sizes[i] < q_size) |
1035 | return -EINVAL; | 1033 | return -EINVAL; |
1036 | alloc_ctxs[i] = ctx->jpu->alloc_ctx; | ||
1037 | } | 1034 | } |
1038 | return 0; | 1035 | return 0; |
1039 | } | 1036 | } |
1040 | 1037 | ||
1041 | *nplanes = q_data->format.num_planes; | 1038 | *nplanes = q_data->format.num_planes; |
1042 | 1039 | ||
1043 | for (i = 0; i < *nplanes; i++) { | 1040 | for (i = 0; i < *nplanes; i++) |
1044 | sizes[i] = q_data->format.plane_fmt[i].sizeimage; | 1041 | sizes[i] = q_data->format.plane_fmt[i].sizeimage; |
1045 | alloc_ctxs[i] = ctx->jpu->alloc_ctx; | ||
1046 | } | ||
1047 | 1042 | ||
1048 | return 0; | 1043 | return 0; |
1049 | } | 1044 | } |
@@ -1214,6 +1209,7 @@ static int jpu_queue_init(void *priv, struct vb2_queue *src_vq, | |||
1214 | src_vq->mem_ops = &vb2_dma_contig_memops; | 1209 | src_vq->mem_ops = &vb2_dma_contig_memops; |
1215 | src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 1210 | src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
1216 | src_vq->lock = &ctx->jpu->mutex; | 1211 | src_vq->lock = &ctx->jpu->mutex; |
1212 | src_vq->dev = ctx->jpu->v4l2_dev.dev; | ||
1217 | 1213 | ||
1218 | ret = vb2_queue_init(src_vq); | 1214 | ret = vb2_queue_init(src_vq); |
1219 | if (ret) | 1215 | if (ret) |
@@ -1228,6 +1224,7 @@ static int jpu_queue_init(void *priv, struct vb2_queue *src_vq, | |||
1228 | dst_vq->mem_ops = &vb2_dma_contig_memops; | 1224 | dst_vq->mem_ops = &vb2_dma_contig_memops; |
1229 | dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 1225 | dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
1230 | dst_vq->lock = &ctx->jpu->mutex; | 1226 | dst_vq->lock = &ctx->jpu->mutex; |
1227 | dst_vq->dev = ctx->jpu->v4l2_dev.dev; | ||
1231 | 1228 | ||
1232 | return vb2_queue_init(dst_vq); | 1229 | return vb2_queue_init(dst_vq); |
1233 | } | 1230 | } |
@@ -1676,13 +1673,6 @@ static int jpu_probe(struct platform_device *pdev) | |||
1676 | goto device_register_rollback; | 1673 | goto device_register_rollback; |
1677 | } | 1674 | } |
1678 | 1675 | ||
1679 | jpu->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); | ||
1680 | if (IS_ERR(jpu->alloc_ctx)) { | ||
1681 | v4l2_err(&jpu->v4l2_dev, "Failed to init memory allocator\n"); | ||
1682 | ret = PTR_ERR(jpu->alloc_ctx); | ||
1683 | goto m2m_init_rollback; | ||
1684 | } | ||
1685 | |||
1686 | /* fill in qantization and Huffman tables for encoder */ | 1676 | /* fill in qantization and Huffman tables for encoder */ |
1687 | for (i = 0; i < JPU_MAX_QUALITY; i++) | 1677 | for (i = 0; i < JPU_MAX_QUALITY; i++) |
1688 | jpu_generate_hdr(i, (unsigned char *)jpeg_hdrs[i]); | 1678 | jpu_generate_hdr(i, (unsigned char *)jpeg_hdrs[i]); |
@@ -1699,7 +1689,7 @@ static int jpu_probe(struct platform_device *pdev) | |||
1699 | ret = video_register_device(&jpu->vfd_encoder, VFL_TYPE_GRABBER, -1); | 1689 | ret = video_register_device(&jpu->vfd_encoder, VFL_TYPE_GRABBER, -1); |
1700 | if (ret) { | 1690 | if (ret) { |
1701 | v4l2_err(&jpu->v4l2_dev, "Failed to register video device\n"); | 1691 | v4l2_err(&jpu->v4l2_dev, "Failed to register video device\n"); |
1702 | goto vb2_allocator_rollback; | 1692 | goto m2m_init_rollback; |
1703 | } | 1693 | } |
1704 | 1694 | ||
1705 | video_set_drvdata(&jpu->vfd_encoder, jpu); | 1695 | video_set_drvdata(&jpu->vfd_encoder, jpu); |
@@ -1732,9 +1722,6 @@ static int jpu_probe(struct platform_device *pdev) | |||
1732 | enc_vdev_register_rollback: | 1722 | enc_vdev_register_rollback: |
1733 | video_unregister_device(&jpu->vfd_encoder); | 1723 | video_unregister_device(&jpu->vfd_encoder); |
1734 | 1724 | ||
1735 | vb2_allocator_rollback: | ||
1736 | vb2_dma_contig_cleanup_ctx(jpu->alloc_ctx); | ||
1737 | |||
1738 | m2m_init_rollback: | 1725 | m2m_init_rollback: |
1739 | v4l2_m2m_release(jpu->m2m_dev); | 1726 | v4l2_m2m_release(jpu->m2m_dev); |
1740 | 1727 | ||
@@ -1750,7 +1737,6 @@ static int jpu_remove(struct platform_device *pdev) | |||
1750 | 1737 | ||
1751 | video_unregister_device(&jpu->vfd_decoder); | 1738 | video_unregister_device(&jpu->vfd_decoder); |
1752 | video_unregister_device(&jpu->vfd_encoder); | 1739 | video_unregister_device(&jpu->vfd_encoder); |
1753 | vb2_dma_contig_cleanup_ctx(jpu->alloc_ctx); | ||
1754 | v4l2_m2m_release(jpu->m2m_dev); | 1740 | v4l2_m2m_release(jpu->m2m_dev); |
1755 | v4l2_device_unregister(&jpu->v4l2_dev); | 1741 | v4l2_device_unregister(&jpu->v4l2_dev); |
1756 | 1742 | ||
diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c index 82b5d69b87fa..afd21c9f1a02 100644 --- a/drivers/media/platform/sh_veu.c +++ b/drivers/media/platform/sh_veu.c | |||
@@ -118,7 +118,6 @@ struct sh_veu_dev { | |||
118 | struct sh_veu_file *output; | 118 | struct sh_veu_file *output; |
119 | struct mutex fop_lock; | 119 | struct mutex fop_lock; |
120 | void __iomem *base; | 120 | void __iomem *base; |
121 | struct vb2_alloc_ctx *alloc_ctx; | ||
122 | spinlock_t lock; | 121 | spinlock_t lock; |
123 | bool is_2h; | 122 | bool is_2h; |
124 | unsigned int xaction; | 123 | unsigned int xaction; |
@@ -882,14 +881,11 @@ static int sh_veu_queue_setup(struct vb2_queue *vq, | |||
882 | *nbuffers = count; | 881 | *nbuffers = count; |
883 | } | 882 | } |
884 | 883 | ||
885 | if (*nplanes) { | 884 | if (*nplanes) |
886 | alloc_ctxs[0] = veu->alloc_ctx; | ||
887 | return sizes[0] < size ? -EINVAL : 0; | 885 | return sizes[0] < size ? -EINVAL : 0; |
888 | } | ||
889 | 886 | ||
890 | *nplanes = 1; | 887 | *nplanes = 1; |
891 | sizes[0] = size; | 888 | sizes[0] = size; |
892 | alloc_ctxs[0] = veu->alloc_ctx; | ||
893 | 889 | ||
894 | dev_dbg(veu->dev, "get %d buffer(s) of size %d each.\n", count, size); | 890 | dev_dbg(veu->dev, "get %d buffer(s) of size %d each.\n", count, size); |
895 | 891 | ||
@@ -948,6 +944,7 @@ static int sh_veu_queue_init(void *priv, struct vb2_queue *src_vq, | |||
948 | src_vq->mem_ops = &vb2_dma_contig_memops; | 944 | src_vq->mem_ops = &vb2_dma_contig_memops; |
949 | src_vq->lock = &veu->fop_lock; | 945 | src_vq->lock = &veu->fop_lock; |
950 | src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 946 | src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
947 | src_vq->dev = veu->v4l2_dev.dev; | ||
951 | 948 | ||
952 | ret = vb2_queue_init(src_vq); | 949 | ret = vb2_queue_init(src_vq); |
953 | if (ret < 0) | 950 | if (ret < 0) |
@@ -962,6 +959,7 @@ static int sh_veu_queue_init(void *priv, struct vb2_queue *src_vq, | |||
962 | dst_vq->mem_ops = &vb2_dma_contig_memops; | 959 | dst_vq->mem_ops = &vb2_dma_contig_memops; |
963 | dst_vq->lock = &veu->fop_lock; | 960 | dst_vq->lock = &veu->fop_lock; |
964 | dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; | 961 | dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; |
962 | dst_vq->dev = veu->v4l2_dev.dev; | ||
965 | 963 | ||
966 | return vb2_queue_init(dst_vq); | 964 | return vb2_queue_init(dst_vq); |
967 | } | 965 | } |
@@ -1148,12 +1146,6 @@ static int sh_veu_probe(struct platform_device *pdev) | |||
1148 | 1146 | ||
1149 | vdev = &veu->vdev; | 1147 | vdev = &veu->vdev; |
1150 | 1148 | ||
1151 | veu->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); | ||
1152 | if (IS_ERR(veu->alloc_ctx)) { | ||
1153 | ret = PTR_ERR(veu->alloc_ctx); | ||
1154 | goto einitctx; | ||
1155 | } | ||
1156 | |||
1157 | *vdev = sh_veu_videodev; | 1149 | *vdev = sh_veu_videodev; |
1158 | vdev->v4l2_dev = &veu->v4l2_dev; | 1150 | vdev->v4l2_dev = &veu->v4l2_dev; |
1159 | spin_lock_init(&veu->lock); | 1151 | spin_lock_init(&veu->lock); |
@@ -1187,8 +1179,6 @@ evidreg: | |||
1187 | pm_runtime_disable(&pdev->dev); | 1179 | pm_runtime_disable(&pdev->dev); |
1188 | v4l2_m2m_release(veu->m2m_dev); | 1180 | v4l2_m2m_release(veu->m2m_dev); |
1189 | em2minit: | 1181 | em2minit: |
1190 | vb2_dma_contig_cleanup_ctx(veu->alloc_ctx); | ||
1191 | einitctx: | ||
1192 | v4l2_device_unregister(&veu->v4l2_dev); | 1182 | v4l2_device_unregister(&veu->v4l2_dev); |
1193 | return ret; | 1183 | return ret; |
1194 | } | 1184 | } |
@@ -1202,7 +1192,6 @@ static int sh_veu_remove(struct platform_device *pdev) | |||
1202 | video_unregister_device(&veu->vdev); | 1192 | video_unregister_device(&veu->vdev); |
1203 | pm_runtime_disable(&pdev->dev); | 1193 | pm_runtime_disable(&pdev->dev); |
1204 | v4l2_m2m_release(veu->m2m_dev); | 1194 | v4l2_m2m_release(veu->m2m_dev); |
1205 | vb2_dma_contig_cleanup_ctx(veu->alloc_ctx); | ||
1206 | v4l2_device_unregister(&veu->v4l2_dev); | 1195 | v4l2_device_unregister(&veu->v4l2_dev); |
1207 | 1196 | ||
1208 | return 0; | 1197 | return 0; |
diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c index 115740498274..59830a491592 100644 --- a/drivers/media/platform/sh_vou.c +++ b/drivers/media/platform/sh_vou.c | |||
@@ -86,7 +86,6 @@ struct sh_vou_device { | |||
86 | v4l2_std_id std; | 86 | v4l2_std_id std; |
87 | int pix_idx; | 87 | int pix_idx; |
88 | struct vb2_queue queue; | 88 | struct vb2_queue queue; |
89 | struct vb2_alloc_ctx *alloc_ctx; | ||
90 | struct sh_vou_buffer *active; | 89 | struct sh_vou_buffer *active; |
91 | enum sh_vou_status status; | 90 | enum sh_vou_status status; |
92 | unsigned sequence; | 91 | unsigned sequence; |
@@ -253,7 +252,6 @@ static int sh_vou_queue_setup(struct vb2_queue *vq, | |||
253 | 252 | ||
254 | dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); | 253 | dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); |
255 | 254 | ||
256 | alloc_ctxs[0] = vou_dev->alloc_ctx; | ||
257 | if (*nplanes) | 255 | if (*nplanes) |
258 | return sizes[0] < pix->height * bytes_per_line ? -EINVAL : 0; | 256 | return sizes[0] < pix->height * bytes_per_line ? -EINVAL : 0; |
259 | *nplanes = 1; | 257 | *nplanes = 1; |
@@ -1304,16 +1302,11 @@ static int sh_vou_probe(struct platform_device *pdev) | |||
1304 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; | 1302 | q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; |
1305 | q->min_buffers_needed = 2; | 1303 | q->min_buffers_needed = 2; |
1306 | q->lock = &vou_dev->fop_lock; | 1304 | q->lock = &vou_dev->fop_lock; |
1305 | q->dev = &pdev->dev; | ||
1307 | ret = vb2_queue_init(q); | 1306 | ret = vb2_queue_init(q); |
1308 | if (ret) | 1307 | if (ret) |
1309 | goto einitctx; | 1308 | goto ei2cgadap; |
1310 | 1309 | ||
1311 | vou_dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); | ||
1312 | if (IS_ERR(vou_dev->alloc_ctx)) { | ||
1313 | dev_err(&pdev->dev, "Can't allocate buffer context"); | ||
1314 | ret = PTR_ERR(vou_dev->alloc_ctx); | ||
1315 | goto einitctx; | ||
1316 | } | ||
1317 | vdev->queue = q; | 1310 | vdev->queue = q; |
1318 | INIT_LIST_HEAD(&vou_dev->buf_list); | 1311 | INIT_LIST_HEAD(&vou_dev->buf_list); |
1319 | 1312 | ||
@@ -1348,8 +1341,6 @@ ei2cnd: | |||
1348 | ereset: | 1341 | ereset: |
1349 | i2c_put_adapter(i2c_adap); | 1342 | i2c_put_adapter(i2c_adap); |
1350 | ei2cgadap: | 1343 | ei2cgadap: |
1351 | vb2_dma_contig_cleanup_ctx(vou_dev->alloc_ctx); | ||
1352 | einitctx: | ||
1353 | pm_runtime_disable(&pdev->dev); | 1344 | pm_runtime_disable(&pdev->dev); |
1354 | v4l2_device_unregister(&vou_dev->v4l2_dev); | 1345 | v4l2_device_unregister(&vou_dev->v4l2_dev); |
1355 | return ret; | 1346 | return ret; |
@@ -1367,7 +1358,6 @@ static int sh_vou_remove(struct platform_device *pdev) | |||
1367 | pm_runtime_disable(&pdev->dev); | 1358 | pm_runtime_disable(&pdev->dev); |
1368 | video_unregister_device(&vou_dev->vdev); | 1359 | video_unregister_device(&vou_dev->vdev); |
1369 | i2c_put_adapter(client->adapter); | 1360 | i2c_put_adapter(client->adapter); |
1370 | vb2_dma_contig_cleanup_ctx(vou_dev->alloc_ctx); | ||
1371 | v4l2_device_unregister(&vou_dev->v4l2_dev); | 1361 | v4l2_device_unregister(&vou_dev->v4l2_dev); |
1372 | return 0; | 1362 | return 0; |
1373 | } | 1363 | } |