Audio Setup and Development

NVIDIA IGX Orin Developer Kit User Guide (Latest)

This topic concerns the ASoC driver, audio hub hardware, USB audio, and other matters connected with audio on NVIDIA® IGX Orin devices.

Advanced Linux Sound Architecture (ALSA) provides audio functionality to the Linux operating system. The NVIDIA ALSA System-on-Chip (ASoC) drivers enable ALSA to work seamlessly with different NVIDIA SoCs. Platform-independent and generic components are maintained by the upstream Linux community.

For more details on ALSA, follow ALSA Project.

The IGX Orin device exposes multiple interfaces that can be used for audio functionalities. For information about the supported interfaces, see I/O and External Interfaces.

ALSA

The ALSA framework is a part of the Linux kernel that is supported and maintained by the Linux community. This makes it feasible to adapt the framework to the IGX Orin device by designing a driver that utilizes NVIDIA audio routing support. ALSA includes a collection of sound card drivers, including actual codec drivers, and can support adding new codec drivers.

ALSA includes libraries and utilities that enable more refined audio control in Linux user space. These libraries control audio applications without having to interact with kernel space drivers directly. These libraries include:

  • amixer

  • aplay

  • arecord

The following diagram illustrates the ALSA software hierarchy.

AlsaSoftwareHierarchy.svg

The functions of the platform and codec drivers are:

  • tegra210-admaif : A kernel driver that represents the interface between audio DMA (ADMA) and audio hub (AHUB)

  • tegra210-<xxxx> : Kernel drivers that represent various hardware accelerators in AHUB

  • tegra210-ahub : A kernel driver that helps to configure audio routing between various hardware accelerators

For more information about these modules, see the section AHUB modules.

User space ALSA applications interact with the ALSA core (kernel space) through APIs provided by user space libraries that initialize the actual hardware codecs at the backend of the audio pipeline.

DAPM

ALSA is designed to support various functionalities including, but not limited to, dynamic audio routing to available PCM devices. The component of ALSA core that provides this support is called Dynamic Audio Power Management (DAPM). DAPM minimizes power consumption by controlling the power flow into and out of various codec blocks in the audio subsystem. DAPM provides switches or kernel controls in the form of widgets (components that affect audio power) to turn a module’s power on and off and to manipulate register bits from user space applications such as aplay, arecord, and amixer.

For more details on DAPM, refer ASoC DAPM.

In terms of software hierarchy, DAPM is part of the ALSA core, which manages the codec module’s power consumption. See the ALSA software hierarchy diagram under ALSA for details.

For more information see Clocking and Power Management.

Device Tree

The device tree is a data structure that describes devices on the platform. It is passed to the operating system at boot time to avoid hard coding component details in the operating system. This makes it easier to change hardware configurations without rebuilding the kernel.

The device tree is composed of nodes and properties. Each node can have properties or child nodes. Each property consists of a name and one or more values. Device tree structures must be written in the correct format so that the data structure can be parsed by the operating system.

A simple device tree example is available at Codec Driver Instantiation Using Device Tree.

ASoC Driver

The ASoC driver provides better ALSA support for embedded system-on-chip processors (e.g. DSP, AHUB) and portable audio codecs. It consists of these components:

  • Platform driver: Responsible for PCM registration and interfacing with the PCM driver. ADMAIF is the platform driver.

  • Codec drivers: Typically a generic, hardware-independent component that configures the codecs. IGX Orin ASoC extends this to some of the internal modules which are described in subsequent sections.

    A codec driver must have at least one input or one output.

    The driver architecture provides a way to define users own DAPM widgets for power management and kcontrols for register settings from user space.

  • Machine driver: Registers a sound card by binding the platform and codec components.

ASoC uses a common structure, snd_soc_component_driver, which represents both a platform and a codec component. It finally depends on which interfaces the drivers implement. For example, a platform component implements PCM interface as well, whereas a codec component can ignore it. Hence at top level, both platform and codec are referred as ASoC component. The same terminology is used in this document whenever a generic reference is needed.

For details on writing a machine driver and identifying a sound card, see ASoC Machine Driver.

The Audio Processing Engine (APE) is a standalone hardware block that takes care of all the audio needs of IGX Orin processors with minimal supervision from the CPU. Its audio hub (AHUB) contains many hardware accelerators and a DMA engine. This section provides an overview of:

  • The audio hub hardware architecture inside the SoC

  • The software architecture of the ASoC driver

This diagram summarizes the hardware architecture of the ASoC.

AsocHardwareArchitecture.svg

The audio hub contains several other modules as shown in the following table and it captures AHUB capabilites of a processor. Each module is described in detail in subsequent sections.

Module

Component

Instances

Mixer Mixer 1x
AMX Audio multiplexer 4x
ADX Audio demultiplexer 4x
SFC Sample frequency converter 4x
MVC Master volume control 2x
ADMA Audio Direct Memory Access 1x (32 channels)
ADMAIF AHUB Direct Memory Access Interface 1x (20 TX and RX channels)
XBAR Crossbar; routes audio samples through other modules 1x

The modules in the audio hub support various kinds of audio devices that are expected to interface with the application processor, such as:

  • Cellular baseband devices

  • Different types of audio CODECs

  • Bluetooth® modules

  • Digital microphones

  • Digital speakers

The audio hub supports the different interfaces and signal quality requirements of these devices.

  • Each of the AHUB modules has at least one RX port or one TX port or both.

  • RX ports receive data from XBAR, and TX ports send data to XBAR. Thus XBAR is a switch where an audio input can be fed to multiple outputs, depending on the use case.

  • Each ADMAIF has TX and RX FIFOs that support simultaneous playback and capture. ADMA transfers the data to the ADMAIF FIFO for all audio routing scenarios.

    For dynamic audio routing examples, see Usage and Examples.

The software architecture of the ASoC driver for IGX Orin leverages the features supported by the hardware and conforms to the ALSA framework.

As mentioned earlier, the ASoC driver comprises the platform, codec and machine drivers. The roles of these drivers are described briefly below, and in more detail in subsequent sections.

The ASoC driver provides NVIDIA Audio Hub (AHUB) hardware acceleration to the platform and codec drivers. AHUB Direct Memory Access Interface (ADMAIF) is implemented as a platform driver with PCM interfaces for playback and capture. The rest of the AHUB modules, such as the crossbar (XBAR), multiplexer (AMX), demultiplexer (ADX), and inter-IC sound (I2S), are implemented as codec drivers. Each of the drivers is connected to XBAR through a digital audio interface (DAI), inside a machine driver, forming an audio hub.

The machine driver probe instantiates the sound card device and registers all of the PCM interfaces as exposed by ADMAIF. After booting, but before using these interfaces for audio playback or capture, user must set up the audio paths inside XBAR. By default, XBAR has no routing connections at boot, and no complete DAPM paths to power on the corresponding widgets. The XBAR driver introduces MUX widgets for all of the audio components and enables custom routing through kcontrols from user space using the ALSA amixer utility. If the audio path is not complete, the DAPM path is not closed, the hardware settings are not applied, and audio output cannot be heard.

For more details on how to set up the route and how to play back or capture on the PCM interfaces, see Usage and Examples.

Platform Driver

The platform driver initializes and instantiates the ports for playback and capture inside the AHUB.

Users must connect some or all of these ports to form a full audio routing path. For examples of full audio paths, see the examples in Usage and Examples. Note that there are other elements in a full audio path setup, which are discussed in subsequent sections; the playback/capture ports set up by the platform driver are only a subset.

ADMAIF

ADMAIF is the platform driver in the IGX Orin ASoC design. It implements required PCM interfaces exposed via the snd_soc_component_driver structure. These interfaces help perform DMA operations by interacting with the SoC DMA engine’s upstream APIs. The ADMAIF platform driver defines DAIs and registers them with ASoC core.

