CubieBoard Forum

Cubieboard itself => Hardware => Cubieboard v3 Hardware (Cubietruck) => Topic started by: kevin on November 25, 2013, 06:07:05 am

Title: ALSA bit-perfect output
Post by: kevin on November 25, 2013, 06:07:05 am
Hello,

I'm trying to use my CT as media player running high definition audio.(like 24bit over 96kHz audio file)
So I enabled sunxi_sndspdif module in /etc/modules then output audio through SPDIF to external DAC.
When I play high-def audio file(eg. 24bit 192kHz), I saw, cat /proc/asound/card1/pcm0p/sub0/hw_params as follow;

root@cubietruck:~# cat /proc/asound/card1/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 192000 (192000/1)
period_size: 8192
buffer_size: 32768

I think "format: S16_LE" should be "S24_LE" something. Is my CT running 24bit high-def file correctly?
So I wonder CT can support HW 24bit processing.

Thanks in advance.

Kevin.
Title: Re: ALSA bit-perfect output
Post by: halfur on November 25, 2013, 11:12:44 am
As far as I know the sunxi_sndspdif module only has support for 16 bit audio. I think I've read about hardware support for 24bit, but I'm not sure about it.

May I ask: Did you do anything special to enable the SPDIF? I've loaded the module, but I didn't get any output on the Toslink.
Title: Re: ALSA bit-perfect output
Post by: kevin on November 25, 2013, 05:24:58 pm
Hello halfur,
Thanks for your reply.
Actually, there are three more modules to load. They are in /lib/module/kernel/3.4.61+/sound/soc/spdif/ I guess. Try put those four in /etc/modules and modify alsa config in /etc/asound.conf to suit your sound card.
If you use MPD to play music, modify /etc/mpd.conf also to suit your environment. That'all.

I will contact to cubietech for this. Once I got an answer, will post here.

Thanks.

Title: Re: ALSA bit-perfect output
Post by: kevin on November 27, 2013, 02:36:06 am
Hi,

I sent email to cubietech for this but no answer by now. :-[
I did almost every possible way to process 24bit audio but I ended up as follow;

1. It looks like(not 100% sure) CT(Cubietruck) has four different kinds of sound cards inside of A20 SoC in ALSA's perspective.
    - sunxi-CODEC
    - sunxi-sndspdif
    - sunxi-sndhdmi
    - sunxi-sndi2s(maybe different name)
2. I searched on the net and found out that sunxi-CODEC & sunxi-sndspdif sources defined supported audio format only "S16_LE". That's why I can't play 24bit audio.
3. I don't know why the developer defined the supported format only for "S16_LE". It could be HW(A20 SoC) limitation, just SW issue(even the HW can support the 24bit) or a bug etc.

So as far as I know, I can't play my 24bit audio file with internal sunxi-sndspdif card unless I buy a new usb-DAC.
Anybody familiar with this kind of thing? Kind help much appreciated.

Thanks in advance.

Kevin.
Title: Re: ALSA bit-perfect output
Post by: kevin on November 28, 2013, 07:13:37 pm
Just for your information...

In order to play 24bit HD audio on CT, there is another way to do not through sndspdif but I2S.
I'm not tested yet but I will soon. Once I get to success, I will post the result here.

Kevin.
Title: Re: ALSA bit-perfect output
Post by: CubieNewb on December 02, 2013, 09:12:04 pm
Hi, would Kevin or someone please post step by step instructions for us Linux newbs?
Title: Re: ALSA bit-perfect output
Post by: kevin on December 03, 2013, 10:11:22 pm
Hello Cubienewb,

If you mean the steps for HD audio play, it's simple.
CT provide 4 different method(actually 4 different sound cards) to play the sound as far as I know.

1. Analog output(through headphone jack on CT)
   - It is most simple one through A20 SoC's internal sound codec named sunxi_codec module.
   - It supports 16bit, sample rate(8K ~ 192K) audio.
2. Digital output
   - HDMI Audio(through HDMI port on CT)
      * The video & audio signal multiplexed by HDMI spec.
      * I don't remember it's sound spec. on CT exactly but 16bit somewhere around 96K sample
          rate top I guess.
      * It processed by sunxi_sndhdmi module.
      * It is generally for HD video play not only for audio and you need external receiver or TV with
          HDMI capable one.
    - SPDIF(through SPDIF-TOSLINK port on CT)
       * It supports 16bit, sample rate(8K ~ 192K) audio.
       * It processed by sunxi_sndspdif module.
       * It DOES NOT support 24bit audio as far as I know.
    - I2S
       * It supports 16/24bit, sample rate(8K ~ 192K) audio.
       * This one is what I trying to enable for HD audio(24bit over 96K sample rate).
       * The A20 SoC document said it support 16/24 bit audio but there is no how to.
       * So I'm searching HOWTOs and once I get the howto, I'll post here.

So there are one analog, three digital output you have.
The analog output is configured by default. So you don't need any other thing to do. Just plug in to
headphone jack and run any music player you want.
The HDMI is not just for audio. Most linux distros in this community, using the HDMI display by default.
So HDMI audio is configured by default also.
And for SPDIF, you should configure manually like I said in previous thread for SPDIF.

Hmm.. This is not step by step instruction just background info. :P
Sorry, once I sit in front of my CT, I will update in this thread.
Hope this help!
Title: Re: ALSA bit-perfect output
Post by: halfur on December 04, 2013, 05:38:46 am
hmm. If you somehow manage to get the I2S working you'll probably need something to convert the I2S to SPDIF though, the Wolfson WM8804 seems to be an appropiate IC for that.

Somehow adding 24bit support for the sndspdif module seems almost easier.
Title: Re: ALSA bit-perfect output
Post by: kevin on December 04, 2013, 08:49:15 am
Quote from: halfur on December 04, 2013, 05:38:46 am
hmm. If you somehow manage to get the I2S working you'll probably need something to convert the I2S to SPDIF though, the Wolfson WM8804 seems to be an appropiate IC for that.

Somehow adding 24bit support for the sndspdif module seems almost easier.


Hi halfur,

Maybe you are right. I use lubuntu server distros for my CT. And found in A20 user manual that it doesn't support 24bit in SPDIF mode but it does in I2S mode.
Also I found in kernel source sound part, it does not configured to compile I2S sound source on CT which is I don't know why even though there is I2S sound source.
And also I found out pins to connect to external DAC for I2S signal on CN9 connector on my CT.
So I am trying to re-compile the kernel and modules with I2S enabled.
If it works, I can transmit the I2S signal to external DAC. There are many cheap I2S input, analog out(RCA) DAC out there.
But it's not easy to modify the source and re-compile cause I'm not developer. I'm just casual user who have much interest to play music on cubieboard.

So anyway, do you know how to do modify the source and re-compile etc.?
If you do, would you guide me how to do? And I'll let you know what I found so far in detail.
Title: Re: ALSA bit-perfect output
Post by: GeorgeIoak on December 09, 2013, 04:55:03 pm
Where are you guys reading that the A20 doesn't support 24-bit audio? If it can output 24-bit on I2S then it can output 24-bit on other digital outputs. HDMI is carrying I2S signals along with the video so this sounds like a software issue to me.

I'm starting to look into this for both A10/A20 but if anyone has some helpful information I would appreciate since I'm more hardware (Much More) than software!
Title: Re: ALSA bit-perfect output
Post by: kevin on December 09, 2013, 06:18:51 pm
In the A20 user manual digital audio section.
It said, two digital audio method, one is I2S and the other is legacy PCM.
PCM support 8 or 16bit sample rate 8~192kHz, I2S support 8~24bit sample rate same as PCM.
I found out, in the sound source, same as I said.
What I like to know is how to configure I2S on cubieboard(1,2,3) in terms of both HW/SW perspective.
There are no info. docs so far from cubietech or Allwinner.
AFAIK, HDMI & I2S are different sound architecture.
As for HDMI, it needs dedicated receiver for video and audio.
And it's expensive for HD video & audio.
I love music, and A20's internal I2S can provide cheap and good(HD audio) solution.
Title: Re: ALSA bit-perfect output
Post by: tbenr on December 10, 2013, 06:29:48 am
have you look at this?

fex config:
http://linux-sunxi.org/Fex_Guide#i2c_configuration

expansion ports reference, to match the A20 PIOs:
http://linux-sunxi.org/A20-Cubietruck

Title: Re: ALSA bit-perfect output
Post by: kevin on December 10, 2013, 08:18:08 pm
Quote from: tbenr on December 10, 2013, 06:29:48 am
have you look at this?

fex config:
http://linux-sunxi.org/Fex_Guide#i2c_configuration

expansion ports reference, to match the A20 PIOs:
http://linux-sunxi.org/A20-Cubietruck

Hello tbenr,

Yes, I have already.
But I don't know how to do, what is exactly related with those things.
I tested a lot of times with my CT to play HD music over the last couple of month.
As a casual user but love to listen to the music very much with these compact, cheap and good solution, I have very much interest to play with CT. ;)
Title: Re: ALSA bit-perfect output
Post by: GeorgeIoak on December 11, 2013, 11:36:51 pm
CB1 and CB2 do not have the I2S pins exposed on the header so you cannot access I2S on those boards. I think I read that the CT has I2S brought out to the pins but I don't have that schematic open right now to check.

