aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/atmel/sam9g20_wm8731.c4
-rw-r--r--sound/soc/au1x/dbdma2.c2
-rw-r--r--sound/soc/codecs/Kconfig20
-rw-r--r--sound/soc/codecs/twl4030.c417
-rw-r--r--sound/soc/codecs/twl4030.h7
-rw-r--r--sound/soc/davinci/davinci-evm.c19
-rw-r--r--sound/soc/davinci/davinci-pcm.c2
-rw-r--r--sound/soc/davinci/davinci-sffsdr.c4
-rw-r--r--sound/soc/omap/Kconfig1
-rw-r--r--sound/soc/omap/omap3pandora.c13
-rw-r--r--sound/soc/pxa/pxa2xx-pcm.c4
-rw-r--r--sound/soc/soc-core.c120
-rw-r--r--sound/soc/soc-dapm.c137
13 files changed, 495 insertions, 255 deletions
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c
index 1fb59a9d3719..6ea04be911d0 100644
--- a/sound/soc/atmel/sam9g20_wm8731.c
+++ b/sound/soc/atmel/sam9g20_wm8731.c
@@ -221,8 +221,8 @@ static int at91sam9g20ek_wm8731_init(struct snd_soc_codec *codec)
221 snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon)); 221 snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon));
222 222
223 /* not connected */ 223 /* not connected */
224 snd_soc_dapm_disable_pin(codec, "RLINEIN"); 224 snd_soc_dapm_nc_pin(codec, "RLINEIN");
225 snd_soc_dapm_disable_pin(codec, "LLINEIN"); 225 snd_soc_dapm_nc_pin(codec, "LLINEIN");
226 226
227 /* always connected */ 227 /* always connected */
228 snd_soc_dapm_enable_pin(codec, "Int Mic"); 228 snd_soc_dapm_enable_pin(codec, "Int Mic");
diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c
index 74c823d60f91..bc8d654576c0 100644
--- a/sound/soc/au1x/dbdma2.c
+++ b/sound/soc/au1x/dbdma2.c
@@ -187,7 +187,7 @@ static int au1x_pcm_dbdma_realloc(struct au1xpsc_audio_dmadata *pcd,
187 au1x_pcm_dmatx_cb, (void *)pcd); 187 au1x_pcm_dmatx_cb, (void *)pcd);
188 188
189 if (!pcd->ddma_chan) 189 if (!pcd->ddma_chan)
190 return -ENOMEM;; 190 return -ENOMEM;
191 191
192 au1xxx_dbdma_set_devwidth(pcd->ddma_chan, msbits); 192 au1xxx_dbdma_set_devwidth(pcd->ddma_chan, msbits);
193 au1xxx_dbdma_ring_alloc(pcd->ddma_chan, 2); 193 au1xxx_dbdma_ring_alloc(pcd->ddma_chan, 2);
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index c41289b5f586..d0e0d691ae51 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -1,3 +1,13 @@
1# Helper to resolve issues with configs that have SPI enabled but I2C
2# modular, meaning we can't build the codec driver in with I2C support.
3# We use an ordered list of conditional defaults to pick the appropriate
4# setting - SPI can't be modular so that case doesn't need to be covered.
5config SND_SOC_I2C_AND_SPI
6 tristate
7 default m if I2C=m
8 default y if I2C=y
9 default y if SPI_MASTER=y
10
1config SND_SOC_ALL_CODECS 11config SND_SOC_ALL_CODECS
2 tristate "Build all ASoC CODEC drivers" 12 tristate "Build all ASoC CODEC drivers"
3 select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS 13 select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS
@@ -14,12 +24,12 @@ config SND_SOC_ALL_CODECS
14 select SND_SOC_UDA134X 24 select SND_SOC_UDA134X
15 select SND_SOC_UDA1380 if I2C 25 select SND_SOC_UDA1380 if I2C
16 select SND_SOC_WM8350 if MFD_WM8350 26 select SND_SOC_WM8350 if MFD_WM8350
17 select SND_SOC_WM8510 if (I2C || SPI_MASTER) 27 select SND_SOC_WM8510 if SND_SOC_I2C_AND_SPI
18 select SND_SOC_WM8580 if I2C 28 select SND_SOC_WM8580 if I2C
19 select SND_SOC_WM8728 if (I2C || SPI_MASTER) 29 select SND_SOC_WM8728 if SND_SOC_I2C_AND_SPI
20 select SND_SOC_WM8731 if (I2C || SPI_MASTER) 30 select SND_SOC_WM8731 if SND_SOC_I2C_AND_SPI
21 select SND_SOC_WM8750 if (I2C || SPI_MASTER) 31 select SND_SOC_WM8750 if SND_SOC_I2C_AND_SPI
22 select SND_SOC_WM8753 if (I2C || SPI_MASTER) 32 select SND_SOC_WM8753 if SND_SOC_I2C_AND_SPI
23 select SND_SOC_WM8900 if I2C 33 select SND_SOC_WM8900 if I2C
24 select SND_SOC_WM8903 if I2C 34 select SND_SOC_WM8903 if I2C
25 select SND_SOC_WM8971 if I2C 35 select SND_SOC_WM8971 if I2C
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 51848880504a..ea370a4f86d5 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -192,39 +192,51 @@ static void twl4030_init_chip(struct snd_soc_codec *codec)
192 192
193/* Earpiece */ 193/* Earpiece */
194static const char *twl4030_earpiece_texts[] = 194static const char *twl4030_earpiece_texts[] =
195 {"Off", "DACL1", "DACL2", "Invalid", "DACR1"}; 195 {"Off", "DACL1", "DACL2", "DACR1"};
196
197static const unsigned int twl4030_earpiece_values[] =
198 {0x0, 0x1, 0x2, 0x4};
196 199
197static const struct soc_enum twl4030_earpiece_enum = 200static const struct soc_enum twl4030_earpiece_enum =
198 SOC_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, 201 SOC_VALUE_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, 0x7,
199 ARRAY_SIZE(twl4030_earpiece_texts), 202 ARRAY_SIZE(twl4030_earpiece_texts),
200 twl4030_earpiece_texts); 203 twl4030_earpiece_texts,
204 twl4030_earpiece_values);
201 205
202static const struct snd_kcontrol_new twl4030_dapm_earpiece_control = 206static const struct snd_kcontrol_new twl4030_dapm_earpiece_control =
203SOC_DAPM_ENUM("Route", twl4030_earpiece_enum); 207SOC_DAPM_VALUE_ENUM("Route", twl4030_earpiece_enum);
204 208
205/* PreDrive Left */ 209/* PreDrive Left */
206static const char *twl4030_predrivel_texts[] = 210static const char *twl4030_predrivel_texts[] =
207 {"Off", "DACL1", "DACL2", "Invalid", "DACR2"}; 211 {"Off", "DACL1", "DACL2", "DACR2"};
212
213static const unsigned int twl4030_predrivel_values[] =
214 {0x0, 0x1, 0x2, 0x4};
208 215
209static const struct soc_enum twl4030_predrivel_enum = 216static const struct soc_enum twl4030_predrivel_enum =
210 SOC_ENUM_SINGLE(TWL4030_REG_PREDL_CTL, 1, 217 SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDL_CTL, 1, 0x7,
211 ARRAY_SIZE(twl4030_predrivel_texts), 218 ARRAY_SIZE(twl4030_predrivel_texts),
212 twl4030_predrivel_texts); 219 twl4030_predrivel_texts,
220 twl4030_predrivel_values);
213 221
214static const struct snd_kcontrol_new twl4030_dapm_predrivel_control = 222static const struct snd_kcontrol_new twl4030_dapm_predrivel_control =
215SOC_DAPM_ENUM("Route", twl4030_predrivel_enum); 223SOC_DAPM_VALUE_ENUM("Route", twl4030_predrivel_enum);
216 224
217/* PreDrive Right */ 225/* PreDrive Right */
218static const char *twl4030_predriver_texts[] = 226static const char *twl4030_predriver_texts[] =
219 {"Off", "DACR1", "DACR2", "Invalid", "DACL2"}; 227 {"Off", "DACR1", "DACR2", "DACL2"};
228
229static const unsigned int twl4030_predriver_values[] =
230 {0x0, 0x1, 0x2, 0x4};
220 231
221static const struct soc_enum twl4030_predriver_enum = 232static const struct soc_enum twl4030_predriver_enum =
222 SOC_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, 233 SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, 0x7,
223 ARRAY_SIZE(twl4030_predriver_texts), 234 ARRAY_SIZE(twl4030_predriver_texts),
224 twl4030_predriver_texts); 235 twl4030_predriver_texts,
236 twl4030_predriver_values);
225 237
226static const struct snd_kcontrol_new twl4030_dapm_predriver_control = 238static const struct snd_kcontrol_new twl4030_dapm_predriver_control =
227SOC_DAPM_ENUM("Route", twl4030_predriver_enum); 239SOC_DAPM_VALUE_ENUM("Route", twl4030_predriver_enum);
228 240
229/* Headset Left */ 241/* Headset Left */
230static const char *twl4030_hsol_texts[] = 242static const char *twl4030_hsol_texts[] =
@@ -298,28 +310,90 @@ static const struct soc_enum twl4030_handsfreer_enum =
298static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control = 310static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control =
299SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); 311SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum);
300 312
301static int outmixer_event(struct snd_soc_dapm_widget *w, 313/* Left analog microphone selection */
314static const char *twl4030_analoglmic_texts[] =
315 {"Off", "Main mic", "Headset mic", "AUXL", "Carkit mic"};
316
317static const unsigned int twl4030_analoglmic_values[] =
318 {0x0, 0x1, 0x2, 0x4, 0x8};
319
320static const struct soc_enum twl4030_analoglmic_enum =
321 SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICL, 0, 0xf,
322 ARRAY_SIZE(twl4030_analoglmic_texts),
323 twl4030_analoglmic_texts,
324 twl4030_analoglmic_values);
325
326static const struct snd_kcontrol_new twl4030_dapm_analoglmic_control =
327SOC_DAPM_VALUE_ENUM("Route", twl4030_analoglmic_enum);
328
329/* Right analog microphone selection */
330static const char *twl4030_analogrmic_texts[] =
331 {"Off", "Sub mic", "AUXR"};
332
333static const unsigned int twl4030_analogrmic_values[] =
334 {0x0, 0x1, 0x4};
335
336static const struct soc_enum twl4030_analogrmic_enum =
337 SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICR, 0, 0x5,
338 ARRAY_SIZE(twl4030_analogrmic_texts),
339 twl4030_analogrmic_texts,
340 twl4030_analogrmic_values);
341
342static const struct snd_kcontrol_new twl4030_dapm_analogrmic_control =
343SOC_DAPM_VALUE_ENUM("Route", twl4030_analogrmic_enum);
344
345/* TX1 L/R Analog/Digital microphone selection */
346static const char *twl4030_micpathtx1_texts[] =
347 {"Analog", "Digimic0"};
348
349static const struct soc_enum twl4030_micpathtx1_enum =
350 SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 0,
351 ARRAY_SIZE(twl4030_micpathtx1_texts),
352 twl4030_micpathtx1_texts);
353
354static const struct snd_kcontrol_new twl4030_dapm_micpathtx1_control =
355SOC_DAPM_ENUM("Route", twl4030_micpathtx1_enum);
356
357/* TX2 L/R Analog/Digital microphone selection */
358static const char *twl4030_micpathtx2_texts[] =
359 {"Analog", "Digimic1"};
360
361static const struct soc_enum twl4030_micpathtx2_enum =
362 SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 2,
363 ARRAY_SIZE(twl4030_micpathtx2_texts),
364 twl4030_micpathtx2_texts);
365
366static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control =
367SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum);
368
369static int micpath_event(struct snd_soc_dapm_widget *w,
302 struct snd_kcontrol *kcontrol, int event) 370 struct snd_kcontrol *kcontrol, int event)
303{ 371{
304 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 372 struct soc_enum *e = (struct soc_enum *)w->kcontrols->private_value;
305 int ret = 0; 373 unsigned char adcmicsel, micbias_ctl;
306 int val; 374
307 375 adcmicsel = twl4030_read_reg_cache(w->codec, TWL4030_REG_ADCMICSEL);
308 switch (e->reg) { 376 micbias_ctl = twl4030_read_reg_cache(w->codec, TWL4030_REG_MICBIAS_CTL);
309 case TWL4030_REG_PREDL_CTL: 377 /* Prepare the bits for the given TX path:
310 case TWL4030_REG_PREDR_CTL: 378 * shift_l == 0: TX1 microphone path
311 case TWL4030_REG_EAR_CTL: 379 * shift_l == 2: TX2 microphone path */
312 val = w->value >> e->shift_l; 380 if (e->shift_l) {
313 if (val == 3) { 381 /* TX2 microphone path */
314 printk(KERN_WARNING 382 if (adcmicsel & TWL4030_TX2IN_SEL)
315 "Invalid MUX setting for register 0x%02x (%d)\n", 383 micbias_ctl |= TWL4030_MICBIAS2_CTL; /* digimic */
316 e->reg, val); 384 else
317 ret = -1; 385 micbias_ctl &= ~TWL4030_MICBIAS2_CTL;
318 } 386 } else {
319 break; 387 /* TX1 microphone path */
388 if (adcmicsel & TWL4030_TX1IN_SEL)
389 micbias_ctl |= TWL4030_MICBIAS1_CTL; /* digimic */
390 else
391 micbias_ctl &= ~TWL4030_MICBIAS1_CTL;
320 } 392 }
321 393
322 return ret; 394 twl4030_write(w->codec, TWL4030_REG_MICBIAS_CTL, micbias_ctl);
395
396 return 0;
323} 397}
324 398
325static int handsfree_event(struct snd_soc_dapm_widget *w, 399static int handsfree_event(struct snd_soc_dapm_widget *w,
@@ -503,162 +577,6 @@ static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol,
503 return err; 577 return err;
504} 578}
505 579
506static int twl4030_get_left_input(struct snd_kcontrol *kcontrol,
507 struct snd_ctl_elem_value *ucontrol)
508{
509 struct snd_soc_codec *codec = kcontrol->private_data;
510 u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL);
511 int result = 0;
512
513 /* one bit must be set a time */
514 reg &= TWL4030_CKMIC_EN | TWL4030_AUXL_EN | TWL4030_HSMIC_EN
515 | TWL4030_MAINMIC_EN;
516 if (reg != 0) {
517 result++;
518 while ((reg & 1) == 0) {
519 result++;
520 reg >>= 1;
521 }
522 }
523
524 ucontrol->value.integer.value[0] = result;
525 return 0;
526}
527
528static int twl4030_put_left_input(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_value *ucontrol)
530{
531 struct snd_soc_codec *codec = kcontrol->private_data;
532 int value = ucontrol->value.integer.value[0];
533 u8 anamicl, micbias, avadc_ctl;
534
535 anamicl = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL);
536 anamicl &= ~(TWL4030_CKMIC_EN | TWL4030_AUXL_EN | TWL4030_HSMIC_EN
537 | TWL4030_MAINMIC_EN);
538 micbias = twl4030_read_reg_cache(codec, TWL4030_REG_MICBIAS_CTL);
539 micbias &= ~(TWL4030_HSMICBIAS_EN | TWL4030_MICBIAS1_EN);
540 avadc_ctl = twl4030_read_reg_cache(codec, TWL4030_REG_AVADC_CTL);
541
542 switch (value) {
543 case 1:
544 anamicl |= TWL4030_MAINMIC_EN;
545 micbias |= TWL4030_MICBIAS1_EN;
546 break;
547 case 2:
548 anamicl |= TWL4030_HSMIC_EN;
549 micbias |= TWL4030_HSMICBIAS_EN;
550 break;
551 case 3:
552 anamicl |= TWL4030_AUXL_EN;
553 break;
554 case 4:
555 anamicl |= TWL4030_CKMIC_EN;
556 break;
557 default:
558 break;
559 }
560
561 /* If some input is selected, enable amp and ADC */
562 if (value != 0) {
563 anamicl |= TWL4030_MICAMPL_EN;
564 avadc_ctl |= TWL4030_ADCL_EN;
565 } else {
566 anamicl &= ~TWL4030_MICAMPL_EN;
567 avadc_ctl &= ~TWL4030_ADCL_EN;
568 }
569
570 twl4030_write(codec, TWL4030_REG_ANAMICL, anamicl);
571 twl4030_write(codec, TWL4030_REG_MICBIAS_CTL, micbias);
572 twl4030_write(codec, TWL4030_REG_AVADC_CTL, avadc_ctl);
573
574 return 1;
575}
576
577static int twl4030_get_right_input(struct snd_kcontrol *kcontrol,
578 struct snd_ctl_elem_value *ucontrol)
579{
580 struct snd_soc_codec *codec = kcontrol->private_data;
581 u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICR);
582 int value = 0;
583
584 reg &= TWL4030_SUBMIC_EN|TWL4030_AUXR_EN;
585 switch (reg) {
586 case TWL4030_SUBMIC_EN:
587 value = 1;
588 break;
589 case TWL4030_AUXR_EN:
590 value = 2;
591 break;
592 default:
593 break;
594 }
595
596 ucontrol->value.integer.value[0] = value;
597 return 0;
598}
599
600static int twl4030_put_right_input(struct snd_kcontrol *kcontrol,
601 struct snd_ctl_elem_value *ucontrol)
602{
603 struct snd_soc_codec *codec = kcontrol->private_data;
604 int value = ucontrol->value.integer.value[0];
605 u8 anamicr, micbias, avadc_ctl;
606
607 anamicr = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICR);
608 anamicr &= ~(TWL4030_SUBMIC_EN|TWL4030_AUXR_EN);
609 micbias = twl4030_read_reg_cache(codec, TWL4030_REG_MICBIAS_CTL);
610 micbias &= ~TWL4030_MICBIAS2_EN;
611 avadc_ctl = twl4030_read_reg_cache(codec, TWL4030_REG_AVADC_CTL);
612
613 switch (value) {
614 case 1:
615 anamicr |= TWL4030_SUBMIC_EN;
616 micbias |= TWL4030_MICBIAS2_EN;
617 break;
618 case 2:
619 anamicr |= TWL4030_AUXR_EN;
620 break;
621 default:
622 break;
623 }
624
625 if (value != 0) {
626 anamicr |= TWL4030_MICAMPR_EN;
627 avadc_ctl |= TWL4030_ADCR_EN;
628 } else {
629 anamicr &= ~TWL4030_MICAMPR_EN;
630 avadc_ctl &= ~TWL4030_ADCR_EN;
631 }
632
633 twl4030_write(codec, TWL4030_REG_ANAMICR, anamicr);
634 twl4030_write(codec, TWL4030_REG_MICBIAS_CTL, micbias);
635 twl4030_write(codec, TWL4030_REG_AVADC_CTL, avadc_ctl);
636
637 return 1;
638}
639
640static const char *twl4030_left_in_sel[] = {
641 "None",
642 "Main Mic",
643 "Headset Mic",
644 "Line In",
645 "Carkit Mic",
646};
647
648static const char *twl4030_right_in_sel[] = {
649 "None",
650 "Sub Mic",
651 "Line In",
652};
653
654static const struct soc_enum twl4030_left_input_mux =
655 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(twl4030_left_in_sel),
656 twl4030_left_in_sel);
657
658static const struct soc_enum twl4030_right_input_mux =
659 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(twl4030_right_in_sel),
660 twl4030_right_in_sel);
661
662/* 580/*
663 * FGAIN volume control: 581 * FGAIN volume control:
664 * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB) 582 * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB)
@@ -741,18 +659,15 @@ static const struct snd_kcontrol_new twl4030_snd_controls[] = {
741 TWL4030_REG_EAR_CTL, 4, 3, 0, output_tvl), 659 TWL4030_REG_EAR_CTL, 4, 3, 0, output_tvl),
742 660
743 /* Common capture gain controls */ 661 /* Common capture gain controls */
744 SOC_DOUBLE_R_TLV("Capture Volume", 662 SOC_DOUBLE_R_TLV("TX1 Digital Capture Volume",
745 TWL4030_REG_ATXL1PGA, TWL4030_REG_ATXR1PGA, 663 TWL4030_REG_ATXL1PGA, TWL4030_REG_ATXR1PGA,
746 0, 0x1f, 0, digital_capture_tlv), 664 0, 0x1f, 0, digital_capture_tlv),
665 SOC_DOUBLE_R_TLV("TX2 Digital Capture Volume",
666 TWL4030_REG_AVTXL2PGA, TWL4030_REG_AVTXR2PGA,
667 0, 0x1f, 0, digital_capture_tlv),
747 668
748 SOC_DOUBLE_TLV("Input Boost Volume", TWL4030_REG_ANAMIC_GAIN, 669 SOC_DOUBLE_TLV("Analog Capture Volume", TWL4030_REG_ANAMIC_GAIN,
749 0, 3, 5, 0, input_gain_tlv), 670 0, 3, 5, 0, input_gain_tlv),
750
751 /* Input source controls */
752 SOC_ENUM_EXT("Left Input Source", twl4030_left_input_mux,
753 twl4030_get_left_input, twl4030_put_left_input),
754 SOC_ENUM_EXT("Right Input Source", twl4030_right_input_mux,
755 twl4030_get_right_input, twl4030_put_right_input),
756}; 671};
757 672
758/* add non dapm controls */ 673/* add non dapm controls */
@@ -772,9 +687,19 @@ static int twl4030_add_controls(struct snd_soc_codec *codec)
772} 687}
773 688
774static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { 689static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
775 SND_SOC_DAPM_INPUT("INL"), 690 /* Left channel inputs */
776 SND_SOC_DAPM_INPUT("INR"), 691 SND_SOC_DAPM_INPUT("MAINMIC"),
777 692 SND_SOC_DAPM_INPUT("HSMIC"),
693 SND_SOC_DAPM_INPUT("AUXL"),
694 SND_SOC_DAPM_INPUT("CARKITMIC"),
695 /* Right channel inputs */
696 SND_SOC_DAPM_INPUT("SUBMIC"),
697 SND_SOC_DAPM_INPUT("AUXR"),
698 /* Digital microphones (Stereo) */
699 SND_SOC_DAPM_INPUT("DIGIMIC0"),
700 SND_SOC_DAPM_INPUT("DIGIMIC1"),
701
702 /* Outputs */
778 SND_SOC_DAPM_OUTPUT("OUTL"), 703 SND_SOC_DAPM_OUTPUT("OUTL"),
779 SND_SOC_DAPM_OUTPUT("OUTR"), 704 SND_SOC_DAPM_OUTPUT("OUTR"),
780 SND_SOC_DAPM_OUTPUT("EARPIECE"), 705 SND_SOC_DAPM_OUTPUT("EARPIECE"),
@@ -809,16 +734,13 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
809 734
810 /* Output MUX controls */ 735 /* Output MUX controls */
811 /* Earpiece */ 736 /* Earpiece */
812 SND_SOC_DAPM_MUX_E("Earpiece Mux", SND_SOC_NOPM, 0, 0, 737 SND_SOC_DAPM_VALUE_MUX("Earpiece Mux", SND_SOC_NOPM, 0, 0,
813 &twl4030_dapm_earpiece_control, outmixer_event, 738 &twl4030_dapm_earpiece_control),
814 SND_SOC_DAPM_PRE_REG),
815 /* PreDrivL/R */ 739 /* PreDrivL/R */
816 SND_SOC_DAPM_MUX_E("PredriveL Mux", SND_SOC_NOPM, 0, 0, 740 SND_SOC_DAPM_VALUE_MUX("PredriveL Mux", SND_SOC_NOPM, 0, 0,
817 &twl4030_dapm_predrivel_control, outmixer_event, 741 &twl4030_dapm_predrivel_control),
818 SND_SOC_DAPM_PRE_REG), 742 SND_SOC_DAPM_VALUE_MUX("PredriveR Mux", SND_SOC_NOPM, 0, 0,
819 SND_SOC_DAPM_MUX_E("PredriveR Mux", SND_SOC_NOPM, 0, 0, 743 &twl4030_dapm_predriver_control),
820 &twl4030_dapm_predriver_control, outmixer_event,
821 SND_SOC_DAPM_PRE_REG),
822 /* HeadsetL/R */ 744 /* HeadsetL/R */
823 SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0, 745 SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0,
824 &twl4030_dapm_hsol_control), 746 &twl4030_dapm_hsol_control),
@@ -837,8 +759,48 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
837 &twl4030_dapm_handsfreer_control, handsfree_event, 759 &twl4030_dapm_handsfreer_control, handsfree_event,
838 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), 760 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
839 761
840 SND_SOC_DAPM_ADC("ADCL", "Left Capture", SND_SOC_NOPM, 0, 0), 762 /* Introducing four virtual ADC, since TWL4030 have four channel for
841 SND_SOC_DAPM_ADC("ADCR", "Right Capture", SND_SOC_NOPM, 0, 0), 763 capture */
764 SND_SOC_DAPM_ADC("ADC Virtual Left1", "Left Front Capture",
765 SND_SOC_NOPM, 0, 0),
766 SND_SOC_DAPM_ADC("ADC Virtual Right1", "Right Front Capture",
767 SND_SOC_NOPM, 0, 0),
768 SND_SOC_DAPM_ADC("ADC Virtual Left2", "Left Rear Capture",
769 SND_SOC_NOPM, 0, 0),
770 SND_SOC_DAPM_ADC("ADC Virtual Right2", "Right Rear Capture",
771 SND_SOC_NOPM, 0, 0),
772
773 /* Analog/Digital mic path selection.
774 TX1 Left/Right: either analog Left/Right or Digimic0
775 TX2 Left/Right: either analog Left/Right or Digimic1 */
776 SND_SOC_DAPM_MUX_E("TX1 Capture Route", SND_SOC_NOPM, 0, 0,
777 &twl4030_dapm_micpathtx1_control, micpath_event,
778 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD|
779 SND_SOC_DAPM_POST_REG),
780 SND_SOC_DAPM_MUX_E("TX2 Capture Route", SND_SOC_NOPM, 0, 0,
781 &twl4030_dapm_micpathtx2_control, micpath_event,
782 SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD|
783 SND_SOC_DAPM_POST_REG),
784
785 /* Analog input muxes with power switch for the physical ADCL/R */
786 SND_SOC_DAPM_VALUE_MUX("Analog Left Capture Route",
787 TWL4030_REG_AVADC_CTL, 3, 0, &twl4030_dapm_analoglmic_control),
788 SND_SOC_DAPM_VALUE_MUX("Analog Right Capture Route",
789 TWL4030_REG_AVADC_CTL, 1, 0, &twl4030_dapm_analogrmic_control),
790
791 SND_SOC_DAPM_PGA("Analog Left Amplifier",
792 TWL4030_REG_ANAMICL, 4, 0, NULL, 0),
793 SND_SOC_DAPM_PGA("Analog Right Amplifier",
794 TWL4030_REG_ANAMICR, 4, 0, NULL, 0),
795
796 SND_SOC_DAPM_PGA("Digimic0 Enable",
797 TWL4030_REG_ADCMICSEL, 1, 0, NULL, 0),
798 SND_SOC_DAPM_PGA("Digimic1 Enable",
799 TWL4030_REG_ADCMICSEL, 3, 0, NULL, 0),
800
801 SND_SOC_DAPM_MICBIAS("Mic Bias 1", TWL4030_REG_MICBIAS_CTL, 0, 0),
802 SND_SOC_DAPM_MICBIAS("Mic Bias 2", TWL4030_REG_MICBIAS_CTL, 1, 0),
803 SND_SOC_DAPM_MICBIAS("Headset Mic Bias", TWL4030_REG_MICBIAS_CTL, 2, 0),
842}; 804};
843 805
844static const struct snd_soc_dapm_route intercon[] = { 806static const struct snd_soc_dapm_route intercon[] = {
@@ -894,9 +856,39 @@ static const struct snd_soc_dapm_route intercon[] = {
894 {"HFL", NULL, "HandsfreeL Mux"}, 856 {"HFL", NULL, "HandsfreeL Mux"},
895 {"HFR", NULL, "HandsfreeR Mux"}, 857 {"HFR", NULL, "HandsfreeR Mux"},
896 858
897 /* inputs */ 859 /* Capture path */
898 {"ADCL", NULL, "INL"}, 860 {"Analog Left Capture Route", "Main mic", "MAINMIC"},
899 {"ADCR", NULL, "INR"}, 861 {"Analog Left Capture Route", "Headset mic", "HSMIC"},
862 {"Analog Left Capture Route", "AUXL", "AUXL"},
863 {"Analog Left Capture Route", "Carkit mic", "CARKITMIC"},
864
865 {"Analog Right Capture Route", "Sub mic", "SUBMIC"},
866 {"Analog Right Capture Route", "AUXR", "AUXR"},
867
868 {"Analog Left Amplifier", NULL, "Analog Left Capture Route"},
869 {"Analog Right Amplifier", NULL, "Analog Right Capture Route"},
870
871 {"Digimic0 Enable", NULL, "DIGIMIC0"},
872 {"Digimic1 Enable", NULL, "DIGIMIC1"},
873
874 /* TX1 Left capture path */
875 {"TX1 Capture Route", "Analog", "Analog Left Amplifier"},
876 {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"},
877 /* TX1 Right capture path */
878 {"TX1 Capture Route", "Analog", "Analog Right Amplifier"},
879 {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"},
880 /* TX2 Left capture path */
881 {"TX2 Capture Route", "Analog", "Analog Left Amplifier"},
882 {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"},
883 /* TX2 Right capture path */
884 {"TX2 Capture Route", "Analog", "Analog Right Amplifier"},
885 {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"},
886
887 {"ADC Virtual Left1", NULL, "TX1 Capture Route"},
888 {"ADC Virtual Right1", NULL, "TX1 Capture Route"},
889 {"ADC Virtual Left2", NULL, "TX2 Capture Route"},
890 {"ADC Virtual Right2", NULL, "TX2 Capture Route"},
891
900}; 892};
901 893
902static int twl4030_add_widgets(struct snd_soc_codec *codec) 894static int twl4030_add_widgets(struct snd_soc_codec *codec)
@@ -923,6 +915,7 @@ static void twl4030_power_up(struct snd_soc_codec *codec)
923 twl4030_write(codec, TWL4030_REG_ANAMICL, 915 twl4030_write(codec, TWL4030_REG_ANAMICL,
924 anamicl | TWL4030_CNCL_OFFSET_START); 916 anamicl | TWL4030_CNCL_OFFSET_START);
925 917
918
926 /* wait for offset cancellation to complete */ 919 /* wait for offset cancellation to complete */
927 do { 920 do {
928 /* this takes a little while, so don't slam i2c */ 921 /* this takes a little while, so don't slam i2c */
@@ -1287,6 +1280,8 @@ static int twl4030_remove(struct platform_device *pdev)
1287 struct snd_soc_codec *codec = socdev->codec; 1280 struct snd_soc_codec *codec = socdev->codec;
1288 1281
1289 printk(KERN_INFO "TWL4030 Audio Codec remove\n"); 1282 printk(KERN_INFO "TWL4030 Audio Codec remove\n");
1283 snd_soc_free_pcms(socdev);
1284 snd_soc_dapm_free(socdev);
1290 kfree(codec); 1285 kfree(codec);
1291 1286
1292 return 0; 1287 return 0;
diff --git a/sound/soc/codecs/twl4030.h b/sound/soc/codecs/twl4030.h
index 54615c76802b..442e5a828617 100644
--- a/sound/soc/codecs/twl4030.h
+++ b/sound/soc/codecs/twl4030.h
@@ -147,6 +147,13 @@
147#define TWL4030_AVADC_CLK_PRIORITY 0x04 147#define TWL4030_AVADC_CLK_PRIORITY 0x04
148#define TWL4030_ADCR_EN 0x02 148#define TWL4030_ADCR_EN 0x02
149 149
150/* TWL4030_REG_ADCMICSEL (0x08) Fields */
151
152#define TWL4030_DIGMIC1_EN 0x08
153#define TWL4030_TX2IN_SEL 0x04
154#define TWL4030_DIGMIC0_EN 0x02
155#define TWL4030_TX1IN_SEL 0x01
156
150/* AUDIO_IF (0x0E) Fields */ 157/* AUDIO_IF (0x0E) Fields */
151 158
152#define TWL4030_AIF_SLAVE_EN 0x80 159#define TWL4030_AIF_SLAVE_EN 0x80
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 01b948bb55a1..54851f318568 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -26,7 +26,6 @@
26#include "davinci-pcm.h" 26#include "davinci-pcm.h"
27#include "davinci-i2s.h" 27#include "davinci-i2s.h"
28 28
29#define EVM_CODEC_CLOCK 22579200
30 29
31#define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ 30#define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \
32 SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF) 31 SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF)
@@ -37,6 +36,21 @@ static int evm_hw_params(struct snd_pcm_substream *substream,
37 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 36 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
38 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 37 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
39 int ret = 0; 38 int ret = 0;
39 unsigned sysclk;
40
41 /* ASP1 on DM355 EVM is clocked by an external oscillator */
42 if (machine_is_davinci_dm355_evm())
43 sysclk = 27000000;
44
45 /* ASP0 in DM6446 EVM is clocked by U55, as configured by
46 * board-dm644x-evm.c using GPIOs from U18. There are six
47 * options; here we "know" we use a 48 KHz sample rate.
48 */
49 else if (machine_is_davinci_evm())
50 sysclk = 12288000;
51
52 else
53 return -EINVAL;
40 54
41 /* set codec DAI configuration */ 55 /* set codec DAI configuration */
42 ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT); 56 ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT);
@@ -49,8 +63,7 @@ static int evm_hw_params(struct snd_pcm_substream *substream,
49 return ret; 63 return ret;
50 64
51 /* set the codec system clock */ 65 /* set the codec system clock */
52 ret = snd_soc_dai_set_sysclk(codec_dai, 0, EVM_CODEC_CLOCK, 66 ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
53 SND_SOC_CLOCK_OUT);
54 if (ret < 0) 67 if (ret < 0)
55 return ret; 68 return ret;
56 69
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
index 74abc9b4f1cc..366049d8578c 100644
--- a/sound/soc/davinci/davinci-pcm.c
+++ b/sound/soc/davinci/davinci-pcm.c
@@ -212,7 +212,7 @@ davinci_pcm_pointer(struct snd_pcm_substream *substream)
212 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 212 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
213 count = src - runtime->dma_addr; 213 count = src - runtime->dma_addr;
214 else 214 else
215 count = dst - runtime->dma_addr;; 215 count = dst - runtime->dma_addr;
216 216
217 spin_unlock(&prtd->lock); 217 spin_unlock(&prtd->lock);
218 218
diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c
index f67579d52765..4935d1bcbd8d 100644
--- a/sound/soc/davinci/davinci-sffsdr.c
+++ b/sound/soc/davinci/davinci-sffsdr.c
@@ -24,6 +24,7 @@
24#include <sound/soc-dapm.h> 24#include <sound/soc-dapm.h>
25 25
26#include <asm/dma.h> 26#include <asm/dma.h>
27#include <asm/mach-types.h>
27#include <asm/plat-sffsdr/sffsdr-fpga.h> 28#include <asm/plat-sffsdr/sffsdr-fpga.h>
28 29
29#include <mach/mcbsp.h> 30#include <mach/mcbsp.h>
@@ -115,6 +116,9 @@ static int __init sffsdr_init(void)
115{ 116{
116 int ret; 117 int ret;
117 118
119 if (!machine_is_sffsdr())
120 return -EINVAL;
121
118 sffsdr_snd_device = platform_device_alloc("soc-audio", 0); 122 sffsdr_snd_device = platform_device_alloc("soc-audio", 0);
119 if (!sffsdr_snd_device) { 123 if (!sffsdr_snd_device) {
120 printk(KERN_ERR "platform device allocation failed\n"); 124 printk(KERN_ERR "platform device allocation failed\n");
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
index a7b1d77b2105..4f7f04014585 100644
--- a/sound/soc/omap/Kconfig
+++ b/sound/soc/omap/Kconfig
@@ -10,6 +10,7 @@ config SND_OMAP_SOC_N810
10 tristate "SoC Audio support for Nokia N810" 10 tristate "SoC Audio support for Nokia N810"
11 depends on SND_OMAP_SOC && MACH_NOKIA_N810 11 depends on SND_OMAP_SOC && MACH_NOKIA_N810
12 select SND_OMAP_SOC_MCBSP 12 select SND_OMAP_SOC_MCBSP
13 select OMAP_MUX
13 select SND_SOC_TLV320AIC3X 14 select SND_SOC_TLV320AIC3X
14 help 15 help
15 Say Y if you want to add support for SoC audio on Nokia N810. 16 Say Y if you want to add support for SoC audio on Nokia N810.
diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c
index bd91594496b1..fcc2f5d9a878 100644
--- a/sound/soc/omap/omap3pandora.c
+++ b/sound/soc/omap/omap3pandora.c
@@ -180,6 +180,19 @@ static int omap3pandora_in_init(struct snd_soc_codec *codec)
180{ 180{
181 int ret; 181 int ret;
182 182
183 /* All TWL4030 output pins are floating */
184 snd_soc_dapm_nc_pin(codec, "OUTL"),
185 snd_soc_dapm_nc_pin(codec, "OUTR"),
186 snd_soc_dapm_nc_pin(codec, "EARPIECE"),
187 snd_soc_dapm_nc_pin(codec, "PREDRIVEL"),
188 snd_soc_dapm_nc_pin(codec, "PREDRIVER"),
189 snd_soc_dapm_nc_pin(codec, "HSOL"),
190 snd_soc_dapm_nc_pin(codec, "HSOR"),
191 snd_soc_dapm_nc_pin(codec, "CARKITL"),
192 snd_soc_dapm_nc_pin(codec, "CARKITR"),
193 snd_soc_dapm_nc_pin(codec, "HFL"),
194 snd_soc_dapm_nc_pin(codec, "HFR"),
195
183 ret = snd_soc_dapm_new_controls(codec, omap3pandora_in_dapm_widgets, 196 ret = snd_soc_dapm_new_controls(codec, omap3pandora_in_dapm_widgets,
184 ARRAY_SIZE(omap3pandora_in_dapm_widgets)); 197 ARRAY_SIZE(omap3pandora_in_dapm_widgets));
185 if (ret < 0) 198 if (ret < 0)
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
index c670d08e7c9e..53b9fb127a6d 100644
--- a/sound/soc/pxa/pxa2xx-pcm.c
+++ b/sound/soc/pxa/pxa2xx-pcm.c
@@ -61,9 +61,9 @@ static int pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream)
61 61
62 __pxa2xx_pcm_hw_free(substream); 62 __pxa2xx_pcm_hw_free(substream);
63 63
64 if (prtd->dma_ch) { 64 if (prtd->dma_ch >= 0) {
65 pxa_free_dma(prtd->dma_ch); 65 pxa_free_dma(prtd->dma_ch);
66 prtd->dma_ch = 0; 66 prtd->dma_ch = -1;
67 } 67 }
68 68
69 return 0; 69 return 0;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b098c0b4c584..55fdb4abb179 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1300,6 +1300,8 @@ EXPORT_SYMBOL_GPL(snd_soc_test_bits);
1300/** 1300/**
1301 * snd_soc_new_pcms - create new sound card and pcms 1301 * snd_soc_new_pcms - create new sound card and pcms
1302 * @socdev: the SoC audio device 1302 * @socdev: the SoC audio device
1303 * @idx: ALSA card index
1304 * @xid: card identification
1303 * 1305 *
1304 * Create a new sound card based upon the codec and interface pcms. 1306 * Create a new sound card based upon the codec and interface pcms.
1305 * 1307 *
@@ -1472,7 +1474,7 @@ EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams);
1472 * snd_soc_cnew - create new control 1474 * snd_soc_cnew - create new control
1473 * @_template: control template 1475 * @_template: control template
1474 * @data: control private data 1476 * @data: control private data
1475 * @lnng_name: control long name 1477 * @long_name: control long name
1476 * 1478 *
1477 * Create a new mixer control from a template control. 1479 * Create a new mixer control from a template control.
1478 * 1480 *
@@ -1522,7 +1524,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_enum_double);
1522/** 1524/**
1523 * snd_soc_get_enum_double - enumerated double mixer get callback 1525 * snd_soc_get_enum_double - enumerated double mixer get callback
1524 * @kcontrol: mixer control 1526 * @kcontrol: mixer control
1525 * @uinfo: control element information 1527 * @ucontrol: control element information
1526 * 1528 *
1527 * Callback to get the value of a double enumerated mixer. 1529 * Callback to get the value of a double enumerated mixer.
1528 * 1530 *
@@ -1551,7 +1553,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_enum_double);
1551/** 1553/**
1552 * snd_soc_put_enum_double - enumerated double mixer put callback 1554 * snd_soc_put_enum_double - enumerated double mixer put callback
1553 * @kcontrol: mixer control 1555 * @kcontrol: mixer control
1554 * @uinfo: control element information 1556 * @ucontrol: control element information
1555 * 1557 *
1556 * Callback to set the value of a double enumerated mixer. 1558 * Callback to set the value of a double enumerated mixer.
1557 * 1559 *
@@ -1583,6 +1585,80 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
1583EXPORT_SYMBOL_GPL(snd_soc_put_enum_double); 1585EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
1584 1586
1585/** 1587/**
1588 * snd_soc_get_value_enum_double - semi enumerated double mixer get callback
1589 * @kcontrol: mixer control
1590 * @ucontrol: control element information
1591 *
1592 * Callback to get the value of a double semi enumerated mixer.
1593 *
1594 * Semi enumerated mixer: the enumerated items are referred as values. Can be
1595 * used for handling bitfield coded enumeration for example.
1596 *
1597 * Returns 0 for success.
1598 */
1599int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
1600 struct snd_ctl_elem_value *ucontrol)
1601{
1602 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1603 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1604 unsigned short reg_val, val, mux;
1605
1606 reg_val = snd_soc_read(codec, e->reg);
1607 val = (reg_val >> e->shift_l) & e->mask;
1608 for (mux = 0; mux < e->max; mux++) {
1609 if (val == e->values[mux])
1610 break;
1611 }
1612 ucontrol->value.enumerated.item[0] = mux;
1613 if (e->shift_l != e->shift_r) {
1614 val = (reg_val >> e->shift_r) & e->mask;
1615 for (mux = 0; mux < e->max; mux++) {
1616 if (val == e->values[mux])
1617 break;
1618 }
1619 ucontrol->value.enumerated.item[1] = mux;
1620 }
1621
1622 return 0;
1623}
1624EXPORT_SYMBOL_GPL(snd_soc_get_value_enum_double);
1625
1626/**
1627 * snd_soc_put_value_enum_double - semi enumerated double mixer put callback
1628 * @kcontrol: mixer control
1629 * @ucontrol: control element information
1630 *
1631 * Callback to set the value of a double semi enumerated mixer.
1632 *
1633 * Semi enumerated mixer: the enumerated items are referred as values. Can be
1634 * used for handling bitfield coded enumeration for example.
1635 *
1636 * Returns 0 for success.
1637 */
1638int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
1639 struct snd_ctl_elem_value *ucontrol)
1640{
1641 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
1642 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1643 unsigned short val;
1644 unsigned short mask;
1645
1646 if (ucontrol->value.enumerated.item[0] > e->max - 1)
1647 return -EINVAL;
1648 val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l;
1649 mask = e->mask << e->shift_l;
1650 if (e->shift_l != e->shift_r) {
1651 if (ucontrol->value.enumerated.item[1] > e->max - 1)
1652 return -EINVAL;
1653 val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r;
1654 mask |= e->mask << e->shift_r;
1655 }
1656
1657 return snd_soc_update_bits(codec, e->reg, mask, val);
1658}
1659EXPORT_SYMBOL_GPL(snd_soc_put_value_enum_double);
1660
1661/**
1586 * snd_soc_info_enum_ext - external enumerated single mixer info callback 1662 * snd_soc_info_enum_ext - external enumerated single mixer info callback
1587 * @kcontrol: mixer control 1663 * @kcontrol: mixer control
1588 * @uinfo: control element information 1664 * @uinfo: control element information
@@ -1668,7 +1744,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
1668/** 1744/**
1669 * snd_soc_get_volsw - single mixer get callback 1745 * snd_soc_get_volsw - single mixer get callback
1670 * @kcontrol: mixer control 1746 * @kcontrol: mixer control
1671 * @uinfo: control element information 1747 * @ucontrol: control element information
1672 * 1748 *
1673 * Callback to get the value of a single mixer control. 1749 * Callback to get the value of a single mixer control.
1674 * 1750 *
@@ -1707,7 +1783,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw);
1707/** 1783/**
1708 * snd_soc_put_volsw - single mixer put callback 1784 * snd_soc_put_volsw - single mixer put callback
1709 * @kcontrol: mixer control 1785 * @kcontrol: mixer control
1710 * @uinfo: control element information 1786 * @ucontrol: control element information
1711 * 1787 *
1712 * Callback to set the value of a single mixer control. 1788 * Callback to set the value of a single mixer control.
1713 * 1789 *
@@ -1775,7 +1851,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r);
1775/** 1851/**
1776 * snd_soc_get_volsw_2r - double mixer get callback 1852 * snd_soc_get_volsw_2r - double mixer get callback
1777 * @kcontrol: mixer control 1853 * @kcontrol: mixer control
1778 * @uinfo: control element information 1854 * @ucontrol: control element information
1779 * 1855 *
1780 * Callback to get the value of a double mixer control that spans 2 registers. 1856 * Callback to get the value of a double mixer control that spans 2 registers.
1781 * 1857 *
@@ -1812,7 +1888,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r);
1812/** 1888/**
1813 * snd_soc_put_volsw_2r - double mixer set callback 1889 * snd_soc_put_volsw_2r - double mixer set callback
1814 * @kcontrol: mixer control 1890 * @kcontrol: mixer control
1815 * @uinfo: control element information 1891 * @ucontrol: control element information
1816 * 1892 *
1817 * Callback to set the value of a double mixer control that spans 2 registers. 1893 * Callback to set the value of a double mixer control that spans 2 registers.
1818 * 1894 *
@@ -1882,7 +1958,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw_s8);
1882/** 1958/**
1883 * snd_soc_get_volsw_s8 - signed mixer get callback 1959 * snd_soc_get_volsw_s8 - signed mixer get callback
1884 * @kcontrol: mixer control 1960 * @kcontrol: mixer control
1885 * @uinfo: control element information 1961 * @ucontrol: control element information
1886 * 1962 *
1887 * Callback to get the value of a signed mixer control. 1963 * Callback to get the value of a signed mixer control.
1888 * 1964 *
@@ -1909,7 +1985,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_s8);
1909/** 1985/**
1910 * snd_soc_put_volsw_sgn - signed mixer put callback 1986 * snd_soc_put_volsw_sgn - signed mixer put callback
1911 * @kcontrol: mixer control 1987 * @kcontrol: mixer control
1912 * @uinfo: control element information 1988 * @ucontrol: control element information
1913 * 1989 *
1914 * Callback to set the value of a signed mixer control. 1990 * Callback to set the value of a signed mixer control.
1915 * 1991 *
@@ -1954,7 +2030,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
1954/** 2030/**
1955 * snd_soc_dai_set_clkdiv - configure DAI clock dividers. 2031 * snd_soc_dai_set_clkdiv - configure DAI clock dividers.
1956 * @dai: DAI 2032 * @dai: DAI
1957 * @clk_id: DAI specific clock divider ID 2033 * @div_id: DAI specific clock divider ID
1958 * @div: new clock divisor. 2034 * @div: new clock divisor.
1959 * 2035 *
1960 * Configures the clock dividers. This is used to derive the best DAI bit and 2036 * Configures the clock dividers. This is used to derive the best DAI bit and
@@ -2060,7 +2136,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
2060/** 2136/**
2061 * snd_soc_register_card - Register a card with the ASoC core 2137 * snd_soc_register_card - Register a card with the ASoC core
2062 * 2138 *
2063 * @param card Card to register 2139 * @card: Card to register
2064 * 2140 *
2065 * Note that currently this is an internal only function: it will be 2141 * Note that currently this is an internal only function: it will be
2066 * exposed to machine drivers after further backporting of ASoC v2 2142 * exposed to machine drivers after further backporting of ASoC v2
@@ -2087,7 +2163,7 @@ static int snd_soc_register_card(struct snd_soc_card *card)
2087/** 2163/**
2088 * snd_soc_unregister_card - Unregister a card with the ASoC core 2164 * snd_soc_unregister_card - Unregister a card with the ASoC core
2089 * 2165 *
2090 * @param card Card to unregister 2166 * @card: Card to unregister
2091 * 2167 *
2092 * Note that currently this is an internal only function: it will be 2168 * Note that currently this is an internal only function: it will be
2093 * exposed to machine drivers after further backporting of ASoC v2 2169 * exposed to machine drivers after further backporting of ASoC v2
@@ -2107,7 +2183,7 @@ static int snd_soc_unregister_card(struct snd_soc_card *card)
2107/** 2183/**
2108 * snd_soc_register_dai - Register a DAI with the ASoC core 2184 * snd_soc_register_dai - Register a DAI with the ASoC core
2109 * 2185 *
2110 * @param dai DAI to register 2186 * @dai: DAI to register
2111 */ 2187 */
2112int snd_soc_register_dai(struct snd_soc_dai *dai) 2188int snd_soc_register_dai(struct snd_soc_dai *dai)
2113{ 2189{
@@ -2134,7 +2210,7 @@ EXPORT_SYMBOL_GPL(snd_soc_register_dai);
2134/** 2210/**
2135 * snd_soc_unregister_dai - Unregister a DAI from the ASoC core 2211 * snd_soc_unregister_dai - Unregister a DAI from the ASoC core
2136 * 2212 *
2137 * @param dai DAI to unregister 2213 * @dai: DAI to unregister
2138 */ 2214 */
2139void snd_soc_unregister_dai(struct snd_soc_dai *dai) 2215void snd_soc_unregister_dai(struct snd_soc_dai *dai)
2140{ 2216{
@@ -2149,8 +2225,8 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
2149/** 2225/**
2150 * snd_soc_register_dais - Register multiple DAIs with the ASoC core 2226 * snd_soc_register_dais - Register multiple DAIs with the ASoC core
2151 * 2227 *
2152 * @param dai Array of DAIs to register 2228 * @dai: Array of DAIs to register
2153 * @param count Number of DAIs 2229 * @count: Number of DAIs
2154 */ 2230 */
2155int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count) 2231int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count)
2156{ 2232{
@@ -2175,8 +2251,8 @@ EXPORT_SYMBOL_GPL(snd_soc_register_dais);
2175/** 2251/**
2176 * snd_soc_unregister_dais - Unregister multiple DAIs from the ASoC core 2252 * snd_soc_unregister_dais - Unregister multiple DAIs from the ASoC core
2177 * 2253 *
2178 * @param dai Array of DAIs to unregister 2254 * @dai: Array of DAIs to unregister
2179 * @param count Number of DAIs 2255 * @count: Number of DAIs
2180 */ 2256 */
2181void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count) 2257void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count)
2182{ 2258{
@@ -2190,7 +2266,7 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dais);
2190/** 2266/**
2191 * snd_soc_register_platform - Register a platform with the ASoC core 2267 * snd_soc_register_platform - Register a platform with the ASoC core
2192 * 2268 *
2193 * @param platform platform to register 2269 * @platform: platform to register
2194 */ 2270 */
2195int snd_soc_register_platform(struct snd_soc_platform *platform) 2271int snd_soc_register_platform(struct snd_soc_platform *platform)
2196{ 2272{
@@ -2213,7 +2289,7 @@ EXPORT_SYMBOL_GPL(snd_soc_register_platform);
2213/** 2289/**
2214 * snd_soc_unregister_platform - Unregister a platform from the ASoC core 2290 * snd_soc_unregister_platform - Unregister a platform from the ASoC core
2215 * 2291 *
2216 * @param platform platform to unregister 2292 * @platform: platform to unregister
2217 */ 2293 */
2218void snd_soc_unregister_platform(struct snd_soc_platform *platform) 2294void snd_soc_unregister_platform(struct snd_soc_platform *platform)
2219{ 2295{
@@ -2228,7 +2304,7 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_platform);
2228/** 2304/**
2229 * snd_soc_register_codec - Register a codec with the ASoC core 2305 * snd_soc_register_codec - Register a codec with the ASoC core
2230 * 2306 *
2231 * @param codec codec to register 2307 * @codec: codec to register
2232 */ 2308 */
2233int snd_soc_register_codec(struct snd_soc_codec *codec) 2309int snd_soc_register_codec(struct snd_soc_codec *codec)
2234{ 2310{
@@ -2255,7 +2331,7 @@ EXPORT_SYMBOL_GPL(snd_soc_register_codec);
2255/** 2331/**
2256 * snd_soc_unregister_codec - Unregister a codec from the ASoC core 2332 * snd_soc_unregister_codec - Unregister a codec from the ASoC core
2257 * 2333 *
2258 * @param codec codec to unregister 2334 * @codec: codec to unregister
2259 */ 2335 */
2260void snd_soc_unregister_codec(struct snd_soc_codec *codec) 2336void snd_soc_unregister_codec(struct snd_soc_codec *codec)
2261{ 2337{
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 8863eddbac02..493a4e8aa273 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -53,13 +53,15 @@
53/* dapm power sequences - make this per codec in the future */ 53/* dapm power sequences - make this per codec in the future */
54static int dapm_up_seq[] = { 54static int dapm_up_seq[] = {
55 snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic, 55 snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic,
56 snd_soc_dapm_mux, snd_soc_dapm_dac, snd_soc_dapm_mixer, snd_soc_dapm_pga, 56 snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac,
57 snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_post 57 snd_soc_dapm_mixer, snd_soc_dapm_pga, snd_soc_dapm_adc, snd_soc_dapm_hp,
58 snd_soc_dapm_spk, snd_soc_dapm_post
58}; 59};
59static int dapm_down_seq[] = { 60static int dapm_down_seq[] = {
60 snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, 61 snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk,
61 snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic, 62 snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic,
62 snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_post 63 snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_value_mux,
64 snd_soc_dapm_post
63}; 65};
64 66
65static int dapm_status = 1; 67static int dapm_status = 1;
@@ -134,6 +136,25 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
134 } 136 }
135 } 137 }
136 break; 138 break;
139 case snd_soc_dapm_value_mux: {
140 struct soc_enum *e = (struct soc_enum *)
141 w->kcontrols[i].private_value;
142 int val, item;
143
144 val = snd_soc_read(w->codec, e->reg);
145 val = (val >> e->shift_l) & e->mask;
146 for (item = 0; item < e->max; item++) {
147 if (val == e->values[item])
148 break;
149 }
150
151 p->connect = 0;
152 for (i = 0; i < e->max; i++) {
153 if (!(strcmp(p->name, e->texts[i])) && item == i)
154 p->connect = 1;
155 }
156 }
157 break;
137 /* does not effect routing - always connected */ 158 /* does not effect routing - always connected */
138 case snd_soc_dapm_pga: 159 case snd_soc_dapm_pga:
139 case snd_soc_dapm_output: 160 case snd_soc_dapm_output:
@@ -653,6 +674,7 @@ static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action)
653 case snd_soc_dapm_vmid: 674 case snd_soc_dapm_vmid:
654 continue; 675 continue;
655 case snd_soc_dapm_mux: 676 case snd_soc_dapm_mux:
677 case snd_soc_dapm_value_mux:
656 case snd_soc_dapm_output: 678 case snd_soc_dapm_output:
657 case snd_soc_dapm_input: 679 case snd_soc_dapm_input:
658 case snd_soc_dapm_switch: 680 case snd_soc_dapm_switch:
@@ -960,6 +982,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
960 path->connect = 1; 982 path->connect = 1;
961 return 0; 983 return 0;
962 case snd_soc_dapm_mux: 984 case snd_soc_dapm_mux:
985 case snd_soc_dapm_value_mux:
963 ret = dapm_connect_mux(codec, wsource, wsink, path, control, 986 ret = dapm_connect_mux(codec, wsource, wsink, path, control,
964 &wsink->kcontrols[0]); 987 &wsink->kcontrols[0]);
965 if (ret != 0) 988 if (ret != 0)
@@ -1047,6 +1070,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
1047 dapm_new_mixer(codec, w); 1070 dapm_new_mixer(codec, w);
1048 break; 1071 break;
1049 case snd_soc_dapm_mux: 1072 case snd_soc_dapm_mux:
1073 case snd_soc_dapm_value_mux:
1050 dapm_new_mux(codec, w); 1074 dapm_new_mux(codec, w);
1051 break; 1075 break;
1052 case snd_soc_dapm_adc: 1076 case snd_soc_dapm_adc:
@@ -1077,7 +1101,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
1077/** 1101/**
1078 * snd_soc_dapm_get_volsw - dapm mixer get callback 1102 * snd_soc_dapm_get_volsw - dapm mixer get callback
1079 * @kcontrol: mixer control 1103 * @kcontrol: mixer control
1080 * @uinfo: control element information 1104 * @ucontrol: control element information
1081 * 1105 *
1082 * Callback to get the value of a dapm mixer control. 1106 * Callback to get the value of a dapm mixer control.
1083 * 1107 *
@@ -1122,7 +1146,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
1122/** 1146/**
1123 * snd_soc_dapm_put_volsw - dapm mixer set callback 1147 * snd_soc_dapm_put_volsw - dapm mixer set callback
1124 * @kcontrol: mixer control 1148 * @kcontrol: mixer control
1125 * @uinfo: control element information 1149 * @ucontrol: control element information
1126 * 1150 *
1127 * Callback to set the value of a dapm mixer control. 1151 * Callback to set the value of a dapm mixer control.
1128 * 1152 *
@@ -1193,7 +1217,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
1193/** 1217/**
1194 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback 1218 * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
1195 * @kcontrol: mixer control 1219 * @kcontrol: mixer control
1196 * @uinfo: control element information 1220 * @ucontrol: control element information
1197 * 1221 *
1198 * Callback to get the value of a dapm enumerated double mixer control. 1222 * Callback to get the value of a dapm enumerated double mixer control.
1199 * 1223 *
@@ -1221,7 +1245,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
1221/** 1245/**
1222 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback 1246 * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
1223 * @kcontrol: mixer control 1247 * @kcontrol: mixer control
1224 * @uinfo: control element information 1248 * @ucontrol: control element information
1225 * 1249 *
1226 * Callback to set the value of a dapm enumerated double mixer control. 1250 * Callback to set the value of a dapm enumerated double mixer control.
1227 * 1251 *
@@ -1274,6 +1298,103 @@ out:
1274EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double); 1298EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
1275 1299
1276/** 1300/**
1301 * snd_soc_dapm_get_value_enum_double - dapm semi enumerated double mixer get
1302 * callback
1303 * @kcontrol: mixer control
1304 * @ucontrol: control element information
1305 *
1306 * Callback to get the value of a dapm semi enumerated double mixer control.
1307 *
1308 * Semi enumerated mixer: the enumerated items are referred as values. Can be
1309 * used for handling bitfield coded enumeration for example.
1310 *
1311 * Returns 0 for success.
1312 */
1313int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol,
1314 struct snd_ctl_elem_value *ucontrol)
1315{
1316 struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
1317 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1318 unsigned short reg_val, val, mux;
1319
1320 reg_val = snd_soc_read(widget->codec, e->reg);
1321 val = (reg_val >> e->shift_l) & e->mask;
1322 for (mux = 0; mux < e->max; mux++) {
1323 if (val == e->values[mux])
1324 break;
1325 }
1326 ucontrol->value.enumerated.item[0] = mux;
1327 if (e->shift_l != e->shift_r) {
1328 val = (reg_val >> e->shift_r) & e->mask;
1329 for (mux = 0; mux < e->max; mux++) {
1330 if (val == e->values[mux])
1331 break;
1332 }
1333 ucontrol->value.enumerated.item[1] = mux;
1334 }
1335
1336 return 0;
1337}
1338EXPORT_SYMBOL_GPL(snd_soc_dapm_get_value_enum_double);
1339
1340/**
1341 * snd_soc_dapm_put_value_enum_double - dapm semi enumerated double mixer set
1342 * callback
1343 * @kcontrol: mixer control
1344 * @ucontrol: control element information
1345 *
1346 * Callback to set the value of a dapm semi enumerated double mixer control.
1347 *
1348 * Semi enumerated mixer: the enumerated items are referred as values. Can be
1349 * used for handling bitfield coded enumeration for example.
1350 *
1351 * Returns 0 for success.
1352 */
1353int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
1354 struct snd_ctl_elem_value *ucontrol)
1355{
1356 struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
1357 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
1358 unsigned short val, mux;
1359 unsigned short mask;
1360 int ret = 0;
1361
1362 if (ucontrol->value.enumerated.item[0] > e->max - 1)
1363 return -EINVAL;
1364 mux = ucontrol->value.enumerated.item[0];
1365 val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l;
1366 mask = e->mask << e->shift_l;
1367 if (e->shift_l != e->shift_r) {
1368 if (ucontrol->value.enumerated.item[1] > e->max - 1)
1369 return -EINVAL;
1370 val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r;
1371 mask |= e->mask << e->shift_r;
1372 }
1373
1374 mutex_lock(&widget->codec->mutex);
1375 widget->value = val;
1376 dapm_mux_update_power(widget, kcontrol, mask, mux, val, e);
1377 if (widget->event) {
1378 if (widget->event_flags & SND_SOC_DAPM_PRE_REG) {
1379 ret = widget->event(widget,
1380 kcontrol, SND_SOC_DAPM_PRE_REG);
1381 if (ret < 0)
1382 goto out;
1383 }
1384 ret = snd_soc_update_bits(widget->codec, e->reg, mask, val);
1385 if (widget->event_flags & SND_SOC_DAPM_POST_REG)
1386 ret = widget->event(widget,
1387 kcontrol, SND_SOC_DAPM_POST_REG);
1388 } else
1389 ret = snd_soc_update_bits(widget->codec, e->reg, mask, val);
1390
1391out:
1392 mutex_unlock(&widget->codec->mutex);
1393 return ret;
1394}
1395EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double);
1396
1397/**
1277 * snd_soc_dapm_new_control - create new dapm control 1398 * snd_soc_dapm_new_control - create new dapm control
1278 * @codec: audio codec 1399 * @codec: audio codec
1279 * @widget: widget template 1400 * @widget: widget template
@@ -1419,7 +1540,7 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
1419 1540
1420/** 1541/**
1421 * snd_soc_dapm_enable_pin - enable pin. 1542 * snd_soc_dapm_enable_pin - enable pin.
1422 * @snd_soc_codec: SoC codec 1543 * @codec: SoC codec
1423 * @pin: pin name 1544 * @pin: pin name
1424 * 1545 *
1425 * Enables input/output pin and it's parents or children widgets iff there is 1546 * Enables input/output pin and it's parents or children widgets iff there is