diff --git a/src/classic/hfp.c b/src/classic/hfp.c index b9a9da0cd..fd6913536 100644 --- a/src/classic/hfp.c +++ b/src/classic/hfp.c @@ -827,6 +827,9 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet #endif #ifdef ENABLE_BCM_PCM_WBS hfp_bcm_prepare_for_sco(hfp_connection); +#endif +#ifdef ENABLE_RTK_PCM_WBS + hfp_connection->rtk_send_sco_config = true; #endif log_info("accept sco %u\n", hfp_connection->accept_sco); hfp_sco_establishment_active = hfp_connection; diff --git a/src/classic/hfp.h b/src/classic/hfp.h index c28b0ea88..cdc52438e 100644 --- a/src/classic/hfp.h +++ b/src/classic/hfp.h @@ -727,6 +727,9 @@ typedef struct hfp_connection { bool bcm_send_disable_wbs; bool bcm_send_write_i2spcm_interface_param; #endif +#ifdef ENABLE_RTK_PCM_WBS + bool rtk_send_sco_config; +#endif } hfp_connection_t; // UTILS_START : TODO move to utils diff --git a/src/classic/hfp_ag.c b/src/classic/hfp_ag.c index a0f923fa1..6ac2bc7a8 100644 --- a/src/classic/hfp_ag.c +++ b/src/classic/hfp_ag.c @@ -632,6 +632,9 @@ static int codecs_exchange_state_machine(hfp_connection_t * hfp_connection){ hfp_init_link_settings(hfp_connection, hfp_ag_esco_s4_supported(hfp_connection)); #ifdef ENABLE_CC256X_ASSISTED_HFP hfp_cc256x_prepare_for_sco(hfp_connection); +#endif +#ifdef ENABLE_RTK_PCM_WBS + hfp_connection->rtk_send_sco_config = true; #endif return 1; default: @@ -2197,6 +2200,20 @@ static void hfp_ag_run_for_context(hfp_connection_t *hfp_connection){ return; } #endif +#ifdef ENABLE_RTK_PCM_WBS + // Configure CVSD vs. mSBC + if (hfp_connection->rtk_send_sco_config){ + hfp_connection->rtk_send_sco_config = false; + if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){ + log_info("RTK SCO: 16k + mSBC"); + hci_send_cmd(&hci_rtk_configure_sco_routing, 0x81, 0x90, 0x00, 0x00, 0x1a, 0x0c, 0x00, 0x00, 0x41); + } else { + log_info("RTK SCO: 16k + CVSD"); + hci_send_cmd(&hci_rtk_configure_sco_routing, 0x81, 0x90, 0x00, 0x00, 0x1a, 0x0c, 0x0c, 0x00, 0x01); + } + return; + } +#endif #if defined (ENABLE_CC256X_ASSISTED_HFP) || defined (ENABLE_BCM_PCM_WBS) if (hfp_connection->state == HFP_W4_WBS_SHUTDOWN){ hfp_finalize_connection_context(hfp_connection); diff --git a/src/classic/hfp_hf.c b/src/classic/hfp_hf.c index 4464550c8..c2edae7cf 100644 --- a/src/classic/hfp_hf.c +++ b/src/classic/hfp_hf.c @@ -785,6 +785,19 @@ static void hfp_hf_run_for_context(hfp_connection_t * hfp_connection){ return; } #endif +#ifdef ENABLE_RTK_PCM_WBS + if (hfp_connection->rtk_send_sco_config){ + hfp_connection->rtk_send_sco_config = false; + if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){ + log_info("RTK SCO: 16k + mSBC"); + hci_send_cmd(&hci_rtk_configure_sco_routing, 0x81, 0x90, 0x00, 0x00, 0x1a, 0x0c, 0x00, 0x00, 0x41); + } else { + log_info("RTK SCO: 16k + CVSD"); + hci_send_cmd(&hci_rtk_configure_sco_routing, 0x81, 0x90, 0x00, 0x00, 0x1a, 0x0c, 0x0c, 0x00, 0x01); + } + return; + } +#endif #if defined (ENABLE_CC256X_ASSISTED_HFP) || defined (ENABLE_BCM_PCM_WBS) if (hfp_connection->state == HFP_W4_WBS_SHUTDOWN){ hfp_finalize_connection_context(hfp_connection);