Lines Matching +full:dmic +full:- +full:sample +full:- +full:rate

1 // SPDX-License-Identifier: GPL-2.0
10 #include "mt8183-afe-common.h"
11 #include "mt8183-interconnection.h"
12 #include "mt8183-reg.h"
13 #include "../common/mtk-dai-adda-common.h"
62 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_adda_ul_event()
64 struct mt8183_afe_private *afe_priv = afe->platform_priv; in mtk_adda_ul_event()
66 dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n", in mtk_adda_ul_event()
67 __func__, w->name, event); in mtk_adda_ul_event()
71 /* update setting to dmic */ in mtk_adda_ul_event()
72 if (afe_priv->mtkaif_dmic) { in mtk_adda_ul_event()
73 /* mtkaif_rxif_data_mode = 1, dmic */ in mtk_adda_ul_event()
74 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG0, in mtk_adda_ul_event()
77 /* dmic mode, 3.25M*/ in mtk_adda_ul_event()
78 regmap_update_bits(afe->regmap, AFE_ADDA_MTKAIF_RX_CFG0, in mtk_adda_ul_event()
80 regmap_update_bits(afe->regmap, AFE_ADDA_UL_SRC_CON0, in mtk_adda_ul_event()
82 regmap_update_bits(afe->regmap, AFE_ADDA_UL_SRC_CON0, in mtk_adda_ul_event()
85 /* turn on dmic, ch1, ch2 */ in mtk_adda_ul_event()
86 regmap_update_bits(afe->regmap, AFE_ADDA_UL_SRC_CON0, in mtk_adda_ul_event()
88 regmap_update_bits(afe->regmap, AFE_ADDA_UL_SRC_CON0, in mtk_adda_ul_event()
103 /* mtkaif dmic */
118 struct mt8183_afe_private *afe_priv = afe->platform_priv; in mt8183_adda_dmic_get()
120 ucontrol->value.integer.value[0] = afe_priv->mtkaif_dmic; in mt8183_adda_dmic_get()
130 struct mt8183_afe_private *afe_priv = afe->platform_priv; in mt8183_adda_dmic_set()
131 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in mt8183_adda_dmic_set()
133 if (ucontrol->value.enumerated.item[0] >= e->items) in mt8183_adda_dmic_set()
134 return -EINVAL; in mt8183_adda_dmic_set()
136 afe_priv->mtkaif_dmic = ucontrol->value.integer.value[0]; in mt8183_adda_dmic_set()
138 dev_info(afe->dev, "%s(), kcontrol name %s, mtkaif_dmic %d\n", in mt8183_adda_dmic_set()
139 __func__, kcontrol->id.name, afe_priv->mtkaif_dmic); in mt8183_adda_dmic_set()
219 struct mt8183_afe_private *afe_priv = afe->platform_priv; in set_mtkaif_rx()
223 switch (afe_priv->mtkaif_protocol) { in set_mtkaif_rx()
225 regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x38); in set_mtkaif_rx()
226 regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x39); in set_mtkaif_rx()
228 regmap_write(afe->regmap, AFE_ADDA_MTKAIF_CFG0, in set_mtkaif_rx()
231 if (afe_priv->mtkaif_phase_cycle[0] >= in set_mtkaif_rx()
232 afe_priv->mtkaif_phase_cycle[1]) { in set_mtkaif_rx()
234 delay_cycle = afe_priv->mtkaif_phase_cycle[0] - in set_mtkaif_rx()
235 afe_priv->mtkaif_phase_cycle[1]; in set_mtkaif_rx()
238 delay_cycle = afe_priv->mtkaif_phase_cycle[1] - in set_mtkaif_rx()
239 afe_priv->mtkaif_phase_cycle[0]; in set_mtkaif_rx()
242 regmap_update_bits(afe->regmap, in set_mtkaif_rx()
247 regmap_update_bits(afe->regmap, in set_mtkaif_rx()
253 regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x31); in set_mtkaif_rx()
254 regmap_write(afe->regmap, AFE_ADDA_MTKAIF_CFG0, in set_mtkaif_rx()
258 regmap_write(afe->regmap, AFE_AUD_PAD_TOP, 0x31); in set_mtkaif_rx()
259 regmap_write(afe->regmap, AFE_ADDA_MTKAIF_CFG0, 0x0); in set_mtkaif_rx()
274 unsigned int rate = params_rate(params); in mtk_dai_adda_hw_params() local
276 dev_dbg(afe->dev, "%s(), id %d, stream %d, rate %d\n", in mtk_dai_adda_hw_params()
277 __func__, dai->id, substream->stream, rate); in mtk_dai_adda_hw_params()
279 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in mtk_dai_adda_hw_params()
284 regmap_write(afe->regmap, AFE_ADDA_PREDIS_CON0, 0); in mtk_dai_adda_hw_params()
285 regmap_write(afe->regmap, AFE_ADDA_PREDIS_CON1, 0); in mtk_dai_adda_hw_params()
287 /* set sampling rate */ in mtk_dai_adda_hw_params()
288 dl_src2_con0 = mtk_adda_dl_rate_transform(afe, rate) << 28; in mtk_dai_adda_hw_params()
291 switch (rate) { in mtk_dai_adda_hw_params()
308 /* set voice input data if input sample rate is 8k or 16k */ in mtk_dai_adda_hw_params()
309 if (rate == 8000 || rate == 16000) in mtk_dai_adda_hw_params()
312 /* SA suggest apply -0.3db to audio/speech path */ in mtk_dai_adda_hw_params()
315 /* turn on down-link gain */ in mtk_dai_adda_hw_params()
318 regmap_write(afe->regmap, AFE_ADDA_DL_SRC2_CON0, dl_src2_con0); in mtk_dai_adda_hw_params()
319 regmap_write(afe->regmap, AFE_ADDA_DL_SRC2_CON1, dl_src2_con1); in mtk_dai_adda_hw_params()
322 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
334 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
339 voice_mode = mtk_adda_ul_rate_transform(afe, rate); in mtk_dai_adda_hw_params()
348 regmap_write(afe->regmap, AFE_ADDA_IIR_COEF_02_01, 0x00000000); in mtk_dai_adda_hw_params()
349 regmap_write(afe->regmap, AFE_ADDA_IIR_COEF_04_03, 0x00003FB8); in mtk_dai_adda_hw_params()
350 regmap_write(afe->regmap, AFE_ADDA_IIR_COEF_06_05, 0x3FB80000); in mtk_dai_adda_hw_params()
351 regmap_write(afe->regmap, AFE_ADDA_IIR_COEF_08_07, 0x3FB80000); in mtk_dai_adda_hw_params()
352 regmap_write(afe->regmap, AFE_ADDA_IIR_COEF_10_09, 0x0000C048); in mtk_dai_adda_hw_params()
354 regmap_write(afe->regmap, AFE_ADDA_UL_SRC_CON0, ul_src_con0); in mtk_dai_adda_hw_params()
357 regmap_update_bits(afe->regmap, in mtk_dai_adda_hw_params()
410 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8183_dai_adda_register()
412 return -ENOMEM; in mt8183_dai_adda_register()
414 list_add(&dai->list, &afe->sub_dais); in mt8183_dai_adda_register()
416 dai->dai_drivers = mtk_dai_adda_driver; in mt8183_dai_adda_register()
417 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_adda_driver); in mt8183_dai_adda_register()
419 dai->controls = mtk_adda_controls; in mt8183_dai_adda_register()
420 dai->num_controls = ARRAY_SIZE(mtk_adda_controls); in mt8183_dai_adda_register()
421 dai->dapm_widgets = mtk_dai_adda_widgets; in mt8183_dai_adda_register()
422 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_adda_widgets); in mt8183_dai_adda_register()
423 dai->dapm_routes = mtk_dai_adda_routes; in mt8183_dai_adda_register()
424 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_adda_routes); in mt8183_dai_adda_register()