IMX8MP PDM Microphone SPH0641LM4H-1

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IMX8MP PDM Microphone SPH0641LM4H-1

Jump to solution
5,711 Views
jgsandom
Contributor III

Hi all, we're trying to integrate the SPH0641LM4H-1 PDM microphone and we're having a few issues, we're trying to use this command to test the output;

 

arecord -f S32_LE -d 10 -r 48000 --device="hw:0,0" -vvv

 

Seem to just get a continuous stream which is saturated at 99% e.g.;

 

arecord -f S32_LE -d 10 -r 48000 --device="hw:0,0" -vvv
Recording WAVE 'stdin' : Signed 32 bit Little Endian, Rate 48000 Hz, Mono
Hardware PCM card 0 'imx-audio-micfil' device 0 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S32_LE
  subformat    : STD
  channels     : 1
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 32
  buffer_size  : 16384
  period_size  : 4096
  period_time  : 85333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 4096
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 16384
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
  appl_ptr     : 0
  hw_ptr       : 0
RIFF$LWAVEfmt ��� dataLMax peak (4096 samples): 0x7fffe500 #################### 99%
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Max peak (4096 samples): 0x7fffe000 #################### 99%

 

The kernel log looks fine, don't see any issues there;

 

dmesg -wH | grep mic
[  +0.006196] DMA: preallocated 256 KiB pool for atomic allocations
[  +0.011044] fsl-micfil-dai 30ca0000.micfil: GET IRQ: 39
[  +0.005251] fsl-micfil-dai 30ca0000.micfil: GET IRQ: 40
[  +0.005243] fsl-micfil-dai 30ca0000.micfil: GET IRQ: 41
[  +0.005245] fsl-micfil-dai 30ca0000.micfil: GET IRQ: 42
[  +0.008303] debugfs: Directory '30ca0000.micfil' with parent 'imx-audio-micfil' already present!
[  +0.008880] imx-micfil sound-micfil: snd-soc-dummy-dai <-> 30ca0000.micfil mapping ok
[  +0.007843] imx-micfil sound-micfil: ASoC: no DMI vendor name!
[  +0.002977]   #0: imx-audio-micfil

 

The dts entry looks like this;

 

sound-micfil {
	compatible = "fsl,imx-audio-micfil";
	model = "imx-audio-micfil";
	cpu-dai = <&micfil>;
};

&micfil {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_pdm>;
	assigned-clocks = <&clk IMX8MP_CLK_PDM>;
	assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
	assigned-clock-rates = <196608000>;
	status = "okay";
};

pinctrl_pdm: pdmgrp {
	fsl,pins = <
		MX8MP_IOMUXC_SAI5_RXC__AUDIOMIX_PDM_CLK			0xd6
		MX8MP_IOMUXC_SAI5_RXD0__AUDIOMIX_PDM_BIT_STREAM00	0xd6
		MX8MP_IOMUXC_SAI5_RXD1__AUDIOMIX_PDM_BIT_STREAM01	0xd6
		MX8MP_IOMUXC_SAI5_RXD2__AUDIOMIX_PDM_BIT_STREAM02	0xd6
		MX8MP_IOMUXC_SAI5_RXD3__AUDIOMIX_PDM_BIT_STREAM03	0xd6
	>;
};

 

Does anyone have any idea what could be the issue? note that we haven't had the chance to scope the PDM clock and data lines yet, so can't completely discount an electronics issue. (will be doing this next week).

I've also seen that there is a sound-swpdm node, should this be used instead of sound-micfil? Some clarification would be appreciated!

Thank you

Tags (3)
0 Kudos
1 Solution
5,413 Views
jgsandom
Contributor III

@igorpadykov I tried both options and they didn't work unfortunately for RX2. I made some additional modifications as suggested in my previous post. It works ok for me - I've attached the patch.

View solution in original post

22 Replies
4,770 Views
jgsandom
Contributor III

Hi @igorpadykov ,

There isn't much information in sect 7.6 PDM Microphone Interface (MICFIL) for testing. Is there anything specific that needs to be set using amixer or are the defaults sufficient?

Regarding the unit tests, this doesn't work, there is a format mismatch;

./mxc_pdm_test.out --device hw:0,0 --output test-16k.raw --rate 48000 --seconds 60
Set pcm format not supported
fail setting params error: -22
fail to init alsa pdm -22
root@digitalsurgery-imx8mp:

