#ifndef _BSD_AUDIOIRIG_H_
#define _BSD_AUDIOIRIG_H_
#include <sys/time.h>
#if defined(__STDC__) || (!defined(sun) && !defined(ibm032) && !defined(__GNUC))
#define AUDIO_IRIG_OPEN _IO('A', 50)
#define AUDIO_IRIG_CLOSE _IO('A', 51)
#define AUDIO_IRIG_SETFORMAT _IOWR('A', 52, int)
#else
#define AUDIO_IRIG_OPEN _IO(A, 50)
#define AUDIO_IRIG_CLOSE _IO(A, 51)
#define AUDIO_IRIG_SETFORMAT _IOWR(A, 52, int)
#endif
#define AUDIO_IRIG_BADSIGNAL 0x01
#define AUDIO_IRIG_BADDATA 0x02
#define AUDIO_IRIG_BADSYNC 0x04
#define AUDIO_IRIG_BADCLOCK 0x08
#define AUDIO_IRIG_OLDDATA 0x10
#define AUIB_SIZE (0x0040)
#define AUIB_INC (0x0008)
#define AUIB_MOD(k) ((k) & 0x0038)
#define AUIB_INIT(ib) ((ib)->ib_head = (ib)->ib_tail = (ib)->ib_lock = \
(ib)->phase = (ib)->shi = (ib)->slo = (ib)->high = \
(ib)->level0 = (ib)->level1 = \
(ib)->shift[0] = (ib)->shift[1] = (ib)->shift[2] = \
(ib)->shift[3] = (ib)->sdata[0] = (ib)->sdata[1] = \
(ib)->sdata[2] = (ib)->sdata[3] = (ib)->err = 0)
#define AUIB_EMPTY(ib) ((ib)->ib_head == (ib)->ib_tail)
#define AUIB_LEN(ib) (AUIB_MOD((ib)->ib_tail - (ib)->ib_head))
#define AUIB_LEFT(ib) (AUIB_MOD((ib)->ib_head - (ib)->ib_tail - 1))
#define IRIGDELAY 3
#define IRIGLEVEL 1355
#ifndef LOCORE
struct irig_time {
struct timeval stamp;
u_char bits[13];
u_char status;
char time[14];
};
struct auib {
u_short active;
u_short format;
struct irig_time timestr;
char buffer[14];
struct timeval tv1,tv2,tv3;
int level0,level1;
int level;
int high;
int sl0,sl1;
int lasts;
u_short scount;
u_long eacc;
u_long ebit;
u_char r_level,mmr1;
int shi,slo,phase;
u_long err;
int ecount;
long shift[4];
long sdata[4];
int ib_head;
int ib_tail;
u_short ib_lock;
u_long ib_data[AUIB_SIZE];
};
#endif
#endif