Lines Matching +full:ch0 +full:- +full:2

1 // SPDX-License-Identifier: GPL-2.0
11 #include "mt8192-afe-clk.h"
12 #include "mt8192-afe-common.h"
13 #include "mt8192-afe-gpio.h"
14 #include "mt8192-interconnection.h"
32 TDM_OUT_DSP_B = 2,
47 TDM_WLEN_32_BIT = 2,
53 TDM_CHANNEL_BCK_32 = 2,
59 TDM_CHANNEL_NUM_8 = 2,
84 return snd_pcm_format_physical_width(format) - 1; in get_tdm_lrck_width()
91 case 2: in get_tdm_ch()
109 else if (channels > 2) in get_tdm_ch_fixup()
112 return 2; in get_tdm_ch_fixup()
121 return 2; in get_tdm_ch_per_sdata()
137 "CH0", "CH1", "CH2", "CH3",
248 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_tdm_en_event()
250 struct mt8192_afe_private *afe_priv = afe->platform_priv; in mtk_tdm_en_event()
251 int dai_id = get_tdm_id_by_name(w->name); in mtk_tdm_en_event()
252 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; in mtk_tdm_en_event()
255 dev_warn(afe->dev, "%s(), tdm_priv == NULL", __func__); in mtk_tdm_en_event()
256 return -EINVAL; in mtk_tdm_en_event()
259 dev_dbg(cmpnt->dev, "%s(), name %s, event 0x%x\n", in mtk_tdm_en_event()
260 __func__, w->name, event); in mtk_tdm_en_event()
264 mt8192_afe_gpio_request(afe->dev, true, tdm_priv->id, 0); in mtk_tdm_en_event()
267 mt8192_afe_gpio_request(afe->dev, false, tdm_priv->id, 0); in mtk_tdm_en_event()
280 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_tdm_bck_en_event()
282 struct mt8192_afe_private *afe_priv = afe->platform_priv; in mtk_tdm_bck_en_event()
283 int dai_id = get_tdm_id_by_name(w->name); in mtk_tdm_bck_en_event()
284 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; in mtk_tdm_bck_en_event()
287 dev_warn(afe->dev, "%s(), tdm_priv == NULL", __func__); in mtk_tdm_bck_en_event()
288 return -EINVAL; in mtk_tdm_bck_en_event()
291 dev_dbg(cmpnt->dev, "%s(), name %s, event 0x%x, dai_id %d\n", in mtk_tdm_bck_en_event()
292 __func__, w->name, event, dai_id); in mtk_tdm_bck_en_event()
296 mt8192_mck_enable(afe, tdm_priv->bck_id, tdm_priv->bck_rate); in mtk_tdm_bck_en_event()
299 mt8192_mck_disable(afe, tdm_priv->bck_id); in mtk_tdm_bck_en_event()
312 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_tdm_mck_en_event()
314 struct mt8192_afe_private *afe_priv = afe->platform_priv; in mtk_tdm_mck_en_event()
315 int dai_id = get_tdm_id_by_name(w->name); in mtk_tdm_mck_en_event()
316 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; in mtk_tdm_mck_en_event()
319 dev_warn(afe->dev, "%s(), tdm_priv == NULL", __func__); in mtk_tdm_mck_en_event()
320 return -EINVAL; in mtk_tdm_mck_en_event()
323 dev_dbg(cmpnt->dev, "%s(), name %s, event 0x%x, dai_id %d\n", in mtk_tdm_mck_en_event()
324 __func__, w->name, event, dai_id); in mtk_tdm_mck_en_event()
328 mt8192_mck_enable(afe, tdm_priv->mclk_id, tdm_priv->mclk_rate); in mtk_tdm_mck_en_event()
331 tdm_priv->mclk_rate = 0; in mtk_tdm_mck_en_event()
332 mt8192_mck_disable(afe, tdm_priv->mclk_id); in mtk_tdm_mck_en_event()
381 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mtk_afe_tdm_apll_connect()
383 struct mt8192_afe_private *afe_priv = afe->platform_priv; in mtk_afe_tdm_apll_connect()
384 int dai_id = get_tdm_id_by_name(w->name); in mtk_afe_tdm_apll_connect()
385 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; in mtk_afe_tdm_apll_connect()
389 cur_apll = mt8192_get_apll_by_name(afe, source->name); in mtk_afe_tdm_apll_connect()
391 return (tdm_priv->mclk_apll == cur_apll) ? 1 : 0; in mtk_afe_tdm_apll_connect()
395 {"HDMI_CH0_MUX", "CH0", "HDMI"},
404 {"HDMI_CH1_MUX", "CH0", "HDMI"},
413 {"HDMI_CH2_MUX", "CH0", "HDMI"},
422 {"HDMI_CH3_MUX", "CH0", "HDMI"},
431 {"HDMI_CH4_MUX", "CH0", "HDMI"},
440 {"HDMI_CH5_MUX", "CH0", "HDMI"},
449 {"HDMI_CH6_MUX", "CH0", "HDMI"},
458 {"HDMI_CH7_MUX", "CH0", "HDMI"},
496 dev_warn(afe->dev, in mtk_dai_tdm_cal_mclk()
498 return -EINVAL; in mtk_dai_tdm_cal_mclk()
502 dev_warn(afe->dev, in mtk_dai_tdm_cal_mclk()
504 return -EINVAL; in mtk_dai_tdm_cal_mclk()
507 tdm_priv->mclk_rate = freq; in mtk_dai_tdm_cal_mclk()
508 tdm_priv->mclk_apll = apll; in mtk_dai_tdm_cal_mclk()
518 struct mt8192_afe_private *afe_priv = afe->platform_priv; in mtk_dai_tdm_hw_params()
519 int tdm_id = dai->id; in mtk_dai_tdm_hw_params()
520 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[tdm_id]; in mtk_dai_tdm_hw_params()
521 unsigned int tdm_out_mode = tdm_priv->tdm_out_mode; in mtk_dai_tdm_hw_params()
530 if (!tdm_priv->mclk_rate) { in mtk_dai_tdm_hw_params()
531 tdm_priv->mclk_rate = rate * tdm_priv->mclk_multiple; in mtk_dai_tdm_hw_params()
534 tdm_priv->mclk_rate); in mtk_dai_tdm_hw_params()
538 tdm_priv->bck_rate = rate * in mtk_dai_tdm_hw_params()
542 if (tdm_priv->bck_rate > tdm_priv->mclk_rate) in mtk_dai_tdm_hw_params()
543 dev_warn(afe->dev, "%s(), bck_rate > mclk_rate rate", __func__); in mtk_dai_tdm_hw_params()
545 if (tdm_priv->mclk_rate % tdm_priv->bck_rate != 0) in mtk_dai_tdm_hw_params()
546 dev_warn(afe->dev, "%s(), bck cannot generate", __func__); in mtk_dai_tdm_hw_params()
548 dev_dbg(afe->dev, "%s(), id %d, rate %d, channels %d, format %d, mclk_rate %d, bck_rate %d\n", in mtk_dai_tdm_hw_params()
551 tdm_priv->mclk_rate, tdm_priv->bck_rate); in mtk_dai_tdm_hw_params()
553 dev_dbg(afe->dev, "%s(), out_channels_per_sdata = %d\n", in mtk_dai_tdm_hw_params()
557 if (tdm_priv->bck_invert) in mtk_dai_tdm_hw_params()
558 regmap_update_bits(afe->regmap, AUDIO_TOP_CON3, in mtk_dai_tdm_hw_params()
562 if (tdm_priv->lck_invert) in mtk_dai_tdm_hw_params()
565 if (tdm_priv->tdm_out_mode == TDM_OUT_I2S) { in mtk_dai_tdm_hw_params()
568 } else if (tdm_priv->tdm_out_mode == TDM_OUT_DSP_A) { in mtk_dai_tdm_hw_params()
571 } else if (tdm_priv->tdm_out_mode == TDM_OUT_DSP_B) { in mtk_dai_tdm_hw_params()
580 regmap_write(afe->regmap, AFE_TDM_CON1, tdm_con); in mtk_dai_tdm_hw_params()
582 if (out_channels_per_sdata == 2) { in mtk_dai_tdm_hw_params()
585 case 2: in mtk_dai_tdm_hw_params()
622 regmap_write(afe->regmap, AFE_TDM_CON2, tdm_con); in mtk_dai_tdm_hw_params()
624 regmap_update_bits(afe->regmap, AFE_HDMI_OUT_CON0, in mtk_dai_tdm_hw_params()
633 struct mtk_base_afe *afe = dev_get_drvdata(dai->dev); in mtk_dai_tdm_set_sysclk()
634 struct mt8192_afe_private *afe_priv = afe->platform_priv; in mtk_dai_tdm_set_sysclk()
635 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai->id]; in mtk_dai_tdm_set_sysclk()
638 dev_warn(afe->dev, "%s(), tdm_priv == NULL", __func__); in mtk_dai_tdm_set_sysclk()
639 return -EINVAL; in mtk_dai_tdm_set_sysclk()
643 dev_warn(afe->dev, "%s(), dir != SND_SOC_CLOCK_OUT", __func__); in mtk_dai_tdm_set_sysclk()
644 return -EINVAL; in mtk_dai_tdm_set_sysclk()
647 dev_dbg(afe->dev, "%s(), freq %d\n", __func__, freq); in mtk_dai_tdm_set_sysclk()
654 struct mtk_base_afe *afe = dev_get_drvdata(dai->dev); in mtk_dai_tdm_set_fmt()
655 struct mt8192_afe_private *afe_priv = afe->platform_priv; in mtk_dai_tdm_set_fmt()
656 struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai->id]; in mtk_dai_tdm_set_fmt()
659 dev_warn(afe->dev, "%s(), tdm_priv == NULL", __func__); in mtk_dai_tdm_set_fmt()
660 return -EINVAL; in mtk_dai_tdm_set_fmt()
666 tdm_priv->tdm_out_mode = TDM_OUT_I2S; in mtk_dai_tdm_set_fmt()
669 tdm_priv->tdm_out_mode = TDM_OUT_DSP_A; in mtk_dai_tdm_set_fmt()
672 tdm_priv->tdm_out_mode = TDM_OUT_DSP_B; in mtk_dai_tdm_set_fmt()
675 tdm_priv->tdm_out_mode = TDM_OUT_I2S; in mtk_dai_tdm_set_fmt()
681 tdm_priv->bck_invert = TDM_BCK_NON_INV; in mtk_dai_tdm_set_fmt()
682 tdm_priv->lck_invert = TDM_LCK_NON_INV; in mtk_dai_tdm_set_fmt()
685 tdm_priv->bck_invert = TDM_BCK_NON_INV; in mtk_dai_tdm_set_fmt()
686 tdm_priv->lck_invert = TDM_LCK_INV; in mtk_dai_tdm_set_fmt()
689 tdm_priv->bck_invert = TDM_BCK_INV; in mtk_dai_tdm_set_fmt()
690 tdm_priv->lck_invert = TDM_LCK_NON_INV; in mtk_dai_tdm_set_fmt()
694 tdm_priv->bck_invert = TDM_BCK_INV; in mtk_dai_tdm_set_fmt()
695 tdm_priv->lck_invert = TDM_LCK_INV; in mtk_dai_tdm_set_fmt()
725 .channels_min = 2,
738 tdm_priv = devm_kzalloc(afe->dev, sizeof(struct mtk_afe_tdm_priv), in init_tdm_priv_data()
743 tdm_priv->mclk_multiple = 512; in init_tdm_priv_data()
744 tdm_priv->bck_id = MT8192_I2S4_BCK; in init_tdm_priv_data()
745 tdm_priv->mclk_id = MT8192_I2S4_MCK; in init_tdm_priv_data()
746 tdm_priv->id = MT8192_DAI_TDM; in init_tdm_priv_data()
753 struct mt8192_afe_private *afe_priv = afe->platform_priv; in mt8192_dai_tdm_register()
757 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8192_dai_tdm_register()
759 return -ENOMEM; in mt8192_dai_tdm_register()
761 list_add(&dai->list, &afe->sub_dais); in mt8192_dai_tdm_register()
763 dai->dai_drivers = mtk_dai_tdm_driver; in mt8192_dai_tdm_register()
764 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_tdm_driver); in mt8192_dai_tdm_register()
766 dai->dapm_widgets = mtk_dai_tdm_widgets; in mt8192_dai_tdm_register()
767 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_tdm_widgets); in mt8192_dai_tdm_register()
768 dai->dapm_routes = mtk_dai_tdm_routes; in mt8192_dai_tdm_register()
769 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_tdm_routes); in mt8192_dai_tdm_register()
773 return -ENOMEM; in mt8192_dai_tdm_register()
775 afe_priv->dai_priv[MT8192_DAI_TDM] = tdm_priv; in mt8192_dai_tdm_register()