Analog MIC initialization on Linaro distribution

I am running linaro (not android). Version details -
Linux linaro-developer 4.4.9-linaro-lt-qcom #1 SMP PREEMPT Thu Jun 30 21:34:48 UTC 2016 aarch64 GNU/Linux

What is the procedure to get the analog mic input working. I just need one microphone to work to begin with. I don’t have any preference between Mic1/2/3. I tried connecting an analog mic as follows -

  • CDC_MIC3_P connected to analog output of the mic (pin 7 on J7)
  • GND_FILT connected to the mic’s ground (pin 5 on J7)
  • CDC_MIC_BIAS1 connected to mic’s power (pin 12 of J7).

I see that the voltage on CDC_MIC_BIAS1 is 0V. That is surprising as some of the android counterparts on other forums seem to be reporting about 1.7V. Is the analog mic interface not supported on the regular linaro distribution?

Any help would be greatly appreciated!.

Regards
Bharath

I tried running arecord -l. The output is the following -
**** List of CAPTURE Hardware Devices ****
card 0: DB410c [DB410c], device 2: WCD-Capture msm8916_wcd_i2s_tx1-2 []
Subdevices: 1/1
Subdevice #0: subdevice #0

If I try running arecord to actually start recording, I get the following error -
arecord: main:722: audio open error: No such file or directory

Regards
Bharath

Hi Bharath,

what is your hardware setup in terms of audio connections with DB410c?

To capture audio on headset mic please use below commands:(Note this uses internal mic bias so you should not see voltage on CDC_MIC_BIAS1

amixer cset iface=MIXER,name=‘DEC1 MUX’ ‘ADC2’
amixer cset iface=MIXER,name=‘ADC2 Volume’ 70
amixer cset iface=MIXER,name=‘ADC2 MUX’ ‘INP2’
arecord -D plughw:0,1 -r 16000 -f S16_LE /tmp/f-16000.wav

To capture audio on a secondary mic connected to MIC3_IN and has external micbias taken from MICBIAS1
amixer cset iface=MIXER,name=‘DEC1 MUX’ ‘ADC2’
amixer cset iface=MIXER,name=‘ADC2 Volume’ 70
amixer cset iface=MIXER,name=‘ADC2 MUX’ ‘INP3’
arecord -D plughw:0,1 -r 48000 -f S16_LE /tmp/f-48000.wav

while you are recording on secondary mic you should see voltage on CDC_MIC_BIAS1, all other times i expect this to be zero.

Most of this information is already available in the ucm config files.

thanks,
srini

Hi Bharath,

Just realized that the sub device in arecord example is incorrect.

It should be “plughw:0,2” instead of “plughw:0,1”

Thanks,
srini

Srini,

Thanks! I actually got it working soon after I posted. One critical piece was plughw:0,2. I was missing that too. The other was that in alsamixer, I had to unmute ADC3. I was unmuting ADC1 by mistake. But I was a bit disappointed with my electret microphone based recording. It is too low in volume and too noisy. Does the input need an external amplifier or the amplifier is inbuilt in PM8916/8016?

Regards
Bharath

You may be configured in line-in mode instead of microphone, try to record from your telephone.

If that is the case I think you need to add a couple of resistences on the board, that was the case on our Intrinsyc board.

Also, to be able to record(I was not able to change the adc2 mux value) I had to modify the msm8916-wcd.c file in the kernel to change the ADC2 Mux to virtual. Here is the new code that by the way will be included in the kernel 4.9 but not 4.4:

/* ADC2 MUX */
static const struct soc_enum adc2_enum =
SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(adc2_mux_text), adc2_mux_text);

Srini,

The mono microphone capture seems to work well. I am now trying to move to stereo capture. If I give the below command, what is the stereo input taken from?

arecord -D plughw:0,2 -c 2 -r 48000 -f S16_LE > temp.wav

There seem to be 3 analog Mics. So I was wondering which of the two will be selected for stereo capture. I am hoping it is Mic1 and Mic3 as Mic2 seems to be dedicated for headset.

Regards
Bharath

Srini,

Some additional info might help:
I wired up a Mic1 on DB410c and was able to record with the following set of commands:

amixer cset iface=MIXER,name=‘DEC1 MUX’ ‘ADC1’
amixer cset iface=MIXER,name=‘ADC1 Volume’ 100
amixer cset iface=MIXER,name=‘ADC1 MUX’ ‘INP1’
arecord -D plughw:0,2 -r 48000 -f > temp.wav

The question now is, how do I do both so that MIc1 and Mic3 form a stereo pair?

Regards
Bharath

Srini,

Looks the below conf works for stereo. Just tried out and it seemed to work:

#configure left channel
amixer cset iface=MIXER,name=‘DEC1 MUX’ ‘ADC1’
amixer cset iface=MIXER,name=‘ADC1 Volume’ 100

#configure right channel
amixer cset iface=MIXER,name=‘DEC2 MUX’ ‘ADC2’
amixer cset iface=MIXER,name=‘ADC2 Volume’ 100
amixer cset iface=MIXER,name=‘ADC2 MUX’ ‘INP3’

#record with channel count of 2
arecord -D plughw:0,2 -r 48000 -f S16_LE -c 2 > temp.wav

Is the timing delay between the channels guaranteed? To what level. I am trying to do beamforming with these mics. So it is critical for me to get the timing difference between the two channels to be the same to a 100us level on every reboot.

Regards
Bharath

I have 2 microphones, connected to MIC2 and MIC3 on the analog extension header.
In the datasheet of the amixer, you can see that MIC2 and MIC3 are going in the same ADC2/3.
The question is, can I record separately from each microphone or does that not work because they are on the same ADC? If yes, what would be the command for that…
MIC1 is connected to ADC1.