diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2014-03-09 19:57:53 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-05-25 10:19:48 -0400 |
commit | 988d54c4b9463bd14bb05e4b8c9a47d04a14d272 (patch) | |
tree | 3b730cd6347c953c7f17e11beed24446c5d0930e /drivers/media | |
parent | 1e345d4ab4a873a0c96ecbdfdd2f9a36998bba6f (diff) |
[media] omap3isp: Move queue mutex to isp_video structure
This prepares for the move to videobuf2.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/platform/omap3isp/ispqueue.c | 102 | ||||
-rw-r--r-- | drivers/media/platform/omap3isp/ispqueue.h | 2 | ||||
-rw-r--r-- | drivers/media/platform/omap3isp/ispvideo.c | 72 | ||||
-rw-r--r-- | drivers/media/platform/omap3isp/ispvideo.h | 1 |
4 files changed, 86 insertions, 91 deletions
diff --git a/drivers/media/platform/omap3isp/ispqueue.c b/drivers/media/platform/omap3isp/ispqueue.c index 515ed94cec48..dcd9446f01a5 100644 --- a/drivers/media/platform/omap3isp/ispqueue.c +++ b/drivers/media/platform/omap3isp/ispqueue.c | |||
@@ -660,7 +660,6 @@ int omap3isp_video_queue_init(struct isp_video_queue *queue, | |||
660 | struct device *dev, unsigned int bufsize) | 660 | struct device *dev, unsigned int bufsize) |
661 | { | 661 | { |
662 | INIT_LIST_HEAD(&queue->queue); | 662 | INIT_LIST_HEAD(&queue->queue); |
663 | mutex_init(&queue->lock); | ||
664 | spin_lock_init(&queue->irqlock); | 663 | spin_lock_init(&queue->irqlock); |
665 | 664 | ||
666 | queue->type = type; | 665 | queue->type = type; |
@@ -712,18 +711,12 @@ int omap3isp_video_queue_reqbufs(struct isp_video_queue *queue, | |||
712 | 711 | ||
713 | nbuffers = min_t(unsigned int, nbuffers, ISP_VIDEO_MAX_BUFFERS); | 712 | nbuffers = min_t(unsigned int, nbuffers, ISP_VIDEO_MAX_BUFFERS); |
714 | 713 | ||
715 | mutex_lock(&queue->lock); | ||
716 | |||
717 | ret = isp_video_queue_alloc(queue, nbuffers, size, rb->memory); | 714 | ret = isp_video_queue_alloc(queue, nbuffers, size, rb->memory); |
718 | if (ret < 0) | 715 | if (ret < 0) |
719 | goto done; | 716 | return ret; |
720 | 717 | ||
721 | rb->count = ret; | 718 | rb->count = ret; |
722 | ret = 0; | 719 | return 0; |
723 | |||
724 | done: | ||
725 | mutex_unlock(&queue->lock); | ||
726 | return ret; | ||
727 | } | 720 | } |
728 | 721 | ||
729 | /** | 722 | /** |
@@ -738,24 +731,17 @@ int omap3isp_video_queue_querybuf(struct isp_video_queue *queue, | |||
738 | struct v4l2_buffer *vbuf) | 731 | struct v4l2_buffer *vbuf) |
739 | { | 732 | { |
740 | struct isp_video_buffer *buf; | 733 | struct isp_video_buffer *buf; |
741 | int ret = 0; | ||
742 | 734 | ||
743 | if (vbuf->type != queue->type) | 735 | if (vbuf->type != queue->type) |
744 | return -EINVAL; | 736 | return -EINVAL; |
745 | 737 | ||
746 | mutex_lock(&queue->lock); | 738 | if (vbuf->index >= queue->count) |
747 | 739 | return -EINVAL; | |
748 | if (vbuf->index >= queue->count) { | ||
749 | ret = -EINVAL; | ||
750 | goto done; | ||
751 | } | ||
752 | 740 | ||
753 | buf = queue->buffers[vbuf->index]; | 741 | buf = queue->buffers[vbuf->index]; |
754 | isp_video_buffer_query(buf, vbuf); | 742 | isp_video_buffer_query(buf, vbuf); |
755 | 743 | ||
756 | done: | 744 | return 0; |
757 | mutex_unlock(&queue->lock); | ||
758 | return ret; | ||
759 | } | 745 | } |
760 | 746 | ||
761 | /** | 747 | /** |
@@ -776,27 +762,25 @@ int omap3isp_video_queue_qbuf(struct isp_video_queue *queue, | |||
776 | { | 762 | { |
777 | struct isp_video_buffer *buf; | 763 | struct isp_video_buffer *buf; |
778 | unsigned long flags; | 764 | unsigned long flags; |
779 | int ret = -EINVAL; | 765 | int ret; |
780 | 766 | ||
781 | if (vbuf->type != queue->type) | 767 | if (vbuf->type != queue->type) |
782 | goto done; | 768 | return -EINVAL; |
783 | |||
784 | mutex_lock(&queue->lock); | ||
785 | 769 | ||
786 | if (vbuf->index >= queue->count) | 770 | if (vbuf->index >= queue->count) |
787 | goto done; | 771 | return -EINVAL; |
788 | 772 | ||
789 | buf = queue->buffers[vbuf->index]; | 773 | buf = queue->buffers[vbuf->index]; |
790 | 774 | ||
791 | if (vbuf->memory != buf->vbuf.memory) | 775 | if (vbuf->memory != buf->vbuf.memory) |
792 | goto done; | 776 | return -EINVAL; |
793 | 777 | ||
794 | if (buf->state != ISP_BUF_STATE_IDLE) | 778 | if (buf->state != ISP_BUF_STATE_IDLE) |
795 | goto done; | 779 | return -EINVAL; |
796 | 780 | ||
797 | if (vbuf->memory == V4L2_MEMORY_USERPTR && | 781 | if (vbuf->memory == V4L2_MEMORY_USERPTR && |
798 | vbuf->length < buf->vbuf.length) | 782 | vbuf->length < buf->vbuf.length) |
799 | goto done; | 783 | return -EINVAL; |
800 | 784 | ||
801 | if (vbuf->memory == V4L2_MEMORY_USERPTR && | 785 | if (vbuf->memory == V4L2_MEMORY_USERPTR && |
802 | vbuf->m.userptr != buf->vbuf.m.userptr) { | 786 | vbuf->m.userptr != buf->vbuf.m.userptr) { |
@@ -808,7 +792,7 @@ int omap3isp_video_queue_qbuf(struct isp_video_queue *queue, | |||
808 | if (!buf->prepared) { | 792 | if (!buf->prepared) { |
809 | ret = isp_video_buffer_prepare(buf); | 793 | ret = isp_video_buffer_prepare(buf); |
810 | if (ret < 0) | 794 | if (ret < 0) |
811 | goto done; | 795 | return ret; |
812 | buf->prepared = 1; | 796 | buf->prepared = 1; |
813 | } | 797 | } |
814 | 798 | ||
@@ -823,11 +807,7 @@ int omap3isp_video_queue_qbuf(struct isp_video_queue *queue, | |||
823 | spin_unlock_irqrestore(&queue->irqlock, flags); | 807 | spin_unlock_irqrestore(&queue->irqlock, flags); |
824 | } | 808 | } |
825 | 809 | ||
826 | ret = 0; | 810 | return 0; |
827 | |||
828 | done: | ||
829 | mutex_unlock(&queue->lock); | ||
830 | return ret; | ||
831 | } | 811 | } |
832 | 812 | ||
833 | /** | 813 | /** |
@@ -853,17 +833,13 @@ int omap3isp_video_queue_dqbuf(struct isp_video_queue *queue, | |||
853 | if (vbuf->type != queue->type) | 833 | if (vbuf->type != queue->type) |
854 | return -EINVAL; | 834 | return -EINVAL; |
855 | 835 | ||
856 | mutex_lock(&queue->lock); | 836 | if (list_empty(&queue->queue)) |
857 | 837 | return -EINVAL; | |
858 | if (list_empty(&queue->queue)) { | ||
859 | ret = -EINVAL; | ||
860 | goto done; | ||
861 | } | ||
862 | 838 | ||
863 | buf = list_first_entry(&queue->queue, struct isp_video_buffer, stream); | 839 | buf = list_first_entry(&queue->queue, struct isp_video_buffer, stream); |
864 | ret = isp_video_buffer_wait(buf, nonblocking); | 840 | ret = isp_video_buffer_wait(buf, nonblocking); |
865 | if (ret < 0) | 841 | if (ret < 0) |
866 | goto done; | 842 | return ret; |
867 | 843 | ||
868 | list_del(&buf->stream); | 844 | list_del(&buf->stream); |
869 | 845 | ||
@@ -871,9 +847,7 @@ int omap3isp_video_queue_dqbuf(struct isp_video_queue *queue, | |||
871 | buf->state = ISP_BUF_STATE_IDLE; | 847 | buf->state = ISP_BUF_STATE_IDLE; |
872 | vbuf->flags &= ~V4L2_BUF_FLAG_QUEUED; | 848 | vbuf->flags &= ~V4L2_BUF_FLAG_QUEUED; |
873 | 849 | ||
874 | done: | 850 | return 0; |
875 | mutex_unlock(&queue->lock); | ||
876 | return ret; | ||
877 | } | 851 | } |
878 | 852 | ||
879 | /** | 853 | /** |
@@ -890,10 +864,8 @@ int omap3isp_video_queue_streamon(struct isp_video_queue *queue) | |||
890 | struct isp_video_buffer *buf; | 864 | struct isp_video_buffer *buf; |
891 | unsigned long flags; | 865 | unsigned long flags; |
892 | 866 | ||
893 | mutex_lock(&queue->lock); | ||
894 | |||
895 | if (queue->streaming) | 867 | if (queue->streaming) |
896 | goto done; | 868 | return 0; |
897 | 869 | ||
898 | queue->streaming = 1; | 870 | queue->streaming = 1; |
899 | 871 | ||
@@ -902,8 +874,6 @@ int omap3isp_video_queue_streamon(struct isp_video_queue *queue) | |||
902 | queue->ops->buffer_queue(buf); | 874 | queue->ops->buffer_queue(buf); |
903 | spin_unlock_irqrestore(&queue->irqlock, flags); | 875 | spin_unlock_irqrestore(&queue->irqlock, flags); |
904 | 876 | ||
905 | done: | ||
906 | mutex_unlock(&queue->lock); | ||
907 | return 0; | 877 | return 0; |
908 | } | 878 | } |
909 | 879 | ||
@@ -923,10 +893,8 @@ void omap3isp_video_queue_streamoff(struct isp_video_queue *queue) | |||
923 | unsigned long flags; | 893 | unsigned long flags; |
924 | unsigned int i; | 894 | unsigned int i; |
925 | 895 | ||
926 | mutex_lock(&queue->lock); | ||
927 | |||
928 | if (!queue->streaming) | 896 | if (!queue->streaming) |
929 | goto done; | 897 | return; |
930 | 898 | ||
931 | queue->streaming = 0; | 899 | queue->streaming = 0; |
932 | 900 | ||
@@ -942,9 +910,6 @@ void omap3isp_video_queue_streamoff(struct isp_video_queue *queue) | |||
942 | spin_unlock_irqrestore(&queue->irqlock, flags); | 910 | spin_unlock_irqrestore(&queue->irqlock, flags); |
943 | 911 | ||
944 | INIT_LIST_HEAD(&queue->queue); | 912 | INIT_LIST_HEAD(&queue->queue); |
945 | |||
946 | done: | ||
947 | mutex_unlock(&queue->lock); | ||
948 | } | 913 | } |
949 | 914 | ||
950 | /** | 915 | /** |
@@ -963,10 +928,8 @@ void omap3isp_video_queue_discard_done(struct isp_video_queue *queue) | |||
963 | struct isp_video_buffer *buf; | 928 | struct isp_video_buffer *buf; |
964 | unsigned int i; | 929 | unsigned int i; |
965 | 930 | ||
966 | mutex_lock(&queue->lock); | ||
967 | |||
968 | if (!queue->streaming) | 931 | if (!queue->streaming) |
969 | goto done; | 932 | return; |
970 | 933 | ||
971 | for (i = 0; i < queue->count; ++i) { | 934 | for (i = 0; i < queue->count; ++i) { |
972 | buf = queue->buffers[i]; | 935 | buf = queue->buffers[i]; |
@@ -974,9 +937,6 @@ void omap3isp_video_queue_discard_done(struct isp_video_queue *queue) | |||
974 | if (buf->state == ISP_BUF_STATE_DONE) | 937 | if (buf->state == ISP_BUF_STATE_DONE) |
975 | buf->state = ISP_BUF_STATE_ERROR; | 938 | buf->state = ISP_BUF_STATE_ERROR; |
976 | } | 939 | } |
977 | |||
978 | done: | ||
979 | mutex_unlock(&queue->lock); | ||
980 | } | 940 | } |
981 | 941 | ||
982 | static void isp_video_queue_vm_open(struct vm_area_struct *vma) | 942 | static void isp_video_queue_vm_open(struct vm_area_struct *vma) |
@@ -1014,26 +974,20 @@ int omap3isp_video_queue_mmap(struct isp_video_queue *queue, | |||
1014 | unsigned int i; | 974 | unsigned int i; |
1015 | int ret = 0; | 975 | int ret = 0; |
1016 | 976 | ||
1017 | mutex_lock(&queue->lock); | ||
1018 | |||
1019 | for (i = 0; i < queue->count; ++i) { | 977 | for (i = 0; i < queue->count; ++i) { |
1020 | buf = queue->buffers[i]; | 978 | buf = queue->buffers[i]; |
1021 | if ((buf->vbuf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff) | 979 | if ((buf->vbuf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff) |
1022 | break; | 980 | break; |
1023 | } | 981 | } |
1024 | 982 | ||
1025 | if (i == queue->count) { | 983 | if (i == queue->count) |
1026 | ret = -EINVAL; | 984 | return -EINVAL; |
1027 | goto done; | ||
1028 | } | ||
1029 | 985 | ||
1030 | size = vma->vm_end - vma->vm_start; | 986 | size = vma->vm_end - vma->vm_start; |
1031 | 987 | ||
1032 | if (buf->vbuf.memory != V4L2_MEMORY_MMAP || | 988 | if (buf->vbuf.memory != V4L2_MEMORY_MMAP || |
1033 | size != PAGE_ALIGN(buf->vbuf.length)) { | 989 | size != PAGE_ALIGN(buf->vbuf.length)) |
1034 | ret = -EINVAL; | 990 | return -EINVAL; |
1035 | goto done; | ||
1036 | } | ||
1037 | 991 | ||
1038 | /* dma_mmap_coherent() uses vm_pgoff as an offset inside the buffer | 992 | /* dma_mmap_coherent() uses vm_pgoff as an offset inside the buffer |
1039 | * while we used it to identify the buffer and want to map the whole | 993 | * while we used it to identify the buffer and want to map the whole |
@@ -1043,16 +997,14 @@ int omap3isp_video_queue_mmap(struct isp_video_queue *queue, | |||
1043 | 997 | ||
1044 | ret = dma_mmap_coherent(queue->dev, vma, buf->vaddr, buf->dma, size); | 998 | ret = dma_mmap_coherent(queue->dev, vma, buf->vaddr, buf->dma, size); |
1045 | if (ret < 0) | 999 | if (ret < 0) |
1046 | goto done; | 1000 | return ret; |
1047 | 1001 | ||
1048 | vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; | 1002 | vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; |
1049 | vma->vm_ops = &isp_video_queue_vm_ops; | 1003 | vma->vm_ops = &isp_video_queue_vm_ops; |
1050 | vma->vm_private_data = buf; | 1004 | vma->vm_private_data = buf; |
1051 | isp_video_queue_vm_open(vma); | 1005 | isp_video_queue_vm_open(vma); |
1052 | 1006 | ||
1053 | done: | 1007 | return 0; |
1054 | mutex_unlock(&queue->lock); | ||
1055 | return ret; | ||
1056 | } | 1008 | } |
1057 | 1009 | ||
1058 | /** | 1010 | /** |
@@ -1070,7 +1022,6 @@ unsigned int omap3isp_video_queue_poll(struct isp_video_queue *queue, | |||
1070 | struct isp_video_buffer *buf; | 1022 | struct isp_video_buffer *buf; |
1071 | unsigned int mask = 0; | 1023 | unsigned int mask = 0; |
1072 | 1024 | ||
1073 | mutex_lock(&queue->lock); | ||
1074 | if (list_empty(&queue->queue)) { | 1025 | if (list_empty(&queue->queue)) { |
1075 | mask |= POLLERR; | 1026 | mask |= POLLERR; |
1076 | goto done; | 1027 | goto done; |
@@ -1087,6 +1038,5 @@ unsigned int omap3isp_video_queue_poll(struct isp_video_queue *queue, | |||
1087 | } | 1038 | } |
1088 | 1039 | ||
1089 | done: | 1040 | done: |
1090 | mutex_unlock(&queue->lock); | ||
1091 | return mask; | 1041 | return mask; |
1092 | } | 1042 | } |
diff --git a/drivers/media/platform/omap3isp/ispqueue.h b/drivers/media/platform/omap3isp/ispqueue.h index 27189bb5a690..ecff055d7a5b 100644 --- a/drivers/media/platform/omap3isp/ispqueue.h +++ b/drivers/media/platform/omap3isp/ispqueue.h | |||
@@ -132,7 +132,6 @@ struct isp_video_queue_operations { | |||
132 | * @bufsize: Size of a driver-specific buffer object | 132 | * @bufsize: Size of a driver-specific buffer object |
133 | * @count: Number of currently allocated buffers | 133 | * @count: Number of currently allocated buffers |
134 | * @buffers: ISP video buffers | 134 | * @buffers: ISP video buffers |
135 | * @lock: Mutex to protect access to the buffers, main queue and state | ||
136 | * @irqlock: Spinlock to protect access to the IRQ queue | 135 | * @irqlock: Spinlock to protect access to the IRQ queue |
137 | * @streaming: Queue state, indicates whether the queue is streaming | 136 | * @streaming: Queue state, indicates whether the queue is streaming |
138 | * @queue: List of all queued buffers | 137 | * @queue: List of all queued buffers |
@@ -145,7 +144,6 @@ struct isp_video_queue { | |||
145 | 144 | ||
146 | unsigned int count; | 145 | unsigned int count; |
147 | struct isp_video_buffer *buffers[ISP_VIDEO_MAX_BUFFERS]; | 146 | struct isp_video_buffer *buffers[ISP_VIDEO_MAX_BUFFERS]; |
148 | struct mutex lock; | ||
149 | spinlock_t irqlock; | 147 | spinlock_t irqlock; |
150 | 148 | ||
151 | unsigned int streaming:1; | 149 | unsigned int streaming:1; |
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index a7ef0816230a..12b0f8c82668 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c | |||
@@ -555,8 +555,11 @@ void omap3isp_video_resume(struct isp_video *video, int continuous) | |||
555 | { | 555 | { |
556 | struct isp_buffer *buf = NULL; | 556 | struct isp_buffer *buf = NULL; |
557 | 557 | ||
558 | if (continuous && video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | 558 | if (continuous && video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { |
559 | mutex_lock(&video->queue_lock); | ||
559 | omap3isp_video_queue_discard_done(video->queue); | 560 | omap3isp_video_queue_discard_done(video->queue); |
561 | mutex_unlock(&video->queue_lock); | ||
562 | } | ||
560 | 563 | ||
561 | if (!list_empty(&video->dmaqueue)) { | 564 | if (!list_empty(&video->dmaqueue)) { |
562 | buf = list_first_entry(&video->dmaqueue, | 565 | buf = list_first_entry(&video->dmaqueue, |
@@ -768,33 +771,57 @@ static int | |||
768 | isp_video_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers *rb) | 771 | isp_video_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers *rb) |
769 | { | 772 | { |
770 | struct isp_video_fh *vfh = to_isp_video_fh(fh); | 773 | struct isp_video_fh *vfh = to_isp_video_fh(fh); |
774 | struct isp_video *video = video_drvdata(file); | ||
775 | int ret; | ||
776 | |||
777 | mutex_lock(&video->queue_lock); | ||
778 | ret = omap3isp_video_queue_reqbufs(&vfh->queue, rb); | ||
779 | mutex_unlock(&video->queue_lock); | ||
771 | 780 | ||
772 | return omap3isp_video_queue_reqbufs(&vfh->queue, rb); | 781 | return ret; |
773 | } | 782 | } |
774 | 783 | ||
775 | static int | 784 | static int |
776 | isp_video_querybuf(struct file *file, void *fh, struct v4l2_buffer *b) | 785 | isp_video_querybuf(struct file *file, void *fh, struct v4l2_buffer *b) |
777 | { | 786 | { |
778 | struct isp_video_fh *vfh = to_isp_video_fh(fh); | 787 | struct isp_video_fh *vfh = to_isp_video_fh(fh); |
788 | struct isp_video *video = video_drvdata(file); | ||
789 | int ret; | ||
779 | 790 | ||
780 | return omap3isp_video_queue_querybuf(&vfh->queue, b); | 791 | mutex_lock(&video->queue_lock); |
792 | ret = omap3isp_video_queue_querybuf(&vfh->queue, b); | ||
793 | mutex_unlock(&video->queue_lock); | ||
794 | |||
795 | return ret; | ||
781 | } | 796 | } |
782 | 797 | ||
783 | static int | 798 | static int |
784 | isp_video_qbuf(struct file *file, void *fh, struct v4l2_buffer *b) | 799 | isp_video_qbuf(struct file *file, void *fh, struct v4l2_buffer *b) |
785 | { | 800 | { |
786 | struct isp_video_fh *vfh = to_isp_video_fh(fh); | 801 | struct isp_video_fh *vfh = to_isp_video_fh(fh); |
802 | struct isp_video *video = video_drvdata(file); | ||
803 | int ret; | ||
804 | |||
805 | mutex_lock(&video->queue_lock); | ||
806 | ret = omap3isp_video_queue_qbuf(&vfh->queue, b); | ||
807 | mutex_unlock(&video->queue_lock); | ||
787 | 808 | ||
788 | return omap3isp_video_queue_qbuf(&vfh->queue, b); | 809 | return ret; |
789 | } | 810 | } |
790 | 811 | ||
791 | static int | 812 | static int |
792 | isp_video_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b) | 813 | isp_video_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b) |
793 | { | 814 | { |
794 | struct isp_video_fh *vfh = to_isp_video_fh(fh); | 815 | struct isp_video_fh *vfh = to_isp_video_fh(fh); |
816 | struct isp_video *video = video_drvdata(file); | ||
817 | int ret; | ||
818 | |||
819 | mutex_lock(&video->queue_lock); | ||
820 | ret = omap3isp_video_queue_dqbuf(&vfh->queue, b, | ||
821 | file->f_flags & O_NONBLOCK); | ||
822 | mutex_unlock(&video->queue_lock); | ||
795 | 823 | ||
796 | return omap3isp_video_queue_dqbuf(&vfh->queue, b, | 824 | return ret; |
797 | file->f_flags & O_NONBLOCK); | ||
798 | } | 825 | } |
799 | 826 | ||
800 | static int isp_video_check_external_subdevs(struct isp_video *video, | 827 | static int isp_video_check_external_subdevs(struct isp_video *video, |
@@ -997,7 +1024,9 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) | |||
997 | INIT_LIST_HEAD(&video->dmaqueue); | 1024 | INIT_LIST_HEAD(&video->dmaqueue); |
998 | atomic_set(&pipe->frame_number, -1); | 1025 | atomic_set(&pipe->frame_number, -1); |
999 | 1026 | ||
1027 | mutex_lock(&video->queue_lock); | ||
1000 | ret = omap3isp_video_queue_streamon(&vfh->queue); | 1028 | ret = omap3isp_video_queue_streamon(&vfh->queue); |
1029 | mutex_unlock(&video->queue_lock); | ||
1001 | if (ret < 0) | 1030 | if (ret < 0) |
1002 | goto err_check_format; | 1031 | goto err_check_format; |
1003 | 1032 | ||
@@ -1022,7 +1051,9 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) | |||
1022 | return 0; | 1051 | return 0; |
1023 | 1052 | ||
1024 | err_set_stream: | 1053 | err_set_stream: |
1054 | mutex_lock(&video->queue_lock); | ||
1025 | omap3isp_video_queue_streamoff(&vfh->queue); | 1055 | omap3isp_video_queue_streamoff(&vfh->queue); |
1056 | mutex_unlock(&video->queue_lock); | ||
1026 | err_check_format: | 1057 | err_check_format: |
1027 | media_entity_pipeline_stop(&video->video.entity); | 1058 | media_entity_pipeline_stop(&video->video.entity); |
1028 | err_pipeline_start: | 1059 | err_pipeline_start: |
@@ -1058,9 +1089,9 @@ isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type) | |||
1058 | mutex_lock(&video->stream_lock); | 1089 | mutex_lock(&video->stream_lock); |
1059 | 1090 | ||
1060 | /* Make sure we're not streaming yet. */ | 1091 | /* Make sure we're not streaming yet. */ |
1061 | mutex_lock(&vfh->queue.lock); | 1092 | mutex_lock(&video->queue_lock); |
1062 | streaming = vfh->queue.streaming; | 1093 | streaming = vfh->queue.streaming; |
1063 | mutex_unlock(&vfh->queue.lock); | 1094 | mutex_unlock(&video->queue_lock); |
1064 | 1095 | ||
1065 | if (!streaming) | 1096 | if (!streaming) |
1066 | goto done; | 1097 | goto done; |
@@ -1079,7 +1110,9 @@ isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type) | |||
1079 | 1110 | ||
1080 | /* Stop the stream. */ | 1111 | /* Stop the stream. */ |
1081 | omap3isp_pipeline_set_stream(pipe, ISP_PIPELINE_STREAM_STOPPED); | 1112 | omap3isp_pipeline_set_stream(pipe, ISP_PIPELINE_STREAM_STOPPED); |
1113 | mutex_lock(&video->queue_lock); | ||
1082 | omap3isp_video_queue_streamoff(&vfh->queue); | 1114 | omap3isp_video_queue_streamoff(&vfh->queue); |
1115 | mutex_unlock(&video->queue_lock); | ||
1083 | video->queue = NULL; | 1116 | video->queue = NULL; |
1084 | video->streaming = 0; | 1117 | video->streaming = 0; |
1085 | video->error = false; | 1118 | video->error = false; |
@@ -1201,9 +1234,9 @@ static int isp_video_release(struct file *file) | |||
1201 | /* Disable streaming and free the buffers queue resources. */ | 1234 | /* Disable streaming and free the buffers queue resources. */ |
1202 | isp_video_streamoff(file, vfh, video->type); | 1235 | isp_video_streamoff(file, vfh, video->type); |
1203 | 1236 | ||
1204 | mutex_lock(&handle->queue.lock); | 1237 | mutex_lock(&video->queue_lock); |
1205 | omap3isp_video_queue_cleanup(&handle->queue); | 1238 | omap3isp_video_queue_cleanup(&handle->queue); |
1206 | mutex_unlock(&handle->queue.lock); | 1239 | mutex_unlock(&video->queue_lock); |
1207 | 1240 | ||
1208 | omap3isp_pipeline_pm_use(&video->video.entity, 0); | 1241 | omap3isp_pipeline_pm_use(&video->video.entity, 0); |
1209 | 1242 | ||
@@ -1220,16 +1253,27 @@ static int isp_video_release(struct file *file) | |||
1220 | static unsigned int isp_video_poll(struct file *file, poll_table *wait) | 1253 | static unsigned int isp_video_poll(struct file *file, poll_table *wait) |
1221 | { | 1254 | { |
1222 | struct isp_video_fh *vfh = to_isp_video_fh(file->private_data); | 1255 | struct isp_video_fh *vfh = to_isp_video_fh(file->private_data); |
1223 | struct isp_video_queue *queue = &vfh->queue; | 1256 | struct isp_video *video = video_drvdata(file); |
1257 | int ret; | ||
1224 | 1258 | ||
1225 | return omap3isp_video_queue_poll(queue, file, wait); | 1259 | mutex_lock(&video->queue_lock); |
1260 | ret = omap3isp_video_queue_poll(&vfh->queue, file, wait); | ||
1261 | mutex_unlock(&video->queue_lock); | ||
1262 | |||
1263 | return ret; | ||
1226 | } | 1264 | } |
1227 | 1265 | ||
1228 | static int isp_video_mmap(struct file *file, struct vm_area_struct *vma) | 1266 | static int isp_video_mmap(struct file *file, struct vm_area_struct *vma) |
1229 | { | 1267 | { |
1230 | struct isp_video_fh *vfh = to_isp_video_fh(file->private_data); | 1268 | struct isp_video_fh *vfh = to_isp_video_fh(file->private_data); |
1269 | struct isp_video *video = video_drvdata(file); | ||
1270 | int ret; | ||
1271 | |||
1272 | mutex_lock(&video->queue_lock); | ||
1273 | ret = omap3isp_video_queue_mmap(&vfh->queue, vma); | ||
1274 | mutex_unlock(&video->queue_lock); | ||
1231 | 1275 | ||
1232 | return omap3isp_video_queue_mmap(&vfh->queue, vma); | 1276 | return ret; |
1233 | } | 1277 | } |
1234 | 1278 | ||
1235 | static struct v4l2_file_operations isp_video_fops = { | 1279 | static struct v4l2_file_operations isp_video_fops = { |
@@ -1279,6 +1323,7 @@ int omap3isp_video_init(struct isp_video *video, const char *name) | |||
1279 | 1323 | ||
1280 | spin_lock_init(&video->pipe.lock); | 1324 | spin_lock_init(&video->pipe.lock); |
1281 | mutex_init(&video->stream_lock); | 1325 | mutex_init(&video->stream_lock); |
1326 | mutex_init(&video->queue_lock); | ||
1282 | 1327 | ||
1283 | /* Initialize the video device. */ | 1328 | /* Initialize the video device. */ |
1284 | if (video->ops == NULL) | 1329 | if (video->ops == NULL) |
@@ -1300,6 +1345,7 @@ int omap3isp_video_init(struct isp_video *video, const char *name) | |||
1300 | void omap3isp_video_cleanup(struct isp_video *video) | 1345 | void omap3isp_video_cleanup(struct isp_video *video) |
1301 | { | 1346 | { |
1302 | media_entity_cleanup(&video->video.entity); | 1347 | media_entity_cleanup(&video->video.entity); |
1348 | mutex_destroy(&video->queue_lock); | ||
1303 | mutex_destroy(&video->stream_lock); | 1349 | mutex_destroy(&video->stream_lock); |
1304 | mutex_destroy(&video->mutex); | 1350 | mutex_destroy(&video->mutex); |
1305 | } | 1351 | } |
diff --git a/drivers/media/platform/omap3isp/ispvideo.h b/drivers/media/platform/omap3isp/ispvideo.h index 4e194076cc60..254e7d20f791 100644 --- a/drivers/media/platform/omap3isp/ispvideo.h +++ b/drivers/media/platform/omap3isp/ispvideo.h | |||
@@ -182,6 +182,7 @@ struct isp_video { | |||
182 | 182 | ||
183 | /* Video buffers queue */ | 183 | /* Video buffers queue */ |
184 | struct isp_video_queue *queue; | 184 | struct isp_video_queue *queue; |
185 | struct mutex queue_lock; /* protects the queue */ | ||
185 | struct list_head dmaqueue; | 186 | struct list_head dmaqueue; |
186 | enum isp_video_dmaqueue_flags dmaqueue_flags; | 187 | enum isp_video_dmaqueue_flags dmaqueue_flags; |
187 | 188 | ||