Lines Matching +full:4 +full:- +full:switch
1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8940.c -- WM8940 ALSA Soc Audio driver
48 switch (reg) { in wm8940_volatile_register()
58 switch (reg) { in wm8940_readable_register()
126 { 0x16, 0x0000 }, /* Notch Filter 4 Control 1 */
127 { 0x17, 0x0000 }, /* Notch Filter 4 Control 2 */
140 { 0x2a, 0x0030 }, /* ALC Control 4 */
155 static const char *wm8940_companding[] = { "Off", "NC", "u-law", "A-law" };
173 static DECLARE_TLV_DB_SCALE(wm8940_spk_vol_tlv, -5700, 100, 1);
174 static DECLARE_TLV_DB_SCALE(wm8940_att_tlv, -1000, 1000, 0);
175 static DECLARE_TLV_DB_SCALE(wm8940_pga_vol_tlv, -1200, 75, 0);
176 static DECLARE_TLV_DB_SCALE(wm8940_alc_min_tlv, -1200, 600, 0);
178 static DECLARE_TLV_DB_SCALE(wm8940_alc_tar_tlv, -2250, 50, 0);
180 static DECLARE_TLV_DB_SCALE(wm8940_lim_thresh_tlv, -600, 100, 0);
181 static DECLARE_TLV_DB_SCALE(wm8940_adc_tlv, -12750, 50, 1);
185 SOC_SINGLE("Digital Loopback Switch", WM8940_COMPANDINGCTL,
191 SOC_SINGLE("ALC Switch", WM8940_ALC1, 8, 1, 0),
198 SOC_SINGLE("ALC Capture Hold", WM8940_ALC2, 4, 10, 0),
199 SOC_SINGLE("ALC Capture Decay", WM8940_ALC3, 4, 10, 0),
201 SOC_SINGLE("ALC ZC Switch", WM8940_ALC4, 1, 1, 0),
202 SOC_SINGLE("ALC Capture Noise Gate Switch", WM8940_NOISEGATE,
207 SOC_SINGLE("DAC Playback Limiter Switch", WM8940_DACLIM1, 8, 1, 0),
209 SOC_SINGLE("DAC Playback Limiter Decay", WM8940_DACLIM1, 4, 11, 0),
211 4, 9, 1, wm8940_lim_thresh_tlv),
215 SOC_SINGLE("Capture PGA ZC Switch", WM8940_PGAGAIN, 7, 1, 0),
227 SOC_SINGLE("Speaker Playback Switch", WM8940_SPKVOL, 6, 1, 1),
231 SOC_SINGLE("Speaker Playback ZC Switch", WM8940_SPKVOL, 7, 1, 0),
233 SOC_SINGLE("Mono Out Switch", WM8940_MONOMIX, 6, 1, 1),
237 SOC_SINGLE("High Pass Filter Switch", WM8940_ADC, 8, 1, 0),
239 SOC_SINGLE("High Pass Filter Cut Off", WM8940_ADC, 4, 7, 0),
240 SOC_SINGLE("ADC Inversion Switch", WM8940_ADC, 0, 1, 0),
241 SOC_SINGLE("DAC Inversion Switch", WM8940_DAC, 0, 1, 0),
242 SOC_SINGLE("DAC Auto Mute Switch", WM8940_DAC, 2, 1, 0),
243 SOC_SINGLE("ZC Timeout Clock Switch", WM8940_ADDCNTRL, 0, 1, 0),
247 SOC_DAPM_SINGLE("Line Bypass Switch", WM8940_SPKMIX, 1, 1, 0),
248 SOC_DAPM_SINGLE("Aux Playback Switch", WM8940_SPKMIX, 5, 1, 0),
249 SOC_DAPM_SINGLE("PCM Playback Switch", WM8940_SPKMIX, 0, 1, 0),
253 SOC_DAPM_SINGLE("Line Bypass Switch", WM8940_MONOMIX, 1, 1, 0),
254 SOC_DAPM_SINGLE("Aux Playback Switch", WM8940_MONOMIX, 2, 1, 0),
255 SOC_DAPM_SINGLE("PCM Playback Switch", WM8940_MONOMIX, 0, 1, 0),
258 static DECLARE_TLV_DB_SCALE(wm8940_boost_vol_tlv, -1500, 300, 1);
260 SOC_DAPM_SINGLE("Mic PGA Switch", WM8940_PGAGAIN, 6, 1, 1),
264 4, 7, 0, wm8940_boost_vol_tlv),
268 SOC_DAPM_SINGLE("AUX Switch", WM8940_INPUTCTL, 2, 1, 0),
269 SOC_DAPM_SINGLE("MICP Switch", WM8940_INPUTCTL, 0, 1, 0),
270 SOC_DAPM_SINGLE("MICN Switch", WM8940_INPUTCTL, 1, 1, 0),
294 SND_SOC_DAPM_MIXER("Boost Mixer", WM8940_POWER2, 4, 0,
297 SND_SOC_DAPM_MICBIAS("Mic Bias", WM8940_POWER1, 4, 0),
306 {"Mono Mixer", "PCM Playback Switch", "DAC"},
307 {"Mono Mixer", "Aux Playback Switch", "Aux Input"},
308 {"Mono Mixer", "Line Bypass Switch", "Boost Mixer"},
311 {"Speaker Mixer", "PCM Playback Switch", "DAC"},
312 {"Speaker Mixer", "Aux Playback Switch", "Aux Input"},
313 {"Speaker Mixer", "Line Bypass Switch", "Boost Mixer"},
324 {"Mic PGA", "MICN Switch", "MICN"},
325 {"Mic PGA", "MICP Switch", "MICP"},
326 {"Mic PGA", "AUX Switch", "AUX"},
329 {"Boost Mixer", "Mic PGA Switch", "Mic PGA"},
341 struct snd_soc_component *component = codec_dai->component; in wm8940_set_dai_fmt()
345 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { in wm8940_set_dai_fmt()
352 return -EINVAL; in wm8940_set_dai_fmt()
356 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in wm8940_set_dai_fmt()
373 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { in wm8940_set_dai_fmt()
397 struct snd_soc_component *component = dai->component; in wm8940_i2s_hw_params()
405 priv->fs = params_rate(params); in wm8940_i2s_hw_params()
411 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE in wm8940_i2s_hw_params()
415 switch (params_rate(params)) { in wm8940_i2s_hw_params()
439 switch (params_width(params)) { in wm8940_i2s_hw_params()
466 struct snd_soc_component *component = dai->component; in wm8940_mute()
483 switch (level) { in wm8940_set_bias_level()
502 ret = regcache_sync(wm8940->regmap); in wm8940_set_bias_level()
504 dev_err(component->dev, "Failed to sync cache: %d\n", ret); in wm8940_set_bias_level()
524 unsigned int n:4;
547 /* Divide by 4 */ in pll_factors()
585 struct snd_soc_component *component = codec_dai->component; in wm8940_set_dai_pll()
601 /* Pll is followed by a frequency divide by 4 */ in wm8940_set_dai_pll()
602 pll_factors(freq_out*4, freq_in); in wm8940_set_dai_pll()
605 (pll_div.pre_scale << 4) | pll_div.n | (1 << 6)); in wm8940_set_dai_pll()
608 (pll_div.pre_scale << 4) | pll_div.n); in wm8940_set_dai_pll()
626 struct snd_soc_component *component = codec_dai->component; in wm8940_set_dai_clkdiv()
630 switch (div_id) { in wm8940_set_dai_clkdiv()
641 ret = snd_soc_component_write(component, WM8940_GPIO, reg | (div << 4)); in wm8940_set_dai_clkdiv()
657 } else if (ratio == 4) { in wm8940_get_mclkdiv()
681 struct snd_soc_component *codec = dai->component; in wm8940_update_clocks()
688 if (!priv->mclk || !priv->fs) in wm8940_update_clocks()
691 fs256 = 256 * priv->fs; in wm8940_update_clocks()
693 f = wm8940_get_mclkdiv(priv->mclk, fs256, &mclkdiv); in wm8940_update_clocks()
694 if (f != priv->mclk) { in wm8940_update_clocks()
699 wm8940_set_dai_pll(dai, 0, 0, priv->mclk, fpll); in wm8940_update_clocks()
708 struct snd_soc_component *codec = dai->component; in wm8940_set_dai_sysclk()
712 return -EINVAL; in wm8940_set_dai_sysclk()
714 priv->mclk = freq; in wm8940_set_dai_sysclk()
738 .name = "wm8940-hifi",
759 struct wm8940_setup_data *pdata = component->dev->platform_data; in wm8940_probe()
764 * Check chip ID for wm8940 - value of 0x00 offset in wm8940_probe()
770 dev_err(component->dev, "Wrong wm8940 chip ID: 0x%x\n", reg); in wm8940_probe()
771 return -ENODEV; in wm8940_probe()
776 dev_err(component->dev, "Failed to issue reset\n"); in wm8940_probe()
788 ret = snd_soc_component_write(component, WM8940_OUTPUTCTL, reg | pdata->vroi); in wm8940_probe()
829 wm8940 = devm_kzalloc(&i2c->dev, sizeof(struct wm8940_priv), in wm8940_i2c_probe()
832 return -ENOMEM; in wm8940_i2c_probe()
834 wm8940->regmap = devm_regmap_init_i2c(i2c, &wm8940_regmap); in wm8940_i2c_probe()
835 if (IS_ERR(wm8940->regmap)) in wm8940_i2c_probe()
836 return PTR_ERR(wm8940->regmap); in wm8940_i2c_probe()
840 ret = devm_snd_soc_register_component(&i2c->dev, in wm8940_i2c_probe()