46 INIT_LIST_HEAD(&q->
list);
68 spin_unlock_irqrestore(&s->
qlock, flags);
77 if (!list_empty(&q->
list)) {
79 list_del_init(q->
list.next);
84 spin_unlock_irqrestore(&s->
qlock, flags);
93 list_move_tail(from->
list.next, &to->
list);
127 int from_free = from == &s->
q_free;
128 int to_free = to == &s->
q_free;
129 int bytes_available, bytes_steal;
132 if (needed_bytes == 0) {
134 needed_bytes = from->
length;
138 bytes_steal = (from_free && steal) ? steal->
length : 0;
140 if (bytes_available + bytes_steal < needed_bytes) {
141 spin_unlock_irqrestore(&s->
qlock, flags);
144 while (bytes_available < needed_bytes) {
153 list_move_tail(steal->
list.prev, &from->
list);
162 if (list_empty(&steal->
list))
170 while (to->
length - old_length < needed_bytes) {
171 ivtv_queue_move_buf(s, from, to, 1);
177 while (to->
bytesused - old_bytesused < needed_bytes) {
178 ivtv_queue_move_buf(s, from, to, to_free);
181 spin_unlock_irqrestore(&s->
qlock, flags);
202 IVTV_DEBUG_INFO(
"Allocate %s%s stream: %d x %d buffers (%dkB total)\n",
208 IVTV_ERR(
"Could not allocate sg_pending for %s stream\n", s->
name);
215 IVTV_ERR(
"Could not allocate sg_processing for %s stream\n", s->
name);
225 IVTV_ERR(
"Could not allocate sg_dma for %s stream\n", s->
name);
232 if (ivtv_might_use_dma(s)) {
235 ivtv_stream_sync_for_cpu(s);
239 for (i = 0; i < s->
buffers; i++) {
250 INIT_LIST_HEAD(&buf->
list);
251 if (ivtv_might_use_dma(s)) {
254 ivtv_buf_sync_for_cpu(s, buf);
260 IVTV_ERR(
"Couldn't allocate buffers for %s stream\n", s->
name);
274 if (ivtv_might_use_dma(s))