libertas: fix cmdpendingq locking
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / sound / soc / omap / overo.c
blobbbcf380bfb56309ce0e193e2312fe47eea8f9366
1 /*
2 * overo.c -- SoC audio for Gumstix Overo
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>
28 #include <asm/mach-types.h>
29 #include <mach/hardware.h>
30 #include <mach/gpio.h>
31 #include <plat/mcbsp.h>
33 #include "omap-mcbsp.h"
34 #include "omap-pcm.h"
36 static int overo_hw_params(struct snd_pcm_substream *substream,
37 struct snd_pcm_hw_params *params)
39 struct snd_soc_pcm_runtime *rtd = substream->private_data;
40 struct snd_soc_dai *codec_dai = rtd->codec_dai;
41 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
42 int ret;
44 /* Set codec DAI configuration */
45 ret = snd_soc_dai_set_fmt(codec_dai,
46 SND_SOC_DAIFMT_I2S |
47 SND_SOC_DAIFMT_NB_NF |
48 SND_SOC_DAIFMT_CBM_CFM);
49 if (ret < 0) {
50 printk(KERN_ERR "can't set codec DAI configuration\n");
51 return ret;
54 /* Set cpu DAI configuration */
55 ret = snd_soc_dai_set_fmt(cpu_dai,
56 SND_SOC_DAIFMT_I2S |
57 SND_SOC_DAIFMT_NB_NF |
58 SND_SOC_DAIFMT_CBM_CFM);
59 if (ret < 0) {
60 printk(KERN_ERR "can't set cpu DAI configuration\n");
61 return ret;
64 /* Set the codec system clock for DAC and ADC */
65 ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
66 SND_SOC_CLOCK_IN);
67 if (ret < 0) {
68 printk(KERN_ERR "can't set codec system clock\n");
69 return ret;
72 return 0;
75 static struct snd_soc_ops overo_ops = {
76 .hw_params = overo_hw_params,
79 /* Digital audio interface glue - connects codec <--> CPU */
80 static struct snd_soc_dai_link overo_dai = {
81 .name = "TWL4030",
82 .stream_name = "TWL4030",
83 .cpu_dai_name = "omap-mcbsp-dai.1",
84 .codec_dai_name = "twl4030-hifi",
85 .platform_name = "omap-pcm-audio",
86 .codec_name = "twl4030-codec",
87 .ops = &overo_ops,
90 /* Audio machine driver */
91 static struct snd_soc_card snd_soc_card_overo = {
92 .name = "overo",
93 .dai_link = &overo_dai,
94 .num_links = 1,
97 static struct platform_device *overo_snd_device;
99 static int __init overo_soc_init(void)
101 int ret;
103 if (!(machine_is_overo() || machine_is_cm_t35())) {
104 pr_debug("Incomatible machine!\n");
105 return -ENODEV;
107 printk(KERN_INFO "overo SoC init\n");
109 overo_snd_device = platform_device_alloc("soc-audio", -1);
110 if (!overo_snd_device) {
111 printk(KERN_ERR "Platform device allocation failed\n");
112 return -ENOMEM;
115 platform_set_drvdata(overo_snd_device, &snd_soc_card_overo);
117 ret = platform_device_add(overo_snd_device);
118 if (ret)
119 goto err1;
121 return 0;
123 err1:
124 printk(KERN_ERR "Unable to add platform device\n");
125 platform_device_put(overo_snd_device);
127 return ret;
129 module_init(overo_soc_init);
131 static void __exit overo_soc_exit(void)
133 platform_device_unregister(overo_snd_device);
135 module_exit(overo_soc_exit);
137 MODULE_AUTHOR("Steve Sakoman <steve@sakoman.com>");
138 MODULE_DESCRIPTION("ALSA SoC overo");
139 MODULE_LICENSE("GPL");