diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-02-01 09:55:10 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-02-01 09:55:10 -0500 |
commit | 273de37655369e57919f19e157fafb2b4b1e4472 (patch) | |
tree | b1cb751fc91b4a2400577f4137b7bb2a06fb0c53 /sound/soc/omap | |
parent | 3d8b2ce01b2de7c3c5cbf18b9b97d26cfaf11c14 (diff) | |
parent | 8cda975174945e3b7119d48341052d0dc0c87cf2 (diff) |
Merge branch 'for-2.6.39' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/asoc-2.6 into for-2.6.39
Diffstat (limited to 'sound/soc/omap')
-rw-r--r-- | sound/soc/omap/Kconfig | 1 | ||||
-rw-r--r-- | sound/soc/omap/rx51.c | 93 |
2 files changed, 90 insertions, 4 deletions
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index a088db6d509..b5922984eac 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig | |||
@@ -24,6 +24,7 @@ config SND_OMAP_SOC_RX51 | |||
24 | select OMAP_MCBSP | 24 | select OMAP_MCBSP |
25 | select SND_OMAP_SOC_MCBSP | 25 | select SND_OMAP_SOC_MCBSP |
26 | select SND_SOC_TLV320AIC3X | 26 | select SND_SOC_TLV320AIC3X |
27 | select SND_SOC_TPA6130A2 | ||
27 | help | 28 | help |
28 | Say Y if you want to add support for SoC audio on Nokia RX-51 | 29 | Say Y if you want to add support for SoC audio on Nokia RX-51 |
29 | hardware. This is also known as Nokia N900 product. | 30 | hardware. This is also known as Nokia N900 product. |
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 09fb0df8d41..2d7d4115cb7 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <sound/pcm.h> | 31 | #include <sound/pcm.h> |
32 | #include <sound/soc.h> | 32 | #include <sound/soc.h> |
33 | #include <plat/mcbsp.h> | 33 | #include <plat/mcbsp.h> |
34 | #include "../codecs/tpa6130a2.h" | ||
34 | 35 | ||
35 | #include <asm/mach-types.h> | 36 | #include <asm/mach-types.h> |
36 | 37 | ||
@@ -47,7 +48,8 @@ | |||
47 | 48 | ||
48 | enum { | 49 | enum { |
49 | RX51_JACK_DISABLED, | 50 | RX51_JACK_DISABLED, |
50 | RX51_JACK_TVOUT, /* tv-out */ | 51 | RX51_JACK_TVOUT, /* tv-out with stereo output */ |
52 | RX51_JACK_HP, /* headphone: stereo output, no mic */ | ||
51 | }; | 53 | }; |
52 | 54 | ||
53 | static int rx51_spk_func; | 55 | static int rx51_spk_func; |
@@ -57,6 +59,15 @@ static int rx51_jack_func; | |||
57 | static void rx51_ext_control(struct snd_soc_codec *codec) | 59 | static void rx51_ext_control(struct snd_soc_codec *codec) |
58 | { | 60 | { |
59 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 61 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
62 | int hp = 0, tvout = 0; | ||
63 | |||
64 | switch (rx51_jack_func) { | ||
65 | case RX51_JACK_TVOUT: | ||
66 | tvout = 1; | ||
67 | case RX51_JACK_HP: | ||
68 | hp = 1; | ||
69 | break; | ||
70 | } | ||
60 | 71 | ||
61 | if (rx51_spk_func) | 72 | if (rx51_spk_func) |
62 | snd_soc_dapm_enable_pin(dapm, "Ext Spk"); | 73 | snd_soc_dapm_enable_pin(dapm, "Ext Spk"); |
@@ -66,9 +77,12 @@ static void rx51_ext_control(struct snd_soc_codec *codec) | |||
66 | snd_soc_dapm_enable_pin(dapm, "DMic"); | 77 | snd_soc_dapm_enable_pin(dapm, "DMic"); |
67 | else | 78 | else |
68 | snd_soc_dapm_disable_pin(dapm, "DMic"); | 79 | snd_soc_dapm_disable_pin(dapm, "DMic"); |
80 | if (hp) | ||
81 | snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); | ||
82 | else | ||
83 | snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); | ||
69 | 84 | ||
70 | gpio_set_value(RX51_TVOUT_SEL_GPIO, | 85 | gpio_set_value(RX51_TVOUT_SEL_GPIO, tvout); |
71 | rx51_jack_func == RX51_JACK_TVOUT); | ||
72 | 86 | ||
73 | snd_soc_dapm_sync(dapm); | 87 | snd_soc_dapm_sync(dapm); |
74 | } | 88 | } |
@@ -153,6 +167,19 @@ static int rx51_spk_event(struct snd_soc_dapm_widget *w, | |||
153 | return 0; | 167 | return 0; |
154 | } | 168 | } |
155 | 169 | ||
170 | static int rx51_hp_event(struct snd_soc_dapm_widget *w, | ||
171 | struct snd_kcontrol *k, int event) | ||
172 | { | ||
173 | struct snd_soc_codec *codec = w->dapm->codec; | ||
174 | |||
175 | if (SND_SOC_DAPM_EVENT_ON(event)) | ||
176 | tpa6130a2_stereo_enable(codec, 1); | ||
177 | else | ||
178 | tpa6130a2_stereo_enable(codec, 0); | ||
179 | |||
180 | return 0; | ||
181 | } | ||
182 | |||
156 | static int rx51_get_input(struct snd_kcontrol *kcontrol, | 183 | static int rx51_get_input(struct snd_kcontrol *kcontrol, |
157 | struct snd_ctl_elem_value *ucontrol) | 184 | struct snd_ctl_elem_value *ucontrol) |
158 | { | 185 | { |
@@ -212,19 +239,31 @@ static struct snd_soc_jack_gpio rx51_av_jack_gpios[] = { | |||
212 | static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = { | 239 | static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = { |
213 | SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event), | 240 | SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event), |
214 | SND_SOC_DAPM_MIC("DMic", NULL), | 241 | SND_SOC_DAPM_MIC("DMic", NULL), |
242 | SND_SOC_DAPM_HP("Headphone Jack", rx51_hp_event), | ||
243 | }; | ||
244 | |||
245 | static const struct snd_soc_dapm_widget aic34_dapm_widgetsb[] = { | ||
246 | SND_SOC_DAPM_SPK("Earphone", NULL), | ||
215 | }; | 247 | }; |
216 | 248 | ||
217 | static const struct snd_soc_dapm_route audio_map[] = { | 249 | static const struct snd_soc_dapm_route audio_map[] = { |
218 | {"Ext Spk", NULL, "HPLOUT"}, | 250 | {"Ext Spk", NULL, "HPLOUT"}, |
219 | {"Ext Spk", NULL, "HPROUT"}, | 251 | {"Ext Spk", NULL, "HPROUT"}, |
252 | {"Headphone Jack", NULL, "LLOUT"}, | ||
253 | {"Headphone Jack", NULL, "RLOUT"}, | ||
220 | 254 | ||
221 | {"DMic Rate 64", NULL, "Mic Bias 2V"}, | 255 | {"DMic Rate 64", NULL, "Mic Bias 2V"}, |
222 | {"Mic Bias 2V", NULL, "DMic"}, | 256 | {"Mic Bias 2V", NULL, "DMic"}, |
223 | }; | 257 | }; |
224 | 258 | ||
259 | static const struct snd_soc_dapm_route audio_mapb[] = { | ||
260 | {"b LINE2R", NULL, "MONO_LOUT"}, | ||
261 | {"Earphone", NULL, "b HPLOUT"}, | ||
262 | }; | ||
263 | |||
225 | static const char *spk_function[] = {"Off", "On"}; | 264 | static const char *spk_function[] = {"Off", "On"}; |
226 | static const char *input_function[] = {"ADC", "Digital Mic"}; | 265 | static const char *input_function[] = {"ADC", "Digital Mic"}; |
227 | static const char *jack_function[] = {"Off", "TV-OUT"}; | 266 | static const char *jack_function[] = {"Off", "TV-OUT", "Headphone"}; |
228 | 267 | ||
229 | static const struct soc_enum rx51_enum[] = { | 268 | static const struct soc_enum rx51_enum[] = { |
230 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), | 269 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), |
@@ -241,6 +280,10 @@ static const struct snd_kcontrol_new aic34_rx51_controls[] = { | |||
241 | rx51_get_jack, rx51_set_jack), | 280 | rx51_get_jack, rx51_set_jack), |
242 | }; | 281 | }; |
243 | 282 | ||
283 | static const struct snd_kcontrol_new aic34_rx51_controlsb[] = { | ||
284 | SOC_DAPM_PIN_SWITCH("Earphone"), | ||
285 | }; | ||
286 | |||
244 | static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) | 287 | static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) |
245 | { | 288 | { |
246 | struct snd_soc_codec *codec = rtd->codec; | 289 | struct snd_soc_codec *codec = rtd->codec; |
@@ -265,6 +308,11 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) | |||
265 | /* Set up RX-51 specific audio path audio_map */ | 308 | /* Set up RX-51 specific audio path audio_map */ |
266 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); | 309 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); |
267 | 310 | ||
311 | err = tpa6130a2_add_controls(codec); | ||
312 | if (err < 0) | ||
313 | return err; | ||
314 | snd_soc_limit_volume(codec, "TPA6130A2 Headphone Playback Volume", 42); | ||
315 | |||
268 | snd_soc_dapm_sync(dapm); | 316 | snd_soc_dapm_sync(dapm); |
269 | 317 | ||
270 | /* AV jack detection */ | 318 | /* AV jack detection */ |
@@ -279,6 +327,24 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) | |||
279 | return err; | 327 | return err; |
280 | } | 328 | } |
281 | 329 | ||
330 | static int rx51_aic34b_init(struct snd_soc_dapm_context *dapm) | ||
331 | { | ||
332 | int err; | ||
333 | |||
334 | err = snd_soc_add_controls(dapm->codec, aic34_rx51_controlsb, | ||
335 | ARRAY_SIZE(aic34_rx51_controlsb)); | ||
336 | if (err < 0) | ||
337 | return err; | ||
338 | |||
339 | err = snd_soc_dapm_new_controls(dapm, aic34_dapm_widgetsb, | ||
340 | ARRAY_SIZE(aic34_dapm_widgetsb)); | ||
341 | if (err < 0) | ||
342 | return 0; | ||
343 | |||
344 | return snd_soc_dapm_add_routes(dapm, audio_mapb, | ||
345 | ARRAY_SIZE(audio_mapb)); | ||
346 | } | ||
347 | |||
282 | /* Digital audio interface glue - connects codec <--> CPU */ | 348 | /* Digital audio interface glue - connects codec <--> CPU */ |
283 | static struct snd_soc_dai_link rx51_dai[] = { | 349 | static struct snd_soc_dai_link rx51_dai[] = { |
284 | { | 350 | { |
@@ -293,11 +359,30 @@ static struct snd_soc_dai_link rx51_dai[] = { | |||
293 | }, | 359 | }, |
294 | }; | 360 | }; |
295 | 361 | ||
362 | struct snd_soc_aux_dev rx51_aux_dev[] = { | ||
363 | { | ||
364 | .name = "TLV320AIC34b", | ||
365 | .codec_name = "tlv320aic3x-codec.2-0019", | ||
366 | .init = rx51_aic34b_init, | ||
367 | }, | ||
368 | }; | ||
369 | |||
370 | static struct snd_soc_codec_conf rx51_codec_conf[] = { | ||
371 | { | ||
372 | .dev_name = "tlv320aic3x-codec.2-0019", | ||
373 | .name_prefix = "b", | ||
374 | }, | ||
375 | }; | ||
376 | |||
296 | /* Audio card */ | 377 | /* Audio card */ |
297 | static struct snd_soc_card rx51_sound_card = { | 378 | static struct snd_soc_card rx51_sound_card = { |
298 | .name = "RX-51", | 379 | .name = "RX-51", |
299 | .dai_link = rx51_dai, | 380 | .dai_link = rx51_dai, |
300 | .num_links = ARRAY_SIZE(rx51_dai), | 381 | .num_links = ARRAY_SIZE(rx51_dai), |
382 | .aux_dev = rx51_aux_dev, | ||
383 | .num_aux_devs = ARRAY_SIZE(rx51_aux_dev), | ||
384 | .codec_conf = rx51_codec_conf, | ||
385 | .num_configs = ARRAY_SIZE(rx51_codec_conf), | ||
301 | }; | 386 | }; |
302 | 387 | ||
303 | static struct platform_device *rx51_snd_device; | 388 | static struct platform_device *rx51_snd_device; |