|
| 1 | +# Bluetooth Audio Offload & Transparent DSP Codec Modules (`bt_codec`) |
| 2 | + |
| 3 | +> **Runs in:** Application — under userspace configs (e.g. PTL/WCL with `CONFIG_SOF_USERSPACE_LL`), |
| 4 | +> these IPC4 processing modules run in MMU-isolated **user** threads. See |
| 5 | +> [User/kernel split](../../include/sof/userspace/README.md). |
| 6 | +
|
| 7 | +This directory implements Sound Open Firmware (SOF) DSP audio encoder/decoder modules for |
| 8 | +Bluetooth **Transparent Mode (`Coding_Format = 0x03`)** over the dedicated Bluetooth SSP audio link |
| 9 | +(`SSP2-BT`, HCI `Data_Path_ID = 0x01`, ALSA `Bluetooth` PCM `hw:0,20`). |
| 10 | + |
| 11 | +Together with SOF's `SSP2-BT` passthrough topologies, SOF supports **12 Bluetooth audio offload |
| 12 | +protocols** across two architectural modes: |
| 13 | + |
| 14 | +1. **BT Controller Hardware Offload (`BT_TRANSP_CODEC="none"`)**: |
| 15 | + The SOF topology connects `host-copier` directly to `dai-copier.SSP` (`SSP2-BT`), and the |
| 16 | + Bluetooth controller performs over-the-air audio encoding/decoding in hardware (`A2DP SBC`, |
| 17 | + `A2DP AAC`, `eSCO mSBC`, `eSCO CVSD`, `eSCO G.711 u-law`, `eSCO G.711 A-law`, `eSCO Transparent` |
| 18 | + raw PCM, and `LE Audio CIS LC3`). |
| 19 | +2. **SOF DSP Transparent Codec Offload (`BT_TRANSP_CODEC="lc3" | "msbc" | "g722" | "sb4"`)**: |
| 20 | + The Bluetooth controller runs an unencoded eSCO **Transparent (`0x03`)** air link over `SSP2-BT` |
| 21 | + (`8 kHz` `S16_LE`), while the SOF DSP runs wideband (`16 kHz`) or narrowband (`8 kHz`) mono audio |
| 22 | + compression (`S16_LE` / `S32_LE`) on playback and decompression (`S16_LE`) on capture inside |
| 23 | + `bt_codec`. |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## Architecture & Data Flow |
| 28 | + |
| 29 | +```mermaid |
| 30 | +flowchart LR |
| 31 | + subgraph Host["Linux Host (ALSA + Bluetooth)"] |
| 32 | + ALSA["aplay / arecord\n(hw:0,20 / hw:0,36, 8/16 kHz)"] |
| 33 | + BTSock["BT Socket (SCO / ISO / L2CAP)\nsetsockopt(BT_CODEC, path=0x01)"] |
| 34 | + end |
| 35 | +
|
| 36 | + subgraph DSP["SOF DSP (SSP2-BT Pipelines)"] |
| 37 | + HC_PB["host-copier.20/36.playback"] |
| 38 | + ENC["bt_lc3 / bt_msbc /\nbt_g722 / bt_sb4\n(Encode 8/16 kHz -> 60B pkt)"] |
| 39 | + DC_PB["dai-copier.SSP.BT.playback"] |
| 40 | +
|
| 41 | + DC_CP["dai-copier.SSP.BT.capture"] |
| 42 | + DEC["bt_lc3 / bt_msbc /\nbt_g722 / bt_sb4\n(Decode 60B pkt -> 8/16 kHz)"] |
| 43 | + HC_CP["host-copier.20.capture"] |
| 44 | + end |
| 45 | +
|
| 46 | + subgraph BTC["Bluetooth Controller"] |
| 47 | + SSP["SSP2 TDM Interface\n(Data_Path_ID = 0x01)"] |
| 48 | + RF["BR/EDR eSCO / ACL / LE CIS\nOver-the-Air Radio"] |
| 49 | + end |
| 50 | +
|
| 51 | + ALSA -->|Playback PCM| HC_PB --> ENC --> DC_PB --> SSP --> RF |
| 52 | + RF --> SSP --> DC_CP --> DEC --> HC_CP -->|Capture PCM| ALSA |
| 53 | + BTSock -.->|HCI 0x0c83 + 0x043d/0x206e/0xfc1e| BTC |
| 54 | +``` |
| 55 | + |
| 56 | +### Self-Synchronizing 60-Byte Transparent Packet Framing |
| 57 | + |
| 58 | +Over an `8 kHz` `S16_LE` eSCO `Transparent (0x03)` link, `7.5 ms` equals `60` samples (`60` bytes |
| 59 | +when carrying 1 air byte in the upper 8 bits of each 16-bit TDM sample). Each SOF DSP codec encodes |
| 60 | +`120` wideband (`16 kHz`) or `60` narrowband (`8 kHz`) PCM samples per `7.5 ms` frame into a |
| 61 | +self-synchronizing `60`-byte packet so DSP-to-DSP links achieve deterministic frame lock even across |
| 62 | +arbitrary mid-stream air byte offsets: |
| 63 | + |
| 64 | +| Module | UUID | Algorithm | Host PCM Format | Compressed Payload (per 7.5 ms) | SSP Link Format | |
| 65 | +|---|---|---|---|---|---| |
| 66 | +| `bt_lc3` | `4c433301-b700-4a10-8000010203040501` | Zephyr `liblc3` (60.8 kbps, 7.5 ms) | `8 / 16 kHz` 1ch `S16_LE` / `S32_LE` | `57` bytes (`456` bits) + sync + CRC-8 | `8 kHz` 1ch `S16_LE` | |
| 67 | +| `bt_msbc` | `4d534243-b700-4a10-8000010203040502` | Bluetooth SIG HFP v1.8 / A2DP v1.3 `mSBC` (`bitpool=26`, H2 header) | `8 / 16 kHz` 1ch `S16_LE` / `S32_LE` | `2B` H2 + `57B` mSBC + `0x00` pad | `8 kHz` 1ch `S16_LE` | |
| 68 | +| `bt_g722` | `47373232-b700-4a10-8000010203040503` | ITU-T Rec. G.722 Mode 2 (56 kbps 2-band 24-tap QMF SB-ADPCM) | `8 / 16 kHz` 1ch `S16_LE` / `S32_LE` | `420` bits (`53B`) + sync + CRC-8 | `8 kHz` 1ch `S16_LE` | |
| 69 | +| `bt_sb4` | `53423401-b700-4a10-8000010203040504` | Experimental 4-band tree-QMF subband ADPCM (`6/4/3/2`-bit) | `8 / 16 kHz` 1ch `S16_LE` / `S32_LE` | `450` bits (`57B`) + sync + CRC-8 | `8 kHz` 1ch `S16_LE` | |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## Build & Topology Configuration |
| 74 | + |
| 75 | +### 1. Firmware Build (`Kconfig`) |
| 76 | + |
| 77 | +`CONFIG_COMP_BT_CODEC=m` builds `bt_codec` as a loadable LLEXT module (`bt_codec.llext` in |
| 78 | +`openmodules`, enabled on ACE 3.0 in `intel_adsp_ace30_ptl.conf` and |
| 79 | +`intel_adsp_ace30_wcl.conf`; `=y` is also supported for built-in firmware). Ensure `west update` |
| 80 | +has fetched `modules/lib/liblc3`: |
| 81 | + |
| 82 | +```bash |
| 83 | +west update liblc3 |
| 84 | +./sof/scripts/xtensa-build-zephyr.py -o sof/app/llext_relocatable.conf -p ptl |
| 85 | +./sof/scripts/xtensa-build-zephyr.py -o sof/app/llext_relocatable.conf -p wcl |
| 86 | +``` |
| 87 | + |
| 88 | +### 2. Development Topologies (`tools/topology/topology2`) |
| 89 | + |
| 90 | +Build the topologies (BT offload and Transparent codec variants are emitted under |
| 91 | +`build-tools/topology/topology2/target/development/`): |
| 92 | + |
| 93 | +```bash |
| 94 | +cmake -S sof/tools -B sof/build-tools |
| 95 | +cmake --build sof/build-tools --target topologies2 -j$(nproc) |
| 96 | +``` |
| 97 | + |
| 98 | +Generated development Bluetooth topologies (`PCM 20: Bluetooth` duplex low-latency at `hw:0,20`, |
| 99 | +plus `PCM 36: Deepbuffer Bluetooth` playback at `hw:0,36` with a `100 ms` L2 SRAM DMA buffer and |
| 100 | +`D0i3` streaming compatibility): |
| 101 | +- **BT Controller Hardware Offload (`BT_TRANSP_CODEC="none"`, `BT_DEEP_BUFFER="true"`)**: |
| 102 | + - SoundWire RT722 (PTL / WCL): `sof-{ptl,wcl}-rt722-4ch-bt.tplg`, `sof-{ptl,wcl}-ssp2-bt-id10.tplg` |
| 103 | + - HDA Generic (MTL / ARL / PTL): `sof-hda-generic-ace1-bt.tplg`, `sof-hda-generic-ace3-bt.tplg`, `sof-hda-generic-ace3-{2ch,4ch}-bt.tplg` |
| 104 | +- **SOF DSP Transparent Codec Feature Topologies (`c` in `lc3`, `msbc`, `g722`, `sb4`, `BT_DEEP_BUFFER="true"`)**: |
| 105 | + - SoundWire RT722 (PTL / WCL): `sof-{ptl,wcl}-rt722-4ch-bt-${c}.tplg` |
| 106 | + - Standalone SSP2-BT (PTL / WCL): `sof-{ptl,wcl}-ssp2-bt-id10-${c}.tplg` |
| 107 | + - HDA Generic (PTL): `sof-hda-generic-ace3-bt-${c}.tplg` |
| 108 | + |
| 109 | +### 3. Linux Kernel Driver Prerequisites & Topology Selection |
| 110 | + |
| 111 | +Because these `-bt` / `-bt-${c}` topologies are staged under `development/` until feature-topology |
| 112 | +and kernel auto-selection support lands, copy the desired `.tplg` file into |
| 113 | +`/lib/firmware/intel/sof-ipc4-tplg/` and select it explicitly via the `snd_sof` `tplg_filename` |
| 114 | +module parameter so kernel logs record the exact loaded topology: |
| 115 | + |
| 116 | +```ini |
| 117 | +# /etc/modprobe.d/sof-bt.conf |
| 118 | +options snd_sof tplg_filename=sof-hda-generic-ace3-bt-lc3.tplg |
| 119 | +# On HDA platforms (sof-hda-dsp), also enable the SSP2-BT machine driver DAI link (bit 2 = SSP2): |
| 120 | +options snd_sof_intel_hda_generic bt_link_mask=0x4 |
| 121 | +``` |
| 122 | + |
| 123 | +On SoundWire RT722 platforms (`sof_sdw`), set `tplg_filename=sof-wcl-rt722-4ch-bt-lc3.tplg` |
| 124 | +(or the desired codec suffix). |
| 125 | + |
| 126 | +Verify that `dmesg` shows the selected topology and ALSA exposes `card 0, device 20: Bluetooth (*)` |
| 127 | +and `device 36: Deepbuffer Bluetooth (*)` after loading SOF: |
| 128 | + |
| 129 | +```bash |
| 130 | +dmesg | grep "loading topology" |
| 131 | +aplay -l | grep -i bluetooth |
| 132 | +``` |
| 133 | + |
| 134 | +--- |
| 135 | + |
| 136 | +## Hardware Testing Guide |
| 137 | + |
| 138 | +> **Important (`codec_provider` SSP Clocking):** |
| 139 | +> On Intel Bluetooth controllers, `SSP2-BT` (`BCLK`/`FSYNC`) is driven by the Bluetooth controller |
| 140 | +> (`codec_provider`) **only while an offloaded SCO, ISO, or A2DP connection is active**. Always |
| 141 | +> open the Bluetooth socket *before* (or concurrently with) `aplay`/`arecord` and keep the socket |
| 142 | +> open until `aplay`/`arecord` finishes. |
| 143 | +
|
| 144 | +### 1. Initialize the Bluetooth Controller (Both DUTs) |
| 145 | + |
| 146 | +Stop `bluetoothd` so raw test sockets own `PSM 0x0019` / SCO / ISO directly, and enable BR/EDR, LE, |
| 147 | +Secure Simple Pairing (SSP), and Wideband Speech (WBS): |
| 148 | + |
| 149 | +```bash |
| 150 | +systemctl stop bluetooth |
| 151 | +btmgmt --index 0 power off |
| 152 | +btmgmt --index 0 bredr on |
| 153 | +btmgmt --index 0 le on |
| 154 | +btmgmt --index 0 ssp on |
| 155 | +btmgmt --index 0 bondable on |
| 156 | +btmgmt --index 0 wbs on |
| 157 | +btmgmt --index 0 connectable on |
| 158 | +btmgmt --index 0 discov on |
| 159 | +btmgmt --index 0 power on |
| 160 | +hciconfig hci0 piscan |
| 161 | +``` |
| 162 | + |
| 163 | +### 2. Minimal `BT_CODEC` Offload Socket Helpers |
| 164 | + |
| 165 | +Linux configures Bluetooth SSP offload via `setsockopt(fd, SOL_BLUETOOTH, BT_CODEC, ...)` |
| 166 | +(`SOL_BLUETOOTH = 274`, `BT_CODEC = 19`) using `struct bt_codecs`: |
| 167 | + |
| 168 | +```c |
| 169 | +/* Minimal eSCO SSP offload helper: gcc -O2 sco_offload.c -o sco_offload */ |
| 170 | +#include <stdio.h> |
| 171 | +#include <stdlib.h> |
| 172 | +#include <stdint.h> |
| 173 | +#include <unistd.h> |
| 174 | +#include <poll.h> |
| 175 | +#include <sys/socket.h> |
| 176 | + |
| 177 | +#define BTPROTO_SCO 2 |
| 178 | +#define SOL_BLUETOOTH 274 |
| 179 | +#define BT_DEFER_SETUP 7 |
| 180 | +#define BT_CODEC 19 |
| 181 | + |
| 182 | +typedef struct { uint8_t b[6]; } __attribute__((packed)) bdaddr_t; |
| 183 | +struct sockaddr_sco { sa_family_t sco_family; bdaddr_t sco_bdaddr; }; |
| 184 | +struct bt_codec { |
| 185 | + uint8_t id; uint16_t cid; uint16_t vid; uint8_t data_path; uint8_t num_caps; |
| 186 | +} __attribute__((packed)); |
| 187 | +struct bt_codecs { |
| 188 | + uint8_t num_codecs; struct bt_codec codecs[1]; |
| 189 | +} __attribute__((packed)); |
| 190 | + |
| 191 | +static void parse_bdaddr(const char *s, bdaddr_t *ba) { |
| 192 | + unsigned int b[6]; |
| 193 | + sscanf(s, "%x:%x:%x:%x:%x:%x", &b[5], &b[4], &b[3], &b[2], &b[1], &b[0]); |
| 194 | + for (int i = 0; i < 6; i++) ba->b[i] = (uint8_t)b[i]; |
| 195 | +} |
| 196 | + |
| 197 | +/* Usage: |
| 198 | + * Server: ./sco_offload listen <codec_id> <data_path> <hold_sec> |
| 199 | + * Client: ./sco_offload connect <PEER_BDADDR> <codec_id> <data_path> <hold_sec> |
| 200 | + */ |
| 201 | +int main(int argc, char **argv) { |
| 202 | + int is_srv = (argc > 1 && argv[1][0] == 'l'); |
| 203 | + int argi = is_srv ? 2 : 3; |
| 204 | + uint8_t codec_id = strtoul(argv[argi], NULL, 0); |
| 205 | + uint8_t path = strtoul(argv[argi + 1], NULL, 0); |
| 206 | + int hold = atoi(argv[argi + 2]); |
| 207 | + |
| 208 | + int sk = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO); |
| 209 | + struct sockaddr_sco loc = { .sco_family = AF_BLUETOOTH }; |
| 210 | + bind(sk, (struct sockaddr *)&loc, sizeof(loc)); |
| 211 | + |
| 212 | + struct bt_codecs cs = { |
| 213 | + .num_codecs = 1, |
| 214 | + .codecs = {{ .id = codec_id, .data_path = path }}, |
| 215 | + }; |
| 216 | + if (setsockopt(sk, SOL_BLUETOOTH, BT_CODEC, &cs, sizeof(cs)) < 0) { |
| 217 | + perror("setsockopt(BT_CODEC)"); |
| 218 | + return 1; |
| 219 | + } |
| 220 | + |
| 221 | + if (is_srv) { |
| 222 | + int defer = 1; |
| 223 | + setsockopt(sk, SOL_BLUETOOTH, BT_DEFER_SETUP, &defer, sizeof(defer)); |
| 224 | + listen(sk, 1); |
| 225 | + int csk = accept(sk, NULL, NULL); |
| 226 | + if (csk < 0) { perror("accept"); return 1; } |
| 227 | + char ch; |
| 228 | + recv(csk, &ch, 1, 0); |
| 229 | + struct pollfd pfd = { .fd = csk, .events = POLLOUT }; |
| 230 | + poll(&pfd, 1, 5000); |
| 231 | + puts("SCO SRV connected!"); |
| 232 | + fflush(stdout); |
| 233 | + sleep(hold); |
| 234 | + close(csk); |
| 235 | + } else { |
| 236 | + struct sockaddr_sco rem = { .sco_family = AF_BLUETOOTH }; |
| 237 | + parse_bdaddr(argv[2], &rem.sco_bdaddr); |
| 238 | + if (connect(sk, (struct sockaddr *)&rem, sizeof(rem)) < 0) { |
| 239 | + perror("connect"); |
| 240 | + return 1; |
| 241 | + } |
| 242 | + puts("SCO CLI connected!"); |
| 243 | + fflush(stdout); |
| 244 | + sleep(hold); |
| 245 | + } |
| 246 | + close(sk); |
| 247 | + return 0; |
| 248 | +} |
| 249 | +``` |
| 250 | +
|
| 251 | +### 3. Testing BT Controller Hardware Offload Protocols |
| 252 | +
|
| 253 | +Ensure a passthrough `-bt.tplg` topology is active (e.g. `sof-wcl-rt722-4ch-bt.tplg` or |
| 254 | +`sof-hda-generic-ace3-bt.tplg`). |
| 255 | +
|
| 256 | +#### A. HFP / eSCO Controller Offload (`mSBC`, `CVSD`, `u-law`, `A-law`, `Transparent`) |
| 257 | +
|
| 258 | +| Protocol | `<codec_id>` | `<data_path>` | ALSA PCM Format (`hw:0,20`) | |
| 259 | +|---|---|---|---| |
| 260 | +| `mSBC` (Wideband Speech) | `0x05` | `0x01` | `-r 16000 -c 1 -f S16_LE` | |
| 261 | +| `CVSD` (Narrowband) | `0x02` | `0x01` | `-r 8000 -c 1 -f S16_LE` | |
| 262 | +| `G.711 u-law` | `0x00` | `0x01` | `-r 8000 -c 1 -f S16_LE` | |
| 263 | +| `G.711 A-law` | `0x01` | `0x01` | `-r 8000 -c 1 -f S16_LE` | |
| 264 | +| `Transparent` (Raw PCM) | `0x03` | `0x01` | `-r 8000 -c 1 -f S16_LE` | |
| 265 | +
|
| 266 | +```bash |
| 267 | +# DUT A (Responder, BD_ADDR AA:BB:CC:DD:EE:FF): |
| 268 | +./sco_offload listen 0x05 0x01 10 & |
| 269 | +
|
| 270 | +# DUT B (Initiator): connect eSCO mSBC (0x05) over SSP2-BT (0x01) |
| 271 | +./sco_offload connect AA:BB:CC:DD:EE:FF 0x05 0x01 10 & |
| 272 | +
|
| 273 | +# Once connected, stream & capture full-duplex audio simultaneously on both DUTs: |
| 274 | +# On DUT B: |
| 275 | +aplay -D hw:0,20 -r 16000 -c 1 -f S16_LE -d 4 tone_1000hz_16k.wav & |
| 276 | +arecord -D hw:0,20 -r 16000 -c 1 -f S16_LE -d 4 rx_dut_b.wav & |
| 277 | +
|
| 278 | +# On DUT A: |
| 279 | +aplay -D hw:0,20 -r 16000 -c 1 -f S16_LE -d 4 tone_500hz_16k.wav & |
| 280 | +arecord -D hw:0,20 -r 16000 -c 1 -f S16_LE -d 4 rx_dut_a.wav & |
| 281 | +wait |
| 282 | +``` |
| 283 | + |
| 284 | +#### B. A2DP Controller Offload (`SBC 0x00` & `AAC 0x02`, 48 kHz Stereo) |
| 285 | + |
| 286 | +On `BTPROTO_L2CAP` media sockets (`PSM 0x0019`), `setsockopt(SOL_BLUETOOTH, BT_CODEC)` with |
| 287 | +`data_path = 0x01` and AVDTP Media Codec Capabilities (`id = 0x00` for SBC or `id = 0x02` for AAC) |
| 288 | +triggers Microsoft vendor extension (`0xfc1e`) subcommands `0x08` (`Avdtp_Open`) and `0x09` |
| 289 | +(`Avdtp_Start`), encoding `48 kHz` stereo PCM from `hw:0,20`: |
| 290 | + |
| 291 | +```bash |
| 292 | +# On Transmitter DUT (Low-Latency FE hw:0,20 or Deepbuffer FE hw:0,36): |
| 293 | +aplay -D hw:0,20 -r 48000 -c 2 -f S16_LE -d 5 tone_1000hz_48k_2ch.wav & |
| 294 | +sleep 0.3 |
| 295 | +./a2dp_tx AA:BB:CC:DD:EE:FF sbc 4 # or 'aac' |
| 296 | +wait |
| 297 | +``` |
| 298 | + |
| 299 | +#### D. Deepbuffer Playback & Concurrent Mixing (`hw:0,36`) |
| 300 | + |
| 301 | +When `BT_DEEP_BUFFER=true` is enabled in topology, ALSA exposes `device 36: Deepbuffer Bluetooth` |
| 302 | +(`hw:0,36`) alongside `device 20: Bluetooth` (`hw:0,20`). `hw:0,36` allocates a `100 ms` L2 SRAM |
| 303 | +host-copier buffer (`lp_mode = 1`, `playback_compatible_d0i3 = true`), enforces ALSA period times |
| 304 | +`>= 110 ms`, allows PCI `D0i3` streaming when no low-latency stream is active, and mixes in `S32_LE` |
| 305 | +with `hw:0,20`: |
| 306 | + |
| 307 | +```bash |
| 308 | +# Deepbuffer A2DP playback (>= 110 ms period, D0i3 streaming eligible after 5 s): |
| 309 | +aplay -D hw:0,36 --period-time=250000 --buffer-time=1000000 \ |
| 310 | + -r 48000 -c 2 -f S16_LE -d 10 tone_1000hz_48k_2ch.wav & |
| 311 | +sleep 0.3 |
| 312 | +./a2dp_tx AA:BB:CC:DD:EE:FF sbc 9 |
| 313 | +wait |
| 314 | + |
| 315 | +# Concurrent stream mixing (Deepbuffer media on hw:0,36 + Low-Latency alert on hw:0,20): |
| 316 | +aplay -D hw:0,36 --period-time=125000 --buffer-time=500000 \ |
| 317 | + -r 48000 -c 2 -f S16_LE -d 6 tone_440hz_48k_2ch.wav & |
| 318 | +aplay -D hw:0,20 -r 48000 -c 2 -f S16_LE -d 6 tone_1000hz_48k_2ch.wav & |
| 319 | +sleep 0.3 |
| 320 | +./a2dp_tx AA:BB:CC:DD:EE:FF sbc 5 |
| 321 | +wait |
| 322 | +``` |
| 323 | + |
| 324 | +#### C. LE Audio CIS Controller Offload (`LC3 0x06`, 16 kHz Mono) |
| 325 | + |
| 326 | +On the CIS Peripheral, enable connectable LE Extended Advertising via HCI (`0x08 0x0036` and |
| 327 | +`0x08 0x0039`), listen on a `BTPROTO_ISO` socket configured with `BT_CODEC` (`id = 0x06`, |
| 328 | +`data_path = 0x01`), and connect from the CIS Central (`BT_ISO_QOS`: `interval = 10000` us, |
| 329 | +`sdu = 40` octets): |
| 330 | + |
| 331 | +```bash |
| 332 | +# On CIS Peripheral (DUT A): |
| 333 | +hcitool -i hci0 cmd 0x08 0x0036 \ |
| 334 | + 01 13 00 20 00 00 40 00 00 07 00 00 00 00 00 00 00 00 00 7f 01 00 01 00 00 |
| 335 | +hcitool -i hci0 cmd 0x08 0x0039 01 01 01 00 00 00 |
| 336 | +./iso_srv2 0x06 0x01 12 & |
| 337 | + |
| 338 | +# On CIS Central (DUT B): |
| 339 | +./iso_cli2 AA:BB:CC:DD:EE:FF 0x06 0x01 12 & |
| 340 | + |
| 341 | +# Once CIS is established, run full-duplex 16 kHz PCM on hw:0,20 on both DUTs: |
| 342 | +aplay -D hw:0,20 -r 16000 -c 1 -f S16_LE -d 4 tone_1000hz_16k.wav & |
| 343 | +arecord -D hw:0,20 -r 16000 -c 1 -f S16_LE -d 4 rx_iso_lc3.wav & |
| 344 | +wait |
| 345 | +``` |
| 346 | + |
| 347 | +--- |
| 348 | + |
| 349 | +### 4. Testing SOF DSP Transparent Codec Offload (`bt_lc3`, `bt_msbc`, `bt_g722`, `bt_sb4`) |
| 350 | + |
| 351 | +To test DSP-to-DSP encoding and decoding on SOF, load the matching `*-bt-${c}.tplg` feature |
| 352 | +topology (`c` in `lc3`, `msbc`, `g722`, `sb4`) on both DUTs and establish an eSCO **Transparent |
| 353 | +(`0x03`)** connection with `data_path = 0x01`: |
| 354 | + |
| 355 | +```bash |
| 356 | +CODEC=lc3 # lc3 | msbc | g722 | sb4 |
| 357 | + |
| 358 | +# 1. Reload SOF using tplg_filename so kernel logs clearly identify the test topology |
| 359 | +# (unload snd_sof along with dependent PCI/HDA/SoundWire modules, then reload): |
| 360 | +# Example on Wildcat Lake RT722 (DUT A): |
| 361 | +modprobe -r snd_sof_pci_intel_ptl snd_soc_sof_sdw snd_sof_probes \ |
| 362 | + snd_sof_pci_intel_lnl snd_sof_pci_intel_mtl snd_sof_intel_hda_generic \ |
| 363 | + soundwire_intel snd_sof_intel_hda_sdw_bpt snd_sof_intel_hda_common \ |
| 364 | + snd_sof_intel_hda snd_sof_pci snd_sof |
| 365 | +modprobe snd_sof tplg_filename=sof-wcl-rt722-4ch-bt-${CODEC}.tplg |
| 366 | +modprobe snd_sof_pci_intel_ptl |
| 367 | + |
| 368 | +# Example on Panther Lake HDA (DUT B): |
| 369 | +modprobe -r snd_sof_pci_intel_ptl snd_soc_skl_hda_dsp snd_sof_probes \ |
| 370 | + snd_sof_pci_intel_lnl snd_sof_pci_intel_mtl snd_sof_intel_hda_generic \ |
| 371 | + soundwire_intel snd_sof_intel_hda_sdw_bpt snd_sof_intel_hda_common \ |
| 372 | + snd_sof_intel_hda snd_sof_pci snd_sof |
| 373 | +modprobe snd_sof tplg_filename=sof-hda-generic-ace3-bt-${CODEC}.tplg |
| 374 | +modprobe snd_sof_pci_intel_ptl |
| 375 | +# Note: alternatively set `options snd_sof tplg_filename=...` in `/etc/modprobe.d/sof-bt.conf` |
| 376 | +# and reboot, or if a test setup cannot alter module parameters, back up the default `.tplg` |
| 377 | +# file first and temporarily rename/copy the development file for testing, restoring |
| 378 | +# the original afterward. |
| 379 | + |
| 380 | +# 2. Open eSCO Transparent (0x03) link over SSP2-BT (0x01) |
| 381 | +# DUT A: |
| 382 | +./sco_offload listen 0x03 0x01 10 & |
| 383 | +# DUT B: |
| 384 | +./sco_offload connect AA:BB:CC:DD:EE:FF 0x03 0x01 10 & |
| 385 | + |
| 386 | +# 3. Stream & record 16 kHz wideband (or 8 kHz narrowband) PCM on hw:0,20 / hw:0,36 |
| 387 | +# DUT B (transmits 1000 Hz, captures 500 Hz): |
| 388 | +aplay -D hw:0,20 -r 16000 -c 1 -f S16_LE -d 4 tone_1000hz_16k.wav & |
| 389 | +arecord -D hw:0,20 -r 16000 -c 1 -f S16_LE -d 4 rx_dut_b_${CODEC}.wav & |
| 390 | + |
| 391 | +# DUT A (transmits 500 Hz, captures 1000 Hz): |
| 392 | +aplay -D hw:0,20 -r 16000 -c 1 -f S16_LE -d 4 tone_500hz_16k.wav & |
| 393 | +arecord -D hw:0,20 -r 16000 -c 1 -f S16_LE -d 4 rx_dut_a_${CODEC}.wav & |
| 394 | +wait |
| 395 | +``` |
| 396 | + |
| 397 | +You can test with any standard `8 kHz` or `16 kHz` mono `S16_LE` WAV (or `speaker-test -D hw:0,20 -r 16000 -c 1 -F S16_LE -t sine -f 1000`) and inspect the recorded `rx_dut_*.wav` files locally. |
0 commit comments