SBC with I2S codec drivers for playing/recording

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Most SBCs can be used in conjuction with a cape or plugin module supporting an I2S DAC to play sound.
Usually these SBC support a Linux distribution that includes ALSA drivers, over which one can add Jack, Pulseaudio and support other high level applications for playing music.
What does not seem to be so obvious is to find I2S ADC recording support.
Some time ago I thought I could use a Odroid C2 which is quite compact in size and includes a quite powerful quad ARM. I could even develop myself the HW including a I2S codec board. Unfortunately the Linux distributions do not support I2S recording drivers for Amlogic processor, and it's impossible to get support to make a driver for yourself.
So far I haven't been able to identify a SBC that is able to support play and record/capture MMAP drivers using I2S ADC/DAC codecs.
I find hard to believe that audio recording is not supported by SBCs in the market.
Does anybody know of SBCs that support this?
 
RPi has I2S capture support (I do not know if MMAPed, but why such condition?), there are I2S ADC boards/hats on the market, e.g. Datasheet DAC+ ADC | HiFiBerry , ADC Analog to Digital Converter AKM5720 I2S 24Bit / 96kHz - Audiophonics , etc.

I have never used Odroid C2, but the source code suggests the I2S input as specified in S905 SoC specs (page 182 of https://dn.odroid.com/S905/DataSheet/S905_Public_Datasheet_V1.1.4.pdf ) should be supported linux/sound/soc/aml/m8 at odroidc2-3.14.y * hardkernel/linux * GitHub linux/aml_i2s.c at odroidc2-3.14.y * hardkernel/linux * GitHub .

I did not find any implementation of a driver for any I2S ADC for odroid, but that is always prepared for a specific ADC codec, similar to the odroid DAC2 driver for pcm512x (module snd_soc_odroid_dac2). For the first guess everything is ready for Odroid C2 ADC I2S module.
 
I need MMAP because this is for an audio effect application, I need to process recorded sound and send the processed audio in real time with minimal latency.
I2S implementation on Amlogic S905 (Odroid C2 processor) is very complex and apparently even if the driver has been written, it is not supported and I am not even sure it works. There is some discussion here on odroid forum about it
 
Another member here wrote a custom i2s implementation for the Beaglebone SBC which uses a TI chip. I've seen some I2s related questions answered on TI support forums as well as NXP forums, so maybe look for an SBC with TI or NXP chips and check if their data sheets are freely available. Then try and get answers on the manufacturer forums.
You won't be getting any answers from Broadcom or Allwinner. Intel is also a no-go. I don't know about Rockchip.
 
RPi has I2S capture support (I do not know if MMAPed, but why such condition?), there are I2S ADC boards/hats on the market, e.g. Datasheet DAC+ ADC | HiFiBerry , ADC Analog to Digital Converter AKM5720 I2S 24Bit / 96kHz - Audiophonics , etc.

I have never used Odroid C2, but the source code suggests the I2S input as specified in S905 SoC specs (page 182 of https://dn.odroid.com/S905/DataSheet/S905_Public_Datasheet_V1.1.4.pdf ) should be supported linux/sound/soc/aml/m8 at odroidc2-3.14.y * hardkernel/linux * GitHub linux/aml_i2s.c at odroidc2-3.14.y * hardkernel/linux * GitHub .

I did not find any implementation of a driver for any I2S ADC for odroid, but that is always prepared for a specific ADC codec, similar to the odroid DAC2 driver for pcm512x (module snd_soc_odroid_dac2). For the first guess everything is ready for Odroid C2 ADC I2S module.

Whilst the HiFiBerry board seems to work with and be supported for Raspberry Pi I can find no documentation for the Audiophonics ADC.

My experiments interfacing it with a Raspberry Pi have so far been unsuccessful. I believe it will work as a front end directly to an i2s DAC but not as an ADC for recording into a PI.

If you have any information that would help with interfacing it to a Pi I would be most interested.

Bob.
 
With the audiophonics board connected...and the software installed as per the only instructions I could find for an i2s card...

Overview | Adafruit I2S MEMS Microphone Breakout | Adafruit Learning System
/raspberry-pi-wiring-test

The card is found correctly-
Code:
pi@raspberrypi:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: sndrpii2scard [snd_rpi_i2s_card], device 0: simple-card_codec_link snd-soc-dummy-dai-0 [simple-card_codec_link snd-soc-dummy-dai-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

No matter what arecord command I use the result is the same... (with input open, shorted, or connected to a source.. just the endless repeat of below)

Here is the recorded waveform in audacity...

Obviously something very wrong..!!
 

Attachments

  • Screenshot from 2020-07-18 15:15:10.jpg
    Screenshot from 2020-07-18 15:15:10.jpg
    159.6 KB · Views: 228
Things are not so simple. The digital mic is I2S slave, configuring RPi I2S interface to master mode. Configuration is in the mic driver Raspberry-Pi-Installer-Scripts/snd-i2smic-rpi.c at master * adafruit/Raspberry-Pi-Installer-Scripts * GitHub - constant SND_SOC_DAIFMT_CBS_CFS - explanation soc-dai.h - include/sound/soc-dai.h - Linux source code (v5.8-rc4) - Bootlin

IIUC the AK5720 board configures the I2S port of the ADC to master mode, expecting the RPi I2S interface to accept its BCLK and LRCLK clocks - that would be constant SND_SOC_DAIFMT_CBM_CFM soc-dai.h - include/sound/soc-dai.h - Linux source code (v5.8-rc4) - Bootlin

The driver must fit the hardware precisely. That's why there are dedicated modules for almost every DAC hat for RPi. But all the components for building a working driver are there. My 2 cents from looking at the source code the same holds for the I2S input of Odroid C2, only nobody has done it correctly yet for his specific HW.
 
Thank-you phofman !!

Perfectly explained, and after making the indicated changes to snd-i2smic-rpi.c it now works as expected.

Code:
arecord  -c2 -f S32_LE -r 96000 --vumeter=stereo test.wav

This produces the desired output. (Other bit-rates result in single channel only recorded.)

Unsure if this is how it was meant but I added
Code:
read -p "Press [z] key to resume ..."
to the master installer script straight after the github download of the later installer scripts then navigated to and modified snd-i2smic-rpi.c as you had indicated and resumed the master installer.

Once again my thanks for your time and advice.
 
Great to hear that only fixing the I2S mode was enough to make it work. Congrats.

As of the samplerate - look at table 2 on page 16 of the AK5720 datasheet https://www.akm.com/content/dam/doc.../audio-adc/ak5720vt/ak5720vt-en-datasheet.pdf . Value of the settings resistor would have to be changed to change the fs multiple, hence the outgoing samplerate to the slaved RPi (masteclock is fixed).

Another options would be generating the masterclock directly from RPi on its GPclkout (for ways to avoid the jittery MASH look at the symphonic-mpd clock redefinition https://www.diyaudio.com/forums/pc-based/355137-symphonic-mpd-25.html#post6255443 + further posts - not a simple change though). But that is a large project including proper driver etc.
 
Things are not so simple. The digital mic is I2S slave, configuring RPi I2S interface to master mode. Configuration is in the mic driver Raspberry-Pi-Installer-Scripts/snd-i2smic-rpi.c at master * adafruit/Raspberry-Pi-Installer-Scripts * GitHub - constant SND_SOC_DAIFMT_CBS_CFS - explanation soc-dai.h - include/sound/soc-dai.h - Linux source code (v5.8-rc4) - Bootlin

IIUC the AK5720 board configures the I2S port of the ADC to master mode, expecting the RPi I2S interface to accept its BCLK and LRCLK clocks - that would be constant SND_SOC_DAIFMT_CBM_CFM soc-dai.h - include/sound/soc-dai.h - Linux source code (v5.8-rc4) - Bootlin

The driver must fit the hardware precisely. That's why there are dedicated modules for almost every DAC hat for RPi. But all the components for building a working driver are there. My 2 cents from looking at the source code the same holds for the I2S input of Odroid C2, only nobody has done it correctly yet for his specific HW.
I am more a HW than a SW guy and I have developed a codec plugin board for Odroid C2 based on CS4245 codec, naively believing I2S ADC would work.
I have been working on a mainline Linux driver for Odroid C2 and driver works OK for playing on S16_LE and S32_LE modes. S24_LE mode is bugged on Amlogic S905 processor though.
But I've been struggling a lot with recording driver, initially internal FIFOs didn't move and I had a PCM IO error due to timeout.
Now I am able to run arecord command but wave files generated are just garbage. There are hundreds of registers to configure AUDIN block on S905 and they are badly documented on datasheet, and no way to get any support from Hardkernel or Amlogic. I've got inspiration on how to configure registers from existing v3.16 Linux drivers, though I don't know if these drivers actually work for recording.
For example, before writing sound samples from internal FIFO to external memory, endianness has to be configured. For me there is little endian (LSB first) and big endian (MSB first), but endian register uses 3 bits, 8 different endian modes, and they are not documented. Existing drivers configured endianness=4, except if split mode is used (which it's the case), then endian is 6 for 16-bits and 7 for 24/32-bits, according to existing drivers.
I don't have a way to sweep and test all those values to check what works, I am forced to recomplie the whole Linux, write a Flash and try, which may take ages. Any ideas on how to solve this issue are welcome.
If anybody is interested here is the existing drivir as it is now:
linux/sound/soc/meson at devrezz2 * Rezzonics/linux * GitHub
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.