diff options
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/Kconfig | 20 | ||||
-rw-r--r-- | sound/soc/codecs/twl4030.c | 118 |
2 files changed, 70 insertions, 68 deletions
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 @@ +# 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 31e44e346dc8..fd0f338374a7 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 struct soc_enum twl4030_earpiece_enum = - SOC_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, +static const unsigned int twl4030_earpiece_values[] = + {0x0, 0x1, 0x2, 0x4}; + +static const struct soc_value_enum twl4030_earpiece_enum = + 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, +static const struct soc_value_enum twl4030_predrivel_enum = + 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 struct soc_enum twl4030_predriver_enum = - SOC_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, +static const unsigned int twl4030_predriver_values[] = + {0x0, 0x1, 0x2, 0x4}; + +static const struct soc_value_enum twl4030_predriver_enum = + 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[] = @@ -300,28 +312,35 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); /* Left analog microphone selection */ static const char *twl4030_analoglmic_texts[] = - {"Off", "Main mic", "Headset mic", "Invalid", "AUXL", - "Invalid", "Invalid", "Invalid", "Carkit mic"}; + {"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_ENUM_SINGLE(TWL4030_REG_ANAMICL, 0, +static const struct soc_value_enum twl4030_analoglmic_enum = + SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICL, 0, 0xf, ARRAY_SIZE(twl4030_analoglmic_texts), - twl4030_analoglmic_texts); + twl4030_analoglmic_texts, + twl4030_analoglmic_values); static const struct snd_kcontrol_new twl4030_dapm_analoglmic_control = -SOC_DAPM_ENUM("Route", twl4030_analoglmic_enum); +SOC_DAPM_VALUE_ENUM("Route", twl4030_analoglmic_enum); /* Right analog microphone selection */ static const char *twl4030_analogrmic_texts[] = - {"Off", "Sub mic", "Invalid", "Invalid", "AUXR"}; + {"Off", "Sub mic", "AUXR"}; -static const struct soc_enum twl4030_analogrmic_enum = - SOC_ENUM_SINGLE(TWL4030_REG_ANAMICR, 0, +static const unsigned int twl4030_analogrmic_values[] = + {0x0, 0x1, 0x4}; + +static const struct soc_value_enum twl4030_analogrmic_enum = + SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICR, 0, 0x5, ARRAY_SIZE(twl4030_analogrmic_texts), - twl4030_analogrmic_texts); + twl4030_analogrmic_texts, + twl4030_analogrmic_values); static const struct snd_kcontrol_new twl4030_dapm_analogrmic_control = -SOC_DAPM_ENUM("Route", twl4030_analogrmic_enum); +SOC_DAPM_VALUE_ENUM("Route", twl4030_analogrmic_enum); /* TX1 L/R Analog/Digital microphone selection */ static const char *twl4030_micpathtx1_texts[] = @@ -347,28 +366,6 @@ static const struct soc_enum twl4030_micpathtx2_enum = static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control = SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum); -/* - * This function filters out the non valid mux settings, named as "Invalid" - * in the enum texts. - * Just refuse to set an invalid mux mode. - */ -static int twl4030_enum_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; - - val = w->value >> e->shift_l; - if (!strcmp("Invalid", e->texts[val])) { - printk(KERN_WARNING "Invalid MUX setting on 0x%02x (%d)\n", - e->reg, val); - ret = -1; - } - - return ret; -} - static int micpath_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -737,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, twl4030_enum_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, twl4030_enum_event, - SND_SOC_DAPM_PRE_REG), - SND_SOC_DAPM_MUX_E("PredriveR Mux", SND_SOC_NOPM, 0, 0, - &twl4030_dapm_predriver_control, twl4030_enum_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), @@ -789,12 +783,10 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { SND_SOC_DAPM_POST_REG), /* Analog input muxes with power switch for the physical ADCL/R */ - SND_SOC_DAPM_MUX_E("Analog Left Capture Route", - TWL4030_REG_AVADC_CTL, 3, 0, &twl4030_dapm_analoglmic_control, - twl4030_enum_event, SND_SOC_DAPM_PRE_REG), - SND_SOC_DAPM_MUX_E("Analog Right Capture Route", - TWL4030_REG_AVADC_CTL, 1, 0, &twl4030_dapm_analogrmic_control, - twl4030_enum_event, SND_SOC_DAPM_PRE_REG), + 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), |