]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - sound/arm/omap-aic23.h
ARM: OMAP: Fix compliation/inlining in aic23 ALSA Driver
[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  */
38
39 #ifndef __OMAP_AIC23_H
40 #define __OMAP_AIC23_H
41
42 #include <sound/driver.h>
43 #include <asm/arch/dma.h>
44 #include <sound/core.h>
45 #include <sound/pcm.h>
46
47 #define DEFAULT_OUTPUT_VOLUME         0x60
48 #define DEFAULT_INPUT_VOLUME          0x00      /* 0 ==> mute line in */
49
50 #define OUTPUT_VOLUME_MIN             LHV_MIN
51 #define OUTPUT_VOLUME_MAX             LHV_MAX
52 #define OUTPUT_VOLUME_RANGE           (OUTPUT_VOLUME_MAX - OUTPUT_VOLUME_MIN)
53 #define OUTPUT_VOLUME_MASK            OUTPUT_VOLUME_MAX
54
55 #define INPUT_VOLUME_MIN              LIV_MIN
56 #define INPUT_VOLUME_MAX              LIV_MAX
57 #define INPUT_VOLUME_RANGE            (INPUT_VOLUME_MAX - INPUT_VOLUME_MIN)
58 #define INPUT_VOLUME_MASK             INPUT_VOLUME_MAX
59
60 #define SIDETONE_MASK                 0x1c0
61 #define SIDETONE_0                    0x100
62 #define SIDETONE_6                    0x000
63 #define SIDETONE_9                    0x040
64 #define SIDETONE_12                   0x080
65 #define SIDETONE_18                   0x0c0
66
67 #define DEFAULT_ANALOG_AUDIO_CONTROL  DAC_SELECTED | STE_ENABLED | BYPASS_ON | INSEL_MIC | MICB_20DB
68
69 /*
70  * Buffer management for alsa and dma
71  */
72 struct audio_stream {
73         char *id;               /* identification string */
74         int stream_id;          /* numeric identification */
75         int dma_dev;            /* dma number of that device */
76         int *lch;               /* Chain of channels this stream is linked to */
77         char started;           /* to store if the chain was started or not */
78         int dma_q_head;         /* DMA Channel Q Head */
79         int dma_q_tail;         /* DMA Channel Q Tail */
80         char dma_q_count;       /* DMA Channel Q Count */
81         int active:1;           /* we are using this stream for transfer now */
82         int period;             /* current transfer period */
83         int periods;            /* current count of periods registerd in the DMA engine */
84         spinlock_t dma_lock;    /* for locking in DMA operations */
85         snd_pcm_substream_t *stream;    /* the pcm stream */
86         unsigned linked:1;      /* dma channels linked */
87         int offset;             /* store start position of the last period in the alsa buffer */
88 };
89
90 /*
91  * Alsa card structure for aic23
92  */
93 struct snd_card_omap_aic23 {
94         snd_card_t *card;
95         snd_pcm_t *pcm;
96         long samplerate;
97         struct audio_stream s[2];       /* playback & capture */
98 };
99
100 /*********** Function Prototypes *************************/
101
102 void audio_dma_callback(void *);
103 int snd_omap_mixer(struct snd_card_omap_aic23 *);
104 void snd_omap_init_mixer(void);
105 /* Clock functions */
106 int omap_aic23_clock_on(void);
107 int omap_aic23_clock_off(void);
108
109 #ifdef CONFIG_PM
110 void snd_omap_suspend_mixer(void);
111 void snd_omap_resume_mixer(void);
112 #endif
113
114 /* Codec AIC23 */
115 #if defined(CONFIG_SENSORS_TLV320AIC23) || defined (CONFIG_SENSORS_TLV320AIC23_MODULE)
116
117 extern int tlv320aic23_write_value(u8 reg, u16 value);
118
119 /* TLV320AIC23 is a write only device */
120 static __inline__ void audio_aic23_write(u8 address, u16 data)
121 {
122         tlv320aic23_write_value(address, data);
123 }
124
125 #endif /* CONFIG_SENSORS_TLV320AIC23 */
126
127 #endif