Skip to main content
Each audio use case is a graph with subgraphs of a specific type. Each subgraph has one or more functional software blocks (referred to as modules) that perform a specific function.

Customize at PAL level

The Platform Abstraction Layer (PAL) provides higher-level audio-specific APIs to access audio hardware and drivers. Customizing at the PAL level allows you to control stream behavior, device routing, buffer configuration, and platform-specific audio settings.

PipeWire PAL plug-in

The PipeWire PAL plug-in (pw-pal-plugin) bridges PipeWire streams directly to the PAL API. It runs as a PipeWire module and handles all audio routing between PipeWire and the AudioReach hardware stack. The plug-in performs the following operations:
  • Opens and manages PAL streams for playback and capture
  • Configures mixer controls to set up hardware codec devices and stream configurations
  • Invokes PAL APIs to open and start audio sessions
  • Routes audio data between PipeWire buffers and PAL DMA buffers
The following are the components of the PipeWire PAL plug-in:
SourceA node that produces a stream of data (audio/video frames) and exposes output ports. A PipeWire source node:
  • Has no requirement to receive data
  • Pushes data out via output ports
  • Operates on a clock / driver / capture trigger
  • Is usually tied to hardware or software generators
SinkA node that consumes incoming data and exposes input ports. A PipeWire sink node:
  • Receives data via input ports
  • Does not generate its own primary data
  • Usually interacts with hardware playback/output
  • Controls buffering and rendering
The PAL resource manager tracks all active sessions and devices to enable concurrencies. It parses and loads configuration from the following platform XML files:
  • Resource_manager.xml — Device-to-backend mapping and policy making attributes
  • Card-defs.xml — Virtual PCM and compress nodes and their options
  • mixer_paths.xml — Defines all low-level audio routing paths and controls that determine how sound is recorded, processed, and played on the device
  • plugin_manager.xml — Links audio streams, sessions, and devices to their corresponding plugin libraries and functions for runtime audio handling
  • usecaseKvManager.xml — Maps audio streams and devices to DSP processing graphs, deciding how audio is processed internally on the chip
Find the PipeWire PAL plug-in source code at:
Find the PAL source code at:
The following file lists all APIs exposed by the PAL module:

PAL APIs

The following are common PAL APIs. See PalApi.h for a complete description of all APIs.

pal_init

Initializes PAL, parses the related configuration files, and stores them in a local structure for use.
Parameters None Return value
  • 0 on success
  • Error code on failure

pal_deinit

De-initializes PAL and frees up the resources allocated during initialization.
Parameters None Return value None

pal_stream_open

Opens a stream with the specified configuration such as source/sink devices and media configuration. Returns the stream handle upon success.
Parameters Return value
  • 0 on success
  • Error code on failure

pal_stream_start

Starts a stream.
Parameters Return value
  • 0 on success
  • Error code on failure

pal_stream_read

Reads the audio buffer captured from the audio source device.
Parameters Return value
  • Number of bytes read on success
  • Error code on failure

pal_stream_write

Writes the audio buffer for stream rendering over a sink device.
Parameters Return value
  • Number of bytes written on success
  • Error code on failure

pal_stream_stop

Stops a stream.
Parameters Return value
  • 0 on success
  • Error code on failure

pal_stream_close

Closes a stream.
Parameters Return value
  • 0 on success
  • Error code on failure

Configuration files

Configure audio use cases at the PAL level by using the mixer_paths, resourcemanager, and usecasekvmanager XML files. The following table shows the configuration files for each supported platform: QCS6490 configuration files Qualcomm Dragonwing IQ-9075 configuration files Qualcomm Dragonwing IQ-8275 configuration files Talos QCS615 configuration files

Customize mixer paths XML file

Mixer control is a control variable exposed from the ALSA mixer to the user space. It allows the user space to access set and get functions and pass parameters to the ALSA mixer. The platform uses the mixer_paths_<sound-card-name>.xml file as the mixer path. This file is in the /etc/ folder on the target. The following is an example entry for enabling the mono speaker device in the mixer_paths.xml file. When playback triggers and the device selected is a speaker, the following mixer controls run with the help of the audio route helper class:

Customize resource manager XML file

The Resourcemanager.xml file includes all possible devices, use cases, and combinations. It also includes other configurations, module parameters, and global parameters. The following is an example speaker device entry in the resource manager XML file. It has all configurations for the speaker device such as back-end name, channels, sample rate, and bit width:

Customize usecasekvmanager XML file

The Usecasekvmanager.xml file has the GKV details for each use case. PAL uses this XML file to get the KV configuration for each use case and then uses that configuration to get graph information from the acdb files. This file is in the /etc folder on the device. The following is an example of one stream and device graph key vector configuration: Stream KV
Device KV
DevicePP KV

Sync and compile audio components