The IMX8MP seems to only support S32_LE as advertised here;

./mxc_alsa_hw_params.out hw:0,0 c f
S32_LE 

Whereas the unit test specifies U32_LE;

priv->format = SND_PCM_FORMAT_DSD_U32_LE;

 

Yesterday, we scoped the PDM clock and data, we could see a valid clock at ~3MHz and looked like data was present. 

Note that we are using PDM_DAT2 as our data input, is there anything we need to set specifically to receive data on DAT2? from the evk dts, looks like we are using the exact same micfil setup.

Please let me know your thoughts, thanks!

0 Kudos
4,763 Views
igorpadykov
NXP Employee
NXP Employee

> from the evk dts, looks like we are using the exact same micfil setup.

 

in such case (using SAI5 as in dts https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8mp-evk.d...

seems it should work with "hw:4,0" as in https://source.codeaurora.org/external/imx/imx-test/tree/test/mxc_pdm_test/README?h=lf-5.10.y_2.0.0

How did yoi find "--device hw:0,0" .

Some debug info can be obtained with "--log (l): log debug information\n""  :

https://source.codeaurora.org/external/imx/imx-test/tree/test/mxc_pdm_test/mxc_pdm_test.c?h=lf-5.10....

 

Best regards
igor

0 Kudos
4,760 Views
jgsandom
Contributor III

When I say exact same micfil setup, I just mean the micfil node as outlined in the original post, I'm not using all of the others e.g. sound-hdmi, sound-bt-sco etc. I'm just using sound-micfil in our custom board, that's why it's hw:0,0 instead of hw:4,0

The log output didn't give anything additional;

 

./mxc_pdm_test.out --log --device hw:0,0 --output test-16k.raw --rate 48000 --seconds 60 
Set pcm format not supported
fail setting params error: -22
fail to init alsa pdm -22

Is there any more documentation on the 8MIC board for use with the IMX8M-Plus? It would be good to see the schematic. Is the imx8mp-evk.dts designed to support the 8MIC board already or does it require more changes?

 

0 Kudos
4,753 Views
igorpadykov
NXP Employee
NXP Employee

Hi Joe

 

>Is there any more documentation on the 8MIC board for use with the IMX8M-Plus?

 

only I.MX 8Mic Board Quick Start Guide, sect.3 Record Audio
https://www.nxp.com/docs/en/quick-reference-guide/IMX-8MIC-QSG.pdf

 

>It would be good to see the schematic.

 

was sent you via mail.

 

>Is the imx8mp-evk.dts designed to support the 8MIC board already

 

yes, dts file :

https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8mp-evk.d...

 

Best regards
igor

0 Kudos
4,733 Views
jgsandom
Contributor III

Hi Igor,

I modified mxc_pdm_test unit test to use SND_PCM_FORMAT_S32_LE as that is what the IMX8MP is supporting. This gets past the previous errors and now the output looks like this;

./mxc_pdm_test.out --device hw:0,0 --channels 2 -o test2.raw --rate 48000 --seconds 10 --log
Hardware PCM card 0 'imx-audio-micfil' device 0 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S32_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 32
  buffer_size  : 8192
  period_size  : 512
  period_time  : 10666
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 512
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 8192
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
  appl_ptr     : 0
  hw_ptr       : 0
Avg time proccess one buffer period: 0.003353
Dhrystones per second:  305.4, DMIPS:    0.2
Read:Write periods 938:933

Doesn't seem to be any errors, but the resulting file is just a strange test like tone - almost as if it's not coming from the microphone. (attached)

Does this test at least suggest that the micfil FIFO is being filled by the microphone data and the unit test is grabbing those buffers?

Note that I was playing the file with the following command;

aplay -t raw -c 2 -f S32_LE -r 48000 test2.raw
0 Kudos
4,729 Views
igorpadykov
NXP Employee
NXP Employee

Hi Joe

 

what linux used in the case, is it from nxp source.codeaurora.org/external/imx/linux-imx repository,

also could you provide dts file

 

Best regards
igor

0 Kudos
4,723 Views
jgsandom
Contributor III

Hi,

I recently upgraded from 5.4.7 BSP 2.3.0 to 5.10.35: https://source.codeaurora.org/external/imx/linux-imx/log/?h=lf-5.10.y

Attached is the full dts file of the development kit we're working with.

Thanks,

Joe

 

0 Kudos
4,708 Views
igorpadykov
NXP Employee
NXP Employee

thanks, I will ask internally and update.

 

Best regards
igor

0 Kudos
4,695 Views
igorpadykov
NXP Employee
NXP Employee

answer from internal team:

------------

Please try to add file name while recording.

 

root@imx8mpevk:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: imxaudioxcvr [imx-audio-xcvr], device 0: XCVR PCM snd-soc-dummy-dai-0 [XCVR PCM snd-soc-dummy-dai-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: imxaudiomicfil [imx-audio-micfil], device 0: micfil hifi snd-soc-dummy-dai-0 [micfil hifi snd-soc-dummy-dai-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: btscoaudio [bt-sco-audio], device 0: 30c20000.sai-bt-sco-pcm-wb bt-sco-pcm-wb-0 [30c20000.sai-bt-sco-pcm-wb bt-sco-pcm-wb-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: wm8960audio [wm8960-audio], device 0: HiFi wm8960-hifi-0 [HiFi wm8960-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: wm8960audio [wm8960-audio], device 1: HiFi-ASRC-FE (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

root@imx8mpevk:~# arecord -f S32_LE -d 10 -r 48000 --device="hw:1,0" capture.wav -vvv
Recording WAVE 'capture.wav' : Signed 32 bit Little Endian, Rate 48000 Hz, Mono
Hardware PCM card 1 'imx-audio-micfil' device 0 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S32_LE
  subformat    : STD
  channels     : 1
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 32
  buffer_size  : 24000
  period_size  : 6000
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 6000
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 24000
  silence_threshold: 0
  silence_size : 0
  boundary     : 6755399441055744000
  appl_ptr     : 0
  hw_ptr       : 0
Max peak (6000 samples): 0x30ce7100 ########             38%
Max peak (6000 samples): 0x161cea00 ####                 17%
Max peak (6000 samples): 0x066fc700 ##                   5%
Max peak (6000 samples): 0x070dfc00 ##                   5%
Max peak (6000 samples): 0x06bde300 ##                   5%
Max peak (6000 samples): 0x05783000 #                    4%
Max peak (6000 samples): 0x04088900 #                    3%
Max peak (6000 samples): 0x02ea0100 #                    2%
Max peak (6000 samples): 0x02c7b700 #                    2%
Max peak (6000 samples): 0x01c11e00 #                    1%
Max peak (6000 samples): 0x015fb400 #                    1%
Max peak (6000 samples): 0x011c8300 #                    0%
Max peak (6000 samples): 0x00febe00 #                    0%
Max peak (6000 samples): 0x00d98d00 #                    0%
Max peak (6000 samples): 0x00e02f00 #                    0%
Max peak (6000 samples): 0x0163fc00 #                    1%
Max peak (6000 samples): 0x00f8a700 #                    0%
Max peak (6000 samples): 0x009a6300 #                    0%
Max peak (6000 samples): 0x00a46200 #                    0%
Max peak (6000 samples): 0x00b33900 #                    0%
Max peak (6000 samples): 0x01711e00 #                    1%
Max peak (6000 samples): 0x009f9500 #                    0%
Max peak (6000 samples): 0x00cd3300 #                    0%
Max peak (6000 samples): 0x36bf4100 #########            42%
Max peak (6000 samples): 0x6bf24500 #################    84%
Max peak (6000 samples): 0x7ffffb00 #################### 99%
Max peak (6000 samples): 0x01347700 #                    0%
Max peak (6000 samples): 0x086e8200 ##                   6%
Max peak (6000 samples): 0x6a2b3200 #################    82%
Max peak (6000 samples): 0x0c089900 ##                   9%
Max peak (6000 samples): 0x041d8400 #                    3%
Max peak (6000 samples): 0x7f929300 #################### 99%
Max peak (6000 samples): 0x7d62b400 #################### 97%
Max peak (6000 samples): 0x1ec17d00 #####                24%
Max peak (6000 samples): 0x118f9700 ###                  13%
Max peak (6000 samples): 0x1905fc00 ####                 19%
Max peak (6000 samples): 0x1f170a00 #####                24%
Max peak (6000 samples): 0x222f0800 ######               26%
Max peak (6000 samples): 0x22a0fd00 ######               27%
Max peak (6000 samples): 0x22471100 ######               26%
Max peak (6000 samples): 0x2103fe00 ######               25%
Max peak (6000 samples): 0x20145600 ######               25%
Max peak (6000 samples): 0x1e55af00 #####                23%
Max peak (6000 samples): 0x1886dc00 ####                 19%
Max peak (6000 samples): 0x7f878b00 #################### 99%
Max peak (6000 samples): 0x2ee17800 ########             36%
Max peak (6000 samples): 0x123cf000 ###                  14%
Max peak (6000 samples): 0x7f571300 #################### 99%
Max peak (6000 samples): 0x0e6b0700 ###                  11%
Max peak (6000 samples): 0x0cb13600 ##                   9%
Max peak (6000 samples): 0x094e1900 ##                   7%
Max peak (6000 samples): 0x071d6e00 ##                   5%
Max peak (6000 samples): 0x04d5d200 #                    3%
Max peak (6000 samples): 0x02bd5e00 #                    2%
Max peak (6000 samples): 0x01347700 #                    0%
Max peak (6000 samples): 0x01b05700 #                    1%
Max peak (6000 samples): 0x319f4300 ########             38%
Max peak (6000 samples): 0x1579f300 ####                 16%
Max peak (6000 samples): 0x02087900 #                    1%
Max peak (6000 samples): 0x7ea5bc00 #################### 98%
Max peak (6000 samples): 0x46f33c00 ############         55%
Max peak (6000 samples): 0x00a60e00 #                    0%
Max peak (6000 samples): 0x01560000 #                    1%
Max peak (6000 samples): 0x019bf300 #                    1%
Max peak (6000 samples): 0x0264a900 #                    1%
Max peak (6000 samples): 0x0346df00 #                    2%
Max peak (6000 samples): 0x03f2ab00 #                    3%
Max peak (6000 samples): 0x03e9f300 #                    3%
Max peak (6000 samples): 0x0425b400 #                    3%
Max peak (6000 samples): 0x04b64700 #                    3%
Max peak (6000 samples): 0x04d75600 #                    3%
Max peak (6000 samples): 0x04fdff00 #                    3%
Max peak (6000 samples): 0x04df3500 #                    3%
Max peak (6000 samples): 0x0565be00 #                    4%
Max peak (6000 samples): 0x06027200 #                    4%
Max peak (6000 samples): 0x09d3af00 ##                   7%
Max peak (6000 samples): 0x08fd2300 ##                   7%
Max peak (6000 samples): 0x0b7ee800 ##                   8%
Max peak (6000 samples): 0x06f23900 ##                   5%
Max peak (6000 samples): 0x029f4a00 #                    2%

 

Some more information:

I was testing with 5.10.35 BSP, with microphone https://www.adafruit.com/product/3492

Their dts is same as on evk, so the problem is more like on hw side.

About the difference between swpdm and micfil: they can both convert 1-bit PDM to PCM. MICFIL is described in the 8MP RM14.3 which uses hw decimation filter; swpdm uses software filter to the same job. swpdm was introduced previously to support 24-bit PCM because on 8MM, MICFIL can only convert to 16-bit PCM (see 8MM RM13.8.2.1). For 8MP, customer doesn't need to mind the swpdm.

 

------------

Best regards
igor

4,678 Views
jgsandom
Contributor III

Thanks for the response @igorpadykov , noticed a few differences between the recording parameters when running the same command as what was run internally;

From NXP;

Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S32_LE
  subformat    : STD
  channels     : 1
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 32
  buffer_size  : 24000
  period_size  : 6000
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 6000
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 24000
  silence_threshold: 0
  silence_size : 0
  boundary     : 6755399441055744000
  appl_ptr     : 0
  hw_ptr       : 0

 

From our setup, nothing has changed from our side with regard to these params, could you clarify if anything was modified on the NXP side to get this setup. Here is what we get; (note the buffer size, period size, period time etc)

Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S32_LE
  subformat    : STD
  channels     : 1
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 32
  buffer_size  : 16384
  period_size  : 4096
  period_time  : 85333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1
  avail_min    : 4096
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 16384
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904
  appl_ptr     : 0
  hw_ptr       : 0

 

4,639 Views
igorpadykov
NXP Employee
NXP Employee

from team:

---------------

I did not change the parameters, these parameters are set from user space (app). 

If the customer wants to try different parameters, they can get the list with arecord --help

root@imx8mpevk:~# arecord --help
Usage: arecord [OPTION]... [FILE]...

-h, --help              help
    --version           print current version
-l, --list-devices      list all soundcards and digital audio devices
-L, --list-pcms         list device names
-D, --device=NAME       select PCM by name
-q, --quiet             quiet mode
-t, --file-type TYPE    file type (voc, wav, raw or au)
-c, --channels=#        channels
-f, --format=FORMAT     sample format (case insensitive)
-r, --rate=#            sample rate
-d, --duration=#        interrupt after # seconds
-s, --samples=#         interrupt after # samples per channel
-M, --mmap              mmap stream
-N, --nonblock          nonblocking mode
-F, --period-time=#     distance between interrupts is # microseconds
-B, --buffer-time=#     buffer duration is # microseconds
    --period-size=#     distance between interrupts is # frames
    --buffer-size=#     buffer duration is # frames
-A, --avail-min=#       min available space for wakeup is # microseconds
-R, --start-delay=#     delay for automatic PCM start is # microseconds
                        (relative to buffer size if <= 0)
-T, --stop-delay=#      delay for automatic PCM stop is # microseconds from xrun
-v, --verbose           show PCM structure and setup (accumulative)
-V, --vumeter=TYPE      enable VU meter (TYPE: mono or stereo)
-I, --separate-channels one file for each channel
-i, --interactive       allow interactive operation from stdin
-m, --chmap=ch1,ch2,..  Give the channel map to override or follow
    --disable-resample  disable automatic rate resample
    --disable-channels  disable automatic channel conversions
    --disable-format    disable automatic format conversions
    --disable-softvol   disable software volume control (softvol)
    --test-position     test ring buffer position
    --test-coef=#       test coefficient for ring buffer position (default 8)
                        expression for validation is: coef * (buffer_size / 2)
    --test-nowait       do not wait for ring buffer - eats whole CPU
    --max-file-time=#   start another output file when the old file has recorded
                        for this many seconds
    --process-id-file   write the process ID here
    --use-strftime      apply the strftime facility to the output file name
    --dump-hw-params    dump hw_params of the device
    --fatal-errors      treat all errors as fatal

  Then set the parameter like arecord --period-size=xxx --buffer-size=xxx ......

 

---------------

 

Best regards
igor

0 Kudos
4,630 Views
jgsandom
Contributor III

Thanks @igorpadykov , I understand that the values can be set from userspace, but I didn't see that in your team members command in the previous message.

It was my understanding that we're using the same BSP and kernel version, shouldn't our default values be the same in that case? it makes me think that something does not quite line up between our setups. 

We actually tried to use the same PDM breakout board as your team member as we thought that the PDM microphone on our boards might be damaged. The result was the same, reading 99%.

Is there anything in the meta layers that change the ALSA configuration? perhaps I'm missing that from my build. Could you please ask your team member to send any relevant ALSA conf files so I can compare with my own please?

Thank you.

0 Kudos
4,593 Views
jgsandom
Contributor III

@igorpadykov any updates from the internal team about the above? Still not understanding why the default values from your team members traces are different to mine, despite using the same BSP. Is there a specific configuration that needs to be used?

0 Kudos
4,590 Views
igorpadykov
NXP Employee
NXP Employee

Hi Joe

 

I sent your questions but did not get answer yet.

 

Best regards
igor

0 Kudos
4,566 Views
jgsandom
Contributor III

Hi @igorpadykov ,

I have some more info regarding this question.

If we connect the PDM DATA input to RX0, we're able to capture audio (I imagine this is what your team member did). However, RX1/2/3 do not work. Is there a way to select the data input in the device tree? I did see fsl,dataline option in micfil but it doesn't seem to do anything.

Also, I tried to set the channel in arecord when using e.g. RX1 to channel 3 or 4 and it didn't make a difference.

We need to use RX2 for our implementation, as this is the only RX line exposed for us.

4,557 Views
jgsandom
Contributor III

@igorpadykov some more info for you, looking at fsl_micfil.h we have the following;

#define MICFIL_CTRL1_CHEN_SHIFT		0
#define MICFIL_CTRL1_CHEN_WIDTH		8
#define MICFIL_CTRL1_CHEN_MASK(x)	(BIT(x) << MICFIL_CTRL1_CHEN_SHIFT)
#define MICFIL_CTRL1_CHEN(x)		(MICFIL_CTRL1_CHEN_MASK(x))

It looks as though CHEN is never set and perhaps it just defaults to channel 0, which explains why RX0 works and not RX1/2/3

jgsandom_0-1626797216524.png

I modified fsl_micfil.c to set CHnEN to 0x30 to enable channel 5 + 6, with this we were able to capture on RX2. 

Max peak (4095 samples): 0x150c4b00 ####                 16%
Max peak (4095 samples): 0x0ede2f00 ###                  11%
Max peak (4095 samples): 0x0d808300 ###                  10%
Max peak (4095 samples): 0x08e53b00 ##                   6%
Max peak (4095 samples): 0x08f5b700 ##                   6%
Max peak (4095 samples): 0x0903b900 ##                   7%
Max peak (4095 samples): 0x0831d700 ##                   6%
Max peak (4095 samples): 0x08c83e00 ##                   6%
Max peak (4095 samples): 0x079e1000 ##                   5%
Max peak (4095 samples): 0x19c24f00 #####                20%
Max peak (4095 samples): 0x24988c00 ######               28%
Max peak (4095 samples): 0x1d9e4500 #####                23%
Max peak (4095 samples): 0x56a85900 ##############       67%
Max peak (4095 samples): 0x5fe03600 ###############      74%
Max peak (4095 samples): 0x5cf95300 ###############      72%
Max peak (4095 samples): 0x3cfbd600 ##########           47%
Max peak (4095 samples): 0x480ecf00 ############         56%
Max peak (4095 samples): 0x7faad900 #################### 99%
Max peak (4095 samples): 0x62cb7700 ################     77%
Max peak (4095 samples): 0x59471200 ##############       69%
Max peak (4095 samples): 0x35279800 #########            41%
Max peak (4095 samples): 0x22460100 ######               26%
Max peak (4095 samples): 0x21a6bf00 ######               26%
Max peak (4095 samples): 0x41464c00 ###########          50%
Max peak (4095 samples): 0x14821700 ####                 16%
Max peak (4095 samples): 0x0b0c7c00 ##                   8%
Max peak (4095 samples): 0x0ed65700 ###                  11%

Could we raise this for NXP to provide an official patch? 

4,549 Views
igorpadykov
NXP Employee
NXP Employee

Hi Joe 

 

all your updates and findings were submitted to team, still no feedback so far.

 

Best regards
igor

0 Kudos
4,542 Views
igorpadykov
NXP Employee
NXP Employee

answer from team :

-------------------

According to the customer's finding: recording from RX0 is correct, but from RX1/2/3 is not.

This is expected to happen. In the design, one data line corresponds to 2 audio channels, and by default DMA carries starting from RX0. You can check the code in sound/soc/fsl/fsl_micfil.c

fsl_micfil_probe
2332     micfil->dma_params_rx.chan_name = "rx";
2333     micfil->dma_params_rx.addr = res->start + REG_MICFIL_DATACH0;
2334     micfil->dma_params_rx.maxburst = MICFIL_DMA_MAXBURST_RX;

 Customer's requirement is to record data from PDM_DAT2, then there are two potential ways worth trying:

1. In the arecord command, add the parameter " - c 6 ", which records 6 channels of data. In the recorded file, channel 5/6 should have correct data, corresponding to RX2.

2. Still use 2 channels, but in the above code, change REG_MICFIL_DATACH0 to REG_MICFIL_DATACH2, then DMA knows to carry data starting from RX2. 

 

--------------------

Best regards
igor

4,528 Views
jgsandom
Contributor III

Thanks for the response @igorpadykov , this is helpful.

In terms of the options;

1. This would mean we still try to enable channels 1/2/3/4/5/6 with only 5/6 being valid, the VU meter in arecord will show nothing happening - I had tried this before.

2. This should work in theory, yes but more will need to be done to get this to work, I realised that the channel is in fact being set here;

	ret = regmap_update_bits(micfil->regmap, REG_MICFIL_CTRL1,
				 0xFF, ((1 << channels) - 1));

For RX2, I think rather than setting REG_MICFIL_DATACH2 we would have to set REG_MICFIL_DATACH5 for RX2 as this seems to correspond to channels rather than RX lines. Then if we go with the proposed and set channels to 2 in arecord, the above code snippet will only eable channels 1 + 2, therefore no data should be available even if the DMA access starts from channel 5.

I will play around with it and keep you updated.

4,507 Views
igorpadykov
NXP Employee
NXP Employee

from team:

---------------

I updated several times, especially for the second option, which should solve their problem. Please share latest response to customer.

--------------

Best regards
igor

0 Kudos