mhelin
Posts: 124
Joined: Wed Oct 17, 2012 7:18 pm

Re: I2S: Anyone got it running? (answer is yes!)

Thu May 23, 2013 10:47 am

UPDATE: I have now tested the pipe. It works, but the latency is very high (500 ms!). Are there any settings necessary for the pipe?
arecord -D hw:1,0 -f DAT | aplay -D hw:1,0
Reduce period and buffer sizes. I think usually you use jack adn jackified applications for low latency use cases.

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Thu May 23, 2013 10:52 am

I will do that. One thing I don't understand about this: Why is JACK faster than using ALSA directly?

steveha
Posts: 19
Joined: Fri May 03, 2013 3:15 pm

Re: I2S: Anyone got it running? (answer is yes!)

Fri May 24, 2013 7:08 pm

Hi koalo

I try to compile the latest patch. It seems that the TDA1541A and ESS9018 won't show up when performing make ARCH=arm menuconfig.

Regards
Steve

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Fri May 24, 2013 9:28 pm

Oh I am sorry! I will fix that immediately.

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Fri May 24, 2013 9:55 pm

It should be ok again.
I made some "improvements" for building kernel patches, but I forgot that this breaks some use cases ;-)

steveha
Posts: 19
Joined: Fri May 03, 2013 3:15 pm

Re: I2S: Anyone got it running? (answer is yes!)

Sat May 25, 2013 2:48 pm

Thank you. It is OK now. :P

pasdesignal
Posts: 19
Joined: Sat Jan 05, 2013 8:11 am
Contact: Website

Re: I2S: Anyone got it running? (answer is yes!)

Tue May 28, 2013 11:39 am

I am having trouble getting a working system after compiling a new kernel. I have followed the instructions as best I can but am new to kernel building and compiler environments. Maybe I am missing something that may be obvious to more experienced folk?

I am cross-compiling on Ubuntu 12.04, I used the kernel from here git://github.com/koalo/linux.git, and the pre-built bmc2708 compiler from the RPI tools section on GitHub. I have pretty much followed the instructions very carefully from http://elinux.org/RPi_Kernel_Compilation and Koalos blog.

I believe I have successfully replaced the kernel:

Code: Select all

[email protected] ~ $ uname -a
Linux raspberrypi 3.8.10+ #1 PREEMPT Tue May 28 00:58:35 NZST 2013 armv6l GNU/Linux
But having edited /etc/modules appropriately, I see no evidence of the soc modules loading, and this is confirmed here:

Code: Select all

[email protected] ~ $ lsmod
Module                  Size  Used by
snd_bcm2835            16149  0 
8192cu                490635  0 
leds_gpio               1985  0 
led_class               3680  1 leds_gpio
i2c_bcm2708             3657  0 
But there is no error message about missing modules when I manually load them either:

Code: Select all

[email protected] ~ $ sudo modprobe snd_soc_rpi_mbed
[email protected] ~ $ 
However this also doesnt seem to do anything!

Here are a few other outputs:
[email protected] ~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
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
[email protected] ~ $ cat /proc/asound/modules
cat: /proc/asound/modules: No such file or directory
[email protected] ~ $ cat /proc/asound/cards
0 [ALSA ]: BRCM bcm2835 ALSbcm2835 ALSA - bcm2835 ALSA
bcm2835 ALSA
I definitely enabled DMA driver as well as ASOC drivers in kernel menu as kernel drivers.
Any suggestions on where I may have gone wrong would be greatly appreciated! I have been trying to get this working for a week now... learning lots though! :)

McDaisy
Posts: 7
Joined: Fri Jul 13, 2012 8:49 am

Re: I2S: Anyone got it running? (answer is yes!)

Tue May 28, 2013 2:45 pm

Hi!

Followed this thread for a while now. Tried to compile a kernel to use i2s connectors without success. I can say Im not a software guy...

Im looking for a image just to put on my sd card if someone is willing to share :D

My plan is to use an image with minimum ports and services running. Just Usb, Lan and i2s... Skip the hdmi and use a minimal debian and then install mpd with mpc.

It would be awesome if someone already had an image with successful running i2s pins...


