Skip to contentSkip to conversation

noise issues when recording sound on i.MX28

DISCUSSION Uwe Kleine-König 4 participants 13 messages Jan 27, 2016 – Jan 10, 2017

lore
Share & tools
lore
#0 lore raw

Hello,

I currently work with an i.MX28 based machine and occasionally when recording sound with arecord but no microphone connected the result contains much noise.

I found commits

	90ce77d4468e ENGR00285446-3 [MX28] SAIF: Bit Shift in SAIF RX Data
	1ea685a12f19 ENGR00285446-2 [MX28] SAIF: Bit Shift in SAIF RX Data
	1ca899221d8b ENGR00285446-1 [MX28] SAIF: Bit Shift in SAIF RX Data

in the Freescale vendor kernel (branch imx_2.6.35_maintain at
git://git.freescale.com/imx/linux-2.6-imx.git). The kernel running on the machine in question is based on 3.10 with an impressive (that's negative) patch stack on top. I think patches -2 and -3 are not relevant for my setup because the two saif clocks are configured identically if I'm not mistaken. However implementing the soft reset as is done in patch -1 doesn't work here. When resetting saif1 (that is used for recording with saif0 being it's master) the CLKGATE bit gets never set and when breaking out of the loop the noise issue happend 5 out of 5 test runs in the first iteration.

Does this ring a bell for you? Even if there is something bad hidden in the patch stack (or 3.10?) a reset should never fail, right?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#1 lore raw

Hi Uwe,

Quoted 12 lines · Uwe Kleine-K?nig

Hello,

I currently work with an i.MX28 based machine and occasionally when recording sound with arecord but no microphone connected the result contains much noise.

I found commits

        90ce77d4468e ENGR00285446-3 [MX28] SAIF: Bit Shift in SAIF RX Data
        1ea685a12f19 ENGR00285446-2 [MX28] SAIF: Bit Shift in SAIF RX Data
        1ca899221d8b ENGR00285446-1 [MX28] SAIF: Bit Shift in SAIF RX Data
Quoted 6 lines

in the Freescale vendor kernel (branch imx_2.6.35_maintain at
git://git.freescale.com/imx/linux-2.6-imx.git). The kernel running on the machine in question is based on 3.10 with an impressive (that's negative) patch stack on top. I think patches -2 and -3 are not relevant for my setup because the two saif clocks are configured identically if I'm not mistaken. However implementing the soft reset as is done in

Please make sure that the two saif clocks are configured identically.

This was the most important part of the fix when we worked on this problem on 2.6.35.

Unfortunately I have never had a chance to upstream this fix.

Regards,

Fabio Estevam

#2 lore raw

Hello Fabio,

[dropping Jack Lee from Cc: as his address doesn't exist.]

Quoted 12 lines · Fabio Estevam
Quoted 10 lines · Uwe Kleine-K?nig

I currently work with an i.MX28 based machine and occasionally when recording sound with arecord but no microphone connected the result contains much noise.

I found commits

        90ce77d4468e ENGR00285446-3 [MX28] SAIF: Bit Shift in SAIF RX Data
        1ea685a12f19 ENGR00285446-2 [MX28] SAIF: Bit Shift in SAIF RX Data
        1ca899221d8b ENGR00285446-1 [MX28] SAIF: Bit Shift in SAIF RX Data
Quoted 8 lines
Quoted 6 lines

in the Freescale vendor kernel (branch imx_2.6.35_maintain at
git://git.freescale.com/imx/linux-2.6-imx.git). The kernel running on the machine in question is based on 3.10 with an impressive (that's negative) patch stack on top. I think patches -2 and -3 are not relevant for my setup because the two saif clocks are configured identically if I'm not mistaken. However implementing the soft reset as is done in

Please make sure that the two saif clocks are configured identically.

I think I have that. According to $debugfs/clk the two saif clocks have the same parent and frequency.

Quoted 2 lines

This was the most important part of the fix when we worked on this problem on 2.6.35.

So you didn't hit the problem that resetting a saif didn't work, right?

Do you have a few more technical details here? A usecase of my machine is recording and playback at the same time (an intercom system). So if it's necessary to reset the sending side to start receiving that's unfortunate.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#3 lore raw

Hi,

Quoted 26 lines · On Wed, 27 Jan 2016 15:43:40 +0100 Uwe Kleine-K?nig wrote:

Hello Fabio,

[dropping Jack Lee from Cc: as his address doesn't exist.]

Quoted 12 lines · Fabio Estevam
Quoted 10 lines · Uwe Kleine-K?nig

I currently work with an i.MX28 based machine and occasionally when recording sound with arecord but no microphone connected the result contains much noise.

I found commits

        90ce77d4468e ENGR00285446-3 [MX28] SAIF: Bit Shift in SAIF RX Data
        1ea685a12f19 ENGR00285446-2 [MX28] SAIF: Bit Shift in SAIF RX Data
        1ca899221d8b ENGR00285446-1 [MX28] SAIF: Bit Shift in SAIF RX Data
Quoted 8 lines
Quoted 6 lines

in the Freescale vendor kernel (branch imx_2.6.35_maintain at
git://git.freescale.com/imx/linux-2.6-imx.git). The kernel running on the machine in question is based on 3.10 with an impressive (that's negative) patch stack on top. I think patches -2 and -3 are not relevant for my setup because the two saif clocks are configured identically if I'm not mistaken. However implementing the soft reset as is done in

Please make sure that the two saif clocks are configured identically.

Quoted 8 lines

I think I have that. According to $debugfs/clk the two saif clocks have the same parent and frequency.

Quoted 2 lines

This was the most important part of the fix when we worked on this problem on 2.6.35.

So you didn't hit the problem that resetting a saif didn't work, right?

According to the i.MX28 Ref. Manual CLKGATE of the SAIF block does NOT automatically assert upon asserting SFTRST:
|35.3.1 SAIF Control Register (HW_SAIF_CTRL)
[...]

|HW_SAIF_CTRL field descriptions
| Field Description
|  31   | Setting this bit to 1 forces a reset to the entire block. SFTRST has no effect on CLKGATE. Also, the
|SFTRST | SFTRST bit may be written when CLKGATE=1. This bit must be cleared to 0 for normal operation.

So the standard stmp_reset_block() function won't work for the SAIF block.

BTW: I'm currently investigating the same problem...

Lothar Wa?mann

#4 lore raw
In reply to Uwe Kleine-König

Hi Uwe,

Quoted 1 line · Uwe Kleine-K?nig

So you didn't hit the problem that resetting a saif didn't work, right?

No, we haven't seen this reset issue.

Quoted 1 line

Do you have a few more technical details here? A usecase of my machine

Let me find out as it has been several years I worked on this problem. Will let you know.

Regards,

Fabio Estevam

#5 lore raw

Hello Fabio,

Quoted 11 lines · Fabio Estevam
Quoted 1 line · Uwe Kleine-K?nig

So you didn't hit the problem that resetting a saif didn't work, right?

No, we haven't seen this reset issue.

Quoted 1 line

Do you have a few more technical details here? A usecase of my machine

Let me find out as it has been several years I worked on this problem. Will let you know.

Anything new on your end? I know from Lothar that he invested quite some time to debug his hardware setup, tested the codec instead of the i.MX28 as clock provider and several more things. I also spend some time on this issue and we both hope that Freescale/NXP can help in better understanding the issue and hopefully can come up with a recipe to make concurrent recording and playback on i.MX28 work.

Lothar is in contact with Freescale, too, but up to now with little success. The company I'm working for at the moment would also welcome a solution here.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#6 lore raw

Hi Uwe,

Quoted 22 lines · Uwe Kleine-K?nig

Hello Fabio,

Quoted 11 lines · Fabio Estevam
Quoted 1 line · Uwe Kleine-K?nig

So you didn't hit the problem that resetting a saif didn't work, right?

No, we haven't seen this reset issue.

Quoted 1 line

Do you have a few more technical details here? A usecase of my machine

Let me find out as it has been several years I worked on this problem. Will let you know.

Anything new on your end? I know from Lothar that he invested quite some time to debug his hardware setup, tested the codec instead of the i.MX28 as clock provider and several more things. I also spend some time on this issue and we both hope that Freescale/NXP can help in better understanding the issue and hopefully can come up with a recipe to make concurrent recording and playback on i.MX28 work.

Quoted 3 lines

Lothar is in contact with Freescale, too, but up to now with little success. The company I'm working for at the moment would also welcome a solution here.

Sorry for the delay. I have been on holidays.

Can you confirm you have both SAIF interfaces being clocked from ref_pll?

#7 lore raw
Quoted 26 lines · Fabio Estevam

Hi Uwe,

Quoted 22 lines · Uwe Kleine-K?nig

Hello Fabio,

Quoted 11 lines · Fabio Estevam
Quoted 1 line · Uwe Kleine-K?nig

So you didn't hit the problem that resetting a saif didn't work, right?

No, we haven't seen this reset issue.

Quoted 1 line

Do you have a few more technical details here? A usecase of my machine

Let me find out as it has been several years I worked on this problem. Will let you know.

Anything new on your end? I know from Lothar that he invested quite some time to debug his hardware setup, tested the codec instead of the i.MX28 as clock provider and several more things. I also spend some time on this issue and we both hope that Freescale/NXP can help in better understanding the issue and hopefully can come up with a recipe to make concurrent recording and playback on i.MX28 work.

Quoted 5 lines
Quoted 3 lines

Lothar is in contact with Freescale, too, but up to now with little success. The company I'm working for at the moment would also welcome a solution here.

Sorry for the delay. I have been on holidays.

I wonder who granted you to go on holidays given that we have problems :-)

Quoted 1 line

Can you confirm you have both SAIF interfaces being clocked from ref_pll?

root at hostname:/sys/kernel/debug/clk find -name saif?_sel ./ref_xtal/pll0/saif0_sel ./ref_xtal/pll0/saif1_sel

root at hostname:/sys/kernel/debug/clk cat ./ref_xtal/pll0/saif?_sel/clk_rate 480000000
480000000

This is based on 3.10 (but I hope to update soon to 4.4ish). I know that Lothar uses 4.4. Also Lothar noticed that disabling one of these saif_sel clocks doesn't make an impression on the interfaces, they just continue to run. Maybe a clock is routed in a wrong way?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#8 lore raw

Hi,

Quoted 42 lines · On Thu, 11 Feb 2016 09:40:29 +0100 Uwe Kleine-K?nig wrote:
Quoted 26 lines · Fabio Estevam

Hi Uwe,

Quoted 22 lines · Uwe Kleine-K?nig

Hello Fabio,

Quoted 11 lines · Fabio Estevam
Quoted 1 line · Uwe Kleine-K?nig

So you didn't hit the problem that resetting a saif didn't work, right?

No, we haven't seen this reset issue.

Quoted 1 line

Do you have a few more technical details here? A usecase of my machine

Let me find out as it has been several years I worked on this problem. Will let you know.

Anything new on your end? I know from Lothar that he invested quite some time to debug his hardware setup, tested the codec instead of the i.MX28 as clock provider and several more things. I also spend some time on this issue and we both hope that Freescale/NXP can help in better understanding the issue and hopefully can come up with a recipe to make concurrent recording and playback on i.MX28 work.

Quoted 5 lines
Quoted 3 lines

Lothar is in contact with Freescale, too, but up to now with little success. The company I'm working for at the moment would also welcome a solution here.

Sorry for the delay. I have been on holidays.

I wonder who granted you to go on holidays given that we have problems :-)

Quoted 1 line

Can you confirm you have both SAIF interfaces being clocked from ref_pll?

root at hostname:/sys/kernel/debug/clk find -name saif?_sel ./ref_xtal/pll0/saif0_sel ./ref_xtal/pll0/saif1_sel

Quoted 9 lines

root at hostname:/sys/kernel/debug/clk cat ./ref_xtal/pll0/saif?_sel/clk_rate 480000000
480000000

This is based on 3.10 (but I hope to update soon to 4.4ish). I know that Lothar uses 4.4. Also Lothar noticed that disabling one of these saif_sel clocks doesn't make an impression on the interfaces, they just continue to run. Maybe a clock is routed in a wrong way?

That's obviously some misunderstanding.
What I observed is, that by selectively disabling and re-enabling one of the SAIF clocks in any way (toggling the CLKGATE bit in the CLKCTRL_SAIF# register, toggling the RUN bit in the SAIF_CTRL register or even toggling the SLAVE_MODE bit in the SAIF_CTRL register) the SAIF interfaces get out of sync (if they happened to be in sync in the first place) with no way to deterministically get them in sync again.

Since the SAIF0 clock is routed to the codec, sampling the data on the SAIF1 interface is not in sync with the data sent by the codec.

I also tried tying the BITCLK resp. LRCLK of both SAIFs together and selecting the SAIF1 inputs as source via the SAIF_CLKMUX_SEL field in the DIGCTL_CTRL register. Even with this setup there is no way to get consistent data sampled on the SAIF1 interface.

Lothar Wa?mann

#9 lore raw
In reply to Uwe Kleine-König
Quoted 7 lines · Uwe Kleine-K?nig

root at hostname:/sys/kernel/debug/clk find -name saif?_sel ./ref_xtal/pll0/saif0_sel ./ref_xtal/pll0/saif1_sel

root at hostname:/sys/kernel/debug/clk cat ./ref_xtal/pll0/saif?_sel/clk_rate 480000000
480000000

Ok, what about the SAIF0 and SAIF1 sampling rates: are they always the same?

#10 lore raw

Hello Fabio,

Quoted 7 lines · Fabio Estevam
Quoted 4 lines · Uwe Kleine-K?nig

root at hostname:/sys/kernel/debug/clk find -name saif?_sel ./ref_xtal/pll0/saif0_sel ./ref_xtal/pll0/saif1_sel

Quoted 5 lines
Quoted 3 lines

root at hostname:/sys/kernel/debug/clk cat ./ref_xtal/pll0/saif?_sel/clk_rate 480000000
480000000

Ok, what about the SAIF0 and SAIF1 sampling rates: are they always the same?

Lothar found a recipe to reproduce. I didn't try, but it's something along the lines of (Lothar please correct if I'm wrong):

- start a recording on one SAIF
- start playback on the other SAIF
- using direct access to the registers stop and restart the playback SAIF via the RUN bit.

The program I have doesn't provide a reliable reproduction recipe, it runs in a loop and sometimes need several (>1000) iterations to trigger. In my setup the sampling rates don't change. The values of BITCLK_MULT_RATE differ however in my setup, I don't see why though.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#11 lore raw
In reply to Fabio Estevam

Hi,

Quoted 7 lines · On Tue, 16 Feb 2016 13:01:19 -0200 Fabio Estevam wrote:
Quoted 4 lines · Uwe Kleine-K?nig

root at hostname:/sys/kernel/debug/clk find -name saif?_sel ./ref_xtal/pll0/saif0_sel ./ref_xtal/pll0/saif1_sel

Quoted 6 lines
Quoted 3 lines

root at hostname:/sys/kernel/debug/clk cat ./ref_xtal/pll0/saif?_sel/clk_rate 480000000
480000000

Ok, what about the SAIF0 and SAIF1 sampling rates: are they always the same?

Yes, of course. The driver wouldn't allow using both interfaces with different sample rates any way.

Lothar Wa?mann

#12 lore raw

Hi all,

Quoted 15 lines · Lothar Wa?mann

Hi,

Quoted 12 lines · On Tue, 16 Feb 2016 13:01:19 -0200 Fabio Estevam wrote:
Quoted 8 lines · Uwe Kleine-K?nig

root at hostname:/sys/kernel/debug/clk find -name saif?_sel ./ref_xtal/pll0/saif0_sel ./ref_xtal/pll0/saif1_sel

root at hostname:/sys/kernel/debug/clk cat
./ref_xtal/pll0/saif?_sel/clk_rate
480000000
480000000

Quoted 6 lines
Quoted 3 lines

Ok, what about the SAIF0 and SAIF1 sampling rates: are they always the same?

Yes, of course. The driver wouldn't allow using both interfaces with different sample rates any way.

Are there any updates about this issue?

I am facing the same problem when using SAIF1 for capture and SAIF0 for playback. SAIF1 uses SAIF0 as the master and I do set MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0 when bringing up the board. However, whenever I record with

$ arecord -D hw:0,1 -t wav -c 2 -r 48000 -f S16_LE -d 5 /tmp/out.wav

and playback afterwards:

$ aplay -D hw:0,0 /tmp/out.wav

I only get noise.

Note, that I am using the Audio Codec Board from Mikroelectronika, but replaced the on-board 12.288MHz quarz with the MCLK line from SAIF0.

Best regards,
J?rg Krause