The ADMAIF channels are mapped to:

  • /dev/snd/pcmC1D<n>p for playback

  • /dev/snd/pcmC1D<n>c for capture

Where <n> is the channel number minus 1. For example:

  • ADMAIF1 is mapped to pcmC1D0p for playback, and pcmC1D0c for capture.

  • ADMAIF2 is mapped to pcmC1D1p for playback, and pcmC1D1c for capture.

Codec Driver

An overview of codec drivers is presented in ASoC Driver. In the ASoC driver implementation, the rest of the AHUB modules, except for ADMAIF, are implemented as codec drivers. Their responsibilities include:

  • Interfacing to other modules by defining DAIs

  • Defining DAPM widgets and establishing DAPM routes for dynamic power switching

  • Exposing additional kcontrols as needed for user space utilities to dynamically control module behavior

Codec Driver Instantiation Using Device Tree

Based on architecture, the Makefile in the following directory conditionally compiles the required device tree structure files into DTB files:

Copy
Copied!
            

$KERNEL_TOP/arch/arm64/boot/dts/

When the kernel is flashed, the flash script chooses the appropriate board-specific DTB file for parsing during boot, and the ASoC codecs listed in device tree are instantiated. To add new devices to the device tree, edit the DTS file, and flash the target again. The DTS file name can be identified from the corresponding DTB file name, and the DTB file is in the /boot/dtb target directory.

For example:

Copy
Copied!
            

If ``/boot/dtb/kernel_tegra234-p3740-0002+p3701-0008-nv.dtb`` is the platform DTB, the corresponding DTS file is ``hardware/nvidia/t23x/nv-public/nv-platform/tegra234-p3740-0002+p3701-0008-nv.dts``.

To add a new device, add the device name with the base address and status as "okay":

Copy
Copied!
            

ahub@2900800 { status = "okay"; i2s@2901000 { status = "okay"; }; };

XBAR

The XBAR codec driver defines RX, TX and MUX widgets for all of the interfacing modules: ADMAIF, AMX, ADX, I2S, Mixer, SFC and MVC. MUX widgets are permanently routed to the corresponding TX widgets inside the structure snd_soc_dapm_route.

XBAR interconnections are made by connecting any RX widget block to any MUX widget block as needed using the ALSA amixer utility. The get and put handlers for these widgets are implemented so that audio connections are stored by setting the appropriate bit in the hardware MUX register.

Mixer Controls

If the sound card is available after boot, that indicates that the machine driver was successful in binding all codec drivers and the platform driver. The remaining step before obtaining the audio output on the physical codecs involves the use of MUX widgets to establish the DAPM path in order to route data from a specific input module to a specific output module. Input and output modules are dependent on the applicable use case. This provides flexibility for complex use cases.

This command realizes the internal AHUB path “ADMAIF1 RX to XBAR to I2S1 TX”:

Copy
Copied!
            

$ amixer –c APE cset name='I2S1 Mux' 'ADMAIF1'

For usage and examples of various AHUB modules, see Usage and Examples.

AMX

The Audio Multiplexer (AMX) module can multiplex up to four streams of up to 16 channels, with a maximum of 32 bits per channel, into a time division multiplexed (TDM) stream of up to 16 channels with up to 32 bits per channel. The AMX has four RX ports for receiving data from XBAR and one TX port for transmitting the multiplexed output to XBAR. Each port is exposed as a DAI, as indicated in the following diagram by solid lines. Routes are established using DAPM widgets, as indicated by dotted lines.

AudioMultiplexerModule.svg

The AMX code driver supports these features:

  • Can multiplex up to four input streams of up to 16 channels each, and generate one output stream of up to 16 channels

  • Can assemble assemble an output frame from any combination of bytes from the four input frames (“byte ram”)

  • Provides two modes for data synchronization of the first output frame:

    • Wait for All mode: Wait for all enabled input streams to have data before forming the first output frame.

    • Wait for Any mode: Start forming the first output frame as soon as data is available in any enabled input stream.

Byte Map Configuration

Each byte in the output stream is uniquely mapped from a byte in one of the four input streams. Mapping of bytes from input streams to the output stream is software-configurable through a byte map in the AMX module.

Each byte in the byte map is encoded with these fields:

Field

Bits

Description

Input stream 7:6 Identifies the input stream (0 to 3) that the byte is mapped from, where 0 is RxCIF0, etc.
Input stream channel 5:2 Identifies the input stream channel (0 to 15) that the byte is mapped from, where 0 is channel 0, etc.
Input stream byte 1:0 Identifies the byte in the input stream channel that the byte is mapped from (0 to 3), where 0 is byte 0, etc.

Because the largest supported output frame size is 16 samples (from 16 channels) with 32 bits per sample, the byte map is organized as 16 words of 4 bytes (32 bits) each. Each word represents one input channel, and each byte in the word represents one output channel that the input channel may be mapped to.

If the output frame gets samples from only two input channels, then only the bytes in word 0 and word 1 need be programmed. If the output frame gets samples from all 16 channels, then the bytes in all 16 words must be programmed.

The output frame sample size determines which bytes must be programmed in each word. If the sample size of each channel in the output frame is 16 bits, then only byte 0 and byte 1 of each word in the byte map need be programmed. If the sample size of each channel in the output frame is 32 bits, then all four bytes of each word must be programmed.

Bear these points in mind:

  • Input bytes must be mapped to output bytes in order. For example, if input frame bytes 0 and 1 are both mapped to the output frame, byte 1 must be mapped to a position in the output frame after byte 0.

  • Not all bytes from an input frame need be mapped to the output frame.

  • Each byte in the output frame has a software-configurable enable flag. If a particular byte’s enable flag is cleared, the corresponding mapping in the byte map is ignored, and that byte is populated with zeros.

Mixer Controls

Mixer controls are registered for each instance of AMX by the respective codec driver, and are used to configure the path, characteristics, and processing method of audio data. The table below lists instance-specific mixer controls.

Mixer Control *

Description

Possible Values

AMX RX Mux Selects the AHUB client device from which the AMX input receives data. Run this command to get possible values: amixer -c APE cget name="AMX<i> RX<j> Mux"
AMX Input Audio Channels Specifies the channel count of the input streams. 0-16
AMX Output Audio Channels Specifies the channel count of the output stream. 0-16
AMX Byte Map Specifies the byte map (see Byte Map Configuration). 0-255
* refers to the instance ID of the AMX client, and refers to the input port ID.

Usage and examples of the AMX module can be found in Examples: AMX.

ADX

The Audio Demultiplexer (ADX) module can demultiplex a single TDM stream of up to 16 channels and a maximum of 32 bits per channel into four streams of up to 16 channels and 32 bits per channel. The RX port of ADX receives input data from XBAR, and four TX ports transmit demultiplexed output to XBAR. Each port is exposed as a DAI, indicated by a solid line and routes are established using DAPM widgets as indicated by the dotted lines in the following diagram.

AudioDemultiplexerModule.svg

ADX has one input, RxCIF, which supplies the input stream. The core logic selects bytes from this input stream based on a byte map and forms output streams which are directed to a TxCIF FIFO to be transmitted to a downstream module in AHUB.

The ADX demultiplexer supports these features:

  • Demultiplexing one input stream of up to 16 channels to four output streams of up to 16 channels each

  • Assembling output frames that contain any combination of bytes from the input frame (“byte RAM”). The byte RAM design is the same as in AMX, except that the direction of data flow is reversed.

Byte Map Configuration

Each byte in each output stream is mapped from a byte in the input stream. The mapping of the bytes from input stream to output streams is software-configurable through a byte map in the ADX module.

Field

Bits

Description

Output stream 7:6 Specifies the output stream that the byte is mapped to, where 0 represents TxCIF0, etc.
Output stream channel 5:2 Specifies the output stream channel that the byte is mapped to, where 0 represents channel 0, etc.
Output stream byte 1:0 Specifies the byte in the output stream channel that the byte is mapped to, where0 represents byte 0, etc.

