I2S capture in H3, Armbian 5.21 legacy kernel 3.4.112


Recommended Posts

Hi,

 

Got a bit of a strange situation here.

 

Trying to get H3 I2S working in both playback and capture.

 

Tweaked script.bin and got the I2S0 up and running.

 

Playback in 96K and 192K tested and is ok.

 

Capture though is giving me a headache.

 

When I try to use arecord it does work and generates a wav file but upon playing the file with aplay and although the samplerate (96K or 192K) and channel numbers (Stereo) show ok on screen, the audio result from this recording is always mono and looks that the included samples numer is divided by 2 thus the playback time is shortened accordingly, eg if I record 10 sec, a 5 sec playing time happens.

 

Verified the actual I2S HW lines with digital scope and they are ok with proper time periods/frequency and samplerate or bit depth.

 

So, my question, has anyone any experience with a working I2S in H3 ? Is it actually working or the I2S driver is misbehaving? Is it tested in 96K and 192K capture?

 

Can someone point me to where the pcm script.fex parameters are documented?

The official sunxi does not show them..

-> http://linux-sunxi.org/Fex_Guide

 

 

Christos

 

 

P.S.

Boards tested/used are NanoPi NEO & OrangePi ONE

 

 

 

 

Link to post
Share on other sites
Donate and support the project!

There are though after all pcm parameters in the script.fex for the H3

[pcm0]
daudio_used = 1
daudio_master = 4
daudio_select = 1
audio_format = 1
signal_inversion = 1
mclk_fs = 128
sample_resolution = 32
slot_width_select = 32
pcm_lrck_period = 32
pcm_lrckr_period = 1
msb_lsb_first = 0
sign_extend = 0
slot_index = 0
slot_width = 32
frame_width = 0
tx_data_mode = 0
rx_data_mode = 0
i2s_mclk = port:PA18<2><1><default><default>
i2s_bclk = port:PA19<2><1><default><default>
i2s_dout0 = port:PA20<2><1><default><default>
i2s_din = port:PA21<2><1><default><default>

And they are sitting there since the first 3.x release from whoever did it (AllWinner itself or SinoVoip/Xunlong/FriendlyArm..)

Yet there is zero info for most of them..

Link to post
Share on other sites

Yet there is zero info for most of them..

 

