Lines Matching +full:mic +full:- +full:int
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm9712.c -- ALSA Soc WM9712 codec support
5 * Copyright 2006-12 Wolfson Microelectronics PLC.
30 unsigned int hp_mixer[2];
74 static bool wm9712_volatile_reg(struct device *dev, unsigned int reg) in wm9712_volatile_reg()
108 static const char *wm9712_mic[] = {"Mic 1", "Differential", "Mic 2",
110 static const char *wm9712_rec_sel[] = {"Mic", "NC", "NC", "Speaker Mixer",
113 static const char *wm9712_diff_sel[] = {"Mic", "Line"};
115 static const DECLARE_TLV_DB_SCALE(main_tlv, -3450, 150, 0);
159 SOC_SINGLE("Mic Headphone Volume", AC97_VIDEO, 12, 7, 1),
181 SOC_SINGLE("3D Upper Cut-off Switch", AC97_3D_CONTROL, 5, 1, 1),
182 SOC_SINGLE("3D Lower Cut-off Switch", AC97_3D_CONTROL, 4, 1, 1),
186 SOC_SINGLE("Bass Cut-off Switch", AC97_MASTER_TONE, 12, 1, 1),
187 SOC_SINGLE("Tone Cut-off Switch", AC97_MASTER_TONE, 4, 1, 1),
188 SOC_SINGLE("Playback Attenuate (-6dB) Switch", AC97_MASTER_TONE, 6, 1, 0),
197 SOC_SINGLE_TLV("Mic 1 Volume", AC97_MIC, 8, 31, 1, main_tlv),
198 SOC_SINGLE_TLV("Mic 2 Volume", AC97_MIC, 0, 31, 1, main_tlv),
199 SOC_SINGLE_TLV("Mic Boost Volume", AC97_MIC, 7, 1, 0, boost_tlv),
202 static const unsigned int wm9712_mixer_mute_regs[] = {
215 static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol, in wm9712_hp_mixer_put()
221 unsigned int val = ucontrol->value.integer.value[0]; in wm9712_hp_mixer_put()
223 (struct soc_mixer_control *)kcontrol->private_value; in wm9712_hp_mixer_put()
224 unsigned int mixer, mask, shift, old; in wm9712_hp_mixer_put()
228 mixer = mc->shift >> 8; in wm9712_hp_mixer_put()
229 shift = mc->shift & 0xff; in wm9712_hp_mixer_put()
232 mutex_lock(&wm9712->lock); in wm9712_hp_mixer_put()
233 old = wm9712->hp_mixer[mixer]; in wm9712_hp_mixer_put()
234 if (ucontrol->value.integer.value[0]) in wm9712_hp_mixer_put()
235 wm9712->hp_mixer[mixer] |= mask; in wm9712_hp_mixer_put()
237 wm9712->hp_mixer[mixer] &= ~mask; in wm9712_hp_mixer_put()
239 change = old != wm9712->hp_mixer[mixer]; in wm9712_hp_mixer_put()
244 if ((wm9712->hp_mixer[0] & mask) || in wm9712_hp_mixer_put()
245 (wm9712->hp_mixer[1] & mask)) in wm9712_hp_mixer_put()
254 mutex_unlock(&wm9712->lock); in wm9712_hp_mixer_put()
259 static int wm9712_hp_mixer_get(struct snd_kcontrol *kcontrol, in wm9712_hp_mixer_get()
266 (struct soc_mixer_control *)kcontrol->private_value; in wm9712_hp_mixer_get()
267 unsigned int shift, mixer; in wm9712_hp_mixer_get()
269 mixer = mc->shift >> 8; in wm9712_hp_mixer_get()
270 shift = mc->shift & 0xff; in wm9712_hp_mixer_get()
272 ucontrol->value.integer.value[0] = in wm9712_hp_mixer_get()
273 (wm9712->hp_mixer[mixer] >> shift) & 1; in wm9712_hp_mixer_get()
293 WM9712_HP_MIXER_CTRL("Mic Sidetone Switch", HPL_MIXER, 0),
303 WM9712_HP_MIXER_CTRL("Mic Sidetone Switch", HPR_MIXER, 0),
321 SOC_DAPM_SINGLE("Mic 1 Sidetone Switch", AC97_MIC, 14, 1, 1),
322 SOC_DAPM_SINGLE("Mic 2 Sidetone Switch", AC97_MIC, 13, 1, 1),
349 /* Mic select */
351 SOC_DAPM_ENUM("Mic Source Select", wm9712_enum[7]);
370 SND_SOC_DAPM_MUX("Left Mic Select Source", SND_SOC_NOPM, 0, 0,
372 SND_SOC_DAPM_MUX("Right Mic Select Source", SND_SOC_NOPM, 0, 0,
397 SND_SOC_DAPM_PGA("Mic PGA", AC97_INT_PAGING, 0, 1, NULL, 0),
398 SND_SOC_DAPM_PGA("Differential Mic", SND_SOC_NOPM, 0, 0, NULL, 0),
399 SND_SOC_DAPM_MICBIAS("Mic Bias", AC97_INT_PAGING, 10, 1),
415 /* virtual mixer - mixes left & right channels for spk and mono */
425 {"Left HP Mixer", "Mic Sidetone Switch", "Mic PGA"},
434 {"Right HP Mixer", "Mic Sidetone Switch", "Mic PGA"},
449 {"Phone Mixer", "Mic 1 Sidetone Switch", "Mic PGA"},
450 {"Phone Mixer", "Mic 2 Sidetone Switch", "Mic PGA"},
456 {"Mic PGA", NULL, "MIC1"},
457 {"Mic PGA", NULL, "MIC2"},
460 {"Differential Mic", NULL, "MIC1"},
461 {"Differential Mic", NULL, "MIC2"},
462 {"Left Mic Select Source", "Mic 1", "MIC1"},
463 {"Left Mic Select Source", "Mic 2", "MIC2"},
464 {"Left Mic Select Source", "Stereo", "MIC1"},
465 {"Left Mic Select Source", "Differential", "Differential Mic"},
466 {"Right Mic Select Source", "Mic 1", "MIC1"},
467 {"Right Mic Select Source", "Mic 2", "MIC2"},
468 {"Right Mic Select Source", "Stereo", "MIC2"},
469 {"Right Mic Select Source", "Differential", "Differential Mic"},
472 {"Left Capture Select", "Mic", "MIC1"},
480 {"Right Capture Select", "Mic", "MIC2"},
523 static int ac97_prepare(struct snd_pcm_substream *substream, in ac97_prepare()
526 struct snd_soc_component *component = dai->component; in ac97_prepare()
527 int reg; in ac97_prepare()
528 struct snd_pcm_runtime *runtime = substream->runtime; in ac97_prepare()
532 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in ac97_prepare()
537 return snd_soc_component_write(component, reg, runtime->rate); in ac97_prepare()
540 static int ac97_aux_prepare(struct snd_pcm_substream *substream, in ac97_aux_prepare()
543 struct snd_soc_component *component = dai->component; in ac97_aux_prepare()
544 struct snd_pcm_runtime *runtime = substream->runtime; in ac97_aux_prepare()
549 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in ac97_aux_prepare()
550 return -ENODEV; in ac97_aux_prepare()
552 return snd_soc_component_write(component, AC97_PCM_SURR_DAC_RATE, runtime->rate); in ac97_aux_prepare()
569 .name = "wm9712-hifi",
585 .name = "wm9712-aux",
596 static int wm9712_set_bias_level(struct snd_soc_component *component, in wm9712_set_bias_level()
615 static int wm9712_soc_resume(struct snd_soc_component *component) in wm9712_soc_resume()
618 int ret; in wm9712_soc_resume()
620 ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID, in wm9712_soc_resume()
633 static int wm9712_soc_probe(struct snd_soc_component *component) in wm9712_soc_probe()
638 if (wm9712->mfd_pdata) { in wm9712_soc_probe()
639 wm9712->ac97 = wm9712->mfd_pdata->ac97; in wm9712_soc_probe()
640 regmap = wm9712->mfd_pdata->regmap; in wm9712_soc_probe()
642 int ret; in wm9712_soc_probe()
644 wm9712->ac97 = snd_soc_new_ac97_component(component, WM9712_VENDOR_ID, in wm9712_soc_probe()
646 if (IS_ERR(wm9712->ac97)) { in wm9712_soc_probe()
647 ret = PTR_ERR(wm9712->ac97); in wm9712_soc_probe()
648 dev_err(component->dev, in wm9712_soc_probe()
653 regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config); in wm9712_soc_probe()
655 snd_soc_free_ac97_component(wm9712->ac97); in wm9712_soc_probe()
659 return -ENXIO; in wm9712_soc_probe()
674 if (IS_ENABLED(CONFIG_SND_SOC_AC97_BUS) && !wm9712->mfd_pdata) { in wm9712_soc_remove()
676 snd_soc_free_ac97_component(wm9712->ac97); in wm9712_soc_remove()
697 static int wm9712_probe(struct platform_device *pdev) in wm9712_probe()
701 wm9712 = devm_kzalloc(&pdev->dev, sizeof(*wm9712), GFP_KERNEL); in wm9712_probe()
703 return -ENOMEM; in wm9712_probe()
705 mutex_init(&wm9712->lock); in wm9712_probe()
707 wm9712->mfd_pdata = dev_get_platdata(&pdev->dev); in wm9712_probe()
710 return devm_snd_soc_register_component(&pdev->dev, in wm9712_probe()
716 .name = "wm9712-codec",