Skip navigation

Hi ,

I want to  build rpi-linux-rpi-4.0.y source code which i have downloaded from github to make an image which can support cirrus audio logic card. I have tried the procedure building the code from the github, i got the kernel image also. After reboot output of aplay -l shows only bcm2835 device not cirrus logic card device.

 

Please help me asap .....

Audio paths

 

Note: I don't have the card yet, so I don't know actual alsa names for these settings, but they are very similar to those in the datasheet.

 

You can check the diagrams on page 57-58 of WM5102 datasheet Data Sheet of WM5102.

WM5102 is a versatile device and you can set different audio paths within its digital core. Furtunately it seems almost all of it is possible via alsamixer.

Outputs

WM5102 has many outputs, most of them available on our card. The most usable outputs are OUT1L/P (Line out, HPOUT2L/P in alsa), OUT2L/P (headphones, HPOUT1L/P in alsa) and OUT4L/P (speaker outputs via integrated 2W amplifier, SPKOUTL/P in alsa). Other outputs are OUT3 (earpiece) and OUT5L/P (PDM digital speakers) and there is also SPDIF output (AIF2TX1/2 - stereo).

Each of these outputs have its own mixer with 4 sources, each source having its own input volume. Output then have its own master volume. So you can output combination of any 4 sources into each output.

 

Inputs

WM5102 is connected to our RPi via AIF1 bus running in i2s mode. AIF1RX (stereo) is audio going from RPi to card, AIF1TX is audio from card to RPi (if you want to record anything on RPi, you need to route audio to this output).

WM5102 has several physical inputs: SPDIF (AIF2RX1/2 - stereo), Line-in (IN3L/R), Headset microphone, integrated digital mics. Each input has both analog PGA "volume" (gain of input amplifier) and digital *_VOL volume.

WM5102 has also internal "inputs": 1kHz tone generator, white noise generator and all DSP functions act as inputs also.

 

Effects

It has 4x parametric equaliser (EQ1/2/3/4 - each is mono, so you can use 2 different equaliser for 2 stereo signals),

4x low/high pass filters (LHPF1/2/3/4) and dynamic range controller (DRC1). These also have their internal 4-way mixers, so their input can be combination of any 4 signals (each with own volume control).

 

Routing

You can for example route signal from Line-in throught EQ, from EQ to LHPF and from there to another EQ and finally either to RPi or to Line-out/SPDIF (or to both).

 

Here is picture of how looks a output with its 4-way own mixer:

shot00305.png

In alsa, for each output there is a setting with names "xyz Input 1" to "xyz Input 4". Usually you will use just the first input, but you can use all 4 to mix them. Each of them also has Volume setting "xyz Input 1 Volume"(??). So to route signal from Line-in to EQ and from there to Line-out, you can use these commands:

# Route LineIn input IN3{1,2} through equalizers EQ{1,2} to Line Out.

# IN3 --> EQ --> HPOUT2

amixer -Dhw:0 cset name='EQ1 Input 1' IN3L

amixer -Dhw:0 cset name='EQ2 Input 1' IN3R

amixer -Dhw:0 cset name='HPOUT2L Input 2' EQ1

amixer -Dhw:0 cset name='HPOUT2R Input 2' EQ2

 

Using Parametric EQ and Low/High-Pass filters

 

To use these filters you have to first route some audio to them and from them to some output (see above). (It seems that alsa implements these only as 1-input and not 4-input).

The next step is to configure them.

For EQ, you can configure 5 frequency bands. First band can be either shelving or peak filter, last band is a shelving filter. Each peak filter has a gain (-12 dB to +12 dB; alsa name "EQx Bz Volume" with values 0-24, z is band 1-5), frequency and width (also called Q value). Shelving filters have only gain and frequency. Frequency and band are set in "EQx Bz Coefficients" (see next section).

 

For LHPF, you can only set cut-off frequency and set the filter as low- or high-pass. It seems that the filter is Butterworth. At cut-off freq it will have -3 dB, with -6 dB/octave slope. Alsa name is "LHPFx" as source and "LHPF1 Coefficients" for the settings and "LHPF1 Mode" to set low/high-pass.

 

How to get those magical coefficients

 

Datasheet refers to the "WISCE evaluation board control software". Fortunately this is free, however it is not so straightforward to get to the WM5102 device profile as it is not listed between eval boards to download.

First download & install the WISCE software from http://www.wolfsonmicro.com/support/wisce/

