merge in nyc-mr1-release history after reset to nyc-mr1-dev
diff --git a/msmcobalt/libbt-vendor/include/bt_vendor_qcom.h b/msmcobalt/libbt-vendor/include/bt_vendor_qcom.h
index dd956cf..ac8d2fd 100644
--- a/msmcobalt/libbt-vendor/include/bt_vendor_qcom.h
+++ b/msmcobalt/libbt-vendor/include/bt_vendor_qcom.h
@@ -69,6 +69,7 @@
BT_STATUS_FAIL,
BT_STATUS_INVAL,
BT_STATUS_NOMEM,
+ BT_STATUS_PROP_FAILURE,
};
struct bt_qcom_struct {
diff --git a/msmcobalt/libbt-vendor/src/bt_vendor_qcom.c b/msmcobalt/libbt-vendor/src/bt_vendor_qcom.c
index 09583d5..6586f36 100644
--- a/msmcobalt/libbt-vendor/src/bt_vendor_qcom.c
+++ b/msmcobalt/libbt-vendor/src/bt_vendor_qcom.c
@@ -43,7 +43,7 @@
#define BT_VND_OP_GET_LINESPEED 30
#define STOP_WCNSS_FILTER 0xDD
-#define STOP_WAIT_TIMEOUT 100
+#define STOP_WAIT_TIMEOUT 1000
#define SOC_INIT_PROPERTY "wc_transport.soc_initialized"
@@ -281,35 +281,39 @@
ALOGV("%s: Entry ", __func__);
- property_get(BT_VND_FILTER_START, value, "false");
-
- if (strcmp(value, "false") == 0) {
- ALOGI("%s: hci_filter has been stopped already", __func__);
-// return;
- }
if ((soc_type = get_bt_soc_type()) == BT_SOC_CHEROKEE) {
- filter_ctrl = connect_to_local_socket("wcnssfilter_ctrl");
- if (filter_ctrl < 0) {
- ALOGI("%s: Error while connecting to CTRL_SOCK, filter should stopped: %d", __func__, filter_ctrl);
- //Ignore and fallback
- } else {
- retval = write(filter_ctrl, &stop_val, 1);
- if (retval != 1) {
- ALOGI("%s: problem writing to CTRL_SOCK, ignore: %d", __func__, retval);
- //Ignore and fallback
+ property_get("wc_transport.hci_filter_status", value, "0");
+ if (strcmp(value, "0") == 0) {
+ ALOGI("%s: hci_filter has been stopped already", __func__);
+ }
+ else {
+ filter_ctrl = connect_to_local_socket("wcnssfilter_ctrl");
+ if (filter_ctrl < 0) {
+ ALOGI("%s: Error while connecting to CTRL_SOCK, filter should stopped: %d",
+ __func__, filter_ctrl);
+ }
+ else {
+ retval = write(filter_ctrl, &stop_val, 1);
+ if (retval != 1) {
+ ALOGI("%s: problem writing to CTRL_SOCK, ignore: %d", __func__, retval);
+ //Ignore and fallback
+ }
+
+ close(filter_ctrl);
}
}
/* Ensure Filter is closed by checking the status before
RFKILL 0 operation. this should ideally comeout very
quick */
- for(i=0; i<5; i++) {
- property_get("wc_transport.hci_filter_status", value, "0");
- if (strcmp(value, "0") == 0) {
+ for(i=0; i<500; i++) {
+ property_get(BT_VND_FILTER_START, value, "false");
+ if (strcmp(value, "false") == 0) {
ALOGI("%s: WCNSS_FILTER stopped", __func__);
+ usleep(STOP_WAIT_TIMEOUT * 10);
break;
} else {
- /*sleep of 100ms, This should give enough time for FILTER to
+ /*sleep of 1ms, This should give enough time for FILTER to
exit with all necessary cleanup*/
usleep(STOP_WAIT_TIMEOUT);
}
@@ -585,7 +589,7 @@
static int init(const bt_vendor_callbacks_t *cb, unsigned char *bdaddr)
{
- char address[PROPERTY_VALUE_MAX];
+ char prop[PROPERTY_VALUE_MAX] = {0};
struct bt_qcom_struct *temp = NULL;
int ret = BT_STATUS_SUCCESS, i;
@@ -611,8 +615,18 @@
temp->ant_fd = -1;
temp->soc_type = get_bt_soc_type();
soc_init(temp->soc_type);
+
le2bd(bdaddr, temp->bdaddr);
print_bdaddr(temp->bdaddr);
+ snprintf(prop, sizeof(prop), "%02x:%02x:%02x:%02x:%02x:%02x",
+ temp->bdaddr[0], temp->bdaddr[1], temp->bdaddr[2],
+ temp->bdaddr[3], temp->bdaddr[4], temp->bdaddr[5]);
+ ret = property_set("wc_transport.stack_bdaddr", prop);
+ if (ret < 0) {
+ ALOGE("Failed to set wc_transport.stack_bdaddr prop, ret = %d", ret);
+ ret = -BT_STATUS_PROP_FAILURE;
+ goto out;
+ }
/* TODO: Move these fields inside bt_qcom context */
#ifdef WIFI_BT_STATUS_SYNC
@@ -700,9 +714,8 @@
return init;
}
-
-/** Requested operations */
-static int op(bt_vendor_opcode_t opcode, void *param)
+/* flavor of op without locks */
+static int __op(bt_vendor_opcode_t opcode, void *param)
{
int retval = BT_STATUS_SUCCESS;
int nCnt = 0;
@@ -722,12 +735,6 @@
bool skip_init = true;
int opcode_init = opcode;
ALOGV("++%s opcode %d", __FUNCTION__, opcode);
- pthread_mutex_lock(&q_lock);
- if (!q) {
- ALOGE("op called with NULL context");
- retval = -BT_STATUS_INVAL;
- goto out;
- }
switch(opcode_init)
{
@@ -1244,11 +1251,27 @@
}
out:
- pthread_mutex_unlock(&q_lock);
ALOGV("--%s", __FUNCTION__);
return retval;
}
+static int op(bt_vendor_opcode_t opcode, void *param)
+{
+ int ret;
+ ALOGV("++%s", __FUNCTION__);
+ pthread_mutex_lock(&q_lock);
+ if (!q) {
+ ALOGE("op called with NULL context");
+ ret = -BT_STATUS_INVAL;
+ goto out;
+ }
+ ret = __op(opcode, param);
+out:
+ pthread_mutex_unlock(&q_lock);
+ ALOGV("--%s ret = 0x%x", __FUNCTION__, ret);
+ return ret;
+}
+
static void ssr_cleanup(int reason)
{
int pwr_state = BT_VND_PWR_OFF;
@@ -1260,8 +1283,7 @@
pthread_mutex_lock(&q_lock);
if (!q) {
ALOGE("ssr_cleanup called with NULL context");
- pthread_mutex_unlock(&q_lock);
- return;
+ goto out;
}
if (property_set("wc_transport.patch_dnld_inprog", "null") < 0) {
ALOGE("Failed to set property");
@@ -1281,34 +1303,33 @@
* Then we should send special byte to crash SOC in
* WCNSS_Filter, so we do not need to power off UART here.
*/
- pthread_mutex_unlock(&q_lock);
- return;
+ goto out;
}
}
- /* release lock here as op holds lock anyways */
- pthread_mutex_unlock(&q_lock);
/* Close both ANT channel */
- op(BT_VND_OP_ANT_USERIAL_CLOSE, NULL);
+ __op(BT_VND_OP_ANT_USERIAL_CLOSE, NULL);
#endif
/* Close both BT channel */
- op(BT_VND_OP_USERIAL_CLOSE, NULL);
+ __op(BT_VND_OP_USERIAL_CLOSE, NULL);
#ifdef FM_OVER_UART
- op(BT_VND_OP_FM_USERIAL_CLOSE, NULL);
+ __op(BT_VND_OP_FM_USERIAL_CLOSE, NULL);
#endif
/*CTRL OFF twice to make sure hw
* turns off*/
#ifdef ENABLE_ANT
- op(BT_VND_OP_POWER_CTRL, &pwr_state);
+ __op(BT_VND_OP_POWER_CTRL, &pwr_state);
#endif
#ifdef FM_OVER_UART
- op(BT_VND_OP_POWER_CTRL, &pwr_state);
+ __op(BT_VND_OP_POWER_CTRL, &pwr_state);
#endif
}
/*Generally switching of chip should be enough*/
- op(BT_VND_OP_POWER_CTRL, &pwr_state);
+ __op(BT_VND_OP_POWER_CTRL, &pwr_state);
+out:
+ pthread_mutex_unlock(&q_lock);
ALOGI("--%s", __FUNCTION__);
}