Lines Matching +full:codec +full:- +full:aif2
1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm5110.c -- WM5110 ALSA SoC Audio driver
35 #define DRV_NAME "wm5110-codec"
161 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm5110_sysclk_ev()
162 struct arizona *arizona = dev_get_drvdata(component->dev->parent); in wm5110_sysclk_ev()
163 struct regmap *regmap = arizona->regmap; in wm5110_sysclk_ev()
167 switch (arizona->rev) { in wm5110_sysclk_ev()
198 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm5110_adsp_power_ev()
199 struct arizona *arizona = dev_get_drvdata(component->dev->parent); in wm5110_adsp_power_ev()
203 ret = regmap_read(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, &v); in wm5110_adsp_power_ev()
205 dev_err(component->dev, "Failed to read SYSCLK state: %d\n", ret); in wm5110_adsp_power_ev()
290 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm5110_hp_pre_enable()
292 struct arizona *arizona = priv->arizona; in wm5110_hp_pre_enable()
297 switch (w->shift) { in wm5110_hp_pre_enable()
305 priv->out_up_delay += 10; in wm5110_hp_pre_enable()
315 priv->out_up_delay += 10; in wm5110_hp_pre_enable()
322 return regmap_multi_reg_write(arizona->regmap, wseq, nregs); in wm5110_hp_pre_enable()
327 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm5110_hp_pre_disable()
331 switch (w->shift) { in wm5110_hp_pre_disable()
341 priv->out_down_delay += 27; in wm5110_hp_pre_disable()
353 priv->out_down_delay += 27; in wm5110_hp_pre_disable()
366 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm5110_hp_ev()
369 switch (priv->arizona->rev) { in wm5110_hp_ev()
394 ret = regmap_write(arizona->regmap, reg, 0x80); in wm5110_clear_pga_volume()
396 dev_err(arizona->dev, "Failed to clear PGA (0x%x): %d\n", in wm5110_clear_pga_volume()
407 struct arizona *arizona = dev_get_drvdata(component->dev->parent); in wm5110_put_dre()
409 (struct soc_mixer_control *)kcontrol->private_value; in wm5110_put_dre()
411 unsigned int mask = (0x1 << mc->shift) | (0x1 << mc->rshift); in wm5110_put_dre()
412 unsigned int lnew = (!!ucontrol->value.integer.value[0]) << mc->shift; in wm5110_put_dre()
413 unsigned int rnew = (!!ucontrol->value.integer.value[1]) << mc->rshift; in wm5110_put_dre()
421 ret = regmap_read(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1, &ena); in wm5110_put_dre()
423 dev_err(arizona->dev, "Failed to read output state: %d\n", ret); in wm5110_put_dre()
426 ret = regmap_read(arizona->regmap, ARIZONA_DRE_ENABLE, &dre); in wm5110_put_dre()
428 dev_err(arizona->dev, "Failed to read DRE state: %d\n", ret); in wm5110_put_dre()
432 lold = dre & (1 << mc->shift); in wm5110_put_dre()
433 rold = dre & (1 << mc->rshift); in wm5110_put_dre()
435 lena = ena & (1 << mc->rshift); in wm5110_put_dre()
436 rena = ena & (1 << mc->shift); in wm5110_put_dre()
439 dev_err(arizona->dev, "Can't change DRE on active outputs\n"); in wm5110_put_dre()
440 ret = -EBUSY; in wm5110_put_dre()
444 ret = regmap_update_bits_check(arizona->regmap, ARIZONA_DRE_ENABLE, in wm5110_put_dre()
447 dev_err(arizona->dev, "Failed to set DRE: %d\n", ret); in wm5110_put_dre()
453 wm5110_clear_pga_volume(arizona, mc->shift); in wm5110_put_dre()
456 wm5110_clear_pga_volume(arizona, mc->rshift); in wm5110_put_dre()
510 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm5110_in_analog_ev()
513 struct arizona *arizona = priv->arizona; in wm5110_in_analog_ev()
521 reg = ARIZONA_IN1L_CONTROL + ((w->shift ^ 0x1) * 4); in wm5110_in_analog_ev()
526 wm5110->in_value |= 0x3 << ((w->shift ^ 0x1) * 2); in wm5110_in_analog_ev()
527 wm5110->in_pre_pending++; in wm5110_in_analog_ev()
528 wm5110->in_post_pending++; in wm5110_in_analog_ev()
531 wm5110->in_pga_cache[w->shift] = snd_soc_component_read(component, reg); in wm5110_in_analog_ev()
536 wm5110->in_pre_pending--; in wm5110_in_analog_ev()
537 if (wm5110->in_pre_pending == 0) { in wm5110_in_analog_ev()
538 analog_seq[1].def = wm5110->in_value; in wm5110_in_analog_ev()
539 regmap_multi_reg_write_bypassed(arizona->regmap, in wm5110_in_analog_ev()
545 wm5110->in_value = 0; in wm5110_in_analog_ev()
551 wm5110->in_pga_cache[w->shift]); in wm5110_in_analog_ev()
553 wm5110->in_post_pending--; in wm5110_in_analog_ev()
554 if (wm5110->in_post_pending == 0) in wm5110_in_analog_ev()
555 regmap_multi_reg_write_bypassed(arizona->regmap, in wm5110_in_analog_ev()
569 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wm5110_in_ev()
571 struct arizona *arizona = priv->arizona; in wm5110_in_ev()
573 switch (arizona->rev) { in wm5110_in_ev()
575 if (arizona_input_analog(component, w->shift)) in wm5110_in_ev()
587 static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
588 static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
589 static DECLARE_TLV_DB_SCALE(noise_tlv, -13200, 600, 0);
590 static DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0);
698 ARIZONA_ANC_COEFF_END - ARIZONA_ANC_COEFF_START + 1),
701 ARIZONA_FCL_COEFF_END - ARIZONA_FCL_COEFF_START + 1),
704 ARIZONA_FCR_COEFF_END - ARIZONA_FCR_COEFF_START + 1),
1734 { "AIF2 Capture", NULL, "DBVDD2" },
1735 { "AIF2 Playback", NULL, "DBVDD2" },
1812 { "AIF2 Capture", NULL, "AIF2TX1" },
1813 { "AIF2 Capture", NULL, "AIF2TX2" },
1814 { "AIF2 Capture", NULL, "AIF2TX3" },
1815 { "AIF2 Capture", NULL, "AIF2TX4" },
1816 { "AIF2 Capture", NULL, "AIF2TX5" },
1817 { "AIF2 Capture", NULL, "AIF2TX6" },
1819 { "AIF2RX1", NULL, "AIF2 Playback" },
1820 { "AIF2RX2", NULL, "AIF2 Playback" },
1821 { "AIF2RX3", NULL, "AIF2 Playback" },
1822 { "AIF2RX4", NULL, "AIF2 Playback" },
1823 { "AIF2RX5", NULL, "AIF2 Playback" },
1824 { "AIF2RX6", NULL, "AIF2 Playback" },
1855 { "AIF2 Playback", NULL, "SYSCLK" },
1862 { "AIF2 Capture", NULL, "SYSCLK" },
2057 return arizona_set_fll(&wm5110->fll[0], source, Fref, Fout); in wm5110_set_fll()
2059 return arizona_set_fll(&wm5110->fll[1], source, Fref, Fout); in wm5110_set_fll()
2061 return arizona_set_fll_refclk(&wm5110->fll[0], source, Fref, in wm5110_set_fll()
2064 return arizona_set_fll_refclk(&wm5110->fll[1], source, Fref, in wm5110_set_fll()
2067 return -EINVAL; in wm5110_set_fll()
2082 .name = "wm5110-aif1",
2104 .name = "wm5110-aif2",
2108 .stream_name = "AIF2 Playback",
2115 .stream_name = "AIF2 Capture",
2126 .name = "wm5110-aif3",
2148 .name = "wm5110-slim1",
2167 .name = "wm5110-slim2",
2186 .name = "wm5110-slim3",
2205 .name = "wm5110-cpu-voicectrl",
2216 .name = "wm5110-dsp-voicectrl",
2226 .name = "wm5110-cpu-trace",
2237 .name = "wm5110-dsp-trace",
2251 struct snd_soc_pcm_runtime *rtd = stream->private_data; in wm5110_open()
2253 struct arizona *arizona = priv->core.arizona; in wm5110_open()
2256 if (strcmp(snd_soc_rtd_to_codec(rtd, 0)->name, "wm5110-dsp-voicectrl") == 0) { in wm5110_open()
2258 } else if (strcmp(snd_soc_rtd_to_codec(rtd, 0)->name, "wm5110-dsp-trace") == 0) { in wm5110_open()
2261 dev_err(arizona->dev, in wm5110_open()
2263 snd_soc_rtd_to_codec(rtd, 0)->name); in wm5110_open()
2264 return -EINVAL; in wm5110_open()
2267 return wm_adsp_compr_open(&priv->core.adsp[n_adsp], stream); in wm5110_open()
2273 struct arizona *arizona = priv->core.arizona; in wm5110_adsp2_irq()
2279 ret = wm_adsp_compr_handle_irq(&priv->core.adsp[i]); in wm5110_adsp2_irq()
2280 if (ret != -ENODEV) in wm5110_adsp2_irq()
2291 dev_err(arizona->dev, "Spurious compressed data IRQ\n"); in wm5110_adsp2_irq()
2302 struct arizona *arizona = priv->core.arizona; in wm5110_component_probe()
2305 arizona->dapm = dapm; in wm5110_component_probe()
2306 snd_soc_component_init_regmap(component, arizona->regmap); in wm5110_component_probe()
2316 ret = wm_adsp2_component_probe(&priv->core.adsp[i], component); in wm5110_component_probe()
2332 for (--i; i >= 0; --i) in wm5110_component_probe()
2333 wm_adsp2_component_remove(&priv->core.adsp[i], component); in wm5110_component_probe()
2344 wm_adsp2_component_remove(&priv->core.adsp[i], component); in wm5110_component_remove()
2346 priv->core.arizona->dapm = NULL; in wm5110_component_remove()
2396 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); in wm5110_probe()
2400 wm5110 = devm_kzalloc(&pdev->dev, sizeof(struct wm5110_priv), in wm5110_probe()
2403 return -ENOMEM; in wm5110_probe()
2407 if (!dev_get_platdata(arizona->dev)) { in wm5110_probe()
2414 wm5110->core.arizona = arizona; in wm5110_probe()
2415 wm5110->core.num_inputs = 8; in wm5110_probe()
2418 wm5110->core.adsp[i].part = "wm5110"; in wm5110_probe()
2419 wm5110->core.adsp[i].cs_dsp.num = i + 1; in wm5110_probe()
2420 wm5110->core.adsp[i].cs_dsp.type = WMFW_ADSP2; in wm5110_probe()
2421 wm5110->core.adsp[i].cs_dsp.dev = arizona->dev; in wm5110_probe()
2422 wm5110->core.adsp[i].cs_dsp.regmap = arizona->regmap; in wm5110_probe()
2424 wm5110->core.adsp[i].cs_dsp.base = ARIZONA_DSP1_CONTROL_1 in wm5110_probe()
2426 wm5110->core.adsp[i].cs_dsp.mem = wm5110_dsp_regions[i]; in wm5110_probe()
2427 wm5110->core.adsp[i].cs_dsp.num_mems in wm5110_probe()
2430 ret = wm_adsp2_init(&wm5110->core.adsp[i]); in wm5110_probe()
2435 /* This may return -EPROBE_DEFER, so do this early on */ in wm5110_probe()
2436 ret = arizona_jack_codec_dev_probe(&wm5110->core, &pdev->dev); in wm5110_probe()
2440 for (i = 0; i < ARRAY_SIZE(wm5110->fll); i++) in wm5110_probe()
2441 wm5110->fll[i].vco_mult = 3; in wm5110_probe()
2443 arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1, in wm5110_probe()
2445 &wm5110->fll[0]); in wm5110_probe()
2446 arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1, in wm5110_probe()
2448 &wm5110->fll[1]); in wm5110_probe()
2451 regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_2, in wm5110_probe()
2453 regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_3, in wm5110_probe()
2457 arizona_init_dai(&wm5110->core, i); in wm5110_probe()
2461 regmap_update_bits(arizona->regmap, wm5110_digital_vu[i], in wm5110_probe()
2464 pm_runtime_enable(&pdev->dev); in wm5110_probe()
2465 pm_runtime_idle(&pdev->dev); in wm5110_probe()
2471 dev_err(&pdev->dev, "Failed to request DSP IRQ: %d\n", ret); in wm5110_probe()
2477 dev_warn(&pdev->dev, in wm5110_probe()
2490 ret = devm_snd_soc_register_component(&pdev->dev, in wm5110_probe()
2495 dev_err(&pdev->dev, "Failed to register component: %d\n", ret); in wm5110_probe()
2507 pm_runtime_disable(&pdev->dev); in wm5110_probe()
2508 arizona_jack_codec_dev_remove(&wm5110->core); in wm5110_probe()
2516 struct arizona *arizona = wm5110->core.arizona; in wm5110_remove()
2519 pm_runtime_disable(&pdev->dev); in wm5110_remove()
2522 wm_adsp2_remove(&wm5110->core.adsp[i]); in wm5110_remove()
2529 arizona_jack_codec_dev_remove(&wm5110->core); in wm5110_remove()
2534 .name = "wm5110-codec",
2545 MODULE_ALIAS("platform:wm5110-codec");