THANKS! Sorry I couldnt share so much myself. I can put the schematics Im using for my dac when everything is running successfully.. I will try with both 1541 and 1543 both balanced (with 2 chips) and unbalanced...

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Thu May 30, 2013 8:05 am

pasdesignal wrote:I am having trouble getting a working system after compiling a new kernel.
Please put the output of dmesg to pastebin.

pasdesignal
Posts: 19
Joined: Sat Jan 05, 2013 8:11 am
Contact: Website

Re: I2S: Anyone got it running? (answer is yes!)

Thu May 30, 2013 9:24 am

koalo wrote: Please put the output of dmesg to pastebin.
Hi Koalo!
Thanks for the reply.

http://pastebin.com/xPtYHJA1

I have actually made further progress now but as you can see the drivers are not loading properly. Getting much closer which is a relief.

Code: Select all

[email protected] ~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  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

[email protected] ~ $ lsmod
Module                  Size  Used by
snd_soc_rpi_mbed        2011  0 
bcm2708_dmaengine       6652  0 
virt_dma                2265  1 bcm2708_dmaengine
snd_soc_bcm2708_i2s     5103  0 
snd_bcm2835            16149  0 
snd_soc_wm8731         10947  0 
snd_soc_bcm2708         3004  0 
snd_soc_core          123715  4 snd_soc_bcm2708,snd_soc_wm8731,snd_soc_rpi_mbed,snd_soc_bcm2708_i2s
regmap_spi              1523  2 snd_soc_wm8731,snd_soc_core
regmap_i2c              1629  2 snd_soc_wm8731,snd_soc_core
snd_compress            6754  1 snd_soc_core
joydev                  9076  0 
snd_pcm                80288  4 snd_bcm2835,snd_soc_bcm2708,snd_soc_core,snd_soc_bcm2708_i2s
evdev                   9317  2 
snd_seq                53336  0 
snd_timer              20001  2 snd_pcm,snd_seq
snd_seq_device          6437  1 snd_seq
8192cu                490475  0 
leds_gpio               1985  0 
led_class               3680  1 leds_gpio
snd                    60862  8 snd_bcm2835,snd_soc_wm8731,snd_soc_core,snd_timer,snd_pcm,snd_seq,snd_seq_device,snd_compress
snd_page_alloc          5148  1 snd_pcm
i2c_bcm2708             3657  0 



....The ESS9018 drivers and the TDA1541a drivers are working fine though - or at least they dont post error messages at boot.....
Thanks for your time.
Shannon.

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Thu May 30, 2013 9:37 am

pasdesignal wrote: http://pastebin.com/xPtYHJA1
The interesting line is this one:

Code: Select all

[   13.130268] snd-rpi-mbed snd-rpi-mbed.0: ASoC: CODEC tlv320aic23-codec.1-001b not registered
Are you sure that you have put /CS on high level?

pasdesignal
Posts: 19
Joined: Sat Jan 05, 2013 8:11 am
Contact: Website

Re: I2S: Anyone got it running? (answer is yes!)

Thu May 30, 2013 9:47 am

koalo wrote: The interesting line is this one:

Code: Select all

[   13.130268] snd-rpi-mbed snd-rpi-mbed.0: ASoC: CODEC tlv320aic23-codec.1-001b not registered
Are you sure that you have put /CS on high level?
Probably not because I dont even know what that means!
Could you please elaborate? :oops:

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Thu May 30, 2013 9:52 am

As you are loading the mbed driver, I assume that you have bought a mbed board. It has a pin with the name /CS. This one is used to select the address for the I2C bus. The kernel assumes that the board has address 0x1b. Therefore, you have to connect /CS to 3.3V.

Maybe I should explain this better in the blog, too.

pasdesignal
Posts: 19
Joined: Sat Jan 05, 2013 8:11 am
Contact: Website

Re: I2S: Anyone got it running? (answer is yes!)

Thu May 30, 2013 10:03 am

koalo wrote: Maybe I should explain this better in the blog, too.
Oh yes, I know what you mean. Yes I have set it to HIGH.

Here is relevant stuff from /var/log/messages:
http://pastebin.com/dDDHPFUC

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Thu May 30, 2013 6:19 pm

