• Home
  • Raw
  • Download

Lines Matching +full:codec +full:- +full:clkout

1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8731.c -- WM8731 ALSA SoC Audio driver
6 * Copyright 2006-12 Wolfson Microelectronics, plc
43 /* codec private data */
96 if (wm8731->deemph) { in wm8731_set_deemph()
99 if (abs(wm8731_deemph[i] - wm8731->playback_fs) < in wm8731_set_deemph()
100 abs(wm8731_deemph[best] - wm8731->playback_fs)) in wm8731_set_deemph()
110 dev_dbg(component->dev, "Set deemphasis %d (%dHz)\n", in wm8731_set_deemph()
122 ucontrol->value.integer.value[0] = wm8731->deemph; in wm8731_get_deemph()
132 unsigned int deemph = ucontrol->value.integer.value[0]; in wm8731_put_deemph()
136 return -EINVAL; in wm8731_put_deemph()
138 mutex_lock(&wm8731->lock); in wm8731_put_deemph()
139 if (wm8731->deemph != deemph) { in wm8731_put_deemph()
140 wm8731->deemph = deemph; in wm8731_put_deemph()
146 mutex_unlock(&wm8731->lock); in wm8731_put_deemph()
151 static const DECLARE_TLV_DB_SCALE(in_tlv, -3450, 150, 0);
152 static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -1500, 300, 0);
153 static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
214 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in wm8731_check_osc()
217 return wm8731->sysclk_type == WM8731_SYSCLK_XTAL; in wm8731_check_osc()
257 /* codec mclk clock divider coefficients */
337 struct snd_soc_component *component = dai->component; in wm8731_hw_params()
340 int i = get_coeff(wm8731->sysclk, params_rate(params)); in wm8731_hw_params()
344 wm8731->playback_fs = params_rate(params); in wm8731_hw_params()
371 struct snd_soc_component *component = dai->component; in wm8731_mute()
384 struct snd_soc_component *component = codec_dai->component; in wm8731_set_dai_sysclk()
391 if (wm8731->mclk && clk_set_rate(wm8731->mclk, freq)) in wm8731_set_dai_sysclk()
392 return -EINVAL; in wm8731_set_dai_sysclk()
393 wm8731->sysclk_type = clk_id; in wm8731_set_dai_sysclk()
396 return -EINVAL; in wm8731_set_dai_sysclk()
401 wm8731->constraints = NULL; in wm8731_set_dai_sysclk()
404 wm8731->constraints = &wm8731_constraints_12000000; in wm8731_set_dai_sysclk()
408 wm8731->constraints = &wm8731_constraints_12288000_18432000; in wm8731_set_dai_sysclk()
412 wm8731->constraints = &wm8731_constraints_11289600_16934400; in wm8731_set_dai_sysclk()
415 return -EINVAL; in wm8731_set_dai_sysclk()
418 wm8731->sysclk = freq; in wm8731_set_dai_sysclk()
429 struct snd_soc_component *component = codec_dai->component; in wm8731_set_dai_fmt()
440 return -EINVAL; in wm8731_set_dai_fmt()
460 return -EINVAL; in wm8731_set_dai_fmt()
477 return -EINVAL; in wm8731_set_dai_fmt()
494 if (wm8731->mclk) { in wm8731_set_bias_level()
495 ret = clk_prepare_enable(wm8731->mclk); in wm8731_set_bias_level()
504 ret = regulator_bulk_enable(ARRAY_SIZE(wm8731->supplies), in wm8731_set_bias_level()
505 wm8731->supplies); in wm8731_set_bias_level()
509 regcache_sync(wm8731->regmap); in wm8731_set_bias_level()
512 /* Clear PWROFF, gate CLKOUT, everything else as-is */ in wm8731_set_bias_level()
517 if (wm8731->mclk) in wm8731_set_bias_level()
518 clk_disable_unprepare(wm8731->mclk); in wm8731_set_bias_level()
520 regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), in wm8731_set_bias_level()
521 wm8731->supplies); in wm8731_set_bias_level()
522 regcache_mark_dirty(wm8731->regmap); in wm8731_set_bias_level()
531 struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(dai->component); in wm8731_startup()
533 if (wm8731->constraints) in wm8731_startup()
534 snd_pcm_hw_constraint_list(substream->runtime, 0, in wm8731_startup()
536 wm8731->constraints); in wm8731_startup()
556 .name = "wm8731-hifi",
578 for (i = 0; i < ARRAY_SIZE(wm8731->supplies); i++) in wm8731_request_supplies()
579 wm8731->supplies[i].supply = wm8731_supply_names[i]; in wm8731_request_supplies()
581 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(wm8731->supplies), in wm8731_request_supplies()
582 wm8731->supplies); in wm8731_request_supplies()
588 ret = regulator_bulk_enable(ARRAY_SIZE(wm8731->supplies), in wm8731_request_supplies()
589 wm8731->supplies); in wm8731_request_supplies()
602 ret = wm8731_reset(wm8731->regmap); in wm8731_hw_init()
609 regmap_write(wm8731->regmap, WM8731_PWR, 0x7f); in wm8731_hw_init()
612 regmap_update_bits(wm8731->regmap, WM8731_LOUT1V, 0x100, 0); in wm8731_hw_init()
613 regmap_update_bits(wm8731->regmap, WM8731_ROUT1V, 0x100, 0); in wm8731_hw_init()
614 regmap_update_bits(wm8731->regmap, WM8731_LINVOL, 0x100, 0); in wm8731_hw_init()
615 regmap_update_bits(wm8731->regmap, WM8731_RINVOL, 0x100, 0); in wm8731_hw_init()
618 regmap_update_bits(wm8731->regmap, WM8731_APANA, 0x8, 0); in wm8731_hw_init()
620 regcache_mark_dirty(wm8731->regmap); in wm8731_hw_init()
624 regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); in wm8731_hw_init()
669 wm8731 = devm_kzalloc(&spi->dev, sizeof(*wm8731), GFP_KERNEL); in wm8731_spi_probe()
671 return -ENOMEM; in wm8731_spi_probe()
673 wm8731->mclk = devm_clk_get(&spi->dev, "mclk"); in wm8731_spi_probe()
674 if (IS_ERR(wm8731->mclk)) { in wm8731_spi_probe()
675 ret = PTR_ERR(wm8731->mclk); in wm8731_spi_probe()
676 if (ret == -ENOENT) { in wm8731_spi_probe()
677 wm8731->mclk = NULL; in wm8731_spi_probe()
678 dev_warn(&spi->dev, "Assuming static MCLK\n"); in wm8731_spi_probe()
680 dev_err(&spi->dev, "Failed to get MCLK: %d\n", in wm8731_spi_probe()
686 mutex_init(&wm8731->lock); in wm8731_spi_probe()
690 ret = wm8731_request_supplies(&spi->dev, wm8731); in wm8731_spi_probe()
694 wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap); in wm8731_spi_probe()
695 if (IS_ERR(wm8731->regmap)) { in wm8731_spi_probe()
696 ret = PTR_ERR(wm8731->regmap); in wm8731_spi_probe()
697 dev_err(&spi->dev, "Failed to allocate register map: %d\n", in wm8731_spi_probe()
702 ret = wm8731_hw_init(&spi->dev, wm8731); in wm8731_spi_probe()
706 ret = devm_snd_soc_register_component(&spi->dev, in wm8731_spi_probe()
709 dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret); in wm8731_spi_probe()
738 wm8731 = devm_kzalloc(&i2c->dev, sizeof(struct wm8731_priv), in wm8731_i2c_probe()
741 return -ENOMEM; in wm8731_i2c_probe()
743 wm8731->mclk = devm_clk_get(&i2c->dev, "mclk"); in wm8731_i2c_probe()
744 if (IS_ERR(wm8731->mclk)) { in wm8731_i2c_probe()
745 ret = PTR_ERR(wm8731->mclk); in wm8731_i2c_probe()
746 if (ret == -ENOENT) { in wm8731_i2c_probe()
747 wm8731->mclk = NULL; in wm8731_i2c_probe()
748 dev_warn(&i2c->dev, "Assuming static MCLK\n"); in wm8731_i2c_probe()
750 dev_err(&i2c->dev, "Failed to get MCLK: %d\n", in wm8731_i2c_probe()
756 mutex_init(&wm8731->lock); in wm8731_i2c_probe()
760 ret = wm8731_request_supplies(&i2c->dev, wm8731); in wm8731_i2c_probe()
764 wm8731->regmap = devm_regmap_init_i2c(i2c, &wm8731_regmap); in wm8731_i2c_probe()
765 if (IS_ERR(wm8731->regmap)) { in wm8731_i2c_probe()
766 ret = PTR_ERR(wm8731->regmap); in wm8731_i2c_probe()
767 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in wm8731_i2c_probe()
772 ret = wm8731_hw_init(&i2c->dev, wm8731); in wm8731_i2c_probe()
776 ret = devm_snd_soc_register_component(&i2c->dev, in wm8731_i2c_probe()
779 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); in wm8731_i2c_probe()