aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18/cx18-queue.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx18/cx18-queue.c')
-rw-r--r--drivers/media/video/cx18/cx18-queue.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/drivers/media/video/cx18/cx18-queue.c b/drivers/media/video/cx18/cx18-queue.c
index dbe792ac3001..a33ba04a2686 100644
--- a/drivers/media/video/cx18/cx18-queue.c
+++ b/drivers/media/video/cx18/cx18-queue.c
@@ -37,8 +37,7 @@ void cx18_buf_swap(struct cx18_buffer *buf)
37void cx18_queue_init(struct cx18_queue *q) 37void cx18_queue_init(struct cx18_queue *q)
38{ 38{
39 INIT_LIST_HEAD(&q->list); 39 INIT_LIST_HEAD(&q->list);
40 q->buffers = 0; 40 atomic_set(&q->buffers, 0);
41 q->length = 0;
42 q->bytesused = 0; 41 q->bytesused = 0;
43} 42}
44 43
@@ -55,8 +54,7 @@ void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf,
55 } 54 }
56 spin_lock_irqsave(&s->qlock, flags); 55 spin_lock_irqsave(&s->qlock, flags);
57 list_add_tail(&buf->list, &q->list); 56 list_add_tail(&buf->list, &q->list);
58 q->buffers++; 57 atomic_inc(&q->buffers);
59 q->length += s->buf_size;
60 q->bytesused += buf->bytesused - buf->readpos; 58 q->bytesused += buf->bytesused - buf->readpos;
61 spin_unlock_irqrestore(&s->qlock, flags); 59 spin_unlock_irqrestore(&s->qlock, flags);
62} 60}
@@ -70,8 +68,7 @@ struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q)
70 if (!list_empty(&q->list)) { 68 if (!list_empty(&q->list)) {
71 buf = list_entry(q->list.next, struct cx18_buffer, list); 69 buf = list_entry(q->list.next, struct cx18_buffer, list);
72 list_del_init(q->list.next); 70 list_del_init(q->list.next);
73 q->buffers--; 71 atomic_dec(&q->buffers);
74 q->length -= s->buf_size;
75 q->bytesused -= buf->bytesused - buf->readpos; 72 q->bytesused -= buf->bytesused - buf->readpos;
76 } 73 }
77 spin_unlock_irqrestore(&s->qlock, flags); 74 spin_unlock_irqrestore(&s->qlock, flags);
@@ -95,10 +92,8 @@ struct cx18_buffer *cx18_queue_get_buf_irq(struct cx18_stream *s, u32 id,
95 /* the transport buffers are handled differently, 92 /* the transport buffers are handled differently,
96 they are not moved to the full queue */ 93 they are not moved to the full queue */
97 if (s->type != CX18_ENC_STREAM_TYPE_TS) { 94 if (s->type != CX18_ENC_STREAM_TYPE_TS) {
98 s->q_free.buffers--; 95 atomic_dec(&s->q_free.buffers);
99 s->q_free.length -= s->buf_size; 96 atomic_inc(&s->q_full.buffers);
100 s->q_full.buffers++;
101 s->q_full.length += s->buf_size;
102 s->q_full.bytesused += buf->bytesused; 97 s->q_full.bytesused += buf->bytesused;
103 list_move_tail(&buf->list, &s->q_full.list); 98 list_move_tail(&buf->list, &s->q_full.list);
104 } 99 }
@@ -124,8 +119,7 @@ static void cx18_queue_flush(struct cx18_stream *s, struct cx18_queue *q)
124 buf = list_entry(q->list.next, struct cx18_buffer, list); 119 buf = list_entry(q->list.next, struct cx18_buffer, list);
125 list_move_tail(q->list.next, &s->q_free.list); 120 list_move_tail(q->list.next, &s->q_free.list);
126 buf->bytesused = buf->readpos = buf->b_flags = 0; 121 buf->bytesused = buf->readpos = buf->b_flags = 0;
127 s->q_free.buffers++; 122 atomic_inc(&s->q_free.buffers);
128 s->q_free.length += s->buf_size;
129 } 123 }
130 cx18_queue_init(q); 124 cx18_queue_init(q);
131 spin_unlock_irqrestore(&s->qlock, flags); 125 spin_unlock_irqrestore(&s->qlock, flags);