• Home
  • Raw
  • Download

Lines Matching refs:s

13 int ivtv_buf_copy_from_user(struct ivtv_stream *s, struct ivtv_buffer *buf, const char __user *src,…  in ivtv_buf_copy_from_user()  argument
15 if (s->buf_size - buf->bytesused < copybytes) in ivtv_buf_copy_from_user()
16 copybytes = s->buf_size - buf->bytesused; in ivtv_buf_copy_from_user()
40 void ivtv_enqueue(struct ivtv_stream *s, struct ivtv_buffer *buf, struct ivtv_queue *q) in ivtv_enqueue() argument
45 if (q == &s->q_free) { in ivtv_enqueue()
51 spin_lock_irqsave(&s->qlock, flags); in ivtv_enqueue()
54 q->length += s->buf_size; in ivtv_enqueue()
56 spin_unlock_irqrestore(&s->qlock, flags); in ivtv_enqueue()
59 struct ivtv_buffer *ivtv_dequeue(struct ivtv_stream *s, struct ivtv_queue *q) in ivtv_dequeue() argument
64 spin_lock_irqsave(&s->qlock, flags); in ivtv_dequeue()
69 q->length -= s->buf_size; in ivtv_dequeue()
72 spin_unlock_irqrestore(&s->qlock, flags); in ivtv_dequeue()
76 static void ivtv_queue_move_buf(struct ivtv_stream *s, struct ivtv_queue *from, in ivtv_queue_move_buf() argument
83 from->length -= s->buf_size; in ivtv_queue_move_buf()
89 to->length += s->buf_size; in ivtv_queue_move_buf()
110 int ivtv_queue_move(struct ivtv_stream *s, struct ivtv_queue *from, struct ivtv_queue *steal, in ivtv_queue_move() argument
115 int from_free = from == &s->q_free; in ivtv_queue_move()
116 int to_free = to == &s->q_free; in ivtv_queue_move()
119 spin_lock_irqsave(&s->qlock, flags); in ivtv_queue_move()
129 spin_unlock_irqrestore(&s->qlock, flags); in ivtv_queue_move()
144 steal->length -= s->buf_size; in ivtv_queue_move()
148 from->length += s->buf_size; in ivtv_queue_move()
149 bytes_available += s->buf_size; in ivtv_queue_move()
159 ivtv_queue_move_buf(s, from, to, 1); in ivtv_queue_move()
166 ivtv_queue_move_buf(s, from, to, to_free); in ivtv_queue_move()
169 spin_unlock_irqrestore(&s->qlock, flags); in ivtv_queue_move()
173 void ivtv_flush_queues(struct ivtv_stream *s) in ivtv_flush_queues() argument
175 ivtv_queue_move(s, &s->q_io, NULL, &s->q_free, 0); in ivtv_flush_queues()
176 ivtv_queue_move(s, &s->q_full, NULL, &s->q_free, 0); in ivtv_flush_queues()
177 ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0); in ivtv_flush_queues()
178 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_free, 0); in ivtv_flush_queues()
181 int ivtv_stream_alloc(struct ivtv_stream *s) in ivtv_stream_alloc() argument
183 struct ivtv *itv = s->itv; in ivtv_stream_alloc()
184 int SGsize = sizeof(struct ivtv_sg_host_element) * s->buffers; in ivtv_stream_alloc()
187 if (s->buffers == 0) in ivtv_stream_alloc()
191 s->dma != PCI_DMA_NONE ? "DMA " : "", in ivtv_stream_alloc()
192 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024); in ivtv_stream_alloc()
194 s->sg_pending = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN); in ivtv_stream_alloc()
195 if (s->sg_pending == NULL) { in ivtv_stream_alloc()
196 IVTV_ERR("Could not allocate sg_pending for %s stream\n", s->name); in ivtv_stream_alloc()
199 s->sg_pending_size = 0; in ivtv_stream_alloc()
201 s->sg_processing = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN); in ivtv_stream_alloc()
202 if (s->sg_processing == NULL) { in ivtv_stream_alloc()
203 IVTV_ERR("Could not allocate sg_processing for %s stream\n", s->name); in ivtv_stream_alloc()
204 kfree(s->sg_pending); in ivtv_stream_alloc()
205 s->sg_pending = NULL; in ivtv_stream_alloc()
208 s->sg_processing_size = 0; in ivtv_stream_alloc()
210 s->sg_dma = kzalloc(sizeof(struct ivtv_sg_element), in ivtv_stream_alloc()
212 if (s->sg_dma == NULL) { in ivtv_stream_alloc()
213 IVTV_ERR("Could not allocate sg_dma for %s stream\n", s->name); in ivtv_stream_alloc()
214 kfree(s->sg_pending); in ivtv_stream_alloc()
215 s->sg_pending = NULL; in ivtv_stream_alloc()
216 kfree(s->sg_processing); in ivtv_stream_alloc()
217 s->sg_processing = NULL; in ivtv_stream_alloc()
220 if (ivtv_might_use_dma(s)) { in ivtv_stream_alloc()
221 s->sg_handle = pci_map_single(itv->pdev, s->sg_dma, in ivtv_stream_alloc()
223 ivtv_stream_sync_for_cpu(s); in ivtv_stream_alloc()
227 for (i = 0; i < s->buffers; i++) { in ivtv_stream_alloc()
233 buf->buf = kmalloc(s->buf_size + 256, GFP_KERNEL|__GFP_NOWARN); in ivtv_stream_alloc()
239 if (ivtv_might_use_dma(s)) { in ivtv_stream_alloc()
240 buf->dma_handle = pci_map_single(s->itv->pdev, in ivtv_stream_alloc()
241 buf->buf, s->buf_size + 256, s->dma); in ivtv_stream_alloc()
242 ivtv_buf_sync_for_cpu(s, buf); in ivtv_stream_alloc()
244 ivtv_enqueue(s, buf, &s->q_free); in ivtv_stream_alloc()
246 if (i == s->buffers) in ivtv_stream_alloc()
248 IVTV_ERR("Couldn't allocate buffers for %s stream\n", s->name); in ivtv_stream_alloc()
249 ivtv_stream_free(s); in ivtv_stream_alloc()
253 void ivtv_stream_free(struct ivtv_stream *s) in ivtv_stream_free() argument
258 ivtv_flush_queues(s); in ivtv_stream_free()
261 while ((buf = ivtv_dequeue(s, &s->q_free))) { in ivtv_stream_free()
262 if (ivtv_might_use_dma(s)) in ivtv_stream_free()
263 pci_unmap_single(s->itv->pdev, buf->dma_handle, in ivtv_stream_free()
264 s->buf_size + 256, s->dma); in ivtv_stream_free()
270 if (s->sg_dma != NULL) { in ivtv_stream_free()
271 if (s->sg_handle != IVTV_DMA_UNMAPPED) { in ivtv_stream_free()
272 pci_unmap_single(s->itv->pdev, s->sg_handle, in ivtv_stream_free()
274 s->sg_handle = IVTV_DMA_UNMAPPED; in ivtv_stream_free()
276 kfree(s->sg_pending); in ivtv_stream_free()
277 kfree(s->sg_processing); in ivtv_stream_free()
278 kfree(s->sg_dma); in ivtv_stream_free()
279 s->sg_pending = NULL; in ivtv_stream_free()
280 s->sg_processing = NULL; in ivtv_stream_free()
281 s->sg_dma = NULL; in ivtv_stream_free()
282 s->sg_pending_size = 0; in ivtv_stream_free()
283 s->sg_processing_size = 0; in ivtv_stream_free()