I suggest that the I2C bus of the mbed board is not properly connected (or the corresponding driver is not properly loaded). Please do the following:

1. Execute i2cdetect 1
It could be possible that you have to execute these commands first:

Code: Select all

sudo modprobe i2c-bcm2708
sudo modprobe i2c-dev
sudo apt-get install i2c-tools 
Please post this output.
2. Remove all modules from /etc/modules
3. Reboot
4. Execute i2cdetect 1 again and post the output

lbrouwer
Posts: 2
Joined: Sat Jan 12, 2013 2:47 pm

Re: I2S: Anyone got it running? (answer is yes!)

Fri May 31, 2013 5:00 pm

Hi,

I got the driver working with a Y2 dac and and an external bit clock and my own codec driver. It works great, thanks to all who contributed!

The one problem I had was that at higher sampling frequencies it started to have drop outs. Looking at hw_params I noticed that the buffer at 192kHz seemed smaller than the one for 44.1kHz:
[email protected]:/proc/asound/sndrpibclkdiv/pcm0p/sub0# cat hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 4410
buffer_size: 22050
[email protected]:/proc/asound/sndrpibclkdiv/pcm0p/sub0# cat hw_params
access: RW_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 192000 (192000/1)
period_size: 4096
buffer_size: 16384

Then I changed buffer_bytes_max in bcm2708-pcm.c:
.buffer_bytes_max = 1024 * 1024,

Now I get perfect playback at 192kHz and alsa reports the following:
[email protected]:/proc/asound/sndrpibclkdiv/pcm0p/sub0# cat hw_params
access: RW_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 192000 (192000/1)
period_size: 8000
buffer_size: 96000

Leon

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Fri May 31, 2013 5:49 pm

lbrouwer wrote: Then I changed buffer_bytes_max in bcm2708-pcm.c:
.buffer_bytes_max = 1024 * 1024,
Thank you very much! I will have a deeper look and add it to the driver.

humppe
Posts: 3
Joined: Sat Jun 01, 2013 5:32 am

Re: I2S: Anyone got it running? (answer is yes!)

Sat Jun 01, 2013 6:04 am

koalo wrote:
fgimenez wrote: You mean a converter to match the electrical levels of an SPDIF or the data format is also different?
The data format is different. It could be theoretically possible to fake a SPDIF format over I2S, but this means lot of work and there is a big chance of a total fail.
Oh boy, that was an addicting sentence! Because of that, I have done some googling and learning during past couple of nights, and I'd say that SPDIF is quite doable with raspberry.

The related links that ultimately convinced me:
http://scanlime.org/2011/04/spdif-digit ... ontroller/
http://www.epanorama.net/documents/audio/spdif.html
http://www.hardwarebook.info/S/PDIF

In principle, following steps would need to be done:

I2S driver should be configured to 6.144Mbit/s or 5.6448Mbit/s or 4.096Mbit/s bit rate depending on sampling frequency (48k,44.1k,32k are supported by SPDIF). This seem to be possible.

SPDIF requires continuous bitstream. Also this seem to be possible with BCM chipset by correctly configuring CH1POS and CH2POS.

Then, one would have to wrap samples around SPDIF headers and apply BMC encoding. This is where I expected to write some code .. but no. There seem to be something what could be used as a base:
https://github.com/xcore/sc_spdif

Now, the question (from 100% kernel/alsa newbie). Where should SPDIF encapsulation code belong to in Linux kernel / ALSA architecture? Looks like the alsa soc dai/machine/codec code is not the place. Is it alsa pcm filter plugin or something similar -- where is the last place where sample data can still be modified before passing it over to hardware?

It should be rather easy to prototype this by modifying i2s driver code and pre-generate some audio into spdif bitstream on PC and feed that to raspberry i2s output. And of course the toslink transceiver has to be added.

Now, next step would be to go buy and build some hardware (which is typically the step where my projects tend to stall :oops:)

Jari

pasdesignal
Posts: 19
Joined: Sat Jan 05, 2013 8:11 am
Contact: Website

Re: I2S: Anyone got it running? (answer is yes!)

