2 * linux/include/asm-arm/arch-omap/omap-alsa.h
4 * Alsa Driver for AIC23 and TSC2101 codecs on OMAP platform boards.
6 * Copyright (C) 2006 Mika Laitio <lamikr@cc.jyu.fi>
8 * Copyright (C) 2005 Instituto Nokia de Tecnologia - INdT - Manaus Brazil
9 * Written by Daniel Petrini, David Cohen, Anderson Briglia
10 * {daniel.petrini, david.cohen, anderson.briglia}@indt.org.br
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 675 Mass Ave, Cambridge, MA 02139, USA.
35 * 2005/07/25 INdT-10LE Kernel Team - Alsa driver for omap osk,
36 * original version based in sa1100 driver
37 * and omap oss driver.
43 #include <sound/driver.h>
44 #include <asm/arch/dma.h>
45 #include <sound/core.h>
46 #include <sound/pcm.h>
47 #include <asm/arch/mcbsp.h>
48 #include <linux/platform_device.h>
55 #define ERR(ARGS...) printk(KERN_ERR "{%s}-ERROR: ", __FUNCTION__);printk(ARGS);
58 #define DPRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
59 #define ADEBUG() printk("XXX Alsa debug f:%s, l:%d\n", __FUNCTION__, __LINE__)
60 #define FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
61 #define FN_OUT(n) printk(KERN_INFO "[%s]: end(%u)\n",__FUNCTION__, n)
63 #define DPRINTK(ARGS...) /* nop */
64 #define ADEBUG() /* nop */
65 #define FN_IN /* nop */
66 #define FN_OUT(n) /* nop */
69 #define DMA_BUF_SIZE (1024 * 8)
72 * Buffer management for alsa and dma
75 char *id; /* identification string */
76 int stream_id; /* numeric identification */
77 int dma_dev; /* dma number of that device */
78 int *lch; /* Chain of channels this stream is linked to */
79 char started; /* to store if the chain was started or not */
80 int dma_q_head; /* DMA Channel Q Head */
81 int dma_q_tail; /* DMA Channel Q Tail */
82 char dma_q_count; /* DMA Channel Q Count */
83 int active:1; /* we are using this stream for transfer now */
84 int period; /* current transfer period */
85 int periods; /* current count of periods registerd in the DMA engine */
86 spinlock_t dma_lock; /* for locking in DMA operations */
87 snd_pcm_substream_t *stream; /* the pcm stream */
88 unsigned linked:1; /* dma channels linked */
89 int offset; /* store start position of the last period in the alsa buffer */
90 int (*hw_start)(void); /* interface to start HW interface, e.g. McBSP */
91 int (*hw_stop)(void); /* interface to stop HW interface, e.g. McBSP */
95 * Alsa card structure for aic23
97 struct snd_card_omap_codec {
101 struct audio_stream s[2]; /* playback & capture */
104 /* Codec specific information and function pointers.
105 * Codec (omap-alsa-aic23.c and omap-alsa-tsc2101.c)
106 * are responsible for defining the function pointers.
108 struct omap_alsa_codec_config {
110 struct omap_mcbsp_reg_cfg *mcbsp_regs_alsa;
111 snd_pcm_hw_constraint_list_t *hw_constraints_rates;
112 snd_pcm_hardware_t *snd_omap_alsa_playback;
113 snd_pcm_hardware_t *snd_omap_alsa_capture;
114 void (*codec_configure_dev)(void);
115 void (*codec_set_samplerate)(long);
116 void (*codec_clock_setup)(void);
117 int (*codec_clock_on)(void);
118 int (*codec_clock_off)(void);
119 int (*get_default_samplerate)(void);
122 /*********** Mixer function prototypes *************************/
123 int snd_omap_mixer(struct snd_card_omap_codec *);
124 void snd_omap_init_mixer(void);
127 void snd_omap_suspend_mixer(void);
128 void snd_omap_resume_mixer(void);
131 int snd_omap_alsa_post_probe(struct platform_device *pdev, struct omap_alsa_codec_config *config);
132 int snd_omap_alsa_remove(struct platform_device *pdev);
134 int snd_omap_alsa_suspend(struct platform_device *pdev, pm_message_t state);
135 int snd_omap_alsa_resume(struct platform_device *pdev);
137 #define snd_omap_alsa_suspend NULL
138 #define snd_omap_alsa_resume NULL
141 void callback_omap_alsa_sound_dma(void *);