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"
14 #include "../common/mtk-dai-adda-common.h"
47 struct mt8186_afe_private *afe_priv = afe->platform_priv; in get_adda_priv_by_name()
55 return afe_priv->dai_priv[dai_id]; in get_adda_priv_by_name()
132 return -EINVAL; in mtk_adda_ul_src_dmic()
135 /* dmic mode, 3.25M*/ in mtk_adda_ul_src_dmic()
136 regmap_update_bits(afe->regmap, reg, in mtk_adda_ul_src_dmic()
138 regmap_update_bits(afe->regmap, reg, in mtk_adda_ul_src_dmic()
141 /* turn on dmic, ch1, ch2 */ in mtk_adda_ul_src_dmic()
142 regmap_update_bits(afe->regmap, reg, in mtk_adda_ul_src_dmic()
145 regmap_update_bits(afe->regmap, reg, in mtk_adda_ul_src_dmic()
148 regmap_update_bits(afe->regmap, reg, in mtk_adda_ul_src_dmic()
159 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_ul_event()
161 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mtk_adda_ul_event()
162 int mtkaif_dmic = afe_priv->mtkaif_dmic; in mtk_adda_ul_event()
164 dev_dbg(afe->dev, "%s(), name %s, event 0x%x, mtkaif_dmic %d\n", in mtk_adda_ul_event()
165 __func__, w->name, event, mtkaif_dmic); in mtk_adda_ul_event()
169 mt8186_afe_gpio_request(afe->dev, true, MT8186_DAI_ADDA, 1); in mtk_adda_ul_event()
171 /* update setting to dmic */ in mtk_adda_ul_event()
173 /* mtkaif_rxif_data_mode = 1, dmic */ in mtk_adda_ul_event()
174 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG0, in mtk_adda_ul_event()
177 /* dmic mode, 3.25M*/ in mtk_adda_ul_event()
178 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG0, in mtk_adda_ul_event()
187 mt8186_afe_gpio_request(afe->dev, false, MT8186_DAI_ADDA, 1); in mtk_adda_ul_event()
200 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_pad_top_event()
202 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mtk_adda_pad_top_event()
206 if (afe_priv->mtkaif_protocol == MTKAIF_PROTOCOL_2_CLK_P2) in mtk_adda_pad_top_event()
207 regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x39); in mtk_adda_pad_top_event()
209 regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x31); in mtk_adda_pad_top_event()
222 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_mtkaif_cfg_event()
224 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mtk_adda_mtkaif_cfg_event()
230 if (afe_priv->mtkaif_protocol == MTKAIF_PROTOCOL_2_CLK_P2) { in mtk_adda_mtkaif_cfg_event()
232 regmap_write(afe->regmap, AFE_ADDA_MTKAIF_CFG0, 0x10000); in mtk_adda_mtkaif_cfg_event()
234 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_CFG0, in mtk_adda_mtkaif_cfg_event()
239 if (afe_priv->mtkaif_chosen_phase[0] < 0 && in mtk_adda_mtkaif_cfg_event()
240 afe_priv->mtkaif_chosen_phase[1] < 0) { in mtk_adda_mtkaif_cfg_event()
241 dev_err(afe->dev, in mtk_adda_mtkaif_cfg_event()
244 afe_priv->mtkaif_chosen_phase[0], in mtk_adda_mtkaif_cfg_event()
245 afe_priv->mtkaif_chosen_phase[1]); in mtk_adda_mtkaif_cfg_event()
249 if (afe_priv->mtkaif_chosen_phase[0] < 0 || in mtk_adda_mtkaif_cfg_event()
250 afe_priv->mtkaif_chosen_phase[1] < 0) { in mtk_adda_mtkaif_cfg_event()
251 dev_err(afe->dev, in mtk_adda_mtkaif_cfg_event()
254 afe_priv->mtkaif_chosen_phase[0], in mtk_adda_mtkaif_cfg_event()
255 afe_priv->mtkaif_chosen_phase[1]); in mtk_adda_mtkaif_cfg_event()
261 if (afe_priv->mtkaif_phase_cycle[0] >= in mtk_adda_mtkaif_cfg_event()
262 afe_priv->mtkaif_phase_cycle[1]) { in mtk_adda_mtkaif_cfg_event()
264 delay_cycle = afe_priv->mtkaif_phase_cycle[0] - in mtk_adda_mtkaif_cfg_event()
265 afe_priv->mtkaif_phase_cycle[1]; in mtk_adda_mtkaif_cfg_event()
268 delay_cycle = afe_priv->mtkaif_phase_cycle[1] - in mtk_adda_mtkaif_cfg_event()
269 afe_priv->mtkaif_phase_cycle[0]; in mtk_adda_mtkaif_cfg_event()
272 regmap_update_bits(afe->regmap, in mtk_adda_mtkaif_cfg_event()
278 regmap_update_bits(afe->regmap, in mtk_adda_mtkaif_cfg_event()
284 } else if (afe_priv->mtkaif_protocol == MTKAIF_PROTOCOL_2) { in mtk_adda_mtkaif_cfg_event()
285 regmap_write(afe->regmap, AFE_ADDA_MTKAIF_CFG0, 0x10000); in mtk_adda_mtkaif_cfg_event()
287 regmap_write(afe->regmap, AFE_ADDA_MTKAIF_CFG0, 0); in mtk_adda_mtkaif_cfg_event()
302 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_dl_event()
305 dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n", in mtk_adda_dl_event()
306 __func__, w->name, event); in mtk_adda_dl_event()
310 mt8186_afe_gpio_request(afe->dev, true, MT8186_DAI_ADDA, 0); in mtk_adda_dl_event()
315 mt8186_afe_gpio_request(afe->dev, false, MT8186_DAI_ADDA, 0); in mtk_adda_dl_event()
329 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mt8186_adda_dmic_get()
331 ucontrol->value.integer.value[0] = afe_priv->mtkaif_dmic; in mt8186_adda_dmic_get()
341 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mt8186_adda_dmic_set()
344 dmic_on = ucontrol->value.integer.value[0]; in mt8186_adda_dmic_set()
346 dev_dbg(afe->dev, "%s(), kcontrol name %s, dmic_on %d\n", in mt8186_adda_dmic_set()
347 __func__, kcontrol->id.name, dmic_on); in mt8186_adda_dmic_set()
349 if (afe_priv->mtkaif_dmic == dmic_on) in mt8186_adda_dmic_set()
352 afe_priv->mtkaif_dmic = dmic_on; in mt8186_adda_dmic_set()
391 /* inter-connections */
455 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_afe_dac_hires_connect()
459 adda_priv = get_adda_priv_by_name(afe, w->name); in mtk_afe_dac_hires_connect()
462 dev_err(afe->dev, "%s(), adda_priv == NULL", __func__); in mtk_afe_dac_hires_connect()
466 return (adda_priv->dl_rate > HIRES_THRESHOLD) ? 1 : 0; in mtk_afe_dac_hires_connect()
473 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_afe_adc_hires_connect()
477 adda_priv = get_adda_priv_by_name(afe, w->name); in mtk_afe_adc_hires_connect()
480 dev_err(afe->dev, "%s(), adda_priv == NULL", __func__); in mtk_afe_adc_hires_connect()
484 return (adda_priv->ul_rate > HIRES_THRESHOLD) ? 1 : 0; in mtk_afe_adc_hires_connect()
524 {"ADDA_UL_Mux", "AP_DMIC", "AP DMIC Capture"},
531 {"AP DMIC Capture", NULL, "ADDA Enable"},
532 {"AP DMIC Capture", NULL, "ADDA Capture Enable"},
533 {"AP DMIC Capture", NULL, "ADDA_FIFO"},
534 {"AP DMIC Capture", NULL, "AP_DMIC_EN"},
536 {"AP DMIC Capture", NULL, "AP_DMIC_INPUT"},
560 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mtk_dai_adda_hw_params()
562 int id = dai->id; in mtk_dai_adda_hw_params()
563 struct mtk_afe_adda_priv *adda_priv = afe_priv->dai_priv[id]; in mtk_dai_adda_hw_params()
565 dev_dbg(afe->dev, "%s(), id %d, stream %d, rate %d\n", in mtk_dai_adda_hw_params()
566 __func__, id, substream->stream, rate); in mtk_dai_adda_hw_params()
568 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in mtk_dai_adda_hw_params()
572 adda_priv->dl_rate = rate; in mtk_dai_adda_hw_params()
578 /* set output mode, UP_SAMPLING_RATE_X8 */ in mtk_dai_adda_hw_params()
589 /* SA suggest apply -0.3db to audio/speech path */ in mtk_dai_adda_hw_params()
593 /* turn on down-link gain */ in mtk_dai_adda_hw_params()
598 regmap_write(afe->regmap, AFE_ADDA_PREDIS_CON0, 0); in mtk_dai_adda_hw_params()
599 regmap_write(afe->regmap, AFE_ADDA_PREDIS_CON1, 0); in mtk_dai_adda_hw_params()
601 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
603 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
607 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
614 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
618 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
622 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
628 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
631 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
640 adda_priv->ul_rate = rate; in mtk_dai_adda_hw_params()
652 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
654 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
656 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
658 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
660 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
663 regmap_write(afe->regmap, in mtk_dai_adda_hw_params()
667 regmap_update_bits(afe->regmap, AFE_ADDA_TOP_CON0, BIT(0), 0); in mtk_dai_adda_hw_params()
670 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG0, BIT(0), 0); in mtk_dai_adda_hw_params()
676 /* ap dmic */ in mtk_dai_adda_hw_params()
733 .stream_name = "AP DMIC Capture",
746 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mt8186_dai_adda_register()
749 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8186_dai_adda_register()
751 return -ENOMEM; in mt8186_dai_adda_register()
753 list_add(&dai->list, &afe->sub_dais); in mt8186_dai_adda_register()
755 dai->dai_drivers = mtk_dai_adda_driver; in mt8186_dai_adda_register()
756 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_adda_driver); in mt8186_dai_adda_register()
758 dai->controls = mtk_adda_controls; in mt8186_dai_adda_register()
759 dai->num_controls = ARRAY_SIZE(mtk_adda_controls); in mt8186_dai_adda_register()
760 dai->dapm_widgets = mtk_dai_adda_widgets; in mt8186_dai_adda_register()
761 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_adda_widgets); in mt8186_dai_adda_register()
762 dai->dapm_routes = mtk_dai_adda_routes; in mt8186_dai_adda_register()
763 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_adda_routes); in mt8186_dai_adda_register()
771 /* ap dmic priv share with adda */ in mt8186_dai_adda_register()
772 afe_priv->dai_priv[MT8186_DAI_AP_DMIC] = in mt8186_dai_adda_register()
773 afe_priv->dai_priv[MT8186_DAI_ADDA]; in mt8186_dai_adda_register()