summaryrefslogtreecommitdiffstats
path: root/stack/btm/btm_sco.c
diff options
context:
space:
mode:
Diffstat (limited to 'stack/btm/btm_sco.c')
-rw-r--r--stack/btm/btm_sco.c158
1 files changed, 67 insertions, 91 deletions
diff --git a/stack/btm/btm_sco.c b/stack/btm/btm_sco.c
index d9d0fbc49..801896d14 100644
--- a/stack/btm/btm_sco.c
+++ b/stack/btm/btm_sco.c
@@ -176,61 +176,50 @@ static void btm_esco_conn_rsp (UINT16 sco_inx, UINT8 hci_status, BD_ADDR bda,
else /* Connection is being accepted */
{
p_sco->state = SCO_ST_CONNECTING;
- if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_1_2)
+ p_setup = &p_sco->esco.setup;
+ /* If parameters not specified use the default */
+ if (p_parms)
+ *p_setup = *p_parms;
+ else /* Use the last setup passed thru BTM_SetEscoMode (or defaults) */
{
- p_setup = &p_sco->esco.setup;
- /* If parameters not specified use the default */
- if (p_parms)
- *p_setup = *p_parms;
- else /* Use the last setup passed thru BTM_SetEscoMode (or defaults) */
- {
- *p_setup = btm_cb.sco_cb.def_esco_parms;
- }
+ *p_setup = btm_cb.sco_cb.def_esco_parms;
+ }
- temp_pkt_types = (p_setup->packet_types &
- BTM_SCO_SUPPORTED_PKTS_MASK &
- btm_cb.btm_sco_pkt_types_supported);
+ temp_pkt_types = (p_setup->packet_types &
+ BTM_SCO_SUPPORTED_PKTS_MASK &
+ btm_cb.btm_sco_pkt_types_supported);
- /* Make sure at least one eSCO packet type is sent, else might confuse peer */
- /* Taking this out to confirm with BQB tests
- ** Real application would like to include this though, as many devices
- ** do not retry with SCO only if an eSCO connection fails.
- if (!(temp_pkt_types & BTM_ESCO_LINK_ONLY_MASK))
- {
- temp_pkt_types |= BTM_SCO_PKT_TYPES_MASK_EV3;
- }
- */
- /* If SCO request, remove eSCO packet types (conformance) */
- if (p_sco->esco.data.link_type == BTM_LINK_TYPE_SCO)
- {
- temp_pkt_types &= BTM_SCO_LINK_ONLY_MASK;
-
- if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
- {
- temp_pkt_types |= BTM_SCO_EXCEPTION_PKTS_MASK;
- }
- }
- /* OR in any exception packet types if at least 2.0 version of spec */
- else if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
- {
- temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) |
- (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK));
- }
+ /* Make sure at least one eSCO packet type is sent, else might confuse peer */
+ /* Taking this out to confirm with BQB tests
+ ** Real application would like to include this though, as many devices
+ ** do not retry with SCO only if an eSCO connection fails.
+ if (!(temp_pkt_types & BTM_ESCO_LINK_ONLY_MASK))
+ {
+ temp_pkt_types |= BTM_SCO_PKT_TYPES_MASK_EV3;
+ }
+ */
+ /* If SCO request, remove eSCO packet types (conformance) */
+ if (p_sco->esco.data.link_type == BTM_LINK_TYPE_SCO)
+ {
+ temp_pkt_types &= BTM_SCO_LINK_ONLY_MASK;
+ temp_pkt_types |= BTM_SCO_EXCEPTION_PKTS_MASK;
+ }
+ else
+ {
+ /* OR in any exception packet types */
+ temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) |
+ (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK));
+ }
- if (btsnd_hcic_accept_esco_conn (bda, p_setup->tx_bw, p_setup->rx_bw,
- p_setup->max_latency, p_setup->voice_contfmt,
- p_setup->retrans_effort, temp_pkt_types))
- {
- p_setup->packet_types = temp_pkt_types;
- }
- else
- {
- BTM_TRACE_ERROR("Could not accept SCO conn: No Buffer!!!");
- }
+ if (btsnd_hcic_accept_esco_conn (bda, p_setup->tx_bw, p_setup->rx_bw,
+ p_setup->max_latency, p_setup->voice_contfmt,
+ p_setup->retrans_effort, temp_pkt_types))
+ {
+ p_setup->packet_types = temp_pkt_types;
}
- else /* Controller is version 1.1 or earlier */
+ else
{
- btsnd_hcic_accept_conn (bda, 0);
+ BTM_TRACE_ERROR("Could not accept SCO conn: No Buffer!!!");
}
}
#endif
@@ -421,12 +410,9 @@ static tBTM_STATUS btm_send_connect_request(UINT16 acl_handle,
temp_pkt_types = (p_setup->packet_types & BTM_SCO_SUPPORTED_PKTS_MASK &
btm_cb.btm_sco_pkt_types_supported);
- /* OR in any exception packet types if at least 2.0 version of spec */
- if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
- {
- temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) |
- (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK));
- }
+ /* OR in any exception packet types */
+ temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) |
+ (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK));
/* Finally, remove EDR eSCO if the remote device doesn't support it */
/* UPF25: Only SCO was brought up in this case */
@@ -570,12 +556,12 @@ tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types
UINT16 temp_pkt_types;
tACL_CONN *p_acl;
-#if (BTM_PWR_MGR_INCLUDED == TRUE) && (BTM_SCO_WAKE_PARKED_LINK == TRUE)
+#if (BTM_SCO_WAKE_PARKED_LINK == TRUE)
tBTM_PM_MODE md;
tBTM_PM_PWR_MD pm;
-#else
+#else // BTM_SCO_WAKE_PARKED_LINK
UINT8 mode;
-#endif
+#endif // BTM_SCO_WAKE_PARKED_LINK
*p_sco_inx = BTM_INVALID_SCO_INDEX;
@@ -619,7 +605,7 @@ tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types
if (is_orig)
{
/* can not create SCO link if in park mode */
-#if (BTM_PWR_MGR_INCLUDED == TRUE) && (BTM_SCO_WAKE_PARKED_LINK == TRUE)
+#if BTM_SCO_WAKE_PARKED_LINK == TRUE
if(BTM_ReadPowerMode(remote_bda, &md) == BTM_SUCCESS)
{
if (md == BTM_PM_MD_PARK || md == BTM_PM_MD_SNIFF)
@@ -630,13 +616,10 @@ tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types
p->state = SCO_ST_PEND_UNPARK;
}
}
-#elif BTM_PWR_MGR_INCLUDED == TRUE
+#else // BTM_SCO_WAKE_PARKED_LINK
if( (BTM_ReadPowerMode(remote_bda, &mode) == BTM_SUCCESS) && (mode == BTM_PM_MD_PARK) )
return (BTM_WRONG_MODE);
-#else
- if( (BTM_ReadAclMode(remote_bda, &mode) == BTM_SUCCESS) && (mode == BTM_ACL_MODE_PARK) )
- return (BTM_WRONG_MODE);
-#endif
+#endif // BTM_SCO_WAKE_PARKED_LINK
}
memcpy (p->esco.data.bd_addr, remote_bda, BD_ADDR_LEN);
p->rem_bd_known = TRUE;
@@ -656,18 +639,15 @@ tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types
temp_pkt_types = (p_setup->packet_types & BTM_SCO_SUPPORTED_PKTS_MASK &
btm_cb.btm_sco_pkt_types_supported);
- /* OR in any exception packet types if at least 2.0 version of spec */
- if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
+ /* OR in any exception packet types */
+ if (btm_cb.sco_cb.desired_sco_mode == HCI_LINK_TYPE_ESCO)
{
- if (btm_cb.sco_cb.desired_sco_mode == HCI_LINK_TYPE_ESCO)
- {
- temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) |
- (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK));
- }
- else /* Only using SCO packet types; turn off EDR also */
- {
- temp_pkt_types |= BTM_SCO_EXCEPTION_PKTS_MASK;
- }
+ temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) |
+ (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK));
+ }
+ else /* Only using SCO packet types; turn off EDR also */
+ {
+ temp_pkt_types |= BTM_SCO_EXCEPTION_PKTS_MASK;
}
p_setup->packet_types = temp_pkt_types;
@@ -719,7 +699,7 @@ tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types
return (BTM_NO_RESOURCES);
}
-#if (BTM_PWR_MGR_INCLUDED == TRUE) && (BTM_SCO_WAKE_PARKED_LINK == TRUE)
+#if (BTM_SCO_WAKE_PARKED_LINK == TRUE)
/*******************************************************************************
**
** Function btm_sco_chk_pend_unpark
@@ -750,9 +730,9 @@ void btm_sco_chk_pend_unpark (UINT8 hci_status, UINT16 hci_handle)
p->state = SCO_ST_CONNECTING;
}
}
-#endif
+#endif // BTM_MAX_SCO_LINKS
}
-#endif
+#endif // BTM_SCO_WAKE_PARKED_LINK
/*******************************************************************************
**
@@ -810,8 +790,10 @@ void btm_sco_conn_req (BD_ADDR bda, DEV_CLASS dev_class, UINT8 link_type)
* If the sco state is in the SCO_ST_CONNECTING state, we still need
* to return accept sco to avoid race conditon for sco creation
*/
- if (((p->state == SCO_ST_LISTENING && p->rem_bd_known) || p->state == SCO_ST_CONNECTING)
- && (!memcmp (p->esco.data.bd_addr, bda, BD_ADDR_LEN)))
+ int rem_bd_matches = p->rem_bd_known &&
+ !memcmp (p->esco.data.bd_addr, bda, BD_ADDR_LEN);
+ if (((p->state == SCO_ST_CONNECTING) && rem_bd_matches) ||
+ ((p->state == SCO_ST_LISTENING) && (rem_bd_matches || !p->rem_bd_known)))
{
/* If this guy was a wildcard, he is not one any more */
p->rem_bd_known = TRUE;
@@ -1366,11 +1348,8 @@ tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode, tBTM_ESCO_PARAMS *p_parms)
p_def->voice_contfmt = 0x0060;
p_def->retrans_effort = 0;
- /* OR in any exception packet types if at least 2.0 version of spec */
- if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
- {
- p_def->packet_types |= BTM_SCO_EXCEPTION_PKTS_MASK;
- }
+ /* OR in any exception packet types */
+ p_def->packet_types |= BTM_SCO_EXCEPTION_PKTS_MASK;
}
}
p_esco->desired_sco_mode = sco_mode;
@@ -1534,12 +1513,9 @@ tBTM_STATUS BTM_ChangeEScoLinkParms (UINT16 sco_inx, tBTM_CHG_ESCO_PARAMS *p_par
temp_pkt_types = (p_parms->packet_types & BTM_SCO_SUPPORTED_PKTS_MASK &
btm_cb.btm_sco_pkt_types_supported);
- /* OR in any exception packet types if at least 2.0 version of spec */
- if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0)
- {
- temp_pkt_types |= ((p_parms->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) |
- (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK));
- }
+ /* OR in any exception packet types */
+ temp_pkt_types |= ((p_parms->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) |
+ (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK));
BTM_TRACE_API("BTM_ChangeEScoLinkParms -> eSCO Link for handle 0x%04x", p_sco->hci_handle);
BTM_TRACE_API(" txbw 0x%x, rxbw 0x%x, lat 0x%x, voice 0x%x, retrans 0x%02x, pkt 0x%04x",