Because the maximum supported output frame size per stream is 16 channels with 32 bits per sample, the byte map is organized as 16 words of 32 bits (4 bytes) each.

Each word represents one channel in the input frame. Therefore, if the input frame only has two channels then only the bytes in word 0 and word 1 need be programmed, while if the input frame has 16 channels (the maximum allowed), then bytes in all 16 words must be programmed.

The input frame sample size determines the bytes that must be programmed in each word. If the sample size of each channel in the input frame is 16 bits, then only byte 0 and byte 1 of each word need be programmed. If the sample size of each channel in the input frame is 32 bits, then all four bytes of each word must be programmed.

Bear these points in mind:

  • Input bytes must be mapped to output bytes in order. For example, if input frame bytes 0 and 1 are both mapped to the output frame, byte 1 must be mapped to a position in the output frame after byte 0.

  • Not all bytes in an input frame need be mapped to the output frame.

  • Each byte in the output frame has a software-configurable enable flag. If a particular byte’s enable flag is cleared, the corresponding mapping in the byte map is ignored, and that byte is populated with zeros.

Mixer Controls

Mixer controls are registered for each instance of ADX by the respective codec driver, and are used to configure the path, characteristics, and processing method audio data. The table below lists the instance-specific mixer controls for each instance of the ADX module.

Mixer Control *

Description

Possible Values

ADX Mux Selects the AHUB client device from which the ADX input receives data. Use this command to get possible values: amixer -c APE cget name="ADX<i> Mux"
ADX Input Audio Channels Configures the channel count of the input stream. 0-16
ADX Output Audio Channels Configures the channel count of the output streams. 0-16
ADX Byte Map Configures the byte map (see Byte Map Configuration) 0-255
* refers to the instance ID of the ADX client, and refers to the output port ID.

Usage and examples of ADX module can be found in Examples: ADX.

I2S

An I2S codec driver supports bidirectional data flow, and so defines CIF and DAP RX/TX DAPM widgets with the CIF side of I2S interfacing with XBAR, and the DAP side interfacing with the physical codec on the IGX Orin device.

The DAPM routes established with these DAPM widgets are shown in the following diagram as dotted lines. I2S modules also expose kernel control to enable internal I2S loopback.

I2sModule.svg

The I2S controller implements full-duplex and half-duplex point-to-point serial interfaces. It can interface with I2S-compatible products, such as digital audio tape devices, digital sound processors, modems, and Bluetooth chips.

The I2S codec driver supports these features:

  • Can operate both as master and slave

  • Supports the following modes of data transfer:

    • LRCK modes: I2S mode, Left Justified Mode (LJM), or Right Justified Mode (RJM)

    • FSYNC modes: DSP A or B mode

  • Can transmit and receive data:

    • Sample size: 8 bits (S8), 16 (S16_LE), or 24/32 bits (S32_LE)

    • Sample rate: 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88400, 96000, 176400, or 192000 Hz

    • Channels: LRCK modes support stereo data; DSP A and B modes support 1 to 16 channels

Device Tree Entry

This I2S node entry enables a given I2S instance on a given chip:

Copy
Copied!
            

