I2s-out overlay to enable i2s0

Here is an overlay to enable i2s out.

https://github.com/eragefe/Rockpi-S/raw/master/i2s-out.dtbo

https://raw.githubusercontent.com/eragefe/Rockpi-S/master/i2s-out.dts

Copy i2s-out.dtbo to /boot/dtbs…/rockchip/overlay
edit /boot/uEnv.txt “overlays=rk3308-uart0 i2s-out”
save reboot

2 Likes

@eragefe Bit tangential but on the topic of I2S is it possible to have I2S in but retain the 2 channel Dac out?

When you load the overlay you get both playback and capture devices mapped.
So I guess without testing that it is possible.

Is it possible to skip the multicodecs-card and the rk3308-codec and directly use a different codec?

For reference, I was trying something along these lines:

@eragefe Dunno last time I mangled the DTB I2S was enabled but for both I2S_0 in/out that seemed to disconnect the DAC in preference for a DAC on the I2S.

I will give you overlay a try but expecting prob the same.

Have you compiled the pcm5102a codec? It is not precompiled in the official image as far as can see.
What image are you trying to apply your overlay to ? Radxa ? Armbian?

On what image will this work? Armbian? Radxa?

I have only tested that with Radxa image.

This was with the Ambian 5.x image – I had the pcm5102a codec compiled, but couldn’t get it linked up.

The reason I ask about using a different codec is I don’t think I ported all the I2S stuff from the 4.4 kernel - (the multicodecs-card for example) over to the 5.x kernel, so was playing around directly with the pcm5102a codec using the simple-audio-card (my last attempt). I also now notice that a lot of my testing commits also ended up in the patch list so should probably clean that up… :sweat_smile:

You seem to understand the audio pipeline better than me, do you think its possible to use a different code directly?

PS: Not sure, but you could also try with snd-soc-dummy as it should require no additional modules?

The multicodecs-card will not work with the Armbian 5.x kernel builds – unless some other board has a patch for it in Armbians’s build toolchain.

ok
Then try this one you can change the spdif codec with your pcm5102 but it is really no need for that.
They are almost the same.
https://raw.githubusercontent.com/eragefe/Rockpi-S/master/simple_card.dts
tested with radxa image

After loading the overlay you will get
**** List of PLAYBACK Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: DAC [DAC], device 0: ff300000.i2s-dit-hifi dit-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

Thanks for the overlay. It works for me on 4.4.143-57.

There is also i2s-tdm driver in the buildin modules, but my knowledge of the
devicetree stuff is to low to get it working.

I like to add a ADAU1701 for driving a 5.1 system including headset.

Any help is welcome

Any pointers as to what I might be doing wrong?
I’m trying to get your simple_card overlay working, but can’t seem to get any output. This is on the Radxa Debian image from 2020-08-10.

rock@rockpis:~$ uname -a
Linux rockpis 4.4.143-55-rockchip-g6b7accbc999b #1 SMP PREEMPT Wed Jul 29 02:54:35 UTC 2020 aarch64 GNU/Linux
# Fetch the overlay
rock@rockpis:~$ wget https://raw.githubusercontent.com/eragefe/Rockpi-S/master/simple_card.dts
# Compile it
rock@rockpis:~$ sudo dtc -I dts -O dtb -f simple_card.dts -o simple_card.dtbo
# Move it 
rock@rockpis:~$ sudo cp simple_card.dtbo /boot/dtbs/4.4.143-55-rockchip-g6b7accbc999b/rockchip/overlay/
rock@rockpis:~$ cat /boot/uEnv.txt
verbosity=7
fdtfile=rockchip/rk3308-rock-pi-s.dtb
console=ttyS0,1500000n8
overlays=rk3308-uart0 simple_card
rootuuid=ee60d2e1-358c-467c-acc8-a147c5b38695
initrdsize=0x5c96f8
kernelversion=4.4.143-55-rockchip-g6b7accbc999b
initrdimg=initrd.img-4.4.143-55-rockchip-g6b7accbc999b
kernelimg=vmlinuz-4.4.143-55-rockchip-g6b7accbc999b
rock@rockpis:~$ sudo reboot

rock@rockpis:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: rockchiprk3308a [rockchip,rk3308-acodec], device 0: dailink-multicodecs rk3308-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

But don’t seem to get any output on my DAC. Will trying putting it on the scope to counter check later on.

PS: The i2s-out overlay works, so quite sure I didn’t mess up the wiring.

I have to update kernel to 4.4.143-57-rockchip-g4b8d0571d76e
to get at least the 2 ch out working.

8ch is still not working:
ioctl(4</dev/snd/pcmC1D0p<char 116:8>>, SNDRV_PCM_IOCTL_WRITEI_FRAMES, 0x7ff5b23ec0) = -1 EIO

@peterk Just to confirm - which overlay are you using? The i2s-out or the simple_card one?

ash card 1 is not the result of the simple-card overlay you are trying to load.
The simple-card overlay uses the spdif-dit codec to get I2S out. Maybe the driver for spdif-dit codec is missing in your kernel and the overlay fails to load. Use the dummy-codec instead and it will load.
When you asked last time you used the PCM5102 codec and it works if it is compiled in your kernel.

To be more precise in the simple_card.dts replace the
compatible = “linux,spdif-dit”;
with
compatible = “rockchip,dummy-codec”;

peterk the overlay actually uses the i2s-tdm driver but in your case you have to replace the codec part with the ADAU1701 codec in the overlay

