summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorKausik Sinnaswamy <kausik@broadcom.com>2012-04-02 15:04:26 +0530
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:14 -0700
commit84a000f59a48dac41d04da6bf9569258bc0e2cfc (patch)
tree7552daf852870cf54ce7d6d9e1ad8f1ca83231c5 /vendor
parentc01f69a35563261eca49bd2083afd7064790940d (diff)
downloadexternal_bluetooth_bluedroid-84a000f59a48dac41d04da6bf9569258bc0e2cfc.zip
external_bluetooth_bluedroid-84a000f59a48dac41d04da6bf9569258bc0e2cfc.tar.gz
external_bluetooth_bluedroid-84a000f59a48dac41d04da6bf9569258bc0e2cfc.tar.bz2
Consolidated patchset for
1) Run-time configuration: configure stack and vendor at run-time using bt_stack.conf and bt_vendor.conf in /etc/bluetooth/ 2) Build-time configuration: Auto-generate buildcfg.h header file from the target config bdroid_$(TARGET_DEVICE).txt file Change-Id: Ieebb71081b7de404eab37f9ff4596d3dc94547a7
Diffstat (limited to 'vendor')
-rw-r--r--vendor/libvendor/Android.mk16
-rw-r--r--vendor/libvendor/include/bt_vendor_brcm.h24
-rw-r--r--vendor/libvendor/include/userial.h12
-rw-r--r--vendor/libvendor/include/vnd_buildcfg.h14
-rw-r--r--vendor/libvendor/include/vnd_crespo.txt11
-rw-r--r--vendor/libvendor/include/vnd_maguro.txt11
-rw-r--r--vendor/libvendor/include/vnd_toro.txt11
-rw-r--r--vendor/libvendor/include/vnd_wingray.txt12
-rw-r--r--vendor/libvendor/src/bt_vendor_brcm.c15
-rw-r--r--vendor/libvendor/src/btsnoop.c145
-rw-r--r--vendor/libvendor/src/conf.c199
-rw-r--r--vendor/libvendor/src/hardware.c39
-rw-r--r--vendor/libvendor/src/hci_h4.c35
-rw-r--r--vendor/libvendor/src/upio.c6
-rw-r--r--vendor/libvendor/src/userial.c27
15 files changed, 456 insertions, 121 deletions
diff --git a/vendor/libvendor/Android.mk b/vendor/libvendor/Android.mk
index 8ea5e90..808990d 100644
--- a/vendor/libvendor/Android.mk
+++ b/vendor/libvendor/Android.mk
@@ -2,6 +2,19 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
+vnd_targetfile = $(LOCAL_PATH)/include/$(addprefix vnd_, $(addsuffix .txt,$(basename $(TARGET_DEVICE))))
+vnd_cfgfile = $(LOCAL_PATH)/include/vnd_buildcfg.h
+
+vnd_build_cfg = $(shell if [ -f $(vnd_cfgfile) ] && [ `stat -c %Y $(vnd_targetfile)` -lt `stat -c %Y $(vnd_cfgfile)` ]; then echo 0; else echo 1; fi)
+
+ifeq ($(vnd_build_cfg),1)
+$(info "Creating $(vnd_cfgfile) from $(vnd_targetfile)")
+$(shell echo "#ifndef VND_BUILDCFG_H" > $(vnd_cfgfile))
+$(shell echo "#define VND_BUILDCFG_H" >> $(vnd_cfgfile))
+$(shell sed -e '/^#/d' -e '/^$$/d' -e '/# Makefile only$$/d' -e 's/^/#define /' -e 's/=/ /' $(vnd_targetfile) >> $(vnd_cfgfile))
+$(shell echo "#endif" >> $(vnd_cfgfile))
+endif
+
LOCAL_SRC_FILES := \
src/bt_vendor_brcm.c \
src/hci_h4.c \
@@ -9,7 +22,8 @@ LOCAL_SRC_FILES := \
src/hardware.c \
src/upio.c \
src/utils.c \
- src/btsnoop.c
+ src/btsnoop.c \
+ src/conf.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include
diff --git a/vendor/libvendor/include/bt_vendor_brcm.h b/vendor/libvendor/include/bt_vendor_brcm.h
index 326a8da..ae72fc7 100644
--- a/vendor/libvendor/include/bt_vendor_brcm.h
+++ b/vendor/libvendor/include/bt_vendor_brcm.h
@@ -121,6 +121,11 @@
/* 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 */
@@ -128,7 +133,7 @@
/* Location of firmware patch files */
#ifndef FW_PATCHFILE_LOCATION
-#define FW_PATCHFILE_LOCATION ("/vendor/firmware/") /* maguro */
+#define FW_PATCHFILE_LOCATION "/vendor/firmware/" /* maguro */
#endif
#ifndef UART_TARGET_BAUD_RATE
@@ -385,6 +390,21 @@
#define FACTORY_BT_BDADDR_STORAGE_LEN 17
+/* 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
******************************************************************************/
@@ -416,6 +436,8 @@ typedef struct _vnd_buffer_hdr
******************************************************************************/
extern bt_vendor_callbacks_t *bt_vendor_cbacks;
+extern vnd_debug_t dbg_mode;
+extern vnd_debug_t traces;
/******************************************************************************
** Functions
diff --git a/vendor/libvendor/include/userial.h b/vendor/libvendor/include/userial.h
index 9231bb0..818bb8f 100644
--- a/vendor/libvendor/include/userial.h
+++ b/vendor/libvendor/include/userial.h
@@ -241,5 +241,17 @@ 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/vnd_buildcfg.h b/vendor/libvendor/include/vnd_buildcfg.h
deleted file mode 100644
index a6fbb23..0000000
--- a/vendor/libvendor/include/vnd_buildcfg.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef VND_BUILDCFG_H
-#define VND_BUILDCFG_H
-//#define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyHS0" /* pyramid */
-//#define FW_PATCHFILE_LOCATION ("/etc/firmware/") /* pyramid */
-//#define LPM_BT_WAKE_POLARITY 0 /* pyramid */
-//#define LPM_HOST_WAKE_POLARITY 0 /* pyramid */
-#define BT_WAKE_VIA_USERIAL_IOCTL TRUE
-#define LPM_IDLE_TIMEOUT_MULTIPLE 5
-#define BTSNOOPDISP_INCLUDED TRUE
-#define BTSNOOP_FILENAME "/data/misc/bluedroid/btsnoop_hci.cfa"
-#define SNOOP_CONFIG_PATH "/data/misc/bluedroid/btsnoop_enabled"
-#define BTSNOOP_DBG FALSE
-#define SCO_USE_I2S_INTERFACE TRUE
-#endif // VND_BUILDCFG_H
diff --git a/vendor/libvendor/include/vnd_crespo.txt b/vendor/libvendor/include/vnd_crespo.txt
new file mode 100644
index 0000000..9296738
--- /dev/null
+++ b/vendor/libvendor/include/vnd_crespo.txt
@@ -0,0 +1,11 @@
+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
diff --git a/vendor/libvendor/include/vnd_maguro.txt b/vendor/libvendor/include/vnd_maguro.txt
new file mode 100644
index 0000000..8705da6
--- /dev/null
+++ b/vendor/libvendor/include/vnd_maguro.txt
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 0000000..8705da6
--- /dev/null
+++ b/vendor/libvendor/include/vnd_toro.txt
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 0000000..57ac1c3
--- /dev/null
+++ b/vendor/libvendor/include/vnd_wingray.txt
@@ -0,0 +1,12 @@
+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/bt_vendor_brcm.c b/vendor/libvendor/src/bt_vendor_brcm.c
index 0b10876..9b25692 100644
--- a/vendor/libvendor/src/bt_vendor_brcm.c
+++ b/vendor/libvendor/src/bt_vendor_brcm.c
@@ -67,9 +67,11 @@
#endif
#if (BTVND_DBG == TRUE)
-#define BTVNDDBG LOGD
+#define BTVNDDBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_VND)) \
+ LOGD(param, ## __VA_ARGS__);\
+ }
#else
-#define BTVNDDBG
+#define BTVNDDBG(param, ...) {}
#endif
/******************************************************************************
@@ -90,6 +92,7 @@ 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);
/******************************************************************************
** Variables
@@ -98,6 +101,10 @@ void hw_sco_config(void);
bt_vendor_callbacks_t *bt_vendor_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
******************************************************************************/
@@ -151,7 +158,7 @@ static int init(const bt_vendor_callbacks_t* p_cb)
struct sched_param param;
int policy;
- BTVNDDBG("init");
+ LOGI("init");
if (p_cb == NULL)
{
@@ -159,6 +166,8 @@ static int init(const bt_vendor_callbacks_t* p_cb)
return BT_VENDOR_STATUS_FAIL;
}
+ vnd_load_conf(VENDOR_LIB_CONF_FILE);
+
/* store reference to user callbacks */
bt_vendor_cbacks = (bt_vendor_callbacks_t *) p_cb;
diff --git a/vendor/libvendor/src/btsnoop.c b/vendor/libvendor/src/btsnoop.c
index 78e9dfd..eb0c026 100644
--- a/vendor/libvendor/src/btsnoop.c
+++ b/vendor/libvendor/src/btsnoop.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
- * 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.
*
******************************************************************************/
@@ -90,9 +90,11 @@
#endif
#if (BTSNOOP_DBG == TRUE)
-#define SNOOPDBG LOGD
+#define SNOOPDBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_BTSNOOP)) \
+ LOGD(param, ## __VA_ARGS__);\
+ }
#else
-#define SNOOPDBG
+#define SNOOPDBG(param, ...) {}
#endif
/* file descriptor of the BT snoop file (by default, -1 means disabled) */
@@ -100,14 +102,16 @@ 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 "/sdcard/snoop_log.cfa"
-#error "BTSNOOP_FILENAME needs to be defined in vnd_buildcfg.h"
-
+#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
@@ -169,8 +173,8 @@ do {
** NOTE
** The return value is 64 bit as 2 32 bit variables out_lo and * out_hi.
** A BT Snoop timestamp is the number of microseconds since 01/01/0000.
- ** The timeval structure contains the number of microseconds since EPOCH
- ** (01/01/1970) encoded as: tv.tv_sec, number of seconds since EPOCH and
+ ** The timeval structure contains the number of microseconds since EPOCH
+ ** (01/01/1970) encoded as: tv.tv_sec, number of seconds since EPOCH and
** tv_usec, number of microseconds in current second
**
** Therefore the algorithm is:
@@ -245,12 +249,12 @@ static int btsnoop_log_open(void)
#if defined(BTSNOOPDISP_INCLUDED) && (BTSNOOPDISP_INCLUDED == TRUE)
hci_btsnoop_fd = -1;
- SNOOPDBG("btsnoop_log_open: snoop log file = %s\n", BTSNOOP_FILENAME);
+ SNOOPDBG("btsnoop_log_open: snoop log file = %s\n", btsnoop_logfile);
/* write the BT snoop header */
- if (BTSNOOP_FILENAME != NULL)
+ if (strlen(btsnoop_logfile) != 0)
{
- hci_btsnoop_fd = open((char*)BTSNOOP_FILENAME, \
+ hci_btsnoop_fd = open(btsnoop_logfile, \
O_WRONLY|O_CREAT|O_TRUNC, \
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
if (hci_btsnoop_fd == -1)
@@ -263,9 +267,8 @@ static int btsnoop_log_open(void)
write(hci_btsnoop_fd, "btsnoop\0\0\0\0\1\0\0\x3\xea", 16);
return 1;
}
-#else
- return 2; /* Snoop not available */
#endif
+ return 2; /* Snoop not available */
}
/*******************************************************************************
@@ -312,7 +315,7 @@ void btsnoop_hci_cmd(uint8_t *p)
/* since these display functions are called from different contexts */
utils_lock();
-
+
/* store the length in both original and included fields */
value = l_to_be(p[2] + 4);
write(hci_btsnoop_fd, &value, 4);
@@ -486,7 +489,7 @@ void btsnoop_acl_data(uint8_t *p, uint8_t is_rcvd)
static pthread_t thread_id;
static int s_listen = -1;
static int ext_parser_fd = -1;
-
+
static void ext_parser_detached(void);
int ext_parser_accept(int port)
@@ -503,11 +506,11 @@ int ext_parser_accept(int port)
s_listen = socket(AF_INET, SOCK_STREAM, 0);
if (s_listen < 0)
- {
+ {
LOGE("listener not created: listen fd %d", s_listen);
return -1;
}
-
+
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -529,10 +532,10 @@ int ext_parser_accept(int port)
perror("bind");
result = listen(s_listen, 1);
-
+
if (result < 0)
perror("listen");
-
+
clilen = sizeof(struct sockaddr_in);
s = accept(s_listen, (struct sockaddr *) &cliaddr, &clilen);
@@ -557,14 +560,14 @@ static int send_ext_parser(char *p, int len)
return 0;
SNOOPDBG("write %d to snoop socket\n", len);
-
+
n = write(ext_parser_fd, p, len);
if (n<=0)
{
ext_parser_detached();
}
-
+
return n;
}
@@ -572,12 +575,12 @@ static void ext_parser_detached(void)
{
LOGD("ext parser detached");
- if (ext_parser_fd>0)
+ if (ext_parser_fd>0)
close(ext_parser_fd);
-
- if (s_listen > 0)
+
+ if (s_listen > 0)
close(s_listen);
-
+
ext_parser_fd = -1;
s_listen = -1;
}
@@ -611,7 +614,7 @@ static void ext_parser_thread(void* param)
fd = ext_parser_accept(EXT_PARSER_PORT);
ext_parser_fd = fd;
-
+
LOGD("ext parser attached on fd %d\n", ext_parser_fd);
} while (1);
}
@@ -622,6 +625,25 @@ 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");
@@ -634,14 +656,21 @@ void btsnoop_init(void)
void btsnoop_open(void)
{
- LOGD("btsnoop_open");
- btsnoop_log_open();
+#if defined(BTSNOOPDISP_INCLUDED) && (BTSNOOPDISP_INCLUDED == TRUE)
+ if (btsnoop_log_enabled)
+ {
+ LOGD("btsnoop_open");
+ btsnoop_log_open();
+ }
+#endif // BTSNOOPDISP_INCLUDED
}
void btsnoop_close(void)
{
+#if defined(BTSNOOPDISP_INCLUDED) && (BTSNOOPDISP_INCLUDED == TRUE)
LOGD("btsnoop_close");
btsnoop_log_close();
+#endif
}
void btsnoop_cleanup (void)
@@ -695,6 +724,7 @@ void btsnoop_capture(VND_BT_HDR *p_buf, uint8_t is_rcvd)
return;
}
+#if defined(BTSNOOPDISP_INCLUDED) && (BTSNOOPDISP_INCLUDED == TRUE)
if (hci_btsnoop_fd == -1)
return;
@@ -719,6 +749,7 @@ void btsnoop_capture(VND_BT_HDR *p_buf, uint8_t is_rcvd)
btsnoop_hci_cmd(p);
break;
}
+#endif // BTSNOOPDISP_INCLUDED
}
diff --git a/vendor/libvendor/src/conf.c b/vendor/libvendor/src/conf.c
new file mode 100644
index 0000000..61098ba
--- /dev/null
+++ b/vendor/libvendor/src/conf.c
@@ -0,0 +1,199 @@
+/******************************************************************************
+ *
+ * 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: conf.c
+ *
+ * Description: Contains functions to conduct run-time module configuration
+ * based on entries present in the .conf file
+ *
+ ******************************************************************************/
+
+#define LOG_TAG "bt_vnd_conf"
+
+#include <utils/Log.h>
+#include <string.h>
+#include "bt_vendor_brcm.h"
+
+/******************************************************************************
+** Externs
+******************************************************************************/
+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);
+
+
+/******************************************************************************
+** Local type definitions
+******************************************************************************/
+
+#define CONF_COMMENT '#'
+#define CONF_DELIMITERS " =\n\r\t"
+#define CONF_VALUES_DELIMITERS "=\n\r\t"
+#define CONF_MAX_LINE_LEN 255
+
+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;
+
+/******************************************************************************
+** Static variables
+******************************************************************************/
+
+/*
+ * 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
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function vnd_load_conf
+**
+** Description Read conf entry from p_path file one by one and call
+** the corresponding config function
+**
+** 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);
+ }
+}
+
diff --git a/vendor/libvendor/src/hardware.c b/vendor/libvendor/src/hardware.c
index 886a905..c65caa4 100644
--- a/vendor/libvendor/src/hardware.c
+++ b/vendor/libvendor/src/hardware.c
@@ -81,9 +81,11 @@
#endif
#if (BTHW_DBG == TRUE)
-#define BTHWDBG LOGD
+#define BTHWDBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_HW)) \
+ LOGD(param, ## __VA_ARGS__);\
+ }
#else
-#define BTHWDBG
+#define BTHWDBG(param, ...) {}
#endif
#define FW_PATCHFILE_EXTENSION ".hcd"
@@ -201,6 +203,7 @@ uint8_t hci_h4_send_int_cmd(uint16_t opcode, VND_BT_HDR *p_buf, \
** Static variables
******************************************************************************/
+static char fw_patchfile_path[256] = FW_PATCHFILE_LOCATION;
static uint8_t local_bd_addr[BD_ADDR_LEN]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static const uint8_t null_bdaddr[BD_ADDR_LEN] = {0,0,0,0,0,0};
@@ -305,7 +308,7 @@ static uint8_t hw_config_findpatch(char *p_chip_id_str)
BTHWDBG("Target name = [%s]", p_chip_id_str);
- if ((dirp = opendir(FW_PATCHFILE_LOCATION)) != NULL)
+ if ((dirp = opendir(fw_patchfile_path)) != NULL)
{
/* Fetch next filename in patchfile directory */
while ((dp = readdir(dirp)) != NULL)
@@ -324,10 +327,10 @@ static uint8_t hw_config_findpatch(char *p_chip_id_str)
) == 0))
{
LOGI("Found patchfile: %s/%s", \
- FW_PATCHFILE_LOCATION, dp->d_name);
+ fw_patchfile_path, dp->d_name);
/* Make sure length does not exceed maximum */
- if ((filenamelen + strlen(FW_PATCHFILE_LOCATION)) > \
+ if ((filenamelen + strlen(fw_patchfile_path)) > \
FW_PATCHFILE_PATH_MAXLEN)
{
LOGE("Invalid patchfile name (too long)");
@@ -336,9 +339,9 @@ static uint8_t hw_config_findpatch(char *p_chip_id_str)
{
memset(p_chip_id_str, 0, FW_PATCHFILE_PATH_MAXLEN);
/* Found patchfile. Store location and name */
- strcpy(p_chip_id_str, FW_PATCHFILE_LOCATION);
- if (FW_PATCHFILE_LOCATION[ \
- strlen(FW_PATCHFILE_LOCATION)- 1 \
+ strcpy(p_chip_id_str, fw_patchfile_path);
+ if (fw_patchfile_path[ \
+ strlen(fw_patchfile_path)- 1 \
] != '/')
{
strcat(p_chip_id_str, "/");
@@ -381,7 +384,7 @@ static uint8_t hw_config_findpatch(char *p_chip_id_str)
}
else
{
- LOGE("Could not open %s", FW_PATCHFILE_LOCATION);
+ LOGE("Could not open %s", fw_patchfile_path);
}
return (retval);
@@ -1327,3 +1330,21 @@ void hw_sco_config(void)
}
#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/hci_h4.c b/vendor/libvendor/src/hci_h4.c
index e17c57a..f958951 100644
--- a/vendor/libvendor/src/hci_h4.c
+++ b/vendor/libvendor/src/hci_h4.c
@@ -71,9 +71,11 @@
#endif
#if (HCIH4_DBG == TRUE)
-#define HCIH4DBG LOGD
+#define HCIH4DBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_HCI)) \
+ LOGD(param, ## __VA_ARGS__);\
+ }
#else
-#define HCIH4DBG
+#define HCIH4DBG(param, ...) {}
#endif
/* Preamble length for HCI Commands:
@@ -209,30 +211,6 @@ static tHCI_H4_CB h4_cb;
/*******************************************************************************
**
-** Function is_snoop_enabled
-**
-** Description Enable bt snoop
-**
-** Returns TRUE(enabled)/FALSE
-**
-*******************************************************************************/
-static uint8_t is_snoop_enabled()
-{
- char buf[8];
- int flag = 0;
- int fd = open(SNOOP_CONFIG_PATH, O_RDONLY, 0644);
-
- if (fd < 0) {
- LOGE("file failed to open %s ", SNOOP_CONFIG_PATH);
- return FALSE;
- }
- read(fd, buf, sizeof(buf));
- flag = atoi(buf);
- return (flag == 1) ? TRUE : FALSE;
-}
-
-/*******************************************************************************
-**
** Function get_acl_data_length_cback
**
** Description Callback function for HCI_READ_BUFFER_SIZE and
@@ -600,10 +578,7 @@ void hci_h4_init(void)
h4_cb.hc_ble_acl_data_size = 27;
btsnoop_init();
- if (is_snoop_enabled() == TRUE)
- {
- btsnoop_open();
- }
+ btsnoop_open();
}
/*******************************************************************************
diff --git a/vendor/libvendor/src/upio.c b/vendor/libvendor/src/upio.c
index f26ff45..b156cb6 100644
--- a/vendor/libvendor/src/upio.c
+++ b/vendor/libvendor/src/upio.c
@@ -74,9 +74,11 @@
#endif
#if (UPIO_DBG == TRUE)
-#define UPIODBG LOGD
+#define UPIODBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_UPIO)) \
+ LOGD(param, ## __VA_ARGS__);\
+ }
#else
-#define UPIODBG LOGV
+#define UPIODBG(param, ...) {}
#endif
/******************************************************************************
diff --git a/vendor/libvendor/src/userial.c b/vendor/libvendor/src/userial.c
index 1083505..f806688 100644
--- a/vendor/libvendor/src/userial.c
+++ b/vendor/libvendor/src/userial.c
@@ -75,9 +75,11 @@
#endif
#if (USERIAL_DBG == TRUE)
-#define USERIALDBG LOGD
+#define USERIALDBG(param, ...) {if (dbg_mode & traces & (1 << TRACE_USERIAL)) \
+ LOGD(param, ## __VA_ARGS__);\
+ }
#else
-#define USERIALDBG
+#define USERIALDBG(param, ...) {}
#endif
#define MAX_SERIAL_PORT (USERIAL_PORT_3 + 1)
@@ -439,7 +441,7 @@ uint8_t userial_open(uint8_t port, tUSERIAL_CFG *p_cfg)
struct sched_param param;
int policy;
pthread_attr_t thread_attr;
- char device_name[20];
+ char device_name[32];
USERIALDBG("userial_open(port:%d, baud:%d)", port, p_cfg->baud);
@@ -694,7 +696,7 @@ void userial_change_baud(uint8_t baud)
USERIALDBG("userial_change_baud: Closing UART Port");
userial_close();
- utils_delay(50);
+ utils_delay(100);
/* change baud rate in settings - leave everything else the same */
userial_cb.cfg.baud = baud;
@@ -750,3 +752,20 @@ 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)
+{
+ strcpy(userial_dev[USERIAL_PORT_1], p_conf_value);
+
+ return 0;
+}
+