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
25 {.transmit_bandwidth = TXRX_64KBITS_RATE,
26 .receive_bandwidth = TXRX_64KBITS_RATE,
27 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
28 .company_id = 0x0000,
29 .vendor_specific_codec_id = 0x0000},
30 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD,
31 .company_id = 0x0000,
32 .vendor_specific_codec_id = 0x0000},
33 .transmit_codec_frame_size = 60,
34 .receive_codec_frame_size = 60,
35 .input_bandwidth = INPUT_OUTPUT_64K_RATE,
36 .output_bandwidth = INPUT_OUTPUT_64K_RATE,
37 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
38 .company_id = 0x0000,
39 .vendor_specific_codec_id = 0x0000},
40 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
41 .company_id = 0x0000,
42 .vendor_specific_codec_id = 0x0000},
43 .input_coded_data_size = 16,
44 .output_coded_data_size = 16,
45 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
46 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
47 .input_pcm_payload_msb_position = 0,
48 .output_pcm_payload_msb_position = 0,
49 .input_data_path = ESCO_DATA_PATH_PCM,
50 .output_data_path = ESCO_DATA_PATH_PCM,
51 .input_transport_unit_size = 0x00,
52 .output_transport_unit_size = 0x00,
53 #if (BTA_HFP_VERSION >= HFP_VERSION_1_7)
54 .max_latency_ms = 12,
55 #else
56 .max_latency_ms = 10,
57 #endif
58
59 .packet_types =
60 (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 |
61 ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 |
62 ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5 |
63 ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 |
64 ESCO_PKT_TYPES_MASK_NO_3_EV5),
65 #if (BTA_HFP_VERSION >= HFP_VERSION_1_7)
66 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY
67 #else
68 .retransmission_effort = ESCO_RETRANSMISSION_POWER
69 #endif
70
71 },
72 // mSBC T1
73 {.transmit_bandwidth = TXRX_64KBITS_RATE,
74 .receive_bandwidth = TXRX_64KBITS_RATE,
75 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
76 .company_id = 0x0000,
77 .vendor_specific_codec_id = 0x0000},
78 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
79 .company_id = 0x0000,
80 .vendor_specific_codec_id = 0x0000},
81 .transmit_codec_frame_size = 60,
82 .receive_codec_frame_size = 60,
83 .input_bandwidth = INPUT_OUTPUT_128K_RATE,
84 .output_bandwidth = INPUT_OUTPUT_128K_RATE,
85 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
86 .company_id = 0x0000,
87 .vendor_specific_codec_id = 0x0000},
88 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
89 .company_id = 0x0000,
90 .vendor_specific_codec_id = 0x0000},
91 .input_coded_data_size = 16,
92 .output_coded_data_size = 16,
93 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
94 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
95 .input_pcm_payload_msb_position = 0,
96 .output_pcm_payload_msb_position = 0,
97 .input_data_path = ESCO_DATA_PATH_PCM,
98 .output_data_path = ESCO_DATA_PATH_PCM,
99 .input_transport_unit_size = 0x00,
100 .output_transport_unit_size = 0x00,
101 .max_latency_ms = 8,
102 .packet_types =
103 (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
104 ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5 |
105 ESCO_PKT_TYPES_MASK_NO_2_EV3),
106 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY},
107 // mSBC T2
108 {.transmit_bandwidth = TXRX_64KBITS_RATE,
109 .receive_bandwidth = TXRX_64KBITS_RATE,
110 .transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
111 .company_id = 0x0000,
112 .vendor_specific_codec_id = 0x0000},
113 .receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC,
114 .company_id = 0x0000,
115 .vendor_specific_codec_id = 0x0000},
116 .transmit_codec_frame_size = 60,
117 .receive_codec_frame_size = 60,
118 .input_bandwidth = INPUT_OUTPUT_128K_RATE,
119 .output_bandwidth = INPUT_OUTPUT_128K_RATE,
120 .input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
121 .company_id = 0x0000,
122 .vendor_specific_codec_id = 0x0000},
123 .output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR,
124 .company_id = 0x0000,
125 .vendor_specific_codec_id = 0x0000},
126 .input_coded_data_size = 16,
127 .output_coded_data_size = 16,
128 .input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
129 .output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP,
130 .input_pcm_payload_msb_position = 0,
131 .output_pcm_payload_msb_position = 0,
132 .input_data_path = ESCO_DATA_PATH_PCM,
133 .output_data_path = ESCO_DATA_PATH_PCM,
134 .input_transport_unit_size = 0x00,
135 .output_transport_unit_size = 0x00,
136 .max_latency_ms = 13,
137 .packet_types =
138 (ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 |
139 ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5),
140 .retransmission_effort = ESCO_RETRANSMISSION_QUALITY}};
141
esco_parameters_for_codec(esco_codec_t codec)142 enh_esco_params_t esco_parameters_for_codec(esco_codec_t codec) {
143 CHECK(codec >= 0) << "codec index " << (int)codec << "< 0";
144 CHECK(codec < ESCO_NUM_CODECS) << "codec index " << (int)codec << " > "
145 << ESCO_NUM_CODECS;
146 return default_esco_parameters[codec];
147 }
148