user.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  1. /*
  2. * DAHDI Telephony Interface
  3. *
  4. * Written by Mark Spencer <markster@digium.com>
  5. * Based on previous works, designs, and architectures conceived and
  6. * written by Jim Dixon <jim@lambdatel.com>.
  7. *
  8. * Copyright (C) 2001 Jim Dixon / Zapata Telephony.
  9. * Copyright (C) 2001 - 2008 Digium, Inc.
  10. *
  11. * All rights reserved.
  12. *
  13. */
  14. /*
  15. * See http://www.asterisk.org for more information about
  16. * the Asterisk project. Please do not directly contact
  17. * any of the maintainers of this project for assistance;
  18. * the project provides a web site, mailing lists and IRC
  19. * channels for your use.
  20. *
  21. * This program is free software, distributed under the terms of
  22. * the GNU Lesser General Public License Version 2.1 as published
  23. * by the Free Software Foundation. See the LICENSE.LGPL file
  24. * included with this program for more details.
  25. *
  26. * In addition, when this program is distributed with Asterisk in
  27. * any form that would qualify as a 'combined work' or as a
  28. * 'derivative work' (but not mere aggregation), you can redistribute
  29. * and/or modify the combination under the terms of the license
  30. * provided with that copy of Asterisk, instead of the license
  31. * terms granted here.
  32. */
  33. #ifndef _DAHDI_USER_H
  34. #define _DAHDI_USER_H
  35. #include <linux/types.h>
  36. #include <linux/ioctl.h>
  37. #include <dahdi/dahdi_config.h>
  38. #ifndef ELAST
  39. #define ELAST 500
  40. #endif
  41. /* Per-span configuration values */
  42. #define DAHDI_CONFIG_TXLEVEL 7 /* bits 0-2 are tx level */
  43. /* Line configuration */
  44. /* These apply to T1 */
  45. #define DAHDI_CONFIG_D4 (1 << 4)
  46. #define DAHDI_CONFIG_ESF (1 << 5)
  47. #define DAHDI_CONFIG_AMI (1 << 6)
  48. #define DAHDI_CONFIG_B8ZS (1 << 7)
  49. /* These apply to E1 */
  50. #define DAHDI_CONFIG_CCS (1 << 8) /* CCS (ISDN) instead of CAS (Robbed Bit) */
  51. #define DAHDI_CONFIG_HDB3 (1 << 9) /* HDB3 instead of AMI (line coding) */
  52. #define DAHDI_CONFIG_CRC4 (1 << 10) /* CRC4 framing */
  53. #define DAHDI_CONFIG_NOTOPEN (1 << 16)
  54. /* These apply to BRI */
  55. #define DAHDI_CONFIG_NTTE (1 << 11) /* To enable NT mode, set this bit to 1, for TE this should be 0 */
  56. #define DAHDI_CONFIG_TERM (1 << 12) /* To enable Termination resistance set this bit to 1 */
  57. /* Signalling types */
  58. #define DAHDI_SIG_BROKEN (1 << 31) /* The port is broken and/or failed initialization */
  59. #define __DAHDI_SIG_FXO (1 << 12) /* Never use directly */
  60. #define __DAHDI_SIG_FXS (1 << 13) /* Never use directly */
  61. #define DAHDI_SIG_NONE (0) /* Channel not configured */
  62. #define DAHDI_SIG_FXSLS ((1 << 0) | __DAHDI_SIG_FXS) /* FXS, Loopstart */
  63. #define DAHDI_SIG_FXSGS ((1 << 1) | __DAHDI_SIG_FXS) /* FXS, Groundstart */
  64. #define DAHDI_SIG_FXSKS ((1 << 2) | __DAHDI_SIG_FXS) /* FXS, Kewlstart */
  65. #define DAHDI_SIG_FXOLS ((1 << 3) | __DAHDI_SIG_FXO) /* FXO, Loopstart */
  66. #define DAHDI_SIG_FXOGS ((1 << 4) | __DAHDI_SIG_FXO) /* FXO, Groupstart */
  67. #define DAHDI_SIG_FXOKS ((1 << 5) | __DAHDI_SIG_FXO) /* FXO, Kewlstart */
  68. #define DAHDI_SIG_EM (1 << 6) /* Ear & Mouth (E&M) */
  69. /* The following are all variations on clear channel */
  70. #define __DAHDI_SIG_DACS (1 << 16)
  71. #define DAHDI_SIG_CLEAR (1 << 7) /* Clear channel */
  72. #define DAHDI_SIG_HDLCRAW ((1 << 8) | DAHDI_SIG_CLEAR) /* Raw unchecked HDLC */
  73. #define DAHDI_SIG_HDLCFCS ((1 << 9) | DAHDI_SIG_HDLCRAW) /* HDLC with FCS calculation */
  74. #define DAHDI_SIG_HDLCNET ((1 << 10) | DAHDI_SIG_HDLCFCS) /* HDLC Network */
  75. #define DAHDI_SIG_SLAVE (1 << 11) /* Slave to another channel */
  76. #define DAHDI_SIG_SF (1 << 14) /* Single Freq. tone only, no sig bits */
  77. #define DAHDI_SIG_CAS (1 << 15) /* Just get bits */
  78. #define DAHDI_SIG_DACS (__DAHDI_SIG_DACS | DAHDI_SIG_CLEAR) /* Cross connect */
  79. #define DAHDI_SIG_EM_E1 (1 << 17) /* E1 E&M Variation */
  80. #define DAHDI_SIG_DACS_RBS ((1 << 18) | __DAHDI_SIG_DACS) /* Cross connect w/ RBS */
  81. #define DAHDI_SIG_HARDHDLC ((1 << 19) | DAHDI_SIG_CLEAR)
  82. #define DAHDI_SIG_MTP2 ((1 << 20) | DAHDI_SIG_HDLCFCS) /* MTP2 support Need HDLC bitstuff and FCS calcuation too */
  83. /* tone flag values */
  84. #define DAHDI_REVERSE_RXTONE 1 /* reverse polarity rx tone logic */
  85. #define DAHDI_REVERSE_TXTONE 2 /* reverse polarity tx tone logic */
  86. #define DAHDI_ABIT (1 << 3)
  87. #define DAHDI_BBIT (1 << 2)
  88. #define DAHDI_CBIT (1 << 1)
  89. #define DAHDI_DBIT (1 << 0)
  90. #define DAHDI_BITS_ABCD (DAHDI_ABIT | DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT)
  91. #define DAHDI_BITS_ABD (DAHDI_ABIT | DAHDI_BBIT | DAHDI_DBIT)
  92. #define DAHDI_BITS_ACD (DAHDI_ABIT | DAHDI_CBIT | DAHDI_DBIT)
  93. #define DAHDI_BITS_BCD (DAHDI_BBIT | DAHDI_CBIT | DAHDI_DBIT)
  94. #define DAHDI_BITS_AC (DAHDI_ABIT | DAHDI_CBIT)
  95. #define DAHDI_BITS_BD (DAHDI_BBIT | DAHDI_DBIT)
  96. #define DAHDI_MAJOR 196
  97. #define DAHDI_MAX_BLOCKSIZE 8192
  98. #define DAHDI_DEFAULT_NUM_BUFS 2
  99. #define DAHDI_MAX_NUM_BUFS 32
  100. #define DAHDI_MAX_BUF_SPACE 32768
  101. #define DAHDI_DEFAULT_BLOCKSIZE 1024
  102. #define DAHDI_DEFAULT_MTR_MRU 2048
  103. /*! Define the default network block size */
  104. #define DAHDI_DEFAULT_MTU_MRU 2048
  105. #define DAHDI_POLICY_IMMEDIATE 0 /* Start play/record immediately */
  106. #define DAHDI_POLICY_WHEN_FULL 1 /* Start play/record when buffer is full */
  107. #define DAHDI_POLICY_HALF_FULL 2 /* Start play/record when buffer is half full.
  108. Note -- This policy only works on tx buffers */
  109. #define DAHDI_GET_PARAMS_RETURN_MASTER 0x40000000
  110. #define DAHDI_TONE_ZONE_MAX 128
  111. #define DAHDI_TONE_ZONE_DEFAULT -1 /* To restore default */
  112. #define DAHDI_TONE_STOP -1
  113. #define DAHDI_TONE_DIALTONE 0
  114. #define DAHDI_TONE_BUSY 1
  115. #define DAHDI_TONE_RINGTONE 2
  116. #define DAHDI_TONE_CONGESTION 3
  117. #define DAHDI_TONE_CALLWAIT 4
  118. #define DAHDI_TONE_DIALRECALL 5
  119. #define DAHDI_TONE_RECORDTONE 6
  120. #define DAHDI_TONE_INFO 7
  121. #define DAHDI_TONE_CUST1 8
  122. #define DAHDI_TONE_CUST2 9
  123. #define DAHDI_TONE_STUTTER 10
  124. #define DAHDI_TONE_MAX 16
  125. #define DAHDI_TONE_DTMF_BASE 64
  126. #define DAHDI_TONE_MFR1_BASE 80
  127. #define DAHDI_TONE_MFR2_FWD_BASE 96
  128. #define DAHDI_TONE_MFR2_REV_BASE 112
  129. enum {
  130. DAHDI_TONE_DTMF_0 = DAHDI_TONE_DTMF_BASE,
  131. DAHDI_TONE_DTMF_1,
  132. DAHDI_TONE_DTMF_2,
  133. DAHDI_TONE_DTMF_3,
  134. DAHDI_TONE_DTMF_4,
  135. DAHDI_TONE_DTMF_5,
  136. DAHDI_TONE_DTMF_6,
  137. DAHDI_TONE_DTMF_7,
  138. DAHDI_TONE_DTMF_8,
  139. DAHDI_TONE_DTMF_9,
  140. DAHDI_TONE_DTMF_s,
  141. DAHDI_TONE_DTMF_p,
  142. DAHDI_TONE_DTMF_A,
  143. DAHDI_TONE_DTMF_B,
  144. DAHDI_TONE_DTMF_C,
  145. DAHDI_TONE_DTMF_D
  146. };
  147. #define DAHDI_TONE_DTMF_MAX DAHDI_TONE_DTMF_D
  148. enum {
  149. DAHDI_TONE_MFR1_0 = DAHDI_TONE_MFR1_BASE,
  150. DAHDI_TONE_MFR1_1,
  151. DAHDI_TONE_MFR1_2,
  152. DAHDI_TONE_MFR1_3,
  153. DAHDI_TONE_MFR1_4,
  154. DAHDI_TONE_MFR1_5,
  155. DAHDI_TONE_MFR1_6,
  156. DAHDI_TONE_MFR1_7,
  157. DAHDI_TONE_MFR1_8,
  158. DAHDI_TONE_MFR1_9,
  159. DAHDI_TONE_MFR1_KP,
  160. DAHDI_TONE_MFR1_ST,
  161. DAHDI_TONE_MFR1_STP,
  162. DAHDI_TONE_MFR1_ST2P,
  163. DAHDI_TONE_MFR1_ST3P,
  164. };
  165. #define DAHDI_TONE_MFR1_MAX DAHDI_TONE_MFR1_ST3P
  166. enum {
  167. DAHDI_TONE_MFR2_FWD_1 = DAHDI_TONE_MFR2_FWD_BASE,
  168. DAHDI_TONE_MFR2_FWD_2,
  169. DAHDI_TONE_MFR2_FWD_3,
  170. DAHDI_TONE_MFR2_FWD_4,
  171. DAHDI_TONE_MFR2_FWD_5,
  172. DAHDI_TONE_MFR2_FWD_6,
  173. DAHDI_TONE_MFR2_FWD_7,
  174. DAHDI_TONE_MFR2_FWD_8,
  175. DAHDI_TONE_MFR2_FWD_9,
  176. DAHDI_TONE_MFR2_FWD_10,
  177. DAHDI_TONE_MFR2_FWD_11,
  178. DAHDI_TONE_MFR2_FWD_12,
  179. DAHDI_TONE_MFR2_FWD_13,
  180. DAHDI_TONE_MFR2_FWD_14,
  181. DAHDI_TONE_MFR2_FWD_15,
  182. };
  183. #define DAHDI_TONE_MFR2_FWD_MAX DAHDI_TONE_MFR2_FWD_15
  184. enum {
  185. DAHDI_TONE_MFR2_REV_1 = DAHDI_TONE_MFR2_REV_BASE,
  186. DAHDI_TONE_MFR2_REV_2,
  187. DAHDI_TONE_MFR2_REV_3,
  188. DAHDI_TONE_MFR2_REV_4,
  189. DAHDI_TONE_MFR2_REV_5,
  190. DAHDI_TONE_MFR2_REV_6,
  191. DAHDI_TONE_MFR2_REV_7,
  192. DAHDI_TONE_MFR2_REV_8,
  193. DAHDI_TONE_MFR2_REV_9,
  194. DAHDI_TONE_MFR2_REV_10,
  195. DAHDI_TONE_MFR2_REV_11,
  196. DAHDI_TONE_MFR2_REV_12,
  197. DAHDI_TONE_MFR2_REV_13,
  198. DAHDI_TONE_MFR2_REV_14,
  199. DAHDI_TONE_MFR2_REV_15,
  200. };
  201. #define DAHDI_TONE_MFR2_REV_MAX DAHDI_TONE_MFR2_REV_15
  202. #define DAHDI_LAW_DEFAULT 0 /* Default law for span */
  203. #define DAHDI_LAW_MULAW 1 /* Mu-law */
  204. #define DAHDI_LAW_ALAW 2 /* A-law */
  205. #define DAHDI_DIAL_OP_APPEND 1
  206. #define DAHDI_DIAL_OP_REPLACE 2
  207. #define DAHDI_DIAL_OP_CANCEL 3
  208. #define DAHDI_MAX_CADENCE 16
  209. #define DAHDI_TONEDETECT_ON (1 << 0) /* Detect tones */
  210. #define DAHDI_TONEDETECT_MUTE (1 << 1) /* Mute audio in received channel */
  211. /* Define the max # of outgoing DTMF, MFR1 or MFR2 digits to queue */
  212. #define DAHDI_MAX_DTMF_BUF 256
  213. #define DAHDI_MAX_EVENTSIZE 64 /* 64 events max in buffer */
  214. /* Value for DAHDI_HOOK, set to ON hook */
  215. #define DAHDI_ONHOOK 0
  216. /* Value for DAHDI_HOOK, set to OFF hook */
  217. #define DAHDI_OFFHOOK 1
  218. /* Value for DAHDI_HOOK, wink (off hook momentarily) */
  219. #define DAHDI_WINK 2
  220. /* Value for DAHDI_HOOK, flash (on hook momentarily) */
  221. #define DAHDI_FLASH 3
  222. /* Value for DAHDI_HOOK, start line */
  223. #define DAHDI_START 4
  224. /* Value for DAHDI_HOOK, ring line (same as start line) */
  225. #define DAHDI_RING 5
  226. /* Value for DAHDI_HOOK, turn ringer off */
  227. #define DAHDI_RINGOFF 6
  228. /* Flush and stop the read (input) process */
  229. #define DAHDI_FLUSH_READ 1
  230. /* Flush and stop the write (output) process */
  231. #define DAHDI_FLUSH_WRITE 2
  232. /* Flush and stop both (input and output) processes */
  233. #define DAHDI_FLUSH_BOTH (DAHDI_FLUSH_READ | DAHDI_FLUSH_WRITE)
  234. /* Flush the event queue */
  235. #define DAHDI_FLUSH_EVENT 4
  236. /* Flush everything */
  237. #define DAHDI_FLUSH_ALL (DAHDI_FLUSH_BOTH | DAHDI_FLUSH_EVENT)
  238. #define DAHDI_MAX_SPANS 128 /* Max, 128 spans */
  239. #define DAHDI_MAX_CHANNELS 1024 /* Max, 1024 channels */
  240. #define DAHDI_MAX_CONF 1024 /* Max, 1024 conferences */
  241. /* Conference modes */
  242. #define DAHDI_CONF_MODE_MASK 0xFF /* mask for modes */
  243. #define DAHDI_CONF_NORMAL 0 /* normal mode */
  244. #define DAHDI_CONF_MONITOR 1 /* monitor mode (rx of other chan) */
  245. #define DAHDI_CONF_MONITORTX 2 /* monitor mode (tx of other chan) */
  246. #define DAHDI_CONF_MONITORBOTH 3 /* monitor mode (rx & tx of other chan) */
  247. #define DAHDI_CONF_CONF 4 /* conference mode */
  248. #define DAHDI_CONF_CONFANN 5 /* conference announce mode */
  249. #define DAHDI_CONF_CONFMON 6 /* conference monitor mode */
  250. #define DAHDI_CONF_CONFANNMON 7 /* conference announce/monitor mode */
  251. #define DAHDI_CONF_REALANDPSEUDO 8 /* real and pseudo port both on conf */
  252. #define DAHDI_CONF_DIGITALMON 9 /* Do not decode or interpret */
  253. #define DAHDI_CONF_MONITOR_RX_PREECHO 10 /* monitor mode (rx of other chan) - before echo can is done */
  254. #define DAHDI_CONF_MONITOR_TX_PREECHO 11 /* monitor mode (tx of other chan) - before echo can is done */
  255. #define DAHDI_CONF_MONITORBOTH_PREECHO 12 /* monitor mode (rx & tx of other chan) - before echo can is done */
  256. #define DAHDI_CONF_FLAG_MASK 0xFF00 /* mask for flags */
  257. #define DAHDI_CONF_LISTENER 0x100 /* is a listener on the conference */
  258. #define DAHDI_CONF_TALKER 0x200 /* is a talker on the conference */
  259. #define DAHDI_CONF_PSEUDO_LISTENER 0x400 /* pseudo is a listener on the conference */
  260. #define DAHDI_CONF_PSEUDO_TALKER 0x800 /* pseudo is a talker on the conference */
  261. /* Alarm Condition bits */
  262. #define DAHDI_ALARM_NONE 0 /* No alarms */
  263. #define DAHDI_ALARM_RECOVER (1 << 0) /* Recovering from alarm */
  264. #define DAHDI_ALARM_LOOPBACK (1 << 1) /* In loopback */
  265. #define DAHDI_ALARM_YELLOW (1 << 2) /* Yellow Alarm */
  266. #define DAHDI_ALARM_RED (1 << 3) /* Red Alarm */
  267. #define DAHDI_ALARM_BLUE (1 << 4) /* Blue Alarm */
  268. #define DAHDI_ALARM_NOTOPEN (1 << 5)
  269. /* Verbose alarm states (upper byte) */
  270. #define DAHDI_ALARM_LOS (1 << 8) /* Loss of Signal */
  271. #define DAHDI_ALARM_LFA (1 << 9) /* Loss of Frame Alignment */
  272. #define DAHDI_ALARM_LMFA (1 << 10)/* Loss of Multi-Frame Align */
  273. /* Maintenance modes */
  274. #define DAHDI_MAINT_NONE 0 /* Normal Mode */
  275. #define DAHDI_MAINT_LOCALLOOP 1 /* Local Loopback */
  276. #define DAHDI_MAINT_REMOTELOOP 2 /* Remote Loopback */
  277. #define DAHDI_MAINT_NETWORKLINELOOP 2 /* Remote Loopback */
  278. #define DAHDI_MAINT_LOOPUP 3 /* send loopup code */
  279. #define DAHDI_MAINT_LOOPDOWN 4 /* send loopdown code */
  280. #define DAHDI_MAINT_FAS_DEFECT 6 /* insert a FAS defect */
  281. #define DAHDI_MAINT_MULTI_DEFECT 7 /* insert a Multiframe defect */
  282. #define DAHDI_MAINT_CRC_DEFECT 8 /* insert a FAS defect */
  283. #define DAHDI_MAINT_CAS_DEFECT 9 /* insert a FAS defect */
  284. #define DAHDI_MAINT_PRBS_DEFECT 10 /* insert a FAS defect */
  285. #define DAHDI_MAINT_BIPOLAR_DEFECT 11 /* insert a FAS defect */
  286. #define DAHDI_MAINT_PRBS 12 /* enable the PRBS gen/mon */
  287. #define DAHDI_MAINT_NETWORKPAYLOADLOOP 13 /* Remote Loopback */
  288. #define DAHDI_RESET_COUNTERS 14 /* Clear the error counters */
  289. #define DAHDI_MAINT_ALARM_SIM 15 /* Simulate alarms */
  290. /* Flag Value for IOMUX, read avail */
  291. #define DAHDI_IOMUX_READ 1
  292. /* Flag Value for IOMUX, write avail */
  293. #define DAHDI_IOMUX_WRITE 2
  294. /* Flag Value for IOMUX, write done */
  295. #define DAHDI_IOMUX_WRITEEMPTY 4
  296. /* Flag Value for IOMUX, signalling event avail */
  297. #define DAHDI_IOMUX_SIGEVENT 8
  298. /* Flag Value for IOMUX, Do Not Wait if nothing to report */
  299. #define DAHDI_IOMUX_NOWAIT 0x100
  300. /* Ret. Value for GET/WAIT Event, no event */
  301. #define DAHDI_EVENT_NONE 0
  302. /* Ret. Value for GET/WAIT Event, Went Onhook */
  303. #define DAHDI_EVENT_ONHOOK 1
  304. /* Ret. Value for GET/WAIT Event, Went Offhook or got Ring */
  305. #define DAHDI_EVENT_RINGOFFHOOK 2
  306. /* Ret. Value for GET/WAIT Event, Got Wink or Flash */
  307. #define DAHDI_EVENT_WINKFLASH 3
  308. /* Ret. Value for GET/WAIT Event, Got Alarm */
  309. #define DAHDI_EVENT_ALARM 4
  310. /* Ret. Value for GET/WAIT Event, Got No Alarm (after alarm) */
  311. #define DAHDI_EVENT_NOALARM 5
  312. /* Ret. Value for GET/WAIT Event, HDLC Abort frame */
  313. #define DAHDI_EVENT_ABORT 6
  314. /* Ret. Value for GET/WAIT Event, HDLC Frame overrun */
  315. #define DAHDI_EVENT_OVERRUN 7
  316. /* Ret. Value for GET/WAIT Event, Bad FCS */
  317. #define DAHDI_EVENT_BADFCS 8
  318. /* Ret. Value for dial complete */
  319. #define DAHDI_EVENT_DIALCOMPLETE 9
  320. /* Ret Value for ringer going on */
  321. #define DAHDI_EVENT_RINGERON 10
  322. /* Ret Value for ringer going off */
  323. #define DAHDI_EVENT_RINGEROFF 11
  324. /* Ret Value for hook change complete */
  325. #define DAHDI_EVENT_HOOKCOMPLETE 12
  326. /* Ret Value for bits changing on a CAS / User channel */
  327. #define DAHDI_EVENT_BITSCHANGED 13
  328. /* Ret value for the beginning of a pulse coming on its way */
  329. #define DAHDI_EVENT_PULSE_START 14
  330. /* Timer event -- timer expired */
  331. #define DAHDI_EVENT_TIMER_EXPIRED 15
  332. /* Timer event -- ping ready */
  333. #define DAHDI_EVENT_TIMER_PING 16
  334. /* Polarity reversal event */
  335. #define DAHDI_EVENT_POLARITY 17
  336. /* Ring Begin event */
  337. #define DAHDI_EVENT_RINGBEGIN 18
  338. /* Echo can disabled event */
  339. #define DAHDI_EVENT_EC_DISABLED 19
  340. /* Channel was disconnected. Hint user to close channel */
  341. #define DAHDI_EVENT_REMOVED 20
  342. /* A neon MWI pulse was detected */
  343. #define DAHDI_EVENT_NEONMWI_ACTIVE 21
  344. /* No neon MWI pulses were detected over some period of time */
  345. #define DAHDI_EVENT_NEONMWI_INACTIVE 22
  346. /* A CED tone was detected on the channel in the transmit direction */
  347. #define DAHDI_EVENT_TX_CED_DETECTED 23
  348. /* A CED tone was detected on the channel in the receive direction */
  349. #define DAHDI_EVENT_RX_CED_DETECTED 24
  350. /* A CNG tone was detected on the channel in the transmit direction */
  351. #define DAHDI_EVENT_TX_CNG_DETECTED 25
  352. /* A CNG tone was detected on the channel in the receive direction */
  353. #define DAHDI_EVENT_RX_CNG_DETECTED 26
  354. /* The echo canceler's NLP (only) was disabled */
  355. #define DAHDI_EVENT_EC_NLP_DISABLED 27
  356. /* The echo canceler's NLP (only) was enabled */
  357. #define DAHDI_EVENT_EC_NLP_ENABLED 28
  358. /* The channel's read buffer encountered an overrun condition */
  359. #define DAHDI_EVENT_READ_OVERRUN 29
  360. /* The channel's write buffer encountered an underrun condition */
  361. #define DAHDI_EVENT_WRITE_UNDERRUN 30
  362. #define DAHDI_EVENT_PULSEDIGIT (1 << 16) /* This is OR'd with the digit received */
  363. #define DAHDI_EVENT_DTMFDOWN (1 << 17) /* Ditto for DTMF key down event */
  364. #define DAHDI_EVENT_DTMFUP (1 << 18) /* Ditto for DTMF key up event */
  365. /* Transcoder related definitions */
  366. struct dahdi_transcoder_formats {
  367. __u32 srcfmt;
  368. __u32 dstfmt;
  369. };
  370. struct dahdi_transcoder_info {
  371. __u32 tcnum;
  372. char name[80];
  373. __u32 numchannels;
  374. __u32 dstfmts;
  375. __u32 srcfmts;
  376. };
  377. #define DAHDI_MAX_ECHOCANPARAMS 8
  378. /* ioctl definitions */
  379. #define DAHDI_CODE 0xDA
  380. /*
  381. * Get/Set Transfer Block Size.
  382. */
  383. #define DAHDI_GET_BLOCKSIZE _IOR(DAHDI_CODE, 1, int)
  384. #define DAHDI_SET_BLOCKSIZE _IOW(DAHDI_CODE, 1, int)
  385. /*
  386. * Flush Buffer(s) and stop I/O
  387. */
  388. #define DAHDI_FLUSH _IOW(DAHDI_CODE, 3, int)
  389. /*
  390. * Wait for Write to Finish
  391. */
  392. #define DAHDI_SYNC _IO(DAHDI_CODE, 4)
  393. /*
  394. * Get/set channel parameters
  395. */
  396. struct dahdi_params {
  397. int channo; /* Channel number */
  398. int spanno; /* Span itself */
  399. int chanpos; /* Channel number in span */
  400. int sigtype; /* read-only */
  401. int sigcap; /* read-only */
  402. int rxisoffhook; /* read-only */
  403. int rxbits; /* read-only */
  404. int txbits; /* read-only */
  405. int txhooksig; /* read-only */
  406. int rxhooksig; /* read-only */
  407. int curlaw; /* read-only -- one of DAHDI_LAW_MULAW or DAHDI_LAW_ALAW */
  408. int idlebits; /* read-only -- What is considered the idle state */
  409. char name[40]; /* Name of channel */
  410. int prewinktime;
  411. int preflashtime;
  412. int winktime;
  413. int flashtime;
  414. int starttime;
  415. int rxwinktime;
  416. int rxflashtime;
  417. int debouncetime;
  418. int pulsebreaktime;
  419. int pulsemaketime;
  420. int pulseaftertime;
  421. __u32 chan_alarms; /* alarms on this channel */
  422. };
  423. #define DAHDI_GET_PARAMS_V1 _IOR(DAHDI_CODE, 5, struct dahdi_params)
  424. #define DAHDI_GET_PARAMS _IOWR(DAHDI_CODE, 5, struct dahdi_params)
  425. #define DAHDI_SET_PARAMS _IOW(DAHDI_CODE, 5, struct dahdi_params)
  426. /*
  427. * Set Hookswitch Status
  428. */
  429. #define DAHDI_HOOK _IOW(DAHDI_CODE, 7, int)
  430. /*
  431. * Get Signalling Event
  432. */
  433. #define DAHDI_GETEVENT _IOR(DAHDI_CODE, 8, int)
  434. /*
  435. * Wait for something to happen (IO Mux)
  436. */
  437. #define DAHDI_IOMUX _IOWR(DAHDI_CODE, 9, int)
  438. /*
  439. * Get Span Status
  440. */
  441. struct dahdi_spaninfo {
  442. int spanno; /* span number */
  443. char name[20]; /* Name */
  444. char desc[40]; /* Description */
  445. int alarms; /* alarms status */
  446. int txlevel; /* what TX level is set to */
  447. int rxlevel; /* current RX level */
  448. int bpvcount; /* current BPV count */
  449. int crc4count; /* current CRC4 error count */
  450. int ebitcount; /* current E-bit error count */
  451. int fascount; /* current FAS error count */
  452. __u32 fecount; /* Framing error counter */
  453. __u32 cvcount; /* Coding violations counter */
  454. __u32 becount; /* current bit error count */
  455. __u32 prbs; /* current PRBS detected pattern */
  456. __u32 errsec; /* errored seconds */
  457. int irqmisses; /* current IRQ misses */
  458. int syncsrc; /* span # of current sync source,
  459. or 0 for free run */
  460. int numchans; /* number of configured channels on this span */
  461. int totalchans; /* total number of channels on the span */
  462. int totalspans; /* total number of spans in entire system */
  463. int lbo; /* line build out */
  464. int lineconfig; /* framing/coding */
  465. char lboname[40]; /* line build out in text form */
  466. char location[40]; /* span's device location in system */
  467. char manufacturer[40]; /* manufacturer of span's device */
  468. char devicetype[40]; /* span's device type */
  469. int irq; /* span's device IRQ */
  470. int linecompat; /* span global signaling or 0 for
  471. analog spans.*/
  472. char spantype[6]; /* type of span in text form */
  473. } __attribute__((packed));
  474. struct dahdi_spaninfo_v1 {
  475. int spanno; /* span number */
  476. char name[20]; /* Name */
  477. char desc[40]; /* Description */
  478. int alarms; /* alarms status */
  479. int txlevel; /* what TX level is set to */
  480. int rxlevel; /* current RX level */
  481. int bpvcount; /* current BPV count */
  482. int crc4count; /* current CRC4 error count */
  483. int ebitcount; /* current E-bit error count */
  484. int fascount; /* current FAS error count */
  485. int irqmisses; /* current IRQ misses */
  486. int syncsrc; /* span # of current sync source, or 0 for free run */
  487. int numchans; /* number of configured channels on this span */
  488. int totalchans; /* total number of channels on the span */
  489. int totalspans; /* total number of spans in entire system */
  490. int lbo; /* line build out */
  491. int lineconfig; /* framing/coding */
  492. char lboname[40]; /* line build out in text form */
  493. char location[40]; /* span's device location in system */
  494. char manufacturer[40]; /* manufacturer of span's device */
  495. char devicetype[40]; /* span's device type */
  496. int irq; /* span's device IRQ */
  497. int linecompat; /* signaling modes possible on this span */
  498. char spantype[6]; /* type of span in text form */
  499. };
  500. #define DAHDI_SPANSTAT _IOWR(DAHDI_CODE, 10, struct dahdi_spaninfo)
  501. #define DAHDI_SPANSTAT_V1 _IOWR(DAHDI_CODE, 10, struct dahdi_spaninfo_v1)
  502. /*
  503. * Set Maintenance Mode
  504. */
  505. struct dahdi_maintinfo {
  506. int spanno; /* span number */
  507. int command; /* command */
  508. };
  509. #define DAHDI_MAINT _IOW(DAHDI_CODE, 11, struct dahdi_maintinfo)
  510. /*
  511. * Get/Set Conference Mode
  512. */
  513. struct dahdi_confinfo {
  514. int chan; /* channel number, 0 for current */
  515. int confno; /* conference number */
  516. int confmode; /* conferencing mode */
  517. };
  518. #define DAHDI_GETCONF_V1 _IOR(DAHDI_CODE, 12, struct dahdi_confinfo)
  519. #define DAHDI_GETCONF _IOWR(DAHDI_CODE, 12, struct dahdi_confinfo)
  520. #define DAHDI_SETCONF_V1 _IOW(DAHDI_CODE, 12, struct dahdi_confinfo)
  521. #define DAHDI_SETCONF _IOWR(DAHDI_CODE, 13, struct dahdi_confinfo)
  522. /*
  523. * Setup or Remove Conference Link
  524. */
  525. #define DAHDI_CONFLINK _IOW(DAHDI_CODE, 14, struct dahdi_confinfo)
  526. /*
  527. * Display Conference Diagnostic Information on Console
  528. */
  529. #define DAHDI_CONFDIAG_V1 _IOR(DAHDI_CODE, 15, int)
  530. #define DAHDI_CONFDIAG _IOW(DAHDI_CODE, 15, int)
  531. /*
  532. * Get/Set Channel audio gains
  533. */
  534. struct dahdi_gains {
  535. int chan; /* channel number, 0 for current */
  536. unsigned char rxgain[256]; /* Receive gain table */
  537. unsigned char txgain[256]; /* Transmit gain table */
  538. };
  539. #define DAHDI_GETGAINS_V1 _IOR(DAHDI_CODE, 16, struct dahdi_gains)
  540. #define DAHDI_GETGAINS _IOWR(DAHDI_CODE, 16, struct dahdi_gains)
  541. #define DAHDI_SETGAINS _IOW(DAHDI_CODE, 16, struct dahdi_gains)
  542. /*
  543. * Set Line (T1) Configurations
  544. */
  545. struct dahdi_lineconfig {
  546. int span; /* Which span number (0 to use name) */
  547. char name[20]; /* Name of span to use */
  548. int lbo; /* line build-outs */
  549. int lineconfig; /* line config parameters (framing, coding) */
  550. int sync; /* what level of sync source we are */
  551. };
  552. #define DAHDI_SPANCONFIG _IOW(DAHDI_CODE, 18, struct dahdi_lineconfig)
  553. /*
  554. * Set Channel Configuration
  555. */
  556. struct dahdi_chanconfig {
  557. int chan; /* Channel we're applying this to (0 to use name) */
  558. char name[40]; /* Name of channel to use */
  559. int sigtype; /* Signal type */
  560. int deflaw; /* Default law (DAHDI_LAW_DEFAULT, DAHDI_LAW_MULAW, or DAHDI_LAW_ALAW) */
  561. int master; /* Master channel if sigtype is DAHDI_SLAVE */
  562. int idlebits; /* Idle bits (if this is a CAS channel) or
  563. channel to monitor (if this is DACS channel) */
  564. char netdev_name[16];/* name for the hdlc network device*/
  565. };
  566. #define DAHDI_CHANCONFIG _IOW(DAHDI_CODE, 19, struct dahdi_chanconfig)
  567. /*
  568. * Set Conference to mute mode
  569. */
  570. #define DAHDI_CONFMUTE _IOW(DAHDI_CODE, 20, int)
  571. /*
  572. * Send a particular tone (see DAHDI_TONE_*)
  573. */
  574. #define DAHDI_SENDTONE _IOW(DAHDI_CODE, 21, int)
  575. /*
  576. * Get/Set your region for tones
  577. */
  578. #define DAHDI_GETTONEZONE _IOR(DAHDI_CODE, 22, int)
  579. #define DAHDI_SETTONEZONE _IOW(DAHDI_CODE, 22, int)
  580. /*
  581. * Master unit only -- set default zone (see DAHDI_TONE_ZONE_*)
  582. */
  583. #define DAHDI_DEFAULTZONE _IOW(DAHDI_CODE, 24, int)
  584. /*
  585. * Load a tone zone from a dahdi_tone_def_header
  586. */
  587. struct dahdi_tone_def {
  588. int tone; /* See DAHDI_TONE_* */
  589. int next; /* What the next position in the cadence is
  590. (They're numbered by the order the appear here) */
  591. int samples; /* How many samples to play for this cadence */
  592. int shift; /* How much to scale down the volume (2 is nice) */
  593. /* Now come the constants we need to make tones */
  594. /*
  595. Calculate the next 6 factors using the following equations:
  596. l = <level in dbm>, f1 = <freq1>, f2 = <freq2>
  597. gain = pow(10.0, (l - 3.14) / 20.0) * 65536.0 / 2.0;
  598. // Frequency factor 1
  599. fac_1 = 2.0 * cos(2.0 * M_PI * (f1/8000.0)) * 32768.0;
  600. // Last previous two samples
  601. init_v2_1 = sin(-4.0 * M_PI * (f1/8000.0)) * gain;
  602. init_v3_1 = sin(-2.0 * M_PI * (f1/8000.0)) * gain;
  603. // Frequency factor 2
  604. fac_2 = 2.0 * cos(2.0 * M_PI * (f2/8000.0)) * 32768.0;
  605. // Last previous two samples
  606. init_v2_2 = sin(-4.0 * M_PI * (f2/8000.0)) * gain;
  607. init_v3_2 = sin(-2.0 * M_PI * (f2/8000.0)) * gain;
  608. */
  609. int fac1;
  610. int init_v2_1;
  611. int init_v3_1;
  612. int fac2;
  613. int init_v2_2;
  614. int init_v3_2;
  615. int modulate;
  616. };
  617. struct dahdi_tone_def_header {
  618. int count; /* How many samples follow */
  619. int zone; /* Which zone we are loading */
  620. int ringcadence[DAHDI_MAX_CADENCE]; /* Ring cadence in ms (0=on, 1=off, ends with 0 value) */
  621. char name[40]; /* Informational name of zone */
  622. /* immediately follow this structure with dahdi_tone_def structures */
  623. struct dahdi_tone_def tones[0];
  624. };
  625. #define DAHDI_LOADZONE _IOW(DAHDI_CODE, 25, struct dahdi_tone_def_header)
  626. /*
  627. * Free a tone zone
  628. */
  629. #define DAHDI_FREEZONE _IOW(DAHDI_CODE, 26, int)
  630. /*
  631. * Get/Set buffer policy
  632. */
  633. struct dahdi_bufferinfo {
  634. int txbufpolicy; /* Policy for handling receive buffers */
  635. int rxbufpolicy; /* Policy for handling receive buffers */
  636. int numbufs; /* How many buffers to use */
  637. int bufsize; /* How big each buffer is */
  638. int readbufs; /* How many read buffers are full (read-only) */
  639. int writebufs; /* How many write buffers are full (read-only) */
  640. };
  641. #define DAHDI_GET_BUFINFO _IOR(DAHDI_CODE, 27, struct dahdi_bufferinfo)
  642. #define DAHDI_SET_BUFINFO _IOW(DAHDI_CODE, 27, struct dahdi_bufferinfo)
  643. /*
  644. * Get/Set dialing parameters
  645. */
  646. struct dahdi_dialparams {
  647. int mfv1_tonelen; /* MF R1 tone length for digits */
  648. int dtmf_tonelen; /* DTMF tone length */
  649. int mfr2_tonelen; /* MF R2 tone length */
  650. int reserved[3]; /* Reserved for future expansion -- always set to 0 */
  651. };
  652. #define DAHDI_GET_DIALPARAMS _IOR(DAHDI_CODE, 29, struct dahdi_dialparams)
  653. #define DAHDI_SET_DIALPARAMS _IOW(DAHDI_CODE, 29, struct dahdi_dialparams)
  654. /*
  655. * Append, replace, or cancel a dial string
  656. */
  657. struct dahdi_dialoperation {
  658. int op;
  659. char dialstr[DAHDI_MAX_DTMF_BUF];
  660. };
  661. #define DAHDI_DIAL _IOW(DAHDI_CODE, 31, struct dahdi_dialoperation)
  662. /*
  663. * Set a clear channel into audio mode
  664. */
  665. #define DAHDI_AUDIOMODE _IOW(DAHDI_CODE, 32, int)
  666. /*
  667. * Enable or disable echo cancellation on a channel
  668. *
  669. * For ECHOCANCEL:
  670. * The number is zero to disable echo cancellation and non-zero
  671. * to enable echo cancellation. If the number is between 32
  672. * and 1024, it will also set the number of taps in the echo canceller
  673. *
  674. * For ECHOCANCEL_PARAMS:
  675. * The structure contains parameters that should be passed to the
  676. * echo canceler instance for the selected channel.
  677. */
  678. #define DAHDI_ECHOCANCEL _IOW(DAHDI_CODE, 33, int)
  679. struct dahdi_echocanparam {
  680. char name[16];
  681. __s32 value;
  682. };
  683. struct dahdi_echocanparams {
  684. /* 8 taps per millisecond */
  685. __u32 tap_length;
  686. /* number of parameters supplied */
  687. __u32 param_count;
  688. /* immediately follow this structure with dahdi_echocanparam structures */
  689. struct dahdi_echocanparam params[0];
  690. };
  691. #define DAHDI_ECHOCANCEL_PARAMS _IOW(DAHDI_CODE, 33, struct dahdi_echocanparams)
  692. /*
  693. * Return a channel's channel number
  694. */
  695. #define DAHDI_CHANNO _IOR(DAHDI_CODE, 34, int)
  696. /*
  697. * Return a flag indicating whether channel is currently dialing
  698. */
  699. #define DAHDI_DIALING _IOR(DAHDI_CODE, 35, int)
  700. /*
  701. * Set a clear channel into HDLC w/out FCS checking/calculation mode
  702. */
  703. #define DAHDI_HDLCRAWMODE _IOW(DAHDI_CODE, 36, int)
  704. /*
  705. * Set a clear channel into HDLC w/ FCS mode
  706. */
  707. #define DAHDI_HDLCFCSMODE _IOW(DAHDI_CODE, 37, int)
  708. /*
  709. * Specify a channel on generic channel selector - must be done before
  710. * performing any other ioctls
  711. */
  712. #define DAHDI_SPECIFY _IOW(DAHDI_CODE, 38, int)
  713. /*
  714. * Temporarily set the law on a channel to
  715. * DAHDI_LAW_DEFAULT, DAHDI_LAW_ALAW, or DAHDI_LAW_MULAW. Is reset on close.
  716. */
  717. #define DAHDI_SETLAW _IOW(DAHDI_CODE, 39, int)
  718. /*
  719. * Temporarily set the channel to operate in linear mode when non-zero
  720. * or default law if 0
  721. */
  722. #define DAHDI_SETLINEAR _IOW(DAHDI_CODE, 40, int)
  723. /*
  724. * Set a clear channel into HDLC w/ PPP interface mode
  725. */
  726. #define DAHDI_HDLCPPP _IOW(DAHDI_CODE, 41, int)
  727. /*
  728. * Set the ring cadence for FXS interfaces
  729. */
  730. struct dahdi_ring_cadence {
  731. int ringcadence[DAHDI_MAX_CADENCE];
  732. };
  733. #define DAHDI_SETCADENCE _IOW(DAHDI_CODE, 42, struct dahdi_ring_cadence)
  734. /*
  735. * Get/Set the signaling bits for CAS interface
  736. */
  737. #define DAHDI_GETRXBITS _IOR(DAHDI_CODE, 43, int)
  738. #define DAHDI_SETTXBITS _IOW(DAHDI_CODE, 43, int)
  739. /*
  740. * Display Channel Diagnostic Information on Console
  741. */
  742. #define DAHDI_CHANDIAG_V1 _IOR(DAHDI_CODE, 44, int)
  743. #define DAHDI_CHANDIAG _IOW(DAHDI_CODE, 44, int)
  744. /*
  745. * Set Channel's SF Tone Configuration
  746. */
  747. struct dahdi_sfconfig {
  748. int chan; /* Channel we're applying this to (0 to use name) */
  749. char name[40]; /* Name of channel to use */
  750. long rxp1; /* receive tone det. p1 */
  751. long rxp2; /* receive tone det. p2 */
  752. long rxp3; /* receive tone det. p3 */
  753. int txtone; /* Tx tone factor */
  754. int tx_v2; /* initial v2 value */
  755. int tx_v3; /* initial v3 value */
  756. int toneflag; /* Tone flags */
  757. };
  758. #define DAHDI_SFCONFIG _IOW(DAHDI_CODE, 46, struct dahdi_sfconfig)
  759. /*
  760. * Set timer expiration (in samples)
  761. */
  762. #define DAHDI_TIMERCONFIG _IOW(DAHDI_CODE, 47, int)
  763. /*
  764. * Acknowledge timer expiration (number to acknowledge, or -1 for all)
  765. */
  766. #define DAHDI_TIMERACK _IOW(DAHDI_CODE, 48, int)
  767. /*
  768. * Get Conference to mute mode
  769. */
  770. #define DAHDI_GETCONFMUTE _IOR(DAHDI_CODE, 49, int)
  771. /*
  772. * Request echo training in some number of ms (with muting in the mean time)
  773. */
  774. #define DAHDI_ECHOTRAIN _IOW(DAHDI_CODE, 50, int)
  775. /*
  776. * Set on hook transfer for n number of ms -- implemented by low level driver
  777. */
  778. #define DAHDI_ONHOOKTRANSFER _IOW(DAHDI_CODE, 51, int)
  779. /*
  780. * Queue Ping
  781. */
  782. #define DAHDI_TIMERPING _IO(DAHDI_CODE, 52)
  783. /*
  784. * Acknowledge ping
  785. */
  786. #define DAHDI_TIMERPONG _IO(DAHDI_CODE, 53)
  787. /*
  788. * Get/set signalling freeze
  789. */
  790. #define DAHDI_GETSIGFREEZE _IOR(DAHDI_CODE, 54, int)
  791. #define DAHDI_SETSIGFREEZE _IOW(DAHDI_CODE, 54, int)
  792. /*
  793. * Perform an indirect ioctl (on a specified channel via master interface)
  794. */
  795. struct dahdi_indirect_data {
  796. int chan;
  797. int op;
  798. void *data;
  799. };
  800. #define DAHDI_INDIRECT _IOWR(DAHDI_CODE, 56, struct dahdi_indirect_data)
  801. /*
  802. * Get the version of DAHDI that is running, and a description
  803. * of the compiled-in echo cancellers (if any)
  804. */
  805. struct dahdi_versioninfo {
  806. char version[80];
  807. char echo_canceller[80];
  808. };
  809. #define DAHDI_GETVERSION _IOR(DAHDI_CODE, 57, struct dahdi_versioninfo)
  810. /*
  811. * Put the channel in loopback mode (receive from the channel is
  812. * transmitted back on the interface)
  813. */
  814. #define DAHDI_LOOPBACK _IOW(DAHDI_CODE, 58, int)
  815. /*
  816. Attach the desired echo canceler module (or none) to a channel in an
  817. audio-supporting mode, so that when the channel needs an echo canceler
  818. that module will be used to supply one.
  819. */
  820. struct dahdi_attach_echocan {
  821. int chan; /* Channel we're applying this to */
  822. char echocan[16]; /* Name of echo canceler to attach to this channel
  823. (leave empty to have no echocan attached */
  824. };
  825. #define DAHDI_ATTACH_ECHOCAN _IOW(DAHDI_CODE, 59, struct dahdi_attach_echocan)
  826. /*
  827. * 60-80 are reserved for private drivers
  828. * 80-85 are reserved for dynamic span stuff
  829. */
  830. /*
  831. * Create a dynamic span
  832. */
  833. struct dahdi_dynamic_span {
  834. char driver[20]; /* Which low-level driver to use */
  835. char addr[40]; /* Destination address */
  836. int numchans; /* Number of channels */
  837. int timing; /* Timing source preference */
  838. int spanno; /* Span number (filled in by DAHDI) */
  839. };
  840. #define DAHDI_DYNAMIC_CREATE _IOWR(DAHDI_CODE, 80, struct dahdi_dynamic_span)
  841. /*
  842. * Destroy a dynamic span
  843. */
  844. #define DAHDI_DYNAMIC_DESTROY _IOW(DAHDI_CODE, 81, struct dahdi_dynamic_span)
  845. /*
  846. * Set the HW gain for a device
  847. */
  848. struct dahdi_hwgain {
  849. __s32 newgain; /* desired gain in dB but x10. -3.5dB would be -35 */
  850. __u32 tx:1; /* 0=rx; 1=tx */
  851. };
  852. #define DAHDI_SET_HWGAIN _IOW(DAHDI_CODE, 86, struct dahdi_hwgain)
  853. /*
  854. * Enable tone detection -- implemented by low level driver
  855. */
  856. #define DAHDI_TONEDETECT _IOW(DAHDI_CODE, 91, int)
  857. /*
  858. * Set polarity -- implemented by individual driver. 0 = forward, 1 = reverse
  859. */
  860. #define DAHDI_SETPOLARITY _IOW(DAHDI_CODE, 92, int)
  861. /*
  862. * Transcoder operations
  863. */
  864. /* DAHDI_TRANSCODE_OP is an older interface that is deprecated and no longer
  865. * supported.
  866. */
  867. #define DAHDI_TRANSCODE_OP _IOWR(DAHDI_CODE, 93, int)
  868. #define DAHDI_TC_CODE 'T'
  869. #define DAHDI_TC_ALLOCATE _IOW(DAHDI_TC_CODE, 1, struct dahdi_transcoder_formats)
  870. #define DAHDI_TC_GETINFO _IOWR(DAHDI_TC_CODE, 2, struct dahdi_transcoder_info)
  871. /*
  872. * VMWI Specification
  873. */
  874. struct dahdi_vmwi_info {
  875. unsigned int vmwi_type;
  876. };
  877. #define DAHDI_VMWI_LREV (1 << 0) /* Line Reversal */
  878. #define DAHDI_VMWI_HVDC (1 << 1) /* HV 90VDC */
  879. #define DAHDI_VMWI_HVAC (1 << 2) /* HV 90VAC Neon lamp */
  880. /*
  881. * VoiceMail Waiting Indication (VMWI) -- implemented by low-level driver.
  882. * Value: number of waiting messages (hence 0: switch messages off).
  883. */
  884. #define DAHDI_VMWI _IOWR(DAHDI_CODE, 94, int)
  885. #define DAHDI_VMWI_CONFIG _IOW(DAHDI_CODE, 95, struct dahdi_vmwi_info)
  886. /*
  887. * Startup or Shutdown a span
  888. */
  889. #define DAHDI_STARTUP _IOW(DAHDI_CODE, 99, int)
  890. #define DAHDI_SHUTDOWN _IOW(DAHDI_CODE, 100, int)
  891. #define DAHDI_HDLC_RATE _IOW(DAHDI_CODE, 101, int)
  892. /* Put a channel's echo canceller into 'FAX mode' if possible */
  893. #define DAHDI_ECHOCANCEL_FAX_MODE _IOW(DAHDI_CODE, 102, int)
  894. /*
  895. * Defines which channel to receive mirrored traffic from
  896. */
  897. #ifdef CONFIG_DAHDI_MIRROR
  898. #define DAHDI_RXMIRROR _IOW(DAHDI_CODE, 103, int)
  899. #define DAHDI_TXMIRROR _IOW(DAHDI_CODE, 104, int)
  900. #endif /* CONFIG_DAHDI_MIRROR */
  901. /*
  902. Set the desired state for channel buffer event generation which is disabled
  903. by default to allow for backwards compatibility for dumb users of channels
  904. such as pattern utilities.
  905. */
  906. #define DAHDI_BUFFER_EVENTS _IOW(DAHDI_CODE, 105, int)
  907. /* Get current status IOCTL */
  908. /* Defines for Radio Status (dahdi_radio_stat.radstat) bits */
  909. #define DAHDI_RADSTAT_RX 1 /* currently "receiving " */
  910. #define DAHDI_RADSTAT_TX 2 /* currently "transmitting" */
  911. #define DAHDI_RADSTAT_RXCT 4 /* currently receiving continuous tone with
  912. current settings */
  913. #define DAHDI_RADSTAT_RXCOR 8 /* currently receiving COR (irrelevant of COR
  914. ignore) */
  915. #define DAHDI_RADSTAT_IGNCOR 16 /* currently ignoring COR */
  916. #define DAHDI_RADSTAT_IGNCT 32 /* currently ignoring CTCSS/DCS decode */
  917. #define DAHDI_RADSTAT_NOENCODE 64 /* currently blocking CTCSS/DCS encode */
  918. struct dahdi_radio_stat {
  919. unsigned short ctcode_rx; /* code of currently received CTCSS
  920. or DCS, 0 for none */
  921. unsigned short ctclass; /* class of currently received CTCSS or
  922. DCS code */
  923. unsigned short ctcode_tx; /* code of currently encoded CTCSS or
  924. DCS, 0 for none */
  925. unsigned char radstat; /* status bits of radio */
  926. };
  927. #define DAHDI_RADIO_GETSTAT _IOR(DAHDI_CODE, 57, struct dahdi_radio_stat)
  928. /* Get/Set a radio channel parameter */
  929. /* Defines for Radio Parameters (dahdi_radio_param.radpar) */
  930. #define DAHDI_RADPAR_INVERTCOR 1 /* invert the COR signal (0/1) */
  931. #define DAHDI_RADPAR_IGNORECOR 2 /* ignore the COR signal (0/1) */
  932. #define DAHDI_RADPAR_IGNORECT 3 /* ignore the CTCSS/DCS decode (0/1) */
  933. #define DAHDI_RADPAR_NOENCODE 4 /* block the CTCSS/DCS encode (0/1) */
  934. #define DAHDI_RADPAR_CORTHRESH 5 /* COR trigger threshold (0-7) */
  935. #define DAHDI_RADPAR_EXTRXTONE 6 /* 0 means use internal decoder, 1 means UIOA
  936. logic true is CT decode, 2 means UIOA logic
  937. false is CT decode */
  938. #define DAHDI_RADPAR_NUMTONES 7 /* returns maximum tone index (curently 15) */
  939. #define DAHDI_RADPAR_INITTONE 8 /* init all tone indexes to 0 (no tones) */
  940. #define DAHDI_RADPAR_RXTONE 9 /* CTCSS tone, (1-32) or DCS tone (1-777),
  941. or 0 meaning no tone, set index also (1-15) */
  942. #define DAHDI_RADPAR_RXTONECLASS 10 /* Tone class (0-65535), set index also (1-15) */
  943. #define DAHDI_RADPAR_TXTONE 11 /* CTCSS tone (1-32) or DCS tone (1-777) or 0
  944. to indicate no tone, to transmit
  945. for this tone index (0-32, 0 disables
  946. transmit CTCSS), set index also (0-15) */
  947. #define DAHDI_RADPAR_DEBOUNCETIME 12 /* receive indication debounce time,
  948. milliseconds (1-999) */
  949. #define DAHDI_RADPAR_BURSTTIME 13 /* end of transmit with no CT tone in
  950. milliseconds (0-999) */
  951. #define DAHDI_RADPAR_UIODATA 14 /* read/write UIOA and UIOB data. Bit 0 is
  952. UIOA, bit 1 is UIOB */
  953. #define DAHDI_RADPAR_UIOMODE 15 /* 0 means UIOA and UIOB are both outputs, 1
  954. means UIOA is input, UIOB is output, 2
  955. means UIOB is input and UIOA is output,
  956. 3 means both UIOA and UIOB are inputs. Note
  957. mode for UIOA is overridden when in
  958. EXTRXTONE mode. */
  959. #define DAHDI_RADPAR_REMMODE 16 /* Remote control data mode */
  960. #define DAHDI_RADPAR_REM_NONE 0 /* no remote control data mode */
  961. #define DAHDI_RADPAR_REM_RBI1 1 /* Doug Hall RBI-1 data mode */
  962. #define DAHDI_RADPAR_REM_SERIAL 2 /* Serial Data, 9600 BPS */
  963. #define DAHDI_RADPAR_REM_SERIAL_ASCII 3 /* Serial Ascii Data, 9600 BPS */
  964. #define DAHDI_RADPAR_REMCOMMAND 17 /* Remote conrtol write data block & do cmd */
  965. #define DAHDI_RADPAR_DEEMP 18 /* Audio De-empahsis (on or off) */
  966. #define DAHDI_RADPAR_PREEMP 19 /* Audio Pre-empahsis (on or off) */
  967. #define DAHDI_RADPAR_RXGAIN 20 /* Audio (In to system) Rx Gain */
  968. #define DAHDI_RADPAR_TXGAIN 21 /* Audio (Out from system) Tx Gain */
  969. #define RAD_SERIAL_BUFLEN 128
  970. struct dahdi_radio_param {
  971. unsigned short radpar; /* param identifier */
  972. unsigned short index; /* tone number */
  973. int data; /* param */
  974. int data2; /* param 2 */
  975. unsigned char buf[RAD_SERIAL_BUFLEN];
  976. };
  977. #define DAHDI_RADIO_GETPARAM _IOR(DAHDI_CODE, 58, struct dahdi_radio_param)
  978. #define DAHDI_RADIO_SETPARAM _IOW(DAHDI_CODE, 58, struct dahdi_radio_param)
  979. /*!
  980. \brief Size-limited null-terminating string copy.
  981. \param dst The destination buffer
  982. \param src The source string
  983. \param size The size of the destination buffer
  984. \return Nothing.
  985. This is similar to \a strncpy, with two important differences:
  986. - the destination buffer will \b always be null-terminated
  987. - the destination buffer is not filled with zeros past the copied string length
  988. These differences make it slightly more efficient, and safer to use since it will
  989. not leave the destination buffer unterminated. There is no need to pass an artificially
  990. reduced buffer size to this function (unlike \a strncpy), and the buffer does not need
  991. to be initialized to zeroes prior to calling this function.
  992. */
  993. static inline void dahdi_copy_string(char *dst, const char *src, unsigned int size)
  994. {
  995. while (*src && size) {
  996. *dst++ = *src++;
  997. size--;
  998. }
  999. if (__builtin_expect(!size, 0))
  1000. dst--;
  1001. *dst = '\0';
  1002. }
  1003. #endif /* _DAHDI_USER_H */