diff options
Diffstat (limited to 'sound/soc/codecs/max9867.c')
-rw-r--r-- | sound/soc/codecs/max9867.c | 95 |
1 files changed, 54 insertions, 41 deletions
diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 8600c5439e1e..c72cb2888c21 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -23,8 +23,21 @@ static const char *const max9867_spmode[] = { }; static const char *const max9867_filter_text[] = {"IIR", "FIR"}; +static const char *const max9867_adc_dac_filter_text[] = { + "Disabled", + "Elliptical/16/256", + "Butterworth/16/500", + "Elliptical/8/256", + "Butterworth/8/500", + "Butterworth/8-24" +}; + static SOC_ENUM_SINGLE_DECL(max9867_filter, MAX9867_CODECFLTR, 7, max9867_filter_text); +static SOC_ENUM_SINGLE_DECL(max9867_dac_filter, MAX9867_CODECFLTR, 0, + max9867_adc_dac_filter_text); +static SOC_ENUM_SINGLE_DECL(max9867_adc_filter, MAX9867_CODECFLTR, 4, + max9867_adc_dac_filter_text); static SOC_ENUM_SINGLE_DECL(max9867_spkmode, MAX9867_MODECONFIG, 0, max9867_spmode); static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(max9867_master_tlv, @@ -46,24 +59,27 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(max9867_micboost_tlv, static const struct snd_kcontrol_new max9867_snd_controls[] = { SOC_DOUBLE_R_TLV("Master Playback Volume", MAX9867_LEFTVOL, - MAX9867_RIGHTVOL, 0, 41, 1, max9867_master_tlv), + MAX9867_RIGHTVOL, 0, 40, 1, max9867_master_tlv), SOC_DOUBLE_R_TLV("Line Capture Volume", MAX9867_LEFTLINELVL, MAX9867_RIGHTLINELVL, 0, 15, 1, max9867_line_tlv), SOC_DOUBLE_R_TLV("Mic Capture Volume", MAX9867_LEFTMICGAIN, MAX9867_RIGHTMICGAIN, 0, 20, 1, max9867_mic_tlv), SOC_DOUBLE_R_TLV("Mic Boost Capture Volume", MAX9867_LEFTMICGAIN, - MAX9867_RIGHTMICGAIN, 5, 4, 0, max9867_micboost_tlv), + MAX9867_RIGHTMICGAIN, 5, 3, 0, max9867_micboost_tlv), SOC_SINGLE("Digital Sidetone Volume", MAX9867_SIDETONE, 0, 31, 1), SOC_SINGLE_TLV("Digital Playback Volume", MAX9867_DACLEVEL, 0, 15, 1, max9867_dac_tlv), SOC_SINGLE_TLV("Digital Boost Playback Volume", MAX9867_DACLEVEL, 4, 3, 0, max9867_dacboost_tlv), - SOC_DOUBLE_TLV("Digital Capture Volume", MAX9867_ADCLEVEL, 0, 4, 15, 1, + SOC_DOUBLE_TLV("Digital Capture Volume", MAX9867_ADCLEVEL, 4, 0, 15, 1, max9867_adc_tlv), SOC_ENUM("Speaker Mode", max9867_spkmode), SOC_SINGLE("Volume Smoothing Switch", MAX9867_MODECONFIG, 6, 1, 0), SOC_SINGLE("Line ZC Switch", MAX9867_MODECONFIG, 5, 1, 0), SOC_ENUM("DSP Filter", max9867_filter), + SOC_ENUM("ADC Filter", max9867_adc_filter), + SOC_ENUM("DAC Filter", max9867_dac_filter), + SOC_SINGLE("Mono Playback Switch", MAX9867_IFC1B, 3, 1, 0), }; /* Input mixer */ @@ -88,20 +104,38 @@ static const struct snd_kcontrol_new max9867_line_out_control = SOC_DAPM_DOUBLE_R("Switch", MAX9867_LEFTVOL, MAX9867_RIGHTVOL, 6, 1, 1); +/* DMIC mux */ +static const char *const dmic_mux_text[] = { + "ADC", "DMIC" +}; +static SOC_ENUM_SINGLE_DECL(left_dmic_mux_enum, + MAX9867_MICCONFIG, 5, dmic_mux_text); +static SOC_ENUM_SINGLE_DECL(right_dmic_mux_enum, + MAX9867_MICCONFIG, 4, dmic_mux_text); +static const struct snd_kcontrol_new max9867_left_dmic_mux = + SOC_DAPM_ENUM("DMICL Mux", left_dmic_mux_enum); +static const struct snd_kcontrol_new max9867_right_dmic_mux = + SOC_DAPM_ENUM("DMICR Mux", right_dmic_mux_enum); static const struct snd_soc_dapm_widget max9867_dapm_widgets[] = { SND_SOC_DAPM_INPUT("MICL"), SND_SOC_DAPM_INPUT("MICR"), + SND_SOC_DAPM_INPUT("DMICL"), + SND_SOC_DAPM_INPUT("DMICR"), SND_SOC_DAPM_INPUT("LINL"), SND_SOC_DAPM_INPUT("LINR"), - SND_SOC_DAPM_PGA("Left Line Input", MAX9867_PWRMAN, 6, 0, NULL, 0), - SND_SOC_DAPM_PGA("Right Line Input", MAX9867_PWRMAN, 5, 0, NULL, 0), + SND_SOC_DAPM_PGA("Left Line Input", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("Right Line Input", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER_NAMED_CTL("Input Mixer", SND_SOC_NOPM, 0, 0, max9867_input_mixer_controls, ARRAY_SIZE(max9867_input_mixer_controls)), - SND_SOC_DAPM_ADC("ADCL", "HiFi Capture", MAX9867_PWRMAN, 1, 0), - SND_SOC_DAPM_ADC("ADCR", "HiFi Capture", MAX9867_PWRMAN, 0, 0), + SND_SOC_DAPM_MUX("DMICL Mux", SND_SOC_NOPM, 0, 0, + &max9867_left_dmic_mux), + SND_SOC_DAPM_MUX("DMICR Mux", SND_SOC_NOPM, 0, 0, + &max9867_right_dmic_mux), + SND_SOC_DAPM_ADC("ADCL", "HiFi Capture", SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_ADC("ADCR", "HiFi Capture", SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_MIXER("Digital", SND_SOC_NOPM, 0, 0, max9867_sidetone_mixer_controls, @@ -109,8 +143,8 @@ static const struct snd_soc_dapm_widget max9867_dapm_widgets[] = { SND_SOC_DAPM_MIXER_NAMED_CTL("Output Mixer", SND_SOC_NOPM, 0, 0, max9867_output_mixer_controls, ARRAY_SIZE(max9867_output_mixer_controls)), - SND_SOC_DAPM_DAC("DACL", "HiFi Playback", MAX9867_PWRMAN, 3, 0), - SND_SOC_DAPM_DAC("DACR", "HiFi Playback", MAX9867_PWRMAN, 2, 0), + SND_SOC_DAPM_DAC("DACL", "HiFi Playback", SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_DAC("DACR", "HiFi Playback", SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_SWITCH("Master Playback", SND_SOC_NOPM, 0, 0, &max9867_line_out_control), SND_SOC_DAPM_OUTPUT("LOUT"), @@ -124,8 +158,12 @@ static const struct snd_soc_dapm_route max9867_audio_map[] = { {"Input Mixer", "Mic Capture Switch", "MICR"}, {"Input Mixer", "Line Capture Switch", "Left Line Input"}, {"Input Mixer", "Line Capture Switch", "Right Line Input"}, - {"ADCL", NULL, "Input Mixer"}, - {"ADCR", NULL, "Input Mixer"}, + {"DMICL Mux", "DMIC", "DMICL"}, + {"DMICR Mux", "DMIC", "DMICR"}, + {"DMICL Mux", "ADC", "Input Mixer"}, + {"DMICR Mux", "ADC", "Input Mixer"}, + {"ADCL", NULL, "DMICL Mux"}, + {"ADCR", NULL, "DMICR Mux"}, {"Digital", "Sidetone Switch", "ADCL"}, {"Digital", "Sidetone Switch", "ADCR"}, @@ -346,7 +384,8 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, } regmap_write(max9867->regmap, MAX9867_IFC1A, iface1A); - regmap_write(max9867->regmap, MAX9867_IFC1B, iface1B); + regmap_update_bits(max9867->regmap, MAX9867_IFC1B, + MAX9867_IFC1B_BCLK_MASK, iface1B); return 0; } @@ -413,15 +452,14 @@ static int max9867_set_bias_level(struct snd_soc_component *component, if (err) return err; - err = regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, - MAX9867_SHTDOWN, MAX9867_SHTDOWN); + err = regmap_write(max9867->regmap, + MAX9867_PWRMAN, 0xff); if (err) return err; } break; case SND_SOC_BIAS_OFF: - err = regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, - MAX9867_SHTDOWN, 0); + err = regmap_write(max9867->regmap, MAX9867_PWRMAN, 0); if (err) return err; @@ -463,35 +501,10 @@ static bool max9867_volatile_register(struct device *dev, unsigned int reg) } } -static const struct reg_default max9867_reg[] = { - { 0x04, 0x00 }, - { 0x05, 0x00 }, - { 0x06, 0x00 }, - { 0x07, 0x00 }, - { 0x08, 0x00 }, - { 0x09, 0x00 }, - { 0x0A, 0x00 }, - { 0x0B, 0x00 }, - { 0x0C, 0x00 }, - { 0x0D, 0x00 }, - { 0x0E, 0x40 }, - { 0x0F, 0x40 }, - { 0x10, 0x00 }, - { 0x11, 0x00 }, - { 0x12, 0x00 }, - { 0x13, 0x00 }, - { 0x14, 0x00 }, - { 0x15, 0x00 }, - { 0x16, 0x00 }, - { 0x17, 0x00 }, -}; - static const struct regmap_config max9867_regmap = { .reg_bits = 8, .val_bits = 8, .max_register = MAX9867_REVISION, - .reg_defaults = max9867_reg, - .num_reg_defaults = ARRAY_SIZE(max9867_reg), .volatile_reg = max9867_volatile_register, .cache_type = REGCACHE_RBTREE, }; |