GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / sound / soc / omap / omap3beagle.c
blob240e0975dd6a716e47546a54deb83cecffb9b960
1 /*
2 * omap3beagle.c -- SoC audio for OMAP3 Beagle
4 * Author: Steve Sakoman <steve@sakoman.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
22 #include <linux/clk.h>
23 #include <linux/platform_device.h>
24 #include <sound/core.h>
25 #include <sound/pcm.h>
26 #include <sound/soc.h>
27 #include <sound/soc-dapm.h>
29 #include <asm/mach-types.h>
30 #include <mach/hardware.h>
31 #include <mach/gpio.h>
32 #include <plat/mcbsp.h>
34 #include "omap-mcbsp.h"
35 #include "omap-pcm.h"
36 #include "../codecs/twl4030.h"
38 static int omap3beagle_hw_params(struct snd_pcm_substream *substream,
39 struct snd_pcm_hw_params *params)
41 struct snd_soc_pcm_runtime *rtd = substream->private_data;
42 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
43 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
44 unsigned int fmt;
45 int ret;
47 switch (params_channels(params)) {
48 case 2: /* Stereo I2S mode */
49 fmt = SND_SOC_DAIFMT_I2S |
50 SND_SOC_DAIFMT_NB_NF |
51 SND_SOC_DAIFMT_CBM_CFM;
52 break;
53 case 4: /* Four channel TDM mode */
54 fmt = SND_SOC_DAIFMT_DSP_A |
55 SND_SOC_DAIFMT_IB_NF |
56 SND_SOC_DAIFMT_CBM_CFM;
57 break;
58 default:
59 return -EINVAL;
62 /* Set codec DAI configuration */
63 ret = snd_soc_dai_set_fmt(codec_dai, fmt);
64 if (ret < 0) {
65 printk(KERN_ERR "can't set codec DAI configuration\n");
66 return ret;
69 /* Set cpu DAI configuration */
70 ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
71 if (ret < 0) {
72 printk(KERN_ERR "can't set cpu DAI configuration\n");
73 return ret;
76 /* Set the codec system clock for DAC and ADC */
77 ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
78 SND_SOC_CLOCK_IN);
79 if (ret < 0) {
80 printk(KERN_ERR "can't set codec system clock\n");
81 return ret;
84 return 0;
87 static struct snd_soc_ops omap3beagle_ops = {
88 .hw_params = omap3beagle_hw_params,
91 /* Digital audio interface glue - connects codec <--> CPU */
92 static struct snd_soc_dai_link omap3beagle_dai = {
93 .name = "TWL4030",
94 .stream_name = "TWL4030",
95 .cpu_dai = &omap_mcbsp_dai[0],
96 .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI],
97 .ops = &omap3beagle_ops,
100 /* Audio machine driver */
101 static struct snd_soc_card snd_soc_omap3beagle = {
102 .name = "omap3beagle",
103 .platform = &omap_soc_platform,
104 .dai_link = &omap3beagle_dai,
105 .num_links = 1,
108 /* Audio subsystem */
109 static struct snd_soc_device omap3beagle_snd_devdata = {
110 .card = &snd_soc_omap3beagle,
111 .codec_dev = &soc_codec_dev_twl4030,
114 static struct platform_device *omap3beagle_snd_device;
116 static int __init omap3beagle_soc_init(void)
118 int ret;
120 if (!(machine_is_omap3_beagle() || machine_is_devkit8000())) {
121 pr_debug("Not OMAP3 Beagle or Devkit8000!\n");
122 return -ENODEV;
124 pr_info("OMAP3 Beagle/Devkit8000 SoC init\n");
126 omap3beagle_snd_device = platform_device_alloc("soc-audio", -1);
127 if (!omap3beagle_snd_device) {
128 printk(KERN_ERR "Platform device allocation failed\n");
129 return -ENOMEM;
132 platform_set_drvdata(omap3beagle_snd_device, &omap3beagle_snd_devdata);
133 omap3beagle_snd_devdata.dev = &omap3beagle_snd_device->dev;
134 *(unsigned int *)omap3beagle_dai.cpu_dai->private_data = 1; /* McBSP2 */
136 ret = platform_device_add(omap3beagle_snd_device);
137 if (ret)
138 goto err1;
140 return 0;
142 err1:
143 printk(KERN_ERR "Unable to add platform device\n");
144 platform_device_put(omap3beagle_snd_device);
146 return ret;
149 static void __exit omap3beagle_soc_exit(void)
151 platform_device_unregister(omap3beagle_snd_device);
154 module_init(omap3beagle_soc_init);
155 module_exit(omap3beagle_soc_exit);
157 MODULE_AUTHOR("Steve Sakoman <steve@sakoman.com>");
158 MODULE_DESCRIPTION("ALSA SoC OMAP3 Beagle");
159 MODULE_LICENSE("GPL");