diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-06-30 09:46:53 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-06-30 09:46:53 -0400 |
commit | af51b5c0f06d449667eba226d96c8f56e2b96659 (patch) | |
tree | c0b6b398ae5acb694690f759e3a6e73673165d5c /sound | |
parent | 9c1be7e8cb1e33d4d7d4bed40466ee358fdf5a34 (diff) | |
parent | e827e32efc313e1a061c81007e96fff439ccb802 (diff) |
Merge remote branch 'takashi/topic/asoc' into for-2.6.36
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/tlv320aic23.c | 7 | ||||
-rw-r--r-- | sound/soc/omap/omap3pandora.c | 36 | ||||
-rw-r--r-- | sound/soc/omap/rx51.c | 73 |
3 files changed, 84 insertions, 32 deletions
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index b0bae3508b2..0a4b0fef335 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c | |||
@@ -560,13 +560,16 @@ static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec, | |||
560 | switch (level) { | 560 | switch (level) { |
561 | case SND_SOC_BIAS_ON: | 561 | case SND_SOC_BIAS_ON: |
562 | /* vref/mid, osc on, dac unmute */ | 562 | /* vref/mid, osc on, dac unmute */ |
563 | reg &= ~(TLV320AIC23_DEVICE_PWR_OFF | TLV320AIC23_OSC_OFF | \ | ||
564 | TLV320AIC23_DAC_OFF); | ||
563 | tlv320aic23_write(codec, TLV320AIC23_PWR, reg); | 565 | tlv320aic23_write(codec, TLV320AIC23_PWR, reg); |
564 | break; | 566 | break; |
565 | case SND_SOC_BIAS_PREPARE: | 567 | case SND_SOC_BIAS_PREPARE: |
566 | break; | 568 | break; |
567 | case SND_SOC_BIAS_STANDBY: | 569 | case SND_SOC_BIAS_STANDBY: |
568 | /* everything off except vref/vmid, */ | 570 | /* everything off except vref/vmid, */ |
569 | tlv320aic23_write(codec, TLV320AIC23_PWR, reg | 0x0040); | 571 | tlv320aic23_write(codec, TLV320AIC23_PWR, reg | \ |
572 | TLV320AIC23_CLK_OFF); | ||
570 | break; | 573 | break; |
571 | case SND_SOC_BIAS_OFF: | 574 | case SND_SOC_BIAS_OFF: |
572 | /* everything off, dac mute, inactive */ | 575 | /* everything off, dac mute, inactive */ |
@@ -615,7 +618,6 @@ static int tlv320aic23_suspend(struct platform_device *pdev, | |||
615 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 618 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
616 | struct snd_soc_codec *codec = socdev->card->codec; | 619 | struct snd_soc_codec *codec = socdev->card->codec; |
617 | 620 | ||
618 | tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x0); | ||
619 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_OFF); | 621 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_OFF); |
620 | 622 | ||
621 | return 0; | 623 | return 0; |
@@ -632,7 +634,6 @@ static int tlv320aic23_resume(struct platform_device *pdev) | |||
632 | u16 val = tlv320aic23_read_reg_cache(codec, reg); | 634 | u16 val = tlv320aic23_read_reg_cache(codec, reg); |
633 | tlv320aic23_write(codec, reg, val); | 635 | tlv320aic23_write(codec, reg, val); |
634 | } | 636 | } |
635 | |||
636 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 637 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
637 | 638 | ||
638 | return 0; | 639 | return 0; |
diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index 87ce842fa2e..9eecac135bb 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c | |||
@@ -43,12 +43,14 @@ | |||
43 | 43 | ||
44 | static struct regulator *omap3pandora_dac_reg; | 44 | static struct regulator *omap3pandora_dac_reg; |
45 | 45 | ||
46 | static int omap3pandora_cmn_hw_params(struct snd_pcm_substream *substream, | 46 | static int omap3pandora_hw_params(struct snd_pcm_substream *substream, |
47 | struct snd_pcm_hw_params *params, unsigned int fmt) | 47 | struct snd_pcm_hw_params *params) |
48 | { | 48 | { |
49 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 49 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
50 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | 50 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; |
51 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | 51 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; |
52 | int fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | ||
53 | SND_SOC_DAIFMT_CBS_CFS; | ||
52 | int ret; | 54 | int ret; |
53 | 55 | ||
54 | /* Set codec DAI configuration */ | 56 | /* Set codec DAI configuration */ |
@@ -91,24 +93,6 @@ static int omap3pandora_cmn_hw_params(struct snd_pcm_substream *substream, | |||
91 | return 0; | 93 | return 0; |
92 | } | 94 | } |
93 | 95 | ||
94 | static int omap3pandora_out_hw_params(struct snd_pcm_substream *substream, | ||
95 | struct snd_pcm_hw_params *params) | ||
96 | { | ||
97 | return omap3pandora_cmn_hw_params(substream, params, | ||
98 | SND_SOC_DAIFMT_I2S | | ||
99 | SND_SOC_DAIFMT_IB_NF | | ||
100 | SND_SOC_DAIFMT_CBS_CFS); | ||
101 | } | ||
102 | |||
103 | static int omap3pandora_in_hw_params(struct snd_pcm_substream *substream, | ||
104 | struct snd_pcm_hw_params *params) | ||
105 | { | ||
106 | return omap3pandora_cmn_hw_params(substream, params, | ||
107 | SND_SOC_DAIFMT_I2S | | ||
108 | SND_SOC_DAIFMT_NB_NF | | ||
109 | SND_SOC_DAIFMT_CBS_CFS); | ||
110 | } | ||
111 | |||
112 | static int omap3pandora_dac_event(struct snd_soc_dapm_widget *w, | 96 | static int omap3pandora_dac_event(struct snd_soc_dapm_widget *w, |
113 | struct snd_kcontrol *k, int event) | 97 | struct snd_kcontrol *k, int event) |
114 | { | 98 | { |
@@ -231,12 +215,8 @@ static int omap3pandora_in_init(struct snd_soc_codec *codec) | |||
231 | return snd_soc_dapm_sync(codec); | 215 | return snd_soc_dapm_sync(codec); |
232 | } | 216 | } |
233 | 217 | ||
234 | static struct snd_soc_ops omap3pandora_out_ops = { | 218 | static struct snd_soc_ops omap3pandora_ops = { |
235 | .hw_params = omap3pandora_out_hw_params, | 219 | .hw_params = omap3pandora_hw_params, |
236 | }; | ||
237 | |||
238 | static struct snd_soc_ops omap3pandora_in_ops = { | ||
239 | .hw_params = omap3pandora_in_hw_params, | ||
240 | }; | 220 | }; |
241 | 221 | ||
242 | /* Digital audio interface glue - connects codec <--> CPU */ | 222 | /* Digital audio interface glue - connects codec <--> CPU */ |
@@ -246,14 +226,14 @@ static struct snd_soc_dai_link omap3pandora_dai[] = { | |||
246 | .stream_name = "HiFi Out", | 226 | .stream_name = "HiFi Out", |
247 | .cpu_dai = &omap_mcbsp_dai[0], | 227 | .cpu_dai = &omap_mcbsp_dai[0], |
248 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], | 228 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], |
249 | .ops = &omap3pandora_out_ops, | 229 | .ops = &omap3pandora_ops, |
250 | .init = omap3pandora_out_init, | 230 | .init = omap3pandora_out_init, |
251 | }, { | 231 | }, { |
252 | .name = "TWL4030", | 232 | .name = "TWL4030", |
253 | .stream_name = "Line/Mic In", | 233 | .stream_name = "Line/Mic In", |
254 | .cpu_dai = &omap_mcbsp_dai[1], | 234 | .cpu_dai = &omap_mcbsp_dai[1], |
255 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], | 235 | .codec_dai = &twl4030_dai[TWL4030_DAI_HIFI], |
256 | .ops = &omap3pandora_in_ops, | 236 | .ops = &omap3pandora_ops, |
257 | .init = omap3pandora_in_init, | 237 | .init = omap3pandora_in_init, |
258 | } | 238 | } |
259 | }; | 239 | }; |
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 47d831ef2db..88052d29617 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/gpio.h> | 27 | #include <linux/gpio.h> |
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <sound/core.h> | 29 | #include <sound/core.h> |
30 | #include <sound/jack.h> | ||
30 | #include <sound/pcm.h> | 31 | #include <sound/pcm.h> |
31 | #include <sound/soc.h> | 32 | #include <sound/soc.h> |
32 | #include <sound/soc-dapm.h> | 33 | #include <sound/soc-dapm.h> |
@@ -37,14 +38,22 @@ | |||
37 | #include "omap-pcm.h" | 38 | #include "omap-pcm.h" |
38 | #include "../codecs/tlv320aic3x.h" | 39 | #include "../codecs/tlv320aic3x.h" |
39 | 40 | ||
41 | #define RX51_TVOUT_SEL_GPIO 40 | ||
42 | #define RX51_JACK_DETECT_GPIO 177 | ||
40 | /* | 43 | /* |
41 | * REVISIT: TWL4030 GPIO base in RX-51. Now statically defined to 192. This | 44 | * REVISIT: TWL4030 GPIO base in RX-51. Now statically defined to 192. This |
42 | * gpio is reserved in arch/arm/mach-omap2/board-rx51-peripherals.c | 45 | * gpio is reserved in arch/arm/mach-omap2/board-rx51-peripherals.c |
43 | */ | 46 | */ |
44 | #define RX51_SPEAKER_AMP_TWL_GPIO (192 + 7) | 47 | #define RX51_SPEAKER_AMP_TWL_GPIO (192 + 7) |
45 | 48 | ||
49 | enum { | ||
50 | RX51_JACK_DISABLED, | ||
51 | RX51_JACK_TVOUT, /* tv-out */ | ||
52 | }; | ||
53 | |||
46 | static int rx51_spk_func; | 54 | static int rx51_spk_func; |
47 | static int rx51_dmic_func; | 55 | static int rx51_dmic_func; |
56 | static int rx51_jack_func; | ||
48 | 57 | ||
49 | static void rx51_ext_control(struct snd_soc_codec *codec) | 58 | static void rx51_ext_control(struct snd_soc_codec *codec) |
50 | { | 59 | { |
@@ -57,6 +66,9 @@ static void rx51_ext_control(struct snd_soc_codec *codec) | |||
57 | else | 66 | else |
58 | snd_soc_dapm_disable_pin(codec, "DMic"); | 67 | snd_soc_dapm_disable_pin(codec, "DMic"); |
59 | 68 | ||
69 | gpio_set_value(RX51_TVOUT_SEL_GPIO, | ||
70 | rx51_jack_func == RX51_JACK_TVOUT); | ||
71 | |||
60 | snd_soc_dapm_sync(codec); | 72 | snd_soc_dapm_sync(codec); |
61 | } | 73 | } |
62 | 74 | ||
@@ -162,6 +174,40 @@ static int rx51_set_input(struct snd_kcontrol *kcontrol, | |||
162 | return 1; | 174 | return 1; |
163 | } | 175 | } |
164 | 176 | ||
177 | static int rx51_get_jack(struct snd_kcontrol *kcontrol, | ||
178 | struct snd_ctl_elem_value *ucontrol) | ||
179 | { | ||
180 | ucontrol->value.integer.value[0] = rx51_jack_func; | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | static int rx51_set_jack(struct snd_kcontrol *kcontrol, | ||
186 | struct snd_ctl_elem_value *ucontrol) | ||
187 | { | ||
188 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
189 | |||
190 | if (rx51_jack_func == ucontrol->value.integer.value[0]) | ||
191 | return 0; | ||
192 | |||
193 | rx51_jack_func = ucontrol->value.integer.value[0]; | ||
194 | rx51_ext_control(codec); | ||
195 | |||
196 | return 1; | ||
197 | } | ||
198 | |||
199 | static struct snd_soc_jack rx51_av_jack; | ||
200 | |||
201 | static struct snd_soc_jack_gpio rx51_av_jack_gpios[] = { | ||
202 | { | ||
203 | .gpio = RX51_JACK_DETECT_GPIO, | ||
204 | .name = "avdet-gpio", | ||
205 | .report = SND_JACK_VIDEOOUT, | ||
206 | .invert = 1, | ||
207 | .debounce_time = 200, | ||
208 | }, | ||
209 | }; | ||
210 | |||
165 | static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = { | 211 | static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = { |
166 | SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event), | 212 | SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event), |
167 | SND_SOC_DAPM_MIC("DMic", NULL), | 213 | SND_SOC_DAPM_MIC("DMic", NULL), |
@@ -177,10 +223,12 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
177 | 223 | ||
178 | static const char *spk_function[] = {"Off", "On"}; | 224 | static const char *spk_function[] = {"Off", "On"}; |
179 | static const char *input_function[] = {"ADC", "Digital Mic"}; | 225 | static const char *input_function[] = {"ADC", "Digital Mic"}; |
226 | static const char *jack_function[] = {"Off", "TV-OUT"}; | ||
180 | 227 | ||
181 | static const struct soc_enum rx51_enum[] = { | 228 | static const struct soc_enum rx51_enum[] = { |
182 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), | 229 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), |
183 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(input_function), input_function), | 230 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(input_function), input_function), |
231 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(jack_function), jack_function), | ||
184 | }; | 232 | }; |
185 | 233 | ||
186 | static const struct snd_kcontrol_new aic34_rx51_controls[] = { | 234 | static const struct snd_kcontrol_new aic34_rx51_controls[] = { |
@@ -188,10 +236,13 @@ static const struct snd_kcontrol_new aic34_rx51_controls[] = { | |||
188 | rx51_get_spk, rx51_set_spk), | 236 | rx51_get_spk, rx51_set_spk), |
189 | SOC_ENUM_EXT("Input Select", rx51_enum[1], | 237 | SOC_ENUM_EXT("Input Select", rx51_enum[1], |
190 | rx51_get_input, rx51_set_input), | 238 | rx51_get_input, rx51_set_input), |
239 | SOC_ENUM_EXT("Jack Function", rx51_enum[2], | ||
240 | rx51_get_jack, rx51_set_jack), | ||
191 | }; | 241 | }; |
192 | 242 | ||
193 | static int rx51_aic34_init(struct snd_soc_codec *codec) | 243 | static int rx51_aic34_init(struct snd_soc_codec *codec) |
194 | { | 244 | { |
245 | struct snd_soc_card *card = codec->socdev->card; | ||
195 | int err; | 246 | int err; |
196 | 247 | ||
197 | /* Set up NC codec pins */ | 248 | /* Set up NC codec pins */ |
@@ -214,7 +265,16 @@ static int rx51_aic34_init(struct snd_soc_codec *codec) | |||
214 | 265 | ||
215 | snd_soc_dapm_sync(codec); | 266 | snd_soc_dapm_sync(codec); |
216 | 267 | ||
217 | return 0; | 268 | /* AV jack detection */ |
269 | err = snd_soc_jack_new(card, "AV Jack", | ||
270 | SND_JACK_VIDEOOUT, &rx51_av_jack); | ||
271 | if (err) | ||
272 | return err; | ||
273 | err = snd_soc_jack_add_gpios(&rx51_av_jack, | ||
274 | ARRAY_SIZE(rx51_av_jack_gpios), | ||
275 | rx51_av_jack_gpios); | ||
276 | |||
277 | return err; | ||
218 | } | 278 | } |
219 | 279 | ||
220 | /* Digital audio interface glue - connects codec <--> CPU */ | 280 | /* Digital audio interface glue - connects codec <--> CPU */ |
@@ -259,6 +319,11 @@ static int __init rx51_soc_init(void) | |||
259 | if (!machine_is_nokia_rx51()) | 319 | if (!machine_is_nokia_rx51()) |
260 | return -ENODEV; | 320 | return -ENODEV; |
261 | 321 | ||
322 | err = gpio_request(RX51_TVOUT_SEL_GPIO, "tvout_sel"); | ||
323 | if (err) | ||
324 | goto err_gpio_tvout_sel; | ||
325 | gpio_direction_output(RX51_TVOUT_SEL_GPIO, 0); | ||
326 | |||
262 | rx51_snd_device = platform_device_alloc("soc-audio", -1); | 327 | rx51_snd_device = platform_device_alloc("soc-audio", -1); |
263 | if (!rx51_snd_device) { | 328 | if (!rx51_snd_device) { |
264 | err = -ENOMEM; | 329 | err = -ENOMEM; |
@@ -277,13 +342,19 @@ static int __init rx51_soc_init(void) | |||
277 | err2: | 342 | err2: |
278 | platform_device_put(rx51_snd_device); | 343 | platform_device_put(rx51_snd_device); |
279 | err1: | 344 | err1: |
345 | gpio_free(RX51_TVOUT_SEL_GPIO); | ||
346 | err_gpio_tvout_sel: | ||
280 | 347 | ||
281 | return err; | 348 | return err; |
282 | } | 349 | } |
283 | 350 | ||
284 | static void __exit rx51_soc_exit(void) | 351 | static void __exit rx51_soc_exit(void) |
285 | { | 352 | { |
353 | snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios), | ||
354 | rx51_av_jack_gpios); | ||
355 | |||
286 | platform_device_unregister(rx51_snd_device); | 356 | platform_device_unregister(rx51_snd_device); |
357 | gpio_free(RX51_TVOUT_SEL_GPIO); | ||
287 | } | 358 | } |
288 | 359 | ||
289 | module_init(rx51_soc_init); | 360 | module_init(rx51_soc_init); |