Lines Matching +full:dmic +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
10 #include "mt8186-afe-clk.h"
11 #include "mt8186-afe-common.h"
12 #include "mt8186-afe-gpio.h"
13 #include "mt8186-interconnection.h"
75 struct mt8186_afe_private *afe_priv = afe->platform_priv; in get_adda_priv_by_name()
83 return afe_priv->dai_priv[dai_id]; in get_adda_priv_by_name()
113 dev_info(afe->dev, "%s(), rate %d invalid, use 48kHz!!!\n", in adda_dl_rate_transform()
137 dev_info(afe->dev, "%s(), rate %d invalid, use 48kHz!!!\n", in adda_ul_rate_transform()
218 return -EINVAL; in mtk_adda_ul_src_dmic()
221 /* dmic mode, 3.25M*/ in mtk_adda_ul_src_dmic()
222 regmap_update_bits(afe->regmap, reg, in mtk_adda_ul_src_dmic()
224 regmap_update_bits(afe->regmap, reg, in mtk_adda_ul_src_dmic()
227 /* turn on dmic, ch1, ch2 */ in mtk_adda_ul_src_dmic()
228 regmap_update_bits(afe->regmap, reg, in mtk_adda_ul_src_dmic()
231 regmap_update_bits(afe->regmap, reg, in mtk_adda_ul_src_dmic()
234 regmap_update_bits(afe->regmap, reg, in mtk_adda_ul_src_dmic()
245 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_ul_event()
247 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mtk_adda_ul_event()
248 int mtkaif_dmic = afe_priv->mtkaif_dmic; in mtk_adda_ul_event()
250 dev_dbg(afe->dev, "%s(), name %s, event 0x%x, mtkaif_dmic %d\n", in mtk_adda_ul_event()
251 __func__, w->name, event, mtkaif_dmic); in mtk_adda_ul_event()
255 mt8186_afe_gpio_request(afe->dev, true, MT8186_DAI_ADDA, 1); in mtk_adda_ul_event()
257 /* update setting to dmic */ in mtk_adda_ul_event()
259 /* mtkaif_rxif_data_mode = 1, dmic */ in mtk_adda_ul_event()
260 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG0, in mtk_adda_ul_event()
263 /* dmic mode, 3.25M*/ in mtk_adda_ul_event()
264 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG0, in mtk_adda_ul_event()
273 mt8186_afe_gpio_request(afe->dev, false, MT8186_DAI_ADDA, 1); in mtk_adda_ul_event()
286 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_pad_top_event()
288 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mtk_adda_pad_top_event()
292 if (afe_priv->mtkaif_protocol == MTKAIF_PROTOCOL_2_CLK_P2) in mtk_adda_pad_top_event()
293 regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x39); in mtk_adda_pad_top_event()
295 regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x31); in mtk_adda_pad_top_event()
308 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_mtkaif_cfg_event()
310 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mtk_adda_mtkaif_cfg_event()
316 if (afe_priv->mtkaif_protocol == MTKAIF_PROTOCOL_2_CLK_P2) { in mtk_adda_mtkaif_cfg_event()
318 regmap_write(afe->regmap, AFE_ADDA_MTKAIF_CFG0, 0x10000); in mtk_adda_mtkaif_cfg_event()
320 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_CFG0, in mtk_adda_mtkaif_cfg_event()
324 if (strcmp(w->name, "ADDA_MTKAIF_CFG") == 0) { in mtk_adda_mtkaif_cfg_event()
325 if (afe_priv->mtkaif_chosen_phase[0] < 0 && in mtk_adda_mtkaif_cfg_event()
326 afe_priv->mtkaif_chosen_phase[1] < 0) { in mtk_adda_mtkaif_cfg_event()
327 dev_err(afe->dev, in mtk_adda_mtkaif_cfg_event()
330 afe_priv->mtkaif_chosen_phase[0], in mtk_adda_mtkaif_cfg_event()
331 afe_priv->mtkaif_chosen_phase[1]); in mtk_adda_mtkaif_cfg_event()
335 if (afe_priv->mtkaif_chosen_phase[0] < 0 || in mtk_adda_mtkaif_cfg_event()
336 afe_priv->mtkaif_chosen_phase[1] < 0) { in mtk_adda_mtkaif_cfg_event()
337 dev_err(afe->dev, in mtk_adda_mtkaif_cfg_event()
340 afe_priv->mtkaif_chosen_phase[0], in mtk_adda_mtkaif_cfg_event()
341 afe_priv->mtkaif_chosen_phase[1]); in mtk_adda_mtkaif_cfg_event()
347 if (afe_priv->mtkaif_phase_cycle[0] >= in mtk_adda_mtkaif_cfg_event()
348 afe_priv->mtkaif_phase_cycle[1]) { in mtk_adda_mtkaif_cfg_event()
350 delay_cycle = afe_priv->mtkaif_phase_cycle[0] - in mtk_adda_mtkaif_cfg_event()
351 afe_priv->mtkaif_phase_cycle[1]; in mtk_adda_mtkaif_cfg_event()
354 delay_cycle = afe_priv->mtkaif_phase_cycle[1] - in mtk_adda_mtkaif_cfg_event()
355 afe_priv->mtkaif_phase_cycle[0]; in mtk_adda_mtkaif_cfg_event()
358 regmap_update_bits(afe->regmap, in mtk_adda_mtkaif_cfg_event()
364 regmap_update_bits(afe->regmap, in mtk_adda_mtkaif_cfg_event()
370 } else if (afe_priv->mtkaif_protocol == MTKAIF_PROTOCOL_2) { in mtk_adda_mtkaif_cfg_event()
371 regmap_write(afe->regmap, AFE_ADDA_MTKAIF_CFG0, 0x10000); in mtk_adda_mtkaif_cfg_event()
373 regmap_write(afe->regmap, AFE_ADDA_MTKAIF_CFG0, 0); in mtk_adda_mtkaif_cfg_event()
388 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_dl_event()
391 dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n", in mtk_adda_dl_event()
392 __func__, w->name, event); in mtk_adda_dl_event()
396 mt8186_afe_gpio_request(afe->dev, true, MT8186_DAI_ADDA, 0); in mtk_adda_dl_event()
401 mt8186_afe_gpio_request(afe->dev, false, MT8186_DAI_ADDA, 0); in mtk_adda_dl_event()
415 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mt8186_adda_dmic_get()
417 ucontrol->value.integer.value[0] = afe_priv->mtkaif_dmic; in mt8186_adda_dmic_get()
427 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mt8186_adda_dmic_set()
430 dmic_on = ucontrol->value.integer.value[0]; in mt8186_adda_dmic_set()
432 dev_dbg(afe->dev, "%s(), kcontrol name %s, dmic_on %d\n", in mt8186_adda_dmic_set()
433 __func__, kcontrol->id.name, dmic_on); in mt8186_adda_dmic_set()
435 if (afe_priv->mtkaif_dmic == dmic_on) in mt8186_adda_dmic_set()
438 afe_priv->mtkaif_dmic = dmic_on; in mt8186_adda_dmic_set()
477 /* inter-connections */
541 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_afe_dac_hires_connect()
545 adda_priv = get_adda_priv_by_name(afe, w->name); in mtk_afe_dac_hires_connect()
548 dev_err(afe->dev, "%s(), adda_priv == NULL", __func__); in mtk_afe_dac_hires_connect()
552 return (adda_priv->dl_rate > HIRES_THRESHOLD) ? 1 : 0; in mtk_afe_dac_hires_connect()
559 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_afe_adc_hires_connect()
563 adda_priv = get_adda_priv_by_name(afe, w->name); in mtk_afe_adc_hires_connect()
566 dev_err(afe->dev, "%s(), adda_priv == NULL", __func__); in mtk_afe_adc_hires_connect()
570 return (adda_priv->ul_rate > HIRES_THRESHOLD) ? 1 : 0; in mtk_afe_adc_hires_connect()
610 {"ADDA_UL_Mux", "AP_DMIC", "AP DMIC Capture"},
617 {"AP DMIC Capture", NULL, "ADDA Enable"},
618 {"AP DMIC Capture", NULL, "ADDA Capture Enable"},
619 {"AP DMIC Capture", NULL, "ADDA_FIFO"},
620 {"AP DMIC Capture", NULL, "AP_DMIC_EN"},
622 {"AP DMIC Capture", NULL, "AP_DMIC_INPUT"},
646 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mtk_dai_adda_hw_params()
648 int id = dai->id; in mtk_dai_adda_hw_params()
649 struct mtk_afe_adda_priv *adda_priv = afe_priv->dai_priv[id]; in mtk_dai_adda_hw_params()
651 dev_dbg(afe->dev, "%s(), id %d, stream %d, rate %d\n", in mtk_dai_adda_hw_params()
652 __func__, id, substream->stream, rate); in mtk_dai_adda_hw_params()
654 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in mtk_dai_adda_hw_params()
658 adda_priv->dl_rate = rate; in mtk_dai_adda_hw_params()
664 /* set output mode, UP_SAMPLING_RATE_X8 */ in mtk_dai_adda_hw_params()
675 /* SA suggest apply -0.3db to audio/speech path */ in mtk_dai_adda_hw_params()
679 /* turn on down-link gain */ in mtk_dai_adda_hw_params()
684 regmap_write(afe->regmap, AFE_ADDA_PREDIS_CON0, 0); in mtk_dai_adda_hw_params()
685 regmap_write(afe->regmap, AFE_ADDA_PREDIS_CON1, 0); in mtk_dai_adda_hw_params()
687 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
689 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
693 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
700 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
704 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
708 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
714 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
717 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
726 adda_priv->ul_rate = rate; in mtk_dai_adda_hw_params()
738 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
740 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
742 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
744 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
746 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
749 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
753 regmap_update_bits(afe->regmap, AFE_ADDA_TOP_CON0, BIT(0), 0); in mtk_dai_adda_hw_params()
756 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG0, BIT(0), 0); in mtk_dai_adda_hw_params()
762 /* ap dmic */ in mtk_dai_adda_hw_params()
819 .stream_name = "AP DMIC Capture",
832 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mt8186_dai_adda_register()
835 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8186_dai_adda_register()
837 return -ENOMEM; in mt8186_dai_adda_register()
839 list_add(&dai->list, &afe->sub_dais); in mt8186_dai_adda_register()
841 dai->dai_drivers = mtk_dai_adda_driver; in mt8186_dai_adda_register()
842 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_adda_driver); in mt8186_dai_adda_register()
844 dai->controls = mtk_adda_controls; in mt8186_dai_adda_register()
845 dai->num_controls = ARRAY_SIZE(mtk_adda_controls); in mt8186_dai_adda_register()
846 dai->dapm_widgets = mtk_dai_adda_widgets; in mt8186_dai_adda_register()
847 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_adda_widgets); in mt8186_dai_adda_register()
848 dai->dapm_routes = mtk_dai_adda_routes; in mt8186_dai_adda_register()
849 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_adda_routes); in mt8186_dai_adda_register()
857 /* ap dmic priv share with adda */ in mt8186_dai_adda_register()
858 afe_priv->dai_priv[MT8186_DAI_AP_DMIC] = in mt8186_dai_adda_register()
859 afe_priv->dai_priv[MT8186_DAI_ADDA]; in mt8186_dai_adda_register()