system/bt
Revision | a43e1304c2cbca16d583e08b63cb4c95a37b7b87 (tree) |
---|---|
Zeit | 2017-05-24 05:24:50 |
Autor | Jack He <siyuanh@goog...> |
Commiter | Jack He |
eSCO: Format changes to original vendor patch (4/5)
* Format changes to original vendor patch
* Re-order part of SCO creation code to improve readability
* Make log more concise and usefull
Bug: 19540029
Test: make, HFP PTS test, testplans/86884, testplans/87103
Change-Id: Ie0199519afb30f56568c04fef728fce44a172063
(cherry picked from commit fe695a557a92053d4c44428ba08c0b8e945d4711)
@@ -828,15 +828,14 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type, | ||
828 | 828 | tBTA_AG_SCB* ag_scb; |
829 | 829 | uint32_t i, ind_id; |
830 | 830 | uint32_t bia_masked_out; |
831 | - tBTA_AG_PEER_CODEC codec_type, codec_sent; | |
832 | 831 | if (p_arg == NULL) { |
833 | 832 | APPL_TRACE_ERROR("%s: p_arg is null, send error and return", __func__); |
834 | 833 | bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_TSTR); |
835 | 834 | return; |
836 | 835 | } |
837 | 836 | |
838 | - APPL_TRACE_DEBUG("HFP AT cmd:%d arg_type:%d arg:%d arg:%s", cmd, arg_type, | |
839 | - int_arg, p_arg); | |
837 | + APPL_TRACE_DEBUG("%s: AT command %d, arg_type %d, int_arg %d, arg %s", | |
838 | + __func__, cmd, arg_type, int_arg, p_arg); | |
840 | 839 | |
841 | 840 | memset(&val, 0, sizeof(tBTA_AG_VAL)); |
842 | 841 | val.hdr.handle = bta_ag_scb_to_idx(p_scb); |
@@ -1204,7 +1203,8 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type, | ||
1204 | 1203 | } |
1205 | 1204 | break; |
1206 | 1205 | |
1207 | - case BTA_AG_AT_BCS_EVT: | |
1206 | + case BTA_AG_AT_BCS_EVT: { | |
1207 | + tBTA_AG_PEER_CODEC codec_type, codec_sent; | |
1208 | 1208 | bta_ag_send_ok(p_scb); |
1209 | 1209 | alarm_cancel(p_scb->codec_negotiation_timer); |
1210 | 1210 |
@@ -1234,7 +1234,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type, | ||
1234 | 1234 | /* send final codec info to callback */ |
1235 | 1235 | val.num = codec_sent; |
1236 | 1236 | break; |
1237 | - | |
1237 | + } | |
1238 | 1238 | case BTA_AG_LOCAL_EVT_BCC: |
1239 | 1239 | bta_ag_send_ok(p_scb); |
1240 | 1240 | bta_ag_sco_open(p_scb, NULL); |
@@ -217,7 +217,7 @@ static void bta_ag_sco_disc_cback(uint16_t sco_idx) { | ||
217 | 217 | static void bta_ag_sco_read_cback(uint16_t sco_inx, BT_HDR* p_data, |
218 | 218 | tBTM_SCO_DATA_FLAG status) { |
219 | 219 | if (status != BTM_SCO_DATA_CORRECT) { |
220 | - APPL_TRACE_DEBUG("bta_ag_sco_read_cback: status(%d)", status); | |
220 | + APPL_TRACE_DEBUG("%s: status %d", __func__, status); | |
221 | 221 | } |
222 | 222 | |
223 | 223 | /* Callout function must free the data. */ |
@@ -232,33 +232,26 @@ static void bta_ag_sco_read_cback(uint16_t sco_inx, BT_HDR* p_data, | ||
232 | 232 | * If only_active is true, then SCO is only removed if |
233 | 233 | * connected |
234 | 234 | * |
235 | - * Returns bool - true if Sco removal was started | |
235 | + * Returns bool - true if SCO removal was started | |
236 | 236 | * |
237 | 237 | ******************************************************************************/ |
238 | 238 | static bool bta_ag_remove_sco(tBTA_AG_SCB* p_scb, bool only_active) { |
239 | - bool removed_started = false; | |
240 | - tBTM_STATUS status; | |
241 | - | |
242 | 239 | if (p_scb->sco_idx != BTM_INVALID_SCO_INDEX) { |
243 | 240 | if (!only_active || p_scb->sco_idx == bta_ag_cb.sco.cur_idx) { |
244 | - status = BTM_RemoveSco(p_scb->sco_idx); | |
245 | - | |
246 | - APPL_TRACE_DEBUG("%s: inx 0x%04x, status:0x%x", __func__, p_scb->sco_idx, | |
247 | - status); | |
248 | - | |
241 | + tBTM_STATUS status = BTM_RemoveSco(p_scb->sco_idx); | |
242 | + APPL_TRACE_DEBUG("%s: SCO index 0x%04x, status %d", __func__, | |
243 | + p_scb->sco_idx, status); | |
249 | 244 | if (status == BTM_CMD_STARTED) { |
250 | - /* Sco is connected; set current control block */ | |
245 | + /* SCO is connected; set current control block */ | |
251 | 246 | bta_ag_cb.sco.p_curr_scb = p_scb; |
252 | - | |
253 | - removed_started = true; | |
254 | - } | |
255 | - /* If no connection reset the sco handle */ | |
256 | - else if ((status == BTM_SUCCESS) || (status == BTM_UNKNOWN_ADDR)) { | |
247 | + return true; | |
248 | + } else if ((status == BTM_SUCCESS) || (status == BTM_UNKNOWN_ADDR)) { | |
249 | + /* If no connection reset the SCO handle */ | |
257 | 250 | p_scb->sco_idx = BTM_INVALID_SCO_INDEX; |
258 | 251 | } |
259 | 252 | } |
260 | 253 | } |
261 | - return removed_started; | |
254 | + return false; | |
262 | 255 | } |
263 | 256 | |
264 | 257 | /******************************************************************************* |
@@ -292,8 +285,8 @@ static void bta_ag_esco_connreq_cback(tBTM_ESCO_EVT event, | ||
292 | 285 | bta_ag_cb.sco.state = BTA_AG_SCO_OPENING_ST; |
293 | 286 | bta_ag_cb.sco.p_curr_scb = p_scb; |
294 | 287 | bta_ag_cb.sco.cur_idx = p_scb->sco_idx; |
295 | - } else /* Begin a transfer: Close current SCO before responding */ | |
296 | - { | |
288 | + } else { | |
289 | + /* Begin a transfer: Close current SCO before responding */ | |
297 | 290 | APPL_TRACE_DEBUG("bta_ag_esco_connreq_cback: Begin XFER"); |
298 | 291 | bta_ag_cb.sco.p_xfer_scb = p_scb; |
299 | 292 | bta_ag_cb.sco.conn_data = p_data->conn_evt; |
@@ -309,17 +302,15 @@ static void bta_ag_esco_connreq_cback(tBTM_ESCO_EVT event, | ||
309 | 302 | bta_ag_sco_conn_rsp(p_scb, &p_data->conn_evt); |
310 | 303 | } |
311 | 304 | } |
312 | - } | |
313 | - /* If error occurred send reject response immediately */ | |
314 | - else { | |
305 | + } else { | |
306 | + /* If error occurred send reject response immediately */ | |
315 | 307 | APPL_TRACE_WARNING( |
316 | 308 | "no scb for bta_ag_esco_connreq_cback or no resources"); |
317 | 309 | BTM_EScoConnRsp(p_data->conn_evt.sco_inx, HCI_ERR_HOST_REJECT_RESOURCES, |
318 | 310 | (enh_esco_params_t*)NULL); |
319 | 311 | } |
320 | - } | |
321 | - /* Received a change in the esco link */ | |
322 | - else if (event == BTM_ESCO_CHG_EVT) { | |
312 | + } else if (event == BTM_ESCO_CHG_EVT) { | |
313 | + /* Received a change in the esco link */ | |
323 | 314 | APPL_TRACE_EVENT( |
324 | 315 | "%s: eSCO change event (inx %d): rtrans %d, " |
325 | 316 | "rxlen %d, txlen %d, txint %d", |
@@ -565,6 +556,7 @@ bool bta_ag_attempt_msbc_safe_settings(tBTA_AG_SCB* p_scb) { | ||
565 | 556 | * |
566 | 557 | ******************************************************************************/ |
567 | 558 | static void bta_ag_codec_negotiation_timer_cback(void* data) { |
559 | + APPL_TRACE_DEBUG("%s", __func__); | |
568 | 560 | tBTA_AG_SCB* p_scb = (tBTA_AG_SCB*)data; |
569 | 561 | |
570 | 562 | /* Announce that codec negotiation failed. */ |
@@ -585,11 +577,12 @@ static void bta_ag_codec_negotiation_timer_cback(void* data) { | ||
585 | 577 | * |
586 | 578 | ******************************************************************************/ |
587 | 579 | void bta_ag_codec_negotiate(tBTA_AG_SCB* p_scb) { |
580 | + APPL_TRACE_DEBUG("%s", __func__); | |
588 | 581 | bta_ag_cb.sco.p_curr_scb = p_scb; |
589 | 582 | |
590 | 583 | if ((p_scb->codec_updated || p_scb->codec_fallback) && |
591 | 584 | (p_scb->peer_features & BTA_AG_PEER_FEAT_CODEC)) { |
592 | - /* Change the power mode to Active until sco open is completed. */ | |
585 | + /* Change the power mode to Active until SCO open is completed. */ | |
593 | 586 | bta_sys_busy(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr); |
594 | 587 | |
595 | 588 | /* Send +BCS to the peer */ |
@@ -624,20 +617,19 @@ static void bta_ag_sco_event(tBTA_AG_SCB* p_scb, uint8_t event) { | ||
624 | 617 | BT_HDR* p_buf; |
625 | 618 | #endif |
626 | 619 | |
627 | -#if BTA_AG_SCO_DEBUG == TRUE | |
620 | +#if (BTA_AG_SCO_DEBUG == TRUE) | |
628 | 621 | uint8_t in_state = p_sco->state; |
629 | 622 | |
630 | 623 | if (event != BTA_AG_SCO_CI_DATA_E) { |
631 | - APPL_TRACE_EVENT( | |
632 | - "%s: BTA ag sco evt (hdl 0x%04x): State %d (%s), Event %d (%s)", | |
633 | - __func__, p_scb->sco_idx, p_sco->state, | |
634 | - bta_ag_sco_state_str(p_sco->state), event, bta_ag_sco_evt_str(event)); | |
624 | + APPL_TRACE_EVENT("%s: SCO Index 0x%04x, State %d (%s), Event %d (%s)", | |
625 | + __func__, p_scb->sco_idx, p_sco->state, | |
626 | + bta_ag_sco_state_str(p_sco->state), event, | |
627 | + bta_ag_sco_evt_str(event)); | |
635 | 628 | } |
636 | 629 | #else |
637 | - | |
638 | 630 | if (event != BTA_AG_SCO_CI_DATA_E) { |
639 | - APPL_TRACE_EVENT("%s: BTA ag sco evt (hdl 0x%04x): State %d, Event %d", | |
640 | - __func__, p_scb->sco_idx, p_sco->state, event); | |
631 | + APPL_TRACE_EVENT("%s: SCO Index 0x%04x, State %d, Event %d", __func__, | |
632 | + p_scb->sco_idx, p_sco->state, event); | |
641 | 633 | } |
642 | 634 | #endif |
643 | 635 |
@@ -1246,12 +1238,16 @@ void bta_ag_sco_close(tBTA_AG_SCB* p_scb, UNUSED_ATTR tBTA_AG_DATA* p_data) { | ||
1246 | 1238 | ******************************************************************************/ |
1247 | 1239 | void bta_ag_sco_codec_nego(tBTA_AG_SCB* p_scb, bool result) { |
1248 | 1240 | if (result == true) { |
1249 | - /* Subsequent sco connection will skip codec negotiation */ | |
1241 | + /* Subsequent SCO connection will skip codec negotiation */ | |
1242 | + APPL_TRACE_DEBUG("%s: Succeeded for index 0x%04x", __func__, | |
1243 | + p_scb->sco_idx); | |
1250 | 1244 | p_scb->codec_updated = false; |
1251 | - | |
1252 | 1245 | bta_ag_sco_event(p_scb, BTA_AG_SCO_CN_DONE_E); |
1253 | - } else /* codec negotiation failed */ | |
1246 | + } else { | |
1247 | + /* codec negotiation failed */ | |
1248 | + APPL_TRACE_ERROR("%s: Failed for index 0x%04x", __func__, p_scb->sco_idx); | |
1254 | 1249 | bta_ag_sco_event(p_scb, BTA_AG_SCO_CLOSE_E); |
1250 | + } | |
1255 | 1251 | } |
1256 | 1252 | |
1257 | 1253 | /******************************************************************************* |
@@ -3920,11 +3920,11 @@ bool bta_dm_check_if_only_hd_connected(BD_ADDR peer_addr) { | ||
3920 | 3920 | !bdcmp(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr, peer_addr)) { |
3921 | 3921 | APPL_TRACE_DEBUG("%s: Another profile (id=%d) is connected", __func__, |
3922 | 3922 | bta_dm_conn_srvcs.conn_srvc[j].id); |
3923 | - return FALSE; | |
3923 | + return false; | |
3924 | 3924 | } |
3925 | 3925 | } |
3926 | 3926 | |
3927 | - return TRUE; | |
3927 | + return true; | |
3928 | 3928 | } |
3929 | 3929 | |
3930 | 3930 | /******************************************************************************* |
@@ -222,7 +222,6 @@ static void bta_hf_client_sco_create(tBTA_HF_CLIENT_CB* client_cb, | ||
222 | 222 | bool is_orig) { |
223 | 223 | tBTM_STATUS status; |
224 | 224 | uint8_t* p_bd_addr = NULL; |
225 | - enh_esco_params_t params; | |
226 | 225 | |
227 | 226 | APPL_TRACE_DEBUG("%s: %d", __func__, is_orig); |
228 | 227 |
@@ -233,7 +232,7 @@ static void bta_hf_client_sco_create(tBTA_HF_CLIENT_CB* client_cb, | ||
233 | 232 | return; |
234 | 233 | } |
235 | 234 | |
236 | - params = esco_parameters_for_codec(ESCO_CODEC_MSBC_T1); | |
235 | + enh_esco_params_t params = esco_parameters_for_codec(ESCO_CODEC_MSBC_T1); | |
237 | 236 | |
238 | 237 | /* if initiating set current scb and peer bd addr */ |
239 | 238 | if (is_orig) { |
@@ -462,7 +462,7 @@ void bta_sys_event(BT_HDR* p_msg) { | ||
462 | 462 | uint8_t id; |
463 | 463 | bool freebuf = true; |
464 | 464 | |
465 | - APPL_TRACE_EVENT("BTA got event 0x%x", p_msg->event); | |
465 | + APPL_TRACE_EVENT("%s: Event 0x%x", __func__, p_msg->event); | |
466 | 466 | |
467 | 467 | /* get subsystem id from event */ |
468 | 468 | id = (uint8_t)(p_msg->event >> 8); |
@@ -471,7 +471,7 @@ void bta_sys_event(BT_HDR* p_msg) { | ||
471 | 471 | if ((id < BTA_ID_MAX) && (bta_sys_cb.reg[id] != NULL)) { |
472 | 472 | freebuf = (*bta_sys_cb.reg[id]->evt_hdlr)(p_msg); |
473 | 473 | } else { |
474 | - APPL_TRACE_WARNING("BTA got unregistered event id %d", id); | |
474 | + APPL_TRACE_WARNING("%s: Received unregistered event id %d", __func__, id); | |
475 | 475 | } |
476 | 476 | |
477 | 477 | if (freebuf) { |
@@ -547,14 +547,14 @@ static void btif_hf_upstreams_evt(uint16_t event, char* p_param) { | ||
547 | 547 | break; |
548 | 548 | case BTA_AG_AT_BAC_EVT: |
549 | 549 | BTIF_TRACE_DEBUG("AG Bitmap of peer-codecs %d", p_data->val.num); |
550 | - /* If the peer supports mSBC and the BTIF prefferred codec is also mSBC, | |
550 | + /* If the peer supports mSBC and the BTIF preferred codec is also mSBC, | |
551 | 551 | then |
552 | 552 | we should set the BTA AG Codec to mSBC. This would trigger a +BCS to mSBC |
553 | 553 | at the time |
554 | 554 | of SCO connection establishment */ |
555 | 555 | if ((btif_conf_hf_force_wbs == true) && |
556 | 556 | (p_data->val.num & BTA_AG_CODEC_MSBC)) { |
557 | - BTIF_TRACE_EVENT("%s btif_hf override-Preferred Codec to MSBC", | |
557 | + BTIF_TRACE_EVENT("%s: btif_hf override-Preferred Codec to MSBC", | |
558 | 558 | __func__); |
559 | 559 | BTA_AgSetCodec(btif_hf_cb[idx].handle, BTA_AG_CODEC_MSBC); |
560 | 560 | } else { |
@@ -564,12 +564,13 @@ static void btif_hf_upstreams_evt(uint16_t event, char* p_param) { | ||
564 | 564 | } |
565 | 565 | break; |
566 | 566 | case BTA_AG_AT_BCS_EVT: |
567 | - BTIF_TRACE_DEBUG("AG final seleded codec is %d 1=CVSD 2=MSBC", | |
568 | - p_data->val.num); | |
569 | - /* no BTHF_WBS_NONE case, becuase HF1.6 supported device can send BCS */ | |
567 | + BTIF_TRACE_DEBUG("%s: AG final selected codec is 0x%02x 1=CVSD 2=MSBC", | |
568 | + __func__, p_data->val.num); | |
569 | + /* No BTHF_WBS_NONE case, because HF1.6 supported device can send BCS */ | |
570 | + /* Only CVSD is considered narrow band speech */ | |
570 | 571 | HAL_CBACK( |
571 | 572 | bt_hf_callbacks, wbs_cb, |
572 | - (p_data->val.num == BTA_AG_CODEC_MSBC) ? BTHF_WBS_YES : BTHF_WBS_NO, | |
573 | + (p_data->val.num == BTA_AG_CODEC_CVSD) ? BTHF_WBS_NO : BTHF_WBS_YES, | |
573 | 574 | &btif_hf_cb[idx].connected_bda); |
574 | 575 | break; |
575 | 576 |
@@ -1297,7 +1298,7 @@ static bt_status_t phone_state_change(int num_active, int num_held, | ||
1297 | 1298 | ag_res.audio_handle = BTA_AG_HANDLE_SCO_NO_CHANGE; |
1298 | 1299 | /* Addition call setup with the Active call |
1299 | 1300 | ** CIND response should have been updated. |
1300 | - ** just open SCO conenction. | |
1301 | + ** just open SCO connection. | |
1301 | 1302 | */ |
1302 | 1303 | if (call_setup_state != BTHF_CALL_STATE_IDLE) |
1303 | 1304 | res = BTA_AG_MULTI_CALL_RES; |
@@ -1123,7 +1123,7 @@ bool btif_rc_get_connected_peer(BD_ADDR peer_addr) { | ||
1123 | 1123 | p_dev = get_connected_device(idx); |
1124 | 1124 | if (p_dev != NULL && (p_dev->rc_connected == TRUE)) { |
1125 | 1125 | bdcpy(peer_addr, p_dev->rc_addr); |
1126 | - return TRUE; | |
1126 | + return true; | |
1127 | 1127 | } |
1128 | 1128 | } |
1129 | 1129 | return false; |
@@ -137,7 +137,6 @@ static sco_socket_t* sco_socket_establish_locked(bool is_listening, | ||
137 | 137 | socket_t* socket = NULL; |
138 | 138 | tBTM_STATUS status; |
139 | 139 | enh_esco_params_t params; |
140 | - | |
141 | 140 | if (socketpair(AF_LOCAL, SOCK_STREAM, 0, pair) == -1) { |
142 | 141 | LOG_ERROR(LOG_TAG, "%s unable to allocate socket pair: %s", __func__, |
143 | 142 | strerror(errno)); |
@@ -140,6 +140,8 @@ static const enh_esco_params_t default_esco_parameters[ESCO_NUM_CODECS] = { | ||
140 | 140 | .retransmission_effort = ESCO_RETRANSMISSION_QUALITY}}; |
141 | 141 | |
142 | 142 | enh_esco_params_t esco_parameters_for_codec(esco_codec_t codec) { |
143 | - CHECK(codec >= 0 && codec < ESCO_NUM_CODECS); | |
143 | + CHECK(codec >= 0) << "codec index " << (int)codec << "< 0"; | |
144 | + CHECK(codec < ESCO_NUM_CODECS) << "codec index " << (int)codec << " > " | |
145 | + << ESCO_NUM_CODECS; | |
144 | 146 | return default_esco_parameters[codec]; |
145 | 147 | } |
@@ -134,21 +134,20 @@ static void btm_esco_conn_rsp(uint16_t sco_inx, uint8_t hci_status, BD_ADDR bda, | ||
134 | 134 | p_sco->state = (p_sco->state == SCO_ST_W4_CONN_RSP) ? SCO_ST_LISTENING |
135 | 135 | : SCO_ST_UNUSED; |
136 | 136 | } |
137 | - | |
138 | 137 | if (!btm_cb.sco_cb.esco_supported) { |
139 | 138 | btsnd_hcic_reject_conn(bda, hci_status); |
140 | 139 | } else { |
141 | 140 | btsnd_hcic_reject_esco_conn(bda, hci_status); |
142 | 141 | } |
143 | - } else /* Connection is being accepted */ | |
144 | - { | |
142 | + } else { | |
143 | + /* Connection is being accepted */ | |
145 | 144 | p_sco->state = SCO_ST_CONNECTING; |
146 | 145 | enh_esco_params_t* p_setup = &p_sco->esco.setup; |
147 | 146 | /* If parameters not specified use the default */ |
148 | - if (p_parms) | |
147 | + if (p_parms) { | |
149 | 148 | *p_setup = *p_parms; |
150 | - else /* Use the last setup passed thru BTM_SetEscoMode (or defaults) */ | |
151 | - { | |
149 | + } else { | |
150 | + /* Use the last setup passed thru BTM_SetEscoMode (or defaults) */ | |
152 | 151 | *p_setup = btm_cb.sco_cb.def_esco_parms; |
153 | 152 | } |
154 | 153 |
@@ -185,17 +184,16 @@ static void btm_esco_conn_rsp(uint16_t sco_inx, uint8_t hci_status, BD_ADDR bda, | ||
185 | 184 | btm_cb.sco_cb.sco_route; |
186 | 185 | |
187 | 186 | BTM_TRACE_DEBUG( |
188 | - "%s: txbw 0x%x, rxbw 0x%x, " | |
189 | - "lat 0x%x, retrans 0x%02x, pkt 0x%04x, path %u", | |
187 | + "%s: txbw 0x%x, rxbw 0x%x, lat 0x%x, retrans 0x%02x, " | |
188 | + "pkt 0x%04x, path %u", | |
190 | 189 | __func__, p_setup->transmit_bandwidth, p_setup->receive_bandwidth, |
191 | 190 | p_setup->max_latency_ms, p_setup->retransmission_effort, |
192 | 191 | p_setup->packet_types, p_setup->input_data_path); |
193 | 192 | |
194 | 193 | btsnd_hcic_enhanced_accept_synchronous_connection(bda, p_setup); |
195 | 194 | |
196 | - } else /* Use older command */ | |
197 | - { | |
198 | - /* needed if enhanced HCI cmds not supported */ | |
195 | + } else { | |
196 | + /* Use legacy command if enhanced SCO setup is not supported */ | |
199 | 197 | uint16_t voice_content_format = btm_sco_voice_settings_to_legacy(p_setup); |
200 | 198 | btsnd_hcic_accept_esco_conn( |
201 | 199 | bda, p_setup->transmit_bandwidth, p_setup->receive_bandwidth, |
@@ -402,7 +400,7 @@ static tBTM_STATUS btm_send_connect_request(uint16_t acl_handle, | ||
402 | 400 | if (BTM_BothEndsSupportSecureConnections(p_acl->remote_addr)) { |
403 | 401 | temp_packet_types &= ~(BTM_SCO_PKT_TYPE_MASK); |
404 | 402 | BTM_TRACE_DEBUG("%s: SCO Conn: pkt_types after removing SCO (0x%04x)", |
405 | - __FUNCTION__, temp_packet_types); | |
403 | + __func__, temp_packet_types); | |
406 | 404 | |
407 | 405 | /* Return error if no packet types left */ |
408 | 406 | if (temp_packet_types == 0) { |
@@ -550,7 +548,6 @@ tBTM_STATUS BTM_CreateSco(BD_ADDR remote_bda, bool is_orig, uint16_t pkt_types, | ||
550 | 548 | tSCO_CONN* p = &btm_cb.sco_cb.sco_db[0]; |
551 | 549 | uint16_t xx; |
552 | 550 | uint16_t acl_handle = 0; |
553 | - uint16_t temp_pkt_types; | |
554 | 551 | tACL_CONN* p_acl; |
555 | 552 | |
556 | 553 | #if (BTM_SCO_WAKE_PARKED_LINK == TRUE) |
@@ -563,10 +560,21 @@ tBTM_STATUS BTM_CreateSco(BD_ADDR remote_bda, bool is_orig, uint16_t pkt_types, | ||
563 | 560 | *p_sco_inx = BTM_INVALID_SCO_INDEX; |
564 | 561 | |
565 | 562 | /* If originating, ensure that there is an ACL connection to the BD Address */ |
563 | + | |
566 | 564 | if (is_orig) { |
567 | - if ((!remote_bda) || ((acl_handle = BTM_GetHCIConnHandle( | |
568 | - remote_bda, BT_TRANSPORT_BR_EDR)) == 0xFFFF)) | |
569 | - return (BTM_UNKNOWN_ADDR); | |
565 | + if (!remote_bda) { | |
566 | + BTM_TRACE_ERROR("%s: remote_bda is null", __func__); | |
567 | + return BTM_ILLEGAL_VALUE; | |
568 | + } | |
569 | + acl_handle = BTM_GetHCIConnHandle(remote_bda, BT_TRANSPORT_BR_EDR); | |
570 | + if (acl_handle == 0xFFFF) { | |
571 | + BTM_TRACE_ERROR( | |
572 | + "%s: cannot find ACL handle for remote device " | |
573 | + "%02x:%02x:%02x:%02x:%02x:%02x", | |
574 | + __func__, remote_bda[0], remote_bda[1], remote_bda[2], remote_bda[3], | |
575 | + remote_bda[4], remote_bda[5]); | |
576 | + return BTM_UNKNOWN_ADDR; | |
577 | + } | |
570 | 578 | } |
571 | 579 | |
572 | 580 | if (remote_bda) { |
@@ -575,19 +583,17 @@ tBTM_STATUS BTM_CreateSco(BD_ADDR remote_bda, bool is_orig, uint16_t pkt_types, | ||
575 | 583 | if (((p->state == SCO_ST_CONNECTING) || (p->state == SCO_ST_LISTENING) || |
576 | 584 | (p->state == SCO_ST_PEND_UNPARK)) && |
577 | 585 | (!memcmp(p->esco.data.bd_addr, remote_bda, BD_ADDR_LEN))) { |
578 | - return (BTM_BUSY); | |
586 | + return BTM_BUSY; | |
579 | 587 | } |
580 | 588 | } |
581 | 589 | } else { |
582 | 590 | /* Support only 1 wildcard BD address at a time */ |
583 | 591 | for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) { |
584 | - if ((p->state == SCO_ST_LISTENING) && (!p->rem_bd_known)) | |
585 | - return (BTM_BUSY); | |
592 | + if ((p->state == SCO_ST_LISTENING) && (!p->rem_bd_known)) return BTM_BUSY; | |
586 | 593 | } |
587 | 594 | } |
588 | 595 | |
589 | - /* Now, try to find an unused control block, and kick off the SCO | |
590 | - * establishment */ | |
596 | + /* Try to find an unused control block, and kick off the SCO establishment */ | |
591 | 597 | for (xx = 0, p = &btm_cb.sco_cb.sco_db[0]; xx < BTM_MAX_SCO_LINKS; |
592 | 598 | xx++, p++) { |
593 | 599 | if (p->state == SCO_ST_UNUSED) { |
@@ -620,21 +626,18 @@ tBTM_STATUS BTM_CreateSco(BD_ADDR remote_bda, bool is_orig, uint16_t pkt_types, | ||
620 | 626 | |
621 | 627 | p_setup = &p->esco.setup; |
622 | 628 | *p_setup = btm_cb.sco_cb.def_esco_parms; |
623 | - p_setup->packet_types = pkt_types; | |
624 | - | |
625 | - temp_pkt_types = (p_setup->packet_types & BTM_SCO_SUPPORTED_PKTS_MASK & | |
626 | - btm_cb.btm_sco_pkt_types_supported); | |
627 | 629 | |
630 | + /* Determine the packet types */ | |
631 | + p_setup->packet_types = pkt_types & BTM_SCO_SUPPORTED_PKTS_MASK & | |
632 | + btm_cb.btm_sco_pkt_types_supported; | |
628 | 633 | /* OR in any exception packet types */ |
629 | 634 | if (controller_get_interface()->get_bt_version()->hci_version >= |
630 | 635 | HCI_PROTO_VERSION_2_0) { |
631 | - temp_pkt_types |= | |
632 | - ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) | | |
633 | - (btm_cb.btm_sco_pkt_types_supported & | |
634 | - BTM_SCO_EXCEPTION_PKTS_MASK)); | |
636 | + p_setup->packet_types |= | |
637 | + (pkt_types & BTM_SCO_EXCEPTION_PKTS_MASK) | | |
638 | + (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK); | |
635 | 639 | } |
636 | 640 | |
637 | - p_setup->packet_types = temp_pkt_types; | |
638 | 641 | p->p_conn_cb = p_conn_cb; |
639 | 642 | p->p_disc_cb = p_disc_cb; |
640 | 643 | p->hci_handle = BTM_INVALID_HCI_HANDLE; |
@@ -670,13 +673,13 @@ tBTM_STATUS BTM_CreateSco(BD_ADDR remote_bda, bool is_orig, uint16_t pkt_types, | ||
670 | 673 | |
671 | 674 | *p_sco_inx = xx; |
672 | 675 | |
673 | - return (BTM_CMD_STARTED); | |
676 | + return BTM_CMD_STARTED; | |
674 | 677 | } |
675 | 678 | } |
676 | 679 | |
677 | 680 | #endif |
678 | 681 | /* If here, all SCO blocks in use */ |
679 | - return (BTM_NO_RESOURCES); | |
682 | + return BTM_NO_RESOURCES; | |
680 | 683 | } |
681 | 684 | |
682 | 685 | #if (BTM_SCO_WAKE_PARKED_LINK == TRUE) |
@@ -1323,8 +1326,7 @@ tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms) { | ||
1323 | 1326 | p_def->packet_types &= BTM_SCO_LINK_ONLY_MASK; |
1324 | 1327 | p_def->retransmission_effort = ESCO_RETRANSMISSION_OFF; |
1325 | 1328 | p_def->max_latency_ms = 12; |
1326 | - BTM_TRACE_WARNING("%s: BTM_SetEScoMode -> mode SCO (eSCO not supported)", | |
1327 | - __func__); | |
1329 | + BTM_TRACE_WARNING("%s: eSCO not supported", __func__); | |
1328 | 1330 | } |
1329 | 1331 | |
1330 | 1332 | BTM_TRACE_API( |
@@ -1333,7 +1335,7 @@ tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms) { | ||
1333 | 1335 | __func__, p_def->transmit_bandwidth, p_def->receive_bandwidth, |
1334 | 1336 | p_def->max_latency_ms, p_def->packet_types, p_def->retransmission_effort); |
1335 | 1337 | |
1336 | - return (BTM_SUCCESS); | |
1338 | + return BTM_SUCCESS; | |
1337 | 1339 | } |
1338 | 1340 | |
1339 | 1341 | /******************************************************************************* |
@@ -1063,7 +1063,6 @@ void btsnd_hcic_enhanced_set_up_synchronous_connection( | ||
1063 | 1063 | void btsnd_hcic_enhanced_accept_synchronous_connection( |
1064 | 1064 | BD_ADDR bd_addr, enh_esco_params_t* p_params) { |
1065 | 1065 | BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); |
1066 | - ; | |
1067 | 1066 | uint8_t* pp = (uint8_t*)(p + 1); |
1068 | 1067 | |
1069 | 1068 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ENH_ACC_ESCO_CONN; |
@@ -27,7 +27,7 @@ | ||
27 | 27 | |
28 | 28 | #include "bt_target.h" |
29 | 29 | #include "device/include/esco_parameters.h" |
30 | -#include "hcimsgs.h" | |
30 | +#include "hcidefs.h" | |
31 | 31 | #include "sdp_api.h" |
32 | 32 | |
33 | 33 | #include "smp_api.h" |
@@ -21,7 +21,7 @@ | ||
21 | 21 | |
22 | 22 | #include "bt_target.h" |
23 | 23 | #include "device/include/esco_parameters.h" |
24 | -#include "hcimsgs.h" | |
24 | +#include "hcidefs.h" | |
25 | 25 | #include "smp_api_types.h" |
26 | 26 | |
27 | 27 | /* Maximum number of bytes allowed for vendor specific command parameters */ |