Lines Matching +full:dai +full:- +full:format
1 // SPDX-License-Identifier: GPL-2.0
3 * MediaTek ALSA SoC Audio DAI eTDM Control
14 #include "mt7986-afe-common.h"
15 #include "mt7986-reg.h"
43 unsigned int format; member
87 /* dai component */
117 /* dai ops */
119 struct snd_soc_dai *dai) in mtk_dai_etdm_startup() argument
121 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_dai_etdm_startup()
122 struct mt7986_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_startup()
125 ret = clk_bulk_prepare_enable(afe_priv->num_clks, afe_priv->clks); in mtk_dai_etdm_startup()
127 return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n"); in mtk_dai_etdm_startup()
129 regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK, 0); in mtk_dai_etdm_startup()
130 regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK, 0); in mtk_dai_etdm_startup()
136 struct snd_soc_dai *dai) in mtk_dai_etdm_shutdown() argument
138 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_dai_etdm_shutdown()
139 struct mt7986_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_shutdown()
141 regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK, in mtk_dai_etdm_shutdown()
143 regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK, in mtk_dai_etdm_shutdown()
146 clk_bulk_disable_unprepare(afe_priv->num_clks, afe_priv->clks); in mtk_dai_etdm_shutdown()
165 struct snd_soc_dai *dai, in mtk_dai_etdm_config() argument
168 struct mt7986_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_config()
169 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_etdm_config()
171 unsigned int etdm_rate = mt7986_etdm_rate_transform(afe->dev, rate); in mtk_dai_etdm_config()
172 unsigned int afe_rate = mt7986_afe_rate_transform(afe->dev, rate); in mtk_dai_etdm_config()
179 dev_dbg(afe->dev, "%s(), stream %d, rate %u, bitwidth %u\n", in mtk_dai_etdm_config()
184 val |= FIELD_PREP(ETDM_BIT_LEN_MASK, bit_width - 1); in mtk_dai_etdm_config()
186 val |= FIELD_PREP(ETDM_WRD_LEN_MASK, wlen - 1); in mtk_dai_etdm_config()
188 val |= FIELD_PREP(ETDM_FMT_MASK, etdm_data->format); in mtk_dai_etdm_config()
190 val |= FIELD_PREP(ETDM_CH_NUM_MASK, get_etdm_ch_fixup(channels) - 1); in mtk_dai_etdm_config()
197 regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, mask, val); in mtk_dai_etdm_config()
200 regmap_update_bits(afe->regmap, ETDM_OUT5_CON4, in mtk_dai_etdm_config()
202 regmap_update_bits(afe->regmap, ETDM_OUT5_CON4, in mtk_dai_etdm_config()
204 regmap_update_bits(afe->regmap, ETDM_OUT5_CON4, in mtk_dai_etdm_config()
208 regmap_update_bits(afe->regmap, ETDM_OUT5_CON5, in mtk_dai_etdm_config()
213 regmap_update_bits(afe->regmap, ETDM_IN5_CON0, mask, val); in mtk_dai_etdm_config()
214 regmap_update_bits(afe->regmap, ETDM_IN5_CON0, in mtk_dai_etdm_config()
218 regmap_update_bits(afe->regmap, ETDM_IN5_CON2, in mtk_dai_etdm_config()
222 regmap_update_bits(afe->regmap, ETDM_IN5_CON3, in mtk_dai_etdm_config()
226 regmap_update_bits(afe->regmap, ETDM_IN5_CON4, in mtk_dai_etdm_config()
238 struct snd_soc_dai *dai) in mtk_dai_etdm_hw_params() argument
241 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_dai_etdm_hw_params()
252 mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); in mtk_dai_etdm_hw_params()
253 mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); in mtk_dai_etdm_hw_params()
256 dev_err(afe->dev, in mtk_dai_etdm_hw_params()
259 return -EINVAL; in mtk_dai_etdm_hw_params()
264 struct snd_soc_dai *dai) in mtk_dai_etdm_trigger() argument
266 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_dai_etdm_trigger()
268 dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai->id); in mtk_dai_etdm_trigger()
272 regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK, in mtk_dai_etdm_trigger()
274 regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK, in mtk_dai_etdm_trigger()
279 regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK, in mtk_dai_etdm_trigger()
281 regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK, in mtk_dai_etdm_trigger()
291 static int mtk_dai_etdm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) in mtk_dai_etdm_set_fmt() argument
293 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); in mtk_dai_etdm_set_fmt()
294 struct mt7986_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_set_fmt()
298 switch (dai->id) { in mtk_dai_etdm_set_fmt()
302 dev_warn(afe->dev, "%s(), id %d not support\n", in mtk_dai_etdm_set_fmt()
303 __func__, dai->id); in mtk_dai_etdm_set_fmt()
304 return -EINVAL; in mtk_dai_etdm_set_fmt()
307 priv_data = devm_kzalloc(afe->dev, sizeof(struct mtk_dai_etdm_priv), in mtk_dai_etdm_set_fmt()
310 return -ENOMEM; in mtk_dai_etdm_set_fmt()
312 afe_priv->dai_priv[dai->id] = priv_data; in mtk_dai_etdm_set_fmt()
313 etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_etdm_set_fmt()
317 etdm_data->format = MTK_DAI_ETDM_FORMAT_I2S; in mtk_dai_etdm_set_fmt()
320 etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPA; in mtk_dai_etdm_set_fmt()
323 etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPB; in mtk_dai_etdm_set_fmt()
326 return -EINVAL; in mtk_dai_etdm_set_fmt()
331 etdm_data->bck_inv = false; in mtk_dai_etdm_set_fmt()
332 etdm_data->lrck_inv = false; in mtk_dai_etdm_set_fmt()
335 etdm_data->bck_inv = false; in mtk_dai_etdm_set_fmt()
336 etdm_data->lrck_inv = true; in mtk_dai_etdm_set_fmt()
339 etdm_data->bck_inv = true; in mtk_dai_etdm_set_fmt()
340 etdm_data->lrck_inv = false; in mtk_dai_etdm_set_fmt()
343 etdm_data->bck_inv = true; in mtk_dai_etdm_set_fmt()
344 etdm_data->lrck_inv = true; in mtk_dai_etdm_set_fmt()
347 return -EINVAL; in mtk_dai_etdm_set_fmt()
352 etdm_data->slave_mode = true; in mtk_dai_etdm_set_fmt()
355 etdm_data->slave_mode = false; in mtk_dai_etdm_set_fmt()
358 return -EINVAL; in mtk_dai_etdm_set_fmt()
372 /* dai driver */
409 struct mtk_base_afe_dai *dai; in mt7986_dai_etdm_register() local
411 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt7986_dai_etdm_register()
412 if (!dai) in mt7986_dai_etdm_register()
413 return -ENOMEM; in mt7986_dai_etdm_register()
415 list_add(&dai->list, &afe->sub_dais); in mt7986_dai_etdm_register()
417 dai->dai_drivers = mtk_dai_etdm_driver; in mt7986_dai_etdm_register()
418 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_etdm_driver); in mt7986_dai_etdm_register()
420 dai->dapm_widgets = mtk_dai_etdm_widgets; in mt7986_dai_etdm_register()
421 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_etdm_widgets); in mt7986_dai_etdm_register()
422 dai->dapm_routes = mtk_dai_etdm_routes; in mt7986_dai_etdm_register()
423 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_etdm_routes); in mt7986_dai_etdm_register()