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. > 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. 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. HTH, Richard _______________________________________________ Linuxptp-users mailing list Linuxptp-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-users