Then from http://www.wolfsonmicro.com/products/evaluation-boards/wm5102ev1m/ download the "WISCE™ Install kitDevice Pack for WM5102EV1M" (last one on the right grey column).

When you start WISCE it will load a profile for our WM5102 and display a warning that it can't find the eval board and will run in standalone mode. That is OK. To configure EQ, just click on EQ1/2/3/4 in the top menu (after the toolbar, with labels only). You will see screen like this:

shot00303.png

There you can play with the settings and see the result on graph. However it seems that the graph is weird when combining overlapping bands. I don't know if it issue only on this simulator or also in the device itself. According to graph when I have 2 filters on the same freq with -12 dB, it won't be -24 dB but something like -6 dB. The "B P" checkbox changes the first band to be either shelving or band-pass filter.

When you are happy with your selection, change the view in top menu to "Registers" and find registers for you EQ/LHPF (for EQ they are around R-E10h, for LHPF around R-EC1h; look at datasheet from page 68). You will know from the register name that it is the correct one . Then use the value from register in your alsa command (but alsa requires value in decimal format, not hex - so either convert manually or change appl settings to display in dec, but then also register addrs will be in dec).

shot00306.png

So to get set LHPF2, you take the value of "MODE=1" in Reg-EC4h and value F8ADh from Reg-EC5h. The coefficients need to be entered as 2 byte values separated by comma in alsa. So we convert from hex F8,AD to decimal 248,173 and set this as value to "LHPF2 Coefficients".

 

For EQ it is little more complicated, as there are multiple gains stored in one register:

shot00307.png

For example for EQ1, the gains are in registers R-E10h and R-E11h. You need to take value of each gain separately and convert it from binary to decimal (for EQ1_B1_GAIN it would be from 01100 binary to 12 decimal, which is 0 dB). The coefficients for each band are in 3 registers (EQ1_B1_A / B / PG). So for EQ1 Band1, you get values FC8h, 404h and E0h (4040, 1028, 224 in decimal).

But I'm not sure how to set these values in alsa as alsa has only one parameter "EQ1 Coefficients" for all 5 bands. You can check with command "amixer -Dhw:0 cget name='EQ1 Coefficients' ". I will check & try once I get the card delivered.

wolf.jpg

 

This audio card will push your Pi.

 

The Wolfson Audio CardWolfson Audio Card has taken a good amount of time to come forth from Wolfson Microelectronics and with decent reason. They want to make sure that they have it right and something that you can work with. As with any audio setup it takes a little time to optimise and get it setup correctly, but once you're there then you have a potentially powerful portable audio sensation in your hands. The audio codec with digital signal processor for voice, WM5102 even won an award in 2013 for innovation from the Institute of Engineers and Technology (IET)


The package for the Wolfson Audio Card comes in the standard Raspberry PiRaspberry Pi add-on box that you may be used to if you've picked up a GertduinoGertduino or Pi FacePi Face. The box clearly informs you as to the features the device comes with and where to go for more information. Chances are you're going to need it.

 

Upon opening the packaging you're presented with the regulation anti-static bag containing your card along with a slip of paper covering regulations compliance and rather curiously, a plastic screw. It seemed odd at first why there was a lone screw in the box, but once I fitted the audio card to the Raspberry Pi it became clear.

 

To ensure that the boards push/pogo-pins make contact with the Raspberry Pi, using an unpopulated header next to the GPIO breakout it needs the screws to make sure that the board is pushed securely to the Pi. I found it stranger that it wasn't a metal screw, but this makes sense after making sure that it was fully in, it potentially touches on some on-board circuitry and we wouldn't want any short-outs to happen.

 

Before getting started with the setup, make sure that you have any USB devices that you're going to use with it, plugged in. I had the unfortunate experience later when I exchanged my USB devices for others that the Raspberry Pi restarted. There is warning of using USB hubs in the user manual so I suspect this is related and possibly an issue with power.

 

The best choice to get started is to write the SD Card image provided on element14 to get started with the card, there are a number of modifications and hacks to the stock Raspbian kernel and installed modules that have been necessary to get the device to work.

If you're running Windows then you can download Win32DiskImager to write the image to the SD Card, so long as you have Administrative rights and a way to connect your SD Card to your computer. Or if you're running Linux you can use the dd command to write it to your /dev/<device name> card. If you need to check this, then typing 'man dd' at a terminal will help you with the dd command, and typing 'dmesg' at a terminal will help you to determine what your SD Card is referred to as.

 

