18 #ifndef _SYS_TIMEPPS_H_
19 #define _SYS_TIMEPPS_H_
24 #include <sys/ioctl.h>
25 #include <linux/types.h>
26 #include <linux/pps.h>
40 struct timespec
tspec;
67 #define assert_timestamp assert_tu.tspec
68 #define clear_timestamp clear_tu.tspec
70 #define assert_timestamp_ntpfp assert_tu.ntpfp
71 #define clear_timestamp_ntpfp clear_tu.ntpfp
73 #define assert_offset assert_off_tu.tspec
74 #define clear_offset clear_off_tu.tspec
76 #define assert_offset_ntpfp assert_off_tu.ntpfp
77 #define clear_offset_ntpfp clear_off_tu.ntpfp
83 static __inline
int time_pps_create(
int source,
pps_handle_t *handle)
86 struct pps_kparams dummy;
96 ret = ioctl(source, PPS_GETPARAMS, &dummy);
110 static __inline
int time_pps_destroy(
pps_handle_t handle)
112 return close(handle);
115 static __inline
int time_pps_getparams(
pps_handle_t handle,
119 struct pps_kparams __ppsparams;
121 ret = ioctl(handle, PPS_GETPARAMS, &__ppsparams);
124 ppsparams->
mode = __ppsparams.mode;
133 static __inline
int time_pps_setparams(
pps_handle_t handle,
136 struct pps_kparams __ppsparams;
139 __ppsparams.mode = ppsparams->
mode;
145 return ioctl(handle, PPS_SETPARAMS, &__ppsparams);
149 static __inline
int time_pps_getcap(
pps_handle_t handle,
int *mode)
151 return ioctl(handle, PPS_GETCAP, mode);
154 static __inline
int time_pps_fetch(
pps_handle_t handle,
const int tsformat,
156 const struct timespec *timeout)
158 struct pps_fdata __fdata;
162 if (tsformat != PPS_TSFMT_TSPEC) {
168 __fdata.timeout.sec = timeout->tv_sec;
169 __fdata.timeout.nsec = timeout->tv_nsec;
170 __fdata.timeout.flags = ~PPS_TIME_INVALID;
172 __fdata.timeout.flags = PPS_TIME_INVALID;
174 ret = ioctl(handle, PPS_FETCH, &__fdata);
179 ppsinfobuf->
assert_tu.
tspec.tv_nsec = __fdata.info.assert_tu.nsec;
180 ppsinfobuf->
clear_tu.
tspec.tv_sec = __fdata.info.clear_tu.sec;
181 ppsinfobuf->
clear_tu.
tspec.tv_nsec = __fdata.info.clear_tu.nsec;
189 static __inline
int time_pps_kcbind(
pps_handle_t handle,
190 const int kernel_consumer,
191 const int edge,
const int tsformat)
193 struct pps_bind_args __bind_args;
195 __bind_args.tsformat = tsformat;
196 __bind_args.edge = edge;
197 __bind_args.consumer = kernel_consumer;
199 return ioctl(handle, PPS_KC_BIND, &__bind_args);
204 static __inline
int time_pps_kcbind(
pps_handle_t handle,
205 const int kernel_consumer,
206 const int edge,
const int tsformat)