# Bluetooth audio on embedded hardware

I would really like the bluetooth-alsa project to get far enough along to really shine on embedded platforms. gumstix is the perfect little device for working this out.

### Completed items

- Modify btsco to build in a cross-compile buildroot environment (seems to have broken again in 2.6.14 buildroot)
- Tweak build so kernel module snd-hwdep-new gets built (need to make sure it gets installed automatically)
- Figure out hcid.conf settings and required modules for audio
- Fix timing problem in a2play--setitimer and rtc/pthreads timers
- Implemented unrolled and fixed-point a2dp encoder and fixed-point decoder
- Implemented 32-bit fixed point codec, made it the default fixed point, moving it into its own independent library

### Status

- Stereo A2DP transmission (.au file) with a2play: audio breaks up occasionally but comes back (using -n flag)
- Live stereo transmission from line-in: occasional bursts of static (probably endian problems again)
- Stereo reception with a2recv: cpu is working hard and audio is working using subbands=4,blocks=4,bitpool=12 (should work with any settings now that decoder is in fixed-point)
- SCO (voice-quality audio) with btsco: gumstix connects to bluetooth headset and responds to headset controls but audio is not going through
- Some basic AVRCP code; able to receive commands in a separate process

### To-do

- fix btsco.mk for 2.6.14+ buildroot
- Squash the last remaining quality problems with fixed point encoding (high frequencies are distorted) and retire floating point :)
- Set up AVRCP to control the stream
- Find out if future gumstix boards could have PCM pins from infineon connected to xscale (yes! confirmed!)
- Find out if SCO can be mapped to HCI as it can on CSR (maybe; see bluez-devel topic "SCO over UART")
- Try connecting a CSR bluetooth chip to see if audio works better (see next section)

### Bluetooth 1.1 CSR Module

The avantwave class 1 module is here. The specs are here and the specific model is btr140-h4-921k. Now I need to connect it up. I'm going to get access to hirose pins through the tweener vias (tweener also has a 3.3v converter which might be usable when I try a class 2 module) hciattach times out complaining about no connection. I have a newer module so I'm likely to spend additional effort getting it to work.

BTR140 | hirose | pxa | Description
--- | --- | --- | ---
1 | - |  | attached an mmcx post here for an external antenna
5 | 14 | gpio35 | steal GPIO from ffuart for btr140 active high reset
7 | 32 | gpio50 | module uart rts->hwcts (asserted by module)
8 | 34 | gpio51 | module uart cts<-hwrts (asserted by gumstix)
9 | 33 | gpio49 | module uart tx->hwrxd (asserted by module)
10 | 35 | gpio48 | module uart rx<-hwtxd (asserted by gumstix)
15 | - |  | 1.8v using a voltage regulator (digikey MCP1700-1802E/TO-ND or NJM2845DL118TE1CT-ND) for a max 161mA
6,16 | 30 |  | 3.3v using voltage regulator for max 161mA
17 | 1 |  | Ground
11 | 3.3v |  | synchronous serial (active low) do we use synchronous??
18 |  |  | pcm clock
24 |  |  | gnd (dual boot fn)
25 |  |  | pcm out
26 |  |  | pcm in
27 |  |  | pcm sync
42 | - |  | rf ground (also surrounds pin 1)

### Links

- Source files
- bluetooth-alsa project

### Notes

PSKEY_HOST_INTERFACE values are 1 (BCSP), 2 (USB), 3 (H4) so I thought we need 3. In the end it was unnecessary to change this.

PSKEY_INITIAL_BOOTMODE (x3cd) should be 4 for HCI H4. It's shipped set to 3 for USB.

PSKEY_UART_BAUDRATE (x1be) should be x1d8 for 115k or xebf for 921k. The default was 115k so I left it alone.

It seems that PSKEY_HOSTIO_MAP_SCO_PCM (x1ab) should be 0, equivalent to the old "pskey mapsco 0" command. There is no x1ab key and `hciconfig hci0 revision` indicates SCO mapping: HCI so HCI must be the default routing.