1218885Sdim/* 2218885Sdim * $Header: bsd_audioirig.h,v 1.0 93/08/02 12:42:00 3218885Sdim */ 4218885Sdim 5218885Sdim#ifndef _BSD_AUDIOIRIG_H_ 6218885Sdim#define _BSD_AUDIOIRIG_H_ 7218885Sdim 8218885Sdim#include <sys/time.h> 9218885Sdim 10218885Sdim/********************************************************************/ 11218885Sdim/* user interface */ 12218885Sdim 13218885Sdim/* 14218885Sdim * irig ioctls 15218885Sdim */ 16218885Sdim#if defined(__STDC__) || (!defined(sun) && !defined(ibm032) && !defined(__GNUC)) 17218885Sdim#define AUDIO_IRIG_OPEN _IO('A', 50) 18218885Sdim#define AUDIO_IRIG_CLOSE _IO('A', 51) 19218885Sdim#define AUDIO_IRIG_SETFORMAT _IOWR('A', 52, int) 20218885Sdim#else 21218885Sdim#define AUDIO_IRIG_OPEN _IO(A, 50) 22218885Sdim#define AUDIO_IRIG_CLOSE _IO(A, 51) 23218885Sdim#define AUDIO_IRIG_SETFORMAT _IOWR(A, 52, int) 24218885Sdim#endif 25235633Sdim 26235633Sdim/* 27235633Sdim * irig error codes 28235633Sdim */ 29235633Sdim#define AUDIO_IRIG_BADSIGNAL 0x01 30235633Sdim#define AUDIO_IRIG_BADDATA 0x02 31235633Sdim#define AUDIO_IRIG_BADSYNC 0x04 32235633Sdim#define AUDIO_IRIG_BADCLOCK 0x08 33235633Sdim#define AUDIO_IRIG_OLDDATA 0x10 34218885Sdim 35218885Sdim/********************************************************************/ 36218885Sdim 37252723Sdim/* 38235633Sdim * auib definitions 39218885Sdim */ 40218885Sdim#define AUIB_SIZE (0x0040) 41218885Sdim#define AUIB_INC (0x0008) 42218885Sdim#define AUIB_MOD(k) ((k) & 0x0038) 43218885Sdim#define AUIB_INIT(ib) ((ib)->ib_head = (ib)->ib_tail = (ib)->ib_lock = \ 44218885Sdim (ib)->phase = (ib)->shi = (ib)->slo = (ib)->high = \ 45218885Sdim (ib)->level0 = (ib)->level1 = \ 46218885Sdim (ib)->shift[0] = (ib)->shift[1] = (ib)->shift[2] = \ 47235633Sdim (ib)->shift[3] = (ib)->sdata[0] = (ib)->sdata[1] = \ 48235633Sdim (ib)->sdata[2] = (ib)->sdata[3] = (ib)->err = 0) 49235633Sdim#define AUIB_EMPTY(ib) ((ib)->ib_head == (ib)->ib_tail) 50235633Sdim#define AUIB_LEN(ib) (AUIB_MOD((ib)->ib_tail - (ib)->ib_head)) 51218885Sdim#define AUIB_LEFT(ib) (AUIB_MOD((ib)->ib_head - (ib)->ib_tail - 1)) 52218885Sdim#define IRIGDELAY 3 53218885Sdim#define IRIGLEVEL 1355 54218885Sdim 55218885Sdim#ifndef LOCORE 56/* 57 * irig_time holds IRIG data for one second 58 */ 59struct irig_time { 60 struct timeval stamp; /* timestamp */ 61 u_char bits[13]; /* 100 irig data bits */ 62 u_char status; /* status byte */ 63 char time[14]; /* time string */ 64}; 65 66/* 67 * auib's are used for IRIG data communication between the trap 68 * handler and the software interrupt. 69 */ 70struct auib { 71 /* driver variables */ 72 u_short active; /* 0=inactive, else=active */ 73 u_short format; /* time output format */ 74 struct irig_time timestr; /* time structure */ 75 char buffer[14]; /* output formation buffer */ 76 77 /* hardware interrupt variables */ 78 struct timeval tv1,tv2,tv3; /* time stamps (median filter) */ 79 int level0,level1; /* lo/hi input levels */ 80 int level; /* decision level */ 81 int high; /* recent largest sample */ 82 int sl0,sl1; /* recent sample levels */ 83 int lasts; /* last sample value */ 84 u_short scount; /* sample count */ 85 u_long eacc; /* 10-bit element accumulator */ 86 u_long ebit; /* current bit in element */ 87 u_char r_level,mmr1; /* recording level 0-255 */ 88 int shi,slo,phase; /* AGC variables */ 89 u_long err; /* error status bits */ 90 int ecount; /* count of elements this second */ 91 long shift[4]; /* shift register of pos ident */ 92 long sdata[4]; /* shift register of symbols */ 93 94 int ib_head; /* queue head */ 95 int ib_tail; /* queue tail */ 96 u_short ib_lock; /* queue head lock */ 97 u_long ib_data[AUIB_SIZE]; /* data buffer */ 98}; 99#endif 100 101#endif /* _BSD_AUDIOIRIG_H_ */ 102