mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 08:42:28 +00:00
hfp: use enhanced setup/accept sco connection for NXP with WBS support
This commit is contained in:
parent
5fd6f36099
commit
77d6354911
@ -1957,8 +1957,77 @@ void hfp_setup_synchronous_connection(hfp_connection_t * hfp_connection){
|
||||
|
||||
// get packet types - bits 6-9 are 'don't allow'
|
||||
uint16_t packet_types_flipped = packet_types ^ 0x03c0;
|
||||
#if defined(ENABLE_SCO_OVER_PCM) && defined(ENABLE_NXP_PCM_WBS)
|
||||
uint8_t radio_coding_format = 3;
|
||||
uint32_t host_bandwidth = 0;
|
||||
uint8_t coded_data_size = 0;
|
||||
switch (hfp_connection->negotiated_codec){
|
||||
case HFP_CODEC_CVSD:
|
||||
radio_coding_format = 0x02;
|
||||
host_bandwidth = 16000;
|
||||
coded_data_size = 0x10;
|
||||
break;
|
||||
case HFP_CODEC_MSBC:
|
||||
radio_coding_format = 0x05;
|
||||
host_bandwidth = 32000;
|
||||
coded_data_size = 0x08;
|
||||
break;
|
||||
default:
|
||||
log_error("Coding format %u not supported by Controller", hfp_connection->negotiated_codec);
|
||||
btstack_assert(false);
|
||||
break;
|
||||
}
|
||||
hci_send_cmd(&hci_enhanced_setup_synchronous_connection,
|
||||
// ACL Handle
|
||||
hfp_connection->acl_handle,
|
||||
// Transmit_Bandwidth
|
||||
8000,
|
||||
// Receive_Bandwidth
|
||||
8000,
|
||||
// Transmit_Coding_Format: radio_config_format, company, codec
|
||||
radio_coding_format, 0x00, 0x00,
|
||||
// Receive_Coding_Format: radio_config_format, company, codec
|
||||
radio_coding_format, 0x00, 0x00,
|
||||
// Transmit_Codec_Frame_Size
|
||||
0x3c,
|
||||
// Receive_Codec_Frame_Size
|
||||
0x3c,
|
||||
// Input_Bandwidth
|
||||
host_bandwidth,
|
||||
// Output_Bandwidth
|
||||
host_bandwidth,
|
||||
// Input_Coding_Format, 0x04 = Linear PCM, company, codec
|
||||
0x04, 0x00, 0x00,
|
||||
// Output_Coding_Format, 0x04 = Linear PCM, company, codec
|
||||
0x04, 0x00, 0x00,
|
||||
// Input_Coded_Data_Size
|
||||
coded_data_size,
|
||||
// Output_Coded_Data_Size
|
||||
coded_data_size,
|
||||
// Input_PCM_Data_Format, 0x02 = 2’s complement
|
||||
0x02,
|
||||
// Output_PCM_Data_Format, 0x02 = 2’s complement
|
||||
0x02,
|
||||
// Input_PCM_Sample_Payload_MSB_Position
|
||||
0x00,
|
||||
// Output_PCM_Sample_Payload_MSB_Position
|
||||
0x00,
|
||||
// Input_Data_Path - vendor specific: NXP - I2S/PCM
|
||||
0x01,
|
||||
// Output_Data_Path - vendor specific: NXP - I2S/PCM
|
||||
0x01,
|
||||
// Input_Transport_Unit_Size
|
||||
0x10,
|
||||
// Output_Transport_Unit_Size
|
||||
0x10,
|
||||
//
|
||||
hfp_link_settings[setting].max_latency,
|
||||
packet_types_flipped,
|
||||
hfp_link_settings[setting].retransmission_effort);
|
||||
#else
|
||||
hci_send_cmd(&hci_setup_synchronous_connection, hfp_connection->acl_handle, 8000, 8000, hfp_link_settings[setting].max_latency,
|
||||
sco_voice_setting, hfp_link_settings[setting].retransmission_effort, packet_types_flipped);
|
||||
#endif
|
||||
}
|
||||
|
||||
hfp_link_settings_t hfp_safe_settings_for_context(bool use_eSCO, uint8_t negotiated_codec, bool secure_connection_in_use){
|
||||
@ -2011,8 +2080,77 @@ void hfp_accept_synchronous_connection(hfp_connection_t * hfp_connection, bool u
|
||||
log_info("Sending hci_accept_connection_request for link settings %u: packet types 0x%04x, sco_voice_setting 0x%02x",
|
||||
(uint8_t) link_setting, packet_types, sco_voice_setting);
|
||||
|
||||
#if defined(ENABLE_SCO_OVER_PCM) && defined(ENABLE_NXP_PCM_WBS)
|
||||
uint8_t radio_coding_format = 3;
|
||||
uint32_t host_bandwidth = 0;
|
||||
uint8_t coded_data_size = 0;
|
||||
switch (hfp_connection->negotiated_codec){
|
||||
case HFP_CODEC_CVSD:
|
||||
radio_coding_format = 0x02;
|
||||
host_bandwidth = 16000;
|
||||
coded_data_size = 0x10;
|
||||
break;
|
||||
case HFP_CODEC_MSBC:
|
||||
radio_coding_format = 0x05;
|
||||
host_bandwidth = 32000;
|
||||
coded_data_size = 0x08;
|
||||
break;
|
||||
default:
|
||||
log_error("Coding format %u not supported by Controller", hfp_connection->negotiated_codec);
|
||||
btstack_assert(false);
|
||||
break;
|
||||
}
|
||||
hci_send_cmd(&hci_enhanced_accept_synchronous_connection,
|
||||
// BD_ADDR
|
||||
hfp_connection->remote_addr,
|
||||
// Transmit_Bandwidth
|
||||
8000,
|
||||
// Receive_Bandwidth
|
||||
8000,
|
||||
// Transmit_Coding_Format: radio_config_format, company, codec
|
||||
radio_coding_format, 0x00, 0x00,
|
||||
// Receive_Coding_Format: radio_config_format, company, codec
|
||||
radio_coding_format, 0x00, 0x00,
|
||||
// Transmit_Codec_Frame_Size
|
||||
0x3c,
|
||||
// Receive_Codec_Frame_Size
|
||||
0x3c,
|
||||
// Input_Bandwidth
|
||||
host_bandwidth,
|
||||
// Output_Bandwidth
|
||||
host_bandwidth,
|
||||
// Input_Coding_Format, 0x04 = Linear PCM, company, codec
|
||||
0x04, 0x00, 0x00,
|
||||
// Output_Coding_Format, 0x04 = Linear PCM, company, codec
|
||||
0x04, 0x00, 0x00,
|
||||
// Input_Coded_Data_Size
|
||||
coded_data_size,
|
||||
// Output_Coded_Data_Size
|
||||
coded_data_size,
|
||||
// Input_PCM_Data_Format, 0x02 = 2’s complement
|
||||
0x02,
|
||||
// Output_PCM_Data_Format, 0x02 = 2’s complement
|
||||
0x02,
|
||||
// Input_PCM_Sample_Payload_MSB_Position
|
||||
0x00,
|
||||
// Output_PCM_Sample_Payload_MSB_Position
|
||||
0x00,
|
||||
// Input_Data_Path - vendor specific: NXP - I2S/PCM
|
||||
0x01,
|
||||
// Output_Data_Path - vendor specific: NXP - I2S/PCM
|
||||
0x01,
|
||||
// Input_Transport_Unit_Size
|
||||
0x10,
|
||||
// Output_Transport_Unit_Size
|
||||
0x10,
|
||||
//
|
||||
max_latency,
|
||||
packet_types_flipped,
|
||||
retransmission_effort);
|
||||
#else
|
||||
hci_send_cmd(&hci_accept_synchronous_connection, hfp_connection->remote_addr, 8000, 8000, max_latency,
|
||||
sco_voice_setting, retransmission_effort, packet_types_flipped);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CC256X_ASSISTED_HFP
|
||||
|
Loading…
x
Reference in New Issue
Block a user