Sidetone (Loopback) Issue on Kernel 4.14


I have been working on getting the Sidetone (loopback) working for the APQ8016. I started by using a patch that I found on this forum. Then I looked through the actual android source, I moved all the code over and the code did not work as expected. I had a ton of issues with setting the IIR coefficients so I simplified the code using what I had from the android source. Using the Processor register description document, I found the register values that the registers needed to be I set to and set them.

After doing this the sidetone worked… for about four seconds after every time you do play an audio file. I read through the Processor register description document and read about some digital mute stuff and I played with that. That still did not give me the results I expected.

I created a patch with all the ported and changed code that I use to get the 4 second loop. My application does not use the ADV7533 HDMI chip so the patch also removed all of that in the device tree.

To repeat my results you need to:

Set up alsa and you do so with these instructions:

amixer -c 0 cset iface=MIXER,name=‘RX1 MIX1 INP1’ ‘RX1’
amixer -c 0 cset iface=MIXER,name=‘RX1 MIX2 INP1’ ‘IIR1’
amixer -c 0 cset iface=MIXER,name=‘RX2 MIX1 INP1’ ‘RX2’
amixer -c 0 cset iface=MIXER,name=‘RX2 MIX2 INP1’ ‘IIR1’
amixer -c 0 cset iface=MIXER,name=‘RDAC2 MUX’ ‘RX2’
amixer -c 0 cset iface=MIXER,name=‘HPHL’ 1
amixer -c 0 cset iface=MIXER,name=‘HPHR’ 1
amixer -c 0 cset iface=MIXER,name=‘RX1 Digital Volume’ 100
amixer -c 0 cset iface=MIXER,name=‘RX2 Digital Volume’ 100
amixer -c 0 cset iface=MIXER,name=‘DEC1 MUX’ ‘ADC2’
amixer -c 0 cset iface=MIXER,name=‘ADC2 Volume’ 70
amixer -c 0 cset iface=MIXER,name=‘ADC2 MUX’ ‘INP2’
amixer -c 0 cset iface=MIXER,name=‘RX1 MIX1 INP1’ ‘RX1’
amixer -c 0 cset iface=MIXER,name=‘IIR1 INP1 MUX’ ‘DEC1’
amixer -c 0 cset iface=MIXER,name=‘IIR2 INP1 MUX’ ‘DEC1’
amixer -c 0 cset iface=MIXER,name=‘SIDETONE Set’ 1

Then you will have to record an audio file:

arecord -D plughw:0,1 -r 16000 -f S16_LE test.wav

Followed by playing a file:

aplay test.wav

Then you will hear the sidetone on this record:

arecord -D plughw:0,1 -r 16000 -f S16_LE test.wav

At this point I am a little lost and anything will help! I linked the patch ( It is not that best code but its just to see the feature work. Thank you for your help and time!

Are you using pulseaudio or just straight ALSA? I’ve noticed that pulse sometimes plays hell with some of these QCom specific audio modes.

If you’re using pulse I’d try disabling it in favor of interfacing directly with ALSA.

I am using straight alsa. I should have put that in the post so thats on me.

Oh and I do not know if this helps or not but I am using Yocto (Thud) and the image I am building is just the rpb/rpb-console-image.

Turns out this actually works and it was me not understanding how the dapm works.

You have to have both the playback and record hardware running to have it run correctly. Looking at this post (APQ8016 IIR Filter Configuration) Srini made a comment and on the bottom of the comment he uses “arecord -D plughw:0,1 -r 48000 -f S16_LE /tmp/f-48000.wav &” that and leaves it running and then he plays the file. You can test this same thing by using alsaloop! BOOM WORKS! I hope this helps someone one day!