Lines Matching refs:s
43 struct cx18_queue *_cx18_enqueue(struct cx18_stream *s, struct cx18_mdl *mdl, in _cx18_enqueue() argument
47 if (q != &s->q_full) { in _cx18_enqueue()
56 if (q == &s->q_busy && in _cx18_enqueue()
58 q = &s->q_free; in _cx18_enqueue()
73 struct cx18_mdl *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q) in cx18_dequeue() argument
89 static void _cx18_mdl_update_bufs_for_cpu(struct cx18_stream *s, in _cx18_mdl_update_bufs_for_cpu() argument
93 u32 buf_size = s->buf_size; in _cx18_mdl_update_bufs_for_cpu()
105 cx18_buf_sync_for_cpu(s, buf); in _cx18_mdl_update_bufs_for_cpu()
109 static inline void cx18_mdl_update_bufs_for_cpu(struct cx18_stream *s, in cx18_mdl_update_bufs_for_cpu() argument
119 cx18_buf_sync_for_cpu(s, buf); in cx18_mdl_update_bufs_for_cpu()
121 _cx18_mdl_update_bufs_for_cpu(s, mdl); in cx18_mdl_update_bufs_for_cpu()
125 struct cx18_mdl *cx18_queue_get_mdl(struct cx18_stream *s, u32 id, in cx18_queue_get_mdl() argument
128 struct cx18 *cx = s->cx; in cx18_queue_get_mdl()
140 spin_lock(&s->q_busy.lock); in cx18_queue_get_mdl()
141 list_for_each_entry_safe(mdl, tmp, &s->q_busy.list, list) { in cx18_queue_get_mdl()
151 if (mdl->skipped >= atomic_read(&s->q_busy.depth)-1) { in cx18_queue_get_mdl()
154 s->name, mdl->id, in cx18_queue_get_mdl()
158 atomic_dec(&s->q_busy.depth); in cx18_queue_get_mdl()
167 atomic_dec(&s->q_busy.depth); in cx18_queue_get_mdl()
171 spin_unlock(&s->q_busy.lock); in cx18_queue_get_mdl()
181 cx18_mdl_update_bufs_for_cpu(s, ret); in cx18_queue_get_mdl()
182 if (s->type != CX18_ENC_STREAM_TYPE_TS) in cx18_queue_get_mdl()
189 cx18_enqueue(s, mdl, &s->q_free); in cx18_queue_get_mdl()
195 static void cx18_queue_flush(struct cx18_stream *s, in cx18_queue_flush() argument
201 if (q_src == q_dst || q_dst == &s->q_full || q_dst == &s->q_busy) in cx18_queue_flush()
221 void cx18_flush_queues(struct cx18_stream *s) in cx18_flush_queues() argument
223 cx18_queue_flush(s, &s->q_busy, &s->q_free); in cx18_flush_queues()
224 cx18_queue_flush(s, &s->q_full, &s->q_free); in cx18_flush_queues()
231 void cx18_unload_queues(struct cx18_stream *s) in cx18_unload_queues() argument
233 struct cx18_queue *q_idle = &s->q_idle; in cx18_unload_queues()
238 cx18_queue_flush(s, &s->q_busy, q_idle); in cx18_unload_queues()
239 cx18_queue_flush(s, &s->q_full, q_idle); in cx18_unload_queues()
240 cx18_queue_flush(s, &s->q_free, q_idle); in cx18_unload_queues()
248 list_move_tail(&buf->list, &s->buf_pool); in cx18_unload_queues()
252 mdl->id = s->mdl_base_idx; /* reset id to a "safe" value */ in cx18_unload_queues()
262 void cx18_load_queues(struct cx18_stream *s) in cx18_load_queues() argument
264 struct cx18 *cx = s->cx; in cx18_load_queues()
276 mdl_id = s->mdl_base_idx; in cx18_load_queues()
277 for (mdl = cx18_dequeue(s, &s->q_idle), i = s->bufs_per_mdl; in cx18_load_queues()
278 mdl != NULL && i == s->bufs_per_mdl; in cx18_load_queues()
279 mdl = cx18_dequeue(s, &s->q_idle)) { in cx18_load_queues()
283 for (i = 0; i < s->bufs_per_mdl; i++) { in cx18_load_queues()
284 if (list_empty(&s->buf_pool)) in cx18_load_queues()
287 buf = list_first_entry(&s->buf_pool, struct cx18_buffer, in cx18_load_queues()
294 cx18_writel(cx, s->buf_size, in cx18_load_queues()
298 if (i == s->bufs_per_mdl) { in cx18_load_queues()
306 partial_buf_size = s->mdl_size % s->buf_size; in cx18_load_queues()
311 cx18_enqueue(s, mdl, &s->q_free); in cx18_load_queues()
314 cx18_push(s, mdl, &s->q_idle); in cx18_load_queues()
320 void _cx18_mdl_sync_for_device(struct cx18_stream *s, struct cx18_mdl *mdl) in _cx18_mdl_sync_for_device() argument
322 int dma = s->dma; in _cx18_mdl_sync_for_device()
323 u32 buf_size = s->buf_size; in _cx18_mdl_sync_for_device()
324 struct pci_dev *pci_dev = s->cx->pci_dev; in _cx18_mdl_sync_for_device()
332 int cx18_stream_alloc(struct cx18_stream *s) in cx18_stream_alloc() argument
334 struct cx18 *cx = s->cx; in cx18_stream_alloc()
337 if (s->buffers == 0) in cx18_stream_alloc()
341 s->name, s->buffers, s->buf_size, in cx18_stream_alloc()
342 s->buffers * s->buf_size / 1024, in cx18_stream_alloc()
343 (s->buffers * s->buf_size * 100 / 1024) % 100); in cx18_stream_alloc()
345 if (((char __iomem *)&cx->scb->cpu_mdl[cx->free_mdl_idx + s->buffers] - in cx18_stream_alloc()
356 s->mdl_base_idx = cx->free_mdl_idx; in cx18_stream_alloc()
359 for (i = 0; i < s->buffers; i++) { in cx18_stream_alloc()
375 buf->buf = kmalloc(s->buf_size, GFP_KERNEL|__GFP_NOWARN); in cx18_stream_alloc()
384 mdl->id = s->mdl_base_idx; /* a somewhat safe value */ in cx18_stream_alloc()
385 cx18_enqueue(s, mdl, &s->q_idle); in cx18_stream_alloc()
388 buf->dma_handle = pci_map_single(s->cx->pci_dev, in cx18_stream_alloc()
389 buf->buf, s->buf_size, s->dma); in cx18_stream_alloc()
390 cx18_buf_sync_for_cpu(s, buf); in cx18_stream_alloc()
391 list_add_tail(&buf->list, &s->buf_pool); in cx18_stream_alloc()
393 if (i == s->buffers) { in cx18_stream_alloc()
394 cx->free_mdl_idx += s->buffers; in cx18_stream_alloc()
397 CX18_ERR("Couldn't allocate buffers for %s stream\n", s->name); in cx18_stream_alloc()
398 cx18_stream_free(s); in cx18_stream_alloc()
402 void cx18_stream_free(struct cx18_stream *s) in cx18_stream_free() argument
406 struct cx18 *cx = s->cx; in cx18_stream_free()
408 CX18_DEBUG_INFO("Deallocating buffers for %s stream\n", s->name); in cx18_stream_free()
411 cx18_unload_queues(s); in cx18_stream_free()
414 while ((mdl = cx18_dequeue(s, &s->q_idle))) in cx18_stream_free()
418 while (!list_empty(&s->buf_pool)) { in cx18_stream_free()
419 buf = list_first_entry(&s->buf_pool, struct cx18_buffer, list); in cx18_stream_free()
422 pci_unmap_single(s->cx->pci_dev, buf->dma_handle, in cx18_stream_free()
423 s->buf_size, s->dma); in cx18_stream_free()