~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/core/isadma.c

Version: ~ [ linux-5.7 ] ~ [ linux-5.6.15 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.43 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.125 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.182 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.225 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.225 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.84 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  ISA DMA support functions
  3  *  Copyright (c) by Jaroslav Kysela <perex@perex.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 <linux/export.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 EXPORT_SYMBOL(snd_dma_program);
 59 
 60 /**
 61  * snd_dma_disable - stop the ISA DMA transfer
 62  * @dma: the dma number
 63  *
 64  * Stops the ISA DMA transfer.
 65  */
 66 void snd_dma_disable(unsigned long dma)
 67 {
 68         unsigned long flags;
 69 
 70         flags = claim_dma_lock();
 71         clear_dma_ff(dma);
 72         disable_dma(dma);
 73         release_dma_lock(flags);
 74 }
 75 EXPORT_SYMBOL(snd_dma_disable);
 76 
 77 /**
 78  * snd_dma_pointer - return the current pointer to DMA transfer buffer in bytes
 79  * @dma: the dma number
 80  * @size: the dma transfer size
 81  *
 82  * Return: The current pointer in DMA transfer buffer in bytes.
 83  */
 84 unsigned int snd_dma_pointer(unsigned long dma, unsigned int size)
 85 {
 86         unsigned long flags;
 87         unsigned int result, result1;
 88 
 89         flags = claim_dma_lock();
 90         clear_dma_ff(dma);
 91         if (!isa_dma_bridge_buggy)
 92                 disable_dma(dma);
 93         result = get_dma_residue(dma);
 94         /*
 95          * HACK - read the counter again and choose higher value in order to
 96          * avoid reading during counter lower byte roll over if the
 97          * isa_dma_bridge_buggy is set.
 98          */
 99         result1 = get_dma_residue(dma);
100         if (!isa_dma_bridge_buggy)
101                 enable_dma(dma);
102         release_dma_lock(flags);
103         if (unlikely(result < result1))
104                 result = result1;
105 #ifdef CONFIG_SND_DEBUG
106         if (result > size)
107                 pr_err("ALSA: pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size);
108 #endif
109         if (result >= size || result == 0)
110                 return 0;
111         else
112                 return size - result;
113 }
114 EXPORT_SYMBOL(snd_dma_pointer);
115 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp