Lines Matching +full:4 +full:- +full:switch

1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8974.c -- WM8974 ALSA Soc Audio driver
5 * Copyright 2006-2009 Wolfson Microelectronics PLC.
34 { 4, 0x0050 }, { 5, 0x0000 }, { 6, 0x0140 }, { 7, 0x0000 },
55 static const char *wm8974_companding[] = {"Off", "NC", "u-law", "A-law" };
67 SOC_ENUM_SINGLE(WM8974_COMP, 1, 4, wm8974_companding), /* adc */
68 SOC_ENUM_SINGLE(WM8974_COMP, 3, 4, wm8974_companding), /* dac */
69 SOC_ENUM_SINGLE(WM8974_DAC, 4, 4, wm8974_deemp),
72 SOC_ENUM_SINGLE(WM8974_EQ1, 5, 4, wm8974_eq1),
74 SOC_ENUM_SINGLE(WM8974_EQ2, 5, 4, wm8974_eq2),
77 SOC_ENUM_SINGLE(WM8974_EQ3, 5, 4, wm8974_eq3),
79 SOC_ENUM_SINGLE(WM8974_EQ4, 5, 4, wm8974_eq4),
82 SOC_ENUM_SINGLE(WM8974_EQ5, 5, 4, wm8974_eq5),
91 static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1);
92 static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
93 static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1200, 75, 0);
94 static const DECLARE_TLV_DB_SCALE(spk_tlv, -5700, 100, 0);
98 SOC_SINGLE("Digital Loopback Switch", WM8974_COMP, 0, 1, 0),
103 SOC_ENUM("Playback De-emphasis", wm8974_enum[2]),
104 SOC_SINGLE("DAC Inversion Switch", WM8974_DAC, 0, 1, 0),
108 SOC_SINGLE("High Pass Filter Switch", WM8974_ADC, 8, 1, 0),
109 SOC_SINGLE("High Pass Cut Off", WM8974_ADC, 4, 7, 0),
110 SOC_SINGLE("ADC Inversion Switch", WM8974_ADC, 0, 1, 0),
115 SOC_ENUM("EQ1 Cut Off", wm8974_enum[4]),
134 SOC_SINGLE("DAC Playback Limiter Switch", WM8974_DACLIM1, 8, 1, 0),
135 SOC_SINGLE("DAC Playback Limiter Decay", WM8974_DACLIM1, 4, 15, 0),
138 SOC_SINGLE("DAC Playback Limiter Threshold", WM8974_DACLIM2, 4, 7, 0),
141 SOC_SINGLE("ALC Enable Switch", WM8974_ALC1, 8, 1, 0),
145 SOC_SINGLE("ALC Capture ZC Switch", WM8974_ALC2, 8, 1, 0),
146 SOC_SINGLE("ALC Capture Hold", WM8974_ALC2, 4, 7, 0),
150 SOC_SINGLE("ALC Capture Decay", WM8974_ALC3, 4, 15, 0),
153 SOC_SINGLE("ALC Capture Noise Gate Switch", WM8974_NGATE, 3, 1, 0),
156 SOC_SINGLE("Capture PGA ZC Switch", WM8974_INPPGA, 7, 1, 0),
159 SOC_SINGLE("Speaker Playback ZC Switch", WM8974_SPKVOL, 7, 1, 0),
160 SOC_SINGLE("Speaker Playback Switch", WM8974_SPKVOL, 6, 1, 1),
166 SOC_SINGLE("Mono Playback Switch", WM8974_MONOMIX, 6, 1, 1),
169 SOC_SINGLE("DAC 128x Oversampling Switch", WM8974_DAC, 8, 1, 0),
170 SOC_SINGLE("ADC 128x Oversampling Switch", WM8974_ADC, 8, 1, 0),
175 SOC_DAPM_SINGLE("Line Bypass Switch", WM8974_SPKMIX, 1, 1, 0),
176 SOC_DAPM_SINGLE("Aux Playback Switch", WM8974_SPKMIX, 5, 1, 0),
177 SOC_DAPM_SINGLE("PCM Playback Switch", WM8974_SPKMIX, 0, 1, 0),
182 SOC_DAPM_SINGLE("Line Bypass Switch", WM8974_MONOMIX, 1, 1, 0),
183 SOC_DAPM_SINGLE("Aux Playback Switch", WM8974_MONOMIX, 2, 1, 0),
184 SOC_DAPM_SINGLE("PCM Playback Switch", WM8974_MONOMIX, 0, 1, 0),
189 SOC_DAPM_SINGLE("Aux Switch", WM8974_INPPGA, 6, 1, 1),
194 SOC_DAPM_SINGLE("Aux Switch", WM8974_INPUT, 2, 1, 0),
195 SOC_DAPM_SINGLE("MicN Switch", WM8974_INPUT, 1, 1, 0),
196 SOC_DAPM_SINGLE("MicP Switch", WM8974_INPUT, 0, 1, 0),
215 SND_SOC_DAPM_MIXER("Boost Mixer", WM8974_POWER2, 4, 0,
218 SND_SOC_DAPM_SUPPLY("Mic Bias", WM8974_POWER1, 4, 0, NULL, 0),
230 {"Mono Mixer", "PCM Playback Switch", "DAC"},
231 {"Mono Mixer", "Aux Playback Switch", "Aux Input"},
232 {"Mono Mixer", "Line Bypass Switch", "Boost Mixer"},
235 {"Speaker Mixer", "PCM Playback Switch", "DAC"},
236 {"Speaker Mixer", "Aux Playback Switch", "Aux Input"},
237 {"Speaker Mixer", "Line Bypass Switch", "Boost Mixer"},
249 {"Boost Mixer", "Aux Switch", "Aux Input"},
254 {"Input PGA", "Aux Switch", "Aux Input"},
255 {"Input PGA", "MicN Switch", "MICN"},
256 {"Input PGA", "MicP Switch", "MICP"},
264 unsigned int n:4;
278 /* There is a fixed divide by 4 in the output path */ in pll_factors()
279 target *= 4; in pll_factors()
284 pll_div->pre_div = 1; in pll_factors()
287 pll_div->pre_div = 0; in pll_factors()
294 pll_div->n = Ndiv; in pll_factors()
309 pll_div->k = K; in pll_factors()
315 struct snd_soc_component *component = codec_dai->component; in wm8974_set_dai_pll()
332 snd_soc_component_write(component, WM8974_PLLN, (pll_div.pre_div << 4) | pll_div.n); in wm8974_set_dai_pll()
352 struct snd_soc_component *component = codec_dai->component; in wm8974_set_dai_clkdiv()
355 switch (div_id) { in wm8974_set_dai_clkdiv()
369 return -EINVAL; in wm8974_set_dai_clkdiv()
385 } else if (ratio == 4) { in wm8974_get_mclkdiv()
409 struct snd_soc_component *component = dai->component; in wm8974_update_clocks()
416 if (!priv->mclk || !priv->fs) in wm8974_update_clocks()
419 fs256 = 256 * priv->fs; in wm8974_update_clocks()
421 f = wm8974_get_mclkdiv(priv->mclk, fs256, &mclkdiv); in wm8974_update_clocks()
423 if (f != priv->mclk) { in wm8974_update_clocks()
428 wm8974_set_dai_pll(dai, 0, 0, priv->mclk, fpll); in wm8974_update_clocks()
437 struct snd_soc_component *component = dai->component; in wm8974_set_dai_sysclk()
441 return -EINVAL; in wm8974_set_dai_sysclk()
443 priv->mclk = freq; in wm8974_set_dai_sysclk()
451 struct snd_soc_component *component = codec_dai->component; in wm8974_set_dai_fmt()
456 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { in wm8974_set_dai_fmt()
463 return -EINVAL; in wm8974_set_dai_fmt()
467 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in wm8974_set_dai_fmt()
479 return -EINVAL; in wm8974_set_dai_fmt()
484 return -EINVAL; in wm8974_set_dai_fmt()
488 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { in wm8974_set_dai_fmt()
501 return -EINVAL; in wm8974_set_dai_fmt()
513 struct snd_soc_component *component = dai->component; in wm8974_pcm_hw_params()
519 priv->fs = params_rate(params); in wm8974_pcm_hw_params()
525 switch (params_width(params)) { in wm8974_pcm_hw_params()
540 switch (params_rate(params)) { in wm8974_pcm_hw_params()
568 struct snd_soc_component *component = dai->component; in wm8974_mute()
584 switch (level) { in wm8974_set_bias_level()
595 regcache_sync(dev_get_regmap(component->dev, NULL)); in wm8974_set_bias_level()
632 .name = "wm8974-hifi",
665 dev_err(component->dev, "Failed to issue reset\n"); in wm8974_probe()
693 priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); in wm8974_i2c_probe()
695 return -ENOMEM; in wm8974_i2c_probe()
703 ret = devm_snd_soc_register_component(&i2c->dev, in wm8974_i2c_probe()