1 // SPDX-License-Identifier: GPL-2.0 2 // 3 // MediaTek ALSA SoC Audio DAI Hostless Control 4 // 5 // Copyright (c) 2018 MediaTek Inc. 6 // Author: KaiChieh Chuang <kaichieh.chuang@mediatek.com> 7 8 #include "mt8183-afe-common.h" 9 10 /* dai component */ 11 static const struct snd_soc_dapm_route mtk_dai_hostless_routes[] = { 12 /* Hostless ADDA Loopback */ 13 {"ADDA_DL_CH1", "ADDA_UL_CH1", "Hostless LPBK DL"}, 14 {"ADDA_DL_CH1", "ADDA_UL_CH2", "Hostless LPBK DL"}, 15 {"ADDA_DL_CH2", "ADDA_UL_CH1", "Hostless LPBK DL"}, 16 {"ADDA_DL_CH2", "ADDA_UL_CH2", "Hostless LPBK DL"}, 17 {"Hostless LPBK UL", NULL, "ADDA Capture"}, 18 19 /* Hostless Speech */ 20 {"ADDA_DL_CH1", "PCM_1_CAP_CH1", "Hostless Speech DL"}, 21 {"ADDA_DL_CH2", "PCM_1_CAP_CH1", "Hostless Speech DL"}, 22 {"ADDA_DL_CH2", "PCM_1_CAP_CH2", "Hostless Speech DL"}, 23 {"ADDA_DL_CH1", "PCM_2_CAP_CH1", "Hostless Speech DL"}, 24 {"ADDA_DL_CH2", "PCM_2_CAP_CH1", "Hostless Speech DL"}, 25 {"ADDA_DL_CH2", "PCM_2_CAP_CH2", "Hostless Speech DL"}, 26 {"PCM_1_PB_CH1", "ADDA_UL_CH1", "Hostless Speech DL"}, 27 {"PCM_1_PB_CH2", "ADDA_UL_CH2", "Hostless Speech DL"}, 28 {"PCM_2_PB_CH1", "ADDA_UL_CH1", "Hostless Speech DL"}, 29 {"PCM_2_PB_CH2", "ADDA_UL_CH2", "Hostless Speech DL"}, 30 31 {"Hostless Speech UL", NULL, "PCM 1 Capture"}, 32 {"Hostless Speech UL", NULL, "PCM 2 Capture"}, 33 {"Hostless Speech UL", NULL, "ADDA Capture"}, 34 }; 35 36 /* dai ops */ 37 static int mtk_dai_hostless_startup(struct snd_pcm_substream *substream, 38 struct snd_soc_dai *dai) 39 { 40 struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); 41 42 return snd_soc_set_runtime_hwparams(substream, afe->mtk_afe_hardware); 43 } 44 45 static const struct snd_soc_dai_ops mtk_dai_hostless_ops = { 46 .startup = mtk_dai_hostless_startup, 47 }; 48 49 /* dai driver */ 50 #define MTK_HOSTLESS_RATES (SNDRV_PCM_RATE_8000_48000 |\ 51 SNDRV_PCM_RATE_88200 |\ 52 SNDRV_PCM_RATE_96000 |\ 53 SNDRV_PCM_RATE_176400 |\ 54 SNDRV_PCM_RATE_192000) 55 56 #define MTK_HOSTLESS_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ 57 SNDRV_PCM_FMTBIT_S24_LE |\ 58 SNDRV_PCM_FMTBIT_S32_LE) 59 60 static struct snd_soc_dai_driver mtk_dai_hostless_driver[] = { 61 { 62 .name = "Hostless LPBK DAI", 63 .id = MT8183_DAI_HOSTLESS_LPBK, 64 .playback = { 65 .stream_name = "Hostless LPBK DL", 66 .channels_min = 1, 67 .channels_max = 2, 68 .rates = MTK_HOSTLESS_RATES, 69 .formats = MTK_HOSTLESS_FORMATS, 70 }, 71 .capture = { 72 .stream_name = "Hostless LPBK UL", 73 .channels_min = 1, 74 .channels_max = 2, 75 .rates = MTK_HOSTLESS_RATES, 76 .formats = MTK_HOSTLESS_FORMATS, 77 }, 78 .ops = &mtk_dai_hostless_ops, 79 }, 80 { 81 .name = "Hostless Speech DAI", 82 .id = MT8183_DAI_HOSTLESS_SPEECH, 83 .playback = { 84 .stream_name = "Hostless Speech DL", 85 .channels_min = 1, 86 .channels_max = 2, 87 .rates = MTK_HOSTLESS_RATES, 88 .formats = MTK_HOSTLESS_FORMATS, 89 }, 90 .capture = { 91 .stream_name = "Hostless Speech UL", 92 .channels_min = 1, 93 .channels_max = 2, 94 .rates = MTK_HOSTLESS_RATES, 95 .formats = MTK_HOSTLESS_FORMATS, 96 }, 97 .ops = &mtk_dai_hostless_ops, 98 }, 99 }; 100 101 int mt8183_dai_hostless_register(struct mtk_base_afe *afe) 102 { 103 struct mtk_base_afe_dai *dai; 104 105 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); 106 if (!dai) 107 return -ENOMEM; 108 109 list_add(&dai->list, &afe->sub_dais); 110 111 dai->dai_drivers = mtk_dai_hostless_driver; 112 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_hostless_driver); 113 114 dai->dapm_routes = mtk_dai_hostless_routes; 115 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_hostless_routes); 116 117 return 0; 118 } 119
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.