Skip to content

Commit c781e4a

Browse files
Hans Verkuilmchehab
authored andcommitted
[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>
1 parent 8e9bca3 commit c781e4a

12 files changed

Lines changed: 15 additions & 68 deletions

File tree

‎drivers/media/platform/exynos-gsc/gsc-core.c‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,20 +1123,13 @@ static int gsc_probe(struct platform_device *pdev)
11231123
if (ret < 0)
11241124
goto err_m2m;
11251125

1126-
/* Initialize continious memory allocator */
11271126
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-
}
11331127

11341128
dev_dbg(dev, "gsc-%d registered successfully\n", gsc->id);
11351129

11361130
pm_runtime_put(dev);
11371131
return 0;
1138-
err_pm:
1139-
pm_runtime_put(dev);
1132+
11401133
err_m2m:
11411134
gsc_unregister_m2m_device(gsc);
11421135
err_v4l2:
@@ -1153,7 +1146,6 @@ static int gsc_remove(struct platform_device *pdev)
11531146
gsc_unregister_m2m_device(gsc);
11541147
v4l2_device_unregister(&gsc->v4l2_dev);
11551148

1156-
vb2_dma_contig_cleanup_ctx(gsc->alloc_ctx);
11571149
vb2_dma_contig_clear_max_seg_size(&pdev->dev);
11581150
pm_runtime_disable(&pdev->dev);
11591151
gsc_clk_put(gsc);

‎drivers/media/platform/exynos-gsc/gsc-core.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ struct gsc_dev {
341341
wait_queue_head_t irq_queue;
342342
struct gsc_m2m_device m2m;
343343
unsigned long state;
344-
struct vb2_alloc_ctx *alloc_ctx;
345344
struct video_device vdev;
346345
struct v4l2_device v4l2_dev;
347346
};

‎drivers/media/platform/exynos-gsc/gsc-m2m.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,8 @@ static int gsc_m2m_queue_setup(struct vb2_queue *vq,
227227
return -EINVAL;
228228

229229
*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++)
231231
sizes[i] = frame->payload[i];
232-
allocators[i] = ctx->gsc_dev->alloc_ctx;
233-
}
234232
return 0;
235233
}
236234

@@ -591,6 +589,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
591589
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
592590
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
593591
src_vq->lock = &ctx->gsc_dev->lock;
592+
src_vq->dev = &ctx->gsc_dev->pdev->dev;
594593

595594
ret = vb2_queue_init(src_vq);
596595
if (ret)
@@ -605,6 +604,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
605604
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
606605
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
607606
dst_vq->lock = &ctx->gsc_dev->lock;
607+
dst_vq->dev = &ctx->gsc_dev->pdev->dev;
608608

609609
return vb2_queue_init(dst_vq);
610610
}

