1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef IVTV_QUEUE_H
23#define IVTV_QUEUE_H
24
25#define IVTV_DMA_UNMAPPED ((u32) -1)
26#define SLICED_VBI_PIO 1
27
28
29
30static inline int ivtv_might_use_pio(struct ivtv_stream *s)
31{
32 return s->dma == PCI_DMA_NONE || (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI);
33}
34
35static inline int ivtv_use_pio(struct ivtv_stream *s)
36{
37 struct ivtv *itv = s->itv;
38
39 return s->dma == PCI_DMA_NONE ||
40 (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI && itv->vbi.sliced_in->service_set);
41}
42
43static inline int ivtv_might_use_dma(struct ivtv_stream *s)
44{
45 return s->dma != PCI_DMA_NONE;
46}
47
48static inline int ivtv_use_dma(struct ivtv_stream *s)
49{
50 return !ivtv_use_pio(s);
51}
52
53static inline void ivtv_buf_sync_for_cpu(struct ivtv_stream *s, struct ivtv_buffer *buf)
54{
55 if (ivtv_use_dma(s))
56 pci_dma_sync_single_for_cpu(s->itv->dev, buf->dma_handle,
57 s->buf_size + 256, s->dma);
58}
59
60static inline void ivtv_buf_sync_for_device(struct ivtv_stream *s, struct ivtv_buffer *buf)
61{
62 if (ivtv_use_dma(s))
63 pci_dma_sync_single_for_device(s->itv->dev, buf->dma_handle,
64 s->buf_size + 256, s->dma);
65}
66
67int ivtv_buf_copy_from_user(struct ivtv_stream *s, struct ivtv_buffer *buf, const char __user *src, int copybytes);
68void ivtv_buf_swap(struct ivtv_buffer *buf);
69
70
71void ivtv_queue_init(struct ivtv_queue *q);
72void ivtv_enqueue(struct ivtv_stream *s, struct ivtv_buffer *buf, struct ivtv_queue *q);
73struct ivtv_buffer *ivtv_dequeue(struct ivtv_stream *s, struct ivtv_queue *q);
74int ivtv_queue_move(struct ivtv_stream *s, struct ivtv_queue *from, struct ivtv_queue *steal,
75 struct ivtv_queue *to, int needed_bytes);
76void ivtv_flush_queues(struct ivtv_stream *s);
77
78
79int ivtv_stream_alloc(struct ivtv_stream *s);
80void ivtv_stream_free(struct ivtv_stream *s);
81
82static inline void ivtv_stream_sync_for_cpu(struct ivtv_stream *s)
83{
84 if (ivtv_use_dma(s))
85 pci_dma_sync_single_for_cpu(s->itv->dev, s->sg_handle,
86 sizeof(struct ivtv_sg_element), PCI_DMA_TODEVICE);
87}
88
89static inline void ivtv_stream_sync_for_device(struct ivtv_stream *s)
90{
91 if (ivtv_use_dma(s))
92 pci_dma_sync_single_for_device(s->itv->dev, s->sg_handle,
93 sizeof(struct ivtv_sg_element), PCI_DMA_TODEVICE);
94}
95
96#endif
97