aconnect@2a41000 { compatible = "nvidia,tegra234-aconnect", "nvidia,tegra210-aconnect"; status = "okay"; ... tegra_ahub: ahub@2900800 { compatible = "nvidia,tegra234-ahub"; status = "okay"; ... tegra_i2s1: i2s@2901000 { compatible = "nvidia,tegra234-i2s", "nvidia,tegra210-i2s"; reg = <0x0 0x2901000 0x0 0x100>; clocks = <&bpmp TEGRA234_CLK_I2S1>, <&bpmp TEGRA234_CLK_I2S1_SYNC_INPUT>; clock-names = "i2s", "sync_input"; assigned-clocks = <&bpmp TEGRA234_CLK_I2S1>; assigned-clock-parents = <&bpmp TEGRA234_CLK_PLLA_OUT0>; assigned-clock-rates = <1536000>; sound-name-prefix = "I2S1"; #sound-dai-cells = <1>; nvidia,ahub-i2s-id = <0>; status = "okay"; }; ... }; };

The snippet above is from the device tree structure for IGX Orin. The address and a few other properties are IGX Orin device-specific and might be referenced by the corresponding IGX Orin device tree files. In the case of I2S, the device entry above specifies the names of clocks needed by the device, the source of each clock, and the register base address and address range belonging to the device. Other properties such as fsync-width may be adjusted to fit the use case’s requirements.

Mixer Controls

Mixer controls are registered for each instance of I2S by the respective codec driver, and are used to configure the path, characteristics, and processing method of audio data. The table below lists instance-specific mixer controls.

Mixer Control *

Description

Possible Values

I2S Loopback Enables internal I2S loopback. On or Off
I2S Playback Audio Bit Format Configures length of playback sample bits. 16 or 32
I2S Capture Audio Bit Format Configures length of capture sample bits. 16 or 32
I2S Client Bit Format Configures length of playback/capture sample bits on client side 16 or 32
I2S FSYNC Width Configures frame sync signal’s width in terms of bit clocks. 0-255
I2S Sample Rate Configures sample rate of audio stream. 8000, 11025, 16000, 22500, 24000, 32000, 44100, 48000, 88400, 96000, 176400, or 192000 Hz
I2S Playback Audio Channels Configures channel count of audio playback stream. 0-16
I2S Capture Audio Channels Configures channel count of audio capture stream. 0-16
I2S Client Channels Configures channel count of audio playback/capture stream on client side 0-16
I2S Capture Stereo To Mono Configures stereo to mono conversion method to be applied to capture stream. CH0, CH1, or AVG
I2S Capture Mono To Stereo Configures mono to stereo conversion method to be applied to capture stream. Zero, or Copy
I2S Playback Stereo To Mono Configures stereo to mono conversion method to be applied to playback stream. CH0, CH1, or AVG
I2S Playback Mono To Stereo Configures mono to stereo conversion method to be applied to playback stream. Zero, or Copy
I2S Playback FIFO Threshold Configures CIF’s FIFO threshold for playback to start. 0-63
I2S BCLK Ratio Threshold I2S BCLK (bit clock) multiplier 1, 2 …
I2S Codec Frame Mode Configures I2S frame mode. dsp-a refers to a data offset of 1 and dsp-b refers to a data offset of 0. None, i2s, left-j, right-j, dsp-a, or dsp-b
I2S Codec Master Mode Configures I2S codec’s mode of operation (bit-master, bit-slave frame-slave, or frame-master). None, cbm-cfm, or cbs-cfs
I2S Mux Selects the AHUB client device from which the I2S input receives data. Use this command to get possible values: amixer -c APE cget name="I2S<i> Mux"
* refers to the instance ID of the ADX client, and refers to the output port ID.

For usage and an example for the I2S module, see Examples: I2S.

Mixer

The Mixer mixes audio streams from any of the 10 input ports that receive data from XBAR to any of the 5 output ports that transmit data onto XBAR. The DAPM widgets and routes for Mixer are shown in the figure below. The Mixer driver also exposes RX Gain and Mixer Enable as additional kcontrols to set the volume of each input stream and to globally enable or disable the Mixer respectively.

MixerModule.svg

Features Supported
  • Supports mixing up to 10 input streams

  • Supports five outputs, each of which can be a mix of any combination of 10 input streams

  • Can transmit and receive:

    • Sample size: 8, 16, 24, or 32

    • Sample rate: 8000, 11025, 16000, 22500, 24000, 32000, 44100, 48000, 88400, 96000, or 192000 Hz

    • Channels: 1-8

  • Fixed gain for each stream is also available

Mixer Controls

Mixer controls are registered for each instance of Mixer by the corresponding codec driver. They are used to the configure path, characteristics, and processing method of audio data. The table below lists instance-specific mixer controls.

Mixer Control *

Description

Possible Values

MIXER1 RX Mux Selects the AHUB client device from which the I2S input receives data. Run this command to get possible values: amixer -c APE cget name="MIXER1 RX<i> Mux"
MIXER1 Mixer Enable Enables Mixer. On or Off
MIXER1 Adder RX Enables the input stream <i> on Adder <j>. On or Off
MIXER1 RX Audio Channels Configures the channel count of the input stream. 0-8
MIXER1 TX Audio Channels Configures the channel count of the output stream. 0-8
MIXER1 RX Gain Configures the gain for an input stream before add in the adder. 0-131072
MIXER1 RX Gain Instant Configures the gain for an input stream before add in the adder. 0-131072
* refers to the input port of the mixer, and refers to the output port of the mixer.

For usage and examples for the Mixer module, see Examples: Mixer.

SFC

The Sampling Frequency Converter (SFC) converts the input sampling frequency to the required sampling rate. SFC has one input port and one output port, which are connected to XBAR.

SfcModule.svg

Features Supported
  • Sampling frequency conversion of streams of up to two channels (stereo)

  • Very low latency (maximum latency less than 125 microseconds)

  • Supported frequency conversions appear in the following table. When the frequency in and out are the same, frequency conversion is bypassed.

Supported Frequency Conversions

Fs in →

8

11.025

16

22.05

24

32

44.1

48

88.2

96

176.4

192

n/a yes yes yes yes
n/a yes yes
yes n/a yes yes yes
n/a yes yes
n/a yes yes
n/a yes yes
yes yes n/a yes
yes yes yes yes n/a yes yes
yes yes n/a
yes yes n/a
yes yes n/a
yes yes n/a
Mixer Controls for SFC

Mixer controls are registered for each instance of SFC by the corresponding codec driver. They are used to configure the path, characteristics, and processing method of audio data. The table below lists instance-specific mixer controls.

Mixer Control *

Description

Possible Values

SFC Mux Selects the AHUB client device from which the I2S input receives data. Use this command to get possible values: amixer -c APE cget name="SFC<i> Mux"
SFC Init Enables the instance of SFC. On or Off
SFC Input Sample Rate Configures sampling rate of the input stream. 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, 176400, or 192000  Hz
SFC Output Sample Rate Configures sampling rate of the output stream. 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, 176400, or 192000 Hz
SFC Input Audio Channels Configures channel count of the input stream. 1, 2
SFC Output Audio Channels Configures channel count of the input stream. 1, 2
SFC Input Audio Bit Format Configures sample size of the input stream. 16 or 32
SFC Output Audio Bit Format Configures sample size of output stream. 16 or 32
SFC Input Stereo To Mono Configures stereo to mono conversion of input stream CH0, CH1 or AVG
SFC Input Mono To Stereo Configures mono to stereo conversion of input stream Zero, or Copy
SFC Output Stereo To Mono Configures stereo to mono conversion of output stream CH0, CH1 or AVG
SFC Output Mono To Stereo Configures mono to stereo conversion of output stream Zero, or Copy
* refers to the instance ID of SFC.

For usage and examples for the SFC module, see Examples: SFC.

MVC

MVC (volume control) applies gain or attenuation to a digital signal path. The MVC block is a generic block. It can be used to apply volume control:

  • To the input or output digital signal path

  • Per-stream and to all streams (primary volume control)

The following diagram shows MVC’s DAPM widgets and routes.

MvcModule.svg

Features Supported
  • Programmable volume gain for data formats:

    • Sample size: 8, 16, 24, or 32 bits

    • Sample rate: 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88400, 96000, 176400, or 192000 Hz

    • Channels: 1-8

  • Programmable curve ramp for volume control

  • Separate mute and unmute controls

Mixer Controls

Mixer controls are registered for each instance of MVC by the corresponding codec driver. They are used to configure the path, characteristics, and processing method of audio data. The table below lists instance-specific mixer controls.

Mixer Control *

Description

Possible Values

MVC Volume Configures master volume 0 to 16000 (Represents -120 to +40 dB with 100x scale factor)
MVC Channel Volume Configures channel-specific volume 0 to 16000 (Represents -120 to +40 dB with 100x scale factor)
MVC Mute Enables/disables Master mute On or Off
MVC Per Channel Mute Mask Controls Channel- specific mute mute/unmute 0 to 255
MVC Curve Type Configures volume ramp curve type Poly or Linear
MVC Audio Channels Configures channels of audio data passing through MVC 0-8
MVC Audio Bit Format Configures sample size of input audio data through MVC 16 or 32
MVC Bits Configures sample size of output audio data through MVC OSR_64, OSR_128, or OSR_256
MVC Mux Selects the AHUB client device from which the MVC input receives data. Use this command to get possible values: amixer -c APE cget name="MVC<i> Mux"
* <i> refers to the instance ID of the MVC client and <j> refers to the channel number

For usage and examples of the MVC module, see Examples: MVC.

AHUB Client TX Port Names

This is a list of names of AHUB clients’ TX ports.

AHUB Client

TX Port Names *

ADMAIF ADMAIF<i>
I2S I2S<i>
AMX AMX<i>
ADX ADX<i> TX1, ADX<i> TX2, ADX<i> TX3, ADX<i> TX4
SFC SFC<i>
MVC MVC<i>
MIXER MIXER1 TX1 to MIXER1 TX5
* <i> represents the instance ID of a given AHUB client.

ASoC Machine Driver

The ASoC machine driver connects the codec drivers to a PCM driver by linking the DAIs exposed by each module. It instantiates the sound card (a software component in ASoC architecture).

The structure snd_soc_dai_link, in ASoC core, defines a link that connects two DAIs from different modules. Such a link is called a DAI link. A given machine driver can have one or more of DAI links, which are connected at runtime to form an audio path.

In brief, the ASoC machine driver’s functions are to:

  • Parse all DAI links from DT. These include both SoC internal DAI links (those between XBAR and various AHUB modules) and IGX Orin device-specific DAI links between SoC I/O modules and external audio codecs.

  • Parse DAPM widgets and routes from the device tree (DT), which are required to connect machine source/sink widgets with codec endpoints. For example machine widgets are defined for headphone jacks, speakers and microphones. These in turn are mapped to corresponding audio codec inputs and outputs.

  • Configure the Audio Processing Engine (APE) subsystem and codec clocks.

  • Propagate the runtime PCM parameters, such as sample-rate and sample-size.

The IGX Orin ASoC machine driver is available in the kernel sources archive in this location:

Copy
Copied!
            

kernel/nvidia-oot/sound/soc/tegra/tegra_machine_driver.c

All DAI links are defined in:

Copy
Copied!
            

hardware/nvidia/t23x/nv-public/overlay/tegra234-soc-audio-dai-links.dtsi

All I/O DAI links are connected to dummy endpoints by default. This allows the SoC to drive the interface pins even when no external device is present. These have phandle references which can easily be used to override the specific properties. In short, if user want interface to a specific external codec, the corresponding DAI link in the device tree must be overridden.

For example, I2S1 DAI is connected to the dummy codec, and looks like below:

Copy
Copied!
            

i2s1_to_codec: nvidia-audio-card,dai-link@76 { status = "okay"; format = "i2s"; link-type = <C2C_LINK>; i2s1_cpu: cpu { sound-dai = <&tegra_i2s1 I2S_DAP>; }; codec { sound-dai = <&tegra_i2s1 I2S_DUMMY>; }; };

Definition of a DAI Node

Each DAI link for the I2S interface must be defined by a DAI node, which is a subnode of the sound node. The overall format of a DAI node is described in ASoc Machine Driver.

For each I2S interface DAI link, you must configure the following properties:

  • bitclock-master and frame-master: Optional Booleans; specify whether the codec is a slave or a master. The codec is the I2S bit clock and frame master if these properties are present, or the I2S slave if they are absent.

  • format: Configures CPU/CODEC common audio format. The value may be i2s, right_j, left_j, dsp_a, or dsp_b.

  • bclk-ratio: An integer used to configure the I2S bit clock rate. The I2S bit clock rate is the product of this value and the stream sample rate. A value of 0 yields the same clock rate as 1.

  • srate: PCM data stream sample rate

  • bit-format: Data stream sample size

  • num-channel: Number of data stream channels

Clocking and Power Management

The following debugfs node listing, obtained from /sys/kernel/debug/clk/clk_summary, shows the clock tree of the ASoC driver for IGX Orin in the idle state, when no audio playback or capture operations are in progress.

clock

enable_cnt

prepare_cnt

rate

req_rate

accuracy

phase

0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 600000000 600000000 0 0
0 0 150000000 150000000 0 0
0 0 150000000 150000000 0 0
0 0 258000000 258000000 0 0
0 0 12285714 12285714 0 0
0 0 12285714 12285714 0 0
0 0 12285714 12285714 0 0
0 0 12285714 12285714 0 0
0 0 23454545 23454545 0 0
0 0 23454545 23454545 0 0
0 0 23454545 23454545 0 0
0 0 23454545 23454545 0 0
0 0 23454545 23454545 0 0
0 0 23454545 23454545 0 0
0 0 86000000 86000000 0 0

The clocks of the individual modules, AMX, ADX, AFC, SFC, MIXER, and others, are internally driven by the APE clock.

The clock for all codec drivers (I2S, XBAR, etc.) are switched off in the idle state. They are turned on when audio playback or capture begins.

Dynamic PLL_A Rate Update

PLL_A is a clock source provided by IGX Orin processors for audio needs. Its primary function is to source the clocking requirements of I2S modules. The AUD_MCLK clock is also derived from PLL_A.

IGX Orin devices support two families of sample rates:

  • Multiples of 8 Kbps (8x): 8000, 16000, 24000, 32000, 48000, 96000, and 192000 Hz

  • Multiples of 11.025  Kbps (11.025x): 11025, 22050, 44100, 88200, and 176400 Hz

A single PLL_A base rate cannot support both families of rates. Therefore, separate base rates are used for 8x and 11.025x. The machine driver sets the rate of PLL_A at run time, depending on the incoming stream’s sample rate. Thus users can play and capture at a rate from either list above.

IGX Orin devices support one or more High Definition Audio (HDA) interfaces through on-board HDMI and DP ports. These interfaces can be used to perform high-quality audio rendering on devices like TVs and A/V receivers. These HDA interfaces are available on IGX Orin:

  • One DP output (can support single or multiple streams)

  • One HDMI input for HDMI-IN.

HDMI and DP interfaces can be connected using the respective connectors.

Features Supported

IGX Orin High Definition Audio supports the following features:

  • Compliant with High Definition Audio Specification Revision 1.0

  • Supports HDMI 1.3a and DP

  • Audio Format Support

    • Channels: 2 to 8

    • Sample size: 16 bits (S16_LE) or 24 bits (S32_LE)

    • Sample rate:

      • 32000, 44100, 48000, 88200, 96000, 176400, or 192000 Hz (HDMI)

      • 32000, 44100, 48000, 88200, or 96000 Hz (DP)

If you experience issues when playing high resolution audio formats (using multichannel output or a high sampling rate), even with an audio format that your monitor supports, this is because the available audio bandwidth depends on the HDMI configuration, increasing with higher display resolutions.

If you encounter issues when playing a high resolution audio format, NVIDIA recommends that you set your display resolution to at least the level that corresponds to your audio format in the following table. This table is taken from the HDMI 1.3a specification document.

Note

Two-channel PCM can never exceed 192 kHz. Higher values indicate higher frame rates that can be used for compressed streams.

Suggested Display Resolutions

Display Resolution

Format Timing

Pixel Repetition

Maximum fs 8 Channels (Hz)

Maximum Frame Rate 2 Channels Compressed

SuperAudio CD Channel Count

none 48000 192 2
2 88200 192 2
4 192000 768 8
2 88200 192 2
4 192000 768 8
none 48000 192 2
2 176400 384 8
4 192000 768 8
none 192000 768 8
none 192000 768 8
none 192000 768 8

Software Driver Details

HDA interfaces are accessible through standard ALSA interfaces. Use the aplay utility for rendering audio:

Copy
Copied!
            

$ aplay -Dhw:HDA,<devID> <wav_in>

Where:

  • <deviceID> is the sound interface’s device ID.

  • <wav_in> is the name of the sound file to be played. It should be a .wav file.

Here are some further details about driver usage:

  • All HDA interfaces are available under one card.

  • Read card details from /proc/asound/cards.

  • To see available PCM devices (i.e. HDA interfaces) under /proc/asound/card<n>/.

  • AHUB supports 16-bit audio in S16_LE format, and 20 or 24-bit audio in S32_LE format.

All IGX Orin devices provide a USB host interface for connecting various USB devices, including USB audio devices such as speakers, microphones and headsets.

Features Supported

IGX Orin High Definition Audio supports the following features:

  • Channels: 8 maximum

  • Sample size: 16 bits (S16_LE) or 24 bits (S24_3LE)

  • Sample rate: 32000, 44100, 48000, 88200, 96000, 176400, or 192000  Hz

Supported audio formats are determined by the USB audio equipment connected.

Software Driver Details

USB audio is accessible through standard ALSA interfaces. Use the aplay and arecord utilities to render and capture audio, respectively:

Copy
Copied!
            

$ aplay -Dhw:<cardID>,<devID> <file_wav> $ arecord -Dhw:<cardID>,<devID> -r <rate> -c <chan> -f <format> <file_wav>

Where:

  • <cardID> is the card ID, a string that identifies the type of sound card: APE or HDA.

  • <devID> is the device ID.

  • <file_wav> is the name of the input file (for aplay) or output file (for arecord). It must be a WAV file.

  • <rate> is the sampling rate.

  • <chan> is the number of audio channels.

  • <format> is the sample format

Here are some further details about driver usage:

  • The USB audio card is enumerated upon connecting a USB device (e.g. a USB headphone).

  • Read card details from /proc/asound/cards.

  • To see available PCM devices under /proc/asound/card<n>/.

The Playback and Capture jack ports are connected internally to the RT5640 codec on IGX Orin.

Audio Formats Supported

The IGX Orin ASoC driver supports these formats:

  • Sample size: 8 bits (S8), 16 bits (S16_LE), or 24/32 bits (S32_LE)

  • Sample rate: 8000, 11025, 16000, 22050. 24000, 32000, 44100, 48000, 88400, 96000, 176400, or 192000 Hz

  • Channels: 1 or 2

Usage Guide

To establish the audio route for playback or recording through the header, it’s necessary to configure several ALSA mixer controls for both the IGX Orin device and the onboard codec. By default, audio route is set for LINE OUT and MIC path.

Playback and Capture Commands

Playback:

Copy
Copied!
            

$ aplay -D hw:APE,0 <in_wav>

Capture:

Copy
Copied!
            

$ arecord -Dhw:APE,0 -c <channels> -r <rate> -f <format> -d <duration> <out_wav>

HDMI IN Capture

Considering HDMI IN signal are present to start Audio capture:

Copy
Copied!
            

# AHUB Mixer Controls (apply on IGX Orin) $ amixer -c APE cset name="ADMAIF2 Mux" "I2S6" $ amixer -c APE cset name="I2S6 codec master mode" "cbm-cfm" # Start capture $ arecord -Dhw:APE,1 -c 2 -r 48000 -f S16_LE -d 15 <out_wav>

This section gives an example of how a device’s I/O interfaces and AHUB modules can be used in audio applications.

This shows a dump of sound card descriptions from an IGX Orin device.

Note

The example uses a specific ADMAIF, but you may choose any ADMAIF you want.

Copy
Copied!
            

$ cat /proc/asound/cards 0 [HDA ]: tegra-hda - NVIDIA IGX Orin HDA NVIDIA Jetson IGX Orin HDA at 0x3518000 irq 122 1 [APE ]: tegra-ape - NVIDIA IGX Orin APE Unknown-JetsonIGXOrinDeveloperKit-NotSpecified

For each sound card, the dump shows:

  • The initial number is the index of the sound card, a sequential number counting from 0.

  • The word in square brackets is the card ID (“card identifier”), a string that identifies a sound card. Trailing spaces are not part of the card ID.

  • tegra-hda or tegra-ape is the ALSA card driver name, that is, the machine driver name associated with the sound card. On IGX Orin devices, HDA sound cards use tegra-hda and APE sound cards use tegra-ape.

  • “NVIDIA IGX Orin HDA” and “…APE”: Short name of the sound card, and it is considered to be the name of the card.

  • “NVIDIA IGX Orin HDA at 0x3518000 irq 118” and “…APE”: Long name of the sound card.

Note

The example shows the two types of sounds cards that are built into the IGX Orin AHUB architecture, and use drivers provided by NVIDIA. An IGX Orin device might have other types. If you attached a USB headset to the device, for example, the dump will also show a USB sound card.

USB sound card names depend on the vendor and model of the sound card. A dump like the one above can help you determine a USB sound card’s long name.

The following table lists the short names that are used on different IGX Orin devices for APE and HDA cards.

Board name

APE card name

HDA card name

USB card name

IGX Orin NVIDIA IGX Orin APE NVIDIA IGX Orin HDA For the name after plugging in the device, run /proc/asound/cards

In addition to a name, each sound card has a device ID, as shown in the table later in this section.

For an APE card, the device ID refers to the ADMAIF channel index being used. IGX Orin devices have 20 ADMAIF channels, and each channel is associated with a playback device and a capture device. Each device has a device ID ranging from 0 to 19.

To determine how many sound cards are available, enter:

Copy
Copied!
            

$ cat /proc/asound/cards

This command displays the index of the last sound card, which is one less than the number of sound cards. For example, if /proc/asound/cards contains ‘2’, the IGX Orin device has three sound cards, with card indexes 0, 1, and 2.

To list all of the available PCM sound cards’ device IDs, enter:

Copy
Copied!
            

$ ls /dev/snd/pcmC?D*

This a convenient way to get the available device IDs for a given card. If you know the card’s index, you may use it in place of the ‘?’. Note, though, that sound card indexes are assigned in the order that the kernel registers the sound cards at boot time, so a given card ID may not represent the same card from boot to boot.

To display a description of a specific PCM sound card, enter:

Copy
Copied!
            

$ cat /dev/snd/pcmC<n>D<devID><f>

Where:

  • <n> is the card’s index, 0 or 1.

  • <devID> is the card’s device ID

  • <f> is the function of this device, c for “capture” or p for “playback.”

This table lists port to <devID> mappings for HDA devices, for which different HDA ports are mapped to specific <devID> values.

Port to device ID map

Device

Port Name

PCM Device ID

IGX Orin DP 3 (DP single stream)
3 and 7 (DP multi-stream)
HDMI HDMI IN

Following are examples of device name usage for several different types of interfaces. In these examples:

  • <i> and <i−1> are respectively the number of the ADMAIF channel to be used, and that number minus 1.

  • <in_wav> and <out_wav> are respectively the pathnames of the input and output sound files. Both must be .wav files.

  • <rate> is the sampling rate to be used.

  • <bits> is the number of bits per sample.

  • <channels> is the number of channels to be used.

Examples: I2S

These examples illustrate various I/O playback and capture using I2S2 with ADMAIF<i>.

Playback

Playback using I2S2 with ADMAIF<i>:

Copy
Copied!
            

$ amixer -c APE cset name="I2S2 Mux" ADMAIF<i> $ aplay -D hw:APE,<i-1> <in_wav>

Capture

Capture using I2S2 with ADMAIF<i>:

Copy
Copied!
            

$ amixer -c APE cset name="ADMAIF<i> Mux" I2S2 $ arecord -D hw:APE,<i-1> -r <rate> -c <channels> -f <sample_format> <out_wav>

Internal Loopback

Internal Loopback using I2S2 with ADMAIF<i>:

Copy
Copied!
            

$ amixer -c APE cset name="I2S2 Mux" "ADMAIF<i>" $ amixer -c APE cset name="ADMAIF<i> Mux" "I2S2" $ amixer -c APE cset name="I2S2 Loopback" "on" $ aplay -D hw:APE,<i-1> <in_wav> & $ arecord -D hw:APE,<i-1> -r <rate> -c <channels> -f <sample_format> <out_wav>

Multi-Channel (TDM) Capture

To perform TDM capture on I2S4 via ADMAIF, enter these commands:

Copy
Copied!
            

$ amixer -c APE cset name="ADMAIF<i> Mux" "I2S4" $ amixer -c APE cset name="I2S4 codec master mode" "cbs-cfs" $ amixer -c APE cset name="I2S4 codec frame mode" "dsp-a" $ amixer -c APE cset name="I2S4 FSYNC width" 0 $ arecord -D hw:APE,<i-1> -r <rate> -c <channels> -f <sample_format> <out_wav>

Where:

  • <i> and <i-1> respectively represent an ADMAIF instance number, and the number minus 1.

  • The last digit of I2S4 may be changed to use a different channel.

Note that “I2S4 codec frame mode” and “I2S4 fsync width” must be set to the data offset with regard to fsync and fsync width available from the I2S timing diagram in the codec data sheet. “I2S4 codec master mode” must be set as per the mode of operation (master/slave). For more details on mixer controls, see Codec Driver, I2S, Mixer Controls.

Examples: MVC

The following examples show how to apply gain and to mute and unmute the stream. The MVC supports up to eight channels, with control of per-channel gain and mute/unmute.

Apply Gain to a Playback Stream

This command model shows how to use the MVC module to control volume during playback on I2S:

Copy
Copied!
            

$ amixer -c APE cset name="MVC1 Mux" ADMAIF<i> $ amixer -c APE cset name="I2S1 Mux" MVC1 $ amixer -c APE cset name="MVC1 Volume" <Q8.24_Val> $ aplay -D hw:APE,<i-1> <in_wav>

The MVC module supports per-channel volume control. That is, it can apply a different gain factor to each channel. To set per-channel volume, use this mixer control:

Copy
Copied!
            

$ amixer -c APE cset name="MVC1 Channel<x> Volume" <Q8.24_Val>

Where <x> is the MVC channel number (1, 2 … 8).

Mute and Unmute Channels

This example shows how to mute and unmute channels during I2S playback:

Copy
Copied!
            

$ amixer -c APE cset name="MVC1 Mux" ADMAIF<i> $ amixer -c APE cset name="I2S1 Mux" MVC1 $ amixer -c APE cset name=”MVC1 Per Chan Mute Mask” <mask> $ aplay -D hw:APE,<i-1> <in.wav>

Where <mask> is the mute/unmute mask value. The mask supports per-channel mute control. The mask’s value may be 0 to 255 (0x0 to 0xFF); to mute channel n of the stream, set bit n to 1. Similarly to unmute channel n of the stream, set bit n to 0.

Examples: AMX

These sections provide usage examples for multiplexing two and three streams and for demultiplexing one stereo stream into two mono streams.

Multiplexing Two Streams

This example shows how to use the AMX module to multiplex two stereo streams, ADMAIF1 and ADAMIF2:

Copy
Copied!
            

$ amixer -c APE cset name="AMX2 RX1 Mux" "ADMAIF1" $ amixer -c APE cset name="AMX2 RX2 Mux" "ADMAIF2" $ amixer -c APE cset name="AMX2 Output Audio Channels" 4 $ amixer -c APE cset name="ADMAIF<i> Mux" AMX2 $ amixer -c APE cset name="ADMAIF<i> Playback Audio Channels" 4 $ amixer -c APE cset name="ADMAIF<i> Capture Audio Channels" 4 $ amixer -c APE cset name="ADMAIF<i> Playback Client Channels" 4 $ amixer -c APE cset name="ADMAIF<i> Capture Client Channels" 4 $ amixer -c APE cset name="AMX2 Byte Map 0" 0 $ amixer -c APE cset name="AMX2 Byte Map 1" 1 $ amixer -c APE cset name="AMX2 Byte Map 2" 2 $ amixer -c APE cset name="AMX2 Byte Map 3" 3 $ amixer -c APE cset name="AMX2 Byte Map 4" 4 $ amixer -c APE cset name="AMX2 Byte Map 5" 5 $ amixer -c APE cset name="AMX2 Byte Map 6" 6 $ amixer -c APE cset name="AMX2 Byte Map 7" 7 $ amixer -c APE cset name="AMX2 Byte Map 8" 64 $ amixer -c APE cset name="AMX2 Byte Map 9" 65 $ amixer -c APE cset name="AMX2 Byte Map 10" 66 $ amixer -c APE cset name="AMX2 Byte Map 11" 67 $ amixer -c APE cset name="AMX2 Byte Map 12" 68 $ amixer -c APE cset name="AMX2 Byte Map 13" 69 $ amixer -c APE cset name="AMX2 Byte Map 14" 70 $ amixer -c APE cset name="AMX2 Byte Map 15" 71 $ aplay -D hw:APE,0 <in1_wav> $ aplay -D hw:APE,1 <in2_wav> $ arecord -D hw:APE,<i-1> -r 48000 -c 4 -f S16_LE <out_wav>

Examples: ADX

This example shows how to use the ADX module to demultiplex 16-bit stereo streams onto ADMAIF1 and ADMAIF2:

Copy
Copied!
            

$ amixer -c APE cset name="ADX1 Mux" ADMAIF<i> $ amixer -c APE cset name="ADX1 Input Audio Channels" 2 $ amixer -c APE cset name="ADMAIF1 Mux" "ADX1 TX1" $ amixer -c APE cset name="ADMAIF2 Mux" "ADX1 TX2" $ amixer -c APE cset name="ADX1 Output1 Audio Channels” 1 $ amixer -c APE cset name="ADX1 Output2 Audio Channels” 1 $ amixer -c APE cset name="ADX1 Byte Map 0" 0 $ amixer -c APE cset name="ADX1 Byte Map 1" 1 $ amixer -c APE cset name="ADX1 Byte Map 2" 2 $ amixer -c APE cset name="ADX1 Byte Map 3" 3 $ amixer -c APE cset name="ADX1 Byte Map 4" 64 $ amixer -c APE cset name="ADX1 Byte Map 5" 65 $ amixer -c APE cset name="ADX1 Byte Map 6" 66 $ amixer -c APE cset name="ADX1 Byte Map 7" 67 $ aplay -D hw:APE,<i-1> <in_wav> $ arecord -D hw:APE,0 -r 48000 -c 1 -f S16_LE <out1_wav> $ arecord -D hw:APE,1 -r 48000 -c 1 -f S16_LE <out2_wav>

Examples: SFC

This example shows how to perform sample rate conversion from 48000 to 44100 Hz and capture using ADMAIF2, where ADMAIF3 feeds the SFC1 and generates sample frequency-converted output:

Copy
Copied!
            

$ amixer -c APE cset name="SFC1 Mux" ADMAIF3 $ amixer -c APE cset name="ADMAIF2 Mux" SFC1 $ amixer -c APE cset name="SFC1 Input Sample Rate" 48000 $ amixer -c APE cset name="SFC1 Output Sample Rate" 44100 $ aplay -D hw:APE,2 <in_wav> $ arecord -D hw:APE,1 -r 44100 -c <channels> -f <sample_format> <out_wav>

Examples: Mixer

This example shows how to mix two input streams to generate a single output stream via Adder1 of the Mixer module:

Copy
Copied!
            

$ amixer -c APE cset name="MIXER1 RX1 Mux" ADMAIF1 $ amixer -c APE cset name="MIXER1 RX2 Mux" ADMAIF2 $ amixer -c APE cset name="MIXER1 Adder1 RX1" 1 $ amixer -c APE cset name="MIXER1 Adder1 RX2" 1 $ amixer -c APE cset name="MIXER1 Mixer Enable" 1 $ amixer -c APE cset name="ADMAIF3 Mux" MIXER1 TX1 $ aplay -D hw:APE,0 <inputfile1.wav> $ aplay -D hw:APE,1 <inputfile2.wav> $ arecord -D hw:APE,2 -r <rate> -c <channels> -f <sample_format> <out_wav>

Examples: HDMI/DP Playback

This example shows how to perform playback on an HDMI/DP device (e.g. a monitor with speakers):

Copy
Copied!
            

$ aplay -Dhw:HDA,<devID> <in_wav>

Examples: USB

The following sections provide usage examples of playback and capture on USB.

Playback

This example shows how to perform playback on a USB device:

Copy
Copied!
            

$ aplay -Dhw:<cardID>,<devID> <in_wav>

Capture

This example shows how to perform capture on a USB device:

Copy
Copied!
            

$ arecord -Dhw:<cardID>,<devID> -r <rate> -c <channels> -f <sample_format> <out_wav>

This section describes some issues that are liable to occur when you are working with ASoC drivers, and their probable causes and solutions.

No Sound Cards Found

This has several possible causes. Some typical ones are described below. In most cases the dmesg output can provide clues.

Source/Sink Widget Not Found

The dmesg output shows that “no source widget” or “no sink widget” was found, as shown in this example log:

Copy
Copied!
            

$ dmesg | grep "ASoC" tegra-asoc: sound: ASoC: no source widget found for x OUT tegra-asoc: sound: ASoC: Failed to add route x OUT -> direct -> Headphone Jack tegra-asoc: sound: ASoC: no sink widget found for x IN tegra-asoc: sound: ASoC: Failed to add route Mic Jack -> direct -> x IN

In the above log, x OUT and x IN widgets are not found. ASoC may not have instantiated corresponding codecs. Confirm this by checking below:

Copy
Copied!
            

$ cat /sys/kernel/debug/asoc/components

If the codec is not instantiated, it could be due to one of these reasons:

  • The codec is not enabled in the Linux kernel configuration. Enter these commands to determine whether the codec is enabled:

    Copy
    Copied!
                

    $ zcat /proc/config.gz | grep <codec_config>

    Where <codec_config> is the name of the config that represents the codec in config.gz. Users must define it if it is not already available, and you must ensure that it is enabled in the Linux kernel configuration.

    Enter below command to scan the desired I2C bus and confirm that the codec is being probed:

    Copy
    Copied!
                

    $ i2cdetect -y -r <i2c-bus-number>

    If the scan does not indicate that the codec is present, it could be due to a loose connection, or the codec could be connected to another I2C bus. To check for the latter cause, scan the rest of the available I2C buses, identify the bus that is connected to the codec, and place the codec device tree node in the that I2C bus’s DT node.

  • The widget’s prefix (x in this case) is neither the same as the one specified in the prefix entry of the codec subnode of DAI link, nor the same as the one specified under the sound-name-prefix entry of the corresponding codec device node. In this case, edit or override the prefixes appropriately.

CPU DAI Not Registered

The dmesg output shows that no “CPU DAI” was found:

Copy
Copied!
            

$ dmesg | grep "ASoC" tegra-asoc: sound: ASoC: CPU DAI DAP not registered

In this case, “DAP” is the CPU DAI for the I2S-to-codec DAI link.

The ASoC may not have instantiated the I2S codec. To determine whether the codec is instantiated, enter the command:

Copy
Copied!
            

$ cat /sys/kernel/debug/asoc/components

If the I2S codec is instantiated, it has a name like <addr>.i2s, where <addr> is the corresponding unit-address (i2s@<addr>) used in DT for the device.

Identifying the DAI link at the point of failure can give a clue to the I2S instance number that failed to instantiate. Accordingly, you can instantiate the I2S codec driver by providing a suitable entry point in the device tree structure (DTS) file as described in Codec Driver Instantiation Using Device Tree.

Sound Not Audible or Not Recorded

Follow this procedure to diagnose the issue:

  1. Determine whether the DAPM path is completed. User may need to set some codec-specific mixer controls to enable playback or capture. Get these settings from the codec vendor or from the codec data sheet. For tracing the DAPM path, DAPM tracing events must be enabled before user run the playback or capture use case using the command:

    Copy
    Copied!
                

    $ for i in `find /sys/kernel/debug/tracing/events -name "enable" | grep snd_soc_`; do echo 1 > $i; done

    If the DAPM path is not complete, the use case cannot proceed. The DAPM path is populated in the file below as and when it is set up:

    Copy
    Copied!
                

    $ cat /sys/kernel/debug/tracing/trace_pipe | grep \*

    Below is a complete sample DAPM path for recording through the microphone jack on IGX Orin through an RT5640 audio codec, ADMAIF1, and I2S1. Another audio path will produce a similar dump, depending on the widgets defined in the path. Here is a filtered log for the sake of illustration:

    Copy
    Copied!
                

    snd_soc_dapm_path: *CVB-RT AIF1 Capture <- (direct) <- CVB-RT AIF1TX snd_soc_dapm_path: *CVB-RT AIF1 Capture -> (direct) -> rt5640-playback-capture snd_soc_dapm_path: *CVB-RT AIF1TX -> (direct) -> CVB-RT AIF1 Capture [ ... ] snd_soc_dapm_path: *CVB-RT IN1N -> (direct) -> CVB-RT BST1 snd_soc_dapm_path: *CVB-RT IN1P -> (direct) -> CVB-RT BST1 snd_soc_dapm_path: *CVB-RT IN2N -> (direct) -> CVB-RT BST2 snd_soc_dapm_path: *CVB-RT IN2N -> (direct) -> CVB-RT INR VOL snd_soc_dapm_path: *CVB-RT IN2P -> (direct) -> CVB-RT BST2 snd_soc_dapm_path: *CVB-RT IN2P -> (direct) -> CVB-RT INL VOL snd_soc_dapm_path: *CVB-RT Mic Jack -> (direct) -> CVB-RT IN1P snd_soc_dapm_path: *CVB-RT Mic Jack -> (direct) -> CVB-RT IN2P [ ... ] snd_soc_dapm_path: *I2S4 CIF-Capture <- (direct) <- I2S4 TX snd_soc_dapm_path: *I2S4 CIF-Capture -> (direct) -> tegra-dlink-64-capture snd_soc_dapm_path: *I2S4 DAP-Playback -> (direct) -> I2S4 TX snd_soc_dapm_path: *I2S4 DAP-Playback <- (direct) <- rt5640-playback-capture snd_soc_dapm_path: *I2S4 XBAR-Playback -> (direct) -> I2S4 XBAR-RX snd_soc_dapm_path: *I2S4 XBAR-Playback <- (direct) <- tegra-dlink-64-capture

    Users must ensure that there is a valid DAPM path from source widgets to sink widgets. This dump gives a platform DAPM path involving all the components that get activated during a use case.

  2. Confirm that the audio interface’s status property is set to "okay" in the appropriate device tree source file.

    For example, for IGX Orin, the device tree file is at:

    Copy
    Copied!
                

    hardware/nvidia/t23x/nv-public/tegra234-p3701.dtsi

    An alternative method is to use the following command to inspect the device tree entries from the target and find the .dts file that has been flashed:

    Copy
    Copied!
                

    $ dtc -I fs -O dts /proc/device-tree >/tmp/dt.log

  3. Probe the audio signals with an oscilloscope.

    For example, if using I2S, probe the frame sync (FS) and bit clock (BCLK) to verify that the timings are correct. If the I2S is transmitting, probe FS and BCLK to verify that they are generated as desired.

I2S Software Reset Failed

A common problem is that the I2S software reset fails when starting playback or capture via an I2S interface. Error messages like this one appear in the dmesg log:

Copy
Copied!
            

tegra210-i2s 2901000.i2s: timeout: failed to reset I2S for playback tegra210-i2s 2901000.i2s: ASoC: PRE_PMU: I2S1 RX event failed: -22

This problem occurs when the clock for the I2S interface is not active, and hence the software reset fails. It typically occurs when the I2S interface is the bit clock slave and hence the bit clock is provided by an external device such as a codec. If this problem occurs, check whether the bit clock is being enabled when the playback or capture is initiated.

XRUN Observed During Playback or Capture

An XRUN is either an underrun (on playback) or overrun (on capture) of the audio circular buffer.

In the case of playback, the CPU writes to the audio circular buffer. The DMA reads it and sends the data to the appropriate audio interface (I2S, etc.) via the AHUB.

In the case of capture, the DMA writes data received from the AHUB to the audio circular buffer, and the CPU reads it.

An XRUN event typically indicates that the CPU is unable to keep up with the DMA. In the case of playback, the DMA reads stale data. In the case of capture, data is lost. Hence, an XRUN event can signify a system performance or latency issue, which can have many different causes.

If an XRUN occurs, try these measures to determine whether there is a performance issue:

  • Enable maximum performance by running jetson_clocks.sh. This script is in the user home directory on the IGX Orin device’s root file system.

  • Use a RAM file system for reading and writing the audio data. The default root file system format for IGX Orin devices is EXT4 with journaling enabled. Latencies have been observed with journaling file systems such as EXT4, and can lead to XRUN events. Enter these commands to create a simple 100 MB RAM file system:

    Copy
    Copied!
                

    $ sudo mkdir /mnt/ramfs $ sudo mount -t tmpfs -o size=100m tmpfs /mnt/ramfs

  • User can increase the size of the audio circular buffer to reduce the impact of system latencies. The default size of the buffer is 32 KB. The buffer size is specified by the buffer_bytes_max member of the structure tegra_alt_pcm_hardware in the Linux kernel source file:

    Copy
    Copied!
                

    kernel/3rdparty/canonical/linux-jammy/kernel-source/sound/soc/tegra/tegra_pcm.c

Audio Pops and Clicks

Pops and clicks may occur at the start or end of playback or capture because I2S starts transmitting or receiving data before the codec is completely powered up or down.

The following command delays transmission or reception of data by a specified number of milliseconds:

Copy
Copied!
            

$ echo 10 | sudo tee /sys/kernel/debug/asoc/APE/dapm_pop_time

Get More Help on NVIDIA Developer Forum

If none of the preceding steps help, post a query to the appropriate section of the NVIDIA Developer Forum, providing the following information:

  1. Conditions under which the problem is manifested: sampling rate, sample width, etc.

  2. Mixer control settings. Enter this command to display the settings:

    Copy
    Copied!
                

    $ amixer – c <cardID> contents > ~/settings.txt

  3. Kernel log. Enter this command to display it:

    Copy
    Copied!
                

    $ dmesg > ~/kernel_log

  4. Device tree log. Enter this command to display it:

    Copy
    Copied!
                

    $ dtc -I fs -O dts /proc/device-tree >/tmp/dt.log

  5. Oscilloscope snapshots at an appropriate resolution, with and without the codec.

  6. Register dump of I2S being used while running the use case, for example:

    Copy
    Copied!
                

    $ cat /sys/kernel/debug/regmap/<addr>.i2s/registers > ~/reg_dump

    where <addr> is the unit-address of I2S device (i2s@<addr>) in DT. Use the same for lookup of corresponding regmap path.

Previous Flashing the dGPU with ARM VBIOS
Next GPIO Support
© Copyright © 2024, NVIDIA Corporation. Last updated on Jun 10, 2024.