There may be something wrong with my ADC casuing the noise. I won’t worry about that just yet.
I tried combining the two devices (inputs and outputs) to a single virtual device using asound multi plugin but the required library is not found in zynthian.
It looks like we may need to write a driver. The simple-audio-card driver seems to have a limitation that you cannot combine codecs into a single device. Skeleton code might look something like this:
I was worried that we will need to do a little bit more than just overlay. If we need to develop our own codec where can I found more information what is the process of compiling it and registering for overlay to see it ?
Yay! I have written a codec driver that provides duplex audio… and it works!!! I took the spdif_dit codec and modified to provide duplex operation, so it creates both two inputs and two outputs for each I2S port. I have put the code in a repo within my GitHub account.
Please let me know if it works. I can’t test audio input at the momement due to a suspected faulty board. (I need to solder the other board up…)
@riban what is the easiest way to get zynthian linux environment ready to compile. I am missing kernel header files and probably few other bits and peaces. I am searching the net to see how to get them all installed but maybe you can quickly tell me what is the minimum.
(venv) root@zynthian:~/zynaudio# apt-get install raspberrypi-kernel-headers
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
raspberrypi-kernel-headers
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 0 B/10.2 MB of archives.
After this operation, 64.8 MB of additional disk space will be used.
Selecting previously unselected package raspberrypi-kernel-headers.
(Reading database ... 179624 files and directories currently installed.)
Preparing to unpack .../raspberrypi-kernel-headers_1%3a1.20230405-1_arm64.deb ...
Unpacking raspberrypi-kernel-headers (1:1.20230405-1) ...
Setting up raspberrypi-kernel-headers (1:1.20230405-1) ...
(venv) root@zynthian:~/zynaudio# make
make -C /lib/modules/6.6.47-v8-16k+/build M=/root/zynaudio modules
make[1]: *** /lib/modules/6.6.47-v8-16k+/build: No such file or directory. Stop.
make: *** [Makefile:4: all] Error 2
(venv) root@zynthian:~/zynaudio#
@riban , if you have not checked already, it would be worth checking source code of the codec that this guy made it working on older kernel. Our card should be the same as the one that he used. He managed to record using audacity with no problems.
I believe the noise on the input is due to PCM1808 only supporting 24-bit audio. We have it configured for 32-bit and so there are 8 (most significant) bits of noise. This is validated by the low-level tone I can hear below the noise from the tone generator I am feeding into the input.
I tried changing dai-tdm-slot-width = <24> which should work but this throws an error when trying to load the driver: ASoC: error at snd_soc_dai_set_tdm_slot on 1f000a4000.i2s: -22.
My duplex driver is a simple wrapper. I need to dig deeper…
It looks like the simple-card driver is throwing an error before the codec driver even has a chance to set the TDM width. We may need a new card driver…