diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /sound/core/isadma.c |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'sound/core/isadma.c')
-rw-r--r-- | sound/core/isadma.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/sound/core/isadma.c b/sound/core/isadma.c new file mode 100644 index 00000000000..1a378951da5 --- /dev/null +++ b/sound/core/isadma.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | * ISA DMA support functions | ||
3 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz> | ||
4 | * | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | /* | ||
23 | * Defining following add some delay. Maybe this helps for some broken | ||
24 | * ISA DMA controllers. | ||
25 | */ | ||
26 | |||
27 | #undef HAVE_REALLY_SLOW_DMA_CONTROLLER | ||
28 | |||
29 | #include <sound/driver.h> | ||
30 | #include <sound/core.h> | ||
31 | #include <asm/dma.h> | ||
32 | |||
33 | /** | ||
34 | * snd_dma_program - program an ISA DMA transfer | ||
35 | * @dma: the dma number | ||
36 | * @addr: the physical address of the buffer | ||
37 | * @size: the DMA transfer size | ||
38 | * @mode: the DMA transfer mode, DMA_MODE_XXX | ||
39 | * | ||
40 | * Programs an ISA DMA transfer for the given buffer. | ||
41 | */ | ||
42 | void 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 | |||
59 | /** | ||
60 | * snd_dma_disable - stop the ISA DMA transfer | ||
61 | * @dma: the dma number | ||
62 | * | ||
63 | * Stops the ISA DMA transfer. | ||
64 | */ | ||
65 | void snd_dma_disable(unsigned long dma) | ||
66 | { | ||
67 | unsigned long flags; | ||
68 | |||
69 | flags = claim_dma_lock(); | ||
70 | clear_dma_ff(dma); | ||
71 | disable_dma(dma); | ||
72 | release_dma_lock(flags); | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * snd_dma_pointer - return the current pointer to DMA transfer buffer in bytes | ||
77 | * @dma: the dma number | ||
78 | * @size: the dma transfer size | ||
79 | * | ||
80 | * Returns the current pointer in DMA tranfer buffer in bytes | ||
81 | */ | ||
82 | unsigned int snd_dma_pointer(unsigned long dma, unsigned int size) | ||
83 | { | ||
84 | unsigned long flags; | ||
85 | unsigned int result; | ||
86 | |||
87 | flags = claim_dma_lock(); | ||
88 | clear_dma_ff(dma); | ||
89 | if (!isa_dma_bridge_buggy) | ||
90 | disable_dma(dma); | ||
91 | result = get_dma_residue(dma); | ||
92 | if (!isa_dma_bridge_buggy) | ||
93 | enable_dma(dma); | ||
94 | release_dma_lock(flags); | ||
95 | #ifdef CONFIG_SND_DEBUG | ||
96 | if (result > size) | ||
97 | snd_printk(KERN_ERR "pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size); | ||
98 | #endif | ||
99 | if (result >= size || result == 0) | ||
100 | return 0; | ||
101 | else | ||
102 | return size - result; | ||
103 | } | ||