154359Sroberto/* 254359Sroberto * $Header: bsd_audioirig.h,v 1.0 93/08/02 12:42:00 354359Sroberto */ 454359Sroberto 554359Sroberto#ifndef _BSD_AUDIOIRIG_H_ 654359Sroberto#define _BSD_AUDIOIRIG_H_ 754359Sroberto 854359Sroberto#include <sys/time.h> 954359Sroberto 1054359Sroberto/********************************************************************/ 1154359Sroberto/* user interface */ 1254359Sroberto 1354359Sroberto/* 1454359Sroberto * irig ioctls 1554359Sroberto */ 1654359Sroberto#if defined(__STDC__) || (!defined(sun) && !defined(ibm032) && !defined(__GNUC)) 1754359Sroberto#define AUDIO_IRIG_OPEN _IO('A', 50) 1854359Sroberto#define AUDIO_IRIG_CLOSE _IO('A', 51) 1954359Sroberto#define AUDIO_IRIG_SETFORMAT _IOWR('A', 52, int) 2054359Sroberto#else 2154359Sroberto#define AUDIO_IRIG_OPEN _IO(A, 50) 2254359Sroberto#define AUDIO_IRIG_CLOSE _IO(A, 51) 2354359Sroberto#define AUDIO_IRIG_SETFORMAT _IOWR(A, 52, int) 2454359Sroberto#endif 2554359Sroberto 2654359Sroberto/* 2754359Sroberto * irig error codes 2854359Sroberto */ 2954359Sroberto#define AUDIO_IRIG_BADSIGNAL 0x01 3054359Sroberto#define AUDIO_IRIG_BADDATA 0x02 3154359Sroberto#define AUDIO_IRIG_BADSYNC 0x04 3254359Sroberto#define AUDIO_IRIG_BADCLOCK 0x08 3354359Sroberto#define AUDIO_IRIG_OLDDATA 0x10 3454359Sroberto 3554359Sroberto/********************************************************************/ 3654359Sroberto 3754359Sroberto/* 3854359Sroberto * auib definitions 3954359Sroberto */ 4054359Sroberto#define AUIB_SIZE (0x0040) 4154359Sroberto#define AUIB_INC (0x0008) 4254359Sroberto#define AUIB_MOD(k) ((k) & 0x0038) 4354359Sroberto#define AUIB_INIT(ib) ((ib)->ib_head = (ib)->ib_tail = (ib)->ib_lock = \ 4454359Sroberto (ib)->phase = (ib)->shi = (ib)->slo = (ib)->high = \ 4554359Sroberto (ib)->level0 = (ib)->level1 = \ 4654359Sroberto (ib)->shift[0] = (ib)->shift[1] = (ib)->shift[2] = \ 4754359Sroberto (ib)->shift[3] = (ib)->sdata[0] = (ib)->sdata[1] = \ 4854359Sroberto (ib)->sdata[2] = (ib)->sdata[3] = (ib)->err = 0) 4954359Sroberto#define AUIB_EMPTY(ib) ((ib)->ib_head == (ib)->ib_tail) 5054359Sroberto#define AUIB_LEN(ib) (AUIB_MOD((ib)->ib_tail - (ib)->ib_head)) 5154359Sroberto#define AUIB_LEFT(ib) (AUIB_MOD((ib)->ib_head - (ib)->ib_tail - 1)) 5254359Sroberto#define IRIGDELAY 3 5354359Sroberto#define IRIGLEVEL 1355 5454359Sroberto 5554359Sroberto#ifndef LOCORE 5654359Sroberto/* 5754359Sroberto * irig_time holds IRIG data for one second 5854359Sroberto */ 5954359Srobertostruct irig_time { 6054359Sroberto struct timeval stamp; /* timestamp */ 6154359Sroberto u_char bits[13]; /* 100 irig data bits */ 6254359Sroberto u_char status; /* status byte */ 6354359Sroberto char time[14]; /* time string */ 6454359Sroberto}; 6554359Sroberto 6654359Sroberto/* 6754359Sroberto * auib's are used for IRIG data communication between the trap 6854359Sroberto * handler and the software interrupt. 6954359Sroberto */ 7054359Srobertostruct auib { 7154359Sroberto /* driver variables */ 7254359Sroberto u_short active; /* 0=inactive, else=active */ 7354359Sroberto u_short format; /* time output format */ 7454359Sroberto struct irig_time timestr; /* time structure */ 7554359Sroberto char buffer[14]; /* output formation buffer */ 7654359Sroberto 7754359Sroberto /* hardware interrupt variables */ 7854359Sroberto struct timeval tv1,tv2,tv3; /* time stamps (median filter) */ 7954359Sroberto int level0,level1; /* lo/hi input levels */ 8054359Sroberto int level; /* decision level */ 8154359Sroberto int high; /* recent largest sample */ 8254359Sroberto int sl0,sl1; /* recent sample levels */ 8354359Sroberto int lasts; /* last sample value */ 8454359Sroberto u_short scount; /* sample count */ 8554359Sroberto u_long eacc; /* 10-bit element accumulator */ 8654359Sroberto u_long ebit; /* current bit in element */ 8754359Sroberto u_char r_level,mmr1; /* recording level 0-255 */ 8854359Sroberto int shi,slo,phase; /* AGC variables */ 8954359Sroberto u_long err; /* error status bits */ 9054359Sroberto int ecount; /* count of elements this second */ 9154359Sroberto long shift[4]; /* shift register of pos ident */ 9254359Sroberto long sdata[4]; /* shift register of symbols */ 9354359Sroberto 9454359Sroberto int ib_head; /* queue head */ 9554359Sroberto int ib_tail; /* queue tail */ 9654359Sroberto u_short ib_lock; /* queue head lock */ 9754359Sroberto u_long ib_data[AUIB_SIZE]; /* data buffer */ 9854359Sroberto}; 9954359Sroberto#endif 10054359Sroberto 10154359Sroberto#endif /* _BSD_AUDIOIRIG_H_ */ 102