Skip to content

Commit

Permalink
imx8mp_var_dart: Fix Android BT issue for LWB
Browse files Browse the repository at this point in the history
Signed-off-by: Harshesh Valera <[email protected]>
  • Loading branch information
hj2006 committed Jun 8, 2023
1 parent 3013596 commit 3f23031
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 3 deletions.
13 changes: 13 additions & 0 deletions imx8m/dart_mx8mp/init.brcm.wifibt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,18 @@ echo 0 > /sys/class/gpio/gpio${BT_BUF_GPIO}/value
# always set property even if wifi failed
# as property value "1" is expected in early-boot trigger
setprop sys.brcm.wifibt.completed 1
# Return true if SOM has 5G WIFI chip
som_has_5g_wifi()
{
if [ "`cat ${WIFI_SDIO_ID_FILE}`" = "${WIFI_5G_SDIO_ID}" ]; then
return 0
fi

return 1
}
if som_has_5g_wifi; then
setprop ro.boot.bt_firmware "BCM4335C0.hcd"
else
setprop ro.boot.bt_firmware "BCM43430A1.hcd"
fi
exit 0
6 changes: 6 additions & 0 deletions imx8m/dart_mx8mp/init.rc
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,9 @@ on property:ro.boot.usb.debugging=1

on property:sys.boot_completed=1
start init_brcm_bt_sh

on property:vendor.bluetooth.init=true
start init_brcm_bt_sh

on property:vendor.bluetooth.init=false
start init_brcm_bt_sh
15 changes: 15 additions & 0 deletions imx8m/dart_mx8mp/sepolicy/hal_bluetooth_default.te
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@ allow hal_bluetooth_default system_file:file read;
allow hal_bluetooth_default system_file:file open;
allow hal_bluetooth_default system_file:file getattr;
allow hal_bluetooth_default sysfs_rfkill:file write;
allow hal_bluetooth_default sysfs:file { write };
allow hal_bluetooth_default hal_bluetooth_default:unix_stream_socket { ioctl };
allow hal_bluetooth_default sysfs_rfkill:file { write };
# connect to the UART
allow hal_bluetooth_default wcnss_filter:unix_stream_socket {connectto};
# vendor.wc_transport.start_hci and friends
set_prop(hal_bluetooth_default, wc_prop)
set_prop(hal_bluetooth_default, vendor_bluetooth_prop)
set_prop(hal_bluetooth_default, public_vendor_default_prop)
# talk to system_server to set priority
allow hal_bluetooth_default fwk_scheduler_hwservice:hwservice_manager {find};
allow hal_bluetooth_default system_server:binder {call};
# Use bluetooth device
allow hal_bluetooth_default hci_attach_dev:chr_file rw_file_perms;
allow hal_bluetooth_default hci_attach_dev:chr_file {open read write ioctl};
1 change: 1 addition & 0 deletions imx8m/dart_mx8mp/sepolicy/property_contexts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ro.boot.bt_firmware u:object_r:exported_default_prop:s0 exact string
ro.boot.bt_uart u:object_r:exported_default_prop:s0 exact string
ro.boot.bt_sdio_id u:object_r:exported_default_prop:s0 exact string
ro.rfkilldisabled u:object_r:exported_default_prop:s0 exact string
vendor.bluetooth.init u:object_r:public_vendor_default_prop:s0
1 change: 1 addition & 0 deletions imx8m/dart_mx8mp/sepolicy/system_server.te
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
allow system_server nfc:file write;
dontaudit system_server bluetooth:file write;
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
From 98e1c946d562a4453fd344ac7aeb53424ddb3227 Mon Sep 17 00:00:00 2001
From 4ffe14f692336daf348551ea641c31043486d31c Mon Sep 17 00:00:00 2001
From: Mohit Singh <[email protected]>
Date: Mon, 17 Feb 2020 14:14:51 -0800
Subject: [PATCH] imx8mm_var_som: Support to override BT uart and BT fimware.
Subject: [PATCH 1/3] imx8mm_var_som: Support to override BT uart and BT
fimware.

- Added support to switch between 2.4G and 5G firmware.
---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 0fbb8d6d71c0be53f36bce1453fad2b4aea57384 Mon Sep 17 00:00:00 2001
From: Harshesh Valera <[email protected]>
Date: Wed, 17 May 2023 21:16:06 -0700
Subject: [PATCH 2/2] imx8mp_var_dart: Support for dual band firmware loading
Subject: [PATCH 2/3] imx8mp_var_dart: Support for dual band firmware loading

Signed-off-by: Harshesh Valera <[email protected]>
---
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From b8b75d0f8ecf3e717baffd9f0ea9ec70ca6bd33f Mon Sep 17 00:00:00 2001
From: Harshesh Valera <[email protected]>
Date: Thu, 8 Jun 2023 13:17:24 -0700
Subject: [PATCH 3/3] libbt: Instead of rfkill use the power on properties to
trigger BT init scripts

Signed-off-by: Harshesh Valera <[email protected]>
---
src/upio.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/src/upio.c b/src/upio.c
index 6d32a33..ddb65ef 100644
--- a/src/upio.c
+++ b/src/upio.c
@@ -290,6 +290,22 @@ void upio_cleanup(void)
#endif
}

+int setprop_brcm(int on)
+{
+ switch(on)
+ {
+ case UPIO_BT_POWER_ON:
+ property_set("vendor.bluetooth.init", "true");
+ break;
+ case UPIO_BT_POWER_OFF:
+ property_set("vendor.bluetooth.init", "false");
+ break;
+ default:
+ property_set("vendor.bluetooth.init", "true");
+ }
+ sleep(1);
+ return 0;
+}
/*******************************************************************************
**
** Function upio_set_bluetooth_power
@@ -318,6 +334,7 @@ int upio_set_bluetooth_power(int on)
buffer = '1';
break;
}
+ setprop_brcm(on);

if (is_emulator_context())
{
--
2.25.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From d5d0418040f38cf12af5b72a1da00eb2a000d174 Mon Sep 17 00:00:00 2001
From: Harshesh Valera <[email protected]>
Date: Thu, 8 Jun 2023 13:14:35 -0700
Subject: [PATCH] system/bt: Revert bt initialization timeout from new 2.9
seconds back to 8 second

As per Leird Documentation

Signed-off-by: Harshesh Valera <[email protected]>
---
hci/src/hci_layer.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hci/src/hci_layer.cc b/hci/src/hci_layer.cc
index 80f63de..f2a99ad 100644
--- a/hci/src/hci_layer.cc
+++ b/hci/src/hci_layer.cc
@@ -80,7 +80,7 @@ typedef struct {
// Using a define here, because it can be stringified for the property lookup
// Default timeout should be less than BLE_START_TIMEOUT and
// having less than 3 sec would hold the wakelock for init
-#define DEFAULT_STARTUP_TIMEOUT_MS 2900
+#define DEFAULT_STARTUP_TIMEOUT_MS 8000
#define STRING_VALUE_OF(x) #x

// Abort if there is no response to an HCI command.
--
2.25.1

0 comments on commit 3f23031

Please sign in to comment.