imx7 how to capture raw PCM samples from I2S

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

imx7 how to capture raw PCM samples from I2S

3,729 次查看
gonewithwind-peter
Senior Contributor I

imx7 how to capture raw PCM samples from I2S.

I config imx7 i2s as slave mode( fs ,clock and data pin as input which are conneted to my data device that generates clock,fs and data) after changing fsl_sai.c driver following here iMX7 I2S playback in Slave mode   to clear 

bit BCD register I2Sx_TCR2,  bit FSD register I2Sx_TCR4, the code changed as posting later:

and the i2s do not connect to sgtl5000. it connects to my device which is i2s masrer.

after that,I want  read data  directly from i2s. 

how can I do? 

I tried  imx6_platform_sdk/apps/obds/src/tests (GitHub - flit/imx6_platform_sdk: Bare metal SDK for i.MX6 Q/D/DL/S/SL ). but I did  not make it work.

any idea?

Thanks

========================

diff -Naur ori/sound/soc/fsl/fsl_sai.c patches/sound/soc/fsl/fsl_sai.c
--- ori/sound/soc/fsl/fsl_sai.c 2019-07-02 15:58:04.328667455 -0400
+++ patches/sound/soc/fsl/fsl_sai.c 2019-07-03 10:24:58.693299060 -0400
@@ -374,17 +374,17 @@
/* DAI clock master masks */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBS_CFS:
- val_cr2 |= FSL_SAI_CR2_BCD_MSTR;
- val_cr4 |= FSL_SAI_CR4_FSD_MSTR;
+ //val_cr2 |= FSL_SAI_CR2_BCD_MSTR;
+ //val_cr4 |= FSL_SAI_CR4_FSD_MSTR;
break;
case SND_SOC_DAIFMT_CBM_CFM:
sai->slave_mode[tx] = true;
break;
case SND_SOC_DAIFMT_CBS_CFM:
- val_cr2 |= FSL_SAI_CR2_BCD_MSTR;
+ //val_cr2 |= FSL_SAI_CR2_BCD_MSTR;
break;
case SND_SOC_DAIFMT_CBM_CFS:
- val_cr4 |= FSL_SAI_CR4_FSD_MSTR;
+ //val_cr4 |= FSL_SAI_CR4_FSD_MSTR;
sai->slave_mode[tx] = true;
break;
default:
@@ -392,10 +392,10 @@
}

regmap_update_bits(sai->regmap, FSL_SAI_xCR2(tx, offset),
- FSL_SAI_CR2_BCP | FSL_SAI_CR2_BCD_MSTR, val_cr2);
+ FSL_SAI_CR2_BCP /*| FSL_SAI_CR2_BCD_MSTR*/, val_cr2);
regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx, offset),
FSL_SAI_CR4_MF | FSL_SAI_CR4_FSE |
- FSL_SAI_CR4_FSP | FSL_SAI_CR4_FSD_MSTR, val_cr4);
+ FSL_SAI_CR4_FSP /* | FSL_SAI_CR4_FSD_MSTR*/, val_cr4);

return 0;
}

0 项奖励
回复
4 回复数

3,135 次查看
igorpadykov
NXP Employee
NXP Employee

Hi peter

general approach could be to analyse Chapter 7 Audio attached Linux Manual

to understand what sound formats are supported for i.mx sai driver.

Supported formats are described in sect.7.1.2.1 Stereo CODEC Features,

sect.7.1.2.3. If used format is not supported, try to convert it to supported format

or try to add support for new format using Table 7-1. Stereo Codec SoC Driver Files.

One can read from i2s master using i.mx7 SAI Receive Data Register (I2Sx_RDRn).

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

3,135 次查看
gonewithwind-peter
Senior Contributor I

Hi igorpadykov

Thank you very much for your reply.

I have a little confuse:

my questions are  :

Q1:do you have linux user space code to read I2S data directly? the code at here (GitHub - flit/imx6_platform_sdk: Bare metal SDK for i.MX6 Q/D/DL/S/SL  ) It seems it not running on linux , it's non-system code,is it right? if the code is there for linux , which file can be change to read i2s directly?

In my application. imx7 i2s as slave mode(technexion pico-pi-imx7 board), my device is  as i2s master to continuously send data to imx7 i2s (same as spi data. but imx7 spi salve not works well, so I try to use i2s pcm. I use raspberry pi pcm as spi slave worked well before, but raspberry can not be productions,so we choose imx7 to try).  I follow this page iMX7 I2S playback in Slave mode  to modify fsl_sai.c as posting as before.

Q2. do i need write a driver ? I find some people discuss at here: Capturing RAW PCM DATA in Imx6     and here https://community.nxp.com/thread/321837   but it seems not work well.

attached is   my device to generate the  fs and clock(16bit),I did not capture data picture because my scope has only two channels.

Thank you very much.

0 项奖励
回复

3,135 次查看
igorpadykov
NXP Employee
NXP Employee

Hi peter

>Q1:do you have linux user space code to read I2S data directly? 

not sorry.

>Q2. do i need write a driver ?

I think yes

Best regards
igor

0 项奖励
回复

3,135 次查看
gonewithwind-peter
Senior Contributor I

hi igorpadykov

Thank you very much for your reply very soon.

I am trying to find more info using keywords "dummy codec driver using soc_utils.c" in google. and found something here: https://community.nxp.com/thread/391216     

I am trying to figure out

1. how to write the driver and

2. the user space  read i2s code.

later I will need your more help.

Thanks

Regards

peter

0 项奖励
回复