Only sources available. So unless someone knowledgeable reading through sources adds the stuff to linux-sunxi wiki nothing will change (I'm not kidding and I also lack both skills and interest... but this is really how it works. Documentation has to be written ;) )

Link to post
Share on other sites

Only sources available. So unless someone knowledgeable reading through sources adds the stuff to linux-sunxi wiki nothing will change (I'm not kidding and I also lack both skills and interest... but this is really how it works. Documentation has to be written ;) )

 

Ok Thomas, I understand your point and where you stand on this.

 

I only hope that some knowledgable guys who have insight or experience on the issue I have stated on the initial post, come and lend a hand with some pointers at least on what to look for or where.

 

Any help is welcome.

 

Christos

Link to post
Share on other sites

Hi,

 

Got a bit of a strange situation here.

 

Trying to get H3 I2S working in both playback and capture.

 

Tweaked script.bin and got the I2S0 up and running.

 

Playback in 96K and 192K tested and is ok.

 

Capture though is giving me a headache.

 

When I try to use arecord it does work and generates a wav file but upon playing the file with aplay and although the samplerate (96K or 192K) and channel numbers (Stereo) show ok on screen, the audio result from this recording is always mono and looks that the included samples numer is divided by 2 thus the playback time is shortened accordingly, eg if I record 10 sec, a 5 sec playing time happens.

 

Verified the actual I2S HW lines with digital scope and they are ok with proper time periods/frequency and samplerate or bit depth.

 

So, my question, has anyone any experience with a working I2S in H3 ? Is it actually working or the I2S driver is misbehaving? Is it tested in 96K and 192K capture?

 

Can someone point me to where the pcm script.fex parameters are documented?

The official sunxi does not show them..

-> http://linux-sunxi.org/Fex_Guide

 

 

Christos

 

 

P.S.

Boards tested/used are NanoPi NEO & OrangePi ONE

 

 

 

To add a bit here, the problem happens when I capture/play with samplesizes more than 16bits, eg 24 or 32, S24_LE/S32_LE.

 

 

Christos

Link to post
Share on other sites

Hi,

 

Got a bit of a strange situation here.

 

Trying to get H3 I2S working in both playback and capture.

 

Tweaked script.bin and got the I2S0 up and running.

 

Playback in 96K and 192K tested and is ok.

 

Capture though is giving me a headache.

 

When I try to use arecord it does work and generates a wav file but upon playing the file with aplay and although the samplerate (96K or 192K) and channel numbers (Stereo) show ok on screen, the audio result from this recording is always mono and looks that the included samples numer is divided by 2 thus the playback time is shortened accordingly, eg if I record 10 sec, a 5 sec playing time happens.

 

Verified the actual I2S HW lines with digital scope and they are ok with proper time periods/frequency and samplerate or bit depth.

 

So, my question, has anyone any experience with a working I2S in H3 ? Is it actually working or the I2S driver is misbehaving? Is it tested in 96K and 192K capture?

 

Can someone point me to where the pcm script.fex parameters are documented?

The official sunxi does not show them..

-> http://linux-sunxi.org/Fex_Guide

 

 

Christos

 

 

P.S.

Boards tested/used are NanoPi NEO & OrangePi ONE

I am trying to get I2S playback working.

 

I have edited the script.bin to activate the pcm0 interface and aplay -l shows the interface is active. But when I try to playback audio I see no data on any of the signal lines with a scope.

 

Did you have to load any additional modules to activate playback or just tweak the parameters in script.bin ?.

 

Could you post a copy of the parameters you used in the script.bin for the pcm interface.

 

Thanks.

Link to post
Share on other sites
On 10/10/2016 at 6:01 AM, Christos said:

To add a bit here, the problem happens when I capture/play with samplesizes more than 16bits, eg 24 or 32, S24_LE/S32_LE.

That's exactly the same problem I'm facing right now with legacy 3.4.113 on Nano Pi NEO Air (H3 chip). Audio recorded with e.g. S32_LE format is garbage, whereas S16_LE is perfect.

 

Has anybody figured out how to handle this? I tried meddling with pcm0 parameters to no avail.

Link to post
Share on other sites
On 10/9/2016 at 1:10 PM, Christos said:

There are though after all pcm parameters in the script.fex for the H3


[pcm0]
daudio_used = 1
daudio_master = 4
daudio_select = 1
audio_format = 1
signal_inversion = 1
mclk_fs = 128
sample_resolution = 32
slot_width_select = 32
pcm_lrck_period = 32
pcm_lrckr_period = 1
msb_lsb_first = 0
sign_extend = 0
slot_index = 0
slot_width = 32
frame_width = 0
tx_data_mode = 0
rx_data_mode = 0
i2s_mclk = port:PA18<2><1><default><default>
i2s_bclk = port:PA19<2><1><default><default>
i2s_dout0 = port:PA20<2><1><default><default>
i2s_din = port:PA21<2><1><default><default>

And they are sitting there since the first 3.x release from whoever did it (AllWinner itself or SinoVoip/Xunlong/FriendlyArm..)

Yet there is zero info for most of them..

I've been delving into I2S driver on H3 (legacy kernel) because I need TDM (time-division multiplexing) mics to work. So I came across what all those fex parameters really mean. Almost all of them can be found in sunxi-daudio0.c, some can be found in sunxi-snddaudio0.c, and you need to match those parameters to H3 datasheet.

 

I'll spit out some of my findings. Please feel free to ask questions about any of the parameters.

 

- daudio_master: it goes from 1 to 4. It selects slave/master combinations of bit clock and frame sync. 

    = 1: bit clock and frame sync are input to H3 (i.e., codec is master, H3 is slave);

    = 2: bit clock is output from H3, frame sync is input to H3;

    = 3: bit clock is input to H3, frame sync is output from H3;

    = 4: bit clock and frame sync are output from H3 (i.e., codec is slave, H3 is master).

 

- daudio_select: it can be 0 or 1. It selects whether we will be working with I2S or PCM mode.

    = 0: PCM mode. Basically, frame sync is just a short pulse, and all channels are sent/captured one after the other. When the last one is sent/captured, frame sync is pulsed again.

    = 1: I2S mode. Channels 0, 2, 4... are sent/captured during frame sync high; channels 1, 3, 5... are sent/captured during frame sync low.

 

- audio_format: it goes from 1 to 5. It selects different configurations of I2S or PCM mode. See pages 529 and 530 of H3 datasheet.

    = 1: regular I2S mode. Only makes sense when daudio_select = 1 (I2S).

    = 2: I2S right justified mode. Only makes sense when daudio_select = 1.

    = 3: I2S left justified mode. Only makes sense when daudio_select = 1.

    = 4: DSP_A mode. Only makes sense when daudio_select = 0 (PCM).

    = 5: DSP_B mode. Only makes sense when daudio_select = 0.

 

- signal_inversion: it goes from 1 to 4. It selects different combinations of bit clock and frame sync polarity.

Link to post
Share on other sites
Guest
This topic is now closed to further replies.