I've been playing with the source code and recompiling getting mixed results. Everything that I've read says that you should be able to have 24-bit on all ports.
Title: Re: ALSA bit-perfect output
Post by: kevin on December 12, 2013, 05:39:12 am
You can check CT's schematic which A20 SoC's pin goes to expansion header's pin(CN8 & 9)
With that, I guess pin #18,20,22,24 are for MCLK,BCLK,LRCLK,SDO of I2S on CN9 connector.
Coresponding ports are PB5,6,7,8 for each I2S signal respectively.
But it seems like sharing those four pins with TVIN & AC97.
At this point, I don't know how to do about sharing situation.
Also there is SW issue, in the sound related source file /sound/soc/sunxi/Kconfig,
it said sun7i(A20) platform needs to be adjust various thing to comple the I2S source.
But no comment or description what is various thing to be done.
Anyway, I modified Kconfig file to include I2S source and re-compiled the kernel and modules.
And reboot, booted normally but kernel refused to load I2S with some error.
It seems like some clocking issue.
I'll post detailed error message soon when I get back to my office.
Title: Re: ALSA bit-perfect output
Post by: GeorgeIoak on December 12, 2013, 06:27:42 pm
you probably have to define the pins in the fex file and use the proper mux mode in order to get them to work.

Looking at http://dl.cubieforums.com/pdf/A10 EVB Manual.pdf (http://dl.cubieforums.com/pdf/A10 EVB Manual.pdf) (A10 developer manual) on p37 it states it supports up to 8 channel, 24-bit PCM in HDMI.

I'm at the point now that I'm thinking this could be related to DMA transfers and the driver code was never written to handle greater than 16-bit data. That's just a guess on my part and a hope that someone who actually knows the code will read this and take a look for us.
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 09, 2014, 07:30:57 am
Hi,

I also want to use I2S to connect an external DAC. Kevin, have you any progress?
Title: Re: ALSA bit-perfect output
Post by: kevin on January 09, 2014, 08:40:14 pm
Quote from: nikkov on January 09, 2014, 07:30:57 am
Hi,

I also want to use I2S to connect an external DAC. Kevin, have you any progress?

Hello nikkov,

Like GeorgeIoak said above, there are SW-side issues to handle 24-bit sound.
Unlike everybody else in this forum, I'm not developer so not used to modifying the kernel or sound driver.
The HW(A20 SoC) itself has 24-bit processing feature but not SW so far.
What I know and tested so far about 24-bit sound on Cubieboard as follow;

1. 16-bit sound is OK (up to 192khz sample rate)
2. 24-bit sound playable but it showed bit depth 16-bit like "S16_LE" on ALSA. (up to 192khz sample rate)
3. I recompiled the I2S module in CT which is disabled by default. And then, when I loaded I2S module, the system showed error message something like as follow;
    - [ccu-error] clk_enabled:invalid handle
    - [ccu-error] clk_set_parent:invalid handle try to set parent of i2s_moduleclk to i2s_pll2ck failed line=603
    - [ccu-err] clk_disabled:invalid handle

For above #2, I don't know my CT can play 24-bit sound correctly because "cat /proc/asound/card1/pcm0p1/sub0/hw_param" showed sound format "S16_LE" which is should be "S24_LE".
For above #3, even though I don't know how to configure I2S from scratch, I just give it a try but no luck.
All the testing was done with digital out(SPDIF).
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 09, 2014, 11:03:46 pm
Thank you, kevin.

And I'm also beginner in linux-world.
I connected USB Audio device and CT can play up to 192/24, but for me very interesting how to use I2S.
Can you explain which system image you used and how enabled I2S module compilation?
Title: Re: ALSA bit-perfect output
Post by: kevin on January 10, 2014, 01:40:28 am
Hi nikkov,

