SGTL5000 LINE-IN Sound Record Problem

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

SGTL5000 LINE-IN Sound Record Problem

跳至解决方案
10,563 次查看
topkarag
Contributor III

Hello,
I am running Android 11 operating system with IMX8MQ processor on custom carrier board. I am using SGTL5000 codec.
I am trying to record sound by connecting microphone to Line-In pin of SGTL5000 chip. However, Frame number is different from 0, that is, although frame size increases as recording time increases, no sound is heard in xxx.wav file that is recorded.
I am sure about microphone connection because same connection works with same sgtl5000 codec in our other Linux based custom devices.
In my researches, I see that some people have this problem but they measure 0 frames after recording. I do not have such a situation, I see that frame size increases as recording time increases.

As stated in SGTL5000 document, Line-In can bypass ADC and go to Headphone output. In order to cancel this, I cleared CHIP_ANA_CTRL -> SELECT_HP bit. I write the value 0x0036 to the CHIP_ANA_CTRL register on the driver side. Therefore, I think Line-In does not go directly to the HP output, it goes to the adc.

Also, I learned that the ADC_POWERUP Bit value in the CHIP_DIG_POWER register specified in the datasheet should be 0x1 for the adc to be enabled, when I check the driver side, the ADC_POWERUP and DAC_POWERUP bit values ​​appear as 0x1. So there is no problem there either.

I use tinycap for sound recording.
I open sound files with tinyplay. I get sound through the lineout pins. I can listen to normal wav files, only the file I record has no sound.

I noticed that there is a capture mux variable in the tinymix settings. Even though I changed this to LINE_IN, I still cannot record sound properly.

Below, I save the default setting as tinymix as tinymix_default.txt.
Below, I am saving the changes I made to be able to record sound via tinymix as tinymix_changed.txt.
Changes I made via Tinymix

Controller Name |Default Value| Updated Value|
--------------------------------------------
CAPTURE VALUME | 0 0 >               | 12 12 |
--------------------------------------------
CAPTURE SWITCH | OFF >               | ON |
--------------------------------------------
Mic Volume | 0 >                             | 3 |
--------------------------------------------
Capture Mux | MIC_IN >                 | LINE_IN |
--------------------------------------------

SGTL5000 Power Connections:
VDDIO:1.8V
VDDD: 1.8V (VDDD powered up VDDIO and VDDA have alrady powered up according to ErrataSheet. We have solved it by hardware configuration)
VDDA: 3.3

0 项奖励
回复
1 解答
9,810 次查看
topkarag
Contributor III

Hello everyone. I have solved the problem. Problem was in sai2 definition of devicetree. MX8MQ_IOMUXC_SAI2_RXD0_SAI2_RX_DATA0  was not defined which is responsible for audio input functionality of I2S.
Here is old version and new worked version of sai2grp definition. 

Old Version of sai2 definition

       pinctrl_sai2: sai2grp {
                fsl,pins = <
                        MX8MQ_IOMUXC_SAI2_TXFS_SAI2_TX_SYNC     0xd6
                        MX8MQ_IOMUXC_SAI2_TXC_SAI2_TX_BCLK      0xd6
                        MX8MQ_IOMUXC_SAI2_MCLK_SAI2_MCLK        0xd6
                        MX8MQ_IOMUXC_SAI2_TXD0_SAI2_TX_DATA0    0xd6
>;
        };



Worked version of sai2 definition 

      pinctrl_sai2: sai2grp {
                fsl,pins = <
                        MX8MQ_IOMUXC_SAI2_TXFS_SAI2_TX_SYNC     0xd6
                        MX8MQ_IOMUXC_SAI2_TXC_SAI2_TX_BCLK      0xd6
                        MX8MQ_IOMUXC_SAI2_MCLK_SAI2_MCLK        0xd6
                        MX8MQ_IOMUXC_SAI2_TXD0_SAI2_TX_DATA0    0xd6
           MX8MQ_IOMUXC_SAI2_RXD0_SAI2_RX_DATA0    0xd6
>;    
        }