The audio software uses user space and kernel space modules located in the Linux-enabled audio software directory. The audio user space and kernel module source trees extract to the following path:
Use the devtool Linux utility to get, extract, and build the audio module source code.
Go to the workspace (<workspace>/build-qcom-wayland$) to access the source code trees using devtool.

Sync PipeWire

  1. Extract the source tree:
    The PipeWire source tree extracts to:
  2. Build the source tree:

Sync PAL

  1. Extract the source tree:
    The PAL source tree extracts to:
  2. Build the source tree:

Sync TinyALSA

  1. Extract the source tree:
    The TinyALSA source tree extracts to:
  2. Build the source tree:

Audio module source code locations

If you have full access to the proprietary software shipped with Qualcomm Linux, view the audio module source code at the following locations:

Audio graph terms

Audio graph terms

Graph segments

An audio use case has the following segments. The front-end represents stream and streamPP subgraphs, while the back-end represents the per-stream per-device (PSPD), devicePP, and device subgraphs. Graph segments Once a front-end connects to a back-end using a routing mixer control, the full GKV forms by concatenating the subgraph GKVs and the CKVs assigned using mixer controls. Upon opening the front-end PCM or compress device, AGM invokes GSL APIs with concatenated GKVs and CKVs to set up the graph in SPF and apply calibration. At the same time, AGM opens a kernel PCM device corresponding to the connected back-ends to begin audio peripheral setup.

Sample audio graph

The following figure shows an example audio graph for a playback scenario.
Sample audio graph for playback

Sample audio graph for playback

CONT#1PCM ConverterPCM DecoderWrite SHMEM EPCONT#6Media Format ConverterCONT#2SplitterPP2PP1CONT#8HW EPCONT#7PP6PP5MixerClient PCM DataSGKV: [StreamRx: PCM Low Latency PlaybackInstance: instance 1]SGKV: [StreamRx: PCM Low Latency Playback Device: SpeakerInstance: instance 1]SGKV: [DeviceRx:SpeakerDevicePP rx: Speaker PP]SGKV: [DeviceRx:Speaker] Sample audio graph for playback In this graph:
  1. The stream subgraph has a write shared memory endpoint, PCM decoder, and PCM converter. The client passes PCM samples to write shared memory endpoint.
  2. If conversion is necessary, the PCM converter converts PCM samples to a format supported by the stream-specific postprocessing modules.
  3. Output of the stream subgraph is fed into the stream-device subgraph, which has the media format converter (MFC). MFC converts the stream-subgraph PCM to the device-subgraph PCM format.
  4. After conversion, output of the stream-device subgraph is fed into the device PP subgraph for device-specific postprocessing. A mixer is placed at the beginning of subgraph to mix input streams.
  5. Output of the devicePP subgraph is then fed into the device subgraph, which has a hardware endpoint module such as an I2S driver.
The following is the GKV for this example graph:

Audio graph manager

The audio graph manager (AGM) gives interfaces to allow TinyALSA-based mixer controls and PCM/compress plug-ins to interact and enable audio use cases. AGM runs as part of the PipeWire service that runs in the user space. AGM gives APIs for mixer plug-ins and PCM/compress APIs to set up audio use cases. It maintains many ALSA clients to set up use cases. AGM also manages front-end to back-end connections. The following figure shows the AGM block at a high level.
High-level AGM software block

High-level AGM software block

Kernel spaceUserspaceAGM serviceAGM APIPALSession objectsGSLALSA devicesGraph objectsDevice objects High-level AGM software block AGM objects

AudioReach graph services

The AudioReach™ Signal Processing Framework graph services (ARGS) consists of the graph service layer (GSL), generic packet router (GPR), and acdb management layer (AML). It handles initialization and creation of graphs, and creation of packets for sending series of commands to the SPF. ARGS components

Audio calibration database

acdb is a static database on the Apps processor. It has all tuning/calibration parameters for the LPAI. The *.acdb file format organizes calibration data for various audio modules for various use cases. Edit this file format using QACT (a PC tool) and place it on the device file system in the /etc/acdbdata/ folder. During use case initialization or device switch, the AML queries the acdb database with a specified GKV and pushes the device calibration data to SPF.

AudioReach Engine (ARE)

AudioReach Engine (ARE) runs in the LPAI subsystem and performs audio data processing. The following figure gives a high-level overview of the functional blocks used in SPF.
High-level SPF software block

High-level SPF software block

Processing Domain BProcessing Domain ASignal Processing Framework (SPF)Generic Packet Router (GPR)Audio Processing Manager (APM)OffloadSpecializedGenericContainerM1M2M3AMDPRMIRMModule-2Module-3…ApplicationPlatform and OS abstraction layerBoard Support Package(timer, memory manager, power manager, debug, etc.)Hardware driversReal-Time Operating System (RTOS)CAPIModule-1CAPICAPI High-level SPF software block SPF components

Next steps