1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#undef HAVE_REALLY_SLOW_DMA_CONTROLLER
28
29#include <linux/export.h>
30#include <sound/core.h>
31#include <asm/dma.h>
32
33
34
35
36
37
38
39
40
41
42void snd_dma_program(unsigned long dma,
43 unsigned long addr, unsigned int size,
44 unsigned short mode)
45{
46 unsigned long flags;
47
48 flags = claim_dma_lock();
49 disable_dma(dma);
50 clear_dma_ff(dma);
51 set_dma_mode(dma, mode);
52 set_dma_addr(dma, addr);
53 set_dma_count(dma, size);
54 if (!(mode & DMA_MODE_NO_ENABLE))
55 enable_dma(dma);
56 release_dma_lock(flags);
57}
58
59EXPORT_SYMBOL(snd_dma_program);
60
61
62
63
64
65
66
67void snd_dma_disable(unsigned long dma)
68{
69 unsigned long flags;
70
71 flags = claim_dma_lock();
72 clear_dma_ff(dma);
73 disable_dma(dma);
74 release_dma_lock(flags);
75}
76
77EXPORT_SYMBOL(snd_dma_disable);
78
79
80
81
82
83
84
85
86unsigned int snd_dma_pointer(unsigned long dma, unsigned int size)
87{
88 unsigned long flags;
89 unsigned int result, result1;
90
91 flags = claim_dma_lock();
92 clear_dma_ff(dma);
93 if (!isa_dma_bridge_buggy)
94 disable_dma(dma);
95 result = get_dma_residue(dma);
96
97
98
99
100
101 result1 = get_dma_residue(dma);
102 if (!isa_dma_bridge_buggy)
103 enable_dma(dma);
104 release_dma_lock(flags);
105 if (unlikely(result < result1))
106 result = result1;
107#ifdef CONFIG_SND_DEBUG
108 if (result > size)
109 snd_printk(KERN_ERR "pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size);
110#endif
111 if (result >= size || result == 0)
112 return 0;
113 else
114 return size - result;
115}
116
117EXPORT_SYMBOL(snd_dma_pointer);
118