diff options
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/da7210.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index fa0d5125e70b..4aad01c10c53 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #define DA7210_STARTUP1 0x03 | 30 | #define DA7210_STARTUP1 0x03 |
31 | #define DA7210_MIC_L 0x07 | 31 | #define DA7210_MIC_L 0x07 |
32 | #define DA7210_MIC_R 0x08 | 32 | #define DA7210_MIC_R 0x08 |
33 | #define DA7210_AUX2 0x0B | ||
33 | #define DA7210_INMIX_L 0x0D | 34 | #define DA7210_INMIX_L 0x0D |
34 | #define DA7210_INMIX_R 0x0E | 35 | #define DA7210_INMIX_R 0x0E |
35 | #define DA7210_ADC_HPF 0x0F | 36 | #define DA7210_ADC_HPF 0x0F |
@@ -41,6 +42,7 @@ | |||
41 | #define DA7210_DAC_L 0x15 | 42 | #define DA7210_DAC_L 0x15 |
42 | #define DA7210_DAC_R 0x16 | 43 | #define DA7210_DAC_R 0x16 |
43 | #define DA7210_DAC_SEL 0x17 | 44 | #define DA7210_DAC_SEL 0x17 |
45 | #define DA7210_SOFTMUTE 0x18 | ||
44 | #define DA7210_DAC_EQ1_2 0x19 | 46 | #define DA7210_DAC_EQ1_2 0x19 |
45 | #define DA7210_DAC_EQ3_4 0x1A | 47 | #define DA7210_DAC_EQ3_4 0x1A |
46 | #define DA7210_DAC_EQ5 0x1B | 48 | #define DA7210_DAC_EQ5 0x1B |
@@ -49,6 +51,7 @@ | |||
49 | #define DA7210_HP_L_VOL 0x21 | 51 | #define DA7210_HP_L_VOL 0x21 |
50 | #define DA7210_HP_R_VOL 0x22 | 52 | #define DA7210_HP_R_VOL 0x22 |
51 | #define DA7210_HP_CFG 0x23 | 53 | #define DA7210_HP_CFG 0x23 |
54 | #define DA7210_ZERO_CROSS 0x24 | ||
52 | #define DA7210_DAI_SRC_SEL 0x25 | 55 | #define DA7210_DAI_SRC_SEL 0x25 |
53 | #define DA7210_DAI_CFG1 0x26 | 56 | #define DA7210_DAI_CFG1 0x26 |
54 | #define DA7210_DAI_CFG3 0x28 | 57 | #define DA7210_DAI_CFG3 0x28 |
@@ -144,6 +147,9 @@ | |||
144 | #define DA7210_PLL_FS_96000 (0xF << 0) | 147 | #define DA7210_PLL_FS_96000 (0xF << 0) |
145 | #define DA7210_PLL_EN (0x1 << 7) | 148 | #define DA7210_PLL_EN (0x1 << 7) |
146 | 149 | ||
150 | /* SOFTMUTE bit fields */ | ||
151 | #define DA7210_RAMP_EN (1 << 6) | ||
152 | |||
147 | #define DA7210_VERSION "0.0.1" | 153 | #define DA7210_VERSION "0.0.1" |
148 | 154 | ||
149 | /* | 155 | /* |
@@ -189,6 +195,13 @@ static const struct soc_enum da7210_dac_vf_cutoff = | |||
189 | static const struct soc_enum da7210_adc_vf_cutoff = | 195 | static const struct soc_enum da7210_adc_vf_cutoff = |
190 | SOC_ENUM_SINGLE(DA7210_ADC_HPF, 4, 8, da7210_vf_cutoff_txt); | 196 | SOC_ENUM_SINGLE(DA7210_ADC_HPF, 4, 8, da7210_vf_cutoff_txt); |
191 | 197 | ||
198 | static const char *da7210_hp_mode_txt[] = { | ||
199 | "Class H", "Class G" | ||
200 | }; | ||
201 | |||
202 | static const struct soc_enum da7210_hp_mode_sel = | ||
203 | SOC_ENUM_SINGLE(DA7210_HP_CFG, 0, 2, da7210_hp_mode_txt); | ||
204 | |||
192 | static const struct snd_kcontrol_new da7210_snd_controls[] = { | 205 | static const struct snd_kcontrol_new da7210_snd_controls[] = { |
193 | 206 | ||
194 | SOC_DOUBLE_R_TLV("HeadPhone Playback Volume", | 207 | SOC_DOUBLE_R_TLV("HeadPhone Playback Volume", |
@@ -232,6 +245,21 @@ static const struct snd_kcontrol_new da7210_snd_controls[] = { | |||
232 | SOC_ENUM("ADC HPF Cutoff", da7210_adc_hpf_cutoff), | 245 | SOC_ENUM("ADC HPF Cutoff", da7210_adc_hpf_cutoff), |
233 | SOC_SINGLE("ADC Voice Mode Switch", DA7210_ADC_HPF, 7, 1, 0), | 246 | SOC_SINGLE("ADC Voice Mode Switch", DA7210_ADC_HPF, 7, 1, 0), |
234 | SOC_ENUM("ADC Voice Cutoff", da7210_adc_vf_cutoff), | 247 | SOC_ENUM("ADC Voice Cutoff", da7210_adc_vf_cutoff), |
248 | |||
249 | /* Mute controls */ | ||
250 | SOC_DOUBLE_R("Mic Capture Switch", DA7210_MIC_L, DA7210_MIC_R, 3, 1, 0), | ||
251 | SOC_SINGLE("Aux2 Capture Switch", DA7210_AUX2, 2, 1, 0), | ||
252 | SOC_DOUBLE("ADC Capture Switch", DA7210_ADC, 2, 6, 1, 0), | ||
253 | SOC_SINGLE("Digital Soft Mute Switch", DA7210_SOFTMUTE, 7, 1, 0), | ||
254 | SOC_SINGLE("Digital Soft Mute Rate", DA7210_SOFTMUTE, 0, 0x7, 0), | ||
255 | |||
256 | /* Zero cross controls */ | ||
257 | SOC_DOUBLE("Aux1 ZC Switch", DA7210_ZERO_CROSS, 0, 1, 1, 0), | ||
258 | SOC_DOUBLE("In PGA ZC Switch", DA7210_ZERO_CROSS, 2, 3, 1, 0), | ||
259 | SOC_DOUBLE("Lineout ZC Switch", DA7210_ZERO_CROSS, 4, 5, 1, 0), | ||
260 | SOC_DOUBLE("Headphone ZC Switch", DA7210_ZERO_CROSS, 6, 7, 1, 0), | ||
261 | |||
262 | SOC_ENUM("Headphone Class", da7210_hp_mode_sel), | ||
235 | }; | 263 | }; |
236 | 264 | ||
237 | /* Codec private data */ | 265 | /* Codec private data */ |
@@ -448,6 +476,18 @@ static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) | |||
448 | return 0; | 476 | return 0; |
449 | } | 477 | } |
450 | 478 | ||
479 | static int da7210_mute(struct snd_soc_dai *dai, int mute) | ||
480 | { | ||
481 | struct snd_soc_codec *codec = dai->codec; | ||
482 | u8 mute_reg = snd_soc_read(codec, DA7210_DAC_HPF) & 0xFB; | ||
483 | |||
484 | if (mute) | ||
485 | snd_soc_write(codec, DA7210_DAC_HPF, mute_reg | 0x4); | ||
486 | else | ||
487 | snd_soc_write(codec, DA7210_DAC_HPF, mute_reg); | ||
488 | return 0; | ||
489 | } | ||
490 | |||
451 | #define DA7210_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ | 491 | #define DA7210_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ |
452 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) | 492 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) |
453 | 493 | ||
@@ -456,6 +496,7 @@ static struct snd_soc_dai_ops da7210_dai_ops = { | |||
456 | .startup = da7210_startup, | 496 | .startup = da7210_startup, |
457 | .hw_params = da7210_hw_params, | 497 | .hw_params = da7210_hw_params, |
458 | .set_fmt = da7210_set_dai_fmt, | 498 | .set_fmt = da7210_set_dai_fmt, |
499 | .digital_mute = da7210_mute, | ||
459 | }; | 500 | }; |
460 | 501 | ||
461 | static struct snd_soc_dai_driver da7210_dai = { | 502 | static struct snd_soc_dai_driver da7210_dai = { |
@@ -545,6 +586,9 @@ static int da7210_probe(struct snd_soc_codec *codec) | |||
545 | DA7210_HP_2CAP_MODE | DA7210_HP_SENSE_EN | | 586 | DA7210_HP_2CAP_MODE | DA7210_HP_SENSE_EN | |
546 | DA7210_HP_L_EN | DA7210_HP_MODE | DA7210_HP_R_EN); | 587 | DA7210_HP_L_EN | DA7210_HP_MODE | DA7210_HP_R_EN); |
547 | 588 | ||
589 | /* Enable ramp mode for DAC gain update */ | ||
590 | snd_soc_write(codec, DA7210_SOFTMUTE, DA7210_RAMP_EN); | ||
591 | |||
548 | /* Diable PLL and bypass it */ | 592 | /* Diable PLL and bypass it */ |
549 | snd_soc_write(codec, DA7210_PLL, DA7210_PLL_FS_48000); | 593 | snd_soc_write(codec, DA7210_PLL, DA7210_PLL_FS_48000); |
550 | 594 | ||