APQ8016 IIR Filter Configuration

“Stereo Connector and Audio Routing on DragonBoard 410c Application Note” (September 2016) lists, on page 16, two IIR filter blocks in a filter signal chain which take in {DEC1 DEC2 Rx1 Rx2 Rx3} into a mux, and outputs IIR1 or IIR2. These can then be routed through to the output signal path.

I have successfully used AlsaMixer to configure the signal routing and gain staging. I am unable to figure out how to configure the IIR filters.

I have three questions

  • What is the default configuration for the IIR filter block?
  • Where can i manipulate these filters?
  • Where does this processing take place (DSP or processor)?

for anyone interested, more info on this was found via IRC:

[11:09] dav: mainline wcd codec for 8016 does not support IIR filter configuration yet.
[11:10] dav: mainline codec does support the mux for this setup, Only thing that is missing is the mixer control for configuring the iir parameters
[11:11] dav: AFAIU it should be trivial to add IIR BAND setup mixers to the existing codec.
[11:12] how can i do that?
[11:12] dav: are you planning to use these filters or are you trying to just test audio?
[11:12] srinik: i am planning to use these filters to condition audio before it reaches our speakers
[11:14] dav: you would need to port this msm8x16-wcd.c « codecs « soc « sound - working/qualcomm/kernel.git - Qualcomm Landing Team kernel to msm8916-wcd-digital.c « codecs « soc « sound - kernel/git/torvalds/linux.git - Linux kernel source tree

Hi @davabrams:

Sorry about the delay replying, I have been away for a week, although I did see this and I have asked the internal experts about the IIR filters, I don’t have a full response yet.

The IIR filters are dedicated hardware pipelines, they are not software running on the main processor, or on the DSP.

Other little tidbits I have found are

  1. The filters are 5 stage IIR filters
  2. the filters are intended for sidetone equalization.

The consequence of 1) is you probably couldn’t do a lot of equalization for your application since there is only 5 stages, but if you are doing a very simple equalization it may be enough.

I haven’t figured out all of the consequences if 2), but I fear that you may not be able to route anything other than the MIC into the IIR filters and the output can only be routed to the speakers.

Of course I am not 100% sure about any of this, I will keep you updated as I discover more about the IIR filters.

Other related news is we are really close to enabling user programs on the DSP. When this becomes available you will be able to write your own filtering, run it on the DSP, and do any equalization your desire.

Full disclosure: I am an employee of Qualcomm Canada, any opinions I have expressed in this or any other post may not reflect the opinions of my employer.

1 Like

So I gave porting the IIR code from 3.18 to 4.14 a shot, and using the patch below populates mixer controls for both IIR1 and IIR2. However, I cannot tell if the levels applied to either of the IIR filters are actually doing anything.

Link to patch - https://gist.githubusercontent.com/RobGries/da32d3bddca5a5b3092f84a885435e55/raw/7b85f4dd4723046dfa26f5f269d619f9ee890545/0001-ported-iir-filters-from-3.18-kernel.-not-sure-if-thi.patch

I saw ljking’s post on the subject, and I was wondering how we should be routing the mic audio to the speakers? I was just wondering because I’d like to see it working since I think that I’ve ported it properly with this patch.

1 Like

Hey Rob,

this patch was a huge help. I am willing to take a crack at your question.

So if you go to this link https://developer.qualcomm.com/download/db410c/stereo-connector-and-audio-routing-application-note.pdf and go to page 17 on the document you will see a block diagram that breaks down the APQ8016 mixing paths. if you follow that you can see that ADC1 > Decimator > HPF > X > DEC1 that then can go through the summer to the left of it and then go through the summer > IIR filter > Post attn > IIIR 1 and that can go through RX 1 path.

You may have already figured this out but it might be huge for someone else that is using this chip.

1 Like

Hi Jessie,
Finally found some time to cookup a patch which works for me on top of 5.1-rc3
Here is link to the patch: srinivas.kandagatla/linux.git - srini kernel working tree

Here are mixer setting or steps to test sidetone from DMIC to Headphone via IIR1:

#Step 1 Setup IIR Path
#Select DEC1 as in IIR1 Mux Input path
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘IIR1 INP1 MUX’ ‘DEC1’
#Increase Volume of Mix Input 1 path
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘IIR1 INP1 Volume’ 127
#set IIR filter coefficients for 5 Bands
root@linaro-alip:~# amixer cset iface=MIXER,name=‘IIR1 Band1’ 0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
root@linaro-alip:~# amixer cset iface=MIXER,name=‘IIR1 Band2’ 0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
root@linaro-alip:~# amixer cset iface=MIXER,name=‘IIR1 Band3’ 0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
root@linaro-alip:~# amixer cset iface=MIXER,name=‘IIR1 Band4’ 0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
root@linaro-alip:~# amixer cset iface=MIXER,name=‘IIR1 Band5’ 0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
#Enable all the 5 IIR bands
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘IIR1 Enable Band1’ 1
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘IIR1 Enable Band2’ 1
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘IIR1 Enable Band3’ 1
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘IIR1 Enable Band4’ 1
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘IIR1 Enable Band5’ 1
#Select IIR1 as Feedback path to RX Left and Right.
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘RX1 MIX1 INP2’ ‘IIR1’
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘RX2 MIX1 INP2’ ‘IIR1’

#Step 2 Start DMIC:
root@linaro-alip:~# amixer cset iface=MIXER,name=‘DEC1 MUX’ ‘DMIC1’
root@linaro-alip:~# amixer cset iface=MIXER,name=‘CIC1 MUX’ ‘DMIC’
root@linaro-alip:~# arecord -D plughw:0,1 -r 48000 -f S16_LE /tmp/f-48000.wav &

#Step 3 Playback silence for testing purpose:

root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘RX1 MIX1 INP1’ ‘RX1’
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘RX2 MIX1 INP1’ ‘RX2’
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘RDAC2 MUX’ ‘RX2’
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘HPHL’ 1
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘HPHR’ 1
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘RX1 Digital Volume’ 127
root@linaro-alip:~# amixer -c 0 cset iface=MIXER,name=‘RX2 Digital Volume’ 127
root@linaro-alip:~# aplay -D plughw:0,0 silence.wav

Thanks,
srini

2 Likes