Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

...

...

...

...

The purpose of this page is to describe the Linux ALSA SoC driver for SPDIF transmitter/receiver SoftIP.

Table of contents

Table of Contents
maxLevel2

Introduction

The LogiCORE IP SPDIF/AES3 core is a digital audio interface controller that implements the PCM IEC 60958-3 interface features for transmitting and receiving audio data. The core can be configured as an SPDIF/AES3 audio data transmitter or an SPDIF/AES3 audio data receiver

...

HW IP Features

...

.

...

Typical System Using SPDIF Rx and Tx:

Following design depicts the typical SPDIF transmitter/receiver IP interfaces for audio playback and recording. In transmitter mode, audio from a source like file storage is fed to SPDIF

...

IP block configured in transmitter mode via Audio Formatter. Similarly, in receiver mode, incoming SPDIF audio is fed to SPDIF IP configured as receiver

...

then given to Audio Formatter IP and sent to DDR from which it can be saved to a file as PCM audio.

Image Modified

SW Driver Overview

The SPDIF audio Rx/Tx driver

...

is based on the ALSA framework(refer ASoC sound card). This driver registers one of the 'component' expected by the ALSA framework.This SPDIF audio driver along with

...

Audio Formatter and sound card drivers will create a SPDIF audio pipeline. Driver cannot be used as standalone.

...

Kernel Configurations

Code Block
themeMidnight
CONFIG_SND_SOC=y
SND_SOC_XILINX_SPDIF=y should be enabled.

Device Tree Binding

A sample binding is shown below and the description of DT property is documented at

The driver is present at https://github.com/Xilinx/linux-xlnx/blob/master

...

/sound/soc/xilinx/xlnx_spdif.c

HW IP Features

IP Features2019.1

Variable sampling rates (32/44.1/48/88.2/96/176.4/192 kHz)

Yes
Audio sample length of 16/20/24-bitYes
AXI4-Stream interface to carry audio samples in AES3 formatYes
2 audio channelsYes


Known Issues & Limitations

  • None

Kernel Configurations

Below driver configurations should be enabled.

Code Block
themeMidnight
spdif_0: spdif@80010000 {
	clock-names = "aud_clk_i", "s_axi_aclk", "m_axis_aclk";
    clocks = <&si570_1>, <&clk 71>, <&clk 71>;
    compatible = "xlnx,spdif-2.0";
    interrupt-parent = <&gic>;
    interrupts = <0 91 4>;
    reg = <0x0 0x80010000 0x0 0x10000>;
    xlnx,spdif-mode = <1>;
    xlnx,snd-pcm = <&audio_formatter_0>;
};
CONFIG_SND_SOC=y
SND_SOC_XILINX_SPDIF=y

Device Tree Binding

The dts node should be defined with correct hardware configuration. How to define the node is documented inxlnx,spdif.txt.

Test Procedure

The driver has been tested using following tools.

  1. ALSA Utilities.
  2. Gstreamer Utilities.

Note:

  1. Below examples assume sound card registered is #0, playback device is #0, record device is #1.
  2. Following is the recording audio file with 24bit bit depth, 48khz sampling frequency and 2 channel audio properties.

Procedure to test SPDIF audio with ALSA Utilities

Recording a file: arecord tool is used to record

...

the

...

audio file

...

.

Code Block
themeMidnight
arecord -Dhw:0,1  -fS24_LE -r 48000 -c 2  -d 30 -t raw file.raw

Playing a file: aplay tool is used to play the audio file.

Following is the playing audio file with 24bit bit depth, 48khz sampling frequency and 2 channel audio properties.

Code Block
themeMidnight
aplay -D hw:0,0 -fS24_LE -r 48000 -c 2  -d 30 -t raw file.raw

Device Enumeration:

For record device:

Code Block
themeMidnight
arecord --device="hw:0,1" --dump-hw-params


For playback device:

Code Block
themeMidnight
aplay --device="hw:0,0" --dump-hw-params


Procedure to test SPDIF audio with Gstreamer Utilities

Recording a file: gst-launch is used to record the audio file.

...

gst-launch is using alsa src plugin to enable recording with SPDIF driver.

Code Block
themeMidnight
gst-launch-1.0 alsasrc device=hw:1,1 ! queue ! audio/x-raw,format=S24_32LE,rate=48000,channnels=2 ! filesink location=48000.raw

Playing a file: gst-launch is used to play the audio file.

...

gst-launch is using alsa sink plugin to enable playback with SPDIF driver.

Code Block
themeMidnight
gst-launch-1.0 filesrc location=48000.raw ! audio/x-raw,format=S24_32LE,rate=48000,channnels=2  ! alsasink device=hw:0,0

Debug Capability

This page provides different tools and techniques useful for debugging audio issues encountered in Linux-based systems. The document is mostly focused on the Linux operating system and also describes the build-in ALSA driver tool to debug PCM ring buffer positions.

/proc/asound/card#/pcm0p/xrun_debug

Replace '#' with your card number (usually 0). This proc file can enable various debugging tools. The CONFIG_SND_PCM_XRUN_DEBUG, CONFIG_SND_VERBOSE_PROCFS, CONFIG_SND_DEBUG options must be enabled in your kernel (if xrun_debug proc file is present - this feature is enabled).

Code Block
themeMidnight
1   Basic debugging - show xruns in ksyslog interface.
2   Dump stack - dump stack for basic debugging
4   Jiffies check - compare the position with kernel jiffies (a sort of in-kernel monotonic clock), show what's changed when basic debugging is enabled
8   Dump positions on each period update call
16  Dump positions on each hardware pointer update call
32  Enable logging of last 10 ring buffer positions
64  Show the last 10 ring buffer position only once (when first error situation occurred)

To enable more features just do sum values of above (for example 1+2=3).

Some good value combinations:

Code Block
themeMidnight
# Enable basic debugging and dump stack
# Usefull to just see, if PCM stream is stopped for a reason (usually wrong audio process timing from scheduler)
echo 3 > /proc/asound/card0/pcm0p/xrun_debug


Boards Supported

Driver has been tested on the following boards

  1. ZCU106 Rev

...

Change Log

  1. Corrected format of this page to make it uniform with the other documents.

Related Links

...

Linux Drivers

...

Create ASoC sound Card

  1. 1.0

Mainline Status

This driver is upstreamed and present at, https://

...

git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/xilinx/xlnx_spdif.c.

Change Log

2019.1

  • Summary:
    • Initial release
  • Commits:
    • f8def0f    - ASoC: xlnx: use clock framework for clocks to SPDIF.
    • 24ebbbc - ASoC: xlnx: add SPDIF audio driver.

Related Links