aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mem2mem_testdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/mem2mem_testdev.c')
-rw-r--r--drivers/media/video/mem2mem_testdev.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/media/video/mem2mem_testdev.c b/drivers/media/video/mem2mem_testdev.c
index 3b19f5b25a72..c179041d91f8 100644
--- a/drivers/media/video/mem2mem_testdev.c
+++ b/drivers/media/video/mem2mem_testdev.c
@@ -524,7 +524,6 @@ static int vidioc_s_fmt(struct m2mtest_ctx *ctx, struct v4l2_format *f)
524{ 524{
525 struct m2mtest_q_data *q_data; 525 struct m2mtest_q_data *q_data;
526 struct videobuf_queue *vq; 526 struct videobuf_queue *vq;
527 int ret = 0;
528 527
529 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); 528 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
530 if (!vq) 529 if (!vq)
@@ -534,12 +533,9 @@ static int vidioc_s_fmt(struct m2mtest_ctx *ctx, struct v4l2_format *f)
534 if (!q_data) 533 if (!q_data)
535 return -EINVAL; 534 return -EINVAL;
536 535
537 mutex_lock(&vq->vb_lock);
538
539 if (videobuf_queue_is_busy(vq)) { 536 if (videobuf_queue_is_busy(vq)) {
540 v4l2_err(&ctx->dev->v4l2_dev, "%s queue busy\n", __func__); 537 v4l2_err(&ctx->dev->v4l2_dev, "%s queue busy\n", __func__);
541 ret = -EBUSY; 538 return -EBUSY;
542 goto out;
543 } 539 }
544 540
545 q_data->fmt = find_format(f); 541 q_data->fmt = find_format(f);
@@ -553,9 +549,7 @@ static int vidioc_s_fmt(struct m2mtest_ctx *ctx, struct v4l2_format *f)
553 "Setting format for type %d, wxh: %dx%d, fmt: %d\n", 549 "Setting format for type %d, wxh: %dx%d, fmt: %d\n",
554 f->type, q_data->width, q_data->height, q_data->fmt->fourcc); 550 f->type, q_data->width, q_data->height, q_data->fmt->fourcc);
555 551
556out: 552 return 0;
557 mutex_unlock(&vq->vb_lock);
558 return ret;
559} 553}
560 554
561static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, 555static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
@@ -845,10 +839,12 @@ static void queue_init(void *priv, struct videobuf_queue *vq,
845 enum v4l2_buf_type type) 839 enum v4l2_buf_type type)
846{ 840{
847 struct m2mtest_ctx *ctx = priv; 841 struct m2mtest_ctx *ctx = priv;
842 struct m2mtest_dev *dev = ctx->dev;
848 843
849 videobuf_queue_vmalloc_init(vq, &m2mtest_qops, ctx->dev->v4l2_dev.dev, 844 videobuf_queue_vmalloc_init(vq, &m2mtest_qops, dev->v4l2_dev.dev,
850 &ctx->dev->irqlock, type, V4L2_FIELD_NONE, 845 &dev->irqlock, type, V4L2_FIELD_NONE,
851 sizeof(struct m2mtest_buffer), priv, NULL); 846 sizeof(struct m2mtest_buffer), priv,
847 &dev->dev_mutex);
852} 848}
853 849
854 850
@@ -920,7 +916,7 @@ static const struct v4l2_file_operations m2mtest_fops = {
920 .open = m2mtest_open, 916 .open = m2mtest_open,
921 .release = m2mtest_release, 917 .release = m2mtest_release,
922 .poll = m2mtest_poll, 918 .poll = m2mtest_poll,
923 .ioctl = video_ioctl2, 919 .unlocked_ioctl = video_ioctl2,
924 .mmap = m2mtest_mmap, 920 .mmap = m2mtest_mmap,
925}; 921};
926 922
@@ -965,6 +961,7 @@ static int m2mtest_probe(struct platform_device *pdev)
965 } 961 }
966 962
967 *vfd = m2mtest_videodev; 963 *vfd = m2mtest_videodev;
964 vfd->lock = &dev->dev_mutex;
968 965
969 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); 966 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
970 if (ret) { 967 if (ret) {