diff --git a/SPECS/69-btattach-bcm.rules b/SPECS/69-btattach-bcm.rules new file mode 100644 index 0000000..dfe8d1e --- /dev/null +++ b/SPECS/69-btattach-bcm.rules @@ -0,0 +1,33 @@ +# Some devices have a bluetooth HCI connected to an uart, these needs to be +# setup by calling btattach. The systemd btattach-bcm.service takes care of +# this. These udev rules hardware-activate that service when necessary. +# +# For now this only suports ACPI enumerated Broadcom BT HCIs. +# This has been tested on Bay and Cherry Trail devices with both ACPI and +# PCI enumerated UARTs. + +# Note we check for the platform device not for the acpi device, because +# some DSDTs list multiple bluetooth adapters, but only some (or none) +# are enabled. Only enabled adapters get a platform device created. +ACTION!="add", GOTO="btattach_bcm_rules_end" +SUBSYSTEM!="platform", GOTO="btattach_bcm_rules_end" + +KERNEL=="BCM2E1A:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E39:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E3A:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E3D:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E3F:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E40:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E54:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E55:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E64:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E65:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E67:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E71:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E7B:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E7C:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E7E:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E95:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" +KERNEL=="BCM2E96:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service" + +LABEL="btattach_bcm_rules_end" diff --git a/SPECS/bluez.gitignore b/SPECS/bluez.gitignore new file mode 100644 index 0000000..137d2e5 --- /dev/null +++ b/SPECS/bluez.gitignore @@ -0,0 +1,100 @@ +*.o +*.a +*.lo +*.la +*.so +.deps +.libs +.dirstamp +Makefile +Makefile.in +aclocal.m4 +config.guess +config.h +config.h.in +config.log +config.status +config.sub +configure +depcomp +compile +install-sh +libtool +ltmain.sh +missing +stamp-h1 +autom4te.cache + +ylwrap +lexer.c +parser.h +parser.c + +bluez.pc +lib/bluetooth +src/builtin.h +src/bluetoothd +audio/telephony.c +sap/sap.c +scripts/bluetooth.rules +scripts/97-bluetooth.rules +scripts/97-bluetooth-hid2hci.rules + +sbc/sbcdec +sbc/sbcenc +sbc/sbcinfo +sbc/sbctester + +attrib/gatttool +tools/avctrl +tools/avinfo +tools/bccmd +tools/ciptool +tools/dfubabel +tools/dfutool +tools/hciattach +tools/hciconfig +tools/hcieventmask +tools/hcisecfilter +tools/hcitool +tools/hid2hci +tools/rfcomm +tools/l2ping +tools/ppporc +tools/sdptool +cups/bluetooth +test/agent +test/bdaddr +test/hciemu +test/attest +test/hstest +test/avtest +test/l2test +test/rctest +test/scotest +test/gaptest +test/sdptest +test/lmptest +test/ipctest +test/btiotest +test/test-textfile +test/uuidtest +test/mpris-player +compat/dund +compat/hidd +compat/pand +unit/test-eir +mgmt/btmgmt +monitor/btmon +emulator/btvirt + +doc/*.bak +doc/*.stamp +doc/bluez.* +doc/bluez-*.txt +doc/*.sgml +doc/version.xml +doc/xml +doc/html +src/bluetoothd.8 +src/bluetooth.service diff --git a/SPECS/btattach-bcm-service.sh b/SPECS/btattach-bcm-service.sh new file mode 100644 index 0000000..c7f8b17 --- /dev/null +++ b/SPECS/btattach-bcm-service.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Simple shell script to wait for the tty for an uart using BT HCI to show up +# and then invoke btattach with the right parameters, this is intended to be +# invoked from a hardware-activated systemd service +# +# For now this only suports ACPI enumerated Broadcom BT HCIs. +# This has been tested on Bay and Cherry Trail devices with both ACPI and +# PCI enumerated UARTs. +# +# Note the kernel bt developers are working on solving this entirely in the +# kernel, so it is not worth the trouble to write something better then this. + +BT_DEV="/sys/bus/platform/devices/$1" +BT_DEV="$(readlink -f $BT_DEV)" +UART_DEV="$(dirname $BT_DEV)" + +# Stupid GPD-pocket has USB BT with id 0000:0000, but still claims to have +# an uart attached bt +if [ "$1" = "BCM2E7E:00" ] && lsusb | grep -q "ID 0000:0000"; then + exit 0 +fi + +while [ ! -d "$UART_DEV/tty" ]; do + sleep .2 +done + +TTY="$(ls $UART_DEV/tty)" + +exec btattach --bredr "/dev/$TTY" -P bcm diff --git a/SPECS/btattach-bcm@.service b/SPECS/btattach-bcm@.service new file mode 100644 index 0000000..1e7c7db --- /dev/null +++ b/SPECS/btattach-bcm@.service @@ -0,0 +1,6 @@ +[Unit] +Description=btattach for Broadcom devices + +[Service] +Type=simple +ExecStart=/usr/libexec/bluetooth/btattach-bcm-service.sh %I