aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/platform/omap3isp/isp.c6
-rw-r--r--drivers/media/platform/omap3isp/ispqueue.c13
-rw-r--r--drivers/media/platform/omap3isp/ispqueue.h5
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c21
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.h1
5 files changed, 19 insertions, 27 deletions
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 5a4801b76282..2c7aa6720569 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1399,14 +1399,14 @@ int omap3isp_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,
1399 if (isp_pipeline_is_last(me)) { 1399 if (isp_pipeline_is_last(me)) {
1400 struct isp_video *video = pipe->output; 1400 struct isp_video *video = pipe->output;
1401 unsigned long flags; 1401 unsigned long flags;
1402 spin_lock_irqsave(&video->queue->irqlock, flags); 1402 spin_lock_irqsave(&video->irqlock, flags);
1403 if (video->dmaqueue_flags & ISP_VIDEO_DMAQUEUE_UNDERRUN) { 1403 if (video->dmaqueue_flags & ISP_VIDEO_DMAQUEUE_UNDERRUN) {
1404 spin_unlock_irqrestore(&video->queue->irqlock, flags); 1404 spin_unlock_irqrestore(&video->irqlock, flags);
1405 atomic_set(stopping, 0); 1405 atomic_set(stopping, 0);
1406 smp_mb(); 1406 smp_mb();
1407 return 0; 1407 return 0;
1408 } 1408 }
1409 spin_unlock_irqrestore(&video->queue->irqlock, flags); 1409 spin_unlock_irqrestore(&video->irqlock, flags);
1410 if (!wait_event_timeout(*wait, !atomic_read(stopping), 1410 if (!wait_event_timeout(*wait, !atomic_read(stopping),
1411 msecs_to_jiffies(1000))) { 1411 msecs_to_jiffies(1000))) {
1412 atomic_set(stopping, 0); 1412 atomic_set(stopping, 0);
diff --git a/drivers/media/platform/omap3isp/ispqueue.c b/drivers/media/platform/omap3isp/ispqueue.c
index dcd9446f01a5..77afb6370443 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 spin_lock_init(&queue->irqlock);
664 663
665 queue->type = type; 664 queue->type = type;
666 queue->ops = ops; 665 queue->ops = ops;
@@ -761,7 +760,6 @@ int omap3isp_video_queue_qbuf(struct isp_video_queue *queue,
761 struct v4l2_buffer *vbuf) 760 struct v4l2_buffer *vbuf)
762{ 761{
763 struct isp_video_buffer *buf; 762 struct isp_video_buffer *buf;
764 unsigned long flags;
765 int ret; 763 int ret;
766 764
767 if (vbuf->type != queue->type) 765 if (vbuf->type != queue->type)
@@ -801,11 +799,8 @@ int omap3isp_video_queue_qbuf(struct isp_video_queue *queue,
801 buf->state = ISP_BUF_STATE_QUEUED; 799 buf->state = ISP_BUF_STATE_QUEUED;
802 list_add_tail(&buf->stream, &queue->queue); 800 list_add_tail(&buf->stream, &queue->queue);
803 801
804 if (queue->streaming) { 802 if (queue->streaming)
805 spin_lock_irqsave(&queue->irqlock, flags);
806 queue->ops->buffer_queue(buf); 803 queue->ops->buffer_queue(buf);
807 spin_unlock_irqrestore(&queue->irqlock, flags);
808 }
809 804
810 return 0; 805 return 0;
811} 806}
@@ -862,17 +857,14 @@ int omap3isp_video_queue_dqbuf(struct isp_video_queue *queue,
862int omap3isp_video_queue_streamon(struct isp_video_queue *queue) 857int omap3isp_video_queue_streamon(struct isp_video_queue *queue)
863{ 858{
864 struct isp_video_buffer *buf; 859 struct isp_video_buffer *buf;
865 unsigned long flags;
866 860
867 if (queue->streaming) 861 if (queue->streaming)
868 return 0; 862 return 0;
869 863
870 queue->streaming = 1; 864 queue->streaming = 1;
871 865
872 spin_lock_irqsave(&queue->irqlock, flags);
873 list_for_each_entry(buf, &queue->queue, stream) 866 list_for_each_entry(buf, &queue->queue, stream)
874 queue->ops->buffer_queue(buf); 867 queue->ops->buffer_queue(buf);
875 spin_unlock_irqrestore(&queue->irqlock, flags);
876 868
877 return 0; 869 return 0;
878} 870}
@@ -890,7 +882,6 @@ int omap3isp_video_queue_streamon(struct isp_video_queue *queue)
890void omap3isp_video_queue_streamoff(struct isp_video_queue *queue) 882void omap3isp_video_queue_streamoff(struct isp_video_queue *queue)
891{ 883{
892 struct isp_video_buffer *buf; 884 struct isp_video_buffer *buf;
893 unsigned long flags;
894 unsigned int i; 885 unsigned int i;
895 886
896 if (!queue->streaming) 887 if (!queue->streaming)
@@ -898,7 +889,6 @@ void omap3isp_video_queue_streamoff(struct isp_video_queue *queue)
898 889
899 queue->streaming = 0; 890 queue->streaming = 0;
900 891
901 spin_lock_irqsave(&queue->irqlock, flags);
902 for (i = 0; i < queue->count; ++i) { 892 for (i = 0; i < queue->count; ++i) {
903 buf = queue->buffers[i]; 893 buf = queue->buffers[i];
904 894
@@ -907,7 +897,6 @@ void omap3isp_video_queue_streamoff(struct isp_video_queue *queue)
907 897
908 buf->state = ISP_BUF_STATE_IDLE; 898 buf->state = ISP_BUF_STATE_IDLE;
909 } 899 }
910 spin_unlock_irqrestore(&queue->irqlock, flags);
911 900
912 INIT_LIST_HEAD(&queue->queue); 901 INIT_LIST_HEAD(&queue->queue);
913} 902}
diff --git a/drivers/media/platform/omap3isp/ispqueue.h b/drivers/media/platform/omap3isp/ispqueue.h
index ecff055d7a5b..ecf330960ee5 100644
--- a/drivers/media/platform/omap3isp/ispqueue.h
+++ b/drivers/media/platform/omap3isp/ispqueue.h
@@ -114,8 +114,7 @@ struct isp_video_buffer {
114 * the userspace memory address for a USERPTR buffer, with the queue lock 114 * the userspace memory address for a USERPTR buffer, with the queue lock
115 * held. Drivers should perform device-specific buffer preparation (such as 115 * held. Drivers should perform device-specific buffer preparation (such as
116 * mapping the buffer memory in an IOMMU). This operation is optional. 116 * mapping the buffer memory in an IOMMU). This operation is optional.
117 * @buffer_queue: Called when a buffer is being added to the queue with the 117 * @buffer_queue: Called when a buffer is being added.
118 * queue irqlock spinlock held.
119 */ 118 */
120struct isp_video_queue_operations { 119struct isp_video_queue_operations {
121 void (*queue_prepare)(struct isp_video_queue *queue, 120 void (*queue_prepare)(struct isp_video_queue *queue,
@@ -132,7 +131,6 @@ struct isp_video_queue_operations {
132 * @bufsize: Size of a driver-specific buffer object 131 * @bufsize: Size of a driver-specific buffer object
133 * @count: Number of currently allocated buffers 132 * @count: Number of currently allocated buffers
134 * @buffers: ISP video buffers 133 * @buffers: ISP video buffers
135 * @irqlock: Spinlock to protect access to the IRQ queue
136 * @streaming: Queue state, indicates whether the queue is streaming 134 * @streaming: Queue state, indicates whether the queue is streaming
137 * @queue: List of all queued buffers 135 * @queue: List of all queued buffers
138 */ 136 */
@@ -144,7 +142,6 @@ struct isp_video_queue {
144 142
145 unsigned int count; 143 unsigned int count;
146 struct isp_video_buffer *buffers[ISP_VIDEO_MAX_BUFFERS]; 144 struct isp_video_buffer *buffers[ISP_VIDEO_MAX_BUFFERS];
147 spinlock_t irqlock;
148 145
149 unsigned int streaming:1; 146 unsigned int streaming:1;
150 147
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 12b0f8c82668..85338d33442f 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -381,15 +381,20 @@ static void isp_video_buffer_queue(struct isp_video_buffer *buf)
381 unsigned int empty; 381 unsigned int empty;
382 unsigned int start; 382 unsigned int start;
383 383
384 spin_lock_irqsave(&video->irqlock, flags);
385
384 if (unlikely(video->error)) { 386 if (unlikely(video->error)) {
385 buf->state = ISP_BUF_STATE_ERROR; 387 buf->state = ISP_BUF_STATE_ERROR;
386 wake_up(&buf->wait); 388 wake_up(&buf->wait);
389 spin_unlock_irqrestore(&video->irqlock, flags);
387 return; 390 return;
388 } 391 }
389 392
390 empty = list_empty(&video->dmaqueue); 393 empty = list_empty(&video->dmaqueue);
391 list_add_tail(&buffer->buffer.irqlist, &video->dmaqueue); 394 list_add_tail(&buffer->buffer.irqlist, &video->dmaqueue);
392 395
396 spin_unlock_irqrestore(&video->irqlock, flags);
397
393 if (empty) { 398 if (empty) {
394 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) 399 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
395 state = ISP_PIPELINE_QUEUE_OUTPUT; 400 state = ISP_PIPELINE_QUEUE_OUTPUT;
@@ -445,16 +450,16 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
445 unsigned long flags; 450 unsigned long flags;
446 struct timespec ts; 451 struct timespec ts;
447 452
448 spin_lock_irqsave(&queue->irqlock, flags); 453 spin_lock_irqsave(&video->irqlock, flags);
449 if (WARN_ON(list_empty(&video->dmaqueue))) { 454 if (WARN_ON(list_empty(&video->dmaqueue))) {
450 spin_unlock_irqrestore(&queue->irqlock, flags); 455 spin_unlock_irqrestore(&video->irqlock, flags);
451 return NULL; 456 return NULL;
452 } 457 }
453 458
454 buf = list_first_entry(&video->dmaqueue, struct isp_video_buffer, 459 buf = list_first_entry(&video->dmaqueue, struct isp_video_buffer,
455 irqlist); 460 irqlist);
456 list_del(&buf->irqlist); 461 list_del(&buf->irqlist);
457 spin_unlock_irqrestore(&queue->irqlock, flags); 462 spin_unlock_irqrestore(&video->irqlock, flags);
458 463
459 buf->vbuf.bytesused = vfh->format.fmt.pix.sizeimage; 464 buf->vbuf.bytesused = vfh->format.fmt.pix.sizeimage;
460 465
@@ -520,10 +525,9 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
520 */ 525 */
521void omap3isp_video_cancel_stream(struct isp_video *video) 526void omap3isp_video_cancel_stream(struct isp_video *video)
522{ 527{
523 struct isp_video_queue *queue = video->queue;
524 unsigned long flags; 528 unsigned long flags;
525 529
526 spin_lock_irqsave(&queue->irqlock, flags); 530 spin_lock_irqsave(&video->irqlock, flags);
527 531
528 while (!list_empty(&video->dmaqueue)) { 532 while (!list_empty(&video->dmaqueue)) {
529 struct isp_video_buffer *buf; 533 struct isp_video_buffer *buf;
@@ -538,7 +542,7 @@ void omap3isp_video_cancel_stream(struct isp_video *video)
538 542
539 video->error = true; 543 video->error = true;
540 544
541 spin_unlock_irqrestore(&queue->irqlock, flags); 545 spin_unlock_irqrestore(&video->irqlock, flags);
542} 546}
543 547
544/* 548/*
@@ -1039,10 +1043,10 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
1039 ISP_PIPELINE_STREAM_CONTINUOUS); 1043 ISP_PIPELINE_STREAM_CONTINUOUS);
1040 if (ret < 0) 1044 if (ret < 0)
1041 goto err_set_stream; 1045 goto err_set_stream;
1042 spin_lock_irqsave(&video->queue->irqlock, flags); 1046 spin_lock_irqsave(&video->irqlock, flags);
1043 if (list_empty(&video->dmaqueue)) 1047 if (list_empty(&video->dmaqueue))
1044 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN; 1048 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN;
1045 spin_unlock_irqrestore(&video->queue->irqlock, flags); 1049 spin_unlock_irqrestore(&video->irqlock, flags);
1046 } 1050 }
1047 1051
1048 video->streaming = 1; 1052 video->streaming = 1;
@@ -1324,6 +1328,7 @@ int omap3isp_video_init(struct isp_video *video, const char *name)
1324 spin_lock_init(&video->pipe.lock); 1328 spin_lock_init(&video->pipe.lock);
1325 mutex_init(&video->stream_lock); 1329 mutex_init(&video->stream_lock);
1326 mutex_init(&video->queue_lock); 1330 mutex_init(&video->queue_lock);
1331 spin_lock_init(&video->irqlock);
1327 1332
1328 /* Initialize the video device. */ 1333 /* Initialize the video device. */
1329 if (video->ops == NULL) 1334 if (video->ops == NULL)
diff --git a/drivers/media/platform/omap3isp/ispvideo.h b/drivers/media/platform/omap3isp/ispvideo.h
index 254e7d20f791..0fa098cc04bb 100644
--- a/drivers/media/platform/omap3isp/ispvideo.h
+++ b/drivers/media/platform/omap3isp/ispvideo.h
@@ -183,6 +183,7 @@ struct isp_video {
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 mutex queue_lock; /* protects the queue */
186 spinlock_t irqlock; /* protects dmaqueue */
186 struct list_head dmaqueue; 187 struct list_head dmaqueue;
187 enum isp_video_dmaqueue_flags dmaqueue_flags; 188 enum isp_video_dmaqueue_flags dmaqueue_flags;
188 189