WM8960 codec on Vim


#1

Hello.

I have WM8960 codec connected to i2s (pins 29-33) and i2c (SCL-22, SDA-23).

I modify kvim_linux.dts, and add:

&i2c_a {
    status = "okay";
    wm8960: codec@1a {
    compatible = "wlf,wm8960";
            reg = <0x1a>;

            wlf,shared-lrclk;
    };

};

On boot in dmesg I have:
[ 4.514353] wm8960 1-001a: probe
[ 4.514479] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.514606] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.514719] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.514834] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.514949] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.515063] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.515177] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.515291] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.515405] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.515591] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.515706] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.515818] i2c i2c-1: master_xfer[0] W, addr=0x1a, len=2
[ 4.516005] i2c-core: driver [wm8960] registered

After record (arecord -D hw:0,0 test.wav) I don’t have sound.
I know, I must configure WM8960 (disable mute etc), but how do this? in /proc/asound/cards I only have AML-MESONAUDIO.
How add WM codec to alsa?


#2

No sound card for WM8960. Can you make sure your driver works? Maybe you can provide the dmesg log.


#3

https://pastebin.com/JYCTMnvs


#4

Hello jarbash,

You just defined the codec, you also need to define a new sound card.You can refer to


#5

Hello.

I add new sound card (asoc-simple-card).

880,914d879
       sound {
                 compatible = "simple-audio-card";
                 simple-audio-card,format = "i2s";
                 simple-audio-card,name = "wm8960-hifi";
                 status = "okay";
                 simple-audio-card,widgets =
                         "Microphone", "Mic Jack",
                         "Line", "Line In",
                         "Line", "Line Out",
                         "Speaker", "Speaker",
                         "Headphone", "Headphone Jack";
                 simple-audio-card,routing =
                         "Headphone Jack", "HP_L",
                         "Headphone Jack", "HP_R",
                         "Speaker", "SPK_LP",
                         "Speaker", "SPK_LN",
                         "LINPUT1", "Mic Jack",
                         "LINPUT3", "Mic Jack",
                         "RINPUT1", "Mic Jack",
                         "RINPUT2", "Mic Jack";

                 simple-audio-card,cpu {
                       sound-dai = <&i2s_dai>;
                 };
                 dailink0_slave: simple-audio-card,codec {
                       sound-dai = <&wm8960>;
                         clocks = <&wm8960_mclk>;
                         clock-names = "mclk";
                 };
         };
       wm8960_mclk: wm8960_mclk {
                 compatible = "fixed-clock";
                 #clock-cells = <0>;
                 clock-frequency = <12288000>;
         };
   1164,1170d1128
       wm8960: wm8960 {
               #sound-dai-cells = <0>;
               compatible = "wlf,wm8960";
               reg = <0x1a>;

               wlf,shared-lrclk;
       };

Now in dmesg I have:

asoc-simple-card sound: ASoC: platform (null) not registered

I found solution for this error - add this:

simple-audio-card,plat {
sound-dai = <???????>;
};

But what write in sound-dai = <???????> ?


#6

Is anyone can help me?


#7

How do you know that.vim is compatible with i2s dacs ? We suppose you use a vim1 under Linux, right?


#8

How do you know that.vim is compatible with i2s dacs ?

I don’t know. How to check this?

We suppose you use a vim1 under Linux, right?

Yes. VIM1 + Ubuntu (kernel 4.9.40). Also I have VIM2.


#9

Hello.

In oryginal kvim_linux.dts after executed below commands:

sudo i2cset -y 0 0x1a 0x1E 0x01; echo $?
sudo i2cset -y 0 0x1a 0x0E 0x02; echo $?
sudo i2cset -y 0 0x1a 0x08 0x00; echo $?
sudo i2cset -y 0 0x1a 0x32 0x68; echo $?
sudo i2cset -y 0 0x1a 0x5E 0x20; echo $?
sudo i2cset -y 0 0x1a 0x41 0x00; echo $?
sudo i2cset -y 0 0x1a 0x42 0x00; echo $?
sudo i2cset -y 0 0x1a 0x01 0x3F; echo $?
sudo i2cset -y 0 0x1a 0x03 0x97; echo $?
sudo i2cset -y 0 0x1a 0x56 0x00; echo $?
sudo i2cset -y 0 0x1a 0x44 0x50; echo $?
sudo i2cset -y 0 0x1a 0x36 0x05; echo $?

data is appear after executed arecod -D hw:0,0 -f dat | xxd:

00006a80: 9200 0000 1100 0000 3100 0000 e7ff 0000 ........1.......
00006a90: 4900 0000 46ff 0000 1c00 0000 1c00 0000 I...F...........
00006aa0: eaff 0000 8a00 0000 16ff 0000 ebff 0000 ................
00006ab0: 1401 0000 1200 0000 0300 0000 13ff 0000 ................
00006ac0: 6701 0000 6aff 0000 f300 0000 23ff 0000 g...j.......#...

unfortunately there is only noise instead of a voice.

I commented the ml_sound_meson card in the DTS.
Next, I added new card:

wm89_sound{
        compatible = "simple-audio-card";
        simple-audio-card,format = "i2s";
        simple-audio-card,name = "seeed-2mic-voicecard";
        status = "okay";
        simple-audio-card,widgets =
                "Microphone", "Mic Jack",
                "Line", "Line In",
                "Line", "Line Out",
                "Speaker", "Speaker",
                "Headphone", "Headphone Jack";
        simple-audio-card,routing =
                "Headphone Jack", "HP_L",
                "Headphone Jack", "HP_R",
                "Speaker", "SPK_LP",
                "Speaker", "SPK_LN",
                "LINPUT1", "Mic Jack",
                "LINPUT3", "Mic Jack",
                "RINPUT1", "Mic Jack",
                "RINPUT2", "Mic Jack";


        simple-audio-card,cpu {
            sound-dai = <&i2s_dai>;
        };
        dailink0_slave: simple-audio-card,codec {
                sound-dai = <&wm8960>;
                clocks = <&wm8960_mclk>;
                clock-names = "mclk";
        };
        simple-audio-card,plat {
            sound-dai = <&i2s_plat>;
        };
};


&i2c_a {
        #address-cells = <1>;
        #size-cells = <0>;

        status = "okay";

        wm8960: wm8960{
                compatible = "wlf,wm8960";
                reg = <0x1a>;
                #sound-dai-cells = <0>;
        };
};

After reboot new card is appear:

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: seeed2micvoicec [seeed-2mic-voicecard], device 0: I2S-wm8960-hifi wm8960-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

But when I try to record I have:

arecord -D hw:0,0 -f dat | xxd
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
00000000: 5249 4646 2400 0080 5741 5645 666d 7420  RIFF$...WAVEfmt
00000010: 1000 0000 0100 0200 80bb 0000 00ee 0200  ................
overrun!!! (at least 0.043 ms long)
overrun!!! (at least 0.044 ms long)
overrun!!! (at least 0.044 ms long)
overrun!!! (at least 0.041 ms long)
overrun!!! (at least 0.044 ms long)
overrun!!! (at least 0.042 ms long)
overrun!!! (at least 0.043 ms long)

Some one can help me?