]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - sound/arm/omap-aic23.h
c8ab42c29354c00b9e364c5c24abe5eaed9aa0f6
[linux-2.6-omap-h63xx.git] / sound / arm / omap-aic23.h
1 /*
2  * sound/arm/omap-aic23.h
3  * 
4  * Alsa Driver for AIC23 codec on OSK5912 platform board
5  *
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
9  *
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.
14  *
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.
25  *
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.
29  *
30  *  History
31  *  -------
32  *
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.
36  *
37  *  2005-12-18   Dirk Behme      - Added L/R Channel Interchange fix as proposed by Ajaya Babu
38  */
39
40 #ifndef __OMAP_AIC23_H
41 #define __OMAP_AIC23_H
42
43 #include <sound/driver.h>
44 #include <asm/arch/dma.h>
45 #include <sound/core.h>
46 #include <sound/pcm.h>
47
48 #define DEFAULT_OUTPUT_VOLUME         0x60
49 #define DEFAULT_INPUT_VOLUME          0x00      /* 0 ==> mute line in */
50
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
55
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
60
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
67
68 #define DEFAULT_ANALOG_AUDIO_CONTROL  DAC_SELECTED | STE_ENABLED | BYPASS_ON | INSEL_MIC | MICB_20DB
69
70 /*
71  * Buffer management for alsa and dma
72  */
73 struct audio_stream {
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 */
91 };
92
93 /*
94  * Alsa card structure for aic23
95  */
96 struct snd_card_omap_aic23 {
97         snd_card_t *card;
98         snd_pcm_t *pcm;
99         long samplerate;
100         struct audio_stream s[2];       /* playback & capture */
101 };
102
103 /*********** Function Prototypes *************************/
104
105 void audio_dma_callback(void *);
106 int snd_omap_mixer(struct snd_card_omap_aic23 *);
107 void snd_omap_init_mixer(void);
108 /* Clock functions */
109 int omap_aic23_clock_on(void);
110 int omap_aic23_clock_off(void);
111
112 #ifdef CONFIG_PM
113 void snd_omap_suspend_mixer(void);
114 void snd_omap_resume_mixer(void);
115 #endif
116
117 /* Codec AIC23 */
118 #if defined(CONFIG_SENSORS_TLV320AIC23) || defined (CONFIG_SENSORS_TLV320AIC23_MODULE)
119
120 extern int tlv320aic23_write_value(u8 reg, u16 value);
121
122 /* TLV320AIC23 is a write only device */
123 static __inline__ void audio_aic23_write(u8 address, u16 data)
124 {
125         tlv320aic23_write_value(address, data);
126 }
127
128 #endif /* CONFIG_SENSORS_TLV320AIC23 */
129
130 #endif