blob: b22f3a2d64f7038239738025845c589c26df8777 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Lijian Zhao0e956f22017-10-22 18:30:39 -07002
Lijian Zhao0e956f22017-10-22 18:30:39 -07003#include <nhlt.h>
4#include <soc/nhlt.h>
5
6static const struct nhlt_format_config dmic_1ch_formats[] = {
7 /* 48 KHz 16-bits per sample. */
8 {
9 .num_channels = 1,
10 .sample_freq_khz = 48,
11 .container_bits_per_sample = 16,
12 .valid_bits_per_sample = 16,
13 .settings_file = "dmic-1ch-48khz-16b.bin",
14 },
15};
16
17static const struct nhlt_dmic_array_config dmic_1ch_mic_config = {
18 .tdm_config = {
19 .config_type = NHLT_TDM_MIC_ARRAY,
20 },
21 .array_type = NHLT_MIC_ARRAY_VENDOR_DEFINED,
22};
23
24static const struct nhlt_endp_descriptor dmic_1ch_descriptors[] = {
25 {
26 .link = NHLT_LINK_PDM,
27 .device = NHLT_PDM_DEV,
28 .direction = NHLT_DIR_CAPTURE,
29 .vid = NHLT_VID,
30 .did = NHLT_DID_DMIC,
31 .cfg = &dmic_1ch_mic_config,
32 .cfg_size = sizeof(dmic_1ch_mic_config),
33 .formats = dmic_1ch_formats,
34 .num_formats = ARRAY_SIZE(dmic_1ch_formats),
35 },
36};
37
38static const struct nhlt_format_config dmic_2ch_formats[] = {
39 /* 48 KHz 16-bits per sample. */
40 {
41 .num_channels = 2,
42 .sample_freq_khz = 48,
43 .container_bits_per_sample = 16,
44 .valid_bits_per_sample = 16,
45 .settings_file = "dmic-2ch-48khz-16b.bin",
46 },
47};
48
49static const struct nhlt_dmic_array_config dmic_2ch_mic_config = {
50 .tdm_config = {
51 .config_type = NHLT_TDM_MIC_ARRAY,
52 },
53 .array_type = NHLT_MIC_ARRAY_2CH_SMALL,
54};
55
56static const struct nhlt_endp_descriptor dmic_2ch_descriptors[] = {
57 {
58 .link = NHLT_LINK_PDM,
59 .device = NHLT_PDM_DEV,
60 .direction = NHLT_DIR_CAPTURE,
61 .vid = NHLT_VID,
62 .did = NHLT_DID_DMIC,
63 .cfg = &dmic_2ch_mic_config,
64 .cfg_size = sizeof(dmic_2ch_mic_config),
65 .formats = dmic_2ch_formats,
66 .num_formats = ARRAY_SIZE(dmic_2ch_formats),
67 },
68};
69
70static const struct nhlt_format_config dmic_4ch_formats[] = {
71 /* 48 KHz 16-bits per sample. */
72 {
73 .num_channels = 4,
74 .sample_freq_khz = 48,
75 .container_bits_per_sample = 16,
76 .valid_bits_per_sample = 16,
77 .settings_file = "dmic-4ch-48khz-16b.bin",
78 },
79};
80
81static const struct nhlt_dmic_array_config dmic_4ch_mic_config = {
82 .tdm_config = {
83 .config_type = NHLT_TDM_MIC_ARRAY,
84 },
85 .array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED,
86};
87
88static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = {
89 {
90 .link = NHLT_LINK_PDM,
91 .device = NHLT_PDM_DEV,
92 .direction = NHLT_DIR_CAPTURE,
93 .vid = NHLT_VID,
94 .did = NHLT_DID_DMIC,
95 .cfg = &dmic_4ch_mic_config,
96 .cfg_size = sizeof(dmic_4ch_mic_config),
97 .formats = dmic_4ch_formats,
98 .num_formats = ARRAY_SIZE(dmic_4ch_formats),
99 },
100};
101
102static const struct nhlt_format_config da7219_formats[] = {
103 /* 48 KHz 24-bits per sample. */
104 {
105 .num_channels = 2,
106 .sample_freq_khz = 48,
107 .container_bits_per_sample = 32,
108 .valid_bits_per_sample = 24,
109 .settings_file = "dialog-2ch-48khz-24b.bin",
110 },
111};
112
113static const struct nhlt_tdm_config tdm_config = {
114 .virtual_slot = 0,
115 .config_type = NHLT_TDM_BASIC,
116};
117
118static const struct nhlt_endp_descriptor da7219_descriptors[] = {
119 /* Render Endpoint */
120 {
121 .link = NHLT_LINK_SSP,
122 .device = NHLT_SSP_DEV_I2S,
123 .direction = NHLT_DIR_RENDER,
124 .vid = NHLT_VID,
125 .did = NHLT_DID_SSP,
126 .cfg = &tdm_config,
127 .cfg_size = sizeof(tdm_config),
128 .formats = da7219_formats,
129 .num_formats = ARRAY_SIZE(da7219_formats),
130 },
131 /* Capture Endpoint */
132 {
133 .link = NHLT_LINK_SSP,
134 .device = NHLT_SSP_DEV_I2S,
135 .direction = NHLT_DIR_CAPTURE,
136 .vid = NHLT_VID,
137 .did = NHLT_DID_SSP,
138 .cfg = &tdm_config,
139 .cfg_size = sizeof(tdm_config),
140 .formats = da7219_formats,
141 .num_formats = ARRAY_SIZE(da7219_formats),
142 },
143};
144
145static const struct nhlt_format_config max98357_formats[] = {
146 /* 48 KHz 24-bits per sample. */
147 {
148 .num_channels = 2,
149 .sample_freq_khz = 48,
150 .container_bits_per_sample = 32,
151 .valid_bits_per_sample = 24,
152 .settings_file = "max98357-render-2ch-48khz-24b.bin",
153 },
154};
155
156static const struct nhlt_endp_descriptor max98357_descriptors[] = {
157 {
158 .link = NHLT_LINK_SSP,
159 .device = NHLT_SSP_DEV_I2S,
160 .direction = NHLT_DIR_RENDER,
161 .vid = NHLT_VID,
162 .did = NHLT_DID_SSP,
163 .formats = max98357_formats,
164 .num_formats = ARRAY_SIZE(max98357_formats),
165 },
166};
167
N, Harshapriya4a1ee4b2017-11-28 14:29:26 -0800168static const struct nhlt_format_config max98373_render_formats[] = {
169 /* 48 KHz 24-bits per sample. */
170 {
171 .num_channels = 2,
172 .sample_freq_khz = 48,
173 .container_bits_per_sample = 32,
174 .valid_bits_per_sample = 24,
175 .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT,
176 .settings_file = "max98373-render-2ch-48khz-24b.bin",
177 },
178 /* 48 KHz 16-bits per sample. */
179 {
180 .num_channels = 2,
181 .sample_freq_khz = 48,
182 .container_bits_per_sample = 16,
183 .valid_bits_per_sample = 16,
184 .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT,
185 .settings_file = "max98373-render-2ch-48khz-16b.bin",
186 }
187};
188
189static const struct nhlt_format_config max98373_capture_formats[] = {
190 /* 48 KHz 16-bits per sample. */
191 {
192 .num_channels = 2,
193 .sample_freq_khz = 48,
194 .container_bits_per_sample = 16,
195 .valid_bits_per_sample = 16,
196 .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT,
197 .settings_file = "max98373-render-2ch-48khz-16b.bin",
198 },
199};
200
201static const struct nhlt_endp_descriptor max98373_descriptors[] = {
202 {
203 .link = NHLT_LINK_SSP,
204 .device = NHLT_SSP_DEV_I2S,
205 .direction = NHLT_DIR_RENDER,
206 .vid = NHLT_VID,
207 .did = NHLT_DID_SSP,
208 .formats = max98373_render_formats,
209 .num_formats = ARRAY_SIZE(max98373_render_formats),
210 },
211 {
212 .link = NHLT_LINK_SSP,
213 .device = NHLT_SSP_DEV_I2S,
214 .direction = NHLT_DIR_CAPTURE,
215 .vid = NHLT_VID,
216 .did = NHLT_DID_SSP,
217 .formats = max98373_capture_formats,
218 .num_formats = ARRAY_SIZE(max98373_capture_formats),
Elyes HAOUAS88607a42018-10-05 10:36:45 +0200219 },
N, Harshapriya4a1ee4b2017-11-28 14:29:26 -0800220};
221
Lijian Zhao0e956f22017-10-22 18:30:39 -0700222int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels)
223{
224 switch (num_channels) {
225 case 1:
226 return nhlt_add_endpoints(nhlt, dmic_1ch_descriptors,
227 ARRAY_SIZE(dmic_1ch_descriptors));
228 case 2:
229 return nhlt_add_endpoints(nhlt, dmic_2ch_descriptors,
230 ARRAY_SIZE(dmic_2ch_descriptors));
231 case 4:
232 return nhlt_add_endpoints(nhlt, dmic_4ch_descriptors,
233 ARRAY_SIZE(dmic_4ch_descriptors));
234 default:
235 return -1;
236 }
237}
238
239int nhlt_soc_add_da7219(struct nhlt *nhlt, int hwlink)
240{
241 /* Virtual bus id of SSP links are the hardware port ids proper. */
242 return nhlt_add_ssp_endpoints(nhlt, hwlink, da7219_descriptors,
243 ARRAY_SIZE(da7219_descriptors));
244}
245
246int nhlt_soc_add_max98357(struct nhlt *nhlt, int hwlink)
247{
248 /* Virtual bus id of SSP links are the hardware port ids proper. */
249 return nhlt_add_ssp_endpoints(nhlt, hwlink, max98357_descriptors,
250 ARRAY_SIZE(max98357_descriptors));
251}
N, Harshapriya4a1ee4b2017-11-28 14:29:26 -0800252
253int nhlt_soc_add_max98373(struct nhlt *nhlt, int hwlink)
254{
255 /* Virtual bus id of SSP links are the hardware port ids proper. */
256 return nhlt_add_ssp_endpoints(nhlt, hwlink, max98373_descriptors,
257 ARRAY_SIZE(max98373_descriptors));
258}