Site Tools


tech:rpi_i2s_audio

I2S Audio on Raspberry Pi 2 / B+

I2S is a digital audio bus that is commonly used. The Raspberry Pi B+ and Raspberry Pi 2 both now have an I2S audio driver. This page is a reference for when I was making my own DAC boards using some of TI's DAC IC's. Check out my I2S Audio Amp.

Hardware Connections

I2S pinout connections for Raspberry Pi B+ / Raspberry Pi 2

I2S requires 3 digital pins: the bit clock (BCK), the word clock or left/right clock (LRCK), and the data line (DOUT). All 3 of these pins are located on the main I/O header, J8. (note that the Raspberry Pi model B has these pins on a different header)

Pi Setup

Disable onboard audio

sudo nano /etc/modules

# snd_bcm2835	# comment out this line to disable onboard audio	

Setup I2S Driver

sudo nano /boot/config.txt
Add one of the following lines to the end of the config file.

PCM5102A

dtoverlay=hifiberry-dac

PCM5122

HiFiBerry DAC+

dtoverlay=hifiberry-dacplus

IQaudio DAC+

dtoverlay=iqaudio-dacplus

Create config file (no mixing)

sudo nano /etc/asound.conf

pcm.!default  {
 type hw card 0
}
ctl.!default {
 type hw card 0
}

Create config file (with mixing)

sudo nano /boot/config.txt

dtoverlay=i2s-mmap		# for mixing

sudo nano /etc/asound.conf

pcm.i2s_dac { 
	type hw card 0 
}

pcm.!default { 
	type plug 
	slave.pcm "dmixer" 
}

pcm.dmixer { 
	type dmix 
	ipc_key 1024 
	slave { 
		pcm "i2s_dac" 
		channels 2 
	} 
}

ctl.dmixer { 
	type hw 
	card 0 
}

Finish

sudo reboot

Tested Devices

Raspberry Pi 2 Model B

Linux raspberrypi 3.18.11-v7+ #777 SMP PREEMPT Sat Apr 11 17:30:37 BST 2015 armv7l GNU/Linux
tech/rpi_i2s_audio.txt · Last modified: 2016-07-19 21:15 by daniel