Overview
The purpose of this document is to demonstrate how to enable USB Bluetooth Dongle based on i.MX6 Android ICS.
Hardware
- i.MX6Dual/Quad or i.MX6DualLite SabreSD board
- USB Bluetooth Dongle
Software
- i.MX6DQ/MX6DL Android ICS R13.4 or R13.4.1 Release
Changes
- 0001-enable-usb-dongle-BT.patch: Update bluedroid to disable RFKILL and enable HCIATTACH property for USB Bluetooth Dongle.
diff --git a/bluedroid/Android.mk b/bluedroid/Android.mk
index 17df49b..569be44 100644
--- a/bluedroid/Android.mk
+++ b/bluedroid/Android.mk
@@ -5,6 +5,13 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
+ifeq ($(BOARD_BLUETOOTH_DOES_NOT_USE_RFKILL),true)
+ LOCAL_CFLAGS := $(LOCAL_CFLAGS) -DBLUETOOTH_DOES_NOT_USE_RFKILL
+endif
+
+ifeq ($(BOARD_BLUETOOTH_USES_HCIATTACH_PROPERTY),true)
+ LOCAL_CFLAGS := $(LOCAL_CFLAGS) -DBLUETOOTH_HCIATTACH_USING_PROPERTY
+endif
LOCAL_SRC_FILES := \
bluetooth.c
diff --git a/bluedroid/bluetooth.c b/bluedroid/bluetooth.c
index 4cc9204..2636942 100644
--- a/bluedroid/bluetooth.c
+++ b/bluedroid/bluetooth.c
@@ -44,7 +44,7 @@
static int rfkill_id = -1;
static char *rfkill_state_path = NULL;
-
+#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL
static int init_rfkill() {
char path[64];
char buf[16];
@@ -135,6 +135,7 @@ out:
if (fd >= 0) close(fd);
return ret;
}
+#endif
static inline int create_hci_sock() {
int sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
@@ -151,13 +152,20 @@ int bt_enable() {
int ret = -1;
int hci_sock = -1;
int attempt;
-
+#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL
if (set_bluetooth_power(1) < 0) goto out;
-
+#endif
+#ifndef BLUETOOTH_HCIATTACH_USING_PROPERTY
LOGI("Starting hciattach daemon");
- if (property_set("ctl.start", "hciattach") < 0) {
+ if (property_set("ctl.start", "hciattach") < 0)
+#else
+ if (property_set("bluetooth.hciattach", "true") < 0)
+#endif
+ {
LOGE("Failed to start hciattach");
+#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL
set_bluetooth_power(0);
+#endif
goto out;
}
@@ -186,14 +194,18 @@ int bt_enable() {
if (property_set("ctl.stop", "hciattach") < 0) {
LOGE("Error stopping hciattach");
}
+#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL
set_bluetooth_power(0);
+#endif
goto out;
}
LOGI("Starting bluetoothd deamon");
if (property_set("ctl.start", "bluetoothd") < 0) {
LOGE("Failed to start bluetoothd");
+#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL
set_bluetooth_power(0);
+#endif
goto out;
}
@@ -222,14 +234,20 @@ int bt_disable() {
ioctl(hci_sock, HCIDEVDOWN, HCI_DEV_ID);
LOGI("Stopping hciattach deamon");
- if (property_set("ctl.stop", "hciattach") < 0) {
+#ifndef BLUETOOTH_HCIATTACH_USING_PROPERTY
+ if (property_set("ctl.stop", "hciattach") < 0)
+#else
+ if (property_set("bluetooth.hciattach", "false") < 0)
+#endif
+ {
LOGE("Error stopping hciattach");
goto out;
}
-
+#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL
if (set_bluetooth_power(0) < 0) {
goto out;
}
+#endif
ret = 0;
out:
@@ -246,9 +264,10 @@ int bt_is_enabled() {
// Check power first
+#ifndef BLUETOOTH_DOES_NOT_USE_RFKILL
ret = check_bluetooth_power();
if (ret == -1 || ret == 0) goto out;
-
+#endif
ret = -1;
// Power is on, now check if the HCI interface is up
- 0002-usb_dongle-on-SabreSD.patch: Update MX6 board configuration files to enable USB Bluetooth dongle feature.
diff --git a/imx6/imx6.mk b/imx6/imx6.mk
@@ -63,6 +63,7 @@ PRODUCT_PACKAGES += \
PRODUCT_PACKAGES += \
audio.tinyalsa.freescale \
audio.legacy.freescale \
+ audio.a2dp.default \
alsa_aplay \
alsa_arecord \
alsa_amixer \
diff --git a/imx6/sabresd/SabreSDBoardConfigComm.mk b/imx6/sabresd/SabreSDBoardConfigComm.mk
index 03d8ce5..1a8a6bd 100755
--- a/imx6/sabresd/SabreSDBoardConfigComm.mk
+++ b/imx6/sabresd/SabreSDBoardConfigComm.mk
-# atheros 3k BT
-BOARD_USE_AR3K_BLUETOOTH := true
+# Default use USB BT dongle for imx6, so should enable below
+BOARD_BLUETOOTH_DOES_NOT_USE_RFKILL := true
+BOARD_BLUETOOTH_USES_HCIATTACH_PROPERTY := true
+
USE_ION_ALLOCATOR := false
USE_GPU_ALLOCATOR := true
diff --git a/imx6/sabresd/init.rc b/imx6/sabresd/init.rc
index ff9f0ff..f127177 100755
--- a/imx6/sabresd/init.rc
+++ b/imx6/sabresd/init.rc
@@ -84,9 +84,12 @@ on boot
# No bluetooth hardware present
setprop hw.bluetooth 0
setprop wlan.interface wlan0
+ setprop hw.bluetooth 1
diff --git a/imx6/sabresd/required_hardware.xml b/imx6/sabresd/required_hardware.xml
index c9a2271..f7db37b 100644
--- a/imx6/sabresd/required_hardware.xml
+++ b/imx6/sabresd/required_hardware.xml
@@ -22,6 +22,7 @@
<feature name="android.hardware.camera.flash" />
<feature name="android.hardware.camera.front" />
<feature name="android.hardware.location" />
+ <feature name="android.hardware.bluetooth" />
<feature name="android.hardware.location.network" />
<feature name="android.hardware.location.gps" />
<feature name="android.hardware.telephony" />