‎drivers/media/platform/s3c-camif/camif-capture.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ static int queue_setup(struct vb2_queue *vq,
440440
unsigned int sizes[], void *allocators[])
441441
{
442442
struct camif_vp *vp = vb2_get_drv_priv(vq);
443-
struct camif_dev *camif = vp->camif;
444443
struct camif_frame *frame = &vp->out_frame;
445444
const struct camif_fmt *fmt = vp->out_fmt;
446445
unsigned int size;
@@ -449,7 +448,6 @@ static int queue_setup(struct vb2_queue *vq,
449448
return -EINVAL;
450449

451450
size = (frame->f_width * frame->f_height * fmt->depth) / 8;
452-
allocators[0] = camif->alloc_ctx;
453451

454452
if (*num_planes)
455453
return sizes[0] < size ? -EINVAL : 0;
@@ -1138,6 +1136,7 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
11381136
q->drv_priv = vp;
11391137
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
11401138
q->lock = &vp->camif->lock;
1139+
q->dev = camif->v4l2_dev.dev;
11411140

11421141
ret = vb2_queue_init(q);
11431142
if (ret)

‎drivers/media/platform/s3c-camif/camif-core.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -474,16 +474,9 @@ static int s3c_camif_probe(struct platform_device *pdev)
474474
if (ret < 0)
475475
goto err_pm;
476476

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-
484477
ret = camif_media_dev_init(camif);
485478
if (ret < 0)
486-
goto err_mdev;
479+
goto err_alloc;
487480

488481
ret = camif_register_sensor(camif);
489482
if (ret < 0)
@@ -517,8 +510,6 @@ static int s3c_camif_probe(struct platform_device *pdev)
517510
media_device_unregister(&camif->media_dev);
518511
media_device_cleanup(&camif->media_dev);
519512
camif_unregister_media_entities(camif);
520-
err_mdev:
521-
vb2_dma_contig_cleanup_ctx(camif->alloc_ctx);
522513
err_alloc:
523514
pm_runtime_put(dev);
524515
pm_runtime_disable(dev);

‎drivers/media/platform/s3c-camif/camif-core.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ struct camif_vp {
254254
* @ctrl_handler: v4l2 control handler (owned by @subdev)
255255
* @test_pattern: test pattern controls
256256
* @vp: video path (DMA) description (codec/preview)
257-
* @alloc_ctx: memory buffer allocator context
258257
* @variant: variant information for this device
259258
* @dev: pointer to the CAMIF device struct
260259
* @pdata: a copy of the driver's platform data
@@ -291,7 +290,6 @@ struct camif_dev {
291290
u8 colorfx_cr;
292291

293292
struct camif_vp vp[CAMIF_VP_NUM];
294-
struct vb2_alloc_ctx *alloc_ctx;
295293

296294
const struct s3c_camif_variant *variant;
297295
struct device *dev;

‎drivers/media/platform/s5p-g2d/g2d.c‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ static int g2d_queue_setup(struct vb2_queue *vq,
113113

114114
sizes[0] = f->size;
115115
*nplanes = 1;
116-
alloc_ctxs[0] = ctx->dev->alloc_ctx;
117116

118117
if (*nbuffers == 0)
119118
*nbuffers = 1;
@@ -159,6 +158,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
159158
src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
160159
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
161160
src_vq->lock = &ctx->dev->mutex;
161+
src_vq->dev = ctx->dev->v4l2_dev.dev;
162162

163163
ret = vb2_queue_init(src_vq);
164164
if (ret)
@@ -172,6 +172,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
172172
dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
173173
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
174174
dst_vq->lock = &ctx->dev->mutex;
175+
dst_vq->dev = ctx->dev->v4l2_dev.dev;
175176

176177
return vb2_queue_init(dst_vq);
177178
}
@@ -682,15 +683,10 @@ static int g2d_probe(struct platform_device *pdev)
682683
}
683684

684685
vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
685-
dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
686-
if (IS_ERR(dev->alloc_ctx)) {
687-
ret = PTR_ERR(dev->alloc_ctx);
688-
goto unprep_clk_gate;
689-
}
690686

691687
ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
692688
if (ret)
693-
goto alloc_ctx_cleanup;
689+
goto unprep_clk_gate;
694690
vfd = video_device_alloc();
695691
if (!vfd) {
696692
v4l2_err(&dev->v4l2_dev, "Failed to allocate video device\n");
@@ -735,8 +731,6 @@ static int g2d_probe(struct platform_device *pdev)
735731
video_device_release(vfd);
736732
unreg_v4l2_dev:
737733
v4l2_device_unregister(&dev->v4l2_dev);
738-
alloc_ctx_cleanup:
739-
vb2_dma_contig_cleanup_ctx(dev->alloc_ctx);
740734
unprep_clk_gate:
741735
clk_unprepare(dev->gate);
742736
put_clk_gate:
@@ -757,7 +751,6 @@ static int g2d_remove(struct platform_device *pdev)
757751
v4l2_m2m_release(dev->m2m_dev);
758752
video_unregister_device(dev->vfd);
759753
v4l2_device_unregister(&dev->v4l2_dev);
760-
vb2_dma_contig_cleanup_ctx(dev->alloc_ctx);
761754
vb2_dma_contig_clear_max_seg_size(&pdev->dev);
762755
clk_unprepare(dev->gate);
763756
clk_put(dev->gate);

‎drivers/media/platform/s5p-g2d/g2d.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ struct g2d_dev {
2525
struct mutex mutex;
2626
spinlock_t ctrl_lock;
2727
atomic_t num_inst;
28-
struct vb2_alloc_ctx *alloc_ctx;
2928
void __iomem *regs;
3029
struct clk *clk;
3130
struct clk *gate;

‎drivers/media/platform/s5p-jpeg/jpeg-core.c‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,6 @@ static int s5p_jpeg_queue_setup(struct vb2_queue *vq,
24572457
*nbuffers = count;
24582458
*nplanes = 1;
24592459
sizes[0] = size;
2460-
alloc_ctxs[0] = ctx->jpeg->alloc_ctx;
24612460

24622461
return 0;
24632462
}
@@ -2563,6 +2562,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
25632562
src_vq->mem_ops = &vb2_dma_contig_memops;
25642563
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
25652564
src_vq->lock = &ctx->jpeg->lock;
2565+
src_vq->dev = ctx->jpeg->dev;
25662566

25672567
ret = vb2_queue_init(src_vq);
25682568
if (ret)
@@ -2576,6 +2576,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
25762576
dst_vq->mem_ops = &vb2_dma_contig_memops;
25772577
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
25782578
dst_vq->lock = &ctx->jpeg->lock;
2579+
dst_vq->dev = ctx->jpeg->dev;
25792580

25802581
return vb2_queue_init(dst_vq);
25812582
}
@@ -2844,19 +2845,13 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
28442845
}
28452846

28462847
vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
2847-
jpeg->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
2848-
if (IS_ERR(jpeg->alloc_ctx)) {
2849-
v4l2_err(&jpeg->v4l2_dev, "Failed to init memory allocator\n");
2850-
ret = PTR_ERR(jpeg->alloc_ctx);
2851-
goto m2m_init_rollback;
2852-
}
28532848

28542849
/* JPEG encoder /dev/videoX node */
28552850
jpeg->vfd_encoder = video_device_alloc();
28562851
if (!jpeg->vfd_encoder) {
28572852
v4l2_err(&jpeg->v4l2_dev, "Failed to allocate video device\n");
28582853
ret = -ENOMEM;
2859-
goto vb2_allocator_rollback;
2854+
goto m2m_init_rollback;
28602855
}
28612856
snprintf(jpeg->vfd_encoder->name, sizeof(jpeg->vfd_encoder->name),
28622857
"%s-enc", S5P_JPEG_M2M_NAME);
@@ -2872,7 +2867,7 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
28722867
if (ret) {
28732868
v4l2_err(&jpeg->v4l2_dev, "Failed to register video device\n");
28742869
video_device_release(jpeg->vfd_encoder);
2875-
goto vb2_allocator_rollback;
2870+
goto m2m_init_rollback;
28762871
}
28772872

28782873
video_set_drvdata(jpeg->vfd_encoder, jpeg);
@@ -2921,9 +2916,6 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
29212916
enc_vdev_register_rollback:
29222917
video_unregister_device(jpeg->vfd_encoder);
29232918

2924-
vb2_allocator_rollback:
2925-
vb2_dma_contig_cleanup_ctx(jpeg->alloc_ctx);
2926-
29272919
m2m_init_rollback:
29282920
v4l2_m2m_release(jpeg->m2m_dev);
29292921

@@ -2942,7 +2934,6 @@ static int s5p_jpeg_remove(struct platform_device *pdev)
29422934

29432935
video_unregister_device(jpeg->vfd_decoder);
29442936
video_unregister_device(jpeg->vfd_encoder);
2945-
vb2_dma_contig_cleanup_ctx(jpeg->alloc_ctx);
29462937
vb2_dma_contig_clear_max_seg_size(&pdev->dev);
29472938
v4l2_m2m_release(jpeg->m2m_dev);
29482939
v4l2_device_unregister(&jpeg->v4l2_dev);

‎drivers/media/platform/s5p-jpeg/jpeg-core.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ enum exynos4_jpeg_img_quality_level {
110110
* @irq: JPEG IP irq
111111
* @clocks: JPEG IP clock(s)
112112
* @dev: JPEG IP struct device
113-
* @alloc_ctx: videobuf2 memory allocator's context
114113
* @variant: driver variant to be used
115114
* @irq_status interrupt flags set during single encode/decode
116115
operation
@@ -130,7 +129,6 @@ struct s5p_jpeg {
130129
enum exynos4_jpeg_result irq_ret;
131130
struct clk *clocks[JPEG_MAX_CLOCKS];
132131
struct device *dev;
133-
void *alloc_ctx;
134132
struct s5p_jpeg_variant *variant;
135133
u32 irq_status;
136134
};

0 commit comments

Comments
 (0)