diff options
author | Jarkko Nikula <jhnikula@gmail.com> | 2011-01-27 09:47:11 -0500 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2011-01-27 15:48:46 -0500 |
commit | 48529b3b7ca76e688146e13d1a1666fe69703f0c (patch) | |
tree | 226c9a718a4bd47b309eaeae4f3aaece8359036a /sound/soc | |
parent | 64ed98365062b748770b340fd27ae34564a5a322 (diff) |
ASoC: omap: rx51: Add stereo output support to audio jack
Audio jack in Nokia RX-51/N900 is driven by TPA6130 headphone amplifier.
This patch adds support for it and stereo output can be active when
"Jack Function" == "TV-OUT" || "Headphone".
As the TPA6130 can output very high volume levels the output is limited
with snd_soc_limit_volume. Limiting value is found from Maemo kernel sources.
Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Cc: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/omap/Kconfig | 1 | ||||
-rw-r--r-- | sound/soc/omap/rx51.c | 43 |
2 files changed, 40 insertions, 4 deletions
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index a088db6d5091..b5922984eac6 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 09fb0df8d416..251afbe303c6 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,11 +239,14 @@ 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), | ||
215 | }; | 243 | }; |
216 | 244 | ||
217 | static const struct snd_soc_dapm_route audio_map[] = { | 245 | static const struct snd_soc_dapm_route audio_map[] = { |
218 | {"Ext Spk", NULL, "HPLOUT"}, | 246 | {"Ext Spk", NULL, "HPLOUT"}, |
219 | {"Ext Spk", NULL, "HPROUT"}, | 247 | {"Ext Spk", NULL, "HPROUT"}, |
248 | {"Headphone Jack", NULL, "LLOUT"}, | ||
249 | {"Headphone Jack", NULL, "RLOUT"}, | ||
220 | 250 | ||
221 | {"DMic Rate 64", NULL, "Mic Bias 2V"}, | 251 | {"DMic Rate 64", NULL, "Mic Bias 2V"}, |
222 | {"Mic Bias 2V", NULL, "DMic"}, | 252 | {"Mic Bias 2V", NULL, "DMic"}, |
@@ -224,7 +254,7 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
224 | 254 | ||
225 | static const char *spk_function[] = {"Off", "On"}; | 255 | static const char *spk_function[] = {"Off", "On"}; |
226 | static const char *input_function[] = {"ADC", "Digital Mic"}; | 256 | static const char *input_function[] = {"ADC", "Digital Mic"}; |
227 | static const char *jack_function[] = {"Off", "TV-OUT"}; | 257 | static const char *jack_function[] = {"Off", "TV-OUT", "Headphone"}; |
228 | 258 | ||
229 | static const struct soc_enum rx51_enum[] = { | 259 | static const struct soc_enum rx51_enum[] = { |
230 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), | 260 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), |
@@ -265,6 +295,11 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) | |||
265 | /* Set up RX-51 specific audio path audio_map */ | 295 | /* Set up RX-51 specific audio path audio_map */ |
266 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); | 296 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); |
267 | 297 | ||
298 | err = tpa6130a2_add_controls(codec); | ||
299 | if (err < 0) | ||
300 | return err; | ||
301 | snd_soc_limit_volume(codec, "TPA6130A2 Headphone Playback Volume", 42); | ||
302 | |||
268 | snd_soc_dapm_sync(dapm); | 303 | snd_soc_dapm_sync(dapm); |
269 | 304 | ||
270 | /* AV jack detection */ | 305 | /* AV jack detection */ |