From e4eb949c6cb873163c8931e61a73680d886f9deb Mon Sep 17 00:00:00 2001 From: Kiran Kelageri Date: Thu, 8 Oct 2015 11:12:57 -0700 Subject: Bluetooth: change patch download procedure as blocking procedure. Changes include patch download procedure to be blocking using properties i.e. if any client either ANT or BT is already in patch download process then the other would wait till complete. Change-Id: If2ac3d68741e7a33ff093ed4bee867a2099fa8ba --- libbt-vendor/src/bt_vendor_qcom.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/libbt-vendor/src/bt_vendor_qcom.c b/libbt-vendor/src/bt_vendor_qcom.c index e898112..014cb50 100644 --- a/libbt-vendor/src/bt_vendor_qcom.c +++ b/libbt-vendor/src/bt_vendor_qcom.c @@ -50,6 +50,7 @@ #endif #define CMD_TIMEOUT 0x22 +void wait_for_patch_download(); /****************************************************************************** ** Externs ******************************************************************************/ @@ -225,6 +226,7 @@ static int get_bt_soc_type() bool can_perform_action(char action) { bool can_perform = false; char ref_count[PROPERTY_VALUE_MAX]; + char inProgress[PROPERTY_VALUE_MAX] = {'\0'}; int value, ret; property_get("wc_transport.ref_count", ref_count, "0"); @@ -236,7 +238,8 @@ bool can_perform_action(char action) { ALOGV("%s: on : value is: %d", __func__, value); if(value == 1) { - if(is_soc_initialized() == true) + property_get("wc_transport.patch_dnld_inprog", inProgress, "0"); + if((is_soc_initialized() == true) || (strcmp(inProgress,"1") == 0)) { value++; ALOGV("%s: on : value is incremented to : %d", __func__, value); @@ -762,8 +765,12 @@ static int op(bt_vendor_opcode_t opcode, void *param) break; case BT_SOC_ROME: { + wait_for_patch_download(); property_get("ro.bluetooth.emb_wp_mode", emb_wp_mode, false); if (!is_soc_initialized()) { + if (property_set("wc_transport.patch_dnld_inprog", "1") < 0) { + ALOGE("%s: Failed to set property", __FUNCTION__); + } fd = userial_vendor_open((tUSERIAL_CFG *) &userial_init_cfg); if (fd < 0) { ALOGE("userial_vendor_open returns err"); @@ -836,6 +843,9 @@ static int op(bt_vendor_opcode_t opcode, void *param) } } } + if (property_set("wc_transport.patch_dnld_inprog", "0") < 0) { + ALOGE("%s: Failed to set property", __FUNCTION__); + } property_set("wc_transport.clean_up","0"); if (retval != -1) { @@ -1051,6 +1061,9 @@ static void ssr_cleanup(int reason) { int ret; unsigned char trig_ssr = 0xEE; ALOGI("ssr_cleanup"); + if (property_set("wc_transport.patch_dnld_inprog", "0") < 0) { + ALOGE("%s: Failed to set property", __FUNCTION__); + } if ((btSocType = get_bt_soc_type()) < 0) { ALOGE("%s: Failed to detect BT SOC Type", __FUNCTION__); @@ -1099,6 +1112,24 @@ static void cleanup( void ) #endif /* WIFI_BT_STATUS_SYNC */ } +/* Check for one of the cients ANT/BT patch download is already in +** progress if yes wait till complete +*/ +void wait_for_patch_download() { + ALOGV("%s:", __FUNCTION__); + char inProgress[PROPERTY_VALUE_MAX] = {'\0'}; + while (1) { + property_get("wc_transport.patch_dnld_inprog", inProgress, "0"); + if(strcmp(inProgress,"1") == 0) { + usleep(50000); + } + else { + ALOGI("%s: patch download completed", __FUNCTION__); + break; + } + } +} + // Entry point of DLib const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = { sizeof(bt_vendor_interface_t), -- cgit v1.2.3