Thank you for following this topic. 
Regards

 

在原帖中查看解决方案

0 项奖励
回复
11 回复数
9,811 次查看
topkarag
Contributor III

Hello everyone. I have solved the problem. Problem was in sai2 definition of devicetree. MX8MQ_IOMUXC_SAI2_RXD0_SAI2_RX_DATA0  was not defined which is responsible for audio input functionality of I2S.
Here is old version and new worked version of sai2grp definition. 

Old Version of sai2 definition

       pinctrl_sai2: sai2grp {
                fsl,pins = <
                        MX8MQ_IOMUXC_SAI2_TXFS_SAI2_TX_SYNC     0xd6
                        MX8MQ_IOMUXC_SAI2_TXC_SAI2_TX_BCLK      0xd6
                        MX8MQ_IOMUXC_SAI2_MCLK_SAI2_MCLK        0xd6
                        MX8MQ_IOMUXC_SAI2_TXD0_SAI2_TX_DATA0    0xd6
>;
        };



Worked version of sai2 definition 

      pinctrl_sai2: sai2grp {
                fsl,pins = <
                        MX8MQ_IOMUXC_SAI2_TXFS_SAI2_TX_SYNC     0xd6
                        MX8MQ_IOMUXC_SAI2_TXC_SAI2_TX_BCLK      0xd6
                        MX8MQ_IOMUXC_SAI2_MCLK_SAI2_MCLK        0xd6
                        MX8MQ_IOMUXC_SAI2_TXD0_SAI2_TX_DATA0    0xd6
           MX8MQ_IOMUXC_SAI2_RXD0_SAI2_RX_DATA0    0xd6
>;    
        }

Thank you for following this topic. 
Regards

 
0 项奖励
回复
10,545 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Did you confirmed that audio input is correctly routed in OS?

Best regards.

0 项奖励
回复
10,521 次查看
topkarag
Contributor III

Hello, thank you for your quick reply. 

I have changed the audio routing in audio_policy_configuration.xml file from built-in mic to Line-In. I have attached the xml file. 
Also, there are another pcmc0d0c capture card in system. This is not used, so maybe ı can desible it from device tree but anyway ı have choosed attached device as Line-In as you can check from xml file. 

There are some info about audio in OS. 

1|smarc_mx8mq:/ $ cat /proc/asound/cards
0 [imxhdmiarc ]: imx-hdmi-arc - imx-hdmi-arc
imx-hdmi-arc
1 [sgtl5000audio ]: sgtl5000-audio - sgtl5000-audio
sgtl5000-audio

130|smarc_mx8mq:/ $ ls /dev/snd
controlC0 controlC1 pcmC0D0c pcmC1D0c pcmC1D0p timer



I have attached dumpsys audio file, please check it also. Best Regards

0 项奖励
回复
10,506 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Got it, thank you for the information.

Here some debugging recommendations:

  • Check that CODEC voltages are according to manufacturer specifications.
  • Check that clocks are configured as expected.
  • When linux starts, can you see the prompt of audio mapping-->ok?
  • Check I2S/I2C communication when recording.

Do you get some kind of errors during recording?

Best regards.

0 项奖励
回复
10,491 次查看
topkarag
Contributor III

Hello again;
I have checked codec voltages already, it was same with datasheet and there was no any problem with voltage levels. I have also checked changing VDDA voltage from 3.3 to 1.8, nothing changed. I have aso checked VDDD voltage with 3.3V, problem was still exist.  I think problem is in software side, or configuring audio policies. But as far as ı know, it is configured by audio_policy_configuration.xml file. I have changed it correct but still there is no any recording.

By debugging, in recoding time, ı have seen analog voltage in changing when while changing recorded voice, in software part ı have seen also frame size increasing with time. So if ı see 0 frame, ı would say it will never be recorded but ı have seen frame size increased by time of recording. 

Clock was correctly given in codec as 24.576MHz. I have given as internal and external to check is there any problem with clock size but in both case problem was still exist. 

Let me give you my dmesg. Let me remind yo that ı have android11 device which uses kernel 5.10. 