There are lots of things to explain why I recompile I2S kernel module even though I'm not used to do that. :'(
But you know, it's fun to do and great chance to learn a lot for about HD audio in Linux world etc.
Anyway, I used following kernel source and method;

1. For kernel source I used
    https://github.com/cubieboard2/linux-sunxi/tree/sunxi-3.4-ct-v101 (https://github.com/cubieboard2/linux-sunxi/tree/sunxi-3.4-ct-v101)
2. For compiling the kernel and module, read the following
    http://dl.cubieboard.org/docs/How_to_make_a_cubieboard_system.pdf (http://dl.cubieboard.org/docs/How_to_make_a_cubieboard_system.pdf)
3. For I2S module compile
    - You need to do some modification of "Kconfig" file at
       https://github.com/cubieboard2/linux-sunxi/blob/sunxi-3.4-ct-v101/sound/soc/Kconfig (https://github.com/cubieboard2/linux-sunxi/blob/sunxi-3.4-ct-v101/sound/soc/Kconfig) to include I2S driver source code when you compile the kernel or
    - You can choose the option to include I2S driver as module or built-in in the kernel when you compile the kernel by "menuconfig'.

Before compiling the kernel, you need read carefully #2 step and any relevant information about kernel compiling in this forum or googling whatever in the internet. ;)
Also you may need to look at this http://ubuntuone.com/3DhPanhzINWVGnQijjXWa0 (http://ubuntuone.com/3DhPanhzINWVGnQijjXWa0) in section 1.13, 5.2, 6.9 and 6.10 for about audio related information on A20 based cubieboard.

I know I can use usb DAC/converter for HD audio. This may be the most simplest way to do but it cost from tenth to a few hundreds of dollars depending on the device.
If the cubieboard can handle the I2S signal properly, one can play HD audio easily by connecting I2S capable DAC.(there are a lots of cheap I2S DACs in the market)
But it seems like a lot of people have interest other than HD audio on cubieboard. :'(
If you have any question or anything your own way about audio feature, let's share to improve this community!

Thanks.

Kevin.
Title: Re: ALSA bit-perfect output
Post by: kryoz on January 10, 2014, 02:49:22 am
I really interested in progress about enabling I2S for CT but I'll be satisfied even in 16/44.1 because I prefer old multibit parallel DACs. I have an intention for tweaking my USB/SPDIF DAC with AD1866 on board to grab i2s source.
Title: Re: ALSA bit-perfect output
Post by: kevin on January 10, 2014, 03:39:15 am
Quote from: kryoz on January 10, 2014, 02:49:22 am
I really interested in progress about enabling I2S for CT but I'll be satisfied even in 16/44.1 because I prefer old multibit parallel DACs. I have an intention for tweaking my USB/SPDIF DAC with AD1866 on board to grab i2s source.


Hi kryoz,

Glad to hear from you because it's counting up one more person to have interest for audio use. ;D
BTW, my original thought was to pull out I2S signal out of the CT via expansion port and connect to external DAC directly.
Otherwise IMHO, you need to use usb-to-I2S converter and then connect it to external DAC.(I2S input capable one)
If your DAC can have I2S input, you can give it a try but it's not that easy I guess. ;)
Title: Re: ALSA bit-perfect output
Post by: kryoz on January 10, 2014, 06:55:31 am
Quote from: kevin on January 10, 2014, 03:39:15 am
Hi kryoz,

Glad to hear from you because it's counting up one more person to have interest for audio use. ;D
BTW, my original thought was to pull out I2S signal out of the CT via expansion port and connect to external DAC directly.
Otherwise IMHO, you need to use usb-to-I2S converter and then connect it to external DAC.(I2S input capable one)
If your DAC can have I2S input, you can give it a try but it's not that easy I guess. ;)


Hi  8)

At first I have to solve another problem which is in progress now - implement i2s input in the DAC. I contacted with DAC developer and he gladly helped me with necessary information. The trick can be only with i2s format. DAC can accept only right justified.
Can we manipulate with output i2s format?

And a small offtopic. I've got USB-SPDIF converter with async mode (CM6631A chip) and external power supply. I was sure about its superb quality comparing to all internal soundcards on PC motherboards. But I was surprised when CT's optical SPDIF revealed even better quality. My best explanation is that power supply does really matter. Obviously in CT case it's much cleaner then in PCs.
Title: Re: ALSA bit-perfect output
Post by: HaikuZen on January 10, 2014, 09:56:07 am
Hi Kevin,
I'm also interested in the topic.
I also would like have I2S kernel enabled in android. ;)

Did you heard about HiFiBerry for Raspberri PI? http://www.hifiberry.com/
Do you think the pins are compatibles?
Title: Re: ALSA bit-perfect output
Post by: kryoz on January 11, 2014, 04:44:19 pm
I've been trying to compile kernel with i2s module but stiil have no luck.
There were many things I discovered about this process and now I have a kernel with i2s module but looks like it doesn't start at all. syslog reports nothing when i do modprobe sunxi-sndi2s.
Also I couldn't make to work wi-fi module  :-\
I'll appreciate any help but .config for make can be the best option.
Title: Re: ALSA bit-perfect output
Post by: kevin on January 12, 2014, 07:58:03 pm
Quote from: kryoz on January 10, 2014, 06:55:31 am
Quote from: kevin on January 10, 2014, 03:39:15 am
Hi kryoz,

Glad to hear from you because it's counting up one more person to have interest for audio use. ;D
BTW, my original thought was to pull out I2S signal out of the CT via expansion port and connect to external DAC directly.
Otherwise IMHO, you need to use usb-to-I2S converter and then connect it to external DAC.(I2S input capable one)
If your DAC can have I2S input, you can give it a try but it's not that easy I guess. ;)


Hi  8)

At first I have to solve another problem which is in progress now - implement i2s input in the DAC. I contacted with DAC developer and he gladly helped me with necessary information. The trick can be only with i2s format. DAC can accept only right justified.
Can we manipulate with output i2s format?

And a small offtopic. I've got USB-SPDIF converter with async mode (CM6631A chip) and external power supply. I was sure about its superb quality comparing to all internal soundcards on PC motherboards. But I was surprised when CT's optical SPDIF revealed even better quality. My best explanation is that power supply does really matter. Obviously in CT case it's much cleaner then in PCs.


Hi kryoz,

How is modification going?
Yes, CT's SPDIF output quality is good. I'm running mpd with small cheap DAC(up to 24/192) for my music listening.
But I have pop noise when I stop or forward between tracks with HD audio file.(like 24bit 96khz)
Do you have any experience like this?
Title: Re: ALSA bit-perfect output
Post by: kevin on January 12, 2014, 08:06:00 pm
Quote from: HaikuZen on January 10, 2014, 09:56:07 am
Hi Kevin,
I'm also interested in the topic.
I also would like have I2S kernel enabled in android. ;)

Did you heard about HiFiBerry for Raspberri PI? http://www.hifiberry.com/
Do you think the pins are compatibles?

Hello HaikuZen,

