Lines Matching +full:dai +full:- +full:format
1 // SPDX-License-Identifier: GPL-2.0
3 // MediaTek ALSA SoC Audio DAI I2S Control
10 #include "mt8186-afe-common.h"
11 #include "mt8186-afe-gpio.h"
12 #include "mt8186-interconnection.h"
99 /* dai component */
122 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_pcm_en_event()
125 dev_dbg(afe->dev, "%s(), name %s, event 0x%x\n", in mtk_pcm_en_event()
126 __func__, w->name, event); in mtk_pcm_en_event()
130 mt8186_afe_gpio_request(afe->dev, true, MT8186_DAI_PCM, 0); in mtk_pcm_en_event()
133 mt8186_afe_gpio_request(afe->dev, false, MT8186_DAI_PCM, 0); in mtk_pcm_en_event()
170 /* inter-connections */
214 /* dai ops */
217 struct snd_soc_dai *dai) in mtk_dai_pcm_hw_params() argument
219 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_dai_pcm_hw_params()
220 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mtk_dai_pcm_hw_params()
221 struct snd_soc_dapm_widget *p = snd_soc_dai_get_widget_playback(dai); in mtk_dai_pcm_hw_params()
222 struct snd_soc_dapm_widget *c = snd_soc_dai_get_widget_capture(dai); in mtk_dai_pcm_hw_params()
223 int pcm_id = dai->id; in mtk_dai_pcm_hw_params()
224 struct mtk_afe_pcm_priv *pcm_priv = afe_priv->dai_priv[pcm_id]; in mtk_dai_pcm_hw_params()
226 unsigned int rate_reg = mt8186_rate_transform(afe->dev, rate, dai->id); in mtk_dai_pcm_hw_params()
227 snd_pcm_format_t format = params_format(params); in mtk_dai_pcm_hw_params() local
229 snd_pcm_format_width(format); in mtk_dai_pcm_hw_params()
231 snd_pcm_format_physical_width(format); in mtk_dai_pcm_hw_params()
234 dev_dbg(afe->dev, "%s(), id %d, stream %d, widget active p %d, c %d\n", in mtk_dai_pcm_hw_params()
235 __func__, dai->id, substream->stream, p->active, c->active); in mtk_dai_pcm_hw_params()
236 dev_dbg(afe->dev, "%s(), rate %d, rate_reg %d, data_width %d, wlen_width %d\n", in mtk_dai_pcm_hw_params()
239 if (p->active || c->active) in mtk_dai_pcm_hw_params()
242 switch (dai->id) { in mtk_dai_pcm_hw_params()
256 /* format */ in mtk_dai_pcm_hw_params()
257 pcm_con |= pcm_priv->fmt << PCM_FMT_SFT; in mtk_dai_pcm_hw_params()
272 pcm_con |= pcm_priv->lck_invert << PCM_SYNC_OUT_INV_SFT; in mtk_dai_pcm_hw_params()
273 pcm_con |= pcm_priv->bck_invert << PCM_BCLK_OUT_INV_SFT; in mtk_dai_pcm_hw_params()
275 regmap_update_bits(afe->regmap, PCM_INTF_CON1, 0xfffffffe, pcm_con); in mtk_dai_pcm_hw_params()
278 dev_err(afe->dev, "%s(), id %d not support\n", __func__, dai->id); in mtk_dai_pcm_hw_params()
279 return -EINVAL; in mtk_dai_pcm_hw_params()
285 static int mtk_dai_pcm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) in mtk_dai_pcm_set_fmt() argument
287 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_dai_pcm_set_fmt()
288 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mtk_dai_pcm_set_fmt()
289 struct mtk_afe_pcm_priv *pcm_priv = afe_priv->dai_priv[dai->id]; in mtk_dai_pcm_set_fmt()
291 /* DAI mode*/ in mtk_dai_pcm_set_fmt()
294 pcm_priv->fmt = AUD_PCM_FMT_I2S; in mtk_dai_pcm_set_fmt()
297 pcm_priv->fmt = AUD_PCM_FMT_EIAJ; in mtk_dai_pcm_set_fmt()
300 pcm_priv->fmt = AUD_PCM_FMT_PCM_MODE_A; in mtk_dai_pcm_set_fmt()
303 pcm_priv->fmt = AUD_PCM_FMT_PCM_MODE_B; in mtk_dai_pcm_set_fmt()
306 pcm_priv->fmt = AUD_PCM_FMT_I2S; in mtk_dai_pcm_set_fmt()
309 /* DAI clock inversion*/ in mtk_dai_pcm_set_fmt()
312 pcm_priv->bck_invert = AUD_BCLK_OUT_INV_NO_INVERSE; in mtk_dai_pcm_set_fmt()
313 pcm_priv->lck_invert = AUD_LRCLK_OUT_INV_NO_INVERSE; in mtk_dai_pcm_set_fmt()
316 pcm_priv->bck_invert = AUD_BCLK_OUT_INV_NO_INVERSE; in mtk_dai_pcm_set_fmt()
317 pcm_priv->lck_invert = AUD_BCLK_OUT_INV_INVERSE; in mtk_dai_pcm_set_fmt()
320 pcm_priv->bck_invert = AUD_BCLK_OUT_INV_INVERSE; in mtk_dai_pcm_set_fmt()
321 pcm_priv->lck_invert = AUD_LRCLK_OUT_INV_NO_INVERSE; in mtk_dai_pcm_set_fmt()
324 pcm_priv->bck_invert = AUD_BCLK_OUT_INV_INVERSE; in mtk_dai_pcm_set_fmt()
325 pcm_priv->lck_invert = AUD_BCLK_OUT_INV_INVERSE; in mtk_dai_pcm_set_fmt()
328 pcm_priv->bck_invert = AUD_BCLK_OUT_INV_NO_INVERSE; in mtk_dai_pcm_set_fmt()
329 pcm_priv->lck_invert = AUD_LRCLK_OUT_INV_NO_INVERSE; in mtk_dai_pcm_set_fmt()
341 /* dai driver */
379 pcm_priv = devm_kzalloc(afe->dev, sizeof(struct mtk_afe_pcm_priv), in init_pcm_priv_data()
384 pcm_priv->id = MT8186_DAI_PCM; in init_pcm_priv_data()
385 pcm_priv->fmt = AUD_PCM_FMT_I2S; in init_pcm_priv_data()
386 pcm_priv->bck_invert = AUD_BCLK_OUT_INV_NO_INVERSE; in init_pcm_priv_data()
387 pcm_priv->lck_invert = AUD_LRCLK_OUT_INV_NO_INVERSE; in init_pcm_priv_data()
394 struct mt8186_afe_private *afe_priv = afe->platform_priv; in mt8186_dai_pcm_register()
396 struct mtk_base_afe_dai *dai; in mt8186_dai_pcm_register() local
398 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8186_dai_pcm_register()
399 if (!dai) in mt8186_dai_pcm_register()
400 return -ENOMEM; in mt8186_dai_pcm_register()
402 list_add(&dai->list, &afe->sub_dais); in mt8186_dai_pcm_register()
404 dai->dai_drivers = mtk_dai_pcm_driver; in mt8186_dai_pcm_register()
405 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_pcm_driver); in mt8186_dai_pcm_register()
407 dai->dapm_widgets = mtk_dai_pcm_widgets; in mt8186_dai_pcm_register()
408 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_pcm_widgets); in mt8186_dai_pcm_register()
409 dai->dapm_routes = mtk_dai_pcm_routes; in mt8186_dai_pcm_register()
410 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_pcm_routes); in mt8186_dai_pcm_register()
414 return -ENOMEM; in mt8186_dai_pcm_register()
416 afe_priv->dai_priv[MT8186_DAI_PCM] = pcm_priv; in mt8186_dai_pcm_register()