[HDMI] Sound glitch every 3 sec

Moderators: mdrjr, odroid

[HDMI] Sound glitch every 3 sec

Unread postby Mobilaz » Tue Oct 30, 2018 9:46 pm

Hi,

For my project, I would like to display a video with sound via HDMI with an Odroid-C2 and the ubuntu distribution based on the kernel 3.16.60.
I noticed that every 3 seconds there is a small glitch corresponding to a drop of an audio sample when playing a sine wave at 200Hz.

This issue seems to not appear when using the LibreElec distribution.

After investigation, I think that the issue comes from a drift between the audio clock and the hdmi clock but I couldn't find any clock differences between the Ubuntu and the LibreElec distribution.

I also noticed a lot of differences between the two sound drivers from LibreElec and Ubuntu (in /sound/soc/aml/m8 mainly).

Do you have any idea why there is a sound glitch or/and how I could use the same clock for the audio/hdmi system as in LibreElec ?

Thanks in advance
Mobilaz
 
Posts: 5
Joined: Tue Oct 30, 2018 8:00 pm
languages_spoken: english
ODROIDs: ODROID-C2

Re: [HDMI] Sound glitch every 3 sec

Unread postby rooted » Wed Oct 31, 2018 2:21 am

You could try using LE kernel.
User avatar
rooted
 
Posts: 5680
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: [HDMI] Sound glitch every 3 sec

Unread postby odroid » Wed Oct 31, 2018 9:39 am

Can you share the 200Hz sine wave audio file to reproduce the issue on our side?
User avatar
odroid
Site Admin
 
Posts: 28859
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: [HDMI] Sound glitch every 3 sec

Unread postby Mobilaz » Wed Oct 31, 2018 8:28 pm

Hi,

Thanks for your reply.

I used the ALSA Api to send an homemade sine wave at 200Hz to the HDMI.

Please find hereby attached the source code of the sinewave and the elf file.

In the device tree, I could see that the PLL0 is used in ubuntu while the PLL2 is used in LE kernel for I2S. Is it possible that this has an impact ?

Thanks in advance,
Attachments
SineWaveAlsa.txt
had to change the extension from .elf to .txt to upload it
(54.13 KiB) Downloaded 11 times
SineWaveAlsa.cpp
(6.14 KiB) Downloaded 12 times
Mobilaz
 
Posts: 5
Joined: Tue Oct 30, 2018 8:00 pm
languages_spoken: english
ODROIDs: ODROID-C2

Re: [HDMI] Sound glitch every 3 sec

Unread postby joy » Thu Nov 01, 2018 5:10 pm

Hi Mobilaz,
Thank you for sharing the files.
Please let us check the issue for a couple of days.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: [HDMI] Sound glitch every 3 sec

Unread postby Mobilaz » Tue Nov 06, 2018 6:49 pm

Hi,

Were you able to reproduce the issue ? The image used for my test is the "ubuntu-18.04-3.16-minimal-odroid-c2.img".

I kept digging a bit more in the source code and the datasheet to find the HDMI and audio clocks differences between LE and Ubuntu Kernel. So far, I couldn’t spot the issue.

I’d like to better understand the clocking of the HDMI/AUDIO device. So, I really need clear and complete documentation.
While digging into the S905 public datasheet, which clearly lacks details, I encountered a reference to a clock tree document. Do you know where I could find this referenced document which would be very helpful to understand.

I am also missing some parts of the audio data flow via HDMI:

- Is I2S used to transfer data ?
- How does the audio go from the memory to the final HDMI output ? (any hardware codec ?)

Would it be possible to have access to a more detailed datasheet of the S905 amlogic processor ?

Thanks in advance,
Mobilaz
 
Posts: 5
Joined: Tue Oct 30, 2018 8:00 pm
languages_spoken: english
ODROIDs: ODROID-C2

Re: [HDMI] Sound glitch every 3 sec

Unread postby joy » Wed Nov 07, 2018 8:41 am

Mobilaz wrote:Were you able to reproduce the issue ? The image used for my test is the "ubuntu-18.04-3.16-minimal-odroid-c2.img".
I kept digging a bit more in the source code and the datasheet to find the HDMI and audio clocks differences between LE and Ubuntu Kernel. So far, I couldn’t spot the issue.

Hi Mobilaz,
Sorry for late response.

Yes, I could reproduce the issue and hear the glitch noise (like pop-up noise)
and also tried LibreELEC then no issue.
I also tried USB audio adapter on ubuntu 18.40 and in this case, no issue.

To make sure the output, I also checked the sine wave from HDMI using oscilloscope
and I got 200Hz sinewave and no signal drop in my eyes.

We're still looking into differences between LibreELEC and Ubuntu 3.16 version.
So I will try 3.14 kernel version on Ubuntu 18.04.

Mobilaz wrote:I’d like to better understand the clocking of the HDMI/AUDIO device. So, I really need clear and complete documentation.
While digging into the S905 public datasheet, which clearly lacks details, I encountered a reference to a clock tree document. Do you know where I could find this referenced document which would be very helpful to understand.
I am also missing some parts of the audio data flow via HDMI:
- Is I2S used to transfer data ?
- How does the audio go from the memory to the final HDMI output ? (any hardware codec ?)
Would it be possible to have access to a more detailed datasheet of the S905 amlogic processor ?

