This source file includes following definitions.
- dp_mark_completed
- dp_is_completed
- dma_fifo_level
- dma_fifo_out_level
- dma_fifo_avail
- dma_fifo_busy
- dma_fifo_change_tx_limit
1
2
3
4
5
6
7
8 #ifndef _DMA_FIFO_H_
9 #define _DMA_FIFO_H_
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 #define DMA_FIFO_GUARD 3
37
38 struct dma_fifo {
39 unsigned int in;
40 unsigned int out;
41 unsigned int done;
42 struct {
43 unsigned corrupt:1;
44 };
45 int size;
46 int guard;
47 int capacity;
48 int avail;
49 unsigned int align;
50 int tx_limit;
51 int open_limit;
52 int open;
53 struct list_head pending;
54 void *data;
55 };
56
57 struct dma_pending {
58 struct list_head link;
59 void *data;
60 unsigned int len;
61 unsigned int next;
62 unsigned int out;
63 };
64
65 static inline void dp_mark_completed(struct dma_pending *dp)
66 {
67 dp->data += 1;
68 }
69
70 static inline bool dp_is_completed(struct dma_pending *dp)
71 {
72 return (unsigned long)dp->data & 1UL;
73 }
74
75 void dma_fifo_init(struct dma_fifo *fifo);
76 int dma_fifo_alloc(struct dma_fifo *fifo, int size, unsigned int align,
77 int tx_limit, int open_limit, gfp_t gfp_mask);
78 void dma_fifo_free(struct dma_fifo *fifo);
79 void dma_fifo_reset(struct dma_fifo *fifo);
80 int dma_fifo_in(struct dma_fifo *fifo, const void *src, int n);
81 int dma_fifo_out_pend(struct dma_fifo *fifo, struct dma_pending *pended);
82 int dma_fifo_out_complete(struct dma_fifo *fifo,
83 struct dma_pending *complete);
84
85
86 static inline int dma_fifo_level(struct dma_fifo *fifo)
87 {
88 return fifo->size - fifo->avail;
89 }
90
91
92 static inline int dma_fifo_out_level(struct dma_fifo *fifo)
93 {
94 return fifo->in - fifo->out;
95 }
96
97
98 static inline int dma_fifo_avail(struct dma_fifo *fifo)
99 {
100 return fifo->avail;
101 }
102
103
104 static inline bool dma_fifo_busy(struct dma_fifo *fifo)
105 {
106 return fifo->open == fifo->open_limit;
107 }
108
109
110 static inline int dma_fifo_change_tx_limit(struct dma_fifo *fifo, int tx_limit)
111 {
112 tx_limit = round_down(tx_limit, fifo->align);
113 fifo->tx_limit = max_t(int, tx_limit, fifo->align);
114 return 0;
115 }
116
117 #endif