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
| Source | A node that produces a stream of data (audio/video frames) and exposes output ports. A PipeWire source node:
|
| Sink | A node that consumes incoming data and exposes input ports. A PipeWire sink node:
|
Resource_manager.xml— Device-to-backend mapping and policy making attributesCard-defs.xml— Virtual PCM and compress nodes and their optionsmixer_paths.xml— Defines all low-level audio routing paths and controls that determine how sound is recorded, processed, and played on the deviceplugin_manager.xml— Links audio streams, sessions, and devices to their corresponding plugin libraries and functions for runtime audio handlingusecaseKvManager.xml— Maps audio streams and devices to DSP processing graphs, deciding how audio is processed internally on the chip
PAL APIs
The following are common PAL APIs. SeePalApi.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.- 0 on success
- Error code on failure
pal_deinit
De-initializes PAL and frees up the resources allocated during initialization.pal_stream_open
Opens a stream with the specified configuration such as source/sink devices and media configuration. Returns the stream handle upon success.
Return value
- 0 on success
- Error code on failure
pal_stream_start
Starts a stream.
Return value
- 0 on success
- Error code on failure
pal_stream_read
Reads the audio buffer captured from the audio source device.
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.
Return value
- Number of bytes written on success
- Error code on failure
pal_stream_stop
Stops a stream.
Return value
- 0 on success
- Error code on failure
pal_stream_close
Closes a stream.
Return value
- 0 on success
- Error code on failure
Configuration files
Configure audio use cases at the PAL level by using themixer_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 themixer_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
TheResourcemanager.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
TheUsecasekvmanager.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
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: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
-
Extract the source tree:
The PipeWire source tree extracts to:
-
Build the source tree:
Sync PAL
-
Extract the source tree:
The PAL source tree extracts to:
-
Build the source tree:
Sync TinyALSA
-
Extract the source tree:
The TinyALSA source tree extracts to:
-
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 termsGraph 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
- The stream subgraph has a write shared memory endpoint, PCM decoder, and PCM converter. The client passes PCM samples to write shared memory endpoint.
- If conversion is necessary, the PCM converter converts PCM samples to a format supported by the stream-specific postprocessing modules.
- 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.
- 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.
- Output of the devicePP subgraph is then fed into the device subgraph, which has a hardware endpoint module such as an I2S driver.
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
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 componentsAudio 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
Next steps
- Advanced audio features — Enable echo cancellation, noise suppression, and multi-device playback
- Audio Addendum — Use QACT and QXDM for calibration and diagnostics
- Troubleshoot audio — Capture and analyze audio logs to resolve issues

