AVB: extract audio clock from stream

Technical questions regarding the XTC tools and programming with XMOS.
andreaalbano
Member
Posts: 10
Joined: Tue May 31, 2016 3:00 pm

AVB: extract audio clock from stream

Post by andreaalbano »

Hello everyone,
we are developing and AVB <-> I2S slave application on a custom board derived from xCORE-200 Multichannel Audio platform version 2. The different thing is that the I2S interface is slave and not master.

We have modified the AN0202 example (Gigabit Ethernet AVB endpoint example using I2S master) and the application is now almost working.

What we can't figure out is how the audio clock management works:
  • in DEVICE_MEDIA_CLOCK_LOCAL_CLOCK mode we would like to syncronize the AVB communication with the I2S word clock, but it seems like that the core uses the internal clock (we are not sure).
    * Can anyone give us some hints on how the audio clock is handled on AVB library?
  • in DEVICE_MEDIA_CLOCK_INPUT_STREAM_DERIVED we would like to extract a word clock (or something similar) from the AVB stream and send it to a CS2000 (a pll/clock recovery chip) to recover it. From the reference board we thought that the PLL_SYNC signal on X0D0 (p_fs port on the example code) was what we needed, but we are not sure that it is the correct signal: from what we have understood that signal is always generated from the internal clock of the XMOS.
    * Can anyone help us to understand this?
    * In case the signal is not correct, there is a way to generate a reference clock from the AVB stream?

I'm not sure if I was clear. I can provide more information if necessary.

Many thanks in advance,
Andrea
andreaalbano
Member
Posts: 10
Joined: Tue May 31, 2016 3:00 pm

Post by andreaalbano »

I've just done some test that answered to my question:
I've connected to an oscilloscope the PLL_SYNC signal and connected the AVB port to a MAC.
  • DEVICE_MEDIA_CLOCK_INPUT_STREAM_DERIVED:
    When I use the local MAC clock as reference I can see the PLL_SYNC signal changing frequency to adapt to the MAC clock. The confusing thing was that this happen only when a signal is actually streamed to/from the MAC. When no stream is active, no synchronization is performed.
  • DEVICE_MEDIA_CLOCK_LOCAL_CLOCK :
    I've still not figured out how exactly it works, but from the code it seems like that the synchronization is performed not by a clock, but by the amount of data coming/going from/to the I2S peripheral. So the AVB should always be synchronized with the audio periferal, both in master and in slave mode.
User avatar
larry
Respected Member
Posts: 275
Joined: Fri Mar 12, 2010 6:03 pm

Post by larry »

The confusing thing was that this happen only when a signal is actually streamed to/from the MAC. When no stream is active, no synchronization is performed.
The idea behind media clock synchronisation is for listener endpoint to recover a clock by comparing presentation timestamps to timestamps when audio samples actually go out until those get close enough. XMOS endpoint runs a PI controller adjusting PLL input clock (p_fs) as its output.

In local clock mode, p_fs is tied to the chip's system clock.

As far as I know media clock recovery/synchronisation isn't specified in the published standards so implementations are free to do it any way they like. AVnu published a couple of presentations that illustrate the above concept, e.g.:

http://avnu.org/wp-content/uploads/2014 ... lfvast.pdf
User avatar
larry
Respected Member
Posts: 275
Joined: Fri Mar 12, 2010 6:03 pm

Post by larry »

andreaalbano
Member
Posts: 10
Joined: Tue May 31, 2016 3:00 pm

Post by andreaalbano »

Thank you larry,
as far as I can understand the slave can't synchronize in any way if no channel is streamed, and this can be a problem.

I think I need to study the protocol... :'(
User avatar
larry
Respected Member
Posts: 275
Joined: Fri Mar 12, 2010 6:03 pm

Post by larry »

That is correct. Listener needs a stream to lock onto. It could be an empty stream.

New 1722 standards specify a stream that has just timestamps and no audio, the Clock Reference Format (CRF). The idea is generalise AVB into TSN so it can synchronise distributed systems other than audio/video.