/contrib/ntp/kernel/sys/bsd_audioirig.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 101 lines · 65 code · 12 blank · 24 comment · 4 complexity · 919d0329f6372485a637c327f95b9efc MD5 · raw file

  1. /*
  2. * $Header: bsd_audioirig.h,v 1.0 93/08/02 12:42:00
  3. */
  4. #ifndef _BSD_AUDIOIRIG_H_
  5. #define _BSD_AUDIOIRIG_H_
  6. #include <sys/time.h>
  7. /********************************************************************/
  8. /* user interface */
  9. /*
  10. * irig ioctls
  11. */
  12. #if defined(__STDC__) || (!defined(sun) && !defined(ibm032) && !defined(__GNUC))
  13. #define AUDIO_IRIG_OPEN _IO('A', 50)
  14. #define AUDIO_IRIG_CLOSE _IO('A', 51)
  15. #define AUDIO_IRIG_SETFORMAT _IOWR('A', 52, int)
  16. #else
  17. #define AUDIO_IRIG_OPEN _IO(A, 50)
  18. #define AUDIO_IRIG_CLOSE _IO(A, 51)
  19. #define AUDIO_IRIG_SETFORMAT _IOWR(A, 52, int)
  20. #endif
  21. /*
  22. * irig error codes
  23. */
  24. #define AUDIO_IRIG_BADSIGNAL 0x01
  25. #define AUDIO_IRIG_BADDATA 0x02
  26. #define AUDIO_IRIG_BADSYNC 0x04
  27. #define AUDIO_IRIG_BADCLOCK 0x08
  28. #define AUDIO_IRIG_OLDDATA 0x10
  29. /********************************************************************/
  30. /*
  31. * auib definitions
  32. */
  33. #define AUIB_SIZE (0x0040)
  34. #define AUIB_INC (0x0008)
  35. #define AUIB_MOD(k) ((k) & 0x0038)
  36. #define AUIB_INIT(ib) ((ib)->ib_head = (ib)->ib_tail = (ib)->ib_lock = \
  37. (ib)->phase = (ib)->shi = (ib)->slo = (ib)->high = \
  38. (ib)->level0 = (ib)->level1 = \
  39. (ib)->shift[0] = (ib)->shift[1] = (ib)->shift[2] = \
  40. (ib)->shift[3] = (ib)->sdata[0] = (ib)->sdata[1] = \
  41. (ib)->sdata[2] = (ib)->sdata[3] = (ib)->err = 0)
  42. #define AUIB_EMPTY(ib) ((ib)->ib_head == (ib)->ib_tail)
  43. #define AUIB_LEN(ib) (AUIB_MOD((ib)->ib_tail - (ib)->ib_head))
  44. #define AUIB_LEFT(ib) (AUIB_MOD((ib)->ib_head - (ib)->ib_tail - 1))
  45. #define IRIGDELAY 3
  46. #define IRIGLEVEL 1355
  47. #ifndef LOCORE
  48. /*
  49. * irig_time holds IRIG data for one second
  50. */
  51. struct irig_time {
  52. struct timeval stamp; /* timestamp */
  53. u_char bits[13]; /* 100 irig data bits */
  54. u_char status; /* status byte */
  55. char time[14]; /* time string */
  56. };
  57. /*
  58. * auib's are used for IRIG data communication between the trap
  59. * handler and the software interrupt.
  60. */
  61. struct auib {
  62. /* driver variables */
  63. u_short active; /* 0=inactive, else=active */
  64. u_short format; /* time output format */
  65. struct irig_time timestr; /* time structure */
  66. char buffer[14]; /* output formation buffer */
  67. /* hardware interrupt variables */
  68. struct timeval tv1,tv2,tv3; /* time stamps (median filter) */
  69. int level0,level1; /* lo/hi input levels */
  70. int level; /* decision level */
  71. int high; /* recent largest sample */
  72. int sl0,sl1; /* recent sample levels */
  73. int lasts; /* last sample value */
  74. u_short scount; /* sample count */
  75. u_long eacc; /* 10-bit element accumulator */
  76. u_long ebit; /* current bit in element */
  77. u_char r_level,mmr1; /* recording level 0-255 */
  78. int shi,slo,phase; /* AGC variables */
  79. u_long err; /* error status bits */
  80. int ecount; /* count of elements this second */
  81. long shift[4]; /* shift register of pos ident */
  82. long sdata[4]; /* shift register of symbols */
  83. int ib_head; /* queue head */
  84. int ib_tail; /* queue tail */
  85. u_short ib_lock; /* queue head lock */
  86. u_long ib_data[AUIB_SIZE]; /* data buffer */
  87. };
  88. #endif
  89. #endif /* _BSD_AUDIOIRIG_H_ */