Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
c781e4a5 8e9bca3a

+15 -68
+1 -9
drivers/media/platform/exynos-gsc/gsc-core.c
··· 1123 1123 if (ret < 0) 1124 1124 goto err_m2m; 1125 1125 1126 - /* Initialize continious memory allocator */ 1127 1126 vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32)); 1128 - gsc->alloc_ctx = vb2_dma_contig_init_ctx(dev); 1129 - if (IS_ERR(gsc->alloc_ctx)) { 1130 - ret = PTR_ERR(gsc->alloc_ctx); 1131 - goto err_pm; 1132 - } 1133 1127 1134 1128 dev_dbg(dev, "gsc-%d registered successfully\n", gsc->id); 1135 1129 1136 1130 pm_runtime_put(dev); 1137 1131 return 0; 1138 - err_pm: 1139 - pm_runtime_put(dev); 1132 + 1140 1133 err_m2m: 1141 1134 gsc_unregister_m2m_device(gsc); 1142 1135 err_v4l2: ··· 1146 1153 gsc_unregister_m2m_device(gsc); 1147 1154 v4l2_device_unregister(&gsc->v4l2_dev); 1148 1155 1149 - vb2_dma_contig_cleanup_ctx(gsc->alloc_ctx); 1150 1156 vb2_dma_contig_clear_max_seg_size(&pdev->dev); 1151 1157 pm_runtime_disable(&pdev->dev); 1152 1158 gsc_clk_put(gsc);
-1
drivers/media/platform/exynos-gsc/gsc-core.h
··· 341 341 wait_queue_head_t irq_queue; 342 342 struct gsc_m2m_device m2m; 343 343 unsigned long state; 344 - struct vb2_alloc_ctx *alloc_ctx; 345 344 struct video_device vdev; 346 345 struct v4l2_device v4l2_dev; 347 346 };
+3 -3
drivers/media/platform/exynos-gsc/gsc-m2m.c
··· 227 227 return -EINVAL; 228 228 229 229 *num_planes = frame->fmt->num_planes; 230 - for (i = 0; i < frame->fmt->num_planes; i++) { 230 + for (i = 0; i < frame->fmt->num_planes; i++) 231 231 sizes[i] = frame->payload[i]; 232 - allocators[i] = ctx->gsc_dev->alloc_ctx; 233 - } 234 232 return 0; 235 233 } 236 234 ··· 589 591 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 590 592 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 591 593 src_vq->lock = &ctx->gsc_dev->lock; 594 + src_vq->dev = &ctx->gsc_dev->pdev->dev; 592 595 593 596 ret = vb2_queue_init(src_vq); 594 597 if (ret) ··· 604 605 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 605 606 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 606 607 dst_vq->lock = &ctx->gsc_dev->lock; 608 + dst_vq->dev = &ctx->gsc_dev->pdev->dev; 607 609 608 610 return vb2_queue_init(dst_vq); 609 611 }
+1 -2
drivers/media/platform/s3c-camif/camif-capture.c
··· 440 440 unsigned int sizes[], void *allocators[]) 441 441 { 442 442 struct camif_vp *vp = vb2_get_drv_priv(vq); 443 - struct camif_dev *camif = vp->camif; 444 443 struct camif_frame *frame = &vp->out_frame; 445 444 const struct camif_fmt *fmt = vp->out_fmt; 446 445 unsigned int size; ··· 448 449 return -EINVAL; 449 450 450 451 size = (frame->f_width * frame->f_height * fmt->depth) / 8; 451 - allocators[0] = camif->alloc_ctx; 452 452 453 453 if (*num_planes) 454 454 return sizes[0] < size ? -EINVAL : 0; ··· 1136 1138 q->drv_priv = vp; 1137 1139 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1138 1140 q->lock = &vp->camif->lock; 1141 + q->dev = camif->v4l2_dev.dev; 1139 1142 1140 1143 ret = vb2_queue_init(q); 1141 1144 if (ret)
+1 -10
drivers/media/platform/s3c-camif/camif-core.c
··· 474 474 if (ret < 0) 475 475 goto err_pm; 476 476 477 - /* Initialize contiguous memory allocator */ 478 - camif->alloc_ctx = vb2_dma_contig_init_ctx(dev); 479 - if (IS_ERR(camif->alloc_ctx)) { 480 - ret = PTR_ERR(camif->alloc_ctx); 481 - goto err_alloc; 482 - } 483 - 484 477 ret = camif_media_dev_init(camif); 485 478 if (ret < 0) 486 - goto err_mdev; 479 + goto err_alloc; 487 480 488 481 ret = camif_register_sensor(camif); 489 482 if (ret < 0) ··· 510 517 media_device_unregister(&camif->media_dev); 511 518 media_device_cleanup(&camif->media_dev); 512 519 camif_unregister_media_entities(camif); 513 - err_mdev: 514 - vb2_dma_contig_cleanup_ctx(camif->alloc_ctx); 515 520 err_alloc: 516 521 pm_runtime_put(dev); 517 522 pm_runtime_disable(dev);
-2
drivers/media/platform/s3c-camif/camif-core.h
··· 254 254 * @ctrl_handler: v4l2 control handler (owned by @subdev) 255 255 * @test_pattern: test pattern controls 256 256 * @vp: video path (DMA) description (codec/preview) 257 - * @alloc_ctx: memory buffer allocator context 258 257 * @variant: variant information for this device 259 258 * @dev: pointer to the CAMIF device struct 260 259 * @pdata: a copy of the driver's platform data ··· 290 291 u8 colorfx_cr; 291 292 292 293 struct camif_vp vp[CAMIF_VP_NUM]; 293 - struct vb2_alloc_ctx *alloc_ctx; 294 294 295 295 const struct s3c_camif_variant *variant; 296 296 struct device *dev;
+3 -10
drivers/media/platform/s5p-g2d/g2d.c
··· 113 113 114 114 sizes[0] = f->size; 115 115 *nplanes = 1; 116 - alloc_ctxs[0] = ctx->dev->alloc_ctx; 117 116 118 117 if (*nbuffers == 0) 119 118 *nbuffers = 1; ··· 158 159 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 159 160 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 160 161 src_vq->lock = &ctx->dev->mutex; 162 + src_vq->dev = ctx->dev->v4l2_dev.dev; 161 163 162 164 ret = vb2_queue_init(src_vq); 163 165 if (ret) ··· 172 172 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 173 173 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 174 174 dst_vq->lock = &ctx->dev->mutex; 175 + dst_vq->dev = ctx->dev->v4l2_dev.dev; 175 176 176 177 return vb2_queue_init(dst_vq); 177 178 } ··· 683 682 } 684 683 685 684 vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); 686 - dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); 687 - if (IS_ERR(dev->alloc_ctx)) { 688 - ret = PTR_ERR(dev->alloc_ctx); 689 - goto unprep_clk_gate; 690 - } 691 685 692 686 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); 693 687 if (ret) 694 - goto alloc_ctx_cleanup; 688 + goto unprep_clk_gate; 695 689 vfd = video_device_alloc(); 696 690 if (!vfd) { 697 691 v4l2_err(&dev->v4l2_dev, "Failed to allocate video device\n"); ··· 731 735 video_device_release(vfd); 732 736 unreg_v4l2_dev: 733 737 v4l2_device_unregister(&dev->v4l2_dev); 734 - alloc_ctx_cleanup: 735 - vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); 736 738 unprep_clk_gate: 737 739 clk_unprepare(dev->gate); 738 740 put_clk_gate: ··· 751 757 v4l2_m2m_release(dev->m2m_dev); 752 758 video_unregister_device(dev->vfd); 753 759 v4l2_device_unregister(&dev->v4l2_dev); 754 - vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); 755 760 vb2_dma_contig_clear_max_seg_size(&pdev->dev); 756 761 clk_unprepare(dev->gate); 757 762 clk_put(dev->gate);
-1
drivers/media/platform/s5p-g2d/g2d.h
··· 25 25 struct mutex mutex; 26 26 spinlock_t ctrl_lock; 27 27 atomic_t num_inst; 28 - struct vb2_alloc_ctx *alloc_ctx; 29 28 void __iomem *regs; 30 29 struct clk *clk; 31 30 struct clk *gate;
+4 -13
drivers/media/platform/s5p-jpeg/jpeg-core.c
··· 2457 2457 *nbuffers = count; 2458 2458 *nplanes = 1; 2459 2459 sizes[0] = size; 2460 - alloc_ctxs[0] = ctx->jpeg->alloc_ctx; 2461 2460 2462 2461 return 0; 2463 2462 } ··· 2562 2563 src_vq->mem_ops = &vb2_dma_contig_memops; 2563 2564 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 2564 2565 src_vq->lock = &ctx->jpeg->lock; 2566 + src_vq->dev = ctx->jpeg->dev; 2565 2567 2566 2568 ret = vb2_queue_init(src_vq); 2567 2569 if (ret) ··· 2576 2576 dst_vq->mem_ops = &vb2_dma_contig_memops; 2577 2577 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; 2578 2578 dst_vq->lock = &ctx->jpeg->lock; 2579 + dst_vq->dev = ctx->jpeg->dev; 2579 2580 2580 2581 return vb2_queue_init(dst_vq); 2581 2582 } ··· 2845 2844 } 2846 2845 2847 2846 vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); 2848 - jpeg->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); 2849 - if (IS_ERR(jpeg->alloc_ctx)) { 2850 - v4l2_err(&jpeg->v4l2_dev, "Failed to init memory allocator\n"); 2851 - ret = PTR_ERR(jpeg->alloc_ctx); 2852 - goto m2m_init_rollback; 2853 - } 2854 2847 2855 2848 /* JPEG encoder /dev/videoX node */ 2856 2849 jpeg->vfd_encoder = video_device_alloc(); 2857 2850 if (!jpeg->vfd_encoder) { 2858 2851 v4l2_err(&jpeg->v4l2_dev, "Failed to allocate video device\n"); 2859 2852 ret = -ENOMEM; 2860 - goto vb2_allocator_rollback; 2853 + goto m2m_init_rollback; 2861 2854 } 2862 2855 snprintf(jpeg->vfd_encoder->name, sizeof(jpeg->vfd_encoder->name), 2863 2856 "%s-enc", S5P_JPEG_M2M_NAME); ··· 2867 2872 if (ret) { 2868 2873 v4l2_err(&jpeg->v4l2_dev, "Failed to register video device\n"); 2869 2874 video_device_release(jpeg->vfd_encoder); 2870 - goto vb2_allocator_rollback; 2875 + goto m2m_init_rollback; 2871 2876 } 2872 2877 2873 2878 video_set_drvdata(jpeg->vfd_encoder, jpeg); ··· 2916 2921 enc_vdev_register_rollback: 2917 2922 video_unregister_device(jpeg->vfd_encoder); 2918 2923 2919 - vb2_allocator_rollback: 2920 - vb2_dma_contig_cleanup_ctx(jpeg->alloc_ctx); 2921 - 2922 2924 m2m_init_rollback: 2923 2925 v4l2_m2m_release(jpeg->m2m_dev); 2924 2926 ··· 2934 2942 2935 2943 video_unregister_device(jpeg->vfd_decoder); 2936 2944 video_unregister_device(jpeg->vfd_encoder); 2937 - vb2_dma_contig_cleanup_ctx(jpeg->alloc_ctx); 2938 2945 vb2_dma_contig_clear_max_seg_size(&pdev->dev); 2939 2946 v4l2_m2m_release(jpeg->m2m_dev); 2940 2947 v4l2_device_unregister(&jpeg->v4l2_dev);
-2
drivers/media/platform/s5p-jpeg/jpeg-core.h
··· 110 110 * @irq: JPEG IP irq 111 111 * @clocks: JPEG IP clock(s) 112 112 * @dev: JPEG IP struct device 113 - * @alloc_ctx: videobuf2 memory allocator's context 114 113 * @variant: driver variant to be used 115 114 * @irq_status interrupt flags set during single encode/decode 116 115 operation ··· 129 130 enum exynos4_jpeg_result irq_ret; 130 131 struct clk *clocks[JPEG_MAX_CLOCKS]; 131 132 struct device *dev; 132 - void *alloc_ctx; 133 133 struct s5p_jpeg_variant *variant; 134 134 u32 irq_status; 135 135 };
-2
drivers/media/platform/s5p-tv/mixer.h
··· 245 245 246 246 /** V4L2 device */ 247 247 struct v4l2_device v4l2_dev; 248 - /** context of allocator */ 249 - void *alloc_ctx; 250 248 /** event wait queue */ 251 249 wait_queue_head_t event_queue; 252 250 /** state flags */
+2 -13
drivers/media/platform/s5p-tv/mixer_video.c
··· 81 81 } 82 82 83 83 vb2_dma_contig_set_max_seg_size(mdev->dev, DMA_BIT_MASK(32)); 84 - mdev->alloc_ctx = vb2_dma_contig_init_ctx(mdev->dev); 85 - if (IS_ERR(mdev->alloc_ctx)) { 86 - mxr_err(mdev, "could not acquire vb2 allocator\n"); 87 - ret = PTR_ERR(mdev->alloc_ctx); 88 - goto fail_v4l2_dev; 89 - } 90 84 91 85 /* registering outputs */ 92 86 mdev->output_cnt = 0; ··· 115 121 mxr_err(mdev, "failed to register any output\n"); 116 122 ret = -ENODEV; 117 123 /* skipping fail_output because there is nothing to free */ 118 - goto fail_vb2_allocator; 124 + goto fail_v4l2_dev; 119 125 } 120 126 121 127 return 0; ··· 125 131 for (i = 0; i < mdev->output_cnt; ++i) 126 132 kfree(mdev->output[i]); 127 133 memset(mdev->output, 0, sizeof(mdev->output)); 128 - 129 - fail_vb2_allocator: 130 - /* freeing allocator context */ 131 - vb2_dma_contig_cleanup_ctx(mdev->alloc_ctx); 132 134 133 135 fail_v4l2_dev: 134 136 /* NOTE: automatically unregister all subdevs */ ··· 142 152 for (i = 0; i < mdev->output_cnt; ++i) 143 153 kfree(mdev->output[i]); 144 154 145 - vb2_dma_contig_cleanup_ctx(mdev->alloc_ctx); 146 155 vb2_dma_contig_clear_max_seg_size(mdev->dev); 147 156 v4l2_device_unregister(&mdev->v4l2_dev); 148 157 } ··· 892 903 893 904 *nplanes = fmt->num_subframes; 894 905 for (i = 0; i < fmt->num_subframes; ++i) { 895 - alloc_ctxs[i] = layer->mdev->alloc_ctx; 896 906 sizes[i] = planes[i].sizeimage; 897 907 mxr_dbg(mdev, "size[%d] = %08x\n", i, sizes[i]); 898 908 } ··· 1100 1112 .min_buffers_needed = 1, 1101 1113 .mem_ops = &vb2_dma_contig_memops, 1102 1114 .lock = &layer->mutex, 1115 + .dev = mdev->dev, 1103 1116 }; 1104 1117 1105 1118 return layer;