diff options
Diffstat (limited to 'sound/soc/omap')
-rw-r--r-- | sound/soc/omap/Kconfig | 9 | ||||
-rw-r--r-- | sound/soc/omap/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/omap/mcpdm.c | 1 | ||||
-rw-r--r-- | sound/soc/omap/omap-mcbsp.c | 28 | ||||
-rw-r--r-- | sound/soc/omap/omap-pcm.c | 1 | ||||
-rw-r--r-- | sound/soc/omap/sdp4430.c | 233 |
6 files changed, 270 insertions, 4 deletions
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 83be4a76d2bb..d542ea2ff6be 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig | |||
@@ -98,6 +98,15 @@ config SND_OMAP_SOC_SDP3430 | |||
98 | Say Y if you want to add support for SoC audio on Texas Instruments | 98 | Say Y if you want to add support for SoC audio on Texas Instruments |
99 | SDP3430. | 99 | SDP3430. |
100 | 100 | ||
101 | config SND_OMAP_SOC_SDP4430 | ||
102 | tristate "SoC Audio support for Texas Instruments SDP4430" | ||
103 | depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_4430SDP | ||
104 | select SND_OMAP_SOC_MCPDM | ||
105 | select SND_SOC_TWL6040 | ||
106 | help | ||
107 | Say Y if you want to add support for SoC audio on Texas Instruments | ||
108 | SDP4430. | ||
109 | |||
101 | config SND_OMAP_SOC_OMAP3_PANDORA | 110 | config SND_OMAP_SOC_OMAP3_PANDORA |
102 | tristate "SoC Audio support for OMAP3 Pandora" | 111 | tristate "SoC Audio support for OMAP3 Pandora" |
103 | depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3_PANDORA | 112 | depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3_PANDORA |
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 3a75755f25e4..ba9fc650db28 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile | |||
@@ -17,6 +17,7 @@ snd-soc-omap2evm-objs := omap2evm.o | |||
17 | snd-soc-omap3evm-objs := omap3evm.o | 17 | snd-soc-omap3evm-objs := omap3evm.o |
18 | snd-soc-am3517evm-objs := am3517evm.o | 18 | snd-soc-am3517evm-objs := am3517evm.o |
19 | snd-soc-sdp3430-objs := sdp3430.o | 19 | snd-soc-sdp3430-objs := sdp3430.o |
20 | snd-soc-sdp4430-objs := sdp4430.o | ||
20 | snd-soc-omap3pandora-objs := omap3pandora.o | 21 | snd-soc-omap3pandora-objs := omap3pandora.o |
21 | snd-soc-omap3beagle-objs := omap3beagle.o | 22 | snd-soc-omap3beagle-objs := omap3beagle.o |
22 | snd-soc-zoom2-objs := zoom2.o | 23 | snd-soc-zoom2-objs := zoom2.o |
@@ -31,6 +32,7 @@ obj-$(CONFIG_SND_OMAP_SOC_OMAP2EVM) += snd-soc-omap2evm.o | |||
31 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3EVM) += snd-soc-omap3evm.o | 32 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3EVM) += snd-soc-omap3evm.o |
32 | obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o | 33 | obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o |
33 | obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o | 34 | obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o |
35 | obj-$(CONFIG_SND_OMAP_SOC_SDP4430) += snd-soc-sdp4430.o | ||
34 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o | 36 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o |
35 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o | 37 | obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o |
36 | obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o | 38 | obj-$(CONFIG_SND_OMAP_SOC_ZOOM2) += snd-soc-zoom2.o |
diff --git a/sound/soc/omap/mcpdm.c b/sound/soc/omap/mcpdm.c index 479d3b6306d7..90b8bf71c893 100644 --- a/sound/soc/omap/mcpdm.c +++ b/sound/soc/omap/mcpdm.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/device.h> | 25 | #include <linux/device.h> |
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/wait.h> | 27 | #include <linux/wait.h> |
28 | #include <linux/slab.h> | ||
28 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
29 | #include <linux/err.h> | 30 | #include <linux/err.h> |
30 | #include <linux/clk.h> | 31 | #include <linux/clk.h> |
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 2d33a89f147a..6f44cb4d30b8 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
@@ -320,8 +320,18 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
320 | omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma; | 320 | omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma; |
321 | omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port; | 321 | omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port; |
322 | omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode; | 322 | omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode; |
323 | omap_mcbsp_dai_dma_params[id][substream->stream].data_type = | 323 | switch (params_format(params)) { |
324 | OMAP_DMA_DATA_TYPE_S16; | 324 | case SNDRV_PCM_FORMAT_S16_LE: |
325 | omap_mcbsp_dai_dma_params[id][substream->stream].data_type = | ||
326 | OMAP_DMA_DATA_TYPE_S16; | ||
327 | break; | ||
328 | case SNDRV_PCM_FORMAT_S32_LE: | ||
329 | omap_mcbsp_dai_dma_params[id][substream->stream].data_type = | ||
330 | OMAP_DMA_DATA_TYPE_S32; | ||
331 | break; | ||
332 | default: | ||
333 | return -EINVAL; | ||
334 | } | ||
325 | 335 | ||
326 | snd_soc_dai_set_dma_data(cpu_dai, substream, | 336 | snd_soc_dai_set_dma_data(cpu_dai, substream, |
327 | &omap_mcbsp_dai_dma_params[id][substream->stream]); | 337 | &omap_mcbsp_dai_dma_params[id][substream->stream]); |
@@ -356,6 +366,14 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
356 | regs->xcr2 |= XWDLEN2(OMAP_MCBSP_WORD_16); | 366 | regs->xcr2 |= XWDLEN2(OMAP_MCBSP_WORD_16); |
357 | regs->xcr1 |= XWDLEN1(OMAP_MCBSP_WORD_16); | 367 | regs->xcr1 |= XWDLEN1(OMAP_MCBSP_WORD_16); |
358 | break; | 368 | break; |
369 | case SNDRV_PCM_FORMAT_S32_LE: | ||
370 | /* Set word lengths */ | ||
371 | wlen = 32; | ||
372 | regs->rcr2 |= RWDLEN2(OMAP_MCBSP_WORD_32); | ||
373 | regs->rcr1 |= RWDLEN1(OMAP_MCBSP_WORD_32); | ||
374 | regs->xcr2 |= XWDLEN2(OMAP_MCBSP_WORD_32); | ||
375 | regs->xcr1 |= XWDLEN1(OMAP_MCBSP_WORD_32); | ||
376 | break; | ||
359 | default: | 377 | default: |
360 | /* Unsupported PCM format */ | 378 | /* Unsupported PCM format */ |
361 | return -EINVAL; | 379 | return -EINVAL; |
@@ -659,13 +677,15 @@ static struct snd_soc_dai_ops omap_mcbsp_dai_ops = { | |||
659 | .channels_min = 1, \ | 677 | .channels_min = 1, \ |
660 | .channels_max = 16, \ | 678 | .channels_max = 16, \ |
661 | .rates = OMAP_MCBSP_RATES, \ | 679 | .rates = OMAP_MCBSP_RATES, \ |
662 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ | 680 | .formats = SNDRV_PCM_FMTBIT_S16_LE | \ |
681 | SNDRV_PCM_FMTBIT_S32_LE, \ | ||
663 | }, \ | 682 | }, \ |
664 | .capture = { \ | 683 | .capture = { \ |
665 | .channels_min = 1, \ | 684 | .channels_min = 1, \ |
666 | .channels_max = 16, \ | 685 | .channels_max = 16, \ |
667 | .rates = OMAP_MCBSP_RATES, \ | 686 | .rates = OMAP_MCBSP_RATES, \ |
668 | .formats = SNDRV_PCM_FMTBIT_S16_LE, \ | 687 | .formats = SNDRV_PCM_FMTBIT_S16_LE | \ |
688 | SNDRV_PCM_FMTBIT_S32_LE, \ | ||
669 | }, \ | 689 | }, \ |
670 | .ops = &omap_mcbsp_dai_ops, \ | 690 | .ops = &omap_mcbsp_dai_ops, \ |
671 | .private_data = &mcbsp_data[(link_id)].bus_id, \ | 691 | .private_data = &mcbsp_data[(link_id)].bus_id, \ |
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 39456447132c..1e521904ea64 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c | |||
@@ -23,6 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/dma-mapping.h> | 25 | #include <linux/dma-mapping.h> |
26 | #include <linux/slab.h> | ||
26 | #include <sound/core.h> | 27 | #include <sound/core.h> |
27 | #include <sound/pcm.h> | 28 | #include <sound/pcm.h> |
28 | #include <sound/pcm_params.h> | 29 | #include <sound/pcm_params.h> |
diff --git a/sound/soc/omap/sdp4430.c b/sound/soc/omap/sdp4430.c new file mode 100644 index 000000000000..4ebbde6b565f --- /dev/null +++ b/sound/soc/omap/sdp4430.c | |||
@@ -0,0 +1,233 @@ | |||
1 | /* | ||
2 | * sdp4430.c -- SoC audio for TI OMAP4430 SDP | ||
3 | * | ||
4 | * Author: Misael Lopez Cruz <x0052729@ti.com> | ||
5 | * | ||
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. | ||
9 | * | ||
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. | ||
14 | * | ||
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 | ||
19 | * | ||
20 | */ | ||
21 | |||
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> | ||
28 | |||
29 | #include <asm/mach-types.h> | ||
30 | #include <plat/hardware.h> | ||
31 | #include <plat/mux.h> | ||
32 | |||
33 | #include "mcpdm.h" | ||
34 | #include "omap-mcpdm.h" | ||
35 | #include "omap-pcm.h" | ||
36 | #include "../codecs/twl6040.h" | ||
37 | |||
38 | static int twl6040_power_mode; | ||
39 | |||
40 | static int sdp4430_hw_params(struct snd_pcm_substream *substream, | ||
41 | struct snd_pcm_hw_params *params) | ||
42 | { | ||
43 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
44 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
45 | int clk_id, freq; | ||
46 | int ret; | ||
47 | |||
48 | if (twl6040_power_mode) { | ||
49 | clk_id = TWL6040_SYSCLK_SEL_HPPLL; | ||
50 | freq = 38400000; | ||
51 | } else { | ||
52 | clk_id = TWL6040_SYSCLK_SEL_LPPLL; | ||
53 | freq = 32768; | ||
54 | } | ||
55 | |||
56 | /* set the codec mclk */ | ||
57 | ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, freq, | ||
58 | SND_SOC_CLOCK_IN); | ||
59 | if (ret) { | ||
60 | printk(KERN_ERR "can't set codec system clock\n"); | ||
61 | return ret; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | static struct snd_soc_ops sdp4430_ops = { | ||
66 | .hw_params = sdp4430_hw_params, | ||
67 | }; | ||
68 | |||
69 | static int sdp4430_get_power_mode(struct snd_kcontrol *kcontrol, | ||
70 | struct snd_ctl_elem_value *ucontrol) | ||
71 | { | ||
72 | ucontrol->value.integer.value[0] = twl6040_power_mode; | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static int sdp4430_set_power_mode(struct snd_kcontrol *kcontrol, | ||
77 | struct snd_ctl_elem_value *ucontrol) | ||
78 | { | ||
79 | if (twl6040_power_mode == ucontrol->value.integer.value[0]) | ||
80 | return 0; | ||
81 | |||
82 | twl6040_power_mode = ucontrol->value.integer.value[0]; | ||
83 | |||
84 | return 1; | ||
85 | } | ||
86 | |||
87 | static const char *power_texts[] = {"Low-Power", "High-Performance"}; | ||
88 | |||
89 | static const struct soc_enum sdp4430_enum[] = { | ||
90 | SOC_ENUM_SINGLE_EXT(2, power_texts), | ||
91 | }; | ||
92 | |||
93 | static const struct snd_kcontrol_new sdp4430_controls[] = { | ||
94 | SOC_ENUM_EXT("TWL6040 Power Mode", sdp4430_enum[0], | ||
95 | sdp4430_get_power_mode, sdp4430_set_power_mode), | ||
96 | }; | ||
97 | |||
98 | /* SDP4430 machine DAPM */ | ||
99 | static const struct snd_soc_dapm_widget sdp4430_twl6040_dapm_widgets[] = { | ||
100 | SND_SOC_DAPM_MIC("Ext Mic", NULL), | ||
101 | SND_SOC_DAPM_SPK("Ext Spk", NULL), | ||
102 | SND_SOC_DAPM_MIC("Headset Mic", NULL), | ||
103 | SND_SOC_DAPM_HP("Headset Stereophone", NULL), | ||
104 | SND_SOC_DAPM_SPK("Earphone Spk", NULL), | ||
105 | }; | ||
106 | |||
107 | static const struct snd_soc_dapm_route audio_map[] = { | ||
108 | /* External Mics: MAINMIC, SUBMIC with bias*/ | ||
109 | {"MAINMIC", NULL, "Main Mic Bias"}, | ||
110 | {"SUBMIC", NULL, "Main Mic Bias"}, | ||
111 | {"Main Mic Bias", NULL, "Ext Mic"}, | ||
112 | |||
113 | /* External Speakers: HFL, HFR */ | ||
114 | {"Ext Spk", NULL, "HFL"}, | ||
115 | {"Ext Spk", NULL, "HFR"}, | ||
116 | |||
117 | /* Headset Mic: HSMIC with bias */ | ||
118 | {"HSMIC", NULL, "Headset Mic Bias"}, | ||
119 | {"Headset Mic Bias", NULL, "Headset Mic"}, | ||
120 | |||
121 | /* Headset Stereophone (Headphone): HSOL, HSOR */ | ||
122 | {"Headset Stereophone", NULL, "HSOL"}, | ||
123 | {"Headset Stereophone", NULL, "HSOR"}, | ||
124 | |||
125 | /* Earphone speaker */ | ||
126 | {"Earphone Spk", NULL, "EP"}, | ||
127 | }; | ||
128 | |||
129 | static int sdp4430_twl6040_init(struct snd_soc_codec *codec) | ||
130 | { | ||
131 | int ret; | ||
132 | |||
133 | /* Add SDP4430 specific controls */ | ||
134 | ret = snd_soc_add_controls(codec, sdp4430_controls, | ||
135 | ARRAY_SIZE(sdp4430_controls)); | ||
136 | if (ret) | ||
137 | return ret; | ||
138 | |||
139 | /* Add SDP4430 specific widgets */ | ||
140 | ret = snd_soc_dapm_new_controls(codec, sdp4430_twl6040_dapm_widgets, | ||
141 | ARRAY_SIZE(sdp4430_twl6040_dapm_widgets)); | ||
142 | if (ret) | ||
143 | return ret; | ||
144 | |||
145 | /* Set up SDP4430 specific audio path audio_map */ | ||
146 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | ||
147 | |||
148 | /* SDP4430 connected pins */ | ||
149 | snd_soc_dapm_enable_pin(codec, "Ext Mic"); | ||
150 | snd_soc_dapm_enable_pin(codec, "Ext Spk"); | ||
151 | snd_soc_dapm_enable_pin(codec, "Headset Mic"); | ||
152 | snd_soc_dapm_enable_pin(codec, "Headset Stereophone"); | ||
153 | |||
154 | /* TWL6040 not connected pins */ | ||
155 | snd_soc_dapm_nc_pin(codec, "AFML"); | ||
156 | snd_soc_dapm_nc_pin(codec, "AFMR"); | ||
157 | |||
158 | ret = snd_soc_dapm_sync(codec); | ||
159 | |||
160 | return ret; | ||
161 | } | ||
162 | |||
163 | /* Digital audio interface glue - connects codec <--> CPU */ | ||
164 | static struct snd_soc_dai_link sdp4430_dai = { | ||
165 | .name = "TWL6040", | ||
166 | .stream_name = "TWL6040", | ||
167 | .cpu_dai = &omap_mcpdm_dai, | ||
168 | .codec_dai = &twl6040_dai, | ||
169 | .init = sdp4430_twl6040_init, | ||
170 | .ops = &sdp4430_ops, | ||
171 | }; | ||
172 | |||
173 | /* Audio machine driver */ | ||
174 | static struct snd_soc_card snd_soc_sdp4430 = { | ||
175 | .name = "SDP4430", | ||
176 | .platform = &omap_soc_platform, | ||
177 | .dai_link = &sdp4430_dai, | ||
178 | .num_links = 1, | ||
179 | }; | ||
180 | |||
181 | /* Audio subsystem */ | ||
182 | static struct snd_soc_device sdp4430_snd_devdata = { | ||
183 | .card = &snd_soc_sdp4430, | ||
184 | .codec_dev = &soc_codec_dev_twl6040, | ||
185 | }; | ||
186 | |||
187 | static struct platform_device *sdp4430_snd_device; | ||
188 | |||
189 | static int __init sdp4430_soc_init(void) | ||
190 | { | ||
191 | int ret; | ||
192 | |||
193 | if (!machine_is_omap_4430sdp()) { | ||
194 | pr_debug("Not SDP4430!\n"); | ||
195 | return -ENODEV; | ||
196 | } | ||
197 | printk(KERN_INFO "SDP4430 SoC init\n"); | ||
198 | |||
199 | sdp4430_snd_device = platform_device_alloc("soc-audio", -1); | ||
200 | if (!sdp4430_snd_device) { | ||
201 | printk(KERN_ERR "Platform device allocation failed\n"); | ||
202 | return -ENOMEM; | ||
203 | } | ||
204 | |||
205 | platform_set_drvdata(sdp4430_snd_device, &sdp4430_snd_devdata); | ||
206 | sdp4430_snd_devdata.dev = &sdp4430_snd_device->dev; | ||
207 | |||
208 | ret = platform_device_add(sdp4430_snd_device); | ||
209 | if (ret) | ||
210 | goto err; | ||
211 | |||
212 | /* Codec starts in HP mode */ | ||
213 | twl6040_power_mode = 1; | ||
214 | |||
215 | return 0; | ||
216 | |||
217 | err: | ||
218 | printk(KERN_ERR "Unable to add platform device\n"); | ||
219 | platform_device_put(sdp4430_snd_device); | ||
220 | return ret; | ||
221 | } | ||
222 | module_init(sdp4430_soc_init); | ||
223 | |||
224 | static void __exit sdp4430_soc_exit(void) | ||
225 | { | ||
226 | platform_device_unregister(sdp4430_snd_device); | ||
227 | } | ||
228 | module_exit(sdp4430_soc_exit); | ||
229 | |||
230 | MODULE_AUTHOR("Misael Lopez Cruz <x0052729@ti.com>"); | ||
231 | MODULE_DESCRIPTION("ALSA SoC SDP4430"); | ||
232 | MODULE_LICENSE("GPL"); | ||
233 | |||