I heard about that DAC before but I don't think it's compatible with cubieboard in terms of HW and SW.
Because RPi and Cubieboard has different HW spec.
Title: Re: ALSA bit-perfect output
Post by: kevin on January 12, 2014, 08:51:21 pm
Quote from: kryoz on January 11, 2014, 04:44:19 pm
I've been trying to compile kernel with i2s module but stiil have no luck.
There were many things I discovered about this process and now I have a kernel with i2s module but looks like it doesn't start at all. syslog reports nothing when i do modprobe sunxi-sndi2s.
Also I couldn't make to work wi-fi module  :-\
I'll appreciate any help but .config for make can be the best option.

Hi kryoz,

Compilation of I2S module itself is not an issue I guess.
When loading the module, it refused to load with some error.
It needs to be done something in I2S module source code.
Would you provide me what happen when you load the module?

Thanks.
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 13, 2014, 02:13:37 am
I looked up the source code and found that code from sunxi-i2s.c

//i2s module clk
i2s_moduleclk = clk_get(NULL, "i2s");
for A20 must be replaced:
//i2s module clk
i2s_moduleclk = clk_get(NULL, "i2s0");

because clock module with name "i2s" not exists.
Title: Re: ALSA bit-perfect output
Post by: kryoz on January 13, 2014, 03:30:24 am
Quote from: kevin on January 12, 2014, 07:58:03 pm
Hi kryoz,

How is modification going?
Yes, CT's SPDIF output quality is good. I'm running mpd with small cheap DAC(up to 24/192) for my music listening.
But I have pop noise when I stop or forward between tracks with HD audio file.(like 24bit 96khz)
Do you have any experience like this?


Hi kevin,

I digged deeper and reproduced errors like yours. Then stucked. Also I haven't managed to make work wi-fi module correct despite on notes and even .config in near NAS thread :(

Quote
Yes, CT's SPDIF output quality is good. I'm running mpd with small cheap DAC(up to 24/192) for my music listening.
But I have pop noise when I stop or forward between tracks with HD audio file.(like 24bit 96khz)
Do you have any experience like this?


That's strange I don't have such an issue. But I have another one with skipping for about 1 second of the beginning of new track when I forward between them.

Quote from: nikkov on January 13, 2014, 02:13:37 am
I looked up the source code and found that code from sunxi-i2s.c

//i2s module clk
i2s_moduleclk = clk_get(NULL, "i2s");
for A20 must be replaced:
//i2s module clk
i2s_moduleclk = clk_get(NULL, "i2s0");

because clock module with name "i2s" not exists.



Tank you for advice. I'll try this patch today.
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 13, 2014, 08:18:41 am
Quote from: kryoz on January 13, 2014, 03:30:24 am
Tank you for advice. I'll try this patch today.


