sh: Add OHCI and UDC platform devices for SH7720.
[linux-2.6/mini2440.git] / sound / core / isadma.c
blobeb173cef4f05e3925565090e048b8be0d3e161bb
1 /*
2 * ISA DMA support functions
3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
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.
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.
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
23 * Defining following add some delay. Maybe this helps for some broken
24 * ISA DMA controllers.
27 #undef HAVE_REALLY_SLOW_DMA_CONTROLLER
29 #include <sound/driver.h>
30 #include <sound/core.h>
31 #include <asm/dma.h>
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
40 * Programs an ISA DMA transfer for the given buffer.
42 void snd_dma_program(unsigned long dma,
43 unsigned long addr, unsigned int size,
44 unsigned short mode)
46 unsigned long flags;
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);
59 EXPORT_SYMBOL(snd_dma_program);
61 /**
62 * snd_dma_disable - stop the ISA DMA transfer
63 * @dma: the dma number
65 * Stops the ISA DMA transfer.
67 void snd_dma_disable(unsigned long dma)
69 unsigned long flags;
71 flags = claim_dma_lock();
72 clear_dma_ff(dma);
73 disable_dma(dma);
74 release_dma_lock(flags);
77 EXPORT_SYMBOL(snd_dma_disable);
79 /**
80 * snd_dma_pointer - return the current pointer to DMA transfer buffer in bytes
81 * @dma: the dma number
82 * @size: the dma transfer size
84 * Returns the current pointer in DMA tranfer buffer in bytes
86 unsigned int snd_dma_pointer(unsigned long dma, unsigned int size)
88 unsigned long flags;
89 unsigned int result;
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 if (!isa_dma_bridge_buggy)
97 enable_dma(dma);
98 release_dma_lock(flags);
99 #ifdef CONFIG_SND_DEBUG
100 if (result > size)
101 snd_printk(KERN_ERR "pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size);
102 #endif
103 if (result >= size || result == 0)
104 return 0;
105 else
106 return size - result;
109 EXPORT_SYMBOL(snd_dma_pointer);