Lines Matching refs:queue

4  * TI OMAP3 ISP - Video buffers queue handling
266 if (buf->queue->ops->buffer_cleanup)
267 buf->queue->ops->buffer_cleanup(buf);
272 dma_unmap_sg(buf->queue->dev, buf->sglist, buf->sglen,
520 ret = dma_map_sg(buf->queue->dev, buf->sglist, buf->sglen,
528 if (buf->queue->ops->buffer_prepare)
529 ret = buf->queue->ops->buffer_prepare(buf);
543 * Locking: must be called with the queue lock held.
575 * queue using the same condition.
597 * Buffers can only be freed if the queue isn't streaming and if no buffer is
600 * This function must be called with the queue lock held.
602 static int isp_video_queue_free(struct isp_video_queue *queue)
606 if (queue->streaming)
609 for (i = 0; i < queue->count; ++i) {
610 if (queue->buffers[i]->vma_use_count != 0)
614 for (i = 0; i < queue->count; ++i) {
615 struct isp_video_buffer *buf = queue->buffers[i];
623 queue->buffers[i] = NULL;
626 INIT_LIST_HEAD(&queue->queue);
627 queue->count = 0;
634 * This function must be called with the queue lock held.
636 static int isp_video_queue_alloc(struct isp_video_queue *queue,
646 ret = isp_video_queue_free(queue);
656 buf = kzalloc(queue->bufsize, GFP_KERNEL);
676 buf->vbuf.type = queue->type;
680 buf->queue = queue;
683 queue->buffers[i] = buf;
689 queue->count = i;
694 * omap3isp_video_queue_cleanup - Clean up the video buffers queue
695 * @queue: Video buffers queue
697 * Free all allocated resources and clean up the video buffers queue. The queue
701 * Return 0 on success or -EBUSY if the queue is busy or buffers haven't been
704 int omap3isp_video_queue_cleanup(struct isp_video_queue *queue)
706 return isp_video_queue_free(queue);
710 * omap3isp_video_queue_init - Initialize the video buffers queue
711 * @queue: Video buffers queue
713 * @ops: Driver-specific queue operations
717 * Initialize the video buffers queue with the supplied parameters.
719 * The queue type must be one of V4L2_BUF_TYPE_VIDEO_CAPTURE or
730 int omap3isp_video_queue_init(struct isp_video_queue *queue,
735 INIT_LIST_HEAD(&queue->queue);
736 mutex_init(&queue->lock);
737 spin_lock_init(&queue->irqlock);
739 queue->type = type;
740 queue->ops = ops;
741 queue->dev = dev;
742 queue->bufsize = bufsize;
769 * -EBUSY if the queue is busy (streaming or buffers mapped)
772 int omap3isp_video_queue_reqbufs(struct isp_video_queue *queue,
779 if (rb->type != queue->type)
782 queue->ops->queue_prepare(queue, &nbuffers, &size);
788 mutex_lock(&queue->lock);
790 ret = isp_video_queue_alloc(queue, nbuffers, size, rb->memory);
798 mutex_unlock(&queue->lock);
803 * omap3isp_video_queue_querybuf - Query the status of a buffer in a queue
810 int omap3isp_video_queue_querybuf(struct isp_video_queue *queue,
816 if (vbuf->type != queue->type)
819 mutex_lock(&queue->lock);
821 if (vbuf->index >= queue->count) {
826 buf = queue->buffers[vbuf->index];
830 mutex_unlock(&queue->lock);
840 * sane, the buffer is then processed and added to the main queue and, if the
841 * queue is streaming, to the IRQ queue.
847 int omap3isp_video_queue_qbuf(struct isp_video_queue *queue,
854 if (vbuf->type != queue->type)
857 mutex_lock(&queue->lock);
859 if (vbuf->index >= queue->count)
862 buf = queue->buffers[vbuf->index];
891 list_add_tail(&buf->stream, &queue->queue);
893 if (queue->streaming) {
894 spin_lock_irqsave(&queue->irqlock, flags);
895 queue->ops->buffer_queue(buf);
896 spin_unlock_irqrestore(&queue->irqlock, flags);
902 mutex_unlock(&queue->lock);
912 * sane, the buffer is then processed and added to the main queue and, if the
913 * queue is streaming, to the IRQ queue.
919 int omap3isp_video_queue_dqbuf(struct isp_video_queue *queue,
925 if (vbuf->type != queue->type)
928 mutex_lock(&queue->lock);
930 if (list_empty(&queue->queue)) {
935 buf = list_first_entry(&queue->queue, struct isp_video_buffer, stream);
947 mutex_unlock(&queue->lock);
955 * starts streaming on the queue and calls the buffer_queue operation for all
960 int omap3isp_video_queue_streamon(struct isp_video_queue *queue)
965 mutex_lock(&queue->lock);
967 if (queue->streaming)
970 queue->streaming = 1;
972 spin_lock_irqsave(&queue->irqlock, flags);
973 list_for_each_entry(buf, &queue->queue, stream)
974 queue->ops->buffer_queue(buf);
975 spin_unlock_irqrestore(&queue->irqlock, flags);
978 mutex_unlock(&queue->lock);
986 * stops streaming on the queue and wakes up all the buffers.
992 void omap3isp_video_queue_streamoff(struct isp_video_queue *queue)
998 mutex_lock(&queue->lock);
1000 if (!queue->streaming)
1003 queue->streaming = 0;
1005 spin_lock_irqsave(&queue->irqlock, flags);
1006 for (i = 0; i < queue->count; ++i) {
1007 buf = queue->buffers[i];
1014 spin_unlock_irqrestore(&queue->irqlock, flags);
1016 INIT_LIST_HEAD(&queue->queue);
1019 mutex_unlock(&queue->lock);
1033 void omap3isp_video_queue_discard_done(struct isp_video_queue *queue)
1038 mutex_lock(&queue->lock);
1040 if (!queue->streaming)
1043 for (i = 0; i < queue->count; ++i) {
1044 buf = queue->buffers[i];
1051 mutex_unlock(&queue->lock);
1081 int omap3isp_video_queue_mmap(struct isp_video_queue *queue,
1089 mutex_lock(&queue->lock);
1091 for (i = 0; i < queue->count; ++i) {
1092 buf = queue->buffers[i];
1097 if (i == queue->count) {
1119 mutex_unlock(&queue->lock);
1124 * omap3isp_video_queue_poll - Poll video queue state
1127 * polls the state of the video buffer at the front of the queue and returns an
1130 * If no buffer is present at the front of the queue, POLLERR is returned.
1132 unsigned int omap3isp_video_queue_poll(struct isp_video_queue *queue,
1138 mutex_lock(&queue->lock);
1139 if (list_empty(&queue->queue)) {
1143 buf = list_first_entry(&queue->queue, struct isp_video_buffer, stream);
1148 if (queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
1155 mutex_unlock(&queue->lock);