]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/plat-omap/include/mach/omap-alsa.h
Merge current mainline tree into linux-omap tree
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / include / mach / omap-alsa.h
1 /*
2  * arch/arm/plat-omap/include/mach/omap-alsa.h
3  *
4  * Alsa Driver for AIC23 and TSC2101 codecs on OMAP platform boards.
5  *
6  * Copyright (C) 2006 Mika Laitio <lamikr@cc.jyu.fi>
7  *
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
11  *
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.
16  *
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.
27  *
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.
31  *
32  *  History
33  *  -------
34  *
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.
38  */
39
40 #ifndef __OMAP_ALSA_H
41 #define __OMAP_ALSA_H
42
43 #include <mach/dma.h>
44 #include <sound/core.h>
45 #include <sound/pcm.h>
46 #include <mach/mcbsp.h>
47 #include <linux/platform_device.h>
48 /*
49  * Debug functions
50  */
51 #undef DEBUG
52 /* #define DEBUG */
53
54 #define ERR(ARGS...)                                            \
55         do {                                                    \
56                 printk(KERN_ERR "{%s}-ERROR: ", __func__);      \
57                 printk(ARGS);                                   \
58         } while (0)
59
60 #ifdef DEBUG
61 #define DPRINTK(ARGS...)                                        \
62         do {                                                    \
63                 printk(KERN_INFO "<%s>: ", __func__);           \
64                 printk(ARGS);                                   \
65         } while (0)
66 #define ADEBUG() printk("XXX Alsa debug f:%s, l:%d\n", __func__, __LINE__)
67 #define FN_IN printk(KERN_INFO "[%s]: start\n", __func__)
68 #define FN_OUT(n) printk(KERN_INFO "[%s]: end(%u)\n", __func__, n)
69 #else
70 #define DPRINTK(ARGS...)        /* nop */
71 #define ADEBUG()                /* nop */
72 #define FN_IN                   /* nop */
73 #define FN_OUT(n)               /* nop */
74 #endif
75
76 #define DMA_BUF_SIZE    (1024 * 8)
77
78 /*
79  * Buffer management for alsa and dma
80  */
81 struct audio_stream {
82         char *id;               /* identification string */
83         int stream_id;          /* numeric identification */
84         int dma_dev;            /* dma number of that device */
85         int *lch;               /* Chain of channels this stream is linked to */
86         char started;           /* to store if the chain was started or not */
87         int dma_q_head;         /* DMA Channel Q Head */
88         int dma_q_tail;         /* DMA Channel Q Tail */
89         char dma_q_count;       /* DMA Channel Q Count */
90         int active:1;           /* we are using this stream for transfer now */
91         int period;             /* current transfer period */
92         int periods;            /* current registered periods in DMA engine */
93         spinlock_t dma_lock;    /* for locking in DMA operations */
94         struct snd_pcm_substream *stream;       /* the pcm stream */
95         unsigned linked:1;      /* dma channels linked */
96         int offset;             /* start position of last period in alsa buf */
97         int (*hw_start)(void);  /* interface to start HW interface, (McBSP) */
98         int (*hw_stop)(void);   /* interface to stop HW interface, e.g. McBSP */
99 };
100
101 /*
102  * Alsa card structure for aic23
103  */
104 struct snd_card_omap_codec {
105         struct snd_card *card;
106         struct snd_pcm *pcm;
107         long samplerate;
108         struct audio_stream s[2];       /* playback & capture */
109 };
110
111 /* Codec specific information and function pointers.
112  * Codec (omap-alsa-aic23.c and omap-alsa-tsc2101.c)
113  * are responsible for defining the function pointers.
114  */
115 struct omap_alsa_codec_config {
116         char    *name;
117         struct  omap_mcbsp_reg_cfg *mcbsp_regs_alsa;
118         struct  snd_pcm_hw_constraint_list *hw_constraints_rates;
119         struct  snd_pcm_hardware *snd_omap_alsa_playback;
120         struct  snd_pcm_hardware *snd_omap_alsa_capture;
121         void    (*codec_configure_dev)(void);
122         void    (*codec_set_samplerate)(long);
123         void    (*codec_clock_setup)(void);
124         int     (*codec_clock_on)(void);
125         int     (*codec_clock_off)(void);
126         int     (*get_default_samplerate)(void);
127 };
128
129 /*********** Mixer function prototypes *************************/
130 int snd_omap_mixer(struct snd_card_omap_codec *);
131 void snd_omap_init_mixer(void);
132
133 #ifdef CONFIG_PM
134 void snd_omap_suspend_mixer(void);
135 void snd_omap_resume_mixer(void);
136 #endif
137
138 int snd_omap_alsa_post_probe(struct platform_device *pdev,
139                                 struct omap_alsa_codec_config *config);
140 int snd_omap_alsa_remove(struct platform_device *pdev);
141 #ifdef CONFIG_PM
142 int snd_omap_alsa_suspend(struct platform_device *pdev, pm_message_t state);
143 int snd_omap_alsa_resume(struct platform_device *pdev);
144 #else
145 #define snd_omap_alsa_suspend   NULL
146 #define snd_omap_alsa_resume    NULL
147 #endif
148
149 void callback_omap_alsa_sound_dma(void *);
150
151 #endif