compatible = “adi,adau1701”;
AND
you must have the adau1701 module compiled in the kernel to get it work.

Thanks for getting back.
Card 1(rockchiprk3308a) here is the analog codec if I understood correctly, and not the I2S card.
When I load the simple_card i2s-out overlay, the analog output is instead mapped to the I2S output correct? Or do they both work simultaneously?

W.t.r simple_card, I already tried with the dummy-codec but that did not seem to work. I have to check if the kernel modules is already built however.

EDIT: first simple_card should read i2s-out

They both can work simultaneously.
Just replace compatible = “linux,spdif-dit”; with compatible = “rockchip,dummy-codec”; and recompile the dts and reboot.
You will get
rock@rockpis:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: rockchiprk3308a [rockchip,rk3308-acodec], device 0: dailink-multicodecs rk3308-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: DAC [DAC], device 0: ff300000.i2s-dummy_codec dummy_codec-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

card 2 will output i2s.

This is what I was trying with earlier - it is the same simple_card overlay from you, but don’t seem to be able to reproduce your results! Could you share your dts/dtbo again to compare?

rock@rockpis:~$ cat simple_card_dummy.dts
// Definitions for DummyDAC
/dts-v1/;
/plugin/;

/ {
        compatible = "radxa,rockpis", "rockchip,rk3308";

        fragment@0 {
                target = <&i2s_8ch_0>;

                __overlay__ {
                        #sound-dai-cells = <0>;
                        status = "okay";
                        };
               };

        fragment@1 {
                target-path = "/";

                __overlay__ {
                        i2s0_out: i2s0-out {
                                #sound-dai-cells = <0>;
                                compatible = "linux,snd-soc-dummy";
                                status = "okay";
                                };

                        sound_i2s {
                                simple-audio-card,name = "DummyDAC";
                                compatible = "simple-audio-card";
                                simple-audio-card,format = "i2s";
                                simple-audio-card,bitclock-master = <&cpu_dai>;
                                simple-audio-card,frame-master = <&cpu_dai>;
                                simple-audio-card,mclk-fs = <256>;
                                status = "okay";

                                cpu_dai: simple-audio-card,cpu {
                                sound-dai = <&i2s_8ch_0>;
                                };

                                codec_dai: simple-audio-card,codec {
                                sound-dai = <&i2s0_out>;
                                };
                         };
                };
        };
};


From dmesg I see the the module is being loaded, but it fails to bind.

[    1.572621] dummy_codec dummy-codec: Unable to get mclk
[    1.573575] rk3308-acodec ff560000.acodec: GPIO lookup for consumer hp-ctl
[    1.573595] rk3308-acodec ff560000.acodec: using device tree for GPIO lookup
[    1.573612] of_get_named_gpiod_flags: can't parse 'hp-ctl-gpios' property of node '/acodec@ff560000[0]'
[    1.573626] of_get_named_gpiod_flags: can't parse 'hp-ctl-gpio' property of node '/acodec@ff560000[0]'
[    1.573640] rk3308-acodec ff560000.acodec: using lookup tables for GPIO lookup
[    1.573656] rk3308-acodec ff560000.acodec: lookup for GPIO hp-ctl failed
[    1.573670] rk3308-acodec ff560000.acodec: Don't need hp-ctl gpio
[    1.574252] rk3308-acodec ff560000.acodec: GPIO lookup for consumer spk-ctl
[    1.574265] rk3308-acodec ff560000.acodec: using device tree for GPIO lookup
[    1.574280] of_get_named_gpiod_flags: can't parse 'spk-ctl-gpios' property of node '/acodec@ff560000[0]'
[    1.574295] of_get_named_gpiod_flags: can't parse 'spk-ctl-gpio' property of node '/acodec@ff560000[0]'
[    1.574308] rk3308-acodec ff560000.acodec: using lookup tables for GPIO lookup
[    1.574323] rk3308-acodec ff560000.acodec: lookup for GPIO spk-ctl failed
[    1.574337] rk3308-acodec ff560000.acodec: Don't need spk-ctl gpio
[    1.574981] rk3308-acodec ff560000.acodec: GPIO lookup for consumer pa-drv
[    1.574996] rk3308-acodec ff560000.acodec: using device tree for GPIO lookup
[    1.575011] of_get_named_gpiod_flags: can't parse 'pa-drv-gpios' property of node '/acodec@ff560000[0]'
[    1.575025] of_get_named_gpiod_flags: can't parse 'pa-drv-gpio' property of node '/acodec@ff560000[0]'
[    1.575039] mmc_host mmc2: Bus speed (slot 0) = 50000000Hz (slot req 50000000Hz, actual 50000000HZ div = 0)
[    1.575960] rk3308-acodec ff560000.acodec: using lookup tables for GPIO lookup
[    1.575975] rk3308-acodec ff560000.acodec: lookup for GPIO pa-drv failed
[    1.575988] rk3308-acodec ff560000.acodec: Don't need pa-drv gpio
[    1.576314] mmc2: new high speed SDIO card at address 0001
[    1.577080] rk3308-acodec ff560000.acodec: De-pop as much as possible
[    1.577821] The acodec version is: a
[    1.636386] rk-multicodecs acodec-sound: rk3308-hifi <-> ff320000.i2s mapping ok
[    1.638606] input: rockchip,rk3308-acodec Headphones as /devices/platform/acodec-sound/sound/card1/input0

Any ideas?

you replaced with compatible = “linux,snd-soc-dummy”;
it is not the same

1 Like