Lines Matching +full:mt8195 +full:- +full:audio

1 // SPDX-License-Identifier: GPL-2.0
3 * MediaTek ALSA SoC Audio DAI ADDA Control
12 #include "mt8195-afe-clk.h"
13 #include "mt8195-afe-common.h"
14 #include "mt8195-reg.h"
15 #include "../common/mtk-dai-adda-common.h"
40 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_adda_mtkaif_init()
41 struct mtkaif_param *param = &afe_priv->mtkaif_params; in mt8195_adda_mtkaif_init()
51 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_CFG0, mask, val); in mt8195_adda_mtkaif_init()
52 regmap_update_bits(afe->regmap, AFE_ADDA6_MTKAIF_CFG0, mask, val); in mt8195_adda_mtkaif_init()
56 regmap_update_bits(afe->regmap, AFE_AUD_PAD_TOP, mask, val); in mt8195_adda_mtkaif_init()
58 if (!param->mtkaif_calibration_ok) { in mt8195_adda_mtkaif_init()
59 dev_info(afe->dev, "%s(), calibration fail\n", __func__); in mt8195_adda_mtkaif_init()
64 if (param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_0] >= in mt8195_adda_mtkaif_init()
65 param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_1]) { in mt8195_adda_mtkaif_init()
68 param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_0] - in mt8195_adda_mtkaif_init()
69 param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_1]; in mt8195_adda_mtkaif_init()
73 param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_1] - in mt8195_adda_mtkaif_init()
74 param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_0]; in mt8195_adda_mtkaif_init()
82 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG2, mask, val); in mt8195_adda_mtkaif_init()
85 if (param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_2] >= in mt8195_adda_mtkaif_init()
86 param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_1]) { in mt8195_adda_mtkaif_init()
89 param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_2] - in mt8195_adda_mtkaif_init()
90 param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_1]; in mt8195_adda_mtkaif_init()
94 param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_1] - in mt8195_adda_mtkaif_init()
95 param->mtkaif_phase_cycle[MT8195_MTKAIF_MISO_2]; in mt8195_adda_mtkaif_init()
103 regmap_update_bits(afe->regmap, AFE_ADDA6_MTKAIF_RX_CFG2, mask, val); in mt8195_adda_mtkaif_init()
112 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_mtkaif_cfg_event()
115 dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n", in mtk_adda_mtkaif_cfg_event()
116 __func__, w->name, event); in mtk_adda_mtkaif_cfg_event()
133 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_dl_event()
136 dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n", in mtk_adda_dl_event()
137 __func__, w->name, event); in mtk_adda_dl_event()
165 dev_info(afe->dev, "%s(), wrong parameter\n", __func__); in mtk_adda_ul_mictype()
176 regmap_update_bits(afe->regmap, reg, mask, val); in mtk_adda_ul_mictype()
183 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_ul_event()
185 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_adda_ul_event()
186 struct mtkaif_param *param = &afe_priv->mtkaif_params; in mtk_adda_ul_event()
188 dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n", in mtk_adda_ul_event()
189 __func__, w->name, event); in mtk_adda_ul_event()
193 mtk_adda_ul_mictype(afe, MTK_AFE_ADDA, param->mtkaif_dmic_on); in mtk_adda_ul_event()
210 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda6_ul_event()
212 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_adda6_ul_event()
213 struct mtkaif_param *param = &afe_priv->mtkaif_params; in mtk_adda6_ul_event()
216 dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n", in mtk_adda6_ul_event()
217 __func__, w->name, event); in mtk_adda6_ul_event()
221 mtk_adda_ul_mictype(afe, MTK_AFE_ADDA6, param->mtkaif_dmic_on); in mtk_adda6_ul_event()
223 val = (param->mtkaif_adda6_only ? in mtk_adda6_ul_event()
226 regmap_update_bits(afe->regmap, in mtk_adda6_ul_event()
246 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_audio_hires_event()
248 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_audio_hires_event()
249 struct clk *clk = afe_priv->clk[MT8195_CLK_TOP_AUDIO_H_SEL]; in mtk_audio_hires_event()
252 dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n", in mtk_audio_hires_event()
253 __func__, w->name, event); in mtk_audio_hires_event()
257 clk_parent = afe_priv->clk[MT8195_CLK_TOP_APLL1]; in mtk_audio_hires_event()
260 clk_parent = afe_priv->clk[MT8195_CLK_XTAL_26M]; in mtk_audio_hires_event()
273 struct mt8195_afe_private *afe_priv = afe->platform_priv; in get_adda_priv_by_name()
285 return afe_priv->dai_priv[dai_id]; in get_adda_priv_by_name()
292 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_afe_adda_hires_connect()
296 adda_priv = get_adda_priv_by_name(afe, w->name); in mtk_afe_adda_hires_connect()
299 dev_info(afe->dev, "adda_priv == NULL"); in mtk_afe_adda_hires_connect()
303 return (adda_priv->hires_required) ? 1 : 0; in mtk_afe_adda_hires_connect()
462 unsigned int value = (unsigned int)(ucontrol->value.integer.value[0]); in mt8195_adda_dl_gain_put()
464 regmap_update_bits(afe->regmap, reg, mask, DL_2_GAIN_CTL_PRE(value)); in mt8195_adda_dl_gain_put()
477 regmap_read(afe->regmap, reg, &value); in mt8195_adda_dl_gain_get()
479 ucontrol->value.integer.value[0] = ((value & mask) >> in mt8195_adda_dl_gain_get()
489 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_adda6_only_get()
490 struct mtkaif_param *param = &afe_priv->mtkaif_params; in mt8195_adda6_only_get()
492 ucontrol->value.integer.value[0] = param->mtkaif_adda6_only; in mt8195_adda6_only_get()
501 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_adda6_only_set()
502 struct mtkaif_param *param = &afe_priv->mtkaif_params; in mt8195_adda6_only_set()
505 mtkaif_adda6_only = ucontrol->value.integer.value[0]; in mt8195_adda6_only_set()
507 dev_info(afe->dev, "%s(), kcontrol name %s, mtkaif_adda6_only %d\n", in mt8195_adda6_only_set()
508 __func__, kcontrol->id.name, mtkaif_adda6_only); in mt8195_adda6_only_set()
510 param->mtkaif_adda6_only = mtkaif_adda6_only; in mt8195_adda6_only_set()
520 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_adda_dmic_get()
521 struct mtkaif_param *param = &afe_priv->mtkaif_params; in mt8195_adda_dmic_get()
523 ucontrol->value.integer.value[0] = param->mtkaif_dmic_on; in mt8195_adda_dmic_get()
532 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_adda_dmic_set()
533 struct mtkaif_param *param = &afe_priv->mtkaif_params; in mt8195_adda_dmic_set()
536 dmic_on = ucontrol->value.integer.value[0]; in mt8195_adda_dmic_set()
538 dev_dbg(afe->dev, "%s(), kcontrol name %s, dmic_on %d\n", in mt8195_adda_dmic_set()
539 __func__, kcontrol->id.name, dmic_on); in mt8195_adda_dmic_set()
541 param->mtkaif_dmic_on = dmic_on; in mt8195_adda_dmic_set()
580 regmap_update_bits(afe->regmap, AFE_ADDA_DL_SRC2_CON0, mask, val); in mtk_dai_da_configure()
588 regmap_update_bits(afe->regmap, AFE_ADDA_DL_SDM_DCCOMP_CON, mask, val); in mtk_dai_da_configure()
604 regmap_update_bits(afe->regmap, AFE_ADDA_UL_SRC_CON0, in mtk_dai_ad_configure()
608 regmap_update_bits(afe->regmap, AFE_ADDA6_UL_SRC_CON0, in mtk_dai_ad_configure()
622 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_adda_hw_params()
627 if (dai->id != MT8195_AFE_IO_DL_SRC && in mtk_dai_adda_hw_params()
628 dai->id != MT8195_AFE_IO_UL_SRC1 && in mtk_dai_adda_hw_params()
629 dai->id != MT8195_AFE_IO_UL_SRC2) in mtk_dai_adda_hw_params()
630 return -EINVAL; in mtk_dai_adda_hw_params()
631 adda_priv = afe_priv->dai_priv[dai->id]; in mtk_dai_adda_hw_params()
633 dev_dbg(afe->dev, "%s(), id %d, stream %d, rate %d\n", in mtk_dai_adda_hw_params()
634 __func__, dai->id, substream->stream, rate); in mtk_dai_adda_hw_params()
637 adda_priv->hires_required = 1; in mtk_dai_adda_hw_params()
639 adda_priv->hires_required = 0; in mtk_dai_adda_hw_params()
641 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in mtk_dai_adda_hw_params()
642 ret = mtk_dai_da_configure(afe, rate, dai->id); in mtk_dai_adda_hw_params()
644 ret = mtk_dai_ad_configure(afe, rate, dai->id); in mtk_dai_adda_hw_params()
710 struct mt8195_afe_private *afe_priv = afe->platform_priv; in init_adda_priv_data()
720 adda_priv = devm_kzalloc(afe->dev, in init_adda_priv_data()
724 return -ENOMEM; in init_adda_priv_data()
726 afe_priv->dai_priv[adda_dai_list[i]] = adda_priv; in init_adda_priv_data()
736 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8195_dai_adda_register()
738 return -ENOMEM; in mt8195_dai_adda_register()
740 list_add(&dai->list, &afe->sub_dais); in mt8195_dai_adda_register()
742 dai->dai_drivers = mtk_dai_adda_driver; in mt8195_dai_adda_register()
743 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_adda_driver); in mt8195_dai_adda_register()
745 dai->dapm_widgets = mtk_dai_adda_widgets; in mt8195_dai_adda_register()
746 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_adda_widgets); in mt8195_dai_adda_register()
747 dai->dapm_routes = mtk_dai_adda_routes; in mt8195_dai_adda_register()
748 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_adda_routes); in mt8195_dai_adda_register()
749 dai->controls = mtk_dai_adda_controls; in mt8195_dai_adda_register()
750 dai->num_controls = ARRAY_SIZE(mtk_dai_adda_controls); in mt8195_dai_adda_register()