• Home
  • Raw
  • Download

Lines Matching +full:boost +full:- +full:bypass

2  * wm8960.c  --  WM8960 ALSA SoC Audio driver
4 * Copyright 2007-11 Wolfson Microelectronics, plc
31 /* R25 - Power 1 */
35 /* R26 - Power 2 */
40 /* R28 - Anti-pop 1 */
47 /* R29 - Anti-pop 2 */
179 if (wm8960->deemph) { in wm8960_set_deemph()
182 if (abs(deemph_settings[i] - wm8960->lrclk) < in wm8960_set_deemph()
183 abs(deemph_settings[best] - wm8960->lrclk)) in wm8960_set_deemph()
192 dev_dbg(component->dev, "Set deemphasis %d\n", val); in wm8960_set_deemph()
204 ucontrol->value.integer.value[0] = wm8960->deemph; in wm8960_get_deemph()
213 unsigned int deemph = ucontrol->value.integer.value[0]; in wm8960_put_deemph()
216 return -EINVAL; in wm8960_put_deemph()
218 wm8960->deemph = deemph; in wm8960_put_deemph()
223 static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1);
224 static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1725, 75, 0);
225 static const DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 1);
226 static const DECLARE_TLV_DB_SCALE(bypass_tlv, -2100, 300, 0);
227 static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
228 static const DECLARE_TLV_DB_SCALE(lineinboost_tlv, -1500, 300, 1);
242 SOC_SINGLE_TLV("Left Input Boost Mixer LINPUT3 Volume",
244 SOC_SINGLE_TLV("Left Input Boost Mixer LINPUT2 Volume",
246 SOC_SINGLE_TLV("Right Input Boost Mixer RINPUT3 Volume",
248 SOC_SINGLE_TLV("Right Input Boost Mixer RINPUT2 Volume",
250 SOC_SINGLE_TLV("Right Input Boost Mixer RINPUT1 Volume",
252 SOC_SINGLE_TLV("Left Input Boost Mixer LINPUT1 Volume",
270 SOC_SINGLE("PCM Playback -6dB Switch", WM8960_DACCTL1, 7, 1, 0),
278 SOC_ENUM("3D Filter Upper Cut-Off", wm8960_enum[2]),
279 SOC_ENUM("3D Filter Lower Cut-Off", wm8960_enum[3]),
298 SOC_SINGLE_TLV("Left Output Mixer Boost Bypass Volume",
302 SOC_SINGLE_TLV("Right Output Mixer Boost Bypass Volume",
318 SOC_DAPM_SINGLE("Boost Switch", WM8960_LINPATH, 3, 1, 0),
328 SOC_DAPM_SINGLE("Boost Switch", WM8960_RINPATH, 3, 1, 0),
334 SOC_DAPM_SINGLE("Boost Bypass Switch", WM8960_BYPASS1, 7, 1, 0),
340 SOC_DAPM_SINGLE("Boost Bypass Switch", WM8960_BYPASS2, 7, 1, 0),
358 SND_SOC_DAPM_MIXER("Left Boost Mixer", WM8960_POWER1, 5, 0,
360 SND_SOC_DAPM_MIXER("Right Boost Mixer", WM8960_POWER1, 4, 0,
411 { "Left Boost Mixer", "LINPUT1 Switch", "LINPUT1" },
412 { "Left Boost Mixer", "LINPUT2 Switch", "LINPUT2" },
413 { "Left Boost Mixer", "LINPUT3 Switch", "LINPUT3" },
415 { "Left Input Mixer", "Boost Switch", "Left Boost Mixer" },
416 { "Left Input Mixer", "Boost Switch", "LINPUT1" }, /* Really Boost Switch */
420 { "Right Boost Mixer", "RINPUT1 Switch", "RINPUT1" },
421 { "Right Boost Mixer", "RINPUT2 Switch", "RINPUT2" },
422 { "Right Boost Mixer", "RINPUT3 Switch", "RINPUT3" },
424 { "Right Input Mixer", "Boost Switch", "Right Boost Mixer" },
425 { "Right Input Mixer", "Boost Switch", "RINPUT1" }, /* Really Boost Switch */
433 { "Left Output Mixer", "Boost Bypass Switch", "Left Boost Mixer" },
437 { "Right Output Mixer", "Boost Bypass Switch", "Right Boost Mixer" },
476 struct wm8960_data *pdata = &wm8960->pdata; in wm8960_add_widgets()
488 if (pdata && pdata->capless) { in wm8960_add_widgets()
507 list_for_each_entry(w, &component->card->widgets, list) { in wm8960_add_widgets()
508 if (w->dapm != dapm) in wm8960_add_widgets()
510 if (strcmp(w->name, "LOUT1 PGA") == 0) in wm8960_add_widgets()
511 wm8960->lout1 = w; in wm8960_add_widgets()
512 if (strcmp(w->name, "ROUT1 PGA") == 0) in wm8960_add_widgets()
513 wm8960->rout1 = w; in wm8960_add_widgets()
514 if (strcmp(w->name, "OUT3 VMID") == 0) in wm8960_add_widgets()
515 wm8960->out3 = w; in wm8960_add_widgets()
524 struct snd_soc_component *component = codec_dai->component; in wm8960_set_dai_fmt()
535 return -EINVAL; in wm8960_set_dai_fmt()
555 return -EINVAL; in wm8960_set_dai_fmt()
572 return -EINVAL; in wm8960_set_dai_fmt()
595 /* -1 for reserved value */
596 static const int sysclk_divs[] = { 1, -1, 2, -1 };
608 * wm8960_configure_sysclk - checks if there is a sysclk frequency available
610 * - sysclk = MCLK / sysclk_divs
611 * - lrclk = sysclk / dac_divs
612 * - 10 * bclk = sysclk / bclk_divs
625 * -1, in case no sysclk frequency available found
638 *bclk_idx = -1; in wm8960_configure_sysclk()
640 bclk = wm8960->bclk; in wm8960_configure_sysclk()
641 lrclk = wm8960->lrclk; in wm8960_configure_sysclk()
645 if (sysclk_divs[i] == -1) in wm8960_configure_sysclk()
652 diff = sysclk - bclk * bclk_divs[k] / 10; in wm8960_configure_sysclk()
676 * wm8960_configure_pll - checks if there is a PLL out frequency available
678 * - sysclk = lrclk * dac_divs
679 * - freq_out = sysclk * sysclk_divs
680 * - 10 * sysclk = bclk * bclk_divs
706 bclk = wm8960->bclk; in wm8960_configure_pll()
707 lrclk = wm8960->lrclk; in wm8960_configure_pll()
710 best_freq_out = -EINVAL; in wm8960_configure_pll()
711 *sysclk_idx = *dac_idx = *bclk_idx = -1; in wm8960_configure_pll()
714 if (sysclk_divs[i] == -1) in wm8960_configure_pll()
724 diff = sysclk - bclk * bclk_divs[k] / 10; in wm8960_configure_pll()
753 dev_dbg(component->dev, in wm8960_configure_clocking()
758 if (wm8960->clk_id != WM8960_SYSCLK_MCLK && !wm8960->freq_in) { in wm8960_configure_clocking()
759 dev_err(component->dev, "No MCLK configured\n"); in wm8960_configure_clocking()
760 return -EINVAL; in wm8960_configure_clocking()
763 freq_in = wm8960->freq_in; in wm8960_configure_clocking()
770 if (wm8960->clk_id == WM8960_SYSCLK_AUTO) { in wm8960_configure_clocking()
774 } else if (wm8960->sysclk) { in wm8960_configure_clocking()
775 freq_out = wm8960->sysclk; in wm8960_configure_clocking()
777 dev_err(component->dev, "No SYSCLK configured\n"); in wm8960_configure_clocking()
778 return -EINVAL; in wm8960_configure_clocking()
781 if (wm8960->clk_id != WM8960_SYSCLK_PLL) { in wm8960_configure_clocking()
785 } else if (wm8960->clk_id != WM8960_SYSCLK_AUTO) { in wm8960_configure_clocking()
786 dev_err(component->dev, "failed to configure clock\n"); in wm8960_configure_clocking()
787 return -EINVAL; in wm8960_configure_clocking()
793 dev_err(component->dev, "failed to configure clock via PLL\n"); in wm8960_configure_clocking()
816 struct snd_soc_component *component = dai->component; in wm8960_hw_params()
819 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in wm8960_hw_params()
822 wm8960->bclk = snd_soc_params_to_bclk(params); in wm8960_hw_params()
824 wm8960->bclk *= 2; in wm8960_hw_params()
844 dev_err(component->dev, "unsupported width %d\n", in wm8960_hw_params()
846 return -EINVAL; in wm8960_hw_params()
849 wm8960->lrclk = params_rate(params); in wm8960_hw_params()
864 wm8960->is_stream_in_use[tx] = true; in wm8960_hw_params()
866 if (!wm8960->is_stream_in_use[!tx]) in wm8960_hw_params()
875 struct snd_soc_component *component = dai->component; in wm8960_hw_free()
877 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in wm8960_hw_free()
879 wm8960->is_stream_in_use[tx] = false; in wm8960_hw_free()
886 struct snd_soc_component *component = dai->component; in wm8960_mute()
909 if (!IS_ERR(wm8960->mclk)) { in wm8960_set_bias_level_out3()
910 ret = clk_prepare_enable(wm8960->mclk); in wm8960_set_bias_level_out3()
912 dev_err(component->dev, in wm8960_set_bias_level_out3()
932 if (wm8960->clk_id == WM8960_SYSCLK_AUTO && (pm2 & 0x1)) in wm8960_set_bias_level_out3()
935 if (!IS_ERR(wm8960->mclk)) in wm8960_set_bias_level_out3()
936 clk_disable_unprepare(wm8960->mclk); in wm8960_set_bias_level_out3()
947 regcache_sync(wm8960->regmap); in wm8960_set_bias_level_out3()
949 /* Enable anti-pop features */ in wm8960_set_bias_level_out3()
962 /* Disable anti-pop features */ in wm8960_set_bias_level_out3()
971 /* Enable anti-pop features */ in wm8960_set_bias_level_out3()
1008 if (wm8960->lout1 && wm8960->lout1->power) in wm8960_set_bias_level_capless()
1010 if (wm8960->rout1 && wm8960->rout1->power) in wm8960_set_bias_level_capless()
1012 if (wm8960->out3 && wm8960->out3->power) in wm8960_set_bias_level_capless()
1032 if (!IS_ERR(wm8960->mclk)) { in wm8960_set_bias_level_capless()
1033 ret = clk_prepare_enable(wm8960->mclk); in wm8960_set_bias_level_capless()
1035 dev_err(component->dev, in wm8960_set_bias_level_capless()
1053 if (wm8960->clk_id == WM8960_SYSCLK_AUTO && (pm2 & 0x1)) in wm8960_set_bias_level_capless()
1056 if (!IS_ERR(wm8960->mclk)) in wm8960_set_bias_level_capless()
1057 clk_disable_unprepare(wm8960->mclk); in wm8960_set_bias_level_capless()
1059 /* Enable anti-pop mode */ in wm8960_set_bias_level_capless()
1072 regcache_sync(wm8960->regmap); in wm8960_set_bias_level_capless()
1087 /* Disable anti-pop features */ in wm8960_set_bias_level_capless()
1146 pr_debug("WM8960 PLL: setting %dHz->%dHz\n", source, target); in pll_factors()
1154 pll_div->pre_div = 1; in pll_factors()
1157 pll_div->pre_div = 0; in pll_factors()
1161 return -EINVAL; in pll_factors()
1164 pll_div->n = Ndiv; in pll_factors()
1179 pll_div->k = K; in pll_factors()
1182 pll_div->n, pll_div->k, pll_div->pre_div); in pll_factors()
1232 struct snd_soc_component *component = codec_dai->component; in wm8960_set_dai_pll()
1235 wm8960->freq_in = freq_in; in wm8960_set_dai_pll()
1246 struct snd_soc_component *component = codec_dai->component; in wm8960_set_dai_clkdiv()
1271 return -EINVAL; in wm8960_set_dai_clkdiv()
1282 return wm8960->set_bias_level(component, level); in wm8960_set_bias_level()
1288 struct snd_soc_component *component = dai->component; in wm8960_set_dai_sysclk()
1303 return -EINVAL; in wm8960_set_dai_sysclk()
1306 wm8960->sysclk = freq; in wm8960_set_dai_sysclk()
1307 wm8960->clk_id = clk_id; in wm8960_set_dai_sysclk()
1329 .name = "wm8960-hifi",
1349 struct wm8960_data *pdata = &wm8960->pdata; in wm8960_probe()
1351 if (pdata->capless) in wm8960_probe()
1352 wm8960->set_bias_level = wm8960_set_bias_level_capless; in wm8960_probe()
1354 wm8960->set_bias_level = wm8960_set_bias_level_out3; in wm8960_probe()
1388 const struct device_node *np = i2c->dev.of_node; in wm8960_set_pdata_from_of()
1391 pdata->capless = true; in wm8960_set_pdata_from_of()
1393 if (of_property_read_bool(np, "wlf,shared-lrclk")) in wm8960_set_pdata_from_of()
1394 pdata->shared_lrclk = true; in wm8960_set_pdata_from_of()
1400 struct wm8960_data *pdata = dev_get_platdata(&i2c->dev); in wm8960_i2c_probe()
1404 wm8960 = devm_kzalloc(&i2c->dev, sizeof(struct wm8960_priv), in wm8960_i2c_probe()
1407 return -ENOMEM; in wm8960_i2c_probe()
1409 wm8960->mclk = devm_clk_get(&i2c->dev, "mclk"); in wm8960_i2c_probe()
1410 if (IS_ERR(wm8960->mclk)) { in wm8960_i2c_probe()
1411 if (PTR_ERR(wm8960->mclk) == -EPROBE_DEFER) in wm8960_i2c_probe()
1412 return -EPROBE_DEFER; in wm8960_i2c_probe()
1415 wm8960->regmap = devm_regmap_init_i2c(i2c, &wm8960_regmap); in wm8960_i2c_probe()
1416 if (IS_ERR(wm8960->regmap)) in wm8960_i2c_probe()
1417 return PTR_ERR(wm8960->regmap); in wm8960_i2c_probe()
1420 memcpy(&wm8960->pdata, pdata, sizeof(struct wm8960_data)); in wm8960_i2c_probe()
1421 else if (i2c->dev.of_node) in wm8960_i2c_probe()
1422 wm8960_set_pdata_from_of(i2c, &wm8960->pdata); in wm8960_i2c_probe()
1424 ret = wm8960_reset(wm8960->regmap); in wm8960_i2c_probe()
1426 dev_err(&i2c->dev, "Failed to issue reset\n"); in wm8960_i2c_probe()
1430 if (wm8960->pdata.shared_lrclk) { in wm8960_i2c_probe()
1431 ret = regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2, in wm8960_i2c_probe()
1434 dev_err(&i2c->dev, "Failed to enable LRCM: %d\n", in wm8960_i2c_probe()
1441 regmap_update_bits(wm8960->regmap, WM8960_LINVOL, 0x100, 0x100); in wm8960_i2c_probe()
1442 regmap_update_bits(wm8960->regmap, WM8960_RINVOL, 0x100, 0x100); in wm8960_i2c_probe()
1443 regmap_update_bits(wm8960->regmap, WM8960_LADC, 0x100, 0x100); in wm8960_i2c_probe()
1444 regmap_update_bits(wm8960->regmap, WM8960_RADC, 0x100, 0x100); in wm8960_i2c_probe()
1445 regmap_update_bits(wm8960->regmap, WM8960_LDAC, 0x100, 0x100); in wm8960_i2c_probe()
1446 regmap_update_bits(wm8960->regmap, WM8960_RDAC, 0x100, 0x100); in wm8960_i2c_probe()
1447 regmap_update_bits(wm8960->regmap, WM8960_LOUT1, 0x100, 0x100); in wm8960_i2c_probe()
1448 regmap_update_bits(wm8960->regmap, WM8960_ROUT1, 0x100, 0x100); in wm8960_i2c_probe()
1449 regmap_update_bits(wm8960->regmap, WM8960_LOUT2, 0x100, 0x100); in wm8960_i2c_probe()
1450 regmap_update_bits(wm8960->regmap, WM8960_ROUT2, 0x100, 0x100); in wm8960_i2c_probe()
1454 ret = devm_snd_soc_register_component(&i2c->dev, in wm8960_i2c_probe()