Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (9800): cx18: Eliminate q_io from stream buffer handling

Eliminate q_io from stream buffer handling in anticipation of upcoming
changes in buffer handling. q_io was a holdover from ivtv and it's function
in cx18 was trivial and not necessary. We just push things back onto the
front of q_full now, instead of maintaining a 1 buffer q_io queue.

Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Andy Walls and committed by
Mauro Carvalho Chehab
b80e1074 be2c6db1

+25 -15
-1
drivers/media/video/cx18/cx18-driver.h
··· 290 290 /* Buffer Queues */ 291 291 struct cx18_queue q_free; /* free buffers */ 292 292 struct cx18_queue q_full; /* full buffers */ 293 - struct cx18_queue q_io; /* waiting for I/O */ 294 293 295 294 /* DVB / Digital Transport */ 296 295 struct cx18_dvb dvb;
+2 -7
drivers/media/video/cx18/cx18-fileops.c
··· 195 195 return buf; 196 196 } 197 197 198 - /* do we have leftover data? */ 199 - buf = cx18_dequeue(s, &s->q_io); 200 - if (buf) 201 - return buf; 202 - 203 198 /* do we have new data? */ 204 199 buf = cx18_dequeue(s, &s->q_full); 205 200 if (buf) { ··· 370 375 cx->enc_mem, 371 376 1, buf->id, s->buf_size); 372 377 } else 373 - cx18_enqueue(s, buf, &s->q_io); 378 + cx18_push(s, buf, &s->q_full); 374 379 } else if (buf->readpos == buf->bytesused) { 375 380 int idx = cx->vbi.inserted_frame % CX18_VBI_FRAMES; 376 381 ··· 514 519 CX18_DEBUG_HI_FILE("Encoder poll\n"); 515 520 poll_wait(filp, &s->waitq, wait); 516 521 517 - if (atomic_read(&s->q_full.buffers) || atomic_read(&s->q_io.buffers)) 522 + if (atomic_read(&s->q_full.buffers)) 518 523 return POLLIN | POLLRDNORM; 519 524 if (eof) 520 525 return POLLHUP;
+6 -4
drivers/media/video/cx18/cx18-queue.c
··· 42 42 q->bytesused = 0; 43 43 } 44 44 45 - void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, 46 - struct cx18_queue *q) 45 + void _cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, 46 + struct cx18_queue *q, int to_front) 47 47 { 48 48 /* clear the buffer if it is going to be enqueued to the free queue */ 49 49 if (q == &s->q_free) { ··· 53 53 buf->skipped = 0; 54 54 } 55 55 mutex_lock(&s->qlock); 56 - list_add_tail(&buf->list, &q->list); 56 + if (to_front) 57 + list_add(&buf->list, &q->list); /* LIFO */ 58 + else 59 + list_add_tail(&buf->list, &q->list); /* FIFO */ 57 60 atomic_inc(&q->buffers); 58 61 q->bytesused += buf->bytesused - buf->readpos; 59 62 mutex_unlock(&s->qlock); ··· 162 159 163 160 void cx18_flush_queues(struct cx18_stream *s) 164 161 { 165 - cx18_queue_flush(s, &s->q_io); 166 162 cx18_queue_flush(s, &s->q_full); 167 163 } 168 164
+17 -2
drivers/media/video/cx18/cx18-queue.h
··· 43 43 void cx18_buf_swap(struct cx18_buffer *buf); 44 44 45 45 /* cx18_queue utility functions */ 46 - void cx18_queue_init(struct cx18_queue *q); 46 + void _cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, 47 + struct cx18_queue *q, int to_front); 48 + 49 + static inline 47 50 void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, 48 - struct cx18_queue *q); 51 + struct cx18_queue *q) 52 + { 53 + _cx18_enqueue(s, buf, q, 0); /* FIFO */ 54 + } 55 + 56 + static inline 57 + void cx18_push(struct cx18_stream *s, struct cx18_buffer *buf, 58 + struct cx18_queue *q) 59 + { 60 + _cx18_enqueue(s, buf, q, 1); /* LIFO */ 61 + } 62 + 63 + void cx18_queue_init(struct cx18_queue *q); 49 64 struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q); 50 65 struct cx18_buffer *cx18_queue_get_buf(struct cx18_stream *s, u32 id, 51 66 u32 bytesused);
-1
drivers/media/video/cx18/cx18-streams.c
··· 138 138 s->id = -1; 139 139 cx18_queue_init(&s->q_free); 140 140 cx18_queue_init(&s->q_full); 141 - cx18_queue_init(&s->q_io); 142 141 } 143 142 144 143 static int cx18_prep_dev(struct cx18 *cx, int type)