blob: b43a34ea3139f1b0596d0d17f0d3efcd1e6c885d [file] [log] [blame]
Saurabh Satija734aa872016-06-21 14:22:16 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016 Intel Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <console/console.h>
18#include <nhlt.h>
19#include <soc/nhlt.h>
20
Sathyanarayana Nujella3e0a3fb2016-10-26 17:31:36 -070021static const struct nhlt_format_config dmic_1ch_formats[] = {
22 /* 48 KHz 16-bits per sample. */
23 {
24 .num_channels = 1,
25 .sample_freq_khz = 48,
26 .container_bits_per_sample = 16,
27 .valid_bits_per_sample = 16,
28 .settings_file = "dmic-1ch-48khz-16b.bin",
29 },
30};
31
32static const struct nhlt_dmic_array_config dmic_1ch_mic_config = {
33 .tdm_config = {
34 .config_type = NHLT_TDM_MIC_ARRAY,
35 },
36 .array_type = NHLT_MIC_ARRAY_VENDOR_DEFINED,
37};
38
39static const struct nhlt_endp_descriptor dmic_1ch_descriptors[] = {
40 {
41 .link = NHLT_LINK_PDM,
42 .device = NHLT_PDM_DEV,
43 .direction = NHLT_DIR_CAPTURE,
44 .vid = NHLT_VID,
45 .did = NHLT_DID_DMIC,
46 .cfg = &dmic_1ch_mic_config,
47 .cfg_size = sizeof(dmic_1ch_mic_config),
48 .formats = dmic_1ch_formats,
49 .num_formats = ARRAY_SIZE(dmic_1ch_formats),
50 },
51};
52
Saurabh Satija734aa872016-06-21 14:22:16 -070053static const struct nhlt_format_config dmic_2ch_formats[] = {
54 /* 48 KHz 16-bits per sample. */
55 {
56 .num_channels = 2,
57 .sample_freq_khz = 48,
58 .container_bits_per_sample = 16,
59 .valid_bits_per_sample = 16,
60 .settings_file = "dmic-2ch-48khz-16b.bin",
61 },
62};
63
64static const struct nhlt_dmic_array_config dmic_2ch_mic_config = {
65 .tdm_config = {
66 .config_type = NHLT_TDM_MIC_ARRAY,
67 },
68 .array_type = NHLT_MIC_ARRAY_2CH_SMALL,
69};
70
71static const struct nhlt_endp_descriptor dmic_2ch_descriptors[] = {
72 {
73 .link = NHLT_LINK_PDM,
74 .device = NHLT_PDM_DEV,
75 .direction = NHLT_DIR_CAPTURE,
76 .vid = NHLT_VID,
77 .did = NHLT_DID_DMIC,
78 .cfg = &dmic_2ch_mic_config,
79 .cfg_size = sizeof(dmic_2ch_mic_config),
80 .formats = dmic_2ch_formats,
81 .num_formats = ARRAY_SIZE(dmic_2ch_formats),
82 },
83};
84
Sathyanarayana Nujella3e0a3fb2016-10-26 17:31:36 -070085static const struct nhlt_format_config dmic_4ch_formats[] = {
86 /* 48 KHz 16-bits per sample. */
87 {
88 .num_channels = 4,
89 .sample_freq_khz = 48,
90 .container_bits_per_sample = 16,
91 .valid_bits_per_sample = 16,
92 .settings_file = "dmic-4ch-48khz-16b.bin",
93 },
94};
95
96static const struct nhlt_dmic_array_config dmic_4ch_mic_config = {
97 .tdm_config = {
98 .config_type = NHLT_TDM_MIC_ARRAY,
99 },
100 .array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED,
101};
102
103static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = {
104 {
105 .link = NHLT_LINK_PDM,
106 .device = NHLT_PDM_DEV,
107 .direction = NHLT_DIR_CAPTURE,
108 .vid = NHLT_VID,
109 .did = NHLT_DID_DMIC,
110 .cfg = &dmic_4ch_mic_config,
111 .cfg_size = sizeof(dmic_4ch_mic_config),
112 .formats = dmic_4ch_formats,
113 .num_formats = ARRAY_SIZE(dmic_4ch_formats),
114 },
115};
116
Saurabh Satija734aa872016-06-21 14:22:16 -0700117static const struct nhlt_format_config da7219_formats[] = {
118 /* 48 KHz 24-bits per sample. */
119 {
120 .num_channels = 2,
121 .sample_freq_khz = 48,
122 .container_bits_per_sample = 32,
123 .valid_bits_per_sample = 24,
124 .settings_file = "dialog-2ch-48khz-24b.bin",
125 },
126};
127
128static const struct nhlt_tdm_config tdm_config = {
129 .virtual_slot = 0,
130 .config_type = NHLT_TDM_BASIC,
131};
132
133static const struct nhlt_endp_descriptor da7219_descriptors[] = {
134 /* Render Endpoint */
135 {
136 .link = NHLT_LINK_SSP,
137 .device = NHLT_SSP_DEV_I2S,
138 .direction = NHLT_DIR_RENDER,
139 .vid = NHLT_VID,
140 .did = NHLT_DID_SSP,
141 .cfg = &tdm_config,
142 .cfg_size = sizeof(tdm_config),
143 .formats = da7219_formats,
144 .num_formats = ARRAY_SIZE(da7219_formats),
145 },
146 /* Capture Endpoint */
147 {
148 .link = NHLT_LINK_SSP,
149 .device = NHLT_SSP_DEV_I2S,
150 .direction = NHLT_DIR_CAPTURE,
151 .vid = NHLT_VID,
152 .did = NHLT_DID_SSP,
153 .cfg = &tdm_config,
154 .cfg_size = sizeof(tdm_config),
155 .formats = da7219_formats,
156 .num_formats = ARRAY_SIZE(da7219_formats),
157 },
158};
159
160static const struct nhlt_format_config max98357_formats[] = {
161 /* 48 KHz 24-bits per sample. */
162 {
163 .num_channels = 2,
164 .sample_freq_khz = 48,
165 .container_bits_per_sample = 32,
166 .valid_bits_per_sample = 24,
167 .settings_file = "max98357-render-2ch-48khz-24b.bin",
168 },
169};
170
171static const struct nhlt_endp_descriptor max98357_descriptors[] = {
172 {
173 .link = NHLT_LINK_SSP,
174 .device = NHLT_SSP_DEV_I2S,
175 .direction = NHLT_DIR_RENDER,
176 .vid = NHLT_VID,
177 .did = NHLT_DID_SSP,
178 .formats = max98357_formats,
179 .num_formats = ARRAY_SIZE(max98357_formats),
180 },
181};
182
183int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels)
184{
Sathyanarayana Nujella3e0a3fb2016-10-26 17:31:36 -0700185 switch (num_channels) {
186 case 1:
187 return nhlt_add_endpoints(nhlt, dmic_1ch_descriptors,
188 ARRAY_SIZE(dmic_1ch_descriptors));
189 case 2:
190 return nhlt_add_endpoints(nhlt, dmic_2ch_descriptors,
Saurabh Satija734aa872016-06-21 14:22:16 -0700191 ARRAY_SIZE(dmic_2ch_descriptors));
Sathyanarayana Nujella3e0a3fb2016-10-26 17:31:36 -0700192 case 4:
193 return nhlt_add_endpoints(nhlt, dmic_4ch_descriptors,
194 ARRAY_SIZE(dmic_4ch_descriptors));
195 default:
196 return -1;
197 }
Saurabh Satija734aa872016-06-21 14:22:16 -0700198}
199
200int nhlt_soc_add_da7219(struct nhlt *nhlt, int hwlink)
201{
202 /* Virtual bus id of SSP links are the hardware port ids proper. */
203 return nhlt_add_ssp_endpoints(nhlt, hwlink, da7219_descriptors,
204 ARRAY_SIZE(da7219_descriptors));
205}
206
207int nhlt_soc_add_max98357(struct nhlt *nhlt, int hwlink)
208{
209 /* Virtual bus id of SSP links are the hardware port ids proper. */
210 return nhlt_add_ssp_endpoints(nhlt, hwlink, max98357_descriptors,
211 ARRAY_SIZE(max98357_descriptors));
212}