Promotion of bt.lnx.2.1-00032.

CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
1077744   Ibde0a038052ea5dff2fd4bdb6059d8e964d3cebd   Remove tcflush during BT_ON
1083234   I662e293431ecef1096ea69bfdc82190c6020ce90   Add ioctl to do power control ops for connectivity chips

Change-Id: If924df58eabbb3f15a25ec59b61b71679da3b6a2
CRs-Fixed: 1083234, 1077744
diff --git a/libbt-vendor/include/bt_vendor_qcom.h b/libbt-vendor/include/bt_vendor_qcom.h
index ac8d2fd..c71ce8a 100644
--- a/libbt-vendor/include/bt_vendor_qcom.h
+++ b/libbt-vendor/include/bt_vendor_qcom.h
@@ -63,6 +63,7 @@
 #define HCI_CMD_PREAMBLE_SIZE 3
 #define HCI_EVT_CMD_CMPL_STATUS_RET_BYTE   5
 #define HCI_EVT_CMD_CMPL_OPCODE        3
+#define BT_PWR_CNTRL_DEVICE    "/dev/btpower"
 
 enum {
     BT_STATUS_SUCCESS = 0,
@@ -71,7 +72,7 @@
     BT_STATUS_NOMEM,
     BT_STATUS_PROP_FAILURE,
 };
-
+#define BT_CMD_PWR_CTRL         0xbfad
 struct bt_qcom_struct {
     int fd[2];
     int ant_fd;
diff --git a/libbt-vendor/src/bt_vendor_qcom.c b/libbt-vendor/src/bt_vendor_qcom.c
index 278e897..d58df78 100644
--- a/libbt-vendor/src/bt_vendor_qcom.c
+++ b/libbt-vendor/src/bt_vendor_qcom.c
@@ -33,6 +33,7 @@
 #include "bt_vendor_qcom.h"
 #include "hci_uart.h"
 #include "hci_smd.h"
+#include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <cutils/sockets.h>
 #include <linux/un.h>
@@ -380,7 +381,7 @@
 {
     char rfkill_type[64], *enable_ldo_path = NULL;
     char type[16], enable_ldo[6];
-    int fd = 0, size, i, ret, fd_ldo;
+    int fd = 0, size, i, ret, fd_ldo, fd_btpower;
 
     char disable[PROPERTY_VALUE_MAX];
     char state;
@@ -489,20 +490,36 @@
         property_set("wc_transport.soc_initialized", "0");
     }
 
-    ALOGI("Write %c to rfkill\n", on);
-
-    /* Write value to control rfkill */
-    if(fd >= 0) {
-        if ((size = write(fd, &on, 1)) < 0) {
-            ALOGE("write(%s) failed: %s (%d)", q->rfkill_state, strerror(errno), errno);
+    if (q->soc_type >= BT_SOC_CHEROKEE && q->soc_type < BT_SOC_RESERVED) {
+       ALOGI("open bt power devnode,send ioctl power op  :%d ",en);
+       fd_btpower = open(BT_PWR_CNTRL_DEVICE, O_RDWR, O_NONBLOCK);
+       if (fd_btpower < 0) {
+           ALOGE("\nfailed to open bt device error = (%s)\n",strerror(errno));
 #ifdef WIFI_BT_STATUS_SYNC
-            bt_semaphore_release(lock_fd);
-            bt_semaphore_destroy(lock_fd);
+           bt_semaphore_release(lock_fd);
+           bt_semaphore_destroy(lock_fd);
 #endif
-            return -1;
+           return -1;
+       }
+       ret = ioctl(fd_btpower, BT_CMD_PWR_CTRL, (unsigned long)en);
+        if (ret < 0) {
+            ALOGE(" ioctl failed to power control:%d error =(%s)",ret,strerror(errno));
         }
-    }
-
+        close(fd_btpower);
+    } else {
+       ALOGI("Write %c to rfkill\n", on);
+       /* Write value to control rfkill */
+       if(fd >= 0) {
+           if ((size = write(fd, &on, 1)) < 0) {
+               ALOGE("write(%s) failed: %s (%d)", q->rfkill_state, strerror(errno), errno);
+#ifdef WIFI_BT_STATUS_SYNC
+               bt_semaphore_release(lock_fd);
+               bt_semaphore_destroy(lock_fd);
+#endif
+               return -1;
+           }
+       }
+   }
 #ifdef WIFI_BT_STATUS_SYNC
     /* query wifi status */
     property_get(WIFI_PROP_NAME, wifi_status, "");
@@ -545,7 +562,6 @@
 done:
     if (fd >= 0)
         close(fd);
-
     return 0;
 }
 
diff --git a/libbt-vendor/src/hw_rome.c b/libbt-vendor/src/hw_rome.c
index 56c3b9a..ccfb137 100644
--- a/libbt-vendor/src/hw_rome.c
+++ b/libbt-vendor/src/hw_rome.c
@@ -1456,7 +1456,7 @@
 
     /* Total length of the packet to be sent to the Controller */
     size = (HCI_CMD_IND + HCI_COMMAND_HDR_SIZE + VSC_SET_BAUDRATE_REQ_LEN);
-    tcflush(fd,TCIOFLUSH);
+
     /* Flow off during baudrate change */
     if ((err = userial_vendor_ioctl(USERIAL_OP_FLOW_OFF , &flags)) < 0)
     {