October 22, 2019, 09:46:42 am

News:

Have you visited the Allwinner Chipset wiki? - http://linux-sunxi.org/


ALSA bit-perfect output

Started by kevin, November 25, 2013, 06:07:05 am

Previous topic - Next topic

kevin

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.

halfur

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.

kevin

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.


kevin

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.

kevin

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.

CubieNewb

Hi, would Kevin or someone please post step by step instructions for us Linux newbs?

kevin

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!

halfur

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.

kevin

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.

GeorgeIoak

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!

kevin

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.

tbenr


kevin

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. ;)

GeorgeIoak

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.

kevin

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.