November 12, 2019, 08:36:06 pm

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

nikkov

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



kryoz

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>

nikkov

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 image and patwood's kernel 3.4.75 sources.

GeorgeIoak

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.

nikkov

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

kevin

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.

nikkov

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

GeorgeIoak

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.

bluerose

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?

kryoz

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.

nikkov

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.

kryoz

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 :)

nikkov

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.

GeorgeIoak

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.

nikkov

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.