Bluetooth Audio from a Lenovo X220 running FreeBSD 13.0-CURRENT
The FreeBSD Handbook Bluetooth chapter is, as usual, great but I needed to do a bit more (or perhaps in a more specific way) to get audio from the Broadcom Bluetooth chip in my Lenovo X220 to the Soundblaster Roar SR20 that lives in my kitchen.
Load the user character device driver
cuse and all the netgraph bluetooth modules, this is better done earlier to avoid the annoying (and possibly significant)
WARNING: attempt to domain_add(xyz) after domainfinalize() errors at startup.
cuse_load="YES" ng_ubt_load="YES" # for most USB bluetooth, for others, refer to the handbook ng_hci_load="YES" ng_l2cap_load="YES" ng_btsocket_load="YES" ng_socket_load="YES" ng_bluetooth_load="YES"
Assuming your bluetooth device name is
cp /etc/defaults/bluetooth.device.conf /etc/bluetooth/ubt0.conf
In my case I set
local_name to the hostname and also set
Start the bluetooth stack
service hcsecd start service bluetooth start ubt0 # if this fails, do it again
Pair with the device for the first time
If you're going to use encryption, set the audio device to pairing mode first.
# bluetooth-config scan Scanning for new Bluetooth devices (Attempt 1 of 5) ... done. Found 1 new bluetooth device (now scanning for names): [ 1] 00:02:3c:xx:xx:xx "SB ROAR SR20A" (SB_ROAR_SR20A) Select device to pair with [1, or 0 to rescan]: 1 Writing pairing information description block to /etc/bluetooth/hcsecd.conf. (To get PIN, put device in pairing mode first. ) Enter PIN [nopin]: 0000 Stopping hcsecd. Waiting for PIDS: 58789. Starting hcsecd.
bluetooth-config will create an entry in
/etc/bluetooth/hosts mapping the bluetooth device's MAC address to a short name. In this case, the shortname for my device is
Create the virtual OSS device
This step creates the virtual device /dev/dsp, the device
/dev/bluetooth/SB_ROAR_SR20A won't actually exist in the dev filesystem so don't go looking for it. Also you can use the shortname defined in
/etc/bluetooth/hosts or the full MAC address.
virtual_oss -C 2 -c 2 -r 48000 -b 16 -s 768 -R /dev/null -P /dev/bluetooth/SB_ROAR_SR20A -d dsp
After this on subsequent reboots I only needed to re-run the
virtual_oss command to reconnect.