phc2sys: Use reversed sysoff when synchronizing to system clock.
If synchronizing a PHC to the system clock, use one of the PTP_SYS_OFFSET ioctls (if supported) to measure the offset between the two clocks. Negate the offset and switch the timestamp before passing them to the servo. This makes the synchronization between PHC and system clock symmetric. Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
68a9011c9d
commit
8142da41b6
10
phc2sys.c
10
phc2sys.c
|
@ -790,6 +790,16 @@ static int do_loop(struct node *node, int subscriptions)
|
||||||
node->phc_readings,
|
node->phc_readings,
|
||||||
&offset, &ts, &delay) < 0)
|
&offset, &ts, &delay) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
} else if (node->master->clkid == CLOCK_REALTIME &&
|
||||||
|
clock->sysoff_method >= 0) {
|
||||||
|
/* use reversed sysoff */
|
||||||
|
if (sysoff_measure(CLOCKID_TO_FD(clock->clkid),
|
||||||
|
clock->sysoff_method,
|
||||||
|
node->phc_readings,
|
||||||
|
&offset, &ts, &delay) < 0)
|
||||||
|
return -1;
|
||||||
|
ts += offset;
|
||||||
|
offset = -offset;
|
||||||
} else {
|
} else {
|
||||||
/* use phc */
|
/* use phc */
|
||||||
if (!read_phc(node->master->clkid, clock->clkid,
|
if (!read_phc(node->master->clkid, clock->clkid,
|
||||||
|
|
Loading…
Reference in New Issue