diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-09-20 16:24:30 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-20 23:06:14 -0400 |
commit | 97397687886aa8ecd4ec603fab9e70e970c11597 (patch) | |
tree | 339d460b43d2ec7206c9d147d2ad6f8fcbfa3870 | |
parent | ee6869afc922a9849979e49bb3bbcad794872fcb (diff) |
V4L/DVB: videobuf: prepare to make locking optional in videobuf
Currently videobuf uses the vb_lock mutex to lock its data structures.
But this locking will (optionally) move into the v4l2 core, which means
that in that case vb_lock shouldn't be used since the external lock is already
held.
Prepare for this by adding a pointer to such an external mutex and
don't lock if that pointer is set.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/v4l2-mem2mem.c | 8 | ||||
-rw-r--r-- | drivers/media/video/videobuf-core.c | 64 | ||||
-rw-r--r-- | drivers/media/video/videobuf-dma-contig.c | 4 | ||||
-rw-r--r-- | drivers/media/video/videobuf-dma-sg.c | 4 | ||||
-rw-r--r-- | drivers/media/video/videobuf-vmalloc.c | 4 | ||||
-rw-r--r-- | include/media/videobuf-core.h | 13 |
6 files changed, 55 insertions, 42 deletions
diff --git a/drivers/media/video/v4l2-mem2mem.c b/drivers/media/video/v4l2-mem2mem.c index f45f9405ea39..ac832a28e18e 100644 --- a/drivers/media/video/v4l2-mem2mem.c +++ b/drivers/media/video/v4l2-mem2mem.c | |||
@@ -421,8 +421,8 @@ unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | |||
421 | src_q = v4l2_m2m_get_src_vq(m2m_ctx); | 421 | src_q = v4l2_m2m_get_src_vq(m2m_ctx); |
422 | dst_q = v4l2_m2m_get_dst_vq(m2m_ctx); | 422 | dst_q = v4l2_m2m_get_dst_vq(m2m_ctx); |
423 | 423 | ||
424 | mutex_lock(&src_q->vb_lock); | 424 | videobuf_queue_lock(src_q); |
425 | mutex_lock(&dst_q->vb_lock); | 425 | videobuf_queue_lock(dst_q); |
426 | 426 | ||
427 | if (src_q->streaming && !list_empty(&src_q->stream)) | 427 | if (src_q->streaming && !list_empty(&src_q->stream)) |
428 | src_vb = list_first_entry(&src_q->stream, | 428 | src_vb = list_first_entry(&src_q->stream, |
@@ -450,8 +450,8 @@ unsigned int v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, | |||
450 | } | 450 | } |
451 | 451 | ||
452 | end: | 452 | end: |
453 | mutex_unlock(&dst_q->vb_lock); | 453 | videobuf_queue_unlock(dst_q); |
454 | mutex_unlock(&src_q->vb_lock); | 454 | videobuf_queue_unlock(src_q); |
455 | return rc; | 455 | return rc; |
456 | } | 456 | } |
457 | EXPORT_SYMBOL_GPL(v4l2_m2m_poll); | 457 | EXPORT_SYMBOL_GPL(v4l2_m2m_poll); |
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c index ce1595bef629..2930665910b7 100644 --- a/drivers/media/video/videobuf-core.c +++ b/drivers/media/video/videobuf-core.c | |||
@@ -350,9 +350,9 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, | |||
350 | int videobuf_mmap_free(struct videobuf_queue *q) | 350 | int videobuf_mmap_free(struct videobuf_queue *q) |
351 | { | 351 | { |
352 | int ret; | 352 | int ret; |
353 | mutex_lock(&q->vb_lock); | 353 | videobuf_queue_lock(q); |
354 | ret = __videobuf_free(q); | 354 | ret = __videobuf_free(q); |
355 | mutex_unlock(&q->vb_lock); | 355 | videobuf_queue_unlock(q); |
356 | return ret; | 356 | return ret; |
357 | } | 357 | } |
358 | EXPORT_SYMBOL_GPL(videobuf_mmap_free); | 358 | EXPORT_SYMBOL_GPL(videobuf_mmap_free); |
@@ -407,9 +407,9 @@ int videobuf_mmap_setup(struct videobuf_queue *q, | |||
407 | enum v4l2_memory memory) | 407 | enum v4l2_memory memory) |
408 | { | 408 | { |
409 | int ret; | 409 | int ret; |
410 | mutex_lock(&q->vb_lock); | 410 | videobuf_queue_lock(q); |
411 | ret = __videobuf_mmap_setup(q, bcount, bsize, memory); | 411 | ret = __videobuf_mmap_setup(q, bcount, bsize, memory); |
412 | mutex_unlock(&q->vb_lock); | 412 | videobuf_queue_unlock(q); |
413 | return ret; | 413 | return ret; |
414 | } | 414 | } |
415 | EXPORT_SYMBOL_GPL(videobuf_mmap_setup); | 415 | EXPORT_SYMBOL_GPL(videobuf_mmap_setup); |
@@ -432,7 +432,7 @@ int videobuf_reqbufs(struct videobuf_queue *q, | |||
432 | return -EINVAL; | 432 | return -EINVAL; |
433 | } | 433 | } |
434 | 434 | ||
435 | mutex_lock(&q->vb_lock); | 435 | videobuf_queue_lock(q); |
436 | if (req->type != q->type) { | 436 | if (req->type != q->type) { |
437 | dprintk(1, "reqbufs: queue type invalid\n"); | 437 | dprintk(1, "reqbufs: queue type invalid\n"); |
438 | retval = -EINVAL; | 438 | retval = -EINVAL; |
@@ -469,7 +469,7 @@ int videobuf_reqbufs(struct videobuf_queue *q, | |||
469 | retval = 0; | 469 | retval = 0; |
470 | 470 | ||
471 | done: | 471 | done: |
472 | mutex_unlock(&q->vb_lock); | 472 | videobuf_queue_unlock(q); |
473 | return retval; | 473 | return retval; |
474 | } | 474 | } |
475 | EXPORT_SYMBOL_GPL(videobuf_reqbufs); | 475 | EXPORT_SYMBOL_GPL(videobuf_reqbufs); |
@@ -478,7 +478,7 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b) | |||
478 | { | 478 | { |
479 | int ret = -EINVAL; | 479 | int ret = -EINVAL; |
480 | 480 | ||
481 | mutex_lock(&q->vb_lock); | 481 | videobuf_queue_lock(q); |
482 | if (unlikely(b->type != q->type)) { | 482 | if (unlikely(b->type != q->type)) { |
483 | dprintk(1, "querybuf: Wrong type.\n"); | 483 | dprintk(1, "querybuf: Wrong type.\n"); |
484 | goto done; | 484 | goto done; |
@@ -496,7 +496,7 @@ int videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b) | |||
496 | 496 | ||
497 | ret = 0; | 497 | ret = 0; |
498 | done: | 498 | done: |
499 | mutex_unlock(&q->vb_lock); | 499 | videobuf_queue_unlock(q); |
500 | return ret; | 500 | return ret; |
501 | } | 501 | } |
502 | EXPORT_SYMBOL_GPL(videobuf_querybuf); | 502 | EXPORT_SYMBOL_GPL(videobuf_querybuf); |
@@ -513,7 +513,7 @@ int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b) | |||
513 | if (b->memory == V4L2_MEMORY_MMAP) | 513 | if (b->memory == V4L2_MEMORY_MMAP) |
514 | down_read(¤t->mm->mmap_sem); | 514 | down_read(¤t->mm->mmap_sem); |
515 | 515 | ||
516 | mutex_lock(&q->vb_lock); | 516 | videobuf_queue_lock(q); |
517 | retval = -EBUSY; | 517 | retval = -EBUSY; |
518 | if (q->reading) { | 518 | if (q->reading) { |
519 | dprintk(1, "qbuf: Reading running...\n"); | 519 | dprintk(1, "qbuf: Reading running...\n"); |
@@ -605,7 +605,7 @@ int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b) | |||
605 | wake_up_interruptible_sync(&q->wait); | 605 | wake_up_interruptible_sync(&q->wait); |
606 | 606 | ||
607 | done: | 607 | done: |
608 | mutex_unlock(&q->vb_lock); | 608 | videobuf_queue_unlock(q); |
609 | 609 | ||
610 | if (b->memory == V4L2_MEMORY_MMAP) | 610 | if (b->memory == V4L2_MEMORY_MMAP) |
611 | up_read(¤t->mm->mmap_sem); | 611 | up_read(¤t->mm->mmap_sem); |
@@ -635,14 +635,14 @@ checks: | |||
635 | dprintk(2, "next_buffer: waiting on buffer\n"); | 635 | dprintk(2, "next_buffer: waiting on buffer\n"); |
636 | 636 | ||
637 | /* Drop lock to avoid deadlock with qbuf */ | 637 | /* Drop lock to avoid deadlock with qbuf */ |
638 | mutex_unlock(&q->vb_lock); | 638 | videobuf_queue_unlock(q); |
639 | 639 | ||
640 | /* Checking list_empty and streaming is safe without | 640 | /* Checking list_empty and streaming is safe without |
641 | * locks because we goto checks to validate while | 641 | * locks because we goto checks to validate while |
642 | * holding locks before proceeding */ | 642 | * holding locks before proceeding */ |
643 | retval = wait_event_interruptible(q->wait, | 643 | retval = wait_event_interruptible(q->wait, |
644 | !list_empty(&q->stream) || !q->streaming); | 644 | !list_empty(&q->stream) || !q->streaming); |
645 | mutex_lock(&q->vb_lock); | 645 | videobuf_queue_lock(q); |
646 | 646 | ||
647 | if (retval) | 647 | if (retval) |
648 | goto done; | 648 | goto done; |
@@ -687,7 +687,7 @@ int videobuf_dqbuf(struct videobuf_queue *q, | |||
687 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 687 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
688 | 688 | ||
689 | memset(b, 0, sizeof(*b)); | 689 | memset(b, 0, sizeof(*b)); |
690 | mutex_lock(&q->vb_lock); | 690 | videobuf_queue_lock(q); |
691 | 691 | ||
692 | retval = stream_next_buffer(q, &buf, nonblocking); | 692 | retval = stream_next_buffer(q, &buf, nonblocking); |
693 | if (retval < 0) { | 693 | if (retval < 0) { |
@@ -713,7 +713,7 @@ int videobuf_dqbuf(struct videobuf_queue *q, | |||
713 | buf->state = VIDEOBUF_IDLE; | 713 | buf->state = VIDEOBUF_IDLE; |
714 | b->flags &= ~V4L2_BUF_FLAG_DONE; | 714 | b->flags &= ~V4L2_BUF_FLAG_DONE; |
715 | done: | 715 | done: |
716 | mutex_unlock(&q->vb_lock); | 716 | videobuf_queue_unlock(q); |
717 | return retval; | 717 | return retval; |
718 | } | 718 | } |
719 | EXPORT_SYMBOL_GPL(videobuf_dqbuf); | 719 | EXPORT_SYMBOL_GPL(videobuf_dqbuf); |
@@ -724,7 +724,7 @@ int videobuf_streamon(struct videobuf_queue *q) | |||
724 | unsigned long flags = 0; | 724 | unsigned long flags = 0; |
725 | int retval; | 725 | int retval; |
726 | 726 | ||
727 | mutex_lock(&q->vb_lock); | 727 | videobuf_queue_lock(q); |
728 | retval = -EBUSY; | 728 | retval = -EBUSY; |
729 | if (q->reading) | 729 | if (q->reading) |
730 | goto done; | 730 | goto done; |
@@ -740,7 +740,7 @@ int videobuf_streamon(struct videobuf_queue *q) | |||
740 | 740 | ||
741 | wake_up_interruptible_sync(&q->wait); | 741 | wake_up_interruptible_sync(&q->wait); |
742 | done: | 742 | done: |
743 | mutex_unlock(&q->vb_lock); | 743 | videobuf_queue_unlock(q); |
744 | return retval; | 744 | return retval; |
745 | } | 745 | } |
746 | EXPORT_SYMBOL_GPL(videobuf_streamon); | 746 | EXPORT_SYMBOL_GPL(videobuf_streamon); |
@@ -760,9 +760,9 @@ int videobuf_streamoff(struct videobuf_queue *q) | |||
760 | { | 760 | { |
761 | int retval; | 761 | int retval; |
762 | 762 | ||
763 | mutex_lock(&q->vb_lock); | 763 | videobuf_queue_lock(q); |
764 | retval = __videobuf_streamoff(q); | 764 | retval = __videobuf_streamoff(q); |
765 | mutex_unlock(&q->vb_lock); | 765 | videobuf_queue_unlock(q); |
766 | 766 | ||
767 | return retval; | 767 | return retval; |
768 | } | 768 | } |
@@ -868,7 +868,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
868 | 868 | ||
869 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 869 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
870 | 870 | ||
871 | mutex_lock(&q->vb_lock); | 871 | videobuf_queue_lock(q); |
872 | 872 | ||
873 | q->ops->buf_setup(q, &nbufs, &size); | 873 | q->ops->buf_setup(q, &nbufs, &size); |
874 | 874 | ||
@@ -938,7 +938,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
938 | } | 938 | } |
939 | 939 | ||
940 | done: | 940 | done: |
941 | mutex_unlock(&q->vb_lock); | 941 | videobuf_queue_unlock(q); |
942 | return retval; | 942 | return retval; |
943 | } | 943 | } |
944 | EXPORT_SYMBOL_GPL(videobuf_read_one); | 944 | EXPORT_SYMBOL_GPL(videobuf_read_one); |
@@ -999,9 +999,9 @@ int videobuf_read_start(struct videobuf_queue *q) | |||
999 | { | 999 | { |
1000 | int rc; | 1000 | int rc; |
1001 | 1001 | ||
1002 | mutex_lock(&q->vb_lock); | 1002 | videobuf_queue_lock(q); |
1003 | rc = __videobuf_read_start(q); | 1003 | rc = __videobuf_read_start(q); |
1004 | mutex_unlock(&q->vb_lock); | 1004 | videobuf_queue_unlock(q); |
1005 | 1005 | ||
1006 | return rc; | 1006 | return rc; |
1007 | } | 1007 | } |
@@ -1009,15 +1009,15 @@ EXPORT_SYMBOL_GPL(videobuf_read_start); | |||
1009 | 1009 | ||
1010 | void videobuf_read_stop(struct videobuf_queue *q) | 1010 | void videobuf_read_stop(struct videobuf_queue *q) |
1011 | { | 1011 | { |
1012 | mutex_lock(&q->vb_lock); | 1012 | videobuf_queue_lock(q); |
1013 | __videobuf_read_stop(q); | 1013 | __videobuf_read_stop(q); |
1014 | mutex_unlock(&q->vb_lock); | 1014 | videobuf_queue_unlock(q); |
1015 | } | 1015 | } |
1016 | EXPORT_SYMBOL_GPL(videobuf_read_stop); | 1016 | EXPORT_SYMBOL_GPL(videobuf_read_stop); |
1017 | 1017 | ||
1018 | void videobuf_stop(struct videobuf_queue *q) | 1018 | void videobuf_stop(struct videobuf_queue *q) |
1019 | { | 1019 | { |
1020 | mutex_lock(&q->vb_lock); | 1020 | videobuf_queue_lock(q); |
1021 | 1021 | ||
1022 | if (q->streaming) | 1022 | if (q->streaming) |
1023 | __videobuf_streamoff(q); | 1023 | __videobuf_streamoff(q); |
@@ -1025,7 +1025,7 @@ void videobuf_stop(struct videobuf_queue *q) | |||
1025 | if (q->reading) | 1025 | if (q->reading) |
1026 | __videobuf_read_stop(q); | 1026 | __videobuf_read_stop(q); |
1027 | 1027 | ||
1028 | mutex_unlock(&q->vb_lock); | 1028 | videobuf_queue_unlock(q); |
1029 | } | 1029 | } |
1030 | EXPORT_SYMBOL_GPL(videobuf_stop); | 1030 | EXPORT_SYMBOL_GPL(videobuf_stop); |
1031 | 1031 | ||
@@ -1039,7 +1039,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
1039 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 1039 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
1040 | 1040 | ||
1041 | dprintk(2, "%s\n", __func__); | 1041 | dprintk(2, "%s\n", __func__); |
1042 | mutex_lock(&q->vb_lock); | 1042 | videobuf_queue_lock(q); |
1043 | retval = -EBUSY; | 1043 | retval = -EBUSY; |
1044 | if (q->streaming) | 1044 | if (q->streaming) |
1045 | goto done; | 1045 | goto done; |
@@ -1097,7 +1097,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | done: | 1099 | done: |
1100 | mutex_unlock(&q->vb_lock); | 1100 | videobuf_queue_unlock(q); |
1101 | return retval; | 1101 | return retval; |
1102 | } | 1102 | } |
1103 | EXPORT_SYMBOL_GPL(videobuf_read_stream); | 1103 | EXPORT_SYMBOL_GPL(videobuf_read_stream); |
@@ -1109,7 +1109,7 @@ unsigned int videobuf_poll_stream(struct file *file, | |||
1109 | struct videobuf_buffer *buf = NULL; | 1109 | struct videobuf_buffer *buf = NULL; |
1110 | unsigned int rc = 0; | 1110 | unsigned int rc = 0; |
1111 | 1111 | ||
1112 | mutex_lock(&q->vb_lock); | 1112 | videobuf_queue_lock(q); |
1113 | if (q->streaming) { | 1113 | if (q->streaming) { |
1114 | if (!list_empty(&q->stream)) | 1114 | if (!list_empty(&q->stream)) |
1115 | buf = list_entry(q->stream.next, | 1115 | buf = list_entry(q->stream.next, |
@@ -1147,7 +1147,7 @@ unsigned int videobuf_poll_stream(struct file *file, | |||
1147 | } | 1147 | } |
1148 | } | 1148 | } |
1149 | } | 1149 | } |
1150 | mutex_unlock(&q->vb_lock); | 1150 | videobuf_queue_unlock(q); |
1151 | return rc; | 1151 | return rc; |
1152 | } | 1152 | } |
1153 | EXPORT_SYMBOL_GPL(videobuf_poll_stream); | 1153 | EXPORT_SYMBOL_GPL(videobuf_poll_stream); |
@@ -1164,7 +1164,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q, struct vm_area_struct *vma) | |||
1164 | return -EINVAL; | 1164 | return -EINVAL; |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | mutex_lock(&q->vb_lock); | 1167 | videobuf_queue_lock(q); |
1168 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { | 1168 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
1169 | struct videobuf_buffer *buf = q->bufs[i]; | 1169 | struct videobuf_buffer *buf = q->bufs[i]; |
1170 | 1170 | ||
@@ -1174,7 +1174,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q, struct vm_area_struct *vma) | |||
1174 | break; | 1174 | break; |
1175 | } | 1175 | } |
1176 | } | 1176 | } |
1177 | mutex_unlock(&q->vb_lock); | 1177 | videobuf_queue_unlock(q); |
1178 | 1178 | ||
1179 | return rc; | 1179 | return rc; |
1180 | } | 1180 | } |
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c index 6ff9e4bac3ea..047054f79601 100644 --- a/drivers/media/video/videobuf-dma-contig.c +++ b/drivers/media/video/videobuf-dma-contig.c | |||
@@ -63,7 +63,7 @@ static void videobuf_vm_close(struct vm_area_struct *vma) | |||
63 | struct videobuf_dma_contig_memory *mem; | 63 | struct videobuf_dma_contig_memory *mem; |
64 | 64 | ||
65 | dev_dbg(q->dev, "munmap %p q=%p\n", map, q); | 65 | dev_dbg(q->dev, "munmap %p q=%p\n", map, q); |
66 | mutex_lock(&q->vb_lock); | 66 | videobuf_queue_lock(q); |
67 | 67 | ||
68 | /* We need first to cancel streams, before unmapping */ | 68 | /* We need first to cancel streams, before unmapping */ |
69 | if (q->streaming) | 69 | if (q->streaming) |
@@ -103,7 +103,7 @@ static void videobuf_vm_close(struct vm_area_struct *vma) | |||
103 | 103 | ||
104 | kfree(map); | 104 | kfree(map); |
105 | 105 | ||
106 | mutex_unlock(&q->vb_lock); | 106 | videobuf_queue_unlock(q); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 2ad0bc252b0e..515ae887ffcf 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
@@ -358,7 +358,7 @@ static void videobuf_vm_close(struct vm_area_struct *vma) | |||
358 | map->count--; | 358 | map->count--; |
359 | if (0 == map->count) { | 359 | if (0 == map->count) { |
360 | dprintk(1, "munmap %p q=%p\n", map, q); | 360 | dprintk(1, "munmap %p q=%p\n", map, q); |
361 | mutex_lock(&q->vb_lock); | 361 | videobuf_queue_lock(q); |
362 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { | 362 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
363 | if (NULL == q->bufs[i]) | 363 | if (NULL == q->bufs[i]) |
364 | continue; | 364 | continue; |
@@ -374,7 +374,7 @@ static void videobuf_vm_close(struct vm_area_struct *vma) | |||
374 | q->bufs[i]->baddr = 0; | 374 | q->bufs[i]->baddr = 0; |
375 | q->ops->buf_release(q, q->bufs[i]); | 375 | q->ops->buf_release(q, q->bufs[i]); |
376 | } | 376 | } |
377 | mutex_unlock(&q->vb_lock); | 377 | videobuf_queue_unlock(q); |
378 | kfree(map); | 378 | kfree(map); |
379 | } | 379 | } |
380 | return; | 380 | return; |
diff --git a/drivers/media/video/videobuf-vmalloc.c b/drivers/media/video/videobuf-vmalloc.c index e7fe31d54f07..91348b3170ff 100644 --- a/drivers/media/video/videobuf-vmalloc.c +++ b/drivers/media/video/videobuf-vmalloc.c | |||
@@ -75,7 +75,7 @@ static void videobuf_vm_close(struct vm_area_struct *vma) | |||
75 | struct videobuf_vmalloc_memory *mem; | 75 | struct videobuf_vmalloc_memory *mem; |
76 | 76 | ||
77 | dprintk(1, "munmap %p q=%p\n", map, q); | 77 | dprintk(1, "munmap %p q=%p\n", map, q); |
78 | mutex_lock(&q->vb_lock); | 78 | videobuf_queue_lock(q); |
79 | 79 | ||
80 | /* We need first to cancel streams, before unmapping */ | 80 | /* We need first to cancel streams, before unmapping */ |
81 | if (q->streaming) | 81 | if (q->streaming) |
@@ -114,7 +114,7 @@ static void videobuf_vm_close(struct vm_area_struct *vma) | |||
114 | 114 | ||
115 | kfree(map); | 115 | kfree(map); |
116 | 116 | ||
117 | mutex_unlock(&q->vb_lock); | 117 | videobuf_queue_unlock(q); |
118 | } | 118 | } |
119 | 119 | ||
120 | return; | 120 | return; |
diff --git a/include/media/videobuf-core.h b/include/media/videobuf-core.h index f2c41cebf453..f5eb2cbf3002 100644 --- a/include/media/videobuf-core.h +++ b/include/media/videobuf-core.h | |||
@@ -139,6 +139,7 @@ struct videobuf_qtype_ops { | |||
139 | 139 | ||
140 | struct videobuf_queue { | 140 | struct videobuf_queue { |
141 | struct mutex vb_lock; | 141 | struct mutex vb_lock; |
142 | struct mutex *ext_lock; | ||
142 | spinlock_t *irqlock; | 143 | spinlock_t *irqlock; |
143 | struct device *dev; | 144 | struct device *dev; |
144 | 145 | ||
@@ -167,6 +168,18 @@ struct videobuf_queue { | |||
167 | void *priv_data; | 168 | void *priv_data; |
168 | }; | 169 | }; |
169 | 170 | ||
171 | static inline void videobuf_queue_lock(struct videobuf_queue *q) | ||
172 | { | ||
173 | if (!q->ext_lock) | ||
174 | mutex_lock(&q->vb_lock); | ||
175 | } | ||
176 | |||
177 | static inline void videobuf_queue_unlock(struct videobuf_queue *q) | ||
178 | { | ||
179 | if (!q->ext_lock) | ||
180 | mutex_unlock(&q->vb_lock); | ||
181 | } | ||
182 | |||
170 | int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); | 183 | int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr); |
171 | int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, | 184 | int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, |
172 | struct v4l2_framebuffer *fbuf); | 185 | struct v4l2_framebuffer *fbuf); |