About it, Sorry. The documentation shared in wiki page is all.
Also, we don't have any detailed S905 datasheet that is not opened to ODROID users, too. :(
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: [HDMI] Sound glitch every 3 sec

Unread postby joy » Wed Nov 07, 2018 11:05 am

Hello Mobilaz,
I've checked 3.14.y kernel on Ubuntu 18.04 and got the same issue with 3.16.y,
and found hdmi sound driver under sound/soc/aml/ is quite different from LibreELEC kernel.
So could you please check us it more internally for more days?
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: [HDMI] Sound glitch every 3 sec

Unread postby Mobilaz » Thu Nov 08, 2018 11:32 pm

Hi Joy,

Thanks for looking into this issue.

I analyzed the hdmi audio output with an external device and I could isolate the issue.

There is a single audio sample set to zero every 7 sec at a sample rate of 48kHz as can be seen in the attached picture.

I am looking forward to hearing from you.

Thanks in advance,
Attachments
48k_sine_18sec.PNG
48k_sine_18sec.PNG (41.36 KiB) Viewed 321 times
Mobilaz
 
Posts: 5
Joined: Tue Oct 30, 2018 8:00 pm
languages_spoken: english
ODROIDs: ODROID-C2

Re: [HDMI] Sound glitch every 3 sec

Unread postby joy » Fri Nov 09, 2018 10:05 am

Hi Mobilaz,
My colleague in charge of audio has been fixed this issue. ;)
He will share his patch soon.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X

Re: [HDMI] Sound glitch every 3 sec

Unread postby cap00k » Fri Nov 09, 2018 12:01 pm

Hi Mobilaz,

I reviewed the issue, I noticed that there was a difference between the audio clock and the hdmi clock.
So I applied this patch to fix the problem. This is a patch for clock settings when i2s data is the source of hdmi audio output.
Could you tell me apply this patch and test it then results?
Attachments
0001-ODROID-C2-Modified-HDMI-sound-glitch.zip
(927 Bytes) Downloaded 8 times
cap00k
 
Posts: 67
Joined: Tue May 21, 2013 10:46 am
languages_spoken: english
ODROIDs: ODROID

Re: [HDMI] Sound glitch every 3 sec

Unread postby Mobilaz » Fri Nov 09, 2018 7:13 pm

Hi,

Thanks for your solution.

I tested the patch on the sine wave and it seems to be working just fine.
I will run some long term tests to be sure it works in all scenarios and I will keep you posted with the results.

Thank you very much for your help,
Mobilaz
 
Posts: 5
Joined: Tue Oct 30, 2018 8:00 pm
languages_spoken: english
ODROIDs: ODROID-C2

Re: [HDMI] Sound glitch every 3 sec

Unread postby Isard7777 » Tue Nov 13, 2018 1:44 am

Hello,

I'm working on the same project of Mobilaz. During the validation of the provided patch, I try to see if a drift between the HDMI Video clock (Vsync) and the Alsa Audio Clock (through Alsa callback) is still remained. The software we used is simple, on each Vsync, we virtualy generate 800 empty audio samples (corresponding of the number of sample needed on each video frame at 60Hz), that the alsa callback must consume.

Unfortunately the drift is still present and I calculate, without any other configuration than the provided patch, a drift of 0.236833 audio sample / second. I've also decided to use the tsync driver (/sys/class/tsync/mode) and change the mode to see if it was possible to have any benefit effect on the clocks drift but, the audio master clock give us exactly the same drift, the video master clock give us a drift of 0.2399 audio sample /second and the PCR master clock also give us a greater drift of 0.237241.

Is it normal that the provided patch does not solve the clock drift between the audio and the video from the moment where there is no more sound glitch explained by clock derivation? Is it possible to configure the odroid to have the same clock source between the Alsa callback and the Framebuffer Vsync?

Thanks.
Last edited by Isard7777 on Tue Nov 13, 2018 5:23 pm, edited 1 time in total.
Isard7777
 
Posts: 8
Joined: Fri Aug 10, 2018 5:25 pm
languages_spoken: english french
ODROIDs: C2

Re: [HDMI] Sound glitch every 3 sec

Unread postby joy » Tue Nov 13, 2018 8:46 am

Isard7777 wrote:Is it normal that the provided patch does not solve the clock drift between the audio and the video from the moment wher there is no more sound glitch explained by clock derivation?
Is it possible to configure the odroid to have the same clock source between the Alsa callback and the Framebuffer Vsync?

They don't share the same clock source.
And this commit doesn't affect framebuffer vsync or hdmi pixel clock and so on.
HDMI uses a dedicated pll block.
The commit is to synchronize data from I2S output to HDMI input.
During the process, data at a specific moment is lost.
It depends on I2S block.

And usually, Audio and HDMI use each dedicated pll blocks because various kinds of clocks must be generated.
joy
 
Posts: 571
Joined: Fri Oct 02, 2015 1:44 pm
languages_spoken: english
ODROIDs: ODROID-C1+, XU4, X


Return to Issues

Who is online

Users browsing this forum: No registered users and 2 guests