Support us and view this ad

可选:点击以支持我们的网站

免费文章

1. Introduction: The Challenge of LC3 on a Heterogeneous RISC-V Core Porting the BlueZ LE Audio stack to a non-ARM, imported RISC-V SoC presents a unique set of challenges, particularly in the audio data path. While the upper layers of BlueZ (profiles, GATT, BAP) are largely platform-agnostic, the real-time, low-latency requirements of the LC3 codec expose the weaknesses of a new, often unoptimized RISC-V core. The core problem is not just compiling the code, but ensuring that the LC3 encoder can meet the strict timing constraints of the Isochronous Adaptation Layer (ISOAL) and the LE Audio frame scheduling. This article details the integration of the LC3 encoder into the BlueZ stack on a custom RISC-V SoC, focusing on codec configuration, buffer management, and the critical interplay between the audio DSP (if present) and the application core. 2. Core Technical Principle: The LE Audio Frame Pipeline and LC3 Packetization The LE Audio stack defines a rigid pipeline for audio data. The key components are the BAP (Basic Audio Profile), the ISOAL (Isochronous Adaptation Layer), and the Codec (LC3). The timing diagram for a single audio frame (10ms) is as follows: Time (ms): 0 2.5 5.0 7.5 10.0 |------------|------------|------------|------------| Events: Audio In LC3 Enc ISOAL Frag Tx Slot Next Frame (PCM Buffer) (CPU Load) (Packetize) (BLE Radio) The critical path is the LC3 encoder execution. For a 10ms frame at 48kHz, a single channel provides 480 PCM samples. The encoder must compress this into an LC3 frame (typically 240-360 bytes depending on bitrate) within a fraction of the 10ms window. On a RISC-V core without hardware acceleration, this is a significant CPU load. The packet format for an LE Audio BIS (Broadcast Isochronous Stream) or CIS (Connected Isochronous Stream) is defined by the ISOAL. The LC3 frame is encapsulated into an ISOAL PDU. The structure is: ISOAL PDU (for a single SDU): +----------------+----------------+----------------+----------------+ | Access Addr | LLID (2 bits) | NESN/SN (2b) | CI (2 bits) | | (4 bytes) | (0x02=Data) | (Seq. Num) | (More Data) | +----------------+----------------+----------------+----------------+ | ISO Header | SDU Length | LC3 Frame | MIC (if any) | | (2 bytes) | (1-2 bytes) | (N bytes) | (4 bytes) | +----------------+----------------+----------------+----------------+ The SDU Length field is crucial. It tells the receiver how many bytes of LC3 data are in this PDU. The LC3 frame itself is a self-contained bitstream. The encoder must produce a frame that fits within the maximum SDU size negotiated during BAP configuration. For example, a unicast 48kHz stereo stream at 96 kbps per channel requires an SDU size of 120 bytes per channel (96 kbps * 10ms / 8 = 120 bytes). 3. Implementation Walkthrough: LC3 Encoder Integration with BlueZ The integration point is the bt_audio_codec_cfg structure in BlueZ....

继续阅读完整内容

支持我们的网站,请点击查看下方广告

正在加载广告...

Login