hfp.c (7d81706fa74a61fff75d7256d66e4f9a74466633) | hfp.c (cb81d35d7c3b357e822fcc8ed88aa49b7661232f) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 715 unchanged lines hidden (view full) --- 724 case HCI_EVENT_CONNECTION_REQUEST: 725 switch(hci_event_connection_request_get_link_type(packet)){ 726 case 0: // SCO 727 case 2: // eSCO 728 hci_event_connection_request_get_bd_addr(packet, event_addr); 729 hfp_connection = get_hfp_connection_context_for_bd_addr(event_addr, local_role); 730 if (!hfp_connection) break; 731 if (hci_event_connection_request_get_link_type(packet) == 2){ | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 715 unchanged lines hidden (view full) --- 724 case HCI_EVENT_CONNECTION_REQUEST: 725 switch(hci_event_connection_request_get_link_type(packet)){ 726 case 0: // SCO 727 case 2: // eSCO 728 hci_event_connection_request_get_bd_addr(packet, event_addr); 729 hfp_connection = get_hfp_connection_context_for_bd_addr(event_addr, local_role); 730 if (!hfp_connection) break; 731 if (hci_event_connection_request_get_link_type(packet) == 2){ |
732 hfp_connection->hf_accept_sco = 2; | 732 hfp_connection->accept_sco = 2; |
733 } else { | 733 } else { |
734 hfp_connection->hf_accept_sco = 1; | 734 hfp_connection->accept_sco = 1; |
735 } 736#ifdef ENABLE_CC256X_ASSISTED_HFP 737 hfp_cc256x_prepare_for_sco(hfp_connection); 738#endif 739#ifdef ENABLE_BCM_PCM_WBS 740 hfp_bcm_prepare_for_sco(hfp_connection); 741#endif | 735 } 736#ifdef ENABLE_CC256X_ASSISTED_HFP 737 hfp_cc256x_prepare_for_sco(hfp_connection); 738#endif 739#ifdef ENABLE_BCM_PCM_WBS 740 hfp_bcm_prepare_for_sco(hfp_connection); 741#endif |
742 log_info("hf accept sco %u\n", hfp_connection->hf_accept_sco); | 742 log_info("accept sco %u\n", hfp_connection->accept_sco); |
743 sco_establishment_active = hfp_connection; 744 break; 745 default: 746 break; 747 } 748 break; 749 750 case HCI_EVENT_COMMAND_STATUS: --- 16 unchanged lines hidden (view full) --- 767 hfp_connection = get_hfp_connection_context_for_bd_addr(event_addr, local_role); 768 if (!hfp_connection) { 769 log_error("HFP: connection does not exist for remote with addr %s.", bd_addr_to_str(event_addr)); 770 return; 771 } 772 773 status = hci_event_synchronous_connection_complete_get_status(packet); 774 if (status != ERROR_CODE_SUCCESS){ | 743 sco_establishment_active = hfp_connection; 744 break; 745 default: 746 break; 747 } 748 break; 749 750 case HCI_EVENT_COMMAND_STATUS: --- 16 unchanged lines hidden (view full) --- 767 hfp_connection = get_hfp_connection_context_for_bd_addr(event_addr, local_role); 768 if (!hfp_connection) { 769 log_error("HFP: connection does not exist for remote with addr %s.", bd_addr_to_str(event_addr)); 770 return; 771 } 772 773 status = hci_event_synchronous_connection_complete_get_status(packet); 774 if (status != ERROR_CODE_SUCCESS){ |
775 hfp_connection->hf_accept_sco = 0; | 775 hfp_connection->accept_sco = 0; |
776 if (hfp_handle_failed_sco_connection(status)) break; 777 778 hfp_connection->establish_audio_connection = 0; 779 hfp_connection->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED; 780 hfp_emit_sco_event(hfp_connection, status, 0, event_addr, hfp_connection->negotiated_codec); 781 break; 782 } 783 --- 890 unchanged lines hidden (view full) --- 1674#endif 1675 } 1676 // get packet types - bits 6-9 are 'don't allow' 1677 uint16_t packet_types = hfp_link_settings[setting].packet_types ^ 0x03c0; 1678 hci_send_cmd(&hci_setup_synchronous_connection, hfp_connection->acl_handle, 8000, 8000, hfp_link_settings[setting].max_latency, 1679 sco_voice_setting, hfp_link_settings[setting].retransmission_effort, packet_types); 1680} 1681 | 776 if (hfp_handle_failed_sco_connection(status)) break; 777 778 hfp_connection->establish_audio_connection = 0; 779 hfp_connection->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED; 780 hfp_emit_sco_event(hfp_connection, status, 0, event_addr, hfp_connection->negotiated_codec); 781 break; 782 } 783 --- 890 unchanged lines hidden (view full) --- 1674#endif 1675 } 1676 // get packet types - bits 6-9 are 'don't allow' 1677 uint16_t packet_types = hfp_link_settings[setting].packet_types ^ 0x03c0; 1678 hci_send_cmd(&hci_setup_synchronous_connection, hfp_connection->acl_handle, 8000, 8000, hfp_link_settings[setting].max_latency, 1679 sco_voice_setting, hfp_link_settings[setting].retransmission_effort, packet_types); 1680} 1681 |
1682void hfp_accept_synchronous_connection(hfp_connection_t * hfp_connection, bool incoming_eSCO){ 1683 1684 // remote supported feature eSCO is set if link type is eSCO 1685 // eSCO: S4 - max latency == transmission interval = 0x000c == 12 ms, 1686 uint16_t max_latency; 1687 uint8_t retransmission_effort; 1688 uint16_t packet_types; 1689 1690 if (incoming_eSCO && hci_extended_sco_link_supported() && hci_remote_esco_supported(hfp_connection->acl_handle)){ 1691 max_latency = 0x000c; 1692 retransmission_effort = 0x02; 1693 // eSCO: EV3 and 2-EV3 1694 packet_types = 0x0048; 1695 } else { 1696 max_latency = 0xffff; 1697 retransmission_effort = 0xff; 1698 // sco: HV1 and HV3 1699 packet_types = 0x005; 1700 } 1701 1702 // mSBC only allows for transparent data 1703 uint16_t sco_voice_setting = hci_get_sco_voice_setting(); 1704 if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){ 1705#ifdef ENABLE_BCM_PCM_WBS 1706 sco_voice_setting = 0x0063; // Transparent data, 16-bit for BCM controllers 1707#else 1708 sco_voice_setting = 0x0043; // Transparent data, 8-bit otherwise 1709#endif 1710 } 1711 1712 // filter packet types 1713 packet_types &= hfp_get_sco_packet_types(); 1714 1715 // bits 6-9 are 'don't allow' 1716 packet_types ^= 0x3c0; 1717 1718 log_info("HFP: sending hci_accept_connection_request, packet types 0x%04x, sco_voice_setting 0x%02x", packet_types, sco_voice_setting); 1719 hci_send_cmd(&hci_accept_synchronous_connection, hfp_connection->remote_addr, 8000, 8000, max_latency, 1720 sco_voice_setting, retransmission_effort, packet_types); 1721} 1722 |
|
1682#ifdef ENABLE_CC256X_ASSISTED_HFP 1683void hfp_cc256x_prepare_for_sco(hfp_connection_t * hfp_connection){ 1684 hfp_connection->cc256x_send_write_codec_config = true; 1685 if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){ 1686 hfp_connection->cc256x_send_wbs_associate = true; 1687 } 1688} 1689 --- 142 unchanged lines hidden --- | 1723#ifdef ENABLE_CC256X_ASSISTED_HFP 1724void hfp_cc256x_prepare_for_sco(hfp_connection_t * hfp_connection){ 1725 hfp_connection->cc256x_send_write_codec_config = true; 1726 if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){ 1727 hfp_connection->cc256x_send_wbs_associate = true; 1728 } 1729} 1730 --- 142 unchanged lines hidden --- |