Version 0.1.5 from FTP
[asterisk/asterisk.git] / channels / ixjuser.h
1 /******************************************************************************
2 $Id$
3 $Log$
4 Revision 1.6  1999/12/01 05:25:58  markster
5 Version 0.1.5 from FTP
6
7 Revision 1.1  1999/12/01 05:25:58  markster
8 Start on the Internet Phone Jack channel
9
10 Revision 3.0  1999/11/18 22:21:43  root
11 Added isapnp kernel module support.
12
13 Revision 2.5  1999/11/09 15:42:06  root
14 Fixed convert code for older PhoneJACK cards.
15 Fixed G723.1 5.3 record bug.
16
17 Revision 2.4  1999/11/02 20:17:20  root
18 Fixed hookswitch bug for PhoneJACK
19 Added filter exception bit code.
20
21 Revision 2.3  1999/11/01 23:22:02  root
22 Added tone cadence generation.
23 Fixed hookswitch detection when PORT != POTS
24 Fixed ringing when PORT != POTS
25
26 Revision 2.2  1999/10/13 05:33:31  root
27 Added G.729A/B codec.
28 Fixed G.728 codec.
29
30 Revision 2.1  1999/10/11 19:29:46  root
31 Enhanced PSTN ring detection
32 Added Caller ID recognition
33 Added wink detection
34
35 Revision 2.0  1999/09/18 03:29:15  root
36 Added PSTN Support
37 Enhanced mixer functions
38 Fixed LineJACK and PhoneJACK Lite not reporting second IO range in p/proc/ioports
39 Added DSP Volume controls
40
41 Revision 1.23  1999/08/16 16:37:27  root
42 Added drybuffer ioctls
43 Added card type ioctl
44
45 Revision 1.22  1999/08/14 05:15:58  root
46 Fixed select timeout problems.  Was using the wrong wait queues.
47
48 Revision 1.21  1999/08/04 22:53:43  root
49 Added levels to AEC
50
51 Revision 1.20  1999/07/28 20:32:23  root
52 Added non-blocking rings
53 Added ring cadence
54
55 Revision 1.19  1999/07/14 21:08:10  root
56 fixed rcsid
57
58 Revision 1.18  1999/07/14 21:03:33  root
59 added rcsid
60
61 Revision 1.17  1999/07/12 20:20:00  root
62 Continuing work on 20ms and 10ms linear modes.
63
64 Revision 1.16  1999/07/09 19:13:50  root
65 Added IXJCTL_RATE to set the rate the DSP is polled.
66 Added 20ms and 10ms linear modes for LineJack and PhoneJack Lite.
67
68 Revision 1.15  1999/07/08 02:21:20  root
69 Async Notification on hookswitch changes.
70 Added IXJ_EXCEPTION bitfield structure for select exception sets
71 Added IXJCTL_DTMFASCII ioctl
72
73 Revision 1.14  1999/07/06 23:20:52  root
74 *** empty log message ***
75
76 Revision 1.14  1999/07/06 21:48:38  root
77 Fixed lockups in linear modes during write.
78
79 Revision 1.13  1999/06/28 18:30:44  root
80 Added buffer depth commands to reduce latency in compressed modes.
81
82 Revision 1.12  1999/06/25 21:03:18  root
83 Close device properly.
84 Started Mixer code for LineJack
85
86 Revision 1.11  1999/06/24 21:51:21  root
87 bug fixes
88
89 Revision 1.10  1999/06/17 18:23:16  root
90 Added tone generation.
91 Fixed LineJack hookswitch again.
92
93 Revision 1.9  1999/06/09 14:18:15  root
94 Fixed duplicate IOCTL numbers
95
96 Revision 1.8  1999/06/09 14:13:29  root
97 Added DTMF Recognition with Async Notification
98
99 Revision 1.7  1999/06/03 16:50:43  root
100 Added IXJCTL_HZ to allow changing the HZ value the driver uses.
101
102 Revision 1.6  1999/05/31 17:56:07  root
103 All linear modes now work properly.
104
105 Revision 1.5  1999/05/25 14:05:44  root
106 Added multiple codec selections.
107
108 Revision 1.4  1999/04/28 03:43:52  root
109 More work on echo cancellation
110
111 Revision 1.3  1999/04/27 17:17:12  root
112 added AEC
113
114 Revision 1.2  1999/04/22 11:43:52  root
115 Fixed stability problems
116
117 Revision 1.1  1999/03/25 21:52:42  root
118 Initial revision
119
120 *
121 * IOCTL's used for the Quicknet Cards
122 *
123 * If you use the IXJCTL_TESTRAM command, the card must be power cycled to
124 * reset the SRAM values before futher use.
125 *
126 ******************************************************************************/
127 static char ixjuser_h_rcsid[] = "$Id$";
128
129 #define IXJCTL_DSP_RESET                _IO  ('q', 0x80)
130 #define IXJCTL_RING                     _IO  ('q', 0x82)
131 #define IXJCTL_HOOKSTATE                _IO  ('q', 0x83)
132 #define IXJCTL_MAXRINGS                 _IOW ('q', 0x84, char)
133 #define IXJCTL_RING_CADENCE             _IOW ('q', 0x85, short)
134 #define IXJCTL_RING_START               _IO  ('q', 0x86)
135 #define IXJCTL_RING_STOP                _IO  ('q', 0x87)
136 #define IXJCTL_CARDTYPE                 _IOR ('q', 0x88, int)
137 #define IXJCTL_DSP_TYPE                 _IOR ('q', 0x8C, int)
138 #define IXJCTL_DSP_VERSION              _IOR ('q', 0x8D, int)
139 #define IXJCTL_DSP_IDLE                 _IO  ('q', 0x8E)
140 #define IXJCTL_TESTRAM                  _IO  ('q', 0x8F)
141
142 /******************************************************************************
143 *
144 * This group of IOCTLs deal with the record settings of the DSP
145 *
146 * The IXJCTL_REC_DEPTH command sets the internal buffer depth of the DSP.
147 * Setting a lower depth reduces latency, but increases the demand of the
148 * application to service the driver without frame loss.  The DSP has 480
149 * bytes of physical buffer memory for the record channel so the true
150 * maximum limit is determined by how many frames will fit in the buffer.
151 *
152 * 1 uncompressed (480 byte) 16-bit linear frame.
153 * 2 uncompressed (240 byte) 8-bit A-law/mu-law frames.
154 * 15 TrueSpeech 8.5 frames.
155 * 20 TrueSpeech 6.3,5.3,4.8 or 4.1 frames.
156 *
157 * The default in the driver is currently set to 2 frames.
158 *
159 * The IXJCTL_REC_VOLUME and IXJCTL_PLAY_VOLUME commands both use a Q8
160 * number as a parameter, 0x100 scales the signal by 1.0, 0x200 scales the
161 * signal by 2.0, 0x80 scales the signal by 0.5.  No protection is given
162 * against over-scaling, if the multiplication factor times the input
163 * signal exceeds 16 bits, overflow distortion will occur.  The default
164 * setting is 0x100 (1.0).
165 *
166 * The IXJCTL_REC_LEVEL returns the average signal level (not r.m.s.) on
167 * the most recently recorded frame as a 16 bit value.
168 ******************************************************************************/
169
170 #define IXJCTL_REC_CODEC                _IOW ('q', 0x90, int)
171 #define IXJCTL_REC_START                _IO  ('q', 0x92)
172 #define IXJCTL_REC_STOP                 _IO  ('q', 0x93)
173 #define IXJCTL_REC_DEPTH                _IOW ('q', 0x94, int)
174 #define IXJCTL_FRAME                    _IOW ('q', 0x95, int)
175 #define IXJCTL_REC_VOLUME               _IOW ('q', 0x96, int)
176 #define IXJCTL_REC_LEVEL                _IO  ('q', 0x97)
177
178 typedef enum{
179 f300_640 = 4, f300_500, f1100, f350, f400, f480, f440, f620, f20_50,
180 f133_200, f300, f300_420, f330, f300_425, f330_440, f340, f350_400,
181 f350_440, f350_450, f360, f380_420, f392, f400_425, f400_440, f400_450,
182 f420, f425, f425_450, f425_475, f435, f440_450, f440_480, f445, f450,
183 f452, f475, f480_620, f494, f500, f520, f523, f525, f540_660, f587,
184 f590, f600, f660, f700, f740, f750, f750_1450, f770, f800, f816, f850,
185 f857_1645, f900, f900_1300, f935_1215, f941_1477, f942, f950, f950_1400,
186 f975, f1000, f1020, f1050, f1100_1750, f1140, f1200, f1209, f1330, f1336,
187 lf1366, f1380, f1400, f1477, f1600, f1633_1638, f1800, f1860
188 }IXJ_FILTER_FREQ;
189
190 typedef struct
191 {
192   unsigned int filter;
193   IXJ_FILTER_FREQ freq;
194   char enable;
195 }IXJ_FILTER;
196
197 #define IXJCTL_SET_FILTER               _IOW ('q', 0x98, IXJ_FILTER *)
198 #define IXJCTL_GET_FILTER_HIST          _IOW ('q', 0x9B, int)
199 /******************************************************************************
200 *
201 * This IOCTL allows you to reassign values in the tone index table.  The
202 * tone table has 32 entries (0 - 31), but the driver only allows entries
203 * 13 - 27 to be modified, entry 0 is reserved for silence and 1 - 12 are
204 * the standard DTMF digits and 28 - 31 are the DTMF tones for A, B, C & D.
205 * The positions used internally for Call Progress Tones are as follows:
206 *    Dial Tone   - 25
207 *    Ring Back   - 26
208 *    Busy Signal - 27
209 *
210 * The freq values are calculated as:
211 * freq = cos(2 * PI * frequency / 8000)
212 *
213 * The most commonly needed values are already calculated and listed in the
214 * enum IXJ_TONE_FREQ.  Each tone index can have two frequencies with
215 * different gains, if you are only using a single frequency set the unused
216 * one to 0.
217 *
218 * The gain values range from 0 to 15 indicating +6dB to -24dB in 2dB
219 * increments.
220 *
221 ******************************************************************************/
222
223 typedef enum
224 {
225 hz20 = 0x7ffa, 
226 hz50 = 0x7fe5, 
227 hz133 = 0x7f4c, 
228 hz200 = 0x7e6b, 
229 hz261 = 0x7d50, /* .63 C1  */
230 hz277 = 0x7cfa, /* .18 CS1 */
231 hz293 = 0x7c9f, /* .66 D1  */
232 hz300 = 0x7c75, 
233 hz311 = 0x7c32, /* .13 DS1 */
234 hz329 = 0x7bbf, /* .63 E1  */
235 hz330 = 0x7bb8, 
236 hz340 = 0x7b75, 
237 hz349 = 0x7b37, /* .23 F1  */
238 hz350 = 0x7b30, 
239 hz360 = 0x7ae9, 
240 hz369 = 0x7aa8, /* .99 FS1 */
241 hz380 = 0x7a56, 
242 hz392 = 0x79fa, /* .00 G1  */
243 hz400 = 0x79bb, 
244 hz415 = 0x7941, /* .30 GS1 */
245 hz420 = 0x7918, 
246 hz425 = 0x78ee, 
247 hz435 = 0x7899, 
248 hz440 = 0x786d, /* .00 A1  */
249 hz445 = 0x7842, 
250 hz450 = 0x7815, 
251 hz452 = 0x7803, 
252 hz466 = 0x7784, /* .16 AS1 */
253 hz475 = 0x7731, 
254 hz480 = 0x7701, 
255 hz493 = 0x7685, /* .88 B1  */
256 hz494 = 0x767b, 
257 hz500 = 0x7640, 
258 hz520 = 0x7578, 
259 hz523 = 0x7559, /* .25 C2  */
260 hz525 = 0x7544, 
261 hz540 = 0x74a7, 
262 hz554 = 0x7411, /* .37 CS2 */
263 hz587 = 0x72a1, /* .33 D2  */
264 hz590 = 0x727f, 
265 hz600 = 0x720b, 
266 hz620 = 0x711e, 
267 hz622 = 0x7106, /* .25 DS2 */
268 hz659 = 0x6f3b, /* .26 E2  */
269 hz660 = 0x6f2e, 
270 hz698 = 0x6d3d, /* .46 F2  */
271 hz700 = 0x6d22, 
272 hz739 = 0x6b09, /* .99 FS2 */
273 hz740 = 0x6afa, 
274 hz750 = 0x6a6c, 
275 hz770 = 0x694b, 
276 hz783 = 0x688b, /* .99 G2  */
277 hz800 = 0x678d, 
278 hz816 = 0x6698, 
279 hz830 = 0x65bf, /* .61 GS2 */
280 hz850 = 0x6484, 
281 hz857 = 0x6414, 
282 hz880 = 0x629f, /* .00 A2  */
283 hz900 = 0x6154, 
284 hz932 = 0x5f35, /* .33 AS2 */
285 hz935 = 0x5f01, 
286 hz941 = 0x5e9a, 
287 hz942 = 0x5e88, 
288 hz950 = 0x5dfd, 
289 hz975 = 0x5c44, 
290 hz1000 = 0x5a81, 
291 hz1020 = 0x5912, 
292 hz1050 = 0x56e2, 
293 hz1100 = 0x5320, 
294 hz1140 = 0x5007, 
295 hz1200 = 0x4b3b, 
296 hz1209 = 0x4a80, 
297 hz1215 = 0x4a02, 
298 hz1250 = 0x471c, 
299 hz1300 = 0x42e0, 
300 hz1330 = 0x4049, 
301 hz1336 = 0x3fc4, 
302 hz1366 = 0x3d22, 
303 hz1380 = 0x3be4, 
304 hz1400 = 0x3a1b, 
305 hz1450 = 0x3596, 
306 hz1477 = 0x331c, 
307 hz1500 = 0x30fb, 
308 hz1600 = 0x278d, 
309 hz1633 = 0x2462, 
310 hz1638 = 0x23e7, 
311 hz1645 = 0x233a, 
312 hz1750 = 0x18f8, 
313 hz1800 = 0x1405, 
314 hz1860 = 0xe0b, 
315 hz2100 = 0xf5f6, 
316 hz2450 = 0xd3b3
317 }IXJ_FREQ;
318
319 typedef enum
320 {
321 C1  = hz261,
322 CS1 = hz277,
323 D1  = hz293,
324 DS1 = hz311,
325 E1  = hz329,
326 F1  = hz349,
327 FS1 = hz369,
328 G1  = hz392,
329 GS1 = hz415,
330 A1  = hz440,
331 AS1 = hz466,
332 B1  = hz493,
333 C2  = hz523,
334 CS2 = hz554,
335 D2  = hz587,
336 DS2 = hz622,
337 E2  = hz659,
338 F2  = hz698,
339 FS2 = hz739,
340 G2  = hz783,
341 GS2 = hz830,
342 A2  = hz880,
343 AS2 = hz932,
344 }IXJ_NOTE;
345
346 typedef struct
347 {
348   int tone_index;
349   int freq0;
350   int gain0;
351   int freq1;
352   int gain1;
353 }IXJ_TONE;
354
355 #define IXJCTL_INIT_TONE                _IOW ('q', 0x99, IXJ_TONE *)
356
357 /******************************************************************************
358 *
359 * The IXJCTL_TONE_CADENCE ioctl defines tone sequences used for various
360 * Call Progress Tones (CPT).  This is accomplished by setting up an array of
361 * IXJ_CADENCE_ELEMENT structures that sequentially define the states of
362 * the tone sequence.  The tone_on_time and tone_off time are in
363 * 250 microsecond intervals.  A pointer to this array is passed to the
364 * driver as the ce element of an IXJ_CADENCE structure.  The elements_used
365 * must be set to the number of IXJ_CADENCE_ELEMENTS in the array.  The
366 * termination variable defines what to do at the end of a cadence, the
367 * options are to play the cadence once and stop, to repeat the last
368 * element of the cadence indefinatly, or to repeat the entire cadence
369 * indefinatly.  The ce variable is a pointer to the array of IXJ_TONE
370 * structures.  If the freq0 variable is non-zero, the tone table contents
371 * for the tone_index are updated to the frequencies and gains defined.  It
372 * should be noted that DTMF tones cannot be reassigned, so if DTMF tone
373 * table indexs are used in a cadence the frequency and gain variables will
374 * be ignored.
375 *
376 * If the array elements contain frequency parameters the driver will
377 * initialize the needed tone table elements and begin playing the tone,
378 * there is no preset limit on the number of elements in the cadence.  If
379 * there is more than one frequency used in the cadence, sequential elements
380 * of different frequencies MUST use different tone table indexes.  Only one
381 * cadence can be played at a time.  It is possible to build complex
382 * cadences with multiple frequencies using 2 tone table indexes by
383 * alternating between them.
384 *
385 ******************************************************************************/
386
387 typedef struct
388 {
389   int index;
390   int tone_on_time;
391   int tone_off_time;
392   int freq0;
393   int gain0;
394   int freq1;
395   int gain1;
396 }IXJ_CADENCE_ELEMENT;
397
398 typedef enum
399 {
400   PLAY_ONCE,
401   REPEAT_LAST_ELEMENT,
402   REPEAT_ALL
403 }IXJ_CADENCE_TERM;
404
405 typedef struct
406 {
407   int elements_used;
408   IXJ_CADENCE_TERM termination;
409   IXJ_CADENCE_ELEMENT *ce;
410 }IXJ_CADENCE;
411
412 #define IXJCTL_TONE_CADENCE                     _IOW ('q', 0x9A, IXJ_CADENCE *)
413 /******************************************************************************
414 *
415 * This group of IOCTLs deal with the playback settings of the DSP
416 *
417 ******************************************************************************/
418
419 #define IXJCTL_PLAY_CODEC               _IOW ('q', 0xA0, int)
420 #define IXJCTL_PLAY_START               _IO  ('q', 0xA2)
421 #define IXJCTL_PLAY_STOP                _IO  ('q', 0xA3)
422 #define IXJCTL_PLAY_DEPTH               _IOW ('q', 0xA4, int)
423 #define IXJCTL_PLAY_VOLUME              _IOW ('q', 0xA5, int)
424 #define IXJCTL_PLAY_LEVEL               _IO  ('q', 0xA6)
425
426 /******************************************************************************
427 *
428 * This group of IOCTLs deal with the Acoustic Echo Cancellation settings
429 * of the DSP
430 *
431 * Issueing the IXJCTL_AEC_START command with a value of AEC_OFF has the
432 * same effect as IXJCTL_AEC_STOP.  This is to simplify slider bar
433 * controls.
434 ******************************************************************************/
435 #define IXJCTL_AEC_START                _IOW ('q', 0xB0, int)
436 #define IXJCTL_AEC_STOP                 _IO  ('q', 0xB1)
437
438 #define AEC_OFF   0
439 #define AEC_LOW   1
440 #define AEC_MED   2
441 #define AEC_HIGH  3
442 /******************************************************************************
443 *
444 * Call Progress Tones, DTMF, etc.
445 * Tone on and off times are in 250 microsecond intervals so
446 * ioctl(ixj1, IXJCTL_SET_TONE_ON_TIME, 360);
447 * will set the tone on time of board ixj1 to 360 * 250us = 90ms
448 * the default values of tone on and off times is 840 or 210ms
449 ******************************************************************************/
450
451 #define IXJCTL_DTMF_READY               _IOR ('q', 0xC0, int)
452 #define IXJCTL_GET_DTMF                 _IOR ('q', 0xC1, int)
453 #define IXJCTL_GET_DTMF_ASCII           _IOR ('q', 0xC2, int)
454 #define IXJCTL_EXCEPTION                _IOR ('q', 0xC4, int)
455 #define IXJCTL_PLAY_TONE                _IOW ('q', 0xC6, char)
456 #define IXJCTL_SET_TONE_ON_TIME         _IOW ('q', 0xC7, int)
457 #define IXJCTL_SET_TONE_OFF_TIME        _IOW ('q', 0xC8, int)
458 #define IXJCTL_GET_TONE_ON_TIME         _IO  ('q', 0xC9)
459 #define IXJCTL_GET_TONE_OFF_TIME        _IO  ('q', 0xCA)
460 #define IXJCTL_GET_TONE_STATE           _IO  ('q', 0xCB)
461 #define IXJCTL_BUSY                     _IO  ('q', 0xCC)
462 #define IXJCTL_RINGBACK                 _IO  ('q', 0xCD)
463 #define IXJCTL_DIALTONE                 _IO  ('q', 0xCE)
464
465 // This IOCTL replaced both IXJCTL_BUSY_STOP and IXJCTL_RINGBACK_STOP and
466 // should be used from now on to stop all Call Progress Tones.  It will
467 // actually abort any tone, regardless of time left in the tone_on_time
468 // and tone_off_time counters.
469 #define IXJCTL_CPT_STOP                 _IO  ('q', 0xCF)
470
471 /******************************************************************************
472 * LineJack specific IOCTLs
473 *
474 * The lsb 4 bits of the LED argument represent the state of each of the 4
475 * LED's on the LineJack
476 ******************************************************************************/
477
478 #define IXJCTL_SET_LED                  _IOW ('q', 0xD0, int)
479 #define IXJCTL_MIXER                    _IOW ('q', 0xD1, int)
480
481 /******************************************************************************
482
483 * The master volume controls use attenuation with 32 levels from 0 to -62dB
484 * with steps of 2dB each, the defines should be OR'ed together then sent
485 * as the parameter to the mixer command to change the mixer settings.
486
487 ******************************************************************************/
488 #define MIXER_MASTER_L          0x0100
489 #define MIXER_MASTER_R          0x0200
490 #define ATT00DB                 0x00
491 #define ATT02DB                 0x01
492 #define ATT04DB                 0x02
493 #define ATT06DB                 0x03
494 #define ATT08DB                 0x04
495 #define ATT10DB                 0x05
496 #define ATT12DB                 0x06
497 #define ATT14DB                 0x07
498 #define ATT16DB                 0x08
499 #define ATT18DB                 0x09
500 #define ATT20DB                 0x0A
501 #define ATT22DB                 0x0B
502 #define ATT24DB                 0x0C
503 #define ATT26DB                 0x0D
504 #define ATT28DB                 0x0E
505 #define ATT30DB                 0x0F
506 #define ATT32DB                 0x10
507 #define ATT34DB                 0x11
508 #define ATT36DB                 0x12
509 #define ATT38DB                 0x13
510 #define ATT40DB                 0x14
511 #define ATT42DB                 0x15
512 #define ATT44DB                 0x16
513 #define ATT46DB                 0x17
514 #define ATT48DB                 0x18
515 #define ATT50DB                 0x19
516 #define ATT52DB                 0x1A
517 #define ATT54DB                 0x1B
518 #define ATT56DB                 0x1C
519 #define ATT58DB                 0x1D
520 #define ATT60DB                 0x1E
521 #define ATT62DB                 0x1F
522 #define MASTER_MUTE             0x80
523
524 /******************************************************************************
525
526 * The input volume controls use gain with 32 levels from +12dB to -50dB
527 * with steps of 2dB each, the defines should be OR'ed together then sent
528 * as the parameter to the mixer command to change the mixer settings.
529
530 ******************************************************************************/
531 #define MIXER_PORT_CD_L         0x0600
532 #define MIXER_PORT_CD_R         0x0700
533 #define MIXER_PORT_LINE_IN_L    0x0800
534 #define MIXER_PORT_LINE_IN_R    0x0900
535 #define MIXER_PORT_POTS_REC     0x0C00
536 #define MIXER_PORT_MIC          0x0E00
537
538 #define GAIN12DB                0x00
539 #define GAIN10DB                0x01
540 #define GAIN08DB                0x02
541 #define GAIN06DB                0x03
542 #define GAIN04DB                0x04
543 #define GAIN02DB                0x05
544 #define GAIN00DB                0x06
545 #define GAIN_02DB               0x07
546 #define GAIN_04DB               0x08
547 #define GAIN_06DB               0x09
548 #define GAIN_08DB               0x0A
549 #define GAIN_10DB               0x0B
550 #define GAIN_12DB               0x0C
551 #define GAIN_14DB               0x0D
552 #define GAIN_16DB               0x0E
553 #define GAIN_18DB               0x0F
554 #define GAIN_20DB               0x10
555 #define GAIN_22DB               0x11
556 #define GAIN_24DB               0x12
557 #define GAIN_26DB               0x13
558 #define GAIN_28DB               0x14
559 #define GAIN_30DB               0x15
560 #define GAIN_32DB               0x16
561 #define GAIN_34DB               0x17
562 #define GAIN_36DB               0x18
563 #define GAIN_38DB               0x19
564 #define GAIN_40DB               0x1A
565 #define GAIN_42DB               0x1B
566 #define GAIN_44DB               0x1C
567 #define GAIN_46DB               0x1D
568 #define GAIN_48DB               0x1E
569 #define GAIN_50DB               0x1F
570 #define INPUT_MUTE              0x80
571
572 /******************************************************************************
573
574 * The POTS volume control use attenuation with 8 levels from 0dB to -28dB
575 * with steps of 4dB each, the defines should be OR'ed together then sent
576 * as the parameter to the mixer command to change the mixer settings.
577
578 ******************************************************************************/
579 #define MIXER_PORT_POTS_PLAY    0x0F00
580
581 #define POTS_ATT_00DB           0x00
582 #define POTS_ATT_04DB           0x01
583 #define POTS_ATT_08DB           0x02
584 #define POTS_ATT_12DB           0x03
585 #define POTS_ATT_16DB           0x04
586 #define POTS_ATT_20DB           0x05
587 #define POTS_ATT_24DB           0x06
588 #define POTS_ATT_28DB           0x07
589 #define POTS_MUTE               0x80
590
591 /******************************************************************************
592
593 * The DAA controls the interface to the PSTN port.  The driver loads the
594 * US coefficients by default, so if you live in a different country you
595 * need to load the set for your countries phone system.
596
597 ******************************************************************************/
598 #define IXJCTL_DAA_COEFF_SET            _IOW ('q', 0xD2, int)
599
600 #define DAA_US          1  //PITA 8kHz
601 #define DAA_UK          2  //ISAR34 8kHz
602 #define DAA_FRANCE      3  //
603 #define DAA_GERMANY     4
604 #define DAA_AUSTRALIA   5
605 #define DAA_JAPAN       6
606
607 /******************************************************************************
608
609 * Use IXJCTL_PORT to set or query the port the card is set to.  If the
610 * argument is set to PORT_QUERY, the return value of the ioctl will
611 * indicate which port is currently in use, otherwise it will change the
612 * port.
613
614 ******************************************************************************/
615 #define IXJCTL_PORT                     _IOW ('q', 0xD3, int)
616
617 #define PORT_QUERY      0
618 #define PORT_POTS       1
619 #define PORT_PSTN       2
620 #define PORT_SPEAKER    3
621 #define PORT_HANDSET    4
622
623 #define IXJCTL_PSTN_SET_STATE           _IOW ('q', 0xD4, int)
624 #define IXJCTL_PSTN_GET_STATE           _IO  ('q', 0xD5)
625
626 #define PSTN_ON_HOOK    0
627 #define PSTN_RINGING    1
628 #define PSTN_OFF_HOOK   2
629 #define PSTN_PULSE_DIAL 3
630
631 /******************************************************************************
632
633 * The DAA Analog GAIN sets 2 parameters at one time, the recieve gain (AGRR), 
634 * and the transmit gain (AGX).  OR together the components and pass them
635 * as the parameter to IXJCTL_DAA_AGAIN.  The default setting is both at 0dB.
636
637 ******************************************************************************/
638 #define IXJCTL_DAA_AGAIN                _IOW ('q', 0xD6, int)
639
640 #define AGRR00DB        0x00  // Analog gain in recieve direction 0dB
641 #define AGRR3_5DB       0x10  // Analog gain in recieve direction 3.5dB
642 #define AGRR06DB        0x30  // Analog gain in recieve direction 6dB
643
644 #define AGX00DB         0x00  // Analog gain in transmit direction 0dB
645 #define AGX_6DB         0x04  // Analog gain in transmit direction -6dB
646 #define AGX3_5DB        0x08  // Analog gain in transmit direction 3.5dB
647 #define AGX_2_5B        0x0C  // Analog gain in transmit direction -2.5dB
648
649 #define IXJCTL_PSTN_LINETEST            _IO  ('q', 0xD7)
650
651 typedef struct
652 {
653   char month[3];
654   char day[3];
655   char hour[3];
656   char min[3];
657   int numlen;
658   char number[11];
659   int namelen;
660   char name[80];
661 }IXJ_CID;
662
663 #define IXJCTL_CID                      _IOR ('q', 0xD8, IXJ_CID *)
664 /******************************************************************************
665
666 * The wink duration is tunable with this ioctl.  The default wink duration  
667 * is 320ms.  You do not need to use this ioctl if you do not require a
668 * different wink duration.
669
670 ******************************************************************************/
671 #define IXJCTL_WINK_DURATION            _IOW ('q', 0xD9, int)
672
673 /******************************************************************************
674
675 * This ioctl will connect the POTS port to the PSTN port on the LineJACK
676 * In order for this to work properly the port selection should be set to
677 * the PSTN port with IXJCTL_PORT prior to calling this ioctl.  This will
678 * enable conference calls between PSTN callers and network callers.
679 * Passing a 1 to this ioctl enables the POTS<->PSTN connection while
680 * passing a 0 turns it back off.
681
682 ******************************************************************************/
683 #define IXJCTL_POTS_PSTN                _IOW ('q', 0xDA, int)
684
685 /******************************************************************************
686 *
687 * IOCTLs added by request.
688 *
689 * IXJCTL_HZ sets the value your Linux kernel uses for HZ as defined in
690 *           /usr/include/asm/param.h, this determines the fundamental
691 *           frequency of the clock ticks on your Linux system.  The kernel
692 *           must be rebuilt if you change this value, also all modules you
693 *           use (except this one) must be recompiled.  The default value
694 *           is 100, and you only need to use this IOCTL if you use some
695 *           other value.
696 *
697 *
698 * IXJCTL_RATE sets the number of times per second that the driver polls
699 *             the DSP.  This value cannot be larger than HZ.  By
700 *             increasing both of these values, you may be able to reduce
701 *             latency because the max hang time that can exist between the
702 *             driver and the DSP will be reduced.
703 *
704 ******************************************************************************/
705
706 #define IXJCTL_HZ                       _IOW ('q', 0xE0, int)
707 #define IXJCTL_RATE                     _IOW ('q', 0xE1, int)
708 #define IXJCTL_FRAMES_READ              _IOR ('q', 0xE2, unsigned long)
709 #define IXJCTL_FRAMES_WRITTEN           _IOR ('q', 0xE3, unsigned long)
710 #define IXJCTL_READ_WAIT                _IOR ('q', 0xE4, unsigned long)
711 #define IXJCTL_WRITE_WAIT               _IOR ('q', 0xE5, unsigned long)
712 #define IXJCTL_DRYBUFFER_READ           _IOR ('q', 0xE6, unsigned long)
713 #define IXJCTL_DRYBUFFER_CLEAR          _IO  ('q', 0xE7)
714
715 /******************************************************************************
716 *
717 * The defined CODECs that can be used with the IXJCTL_REC_CODEC and
718 * IXJ_PLAY_CODEC IOCTLs.
719 *
720 * PCM uLaw mode is a "pass through" mode.
721 *
722 * 16 bit linear data is signed integer (2's complement form), positive
723 * full scale is 7FFFH, negative full scale is 8000H, zero is 0000H
724 *
725 * 8 bit linear data is signed byte (2's complement form), positive
726 * full scale is 7FH, negative full scale is 80H, zero is 00H
727 *
728 * 8 bit linear WSS data is unsigned byte, positive full scale is FFH,
729 * negative full scale is 00H, zero is 80H.  This is the format used for
730 * 8-bit WAVE format data (Windows Sound System).  Data can be converted
731 * between the two 8-bit formats by simply inverting the ms bit. 
732 *
733 * G729 currently works most reliably with 10ms frames.  Use 20ms and 30ms
734 * at your own risk.  If you really need larger frame sizes you can
735 * concatenate multiple 10ms frames.
736 *
737 ******************************************************************************/
738 typedef enum{           // Bytes per 30ms audio frame
739 G723_63 =       1,      // 24
740 G723_53 =       2,      // 20
741 TS85    =       3,      // 32 Does not currently work on LineJack
742 TS48    =       4,      // 18
743 TS41    =       5,      // 16
744 G728    =       6,      // 96 LineJack only!
745 G729    =       7,      // 30 LineJack only!
746 ULAW    =       8,      // 240
747 ALAW    =       9,      // 240 not implemented DO NOT USE!
748 LINEAR16=       10,     // 480
749 LINEAR8 =       11,     // 240
750 WSS     =       12      // 240
751 }IXJ_CODEC;
752 /******************************************************************************
753 *
754 * The intercom IOCTL's short the output from one card to the input of the
755 * other and vice versa (actually done in the DSP read function).  It is only
756 * necessary to execute the IOCTL on one card, but it is necessary to have
757 * both devices open to be able to detect hook switch changes.  The record
758 * codec and rate of each card must match the playback codec and rate of
759 * the other card for this to work properly.
760 *
761 ******************************************************************************/
762
763 #define IXJCTL_INTERCOM_START           _IOW ('q', 0xFD, int)
764 #define IXJCTL_INTERCOM_STOP            _IOW ('q', 0xFE, int) 
765
766 /******************************************************************************
767 *
768 * This IOCTL will decrement the module usage counter so you can force
769 * the module to unload after a program bombs.
770 *
771 ******************************************************************************/
772
773 #define IXJCTL_MODRESET                 _IO  ('q', 0xFF)
774
775 /******************************************************************************
776 *
777 * Various Defines used for the Quicknet Cards
778 *
779 ******************************************************************************/
780
781 #define SYNC_MODE_CODEC         0
782 #define SYNC_MODE_DATA          1
783 #define SYNC_MODE_POLL          2
784 #define SYNC_MODE_HOST          3
785
786 #define RECORD_SYNC_MODE        0x5100
787 #define PLAYBACK_SYNC_MODE      0x5200
788
789 #define USA_RING_CADENCE        0xC0C0
790
791 /******************************************************************************
792 *
793 * The exception structure allows us to multiplex multiple events onto the
794 * select() exception set.  If any of these flags are set select() will
795 * return with a positive indication on the exception set.  The dtmf_ready
796 * bit indicates if there is data waiting in the DTMF buffer.  The
797 * hookstate bit is set if there is a change in hookstate status, it does not
798 * indicate the current state of the hookswitch.  The pstn_ring bit
799 * indicates that the DAA on a LineJACK card has detected ring voltage on
800 * the PSTN port.  The caller_id bit indicates that caller_id data has been
801 * recieved and is available.  The pstn_wink bit indicates that the DAA on
802 * the LineJACK has recieved a wink from the telco switch.  The f0, f1, f2
803 * and f3 bits indicate that the filter has been triggered by detecting the
804 * frequency programmed into that filter.
805 *
806 ******************************************************************************/
807
808 typedef struct
809 {
810   unsigned int dtmf_ready:1;
811   unsigned int hookstate:1;
812   unsigned int pstn_ring:1;
813   unsigned int caller_id:1;
814   unsigned int pstn_wink:1;
815   unsigned int f0:1;
816   unsigned int f1:1;
817   unsigned int f2:1;
818   unsigned int f3:1;
819   unsigned int reserved:23;
820 }IXJ_EXCEPT;
821
822 typedef union
823 {
824   IXJ_EXCEPT bits;
825   unsigned int bytes;
826 }IXJ_EXCEPTION;
827