1 /******************************************************************************
2 *
3 * Copyright 2015 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 #include "base/logging.h"
20
21 #include "device/include/esco_parameters.h"
22
23 #include "check.h"
24
25 static const enh_esco_params_t default_esco_parameters[ESCO_NUM_CODECS] = {
26 // CVSD D1
27 {
28 .transmit_bandwidth = TXRX_64KBITS_RATE,
29 .receive_bandwidth = TXRX_64KBITS_RATE,
30 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
31 .company_id = 0x0000,
32 .vendor_specific_codec_id = 0x0000},
33 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
34 .company_id = 0x0000,
35 .vendor_specific_codec_id = 0x0000},
36 .transmit_codec_frame_size = 60,
37 .receive_codec_frame_size = 60,
38 .input_bandwidth = INPUT_OUTPUT_64K_RATE,
39 .output_bandwidth = INPUT_OUTPUT_64K_RATE,
40 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
41 .company_id = 0x0000,
42 .vendor_specific_codec_id = 0x0000},
43 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
44 .company_id = 0x0000,
45 .vendor_specific_codec_id = 0x0000},
46 .input_coded_data_size = 16,
47 .output_coded_data_size = 16,
48 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
49 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
50 .input_pcm_payload_msb_position = 0,
51 .output_pcm_payload_msb_position = 0,
52 .input_data_path = ESCO_DATA_PATH_PCM,
53 .output_data_path = ESCO_DATA_PATH_PCM,
54 .input_transport_unit_size = 0x00,
55 .output_transport_unit_size = 0x00,
56 .max_latency_ms = 0xFFFF, // Don't care
57 .packet_types = (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
58 ESCO_PKT_TYPES_MASK_HV3),
59 .retransmission_effort = ESCO_RETRANSMISSION_OFF,
60 },
61 // CVSD S3
62 {
63 .transmit_bandwidth = TXRX_64KBITS_RATE,
64 .receive_bandwidth = TXRX_64KBITS_RATE,
65 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
66 .company_id = 0x0000,
67 .vendor_specific_codec_id = 0x0000},
68 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
69 .company_id = 0x0000,
70 .vendor_specific_codec_id = 0x0000},
71 .transmit_codec_frame_size = 60,
72 .receive_codec_frame_size = 60,
73 .input_bandwidth = INPUT_OUTPUT_64K_RATE,
74 .output_bandwidth = INPUT_OUTPUT_64K_RATE,
75 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
76 .company_id = 0x0000,
77 .vendor_specific_codec_id = 0x0000},
78 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
79 .company_id = 0x0000,
80 .vendor_specific_codec_id = 0x0000},
81 .input_coded_data_size = 16,
82 .output_coded_data_size = 16,
83 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
84 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
85 .input_pcm_payload_msb_position = 0,
86 .output_pcm_payload_msb_position = 0,
87 .input_data_path = ESCO_DATA_PATH_PCM,
88 .output_data_path = ESCO_DATA_PATH_PCM,
89 .input_transport_unit_size = 0x00,
90 .output_transport_unit_size = 0x00,
91 .max_latency_ms = 10,
92 .packet_types =
93 (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
94 ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 |
95 ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5 |
96 ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
97 ESCO_PKT_TYPES_MASK_NO_3_EV5),
98 .retransmission_effort = ESCO_RETRANSMISSION_POWER,
99 },
100 // CVSD S4
101 {
102 .transmit_bandwidth = TXRX_64KBITS_RATE,
103 .receive_bandwidth = TXRX_64KBITS_RATE,
104 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
105 .company_id = 0x0000,
106 .vendor_specific_codec_id = 0x0000},
107 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
108 .company_id = 0x0000,
109 .vendor_specific_codec_id = 0x0000},
110 .transmit_codec_frame_size = 60,
111 .receive_codec_frame_size = 60,
112 .input_bandwidth = INPUT_OUTPUT_64K_RATE,
113 .output_bandwidth = INPUT_OUTPUT_64K_RATE,
114 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
115 .company_id = 0x0000,
116 .vendor_specific_codec_id = 0x0000},
117 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
118 .company_id = 0x0000,
119 .vendor_specific_codec_id = 0x0000},
120 .input_coded_data_size = 16,
121 .output_coded_data_size = 16,
122 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
123 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
124 .input_pcm_payload_msb_position = 0,
125 .output_pcm_payload_msb_position = 0,
126 .input_data_path = ESCO_DATA_PATH_PCM,
127 .output_data_path = ESCO_DATA_PATH_PCM,
128 .input_transport_unit_size = 0x00,
129 .output_transport_unit_size = 0x00,
130 .max_latency_ms = 12,
131 .packet_types =
132 (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
133 ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 |
134 ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5 |
135 ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
136 ESCO_PKT_TYPES_MASK_NO_3_EV5),
137 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
138 },
139 // mSBC T1
140 {
141 .transmit_bandwidth = TXRX_64KBITS_RATE,
142 .receive_bandwidth = TXRX_64KBITS_RATE,
143 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
144 .company_id = 0x0000,
145 .vendor_specific_codec_id = 0x0000},
146 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
147 .company_id = 0x0000,
148 .vendor_specific_codec_id = 0x0000},
149 .transmit_codec_frame_size = 60,
150 .receive_codec_frame_size = 60,
151 .input_bandwidth = INPUT_OUTPUT_128K_RATE,
152 .output_bandwidth = INPUT_OUTPUT_128K_RATE,
153 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
154 .company_id = 0x0000,
155 .vendor_specific_codec_id = 0x0000},
156 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
157 .company_id = 0x0000,
158 .vendor_specific_codec_id = 0x0000},
159 .input_coded_data_size = 16,
160 .output_coded_data_size = 16,
161 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
162 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
163 .input_pcm_payload_msb_position = 0,
164 .output_pcm_payload_msb_position = 0,
165 .input_data_path = ESCO_DATA_PATH_PCM,
166 .output_data_path = ESCO_DATA_PATH_PCM,
167 .input_transport_unit_size = 0x00,
168 .output_transport_unit_size = 0x00,
169 .max_latency_ms = 8,
170 .packet_types =
171 (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
172 ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5 |
173 ESCO_PKT_TYPES_MASK_NO_2_EV3),
174 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
175 },
176 // mSBC T2
177 {
178 .transmit_bandwidth = TXRX_64KBITS_RATE,
179 .receive_bandwidth = TXRX_64KBITS_RATE,
180 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
181 .company_id = 0x0000,
182 .vendor_specific_codec_id = 0x0000},
183 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
184 .company_id = 0x0000,
185 .vendor_specific_codec_id = 0x0000},
186 .transmit_codec_frame_size = 60,
187 .receive_codec_frame_size = 60,
188 .input_bandwidth = INPUT_OUTPUT_128K_RATE,
189 .output_bandwidth = INPUT_OUTPUT_128K_RATE,
190 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
191 .company_id = 0x0000,
192 .vendor_specific_codec_id = 0x0000},
193 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
194 .company_id = 0x0000,
195 .vendor_specific_codec_id = 0x0000},
196 .input_coded_data_size = 16,
197 .output_coded_data_size = 16,
198 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
199 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
200 .input_pcm_payload_msb_position = 0,
201 .output_pcm_payload_msb_position = 0,
202 .input_data_path = ESCO_DATA_PATH_PCM,
203 .output_data_path = ESCO_DATA_PATH_PCM,
204 .input_transport_unit_size = 0x00,
205 .output_transport_unit_size = 0x00,
206 .max_latency_ms = 13,
207 .packet_types =
208 (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
209 ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5),
210 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
211 },
212 // LC3 T1
213 {
214 .transmit_bandwidth = TXRX_64KBITS_RATE,
215 .receive_bandwidth = TXRX_64KBITS_RATE,
216 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_LC3,
217 .company_id = 0x0000,
218 .vendor_specific_codec_id = 0x0000},
219 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_LC3,
220 .company_id = 0x0000,
221 .vendor_specific_codec_id = 0x0000},
222 .transmit_codec_frame_size = 60,
223 .receive_codec_frame_size = 60,
224 .input_bandwidth = INPUT_OUTPUT_256K_RATE,
225 .output_bandwidth = INPUT_OUTPUT_256K_RATE,
226 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
227 .company_id = 0x0000,
228 .vendor_specific_codec_id = 0x0000},
229 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
230 .company_id = 0x0000,
231 .vendor_specific_codec_id = 0x0000},
232 .input_coded_data_size = 16,
233 .output_coded_data_size = 16,
234 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
235 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
236 .input_pcm_payload_msb_position = 0,
237 .output_pcm_payload_msb_position = 0,
238 .input_data_path = ESCO_DATA_PATH_PCM,
239 .output_data_path = ESCO_DATA_PATH_PCM,
240 .input_transport_unit_size = 0x00,
241 .output_transport_unit_size = 0x00,
242 .max_latency_ms = 8,
243 .packet_types =
244 (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
245 ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5 |
246 ESCO_PKT_TYPES_MASK_NO_2_EV3),
247 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
248 },
249 // LC3 T2
250 {
251 .transmit_bandwidth = TXRX_64KBITS_RATE,
252 .receive_bandwidth = TXRX_64KBITS_RATE,
253 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_LC3,
254 .company_id = 0x0000,
255 .vendor_specific_codec_id = 0x0000},
256 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_LC3,
257 .company_id = 0x0000,
258 .vendor_specific_codec_id = 0x0000},
259 .transmit_codec_frame_size = 60,
260 .receive_codec_frame_size = 60,
261 .input_bandwidth = INPUT_OUTPUT_256K_RATE,
262 .output_bandwidth = INPUT_OUTPUT_256K_RATE,
263 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
264 .company_id = 0x0000,
265 .vendor_specific_codec_id = 0x0000},
266 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
267 .company_id = 0x0000,
268 .vendor_specific_codec_id = 0x0000},
269 .input_coded_data_size = 16,
270 .output_coded_data_size = 16,
271 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
272 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
273 .input_pcm_payload_msb_position = 0,
274 .output_pcm_payload_msb_position = 0,
275 .input_data_path = ESCO_DATA_PATH_PCM,
276 .output_data_path = ESCO_DATA_PATH_PCM,
277 .input_transport_unit_size = 0x00,
278 .output_transport_unit_size = 0x00,
279 .max_latency_ms = 13,
280 .packet_types =
281 (ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
282 ESCO_PKT_TYPES_MASK_NO_3_EV5),
283 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
284 },
285 };
286
esco_parameters_for_codec(esco_codec_t codec,bool offload)287 enh_esco_params_t esco_parameters_for_codec(esco_codec_t codec, bool offload) {
288 CHECK(codec >= 0) << "codec index " << (int)codec << "< 0";
289 CHECK(codec < ESCO_NUM_CODECS)
290 << "codec index " << (int)codec << " > " << ESCO_NUM_CODECS;
291 if (offload) {
292 return default_esco_parameters[codec];
293 }
294
295 enh_esco_params_t param = default_esco_parameters[codec];
296 param.input_data_path = param.output_data_path = ESCO_DATA_PATH_HCI;
297
298 if (codec >= ESCO_CODEC_MSBC_T1) {
299 param.transmit_coding_format.coding_format = ESCO_CODING_FORMAT_TRANSPNT;
300 param.receive_coding_format.coding_format = ESCO_CODING_FORMAT_TRANSPNT;
301 param.input_coding_format.coding_format = ESCO_CODING_FORMAT_TRANSPNT;
302 param.output_coding_format.coding_format = ESCO_CODING_FORMAT_TRANSPNT;
303 param.input_bandwidth = TXRX_64KBITS_RATE;
304 param.output_bandwidth = TXRX_64KBITS_RATE;
305 }
306
307 return param;
308 }
309