1 /****************************************************************************
4 * Device Driver for Quicknet Technologies, Inc.'s Telephony cards
5 * including the Internet PhoneJACK, Internet PhoneJACK Lite,
6 * Internet PhoneJACK PCI, Internet LineJACK, Internet PhoneCARD and
9 * (c) Copyright 1999-2001 Quicknet Technologies, Inc.
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
16 * Author: Ed Okerson, <eokerson@quicknet.net>
18 * Contributors: Greg Herlein, <gherlein@quicknet.net>
19 * David W. Erhart, <derhart@quicknet.net>
20 * John Sellers, <jsellers@quicknet.net>
21 * Mike Preston, <mpreston@quicknet.net>
23 * Fixes: David Huggins-Daines, <dhd@cepstral.com>
24 * Fabio Ferrari, <fabio.ferrari@digitro.com.br>
25 * Artis Kugevics, <artis@mt.lv>
26 * Daniele Bellucci, <bellucda@tiscali.it>
28 * More information about the hardware related to this driver can be found
29 * at our website: http://www.quicknet.net
31 * IN NO EVENT SHALL QUICKNET TECHNOLOGIES, INC. BE LIABLE TO ANY PARTY FOR
32 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
33 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF QUICKNET
34 * TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 * QUICKNET TECHNOLOGIES, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
37 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
38 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
39 * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION
40 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
42 ***************************************************************************/
45 * Revision 4.8 2003/07/09 19:39:00 Daniele Bellucci
46 * Audit some copy_*_user and minor cleanup.
48 * Revision 4.7 2001/08/13 06:19:33 craigs
49 * Added additional changes from Alan Cox and John Anderson for
50 * 2.2 to 2.4 cleanup and bounds checking
52 * Revision 4.6 2001/08/13 01:05:05 craigs
53 * Really fixed PHONE_QUERY_CODEC problem this time
55 * Revision 4.5 2001/08/13 00:11:03 craigs
56 * Fixed problem in handling of PHONE_QUERY_CODEC, thanks to Shane Anderson
58 * Revision 4.4 2001/08/07 07:58:12 craigs
59 * Changed back to three digit version numbers
60 * Added tagbuild target to allow automatic and easy tagging of versions
62 * Revision 4.3 2001/08/07 07:24:47 craigs
63 * Added ixj-ver.h to allow easy configuration management of driver
64 * Added display of version number in /prox/ixj
66 * Revision 4.2 2001/08/06 07:07:19 craigs
67 * Reverted IXJCTL_DSP_TYPE and IXJCTL_DSP_VERSION files to original
68 * behaviour of returning int rather than short *
70 * Revision 4.1 2001/08/05 00:17:37 craigs
71 * More changes for correct PCMCIA installation
72 * Start of changes for backward Linux compatibility
74 * Revision 4.0 2001/08/04 12:33:12 craigs
75 * New version using GNU autoconf
77 * Revision 3.105 2001/07/20 23:14:32 eokerson
78 * More work on CallerID generation when using ring cadences.
80 * Revision 3.104 2001/07/06 01:33:55 eokerson
81 * Some bugfixes from Robert Vojta <vojta@ipex.cz> and a few mods to the Makefile.
83 * Revision 3.103 2001/07/05 19:20:16 eokerson
85 * Changed mic gain to 30dB on Internet LineJACK mic/speaker port.
87 * Revision 3.102 2001/07/03 23:51:21 eokerson
88 * Un-mute mic on Internet LineJACK when in speakerphone mode.
90 * Revision 3.101 2001/07/02 19:26:56 eokerson
91 * Removed initialiazation of ixjdebug and ixj_convert_loaded so they will go in the .bss instead of the .data
93 * Revision 3.100 2001/07/02 19:18:27 eokerson
94 * Changed driver to make dynamic allocation possible. We now pass IXJ * between functions instead of array indexes.
95 * Fixed the way the POTS and PSTN ports interact during a PSTN call to allow local answering.
96 * Fixed speaker mode on Internet LineJACK.
98 * Revision 3.99 2001/05/09 14:11:16 eokerson
99 * Fixed kmalloc error in ixj_build_filter_cadence. Thanks David Chan <cat@waulogy.stanford.edu>.
101 * Revision 3.98 2001/05/08 19:55:33 eokerson
102 * Fixed POTS hookstate detection while it is connected to PSTN port.
104 * Revision 3.97 2001/05/08 00:01:04 eokerson
105 * Fixed kernel oops when sending caller ID data.
107 * Revision 3.96 2001/05/04 23:09:30 eokerson
108 * Now uses one kernel timer for each card, instead of one for the entire driver.
110 * Revision 3.95 2001/04/25 22:06:47 eokerson
111 * Fixed squawking at beginning of some G.723.1 calls.
113 * Revision 3.94 2001/04/03 23:42:00 eokerson
114 * Added linear volume ioctls
115 * Added raw filter load ioctl
117 * Revision 3.93 2001/02/27 01:00:06 eokerson
118 * Fixed blocking in CallerID.
119 * Reduced size of ixj structure for smaller driver footprint.
121 * Revision 3.92 2001/02/20 22:02:59 eokerson
122 * Fixed isapnp and pcmcia module compatibility for 2.4.x kernels.
123 * Improved PSTN ring detection.
124 * Fixed wink generation on POTS ports.
126 * Revision 3.91 2001/02/13 00:55:44 eokerson
127 * Turn AEC back on after changing frame sizes.
129 * Revision 3.90 2001/02/12 16:42:00 eokerson
130 * Added ALAW codec, thanks to Fabio Ferrari for the table based converters to make ALAW from ULAW.
132 * Revision 3.89 2001/02/12 15:41:16 eokerson
133 * Fix from Artis Kugevics - Tone gains were not being set correctly.
135 * Revision 3.88 2001/02/05 23:25:42 eokerson
136 * Fixed lockup bugs with deregister.
138 * Revision 3.87 2001/01/29 21:00:39 eokerson
139 * Fix from Fabio Ferrari <fabio.ferrari@digitro.com.br> to properly handle EAGAIN and EINTR during non-blocking write.
140 * Updated copyright date.
142 * Revision 3.86 2001/01/23 23:53:46 eokerson
143 * Fixes to G.729 compatibility.
145 * Revision 3.85 2001/01/23 21:30:36 eokerson
146 * Added verbage about cards supported.
147 * Removed commands that put the card in low power mode at some times that it should not be in low power mode.
149 * Revision 3.84 2001/01/22 23:32:10 eokerson
150 * Some bugfixes from David Huggins-Daines, <dhd@cepstral.com> and other cleanups.
152 * Revision 3.83 2001/01/19 14:51:41 eokerson
153 * Fixed ixj_WriteDSPCommand to decrement usage counter when command fails.
155 * Revision 3.82 2001/01/19 00:34:49 eokerson
156 * Added verbosity to write overlap errors.
158 * Revision 3.81 2001/01/18 23:56:54 eokerson
159 * Fixed PSTN line test functions.
161 * Revision 3.80 2001/01/18 22:29:27 eokerson
162 * Updated AEC/AGC values for different cards.
164 * Revision 3.79 2001/01/17 02:58:54 eokerson
165 * Fixed AEC reset after Caller ID.
166 * Fixed Codec lockup after Caller ID on Call Waiting when not using 30ms frames.
168 * Revision 3.78 2001/01/16 19:43:09 eokerson
169 * Added support for Linux 2.4.x kernels.
171 * Revision 3.77 2001/01/09 04:00:52 eokerson
172 * Linetest will now test the line, even if it has previously succeeded.
174 * Revision 3.76 2001/01/08 19:27:00 eokerson
175 * Fixed problem with standard cable on Internet PhoneCARD.
177 * Revision 3.75 2000/12/22 16:52:14 eokerson
178 * Modified to allow hookstate detection on the POTS port when the PSTN port is selected.
180 * Revision 3.74 2000/12/08 22:41:50 eokerson
181 * Added capability for G729B.
183 * Revision 3.73 2000/12/07 23:35:16 eokerson
184 * Added capability to have different ring pattern before CallerID data.
185 * Added hookstate checks in CallerID routines to stop FSK.
187 * Revision 3.72 2000/12/06 19:31:31 eokerson
188 * Modified signal behavior to only send one signal per event.
190 * Revision 3.71 2000/12/06 03:23:08 eokerson
191 * Fixed CallerID on Call Waiting.
193 * Revision 3.70 2000/12/04 21:29:37 eokerson
194 * Added checking to Smart Cable gain functions.
196 * Revision 3.69 2000/12/04 21:05:20 eokerson
197 * Changed ixjdebug levels.
198 * Added ioctls to change gains in Internet Phone CARD Smart Cable.
200 * Revision 3.68 2000/12/04 00:17:21 craigs
201 * Changed mixer voice gain to +6dB rather than 0dB
203 * Revision 3.67 2000/11/30 21:25:51 eokerson
204 * Fixed write signal errors.
206 * Revision 3.66 2000/11/29 22:42:44 eokerson
207 * Fixed PSTN ring detect problems.
209 * Revision 3.65 2000/11/29 07:31:55 craigs
210 * Added new 425Hz filter co-efficients
211 * Added card-specific DTMF prescaler initialisation
213 * Revision 3.64 2000/11/28 14:03:32 craigs
214 * Changed certain mixer initialisations to be 0dB rather than 12dB
215 * Added additional information to /proc/ixj
217 * Revision 3.63 2000/11/28 11:38:41 craigs
218 * Added display of AEC modes in AUTO and AGC mode
220 * Revision 3.62 2000/11/28 04:05:44 eokerson
221 * Improved PSTN ring detection routine.
223 * Revision 3.61 2000/11/27 21:53:12 eokerson
224 * Fixed flash detection.
226 * Revision 3.60 2000/11/27 15:57:29 eokerson
227 * More work on G.729 load routines.
229 * Revision 3.59 2000/11/25 21:55:12 eokerson
230 * Fixed errors in G.729 load routine.
232 * Revision 3.58 2000/11/25 04:08:29 eokerson
233 * Added board locks around G.729 and TS85 load routines.
235 * Revision 3.57 2000/11/24 05:35:17 craigs
236 * Added ability to retrieve mixer values on LineJACK
237 * Added complete initialisation of all mixer values at startup
238 * Fixed spelling mistake
240 * Revision 3.56 2000/11/23 02:52:11 robertj
241 * Added cvs change log keyword.
242 * Fixed bug in capabilities list when using G.729 module.
248 #define PERFMON_STATS
252 #include <linux/module.h>
254 #include <linux/init.h>
255 #include <linux/sched.h>
256 #include <linux/kernel.h> /* printk() */
257 #include <linux/fs.h> /* everything... */
258 #include <linux/errno.h> /* error codes */
259 #include <linux/slab.h>
260 #include <linux/mutex.h>
261 #include <linux/mm.h>
262 #include <linux/ioport.h>
263 #include <linux/interrupt.h>
264 #include <linux/proc_fs.h>
265 #include <linux/poll.h>
266 #include <linux/timer.h>
267 #include <linux/delay.h>
268 #include <linux/pci.h>
271 #include <asm/uaccess.h>
273 #include <linux/isapnp.h>
277 #define TYPE(inode) (iminor(inode) >> 4)
278 #define NUM(inode) (iminor(inode) & 0xf)
280 static DEFINE_MUTEX(ixj_mutex);
282 static int hertz = HZ;
283 static int samplerate = 100;
285 module_param(ixjdebug, int, 0);
287 static DEFINE_PCI_DEVICE_TABLE(ixj_pci_tbl) = {
288 { PCI_VENDOR_ID_QUICKNET, PCI_DEVICE_ID_QUICKNET_XJ,
289 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
292 MODULE_DEVICE_TABLE(pci, ixj_pci_tbl);
294 /************************************************************************
296 * ixjdebug meanings are now bit mapped instead of level based
297 * Values can be or'ed together to turn on multiple messages
299 * bit 0 (0x0001) = any failure
300 * bit 1 (0x0002) = general messages
301 * bit 2 (0x0004) = POTS ringing related
302 * bit 3 (0x0008) = PSTN events
303 * bit 4 (0x0010) = PSTN Cadence state details
304 * bit 5 (0x0020) = Tone detection triggers
305 * bit 6 (0x0040) = Tone detection cadence details
306 * bit 7 (0x0080) = ioctl tracking
307 * bit 8 (0x0100) = signal tracking
308 * bit 9 (0x0200) = CallerID generation details
310 ************************************************************************/
314 static IXJ *ixj[IXJMAX];
315 #define get_ixj(b) ixj[(b)]
318 * Allocate a free IXJ device
321 static IXJ *ixj_alloc()
323 for(cnt=0; cnt<IXJMAX; cnt++)
325 if(ixj[cnt] == NULL || !ixj[cnt]->DSPbase)
327 j = kmalloc(sizeof(IXJ), GFP_KERNEL);
337 static void ixj_fsk_free(IXJ *j)
343 static void ixj_fsk_alloc(IXJ *j)
346 j->fskdata = kmalloc(8000, GFP_KERNEL);
348 if(ixjdebug & 0x0200) {
349 printk("IXJ phone%d - allocate failed\n", j->board);
354 if(ixjdebug & 0x0200) {
355 printk("IXJ phone%d - allocate succeeded\n", j->board);
363 static IXJ ixj[IXJMAX];
364 #define get_ixj(b) (&ixj[(b)])
367 * Allocate a free IXJ device
370 static IXJ *ixj_alloc(void)
373 for(cnt=0; cnt<IXJMAX; cnt++) {
374 if(!ixj[cnt].DSPbase)
380 static inline void ixj_fsk_free(IXJ *j) {;}
382 static inline void ixj_fsk_alloc(IXJ *j)
390 #define ixj_perfmon(x) ((x)++)
392 #define ixj_perfmon(x) do { } while(0)
395 static int ixj_convert_loaded;
397 static int ixj_WriteDSPCommand(unsigned short, IXJ *j);
399 /************************************************************************
401 * These are function definitions to allow external modules to register
402 * enhanced functionality call backs.
404 ************************************************************************/
406 static int Stub(IXJ * J, unsigned long arg)
411 static IXJ_REGFUNC ixj_PreRead = &Stub;
412 static IXJ_REGFUNC ixj_PostRead = &Stub;
413 static IXJ_REGFUNC ixj_PreWrite = &Stub;
414 static IXJ_REGFUNC ixj_PostWrite = &Stub;
416 static void ixj_read_frame(IXJ *j);
417 static void ixj_write_frame(IXJ *j);
418 static void ixj_init_timer(IXJ *j);
419 static void ixj_add_timer(IXJ * j);
420 static void ixj_timeout(unsigned long ptr);
421 static int read_filters(IXJ *j);
422 static int LineMonitor(IXJ *j);
423 static int ixj_fasync(int fd, struct file *, int mode);
424 static int ixj_set_port(IXJ *j, int arg);
425 static int ixj_set_pots(IXJ *j, int arg);
426 static int ixj_hookstate(IXJ *j);
427 static int ixj_record_start(IXJ *j);
428 static void ixj_record_stop(IXJ *j);
429 static void set_rec_volume(IXJ *j, int volume);
430 static int get_rec_volume(IXJ *j);
431 static int set_rec_codec(IXJ *j, int rate);
432 static void ixj_vad(IXJ *j, int arg);
433 static int ixj_play_start(IXJ *j);
434 static void ixj_play_stop(IXJ *j);
435 static int ixj_set_tone_on(unsigned short arg, IXJ *j);
436 static int ixj_set_tone_off(unsigned short, IXJ *j);
437 static int ixj_play_tone(IXJ *j, char tone);
438 static void ixj_aec_start(IXJ *j, int level);
439 static int idle(IXJ *j);
440 static void ixj_ring_on(IXJ *j);
441 static void ixj_ring_off(IXJ *j);
442 static void aec_stop(IXJ *j);
443 static void ixj_ringback(IXJ *j);
444 static void ixj_busytone(IXJ *j);
445 static void ixj_dialtone(IXJ *j);
446 static void ixj_cpt_stop(IXJ *j);
447 static char daa_int_read(IXJ *j);
448 static char daa_CR_read(IXJ *j, int cr);
449 static int daa_set_mode(IXJ *j, int mode);
450 static int ixj_linetest(IXJ *j);
451 static int ixj_daa_write(IXJ *j);
452 static int ixj_daa_cid_read(IXJ *j);
453 static void DAA_Coeff_US(IXJ *j);
454 static void DAA_Coeff_UK(IXJ *j);
455 static void DAA_Coeff_France(IXJ *j);
456 static void DAA_Coeff_Germany(IXJ *j);
457 static void DAA_Coeff_Australia(IXJ *j);
458 static void DAA_Coeff_Japan(IXJ *j);
459 static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf);
460 static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr);
461 static int ixj_init_tone(IXJ *j, IXJ_TONE * ti);
462 static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp);
463 static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp);
464 /* Serial Control Interface funtions */
465 static int SCI_Control(IXJ *j, int control);
466 static int SCI_Prepare(IXJ *j);
467 static int SCI_WaitHighSCI(IXJ *j);
468 static int SCI_WaitLowSCI(IXJ *j);
469 static DWORD PCIEE_GetSerialNumber(WORD wAddress);
470 static int ixj_PCcontrol_wait(IXJ *j);
471 static void ixj_pre_cid(IXJ *j);
472 static void ixj_write_cid(IXJ *j);
473 static void ixj_write_cid_bit(IXJ *j, int bit);
474 static int set_base_frame(IXJ *j, int size);
475 static int set_play_codec(IXJ *j, int rate);
476 static void set_rec_depth(IXJ *j, int depth);
477 static int ixj_mixer(long val, IXJ *j);
479 /************************************************************************
480 CT8020/CT8021 Host Programmers Model
481 Host address Function Access
483 0-1 Aux Software Status Register (reserved) Read Only
484 2-3 Software Status Register Read Only
485 4-5 Aux Software Control Register (reserved) Read Write
486 6-7 Software Control Register Read Write
487 8-9 Hardware Status Register Read Only
488 A-B Hardware Control Register Read Write
489 C-D Host Transmit (Write) Data Buffer Access Port (buffer input)Write Only
490 E-F Host Receive (Read) Data Buffer Access Port (buffer input) Read Only
491 ************************************************************************/
493 static inline void ixj_read_HSR(IXJ *j)
495 j->hsr.bytes.low = inb_p(j->DSPbase + 8);
496 j->hsr.bytes.high = inb_p(j->DSPbase + 9);
499 static inline int IsControlReady(IXJ *j)
502 return j->hsr.bits.controlrdy ? 1 : 0;
505 static inline int IsPCControlReady(IXJ *j)
507 j->pccr1.byte = inb_p(j->XILINXbase + 3);
508 return j->pccr1.bits.crr ? 1 : 0;
511 static inline int IsStatusReady(IXJ *j)
514 return j->hsr.bits.statusrdy ? 1 : 0;
517 static inline int IsRxReady(IXJ *j)
520 ixj_perfmon(j->rxreadycheck);
521 return j->hsr.bits.rxrdy ? 1 : 0;
524 static inline int IsTxReady(IXJ *j)
527 ixj_perfmon(j->txreadycheck);
528 return j->hsr.bits.txrdy ? 1 : 0;
531 static inline void set_play_volume(IXJ *j, int volume)
533 if (ixjdebug & 0x0002)
534 printk(KERN_INFO "IXJ: /dev/phone%d Setting Play Volume to 0x%4.4x\n", j->board, volume);
535 ixj_WriteDSPCommand(0xCF02, j);
536 ixj_WriteDSPCommand(volume, j);
539 static int set_play_volume_linear(IXJ *j, int volume)
541 int newvolume, dspplaymax;
543 if (ixjdebug & 0x0002)
544 printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Play Volume to 0x%4.4x\n", j->board, volume);
545 if(volume > 100 || volume < 0) {
549 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
550 switch (j->cardtype) {
555 if(j->port == PORT_PSTN) {
561 case QTI_PHONEJACK_LITE:
564 case QTI_PHONEJACK_PCI:
573 newvolume = (dspplaymax * volume) / 100;
574 set_play_volume(j, newvolume);
578 static inline void set_play_depth(IXJ *j, int depth)
584 ixj_WriteDSPCommand(0x5280 + depth, j);
587 static inline int get_play_volume(IXJ *j)
589 ixj_WriteDSPCommand(0xCF00, j);
590 return j->ssr.high << 8 | j->ssr.low;
593 static int get_play_volume_linear(IXJ *j)
595 int volume, newvolume, dspplaymax;
597 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
598 switch (j->cardtype) {
603 if(j->port == PORT_PSTN) {
609 case QTI_PHONEJACK_LITE:
612 case QTI_PHONEJACK_PCI:
621 volume = get_play_volume(j);
622 newvolume = (volume * 100) / dspplaymax;
628 static inline BYTE SLIC_GetState(IXJ *j)
630 if (j->cardtype == QTI_PHONECARD) {
632 j->psccr.bits.dev = 3;
633 j->psccr.bits.rw = 1;
634 outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
635 ixj_PCcontrol_wait(j);
636 j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
637 ixj_PCcontrol_wait(j);
638 if (j->pslic.bits.powerdown)
639 return PLD_SLIC_STATE_OC;
640 else if (!j->pslic.bits.ring0 && !j->pslic.bits.ring1)
641 return PLD_SLIC_STATE_ACTIVE;
643 return PLD_SLIC_STATE_RINGING;
645 j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
647 return j->pld_slicr.bits.state;
650 static bool SLIC_SetState(BYTE byState, IXJ *j)
652 bool fRetVal = false;
654 if (j->cardtype == QTI_PHONECARD) {
655 if (j->flags.pcmciasct) {
657 case PLD_SLIC_STATE_TIPOPEN:
658 case PLD_SLIC_STATE_OC:
659 j->pslic.bits.powerdown = 1;
660 j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
663 case PLD_SLIC_STATE_RINGING:
664 if (j->readers || j->writers) {
665 j->pslic.bits.powerdown = 0;
666 j->pslic.bits.ring0 = 1;
667 j->pslic.bits.ring1 = 0;
671 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
673 case PLD_SLIC_STATE_STANDBY:
674 case PLD_SLIC_STATE_ACTIVE:
675 if (j->readers || j->writers) {
676 j->pslic.bits.powerdown = 0;
678 j->pslic.bits.powerdown = 1;
680 j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
683 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
685 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
691 j->psccr.bits.dev = 3;
692 j->psccr.bits.rw = 0;
693 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
694 ixj_PCcontrol_wait(j);
697 /* Set the C1, C2, C3 & B2EN signals. */
699 case PLD_SLIC_STATE_OC:
700 j->pld_slicw.bits.c1 = 0;
701 j->pld_slicw.bits.c2 = 0;
702 j->pld_slicw.bits.c3 = 0;
703 j->pld_slicw.bits.b2en = 0;
704 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
707 case PLD_SLIC_STATE_RINGING:
708 j->pld_slicw.bits.c1 = 1;
709 j->pld_slicw.bits.c2 = 0;
710 j->pld_slicw.bits.c3 = 0;
711 j->pld_slicw.bits.b2en = 1;
712 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
715 case PLD_SLIC_STATE_ACTIVE:
716 j->pld_slicw.bits.c1 = 0;
717 j->pld_slicw.bits.c2 = 1;
718 j->pld_slicw.bits.c3 = 0;
719 j->pld_slicw.bits.b2en = 0;
720 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
723 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
725 j->pld_slicw.bits.c1 = 1;
726 j->pld_slicw.bits.c2 = 1;
727 j->pld_slicw.bits.c3 = 0;
728 j->pld_slicw.bits.b2en = 0;
729 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
732 case PLD_SLIC_STATE_TIPOPEN:
733 j->pld_slicw.bits.c1 = 0;
734 j->pld_slicw.bits.c2 = 0;
735 j->pld_slicw.bits.c3 = 1;
736 j->pld_slicw.bits.b2en = 0;
737 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
740 case PLD_SLIC_STATE_STANDBY:
741 j->pld_slicw.bits.c1 = 1;
742 j->pld_slicw.bits.c2 = 0;
743 j->pld_slicw.bits.c3 = 1;
744 j->pld_slicw.bits.b2en = 1;
745 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
748 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
750 j->pld_slicw.bits.c1 = 0;
751 j->pld_slicw.bits.c2 = 1;
752 j->pld_slicw.bits.c3 = 1;
753 j->pld_slicw.bits.b2en = 0;
754 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
757 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
759 j->pld_slicw.bits.c1 = 1;
760 j->pld_slicw.bits.c2 = 1;
761 j->pld_slicw.bits.c3 = 1;
762 j->pld_slicw.bits.b2en = 0;
763 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
775 static int ixj_wink(IXJ *j)
779 slicnow = SLIC_GetState(j);
781 j->pots_winkstart = jiffies;
782 SLIC_SetState(PLD_SLIC_STATE_OC, j);
784 msleep(jiffies_to_msecs(j->winktime));
786 SLIC_SetState(slicnow, j);
790 static void ixj_init_timer(IXJ *j)
792 init_timer(&j->timer);
793 j->timer.function = ixj_timeout;
794 j->timer.data = (unsigned long)j;
797 static void ixj_add_timer(IXJ *j)
799 j->timer.expires = jiffies + (hertz / samplerate);
800 add_timer(&j->timer);
803 static void ixj_tone_timeout(IXJ *j)
808 if (j->tone_state == 3) {
811 j->tone_cadence_state++;
812 if (j->tone_cadence_state >= j->cadence_t->elements_used) {
813 switch (j->cadence_t->termination) {
817 case REPEAT_LAST_ELEMENT:
818 j->tone_cadence_state--;
819 ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
822 j->tone_cadence_state = 0;
823 if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
824 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
825 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
826 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
827 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
828 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
829 ixj_init_tone(j, &ti);
831 ixj_set_tone_on(j->cadence_t->ce[0].tone_on_time, j);
832 ixj_set_tone_off(j->cadence_t->ce[0].tone_off_time, j);
833 ixj_play_tone(j, j->cadence_t->ce[0].index);
837 if (j->cadence_t->ce[j->tone_cadence_state].gain0) {
838 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
839 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
840 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
841 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
842 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
843 ixj_init_tone(j, &ti);
845 ixj_set_tone_on(j->cadence_t->ce[j->tone_cadence_state].tone_on_time, j);
846 ixj_set_tone_off(j->cadence_t->ce[j->tone_cadence_state].tone_off_time, j);
847 ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
853 static inline void ixj_kill_fasync(IXJ *j, IXJ_SIGEVENT event, int dir)
855 if(j->ixj_signals[event]) {
856 if(ixjdebug & 0x0100)
857 printk("Sending signal for event %d\n", event);
858 /* Send apps notice of change */
859 /* see config.h for macro definition */
860 kill_fasync(&(j->async_queue), j->ixj_signals[event], dir);
864 static void ixj_pstn_state(IXJ *j)
867 union XOPXR0 XR0, daaint;
871 XR0.reg = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg;
873 XR0.bitreg.RMR = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
875 j->pld_scrr.byte = inb_p(j->XILINXbase);
876 if (j->pld_scrr.bits.daaflag) {
878 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.RING) {
879 if(time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) {
880 daaint.bitreg.RING = 1;
881 if(ixjdebug & 0x0008) {
882 printk(KERN_INFO "IXJ DAA Ring Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
885 daa_set_mode(j, SOP_PU_RESET);
888 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Caller_ID) {
889 daaint.bitreg.Caller_ID = 1;
890 j->pstn_cid_intr = 1;
891 j->pstn_cid_received = jiffies;
892 if(ixjdebug & 0x0008) {
893 printk(KERN_INFO "IXJ DAA Caller_ID Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
896 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Cadence) {
897 daaint.bitreg.Cadence = 1;
898 if(ixjdebug & 0x0008) {
899 printk(KERN_INFO "IXJ DAA Cadence Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
902 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK != XR0.bitreg.VDD_OK) {
903 daaint.bitreg.VDD_OK = 1;
904 daaint.bitreg.SI_0 = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK;
908 if(j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR != XR0.bitreg.RMR && time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) {
909 daaint.bitreg.RMR = 1;
910 daaint.bitreg.SI_1 = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
911 if(ixjdebug & 0x0008) {
912 printk(KERN_INFO "IXJ DAA RMR /dev/phone%d was %s for %ld\n", j->board, XR0.bitreg.RMR?"on":"off", jiffies - j->pstn_last_rmr);
914 j->pstn_prev_rmr = j->pstn_last_rmr;
915 j->pstn_last_rmr = jiffies;
917 switch(j->daa_mode) {
919 if (daaint.bitreg.RING) {
920 if (!j->flags.pstn_ringing) {
921 if (j->daa_mode != SOP_PU_RINGING) {
922 j->pstn_ring_int = jiffies;
923 daa_set_mode(j, SOP_PU_RINGING);
929 if (daaint.bitreg.RMR) {
930 if (ixjdebug & 0x0008) {
931 printk(KERN_INFO "IXJ Ring Cadence a state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
933 if (daaint.bitreg.SI_1) { /* Rising edge of RMR */
934 j->flags.pstn_rmr = 1;
935 j->pstn_ring_start = jiffies;
936 j->pstn_ring_stop = 0;
937 j->ex.bits.pstn_ring = 0;
938 if (j->cadence_f[4].state == 0) {
939 j->cadence_f[4].state = 1;
940 j->cadence_f[4].on1min = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 - var)) / 10000);
941 j->cadence_f[4].on1dot = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100)) / 10000);
942 j->cadence_f[4].on1max = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 + var)) / 10000);
943 } else if (j->cadence_f[4].state == 2) {
944 if((time_after(jiffies, j->cadence_f[4].off1min) &&
945 time_before(jiffies, j->cadence_f[4].off1max))) {
946 if (j->cadence_f[4].on2) {
947 j->cadence_f[4].state = 3;
948 j->cadence_f[4].on2min = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 - var)) / 10000));
949 j->cadence_f[4].on2dot = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100)) / 10000));
950 j->cadence_f[4].on2max = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 + var)) / 10000));
952 j->cadence_f[4].state = 7;
955 if (ixjdebug & 0x0008) {
956 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
957 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
958 j->cadence_f[4].off1);
960 j->cadence_f[4].state = 0;
962 } else if (j->cadence_f[4].state == 4) {
963 if((time_after(jiffies, j->cadence_f[4].off2min) &&
964 time_before(jiffies, j->cadence_f[4].off2max))) {
965 if (j->cadence_f[4].on3) {
966 j->cadence_f[4].state = 5;
967 j->cadence_f[4].on3min = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 - var)) / 10000));
968 j->cadence_f[4].on3dot = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100)) / 10000));
969 j->cadence_f[4].on3max = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 + var)) / 10000));
971 j->cadence_f[4].state = 7;
974 if (ixjdebug & 0x0008) {
975 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
976 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
977 j->cadence_f[4].off2);
979 j->cadence_f[4].state = 0;
981 } else if (j->cadence_f[4].state == 6) {
982 if((time_after(jiffies, j->cadence_f[4].off3min) &&
983 time_before(jiffies, j->cadence_f[4].off3max))) {
984 j->cadence_f[4].state = 7;
986 if (ixjdebug & 0x0008) {
987 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
988 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
989 j->cadence_f[4].off3);
991 j->cadence_f[4].state = 0;
994 j->cadence_f[4].state = 0;
996 } else { /* Falling edge of RMR */
997 j->pstn_ring_start = 0;
998 j->pstn_ring_stop = jiffies;
999 if (j->cadence_f[4].state == 1) {
1000 if(!j->cadence_f[4].on1) {
1001 j->cadence_f[4].state = 7;
1002 } else if((time_after(jiffies, j->cadence_f[4].on1min) &&
1003 time_before(jiffies, j->cadence_f[4].on1max))) {
1004 if (j->cadence_f[4].off1) {
1005 j->cadence_f[4].state = 2;
1006 j->cadence_f[4].off1min = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 - var)) / 10000));
1007 j->cadence_f[4].off1dot = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100)) / 10000));
1008 j->cadence_f[4].off1max = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 + var)) / 10000));
1010 j->cadence_f[4].state = 7;
1013 if (ixjdebug & 0x0008) {
1014 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1015 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1016 j->cadence_f[4].on1);
1018 j->cadence_f[4].state = 0;
1020 } else if (j->cadence_f[4].state == 3) {
1021 if((time_after(jiffies, j->cadence_f[4].on2min) &&
1022 time_before(jiffies, j->cadence_f[4].on2max))) {
1023 if (j->cadence_f[4].off2) {
1024 j->cadence_f[4].state = 4;
1025 j->cadence_f[4].off2min = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 - var)) / 10000));
1026 j->cadence_f[4].off2dot = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100)) / 10000));
1027 j->cadence_f[4].off2max = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 + var)) / 10000));
1029 j->cadence_f[4].state = 7;
1032 if (ixjdebug & 0x0008) {
1033 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1034 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1035 j->cadence_f[4].on2);
1037 j->cadence_f[4].state = 0;
1039 } else if (j->cadence_f[4].state == 5) {
1040 if((time_after(jiffies, j->cadence_f[4].on3min) &&
1041 time_before(jiffies, j->cadence_f[4].on3max))) {
1042 if (j->cadence_f[4].off3) {
1043 j->cadence_f[4].state = 6;
1044 j->cadence_f[4].off3min = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 - var)) / 10000));
1045 j->cadence_f[4].off3dot = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100)) / 10000));
1046 j->cadence_f[4].off3max = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 + var)) / 10000));
1048 j->cadence_f[4].state = 7;
1051 j->cadence_f[4].state = 0;
1054 if (ixjdebug & 0x0008) {
1055 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1056 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1057 j->cadence_f[4].on3);
1059 j->cadence_f[4].state = 0;
1062 if (ixjdebug & 0x0010) {
1063 printk(KERN_INFO "IXJ Ring Cadence b state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
1065 if (ixjdebug & 0x0010) {
1066 switch(j->cadence_f[4].state) {
1068 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1069 j->cadence_f[4].on1, j->cadence_f[4].on1min, j->cadence_f[4].on1dot, j->cadence_f[4].on1max);
1072 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1073 j->cadence_f[4].off1, j->cadence_f[4].off1min, j->cadence_f[4].off1dot, j->cadence_f[4].off1max);
1076 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1077 j->cadence_f[4].on2, j->cadence_f[4].on2min, j->cadence_f[4].on2dot, j->cadence_f[4].on2max);
1080 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1081 j->cadence_f[4].off2, j->cadence_f[4].off2min, j->cadence_f[4].off2dot, j->cadence_f[4].off2max);
1084 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1085 j->cadence_f[4].on3, j->cadence_f[4].on3min, j->cadence_f[4].on3dot, j->cadence_f[4].on3max);
1088 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1089 j->cadence_f[4].off3, j->cadence_f[4].off3min, j->cadence_f[4].off3dot, j->cadence_f[4].off3max);
1094 if (j->cadence_f[4].state == 7) {
1095 j->cadence_f[4].state = 0;
1096 j->pstn_ring_stop = jiffies;
1097 j->ex.bits.pstn_ring = 1;
1098 ixj_kill_fasync(j, SIG_PSTN_RING, POLL_IN);
1099 if(ixjdebug & 0x0008) {
1100 printk(KERN_INFO "IXJ Ring int set /dev/phone%d at %ld\n", j->board, jiffies);
1103 if((j->pstn_ring_int != 0 && time_after(jiffies, j->pstn_ring_int + (hertz * 5)) && !j->flags.pstn_rmr) ||
1104 (j->pstn_ring_stop != 0 && time_after(jiffies, j->pstn_ring_stop + (hertz * 5)))) {
1105 if(ixjdebug & 0x0008) {
1106 printk("IXJ DAA no ring in 5 seconds /dev/phone%d at %ld\n", j->board, jiffies);
1107 printk("IXJ DAA pstn ring int /dev/phone%d at %ld\n", j->board, j->pstn_ring_int);
1108 printk("IXJ DAA pstn ring stop /dev/phone%d at %ld\n", j->board, j->pstn_ring_stop);
1110 j->pstn_ring_stop = j->pstn_ring_int = 0;
1111 daa_set_mode(j, SOP_PU_SLEEP);
1113 outb_p(j->pld_scrw.byte, j->XILINXbase);
1114 if (j->pstn_cid_intr && time_after(jiffies, j->pstn_cid_received + hertz)) {
1115 ixj_daa_cid_read(j);
1116 j->ex.bits.caller_id = 1;
1117 ixj_kill_fasync(j, SIG_CALLER_ID, POLL_IN);
1118 j->pstn_cid_intr = 0;
1120 if (daaint.bitreg.Cadence) {
1121 if(ixjdebug & 0x0008) {
1122 printk("IXJ DAA Cadence interrupt going to sleep /dev/phone%d\n", j->board);
1124 daa_set_mode(j, SOP_PU_SLEEP);
1125 j->ex.bits.pstn_ring = 0;
1128 case SOP_PU_CONVERSATION:
1129 if (daaint.bitreg.VDD_OK) {
1130 if(!daaint.bitreg.SI_0) {
1131 if (!j->pstn_winkstart) {
1132 if(ixjdebug & 0x0008) {
1133 printk("IXJ DAA possible wink /dev/phone%d %ld\n", j->board, jiffies);
1135 j->pstn_winkstart = jiffies;
1138 if (j->pstn_winkstart) {
1139 if(ixjdebug & 0x0008) {
1140 printk("IXJ DAA possible wink end /dev/phone%d %ld\n", j->board, jiffies);
1142 j->pstn_winkstart = 0;
1146 if (j->pstn_winkstart && time_after(jiffies, j->pstn_winkstart + ((hertz * j->winktime) / 1000))) {
1147 if(ixjdebug & 0x0008) {
1148 printk("IXJ DAA wink detected going to sleep /dev/phone%d %ld\n", j->board, jiffies);
1150 daa_set_mode(j, SOP_PU_SLEEP);
1151 j->pstn_winkstart = 0;
1152 j->ex.bits.pstn_wink = 1;
1153 ixj_kill_fasync(j, SIG_PSTN_WINK, POLL_IN);
1159 static void ixj_timeout(unsigned long ptr)
1162 unsigned long jifon;
1163 IXJ *j = (IXJ *)ptr;
1166 if (j->DSPbase && atomic_read(&j->DSPWrite) == 0 && test_and_set_bit(board, (void *)&j->busyflags) == 0) {
1167 ixj_perfmon(j->timerchecks);
1168 j->hookstate = ixj_hookstate(j);
1169 if (j->tone_state) {
1170 if (!(j->hookstate)) {
1174 j->ex.bits.hookstate = 1;
1175 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1177 clear_bit(board, &j->busyflags);
1181 if (j->tone_state == 1)
1182 jifon = ((hertz * j->tone_on_time) * 25 / 100000);
1184 jifon = ((hertz * j->tone_on_time) * 25 / 100000) + ((hertz * j->tone_off_time) * 25 / 100000);
1185 if (time_before(jiffies, j->tone_start_jif + jifon)) {
1186 if (j->tone_state == 1) {
1187 ixj_play_tone(j, j->tone_index);
1188 if (j->dsp.low == 0x20) {
1189 clear_bit(board, &j->busyflags);
1194 ixj_play_tone(j, 0);
1195 if (j->dsp.low == 0x20) {
1196 clear_bit(board, &j->busyflags);
1202 ixj_tone_timeout(j);
1203 if (j->flags.dialtone) {
1206 if (j->flags.busytone) {
1208 if (j->dsp.low == 0x20) {
1209 clear_bit(board, &j->busyflags);
1214 if (j->flags.ringback) {
1216 if (j->dsp.low == 0x20) {
1217 clear_bit(board, &j->busyflags);
1222 if (!j->tone_state) {
1227 if (!(j->tone_state && j->dsp.low == 0x20)) {
1235 if (j->flags.cringing) {
1236 if (j->hookstate & 1) {
1237 j->flags.cringing = 0;
1239 } else if(j->cadence_f[5].enable && ((!j->cadence_f[5].en_filter) || (j->cadence_f[5].en_filter && j->flags.firstring))) {
1240 switch(j->cadence_f[5].state) {
1242 j->cadence_f[5].on1dot = jiffies + (long)((j->cadence_f[5].on1 * (hertz * 100) / 10000));
1243 if (time_before(jiffies, j->cadence_f[5].on1dot)) {
1244 if(ixjdebug & 0x0004) {
1245 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1249 j->cadence_f[5].state = 1;
1252 if (time_after(jiffies, j->cadence_f[5].on1dot)) {
1253 j->cadence_f[5].off1dot = jiffies + (long)((j->cadence_f[5].off1 * (hertz * 100) / 10000));
1254 if(ixjdebug & 0x0004) {
1255 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1258 j->cadence_f[5].state = 2;
1262 if (time_after(jiffies, j->cadence_f[5].off1dot)) {
1263 if(ixjdebug & 0x0004) {
1264 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1267 if (j->cadence_f[5].on2) {
1268 j->cadence_f[5].on2dot = jiffies + (long)((j->cadence_f[5].on2 * (hertz * 100) / 10000));
1269 j->cadence_f[5].state = 3;
1271 j->cadence_f[5].state = 7;
1276 if (time_after(jiffies, j->cadence_f[5].on2dot)) {
1277 if(ixjdebug & 0x0004) {
1278 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1281 if (j->cadence_f[5].off2) {
1282 j->cadence_f[5].off2dot = jiffies + (long)((j->cadence_f[5].off2 * (hertz * 100) / 10000));
1283 j->cadence_f[5].state = 4;
1285 j->cadence_f[5].state = 7;
1290 if (time_after(jiffies, j->cadence_f[5].off2dot)) {
1291 if(ixjdebug & 0x0004) {
1292 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1295 if (j->cadence_f[5].on3) {
1296 j->cadence_f[5].on3dot = jiffies + (long)((j->cadence_f[5].on3 * (hertz * 100) / 10000));
1297 j->cadence_f[5].state = 5;
1299 j->cadence_f[5].state = 7;
1304 if (time_after(jiffies, j->cadence_f[5].on3dot)) {
1305 if(ixjdebug & 0x0004) {
1306 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1309 if (j->cadence_f[5].off3) {
1310 j->cadence_f[5].off3dot = jiffies + (long)((j->cadence_f[5].off3 * (hertz * 100) / 10000));
1311 j->cadence_f[5].state = 6;
1313 j->cadence_f[5].state = 7;
1318 if (time_after(jiffies, j->cadence_f[5].off3dot)) {
1319 if(ixjdebug & 0x0004) {
1320 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1322 j->cadence_f[5].state = 7;
1326 if(ixjdebug & 0x0004) {
1327 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1329 j->flags.cidring = 1;
1330 j->cadence_f[5].state = 0;
1333 if (j->flags.cidring && !j->flags.cidsent) {
1334 j->flags.cidsent = 1;
1336 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
1339 j->flags.cidring = 0;
1341 clear_bit(board, &j->busyflags);
1345 if (time_after(jiffies, j->ring_cadence_jif + (hertz / 2))) {
1346 if (j->flags.cidring && !j->flags.cidsent) {
1347 j->flags.cidsent = 1;
1349 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
1352 j->flags.cidring = 0;
1354 j->ring_cadence_t--;
1355 if (j->ring_cadence_t == -1)
1356 j->ring_cadence_t = 15;
1357 j->ring_cadence_jif = jiffies;
1359 if (j->ring_cadence & 1 << j->ring_cadence_t) {
1360 if(j->flags.cidsent && j->cadence_f[5].en_filter)
1361 j->flags.firstring = 1;
1366 if(!j->flags.cidsent)
1367 j->flags.cidring = 1;
1370 clear_bit(board, &j->busyflags);
1375 if (!j->flags.ringing) {
1376 if (j->hookstate) { /* & 1) { */
1377 if (j->dsp.low != 0x20 &&
1378 SLIC_GetState(j) != PLD_SLIC_STATE_ACTIVE) {
1379 SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
1383 ixj_WriteDSPCommand(0x511B, j);
1384 j->proc_load = j->ssr.high << 8 | j->ssr.low;
1385 if (!j->m_hook && (j->hookstate & 1)) {
1386 j->m_hook = j->ex.bits.hookstate = 1;
1387 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1390 if (j->ex.bits.dtmf_ready) {
1391 j->dtmf_wp = j->dtmf_rp = j->ex.bits.dtmf_ready = 0;
1395 j->ex.bits.hookstate = 1;
1396 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1400 if (j->cardtype == QTI_LINEJACK && !j->flags.pstncheck && j->flags.pstn_present) {
1404 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
1406 clear_bit(board, &j->busyflags);
1411 static int ixj_status_wait(IXJ *j)
1415 jif = jiffies + ((60 * hertz) / 100);
1416 while (!IsStatusReady(j)) {
1417 ixj_perfmon(j->statuswait);
1418 if (time_after(jiffies, jif)) {
1419 ixj_perfmon(j->statuswaitfail);
1426 static int ixj_PCcontrol_wait(IXJ *j)
1430 jif = jiffies + ((60 * hertz) / 100);
1431 while (!IsPCControlReady(j)) {
1432 ixj_perfmon(j->pcontrolwait);
1433 if (time_after(jiffies, jif)) {
1434 ixj_perfmon(j->pcontrolwaitfail);
1441 static int ixj_WriteDSPCommand(unsigned short cmd, IXJ *j)
1446 atomic_inc(&j->DSPWrite);
1447 if(atomic_read(&j->DSPWrite) > 1) {
1448 printk("IXJ %d DSP write overlap attempting command 0x%4.4x\n", j->board, cmd);
1451 bytes.high = (cmd & 0xFF00) >> 8;
1452 bytes.low = cmd & 0x00FF;
1453 jif = jiffies + ((60 * hertz) / 100);
1454 while (!IsControlReady(j)) {
1455 ixj_perfmon(j->iscontrolready);
1456 if (time_after(jiffies, jif)) {
1457 ixj_perfmon(j->iscontrolreadyfail);
1458 atomic_dec(&j->DSPWrite);
1459 if(atomic_read(&j->DSPWrite) > 0) {
1460 printk("IXJ %d DSP overlaped command 0x%4.4x during control ready failure.\n", j->board, cmd);
1461 while(atomic_read(&j->DSPWrite) > 0) {
1462 atomic_dec(&j->DSPWrite);
1468 outb(bytes.low, j->DSPbase + 6);
1469 outb(bytes.high, j->DSPbase + 7);
1471 if (ixj_status_wait(j)) {
1474 atomic_dec(&j->DSPWrite);
1475 if(atomic_read(&j->DSPWrite) > 0) {
1476 printk("IXJ %d DSP overlaped command 0x%4.4x during status wait failure.\n", j->board, cmd);
1477 while(atomic_read(&j->DSPWrite) > 0) {
1478 atomic_dec(&j->DSPWrite);
1483 /* Read Software Status Register */
1484 j->ssr.low = inb_p(j->DSPbase + 2);
1485 j->ssr.high = inb_p(j->DSPbase + 3);
1486 atomic_dec(&j->DSPWrite);
1487 if(atomic_read(&j->DSPWrite) > 0) {
1488 printk("IXJ %d DSP overlaped command 0x%4.4x\n", j->board, cmd);
1489 while(atomic_read(&j->DSPWrite) > 0) {
1490 atomic_dec(&j->DSPWrite);
1496 /***************************************************************************
1498 * General Purpose IO Register read routine
1500 ***************************************************************************/
1501 static inline int ixj_gpio_read(IXJ *j)
1503 if (ixj_WriteDSPCommand(0x5143, j))
1506 j->gpio.bytes.low = j->ssr.low;
1507 j->gpio.bytes.high = j->ssr.high;
1512 static inline void LED_SetState(int state, IXJ *j)
1514 if (j->cardtype == QTI_LINEJACK) {
1515 j->pld_scrw.bits.led1 = state & 0x1 ? 1 : 0;
1516 j->pld_scrw.bits.led2 = state & 0x2 ? 1 : 0;
1517 j->pld_scrw.bits.led3 = state & 0x4 ? 1 : 0;
1518 j->pld_scrw.bits.led4 = state & 0x8 ? 1 : 0;
1520 outb(j->pld_scrw.byte, j->XILINXbase);
1524 /*********************************************************************
1525 * GPIO Pins are configured as follows on the Quicknet Internet
1526 * PhoneJACK Telephony Cards
1528 * POTS Select GPIO_6=0 GPIO_7=0
1529 * Mic/Speaker Select GPIO_6=0 GPIO_7=1
1530 * Handset Select GPIO_6=1 GPIO_7=0
1532 * SLIC Active GPIO_1=0 GPIO_2=1 GPIO_5=0
1533 * SLIC Ringing GPIO_1=1 GPIO_2=1 GPIO_5=0
1534 * SLIC Open Circuit GPIO_1=0 GPIO_2=0 GPIO_5=0
1536 * Hook Switch changes reported on GPIO_3
1537 *********************************************************************/
1538 static int ixj_set_port(IXJ *j, int arg)
1540 if (j->cardtype == QTI_PHONEJACK_LITE) {
1541 if (arg != PORT_POTS)
1548 j->port = PORT_POTS;
1549 switch (j->cardtype) {
1551 if (j->flags.pcmciasct == 1)
1552 SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
1556 case QTI_PHONEJACK_PCI:
1557 j->pld_slicw.pcib.mic = 0;
1558 j->pld_slicw.pcib.spk = 0;
1559 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1562 ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
1563 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
1564 Software Control Register */
1566 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
1568 outb(j->pld_scrw.byte, j->XILINXbase);
1569 j->pld_clock.byte = 0;
1570 outb(j->pld_clock.byte, j->XILINXbase + 0x04);
1571 j->pld_slicw.bits.rly1 = 1;
1572 j->pld_slicw.bits.spken = 0;
1573 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1574 ixj_mixer(0x1200, j); /* Turn Off MIC switch on mixer left */
1575 ixj_mixer(0x1401, j); /* Turn On Mono1 switch on mixer left */
1576 ixj_mixer(0x1300, j); /* Turn Off MIC switch on mixer right */
1577 ixj_mixer(0x1501, j); /* Turn On Mono1 switch on mixer right */
1578 ixj_mixer(0x0E80, j); /*Mic mute */
1579 ixj_mixer(0x0F00, j); /* Set mono out (SLIC) to 0dB */
1580 ixj_mixer(0x0080, j); /* Mute Master Left volume */
1581 ixj_mixer(0x0180, j); /* Mute Master Right volume */
1582 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
1583 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
1586 j->gpio.bytes.high = 0x0B;
1587 j->gpio.bits.gpio6 = 0;
1588 j->gpio.bits.gpio7 = 0;
1589 ixj_WriteDSPCommand(j->gpio.word, j);
1594 if (j->cardtype == QTI_LINEJACK) {
1595 ixj_WriteDSPCommand(0xC534, j); /* Write CODEC config to Software Control Register */
1597 j->pld_slicw.bits.rly3 = 0;
1598 j->pld_slicw.bits.rly1 = 1;
1599 j->pld_slicw.bits.spken = 0;
1600 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1601 j->port = PORT_PSTN;
1607 j->port = PORT_SPEAKER;
1608 switch (j->cardtype) {
1610 if (j->flags.pcmciasct) {
1611 SLIC_SetState(PLD_SLIC_STATE_OC, j);
1614 case QTI_PHONEJACK_PCI:
1615 j->pld_slicw.pcib.mic = 1;
1616 j->pld_slicw.pcib.spk = 1;
1617 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1620 ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
1621 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
1622 Software Control Register */
1624 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
1626 outb(j->pld_scrw.byte, j->XILINXbase);
1627 j->pld_clock.byte = 0;
1628 outb(j->pld_clock.byte, j->XILINXbase + 0x04);
1629 j->pld_slicw.bits.rly1 = 1;
1630 j->pld_slicw.bits.spken = 1;
1631 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1632 ixj_mixer(0x1201, j); /* Turn On MIC switch on mixer left */
1633 ixj_mixer(0x1400, j); /* Turn Off Mono1 switch on mixer left */
1634 ixj_mixer(0x1301, j); /* Turn On MIC switch on mixer right */
1635 ixj_mixer(0x1500, j); /* Turn Off Mono1 switch on mixer right */
1636 ixj_mixer(0x0E06, j); /*Mic un-mute 0dB */
1637 ixj_mixer(0x0F80, j); /* Mute mono out (SLIC) */
1638 ixj_mixer(0x0000, j); /* Set Master Left volume to 0dB */
1639 ixj_mixer(0x0100, j); /* Set Master Right volume to 0dB */
1642 j->gpio.bytes.high = 0x0B;
1643 j->gpio.bits.gpio6 = 0;
1644 j->gpio.bits.gpio7 = 1;
1645 ixj_WriteDSPCommand(j->gpio.word, j);
1650 if (j->cardtype != QTI_PHONEJACK) {
1653 j->gpio.bytes.high = 0x0B;
1654 j->gpio.bits.gpio6 = 1;
1655 j->gpio.bits.gpio7 = 0;
1656 ixj_WriteDSPCommand(j->gpio.word, j);
1657 j->port = PORT_HANDSET;
1667 static int ixj_set_pots(IXJ *j, int arg)
1669 if (j->cardtype == QTI_LINEJACK) {
1671 if (j->port == PORT_PSTN) {
1672 j->pld_slicw.bits.rly1 = 0;
1673 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1674 j->flags.pots_pstn = 1;
1677 j->flags.pots_pstn = 0;
1681 j->pld_slicw.bits.rly1 = 1;
1682 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1683 j->flags.pots_pstn = 0;
1691 static void ixj_ring_on(IXJ *j)
1693 if (j->dsp.low == 0x20) /* Internet PhoneJACK */
1695 if (ixjdebug & 0x0004)
1696 printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
1698 j->gpio.bytes.high = 0x0B;
1699 j->gpio.bytes.low = 0x00;
1700 j->gpio.bits.gpio1 = 1;
1701 j->gpio.bits.gpio2 = 1;
1702 j->gpio.bits.gpio5 = 0;
1703 ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring signal */
1704 } else /* Internet LineJACK, Internet PhoneJACK Lite or Internet PhoneJACK PCI */
1706 if (ixjdebug & 0x0004)
1707 printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
1709 SLIC_SetState(PLD_SLIC_STATE_RINGING, j);
1713 static int ixj_siadc(IXJ *j, int val)
1715 if(j->cardtype == QTI_PHONECARD){
1716 if(j->flags.pcmciascp){
1718 return j->siadc.bits.rxg;
1720 if(val < 0 || val > 0x1F)
1723 j->siadc.bits.hom = 0; /* Handset Out Mute */
1724 j->siadc.bits.lom = 0; /* Line Out Mute */
1725 j->siadc.bits.rxg = val; /*(0xC000 - 0x41C8) / 0x4EF; RX PGA Gain */
1726 j->psccr.bits.addr = 6; /* R/W Smart Cable Register Address */
1727 j->psccr.bits.rw = 0; /* Read / Write flag */
1728 j->psccr.bits.dev = 0;
1729 outb(j->siadc.byte, j->XILINXbase + 0x00);
1730 outb(j->psccr.byte, j->XILINXbase + 0x01);
1731 ixj_PCcontrol_wait(j);
1732 return j->siadc.bits.rxg;
1738 static int ixj_sidac(IXJ *j, int val)
1740 if(j->cardtype == QTI_PHONECARD){
1741 if(j->flags.pcmciascp){
1743 return j->sidac.bits.txg;
1745 if(val < 0 || val > 0x1F)
1748 j->sidac.bits.srm = 1; /* Speaker Right Mute */
1749 j->sidac.bits.slm = 1; /* Speaker Left Mute */
1750 j->sidac.bits.txg = val; /* (0xC000 - 0x45E4) / 0x5D3; TX PGA Gain */
1751 j->psccr.bits.addr = 7; /* R/W Smart Cable Register Address */
1752 j->psccr.bits.rw = 0; /* Read / Write flag */
1753 j->psccr.bits.dev = 0;
1754 outb(j->sidac.byte, j->XILINXbase + 0x00);
1755 outb(j->psccr.byte, j->XILINXbase + 0x01);
1756 ixj_PCcontrol_wait(j);
1757 return j->sidac.bits.txg;
1763 static int ixj_pcmcia_cable_check(IXJ *j)
1765 j->pccr1.byte = inb_p(j->XILINXbase + 0x03);
1766 if (!j->flags.pcmciastate) {
1767 j->pccr2.byte = inb_p(j->XILINXbase + 0x02);
1768 if (j->pccr1.bits.drf || j->pccr2.bits.rstc) {
1769 j->flags.pcmciastate = 4;
1772 if (j->pccr1.bits.ed) {
1773 j->pccr1.bits.ed = 0;
1774 j->psccr.bits.dev = 3;
1775 j->psccr.bits.rw = 1;
1776 outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
1777 ixj_PCcontrol_wait(j);
1778 j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
1779 j->pslic.bits.led2 = j->pslic.bits.det ? 1 : 0;
1780 j->psccr.bits.dev = 3;
1781 j->psccr.bits.rw = 0;
1782 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
1783 ixj_PCcontrol_wait(j);
1784 return j->pslic.bits.led2 ? 1 : 0;
1785 } else if (j->flags.pcmciasct) {
1790 } else if (j->flags.pcmciastate == 4) {
1791 if (!j->pccr1.bits.drf) {
1792 j->flags.pcmciastate = 3;
1795 } else if (j->flags.pcmciastate == 3) {
1796 j->pccr2.bits.pwr = 0;
1797 j->pccr2.bits.rstc = 1;
1798 outb(j->pccr2.byte, j->XILINXbase + 0x02);
1799 j->checkwait = jiffies + (hertz * 2);
1800 j->flags.incheck = 1;
1801 j->flags.pcmciastate = 2;
1803 } else if (j->flags.pcmciastate == 2) {
1804 if (j->flags.incheck) {
1805 if (time_before(jiffies, j->checkwait)) {
1808 j->flags.incheck = 0;
1811 j->pccr2.bits.pwr = 0;
1812 j->pccr2.bits.rstc = 0;
1813 outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
1814 j->flags.pcmciastate = 1;
1816 } else if (j->flags.pcmciastate == 1) {
1817 j->flags.pcmciastate = 0;
1818 if (!j->pccr1.bits.drf) {
1819 j->psccr.bits.dev = 3;
1820 j->psccr.bits.rw = 1;
1821 outb_p(j->psccr.byte, j->XILINXbase + 0x01);
1822 ixj_PCcontrol_wait(j);
1823 j->flags.pcmciascp = 1; /* Set Cable Present Flag */
1825 j->flags.pcmciasct = (inw_p(j->XILINXbase + 0x00) >> 8) & 0x03; /* Get Cable Type */
1827 if (j->flags.pcmciasct == 3) {
1828 j->flags.pcmciastate = 4;
1830 } else if (j->flags.pcmciasct == 0) {
1831 j->pccr2.bits.pwr = 1;
1832 j->pccr2.bits.rstc = 0;
1833 outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
1834 j->port = PORT_SPEAKER;
1836 j->port = PORT_POTS;
1838 j->sic1.bits.cpd = 0; /* Chip Power Down */
1839 j->sic1.bits.mpd = 0; /* MIC Bias Power Down */
1840 j->sic1.bits.hpd = 0; /* Handset Bias Power Down */
1841 j->sic1.bits.lpd = 0; /* Line Bias Power Down */
1842 j->sic1.bits.spd = 1; /* Speaker Drive Power Down */
1843 j->psccr.bits.addr = 1; /* R/W Smart Cable Register Address */
1844 j->psccr.bits.rw = 0; /* Read / Write flag */
1845 j->psccr.bits.dev = 0;
1846 outb(j->sic1.byte, j->XILINXbase + 0x00);
1847 outb(j->psccr.byte, j->XILINXbase + 0x01);
1848 ixj_PCcontrol_wait(j);
1850 j->sic2.bits.al = 0; /* Analog Loopback DAC analog -> ADC analog */
1851 j->sic2.bits.dl2 = 0; /* Digital Loopback DAC -> ADC one bit */
1852 j->sic2.bits.dl1 = 0; /* Digital Loopback ADC -> DAC one bit */
1853 j->sic2.bits.pll = 0; /* 1 = div 10, 0 = div 5 */
1854 j->sic2.bits.hpd = 0; /* HPF disable */
1855 j->psccr.bits.addr = 2; /* R/W Smart Cable Register Address */
1856 j->psccr.bits.rw = 0; /* Read / Write flag */
1857 j->psccr.bits.dev = 0;
1858 outb(j->sic2.byte, j->XILINXbase + 0x00);
1859 outb(j->psccr.byte, j->XILINXbase + 0x01);
1860 ixj_PCcontrol_wait(j);
1862 j->psccr.bits.addr = 3; /* R/W Smart Cable Register Address */
1863 j->psccr.bits.rw = 0; /* Read / Write flag */
1864 j->psccr.bits.dev = 0;
1865 outb(0x00, j->XILINXbase + 0x00); /* PLL Divide N1 */
1866 outb(j->psccr.byte, j->XILINXbase + 0x01);
1867 ixj_PCcontrol_wait(j);
1869 j->psccr.bits.addr = 4; /* R/W Smart Cable Register Address */
1870 j->psccr.bits.rw = 0; /* Read / Write flag */
1871 j->psccr.bits.dev = 0;
1872 outb(0x09, j->XILINXbase + 0x00); /* PLL Multiply M1 */
1873 outb(j->psccr.byte, j->XILINXbase + 0x01);
1874 ixj_PCcontrol_wait(j);
1876 j->sirxg.bits.lig = 1; /* Line In Gain */
1877 j->sirxg.bits.lim = 1; /* Line In Mute */
1878 j->sirxg.bits.mcg = 0; /* MIC In Gain was 3 */
1879 j->sirxg.bits.mcm = 0; /* MIC In Mute */
1880 j->sirxg.bits.him = 0; /* Handset In Mute */
1881 j->sirxg.bits.iir = 1; /* IIR */
1882 j->psccr.bits.addr = 5; /* R/W Smart Cable Register Address */
1883 j->psccr.bits.rw = 0; /* Read / Write flag */
1884 j->psccr.bits.dev = 0;
1885 outb(j->sirxg.byte, j->XILINXbase + 0x00);
1886 outb(j->psccr.byte, j->XILINXbase + 0x01);
1887 ixj_PCcontrol_wait(j);
1892 j->siaatt.bits.sot = 0;
1893 j->psccr.bits.addr = 9; /* R/W Smart Cable Register Address */
1894 j->psccr.bits.rw = 0; /* Read / Write flag */
1895 j->psccr.bits.dev = 0;
1896 outb(j->siaatt.byte, j->XILINXbase + 0x00);
1897 outb(j->psccr.byte, j->XILINXbase + 0x01);
1898 ixj_PCcontrol_wait(j);
1900 if (j->flags.pcmciasct == 1 && !j->readers && !j->writers) {
1901 j->psccr.byte = j->pslic.byte = 0;
1902 j->pslic.bits.powerdown = 1;
1903 j->psccr.bits.dev = 3;
1904 j->psccr.bits.rw = 0;
1905 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
1906 ixj_PCcontrol_wait(j);
1911 j->flags.pcmciascp = 0;
1917 static int ixj_hookstate(IXJ *j)
1921 switch (j->cardtype) {
1924 fOffHook = j->gpio.bits.gpio3read ? 1 : 0;
1927 case QTI_PHONEJACK_LITE:
1928 case QTI_PHONEJACK_PCI:
1930 if(j->cardtype == QTI_LINEJACK && j->flags.pots_pstn == 1 && (j->readers || j->writers)) {
1931 fOffHook = j->pld_slicr.bits.potspstn ? 1 : 0;
1932 if(fOffHook != j->p_hook) {
1934 j->checkwait = jiffies;
1936 if(time_before(jiffies, j->checkwait + 2)) {
1941 j->p_hook = fOffHook;
1942 printk("IXJ : /dev/phone%d pots-pstn hookstate check %d at %ld\n", j->board, fOffHook, jiffies);
1945 if (j->pld_slicr.bits.state == PLD_SLIC_STATE_ACTIVE ||
1946 j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) {
1947 if (j->flags.ringing || j->flags.cringing) {
1948 if (!in_interrupt()) {
1952 if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) {
1956 if (j->cardtype == QTI_PHONEJACK_PCI) {
1957 j->pld_scrr.byte = inb_p(j->XILINXbase);
1958 fOffHook = j->pld_scrr.pcib.det ? 1 : 0;
1960 fOffHook = j->pld_slicr.bits.det ? 1 : 0;
1965 fOffHook = ixj_pcmcia_cable_check(j);
1968 if (j->r_hook != fOffHook) {
1969 j->r_hook = fOffHook;
1970 if (j->port == PORT_SPEAKER || j->port == PORT_HANDSET) { // || (j->port == PORT_PSTN && j->flags.pots_pstn == 0)) {
1971 j->ex.bits.hookstate = 1;
1972 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1973 } else if (!fOffHook) {
1974 j->flash_end = jiffies + ((60 * hertz) / 100);
1978 if(time_before(jiffies, j->flash_end)) {
1979 j->ex.bits.flash = 1;
1981 ixj_kill_fasync(j, SIG_FLASH, POLL_IN);
1984 if(time_before(jiffies, j->flash_end)) {
1989 if (j->port == PORT_PSTN && j->daa_mode == SOP_PU_CONVERSATION)
1992 if (j->port == PORT_SPEAKER) {
1993 if(j->cardtype == QTI_PHONECARD) {
1994 if(j->flags.pcmciascp && j->flags.pcmciasct) {
2002 if (j->port == PORT_HANDSET)
2008 static void ixj_ring_off(IXJ *j)
2010 if (j->dsp.low == 0x20) /* Internet PhoneJACK */
2012 if (ixjdebug & 0x0004)
2013 printk(KERN_INFO "IXJ Ring Off\n");
2014 j->gpio.bytes.high = 0x0B;
2015 j->gpio.bytes.low = 0x00;
2016 j->gpio.bits.gpio1 = 0;
2017 j->gpio.bits.gpio2 = 1;
2018 j->gpio.bits.gpio5 = 0;
2019 ixj_WriteDSPCommand(j->gpio.word, j);
2020 } else /* Internet LineJACK */
2022 if (ixjdebug & 0x0004)
2023 printk(KERN_INFO "IXJ Ring Off\n");
2025 if(!j->flags.cidplay)
2026 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
2032 static void ixj_ring_start(IXJ *j)
2034 j->flags.cringing = 1;
2035 if (ixjdebug & 0x0004)
2036 printk(KERN_INFO "IXJ Cadence Ringing Start /dev/phone%d\n", j->board);
2037 if (ixj_hookstate(j) & 1) {
2038 if (j->port == PORT_POTS)
2040 j->flags.cringing = 0;
2041 if (ixjdebug & 0x0004)
2042 printk(KERN_INFO "IXJ Cadence Ringing Stopped /dev/phone%d off hook\n", j->board);
2043 } else if(j->cadence_f[5].enable && (!j->cadence_f[5].en_filter)) {
2044 j->ring_cadence_jif = jiffies;
2045 j->flags.cidsent = j->flags.cidring = 0;
2046 j->cadence_f[5].state = 0;
2047 if(j->cadence_f[5].on1)
2050 j->ring_cadence_jif = jiffies;
2051 j->ring_cadence_t = 15;
2052 if (j->ring_cadence & 1 << j->ring_cadence_t) {
2057 j->flags.cidsent = j->flags.cidring = j->flags.firstring = 0;
2061 static int ixj_ring(IXJ *j)
2066 j->flags.ringing = 1;
2067 if (ixj_hookstate(j) & 1) {
2069 j->flags.ringing = 0;
2072 for (cntr = 0; cntr < j->maxrings; cntr++) {
2073 jif = jiffies + (1 * hertz);
2075 while (time_before(jiffies, jif)) {
2076 if (ixj_hookstate(j) & 1) {
2078 j->flags.ringing = 0;
2081 schedule_timeout_interruptible(1);
2082 if (signal_pending(current))
2085 jif = jiffies + (3 * hertz);
2087 while (time_before(jiffies, jif)) {
2088 if (ixj_hookstate(j) & 1) {
2090 if (ixj_hookstate(j) & 1) {
2091 j->flags.ringing = 0;
2095 schedule_timeout_interruptible(1);
2096 if (signal_pending(current))
2101 j->flags.ringing = 0;
2105 static int ixj_open(struct phone_device *p, struct file *file_p)
2107 IXJ *j = get_ixj(p->board);
2108 file_p->private_data = j;
2113 if (file_p->f_mode & FMODE_READ) {
2121 if (file_p->f_mode & FMODE_WRITE) {
2125 if (file_p->f_mode & FMODE_READ){
2132 if (j->cardtype == QTI_PHONECARD) {
2133 j->pslic.bits.powerdown = 0;
2134 j->psccr.bits.dev = 3;
2135 j->psccr.bits.rw = 0;
2136 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
2137 ixj_PCcontrol_wait(j);
2140 j->flags.cidplay = 0;
2141 j->flags.cidcw_ack = 0;
2143 if (ixjdebug & 0x0002)
2144 printk(KERN_INFO "Opening board %d\n", p->board);
2146 j->framesread = j->frameswritten = 0;
2150 static int ixj_release(struct inode *inode, struct file *file_p)
2154 IXJ *j = file_p->private_data;
2155 int board = j->p.board;
2158 * Set up locks to ensure that only one process is talking to the DSP at a time.
2159 * This is necessary to keep the DSP from locking up.
2161 while(test_and_set_bit(board, (void *)&j->busyflags) != 0)
2162 schedule_timeout_interruptible(1);
2163 if (ixjdebug & 0x0002)
2164 printk(KERN_INFO "Closing board %d\n", NUM(inode));
2166 if (j->cardtype == QTI_PHONECARD)
2167 ixj_set_port(j, PORT_SPEAKER);
2169 ixj_set_port(j, PORT_POTS);
2174 set_play_volume(j, 0x100);
2175 set_rec_volume(j, 0x100);
2178 /* Restore the tone table to default settings. */
2184 ixj_init_tone(j, &ti);
2190 ixj_init_tone(j, &ti);
2196 ixj_init_tone(j, &ti);
2202 ixj_init_tone(j, &ti);
2208 ixj_init_tone(j, &ti);
2214 ixj_init_tone(j, &ti);
2220 ixj_init_tone(j, &ti);
2226 ixj_init_tone(j, &ti);
2232 ixj_init_tone(j, &ti);
2238 ixj_init_tone(j, &ti);
2244 ixj_init_tone(j, &ti);
2250 ixj_init_tone(j, &ti);
2256 ixj_init_tone(j, &ti);
2262 ixj_init_tone(j, &ti);
2268 ixj_init_tone(j, &ti);
2274 ixj_init_tone(j, &ti);
2280 ixj_init_tone(j, &ti);
2286 ixj_init_tone(j, &ti);
2288 set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
2290 set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
2292 j->ex.bits.dtmf_ready = 0;
2294 j->dtmf_wp = j->dtmf_rp = 0;
2295 j->rec_mode = j->play_mode = -1;
2296 j->flags.ringing = 0;
2297 j->maxrings = MAXRINGS;
2298 j->ring_cadence = USA_RING_CADENCE;
2299 if(j->cadence_f[5].enable) {
2300 j->cadence_f[5].enable = j->cadence_f[5].en_filter = j->cadence_f[5].state = 0;
2304 j->flags.dtmf_oob = 0;
2305 for (cnt = 0; cnt < 4; cnt++)
2306 j->cadence_f[cnt].enable = 0;
2310 if(j->cardtype == QTI_PHONECARD) {
2311 SLIC_SetState(PLD_SLIC_STATE_OC, j);
2314 if (file_p->f_mode & FMODE_READ)
2316 if (file_p->f_mode & FMODE_WRITE)
2319 if (j->read_buffer && !j->readers) {
2320 kfree(j->read_buffer);
2321 j->read_buffer = NULL;
2322 j->read_buffer_size = 0;
2324 if (j->write_buffer && !j->writers) {
2325 kfree(j->write_buffer);
2326 j->write_buffer = NULL;
2327 j->write_buffer_size = 0;
2329 j->rec_codec = j->play_codec = 0;
2330 j->rec_frame_size = j->play_frame_size = 0;
2331 j->flags.cidsent = j->flags.cidring = 0;
2333 if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) {
2334 ixj_set_port(j, PORT_PSTN);
2335 daa_set_mode(j, SOP_PU_SLEEP);
2338 ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
2340 /* Set up the default signals for events */
2341 for (cnt = 0; cnt < 35; cnt++)
2342 j->ixj_signals[cnt] = SIGIO;
2344 /* Set the excetion signal enable flags */
2345 j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
2346 j->ex_sig.bits.caller_id = j->ex_sig.bits.pstn_wink = j->ex_sig.bits.f0 = j->ex_sig.bits.f1 = j->ex_sig.bits.f2 =
2347 j->ex_sig.bits.f3 = j->ex_sig.bits.fc0 = j->ex_sig.bits.fc1 = j->ex_sig.bits.fc2 = j->ex_sig.bits.fc3 = 1;
2349 file_p->private_data = NULL;
2350 clear_bit(board, &j->busyflags);
2354 static int read_filters(IXJ *j)
2356 unsigned short fc, cnt, trg;
2360 if (ixj_WriteDSPCommand(0x5144, j)) {
2361 if(ixjdebug & 0x0001) {
2362 printk(KERN_INFO "Read Frame Counter failed!\n");
2366 fc = j->ssr.high << 8 | j->ssr.low;
2367 if (fc == j->frame_count)
2370 j->frame_count = fc;
2377 for (cnt = 0; cnt < 4; cnt++) {
2378 if (ixj_WriteDSPCommand(0x5154 + cnt, j)) {
2379 if(ixjdebug & 0x0001) {
2380 printk(KERN_INFO "Select Filter %d failed!\n", cnt);
2384 if (ixj_WriteDSPCommand(0x515C, j)) {
2385 if(ixjdebug & 0x0001) {
2386 printk(KERN_INFO "Read Filter History %d failed!\n", cnt);
2390 j->filter_hist[cnt] = j->ssr.high << 8 | j->ssr.low;
2392 if (j->cadence_f[cnt].enable) {
2393 if (j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) {
2394 if (j->cadence_f[cnt].state == 0) {
2395 j->cadence_f[cnt].state = 1;
2396 j->cadence_f[cnt].on1min = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 - var)) / 10000));
2397 j->cadence_f[cnt].on1dot = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100)) / 10000));
2398 j->cadence_f[cnt].on1max = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 + var)) / 10000));
2399 } else if (j->cadence_f[cnt].state == 2 &&
2400 (time_after(jiffies, j->cadence_f[cnt].off1min) &&
2401 time_before(jiffies, j->cadence_f[cnt].off1max))) {
2402 if (j->cadence_f[cnt].on2) {
2403 j->cadence_f[cnt].state = 3;
2404 j->cadence_f[cnt].on2min = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 - var)) / 10000));
2405 j->cadence_f[cnt].on2dot = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100)) / 10000));
2406 j->cadence_f[cnt].on2max = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 + var)) / 10000));
2408 j->cadence_f[cnt].state = 7;
2410 } else if (j->cadence_f[cnt].state == 4 &&
2411 (time_after(jiffies, j->cadence_f[cnt].off2min) &&
2412 time_before(jiffies, j->cadence_f[cnt].off2max))) {
2413 if (j->cadence_f[cnt].on3) {
2414 j->cadence_f[cnt].state = 5;
2415 j->cadence_f[cnt].on3min = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 - var)) / 10000));
2416 j->cadence_f[cnt].on3dot = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100)) / 10000));
2417 j->cadence_f[cnt].on3max = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 + var)) / 10000));
2419 j->cadence_f[cnt].state = 7;
2422 j->cadence_f[cnt].state = 0;
2424 } else if (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)) {
2425 if (j->cadence_f[cnt].state == 1) {
2426 if(!j->cadence_f[cnt].on1) {
2427 j->cadence_f[cnt].state = 7;
2428 } else if((time_after(jiffies, j->cadence_f[cnt].on1min) &&
2429 time_before(jiffies, j->cadence_f[cnt].on1max))) {
2430 if(j->cadence_f[cnt].off1) {
2431 j->cadence_f[cnt].state = 2;
2432 j->cadence_f[cnt].off1min = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 - var)) / 10000));
2433 j->cadence_f[cnt].off1dot = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100)) / 10000));
2434 j->cadence_f[cnt].off1max = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 + var)) / 10000));
2436 j->cadence_f[cnt].state = 7;
2439 j->cadence_f[cnt].state = 0;
2441 } else if (j->cadence_f[cnt].state == 3) {
2442 if((time_after(jiffies, j->cadence_f[cnt].on2min) &&
2443 time_before(jiffies, j->cadence_f[cnt].on2max))) {
2444 if(j->cadence_f[cnt].off2) {
2445 j->cadence_f[cnt].state = 4;
2446 j->cadence_f[cnt].off2min = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 - var)) / 10000));
2447 j->cadence_f[cnt].off2dot = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100)) / 10000));
2448 j->cadence_f[cnt].off2max = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 + var)) / 10000));
2450 j->cadence_f[cnt].state = 7;
2453 j->cadence_f[cnt].state = 0;
2455 } else if (j->cadence_f[cnt].state == 5) {
2456 if ((time_after(jiffies, j->cadence_f[cnt].on3min) &&
2457 time_before(jiffies, j->cadence_f[cnt].on3max))) {
2458 if(j->cadence_f[cnt].off3) {
2459 j->cadence_f[cnt].state = 6;
2460 j->cadence_f[cnt].off3min = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 - var)) / 10000));
2461 j->cadence_f[cnt].off3dot = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100)) / 10000));
2462 j->cadence_f[cnt].off3max = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 + var)) / 10000));
2464 j->cadence_f[cnt].state = 7;
2467 j->cadence_f[cnt].state = 0;
2470 j->cadence_f[cnt].state = 0;
2473 switch(j->cadence_f[cnt].state) {
2475 if(time_after(jiffies, j->cadence_f[cnt].on1dot) &&
2476 !j->cadence_f[cnt].off1 &&
2477 !j->cadence_f[cnt].on2 && !j->cadence_f[cnt].off2 &&
2478 !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
2479 j->cadence_f[cnt].state = 7;
2483 if(time_after(jiffies, j->cadence_f[cnt].on2dot) &&
2484 !j->cadence_f[cnt].off2 &&
2485 !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
2486 j->cadence_f[cnt].state = 7;
2490 if(time_after(jiffies, j->cadence_f[cnt].on3dot) &&
2491 !j->cadence_f[cnt].off3) {
2492 j->cadence_f[cnt].state = 7;
2498 if (ixjdebug & 0x0040) {
2499 printk(KERN_INFO "IXJ Tone Cadence state = %d /dev/phone%d at %ld\n", j->cadence_f[cnt].state, j->board, jiffies);
2500 switch(j->cadence_f[cnt].state) {
2502 printk(KERN_INFO "IXJ /dev/phone%d No Tone detected\n", j->board);
2505 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %u %ld - %ld - %ld\n", j->board,
2506 j->cadence_f[cnt].on1, j->cadence_f[cnt].on1min, j->cadence_f[cnt].on1dot, j->cadence_f[cnt].on1max);
2509 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off1min,
2510 j->cadence_f[cnt].off1max);
2513 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on2min,
2514 j->cadence_f[cnt].on2max);
2517 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off2min,
2518 j->cadence_f[cnt].off2max);
2521 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on3min,
2522 j->cadence_f[cnt].on3max);
2525 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off3min,
2526 j->cadence_f[cnt].off3max);
2531 if (j->cadence_f[cnt].state == 7) {
2532 j->cadence_f[cnt].state = 0;
2533 if (j->cadence_f[cnt].enable == 1)
2534 j->cadence_f[cnt].enable = 0;
2537 if(ixjdebug & 0x0020) {
2538 printk(KERN_INFO "Filter Cadence 0 triggered %ld\n", jiffies);
2541 ixj_kill_fasync(j, SIG_FC0, POLL_IN);
2544 if(ixjdebug & 0x0020) {
2545 printk(KERN_INFO "Filter Cadence 1 triggered %ld\n", jiffies);
2548 ixj_kill_fasync(j, SIG_FC1, POLL_IN);
2551 if(ixjdebug & 0x0020) {
2552 printk(KERN_INFO "Filter Cadence 2 triggered %ld\n", jiffies);
2555 ixj_kill_fasync(j, SIG_FC2, POLL_IN);
2558 if(ixjdebug & 0x0020) {
2559 printk(KERN_INFO "Filter Cadence 3 triggered %ld\n", jiffies);
2562 ixj_kill_fasync(j, SIG_FC3, POLL_IN);
2566 if (j->filter_en[cnt] && ((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) ||
2567 (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)))) {
2568 if((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12))) {
2570 } else if((j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3))) {
2575 if(ixjdebug & 0x0020) {
2576 printk(KERN_INFO "Filter 0 triggered %d at %ld\n", trg, jiffies);
2579 ixj_kill_fasync(j, SIG_F0, POLL_IN);
2582 if(ixjdebug & 0x0020) {
2583 printk(KERN_INFO "Filter 1 triggered %d at %ld\n", trg, jiffies);
2586 ixj_kill_fasync(j, SIG_F1, POLL_IN);
2589 if(ixjdebug & 0x0020) {
2590 printk(KERN_INFO "Filter 2 triggered %d at %ld\n", trg, jiffies);
2593 ixj_kill_fasync(j, SIG_F2, POLL_IN);
2596 if(ixjdebug & 0x0020) {
2597 printk(KERN_INFO "Filter 3 triggered %d at %ld\n", trg, jiffies);
2600 ixj_kill_fasync(j, SIG_F3, POLL_IN);
2608 static int LineMonitor(IXJ *j)
2615 if (ixj_WriteDSPCommand(0x7000, j)) /* Line Monitor */
2618 j->dtmf.bytes.high = j->ssr.high;
2619 j->dtmf.bytes.low = j->ssr.low;
2620 if (!j->dtmf_state && j->dtmf.bits.dtmf_valid) {
2622 j->dtmf_current = j->dtmf.bits.digit;
2624 if (j->dtmf_state && !j->dtmf.bits.dtmf_valid) /* && j->dtmf_wp != j->dtmf_rp) */
2626 if(!j->cidcw_wait) {
2627 j->dtmfbuffer[j->dtmf_wp] = j->dtmf_current;
2629 if (j->dtmf_wp == 79)
2631 j->ex.bits.dtmf_ready = 1;
2632 if(j->ex_sig.bits.dtmf_ready) {
2633 ixj_kill_fasync(j, SIG_DTMF_READY, POLL_IN);
2636 else if(j->dtmf_current == 0x00 || j->dtmf_current == 0x0D) {
2637 if(ixjdebug & 0x0020) {
2638 printk("IXJ phone%d saw CIDCW Ack DTMF %d from display at %ld\n", j->board, j->dtmf_current, jiffies);
2640 j->flags.cidcw_ack = 1;
2649 /************************************************************************
2651 * Functions to allow alaw <-> ulaw conversions.
2653 ************************************************************************/
2655 static void ulaw2alaw(unsigned char *buff, unsigned long len)
2657 static unsigned char table_ulaw2alaw[] =
2659 0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D,
2660 0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25,
2661 0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D,
2662 0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35,
2663 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02,
2664 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A,
2665 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12,
2666 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B,
2667 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63,
2668 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79,
2669 0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71,
2670 0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D,
2671 0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45,
2672 0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D,
2673 0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51,
2674 0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5,
2675 0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD,
2676 0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5,
2677 0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD,
2678 0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5,
2679 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82,
2680 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A,
2681 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92,
2682 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB,
2683 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3,
2684 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9,
2685 0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1,
2686 0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD,
2687 0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5,
2688 0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD,
2689 0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1,
2690 0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5
2695 *buff = table_ulaw2alaw[*(unsigned char *)buff];
2700 static void alaw2ulaw(unsigned char *buff, unsigned long len)
2702 static unsigned char table_alaw2ulaw[] =
2704 0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C,
2705 0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24,
2706 0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C,
2707 0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34,
2708 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D,
2709 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
2710 0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D,
2711 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15,
2712 0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65,
2713 0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E,
2714 0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A,
2715 0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D,
2716 0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B,
2717 0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43,
2718 0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59,
2719 0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51,
2720 0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC,
2721 0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4,
2722 0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC,
2723 0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4,
2724 0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D,
2725 0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85,
2726 0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D,
2727 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95,
2728 0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5,
2729 0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE,
2730 0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA,
2731 0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED,
2732 0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB,
2733 0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3,
2734 0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9,
2735 0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1
2740 *buff = table_alaw2ulaw[*(unsigned char *)buff];
2745 static ssize_t ixj_read(struct file * file_p, char __user *buf, size_t length, loff_t * ppos)
2747 unsigned long i = *ppos;
2748 IXJ * j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
2750 DECLARE_WAITQUEUE(wait, current);
2752 if (j->flags.inread)
2755 j->flags.inread = 1;
2757 add_wait_queue(&j->read_q, &wait);
2758 set_current_state(TASK_INTERRUPTIBLE);
2761 while (!j->read_buffer_ready || (j->dtmf_state && j->flags.dtmf_oob)) {
2763 if (file_p->f_flags & O_NONBLOCK) {
2764 set_current_state(TASK_RUNNING);
2765 remove_wait_queue(&j->read_q, &wait);
2766 j->flags.inread = 0;
2769 if (!ixj_hookstate(j)) {
2770 set_current_state(TASK_RUNNING);
2771 remove_wait_queue(&j->read_q, &wait);
2772 j->flags.inread = 0;
2775 interruptible_sleep_on(&j->read_q);
2776 if (signal_pending(current)) {
2777 set_current_state(TASK_RUNNING);
2778 remove_wait_queue(&j->read_q, &wait);
2779 j->flags.inread = 0;
2784 remove_wait_queue(&j->read_q, &wait);
2785 set_current_state(TASK_RUNNING);
2786 /* Don't ever copy more than the user asks */
2787 if(j->rec_codec == ALAW)
2788 ulaw2alaw(j->read_buffer, min(length, j->read_buffer_size));
2789 i = copy_to_user(buf, j->read_buffer, min(length, j->read_buffer_size));
2790 j->read_buffer_ready = 0;
2792 j->flags.inread = 0;
2795 j->flags.inread = 0;
2796 return min(length, j->read_buffer_size);
2800 static ssize_t ixj_enhanced_read(struct file * file_p, char __user *buf, size_t length,
2804 ssize_t read_retval = 0;
2805 IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
2807 pre_retval = ixj_PreRead(j, 0L);
2808 switch (pre_retval) {
2810 read_retval = ixj_read(file_p, buf, length, ppos);
2811 ixj_PostRead(j, 0L);
2814 read_retval = ixj_read(file_p, buf, length, ppos);
2817 ixj_PostRead(j, 0L);
2820 read_retval = pre_retval;
2825 static ssize_t ixj_write(struct file *file_p, const char __user *buf, size_t count, loff_t * ppos)
2827 unsigned long i = *ppos;
2828 IXJ *j = file_p->private_data;
2830 DECLARE_WAITQUEUE(wait, current);
2832 if (j->flags.inwrite)
2835 j->flags.inwrite = 1;
2837 add_wait_queue(&j->write_q, &wait);
2838 set_current_state(TASK_INTERRUPTIBLE);
2842 while (!j->write_buffers_empty) {
2844 if (file_p->f_flags & O_NONBLOCK) {
2845 set_current_state(TASK_RUNNING);
2846 remove_wait_queue(&j->write_q, &wait);
2847 j->flags.inwrite = 0;
2850 if (!ixj_hookstate(j)) {
2851 set_current_state(TASK_RUNNING);
2852 remove_wait_queue(&j->write_q, &wait);
2853 j->flags.inwrite = 0;
2856 interruptible_sleep_on(&j->write_q);
2857 if (signal_pending(current)) {
2858 set_current_state(TASK_RUNNING);
2859 remove_wait_queue(&j->write_q, &wait);
2860 j->flags.inwrite = 0;
2864 set_current_state(TASK_RUNNING);
2865 remove_wait_queue(&j->write_q, &wait);
2866 if (j->write_buffer_wp + count >= j->write_buffer_end)
2867 j->write_buffer_wp = j->write_buffer;
2868 i = copy_from_user(j->write_buffer_wp, buf, min(count, j->write_buffer_size));
2870 j->flags.inwrite = 0;
2873 if(j->play_codec == ALAW)
2874 alaw2ulaw(j->write_buffer_wp, min(count, j->write_buffer_size));
2875 j->flags.inwrite = 0;
2876 return min(count, j->write_buffer_size);
2879 static ssize_t ixj_enhanced_write(struct file * file_p, const char __user *buf, size_t count, loff_t * ppos)
2882 ssize_t write_retval = 0;
2884 IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
2886 pre_retval = ixj_PreWrite(j, 0L);
2887 switch (pre_retval) {
2889 write_retval = ixj_write(file_p, buf, count, ppos);
2890 if (write_retval > 0) {
2891 ixj_PostWrite(j, 0L);
2892 j->write_buffer_wp += write_retval;
2893 j->write_buffers_empty--;
2897 write_retval = ixj_write(file_p, buf, count, ppos);
2898 if (write_retval > 0) {
2899 j->write_buffer_wp += write_retval;
2900 j->write_buffers_empty--;
2904 ixj_PostWrite(j, 0L);
2907 write_retval = pre_retval;
2909 return write_retval;
2912 static void ixj_read_frame(IXJ *j)
2916 if (j->read_buffer) {
2917 for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
2918 if (!(cnt % 16) && !IsRxReady(j)) {
2920 while (!IsRxReady(j)) {
2928 /* Throw away word 0 of the 8021 compressed format to get standard G.729. */
2929 if (j->rec_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
2930 inb_p(j->DSPbase + 0x0E);
2931 inb_p(j->DSPbase + 0x0F);
2933 *(j->read_buffer + cnt) = inb_p(j->DSPbase + 0x0E);
2934 *(j->read_buffer + cnt + 1) = inb_p(j->DSPbase + 0x0F);
2937 if (j->intercom != -1) {
2938 if (IsTxReady(get_ixj(j->intercom))) {
2939 for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
2940 if (!(cnt % 16) && !IsTxReady(j)) {
2942 while (!IsTxReady(j)) {
2950 outb_p(*(j->read_buffer + cnt), get_ixj(j->intercom)->DSPbase + 0x0C);
2951 outb_p(*(j->read_buffer + cnt + 1), get_ixj(j->intercom)->DSPbase + 0x0D);
2953 get_ixj(j->intercom)->frameswritten++;
2956 j->read_buffer_ready = 1;
2957 wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
2959 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
2961 if(j->ixj_signals[SIG_READ_READY])
2962 ixj_kill_fasync(j, SIG_READ_READY, POLL_OUT);
2967 static short fsk[][6][20] =
2971 0, 17846, 29934, 32364, 24351, 8481, -10126, -25465, -32587, -29196,
2972 -16384, 1715, 19260, 30591, 32051, 23170, 6813, -11743, -26509, -32722
2975 -28377, -14876, 3425, 20621, 31163, 31650, 21925, 5126, -13328, -27481,
2976 -32767, -27481, -13328, 5126, 21925, 31650, 31163, 20621, 3425, -14876
2979 -28377, -32722, -26509, -11743, 6813, 23170, 32051, 30591, 19260, 1715,
2980 -16384, -29196, -32587, -25465, -10126, 8481, 24351, 32364, 29934, 17846
2983 0, -17846, -29934, -32364, -24351, -8481, 10126, 25465, 32587, 29196,
2984 16384, -1715, -19260, -30591, -32051, -23170, -6813, 11743, 26509, 32722
2987 28377, 14876, -3425, -20621, -31163, -31650, -21925, -5126, 13328, 27481,
2988 32767, 27481, 13328, -5126, -21925, -31650, -31163, -20621, -3425, 14876
2991 28377, 32722, 26509, 11743, -6813, -23170, -32051, -30591, -19260, -1715,
2992 16384, 29196, 32587, 25465, 10126, -8481, -24351, -32364, -29934, -17846
2997 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126,
2998 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126
3001 -28377, -21925, -13328, -3425, 6813, 16384, 24351, 29934, 32587, 32051,
3002 28377, 21925, 13328, 3425, -6813, -16384, -24351, -29934, -32587, -32051
3005 -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925,
3006 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925
3009 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126,
3010 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126
3013 28377, 21925, 13328, 3425, -6813, -16383, -24351, -29934, -32587, -32051,
3014 -28377, -21925, -13328, -3425, 6813, 16383, 24351, 29934, 32587, 32051
3017 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925,
3018 -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925
3024 static void ixj_write_cid_bit(IXJ *j, int bit)
3026 while (j->fskcnt < 20) {
3027 if(j->fskdcnt < (j->fsksize - 1))
3028 j->fskdata[j->fskdcnt++] = fsk[bit][j->fskz][j->fskcnt];
3041 static void ixj_write_cid_byte(IXJ *j, char byte)
3046 ixj_write_cid_bit(j, 0);
3047 ixj_write_cid_bit(j, cb.cbits.b0 ? 1 : 0);
3048 ixj_write_cid_bit(j, cb.cbits.b1 ? 1 : 0);
3049 ixj_write_cid_bit(j, cb.cbits.b2 ? 1 : 0);
3050 ixj_write_cid_bit(j, cb.cbits.b3 ? 1 : 0);
3051 ixj_write_cid_bit(j, cb.cbits.b4 ? 1 : 0);
3052 ixj_write_cid_bit(j, cb.cbits.b5 ? 1 : 0);
3053 ixj_write_cid_bit(j, cb.cbits.b6 ? 1 : 0);
3054 ixj_write_cid_bit(j, cb.cbits.b7 ? 1 : 0);
3055 ixj_write_cid_bit(j, 1);
3058 static void ixj_write_cid_seize(IXJ *j)
3062 for (cnt = 0; cnt < 150; cnt++) {
3063 ixj_write_cid_bit(j, 0);
3064 ixj_write_cid_bit(j, 1);
3066 for (cnt = 0; cnt < 180; cnt++) {
3067 ixj_write_cid_bit(j, 1);
3071 static void ixj_write_cidcw_seize(IXJ *j)
3075 for (cnt = 0; cnt < 80; cnt++) {
3076 ixj_write_cid_bit(j, 1);
3080 static int ixj_write_cid_string(IXJ *j, char *s, int checksum)
3084 for (cnt = 0; cnt < strlen(s); cnt++) {
3085 ixj_write_cid_byte(j, s[cnt]);
3086 checksum = (checksum + s[cnt]);
3091 static void ixj_pad_fsk(IXJ *j, int pad)
3095 for (cnt = 0; cnt < pad; cnt++) {
3096 if(j->fskdcnt < (j->fsksize - 1))
3097 j->fskdata[j->fskdcnt++] = 0x0000;
3099 for (cnt = 0; cnt < 720; cnt++) {
3100 if(j->fskdcnt < (j->fsksize - 1))
3101 j->fskdata[j->fskdcnt++] = 0x0000;
3105 static void ixj_pre_cid(IXJ *j)
3107 j->cid_play_codec = j->play_codec;
3108 j->cid_play_frame_size = j->play_frame_size;
3109 j->cid_play_volume = get_play_volume(j);
3110 j->cid_play_flag = j->flags.playing;
3112 j->cid_rec_codec = j->rec_codec;
3113 j->cid_rec_volume = get_rec_volume(j);
3114 j->cid_rec_flag = j->flags.recording;
3116 j->cid_play_aec_level = j->aec_level;
3118 switch(j->baseframe.low) {
3120 j->cid_base_frame_size = 20;
3123 j->cid_base_frame_size = 10;
3126 j->cid_base_frame_size = 30;
3133 j->flags.cidplay = 1;
3135 set_base_frame(j, 30);
3136 set_play_codec(j, LINEAR16);
3137 set_play_volume(j, 0x1B);
3141 static void ixj_post_cid(IXJ *j)
3145 if(j->cidsize > 5000) {
3146 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
3148 j->flags.cidplay = 0;
3149 if(ixjdebug & 0x0200) {
3150 printk("IXJ phone%d Finished Playing CallerID data %ld\n", j->board, jiffies);
3156 set_base_frame(j, j->cid_base_frame_size);
3157 set_play_codec(j, j->cid_play_codec);
3158 ixj_aec_start(j, j->cid_play_aec_level);
3159 set_play_volume(j, j->cid_play_volume);
3161 set_rec_codec(j, j->cid_rec_codec);
3162 set_rec_volume(j, j->cid_rec_volume);
3165 ixj_record_start(j);
3167 if(j->cid_play_flag)
3170 if(j->cid_play_flag) {
3171 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3175 static void ixj_write_cid(IXJ *j)
3180 char mdmflen, len1, len2, len3;
3185 if (j->dsp.low == 0x20 || j->flags.cidplay)
3188 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3189 j->cidsize = j->cidcnt = 0;
3193 strcpy(sdmf1, j->cid_send.month);
3194 strcat(sdmf1, j->cid_send.day);
3195 strcat(sdmf1, j->cid_send.hour);
3196 strcat(sdmf1, j->cid_send.min);
3197 strcpy(sdmf2, j->cid_send.number);
3198 strcpy(sdmf3, j->cid_send.name);
3200 len1 = strlen(sdmf1);
3201 len2 = strlen(sdmf2);
3202 len3 = strlen(sdmf3);
3203 mdmflen = len1 + len2 + len3 + 6;
3206 ixj_write_cid_seize(j);
3208 ixj_write_cid_byte(j, 0x80);
3210 ixj_write_cid_byte(j, mdmflen);
3211 checksum = checksum + mdmflen;
3213 ixj_write_cid_byte(j, 0x01);
3214 checksum = checksum + 0x01;
3215 ixj_write_cid_byte(j, len1);
3216 checksum = checksum + len1;
3217 checksum = ixj_write_cid_string(j, sdmf1, checksum);
3218 if(ixj_hookstate(j) & 1)
3221 ixj_write_cid_byte(j, 0x02);
3222 checksum = checksum + 0x02;
3223 ixj_write_cid_byte(j, len2);
3224 checksum = checksum + len2;
3225 checksum = ixj_write_cid_string(j, sdmf2, checksum);
3226 if(ixj_hookstate(j) & 1)
3229 ixj_write_cid_byte(j, 0x07);
3230 checksum = checksum + 0x07;
3231 ixj_write_cid_byte(j, len3);
3232 checksum = checksum + len3;
3233 checksum = ixj_write_cid_string(j, sdmf3, checksum);
3234 if(ixj_hookstate(j) & 1)
3241 ixj_write_cid_byte(j, (char) checksum);
3243 pad = j->fskdcnt % 240;
3247 ixj_pad_fsk(j, pad);
3254 static void ixj_write_cidcw(IXJ *j)
3261 char mdmflen, len1, len2, len3;
3266 if (j->dsp.low == 0x20 || j->flags.cidplay)
3269 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3270 j->cidsize = j->cidcnt = 0;
3274 j->flags.cidcw_ack = 0;
3281 ixj_init_tone(j, &ti);
3283 ixj_set_tone_on(1500, j);
3284 ixj_set_tone_off(32, j);
3285 if(ixjdebug & 0x0200) {
3286 printk("IXJ cidcw phone%d first tone start at %ld\n", j->board, jiffies);
3288 ixj_play_tone(j, 23);
3290 clear_bit(j->board, &j->busyflags);
3291 while(j->tone_state)
3292 schedule_timeout_interruptible(1);
3293 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
3294 schedule_timeout_interruptible(1);
3295 if(ixjdebug & 0x0200) {
3296 printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies);
3304 ixj_init_tone(j, &ti);
3306 ixj_set_tone_off(10, j);
3307 ixj_set_tone_on(600, j);
3308 if(ixjdebug & 0x0200) {
3309 printk("IXJ cidcw phone%d second tone start at %ld\n", j->board, jiffies);
3311 ixj_play_tone(j, 24);
3313 clear_bit(j->board, &j->busyflags);
3314 while(j->tone_state)
3315 schedule_timeout_interruptible(1);
3316 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
3317 schedule_timeout_interruptible(1);
3318 if(ixjdebug & 0x0200) {
3319 printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies);
3322 j->cidcw_wait = jiffies + ((50 * hertz) / 100);
3324 clear_bit(j->board, &j->busyflags);
3325 while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait))
3326 schedule_timeout_interruptible(1);
3327 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
3328 schedule_timeout_interruptible(1);
3330 if(!j->flags.cidcw_ack) {
3331 if(ixjdebug & 0x0200) {
3332 printk("IXJ cidcw phone%d did not receive ACK from display %ld\n", j->board, jiffies);
3335 if(j->cid_play_flag) {
3336 wake_up_interruptible(&j->write_q); /* Wake any blocked readers */
3342 j->flags.cidcw_ack = 0;
3343 strcpy(sdmf1, j->cid_send.month);
3344 strcat(sdmf1, j->cid_send.day);
3345 strcat(sdmf1, j->cid_send.hour);
3346 strcat(sdmf1, j->cid_send.min);
3347 strcpy(sdmf2, j->cid_send.number);
3348 strcpy(sdmf3, j->cid_send.name);
3350 len1 = strlen(sdmf1);
3351 len2 = strlen(sdmf2);
3352 len3 = strlen(sdmf3);
3353 mdmflen = len1 + len2 + len3 + 6;
3355 ixj_write_cidcw_seize(j);
3357 ixj_write_cid_byte(j, 0x80);
3359 ixj_write_cid_byte(j, mdmflen);
3360 checksum = checksum + mdmflen;
3362 ixj_write_cid_byte(j, 0x01);
3363 checksum = checksum + 0x01;
3364 ixj_write_cid_byte(j, len1);
3365 checksum = checksum + len1;
3366 checksum = ixj_write_cid_string(j, sdmf1, checksum);
3368 ixj_write_cid_byte(j, 0x02);
3369 checksum = checksum + 0x02;
3370 ixj_write_cid_byte(j, len2);
3371 checksum = checksum + len2;
3372 checksum = ixj_write_cid_string(j, sdmf2, checksum);
3374 ixj_write_cid_byte(j, 0x07);
3375 checksum = checksum + 0x07;
3376 ixj_write_cid_byte(j, len3);
3377 checksum = checksum + len3;
3378 checksum = ixj_write_cid_string(j, sdmf3, checksum);
3384 ixj_write_cid_byte(j, (char) checksum);
3386 pad = j->fskdcnt % 240;
3390 ixj_pad_fsk(j, pad);
3391 if(ixjdebug & 0x0200) {
3392 printk("IXJ cidcw phone%d sent FSK data at %ld\n", j->board, jiffies);
3396 static void ixj_write_vmwi(IXJ *j, int msg)
3403 if (j->dsp.low == 0x20 || j->flags.cidplay)
3406 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3407 j->cidsize = j->cidcnt = 0;
3413 if (j->port == PORT_POTS)
3414 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
3416 ixj_write_cid_seize(j);
3418 ixj_write_cid_byte(j, 0x82);
3420 ixj_write_cid_byte(j, mdmflen);
3421 checksum = checksum + mdmflen;
3423 ixj_write_cid_byte(j, 0x0B);
3424 checksum = checksum + 0x0B;
3425 ixj_write_cid_byte(j, 1);
3426 checksum = checksum + 1;
3429 ixj_write_cid_byte(j, 0xFF);
3430 checksum = checksum + 0xFF;
3433 ixj_write_cid_byte(j, 0x00);
3434 checksum = checksum + 0x00;
3441 ixj_write_cid_byte(j, (char) checksum);
3443 pad = j->fskdcnt % 240;
3447 ixj_pad_fsk(j, pad);
3450 static void ixj_write_frame(IXJ *j)
3452 int cnt, frame_count, dly;
3456 if(j->flags.cidplay) {
3457 for(cnt = 0; cnt < 480; cnt++) {
3458 if (!(cnt % 16) && !IsTxReady(j)) {
3460 while (!IsTxReady(j)) {
3468 dat.word = j->fskdata[j->cidcnt++];
3469 outb_p(dat.bytes.low, j->DSPbase + 0x0C);
3470 outb_p(dat.bytes.high, j->DSPbase + 0x0D);
3473 if(j->cidcnt >= j->fskdcnt) {
3476 /* This may seem rude, but if we just played one frame of FSK data for CallerID
3477 and there is real audio data in the buffer, we need to throw it away because
3478 we just used it's time slot */
3479 if (j->write_buffer_rp > j->write_buffer_wp) {
3480 j->write_buffer_rp += j->cid_play_frame_size * 2;
3481 if (j->write_buffer_rp >= j->write_buffer_end) {
3482 j->write_buffer_rp = j->write_buffer;
3484 j->write_buffers_empty++;
3485 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3487 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
3489 } else if (j->write_buffer && j->write_buffers_empty < 1) {
3490 if (j->write_buffer_wp > j->write_buffer_rp) {
3492 (j->write_buffer_wp - j->write_buffer_rp) / (j->play_frame_size * 2);
3494 if (j->write_buffer_rp > j->write_buffer_wp) {
3496 (j->write_buffer_wp - j->write_buffer) / (j->play_frame_size * 2) +
3497 (j->write_buffer_end - j->write_buffer_rp) / (j->play_frame_size * 2);
3499 if (frame_count >= 1) {
3500 if (j->ver.low == 0x12 && j->play_mode && j->flags.play_first_frame) {
3503 switch (j->play_mode) {
3504 case PLAYBACK_MODE_ULAW:
3505 case PLAYBACK_MODE_ALAW:
3506 blankword.low = blankword.high = 0xFF;
3508 case PLAYBACK_MODE_8LINEAR:
3509 case PLAYBACK_MODE_16LINEAR:
3511 blankword.low = blankword.high = 0x00;
3513 case PLAYBACK_MODE_8LINEAR_WSS:
3514 blankword.low = blankword.high = 0x80;
3517 for (cnt = 0; cnt < 16; cnt++) {
3518 if (!(cnt % 16) && !IsTxReady(j)) {
3520 while (!IsTxReady(j)) {
3528 outb_p((blankword.low), j->DSPbase + 0x0C);
3529 outb_p((blankword.high), j->DSPbase + 0x0D);
3531 j->flags.play_first_frame = 0;
3532 } else if (j->play_codec == G723_63 && j->flags.play_first_frame) {
3533 for (cnt = 0; cnt < 24; cnt++) {
3537 blankword.low = 0x02;
3538 blankword.high = 0x00;
3541 blankword.low = blankword.high = 0x00;
3543 if (!(cnt % 16) && !IsTxReady(j)) {
3545 while (!IsTxReady(j)) {
3553 outb_p((blankword.low), j->DSPbase + 0x0C);
3554 outb_p((blankword.high), j->DSPbase + 0x0D);
3556 j->flags.play_first_frame = 0;
3558 for (cnt = 0; cnt < j->play_frame_size * 2; cnt += 2) {
3559 if (!(cnt % 16) && !IsTxReady(j)) {
3561 while (!IsTxReady(j)) {
3569 /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */
3570 if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
3571 if (j->write_buffer_rp[cnt] == 0 &&
3572 j->write_buffer_rp[cnt + 1] == 0 &&
3573 j->write_buffer_rp[cnt + 2] == 0 &&
3574 j->write_buffer_rp[cnt + 3] == 0 &&
3575 j->write_buffer_rp[cnt + 4] == 0 &&
3576 j->write_buffer_rp[cnt + 5] == 0 &&
3577 j->write_buffer_rp[cnt + 6] == 0 &&
3578 j->write_buffer_rp[cnt + 7] == 0 &&
3579 j->write_buffer_rp[cnt + 8] == 0 &&
3580 j->write_buffer_rp[cnt + 9] == 0) {
3581 /* someone is trying to write silence lets make this a type 0 frame. */
3582 outb_p(0x00, j->DSPbase + 0x0C);
3583 outb_p(0x00, j->DSPbase + 0x0D);
3585 /* so all other frames are type 1. */
3586 outb_p(0x01, j->DSPbase + 0x0C);
3587 outb_p(0x00, j->DSPbase + 0x0D);
3590 outb_p(*(j->write_buffer_rp + cnt), j->DSPbase + 0x0C);
3591 outb_p(*(j->write_buffer_rp + cnt + 1), j->DSPbase + 0x0D);
3592 *(j->write_buffer_rp + cnt) = 0;
3593 *(j->write_buffer_rp + cnt + 1) = 0;
3595 j->write_buffer_rp += j->play_frame_size * 2;
3596 if (j->write_buffer_rp >= j->write_buffer_end) {
3597 j->write_buffer_rp = j->write_buffer;
3599 j->write_buffers_empty++;
3600 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3602 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
3609 if(j->ixj_signals[SIG_WRITE_READY]) {
3610 ixj_kill_fasync(j, SIG_WRITE_READY, POLL_OUT);
3614 static int idle(IXJ *j)
3616 if (ixj_WriteDSPCommand(0x0000, j)) /* DSP Idle */
3620 if (j->ssr.high || j->ssr.low) {
3624 j->flags.playing = 0;
3626 j->flags.recording = 0;
3631 static int set_base_frame(IXJ *j, int size)
3637 j->cid_play_aec_level = j->aec_level;
3639 for (cnt = 0; cnt < 10; cnt++) {
3643 if (j->ssr.high || j->ssr.low)
3645 if (j->dsp.low != 0x20) {
3649 /* Set Base Frame Size to 240 pg9-10 8021 */
3653 /* Set Base Frame Size to 160 pg9-10 8021 */
3657 /* Set Base Frame Size to 80 pg9-10 8021 */
3668 if (ixj_WriteDSPCommand(cmd, j)) {
3669 j->baseframe.high = j->baseframe.low = 0xFF;
3672 j->baseframe.high = j->ssr.high;
3673 j->baseframe.low = j->ssr.low;
3674 /* If the status returned is 0x0000 (pg9-9 8021) the call failed */
3675 if(j->baseframe.high == 0x00 && j->baseframe.low == 0x00) {
3679 ixj_aec_start(j, j->cid_play_aec_level);
3683 static int set_rec_codec(IXJ *j, int rate)
3687 j->rec_codec = rate;
3691 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3692 j->rec_frame_size = 12;
3699 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3700 j->rec_frame_size = 10;
3707 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
3708 j->rec_frame_size = 16;
3715 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3716 j->rec_frame_size = 9;
3723 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3724 j->rec_frame_size = 8;
3731 if (j->dsp.low != 0x20) {
3732 j->rec_frame_size = 48;
3739 if (j->dsp.low != 0x20) {
3740 if (!j->flags.g729_loaded) {
3744 switch (j->baseframe.low) {
3746 j->rec_frame_size = 10;
3749 j->rec_frame_size = 5;
3752 j->rec_frame_size = 15;
3761 if (j->dsp.low != 0x20) {
3762 if (!j->flags.g729_loaded) {
3766 switch (j->baseframe.low) {
3768 j->rec_frame_size = 12;
3771 j->rec_frame_size = 6;
3774 j->rec_frame_size = 18;
3783 switch (j->baseframe.low) {
3785 j->rec_frame_size = 80;
3788 j->rec_frame_size = 40;
3791 j->rec_frame_size = 120;
3797 switch (j->baseframe.low) {
3799 j->rec_frame_size = 80;
3802 j->rec_frame_size = 40;
3805 j->rec_frame_size = 120;
3811 switch (j->baseframe.low) {
3813 j->rec_frame_size = 160;
3816 j->rec_frame_size = 80;
3819 j->rec_frame_size = 240;
3825 switch (j->baseframe.low) {
3827 j->rec_frame_size = 80;
3830 j->rec_frame_size = 40;
3833 j->rec_frame_size = 120;
3839 switch (j->baseframe.low) {
3841 j->rec_frame_size = 80;
3844 j->rec_frame_size = 40;
3847 j->rec_frame_size = 120;
3853 kfree(j->read_buffer);
3854 j->rec_frame_size = 0;
3856 j->read_buffer = NULL;
3857 j->read_buffer_size = 0;
3864 static int ixj_record_start(IXJ *j)
3866 unsigned short cmd = 0x0000;
3868 if (j->read_buffer) {
3871 j->flags.recording = 1;
3872 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
3874 if(ixjdebug & 0x0002)
3875 printk("IXJ %d Starting Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
3878 switch (j->rec_codec) {
3886 cmd = 0x5130; /* TrueSpeech 8.5 */
3890 cmd = 0x5133; /* TrueSpeech 4.8 */
3894 cmd = 0x5134; /* TrueSpeech 4.1 */
3907 if (ixj_WriteDSPCommand(cmd, j))
3910 if (!j->read_buffer) {
3911 if (!j->read_buffer)
3912 j->read_buffer = kmalloc(j->rec_frame_size * 2, GFP_ATOMIC);
3913 if (!j->read_buffer) {
3914 printk("Read buffer allocation for ixj board %d failed!\n", j->board);
3918 j->read_buffer_size = j->rec_frame_size * 2;
3920 if (ixj_WriteDSPCommand(0x5102, j)) /* Set Poll sync mode */
3924 switch (j->rec_mode) {
3926 cmd = 0x1C03; /* Record C1 */
3930 if (j->ver.low == 0x12) {
3931 cmd = 0x1E03; /* Record C1 */
3934 cmd = 0x1E01; /* Record C1 */
3939 if (j->ver.low == 0x12) {
3940 cmd = 0x1E83; /* Record C1 */
3943 cmd = 0x1E81; /* Record C1 */
3948 if (j->ver.low == 0x12) {
3949 cmd = 0x1F03; /* Record C1 */
3952 cmd = 0x1F01; /* Record C1 */
3957 if (j->ver.low == 0x12) {
3958 cmd = 0x1F83; /* Record C1 */
3960 cmd = 0x1F81; /* Record C1 */
3964 if (ixj_WriteDSPCommand(cmd, j))
3967 if (j->flags.playing) {
3968 ixj_aec_start(j, j->aec_level);
3973 static void ixj_record_stop(IXJ *j)
3975 if (ixjdebug & 0x0002)
3976 printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
3978 kfree(j->read_buffer);
3979 j->read_buffer = NULL;
3980 j->read_buffer_size = 0;
3981 if (j->rec_mode > -1) {
3982 ixj_WriteDSPCommand(0x5120, j);
3985 j->flags.recording = 0;
3987 static void ixj_vad(IXJ *j, int arg)
3990 ixj_WriteDSPCommand(0x513F, j);
3992 ixj_WriteDSPCommand(0x513E, j);
3995 static void set_rec_depth(IXJ *j, int depth)
4001 ixj_WriteDSPCommand(0x5180 + depth, j);
4004 static void set_dtmf_prescale(IXJ *j, int volume)
4006 ixj_WriteDSPCommand(0xCF07, j);
4007 ixj_WriteDSPCommand(volume, j);
4010 static int get_dtmf_prescale(IXJ *j)
4012 ixj_WriteDSPCommand(0xCF05, j);
4013 return j->ssr.high << 8 | j->ssr.low;
4016 static void set_rec_volume(IXJ *j, int volume)
4018 if(j->aec_level == AEC_AGC) {
4019 if (ixjdebug & 0x0002)
4020 printk(KERN_INFO "IXJ: /dev/phone%d Setting AGC Threshold to 0x%4.4x\n", j->board, volume);
4021 ixj_WriteDSPCommand(0xCF96, j);
4022 ixj_WriteDSPCommand(volume, j);
4024 if (ixjdebug & 0x0002)
4025 printk(KERN_INFO "IXJ: /dev/phone %d Setting Record Volume to 0x%4.4x\n", j->board, volume);
4026 ixj_WriteDSPCommand(0xCF03, j);
4027 ixj_WriteDSPCommand(volume, j);
4031 static int set_rec_volume_linear(IXJ *j, int volume)
4033 int newvolume, dsprecmax;
4035 if (ixjdebug & 0x0002)
4036 printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Record Volume to 0x%4.4x\n", j->board, volume);
4037 if(volume > 100 || volume < 0) {
4041 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
4042 switch (j->cardtype) {
4048 ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
4049 ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
4050 ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
4052 case QTI_PHONEJACK_LITE:
4055 case QTI_PHONEJACK_PCI:
4064 newvolume = (dsprecmax * volume) / 100;
4065 set_rec_volume(j, newvolume);
4069 static int get_rec_volume(IXJ *j)
4071 if(j->aec_level == AEC_AGC) {
4072 if (ixjdebug & 0x0002)
4073 printk(KERN_INFO "Getting AGC Threshold\n");
4074 ixj_WriteDSPCommand(0xCF86, j);
4075 if (ixjdebug & 0x0002)
4076 printk(KERN_INFO "AGC Threshold is 0x%2.2x%2.2x\n", j->ssr.high, j->ssr.low);
4077 return j->ssr.high << 8 | j->ssr.low;
4079 if (ixjdebug & 0x0002)
4080 printk(KERN_INFO "Getting Record Volume\n");
4081 ixj_WriteDSPCommand(0xCF01, j);
4082 return j->ssr.high << 8 | j->ssr.low;
4086 static int get_rec_volume_linear(IXJ *j)
4088 int volume, newvolume, dsprecmax;
4090 switch (j->cardtype) {
4097 case QTI_PHONEJACK_LITE:
4100 case QTI_PHONEJACK_PCI:
4109 volume = get_rec_volume(j);
4110 newvolume = (volume * 100) / dsprecmax;
4116 static int get_rec_level(IXJ *j)
4120 ixj_WriteDSPCommand(0xCF88, j);
4122 retval = j->ssr.high << 8 | j->ssr.low;
4123 retval = (retval * 256) / 240;
4127 static void ixj_aec_start(IXJ *j, int level)
4129 j->aec_level = level;
4130 if (ixjdebug & 0x0002)
4131 printk(KERN_INFO "AGC set = 0x%2.2x\n", j->aec_level);
4135 if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
4136 ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer */
4138 ixj_WriteDSPCommand(0x0300, j);
4140 ixj_WriteDSPCommand(0xB001, j); /* AEC On */
4142 ixj_WriteDSPCommand(0xE013, j); /* Advanced AEC C1 */
4146 ixj_WriteDSPCommand(0x0000, j); /* Advanced AEC C2 = off */
4148 ixj_WriteDSPCommand(0xE011, j);
4149 ixj_WriteDSPCommand(0xFFFF, j);
4151 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4152 ixj_WriteDSPCommand(0x0000, j); /* to off */
4157 ixj_WriteDSPCommand(0x0600, j); /* Advanced AEC C2 = on medium */
4159 ixj_WriteDSPCommand(0xE011, j);
4160 ixj_WriteDSPCommand(0x0080, j);
4162 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4163 ixj_WriteDSPCommand(0x0000, j); /* to off */
4168 ixj_WriteDSPCommand(0x0C00, j); /* Advanced AEC C2 = on high */
4170 ixj_WriteDSPCommand(0xE011, j);
4171 ixj_WriteDSPCommand(0x0080, j);
4173 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4174 ixj_WriteDSPCommand(0x0000, j); /* to off */
4179 /* First we have to put the AEC into advance auto mode so that AGC will not conflict with it */
4180 ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
4182 ixj_WriteDSPCommand(0xE011, j);
4183 ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
4185 ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
4187 if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
4188 ixj_WriteDSPCommand(0x0224, j);
4190 ixj_WriteDSPCommand(0x1224, j);
4192 ixj_WriteDSPCommand(0xE014, j);
4193 ixj_WriteDSPCommand(0x0003, j); /* Lock threshold at 3dB */
4195 ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
4197 /* Now we can set the AGC initial parameters and turn it on */
4198 ixj_WriteDSPCommand(0xCF90, j); /* Set AGC Minimum gain */
4199 ixj_WriteDSPCommand(0x0020, j); /* to 0.125 (-18dB) */
4201 ixj_WriteDSPCommand(0xCF91, j); /* Set AGC Maximum gain */
4202 ixj_WriteDSPCommand(0x1000, j); /* to 16 (24dB) */
4204 ixj_WriteDSPCommand(0xCF92, j); /* Set AGC start gain */
4205 ixj_WriteDSPCommand(0x0800, j); /* to 8 (+18dB) */
4207 ixj_WriteDSPCommand(0xCF93, j); /* Set AGC hold time */
4208 ixj_WriteDSPCommand(0x1F40, j); /* to 2 seconds (units are 250us) */
4210 ixj_WriteDSPCommand(0xCF94, j); /* Set AGC Attack Time Constant */
4211 ixj_WriteDSPCommand(0x0005, j); /* to 8ms */
4213 ixj_WriteDSPCommand(0xCF95, j); /* Set AGC Decay Time Constant */
4214 ixj_WriteDSPCommand(0x000D, j); /* to 4096ms */
4216 ixj_WriteDSPCommand(0xCF96, j); /* Set AGC Attack Threshold */
4217 ixj_WriteDSPCommand(0x1200, j); /* to 25% */
4219 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4220 ixj_WriteDSPCommand(0x0001, j); /* to on */
4225 ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
4227 ixj_WriteDSPCommand(0xE011, j);
4228 ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
4230 ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
4232 if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
4233 ixj_WriteDSPCommand(0x0224, j);
4235 ixj_WriteDSPCommand(0x1224, j);
4237 ixj_WriteDSPCommand(0xE014, j);
4238 ixj_WriteDSPCommand(0x0003, j); /* Lock threshold at 3dB */
4240 ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
4247 static void aec_stop(IXJ *j)
4249 j->aec_level = AEC_OFF;
4250 if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
4251 ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer back */
4253 ixj_WriteDSPCommand(0x0700, j);
4255 if (j->play_mode != -1 && j->rec_mode != -1)
4257 ixj_WriteDSPCommand(0xB002, j); /* AEC Stop */
4261 static int set_play_codec(IXJ *j, int rate)
4265 j->play_codec = rate;
4269 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4270 j->play_frame_size = 12;
4277 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4278 j->play_frame_size = 10;
4285 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
4286 j->play_frame_size = 16;
4293 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4294 j->play_frame_size = 9;
4301 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4302 j->play_frame_size = 8;
4309 if (j->dsp.low != 0x20) {
4310 j->play_frame_size = 48;
4317 if (j->dsp.low != 0x20) {
4318 if (!j->flags.g729_loaded) {
4322 switch (j->baseframe.low) {
4324 j->play_frame_size = 10;
4327 j->play_frame_size = 5;
4330 j->play_frame_size = 15;
4339 if (j->dsp.low != 0x20) {
4340 if (!j->flags.g729_loaded) {
4344 switch (j->baseframe.low) {
4346 j->play_frame_size = 12;
4349 j->play_frame_size = 6;
4352 j->play_frame_size = 18;
4361 switch (j->baseframe.low) {
4363 j->play_frame_size = 80;
4366 j->play_frame_size = 40;
4369 j->play_frame_size = 120;
4375 switch (j->baseframe.low) {
4377 j->play_frame_size = 80;
4380 j->play_frame_size = 40;
4383 j->play_frame_size = 120;
4389 switch (j->baseframe.low) {
4391 j->play_frame_size = 160;
4394 j->play_frame_size = 80;
4397 j->play_frame_size = 240;
4403 switch (j->baseframe.low) {
4405 j->play_frame_size = 80;
4408 j->play_frame_size = 40;
4411 j->play_frame_size = 120;
4417 switch (j->baseframe.low) {
4419 j->play_frame_size = 80;
4422 j->play_frame_size = 40;
4425 j->play_frame_size = 120;
4431 kfree(j->write_buffer);
4432 j->play_frame_size = 0;
4434 j->write_buffer = NULL;
4435 j->write_buffer_size = 0;
4442 static int ixj_play_start(IXJ *j)
4444 unsigned short cmd = 0x0000;
4446 if (j->write_buffer) {
4450 if(ixjdebug & 0x0002)
4451 printk("IXJ %d Starting Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
4453 j->flags.playing = 1;
4454 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
4456 j->flags.play_first_frame = 1;
4459 if (!j->play_mode) {
4460 switch (j->play_codec) {
4468 cmd = 0x5230; /* TrueSpeech 8.5 */
4472 cmd = 0x5233; /* TrueSpeech 4.8 */
4476 cmd = 0x5234; /* TrueSpeech 4.1 */
4489 if (ixj_WriteDSPCommand(cmd, j))
4492 j->write_buffer = kmalloc(j->play_frame_size * 2, GFP_ATOMIC);
4493 if (!j->write_buffer) {
4494 printk("Write buffer allocation for ixj board %d failed!\n", j->board);
4497 /* j->write_buffers_empty = 2; */
4498 j->write_buffers_empty = 1;
4499 j->write_buffer_size = j->play_frame_size * 2;
4500 j->write_buffer_end = j->write_buffer + j->play_frame_size * 2;
4501 j->write_buffer_rp = j->write_buffer_wp = j->write_buffer;
4503 if (ixj_WriteDSPCommand(0x5202, j)) /* Set Poll sync mode */
4507 switch (j->play_mode) {
4512 if (j->ver.low == 0x12) {
4519 if (j->ver.low == 0x12) {
4526 if (j->ver.low == 0x12) {
4533 if (j->ver.low == 0x12) {
4540 if (ixj_WriteDSPCommand(cmd, j))
4543 if (ixj_WriteDSPCommand(0x2000, j)) /* Playback C2 */
4546 if (ixj_WriteDSPCommand(0x2000 + j->play_frame_size, j)) /* Playback C3 */
4549 if (j->flags.recording) {
4550 ixj_aec_start(j, j->aec_level);
4556 static void ixj_play_stop(IXJ *j)
4558 if (ixjdebug & 0x0002)
4559 printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
4561 kfree(j->write_buffer);
4562 j->write_buffer = NULL;
4563 j->write_buffer_size = 0;
4564 if (j->play_mode > -1) {
4565 ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */
4569 j->flags.playing = 0;
4572 static inline int get_play_level(IXJ *j)
4576 ixj_WriteDSPCommand(0xCF8F, j); /* 8022 Reference page 9-38 */
4577 return j->ssr.high << 8 | j->ssr.low;
4578 retval = j->ssr.high << 8 | j->ssr.low;
4579 retval = (retval * 256) / 240;
4583 static unsigned int ixj_poll(struct file *file_p, poll_table * wait)
4585 unsigned int mask = 0;
4587 IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
4589 poll_wait(file_p, &(j->poll_q), wait);
4590 if (j->read_buffer_ready > 0)
4591 mask |= POLLIN | POLLRDNORM; /* readable */
4592 if (j->write_buffers_empty > 0)
4593 mask |= POLLOUT | POLLWRNORM; /* writable */
4599 static int ixj_play_tone(IXJ *j, char tone)
4601 if (!j->tone_state) {
4602 if(ixjdebug & 0x0002) {
4603 printk("IXJ %d starting tone %d at %ld\n", j->board, tone, jiffies);
4605 if (j->dsp.low == 0x20) {
4608 j->tone_start_jif = jiffies;
4613 j->tone_index = tone;
4614 if (ixj_WriteDSPCommand(0x6000 + j->tone_index, j))
4620 static int ixj_set_tone_on(unsigned short arg, IXJ *j)
4622 j->tone_on_time = arg;
4624 if (ixj_WriteDSPCommand(0x6E04, j)) /* Set Tone On Period */
4628 if (ixj_WriteDSPCommand(arg, j))
4634 static int SCI_WaitHighSCI(IXJ *j)
4638 j->pld_scrr.byte = inb_p(j->XILINXbase);
4639 if (!j->pld_scrr.bits.sci) {
4640 for (cnt = 0; cnt < 10; cnt++) {
4642 j->pld_scrr.byte = inb_p(j->XILINXbase);
4644 if ((j->pld_scrr.bits.sci))
4647 if (ixjdebug & 0x0001)
4648 printk(KERN_INFO "SCI Wait High failed %x\n", j->pld_scrr.byte);
4654 static int SCI_WaitLowSCI(IXJ *j)
4658 j->pld_scrr.byte = inb_p(j->XILINXbase);
4659 if (j->pld_scrr.bits.sci) {
4660 for (cnt = 0; cnt < 10; cnt++) {
4662 j->pld_scrr.byte = inb_p(j->XILINXbase);
4664 if (!(j->pld_scrr.bits.sci))
4667 if (ixjdebug & 0x0001)
4668 printk(KERN_INFO "SCI Wait Low failed %x\n", j->pld_scrr.byte);
4674 static int SCI_Control(IXJ *j, int control)
4678 j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
4680 j->pld_scrw.bits.c1 = 0; /* to no selection */
4683 case SCI_Enable_DAA:
4684 j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
4686 j->pld_scrw.bits.c1 = 0; /* to write to DAA */
4689 case SCI_Enable_Mixer:
4690 j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
4692 j->pld_scrw.bits.c1 = 1; /* to write to mixer */
4695 case SCI_Enable_EEPROM:
4696 j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
4698 j->pld_scrw.bits.c1 = 1; /* to write to EEPROM */
4705 outb_p(j->pld_scrw.byte, j->XILINXbase);
4711 case SCI_Enable_DAA:
4712 case SCI_Enable_Mixer:
4713 case SCI_Enable_EEPROM:
4714 if (!SCI_WaitHighSCI(j))
4724 static int SCI_Prepare(IXJ *j)
4726 if (!SCI_Control(j, SCI_End))
4729 if (!SCI_WaitLowSCI(j))
4735 static int ixj_get_mixer(long val, IXJ *j)
4737 int reg = (val & 0x1F00) >> 8;
4738 return j->mix.vol[reg];
4741 static int ixj_mixer(long val, IXJ *j)
4745 bytes.high = (val & 0x1F00) >> 8;
4746 bytes.low = val & 0x00FF;
4748 /* save mixer value so we can get back later on */
4749 j->mix.vol[bytes.high] = bytes.low;
4751 outb_p(bytes.high & 0x1F, j->XILINXbase + 0x03); /* Load Mixer Address */
4753 outb_p(bytes.low, j->XILINXbase + 0x02); /* Load Mixer Data */
4755 SCI_Control(j, SCI_Enable_Mixer);
4757 SCI_Control(j, SCI_End);
4762 static int daa_load(BYTES * p_bytes, IXJ *j)
4764 outb_p(p_bytes->high, j->XILINXbase + 0x03);
4765 outb_p(p_bytes->low, j->XILINXbase + 0x02);
4766 if (!SCI_Control(j, SCI_Enable_DAA))
4772 static int ixj_daa_cr4(IXJ *j, char reg)
4776 switch (j->daa_mode) {
4780 case SOP_PU_RINGING:
4783 case SOP_PU_CONVERSATION:
4786 case SOP_PU_PULSEDIALING:
4791 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = reg;
4793 switch (j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGX) {
4795 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 0;
4798 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 2;
4801 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 1;
4804 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 3;
4808 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
4810 if (!daa_load(&bytes, j))
4813 if (!SCI_Prepare(j))
4819 static char daa_int_read(IXJ *j)
4823 if (!SCI_Prepare(j))
4828 outb_p(bytes.high, j->XILINXbase + 0x03);
4829 outb_p(bytes.low, j->XILINXbase + 0x02);
4831 if (!SCI_Control(j, SCI_Enable_DAA))
4834 bytes.high = inb_p(j->XILINXbase + 0x03);
4835 bytes.low = inb_p(j->XILINXbase + 0x02);
4836 if (bytes.low != ALISDAA_ID_BYTE) {
4837 if (ixjdebug & 0x0001)
4838 printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
4841 if (!SCI_Control(j, SCI_Enable_DAA))
4843 if (!SCI_Control(j, SCI_End))
4846 bytes.high = inb_p(j->XILINXbase + 0x03);
4847 bytes.low = inb_p(j->XILINXbase + 0x02);
4849 j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg = bytes.high;
4854 static char daa_CR_read(IXJ *j, int cr)
4859 if (!SCI_Prepare(j))
4862 switch (j->daa_mode) {
4864 bytes.high = 0x30 + cr;
4866 case SOP_PU_RINGING:
4867 bytes.high = 0x70 + cr;
4869 case SOP_PU_CONVERSATION:
4870 bytes.high = 0xB0 + cr;
4872 case SOP_PU_PULSEDIALING:
4874 bytes.high = 0xF0 + cr;
4880 outb_p(bytes.high, j->XILINXbase + 0x03);
4881 outb_p(bytes.low, j->XILINXbase + 0x02);
4883 if (!SCI_Control(j, SCI_Enable_DAA))
4886 bytes.high = inb_p(j->XILINXbase + 0x03);
4887 bytes.low = inb_p(j->XILINXbase + 0x02);
4888 if (bytes.low != ALISDAA_ID_BYTE) {
4889 if (ixjdebug & 0x0001)
4890 printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
4893 if (!SCI_Control(j, SCI_Enable_DAA))
4895 if (!SCI_Control(j, SCI_End))
4898 wdata.word = inw_p(j->XILINXbase + 0x02);
4902 j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = wdata.bytes.high;
4905 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = wdata.bytes.high;
4908 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = wdata.bytes.high;
4911 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = wdata.bytes.high;
4914 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = wdata.bytes.high;
4917 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = wdata.bytes.high;
4925 static int ixj_daa_cid_reset(IXJ *j)
4930 if (ixjdebug & 0x0002)
4931 printk("DAA Clearing CID ram\n");
4933 if (!SCI_Prepare(j))
4938 outb_p(bytes.high, j->XILINXbase + 0x03);
4939 outb_p(bytes.low, j->XILINXbase + 0x02);
4941 if (!SCI_Control(j, SCI_Enable_DAA))
4944 if (!SCI_WaitHighSCI(j))
4947 for (i = 0; i < ALISDAA_CALLERID_SIZE - 1; i += 2) {
4948 bytes.high = bytes.low = 0x00;
4949 outb_p(bytes.high, j->XILINXbase + 0x03);
4951 if (i < ALISDAA_CALLERID_SIZE - 1)
4952 outb_p(bytes.low, j->XILINXbase + 0x02);
4954 if (!SCI_Control(j, SCI_Enable_DAA))
4957 if (!SCI_WaitHighSCI(j))
4962 if (!SCI_Control(j, SCI_End))
4965 if (ixjdebug & 0x0002)
4966 printk("DAA CID ram cleared\n");
4971 static int ixj_daa_cid_read(IXJ *j)
4975 char CID[ALISDAA_CALLERID_SIZE];
4979 if (!SCI_Prepare(j))
4984 outb_p(bytes.high, j->XILINXbase + 0x03);
4985 outb_p(bytes.low, j->XILINXbase + 0x02);
4987 if (!SCI_Control(j, SCI_Enable_DAA))
4990 if (!SCI_WaitHighSCI(j))
4993 bytes.high = inb_p(j->XILINXbase + 0x03);
4994 bytes.low = inb_p(j->XILINXbase + 0x02);
4995 if (bytes.low != ALISDAA_ID_BYTE) {
4996 if (ixjdebug & 0x0001)
4997 printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
5000 for (i = 0; i < ALISDAA_CALLERID_SIZE; i += 2) {
5001 bytes.high = bytes.low = 0x00;
5002 outb_p(bytes.high, j->XILINXbase + 0x03);
5003 outb_p(bytes.low, j->XILINXbase + 0x02);
5005 if (!SCI_Control(j, SCI_Enable_DAA))
5008 if (!SCI_WaitHighSCI(j))
5011 CID[i + 0] = inb_p(j->XILINXbase + 0x03);
5012 CID[i + 1] = inb_p(j->XILINXbase + 0x02);
5015 if (!SCI_Control(j, SCI_End))
5019 pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
5022 if ((pIn[1] & 0x03) == 0x01) {
5025 if ((pIn[2] & 0x0c) == 0x04) {
5026 pOut[1] = ((pIn[2] & 0x03) << 6) | ((pIn[1] & 0xfc) >> 2);
5028 if ((pIn[3] & 0x30) == 0x10) {
5029 pOut[2] = ((pIn[3] & 0x0f) << 4) | ((pIn[2] & 0xf0) >> 4);
5031 if ((pIn[4] & 0xc0) == 0x40) {
5032 pOut[3] = ((pIn[4] & 0x3f) << 2) | ((pIn[3] & 0xc0) >> 6);
5036 pIn += 5, pOut += 4;
5038 memset(&j->cid, 0, sizeof(PHONE_CID));
5039 pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
5041 strncpy(j->cid.month, pOut, 2);
5043 strncpy(j->cid.day, pOut, 2);
5045 strncpy(j->cid.hour, pOut, 2);
5047 strncpy(j->cid.min, pOut, 2);
5049 j->cid.numlen = *pOut;
5051 strncpy(j->cid.number, pOut, j->cid.numlen);
5052 pOut += j->cid.numlen + 1;
5053 j->cid.namelen = *pOut;
5055 strncpy(j->cid.name, pOut, j->cid.namelen);
5057 ixj_daa_cid_reset(j);
5061 static char daa_get_version(IXJ *j)
5065 if (!SCI_Prepare(j))
5070 outb_p(bytes.high, j->XILINXbase + 0x03);
5071 outb_p(bytes.low, j->XILINXbase + 0x02);
5073 if (!SCI_Control(j, SCI_Enable_DAA))
5076 bytes.high = inb_p(j->XILINXbase + 0x03);
5077 bytes.low = inb_p(j->XILINXbase + 0x02);
5078 if (bytes.low != ALISDAA_ID_BYTE) {
5079 if (ixjdebug & 0x0001)
5080 printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
5083 if (!SCI_Control(j, SCI_Enable_DAA))
5086 if (!SCI_Control(j, SCI_End))
5089 bytes.high = inb_p(j->XILINXbase + 0x03);
5090 bytes.low = inb_p(j->XILINXbase + 0x02);
5091 if (ixjdebug & 0x0002)
5092 printk("DAA CR5 Byte high = 0x%x low = 0x%x\n", bytes.high, bytes.low);
5093 j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = bytes.high;
5097 static int daa_set_mode(IXJ *j, int mode)
5100 The DAA *MUST* be in the conversation mode if the
5101 PSTN line is to be seized (PSTN line off-hook).
5102 Taking the PSTN line off-hook while the DAA is in
5103 a mode other than conversation mode will cause a
5104 hardware failure of the ALIS-A part.
5107 The DAA can only go to SLEEP, RINGING or PULSEDIALING modes
5108 if the PSTN line is on-hook. Failure to have the PSTN line
5109 in the on-hook state WILL CAUSE A HARDWARE FAILURE OF THE
5115 j->flags.pstn_rmr = 0;
5117 if (!SCI_Prepare(j))
5122 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5124 outb_p(j->pld_scrw.byte, j->XILINXbase);
5125 j->pld_slicw.bits.rly2 = 0;
5126 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5128 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5129 daa_load(&bytes, j);
5130 if (!SCI_Prepare(j))
5133 j->daa_mode = SOP_PU_SLEEP;
5136 if(j->daa_mode == SOP_PU_SLEEP)
5140 if (ixjdebug & 0x0008)
5141 printk(KERN_INFO "phone DAA: SOP_PU_SLEEP at %ld\n", jiffies);
5142 /* if(j->daa_mode == SOP_PU_CONVERSATION) */
5144 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5146 outb_p(j->pld_scrw.byte, j->XILINXbase);
5147 j->pld_slicw.bits.rly2 = 0;
5148 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5150 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5151 daa_load(&bytes, j);
5152 if (!SCI_Prepare(j))
5155 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5157 outb_p(j->pld_scrw.byte, j->XILINXbase);
5158 j->pld_slicw.bits.rly2 = 0;
5159 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5161 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5162 daa_load(&bytes, j);
5163 if (!SCI_Prepare(j))
5166 j->daa_mode = SOP_PU_SLEEP;
5167 j->flags.pstn_ringing = 0;
5168 j->ex.bits.pstn_ring = 0;
5169 j->pstn_sleeptil = jiffies + (hertz / 4);
5170 wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
5171 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
5172 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
5174 case SOP_PU_RINGING:
5175 if (ixjdebug & 0x0008)
5176 printk(KERN_INFO "phone DAA: SOP_PU_RINGING at %ld\n", jiffies);
5177 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5179 outb_p(j->pld_scrw.byte, j->XILINXbase);
5180 j->pld_slicw.bits.rly2 = 0;
5181 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5183 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5184 daa_load(&bytes, j);
5185 if (!SCI_Prepare(j))
5187 j->daa_mode = SOP_PU_RINGING;
5189 case SOP_PU_CONVERSATION:
5190 if (ixjdebug & 0x0008)
5191 printk(KERN_INFO "phone DAA: SOP_PU_CONVERSATION at %ld\n", jiffies);
5193 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5194 daa_load(&bytes, j);
5195 if (!SCI_Prepare(j))
5197 j->pld_slicw.bits.rly2 = 1;
5198 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5199 j->pld_scrw.bits.daafsyncen = 1; /* Turn on DAA Frame Sync */
5201 outb_p(j->pld_scrw.byte, j->XILINXbase);
5202 j->daa_mode = SOP_PU_CONVERSATION;
5203 j->flags.pstn_ringing = 0;
5204 j->ex.bits.pstn_ring = 0;
5205 j->pstn_sleeptil = jiffies;
5206 j->pstn_ring_start = j->pstn_ring_stop = j->pstn_ring_int = 0;
5208 case SOP_PU_PULSEDIALING:
5209 if (ixjdebug & 0x0008)
5210 printk(KERN_INFO "phone DAA: SOP_PU_PULSEDIALING at %ld\n", jiffies);
5211 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5213 outb_p(j->pld_scrw.byte, j->XILINXbase);
5214 j->pld_slicw.bits.rly2 = 0;
5215 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5217 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5218 daa_load(&bytes, j);
5219 if (!SCI_Prepare(j))
5221 j->daa_mode = SOP_PU_PULSEDIALING;
5229 static int ixj_daa_write(IXJ *j)
5233 j->flags.pstncheck = 1;
5235 daa_set_mode(j, SOP_PU_SLEEP);
5237 if (!SCI_Prepare(j))
5240 outb_p(j->pld_scrw.byte, j->XILINXbase);
5243 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
5244 if (!daa_load(&bytes, j))
5247 bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg;
5248 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg;
5249 if (!daa_load(&bytes, j))
5252 bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg;
5253 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5254 if (!daa_load(&bytes, j))
5257 if (!SCI_Prepare(j))
5261 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg;
5262 if (!daa_load(&bytes, j))
5265 bytes.high = j->m_DAAShadowRegs.XOP_xr6_W.reg;
5266 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg;
5267 if (!daa_load(&bytes, j))
5270 bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg;
5271 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg;
5272 if (!daa_load(&bytes, j))
5275 bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg;
5276 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg;
5277 if (!daa_load(&bytes, j))
5280 bytes.high = j->m_DAAShadowRegs.XOP_xr0_W.reg;
5282 if (!daa_load(&bytes, j))
5285 if (!SCI_Prepare(j))
5289 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7];
5290 if (!daa_load(&bytes, j))
5293 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6];
5294 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5];
5295 if (!daa_load(&bytes, j))
5298 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4];
5299 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3];
5300 if (!daa_load(&bytes, j))
5303 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2];
5304 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1];
5305 if (!daa_load(&bytes, j))
5308 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0];
5310 if (!daa_load(&bytes, j))
5313 if (!SCI_Control(j, SCI_End))
5315 if (!SCI_WaitLowSCI(j))
5319 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7];
5320 if (!daa_load(&bytes, j))
5323 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6];
5324 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5];
5325 if (!daa_load(&bytes, j))
5328 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4];
5329 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3];
5330 if (!daa_load(&bytes, j))
5333 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2];
5334 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1];
5335 if (!daa_load(&bytes, j))
5338 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0];
5340 if (!daa_load(&bytes, j))
5343 if (!SCI_Control(j, SCI_End))
5345 if (!SCI_WaitLowSCI(j))
5349 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7];
5350 if (!daa_load(&bytes, j))
5353 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6];
5354 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5];
5355 if (!daa_load(&bytes, j))
5358 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4];
5359 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3];
5360 if (!daa_load(&bytes, j))
5363 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2];
5364 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1];
5365 if (!daa_load(&bytes, j))
5368 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0];
5370 if (!daa_load(&bytes, j))
5373 if (!SCI_Control(j, SCI_End))
5375 if (!SCI_WaitLowSCI(j))
5379 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7];
5380 if (!daa_load(&bytes, j))
5383 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6];
5384 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5];
5385 if (!daa_load(&bytes, j))
5388 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4];
5389 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3];
5390 if (!daa_load(&bytes, j))
5393 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2];
5394 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1];
5395 if (!daa_load(&bytes, j))
5398 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0];
5400 if (!daa_load(&bytes, j))
5403 if (!SCI_Control(j, SCI_End))
5405 if (!SCI_WaitLowSCI(j))
5409 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7];
5410 if (!daa_load(&bytes, j))
5413 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6];
5414 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5];
5415 if (!daa_load(&bytes, j))
5418 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4];
5419 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3];
5420 if (!daa_load(&bytes, j))
5423 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2];
5424 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1];
5425 if (!daa_load(&bytes, j))
5428 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0];
5430 if (!daa_load(&bytes, j))
5433 if (!SCI_Control(j, SCI_End))
5435 if (!SCI_WaitLowSCI(j))
5439 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7];
5440 if (!daa_load(&bytes, j))
5443 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6];
5444 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5];
5445 if (!daa_load(&bytes, j))
5448 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4];
5449 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3];
5450 if (!daa_load(&bytes, j))
5453 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2];
5454 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1];
5455 if (!daa_load(&bytes, j))
5458 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0];
5460 if (!daa_load(&bytes, j))
5463 if (!SCI_Control(j, SCI_End))
5465 if (!SCI_WaitLowSCI(j))
5469 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7];
5470 if (!daa_load(&bytes, j))
5473 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6];
5474 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5];
5475 if (!daa_load(&bytes, j))
5478 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4];
5479 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3];
5480 if (!daa_load(&bytes, j))
5483 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2];
5484 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1];
5485 if (!daa_load(&bytes, j))
5488 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0];
5490 if (!daa_load(&bytes, j))
5493 if (!SCI_Control(j, SCI_End))
5495 if (!SCI_WaitLowSCI(j))
5499 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7];
5500 if (!daa_load(&bytes, j))
5503 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6];
5504 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5];
5505 if (!daa_load(&bytes, j))
5508 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4];
5509 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3];
5510 if (!daa_load(&bytes, j))
5513 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2];
5514 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1];
5515 if (!daa_load(&bytes, j))
5518 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0];
5520 if (!daa_load(&bytes, j))
5523 if (!SCI_Control(j, SCI_End))
5525 if (!SCI_WaitLowSCI(j))
5529 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7];
5530 if (!daa_load(&bytes, j))
5533 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6];
5534 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5];
5535 if (!daa_load(&bytes, j))
5538 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4];
5539 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3];
5540 if (!daa_load(&bytes, j))
5543 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2];
5544 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1];
5545 if (!daa_load(&bytes, j))
5548 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0];
5550 if (!daa_load(&bytes, j))
5553 if (!SCI_Control(j, SCI_End))
5555 if (!SCI_WaitLowSCI(j))
5559 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3];
5560 if (!daa_load(&bytes, j))
5563 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2];
5564 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1];
5565 if (!daa_load(&bytes, j))
5568 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0];
5570 if (!daa_load(&bytes, j))
5573 if (!SCI_Control(j, SCI_End))
5575 if (!SCI_WaitLowSCI(j))
5579 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3];
5580 if (!daa_load(&bytes, j))
5583 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2];
5584 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1];
5585 if (!daa_load(&bytes, j))
5588 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0];
5590 if (!daa_load(&bytes, j))
5593 if (!SCI_Control(j, SCI_End))
5595 if (!SCI_WaitLowSCI(j))
5599 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3];
5600 if (!daa_load(&bytes, j))
5603 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2];
5604 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1];
5605 if (!daa_load(&bytes, j))
5608 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0];
5610 if (!daa_load(&bytes, j))
5613 if (!SCI_Control(j, SCI_End))
5615 if (!SCI_WaitLowSCI(j))
5619 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3];
5620 if (!daa_load(&bytes, j))
5623 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2];
5624 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1];
5625 if (!daa_load(&bytes, j))
5628 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0];
5630 if (!daa_load(&bytes, j))
5633 if (!SCI_Control(j, SCI_End))
5635 if (!SCI_WaitLowSCI(j))
5639 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3];
5640 if (!daa_load(&bytes, j))
5643 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2];
5644 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1];
5645 if (!daa_load(&bytes, j))
5648 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0];
5650 if (!daa_load(&bytes, j))
5653 if (!SCI_Control(j, SCI_End))
5655 if (!SCI_WaitLowSCI(j))
5659 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7];
5660 if (!daa_load(&bytes, j))
5663 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6];
5664 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5];
5665 if (!daa_load(&bytes, j))
5668 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4];
5669 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3];
5670 if (!daa_load(&bytes, j))
5673 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2];
5674 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1];
5675 if (!daa_load(&bytes, j))
5678 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0];
5680 if (!daa_load(&bytes, j))
5683 if (!SCI_Control(j, SCI_End))
5685 if (!SCI_WaitLowSCI(j))
5689 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7];
5690 if (!daa_load(&bytes, j))
5693 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6];
5694 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5];
5695 if (!daa_load(&bytes, j))
5698 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4];
5699 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3];
5700 if (!daa_load(&bytes, j))
5703 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2];
5704 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1];
5705 if (!daa_load(&bytes, j))
5708 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0];
5710 if (!daa_load(&bytes, j))
5714 j->pld_scrr.byte = inb_p(j->XILINXbase);
5715 if (!SCI_Control(j, SCI_End))
5718 outb_p(j->pld_scrw.byte, j->XILINXbase);
5720 if (ixjdebug & 0x0002)
5721 printk("DAA Coefficients Loaded\n");
5723 j->flags.pstncheck = 0;
5727 static int ixj_set_tone_off(unsigned short arg, IXJ *j)
5729 j->tone_off_time = arg;
5730 if (ixj_WriteDSPCommand(0x6E05, j)) /* Set Tone Off Period */
5733 if (ixj_WriteDSPCommand(arg, j))
5738 static int ixj_get_tone_on(IXJ *j)
5740 if (ixj_WriteDSPCommand(0x6E06, j)) /* Get Tone On Period */
5746 static int ixj_get_tone_off(IXJ *j)
5748 if (ixj_WriteDSPCommand(0x6E07, j)) /* Get Tone Off Period */
5754 static void ixj_busytone(IXJ *j)
5756 j->flags.ringback = 0;
5757 j->flags.dialtone = 0;
5758 j->flags.busytone = 1;
5759 ixj_set_tone_on(0x07D0, j);
5760 ixj_set_tone_off(0x07D0, j);
5761 ixj_play_tone(j, 27);
5764 static void ixj_dialtone(IXJ *j)
5766 j->flags.ringback = 0;
5767 j->flags.dialtone = 1;
5768 j->flags.busytone = 0;
5769 if (j->dsp.low == 0x20) {
5772 ixj_set_tone_on(0xFFFF, j);
5773 ixj_set_tone_off(0x0000, j);
5774 ixj_play_tone(j, 25);
5778 static void ixj_cpt_stop(IXJ *j)
5780 if(j->tone_state || j->tone_cadence_state)
5782 j->flags.dialtone = 0;
5783 j->flags.busytone = 0;
5784 j->flags.ringback = 0;
5785 ixj_set_tone_on(0x0001, j);
5786 ixj_set_tone_off(0x0000, j);
5787 ixj_play_tone(j, 0);
5788 j->tone_state = j->tone_cadence_state = 0;
5790 kfree(j->cadence_t->ce);
5791 kfree(j->cadence_t);
5792 j->cadence_t = NULL;
5795 if (j->play_mode == -1 && j->rec_mode == -1)
5797 if (j->play_mode != -1 && j->dsp.low == 0x20)
5799 if (j->rec_mode != -1 && j->dsp.low == 0x20)
5800 ixj_record_start(j);
5803 static void ixj_ringback(IXJ *j)
5805 j->flags.busytone = 0;
5806 j->flags.dialtone = 0;
5807 j->flags.ringback = 1;
5808 ixj_set_tone_on(0x0FA0, j);
5809 ixj_set_tone_off(0x2EE0, j);
5810 ixj_play_tone(j, 26);
5813 static void ixj_testram(IXJ *j)
5815 ixj_WriteDSPCommand(0x3001, j); /* Test External SRAM */
5818 static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp)
5821 IXJ_CADENCE_ELEMENT __user *cep;
5822 IXJ_CADENCE_ELEMENT *lcep;
5826 lcp = kmalloc(sizeof(ixj_cadence), GFP_KERNEL);
5831 if (copy_from_user(&lcp->elements_used,
5832 &cp->elements_used, sizeof(int)))
5834 if (copy_from_user(&lcp->termination,
5835 &cp->termination, sizeof(IXJ_CADENCE_TERM)))
5837 if (get_user(cep, &cp->ce))
5841 if ((unsigned)lcp->elements_used >= ~0U/sizeof(IXJ_CADENCE_ELEMENT))
5845 lcep = kmalloc(sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used, GFP_KERNEL);
5850 if (copy_from_user(lcep, cep, sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used))
5854 kfree(j->cadence_t->ce);
5855 kfree(j->cadence_t);
5857 lcp->ce = (void *) lcep;
5859 j->tone_cadence_state = 0;
5860 ixj_set_tone_on(lcp->ce[0].tone_on_time, j);
5861 ixj_set_tone_off(lcp->ce[0].tone_off_time, j);
5862 if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
5863 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
5864 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
5865 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
5866 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
5867 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
5868 ixj_init_tone(j, &ti);
5870 ixj_play_tone(j, lcp->ce[0].index);
5879 static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp)
5881 IXJ_FILTER_CADENCE *lcp;
5882 lcp = memdup_user(cp, sizeof(IXJ_FILTER_CADENCE));
5884 if(ixjdebug & 0x0001) {
5885 printk(KERN_INFO "Could not allocate memory for cadence or could not copy cadence to kernel\n");
5887 return PTR_ERR(lcp);
5889 if (lcp->filter > 5) {
5890 if(ixjdebug & 0x0001) {
5891 printk(KERN_INFO "Cadence out of range\n");
5896 j->cadence_f[lcp->filter].state = 0;
5897 j->cadence_f[lcp->filter].enable = lcp->enable;
5898 j->filter_en[lcp->filter] = j->cadence_f[lcp->filter].en_filter = lcp->en_filter;
5899 j->cadence_f[lcp->filter].on1 = lcp->on1;
5900 j->cadence_f[lcp->filter].on1min = 0;
5901 j->cadence_f[lcp->filter].on1max = 0;
5902 j->cadence_f[lcp->filter].off1 = lcp->off1;
5903 j->cadence_f[lcp->filter].off1min = 0;
5904 j->cadence_f[lcp->filter].off1max = 0;
5905 j->cadence_f[lcp->filter].on2 = lcp->on2;
5906 j->cadence_f[lcp->filter].on2min = 0;
5907 j->cadence_f[lcp->filter].on2max = 0;
5908 j->cadence_f[lcp->filter].off2 = lcp->off2;
5909 j->cadence_f[lcp->filter].off2min = 0;
5910 j->cadence_f[lcp->filter].off2max = 0;
5911 j->cadence_f[lcp->filter].on3 = lcp->on3;
5912 j->cadence_f[lcp->filter].on3min = 0;
5913 j->cadence_f[lcp->filter].on3max = 0;
5914 j->cadence_f[lcp->filter].off3 = lcp->off3;
5915 j->cadence_f[lcp->filter].off3min = 0;
5916 j->cadence_f[lcp->filter].off3max = 0;
5917 if(ixjdebug & 0x0002) {
5918 printk(KERN_INFO "Cadence %d loaded\n", lcp->filter);
5924 static void add_caps(IXJ *j)
5927 j->caplist[j->caps].cap = PHONE_VENDOR_QUICKNET;
5928 strcpy(j->caplist[j->caps].desc, "Quicknet Technologies, Inc. (www.quicknet.net)");
5929 j->caplist[j->caps].captype = vendor;
5930 j->caplist[j->caps].handle = j->caps;
5932 j->caplist[j->caps].captype = device;
5933 switch (j->cardtype) {
5935 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK");
5938 strcpy(j->caplist[j->caps].desc, "Quicknet Internet LineJACK");
5940 case QTI_PHONEJACK_LITE:
5941 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK Lite");
5943 case QTI_PHONEJACK_PCI:
5944 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK PCI");
5947 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneCARD");
5950 j->caplist[j->caps].cap = j->cardtype;
5951 j->caplist[j->caps].handle = j->caps;
5953 strcpy(j->caplist[j->caps].desc, "POTS");
5954 j->caplist[j->caps].captype = port;
5955 j->caplist[j->caps].cap = pots;
5956 j->caplist[j->caps].handle = j->caps;
5959 /* add devices that can do speaker/mic */
5960 switch (j->cardtype) {
5963 case QTI_PHONEJACK_PCI:
5965 strcpy(j->caplist[j->caps].desc, "SPEAKER");
5966 j->caplist[j->caps].captype = port;
5967 j->caplist[j->caps].cap = speaker;
5968 j->caplist[j->caps].handle = j->caps;
5974 /* add devices that can do handset */
5975 switch (j->cardtype) {
5977 strcpy(j->caplist[j->caps].desc, "HANDSET");
5978 j->caplist[j->caps].captype = port;
5979 j->caplist[j->caps].cap = handset;
5980 j->caplist[j->caps].handle = j->caps;
5987 /* add devices that can do PSTN */
5988 switch (j->cardtype) {
5990 strcpy(j->caplist[j->caps].desc, "PSTN");
5991 j->caplist[j->caps].captype = port;
5992 j->caplist[j->caps].cap = pstn;
5993 j->caplist[j->caps].handle = j->caps;
6000 /* add codecs - all cards can do uLaw, linear 8/16, and Windows sound system */
6001 strcpy(j->caplist[j->caps].desc, "ULAW");
6002 j->caplist[j->caps].captype = codec;
6003 j->caplist[j->caps].cap = ULAW;
6004 j->caplist[j->caps].handle = j->caps;
6007 strcpy(j->caplist[j->caps].desc, "LINEAR 16 bit");
6008 j->caplist[j->caps].captype = codec;
6009 j->caplist[j->caps].cap = LINEAR16;
6010 j->caplist[j->caps].handle = j->caps;
6013 strcpy(j->caplist[j->caps].desc, "LINEAR 8 bit");
6014 j->caplist[j->caps].captype = codec;
6015 j->caplist[j->caps].cap = LINEAR8;
6016 j->caplist[j->caps].handle = j->caps;
6019 strcpy(j->caplist[j->caps].desc, "Windows Sound System");
6020 j->caplist[j->caps].captype = codec;
6021 j->caplist[j->caps].cap = WSS;
6022 j->caplist[j->caps].handle = j->caps;
6025 /* software ALAW codec, made from ULAW */
6026 strcpy(j->caplist[j->caps].desc, "ALAW");
6027 j->caplist[j->caps].captype = codec;
6028 j->caplist[j->caps].cap = ALAW;
6029 j->caplist[j->caps].handle = j->caps;
6032 /* version 12 of the 8020 does the following codecs in a broken way */
6033 if (j->dsp.low != 0x20 || j->ver.low != 0x12) {
6034 strcpy(j->caplist[j->caps].desc, "G.723.1 6.3kbps");
6035 j->caplist[j->caps].captype = codec;
6036 j->caplist[j->caps].cap = G723_63;
6037 j->caplist[j->caps].handle = j->caps;
6040 strcpy(j->caplist[j->caps].desc, "G.723.1 5.3kbps");
6041 j->caplist[j->caps].captype = codec;
6042 j->caplist[j->caps].cap = G723_53;
6043 j->caplist[j->caps].handle = j->caps;
6046 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.8kbps");
6047 j->caplist[j->caps].captype = codec;
6048 j->caplist[j->caps].cap = TS48;
6049 j->caplist[j->caps].handle = j->caps;
6052 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.1kbps");
6053 j->caplist[j->caps].captype = codec;
6054 j->caplist[j->caps].cap = TS41;
6055 j->caplist[j->caps].handle = j->caps;
6059 /* 8020 chips can do TS8.5 native, and 8021/8022 can load it */
6060 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
6061 strcpy(j->caplist[j->caps].desc, "TrueSpeech 8.5kbps");
6062 j->caplist[j->caps].captype = codec;
6063 j->caplist[j->caps].cap = TS85;
6064 j->caplist[j->caps].handle = j->caps;
6068 /* 8021 chips can do G728 */
6069 if (j->dsp.low == 0x21) {
6070 strcpy(j->caplist[j->caps].desc, "G.728 16kbps");
6071 j->caplist[j->caps].captype = codec;
6072 j->caplist[j->caps].cap = G728;
6073 j->caplist[j->caps].handle = j->caps;
6077 /* 8021/8022 chips can do G729 if loaded */
6078 if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
6079 strcpy(j->caplist[j->caps].desc, "G.729A 8kbps");
6080 j->caplist[j->caps].captype = codec;
6081 j->caplist[j->caps].cap = G729;
6082 j->caplist[j->caps].handle = j->caps;
6085 if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
6086 strcpy(j->caplist[j->caps].desc, "G.729B 8kbps");
6087 j->caplist[j->caps].captype = codec;
6088 j->caplist[j->caps].cap = G729B;
6089 j->caplist[j->caps].handle = j->caps;
6094 static int capabilities_check(IXJ *j, struct phone_capability *pcreq)
6098 for (cnt = 0; cnt < j->caps; cnt++) {
6099 if (pcreq->captype == j->caplist[cnt].captype
6100 && pcreq->cap == j->caplist[cnt].cap) {
6108 static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg)
6113 void __user *argp = (void __user *)arg;
6114 struct inode *inode = file_p->f_path.dentry->d_inode;
6115 unsigned int minor = iminor(inode);
6116 unsigned int raise, mant;
6117 int board = NUM(inode);
6119 IXJ *j = get_ixj(NUM(inode));
6124 * Set up locks to ensure that only one process is talking to the DSP at a time.
6125 * This is necessary to keep the DSP from locking up.
6127 while(test_and_set_bit(board, (void *)&j->busyflags) != 0)
6128 schedule_timeout_interruptible(1);
6129 if (ixjdebug & 0x0040)
6130 printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
6131 if (minor >= IXJMAX) {
6132 clear_bit(board, &j->busyflags);
6136 * Check ioctls only root can use.
6138 if (!capable(CAP_SYS_ADMIN)) {
6140 case IXJCTL_TESTRAM:
6146 case IXJCTL_TESTRAM:
6148 retval = (j->ssr.high << 8) + j->ssr.low;
6150 case IXJCTL_CARDTYPE:
6151 retval = j->cardtype;
6156 case IXJCTL_VERSION:
6159 snprintf(arg_str, sizeof(arg_str),
6160 "\nDriver version %i.%i.%i", IXJ_VER_MAJOR,
6161 IXJ_VER_MINOR, IXJ_BLD_VER);
6162 if (copy_to_user(argp, arg_str, strlen(arg_str)))
6166 case PHONE_RING_CADENCE:
6167 j->ring_cadence = arg;
6171 if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) {
6176 memset(&j->cid_send, 0, sizeof(PHONE_CID));
6180 /* Binary compatbility */
6181 case OLD_PHONE_RING_START:
6184 case PHONE_RING_START:
6186 if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) {
6192 memset(&j->cid_send, 0, sizeof(PHONE_CID));
6196 case PHONE_RING_STOP:
6197 j->flags.cringing = 0;
6198 if(j->cadence_f[5].enable) {
6199 j->cadence_f[5].state = 0;
6204 retval = ixj_ring(j);
6206 case PHONE_EXCEPTION:
6207 retval = j->ex.bytes;
6208 if(j->ex.bits.flash) {
6210 j->ex.bits.flash = 0;
6212 j->ex.bits.pstn_ring = 0;
6213 j->ex.bits.caller_id = 0;
6214 j->ex.bits.pstn_wink = 0;
6223 j->ex.bits.reserved = 0;
6225 case PHONE_HOOKSTATE:
6226 j->ex.bits.hookstate = 0;
6227 retval = j->hookstate; //j->r_hook;
6229 case IXJCTL_SET_LED:
6230 LED_SetState(arg, j);
6233 retval = set_base_frame(j, arg);
6235 case PHONE_REC_CODEC:
6236 retval = set_rec_codec(j, arg);
6241 case PHONE_REC_START:
6242 ixj_record_start(j);
6244 case PHONE_REC_STOP:
6247 case PHONE_REC_DEPTH:
6248 set_rec_depth(j, arg);
6250 case PHONE_REC_VOLUME:
6252 retval = get_rec_volume(j);
6255 set_rec_volume(j, arg);
6259 case PHONE_REC_VOLUME_LINEAR:
6261 retval = get_rec_volume_linear(j);
6264 set_rec_volume_linear(j, arg);
6268 case IXJCTL_DTMF_PRESCALE:
6270 retval = get_dtmf_prescale(j);
6273 set_dtmf_prescale(j, arg);
6277 case PHONE_REC_LEVEL:
6278 retval = get_rec_level(j);
6281 retval = ixj_siadc(j, arg);
6284 retval = ixj_sidac(j, arg);
6286 case IXJCTL_AEC_START:
6287 ixj_aec_start(j, arg);
6289 case IXJCTL_AEC_STOP:
6292 case IXJCTL_AEC_GET_LEVEL:
6293 retval = j->aec_level;
6295 case PHONE_PLAY_CODEC:
6296 retval = set_play_codec(j, arg);
6298 case PHONE_PLAY_START:
6299 retval = ixj_play_start(j);
6301 case PHONE_PLAY_STOP:
6304 case PHONE_PLAY_DEPTH:
6305 set_play_depth(j, arg);
6307 case PHONE_PLAY_VOLUME:
6309 retval = get_play_volume(j);
6312 set_play_volume(j, arg);
6316 case PHONE_PLAY_VOLUME_LINEAR:
6318 retval = get_play_volume_linear(j);
6321 set_play_volume_linear(j, arg);
6325 case PHONE_PLAY_LEVEL:
6326 retval = get_play_level(j);
6328 case IXJCTL_DSP_TYPE:
6329 retval = (j->dsp.high << 8) + j->dsp.low;
6331 case IXJCTL_DSP_VERSION:
6332 retval = (j->ver.high << 8) + j->ver.low;
6343 case IXJCTL_DRYBUFFER_READ:
6344 put_user(j->drybuffer, (unsigned long __user *) argp);
6346 case IXJCTL_DRYBUFFER_CLEAR:
6349 case IXJCTL_FRAMES_READ:
6350 put_user(j->framesread, (unsigned long __user *) argp);
6352 case IXJCTL_FRAMES_WRITTEN:
6353 put_user(j->frameswritten, (unsigned long __user *) argp);
6355 case IXJCTL_READ_WAIT:
6356 put_user(j->read_wait, (unsigned long __user *) argp);
6358 case IXJCTL_WRITE_WAIT:
6359 put_user(j->write_wait, (unsigned long __user *) argp);
6361 case PHONE_MAXRINGS:
6364 case PHONE_SET_TONE_ON_TIME:
6365 ixj_set_tone_on(arg, j);
6367 case PHONE_SET_TONE_OFF_TIME:
6368 ixj_set_tone_off(arg, j);
6370 case PHONE_GET_TONE_ON_TIME:
6371 if (ixj_get_tone_on(j)) {
6374 retval = (j->ssr.high << 8) + j->ssr.low;
6377 case PHONE_GET_TONE_OFF_TIME:
6378 if (ixj_get_tone_off(j)) {
6381 retval = (j->ssr.high << 8) + j->ssr.low;
6384 case PHONE_PLAY_TONE:
6386 retval = ixj_play_tone(j, arg);
6390 case PHONE_GET_TONE_STATE:
6391 retval = j->tone_state;
6393 case PHONE_DTMF_READY:
6394 retval = j->ex.bits.dtmf_ready;
6396 case PHONE_GET_DTMF:
6397 if (ixj_hookstate(j)) {
6398 if (j->dtmf_rp != j->dtmf_wp) {
6399 retval = j->dtmfbuffer[j->dtmf_rp];
6401 if (j->dtmf_rp == 79)
6403 if (j->dtmf_rp == j->dtmf_wp) {
6404 j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
6409 case PHONE_GET_DTMF_ASCII:
6410 if (ixj_hookstate(j)) {
6411 if (j->dtmf_rp != j->dtmf_wp) {
6412 switch (j->dtmfbuffer[j->dtmf_rp]) {
6414 retval = 42; /* '*'; */
6418 retval = 48; /*'0'; */
6422 retval = 35; /*'#'; */
6426 retval = 65; /*'A'; */
6430 retval = 66; /*'B'; */
6434 retval = 67; /*'C'; */
6438 retval = 68; /*'D'; */
6442 retval = 48 + j->dtmfbuffer[j->dtmf_rp];
6446 if (j->dtmf_rp == 79)
6448 if(j->dtmf_rp == j->dtmf_wp)
6450 j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
6455 case PHONE_DTMF_OOB:
6456 j->flags.dtmf_oob = arg;
6458 case PHONE_DIALTONE:
6464 case PHONE_RINGBACK:
6468 if(j->cardtype == QTI_PHONEJACK)
6471 retval = ixj_wink(j);
6473 case PHONE_CPT_STOP:
6476 case PHONE_QUERY_CODEC:
6478 struct phone_codec_data pd;
6480 int proto_size[] = {
6482 12, 10, 16, 9, 8, 48, 5,
6483 40, 40, 80, 40, 40, 6
6485 if(copy_from_user(&pd, argp, sizeof(pd))) {
6489 if(pd.type<1 || pd.type>13) {
6490 retval = -EPROTONOSUPPORT;
6494 val=proto_size[pd.type];
6495 else switch(j->baseframe.low)
6497 case 0xA0:val=2*proto_size[pd.type];break;
6498 case 0x50:val=proto_size[pd.type];break;
6499 default:val=proto_size[pd.type]*3;break;
6501 pd.buf_min=pd.buf_max=pd.buf_opt=val;
6502 if(copy_to_user(argp, &pd, sizeof(pd)))
6506 case IXJCTL_DSP_IDLE:
6510 if ((arg & 0xff) == 0xff)
6511 retval = ixj_get_mixer(arg, j);
6515 case IXJCTL_DAA_COEFF_SET:
6519 retval = ixj_daa_write(j);
6523 retval = ixj_daa_write(j);
6526 DAA_Coeff_France(j);
6527 retval = ixj_daa_write(j);
6530 DAA_Coeff_Germany(j);
6531 retval = ixj_daa_write(j);
6534 DAA_Coeff_Australia(j);
6535 retval = ixj_daa_write(j);
6539 retval = ixj_daa_write(j);
6546 case IXJCTL_DAA_AGAIN:
6547 ixj_daa_cr4(j, arg | 0x02);
6549 case IXJCTL_PSTN_LINETEST:
6550 retval = ixj_linetest(j);
6553 ixj_write_vmwi(j, arg);
6556 if (copy_to_user(argp, &j->cid, sizeof(PHONE_CID)))
6558 j->ex.bits.caller_id = 0;
6560 case IXJCTL_WINK_DURATION:
6565 retval = ixj_set_port(j, arg);
6569 case IXJCTL_POTS_PSTN:
6570 retval = ixj_set_pots(j, arg);
6572 case PHONE_CAPABILITIES:
6576 case PHONE_CAPABILITIES_LIST:
6578 if (copy_to_user(argp, j->caplist, sizeof(struct phone_capability) * j->caps))
6581 case PHONE_CAPABILITIES_CHECK:
6583 struct phone_capability cap;
6584 if (copy_from_user(&cap, argp, sizeof(cap)))
6588 retval = capabilities_check(j, &cap);
6592 case PHONE_PSTN_SET_STATE:
6593 daa_set_mode(j, arg);
6595 case PHONE_PSTN_GET_STATE:
6596 retval = j->daa_mode;
6597 j->ex.bits.pstn_ring = 0;
6599 case IXJCTL_SET_FILTER:
6600 if (copy_from_user(&jf, argp, sizeof(jf)))
6603 retval = ixj_init_filter(j, &jf);
6605 case IXJCTL_SET_FILTER_RAW:
6606 if (copy_from_user(&jfr, argp, sizeof(jfr)))
6609 retval = ixj_init_filter_raw(j, &jfr);
6611 case IXJCTL_GET_FILTER_HIST:
6615 retval = j->filter_hist[arg];
6617 case IXJCTL_INIT_TONE:
6618 if (copy_from_user(&ti, argp, sizeof(ti)))
6621 retval = ixj_init_tone(j, &ti);
6623 case IXJCTL_TONE_CADENCE:
6624 retval = ixj_build_cadence(j, argp);
6626 case IXJCTL_FILTER_CADENCE:
6627 retval = ixj_build_filter_cadence(j, argp);
6630 if (copy_from_user(&j->sigdef, argp, sizeof(IXJ_SIGDEF))) {
6634 j->ixj_signals[j->sigdef.event] = j->sigdef.signal;
6635 if(j->sigdef.event < 33) {
6637 for(mant = 0; mant < j->sigdef.event; mant++){
6640 if(j->sigdef.signal)
6641 j->ex_sig.bytes |= raise;
6643 j->ex_sig.bytes &= (raise^0xffff);
6646 case IXJCTL_INTERCOM_STOP:
6647 if(arg < 0 || arg >= IXJMAX)
6653 get_ixj(arg)->intercom = -1;
6654 ixj_record_stop(get_ixj(arg));
6655 ixj_play_stop(get_ixj(arg));
6658 case IXJCTL_INTERCOM_START:
6659 if(arg < 0 || arg >= IXJMAX)
6662 ixj_record_start(j);
6664 get_ixj(arg)->intercom = board;
6665 ixj_play_start(get_ixj(arg));
6666 ixj_record_start(get_ixj(arg));
6669 if (ixjdebug & 0x0040)
6670 printk("phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
6671 clear_bit(board, &j->busyflags);
6675 static long ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg)
6678 mutex_lock(&ixj_mutex);
6679 ret = do_ixj_ioctl(file_p, cmd, arg);
6680 mutex_unlock(&ixj_mutex);
6684 static int ixj_fasync(int fd, struct file *file_p, int mode)
6686 IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
6688 return fasync_helper(fd, file_p, mode, &j->async_queue);
6691 static const struct file_operations ixj_fops =
6693 .owner = THIS_MODULE,
6694 .read = ixj_enhanced_read,
6695 .write = ixj_enhanced_write,
6697 .unlocked_ioctl = ixj_ioctl,
6698 .release = ixj_release,
6699 .fasync = ixj_fasync,
6700 .llseek = default_llseek,
6703 static int ixj_linetest(IXJ *j)
6705 j->flags.pstncheck = 1; /* Testing */
6706 j->flags.pstn_present = 0; /* Assume the line is not there */
6708 daa_int_read(j); /*Clear DAA Interrupt flags */
6710 /* Hold all relays in the normally de-energized position. */
6713 j->pld_slicw.bits.rly1 = 0;
6714 j->pld_slicw.bits.rly2 = 0;
6715 j->pld_slicw.bits.rly3 = 0;
6716 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6717 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6719 outb_p(j->pld_scrw.byte, j->XILINXbase);
6720 j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
6721 if (j->pld_slicr.bits.potspstn) {
6722 j->flags.pots_pstn = 1;
6723 j->flags.pots_correct = 0;
6724 LED_SetState(0x4, j);
6726 j->flags.pots_pstn = 0;
6727 j->pld_slicw.bits.rly1 = 0;
6728 j->pld_slicw.bits.rly2 = 0;
6729 j->pld_slicw.bits.rly3 = 1;
6730 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6731 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6733 outb_p(j->pld_scrw.byte, j->XILINXbase);
6734 daa_set_mode(j, SOP_PU_CONVERSATION);
6737 daa_set_mode(j, SOP_PU_RESET);
6738 if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
6739 j->flags.pots_correct = 0; /* Should not be line voltage on POTS port. */
6740 LED_SetState(0x4, j);
6741 j->pld_slicw.bits.rly3 = 0;
6742 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6744 j->flags.pots_correct = 1;
6745 LED_SetState(0x8, j);
6746 j->pld_slicw.bits.rly1 = 1;
6747 j->pld_slicw.bits.rly2 = 0;
6748 j->pld_slicw.bits.rly3 = 0;
6749 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6752 j->pld_slicw.bits.rly3 = 0;
6753 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6754 daa_set_mode(j, SOP_PU_CONVERSATION);
6757 daa_set_mode(j, SOP_PU_RESET);
6758 if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
6759 j->pstn_sleeptil = jiffies + (hertz / 4);
6760 j->flags.pstn_present = 1;
6762 j->flags.pstn_present = 0;
6764 if (j->flags.pstn_present) {
6765 if (j->flags.pots_correct) {
6766 LED_SetState(0xA, j);
6768 LED_SetState(0x6, j);
6771 if (j->flags.pots_correct) {
6772 LED_SetState(0x9, j);
6774 LED_SetState(0x5, j);
6777 j->flags.pstncheck = 0; /* Testing */
6778 return j->flags.pstn_present;
6781 static int ixj_selfprobe(IXJ *j)
6787 init_waitqueue_head(&j->poll_q);
6788 init_waitqueue_head(&j->read_q);
6789 init_waitqueue_head(&j->write_q);
6791 while(atomic_read(&j->DSPWrite) > 0)
6792 atomic_dec(&j->DSPWrite);
6793 if (ixjdebug & 0x0002)
6794 printk(KERN_INFO "Write IDLE to Software Control Register\n");
6795 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
6797 if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
6799 /* The read values of the SSR should be 0x00 for the IDLE command */
6800 if (j->ssr.low || j->ssr.high)
6802 if (ixjdebug & 0x0002)
6803 printk(KERN_INFO "Get Device ID Code\n");
6804 if (ixj_WriteDSPCommand(0x3400, j)) /* Get Device ID Code */
6806 j->dsp.low = j->ssr.low;
6807 j->dsp.high = j->ssr.high;
6808 if (ixjdebug & 0x0002)
6809 printk(KERN_INFO "Get Device Version Code\n");
6810 if (ixj_WriteDSPCommand(0x3800, j)) /* Get Device Version Code */
6812 j->ver.low = j->ssr.low;
6813 j->ver.high = j->ssr.high;
6815 if (j->dsp.low == 0x21) {
6816 bytes.high = bytes.low = inb_p(j->XILINXbase + 0x02);
6817 outb_p(bytes.low ^ 0xFF, j->XILINXbase + 0x02);
6818 /* Test for Internet LineJACK or Internet PhoneJACK Lite */
6819 bytes.low = inb_p(j->XILINXbase + 0x02);
6820 if (bytes.low == bytes.high) /* Register is read only on */
6821 /* Internet PhoneJack Lite */
6823 j->cardtype = QTI_PHONEJACK_LITE;
6824 if (!request_region(j->XILINXbase, 4, "ixj control")) {
6825 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6828 j->pld_slicw.pcib.e1 = 1;
6829 outb_p(j->pld_slicw.byte, j->XILINXbase);
6831 j->cardtype = QTI_LINEJACK;
6833 if (!request_region(j->XILINXbase, 8, "ixj control")) {
6834 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6838 } else if (j->dsp.low == 0x22) {
6839 j->cardtype = QTI_PHONEJACK_PCI;
6840 request_region(j->XILINXbase, 4, "ixj control");
6841 j->pld_slicw.pcib.e1 = 1;
6842 outb_p(j->pld_slicw.byte, j->XILINXbase);
6844 j->cardtype = QTI_PHONEJACK;
6846 switch (j->cardtype) {
6848 if (!j->dsp.low != 0x20) {
6851 ixj_WriteDSPCommand(0x3800, j);
6852 j->ver.low = j->ssr.low;
6853 j->ver.high = j->ssr.high;
6857 if (!request_region(j->XILINXbase, 8, "ixj control")) {
6858 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6862 case QTI_PHONEJACK_LITE:
6863 case QTI_PHONEJACK_PCI:
6864 if (!request_region(j->XILINXbase, 4, "ixj control")) {
6865 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6868 j->pld_slicw.pcib.e1 = 1;
6869 outb_p(j->pld_slicw.byte, j->XILINXbase);
6875 if (j->dsp.low == 0x20 || j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
6876 if (ixjdebug & 0x0002)
6877 printk(KERN_INFO "Write CODEC config to Software Control Register\n");
6878 if (ixj_WriteDSPCommand(0xC462, j)) /* Write CODEC config to Software Control Register */
6880 if (ixjdebug & 0x0002)
6881 printk(KERN_INFO "Write CODEC timing to Software Control Register\n");
6882 if (j->cardtype == QTI_PHONEJACK) {
6887 if (ixj_WriteDSPCommand(cmd, j)) /* Write CODEC timing to Software Control Register */
6890 if (set_base_frame(j, 30) != 30)
6892 if (ixjdebug & 0x0002)
6893 printk(KERN_INFO "Write CODEC config to Software Control Register\n");
6894 if (j->cardtype == QTI_PHONECARD) {
6895 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
6898 if (j->cardtype == QTI_LINEJACK) {
6899 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
6901 if (ixjdebug & 0x0002)
6902 printk(KERN_INFO "Turn on the PLD Clock at 8Khz\n");
6903 j->pld_clock.byte = 0;
6904 outb_p(j->pld_clock.byte, j->XILINXbase + 0x04);
6908 if (j->dsp.low == 0x20) {
6909 if (ixjdebug & 0x0002)
6910 printk(KERN_INFO "Configure GPIO pins\n");
6911 j->gpio.bytes.high = 0x09;
6912 /* bytes.low = 0xEF; 0xF7 */
6913 j->gpio.bits.gpio1 = 1;
6914 j->gpio.bits.gpio2 = 1;
6915 j->gpio.bits.gpio3 = 0;
6916 j->gpio.bits.gpio4 = 1;
6917 j->gpio.bits.gpio5 = 1;
6918 j->gpio.bits.gpio6 = 1;
6919 j->gpio.bits.gpio7 = 1;
6920 ixj_WriteDSPCommand(j->gpio.word, j); /* Set GPIO pin directions */
6921 if (ixjdebug & 0x0002)
6922 printk(KERN_INFO "Enable SLIC\n");
6923 j->gpio.bytes.high = 0x0B;
6924 j->gpio.bytes.low = 0x00;
6925 j->gpio.bits.gpio1 = 0;
6926 j->gpio.bits.gpio2 = 1;
6927 j->gpio.bits.gpio5 = 0;
6928 ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring stop signal */
6929 j->port = PORT_POTS;
6931 if (j->cardtype == QTI_LINEJACK) {
6932 LED_SetState(0x1, j);
6934 LED_SetState(0x2, j);
6936 LED_SetState(0x4, j);
6938 LED_SetState(0x8, j);
6940 LED_SetState(0x0, j);
6942 if (ixjdebug & 0x0002)
6943 printk("Loading DAA Coefficients\n");
6945 if (!ixj_daa_write(j)) {
6946 printk("DAA write failed on board %d\n", j->board);
6949 if(!ixj_daa_cid_reset(j)) {
6950 printk("DAA CID reset failed on board %d\n", j->board);
6953 j->flags.pots_correct = 0;
6954 j->flags.pstn_present = 0;
6956 if (j->flags.pots_correct) {
6957 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6959 outb_p(j->pld_scrw.byte, j->XILINXbase);
6960 j->pld_slicw.bits.rly1 = 1;
6961 j->pld_slicw.bits.spken = 1;
6962 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6963 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
6964 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
6965 j->port = PORT_POTS;
6967 ixj_set_port(j, PORT_PSTN);
6969 if (ixjdebug & 0x0002)
6970 printk(KERN_INFO "Enable Mixer\n");
6971 ixj_mixer(0x0000, j); /*Master Volume Left unmute 0db */
6972 ixj_mixer(0x0100, j); /*Master Volume Right unmute 0db */
6974 ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
6975 ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
6977 ixj_mixer(0x0480, j); /*FM Left mute */
6978 ixj_mixer(0x0580, j); /*FM Right mute */
6980 ixj_mixer(0x0680, j); /*CD Left mute */
6981 ixj_mixer(0x0780, j); /*CD Right mute */
6983 ixj_mixer(0x0880, j); /*Line Left mute */
6984 ixj_mixer(0x0980, j); /*Line Right mute */
6986 ixj_mixer(0x0A80, j); /*Aux left mute */
6987 ixj_mixer(0x0B80, j); /*Aux right mute */
6989 ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
6990 ixj_mixer(0x0D80, j); /*Mono2 mute */
6992 ixj_mixer(0x0E80, j); /*Mic mute */
6994 ixj_mixer(0x0F00, j); /*Mono Out Volume unmute 0db */
6996 ixj_mixer(0x1000, j); /*Voice Left and Right out only */
6997 ixj_mixer(0x110C, j);
7000 ixj_mixer(0x1200, j); /*Mono1 switch on mixer left */
7001 ixj_mixer(0x1401, j);
7003 ixj_mixer(0x1300, j); /*Mono1 switch on mixer right */
7004 ixj_mixer(0x1501, j);
7006 ixj_mixer(0x1700, j); /*Clock select */
7008 ixj_mixer(0x1800, j); /*ADC input from mixer */
7010 ixj_mixer(0x1901, j); /*Mic gain 30db */
7012 if (ixjdebug & 0x0002)
7013 printk(KERN_INFO "Setting Default US Ring Cadence Detection\n");
7014 j->cadence_f[4].state = 0;
7015 j->cadence_f[4].on1 = 0; /*Cadence Filter 4 is used for PSTN ring cadence */
7016 j->cadence_f[4].off1 = 0;
7017 j->cadence_f[4].on2 = 0;
7018 j->cadence_f[4].off2 = 0;
7019 j->cadence_f[4].on3 = 0;
7020 j->cadence_f[4].off3 = 0; /* These should represent standard US ring pulse. */
7021 j->pstn_last_rmr = jiffies;
7024 if (j->cardtype == QTI_PHONECARD) {
7025 ixj_WriteDSPCommand(0xCF07, j);
7026 ixj_WriteDSPCommand(0x00B0, j);
7027 ixj_set_port(j, PORT_SPEAKER);
7029 ixj_set_port(j, PORT_POTS);
7030 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
7031 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
7037 j->framesread = j->frameswritten = 0;
7038 j->read_wait = j->write_wait = 0;
7039 j->rxreadycheck = j->txreadycheck = 0;
7041 /* initialise the DTMF prescale to a sensible value */
7042 if (j->cardtype == QTI_LINEJACK) {
7043 set_dtmf_prescale(j, 0x10);
7045 set_dtmf_prescale(j, 0x40);
7047 set_play_volume(j, 0x100);
7048 set_rec_volume(j, 0x100);
7050 if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
7052 /* The read values of the SSR should be 0x00 for the IDLE command */
7053 if (j->ssr.low || j->ssr.high)
7056 if (ixjdebug & 0x0002)
7057 printk(KERN_INFO "Enable Line Monitor\n");
7059 if (ixjdebug & 0x0002)
7060 printk(KERN_INFO "Set Line Monitor to Asyncronous Mode\n");
7062 if (ixj_WriteDSPCommand(0x7E01, j)) /* Asynchronous Line Monitor */
7065 if (ixjdebug & 0x002)
7066 printk(KERN_INFO "Enable DTMF Detectors\n");
7068 if (ixj_WriteDSPCommand(0x5151, j)) /* Enable DTMF detection */
7071 if (ixj_WriteDSPCommand(0x6E01, j)) /* Set Asyncronous Tone Generation */
7074 set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
7076 set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
7078 j->ex.bits.dtmf_ready = 0;
7080 j->dtmf_wp = j->dtmf_rp = 0;
7081 j->rec_mode = j->play_mode = -1;
7082 j->flags.ringing = 0;
7083 j->maxrings = MAXRINGS;
7084 j->ring_cadence = USA_RING_CADENCE;
7087 j->flags.dtmf_oob = 0;
7088 for (cnt = 0; cnt < 4; cnt++)
7089 j->cadence_f[cnt].enable = 0;
7090 /* must be a device on the specified address */
7091 ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
7093 /* Set up the default signals for events */
7094 for (cnt = 0; cnt < 35; cnt++)
7095 j->ixj_signals[cnt] = SIGIO;
7097 /* Set the exception signal enable flags */
7098 j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
7099 j->ex_sig.bits.caller_id = j->ex_sig.bits.pstn_wink = j->ex_sig.bits.f0 = j->ex_sig.bits.f1 = j->ex_sig.bits.f2 =
7100 j->ex_sig.bits.f3 = j->ex_sig.bits.fc0 = j->ex_sig.bits.fc1 = j->ex_sig.bits.fc2 = j->ex_sig.bits.fc3 = 1;
7101 #ifdef IXJ_DYN_ALLOC
7107 /* Register with the Telephony for Linux subsystem */
7108 j->p.f_op = &ixj_fops;
7109 j->p.open = ixj_open;
7110 j->p.board = j->board;
7111 phone_register_device(&j->p, PHONE_UNIT_ANY);
7119 * Exported service for pcmcia card handling
7122 IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx)
7124 IXJ *j = ixj_alloc();
7129 j->XILINXbase = xilinx;
7130 j->cardtype = QTI_PHONECARD;
7135 EXPORT_SYMBOL(ixj_pcmcia_probe); /* For PCMCIA */
7137 static int ixj_get_status_proc(char *buf)
7143 len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER);
7144 len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ));
7145 len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS));
7146 len += sprintf(buf + len, "\nUsing old telephony API");
7147 len += sprintf(buf + len, "\nDebug Level %d\n", ixjdebug);
7149 for (cnt = 0; cnt < IXJMAX; cnt++) {
7154 len += sprintf(buf + len, "\nCard Num %d", cnt);
7155 len += sprintf(buf + len, "\nDSP Base Address 0x%4.4x", j->DSPbase);
7156 if (j->cardtype != QTI_PHONEJACK)
7157 len += sprintf(buf + len, "\nXILINX Base Address 0x%4.4x", j->XILINXbase);
7158 len += sprintf(buf + len, "\nDSP Type %2.2x%2.2x", j->dsp.high, j->dsp.low);
7159 len += sprintf(buf + len, "\nDSP Version %2.2x.%2.2x", j->ver.high, j->ver.low);
7160 len += sprintf(buf + len, "\nSerial Number %8.8x", j->serial);
7161 switch (j->cardtype) {
7162 case (QTI_PHONEJACK):
7163 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK");
7165 case (QTI_LINEJACK):
7166 len += sprintf(buf + len, "\nCard Type = Internet LineJACK");
7167 if (j->flags.g729_loaded)
7168 len += sprintf(buf + len, " w/G.729 A/B");
7169 len += sprintf(buf + len, " Country = %d", j->daa_country);
7171 case (QTI_PHONEJACK_LITE):
7172 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK Lite");
7173 if (j->flags.g729_loaded)
7174 len += sprintf(buf + len, " w/G.729 A/B");
7176 case (QTI_PHONEJACK_PCI):
7177 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK PCI");
7178 if (j->flags.g729_loaded)
7179 len += sprintf(buf + len, " w/G.729 A/B");
7181 case (QTI_PHONECARD):
7182 len += sprintf(buf + len, "\nCard Type = Internet PhoneCARD");
7183 if (j->flags.g729_loaded)
7184 len += sprintf(buf + len, " w/G.729 A/B");
7185 len += sprintf(buf + len, "\nSmart Cable %spresent", j->pccr1.bits.drf ? "not " : "");
7186 if (!j->pccr1.bits.drf)
7187 len += sprintf(buf + len, "\nSmart Cable type %d", j->flags.pcmciasct);
7188 len += sprintf(buf + len, "\nSmart Cable state %d", j->flags.pcmciastate);
7191 len += sprintf(buf + len, "\nCard Type = %d", j->cardtype);
7194 len += sprintf(buf + len, "\nReaders %d", j->readers);
7195 len += sprintf(buf + len, "\nWriters %d", j->writers);
7197 len += sprintf(buf + len, "\nCapabilities %d", j->caps);
7198 if (j->dsp.low != 0x20)
7199 len += sprintf(buf + len, "\nDSP Processor load %d", j->proc_load);
7200 if (j->flags.cidsent)
7201 len += sprintf(buf + len, "\nCaller ID data sent");
7203 len += sprintf(buf + len, "\nCaller ID data not sent");
7205 len += sprintf(buf + len, "\nPlay CODEC ");
7206 switch (j->play_codec) {
7208 len += sprintf(buf + len, "G.723.1 6.3");
7211 len += sprintf(buf + len, "G.723.1 5.3");
7214 len += sprintf(buf + len, "TrueSpeech 8.5");
7217 len += sprintf(buf + len, "TrueSpeech 4.8");
7220 len += sprintf(buf + len, "TrueSpeech 4.1");
7223 len += sprintf(buf + len, "G.728");
7226 len += sprintf(buf + len, "G.729");
7229 len += sprintf(buf + len, "G.729B");
7232 len += sprintf(buf + len, "uLaw");
7235 len += sprintf(buf + len, "aLaw");
7238 len += sprintf(buf + len, "16 bit Linear");
7241 len += sprintf(buf + len, "8 bit Linear");
7244 len += sprintf(buf + len, "Windows Sound System");
7247 len += sprintf(buf + len, "NO CODEC CHOSEN");
7250 len += sprintf(buf + len, "\nRecord CODEC ");
7251 switch (j->rec_codec) {
7253 len += sprintf(buf + len, "G.723.1 6.3");
7256 len += sprintf(buf + len, "G.723.1 5.3");
7259 len += sprintf(buf + len, "TrueSpeech 8.5");
7262 len += sprintf(buf + len, "TrueSpeech 4.8");
7265 len += sprintf(buf + len, "TrueSpeech 4.1");
7268 len += sprintf(buf + len, "G.728");
7271 len += sprintf(buf + len, "G.729");
7274 len += sprintf(buf + len, "G.729B");
7277 len += sprintf(buf + len, "uLaw");
7280 len += sprintf(buf + len, "aLaw");
7283 len += sprintf(buf + len, "16 bit Linear");
7286 len += sprintf(buf + len, "8 bit Linear");
7289 len += sprintf(buf + len, "Windows Sound System");
7292 len += sprintf(buf + len, "NO CODEC CHOSEN");
7295 len += sprintf(buf + len, "\nAEC ");
7296 switch (j->aec_level) {
7298 len += sprintf(buf + len, "Off");
7301 len += sprintf(buf + len, "Low");
7304 len += sprintf(buf + len, "Med");
7307 len += sprintf(buf + len, "High");
7310 len += sprintf(buf + len, "Auto");
7313 len += sprintf(buf + len, "AEC/AGC");
7316 len += sprintf(buf + len, "unknown(%i)", j->aec_level);
7320 len += sprintf(buf + len, "\nRec volume 0x%x", get_rec_volume(j));
7321 len += sprintf(buf + len, "\nPlay volume 0x%x", get_play_volume(j));
7322 len += sprintf(buf + len, "\nDTMF prescale 0x%x", get_dtmf_prescale(j));
7324 len += sprintf(buf + len, "\nHook state %d", j->hookstate); /* j->r_hook); */
7326 if (j->cardtype == QTI_LINEJACK) {
7327 len += sprintf(buf + len, "\nPOTS Correct %d", j->flags.pots_correct);
7328 len += sprintf(buf + len, "\nPSTN Present %d", j->flags.pstn_present);
7329 len += sprintf(buf + len, "\nPSTN Check %d", j->flags.pstncheck);
7330 len += sprintf(buf + len, "\nPOTS to PSTN %d", j->flags.pots_pstn);
7331 switch (j->daa_mode) {
7333 len += sprintf(buf + len, "\nDAA PSTN On Hook");
7335 case SOP_PU_RINGING:
7336 len += sprintf(buf + len, "\nDAA PSTN Ringing");
7337 len += sprintf(buf + len, "\nRinging state = %d", j->cadence_f[4].state);
7339 case SOP_PU_CONVERSATION:
7340 len += sprintf(buf + len, "\nDAA PSTN Off Hook");
7342 case SOP_PU_PULSEDIALING:
7343 len += sprintf(buf + len, "\nDAA PSTN Pulse Dialing");
7346 len += sprintf(buf + len, "\nDAA RMR = %d", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR);
7347 len += sprintf(buf + len, "\nDAA VDD OK = %d", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK);
7348 len += sprintf(buf + len, "\nDAA CR0 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg);
7349 len += sprintf(buf + len, "\nDAA CR1 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg);
7350 len += sprintf(buf + len, "\nDAA CR2 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg);
7351 len += sprintf(buf + len, "\nDAA CR3 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg);
7352 len += sprintf(buf + len, "\nDAA CR4 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg);
7353 len += sprintf(buf + len, "\nDAA CR5 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg);
7354 len += sprintf(buf + len, "\nDAA XR0 = 0x%02x", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg);
7355 len += sprintf(buf + len, "\nDAA ringstop %ld - jiffies %ld", j->pstn_ring_stop, jiffies);
7359 len += sprintf(buf + len, "\nPort POTS");
7362 len += sprintf(buf + len, "\nPort PSTN");
7365 len += sprintf(buf + len, "\nPort SPEAKER/MIC");
7368 len += sprintf(buf + len, "\nPort HANDSET");
7371 if (j->dsp.low == 0x21 || j->dsp.low == 0x22) {
7372 len += sprintf(buf + len, "\nSLIC state ");
7373 switch (SLIC_GetState(j)) {
7374 case PLD_SLIC_STATE_OC:
7375 len += sprintf(buf + len, "OC");
7377 case PLD_SLIC_STATE_RINGING:
7378 len += sprintf(buf + len, "RINGING");
7380 case PLD_SLIC_STATE_ACTIVE:
7381 len += sprintf(buf + len, "ACTIVE");
7383 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
7384 len += sprintf(buf + len, "OHT");
7386 case PLD_SLIC_STATE_TIPOPEN:
7387 len += sprintf(buf + len, "TIPOPEN");
7389 case PLD_SLIC_STATE_STANDBY:
7390 len += sprintf(buf + len, "STANDBY");
7392 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
7393 len += sprintf(buf + len, "APR");
7395 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
7396 len += sprintf(buf + len, "OHTPR");
7399 len += sprintf(buf + len, "%d", SLIC_GetState(j));
7403 len += sprintf(buf + len, "\nBase Frame %2.2x.%2.2x", j->baseframe.high, j->baseframe.low);
7404 len += sprintf(buf + len, "\nCID Base Frame %2d", j->cid_base_frame_size);
7405 #ifdef PERFMON_STATS
7406 len += sprintf(buf + len, "\nTimer Checks %ld", j->timerchecks);
7407 len += sprintf(buf + len, "\nRX Ready Checks %ld", j->rxreadycheck);
7408 len += sprintf(buf + len, "\nTX Ready Checks %ld", j->txreadycheck);
7409 len += sprintf(buf + len, "\nFrames Read %ld", j->framesread);
7410 len += sprintf(buf + len, "\nFrames Written %ld", j->frameswritten);
7411 len += sprintf(buf + len, "\nDry Buffer %ld", j->drybuffer);
7412 len += sprintf(buf + len, "\nRead Waits %ld", j->read_wait);
7413 len += sprintf(buf + len, "\nWrite Waits %ld", j->write_wait);
7414 len += sprintf(buf + len, "\nStatus Waits %ld", j->statuswait);
7415 len += sprintf(buf + len, "\nStatus Wait Fails %ld", j->statuswaitfail);
7416 len += sprintf(buf + len, "\nPControl Waits %ld", j->pcontrolwait);
7417 len += sprintf(buf + len, "\nPControl Wait Fails %ld", j->pcontrolwaitfail);
7418 len += sprintf(buf + len, "\nIs Control Ready Checks %ld", j->iscontrolready);
7419 len += sprintf(buf + len, "\nIs Control Ready Check failures %ld", j->iscontrolreadyfail);
7422 len += sprintf(buf + len, "\n");
7428 static int ixj_read_proc(char *page, char **start, off_t off,
7429 int count, int *eof, void *data)
7431 int len = ixj_get_status_proc(page);
7432 if (len <= off+count) *eof = 1;
7433 *start = page + off;
7435 if (len>count) len = count;
7441 static void cleanup(void)
7446 for (cnt = 0; cnt < IXJMAX; cnt++) {
7448 if(j != NULL && j->DSPbase) {
7449 if (ixjdebug & 0x0002)
7450 printk(KERN_INFO "IXJ: Deleting timer for /dev/phone%d\n", cnt);
7451 del_timer(&j->timer);
7452 if (j->cardtype == QTI_LINEJACK) {
7453 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
7455 outb_p(j->pld_scrw.byte, j->XILINXbase);
7456 j->pld_slicw.bits.rly1 = 0;
7457 j->pld_slicw.bits.rly2 = 0;
7458 j->pld_slicw.bits.rly3 = 0;
7459 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
7460 LED_SetState(0x0, j);
7461 if (ixjdebug & 0x0002)
7462 printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
7463 release_region(j->XILINXbase, 8);
7464 } else if (j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
7465 if (ixjdebug & 0x0002)
7466 printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
7467 release_region(j->XILINXbase, 4);
7469 kfree(j->read_buffer);
7470 kfree(j->write_buffer);
7472 pnp_device_detach(j->dev);
7473 if (ixjdebug & 0x0002)
7474 printk(KERN_INFO "IXJ: Unregistering /dev/phone%d from LTAPI\n", cnt);
7475 phone_unregister_device(&j->p);
7476 if (ixjdebug & 0x0002)
7477 printk(KERN_INFO "IXJ: Releasing DSP address for /dev/phone%d\n", cnt);
7478 release_region(j->DSPbase, 16);
7479 #ifdef IXJ_DYN_ALLOC
7480 if (ixjdebug & 0x0002)
7481 printk(KERN_INFO "IXJ: Freeing memory for /dev/phone%d\n", cnt);
7487 if (ixjdebug & 0x0002)
7488 printk(KERN_INFO "IXJ: Removing /proc/ixj\n");
7489 remove_proc_entry ("ixj", NULL);
7498 static void PCIEE_WriteBit(WORD wEEPROMAddress, BYTE lastLCC, BYTE byData)
7500 lastLCC = lastLCC & 0xfb;
7501 lastLCC = lastLCC | (byData ? 4 : 0);
7502 outb(lastLCC, wEEPROMAddress); /*set data out bit as appropriate */
7505 lastLCC = lastLCC | 0x01;
7506 outb(lastLCC, wEEPROMAddress); /*SK rising edge */
7508 byData = byData << 1;
7509 lastLCC = lastLCC & 0xfe;
7511 outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
7515 static BYTE PCIEE_ReadBit(WORD wEEPROMAddress, BYTE lastLCC)
7518 lastLCC = lastLCC | 0x01;
7519 outb(lastLCC, wEEPROMAddress); /*SK rising edge */
7521 lastLCC = lastLCC & 0xfe;
7523 outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
7525 return ((inb(wEEPROMAddress) >> 3) & 1);
7528 static bool PCIEE_ReadWord(WORD wAddress, WORD wLoc, WORD * pwResult)
7531 WORD wEEPROMAddress = wAddress + 3;
7535 lastLCC = inb(wEEPROMAddress);
7536 lastLCC = lastLCC | 0x02;
7537 lastLCC = lastLCC & 0xfe;
7538 outb(lastLCC, wEEPROMAddress); /* CS hi, SK lo */
7540 mdelay(1); /* delay */
7542 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
7543 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
7544 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 0);
7545 for (i = 0; i < 8; i++) {
7546 PCIEE_WriteBit(wEEPROMAddress, lastLCC, wLoc & 0x80 ? 1 : 0);
7550 for (i = 0; i < 16; i++) {
7551 byResult = PCIEE_ReadBit(wEEPROMAddress, lastLCC);
7552 *pwResult = (*pwResult << 1) | byResult;
7555 mdelay(1); /* another delay */
7557 lastLCC = lastLCC & 0xfd;
7558 outb(lastLCC, wEEPROMAddress); /* negate CS */
7563 static DWORD PCIEE_GetSerialNumber(WORD wAddress)
7566 if (PCIEE_ReadWord(wAddress, 62, &wLo))
7568 if (PCIEE_ReadWord(wAddress, 63, &wHi))
7570 return (((DWORD) wHi << 16) | wLo);
7573 static int dspio[IXJMAX + 1] =
7577 static int xio[IXJMAX + 1] =
7582 module_param_array(dspio, int, NULL, 0);
7583 module_param_array(xio, int, NULL, 0);
7584 MODULE_DESCRIPTION("Quicknet VoIP Telephony card module - www.quicknet.net");
7585 MODULE_AUTHOR("Ed Okerson <eokerson@quicknet.net>");
7586 MODULE_LICENSE("GPL");
7588 static void __exit ixj_exit(void)
7593 static IXJ *new_ixj(unsigned long port)
7596 if (!request_region(port, 16, "ixj DSP")) {
7597 printk(KERN_INFO "ixj: can't get I/O address 0x%lx\n", port);
7602 release_region(port, 16);
7603 printk(KERN_INFO "ixj: out of memory\n");
7606 res->DSPbase = port;
7610 static int __init ixj_probe_isapnp(int *cnt)
7614 struct pnp_dev *dev = NULL, *old_dev = NULL;
7622 dev = pnp_find_dev(NULL, ISAPNP_VENDOR('Q', 'T', 'I'),
7623 ISAPNP_FUNCTION(func), old_dev);
7624 if (!dev || !dev->card)
7626 result = pnp_device_attach(dev);
7628 printk("pnp attach failed %d \n", result);
7631 if (pnp_activate_dev(dev) < 0) {
7632 printk("pnp activate failed (out of resources?)\n");
7633 pnp_device_detach(dev);
7637 if (!pnp_port_valid(dev, 0)) {
7638 pnp_device_detach(dev);
7642 j = new_ixj(pnp_port_start(dev, 0));
7647 j->XILINXbase = pnp_port_start(dev, 1); /* get real port */
7651 j->cardtype = QTI_PHONEJACK;
7654 j->cardtype = QTI_LINEJACK;
7657 j->cardtype = QTI_PHONEJACK_LITE;
7661 probe = ixj_selfprobe(j);
7663 j->serial = dev->card->serial;
7667 printk(KERN_INFO "ixj: found Internet PhoneJACK at 0x%x\n", j->DSPbase);
7670 printk(KERN_INFO "ixj: found Internet LineJACK at 0x%x\n", j->DSPbase);
7673 printk(KERN_INFO "ixj: found Internet PhoneJACK Lite at 0x%x\n", j->DSPbase);
7690 static int __init ixj_probe_isa(int *cnt)
7694 /* Use passed parameters for older kernels without PnP */
7695 for (i = 0; i < IXJMAX; i++) {
7697 IXJ *j = new_ixj(dspio[i]);
7702 j->XILINXbase = xio[i];
7706 probe = ixj_selfprobe(j);
7714 static int __init ixj_probe_pci(int *cnt)
7716 struct pci_dev *pci = NULL;
7720 for (i = 0; i < IXJMAX - *cnt; i++) {
7721 pci = pci_get_device(PCI_VENDOR_ID_QUICKNET,
7722 PCI_DEVICE_ID_QUICKNET_XJ, pci);
7726 if (pci_enable_device(pci))
7728 j = new_ixj(pci_resource_start(pci, 0));
7732 j->serial = (PCIEE_GetSerialNumber)pci_resource_start(pci, 2);
7733 j->XILINXbase = j->DSPbase + 0x10;
7734 j->cardtype = QTI_PHONEJACK_PCI;
7736 probe = ixj_selfprobe(j);
7738 printk(KERN_INFO "ixj: found Internet PhoneJACK PCI at 0x%x\n", j->DSPbase);
7745 static int __init ixj_init(void)
7752 /* These might be no-ops, see above. */
7753 if ((probe = ixj_probe_isapnp(&cnt)) < 0) {
7756 if ((probe = ixj_probe_isa(&cnt)) < 0) {
7759 if ((probe = ixj_probe_pci(&cnt)) < 0) {
7762 printk(KERN_INFO "ixj driver initialized.\n");
7763 create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL);
7767 module_init(ixj_init);
7768 module_exit(ixj_exit);
7770 static void DAA_Coeff_US(IXJ *j)
7774 j->daa_country = DAA_US;
7775 /*----------------------------------------------- */
7777 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
7778 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
7781 /* Bytes for IM-filter part 1 (04): 0E,32,E2,2F,C2,5A,C0,00 */
7782 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x03;
7783 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0x4B;
7784 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x5D;
7785 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xCD;
7786 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x24;
7787 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xC5;
7788 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
7789 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
7790 /* Bytes for IM-filter part 2 (05): 72,85,00,0E,2B,3A,D0,08 */
7791 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x71;
7792 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x1A;
7793 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
7794 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
7795 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xB5;
7796 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
7797 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
7798 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
7799 /* Bytes for FRX-filter (08): 03,8F,48,F2,8F,48,70,08 */
7800 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x05;
7801 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xA3;
7802 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x72;
7803 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
7804 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x3F;
7805 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x3B;
7806 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
7807 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
7808 /* Bytes for FRR-filter (07): 04,8F,38,7F,9B,EA,B0,08 */
7809 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x05;
7810 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
7811 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
7812 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x3E;
7813 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x32;
7814 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xDA;
7815 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
7816 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
7817 /* Bytes for AX-filter (0A): 16,55,DD,CA */
7818 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x41;
7819 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
7820 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
7821 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
7822 /* Bytes for AR-filter (09): 52,D3,11,42 */
7823 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
7824 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
7825 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
7826 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
7827 /* Bytes for TH-filter part 1 (00): 00,42,48,81,B3,80,00,98 */
7828 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
7829 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
7830 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
7831 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
7832 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA5;
7833 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
7834 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
7835 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
7836 /* Bytes for TH-filter part 2 (01): 02,F2,33,A0,68,AB,8A,AD */
7837 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
7838 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xA2;
7839 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2B;
7840 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
7841 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
7842 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAB;
7843 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
7844 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xCC;
7845 /* Bytes for TH-filter part 3 (02): 00,88,DA,54,A4,BA,2D,BB */
7846 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
7847 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
7848 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xD2;
7849 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x24;
7850 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBA;
7851 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xA9;
7852 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x3B;
7853 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xA6;
7854 /* ; (10K, 0.68uF) */
7856 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
7857 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
7858 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
7859 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
7860 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
7861 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
7862 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
7863 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
7864 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
7865 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
7866 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
7867 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
7868 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
7869 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
7870 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
7871 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
7872 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
7873 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
7875 /* Levelmetering Ringing (0D):B2,45,0F,8E */
7876 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
7877 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
7878 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
7879 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
7881 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
7882 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1C; */
7883 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0xB3; */
7884 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0xAB; */
7885 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xAB; */
7886 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x54; */
7887 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x2D; */
7888 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0x62; */
7889 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x2D; */
7890 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
7891 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x2D; */
7892 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x62; */
7893 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; */
7894 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBB; */
7895 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x2A; */
7896 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7D; */
7897 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; */
7898 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD4; */
7900 /* Levelmetering Ringing (0D):B2,45,0F,8E */
7901 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; */
7902 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x05; */
7903 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; */
7904 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; */
7906 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
7907 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
7908 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
7909 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
7910 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
7911 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
7912 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
7913 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
7914 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
7915 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
7916 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
7917 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
7918 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
7919 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
7920 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
7921 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
7922 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
7923 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
7926 /* Config. Reg. 0 (filters) (cr0):FE ; CLK gen. by crystal */
7927 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
7928 /* Config. Reg. 1 (dialing) (cr1):05 */
7929 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
7930 /* Config. Reg. 2 (caller ID) (cr2):04 */
7931 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
7932 /* Config. Reg. 3 (testloops) (cr3):03 ; SEL Bit==0, HP-disabled */
7933 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
7934 /* Config. Reg. 4 (analog gain) (cr4):02 */
7935 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
7936 /* Config. Reg. 5 (Version) (cr5):02 */
7937 /* Config. Reg. 6 (Reserved) (cr6):00 */
7938 /* Config. Reg. 7 (Reserved) (cr7):00 */
7941 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
7943 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
7944 /* Ext. Reg. 1 (Interrupt enable) (xr1):3C Cadence, RING, Caller ID, VDD_OK */
7946 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x3C;
7947 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
7948 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
7949 /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off == 1 */
7950 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x3B; /*0x32; */
7951 /* Ext. Reg. 4 (Cadence) (xr4):00 */
7953 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
7954 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
7955 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
7956 /* Ext. Reg. 6 (Power State) (xr6):00 */
7957 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
7958 /* Ext. Reg. 7 (Vdd) (xr7):40 */
7959 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
7961 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
7962 /* 12,33,5A,C3 ; 770 Hz */
7963 /* 13,3C,5B,32 ; 852 Hz */
7964 /* 1D,1B,5C,CC ; 941 Hz */
7966 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
7967 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
7968 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
7969 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
7970 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
7971 /* EC,1D,52,22 ; 1336 Hz */
7972 /* AA,AC,51,D2 ; 1477 Hz */
7973 /* 9B,3B,51,25 ; 1633 Hz */
7974 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
7975 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
7976 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
7977 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
7980 static void DAA_Coeff_UK(IXJ *j)
7984 j->daa_country = DAA_UK;
7985 /*----------------------------------------------- */
7987 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
7988 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
7991 /* Bytes for IM-filter part 1 (04): 00,C2,BB,A8,CB,81,A0,00 */
7992 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
7993 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xC2;
7994 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
7995 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xA8;
7996 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xCB;
7997 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
7998 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
7999 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8000 /* Bytes for IM-filter part 2 (05): 40,00,00,0A,A4,33,E0,08 */
8001 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x40;
8002 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x00;
8003 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8004 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
8005 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xA4;
8006 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8007 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8008 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8009 /* Bytes for FRX-filter (08): 07,9B,ED,24,B2,A2,A0,08 */
8010 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8011 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9B;
8012 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xED;
8013 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x24;
8014 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0xB2;
8015 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0xA2;
8016 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xA0;
8017 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8018 /* Bytes for FRR-filter (07): 0F,92,F2,B2,87,D2,30,08 */
8019 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
8020 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x92;
8021 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF2;
8022 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0xB2;
8023 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
8024 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xD2;
8025 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x30;
8026 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8027 /* Bytes for AX-filter (0A): 1B,A5,DD,CA */
8028 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x1B;
8029 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xA5;
8030 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8031 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8032 /* Bytes for AR-filter (09): E2,27,10,D6 */
8033 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
8034 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x27;
8035 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8036 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8037 /* Bytes for TH-filter part 1 (00): 80,2D,38,8B,D0,00,00,98 */
8038 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8039 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x2D;
8040 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x38;
8041 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x8B;
8042 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xD0;
8043 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x00;
8044 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8045 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8046 /* Bytes for TH-filter part 2 (01): 02,5A,53,F0,0B,5F,84,D4 */
8047 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8048 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x5A;
8049 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x53;
8050 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xF0;
8051 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x0B;
8052 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5F;
8053 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x84;
8054 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xD4;
8055 /* Bytes for TH-filter part 3 (02): 00,88,6A,A4,8F,52,F5,32 */
8056 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8057 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8058 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x6A;
8059 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA4;
8060 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x8F;
8061 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x52;
8062 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xF5;
8063 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x32;
8065 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8066 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8067 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8068 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8069 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8070 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8071 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8072 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8073 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8074 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8075 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8076 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8077 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8078 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8079 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8080 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8081 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8082 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8083 /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V less possible? */
8084 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
8085 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
8086 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8087 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8088 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8089 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8090 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8091 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8092 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8093 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8094 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8095 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8096 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8097 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8098 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8099 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8100 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8101 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8102 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8103 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8104 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8105 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8107 /* Config. Reg. 0 (filters) (cr0):FF */
8108 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8109 /* Config. Reg. 1 (dialing) (cr1):05 */
8110 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8111 /* Config. Reg. 2 (caller ID) (cr2):04 */
8112 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8113 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8114 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8115 /* Config. Reg. 4 (analog gain) (cr4):02 */
8116 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8117 /* Config. Reg. 5 (Version) (cr5):02 */
8118 /* Config. Reg. 6 (Reserved) (cr6):00 */
8119 /* Config. Reg. 7 (Reserved) (cr7):00 */
8121 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8123 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8124 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8126 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8127 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8129 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8130 /* Ext. Reg. 3 (DC Char) (xr3):36 ; */
8131 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
8132 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8133 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8134 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8135 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8136 /* Ext. Reg. 6 (Power State) (xr6):00 */
8137 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8138 /* Ext. Reg. 7 (Vdd) (xr7):46 */
8139 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
8140 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8141 /* 12,33,5A,C3 ; 770 Hz */
8142 /* 13,3C,5B,32 ; 852 Hz */
8143 /* 1D,1B,5C,CC ; 941 Hz */
8145 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8146 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8147 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8148 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8149 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8150 /* EC,1D,52,22 ; 1336 Hz */
8151 /* AA,AC,51,D2 ; 1477 Hz */
8152 /* 9B,3B,51,25 ; 1633 Hz */
8153 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8154 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8155 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8156 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8160 static void DAA_Coeff_France(IXJ *j)
8164 j->daa_country = DAA_FRANCE;
8165 /*----------------------------------------------- */
8167 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8168 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8171 /* Bytes for IM-filter part 1 (04): 02,A2,43,2C,22,AF,A0,00 */
8172 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x02;
8173 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA2;
8174 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x43;
8175 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2C;
8176 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x22;
8177 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xAF;
8178 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
8179 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8180 /* Bytes for IM-filter part 2 (05): 67,CE,00,0C,22,33,E0,08 */
8181 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x67;
8182 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xCE;
8183 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8184 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x2C;
8185 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x22;
8186 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8187 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8188 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8189 /* Bytes for FRX-filter (08): 07,9A,28,F6,23,4A,B0,08 */
8190 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8191 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9A;
8192 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x28;
8193 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0xF6;
8194 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x23;
8195 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x4A;
8196 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xB0;
8197 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8198 /* Bytes for FRR-filter (07): 03,8F,F9,2F,9E,FA,20,08 */
8199 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
8200 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
8201 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
8202 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
8203 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9E;
8204 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xFA;
8205 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
8206 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8207 /* Bytes for AX-filter (0A): 16,B5,DD,CA */
8208 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x16;
8209 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
8210 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8211 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8212 /* Bytes for AR-filter (09): 52,C7,10,D6 */
8213 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
8214 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
8215 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8216 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8217 /* Bytes for TH-filter part 1 (00): 00,42,48,81,A6,80,00,98 */
8218 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
8219 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
8220 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8221 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8222 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA6;
8223 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8224 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8225 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8226 /* Bytes for TH-filter part 2 (01): 02,AC,2A,30,78,AC,8A,2C */
8227 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8228 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAC;
8229 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
8230 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x30;
8231 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x78;
8232 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAC;
8233 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x8A;
8234 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x2C;
8235 /* Bytes for TH-filter part 3 (02): 00,88,DA,A5,22,BA,2C,45 */
8236 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8237 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8238 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
8239 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA5;
8240 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x22;
8241 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xBA;
8242 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x2C;
8243 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x45;
8245 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8246 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8247 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8248 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8249 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8250 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8251 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8252 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8253 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8254 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8255 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8256 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8257 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8258 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8259 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8260 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8261 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8262 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8263 /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
8264 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
8265 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8266 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
8267 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
8268 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8269 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8270 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8271 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8272 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8273 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8274 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8275 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8276 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8277 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8278 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8279 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8280 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8281 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8282 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8283 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8284 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8285 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8287 /* Config. Reg. 0 (filters) (cr0):FF */
8288 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8289 /* Config. Reg. 1 (dialing) (cr1):05 */
8290 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8291 /* Config. Reg. 2 (caller ID) (cr2):04 */
8292 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8293 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8294 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8295 /* Config. Reg. 4 (analog gain) (cr4):02 */
8296 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8297 /* Config. Reg. 5 (Version) (cr5):02 */
8298 /* Config. Reg. 6 (Reserved) (cr6):00 */
8299 /* Config. Reg. 7 (Reserved) (cr7):00 */
8301 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8303 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8304 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8306 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8307 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8309 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8310 /* Ext. Reg. 3 (DC Char) (xr3):36 ; */
8311 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
8312 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8313 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8314 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8315 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8316 /* Ext. Reg. 6 (Power State) (xr6):00 */
8317 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8318 /* Ext. Reg. 7 (Vdd) (xr7):46 */
8319 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
8320 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8321 /* 12,33,5A,C3 ; 770 Hz */
8322 /* 13,3C,5B,32 ; 852 Hz */
8323 /* 1D,1B,5C,CC ; 941 Hz */
8325 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8326 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8327 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8328 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8329 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8330 /* EC,1D,52,22 ; 1336 Hz */
8331 /* AA,AC,51,D2 ; 1477 Hz */
8332 /* 9B,3B,51,25 ; 1633 Hz */
8333 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8334 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8335 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8336 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8340 static void DAA_Coeff_Germany(IXJ *j)
8344 j->daa_country = DAA_GERMANY;
8345 /*----------------------------------------------- */
8347 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8348 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8351 /* Bytes for IM-filter part 1 (04): 00,CE,BB,B8,D2,81,B0,00 */
8352 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
8353 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xCE;
8354 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
8355 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xB8;
8356 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xD2;
8357 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
8358 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xB0;
8359 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8360 /* Bytes for IM-filter part 2 (05): 45,8F,00,0C,D2,3A,D0,08 */
8361 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x45;
8362 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x8F;
8363 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8364 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0C;
8365 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xD2;
8366 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x3A;
8367 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xD0;
8368 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8369 /* Bytes for FRX-filter (08): 07,AA,E2,34,24,89,20,08 */
8370 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8371 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xAA;
8372 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
8373 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
8374 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x24;
8375 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x89;
8376 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x20;
8377 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8378 /* Bytes for FRR-filter (07): 02,87,FA,37,9A,CA,B0,08 */
8379 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x02;
8380 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
8381 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xFA;
8382 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x37;
8383 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9A;
8384 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCA;
8385 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
8386 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8387 /* Bytes for AX-filter (0A): 72,D5,DD,CA */
8388 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x72;
8389 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xD5;
8390 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8391 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8392 /* Bytes for AR-filter (09): 72,42,13,4B */
8393 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x72;
8394 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x42;
8395 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x13;
8396 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0x4B;
8397 /* Bytes for TH-filter part 1 (00): 80,52,48,81,AD,80,00,98 */
8398 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8399 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
8400 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8401 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8402 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAD;
8403 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8404 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8405 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8406 /* Bytes for TH-filter part 2 (01): 02,42,5A,20,E8,1A,81,27 */
8407 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8408 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x42;
8409 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x5A;
8410 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
8411 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
8412 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x1A;
8413 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
8414 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x27;
8415 /* Bytes for TH-filter part 3 (02): 00,88,63,26,BD,4B,A3,C2 */
8416 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8417 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8418 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x63;
8419 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x26;
8420 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBD;
8421 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x4B;
8422 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xA3;
8423 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xC2;
8424 /* ; (10K, 0.68uF) */
8425 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
8426 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8427 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3B;
8428 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x9B;
8429 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xBA;
8430 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0xD4;
8431 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x1C;
8432 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xB3;
8433 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8434 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
8435 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x13;
8436 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x42;
8437 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8438 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8439 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0xD4;
8440 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x73;
8441 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0xCA;
8442 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8443 /* Levelmetering Ringing (0D):B2,45,0F,8E */
8444 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xB2;
8445 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8446 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8447 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8448 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8449 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8450 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8451 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8452 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8453 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8454 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8455 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8456 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8457 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8458 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8459 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8460 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8461 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8462 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8463 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8464 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8465 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8467 /* Config. Reg. 0 (filters) (cr0):FF ; all Filters enabled, CLK from ext. source */
8468 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8469 /* Config. Reg. 1 (dialing) (cr1):05 ; Manual Ring, Ring metering enabled */
8470 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8471 /* Config. Reg. 2 (caller ID) (cr2):04 ; Analog Gain 0dB, FSC internal */
8472 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8473 /* Config. Reg. 3 (testloops) (cr3):00 ; SEL Bit==0, HP-enabled */
8474 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8475 /* Config. Reg. 4 (analog gain) (cr4):02 */
8476 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8477 /* Config. Reg. 5 (Version) (cr5):02 */
8478 /* Config. Reg. 6 (Reserved) (cr6):00 */
8479 /* Config. Reg. 7 (Reserved) (cr7):00 */
8481 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8483 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8484 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C ; Ring, CID, VDDOK Interrupts enabled */
8486 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8487 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8489 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8490 /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off==1, U0=3.5V, R=200Ohm */
8491 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x32;
8492 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8493 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8494 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8495 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8496 /* Ext. Reg. 6 (Power State) (xr6):00 */
8497 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8498 /* Ext. Reg. 7 (Vdd) (xr7):40 ; VDD=4.25 V */
8499 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8500 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8501 /* 12,33,5A,C3 ; 770 Hz */
8502 /* 13,3C,5B,32 ; 852 Hz */
8503 /* 1D,1B,5C,CC ; 941 Hz */
8505 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8506 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8507 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8508 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8509 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8510 /* EC,1D,52,22 ; 1336 Hz */
8511 /* AA,AC,51,D2 ; 1477 Hz */
8512 /* 9B,3B,51,25 ; 1633 Hz */
8513 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8514 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8515 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8516 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8520 static void DAA_Coeff_Australia(IXJ *j)
8524 j->daa_country = DAA_AUSTRALIA;
8525 /*----------------------------------------------- */
8527 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8528 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8531 /* Bytes for IM-filter part 1 (04): 00,A3,AA,28,B3,82,D0,00 */
8532 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
8533 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA3;
8534 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xAA;
8535 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x28;
8536 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xB3;
8537 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x82;
8538 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xD0;
8539 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8540 /* Bytes for IM-filter part 2 (05): 70,96,00,09,32,6B,C0,08 */
8541 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x70;
8542 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x96;
8543 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8544 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x09;
8545 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x32;
8546 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x6B;
8547 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xC0;
8548 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8549 /* Bytes for FRX-filter (08): 07,96,E2,34,32,9B,30,08 */
8550 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8551 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x96;
8552 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
8553 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
8554 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x32;
8555 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x9B;
8556 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
8557 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8558 /* Bytes for FRR-filter (07): 0F,9A,E9,2F,22,CC,A0,08 */
8559 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
8560 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x9A;
8561 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xE9;
8562 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
8563 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x22;
8564 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCC;
8565 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xA0;
8566 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8567 /* Bytes for AX-filter (0A): CB,45,DD,CA */
8568 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0xCB;
8569 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0x45;
8570 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8571 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8572 /* Bytes for AR-filter (09): 1B,67,10,D6 */
8573 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x1B;
8574 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x67;
8575 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8576 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8577 /* Bytes for TH-filter part 1 (00): 80,52,48,81,AF,80,00,98 */
8578 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8579 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
8580 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8581 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8582 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAF;
8583 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8584 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8585 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8586 /* Bytes for TH-filter part 2 (01): 02,DB,52,B0,38,01,82,AC */
8587 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8588 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xDB;
8589 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x52;
8590 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
8591 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x38;
8592 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x01;
8593 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x82;
8594 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xAC;
8595 /* Bytes for TH-filter part 3 (02): 00,88,4A,3E,2C,3B,24,46 */
8596 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8597 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8598 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x4A;
8599 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x3E;
8600 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x2C;
8601 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x3B;
8602 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x24;
8603 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x46;
8605 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8606 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8607 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8608 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8609 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8610 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8611 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8612 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8613 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8614 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8615 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8616 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8617 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8618 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8619 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8620 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8621 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8622 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8623 /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
8624 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
8625 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8626 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
8627 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
8628 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8629 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8630 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8631 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8632 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8633 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8634 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8635 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8636 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8637 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8638 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8639 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8640 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8641 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8642 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8643 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8644 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8645 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8647 /* Config. Reg. 0 (filters) (cr0):FF */
8648 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8649 /* Config. Reg. 1 (dialing) (cr1):05 */
8650 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8651 /* Config. Reg. 2 (caller ID) (cr2):04 */
8652 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8653 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8654 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8655 /* Config. Reg. 4 (analog gain) (cr4):02 */
8656 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8657 /* Config. Reg. 5 (Version) (cr5):02 */
8658 /* Config. Reg. 6 (Reserved) (cr6):00 */
8659 /* Config. Reg. 7 (Reserved) (cr7):00 */
8661 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8663 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8664 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8666 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8667 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8669 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8670 /* Ext. Reg. 3 (DC Char) (xr3):2B ; */
8671 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x2B;
8672 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8673 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8674 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8675 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8676 /* Ext. Reg. 6 (Power State) (xr6):00 */
8677 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8678 /* Ext. Reg. 7 (Vdd) (xr7):40 */
8679 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8681 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8682 /* 12,33,5A,C3 ; 770 Hz */
8683 /* 13,3C,5B,32 ; 852 Hz */
8684 /* 1D,1B,5C,CC ; 941 Hz */
8685 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8686 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8687 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8688 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8690 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8691 /* EC,1D,52,22 ; 1336 Hz */
8692 /* AA,AC,51,D2 ; 1477 Hz */
8693 /* 9B,3B,51,25 ; 1633 Hz */
8694 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8695 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8696 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8697 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8700 static void DAA_Coeff_Japan(IXJ *j)
8704 j->daa_country = DAA_JAPAN;
8705 /*----------------------------------------------- */
8707 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8708 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8711 /* Bytes for IM-filter part 1 (04): 06,BD,E2,2D,BA,F9,A0,00 */
8712 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x06;
8713 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xBD;
8714 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xE2;
8715 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2D;
8716 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xBA;
8717 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xF9;
8718 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
8719 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8720 /* Bytes for IM-filter part 2 (05): 6F,F7,00,0E,34,33,E0,08 */
8721 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x6F;
8722 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xF7;
8723 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8724 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0E;
8725 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x34;
8726 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8727 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8728 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8729 /* Bytes for FRX-filter (08): 02,8F,68,77,9C,58,F0,08 */
8730 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x02;
8731 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x8F;
8732 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x68;
8733 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x77;
8734 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x9C;
8735 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x58;
8736 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xF0;
8737 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8738 /* Bytes for FRR-filter (07): 03,8F,38,73,87,EA,20,08 */
8739 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
8740 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
8741 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0x38;
8742 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x73;
8743 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
8744 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xEA;
8745 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
8746 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8747 /* Bytes for AX-filter (0A): 51,C5,DD,CA */
8748 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x51;
8749 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xC5;
8750 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8751 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8752 /* Bytes for AR-filter (09): 25,A7,10,D6 */
8753 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
8754 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xA7;
8755 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8756 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8757 /* Bytes for TH-filter part 1 (00): 00,42,48,81,AE,80,00,98 */
8758 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
8759 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
8760 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8761 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8762 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAE;
8763 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8764 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8765 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8766 /* Bytes for TH-filter part 2 (01): 02,AB,2A,20,99,5B,89,28 */
8767 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8768 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAB;
8769 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
8770 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
8771 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x99;
8772 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5B;
8773 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x89;
8774 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x28;
8775 /* Bytes for TH-filter part 3 (02): 00,88,DA,25,34,C5,4C,BA */
8776 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8777 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8778 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
8779 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x25;
8780 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x34;
8781 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xC5;
8782 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x4C;
8783 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xBA;
8785 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8786 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8787 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8788 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8789 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8790 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8791 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8792 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8793 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8794 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8795 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8796 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8797 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8798 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8799 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8800 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8801 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8802 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8803 /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V ????????? */
8804 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
8805 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
8806 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8807 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8808 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8809 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8810 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8811 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8812 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8813 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8814 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8815 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8816 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8817 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8818 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8819 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8820 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8821 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8822 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8823 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8824 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8825 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8827 /* Config. Reg. 0 (filters) (cr0):FF */
8828 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8829 /* Config. Reg. 1 (dialing) (cr1):05 */
8830 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8831 /* Config. Reg. 2 (caller ID) (cr2):04 */
8832 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8833 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8834 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8835 /* Config. Reg. 4 (analog gain) (cr4):02 */
8836 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8837 /* Config. Reg. 5 (Version) (cr5):02 */
8838 /* Config. Reg. 6 (Reserved) (cr6):00 */
8839 /* Config. Reg. 7 (Reserved) (cr7):00 */
8841 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8843 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8844 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8846 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8847 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8849 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8850 /* Ext. Reg. 3 (DC Char) (xr3):22 ; */
8851 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x22;
8852 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8853 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8854 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8855 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8856 /* Ext. Reg. 6 (Power State) (xr6):00 */
8857 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8858 /* Ext. Reg. 7 (Vdd) (xr7):40 */
8859 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8860 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8861 /* 12,33,5A,C3 ; 770 Hz */
8862 /* 13,3C,5B,32 ; 852 Hz */
8863 /* 1D,1B,5C,CC ; 941 Hz */
8865 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8866 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8867 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8868 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8869 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8870 /* EC,1D,52,22 ; 1336 Hz */
8871 /* AA,AC,51,D2 ; 1477 Hz */
8872 /* 9B,3B,51,25 ; 1633 Hz */
8873 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8874 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8875 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8876 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8879 static s16 tone_table[][19] =
8882 32538, /* A1 = 1.985962 */
8883 -32325, /* A2 = -0.986511 */
8884 -343, /* B2 = -0.010493 */
8886 343, /* B0 = 0.010493 */
8887 32619, /* A1 = 1.990906 */
8888 -32520, /* A2 = -0.992462 */
8889 19179, /* B2 = 0.585327 */
8890 -19178, /* B1 = -1.170593 */
8891 19179, /* B0 = 0.585327 */
8892 32723, /* A1 = 1.997314 */
8893 -32686, /* A2 = -0.997528 */
8894 9973, /* B2 = 0.304352 */
8895 -9955, /* B1 = -0.607605 */
8896 9973, /* B0 = 0.304352 */
8897 7, /* Internal filter scaling */
8898 159, /* Minimum in-band energy threshold */
8899 21, /* 21/32 in-band to broad-band ratio */
8900 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8902 { /* f133_200[] 12 */
8903 32072, /* A1 = 1.95752 */
8904 -31896, /* A2 = -0.973419 */
8905 -435, /* B2 = -0.013294 */
8907 435, /* B0 = 0.013294 */
8908 32188, /* A1 = 1.9646 */
8909 -32400, /* A2 = -0.98877 */
8910 15139, /* B2 = 0.462036 */
8911 -14882, /* B1 = -0.908356 */
8912 15139, /* B0 = 0.462036 */
8913 32473, /* A1 = 1.981995 */
8914 -32524, /* A2 = -0.992584 */
8915 23200, /* B2 = 0.708008 */
8916 -23113, /* B1 = -1.410706 */
8917 23200, /* B0 = 0.708008 */
8918 7, /* Internal filter scaling */
8919 159, /* Minimum in-band energy threshold */
8920 21, /* 21/32 in-band to broad-band ratio */
8921 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8924 31769, /* A1 = -1.939026 */
8925 -32584, /* A2 = 0.994385 */
8926 -475, /* B2 = -0.014522 */
8927 0, /* B1 = 0.000000 */
8928 475, /* B0 = 0.014522 */
8929 31789, /* A1 = -1.940247 */
8930 -32679, /* A2 = 0.997284 */
8931 17280, /* B2 = 0.527344 */
8932 -16865, /* B1 = -1.029358 */
8933 17280, /* B0 = 0.527344 */
8934 31841, /* A1 = -1.943481 */
8935 -32681, /* A2 = 0.997345 */
8936 543, /* B2 = 0.016579 */
8937 -525, /* B1 = -0.032097 */
8938 543, /* B0 = 0.016579 */
8939 5, /* Internal filter scaling */
8940 159, /* Minimum in-band energy threshold */
8941 21, /* 21/32 in-band to broad-band ratio */
8942 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8944 { /* f300_420[] 14 */
8945 30750, /* A1 = 1.876892 */
8946 -31212, /* A2 = -0.952515 */
8947 -804, /* B2 = -0.024541 */
8949 804, /* B0 = 0.024541 */
8950 30686, /* A1 = 1.872925 */
8951 -32145, /* A2 = -0.980988 */
8952 14747, /* B2 = 0.450043 */
8953 -13703, /* B1 = -0.836395 */
8954 14747, /* B0 = 0.450043 */
8955 31651, /* A1 = 1.931824 */
8956 -32321, /* A2 = -0.986389 */
8957 24425, /* B2 = 0.745422 */
8958 -23914, /* B1 = -1.459595 */
8959 24427, /* B0 = 0.745483 */
8960 7, /* Internal filter scaling */
8961 159, /* Minimum in-band energy threshold */
8962 21, /* 21/32 in-band to broad-band ratio */
8963 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8966 31613, /* A1 = -1.929565 */
8967 -32646, /* A2 = 0.996277 */
8968 -185, /* B2 = -0.005657 */
8969 0, /* B1 = 0.000000 */
8970 185, /* B0 = 0.005657 */
8971 31620, /* A1 = -1.929932 */
8972 -32713, /* A2 = 0.998352 */
8973 19253, /* B2 = 0.587585 */
8974 -18566, /* B1 = -1.133179 */
8975 19253, /* B0 = 0.587585 */
8976 31674, /* A1 = -1.933228 */
8977 -32715, /* A2 = 0.998413 */
8978 2575, /* B2 = 0.078590 */
8979 -2495, /* B1 = -0.152283 */
8980 2575, /* B0 = 0.078590 */
8981 5, /* Internal filter scaling */
8982 159, /* Minimum in-band energy threshold */
8983 21, /* 21/32 in-band to broad-band ratio */
8984 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8986 { /* f300_425[] 16 */
8987 30741, /* A1 = 1.876282 */
8988 -31475, /* A2 = -0.960541 */
8989 -703, /* B2 = -0.021484 */
8991 703, /* B0 = 0.021484 */
8992 30688, /* A1 = 1.873047 */
8993 -32248, /* A2 = -0.984161 */
8994 14542, /* B2 = 0.443787 */
8995 -13523, /* B1 = -0.825439 */
8996 14542, /* B0 = 0.443817 */
8997 31494, /* A1 = 1.922302 */
8998 -32366, /* A2 = -0.987762 */
8999 21577, /* B2 = 0.658508 */
9000 -21013, /* B1 = -1.282532 */
9001 21577, /* B0 = 0.658508 */
9002 7, /* Internal filter scaling */
9003 159, /* Minimum in-band energy threshold */
9004 21, /* 21/32 in-band to broad-band ratio */
9005 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9007 { /* f330_440[] 17 */
9008 30627, /* A1 = 1.869324 */
9009 -31338, /* A2 = -0.95636 */
9010 -843, /* B2 = -0.025749 */
9012 843, /* B0 = 0.025749 */
9013 30550, /* A1 = 1.864685 */
9014 -32221, /* A2 = -0.983337 */
9015 13594, /* B2 = 0.414886 */
9016 -12589, /* B1 = -0.768402 */
9017 13594, /* B0 = 0.414886 */
9018 31488, /* A1 = 1.921936 */
9019 -32358, /* A2 = -0.987518 */
9020 24684, /* B2 = 0.753296 */
9021 -24029, /* B1 = -1.466614 */
9022 24684, /* B0 = 0.753296 */
9023 7, /* Internal filter scaling */
9024 159, /* Minimum in-band energy threshold */
9025 21, /* 21/32 in-band to broad-band ratio */
9026 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9029 31546, /* A1 = -1.925476 */
9030 -32646, /* A2 = 0.996277 */
9031 -445, /* B2 = -0.013588 */
9032 0, /* B1 = 0.000000 */
9033 445, /* B0 = 0.013588 */
9034 31551, /* A1 = -1.925781 */
9035 -32713, /* A2 = 0.998352 */
9036 23884, /* B2 = 0.728882 */
9037 -22979, /* B1 = -1.402527 */
9038 23884, /* B0 = 0.728882 */
9039 31606, /* A1 = -1.929138 */
9040 -32715, /* A2 = 0.998413 */
9041 863, /* B2 = 0.026367 */
9042 -835, /* B1 = -0.050985 */
9043 863, /* B0 = 0.026367 */
9044 5, /* Internal filter scaling */
9045 159, /* Minimum in-band energy threshold */
9046 21, /* 21/32 in-band to broad-band ratio */
9047 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9049 { /* f350_400[] 19 */
9050 31006, /* A1 = 1.892517 */
9051 -32029, /* A2 = -0.977448 */
9052 -461, /* B2 = -0.014096 */
9054 461, /* B0 = 0.014096 */
9055 30999, /* A1 = 1.892029 */
9056 -32487, /* A2 = -0.991455 */
9057 11325, /* B2 = 0.345612 */
9058 -10682, /* B1 = -0.651978 */
9059 11325, /* B0 = 0.345612 */
9060 31441, /* A1 = 1.919067 */
9061 -32526, /* A2 = -0.992615 */
9062 24324, /* B2 = 0.74231 */
9063 -23535, /* B1 = -1.436523 */
9064 24324, /* B0 = 0.74231 */
9065 7, /* Internal filter scaling */
9066 159, /* Minimum in-band energy threshold */
9067 21, /* 21/32 in-band to broad-band ratio */
9068 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9071 30634, /* A1 = 1.869751 */
9072 -31533, /* A2 = -0.962341 */
9073 -680, /* B2 = -0.020782 */
9075 680, /* B0 = 0.020782 */
9076 30571, /* A1 = 1.865906 */
9077 -32277, /* A2 = -0.985016 */
9078 12894, /* B2 = 0.393524 */
9079 -11945, /* B1 = -0.729065 */
9080 12894, /* B0 = 0.393524 */
9081 31367, /* A1 = 1.91449 */
9082 -32379, /* A2 = -0.988129 */
9083 23820, /* B2 = 0.726929 */
9084 -23104, /* B1 = -1.410217 */
9085 23820, /* B0 = 0.726929 */
9086 7, /* Internal filter scaling */
9087 159, /* Minimum in-band energy threshold */
9088 21, /* 21/32 in-band to broad-band ratio */
9089 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9092 30552, /* A1 = 1.864807 */
9093 -31434, /* A2 = -0.95929 */
9094 -690, /* B2 = -0.021066 */
9096 690, /* B0 = 0.021066 */
9097 30472, /* A1 = 1.859924 */
9098 -32248, /* A2 = -0.984161 */
9099 13385, /* B2 = 0.408478 */
9100 -12357, /* B1 = -0.754242 */
9101 13385, /* B0 = 0.408478 */
9102 31358, /* A1 = 1.914001 */
9103 -32366, /* A2 = -0.987732 */
9104 26488, /* B2 = 0.80835 */
9105 -25692, /* B1 = -1.568176 */
9106 26490, /* B0 = 0.808411 */
9107 7, /* Internal filter scaling */
9108 159, /* Minimum in-band energy threshold */
9109 21, /* 21/32 in-band to broad-band ratio */
9110 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9113 31397, /* A1 = -1.916321 */
9114 -32623, /* A2 = 0.995605 */
9115 -117, /* B2 = -0.003598 */
9116 0, /* B1 = 0.000000 */
9117 117, /* B0 = 0.003598 */
9118 31403, /* A1 = -1.916687 */
9119 -32700, /* A2 = 0.997925 */
9120 3388, /* B2 = 0.103401 */
9121 -3240, /* B1 = -0.197784 */
9122 3388, /* B0 = 0.103401 */
9123 31463, /* A1 = -1.920410 */
9124 -32702, /* A2 = 0.997986 */
9125 13346, /* B2 = 0.407288 */
9126 -12863, /* B1 = -0.785126 */
9127 13346, /* B0 = 0.407288 */
9128 5, /* Internal filter scaling */
9129 159, /* Minimum in-band energy threshold */
9130 21, /* 21/32 in-band to broad-band ratio */
9131 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9134 30831, /* A1 = 1.881775 */
9135 -32064, /* A2 = -0.978546 */
9136 -367, /* B2 = -0.01122 */
9138 367, /* B0 = 0.01122 */
9139 30813, /* A1 = 1.880737 */
9140 -32456, /* A2 = -0.990509 */
9141 11068, /* B2 = 0.337769 */
9142 -10338, /* B1 = -0.631042 */
9143 11068, /* B0 = 0.337769 */
9144 31214, /* A1 = 1.905212 */
9145 -32491, /* A2 = -0.991577 */
9146 16374, /* B2 = 0.499695 */
9147 -15781, /* B1 = -0.963196 */
9148 16374, /* B0 = 0.499695 */
9149 7, /* Internal filter scaling */
9150 159, /* Minimum in-band energy threshold */
9151 21, /* 21/32 in-band to broad-band ratio */
9152 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9155 31152, /* A1 = -1.901428 */
9156 -32613, /* A2 = 0.995300 */
9157 -314, /* B2 = -0.009605 */
9158 0, /* B1 = 0.000000 */
9159 314, /* B0 = 0.009605 */
9160 31156, /* A1 = -1.901672 */
9161 -32694, /* A2 = 0.997742 */
9162 28847, /* B2 = 0.880371 */
9163 -2734, /* B1 = -0.166901 */
9164 28847, /* B0 = 0.880371 */
9165 31225, /* A1 = -1.905823 */
9166 -32696, /* A2 = 0.997803 */
9167 462, /* B2 = 0.014108 */
9168 -442, /* B1 = -0.027019 */
9169 462, /* B0 = 0.014108 */
9170 5, /* Internal filter scaling */
9171 159, /* Minimum in-band energy threshold */
9172 21, /* 21/32 in-band to broad-band ratio */
9173 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9176 30836, /* A1 = 1.882141 */
9177 -32296, /* A2 = -0.985596 */
9178 -324, /* B2 = -0.009903 */
9180 324, /* B0 = 0.009903 */
9181 30825, /* A1 = 1.881409 */
9182 -32570, /* A2 = -0.993958 */
9183 16847, /* B2 = 0.51416 */
9184 -15792, /* B1 = -0.963898 */
9185 16847, /* B0 = 0.51416 */
9186 31106, /* A1 = 1.89856 */
9187 -32584, /* A2 = -0.994415 */
9188 9579, /* B2 = 0.292328 */
9189 -9164, /* B1 = -0.559357 */
9190 9579, /* B0 = 0.292328 */
9191 7, /* Internal filter scaling */
9192 159, /* Minimum in-band energy threshold */
9193 21, /* 21/32 in-band to broad-band ratio */
9194 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9197 30702, /* A1 = 1.873962 */
9198 -32134, /* A2 = -0.980682 */
9199 -517, /* B2 = -0.015793 */
9201 517, /* B0 = 0.015793 */
9202 30676, /* A1 = 1.872375 */
9203 -32520, /* A2 = -0.992462 */
9204 8144, /* B2 = 0.24855 */
9205 -7596, /* B1 = -0.463684 */
9206 8144, /* B0 = 0.24855 */
9207 31084, /* A1 = 1.897217 */
9208 -32547, /* A2 = -0.993256 */
9209 22713, /* B2 = 0.693176 */
9210 -21734, /* B1 = -1.326599 */
9211 22713, /* B0 = 0.693176 */
9212 7, /* Internal filter scaling */
9213 159, /* Minimum in-band energy threshold */
9214 21, /* 21/32 in-band to broad-band ratio */
9215 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9218 30613, /* A1 = 1.86853 */
9219 -32031, /* A2 = -0.977509 */
9220 -618, /* B2 = -0.018866 */
9222 618, /* B0 = 0.018866 */
9223 30577, /* A1 = 1.866272 */
9224 -32491, /* A2 = -0.991577 */
9225 9612, /* B2 = 0.293335 */
9226 -8935, /* B1 = -0.54541 */
9227 9612, /* B0 = 0.293335 */
9228 31071, /* A1 = 1.896484 */
9229 -32524, /* A2 = -0.992584 */
9230 21596, /* B2 = 0.659058 */
9231 -20667, /* B1 = -1.261414 */
9232 21596, /* B0 = 0.659058 */
9233 7, /* Internal filter scaling */
9234 159, /* Minimum in-band energy threshold */
9235 21, /* 21/32 in-band to broad-band ratio */
9236 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9239 30914, /* A1 = -1.886841 */
9240 -32584, /* A2 = 0.994385 */
9241 -426, /* B2 = -0.013020 */
9242 0, /* B1 = 0.000000 */
9243 426, /* B0 = 0.013020 */
9244 30914, /* A1 = -1.886841 */
9245 -32679, /* A2 = 0.997314 */
9246 17520, /* B2 = 0.534668 */
9247 -16471, /* B1 = -1.005310 */
9248 17520, /* B0 = 0.534668 */
9249 31004, /* A1 = -1.892334 */
9250 -32683, /* A2 = 0.997406 */
9251 819, /* B2 = 0.025023 */
9252 -780, /* B1 = -0.047619 */
9253 819, /* B0 = 0.025023 */
9254 5, /* Internal filter scaling */
9255 159, /* Minimum in-band energy threshold */
9256 21, /* 21/32 in-band to broad-band ratio */
9257 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9261 30881, /* A1 = -1.884827 */
9262 -32603, /* A2 = 0.994965 */
9263 -496, /* B2 = -0.015144 */
9264 0, /* B1 = 0.000000 */
9265 496, /* B0 = 0.015144 */
9266 30880, /* A1 = -1.884766 */
9267 -32692, /* A2 = 0.997711 */
9268 24767, /* B2 = 0.755859 */
9269 -23290, /* B1 = -1.421509 */
9270 24767, /* B0 = 0.755859 */
9271 30967, /* A1 = -1.890076 */
9272 -32694, /* A2 = 0.997772 */
9273 728, /* B2 = 0.022232 */
9274 -691, /* B1 = -0.042194 */
9275 728, /* B0 = 0.022232 */
9276 5, /* Internal filter scaling */
9277 159, /* Minimum in-band energy threshold */
9278 21, /* 21/32 in-band to broad-band ratio */
9279 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9305 30646, /* A1 = 1.870544 */
9306 -32327, /* A2 = -0.986572 */
9307 -287, /* B2 = -0.008769 */
9309 287, /* B0 = 0.008769 */
9310 30627, /* A1 = 1.869324 */
9311 -32607, /* A2 = -0.995087 */
9312 13269, /* B2 = 0.404968 */
9313 -12376, /* B1 = -0.755432 */
9314 13269, /* B0 = 0.404968 */
9315 30924, /* A1 = 1.887512 */
9316 -32619, /* A2 = -0.995453 */
9317 19950, /* B2 = 0.608826 */
9318 -18940, /* B1 = -1.156006 */
9319 19950, /* B0 = 0.608826 */
9320 7, /* Internal filter scaling */
9321 159, /* Minimum in-band energy threshold */
9322 21, /* 21/32 in-band to broad-band ratio */
9323 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9326 30396, /* A1 = 1.855225 */
9327 -32014, /* A2 = -0.97699 */
9328 -395, /* B2 = -0.012055 */
9330 395, /* B0 = 0.012055 */
9331 30343, /* A1 = 1.85199 */
9332 -32482, /* A2 = -0.991302 */
9333 17823, /* B2 = 0.543945 */
9334 -16431, /* B1 = -1.002869 */
9335 17823, /* B0 = 0.543945 */
9336 30872, /* A1 = 1.884338 */
9337 -32516, /* A2 = -0.99231 */
9338 18124, /* B2 = 0.553101 */
9339 -17246, /* B1 = -1.052673 */
9340 18124, /* B0 = 0.553101 */
9341 7, /* Internal filter scaling */
9342 159, /* Minimum in-band energy threshold */
9343 21, /* 21/32 in-band to broad-band ratio */
9344 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9347 30796, /* A1 = -1.879639 */
9348 -32603, /* A2 = 0.994965 */
9349 -254, /* B2 = -0.007762 */
9350 0, /* B1 = 0.000000 */
9351 254, /* B0 = 0.007762 */
9352 30793, /* A1 = -1.879456 */
9353 -32692, /* A2 = 0.997711 */
9354 18934, /* B2 = 0.577820 */
9355 -17751, /* B1 = -1.083496 */
9356 18934, /* B0 = 0.577820 */
9357 30882, /* A1 = -1.884888 */
9358 -32694, /* A2 = 0.997772 */
9359 1858, /* B2 = 0.056713 */
9360 -1758, /* B1 = -0.107357 */
9361 1858, /* B0 = 0.056713 */
9362 5, /* Internal filter scaling */
9363 159, /* Minimum in-band energy threshold */
9364 21, /* 21/32 in-band to broad-band ratio */
9365 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9368 30641, /* A1 = 1.870239 */
9369 -32458, /* A2 = -0.99057 */
9370 -155, /* B2 = -0.004735 */
9372 155, /* B0 = 0.004735 */
9373 30631, /* A1 = 1.869568 */
9374 -32630, /* A2 = -0.995789 */
9375 11453, /* B2 = 0.349548 */
9376 -10666, /* B1 = -0.651001 */
9377 11453, /* B0 = 0.349548 */
9378 30810, /* A1 = 1.880554 */
9379 -32634, /* A2 = -0.995941 */
9380 12237, /* B2 = 0.373474 */
9381 -11588, /* B1 = -0.707336 */
9382 12237, /* B0 = 0.373474 */
9383 7, /* Internal filter scaling */
9384 159, /* Minimum in-band energy threshold */
9385 21, /* 21/32 in-band to broad-band ratio */
9386 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9389 30367, /* A1 = 1.853455 */
9390 -32147, /* A2 = -0.981079 */
9391 -495, /* B2 = -0.015113 */
9393 495, /* B0 = 0.015113 */
9394 30322, /* A1 = 1.850769 */
9395 -32543, /* A2 = -0.993134 */
9396 10031, /* B2 = 0.306152 */
9397 -9252, /* B1 = -0.564728 */
9398 10031, /* B0 = 0.306152 */
9399 30770, /* A1 = 1.878052 */
9400 -32563, /* A2 = -0.993774 */
9401 22674, /* B2 = 0.691956 */
9402 -21465, /* B1 = -1.31012 */
9403 22674, /* B0 = 0.691956 */
9404 7, /* Internal filter scaling */
9405 159, /* Minimum in-band energy threshold */
9406 21, /* 21/32 in-band to broad-band ratio */
9407 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9410 30709, /* A1 = -1.874329 */
9411 -32603, /* A2 = 0.994965 */
9412 -83, /* B2 = -0.002545 */
9413 0, /* B1 = 0.000000 */
9414 83, /* B0 = 0.002545 */
9415 30704, /* A1 = -1.874084 */
9416 -32692, /* A2 = 0.997711 */
9417 10641, /* B2 = 0.324738 */
9418 -9947, /* B1 = -0.607147 */
9419 10641, /* B0 = 0.324738 */
9420 30796, /* A1 = -1.879639 */
9421 -32694, /* A2 = 0.997772 */
9422 10079, /* B2 = 0.307587 */
9423 9513, /* B1 = 0.580688 */
9424 10079, /* B0 = 0.307587 */
9425 5, /* Internal filter scaling */
9426 159, /* Minimum in-band energy threshold */
9427 21, /* 21/32 in-band to broad-band ratio */
9428 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9431 30664, /* A1 = -1.871643 */
9432 -32603, /* A2 = 0.994965 */
9433 -164, /* B2 = -0.005029 */
9434 0, /* B1 = 0.000000 */
9435 164, /* B0 = 0.005029 */
9436 30661, /* A1 = -1.871399 */
9437 -32692, /* A2 = 0.997711 */
9438 15294, /* B2 = 0.466736 */
9439 -14275, /* B1 = -0.871307 */
9440 15294, /* B0 = 0.466736 */
9441 30751, /* A1 = -1.876953 */
9442 -32694, /* A2 = 0.997772 */
9443 3548, /* B2 = 0.108284 */
9444 -3344, /* B1 = -0.204155 */
9445 3548, /* B0 = 0.108284 */
9446 5, /* Internal filter scaling */
9447 159, /* Minimum in-band energy threshold */
9448 21, /* 21/32 in-band to broad-band ratio */
9449 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9452 30653, /* A1 = -1.870911 */
9453 -32615, /* A2 = 0.995361 */
9454 -209, /* B2 = -0.006382 */
9455 0, /* B1 = 0.000000 */
9456 209, /* B0 = 0.006382 */
9457 30647, /* A1 = -1.870605 */
9458 -32702, /* A2 = 0.997986 */
9459 18971, /* B2 = 0.578979 */
9460 -17716, /* B1 = -1.081299 */
9461 18971, /* B0 = 0.578979 */
9462 30738, /* A1 = -1.876099 */
9463 -32702, /* A2 = 0.998016 */
9464 2967, /* B2 = 0.090561 */
9465 -2793, /* B1 = -0.170502 */
9466 2967, /* B0 = 0.090561 */
9467 5, /* Internal filter scaling */
9468 159, /* Minimum in-band energy threshold */
9469 21, /* 21/32 in-band to broad-band ratio */
9470 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9473 30437, /* A1 = -1.857727 */
9474 -32603, /* A2 = 0.994965 */
9475 -264, /* B2 = -0.008062 */
9476 0, /* B1 = 0.000000 */
9477 264, /* B0 = 0.008062 */
9478 30430, /* A1 = -1.857300 */
9479 -32692, /* A2 = 0.997711 */
9480 21681, /* B2 = 0.661682 */
9481 -20082, /* B1 = -1.225708 */
9482 21681, /* B0 = 0.661682 */
9483 30526, /* A1 = -1.863220 */
9484 -32694, /* A2 = 0.997742 */
9485 1559, /* B2 = 0.047600 */
9486 -1459, /* B1 = -0.089096 */
9487 1559, /* B0 = 0.047600 */
9488 5, /* Internal filter scaling */
9489 159, /* Minimum in-band energy threshold */
9490 21, /* 21/32 in-band to broad-band ratio */
9491 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9494 28975, /* A1 = 1.768494 */
9495 -30955, /* A2 = -0.944672 */
9496 -1026, /* B2 = -0.03133 */
9498 1026, /* B0 = 0.03133 */
9499 28613, /* A1 = 1.746399 */
9500 -32089, /* A2 = -0.979309 */
9501 14214, /* B2 = 0.433807 */
9502 -12202, /* B1 = -0.744812 */
9503 14214, /* B0 = 0.433807 */
9504 30243, /* A1 = 1.845947 */
9505 -32238, /* A2 = -0.983856 */
9506 24825, /* B2 = 0.757629 */
9507 -23402, /* B1 = -1.428345 */
9508 24825, /* B0 = 0.757629 */
9509 7, /* Internal filter scaling */
9510 159, /* Minimum in-band energy threshold */
9511 21, /* 21/32 in-band to broad-band ratio */
9512 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9515 30257, /* A1 = -1.846741 */
9516 -32605, /* A2 = 0.995056 */
9517 -249, /* B2 = -0.007625 */
9518 0, /* B1 = 0.000000 */
9519 249, /* B0 = 0.007625 */
9520 30247, /* A1 = -1.846191 */
9521 -32694, /* A2 = 0.997772 */
9522 18088, /* B2 = 0.552002 */
9523 -16652, /* B1 = -1.016418 */
9524 18088, /* B0 = 0.552002 */
9525 30348, /* A1 = -1.852295 */
9526 -32696, /* A2 = 0.997803 */
9527 2099, /* B2 = 0.064064 */
9528 -1953, /* B1 = -0.119202 */
9529 2099, /* B0 = 0.064064 */
9530 5, /* Internal filter scaling */
9531 159, /* Minimum in-band energy threshold */
9532 21, /* 21/32 in-band to broad-band ratio */
9533 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9536 30202, /* A1 = -1.843431 */
9537 -32624, /* A2 = 0.995622 */
9538 -413, /* B2 = -0.012622 */
9539 0, /* B1 = 0.000000 */
9540 413, /* B0 = 0.012622 */
9541 30191, /* A1 = -1.842721 */
9542 -32714, /* A2 = 0.998364 */
9543 25954, /* B2 = 0.792057 */
9544 -23890, /* B1 = -1.458131 */
9545 25954, /* B0 = 0.792057 */
9546 30296, /* A1 = -1.849172 */
9547 -32715, /* A2 = 0.998397 */
9548 2007, /* B2 = 0.061264 */
9549 -1860, /* B1 = -0.113568 */
9550 2007, /* B0 = 0.061264 */
9551 5, /* Internal filter scaling */
9552 159, /* Minimum in-band energy threshold */
9553 21, /* 21/32 in-band to broad-band ratio */
9554 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9557 30001, /* A1 = -1.831116 */
9558 -32613, /* A2 = 0.995270 */
9559 -155, /* B2 = -0.004750 */
9560 0, /* B1 = 0.000000 */
9561 155, /* B0 = 0.004750 */
9562 29985, /* A1 = -1.830200 */
9563 -32710, /* A2 = 0.998260 */
9564 6584, /* B2 = 0.200928 */
9565 -6018, /* B1 = -0.367355 */
9566 6584, /* B0 = 0.200928 */
9567 30105, /* A1 = -1.837524 */
9568 -32712, /* A2 = 0.998291 */
9569 23812, /* B2 = 0.726685 */
9570 -21936, /* B1 = -1.338928 */
9571 23812, /* B0 = 0.726685 */
9572 5, /* Internal filter scaling */
9573 159, /* Minimum in-band energy threshold */
9574 21, /* 21/32 in-band to broad-band ratio */
9575 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9578 29964, /* A1 = -1.828918 */
9579 -32601, /* A2 = 0.994904 */
9580 -101, /* B2 = -0.003110 */
9581 0, /* B1 = 0.000000 */
9582 101, /* B0 = 0.003110 */
9583 29949, /* A1 = -1.827942 */
9584 -32700, /* A2 = 0.997925 */
9585 11041, /* B2 = 0.336975 */
9586 -10075, /* B1 = -0.614960 */
9587 11041, /* B0 = 0.336975 */
9588 30070, /* A1 = -1.835388 */
9589 -32702, /* A2 = 0.997986 */
9590 16762, /* B2 = 0.511536 */
9591 -15437, /* B1 = -0.942230 */
9592 16762, /* B0 = 0.511536 */
9593 5, /* Internal filter scaling */
9594 159, /* Minimum in-band energy threshold */
9595 21, /* 21/32 in-band to broad-band ratio */
9596 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9599 29936, /* A1 = -1.827209 */
9600 -32584, /* A2 = 0.994415 */
9601 -91, /* B2 = -0.002806 */
9602 0, /* B1 = 0.000000 */
9603 91, /* B0 = 0.002806 */
9604 29921, /* A1 = -1.826233 */
9605 -32688, /* A2 = 0.997559 */
9606 11449, /* B2 = 0.349396 */
9607 -10426, /* B1 = -0.636383 */
9608 11449, /* B0 = 0.349396 */
9609 30045, /* A1 = -1.833862 */
9610 -32688, /* A2 = 0.997589 */
9611 13055, /* B2 = 0.398407 */
9612 -12028, /* B1 = -0.734161 */
9613 13055, /* B0 = 0.398407 */
9614 5, /* Internal filter scaling */
9615 159, /* Minimum in-band energy threshold */
9616 21, /* 21/32 in-band to broad-band ratio */
9617 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9620 28499, /* A1 = 1.739441 */
9621 -31129, /* A2 = -0.949982 */
9622 -849, /* B2 = -0.025922 */
9624 849, /* B0 = 0.025922 */
9625 28128, /* A1 = 1.716797 */
9626 -32130, /* A2 = -0.98056 */
9627 14556, /* B2 = 0.444214 */
9628 -12251, /* B1 = -0.747772 */
9629 14556, /* B0 = 0.444244 */
9630 29667, /* A1 = 1.81073 */
9631 -32244, /* A2 = -0.984039 */
9632 23038, /* B2 = 0.703064 */
9633 -21358, /* B1 = -1.303589 */
9634 23040, /* B0 = 0.703125 */
9635 7, /* Internal filter scaling */
9636 159, /* Minimum in-band energy threshold */
9637 21, /* 21/32 in-band to broad-band ratio */
9638 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9641 29271, /* A1 = -1.786560 */
9642 -32599, /* A2 = 0.994873 */
9643 -490, /* B2 = -0.014957 */
9644 0, /* B1 = 0.000000 */
9645 490, /* B0 = 0.014957 */
9646 29246, /* A1 = -1.785095 */
9647 -32700, /* A2 = 0.997925 */
9648 28961, /* B2 = 0.883850 */
9649 -25796, /* B1 = -1.574463 */
9650 28961, /* B0 = 0.883850 */
9651 29383, /* A1 = -1.793396 */
9652 -32700, /* A2 = 0.997955 */
9653 1299, /* B2 = 0.039650 */
9654 -1169, /* B1 = -0.071396 */
9655 1299, /* B0 = 0.039650 */
9656 5, /* Internal filter scaling */
9657 159, /* Minimum in-band energy threshold */
9658 21, /* 21/32 in-band to broad-band ratio */
9659 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9662 29230, /* A1 = -1.784058 */
9663 -32584, /* A2 = 0.994415 */
9664 -418, /* B2 = -0.012757 */
9665 0, /* B1 = 0.000000 */
9666 418, /* B0 = 0.012757 */
9667 29206, /* A1 = -1.782593 */
9668 -32688, /* A2 = 0.997559 */
9669 36556, /* B2 = 1.115601 */
9670 -32478, /* B1 = -1.982300 */
9671 36556, /* B0 = 1.115601 */
9672 29345, /* A1 = -1.791077 */
9673 -32688, /* A2 = 0.997589 */
9674 897, /* B2 = 0.027397 */
9675 -808, /* B1 = -0.049334 */
9676 897, /* B0 = 0.027397 */
9677 5, /* Internal filter scaling */
9678 159, /* Minimum in-band energy threshold */
9679 21, /* 21/32 in-band to broad-band ratio */
9680 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9683 29116, /* A1 = -1.777100 */
9684 -32603, /* A2 = 0.994965 */
9685 -165, /* B2 = -0.005039 */
9686 0, /* B1 = 0.000000 */
9687 165, /* B0 = 0.005039 */
9688 29089, /* A1 = -1.775452 */
9689 -32708, /* A2 = 0.998199 */
9690 6963, /* B2 = 0.212494 */
9691 -6172, /* B1 = -0.376770 */
9692 6963, /* B0 = 0.212494 */
9693 29237, /* A1 = -1.784485 */
9694 -32710, /* A2 = 0.998230 */
9695 24197, /* B2 = 0.738464 */
9696 -21657, /* B1 = -1.321899 */
9697 24197, /* B0 = 0.738464 */
9698 5, /* Internal filter scaling */
9699 159, /* Minimum in-band energy threshold */
9700 21, /* 21/32 in-band to broad-band ratio */
9701 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9704 28376, /* A1 = -1.731934 */
9705 -32567, /* A2 = 0.993896 */
9706 -363, /* B2 = -0.011102 */
9707 0, /* B1 = 0.000000 */
9708 363, /* B0 = 0.011102 */
9709 28337, /* A1 = -1.729614 */
9710 -32683, /* A2 = 0.997434 */
9711 21766, /* B2 = 0.664246 */
9712 -18761, /* B1 = -1.145081 */
9713 21766, /* B0 = 0.664246 */
9714 28513, /* A1 = -1.740356 */
9715 -32686, /* A2 = 0.997498 */
9716 2509, /* B2 = 0.076584 */
9717 -2196, /* B1 = -0.134041 */
9718 2509, /* B0 = 0.076584 */
9719 5, /* Internal filter scaling */
9720 159, /* Minimum in-band energy threshold */
9721 21, /* 21/32 in-band to broad-band ratio */
9722 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9725 27844, /* A1 = -1.699463 */
9726 -32563, /* A2 = 0.993744 */
9727 -366, /* B2 = -0.011187 */
9728 0, /* B1 = 0.000000 */
9729 366, /* B0 = 0.011187 */
9730 27797, /* A1 = -1.696655 */
9731 -32686, /* A2 = 0.997498 */
9732 22748, /* B2 = 0.694214 */
9733 -19235, /* B1 = -1.174072 */
9734 22748, /* B0 = 0.694214 */
9735 27995, /* A1 = -1.708740 */
9736 -32688, /* A2 = 0.997559 */
9737 2964, /* B2 = 0.090477 */
9738 -2546, /* B1 = -0.155449 */
9739 2964, /* B0 = 0.090477 */
9740 5, /* Internal filter scaling */
9741 159, /* Minimum in-band energy threshold */
9742 21, /* 21/32 in-band to broad-band ratio */
9743 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9746 27297, /* A1 = -1.666077 */
9747 -32551, /* A2 = 0.993408 */
9748 -345, /* B2 = -0.010540 */
9749 0, /* B1 = 0.000000 */
9750 345, /* B0 = 0.010540 */
9751 27240, /* A1 = -1.662598 */
9752 -32683, /* A2 = 0.997406 */
9753 22560, /* B2 = 0.688477 */
9754 -18688, /* B1 = -1.140625 */
9755 22560, /* B0 = 0.688477 */
9756 27461, /* A1 = -1.676147 */
9757 -32684, /* A2 = 0.997467 */
9758 3541, /* B2 = 0.108086 */
9759 -2985, /* B1 = -0.182220 */
9760 3541, /* B0 = 0.108086 */
9761 5, /* Internal filter scaling */
9762 159, /* Minimum in-band energy threshold */
9763 21, /* 21/32 in-band to broad-band ratio */
9764 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9767 27155, /* A1 = -1.657410 */
9768 -32551, /* A2 = 0.993408 */
9769 -462, /* B2 = -0.014117 */
9770 0, /* B1 = 0.000000 */
9771 462, /* B0 = 0.014117 */
9772 27097, /* A1 = -1.653870 */
9773 -32683, /* A2 = 0.997406 */
9774 32495, /* B2 = 0.991699 */
9775 -26776, /* B1 = -1.634338 */
9776 32495, /* B0 = 0.991699 */
9777 27321, /* A1 = -1.667542 */
9778 -32684, /* A2 = 0.997467 */
9779 1835, /* B2 = 0.056007 */
9780 -1539, /* B1 = -0.093948 */
9781 1835, /* B0 = 0.056007 */
9782 5, /* Internal filter scaling */
9783 159, /* Minimum in-band energy threshold */
9784 21, /* 21/32 in-band to broad-band ratio */
9785 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9788 19298, /* A1 = 1.177917 */
9789 -24471, /* A2 = -0.746796 */
9790 -4152, /* B2 = -0.126709 */
9792 4152, /* B0 = 0.126709 */
9793 12902, /* A1 = 0.787476 */
9794 -29091, /* A2 = -0.887817 */
9795 12491, /* B2 = 0.38121 */
9796 -1794, /* B1 = -0.109528 */
9797 12494, /* B0 = 0.381317 */
9798 26291, /* A1 = 1.604736 */
9799 -30470, /* A2 = -0.929901 */
9800 28859, /* B2 = 0.880737 */
9801 -26084, /* B1 = -1.592102 */
9802 28861, /* B0 = 0.880798 */
9803 7, /* Internal filter scaling */
9804 159, /* Minimum in-band energy threshold */
9805 21, /* 21/32 in-band to broad-band ratio */
9806 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9809 26867, /* A1 = -1.639832 */
9810 -32551, /* A2 = 0.993408 */
9811 -123, /* B2 = -0.003755 */
9812 0, /* B1 = 0.000000 */
9813 123, /* B0 = 0.003755 */
9814 26805, /* A1 = -1.636108 */
9815 -32683, /* A2 = 0.997406 */
9816 17297, /* B2 = 0.527863 */
9817 -14096, /* B1 = -0.860382 */
9818 17297, /* B0 = 0.527863 */
9819 27034, /* A1 = -1.650085 */
9820 -32684, /* A2 = 0.997467 */
9821 12958, /* B2 = 0.395477 */
9822 -10756, /* B1 = -0.656525 */
9823 12958, /* B0 = 0.395477 */
9824 5, /* Internal filter scaling */
9825 159, /* Minimum in-band energy threshold */
9826 21, /* 21/32 in-band to broad-band ratio */
9827 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9830 26413, /* A1 = -1.612122 */
9831 -32547, /* A2 = 0.993286 */
9832 -223, /* B2 = -0.006825 */
9833 0, /* B1 = 0.000000 */
9834 223, /* B0 = 0.006825 */
9835 26342, /* A1 = -1.607849 */
9836 -32686, /* A2 = 0.997498 */
9837 6391, /* B2 = 0.195053 */
9838 -5120, /* B1 = -0.312531 */
9839 6391, /* B0 = 0.195053 */
9840 26593, /* A1 = -1.623108 */
9841 -32688, /* A2 = 0.997559 */
9842 23681, /* B2 = 0.722717 */
9843 -19328, /* B1 = -1.179688 */
9844 23681, /* B0 = 0.722717 */
9845 5, /* Internal filter scaling */
9846 159, /* Minimum in-band energy threshold */
9847 21, /* 21/32 in-band to broad-band ratio */
9848 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9851 26168, /* A1 = -1.597209 */
9852 -32528, /* A2 = 0.992706 */
9853 -235, /* B2 = -0.007182 */
9854 0, /* B1 = 0.000000 */
9855 235, /* B0 = 0.007182 */
9856 26092, /* A1 = -1.592590 */
9857 -32675, /* A2 = 0.997192 */
9858 20823, /* B2 = 0.635498 */
9859 -16510, /* B1 = -1.007751 */
9860 20823, /* B0 = 0.635498 */
9861 26363, /* A1 = -1.609070 */
9862 -32677, /* A2 = 0.997253 */
9863 6739, /* B2 = 0.205688 */
9864 -5459, /* B1 = -0.333206 */
9865 6739, /* B0 = 0.205688 */
9866 5, /* Internal filter scaling */
9867 159, /* Minimum in-band energy threshold */
9868 21, /* 21/32 in-band to broad-band ratio */
9869 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9872 25641, /* A1 = -1.565063 */
9873 -32536, /* A2 = 0.992950 */
9874 -121, /* B2 = -0.003707 */
9875 0, /* B1 = 0.000000 */
9876 121, /* B0 = 0.003707 */
9877 25560, /* A1 = -1.560059 */
9878 -32684, /* A2 = 0.997437 */
9879 18341, /* B2 = 0.559753 */
9880 -14252, /* B1 = -0.869904 */
9881 18341, /* B0 = 0.559753 */
9882 25837, /* A1 = -1.577026 */
9883 -32684, /* A2 = 0.997467 */
9884 16679, /* B2 = 0.509003 */
9885 -13232, /* B1 = -0.807648 */
9886 16679, /* B0 = 0.509003 */
9887 5, /* Internal filter scaling */
9888 159, /* Minimum in-band energy threshold */
9889 21, /* 21/32 in-band to broad-band ratio */
9890 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9893 16415, /* A1 = 1.001953 */
9894 -23669, /* A2 = -0.722321 */
9895 -4549, /* B2 = -0.138847 */
9897 4549, /* B0 = 0.138847 */
9898 8456, /* A1 = 0.516174 */
9899 -28996, /* A2 = -0.884918 */
9900 13753, /* B2 = 0.419724 */
9901 -12, /* B1 = -0.000763 */
9902 13757, /* B0 = 0.419846 */
9903 24632, /* A1 = 1.503418 */
9904 -30271, /* A2 = -0.923828 */
9905 29070, /* B2 = 0.887146 */
9906 -25265, /* B1 = -1.542114 */
9907 29073, /* B0 = 0.887268 */
9908 7, /* Internal filter scaling */
9909 159, /* Minimum in-band energy threshold */
9910 21, /* 21/32 in-band to broad-band ratio */
9911 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9914 24806, /* A1 = -1.514099 */
9915 -32501, /* A2 = 0.991852 */
9916 -326, /* B2 = -0.009969 */
9917 0, /* B1 = 0.000000 */
9918 326, /* B0 = 0.009969 */
9919 24709, /* A1 = -1.508118 */
9920 -32659, /* A2 = 0.996674 */
9921 20277, /* B2 = 0.618835 */
9922 -15182, /* B1 = -0.926636 */
9923 20277, /* B0 = 0.618835 */
9924 25022, /* A1 = -1.527222 */
9925 -32661, /* A2 = 0.996735 */
9926 4320, /* B2 = 0.131836 */
9927 -3331, /* B1 = -0.203339 */
9928 4320, /* B0 = 0.131836 */
9929 5, /* Internal filter scaling */
9930 159, /* Minimum in-band energy threshold */
9931 21, /* 21/32 in-band to broad-band ratio */
9932 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9935 19776, /* A1 = 1.207092 */
9936 -27437, /* A2 = -0.837341 */
9937 -2666, /* B2 = -0.081371 */
9939 2666, /* B0 = 0.081371 */
9940 16302, /* A1 = 0.995026 */
9941 -30354, /* A2 = -0.926361 */
9942 10389, /* B2 = 0.317062 */
9943 -3327, /* B1 = -0.203064 */
9944 10389, /* B0 = 0.317062 */
9945 24299, /* A1 = 1.483154 */
9946 -30930, /* A2 = -0.943909 */
9947 25016, /* B2 = 0.763428 */
9948 -21171, /* B1 = -1.292236 */
9949 25016, /* B0 = 0.763428 */
9950 7, /* Internal filter scaling */
9951 159, /* Minimum in-band energy threshold */
9952 21, /* 21/32 in-band to broad-band ratio */
9953 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9956 20554, /* A1 = 1.254517 */
9957 -28764, /* A2 = -0.877838 */
9958 -2048, /* B2 = -0.062515 */
9960 2048, /* B0 = 0.062515 */
9961 18209, /* A1 = 1.11145 */
9962 -30951, /* A2 = -0.94458 */
9963 9390, /* B2 = 0.286575 */
9964 -3955, /* B1 = -0.241455 */
9965 9390, /* B0 = 0.286575 */
9966 23902, /* A1 = 1.458923 */
9967 -31286, /* A2 = -0.954803 */
9968 23252, /* B2 = 0.709595 */
9969 -19132, /* B1 = -1.167725 */
9970 23252, /* B0 = 0.709595 */
9971 7, /* Internal filter scaling */
9972 159, /* Minimum in-band energy threshold */
9973 21, /* 21/32 in-band to broad-band ratio */
9974 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9977 17543, /* A1 = 1.07074 */
9978 -26220, /* A2 = -0.800201 */
9979 -3298, /* B2 = -0.100647 */
9981 3298, /* B0 = 0.100647 */
9982 12423, /* A1 = 0.75827 */
9983 -30036, /* A2 = -0.916626 */
9984 12651, /* B2 = 0.386078 */
9985 -2444, /* B1 = -0.14917 */
9986 12653, /* B0 = 0.386154 */
9987 23518, /* A1 = 1.435425 */
9988 -30745, /* A2 = -0.938293 */
9989 27282, /* B2 = 0.832581 */
9990 -22529, /* B1 = -1.375122 */
9991 27286, /* B0 = 0.832703 */
9992 7, /* Internal filter scaling */
9993 159, /* Minimum in-band energy threshold */
9994 21, /* 21/32 in-band to broad-band ratio */
9995 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9998 24104, /* A1 = -1.471252 */
9999 -32507, /* A2 = 0.992065 */
10000 -351, /* B2 = -0.010722 */
10001 0, /* B1 = 0.000000 */
10002 351, /* B0 = 0.010722 */
10003 23996, /* A1 = -1.464600 */
10004 -32671, /* A2 = 0.997040 */
10005 22848, /* B2 = 0.697266 */
10006 -16639, /* B1 = -1.015564 */
10007 22848, /* B0 = 0.697266 */
10008 24332, /* A1 = -1.485168 */
10009 -32673, /* A2 = 0.997101 */
10010 4906, /* B2 = 0.149727 */
10011 -3672, /* B1 = -0.224174 */
10012 4906, /* B0 = 0.149727 */
10013 5, /* Internal filter scaling */
10014 159, /* Minimum in-band energy threshold */
10015 21, /* 21/32 in-band to broad-band ratio */
10016 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10019 23967, /* A1 = -1.462830 */
10020 -32507, /* A2 = 0.992065 */
10021 -518, /* B2 = -0.015821 */
10022 0, /* B1 = 0.000000 */
10023 518, /* B0 = 0.015821 */
10024 23856, /* A1 = -1.456055 */
10025 -32671, /* A2 = 0.997040 */
10026 26287, /* B2 = 0.802246 */
10027 -19031, /* B1 = -1.161560 */
10028 26287, /* B0 = 0.802246 */
10029 24195, /* A1 = -1.476746 */
10030 -32673, /* A2 = 0.997101 */
10031 2890, /* B2 = 0.088196 */
10032 -2151, /* B1 = -0.131317 */
10033 2890, /* B0 = 0.088196 */
10034 5, /* Internal filter scaling */
10035 159, /* Minimum in-band energy threshold */
10036 21, /* 21/32 in-band to broad-band ratio */
10037 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10039 { /* f950_1400[] */
10040 18294, /* A1 = 1.116638 */
10041 -26962, /* A2 = -0.822845 */
10042 -2914, /* B2 = -0.088936 */
10044 2914, /* B0 = 0.088936 */
10045 14119, /* A1 = 0.861786 */
10046 -30227, /* A2 = -0.922455 */
10047 11466, /* B2 = 0.349945 */
10048 -2833, /* B1 = -0.172943 */
10049 11466, /* B0 = 0.349945 */
10050 23431, /* A1 = 1.430115 */
10051 -30828, /* A2 = -0.940796 */
10052 25331, /* B2 = 0.773071 */
10053 -20911, /* B1 = -1.276367 */
10054 25331, /* B0 = 0.773071 */
10055 7, /* Internal filter scaling */
10056 159, /* Minimum in-band energy threshold */
10057 21, /* 21/32 in-band to broad-band ratio */
10058 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10061 23521, /* A1 = -1.435608 */
10062 -32489, /* A2 = 0.991516 */
10063 -193, /* B2 = -0.005915 */
10064 0, /* B1 = 0.000000 */
10065 193, /* B0 = 0.005915 */
10066 23404, /* A1 = -1.428467 */
10067 -32655, /* A2 = 0.996582 */
10068 17740, /* B2 = 0.541412 */
10069 -12567, /* B1 = -0.767029 */
10070 17740, /* B0 = 0.541412 */
10071 23753, /* A1 = -1.449829 */
10072 -32657, /* A2 = 0.996613 */
10073 9090, /* B2 = 0.277405 */
10074 -6662, /* B1 = -0.406647 */
10075 9090, /* B0 = 0.277405 */
10076 5, /* Internal filter scaling */
10077 159, /* Minimum in-band energy threshold */
10078 21, /* 21/32 in-band to broad-band ratio */
10079 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10082 23071, /* A1 = -1.408203 */
10083 -32489, /* A2 = 0.991516 */
10084 -293, /* B2 = -0.008965 */
10085 0, /* B1 = 0.000000 */
10086 293, /* B0 = 0.008965 */
10087 22951, /* A1 = -1.400818 */
10088 -32655, /* A2 = 0.996582 */
10089 5689, /* B2 = 0.173645 */
10090 -3951, /* B1 = -0.241150 */
10091 5689, /* B0 = 0.173645 */
10092 23307, /* A1 = -1.422607 */
10093 -32657, /* A2 = 0.996613 */
10094 18692, /* B2 = 0.570435 */
10095 -13447, /* B1 = -0.820770 */
10096 18692, /* B0 = 0.570435 */
10097 5, /* Internal filter scaling */
10098 159, /* Minimum in-band energy threshold */
10099 21, /* 21/32 in-band to broad-band ratio */
10100 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10103 22701, /* A1 = -1.385620 */
10104 -32474, /* A2 = 0.991058 */
10105 -292, /* B2 = -0.008933 */
10106 0, /*163840 , B1 = 10.000000 */
10107 292, /* B0 = 0.008933 */
10108 22564, /* A1 = -1.377258 */
10109 -32655, /* A2 = 0.996552 */
10110 20756, /* B2 = 0.633423 */
10111 -14176, /* B1 = -0.865295 */
10112 20756, /* B0 = 0.633423 */
10113 22960, /* A1 = -1.401428 */
10114 -32657, /* A2 = 0.996613 */
10115 6520, /* B2 = 0.198990 */
10116 -4619, /* B1 = -0.281937 */
10117 6520, /* B0 = 0.198990 */
10118 5, /* Internal filter scaling */
10119 159, /* Minimum in-band energy threshold */
10120 21, /* 21/32 in-band to broad-band ratio */
10121 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10124 22142, /* A1 = -1.351501 */
10125 -32474, /* A2 = 0.991058 */
10126 -147, /* B2 = -0.004493 */
10127 0, /* B1 = 0.000000 */
10128 147, /* B0 = 0.004493 */
10129 22000, /* A1 = -1.342834 */
10130 -32655, /* A2 = 0.996552 */
10131 15379, /* B2 = 0.469360 */
10132 -10237, /* B1 = -0.624847 */
10133 15379, /* B0 = 0.469360 */
10134 22406, /* A1 = -1.367554 */
10135 -32657, /* A2 = 0.996613 */
10136 17491, /* B2 = 0.533783 */
10137 -12096, /* B1 = -0.738312 */
10138 17491, /* B0 = 0.533783 */
10139 5, /* Internal filter scaling */
10140 159, /* Minimum in-band energy threshold */
10141 21, /* 21/32 in-band to broad-band ratio */
10142 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10144 { /* f1100_1750[] */
10145 12973, /* A1 = 0.79184 */
10146 -24916, /* A2 = -0.760376 */
10147 6655, /* B2 = 0.203102 */
10148 367, /* B1 = 0.0224 */
10149 6657, /* B0 = 0.203171 */
10150 5915, /* A1 = 0.361053 */
10151 -29560, /* A2 = -0.90213 */
10152 -7777, /* B2 = -0.23735 */
10154 7777, /* B0 = 0.23735 */
10155 20510, /* A1 = 1.251892 */
10156 -30260, /* A2 = -0.923462 */
10157 26662, /* B2 = 0.81366 */
10158 -20573, /* B1 = -1.255737 */
10159 26668, /* B0 = 0.813843 */
10160 7, /* Internal filter scaling */
10161 159, /* Minimum in-band energy threshold */
10162 21, /* 21/32 in-band to broad-band ratio */
10163 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10166 20392, /* A1 = -1.244629 */
10167 -32460, /* A2 = 0.990601 */
10168 -270, /* B2 = -0.008240 */
10169 0, /* B1 = 0.000000 */
10170 270, /* B0 = 0.008240 */
10171 20218, /* A1 = -1.234009 */
10172 -32655, /* A2 = 0.996582 */
10173 21337, /* B2 = 0.651154 */
10174 -13044, /* B1 = -0.796143 */
10175 21337, /* B0 = 0.651154 */
10176 20684, /* A1 = -1.262512 */
10177 -32657, /* A2 = 0.996643 */
10178 8572, /* B2 = 0.261612 */
10179 -5476, /* B1 = -0.334244 */
10180 8572, /* B0 = 0.261612 */
10181 5, /* Internal filter scaling */
10182 159, /* Minimum in-band energy threshold */
10183 21, /* 21/32 in-band to broad-band ratio */
10184 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10187 19159, /* A1 = -1.169373 */
10188 -32456, /* A2 = 0.990509 */
10189 -335, /* B2 = -0.010252 */
10190 0, /* B1 = 0.000000 */
10191 335, /* B0 = 0.010252 */
10192 18966, /* A1 = -1.157593 */
10193 -32661, /* A2 = 0.996735 */
10194 6802, /* B2 = 0.207588 */
10195 -3900, /* B1 = -0.238098 */
10196 6802, /* B0 = 0.207588 */
10197 19467, /* A1 = -1.188232 */
10198 -32661, /* A2 = 0.996765 */
10199 25035, /* B2 = 0.764008 */
10200 -15049, /* B1 = -0.918579 */
10201 25035, /* B0 = 0.764008 */
10202 5, /* Internal filter scaling */
10203 159, /* Minimum in-band energy threshold */
10204 21, /* 21/32 in-band to broad-band ratio */
10205 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10208 18976, /* A1 = -1.158264 */
10209 -32439, /* A2 = 0.989990 */
10210 -183, /* B2 = -0.005588 */
10211 0, /* B1 = 0.000000 */
10212 183, /* B0 = 0.005588 */
10213 18774, /* A1 = -1.145874 */
10214 -32650, /* A2 = 0.996429 */
10215 15468, /* B2 = 0.472076 */
10216 -8768, /* B1 = -0.535217 */
10217 15468, /* B0 = 0.472076 */
10218 19300, /* A1 = -1.177979 */
10219 -32652, /* A2 = 0.996490 */
10220 19840, /* B2 = 0.605499 */
10221 -11842, /* B1 = -0.722809 */
10222 19840, /* B0 = 0.605499 */
10223 5, /* Internal filter scaling */
10224 159, /* Minimum in-band energy threshold */
10225 21, /* 21/32 in-band to broad-band ratio */
10226 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10229 16357, /* A1 = -0.998413 */
10230 -32368, /* A2 = 0.987793 */
10231 -217, /* B2 = -0.006652 */
10232 0, /* B1 = 0.000000 */
10233 217, /* B0 = 0.006652 */
10234 16107, /* A1 = -0.983126 */
10235 -32601, /* A2 = 0.994904 */
10236 11602, /* B2 = 0.354065 */
10237 -5555, /* B1 = -0.339111 */
10238 11602, /* B0 = 0.354065 */
10239 16722, /* A1 = -1.020630 */
10240 -32603, /* A2 = 0.994965 */
10241 15574, /* B2 = 0.475311 */
10242 -8176, /* B1 = -0.499069 */
10243 15574, /* B0 = 0.475311 */
10244 5, /* Internal filter scaling */
10245 159, /* Minimum in-band energy threshold */
10246 21, /* 21/32 in-band to broad-band ratio */
10247 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10250 16234, /* A1 = -0.990875 */
10251 32404, /* A2 = -0.988922 */
10252 -193, /* B2 = -0.005908 */
10253 0, /* B1 = 0.000000 */
10254 193, /* B0 = 0.005908 */
10255 15986, /* A1 = -0.975769 */
10256 -32632, /* A2 = 0.995880 */
10257 18051, /* B2 = 0.550903 */
10258 -8658, /* B1 = -0.528473 */
10259 18051, /* B0 = 0.550903 */
10260 16591, /* A1 = -1.012695 */
10261 -32634, /* A2 = 0.995941 */
10262 15736, /* B2 = 0.480240 */
10263 -8125, /* B1 = -0.495926 */
10264 15736, /* B0 = 0.480240 */
10265 5, /* Internal filter scaling */
10266 159, /* Minimum in-band energy threshold */
10267 21, /* 21/32 in-band to broad-band ratio */
10268 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10271 15564, /* A1 = -0.949982 */
10272 -32404, /* A2 = 0.988922 */
10273 -269, /* B2 = -0.008216 */
10274 0, /* B1 = 0.000000 */
10275 269, /* B0 = 0.008216 */
10276 15310, /* A1 = -0.934479 */
10277 -32632, /* A2 = 0.995880 */
10278 10815, /* B2 = 0.330063 */
10279 -4962, /* B1 = -0.302887 */
10280 10815, /* B0 = 0.330063 */
10281 15924, /* A1 = -0.971924 */
10282 -32634, /* A2 = 0.995941 */
10283 18880, /* B2 = 0.576172 */
10284 -9364, /* B1 = -0.571594 */
10285 18880, /* B0 = 0.576172 */
10286 5, /* Internal filter scaling */
10287 159, /* Minimum in-band energy threshold */
10288 21, /* 21/32 in-band to broad-band ratio */
10289 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10292 15247, /* A1 = -0.930603 */
10293 -32397, /* A2 = 0.988708 */
10294 -244, /* B2 = -0.007451 */
10295 0, /* B1 = 0.000000 */
10296 244, /* B0 = 0.007451 */
10297 14989, /* A1 = -0.914886 */
10298 -32627, /* A2 = 0.995697 */
10299 18961, /* B2 = 0.578644 */
10300 -8498, /* B1 = -0.518707 */
10301 18961, /* B0 = 0.578644 */
10302 15608, /* A1 = -0.952667 */
10303 -32628, /* A2 = 0.995758 */
10304 11145, /* B2 = 0.340134 */
10305 -5430, /* B1 = -0.331467 */
10306 11145, /* B0 = 0.340134 */
10307 5, /* Internal filter scaling */
10308 159, /* Minimum in-band energy threshold */
10309 21, /* 21/32 in-band to broad-band ratio */
10310 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10313 14780, /* A1 = -0.902130 */
10314 -32393, /* A2 = 0.988586 */
10315 -396, /* B2 = -0.012086 */
10316 0, /* B1 = 0.000000 */
10317 396, /* B0 = 0.012086 */
10318 14510, /* A1 = -0.885651 */
10319 -32630, /* A2 = 0.995819 */
10320 6326, /* B2 = 0.193069 */
10321 -2747, /* B1 = -0.167671 */
10322 6326, /* B0 = 0.193069 */
10323 15154, /* A1 = -0.924957 */
10324 -32632, /* A2 = 0.995850 */
10325 23235, /* B2 = 0.709076 */
10326 -10983, /* B1 = -0.670380 */
10327 23235, /* B0 = 0.709076 */
10328 5, /* Internal filter scaling */
10329 159, /* Minimum in-band energy threshold */
10330 21, /* 21/32 in-band to broad-band ratio */
10331 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10334 13005, /* A1 = -0.793793 */
10335 -32368, /* A2 = 0.987823 */
10336 -500, /* B2 = -0.015265 */
10337 0, /* B1 = 0.000000 */
10338 500, /* B0 = 0.015265 */
10339 12708, /* A1 = -0.775665 */
10340 -32615, /* A2 = 0.995331 */
10341 11420, /* B2 = 0.348526 */
10342 -4306, /* B1 = -0.262833 */
10343 11420, /* B0 = 0.348526 */
10344 13397, /* A1 = -0.817688 */
10345 -32615, /* A2 = 0.995361 */
10346 9454, /* B2 = 0.288528 */
10347 -3981, /* B1 = -0.243027 */
10348 9454, /* B0 = 0.288528 */
10349 5, /* Internal filter scaling */
10350 159, /* Minimum in-band energy threshold */
10351 21, /* 21/32 in-band to broad-band ratio */
10352 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10355 10046, /* A1 = -0.613190 */
10356 -32331, /* A2 = 0.986694 */
10357 -455, /* B2 = -0.013915 */
10358 0, /* B1 = 0.000000 */
10359 455, /* B0 = 0.013915 */
10360 9694, /* A1 = -0.591705 */
10361 -32601, /* A2 = 0.994934 */
10362 6023, /* B2 = 0.183815 */
10363 -1708, /* B1 = -0.104279 */
10364 6023, /* B0 = 0.183815 */
10365 10478, /* A1 = -0.639587 */
10366 -32603, /* A2 = 0.994965 */
10367 22031, /* B2 = 0.672333 */
10368 -7342, /* B1 = -0.448151 */
10369 22031, /* B0 = 0.672333 */
10370 5, /* Internal filter scaling */
10371 159, /* Minimum in-band energy threshold */
10372 21, /* 21/32 in-band to broad-band ratio */
10373 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10375 { /* f1633_1638[] */
10376 9181, /* A1 = 0.560394 */
10377 -32256, /* A2 = -0.984375 */
10378 -556, /* B2 = -0.016975 */
10380 556, /* B0 = 0.016975 */
10381 8757, /* A1 = 0.534515 */
10382 -32574, /* A2 = -0.99408 */
10383 8443, /* B2 = 0.25769 */
10384 -2135, /* B1 = -0.130341 */
10385 8443, /* B0 = 0.25769 */
10386 9691, /* A1 = 0.591522 */
10387 -32574, /* A2 = -0.99411 */
10388 15446, /* B2 = 0.471375 */
10389 -4809, /* B1 = -0.293579 */
10390 15446, /* B0 = 0.471375 */
10391 7, /* Internal filter scaling */
10392 159, /* Minimum in-band energy threshold */
10393 21, /* 21/32 in-band to broad-band ratio */
10394 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10397 5076, /* A1 = -0.309875 */
10398 -32304, /* A2 = 0.985840 */
10399 -508, /* B2 = -0.015503 */
10400 0, /* B1 = 0.000000 */
10401 508, /* B0 = 0.015503 */
10402 4646, /* A1 = -0.283600 */
10403 -32605, /* A2 = 0.995026 */
10404 6742, /* B2 = 0.205780 */
10405 -878, /* B1 = -0.053635 */
10406 6742, /* B0 = 0.205780 */
10407 5552, /* A1 = -0.338928 */
10408 -32605, /* A2 = 0.995056 */
10409 23667, /* B2 = 0.722260 */
10410 -4297, /* B1 = -0.262329 */
10411 23667, /* B0 = 0.722260 */
10412 5, /* Internal filter scaling */
10413 159, /* Minimum in-band energy threshold */
10414 21, /* 21/32 in-band to broad-band ratio */
10415 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10418 3569, /* A1 = -0.217865 */
10419 -32292, /* A2 = 0.985504 */
10420 -239, /* B2 = -0.007322 */
10421 0, /* B1 = 0.000000 */
10422 239, /* B0 = 0.007322 */
10423 3117, /* A1 = -0.190277 */
10424 -32603, /* A2 = 0.994965 */
10425 18658, /* B2 = 0.569427 */
10426 -1557, /* B1 = -0.095032 */
10427 18658, /* B0 = 0.569427 */
10428 4054, /* A1 = -0.247437 */
10429 -32603, /* A2 = 0.994965 */
10430 18886, /* B2 = 0.576385 */
10431 -2566, /* B1 = -0.156647 */
10432 18886, /* B0 = 0.576385 */
10433 5, /* Internal filter scaling */
10434 159, /* Minimum in-band energy threshold */
10435 21, /* 21/32 in-band to broad-band ratio */
10436 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10439 static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf)
10441 unsigned short cmd;
10444 if (jf->filter > 3) {
10447 if (ixj_WriteDSPCommand(0x5154 + jf->filter, j)) /* Select Filter */
10451 if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
10457 if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
10460 /* Select the filter (f0 - f3) to use. */
10461 if (ixj_WriteDSPCommand(0x5154 + jf->filter, j))
10464 if (jf->freq < 12 && jf->freq > 3) {
10465 /* Select the frequency for the selected filter. */
10466 if (ixj_WriteDSPCommand(0x5170 + jf->freq, j))
10468 } else if (jf->freq > 11) {
10469 /* We need to load a programmable filter set for undefined */
10470 /* frequencies. So we will point the filter to a programmable set. */
10471 /* Since there are only 4 filters and 4 programmable sets, we will */
10472 /* just point the filter to the same number set and program it for the */
10473 /* frequency we want. */
10474 if (ixj_WriteDSPCommand(0x5170 + jf->filter, j))
10476 if (j->ver.low != 0x12) {
10483 if (ixj_WriteDSPCommand(cmd, j))
10485 for (cnt = 0; cnt < max; cnt++) {
10486 if (ixj_WriteDSPCommand(tone_table[jf->freq - 12][cnt], j))
10490 j->filter_en[jf->filter] = jf->enable;
10494 static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr)
10496 unsigned short cmd;
10498 if (jfr->filter > 3) {
10501 if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j)) /* Select Filter */
10504 if (!jfr->enable) {
10505 if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
10510 if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
10512 /* Select the filter (f0 - f3) to use. */
10513 if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j))
10516 /* We need to load a programmable filter set for undefined */
10517 /* frequencies. So we will point the filter to a programmable set. */
10518 /* Since there are only 4 filters and 4 programmable sets, we will */
10519 /* just point the filter to the same number set and program it for the */
10520 /* frequency we want. */
10521 if (ixj_WriteDSPCommand(0x5170 + jfr->filter, j))
10523 if (j->ver.low != 0x12) {
10530 if (ixj_WriteDSPCommand(cmd, j))
10532 for (cnt = 0; cnt < max; cnt++) {
10533 if (ixj_WriteDSPCommand(jfr->coeff[cnt], j))
10536 j->filter_en[jfr->filter] = jfr->enable;
10540 static int ixj_init_tone(IXJ *j, IXJ_TONE * ti)
10543 unsigned short data;
10556 if(ti->tone_index > 12 && ti->tone_index < 28)
10558 if (ixj_WriteDSPCommand(0x6800 + ti->tone_index, j))
10560 if (ixj_WriteDSPCommand(0x6000 + (ti->gain1 << 4) + ti->gain0, j))
10563 if (ixj_WriteDSPCommand(data, j))
10566 if (ixj_WriteDSPCommand(data, j))