treewide: replace GPLv2 long form headers with SPDX header
[coreboot.git] / src / soc / intel / cannonlake / nhlt.c
bloba63502aac993959784829503d53470b249d8fd9d
1 /* This file is part of the coreboot project. */
2 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 #include <nhlt.h>
5 #include <soc/nhlt.h>
7 static const struct nhlt_format_config dmic_1ch_formats[] = {
8 /* 48 KHz 16-bits per sample. */
10 .num_channels = 1,
11 .sample_freq_khz = 48,
12 .container_bits_per_sample = 16,
13 .valid_bits_per_sample = 16,
14 .settings_file = "dmic-1ch-48khz-16b.bin",
18 static const struct nhlt_dmic_array_config dmic_1ch_mic_config = {
19 .tdm_config = {
20 .config_type = NHLT_TDM_MIC_ARRAY,
22 .array_type = NHLT_MIC_ARRAY_VENDOR_DEFINED,
25 static const struct nhlt_endp_descriptor dmic_1ch_descriptors[] = {
27 .link = NHLT_LINK_PDM,
28 .device = NHLT_PDM_DEV,
29 .direction = NHLT_DIR_CAPTURE,
30 .vid = NHLT_VID,
31 .did = NHLT_DID_DMIC,
32 .cfg = &dmic_1ch_mic_config,
33 .cfg_size = sizeof(dmic_1ch_mic_config),
34 .formats = dmic_1ch_formats,
35 .num_formats = ARRAY_SIZE(dmic_1ch_formats),
39 static const struct nhlt_format_config dmic_2ch_formats[] = {
40 /* 48 KHz 16-bits per sample. */
42 .num_channels = 2,
43 .sample_freq_khz = 48,
44 .container_bits_per_sample = 16,
45 .valid_bits_per_sample = 16,
46 .settings_file = "dmic-2ch-48khz-16b.bin",
50 static const struct nhlt_dmic_array_config dmic_2ch_mic_config = {
51 .tdm_config = {
52 .config_type = NHLT_TDM_MIC_ARRAY,
54 .array_type = NHLT_MIC_ARRAY_2CH_SMALL,
57 static const struct nhlt_endp_descriptor dmic_2ch_descriptors[] = {
59 .link = NHLT_LINK_PDM,
60 .device = NHLT_PDM_DEV,
61 .direction = NHLT_DIR_CAPTURE,
62 .vid = NHLT_VID,
63 .did = NHLT_DID_DMIC,
64 .cfg = &dmic_2ch_mic_config,
65 .cfg_size = sizeof(dmic_2ch_mic_config),
66 .formats = dmic_2ch_formats,
67 .num_formats = ARRAY_SIZE(dmic_2ch_formats),
71 static const struct nhlt_format_config dmic_4ch_formats[] = {
72 /* 48 KHz 16-bits per sample. */
74 .num_channels = 4,
75 .sample_freq_khz = 48,
76 .container_bits_per_sample = 16,
77 .valid_bits_per_sample = 16,
78 .settings_file = "dmic-4ch-48khz-16b.bin",
82 static const struct nhlt_dmic_array_config dmic_4ch_mic_config = {
83 .tdm_config = {
84 .config_type = NHLT_TDM_MIC_ARRAY,
86 .array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED,
89 static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = {
91 .link = NHLT_LINK_PDM,
92 .device = NHLT_PDM_DEV,
93 .direction = NHLT_DIR_CAPTURE,
94 .vid = NHLT_VID,
95 .did = NHLT_DID_DMIC,
96 .cfg = &dmic_4ch_mic_config,
97 .cfg_size = sizeof(dmic_4ch_mic_config),
98 .formats = dmic_4ch_formats,
99 .num_formats = ARRAY_SIZE(dmic_4ch_formats),
103 static const struct nhlt_format_config da7219_formats[] = {
104 /* 48 KHz 24-bits per sample. */
106 .num_channels = 2,
107 .sample_freq_khz = 48,
108 .container_bits_per_sample = 32,
109 .valid_bits_per_sample = 24,
110 .settings_file = "dialog-2ch-48khz-24b.bin",
114 static const struct nhlt_tdm_config tdm_config = {
115 .virtual_slot = 0,
116 .config_type = NHLT_TDM_BASIC,
119 static const struct nhlt_endp_descriptor da7219_descriptors[] = {
120 /* Render Endpoint */
122 .link = NHLT_LINK_SSP,
123 .device = NHLT_SSP_DEV_I2S,
124 .direction = NHLT_DIR_RENDER,
125 .vid = NHLT_VID,
126 .did = NHLT_DID_SSP,
127 .cfg = &tdm_config,
128 .cfg_size = sizeof(tdm_config),
129 .formats = da7219_formats,
130 .num_formats = ARRAY_SIZE(da7219_formats),
132 /* Capture Endpoint */
134 .link = NHLT_LINK_SSP,
135 .device = NHLT_SSP_DEV_I2S,
136 .direction = NHLT_DIR_CAPTURE,
137 .vid = NHLT_VID,
138 .did = NHLT_DID_SSP,
139 .cfg = &tdm_config,
140 .cfg_size = sizeof(tdm_config),
141 .formats = da7219_formats,
142 .num_formats = ARRAY_SIZE(da7219_formats),
146 static const struct nhlt_format_config max98357_formats[] = {
147 /* 48 KHz 24-bits per sample. */
149 .num_channels = 2,
150 .sample_freq_khz = 48,
151 .container_bits_per_sample = 32,
152 .valid_bits_per_sample = 24,
153 .settings_file = "max98357-render-2ch-48khz-24b.bin",
157 static const struct nhlt_endp_descriptor max98357_descriptors[] = {
159 .link = NHLT_LINK_SSP,
160 .device = NHLT_SSP_DEV_I2S,
161 .direction = NHLT_DIR_RENDER,
162 .vid = NHLT_VID,
163 .did = NHLT_DID_SSP,
164 .formats = max98357_formats,
165 .num_formats = ARRAY_SIZE(max98357_formats),
169 static const struct nhlt_format_config max98373_render_formats[] = {
170 /* 48 KHz 24-bits per sample. */
172 .num_channels = 2,
173 .sample_freq_khz = 48,
174 .container_bits_per_sample = 32,
175 .valid_bits_per_sample = 24,
176 .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT,
177 .settings_file = "max98373-render-2ch-48khz-24b.bin",
179 /* 48 KHz 16-bits per sample. */
181 .num_channels = 2,
182 .sample_freq_khz = 48,
183 .container_bits_per_sample = 16,
184 .valid_bits_per_sample = 16,
185 .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT,
186 .settings_file = "max98373-render-2ch-48khz-16b.bin",
190 static const struct nhlt_format_config max98373_capture_formats[] = {
191 /* 48 KHz 16-bits per sample. */
193 .num_channels = 2,
194 .sample_freq_khz = 48,
195 .container_bits_per_sample = 16,
196 .valid_bits_per_sample = 16,
197 .speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT,
198 .settings_file = "max98373-render-2ch-48khz-16b.bin",
202 static const struct nhlt_endp_descriptor max98373_descriptors[] = {
204 .link = NHLT_LINK_SSP,
205 .device = NHLT_SSP_DEV_I2S,
206 .direction = NHLT_DIR_RENDER,
207 .vid = NHLT_VID,
208 .did = NHLT_DID_SSP,
209 .formats = max98373_render_formats,
210 .num_formats = ARRAY_SIZE(max98373_render_formats),
213 .link = NHLT_LINK_SSP,
214 .device = NHLT_SSP_DEV_I2S,
215 .direction = NHLT_DIR_CAPTURE,
216 .vid = NHLT_VID,
217 .did = NHLT_DID_SSP,
218 .formats = max98373_capture_formats,
219 .num_formats = ARRAY_SIZE(max98373_capture_formats),
223 int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels)
225 switch (num_channels) {
226 case 1:
227 return nhlt_add_endpoints(nhlt, dmic_1ch_descriptors,
228 ARRAY_SIZE(dmic_1ch_descriptors));
229 case 2:
230 return nhlt_add_endpoints(nhlt, dmic_2ch_descriptors,
231 ARRAY_SIZE(dmic_2ch_descriptors));
232 case 4:
233 return nhlt_add_endpoints(nhlt, dmic_4ch_descriptors,
234 ARRAY_SIZE(dmic_4ch_descriptors));
235 default:
236 return -1;
240 int nhlt_soc_add_da7219(struct nhlt *nhlt, int hwlink)
242 /* Virtual bus id of SSP links are the hardware port ids proper. */
243 return nhlt_add_ssp_endpoints(nhlt, hwlink, da7219_descriptors,
244 ARRAY_SIZE(da7219_descriptors));
247 int nhlt_soc_add_max98357(struct nhlt *nhlt, int hwlink)
249 /* Virtual bus id of SSP links are the hardware port ids proper. */
250 return nhlt_add_ssp_endpoints(nhlt, hwlink, max98357_descriptors,
251 ARRAY_SIZE(max98357_descriptors));
254 int nhlt_soc_add_max98373(struct nhlt *nhlt, int hwlink)
256 /* Virtual bus id of SSP links are the hardware port ids proper. */
257 return nhlt_add_ssp_endpoints(nhlt, hwlink, max98373_descriptors,
258 ARRAY_SIZE(max98373_descriptors));