diff options
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/atmel/sam9g20_wm8731.c | 4 | ||||
-rw-r--r-- | sound/soc/au1x/dbdma2.c | 2 | ||||
-rw-r--r-- | sound/soc/codecs/Kconfig | 20 | ||||
-rw-r--r-- | sound/soc/codecs/twl4030.c | 417 | ||||
-rw-r--r-- | sound/soc/codecs/twl4030.h | 7 | ||||
-rw-r--r-- | sound/soc/davinci/davinci-evm.c | 19 | ||||
-rw-r--r-- | sound/soc/davinci/davinci-pcm.c | 2 | ||||
-rw-r--r-- | sound/soc/davinci/davinci-sffsdr.c | 4 | ||||
-rw-r--r-- | sound/soc/omap/Kconfig | 1 | ||||
-rw-r--r-- | sound/soc/omap/omap3pandora.c | 13 | ||||
-rw-r--r-- | sound/soc/pxa/pxa2xx-pcm.c | 4 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 120 | ||||
-rw-r--r-- | sound/soc/soc-dapm.c | 137 |
13 files changed, 495 insertions, 255 deletions
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index 1fb59a9d371..6ea04be911d 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) snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon)); /* not connected */ - snd_soc_dapm_disable_pin(codec, "RLINEIN"); - snd_soc_dapm_disable_pin(codec, "LLINEIN"); + snd_soc_dapm_nc_pin(codec, "RLINEIN"); + snd_soc_dapm_nc_pin(codec, "LLINEIN"); /* always connected */ snd_soc_dapm_enable_pin(codec, "Int Mic"); diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index 74c823d60f9..bc8d654576c 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, au1x_pcm_dmatx_cb, (void *)pcd); if (!pcd->ddma_chan) - return -ENOMEM;; + return -ENOMEM; au1xxx_dbdma_set_devwidth(pcd->ddma_chan, msbits); au1xxx_dbdma_ring_alloc(pcd->ddma_chan, 2); diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index c41289b5f58..d0e0d691ae5 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -1,3 +1,13 @@ +# Helper to resolve issues with configs that have SPI enabled but I2C +# modular, meaning we can't build the codec driver in with I2C support. +# We use an ordered list of conditional defaults to pick the appropriate +# setting - SPI can't be modular so that case doesn't need to be covered. +config SND_SOC_I2C_AND_SPI + tristate + default m if I2C=m + default y if I2C=y + default y if SPI_MASTER=y + config SND_SOC_ALL_CODECS tristate "Build all ASoC CODEC drivers" select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS @@ -14,12 +24,12 @@ config SND_SOC_ALL_CODECS select SND_SOC_UDA134X select SND_SOC_UDA1380 if I2C select SND_SOC_WM8350 if MFD_WM8350 - select SND_SOC_WM8510 if (I2C || SPI_MASTER) + select SND_SOC_WM8510 if SND_SOC_I2C_AND_SPI select SND_SOC_WM8580 if I2C - select SND_SOC_WM8728 if (I2C || SPI_MASTER) - select SND_SOC_WM8731 if (I2C || SPI_MASTER) - select SND_SOC_WM8750 if (I2C || SPI_MASTER) - select SND_SOC_WM8753 if (I2C || SPI_MASTER) + select SND_SOC_WM8728 if SND_SOC_I2C_AND_SPI + select SND_SOC_WM8731 if SND_SOC_I2C_AND_SPI + select SND_SOC_WM8750 if SND_SOC_I2C_AND_SPI + select SND_SOC_WM8753 if SND_SOC_I2C_AND_SPI select SND_SOC_WM8900 if I2C select SND_SOC_WM8903 if I2C select SND_SOC_WM8971 if I2C diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 51848880504..ea370a4f86d 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) /* Earpiece */ static const char *twl4030_earpiece_texts[] = - {"Off", "DACL1", "DACL2", "Invalid", "DACR1"}; + {"Off", "DACL1", "DACL2", "DACR1"}; + +static const unsigned int twl4030_earpiece_values[] = + {0x0, 0x1, 0x2, 0x4}; static const struct soc_enum twl4030_earpiece_enum = - SOC_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, + SOC_VALUE_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, 0x7, ARRAY_SIZE(twl4030_earpiece_texts), - twl4030_earpiece_texts); + twl4030_earpiece_texts, + twl4030_earpiece_values); static const struct snd_kcontrol_new twl4030_dapm_earpiece_control = -SOC_DAPM_ENUM("Route", twl4030_earpiece_enum); +SOC_DAPM_VALUE_ENUM("Route", twl4030_earpiece_enum); /* PreDrive Left */ static const char *twl4030_predrivel_texts[] = - {"Off", "DACL1", "DACL2", "Invalid", "DACR2"}; + {"Off", "DACL1", "DACL2", "DACR2"}; + +static const unsigned int twl4030_predrivel_values[] = + {0x0, 0x1, 0x2, 0x4}; static const struct soc_enum twl4030_predrivel_enum = - SOC_ENUM_SINGLE(TWL4030_REG_PREDL_CTL, 1, + SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDL_CTL, 1, 0x7, ARRAY_SIZE(twl4030_predrivel_texts), - twl4030_predrivel_texts); + twl4030_predrivel_texts, + twl4030_predrivel_values); static const struct snd_kcontrol_new twl4030_dapm_predrivel_control = -SOC_DAPM_ENUM("Route", twl4030_predrivel_enum); +SOC_DAPM_VALUE_ENUM("Route", twl4030_predrivel_enum); /* PreDrive Right */ static const char *twl4030_predriver_texts[] = - {"Off", "DACR1", "DACR2", "Invalid", "DACL2"}; + {"Off", "DACR1", "DACR2", "DACL2"}; + +static const unsigned int twl4030_predriver_values[] = + {0x0, 0x1, 0x2, 0x4}; static const struct soc_enum twl4030_predriver_enum = - SOC_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, + SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, 0x7, ARRAY_SIZE(twl4030_predriver_texts), - twl4030_predriver_texts); + twl4030_predriver_texts, + twl4030_predriver_values); static const struct snd_kcontrol_new twl4030_dapm_predriver_control = -SOC_DAPM_ENUM("Route", twl4030_predriver_enum); +SOC_DAPM_VALUE_ENUM("Route", twl4030_predriver_enum); /* Headset Left */ static const char *twl4030_hsol_texts[] = @@ -298,28 +310,90 @@ static const struct soc_enum twl4030_handsfreer_enum = static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control = SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); -static int outmixer_event(struct snd_soc_dapm_widget *w, +/* Left analog microphone selection */ +static const char *twl4030_analoglmic_texts[] = + {"Off", "Main mic", "Headset mic", "AUXL", "Carkit mic"}; + +static const unsigned int twl4030_analoglmic_values[] = + {0x0, 0x1, 0x2, 0x4, 0x8}; + +static const struct soc_enum twl4030_analoglmic_enum = + SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICL, 0, 0xf, + ARRAY_SIZE(twl4030_analoglmic_texts), + twl4030_analoglmic_texts, + twl4030_analoglmic_values); + +static const struct snd_kcontrol_new twl4030_dapm_analoglmic_control = +SOC_DAPM_VALUE_ENUM("Route", twl4030_analoglmic_enum); + +/* Right analog microphone selection */ +static const char *twl4030_analogrmic_texts[] = + {"Off", "Sub mic", "AUXR"}; + +static const unsigned int twl4030_analogrmic_values[] = + {0x0, 0x1, 0x4}; + +static const struct soc_enum twl4030_analogrmic_enum = + SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICR, 0, 0x5, + ARRAY_SIZE(twl4030_analogrmic_texts), + twl4030_analogrmic_texts, + twl4030_analogrmic_values); + +static const struct snd_kcontrol_new twl4030_dapm_analogrmic_control = +SOC_DAPM_VALUE_ENUM("Route", twl4030_analogrmic_enum); + +/* TX1 L/R Analog/Digital microphone selection */ +static const char *twl4030_micpathtx1_texts[] = + {"Analog", "Digimic0"}; + +static const struct soc_enum twl4030_micpathtx1_enum = + SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 0, + ARRAY_SIZE(twl4030_micpathtx1_texts), + twl4030_micpathtx1_texts); + +static const struct snd_kcontrol_new twl4030_dapm_micpathtx1_control = +SOC_DAPM_ENUM("Route", twl4030_micpathtx1_enum); + +/* TX2 L/R Analog/Digital microphone selection */ +static const char *twl4030_micpathtx2_texts[] = + {"Analog", "Digimic1"}; + +static const struct soc_enum twl4030_micpathtx2_enum = + SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 2, + ARRAY_SIZE(twl4030_micpathtx2_texts), + twl4030_micpathtx2_texts); + +static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control = +SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum); + +static int micpath_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - int ret = 0; - int val; - - switch (e->reg) { - case TWL4030_REG_PREDL_CTL: - case TWL4030_REG_PREDR_CTL: - case TWL4030_REG_EAR_CTL: - val = w->value >> e->shift_l; - if (val == 3) { - printk(KERN_WARNING - "Invalid MUX setting for register 0x%02x (%d)\n", - e->reg, val); - ret = -1; - } - break; + struct soc_enum *e = (struct soc_enum *)w->kcontrols->private_value; + unsigned char adcmicsel, micbias_ctl; + + adcmicsel = twl4030_read_reg_cache(w->codec, TWL4030_REG_ADCMICSEL); + micbias_ctl = twl4030_read_reg_cache(w->codec, TWL4030_REG_MICBIAS_CTL); + /* Prepare the bits for the given TX path: + * shift_l == 0: TX1 microphone path + * shift_l == 2: TX2 microphone path */ + if (e->shift_l) { + /* TX2 microphone path */ + if (adcmicsel & TWL4030_TX2IN_SEL) + micbias_ctl |= TWL4030_MICBIAS2_CTL; /* digimic */ + else + micbias_ctl &= ~TWL4030_MICBIAS2_CTL; + } else { + /* TX1 microphone path */ + if (adcmicsel & TWL4030_TX1IN_SEL) + micbias_ctl |= TWL4030_MICBIAS1_CTL; /* digimic */ + else + micbias_ctl &= ~TWL4030_MICBIAS1_CTL; } - return ret; + twl4030_write(w->codec, TWL4030_REG_MICBIAS_CTL, micbias_ctl); + + return 0; } static 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, return err; } -static int twl4030_get_left_input(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = kcontrol->private_data; - u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); - int result = 0; - - /* one bit must be set a time */ - reg &= TWL4030_CKMIC_EN | TWL4030_AUXL_EN | TWL4030_HSMIC_EN - | TWL4030_MAINMIC_EN; - if (reg != 0) { - result++; - while ((reg & 1) == 0) { - result++; - reg >>= 1; - } - } - - ucontrol->value.integer.value[0] = result; - return 0; -} - -static int twl4030_put_left_input(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = kcontrol->private_data; - int value = ucontrol->value.integer.value[0]; - u8 anamicl, micbias, avadc_ctl; - - anamicl = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); - anamicl &= ~(TWL4030_CKMIC_EN | TWL4030_AUXL_EN | TWL4030_HSMIC_EN - | TWL4030_MAINMIC_EN); - micbias = twl4030_read_reg_cache(codec, TWL4030_REG_MICBIAS_CTL); - micbias &= ~(TWL4030_HSMICBIAS_EN | TWL4030_MICBIAS1_EN); - avadc_ctl = twl4030_read_reg_cache(codec, TWL4030_REG_AVADC_CTL); - - switch (value) { - case 1: - anamicl |= TWL4030_MAINMIC_EN; - micbias |= TWL4030_MICBIAS1_EN; - break; - case 2: - anamicl |= TWL4030_HSMIC_EN; - micbias |= TWL4030_HSMICBIAS_EN; - break; - case 3: - anamicl |= TWL4030_AUXL_EN; - break; - case 4: - anamicl |= TWL4030_CKMIC_EN; - break; - default: - break; - } - - /* If some input is selected, enable amp and ADC */ - if (value != 0) { - anamicl |= TWL4030_MICAMPL_EN; - avadc_ctl |= TWL4030_ADCL_EN; - } else { - anamicl &= ~TWL4030_MICAMPL_EN; - avadc_ctl &= ~TWL4030_ADCL_EN; - } - - twl4030_write(codec, TWL4030_REG_ANAMICL, anamicl); - twl4030_write(codec, TWL4030_REG_MICBIAS_CTL, micbias); - twl4030_write(codec, TWL4030_REG_AVADC_CTL, avadc_ctl); - - return 1; -} - -static int twl4030_get_right_input(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = kcontrol->private_data; - u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICR); - int value = 0; - - reg &= TWL4030_SUBMIC_EN|TWL4030_AUXR_EN; - switch (reg) { - case TWL4030_SUBMIC_EN: - value = 1; - break; - case TWL4030_AUXR_EN: - value = 2; - break; - default: - break; - } - - ucontrol->value.integer.value[0] = value; - return 0; -} - -static int twl4030_put_right_input(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = kcontrol->private_data; - int value = ucontrol->value.integer.value[0]; - u8 anamicr, micbias, avadc_ctl; - - anamicr = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICR); - anamicr &= ~(TWL4030_SUBMIC_EN|TWL4030_AUXR_EN); - micbias = twl4030_read_reg_cache(codec, TWL4030_REG_MICBIAS_CTL); - micbias &= ~TWL4030_MICBIAS2_EN; - avadc_ctl = twl4030_read_reg_cache(codec, TWL4030_REG_AVADC_CTL); - - switch (value) { - case 1: - anamicr |= TWL4030_SUBMIC_EN; - micbias |= TWL4030_MICBIAS2_EN; - break; - case 2: - anamicr |= TWL4030_AUXR_EN; - break; - default: - break; - } - - if (value != 0) { - anamicr |= TWL4030_MICAMPR_EN; - avadc_ctl |= TWL4030_ADCR_EN; - } else { - anamicr &= ~TWL4030_MICAMPR_EN; - avadc_ctl &= ~TWL4030_ADCR_EN; - } - - twl4030_write(codec, TWL4030_REG_ANAMICR, anamicr); - twl4030_write(codec, TWL4030_REG_MICBIAS_CTL, micbias); - twl4030_write(codec, TWL4030_REG_AVADC_CTL, avadc_ctl); - - return 1; -} - -static const char *twl4030_left_in_sel[] = { - "None", - "Main Mic", - "Headset Mic", - "Line In", - "Carkit Mic", -}; - -static const char *twl4030_right_in_sel[] = { - "None", - "Sub Mic", - "Line In", -}; - -static const struct soc_enum twl4030_left_input_mux = - SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(twl4030_left_in_sel), - twl4030_left_in_sel); - -static const struct soc_enum twl4030_right_input_mux = - SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(twl4030_right_in_sel), - twl4030_right_in_sel); - /* * FGAIN volume control: * 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[] = { TWL4030_REG_EAR_CTL, 4, 3, 0, output_tvl), /* Common capture gain controls */ - SOC_DOUBLE_R_TLV("Capture Volume", + SOC_DOUBLE_R_TLV("TX1 Digital Capture Volume", TWL4030_REG_ATXL1PGA, TWL4030_REG_ATXR1PGA, 0, 0x1f, 0, digital_capture_tlv), + SOC_DOUBLE_R_TLV("TX2 Digital Capture Volume", + TWL4030_REG_AVTXL2PGA, TWL4030_REG_AVTXR2PGA, + 0, 0x1f, 0, digital_capture_tlv), - SOC_DOUBLE_TLV("Input Boost Volume", TWL4030_REG_ANAMIC_GAIN, + SOC_DOUBLE_TLV("Analog Capture Volume", TWL4030_REG_ANAMIC_GAIN, 0, 3, 5, 0, input_gain_tlv), - - /* Input source controls */ - SOC_ENUM_EXT("Left Input Source", twl4030_left_input_mux, - twl4030_get_left_input, twl4030_put_left_input), - SOC_ENUM_EXT("Right Input Source", twl4030_right_input_mux, - twl4030_get_right_input, twl4030_put_right_input), }; /* add non dapm controls */ @@ -772,9 +687,19 @@ static int twl4030_add_controls(struct snd_soc_codec *codec) } static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { - SND_SOC_DAPM_INPUT("INL"), - SND_SOC_DAPM_INPUT("INR"), - + /* Left channel inputs */ + SND_SOC_DAPM_INPUT("MAINMIC"), + SND_SOC_DAPM_INPUT("HSMIC"), + SND_SOC_DAPM_INPUT("AUXL"), + SND_SOC_DAPM_INPUT("CARKITMIC"), + /* Right channel inputs */ + SND_SOC_DAPM_INPUT("SUBMIC"), + SND_SOC_DAPM_INPUT("AUXR"), + /* Digital microphones (Stereo) */ + SND_SOC_DAPM_INPUT("DIGIMIC0"), + SND_SOC_DAPM_INPUT("DIGIMIC1"), + + /* Outputs */ SND_SOC_DAPM_OUTPUT("OUTL"), SND_SOC_DAPM_OUTPUT("OUTR"), SND_SOC_DAPM_OUTPUT("EARPIECE"), @@ -809,16 +734,13 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { /* Output MUX controls */ /* Earpiece */ - SND_SOC_DAPM_MUX_E("Earpiece Mux", SND_SOC_NOPM, 0, 0, - &twl4030_dapm_earpiece_control, outmixer_event, - SND_SOC_DAPM_PRE_REG), + SND_SOC_DAPM_VALUE_MUX("Earpiece Mux", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_earpiece_control), /* PreDrivL/R */ - SND_SOC_DAPM_MUX_E("PredriveL Mux", SND_SOC_NOPM, 0, 0, - &twl4030_dapm_predrivel_control, outmixer_event, - SND_SOC_DAPM_PRE_REG), - SND_SOC_DAPM_MUX_E("PredriveR Mux", SND_SOC_NOPM, 0, 0, - &twl4030_dapm_predriver_control, outmixer_event, - SND_SOC_DAPM_PRE_REG), + SND_SOC_DAPM_VALUE_MUX("PredriveL Mux", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_predrivel_control), + SND_SOC_DAPM_VALUE_MUX("PredriveR Mux", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_predriver_control), /* HeadsetL/R */ SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0, &twl4030_dapm_hsol_control), @@ -837,8 +759,48 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { &twl4030_dapm_handsfreer_control, handsfree_event, SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), - SND_SOC_DAPM_ADC("ADCL", "Left Capture", SND_SOC_NOPM, 0, 0), - SND_SOC_DAPM_ADC("ADCR", "Right Capture", SND_SOC_NOPM, 0, 0), + /* Introducing four virtual ADC, since TWL4030 have four channel for + capture */ + SND_SOC_DAPM_ADC("ADC Virtual Left1", "Left Front Capture", + SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_ADC("ADC Virtual Right1", "Right Front Capture", + SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_ADC("ADC Virtual Left2", "Left Rear Capture", + SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_ADC("ADC Virtual Right2", "Right Rear Capture", + SND_SOC_NOPM, 0, 0), + + /* Analog/Digital mic path selection. + TX1 Left/Right: either analog Left/Right or Digimic0 + TX2 Left/Right: either analog Left/Right or Digimic1 */ + SND_SOC_DAPM_MUX_E("TX1 Capture Route", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_micpathtx1_control, micpath_event, + SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD| + SND_SOC_DAPM_POST_REG), + SND_SOC_DAPM_MUX_E("TX2 Capture Route", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_micpathtx2_control, micpath_event, + SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD| + SND_SOC_DAPM_POST_REG), + + /* Analog input muxes with power switch for the physical ADCL/R */ + SND_SOC_DAPM_VALUE_MUX("Analog Left Capture Route", + TWL4030_REG_AVADC_CTL, 3, 0, &twl4030_dapm_analoglmic_control), + SND_SOC_DAPM_VALUE_MUX("Analog Right Capture Route", + TWL4030_REG_AVADC_CTL, 1, 0, &twl4030_dapm_analogrmic_control), + + SND_SOC_DAPM_PGA("Analog Left Amplifier", + TWL4030_REG_ANAMICL, 4, 0, NULL, 0), + SND_SOC_DAPM_PGA("Analog Right Amplifier", + TWL4030_REG_ANAMICR, 4, 0, NULL, 0), + + SND_SOC_DAPM_PGA("Digimic0 Enable", + TWL4030_REG_ADCMICSEL, 1, 0, NULL, 0), + SND_SOC_DAPM_PGA("Digimic1 Enable", + TWL4030_REG_ADCMICSEL, 3, 0, NULL, 0), + + SND_SOC_DAPM_MICBIAS("Mic Bias 1", TWL4030_REG_MICBIAS_CTL, 0, 0), + SND_SOC_DAPM_MICBIAS("Mic Bias 2", TWL4030_REG_MICBIAS_CTL, 1, 0), + SND_SOC_DAPM_MICBIAS("Headset Mic Bias", TWL4030_REG_MICBIAS_CTL, 2, 0), }; static const struct snd_soc_dapm_route intercon[] = { @@ -894,9 +856,39 @@ static const struct snd_soc_dapm_route intercon[] = { {"HFL", NULL, "HandsfreeL Mux"}, {"HFR", NULL, "HandsfreeR Mux"}, - /* inputs */ - {"ADCL", NULL, "INL"}, - {"ADCR", NULL, "INR"}, + /* Capture path */ + {"Analog Left Capture Route", "Main mic", "MAINMIC"}, + {"Analog Left Capture Route", "Headset mic", "HSMIC"}, + {"Analog Left Capture Route", "AUXL", "AUXL"}, + {"Analog Left Capture Route", "Carkit mic", "CARKITMIC"}, + + {"Analog Right Capture Route", "Sub mic", "SUBMIC"}, + {"Analog Right Capture Route", "AUXR", "AUXR"}, + + {"Analog Left Amplifier", NULL, "Analog Left Capture Route"}, + {"Analog Right Amplifier", NULL, "Analog Right Capture Route"}, + + {"Digimic0 Enable", NULL, "DIGIMIC0"}, + {"Digimic1 Enable", NULL, "DIGIMIC1"}, + + /* TX1 Left capture path */ + {"TX1 Capture Route", "Analog", "Analog Left Amplifier"}, + {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"}, + /* TX1 Right capture path */ + {"TX1 Capture Route", "Analog", "Analog Right Amplifier"}, + {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"}, + /* TX2 Left capture path */ + {"TX2 Capture Route", "Analog", "Analog Left Amplifier"}, + {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"}, + /* TX2 Right capture path */ + {"TX2 Capture Route", "Analog", "Analog Right Amplifier"}, + {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"}, + + {"ADC Virtual Left1", NULL, "TX1 Capture Route"}, + {"ADC Virtual Right1", NULL, "TX1 Capture Route"}, + {"ADC Virtual Left2", NULL, "TX2 Capture Route"}, + {"ADC Virtual Right2", NULL, "TX2 Capture Route"}, + }; static int twl4030_add_widgets(struct snd_soc_codec *codec) @@ -923,6 +915,7 @@ static void twl4030_power_up(struct snd_soc_codec *codec) twl4030_write(codec, TWL4030_REG_ANAMICL, anamicl | TWL4030_CNCL_OFFSET_START); + /* wait for offset cancellation to complete */ do { /* this takes a little while, so don't slam i2c */ @@ -1287,6 +1280,8 @@ static int twl4030_remove(struct platform_device *pdev) struct snd_soc_codec *codec = socdev->codec; printk(KERN_INFO "TWL4030 Audio Codec remove\n"); + snd_soc_free_pcms(socdev); + snd_soc_dapm_free(socdev); kfree(codec); return 0; diff --git a/sound/soc/codecs/twl4030.h b/sound/soc/codecs/twl4030.h index 54615c76802..442e5a82861 100644 --- a/sound/soc/codecs/twl4030.h +++ b/sound/soc/codecs/twl4030.h @@ -147,6 +147,13 @@ #define TWL4030_AVADC_CLK_PRIORITY 0x04 #define TWL4030_ADCR_EN 0x02 +/* TWL4030_REG_ADCMICSEL (0x08) Fields */ + +#define TWL4030_DIGMIC1_EN 0x08 +#define TWL4030_TX2IN_SEL 0x04 +#define TWL4030_DIGMIC0_EN 0x02 +#define TWL4030_TX1IN_SEL 0x01 + /* AUDIO_IF (0x0E) Fields */ #define TWL4030_AIF_SLAVE_EN 0x80 diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 01b948bb55a..54851f31856 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -26,7 +26,6 @@ #include "davinci-pcm.h" #include "davinci-i2s.h" -#define EVM_CODEC_CLOCK 22579200 #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF) @@ -37,6 +36,21 @@ static int evm_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; int ret = 0; + unsigned sysclk; + + /* ASP1 on DM355 EVM is clocked by an external oscillator */ + if (machine_is_davinci_dm355_evm()) + sysclk = 27000000; + + /* ASP0 in DM6446 EVM is clocked by U55, as configured by + * board-dm644x-evm.c using GPIOs from U18. There are six + * options; here we "know" we use a 48 KHz sample rate. + */ + else if (machine_is_davinci_evm()) + sysclk = 12288000; + + else + return -EINVAL; /* set codec DAI configuration */ ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT); @@ -49,8 +63,7 @@ static int evm_hw_params(struct snd_pcm_substream *substream, return ret; /* set the codec system clock */ - ret = snd_soc_dai_set_sysclk(codec_dai, 0, EVM_CODEC_CLOCK, - SND_SOC_CLOCK_OUT); + ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT); if (ret < 0) return ret; diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index 74abc9b4f1c..366049d8578 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) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) count = src - runtime->dma_addr; else - count = dst - runtime->dma_addr;; + count = dst - runtime->dma_addr; spin_unlock(&prtd->lock); diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c index f67579d5276..4935d1bcbd8 100644 --- a/sound/soc/davinci/davinci-sffsdr.c +++ b/sound/soc/davinci/davinci-sffsdr.c @@ -24,6 +24,7 @@ #include <sound/soc-dapm.h> #include <asm/dma.h> +#include <asm/mach-types.h> #include <asm/plat-sffsdr/sffsdr-fpga.h> #include <mach/mcbsp.h> @@ -115,6 +116,9 @@ static int __init sffsdr_init(void) { int ret; + if (!machine_is_sffsdr()) + return -EINVAL; + sffsdr_snd_device = platform_device_alloc("soc-audio", 0); if (!sffsdr_snd_device) { printk(KERN_ERR "platform device allocation failed\n"); diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index a7b1d77b210..4f7f0401458 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -10,6 +10,7 @@ config SND_OMAP_SOC_N810 tristate "SoC Audio support for Nokia N810" depends on SND_OMAP_SOC && MACH_NOKIA_N810 select SND_OMAP_SOC_MCBSP + select OMAP_MUX select SND_SOC_TLV320AIC3X help 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 bd91594496b..fcc2f5d9a87 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) { int ret; + /* All TWL4030 output pins are floating */ + snd_soc_dapm_nc_pin(codec, "OUTL"), + snd_soc_dapm_nc_pin(codec, "OUTR"), + snd_soc_dapm_nc_pin(codec, "EARPIECE"), + snd_soc_dapm_nc_pin(codec, "PREDRIVEL"), + snd_soc_dapm_nc_pin(codec, "PREDRIVER"), + snd_soc_dapm_nc_pin(codec, "HSOL"), + snd_soc_dapm_nc_pin(codec, "HSOR"), + snd_soc_dapm_nc_pin(codec, "CARKITL"), + snd_soc_dapm_nc_pin(codec, "CARKITR"), + snd_soc_dapm_nc_pin(codec, "HFL"), + snd_soc_dapm_nc_pin(codec, "HFR"), + ret = snd_soc_dapm_new_controls(codec, omap3pandora_in_dapm_widgets, ARRAY_SIZE(omap3pandora_in_dapm_widgets)); if (ret < 0) diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c index c670d08e7c9..53b9fb127a6 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) __pxa2xx_pcm_hw_free(substream); - if (prtd->dma_ch) { + if (prtd->dma_ch >= 0) { pxa_free_dma(prtd->dma_ch); - prtd->dma_ch = 0; + prtd->dma_ch = -1; } return 0; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b098c0b4c58..55fdb4abb17 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1300,6 +1300,8 @@ EXPORT_SYMBOL_GPL(snd_soc_test_bits); /** * snd_soc_new_pcms - create new sound card and pcms * @socdev: the SoC audio device + * @idx: ALSA card index + * @xid: card identification * * Create a new sound card based upon the codec and interface pcms. * @@ -1472,7 +1474,7 @@ EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams); * snd_soc_cnew - create new control * @_template: control template * @data: control private data - * @lnng_name: control long name + * @long_name: control long name * * Create a new mixer control from a template control. * @@ -1522,7 +1524,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_enum_double); /** * snd_soc_get_enum_double - enumerated double mixer get callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to get the value of a double enumerated mixer. * @@ -1551,7 +1553,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_enum_double); /** * snd_soc_put_enum_double - enumerated double mixer put callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to set the value of a double enumerated mixer. * @@ -1583,6 +1585,80 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol, EXPORT_SYMBOL_GPL(snd_soc_put_enum_double); /** + * snd_soc_get_value_enum_double - semi enumerated double mixer get callback + * @kcontrol: mixer control + * @ucontrol: control element information + * + * Callback to get the value of a double semi enumerated mixer. + * + * Semi enumerated mixer: the enumerated items are referred as values. Can be + * used for handling bitfield coded enumeration for example. + * + * Returns 0 for success. + */ +int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned short reg_val, val, mux; + + reg_val = snd_soc_read(codec, e->reg); + val = (reg_val >> e->shift_l) & e->mask; + for (mux = 0; mux < e->max; mux++) { + if (val == e->values[mux]) + break; + } + ucontrol->value.enumerated.item[0] = mux; + if (e->shift_l != e->shift_r) { + val = (reg_val >> e->shift_r) & e->mask; + for (mux = 0; mux < e->max; mux++) { + if (val == e->values[mux]) + break; + } + ucontrol->value.enumerated.item[1] = mux; + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_get_value_enum_double); + +/** + * snd_soc_put_value_enum_double - semi enumerated double mixer put callback + * @kcontrol: mixer control + * @ucontrol: control element information + * + * Callback to set the value of a double semi enumerated mixer. + * + * Semi enumerated mixer: the enumerated items are referred as values. Can be + * used for handling bitfield coded enumeration for example. + * + * Returns 0 for success. + */ +int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned short val; + unsigned short mask; + + if (ucontrol->value.enumerated.item[0] > e->max - 1) + return -EINVAL; + val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l; + mask = e->mask << e->shift_l; + if (e->shift_l != e->shift_r) { + if (ucontrol->value.enumerated.item[1] > e->max - 1) + return -EINVAL; + val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r; + mask |= e->mask << e->shift_r; + } + + return snd_soc_update_bits(codec, e->reg, mask, val); +} +EXPORT_SYMBOL_GPL(snd_soc_put_value_enum_double); + +/** * snd_soc_info_enum_ext - external enumerated single mixer info callback * @kcontrol: mixer control * @uinfo: control element information @@ -1668,7 +1744,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw); /** * snd_soc_get_volsw - single mixer get callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to get the value of a single mixer control. * @@ -1707,7 +1783,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw); /** * snd_soc_put_volsw - single mixer put callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to set the value of a single mixer control. * @@ -1775,7 +1851,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw_2r); /** * snd_soc_get_volsw_2r - double mixer get callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to get the value of a double mixer control that spans 2 registers. * @@ -1812,7 +1888,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_2r); /** * snd_soc_put_volsw_2r - double mixer set callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to set the value of a double mixer control that spans 2 registers. * @@ -1882,7 +1958,7 @@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw_s8); /** * snd_soc_get_volsw_s8 - signed mixer get callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to get the value of a signed mixer control. * @@ -1909,7 +1985,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_s8); /** * snd_soc_put_volsw_sgn - signed mixer put callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to set the value of a signed mixer control. * @@ -1954,7 +2030,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk); /** * snd_soc_dai_set_clkdiv - configure DAI clock dividers. * @dai: DAI - * @clk_id: DAI specific clock divider ID + * @div_id: DAI specific clock divider ID * @div: new clock divisor. * * 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); /** * snd_soc_register_card - Register a card with the ASoC core * - * @param card Card to register + * @card: Card to register * * Note that currently this is an internal only function: it will be * 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) /** * snd_soc_unregister_card - Unregister a card with the ASoC core * - * @param card Card to unregister + * @card: Card to unregister * * Note that currently this is an internal only function: it will be * 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) /** * snd_soc_register_dai - Register a DAI with the ASoC core * - * @param dai DAI to register + * @dai: DAI to register */ int snd_soc_register_dai(struct snd_soc_dai *dai) { @@ -2134,7 +2210,7 @@ EXPORT_SYMBOL_GPL(snd_soc_register_dai); /** * snd_soc_unregister_dai - Unregister a DAI from the ASoC core * - * @param dai DAI to unregister + * @dai: DAI to unregister */ void snd_soc_unregister_dai(struct snd_soc_dai *dai) { @@ -2149,8 +2225,8 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dai); /** * snd_soc_register_dais - Register multiple DAIs with the ASoC core * - * @param dai Array of DAIs to register - * @param count Number of DAIs + * @dai: Array of DAIs to register + * @count: Number of DAIs */ int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count) { @@ -2175,8 +2251,8 @@ EXPORT_SYMBOL_GPL(snd_soc_register_dais); /** * snd_soc_unregister_dais - Unregister multiple DAIs from the ASoC core * - * @param dai Array of DAIs to unregister - * @param count Number of DAIs + * @dai: Array of DAIs to unregister + * @count: Number of DAIs */ void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count) { @@ -2190,7 +2266,7 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_dais); /** * snd_soc_register_platform - Register a platform with the ASoC core * - * @param platform platform to register + * @platform: platform to register */ int snd_soc_register_platform(struct snd_soc_platform *platform) { @@ -2213,7 +2289,7 @@ EXPORT_SYMBOL_GPL(snd_soc_register_platform); /** * snd_soc_unregister_platform - Unregister a platform from the ASoC core * - * @param platform platform to unregister + * @platform: platform to unregister */ void snd_soc_unregister_platform(struct snd_soc_platform *platform) { @@ -2228,7 +2304,7 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); /** * snd_soc_register_codec - Register a codec with the ASoC core * - * @param codec codec to register + * @codec: codec to register */ int snd_soc_register_codec(struct snd_soc_codec *codec) { @@ -2255,7 +2331,7 @@ EXPORT_SYMBOL_GPL(snd_soc_register_codec); /** * snd_soc_unregister_codec - Unregister a codec from the ASoC core * - * @param codec codec to unregister + * @codec: codec to unregister */ void snd_soc_unregister_codec(struct snd_soc_codec *codec) { diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 8863eddbac0..493a4e8aa27 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -53,13 +53,15 @@ /* dapm power sequences - make this per codec in the future */ static int dapm_up_seq[] = { snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic, - snd_soc_dapm_mux, snd_soc_dapm_dac, snd_soc_dapm_mixer, snd_soc_dapm_pga, - snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_post + snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac, + snd_soc_dapm_mixer, snd_soc_dapm_pga, snd_soc_dapm_adc, snd_soc_dapm_hp, + snd_soc_dapm_spk, snd_soc_dapm_post }; static int dapm_down_seq[] = { snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic, - snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_post + snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_value_mux, + snd_soc_dapm_post }; static int dapm_status = 1; @@ -134,6 +136,25 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, } } break; + case snd_soc_dapm_value_mux: { + struct soc_enum *e = (struct soc_enum *) + w->kcontrols[i].private_value; + int val, item; + + val = snd_soc_read(w->codec, e->reg); + val = (val >> e->shift_l) & e->mask; + for (item = 0; item < e->max; item++) { + if (val == e->values[item]) + break; + } + + p->connect = 0; + for (i = 0; i < e->max; i++) { + if (!(strcmp(p->name, e->texts[i])) && item == i) + p->connect = 1; + } + } + break; /* does not effect routing - always connected */ case snd_soc_dapm_pga: case snd_soc_dapm_output: @@ -653,6 +674,7 @@ static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action) case snd_soc_dapm_vmid: continue; case snd_soc_dapm_mux: + case snd_soc_dapm_value_mux: case snd_soc_dapm_output: case snd_soc_dapm_input: case snd_soc_dapm_switch: @@ -960,6 +982,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec, path->connect = 1; return 0; case snd_soc_dapm_mux: + case snd_soc_dapm_value_mux: ret = dapm_connect_mux(codec, wsource, wsink, path, control, &wsink->kcontrols[0]); if (ret != 0) @@ -1047,6 +1070,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec) dapm_new_mixer(codec, w); break; case snd_soc_dapm_mux: + case snd_soc_dapm_value_mux: dapm_new_mux(codec, w); break; case snd_soc_dapm_adc: @@ -1077,7 +1101,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets); /** * snd_soc_dapm_get_volsw - dapm mixer get callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to get the value of a dapm mixer control. * @@ -1122,7 +1146,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw); /** * snd_soc_dapm_put_volsw - dapm mixer set callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to set the value of a dapm mixer control. * @@ -1193,7 +1217,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw); /** * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to get the value of a dapm enumerated double mixer control. * @@ -1221,7 +1245,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double); /** * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback * @kcontrol: mixer control - * @uinfo: control element information + * @ucontrol: control element information * * Callback to set the value of a dapm enumerated double mixer control. * @@ -1274,6 +1298,103 @@ out: EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double); /** + * snd_soc_dapm_get_value_enum_double - dapm semi enumerated double mixer get + * callback + * @kcontrol: mixer control + * @ucontrol: control element information + * + * Callback to get the value of a dapm semi enumerated double mixer control. + * + * Semi enumerated mixer: the enumerated items are referred as values. Can be + * used for handling bitfield coded enumeration for example. + * + * Returns 0 for success. + */ +int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned short reg_val, val, mux; + + reg_val = snd_soc_read(widget->codec, e->reg); + val = (reg_val >> e->shift_l) & e->mask; + for (mux = 0; mux < e->max; mux++) { + if (val == e->values[mux]) + break; + } + ucontrol->value.enumerated.item[0] = mux; + if (e->shift_l != e->shift_r) { + val = (reg_val >> e->shift_r) & e->mask; + for (mux = 0; mux < e->max; mux++) { + if (val == e->values[mux]) + break; + } + ucontrol->value.enumerated.item[1] = mux; + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_get_value_enum_double); + +/** + * snd_soc_dapm_put_value_enum_double - dapm semi enumerated double mixer set + * callback + * @kcontrol: mixer control + * @ucontrol: control element information + * + * Callback to set the value of a dapm semi enumerated double mixer control. + * + * Semi enumerated mixer: the enumerated items are referred as values. Can be + * used for handling bitfield coded enumeration for example. + * + * Returns 0 for success. + */ +int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned short val, mux; + unsigned short mask; + int ret = 0; + + if (ucontrol->value.enumerated.item[0] > e->max - 1) + return -EINVAL; + mux = ucontrol->value.enumerated.item[0]; + val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l; + mask = e->mask << e->shift_l; + if (e->shift_l != e->shift_r) { + if (ucontrol->value.enumerated.item[1] > e->max - 1) + return -EINVAL; + val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r; + mask |= e->mask << e->shift_r; + } + + mutex_lock(&widget->codec->mutex); + widget->value = val; + dapm_mux_update_power(widget, kcontrol, mask, mux, val, e); + if (widget->event) { + if (widget->event_flags & SND_SOC_DAPM_PRE_REG) { + ret = widget->event(widget, + kcontrol, SND_SOC_DAPM_PRE_REG); + if (ret < 0) + goto out; + } + ret = snd_soc_update_bits(widget->codec, e->reg, mask, val); + if (widget->event_flags & SND_SOC_DAPM_POST_REG) + ret = widget->event(widget, + kcontrol, SND_SOC_DAPM_POST_REG); + } else + ret = snd_soc_update_bits(widget->codec, e->reg, mask, val); + +out: + mutex_unlock(&widget->codec->mutex); + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double); + +/** * snd_soc_dapm_new_control - create new dapm control * @codec: audio codec * @widget: widget template @@ -1419,7 +1540,7 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev, /** * snd_soc_dapm_enable_pin - enable pin. - * @snd_soc_codec: SoC codec + * @codec: SoC codec * @pin: pin name * * Enables input/output pin and it's parents or children widgets iff there is |