November 20, 2019, 09:47:05 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

Yesterday I resolder resistors and connected to I2S header external DAC.
With 16bit format played music, but with 24bit format played noise.

kryoz

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?

nikkov

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.

szricky

Nikkov,

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

Ricky

nikkov

I can, but 24 bit not working yet.

szricky

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

nikkov

January 22, 2014, 03:15:27 am #51 Last Edit: January 23, 2014, 08:28:33 am by nikkov
I attached patch file with my modifications. I also added some debug information.
Note: sunxi-codec must be compiled as kernel module!

szricky

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
#

nikkov

Szricky,

Are you set options
CONFIG_SND_SUNXI_SOC_CODEC=y
in .config?

szricky

January 22, 2014, 04:26:56 am #54 Last Edit: January 22, 2014, 04:46:01 am by szricky
Okay, the MCLK can be found with Oscilloscope.


nikkov

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.

kevin

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!!

nikkov

January 23, 2014, 07:32:42 am #57 Last Edit: January 23, 2014, 07:54:57 am by nikkov
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:


hi-fi-ct by nikkov55, on Flickr

And last patch attached

kryoz

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?

nikkov

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