WIP FPC-III support
[linux/fpc-iii.git] / sound / soc / mediatek / mt6797 / mt6797-dai-hostless.c
blobed23e6a53b086f63e42ab539916d94e889a521c8
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>
8 #include "mt6797-afe-common.h"
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"},
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"},
31 {"Hostless Speech UL", NULL, "PCM 1 Capture"},
32 {"Hostless Speech UL", NULL, "PCM 2 Capture"},
33 {"Hostless Speech UL", NULL, "ADDA Capture"},
36 /* dai ops */
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,
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)
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,
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,
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,
78 .ops = &mtk_dai_hostless_ops,
81 .name = "Hostless Speech DAI",
82 .id = MT6797_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,
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,
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);
106 if (!dai)
107 return -ENOMEM;
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);
117 return 0;