Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: sound/soc/samsung/goni_wm8994.c

Issue 6577007: CHROMIUM: ASoC: Import entire upstream ASoC tree (Closed)
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sound/soc/samsung/dma.c ('k') | sound/soc/samsung/h1940_uda1380.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * goni_wm8994.c 2 * goni_wm8994.c
3 * 3 *
4 * Copyright (C) 2010 Samsung Electronics Co.Ltd 4 * Copyright (C) 2010 Samsung Electronics Co.Ltd
5 * Author: Chanwoo Choi <cw00.choi@samsung.com> 5 * Author: Chanwoo Choi <cw00.choi@samsung.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the 8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your 9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. 10 * option) any later version.
11 * 11 *
12 */ 12 */
13 13
14 #include <linux/module.h>
15 #include <linux/moduleparam.h>
16 #include <linux/io.h>
17 #include <linux/platform_device.h>
18 #include <sound/soc.h> 14 #include <sound/soc.h>
19 #include <sound/soc-dapm.h>
20 #include <sound/jack.h> 15 #include <sound/jack.h>
16
21 #include <asm/mach-types.h> 17 #include <asm/mach-types.h>
22 #include <mach/gpio.h> 18 #include <mach/gpio.h>
23 #include <mach/regs-clock.h>
24 19
25 #include <linux/mfd/wm8994/core.h>
26 #include <linux/mfd/wm8994/registers.h>
27 #include "../codecs/wm8994.h" 20 #include "../codecs/wm8994.h"
28 #include "s3c-dma.h" 21
29 #include "s3c64xx-i2s.h" 22 #define MACHINE_NAME» 0
23 #define CPU_VOICE_DAI» 1
24
25 static const char *aquila_str[] = {
26 » [MACHINE_NAME] = "aquila",
27 » [CPU_VOICE_DAI] = "aquila-voice-dai",
28 };
30 29
31 static struct snd_soc_card goni; 30 static struct snd_soc_card goni;
32 static struct platform_device *goni_snd_device; 31 static struct platform_device *goni_snd_device;
33 32
34 /* 3.5 pie jack */ 33 /* 3.5 pie jack */
35 static struct snd_soc_jack jack; 34 static struct snd_soc_jack jack;
36 35
37 /* 3.5 pie jack detection DAPM pins */ 36 /* 3.5 pie jack detection DAPM pins */
38 static struct snd_soc_jack_pin jack_pins[] = { 37 static struct snd_soc_jack_pin jack_pins[] = {
39 { 38 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 {"IN1LN", NULL, "Main Mic"}, 89 {"IN1LN", NULL, "Main Mic"},
91 {"IN1LP", NULL, "Main Mic"}, 90 {"IN1LP", NULL, "Main Mic"},
92 91
93 {"IN2LN", NULL, "Radio In"}, 92 {"IN2LN", NULL, "Radio In"},
94 {"IN2RN", NULL, "Radio In"}, 93 {"IN2RN", NULL, "Radio In"},
95 }; 94 };
96 95
97 static int goni_wm8994_init(struct snd_soc_pcm_runtime *rtd) 96 static int goni_wm8994_init(struct snd_soc_pcm_runtime *rtd)
98 { 97 {
99 struct snd_soc_codec *codec = rtd->codec; 98 struct snd_soc_codec *codec = rtd->codec;
99 struct snd_soc_dapm_context *dapm = &codec->dapm;
100 int ret; 100 int ret;
101 101
102 /* add goni specific widgets */ 102 /* add goni specific widgets */
103 » snd_soc_dapm_new_controls(codec, goni_dapm_widgets, 103 » snd_soc_dapm_new_controls(dapm, goni_dapm_widgets,
104 ARRAY_SIZE(goni_dapm_widgets)); 104 ARRAY_SIZE(goni_dapm_widgets));
105 105
106 /* set up goni specific audio routes */ 106 /* set up goni specific audio routes */
107 » snd_soc_dapm_add_routes(codec, goni_dapm_routes, 107 » snd_soc_dapm_add_routes(dapm, goni_dapm_routes,
108 ARRAY_SIZE(goni_dapm_routes)); 108 ARRAY_SIZE(goni_dapm_routes));
109 109
110 /* set endpoints to not connected */ 110 /* set endpoints to not connected */
111 » snd_soc_dapm_nc_pin(codec, "IN2LP:VXRN"); 111 » snd_soc_dapm_nc_pin(dapm, "IN2LP:VXRN");
112 » snd_soc_dapm_nc_pin(codec, "IN2RP:VXRP"); 112 » snd_soc_dapm_nc_pin(dapm, "IN2RP:VXRP");
113 » snd_soc_dapm_nc_pin(codec, "LINEOUT1N"); 113 » snd_soc_dapm_nc_pin(dapm, "LINEOUT1N");
114 » snd_soc_dapm_nc_pin(codec, "LINEOUT1P"); 114 » snd_soc_dapm_nc_pin(dapm, "LINEOUT1P");
115 » snd_soc_dapm_nc_pin(codec, "LINEOUT2N"); 115 » snd_soc_dapm_nc_pin(dapm, "LINEOUT2N");
116 » snd_soc_dapm_nc_pin(codec, "LINEOUT2P"); 116 » snd_soc_dapm_nc_pin(dapm, "LINEOUT2P");
117 117
118 » snd_soc_dapm_sync(codec); 118 » if (machine_is_aquila()) {
119 » » snd_soc_dapm_nc_pin(dapm, "SPKOUTRN");
120 » » snd_soc_dapm_nc_pin(dapm, "SPKOUTRP");
121 » }
122
123 » snd_soc_dapm_sync(dapm);
119 124
120 /* Headset jack detection */ 125 /* Headset jack detection */
121 » ret = snd_soc_jack_new(&goni, "Headset Jack", 126 » ret = snd_soc_jack_new(codec, "Headset Jack",
122 SND_JACK_HEADSET | SND_JACK_MECHANICAL | SND_JACK_AVOUT, 127 SND_JACK_HEADSET | SND_JACK_MECHANICAL | SND_JACK_AVOUT,
123 &jack); 128 &jack);
124 if (ret) 129 if (ret)
125 return ret; 130 return ret;
126 131
127 ret = snd_soc_jack_add_pins(&jack, ARRAY_SIZE(jack_pins), jack_pins); 132 ret = snd_soc_jack_add_pins(&jack, ARRAY_SIZE(jack_pins), jack_pins);
128 if (ret) 133 if (ret)
129 return ret; 134 return ret;
130 135
131 ret = snd_soc_jack_add_gpios(&jack, ARRAY_SIZE(jack_gpios), jack_gpios); 136 ret = snd_soc_jack_add_gpios(&jack, ARRAY_SIZE(jack_gpios), jack_gpios);
(...skipping 11 matching lines...) Expand all
143 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 148 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
144 unsigned int pll_out = 24000000; 149 unsigned int pll_out = 24000000;
145 int ret = 0; 150 int ret = 0;
146 151
147 /* set the cpu DAI configuration */ 152 /* set the cpu DAI configuration */
148 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | 153 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
149 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); 154 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
150 if (ret < 0) 155 if (ret < 0)
151 return ret; 156 return ret;
152 157
153 /* set the cpu system clock */
154 ret = snd_soc_dai_set_sysclk(cpu_dai, S3C64XX_CLKSRC_PCLK,
155 0, SND_SOC_CLOCK_IN);
156 if (ret < 0)
157 return ret;
158
159 /* set codec DAI configuration */ 158 /* set codec DAI configuration */
160 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | 159 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
161 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); 160 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
162 if (ret < 0) 161 if (ret < 0)
163 return ret; 162 return ret;
164 163
165 /* set the codec FLL */ 164 /* set the codec FLL */
166 ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL1, 0, pll_out, 165 ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL1, 0, pll_out,
167 params_rate(params) * 256); 166 params_rate(params) * 256);
168 if (ret < 0) 167 if (ret < 0)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 }; 228 };
230 229
231 static struct snd_soc_ops goni_voice_ops = { 230 static struct snd_soc_ops goni_voice_ops = {
232 .hw_params = goni_voice_hw_params, 231 .hw_params = goni_voice_hw_params,
233 }; 232 };
234 233
235 static struct snd_soc_dai_link goni_dai[] = { 234 static struct snd_soc_dai_link goni_dai[] = {
236 { 235 {
237 .name = "WM8994", 236 .name = "WM8994",
238 .stream_name = "WM8994 HiFi", 237 .stream_name = "WM8994 HiFi",
239 » .cpu_dai_name = "s3c64xx-i2s-v4", 238 » .cpu_dai_name = "samsung-i2s.0",
240 .codec_dai_name = "wm8994-hifi", 239 .codec_dai_name = "wm8994-hifi",
241 » .platform_name = "s3c24xx-pcm-audio", 240 » .platform_name = "samsung-audio",
242 .codec_name = "wm8994-codec.0-0x1a", 241 .codec_name = "wm8994-codec.0-0x1a",
243 .init = goni_wm8994_init, 242 .init = goni_wm8994_init,
244 .ops = &goni_hifi_ops, 243 .ops = &goni_hifi_ops,
245 }, { 244 }, {
246 .name = "WM8994 Voice", 245 .name = "WM8994 Voice",
247 .stream_name = "Voice", 246 .stream_name = "Voice",
248 .cpu_dai_name = "goni-voice-dai", 247 .cpu_dai_name = "goni-voice-dai",
249 .codec_dai_name = "wm8994-voice", 248 .codec_dai_name = "wm8994-voice",
250 » .platform_name = "s3c24xx-pcm-audio", 249 » .platform_name = "samsung-audio",
251 .codec_name = "wm8994-codec.0-0x1a", 250 .codec_name = "wm8994-codec.0-0x1a",
252 .ops = &goni_voice_ops, 251 .ops = &goni_voice_ops,
253 }, 252 },
254 }; 253 };
255 254
256 static struct snd_soc_card goni = { 255 static struct snd_soc_card goni = {
257 .name = "goni", 256 .name = "goni",
258 .dai_link = goni_dai, 257 .dai_link = goni_dai,
259 .num_links = ARRAY_SIZE(goni_dai), 258 .num_links = ARRAY_SIZE(goni_dai),
260 }; 259 };
261 260
262 static int __init goni_init(void) 261 static int __init goni_init(void)
263 { 262 {
264 int ret; 263 int ret;
265 264
266 » if (!machine_is_goni()) 265 » if (machine_is_aquila()) {
266 » » voice_dai.name = aquila_str[CPU_VOICE_DAI];
267 » » goni_dai[1].cpu_dai_name = aquila_str[CPU_VOICE_DAI];
268 » » goni.name = aquila_str[MACHINE_NAME];
269 » } else if (!machine_is_goni())
267 return -ENODEV; 270 return -ENODEV;
268 271
269 goni_snd_device = platform_device_alloc("soc-audio", -1); 272 goni_snd_device = platform_device_alloc("soc-audio", -1);
270 if (!goni_snd_device) 273 if (!goni_snd_device)
271 return -ENOMEM; 274 return -ENOMEM;
272 275
273 /* register voice DAI here */ 276 /* register voice DAI here */
274 ret = snd_soc_register_dai(&goni_snd_device->dev, &voice_dai); 277 ret = snd_soc_register_dai(&goni_snd_device->dev, &voice_dai);
275 » if (ret) 278 » if (ret) {
279 » » platform_device_put(goni_snd_device);
276 return ret; 280 return ret;
281 }
277 282
278 platform_set_drvdata(goni_snd_device, &goni); 283 platform_set_drvdata(goni_snd_device, &goni);
279 ret = platform_device_add(goni_snd_device); 284 ret = platform_device_add(goni_snd_device);
280 285
281 » if (ret) 286 » if (ret) {
287 » » snd_soc_unregister_dai(&goni_snd_device->dev);
282 platform_device_put(goni_snd_device); 288 platform_device_put(goni_snd_device);
289 }
283 290
284 return ret; 291 return ret;
285 } 292 }
286 293
287 static void __exit goni_exit(void) 294 static void __exit goni_exit(void)
288 { 295 {
296 snd_soc_unregister_dai(&goni_snd_device->dev);
289 platform_device_unregister(goni_snd_device); 297 platform_device_unregister(goni_snd_device);
290 } 298 }
291 299
292 module_init(goni_init); 300 module_init(goni_init);
293 module_exit(goni_exit); 301 module_exit(goni_exit);
294 302
295 /* Module information */ 303 /* Module information */
296 MODULE_DESCRIPTION("ALSA SoC WM8994 GONI(S5PV210)"); 304 MODULE_DESCRIPTION("ALSA SoC WM8994 GONI(S5PV210)");
297 MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>"); 305 MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>");
298 MODULE_LICENSE("GPL"); 306 MODULE_LICENSE("GPL");
OLDNEW
« no previous file with comments | « sound/soc/samsung/dma.c ('k') | sound/soc/samsung/h1940_uda1380.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698