Lines Matching +full:hdmi +full:- +full:switch

1 // SPDX-License-Identifier: GPL-2.0
10 #include "mt8183-afe-clk.h"
11 #include "mt8183-afe-common.h"
12 #include "mt8183-interconnection.h"
13 #include "mt8183-reg.h"
92 return snd_pcm_format_physical_width(format) - 1; in get_tdm_lrck_width()
97 switch (ch) { in get_tdm_ch()
250 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_tdm_bck_en_event()
252 struct mt8183_afe_private *afe_priv = afe->platform_priv; in mtk_tdm_bck_en_event()
253 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[MT8183_DAI_TDM]; in mtk_tdm_bck_en_event()
255 dev_info(cmpnt->dev, "%s(), name %s, event 0x%x\n", in mtk_tdm_bck_en_event()
256 __func__, w->name, event); in mtk_tdm_bck_en_event()
258 switch (event) { in mtk_tdm_bck_en_event()
260 mt8183_mck_enable(afe, tdm_priv->bck_id, tdm_priv->bck_rate); in mtk_tdm_bck_en_event()
263 mt8183_mck_disable(afe, tdm_priv->bck_id); in mtk_tdm_bck_en_event()
276 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_tdm_mck_en_event()
278 struct mt8183_afe_private *afe_priv = afe->platform_priv; in mtk_tdm_mck_en_event()
279 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[MT8183_DAI_TDM]; in mtk_tdm_mck_en_event()
281 dev_info(cmpnt->dev, "%s(), name %s, event 0x%x\n", in mtk_tdm_mck_en_event()
282 __func__, w->name, event); in mtk_tdm_mck_en_event()
284 switch (event) { in mtk_tdm_mck_en_event()
286 mt8183_mck_enable(afe, tdm_priv->mclk_id, tdm_priv->mclk_rate); in mtk_tdm_mck_en_event()
289 tdm_priv->mclk_rate = 0; in mtk_tdm_mck_en_event()
290 mt8183_mck_disable(afe, tdm_priv->mclk_id); in mtk_tdm_mck_en_event()
334 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_afe_tdm_apll_connect()
336 struct mt8183_afe_private *afe_priv = afe->platform_priv; in mtk_afe_tdm_apll_connect()
337 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[MT8183_DAI_TDM]; in mtk_afe_tdm_apll_connect()
341 cur_apll = mt8183_get_apll_by_name(afe, source->name); in mtk_afe_tdm_apll_connect()
343 return (tdm_priv->mclk_apll == cur_apll) ? 1 : 0; in mtk_afe_tdm_apll_connect()
347 {"HDMI_CH0_MUX", "CH0", "HDMI"},
348 {"HDMI_CH0_MUX", "CH1", "HDMI"},
349 {"HDMI_CH0_MUX", "CH2", "HDMI"},
350 {"HDMI_CH0_MUX", "CH3", "HDMI"},
351 {"HDMI_CH0_MUX", "CH4", "HDMI"},
352 {"HDMI_CH0_MUX", "CH5", "HDMI"},
353 {"HDMI_CH0_MUX", "CH6", "HDMI"},
354 {"HDMI_CH0_MUX", "CH7", "HDMI"},
356 {"HDMI_CH1_MUX", "CH0", "HDMI"},
357 {"HDMI_CH1_MUX", "CH1", "HDMI"},
358 {"HDMI_CH1_MUX", "CH2", "HDMI"},
359 {"HDMI_CH1_MUX", "CH3", "HDMI"},
360 {"HDMI_CH1_MUX", "CH4", "HDMI"},
361 {"HDMI_CH1_MUX", "CH5", "HDMI"},
362 {"HDMI_CH1_MUX", "CH6", "HDMI"},
363 {"HDMI_CH1_MUX", "CH7", "HDMI"},
365 {"HDMI_CH2_MUX", "CH0", "HDMI"},
366 {"HDMI_CH2_MUX", "CH1", "HDMI"},
367 {"HDMI_CH2_MUX", "CH2", "HDMI"},
368 {"HDMI_CH2_MUX", "CH3", "HDMI"},
369 {"HDMI_CH2_MUX", "CH4", "HDMI"},
370 {"HDMI_CH2_MUX", "CH5", "HDMI"},
371 {"HDMI_CH2_MUX", "CH6", "HDMI"},
372 {"HDMI_CH2_MUX", "CH7", "HDMI"},
374 {"HDMI_CH3_MUX", "CH0", "HDMI"},
375 {"HDMI_CH3_MUX", "CH1", "HDMI"},
376 {"HDMI_CH3_MUX", "CH2", "HDMI"},
377 {"HDMI_CH3_MUX", "CH3", "HDMI"},
378 {"HDMI_CH3_MUX", "CH4", "HDMI"},
379 {"HDMI_CH3_MUX", "CH5", "HDMI"},
380 {"HDMI_CH3_MUX", "CH6", "HDMI"},
381 {"HDMI_CH3_MUX", "CH7", "HDMI"},
383 {"HDMI_CH4_MUX", "CH0", "HDMI"},
384 {"HDMI_CH4_MUX", "CH1", "HDMI"},
385 {"HDMI_CH4_MUX", "CH2", "HDMI"},
386 {"HDMI_CH4_MUX", "CH3", "HDMI"},
387 {"HDMI_CH4_MUX", "CH4", "HDMI"},
388 {"HDMI_CH4_MUX", "CH5", "HDMI"},
389 {"HDMI_CH4_MUX", "CH6", "HDMI"},
390 {"HDMI_CH4_MUX", "CH7", "HDMI"},
392 {"HDMI_CH5_MUX", "CH0", "HDMI"},
393 {"HDMI_CH5_MUX", "CH1", "HDMI"},
394 {"HDMI_CH5_MUX", "CH2", "HDMI"},
395 {"HDMI_CH5_MUX", "CH3", "HDMI"},
396 {"HDMI_CH5_MUX", "CH4", "HDMI"},
397 {"HDMI_CH5_MUX", "CH5", "HDMI"},
398 {"HDMI_CH5_MUX", "CH6", "HDMI"},
399 {"HDMI_CH5_MUX", "CH7", "HDMI"},
401 {"HDMI_CH6_MUX", "CH0", "HDMI"},
402 {"HDMI_CH6_MUX", "CH1", "HDMI"},
403 {"HDMI_CH6_MUX", "CH2", "HDMI"},
404 {"HDMI_CH6_MUX", "CH3", "HDMI"},
405 {"HDMI_CH6_MUX", "CH4", "HDMI"},
406 {"HDMI_CH6_MUX", "CH5", "HDMI"},
407 {"HDMI_CH6_MUX", "CH6", "HDMI"},
408 {"HDMI_CH6_MUX", "CH7", "HDMI"},
410 {"HDMI_CH7_MUX", "CH0", "HDMI"},
411 {"HDMI_CH7_MUX", "CH1", "HDMI"},
412 {"HDMI_CH7_MUX", "CH2", "HDMI"},
413 {"HDMI_CH7_MUX", "CH3", "HDMI"},
414 {"HDMI_CH7_MUX", "CH4", "HDMI"},
415 {"HDMI_CH7_MUX", "CH5", "HDMI"},
416 {"HDMI_CH7_MUX", "CH6", "HDMI"},
417 {"HDMI_CH7_MUX", "CH7", "HDMI"},
447 dev_warn(afe->dev, in mtk_dai_tdm_cal_mclk()
449 return -EINVAL; in mtk_dai_tdm_cal_mclk()
453 dev_warn(afe->dev, in mtk_dai_tdm_cal_mclk()
455 return -EINVAL; in mtk_dai_tdm_cal_mclk()
458 tdm_priv->mclk_rate = freq; in mtk_dai_tdm_cal_mclk()
459 tdm_priv->mclk_apll = apll; in mtk_dai_tdm_cal_mclk()
469 struct mt8183_afe_private *afe_priv = afe->platform_priv; in mtk_dai_tdm_hw_params()
470 int tdm_id = dai->id; in mtk_dai_tdm_hw_params()
471 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[tdm_id]; in mtk_dai_tdm_hw_params()
472 unsigned int tdm_out_mode = tdm_priv->tdm_out_mode; in mtk_dai_tdm_hw_params()
481 if (!tdm_priv->mclk_rate) { in mtk_dai_tdm_hw_params()
482 tdm_priv->mclk_rate = rate * tdm_priv->mclk_multiple; in mtk_dai_tdm_hw_params()
485 tdm_priv->mclk_rate); in mtk_dai_tdm_hw_params()
489 tdm_priv->bck_rate = rate * in mtk_dai_tdm_hw_params()
493 if (tdm_priv->bck_rate > tdm_priv->mclk_rate) in mtk_dai_tdm_hw_params()
494 dev_warn(afe->dev, "%s(), bck_rate > mclk_rate rate", __func__); in mtk_dai_tdm_hw_params()
496 if (tdm_priv->mclk_rate % tdm_priv->bck_rate != 0) in mtk_dai_tdm_hw_params()
497 dev_warn(afe->dev, "%s(), bck cannot generate", __func__); in mtk_dai_tdm_hw_params()
499 dev_info(afe->dev, "%s(), id %d, rate %d, channels %d, format %d, mclk_rate %d, bck_rate %d\n", in mtk_dai_tdm_hw_params()
502 tdm_priv->mclk_rate, tdm_priv->bck_rate); in mtk_dai_tdm_hw_params()
503 dev_info(afe->dev, "%s(), out_channels_per_sdata = %d\n", in mtk_dai_tdm_hw_params()
507 if (tdm_priv->bck_invert) in mtk_dai_tdm_hw_params()
508 regmap_update_bits(afe->regmap, AUDIO_TOP_CON3, in mtk_dai_tdm_hw_params()
512 if (tdm_priv->lck_invert) in mtk_dai_tdm_hw_params()
515 if (tdm_priv->tdm_out_mode == TDM_OUT_I2S) { in mtk_dai_tdm_hw_params()
518 } else if (tdm_priv->tdm_out_mode == TDM_OUT_TDM) { in mtk_dai_tdm_hw_params()
527 regmap_write(afe->regmap, AFE_TDM_CON1, tdm_con); in mtk_dai_tdm_hw_params()
530 switch (channels) { in mtk_dai_tdm_hw_params()
569 regmap_write(afe->regmap, AFE_TDM_CON2, tdm_con); in mtk_dai_tdm_hw_params()
571 regmap_update_bits(afe->regmap, AFE_HDMI_OUT_CON0, in mtk_dai_tdm_hw_params()
575 regmap_update_bits(afe->regmap, AFE_HDMI_OUT_CON0, in mtk_dai_tdm_hw_params()
587 switch (cmd) { in mtk_dai_tdm_trigger()
591 regmap_update_bits(afe->regmap, AFE_HDMI_OUT_CON0, in mtk_dai_tdm_trigger()
595 regmap_update_bits(afe->regmap, AFE_TDM_CON1, in mtk_dai_tdm_trigger()
601 regmap_update_bits(afe->regmap, AFE_TDM_CON1, in mtk_dai_tdm_trigger()
604 regmap_update_bits(afe->regmap, AFE_HDMI_OUT_CON0, in mtk_dai_tdm_trigger()
609 return -EINVAL; in mtk_dai_tdm_trigger()
618 struct mtk_base_afe *afe = dev_get_drvdata(dai->dev); in mtk_dai_tdm_set_sysclk()
619 struct mt8183_afe_private *afe_priv = afe->platform_priv; in mtk_dai_tdm_set_sysclk()
620 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai->id]; in mtk_dai_tdm_set_sysclk()
623 dev_warn(afe->dev, "%s(), tdm_priv == NULL", __func__); in mtk_dai_tdm_set_sysclk()
624 return -EINVAL; in mtk_dai_tdm_set_sysclk()
628 dev_warn(afe->dev, "%s(), dir != SND_SOC_CLOCK_OUT", __func__); in mtk_dai_tdm_set_sysclk()
629 return -EINVAL; in mtk_dai_tdm_set_sysclk()
632 dev_info(afe->dev, "%s(), freq %d\n", __func__, freq); in mtk_dai_tdm_set_sysclk()
639 struct mtk_base_afe *afe = dev_get_drvdata(dai->dev); in mtk_dai_tdm_set_fmt()
640 struct mt8183_afe_private *afe_priv = afe->platform_priv; in mtk_dai_tdm_set_fmt()
641 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai->id]; in mtk_dai_tdm_set_fmt()
644 dev_warn(afe->dev, "%s(), tdm_priv == NULL", __func__); in mtk_dai_tdm_set_fmt()
645 return -EINVAL; in mtk_dai_tdm_set_fmt()
649 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in mtk_dai_tdm_set_fmt()
651 tdm_priv->tdm_out_mode = TDM_OUT_I2S; in mtk_dai_tdm_set_fmt()
654 tdm_priv->tdm_out_mode = TDM_OUT_TDM; in mtk_dai_tdm_set_fmt()
657 tdm_priv->tdm_out_mode = TDM_OUT_I2S; in mtk_dai_tdm_set_fmt()
661 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { in mtk_dai_tdm_set_fmt()
663 tdm_priv->bck_invert = TDM_BCK_NON_INV; in mtk_dai_tdm_set_fmt()
664 tdm_priv->lck_invert = TDM_LCK_NON_INV; in mtk_dai_tdm_set_fmt()
667 tdm_priv->bck_invert = TDM_BCK_NON_INV; in mtk_dai_tdm_set_fmt()
668 tdm_priv->lck_invert = TDM_LCK_INV; in mtk_dai_tdm_set_fmt()
671 tdm_priv->bck_invert = TDM_BCK_INV; in mtk_dai_tdm_set_fmt()
672 tdm_priv->lck_invert = TDM_LCK_NON_INV; in mtk_dai_tdm_set_fmt()
676 tdm_priv->bck_invert = TDM_BCK_INV; in mtk_dai_tdm_set_fmt()
677 tdm_priv->lck_invert = TDM_LCK_INV; in mtk_dai_tdm_set_fmt()
719 struct mt8183_afe_private *afe_priv = afe->platform_priv; in mt8183_dai_tdm_register()
723 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8183_dai_tdm_register()
725 return -ENOMEM; in mt8183_dai_tdm_register()
727 list_add(&dai->list, &afe->sub_dais); in mt8183_dai_tdm_register()
729 dai->dai_drivers = mtk_dai_tdm_driver; in mt8183_dai_tdm_register()
730 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_tdm_driver); in mt8183_dai_tdm_register()
732 dai->dapm_widgets = mtk_dai_tdm_widgets; in mt8183_dai_tdm_register()
733 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_tdm_widgets); in mt8183_dai_tdm_register()
734 dai->dapm_routes = mtk_dai_tdm_routes; in mt8183_dai_tdm_register()
735 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_tdm_routes); in mt8183_dai_tdm_register()
737 tdm_priv = devm_kzalloc(afe->dev, sizeof(struct mtk_afe_tdm_priv), in mt8183_dai_tdm_register()
740 return -ENOMEM; in mt8183_dai_tdm_register()
742 tdm_priv->mclk_multiple = 128; in mt8183_dai_tdm_register()
743 tdm_priv->bck_id = MT8183_I2S4_BCK; in mt8183_dai_tdm_register()
744 tdm_priv->mclk_id = MT8183_I2S4_MCK; in mt8183_dai_tdm_register()
746 afe_priv->dai_priv[MT8183_DAI_TDM] = tdm_priv; in mt8183_dai_tdm_register()