On 15/01/2021 22.32, Richard Cochran wrote:
On Fri, Jan 15, 2021 at 06:33:04PM +0100, Juergen Werner wrote:
I thought about using the PHC directly, but as I understand the time
retrieval is contraint by bus speed and jitter, which is bad for low
latency media streaming synchronization. Using phc2sys mitigates these
constraints through algorithms I cannot even begin to understand and the
clock retrieval from CLOCK_REALTIME is incredibly fast.

This is a highly optimized code path.  The kernel maps a VDSO (dynamic
shared object) that shares time keeping variables into the application
address space.

See 'man 7 vdso' for an introduction.

Interesting tidbit.

So my question would be: Is there a way to use the synchronization
algorithms of phc2sys for a "virtual" clock either in shared memory
through a daemon process (maybe even phc2sys itself) or inside my
application. So I can have fast, stable read outs of the PTP clock,
while keeping the system clock PTP independent?

You can let ptp4l run with --free_running=1 and synchronize it to your
system's CLOCK_REALTIME using phc2sys.

Then monitor TIME_STATUS_NP to obtain data points of the local and the
remote clocks.  Those let you figure the relationship between the time
server and CLOCK_REALTIME.  Assuming you know the relationship between
your media clock and CLOCK_REALTIME, you can also figure how the
relationship between the remote time server and your media clock.

This approach sounds reasonable. Do I need to reimplement the 'GET
TIME_STATUS_NP' query or is there a library I could use from my C code?
Using pmc and parsing the output seems like a lot of overhead, which
could distort the measurement again.

There are even better ways if you have the right hardware setup.  For
example, you can let ptp4l synchronize the PHC to the arbitrary remote
time and then feed a 10 KHz output (for example) from the PHC into a
PLL that provides the media clock.

Interesting. I have to check if that is possible on my SOC (i.MX8MM).
But I would still have to recover the absolute PTP time, since I want to
play out the streams on multiple devices in sync.

HTH,
Richard


Thank you for the insight!
j


_______________________________________________
Linuxptp-users mailing list
Linuxptp-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-users

Reply via email to