Lines Matching +full:4 +full:- +full:switch
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm9713.c -- ALSA Soc WM9713 codec support
5 * Copyright 2006-10 Wolfson Microelectronics PLC.
8 * Features:-
70 SOC_ENUM_SINGLE(AC97_LINE, 3, 4, wm9713_mic_mixer), /* record mic mixer 0 */
71 SOC_ENUM_SINGLE(AC97_VIDEO, 14, 4, wm9713_rec_mux), /* record mux hp 1 */
72 SOC_ENUM_SINGLE(AC97_VIDEO, 9, 4, wm9713_rec_mux), /* record mux mono 2 */
74 SOC_ENUM_SINGLE(AC97_VIDEO, 0, 8, wm9713_rec_src), /* record mux right 4*/
76 SOC_ENUM_SINGLE(AC97_PCI_SVID, 14, 4, wm9713_alc_select), /* alc source select 6*/
77 SOC_ENUM_SINGLE(AC97_REC_GAIN, 14, 4, wm9713_mono_pga), /* mono input select 7 */
81 SOC_ENUM_SINGLE(AC97_REC_GAIN, 4, 3, wm9713_hp_pga), /* headphone right input 11 */
82 SOC_ENUM_SINGLE(AC97_REC_GAIN, 2, 4, wm9713_out3_pga), /* out 3 source 12 */
83 SOC_ENUM_SINGLE(AC97_REC_GAIN, 0, 4, wm9713_out4_pga), /* out 4 source 13 */
92 static const DECLARE_TLV_DB_SCALE(out_tlv, -4650, 150, 0);
93 static const DECLARE_TLV_DB_SCALE(main_tlv, -3450, 150, 0);
94 static const DECLARE_TLV_DB_SCALE(misc_tlv, -1500, 300, 0);
102 SOC_DOUBLE("Speaker Playback Switch", AC97_MASTER, 15, 7, 1, 1),
105 SOC_DOUBLE("Headphone Playback Switch", AC97_HEADPHONE, 15, 7, 1, 1),
113 SOC_SINGLE("Mic Boost (+20dB) Switch", AC97_LINE, 5, 1, 0),
116 SOC_SINGLE("Capture Switch", AC97_CD, 15, 1, 1),
119 SOC_SINGLE("Capture ZC Switch", AC97_CD, 7, 1, 0),
122 SOC_SINGLE("Capture to Mono Boost (+20dB) Switch", AC97_VIDEO, 8, 1, 0),
123 SOC_SINGLE("Capture ADC Boost (+20dB) Switch", AC97_VIDEO, 6, 1, 0),
127 SOC_SINGLE("ALC Decay Time", AC97_CODEC_CLASS_REV, 4, 15, 0),
132 SOC_SINGLE("ALC ZC Switch", AC97_PCI_SVID, 8, 1, 0),
133 SOC_SINGLE("ALC NG Switch", AC97_PCI_SVID, 7, 1, 0),
137 SOC_DOUBLE("Speaker Playback ZC Switch", AC97_MASTER, 14, 6, 1, 0),
138 SOC_DOUBLE("Headphone Playback ZC Switch", AC97_HEADPHONE, 14, 6, 1, 0),
140 SOC_SINGLE("Out4 Playback Switch", AC97_MASTER_MONO, 15, 1, 1),
141 SOC_SINGLE("Out4 Playback ZC Switch", AC97_MASTER_MONO, 14, 1, 0),
144 SOC_SINGLE("Out3 Playback Switch", AC97_MASTER_MONO, 7, 1, 1),
145 SOC_SINGLE("Out3 Playback ZC Switch", AC97_MASTER_MONO, 6, 1, 0),
149 SOC_SINGLE("Mono Playback Switch", AC97_MASTER_TONE, 7, 1, 1),
150 SOC_SINGLE("Mono Playback ZC Switch", AC97_MASTER_TONE, 6, 1, 0),
157 SOC_SINGLE_TLV("Mono Mixer Beep Playback Volume", AC97_AUX, 4, 7, 1, misc_tlv),
162 SOC_SINGLE("Voice Playback Mono Volume", AC97_PCM, 4, 7, 1),
172 SOC_SINGLE_TLV("Mono Mixer Voice Playback Volume", AC97_PCM, 4, 7, 1,
174 SOC_SINGLE_TLV("Mono Mixer Aux Playback Volume", AC97_REC_SEL, 4, 7, 1,
181 SOC_SINGLE("Bass Cut-off Switch", AC97_GENERAL_PURPOSE, 12, 1, 1),
182 SOC_SINGLE("Tone Cut-off Switch", AC97_GENERAL_PURPOSE, 4, 1, 1),
183 SOC_SINGLE("Playback Attenuate (-6dB) Switch", AC97_GENERAL_PURPOSE, 6, 1, 0),
187 SOC_SINGLE("3D Upper Cut-off Switch", AC97_REC_GAIN_MIC, 5, 1, 0),
188 SOC_SINGLE("3D Lower Cut-off Switch", AC97_REC_GAIN_MIC, 4, 1, 0),
195 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm9713_voice_shutdown()
198 return -EINVAL; in wm9713_voice_shutdown()
230 unsigned int val = ucontrol->value.integer.value[0]; in wm9713_hp_mixer_put()
232 (struct soc_mixer_control *)kcontrol->private_value; in wm9713_hp_mixer_put()
237 mixer = mc->shift >> 8; in wm9713_hp_mixer_put()
238 shift = mc->shift & 0xff; in wm9713_hp_mixer_put()
241 mutex_lock(&wm9713->lock); in wm9713_hp_mixer_put()
242 old = wm9713->hp_mixer[mixer]; in wm9713_hp_mixer_put()
243 if (ucontrol->value.integer.value[0]) in wm9713_hp_mixer_put()
244 wm9713->hp_mixer[mixer] |= mask; in wm9713_hp_mixer_put()
246 wm9713->hp_mixer[mixer] &= ~mask; in wm9713_hp_mixer_put()
248 change = old != wm9713->hp_mixer[mixer]; in wm9713_hp_mixer_put()
253 if ((wm9713->hp_mixer[0] & mask) || in wm9713_hp_mixer_put()
254 (wm9713->hp_mixer[1] & mask)) in wm9713_hp_mixer_put()
263 mutex_unlock(&wm9713->lock); in wm9713_hp_mixer_put()
275 (struct soc_mixer_control *)kcontrol->private_value; in wm9713_hp_mixer_get()
278 mixer = mc->shift >> 8; in wm9713_hp_mixer_get()
279 shift = mc->shift & 0xff; in wm9713_hp_mixer_get()
281 ucontrol->value.integer.value[0] = in wm9713_hp_mixer_get()
282 (wm9713->hp_mixer[mixer] >> shift) & 1; in wm9713_hp_mixer_get()
297 WM9713_HP_MIXER_CTRL("Beep Playback Switch", HPL_MIXER, 5),
298 WM9713_HP_MIXER_CTRL("Voice Playback Switch", HPL_MIXER, 4),
299 WM9713_HP_MIXER_CTRL("Aux Playback Switch", HPL_MIXER, 3),
300 WM9713_HP_MIXER_CTRL("PCM Playback Switch", HPL_MIXER, 2),
301 WM9713_HP_MIXER_CTRL("MonoIn Playback Switch", HPL_MIXER, 1),
302 WM9713_HP_MIXER_CTRL("Bypass Playback Switch", HPL_MIXER, 0),
307 WM9713_HP_MIXER_CTRL("Beep Playback Switch", HPR_MIXER, 5),
308 WM9713_HP_MIXER_CTRL("Voice Playback Switch", HPR_MIXER, 4),
309 WM9713_HP_MIXER_CTRL("Aux Playback Switch", HPR_MIXER, 3),
310 WM9713_HP_MIXER_CTRL("PCM Playback Switch", HPR_MIXER, 2),
311 WM9713_HP_MIXER_CTRL("MonoIn Playback Switch", HPR_MIXER, 1),
312 WM9713_HP_MIXER_CTRL("Bypass Playback Switch", HPR_MIXER, 0),
325 SOC_DAPM_SINGLE("Beep Playback Switch", AC97_AUX, 11, 1, 1),
326 SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 11, 1, 1),
327 SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 11, 1, 1),
328 SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 14, 1, 1),
329 SOC_DAPM_SINGLE("MonoIn Playback Switch", AC97_MASTER_TONE, 14, 1, 1),
330 SOC_DAPM_SINGLE("Bypass Playback Switch", AC97_PC_BEEP, 14, 1, 1),
335 SOC_DAPM_SINGLE("Beep Playback Switch", AC97_AUX, 7, 1, 1),
336 SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 7, 1, 1),
337 SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 7, 1, 1),
338 SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 13, 1, 1),
339 SOC_DAPM_SINGLE("MonoIn Playback Switch", AC97_MASTER_TONE, 13, 1, 1),
340 SOC_DAPM_SINGLE("Bypass Playback Switch", AC97_PC_BEEP, 13, 1, 1),
341 SOC_DAPM_SINGLE("Mic 1 Sidetone Switch", AC97_LINE, 7, 1, 1),
342 SOC_DAPM_SINGLE("Mic 2 Sidetone Switch", AC97_LINE, 6, 1, 1),
391 SOC_DAPM_ENUM("Route", wm9713_enum[4]);
420 SND_SOC_DAPM_MUX("Out 4 Mux", SND_SOC_NOPM, 0, 0,
453 SND_SOC_DAPM_PGA("Right ADC", AC97_EXTENDED_MID, 4, 1, NULL, 0),
463 SND_SOC_DAPM_PGA("Out 4", AC97_EXTENDED_MSTATUS, 12, 1, NULL, 0),
467 SND_SOC_DAPM_PGA("Mono In", AC97_EXTENDED_MSTATUS, 4, 1, NULL, 0),
492 {"Left HP Mixer", "Beep Playback Switch", "PCBEEP"},
493 {"Left HP Mixer", "Voice Playback Switch", "Voice DAC"},
494 {"Left HP Mixer", "Aux Playback Switch", "Aux DAC"},
495 {"Left HP Mixer", "Bypass Playback Switch", "Left Line In"},
496 {"Left HP Mixer", "PCM Playback Switch", "Left DAC"},
497 {"Left HP Mixer", "MonoIn Playback Switch", "Mono In"},
501 {"Right HP Mixer", "Beep Playback Switch", "PCBEEP"},
502 {"Right HP Mixer", "Voice Playback Switch", "Voice DAC"},
503 {"Right HP Mixer", "Aux Playback Switch", "Aux DAC"},
504 {"Right HP Mixer", "Bypass Playback Switch", "Right Line In"},
505 {"Right HP Mixer", "PCM Playback Switch", "Right DAC"},
506 {"Right HP Mixer", "MonoIn Playback Switch", "Mono In"},
509 /* virtual mixer - mixes left & right channels for spk and mono */
520 {"Speaker Mixer", "Beep Playback Switch", "PCBEEP"},
521 {"Speaker Mixer", "Voice Playback Switch", "Voice DAC"},
522 {"Speaker Mixer", "Aux Playback Switch", "Aux DAC"},
523 {"Speaker Mixer", "Bypass Playback Switch", "Line Mixer"},
524 {"Speaker Mixer", "PCM Playback Switch", "AC97 Mixer"},
525 {"Speaker Mixer", "MonoIn Playback Switch", "Mono In"},
528 {"Mono Mixer", "Beep Playback Switch", "PCBEEP"},
529 {"Mono Mixer", "Voice Playback Switch", "Voice DAC"},
530 {"Mono Mixer", "Aux Playback Switch", "Aux DAC"},
531 {"Mono Mixer", "Bypass Playback Switch", "Line Mixer"},
532 {"Mono Mixer", "PCM Playback Switch", "AC97 Mixer"},
533 {"Mono Mixer", "Mic 1 Sidetone Switch", "Mic A PGA"},
534 {"Mono Mixer", "Mic 2 Sidetone Switch", "Mic B PGA"},
574 /* out 4 mux */
575 {"Out 4 Mux", "Inv 2", "DAC Inv Mux 2"},
584 {"OUT4", NULL, "Out 4"},
585 {"Out 4", NULL, "Out 4 Mux"},
649 switch (reg) { in wm9713_readable_reg()
665 switch (reg) { in wm9713_writeable_reg()
704 { 0x42, 0x0000 }, /* Fast Power-Up Control */
710 { 0x52, 0x0000 }, /* GPIO Pin Wake-Up */
744 u32 n:4;
764 pll_div->divsel = 1; in pll_factors()
768 pll_div->divctl = 1; in pll_factors()
770 pll_div->divctl = 0; in pll_factors()
773 pll_div->divsel = 0; in pll_factors()
774 pll_div->divctl = 0; in pll_factors()
781 pll_div->lf = 1; in pll_factors()
784 pll_div->lf = 0; in pll_factors()
788 dev_warn(component->dev, in pll_factors()
792 pll_div->n = Ndiv; in pll_factors()
807 pll_div->k = K; in pll_factors()
826 wm9713->pll_in = 0; in wm9713_set_pll()
842 reg = reg2 | (0x5 << 4) | (pll_div.k >> 20); in wm9713_set_pll()
846 reg = reg2 | (0x4 << 4) | ((pll_div.k >> 16) & 0xf); in wm9713_set_pll()
850 reg = reg2 | (0x3 << 4) | ((pll_div.k >> 12) & 0xf); in wm9713_set_pll()
854 reg = reg2 | (0x2 << 4) | ((pll_div.k >> 8) & 0xf); in wm9713_set_pll()
857 /* K [7:4] */ in wm9713_set_pll()
858 reg = reg2 | (0x1 << 4) | ((pll_div.k >> 4) & 0xf); in wm9713_set_pll()
861 reg = reg2 | (0x0 << 4) | (pll_div.k & 0xf); /* K [3:0] */ in wm9713_set_pll()
868 wm9713->pll_in = freq_in; in wm9713_set_pll()
878 struct snd_soc_component *component = codec_dai->component; in wm9713_set_dai_pll()
889 struct snd_soc_component *component = codec_dai->component; in wm9713_set_dai_tristate()
905 struct snd_soc_component *component = codec_dai->component; in wm9713_set_dai_clkdiv()
907 switch (div_id) { in wm9713_set_dai_clkdiv()
932 return -EINVAL; in wm9713_set_dai_clkdiv()
941 struct snd_soc_component *component = codec_dai->component; in wm9713_set_dai_fmt()
946 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { in wm9713_set_dai_fmt()
965 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { in wm9713_set_dai_fmt()
978 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in wm9713_set_dai_fmt()
1004 struct snd_soc_component *component = dai->component; in wm9713_pcm_hw_params()
1007 switch (params_width(params)) { in wm9713_pcm_hw_params()
1029 struct snd_soc_component *component = dai->component; in ac97_hifi_prepare()
1030 struct snd_pcm_runtime *runtime = substream->runtime; in ac97_hifi_prepare()
1035 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in ac97_hifi_prepare()
1040 return snd_soc_component_write(component, reg, runtime->rate); in ac97_hifi_prepare()
1046 struct snd_soc_component *component = dai->component; in ac97_aux_prepare()
1047 struct snd_pcm_runtime *runtime = substream->runtime; in ac97_aux_prepare()
1052 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in ac97_aux_prepare()
1053 return -ENODEV; in ac97_aux_prepare()
1055 return snd_soc_component_write(component, AC97_PCM_SURR_DAC_RATE, runtime->rate); in ac97_aux_prepare()
1097 .name = "wm9713-hifi",
1113 .name = "wm9713-aux",
1123 .name = "wm9713-voice",
1144 switch (level) { in wm9713_set_bias_level()
1168 /* Disable everything except touchpanel - that will be handled in wm9713_soc_suspend()
1185 ret = snd_ac97_reset(wm9713->ac97, true, WM9713_VENDOR_ID, in wm9713_soc_resume()
1192 /* do we need to re-start the PLL ? */ in wm9713_soc_resume()
1193 if (wm9713->pll_in) in wm9713_soc_resume()
1194 wm9713_set_pll(component, 0, wm9713->pll_in, 0); in wm9713_soc_resume()
1198 regcache_mark_dirty(component->regmap); in wm9713_soc_resume()
1210 if (wm9713->mfd_pdata) { in wm9713_soc_probe()
1211 wm9713->ac97 = wm9713->mfd_pdata->ac97; in wm9713_soc_probe()
1212 regmap = wm9713->mfd_pdata->regmap; in wm9713_soc_probe()
1214 wm9713->ac97 = snd_soc_new_ac97_component(component, WM9713_VENDOR_ID, in wm9713_soc_probe()
1216 if (IS_ERR(wm9713->ac97)) in wm9713_soc_probe()
1217 return PTR_ERR(wm9713->ac97); in wm9713_soc_probe()
1218 regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config); in wm9713_soc_probe()
1220 snd_soc_free_ac97_component(wm9713->ac97); in wm9713_soc_probe()
1224 return -ENXIO; in wm9713_soc_probe()
1229 /* unmute the adc - move to kcontrol */ in wm9713_soc_probe()
1239 if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS) && !wm9713->mfd_pdata) { in wm9713_soc_remove()
1241 snd_soc_free_ac97_component(wm9713->ac97); in wm9713_soc_remove()
1266 wm9713 = devm_kzalloc(&pdev->dev, sizeof(*wm9713), GFP_KERNEL); in wm9713_probe()
1268 return -ENOMEM; in wm9713_probe()
1270 mutex_init(&wm9713->lock); in wm9713_probe()
1272 wm9713->mfd_pdata = dev_get_platdata(&pdev->dev); in wm9713_probe()
1275 return devm_snd_soc_register_component(&pdev->dev, in wm9713_probe()
1281 .name = "wm9713-codec",