• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/broadcom/libbt


Commit MetaInfo

Revisióneb19c482b004ea1252427f9ed0962287a2889a8c (tree)
Tiempo2012-10-17 08:58:09
AutorYK Jeffrey Chao <jechao@broa...>
CommiterThe Android Automerger

Log Message

Add support of getting factory BDADDR from Controller's non-volatile memory(2/2)

When factory Bluetooth device address is stored in the BT Controller's
non-volatile memory (e.g. BCM4330 OTP memory) instead of devices's file system,
the BDADDR will be retrieved from the Controller while enabling Bluedroid core
stack.

Introduce USE_CONTROLLER_BDADDR preprocessor directive in the vendor lib.

After patchram download, check whether the BT Controller has a non-zero's BDADDR
stored in its non-volatile memory. If not, write BTIF's init BDADDR to the
Controller.

bug 7340441

Change-Id: I2414b9479d4ef93ffd20c7ccc4875aab009e7cc8

Cambiar Resumen

Diferencia incremental

--- a/include/bt_vendor_brcm.h
+++ b/include/bt_vendor_brcm.h
@@ -82,6 +82,24 @@
8282 #define FW_PATCH_SETTLEMENT_DELAY_MS 0
8383 #endif
8484
85+/* The Bluetooth Device Aaddress source switch:
86+ *
87+ * -FALSE- (default value)
88+ * Get the factory BDADDR from device's file system. Normally the BDADDR is
89+ * stored in the location pointed by the PROPERTY_BT_BDADDR_PATH (defined in
90+ * btif_common.h file) property.
91+ *
92+ * -TRUE-
93+ * If the Bluetooth Controller has equipped with a non-volatile memory (such
94+ * as BCM4330's OTP memory), the factory BDADDR can be stored in there and
95+ * retrieved by the stack while enabling BT.
96+ * !!! WARNING !!! Make sure that the OTP feature has been enabled in the
97+ * firmware patchram (.hcd) file.
98+ */
99+#ifndef USE_CONTROLLER_BDADDR
100+#define USE_CONTROLLER_BDADDR FALSE
101+#endif
102+
85103 /* sleep mode
86104
87105 0: disable
--- a/include/vnd_grouper.txt
+++ b/include/vnd_grouper.txt
@@ -7,3 +7,4 @@ BTHW_DBG = TRUE
77 VNDUSERIAL_DBG = FALSE
88 UPIO_DBG = FALSE
99 SCO_PCM_IF_CLOCK_RATE = 2
10+USE_CONTROLLER_BDADDR = TRUE
--- a/include/vnd_tilapia.txt
+++ b/include/vnd_tilapia.txt
@@ -7,3 +7,4 @@ BTHW_DBG = TRUE
77 VNDUSERIAL_DBG = FALSE
88 UPIO_DBG = FALSE
99 SCO_PCM_IF_CLOCK_RATE = 2
10+USE_CONTROLLER_BDADDR = TRUE
--- a/src/hardware.c
+++ b/src/hardware.c
@@ -77,9 +77,11 @@
7777 #define HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM 0xFC1E
7878 #define HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM 0xFC6D
7979 #define HCI_VSC_LAUNCH_RAM 0xFC4E
80+#define HCI_READ_LOCAL_BDADDR 0x1009
8081
8182 #define HCI_EVT_CMD_CMPL_STATUS_RET_BYTE 5
8283 #define HCI_EVT_CMD_CMPL_LOCAL_NAME_STRING 6
84+#define HCI_EVT_CMD_CMPL_LOCAL_BDADDR_ARRAY 6
8385 #define HCI_EVT_CMD_CMPL_OPCODE 3
8486 #define LPM_CMD_PARAM_SIZE 12
8587 #define UPDATE_BAUDRATE_CMD_PARAM_SIZE 6
@@ -107,6 +109,9 @@ enum {
107109 HW_CFG_DL_FW_PATCH,
108110 HW_CFG_SET_UART_BAUD_2,
109111 HW_CFG_SET_BD_ADDR
112+#if (USE_CONTROLLER_BDADDR == TRUE)
113+ , HW_CFG_READ_BD_ADDR
114+#endif
110115 };
111116
112117 /* h/w config control block */
@@ -534,6 +539,35 @@ static uint8_t hw_config_set_bdaddr(HC_BT_HDR *p_buf)
534539 return (retval);
535540 }
536541
542+#if (USE_CONTROLLER_BDADDR == TRUE)
543+/*******************************************************************************
544+**
545+** Function hw_config_read_bdaddr
546+**
547+** Description Read controller's Bluetooth Device Address
548+**
549+** Returns TRUE, if valid address is sent
550+** FALSE, otherwise
551+**
552+*******************************************************************************/
553+static uint8_t hw_config_read_bdaddr(HC_BT_HDR *p_buf)
554+{
555+ uint8_t retval = FALSE;
556+ uint8_t *p = (uint8_t *) (p_buf + 1);
557+
558+ UINT16_TO_STREAM(p, HCI_READ_LOCAL_BDADDR);
559+ *p = 0; /* parameter length */
560+
561+ p_buf->len = HCI_CMD_PREAMBLE_SIZE;
562+ hw_cfg_cb.state = HW_CFG_READ_BD_ADDR;
563+
564+ retval = bt_vendor_cbacks->xmit_cb(HCI_READ_LOCAL_BDADDR, p_buf, \
565+ hw_config_cback);
566+
567+ return (retval);
568+}
569+#endif // (USE_CONTROLLER_BDADDR == TRUE)
570+
537571 /*******************************************************************************
538572 **
539573 ** Function hw_config_cback
@@ -552,6 +586,9 @@ void hw_config_cback(void *p_mem)
552586 HC_BT_HDR *p_buf=NULL;
553587 uint8_t is_proceeding = FALSE;
554588 int i;
589+#if (USE_CONTROLLER_BDADDR == TRUE)
590+ const uint8_t null_bdaddr[BD_ADDR_LEN] = {0,0,0,0,0,0};
591+#endif
555592
556593 status = *((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE);
557594 p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE;
@@ -735,9 +772,13 @@ void hw_config_cback(void *p_mem)
735772 line_speed_to_userial_baud(UART_TARGET_BAUD_RATE) \
736773 );
737774
775+#if (USE_CONTROLLER_BDADDR == TRUE)
776+ if ((is_proceeding = hw_config_read_bdaddr(p_buf)) == TRUE)
777+ break;
778+#else
738779 if ((is_proceeding = hw_config_set_bdaddr(p_buf)) == TRUE)
739780 break;
740-
781+#endif
741782 /* fall through intentionally */
742783 case HW_CFG_SET_BD_ADDR:
743784 ALOGI("vendor lib fwcfg completed");
@@ -754,6 +795,41 @@ void hw_config_cback(void *p_mem)
754795
755796 is_proceeding = TRUE;
756797 break;
798+
799+#if (USE_CONTROLLER_BDADDR == TRUE)
800+ case HW_CFG_READ_BD_ADDR:
801+ p_tmp = (char *) (p_evt_buf + 1) + \
802+ HCI_EVT_CMD_CMPL_LOCAL_BDADDR_ARRAY;
803+
804+ if (memcmp(p_tmp, null_bdaddr, BD_ADDR_LEN) == 0)
805+ {
806+ // Controller does not have a valid OTP BDADDR!
807+ // Set the BTIF initial BDADDR instead.
808+ if ((is_proceeding = hw_config_set_bdaddr(p_buf)) == TRUE)
809+ break;
810+ }
811+ else
812+ {
813+ ALOGI("Controller OTP bdaddr %02X:%02X:%02X:%02X:%02X:%02X",
814+ *(p_tmp+5), *(p_tmp+4), *(p_tmp+3),
815+ *(p_tmp+2), *(p_tmp+1), *p_tmp);
816+ }
817+
818+ ALOGI("vendor lib fwcfg completed");
819+ bt_vendor_cbacks->dealloc(p_buf);
820+ bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS);
821+
822+ hw_cfg_cb.state = 0;
823+
824+ if (hw_cfg_cb.fw_fd != -1)
825+ {
826+ close(hw_cfg_cb.fw_fd);
827+ hw_cfg_cb.fw_fd = -1;
828+ }
829+
830+ is_proceeding = TRUE;
831+ break;
832+#endif // (USE_CONTROLLER_BDADDR == TRUE)
757833 } // switch(hw_cfg_cb.state)
758834 } // if (p_buf != NULL)
759835