This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3352: WM8776 ADC Capture not working.

Part Number: AM3352

Hello,

Currently we are reverse engineering a device to the latest TISDK kit. Unfortunately we do not have any original documentation. We stripped the DTS from the older kernel and went from there. Everything has been going fairly well this far, we managed to get all the devices working perfectly fine, except the audio. The board uses the WM8776 which is a multi-dai soundcard. One for capture and one for playback. I will briefly post the needed information regarding the device tree here:

mcasp0_pins: mcasp0_pins {
    pinctrl-single,pins = <
        AM33XX_IOPAD(0x990, PIN_OUTPUT | MUX_MODE0)
        AM33XX_IOPAD(0x994, PIN_OUTPUT | MUX_MODE0)
        AM33XX_IOPAD(0x998, PIN_OUTPUT | MUX_MODE0)
        AM33XX_IOPAD(0x99c, PIN_INPUT | MUX_MODE0)
        AM33XX_IOPAD(0x9a0, PIN_OUTPUT | MUX_MODE0)
        AM33XX_IOPAD(0x9a4, PIN_OUTPUT | MUX_MODE0)
        AM33XX_IOPAD(0x9a8, PIN_INPUT | MUX_MODE0)
        AM33XX_IOPAD(0x9ac, PIN_INPUT | MUX_MODE0)
    >;
};
     
     
&mcasp0 {
    #sound-dai-cells = <0>;
    pinctrl-names = "default";
    pinctrl-0 = <&mcasp0_pins>;
    rx-num-evt = <1>;
    tx-num-evt = <1>;
    serial-dir = <1 2 0 0
                  0 0 0 0
                  0 0 0 0
                  0 0 0 0>;
    num-serializer = <16>;
    tdm-slots = <2>;
    op-mode = <0>;
    status = "okay";
};           

&i2c0 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&i2c0_pins>;
    wm8776: wm8776@1b {
        #sound-dai-cells = <1>;
        reg = <0x1b>;
        compatible = "wlf,wm8776";
    };
    
sound {
    compatible = "simple-audio-card";
    simple-audio-card,name = "Audio Card";
    simple-audio-card,bitclock-inversion;

    simple-audio-card,dai-link@0 {
            format = "i2s";
            bitclock-master = <&cpu1>;
            frame-master = <&cpu1>;
            simple-audio-card,bitclock-inversion;
            cpu1: cpu {
                    sound-dai = <&mcasp0>;
                    system-clock-frequency = <11289600>;
            };

            codec {
                    sound-dai = <&wm8776 0>;
            };
    };

    simple-audio-card,dai-link@1 {
            format = "i2s";
            bitclock-master = <&cpu0>;
            frame-master = <&cpu0>;

            simple-audio-card,bitclock-inversion;

            cpu0: cpu {
                    sound-dai = <&mcasp0>;
                    system-clock-frequency = <11289600>;
            };
            
            codec {
                    sound-dai = <&wm8776 1>;
            };
        };
    };
};

I will also provide the original pinmux I got from the stripped DTS. Those where on old notations but I am pretty sure that I converted them correctly to todays standard.

mcasp0_pins: mcasp0_pins {
		pinctrl-single,pins = <0x190 0x08 0x194 0x08 0x198 0x08 0x19c 0x28 0x1a0 0x08 0x1a4 0x08 0x1a8 0x28 0x1ac 0x28>;
	};

One of the things I observed during using 

arecord -D hw:0,1 1.wav -f cd
debugging was the following:

It seems like the ADC does not have a capture stream. However, I cannot manage to figure out why. Is there anyone who can help me out figuring why this is not working as expected?

Best regards,

