Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


pps.h
001: /*
002:  * PPS API header
003:  *
004:  * Copyright (C) 2005-2009   Rodolfo Giometti <giometti@linux.it>
005:  *
006:  *   This program is free software; you can redistribute it and/or modify
007:  *   it under the terms of the GNU General Public License as published by
008:  *   the Free Software Foundation; either version 2 of the License, or
009:  *   (at your option) any later version.
010:  *
011:  *   This program is distributed in the hope that it will be useful,
012:  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
013:  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:  *   GNU General Public License for more details.
015:  *
016:  *   You should have received a copy of the GNU General Public License
017:  *   along with this program; if not, write to the Free Software
018:  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
019:  */
020: 
021: 
022: #ifndef _PPS_H_
023: #define _PPS_H_
024: 
025: #include <linux/types.h>
026: 
027: #define PPS_VERSION             "5.3.6"
028: #define PPS_MAX_SOURCES         16              /* should be enough... */
029: 
030: /* Implementation note: the logical states ``assert'' and ``clear''
031:  * are implemented in terms of the chip register, i.e. ``assert''
032:  * means the bit is set.  */
033: 
034: /*
035:  * 3.2 New data structures
036:  */
037: 
038: #define PPS_API_VERS_1          1
039: #define PPS_API_VERS            PPS_API_VERS_1  /* we use API version 1 */
040: #define PPS_MAX_NAME_LEN        32
041: 
042: /* 32-bit vs. 64-bit compatibility.
043:  *
044:  * 0n i386, the alignment of a uint64_t is only 4 bytes, while on most other
045:  * architectures it's 8 bytes. On i386, there will be no padding between the
046:  * two consecutive 'struct pps_ktime' members of struct pps_kinfo and struct
047:  * pps_kparams. But on most platforms there will be padding to ensure correct
048:  * alignment.
049:  *
050:  * The simple fix is probably to add an explicit padding.
051:  *                                                      [David Woodhouse]
052:  */
053: struct pps_ktime {
054:         __s64 sec;
055:         __s32 nsec;
056:         __u32 flags;
057: };
058: #define PPS_TIME_INVALID        (1<<0)  /* used to specify timeout==NULL */
059: 
060: struct pps_kinfo {
061:         __u32 assert_sequence;          /* seq. num. of assert event */
062:         __u32 clear_sequence;           /* seq. num. of clear event */
063:         struct pps_ktime assert_tu;     /* time of assert event */
064:         struct pps_ktime clear_tu;      /* time of clear event */
065:         int current_mode;               /* current mode bits */
066: };
067: 
068: struct pps_kparams {
069:         int api_version;                /* API version # */
070:         int mode;                       /* mode bits */
071:         struct pps_ktime assert_off_tu; /* offset compensation for assert */
072:         struct pps_ktime clear_off_tu;  /* offset compensation for clear */
073: };
074: 
075: /*
076:  * 3.3 Mode bit definitions
077:  */
078: 
079: /* Device/implementation parameters */
080: #define PPS_CAPTUREASSERT       0x01    /* capture assert events */
081: #define PPS_CAPTURECLEAR        0x02    /* capture clear events */
082: #define PPS_CAPTUREBOTH         0x03    /* capture assert and clear events */
083: 
084: #define PPS_OFFSETASSERT        0x10    /* apply compensation for assert ev. */
085: #define PPS_OFFSETCLEAR         0x20    /* apply compensation for clear ev. */
086: 
087: #define PPS_CANWAIT             0x100   /* can we wait for an event? */
088: #define PPS_CANPOLL             0x200   /* bit reserved for future use */
089: 
090: /* Kernel actions */
091: #define PPS_ECHOASSERT          0x40    /* feed back assert event to output */
092: #define PPS_ECHOCLEAR           0x80    /* feed back clear event to output */
093: 
094: /* Timestamp formats */
095: #define PPS_TSFMT_TSPEC         0x1000  /* select timespec format */
096: #define PPS_TSFMT_NTPFP         0x2000  /* select NTP format */
097: 
098: /*
099:  * 3.4.4 New functions: disciplining the kernel timebase
100:  */
101: 
102: /* Kernel consumers */
103: #define PPS_KC_HARDPPS          0       /* hardpps() (or equivalent) */
104: #define PPS_KC_HARDPPS_PLL      1       /* hardpps() constrained to
105:                                            use a phase-locked loop */
106: #define PPS_KC_HARDPPS_FLL      2       /* hardpps() constrained to
107:                                            use a frequency-locked loop */
108: /*
109:  * Here begins the implementation-specific part!
110:  */
111: 
112: struct pps_fdata {
113:         struct pps_kinfo info;
114:         struct pps_ktime timeout;
115: };
116: 
117: struct pps_bind_args {
118:         int tsformat;   /* format of time stamps */
119:         int edge;       /* selected event type */
120:         int consumer;   /* selected kernel consumer */
121: };
122: 
123: #include <linux/ioctl.h>
124: 
125: #define PPS_GETPARAMS           _IOR('p', 0xa1, struct pps_kparams *)
126: #define PPS_SETPARAMS           _IOW('p', 0xa2, struct pps_kparams *)
127: #define PPS_GETCAP              _IOR('p', 0xa3, int *)
128: #define PPS_FETCH               _IOWR('p', 0xa4, struct pps_fdata *)
129: #define PPS_KC_BIND             _IOW('p', 0xa5, struct pps_bind_args *)
130: 
131: #endif /* _PPS_H_ */
132: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/