2020-06-29 03:02:38 +08:00
|
|
|
/**
|
|
|
|
* @file ts2phc.h
|
|
|
|
* @brief Structure definitions for ts2phc
|
|
|
|
* @note Copyright 2020 Vladimir Oltean <olteanv@gmail.com>
|
|
|
|
* @note SPDX-License-Identifier: GPL-2.0+
|
|
|
|
*/
|
|
|
|
#ifndef HAVE_TS2PHC_H
|
|
|
|
#define HAVE_TS2PHC_H
|
|
|
|
|
2020-07-28 07:51:28 +08:00
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include "servo.h"
|
|
|
|
|
2020-06-29 03:02:38 +08:00
|
|
|
struct ts2phc_slave_array;
|
|
|
|
|
2020-07-28 07:51:28 +08:00
|
|
|
#define SERVO_SYNC_INTERVAL 1.0
|
|
|
|
|
|
|
|
struct clock {
|
|
|
|
LIST_ENTRY(clock) list;
|
|
|
|
LIST_ENTRY(clock) dst_list;
|
|
|
|
clockid_t clkid;
|
|
|
|
int phc_index;
|
|
|
|
int state;
|
|
|
|
int new_state;
|
|
|
|
struct servo *servo;
|
|
|
|
enum servo_state servo_state;
|
|
|
|
char *name;
|
|
|
|
int no_adj;
|
|
|
|
int is_destination;
|
|
|
|
};
|
|
|
|
|
2020-06-29 03:02:38 +08:00
|
|
|
struct ts2phc_private {
|
|
|
|
struct ts2phc_master *master;
|
|
|
|
STAILQ_HEAD(slave_ifaces_head, ts2phc_slave) slaves;
|
|
|
|
unsigned int n_slaves;
|
|
|
|
struct ts2phc_slave_array *polling_array;
|
|
|
|
struct config *cfg;
|
2020-07-28 07:51:28 +08:00
|
|
|
struct clock *source;
|
|
|
|
LIST_HEAD(clock_head, clock) clocks;
|
2020-06-29 03:02:38 +08:00
|
|
|
};
|
|
|
|
|
2020-07-28 07:51:28 +08:00
|
|
|
struct servo *servo_add(struct ts2phc_private *priv, struct clock *clock);
|
|
|
|
struct clock *clock_add(struct ts2phc_private *priv, const char *device);
|
|
|
|
void clock_add_tstamp(struct clock *clock, struct timespec ts);
|
|
|
|
void clock_destroy(struct clock *clock);
|
|
|
|
|
2020-06-29 03:02:38 +08:00
|
|
|
#include "ts2phc_master.h"
|
|
|
|
#include "ts2phc_slave.h"
|
|
|
|
|
|
|
|
#endif
|