• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "device/include/esco_parameters.h"
20 
21 #include <bluetooth/log.h>
22 #include <com_android_bluetooth_flags.h>
23 
24 #include "hci/controller_interface.h"
25 #include "main/shim/entry.h"
26 
27 using namespace bluetooth;
28 
29 static const enh_esco_params_t default_esco_parameters[ESCO_NUM_CODECS] = {
30     // CVSD D1
31     {
32         .transmit_bandwidth = TXRX_64KBITS_RATE,
33         .receive_bandwidth = TXRX_64KBITS_RATE,
34         .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
35                                    .company_id = 0x0000,
36                                    .vendor_specific_codec_id = 0x0000},
37         .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
38                                   .company_id = 0x0000,
39                                   .vendor_specific_codec_id = 0x0000},
40         .transmit_codec_frame_size = 60,
41         .receive_codec_frame_size = 60,
42         .input_bandwidth = INPUT_OUTPUT_64K_RATE,
43         .output_bandwidth = INPUT_OUTPUT_64K_RATE,
44         .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
45                                 .company_id = 0x0000,
46                                 .vendor_specific_codec_id = 0x0000},
47         .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
48                                  .company_id = 0x0000,
49                                  .vendor_specific_codec_id = 0x0000},
50         .input_coded_data_size = 16,
51         .output_coded_data_size = 16,
52         .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
53         .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
54         .input_pcm_payload_msb_position = 0,
55         .output_pcm_payload_msb_position = 0,
56         .input_data_path = ESCO_DATA_PATH_PCM,
57         .output_data_path = ESCO_DATA_PATH_PCM,
58         .input_transport_unit_size = 0x00,
59         .output_transport_unit_size = 0x00,
60         .max_latency_ms = 0xFFFF,  // Don't care
61         .packet_types = (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
62                          ESCO_PKT_TYPES_MASK_HV3),
63         .retransmission_effort = ESCO_RETRANSMISSION_OFF,
64         .coding_format = ESCO_CODING_FORMAT_CVSD,
65     },  // CVSD S1
66     {
67         .transmit_bandwidth = TXRX_64KBITS_RATE,
68         .receive_bandwidth = TXRX_64KBITS_RATE,
69         .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
70                                    .company_id = 0x0000,
71                                    .vendor_specific_codec_id = 0x0000},
72         .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
73                                   .company_id = 0x0000,
74                                   .vendor_specific_codec_id = 0x0000},
75         .transmit_codec_frame_size = 60,
76         .receive_codec_frame_size = 60,
77         .input_bandwidth = INPUT_OUTPUT_64K_RATE,
78         .output_bandwidth = INPUT_OUTPUT_64K_RATE,
79         .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
80                                 .company_id = 0x0000,
81                                 .vendor_specific_codec_id = 0x0000},
82         .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
83                                  .company_id = 0x0000,
84                                  .vendor_specific_codec_id = 0x0000},
85         .input_coded_data_size = 16,
86         .output_coded_data_size = 16,
87         .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
88         .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
89         .input_pcm_payload_msb_position = 0,
90         .output_pcm_payload_msb_position = 0,
91         .input_data_path = ESCO_DATA_PATH_PCM,
92         .output_data_path = ESCO_DATA_PATH_PCM,
93         .input_transport_unit_size = 0x00,
94         .output_transport_unit_size = 0x00,
95         .max_latency_ms = 7,
96         .packet_types =
97             (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
98              ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 |
99              ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5 |
100              ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
101              ESCO_PKT_TYPES_MASK_NO_3_EV5),
102         .retransmission_effort = ESCO_RETRANSMISSION_POWER,
103         .coding_format = ESCO_CODING_FORMAT_CVSD,
104     },
105     // CVSD S3
106     {
107         .transmit_bandwidth = TXRX_64KBITS_RATE,
108         .receive_bandwidth = TXRX_64KBITS_RATE,
109         .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
110                                    .company_id = 0x0000,
111                                    .vendor_specific_codec_id = 0x0000},
112         .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
113                                   .company_id = 0x0000,
114                                   .vendor_specific_codec_id = 0x0000},
115         .transmit_codec_frame_size = 60,
116         .receive_codec_frame_size = 60,
117         .input_bandwidth = INPUT_OUTPUT_64K_RATE,
118         .output_bandwidth = INPUT_OUTPUT_64K_RATE,
119         .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
120                                 .company_id = 0x0000,
121                                 .vendor_specific_codec_id = 0x0000},
122         .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
123                                  .company_id = 0x0000,
124                                  .vendor_specific_codec_id = 0x0000},
125         .input_coded_data_size = 16,
126         .output_coded_data_size = 16,
127         .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
128         .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
129         .input_pcm_payload_msb_position = 0,
130         .output_pcm_payload_msb_position = 0,
131         .input_data_path = ESCO_DATA_PATH_PCM,
132         .output_data_path = ESCO_DATA_PATH_PCM,
133         .input_transport_unit_size = 0x00,
134         .output_transport_unit_size = 0x00,
135         .max_latency_ms = 10,
136         .packet_types =
137             (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
138              ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 |
139              ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5 |
140              ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
141              ESCO_PKT_TYPES_MASK_NO_3_EV5),
142         .retransmission_effort = ESCO_RETRANSMISSION_POWER,
143         .coding_format = ESCO_CODING_FORMAT_CVSD,
144     },
145     // CVSD S4
146     {
147         .transmit_bandwidth = TXRX_64KBITS_RATE,
148         .receive_bandwidth = TXRX_64KBITS_RATE,
149         .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
150                                    .company_id = 0x0000,
151                                    .vendor_specific_codec_id = 0x0000},
152         .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
153                                   .company_id = 0x0000,
154                                   .vendor_specific_codec_id = 0x0000},
155         .transmit_codec_frame_size = 60,
156         .receive_codec_frame_size = 60,
157         .input_bandwidth = INPUT_OUTPUT_64K_RATE,
158         .output_bandwidth = INPUT_OUTPUT_64K_RATE,
159         .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
160                                 .company_id = 0x0000,
161                                 .vendor_specific_codec_id = 0x0000},
162         .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
163                                  .company_id = 0x0000,
164                                  .vendor_specific_codec_id = 0x0000},
165         .input_coded_data_size = 16,
166         .output_coded_data_size = 16,
167         .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
168         .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
169         .input_pcm_payload_msb_position = 0,
170         .output_pcm_payload_msb_position = 0,
171         .input_data_path = ESCO_DATA_PATH_PCM,
172         .output_data_path = ESCO_DATA_PATH_PCM,
173         .input_transport_unit_size = 0x00,
174         .output_transport_unit_size = 0x00,
175         .max_latency_ms = 12,
176         .packet_types =
177             (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
178              ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 |
179              ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5 |
180              ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
181              ESCO_PKT_TYPES_MASK_NO_3_EV5),
182         .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
183         .coding_format = ESCO_CODING_FORMAT_CVSD,
184     },
185     // mSBC T1
186     {
187         .transmit_bandwidth = TXRX_64KBITS_RATE,
188         .receive_bandwidth = TXRX_64KBITS_RATE,
189         .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
190                                    .company_id = 0x0000,
191                                    .vendor_specific_codec_id = 0x0000},
192         .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
193                                   .company_id = 0x0000,
194                                   .vendor_specific_codec_id = 0x0000},
195         .transmit_codec_frame_size = 60,
196         .receive_codec_frame_size = 60,
197         .input_bandwidth = INPUT_OUTPUT_128K_RATE,
198         .output_bandwidth = INPUT_OUTPUT_128K_RATE,
199         .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
200                                 .company_id = 0x0000,
201                                 .vendor_specific_codec_id = 0x0000},
202         .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
203                                  .company_id = 0x0000,
204                                  .vendor_specific_codec_id = 0x0000},
205         .input_coded_data_size = 16,
206         .output_coded_data_size = 16,
207         .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
208         .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
209         .input_pcm_payload_msb_position = 0,
210         .output_pcm_payload_msb_position = 0,
211         .input_data_path = ESCO_DATA_PATH_PCM,
212         .output_data_path = ESCO_DATA_PATH_PCM,
213         .input_transport_unit_size = 0x00,
214         .output_transport_unit_size = 0x00,
215         .max_latency_ms = 8,
216         .packet_types =
217             (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
218              ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5 |
219              ESCO_PKT_TYPES_MASK_NO_2_EV3),
220         .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
221         .coding_format = ESCO_CODING_FORMAT_MSBC,
222     },
223     // mSBC T2
224     {
225         .transmit_bandwidth = TXRX_64KBITS_RATE,
226         .receive_bandwidth = TXRX_64KBITS_RATE,
227         .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
228                                    .company_id = 0x0000,
229                                    .vendor_specific_codec_id = 0x0000},
230         .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
231                                   .company_id = 0x0000,
232                                   .vendor_specific_codec_id = 0x0000},
233         .transmit_codec_frame_size = 60,
234         .receive_codec_frame_size = 60,
235         .input_bandwidth = INPUT_OUTPUT_128K_RATE,
236         .output_bandwidth = INPUT_OUTPUT_128K_RATE,
237         .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
238                                 .company_id = 0x0000,
239                                 .vendor_specific_codec_id = 0x0000},
240         .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
241                                  .company_id = 0x0000,
242                                  .vendor_specific_codec_id = 0x0000},
243         .input_coded_data_size = 16,
244         .output_coded_data_size = 16,
245         .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
246         .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
247         .input_pcm_payload_msb_position = 0,
248         .output_pcm_payload_msb_position = 0,
249         .input_data_path = ESCO_DATA_PATH_PCM,
250         .output_data_path = ESCO_DATA_PATH_PCM,
251         .input_transport_unit_size = 0x00,
252         .output_transport_unit_size = 0x00,
253         .max_latency_ms = 13,
254         .packet_types =
255             (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
256              ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5),
257         .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
258         .coding_format = ESCO_CODING_FORMAT_MSBC,
259     },
260     // LC3 T1
261     {
262         .transmit_bandwidth = TXRX_64KBITS_RATE,
263         .receive_bandwidth = TXRX_64KBITS_RATE,
264         .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_LC3,
265                                    .company_id = 0x0000,
266                                    .vendor_specific_codec_id = 0x0000},
267         .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_LC3,
268                                   .company_id = 0x0000,
269                                   .vendor_specific_codec_id = 0x0000},
270         .transmit_codec_frame_size = 60,
271         .receive_codec_frame_size = 60,
272         .input_bandwidth = INPUT_OUTPUT_256K_RATE,
273         .output_bandwidth = INPUT_OUTPUT_256K_RATE,
274         .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
275                                 .company_id = 0x0000,
276                                 .vendor_specific_codec_id = 0x0000},
277         .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
278                                  .company_id = 0x0000,
279                                  .vendor_specific_codec_id = 0x0000},
280         .input_coded_data_size = 16,
281         .output_coded_data_size = 16,
282         .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
283         .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
284         .input_pcm_payload_msb_position = 0,
285         .output_pcm_payload_msb_position = 0,
286         .input_data_path = ESCO_DATA_PATH_PCM,
287         .output_data_path = ESCO_DATA_PATH_PCM,
288         .input_transport_unit_size = 0x00,
289         .output_transport_unit_size = 0x00,
290         .max_latency_ms = 8,
291         .packet_types =
292             (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
293              ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5 |
294              ESCO_PKT_TYPES_MASK_NO_2_EV3),
295         .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
296         .coding_format = ESCO_CODING_FORMAT_LC3,
297     },
298     // LC3 T2
299     {
300         .transmit_bandwidth = TXRX_64KBITS_RATE,
301         .receive_bandwidth = TXRX_64KBITS_RATE,
302         .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_LC3,
303                                    .company_id = 0x0000,
304                                    .vendor_specific_codec_id = 0x0000},
305         .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_LC3,
306                                   .company_id = 0x0000,
307                                   .vendor_specific_codec_id = 0x0000},
308         .transmit_codec_frame_size = 60,
309         .receive_codec_frame_size = 60,
310         .input_bandwidth = INPUT_OUTPUT_256K_RATE,
311         .output_bandwidth = INPUT_OUTPUT_256K_RATE,
312         .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
313                                 .company_id = 0x0000,
314                                 .vendor_specific_codec_id = 0x0000},
315         .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
316                                  .company_id = 0x0000,
317                                  .vendor_specific_codec_id = 0x0000},
318         .input_coded_data_size = 16,
319         .output_coded_data_size = 16,
320         .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
321         .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
322         .input_pcm_payload_msb_position = 0,
323         .output_pcm_payload_msb_position = 0,
324         .input_data_path = ESCO_DATA_PATH_PCM,
325         .output_data_path = ESCO_DATA_PATH_PCM,
326         .input_transport_unit_size = 0x00,
327         .output_transport_unit_size = 0x00,
328         .max_latency_ms = 13,
329         .packet_types =
330             (ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
331              ESCO_PKT_TYPES_MASK_NO_3_EV5),
332         .retransmission_effort = ESCO_RETRANSMISSION_QUALITY,
333         .coding_format = ESCO_CODING_FORMAT_LC3,
334     },
335     // aptX Voice SWB
336     {.transmit_bandwidth = TXRX_64KBITS_RATE,
337      .receive_bandwidth = TXRX_64KBITS_RATE,
338      .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_VS,
339                                 .company_id = 0x000A,
340                                 .vendor_specific_codec_id = 0x0000},
341      .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_VS,
342                                .company_id = 0x000A,
343                                .vendor_specific_codec_id = 0x0000},
344      .transmit_codec_frame_size = 60,
345      .receive_codec_frame_size = 60,
346      .input_bandwidth = INPUT_OUTPUT_128K_RATE,
347      .output_bandwidth = INPUT_OUTPUT_128K_RATE,
348      .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
349                              .company_id = 0x0000,
350                              .vendor_specific_codec_id = 0x0000},
351      .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
352                               .company_id = 0x0000,
353                               .vendor_specific_codec_id = 0x0000},
354      .input_coded_data_size = 16,
355      .output_coded_data_size = 16,
356      .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
357      .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
358      .input_pcm_payload_msb_position = 0,
359      .output_pcm_payload_msb_position = 0,
360      .input_data_path = ESCO_DATA_PATH_PCM,
361      .output_data_path = ESCO_DATA_PATH_PCM,
362      .input_transport_unit_size = 0x00,
363      .output_transport_unit_size = 0x00,
364      .max_latency_ms = 14,
365      .packet_types = 0x0380,
366      .retransmission_effort = ESCO_RETRANSMISSION_QUALITY}};
367 
esco_parameters_for_codec(esco_codec_t codec,bool offload)368 enh_esco_params_t esco_parameters_for_codec(esco_codec_t codec, bool offload) {
369   log::assert_that((int)codec >= 0, "codec index {}< 0", (int)codec);
370   log::assert_that(codec < ESCO_NUM_CODECS, "codec index {} > {}", (int)codec,
371                    ESCO_NUM_CODECS);
372 
373   std::vector<uint8_t> codecIds;
374   if (com::android::bluetooth::flags::
375           use_dsp_codec_when_controller_does_not_support()) {
376     auto controller = bluetooth::shim::GetController();
377     if (controller == nullptr) {
378       log::warn("controller is null");
379     } else {
380       codecIds = controller->GetLocalSupportedBrEdrCodecIds();
381       if (std::find(codecIds.begin(), codecIds.end(), ESCO_CODING_FORMAT_LC3) ==
382           codecIds.end()) {
383         if (codec == ESCO_CODEC_LC3_T1 || codec == ESCO_CODEC_LC3_T2) {
384           log::info("BT controller does not support LC3 codec, use DSP codec");
385           enh_esco_params_t param = default_esco_parameters[codec];
386           param.input_coding_format.coding_format = ESCO_CODING_FORMAT_LC3;
387           param.output_coding_format.coding_format = ESCO_CODING_FORMAT_LC3;
388           param.input_bandwidth = TXRX_64KBITS_RATE;
389           param.output_bandwidth = TXRX_64KBITS_RATE;
390           return param;
391         }
392       }
393     }
394   }
395 
396   if (offload) {
397     if (codec == ESCO_CODEC_SWB_Q0 || codec == ESCO_CODEC_SWB_Q1 ||
398         codec == ESCO_CODEC_SWB_Q2 || codec == ESCO_CODEC_SWB_Q3) {
399       return default_esco_parameters[ESCO_CODEC_SWB_Q0];
400     }
401     return default_esco_parameters[codec];
402   }
403 
404   log::assert_that(codec < ESCO_LEGACY_NUM_CODECS, "legacy codec index {} > {}",
405                    (int)codec, ESCO_LEGACY_NUM_CODECS);
406   enh_esco_params_t param = default_esco_parameters[codec];
407   param.input_data_path = param.output_data_path = ESCO_DATA_PATH_HCI;
408 
409   if (codec >= ESCO_CODEC_MSBC_T1) {
410     param.transmit_coding_format.coding_format = ESCO_CODING_FORMAT_TRANSPNT;
411     param.receive_coding_format.coding_format = ESCO_CODING_FORMAT_TRANSPNT;
412     param.input_coding_format.coding_format = ESCO_CODING_FORMAT_TRANSPNT;
413     param.output_coding_format.coding_format = ESCO_CODING_FORMAT_TRANSPNT;
414     param.input_bandwidth = TXRX_64KBITS_RATE;
415     param.output_bandwidth = TXRX_64KBITS_RATE;
416   }
417 
418   if (com::android::bluetooth::flags::fix_hfp_qual_1_9()) {
419     esco_packet_types_t new_packet_types = param.packet_types;
420     if (codec == ESCO_CODEC_CVSD_S3 || codec == ESCO_CODEC_CVSD_S4 ||
421         codec == ESCO_CODEC_MSBC_T2 || codec == ESCO_CODEC_LC3_T2) {
422       new_packet_types =
423           (ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
424            ESCO_PKT_TYPES_MASK_NO_3_EV5);
425     } else if (codec == ESCO_CODEC_CVSD_S1) {
426       new_packet_types =
427           (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_EV4 |
428            ESCO_PKT_TYPES_MASK_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
429            ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5);
430     }
431 
432     if (param.packet_types != new_packet_types) {
433       log::info(
434           "Applying restricted packet types for codec {}: 0x{:04x} -> 0x{:04x}",
435           (int)codec, param.packet_types, new_packet_types);
436       param.packet_types = new_packet_types;
437     }
438   }
439 
440   return param;
441 }
442