You have the option of downloading and compiling the kernel/driver source code and apply the patches to it to get it to work and then install the modules; but unless you're comfortable with cross-compiling on a faster computer and debugging any problems that occur you're going to be waiting a long time, not just for compiling on your Pi but also downloading the source files for the Raspbian kernel. Hopefully Wolfson Microelectronics or a member of the community will bring out a Raspbian package to install from or the changes will be integrated into the Raspbian OS by default in the future.

 

*Edit*: Ragnar Jensen has pulled out the compiled kernel and modules for the Wolfson Audio Card along with the use case scripts and put them into a compressed file that you can extract on your existing Raspbian installation. Note that this will lock you down to using a specific kernel that will not be updated when you update Raspbian, you can get it from here.

 

The SD Card needs to be of Class 6 or higher, especially if you want to read/write high quality audio, of note is that the Raspbian installation, which I downloaded at least, has been modified by Wolfson and attempts to overclock the Raspberry Pi to 900mhz with slight voltage alteration. This can be disabled in the config.txt in the /boot/ folder by finding the relevant lines and removing them.

 

So, let's test it by playing music! When you have booted your Pi with your audio card attached and SD Card setup you will want to open LXTerminal on the desktop, then type one of the relevant commands, assuming that you are in the /pi/home directory, based on how you want to listen to your music:

 

CommandDescription
./Playback_to_Headset.shIf you want to use the black headphone jack
./Playback_to_Lineout.shif you want to use a set of powered speakers from the LineOut jack
./Playback_to_Speakers.shif you want to use a set of speakers powered from/connected to the header(s) on the board
./SPDIF_playback.shUse the S/PDIF digital connection on the board

 

These scripts are located in the 'pi' user account home directory (/home/pi) and they are just a set of commands for setting up AlsaMixer (aka amixer, which PEarle has gone into more detail in his tasty write-up here: Wolfson Audio Card - Command Line recording ) to use the relevant device for outputting the audio. Once you're familiar with Alsa and the scripts you can edit these as you see fit, they commit themselves such that they're persistent after a reboot of the Pi.

 

Once you have setup your output, we can run Music Player from the desktop, the playlist is already populated, then just play away. These audio files are in a very nice .flac format which is a non-loss audio compression standard. For me there was some delay before the play started, and there were gaps, clicks and pops. This is because I was using a Class 4 SD Card, I changed this for a Class 6 and played just fine. It still wasn't very fast on occasion though, with this particular Raspbian installation there is a CPU usage monitor on the taskbar which was regularly sitting at 100% usage.

 

Now, to record on the Wolfson Audio Card is a different matter, it isn't straightforward to install audio software such as Audacity and just record. The best way to check it is to run a command from the terminal again. To setup AlsaMixer using the scripts you can choose one of the following, assuming that you are in the /pi/home directory:

 

CommandDescription
./Record_from_Headset.shRecords from the boom mic' on a headset
./Record_from_lineIn.shRecords from a powered/amplified device/microphone on the line in jack
./Record_from_DMIC.shRecords from the stereo microphones that are situated on the Wolfson Audio Card
./SPDIF_record.shRecords from the digital S/PDIF connector

 

For recording, unfortunately I do not have any S/PDIF equipment, or a boom microphone style headset, so I mainly tested the on board digital stereo microphones! I can confirm that they're definitely in stereo, record quite clearly with minimal post-cleanup, but the channels were opposite to how they are marked on the board (left was right and right was left). Which is just a minor point really.

 

audacity.jpg

 

In the picture to the left, in the audio file I recorded via command line and then loaded into Audacity you can see where I spoke into each left/right channel individually at an intentional offset.

 

You can also see what the record quality is like for silence up until that point, initially there is some raised audio level and the click of initialisation. It is probably a good idea to bare this in mind when you're recording and to do some post cleanup depending on what you're using it for.

 

The method suggested to record audio on the Wolfson Audio Card is specified in each of the .sh files, which you can run the command "less ./Record_from_DMIC.sh" to read. I didn't manage to get Audacity to record from the card directly as it only had options for S/PDIF - I am assuming this is because of how Audacity integrates with Alsa and that this is not currently setup in an ideal way even by switching with the scripts (use cases) provided. Edit: It's worth reading Ragnar's post below in the comments regarding using Audacity with the Wolfson Audio Card, in particular the post on altering the use case for the on board digital microphones (DC offset on microphones and workaround.).

 

All in all it's a nice little board but it's going to take a bit of polish and work from Raspbian/the Community/Wolfson microelectronics to get the process streamlined, but I'm thankful we now have the opportunity to do so! The results are definitely worth it.