Lars

  • Hi Lars,

    Could you provide if you are able to see the soundcard? Also, are you able to see the MCLK, BCLK and FSYNC? From the DTS file, I see that you are using McASP's as master and WM8776 as slave.

    Also, could you add this entry in your DTS file as McASP is the sound master and see if there is any difference. 

    system-clock-direction-out;

    Appreciate if you could provide the entire logs when you run the alsa arecord command. 

    Best Regards,

    Suren

  • Hi Suren,

    Thanks for your reply. I am able to see the soundcard. I do not get any errors regarding probing in 

    dmes | grep asoc

    Also the playback codec works perfect. When using the ALSA Test.wav via aplay everything works as expected and correctly.

    When using arecord I do not get any errors so there is not much regarding logs. When recording I also do get the correct clock e.g. when recording 44.1Khz I do get a clock of 44.1 Khz. I have the feeling like the ADC does not get a input stream but I am not sure.

    Where do you want me to put the 

    system-clock-direction-out;


    Should it be in the CPU of every DAI, so in both cpu1 and cpu2, or outside the DAIs?


    Best regards,
    Lars




  • When using the following dts for the sound:

    sound {
    
        compatible = "simple-audio-card";
        simple-audio-card,name = "Simple Audio AM335x Roomplayer";
    
        simple-audio-card,dai-link@0 {
                format = "i2s";
                bitclock-master = <&cpu1>;
                frame-master = <&cpu1>;
    
                cpu1: cpu {
                        sound-dai = <&mcasp0>;
                        system-clock-frequency = <11289600 24576000>;
                        system-clock-direction-out;     
    
                };
    
                codec {
                       sound-dai = <&wm8776 0>;
                };
    
        };
        
        simple-audio-card,dai-link@1 {
                format = "i2s";
                bitclock-master = <&cpu0>;
                frame-master = <&cpu0>;
    
                cpu0: cpu {
                        sound-dai = <&mcasp0>;
                        system-clock-frequency = <11289600 24576000>;
                        system-clock-direction-out;
                };
    
    
    
                codec0: codec {
                        sound-dai = <&wm8776 1>;
                };
    
        };
    
    };

    I get when selectiong rate 44100 a clock of 88200Hz.

  • Hi Lars,

    You don't need to add widgets in the DTS file for what speakers/mic's to use and route the data?

    Please look at the following DTS file:

    https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/am335x-evm.dts

    So when adding the system-clock-direction-out DTS entry, I also see you have added clock frequency to be 24MHz, is there  a reason? Also, with this change, was the playback working perfectly? 

    Best Regards,

    Suren

  • Hi Suren,

    I am pretty sure it is not necessary since the WM8776 kernel driver already doest this. I have got all the expected widgets in alsamixer. On your second question: I have a clock mux on which I have a 11289600 and 24576000 clock. So I can switch between 44.1khz and 48Khz.

    The above works correctly for playback. I do not have any issues with the playback part of the codec it is fully working as expected. Capture however does not work. I forgot to mention I can actually record, for example:

    arecord -D hw:0,1 1.wav -f cd

    Does give me the file 1.wav. However when listening back to this file there is no sound, not even a zooming or buzzing sound either. It is a very weird issue especially since the playback has not given any issues and to my feeling the dts is correctly configured.

  • Hi Lars,

    Did you check the mic bias voltage? Also, can you set the Alsa mixer controls and see if that helps in capturing data correctly.

    For eg:

    amixer sset 'Right PGA Mixer Line1L' on  

    amixer sset 'Right PGA Mixer Line2R' on 

    amixer sset 'Left PGA Mixer Line1L' on

    amixer sset 'Right PGA Mixer Line1R' on

     amixer cset name='PGA Capture Switch' on

    amixer cset name='PGA Capture Volume' 110

    Hope this helps.

    Best Regards,

    Suren

  • Hi Suren,

    The board cannot be the issue I do have a 3.8.13 kernel which can both record and play audio. Also to be clear: I am capturing audio from a device, for example an iPhone via a 3.5mm input. I tried to set with amixer aswell just now but it does still not give any data the debug still says the ADC stream which is Capture is inactive.

    While:

    Stream capture is active on 'Capture'.

    Kind regards

  • Hi Lars,

    Could you please try the command to capture 2 channel audio for 20 sec:

    arecord -D hw:0,1 1.wav -f  S16_LE -r 48000 -c 2 -d 20

    Please share the 1.wav.

    Best Regards,

    Suren

  • Yes sure:

    The only thing I hear is a click at the beginning.

    Lars

  • Hi Lars,

    Thanks for the wav file. It seems like its capturing nothing.

    Also, Can you provide me the outputs of these commands

    arecord -l /aplay -l  (To list available soundcards) so, specifying the right card and sub device associated with the soundcard.

    Also, provide me what kernel version are you using or Processor SDK version, that you are testing with.

    I am sure, you might have already seen this link for Audio:

    https://software-dl.ti.com/processor-sdk-linux/esd/docs/latest/linux/Foundational_Components/Kernel/Kernel_Drivers/Audio.html#AM335x_EVM

    Best Regards,

    Suren

  • Hi Suren

    My SKD is am335x-evm-linux-sdk-src-08.02.00.24. My kernel version is

    root@debian-armhf:~# uname -r
    5.10.100-g7a7a3af903

    aplay and acapture output:

    root@debian-armhf:~# aplay -l && arecord -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: Default [audio card], device 0: davinci-mcasp.0-wm8776-hifi-playback wm8776-hifi-playback-0 [davinci-mcasp.0-wm8776-hifi-playback wm8776-hifi-playback-0]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    **** List of CAPTURE Hardware Devices ****
    card 0: Default [audio card], device 1: davinci-mcasp.0-wm8776-hifi-capture wm8776-hifi-capture-1 [davinci-mcasp.0-wm8776-hifi-capture wm8776-hifi-capture-1]
      Subdevices: 1/1
      Subdevice #0: subdevice #0

    I have read the TI documentation indeed which was usefull to port to the new kernel version. Unfortunately there are not a lot of cards which use the same setup as the WM8776. When I try to search online for a DTS which uses the WM8776 I cannot find anything either. So I am not 100% sure about the DTS either even though the Playback works correctly and expected. It could even be a bug in the driver as it is quite old.

    Kind regards,

    Lars

  • Hi Lars,

    I would suggest you to trace the DAPM path and see if the path is complete in order to record. 

    Best Regards,

    Suren

  • Hello Suren,

    The routing is if I am not mistaken from wm8776.c:

    When checking the DAPM via debugfs everything seems to be fine. 

    root@debian-armhf:/sys/kernel/debug/asoc/audio card/wm8776.0-001b/dapm# cat ./AIN2 && cat ./'Input Mixer' && cat ./ADC && cat ./Capture
    AIN2: On  in 1 out 1
     out  "AIN2 Switch" "Input Mixer"
    Input Mixer: On  in 1 out 1 - R13(0xd) mask 0x40
     out  "static" "ADC"
     in  "AIN2 Switch" "AIN2"
    ADC: On  in 1 out 1 - R13(0xd) mask 0x2
     stream Capture inactive
     out  "static" "Capture"
     in  "static" "Input Mixer"
    Capture: On  in 1 out 1
     stream Capture active
     out  "static" "IIS Capture"
     in  "static" "ADC"

    The only thing I am unsure about is the inactive capture on the ADC. But even when the ADC is enabled I would expect some sounds from the ADC.

    Kind regards,
    Lars

  • Hi Lars,

    When you say "Even when the ADC is enabled I would expect some sounds from the ADC" 

    Were you able to power on the ADC using DAPM?

    Does debugfs show ADC as active? and even then you are not able to capture sound?

    Best Regards,

    Suren

  • Hi Suren,

    Sorry for my late reply, we were busy with other projects. 

    When you say "Even when the ADC is enabled I would expect some sounds from the ADC" 

    Were you able to power on the ADC using DAPM?

    Yes.

    Does debugfs show ADC as active? and even then you are not able to capture sound

    Yes the ADC is shown as active.

    We still do not have a clue why it might not work.

    Kind regards,

    Lars

  • Hi Lars,

    I would suggest to contact Wolfson on driver support, as this looks like a bug in their driver.

    Best Regards,

    Suren