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
2548fee6 c781e4a5

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