hardware/broadcom/libbt
Revisión | eb19c482b004ea1252427f9ed0962287a2889a8c (tree) |
---|---|
Tiempo | 2012-10-17 08:58:09 |
Autor | YK Jeffrey Chao <jechao@broa...> |
Commiter | The Android Automerger |
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
@@ -82,6 +82,24 @@ | ||
82 | 82 | #define FW_PATCH_SETTLEMENT_DELAY_MS 0 |
83 | 83 | #endif |
84 | 84 | |
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 | + | |
85 | 103 | /* sleep mode |
86 | 104 | |
87 | 105 | 0: disable |
@@ -7,3 +7,4 @@ BTHW_DBG = TRUE | ||
7 | 7 | VNDUSERIAL_DBG = FALSE |
8 | 8 | UPIO_DBG = FALSE |
9 | 9 | SCO_PCM_IF_CLOCK_RATE = 2 |
10 | +USE_CONTROLLER_BDADDR = TRUE |
@@ -7,3 +7,4 @@ BTHW_DBG = TRUE | ||
7 | 7 | VNDUSERIAL_DBG = FALSE |
8 | 8 | UPIO_DBG = FALSE |
9 | 9 | SCO_PCM_IF_CLOCK_RATE = 2 |
10 | +USE_CONTROLLER_BDADDR = TRUE |
@@ -77,9 +77,11 @@ | ||
77 | 77 | #define HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM 0xFC1E |
78 | 78 | #define HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM 0xFC6D |
79 | 79 | #define HCI_VSC_LAUNCH_RAM 0xFC4E |
80 | +#define HCI_READ_LOCAL_BDADDR 0x1009 | |
80 | 81 | |
81 | 82 | #define HCI_EVT_CMD_CMPL_STATUS_RET_BYTE 5 |
82 | 83 | #define HCI_EVT_CMD_CMPL_LOCAL_NAME_STRING 6 |
84 | +#define HCI_EVT_CMD_CMPL_LOCAL_BDADDR_ARRAY 6 | |
83 | 85 | #define HCI_EVT_CMD_CMPL_OPCODE 3 |
84 | 86 | #define LPM_CMD_PARAM_SIZE 12 |
85 | 87 | #define UPDATE_BAUDRATE_CMD_PARAM_SIZE 6 |
@@ -107,6 +109,9 @@ enum { | ||
107 | 109 | HW_CFG_DL_FW_PATCH, |
108 | 110 | HW_CFG_SET_UART_BAUD_2, |
109 | 111 | HW_CFG_SET_BD_ADDR |
112 | +#if (USE_CONTROLLER_BDADDR == TRUE) | |
113 | + , HW_CFG_READ_BD_ADDR | |
114 | +#endif | |
110 | 115 | }; |
111 | 116 | |
112 | 117 | /* h/w config control block */ |
@@ -534,6 +539,35 @@ static uint8_t hw_config_set_bdaddr(HC_BT_HDR *p_buf) | ||
534 | 539 | return (retval); |
535 | 540 | } |
536 | 541 | |
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 | + | |
537 | 571 | /******************************************************************************* |
538 | 572 | ** |
539 | 573 | ** Function hw_config_cback |
@@ -552,6 +586,9 @@ void hw_config_cback(void *p_mem) | ||
552 | 586 | HC_BT_HDR *p_buf=NULL; |
553 | 587 | uint8_t is_proceeding = FALSE; |
554 | 588 | 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 | |
555 | 592 | |
556 | 593 | status = *((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE); |
557 | 594 | p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE; |
@@ -735,9 +772,13 @@ void hw_config_cback(void *p_mem) | ||
735 | 772 | line_speed_to_userial_baud(UART_TARGET_BAUD_RATE) \ |
736 | 773 | ); |
737 | 774 | |
775 | +#if (USE_CONTROLLER_BDADDR == TRUE) | |
776 | + if ((is_proceeding = hw_config_read_bdaddr(p_buf)) == TRUE) | |
777 | + break; | |
778 | +#else | |
738 | 779 | if ((is_proceeding = hw_config_set_bdaddr(p_buf)) == TRUE) |
739 | 780 | break; |
740 | - | |
781 | +#endif | |
741 | 782 | /* fall through intentionally */ |
742 | 783 | case HW_CFG_SET_BD_ADDR: |
743 | 784 | ALOGI("vendor lib fwcfg completed"); |
@@ -754,6 +795,41 @@ void hw_config_cback(void *p_mem) | ||
754 | 795 | |
755 | 796 | is_proceeding = TRUE; |
756 | 797 | 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) | |
757 | 833 | } // switch(hw_cfg_cb.state) |
758 | 834 | } // if (p_buf != NULL) |
759 | 835 |