Go Back   Home > Forums > >

PC Based Computer music servers, crossovers, and equalization

SBC with I2S codec drivers for playing/recording
SBC with I2S codec drivers for playing/recording
Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools
Old 17th July 2020, 10:14 AM   #1
rezzonics is offline rezzonics
diyAudio Member
 
Join Date: Sep 2013
Default SBC with I2S codec drivers for playing/recording

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?
  Reply With Quote
Old 17th July 2020, 12:30 PM   #2
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
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...eet_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.
  Reply With Quote
Old 17th July 2020, 04:29 PM   #3
rezzonics is offline rezzonics
diyAudio Member
 
Join Date: Sep 2013
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
  Reply With Quote
Old 17th July 2020, 08:32 PM   #4
wealas is offline wealas
diyAudio Member
 
Join Date: Apr 2017
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.
  Reply With Quote
Old 17th July 2020, 09:54 PM   #5
DRONE7 is offline DRONE7  New Zealand
diyAudio Member
 
Join Date: Aug 2008
Quote:
Originally Posted by phofman View Post
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...eet_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.
  Reply With Quote
Old 18th July 2020, 04:19 AM   #6
DRONE7 is offline DRONE7  New Zealand
diyAudio Member
 
Join Date: Aug 2008
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..!!
Attached Images
File Type: jpg Screenshot from 2020-07-18 15:15:10.jpg (159.6 KB, 123 views)
  Reply With Quote
Old 18th July 2020, 08:33 AM   #7
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
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.
  Reply With Quote
Old 18th July 2020, 10:26 AM   #8
DRONE7 is offline DRONE7  New Zealand
diyAudio Member
 
Join Date: Aug 2008
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.
  Reply With Quote
Old 18th July 2020, 11:40 AM   #9
phofman is offline phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
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/docu...-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-b...ml#post6255443 + further posts - not a simple change though). But that is a large project including proper driver etc.
  Reply With Quote
Old 19th July 2020, 03:56 PM   #10
rezzonics is offline rezzonics
diyAudio Member
 
Join Date: Sep 2013
Quote:
Originally Posted by phofman View Post
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
  Reply With Quote

Reply


SBC with I2S codec drivers for playing/recordingHide this!Advertise here!
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can playing playing poor quality records damage my stylus? HarryY Analogue Source 13 23rd February 2020 05:43 PM
Which USB codec to use? Neil_J PC Based 1 27th November 2017 04:25 PM
Recording, playbackís poor relation? Post a DIY recording. wakibaki The Lounge 4 2nd December 2010 05:46 AM
I2S codec... wildswan Digital Line Level 4 30th July 2010 04:07 PM
what's better, a mid playing high, or a tweet playing low??? cody6766 Multi-Way 10 20th February 2005 10:40 PM


New To Site? Need Help?

All times are GMT. The time now is 07:33 AM.


Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 15.00%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Copyright ©1999-2021 diyAudio
Wiki