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.