diff options
43 files changed, 1588 insertions, 3562 deletions
diff --git a/conf/Android.mk b/conf/Android.mk index 816757f..22d03d7 100755 --- a/conf/Android.mk +++ b/conf/Android.mk @@ -4,36 +4,25 @@ include $(CLEAR_VARS) LOCAL_MODULE := bt_stack.conf LOCAL_MODULE_CLASS := ETC LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth -LOCAL_MODULE_TAGS := eng +LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) + include $(CLEAR_VARS) LOCAL_MODULE := bt_did.conf LOCAL_MODULE_CLASS := ETC LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth -LOCAL_MODULE_TAGS := eng -LOCAL_SRC_FILES := $(LOCAL_MODULE) +LOCAL_MODULE_TAGS := optional +LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) + include $(CLEAR_VARS) LOCAL_MODULE := auto_pair_devlist.conf LOCAL_MODULE_CLASS := ETC LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth -LOCAL_MODULE_TAGS := eng +LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) -ifeq ($(TARGET_PRODUCT), full_maguro) - include $(LOCAL_PATH)/samsung/maguro/Android.mk -endif -ifeq ($(TARGET_PRODUCT), full_crespo) - include $(LOCAL_PATH)/samsung/crespo/Android.mk -endif -ifeq ($(TARGET_PRODUCT), full_crespo4g) - include $(LOCAL_PATH)/samsung/crespo4g/Android.mk -endif -ifeq ($(TARGET_PRODUCT), full_wingray) - include $(LOCAL_PATH)/moto/wingray/Android.mk -endif - diff --git a/conf/bt_stack.conf b/conf/bt_stack.conf index c64e538..0b16be4 100644 --- a/conf/bt_stack.conf +++ b/conf/bt_stack.conf @@ -1,3 +1,10 @@ +# Enable BtSnoop logging function +# valid value : true, false +BtSnoopLogOutput=false + +# BtSnoop log output file +BtSnoopFileName=/sdcard/btsnoop_hci.log + # Enable trace level reconfiguration function # Must be present before any TRC_ trace level settings TraceConf=true diff --git a/conf/moto/wingray/Android.mk b/conf/moto/wingray/Android.mk deleted file mode 100644 index 974e213..0000000 --- a/conf/moto/wingray/Android.mk +++ /dev/null @@ -1,14 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := bt_vendor.conf -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth - -LOCAL_MODULE_TAGS := eng - -LOCAL_SRC_FILES := $(LOCAL_MODULE) - -include $(BUILD_PREBUILT) - diff --git a/conf/moto/wingray/bt_vendor.conf b/conf/moto/wingray/bt_vendor.conf deleted file mode 100644 index 2d4f0e7..0000000 --- a/conf/moto/wingray/bt_vendor.conf +++ /dev/null @@ -1,48 +0,0 @@ -# UART device port where Bluetooth controller is attached -UartPort = /dev/ttyHS2 - -# Firmware patch file location -FwPatchFilePath = /etc/firmware/ - -# Enable/Disable debug mode of libbt-vendor.so library -# The main key turns on/off debug modes of the whole library -# valid value : true, false -EnableDebug = true - -# The sub-key to enable/disable BtSnoop logging function -# The key is masked off if EnableDebug is false -# valid value : true, false -BtSnoopLogOutput = false - -# BtSnoop log output file -BtSnoopFileName = /sdcard/btsnoop_hci.log - -# The sub-key to enable/disable trace output of main vendor lib module -# The key is masked off if EnableDebug is false -# valid value : true, false -VndDebug = true - -# The sub-key to enable/disable trace output of hardware.c module -# The key is masked off if EnableDebug is false -# valid value : true, false -HwDebug = true - -# The sub-key to enable/disable trace output of userial module -# The key is masked off if EnableDebug is false -# valid value : true, false -UserialDebug = false - -# The sub-key to enable/disable trace output of Transport (e.g. H4) module -# The key is masked off if EnableDebug is false -# valid value : true, false -HciDebug = false - -# The sub-key to enable/disable trace output of upio module -# The key is masked off if EnableDebug is false -# valid value : true, false -UpioDebug = false - -# The sub-key to enable/disable debugging in BtSnoop module -# The key is masked off if EnableDebug is false -# valid value : true, false -BtSnoopDebug = false diff --git a/conf/samsung/crespo/Android.mk b/conf/samsung/crespo/Android.mk deleted file mode 100644 index 974e213..0000000 --- a/conf/samsung/crespo/Android.mk +++ /dev/null @@ -1,14 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := bt_vendor.conf -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth - -LOCAL_MODULE_TAGS := eng - -LOCAL_SRC_FILES := $(LOCAL_MODULE) - -include $(BUILD_PREBUILT) - diff --git a/conf/samsung/crespo/bt_vendor.conf b/conf/samsung/crespo/bt_vendor.conf deleted file mode 100644 index 0c4910c..0000000 --- a/conf/samsung/crespo/bt_vendor.conf +++ /dev/null @@ -1,48 +0,0 @@ -# UART device port where Bluetooth controller is attached -UartPort = /dev/s3c2410_serial0 - -# Firmware patch file location -FwPatchFilePath = /vendor/firmware/ - -# Enable/Disable debug mode of libbt-vendor.so library -# The main key turns on/off debug modes of the whole library -# valid value : true, false -EnableDebug = true - -# The sub-key to enable/disable BtSnoop logging function -# The key is masked off if EnableDebug is false -# valid value : true, false -BtSnoopLogOutput = false - -# BtSnoop log output file -BtSnoopFileName = /sdcard/btsnoop_hci.log - -# The sub-key to enable/disable trace output of main vendor lib module -# The key is masked off if EnableDebug is false -# valid value : true, false -VndDebug = false - -# The sub-key to enable/disable trace output of hardware.c module -# The key is masked off if EnableDebug is false -# valid value : true, false -HwDebug = false - -# The sub-key to enable/disable trace output of userial module -# The key is masked off if EnableDebug is false -# valid value : true, false -UserialDebug = false - -# The sub-key to enable/disable trace output of Transport (e.g. H4) module -# The key is masked off if EnableDebug is false -# valid value : true, false -HciDebug = false - -# The sub-key to enable/disable trace output of upio module -# The key is masked off if EnableDebug is false -# valid value : true, false -UpioDebug = false - -# The sub-key to enable/disable debugging in BtSnoop module -# The key is masked off if EnableDebug is false -# valid value : true, false -BtSnoopDebug = false diff --git a/conf/samsung/crespo4g/Android.mk b/conf/samsung/crespo4g/Android.mk deleted file mode 100644 index 974e213..0000000 --- a/conf/samsung/crespo4g/Android.mk +++ /dev/null @@ -1,14 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := bt_vendor.conf -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth - -LOCAL_MODULE_TAGS := eng - -LOCAL_SRC_FILES := $(LOCAL_MODULE) - -include $(BUILD_PREBUILT) - diff --git a/conf/samsung/crespo4g/bt_vendor.conf b/conf/samsung/crespo4g/bt_vendor.conf deleted file mode 100644 index 0c4910c..0000000 --- a/conf/samsung/crespo4g/bt_vendor.conf +++ /dev/null @@ -1,48 +0,0 @@ -# UART device port where Bluetooth controller is attached -UartPort = /dev/s3c2410_serial0 - -# Firmware patch file location -FwPatchFilePath = /vendor/firmware/ - -# Enable/Disable debug mode of libbt-vendor.so library -# The main key turns on/off debug modes of the whole library -# valid value : true, false -EnableDebug = true - -# The sub-key to enable/disable BtSnoop logging function -# The key is masked off if EnableDebug is false -# valid value : true, false -BtSnoopLogOutput = false - -# BtSnoop log output file -BtSnoopFileName = /sdcard/btsnoop_hci.log - -# The sub-key to enable/disable trace output of main vendor lib module -# The key is masked off if EnableDebug is false -# valid value : true, false -VndDebug = false - -# The sub-key to enable/disable trace output of hardware.c module -# The key is masked off if EnableDebug is false -# valid value : true, false -HwDebug = false - -# The sub-key to enable/disable trace output of userial module -# The key is masked off if EnableDebug is false -# valid value : true, false -UserialDebug = false - -# The sub-key to enable/disable trace output of Transport (e.g. H4) module -# The key is masked off if EnableDebug is false -# valid value : true, false -HciDebug = false - -# The sub-key to enable/disable trace output of upio module -# The key is masked off if EnableDebug is false -# valid value : true, false -UpioDebug = false - -# The sub-key to enable/disable debugging in BtSnoop module -# The key is masked off if EnableDebug is false -# valid value : true, false -BtSnoopDebug = false diff --git a/conf/samsung/maguro/Android.mk b/conf/samsung/maguro/Android.mk deleted file mode 100644 index 974e213..0000000 --- a/conf/samsung/maguro/Android.mk +++ /dev/null @@ -1,14 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := bt_vendor.conf -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/bluetooth - -LOCAL_MODULE_TAGS := eng - -LOCAL_SRC_FILES := $(LOCAL_MODULE) - -include $(BUILD_PREBUILT) - diff --git a/conf/samsung/maguro/bt_vendor.conf b/conf/samsung/maguro/bt_vendor.conf deleted file mode 100644 index b20482a..0000000 --- a/conf/samsung/maguro/bt_vendor.conf +++ /dev/null @@ -1,48 +0,0 @@ -# UART device port where Bluetooth controller is attached -UartPort = /dev/ttyO1 - -# Firmware patch file location -FwPatchFilePath = /vendor/firmware/ - -# Enable/Disable debug mode of libbt-vendor.so library -# The main key turns on/off debug modes of the whole library -# valid value : true, false -EnableDebug = true - -# The sub-key to enable/disable BtSnoop logging function -# The key is masked off if EnableDebug is false -# valid value : true, false -BtSnoopLogOutput = false - -# BtSnoop log output file -BtSnoopFileName = /sdcard/btsnoop_hci.log - -# The sub-key to enable/disable trace output of main vendor lib module -# The key is masked off if EnableDebug is false -# valid value : true, false -VndDebug = false - -# The sub-key to enable/disable trace output of hardware.c module -# The key is masked off if EnableDebug is false -# valid value : true, false -HwDebug = false - -# The sub-key to enable/disable trace output of userial module -# The key is masked off if EnableDebug is false -# valid value : true, false -UserialDebug = false - -# The sub-key to enable/disable trace output of Transport (e.g. H4) module -# The key is masked off if EnableDebug is false -# valid value : true, false -HciDebug = false - -# The sub-key to enable/disable trace output of upio module -# The key is masked off if EnableDebug is false -# valid value : true, false -UpioDebug = false - -# The sub-key to enable/disable debugging in BtSnoop module -# The key is masked off if EnableDebug is false -# valid value : true, false -BtSnoopDebug = false diff --git a/vendor/libvendor/Android.mk b/hci/Android.mk index 7d68356..a500538 100644 --- a/vendor/libvendor/Android.mk +++ b/hci/Android.mk @@ -3,25 +3,23 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := \ - src/bt_vendor_brcm.c \ + src/bt_hci_bdroid.c \ src/hci_h4.c \ src/userial.c \ - src/hardware.c \ - src/upio.c \ - src/utils.c \ + src/lpm.c \ + src/bt_hw.c \ src/btsnoop.c \ - src/conf.c + src/utils.c LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/include - + LOCAL_SHARED_LIBRARIES := \ - libcutils + libcutils \ + libbt-vendor -LOCAL_MODULE := libbt-vendor -LOCAL_MODULE_TAGS := eng +LOCAL_MODULE := libbt-hci +LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := SHARED_LIBRARIES -include $(LOCAL_PATH)/vnd_buildcfg.mk - include $(BUILD_SHARED_LIBRARY) diff --git a/vendor/libvendor/src/conf.c b/hci/include/bt_hci_bdroid.h index 61098ba..2345e74 100644 --- a/vendor/libvendor/src/conf.c +++ b/hci/include/bt_hci_bdroid.h @@ -47,153 +47,136 @@ /****************************************************************************** * - * Filename: conf.c + * Filename: bt_hci_bdroid.h * - * Description: Contains functions to conduct run-time module configuration - * based on entries present in the .conf file + * Description: A wrapper header file of bt_hci_lib.h + * + * Contains definitions specific for interfacing with Bluedroid + * Bluetooth stack * ******************************************************************************/ -#define LOG_TAG "bt_vnd_conf" +#ifndef BT_HCI_BDROID_H +#define BT_HCI_BDROID_H -#include <utils/Log.h> -#include <string.h> -#include "bt_vendor_brcm.h" +#include "bt_hci_lib.h" +//#include "hci_buildcfg.h" /****************************************************************************** -** Externs +** Constants & Macros ******************************************************************************/ -int userial_set_port(char *p_conf_name, char *p_conf_value, int param); -int hw_set_patch_file_path(char *p_conf_name, char *p_conf_value, int param); -int btsnoop_set_logfile(char *p_conf_name, char *p_conf_value, int param); -int btsnoop_enable_logging(char *p_conf_name, char *p_conf_value, int param); -int debug_cfg(char *p_conf_name, char *p_conf_value, int param); +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE (!FALSE) +#endif + +#ifndef BTHC_LINUX_BASE_POLICY +#define BTHC_LINUX_BASE_POLICY SCHED_NORMAL +#endif + +#if (BTHC_LINUX_BASE_POLICY != SCHED_NORMAL) +#ifndef BTHC_LINUX_BASE_PRIORITY +#define BTHC_LINUX_BASE_PRIORITY 30 +#endif + +#ifndef BTHC_USERIAL_READ_THREAD_PRIORITY +#define BTHC_USERIAL_READ_THREAD_PRIORITY (BTHC_LINUX_BASE_PRIORITY) +#endif + +#ifndef BTHC_MAIN_THREAD_PRIORITY +#define BTHC_MAIN_THREAD_PRIORITY (BTHC_LINUX_BASE_PRIORITY-1) +#endif +#endif // (BTHC_LINUX_BASE_POLICY != SCHED_NORMAL) + +#ifndef BTHC_USERIAL_READ_MEM_SIZE +#define BTHC_USERIAL_READ_MEM_SIZE (1024) +#endif + +#ifndef BTSNOOPDISP_INCLUDED +#define BTSNOOPDISP_INCLUDED TRUE +#endif + +/* Host/Controller lib internal event ID */ +#define HC_EVENT_PRELOAD 0x0001 +#define HC_EVENT_POSTLOAD 0x0002 +#define HC_EVENT_RX 0x0004 +#define HC_EVENT_TX 0x0008 +#define HC_EVENT_LPM_ENABLE 0x0010 +#define HC_EVENT_LPM_DISABLE 0x0020 +#define HC_EVENT_LPM_WAKE_DEVICE 0x0040 +#define HC_EVENT_LPM_ALLOW_SLEEP 0x0080 +#define HC_EVENT_LPM_IDLE_TIMEOUT 0x0100 +#define HC_EVENT_EXIT 0x0200 + +/* Message event mask across Host/Controller lib and stack */ +#define MSG_EVT_MASK 0xFF00 /* eq. BT_EVT_MASK */ +#define MSG_SUB_EVT_MASK 0x00FF /* eq. BT_SUB_EVT_MASK */ + +/* Message event ID passed from Host/Controller lib to stack */ +#define MSG_HC_TO_STACK_HCI_ERR 0x1300 /* eq. BT_EVT_TO_BTU_HCIT_ERR */ +#define MSG_HC_TO_STACK_HCI_ACL 0x1100 /* eq. BT_EVT_TO_BTU_HCI_ACL */ +#define MSG_HC_TO_STACK_HCI_SCO 0x1200 /* eq. BT_EVT_TO_BTU_HCI_SCO */ +#define MSG_HC_TO_STACK_HCI_EVT 0x1000 /* eq. BT_EVT_TO_BTU_HCI_EVT */ +#define MSG_HC_TO_STACK_L2C_SEG_XMIT 0x1900 /* eq. BT_EVT_TO_BTU_L2C_SEG_XMIT */ + +/* Message event ID passed from stack to vendor lib */ +#define MSG_STACK_TO_HC_HCI_ACL 0x2100 /* eq. BT_EVT_TO_LM_HCI_ACL */ +#define MSG_STACK_TO_HC_HCI_SCO 0x2200 /* eq. BT_EVT_TO_LM_HCI_SCO */ +#define MSG_STACK_TO_HC_HCI_CMD 0x2000 /* eq. BT_EVT_TO_LM_HCI_CMD */ + +/* Local Bluetooth Controller ID for BR/EDR */ +#define LOCAL_BR_EDR_CONTROLLER_ID 0 /****************************************************************************** -** Local type definitions +** Type definitions and return values ******************************************************************************/ -#define CONF_COMMENT '#' -#define CONF_DELIMITERS " =\n\r\t" -#define CONF_VALUES_DELIMITERS "=\n\r\t" -#define CONF_MAX_LINE_LEN 255 +typedef struct +{ + uint16_t event; + uint16_t len; + uint16_t offset; + uint16_t layer_specific; +} HC_BT_HDR; + +#define BT_HC_HDR_SIZE (sizeof(HC_BT_HDR)) -typedef int (conf_action_t)(char *p_conf_name, char *p_conf_value, int param); -typedef struct { - const char *conf_entry; - conf_action_t *p_action; - int param; -} conf_entry_t; +typedef struct _hc_buffer_hdr +{ + struct _hc_buffer_hdr *p_next; /* next buffer in the queue */ + uint8_t reserved1; + uint8_t reserved2; + uint8_t reserved3; + uint8_t reserved4; +} HC_BUFFER_HDR_T; + +#define BT_HC_BUFFER_HDR_SIZE (sizeof(HC_BUFFER_HDR_T)) /****************************************************************************** -** Static variables +** Extern variables and functions ******************************************************************************/ -/* - * Current supported entries and corresponding action functions - */ -static const conf_entry_t conf_table[] = { - {"UartPort", userial_set_port, 0}, - {"FwPatchFilePath", hw_set_patch_file_path, 0}, - {"EnableDebug", debug_cfg, DEBUG_ON}, - {"BtSnoopLogOutput", btsnoop_enable_logging, 0}, - {"BtSnoopFileName", btsnoop_set_logfile, 0}, - {"VndDebug", debug_cfg, TRACE_VND}, - {"HwDebug", debug_cfg, TRACE_HW}, - {"UserialDebug", debug_cfg, TRACE_USERIAL}, - {"HciDebug", debug_cfg, TRACE_HCI}, - {"UpioDebug", debug_cfg, TRACE_UPIO}, - {"BtSnoopDebug", debug_cfg, TRACE_BTSNOOP}, - {(const char *) NULL, NULL, 0} -}; - -int debug_cfg(char *p_conf_name, char *p_conf_value, int param) -{ - uint8_t enabled = (strcmp(p_conf_value, "true") == 0) ? 1 : 0; - - if (param == DEBUG_ON) - { - dbg_mode = (enabled == 1) ? DEBUG_ON : DEBUG_OFF; - } - else - { - if (enabled == 1) - traces |= (1 << param); - else - traces &= ~(1 << param); - } - - return 0; -} - -/***************************************************************************** -** CONF INTERFACE FUNCTIONS -*****************************************************************************/ +extern bt_hc_callbacks_t *bt_hc_cbacks; + +/****************************************************************************** +** Functions +******************************************************************************/ /******************************************************************************* ** -** Function vnd_load_conf +** Function bthc_signal_event ** -** Description Read conf entry from p_path file one by one and call -** the corresponding config function +** Description Perform context switch to bt_hc main thread ** ** Returns None ** *******************************************************************************/ -void vnd_load_conf(const char *p_path) -{ - FILE *p_file; - char *p_name; - char *p_value; - conf_entry_t *p_entry; - char line[CONF_MAX_LINE_LEN+1]; /* add 1 for \0 char */ - - LOGI("Attempt to load conf from %s", p_path); - - if ((p_file = fopen(p_path, "r")) != NULL) - { - /* read line by line */ - while (fgets(line, CONF_MAX_LINE_LEN+1, p_file) != NULL) - { - if (line[0] == CONF_COMMENT) - continue; - - p_name = strtok(line, CONF_DELIMITERS); - - if (NULL == p_name) - { - continue; - } - - p_value = strtok(NULL, CONF_DELIMITERS); - - if (NULL == p_value) - { - LOGW("vnd_load_conf: missing value for name: %s", p_name); - continue; - } - - p_entry = (conf_entry_t *)conf_table; - - while (p_entry->conf_entry != NULL) - { - if (strcmp(p_entry->conf_entry, (const char *)p_name) == 0) - { - p_entry->p_action(p_name, p_value, p_entry->param); - break; - } - - p_entry++; - } - } - - fclose(p_file); - } - else - { - LOGI( "vnd_load_conf file >%s< not found", p_path); - } -} +extern void bthc_signal_event(uint16_t event); + +#endif /* BT_HCI_BDROID_H */ diff --git a/vendor/libvendor/include/bt_vendor_lib.h b/hci/include/bt_hci_lib.h index e727840..59feeb9 100644 --- a/vendor/libvendor/include/bt_vendor_lib.h +++ b/hci/include/bt_hci_lib.h @@ -3,50 +3,50 @@ * Copyright (C) 2009-2012 Broadcom Corporation * * This program is the proprietary software of Broadcom Corporation and/or its - * licensors, and may only be used, duplicated, modified or distributed - * pursuant to the terms and conditions of a separate, written license - * agreement executed between you and Broadcom (an "Authorized License"). - * Except as set forth in an Authorized License, Broadcom grants no license - * (express or implied), right to use, or waiver of any kind with respect to - * the Software, and Broadcom expressly reserves all rights in and to the - * Software and all intellectual property rights therein. - * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS - * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE - * ALL USE OF THE SOFTWARE. + * licensors, and may only be used, duplicated, modified or distributed + * pursuant to the terms and conditions of a separate, written license + * agreement executed between you and Broadcom (an "Authorized License"). + * Except as set forth in an Authorized License, Broadcom grants no license + * (express or implied), right to use, or waiver of any kind with respect to + * the Software, and Broadcom expressly reserves all rights in and to the + * Software and all intellectual property rights therein. + * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS + * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE + * ALL USE OF THE SOFTWARE. * * Except as expressly set forth in the Authorized License, * - * 1. This program, including its structure, sequence and organization, - * constitutes the valuable trade secrets of Broadcom, and you shall - * use all reasonable efforts to protect the confidentiality thereof, - * and to use this information only in connection with your use of + * 1. This program, including its structure, sequence and organization, + * constitutes the valuable trade secrets of Broadcom, and you shall + * use all reasonable efforts to protect the confidentiality thereof, + * and to use this information only in connection with your use of * Broadcom integrated circuit products. * - * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED - * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, - * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, - * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY - * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, - * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, - * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, + * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT * OF USE OR PERFORMANCE OF THE SOFTWARE. * * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR - * ITS LICENSORS BE LIABLE FOR - * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY - * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO - * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM - * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR - * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE - * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE - * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF + * ITS LICENSORS BE LIABLE FOR + * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY + * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO + * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR + * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE + * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE + * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. * ******************************************************************************/ -#ifndef BT_VENDOR_LIB_H -#define BT_VENDOR_LIB_H +#ifndef BT_HCI_LIB_H +#define BT_HCI_LIB_H #include <stdint.h> #include <sys/cdefs.h> @@ -62,17 +62,17 @@ typedef void* TRANSAC; /** Bluetooth Power Control States */ typedef enum { - BT_VENDOR_CHIP_PWR_OFF, - BT_VENDOR_CHIP_PWR_ON, -} bt_vendor_chip_power_state_t; + BT_HC_CHIP_PWR_OFF, + BT_HC_CHIP_PWR_ON, +} bt_hc_chip_power_state_t; /** Bluetooth Low Power Mode */ typedef enum { - BT_VENDOR_LPM_DISABLE, - BT_VENDOR_LPM_ENABLE, - BT_VENDOR_LPM_WAKE_ASSERT, - BT_VENDOR_LPM_WAKE_DEASSERT, -} bt_vendor_low_power_event_t; + BT_HC_LPM_DISABLE, + BT_HC_LPM_ENABLE, + BT_HC_LPM_WAKE_ASSERT, + BT_HC_LPM_WAKE_DEASSERT, +} bt_hc_low_power_event_t; /** Receive flow control */ typedef enum { @@ -80,59 +80,65 @@ typedef enum { BT_RXFLOW_ON, /* remove transport device to from select set */ } bt_rx_flow_state_t; +/** HCI logging control */ +typedef enum { + BT_HC_LOGGING_OFF, + BT_HC_LOGGING_ON, +} bt_hc_logging_state_t; + /** Result of write request */ typedef enum { - BT_VENDOR_TX_SUCCESS, /* a buffer is fully processed and can be released */ - BT_VENDOR_TX_FAIL, /* transmit fail */ - BT_VENDOR_TX_FRAGMENT, /* send split ACL pkt back to stack to reprocess */ -} bt_vendor_transmit_result_t; + BT_HC_TX_SUCCESS, /* a buffer is fully processed and can be released */ + BT_HC_TX_FAIL, /* transmit fail */ + BT_HC_TX_FRAGMENT, /* send split ACL pkt back to stack to reprocess */ +} bt_hc_transmit_result_t; /** Result of preload initialization */ typedef enum { - BT_VENDOR_PRELOAD_SUCCESS, - BT_VENDOR_PRELOAD_FAIL, -} bt_vendor_preload_result_t; + BT_HC_PRELOAD_SUCCESS, + BT_HC_PRELOAD_FAIL, +} bt_hc_preload_result_t; /** Result of postload initialization */ typedef enum { - BT_VENDOR_POSTLOAD_SUCCESS, - BT_VENDOR_POSTLOAD_FAIL, -} bt_vendor_postload_result_t; + BT_HC_POSTLOAD_SUCCESS, + BT_HC_POSTLOAD_FAIL, +} bt_hc_postload_result_t; /** Result of low power enable/disable request */ typedef enum { - BT_VENDOR_LPM_DISABLED, - BT_VENDOR_LPM_ENABLED, -} bt_vendor_lpm_request_result_t; + BT_HC_LPM_DISABLED, + BT_HC_LPM_ENABLED, +} bt_hc_lpm_request_result_t; -/** Vendor Library Return Status */ +/** Host/Controller Library Return Status */ typedef enum { - BT_VENDOR_STATUS_SUCCESS, - BT_VENDOR_STATUS_FAIL, - BT_VENDOR_STATUS_NOT_READY, - BT_VENDOR_STATUS_NOMEM, - BT_VENDOR_STATUS_BUSY, - BT_VENDOR_STATUS_CORRUPTED_BUFFER -} bt_vnd_status_t; + BT_HC_STATUS_SUCCESS, + BT_HC_STATUS_FAIL, + BT_HC_STATUS_NOT_READY, + BT_HC_STATUS_NOMEM, + BT_HC_STATUS_BUSY, + BT_HC_STATUS_CORRUPTED_BUFFER +} bt_hc_status_t; /* Section comment */ /* - * Bluetooth Vendor callback structure. + * Bluetooth Host/Controller callback structure. */ /* called upon bt host wake signal */ -typedef void (*hostwake_ind_cb)(bt_vendor_low_power_event_t event); +typedef void (*hostwake_ind_cb)(bt_hc_low_power_event_t event); /* preload initialization callback */ -typedef void (*preload_result_cb)(TRANSAC transac, bt_vendor_preload_result_t result); +typedef void (*preload_result_cb)(TRANSAC transac, bt_hc_preload_result_t result); /* postload initialization callback */ -typedef void (*postload_result_cb)(TRANSAC transac, bt_vendor_postload_result_t result); +typedef void (*postload_result_cb)(TRANSAC transac, bt_hc_postload_result_t result); /* lpm enable/disable callback */ -typedef void (*lpm_result_cb)(bt_vendor_lpm_request_result_t result); +typedef void (*lpm_result_cb)(bt_hc_lpm_request_result_t result); /* datapath buffer allocation callback (callout) */ typedef char* (*alloc_mem_cb)(int size); @@ -141,24 +147,24 @@ typedef char* (*alloc_mem_cb)(int size); typedef int (*dealloc_mem_cb)(TRANSAC transac, char *p_buf); /* transmit result callback */ -typedef int (*tx_result_cb)(TRANSAC transac, char *p_buf, bt_vendor_transmit_result_t result); +typedef int (*tx_result_cb)(TRANSAC transac, char *p_buf, bt_hc_transmit_result_t result); -/* a previously setup buffer is read and available for processing +/* a previously setup buffer is read and available for processing buffer is deallocated in stack when processed */ typedef int (*data_ind_cb)(TRANSAC transac, char *p_buf, int len); typedef struct { - /** set to sizeof(bt_vendor_callbacks_t) */ + /** set to sizeof(bt_hc_callbacks_t) */ size_t size; /* notifies caller result of preload request */ - preload_result_cb preload_cb; + preload_result_cb preload_cb; /* notifies caller result of postload request */ - postload_result_cb postload_cb; + postload_result_cb postload_cb; /* notifies caller result of lpm enable/disable */ - lpm_result_cb lpm_cb; + lpm_result_cb lpm_cb; /* notifies hardware on host wake state */ hostwake_ind_cb hostwake_ind; @@ -174,26 +180,26 @@ typedef struct { /* notifies caller when a buffer is transmitted (or failed) */ tx_result_cb tx_result; -} bt_vendor_callbacks_t; +} bt_hc_callbacks_t; /* - * Bluetooth Vendor Interface + * Bluetooth Host/Controller Interface */ typedef struct { - /** Set to sizeof(bt_vendor_interface_t) */ + /** Set to sizeof(bt_hc_interface_t) */ size_t size; - + /** * Opens the interface and provides the callback routines * to the implemenation of this interface. */ - int (*init)(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr); + int (*init)(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr); /** Chip power control */ - void (*set_power)(bt_vendor_chip_power_state_t state); + void (*set_power)(bt_hc_chip_power_state_t state); /** Set low power mode wake */ - int (*lpm)(bt_vendor_low_power_event_t event); + int (*lpm)(bt_hc_low_power_event_t event); /** Called prior to stack initialization */ void (*preload)(TRANSAC transac); @@ -207,16 +213,19 @@ typedef struct { /** Controls receive flow */ int (*set_rxflow)(bt_rx_flow_state_t state); + /** Controls HCI logging on/off */ + int (*logging)(bt_hc_logging_state_t state, char *p_path); + /** Closes the interface */ void (*cleanup)( void ); -} bt_vendor_interface_t; +} bt_hc_interface_t; /* - * External shared lib functions + * External shared lib functions */ -extern const bt_vendor_interface_t* bt_vendor_get_interface(void); +extern const bt_hc_interface_t* bt_hc_get_interface(void); -#endif /* BT_VENDOR_LIB_H */ +#endif /* BT_HCI_LIB_H */ diff --git a/hci/include/bt_vendor_lib.h b/hci/include/bt_vendor_lib.h new file mode 100644 index 0000000..202acce --- /dev/null +++ b/hci/include/bt_vendor_lib.h @@ -0,0 +1,171 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * This program is the proprietary software of Broadcom Corporation and/or its + * licensors, and may only be used, duplicated, modified or distributed + * pursuant to the terms and conditions of a separate, written license + * agreement executed between you and Broadcom (an "Authorized License"). + * Except as set forth in an Authorized License, Broadcom grants no license + * (express or implied), right to use, or waiver of any kind with respect to + * the Software, and Broadcom expressly reserves all rights in and to the + * Software and all intellectual property rights therein. + * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS + * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE + * ALL USE OF THE SOFTWARE. + * + * Except as expressly set forth in the Authorized License, + * + * 1. This program, including its structure, sequence and organization, + * constitutes the valuable trade secrets of Broadcom, and you shall + * use all reasonable efforts to protect the confidentiality thereof, + * and to use this information only in connection with your use of + * Broadcom integrated circuit products. + * + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, + * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR + * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT + * OF USE OR PERFORMANCE OF THE SOFTWARE. + * + * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR + * ITS LICENSORS BE LIABLE FOR + * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY + * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO + * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR + * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE + * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE + * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF + * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. + * + ******************************************************************************/ + +#ifndef BT_VENDOR_LIB_H +#define BT_VENDOR_LIB_H + +#include <stdint.h> +#include <sys/cdefs.h> +#include <sys/types.h> + +/** Struct types */ + + +/** Typedefs and defines */ + +/** Vendor operations */ +typedef enum { + BT_VND_OP_POWER_CTRL, + BT_VND_OP_FW_CFG, + BT_VND_OP_SCO_CFG, + BT_VND_OP_USERIAL_OPEN, + BT_VND_OP_USERIAL_CLOSE, + BT_VND_OP_GET_LPM_IDLE_TIMEOUT, + BT_VND_OP_LPM_SET_MODE, + BT_VND_OP_LPM_WAKE_SET_STATE, +} bt_vendor_opcode_t; + +/** Power on/off control states */ +typedef enum { + BT_VND_PWR_OFF, + BT_VND_PWR_ON, +} bt_vendor_power_state_t; + +/** LPM WAKE set state request */ +typedef enum { + BT_VND_LPM_WAKE_ASSERT, + BT_VND_LPM_WAKE_DEASSERT, +} bt_vendor_lpm_wake_state_t; + +/** Result of vendor operations */ +typedef enum { + BT_VND_OP_RESULT_SUCCESS, + BT_VND_OP_RESULT_FAIL, +} bt_vendor_op_result_t; + +/** Userial control ID */ +typedef enum { + BT_VND_USERIAL_SET_BAUD, +} bt_vendor_userial_cid_t; + +/* + * Bluetooth Host/Controller Vendor callback structure. + */ + +/* vendor initialization/configuration callback */ +typedef void (*cfg_result_cb)(bt_vendor_op_result_t result); + +/* datapath buffer allocation callback (callout) */ +typedef void* (*malloc_cb)(int size); + +/* datapath buffer deallocation callback (callout) */ +typedef void (*mdealloc_cb)(void *p_buf); + +/* define callback of the cmd_xmit_cb */ +typedef void (*tINT_CMD_CBACK)(void *p_mem); + +/* hci command packet transmit callback (callout) */ +typedef uint8_t (*cmd_xmit_cb)(uint16_t opcode, void *p_buf, tINT_CMD_CBACK p_cback); + +/* userial control callback (callout) */ +typedef void (*userial_ctrl_cb)(bt_vendor_userial_cid_t cid, void *param); + +typedef struct { + /** set to sizeof(bt_vendor_callbacks_t) */ + size_t size; + + /* notifies caller result of firmware configuration request */ + cfg_result_cb fwcfg_cb; + + /* notifies caller result of sco configuration request */ + cfg_result_cb scocfg_cb; + + /* notifies caller result of lpm enable/disable */ + cfg_result_cb lpm_cb; + + /* buffer allocation request */ + malloc_cb alloc; + + /* buffer deallocation request */ + mdealloc_cb dealloc; + + /* hci command packet transmit request */ + cmd_xmit_cb xmit_cb; + + /* userial control request */ + userial_ctrl_cb usrl_ctrl_cb; +} bt_vendor_callbacks_t; + +/* + * Bluetooth Host/Controller VENDOR Interface + */ +typedef struct { + /** Set to sizeof(bt_vndor_interface_t) */ + size_t size; + + /** + * Opens the interface and provides the callback routines + * to the implemenation of this interface. + */ + int (*init)(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr); + + /** Vendor specific operations */ + int (*op)(bt_vendor_opcode_t opcode, void *param); + + /** Closes the interface */ + void (*cleanup)(void); +} bt_vendor_interface_t; + + +/* + * External shared lib functions + */ + +extern const bt_vendor_interface_t* bt_vendor_get_interface(void); + +#endif /* BT_VENDOR_LIB_H */ + diff --git a/vendor/libvendor/include/userial.h b/hci/include/userial.h index 818bb8f..db3a8cf 100644 --- a/vendor/libvendor/include/userial.h +++ b/hci/include/userial.h @@ -120,29 +120,8 @@ typedef enum { USERIAL_OP_INIT, USERIAL_OP_RXFLOW_ON, USERIAL_OP_RXFLOW_OFF, -#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) - USERIAL_OP_ASSERT_BT_WAKE, - USERIAL_OP_DEASSERT_BT_WAKE, - USERIAL_OP_GET_BT_WAKE_STATE -#endif } userial_ioctl_op_t; -#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) -/* These are the ioctl values used for bt_wake ioctl via UART driver. you may - * need to redefine them on you platform! - * Logically they need to be unique and not colide with existing uart ioctl's. - */ -#ifndef USERIAL_IOCTL_BT_WAKE_ASSERT -#define USERIAL_IOCTL_BT_WAKE_ASSERT 0x8003 -#endif -#ifndef USERIAL_IOCTL_BT_WAKE_DEASSERT -#define USERIAL_IOCTL_BT_WAKE_DEASSERT 0x8004 -#endif -#ifndef USERIAL_IOCTL_BT_WAKE_GET_ST -#define USERIAL_IOCTL_BT_WAKE_GET_ST 0x8005 -#endif -#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) - /****************************************************************************** ** Type definitions ******************************************************************************/ @@ -241,17 +220,5 @@ void userial_change_baud(uint8_t baud); *******************************************************************************/ void userial_ioctl(userial_ioctl_op_t op, void *p_data); -/******************************************************************************* -** -** Function userial_set_port -** -** Description Configure UART port name -** -** Returns 0 : Success -** Otherwise : Fail -** -*******************************************************************************/ -int userial_set_port(char *p_conf_name, char *p_conf_value, int param); - #endif /* USERIAL_H */ diff --git a/vendor/libvendor/include/utils.h b/hci/include/utils.h index 85800bf..85800bf 100644 --- a/vendor/libvendor/include/utils.h +++ b/hci/include/utils.h diff --git a/vendor/libvendor/src/bt_vendor_brcm.c b/hci/src/bt_hci_bdroid.c index c7de93e..7e075cb 100644 --- a/vendor/libvendor/src/bt_vendor_brcm.c +++ b/hci/src/bt_hci_bdroid.c @@ -3,125 +3,121 @@ * Copyright (C) 2009-2012 Broadcom Corporation * * This program is the proprietary software of Broadcom Corporation and/or its - * licensors, and may only be used, duplicated, modified or distributed - * pursuant to the terms and conditions of a separate, written license - * agreement executed between you and Broadcom (an "Authorized License"). - * Except as set forth in an Authorized License, Broadcom grants no license - * (express or implied), right to use, or waiver of any kind with respect to - * the Software, and Broadcom expressly reserves all rights in and to the - * Software and all intellectual property rights therein. - * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS + * licensors, and may only be used, duplicated, modified or distributed + * pursuant to the terms and conditions of a separate, written license + * agreement executed between you and Broadcom (an "Authorized License"). + * Except as set forth in an Authorized License, Broadcom grants no license + * (express or implied), right to use, or waiver of any kind with respect to + * the Software, and Broadcom expressly reserves all rights in and to the + * Software and all intellectual property rights therein. + * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE - * ALL USE OF THE SOFTWARE. + * ALL USE OF THE SOFTWARE. * * Except as expressly set forth in the Authorized License, * - * 1. This program, including its structure, sequence and organization, - * constitutes the valuable trade secrets of Broadcom, and you shall - * use all reasonable efforts to protect the confidentiality thereof, - * and to use this information only in connection with your use of + * 1. This program, including its structure, sequence and organization, + * constitutes the valuable trade secrets of Broadcom, and you shall + * use all reasonable efforts to protect the confidentiality thereof, + * and to use this information only in connection with your use of * Broadcom integrated circuit products. * - * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED - * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, - * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, - * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY - * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, - * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, - * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, + * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT * OF USE OR PERFORMANCE OF THE SOFTWARE. * * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR - * ITS LICENSORS BE LIABLE FOR - * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY - * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO - * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM - * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR - * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE - * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE - * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF + * ITS LICENSORS BE LIABLE FOR + * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY + * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO + * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR + * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE + * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE + * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. * ******************************************************************************/ /****************************************************************************** * - * Filename: bt_vendor_brcm.c + * Filename: bt_hci_bdroid.c * - * Description: Bluetooth vendor library implementation + * Description: Bluedroid Bluetooth Host/Controller interface library + * implementation * ******************************************************************************/ -#define LOG_TAG "bt_vendor_brcm" +#define LOG_TAG "bt_hci_bdroid" #include <utils/Log.h> #include <pthread.h> -#include "bt_vendor_brcm.h" -#include "upio.h" +#include "bt_hci_bdroid.h" +#include "bt_vendor_lib.h" #include "utils.h" #include "userial.h" -#ifndef BTVND_DBG -#define BTVND_DBG FALSE +#ifndef BTHC_DBG +#define BTHC_DBG FALSE #endif -#if (BTVND_DBG == TRUE) -#define BTVNDDBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_VND)) \ - LOGD(param, ## __VA_ARGS__);\ - } +#if (BTHC_DBG == TRUE) +#define BTHCDBG(param, ...) {LOGD(param, ## __VA_ARGS__);} #else -#define BTVNDDBG(param, ...) {} +#define BTHCDBG(param, ...) {} #endif /****************************************************************************** ** Externs ******************************************************************************/ +extern bt_vendor_interface_t *bt_vnd_if; extern int num_hci_cmd_pkts; void hci_h4_init(void); void hci_h4_cleanup(void); -void hci_h4_send_msg(VND_BT_HDR *p_msg); +void hci_h4_send_msg(HC_BT_HDR *p_msg); uint16_t hci_h4_receive_msg(void); void hci_h4_get_acl_data_length(void); -void hw_config_start(void); -uint8_t hw_lpm_enable(uint8_t turn_on); -void hw_lpm_deassert_bt_wake(void); -void hw_lpm_allow_bt_device_sleep(void); -void hw_lpm_assert_bt_wake(void); -#if (SCO_CFG_INCLUDED == TRUE) -void hw_sco_config(void); -#endif -void vnd_load_conf(const char *p_path); +void lpm_init(void); +void lpm_cleanup(void); +void lpm_enable(uint8_t turn_on); +void lpm_wake_deassert(void); +void lpm_allow_bt_device_sleep(void); +void lpm_wake_assert(void); +void init_vnd_if(unsigned char *local_bdaddr); +void btsnoop_open(char *p_path); +void btsnoop_close(void); /****************************************************************************** ** Variables ******************************************************************************/ -bt_vendor_callbacks_t *bt_vendor_cbacks = NULL; +bt_hc_callbacks_t *bt_hc_cbacks = NULL; BUFFER_Q tx_q; -/* By default, turn off debug mode */ -vnd_debug_t dbg_mode = 0; -vnd_debug_t traces = 0; - /****************************************************************************** ** Local type definitions ******************************************************************************/ -/* vendor lib thread control block */ +/* Host/Controller lib thread control block */ typedef struct { pthread_t worker_thread; pthread_mutex_t mutex; pthread_cond_t cond; -} bt_vnd_cb_t; +} bt_hc_cb_t; /****************************************************************************** ** Static Variables ******************************************************************************/ -static bt_vnd_cb_t vnd_cb; +static bt_hc_cb_t hc_cb; static volatile uint8_t lib_running = 0; static volatile uint16_t ready_events = 0; static volatile uint8_t tx_cmd_pkts_pending = FALSE; @@ -136,49 +132,45 @@ static const tUSERIAL_CFG userial_init_cfg = ** Functions ******************************************************************************/ -static void *bt_vndor_worker_thread(void *arg); +static void *bt_hc_worker_thread(void *arg); -void btvnd_signal_event(uint16_t event) +void bthc_signal_event(uint16_t event) { - pthread_mutex_lock(&vnd_cb.mutex); + pthread_mutex_lock(&hc_cb.mutex); ready_events |= event; - pthread_cond_signal(&vnd_cb.cond); - pthread_mutex_unlock(&vnd_cb.mutex); + pthread_cond_signal(&hc_cb.cond); + pthread_mutex_unlock(&hc_cb.mutex); } /***************************************************************************** ** -** BLUETOOTH VENDOR LIBRARY INTERFACE FUNCTIONS +** BLUETOOTH HOST/CONTROLLER INTERFACE LIBRARY FUNCTIONS ** *****************************************************************************/ -uint8_t vendor_local_bd_addr[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static int init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr) +static int init(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr) { pthread_attr_t thread_attr; struct sched_param param; - int policy; + int policy, result; LOGI("init"); if (p_cb == NULL) { LOGE("init failed with no user callbacks!"); - return BT_VENDOR_STATUS_FAIL; + return BT_HC_STATUS_FAIL; } - vnd_load_conf(VENDOR_LIB_CONF_FILE); - /* store reference to user callbacks */ - bt_vendor_cbacks = (bt_vendor_callbacks_t *) p_cb; + bt_hc_cbacks = (bt_hc_callbacks_t *) p_cb; - /* This is handed over from the stack */ - memcpy(vendor_local_bd_addr, local_bdaddr, 6); + init_vnd_if(local_bdaddr); utils_init(); - upio_init(); hci_h4_init(); userial_init(); + lpm_init(); utils_queue_init(&tx_q); @@ -189,82 +181,94 @@ static int init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr) lib_running = 1; ready_events = 0; - pthread_mutex_init(&vnd_cb.mutex, NULL); - pthread_cond_init(&vnd_cb.cond, NULL); + pthread_mutex_init(&hc_cb.mutex, NULL); + pthread_cond_init(&hc_cb.cond, NULL); pthread_attr_init(&thread_attr); - if (pthread_create(&vnd_cb.worker_thread, &thread_attr, \ - bt_vndor_worker_thread, NULL) != 0) + if (pthread_create(&hc_cb.worker_thread, &thread_attr, \ + bt_hc_worker_thread, NULL) != 0) { LOGE("pthread_create failed!"); lib_running = 0; - return BT_VENDOR_STATUS_FAIL; + return BT_HC_STATUS_FAIL; } - if(pthread_getschedparam(vnd_cb.worker_thread, &policy, ¶m)==0) + if(pthread_getschedparam(hc_cb.worker_thread, &policy, ¶m)==0) { - policy = SCHED_FIFO; - param.sched_priority = BTVND_MAIN_THREAD_PRIORITY; - pthread_setschedparam(vnd_cb.worker_thread, policy, ¶m); + policy = BTHC_LINUX_BASE_POLICY; +#if (BTHC_LINUX_BASE_POLICY!=SCHED_NORMAL) + param.sched_priority = BTHC_MAIN_THREAD_PRIORITY; +#endif + result = pthread_setschedparam(hc_cb.worker_thread, policy, ¶m); + if (result != 0) + { + LOGW("libbt-hci init: pthread_setschedparam failed (%s)", \ + strerror(result)); + } } - return BT_VENDOR_STATUS_SUCCESS; + return BT_HC_STATUS_SUCCESS; } /** Chip power control */ -static void set_power(bt_vendor_chip_power_state_t state) +static void set_power(bt_hc_chip_power_state_t state) { - BTVNDDBG("set_power %d", state); + int pwr_state; + + BTHCDBG("set_power %d", state); - if (state == BT_VENDOR_CHIP_PWR_OFF) - upio_set_bluetooth_power(UPIO_BT_POWER_OFF); - else if (state == BT_VENDOR_CHIP_PWR_ON) - upio_set_bluetooth_power(UPIO_BT_POWER_ON); + /* Calling vendor-specific part */ + pwr_state = (state == BT_HC_CHIP_PWR_ON) ? BT_VND_PWR_ON : BT_VND_PWR_OFF; + + if (bt_vnd_if) + bt_vnd_if->op(BT_VND_OP_POWER_CTRL, &pwr_state); + else + LOGE("vendor lib is missing!"); } /** Configure low power mode wake state */ -static int lpm(bt_vendor_low_power_event_t event) +static int lpm(bt_hc_low_power_event_t event) { uint8_t status = TRUE; switch (event) { - case BT_VENDOR_LPM_DISABLE: - btvnd_signal_event(VND_EVENT_LPM_DISABLE); + case BT_HC_LPM_DISABLE: + bthc_signal_event(HC_EVENT_LPM_DISABLE); break; - case BT_VENDOR_LPM_ENABLE: - btvnd_signal_event(VND_EVENT_LPM_ENABLE); + case BT_HC_LPM_ENABLE: + bthc_signal_event(HC_EVENT_LPM_ENABLE); break; - case BT_VENDOR_LPM_WAKE_ASSERT: - btvnd_signal_event(VND_EVENT_LPM_WAKE_DEVICE); + case BT_HC_LPM_WAKE_ASSERT: + bthc_signal_event(HC_EVENT_LPM_WAKE_DEVICE); break; - case BT_VENDOR_LPM_WAKE_DEASSERT: - btvnd_signal_event(VND_EVENT_LPM_ALLOW_SLEEP); + case BT_HC_LPM_WAKE_DEASSERT: + bthc_signal_event(HC_EVENT_LPM_ALLOW_SLEEP); break; } - return(status == TRUE) ? BT_VENDOR_STATUS_SUCCESS : BT_VENDOR_STATUS_FAIL; + return(status == TRUE) ? BT_HC_STATUS_SUCCESS : BT_HC_STATUS_FAIL; } /** Called prio to stack initialization */ static void preload(TRANSAC transac) { - BTVNDDBG("preload"); - btvnd_signal_event(VND_EVENT_PRELOAD); + BTHCDBG("preload"); + bthc_signal_event(HC_EVENT_PRELOAD); } /** Called post stack initialization */ static void postload(TRANSAC transac) { - BTVNDDBG("postload"); - btvnd_signal_event(VND_EVENT_POSTLOAD); + BTHCDBG("postload"); + bthc_signal_event(HC_EVENT_POSTLOAD); } @@ -273,48 +277,71 @@ static int transmit_buf(TRANSAC transac, char *p_buf, int len) { utils_enqueue(&tx_q, (void *) transac); - btvnd_signal_event(VND_EVENT_TX); + bthc_signal_event(HC_EVENT_TX); - return BT_VENDOR_STATUS_SUCCESS; + return BT_HC_STATUS_SUCCESS; } /** Controls receive flow */ static int set_rxflow(bt_rx_flow_state_t state) { - BTVNDDBG("set_rxflow %d", state); + BTHCDBG("set_rxflow %d", state); userial_ioctl(\ ((state == BT_RXFLOW_ON) ? USERIAL_OP_RXFLOW_ON : USERIAL_OP_RXFLOW_OFF), \ NULL); - return BT_VENDOR_STATUS_SUCCESS; + return BT_HC_STATUS_SUCCESS; +} + + +/** Controls HCI logging on/off */ +static int logging(bt_hc_logging_state_t state, char *p_path) +{ + BTHCDBG("logging %d", state); + + if (state == BT_HC_LOGGING_ON) + { + if (p_path != NULL) + btsnoop_open(p_path); + } + else + { + btsnoop_close(); + } + + return BT_HC_STATUS_SUCCESS; } /** Closes the interface */ static void cleanup( void ) { - BTVNDDBG("cleanup"); + BTHCDBG("cleanup"); if (lib_running) { lib_running = 0; - btvnd_signal_event(VND_EVENT_EXIT); - pthread_join(vnd_cb.worker_thread, NULL); + bthc_signal_event(HC_EVENT_EXIT); + pthread_join(hc_cb.worker_thread, NULL); } + lpm_cleanup(); userial_close(); hci_h4_cleanup(); - upio_cleanup(); utils_cleanup(); - bt_vendor_cbacks = NULL; + /* Calling vendor-specific part */ + if (bt_vnd_if) + bt_vnd_if->cleanup(); + + bt_hc_cbacks = NULL; } -static const bt_vendor_interface_t bluetoothVendorLibInterface = { - sizeof(bt_vendor_interface_t), +static const bt_hc_interface_t bluetoothHCLibInterface = { + sizeof(bt_hc_interface_t), init, set_power, lpm, @@ -322,39 +349,40 @@ static const bt_vendor_interface_t bluetoothVendorLibInterface = { postload, transmit_buf, set_rxflow, + logging, cleanup }; /******************************************************************************* ** -** Function bt_vndor_worker_thread +** Function bt_hc_worker_thread ** ** Description Mian worker thread ** ** Returns void * ** *******************************************************************************/ -static void *bt_vndor_worker_thread(void *arg) +static void *bt_hc_worker_thread(void *arg) { uint16_t events; - VND_BT_HDR *p_msg, *p_next_msg; + HC_BT_HDR *p_msg, *p_next_msg; - BTVNDDBG("bt_vndor_worker_thread started"); + BTHCDBG("bt_hc_worker_thread started"); tx_cmd_pkts_pending = FALSE; while (lib_running) { - pthread_mutex_lock(&vnd_cb.mutex); + pthread_mutex_lock(&hc_cb.mutex); while (ready_events == 0) { - pthread_cond_wait(&vnd_cb.cond, &vnd_cb.mutex); + pthread_cond_wait(&hc_cb.cond, &hc_cb.mutex); } events = ready_events; ready_events = 0; - pthread_mutex_unlock(&vnd_cb.mutex); + pthread_mutex_unlock(&hc_cb.mutex); - if (events & VND_EVENT_RX) + if (events & HC_EVENT_RX) { hci_h4_receive_msg(); @@ -362,32 +390,45 @@ static void *bt_vndor_worker_thread(void *arg) { /* Got HCI Cmd Credits from Controller. * Prepare to send prior pending Cmd packets in the - * following VND_EVENT_TX session. + * following HC_EVENT_TX session. */ - events |= VND_EVENT_TX; + events |= HC_EVENT_TX; } } - if (events & VND_EVENT_PRELOAD) + if (events & HC_EVENT_PRELOAD) { userial_open(USERIAL_PORT_1, (tUSERIAL_CFG *) &userial_init_cfg); - hw_config_start(); + + /* Calling vendor-specific part */ + if (bt_vnd_if) + { + bt_vnd_if->op(BT_VND_OP_FW_CFG, NULL); + } + else + { + if (bt_hc_cbacks) + bt_hc_cbacks->preload_cb(NULL, BT_HC_PRELOAD_FAIL); + } } - if (events & VND_EVENT_POSTLOAD) + if (events & HC_EVENT_POSTLOAD) { /* Start from SCO related H/W configuration, if SCO configuration * is required. Then, follow with reading requests of getting * ACL data length for both BR/EDR and LE. */ -#if (SCO_CFG_INCLUDED == TRUE) - hw_sco_config(); -#else - hci_h4_get_acl_data_length(); -#endif + int result = -1; + + /* Calling vendor-specific part */ + if (bt_vnd_if) + result = bt_vnd_if->op(BT_VND_OP_SCO_CFG, NULL); + + if (result == -1) + hci_h4_get_acl_data_length(); } - if (events & VND_EVENT_TX) + if (events & HC_EVENT_TX) { /* * We will go through every packets in the tx queue. @@ -398,7 +439,7 @@ static void *bt_vndor_worker_thread(void *arg) p_next_msg = tx_q.p_first; while (p_next_msg) { - if ((p_next_msg->event & MSG_EVT_MASK)==MSG_STACK_TO_VND_HCI_CMD) + if ((p_next_msg->event & MSG_EVT_MASK)==MSG_STACK_TO_HC_HCI_CMD) { /* * if we have used up controller's outstanding HCI command @@ -423,40 +464,40 @@ static void *bt_vndor_worker_thread(void *arg) } if (tx_cmd_pkts_pending == TRUE) - BTVNDDBG("Used up Tx Cmd credits"); + BTHCDBG("Used up Tx Cmd credits"); } - if (events & VND_EVENT_LPM_ENABLE) + if (events & HC_EVENT_LPM_ENABLE) { - hw_lpm_enable(TRUE); + lpm_enable(TRUE); } - if (events & VND_EVENT_LPM_DISABLE) + if (events & HC_EVENT_LPM_DISABLE) { - hw_lpm_enable(FALSE); + lpm_enable(FALSE); } - if (events & VND_EVENT_LPM_IDLE_TIMEOUT) + if (events & HC_EVENT_LPM_IDLE_TIMEOUT) { - hw_lpm_deassert_bt_wake(); + lpm_wake_deassert(); } - if (events & VND_EVENT_LPM_ALLOW_SLEEP) + if (events & HC_EVENT_LPM_ALLOW_SLEEP) { - hw_lpm_allow_bt_device_sleep(); + lpm_allow_bt_device_sleep(); } - if (events & VND_EVENT_LPM_WAKE_DEVICE) + if (events & HC_EVENT_LPM_WAKE_DEVICE) { - hw_lpm_assert_bt_wake(); + lpm_wake_assert(); } - if (events & VND_EVENT_EXIT) + if (events & HC_EVENT_EXIT) break; } - BTVNDDBG("bt_vndor_worker_thread exiting"); + BTHCDBG("bt_hc_worker_thread exiting"); pthread_exit(NULL); @@ -466,15 +507,15 @@ static void *bt_vndor_worker_thread(void *arg) /******************************************************************************* ** -** Function bt_vendor_get_interface +** Function bt_hc_get_interface ** ** Description Caller calls this function to get API instance ** ** Returns API table ** *******************************************************************************/ -const bt_vendor_interface_t *bt_vendor_get_interface(void) +const bt_hc_interface_t *bt_hc_get_interface(void) { - return &bluetoothVendorLibInterface; + return &bluetoothHCLibInterface; } diff --git a/hci/src/bt_hw.c b/hci/src/bt_hw.c new file mode 100644 index 0000000..1c4a20f --- /dev/null +++ b/hci/src/bt_hw.c @@ -0,0 +1,250 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * This program is the proprietary software of Broadcom Corporation and/or its + * licensors, and may only be used, duplicated, modified or distributed + * pursuant to the terms and conditions of a separate, written license + * agreement executed between you and Broadcom (an "Authorized License"). + * Except as set forth in an Authorized License, Broadcom grants no license + * (express or implied), right to use, or waiver of any kind with respect to + * the Software, and Broadcom expressly reserves all rights in and to the + * Software and all intellectual property rights therein. + * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS + * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE + * ALL USE OF THE SOFTWARE. + * + * Except as expressly set forth in the Authorized License, + * + * 1. This program, including its structure, sequence and organization, + * constitutes the valuable trade secrets of Broadcom, and you shall + * use all reasonable efforts to protect the confidentiality thereof, + * and to use this information only in connection with your use of + * Broadcom integrated circuit products. + * + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, + * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR + * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT + * OF USE OR PERFORMANCE OF THE SOFTWARE. + * + * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR + * ITS LICENSORS BE LIABLE FOR + * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY + * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO + * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR + * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE + * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE + * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF + * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: bt_hw.c + * + * Description: Bluedroid libbt-vendor callback functions + * + ******************************************************************************/ + +#define LOG_TAG "bt_hw" + +#include <utils/Log.h> +#include <pthread.h> +#include "bt_vendor_lib.h" +#include "bt_hci_bdroid.h" +#include "userial.h" + +/****************************************************************************** +** Externs +******************************************************************************/ + +uint8_t hci_h4_send_int_cmd(uint16_t opcode, HC_BT_HDR *p_buf, \ + tINT_CMD_CBACK p_cback); +void lpm_vnd_cback(uint8_t vnd_result); +void hci_h4_get_acl_data_length(void); + +/****************************************************************************** +** Variables +******************************************************************************/ + +bt_vendor_interface_t *bt_vnd_if=NULL; + +/****************************************************************************** +** Functions +******************************************************************************/ + +/****************************************************************************** +** +** Function fwcfg_cb +** +** Description HOST/CONTROLLER VENDOR LIB CALLBACK API - This function is +** called when the libbt-vendor completed firmware +** configuration process +** +** Returns None +** +******************************************************************************/ +static void fwcfg_cb(bt_vendor_op_result_t result) +{ + bt_hc_postload_result_t status = (result == BT_VND_OP_RESULT_SUCCESS) ? \ + BT_HC_PRELOAD_SUCCESS : BT_HC_PRELOAD_FAIL; + + if (bt_hc_cbacks) + bt_hc_cbacks->preload_cb(NULL, status); +} + +/****************************************************************************** +** +** Function scocfg_cb +** +** Description HOST/CONTROLLER VENDOR LIB CALLBACK API - This function is +** called when the libbt-vendor completed vendor specific SCO +** configuration process +** +** Returns None +** +******************************************************************************/ +static void scocfg_cb(bt_vendor_op_result_t result) +{ + /* Continue rest of postload process*/ + hci_h4_get_acl_data_length(); +} + +/****************************************************************************** +** +** Function lpm_vnd_cb +** +** Description HOST/CONTROLLER VENDOR LIB CALLBACK API - This function is +** called back from the libbt-vendor to indicate the result of +** previous LPM enable/disable request +** +** Returns None +** +******************************************************************************/ +static void lpm_vnd_cb(bt_vendor_op_result_t result) +{ + uint8_t status = (result == BT_VND_OP_RESULT_SUCCESS) ? 0 : 1; + + lpm_vnd_cback(status); +} + +/****************************************************************************** +** +** Function alloc +** +** Description HOST/CONTROLLER VENDOR LIB CALLOUT API - This function is +** called from the libbt-vendor to request for data buffer +** allocation +** +** Returns NULL / pointer to allocated buffer +** +******************************************************************************/ +static void *alloc(int size) +{ + HC_BT_HDR *p_hdr = NULL; + + if (bt_hc_cbacks) + p_hdr = (HC_BT_HDR *) bt_hc_cbacks->alloc(size); + + return (p_hdr); +} + +/****************************************************************************** +** +** Function dealloc +** +** Description HOST/CONTROLLER VENDOR LIB CALLOUT API - This function is +** called from the libbt-vendor to release the data buffer +** allocated through the alloc call earlier +** +** Returns None +** +******************************************************************************/ +static void dealloc(void *p_buf) +{ + HC_BT_HDR *p_hdr = (HC_BT_HDR *) p_buf; + + if (bt_hc_cbacks) + bt_hc_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_hdr+1)); +} + +/****************************************************************************** +** +** Function xmit_cb +** +** Description HOST/CONTROLLER VEDNOR LIB CALLOUT API - This function is +** called from the libbt-vendor in order to send a prepared +** HCI command packet through HCI transport TX function. +** +** Returns TRUE/FALSE +** +******************************************************************************/ +static uint8_t xmit_cb(uint16_t opcode, void *p_buf, tINT_CMD_CBACK p_cback) +{ + return hci_h4_send_int_cmd(opcode, (HC_BT_HDR *)p_buf, p_cback); +} + +/****************************************************************************** +** +** Function usrl_ctrl_cb +** +** Description HOST/CONTROLLER VEDNOR LIB CALLOUT API - This function is +** called from the libbt-vendor in order to configure userial +** attributes. +** +** Returns None +** +******************************************************************************/ +static void usrl_ctrl_cb(bt_vendor_userial_cid_t cid, void *param) +{ + if (cid == BT_VND_USERIAL_SET_BAUD) + { + uint8_t *baud = (uint8_t *) param; + + userial_change_baud(*baud); + } +} + +/***************************************************************************** +** The libbt-vendor Callback Functions Table +*****************************************************************************/ +static const bt_vendor_callbacks_t vnd_callbacks = { + sizeof(bt_vendor_callbacks_t), + fwcfg_cb, + scocfg_cb, + lpm_vnd_cb, + alloc, + dealloc, + xmit_cb, + usrl_ctrl_cb +}; + + +/****************************************************************************** +** +** Function init_vnd_if +** +** Description Initialize vendor lib interface +** +** Returns None +** +******************************************************************************/ +void init_vnd_if(unsigned char *local_bdaddr) +{ + if ((bt_vnd_if=(bt_vendor_interface_t *) bt_vendor_get_interface())!=NULL) + { + bt_vnd_if->init(&vnd_callbacks, local_bdaddr); + } + else + { + LOGE("!!! Failed to get BtVendorInterface !!!"); + } +} + diff --git a/vendor/libvendor/src/btsnoop.c b/hci/src/btsnoop.c index eb0c026..8160963 100644 --- a/vendor/libvendor/src/btsnoop.c +++ b/hci/src/btsnoop.c @@ -82,7 +82,7 @@ #define LOG_TAG "BTSNOOP-DISP" #include <cutils/log.h> -#include "bt_vendor_brcm.h" +#include "bt_hci_bdroid.h" #include "utils.h" #ifndef BTSNOOP_DBG @@ -90,9 +90,7 @@ #endif #if (BTSNOOP_DBG == TRUE) -#define SNOOPDBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_BTSNOOP)) \ - LOGD(param, ## __VA_ARGS__);\ - } +#define SNOOPDBG(param, ...) {LOGD(param, ## __VA_ARGS__);} #else #define SNOOPDBG(param, ...) {} #endif @@ -100,20 +98,6 @@ /* file descriptor of the BT snoop file (by default, -1 means disabled) */ int hci_btsnoop_fd = -1; -#if defined(BTSNOOPDISP_INCLUDED) && (BTSNOOPDISP_INCLUDED == TRUE) - -/* by default, btsnoop log is off */ -uint8_t btsnoop_log_enabled = 0; - -/* if not specified in .txt file then use this as default */ -#ifndef BTSNOOP_FILENAME -#define BTSNOOP_FILENAME "/data/misc/bluedroid/btsnoop_hci.log" -#endif /* BTSNOOP_FILENAME */ - -static char btsnoop_logfile[256] = BTSNOOP_FILENAME; - -#endif /* BTSNOOPDISP_INCLUDED */ - /* Macro to perform a multiplication of 2 unsigned 32bit values and store the result * in an unsigned 64 bit value (as two 32 bit variables): * u64 = u32In1 * u32In2 @@ -244,7 +228,7 @@ int btsnoop_is_open(void) ** ** Returns None *******************************************************************************/ -static int btsnoop_log_open(void) +static int btsnoop_log_open(char *btsnoop_logfile) { #if defined(BTSNOOPDISP_INCLUDED) && (BTSNOOPDISP_INCLUDED == TRUE) hci_btsnoop_fd = -1; @@ -252,7 +236,7 @@ static int btsnoop_log_open(void) SNOOPDBG("btsnoop_log_open: snoop log file = %s\n", btsnoop_logfile); /* write the BT snoop header */ - if (strlen(btsnoop_logfile) != 0) + if ((btsnoop_logfile != NULL) && (strlen(btsnoop_logfile) != 0)) { hci_btsnoop_fd = open(btsnoop_logfile, \ O_WRONLY|O_CREAT|O_TRUNC, \ @@ -625,25 +609,6 @@ void btsnoop_stop_listener(void) ext_parser_detached(); } -int btsnoop_set_logfile(char *p_conf_name, char *p_conf_value, int param) -{ -#if defined(BTSNOOPDISP_INCLUDED) && (BTSNOOPDISP_INCLUDED == TRUE) - strcpy(btsnoop_logfile, p_conf_value); -#endif - return 0; -} - -int btsnoop_enable_logging(char *p_conf_name, char *p_conf_value, int param) -{ -#if defined(BTSNOOPDISP_INCLUDED) && (BTSNOOPDISP_INCLUDED == TRUE) - if (strcmp(p_conf_value, "true") == 0) - btsnoop_log_enabled = 1; - else - btsnoop_log_enabled = 0; -#endif // BTSNOOPDISP_INCLUDED - return 0; -} - void btsnoop_init(void) { LOGD("btsnoop_init"); @@ -654,14 +619,11 @@ void btsnoop_init(void) perror("pthread_create"); } -void btsnoop_open(void) +void btsnoop_open(char *p_path) { #if defined(BTSNOOPDISP_INCLUDED) && (BTSNOOPDISP_INCLUDED == TRUE) - if (btsnoop_log_enabled) - { - LOGD("btsnoop_open"); - btsnoop_log_open(); - } + LOGD("btsnoop_open"); + btsnoop_log_open(p_path); #endif // BTSNOOPDISP_INCLUDED } @@ -687,7 +649,7 @@ void btsnoop_cleanup (void) #define HCIT_TYPE_SCO_DATA 3 #define HCIT_TYPE_EVENT 4 -void btsnoop_capture(VND_BT_HDR *p_buf, uint8_t is_rcvd) +void btsnoop_capture(HC_BT_HDR *p_buf, uint8_t is_rcvd) { uint8_t *p = (uint8_t *)(p_buf + 1) + p_buf->offset; @@ -703,18 +665,18 @@ void btsnoop_capture(VND_BT_HDR *p_buf, uint8_t is_rcvd) switch (p_buf->event & MSG_EVT_MASK) { - case MSG_VND_TO_STACK_HCI_EVT: + case MSG_HC_TO_STACK_HCI_EVT: *p = HCIT_TYPE_EVENT; break; - case MSG_VND_TO_STACK_HCI_ACL: - case MSG_STACK_TO_VND_HCI_ACL: + case MSG_HC_TO_STACK_HCI_ACL: + case MSG_STACK_TO_HC_HCI_ACL: *p = HCIT_TYPE_ACL_DATA; break; - case MSG_VND_TO_STACK_HCI_SCO: - case MSG_STACK_TO_VND_HCI_SCO: + case MSG_HC_TO_STACK_HCI_SCO: + case MSG_STACK_TO_HC_HCI_SCO: *p = HCIT_TYPE_SCO_DATA; break; - case MSG_STACK_TO_VND_HCI_CMD: + case MSG_STACK_TO_HC_HCI_CMD: *p = HCIT_TYPE_COMMAND; break; } @@ -730,21 +692,21 @@ void btsnoop_capture(VND_BT_HDR *p_buf, uint8_t is_rcvd) switch (p_buf->event & MSG_EVT_MASK) { - case MSG_VND_TO_STACK_HCI_EVT: + case MSG_HC_TO_STACK_HCI_EVT: SNOOPDBG("TYPE : EVT"); btsnoop_hci_evt(p); break; - case MSG_VND_TO_STACK_HCI_ACL: - case MSG_STACK_TO_VND_HCI_ACL: + case MSG_HC_TO_STACK_HCI_ACL: + case MSG_STACK_TO_HC_HCI_ACL: SNOOPDBG("TYPE : ACL"); btsnoop_acl_data(p, is_rcvd); break; - case MSG_VND_TO_STACK_HCI_SCO: - case MSG_STACK_TO_VND_HCI_SCO: + case MSG_HC_TO_STACK_HCI_SCO: + case MSG_STACK_TO_HC_HCI_SCO: SNOOPDBG("TYPE : SCO"); btsnoop_sco_data(p, is_rcvd); break; - case MSG_STACK_TO_VND_HCI_CMD: + case MSG_STACK_TO_HC_HCI_CMD: SNOOPDBG("TYPE : CMD"); btsnoop_hci_cmd(p); break; diff --git a/vendor/libvendor/src/hci_h4.c b/hci/src/hci_h4.c index f958951..e18ee6a 100644 --- a/vendor/libvendor/src/hci_h4.c +++ b/hci/src/hci_h4.c @@ -58,7 +58,7 @@ #include <utils/Log.h> #include <stdlib.h> #include <fcntl.h> -#include "bt_vendor_brcm.h" +#include "bt_hci_bdroid.h" #include "userial.h" #include "utils.h" @@ -71,9 +71,7 @@ #endif #if (HCIH4_DBG == TRUE) -#define HCIH4DBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_HCI)) \ - LOGD(param, ## __VA_ARGS__);\ - } +#define HCIH4DBG(param, ...) {LOGD(param, ## __VA_ARGS__);} #else #define HCIH4DBG(param, ...) {} #endif @@ -115,10 +113,10 @@ static const uint8_t hci_preamble_table[] = static const uint16_t msg_evt_table[] = { - MSG_VND_TO_STACK_HCI_ERR, /* H4_TYPE_COMMAND */ - MSG_VND_TO_STACK_HCI_ACL, /* H4_TYPE_ACL_DATA */ - MSG_VND_TO_STACK_HCI_SCO, /* H4_TYPE_SCO_DATA */ - MSG_VND_TO_STACK_HCI_EVT /* H4_TYPE_EVENT */ + MSG_HC_TO_STACK_HCI_ERR, /* H4_TYPE_COMMAND */ + MSG_HC_TO_STACK_HCI_ACL, /* H4_TYPE_ACL_DATA */ + MSG_HC_TO_STACK_HCI_SCO, /* H4_TYPE_SCO_DATA */ + MSG_HC_TO_STACK_HCI_EVT /* H4_TYPE_EVENT */ }; #define ACL_RX_PKT_START 2 @@ -149,7 +147,7 @@ typedef enum { } tHCI_H4_RCV_STATE; /* Callback function for the returned event of internal issued command */ -typedef void (*tINT_CMD_CBACK)(VND_BT_HDR *p_buf); +typedef void (*tINT_CMD_CBACK)(void *p_mem); typedef struct { @@ -161,7 +159,7 @@ typedef struct /* Control block for HCISU_H4 */ typedef struct { - VND_BT_HDR *p_rcv_msg; /* Buffer to hold current rx HCI message */ + HC_BT_HDR *p_rcv_msg; /* Buffer to hold current rx HCI message */ uint16_t rcv_len; /* Size of current incoming message */ uint8_t rcv_msg_type; /* Current incoming message type */ tHCI_H4_RCV_STATE rcv_state; /* Receive state of current rx message */ @@ -183,14 +181,13 @@ typedef struct extern BUFFER_Q tx_q; void btsnoop_init(void); -void btsnoop_open(void); void btsnoop_close(void); void btsnoop_cleanup (void); -void btsnoop_capture(VND_BT_HDR *p_buf, uint8_t is_rcvd); -uint8_t hci_h4_send_int_cmd(uint16_t opcode, VND_BT_HDR *p_buf, \ +void btsnoop_capture(HC_BT_HDR *p_buf, uint8_t is_rcvd); +uint8_t hci_h4_send_int_cmd(uint16_t opcode, HC_BT_HDR *p_buf, \ tINT_CMD_CBACK p_cback); -void hw_lpm_assert_bt_wake(void); -void hw_lpm_tx_done(uint8_t is_tx_done); +void lpm_wake_assert(void); +void lpm_tx_done(uint8_t is_tx_done); /****************************************************************************** ** Variables @@ -220,10 +217,11 @@ static tHCI_H4_CB h4_cb; ** Returns None ** *******************************************************************************/ -void get_acl_data_length_cback(VND_BT_HDR *p_buf) +void get_acl_data_length_cback(void *p_mem) { uint8_t *p, status; uint16_t opcode, len=0; + HC_BT_HDR *p_buf = (HC_BT_HDR *) p_mem; p = (uint8_t *)(p_buf + 1) + 3; STREAM_TO_UINT16(opcode, p) @@ -237,7 +235,7 @@ void get_acl_data_length_cback(VND_BT_HDR *p_buf) h4_cb.hc_acl_data_size = len; /* reuse the rx buffer for sending HCI_LE_READ_BUFFER_SIZE command */ - p_buf->event = MSG_STACK_TO_VND_HCI_CMD; + p_buf->event = MSG_STACK_TO_HC_HCI_CMD; p_buf->offset = 0; p_buf->layer_specific = 0; p_buf->len = 3; @@ -249,8 +247,8 @@ void get_acl_data_length_cback(VND_BT_HDR *p_buf) if ((status = hci_h4_send_int_cmd(HCI_LE_READ_BUFFER_SIZE, p_buf, \ get_acl_data_length_cback)) == FALSE) { - bt_vendor_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); - bt_vendor_cbacks->postload_cb(NULL, BT_VENDOR_POSTLOAD_SUCCESS); + bt_hc_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); + bt_hc_cbacks->postload_cb(NULL, BT_HC_POSTLOAD_SUCCESS); } } else if (opcode == HCI_LE_READ_BUFFER_SIZE) @@ -258,11 +256,11 @@ void get_acl_data_length_cback(VND_BT_HDR *p_buf) if (status == 0) h4_cb.hc_ble_acl_data_size = (len) ? len : h4_cb.hc_acl_data_size; - if (bt_vendor_cbacks) + if (bt_hc_cbacks) { - bt_vendor_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); + bt_hc_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); LOGE("vendor lib postload completed"); - bt_vendor_cbacks->postload_cb(NULL, BT_VENDOR_POSTLOAD_SUCCESS); + bt_hc_cbacks->postload_cb(NULL, BT_HC_POSTLOAD_SUCCESS); } } } @@ -342,14 +340,14 @@ uint8_t internal_event_intercept(void) ** into one buffer. ** *******************************************************************************/ -static VND_BT_HDR *acl_rx_frame_buffer_alloc (void) +static HC_BT_HDR *acl_rx_frame_buffer_alloc (void) { uint8_t *p; uint16_t handle; uint16_t hci_len; uint16_t total_len; uint8_t pkt_type; - VND_BT_HDR *p_return_buf = NULL; + HC_BT_HDR *p_return_buf = NULL; tHCI_H4_CB *p_cb = &h4_cb; @@ -365,7 +363,7 @@ static VND_BT_HDR *acl_rx_frame_buffer_alloc (void) if (p_cb->acl_rx_q.count) { uint16_t save_handle; - VND_BT_HDR *p_hdr = p_cb->acl_rx_q.p_first; + HC_BT_HDR *p_hdr = p_cb->acl_rx_q.p_first; while (p_hdr != NULL) { @@ -395,20 +393,20 @@ static VND_BT_HDR *acl_rx_frame_buffer_alloc (void) utils_remove_from_queue(&(p_cb->acl_rx_q), p_return_buf); - if (bt_vendor_cbacks) + if (bt_hc_cbacks) { - bt_vendor_cbacks->dealloc((TRANSAC) p_return_buf, \ + bt_hc_cbacks->dealloc((TRANSAC) p_return_buf, \ (char *) (p_return_buf + 1)); } p_return_buf = NULL; } /* Allocate a buffer for message */ - if (bt_vendor_cbacks) + if (bt_hc_cbacks) { int len = total_len + HCI_ACL_PREAMBLE_SIZE + L2CAP_HEADER_SIZE + \ - BT_VND_HDR_SIZE; - p_return_buf = (VND_BT_HDR *) bt_vendor_cbacks->alloc(len); + BT_HC_HDR_SIZE; + p_return_buf = (HC_BT_HDR *) bt_hc_cbacks->alloc(len); } if (p_return_buf) @@ -416,7 +414,7 @@ static VND_BT_HDR *acl_rx_frame_buffer_alloc (void) /* Initialize buffer with preloaded data */ p_return_buf->offset = 0; p_return_buf->layer_specific = 0; - p_return_buf->event = MSG_VND_TO_STACK_HCI_ACL; + p_return_buf->event = MSG_HC_TO_STACK_HCI_ACL; p_return_buf->len = p_cb->preload_count; memcpy((uint8_t *)(p_return_buf + 1), p_cb->preload_buffer, \ p_cb->preload_count); @@ -465,7 +463,7 @@ static uint8_t acl_rx_frame_end_chk (void) { uint8_t *p; uint16_t handle, hci_len, l2cap_len; - VND_BT_HDR *p_buf; + HC_BT_HDR *p_buf; tHCI_H4_CB *p_cb = &h4_cb; uint8_t frame_end=TRUE; @@ -578,7 +576,6 @@ void hci_h4_init(void) h4_cb.hc_ble_acl_data_size = 27; btsnoop_init(); - btsnoop_open(); } /******************************************************************************* @@ -608,7 +605,7 @@ void hci_h4_cleanup(void) ** Returns None ** *******************************************************************************/ -void hci_h4_send_msg(VND_BT_HDR *p_msg) +void hci_h4_send_msg(HC_BT_HDR *p_msg) { uint8_t type = 0; uint16_t handle; @@ -620,13 +617,13 @@ void hci_h4_send_msg(VND_BT_HDR *p_msg) uint16_t bytes_sent; /* wake up BT device if its in sleep mode */ - hw_lpm_assert_bt_wake(); + lpm_wake_assert(); - if (event == MSG_STACK_TO_VND_HCI_ACL) + if (event == MSG_STACK_TO_HC_HCI_ACL) type = H4_TYPE_ACL_DATA; - else if (event == MSG_STACK_TO_VND_HCI_SCO) + else if (event == MSG_STACK_TO_HC_HCI_SCO) type = H4_TYPE_SCO_DATA; - else if (event == MSG_STACK_TO_VND_HCI_CMD) + else if (event == MSG_STACK_TO_HC_HCI_CMD) type = H4_TYPE_COMMAND; if (sub_event == LOCAL_BR_EDR_CONTROLLER_ID) @@ -641,7 +638,7 @@ void hci_h4_send_msg(VND_BT_HDR *p_msg) } /* Check if sending ACL data that needs fragmenting */ - if ((event == MSG_STACK_TO_VND_HCI_ACL) && (p_msg->len > acl_pkt_size)) + if ((event == MSG_STACK_TO_HC_HCI_ACL) && (p_msg->len > acl_pkt_size)) { /* Get the handle from the packet */ STREAM_TO_UINT16 (handle, p); @@ -689,13 +686,13 @@ void hci_h4_send_msg(VND_BT_HDR *p_msg) { if (--p_msg->layer_specific == 0) { - p_msg->event = MSG_VND_TO_STACK_L2C_SEG_XMIT; + p_msg->event = MSG_HC_TO_STACK_L2C_SEG_XMIT; - if (bt_vendor_cbacks) + if (bt_hc_cbacks) { - bt_vendor_cbacks->tx_result((TRANSAC) p_msg, \ + bt_hc_cbacks->tx_result((TRANSAC) p_msg, \ (char *) (p_msg + 1), \ - BT_VENDOR_TX_FRAGMENT); + BT_HC_TX_FRAGMENT); } return; @@ -718,7 +715,7 @@ void hci_h4_send_msg(VND_BT_HDR *p_msg) p_msg->layer_specific = lay_spec; - if (event == MSG_STACK_TO_VND_HCI_CMD) + if (event == MSG_STACK_TO_HC_HCI_CMD) { num_hci_cmd_pkts--; @@ -733,23 +730,23 @@ void hci_h4_send_msg(VND_BT_HDR *p_msg) /* generate snoop trace message */ btsnoop_capture(p_msg, FALSE); - if (bt_vendor_cbacks) + if (bt_hc_cbacks) { - if ((event == MSG_STACK_TO_VND_HCI_CMD) && \ + if ((event == MSG_STACK_TO_HC_HCI_CMD) && \ (h4_cb.int_cmd_rsp_pending > 0) && \ (p_msg->layer_specific == lay_spec)) { /* dealloc buffer of internal command */ - bt_vendor_cbacks->dealloc((TRANSAC) p_msg, (char *) (p_msg + 1)); + bt_hc_cbacks->dealloc((TRANSAC) p_msg, (char *) (p_msg + 1)); } else { - bt_vendor_cbacks->tx_result((TRANSAC) p_msg, (char *) (p_msg + 1), \ - BT_VENDOR_TX_SUCCESS); + bt_hc_cbacks->tx_result((TRANSAC) p_msg, (char *) (p_msg + 1), \ + BT_HC_TX_SUCCESS); } } - hw_lpm_tx_done(TRUE); + lpm_tx_done(TRUE); return; } @@ -851,11 +848,11 @@ uint16_t hci_h4_receive_msg(void) p_cb->rcv_len = msg_len; /* Allocate a buffer for message */ - if (bt_vendor_cbacks) + if (bt_hc_cbacks) { - len = msg_len + p_cb->preload_count + BT_VND_HDR_SIZE; + len = msg_len + p_cb->preload_count + BT_HC_HDR_SIZE; p_cb->p_rcv_msg = \ - (VND_BT_HDR *) bt_vendor_cbacks->alloc(len); + (HC_BT_HDR *) bt_hc_cbacks->alloc(len); } if (p_cb->p_rcv_msg) @@ -971,17 +968,17 @@ uint16_t hci_h4_receive_msg(void) /* generate snoop trace message */ /* ACL packet tracing had done in acl_rx_frame_end_chk() */ - if (p_cb->p_rcv_msg->event != MSG_VND_TO_STACK_HCI_ACL) + if (p_cb->p_rcv_msg->event != MSG_HC_TO_STACK_HCI_ACL) btsnoop_capture(p_cb->p_rcv_msg, TRUE); - if (p_cb->p_rcv_msg->event == MSG_VND_TO_STACK_HCI_EVT) + if (p_cb->p_rcv_msg->event == MSG_HC_TO_STACK_HCI_EVT) intercepted = internal_event_intercept(); - if ((bt_vendor_cbacks) && (intercepted == FALSE)) + if ((bt_hc_cbacks) && (intercepted == FALSE)) { - bt_vendor_cbacks->data_ind((TRANSAC) p_cb->p_rcv_msg, \ + bt_hc_cbacks->data_ind((TRANSAC) p_cb->p_rcv_msg, \ (char *) (p_cb->p_rcv_msg + 1), \ - p_cb->p_rcv_msg->len + BT_VND_HDR_SIZE); + p_cb->p_rcv_msg->len + BT_HC_HDR_SIZE); } p_cb->p_rcv_msg = NULL; } @@ -1001,7 +998,7 @@ uint16_t hci_h4_receive_msg(void) ** Returns TRUE/FALSE ** *******************************************************************************/ -uint8_t hci_h4_send_int_cmd(uint16_t opcode, VND_BT_HDR *p_buf, \ +uint8_t hci_h4_send_int_cmd(uint16_t opcode, HC_BT_HDR *p_buf, \ tINT_CMD_CBACK p_cback) { if (h4_cb.int_cmd_rsp_pending > INT_CMD_PKT_MAX_COUNT) @@ -1021,7 +1018,7 @@ uint8_t hci_h4_send_int_cmd(uint16_t opcode, VND_BT_HDR *p_buf, \ p_buf->layer_specific = opcode; utils_enqueue(&tx_q, (void *) p_buf); - btvnd_signal_event(VND_EVENT_TX); + bthc_signal_event(HC_EVENT_TX); return TRUE; } @@ -1039,18 +1036,18 @@ uint8_t hci_h4_send_int_cmd(uint16_t opcode, VND_BT_HDR *p_buf, \ *******************************************************************************/ void hci_h4_get_acl_data_length(void) { - VND_BT_HDR *p_buf = NULL; + HC_BT_HDR *p_buf = NULL; uint8_t *p, ret; - if (bt_vendor_cbacks) + if (bt_hc_cbacks) { - p_buf = (VND_BT_HDR *) bt_vendor_cbacks->alloc(BT_VND_HDR_SIZE + \ + p_buf = (HC_BT_HDR *) bt_hc_cbacks->alloc(BT_HC_HDR_SIZE + \ HCI_CMD_PREAMBLE_SIZE); } if (p_buf) { - p_buf->event = MSG_STACK_TO_VND_HCI_CMD; + p_buf->event = MSG_STACK_TO_HC_HCI_CMD; p_buf->offset = 0; p_buf->layer_specific = 0; p_buf->len = HCI_CMD_PREAMBLE_SIZE; @@ -1062,16 +1059,16 @@ void hci_h4_get_acl_data_length(void) if ((ret = hci_h4_send_int_cmd(HCI_READ_BUFFER_SIZE, p_buf, \ get_acl_data_length_cback)) == FALSE) { - bt_vendor_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); + bt_hc_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); } else return; } - if (bt_vendor_cbacks) + if (bt_hc_cbacks) { LOGE("vendor lib postload aborted"); - bt_vendor_cbacks->postload_cb(NULL, BT_VENDOR_POSTLOAD_FAIL); + bt_hc_cbacks->postload_cb(NULL, BT_HC_POSTLOAD_FAIL); } } diff --git a/hci/src/lpm.c b/hci/src/lpm.c new file mode 100644 index 0000000..c07b37c --- /dev/null +++ b/hci/src/lpm.c @@ -0,0 +1,453 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * This program is the proprietary software of Broadcom Corporation and/or its + * licensors, and may only be used, duplicated, modified or distributed + * pursuant to the terms and conditions of a separate, written license + * agreement executed between you and Broadcom (an "Authorized License"). + * Except as set forth in an Authorized License, Broadcom grants no license + * (express or implied), right to use, or waiver of any kind with respect to + * the Software, and Broadcom expressly reserves all rights in and to the + * Software and all intellectual property rights therein. + * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS + * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE + * ALL USE OF THE SOFTWARE. + * + * Except as expressly set forth in the Authorized License, + * + * 1. This program, including its structure, sequence and organization, + * constitutes the valuable trade secrets of Broadcom, and you shall + * use all reasonable efforts to protect the confidentiality thereof, + * and to use this information only in connection with your use of + * Broadcom integrated circuit products. + * + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, + * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR + * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT + * OF USE OR PERFORMANCE OF THE SOFTWARE. + * + * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR + * ITS LICENSORS BE LIABLE FOR + * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY + * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO + * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR + * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE + * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE + * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF + * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. + * + ******************************************************************************/ + +/****************************************************************************** + * + * Filename: lpm.c + * + * Description: Contains low power mode implementation + * + ******************************************************************************/ + +#define LOG_TAG "bt_lpm" + +#include <utils/Log.h> +#include <signal.h> +#include <time.h> +#include "bt_hci_bdroid.h" +#include "bt_vendor_lib.h" + +/****************************************************************************** +** Constants & Macros +******************************************************************************/ + +#ifndef BTLPM_DBG +#define BTLPM_DBG FALSE +#endif + +#if (BTLPM_DBG == TRUE) +#define BTLPMDBG(param, ...) {LOGD(param, ## __VA_ARGS__);} +#else +#define BTLPMDBG(param, ...) {} +#endif + +#ifndef DEFAULT_LPM_IDLE_TIMEOUT +#define DEFAULT_LPM_IDLE_TIMEOUT 3000 +#endif + +/****************************************************************************** +** Externs +******************************************************************************/ + +extern bt_vendor_interface_t *bt_vnd_if; + +/****************************************************************************** +** Local type definitions +******************************************************************************/ + +/* Low power mode state */ +enum { + LPM_DISABLED = 0, /* initial state */ + LPM_ENABLED, + LPM_ENABLING, + LPM_DISABLING +}; + +/* LPM WAKE state */ +enum { + LPM_WAKE_DEASSERTED = 0, /* initial state */ + LPM_WAKE_W4_TX_DONE, + LPM_WAKE_W4_TIMEOUT, + LPM_WAKE_ASSERTED +}; + +/* low power mode control block */ +typedef struct +{ + uint8_t state; /* Low power mode state */ + uint8_t wake_state; /* LPM WAKE state */ + uint8_t no_tx_data; + uint8_t timer_created; + timer_t timer_id; + uint32_t timeout_ms; +} bt_lpm_cb_t; + + +/****************************************************************************** +** Static variables +******************************************************************************/ + +static bt_lpm_cb_t bt_lpm_cb; + +/****************************************************************************** +** LPM Static Functions +******************************************************************************/ + +/******************************************************************************* +** +** Function lpm_idle_timeout +** +** Description Timeout thread of transport idle timer +** +** Returns None +** +*******************************************************************************/ +static void lpm_idle_timeout(union sigval arg) +{ + BTLPMDBG("..lpm_idle_timeout.."); + + if ((bt_lpm_cb.state == LPM_ENABLED) && \ + (bt_lpm_cb.wake_state == LPM_WAKE_W4_TIMEOUT)) + { + bthc_signal_event(HC_EVENT_LPM_IDLE_TIMEOUT); + } +} + +/******************************************************************************* +** +** Function lpm_start_transport_idle_timer +** +** Description Launch transport idle timer +** +** Returns None +** +*******************************************************************************/ +static void lpm_start_transport_idle_timer(void) +{ + int status; + struct itimerspec ts; + struct sigevent se; + + if (bt_lpm_cb.state != LPM_ENABLED) + return; + + if (bt_lpm_cb.timer_created == FALSE) + { + se.sigev_notify = SIGEV_THREAD; + se.sigev_value.sival_ptr = &bt_lpm_cb.timer_id; + se.sigev_notify_function = lpm_idle_timeout; + se.sigev_notify_attributes = NULL; + + status = timer_create(CLOCK_MONOTONIC, &se, &bt_lpm_cb.timer_id); + + if (status == 0) + bt_lpm_cb.timer_created = TRUE; + } + + if (bt_lpm_cb.timer_created == TRUE) + { + ts.it_value.tv_sec = bt_lpm_cb.timeout_ms/1000; + ts.it_value.tv_nsec = 1000*(bt_lpm_cb.timeout_ms%1000); + ts.it_interval.tv_sec = 0; + ts.it_interval.tv_nsec = 0; + + status = timer_settime(bt_lpm_cb.timer_id, 0, &ts, 0); + if (status == -1) + LOGE("[START] Failed to set LPM idle timeout"); + } +} + +/******************************************************************************* +** +** Function lpm_stop_transport_idle_timer +** +** Description Launch transport idle timer +** +** Returns None +** +*******************************************************************************/ +static void lpm_stop_transport_idle_timer(void) +{ + int status; + struct itimerspec ts; + + if (bt_lpm_cb.timer_created == TRUE) + { + ts.it_value.tv_sec = 0; + ts.it_value.tv_nsec = 0; + ts.it_interval.tv_sec = 0; + ts.it_interval.tv_nsec = 0; + + status = timer_settime(bt_lpm_cb.timer_id, 0, &ts, 0); + if (status == -1) + LOGE("[STOP] Failed to set LPM idle timeout"); + } +} + +/******************************************************************************* +** +** Function lpm_vnd_cback +** +** Description Callback of vendor specific result for lpm enable/disable +** rquest +** +** Returns None +** +*******************************************************************************/ +void lpm_vnd_cback(uint8_t vnd_result) +{ + if (vnd_result == 0) + { + /* Status == Success */ + bt_lpm_cb.state = (bt_lpm_cb.state == LPM_ENABLING) ? \ + LPM_ENABLED : LPM_DISABLED; + } + else + { + bt_lpm_cb.state = (bt_lpm_cb.state == LPM_ENABLING) ? \ + LPM_DISABLED : LPM_ENABLED; + } + + if (bt_hc_cbacks) + { + if (bt_lpm_cb.state == LPM_ENABLED) + bt_hc_cbacks->lpm_cb(BT_HC_LPM_ENABLED); + else + bt_hc_cbacks->lpm_cb(BT_HC_LPM_DISABLED); + } + + if (bt_lpm_cb.state == LPM_DISABLED) + { + if (bt_lpm_cb.timer_created == TRUE) + { + timer_delete(bt_lpm_cb.timer_id); + } + + memset(&bt_lpm_cb, 0, sizeof(bt_lpm_cb_t)); + } +} + + +/***************************************************************************** +** Low Power Mode Interface Functions +*****************************************************************************/ + +/******************************************************************************* +** +** Function lpm_init +** +** Description Init LPM +** +** Returns None +** +*******************************************************************************/ +void lpm_init(void) +{ + memset(&bt_lpm_cb, 0, sizeof(bt_lpm_cb_t)); + + /* Calling vendor-specific part */ + if (bt_vnd_if) + bt_vnd_if->op(BT_VND_OP_GET_LPM_IDLE_TIMEOUT, &(bt_lpm_cb.timeout_ms)); + else + bt_lpm_cb.timeout_ms = DEFAULT_LPM_IDLE_TIMEOUT; +} + +/******************************************************************************* +** +** Function lpm_cleanup +** +** Description Clean up +** +** Returns None +** +*******************************************************************************/ +void lpm_cleanup(void) +{ + if (bt_lpm_cb.timer_created == TRUE) + { + timer_delete(bt_lpm_cb.timer_id); + } +} + +/******************************************************************************* +** +** Function lpm_enable +** +** Description Enalbe/Disable LPM +** +** Returns None +** +*******************************************************************************/ +void lpm_enable(uint8_t turn_on) +{ + if ((bt_lpm_cb.state!=LPM_DISABLED) && (bt_lpm_cb.state!=LPM_ENABLED)) + { + LOGW("Still busy on processing prior LPM enable/disable request..."); + return; + } + + if ((turn_on == TRUE) && (bt_lpm_cb.state == LPM_ENABLED)) + { + LOGI("LPM is already on!!!"); + if (bt_hc_cbacks) + bt_hc_cbacks->lpm_cb(BT_HC_LPM_ENABLED); + } + else if ((turn_on == FALSE) && (bt_lpm_cb.state == LPM_DISABLED)) + { + LOGI("LPM is already off!!!"); + if (bt_hc_cbacks) + bt_hc_cbacks->lpm_cb(BT_HC_LPM_DISABLED); + } + + /* Calling vendor-specific part */ + if (bt_vnd_if) + { + bt_lpm_cb.state = (turn_on) ? LPM_ENABLING : LPM_DISABLING; + bt_vnd_if->op(BT_VND_OP_LPM_SET_MODE, &turn_on); + } +} + +/******************************************************************************* +** +** Function lpm_tx_done +** +** Description This function is to inform the lpm module +** if data is waiting in the Tx Q or not. +** +** IsTxDone: TRUE if All data in the Tx Q are gone +** FALSE if any data is still in the Tx Q. +** Typicaly this function must be called +** before USERIAL Write and in the Tx Done routine +** +** Returns None +** +*******************************************************************************/ +void lpm_tx_done(uint8_t is_tx_done) +{ + bt_lpm_cb.no_tx_data = is_tx_done; + + if ((bt_lpm_cb.wake_state==LPM_WAKE_W4_TX_DONE) && (is_tx_done==TRUE)) + { + bt_lpm_cb.wake_state = LPM_WAKE_W4_TIMEOUT; + lpm_start_transport_idle_timer(); + } +} + +/******************************************************************************* +** +** Function lpm_wake_assert +** +** Description Called to wake up Bluetooth chip. +** Normally this is called when there is data to be sent +** over UART. +** +** Returns TRUE/FALSE +** +*******************************************************************************/ +void lpm_wake_assert(void) +{ + if (bt_lpm_cb.state != LPM_DISABLED) + { + BTLPMDBG("LPM WAKE assert"); + + /* Calling vendor-specific part */ + if (bt_vnd_if) + { + uint8_t state = BT_VND_LPM_WAKE_ASSERT; + bt_vnd_if->op(BT_VND_OP_LPM_WAKE_SET_STATE, &state); + } + + lpm_stop_transport_idle_timer(); + + bt_lpm_cb.wake_state = LPM_WAKE_ASSERTED; + } + + lpm_tx_done(FALSE); +} + +/******************************************************************************* +** +** Function lpm_allow_bt_device_sleep +** +** Description Start LPM idle timer if allowed +** +** Returns None +** +*******************************************************************************/ +void lpm_allow_bt_device_sleep(void) +{ + if ((bt_lpm_cb.state == LPM_ENABLED) && \ + (bt_lpm_cb.wake_state == LPM_WAKE_ASSERTED)) + { + if(bt_lpm_cb.no_tx_data == TRUE) + { + bt_lpm_cb.wake_state = LPM_WAKE_W4_TIMEOUT; + lpm_start_transport_idle_timer(); + } + else + { + bt_lpm_cb.wake_state = LPM_WAKE_W4_TX_DONE; + } + } +} + +/******************************************************************************* +** +** Function lpm_wake_deassert +** +** Description Deassert wake if allowed +** +** Returns None +** +*******************************************************************************/ +void lpm_wake_deassert(void) +{ + if ((bt_lpm_cb.state == LPM_ENABLED) && (bt_lpm_cb.no_tx_data == TRUE)) + { + BTLPMDBG("LPM WAKE deassert"); + + /* Calling vendor-specific part */ + if (bt_vnd_if) + { + uint8_t state = BT_VND_LPM_WAKE_DEASSERT; + bt_vnd_if->op(BT_VND_OP_LPM_WAKE_SET_STATE, &state); + } + + bt_lpm_cb.wake_state = LPM_WAKE_DEASSERTED; + } +} + diff --git a/vendor/libvendor/src/userial.c b/hci/src/userial.c index f806688..7385480 100644 --- a/vendor/libvendor/src/userial.c +++ b/hci/src/userial.c @@ -57,14 +57,14 @@ #include <utils/Log.h> #include <pthread.h> -#include <termios.h> #include <fcntl.h> #include <errno.h> #include <stdio.h> #include <sys/socket.h> -#include "bt_vendor_brcm.h" +#include "bt_hci_bdroid.h" #include "userial.h" #include "utils.h" +#include "bt_vendor_lib.h" /****************************************************************************** ** Constants & Macros @@ -75,15 +75,13 @@ #endif #if (USERIAL_DBG == TRUE) -#define USERIALDBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_USERIAL)) \ - LOGD(param, ## __VA_ARGS__);\ - } +#define USERIALDBG(param, ...) {LOGD(param, ## __VA_ARGS__);} #else #define USERIALDBG(param, ...) {} #endif #define MAX_SERIAL_PORT (USERIAL_PORT_3 + 1) -#define READ_LIMIT (BTVND_USERIAL_READ_MEM_SIZE - BT_VND_HDR_SIZE) +#define READ_LIMIT (BTHC_USERIAL_READ_MEM_SIZE - BT_HC_HDR_SIZE) enum { USERIAL_RX_EXIT, @@ -92,6 +90,12 @@ enum { }; /****************************************************************************** +** Externs +******************************************************************************/ + +extern bt_vendor_interface_t *bt_vnd_if; + +/****************************************************************************** ** Local type definitions ******************************************************************************/ @@ -102,7 +106,7 @@ typedef struct pthread_t read_thread; tUSERIAL_CFG cfg; BUFFER_Q rx_q; - VND_BT_HDR *p_rx_hdr; + HC_BT_HDR *p_rx_hdr; } tUSERIAL_CB; /****************************************************************************** @@ -112,12 +116,6 @@ typedef struct static tUSERIAL_CB userial_cb; static volatile uint8_t userial_running = 0; -/* Mapping of USERIAL_PORT_x to device ports */ -char userial_dev[][256] = -{ - BLUETOOTH_UART_DEVICE_PORT /* USERIAL_PORT_1 (HCI)*/ -}; - /* for friendly debugging outpout string */ static uint32_t userial_baud_tbl[] = { @@ -262,7 +260,7 @@ static int select_read(int fd, uint8_t *pbuf, int len) static void *userial_read_thread(void *arg) { int rx_length = 0; - VND_BT_HDR *p_buf = NULL; + HC_BT_HDR *p_buf = NULL; uint8_t *p; USERIALDBG("Entering userial_read_thread()"); @@ -272,10 +270,10 @@ static void *userial_read_thread(void *arg) while (userial_running) { - if (bt_vendor_cbacks) + if (bt_hc_cbacks) { - p_buf = (VND_BT_HDR *) bt_vendor_cbacks->alloc( \ - BTVND_USERIAL_READ_MEM_SIZE); + p_buf = (HC_BT_HDR *) bt_hc_cbacks->alloc( \ + BTHC_USERIAL_READ_MEM_SIZE); } else p_buf = NULL; @@ -301,14 +299,14 @@ static void *userial_read_thread(void *arg) { p_buf->len = (uint16_t)rx_length; utils_enqueue(&(userial_cb.rx_q), p_buf); - btvnd_signal_event(VND_EVENT_RX); + bthc_signal_event(HC_EVENT_RX); } else /* either 0 or < 0 */ { LOGW("select_read return size <=0:%d, exiting userial_read_thread",\ rx_length); /* if we get here, we should have a buffer */ - bt_vendor_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); + bt_hc_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); /* negative value means exit thread */ break; } @@ -323,83 +321,6 @@ static void *userial_read_thread(void *arg) /***************************************************************************** -** Helper Functions -*****************************************************************************/ - -/******************************************************************************* -** -** Function baud_userial_to_tcio -** -** Description helper function converts USERIAL baud rates into TCIO -** conforming baud rates -** -** Returns TRUE/FALSE -** -*******************************************************************************/ -uint8_t userial_to_tcio_baud(uint8_t cfg_baud, uint32_t *baud) -{ - if (cfg_baud == USERIAL_BAUD_600) - *baud = B600; - else if (cfg_baud == USERIAL_BAUD_1200) - *baud = B1200; - else if (cfg_baud == USERIAL_BAUD_9600) - *baud = B9600; - else if (cfg_baud == USERIAL_BAUD_19200) - *baud = B19200; - else if (cfg_baud == USERIAL_BAUD_57600) - *baud = B57600; - else if (cfg_baud == USERIAL_BAUD_115200) - *baud = B115200; - else if (cfg_baud == USERIAL_BAUD_230400) - *baud = B230400; - else if (cfg_baud == USERIAL_BAUD_460800) - *baud = B460800; - else if (cfg_baud == USERIAL_BAUD_921600) - *baud = B921600; - else if (cfg_baud == USERIAL_BAUD_1M) - *baud = B1000000; - else if (cfg_baud == USERIAL_BAUD_2M) - *baud = B2000000; - else if (cfg_baud == USERIAL_BAUD_3M) - *baud = B3000000; - else if (cfg_baud == USERIAL_BAUD_4M) - *baud = B4000000; - else - { - LOGE( "userial_open: unsupported baud idx %i", cfg_baud); - *baud = B115200; - return FALSE; - } - - return TRUE; -} - -#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) -/******************************************************************************* -** -** Function userial_ioctl_init_bt_wake -** -** Description helper function to set the open state of the bt_wake if ioctl -** is used. it should not hurt in the rfkill case but it might -** be better to compile it out. -** -** Returns none -** -*******************************************************************************/ -void userial_ioctl_init_bt_wake(int fd) -{ - uint32_t bt_wake_state; - - /* assert BT_WAKE through ioctl */ - ioctl( fd, USERIAL_IOCTL_BT_WAKE_ASSERT, NULL); - ioctl( fd, USERIAL_IOCTL_BT_WAKE_GET_ST, &bt_wake_state); - USERIALDBG("userial_ioctl_init_bt_wake read back BT_WAKE state=%i", \ - bt_wake_state); -} -#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) - - -/***************************************************************************** ** Userial API Functions *****************************************************************************/ @@ -433,15 +354,9 @@ uint8_t userial_init(void) *******************************************************************************/ uint8_t userial_open(uint8_t port, tUSERIAL_CFG *p_cfg) { - uint32_t baud; - uint8_t data_bits; - uint16_t parity; - uint8_t stop_bits; - struct termios termios; struct sched_param param; - int policy; + int policy, result; pthread_attr_t thread_attr; - char device_name[32]; USERIALDBG("userial_open(port:%d, baud:%d)", port, p_cfg->baud); @@ -458,94 +373,51 @@ uint8_t userial_open(uint8_t port, tUSERIAL_CFG *p_cfg) return FALSE; } - if (!userial_to_tcio_baud(p_cfg->baud, &baud)) + /* Calling vendor-specific part */ + if (bt_vnd_if) { - return FALSE; + userial_cb.sock = bt_vnd_if->op(BT_VND_OP_USERIAL_OPEN, p_cfg); } - - if(p_cfg->fmt & USERIAL_DATABITS_8) - data_bits = CS8; - else if(p_cfg->fmt & USERIAL_DATABITS_7) - data_bits = CS7; - else if(p_cfg->fmt & USERIAL_DATABITS_6) - data_bits = CS6; - else if(p_cfg->fmt & USERIAL_DATABITS_5) - data_bits = CS5; else { - LOGE("userial_open: unsupported data bits"); + LOGE("userial_open: missing vendor lib interface !!!"); + LOGE("userial_open: unable to open UART port"); return FALSE; } - if(p_cfg->fmt & USERIAL_PARITY_NONE) - parity = 0; - else if(p_cfg->fmt & USERIAL_PARITY_EVEN) - parity = PARENB; - else if(p_cfg->fmt & USERIAL_PARITY_ODD) - parity = (PARENB | PARODD); - else + if (userial_cb.sock == -1) { - LOGE("userial_open: unsupported parity bit mode"); + LOGE("userial_open: failed to open UART port"); return FALSE; } - if(p_cfg->fmt & USERIAL_STOPBITS_1) - stop_bits = 0; - else if(p_cfg->fmt & USERIAL_STOPBITS_2) - stop_bits = CSTOPB; - else - { - LOGE("userial_open: unsupported stop bits"); - return FALSE; - } - - sprintf(device_name, "%s", userial_dev[port]); - LOGI("userial_open: opening %s", device_name); - - if ((userial_cb.sock = open(device_name, O_RDWR)) == -1) - { - LOGE("userial_open: unable to open %s", device_name); - return FALSE; - } - - tcflush(userial_cb.sock, TCIOFLUSH); - - tcgetattr(userial_cb.sock, &termios); - cfmakeraw(&termios); - termios.c_cflag |= (CRTSCTS | stop_bits); - tcsetattr(userial_cb.sock, TCSANOW, &termios); - - tcflush(userial_cb.sock, TCIOFLUSH); - - /* set input/output baudrate */ - cfsetospeed(&termios, baud); - cfsetispeed(&termios, baud); - tcsetattr(userial_cb.sock, TCSANOW, &termios); - -#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) - userial_ioctl_init_bt_wake(userial_cb.sock); -#endif USERIALDBG( "sock = %d", userial_cb.sock); userial_cb.port = port; memcpy(&userial_cb.cfg, p_cfg, sizeof(tUSERIAL_CFG)); - pthread_attr_init(&thread_attr); if (pthread_create(&(userial_cb.read_thread), &thread_attr, \ userial_read_thread, NULL) != 0 ) { - LOGE("pthread_create failed!\n\r"); + LOGE("pthread_create failed!"); return FALSE; } if(pthread_getschedparam(userial_cb.read_thread, &policy, ¶m)==0) { - policy = SCHED_FIFO; - param.sched_priority = BTVND_USERIAL_READ_THREAD_PRIORITY; - pthread_setschedparam(userial_cb.read_thread, policy, ¶m); + policy = BTHC_LINUX_BASE_POLICY; +#if (BTHC_LINUX_BASE_POLICY!=SCHED_NORMAL) + param.sched_priority = BTHC_USERIAL_READ_THREAD_PRIORITY; +#endif + result = pthread_setschedparam(userial_cb.read_thread, policy, ¶m); + if (result != 0) + { + LOGW("userial_open: pthread_setschedparam failed (%s)", \ + strerror(result)); + } } return TRUE; @@ -588,8 +460,8 @@ uint16_t userial_read(uint8_t *p_buffer, uint16_t len) if(userial_cb.p_rx_hdr->len == 0) { - if (bt_vendor_cbacks) - bt_vendor_cbacks->dealloc((TRANSAC) userial_cb.p_rx_hdr, \ + if (bt_hc_cbacks) + bt_hc_cbacks->dealloc((TRANSAC) userial_cb.p_rx_hdr, \ (char *) (userial_cb.p_rx_hdr+1)); userial_cb.p_rx_hdr = NULL; @@ -598,15 +470,10 @@ uint16_t userial_read(uint8_t *p_buffer, uint16_t len) if(userial_cb.p_rx_hdr == NULL) { - userial_cb.p_rx_hdr=(VND_BT_HDR *)utils_dequeue(&(userial_cb.rx_q)); + userial_cb.p_rx_hdr=(HC_BT_HDR *)utils_dequeue(&(userial_cb.rx_q)); } } while ((userial_cb.p_rx_hdr != NULL) && (total_len < len)); -#if 0 - if (total_len < len) - USERIALDBG("userial_read() gives %d when asks %d", total_len, len); -#endif - return total_len; } @@ -631,11 +498,6 @@ uint16_t userial_write(uint8_t *p_data, uint16_t len) len -= ret; } -#if 0 - if (total < len) - USERIALDBG("userial_write() does %d when asks %d", total, len); -#endif - return ((uint16_t)total); } @@ -661,21 +523,20 @@ void userial_close(void) if ((result=pthread_join(userial_cb.read_thread, NULL)) < 0) LOGE( "pthread_join() FAILED result:%d", result); -#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) - /* de-assert bt_wake BEFORE closing port */ - ioctl(userial_cb.sock, USERIAL_IOCTL_BT_WAKE_DEASSERT, NULL); -#endif + /* Calling vendor-specific part */ + if (bt_vnd_if) + bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); if ((result=close(userial_cb.sock)) < 0) LOGE( "close(sock:%d) FAILED result:%d", userial_cb.sock, result); userial_cb.sock = -1; - if (bt_vendor_cbacks) + if (bt_hc_cbacks) { while ((p_buf = utils_dequeue (&(userial_cb.rx_q))) != NULL) { - bt_vendor_cbacks->dealloc(p_buf, (char *) ((VND_BT_HDR *)p_buf+1)); + bt_hc_cbacks->dealloc(p_buf, (char *) ((HC_BT_HDR *)p_buf+1)); } } } @@ -691,8 +552,6 @@ void userial_close(void) *******************************************************************************/ void userial_change_baud(uint8_t baud) { - struct termios termios; - USERIALDBG("userial_change_baud: Closing UART Port"); userial_close(); @@ -730,42 +589,9 @@ void userial_ioctl(userial_ioctl_op_t op, void *p_data) send_wakeup_signal(USERIAL_RX_FLOW_OFF); break; -#if (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) - case USERIAL_OP_ASSERT_BT_WAKE: - USERIALDBG("##### userial_ioctl: Asserting BT_Wake ####"); - ioctl(userial_cb.sock, USERIAL_IOCTL_BT_WAKE_ASSERT, NULL); - break; - - case USERIAL_OP_DEASSERT_BT_WAKE: - USERIALDBG("##### userial_ioctl: De-asserting BT_Wake ####"); - ioctl(userial_cb.sock, USERIAL_IOCTL_BT_WAKE_DEASSERT, NULL); - break; - - case USERIAL_OP_GET_BT_WAKE_STATE: - ioctl(userial_cb.sock, USERIAL_IOCTL_BT_WAKE_GET_ST, p_data); - break; -#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE) - case USERIAL_OP_INIT: default: break; } } -/******************************************************************************* -** -** Function userial_set_port -** -** Description Configure UART port name -** -** Returns 0 : Success -** Otherwise : Fail -** -*******************************************************************************/ -int userial_set_port(char *p_conf_name, char *p_conf_value, int param) -{ - strcpy(userial_dev[USERIAL_PORT_1], p_conf_value); - - return 0; -} - diff --git a/vendor/libvendor/src/utils.c b/hci/src/utils.c index 64b4f73..9c1711b 100644 --- a/vendor/libvendor/src/utils.c +++ b/hci/src/utils.c @@ -56,7 +56,7 @@ #include <errno.h> #include <pthread.h> #include <time.h> -#include "bt_vendor_brcm.h" +#include "bt_hci_bdroid.h" #include "utils.h" /****************************************************************************** @@ -122,16 +122,16 @@ void utils_queue_init (BUFFER_Q *p_q) *******************************************************************************/ void utils_enqueue (BUFFER_Q *p_q, void *p_buf) { - VND_BUFFER_HDR_T *p_hdr; + HC_BUFFER_HDR_T *p_hdr; - p_hdr = (VND_BUFFER_HDR_T *) ((uint8_t *) p_buf - BT_VND_BUFFER_HDR_SIZE); + p_hdr = (HC_BUFFER_HDR_T *) ((uint8_t *) p_buf - BT_HC_BUFFER_HDR_SIZE); pthread_mutex_lock(&utils_mutex); if (p_q->p_last) { - VND_BUFFER_HDR_T *p_last_hdr = \ - (VND_BUFFER_HDR_T *)((uint8_t *)p_q->p_last - BT_VND_BUFFER_HDR_SIZE); + HC_BUFFER_HDR_T *p_last_hdr = \ + (HC_BUFFER_HDR_T *)((uint8_t *)p_q->p_last - BT_HC_BUFFER_HDR_SIZE); p_last_hdr->p_next = p_hdr; } @@ -157,7 +157,7 @@ void utils_enqueue (BUFFER_Q *p_q, void *p_buf) *******************************************************************************/ void *utils_dequeue (BUFFER_Q *p_q) { - VND_BUFFER_HDR_T *p_hdr; + HC_BUFFER_HDR_T *p_hdr; pthread_mutex_lock(&utils_mutex); @@ -167,10 +167,10 @@ void *utils_dequeue (BUFFER_Q *p_q) return (NULL); } - p_hdr=(VND_BUFFER_HDR_T *)((uint8_t *)p_q->p_first-BT_VND_BUFFER_HDR_SIZE); + p_hdr=(HC_BUFFER_HDR_T *)((uint8_t *)p_q->p_first-BT_HC_BUFFER_HDR_SIZE); if (p_hdr->p_next) - p_q->p_first = ((uint8_t *)p_hdr->p_next + BT_VND_BUFFER_HDR_SIZE); + p_q->p_first = ((uint8_t *)p_hdr->p_next + BT_HC_BUFFER_HDR_SIZE); else { p_q->p_first = NULL; @@ -183,7 +183,7 @@ void *utils_dequeue (BUFFER_Q *p_q) pthread_mutex_unlock(&utils_mutex); - return ((uint8_t *)p_hdr + BT_VND_BUFFER_HDR_SIZE); + return ((uint8_t *)p_hdr + BT_HC_BUFFER_HDR_SIZE); } /******************************************************************************* @@ -199,12 +199,12 @@ void *utils_dequeue (BUFFER_Q *p_q) *******************************************************************************/ void *utils_getnext (void *p_buf) { - VND_BUFFER_HDR_T *p_hdr; + HC_BUFFER_HDR_T *p_hdr; - p_hdr = (VND_BUFFER_HDR_T *) ((uint8_t *) p_buf - BT_VND_BUFFER_HDR_SIZE); + p_hdr = (HC_BUFFER_HDR_T *) ((uint8_t *) p_buf - BT_HC_BUFFER_HDR_SIZE); if (p_hdr->p_next) - return ((uint8_t *)p_hdr->p_next + BT_VND_BUFFER_HDR_SIZE); + return ((uint8_t *)p_hdr->p_next + BT_HC_BUFFER_HDR_SIZE); else return (NULL); } @@ -220,8 +220,8 @@ void *utils_getnext (void *p_buf) *******************************************************************************/ void *utils_remove_from_queue (BUFFER_Q *p_q, void *p_buf) { - VND_BUFFER_HDR_T *p_prev; - VND_BUFFER_HDR_T *p_buf_hdr; + HC_BUFFER_HDR_T *p_prev; + HC_BUFFER_HDR_T *p_buf_hdr; pthread_mutex_lock(&utils_mutex); @@ -231,8 +231,8 @@ void *utils_remove_from_queue (BUFFER_Q *p_q, void *p_buf) return (utils_dequeue (p_q)); } - p_buf_hdr = (VND_BUFFER_HDR_T *)((uint8_t *)p_buf - BT_VND_BUFFER_HDR_SIZE); - p_prev=(VND_BUFFER_HDR_T *)((uint8_t *)p_q->p_first-BT_VND_BUFFER_HDR_SIZE); + p_buf_hdr = (HC_BUFFER_HDR_T *)((uint8_t *)p_buf - BT_HC_BUFFER_HDR_SIZE); + p_prev=(HC_BUFFER_HDR_T *)((uint8_t *)p_q->p_first-BT_HC_BUFFER_HDR_SIZE); for ( ; p_prev; p_prev = p_prev->p_next) { diff --git a/main/Android.mk b/main/Android.mk index c8fbb40..53b6158 100755 --- a/main/Android.mk +++ b/main/Android.mk @@ -82,7 +82,7 @@ LOCAL_C_INCLUDES+= . \ $(LOCAL_PATH)/../udrv/include \ $(LOCAL_PATH)/../btif/include \ $(LOCAL_PATH)/../btif/co \ - $(LOCAL_PATH)/../vendor/libvendor/include\ + $(LOCAL_PATH)/../hci/include\ $(LOCAL_PATH)/../brcm/include \ $(LOCAL_PATH)/../embdrv/sbc/encoder/include \ $(LOCAL_PATH)/../audio_a2dp_hw @@ -109,7 +109,7 @@ endif LOCAL_SHARED_LIBRARIES := \ libcutils \ libpower \ - libbt-vendor + libbt-hci #LOCAL_WHOLE_STATIC_LIBRARIES := libbt-brcm_gki libbt-brcm_stack libbt-brcm_bta LOCAL_STATIC_LIBRARIES := libbt-brcm_gki libbt-brcm_bta libbt-brcm_stack @@ -118,6 +118,7 @@ LOCAL_MODULE := bluetooth.default LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_REQUIRED_MODULES := libbt-hci libbt-vendor bt_stack.conf bt_did.conf auto_pair_devlist.conf include $(LOCAL_PATH)/../include/buildcfg.mk diff --git a/main/bte_conf.c b/main/bte_conf.c index a03e7be..662593a 100644 --- a/main/bte_conf.c +++ b/main/bte_conf.c @@ -68,10 +68,14 @@ /****************************************************************************** ** Externs ******************************************************************************/ +extern BOOLEAN hci_logging_enabled; +extern char hci_logfile[256]; extern BOOLEAN trace_conf_enabled; void bte_trace_conf(char *p_name, char *p_conf_value); int device_name_cfg(char *p_conf_name, char *p_conf_value); int device_class_cfg(char *p_conf_name, char *p_conf_value); +int logging_cfg_onoff(char *p_conf_name, char *p_conf_value); +int logging_set_filepath(char *p_conf_name, char *p_conf_value); int trace_cfg_onoff(char *p_conf_name, char *p_conf_value); BD_NAME local_device_default_name = BTM_DEF_LOCAL_NAME; @@ -131,6 +135,8 @@ typedef UINT8 tCONF_DID; static const conf_entry_t conf_table[] = { /*{"Name", device_name_cfg}, {"Class", device_class_cfg},*/ + {"BtSnoopLogOutput", logging_cfg_onoff}, + {"BtSnoopFileName", logging_set_filepath}, {"TraceConf", trace_cfg_onoff}, {(const char *) NULL, NULL} }; @@ -175,6 +181,21 @@ int device_class_cfg(char *p_conf_name, char *p_conf_value) return 0; } +int logging_cfg_onoff(char *p_conf_name, char *p_conf_value) +{ + if (strcmp(p_conf_value, "true") == 0) + hci_logging_enabled = TRUE; + else + hci_logging_enabled = FALSE; + return 0; +} + +int logging_set_filepath(char *p_conf_name, char *p_conf_value) +{ + strcpy(hci_logfile, p_conf_value); + return 0; +} + int trace_cfg_onoff(char *p_conf_name, char *p_conf_value) { trace_conf_enabled = (strcmp(p_conf_value, "true") == 0) ? TRUE : FALSE; diff --git a/main/bte_main.c b/main/bte_main.c index 49d964e..f724bae 100644 --- a/main/bte_main.c +++ b/main/bte_main.c @@ -3,44 +3,44 @@ * Copyright (C) 2009-2012 Broadcom Corporation * * This program is the proprietary software of Broadcom Corporation and/or its - * licensors, and may only be used, duplicated, modified or distributed - * pursuant to the terms and conditions of a separate, written license - * agreement executed between you and Broadcom (an "Authorized License"). - * Except as set forth in an Authorized License, Broadcom grants no license - * (express or implied), right to use, or waiver of any kind with respect to - * the Software, and Broadcom expressly reserves all rights in and to the - * Software and all intellectual property rights therein. - * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS + * licensors, and may only be used, duplicated, modified or distributed + * pursuant to the terms and conditions of a separate, written license + * agreement executed between you and Broadcom (an "Authorized License"). + * Except as set forth in an Authorized License, Broadcom grants no license + * (express or implied), right to use, or waiver of any kind with respect to + * the Software, and Broadcom expressly reserves all rights in and to the + * Software and all intellectual property rights therein. + * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE - * ALL USE OF THE SOFTWARE. + * ALL USE OF THE SOFTWARE. * * Except as expressly set forth in the Authorized License, * - * 1. This program, including its structure, sequence and organization, - * constitutes the valuable trade secrets of Broadcom, and you shall - * use all reasonable efforts to protect the confidentiality thereof, - * and to use this information only in connection with your use of + * 1. This program, including its structure, sequence and organization, + * constitutes the valuable trade secrets of Broadcom, and you shall + * use all reasonable efforts to protect the confidentiality thereof, + * and to use this information only in connection with your use of * Broadcom integrated circuit products. * - * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED - * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, - * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, - * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY - * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, - * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, - * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, + * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT * OF USE OR PERFORMANCE OF THE SOFTWARE. * * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR - * ITS LICENSORS BE LIABLE FOR - * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY - * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO - * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM - * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR - * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE - * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE - * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF + * ITS LICENSORS BE LIABLE FOR + * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY + * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO + * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR + * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE + * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE + * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. * ******************************************************************************/ @@ -50,17 +50,18 @@ * Filename: bte_main.c * * Description: Contains BTE core stack initialization and shutdown code - * + * ******************************************************************************/ #include <fcntl.h> #include <stdlib.h> +#include <assert.h> #include "gki.h" #include "bd.h" #include "btu.h" #include "bte.h" #include "bta_api.h" -#include "bt_vendor_lib.h" +#include "bt_hci_lib.h" /******************************************************************************* ** Constants & Macros @@ -71,15 +72,27 @@ #define BTE_STACK_CONF_FILE "/etc/bluetooth/bt_stack.conf" #endif +/* if not specified in .txt file then use this as default */ +#ifndef HCI_LOGGING_FILENAME +#define HCI_LOGGING_FILENAME "/data/misc/bluedroid/btsnoop_hci.log" +#endif + /******************************************************************************* ** Local type definitions *******************************************************************************/ +/****************************************************************************** +** Variables +******************************************************************************/ +BOOLEAN hci_logging_enabled = FALSE; /* by default, turn hci log off */ +char hci_logfile[256] = HCI_LOGGING_FILENAME; + + /******************************************************************************* ** Static variables *******************************************************************************/ -static bt_vendor_interface_t *bt_vendor_if=NULL; -static const bt_vendor_callbacks_t vnd_callbacks; +static bt_hc_interface_t *bt_hc_if=NULL; +static const bt_hc_callbacks_t hc_callbacks; static BOOLEAN lpm_enabled = FALSE; /******************************************************************************* @@ -95,14 +108,9 @@ BTU_API extern void BTE_Init (void); BT_API extern void BTE_LoadStack(void); BT_API void BTE_UnloadStack(void); extern void scru_flip_bda (BD_ADDR dst, const BD_ADDR src); -extern void btsnoop_init(void); -extern void btsnoop_open(void); -extern void btsnoop_close(void); -extern void btsnoop_cleanup (void); extern void bte_load_conf(const char *p_path); - /******************************************************************************* ** System Task Configuration *******************************************************************************/ @@ -125,10 +133,10 @@ UINT32 bte_btu_stack[(BTE_BTU_STACK_SIZE + 3) / 4]; ******************************************************************************/ void bte_main_in_hw_init(void) { - if ( (bt_vendor_if = (bt_vendor_interface_t *) bt_vendor_get_interface()) \ + if ( (bt_hc_if = (bt_hc_interface_t *) bt_hc_get_interface()) \ == NULL) { - APPL_TRACE_ERROR0("!!! Failed to get BtVendorInterface !!!"); + APPL_TRACE_ERROR0("!!! Failed to get BtHostControllerInterface !!!"); } } @@ -154,7 +162,6 @@ void bte_main_boot_entry(void) /* Initialize trace feature */ BTTRC_TraceInit(MAX_TRACE_RAM_SIZE, &BTE_TraceLogBuf[0], BTTRC_METHOD_RAM); #endif - } /****************************************************************************** @@ -168,12 +175,6 @@ void bte_main_boot_entry(void) ******************************************************************************/ void bte_main_shutdown() { -#if 0 - if (bt_vendor_if) - bt_vendor_if->cleanup(); -#endif - - //bt_vendor_if = NULL; GKI_shutdown(); } @@ -196,17 +197,22 @@ void bte_main_enable(uint8_t *local_addr) lpm_enabled = FALSE; - if (bt_vendor_if) + if (bt_hc_if) { - int result = bt_vendor_if->init(&vnd_callbacks, local_addr); - APPL_TRACE_EVENT1("libbt-vendor init returns %d", result); + int result = bt_hc_if->init(&hc_callbacks, local_addr); + APPL_TRACE_EVENT1("libbt-hci init returns %d", result); + + assert(result == BT_HC_STATUS_SUCCESS); + + if (hci_logging_enabled == TRUE) + bt_hc_if->logging(BT_HC_LOGGING_ON, hci_logfile); /* toggle chip power to ensure we will reset chip in case a previous stack shutdown wasn't completed gracefully */ - bt_vendor_if->set_power(BT_VENDOR_CHIP_PWR_OFF); - bt_vendor_if->set_power(BT_VENDOR_CHIP_PWR_ON); + bt_hc_if->set_power(BT_HC_CHIP_PWR_OFF); + bt_hc_if->set_power(BT_HC_CHIP_PWR_ON); - bt_vendor_if->preload(NULL); + bt_hc_if->preload(NULL); } GKI_create_task((TASKPTR)btu_task, BTU_TASK, BTE_BTU_TASK_STR, @@ -234,12 +240,11 @@ void bte_main_disable(void) GKI_freeze(); - if (bt_vendor_if) + if (bt_hc_if) { - bt_vendor_if->cleanup(); - bt_vendor_if->set_power(BT_VENDOR_CHIP_PWR_OFF); + bt_hc_if->cleanup(); + bt_hc_if->set_power(BT_HC_CHIP_PWR_OFF); } - } /****************************************************************************** @@ -253,8 +258,8 @@ void bte_main_disable(void) ******************************************************************************/ void bte_main_postload_cfg(void) { - if (bt_vendor_if) - bt_vendor_if->postload(NULL); + if (bt_hc_if) + bt_hc_if->postload(NULL); } #if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE) @@ -271,12 +276,12 @@ void bte_main_enable_lpm(BOOLEAN enable) { int result = -1; - if (bt_vendor_if) - result = bt_vendor_if->lpm( \ - (enable == TRUE) ? BT_VENDOR_LPM_ENABLE : BT_VENDOR_LPM_DISABLE \ + if (bt_hc_if) + result = bt_hc_if->lpm( \ + (enable == TRUE) ? BT_HC_LPM_ENABLE : BT_HC_LPM_DISABLE \ ); - APPL_TRACE_EVENT2("vendor lib lpm enable=%d return %d", enable, result); + APPL_TRACE_EVENT2("HC lib lpm enable=%d return %d", enable, result); } /****************************************************************************** @@ -292,10 +297,10 @@ void bte_main_lpm_allow_bt_device_sleep() { int result = -1; - if ((bt_vendor_if) && (lpm_enabled == TRUE)) - result = bt_vendor_if->lpm(BT_VENDOR_LPM_WAKE_DEASSERT); + if ((bt_hc_if) && (lpm_enabled == TRUE)) + result = bt_hc_if->lpm(BT_HC_LPM_WAKE_DEASSERT); - APPL_TRACE_DEBUG1("vendor lib lpm deassertion return %d", result); + APPL_TRACE_DEBUG1("HC lib lpm deassertion return %d", result); } /****************************************************************************** @@ -311,10 +316,10 @@ void bte_main_lpm_wake_bt_device() { int result = -1; - if ((bt_vendor_if) && (lpm_enabled == TRUE)) - result = bt_vendor_if->lpm(BT_VENDOR_LPM_WAKE_ASSERT); + if ((bt_hc_if) && (lpm_enabled == TRUE)) + result = bt_hc_if->lpm(BT_HC_LPM_WAKE_ASSERT); - APPL_TRACE_DEBUG1("vendor lib lpm assertion return %d", result); + APPL_TRACE_DEBUG1("HC lib lpm assertion return %d", result); } #endif // HCILP_INCLUDED @@ -340,8 +345,8 @@ void bte_main_hci_send (BT_HDR *p_msg, UINT16 event) if((sub_event == LOCAL_BR_EDR_CONTROLLER_ID) || \ (sub_event == LOCAL_BLE_CONTROLLER_ID)) { - if (bt_vendor_if) - bt_vendor_if->transmit_buf((TRANSAC)p_msg, \ + if (bt_hc_if) + bt_hc_if->transmit_buf((TRANSAC)p_msg, \ (char *) (p_msg + 1), \ p_msg->len); else @@ -371,7 +376,7 @@ void bte_main_post_reset_init() /***************************************************************************** ** -** libbt-vendor Callback Functions +** libbt-hci Callback Functions ** *****************************************************************************/ @@ -379,76 +384,73 @@ void bte_main_post_reset_init() ** ** Function preload_cb ** -** Description VENDOR LIB CALLBACK API - This function is called -** when vendor lib completed stack preload process +** Description HOST/CONTROLLER LIB CALLBACK API - This function is called +** when the libbt-hci completed stack preload process ** ** Returns None ** ******************************************************************************/ -static void preload_cb(TRANSAC transac, bt_vendor_preload_result_t result) +static void preload_cb(TRANSAC transac, bt_hc_preload_result_t result) { - APPL_TRACE_EVENT1("vnd preload_cb %d [0:SUCCESS 1:FAIL]", result); + APPL_TRACE_EVENT1("HC preload_cb %d [0:SUCCESS 1:FAIL]", result); -// if (result == BT_VENDOR_PRELOAD_SUCCESS) - /* keep going even if firmware patch file is missing */ - { - /* notify BTU task that libbt-vendor is ready */ - GKI_send_event(BTU_TASK, TASK_MBOX_0_EVT_MASK); - } + /* notify BTU task that libbt-hci is ready */ + /* even if PRELOAD process failed */ + GKI_send_event(BTU_TASK, TASK_MBOX_0_EVT_MASK); } /****************************************************************************** ** ** Function postload_cb ** -** Description VENDOR LIB CALLBACK API - This function is called -** when vendor lib completed stack postload process +** Description HOST/CONTROLLER LIB CALLBACK API - This function is called +** when the libbt-hci lib completed stack postload process ** ** Returns None ** ******************************************************************************/ -static void postload_cb(TRANSAC transac, bt_vendor_postload_result_t result) +static void postload_cb(TRANSAC transac, bt_hc_postload_result_t result) { - APPL_TRACE_EVENT1("vnd postload_cb %d", result); + APPL_TRACE_EVENT1("HC postload_cb %d", result); } /****************************************************************************** ** ** Function lpm_cb ** -** Description VENDOR LIB CALLBACK API - This function is called -** back from vendor lib to indicate the current LPM state +** Description HOST/CONTROLLER LIB CALLBACK API - This function is called +** back from the libbt-hci to indicate the current LPM state ** ** Returns None ** ******************************************************************************/ -static void lpm_cb(bt_vendor_lpm_request_result_t result) +static void lpm_cb(bt_hc_lpm_request_result_t result) { - APPL_TRACE_EVENT1("vnd lpm_result_cb %d", result); - lpm_enabled = (result == BT_VENDOR_LPM_ENABLED) ? TRUE : FALSE; + APPL_TRACE_EVENT1("HC lpm_result_cb %d", result); + lpm_enabled = (result == BT_HC_LPM_ENABLED) ? TRUE : FALSE; } /****************************************************************************** ** ** Function hostwake_ind ** -** Description VENDOR LIB CALLOUT API - This function is called -** from vendor lib to indicate the HostWake event +** Description HOST/CONTROLLER LIB CALLOUT API - This function is called +** from the libbt-hci to indicate the HostWake event ** ** Returns None ** ******************************************************************************/ -static void hostwake_ind(bt_vendor_low_power_event_t event) +static void hostwake_ind(bt_hc_low_power_event_t event) { - APPL_TRACE_EVENT1("vnd hostwake_ind %d", event); + APPL_TRACE_EVENT1("HC hostwake_ind %d", event); } /****************************************************************************** ** ** Function alloc ** -** Description VENDOR LIB CALLOUT API - This function is called -** from vendor lib to request for data buffer allocation +** Description HOST/CONTROLLER LIB CALLOUT API - This function is called +** from the libbt-hci to request for data buffer allocation ** ** Returns NULL / pointer to allocated buffer ** @@ -458,7 +460,7 @@ static char *alloc(int size) BT_HDR *p_hdr = NULL; /* - APPL_TRACE_DEBUG1("vnd alloc size=%d", size); + APPL_TRACE_DEBUG1("HC alloc size=%d", size); */ p_hdr = (BT_HDR *) GKI_getbuf ((UINT16) size); @@ -475,31 +477,42 @@ static char *alloc(int size) ** ** Function dealloc ** -** Description VENDOR LIB CALLOUT API - This function is called -** from vendor lib to release the data buffer allocated +** Description HOST/CONTROLLER LIB CALLOUT API - This function is called +** from the libbt-hci to release the data buffer allocated ** through the alloc call earlier ** -** Returns bt_vnd_status_t +** Bluedroid libbt-hci library uses 'transac' parameter to +** pass data-path buffer/packet across bt_hci_lib interface +** boundary. The 'p_buf' is not intended to be used here +** but might point to data portion of data-path buffer. +** +** Returns bt_hc_status_t ** ******************************************************************************/ static int dealloc(TRANSAC transac, char *p_buf) { GKI_freebuf(transac); - return BT_VENDOR_STATUS_SUCCESS; + return BT_HC_STATUS_SUCCESS; } /****************************************************************************** ** ** Function data_ind ** -** Description VENDOR LIB CALLOUT API - This function is called -** from vendor lib to pass in the received HCI packets +** Description HOST/CONTROLLER LIB CALLOUT API - This function is called +** from the libbt-hci to pass in the received HCI packets ** ** The core stack is responsible for releasing the data buffer -** passed in from vendor lib once the core stack has done with -** it. +** passed in from the libbt-hci once the core stack has done +** with it. ** -** Returns bt_vnd_status_t +** Bluedroid libbt-hci library uses 'transac' parameter to +** pass data-path buffer/packet across bt_hci_lib interface +** boundary. The 'p_buf' and 'len' parameters are not intended +** to be used here but might point to data portion in data- +** path buffer and length of valid data respectively. +** +** Returns bt_hc_status_t ** ******************************************************************************/ static int data_ind(TRANSAC transac, char *p_buf, int len) @@ -507,37 +520,42 @@ static int data_ind(TRANSAC transac, char *p_buf, int len) BT_HDR *p_msg = (BT_HDR *) transac; /* - APPL_TRACE_DEBUG2("vnd data_ind event=0x%04X (len=%d)", p_msg->event, len); + APPL_TRACE_DEBUG2("HC data_ind event=0x%04X (len=%d)", p_msg->event, len); */ GKI_send_msg (BTU_TASK, BTU_HCI_RCV_MBOX, transac); - return BT_VENDOR_STATUS_SUCCESS; + return BT_HC_STATUS_SUCCESS; } /****************************************************************************** ** ** Function tx_result ** -** Description VENDOR LIB CALLBACK API - This function is called -** from vendor lib once it has processed/sent the prior data +** Description HOST/CONTROLLER LIB CALLBACK API - This function is called +** from the libbt-hci once it has processed/sent the prior data ** buffer which core stack passed to it through transmit_buf ** call earlier. ** ** The core stack is responsible for releasing the data buffer ** if it has been completedly processed. ** -** Returns bt_vnd_status_t +** Bluedroid libbt-hci library uses 'transac' parameter to +** pass data-path buffer/packet across bt_hci_lib interface +** boundary. The 'p_buf' is not intended to be used here +** but might point to data portion in data-path buffer. +** +** Returns bt_hc_status_t ** ******************************************************************************/ static int tx_result(TRANSAC transac, char *p_buf, \ - bt_vendor_transmit_result_t result) + bt_hc_transmit_result_t result) { /* - APPL_TRACE_DEBUG2("vnd tx_result %d (event=%04X)", result, \ + APPL_TRACE_DEBUG2("HC tx_result %d (event=%04X)", result, \ ((BT_HDR *)transac)->event); */ - if (result == BT_VENDOR_TX_FRAGMENT) + if (result == BT_HC_TX_FRAGMENT) { GKI_send_msg (BTU_TASK, BTU_HCI_RCV_MBOX, transac); } @@ -546,14 +564,14 @@ static int tx_result(TRANSAC transac, char *p_buf, \ GKI_freebuf(transac); } - return BT_VENDOR_STATUS_SUCCESS; + return BT_HC_STATUS_SUCCESS; } /***************************************************************************** -** The libbt-vendor Callback Functions Table +** The libbt-hci Callback Functions Table *****************************************************************************/ -static const bt_vendor_callbacks_t vnd_callbacks = { - sizeof(bt_vendor_callbacks_t), +static const bt_hc_callbacks_t hc_callbacks = { + sizeof(bt_hc_callbacks_t), preload_cb, postload_cb, lpm_cb, diff --git a/vendor/Android.mk b/vendor/Android.mk deleted file mode 100644 index d940fa5..0000000 --- a/vendor/Android.mk +++ /dev/null @@ -1,3 +0,0 @@ -ifneq ($(TARGET_SIMULATOR),true)
- include $(call all-subdir-makefiles)
-endif
diff --git a/vendor/firmware/Android.mk b/vendor/firmware/Android.mk deleted file mode 100644 index 8338432..0000000 --- a/vendor/firmware/Android.mk +++ /dev/null @@ -1,2 +0,0 @@ -include $(call all-subdir-makefiles) - diff --git a/vendor/firmware/LICENSE.TXT b/vendor/firmware/LICENSE.TXT deleted file mode 100644 index a418468..0000000 --- a/vendor/firmware/LICENSE.TXT +++ /dev/null @@ -1,216 +0,0 @@ -SOFTWARE LICENSE AGREEMENT - -Unless you and Broadcom Corporation ("Broadcom") execute a separate written -software license agreement governing use of the accompanying software, this -software is licensed to you under the terms of this Software License -Agreement ("Agreement"). - -ANY USE, REPRODUCTION OR DISTRIBUTION OF THE SOFTWARE CONSTITUTES YOUR -ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS. - -1.1. "Broadcom Product" means any of the proprietary integrated circuit -product(s) sold by Broadcom with which the Software was designed to be used, -or their successors. - -1.2. "Licensee" means you or if you are accepting on behalf of an entity -then the entity and its affiliates exercising rights under, and complying -with all of the terms of this Agreement. - -1.3. "Software" shall mean that software made available by Broadcom to -Licensee in binary code form with this Agreement. - -2. LICENSE GRANT; OWNERSHIP - -2.1. License Grants. Subject to the terms and conditions of this Agreement, -Broadcom hereby grants to Licensee a non-exclusive, non-transferable, -royalty-free license (i) to use and integrate the Software in conjunction -with any other software; and (ii) to reproduce and distribute the Software -complete, unmodified and only for use with a Broadcom Product. - -2.2. Restriction on Modification. If and to the extent that the Software is -designed to be compliant with any published communications standard -(including, without limitation, DOCSIS, HomePNA, IEEE, and ITU standards), -Licensee may not make any modifications to the Software that would cause the -Software or the accompanying Broadcom Products to be incompatible with such -standard. - -2.3. Restriction on Distribution. Licensee shall only distribute the -Software (a) under the terms of this Agreement and a copy of this Agreement -accompanies such distribution, and (b) agrees to defend and indemnify -Broadcom and its licensors from and against any damages, costs, liabilities, -settlement amounts and/or expenses (including attorneys' fees) incurred in -connection with any claim, lawsuit or action by any third party that arises -or results from the use or distribution of any and all Software by the -Licensee except as contemplated herein. - -2.4. Proprietary Notices. Licensee shall not remove, efface or obscure any -copyright or trademark notices from the Software. Licensee shall include -reproductions of the Broadcom copyright notice with each copy of the -Software, except where such Software is embedded in a manner not readily -accessible to the end user. Licensee acknowledges that any symbols, -trademarks, tradenames, and service marks adopted by Broadcom to identify the -Software belong to Broadcom and that Licensee shall have no rights therein. - -2.5. Ownership. Broadcom shall retain all right, title and interest, -including all intellectual property rights, in and to the Software. Licensee -hereby covenants that it will not assert any claim that the Software created -by or for Broadcom infringe any intellectual property right owned or -controlled by Licensee. - -2.6. No Other Rights Granted; Restrictions. Apart from the license rights -expressly set forth in this Agreement, Broadcom does not grant and Licensee -does not receive any ownership right, title or interest nor any security -interest or other interest in any intellectual property rights relating to -the Software, nor in any copy of any part of the foregoing. No license is -granted to Licensee in any human readable code of the Software (source code). -Licensee shall not (i) use, license, sell or otherwise distribute the -Software except as provided in this Agreement, (ii) attempt to reverse -engineer, decompile or disassemble any portion of the Software; or (iii) use -the Software or other material in violation of any applicable law or -regulation, including but not limited to any regulatory agency, such as FCC, -rules. - -3. NO WARRANTY OR SUPPORT - -3.1. No Warranty. THE SOFTWARE IS OFFERED "AS IS," AND BROADCOM GRANTS AND -LICENSEE RECEIVES NO WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, BY STATUTE, -COMMUNICATION OR CONDUCT WITH LICENSEE, OR OTHERWISE. BROADCOM SPECIFICALLY -DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A SPECIFIC -PURPOSE OR NONINFRINGEMENT CONCERNING THE SOFTWARE OR ANY UPGRADES TO OR -DOCUMENTATION FOR THE SOFTWARE. WITHOUT LIMITATION OF THE ABOVE, BROADCOM -GRANTS NO WARRANTY THAT THE SOFTWARE IS ERROR-FREE OR WILL OPERATE WITHOUT -INTERRUPTION, AND GRANTS NO WARRANTY REGARDING ITS USE OR THE RESULTS -THEREFROM INCLUDING, WITHOUT LIMITATION, ITS CORRECTNESS, ACCURACY OR -RELIABILITY. - -3.2. No Support. Nothing in this agreement shall obligate Broadcom to -provide any support for the Software. Broadcom may, but shall be under no -obligation to, correct any defects in the Software and/or provide updates to -licensees of the Software. Licensee shall make reasonable efforts to -promptly report to Broadcom any defects it finds in the Software, as an aid -to creating improved revisions of the Software. - -3.3. Dangerous Applications. The Software is not designed, intended, or -certified for use in components of systems intended for the operation of -weapons, weapons systems, nuclear installations, means of mass -transportation, aviation, life-support computers or equipment (including -resuscitation equipment and surgical implants), pollution control, hazardous -substances management, or for any other dangerous application in which the -failure of the Software could create a situation where personal injury or -death may occur. Licensee understands that use of the Software in such -applications is fully at the risk of Licensee. - -4. TERM AND TERMINATION - -4.1. Termination. This Agreement will automatically terminate if Licensee -fails to comply with any of the terms and conditions hereof. In such event, -Licensee must destroy all copies of the Software and all of its component -parts. - -4.2. Effect Of Termination. Upon any termination of this Agreement, the -rights and licenses granted to Licensee under this Agreement shall -immediately terminate. - -4.3. Survival. The rights and obligations under this Agreement which by -their nature should survive termination will remain in effect after -expiration or termination of this Agreement. - -5. CONFIDENTIALITY - -5.1. Obligations. Licensee acknowledges and agrees that any documentation -relating to the Software, and any other information (if such other -information is identified as confidential or should be recognized as -confidential under the circumstances) provided to Licensee by Broadcom -hereunder (collectively, "Confidential Information") constitute the -confidential and proprietary information of Broadcom, and that Licensee's -protection thereof is an essential condition to Licensee's use and possession -of the Software. Licensee shall retain all Confidential Information in -strict confidence and not disclose it to any third party or use it in any way -except under a written agreement with terms and conditions at least as -protective as the terms of this Section. Licensee will exercise at least the -same amount of diligence in preserving the secrecy of the Confidential -Information as it uses in preserving the secrecy of its own most valuable -confidential information, but in no event less than reasonable diligence. -Information shall not be considered Confidential Information if and to the -extent that it: (i) was in the public domain at the time it was disclosed or -has entered the public domain through no fault of Licensee; (ii) was known to -Licensee, without restriction, at the time of disclosure as proven by the -files of Licensee in existence at the time of disclosure; or (iii) becomes -known to Licensee, without restriction, from a source other than Broadcom -without breach of this Agreement by Licensee and otherwise not in violation -of Broadcom's rights. - -5.2. Return of Confidential Information. Notwithstanding the foregoing, all -documents and other tangible objects containing or representing Broadcom -Confidential Information and all copies thereof which are in the possession -of Licensee shall be and remain the property of Broadcom, and shall be -promptly returned to Broadcom upon written request by Broadcom or upon -termination of this Agreement. - -6. LIMITATION OF LIABILITY -TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ANY OF -BROADCOM'S LICENSORS HAVE ANY LIABILITY FOR ANY INDIRECT, INCIDENTAL, -SPECIAL, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER FOR BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE) OR -OTHERWISE, ARISING OUT OF THIS AGREEMENT, INCLUDING BUT NOT LIMITED TO LOSS -OF PROFITS, EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. IN NO EVENT WILL BROADCOM'S LIABILITY WHETHER IN CONTRACT, TORT -(INCLUDING NEGLIGENCE), OR OTHERWISE, EXCEED THE AMOUNT PAID BY LICENSEE FOR -SOFTWARE UNDER THIS AGREEMENT. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING -ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. - -7. MISCELLANEOUS - -7.1. Export Regulations. YOU UNDERSTAND AND AGREE THAT THE SOFTWARE IS -SUBJECT TO UNITED STATES AND OTHER APPLICABLE EXPORT-RELATED LAWS AND -REGULATIONS AND THAT YOU MAY NOT EXPORT, RE-EXPORT OR TRANSFER THE SOFTWARE -OR ANY DIRECT PRODUCT OF THE SOFTWARE EXCEPT AS PERMITTED UNDER THOSE LAWS. -WITHOUT LIMITING THE FOREGOING, EXPORT, RE-EXPORT OR TRANSFER OF THE SOFTWARE -TO CUBA, IRAN, NORTH KOREA, SUDAN AND SYRIA IS PROHIBITED. - -7.2 Assignment. This Agreement shall be binding upon and inure to the -benefit of the parties and their respective successors and assigns, provided, -however that Licensee may not assign this Agreement or any rights or -obligation hereunder, directly or indirectly, by operation of law or -otherwise, without the prior written consent of Broadcom, and any such -attempted assignment shall be void. Notwithstanding the foregoing, Licensee -may assign this Agreement to a successor to all or substantially all of its -business or assets to which this Agreement relates that is not a competitor -of Broadcom. - -7.3. Governing Law; Venue. This Agreement shall be governed by the laws of -California without regard to any conflict-of-laws rules, and the United -Nations Convention on Contracts for the International Sale of Goods is hereby -excluded. The sole jurisdiction and venue for actions related to the subject -matter hereof shall be the state and federal courts located in the County of -Orange, California, and both parties hereby consent to such jurisdiction and -venue. - -7.4. Severability. All terms and provisions of this Agreement shall, if -possible, be construed in a manner which makes them valid, but in the event -any term or provision of this Agreement is found by a court of competent -jurisdiction to be illegal or unenforceable, the validity or enforceability -of the remainder of this Agreement shall not be affected if the illegal or -unenforceable provision does not materially affect the intent of this -Agreement. If the illegal or unenforceable provision materially affects the -intent of the parties to this Agreement, this Agreement shall become -terminated. - -7.5. Equitable Relief. Licensee hereby acknowledges that its breach of this -Agreement would cause irreparable harm and significant injury to Broadcom -that may be difficult to ascertain and that a remedy at law would be -inadequate. Accordingly, Licensee agrees that Broadcom shall have the right -to seek and obtain immediate injunctive relief to enforce obligations under -the Agreement in addition to any other rights and remedies it may have. - -7.6. Waiver. The waiver of, or failure to enforce, any breach or default -hereunder shall not constitute the waiver of any other or subsequent breach -or default. - -7.7. Entire Agreement. This Agreement sets forth the entire Agreement -between the parties and supersedes any and all prior proposals, agreements -and representations between them, whether written or oral concerning the -Software. This Agreement may be changed only by mutual agreement of the -parties in writing. diff --git a/vendor/firmware/bcm4329/Android.mk b/vendor/firmware/bcm4329/Android.mk deleted file mode 100644 index e8e3449..0000000 --- a/vendor/firmware/bcm4329/Android.mk +++ /dev/null @@ -1,19 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := bcm4329.hcd -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/firmware - -#LOCAL_SRC_FILES := $(LOCAL_MODULE) -LOCAL_SRC_FILES := BCM4329B1_002.002.023.0944.0956.hcd - -#PRODUCT_COPY_FILES += \ -# hardware/broadcom/bt/firmware/bcm4330/BCM4329B1_002.002.023.0944.0956.hcd:system/vendor/firmware/BCM4329B1_002.002.023.0944.0956.hcd \ - -LOCAL_MODULE_TAGS := optional - -include $(BUILD_PREBUILT) - - diff --git a/vendor/firmware/bcm4329/BCM4329B1_002.002.023.0944.0956.hcd b/vendor/firmware/bcm4329/BCM4329B1_002.002.023.0944.0956.hcd Binary files differdeleted file mode 100644 index 581125a..0000000 --- a/vendor/firmware/bcm4329/BCM4329B1_002.002.023.0944.0956.hcd +++ /dev/null diff --git a/vendor/firmware/bcm4330/Android.mk b/vendor/firmware/bcm4330/Android.mk deleted file mode 100644 index 3742d98..0000000 --- a/vendor/firmware/bcm4330/Android.mk +++ /dev/null @@ -1,19 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := bcm4330.hcd -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $(TARGET_OUT)/vendor/firmware - -#LOCAL_SRC_FILES := $(LOCAL_MODULE) -LOCAL_SRC_FILES := BCM4330B1.hcd - -#PRODUCT_COPY_FILES += \ -# hardware/broadcom/bt/firmware/bcm4330/BCM4330B1.hcd:system/vendor/firmware/BCM4330B1.hcd - -LOCAL_MODULE_TAGS := eng - -include $(BUILD_PREBUILT) - - diff --git a/vendor/firmware/bcm4330/BCM4330B1.hcd b/vendor/firmware/bcm4330/BCM4330B1.hcd Binary files differdeleted file mode 100644 index 983d40e..0000000 --- a/vendor/firmware/bcm4330/BCM4330B1.hcd +++ /dev/null diff --git a/vendor/libvendor/include/bt_vendor_brcm.h b/vendor/libvendor/include/bt_vendor_brcm.h deleted file mode 100644 index 5d84e8b..0000000 --- a/vendor/libvendor/include/bt_vendor_brcm.h +++ /dev/null @@ -1,441 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2009-2012 Broadcom Corporation - * - * This program is the proprietary software of Broadcom Corporation and/or its - * licensors, and may only be used, duplicated, modified or distributed - * pursuant to the terms and conditions of a separate, written license - * agreement executed between you and Broadcom (an "Authorized License"). - * Except as set forth in an Authorized License, Broadcom grants no license - * (express or implied), right to use, or waiver of any kind with respect to - * the Software, and Broadcom expressly reserves all rights in and to the - * Software and all intellectual property rights therein. - * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS - * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE - * ALL USE OF THE SOFTWARE. - * - * Except as expressly set forth in the Authorized License, - * - * 1. This program, including its structure, sequence and organization, - * constitutes the valuable trade secrets of Broadcom, and you shall - * use all reasonable efforts to protect the confidentiality thereof, - * and to use this information only in connection with your use of - * Broadcom integrated circuit products. - * - * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED - * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, - * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, - * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY - * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, - * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, - * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR - * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT - * OF USE OR PERFORMANCE OF THE SOFTWARE. - * - * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR - * ITS LICENSORS BE LIABLE FOR - * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY - * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO - * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM - * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR - * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE - * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE - * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF - * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. - * - ******************************************************************************/ - -/****************************************************************************** - * - * Filename: bt_vendor_brcm.h - * - * Description: A wrapper header file of bt_vendor_lib.h - * - * Contains definitions specific for running Broadcom - * Bluetooth stack on Broadcom Bluetooth Controllers - * - ******************************************************************************/ - -#ifndef BT_VENDOR_BRCM_H -#define BT_VENDOR_BRCM_H - -#include "bt_vendor_lib.h" -#include "vnd_buildcfg.h" - -/****************************************************************************** -** Constants & Macros -******************************************************************************/ - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE (!FALSE) -#endif - -#ifndef BTVND_LINUX_BASE_PRIORITY -#define BTVND_LINUX_BASE_PRIORITY 30 -#endif - -#ifndef BTVND_USERIAL_READ_THREAD_PRIORITY -#define BTVND_USERIAL_READ_THREAD_PRIORITY (BTVND_LINUX_BASE_PRIORITY) -#endif - -#ifndef BTVND_MAIN_THREAD_PRIORITY -#define BTVND_MAIN_THREAD_PRIORITY (BTVND_LINUX_BASE_PRIORITY-1) -#endif - -#ifndef BTVND_USERIAL_READ_MEM_SIZE -#define BTVND_USERIAL_READ_MEM_SIZE (1024) -#endif - -/* Vendor lib internal event ID */ -#define VND_EVENT_PRELOAD 0x0001 -#define VND_EVENT_POSTLOAD 0x0002 -#define VND_EVENT_RX 0x0004 -#define VND_EVENT_TX 0x0008 -#define VND_EVENT_LPM_ENABLE 0x0010 -#define VND_EVENT_LPM_DISABLE 0x0020 -#define VND_EVENT_LPM_WAKE_DEVICE 0x0040 -#define VND_EVENT_LPM_ALLOW_SLEEP 0x0080 -#define VND_EVENT_LPM_IDLE_TIMEOUT 0x0100 -#define VND_EVENT_EXIT 0x0200 - -/* Message event mask across vendor lib and stack */ -#define MSG_EVT_MASK 0xFF00 /* eq. BT_EVT_MASK */ -#define MSG_SUB_EVT_MASK 0x00FF /* eq. BT_SUB_EVT_MASK */ - -/* Message event ID passed from vendor lib to stack */ -#define MSG_VND_TO_STACK_HCI_ERR 0x1300 /* eq. BT_EVT_TO_BTU_HCIT_ERR */ -#define MSG_VND_TO_STACK_HCI_ACL 0x1100 /* eq. BT_EVT_TO_BTU_HCI_ACL */ -#define MSG_VND_TO_STACK_HCI_SCO 0x1200 /* eq. BT_EVT_TO_BTU_HCI_SCO */ -#define MSG_VND_TO_STACK_HCI_EVT 0x1000 /* eq. BT_EVT_TO_BTU_HCI_EVT */ -#define MSG_VND_TO_STACK_L2C_SEG_XMIT 0x1900 /* eq. BT_EVT_TO_BTU_L2C_SEG_XMIT */ - -/* Message event ID passed from stack to vendor lib */ -#define MSG_STACK_TO_VND_HCI_ACL 0x2100 /* eq. BT_EVT_TO_LM_HCI_ACL */ -#define MSG_STACK_TO_VND_HCI_SCO 0x2200 /* eq. BT_EVT_TO_LM_HCI_SCO */ -#define MSG_STACK_TO_VND_HCI_CMD 0x2000 /* eq. BT_EVT_TO_LM_HCI_CMD */ - -/* Local Bluetooth Controller ID for BR/EDR */ -#define LOCAL_BR_EDR_CONTROLLER_ID 0 - -/* Run-time configuration file */ -#ifndef VENDOR_LIB_CONF_FILE -#define VENDOR_LIB_CONF_FILE "/etc/bluetooth/bt_vendor.conf" -#endif - -/* Device port name where Bluetooth controller attached */ -#ifndef BLUETOOTH_UART_DEVICE_PORT -#define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyO1" /* maguro */ -#endif - -/* Location of firmware patch files */ -#ifndef FW_PATCHFILE_LOCATION -#define FW_PATCHFILE_LOCATION "/vendor/firmware/" /* maguro */ -#endif - -#ifndef UART_TARGET_BAUD_RATE -#define UART_TARGET_BAUD_RATE 3000000 -#endif - -/* sleep mode - - 0: disable - 1: UART with Host wake/BT wake out of band signals -*/ -#ifndef LPM_SLEEP_MODE -#define LPM_SLEEP_MODE 1 -#endif - -/* Host Stack Idle Threshold in 300ms or 25ms - - In sleep mode 1, this is the number of firmware loops executed with no - activity before the Host wake line is deasserted. Activity includes HCI - traffic excluding certain sleep mode commands and the presence of SCO - connections if the "Allow Host Sleep During SCO" flag is not set to 1. - Each count of this parameter is roughly equivalent to 300ms or 25ms. -*/ -#ifndef LPM_IDLE_THRESHOLD -#define LPM_IDLE_THRESHOLD 1 -#endif - -/* Host Controller Idle Threshold in 300ms or 25ms - - This is the number of firmware loops executed with no activity before the - HC is considered idle. Depending on the mode, HC may then attempt to sleep. - Activity includes HCI traffic excluding certain sleep mode commands and - the presence of ACL/SCO connections. -*/ -#ifndef LPM_HC_IDLE_THRESHOLD -#define LPM_HC_IDLE_THRESHOLD 1 -#endif - -/* BT_WAKE Polarity - 0=Active Low, 1= Active High */ -#ifndef LPM_BT_WAKE_POLARITY -#define LPM_BT_WAKE_POLARITY 1 /* maguro */ -#endif - -/* HOST_WAKE Polarity - 0=Active Low, 1= Active High */ -#ifndef LPM_HOST_WAKE_POLARITY -#define LPM_HOST_WAKE_POLARITY 1 /* maguro */ -#endif - -/* LPM_ALLOW_HOST_SLEEP_DURING_SCO - - When this flag is set to 0, the host is not allowed to sleep while - an SCO is active. In sleep mode 1, the device will keep the host - wake line asserted while an SCO is active. - When this flag is set to 1, the host can sleep while an SCO is active. - This flag should only be set to 1 if SCO traffic is directed to the PCM - interface. -*/ -#ifndef LPM_ALLOW_HOST_SLEEP_DURING_SCO -#define LPM_ALLOW_HOST_SLEEP_DURING_SCO 1 -#endif - -/* LPM_COMBINE_SLEEP_MODE_AND_LPM - - In Mode 0, always set byte 7 to 0. In sleep mode 1, device always - requires permission to sleep between scans / periodic inquiries regardless - of the setting of this byte. In sleep mode 1, if byte is set, device must - have "permission" to sleep during the low power modes of sniff, hold, and - park. If byte is not set, device can sleep without permission during these - modes. Permission to sleep in Mode 1 is obtained if the BT_WAKE signal is - not asserted. -*/ -#ifndef LPM_COMBINE_SLEEP_MODE_AND_LPM -#define LPM_COMBINE_SLEEP_MODE_AND_LPM 1 -#endif - -/* LPM_ENABLE_UART_TXD_TRI_STATE - - When set to 0, the device will not tristate its UART TX line before going - to sleep. - When set to 1, the device will tristate its UART TX line before going to - sleep. -*/ -#ifndef LPM_ENABLE_UART_TXD_TRI_STATE -#define LPM_ENABLE_UART_TXD_TRI_STATE 0 -#endif - -/* LPM_PULSED_HOST_WAKE -*/ -#ifndef LPM_PULSED_HOST_WAKE -#define LPM_PULSED_HOST_WAKE 0 -#endif - -/* LPM_IDLE_TIMEOUT_MULTIPLE - - The multiple factor of host stack idle threshold in 300ms/25ms -*/ -#ifndef LPM_IDLE_TIMEOUT_MULTIPLE -#define LPM_IDLE_TIMEOUT_MULTIPLE 10 -#endif - -/* SCO_CFG_INCLUDED - - Do SCO configuration by default. If the firmware patch had been embedded - with desired SCO configuration, set this FALSE to bypass configuration - from host software. -*/ -#ifndef SCO_CFG_INCLUDED -#define SCO_CFG_INCLUDED TRUE -#endif - -#ifndef SCO_USE_I2S_INTERFACE -#define SCO_USE_I2S_INTERFACE FALSE -#endif - -#if (SCO_USE_I2S_INTERFACE == TRUE) -#define SCO_I2SPCM_PARAM_SIZE 4 - -/* SCO_I2SPCM_IF_MODE - 0=Disable, 1=Enable */ -#ifndef SCO_I2SPCM_IF_MODE -#define SCO_I2SPCM_IF_MODE 1 -#endif - -/* SCO_I2SPCM_IF_ROLE - 0=Slave, 1=Master */ -#ifndef SCO_I2SPCM_IF_ROLE -#define SCO_I2SPCM_IF_ROLE 1 -#endif - -/* SCO_I2SPCM_IF_SAMPLE_RATE - - 0 : 8K - 1 : 16K - 2 : 4K -*/ -#ifndef SCO_I2SPCM_IF_SAMPLE_RATE -#define SCO_I2SPCM_IF_SAMPLE_RATE 0 -#endif - -/* SCO_I2SPCM_IF_CLOCK_RATE - - 0 : 128K - 1 : 256K - 2 : 512K - 3 : 1024K - 4 : 2048K -*/ -#ifndef SCO_I2SPCM_IF_CLOCK_RATE -#define SCO_I2SPCM_IF_CLOCK_RATE 1 -#endif -#endif // SCO_USE_I2S_INTERFACE - - -#define SCO_PCM_PARAM_SIZE 5 - -/* SCO_PCM_ROUTING - - 0 : PCM - 1 : Transport - 2 : Codec - 3 : I2S -*/ -#ifndef SCO_PCM_ROUTING -#define SCO_PCM_ROUTING 0 -#endif - -/* SCO_PCM_IF_CLOCK_RATE - - 0 : 128K - 1 : 256K - 2 : 512K - 3 : 1024K - 4 : 2048K -*/ -#ifndef SCO_PCM_IF_CLOCK_RATE -#define SCO_PCM_IF_CLOCK_RATE 4 -#endif - -/* SCO_PCM_IF_FRAME_TYPE - 0=Short, 1=Long */ -#ifndef SCO_PCM_IF_FRAME_TYPE -#define SCO_PCM_IF_FRAME_TYPE 0 -#endif - -/* SCO_PCM_IF_SYNC_MODE - 0=Slave, 1=Master */ -#ifndef SCO_PCM_IF_SYNC_MODE -#define SCO_PCM_IF_SYNC_MODE 0 -#endif - -/* SCO_PCM_IF_CLOCK_MODE - 0=Slave, 1=Master */ -#ifndef SCO_PCM_IF_CLOCK_MODE -#define SCO_PCM_IF_CLOCK_MODE 0 -#endif - -#define PCM_DATA_FORMAT_PARAM_SIZE 5 - -/* PCM_DATA_FMT_SHIFT_MODE - - 0 : MSB first - 1 : LSB first -*/ -#ifndef PCM_DATA_FMT_SHIFT_MODE -#define PCM_DATA_FMT_SHIFT_MODE 0 -#endif - -/* PCM_DATA_FMT_FILL_BITS - - Specifies the value with which to fill unused bits - if Fill_Method is set to programmable -*/ -#ifndef PCM_DATA_FMT_FILL_BITS -#define PCM_DATA_FMT_FILL_BITS 0 -#endif - -/* PCM_DATA_FMT_FILL_METHOD - - 0 : 0's - 1 : 1's - 2 : Signed - 3 : Programmable -*/ -#ifndef PCM_DATA_FMT_FILL_METHOD -#define PCM_DATA_FMT_FILL_METHOD 3 -#endif - -/* PCM_DATA_FMT_FILL_NUM - - Specifies the number of bits to be filled -*/ -#ifndef PCM_DATA_FMT_FILL_NUM -#define PCM_DATA_FMT_FILL_NUM 3 -#endif - -/* PCM_DATA_FMT_JUSTIFY_MODE - - 0 : Left justify (fill data shifted out last) - 1 : Right justify (fill data shifted out first) -*/ -#ifndef PCM_DATA_FMT_JUSTIFY_MODE -#define PCM_DATA_FMT_JUSTIFY_MODE 0 -#endif - -/* Debug mode with bit-wise mask */ -typedef uint8_t vnd_debug_t; -#define DEBUG_ON 0xFF -#define DEBUG_OFF 0x00 - -/* Define trace On/Off bit for every modules */ -enum { - TRACE_VND, - TRACE_HW, - TRACE_USERIAL, - TRACE_HCI, - TRACE_UPIO, - TRACE_BTSNOOP -}; - -/****************************************************************************** -** Type definitions and return values -******************************************************************************/ - -typedef struct -{ - uint16_t event; - uint16_t len; - uint16_t offset; - uint16_t layer_specific; -} VND_BT_HDR; - -#define BT_VND_HDR_SIZE (sizeof(VND_BT_HDR)) - - -typedef struct _vnd_buffer_hdr -{ - struct _vnd_buffer_hdr *p_next; /* next buffer in the queue */ - uint8_t reserved1; - uint8_t reserved2; - uint8_t reserved3; - uint8_t reserved4; -} VND_BUFFER_HDR_T; - -#define BT_VND_BUFFER_HDR_SIZE (sizeof(VND_BUFFER_HDR_T)) - -/****************************************************************************** -** Extern variables and functions -******************************************************************************/ - -extern bt_vendor_callbacks_t *bt_vendor_cbacks; -extern vnd_debug_t dbg_mode; -extern vnd_debug_t traces; - -/****************************************************************************** -** Functions -******************************************************************************/ - -/******************************************************************************* -** -** Function btvnd_signal_event -** -** Description Perform context switch to bt_vendor main thread -** -** Returns None -** -*******************************************************************************/ -extern void btvnd_signal_event(uint16_t event); - -#endif /* BT_VENDOR_BRCM_H */ - diff --git a/vendor/libvendor/include/upio.h b/vendor/libvendor/include/upio.h deleted file mode 100644 index bdca17f..0000000 --- a/vendor/libvendor/include/upio.h +++ /dev/null @@ -1,135 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2009-2012 Broadcom Corporation - * - * This program is the proprietary software of Broadcom Corporation and/or its - * licensors, and may only be used, duplicated, modified or distributed - * pursuant to the terms and conditions of a separate, written license - * agreement executed between you and Broadcom (an "Authorized License"). - * Except as set forth in an Authorized License, Broadcom grants no license - * (express or implied), right to use, or waiver of any kind with respect to - * the Software, and Broadcom expressly reserves all rights in and to the - * Software and all intellectual property rights therein. - * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS - * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE - * ALL USE OF THE SOFTWARE. - * - * Except as expressly set forth in the Authorized License, - * - * 1. This program, including its structure, sequence and organization, - * constitutes the valuable trade secrets of Broadcom, and you shall - * use all reasonable efforts to protect the confidentiality thereof, - * and to use this information only in connection with your use of - * Broadcom integrated circuit products. - * - * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED - * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, - * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, - * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY - * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, - * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, - * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR - * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT - * OF USE OR PERFORMANCE OF THE SOFTWARE. - * - * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR - * ITS LICENSORS BE LIABLE FOR - * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY - * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO - * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM - * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR - * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE - * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE - * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF - * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. - * - ******************************************************************************/ - -/****************************************************************************** - * - * Filename: upio.h - * - * Description: Contains definitions used for I/O controls - * - ******************************************************************************/ - -#ifndef UPIO_H -#define UPIO_H - -/****************************************************************************** -** Constants & Macros -******************************************************************************/ - -#define UPIO_BT_POWER_OFF 0 -#define UPIO_BT_POWER_ON 1 - -/* UPIO signals */ -enum { - UPIO_BT_WAKE = 0, - UPIO_HOST_WAKE, - UPIO_MAX_COUNT -}; - -/* UPIO assertion/deassertion */ -enum { - UPIO_UNKNOWN = 0, - UPIO_DEASSERT, - UPIO_ASSERT -}; - -/****************************************************************************** -** Extern variables and functions -******************************************************************************/ - -/****************************************************************************** -** Functions -******************************************************************************/ - -/******************************************************************************* -** -** Function upio_init -** -** Description Initialization -** -** Returns None -** -*******************************************************************************/ -void upio_init(void); - -/******************************************************************************* -** -** Function upio_cleanup -** -** Description Clean up -** -** Returns None -** -*******************************************************************************/ -void upio_cleanup(void); - -/******************************************************************************* -** -** Function upio_set_bluetooth_power -** -** Description Interact with low layer driver to set Bluetooth power -** on/off. -** -** Returns 0 : SUCCESS or Not-Applicable -** <0 : ERROR -** -*******************************************************************************/ -int upio_set_bluetooth_power(int on); - -/******************************************************************************* -** -** Function upio_set -** -** Description Set i/o based on polarity -** -** Returns None -** -*******************************************************************************/ -void upio_set(uint8_t pio, uint8_t action, uint8_t polarity); - -#endif /* UPIO_H */ - diff --git a/vendor/libvendor/include/vnd_crespo.txt b/vendor/libvendor/include/vnd_crespo.txt deleted file mode 100644 index 68f45b3..0000000 --- a/vendor/libvendor/include/vnd_crespo.txt +++ /dev/null @@ -1,12 +0,0 @@ -BLUETOOTH_UART_DEVICE_PORT = "/dev/s3c2410_serial0" -BT_WAKE_VIA_USERIAL_IOCTL = TRUE -LPM_IDLE_TIMEOUT_MULTIPLE = 5 -BTSNOOPDISP_INCLUDED = TRUE -BTSNOOP_FILENAME = "/data/misc/bluedroid/btsnoop_hci.log" -BTVND_DBG = TRUE -BTHW_DBG = TRUE -USERIAL_DBG = TRUE -HCIH4_DBG = TRUE -UPIO_DBG = TRUE -BTSNOOP_DBG = FALSE -SCO_PCM_IF_CLOCK_RATE = 0 diff --git a/vendor/libvendor/include/vnd_crespo4g.txt b/vendor/libvendor/include/vnd_crespo4g.txt deleted file mode 100755 index 68f45b3..0000000 --- a/vendor/libvendor/include/vnd_crespo4g.txt +++ /dev/null @@ -1,12 +0,0 @@ -BLUETOOTH_UART_DEVICE_PORT = "/dev/s3c2410_serial0" -BT_WAKE_VIA_USERIAL_IOCTL = TRUE -LPM_IDLE_TIMEOUT_MULTIPLE = 5 -BTSNOOPDISP_INCLUDED = TRUE -BTSNOOP_FILENAME = "/data/misc/bluedroid/btsnoop_hci.log" -BTVND_DBG = TRUE -BTHW_DBG = TRUE -USERIAL_DBG = TRUE -HCIH4_DBG = TRUE -UPIO_DBG = TRUE -BTSNOOP_DBG = FALSE -SCO_PCM_IF_CLOCK_RATE = 0 diff --git a/vendor/libvendor/include/vnd_maguro.txt b/vendor/libvendor/include/vnd_maguro.txt deleted file mode 100644 index 8705da6..0000000 --- a/vendor/libvendor/include/vnd_maguro.txt +++ /dev/null @@ -1,11 +0,0 @@ -BT_WAKE_VIA_USERIAL_IOCTL = TRUE -LPM_IDLE_TIMEOUT_MULTIPLE = 5 -BTSNOOPDISP_INCLUDED = TRUE -BTSNOOP_FILENAME = "/data/misc/bluedroid/btsnoop_hci.log" -SCO_USE_I2S_INTERFACE = TRUE -BTVND_DBG = TRUE -BTHW_DBG = TRUE -USERIAL_DBG = FALSE -HCIH4_DBG = FALSE -UPIO_DBG = FALSE -BTSNOOP_DBG = FALSE diff --git a/vendor/libvendor/include/vnd_toro.txt b/vendor/libvendor/include/vnd_toro.txt deleted file mode 100644 index 8705da6..0000000 --- a/vendor/libvendor/include/vnd_toro.txt +++ /dev/null @@ -1,11 +0,0 @@ -BT_WAKE_VIA_USERIAL_IOCTL = TRUE -LPM_IDLE_TIMEOUT_MULTIPLE = 5 -BTSNOOPDISP_INCLUDED = TRUE -BTSNOOP_FILENAME = "/data/misc/bluedroid/btsnoop_hci.log" -SCO_USE_I2S_INTERFACE = TRUE -BTVND_DBG = TRUE -BTHW_DBG = TRUE -USERIAL_DBG = FALSE -HCIH4_DBG = FALSE -UPIO_DBG = FALSE -BTSNOOP_DBG = FALSE diff --git a/vendor/libvendor/include/vnd_wingray.txt b/vendor/libvendor/include/vnd_wingray.txt deleted file mode 100644 index 57ac1c3..0000000 --- a/vendor/libvendor/include/vnd_wingray.txt +++ /dev/null @@ -1,12 +0,0 @@ -BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyHS2" -FW_PATCHFILE_LOCATION = "/etc/firmware/" -BT_WAKE_VIA_USERIAL_IOCTL = TRUE -LPM_IDLE_TIMEOUT_MULTIPLE = 5 -BTSNOOPDISP_INCLUDED = TRUE -BTSNOOP_FILENAME = "/data/misc/bluedroid/btsnoop_hci.log" -BTVND_DBG = TRUE -BTHW_DBG = TRUE -USERIAL_DBG = TRUE -HCIH4_DBG = TRUE -UPIO_DBG = TRUE -BTSNOOP_DBG = FALSE diff --git a/vendor/libvendor/src/hardware.c b/vendor/libvendor/src/hardware.c deleted file mode 100644 index 66d2ad1..0000000 --- a/vendor/libvendor/src/hardware.c +++ /dev/null @@ -1,1185 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2009-2012 Broadcom Corporation - * - * This program is the proprietary software of Broadcom Corporation and/or its - * licensors, and may only be used, duplicated, modified or distributed - * pursuant to the terms and conditions of a separate, written license - * agreement executed between you and Broadcom (an "Authorized License"). - * Except as set forth in an Authorized License, Broadcom grants no license - * (express or implied), right to use, or waiver of any kind with respect to - * the Software, and Broadcom expressly reserves all rights in and to the - * Software and all intellectual property rights therein. - * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS - * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE - * ALL USE OF THE SOFTWARE. - * - * Except as expressly set forth in the Authorized License, - * - * 1. This program, including its structure, sequence and organization, - * constitutes the valuable trade secrets of Broadcom, and you shall - * use all reasonable efforts to protect the confidentiality thereof, - * and to use this information only in connection with your use of - * Broadcom integrated circuit products. - * - * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED - * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, - * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, - * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY - * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, - * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, - * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR - * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT - * OF USE OR PERFORMANCE OF THE SOFTWARE. - * - * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR - * ITS LICENSORS BE LIABLE FOR - * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY - * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO - * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM - * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR - * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE - * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE - * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF - * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. - * - ******************************************************************************/ - -/****************************************************************************** - * - * Filename: hardware.c - * - * Description: Contains controller-specific functions, like - * firmware patch download - * low power mode operations - * - ******************************************************************************/ - -#define LOG_TAG "bt_hw" - -#include <utils/Log.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <signal.h> -#include <time.h> -#include <fcntl.h> -#include <dirent.h> -#include <ctype.h> -#include <cutils/properties.h> -#include <stdlib.h> -#include "bt_vendor_brcm.h" -#include "userial.h" -#include "utils.h" -#include "upio.h" - -/****************************************************************************** -** Constants & Macros -******************************************************************************/ - -#ifndef BTHW_DBG -#define BTHW_DBG FALSE -#endif - -#if (BTHW_DBG == TRUE) -#define BTHWDBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_HW)) \ - LOGD(param, ## __VA_ARGS__);\ - } -#else -#define BTHWDBG(param, ...) {} -#endif - -#define FW_PATCHFILE_EXTENSION ".hcd" -#define FW_PATCHFILE_EXTENSION_LEN 4 -#define FW_PATCHFILE_PATH_MAXLEN 248 /* Local_Name length of return of - HCI_Read_Local_Name */ - -#define HCI_CMD_MAX_LEN 258 - -#define HCI_RESET 0x0C03 -#define HCI_VSC_WRITE_UART_CLOCK_SETTING 0xFC45 -#define HCI_VSC_UPDATE_BAUDRATE 0xFC18 -#define HCI_READ_LOCAL_NAME 0x0C14 -#define HCI_VSC_DOWNLOAD_MINIDRV 0xFC2E -#define HCI_VSC_WRITE_BD_ADDR 0xFC01 -#define HCI_VSC_WRITE_SLEEP_MODE 0xFC27 -#define HCI_VSC_WRITE_SCO_PCM_INT_PARAM 0xFC1C -#define HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM 0xFC1E -#define HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM 0xFC6D -#define HCI_VSC_LAUNCH_RAM 0xFC4E - -#define HCI_EVT_CMD_CMPL_STATUS_RET_BYTE 5 -#define HCI_EVT_CMD_CMPL_LOCAL_NAME_STRING 6 -#define HCI_EVT_CMD_CMPL_OPCODE 3 -#define LPM_CMD_PARAM_SIZE 12 -#define UPDATE_BAUDRATE_CMD_PARAM_SIZE 6 -#define HCI_CMD_PREAMBLE_SIZE 3 -#define HCD_REC_PAYLOAD_LEN_BYTE 2 -#define BD_ADDR_LEN 6 -#define LOCAL_NAME_BUFFER_LEN 32 -#define LOCAL_BDADDR_PATH_BUFFER_LEN 256 - -/****************************************************************************** -** Local type definitions -******************************************************************************/ - -/* Hardware Configuration State */ -enum { - HW_CFG_START = 1, - HW_CFG_SET_UART_CLOCK, - HW_CFG_SET_UART_BAUD_1, - HW_CFG_READ_LOCAL_NAME, - HW_CFG_DL_MINIDRIVER, - HW_CFG_DL_FW_PATCH, - HW_CFG_SET_UART_BAUD_2, - HW_CFG_SET_BD_ADDR -}; - -/* h/w config control block */ -typedef struct -{ - uint8_t state; /* Hardware configuration state */ - int fw_fd; /* FW patch file fd */ - uint8_t f_set_baud_2; /* Baud rate switch state */ - char local_chip_name[LOCAL_NAME_BUFFER_LEN]; -} bt_hw_cfg_cb_t; - -/* low power mode parameters */ -typedef struct -{ - uint8_t sleep_mode; /* 0(disable),1(UART),9(H5) */ - uint8_t host_stack_idle_threshold; /* Unit scale 300ms/25ms */ - uint8_t host_controller_idle_threshold; /* Unit scale 300ms/25ms */ - uint8_t bt_wake_polarity; /* 0=Active Low, 1= Active High */ - uint8_t host_wake_polarity; /* 0=Active Low, 1= Active High */ - uint8_t allow_host_sleep_during_sco; - uint8_t combine_sleep_mode_and_lpm; - uint8_t enable_uart_txd_tri_state; /* UART_TXD Tri-State */ - uint8_t sleep_guard_time; /* sleep guard time in 12.5ms */ - uint8_t wakeup_guard_time; /* wakeup guard time in 12.5ms */ - uint8_t txd_config; /* TXD is high in sleep state */ - uint8_t pulsed_host_wake; /* pulsed host wake if mode = 1 */ -} bt_lpm_param_t; - -/* Low power mode state */ -enum { - HW_LPM_DISABLED = 0, /* initial state */ - HW_LPM_ENABLED, - HW_LPM_ENABLING, - HW_LPM_DISABLING -}; - -/* BT_WAKE state */ -enum { - LPM_BTWAKE_DEASSERTED = 0, /* initial state */ - LPM_BTWAKE_W4_TX_DONE, - LPM_BTWAKE_W4_TIMEOUT, - LPM_BTWAKE_ASSERTED -}; - -/* low power mode control block */ -typedef struct -{ - uint8_t state; /* Low power mode state */ - uint8_t btwake_state; /* BT_WAKE state */ - uint8_t no_tx_data; - uint8_t timer_created; - timer_t timer_id; - uint32_t timeout_ms; /* 10 times of the chip unit */ -} bt_lpm_cb_t; - -/****************************************************************************** -** Externs -******************************************************************************/ - -/* Callback function for the returned event of internal issued command */ -typedef void (*tINT_CMD_CBACK)(VND_BT_HDR *p_buf); -void hci_h4_get_acl_data_length(void); -void hw_config_cback(VND_BT_HDR *p_evt_buf); -uint8_t hci_h4_send_int_cmd(uint16_t opcode, VND_BT_HDR *p_buf, \ - tINT_CMD_CBACK p_cback); - -extern uint8_t vendor_local_bd_addr[BD_ADDR_LEN]; -/****************************************************************************** -** Static variables -******************************************************************************/ - -static char fw_patchfile_path[256] = FW_PATCHFILE_LOCATION; - -static bt_hw_cfg_cb_t hw_cfg_cb; -static bt_lpm_cb_t hw_lpm_cb; - -static bt_lpm_param_t lpm_param = -{ - LPM_SLEEP_MODE, - LPM_IDLE_THRESHOLD, - LPM_HC_IDLE_THRESHOLD, - LPM_BT_WAKE_POLARITY, - LPM_HOST_WAKE_POLARITY, - LPM_ALLOW_HOST_SLEEP_DURING_SCO, - LPM_COMBINE_SLEEP_MODE_AND_LPM, - LPM_ENABLE_UART_TXD_TRI_STATE, - 0, /* not applicable */ - 0, /* not applicable */ - 0, /* not applicable */ - LPM_PULSED_HOST_WAKE -}; - -#if (!defined(SCO_USE_I2S_INTERFACE) || (SCO_USE_I2S_INTERFACE == FALSE)) -static uint8_t bt_sco_param[SCO_PCM_PARAM_SIZE] = -{ - SCO_PCM_ROUTING, - SCO_PCM_IF_CLOCK_RATE, - SCO_PCM_IF_FRAME_TYPE, - SCO_PCM_IF_SYNC_MODE, - SCO_PCM_IF_CLOCK_MODE -}; - -static uint8_t bt_pcm_data_fmt_param[PCM_DATA_FORMAT_PARAM_SIZE] = -{ - PCM_DATA_FMT_SHIFT_MODE, - PCM_DATA_FMT_FILL_BITS, - PCM_DATA_FMT_FILL_METHOD, - PCM_DATA_FMT_FILL_NUM, - PCM_DATA_FMT_JUSTIFY_MODE -}; -#else -static uint8_t bt_sco_param[SCO_I2SPCM_PARAM_SIZE] = -{ - SCO_I2SPCM_IF_MODE, - SCO_I2SPCM_IF_ROLE, - SCO_I2SPCM_IF_SAMPLE_RATE, - SCO_I2SPCM_IF_CLOCK_RATE -}; -#endif - -/****************************************************************************** -** Static functions -******************************************************************************/ - -/****************************************************************************** -** Controller Initialization Static Functions -******************************************************************************/ - -/******************************************************************************* -** -** Function hw_strncmp -** -** Description Used to compare two strings in caseless -** -** Returns 0: match, otherwise: not match -** -*******************************************************************************/ -static int hw_strncmp (const char *p_str1, const char *p_str2, const int len) -{ - int i; - - if (!p_str1 || !p_str2) - return (1); - - for (i = 0; i < len; i++) - { - if (toupper(p_str1[i]) != toupper(p_str2[i])) - return (i+1); - } - - return 0; -} - -/******************************************************************************* -** -** Function hw_config_findpatch -** -** Description Search for a proper firmware patch file -** The selected firmware patch file name with full path -** will be stored in the input string parameter, i.e. -** p_chip_id_str, when returns. -** -** Returns TRUE when found the target patch file, otherwise FALSE -** -*******************************************************************************/ -static uint8_t hw_config_findpatch(char *p_chip_id_str) -{ - DIR *dirp; - struct dirent *dp; - int filenamelen; - uint8_t retval = FALSE; - - BTHWDBG("Target name = [%s]", p_chip_id_str); - - if ((dirp = opendir(fw_patchfile_path)) != NULL) - { - /* Fetch next filename in patchfile directory */ - while ((dp = readdir(dirp)) != NULL) - { - /* Check if filename starts with chip-id name */ - if ((hw_strncmp(dp->d_name, p_chip_id_str, strlen(p_chip_id_str)) \ - ) == 0) - { - /* Check if it has .hcd extenstion */ - filenamelen = strlen(dp->d_name); - if ((filenamelen >= FW_PATCHFILE_EXTENSION_LEN) && - ((hw_strncmp( - &dp->d_name[filenamelen-FW_PATCHFILE_EXTENSION_LEN], \ - FW_PATCHFILE_EXTENSION, \ - FW_PATCHFILE_EXTENSION_LEN) \ - ) == 0)) - { - LOGI("Found patchfile: %s/%s", \ - fw_patchfile_path, dp->d_name); - - /* Make sure length does not exceed maximum */ - if ((filenamelen + strlen(fw_patchfile_path)) > \ - FW_PATCHFILE_PATH_MAXLEN) - { - LOGE("Invalid patchfile name (too long)"); - } - else - { - memset(p_chip_id_str, 0, FW_PATCHFILE_PATH_MAXLEN); - /* Found patchfile. Store location and name */ - strcpy(p_chip_id_str, fw_patchfile_path); - if (fw_patchfile_path[ \ - strlen(fw_patchfile_path)- 1 \ - ] != '/') - { - strcat(p_chip_id_str, "/"); - } - strcat(p_chip_id_str, dp->d_name); - retval = TRUE; - } - break; - } - } - } - - closedir(dirp); - - if (retval == FALSE) - { - /* Try again chip name without revision info */ - - int len = strlen(p_chip_id_str); - char *p = p_chip_id_str + len - 1; - - /* Scan backward and look for the first alphabet - which is not M or m - */ - while (len > 3) // BCM**** - { - if ((isdigit(*p)==0) && (*p != 'M') && (*p != 'm')) - break; - - p--; - len--; - } - - if (len > 3) - { - *p = 0; - retval = hw_config_findpatch(p_chip_id_str); - } - } - } - else - { - LOGE("Could not open %s", fw_patchfile_path); - } - - return (retval); -} - -/******************************************************************************* -** -** Function hw_config_set_bdaddr -** -** Description Program controller's Bluetooth Device Address -** -** Returns TRUE, if valid address is sent -** FALSE, otherwise -** -*******************************************************************************/ -static uint8_t hw_config_set_bdaddr(VND_BT_HDR *p_buf) -{ - uint8_t retval = FALSE; - uint8_t *p = (uint8_t *) (p_buf + 1); - - LOGI("Setting local bd addr to %02X:%02X:%02X:%02X:%02X:%02X", - vendor_local_bd_addr[0], vendor_local_bd_addr[1], vendor_local_bd_addr[2], - vendor_local_bd_addr[3], vendor_local_bd_addr[4], vendor_local_bd_addr[5]); - - UINT16_TO_STREAM(p, HCI_VSC_WRITE_BD_ADDR); - *p++ = BD_ADDR_LEN; /* parameter length */ - *p++ = vendor_local_bd_addr[5]; - *p++ = vendor_local_bd_addr[4]; - *p++ = vendor_local_bd_addr[3]; - *p++ = vendor_local_bd_addr[2]; - *p++ = vendor_local_bd_addr[1]; - *p = vendor_local_bd_addr[0]; - - p_buf->len = HCI_CMD_PREAMBLE_SIZE + BD_ADDR_LEN; - hw_cfg_cb.state = HW_CFG_SET_BD_ADDR; - - retval = hci_h4_send_int_cmd(HCI_VSC_WRITE_BD_ADDR, p_buf, \ - hw_config_cback); - - return (retval); -} - -/******************************************************************************* -** -** Function hw_config_cback -** -** Description Callback function for controller configuration -** -** Returns None -** -*******************************************************************************/ -void hw_config_cback(VND_BT_HDR *p_evt_buf) -{ - char *p_name; - uint8_t *p, status; - uint16_t opcode; - VND_BT_HDR *p_buf=NULL; - uint8_t is_proceeding = FALSE; - - status = *((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE); - p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE; - STREAM_TO_UINT16(opcode,p); - - /* Ask a new buffer big enough to hold any HCI commands sent in here */ - if ((status == 0) && bt_vendor_cbacks) - p_buf = (VND_BT_HDR *) bt_vendor_cbacks->alloc(BT_VND_HDR_SIZE + \ - HCI_CMD_MAX_LEN); - - if (p_buf != NULL) - { - p_buf->event = MSG_STACK_TO_VND_HCI_CMD; - p_buf->offset = 0; - p_buf->len = 0; - p_buf->layer_specific = 0; - - p = (uint8_t *) (p_buf + 1); - - switch (hw_cfg_cb.state) - { - case HW_CFG_SET_UART_BAUD_1: - /* update baud rate of host's UART port */ - userial_change_baud(USERIAL_BAUD_3M); - - /* read local name */ - UINT16_TO_STREAM(p, HCI_READ_LOCAL_NAME); - *p = 0; /* parameter length */ - - p_buf->len = HCI_CMD_PREAMBLE_SIZE; - hw_cfg_cb.state = HW_CFG_READ_LOCAL_NAME; - - is_proceeding = hci_h4_send_int_cmd(HCI_READ_LOCAL_NAME, p_buf,\ - hw_config_cback); - break; - - case HW_CFG_READ_LOCAL_NAME: - p_name = (char *) (p_evt_buf + 1) + \ - HCI_EVT_CMD_CMPL_LOCAL_NAME_STRING; - strncpy(hw_cfg_cb.local_chip_name, p_name, \ - LOCAL_NAME_BUFFER_LEN-1); - hw_cfg_cb.local_chip_name[LOCAL_NAME_BUFFER_LEN-1] = 0; - if ((status = hw_config_findpatch(p_name)) == TRUE) - { - if ((hw_cfg_cb.fw_fd = open(p_name, O_RDONLY)) == -1) - { - LOGE("vendor lib preload failed to open [%s]", p_name); - } - else - { - /* vsc_download_minidriver */ - UINT16_TO_STREAM(p, HCI_VSC_DOWNLOAD_MINIDRV); - *p = 0; /* parameter length */ - - p_buf->len = HCI_CMD_PREAMBLE_SIZE; - hw_cfg_cb.state = HW_CFG_DL_MINIDRIVER; - - is_proceeding = hci_h4_send_int_cmd( \ - HCI_VSC_DOWNLOAD_MINIDRV, p_buf, \ - hw_config_cback); - } - } - else - { - LOGE( \ - "vendor lib preload failed to locate firmware patch file" \ - ); - } - - if (is_proceeding == FALSE) - { - is_proceeding = hw_config_set_bdaddr(p_buf); - } - break; - - case HW_CFG_DL_MINIDRIVER: - /* give time for placing firmware in download mode */ - utils_delay(50); - hw_cfg_cb.state = HW_CFG_DL_FW_PATCH; - /* fall through intentionally */ - case HW_CFG_DL_FW_PATCH: - p_buf->len = read(hw_cfg_cb.fw_fd, p, HCI_CMD_PREAMBLE_SIZE); - if (p_buf->len > 0) - { - if ((p_buf->len < HCI_CMD_PREAMBLE_SIZE) || \ - (opcode == HCI_VSC_LAUNCH_RAM)) - { - LOGW("firmware patch file might be altered!"); - } - else - { - p_buf->len += read(hw_cfg_cb.fw_fd, \ - p+HCI_CMD_PREAMBLE_SIZE,\ - *(p+HCD_REC_PAYLOAD_LEN_BYTE)); - STREAM_TO_UINT16(opcode,p); - is_proceeding = hci_h4_send_int_cmd(opcode, p_buf, \ - hw_config_cback); - break; - } - } - - close(hw_cfg_cb.fw_fd); - hw_cfg_cb.fw_fd = -1; - - /* Normally the firmware patch configuration file - * sets the new starting baud rate at 115200. - * So, we need update host's baud rate accordingly. - */ - userial_change_baud(USERIAL_BAUD_115200); - - /* Next, we would like to boost baud rate up again - * to desired working speed. - */ - hw_cfg_cb.f_set_baud_2 = TRUE; - - /* fall through intentionally */ - case HW_CFG_START: - if (UART_TARGET_BAUD_RATE > 3000000) - { - /* set UART clock to 48MHz */ - UINT16_TO_STREAM(p, HCI_VSC_WRITE_UART_CLOCK_SETTING); - *p++ = 1; /* parameter length */ - *p = 1; /* (1,"UART CLOCK 48 MHz")(2,"UART CLOCK 24 MHz") */ - - p_buf->len = HCI_CMD_PREAMBLE_SIZE + 1; - hw_cfg_cb.state = HW_CFG_SET_UART_CLOCK; - - is_proceeding = hci_h4_send_int_cmd( \ - HCI_VSC_WRITE_UART_CLOCK_SETTING, \ - p_buf, hw_config_cback); - break; - } - /* fall through intentionally */ - case HW_CFG_SET_UART_CLOCK: - /* set controller's UART baud rate to 3M */ - UINT16_TO_STREAM(p, HCI_VSC_UPDATE_BAUDRATE); - *p++ = UPDATE_BAUDRATE_CMD_PARAM_SIZE; /* parameter length */ - *p++ = 0; /* encoded baud rate */ - *p++ = 0; /* use encoded form */ - UINT32_TO_STREAM(p, UART_TARGET_BAUD_RATE); - - p_buf->len = HCI_CMD_PREAMBLE_SIZE + \ - UPDATE_BAUDRATE_CMD_PARAM_SIZE; - hw_cfg_cb.state = (hw_cfg_cb.f_set_baud_2) ? \ - HW_CFG_SET_UART_BAUD_2 : HW_CFG_SET_UART_BAUD_1; - - is_proceeding = hci_h4_send_int_cmd(HCI_VSC_UPDATE_BAUDRATE, \ - p_buf, hw_config_cback); - break; - - case HW_CFG_SET_UART_BAUD_2: - /* update baud rate of host's UART port */ - userial_change_baud(USERIAL_BAUD_3M); - - if ((is_proceeding = hw_config_set_bdaddr(p_buf)) == TRUE) - break; - - /* fall through intentionally */ - case HW_CFG_SET_BD_ADDR: - LOGI("vendor lib preload completed"); - if (bt_vendor_cbacks) - { - bt_vendor_cbacks->dealloc((TRANSAC) p_buf, \ - (char *) (p_buf + 1)); - - bt_vendor_cbacks->preload_cb(NULL, \ - BT_VENDOR_PRELOAD_SUCCESS); - } - - hw_cfg_cb.state = 0; - - if (hw_cfg_cb.fw_fd != -1) - { - close(hw_cfg_cb.fw_fd); - hw_cfg_cb.fw_fd = -1; - } - - is_proceeding = TRUE; - break; - } // switch(hw_cfg_cb.state) - } // if (p_buf != NULL) - - /* Free the RX event buffer */ - if (bt_vendor_cbacks) - bt_vendor_cbacks->dealloc((TRANSAC) p_evt_buf, (char *) (p_evt_buf+1)); - - if (is_proceeding == FALSE) - { - LOGE("vendor lib preload aborted!!!"); - if (bt_vendor_cbacks) - { - if (p_buf != NULL) - bt_vendor_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf+1)); - - bt_vendor_cbacks->preload_cb(NULL, BT_VENDOR_PRELOAD_FAIL); - } - - if (hw_cfg_cb.fw_fd != -1) - { - close(hw_cfg_cb.fw_fd); - hw_cfg_cb.fw_fd = -1; - } - - hw_cfg_cb.state = 0; - } -} - -/****************************************************************************** -** LPM Static Functions -******************************************************************************/ - -/******************************************************************************* -** -** Function hw_lpm_idle_timeout -** -** Description Timeout thread of transport idle timer -** -** Returns None -** -*******************************************************************************/ -static void hw_lpm_idle_timeout(union sigval arg) -{ - BTHWDBG("..hw_lpm_idle_timeout.."); - - if ((hw_lpm_cb.state == HW_LPM_ENABLED) && \ - (hw_lpm_cb.btwake_state == LPM_BTWAKE_W4_TIMEOUT)) - { - btvnd_signal_event(VND_EVENT_LPM_IDLE_TIMEOUT); - } -} - -/******************************************************************************* -** -** Function hw_lpm_start_transport_idle_timer -** -** Description Launch transport idle timer -** -** Returns None -** -*******************************************************************************/ -static void hw_lpm_start_transport_idle_timer(void) -{ - int status; - struct itimerspec ts; - struct sigevent se; - - if (hw_lpm_cb.state != HW_LPM_ENABLED) - return; - - if (hw_lpm_cb.timer_created == FALSE) - { - se.sigev_notify = SIGEV_THREAD; - se.sigev_value.sival_ptr = &hw_lpm_cb.timer_id; - se.sigev_notify_function = hw_lpm_idle_timeout; - se.sigev_notify_attributes = NULL; - - /* set idle time to be LPM_IDLE_TIMEOUT_MULTIPLE times of - * host stack idle threshold (in 300ms/25ms) - */ - hw_lpm_cb.timeout_ms = (uint32_t)lpm_param.host_stack_idle_threshold \ - * LPM_IDLE_TIMEOUT_MULTIPLE; - - if (strstr(hw_cfg_cb.local_chip_name, "BCM4325") != NULL) - hw_lpm_cb.timeout_ms *= 25; // 12.5 or 25 ? - else - hw_lpm_cb.timeout_ms *= 300; - - status = timer_create(CLOCK_MONOTONIC, &se, &hw_lpm_cb.timer_id); - - if (status == 0) - hw_lpm_cb.timer_created = TRUE; - } - - if (hw_lpm_cb.timer_created == TRUE) - { - ts.it_value.tv_sec = hw_lpm_cb.timeout_ms/1000; - ts.it_value.tv_nsec = 1000*(hw_lpm_cb.timeout_ms%1000); - ts.it_interval.tv_sec = 0; - ts.it_interval.tv_nsec = 0; - - status = timer_settime(hw_lpm_cb.timer_id, 0, &ts, 0); - if (status == -1) - LOGE("[START] Failed to set LPM idle timeout"); - } -} - -/******************************************************************************* -** -** Function hw_lpm_stop_transport_idle_timer -** -** Description Launch transport idle timer -** -** Returns None -** -*******************************************************************************/ -static void hw_lpm_stop_transport_idle_timer(void) -{ - int status; - struct itimerspec ts; - - if (hw_lpm_cb.timer_created == TRUE) - { - ts.it_value.tv_sec = 0; - ts.it_value.tv_nsec = 0; - ts.it_interval.tv_sec = 0; - ts.it_interval.tv_nsec = 0; - - status = timer_settime(hw_lpm_cb.timer_id, 0, &ts, 0); - if (status == -1) - LOGE("[STOP] Failed to set LPM idle timeout"); - } -} - -/******************************************************************************* -** -** Function hw_lpm_ctrl_cback -** -** Description Callback function for lpm enable/disable rquest -** -** Returns None -** -*******************************************************************************/ -void hw_lpm_ctrl_cback(VND_BT_HDR *p_evt_buf) -{ - uint8_t next_state; - - if (*((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE) == 0) - { - /* Status == Success */ - hw_lpm_cb.state = (hw_lpm_cb.state == HW_LPM_ENABLING) ? \ - HW_LPM_ENABLED : HW_LPM_DISABLED; - } - else - { - hw_lpm_cb.state = (hw_lpm_cb.state == HW_LPM_ENABLING) ? \ - HW_LPM_DISABLED : HW_LPM_ENABLED; - } - - if (bt_vendor_cbacks) - { - if (hw_lpm_cb.state == HW_LPM_ENABLED) - bt_vendor_cbacks->lpm_cb(BT_VENDOR_LPM_ENABLED); - else - bt_vendor_cbacks->lpm_cb(BT_VENDOR_LPM_DISABLED); - } - - if (hw_lpm_cb.state == HW_LPM_DISABLED) - { - if (hw_lpm_cb.timer_created == TRUE) - { - timer_delete(hw_lpm_cb.timer_id); - } - - memset(&hw_lpm_cb, 0, sizeof(bt_lpm_cb_t)); - } - - if (bt_vendor_cbacks) - { - bt_vendor_cbacks->dealloc((TRANSAC) p_evt_buf, (char *) (p_evt_buf+1)); - } -} - - -#if (SCO_CFG_INCLUDED == TRUE) -/***************************************************************************** -** SCO Configuration Static Functions -*****************************************************************************/ - -/******************************************************************************* -** -** Function hw_sco_cfg_cback -** -** Description Callback function for SCO configuration rquest -** -** Returns None -** -*******************************************************************************/ -void hw_sco_cfg_cback(VND_BT_HDR *p_evt_buf) -{ - uint8_t *p; - uint16_t opcode; - VND_BT_HDR *p_buf=NULL; - - p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE; - STREAM_TO_UINT16(opcode,p); - - /* Free the RX event buffer */ - if (bt_vendor_cbacks) - bt_vendor_cbacks->dealloc((TRANSAC) p_evt_buf, (char *) (p_evt_buf+1)); - -#if (!defined(SCO_USE_I2S_INTERFACE) || (SCO_USE_I2S_INTERFACE == FALSE)) - if (opcode == HCI_VSC_WRITE_SCO_PCM_INT_PARAM) - { - uint8_t ret = FALSE; - - /* Ask a new buffer to hold WRITE_PCM_DATA_FORMAT_PARAM command */ - if (bt_vendor_cbacks) - p_buf = (VND_BT_HDR *) bt_vendor_cbacks->alloc(BT_VND_HDR_SIZE + \ - HCI_CMD_PREAMBLE_SIZE + \ - PCM_DATA_FORMAT_PARAM_SIZE); - if (p_buf) - { - p_buf->event = MSG_STACK_TO_VND_HCI_CMD; - p_buf->offset = 0; - p_buf->layer_specific = 0; - p_buf->len = HCI_CMD_PREAMBLE_SIZE + PCM_DATA_FORMAT_PARAM_SIZE; - - p = (uint8_t *) (p_buf + 1); - UINT16_TO_STREAM(p, HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM); - *p++ = PCM_DATA_FORMAT_PARAM_SIZE; - memcpy(p, &bt_pcm_data_fmt_param, PCM_DATA_FORMAT_PARAM_SIZE); - - if ((ret = hci_h4_send_int_cmd(HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM,\ - p_buf, hw_sco_cfg_cback)) == FALSE) - { - bt_vendor_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); - } - else - return; - } - } -#endif // !SCO_USE_I2S_INTERFACE - - hci_h4_get_acl_data_length(); -} -#endif // SCO_CFG_INCLUDED - -/***************************************************************************** -** Hardware Configuration Interface Functions -*****************************************************************************/ - - -/******************************************************************************* -** -** Function hw_config_start -** -** Description Kick off controller initialization process -** -** Returns None -** -*******************************************************************************/ -void hw_config_start(void) -{ - VND_BT_HDR *p_buf = NULL; - uint8_t *p; - - hw_cfg_cb.state = 0; - hw_cfg_cb.fw_fd = -1; - hw_cfg_cb.f_set_baud_2 = FALSE; - hw_lpm_cb.state = HW_LPM_DISABLED; - - /* Start from sending HCI_RESET */ - - if (bt_vendor_cbacks) - { - p_buf = (VND_BT_HDR *) bt_vendor_cbacks->alloc(BT_VND_HDR_SIZE + \ - HCI_CMD_PREAMBLE_SIZE); - } - - if (p_buf) - { - p_buf->event = MSG_STACK_TO_VND_HCI_CMD; - p_buf->offset = 0; - p_buf->layer_specific = 0; - p_buf->len = HCI_CMD_PREAMBLE_SIZE; - - p = (uint8_t *) (p_buf + 1); - UINT16_TO_STREAM(p, HCI_RESET); - *p = 0; /* parameter length */ - - hw_cfg_cb.state = HW_CFG_START; - - hci_h4_send_int_cmd(HCI_RESET, p_buf, hw_config_cback); - } - else - { - if (bt_vendor_cbacks) - { - LOGE("vendor lib preload aborted [no buffer]"); - bt_vendor_cbacks->preload_cb(NULL, BT_VENDOR_PRELOAD_FAIL); - } - } -} - -/******************************************************************************* -** -** Function hw_lpm_enable -** -** Description Enalbe/Disable LPM -** -** Returns TRUE/FALSE -** -*******************************************************************************/ -uint8_t hw_lpm_enable(uint8_t turn_on) -{ - VND_BT_HDR *p_buf = NULL; - uint8_t *p; - uint8_t ret = FALSE; - - if ((hw_lpm_cb.state!=HW_LPM_DISABLED) && (hw_lpm_cb.state!=HW_LPM_ENABLED)) - { - LOGW("Still busy on processing prior LPM enable/disable request..."); - return FALSE; - } - - if ((turn_on == TRUE) && (hw_lpm_cb.state == HW_LPM_ENABLED)) - { - LOGI("LPM is already on!!!"); - if (bt_vendor_cbacks) - bt_vendor_cbacks->lpm_cb(BT_VENDOR_LPM_ENABLED); - return TRUE; - } - else if ((turn_on == FALSE) && (hw_lpm_cb.state == HW_LPM_DISABLED)) - { - LOGI("LPM is already off!!!"); - if (bt_vendor_cbacks) - bt_vendor_cbacks->lpm_cb(BT_VENDOR_LPM_DISABLED); - return TRUE; - } - - if (bt_vendor_cbacks) - p_buf = (VND_BT_HDR *) bt_vendor_cbacks->alloc(BT_VND_HDR_SIZE + \ - HCI_CMD_PREAMBLE_SIZE + \ - LPM_CMD_PARAM_SIZE); - - if (p_buf) - { - p_buf->event = MSG_STACK_TO_VND_HCI_CMD; - p_buf->offset = 0; - p_buf->layer_specific = 0; - p_buf->len = HCI_CMD_PREAMBLE_SIZE + LPM_CMD_PARAM_SIZE; - - p = (uint8_t *) (p_buf + 1); - UINT16_TO_STREAM(p, HCI_VSC_WRITE_SLEEP_MODE); - *p++ = LPM_CMD_PARAM_SIZE; /* parameter length */ - - if (turn_on) - { - memcpy(p, &lpm_param, LPM_CMD_PARAM_SIZE); - hw_lpm_cb.state = HW_LPM_ENABLING; - } - else - { - memset(p, 0, LPM_CMD_PARAM_SIZE); - hw_lpm_cb.state = HW_LPM_DISABLING; - } - - if ((ret = hci_h4_send_int_cmd(HCI_VSC_WRITE_SLEEP_MODE, p_buf, \ - hw_lpm_ctrl_cback)) == FALSE) - { - hw_lpm_cb.state = (hw_lpm_cb.state == HW_LPM_ENABLING) ? \ - HW_LPM_DISABLED : HW_LPM_ENABLED; - - if (bt_vendor_cbacks) - bt_vendor_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf+1)); - } - } - - return ret; -} - -/******************************************************************************* -** -** Function hw_lpm_tx_done -** -** Description This function is to inform the lpm module -** if data is waiting in the Tx Q or not. -** -** IsTxDone: TRUE if All data in the Tx Q are gone -** FALSE if any data is still in the Tx Q. -** Typicaly this function must be called -** before USERIAL Write and in the Tx Done routine -** -** Returns None -** -*******************************************************************************/ -void hw_lpm_tx_done(uint8_t is_tx_done) -{ - hw_lpm_cb.no_tx_data = is_tx_done; - - if ((hw_lpm_cb.btwake_state==LPM_BTWAKE_W4_TX_DONE) && (is_tx_done==TRUE)) - { - hw_lpm_cb.btwake_state = LPM_BTWAKE_W4_TIMEOUT; - hw_lpm_start_transport_idle_timer(); - } -} - -/******************************************************************************* -** -** Function hw_lpm_assert_bt_wake -** -** Description Called to wake up Bluetooth chip. -** Normally this is called when there is data to be sent -** over UART. -** -** Returns TRUE/FALSE -** -*******************************************************************************/ -void hw_lpm_assert_bt_wake(void) -{ - if (hw_lpm_cb.state != HW_LPM_DISABLED) - { - BTHWDBG("LPM assert BT_WAKE"); - upio_set(UPIO_BT_WAKE, UPIO_ASSERT, lpm_param.bt_wake_polarity); - - hw_lpm_stop_transport_idle_timer(); - - hw_lpm_cb.btwake_state = LPM_BTWAKE_ASSERTED; - } - - hw_lpm_tx_done(FALSE); -} - -/******************************************************************************* -** -** Function hw_lpm_allow_bt_device_sleep -** -** Description Start LPM idle timer if allowed -** -** Returns None -** -*******************************************************************************/ -void hw_lpm_allow_bt_device_sleep(void) -{ - if ((hw_lpm_cb.state == HW_LPM_ENABLED) && \ - (hw_lpm_cb.btwake_state == LPM_BTWAKE_ASSERTED)) - { - if(hw_lpm_cb.no_tx_data == TRUE) - { - hw_lpm_cb.btwake_state = LPM_BTWAKE_W4_TIMEOUT; - hw_lpm_start_transport_idle_timer(); - } - else - { - hw_lpm_cb.btwake_state = LPM_BTWAKE_W4_TX_DONE; - } - } -} - -/******************************************************************************* -** -** Function hw_lpm_deassert_bt_wake -** -** Description Deassert bt_wake if allowed -** -** Returns None -** -*******************************************************************************/ -void hw_lpm_deassert_bt_wake(void) -{ - if ((hw_lpm_cb.state == HW_LPM_ENABLED) && (hw_lpm_cb.no_tx_data == TRUE)) - { - BTHWDBG("LPM deassert BT_WAKE"); - upio_set(UPIO_BT_WAKE, UPIO_DEASSERT, lpm_param.bt_wake_polarity); - hw_lpm_cb.btwake_state = LPM_BTWAKE_DEASSERTED; - } -} - -#if (SCO_CFG_INCLUDED == TRUE) -/******************************************************************************* -** -** Function hw_sco_config -** -** Description Configure SCO related hardware settings -** -** Returns None -** -*******************************************************************************/ -void hw_sco_config(void) -{ - VND_BT_HDR *p_buf = NULL; - uint8_t *p, ret; - -#if (!defined(SCO_USE_I2S_INTERFACE) || (SCO_USE_I2S_INTERFACE == FALSE)) - uint16_t cmd_u16 = HCI_CMD_PREAMBLE_SIZE + SCO_PCM_PARAM_SIZE; -#else - uint16_t cmd_u16 = HCI_CMD_PREAMBLE_SIZE + SCO_I2SPCM_PARAM_SIZE; -#endif - - if (bt_vendor_cbacks) - p_buf = (VND_BT_HDR *) bt_vendor_cbacks->alloc(BT_VND_HDR_SIZE+cmd_u16); - - if (p_buf) - { - p_buf->event = MSG_STACK_TO_VND_HCI_CMD; - p_buf->offset = 0; - p_buf->layer_specific = 0; - p_buf->len = cmd_u16; - - p = (uint8_t *) (p_buf + 1); -#if (!defined(SCO_USE_I2S_INTERFACE) || (SCO_USE_I2S_INTERFACE == FALSE)) - UINT16_TO_STREAM(p, HCI_VSC_WRITE_SCO_PCM_INT_PARAM); - *p++ = SCO_PCM_PARAM_SIZE; - memcpy(p, &bt_sco_param, SCO_PCM_PARAM_SIZE); - cmd_u16 = HCI_VSC_WRITE_SCO_PCM_INT_PARAM; - LOGI("SCO PCM configure {%d, %d, %d, %d, %d}", - bt_sco_param[0], bt_sco_param[1], bt_sco_param[2], bt_sco_param[3], \ - bt_sco_param[4]); - -#else - UINT16_TO_STREAM(p, HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM); - *p++ = SCO_I2SPCM_PARAM_SIZE; - memcpy(p, &bt_sco_param, SCO_I2SPCM_PARAM_SIZE); - cmd_u16 = HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM; - LOGI("SCO over I2SPCM interface {%d, %d, %d, %d}", - bt_sco_param[0], bt_sco_param[1], bt_sco_param[2], bt_sco_param[3]); -#endif - - if ((ret=hci_h4_send_int_cmd(cmd_u16, p_buf, hw_sco_cfg_cback))==FALSE) - { - bt_vendor_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); - } - else - return; - } - - if (bt_vendor_cbacks) - { - LOGE("vendor lib postload aborted"); - bt_vendor_cbacks->postload_cb(NULL, BT_VENDOR_POSTLOAD_FAIL); - } -} -#endif // SCO_CFG_INCLUDED - -/******************************************************************************* -** -** Function hw_set_patch_file_path -** -** Description Set the location of firmware patch file -** -** Returns 0 : Success -** Otherwise : Fail -** -*******************************************************************************/ -int hw_set_patch_file_path(char *p_conf_name, char *p_conf_value, int param) -{ - - strcpy(fw_patchfile_path, p_conf_value); - - return 0; -} - diff --git a/vendor/libvendor/src/upio.c b/vendor/libvendor/src/upio.c deleted file mode 100644 index b156cb6..0000000 --- a/vendor/libvendor/src/upio.c +++ /dev/null @@ -1,329 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2009-2012 Broadcom Corporation - * - * This program is the proprietary software of Broadcom Corporation and/or its - * licensors, and may only be used, duplicated, modified or distributed - * pursuant to the terms and conditions of a separate, written license - * agreement executed between you and Broadcom (an "Authorized License"). - * Except as set forth in an Authorized License, Broadcom grants no license - * (express or implied), right to use, or waiver of any kind with respect to - * the Software, and Broadcom expressly reserves all rights in and to the - * Software and all intellectual property rights therein. - * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS - * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE - * ALL USE OF THE SOFTWARE. - * - * Except as expressly set forth in the Authorized License, - * - * 1. This program, including its structure, sequence and organization, - * constitutes the valuable trade secrets of Broadcom, and you shall - * use all reasonable efforts to protect the confidentiality thereof, - * and to use this information only in connection with your use of - * Broadcom integrated circuit products. - * - * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED - * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, - * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, - * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY - * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, - * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, - * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR - * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT - * OF USE OR PERFORMANCE OF THE SOFTWARE. - * - * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR - * ITS LICENSORS BE LIABLE FOR - * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY - * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO - * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM - * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR - * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE - * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE - * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF - * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. - * - ******************************************************************************/ - -/****************************************************************************** - * - * Filename: upio.c - * - * Description: Contains I/O functions, like - * rfkill control - * BT_WAKE/HOST_WAKE control - * - ******************************************************************************/ - -#define LOG_TAG "bt_upio" - -#include <utils/Log.h> -#include <fcntl.h> -#include <errno.h> -#include <cutils/properties.h> -#include "bt_vendor_brcm.h" -#include "upio.h" -#include "userial.h" - -/****************************************************************************** -** Constants & Macros -******************************************************************************/ - -#ifndef UPIO_DBG -#define UPIO_DBG FALSE -#endif - -#if (UPIO_DBG == TRUE) -#define UPIODBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_UPIO)) \ - LOGD(param, ## __VA_ARGS__);\ - } -#else -#define UPIODBG(param, ...) {} -#endif - -/****************************************************************************** -** Local type definitions -******************************************************************************/ - -/****************************************************************************** -** Static variables -******************************************************************************/ - -static uint8_t upio_state[UPIO_MAX_COUNT]; -static int rfkill_id = -1; -static int bt_emul_enable = 0; -static char *rfkill_state_path = NULL; - -/****************************************************************************** -** Static functions -******************************************************************************/ - -/* for friendly debugging outpout string */ -static char *lpm_state[] = { - "UNKNOWN", - "de-asserted", - "asserted" -}; - -/***************************************************************************** -** Bluetooth On/Off Static Functions -*****************************************************************************/ -static int is_emulator_context(void) -{ - char value[PROPERTY_VALUE_MAX]; - - property_get("ro.kernel.qemu", value, "0"); - UPIODBG("is_emulator_context : %s", value); - if (strcmp(value, "1") == 0) { - return 1; - } - return 0; -} - -static int is_rfkill_disabled(void) -{ - char value[PROPERTY_VALUE_MAX]; - - property_get("ro.rfkilldisabled", value, "0"); - UPIODBG("is_rfkill_disabled ? [%s]", value); - - if (strcmp(value, "1") == 0) { - return UPIO_BT_POWER_ON; - } - - return UPIO_BT_POWER_OFF; -} - -static int init_rfkill() -{ - char path[64]; - char buf[16]; - int fd, sz, id; - - if (is_rfkill_disabled()) - return -1; - - for (id = 0; ; id++) - { - snprintf(path, sizeof(path), "/sys/class/rfkill/rfkill%d/type", id); - fd = open(path, O_RDONLY); - if (fd < 0) - { - LOGE("init_rfkill : open(%s) failed: %s (%d)\n", \ - path, strerror(errno), errno); - return -1; - } - - sz = read(fd, &buf, sizeof(buf)); - close(fd); - - if (sz >= 9 && memcmp(buf, "bluetooth", 9) == 0) - { - rfkill_id = id; - break; - } - } - - asprintf(&rfkill_state_path, "/sys/class/rfkill/rfkill%d/state", rfkill_id); - return 0; -} - -/***************************************************************************** -** LPM Static Functions -*****************************************************************************/ - -/***************************************************************************** -** UPIO Interface Functions -*****************************************************************************/ - -/******************************************************************************* -** -** Function upio_init -** -** Description Initialization -** -** Returns None -** -*******************************************************************************/ -void upio_init(void) -{ - memset(upio_state, UPIO_UNKNOWN, UPIO_MAX_COUNT); -} - -/******************************************************************************* -** -** Function upio_cleanup -** -** Description Clean up -** -** Returns None -** -*******************************************************************************/ -void upio_cleanup(void) -{ -} - -/******************************************************************************* -** -** Function upio_set_bluetooth_power -** -** Description Interact with low layer driver to set Bluetooth power -** on/off. -** -** Returns 0 : SUCCESS or Not-Applicable -** <0 : ERROR -** -*******************************************************************************/ -int upio_set_bluetooth_power(int on) -{ - int sz; - int fd = -1; - int ret = -1; - char buffer = '0'; - - switch(on) - { - case UPIO_BT_POWER_OFF: - buffer = '0'; - break; - - case UPIO_BT_POWER_ON: - buffer = '1'; - break; - } - - if (is_emulator_context()) - { - /* if new value is same as current, return -1 */ - if (bt_emul_enable == on) - return ret; - - UPIODBG("set_bluetooth_power [emul] %d", on); - - bt_emul_enable = on; - return 0; - } - - /* check if we have rfkill interface */ - if (is_rfkill_disabled()) - return 0; - - if (rfkill_id == -1) - { - if (init_rfkill()) - return ret; - } - - fd = open(rfkill_state_path, O_WRONLY); - - if (fd < 0) - { - LOGE("set_bluetooth_power : open(%s) for write failed: %s (%d)", - rfkill_state_path, strerror(errno), errno); - return ret; - } - - sz = write(fd, &buffer, 1); - - if (sz < 0) { - LOGE("set_bluetooth_power : write(%s) failed: %s (%d)", - rfkill_state_path, strerror(errno),errno); - } - else - ret = 0; - - if (fd >= 0) - close(fd); - - return ret; -} - - -/******************************************************************************* -** -** Function upio_set -** -** Description Set i/o based on polarity -** -** Returns None -** -*******************************************************************************/ -void upio_set(uint8_t pio, uint8_t action, uint8_t polarity) -{ - int rc; - - switch (pio) - { - case UPIO_BT_WAKE: - - if (upio_state[UPIO_BT_WAKE] == action) - { - UPIODBG("BT_WAKE is %s already", lpm_state[action]); - return; - } - - upio_state[UPIO_BT_WAKE] = action; - - /**************************************** - * !!! TODO !!! - * - * === Custom Porting Required === - * - * Platform dependent user-to-kernel - * interface is required to set output - * state of physical BT_WAKE pin. - ****************************************/ -#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE) - userial_ioctl( ( (action==UPIO_ASSERT) ? \ - USERIAL_OP_ASSERT_BT_WAKE : USERIAL_OP_DEASSERT_BT_WAKE),\ - NULL); -#endif - break; - - case UPIO_HOST_WAKE: - UPIODBG("upio_set: UPIO_HOST_WAKE"); - break; - } -} - - diff --git a/vendor/libvendor/vnd_buildcfg.mk b/vendor/libvendor/vnd_buildcfg.mk deleted file mode 100644 index ea4b0e5..0000000 --- a/vendor/libvendor/vnd_buildcfg.mk +++ /dev/null @@ -1,12 +0,0 @@ -intermediates := $(local-intermediates-dir) - -SRC := $(call my-dir)/include/$(addprefix vnd_, $(addsuffix .txt,$(basename $(TARGET_DEVICE)))) -GEN := $(intermediates)/vnd_buildcfg.h -TOOL := $(call my-dir)/../../tools/gen-buildcfg.sh - -$(GEN): PRIVATE_PATH := $(call my-dir) -$(GEN): PRIVATE_CUSTOM_TOOL = $(TOOL) $< $@ -$(GEN): $(SRC) $(TOOL) - $(transform-generated-source) - -LOCAL_GENERATED_SOURCES += $(GEN) |