aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/uvc/uvc_queue.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/uvc/uvc_queue.c')
-rw-r--r--drivers/media/video/uvc/uvc_queue.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c
index 8f676f9d9e39..0155752e4a5a 100644
--- a/drivers/media/video/uvc/uvc_queue.c
+++ b/drivers/media/video/uvc/uvc_queue.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * uvc_queue.c -- USB Video Class driver - Buffers management 2 * uvc_queue.c -- USB Video Class driver - Buffers management
3 * 3 *
4 * Copyright (C) 2005-2008 4 * Copyright (C) 2005-2009
5 * Laurent Pinchart (laurent.pinchart@skynet.be) 5 * Laurent Pinchart (laurent.pinchart@skynet.be)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -36,22 +36,22 @@
36 * to user space will return -EBUSY. 36 * to user space will return -EBUSY.
37 * 37 *
38 * Video buffers are managed using two queues. However, unlike most USB video 38 * Video buffers are managed using two queues. However, unlike most USB video
39 * drivers which use an in queue and an out queue, we use a main queue which 39 * drivers that use an in queue and an out queue, we use a main queue to hold
40 * holds all queued buffers (both 'empty' and 'done' buffers), and an irq 40 * all queued buffers (both 'empty' and 'done' buffers), and an irq queue to
41 * queue which holds empty buffers. This design (copied from video-buf) 41 * hold empty buffers. This design (copied from video-buf) minimizes locking
42 * minimizes locking in interrupt, as only one queue is shared between 42 * in interrupt, as only one queue is shared between interrupt and user
43 * interrupt and user contexts. 43 * contexts.
44 * 44 *
45 * Use cases 45 * Use cases
46 * --------- 46 * ---------
47 * 47 *
48 * Unless stated otherwise, all operations which modify the irq buffers queue 48 * Unless stated otherwise, all operations that modify the irq buffers queue
49 * are protected by the irq spinlock. 49 * are protected by the irq spinlock.
50 * 50 *
51 * 1. The user queues the buffers, starts streaming and dequeues a buffer. 51 * 1. The user queues the buffers, starts streaming and dequeues a buffer.
52 * 52 *
53 * The buffers are added to the main and irq queues. Both operations are 53 * The buffers are added to the main and irq queues. Both operations are
54 * protected by the queue lock, and the latert is protected by the irq 54 * protected by the queue lock, and the later is protected by the irq
55 * spinlock as well. 55 * spinlock as well.
56 * 56 *
57 * The completion handler fetches a buffer from the irq queue and fills it 57 * The completion handler fetches a buffer from the irq queue and fills it
@@ -59,7 +59,7 @@
59 * returns immediately. 59 * returns immediately.
60 * 60 *
61 * When the buffer is full, the completion handler removes it from the irq 61 * When the buffer is full, the completion handler removes it from the irq
62 * queue, marks it as ready (UVC_BUF_STATE_DONE) and wake its wait queue. 62 * queue, marks it as ready (UVC_BUF_STATE_DONE) and wakes its wait queue.
63 * At that point, any process waiting on the buffer will be woken up. If a 63 * At that point, any process waiting on the buffer will be woken up. If a
64 * process tries to dequeue a buffer after it has been marked ready, the 64 * process tries to dequeue a buffer after it has been marked ready, the
65 * dequeing will succeed immediately. 65 * dequeing will succeed immediately.
@@ -90,8 +90,8 @@ void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
90/* 90/*
91 * Allocate the video buffers. 91 * Allocate the video buffers.
92 * 92 *
93 * Pages are reserved to make sure they will not be swaped, as they will be 93 * Pages are reserved to make sure they will not be swapped, as they will be
94 * filled in URB completion handler. 94 * filled in the URB completion handler.
95 * 95 *
96 * Buffers will be individually mapped, so they must all be page aligned. 96 * Buffers will be individually mapped, so they must all be page aligned.
97 */ 97 */
@@ -209,8 +209,8 @@ int uvc_query_buffer(struct uvc_video_queue *queue,
209 __uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf); 209 __uvc_query_buffer(&queue->buffer[v4l2_buf->index], v4l2_buf);
210 210
211done: 211done:
212 mutex_unlock(&queue->mutex); 212 mutex_unlock(&queue->mutex);
213 return ret; 213 return ret;
214} 214}
215 215
216/* 216/*
@@ -235,7 +235,7 @@ int uvc_queue_buffer(struct uvc_video_queue *queue,
235 } 235 }
236 236
237 mutex_lock(&queue->mutex); 237 mutex_lock(&queue->mutex);
238 if (v4l2_buf->index >= queue->count) { 238 if (v4l2_buf->index >= queue->count) {
239 uvc_trace(UVC_TRACE_CAPTURE, "[E] Out of range index.\n"); 239 uvc_trace(UVC_TRACE_CAPTURE, "[E] Out of range index.\n");
240 ret = -EINVAL; 240 ret = -EINVAL;
241 goto done; 241 goto done;
@@ -428,7 +428,7 @@ done:
428 * Cancel the video buffers queue. 428 * Cancel the video buffers queue.
429 * 429 *
430 * Cancelling the queue marks all buffers on the irq queue as erroneous, 430 * Cancelling the queue marks all buffers on the irq queue as erroneous,
431 * wakes them up and remove them from the queue. 431 * wakes them up and removes them from the queue.
432 * 432 *
433 * If the disconnect parameter is set, further calls to uvc_queue_buffer will 433 * If the disconnect parameter is set, further calls to uvc_queue_buffer will
434 * fail with -ENODEV. 434 * fail with -ENODEV.