1 // SPDX-License-Identifier: GPL-2.0
3 // MediaTek ALSA SoC Audio DAI Hostless Control
5 // Copyright (c) 2018 MediaTek Inc.
6 // Author: KaiChieh Chuang <kaichieh.chuang@mediatek.com>
8 #include "mt6797-afe-common.h"
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"},
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"},
31 {"Hostless Speech UL", NULL
, "PCM 1 Capture"},
32 {"Hostless Speech UL", NULL
, "PCM 2 Capture"},
33 {"Hostless Speech UL", NULL
, "ADDA Capture"},
37 static int mtk_dai_hostless_startup(struct snd_pcm_substream
*substream
,
38 struct snd_soc_dai
*dai
)
40 struct mtk_base_afe
*afe
= snd_soc_dai_get_drvdata(dai
);
42 return snd_soc_set_runtime_hwparams(substream
, afe
->mtk_afe_hardware
);
45 static const struct snd_soc_dai_ops mtk_dai_hostless_ops
= {
46 .startup
= mtk_dai_hostless_startup
,
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)
56 #define MTK_HOSTLESS_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
57 SNDRV_PCM_FMTBIT_S24_LE |\
58 SNDRV_PCM_FMTBIT_S32_LE)
60 static struct snd_soc_dai_driver mtk_dai_hostless_driver
[] = {
62 .name
= "Hostless LPBK DAI",
63 .id
= MT6797_DAI_HOSTLESS_LPBK
,
65 .stream_name
= "Hostless LPBK DL",
68 .rates
= MTK_HOSTLESS_RATES
,
69 .formats
= MTK_HOSTLESS_FORMATS
,
72 .stream_name
= "Hostless LPBK UL",
75 .rates
= MTK_HOSTLESS_RATES
,
76 .formats
= MTK_HOSTLESS_FORMATS
,
78 .ops
= &mtk_dai_hostless_ops
,
81 .name
= "Hostless Speech DAI",
82 .id
= MT6797_DAI_HOSTLESS_SPEECH
,
84 .stream_name
= "Hostless Speech DL",
87 .rates
= MTK_HOSTLESS_RATES
,
88 .formats
= MTK_HOSTLESS_FORMATS
,
91 .stream_name
= "Hostless Speech UL",
94 .rates
= MTK_HOSTLESS_RATES
,
95 .formats
= MTK_HOSTLESS_FORMATS
,
97 .ops
= &mtk_dai_hostless_ops
,
101 int mt6797_dai_hostless_register(struct mtk_base_afe
*afe
)
103 struct mtk_base_afe_dai
*dai
;
105 dai
= devm_kzalloc(afe
->dev
, sizeof(*dai
), GFP_KERNEL
);
109 list_add(&dai
->list
, &afe
->sub_dais
);
111 dai
->dai_drivers
= mtk_dai_hostless_driver
;
112 dai
->num_dai_drivers
= ARRAY_SIZE(mtk_dai_hostless_driver
);
114 dai
->dapm_routes
= mtk_dai_hostless_routes
;
115 dai
->num_dapm_routes
= ARRAY_SIZE(mtk_dai_hostless_routes
);