Lines Matching +full:mt8188 +full:- +full:afe

1 // SPDX-License-Identifier: GPL-2.0
8 * Chun-Chia Chiu <chun-chia.chiu@mediatek.com>
14 #include "mt8188-afe-clk.h"
15 #include "mt8188-afe-common.h"
16 #include "mt8188-reg.h"
62 return -EINVAL; in mtk_dai_pcm_mode()
123 struct snd_pcm_runtime * const runtime = substream->runtime; in mtk_dai_pcm_configure()
124 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_dai_pcm_configure() local
125 struct mt8188_afe_private *afe_priv = afe->platform_priv; in mtk_dai_pcm_configure()
131 unsigned int bit_width = dai->sample_bits; in mtk_dai_pcm_configure()
137 if (dai->id < 0) in mtk_dai_pcm_configure()
138 return -EINVAL; in mtk_dai_pcm_configure()
140 pcmif_priv = afe_priv->dai_priv[dai->id]; in mtk_dai_pcm_configure()
141 slave_mode = pcmif_priv->slave_mode; in mtk_dai_pcm_configure()
142 lrck_inv = pcmif_priv->lrck_inv; in mtk_dai_pcm_configure()
143 bck_inv = pcmif_priv->bck_inv; in mtk_dai_pcm_configure()
144 fmt = pcmif_priv->format; in mtk_dai_pcm_configure()
147 fs = mt8188_afe_fs_timing(runtime->rate); in mtk_dai_pcm_configure()
149 return -EINVAL; in mtk_dai_pcm_configure()
155 if (runtime->rate % 8000) in mtk_dai_pcm_configure()
163 regmap_update_bits(afe->regmap, PCM_INTF_CON2, mask, val); in mtk_dai_pcm_configure()
169 mode = mtk_dai_pcm_mode(runtime->rate); in mtk_dai_pcm_configure()
171 return -EINVAL; in mtk_dai_pcm_configure()
221 regmap_update_bits(afe->regmap, PCM_INTF_CON1, mask, val); in mtk_dai_pcm_configure()
230 if (snd_soc_dai_get_widget_playback(dai)->active || in mtk_dai_pcm_prepare()
231 snd_soc_dai_get_widget_capture(dai)->active) in mtk_dai_pcm_prepare()
239 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_dai_pcm_set_fmt() local
240 struct mt8188_afe_private *afe_priv = afe->platform_priv; in mtk_dai_pcm_set_fmt()
243 dev_dbg(dai->dev, "%s fmt 0x%x\n", __func__, fmt); in mtk_dai_pcm_set_fmt()
245 if (dai->id < 0) in mtk_dai_pcm_set_fmt()
246 return -EINVAL; in mtk_dai_pcm_set_fmt()
248 pcmif_priv = afe_priv->dai_priv[dai->id]; in mtk_dai_pcm_set_fmt()
252 pcmif_priv->format = MTK_DAI_PCM_FMT_I2S; in mtk_dai_pcm_set_fmt()
255 pcmif_priv->format = MTK_DAI_PCM_FMT_MODEA; in mtk_dai_pcm_set_fmt()
258 pcmif_priv->format = MTK_DAI_PCM_FMT_MODEB; in mtk_dai_pcm_set_fmt()
261 return -EINVAL; in mtk_dai_pcm_set_fmt()
266 pcmif_priv->bck_inv = 0; in mtk_dai_pcm_set_fmt()
267 pcmif_priv->lrck_inv = 0; in mtk_dai_pcm_set_fmt()
270 pcmif_priv->bck_inv = 0; in mtk_dai_pcm_set_fmt()
271 pcmif_priv->lrck_inv = 1; in mtk_dai_pcm_set_fmt()
274 pcmif_priv->bck_inv = 1; in mtk_dai_pcm_set_fmt()
275 pcmif_priv->lrck_inv = 0; in mtk_dai_pcm_set_fmt()
278 pcmif_priv->bck_inv = 1; in mtk_dai_pcm_set_fmt()
279 pcmif_priv->lrck_inv = 1; in mtk_dai_pcm_set_fmt()
282 return -EINVAL; in mtk_dai_pcm_set_fmt()
287 pcmif_priv->slave_mode = 1; in mtk_dai_pcm_set_fmt()
290 pcmif_priv->slave_mode = 0; in mtk_dai_pcm_set_fmt()
293 return -EINVAL; in mtk_dai_pcm_set_fmt()
335 static int init_pcmif_priv_data(struct mtk_base_afe *afe) in init_pcmif_priv_data() argument
337 struct mt8188_afe_private *afe_priv = afe->platform_priv; in init_pcmif_priv_data()
340 pcmif_priv = devm_kzalloc(afe->dev, sizeof(struct mtk_dai_pcmif_priv), in init_pcmif_priv_data()
343 return -ENOMEM; in init_pcmif_priv_data()
345 afe_priv->dai_priv[MT8188_AFE_IO_PCM] = pcmif_priv; in init_pcmif_priv_data()
349 int mt8188_dai_pcm_register(struct mtk_base_afe *afe) in mt8188_dai_pcm_register() argument
353 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8188_dai_pcm_register()
355 return -ENOMEM; in mt8188_dai_pcm_register()
357 list_add(&dai->list, &afe->sub_dais); in mt8188_dai_pcm_register()
359 dai->dai_drivers = mtk_dai_pcm_driver; in mt8188_dai_pcm_register()
360 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_pcm_driver); in mt8188_dai_pcm_register()
362 dai->dapm_widgets = mtk_dai_pcm_widgets; in mt8188_dai_pcm_register()
363 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_pcm_widgets); in mt8188_dai_pcm_register()
364 dai->dapm_routes = mtk_dai_pcm_routes; in mt8188_dai_pcm_register()
365 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_pcm_routes); in mt8188_dai_pcm_register()
367 return init_pcmif_priv_data(afe); in mt8188_dai_pcm_register()