summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk8
-rw-r--r--libbt-vendor/Android.mk11
-rw-r--r--libbt-vendor/include/bt_vendor_qcom.h1
-rw-r--r--libbt-vendor/src/bt_vendor_persist.cpp42
-rw-r--r--libbt-vendor/src/bt_vendor_qcom.c4
-rw-r--r--libbt-vendor/vnd_buildcfg.mk4
6 files changed, 63 insertions, 7 deletions
diff --git a/Android.mk b/Android.mk
index cd2c3ae..52c1c79 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,3 +1,7 @@
-ifeq ($(call is-vendor-board-platform,QCOM),true)
+BT_VENDOR_PATH := $(call my-dir)
+
+ifeq ($(BT_VENDOR_PATH),$(call project-path-for,bt-vendor))
+
include $(call all-named-subdir-makefiles,libbt-vendor)
-endif # is-vendor-board-platform
+
+endif
diff --git a/libbt-vendor/Android.mk b/libbt-vendor/Android.mk
index f275ba6..da74614 100644
--- a/libbt-vendor/Android.mk
+++ b/libbt-vendor/Android.mk
@@ -59,8 +59,7 @@ endif #WIFI_BT_STATUS_SYNC
LOCAL_SHARED_LIBRARIES := \
libcutils \
- liblog \
- libbtnv
+ liblog
LOCAL_MODULE := libbt-vendor
LOCAL_CLANG := false
@@ -75,7 +74,15 @@ else
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
endif
+ifeq ($(QCOM_BT_USE_BTNV),true)
LOCAL_CFLAGS += -DBT_NV_SUPPORT
+ifeq ($(QCPATH),)
+LOCAL_SHARED_LIBRARIES += libdl
+LOCAL_CFLAGS += -DBT_NV_SUPPORT_DL
+else
+LOCAL_SHARED_LIBRARIES += libbtnv
+endif
+endif
ifneq ($(BOARD_ANT_WIRELESS_DEVICE),)
LOCAL_CFLAGS += -DENABLE_ANT
diff --git a/libbt-vendor/include/bt_vendor_qcom.h b/libbt-vendor/include/bt_vendor_qcom.h
index 6e5469e..b30b4f9 100644
--- a/libbt-vendor/include/bt_vendor_qcom.h
+++ b/libbt-vendor/include/bt_vendor_qcom.h
@@ -20,7 +20,6 @@
#include "bt_vendor_lib.h"
//#include "vnd_buildcfg.h"
-
#ifndef FALSE
#define FALSE 0
#endif
diff --git a/libbt-vendor/src/bt_vendor_persist.cpp b/libbt-vendor/src/bt_vendor_persist.cpp
index 519e826..db895fd 100644
--- a/libbt-vendor/src/bt_vendor_persist.cpp
+++ b/libbt-vendor/src/bt_vendor_persist.cpp
@@ -27,7 +27,27 @@
#include "bt_vendor_persist.h"
#ifdef BT_NV_SUPPORT
+#ifdef BT_NV_SUPPORT_DL
+#include <dlfcn.h>
+// All figured out through investigation of this code...
+typedef struct {
+ unsigned char bd_addr[6];
+ // This is a bit dangerous, but this struct
+ // is unknown (however not used outside of this context)
+ unsigned char unknown[58];
+} nv_persist_item_type;
+typedef enum {
+ NV_SUCCESS = 0,
+} nv_persist_stat_enum_type;
+#define TRUE 1
+#define FALSE 0
+#define NV_BD_ADDR_I 1
+// ...except this, which was found through experimentation
+#define NV_READ_F 0
+#else
#include "bt_nv.h"
+#endif
+#define LOG_TAG "QCOM-BTNV"
#include <utils/Log.h>
/*===========================================================================
@@ -56,11 +76,28 @@ uint8_t bt_vendor_nv_read
nv_persist_item_type my_nv_item;
nv_persist_stat_enum_type cmd_result;
boolean result = FALSE;
+#ifdef BT_NV_SUPPORT_DL
+ int (*bt_nv_cmd)(int, int, nv_persist_item_type *, int);
+ void *lib = dlopen("libbtnv.so", RTLD_NOW);
+
+ if (!lib) {
+ ALOGE("Failed to open libbtnv.so: %s", dlerror());
+ return FALSE;
+ }
+
+ bt_nv_cmd = (int (*)(int, int, nv_persist_item_type *, int))dlsym(lib, "bt_nv_cmd");
+ if (!bt_nv_cmd) {
+ ALOGE("Failed to find bt_nv_cmd: %s", dlerror());
+ dlclose(lib);
+ return FALSE;
+ }
+#endif
switch(nv_item)
{
case NV_BD_ADDR_I:
- cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F, NV_BD_ADDR_I, &my_nv_item);
+ // A strange default parameter is used here. A debugger shows 4 parameters being passed.
+ cmd_result = (nv_persist_stat_enum_type)bt_nv_cmd(NV_READ_F, NV_BD_ADDR_I, &my_nv_item, 0);
ALOGI("CMD result: %d", cmd_result);
if (NV_SUCCESS != cmd_result)
{
@@ -86,6 +123,9 @@ uint8_t bt_vendor_nv_read
}
break;
}
+#ifdef BT_NV_SUPPORT_DL
+ dlclose(lib);
+#endif
return result;
}
#endif /* End of BT_NV_SUPPORT */
diff --git a/libbt-vendor/src/bt_vendor_qcom.c b/libbt-vendor/src/bt_vendor_qcom.c
index 0a36ad6..1841b92 100644
--- a/libbt-vendor/src/bt_vendor_qcom.c
+++ b/libbt-vendor/src/bt_vendor_qcom.c
@@ -205,7 +205,7 @@ static int get_bt_soc_type()
ALOGI("bt-vendor : get_bt_soc_type");
ret = property_get("qcom.bluetooth.soc", bt_soc_type, NULL);
- if (ret != 0) {
+ if (ret >= 0) {
ALOGI("qcom.bluetooth.soc set to %s\n", bt_soc_type);
if (!strncasecmp(bt_soc_type, "rome", sizeof("rome"))) {
return BT_SOC_ROME;
@@ -836,12 +836,14 @@ static int op(bt_vendor_opcode_t opcode, void *param)
ignore_boot_prop = TRUE;
}
#endif //READ_BT_ADDR_FROM_PROP
+#ifdef BT_NV_SUPPORT
/* Always read BD address from NV file */
if(ignore_boot_prop && !bt_vendor_nv_read(1, vnd_local_bd_addr))
{
/* Since the BD address is configured in boot time We should not be here */
ALOGI("Failed to read BD address. Use the one from bluedroid stack/ftm");
}
+#endif
if(rome_soc_init(fd, (char*)vnd_local_bd_addr)<0) {
retval = -1;
} else {
diff --git a/libbt-vendor/vnd_buildcfg.mk b/libbt-vendor/vnd_buildcfg.mk
index 626a5f9..4ae0586 100644
--- a/libbt-vendor/vnd_buildcfg.mk
+++ b/libbt-vendor/vnd_buildcfg.mk
@@ -14,7 +14,11 @@
# limitations under the License.
#
+ifneq ($(TARGET_2ND_ARCH),)
+intermediates := $(call local-intermediates-dir,,$(TARGET_2ND_ARCH_VAR_PREFIX))
+else
intermediates := $(local-intermediates-dir)
+endif
SRC := $(call my-dir)/include/$(addprefix vnd_, $(addsuffix .txt,$(basename $(TARGET_DEVICE))))
ifeq (,$(wildcard $(SRC)))