Not works  :(

syslog fragment:

Jan 12 13:28:48 linaro-ubuntu-desktop kernel: [  110.539559] [ccu-err] clk_enable: invalid handle
Jan 12 13:28:48 linaro-ubuntu-desktop kernel: [  110.549707] [ccu-err] clk_set_rate: set i2s0 rate to 3072000 failed
Jan 12 13:28:48 linaro-ubuntu-desktop kernel: [  110.561609] set i2s_moduleclk clock freq to 24576000 failed! line = 612
Jan 12 13:28:48 linaro-ubuntu-desktop kernel: [  110.565402] [ccu-err] clk_disable: invalid handle


Title: Re: ALSA bit-perfect output
Post by: kryoz on January 13, 2014, 09:11:00 am
Quote from: nikkov on January 13, 2014, 08:18:41 am
Quote from: kryoz on January 13, 2014, 03:30:24 am
Tank you for advice. I'll try this patch today.


Not works  :(

syslog fragment:

Jan 12 13:28:48 linaro-ubuntu-desktop kernel: [  110.539559] [ccu-err] clk_enable: invalid handle
Jan 12 13:28:48 linaro-ubuntu-desktop kernel: [  110.549707] [ccu-err] clk_set_rate: set i2s0 rate to 3072000 failed
Jan 12 13:28:48 linaro-ubuntu-desktop kernel: [  110.561609] set i2s_moduleclk clock freq to 24576000 failed! line = 612
Jan 12 13:28:48 linaro-ubuntu-desktop kernel: [  110.565402] [ccu-err] clk_disable: invalid handle



Have you modified your fex config in [i2s_para] with this lines?
i2s_mclk = port:PB05<2><1><default><default>
i2s_bclk = port:PB06<2><1><default><default>
i2s_lrclk = port:PB07<2><1><default><default>
i2s_dout0 = port:PB08<2><1><default><default>
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 13, 2014, 11:24:06 pm
Quote from: kryoz on January 13, 2014, 09:11:00 am
Have you modified your fex config in [i2s_para] with this lines?
i2s_mclk = port:PB05<2><1><default><default>
i2s_bclk = port:PB06<2><1><default><default>
i2s_lrclk = port:PB07<2><1><default><default>
i2s_dout0 = port:PB08<2><1><default><default>



Yes.

Note: I used http://www.cubieforums.com/index.php/topic,1438.0.html (http://www.cubieforums.com/index.php/topic,1438.0.html) image and patwood's kernel 3.4.75 sources.
Title: Re: ALSA bit-perfect output
Post by: GeorgeIoak on January 14, 2014, 11:45:59 am
We are still working on this issue to support 24-bit audio files. The drivers need to be modified in order to support this. I've confirmed with Allwinner that in theory the hardware can support this but it was never tested. I had a very brief meeting with them at CES and asked for their support. I'm not holding my breath that we'll get help but I am looking for knowledgeable programmers every day in order to get this resolved.
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 15, 2014, 08:21:31 am
And a few more changes:

        //i2s apbclk
        i2s_apbclk = clk_get(NULL, "apb_i2s");
        if(-1 == clk_enable(i2s_apbclk)){
                printk("i2s_apbclk failed! line = %d\n", __LINE__);
                goto out;
        }

replaced with:

        //i2s apbclk
        i2s_apbclk = clk_get(NULL, "apb_i2s0");
        if(-1 == clk_enable(i2s_apbclk)){
                printk("i2s_apbclk failed! line = %d\n", __LINE__);
                goto out;
        }


now module is loaded successfully:

linaro@linaro-ubuntu-desktop:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sunxisndspdif [sunxi-sndspdif], device 0: SUNXI-SPDIF sndspdif-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sunxisndi2s [sunxi-sndi2s], device 0: SUNXI-I2S sndi2s-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: sunxisndhdmi [sunxi-sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

but sound not played:

linaro@linaro-ubuntu-desktop:~$ cat /dev/urandom | aplay -r 48000 -c 2 -f S16_LE -D hw:1,0
Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
aplay: pcm_write:1710: write error: Input/output error

syslog message:

Jan 15 13:08:44 linaro-ubuntu-desktop kernel: [  448.949658] [IIS] dma trigger start
Jan 15 13:08:44 linaro-ubuntu-desktop kernel: [  448.953245] [IIS] 0x01c22400+0x24 = 0x91, line= 235
Jan 15 13:09:04 linaro-ubuntu-desktop kernel: [  469.088508] [IIS] dma trigger stop
Title: Re: ALSA bit-perfect output
Post by: kevin on January 15, 2014, 09:29:18 am
Hi nikkov,
Good to hear to load the module.
But how do you pull out the I2S signal out of the box?
In the script.fex file, there are four I2S signal ports from PB05 to PB08.
So far, I don't know which port goes to which pin of which connector on the PCB.
I was looking at the schematic diagram of A20 SoC and I suspect the connector is CN9 and the last four pins of that.
If I am right, you could test with I2S input DAC or logic analyzer.
One more thing, would you play real sound file using MPD with output plugin ALSA?
Also configure MPD logging option "verbose" and see what happen?
It will tell you what's going on even if you don't get sound from it.
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 15, 2014, 09:55:37 am
Hi kevin,

It's only little step to working I2S.

I'm see next problems:
1. aplay reported that I2S device supported only 16 and 20 bit sample.
2. I think that I2S pins on header CN9 on CT board not connected to CPU and need remove R183, 185, 187, 189 and set R182, 184, 186, 188 (reference to page 11 shematic diagram).
3. I2S device in master mode must play without error, but we have "Input/output error".

After solving these problems, next step - connect oscilloscope and I2S DAC
Title: Re: ALSA bit-perfect output
Post by: GeorgeIoak on January 15, 2014, 10:22:04 am
I agree with Nikkov. IF the schematic is correct then the resistors must be changed to pass I2S signals to the header but you can probe on the pad of R182 before making any changes to see if you get a Master Clock signal and you can play different sample rate files and see if the master clock changes correctly.

I think even if you get a signal out for I2S the alsa driver still needs to be modified in order to play 24-bit audio files.
Title: Re: ALSA bit-perfect output
Post by: bluerose on January 15, 2014, 08:53:32 pm
I'm going to make a HD digital source using Cubietruck.

But, I'm newbie in digital sound, linux, cubieboard.
So, please neglect if I'm talking completely non sense.

Is I2S enough to give sound information to another device?
How does master convince the slave device is in the right mode, or at least ready to receive signal?
Is it I2C working for this kind of communication?
Title: Re: ALSA bit-perfect output
Post by: kryoz on January 16, 2014, 02:43:10 am
Quote from: bluerose on January 15, 2014, 08:53:32 pm
I'm going to make a HD digital source using Cubietruck.

But, I'm newbie in digital sound, linux, cubieboard.
So, please neglect if I'm talking completely non sense.

Is I2S enough to give sound information to another device?
How does master convince the slave device is in the right mode, or at least ready to receive signal?
Is it I2C working for this kind of communication?


If you read previous pages then you'll understand that there are both software issues for I2S output and perhaps hardware. At this time you can use only spdif for digital output.
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 16, 2014, 08:59:15 am
I made next some changes and saw on oscilloscope all I2S signals.
Checked 44100, 16 bit and 192000, 24 bit. Seems all OK.

I still need to check all my changes and test CT with external DAC.
Title: Re: ALSA bit-perfect output
Post by: kryoz on January 16, 2014, 09:16:56 am
Quote from: nikkov on January 16, 2014, 08:59:15 am
I made next some changes and saw on oscilloscope all I2S signals.
Checked 44100, 16 bit and 192000, 24 bit. Seems all OK.

I still need to check all my changes and test CT with external DAC.


That's encouraging news! At least there is no need to use a soldering iron yet :)
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 16, 2014, 09:24:34 am
Quote from: kryoz on January 16, 2014, 09:16:56 am
That's encouraging news! At least there is no need to use a soldering iron yet :)


I watched signals on resistors pads  :(. Soldering will still be needed, but later.
Title: Re: ALSA bit-perfect output
Post by: GeorgeIoak on January 16, 2014, 12:15:49 pm
So the master clock frequency properly changed between 44.1kHz and 192kHz?

We're getting closer to solving the driver issues to support this. I think I might have something to share very soon.
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 16, 2014, 08:57:45 pm
Quote from: GeorgeIoak on January 16, 2014, 12:15:49 pm
So the master clock frequency properly changed between 44.1kHz and 192kHz?


Yes, of course. Setting sample rate to 44.1/48 family changed master clock to 22579200/24576000.
But only master clock output disabled for sample rate 192k in function sunxi_i2s_set_clkdiv.
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 19, 2014, 09:44:18 pm
Yesterday I resolder resistors and connected to I2S header external DAC.
With 16bit format played music, but with 24bit format played noise.
Title: Re: ALSA bit-perfect output
Post by: kryoz on January 20, 2014, 03:30:02 am
Quote from: nikkov on January 19, 2014, 09:44:18 pm
Yesterday I resolder resistors and connected to I2S header external DAC.
With 16bit format played music, but with 24bit format played noise.

That's a good progress.
Looking forward to see how to modify the code in module if necessary and resistors scheme. Thank you.
Oh by the way I still don't know how to manage i2s output format, do you have any clues about that?
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 20, 2014, 03:40:33 am
Quote from: kryoz on January 20, 2014, 03:30:02 am
Looking forward to see how to modify the code in module if necessary and resistors scheme. Thank you.

I'll write kernel source modifications after succesfully testing 24bit format.
Resistor scheme you can find in cubietruck schematic diagramm, page 11.
Quote from: kryoz on January 20, 2014, 03:30:02 am
Oh by the way I still don't know how to manage i2s output format, do you have any clues about that?

Now in kernel hardcoded I2S format with 32 bit word size.
Title: Re: ALSA bit-perfect output
Post by: szricky on January 22, 2014, 01:17:29 am
Nikkov,

Can you post your patches so that we can test? Thanks!

Ricky
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 22, 2014, 01:19:17 am
I can, but 24 bit not working yet.
Title: Re: ALSA bit-perfect output
Post by: szricky on January 22, 2014, 02:20:28 am
Nikkov,

I think I can help for testing for you.  ;D

I just apply all the patches of this post, and modules are loaded, but I meet the "Input/output error" as you.

Could you post your patch and show how to fix it? Many Thanks!  8)

Below my log:

# aplay myb.wav
Playing WAVE 'myb.wav' : Signed 16 bit Little Endian, Rat<6>[ccu-dbg] clk_set_rate: set audio_pll rate to 22579200, actual rate is 22579200
[  651.130400] [ccu-dbg] clk_set_rate: set audio_pll rate to 22579200, actual rate is 22579200
e 44100 Hz, Stereo
[IIS] dma trigger start
[  651.142720] [IIS] dma trigger start
[IIS] 0x01c22400+0x24 = 0x91, line= 235
[  651.149783] [IIS] 0x01c22400+0x24 = 0x91, line= 235
aplay: pcm_write:1737: [write error: Input/output error
IIS] dma trigger stop
[  671.252826] [IIS] dma trigger stop
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 22, 2014, 03:15:27 am
I attached patch file with my modifications. I also added some debug information.
Note: sunxi-codec must be compiled as kernel module!
Title: Re: ALSA bit-perfect output
Post by: szricky on January 22, 2014, 04:17:03 am
Nikkov,

Thanks for your patch, but I still meet "Input/output error", below my steps. I believe I don't miss something, it seems a DMA operating error, and I will try more tonight.  ;D

#1: recreate the kernel
tar xvf linux-sunxi-pat-3.4.75-ct.zip

#2: apply the patch, .
patch -p1 < ~/Downloads/patch_i2s

#... make & make uImage, etc.
rebuild and no errors,

#3: update to cubietruck.

#4: load modules and successful.

#5: try to play wav file, and meet the write error: Input/output error

**************************************************************

# aplay myb.wav

Playing WAVE 'myb.wav' : Signed 16 bit Little Endian, Rat[e 44100 Hz, Stereo
IIS]sunxi_sndi2s_hw_params: codec_dai=(sndi2s), cpu_dai=(sunxi-i2s.0)
[   86.591342] [IIS]sunxi_sndi2s_hw_params: codec_dai=(sndi2s), cpu_dai=(sunxi-i2s.0)
[IIS]sunxi_i2s_set_fmt: set master mode for I2S interface
[   86.604084] [IIS]sunxi_i2s_set_fmt: set master mode for I2S interface
[IIS]sunxi_i2s_set_fmt: set I2S mode
[   86.613909] [IIS]sunxi_i2s_set_fmt: set I2S mode
[IIS]sunxi_i2s_set_fmt: normal bit clock + frame
[   86.622880] [IIS]sunxi_i2s_set_fmt: normal bit clock + frame
[IIS]sunxi_i2s_set_fmt: word size = 0
[   86.631934] [IIS]sunxi_i2s_set_fmt: word size = 0
[IIS]sunxi_i2s_set_fmt: set word size = 32
[   86.640466] [IIS]sunxi_i2s_set_fmt: set word size = 32
[IIS]sunxi_i2s_set_fmt: set pcm_sync_type = short sync
[   86.650459] [IIS]sunxi_i2s_set_fmt: set pcm_sync_type = short sync
[IIS]sunxi_i2s_set_sysclk: set sysclk=22579200
[   86.660966] [IIS]sunxi_i2s_set_sysclk: set sysclk=22579200
[IIS]sunxi_i2s_set_clkdiv: div_id=(SUNXI_DIV_MCLK), div=(2)
[   86.671766] [IIS]sunxi_i2s_set_clkdiv: div_id=(SUNXI_DIV_MCLK), div=(2)
[IIS]sunxi_i2s_set_clkdiv: enable MCLK
[   86.681859] [IIS]sunxi_i2s_set_clkdiv: enable MCLK
[IIS]sunxi_i2s_set_clkdiv: div_id=(SUNXI_DIV_BCLK), div=(4)
[   86.691949] [IIS]sunxi_i2s_set_clkdiv: div_id=(SUNXI_DIV_BCLK), div=(4)
[IIS]sunxi_i2s_set_clkdiv: enable MCLK
[   86.702041] [IIS]sunxi_i2s_set_clkdiv: enable MCLK
[IIS]sunxi_i2s_hw_params: format 16 bit
[   86.710401] [IIS]sunxi_i2s_hw_params: format 16 bit
[IIS] sunxi_pcm_prepare playback PCM stream
[   86.719319] [IIS] sunxi_pcm_prepare playback PCM stream
[IIS] dma trigger start
[   86.727510] [IIS] dma trigger start
[IIS] 0x01c22400+0x24 = 0x91, line= 238
[   86.734576] [IIS] 0x01c22400+0x24 = 0x91, line= 238
aplay: pcm_write:1737: [write error: Input/output error
IIS] dma trigger stop
[  106.843011] [IIS] dma trigger stop
#
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 22, 2014, 04:24:22 am
Szricky,

Are you set options
CONFIG_SND_SUNXI_SOC_CODEC=y
in .config?
Title: Re: ALSA bit-perfect output
Post by: szricky on January 22, 2014, 04:26:56 am
Okay, the MCLK can be found with Oscilloscope.

Title: Re: ALSA bit-perfect output
Post by: nikkov on January 23, 2014, 12:23:44 am
I successfully tested (aplay and mpd) 24 bit format too. Today we have a working I2S interface with support 16/24 bit (S16_LE and S24_LE) and up to 192 khz sample rate. I'll upload a patch after some code cleaning.
Title: Re: ALSA bit-perfect output
Post by: kevin on January 23, 2014, 05:48:11 am
Hi nikkov,

Great news!! BTW, maybe you can use format "S24_LE" not "S24_3LE".
Did you already do with "S24_LE"?
And do we need to modify HW to pull out I2S signal?
Is it CN9 for connection to external DAC?
Again, thanks for your great work!!
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 23, 2014, 07:32:42 am
Hi kevin,

Quote from: kevin on January 23, 2014, 05:48:11 am
Hi nikkov,

Great news!! BTW, maybe you can use format "S24_LE" not "S24_3LE".
Did you already do with "S24_LE"?

Yes, I use format S24_LE. And yes, S24_LE now working fine  :).

hw_params output (MPD plays radio station):

access: RW_INTERLEAVED
format: S24_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 4096
buffer_size: 16384


hw_params output (MPD plays 24/192khz):

access: RW_INTERLEAVED
format: S24_LE
subformat: STD
channels: 2
rate: 192000 (192000/1)
period_size: 4096
buffer_size: 16384


Quote from: kevin on January 23, 2014, 05:48:11 am
And do we need to modify HW to pull out I2S signal?
Is it CN9 for connection to external DAC?

Yes, you need to resolder the resistors for output I2S то CN9:
remove R175 and set R174
remove R177 and set R176
remove R178 and set R179
remove R180 and set R181
remove R183 and set R182
remove R185 and set R184
remove R187 and set R186
remove R189 and set R188

and connect extermal DAC to CN9

Quote from: kevin on January 23, 2014, 05:48:11 am
Again, thanks for your great work!!


And thanks to you, you are helped me to start

My setup:

(http://farm8.staticflickr.com/7403/12101552406_8f4108a4df.jpg) (http://www.flickr.com/photos/115250773@N05/12101552406/)
hi-fi-ct (http://www.flickr.com/photos/115250773@N05/12101552406/) by nikkov55 (http://www.flickr.com/people/115250773@N05/), on Flickr

And last patch attached
Title: Re: ALSA bit-perfect output
Post by: kryoz on January 25, 2014, 08:43:27 am
I've got module compilation problem after last patch
ERROR: "sunxi_iis" [sound/soc/sunxi/i2s/sunxi-sndi2s.ko] undefined!
ERROR: "sunxi_iis" [sound/soc/sunxi/i2s/sunxi-i2sdma.ko] undefined!


Using patwood's kernel 3.4.75-ct with .config from his kernel zip-file.
CONFIG_SND_SUNXI_SOC_CODEC set to 'y'

Any help?
Title: Re: ALSA bit-perfect output
Post by: nikkov on January 25, 2014, 09:11:05 am
Quote from: kryoz on January 25, 2014, 08:43:27 am
I've got module compilation problem after last patch
ERROR: "sunxi_iis" [sound/soc/sunxi/i2s/sunxi-sndi2s.ko] undefined!
ERROR: "sunxi_iis" [sound/soc/sunxi/i2s/sunxi-i2sdma.ko] undefined!


Using patwood's kernel 3.4.75-ct with .config from his kernel zip-file.
CONFIG_SND_SUNXI_SOC_CODEC set to 'y'

Any help?


I compiled sunxi-iis as kernel module
Title: Re: ALSA bit-perfect output
Post by: kryoz on January 25, 2014, 09:47:04 am
I found the problem, it didn't have relation to the i2s module. There was an error compiling bcmdhd module for wi-fi.
Title: Re: ALSA bit-perfect output
Post by: Vanderdrux on February 03, 2014, 06:32:37 am
dear all,
    1st off all thank you for your sharing.

I'm interested to make CT able to play with audio for metering, recording, and study.
My 1st goal have been Jackd and ardour working perfect after a long session of source code compile directly on the CT.
With obiouvsly not much filter applied at same time I can use them without have any xrun errors and re-patch audio output to headphone with nice audio quality. No pop, no glitch, no artefacts.

I would like understand which kind of possibilities of audio input can we use with CT.

For analog to be honest I've not yet found the right config but changing script.bin I've made alsa able to have all inputs visible on alsa mixer (various mics, line IN, line ADC, etc...). Jackd can route input (analog noise around -60db -50db of TP). I've not connected nothing yet to the right jumper.

did you experts had some experience about i2s input or only i2s output?
do you have some ideas to have digital input, maybe also more than 2ch please? Maybe with also something like AES/EBU to i2s and so on.

much appreciated any your answer.
apologies for my rough english.

have a nice time
Title: Re: ALSA bit-perfect output
Post by: mhelin on February 11, 2014, 04:33:33 pm
How is the multichannel output in i2s driver, is it supported? The patch seems to enable all SDOx output data pins, but guess that is not enough.
Title: Re: ALSA bit-perfect output
Post by: soundcheck on February 18, 2014, 09:52:17 am
Nikkov.

Great work. I'll try introduce the patch in the ArchLinux project (http://www.cubieforums.com/index.php/topic,1592.0.html) , if you don't mind. It would be even better if patwood or sunxi would take the patch straight into their
kernel work.

How difficult would it be to patch the SPDIF sources?? SPDIF still doesn't come with 24bit, which is a pity. I looked a little bit into the SPDIF code and into your patch . (I'm not an experienced programmer.) A lot of similarities. I guess it shouldn't be too complex to get SPDIF up 2 24bit. 24bit is IMO more important than having high samplerates All high samplerate material is 24bit anyhow. So 24bit comes first.


Thx for your efforts.
Title: Re: ALSA bit-perfect output
Post by: soundcheck on February 18, 2014, 10:52:21 am
Hmmh.

I also ran into this


ERROR: "sunxi_iis" [sound/soc/sunxi/i2s/sunxi-sndi2s.ko] undefined!
ERROR: "sunxi_iis" [sound/soc/sunxi/i2s/sunxi-i2sdma.ko] undefined!


on patwoods kernel.

I set CONFIG_SND_SUNXI_SOC_CODEC=m with make oldconfig.

Anything else I'd have to consider?
Title: Re: ALSA bit-perfect output
Post by: soundcheck on February 18, 2014, 11:18:45 am
Hmmh.

I changed the module config to "Y" now with menuconfig. Compiled again.

and ended up with this:


0 [sunxisndi2s    ]: sunxi-sndi2s - sunxi-sndi2s
                      sunxi-sndi2s


;)
Title: Re: ALSA bit-perfect output
Post by: cu6apum on March 09, 2014, 06:51:42 pm
The patch file has been lost....
nikkov, what's there beyond clock source fix you've posted in the beginning?
Title: Re: ALSA bit-perfect output
Post by: nikkov on March 12, 2014, 01:21:35 am
I attached new patch for I2S.
Changes:
1. Cleaning unused code
2. Support as loadable module compilation
3. Support slave mode

For defination master/slave mode I used script.bin:

[i2s_para]
i2s_used = 1
i2s_slave = 1
i2s_channel = 2
i2s_bclk = port:PB06<2><1><default><default>
i2s_lrclk = port:PB07<2><1><default><default>
i2s_dout0 = port:PB08<2><1><default><default>
i2s_dout1 =
i2s_dout2 =
i2s_dout3 =
i2s_din = port:PB12<2><1><default><default>
i2s_clk_sel = port:PB05<1><0><default><1>
i2s_clk_div0 = port:PB09<1><0><default><1>
i2s_clk_div1 = port:PB10<1><0><default><1>


i2s_clk_sel used for external master clock selector (1=22.5792MHz, 0=24.576MHz)
i2s_clk_div0, i2s_clk_div1 used for bitclock divider:
1, 1 for 44100/48000
1, 0 for 88200/96000
0, 0 for 176400/192000

Simple description of my CT adapter for slave mode:
(http://farm8.staticflickr.com/7395/13098461663_abce02193b.jpg) (http://www.flickr.com/photos/115250773@N05/13098461663/)
block_sch (http://www.flickr.com/photos/115250773@N05/13098461663/) by nikkov55 (http://www.flickr.com/people/115250773@N05/), on Flickr

and adapter:
(http://farm4.staticflickr.com/3814/13098678244_664e062e77.jpg) (http://www.flickr.com/photos/115250773@N05/13098678244/)
CT_adapter (http://www.flickr.com/photos/115250773@N05/13098678244/) by nikkov55 (http://www.flickr.com/people/115250773@N05/), on Flickr
Title: Re: ALSA bit-perfect output
Post by: TBM on March 12, 2014, 02:05:55 am
Nice Nikkov!  :)

What can you say soundwize regarding using your 2 clock solution vs "only" using the internal clock for bit-perfect I2S on 44.1KHz and 48KHz (and multiples)?

Cheers,
Tom
Title: Re: ALSA bit-perfect output
Post by: nikkov on March 12, 2014, 02:23:53 am
Quote from: TBM on March 12, 2014, 02:05:55 am
Nice Nikkov!  :)

What can you say soundwize regarding using your 2 clock solution vs "only" using the internal clock for bit-perfect I2S on 44.1KHz and 48KHz (and multiples)?

Cheers,
Tom


My current setup suitable only for code testing. So I can't compare sound quality. But I know that sound from clock derived from PLL potentially lower quality.
Title: Re: ALSA bit-perfect output
Post by: glt on March 29, 2014, 02:22:12 am
First post here. Good work for enabling I2S. It seems the patch requires compilation of the source. Is there hope for those of us code-challenged to have this incorporated into a release?

Title: Re: ALSA bit-perfect output
Post by: cu6apum on March 30, 2014, 05:35:08 am
There's nothing criminal in compiling the code, there are several toolchains ready-to-go, from linux packages to even Mac OS. One day of pain, and you're in control.
In any case, you need to brush the kernel seriously for best audio results. I have removed tons of unused stuff, shrinking the kernel 6x in size.
Title: Re: ALSA bit-perfect output
Post by: isirps on April 01, 2014, 07:02:30 am
any idea how to send 24/96 stereo through usb dac? It plays mp3, but does not play flac.

lubuntu desktop cubietruck. loaded snd-usb-audio modue and mpd...
Title: Re: ALSA bit-perfect output
Post by: Punith on June 17, 2014, 08:23:59 am
Hi nikkov,

In our A20 custom board we are using i2s sound card , for that we are using TI external codec TLV320AIC3100.
In Kernel tree we have alsa driver for TLV320AIC3100.
vim linux-sunx/sound/soc/codecs/tlv320aic3x.c

So i tried by writing Asoc machine driver linking alsa external codec to  sunxi-i2s soundcard and compiled successfully and by  insmod also working fine.but once i play any audio which is not yet worked.

Here i am attaching my machine driver code ,scripts and schematics and log once i play audio though i2s

Log:
root@localhost:/# mplayer -ao alsa:device=hw=2.0 /Waka.mp4
Warning unknown option skin at line 101
MPlayer2 UNKNOWN (C) 2000-2011 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing /Waka.mp4.
Detected file format: QuickTime/MPEG-4/Motion JPEG 2000 format (libavformat)
[lavf] stream 0: audio (aac), -aid 0, -alang und
[lavf] stream 1: video (h264), -vid 0
VIDEO:  [H264]  1920x1080  24bpp  24.000 fps  3714.5 kbps (453.4 kbyte/s)
Clip info:
major_brand: mp42
minor_version: 0
compatible_brands: isomavc1mp42
creation_time: 2010-06-03 23:14:31
Load subtitles in /
vo: couldn't open the X11 display ()!
Error opening/initializing the selected video_out (-vo) device.
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 125.6 kbit/8.90% (ratio: 15695->176400)
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A:   1.7 (01.6) of 210.6 (03:30.5)  4.1% $<3>


MPlayer interrupted by signal 2 in module: unknown

Exiting... (Quit)


DMESG log:
[SWITCH] sun7i_sndi2s_hw_params,line:131,audio_format:1,SND_SOC_DAIFMT_DSP_A:4
[SWITCH] sun7i_sndi2s_hw_params,line:133,signal_inversion:1,signal_inversion<<8:256,SND_SOC_DAIFMT_IB_NF:768
[SWITCH] sun7i_sndi2s_hw_params,line:135,i2s_master:4,i2s_master<<12:16384,SND_SOC_DAIFMT_CBM_CFM:4096
play:sun7i_i2sdma.c::func:sun7i_pcm_hw_params(line:261)
play DMA_OP_STOP:sun7i-i2sdma.c::func:sun7i_pcm_hw_free(line:382)

My i2s soundcard is working fine, i am getting mclk,bclk  but not able invoke the dac.

Kindly help me. How can i solve this.

Regards
Punith
Title: Re: ALSA bit-perfect output
Post by: nikkov on June 18, 2014, 08:04:37 am
Quote from: Punith on June 17, 2014, 08:23:59 am
Hi nikkov,

In our A20 custom board we are using i2s sound card , for that we are using TI external codec TLV320AIC3100.
In Kernel tree we have alsa driver for TLV320AIC3100.
vim linux-sunx/sound/soc/codecs/tlv320aic3x.c
...

Hi, Punith

Sorry, I have no experience developing drivers for linux, but in your case may be need check codecs initialisation code and working I2C control bus?
And I checked only I2S mode, PCM mode not tested!

Nikolay
Title: Re: ALSA bit-perfect output
Post by: Punith on June 21, 2014, 08:36:10 am
Hi Nikkov,

Actually i ma new i2s protocol,
can you say what is difference pcm mode and i2s mode?.
How can i configure it?

Regards
Punith
Title: Re: ALSA bit-perfect output
Post by: othiman on July 29, 2014, 01:07:09 pm
Hi,

for our project we are playing with the cubietruck i2s functions and want to use all i2s channels. Has anyone tried this yet?

Our goal is to build an AC3/DTS software decoder (capturing SPDIF, playback I2S multichannel). For this we also want to use the spdif input (Pin PB12) of the cubietruck, but have not found any information about that. Can anyone give us a hint?

Best regards,
othiman
Title: Re: ALSA bit-perfect output
Post by: nikkov on April 16, 2015, 11:23:37 pm
I added to SPDIF driver for cubietruck support playback 24bit audio and capture feature 16/24b. Kernel code source:
https://github.com/nikkov/linux-sunxi (https://github.com/nikkov/linux-sunxi).
Note: capture works with LR channels swapping
Title: Re: ALSA bit-perfect output
Post by: othiman on July 01, 2015, 04:40:51 am
Hi nikkov,

we tried your kernel, but it doesn't work for us. How have you connected the Spdif out to Spdif in? Have you directly connected PB12 to PB13 (TP12 to CN9,Pin23 (disconnected R180, connected R181)) or have you used some kind of logic level shifting? Do you know what kind schematics we need to connect a SPDIF Coax, e.g., from a sound card, to the CN9, Pin23?

Best regards,
Thomas
Title: Re: ALSA bit-perfect output
Post by: nikkov on July 02, 2015, 11:12:31 am
Hi othiman
Yes, I directly connected TP12 to CN9,Pin23 (disconnected R180, connected R181). And, of course, I changed fex-file.
If you want connect real coax SPDIF you must use to logic level converter, e.g. with adm1485 or simple logic like 74HC04.