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 static const enh_esco_params_t default_esco_parameters[ESCO_NUM_CODECS] = {
24 // CVSD D1
25 {
26 .transmit_bandwidth = TXRX_64KBITS_RATE,
27 .receive_bandwidth = TXRX_64KBITS_RATE,
28 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
29 .company_id = 0x0000,
30 .vendor_specific_codec_id = 0x0000},
31 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
32 .company_id = 0x0000,
33 .vendor_specific_codec_id = 0x0000},
34 .transmit_codec_frame_size = 60,
35 .receive_codec_frame_size = 60,
36 .input_bandwidth = INPUT_OUTPUT_64K_RATE,
37 .output_bandwidth = INPUT_OUTPUT_64K_RATE,
38 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
39 .company_id = 0x0000,
40 .vendor_specific_codec_id = 0x0000},
41 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
42 .company_id = 0x0000,
43 .vendor_specific_codec_id = 0x0000},
44 .input_coded_data_size = 16,
45 .output_coded_data_size = 16,
46 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
47 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
48 .input_pcm_payload_msb_position = 0,
49 .output_pcm_payload_msb_position = 0,
50 .input_data_path = ESCO_DATA_PATH_PCM,
51 .output_data_path = ESCO_DATA_PATH_PCM,
52 .input_transport_unit_size = 0x00,
53 .output_transport_unit_size = 0x00,
54 .max_latency_ms = 0xFFFF, // Don't care
55 .packet_types = (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
56 ESCO_PKT_TYPES_MASK_HV3),
57 .retransmission_effort = ESCO_RETRANSMISSION_OFF,
58 },
59 // CVSD S3
60 {
61 .transmit_bandwidth = TXRX_64KBITS_RATE,
62 .receive_bandwidth = TXRX_64KBITS_RATE,
63 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
64 .company_id = 0x0000,
65 .vendor_specific_codec_id = 0x0000},
66 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
67 .company_id = 0x0000,
68 .vendor_specific_codec_id = 0x0000},
69 .transmit_codec_frame_size = 60,
70 .receive_codec_frame_size = 60,
71 .input_bandwidth = INPUT_OUTPUT_64K_RATE,
72 .output_bandwidth = INPUT_OUTPUT_64K_RATE,
73 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
74 .company_id = 0x0000,
75 .vendor_specific_codec_id = 0x0000},
76 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
77 .company_id = 0x0000,
78 .vendor_specific_codec_id = 0x0000},
79 .input_coded_data_size = 16,
80 .output_coded_data_size = 16,
81 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
82 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
83 .input_pcm_payload_msb_position = 0,
84 .output_pcm_payload_msb_position = 0,
85 .input_data_path = ESCO_DATA_PATH_PCM,
86 .output_data_path = ESCO_DATA_PATH_PCM,
87 .input_transport_unit_size = 0x00,
88 .output_transport_unit_size = 0x00,
89 .max_latency_ms = 10,
90 .packet_types =
91 (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
92 ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 |
93 ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5 |
94 ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
95 ESCO_PKT_TYPES_MASK_NO_3_EV5),
96 .retransmission_effort = ESCO_RETRANSMISSION_POWER,
97 },
98 // CVSD S4
99 {
100 .transmit_bandwidth = TXRX_64KBITS_RATE,
101 .receive_bandwidth = TXRX_64KBITS_RATE,
102 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
103 .company_id = 0x0000,
104 .vendor_specific_codec_id = 0x0000},
105 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
106 .company_id = 0x0000,
107 .vendor_specific_codec_id = 0x0000},
108 .transmit_codec_frame_size = 60,
109 .receive_codec_frame_size = 60,
110 .input_bandwidth = INPUT_OUTPUT_64K_RATE,
111 .output_bandwidth = INPUT_OUTPUT_64K_RATE,
112 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
113 .company_id = 0x0000,
114 .vendor_specific_codec_id = 0x0000},
115 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
116 .company_id = 0x0000,
117 .vendor_specific_codec_id = 0x0000},
118 .input_coded_data_size = 16,
119 .output_coded_data_size = 16,
120 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
121 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
122 .input_pcm_payload_msb_position = 0,
123 .output_pcm_payload_msb_position = 0,
124 .input_data_path = ESCO_DATA_PATH_PCM,
125 .output_data_path = ESCO_DATA_PATH_PCM,
126 .input_transport_unit_size = 0x00,
127 .output_transport_unit_size = 0x00,
128 .max_latency_ms = 12,
129 .packet_types =
130 (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
131 ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 |
132 ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5 |
133 ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
134 ESCO_PKT_TYPES_MASK_NO_3_EV5),
135 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
136 },
137 // mSBC T1
138 {
139 .transmit_bandwidth = TXRX_64KBITS_RATE,
140 .receive_bandwidth = TXRX_64KBITS_RATE,
141 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
142 .company_id = 0x0000,
143 .vendor_specific_codec_id = 0x0000},
144 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
145 .company_id = 0x0000,
146 .vendor_specific_codec_id = 0x0000},
147 .transmit_codec_frame_size = 60,
148 .receive_codec_frame_size = 60,
149 .input_bandwidth = INPUT_OUTPUT_128K_RATE,
150 .output_bandwidth = INPUT_OUTPUT_128K_RATE,
151 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
152 .company_id = 0x0000,
153 .vendor_specific_codec_id = 0x0000},
154 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
155 .company_id = 0x0000,
156 .vendor_specific_codec_id = 0x0000},
157 .input_coded_data_size = 16,
158 .output_coded_data_size = 16,
159 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
160 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
161 .input_pcm_payload_msb_position = 0,
162 .output_pcm_payload_msb_position = 0,
163 .input_data_path = ESCO_DATA_PATH_PCM,
164 .output_data_path = ESCO_DATA_PATH_PCM,
165 .input_transport_unit_size = 0x00,
166 .output_transport_unit_size = 0x00,
167 .max_latency_ms = 8,
168 .packet_types =
169 (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
170 ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5 |
171 ESCO_PKT_TYPES_MASK_NO_2_EV3),
172 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
173 },
174 // mSBC T2
175 {
176 .transmit_bandwidth = TXRX_64KBITS_RATE,
177 .receive_bandwidth = TXRX_64KBITS_RATE,
178 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
179 .company_id = 0x0000,
180 .vendor_specific_codec_id = 0x0000},
181 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
182 .company_id = 0x0000,
183 .vendor_specific_codec_id = 0x0000},
184 .transmit_codec_frame_size = 60,
185 .receive_codec_frame_size = 60,
186 .input_bandwidth = INPUT_OUTPUT_128K_RATE,
187 .output_bandwidth = INPUT_OUTPUT_128K_RATE,
188 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
189 .company_id = 0x0000,
190 .vendor_specific_codec_id = 0x0000},
191 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
192 .company_id = 0x0000,
193 .vendor_specific_codec_id = 0x0000},
194 .input_coded_data_size = 16,
195 .output_coded_data_size = 16,
196 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
197 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
198 .input_pcm_payload_msb_position = 0,
199 .output_pcm_payload_msb_position = 0,
200 .input_data_path = ESCO_DATA_PATH_PCM,
201 .output_data_path = ESCO_DATA_PATH_PCM,
202 .input_transport_unit_size = 0x00,
203 .output_transport_unit_size = 0x00,
204 .max_latency_ms = 13,
205 .packet_types =
206 (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
207 ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5),
208 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
209 },
210 };
211
esco_parameters_for_codec(esco_codec_t codec)212 enh_esco_params_t esco_parameters_for_codec(esco_codec_t codec) {
213 CHECK(codec >= 0) << "codec index " << (int)codec << "< 0";
214 CHECK(codec < ESCO_NUM_CODECS) << "codec index " << (int)codec << " > "
215 << ESCO_NUM_CODECS;
216 return default_esco_parameters[codec];
217 }
218