I've been working on a reworked driver, based on Linux kernel 4.9, that doesn't require out-of-tree patches to the upstream kernel modules. This driver also adds a lot of new features and bugfixes like fixed micbias setting on LineIn, exposing of WM8804 status and AES bits as ALSA controls and configurable minimum/maximum samplerate limits.
The driver is included in official RPi and Raspbian kernels since early 2017. Make sure your system is up to date and you are running RPi kernel 4.9.12 or newer.
Source code is available from the usual place https://github.com/raspberrypi/linux.
Please note: If you've been compiling from source please switch to the official RPi kernel source. I'm no longer maintaining the code in my development tree cirrus-ng-4.9.y
Add the following line to /boot/config.txt
to enable
the Cirrus Logic card driver
dtoverlay=rpi-cirrus-wm5102
Note: MMAP support is already enabled by default in kernel 4.9, you no
longer need to add the i2s-mmap
overlay.
The cirrus driver requires some manually defined module dependencies, if you fail to add them the driver won't load properly.
Create a file /etc/modprobe.d/cirrus.conf
with the
following content:
softdep arizona-spi pre: arizona-ldo1
Download cirrus-ng-scripts.tgz
and extract it for example in /home/pi/bin
.
wget http://www.horus.com/~hias/tmp/cirrus/cirrus-ng-scripts.tgz
mkdir bin
cd bin
tar zxf ../cirrus-ng-scripts.tgz
Note: If you had installed the older usecase scripts for kernel 4.4 you need to remove them.
You have to start the appropriate scripts before you can use the card. For example:
./Reset_paths.sh
./Playback_to_Lineout.sh
./Playback_to_SPDIF.sh
./Record_from_Linein.sh
On Raspbian the RPi on-board audio device snd-bcm2835
is
enabled by default. When you run aplay -l
you'll see
two cards, the Cirrus card sndrpiwsp
and the on-board
card bcm2835
.
If you don't need on-board audio you can disable it by removing
(or commenting out) the dtparam=audio=on
line from /boot/config.txt
.
#dtparam=audio=on
If you don't want to disable snd-bcm2835 or if you also have an USB audio device connected you might notice that the card numbers under which the drivers register will change. Sometimes the Cirrus card will card 0, sometimes on-board audio. The card number depends on which driver is registered first, which is purely random.
You can manually assign fixed card (slot/index) numbers using
the slot
option of the snd
module. For
example, if you want the Cirrus card always to be the first and
on-board audio the second one, add the following line to your
/etc/modprobe.d/cirrus.conf
file:
For kernel 4.9 add this line:
options snd slots=snd-soc-rpi-cirrus,snd-bcm2835
If something doesn't work as expected please post your questions in this thread on the element14 site.
In order to track down problems follow the steps below and include the URLs to the paste files in your post:
Add the following line to /boot/config.txt
to
enable devicetree debugging, then reboot your RPi.
dtdebug=1
Upload your /boot/config.txt
file, the
GPU firmware version, GPU firmware and linux kernel logs
and the outputs of lsmod
and aplay -l
.
The easiest way to do this is by using the pastebinit
command which is included in Raspbian. Enter the following
commands and include the URLs that are output on the
terminal in your post:
pastebinit /boot/config.txt
vcgencmd version | pastebinit
sudo vcdbg log msg 2>&1 | pastebinit
dmesg | pastebinit
lsmod | pastebinit
aplay -l | pastebinit