We have seen same codec in linux devices and ı have seen there "audio mapping->ok?". But in my device, there is no any audio mapping-->ok? message. Maybe there should be any problem with this part. Please check my DMESG log to get further information. I have also added audio_policy_configuration.xml file to give more info. 

Best Regards;


0 项奖励
回复
10,461 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Thank you for the update.

In this case I suggest you verify SGTL5000 configuration and confirm that CODEC's configuration is the correct for LINE-IN recording such as internal routing and that is transferring the data in i2S output.

Device tree configuration is ok since you are able to play audio, please check if the initialization/configuration in CODEC's driver is correct.

Best regards.

0 项奖励
回复
10,449 次查看
topkarag
Contributor III

As far as ı know, line in goes directly headphone output or goes internal audio switch. So, ı have checked the driver to see what is default and it was going to headphone directly. I have changed it by looking at datasheet. It is 6th bit of CHIP_ANA_CTRL 0x0024 register. I have cleared it since datasheet was telling it to use line-in as input of audio switch. I have attached the figure for this. Long story short I have changed the direction from A to B by writing 0x0036 value to  0x0024 CHIP_ANA_CTRL register so it enabled line-in as adc input, unmute adc analog volume and select headphone input as DAC. 


So ı think driver side is okay, ı have seen changed kernel driver messages in kernel(check dmesg you can see a info line of sgtl5000 content topkarag). Maybe there should be something missing with configuration except from driver ? Do you know anything else for configuration routing except audio_policy_configuration.xml file ? Which files or configurations effect this issue ? Specially android11 and linux kernel 5.10 ? As far as ı know there is only audio_policy_configuration file. 

 

0 项奖励
回复
10,423 次查看
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Thank you for the information, just to confirm that LINE-IN data outs from I2S port.

According to Android User's Guide, the process to add a new card is described in section 8.2.2 Supporting a new sound card.

Best regards.

0 项奖励
回复
10,400 次查看
topkarag
Contributor III

Hello, thanks for your reply. 
First of all, ı have checked I2S3DOUT(26) and I2S3DIN(25) pins. 
When tinyplay play any .wav file, I2S3DOUT signal wave changes. 
When tinycap start record any .wav file. I2SDIN signal wave also changes. 


BUT, IF ı play recorded .wav file with tinyplay, ı did not see any changes in I2S3DOUT(26 pin) signal wave. So problem is playing recorded file. 

Also, when ı record anything with tinycap, frame size is increasing with recording time. SO ı think if ı can not record anything, it should be zero frame size. I have seen this kind of problem in forum, other persons has issue to record more than 0 frame. But i can record a wav file with different than zero frame size but ı can not play it since when ı try to play this recorded file, I2S3DOUT pin signal wave does not change. 

I will check section 8.2.2 also as you mentioned. I will add it here also. 

Best Regards;

 

0 项奖励
回复
10,443 次查看
topkarag
Contributor III

Ekran görüntüsü 2025-01-30 101519.jpg

0 项奖励
回复
10,488 次查看
topkarag
Contributor III

Let me correct myself. audio-> mapping ok message which ı have seen our other custom devices were not linux, it was IMX6 based custom board and android 9 was running on it. Also codec was different. Here what ı have seen in imx8 custom board with different codec which is cs42l73. But as far as ı understand thise mapping is generic operaciton so indepentent from which codec. Do you know how can ı make this operation in android 11 with IMX8MQ MCU ? 

Let me show you the messages example on IMX6 board with different codec(cs42l73). 
What ı have seen in imx6 and cs42l73 codec:

root@sabresd_6dq:/ # dmesg | grep mapping
imx-cs42l73 sound: cs42l73-asp <-> 2028000.ssi mapping ok
imx-spdif sound-spdif: snd-soc-dummy-dai <-> 2004000.spdif mapping ok
imx-audio-hdmi sound-hdmi: hdmi-hifi <-> soc:hdmi_audio@00120000 mapping ok

Best Regards;

标记 (1)
0 项奖励
回复