The purpose of this page is to describe the Linux ALSA CPU Dai driver for I2s Rx and Tx SoftIP.

Introduction

The Xilinx® LogiCORE™ IP I2S Transmitter and Receiver cores are soft Xilinx IP core for use with the Xilinx Vivado® Design Suite. These IPs provide easy way of sending/receiving PCM audio over I2S interface and IPs provide an easy way to interface I2S based audio DAC/ADC. These IPs requires minimal register programming. Further, the IPs support any audio sampling rates.

Features:
  • Up to 4 I2S channels
  • AXI4S compliant
  • Supports up to 8 audio channels.

Typical system using I2S Rx and I2S Tx


The following figure shows the data flow from i2s rx to i2s tx. In the design, External I2S DAC(video FMC card consist of 3.5mm Jack) receives the data from audio source to I2S Rx where audio data is encoded into AES and audio data is sampled at 48KHz with 24bit depth and transferred to i2s Tx. I2S Tx further decodes the audio data and send it over Video FMC's Line Out interface to play audio on Speaker.

typicalflow.JPG

Driver Overview

The I2S Rx/Tx driver (xilinx_iis.c) is based on the ALSA framework. It creates a device node(/dev/snd/pcmCxDx*) which can be used to query and configure the I2S Rx IP and also exposes various ALSA audio parameters Like: Sampling Rate, No.of channels and bit depth which can be used to configure the subsystem.

Kernel Configuration options for Driver

CONFIG_SND_SOC_XILINX_IIS should be enabled.

Device Tree Binding

        i2s_receiver_0: i2s_receiver@80050000 {
            compatible = "xlnx,i2s-receiver-1.0";
            interrupt-parent = <&gic>;
            interrupts = <0 89 4>;
            bit_width = <0x18>;
            mclk_freq = <0x180>;
            reg = <0x0 0x80050000 0x0 0x10000>;
        };
        i2s_transmitter_0: i2s_transmitter@80020000 {
            compatible = "xlnx,i2s-transmitter-1.0";
            interrupt-parent = <&gic>;
            interrupts = <0 93 4>;
            bit_width = <0x18>;
            mclk_freq = <0x180>;
            reg = <0x0 0x80020000 0x0 0x10000>;
        };

Test Procedure

The driver has been tested using following tools:
1. ALSA Utilities.
2. Gstreamer Utilities.

Procedure to test I2s with ALSA Utilities

Recording a file: arecord tool is used to record the audio file with 24bit bit depth, 48khz sampling frequency and 2 channel audio properties.
arecord -D hw:0,1 -f S32_LE -r 48000 -c 2 ./test.wav
Playing a file: aplay tool is used to play the audio file with 24bit bit depth, 48khz sampling frequency and 2 channel audio properties.
aplay -D hw:0,0 -f S32_LE -r 48000 -c 2 ./test.wav

Procedure to test I2s with Gstreamer Utilities

Recording a file: gst-launch is used to record the audio file with 24bit bit depth, 48khz sampling frequency and 2 channel audio properties. Gst-launch is using alsa src plugin to enable recording on i2s driver.
gst-launch-1.0 -v alsasrc device=hw:0,1 num-buffers=1000 ! wavenc ! filesink location="test.wav"
Playing a file: gst-launch is used to record the audio file with 24bit bit depth, 48khz sampling frequency and 2 channel audio properties. Gst-launch is using alsa sink plugin to enable recording on i2s driver.
gst-launch-1.0 filesrc location=/home/root/test.wav ! wavparse ! alsasink
or
gst-play-1.0 /home/root/test.wav

Pass Through i2s driver testing Procedure

G-streamer and alsa-utils tools enables pass through design for the i2s Linux driver i.e i2s receiver is connecting to i2s transmitter.

arecord -D hw:0,1 -f S32_LE -r 48000 -c 2 | aplay -D hw:0,0 -c 2 -f S32_LE -r 48000
or
gst-launch-1.0 alsasrc device=hw:0,1 ! 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).
 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 occured)
To enable more features just do sum values of above (for example 1+2=3).
Some good value combinations:
 # 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 D

Change log


Related Links