2 * sound/arm/omap-aic23.h
4 * Alsa Driver for AIC23 codec on OSK5912 platform board
6 * Copyright (C) 2005 Instituto Nokia de Tecnologia - INdT - Manaus Brazil
7 * Written by Daniel Petrini, David Cohen, Anderson Briglia
8 * {daniel.petrini, david.cohen, anderson.briglia}@indt.org.br
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
21 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
33 * 2005/07/25 INdT-10LE Kernel Team - Alsa driver for omap osk,
34 * original version based in sa1100 driver
35 * and omap oss driver.
37 * 2005-12-18 Dirk Behme - Added L/R Channel Interchange fix as proposed by Ajaya Babu
40 #ifndef __OMAP_AIC23_H
41 #define __OMAP_AIC23_H
43 #include <sound/driver.h>
44 #include <asm/arch/dma.h>
45 #include <sound/core.h>
46 #include <sound/pcm.h>
48 #define DEFAULT_OUTPUT_VOLUME 0x60
49 #define DEFAULT_INPUT_VOLUME 0x00 /* 0 ==> mute line in */
51 #define OUTPUT_VOLUME_MIN LHV_MIN
52 #define OUTPUT_VOLUME_MAX LHV_MAX
53 #define OUTPUT_VOLUME_RANGE (OUTPUT_VOLUME_MAX - OUTPUT_VOLUME_MIN)
54 #define OUTPUT_VOLUME_MASK OUTPUT_VOLUME_MAX
56 #define INPUT_VOLUME_MIN LIV_MIN
57 #define INPUT_VOLUME_MAX LIV_MAX
58 #define INPUT_VOLUME_RANGE (INPUT_VOLUME_MAX - INPUT_VOLUME_MIN)
59 #define INPUT_VOLUME_MASK INPUT_VOLUME_MAX
61 #define SIDETONE_MASK 0x1c0
62 #define SIDETONE_0 0x100
63 #define SIDETONE_6 0x000
64 #define SIDETONE_9 0x040
65 #define SIDETONE_12 0x080
66 #define SIDETONE_18 0x0c0
68 #define DEFAULT_ANALOG_AUDIO_CONTROL DAC_SELECTED | STE_ENABLED | BYPASS_ON | INSEL_MIC | MICB_20DB
71 * Buffer management for alsa and dma
74 char *id; /* identification string */
75 int stream_id; /* numeric identification */
76 int dma_dev; /* dma number of that device */
77 int *lch; /* Chain of channels this stream is linked to */
78 char started; /* to store if the chain was started or not */
79 int dma_q_head; /* DMA Channel Q Head */
80 int dma_q_tail; /* DMA Channel Q Tail */
81 char dma_q_count; /* DMA Channel Q Count */
82 int active:1; /* we are using this stream for transfer now */
83 int period; /* current transfer period */
84 int periods; /* current count of periods registerd in the DMA engine */
85 spinlock_t dma_lock; /* for locking in DMA operations */
86 snd_pcm_substream_t *stream; /* the pcm stream */
87 unsigned linked:1; /* dma channels linked */
88 int offset; /* store start position of the last period in the alsa buffer */
89 int (*hw_start)(void); /* interface to start HW interface, e.g. McBSP */
90 int (*hw_stop)(void); /* interface to stop HW interface, e.g. McBSP */
94 * Alsa card structure for aic23
96 struct snd_card_omap_codec {
100 struct audio_stream s[2]; /* playback & capture */
103 /*********** Mixer function prototypes *************************/
104 int snd_omap_mixer(struct snd_card_omap_codec *);
105 void snd_omap_init_mixer(void);
106 /* Clock functions */
107 int omap_aic23_clock_on(void);
108 int omap_aic23_clock_off(void);
111 void snd_omap_suspend_mixer(void);
112 void snd_omap_resume_mixer(void);
115 /*********** function prototype to function called from the dma interrupt handler ******/
116 void callback_omap_alsa_sound_dma(void *);
119 #if defined(CONFIG_SENSORS_TLV320AIC23) || defined (CONFIG_SENSORS_TLV320AIC23_MODULE)
121 extern int tlv320aic23_write_value(u8 reg, u16 value);
123 /* TLV320AIC23 is a write only device */
124 static __inline__ void audio_aic23_write(u8 address, u16 data)
126 tlv320aic23_write_value(address, data);
129 #endif /* CONFIG_SENSORS_TLV320AIC23 */