Sat Jun 01, 2013 6:36 am

Hi Florian, I have done as you asked:
1. Execute i2cdetect 1

Please post this output.

Code: Select all

 i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f[img][/img]
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- 1b -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --            
2. Remove all modules from /etc/modules
3. Reboot
4. Execute i2cdetect 1 again and post the output

Code: Select all

i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- 1b -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --          
I have the following wiring to the Mbed CODEC:

P1-03 -----SDIN
P1-05 ---- SCLK
P5-02 -----3.3V
P5-03 -----BCLK
P5-04 -----LRCIN
P5-06 -----DIN
P5-08 -----GND

Thanks for your help. I appreciate it! :D

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Sat Jun 01, 2013 8:48 am

Ok - wiring is correct and board is found. Maybe there is a bug while loading the kernel device (although it is ok for me). Please insert the modules again and post the output of

tree /sys/bus/i2c/

pasdesignal
Posts: 19
Joined: Sat Jan 05, 2013 8:11 am
Contact: Website

Re: I2S: Anyone got it running? (answer is yes!)

Sat Jun 01, 2013 1:22 pm

Ok - wiring is correct and board is found. Maybe there is a bug while loading the kernel device (although it is ok for me). Please insert the modules again and post the output of

tree /sys/bus/i2c/
It was a missing CODEC driver. For some reason I had the wrong version of the snd_soc_tlv320aic23 driver (snd_soc_tlv320aic3x instead).... so it is working now :D

Thanks for your help and patience Florian. A lot of these processes were new to me.

Does anyone have MPD cranking with i2s? What settings did you have success with in mpd.conf?

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Sat Jun 01, 2013 1:49 pm

pasdesignal wrote:For some reason I had the wrong version of the snd_soc_tlv320aic23 driver (snd_soc_tlv320aic3x instead)
That is my fault. I am sorry! There is a bug in the Kconfig file. I didn't noticed that, because I compiled all codecs at once.

Regarding your cranking issue:
Is this also with other programs (e.g. aplay, mplayer)?
How do you have connected your codec board (jumper wires, ribbon cable)?

koalo
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm

Re: I2S: Anyone got it running? (answer is yes!)

Sat Jun 01, 2013 4:24 pm

humppe wrote: Oh boy, that was an addicting sentence!
I am sorry ;-)
It sounds really great and I have nothing to say against your arguments. I hope for the best :-)
I don't really understand the interface of that. Can it transfer a buffer of PCM data into a buffer of SPDIF data?
humppe wrote: Now, the question (from 100% kernel/alsa newbie). Where should SPDIF encapsulation code belong to in Linux kernel / ALSA architecture?
I don't really know, too. I would propose to do the conversion in userspace as a ALSA plugin.
humppe wrote: It should be rather easy to prototype this by modifying i2s driver code
Please open an issue at my github repo and I will try to add the requirements for bit rate.

humppe
Posts: 3
Joined: Sat Jun 01, 2013 5:32 am

Re: I2S: Anyone got it running? (answer is yes!)

Sat Jun 01, 2013 7:50 pm

koalo wrote: I don't really understand the interface of that. Can it transfer a buffer of PCM data into a buffer of SPDIF data?
No, that interface would not have been directly usable. And it was build on top of some framework, which would not have worked either. But there were some interesting functions that could have formed the center of the plugin.
koalo wrote: I don't really know, too. I would propose to do the conversion in userspace as a ALSA plugin.
Looks like the alsa plugin was the right answer. Apparently that encapsulation has not always been a hardware feature. Such a plugin was implemented ~9 years ago.
https://github.com/michaelwu/alsa-lib/b ... m_iec958.c

So, BMC encoding next. Now, where could that have been implemented before ;)

-- Jari

mhelin
Posts: 124
Joined: Wed Oct 17, 2012 7:18 pm

Re: I2S: Anyone got it running? (answer is yes!)

Sat Jun 01, 2013 10:24 pm

So, BMC encoding next. Now, where could that have been implemented before
http://www.raspberrypi.org/phpBB3/viewt ... if#p202411

Return to “Interfacing (DSI, CSI, I2C, etc.)”