Xilinx ALSA Audio I2S driver
The purpose of this page is to describe the Linux ALSA SoC driver for I2S Rx/Tx SoftIP.
Table of Contents
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.
Typical system using I2S Rx and I2S Tx:
Following design depicts the typical audio I2S IP interfaces for audio recording and playback.In the following design, External I2S DAC(PMOD consisting of 3.5mm Jack) receives the data from audio source and transfers to I2S Rx where audio data is padded with AES header.On the other hand, I2STx IP removes AES header and renders PCM data through external DAC (PMOD with 3.5mm jack) to play audio on Speaker. Design uses audio formatter IP to send data from I2S to Memory and vice-versa.
The I2S 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 component is responsible for configuring the I2S core to generate proper LR clock and bit clock acting as master to connected codec. This I2S driver along with audio formatter and sound card drivers will create an I2S audio pipeline. This driver cannot be used as standalone.
The driver is available at https://github.com/Xilinx/linux-xlnx/blob/master/sound/soc/xilinx/xlnx_i2s.c
IP/Driver Features
IP Features | 2019.1 |
---|---|
Supports up to 4 I2S channels/8 audio channels | Supports only 2 channels |
AXI4-Stream compliant | Yes |
Supports 16- and 24-bit depths. | Yes |
Drivers is developed considering mclk fixed to 18.43MHz | Yes |
Known Issues & Limitations in Driver
Driver doesn't need FIFO Data Count.
Tested only 2 channel audio.
Sampling rates tested for capture are 48 and 96kHz.
Sampling rates tested for playback are 48, 96 and 192kHz.
Kernel Configuration
Below driver configs should be enabled.
CONFIG_SND_SOC=y
CONFIG_SND_SOC_XILINX_I2S=y
Device Tree Binding
The dts node should be defined with correct hardware configuration. How to define the node is documented -
: <=2024.2 xlnx,i2s.txt
>=2025.1 onwards:linux-xlnx/Documentation/devicetree/bindings/sound/xlnx,i2s.yaml at master · Xilinx/linux-xlnx
Below is the example device tree node for a simple I2S Tx and I2S rx pipeline.
i2s_receiver_0: i2s_receiver@b0010000 {
aud_mclk = <18431999>;
interrupts = < 0 91 4 >;
compatible = "xlnx,i2s-receiver-1.0" , "xlnx,i2s-receiver-1.0";
xlnx,dwidth = <0x18>;
xlnx,depth = <0x80>;
interrupt-parent = <&imux>;
xlnx,ip-name = "i2s_receiver";
reg = <0x0 0xb0010000 0x0 0x10000>;
clocks = <&cips_ss_0_clkx5_wiz_0 0>, <&misc_clk_0>, <&misc_clk_0>;
xlnx,num-channels = <0x1>;
xlnx,snd-pcm = <&audio_formatter_0>;
xlnx,i2srx-board-interface = "Custom";
xlnx,edk-iptype = "PERIPHERAL";
xlnx,is-master = <1>;
status = "okay";
clock-names = "aud_mclk" , "m_axis_aud_aclk" , "s_axi_ctrl_aclk";
xlnx,32bit-lr = <0>;
interrupt-names = "irq";
xlnx,name = "i2s_receiver_0";
};
i2s_transmitter_0: i2s_transmitter@b0020000 {
aud_mclk = <18431999>;
interrupts = < 0 92 4 >;
compatible = "xlnx,i2s-transmitter-1.0" , "xlnx,i2s-transmitter-1.0";
xlnx,dwidth = <0x18>;
xlnx,depth = <0x80>;
interrupt-parent = <&imux>;
xlnx,ip-name = "i2s_transmitter";
reg = <0x0 0xb0020000 0x0 0x10000>;
clocks = <&cips_ss_0_clkx5_wiz_0 0>, <&misc_clk_0>, <&cips_ss_0_clkx5_wiz_0 0>;
xlnx,num-channels = <0x1>;
xlnx,snd-pcm = <&audio_formatter_0>;
xlnx,edk-iptype = "PERIPHERAL";
xlnx,is-master = <1>;
xlnx,i2stx-board-interface = "Custom";
status = "okay";
clock-names = "aud_mclk" , "s_axi_ctrl_aclk" , "s_axis_aud_aclk";
xlnx,32bit-lr = <0>;
interrupt-names = "irq";
xlnx,name = "i2s_transmitter_0";
};
audio_formatter_0: audio_formatter@b0030000 {
xlnx,rx = <&i2s_receiver_0>;
interrupts = < 0 93 4 0 143 4 >;
compatible = "xlnx,audio-formatter-1.0" , "xlnx,audio-formatter-1.0";
xlnx,packing-mode-mm2s = <0>;
xlnx,mm2s-async-clock = <1>;
xlnx,tx = <&i2s_transmitter_0>;
xlnx,mm2s-addr-width = <64>;
interrupt-parent = <&imux>;
xlnx,s2mm-dataformat = <1>;
xlnx,ip-name = "audio_formatter";
reg = <0x0 0xb0030000 0x0 0x10000>;
xlnx,include-s2mm = <1>;
xlnx,max-num-channels-mm2s = <2>;
clocks = <&cips_ss_0_clkx5_wiz_0 0>, <&cips_ss_0_clkx5_wiz_0 0>, <&misc_clk_0>, <&misc_clk_0>;
xlnx,s2mm-async-clock = <1>;
xlnx,packing-mode-s2mm = <0>;
xlnx,edk-iptype = "PERIPHERAL";
xlnx,s2mm-addr-width = <64>;
status = "okay";
clock-names = "aud_mclk" , "m_axis_mm2s_aclk" , "s_axi_lite_aclk" , "s_axis_s2mm_aclk";
xlnx,mm2s-dataformat = <3>;
interrupt-names = "irq_mm2s" , "irq_s2mm";
xlnx,include-mm2s = <1>;
xlnx,max-num-channels-s2mm = <2>;
xlnx,name = "audio_formatter_0";
};
Test procedure
The driver has been tested using following tools:
ALSA Utilities.
Gstreamer Utilities.
Note:
Below examples assume sound card registered is #0, playback device is #0, record device is #1.
Input audio stream properties to be recorded are sampling rate of 48000 Hz, 24 bits per sample, 2 channels.
Procedure to test I2S with ALSA utilities
Recording a file: arecord tool is used to record the audio file.
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.
aplay -D hw:0,0 -fS24_LE -r 48000 -c 2 -d 30 -t raw file.raw
Device enumeration:
For record device:
arecord --device="hw:0,1" --dump-hw-params
For playback device:
aplay --device="hw:0,0" --dump-hw-params
Procedure to test I2S 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 on i2s driver.
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 record the audio file.
Gst-launch is using alsa sink plugin to enable recording on i2s driver.
gst-launch-1.0 filesrc location=48000.raw ! audio/x-raw,format=S24_32LE,rate=48000,channnels=2 ! alsasink device=hw:0,0
Procedure to test I2S Pass-Through
G-streamer and alsa-utils tools enables pass through design for the i2s Linux driver i.e i2s receiver is connecting to i2s transmitter. Below is the alsa command.
arecord -D hw:0,1 -f S24_LE -r 48000 -c 2 -t raw | aplay -D hw:0,0 -c 2 -f S24_LE -r 48000 -t raw
Boards Supported
Driver has been tested on the following boards.
ZCU106 Rev 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_i2s.c.
Change log
2025.1
Summary:
No changes on drivers
2024.2
Summary:
No changes on drivers
The Linux build flow for petalinux migrated to yocto flow.
Hence, for device tree related changes please refer: Video PL-IP Linux Drivers SDT Reference - Xilinx Wiki - Confluence
2024.1
Summary
No changes
2020.2
Summary
No changes
2020.1
Summary
No changes
2019.2
Summary
No change
2019.1
Summary:
Used Common Clock Framework (CCF) for I2S clock configurations.
Changed I2S driver data.
Synced with mainlined version
Commits:
2018.3
Summary
Initial release
Related Links
© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy