Lines Matching +full:asi +full:- +full:format
1 // SPDX-License-Identifier: GPL-2.0-only
3 * tas2552.c - ALSA SoC Texas Instruments TAS2552 Mono Audio Amplifier
5 * Copyright (C) 2014 - 2024 Texas Instruments Incorporated -
27 #include <sound/soc-dapm.h>
29 #include <sound/tas2552-plat.h>
30 #include <dt-bindings/sound/tas2552.h>
84 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in tas2552_post_event()
123 SND_SOC_DAPM_AIF_OUT("ASI OUT", "DAC Capture", 0, SND_SOC_NOPM, 0, 0),
140 {"ASI OUT", NULL, "DMIC"}
148 if (!tas2552->component) in tas2552_sw_shutdown()
154 snd_soc_component_update_bits(tas2552->component, TAS2552_CFG_1, TAS2552_SWS, in tas2552_sw_shutdown()
162 struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); in tas2552_setup_pll()
165 unsigned int pll_clkin = tas2552->pll_clkin; in tas2552_setup_pll()
169 if (tas2552->pll_clk_id != TAS2552_PLL_CLKIN_BCLK) in tas2552_setup_pll()
170 return -EINVAL; in tas2552_setup_pll()
173 pll_clkin += tas2552->tdm_delay; in tas2552_setup_pll()
193 u8 pll_sel = (tas2552->pll_clk_id << 3) & TAS2552_PLL_SRC_MASK; in tas2552_setup_pll()
204 d = q + ((9999 - pll_clkin % 10000) * (d / t - q)) / 10000; in tas2552_setup_pll()
207 if (tas2552->pll_clk_id == TAS2552_PLL_CLKIN_BCLK) { in tas2552_setup_pll()
213 pll_clkin += tas2552->tdm_delay; in tas2552_setup_pll()
243 struct snd_soc_component *component = dai->component; in tas2552_hw_params()
244 struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); in tas2552_hw_params()
251 cpf = 32 + tas2552->tdm_delay; in tas2552_hw_params()
255 cpf = 64 + tas2552->tdm_delay; in tas2552_hw_params()
259 cpf = 64 + tas2552->tdm_delay; in tas2552_hw_params()
263 cpf = 64 + tas2552->tdm_delay; in tas2552_hw_params()
266 dev_err(component->dev, "Not supported sample size: %d\n", in tas2552_hw_params()
268 return -EINVAL; in tas2552_hw_params()
315 dev_err(component->dev, "Not supported sample rate: %d\n", in tas2552_hw_params()
317 return -EINVAL; in tas2552_hw_params()
332 struct snd_soc_component *component = dai->component; in tas2552_prepare()
337 if (tas2552->dai_fmt == SND_SOC_DAIFMT_DSP_A) in tas2552_prepare()
338 delay += (tas2552->tdm_delay + 1); in tas2552_prepare()
339 else if (tas2552->dai_fmt == SND_SOC_DAIFMT_DSP_B) in tas2552_prepare()
340 delay += tas2552->tdm_delay; in tas2552_prepare()
350 struct snd_soc_component *component = dai->component; in tas2552_set_dai_fmt()
351 struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); in tas2552_set_dai_fmt()
368 dev_vdbg(component->dev, "DAI Format master is not found\n"); in tas2552_set_dai_fmt()
369 return -EINVAL; in tas2552_set_dai_fmt()
387 dev_vdbg(component->dev, "DAI Format is not found\n"); in tas2552_set_dai_fmt()
388 return -EINVAL; in tas2552_set_dai_fmt()
390 tas2552->dai_fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in tas2552_set_dai_fmt()
400 struct snd_soc_component *component = dai->component; in tas2552_set_dai_sysclk()
401 struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); in tas2552_set_dai_sysclk()
409 dev_warn(component->dev, "Out of range PLL_CLKIN: %u\n", in tas2552_set_dai_sysclk()
420 tas2552->pll_clk_id = clk_id; in tas2552_set_dai_sysclk()
421 tas2552->pll_clkin = freq; in tas2552_set_dai_sysclk()
430 tas2552->pdm_clk_id = clk_id; in tas2552_set_dai_sysclk()
431 tas2552->pdm_clk = freq; in tas2552_set_dai_sysclk()
434 dev_err(component->dev, "Invalid clk id: %d\n", clk_id); in tas2552_set_dai_sysclk()
435 return -EINVAL; in tas2552_set_dai_sysclk()
447 struct snd_soc_component *component = dai->component; in tas2552_set_dai_tdm_slot()
452 dev_err(component->dev, "tx masks need to be non 0\n"); in tas2552_set_dai_tdm_slot()
453 return -EINVAL; in tas2552_set_dai_tdm_slot()
459 dev_err(component->dev, "Invalid mask, slots must be adjacent\n"); in tas2552_set_dai_tdm_slot()
460 return -EINVAL; in tas2552_set_dai_tdm_slot()
463 tas2552->tdm_delay = lsb * slot_width; in tas2552_set_dai_tdm_slot()
465 /* DOUT in high-impedance on inactive bit clocks */ in tas2552_set_dai_tdm_slot()
475 struct snd_soc_component *component = dai->component; in tas2552_mute()
492 regcache_cache_only(tas2552->regmap, true); in tas2552_runtime_suspend()
493 regcache_mark_dirty(tas2552->regmap); in tas2552_runtime_suspend()
495 gpiod_set_value(tas2552->enable_gpio, 0); in tas2552_runtime_suspend()
504 gpiod_set_value(tas2552->enable_gpio, 1); in tas2552_runtime_resume()
508 regcache_cache_only(tas2552->regmap, false); in tas2552_runtime_resume()
509 regcache_sync(tas2552->regmap); in tas2552_runtime_resume()
537 .name = "tas2552-amplifier",
557 * DAC digital volumes. From -7 to 24 dB in 1 dB steps
559 static DECLARE_TLV_DB_SCALE(dac_tlv, -700, 100, 0);
582 tas2552->component = component; in tas2552_component_probe()
584 ret = regulator_bulk_enable(ARRAY_SIZE(tas2552->supplies), in tas2552_component_probe()
585 tas2552->supplies); in tas2552_component_probe()
588 dev_err(component->dev, "Failed to enable supplies: %d\n", in tas2552_component_probe()
593 gpiod_set_value(tas2552->enable_gpio, 1); in tas2552_component_probe()
595 ret = pm_runtime_resume_and_get(component->dev); in tas2552_component_probe()
597 dev_err(component->dev, "Enabling device failed: %d\n", in tas2552_component_probe()
617 pm_runtime_put_noidle(component->dev); in tas2552_component_probe()
618 gpiod_set_value(tas2552->enable_gpio, 0); in tas2552_component_probe()
620 regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies), in tas2552_component_probe()
621 tas2552->supplies); in tas2552_component_probe()
629 pm_runtime_put(component->dev); in tas2552_component_remove()
631 gpiod_set_value(tas2552->enable_gpio, 0); in tas2552_component_remove()
640 ret = regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies), in tas2552_suspend()
641 tas2552->supplies); in tas2552_suspend()
644 dev_err(component->dev, "Failed to disable supplies: %d\n", in tas2552_suspend()
654 ret = regulator_bulk_enable(ARRAY_SIZE(tas2552->supplies), in tas2552_resume()
655 tas2552->supplies); in tas2552_resume()
658 dev_err(component->dev, "Failed to enable supplies: %d\n", in tas2552_resume()
701 dev = &client->dev; in tas2552_probe()
702 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); in tas2552_probe()
704 return -ENOMEM; in tas2552_probe()
706 data->enable_gpio = devm_gpiod_get_optional(dev, "enable", in tas2552_probe()
708 if (IS_ERR(data->enable_gpio)) in tas2552_probe()
709 return PTR_ERR(data->enable_gpio); in tas2552_probe()
711 data->tas2552_client = client; in tas2552_probe()
712 data->regmap = devm_regmap_init_i2c(client, &tas2552_regmap_config); in tas2552_probe()
713 if (IS_ERR(data->regmap)) { in tas2552_probe()
714 ret = PTR_ERR(data->regmap); in tas2552_probe()
715 dev_err(&client->dev, "Failed to allocate register map: %d\n", in tas2552_probe()
720 for (i = 0; i < ARRAY_SIZE(data->supplies); i++) in tas2552_probe()
721 data->supplies[i].supply = tas2552_supply_names[i]; in tas2552_probe()
723 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies), in tas2552_probe()
724 data->supplies); in tas2552_probe()
730 pm_runtime_set_active(&client->dev); in tas2552_probe()
731 pm_runtime_set_autosuspend_delay(&client->dev, 1000); in tas2552_probe()
732 pm_runtime_use_autosuspend(&client->dev); in tas2552_probe()
733 pm_runtime_enable(&client->dev); in tas2552_probe()
734 pm_runtime_mark_last_busy(&client->dev); in tas2552_probe()
735 pm_runtime_put_sync_autosuspend(&client->dev); in tas2552_probe()
737 dev_set_drvdata(&client->dev, data); in tas2552_probe()
739 ret = devm_snd_soc_register_component(&client->dev, in tas2552_probe()
743 dev_err(&client->dev, "Failed to register component: %d\n", ret); in tas2552_probe()
744 pm_runtime_get_noresume(&client->dev); in tas2552_probe()
752 pm_runtime_disable(&client->dev); in tas2552_i2c_remove()