Linux 2.6.21.1
[linux/fpc-iii.git] / drivers / telephony / ixj.c
blob71cb64e41a1bb6721e47c63de681af7baa0655cf
1 /****************************************************************************
2 * ixj.c
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
7 * SmartCABLE
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 * $Log: ixj.c,v $
47 * Revision 4.8 2003/07/09 19:39:00 Daniele Bellucci
48 * Audit some copy_*_user and minor cleanup.
50 * Revision 4.7 2001/08/13 06:19:33 craigs
51 * Added additional changes from Alan Cox and John Anderson for
52 * 2.2 to 2.4 cleanup and bounds checking
54 * Revision 4.6 2001/08/13 01:05:05 craigs
55 * Really fixed PHONE_QUERY_CODEC problem this time
57 * Revision 4.5 2001/08/13 00:11:03 craigs
58 * Fixed problem in handling of PHONE_QUERY_CODEC, thanks to Shane Anderson
60 * Revision 4.4 2001/08/07 07:58:12 craigs
61 * Changed back to three digit version numbers
62 * Added tagbuild target to allow automatic and easy tagging of versions
64 * Revision 4.3 2001/08/07 07:24:47 craigs
65 * Added ixj-ver.h to allow easy configuration management of driver
66 * Added display of version number in /prox/ixj
68 * Revision 4.2 2001/08/06 07:07:19 craigs
69 * Reverted IXJCTL_DSP_TYPE and IXJCTL_DSP_VERSION files to original
70 * behaviour of returning int rather than short *
72 * Revision 4.1 2001/08/05 00:17:37 craigs
73 * More changes for correct PCMCIA installation
74 * Start of changes for backward Linux compatibility
76 * Revision 4.0 2001/08/04 12:33:12 craigs
77 * New version using GNU autoconf
79 * Revision 3.105 2001/07/20 23:14:32 eokerson
80 * More work on CallerID generation when using ring cadences.
82 * Revision 3.104 2001/07/06 01:33:55 eokerson
83 * Some bugfixes from Robert Vojta <vojta@ipex.cz> and a few mods to the Makefile.
85 * Revision 3.103 2001/07/05 19:20:16 eokerson
86 * Updated HOWTO
87 * Changed mic gain to 30dB on Internet LineJACK mic/speaker port.
89 * Revision 3.102 2001/07/03 23:51:21 eokerson
90 * Un-mute mic on Internet LineJACK when in speakerphone mode.
92 * Revision 3.101 2001/07/02 19:26:56 eokerson
93 * Removed initialiazation of ixjdebug and ixj_convert_loaded so they will go in the .bss instead of the .data
95 * Revision 3.100 2001/07/02 19:18:27 eokerson
96 * Changed driver to make dynamic allocation possible. We now pass IXJ * between functions instead of array indexes.
97 * Fixed the way the POTS and PSTN ports interact during a PSTN call to allow local answering.
98 * Fixed speaker mode on Internet LineJACK.
100 * Revision 3.99 2001/05/09 14:11:16 eokerson
101 * Fixed kmalloc error in ixj_build_filter_cadence. Thanks David Chan <cat@waulogy.stanford.edu>.
103 * Revision 3.98 2001/05/08 19:55:33 eokerson
104 * Fixed POTS hookstate detection while it is connected to PSTN port.
106 * Revision 3.97 2001/05/08 00:01:04 eokerson
107 * Fixed kernel oops when sending caller ID data.
109 * Revision 3.96 2001/05/04 23:09:30 eokerson
110 * Now uses one kernel timer for each card, instead of one for the entire driver.
112 * Revision 3.95 2001/04/25 22:06:47 eokerson
113 * Fixed squawking at beginning of some G.723.1 calls.
115 * Revision 3.94 2001/04/03 23:42:00 eokerson
116 * Added linear volume ioctls
117 * Added raw filter load ioctl
119 * Revision 3.93 2001/02/27 01:00:06 eokerson
120 * Fixed blocking in CallerID.
121 * Reduced size of ixj structure for smaller driver footprint.
123 * Revision 3.92 2001/02/20 22:02:59 eokerson
124 * Fixed isapnp and pcmcia module compatibility for 2.4.x kernels.
125 * Improved PSTN ring detection.
126 * Fixed wink generation on POTS ports.
128 * Revision 3.91 2001/02/13 00:55:44 eokerson
129 * Turn AEC back on after changing frame sizes.
131 * Revision 3.90 2001/02/12 16:42:00 eokerson
132 * Added ALAW codec, thanks to Fabio Ferrari for the table based converters to make ALAW from ULAW.
134 * Revision 3.89 2001/02/12 15:41:16 eokerson
135 * Fix from Artis Kugevics - Tone gains were not being set correctly.
137 * Revision 3.88 2001/02/05 23:25:42 eokerson
138 * Fixed lockup bugs with deregister.
140 * Revision 3.87 2001/01/29 21:00:39 eokerson
141 * Fix from Fabio Ferrari <fabio.ferrari@digitro.com.br> to properly handle EAGAIN and EINTR during non-blocking write.
142 * Updated copyright date.
144 * Revision 3.86 2001/01/23 23:53:46 eokerson
145 * Fixes to G.729 compatibility.
147 * Revision 3.85 2001/01/23 21:30:36 eokerson
148 * Added verbage about cards supported.
149 * Removed commands that put the card in low power mode at some times that it should not be in low power mode.
151 * Revision 3.84 2001/01/22 23:32:10 eokerson
152 * Some bugfixes from David Huggins-Daines, <dhd@cepstral.com> and other cleanups.
154 * Revision 3.83 2001/01/19 14:51:41 eokerson
155 * Fixed ixj_WriteDSPCommand to decrement usage counter when command fails.
157 * Revision 3.82 2001/01/19 00:34:49 eokerson
158 * Added verbosity to write overlap errors.
160 * Revision 3.81 2001/01/18 23:56:54 eokerson
161 * Fixed PSTN line test functions.
163 * Revision 3.80 2001/01/18 22:29:27 eokerson
164 * Updated AEC/AGC values for different cards.
166 * Revision 3.79 2001/01/17 02:58:54 eokerson
167 * Fixed AEC reset after Caller ID.
168 * Fixed Codec lockup after Caller ID on Call Waiting when not using 30ms frames.
170 * Revision 3.78 2001/01/16 19:43:09 eokerson
171 * Added support for Linux 2.4.x kernels.
173 * Revision 3.77 2001/01/09 04:00:52 eokerson
174 * Linetest will now test the line, even if it has previously succeded.
176 * Revision 3.76 2001/01/08 19:27:00 eokerson
177 * Fixed problem with standard cable on Internet PhoneCARD.
179 * Revision 3.75 2000/12/22 16:52:14 eokerson
180 * Modified to allow hookstate detection on the POTS port when the PSTN port is selected.
182 * Revision 3.74 2000/12/08 22:41:50 eokerson
183 * Added capability for G729B.
185 * Revision 3.73 2000/12/07 23:35:16 eokerson
186 * Added capability to have different ring pattern before CallerID data.
187 * Added hookstate checks in CallerID routines to stop FSK.
189 * Revision 3.72 2000/12/06 19:31:31 eokerson
190 * Modified signal behavior to only send one signal per event.
192 * Revision 3.71 2000/12/06 03:23:08 eokerson
193 * Fixed CallerID on Call Waiting.
195 * Revision 3.70 2000/12/04 21:29:37 eokerson
196 * Added checking to Smart Cable gain functions.
198 * Revision 3.69 2000/12/04 21:05:20 eokerson
199 * Changed ixjdebug levels.
200 * Added ioctls to change gains in Internet Phone CARD Smart Cable.
202 * Revision 3.68 2000/12/04 00:17:21 craigs
203 * Changed mixer voice gain to +6dB rather than 0dB
205 * Revision 3.67 2000/11/30 21:25:51 eokerson
206 * Fixed write signal errors.
208 * Revision 3.66 2000/11/29 22:42:44 eokerson
209 * Fixed PSTN ring detect problems.
211 * Revision 3.65 2000/11/29 07:31:55 craigs
212 * Added new 425Hz filter co-efficients
213 * Added card-specific DTMF prescaler initialisation
215 * Revision 3.64 2000/11/28 14:03:32 craigs
216 * Changed certain mixer initialisations to be 0dB rather than 12dB
217 * Added additional information to /proc/ixj
219 * Revision 3.63 2000/11/28 11:38:41 craigs
220 * Added display of AEC modes in AUTO and AGC mode
222 * Revision 3.62 2000/11/28 04:05:44 eokerson
223 * Improved PSTN ring detection routine.
225 * Revision 3.61 2000/11/27 21:53:12 eokerson
226 * Fixed flash detection.
228 * Revision 3.60 2000/11/27 15:57:29 eokerson
229 * More work on G.729 load routines.
231 * Revision 3.59 2000/11/25 21:55:12 eokerson
232 * Fixed errors in G.729 load routine.
234 * Revision 3.58 2000/11/25 04:08:29 eokerson
235 * Added board locks around G.729 and TS85 load routines.
237 * Revision 3.57 2000/11/24 05:35:17 craigs
238 * Added ability to retrieve mixer values on LineJACK
239 * Added complete initialisation of all mixer values at startup
240 * Fixed spelling mistake
242 * Revision 3.56 2000/11/23 02:52:11 robertj
243 * Added cvs change log keyword.
244 * Fixed bug in capabilities list when using G.729 module.
248 #include "ixj-ver.h"
250 #define PERFMON_STATS
251 #define IXJDEBUG 0
252 #define MAXRINGS 5
254 #include <linux/module.h>
256 #include <linux/init.h>
257 #include <linux/sched.h>
258 #include <linux/kernel.h> /* printk() */
259 #include <linux/fs.h> /* everything... */
260 #include <linux/errno.h> /* error codes */
261 #include <linux/slab.h>
262 #include <linux/mm.h>
263 #include <linux/ioport.h>
264 #include <linux/interrupt.h>
265 #include <linux/proc_fs.h>
266 #include <linux/poll.h>
267 #include <linux/timer.h>
268 #include <linux/delay.h>
269 #include <linux/pci.h>
271 #include <asm/io.h>
272 #include <asm/uaccess.h>
274 #include <linux/isapnp.h>
276 #include "ixj.h"
278 #define TYPE(inode) (iminor(inode) >> 4)
279 #define NUM(inode) (iminor(inode) & 0xf)
281 static int ixjdebug;
282 static int hertz = HZ;
283 static int samplerate = 100;
285 module_param(ixjdebug, int, 0);
287 static struct pci_device_id ixj_pci_tbl[] __devinitdata = {
288 { PCI_VENDOR_ID_QUICKNET, PCI_DEVICE_ID_QUICKNET_XJ,
289 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
293 MODULE_DEVICE_TABLE(pci, ixj_pci_tbl);
295 /************************************************************************
297 * ixjdebug meanings are now bit mapped instead of level based
298 * Values can be or'ed together to turn on multiple messages
300 * bit 0 (0x0001) = any failure
301 * bit 1 (0x0002) = general messages
302 * bit 2 (0x0004) = POTS ringing related
303 * bit 3 (0x0008) = PSTN events
304 * bit 4 (0x0010) = PSTN Cadence state details
305 * bit 5 (0x0020) = Tone detection triggers
306 * bit 6 (0x0040) = Tone detection cadence details
307 * bit 7 (0x0080) = ioctl tracking
308 * bit 8 (0x0100) = signal tracking
309 * bit 9 (0x0200) = CallerID generation details
311 ************************************************************************/
313 #ifdef IXJ_DYN_ALLOC
315 static IXJ *ixj[IXJMAX];
316 #define get_ixj(b) ixj[(b)]
319 * Allocate a free IXJ device
322 static IXJ *ixj_alloc()
324 for(cnt=0; cnt<IXJMAX; cnt++)
326 if(ixj[cnt] == NULL || !ixj[cnt]->DSPbase)
328 j = kmalloc(sizeof(IXJ), GFP_KERNEL);
329 if (j == NULL)
330 return NULL;
331 ixj[cnt] = j;
332 return j;
335 return NULL;
338 static void ixj_fsk_free(IXJ *j)
340 kfree(j->fskdata);
341 j->fskdata = NULL;
344 static void ixj_fsk_alloc(IXJ *j)
346 if(!j->fskdata) {
347 j->fskdata = kmalloc(8000, GFP_KERNEL);
348 if (!j->fskdata) {
349 if(ixjdebug & 0x0200) {
350 printk("IXJ phone%d - allocate failed\n", j->board);
352 return;
353 } else {
354 j->fsksize = 8000;
355 if(ixjdebug & 0x0200) {
356 printk("IXJ phone%d - allocate succeded\n", j->board);
362 #else
364 static IXJ ixj[IXJMAX];
365 #define get_ixj(b) (&ixj[(b)])
368 * Allocate a free IXJ device
371 static IXJ *ixj_alloc(void)
373 int cnt;
374 for(cnt=0; cnt<IXJMAX; cnt++) {
375 if(!ixj[cnt].DSPbase)
376 return &ixj[cnt];
378 return NULL;
381 static inline void ixj_fsk_free(IXJ *j) {;}
383 static inline void ixj_fsk_alloc(IXJ *j)
385 j->fsksize = 8000;
388 #endif
390 #ifdef PERFMON_STATS
391 #define ixj_perfmon(x) ((x)++)
392 #else
393 #define ixj_perfmon(x) do { } while(0)
394 #endif
396 static int ixj_convert_loaded;
398 static int ixj_WriteDSPCommand(unsigned short, IXJ *j);
400 /************************************************************************
402 * These are function definitions to allow external modules to register
403 * enhanced functionality call backs.
405 ************************************************************************/
407 static int Stub(IXJ * J, unsigned long arg)
409 return 0;
412 static IXJ_REGFUNC ixj_PreRead = &Stub;
413 static IXJ_REGFUNC ixj_PostRead = &Stub;
414 static IXJ_REGFUNC ixj_PreWrite = &Stub;
415 static IXJ_REGFUNC ixj_PostWrite = &Stub;
417 static void ixj_read_frame(IXJ *j);
418 static void ixj_write_frame(IXJ *j);
419 static void ixj_init_timer(IXJ *j);
420 static void ixj_add_timer(IXJ * j);
421 static void ixj_timeout(unsigned long ptr);
422 static int read_filters(IXJ *j);
423 static int LineMonitor(IXJ *j);
424 static int ixj_fasync(int fd, struct file *, int mode);
425 static int ixj_set_port(IXJ *j, int arg);
426 static int ixj_set_pots(IXJ *j, int arg);
427 static int ixj_hookstate(IXJ *j);
428 static int ixj_record_start(IXJ *j);
429 static void ixj_record_stop(IXJ *j);
430 static void set_rec_volume(IXJ *j, int volume);
431 static int get_rec_volume(IXJ *j);
432 static int set_rec_codec(IXJ *j, int rate);
433 static void ixj_vad(IXJ *j, int arg);
434 static int ixj_play_start(IXJ *j);
435 static void ixj_play_stop(IXJ *j);
436 static int ixj_set_tone_on(unsigned short arg, IXJ *j);
437 static int ixj_set_tone_off(unsigned short, IXJ *j);
438 static int ixj_play_tone(IXJ *j, char tone);
439 static void ixj_aec_start(IXJ *j, int level);
440 static int idle(IXJ *j);
441 static void ixj_ring_on(IXJ *j);
442 static void ixj_ring_off(IXJ *j);
443 static void aec_stop(IXJ *j);
444 static void ixj_ringback(IXJ *j);
445 static void ixj_busytone(IXJ *j);
446 static void ixj_dialtone(IXJ *j);
447 static void ixj_cpt_stop(IXJ *j);
448 static char daa_int_read(IXJ *j);
449 static char daa_CR_read(IXJ *j, int cr);
450 static int daa_set_mode(IXJ *j, int mode);
451 static int ixj_linetest(IXJ *j);
452 static int ixj_daa_write(IXJ *j);
453 static int ixj_daa_cid_read(IXJ *j);
454 static void DAA_Coeff_US(IXJ *j);
455 static void DAA_Coeff_UK(IXJ *j);
456 static void DAA_Coeff_France(IXJ *j);
457 static void DAA_Coeff_Germany(IXJ *j);
458 static void DAA_Coeff_Australia(IXJ *j);
459 static void DAA_Coeff_Japan(IXJ *j);
460 static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf);
461 static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr);
462 static int ixj_init_tone(IXJ *j, IXJ_TONE * ti);
463 static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp);
464 static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp);
465 /* Serial Control Interface funtions */
466 static int SCI_Control(IXJ *j, int control);
467 static int SCI_Prepare(IXJ *j);
468 static int SCI_WaitHighSCI(IXJ *j);
469 static int SCI_WaitLowSCI(IXJ *j);
470 static DWORD PCIEE_GetSerialNumber(WORD wAddress);
471 static int ixj_PCcontrol_wait(IXJ *j);
472 static void ixj_pre_cid(IXJ *j);
473 static void ixj_write_cid(IXJ *j);
474 static void ixj_write_cid_bit(IXJ *j, int bit);
475 static int set_base_frame(IXJ *j, int size);
476 static int set_play_codec(IXJ *j, int rate);
477 static void set_rec_depth(IXJ *j, int depth);
478 static int ixj_mixer(long val, IXJ *j);
480 /************************************************************************
481 CT8020/CT8021 Host Programmers Model
482 Host address Function Access
483 DSPbase +
484 0-1 Aux Software Status Register (reserved) Read Only
485 2-3 Software Status Register Read Only
486 4-5 Aux Software Control Register (reserved) Read Write
487 6-7 Software Control Register Read Write
488 8-9 Hardware Status Register Read Only
489 A-B Hardware Control Register Read Write
490 C-D Host Transmit (Write) Data Buffer Access Port (buffer input)Write Only
491 E-F Host Recieve (Read) Data Buffer Access Port (buffer input) Read Only
492 ************************************************************************/
494 static inline void ixj_read_HSR(IXJ *j)
496 j->hsr.bytes.low = inb_p(j->DSPbase + 8);
497 j->hsr.bytes.high = inb_p(j->DSPbase + 9);
500 static inline int IsControlReady(IXJ *j)
502 ixj_read_HSR(j);
503 return j->hsr.bits.controlrdy ? 1 : 0;
506 static inline int IsPCControlReady(IXJ *j)
508 j->pccr1.byte = inb_p(j->XILINXbase + 3);
509 return j->pccr1.bits.crr ? 1 : 0;
512 static inline int IsStatusReady(IXJ *j)
514 ixj_read_HSR(j);
515 return j->hsr.bits.statusrdy ? 1 : 0;
518 static inline int IsRxReady(IXJ *j)
520 ixj_read_HSR(j);
521 ixj_perfmon(j->rxreadycheck);
522 return j->hsr.bits.rxrdy ? 1 : 0;
525 static inline int IsTxReady(IXJ *j)
527 ixj_read_HSR(j);
528 ixj_perfmon(j->txreadycheck);
529 return j->hsr.bits.txrdy ? 1 : 0;
532 static inline void set_play_volume(IXJ *j, int volume)
534 if (ixjdebug & 0x0002)
535 printk(KERN_INFO "IXJ: /dev/phone%d Setting Play Volume to 0x%4.4x\n", j->board, volume);
536 ixj_WriteDSPCommand(0xCF02, j);
537 ixj_WriteDSPCommand(volume, j);
540 static int set_play_volume_linear(IXJ *j, int volume)
542 int newvolume, dspplaymax;
544 if (ixjdebug & 0x0002)
545 printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Play Volume to 0x%4.4x\n", j->board, volume);
546 if(volume > 100 || volume < 0) {
547 return -1;
550 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
551 switch (j->cardtype) {
552 case QTI_PHONEJACK:
553 dspplaymax = 0x380;
554 break;
555 case QTI_LINEJACK:
556 if(j->port == PORT_PSTN) {
557 dspplaymax = 0x48;
558 } else {
559 dspplaymax = 0x100;
561 break;
562 case QTI_PHONEJACK_LITE:
563 dspplaymax = 0x380;
564 break;
565 case QTI_PHONEJACK_PCI:
566 dspplaymax = 0x6C;
567 break;
568 case QTI_PHONECARD:
569 dspplaymax = 0x50;
570 break;
571 default:
572 return -1;
574 newvolume = (dspplaymax * volume) / 100;
575 set_play_volume(j, newvolume);
576 return 0;
579 static inline void set_play_depth(IXJ *j, int depth)
581 if (depth > 60)
582 depth = 60;
583 if (depth < 0)
584 depth = 0;
585 ixj_WriteDSPCommand(0x5280 + depth, j);
588 static inline int get_play_volume(IXJ *j)
590 ixj_WriteDSPCommand(0xCF00, j);
591 return j->ssr.high << 8 | j->ssr.low;
594 static int get_play_volume_linear(IXJ *j)
596 int volume, newvolume, dspplaymax;
598 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
599 switch (j->cardtype) {
600 case QTI_PHONEJACK:
601 dspplaymax = 0x380;
602 break;
603 case QTI_LINEJACK:
604 if(j->port == PORT_PSTN) {
605 dspplaymax = 0x48;
606 } else {
607 dspplaymax = 0x100;
609 break;
610 case QTI_PHONEJACK_LITE:
611 dspplaymax = 0x380;
612 break;
613 case QTI_PHONEJACK_PCI:
614 dspplaymax = 0x6C;
615 break;
616 case QTI_PHONECARD:
617 dspplaymax = 100;
618 break;
619 default:
620 return -1;
622 volume = get_play_volume(j);
623 newvolume = (volume * 100) / dspplaymax;
624 if(newvolume > 100)
625 newvolume = 100;
626 return newvolume;
629 static inline BYTE SLIC_GetState(IXJ *j)
631 if (j->cardtype == QTI_PHONECARD) {
632 j->pccr1.byte = 0;
633 j->psccr.bits.dev = 3;
634 j->psccr.bits.rw = 1;
635 outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
636 ixj_PCcontrol_wait(j);
637 j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
638 ixj_PCcontrol_wait(j);
639 if (j->pslic.bits.powerdown)
640 return PLD_SLIC_STATE_OC;
641 else if (!j->pslic.bits.ring0 && !j->pslic.bits.ring1)
642 return PLD_SLIC_STATE_ACTIVE;
643 else
644 return PLD_SLIC_STATE_RINGING;
645 } else {
646 j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
648 return j->pld_slicr.bits.state;
651 static bool SLIC_SetState(BYTE byState, IXJ *j)
653 bool fRetVal = false;
655 if (j->cardtype == QTI_PHONECARD) {
656 if (j->flags.pcmciasct) {
657 switch (byState) {
658 case PLD_SLIC_STATE_TIPOPEN:
659 case PLD_SLIC_STATE_OC:
660 j->pslic.bits.powerdown = 1;
661 j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
662 fRetVal = true;
663 break;
664 case PLD_SLIC_STATE_RINGING:
665 if (j->readers || j->writers) {
666 j->pslic.bits.powerdown = 0;
667 j->pslic.bits.ring0 = 1;
668 j->pslic.bits.ring1 = 0;
669 fRetVal = true;
671 break;
672 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
674 case PLD_SLIC_STATE_STANDBY:
675 case PLD_SLIC_STATE_ACTIVE:
676 if (j->readers || j->writers) {
677 j->pslic.bits.powerdown = 0;
678 } else {
679 j->pslic.bits.powerdown = 1;
681 j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
682 fRetVal = true;
683 break;
684 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
686 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
688 default:
689 fRetVal = false;
690 break;
692 j->psccr.bits.dev = 3;
693 j->psccr.bits.rw = 0;
694 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
695 ixj_PCcontrol_wait(j);
697 } else {
698 /* Set the C1, C2, C3 & B2EN signals. */
699 switch (byState) {
700 case PLD_SLIC_STATE_OC:
701 j->pld_slicw.bits.c1 = 0;
702 j->pld_slicw.bits.c2 = 0;
703 j->pld_slicw.bits.c3 = 0;
704 j->pld_slicw.bits.b2en = 0;
705 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
706 fRetVal = true;
707 break;
708 case PLD_SLIC_STATE_RINGING:
709 j->pld_slicw.bits.c1 = 1;
710 j->pld_slicw.bits.c2 = 0;
711 j->pld_slicw.bits.c3 = 0;
712 j->pld_slicw.bits.b2en = 1;
713 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
714 fRetVal = true;
715 break;
716 case PLD_SLIC_STATE_ACTIVE:
717 j->pld_slicw.bits.c1 = 0;
718 j->pld_slicw.bits.c2 = 1;
719 j->pld_slicw.bits.c3 = 0;
720 j->pld_slicw.bits.b2en = 0;
721 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
722 fRetVal = true;
723 break;
724 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
726 j->pld_slicw.bits.c1 = 1;
727 j->pld_slicw.bits.c2 = 1;
728 j->pld_slicw.bits.c3 = 0;
729 j->pld_slicw.bits.b2en = 0;
730 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
731 fRetVal = true;
732 break;
733 case PLD_SLIC_STATE_TIPOPEN:
734 j->pld_slicw.bits.c1 = 0;
735 j->pld_slicw.bits.c2 = 0;
736 j->pld_slicw.bits.c3 = 1;
737 j->pld_slicw.bits.b2en = 0;
738 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
739 fRetVal = true;
740 break;
741 case PLD_SLIC_STATE_STANDBY:
742 j->pld_slicw.bits.c1 = 1;
743 j->pld_slicw.bits.c2 = 0;
744 j->pld_slicw.bits.c3 = 1;
745 j->pld_slicw.bits.b2en = 1;
746 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
747 fRetVal = true;
748 break;
749 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
751 j->pld_slicw.bits.c1 = 0;
752 j->pld_slicw.bits.c2 = 1;
753 j->pld_slicw.bits.c3 = 1;
754 j->pld_slicw.bits.b2en = 0;
755 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
756 fRetVal = true;
757 break;
758 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
760 j->pld_slicw.bits.c1 = 1;
761 j->pld_slicw.bits.c2 = 1;
762 j->pld_slicw.bits.c3 = 1;
763 j->pld_slicw.bits.b2en = 0;
764 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
765 fRetVal = true;
766 break;
767 default:
768 fRetVal = false;
769 break;
773 return fRetVal;
776 static int ixj_wink(IXJ *j)
778 BYTE slicnow;
780 slicnow = SLIC_GetState(j);
782 j->pots_winkstart = jiffies;
783 SLIC_SetState(PLD_SLIC_STATE_OC, j);
785 msleep(jiffies_to_msecs(j->winktime));
787 SLIC_SetState(slicnow, j);
788 return 0;
791 static void ixj_init_timer(IXJ *j)
793 init_timer(&j->timer);
794 j->timer.function = ixj_timeout;
795 j->timer.data = (unsigned long)j;
798 static void ixj_add_timer(IXJ *j)
800 j->timer.expires = jiffies + (hertz / samplerate);
801 add_timer(&j->timer);
804 static void ixj_tone_timeout(IXJ *j)
806 IXJ_TONE ti;
808 j->tone_state++;
809 if (j->tone_state == 3) {
810 j->tone_state = 0;
811 if (j->cadence_t) {
812 j->tone_cadence_state++;
813 if (j->tone_cadence_state >= j->cadence_t->elements_used) {
814 switch (j->cadence_t->termination) {
815 case PLAY_ONCE:
816 ixj_cpt_stop(j);
817 break;
818 case REPEAT_LAST_ELEMENT:
819 j->tone_cadence_state--;
820 ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
821 break;
822 case REPEAT_ALL:
823 j->tone_cadence_state = 0;
824 if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
825 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
826 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
827 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
828 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
829 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
830 ixj_init_tone(j, &ti);
832 ixj_set_tone_on(j->cadence_t->ce[0].tone_on_time, j);
833 ixj_set_tone_off(j->cadence_t->ce[0].tone_off_time, j);
834 ixj_play_tone(j, j->cadence_t->ce[0].index);
835 break;
837 } else {
838 if (j->cadence_t->ce[j->tone_cadence_state].gain0) {
839 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
840 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
841 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
842 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
843 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
844 ixj_init_tone(j, &ti);
846 ixj_set_tone_on(j->cadence_t->ce[j->tone_cadence_state].tone_on_time, j);
847 ixj_set_tone_off(j->cadence_t->ce[j->tone_cadence_state].tone_off_time, j);
848 ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
854 static inline void ixj_kill_fasync(IXJ *j, IXJ_SIGEVENT event, int dir)
856 if(j->ixj_signals[event]) {
857 if(ixjdebug & 0x0100)
858 printk("Sending signal for event %d\n", event);
859 /* Send apps notice of change */
860 /* see config.h for macro definition */
861 kill_fasync(&(j->async_queue), j->ixj_signals[event], dir);
865 static void ixj_pstn_state(IXJ *j)
867 int var;
868 union XOPXR0 XR0, daaint;
870 var = 10;
872 XR0.reg = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg;
873 daaint.reg = 0;
874 XR0.bitreg.RMR = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
876 j->pld_scrr.byte = inb_p(j->XILINXbase);
877 if (j->pld_scrr.bits.daaflag) {
878 daa_int_read(j);
879 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.RING) {
880 if(time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) {
881 daaint.bitreg.RING = 1;
882 if(ixjdebug & 0x0008) {
883 printk(KERN_INFO "IXJ DAA Ring Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
885 } else {
886 daa_set_mode(j, SOP_PU_RESET);
889 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Caller_ID) {
890 daaint.bitreg.Caller_ID = 1;
891 j->pstn_cid_intr = 1;
892 j->pstn_cid_received = jiffies;
893 if(ixjdebug & 0x0008) {
894 printk(KERN_INFO "IXJ DAA Caller_ID Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
897 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Cadence) {
898 daaint.bitreg.Cadence = 1;
899 if(ixjdebug & 0x0008) {
900 printk(KERN_INFO "IXJ DAA Cadence Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
903 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK != XR0.bitreg.VDD_OK) {
904 daaint.bitreg.VDD_OK = 1;
905 daaint.bitreg.SI_0 = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK;
908 daa_CR_read(j, 1);
909 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)) {
910 daaint.bitreg.RMR = 1;
911 daaint.bitreg.SI_1 = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
912 if(ixjdebug & 0x0008) {
913 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);
915 j->pstn_prev_rmr = j->pstn_last_rmr;
916 j->pstn_last_rmr = jiffies;
918 switch(j->daa_mode) {
919 case SOP_PU_SLEEP:
920 if (daaint.bitreg.RING) {
921 if (!j->flags.pstn_ringing) {
922 if (j->daa_mode != SOP_PU_RINGING) {
923 j->pstn_ring_int = jiffies;
924 daa_set_mode(j, SOP_PU_RINGING);
928 break;
929 case SOP_PU_RINGING:
930 if (daaint.bitreg.RMR) {
931 if (ixjdebug & 0x0008) {
932 printk(KERN_INFO "IXJ Ring Cadence a state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
934 if (daaint.bitreg.SI_1) { /* Rising edge of RMR */
935 j->flags.pstn_rmr = 1;
936 j->pstn_ring_start = jiffies;
937 j->pstn_ring_stop = 0;
938 j->ex.bits.pstn_ring = 0;
939 if (j->cadence_f[4].state == 0) {
940 j->cadence_f[4].state = 1;
941 j->cadence_f[4].on1min = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 - var)) / 10000);
942 j->cadence_f[4].on1dot = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100)) / 10000);
943 j->cadence_f[4].on1max = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 + var)) / 10000);
944 } else if (j->cadence_f[4].state == 2) {
945 if((time_after(jiffies, j->cadence_f[4].off1min) &&
946 time_before(jiffies, j->cadence_f[4].off1max))) {
947 if (j->cadence_f[4].on2) {
948 j->cadence_f[4].state = 3;
949 j->cadence_f[4].on2min = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 - var)) / 10000));
950 j->cadence_f[4].on2dot = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100)) / 10000));
951 j->cadence_f[4].on2max = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 + var)) / 10000));
952 } else {
953 j->cadence_f[4].state = 7;
955 } else {
956 if (ixjdebug & 0x0008) {
957 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
958 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
959 j->cadence_f[4].off1);
961 j->cadence_f[4].state = 0;
963 } else if (j->cadence_f[4].state == 4) {
964 if((time_after(jiffies, j->cadence_f[4].off2min) &&
965 time_before(jiffies, j->cadence_f[4].off2max))) {
966 if (j->cadence_f[4].on3) {
967 j->cadence_f[4].state = 5;
968 j->cadence_f[4].on3min = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 - var)) / 10000));
969 j->cadence_f[4].on3dot = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100)) / 10000));
970 j->cadence_f[4].on3max = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 + var)) / 10000));
971 } else {
972 j->cadence_f[4].state = 7;
974 } else {
975 if (ixjdebug & 0x0008) {
976 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
977 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
978 j->cadence_f[4].off2);
980 j->cadence_f[4].state = 0;
982 } else if (j->cadence_f[4].state == 6) {
983 if((time_after(jiffies, j->cadence_f[4].off3min) &&
984 time_before(jiffies, j->cadence_f[4].off3max))) {
985 j->cadence_f[4].state = 7;
986 } else {
987 if (ixjdebug & 0x0008) {
988 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
989 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
990 j->cadence_f[4].off3);
992 j->cadence_f[4].state = 0;
994 } else {
995 j->cadence_f[4].state = 0;
997 } else { /* Falling edge of RMR */
998 j->pstn_ring_start = 0;
999 j->pstn_ring_stop = jiffies;
1000 if (j->cadence_f[4].state == 1) {
1001 if(!j->cadence_f[4].on1) {
1002 j->cadence_f[4].state = 7;
1003 } else if((time_after(jiffies, j->cadence_f[4].on1min) &&
1004 time_before(jiffies, j->cadence_f[4].on1max))) {
1005 if (j->cadence_f[4].off1) {
1006 j->cadence_f[4].state = 2;
1007 j->cadence_f[4].off1min = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 - var)) / 10000));
1008 j->cadence_f[4].off1dot = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100)) / 10000));
1009 j->cadence_f[4].off1max = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 + var)) / 10000));
1010 } else {
1011 j->cadence_f[4].state = 7;
1013 } else {
1014 if (ixjdebug & 0x0008) {
1015 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1016 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1017 j->cadence_f[4].on1);
1019 j->cadence_f[4].state = 0;
1021 } else if (j->cadence_f[4].state == 3) {
1022 if((time_after(jiffies, j->cadence_f[4].on2min) &&
1023 time_before(jiffies, j->cadence_f[4].on2max))) {
1024 if (j->cadence_f[4].off2) {
1025 j->cadence_f[4].state = 4;
1026 j->cadence_f[4].off2min = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 - var)) / 10000));
1027 j->cadence_f[4].off2dot = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100)) / 10000));
1028 j->cadence_f[4].off2max = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 + var)) / 10000));
1029 } else {
1030 j->cadence_f[4].state = 7;
1032 } else {
1033 if (ixjdebug & 0x0008) {
1034 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1035 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1036 j->cadence_f[4].on2);
1038 j->cadence_f[4].state = 0;
1040 } else if (j->cadence_f[4].state == 5) {
1041 if((time_after(jiffies, j->cadence_f[4].on3min) &&
1042 time_before(jiffies, j->cadence_f[4].on3max))) {
1043 if (j->cadence_f[4].off3) {
1044 j->cadence_f[4].state = 6;
1045 j->cadence_f[4].off3min = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 - var)) / 10000));
1046 j->cadence_f[4].off3dot = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100)) / 10000));
1047 j->cadence_f[4].off3max = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 + var)) / 10000));
1048 } else {
1049 j->cadence_f[4].state = 7;
1051 } else {
1052 j->cadence_f[4].state = 0;
1054 } else {
1055 if (ixjdebug & 0x0008) {
1056 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1057 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1058 j->cadence_f[4].on3);
1060 j->cadence_f[4].state = 0;
1063 if (ixjdebug & 0x0010) {
1064 printk(KERN_INFO "IXJ Ring Cadence b state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
1066 if (ixjdebug & 0x0010) {
1067 switch(j->cadence_f[4].state) {
1068 case 1:
1069 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1070 j->cadence_f[4].on1, j->cadence_f[4].on1min, j->cadence_f[4].on1dot, j->cadence_f[4].on1max);
1071 break;
1072 case 2:
1073 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1074 j->cadence_f[4].off1, j->cadence_f[4].off1min, j->cadence_f[4].off1dot, j->cadence_f[4].off1max);
1075 break;
1076 case 3:
1077 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1078 j->cadence_f[4].on2, j->cadence_f[4].on2min, j->cadence_f[4].on2dot, j->cadence_f[4].on2max);
1079 break;
1080 case 4:
1081 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1082 j->cadence_f[4].off2, j->cadence_f[4].off2min, j->cadence_f[4].off2dot, j->cadence_f[4].off2max);
1083 break;
1084 case 5:
1085 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1086 j->cadence_f[4].on3, j->cadence_f[4].on3min, j->cadence_f[4].on3dot, j->cadence_f[4].on3max);
1087 break;
1088 case 6:
1089 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1090 j->cadence_f[4].off3, j->cadence_f[4].off3min, j->cadence_f[4].off3dot, j->cadence_f[4].off3max);
1091 break;
1095 if (j->cadence_f[4].state == 7) {
1096 j->cadence_f[4].state = 0;
1097 j->pstn_ring_stop = jiffies;
1098 j->ex.bits.pstn_ring = 1;
1099 ixj_kill_fasync(j, SIG_PSTN_RING, POLL_IN);
1100 if(ixjdebug & 0x0008) {
1101 printk(KERN_INFO "IXJ Ring int set /dev/phone%d at %ld\n", j->board, jiffies);
1104 if((j->pstn_ring_int != 0 && time_after(jiffies, j->pstn_ring_int + (hertz * 5)) && !j->flags.pstn_rmr) ||
1105 (j->pstn_ring_stop != 0 && time_after(jiffies, j->pstn_ring_stop + (hertz * 5)))) {
1106 if(ixjdebug & 0x0008) {
1107 printk("IXJ DAA no ring in 5 seconds /dev/phone%d at %ld\n", j->board, jiffies);
1108 printk("IXJ DAA pstn ring int /dev/phone%d at %ld\n", j->board, j->pstn_ring_int);
1109 printk("IXJ DAA pstn ring stop /dev/phone%d at %ld\n", j->board, j->pstn_ring_stop);
1111 j->pstn_ring_stop = j->pstn_ring_int = 0;
1112 daa_set_mode(j, SOP_PU_SLEEP);
1114 outb_p(j->pld_scrw.byte, j->XILINXbase);
1115 if (j->pstn_cid_intr && time_after(jiffies, j->pstn_cid_received + hertz)) {
1116 ixj_daa_cid_read(j);
1117 j->ex.bits.caller_id = 1;
1118 ixj_kill_fasync(j, SIG_CALLER_ID, POLL_IN);
1119 j->pstn_cid_intr = 0;
1121 if (daaint.bitreg.Cadence) {
1122 if(ixjdebug & 0x0008) {
1123 printk("IXJ DAA Cadence interrupt going to sleep /dev/phone%d\n", j->board);
1125 daa_set_mode(j, SOP_PU_SLEEP);
1126 j->ex.bits.pstn_ring = 0;
1128 break;
1129 case SOP_PU_CONVERSATION:
1130 if (daaint.bitreg.VDD_OK) {
1131 if(!daaint.bitreg.SI_0) {
1132 if (!j->pstn_winkstart) {
1133 if(ixjdebug & 0x0008) {
1134 printk("IXJ DAA possible wink /dev/phone%d %ld\n", j->board, jiffies);
1136 j->pstn_winkstart = jiffies;
1138 } else {
1139 if (j->pstn_winkstart) {
1140 if(ixjdebug & 0x0008) {
1141 printk("IXJ DAA possible wink end /dev/phone%d %ld\n", j->board, jiffies);
1143 j->pstn_winkstart = 0;
1147 if (j->pstn_winkstart && time_after(jiffies, j->pstn_winkstart + ((hertz * j->winktime) / 1000))) {
1148 if(ixjdebug & 0x0008) {
1149 printk("IXJ DAA wink detected going to sleep /dev/phone%d %ld\n", j->board, jiffies);
1151 daa_set_mode(j, SOP_PU_SLEEP);
1152 j->pstn_winkstart = 0;
1153 j->ex.bits.pstn_wink = 1;
1154 ixj_kill_fasync(j, SIG_PSTN_WINK, POLL_IN);
1156 break;
1160 static void ixj_timeout(unsigned long ptr)
1162 int board;
1163 unsigned long jifon;
1164 IXJ *j = (IXJ *)ptr;
1165 board = j->board;
1167 if (j->DSPbase && atomic_read(&j->DSPWrite) == 0 && test_and_set_bit(board, (void *)&j->busyflags) == 0) {
1168 ixj_perfmon(j->timerchecks);
1169 j->hookstate = ixj_hookstate(j);
1170 if (j->tone_state) {
1171 if (!(j->hookstate)) {
1172 ixj_cpt_stop(j);
1173 if (j->m_hook) {
1174 j->m_hook = 0;
1175 j->ex.bits.hookstate = 1;
1176 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1178 clear_bit(board, &j->busyflags);
1179 ixj_add_timer(j);
1180 return;
1182 if (j->tone_state == 1)
1183 jifon = ((hertz * j->tone_on_time) * 25 / 100000);
1184 else
1185 jifon = ((hertz * j->tone_on_time) * 25 / 100000) + ((hertz * j->tone_off_time) * 25 / 100000);
1186 if (time_before(jiffies, j->tone_start_jif + jifon)) {
1187 if (j->tone_state == 1) {
1188 ixj_play_tone(j, j->tone_index);
1189 if (j->dsp.low == 0x20) {
1190 clear_bit(board, &j->busyflags);
1191 ixj_add_timer(j);
1192 return;
1194 } else {
1195 ixj_play_tone(j, 0);
1196 if (j->dsp.low == 0x20) {
1197 clear_bit(board, &j->busyflags);
1198 ixj_add_timer(j);
1199 return;
1202 } else {
1203 ixj_tone_timeout(j);
1204 if (j->flags.dialtone) {
1205 ixj_dialtone(j);
1207 if (j->flags.busytone) {
1208 ixj_busytone(j);
1209 if (j->dsp.low == 0x20) {
1210 clear_bit(board, &j->busyflags);
1211 ixj_add_timer(j);
1212 return;
1215 if (j->flags.ringback) {
1216 ixj_ringback(j);
1217 if (j->dsp.low == 0x20) {
1218 clear_bit(board, &j->busyflags);
1219 ixj_add_timer(j);
1220 return;
1223 if (!j->tone_state) {
1224 ixj_cpt_stop(j);
1228 if (!(j->tone_state && j->dsp.low == 0x20)) {
1229 if (IsRxReady(j)) {
1230 ixj_read_frame(j);
1232 if (IsTxReady(j)) {
1233 ixj_write_frame(j);
1236 if (j->flags.cringing) {
1237 if (j->hookstate & 1) {
1238 j->flags.cringing = 0;
1239 ixj_ring_off(j);
1240 } else if(j->cadence_f[5].enable && ((!j->cadence_f[5].en_filter) || (j->cadence_f[5].en_filter && j->flags.firstring))) {
1241 switch(j->cadence_f[5].state) {
1242 case 0:
1243 j->cadence_f[5].on1dot = jiffies + (long)((j->cadence_f[5].on1 * (hertz * 100) / 10000));
1244 if (time_before(jiffies, j->cadence_f[5].on1dot)) {
1245 if(ixjdebug & 0x0004) {
1246 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1248 ixj_ring_on(j);
1250 j->cadence_f[5].state = 1;
1251 break;
1252 case 1:
1253 if (time_after(jiffies, j->cadence_f[5].on1dot)) {
1254 j->cadence_f[5].off1dot = jiffies + (long)((j->cadence_f[5].off1 * (hertz * 100) / 10000));
1255 if(ixjdebug & 0x0004) {
1256 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1258 ixj_ring_off(j);
1259 j->cadence_f[5].state = 2;
1261 break;
1262 case 2:
1263 if (time_after(jiffies, j->cadence_f[5].off1dot)) {
1264 if(ixjdebug & 0x0004) {
1265 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1267 ixj_ring_on(j);
1268 if (j->cadence_f[5].on2) {
1269 j->cadence_f[5].on2dot = jiffies + (long)((j->cadence_f[5].on2 * (hertz * 100) / 10000));
1270 j->cadence_f[5].state = 3;
1271 } else {
1272 j->cadence_f[5].state = 7;
1275 break;
1276 case 3:
1277 if (time_after(jiffies, j->cadence_f[5].on2dot)) {
1278 if(ixjdebug & 0x0004) {
1279 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1281 ixj_ring_off(j);
1282 if (j->cadence_f[5].off2) {
1283 j->cadence_f[5].off2dot = jiffies + (long)((j->cadence_f[5].off2 * (hertz * 100) / 10000));
1284 j->cadence_f[5].state = 4;
1285 } else {
1286 j->cadence_f[5].state = 7;
1289 break;
1290 case 4:
1291 if (time_after(jiffies, j->cadence_f[5].off2dot)) {
1292 if(ixjdebug & 0x0004) {
1293 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1295 ixj_ring_on(j);
1296 if (j->cadence_f[5].on3) {
1297 j->cadence_f[5].on3dot = jiffies + (long)((j->cadence_f[5].on3 * (hertz * 100) / 10000));
1298 j->cadence_f[5].state = 5;
1299 } else {
1300 j->cadence_f[5].state = 7;
1303 break;
1304 case 5:
1305 if (time_after(jiffies, j->cadence_f[5].on3dot)) {
1306 if(ixjdebug & 0x0004) {
1307 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1309 ixj_ring_off(j);
1310 if (j->cadence_f[5].off3) {
1311 j->cadence_f[5].off3dot = jiffies + (long)((j->cadence_f[5].off3 * (hertz * 100) / 10000));
1312 j->cadence_f[5].state = 6;
1313 } else {
1314 j->cadence_f[5].state = 7;
1317 break;
1318 case 6:
1319 if (time_after(jiffies, j->cadence_f[5].off3dot)) {
1320 if(ixjdebug & 0x0004) {
1321 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1323 j->cadence_f[5].state = 7;
1325 break;
1326 case 7:
1327 if(ixjdebug & 0x0004) {
1328 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1330 j->flags.cidring = 1;
1331 j->cadence_f[5].state = 0;
1332 break;
1334 if (j->flags.cidring && !j->flags.cidsent) {
1335 j->flags.cidsent = 1;
1336 if(j->fskdcnt) {
1337 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
1338 ixj_pre_cid(j);
1340 j->flags.cidring = 0;
1342 clear_bit(board, &j->busyflags);
1343 ixj_add_timer(j);
1344 return;
1345 } else {
1346 if (time_after(jiffies, j->ring_cadence_jif + (hertz / 2))) {
1347 if (j->flags.cidring && !j->flags.cidsent) {
1348 j->flags.cidsent = 1;
1349 if(j->fskdcnt) {
1350 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
1351 ixj_pre_cid(j);
1353 j->flags.cidring = 0;
1355 j->ring_cadence_t--;
1356 if (j->ring_cadence_t == -1)
1357 j->ring_cadence_t = 15;
1358 j->ring_cadence_jif = jiffies;
1360 if (j->ring_cadence & 1 << j->ring_cadence_t) {
1361 if(j->flags.cidsent && j->cadence_f[5].en_filter)
1362 j->flags.firstring = 1;
1363 else
1364 ixj_ring_on(j);
1365 } else {
1366 ixj_ring_off(j);
1367 if(!j->flags.cidsent)
1368 j->flags.cidring = 1;
1371 clear_bit(board, &j->busyflags);
1372 ixj_add_timer(j);
1373 return;
1376 if (!j->flags.ringing) {
1377 if (j->hookstate) { /* & 1) { */
1378 if (j->dsp.low != 0x20 &&
1379 SLIC_GetState(j) != PLD_SLIC_STATE_ACTIVE) {
1380 SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
1382 LineMonitor(j);
1383 read_filters(j);
1384 ixj_WriteDSPCommand(0x511B, j);
1385 j->proc_load = j->ssr.high << 8 | j->ssr.low;
1386 if (!j->m_hook && (j->hookstate & 1)) {
1387 j->m_hook = j->ex.bits.hookstate = 1;
1388 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1390 } else {
1391 if (j->ex.bits.dtmf_ready) {
1392 j->dtmf_wp = j->dtmf_rp = j->ex.bits.dtmf_ready = 0;
1394 if (j->m_hook) {
1395 j->m_hook = 0;
1396 j->ex.bits.hookstate = 1;
1397 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1401 if (j->cardtype == QTI_LINEJACK && !j->flags.pstncheck && j->flags.pstn_present) {
1402 ixj_pstn_state(j);
1404 if (j->ex.bytes) {
1405 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
1407 clear_bit(board, &j->busyflags);
1409 ixj_add_timer(j);
1412 static int ixj_status_wait(IXJ *j)
1414 unsigned long jif;
1416 jif = jiffies + ((60 * hertz) / 100);
1417 while (!IsStatusReady(j)) {
1418 ixj_perfmon(j->statuswait);
1419 if (time_after(jiffies, jif)) {
1420 ixj_perfmon(j->statuswaitfail);
1421 return -1;
1424 return 0;
1427 static int ixj_PCcontrol_wait(IXJ *j)
1429 unsigned long jif;
1431 jif = jiffies + ((60 * hertz) / 100);
1432 while (!IsPCControlReady(j)) {
1433 ixj_perfmon(j->pcontrolwait);
1434 if (time_after(jiffies, jif)) {
1435 ixj_perfmon(j->pcontrolwaitfail);
1436 return -1;
1439 return 0;
1442 static int ixj_WriteDSPCommand(unsigned short cmd, IXJ *j)
1444 BYTES bytes;
1445 unsigned long jif;
1447 atomic_inc(&j->DSPWrite);
1448 if(atomic_read(&j->DSPWrite) > 1) {
1449 printk("IXJ %d DSP write overlap attempting command 0x%4.4x\n", j->board, cmd);
1450 return -1;
1452 bytes.high = (cmd & 0xFF00) >> 8;
1453 bytes.low = cmd & 0x00FF;
1454 jif = jiffies + ((60 * hertz) / 100);
1455 while (!IsControlReady(j)) {
1456 ixj_perfmon(j->iscontrolready);
1457 if (time_after(jiffies, jif)) {
1458 ixj_perfmon(j->iscontrolreadyfail);
1459 atomic_dec(&j->DSPWrite);
1460 if(atomic_read(&j->DSPWrite) > 0) {
1461 printk("IXJ %d DSP overlaped command 0x%4.4x during control ready failure.\n", j->board, cmd);
1462 while(atomic_read(&j->DSPWrite) > 0) {
1463 atomic_dec(&j->DSPWrite);
1466 return -1;
1469 outb(bytes.low, j->DSPbase + 6);
1470 outb(bytes.high, j->DSPbase + 7);
1472 if (ixj_status_wait(j)) {
1473 j->ssr.low = 0xFF;
1474 j->ssr.high = 0xFF;
1475 atomic_dec(&j->DSPWrite);
1476 if(atomic_read(&j->DSPWrite) > 0) {
1477 printk("IXJ %d DSP overlaped command 0x%4.4x during status wait failure.\n", j->board, cmd);
1478 while(atomic_read(&j->DSPWrite) > 0) {
1479 atomic_dec(&j->DSPWrite);
1482 return -1;
1484 /* Read Software Status Register */
1485 j->ssr.low = inb_p(j->DSPbase + 2);
1486 j->ssr.high = inb_p(j->DSPbase + 3);
1487 atomic_dec(&j->DSPWrite);
1488 if(atomic_read(&j->DSPWrite) > 0) {
1489 printk("IXJ %d DSP overlaped command 0x%4.4x\n", j->board, cmd);
1490 while(atomic_read(&j->DSPWrite) > 0) {
1491 atomic_dec(&j->DSPWrite);
1494 return 0;
1497 /***************************************************************************
1499 * General Purpose IO Register read routine
1501 ***************************************************************************/
1502 static inline int ixj_gpio_read(IXJ *j)
1504 if (ixj_WriteDSPCommand(0x5143, j))
1505 return -1;
1507 j->gpio.bytes.low = j->ssr.low;
1508 j->gpio.bytes.high = j->ssr.high;
1510 return 0;
1513 static inline void LED_SetState(int state, IXJ *j)
1515 if (j->cardtype == QTI_LINEJACK) {
1516 j->pld_scrw.bits.led1 = state & 0x1 ? 1 : 0;
1517 j->pld_scrw.bits.led2 = state & 0x2 ? 1 : 0;
1518 j->pld_scrw.bits.led3 = state & 0x4 ? 1 : 0;
1519 j->pld_scrw.bits.led4 = state & 0x8 ? 1 : 0;
1521 outb(j->pld_scrw.byte, j->XILINXbase);
1525 /*********************************************************************
1526 * GPIO Pins are configured as follows on the Quicknet Internet
1527 * PhoneJACK Telephony Cards
1529 * POTS Select GPIO_6=0 GPIO_7=0
1530 * Mic/Speaker Select GPIO_6=0 GPIO_7=1
1531 * Handset Select GPIO_6=1 GPIO_7=0
1533 * SLIC Active GPIO_1=0 GPIO_2=1 GPIO_5=0
1534 * SLIC Ringing GPIO_1=1 GPIO_2=1 GPIO_5=0
1535 * SLIC Open Circuit GPIO_1=0 GPIO_2=0 GPIO_5=0
1537 * Hook Switch changes reported on GPIO_3
1538 *********************************************************************/
1539 static int ixj_set_port(IXJ *j, int arg)
1541 if (j->cardtype == QTI_PHONEJACK_LITE) {
1542 if (arg != PORT_POTS)
1543 return 10;
1544 else
1545 return 0;
1547 switch (arg) {
1548 case PORT_POTS:
1549 j->port = PORT_POTS;
1550 switch (j->cardtype) {
1551 case QTI_PHONECARD:
1552 if (j->flags.pcmciasct == 1)
1553 SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
1554 else
1555 return 11;
1556 break;
1557 case QTI_PHONEJACK_PCI:
1558 j->pld_slicw.pcib.mic = 0;
1559 j->pld_slicw.pcib.spk = 0;
1560 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1561 break;
1562 case QTI_LINEJACK:
1563 ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
1564 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
1565 Software Control Register */
1566 return 2;
1567 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
1569 outb(j->pld_scrw.byte, j->XILINXbase);
1570 j->pld_clock.byte = 0;
1571 outb(j->pld_clock.byte, j->XILINXbase + 0x04);
1572 j->pld_slicw.bits.rly1 = 1;
1573 j->pld_slicw.bits.spken = 0;
1574 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1575 ixj_mixer(0x1200, j); /* Turn Off MIC switch on mixer left */
1576 ixj_mixer(0x1401, j); /* Turn On Mono1 switch on mixer left */
1577 ixj_mixer(0x1300, j); /* Turn Off MIC switch on mixer right */
1578 ixj_mixer(0x1501, j); /* Turn On Mono1 switch on mixer right */
1579 ixj_mixer(0x0E80, j); /*Mic mute */
1580 ixj_mixer(0x0F00, j); /* Set mono out (SLIC) to 0dB */
1581 ixj_mixer(0x0080, j); /* Mute Master Left volume */
1582 ixj_mixer(0x0180, j); /* Mute Master Right volume */
1583 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
1584 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
1585 break;
1586 case QTI_PHONEJACK:
1587 j->gpio.bytes.high = 0x0B;
1588 j->gpio.bits.gpio6 = 0;
1589 j->gpio.bits.gpio7 = 0;
1590 ixj_WriteDSPCommand(j->gpio.word, j);
1591 break;
1593 break;
1594 case PORT_PSTN:
1595 if (j->cardtype == QTI_LINEJACK) {
1596 ixj_WriteDSPCommand(0xC534, j); /* Write CODEC config to Software Control Register */
1598 j->pld_slicw.bits.rly3 = 0;
1599 j->pld_slicw.bits.rly1 = 1;
1600 j->pld_slicw.bits.spken = 0;
1601 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1602 j->port = PORT_PSTN;
1603 } else {
1604 return 4;
1606 break;
1607 case PORT_SPEAKER:
1608 j->port = PORT_SPEAKER;
1609 switch (j->cardtype) {
1610 case QTI_PHONECARD:
1611 if (j->flags.pcmciasct) {
1612 SLIC_SetState(PLD_SLIC_STATE_OC, j);
1614 break;
1615 case QTI_PHONEJACK_PCI:
1616 j->pld_slicw.pcib.mic = 1;
1617 j->pld_slicw.pcib.spk = 1;
1618 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1619 break;
1620 case QTI_LINEJACK:
1621 ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
1622 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
1623 Software Control Register */
1624 return 2;
1625 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
1627 outb(j->pld_scrw.byte, j->XILINXbase);
1628 j->pld_clock.byte = 0;
1629 outb(j->pld_clock.byte, j->XILINXbase + 0x04);
1630 j->pld_slicw.bits.rly1 = 1;
1631 j->pld_slicw.bits.spken = 1;
1632 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1633 ixj_mixer(0x1201, j); /* Turn On MIC switch on mixer left */
1634 ixj_mixer(0x1400, j); /* Turn Off Mono1 switch on mixer left */
1635 ixj_mixer(0x1301, j); /* Turn On MIC switch on mixer right */
1636 ixj_mixer(0x1500, j); /* Turn Off Mono1 switch on mixer right */
1637 ixj_mixer(0x0E06, j); /*Mic un-mute 0dB */
1638 ixj_mixer(0x0F80, j); /* Mute mono out (SLIC) */
1639 ixj_mixer(0x0000, j); /* Set Master Left volume to 0dB */
1640 ixj_mixer(0x0100, j); /* Set Master Right volume to 0dB */
1641 break;
1642 case QTI_PHONEJACK:
1643 j->gpio.bytes.high = 0x0B;
1644 j->gpio.bits.gpio6 = 0;
1645 j->gpio.bits.gpio7 = 1;
1646 ixj_WriteDSPCommand(j->gpio.word, j);
1647 break;
1649 break;
1650 case PORT_HANDSET:
1651 if (j->cardtype != QTI_PHONEJACK) {
1652 return 5;
1653 } else {
1654 j->gpio.bytes.high = 0x0B;
1655 j->gpio.bits.gpio6 = 1;
1656 j->gpio.bits.gpio7 = 0;
1657 ixj_WriteDSPCommand(j->gpio.word, j);
1658 j->port = PORT_HANDSET;
1660 break;
1661 default:
1662 return 6;
1663 break;
1665 return 0;
1668 static int ixj_set_pots(IXJ *j, int arg)
1670 if (j->cardtype == QTI_LINEJACK) {
1671 if (arg) {
1672 if (j->port == PORT_PSTN) {
1673 j->pld_slicw.bits.rly1 = 0;
1674 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1675 j->flags.pots_pstn = 1;
1676 return 1;
1677 } else {
1678 j->flags.pots_pstn = 0;
1679 return 0;
1681 } else {
1682 j->pld_slicw.bits.rly1 = 1;
1683 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1684 j->flags.pots_pstn = 0;
1685 return 1;
1687 } else {
1688 return 0;
1692 static void ixj_ring_on(IXJ *j)
1694 if (j->dsp.low == 0x20) /* Internet PhoneJACK */
1696 if (ixjdebug & 0x0004)
1697 printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
1699 j->gpio.bytes.high = 0x0B;
1700 j->gpio.bytes.low = 0x00;
1701 j->gpio.bits.gpio1 = 1;
1702 j->gpio.bits.gpio2 = 1;
1703 j->gpio.bits.gpio5 = 0;
1704 ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring signal */
1705 } else /* Internet LineJACK, Internet PhoneJACK Lite or Internet PhoneJACK PCI */
1707 if (ixjdebug & 0x0004)
1708 printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
1710 SLIC_SetState(PLD_SLIC_STATE_RINGING, j);
1714 static int ixj_siadc(IXJ *j, int val)
1716 if(j->cardtype == QTI_PHONECARD){
1717 if(j->flags.pcmciascp){
1718 if(val == -1)
1719 return j->siadc.bits.rxg;
1721 if(val < 0 || val > 0x1F)
1722 return -1;
1724 j->siadc.bits.hom = 0; /* Handset Out Mute */
1725 j->siadc.bits.lom = 0; /* Line Out Mute */
1726 j->siadc.bits.rxg = val; /*(0xC000 - 0x41C8) / 0x4EF; RX PGA Gain */
1727 j->psccr.bits.addr = 6; /* R/W Smart Cable Register Address */
1728 j->psccr.bits.rw = 0; /* Read / Write flag */
1729 j->psccr.bits.dev = 0;
1730 outb(j->siadc.byte, j->XILINXbase + 0x00);
1731 outb(j->psccr.byte, j->XILINXbase + 0x01);
1732 ixj_PCcontrol_wait(j);
1733 return j->siadc.bits.rxg;
1736 return -1;
1739 static int ixj_sidac(IXJ *j, int val)
1741 if(j->cardtype == QTI_PHONECARD){
1742 if(j->flags.pcmciascp){
1743 if(val == -1)
1744 return j->sidac.bits.txg;
1746 if(val < 0 || val > 0x1F)
1747 return -1;
1749 j->sidac.bits.srm = 1; /* Speaker Right Mute */
1750 j->sidac.bits.slm = 1; /* Speaker Left Mute */
1751 j->sidac.bits.txg = val; /* (0xC000 - 0x45E4) / 0x5D3; TX PGA Gain */
1752 j->psccr.bits.addr = 7; /* R/W Smart Cable Register Address */
1753 j->psccr.bits.rw = 0; /* Read / Write flag */
1754 j->psccr.bits.dev = 0;
1755 outb(j->sidac.byte, j->XILINXbase + 0x00);
1756 outb(j->psccr.byte, j->XILINXbase + 0x01);
1757 ixj_PCcontrol_wait(j);
1758 return j->sidac.bits.txg;
1761 return -1;
1764 static int ixj_pcmcia_cable_check(IXJ *j)
1766 j->pccr1.byte = inb_p(j->XILINXbase + 0x03);
1767 if (!j->flags.pcmciastate) {
1768 j->pccr2.byte = inb_p(j->XILINXbase + 0x02);
1769 if (j->pccr1.bits.drf || j->pccr2.bits.rstc) {
1770 j->flags.pcmciastate = 4;
1771 return 0;
1773 if (j->pccr1.bits.ed) {
1774 j->pccr1.bits.ed = 0;
1775 j->psccr.bits.dev = 3;
1776 j->psccr.bits.rw = 1;
1777 outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
1778 ixj_PCcontrol_wait(j);
1779 j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
1780 j->pslic.bits.led2 = j->pslic.bits.det ? 1 : 0;
1781 j->psccr.bits.dev = 3;
1782 j->psccr.bits.rw = 0;
1783 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
1784 ixj_PCcontrol_wait(j);
1785 return j->pslic.bits.led2 ? 1 : 0;
1786 } else if (j->flags.pcmciasct) {
1787 return j->r_hook;
1788 } else {
1789 return 1;
1791 } else if (j->flags.pcmciastate == 4) {
1792 if (!j->pccr1.bits.drf) {
1793 j->flags.pcmciastate = 3;
1795 return 0;
1796 } else if (j->flags.pcmciastate == 3) {
1797 j->pccr2.bits.pwr = 0;
1798 j->pccr2.bits.rstc = 1;
1799 outb(j->pccr2.byte, j->XILINXbase + 0x02);
1800 j->checkwait = jiffies + (hertz * 2);
1801 j->flags.incheck = 1;
1802 j->flags.pcmciastate = 2;
1803 return 0;
1804 } else if (j->flags.pcmciastate == 2) {
1805 if (j->flags.incheck) {
1806 if (time_before(jiffies, j->checkwait)) {
1807 return 0;
1808 } else {
1809 j->flags.incheck = 0;
1812 j->pccr2.bits.pwr = 0;
1813 j->pccr2.bits.rstc = 0;
1814 outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
1815 j->flags.pcmciastate = 1;
1816 return 0;
1817 } else if (j->flags.pcmciastate == 1) {
1818 j->flags.pcmciastate = 0;
1819 if (!j->pccr1.bits.drf) {
1820 j->psccr.bits.dev = 3;
1821 j->psccr.bits.rw = 1;
1822 outb_p(j->psccr.byte, j->XILINXbase + 0x01);
1823 ixj_PCcontrol_wait(j);
1824 j->flags.pcmciascp = 1; /* Set Cable Present Flag */
1826 j->flags.pcmciasct = (inw_p(j->XILINXbase + 0x00) >> 8) & 0x03; /* Get Cable Type */
1828 if (j->flags.pcmciasct == 3) {
1829 j->flags.pcmciastate = 4;
1830 return 0;
1831 } else if (j->flags.pcmciasct == 0) {
1832 j->pccr2.bits.pwr = 1;
1833 j->pccr2.bits.rstc = 0;
1834 outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
1835 j->port = PORT_SPEAKER;
1836 } else {
1837 j->port = PORT_POTS;
1839 j->sic1.bits.cpd = 0; /* Chip Power Down */
1840 j->sic1.bits.mpd = 0; /* MIC Bias Power Down */
1841 j->sic1.bits.hpd = 0; /* Handset Bias Power Down */
1842 j->sic1.bits.lpd = 0; /* Line Bias Power Down */
1843 j->sic1.bits.spd = 1; /* Speaker Drive Power Down */
1844 j->psccr.bits.addr = 1; /* R/W Smart Cable Register Address */
1845 j->psccr.bits.rw = 0; /* Read / Write flag */
1846 j->psccr.bits.dev = 0;
1847 outb(j->sic1.byte, j->XILINXbase + 0x00);
1848 outb(j->psccr.byte, j->XILINXbase + 0x01);
1849 ixj_PCcontrol_wait(j);
1851 j->sic2.bits.al = 0; /* Analog Loopback DAC analog -> ADC analog */
1852 j->sic2.bits.dl2 = 0; /* Digital Loopback DAC -> ADC one bit */
1853 j->sic2.bits.dl1 = 0; /* Digital Loopback ADC -> DAC one bit */
1854 j->sic2.bits.pll = 0; /* 1 = div 10, 0 = div 5 */
1855 j->sic2.bits.hpd = 0; /* HPF disable */
1856 j->psccr.bits.addr = 2; /* R/W Smart Cable Register Address */
1857 j->psccr.bits.rw = 0; /* Read / Write flag */
1858 j->psccr.bits.dev = 0;
1859 outb(j->sic2.byte, j->XILINXbase + 0x00);
1860 outb(j->psccr.byte, j->XILINXbase + 0x01);
1861 ixj_PCcontrol_wait(j);
1863 j->psccr.bits.addr = 3; /* R/W Smart Cable Register Address */
1864 j->psccr.bits.rw = 0; /* Read / Write flag */
1865 j->psccr.bits.dev = 0;
1866 outb(0x00, j->XILINXbase + 0x00); /* PLL Divide N1 */
1867 outb(j->psccr.byte, j->XILINXbase + 0x01);
1868 ixj_PCcontrol_wait(j);
1870 j->psccr.bits.addr = 4; /* R/W Smart Cable Register Address */
1871 j->psccr.bits.rw = 0; /* Read / Write flag */
1872 j->psccr.bits.dev = 0;
1873 outb(0x09, j->XILINXbase + 0x00); /* PLL Multiply M1 */
1874 outb(j->psccr.byte, j->XILINXbase + 0x01);
1875 ixj_PCcontrol_wait(j);
1877 j->sirxg.bits.lig = 1; /* Line In Gain */
1878 j->sirxg.bits.lim = 1; /* Line In Mute */
1879 j->sirxg.bits.mcg = 0; /* MIC In Gain was 3 */
1880 j->sirxg.bits.mcm = 0; /* MIC In Mute */
1881 j->sirxg.bits.him = 0; /* Handset In Mute */
1882 j->sirxg.bits.iir = 1; /* IIR */
1883 j->psccr.bits.addr = 5; /* R/W Smart Cable Register Address */
1884 j->psccr.bits.rw = 0; /* Read / Write flag */
1885 j->psccr.bits.dev = 0;
1886 outb(j->sirxg.byte, j->XILINXbase + 0x00);
1887 outb(j->psccr.byte, j->XILINXbase + 0x01);
1888 ixj_PCcontrol_wait(j);
1890 ixj_siadc(j, 0x17);
1891 ixj_sidac(j, 0x1D);
1893 j->siaatt.bits.sot = 0;
1894 j->psccr.bits.addr = 9; /* R/W Smart Cable Register Address */
1895 j->psccr.bits.rw = 0; /* Read / Write flag */
1896 j->psccr.bits.dev = 0;
1897 outb(j->siaatt.byte, j->XILINXbase + 0x00);
1898 outb(j->psccr.byte, j->XILINXbase + 0x01);
1899 ixj_PCcontrol_wait(j);
1901 if (j->flags.pcmciasct == 1 && !j->readers && !j->writers) {
1902 j->psccr.byte = j->pslic.byte = 0;
1903 j->pslic.bits.powerdown = 1;
1904 j->psccr.bits.dev = 3;
1905 j->psccr.bits.rw = 0;
1906 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
1907 ixj_PCcontrol_wait(j);
1910 return 0;
1911 } else {
1912 j->flags.pcmciascp = 0;
1913 return 0;
1915 return 0;
1918 static int ixj_hookstate(IXJ *j)
1920 int fOffHook = 0;
1922 switch (j->cardtype) {
1923 case QTI_PHONEJACK:
1924 ixj_gpio_read(j);
1925 fOffHook = j->gpio.bits.gpio3read ? 1 : 0;
1926 break;
1927 case QTI_LINEJACK:
1928 case QTI_PHONEJACK_LITE:
1929 case QTI_PHONEJACK_PCI:
1930 SLIC_GetState(j);
1931 if(j->cardtype == QTI_LINEJACK && j->flags.pots_pstn == 1 && (j->readers || j->writers)) {
1932 fOffHook = j->pld_slicr.bits.potspstn ? 1 : 0;
1933 if(fOffHook != j->p_hook) {
1934 if(!j->checkwait) {
1935 j->checkwait = jiffies;
1937 if(time_before(jiffies, j->checkwait + 2)) {
1938 fOffHook ^= 1;
1939 } else {
1940 j->checkwait = 0;
1942 j->p_hook = fOffHook;
1943 printk("IXJ : /dev/phone%d pots-pstn hookstate check %d at %ld\n", j->board, fOffHook, jiffies);
1945 } else {
1946 if (j->pld_slicr.bits.state == PLD_SLIC_STATE_ACTIVE ||
1947 j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) {
1948 if (j->flags.ringing || j->flags.cringing) {
1949 if (!in_interrupt()) {
1950 msleep(20);
1952 SLIC_GetState(j);
1953 if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) {
1954 ixj_ring_on(j);
1957 if (j->cardtype == QTI_PHONEJACK_PCI) {
1958 j->pld_scrr.byte = inb_p(j->XILINXbase);
1959 fOffHook = j->pld_scrr.pcib.det ? 1 : 0;
1960 } else
1961 fOffHook = j->pld_slicr.bits.det ? 1 : 0;
1964 break;
1965 case QTI_PHONECARD:
1966 fOffHook = ixj_pcmcia_cable_check(j);
1967 break;
1969 if (j->r_hook != fOffHook) {
1970 j->r_hook = fOffHook;
1971 if (j->port == PORT_SPEAKER || j->port == PORT_HANDSET) { // || (j->port == PORT_PSTN && j->flags.pots_pstn == 0)) {
1972 j->ex.bits.hookstate = 1;
1973 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1974 } else if (!fOffHook) {
1975 j->flash_end = jiffies + ((60 * hertz) / 100);
1978 if (fOffHook) {
1979 if(time_before(jiffies, j->flash_end)) {
1980 j->ex.bits.flash = 1;
1981 j->flash_end = 0;
1982 ixj_kill_fasync(j, SIG_FLASH, POLL_IN);
1984 } else {
1985 if(time_before(jiffies, j->flash_end)) {
1986 fOffHook = 1;
1990 if (j->port == PORT_PSTN && j->daa_mode == SOP_PU_CONVERSATION)
1991 fOffHook |= 2;
1993 if (j->port == PORT_SPEAKER) {
1994 if(j->cardtype == QTI_PHONECARD) {
1995 if(j->flags.pcmciascp && j->flags.pcmciasct) {
1996 fOffHook |= 2;
1998 } else {
1999 fOffHook |= 2;
2003 if (j->port == PORT_HANDSET)
2004 fOffHook |= 2;
2006 return fOffHook;
2009 static void ixj_ring_off(IXJ *j)
2011 if (j->dsp.low == 0x20) /* Internet PhoneJACK */
2013 if (ixjdebug & 0x0004)
2014 printk(KERN_INFO "IXJ Ring Off\n");
2015 j->gpio.bytes.high = 0x0B;
2016 j->gpio.bytes.low = 0x00;
2017 j->gpio.bits.gpio1 = 0;
2018 j->gpio.bits.gpio2 = 1;
2019 j->gpio.bits.gpio5 = 0;
2020 ixj_WriteDSPCommand(j->gpio.word, j);
2021 } else /* Internet LineJACK */
2023 if (ixjdebug & 0x0004)
2024 printk(KERN_INFO "IXJ Ring Off\n");
2026 if(!j->flags.cidplay)
2027 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
2029 SLIC_GetState(j);
2033 static void ixj_ring_start(IXJ *j)
2035 j->flags.cringing = 1;
2036 if (ixjdebug & 0x0004)
2037 printk(KERN_INFO "IXJ Cadence Ringing Start /dev/phone%d\n", j->board);
2038 if (ixj_hookstate(j) & 1) {
2039 if (j->port == PORT_POTS)
2040 ixj_ring_off(j);
2041 j->flags.cringing = 0;
2042 if (ixjdebug & 0x0004)
2043 printk(KERN_INFO "IXJ Cadence Ringing Stopped /dev/phone%d off hook\n", j->board);
2044 } else if(j->cadence_f[5].enable && (!j->cadence_f[5].en_filter)) {
2045 j->ring_cadence_jif = jiffies;
2046 j->flags.cidsent = j->flags.cidring = 0;
2047 j->cadence_f[5].state = 0;
2048 if(j->cadence_f[5].on1)
2049 ixj_ring_on(j);
2050 } else {
2051 j->ring_cadence_jif = jiffies;
2052 j->ring_cadence_t = 15;
2053 if (j->ring_cadence & 1 << j->ring_cadence_t) {
2054 ixj_ring_on(j);
2055 } else {
2056 ixj_ring_off(j);
2058 j->flags.cidsent = j->flags.cidring = j->flags.firstring = 0;
2062 static int ixj_ring(IXJ *j)
2064 char cntr;
2065 unsigned long jif;
2067 j->flags.ringing = 1;
2068 if (ixj_hookstate(j) & 1) {
2069 ixj_ring_off(j);
2070 j->flags.ringing = 0;
2071 return 1;
2073 for (cntr = 0; cntr < j->maxrings; cntr++) {
2074 jif = jiffies + (1 * hertz);
2075 ixj_ring_on(j);
2076 while (time_before(jiffies, jif)) {
2077 if (ixj_hookstate(j) & 1) {
2078 ixj_ring_off(j);
2079 j->flags.ringing = 0;
2080 return 1;
2082 schedule_timeout_interruptible(1);
2083 if (signal_pending(current))
2084 break;
2086 jif = jiffies + (3 * hertz);
2087 ixj_ring_off(j);
2088 while (time_before(jiffies, jif)) {
2089 if (ixj_hookstate(j) & 1) {
2090 msleep(10);
2091 if (ixj_hookstate(j) & 1) {
2092 j->flags.ringing = 0;
2093 return 1;
2096 schedule_timeout_interruptible(1);
2097 if (signal_pending(current))
2098 break;
2101 ixj_ring_off(j);
2102 j->flags.ringing = 0;
2103 return 0;
2106 static int ixj_open(struct phone_device *p, struct file *file_p)
2108 IXJ *j = get_ixj(p->board);
2109 file_p->private_data = j;
2111 if (!j->DSPbase)
2112 return -ENODEV;
2114 if (file_p->f_mode & FMODE_READ) {
2115 if(!j->readers) {
2116 j->readers++;
2117 } else {
2118 return -EBUSY;
2122 if (file_p->f_mode & FMODE_WRITE) {
2123 if(!j->writers) {
2124 j->writers++;
2125 } else {
2126 if (file_p->f_mode & FMODE_READ){
2127 j->readers--;
2129 return -EBUSY;
2133 if (j->cardtype == QTI_PHONECARD) {
2134 j->pslic.bits.powerdown = 0;
2135 j->psccr.bits.dev = 3;
2136 j->psccr.bits.rw = 0;
2137 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
2138 ixj_PCcontrol_wait(j);
2141 j->flags.cidplay = 0;
2142 j->flags.cidcw_ack = 0;
2144 if (ixjdebug & 0x0002)
2145 printk(KERN_INFO "Opening board %d\n", p->board);
2147 j->framesread = j->frameswritten = 0;
2148 return 0;
2151 static int ixj_release(struct inode *inode, struct file *file_p)
2153 IXJ_TONE ti;
2154 int cnt;
2155 IXJ *j = file_p->private_data;
2156 int board = j->p.board;
2159 * Set up locks to ensure that only one process is talking to the DSP at a time.
2160 * This is necessary to keep the DSP from locking up.
2162 while(test_and_set_bit(board, (void *)&j->busyflags) != 0)
2163 schedule_timeout_interruptible(1);
2164 if (ixjdebug & 0x0002)
2165 printk(KERN_INFO "Closing board %d\n", NUM(inode));
2167 if (j->cardtype == QTI_PHONECARD)
2168 ixj_set_port(j, PORT_SPEAKER);
2169 else
2170 ixj_set_port(j, PORT_POTS);
2172 aec_stop(j);
2173 ixj_play_stop(j);
2174 ixj_record_stop(j);
2175 set_play_volume(j, 0x100);
2176 set_rec_volume(j, 0x100);
2177 ixj_ring_off(j);
2179 /* Restore the tone table to default settings. */
2180 ti.tone_index = 10;
2181 ti.gain0 = 1;
2182 ti.freq0 = hz941;
2183 ti.gain1 = 0;
2184 ti.freq1 = hz1209;
2185 ixj_init_tone(j, &ti);
2186 ti.tone_index = 11;
2187 ti.gain0 = 1;
2188 ti.freq0 = hz941;
2189 ti.gain1 = 0;
2190 ti.freq1 = hz1336;
2191 ixj_init_tone(j, &ti);
2192 ti.tone_index = 12;
2193 ti.gain0 = 1;
2194 ti.freq0 = hz941;
2195 ti.gain1 = 0;
2196 ti.freq1 = hz1477;
2197 ixj_init_tone(j, &ti);
2198 ti.tone_index = 13;
2199 ti.gain0 = 1;
2200 ti.freq0 = hz800;
2201 ti.gain1 = 0;
2202 ti.freq1 = 0;
2203 ixj_init_tone(j, &ti);
2204 ti.tone_index = 14;
2205 ti.gain0 = 1;
2206 ti.freq0 = hz1000;
2207 ti.gain1 = 0;
2208 ti.freq1 = 0;
2209 ixj_init_tone(j, &ti);
2210 ti.tone_index = 15;
2211 ti.gain0 = 1;
2212 ti.freq0 = hz1250;
2213 ti.gain1 = 0;
2214 ti.freq1 = 0;
2215 ixj_init_tone(j, &ti);
2216 ti.tone_index = 16;
2217 ti.gain0 = 1;
2218 ti.freq0 = hz950;
2219 ti.gain1 = 0;
2220 ti.freq1 = 0;
2221 ixj_init_tone(j, &ti);
2222 ti.tone_index = 17;
2223 ti.gain0 = 1;
2224 ti.freq0 = hz1100;
2225 ti.gain1 = 0;
2226 ti.freq1 = 0;
2227 ixj_init_tone(j, &ti);
2228 ti.tone_index = 18;
2229 ti.gain0 = 1;
2230 ti.freq0 = hz1400;
2231 ti.gain1 = 0;
2232 ti.freq1 = 0;
2233 ixj_init_tone(j, &ti);
2234 ti.tone_index = 19;
2235 ti.gain0 = 1;
2236 ti.freq0 = hz1500;
2237 ti.gain1 = 0;
2238 ti.freq1 = 0;
2239 ixj_init_tone(j, &ti);
2240 ti.tone_index = 20;
2241 ti.gain0 = 1;
2242 ti.freq0 = hz1600;
2243 ti.gain1 = 0;
2244 ti.freq1 = 0;
2245 ixj_init_tone(j, &ti);
2246 ti.tone_index = 21;
2247 ti.gain0 = 1;
2248 ti.freq0 = hz1800;
2249 ti.gain1 = 0;
2250 ti.freq1 = 0;
2251 ixj_init_tone(j, &ti);
2252 ti.tone_index = 22;
2253 ti.gain0 = 1;
2254 ti.freq0 = hz2100;
2255 ti.gain1 = 0;
2256 ti.freq1 = 0;
2257 ixj_init_tone(j, &ti);
2258 ti.tone_index = 23;
2259 ti.gain0 = 1;
2260 ti.freq0 = hz1300;
2261 ti.gain1 = 0;
2262 ti.freq1 = 0;
2263 ixj_init_tone(j, &ti);
2264 ti.tone_index = 24;
2265 ti.gain0 = 1;
2266 ti.freq0 = hz2450;
2267 ti.gain1 = 0;
2268 ti.freq1 = 0;
2269 ixj_init_tone(j, &ti);
2270 ti.tone_index = 25;
2271 ti.gain0 = 1;
2272 ti.freq0 = hz350;
2273 ti.gain1 = 0;
2274 ti.freq1 = hz440;
2275 ixj_init_tone(j, &ti);
2276 ti.tone_index = 26;
2277 ti.gain0 = 1;
2278 ti.freq0 = hz440;
2279 ti.gain1 = 0;
2280 ti.freq1 = hz480;
2281 ixj_init_tone(j, &ti);
2282 ti.tone_index = 27;
2283 ti.gain0 = 1;
2284 ti.freq0 = hz480;
2285 ti.gain1 = 0;
2286 ti.freq1 = hz620;
2287 ixj_init_tone(j, &ti);
2289 set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
2291 set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
2293 j->ex.bits.dtmf_ready = 0;
2294 j->dtmf_state = 0;
2295 j->dtmf_wp = j->dtmf_rp = 0;
2296 j->rec_mode = j->play_mode = -1;
2297 j->flags.ringing = 0;
2298 j->maxrings = MAXRINGS;
2299 j->ring_cadence = USA_RING_CADENCE;
2300 if(j->cadence_f[5].enable) {
2301 j->cadence_f[5].enable = j->cadence_f[5].en_filter = j->cadence_f[5].state = 0;
2303 j->drybuffer = 0;
2304 j->winktime = 320;
2305 j->flags.dtmf_oob = 0;
2306 for (cnt = 0; cnt < 4; cnt++)
2307 j->cadence_f[cnt].enable = 0;
2309 idle(j);
2311 if(j->cardtype == QTI_PHONECARD) {
2312 SLIC_SetState(PLD_SLIC_STATE_OC, j);
2315 if (file_p->f_mode & FMODE_READ)
2316 j->readers--;
2317 if (file_p->f_mode & FMODE_WRITE)
2318 j->writers--;
2320 if (j->read_buffer && !j->readers) {
2321 kfree(j->read_buffer);
2322 j->read_buffer = NULL;
2323 j->read_buffer_size = 0;
2325 if (j->write_buffer && !j->writers) {
2326 kfree(j->write_buffer);
2327 j->write_buffer = NULL;
2328 j->write_buffer_size = 0;
2330 j->rec_codec = j->play_codec = 0;
2331 j->rec_frame_size = j->play_frame_size = 0;
2332 j->flags.cidsent = j->flags.cidring = 0;
2333 ixj_fasync(-1, file_p, 0); /* remove from list of async notification */
2335 if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) {
2336 ixj_set_port(j, PORT_PSTN);
2337 daa_set_mode(j, SOP_PU_SLEEP);
2338 ixj_set_pots(j, 1);
2340 ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
2342 /* Set up the default signals for events */
2343 for (cnt = 0; cnt < 35; cnt++)
2344 j->ixj_signals[cnt] = SIGIO;
2346 /* Set the excetion signal enable flags */
2347 j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
2348 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 =
2349 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;
2351 file_p->private_data = NULL;
2352 clear_bit(board, &j->busyflags);
2353 return 0;
2356 static int read_filters(IXJ *j)
2358 unsigned short fc, cnt, trg;
2359 int var;
2361 trg = 0;
2362 if (ixj_WriteDSPCommand(0x5144, j)) {
2363 if(ixjdebug & 0x0001) {
2364 printk(KERN_INFO "Read Frame Counter failed!\n");
2366 return -1;
2368 fc = j->ssr.high << 8 | j->ssr.low;
2369 if (fc == j->frame_count)
2370 return 1;
2372 j->frame_count = fc;
2374 if (j->dtmf_proc)
2375 return 1;
2377 var = 10;
2379 for (cnt = 0; cnt < 4; cnt++) {
2380 if (ixj_WriteDSPCommand(0x5154 + cnt, j)) {
2381 if(ixjdebug & 0x0001) {
2382 printk(KERN_INFO "Select Filter %d failed!\n", cnt);
2384 return -1;
2386 if (ixj_WriteDSPCommand(0x515C, j)) {
2387 if(ixjdebug & 0x0001) {
2388 printk(KERN_INFO "Read Filter History %d failed!\n", cnt);
2390 return -1;
2392 j->filter_hist[cnt] = j->ssr.high << 8 | j->ssr.low;
2394 if (j->cadence_f[cnt].enable) {
2395 if (j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) {
2396 if (j->cadence_f[cnt].state == 0) {
2397 j->cadence_f[cnt].state = 1;
2398 j->cadence_f[cnt].on1min = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 - var)) / 10000));
2399 j->cadence_f[cnt].on1dot = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100)) / 10000));
2400 j->cadence_f[cnt].on1max = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 + var)) / 10000));
2401 } else if (j->cadence_f[cnt].state == 2 &&
2402 (time_after(jiffies, j->cadence_f[cnt].off1min) &&
2403 time_before(jiffies, j->cadence_f[cnt].off1max))) {
2404 if (j->cadence_f[cnt].on2) {
2405 j->cadence_f[cnt].state = 3;
2406 j->cadence_f[cnt].on2min = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 - var)) / 10000));
2407 j->cadence_f[cnt].on2dot = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100)) / 10000));
2408 j->cadence_f[cnt].on2max = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 + var)) / 10000));
2409 } else {
2410 j->cadence_f[cnt].state = 7;
2412 } else if (j->cadence_f[cnt].state == 4 &&
2413 (time_after(jiffies, j->cadence_f[cnt].off2min) &&
2414 time_before(jiffies, j->cadence_f[cnt].off2max))) {
2415 if (j->cadence_f[cnt].on3) {
2416 j->cadence_f[cnt].state = 5;
2417 j->cadence_f[cnt].on3min = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 - var)) / 10000));
2418 j->cadence_f[cnt].on3dot = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100)) / 10000));
2419 j->cadence_f[cnt].on3max = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 + var)) / 10000));
2420 } else {
2421 j->cadence_f[cnt].state = 7;
2423 } else {
2424 j->cadence_f[cnt].state = 0;
2426 } else if (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)) {
2427 if (j->cadence_f[cnt].state == 1) {
2428 if(!j->cadence_f[cnt].on1) {
2429 j->cadence_f[cnt].state = 7;
2430 } else if((time_after(jiffies, j->cadence_f[cnt].on1min) &&
2431 time_before(jiffies, j->cadence_f[cnt].on1max))) {
2432 if(j->cadence_f[cnt].off1) {
2433 j->cadence_f[cnt].state = 2;
2434 j->cadence_f[cnt].off1min = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 - var)) / 10000));
2435 j->cadence_f[cnt].off1dot = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100)) / 10000));
2436 j->cadence_f[cnt].off1max = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 + var)) / 10000));
2437 } else {
2438 j->cadence_f[cnt].state = 7;
2440 } else {
2441 j->cadence_f[cnt].state = 0;
2443 } else if (j->cadence_f[cnt].state == 3) {
2444 if((time_after(jiffies, j->cadence_f[cnt].on2min) &&
2445 time_before(jiffies, j->cadence_f[cnt].on2max))) {
2446 if(j->cadence_f[cnt].off2) {
2447 j->cadence_f[cnt].state = 4;
2448 j->cadence_f[cnt].off2min = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 - var)) / 10000));
2449 j->cadence_f[cnt].off2dot = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100)) / 10000));
2450 j->cadence_f[cnt].off2max = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 + var)) / 10000));
2451 } else {
2452 j->cadence_f[cnt].state = 7;
2454 } else {
2455 j->cadence_f[cnt].state = 0;
2457 } else if (j->cadence_f[cnt].state == 5) {
2458 if ((time_after(jiffies, j->cadence_f[cnt].on3min) &&
2459 time_before(jiffies, j->cadence_f[cnt].on3max))) {
2460 if(j->cadence_f[cnt].off3) {
2461 j->cadence_f[cnt].state = 6;
2462 j->cadence_f[cnt].off3min = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 - var)) / 10000));
2463 j->cadence_f[cnt].off3dot = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100)) / 10000));
2464 j->cadence_f[cnt].off3max = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 + var)) / 10000));
2465 } else {
2466 j->cadence_f[cnt].state = 7;
2468 } else {
2469 j->cadence_f[cnt].state = 0;
2471 } else {
2472 j->cadence_f[cnt].state = 0;
2474 } else {
2475 switch(j->cadence_f[cnt].state) {
2476 case 1:
2477 if(time_after(jiffies, j->cadence_f[cnt].on1dot) &&
2478 !j->cadence_f[cnt].off1 &&
2479 !j->cadence_f[cnt].on2 && !j->cadence_f[cnt].off2 &&
2480 !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
2481 j->cadence_f[cnt].state = 7;
2483 break;
2484 case 3:
2485 if(time_after(jiffies, j->cadence_f[cnt].on2dot) &&
2486 !j->cadence_f[cnt].off2 &&
2487 !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
2488 j->cadence_f[cnt].state = 7;
2490 break;
2491 case 5:
2492 if(time_after(jiffies, j->cadence_f[cnt].on3dot) &&
2493 !j->cadence_f[cnt].off3) {
2494 j->cadence_f[cnt].state = 7;
2496 break;
2500 if (ixjdebug & 0x0040) {
2501 printk(KERN_INFO "IXJ Tone Cadence state = %d /dev/phone%d at %ld\n", j->cadence_f[cnt].state, j->board, jiffies);
2502 switch(j->cadence_f[cnt].state) {
2503 case 0:
2504 printk(KERN_INFO "IXJ /dev/phone%d No Tone detected\n", j->board);
2505 break;
2506 case 1:
2507 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %u %ld - %ld - %ld\n", j->board,
2508 j->cadence_f[cnt].on1, j->cadence_f[cnt].on1min, j->cadence_f[cnt].on1dot, j->cadence_f[cnt].on1max);
2509 break;
2510 case 2:
2511 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off1min,
2512 j->cadence_f[cnt].off1max);
2513 break;
2514 case 3:
2515 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on2min,
2516 j->cadence_f[cnt].on2max);
2517 break;
2518 case 4:
2519 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off2min,
2520 j->cadence_f[cnt].off2max);
2521 break;
2522 case 5:
2523 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on3min,
2524 j->cadence_f[cnt].on3max);
2525 break;
2526 case 6:
2527 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off3min,
2528 j->cadence_f[cnt].off3max);
2529 break;
2533 if (j->cadence_f[cnt].state == 7) {
2534 j->cadence_f[cnt].state = 0;
2535 if (j->cadence_f[cnt].enable == 1)
2536 j->cadence_f[cnt].enable = 0;
2537 switch (cnt) {
2538 case 0:
2539 if(ixjdebug & 0x0020) {
2540 printk(KERN_INFO "Filter Cadence 0 triggered %ld\n", jiffies);
2542 j->ex.bits.fc0 = 1;
2543 ixj_kill_fasync(j, SIG_FC0, POLL_IN);
2544 break;
2545 case 1:
2546 if(ixjdebug & 0x0020) {
2547 printk(KERN_INFO "Filter Cadence 1 triggered %ld\n", jiffies);
2549 j->ex.bits.fc1 = 1;
2550 ixj_kill_fasync(j, SIG_FC1, POLL_IN);
2551 break;
2552 case 2:
2553 if(ixjdebug & 0x0020) {
2554 printk(KERN_INFO "Filter Cadence 2 triggered %ld\n", jiffies);
2556 j->ex.bits.fc2 = 1;
2557 ixj_kill_fasync(j, SIG_FC2, POLL_IN);
2558 break;
2559 case 3:
2560 if(ixjdebug & 0x0020) {
2561 printk(KERN_INFO "Filter Cadence 3 triggered %ld\n", jiffies);
2563 j->ex.bits.fc3 = 1;
2564 ixj_kill_fasync(j, SIG_FC3, POLL_IN);
2565 break;
2568 if (j->filter_en[cnt] && ((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) ||
2569 (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)))) {
2570 if((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12))) {
2571 trg = 1;
2572 } else if((j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3))) {
2573 trg = 0;
2575 switch (cnt) {
2576 case 0:
2577 if(ixjdebug & 0x0020) {
2578 printk(KERN_INFO "Filter 0 triggered %d at %ld\n", trg, jiffies);
2580 j->ex.bits.f0 = 1;
2581 ixj_kill_fasync(j, SIG_F0, POLL_IN);
2582 break;
2583 case 1:
2584 if(ixjdebug & 0x0020) {
2585 printk(KERN_INFO "Filter 1 triggered %d at %ld\n", trg, jiffies);
2587 j->ex.bits.f1 = 1;
2588 ixj_kill_fasync(j, SIG_F1, POLL_IN);
2589 break;
2590 case 2:
2591 if(ixjdebug & 0x0020) {
2592 printk(KERN_INFO "Filter 2 triggered %d at %ld\n", trg, jiffies);
2594 j->ex.bits.f2 = 1;
2595 ixj_kill_fasync(j, SIG_F2, POLL_IN);
2596 break;
2597 case 3:
2598 if(ixjdebug & 0x0020) {
2599 printk(KERN_INFO "Filter 3 triggered %d at %ld\n", trg, jiffies);
2601 j->ex.bits.f3 = 1;
2602 ixj_kill_fasync(j, SIG_F3, POLL_IN);
2603 break;
2607 return 0;
2610 static int LineMonitor(IXJ *j)
2612 if (j->dtmf_proc) {
2613 return -1;
2615 j->dtmf_proc = 1;
2617 if (ixj_WriteDSPCommand(0x7000, j)) /* Line Monitor */
2618 return -1;
2620 j->dtmf.bytes.high = j->ssr.high;
2621 j->dtmf.bytes.low = j->ssr.low;
2622 if (!j->dtmf_state && j->dtmf.bits.dtmf_valid) {
2623 j->dtmf_state = 1;
2624 j->dtmf_current = j->dtmf.bits.digit;
2626 if (j->dtmf_state && !j->dtmf.bits.dtmf_valid) /* && j->dtmf_wp != j->dtmf_rp) */
2628 if(!j->cidcw_wait) {
2629 j->dtmfbuffer[j->dtmf_wp] = j->dtmf_current;
2630 j->dtmf_wp++;
2631 if (j->dtmf_wp == 79)
2632 j->dtmf_wp = 0;
2633 j->ex.bits.dtmf_ready = 1;
2634 if(j->ex_sig.bits.dtmf_ready) {
2635 ixj_kill_fasync(j, SIG_DTMF_READY, POLL_IN);
2638 else if(j->dtmf_current == 0x00 || j->dtmf_current == 0x0D) {
2639 if(ixjdebug & 0x0020) {
2640 printk("IXJ phone%d saw CIDCW Ack DTMF %d from display at %ld\n", j->board, j->dtmf_current, jiffies);
2642 j->flags.cidcw_ack = 1;
2644 j->dtmf_state = 0;
2646 j->dtmf_proc = 0;
2648 return 0;
2651 /************************************************************************
2653 * Functions to allow alaw <-> ulaw conversions.
2655 ************************************************************************/
2657 static void ulaw2alaw(unsigned char *buff, unsigned long len)
2659 static unsigned char table_ulaw2alaw[] =
2661 0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D,
2662 0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25,
2663 0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D,
2664 0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35,
2665 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02,
2666 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A,
2667 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12,
2668 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B,
2669 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63,
2670 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79,
2671 0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71,
2672 0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D,
2673 0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45,
2674 0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D,
2675 0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51,
2676 0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5,
2677 0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD,
2678 0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5,
2679 0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD,
2680 0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5,
2681 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82,
2682 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A,
2683 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92,
2684 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB,
2685 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3,
2686 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9,
2687 0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1,
2688 0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD,
2689 0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5,
2690 0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD,
2691 0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1,
2692 0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5
2695 while (len--)
2697 *buff = table_ulaw2alaw[*(unsigned char *)buff];
2698 buff++;
2702 static void alaw2ulaw(unsigned char *buff, unsigned long len)
2704 static unsigned char table_alaw2ulaw[] =
2706 0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C,
2707 0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24,
2708 0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C,
2709 0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34,
2710 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D,
2711 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
2712 0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D,
2713 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15,
2714 0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65,
2715 0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E,
2716 0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A,
2717 0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D,
2718 0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B,
2719 0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43,
2720 0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59,
2721 0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51,
2722 0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC,
2723 0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4,
2724 0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC,
2725 0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4,
2726 0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D,
2727 0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85,
2728 0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D,
2729 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95,
2730 0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5,
2731 0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE,
2732 0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA,
2733 0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED,
2734 0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB,
2735 0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3,
2736 0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9,
2737 0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1
2740 while (len--)
2742 *buff = table_alaw2ulaw[*(unsigned char *)buff];
2743 buff++;
2747 static ssize_t ixj_read(struct file * file_p, char __user *buf, size_t length, loff_t * ppos)
2749 unsigned long i = *ppos;
2750 IXJ * j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
2752 DECLARE_WAITQUEUE(wait, current);
2754 if (j->flags.inread)
2755 return -EALREADY;
2757 j->flags.inread = 1;
2759 add_wait_queue(&j->read_q, &wait);
2760 set_current_state(TASK_INTERRUPTIBLE);
2761 mb();
2763 while (!j->read_buffer_ready || (j->dtmf_state && j->flags.dtmf_oob)) {
2764 ++j->read_wait;
2765 if (file_p->f_flags & O_NONBLOCK) {
2766 set_current_state(TASK_RUNNING);
2767 remove_wait_queue(&j->read_q, &wait);
2768 j->flags.inread = 0;
2769 return -EAGAIN;
2771 if (!ixj_hookstate(j)) {
2772 set_current_state(TASK_RUNNING);
2773 remove_wait_queue(&j->read_q, &wait);
2774 j->flags.inread = 0;
2775 return 0;
2777 interruptible_sleep_on(&j->read_q);
2778 if (signal_pending(current)) {
2779 set_current_state(TASK_RUNNING);
2780 remove_wait_queue(&j->read_q, &wait);
2781 j->flags.inread = 0;
2782 return -EINTR;
2786 remove_wait_queue(&j->read_q, &wait);
2787 set_current_state(TASK_RUNNING);
2788 /* Don't ever copy more than the user asks */
2789 if(j->rec_codec == ALAW)
2790 ulaw2alaw(j->read_buffer, min(length, j->read_buffer_size));
2791 i = copy_to_user(buf, j->read_buffer, min(length, j->read_buffer_size));
2792 j->read_buffer_ready = 0;
2793 if (i) {
2794 j->flags.inread = 0;
2795 return -EFAULT;
2796 } else {
2797 j->flags.inread = 0;
2798 return min(length, j->read_buffer_size);
2802 static ssize_t ixj_enhanced_read(struct file * file_p, char __user *buf, size_t length,
2803 loff_t * ppos)
2805 int pre_retval;
2806 ssize_t read_retval = 0;
2807 IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
2809 pre_retval = ixj_PreRead(j, 0L);
2810 switch (pre_retval) {
2811 case NORMAL:
2812 read_retval = ixj_read(file_p, buf, length, ppos);
2813 ixj_PostRead(j, 0L);
2814 break;
2815 case NOPOST:
2816 read_retval = ixj_read(file_p, buf, length, ppos);
2817 break;
2818 case POSTONLY:
2819 ixj_PostRead(j, 0L);
2820 break;
2821 default:
2822 read_retval = pre_retval;
2824 return read_retval;
2827 static ssize_t ixj_write(struct file *file_p, const char __user *buf, size_t count, loff_t * ppos)
2829 unsigned long i = *ppos;
2830 IXJ *j = file_p->private_data;
2832 DECLARE_WAITQUEUE(wait, current);
2834 if (j->flags.inwrite)
2835 return -EALREADY;
2837 j->flags.inwrite = 1;
2839 add_wait_queue(&j->write_q, &wait);
2840 set_current_state(TASK_INTERRUPTIBLE);
2841 mb();
2844 while (!j->write_buffers_empty) {
2845 ++j->write_wait;
2846 if (file_p->f_flags & O_NONBLOCK) {
2847 set_current_state(TASK_RUNNING);
2848 remove_wait_queue(&j->write_q, &wait);
2849 j->flags.inwrite = 0;
2850 return -EAGAIN;
2852 if (!ixj_hookstate(j)) {
2853 set_current_state(TASK_RUNNING);
2854 remove_wait_queue(&j->write_q, &wait);
2855 j->flags.inwrite = 0;
2856 return 0;
2858 interruptible_sleep_on(&j->write_q);
2859 if (signal_pending(current)) {
2860 set_current_state(TASK_RUNNING);
2861 remove_wait_queue(&j->write_q, &wait);
2862 j->flags.inwrite = 0;
2863 return -EINTR;
2866 set_current_state(TASK_RUNNING);
2867 remove_wait_queue(&j->write_q, &wait);
2868 if (j->write_buffer_wp + count >= j->write_buffer_end)
2869 j->write_buffer_wp = j->write_buffer;
2870 i = copy_from_user(j->write_buffer_wp, buf, min(count, j->write_buffer_size));
2871 if (i) {
2872 j->flags.inwrite = 0;
2873 return -EFAULT;
2875 if(j->play_codec == ALAW)
2876 alaw2ulaw(j->write_buffer_wp, min(count, j->write_buffer_size));
2877 j->flags.inwrite = 0;
2878 return min(count, j->write_buffer_size);
2881 static ssize_t ixj_enhanced_write(struct file * file_p, const char __user *buf, size_t count, loff_t * ppos)
2883 int pre_retval;
2884 ssize_t write_retval = 0;
2886 IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
2888 pre_retval = ixj_PreWrite(j, 0L);
2889 switch (pre_retval) {
2890 case NORMAL:
2891 write_retval = ixj_write(file_p, buf, count, ppos);
2892 if (write_retval > 0) {
2893 ixj_PostWrite(j, 0L);
2894 j->write_buffer_wp += write_retval;
2895 j->write_buffers_empty--;
2897 break;
2898 case NOPOST:
2899 write_retval = ixj_write(file_p, buf, count, ppos);
2900 if (write_retval > 0) {
2901 j->write_buffer_wp += write_retval;
2902 j->write_buffers_empty--;
2904 break;
2905 case POSTONLY:
2906 ixj_PostWrite(j, 0L);
2907 break;
2908 default:
2909 write_retval = pre_retval;
2911 return write_retval;
2914 static void ixj_read_frame(IXJ *j)
2916 int cnt, dly;
2918 if (j->read_buffer) {
2919 for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
2920 if (!(cnt % 16) && !IsRxReady(j)) {
2921 dly = 0;
2922 while (!IsRxReady(j)) {
2923 if (dly++ > 5) {
2924 dly = 0;
2925 break;
2927 udelay(10);
2930 /* Throw away word 0 of the 8021 compressed format to get standard G.729. */
2931 if (j->rec_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
2932 inb_p(j->DSPbase + 0x0E);
2933 inb_p(j->DSPbase + 0x0F);
2935 *(j->read_buffer + cnt) = inb_p(j->DSPbase + 0x0E);
2936 *(j->read_buffer + cnt + 1) = inb_p(j->DSPbase + 0x0F);
2938 ++j->framesread;
2939 if (j->intercom != -1) {
2940 if (IsTxReady(get_ixj(j->intercom))) {
2941 for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
2942 if (!(cnt % 16) && !IsTxReady(j)) {
2943 dly = 0;
2944 while (!IsTxReady(j)) {
2945 if (dly++ > 5) {
2946 dly = 0;
2947 break;
2949 udelay(10);
2952 outb_p(*(j->read_buffer + cnt), get_ixj(j->intercom)->DSPbase + 0x0C);
2953 outb_p(*(j->read_buffer + cnt + 1), get_ixj(j->intercom)->DSPbase + 0x0D);
2955 get_ixj(j->intercom)->frameswritten++;
2957 } else {
2958 j->read_buffer_ready = 1;
2959 wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
2961 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
2963 if(j->ixj_signals[SIG_READ_READY])
2964 ixj_kill_fasync(j, SIG_READ_READY, POLL_OUT);
2969 static short fsk[][6][20] =
2973 0, 17846, 29934, 32364, 24351, 8481, -10126, -25465, -32587, -29196,
2974 -16384, 1715, 19260, 30591, 32051, 23170, 6813, -11743, -26509, -32722
2977 -28377, -14876, 3425, 20621, 31163, 31650, 21925, 5126, -13328, -27481,
2978 -32767, -27481, -13328, 5126, 21925, 31650, 31163, 20621, 3425, -14876
2981 -28377, -32722, -26509, -11743, 6813, 23170, 32051, 30591, 19260, 1715,
2982 -16384, -29196, -32587, -25465, -10126, 8481, 24351, 32364, 29934, 17846
2985 0, -17846, -29934, -32364, -24351, -8481, 10126, 25465, 32587, 29196,
2986 16384, -1715, -19260, -30591, -32051, -23170, -6813, 11743, 26509, 32722
2989 28377, 14876, -3425, -20621, -31163, -31650, -21925, -5126, 13328, 27481,
2990 32767, 27481, 13328, -5126, -21925, -31650, -31163, -20621, -3425, 14876
2993 28377, 32722, 26509, 11743, -6813, -23170, -32051, -30591, -19260, -1715,
2994 16384, 29196, 32587, 25465, 10126, -8481, -24351, -32364, -29934, -17846
2999 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126,
3000 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126
3003 -28377, -21925, -13328, -3425, 6813, 16384, 24351, 29934, 32587, 32051,
3004 28377, 21925, 13328, 3425, -6813, -16384, -24351, -29934, -32587, -32051
3007 -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925,
3008 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925
3011 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126,
3012 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126
3015 28377, 21925, 13328, 3425, -6813, -16383, -24351, -29934, -32587, -32051,
3016 -28377, -21925, -13328, -3425, 6813, 16383, 24351, 29934, 32587, 32051
3019 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925,
3020 -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925
3026 static void ixj_write_cid_bit(IXJ *j, int bit)
3028 while (j->fskcnt < 20) {
3029 if(j->fskdcnt < (j->fsksize - 1))
3030 j->fskdata[j->fskdcnt++] = fsk[bit][j->fskz][j->fskcnt];
3032 j->fskcnt += 3;
3034 j->fskcnt %= 20;
3036 if (!bit)
3037 j->fskz++;
3038 if (j->fskz >= 6)
3039 j->fskz = 0;
3043 static void ixj_write_cid_byte(IXJ *j, char byte)
3045 IXJ_CBYTE cb;
3047 cb.cbyte = byte;
3048 ixj_write_cid_bit(j, 0);
3049 ixj_write_cid_bit(j, cb.cbits.b0 ? 1 : 0);
3050 ixj_write_cid_bit(j, cb.cbits.b1 ? 1 : 0);
3051 ixj_write_cid_bit(j, cb.cbits.b2 ? 1 : 0);
3052 ixj_write_cid_bit(j, cb.cbits.b3 ? 1 : 0);
3053 ixj_write_cid_bit(j, cb.cbits.b4 ? 1 : 0);
3054 ixj_write_cid_bit(j, cb.cbits.b5 ? 1 : 0);
3055 ixj_write_cid_bit(j, cb.cbits.b6 ? 1 : 0);
3056 ixj_write_cid_bit(j, cb.cbits.b7 ? 1 : 0);
3057 ixj_write_cid_bit(j, 1);
3060 static void ixj_write_cid_seize(IXJ *j)
3062 int cnt;
3064 for (cnt = 0; cnt < 150; cnt++) {
3065 ixj_write_cid_bit(j, 0);
3066 ixj_write_cid_bit(j, 1);
3068 for (cnt = 0; cnt < 180; cnt++) {
3069 ixj_write_cid_bit(j, 1);
3073 static void ixj_write_cidcw_seize(IXJ *j)
3075 int cnt;
3077 for (cnt = 0; cnt < 80; cnt++) {
3078 ixj_write_cid_bit(j, 1);
3082 static int ixj_write_cid_string(IXJ *j, char *s, int checksum)
3084 int cnt;
3086 for (cnt = 0; cnt < strlen(s); cnt++) {
3087 ixj_write_cid_byte(j, s[cnt]);
3088 checksum = (checksum + s[cnt]);
3090 return checksum;
3093 static void ixj_pad_fsk(IXJ *j, int pad)
3095 int cnt;
3097 for (cnt = 0; cnt < pad; cnt++) {
3098 if(j->fskdcnt < (j->fsksize - 1))
3099 j->fskdata[j->fskdcnt++] = 0x0000;
3101 for (cnt = 0; cnt < 720; cnt++) {
3102 if(j->fskdcnt < (j->fsksize - 1))
3103 j->fskdata[j->fskdcnt++] = 0x0000;
3107 static void ixj_pre_cid(IXJ *j)
3109 j->cid_play_codec = j->play_codec;
3110 j->cid_play_frame_size = j->play_frame_size;
3111 j->cid_play_volume = get_play_volume(j);
3112 j->cid_play_flag = j->flags.playing;
3114 j->cid_rec_codec = j->rec_codec;
3115 j->cid_rec_volume = get_rec_volume(j);
3116 j->cid_rec_flag = j->flags.recording;
3118 j->cid_play_aec_level = j->aec_level;
3120 switch(j->baseframe.low) {
3121 case 0xA0:
3122 j->cid_base_frame_size = 20;
3123 break;
3124 case 0x50:
3125 j->cid_base_frame_size = 10;
3126 break;
3127 case 0xF0:
3128 j->cid_base_frame_size = 30;
3129 break;
3132 ixj_play_stop(j);
3133 ixj_cpt_stop(j);
3135 j->flags.cidplay = 1;
3137 set_base_frame(j, 30);
3138 set_play_codec(j, LINEAR16);
3139 set_play_volume(j, 0x1B);
3140 ixj_play_start(j);
3143 static void ixj_post_cid(IXJ *j)
3145 ixj_play_stop(j);
3147 if(j->cidsize > 5000) {
3148 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
3150 j->flags.cidplay = 0;
3151 if(ixjdebug & 0x0200) {
3152 printk("IXJ phone%d Finished Playing CallerID data %ld\n", j->board, jiffies);
3155 ixj_fsk_free(j);
3157 j->fskdcnt = 0;
3158 set_base_frame(j, j->cid_base_frame_size);
3159 set_play_codec(j, j->cid_play_codec);
3160 ixj_aec_start(j, j->cid_play_aec_level);
3161 set_play_volume(j, j->cid_play_volume);
3163 set_rec_codec(j, j->cid_rec_codec);
3164 set_rec_volume(j, j->cid_rec_volume);
3166 if(j->cid_rec_flag)
3167 ixj_record_start(j);
3169 if(j->cid_play_flag)
3170 ixj_play_start(j);
3172 if(j->cid_play_flag) {
3173 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3177 static void ixj_write_cid(IXJ *j)
3179 char sdmf1[50];
3180 char sdmf2[50];
3181 char sdmf3[80];
3182 char mdmflen, len1, len2, len3;
3183 int pad;
3185 int checksum = 0;
3187 if (j->dsp.low == 0x20 || j->flags.cidplay)
3188 return;
3190 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3191 j->cidsize = j->cidcnt = 0;
3193 ixj_fsk_alloc(j);
3195 strcpy(sdmf1, j->cid_send.month);
3196 strcat(sdmf1, j->cid_send.day);
3197 strcat(sdmf1, j->cid_send.hour);
3198 strcat(sdmf1, j->cid_send.min);
3199 strcpy(sdmf2, j->cid_send.number);
3200 strcpy(sdmf3, j->cid_send.name);
3202 len1 = strlen(sdmf1);
3203 len2 = strlen(sdmf2);
3204 len3 = strlen(sdmf3);
3205 mdmflen = len1 + len2 + len3 + 6;
3207 while(1){
3208 ixj_write_cid_seize(j);
3210 ixj_write_cid_byte(j, 0x80);
3211 checksum = 0x80;
3212 ixj_write_cid_byte(j, mdmflen);
3213 checksum = checksum + mdmflen;
3215 ixj_write_cid_byte(j, 0x01);
3216 checksum = checksum + 0x01;
3217 ixj_write_cid_byte(j, len1);
3218 checksum = checksum + len1;
3219 checksum = ixj_write_cid_string(j, sdmf1, checksum);
3220 if(ixj_hookstate(j) & 1)
3221 break;
3223 ixj_write_cid_byte(j, 0x02);
3224 checksum = checksum + 0x02;
3225 ixj_write_cid_byte(j, len2);
3226 checksum = checksum + len2;
3227 checksum = ixj_write_cid_string(j, sdmf2, checksum);
3228 if(ixj_hookstate(j) & 1)
3229 break;
3231 ixj_write_cid_byte(j, 0x07);
3232 checksum = checksum + 0x07;
3233 ixj_write_cid_byte(j, len3);
3234 checksum = checksum + len3;
3235 checksum = ixj_write_cid_string(j, sdmf3, checksum);
3236 if(ixj_hookstate(j) & 1)
3237 break;
3239 checksum %= 256;
3240 checksum ^= 0xFF;
3241 checksum += 1;
3243 ixj_write_cid_byte(j, (char) checksum);
3245 pad = j->fskdcnt % 240;
3246 if (pad) {
3247 pad = 240 - pad;
3249 ixj_pad_fsk(j, pad);
3250 break;
3253 ixj_write_frame(j);
3256 static void ixj_write_cidcw(IXJ *j)
3258 IXJ_TONE ti;
3260 char sdmf1[50];
3261 char sdmf2[50];
3262 char sdmf3[80];
3263 char mdmflen, len1, len2, len3;
3264 int pad;
3266 int checksum = 0;
3268 if (j->dsp.low == 0x20 || j->flags.cidplay)
3269 return;
3271 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3272 j->cidsize = j->cidcnt = 0;
3274 ixj_fsk_alloc(j);
3276 j->flags.cidcw_ack = 0;
3278 ti.tone_index = 23;
3279 ti.gain0 = 1;
3280 ti.freq0 = hz440;
3281 ti.gain1 = 0;
3282 ti.freq1 = 0;
3283 ixj_init_tone(j, &ti);
3285 ixj_set_tone_on(1500, j);
3286 ixj_set_tone_off(32, j);
3287 if(ixjdebug & 0x0200) {
3288 printk("IXJ cidcw phone%d first tone start at %ld\n", j->board, jiffies);
3290 ixj_play_tone(j, 23);
3292 clear_bit(j->board, &j->busyflags);
3293 while(j->tone_state)
3294 schedule_timeout_interruptible(1);
3295 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
3296 schedule_timeout_interruptible(1);
3297 if(ixjdebug & 0x0200) {
3298 printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies);
3301 ti.tone_index = 24;
3302 ti.gain0 = 1;
3303 ti.freq0 = hz2130;
3304 ti.gain1 = 0;
3305 ti.freq1 = hz2750;
3306 ixj_init_tone(j, &ti);
3308 ixj_set_tone_off(10, j);
3309 ixj_set_tone_on(600, j);
3310 if(ixjdebug & 0x0200) {
3311 printk("IXJ cidcw phone%d second tone start at %ld\n", j->board, jiffies);
3313 ixj_play_tone(j, 24);
3315 clear_bit(j->board, &j->busyflags);
3316 while(j->tone_state)
3317 schedule_timeout_interruptible(1);
3318 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
3319 schedule_timeout_interruptible(1);
3320 if(ixjdebug & 0x0200) {
3321 printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies);
3324 j->cidcw_wait = jiffies + ((50 * hertz) / 100);
3326 clear_bit(j->board, &j->busyflags);
3327 while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait))
3328 schedule_timeout_interruptible(1);
3329 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
3330 schedule_timeout_interruptible(1);
3331 j->cidcw_wait = 0;
3332 if(!j->flags.cidcw_ack) {
3333 if(ixjdebug & 0x0200) {
3334 printk("IXJ cidcw phone%d did not receive ACK from display %ld\n", j->board, jiffies);
3336 ixj_post_cid(j);
3337 if(j->cid_play_flag) {
3338 wake_up_interruptible(&j->write_q); /* Wake any blocked readers */
3340 return;
3341 } else {
3342 ixj_pre_cid(j);
3344 j->flags.cidcw_ack = 0;
3345 strcpy(sdmf1, j->cid_send.month);
3346 strcat(sdmf1, j->cid_send.day);
3347 strcat(sdmf1, j->cid_send.hour);
3348 strcat(sdmf1, j->cid_send.min);
3349 strcpy(sdmf2, j->cid_send.number);
3350 strcpy(sdmf3, j->cid_send.name);
3352 len1 = strlen(sdmf1);
3353 len2 = strlen(sdmf2);
3354 len3 = strlen(sdmf3);
3355 mdmflen = len1 + len2 + len3 + 6;
3357 ixj_write_cidcw_seize(j);
3359 ixj_write_cid_byte(j, 0x80);
3360 checksum = 0x80;
3361 ixj_write_cid_byte(j, mdmflen);
3362 checksum = checksum + mdmflen;
3364 ixj_write_cid_byte(j, 0x01);
3365 checksum = checksum + 0x01;
3366 ixj_write_cid_byte(j, len1);
3367 checksum = checksum + len1;
3368 checksum = ixj_write_cid_string(j, sdmf1, checksum);
3370 ixj_write_cid_byte(j, 0x02);
3371 checksum = checksum + 0x02;
3372 ixj_write_cid_byte(j, len2);
3373 checksum = checksum + len2;
3374 checksum = ixj_write_cid_string(j, sdmf2, checksum);
3376 ixj_write_cid_byte(j, 0x07);
3377 checksum = checksum + 0x07;
3378 ixj_write_cid_byte(j, len3);
3379 checksum = checksum + len3;
3380 checksum = ixj_write_cid_string(j, sdmf3, checksum);
3382 checksum %= 256;
3383 checksum ^= 0xFF;
3384 checksum += 1;
3386 ixj_write_cid_byte(j, (char) checksum);
3388 pad = j->fskdcnt % 240;
3389 if (pad) {
3390 pad = 240 - pad;
3392 ixj_pad_fsk(j, pad);
3393 if(ixjdebug & 0x0200) {
3394 printk("IXJ cidcw phone%d sent FSK data at %ld\n", j->board, jiffies);
3398 static void ixj_write_vmwi(IXJ *j, int msg)
3400 char mdmflen;
3401 int pad;
3403 int checksum = 0;
3405 if (j->dsp.low == 0x20 || j->flags.cidplay)
3406 return;
3408 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3409 j->cidsize = j->cidcnt = 0;
3411 ixj_fsk_alloc(j);
3413 mdmflen = 3;
3415 if (j->port == PORT_POTS)
3416 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
3418 ixj_write_cid_seize(j);
3420 ixj_write_cid_byte(j, 0x82);
3421 checksum = 0x82;
3422 ixj_write_cid_byte(j, mdmflen);
3423 checksum = checksum + mdmflen;
3425 ixj_write_cid_byte(j, 0x0B);
3426 checksum = checksum + 0x0B;
3427 ixj_write_cid_byte(j, 1);
3428 checksum = checksum + 1;
3430 if(msg) {
3431 ixj_write_cid_byte(j, 0xFF);
3432 checksum = checksum + 0xFF;
3434 else {
3435 ixj_write_cid_byte(j, 0x00);
3436 checksum = checksum + 0x00;
3439 checksum %= 256;
3440 checksum ^= 0xFF;
3441 checksum += 1;
3443 ixj_write_cid_byte(j, (char) checksum);
3445 pad = j->fskdcnt % 240;
3446 if (pad) {
3447 pad = 240 - pad;
3449 ixj_pad_fsk(j, pad);
3452 static void ixj_write_frame(IXJ *j)
3454 int cnt, frame_count, dly;
3455 IXJ_WORD dat;
3456 BYTES blankword;
3458 frame_count = 0;
3459 if(j->flags.cidplay) {
3460 for(cnt = 0; cnt < 480; cnt++) {
3461 if (!(cnt % 16) && !IsTxReady(j)) {
3462 dly = 0;
3463 while (!IsTxReady(j)) {
3464 if (dly++ > 5) {
3465 dly = 0;
3466 break;
3468 udelay(10);
3471 dat.word = j->fskdata[j->cidcnt++];
3472 outb_p(dat.bytes.low, j->DSPbase + 0x0C);
3473 outb_p(dat.bytes.high, j->DSPbase + 0x0D);
3474 cnt++;
3476 if(j->cidcnt >= j->fskdcnt) {
3477 ixj_post_cid(j);
3479 /* This may seem rude, but if we just played one frame of FSK data for CallerID
3480 and there is real audio data in the buffer, we need to throw it away because
3481 we just used it's time slot */
3482 if (j->write_buffer_rp > j->write_buffer_wp) {
3483 j->write_buffer_rp += j->cid_play_frame_size * 2;
3484 if (j->write_buffer_rp >= j->write_buffer_end) {
3485 j->write_buffer_rp = j->write_buffer;
3487 j->write_buffers_empty++;
3488 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3490 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
3492 } else if (j->write_buffer && j->write_buffers_empty < 1) {
3493 if (j->write_buffer_wp > j->write_buffer_rp) {
3494 frame_count =
3495 (j->write_buffer_wp - j->write_buffer_rp) / (j->play_frame_size * 2);
3497 if (j->write_buffer_rp > j->write_buffer_wp) {
3498 frame_count =
3499 (j->write_buffer_wp - j->write_buffer) / (j->play_frame_size * 2) +
3500 (j->write_buffer_end - j->write_buffer_rp) / (j->play_frame_size * 2);
3502 if (frame_count >= 1) {
3503 if (j->ver.low == 0x12 && j->play_mode && j->flags.play_first_frame) {
3504 switch (j->play_mode) {
3505 case PLAYBACK_MODE_ULAW:
3506 case PLAYBACK_MODE_ALAW:
3507 blankword.low = blankword.high = 0xFF;
3508 break;
3509 case PLAYBACK_MODE_8LINEAR:
3510 case PLAYBACK_MODE_16LINEAR:
3511 blankword.low = blankword.high = 0x00;
3512 break;
3513 case PLAYBACK_MODE_8LINEAR_WSS:
3514 blankword.low = blankword.high = 0x80;
3515 break;
3517 for (cnt = 0; cnt < 16; cnt++) {
3518 if (!(cnt % 16) && !IsTxReady(j)) {
3519 dly = 0;
3520 while (!IsTxReady(j)) {
3521 if (dly++ > 5) {
3522 dly = 0;
3523 break;
3525 udelay(10);
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++) {
3534 if(cnt == 12) {
3535 blankword.low = 0x02;
3536 blankword.high = 0x00;
3538 else {
3539 blankword.low = blankword.high = 0x00;
3541 if (!(cnt % 16) && !IsTxReady(j)) {
3542 dly = 0;
3543 while (!IsTxReady(j)) {
3544 if (dly++ > 5) {
3545 dly = 0;
3546 break;
3548 udelay(10);
3551 outb_p((blankword.low), j->DSPbase + 0x0C);
3552 outb_p((blankword.high), j->DSPbase + 0x0D);
3554 j->flags.play_first_frame = 0;
3556 for (cnt = 0; cnt < j->play_frame_size * 2; cnt += 2) {
3557 if (!(cnt % 16) && !IsTxReady(j)) {
3558 dly = 0;
3559 while (!IsTxReady(j)) {
3560 if (dly++ > 5) {
3561 dly = 0;
3562 break;
3564 udelay(10);
3567 /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */
3568 if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
3569 if (j->write_buffer_rp[cnt] == 0 &&
3570 j->write_buffer_rp[cnt + 1] == 0 &&
3571 j->write_buffer_rp[cnt + 2] == 0 &&
3572 j->write_buffer_rp[cnt + 3] == 0 &&
3573 j->write_buffer_rp[cnt + 4] == 0 &&
3574 j->write_buffer_rp[cnt + 5] == 0 &&
3575 j->write_buffer_rp[cnt + 6] == 0 &&
3576 j->write_buffer_rp[cnt + 7] == 0 &&
3577 j->write_buffer_rp[cnt + 8] == 0 &&
3578 j->write_buffer_rp[cnt + 9] == 0) {
3579 /* someone is trying to write silence lets make this a type 0 frame. */
3580 outb_p(0x00, j->DSPbase + 0x0C);
3581 outb_p(0x00, j->DSPbase + 0x0D);
3582 } else {
3583 /* so all other frames are type 1. */
3584 outb_p(0x01, j->DSPbase + 0x0C);
3585 outb_p(0x00, j->DSPbase + 0x0D);
3588 outb_p(*(j->write_buffer_rp + cnt), j->DSPbase + 0x0C);
3589 outb_p(*(j->write_buffer_rp + cnt + 1), j->DSPbase + 0x0D);
3590 *(j->write_buffer_rp + cnt) = 0;
3591 *(j->write_buffer_rp + cnt + 1) = 0;
3593 j->write_buffer_rp += j->play_frame_size * 2;
3594 if (j->write_buffer_rp >= j->write_buffer_end) {
3595 j->write_buffer_rp = j->write_buffer;
3597 j->write_buffers_empty++;
3598 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3600 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
3602 ++j->frameswritten;
3604 } else {
3605 j->drybuffer++;
3607 if(j->ixj_signals[SIG_WRITE_READY]) {
3608 ixj_kill_fasync(j, SIG_WRITE_READY, POLL_OUT);
3612 static int idle(IXJ *j)
3614 if (ixj_WriteDSPCommand(0x0000, j)) /* DSP Idle */
3616 return 0;
3618 if (j->ssr.high || j->ssr.low) {
3619 return 0;
3620 } else {
3621 j->play_mode = -1;
3622 j->flags.playing = 0;
3623 j->rec_mode = -1;
3624 j->flags.recording = 0;
3625 return 1;
3629 static int set_base_frame(IXJ *j, int size)
3631 unsigned short cmd;
3632 int cnt;
3634 idle(j);
3635 j->cid_play_aec_level = j->aec_level;
3636 aec_stop(j);
3637 for (cnt = 0; cnt < 10; cnt++) {
3638 if (idle(j))
3639 break;
3641 if (j->ssr.high || j->ssr.low)
3642 return -1;
3643 if (j->dsp.low != 0x20) {
3644 switch (size) {
3645 case 30:
3646 cmd = 0x07F0;
3647 /* Set Base Frame Size to 240 pg9-10 8021 */
3648 break;
3649 case 20:
3650 cmd = 0x07A0;
3651 /* Set Base Frame Size to 160 pg9-10 8021 */
3652 break;
3653 case 10:
3654 cmd = 0x0750;
3655 /* Set Base Frame Size to 80 pg9-10 8021 */
3656 break;
3657 default:
3658 return -1;
3660 } else {
3661 if (size == 30)
3662 return size;
3663 else
3664 return -1;
3666 if (ixj_WriteDSPCommand(cmd, j)) {
3667 j->baseframe.high = j->baseframe.low = 0xFF;
3668 return -1;
3669 } else {
3670 j->baseframe.high = j->ssr.high;
3671 j->baseframe.low = j->ssr.low;
3672 /* If the status returned is 0x0000 (pg9-9 8021) the call failed */
3673 if(j->baseframe.high == 0x00 && j->baseframe.low == 0x00) {
3674 return -1;
3677 ixj_aec_start(j, j->cid_play_aec_level);
3678 return size;
3681 static int set_rec_codec(IXJ *j, int rate)
3683 int retval = 0;
3685 j->rec_codec = rate;
3687 switch (rate) {
3688 case G723_63:
3689 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3690 j->rec_frame_size = 12;
3691 j->rec_mode = 0;
3692 } else {
3693 retval = 1;
3695 break;
3696 case G723_53:
3697 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3698 j->rec_frame_size = 10;
3699 j->rec_mode = 0;
3700 } else {
3701 retval = 1;
3703 break;
3704 case TS85:
3705 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
3706 j->rec_frame_size = 16;
3707 j->rec_mode = 0;
3708 } else {
3709 retval = 1;
3711 break;
3712 case TS48:
3713 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3714 j->rec_frame_size = 9;
3715 j->rec_mode = 0;
3716 } else {
3717 retval = 1;
3719 break;
3720 case TS41:
3721 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3722 j->rec_frame_size = 8;
3723 j->rec_mode = 0;
3724 } else {
3725 retval = 1;
3727 break;
3728 case G728:
3729 if (j->dsp.low != 0x20) {
3730 j->rec_frame_size = 48;
3731 j->rec_mode = 0;
3732 } else {
3733 retval = 1;
3735 break;
3736 case G729:
3737 if (j->dsp.low != 0x20) {
3738 if (!j->flags.g729_loaded) {
3739 retval = 1;
3740 break;
3742 switch (j->baseframe.low) {
3743 case 0xA0:
3744 j->rec_frame_size = 10;
3745 break;
3746 case 0x50:
3747 j->rec_frame_size = 5;
3748 break;
3749 default:
3750 j->rec_frame_size = 15;
3751 break;
3753 j->rec_mode = 0;
3754 } else {
3755 retval = 1;
3757 break;
3758 case G729B:
3759 if (j->dsp.low != 0x20) {
3760 if (!j->flags.g729_loaded) {
3761 retval = 1;
3762 break;
3764 switch (j->baseframe.low) {
3765 case 0xA0:
3766 j->rec_frame_size = 12;
3767 break;
3768 case 0x50:
3769 j->rec_frame_size = 6;
3770 break;
3771 default:
3772 j->rec_frame_size = 18;
3773 break;
3775 j->rec_mode = 0;
3776 } else {
3777 retval = 1;
3779 break;
3780 case ULAW:
3781 switch (j->baseframe.low) {
3782 case 0xA0:
3783 j->rec_frame_size = 80;
3784 break;
3785 case 0x50:
3786 j->rec_frame_size = 40;
3787 break;
3788 default:
3789 j->rec_frame_size = 120;
3790 break;
3792 j->rec_mode = 4;
3793 break;
3794 case ALAW:
3795 switch (j->baseframe.low) {
3796 case 0xA0:
3797 j->rec_frame_size = 80;
3798 break;
3799 case 0x50:
3800 j->rec_frame_size = 40;
3801 break;
3802 default:
3803 j->rec_frame_size = 120;
3804 break;
3806 j->rec_mode = 4;
3807 break;
3808 case LINEAR16:
3809 switch (j->baseframe.low) {
3810 case 0xA0:
3811 j->rec_frame_size = 160;
3812 break;
3813 case 0x50:
3814 j->rec_frame_size = 80;
3815 break;
3816 default:
3817 j->rec_frame_size = 240;
3818 break;
3820 j->rec_mode = 5;
3821 break;
3822 case LINEAR8:
3823 switch (j->baseframe.low) {
3824 case 0xA0:
3825 j->rec_frame_size = 80;
3826 break;
3827 case 0x50:
3828 j->rec_frame_size = 40;
3829 break;
3830 default:
3831 j->rec_frame_size = 120;
3832 break;
3834 j->rec_mode = 6;
3835 break;
3836 case WSS:
3837 switch (j->baseframe.low) {
3838 case 0xA0:
3839 j->rec_frame_size = 80;
3840 break;
3841 case 0x50:
3842 j->rec_frame_size = 40;
3843 break;
3844 default:
3845 j->rec_frame_size = 120;
3846 break;
3848 j->rec_mode = 7;
3849 break;
3850 default:
3851 kfree(j->read_buffer);
3852 j->rec_frame_size = 0;
3853 j->rec_mode = -1;
3854 j->read_buffer = NULL;
3855 j->read_buffer_size = 0;
3856 retval = 1;
3857 break;
3859 return retval;
3862 static int ixj_record_start(IXJ *j)
3864 unsigned short cmd = 0x0000;
3866 if (j->read_buffer) {
3867 ixj_record_stop(j);
3869 j->flags.recording = 1;
3870 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
3872 if(ixjdebug & 0x0002)
3873 printk("IXJ %d Starting Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
3875 if (!j->rec_mode) {
3876 switch (j->rec_codec) {
3877 case G723_63:
3878 cmd = 0x5131;
3879 break;
3880 case G723_53:
3881 cmd = 0x5132;
3882 break;
3883 case TS85:
3884 cmd = 0x5130; /* TrueSpeech 8.5 */
3886 break;
3887 case TS48:
3888 cmd = 0x5133; /* TrueSpeech 4.8 */
3890 break;
3891 case TS41:
3892 cmd = 0x5134; /* TrueSpeech 4.1 */
3894 break;
3895 case G728:
3896 cmd = 0x5135;
3897 break;
3898 case G729:
3899 case G729B:
3900 cmd = 0x5136;
3901 break;
3902 default:
3903 return 1;
3905 if (ixj_WriteDSPCommand(cmd, j))
3906 return -1;
3908 if (!j->read_buffer) {
3909 if (!j->read_buffer)
3910 j->read_buffer = kmalloc(j->rec_frame_size * 2, GFP_ATOMIC);
3911 if (!j->read_buffer) {
3912 printk("Read buffer allocation for ixj board %d failed!\n", j->board);
3913 return -ENOMEM;
3916 j->read_buffer_size = j->rec_frame_size * 2;
3918 if (ixj_WriteDSPCommand(0x5102, j)) /* Set Poll sync mode */
3920 return -1;
3922 switch (j->rec_mode) {
3923 case 0:
3924 cmd = 0x1C03; /* Record C1 */
3926 break;
3927 case 4:
3928 if (j->ver.low == 0x12) {
3929 cmd = 0x1E03; /* Record C1 */
3931 } else {
3932 cmd = 0x1E01; /* Record C1 */
3935 break;
3936 case 5:
3937 if (j->ver.low == 0x12) {
3938 cmd = 0x1E83; /* Record C1 */
3940 } else {
3941 cmd = 0x1E81; /* Record C1 */
3944 break;
3945 case 6:
3946 if (j->ver.low == 0x12) {
3947 cmd = 0x1F03; /* Record C1 */
3949 } else {
3950 cmd = 0x1F01; /* Record C1 */
3953 break;
3954 case 7:
3955 if (j->ver.low == 0x12) {
3956 cmd = 0x1F83; /* Record C1 */
3957 } else {
3958 cmd = 0x1F81; /* Record C1 */
3960 break;
3962 if (ixj_WriteDSPCommand(cmd, j))
3963 return -1;
3965 if (j->flags.playing) {
3966 ixj_aec_start(j, j->aec_level);
3968 return 0;
3971 static void ixj_record_stop(IXJ *j)
3973 if (ixjdebug & 0x0002)
3974 printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
3976 kfree(j->read_buffer);
3977 j->read_buffer = NULL;
3978 j->read_buffer_size = 0;
3979 if (j->rec_mode > -1) {
3980 ixj_WriteDSPCommand(0x5120, j);
3981 j->rec_mode = -1;
3983 j->flags.recording = 0;
3985 static void ixj_vad(IXJ *j, int arg)
3987 if (arg)
3988 ixj_WriteDSPCommand(0x513F, j);
3989 else
3990 ixj_WriteDSPCommand(0x513E, j);
3993 static void set_rec_depth(IXJ *j, int depth)
3995 if (depth > 60)
3996 depth = 60;
3997 if (depth < 0)
3998 depth = 0;
3999 ixj_WriteDSPCommand(0x5180 + depth, j);
4002 static void set_dtmf_prescale(IXJ *j, int volume)
4004 ixj_WriteDSPCommand(0xCF07, j);
4005 ixj_WriteDSPCommand(volume, j);
4008 static int get_dtmf_prescale(IXJ *j)
4010 ixj_WriteDSPCommand(0xCF05, j);
4011 return j->ssr.high << 8 | j->ssr.low;
4014 static void set_rec_volume(IXJ *j, int volume)
4016 if(j->aec_level == AEC_AGC) {
4017 if (ixjdebug & 0x0002)
4018 printk(KERN_INFO "IXJ: /dev/phone%d Setting AGC Threshold to 0x%4.4x\n", j->board, volume);
4019 ixj_WriteDSPCommand(0xCF96, j);
4020 ixj_WriteDSPCommand(volume, j);
4021 } else {
4022 if (ixjdebug & 0x0002)
4023 printk(KERN_INFO "IXJ: /dev/phone %d Setting Record Volume to 0x%4.4x\n", j->board, volume);
4024 ixj_WriteDSPCommand(0xCF03, j);
4025 ixj_WriteDSPCommand(volume, j);
4029 static int set_rec_volume_linear(IXJ *j, int volume)
4031 int newvolume, dsprecmax;
4033 if (ixjdebug & 0x0002)
4034 printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Record Volume to 0x%4.4x\n", j->board, volume);
4035 if(volume > 100 || volume < 0) {
4036 return -1;
4039 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
4040 switch (j->cardtype) {
4041 case QTI_PHONEJACK:
4042 dsprecmax = 0x440;
4043 break;
4044 case QTI_LINEJACK:
4045 dsprecmax = 0x180;
4046 ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
4047 ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
4048 ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
4049 break;
4050 case QTI_PHONEJACK_LITE:
4051 dsprecmax = 0x4C0;
4052 break;
4053 case QTI_PHONEJACK_PCI:
4054 dsprecmax = 0x100;
4055 break;
4056 case QTI_PHONECARD:
4057 dsprecmax = 0x400;
4058 break;
4059 default:
4060 return -1;
4062 newvolume = (dsprecmax * volume) / 100;
4063 set_rec_volume(j, newvolume);
4064 return 0;
4067 static int get_rec_volume(IXJ *j)
4069 if(j->aec_level == AEC_AGC) {
4070 if (ixjdebug & 0x0002)
4071 printk(KERN_INFO "Getting AGC Threshold\n");
4072 ixj_WriteDSPCommand(0xCF86, j);
4073 if (ixjdebug & 0x0002)
4074 printk(KERN_INFO "AGC Threshold is 0x%2.2x%2.2x\n", j->ssr.high, j->ssr.low);
4075 return j->ssr.high << 8 | j->ssr.low;
4076 } else {
4077 if (ixjdebug & 0x0002)
4078 printk(KERN_INFO "Getting Record Volume\n");
4079 ixj_WriteDSPCommand(0xCF01, j);
4080 return j->ssr.high << 8 | j->ssr.low;
4084 static int get_rec_volume_linear(IXJ *j)
4086 int volume, newvolume, dsprecmax;
4088 switch (j->cardtype) {
4089 case QTI_PHONEJACK:
4090 dsprecmax = 0x440;
4091 break;
4092 case QTI_LINEJACK:
4093 dsprecmax = 0x180;
4094 break;
4095 case QTI_PHONEJACK_LITE:
4096 dsprecmax = 0x4C0;
4097 break;
4098 case QTI_PHONEJACK_PCI:
4099 dsprecmax = 0x100;
4100 break;
4101 case QTI_PHONECARD:
4102 dsprecmax = 0x400;
4103 break;
4104 default:
4105 return -1;
4107 volume = get_rec_volume(j);
4108 newvolume = (volume * 100) / dsprecmax;
4109 if(newvolume > 100)
4110 newvolume = 100;
4111 return newvolume;
4114 static int get_rec_level(IXJ *j)
4116 int retval;
4118 ixj_WriteDSPCommand(0xCF88, j);
4120 retval = j->ssr.high << 8 | j->ssr.low;
4121 retval = (retval * 256) / 240;
4122 return retval;
4125 static void ixj_aec_start(IXJ *j, int level)
4127 j->aec_level = level;
4128 if (ixjdebug & 0x0002)
4129 printk(KERN_INFO "AGC set = 0x%2.2x\n", j->aec_level);
4130 if (!level) {
4131 aec_stop(j);
4132 } else {
4133 if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
4134 ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer */
4136 ixj_WriteDSPCommand(0x0300, j);
4138 ixj_WriteDSPCommand(0xB001, j); /* AEC On */
4140 ixj_WriteDSPCommand(0xE013, j); /* Advanced AEC C1 */
4142 switch (level) {
4143 case AEC_LOW:
4144 ixj_WriteDSPCommand(0x0000, j); /* Advanced AEC C2 = off */
4146 ixj_WriteDSPCommand(0xE011, j);
4147 ixj_WriteDSPCommand(0xFFFF, j);
4149 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4150 ixj_WriteDSPCommand(0x0000, j); /* to off */
4152 break;
4154 case AEC_MED:
4155 ixj_WriteDSPCommand(0x0600, j); /* Advanced AEC C2 = on medium */
4157 ixj_WriteDSPCommand(0xE011, j);
4158 ixj_WriteDSPCommand(0x0080, j);
4160 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4161 ixj_WriteDSPCommand(0x0000, j); /* to off */
4163 break;
4165 case AEC_HIGH:
4166 ixj_WriteDSPCommand(0x0C00, j); /* Advanced AEC C2 = on high */
4168 ixj_WriteDSPCommand(0xE011, j);
4169 ixj_WriteDSPCommand(0x0080, j);
4171 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4172 ixj_WriteDSPCommand(0x0000, j); /* to off */
4174 break;
4176 case AEC_AGC:
4177 /* First we have to put the AEC into advance auto mode so that AGC will not conflict with it */
4178 ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
4180 ixj_WriteDSPCommand(0xE011, j);
4181 ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
4183 ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
4185 if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
4186 ixj_WriteDSPCommand(0x0224, j);
4187 else
4188 ixj_WriteDSPCommand(0x1224, j);
4190 ixj_WriteDSPCommand(0xE014, j);
4191 ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */
4193 ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
4195 /* Now we can set the AGC initial parameters and turn it on */
4196 ixj_WriteDSPCommand(0xCF90, j); /* Set AGC Minumum gain */
4197 ixj_WriteDSPCommand(0x0020, j); /* to 0.125 (-18dB) */
4199 ixj_WriteDSPCommand(0xCF91, j); /* Set AGC Maximum gain */
4200 ixj_WriteDSPCommand(0x1000, j); /* to 16 (24dB) */
4202 ixj_WriteDSPCommand(0xCF92, j); /* Set AGC start gain */
4203 ixj_WriteDSPCommand(0x0800, j); /* to 8 (+18dB) */
4205 ixj_WriteDSPCommand(0xCF93, j); /* Set AGC hold time */
4206 ixj_WriteDSPCommand(0x1F40, j); /* to 2 seconds (units are 250us) */
4208 ixj_WriteDSPCommand(0xCF94, j); /* Set AGC Attack Time Constant */
4209 ixj_WriteDSPCommand(0x0005, j); /* to 8ms */
4211 ixj_WriteDSPCommand(0xCF95, j); /* Set AGC Decay Time Constant */
4212 ixj_WriteDSPCommand(0x000D, j); /* to 4096ms */
4214 ixj_WriteDSPCommand(0xCF96, j); /* Set AGC Attack Threshold */
4215 ixj_WriteDSPCommand(0x1200, j); /* to 25% */
4217 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4218 ixj_WriteDSPCommand(0x0001, j); /* to on */
4220 break;
4222 case AEC_AUTO:
4223 ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
4225 ixj_WriteDSPCommand(0xE011, j);
4226 ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
4228 ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
4230 if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
4231 ixj_WriteDSPCommand(0x0224, j);
4232 else
4233 ixj_WriteDSPCommand(0x1224, j);
4235 ixj_WriteDSPCommand(0xE014, j);
4236 ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */
4238 ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
4240 break;
4245 static void aec_stop(IXJ *j)
4247 j->aec_level = AEC_OFF;
4248 if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
4249 ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer back */
4251 ixj_WriteDSPCommand(0x0700, j);
4253 if (j->play_mode != -1 && j->rec_mode != -1)
4255 ixj_WriteDSPCommand(0xB002, j); /* AEC Stop */
4259 static int set_play_codec(IXJ *j, int rate)
4261 int retval = 0;
4263 j->play_codec = rate;
4265 switch (rate) {
4266 case G723_63:
4267 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4268 j->play_frame_size = 12;
4269 j->play_mode = 0;
4270 } else {
4271 retval = 1;
4273 break;
4274 case G723_53:
4275 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4276 j->play_frame_size = 10;
4277 j->play_mode = 0;
4278 } else {
4279 retval = 1;
4281 break;
4282 case TS85:
4283 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
4284 j->play_frame_size = 16;
4285 j->play_mode = 0;
4286 } else {
4287 retval = 1;
4289 break;
4290 case TS48:
4291 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4292 j->play_frame_size = 9;
4293 j->play_mode = 0;
4294 } else {
4295 retval = 1;
4297 break;
4298 case TS41:
4299 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4300 j->play_frame_size = 8;
4301 j->play_mode = 0;
4302 } else {
4303 retval = 1;
4305 break;
4306 case G728:
4307 if (j->dsp.low != 0x20) {
4308 j->play_frame_size = 48;
4309 j->play_mode = 0;
4310 } else {
4311 retval = 1;
4313 break;
4314 case G729:
4315 if (j->dsp.low != 0x20) {
4316 if (!j->flags.g729_loaded) {
4317 retval = 1;
4318 break;
4320 switch (j->baseframe.low) {
4321 case 0xA0:
4322 j->play_frame_size = 10;
4323 break;
4324 case 0x50:
4325 j->play_frame_size = 5;
4326 break;
4327 default:
4328 j->play_frame_size = 15;
4329 break;
4331 j->play_mode = 0;
4332 } else {
4333 retval = 1;
4335 break;
4336 case G729B:
4337 if (j->dsp.low != 0x20) {
4338 if (!j->flags.g729_loaded) {
4339 retval = 1;
4340 break;
4342 switch (j->baseframe.low) {
4343 case 0xA0:
4344 j->play_frame_size = 12;
4345 break;
4346 case 0x50:
4347 j->play_frame_size = 6;
4348 break;
4349 default:
4350 j->play_frame_size = 18;
4351 break;
4353 j->play_mode = 0;
4354 } else {
4355 retval = 1;
4357 break;
4358 case ULAW:
4359 switch (j->baseframe.low) {
4360 case 0xA0:
4361 j->play_frame_size = 80;
4362 break;
4363 case 0x50:
4364 j->play_frame_size = 40;
4365 break;
4366 default:
4367 j->play_frame_size = 120;
4368 break;
4370 j->play_mode = 2;
4371 break;
4372 case ALAW:
4373 switch (j->baseframe.low) {
4374 case 0xA0:
4375 j->play_frame_size = 80;
4376 break;
4377 case 0x50:
4378 j->play_frame_size = 40;
4379 break;
4380 default:
4381 j->play_frame_size = 120;
4382 break;
4384 j->play_mode = 2;
4385 break;
4386 case LINEAR16:
4387 switch (j->baseframe.low) {
4388 case 0xA0:
4389 j->play_frame_size = 160;
4390 break;
4391 case 0x50:
4392 j->play_frame_size = 80;
4393 break;
4394 default:
4395 j->play_frame_size = 240;
4396 break;
4398 j->play_mode = 6;
4399 break;
4400 case LINEAR8:
4401 switch (j->baseframe.low) {
4402 case 0xA0:
4403 j->play_frame_size = 80;
4404 break;
4405 case 0x50:
4406 j->play_frame_size = 40;
4407 break;
4408 default:
4409 j->play_frame_size = 120;
4410 break;
4412 j->play_mode = 4;
4413 break;
4414 case WSS:
4415 switch (j->baseframe.low) {
4416 case 0xA0:
4417 j->play_frame_size = 80;
4418 break;
4419 case 0x50:
4420 j->play_frame_size = 40;
4421 break;
4422 default:
4423 j->play_frame_size = 120;
4424 break;
4426 j->play_mode = 5;
4427 break;
4428 default:
4429 kfree(j->write_buffer);
4430 j->play_frame_size = 0;
4431 j->play_mode = -1;
4432 j->write_buffer = NULL;
4433 j->write_buffer_size = 0;
4434 retval = 1;
4435 break;
4437 return retval;
4440 static int ixj_play_start(IXJ *j)
4442 unsigned short cmd = 0x0000;
4444 if (j->write_buffer) {
4445 ixj_play_stop(j);
4448 if(ixjdebug & 0x0002)
4449 printk("IXJ %d Starting Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
4451 j->flags.playing = 1;
4452 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
4454 j->flags.play_first_frame = 1;
4455 j->drybuffer = 0;
4457 if (!j->play_mode) {
4458 switch (j->play_codec) {
4459 case G723_63:
4460 cmd = 0x5231;
4461 break;
4462 case G723_53:
4463 cmd = 0x5232;
4464 break;
4465 case TS85:
4466 cmd = 0x5230; /* TrueSpeech 8.5 */
4468 break;
4469 case TS48:
4470 cmd = 0x5233; /* TrueSpeech 4.8 */
4472 break;
4473 case TS41:
4474 cmd = 0x5234; /* TrueSpeech 4.1 */
4476 break;
4477 case G728:
4478 cmd = 0x5235;
4479 break;
4480 case G729:
4481 case G729B:
4482 cmd = 0x5236;
4483 break;
4484 default:
4485 return 1;
4487 if (ixj_WriteDSPCommand(cmd, j))
4488 return -1;
4490 j->write_buffer = kmalloc(j->play_frame_size * 2, GFP_ATOMIC);
4491 if (!j->write_buffer) {
4492 printk("Write buffer allocation for ixj board %d failed!\n", j->board);
4493 return -ENOMEM;
4495 /* j->write_buffers_empty = 2; */
4496 j->write_buffers_empty = 1;
4497 j->write_buffer_size = j->play_frame_size * 2;
4498 j->write_buffer_end = j->write_buffer + j->play_frame_size * 2;
4499 j->write_buffer_rp = j->write_buffer_wp = j->write_buffer;
4501 if (ixj_WriteDSPCommand(0x5202, j)) /* Set Poll sync mode */
4503 return -1;
4505 switch (j->play_mode) {
4506 case 0:
4507 cmd = 0x2C03;
4508 break;
4509 case 2:
4510 if (j->ver.low == 0x12) {
4511 cmd = 0x2C23;
4512 } else {
4513 cmd = 0x2C21;
4515 break;
4516 case 4:
4517 if (j->ver.low == 0x12) {
4518 cmd = 0x2C43;
4519 } else {
4520 cmd = 0x2C41;
4522 break;
4523 case 5:
4524 if (j->ver.low == 0x12) {
4525 cmd = 0x2C53;
4526 } else {
4527 cmd = 0x2C51;
4529 break;
4530 case 6:
4531 if (j->ver.low == 0x12) {
4532 cmd = 0x2C63;
4533 } else {
4534 cmd = 0x2C61;
4536 break;
4538 if (ixj_WriteDSPCommand(cmd, j))
4539 return -1;
4541 if (ixj_WriteDSPCommand(0x2000, j)) /* Playback C2 */
4542 return -1;
4544 if (ixj_WriteDSPCommand(0x2000 + j->play_frame_size, j)) /* Playback C3 */
4545 return -1;
4547 if (j->flags.recording) {
4548 ixj_aec_start(j, j->aec_level);
4551 return 0;
4554 static void ixj_play_stop(IXJ *j)
4556 if (ixjdebug & 0x0002)
4557 printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
4559 kfree(j->write_buffer);
4560 j->write_buffer = NULL;
4561 j->write_buffer_size = 0;
4562 if (j->play_mode > -1) {
4563 ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */
4565 j->play_mode = -1;
4567 j->flags.playing = 0;
4570 static inline int get_play_level(IXJ *j)
4572 int retval;
4574 ixj_WriteDSPCommand(0xCF8F, j); /* 8022 Reference page 9-38 */
4575 return j->ssr.high << 8 | j->ssr.low;
4576 retval = j->ssr.high << 8 | j->ssr.low;
4577 retval = (retval * 256) / 240;
4578 return retval;
4581 static unsigned int ixj_poll(struct file *file_p, poll_table * wait)
4583 unsigned int mask = 0;
4585 IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
4587 poll_wait(file_p, &(j->poll_q), wait);
4588 if (j->read_buffer_ready > 0)
4589 mask |= POLLIN | POLLRDNORM; /* readable */
4590 if (j->write_buffers_empty > 0)
4591 mask |= POLLOUT | POLLWRNORM; /* writable */
4592 if (j->ex.bytes)
4593 mask |= POLLPRI;
4594 return mask;
4597 static int ixj_play_tone(IXJ *j, char tone)
4599 if (!j->tone_state) {
4600 if(ixjdebug & 0x0002) {
4601 printk("IXJ %d starting tone %d at %ld\n", j->board, tone, jiffies);
4603 if (j->dsp.low == 0x20) {
4604 idle(j);
4606 j->tone_start_jif = jiffies;
4608 j->tone_state = 1;
4611 j->tone_index = tone;
4612 if (ixj_WriteDSPCommand(0x6000 + j->tone_index, j))
4613 return -1;
4615 return 0;
4618 static int ixj_set_tone_on(unsigned short arg, IXJ *j)
4620 j->tone_on_time = arg;
4622 if (ixj_WriteDSPCommand(0x6E04, j)) /* Set Tone On Period */
4624 return -1;
4626 if (ixj_WriteDSPCommand(arg, j))
4627 return -1;
4629 return 0;
4632 static int SCI_WaitHighSCI(IXJ *j)
4634 int cnt;
4636 j->pld_scrr.byte = inb_p(j->XILINXbase);
4637 if (!j->pld_scrr.bits.sci) {
4638 for (cnt = 0; cnt < 10; cnt++) {
4639 udelay(32);
4640 j->pld_scrr.byte = inb_p(j->XILINXbase);
4642 if ((j->pld_scrr.bits.sci))
4643 return 1;
4645 if (ixjdebug & 0x0001)
4646 printk(KERN_INFO "SCI Wait High failed %x\n", j->pld_scrr.byte);
4647 return 0;
4648 } else
4649 return 1;
4652 static int SCI_WaitLowSCI(IXJ *j)
4654 int cnt;
4656 j->pld_scrr.byte = inb_p(j->XILINXbase);
4657 if (j->pld_scrr.bits.sci) {
4658 for (cnt = 0; cnt < 10; cnt++) {
4659 udelay(32);
4660 j->pld_scrr.byte = inb_p(j->XILINXbase);
4662 if (!(j->pld_scrr.bits.sci))
4663 return 1;
4665 if (ixjdebug & 0x0001)
4666 printk(KERN_INFO "SCI Wait Low failed %x\n", j->pld_scrr.byte);
4667 return 0;
4668 } else
4669 return 1;
4672 static int SCI_Control(IXJ *j, int control)
4674 switch (control) {
4675 case SCI_End:
4676 j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
4678 j->pld_scrw.bits.c1 = 0; /* to no selection */
4680 break;
4681 case SCI_Enable_DAA:
4682 j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
4684 j->pld_scrw.bits.c1 = 0; /* to write to DAA */
4686 break;
4687 case SCI_Enable_Mixer:
4688 j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
4690 j->pld_scrw.bits.c1 = 1; /* to write to mixer */
4692 break;
4693 case SCI_Enable_EEPROM:
4694 j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
4696 j->pld_scrw.bits.c1 = 1; /* to write to EEPROM */
4698 break;
4699 default:
4700 return 0;
4701 break;
4703 outb_p(j->pld_scrw.byte, j->XILINXbase);
4705 switch (control) {
4706 case SCI_End:
4707 return 1;
4708 break;
4709 case SCI_Enable_DAA:
4710 case SCI_Enable_Mixer:
4711 case SCI_Enable_EEPROM:
4712 if (!SCI_WaitHighSCI(j))
4713 return 0;
4714 break;
4715 default:
4716 return 0;
4717 break;
4719 return 1;
4722 static int SCI_Prepare(IXJ *j)
4724 if (!SCI_Control(j, SCI_End))
4725 return 0;
4727 if (!SCI_WaitLowSCI(j))
4728 return 0;
4730 return 1;
4733 static int ixj_get_mixer(long val, IXJ *j)
4735 int reg = (val & 0x1F00) >> 8;
4736 return j->mix.vol[reg];
4739 static int ixj_mixer(long val, IXJ *j)
4741 BYTES bytes;
4743 bytes.high = (val & 0x1F00) >> 8;
4744 bytes.low = val & 0x00FF;
4746 /* save mixer value so we can get back later on */
4747 j->mix.vol[bytes.high] = bytes.low;
4749 outb_p(bytes.high & 0x1F, j->XILINXbase + 0x03); /* Load Mixer Address */
4751 outb_p(bytes.low, j->XILINXbase + 0x02); /* Load Mixer Data */
4753 SCI_Control(j, SCI_Enable_Mixer);
4755 SCI_Control(j, SCI_End);
4757 return 0;
4760 static int daa_load(BYTES * p_bytes, IXJ *j)
4762 outb_p(p_bytes->high, j->XILINXbase + 0x03);
4763 outb_p(p_bytes->low, j->XILINXbase + 0x02);
4764 if (!SCI_Control(j, SCI_Enable_DAA))
4765 return 0;
4766 else
4767 return 1;
4770 static int ixj_daa_cr4(IXJ *j, char reg)
4772 BYTES bytes;
4774 switch (j->daa_mode) {
4775 case SOP_PU_SLEEP:
4776 bytes.high = 0x14;
4777 break;
4778 case SOP_PU_RINGING:
4779 bytes.high = 0x54;
4780 break;
4781 case SOP_PU_CONVERSATION:
4782 bytes.high = 0x94;
4783 break;
4784 case SOP_PU_PULSEDIALING:
4785 bytes.high = 0xD4;
4786 break;
4789 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = reg;
4791 switch (j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGX) {
4792 case 0:
4793 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 0;
4794 break;
4795 case 1:
4796 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 2;
4797 break;
4798 case 2:
4799 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 1;
4800 break;
4801 case 3:
4802 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 3;
4803 break;
4806 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
4808 if (!daa_load(&bytes, j))
4809 return 0;
4811 if (!SCI_Prepare(j))
4812 return 0;
4814 return 1;
4817 static char daa_int_read(IXJ *j)
4819 BYTES bytes;
4821 if (!SCI_Prepare(j))
4822 return 0;
4824 bytes.high = 0x38;
4825 bytes.low = 0x00;
4826 outb_p(bytes.high, j->XILINXbase + 0x03);
4827 outb_p(bytes.low, j->XILINXbase + 0x02);
4829 if (!SCI_Control(j, SCI_Enable_DAA))
4830 return 0;
4832 bytes.high = inb_p(j->XILINXbase + 0x03);
4833 bytes.low = inb_p(j->XILINXbase + 0x02);
4834 if (bytes.low != ALISDAA_ID_BYTE) {
4835 if (ixjdebug & 0x0001)
4836 printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
4837 return 0;
4839 if (!SCI_Control(j, SCI_Enable_DAA))
4840 return 0;
4841 if (!SCI_Control(j, SCI_End))
4842 return 0;
4844 bytes.high = inb_p(j->XILINXbase + 0x03);
4845 bytes.low = inb_p(j->XILINXbase + 0x02);
4847 j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg = bytes.high;
4849 return 1;
4852 static char daa_CR_read(IXJ *j, int cr)
4854 IXJ_WORD wdata;
4855 BYTES bytes;
4857 if (!SCI_Prepare(j))
4858 return 0;
4860 switch (j->daa_mode) {
4861 case SOP_PU_SLEEP:
4862 bytes.high = 0x30 + cr;
4863 break;
4864 case SOP_PU_RINGING:
4865 bytes.high = 0x70 + cr;
4866 break;
4867 case SOP_PU_CONVERSATION:
4868 bytes.high = 0xB0 + cr;
4869 break;
4870 case SOP_PU_PULSEDIALING:
4871 bytes.high = 0xF0 + cr;
4872 break;
4875 bytes.low = 0x00;
4877 outb_p(bytes.high, j->XILINXbase + 0x03);
4878 outb_p(bytes.low, j->XILINXbase + 0x02);
4880 if (!SCI_Control(j, SCI_Enable_DAA))
4881 return 0;
4883 bytes.high = inb_p(j->XILINXbase + 0x03);
4884 bytes.low = inb_p(j->XILINXbase + 0x02);
4885 if (bytes.low != ALISDAA_ID_BYTE) {
4886 if (ixjdebug & 0x0001)
4887 printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
4888 return 0;
4890 if (!SCI_Control(j, SCI_Enable_DAA))
4891 return 0;
4892 if (!SCI_Control(j, SCI_End))
4893 return 0;
4895 wdata.word = inw_p(j->XILINXbase + 0x02);
4897 switch(cr){
4898 case 5:
4899 j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = wdata.bytes.high;
4900 break;
4901 case 4:
4902 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = wdata.bytes.high;
4903 break;
4904 case 3:
4905 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = wdata.bytes.high;
4906 break;
4907 case 2:
4908 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = wdata.bytes.high;
4909 break;
4910 case 1:
4911 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = wdata.bytes.high;
4912 break;
4913 case 0:
4914 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = wdata.bytes.high;
4915 break;
4916 default:
4917 return 0;
4919 return 1;
4922 static int ixj_daa_cid_reset(IXJ *j)
4924 int i;
4925 BYTES bytes;
4927 if (ixjdebug & 0x0002)
4928 printk("DAA Clearing CID ram\n");
4930 if (!SCI_Prepare(j))
4931 return 0;
4933 bytes.high = 0x58;
4934 bytes.low = 0x00;
4935 outb_p(bytes.high, j->XILINXbase + 0x03);
4936 outb_p(bytes.low, j->XILINXbase + 0x02);
4938 if (!SCI_Control(j, SCI_Enable_DAA))
4939 return 0;
4941 if (!SCI_WaitHighSCI(j))
4942 return 0;
4944 for (i = 0; i < ALISDAA_CALLERID_SIZE - 1; i += 2) {
4945 bytes.high = bytes.low = 0x00;
4946 outb_p(bytes.high, j->XILINXbase + 0x03);
4948 if (i < ALISDAA_CALLERID_SIZE - 1)
4949 outb_p(bytes.low, j->XILINXbase + 0x02);
4951 if (!SCI_Control(j, SCI_Enable_DAA))
4952 return 0;
4954 if (!SCI_WaitHighSCI(j))
4955 return 0;
4959 if (!SCI_Control(j, SCI_End))
4960 return 0;
4962 if (ixjdebug & 0x0002)
4963 printk("DAA CID ram cleared\n");
4965 return 1;
4968 static int ixj_daa_cid_read(IXJ *j)
4970 int i;
4971 BYTES bytes;
4972 char CID[ALISDAA_CALLERID_SIZE];
4973 bool mContinue;
4974 char *pIn, *pOut;
4976 if (!SCI_Prepare(j))
4977 return 0;
4979 bytes.high = 0x78;
4980 bytes.low = 0x00;
4981 outb_p(bytes.high, j->XILINXbase + 0x03);
4982 outb_p(bytes.low, j->XILINXbase + 0x02);
4984 if (!SCI_Control(j, SCI_Enable_DAA))
4985 return 0;
4987 if (!SCI_WaitHighSCI(j))
4988 return 0;
4990 bytes.high = inb_p(j->XILINXbase + 0x03);
4991 bytes.low = inb_p(j->XILINXbase + 0x02);
4992 if (bytes.low != ALISDAA_ID_BYTE) {
4993 if (ixjdebug & 0x0001)
4994 printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
4995 return 0;
4997 for (i = 0; i < ALISDAA_CALLERID_SIZE; i += 2) {
4998 bytes.high = bytes.low = 0x00;
4999 outb_p(bytes.high, j->XILINXbase + 0x03);
5000 outb_p(bytes.low, j->XILINXbase + 0x02);
5002 if (!SCI_Control(j, SCI_Enable_DAA))
5003 return 0;
5005 if (!SCI_WaitHighSCI(j))
5006 return 0;
5008 CID[i + 0] = inb_p(j->XILINXbase + 0x03);
5009 CID[i + 1] = inb_p(j->XILINXbase + 0x02);
5012 if (!SCI_Control(j, SCI_End))
5013 return 0;
5015 pIn = CID;
5016 pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
5017 mContinue = true;
5018 while (mContinue) {
5019 if ((pIn[1] & 0x03) == 0x01) {
5020 pOut[0] = pIn[0];
5022 if ((pIn[2] & 0x0c) == 0x04) {
5023 pOut[1] = ((pIn[2] & 0x03) << 6) | ((pIn[1] & 0xfc) >> 2);
5025 if ((pIn[3] & 0x30) == 0x10) {
5026 pOut[2] = ((pIn[3] & 0x0f) << 4) | ((pIn[2] & 0xf0) >> 4);
5028 if ((pIn[4] & 0xc0) == 0x40) {
5029 pOut[3] = ((pIn[4] & 0x3f) << 2) | ((pIn[3] & 0xc0) >> 6);
5030 } else {
5031 mContinue = false;
5033 pIn += 5, pOut += 4;
5035 memset(&j->cid, 0, sizeof(PHONE_CID));
5036 pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
5037 pOut += 4;
5038 strncpy(j->cid.month, pOut, 2);
5039 pOut += 2;
5040 strncpy(j->cid.day, pOut, 2);
5041 pOut += 2;
5042 strncpy(j->cid.hour, pOut, 2);
5043 pOut += 2;
5044 strncpy(j->cid.min, pOut, 2);
5045 pOut += 3;
5046 j->cid.numlen = *pOut;
5047 pOut += 1;
5048 strncpy(j->cid.number, pOut, j->cid.numlen);
5049 pOut += j->cid.numlen + 1;
5050 j->cid.namelen = *pOut;
5051 pOut += 1;
5052 strncpy(j->cid.name, pOut, j->cid.namelen);
5054 ixj_daa_cid_reset(j);
5055 return 1;
5058 static char daa_get_version(IXJ *j)
5060 BYTES bytes;
5062 if (!SCI_Prepare(j))
5063 return 0;
5065 bytes.high = 0x35;
5066 bytes.low = 0x00;
5067 outb_p(bytes.high, j->XILINXbase + 0x03);
5068 outb_p(bytes.low, j->XILINXbase + 0x02);
5070 if (!SCI_Control(j, SCI_Enable_DAA))
5071 return 0;
5073 bytes.high = inb_p(j->XILINXbase + 0x03);
5074 bytes.low = inb_p(j->XILINXbase + 0x02);
5075 if (bytes.low != ALISDAA_ID_BYTE) {
5076 if (ixjdebug & 0x0001)
5077 printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
5078 return 0;
5080 if (!SCI_Control(j, SCI_Enable_DAA))
5081 return 0;
5083 if (!SCI_Control(j, SCI_End))
5084 return 0;
5086 bytes.high = inb_p(j->XILINXbase + 0x03);
5087 bytes.low = inb_p(j->XILINXbase + 0x02);
5088 if (ixjdebug & 0x0002)
5089 printk("DAA CR5 Byte high = 0x%x low = 0x%x\n", bytes.high, bytes.low);
5090 j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = bytes.high;
5091 return bytes.high;
5094 static int daa_set_mode(IXJ *j, int mode)
5096 /* NOTE:
5097 The DAA *MUST* be in the conversation mode if the
5098 PSTN line is to be seized (PSTN line off-hook).
5099 Taking the PSTN line off-hook while the DAA is in
5100 a mode other than conversation mode will cause a
5101 hardware failure of the ALIS-A part.
5103 NOTE:
5104 The DAA can only go to SLEEP, RINGING or PULSEDIALING modes
5105 if the PSTN line is on-hook. Failure to have the PSTN line
5106 in the on-hook state WILL CAUSE A HARDWARE FAILURE OF THE
5107 ALIS-A part.
5110 BYTES bytes;
5112 j->flags.pstn_rmr = 0;
5114 if (!SCI_Prepare(j))
5115 return 0;
5117 switch (mode) {
5118 case SOP_PU_RESET:
5119 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5121 outb_p(j->pld_scrw.byte, j->XILINXbase);
5122 j->pld_slicw.bits.rly2 = 0;
5123 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5124 bytes.high = 0x10;
5125 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5126 daa_load(&bytes, j);
5127 if (!SCI_Prepare(j))
5128 return 0;
5130 j->daa_mode = SOP_PU_SLEEP;
5131 break;
5132 case SOP_PU_SLEEP:
5133 if(j->daa_mode == SOP_PU_SLEEP)
5135 break;
5137 if (ixjdebug & 0x0008)
5138 printk(KERN_INFO "phone DAA: SOP_PU_SLEEP at %ld\n", jiffies);
5139 /* if(j->daa_mode == SOP_PU_CONVERSATION) */
5141 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5143 outb_p(j->pld_scrw.byte, j->XILINXbase);
5144 j->pld_slicw.bits.rly2 = 0;
5145 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5146 bytes.high = 0x10;
5147 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5148 daa_load(&bytes, j);
5149 if (!SCI_Prepare(j))
5150 return 0;
5152 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5154 outb_p(j->pld_scrw.byte, j->XILINXbase);
5155 j->pld_slicw.bits.rly2 = 0;
5156 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5157 bytes.high = 0x10;
5158 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5159 daa_load(&bytes, j);
5160 if (!SCI_Prepare(j))
5161 return 0;
5163 j->daa_mode = SOP_PU_SLEEP;
5164 j->flags.pstn_ringing = 0;
5165 j->ex.bits.pstn_ring = 0;
5166 j->pstn_sleeptil = jiffies + (hertz / 4);
5167 wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
5168 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
5169 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
5170 break;
5171 case SOP_PU_RINGING:
5172 if (ixjdebug & 0x0008)
5173 printk(KERN_INFO "phone DAA: SOP_PU_RINGING at %ld\n", jiffies);
5174 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5176 outb_p(j->pld_scrw.byte, j->XILINXbase);
5177 j->pld_slicw.bits.rly2 = 0;
5178 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5179 bytes.high = 0x50;
5180 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5181 daa_load(&bytes, j);
5182 if (!SCI_Prepare(j))
5183 return 0;
5184 j->daa_mode = SOP_PU_RINGING;
5185 break;
5186 case SOP_PU_CONVERSATION:
5187 if (ixjdebug & 0x0008)
5188 printk(KERN_INFO "phone DAA: SOP_PU_CONVERSATION at %ld\n", jiffies);
5189 bytes.high = 0x90;
5190 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5191 daa_load(&bytes, j);
5192 if (!SCI_Prepare(j))
5193 return 0;
5194 j->pld_slicw.bits.rly2 = 1;
5195 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5196 j->pld_scrw.bits.daafsyncen = 1; /* Turn on DAA Frame Sync */
5198 outb_p(j->pld_scrw.byte, j->XILINXbase);
5199 j->daa_mode = SOP_PU_CONVERSATION;
5200 j->flags.pstn_ringing = 0;
5201 j->ex.bits.pstn_ring = 0;
5202 j->pstn_sleeptil = jiffies;
5203 j->pstn_ring_start = j->pstn_ring_stop = j->pstn_ring_int = 0;
5204 break;
5205 case SOP_PU_PULSEDIALING:
5206 if (ixjdebug & 0x0008)
5207 printk(KERN_INFO "phone DAA: SOP_PU_PULSEDIALING at %ld\n", jiffies);
5208 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5210 outb_p(j->pld_scrw.byte, j->XILINXbase);
5211 j->pld_slicw.bits.rly2 = 0;
5212 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5213 bytes.high = 0xD0;
5214 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5215 daa_load(&bytes, j);
5216 if (!SCI_Prepare(j))
5217 return 0;
5218 j->daa_mode = SOP_PU_PULSEDIALING;
5219 break;
5220 default:
5221 break;
5223 return 1;
5226 static int ixj_daa_write(IXJ *j)
5228 BYTES bytes;
5230 j->flags.pstncheck = 1;
5232 daa_set_mode(j, SOP_PU_SLEEP);
5234 if (!SCI_Prepare(j))
5235 return 0;
5237 outb_p(j->pld_scrw.byte, j->XILINXbase);
5239 bytes.high = 0x14;
5240 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
5241 if (!daa_load(&bytes, j))
5242 return 0;
5244 bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg;
5245 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg;
5246 if (!daa_load(&bytes, j))
5247 return 0;
5249 bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg;
5250 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5251 if (!daa_load(&bytes, j))
5252 return 0;
5254 if (!SCI_Prepare(j))
5255 return 0;
5257 bytes.high = 0x1F;
5258 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg;
5259 if (!daa_load(&bytes, j))
5260 return 0;
5262 bytes.high = j->m_DAAShadowRegs.XOP_xr6_W.reg;
5263 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg;
5264 if (!daa_load(&bytes, j))
5265 return 0;
5267 bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg;
5268 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg;
5269 if (!daa_load(&bytes, j))
5270 return 0;
5272 bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg;
5273 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg;
5274 if (!daa_load(&bytes, j))
5275 return 0;
5277 bytes.high = j->m_DAAShadowRegs.XOP_xr0_W.reg;
5278 bytes.low = 0x00;
5279 if (!daa_load(&bytes, j))
5280 return 0;
5282 if (!SCI_Prepare(j))
5283 return 0;
5285 bytes.high = 0x00;
5286 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7];
5287 if (!daa_load(&bytes, j))
5288 return 0;
5290 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6];
5291 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5];
5292 if (!daa_load(&bytes, j))
5293 return 0;
5295 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4];
5296 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3];
5297 if (!daa_load(&bytes, j))
5298 return 0;
5300 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2];
5301 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1];
5302 if (!daa_load(&bytes, j))
5303 return 0;
5305 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0];
5306 bytes.low = 0x00;
5307 if (!daa_load(&bytes, j))
5308 return 0;
5310 if (!SCI_Control(j, SCI_End))
5311 return 0;
5312 if (!SCI_WaitLowSCI(j))
5313 return 0;
5315 bytes.high = 0x01;
5316 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7];
5317 if (!daa_load(&bytes, j))
5318 return 0;
5320 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6];
5321 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5];
5322 if (!daa_load(&bytes, j))
5323 return 0;
5325 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4];
5326 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3];
5327 if (!daa_load(&bytes, j))
5328 return 0;
5330 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2];
5331 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1];
5332 if (!daa_load(&bytes, j))
5333 return 0;
5335 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0];
5336 bytes.low = 0x00;
5337 if (!daa_load(&bytes, j))
5338 return 0;
5340 if (!SCI_Control(j, SCI_End))
5341 return 0;
5342 if (!SCI_WaitLowSCI(j))
5343 return 0;
5345 bytes.high = 0x02;
5346 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7];
5347 if (!daa_load(&bytes, j))
5348 return 0;
5350 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6];
5351 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5];
5352 if (!daa_load(&bytes, j))
5353 return 0;
5355 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4];
5356 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3];
5357 if (!daa_load(&bytes, j))
5358 return 0;
5360 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2];
5361 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1];
5362 if (!daa_load(&bytes, j))
5363 return 0;
5365 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0];
5366 bytes.low = 0x00;
5367 if (!daa_load(&bytes, j))
5368 return 0;
5370 if (!SCI_Control(j, SCI_End))
5371 return 0;
5372 if (!SCI_WaitLowSCI(j))
5373 return 0;
5375 bytes.high = 0x03;
5376 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7];
5377 if (!daa_load(&bytes, j))
5378 return 0;
5380 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6];
5381 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5];
5382 if (!daa_load(&bytes, j))
5383 return 0;
5385 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4];
5386 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3];
5387 if (!daa_load(&bytes, j))
5388 return 0;
5390 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2];
5391 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1];
5392 if (!daa_load(&bytes, j))
5393 return 0;
5395 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0];
5396 bytes.low = 0x00;
5397 if (!daa_load(&bytes, j))
5398 return 0;
5400 if (!SCI_Control(j, SCI_End))
5401 return 0;
5402 if (!SCI_WaitLowSCI(j))
5403 return 0;
5405 bytes.high = 0x04;
5406 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7];
5407 if (!daa_load(&bytes, j))
5408 return 0;
5410 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6];
5411 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5];
5412 if (!daa_load(&bytes, j))
5413 return 0;
5415 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4];
5416 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3];
5417 if (!daa_load(&bytes, j))
5418 return 0;
5420 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2];
5421 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1];
5422 if (!daa_load(&bytes, j))
5423 return 0;
5425 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0];
5426 bytes.low = 0x00;
5427 if (!daa_load(&bytes, j))
5428 return 0;
5430 if (!SCI_Control(j, SCI_End))
5431 return 0;
5432 if (!SCI_WaitLowSCI(j))
5433 return 0;
5435 bytes.high = 0x05;
5436 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7];
5437 if (!daa_load(&bytes, j))
5438 return 0;
5440 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6];
5441 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5];
5442 if (!daa_load(&bytes, j))
5443 return 0;
5445 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4];
5446 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3];
5447 if (!daa_load(&bytes, j))
5448 return 0;
5450 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2];
5451 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1];
5452 if (!daa_load(&bytes, j))
5453 return 0;
5455 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0];
5456 bytes.low = 0x00;
5457 if (!daa_load(&bytes, j))
5458 return 0;
5460 if (!SCI_Control(j, SCI_End))
5461 return 0;
5462 if (!SCI_WaitLowSCI(j))
5463 return 0;
5465 bytes.high = 0x06;
5466 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7];
5467 if (!daa_load(&bytes, j))
5468 return 0;
5470 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6];
5471 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5];
5472 if (!daa_load(&bytes, j))
5473 return 0;
5475 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4];
5476 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3];
5477 if (!daa_load(&bytes, j))
5478 return 0;
5480 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2];
5481 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1];
5482 if (!daa_load(&bytes, j))
5483 return 0;
5485 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0];
5486 bytes.low = 0x00;
5487 if (!daa_load(&bytes, j))
5488 return 0;
5490 if (!SCI_Control(j, SCI_End))
5491 return 0;
5492 if (!SCI_WaitLowSCI(j))
5493 return 0;
5495 bytes.high = 0x07;
5496 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7];
5497 if (!daa_load(&bytes, j))
5498 return 0;
5500 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6];
5501 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5];
5502 if (!daa_load(&bytes, j))
5503 return 0;
5505 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4];
5506 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3];
5507 if (!daa_load(&bytes, j))
5508 return 0;
5510 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2];
5511 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1];
5512 if (!daa_load(&bytes, j))
5513 return 0;
5515 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0];
5516 bytes.low = 0x00;
5517 if (!daa_load(&bytes, j))
5518 return 0;
5520 if (!SCI_Control(j, SCI_End))
5521 return 0;
5522 if (!SCI_WaitLowSCI(j))
5523 return 0;
5525 bytes.high = 0x08;
5526 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7];
5527 if (!daa_load(&bytes, j))
5528 return 0;
5530 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6];
5531 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5];
5532 if (!daa_load(&bytes, j))
5533 return 0;
5535 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4];
5536 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3];
5537 if (!daa_load(&bytes, j))
5538 return 0;
5540 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2];
5541 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1];
5542 if (!daa_load(&bytes, j))
5543 return 0;
5545 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0];
5546 bytes.low = 0x00;
5547 if (!daa_load(&bytes, j))
5548 return 0;
5550 if (!SCI_Control(j, SCI_End))
5551 return 0;
5552 if (!SCI_WaitLowSCI(j))
5553 return 0;
5555 bytes.high = 0x09;
5556 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3];
5557 if (!daa_load(&bytes, j))
5558 return 0;
5560 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2];
5561 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1];
5562 if (!daa_load(&bytes, j))
5563 return 0;
5565 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0];
5566 bytes.low = 0x00;
5567 if (!daa_load(&bytes, j))
5568 return 0;
5570 if (!SCI_Control(j, SCI_End))
5571 return 0;
5572 if (!SCI_WaitLowSCI(j))
5573 return 0;
5575 bytes.high = 0x0A;
5576 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3];
5577 if (!daa_load(&bytes, j))
5578 return 0;
5580 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2];
5581 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1];
5582 if (!daa_load(&bytes, j))
5583 return 0;
5585 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0];
5586 bytes.low = 0x00;
5587 if (!daa_load(&bytes, j))
5588 return 0;
5590 if (!SCI_Control(j, SCI_End))
5591 return 0;
5592 if (!SCI_WaitLowSCI(j))
5593 return 0;
5595 bytes.high = 0x0B;
5596 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3];
5597 if (!daa_load(&bytes, j))
5598 return 0;
5600 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2];
5601 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1];
5602 if (!daa_load(&bytes, j))
5603 return 0;
5605 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0];
5606 bytes.low = 0x00;
5607 if (!daa_load(&bytes, j))
5608 return 0;
5610 if (!SCI_Control(j, SCI_End))
5611 return 0;
5612 if (!SCI_WaitLowSCI(j))
5613 return 0;
5615 bytes.high = 0x0C;
5616 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3];
5617 if (!daa_load(&bytes, j))
5618 return 0;
5620 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2];
5621 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1];
5622 if (!daa_load(&bytes, j))
5623 return 0;
5625 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0];
5626 bytes.low = 0x00;
5627 if (!daa_load(&bytes, j))
5628 return 0;
5630 if (!SCI_Control(j, SCI_End))
5631 return 0;
5632 if (!SCI_WaitLowSCI(j))
5633 return 0;
5635 bytes.high = 0x0D;
5636 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3];
5637 if (!daa_load(&bytes, j))
5638 return 0;
5640 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2];
5641 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1];
5642 if (!daa_load(&bytes, j))
5643 return 0;
5645 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0];
5646 bytes.low = 0x00;
5647 if (!daa_load(&bytes, j))
5648 return 0;
5650 if (!SCI_Control(j, SCI_End))
5651 return 0;
5652 if (!SCI_WaitLowSCI(j))
5653 return 0;
5655 bytes.high = 0x0E;
5656 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7];
5657 if (!daa_load(&bytes, j))
5658 return 0;
5660 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6];
5661 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5];
5662 if (!daa_load(&bytes, j))
5663 return 0;
5665 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4];
5666 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3];
5667 if (!daa_load(&bytes, j))
5668 return 0;
5670 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2];
5671 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1];
5672 if (!daa_load(&bytes, j))
5673 return 0;
5675 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0];
5676 bytes.low = 0x00;
5677 if (!daa_load(&bytes, j))
5678 return 0;
5680 if (!SCI_Control(j, SCI_End))
5681 return 0;
5682 if (!SCI_WaitLowSCI(j))
5683 return 0;
5685 bytes.high = 0x0F;
5686 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7];
5687 if (!daa_load(&bytes, j))
5688 return 0;
5690 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6];
5691 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5];
5692 if (!daa_load(&bytes, j))
5693 return 0;
5695 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4];
5696 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3];
5697 if (!daa_load(&bytes, j))
5698 return 0;
5700 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2];
5701 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1];
5702 if (!daa_load(&bytes, j))
5703 return 0;
5705 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0];
5706 bytes.low = 0x00;
5707 if (!daa_load(&bytes, j))
5708 return 0;
5710 udelay(32);
5711 j->pld_scrr.byte = inb_p(j->XILINXbase);
5712 if (!SCI_Control(j, SCI_End))
5713 return 0;
5715 outb_p(j->pld_scrw.byte, j->XILINXbase);
5717 if (ixjdebug & 0x0002)
5718 printk("DAA Coefficients Loaded\n");
5720 j->flags.pstncheck = 0;
5721 return 1;
5724 static int ixj_set_tone_off(unsigned short arg, IXJ *j)
5726 j->tone_off_time = arg;
5727 if (ixj_WriteDSPCommand(0x6E05, j)) /* Set Tone Off Period */
5729 return -1;
5730 if (ixj_WriteDSPCommand(arg, j))
5731 return -1;
5732 return 0;
5735 static int ixj_get_tone_on(IXJ *j)
5737 if (ixj_WriteDSPCommand(0x6E06, j)) /* Get Tone On Period */
5739 return -1;
5740 return 0;
5743 static int ixj_get_tone_off(IXJ *j)
5745 if (ixj_WriteDSPCommand(0x6E07, j)) /* Get Tone Off Period */
5747 return -1;
5748 return 0;
5751 static void ixj_busytone(IXJ *j)
5753 j->flags.ringback = 0;
5754 j->flags.dialtone = 0;
5755 j->flags.busytone = 1;
5756 ixj_set_tone_on(0x07D0, j);
5757 ixj_set_tone_off(0x07D0, j);
5758 ixj_play_tone(j, 27);
5761 static void ixj_dialtone(IXJ *j)
5763 j->flags.ringback = 0;
5764 j->flags.dialtone = 1;
5765 j->flags.busytone = 0;
5766 if (j->dsp.low == 0x20) {
5767 return;
5768 } else {
5769 ixj_set_tone_on(0xFFFF, j);
5770 ixj_set_tone_off(0x0000, j);
5771 ixj_play_tone(j, 25);
5775 static void ixj_cpt_stop(IXJ *j)
5777 if(j->tone_state || j->tone_cadence_state)
5779 j->flags.dialtone = 0;
5780 j->flags.busytone = 0;
5781 j->flags.ringback = 0;
5782 ixj_set_tone_on(0x0001, j);
5783 ixj_set_tone_off(0x0000, j);
5784 ixj_play_tone(j, 0);
5785 j->tone_state = j->tone_cadence_state = 0;
5786 if (j->cadence_t) {
5787 kfree(j->cadence_t->ce);
5788 kfree(j->cadence_t);
5789 j->cadence_t = NULL;
5792 if (j->play_mode == -1 && j->rec_mode == -1)
5793 idle(j);
5794 if (j->play_mode != -1 && j->dsp.low == 0x20)
5795 ixj_play_start(j);
5796 if (j->rec_mode != -1 && j->dsp.low == 0x20)
5797 ixj_record_start(j);
5800 static void ixj_ringback(IXJ *j)
5802 j->flags.busytone = 0;
5803 j->flags.dialtone = 0;
5804 j->flags.ringback = 1;
5805 ixj_set_tone_on(0x0FA0, j);
5806 ixj_set_tone_off(0x2EE0, j);
5807 ixj_play_tone(j, 26);
5810 static void ixj_testram(IXJ *j)
5812 ixj_WriteDSPCommand(0x3001, j); /* Test External SRAM */
5815 static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp)
5817 ixj_cadence *lcp;
5818 IXJ_CADENCE_ELEMENT __user *cep;
5819 IXJ_CADENCE_ELEMENT *lcep;
5820 IXJ_TONE ti;
5821 int err;
5823 lcp = kmalloc(sizeof(ixj_cadence), GFP_KERNEL);
5824 if (lcp == NULL)
5825 return -ENOMEM;
5827 err = -EFAULT;
5828 if (copy_from_user(&lcp->elements_used,
5829 &cp->elements_used, sizeof(int)))
5830 goto out;
5831 if (copy_from_user(&lcp->termination,
5832 &cp->termination, sizeof(IXJ_CADENCE_TERM)))
5833 goto out;
5834 if (get_user(cep, &cp->ce))
5835 goto out;
5837 err = -EINVAL;
5838 if ((unsigned)lcp->elements_used >= ~0U/sizeof(IXJ_CADENCE_ELEMENT))
5839 goto out;
5841 err = -ENOMEM;
5842 lcep = kmalloc(sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used, GFP_KERNEL);
5843 if (!lcep)
5844 goto out;
5846 err = -EFAULT;
5847 if (copy_from_user(lcep, cep, sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used))
5848 goto out1;
5850 if (j->cadence_t) {
5851 kfree(j->cadence_t->ce);
5852 kfree(j->cadence_t);
5854 lcp->ce = (void *) lcep;
5855 j->cadence_t = lcp;
5856 j->tone_cadence_state = 0;
5857 ixj_set_tone_on(lcp->ce[0].tone_on_time, j);
5858 ixj_set_tone_off(lcp->ce[0].tone_off_time, j);
5859 if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
5860 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
5861 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
5862 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
5863 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
5864 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
5865 ixj_init_tone(j, &ti);
5867 ixj_play_tone(j, lcp->ce[0].index);
5868 return 1;
5869 out1:
5870 kfree(lcep);
5871 out:
5872 kfree(lcp);
5873 return err;
5876 static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp)
5878 IXJ_FILTER_CADENCE *lcp;
5879 lcp = kmalloc(sizeof(IXJ_FILTER_CADENCE), GFP_KERNEL);
5880 if (lcp == NULL) {
5881 if(ixjdebug & 0x0001) {
5882 printk(KERN_INFO "Could not allocate memory for cadence\n");
5884 return -ENOMEM;
5886 if (copy_from_user(lcp, cp, sizeof(IXJ_FILTER_CADENCE))) {
5887 if(ixjdebug & 0x0001) {
5888 printk(KERN_INFO "Could not copy cadence to kernel\n");
5890 kfree(lcp);
5891 return -EFAULT;
5893 if (lcp->filter > 5) {
5894 if(ixjdebug & 0x0001) {
5895 printk(KERN_INFO "Cadence out of range\n");
5897 kfree(lcp);
5898 return -1;
5900 j->cadence_f[lcp->filter].state = 0;
5901 j->cadence_f[lcp->filter].enable = lcp->enable;
5902 j->filter_en[lcp->filter] = j->cadence_f[lcp->filter].en_filter = lcp->en_filter;
5903 j->cadence_f[lcp->filter].on1 = lcp->on1;
5904 j->cadence_f[lcp->filter].on1min = 0;
5905 j->cadence_f[lcp->filter].on1max = 0;
5906 j->cadence_f[lcp->filter].off1 = lcp->off1;
5907 j->cadence_f[lcp->filter].off1min = 0;
5908 j->cadence_f[lcp->filter].off1max = 0;
5909 j->cadence_f[lcp->filter].on2 = lcp->on2;
5910 j->cadence_f[lcp->filter].on2min = 0;
5911 j->cadence_f[lcp->filter].on2max = 0;
5912 j->cadence_f[lcp->filter].off2 = lcp->off2;
5913 j->cadence_f[lcp->filter].off2min = 0;
5914 j->cadence_f[lcp->filter].off2max = 0;
5915 j->cadence_f[lcp->filter].on3 = lcp->on3;
5916 j->cadence_f[lcp->filter].on3min = 0;
5917 j->cadence_f[lcp->filter].on3max = 0;
5918 j->cadence_f[lcp->filter].off3 = lcp->off3;
5919 j->cadence_f[lcp->filter].off3min = 0;
5920 j->cadence_f[lcp->filter].off3max = 0;
5921 if(ixjdebug & 0x0002) {
5922 printk(KERN_INFO "Cadence %d loaded\n", lcp->filter);
5924 kfree(lcp);
5925 return 0;
5928 static void add_caps(IXJ *j)
5930 j->caps = 0;
5931 j->caplist[j->caps].cap = PHONE_VENDOR_QUICKNET;
5932 strcpy(j->caplist[j->caps].desc, "Quicknet Technologies, Inc. (www.quicknet.net)");
5933 j->caplist[j->caps].captype = vendor;
5934 j->caplist[j->caps].handle = j->caps++;
5935 j->caplist[j->caps].captype = device;
5936 switch (j->cardtype) {
5937 case QTI_PHONEJACK:
5938 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK");
5939 break;
5940 case QTI_LINEJACK:
5941 strcpy(j->caplist[j->caps].desc, "Quicknet Internet LineJACK");
5942 break;
5943 case QTI_PHONEJACK_LITE:
5944 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK Lite");
5945 break;
5946 case QTI_PHONEJACK_PCI:
5947 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK PCI");
5948 break;
5949 case QTI_PHONECARD:
5950 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneCARD");
5951 break;
5953 j->caplist[j->caps].cap = j->cardtype;
5954 j->caplist[j->caps].handle = j->caps++;
5955 strcpy(j->caplist[j->caps].desc, "POTS");
5956 j->caplist[j->caps].captype = port;
5957 j->caplist[j->caps].cap = pots;
5958 j->caplist[j->caps].handle = j->caps++;
5960 /* add devices that can do speaker/mic */
5961 switch (j->cardtype) {
5962 case QTI_PHONEJACK:
5963 case QTI_LINEJACK:
5964 case QTI_PHONEJACK_PCI:
5965 case QTI_PHONECARD:
5966 strcpy(j->caplist[j->caps].desc, "SPEAKER");
5967 j->caplist[j->caps].captype = port;
5968 j->caplist[j->caps].cap = speaker;
5969 j->caplist[j->caps].handle = j->caps++;
5970 default:
5971 break;
5974 /* add devices that can do handset */
5975 switch (j->cardtype) {
5976 case QTI_PHONEJACK:
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++;
5981 break;
5982 default:
5983 break;
5986 /* add devices that can do PSTN */
5987 switch (j->cardtype) {
5988 case QTI_LINEJACK:
5989 strcpy(j->caplist[j->caps].desc, "PSTN");
5990 j->caplist[j->caps].captype = port;
5991 j->caplist[j->caps].cap = pstn;
5992 j->caplist[j->caps].handle = j->caps++;
5993 break;
5994 default:
5995 break;
5998 /* add codecs - all cards can do uLaw, linear 8/16, and Windows sound system */
5999 strcpy(j->caplist[j->caps].desc, "ULAW");
6000 j->caplist[j->caps].captype = codec;
6001 j->caplist[j->caps].cap = ULAW;
6002 j->caplist[j->caps].handle = j->caps++;
6004 strcpy(j->caplist[j->caps].desc, "LINEAR 16 bit");
6005 j->caplist[j->caps].captype = codec;
6006 j->caplist[j->caps].cap = LINEAR16;
6007 j->caplist[j->caps].handle = j->caps++;
6009 strcpy(j->caplist[j->caps].desc, "LINEAR 8 bit");
6010 j->caplist[j->caps].captype = codec;
6011 j->caplist[j->caps].cap = LINEAR8;
6012 j->caplist[j->caps].handle = j->caps++;
6014 strcpy(j->caplist[j->caps].desc, "Windows Sound System");
6015 j->caplist[j->caps].captype = codec;
6016 j->caplist[j->caps].cap = WSS;
6017 j->caplist[j->caps].handle = j->caps++;
6019 /* software ALAW codec, made from ULAW */
6020 strcpy(j->caplist[j->caps].desc, "ALAW");
6021 j->caplist[j->caps].captype = codec;
6022 j->caplist[j->caps].cap = ALAW;
6023 j->caplist[j->caps].handle = j->caps++;
6025 /* version 12 of the 8020 does the following codecs in a broken way */
6026 if (j->dsp.low != 0x20 || j->ver.low != 0x12) {
6027 strcpy(j->caplist[j->caps].desc, "G.723.1 6.3kbps");
6028 j->caplist[j->caps].captype = codec;
6029 j->caplist[j->caps].cap = G723_63;
6030 j->caplist[j->caps].handle = j->caps++;
6032 strcpy(j->caplist[j->caps].desc, "G.723.1 5.3kbps");
6033 j->caplist[j->caps].captype = codec;
6034 j->caplist[j->caps].cap = G723_53;
6035 j->caplist[j->caps].handle = j->caps++;
6037 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.8kbps");
6038 j->caplist[j->caps].captype = codec;
6039 j->caplist[j->caps].cap = TS48;
6040 j->caplist[j->caps].handle = j->caps++;
6042 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.1kbps");
6043 j->caplist[j->caps].captype = codec;
6044 j->caplist[j->caps].cap = TS41;
6045 j->caplist[j->caps].handle = j->caps++;
6048 /* 8020 chips can do TS8.5 native, and 8021/8022 can load it */
6049 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
6050 strcpy(j->caplist[j->caps].desc, "TrueSpeech 8.5kbps");
6051 j->caplist[j->caps].captype = codec;
6052 j->caplist[j->caps].cap = TS85;
6053 j->caplist[j->caps].handle = j->caps++;
6056 /* 8021 chips can do G728 */
6057 if (j->dsp.low == 0x21) {
6058 strcpy(j->caplist[j->caps].desc, "G.728 16kbps");
6059 j->caplist[j->caps].captype = codec;
6060 j->caplist[j->caps].cap = G728;
6061 j->caplist[j->caps].handle = j->caps++;
6064 /* 8021/8022 chips can do G729 if loaded */
6065 if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
6066 strcpy(j->caplist[j->caps].desc, "G.729A 8kbps");
6067 j->caplist[j->caps].captype = codec;
6068 j->caplist[j->caps].cap = G729;
6069 j->caplist[j->caps].handle = j->caps++;
6071 if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
6072 strcpy(j->caplist[j->caps].desc, "G.729B 8kbps");
6073 j->caplist[j->caps].captype = codec;
6074 j->caplist[j->caps].cap = G729B;
6075 j->caplist[j->caps].handle = j->caps++;
6079 static int capabilities_check(IXJ *j, struct phone_capability *pcreq)
6081 int cnt;
6082 int retval = 0;
6083 for (cnt = 0; cnt < j->caps; cnt++) {
6084 if (pcreq->captype == j->caplist[cnt].captype
6085 && pcreq->cap == j->caplist[cnt].cap) {
6086 retval = 1;
6087 break;
6090 return retval;
6093 static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, unsigned long arg)
6095 IXJ_TONE ti;
6096 IXJ_FILTER jf;
6097 IXJ_FILTER_RAW jfr;
6098 void __user *argp = (void __user *)arg;
6100 unsigned int raise, mant;
6101 unsigned int minor = iminor(inode);
6102 int board = NUM(inode);
6104 IXJ *j = get_ixj(NUM(inode));
6106 int retval = 0;
6109 * Set up locks to ensure that only one process is talking to the DSP at a time.
6110 * This is necessary to keep the DSP from locking up.
6112 while(test_and_set_bit(board, (void *)&j->busyflags) != 0)
6113 schedule_timeout_interruptible(1);
6114 if (ixjdebug & 0x0040)
6115 printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
6116 if (minor >= IXJMAX) {
6117 clear_bit(board, &j->busyflags);
6118 return -ENODEV;
6121 * Check ioctls only root can use.
6123 if (!capable(CAP_SYS_ADMIN)) {
6124 switch (cmd) {
6125 case IXJCTL_TESTRAM:
6126 case IXJCTL_HZ:
6127 retval = -EPERM;
6130 switch (cmd) {
6131 case IXJCTL_TESTRAM:
6132 ixj_testram(j);
6133 retval = (j->ssr.high << 8) + j->ssr.low;
6134 break;
6135 case IXJCTL_CARDTYPE:
6136 retval = j->cardtype;
6137 break;
6138 case IXJCTL_SERIAL:
6139 retval = j->serial;
6140 break;
6141 case IXJCTL_VERSION:
6143 char arg_str[100];
6144 snprintf(arg_str, sizeof(arg_str),
6145 "\nDriver version %i.%i.%i", IXJ_VER_MAJOR,
6146 IXJ_VER_MINOR, IXJ_BLD_VER);
6147 if (copy_to_user(argp, arg_str, strlen(arg_str)))
6148 retval = -EFAULT;
6150 break;
6151 case PHONE_RING_CADENCE:
6152 j->ring_cadence = arg;
6153 break;
6154 case IXJCTL_CIDCW:
6155 if(arg) {
6156 if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) {
6157 retval = -EFAULT;
6158 break;
6160 } else {
6161 memset(&j->cid_send, 0, sizeof(PHONE_CID));
6163 ixj_write_cidcw(j);
6164 break;
6165 /* Binary compatbility */
6166 case OLD_PHONE_RING_START:
6167 arg = 0;
6168 /* Fall through */
6169 case PHONE_RING_START:
6170 if(arg) {
6171 if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) {
6172 retval = -EFAULT;
6173 break;
6175 ixj_write_cid(j);
6176 } else {
6177 memset(&j->cid_send, 0, sizeof(PHONE_CID));
6179 ixj_ring_start(j);
6180 break;
6181 case PHONE_RING_STOP:
6182 j->flags.cringing = 0;
6183 if(j->cadence_f[5].enable) {
6184 j->cadence_f[5].state = 0;
6186 ixj_ring_off(j);
6187 break;
6188 case PHONE_RING:
6189 retval = ixj_ring(j);
6190 break;
6191 case PHONE_EXCEPTION:
6192 retval = j->ex.bytes;
6193 if(j->ex.bits.flash) {
6194 j->flash_end = 0;
6195 j->ex.bits.flash = 0;
6197 j->ex.bits.pstn_ring = 0;
6198 j->ex.bits.caller_id = 0;
6199 j->ex.bits.pstn_wink = 0;
6200 j->ex.bits.f0 = 0;
6201 j->ex.bits.f1 = 0;
6202 j->ex.bits.f2 = 0;
6203 j->ex.bits.f3 = 0;
6204 j->ex.bits.fc0 = 0;
6205 j->ex.bits.fc1 = 0;
6206 j->ex.bits.fc2 = 0;
6207 j->ex.bits.fc3 = 0;
6208 j->ex.bits.reserved = 0;
6209 break;
6210 case PHONE_HOOKSTATE:
6211 j->ex.bits.hookstate = 0;
6212 retval = j->hookstate; //j->r_hook;
6213 break;
6214 case IXJCTL_SET_LED:
6215 LED_SetState(arg, j);
6216 break;
6217 case PHONE_FRAME:
6218 retval = set_base_frame(j, arg);
6219 break;
6220 case PHONE_REC_CODEC:
6221 retval = set_rec_codec(j, arg);
6222 break;
6223 case PHONE_VAD:
6224 ixj_vad(j, arg);
6225 break;
6226 case PHONE_REC_START:
6227 ixj_record_start(j);
6228 break;
6229 case PHONE_REC_STOP:
6230 ixj_record_stop(j);
6231 break;
6232 case PHONE_REC_DEPTH:
6233 set_rec_depth(j, arg);
6234 break;
6235 case PHONE_REC_VOLUME:
6236 if(arg == -1) {
6237 retval = get_rec_volume(j);
6239 else {
6240 set_rec_volume(j, arg);
6241 retval = arg;
6243 break;
6244 case PHONE_REC_VOLUME_LINEAR:
6245 if(arg == -1) {
6246 retval = get_rec_volume_linear(j);
6248 else {
6249 set_rec_volume_linear(j, arg);
6250 retval = arg;
6252 break;
6253 case IXJCTL_DTMF_PRESCALE:
6254 if(arg == -1) {
6255 retval = get_dtmf_prescale(j);
6257 else {
6258 set_dtmf_prescale(j, arg);
6259 retval = arg;
6261 break;
6262 case PHONE_REC_LEVEL:
6263 retval = get_rec_level(j);
6264 break;
6265 case IXJCTL_SC_RXG:
6266 retval = ixj_siadc(j, arg);
6267 break;
6268 case IXJCTL_SC_TXG:
6269 retval = ixj_sidac(j, arg);
6270 break;
6271 case IXJCTL_AEC_START:
6272 ixj_aec_start(j, arg);
6273 break;
6274 case IXJCTL_AEC_STOP:
6275 aec_stop(j);
6276 break;
6277 case IXJCTL_AEC_GET_LEVEL:
6278 retval = j->aec_level;
6279 break;
6280 case PHONE_PLAY_CODEC:
6281 retval = set_play_codec(j, arg);
6282 break;
6283 case PHONE_PLAY_START:
6284 retval = ixj_play_start(j);
6285 break;
6286 case PHONE_PLAY_STOP:
6287 ixj_play_stop(j);
6288 break;
6289 case PHONE_PLAY_DEPTH:
6290 set_play_depth(j, arg);
6291 break;
6292 case PHONE_PLAY_VOLUME:
6293 if(arg == -1) {
6294 retval = get_play_volume(j);
6296 else {
6297 set_play_volume(j, arg);
6298 retval = arg;
6300 break;
6301 case PHONE_PLAY_VOLUME_LINEAR:
6302 if(arg == -1) {
6303 retval = get_play_volume_linear(j);
6305 else {
6306 set_play_volume_linear(j, arg);
6307 retval = arg;
6309 break;
6310 case PHONE_PLAY_LEVEL:
6311 retval = get_play_level(j);
6312 break;
6313 case IXJCTL_DSP_TYPE:
6314 retval = (j->dsp.high << 8) + j->dsp.low;
6315 break;
6316 case IXJCTL_DSP_VERSION:
6317 retval = (j->ver.high << 8) + j->ver.low;
6318 break;
6319 case IXJCTL_HZ:
6320 hertz = arg;
6321 break;
6322 case IXJCTL_RATE:
6323 if (arg > hertz)
6324 retval = -1;
6325 else
6326 samplerate = arg;
6327 break;
6328 case IXJCTL_DRYBUFFER_READ:
6329 put_user(j->drybuffer, (unsigned long __user *) argp);
6330 break;
6331 case IXJCTL_DRYBUFFER_CLEAR:
6332 j->drybuffer = 0;
6333 break;
6334 case IXJCTL_FRAMES_READ:
6335 put_user(j->framesread, (unsigned long __user *) argp);
6336 break;
6337 case IXJCTL_FRAMES_WRITTEN:
6338 put_user(j->frameswritten, (unsigned long __user *) argp);
6339 break;
6340 case IXJCTL_READ_WAIT:
6341 put_user(j->read_wait, (unsigned long __user *) argp);
6342 break;
6343 case IXJCTL_WRITE_WAIT:
6344 put_user(j->write_wait, (unsigned long __user *) argp);
6345 break;
6346 case PHONE_MAXRINGS:
6347 j->maxrings = arg;
6348 break;
6349 case PHONE_SET_TONE_ON_TIME:
6350 ixj_set_tone_on(arg, j);
6351 break;
6352 case PHONE_SET_TONE_OFF_TIME:
6353 ixj_set_tone_off(arg, j);
6354 break;
6355 case PHONE_GET_TONE_ON_TIME:
6356 if (ixj_get_tone_on(j)) {
6357 retval = -1;
6358 } else {
6359 retval = (j->ssr.high << 8) + j->ssr.low;
6361 break;
6362 case PHONE_GET_TONE_OFF_TIME:
6363 if (ixj_get_tone_off(j)) {
6364 retval = -1;
6365 } else {
6366 retval = (j->ssr.high << 8) + j->ssr.low;
6368 break;
6369 case PHONE_PLAY_TONE:
6370 if (!j->tone_state)
6371 retval = ixj_play_tone(j, arg);
6372 else
6373 retval = -1;
6374 break;
6375 case PHONE_GET_TONE_STATE:
6376 retval = j->tone_state;
6377 break;
6378 case PHONE_DTMF_READY:
6379 retval = j->ex.bits.dtmf_ready;
6380 break;
6381 case PHONE_GET_DTMF:
6382 if (ixj_hookstate(j)) {
6383 if (j->dtmf_rp != j->dtmf_wp) {
6384 retval = j->dtmfbuffer[j->dtmf_rp];
6385 j->dtmf_rp++;
6386 if (j->dtmf_rp == 79)
6387 j->dtmf_rp = 0;
6388 if (j->dtmf_rp == j->dtmf_wp) {
6389 j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
6393 break;
6394 case PHONE_GET_DTMF_ASCII:
6395 if (ixj_hookstate(j)) {
6396 if (j->dtmf_rp != j->dtmf_wp) {
6397 switch (j->dtmfbuffer[j->dtmf_rp]) {
6398 case 10:
6399 retval = 42; /* '*'; */
6401 break;
6402 case 11:
6403 retval = 48; /*'0'; */
6405 break;
6406 case 12:
6407 retval = 35; /*'#'; */
6409 break;
6410 case 28:
6411 retval = 65; /*'A'; */
6413 break;
6414 case 29:
6415 retval = 66; /*'B'; */
6417 break;
6418 case 30:
6419 retval = 67; /*'C'; */
6421 break;
6422 case 31:
6423 retval = 68; /*'D'; */
6425 break;
6426 default:
6427 retval = 48 + j->dtmfbuffer[j->dtmf_rp];
6428 break;
6430 j->dtmf_rp++;
6431 if (j->dtmf_rp == 79)
6432 j->dtmf_rp = 0;
6433 if(j->dtmf_rp == j->dtmf_wp)
6435 j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
6439 break;
6440 case PHONE_DTMF_OOB:
6441 j->flags.dtmf_oob = arg;
6442 break;
6443 case PHONE_DIALTONE:
6444 ixj_dialtone(j);
6445 break;
6446 case PHONE_BUSY:
6447 ixj_busytone(j);
6448 break;
6449 case PHONE_RINGBACK:
6450 ixj_ringback(j);
6451 break;
6452 case PHONE_WINK:
6453 if(j->cardtype == QTI_PHONEJACK)
6454 retval = -1;
6455 else
6456 retval = ixj_wink(j);
6457 break;
6458 case PHONE_CPT_STOP:
6459 ixj_cpt_stop(j);
6460 break;
6461 case PHONE_QUERY_CODEC:
6463 struct phone_codec_data pd;
6464 int val;
6465 int proto_size[] = {
6467 12, 10, 16, 9, 8, 48, 5,
6468 40, 40, 80, 40, 40, 6
6470 if(copy_from_user(&pd, argp, sizeof(pd))) {
6471 retval = -EFAULT;
6472 break;
6474 if(pd.type<1 || pd.type>13) {
6475 retval = -EPROTONOSUPPORT;
6476 break;
6478 if(pd.type<G729)
6479 val=proto_size[pd.type];
6480 else switch(j->baseframe.low)
6482 case 0xA0:val=2*proto_size[pd.type];break;
6483 case 0x50:val=proto_size[pd.type];break;
6484 default:val=proto_size[pd.type]*3;break;
6486 pd.buf_min=pd.buf_max=pd.buf_opt=val;
6487 if(copy_to_user(argp, &pd, sizeof(pd)))
6488 retval = -EFAULT;
6489 break;
6491 case IXJCTL_DSP_IDLE:
6492 idle(j);
6493 break;
6494 case IXJCTL_MIXER:
6495 if ((arg & 0xff) == 0xff)
6496 retval = ixj_get_mixer(arg, j);
6497 else
6498 ixj_mixer(arg, j);
6499 break;
6500 case IXJCTL_DAA_COEFF_SET:
6501 switch (arg) {
6502 case DAA_US:
6503 DAA_Coeff_US(j);
6504 retval = ixj_daa_write(j);
6505 break;
6506 case DAA_UK:
6507 DAA_Coeff_UK(j);
6508 retval = ixj_daa_write(j);
6509 break;
6510 case DAA_FRANCE:
6511 DAA_Coeff_France(j);
6512 retval = ixj_daa_write(j);
6513 break;
6514 case DAA_GERMANY:
6515 DAA_Coeff_Germany(j);
6516 retval = ixj_daa_write(j);
6517 break;
6518 case DAA_AUSTRALIA:
6519 DAA_Coeff_Australia(j);
6520 retval = ixj_daa_write(j);
6521 break;
6522 case DAA_JAPAN:
6523 DAA_Coeff_Japan(j);
6524 retval = ixj_daa_write(j);
6525 break;
6526 default:
6527 retval = 1;
6528 break;
6530 break;
6531 case IXJCTL_DAA_AGAIN:
6532 ixj_daa_cr4(j, arg | 0x02);
6533 break;
6534 case IXJCTL_PSTN_LINETEST:
6535 retval = ixj_linetest(j);
6536 break;
6537 case IXJCTL_VMWI:
6538 ixj_write_vmwi(j, arg);
6539 break;
6540 case IXJCTL_CID:
6541 if (copy_to_user(argp, &j->cid, sizeof(PHONE_CID)))
6542 retval = -EFAULT;
6543 j->ex.bits.caller_id = 0;
6544 break;
6545 case IXJCTL_WINK_DURATION:
6546 j->winktime = arg;
6547 break;
6548 case IXJCTL_PORT:
6549 if (arg)
6550 retval = ixj_set_port(j, arg);
6551 else
6552 retval = j->port;
6553 break;
6554 case IXJCTL_POTS_PSTN:
6555 retval = ixj_set_pots(j, arg);
6556 break;
6557 case PHONE_CAPABILITIES:
6558 add_caps(j);
6559 retval = j->caps;
6560 break;
6561 case PHONE_CAPABILITIES_LIST:
6562 add_caps(j);
6563 if (copy_to_user(argp, j->caplist, sizeof(struct phone_capability) * j->caps))
6564 retval = -EFAULT;
6565 break;
6566 case PHONE_CAPABILITIES_CHECK:
6568 struct phone_capability cap;
6569 if (copy_from_user(&cap, argp, sizeof(cap)))
6570 retval = -EFAULT;
6571 else {
6572 add_caps(j);
6573 retval = capabilities_check(j, &cap);
6576 break;
6577 case PHONE_PSTN_SET_STATE:
6578 daa_set_mode(j, arg);
6579 break;
6580 case PHONE_PSTN_GET_STATE:
6581 retval = j->daa_mode;
6582 j->ex.bits.pstn_ring = 0;
6583 break;
6584 case IXJCTL_SET_FILTER:
6585 if (copy_from_user(&jf, argp, sizeof(jf)))
6586 retval = -EFAULT;
6587 retval = ixj_init_filter(j, &jf);
6588 break;
6589 case IXJCTL_SET_FILTER_RAW:
6590 if (copy_from_user(&jfr, argp, sizeof(jfr)))
6591 retval = -EFAULT;
6592 else
6593 retval = ixj_init_filter_raw(j, &jfr);
6594 break;
6595 case IXJCTL_GET_FILTER_HIST:
6596 if(arg<0||arg>3)
6597 retval = -EINVAL;
6598 else
6599 retval = j->filter_hist[arg];
6600 break;
6601 case IXJCTL_INIT_TONE:
6602 if (copy_from_user(&ti, argp, sizeof(ti)))
6603 retval = -EFAULT;
6604 else
6605 retval = ixj_init_tone(j, &ti);
6606 break;
6607 case IXJCTL_TONE_CADENCE:
6608 retval = ixj_build_cadence(j, argp);
6609 break;
6610 case IXJCTL_FILTER_CADENCE:
6611 retval = ixj_build_filter_cadence(j, argp);
6612 break;
6613 case IXJCTL_SIGCTL:
6614 if (copy_from_user(&j->sigdef, argp, sizeof(IXJ_SIGDEF))) {
6615 retval = -EFAULT;
6616 break;
6618 j->ixj_signals[j->sigdef.event] = j->sigdef.signal;
6619 if(j->sigdef.event < 33) {
6620 raise = 1;
6621 for(mant = 0; mant < j->sigdef.event; mant++){
6622 raise *= 2;
6624 if(j->sigdef.signal)
6625 j->ex_sig.bytes |= raise;
6626 else
6627 j->ex_sig.bytes &= (raise^0xffff);
6629 break;
6630 case IXJCTL_INTERCOM_STOP:
6631 if(arg < 0 || arg >= IXJMAX)
6632 return -EINVAL;
6633 j->intercom = -1;
6634 ixj_record_stop(j);
6635 ixj_play_stop(j);
6636 idle(j);
6637 get_ixj(arg)->intercom = -1;
6638 ixj_record_stop(get_ixj(arg));
6639 ixj_play_stop(get_ixj(arg));
6640 idle(get_ixj(arg));
6641 break;
6642 case IXJCTL_INTERCOM_START:
6643 if(arg < 0 || arg >= IXJMAX)
6644 return -EINVAL;
6645 j->intercom = arg;
6646 ixj_record_start(j);
6647 ixj_play_start(j);
6648 get_ixj(arg)->intercom = board;
6649 ixj_play_start(get_ixj(arg));
6650 ixj_record_start(get_ixj(arg));
6651 break;
6653 if (ixjdebug & 0x0040)
6654 printk("phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
6655 clear_bit(board, &j->busyflags);
6656 return retval;
6659 static int ixj_fasync(int fd, struct file *file_p, int mode)
6661 IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
6663 return fasync_helper(fd, file_p, mode, &j->async_queue);
6666 static const struct file_operations ixj_fops =
6668 .owner = THIS_MODULE,
6669 .read = ixj_enhanced_read,
6670 .write = ixj_enhanced_write,
6671 .poll = ixj_poll,
6672 .ioctl = ixj_ioctl,
6673 .release = ixj_release,
6674 .fasync = ixj_fasync
6677 static int ixj_linetest(IXJ *j)
6679 j->flags.pstncheck = 1; /* Testing */
6680 j->flags.pstn_present = 0; /* Assume the line is not there */
6682 daa_int_read(j); /*Clear DAA Interrupt flags */
6683 /* */
6684 /* Hold all relays in the normally de-energized position. */
6685 /* */
6687 j->pld_slicw.bits.rly1 = 0;
6688 j->pld_slicw.bits.rly2 = 0;
6689 j->pld_slicw.bits.rly3 = 0;
6690 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6691 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6693 outb_p(j->pld_scrw.byte, j->XILINXbase);
6694 j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
6695 if (j->pld_slicr.bits.potspstn) {
6696 j->flags.pots_pstn = 1;
6697 j->flags.pots_correct = 0;
6698 LED_SetState(0x4, j);
6699 } else {
6700 j->flags.pots_pstn = 0;
6701 j->pld_slicw.bits.rly1 = 0;
6702 j->pld_slicw.bits.rly2 = 0;
6703 j->pld_slicw.bits.rly3 = 1;
6704 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6705 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6707 outb_p(j->pld_scrw.byte, j->XILINXbase);
6708 daa_set_mode(j, SOP_PU_CONVERSATION);
6709 msleep(1000);
6710 daa_int_read(j);
6711 daa_set_mode(j, SOP_PU_RESET);
6712 if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
6713 j->flags.pots_correct = 0; /* Should not be line voltage on POTS port. */
6714 LED_SetState(0x4, j);
6715 j->pld_slicw.bits.rly3 = 0;
6716 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6717 } else {
6718 j->flags.pots_correct = 1;
6719 LED_SetState(0x8, j);
6720 j->pld_slicw.bits.rly1 = 1;
6721 j->pld_slicw.bits.rly2 = 0;
6722 j->pld_slicw.bits.rly3 = 0;
6723 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6726 j->pld_slicw.bits.rly3 = 0;
6727 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6728 daa_set_mode(j, SOP_PU_CONVERSATION);
6729 msleep(1000);
6730 daa_int_read(j);
6731 daa_set_mode(j, SOP_PU_RESET);
6732 if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
6733 j->pstn_sleeptil = jiffies + (hertz / 4);
6734 j->flags.pstn_present = 1;
6735 } else {
6736 j->flags.pstn_present = 0;
6738 if (j->flags.pstn_present) {
6739 if (j->flags.pots_correct) {
6740 LED_SetState(0xA, j);
6741 } else {
6742 LED_SetState(0x6, j);
6744 } else {
6745 if (j->flags.pots_correct) {
6746 LED_SetState(0x9, j);
6747 } else {
6748 LED_SetState(0x5, j);
6751 j->flags.pstncheck = 0; /* Testing */
6752 return j->flags.pstn_present;
6755 static int ixj_selfprobe(IXJ *j)
6757 unsigned short cmd;
6758 int cnt;
6759 BYTES bytes;
6761 init_waitqueue_head(&j->poll_q);
6762 init_waitqueue_head(&j->read_q);
6763 init_waitqueue_head(&j->write_q);
6765 while(atomic_read(&j->DSPWrite) > 0)
6766 atomic_dec(&j->DSPWrite);
6767 if (ixjdebug & 0x0002)
6768 printk(KERN_INFO "Write IDLE to Software Control Register\n");
6769 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
6771 if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
6772 return -1;
6773 /* The read values of the SSR should be 0x00 for the IDLE command */
6774 if (j->ssr.low || j->ssr.high)
6775 return -1;
6776 if (ixjdebug & 0x0002)
6777 printk(KERN_INFO "Get Device ID Code\n");
6778 if (ixj_WriteDSPCommand(0x3400, j)) /* Get Device ID Code */
6779 return -1;
6780 j->dsp.low = j->ssr.low;
6781 j->dsp.high = j->ssr.high;
6782 if (ixjdebug & 0x0002)
6783 printk(KERN_INFO "Get Device Version Code\n");
6784 if (ixj_WriteDSPCommand(0x3800, j)) /* Get Device Version Code */
6785 return -1;
6786 j->ver.low = j->ssr.low;
6787 j->ver.high = j->ssr.high;
6788 if (!j->cardtype) {
6789 if (j->dsp.low == 0x21) {
6790 bytes.high = bytes.low = inb_p(j->XILINXbase + 0x02);
6791 outb_p(bytes.low ^ 0xFF, j->XILINXbase + 0x02);
6792 /* Test for Internet LineJACK or Internet PhoneJACK Lite */
6793 bytes.low = inb_p(j->XILINXbase + 0x02);
6794 if (bytes.low == bytes.high) /* Register is read only on */
6795 /* Internet PhoneJack Lite */
6797 j->cardtype = QTI_PHONEJACK_LITE;
6798 if (!request_region(j->XILINXbase, 4, "ixj control")) {
6799 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6800 return -1;
6802 j->pld_slicw.pcib.e1 = 1;
6803 outb_p(j->pld_slicw.byte, j->XILINXbase);
6804 } else {
6805 j->cardtype = QTI_LINEJACK;
6807 if (!request_region(j->XILINXbase, 8, "ixj control")) {
6808 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6809 return -1;
6812 } else if (j->dsp.low == 0x22) {
6813 j->cardtype = QTI_PHONEJACK_PCI;
6814 request_region(j->XILINXbase, 4, "ixj control");
6815 j->pld_slicw.pcib.e1 = 1;
6816 outb_p(j->pld_slicw.byte, j->XILINXbase);
6817 } else
6818 j->cardtype = QTI_PHONEJACK;
6819 } else {
6820 switch (j->cardtype) {
6821 case QTI_PHONEJACK:
6822 if (!j->dsp.low != 0x20) {
6823 j->dsp.high = 0x80;
6824 j->dsp.low = 0x20;
6825 ixj_WriteDSPCommand(0x3800, j);
6826 j->ver.low = j->ssr.low;
6827 j->ver.high = j->ssr.high;
6829 break;
6830 case QTI_LINEJACK:
6831 if (!request_region(j->XILINXbase, 8, "ixj control")) {
6832 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6833 return -1;
6835 break;
6836 case QTI_PHONEJACK_LITE:
6837 case QTI_PHONEJACK_PCI:
6838 if (!request_region(j->XILINXbase, 4, "ixj control")) {
6839 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6840 return -1;
6842 j->pld_slicw.pcib.e1 = 1;
6843 outb_p(j->pld_slicw.byte, j->XILINXbase);
6844 break;
6845 case QTI_PHONECARD:
6846 break;
6849 if (j->dsp.low == 0x20 || j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
6850 if (ixjdebug & 0x0002)
6851 printk(KERN_INFO "Write CODEC config to Software Control Register\n");
6852 if (ixj_WriteDSPCommand(0xC462, j)) /* Write CODEC config to Software Control Register */
6853 return -1;
6854 if (ixjdebug & 0x0002)
6855 printk(KERN_INFO "Write CODEC timing to Software Control Register\n");
6856 if (j->cardtype == QTI_PHONEJACK) {
6857 cmd = 0x9FF2;
6858 } else {
6859 cmd = 0x9FF5;
6861 if (ixj_WriteDSPCommand(cmd, j)) /* Write CODEC timing to Software Control Register */
6862 return -1;
6863 } else {
6864 if (set_base_frame(j, 30) != 30)
6865 return -1;
6866 if (ixjdebug & 0x0002)
6867 printk(KERN_INFO "Write CODEC config to Software Control Register\n");
6868 if (j->cardtype == QTI_PHONECARD) {
6869 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
6870 return -1;
6872 if (j->cardtype == QTI_LINEJACK) {
6873 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
6874 return -1;
6875 if (ixjdebug & 0x0002)
6876 printk(KERN_INFO "Turn on the PLD Clock at 8Khz\n");
6877 j->pld_clock.byte = 0;
6878 outb_p(j->pld_clock.byte, j->XILINXbase + 0x04);
6882 if (j->dsp.low == 0x20) {
6883 if (ixjdebug & 0x0002)
6884 printk(KERN_INFO "Configure GPIO pins\n");
6885 j->gpio.bytes.high = 0x09;
6886 /* bytes.low = 0xEF; 0xF7 */
6887 j->gpio.bits.gpio1 = 1;
6888 j->gpio.bits.gpio2 = 1;
6889 j->gpio.bits.gpio3 = 0;
6890 j->gpio.bits.gpio4 = 1;
6891 j->gpio.bits.gpio5 = 1;
6892 j->gpio.bits.gpio6 = 1;
6893 j->gpio.bits.gpio7 = 1;
6894 ixj_WriteDSPCommand(j->gpio.word, j); /* Set GPIO pin directions */
6895 if (ixjdebug & 0x0002)
6896 printk(KERN_INFO "Enable SLIC\n");
6897 j->gpio.bytes.high = 0x0B;
6898 j->gpio.bytes.low = 0x00;
6899 j->gpio.bits.gpio1 = 0;
6900 j->gpio.bits.gpio2 = 1;
6901 j->gpio.bits.gpio5 = 0;
6902 ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring stop signal */
6903 j->port = PORT_POTS;
6904 } else {
6905 if (j->cardtype == QTI_LINEJACK) {
6906 LED_SetState(0x1, j);
6907 msleep(100);
6908 LED_SetState(0x2, j);
6909 msleep(100);
6910 LED_SetState(0x4, j);
6911 msleep(100);
6912 LED_SetState(0x8, j);
6913 msleep(100);
6914 LED_SetState(0x0, j);
6915 daa_get_version(j);
6916 if (ixjdebug & 0x0002)
6917 printk("Loading DAA Coefficients\n");
6918 DAA_Coeff_US(j);
6919 if (!ixj_daa_write(j)) {
6920 printk("DAA write failed on board %d\n", j->board);
6921 return -1;
6923 if(!ixj_daa_cid_reset(j)) {
6924 printk("DAA CID reset failed on board %d\n", j->board);
6925 return -1;
6927 j->flags.pots_correct = 0;
6928 j->flags.pstn_present = 0;
6929 ixj_linetest(j);
6930 if (j->flags.pots_correct) {
6931 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6933 outb_p(j->pld_scrw.byte, j->XILINXbase);
6934 j->pld_slicw.bits.rly1 = 1;
6935 j->pld_slicw.bits.spken = 1;
6936 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6937 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
6938 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
6939 j->port = PORT_POTS;
6941 ixj_set_port(j, PORT_PSTN);
6942 ixj_set_pots(j, 1);
6943 if (ixjdebug & 0x0002)
6944 printk(KERN_INFO "Enable Mixer\n");
6945 ixj_mixer(0x0000, j); /*Master Volume Left unmute 0db */
6946 ixj_mixer(0x0100, j); /*Master Volume Right unmute 0db */
6948 ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
6949 ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
6951 ixj_mixer(0x0480, j); /*FM Left mute */
6952 ixj_mixer(0x0580, j); /*FM Right mute */
6954 ixj_mixer(0x0680, j); /*CD Left mute */
6955 ixj_mixer(0x0780, j); /*CD Right mute */
6957 ixj_mixer(0x0880, j); /*Line Left mute */
6958 ixj_mixer(0x0980, j); /*Line Right mute */
6960 ixj_mixer(0x0A80, j); /*Aux left mute */
6961 ixj_mixer(0x0B80, j); /*Aux right mute */
6963 ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
6964 ixj_mixer(0x0D80, j); /*Mono2 mute */
6966 ixj_mixer(0x0E80, j); /*Mic mute */
6968 ixj_mixer(0x0F00, j); /*Mono Out Volume unmute 0db */
6970 ixj_mixer(0x1000, j); /*Voice Left and Right out only */
6971 ixj_mixer(0x110C, j);
6974 ixj_mixer(0x1200, j); /*Mono1 switch on mixer left */
6975 ixj_mixer(0x1401, j);
6977 ixj_mixer(0x1300, j); /*Mono1 switch on mixer right */
6978 ixj_mixer(0x1501, j);
6980 ixj_mixer(0x1700, j); /*Clock select */
6982 ixj_mixer(0x1800, j); /*ADC input from mixer */
6984 ixj_mixer(0x1901, j); /*Mic gain 30db */
6986 if (ixjdebug & 0x0002)
6987 printk(KERN_INFO "Setting Default US Ring Cadence Detection\n");
6988 j->cadence_f[4].state = 0;
6989 j->cadence_f[4].on1 = 0; /*Cadence Filter 4 is used for PSTN ring cadence */
6990 j->cadence_f[4].off1 = 0;
6991 j->cadence_f[4].on2 = 0;
6992 j->cadence_f[4].off2 = 0;
6993 j->cadence_f[4].on3 = 0;
6994 j->cadence_f[4].off3 = 0; /* These should represent standard US ring pulse. */
6995 j->pstn_last_rmr = jiffies;
6997 } else {
6998 if (j->cardtype == QTI_PHONECARD) {
6999 ixj_WriteDSPCommand(0xCF07, j);
7000 ixj_WriteDSPCommand(0x00B0, j);
7001 ixj_set_port(j, PORT_SPEAKER);
7002 } else {
7003 ixj_set_port(j, PORT_POTS);
7004 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
7005 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
7010 j->intercom = -1;
7011 j->framesread = j->frameswritten = 0;
7012 j->read_wait = j->write_wait = 0;
7013 j->rxreadycheck = j->txreadycheck = 0;
7015 /* initialise the DTMF prescale to a sensible value */
7016 if (j->cardtype == QTI_LINEJACK) {
7017 set_dtmf_prescale(j, 0x10);
7018 } else {
7019 set_dtmf_prescale(j, 0x40);
7021 set_play_volume(j, 0x100);
7022 set_rec_volume(j, 0x100);
7024 if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
7025 return -1;
7026 /* The read values of the SSR should be 0x00 for the IDLE command */
7027 if (j->ssr.low || j->ssr.high)
7028 return -1;
7030 if (ixjdebug & 0x0002)
7031 printk(KERN_INFO "Enable Line Monitor\n");
7033 if (ixjdebug & 0x0002)
7034 printk(KERN_INFO "Set Line Monitor to Asyncronous Mode\n");
7036 if (ixj_WriteDSPCommand(0x7E01, j)) /* Asynchronous Line Monitor */
7037 return -1;
7039 if (ixjdebug & 0x002)
7040 printk(KERN_INFO "Enable DTMF Detectors\n");
7042 if (ixj_WriteDSPCommand(0x5151, j)) /* Enable DTMF detection */
7043 return -1;
7045 if (ixj_WriteDSPCommand(0x6E01, j)) /* Set Asyncronous Tone Generation */
7046 return -1;
7048 set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
7050 set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
7052 j->ex.bits.dtmf_ready = 0;
7053 j->dtmf_state = 0;
7054 j->dtmf_wp = j->dtmf_rp = 0;
7055 j->rec_mode = j->play_mode = -1;
7056 j->flags.ringing = 0;
7057 j->maxrings = MAXRINGS;
7058 j->ring_cadence = USA_RING_CADENCE;
7059 j->drybuffer = 0;
7060 j->winktime = 320;
7061 j->flags.dtmf_oob = 0;
7062 for (cnt = 0; cnt < 4; cnt++)
7063 j->cadence_f[cnt].enable = 0;
7064 /* must be a device on the specified address */
7065 ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
7067 /* Set up the default signals for events */
7068 for (cnt = 0; cnt < 35; cnt++)
7069 j->ixj_signals[cnt] = SIGIO;
7071 /* Set the excetion signal enable flags */
7072 j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
7073 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 =
7074 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;
7075 #ifdef IXJ_DYN_ALLOC
7076 j->fskdata = NULL;
7077 #endif
7078 j->fskdcnt = 0;
7079 j->cidcw_wait = 0;
7081 /* Register with the Telephony for Linux subsystem */
7082 j->p.f_op = &ixj_fops;
7083 j->p.open = ixj_open;
7084 j->p.board = j->board;
7085 phone_register_device(&j->p, PHONE_UNIT_ANY);
7087 ixj_init_timer(j);
7088 ixj_add_timer(j);
7089 return 0;
7093 * Exported service for pcmcia card handling
7096 IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx)
7098 IXJ *j = ixj_alloc();
7100 j->board = 0;
7102 j->DSPbase = dsp;
7103 j->XILINXbase = xilinx;
7104 j->cardtype = QTI_PHONECARD;
7105 ixj_selfprobe(j);
7106 return j;
7109 EXPORT_SYMBOL(ixj_pcmcia_probe); /* Fpr PCMCIA */
7111 static int ixj_get_status_proc(char *buf)
7113 int len;
7114 int cnt;
7115 IXJ *j;
7116 len = 0;
7117 len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER);
7118 len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ));
7119 len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS));
7120 len += sprintf(buf + len, "\nUsing old telephony API");
7121 len += sprintf(buf + len, "\nDebug Level %d\n", ixjdebug);
7123 for (cnt = 0; cnt < IXJMAX; cnt++) {
7124 j = get_ixj(cnt);
7125 if(j==NULL)
7126 continue;
7127 if (j->DSPbase) {
7128 len += sprintf(buf + len, "\nCard Num %d", cnt);
7129 len += sprintf(buf + len, "\nDSP Base Address 0x%4.4x", j->DSPbase);
7130 if (j->cardtype != QTI_PHONEJACK)
7131 len += sprintf(buf + len, "\nXILINX Base Address 0x%4.4x", j->XILINXbase);
7132 len += sprintf(buf + len, "\nDSP Type %2.2x%2.2x", j->dsp.high, j->dsp.low);
7133 len += sprintf(buf + len, "\nDSP Version %2.2x.%2.2x", j->ver.high, j->ver.low);
7134 len += sprintf(buf + len, "\nSerial Number %8.8x", j->serial);
7135 switch (j->cardtype) {
7136 case (QTI_PHONEJACK):
7137 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK");
7138 break;
7139 case (QTI_LINEJACK):
7140 len += sprintf(buf + len, "\nCard Type = Internet LineJACK");
7141 if (j->flags.g729_loaded)
7142 len += sprintf(buf + len, " w/G.729 A/B");
7143 len += sprintf(buf + len, " Country = %d", j->daa_country);
7144 break;
7145 case (QTI_PHONEJACK_LITE):
7146 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK Lite");
7147 if (j->flags.g729_loaded)
7148 len += sprintf(buf + len, " w/G.729 A/B");
7149 break;
7150 case (QTI_PHONEJACK_PCI):
7151 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK PCI");
7152 if (j->flags.g729_loaded)
7153 len += sprintf(buf + len, " w/G.729 A/B");
7154 break;
7155 case (QTI_PHONECARD):
7156 len += sprintf(buf + len, "\nCard Type = Internet PhoneCARD");
7157 if (j->flags.g729_loaded)
7158 len += sprintf(buf + len, " w/G.729 A/B");
7159 len += sprintf(buf + len, "\nSmart Cable %spresent", j->pccr1.bits.drf ? "not " : "");
7160 if (!j->pccr1.bits.drf)
7161 len += sprintf(buf + len, "\nSmart Cable type %d", j->flags.pcmciasct);
7162 len += sprintf(buf + len, "\nSmart Cable state %d", j->flags.pcmciastate);
7163 break;
7164 default:
7165 len += sprintf(buf + len, "\nCard Type = %d", j->cardtype);
7166 break;
7168 len += sprintf(buf + len, "\nReaders %d", j->readers);
7169 len += sprintf(buf + len, "\nWriters %d", j->writers);
7170 add_caps(j);
7171 len += sprintf(buf + len, "\nCapabilities %d", j->caps);
7172 if (j->dsp.low != 0x20)
7173 len += sprintf(buf + len, "\nDSP Processor load %d", j->proc_load);
7174 if (j->flags.cidsent)
7175 len += sprintf(buf + len, "\nCaller ID data sent");
7176 else
7177 len += sprintf(buf + len, "\nCaller ID data not sent");
7179 len += sprintf(buf + len, "\nPlay CODEC ");
7180 switch (j->play_codec) {
7181 case G723_63:
7182 len += sprintf(buf + len, "G.723.1 6.3");
7183 break;
7184 case G723_53:
7185 len += sprintf(buf + len, "G.723.1 5.3");
7186 break;
7187 case TS85:
7188 len += sprintf(buf + len, "TrueSpeech 8.5");
7189 break;
7190 case TS48:
7191 len += sprintf(buf + len, "TrueSpeech 4.8");
7192 break;
7193 case TS41:
7194 len += sprintf(buf + len, "TrueSpeech 4.1");
7195 break;
7196 case G728:
7197 len += sprintf(buf + len, "G.728");
7198 break;
7199 case G729:
7200 len += sprintf(buf + len, "G.729");
7201 break;
7202 case G729B:
7203 len += sprintf(buf + len, "G.729B");
7204 break;
7205 case ULAW:
7206 len += sprintf(buf + len, "uLaw");
7207 break;
7208 case ALAW:
7209 len += sprintf(buf + len, "aLaw");
7210 break;
7211 case LINEAR16:
7212 len += sprintf(buf + len, "16 bit Linear");
7213 break;
7214 case LINEAR8:
7215 len += sprintf(buf + len, "8 bit Linear");
7216 break;
7217 case WSS:
7218 len += sprintf(buf + len, "Windows Sound System");
7219 break;
7220 default:
7221 len += sprintf(buf + len, "NO CODEC CHOSEN");
7222 break;
7224 len += sprintf(buf + len, "\nRecord CODEC ");
7225 switch (j->rec_codec) {
7226 case G723_63:
7227 len += sprintf(buf + len, "G.723.1 6.3");
7228 break;
7229 case G723_53:
7230 len += sprintf(buf + len, "G.723.1 5.3");
7231 break;
7232 case TS85:
7233 len += sprintf(buf + len, "TrueSpeech 8.5");
7234 break;
7235 case TS48:
7236 len += sprintf(buf + len, "TrueSpeech 4.8");
7237 break;
7238 case TS41:
7239 len += sprintf(buf + len, "TrueSpeech 4.1");
7240 break;
7241 case G728:
7242 len += sprintf(buf + len, "G.728");
7243 break;
7244 case G729:
7245 len += sprintf(buf + len, "G.729");
7246 break;
7247 case G729B:
7248 len += sprintf(buf + len, "G.729B");
7249 break;
7250 case ULAW:
7251 len += sprintf(buf + len, "uLaw");
7252 break;
7253 case ALAW:
7254 len += sprintf(buf + len, "aLaw");
7255 break;
7256 case LINEAR16:
7257 len += sprintf(buf + len, "16 bit Linear");
7258 break;
7259 case LINEAR8:
7260 len += sprintf(buf + len, "8 bit Linear");
7261 break;
7262 case WSS:
7263 len += sprintf(buf + len, "Windows Sound System");
7264 break;
7265 default:
7266 len += sprintf(buf + len, "NO CODEC CHOSEN");
7267 break;
7269 len += sprintf(buf + len, "\nAEC ");
7270 switch (j->aec_level) {
7271 case AEC_OFF:
7272 len += sprintf(buf + len, "Off");
7273 break;
7274 case AEC_LOW:
7275 len += sprintf(buf + len, "Low");
7276 break;
7277 case AEC_MED:
7278 len += sprintf(buf + len, "Med");
7279 break;
7280 case AEC_HIGH:
7281 len += sprintf(buf + len, "High");
7282 break;
7283 case AEC_AUTO:
7284 len += sprintf(buf + len, "Auto");
7285 break;
7286 case AEC_AGC:
7287 len += sprintf(buf + len, "AEC/AGC");
7288 break;
7289 default:
7290 len += sprintf(buf + len, "unknown(%i)", j->aec_level);
7291 break;
7294 len += sprintf(buf + len, "\nRec volume 0x%x", get_rec_volume(j));
7295 len += sprintf(buf + len, "\nPlay volume 0x%x", get_play_volume(j));
7296 len += sprintf(buf + len, "\nDTMF prescale 0x%x", get_dtmf_prescale(j));
7298 len += sprintf(buf + len, "\nHook state %d", j->hookstate); /* j->r_hook); */
7300 if (j->cardtype == QTI_LINEJACK) {
7301 len += sprintf(buf + len, "\nPOTS Correct %d", j->flags.pots_correct);
7302 len += sprintf(buf + len, "\nPSTN Present %d", j->flags.pstn_present);
7303 len += sprintf(buf + len, "\nPSTN Check %d", j->flags.pstncheck);
7304 len += sprintf(buf + len, "\nPOTS to PSTN %d", j->flags.pots_pstn);
7305 switch (j->daa_mode) {
7306 case SOP_PU_SLEEP:
7307 len += sprintf(buf + len, "\nDAA PSTN On Hook");
7308 break;
7309 case SOP_PU_RINGING:
7310 len += sprintf(buf + len, "\nDAA PSTN Ringing");
7311 len += sprintf(buf + len, "\nRinging state = %d", j->cadence_f[4].state);
7312 break;
7313 case SOP_PU_CONVERSATION:
7314 len += sprintf(buf + len, "\nDAA PSTN Off Hook");
7315 break;
7316 case SOP_PU_PULSEDIALING:
7317 len += sprintf(buf + len, "\nDAA PSTN Pulse Dialing");
7318 break;
7320 len += sprintf(buf + len, "\nDAA RMR = %d", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR);
7321 len += sprintf(buf + len, "\nDAA VDD OK = %d", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK);
7322 len += sprintf(buf + len, "\nDAA CR0 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg);
7323 len += sprintf(buf + len, "\nDAA CR1 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg);
7324 len += sprintf(buf + len, "\nDAA CR2 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg);
7325 len += sprintf(buf + len, "\nDAA CR3 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg);
7326 len += sprintf(buf + len, "\nDAA CR4 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg);
7327 len += sprintf(buf + len, "\nDAA CR5 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg);
7328 len += sprintf(buf + len, "\nDAA XR0 = 0x%02x", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg);
7329 len += sprintf(buf + len, "\nDAA ringstop %ld - jiffies %ld", j->pstn_ring_stop, jiffies);
7331 switch (j->port) {
7332 case PORT_POTS:
7333 len += sprintf(buf + len, "\nPort POTS");
7334 break;
7335 case PORT_PSTN:
7336 len += sprintf(buf + len, "\nPort PSTN");
7337 break;
7338 case PORT_SPEAKER:
7339 len += sprintf(buf + len, "\nPort SPEAKER/MIC");
7340 break;
7341 case PORT_HANDSET:
7342 len += sprintf(buf + len, "\nPort HANDSET");
7343 break;
7345 if (j->dsp.low == 0x21 || j->dsp.low == 0x22) {
7346 len += sprintf(buf + len, "\nSLIC state ");
7347 switch (SLIC_GetState(j)) {
7348 case PLD_SLIC_STATE_OC:
7349 len += sprintf(buf + len, "OC");
7350 break;
7351 case PLD_SLIC_STATE_RINGING:
7352 len += sprintf(buf + len, "RINGING");
7353 break;
7354 case PLD_SLIC_STATE_ACTIVE:
7355 len += sprintf(buf + len, "ACTIVE");
7356 break;
7357 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
7358 len += sprintf(buf + len, "OHT");
7359 break;
7360 case PLD_SLIC_STATE_TIPOPEN:
7361 len += sprintf(buf + len, "TIPOPEN");
7362 break;
7363 case PLD_SLIC_STATE_STANDBY:
7364 len += sprintf(buf + len, "STANDBY");
7365 break;
7366 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
7367 len += sprintf(buf + len, "APR");
7368 break;
7369 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
7370 len += sprintf(buf + len, "OHTPR");
7371 break;
7372 default:
7373 len += sprintf(buf + len, "%d", SLIC_GetState(j));
7374 break;
7377 len += sprintf(buf + len, "\nBase Frame %2.2x.%2.2x", j->baseframe.high, j->baseframe.low);
7378 len += sprintf(buf + len, "\nCID Base Frame %2d", j->cid_base_frame_size);
7379 #ifdef PERFMON_STATS
7380 len += sprintf(buf + len, "\nTimer Checks %ld", j->timerchecks);
7381 len += sprintf(buf + len, "\nRX Ready Checks %ld", j->rxreadycheck);
7382 len += sprintf(buf + len, "\nTX Ready Checks %ld", j->txreadycheck);
7383 len += sprintf(buf + len, "\nFrames Read %ld", j->framesread);
7384 len += sprintf(buf + len, "\nFrames Written %ld", j->frameswritten);
7385 len += sprintf(buf + len, "\nDry Buffer %ld", j->drybuffer);
7386 len += sprintf(buf + len, "\nRead Waits %ld", j->read_wait);
7387 len += sprintf(buf + len, "\nWrite Waits %ld", j->write_wait);
7388 len += sprintf(buf + len, "\nStatus Waits %ld", j->statuswait);
7389 len += sprintf(buf + len, "\nStatus Wait Fails %ld", j->statuswaitfail);
7390 len += sprintf(buf + len, "\nPControl Waits %ld", j->pcontrolwait);
7391 len += sprintf(buf + len, "\nPControl Wait Fails %ld", j->pcontrolwaitfail);
7392 len += sprintf(buf + len, "\nIs Control Ready Checks %ld", j->iscontrolready);
7393 len += sprintf(buf + len, "\nIs Control Ready Check failures %ld", j->iscontrolreadyfail);
7395 #endif
7396 len += sprintf(buf + len, "\n");
7399 return len;
7402 static int ixj_read_proc(char *page, char **start, off_t off,
7403 int count, int *eof, void *data)
7405 int len = ixj_get_status_proc(page);
7406 if (len <= off+count) *eof = 1;
7407 *start = page + off;
7408 len -= off;
7409 if (len>count) len = count;
7410 if (len<0) len = 0;
7411 return len;
7415 static void cleanup(void)
7417 int cnt;
7418 IXJ *j;
7420 for (cnt = 0; cnt < IXJMAX; cnt++) {
7421 j = get_ixj(cnt);
7422 if(j != NULL && j->DSPbase) {
7423 if (ixjdebug & 0x0002)
7424 printk(KERN_INFO "IXJ: Deleting timer for /dev/phone%d\n", cnt);
7425 del_timer(&j->timer);
7426 if (j->cardtype == QTI_LINEJACK) {
7427 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
7429 outb_p(j->pld_scrw.byte, j->XILINXbase);
7430 j->pld_slicw.bits.rly1 = 0;
7431 j->pld_slicw.bits.rly2 = 0;
7432 j->pld_slicw.bits.rly3 = 0;
7433 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
7434 LED_SetState(0x0, j);
7435 if (ixjdebug & 0x0002)
7436 printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
7437 release_region(j->XILINXbase, 8);
7438 } else if (j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
7439 if (ixjdebug & 0x0002)
7440 printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
7441 release_region(j->XILINXbase, 4);
7443 kfree(j->read_buffer);
7444 kfree(j->write_buffer);
7445 if (j->dev)
7446 pnp_device_detach(j->dev);
7447 if (ixjdebug & 0x0002)
7448 printk(KERN_INFO "IXJ: Unregistering /dev/phone%d from LTAPI\n", cnt);
7449 phone_unregister_device(&j->p);
7450 if (ixjdebug & 0x0002)
7451 printk(KERN_INFO "IXJ: Releasing DSP address for /dev/phone%d\n", cnt);
7452 release_region(j->DSPbase, 16);
7453 #ifdef IXJ_DYN_ALLOC
7454 if (ixjdebug & 0x0002)
7455 printk(KERN_INFO "IXJ: Freeing memory for /dev/phone%d\n", cnt);
7456 kfree(j);
7457 ixj[cnt] = NULL;
7458 #endif
7461 if (ixjdebug & 0x0002)
7462 printk(KERN_INFO "IXJ: Removing /proc/ixj\n");
7463 remove_proc_entry ("ixj", NULL);
7466 /* Typedefs */
7467 typedef struct {
7468 BYTE length;
7469 DWORD bits;
7470 } DATABLOCK;
7472 static void PCIEE_WriteBit(WORD wEEPROMAddress, BYTE lastLCC, BYTE byData)
7474 lastLCC = lastLCC & 0xfb;
7475 lastLCC = lastLCC | (byData ? 4 : 0);
7476 outb(lastLCC, wEEPROMAddress); /*set data out bit as appropriate */
7478 mdelay(1);
7479 lastLCC = lastLCC | 0x01;
7480 outb(lastLCC, wEEPROMAddress); /*SK rising edge */
7482 byData = byData << 1;
7483 lastLCC = lastLCC & 0xfe;
7484 mdelay(1);
7485 outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
7489 static BYTE PCIEE_ReadBit(WORD wEEPROMAddress, BYTE lastLCC)
7491 mdelay(1);
7492 lastLCC = lastLCC | 0x01;
7493 outb(lastLCC, wEEPROMAddress); /*SK rising edge */
7495 lastLCC = lastLCC & 0xfe;
7496 mdelay(1);
7497 outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
7499 return ((inb(wEEPROMAddress) >> 3) & 1);
7502 static bool PCIEE_ReadWord(WORD wAddress, WORD wLoc, WORD * pwResult)
7504 BYTE lastLCC;
7505 WORD wEEPROMAddress = wAddress + 3;
7506 DWORD i;
7507 BYTE byResult;
7508 *pwResult = 0;
7509 lastLCC = inb(wEEPROMAddress);
7510 lastLCC = lastLCC | 0x02;
7511 lastLCC = lastLCC & 0xfe;
7512 outb(lastLCC, wEEPROMAddress); /* CS hi, SK lo */
7514 mdelay(1); /* delay */
7516 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
7517 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
7518 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 0);
7519 for (i = 0; i < 8; i++) {
7520 PCIEE_WriteBit(wEEPROMAddress, lastLCC, wLoc & 0x80 ? 1 : 0);
7521 wLoc <<= 1;
7524 for (i = 0; i < 16; i++) {
7525 byResult = PCIEE_ReadBit(wEEPROMAddress, lastLCC);
7526 *pwResult = (*pwResult << 1) | byResult;
7529 mdelay(1); /* another delay */
7531 lastLCC = lastLCC & 0xfd;
7532 outb(lastLCC, wEEPROMAddress); /* negate CS */
7534 return 0;
7537 static DWORD PCIEE_GetSerialNumber(WORD wAddress)
7539 WORD wLo, wHi;
7540 if (PCIEE_ReadWord(wAddress, 62, &wLo))
7541 return 0;
7542 if (PCIEE_ReadWord(wAddress, 63, &wHi))
7543 return 0;
7544 return (((DWORD) wHi << 16) | wLo);
7547 static int dspio[IXJMAX + 1] =
7551 static int xio[IXJMAX + 1] =
7556 module_param_array(dspio, int, NULL, 0);
7557 module_param_array(xio, int, NULL, 0);
7558 MODULE_DESCRIPTION("Quicknet VoIP Telephony card module - www.quicknet.net");
7559 MODULE_AUTHOR("Ed Okerson <eokerson@quicknet.net>");
7560 MODULE_LICENSE("GPL");
7562 static void __exit ixj_exit(void)
7564 cleanup();
7567 static IXJ *new_ixj(unsigned long port)
7569 IXJ *res;
7570 if (!request_region(port, 16, "ixj DSP")) {
7571 printk(KERN_INFO "ixj: can't get I/O address 0x%lx\n", port);
7572 return NULL;
7574 res = ixj_alloc();
7575 if (!res) {
7576 release_region(port, 16);
7577 printk(KERN_INFO "ixj: out of memory\n");
7578 return NULL;
7580 res->DSPbase = port;
7581 return res;
7584 static int __init ixj_probe_isapnp(int *cnt)
7586 int probe = 0;
7587 int func = 0x110;
7588 struct pnp_dev *dev = NULL, *old_dev = NULL;
7590 while (1) {
7591 do {
7592 IXJ *j;
7593 int result;
7595 old_dev = dev;
7596 dev = pnp_find_dev(NULL, ISAPNP_VENDOR('Q', 'T', 'I'),
7597 ISAPNP_FUNCTION(func), old_dev);
7598 if (!dev || !dev->card)
7599 break;
7600 result = pnp_device_attach(dev);
7601 if (result < 0) {
7602 printk("pnp attach failed %d \n", result);
7603 break;
7605 if (pnp_activate_dev(dev) < 0) {
7606 printk("pnp activate failed (out of resources?)\n");
7607 pnp_device_detach(dev);
7608 return -ENOMEM;
7611 if (!pnp_port_valid(dev, 0)) {
7612 pnp_device_detach(dev);
7613 return -ENODEV;
7616 j = new_ixj(pnp_port_start(dev, 0));
7617 if (!j)
7618 break;
7620 if (func != 0x110)
7621 j->XILINXbase = pnp_port_start(dev, 1); /* get real port */
7623 switch (func) {
7624 case (0x110):
7625 j->cardtype = QTI_PHONEJACK;
7626 break;
7627 case (0x310):
7628 j->cardtype = QTI_LINEJACK;
7629 break;
7630 case (0x410):
7631 j->cardtype = QTI_PHONEJACK_LITE;
7632 break;
7634 j->board = *cnt;
7635 probe = ixj_selfprobe(j);
7636 if(!probe) {
7637 j->serial = dev->card->serial;
7638 j->dev = dev;
7639 switch (func) {
7640 case 0x110:
7641 printk(KERN_INFO "ixj: found Internet PhoneJACK at 0x%x\n", j->DSPbase);
7642 break;
7643 case 0x310:
7644 printk(KERN_INFO "ixj: found Internet LineJACK at 0x%x\n", j->DSPbase);
7645 break;
7646 case 0x410:
7647 printk(KERN_INFO "ixj: found Internet PhoneJACK Lite at 0x%x\n", j->DSPbase);
7648 break;
7651 ++*cnt;
7652 } while (dev);
7653 if (func == 0x410)
7654 break;
7655 if (func == 0x310)
7656 func = 0x410;
7657 if (func == 0x110)
7658 func = 0x310;
7659 dev = NULL;
7661 return probe;
7664 static int __init ixj_probe_isa(int *cnt)
7666 int i, probe;
7668 /* Use passed parameters for older kernels without PnP */
7669 for (i = 0; i < IXJMAX; i++) {
7670 if (dspio[i]) {
7671 IXJ *j = new_ixj(dspio[i]);
7673 if (!j)
7674 break;
7676 j->XILINXbase = xio[i];
7677 j->cardtype = 0;
7679 j->board = *cnt;
7680 probe = ixj_selfprobe(j);
7681 j->dev = NULL;
7682 ++*cnt;
7685 return 0;
7688 static int __init ixj_probe_pci(int *cnt)
7690 struct pci_dev *pci = NULL;
7691 int i, probe = 0;
7692 IXJ *j = NULL;
7694 for (i = 0; i < IXJMAX - *cnt; i++) {
7695 pci = pci_find_device(PCI_VENDOR_ID_QUICKNET,
7696 PCI_DEVICE_ID_QUICKNET_XJ, pci);
7697 if (!pci)
7698 break;
7700 if (pci_enable_device(pci))
7701 break;
7702 j = new_ixj(pci_resource_start(pci, 0));
7703 if (!j)
7704 break;
7706 j->serial = (PCIEE_GetSerialNumber)pci_resource_start(pci, 2);
7707 j->XILINXbase = j->DSPbase + 0x10;
7708 j->cardtype = QTI_PHONEJACK_PCI;
7709 j->board = *cnt;
7710 probe = ixj_selfprobe(j);
7711 if (!probe)
7712 printk(KERN_INFO "ixj: found Internet PhoneJACK PCI at 0x%x\n", j->DSPbase);
7713 ++*cnt;
7715 return probe;
7718 static int __init ixj_init(void)
7720 int cnt = 0;
7721 int probe = 0;
7723 cnt = 0;
7725 /* These might be no-ops, see above. */
7726 if ((probe = ixj_probe_isapnp(&cnt)) < 0) {
7727 return probe;
7729 if ((probe = ixj_probe_isa(&cnt)) < 0) {
7730 return probe;
7732 if ((probe = ixj_probe_pci(&cnt)) < 0) {
7733 return probe;
7735 printk(KERN_INFO "ixj driver initialized.\n");
7736 create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL);
7737 return probe;
7740 module_init(ixj_init);
7741 module_exit(ixj_exit);
7743 static void DAA_Coeff_US(IXJ *j)
7745 int i;
7747 j->daa_country = DAA_US;
7748 /*----------------------------------------------- */
7749 /* CAO */
7750 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
7751 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
7754 /* Bytes for IM-filter part 1 (04): 0E,32,E2,2F,C2,5A,C0,00 */
7755 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x03;
7756 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0x4B;
7757 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x5D;
7758 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xCD;
7759 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x24;
7760 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xC5;
7761 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
7762 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
7763 /* Bytes for IM-filter part 2 (05): 72,85,00,0E,2B,3A,D0,08 */
7764 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x71;
7765 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x1A;
7766 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
7767 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
7768 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xB5;
7769 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
7770 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
7771 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
7772 /* Bytes for FRX-filter (08): 03,8F,48,F2,8F,48,70,08 */
7773 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x05;
7774 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xA3;
7775 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x72;
7776 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
7777 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x3F;
7778 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x3B;
7779 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
7780 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
7781 /* Bytes for FRR-filter (07): 04,8F,38,7F,9B,EA,B0,08 */
7782 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x05;
7783 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
7784 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
7785 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x3E;
7786 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x32;
7787 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xDA;
7788 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
7789 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
7790 /* Bytes for AX-filter (0A): 16,55,DD,CA */
7791 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x41;
7792 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
7793 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
7794 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
7795 /* Bytes for AR-filter (09): 52,D3,11,42 */
7796 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
7797 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
7798 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
7799 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
7800 /* Bytes for TH-filter part 1 (00): 00,42,48,81,B3,80,00,98 */
7801 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
7802 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
7803 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
7804 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
7805 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA5;
7806 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
7807 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
7808 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
7809 /* Bytes for TH-filter part 2 (01): 02,F2,33,A0,68,AB,8A,AD */
7810 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
7811 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xA2;
7812 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2B;
7813 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
7814 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
7815 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAB;
7816 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
7817 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xCC;
7818 /* Bytes for TH-filter part 3 (02): 00,88,DA,54,A4,BA,2D,BB */
7819 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
7820 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
7821 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xD2;
7822 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x24;
7823 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBA;
7824 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xA9;
7825 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x3B;
7826 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xA6;
7827 /* ; (10K, 0.68uF) */
7828 /* */
7829 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
7830 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
7831 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
7832 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
7833 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
7834 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
7835 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
7836 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
7837 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
7838 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
7839 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
7840 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
7841 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
7842 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
7843 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
7844 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
7845 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
7846 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
7848 /* Levelmetering Ringing (0D):B2,45,0F,8E */
7849 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
7850 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
7851 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
7852 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
7854 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
7855 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1C; */
7856 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0xB3; */
7857 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0xAB; */
7858 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xAB; */
7859 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x54; */
7860 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x2D; */
7861 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0x62; */
7862 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x2D; */
7863 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
7864 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x2D; */
7865 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x62; */
7866 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; */
7867 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBB; */
7868 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x2A; */
7869 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7D; */
7870 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; */
7871 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD4; */
7872 /* */
7873 /* Levelmetering Ringing (0D):B2,45,0F,8E */
7874 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; */
7875 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x05; */
7876 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; */
7877 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; */
7879 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
7880 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
7881 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
7882 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
7883 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
7884 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
7885 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
7886 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
7887 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
7888 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
7889 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
7890 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
7891 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
7892 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
7893 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
7894 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
7895 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
7896 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
7897 /* */
7898 /* ;CR Registers */
7899 /* Config. Reg. 0 (filters) (cr0):FE ; CLK gen. by crystal */
7900 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
7901 /* Config. Reg. 1 (dialing) (cr1):05 */
7902 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
7903 /* Config. Reg. 2 (caller ID) (cr2):04 */
7904 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
7905 /* Config. Reg. 3 (testloops) (cr3):03 ; SEL Bit==0, HP-disabled */
7906 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
7907 /* Config. Reg. 4 (analog gain) (cr4):02 */
7908 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
7909 /* Config. Reg. 5 (Version) (cr5):02 */
7910 /* Config. Reg. 6 (Reserved) (cr6):00 */
7911 /* Config. Reg. 7 (Reserved) (cr7):00 */
7912 /* */
7913 /* ;xr Registers */
7914 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
7916 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
7917 /* Ext. Reg. 1 (Interrupt enable) (xr1):3C Cadence, RING, Caller ID, VDD_OK */
7919 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x3C;
7920 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
7921 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
7922 /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off == 1 */
7923 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x3B; /*0x32; */
7924 /* Ext. Reg. 4 (Cadence) (xr4):00 */
7926 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
7927 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
7928 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
7929 /* Ext. Reg. 6 (Power State) (xr6):00 */
7930 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
7931 /* Ext. Reg. 7 (Vdd) (xr7):40 */
7932 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
7933 /* */
7934 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
7935 /* 12,33,5A,C3 ; 770 Hz */
7936 /* 13,3C,5B,32 ; 852 Hz */
7937 /* 1D,1B,5C,CC ; 941 Hz */
7939 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
7940 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
7941 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
7942 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
7943 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
7944 /* EC,1D,52,22 ; 1336 Hz */
7945 /* AA,AC,51,D2 ; 1477 Hz */
7946 /* 9B,3B,51,25 ; 1633 Hz */
7947 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
7948 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
7949 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
7950 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
7953 static void DAA_Coeff_UK(IXJ *j)
7955 int i;
7957 j->daa_country = DAA_UK;
7958 /*----------------------------------------------- */
7959 /* CAO */
7960 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
7961 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
7964 /* Bytes for IM-filter part 1 (04): 00,C2,BB,A8,CB,81,A0,00 */
7965 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
7966 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xC2;
7967 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
7968 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xA8;
7969 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xCB;
7970 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
7971 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
7972 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
7973 /* Bytes for IM-filter part 2 (05): 40,00,00,0A,A4,33,E0,08 */
7974 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x40;
7975 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x00;
7976 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
7977 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
7978 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xA4;
7979 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
7980 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
7981 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
7982 /* Bytes for FRX-filter (08): 07,9B,ED,24,B2,A2,A0,08 */
7983 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
7984 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9B;
7985 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xED;
7986 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x24;
7987 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0xB2;
7988 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0xA2;
7989 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xA0;
7990 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
7991 /* Bytes for FRR-filter (07): 0F,92,F2,B2,87,D2,30,08 */
7992 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
7993 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x92;
7994 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF2;
7995 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0xB2;
7996 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
7997 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xD2;
7998 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x30;
7999 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8000 /* Bytes for AX-filter (0A): 1B,A5,DD,CA */
8001 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x1B;
8002 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xA5;
8003 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8004 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8005 /* Bytes for AR-filter (09): E2,27,10,D6 */
8006 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
8007 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x27;
8008 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8009 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8010 /* Bytes for TH-filter part 1 (00): 80,2D,38,8B,D0,00,00,98 */
8011 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8012 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x2D;
8013 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x38;
8014 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x8B;
8015 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xD0;
8016 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x00;
8017 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8018 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8019 /* Bytes for TH-filter part 2 (01): 02,5A,53,F0,0B,5F,84,D4 */
8020 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8021 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x5A;
8022 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x53;
8023 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xF0;
8024 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x0B;
8025 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5F;
8026 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x84;
8027 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xD4;
8028 /* Bytes for TH-filter part 3 (02): 00,88,6A,A4,8F,52,F5,32 */
8029 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8030 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8031 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x6A;
8032 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA4;
8033 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x8F;
8034 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x52;
8035 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xF5;
8036 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x32;
8037 /* ; idle */
8038 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8039 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8040 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8041 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8042 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8043 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8044 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8045 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8046 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8047 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8048 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8049 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8050 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8051 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8052 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8053 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8054 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8055 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8056 /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V less possible? */
8057 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
8058 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
8059 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8060 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8061 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8062 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8063 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8064 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8065 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8066 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8067 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8068 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8069 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8070 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8071 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8072 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8073 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8074 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8075 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8076 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8077 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8078 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8079 /* ;CR Registers */
8080 /* Config. Reg. 0 (filters) (cr0):FF */
8081 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8082 /* Config. Reg. 1 (dialing) (cr1):05 */
8083 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8084 /* Config. Reg. 2 (caller ID) (cr2):04 */
8085 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8086 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8087 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8088 /* Config. Reg. 4 (analog gain) (cr4):02 */
8089 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8090 /* Config. Reg. 5 (Version) (cr5):02 */
8091 /* Config. Reg. 6 (Reserved) (cr6):00 */
8092 /* Config. Reg. 7 (Reserved) (cr7):00 */
8093 /* ;xr Registers */
8094 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8096 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8097 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8099 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8100 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8102 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8103 /* Ext. Reg. 3 (DC Char) (xr3):36 ; */
8104 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
8105 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8106 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8107 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8108 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8109 /* Ext. Reg. 6 (Power State) (xr6):00 */
8110 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8111 /* Ext. Reg. 7 (Vdd) (xr7):46 */
8112 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
8113 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8114 /* 12,33,5A,C3 ; 770 Hz */
8115 /* 13,3C,5B,32 ; 852 Hz */
8116 /* 1D,1B,5C,CC ; 941 Hz */
8118 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8119 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8120 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8121 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8122 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8123 /* EC,1D,52,22 ; 1336 Hz */
8124 /* AA,AC,51,D2 ; 1477 Hz */
8125 /* 9B,3B,51,25 ; 1633 Hz */
8126 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8127 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8128 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8129 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8133 static void DAA_Coeff_France(IXJ *j)
8135 int i;
8137 j->daa_country = DAA_FRANCE;
8138 /*----------------------------------------------- */
8139 /* CAO */
8140 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8141 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8144 /* Bytes for IM-filter part 1 (04): 02,A2,43,2C,22,AF,A0,00 */
8145 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x02;
8146 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA2;
8147 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x43;
8148 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2C;
8149 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x22;
8150 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xAF;
8151 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
8152 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8153 /* Bytes for IM-filter part 2 (05): 67,CE,00,0C,22,33,E0,08 */
8154 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x67;
8155 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xCE;
8156 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8157 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x2C;
8158 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x22;
8159 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8160 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8161 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8162 /* Bytes for FRX-filter (08): 07,9A,28,F6,23,4A,B0,08 */
8163 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8164 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9A;
8165 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x28;
8166 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0xF6;
8167 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x23;
8168 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x4A;
8169 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xB0;
8170 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8171 /* Bytes for FRR-filter (07): 03,8F,F9,2F,9E,FA,20,08 */
8172 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
8173 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
8174 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
8175 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
8176 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9E;
8177 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xFA;
8178 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
8179 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8180 /* Bytes for AX-filter (0A): 16,B5,DD,CA */
8181 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x16;
8182 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
8183 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8184 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8185 /* Bytes for AR-filter (09): 52,C7,10,D6 */
8186 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
8187 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
8188 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8189 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8190 /* Bytes for TH-filter part 1 (00): 00,42,48,81,A6,80,00,98 */
8191 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
8192 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
8193 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8194 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8195 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA6;
8196 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8197 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8198 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8199 /* Bytes for TH-filter part 2 (01): 02,AC,2A,30,78,AC,8A,2C */
8200 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8201 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAC;
8202 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
8203 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x30;
8204 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x78;
8205 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAC;
8206 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x8A;
8207 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x2C;
8208 /* Bytes for TH-filter part 3 (02): 00,88,DA,A5,22,BA,2C,45 */
8209 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8210 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8211 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
8212 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA5;
8213 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x22;
8214 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xBA;
8215 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x2C;
8216 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x45;
8217 /* ; idle */
8218 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8219 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8220 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8221 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8222 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8223 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8224 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8225 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8226 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8227 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8228 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8229 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8230 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8231 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8232 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8233 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8234 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8235 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8236 /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
8237 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
8238 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8239 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
8240 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
8241 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8242 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8243 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8244 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8245 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8246 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8247 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8248 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8249 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8250 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8251 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8252 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8253 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8254 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8255 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8256 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8257 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8258 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8259 /* ;CR Registers */
8260 /* Config. Reg. 0 (filters) (cr0):FF */
8261 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8262 /* Config. Reg. 1 (dialing) (cr1):05 */
8263 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8264 /* Config. Reg. 2 (caller ID) (cr2):04 */
8265 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8266 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8267 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8268 /* Config. Reg. 4 (analog gain) (cr4):02 */
8269 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8270 /* Config. Reg. 5 (Version) (cr5):02 */
8271 /* Config. Reg. 6 (Reserved) (cr6):00 */
8272 /* Config. Reg. 7 (Reserved) (cr7):00 */
8273 /* ;xr Registers */
8274 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8276 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8277 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8279 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8280 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8282 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8283 /* Ext. Reg. 3 (DC Char) (xr3):36 ; */
8284 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
8285 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8286 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8287 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8288 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8289 /* Ext. Reg. 6 (Power State) (xr6):00 */
8290 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8291 /* Ext. Reg. 7 (Vdd) (xr7):46 */
8292 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
8293 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8294 /* 12,33,5A,C3 ; 770 Hz */
8295 /* 13,3C,5B,32 ; 852 Hz */
8296 /* 1D,1B,5C,CC ; 941 Hz */
8298 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8299 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8300 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8301 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8302 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8303 /* EC,1D,52,22 ; 1336 Hz */
8304 /* AA,AC,51,D2 ; 1477 Hz */
8305 /* 9B,3B,51,25 ; 1633 Hz */
8306 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8307 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8308 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8309 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8313 static void DAA_Coeff_Germany(IXJ *j)
8315 int i;
8317 j->daa_country = DAA_GERMANY;
8318 /*----------------------------------------------- */
8319 /* CAO */
8320 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8321 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8324 /* Bytes for IM-filter part 1 (04): 00,CE,BB,B8,D2,81,B0,00 */
8325 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
8326 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xCE;
8327 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
8328 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xB8;
8329 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xD2;
8330 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
8331 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xB0;
8332 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8333 /* Bytes for IM-filter part 2 (05): 45,8F,00,0C,D2,3A,D0,08 */
8334 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x45;
8335 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x8F;
8336 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8337 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0C;
8338 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xD2;
8339 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x3A;
8340 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xD0;
8341 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8342 /* Bytes for FRX-filter (08): 07,AA,E2,34,24,89,20,08 */
8343 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8344 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xAA;
8345 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
8346 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
8347 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x24;
8348 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x89;
8349 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x20;
8350 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8351 /* Bytes for FRR-filter (07): 02,87,FA,37,9A,CA,B0,08 */
8352 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x02;
8353 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
8354 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xFA;
8355 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x37;
8356 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9A;
8357 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCA;
8358 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
8359 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8360 /* Bytes for AX-filter (0A): 72,D5,DD,CA */
8361 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x72;
8362 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xD5;
8363 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8364 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8365 /* Bytes for AR-filter (09): 72,42,13,4B */
8366 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x72;
8367 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x42;
8368 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x13;
8369 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0x4B;
8370 /* Bytes for TH-filter part 1 (00): 80,52,48,81,AD,80,00,98 */
8371 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8372 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
8373 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8374 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8375 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAD;
8376 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8377 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8378 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8379 /* Bytes for TH-filter part 2 (01): 02,42,5A,20,E8,1A,81,27 */
8380 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8381 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x42;
8382 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x5A;
8383 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
8384 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
8385 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x1A;
8386 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
8387 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x27;
8388 /* Bytes for TH-filter part 3 (02): 00,88,63,26,BD,4B,A3,C2 */
8389 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8390 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8391 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x63;
8392 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x26;
8393 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBD;
8394 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x4B;
8395 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xA3;
8396 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xC2;
8397 /* ; (10K, 0.68uF) */
8398 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
8399 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8400 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3B;
8401 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x9B;
8402 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xBA;
8403 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0xD4;
8404 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x1C;
8405 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xB3;
8406 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8407 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
8408 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x13;
8409 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x42;
8410 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8411 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8412 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0xD4;
8413 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x73;
8414 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0xCA;
8415 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8416 /* Levelmetering Ringing (0D):B2,45,0F,8E */
8417 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xB2;
8418 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8419 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8420 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8421 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8422 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8423 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8424 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8425 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8426 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8427 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8428 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8429 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8430 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8431 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8432 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8433 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8434 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8435 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8436 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8437 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8438 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8439 /* ;CR Registers */
8440 /* Config. Reg. 0 (filters) (cr0):FF ; all Filters enabled, CLK from ext. source */
8441 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8442 /* Config. Reg. 1 (dialing) (cr1):05 ; Manual Ring, Ring metering enabled */
8443 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8444 /* Config. Reg. 2 (caller ID) (cr2):04 ; Analog Gain 0dB, FSC internal */
8445 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8446 /* Config. Reg. 3 (testloops) (cr3):00 ; SEL Bit==0, HP-enabled */
8447 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8448 /* Config. Reg. 4 (analog gain) (cr4):02 */
8449 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8450 /* Config. Reg. 5 (Version) (cr5):02 */
8451 /* Config. Reg. 6 (Reserved) (cr6):00 */
8452 /* Config. Reg. 7 (Reserved) (cr7):00 */
8453 /* ;xr Registers */
8454 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8456 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8457 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C ; Ring, CID, VDDOK Interrupts enabled */
8459 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8460 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8462 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8463 /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off==1, U0=3.5V, R=200Ohm */
8464 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x32;
8465 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8466 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8467 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8468 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8469 /* Ext. Reg. 6 (Power State) (xr6):00 */
8470 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8471 /* Ext. Reg. 7 (Vdd) (xr7):40 ; VDD=4.25 V */
8472 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8473 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8474 /* 12,33,5A,C3 ; 770 Hz */
8475 /* 13,3C,5B,32 ; 852 Hz */
8476 /* 1D,1B,5C,CC ; 941 Hz */
8478 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8479 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8480 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8481 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8482 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8483 /* EC,1D,52,22 ; 1336 Hz */
8484 /* AA,AC,51,D2 ; 1477 Hz */
8485 /* 9B,3B,51,25 ; 1633 Hz */
8486 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8487 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8488 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8489 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8493 static void DAA_Coeff_Australia(IXJ *j)
8495 int i;
8497 j->daa_country = DAA_AUSTRALIA;
8498 /*----------------------------------------------- */
8499 /* CAO */
8500 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8501 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8504 /* Bytes for IM-filter part 1 (04): 00,A3,AA,28,B3,82,D0,00 */
8505 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
8506 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA3;
8507 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xAA;
8508 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x28;
8509 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xB3;
8510 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x82;
8511 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xD0;
8512 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8513 /* Bytes for IM-filter part 2 (05): 70,96,00,09,32,6B,C0,08 */
8514 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x70;
8515 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x96;
8516 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8517 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x09;
8518 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x32;
8519 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x6B;
8520 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xC0;
8521 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8522 /* Bytes for FRX-filter (08): 07,96,E2,34,32,9B,30,08 */
8523 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8524 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x96;
8525 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
8526 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
8527 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x32;
8528 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x9B;
8529 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
8530 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8531 /* Bytes for FRR-filter (07): 0F,9A,E9,2F,22,CC,A0,08 */
8532 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
8533 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x9A;
8534 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xE9;
8535 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
8536 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x22;
8537 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCC;
8538 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xA0;
8539 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8540 /* Bytes for AX-filter (0A): CB,45,DD,CA */
8541 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0xCB;
8542 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0x45;
8543 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8544 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8545 /* Bytes for AR-filter (09): 1B,67,10,D6 */
8546 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x1B;
8547 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x67;
8548 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8549 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8550 /* Bytes for TH-filter part 1 (00): 80,52,48,81,AF,80,00,98 */
8551 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8552 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
8553 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8554 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8555 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAF;
8556 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8557 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8558 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8559 /* Bytes for TH-filter part 2 (01): 02,DB,52,B0,38,01,82,AC */
8560 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8561 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xDB;
8562 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x52;
8563 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
8564 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x38;
8565 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x01;
8566 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x82;
8567 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xAC;
8568 /* Bytes for TH-filter part 3 (02): 00,88,4A,3E,2C,3B,24,46 */
8569 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8570 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8571 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x4A;
8572 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x3E;
8573 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x2C;
8574 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x3B;
8575 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x24;
8576 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x46;
8577 /* ; idle */
8578 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8579 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8580 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8581 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8582 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8583 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8584 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8585 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8586 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8587 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8588 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8589 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8590 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8591 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8592 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8593 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8594 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8595 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8596 /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
8597 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
8598 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8599 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
8600 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
8601 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8602 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8603 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8604 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8605 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8606 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8607 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8608 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8609 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8610 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8611 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8612 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8613 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8614 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8615 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8616 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8617 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8618 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8619 /* ;CR Registers */
8620 /* Config. Reg. 0 (filters) (cr0):FF */
8621 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8622 /* Config. Reg. 1 (dialing) (cr1):05 */
8623 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8624 /* Config. Reg. 2 (caller ID) (cr2):04 */
8625 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8626 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8627 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8628 /* Config. Reg. 4 (analog gain) (cr4):02 */
8629 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8630 /* Config. Reg. 5 (Version) (cr5):02 */
8631 /* Config. Reg. 6 (Reserved) (cr6):00 */
8632 /* Config. Reg. 7 (Reserved) (cr7):00 */
8633 /* ;xr Registers */
8634 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8636 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8637 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8639 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8640 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8642 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8643 /* Ext. Reg. 3 (DC Char) (xr3):2B ; */
8644 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x2B;
8645 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8646 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8647 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8648 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8649 /* Ext. Reg. 6 (Power State) (xr6):00 */
8650 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8651 /* Ext. Reg. 7 (Vdd) (xr7):40 */
8652 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8654 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8655 /* 12,33,5A,C3 ; 770 Hz */
8656 /* 13,3C,5B,32 ; 852 Hz */
8657 /* 1D,1B,5C,CC ; 941 Hz */
8658 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8659 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8660 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8661 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8663 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8664 /* EC,1D,52,22 ; 1336 Hz */
8665 /* AA,AC,51,D2 ; 1477 Hz */
8666 /* 9B,3B,51,25 ; 1633 Hz */
8667 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8668 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8669 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8670 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8673 static void DAA_Coeff_Japan(IXJ *j)
8675 int i;
8677 j->daa_country = DAA_JAPAN;
8678 /*----------------------------------------------- */
8679 /* CAO */
8680 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8681 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8684 /* Bytes for IM-filter part 1 (04): 06,BD,E2,2D,BA,F9,A0,00 */
8685 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x06;
8686 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xBD;
8687 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xE2;
8688 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2D;
8689 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xBA;
8690 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xF9;
8691 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
8692 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8693 /* Bytes for IM-filter part 2 (05): 6F,F7,00,0E,34,33,E0,08 */
8694 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x6F;
8695 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xF7;
8696 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8697 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0E;
8698 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x34;
8699 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8700 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8701 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8702 /* Bytes for FRX-filter (08): 02,8F,68,77,9C,58,F0,08 */
8703 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x02;
8704 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x8F;
8705 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x68;
8706 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x77;
8707 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x9C;
8708 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x58;
8709 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xF0;
8710 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8711 /* Bytes for FRR-filter (07): 03,8F,38,73,87,EA,20,08 */
8712 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
8713 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
8714 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0x38;
8715 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x73;
8716 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
8717 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xEA;
8718 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
8719 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8720 /* Bytes for AX-filter (0A): 51,C5,DD,CA */
8721 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x51;
8722 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xC5;
8723 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8724 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8725 /* Bytes for AR-filter (09): 25,A7,10,D6 */
8726 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
8727 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xA7;
8728 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8729 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8730 /* Bytes for TH-filter part 1 (00): 00,42,48,81,AE,80,00,98 */
8731 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
8732 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
8733 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8734 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8735 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAE;
8736 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8737 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8738 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8739 /* Bytes for TH-filter part 2 (01): 02,AB,2A,20,99,5B,89,28 */
8740 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8741 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAB;
8742 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
8743 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
8744 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x99;
8745 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5B;
8746 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x89;
8747 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x28;
8748 /* Bytes for TH-filter part 3 (02): 00,88,DA,25,34,C5,4C,BA */
8749 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8750 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8751 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
8752 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x25;
8753 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x34;
8754 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xC5;
8755 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x4C;
8756 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xBA;
8757 /* ; idle */
8758 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8759 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8760 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8761 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8762 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8763 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8764 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8765 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8766 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8767 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8768 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8769 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8770 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8771 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8772 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8773 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8774 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8775 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8776 /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V ????????? */
8777 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
8778 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
8779 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8780 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8781 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8782 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8783 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8784 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8785 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8786 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8787 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8788 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8789 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8790 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8791 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8792 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8793 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8794 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8795 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8796 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8797 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8798 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8799 /* ;CR Registers */
8800 /* Config. Reg. 0 (filters) (cr0):FF */
8801 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8802 /* Config. Reg. 1 (dialing) (cr1):05 */
8803 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8804 /* Config. Reg. 2 (caller ID) (cr2):04 */
8805 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8806 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8807 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8808 /* Config. Reg. 4 (analog gain) (cr4):02 */
8809 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8810 /* Config. Reg. 5 (Version) (cr5):02 */
8811 /* Config. Reg. 6 (Reserved) (cr6):00 */
8812 /* Config. Reg. 7 (Reserved) (cr7):00 */
8813 /* ;xr Registers */
8814 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8816 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8817 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8819 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8820 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8822 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8823 /* Ext. Reg. 3 (DC Char) (xr3):22 ; */
8824 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x22;
8825 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8826 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8827 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8828 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8829 /* Ext. Reg. 6 (Power State) (xr6):00 */
8830 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8831 /* Ext. Reg. 7 (Vdd) (xr7):40 */
8832 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8833 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8834 /* 12,33,5A,C3 ; 770 Hz */
8835 /* 13,3C,5B,32 ; 852 Hz */
8836 /* 1D,1B,5C,CC ; 941 Hz */
8838 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8839 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8840 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8841 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8842 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8843 /* EC,1D,52,22 ; 1336 Hz */
8844 /* AA,AC,51,D2 ; 1477 Hz */
8845 /* 9B,3B,51,25 ; 1633 Hz */
8846 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8847 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8848 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8849 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8852 static s16 tone_table[][19] =
8854 { /* f20_50[] 11 */
8855 32538, /* A1 = 1.985962 */
8856 -32325, /* A2 = -0.986511 */
8857 -343, /* B2 = -0.010493 */
8858 0, /* B1 = 0 */
8859 343, /* B0 = 0.010493 */
8860 32619, /* A1 = 1.990906 */
8861 -32520, /* A2 = -0.992462 */
8862 19179, /* B2 = 0.585327 */
8863 -19178, /* B1 = -1.170593 */
8864 19179, /* B0 = 0.585327 */
8865 32723, /* A1 = 1.997314 */
8866 -32686, /* A2 = -0.997528 */
8867 9973, /* B2 = 0.304352 */
8868 -9955, /* B1 = -0.607605 */
8869 9973, /* B0 = 0.304352 */
8870 7, /* Internal filter scaling */
8871 159, /* Minimum in-band energy threshold */
8872 21, /* 21/32 in-band to broad-band ratio */
8873 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8875 { /* f133_200[] 12 */
8876 32072, /* A1 = 1.95752 */
8877 -31896, /* A2 = -0.973419 */
8878 -435, /* B2 = -0.013294 */
8879 0, /* B1 = 0 */
8880 435, /* B0 = 0.013294 */
8881 32188, /* A1 = 1.9646 */
8882 -32400, /* A2 = -0.98877 */
8883 15139, /* B2 = 0.462036 */
8884 -14882, /* B1 = -0.908356 */
8885 15139, /* B0 = 0.462036 */
8886 32473, /* A1 = 1.981995 */
8887 -32524, /* A2 = -0.992584 */
8888 23200, /* B2 = 0.708008 */
8889 -23113, /* B1 = -1.410706 */
8890 23200, /* B0 = 0.708008 */
8891 7, /* Internal filter scaling */
8892 159, /* Minimum in-band energy threshold */
8893 21, /* 21/32 in-band to broad-band ratio */
8894 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8896 { /* f300 13 */
8897 31769, /* A1 = -1.939026 */
8898 -32584, /* A2 = 0.994385 */
8899 -475, /* B2 = -0.014522 */
8900 0, /* B1 = 0.000000 */
8901 475, /* B0 = 0.014522 */
8902 31789, /* A1 = -1.940247 */
8903 -32679, /* A2 = 0.997284 */
8904 17280, /* B2 = 0.527344 */
8905 -16865, /* B1 = -1.029358 */
8906 17280, /* B0 = 0.527344 */
8907 31841, /* A1 = -1.943481 */
8908 -32681, /* A2 = 0.997345 */
8909 543, /* B2 = 0.016579 */
8910 -525, /* B1 = -0.032097 */
8911 543, /* B0 = 0.016579 */
8912 5, /* Internal filter scaling */
8913 159, /* Minimum in-band energy threshold */
8914 21, /* 21/32 in-band to broad-band ratio */
8915 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8917 { /* f300_420[] 14 */
8918 30750, /* A1 = 1.876892 */
8919 -31212, /* A2 = -0.952515 */
8920 -804, /* B2 = -0.024541 */
8921 0, /* B1 = 0 */
8922 804, /* B0 = 0.024541 */
8923 30686, /* A1 = 1.872925 */
8924 -32145, /* A2 = -0.980988 */
8925 14747, /* B2 = 0.450043 */
8926 -13703, /* B1 = -0.836395 */
8927 14747, /* B0 = 0.450043 */
8928 31651, /* A1 = 1.931824 */
8929 -32321, /* A2 = -0.986389 */
8930 24425, /* B2 = 0.745422 */
8931 -23914, /* B1 = -1.459595 */
8932 24427, /* B0 = 0.745483 */
8933 7, /* Internal filter scaling */
8934 159, /* Minimum in-band energy threshold */
8935 21, /* 21/32 in-band to broad-band ratio */
8936 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8938 { /* f330 15 */
8939 31613, /* A1 = -1.929565 */
8940 -32646, /* A2 = 0.996277 */
8941 -185, /* B2 = -0.005657 */
8942 0, /* B1 = 0.000000 */
8943 185, /* B0 = 0.005657 */
8944 31620, /* A1 = -1.929932 */
8945 -32713, /* A2 = 0.998352 */
8946 19253, /* B2 = 0.587585 */
8947 -18566, /* B1 = -1.133179 */
8948 19253, /* B0 = 0.587585 */
8949 31674, /* A1 = -1.933228 */
8950 -32715, /* A2 = 0.998413 */
8951 2575, /* B2 = 0.078590 */
8952 -2495, /* B1 = -0.152283 */
8953 2575, /* B0 = 0.078590 */
8954 5, /* Internal filter scaling */
8955 159, /* Minimum in-band energy threshold */
8956 21, /* 21/32 in-band to broad-band ratio */
8957 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8959 { /* f300_425[] 16 */
8960 30741, /* A1 = 1.876282 */
8961 -31475, /* A2 = -0.960541 */
8962 -703, /* B2 = -0.021484 */
8963 0, /* B1 = 0 */
8964 703, /* B0 = 0.021484 */
8965 30688, /* A1 = 1.873047 */
8966 -32248, /* A2 = -0.984161 */
8967 14542, /* B2 = 0.443787 */
8968 -13523, /* B1 = -0.825439 */
8969 14542, /* B0 = 0.443817 */
8970 31494, /* A1 = 1.922302 */
8971 -32366, /* A2 = -0.987762 */
8972 21577, /* B2 = 0.658508 */
8973 -21013, /* B1 = -1.282532 */
8974 21577, /* B0 = 0.658508 */
8975 7, /* Internal filter scaling */
8976 159, /* Minimum in-band energy threshold */
8977 21, /* 21/32 in-band to broad-band ratio */
8978 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8980 { /* f330_440[] 17 */
8981 30627, /* A1 = 1.869324 */
8982 -31338, /* A2 = -0.95636 */
8983 -843, /* B2 = -0.025749 */
8984 0, /* B1 = 0 */
8985 843, /* B0 = 0.025749 */
8986 30550, /* A1 = 1.864685 */
8987 -32221, /* A2 = -0.983337 */
8988 13594, /* B2 = 0.414886 */
8989 -12589, /* B1 = -0.768402 */
8990 13594, /* B0 = 0.414886 */
8991 31488, /* A1 = 1.921936 */
8992 -32358, /* A2 = -0.987518 */
8993 24684, /* B2 = 0.753296 */
8994 -24029, /* B1 = -1.466614 */
8995 24684, /* B0 = 0.753296 */
8996 7, /* Internal filter scaling */
8997 159, /* Minimum in-band energy threshold */
8998 21, /* 21/32 in-band to broad-band ratio */
8999 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9001 { /* f340 18 */
9002 31546, /* A1 = -1.925476 */
9003 -32646, /* A2 = 0.996277 */
9004 -445, /* B2 = -0.013588 */
9005 0, /* B1 = 0.000000 */
9006 445, /* B0 = 0.013588 */
9007 31551, /* A1 = -1.925781 */
9008 -32713, /* A2 = 0.998352 */
9009 23884, /* B2 = 0.728882 */
9010 -22979, /* B1 = -1.402527 */
9011 23884, /* B0 = 0.728882 */
9012 31606, /* A1 = -1.929138 */
9013 -32715, /* A2 = 0.998413 */
9014 863, /* B2 = 0.026367 */
9015 -835, /* B1 = -0.050985 */
9016 863, /* B0 = 0.026367 */
9017 5, /* Internal filter scaling */
9018 159, /* Minimum in-band energy threshold */
9019 21, /* 21/32 in-band to broad-band ratio */
9020 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9022 { /* f350_400[] 19 */
9023 31006, /* A1 = 1.892517 */
9024 -32029, /* A2 = -0.977448 */
9025 -461, /* B2 = -0.014096 */
9026 0, /* B1 = 0 */
9027 461, /* B0 = 0.014096 */
9028 30999, /* A1 = 1.892029 */
9029 -32487, /* A2 = -0.991455 */
9030 11325, /* B2 = 0.345612 */
9031 -10682, /* B1 = -0.651978 */
9032 11325, /* B0 = 0.345612 */
9033 31441, /* A1 = 1.919067 */
9034 -32526, /* A2 = -0.992615 */
9035 24324, /* B2 = 0.74231 */
9036 -23535, /* B1 = -1.436523 */
9037 24324, /* B0 = 0.74231 */
9038 7, /* Internal filter scaling */
9039 159, /* Minimum in-band energy threshold */
9040 21, /* 21/32 in-band to broad-band ratio */
9041 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9043 { /* f350_440[] */
9044 30634, /* A1 = 1.869751 */
9045 -31533, /* A2 = -0.962341 */
9046 -680, /* B2 = -0.020782 */
9047 0, /* B1 = 0 */
9048 680, /* B0 = 0.020782 */
9049 30571, /* A1 = 1.865906 */
9050 -32277, /* A2 = -0.985016 */
9051 12894, /* B2 = 0.393524 */
9052 -11945, /* B1 = -0.729065 */
9053 12894, /* B0 = 0.393524 */
9054 31367, /* A1 = 1.91449 */
9055 -32379, /* A2 = -0.988129 */
9056 23820, /* B2 = 0.726929 */
9057 -23104, /* B1 = -1.410217 */
9058 23820, /* B0 = 0.726929 */
9059 7, /* Internal filter scaling */
9060 159, /* Minimum in-band energy threshold */
9061 21, /* 21/32 in-band to broad-band ratio */
9062 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9064 { /* f350_450[] */
9065 30552, /* A1 = 1.864807 */
9066 -31434, /* A2 = -0.95929 */
9067 -690, /* B2 = -0.021066 */
9068 0, /* B1 = 0 */
9069 690, /* B0 = 0.021066 */
9070 30472, /* A1 = 1.859924 */
9071 -32248, /* A2 = -0.984161 */
9072 13385, /* B2 = 0.408478 */
9073 -12357, /* B1 = -0.754242 */
9074 13385, /* B0 = 0.408478 */
9075 31358, /* A1 = 1.914001 */
9076 -32366, /* A2 = -0.987732 */
9077 26488, /* B2 = 0.80835 */
9078 -25692, /* B1 = -1.568176 */
9079 26490, /* B0 = 0.808411 */
9080 7, /* Internal filter scaling */
9081 159, /* Minimum in-band energy threshold */
9082 21, /* 21/32 in-band to broad-band ratio */
9083 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9085 { /* f360 */
9086 31397, /* A1 = -1.916321 */
9087 -32623, /* A2 = 0.995605 */
9088 -117, /* B2 = -0.003598 */
9089 0, /* B1 = 0.000000 */
9090 117, /* B0 = 0.003598 */
9091 31403, /* A1 = -1.916687 */
9092 -32700, /* A2 = 0.997925 */
9093 3388, /* B2 = 0.103401 */
9094 -3240, /* B1 = -0.197784 */
9095 3388, /* B0 = 0.103401 */
9096 31463, /* A1 = -1.920410 */
9097 -32702, /* A2 = 0.997986 */
9098 13346, /* B2 = 0.407288 */
9099 -12863, /* B1 = -0.785126 */
9100 13346, /* B0 = 0.407288 */
9101 5, /* Internal filter scaling */
9102 159, /* Minimum in-band energy threshold */
9103 21, /* 21/32 in-band to broad-band ratio */
9104 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9106 { /* f380_420[] */
9107 30831, /* A1 = 1.881775 */
9108 -32064, /* A2 = -0.978546 */
9109 -367, /* B2 = -0.01122 */
9110 0, /* B1 = 0 */
9111 367, /* B0 = 0.01122 */
9112 30813, /* A1 = 1.880737 */
9113 -32456, /* A2 = -0.990509 */
9114 11068, /* B2 = 0.337769 */
9115 -10338, /* B1 = -0.631042 */
9116 11068, /* B0 = 0.337769 */
9117 31214, /* A1 = 1.905212 */
9118 -32491, /* A2 = -0.991577 */
9119 16374, /* B2 = 0.499695 */
9120 -15781, /* B1 = -0.963196 */
9121 16374, /* B0 = 0.499695 */
9122 7, /* Internal filter scaling */
9123 159, /* Minimum in-band energy threshold */
9124 21, /* 21/32 in-band to broad-band ratio */
9125 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9127 { /* f392 */
9128 31152, /* A1 = -1.901428 */
9129 -32613, /* A2 = 0.995300 */
9130 -314, /* B2 = -0.009605 */
9131 0, /* B1 = 0.000000 */
9132 314, /* B0 = 0.009605 */
9133 31156, /* A1 = -1.901672 */
9134 -32694, /* A2 = 0.997742 */
9135 28847, /* B2 = 0.880371 */
9136 -2734, /* B1 = -0.166901 */
9137 28847, /* B0 = 0.880371 */
9138 31225, /* A1 = -1.905823 */
9139 -32696, /* A2 = 0.997803 */
9140 462, /* B2 = 0.014108 */
9141 -442, /* B1 = -0.027019 */
9142 462, /* B0 = 0.014108 */
9143 5, /* Internal filter scaling */
9144 159, /* Minimum in-band energy threshold */
9145 21, /* 21/32 in-band to broad-band ratio */
9146 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9148 { /* f400_425[] */
9149 30836, /* A1 = 1.882141 */
9150 -32296, /* A2 = -0.985596 */
9151 -324, /* B2 = -0.009903 */
9152 0, /* B1 = 0 */
9153 324, /* B0 = 0.009903 */
9154 30825, /* A1 = 1.881409 */
9155 -32570, /* A2 = -0.993958 */
9156 16847, /* B2 = 0.51416 */
9157 -15792, /* B1 = -0.963898 */
9158 16847, /* B0 = 0.51416 */
9159 31106, /* A1 = 1.89856 */
9160 -32584, /* A2 = -0.994415 */
9161 9579, /* B2 = 0.292328 */
9162 -9164, /* B1 = -0.559357 */
9163 9579, /* B0 = 0.292328 */
9164 7, /* Internal filter scaling */
9165 159, /* Minimum in-band energy threshold */
9166 21, /* 21/32 in-band to broad-band ratio */
9167 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9169 { /* f400_440[] */
9170 30702, /* A1 = 1.873962 */
9171 -32134, /* A2 = -0.980682 */
9172 -517, /* B2 = -0.015793 */
9173 0, /* B1 = 0 */
9174 517, /* B0 = 0.015793 */
9175 30676, /* A1 = 1.872375 */
9176 -32520, /* A2 = -0.992462 */
9177 8144, /* B2 = 0.24855 */
9178 -7596, /* B1 = -0.463684 */
9179 8144, /* B0 = 0.24855 */
9180 31084, /* A1 = 1.897217 */
9181 -32547, /* A2 = -0.993256 */
9182 22713, /* B2 = 0.693176 */
9183 -21734, /* B1 = -1.326599 */
9184 22713, /* B0 = 0.693176 */
9185 7, /* Internal filter scaling */
9186 159, /* Minimum in-band energy threshold */
9187 21, /* 21/32 in-band to broad-band ratio */
9188 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9190 { /* f400_450[] */
9191 30613, /* A1 = 1.86853 */
9192 -32031, /* A2 = -0.977509 */
9193 -618, /* B2 = -0.018866 */
9194 0, /* B1 = 0 */
9195 618, /* B0 = 0.018866 */
9196 30577, /* A1 = 1.866272 */
9197 -32491, /* A2 = -0.991577 */
9198 9612, /* B2 = 0.293335 */
9199 -8935, /* B1 = -0.54541 */
9200 9612, /* B0 = 0.293335 */
9201 31071, /* A1 = 1.896484 */
9202 -32524, /* A2 = -0.992584 */
9203 21596, /* B2 = 0.659058 */
9204 -20667, /* B1 = -1.261414 */
9205 21596, /* B0 = 0.659058 */
9206 7, /* Internal filter scaling */
9207 159, /* Minimum in-band energy threshold */
9208 21, /* 21/32 in-band to broad-band ratio */
9209 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9211 { /* f420 */
9212 30914, /* A1 = -1.886841 */
9213 -32584, /* A2 = 0.994385 */
9214 -426, /* B2 = -0.013020 */
9215 0, /* B1 = 0.000000 */
9216 426, /* B0 = 0.013020 */
9217 30914, /* A1 = -1.886841 */
9218 -32679, /* A2 = 0.997314 */
9219 17520, /* B2 = 0.534668 */
9220 -16471, /* B1 = -1.005310 */
9221 17520, /* B0 = 0.534668 */
9222 31004, /* A1 = -1.892334 */
9223 -32683, /* A2 = 0.997406 */
9224 819, /* B2 = 0.025023 */
9225 -780, /* B1 = -0.047619 */
9226 819, /* B0 = 0.025023 */
9227 5, /* Internal filter scaling */
9228 159, /* Minimum in-band energy threshold */
9229 21, /* 21/32 in-band to broad-band ratio */
9230 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9232 #if 0
9233 { /* f425 */
9234 30881, /* A1 = -1.884827 */
9235 -32603, /* A2 = 0.994965 */
9236 -496, /* B2 = -0.015144 */
9237 0, /* B1 = 0.000000 */
9238 496, /* B0 = 0.015144 */
9239 30880, /* A1 = -1.884766 */
9240 -32692, /* A2 = 0.997711 */
9241 24767, /* B2 = 0.755859 */
9242 -23290, /* B1 = -1.421509 */
9243 24767, /* B0 = 0.755859 */
9244 30967, /* A1 = -1.890076 */
9245 -32694, /* A2 = 0.997772 */
9246 728, /* B2 = 0.022232 */
9247 -691, /* B1 = -0.042194 */
9248 728, /* B0 = 0.022232 */
9249 5, /* Internal filter scaling */
9250 159, /* Minimum in-band energy threshold */
9251 21, /* 21/32 in-band to broad-band ratio */
9252 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9254 #else
9256 30850,
9257 -32534,
9258 -504,
9260 504,
9261 30831,
9262 -32669,
9263 24303,
9264 -22080,
9265 24303,
9266 30994,
9267 -32673,
9268 1905,
9269 -1811,
9270 1905,
9272 129,
9274 0xff5
9276 #endif
9277 { /* f425_450[] */
9278 30646, /* A1 = 1.870544 */
9279 -32327, /* A2 = -0.986572 */
9280 -287, /* B2 = -0.008769 */
9281 0, /* B1 = 0 */
9282 287, /* B0 = 0.008769 */
9283 30627, /* A1 = 1.869324 */
9284 -32607, /* A2 = -0.995087 */
9285 13269, /* B2 = 0.404968 */
9286 -12376, /* B1 = -0.755432 */
9287 13269, /* B0 = 0.404968 */
9288 30924, /* A1 = 1.887512 */
9289 -32619, /* A2 = -0.995453 */
9290 19950, /* B2 = 0.608826 */
9291 -18940, /* B1 = -1.156006 */
9292 19950, /* B0 = 0.608826 */
9293 7, /* Internal filter scaling */
9294 159, /* Minimum in-band energy threshold */
9295 21, /* 21/32 in-band to broad-band ratio */
9296 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9298 { /* f425_475[] */
9299 30396, /* A1 = 1.855225 */
9300 -32014, /* A2 = -0.97699 */
9301 -395, /* B2 = -0.012055 */
9302 0, /* B1 = 0 */
9303 395, /* B0 = 0.012055 */
9304 30343, /* A1 = 1.85199 */
9305 -32482, /* A2 = -0.991302 */
9306 17823, /* B2 = 0.543945 */
9307 -16431, /* B1 = -1.002869 */
9308 17823, /* B0 = 0.543945 */
9309 30872, /* A1 = 1.884338 */
9310 -32516, /* A2 = -0.99231 */
9311 18124, /* B2 = 0.553101 */
9312 -17246, /* B1 = -1.052673 */
9313 18124, /* B0 = 0.553101 */
9314 7, /* Internal filter scaling */
9315 159, /* Minimum in-band energy threshold */
9316 21, /* 21/32 in-band to broad-band ratio */
9317 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9319 { /* f435 */
9320 30796, /* A1 = -1.879639 */
9321 -32603, /* A2 = 0.994965 */
9322 -254, /* B2 = -0.007762 */
9323 0, /* B1 = 0.000000 */
9324 254, /* B0 = 0.007762 */
9325 30793, /* A1 = -1.879456 */
9326 -32692, /* A2 = 0.997711 */
9327 18934, /* B2 = 0.577820 */
9328 -17751, /* B1 = -1.083496 */
9329 18934, /* B0 = 0.577820 */
9330 30882, /* A1 = -1.884888 */
9331 -32694, /* A2 = 0.997772 */
9332 1858, /* B2 = 0.056713 */
9333 -1758, /* B1 = -0.107357 */
9334 1858, /* B0 = 0.056713 */
9335 5, /* Internal filter scaling */
9336 159, /* Minimum in-band energy threshold */
9337 21, /* 21/32 in-band to broad-band ratio */
9338 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9340 { /* f440_450[] */
9341 30641, /* A1 = 1.870239 */
9342 -32458, /* A2 = -0.99057 */
9343 -155, /* B2 = -0.004735 */
9344 0, /* B1 = 0 */
9345 155, /* B0 = 0.004735 */
9346 30631, /* A1 = 1.869568 */
9347 -32630, /* A2 = -0.995789 */
9348 11453, /* B2 = 0.349548 */
9349 -10666, /* B1 = -0.651001 */
9350 11453, /* B0 = 0.349548 */
9351 30810, /* A1 = 1.880554 */
9352 -32634, /* A2 = -0.995941 */
9353 12237, /* B2 = 0.373474 */
9354 -11588, /* B1 = -0.707336 */
9355 12237, /* B0 = 0.373474 */
9356 7, /* Internal filter scaling */
9357 159, /* Minimum in-band energy threshold */
9358 21, /* 21/32 in-band to broad-band ratio */
9359 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9361 { /* f440_480[] */
9362 30367, /* A1 = 1.853455 */
9363 -32147, /* A2 = -0.981079 */
9364 -495, /* B2 = -0.015113 */
9365 0, /* B1 = 0 */
9366 495, /* B0 = 0.015113 */
9367 30322, /* A1 = 1.850769 */
9368 -32543, /* A2 = -0.993134 */
9369 10031, /* B2 = 0.306152 */
9370 -9252, /* B1 = -0.564728 */
9371 10031, /* B0 = 0.306152 */
9372 30770, /* A1 = 1.878052 */
9373 -32563, /* A2 = -0.993774 */
9374 22674, /* B2 = 0.691956 */
9375 -21465, /* B1 = -1.31012 */
9376 22674, /* B0 = 0.691956 */
9377 7, /* Internal filter scaling */
9378 159, /* Minimum in-band energy threshold */
9379 21, /* 21/32 in-band to broad-band ratio */
9380 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9382 { /* f445 */
9383 30709, /* A1 = -1.874329 */
9384 -32603, /* A2 = 0.994965 */
9385 -83, /* B2 = -0.002545 */
9386 0, /* B1 = 0.000000 */
9387 83, /* B0 = 0.002545 */
9388 30704, /* A1 = -1.874084 */
9389 -32692, /* A2 = 0.997711 */
9390 10641, /* B2 = 0.324738 */
9391 -9947, /* B1 = -0.607147 */
9392 10641, /* B0 = 0.324738 */
9393 30796, /* A1 = -1.879639 */
9394 -32694, /* A2 = 0.997772 */
9395 10079, /* B2 = 0.307587 */
9396 9513, /* B1 = 0.580688 */
9397 10079, /* B0 = 0.307587 */
9398 5, /* Internal filter scaling */
9399 159, /* Minimum in-band energy threshold */
9400 21, /* 21/32 in-band to broad-band ratio */
9401 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9403 { /* f450 */
9404 30664, /* A1 = -1.871643 */
9405 -32603, /* A2 = 0.994965 */
9406 -164, /* B2 = -0.005029 */
9407 0, /* B1 = 0.000000 */
9408 164, /* B0 = 0.005029 */
9409 30661, /* A1 = -1.871399 */
9410 -32692, /* A2 = 0.997711 */
9411 15294, /* B2 = 0.466736 */
9412 -14275, /* B1 = -0.871307 */
9413 15294, /* B0 = 0.466736 */
9414 30751, /* A1 = -1.876953 */
9415 -32694, /* A2 = 0.997772 */
9416 3548, /* B2 = 0.108284 */
9417 -3344, /* B1 = -0.204155 */
9418 3548, /* B0 = 0.108284 */
9419 5, /* Internal filter scaling */
9420 159, /* Minimum in-band energy threshold */
9421 21, /* 21/32 in-band to broad-band ratio */
9422 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9424 { /* f452 */
9425 30653, /* A1 = -1.870911 */
9426 -32615, /* A2 = 0.995361 */
9427 -209, /* B2 = -0.006382 */
9428 0, /* B1 = 0.000000 */
9429 209, /* B0 = 0.006382 */
9430 30647, /* A1 = -1.870605 */
9431 -32702, /* A2 = 0.997986 */
9432 18971, /* B2 = 0.578979 */
9433 -17716, /* B1 = -1.081299 */
9434 18971, /* B0 = 0.578979 */
9435 30738, /* A1 = -1.876099 */
9436 -32702, /* A2 = 0.998016 */
9437 2967, /* B2 = 0.090561 */
9438 -2793, /* B1 = -0.170502 */
9439 2967, /* B0 = 0.090561 */
9440 5, /* Internal filter scaling */
9441 159, /* Minimum in-band energy threshold */
9442 21, /* 21/32 in-band to broad-band ratio */
9443 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9445 { /* f475 */
9446 30437, /* A1 = -1.857727 */
9447 -32603, /* A2 = 0.994965 */
9448 -264, /* B2 = -0.008062 */
9449 0, /* B1 = 0.000000 */
9450 264, /* B0 = 0.008062 */
9451 30430, /* A1 = -1.857300 */
9452 -32692, /* A2 = 0.997711 */
9453 21681, /* B2 = 0.661682 */
9454 -20082, /* B1 = -1.225708 */
9455 21681, /* B0 = 0.661682 */
9456 30526, /* A1 = -1.863220 */
9457 -32694, /* A2 = 0.997742 */
9458 1559, /* B2 = 0.047600 */
9459 -1459, /* B1 = -0.089096 */
9460 1559, /* B0 = 0.047600 */
9461 5, /* Internal filter scaling */
9462 159, /* Minimum in-band energy threshold */
9463 21, /* 21/32 in-band to broad-band ratio */
9464 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9466 { /* f480_620[] */
9467 28975, /* A1 = 1.768494 */
9468 -30955, /* A2 = -0.944672 */
9469 -1026, /* B2 = -0.03133 */
9470 0, /* B1 = 0 */
9471 1026, /* B0 = 0.03133 */
9472 28613, /* A1 = 1.746399 */
9473 -32089, /* A2 = -0.979309 */
9474 14214, /* B2 = 0.433807 */
9475 -12202, /* B1 = -0.744812 */
9476 14214, /* B0 = 0.433807 */
9477 30243, /* A1 = 1.845947 */
9478 -32238, /* A2 = -0.983856 */
9479 24825, /* B2 = 0.757629 */
9480 -23402, /* B1 = -1.428345 */
9481 24825, /* B0 = 0.757629 */
9482 7, /* Internal filter scaling */
9483 159, /* Minimum in-band energy threshold */
9484 21, /* 21/32 in-band to broad-band ratio */
9485 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9487 { /* f494 */
9488 30257, /* A1 = -1.846741 */
9489 -32605, /* A2 = 0.995056 */
9490 -249, /* B2 = -0.007625 */
9491 0, /* B1 = 0.000000 */
9492 249, /* B0 = 0.007625 */
9493 30247, /* A1 = -1.846191 */
9494 -32694, /* A2 = 0.997772 */
9495 18088, /* B2 = 0.552002 */
9496 -16652, /* B1 = -1.016418 */
9497 18088, /* B0 = 0.552002 */
9498 30348, /* A1 = -1.852295 */
9499 -32696, /* A2 = 0.997803 */
9500 2099, /* B2 = 0.064064 */
9501 -1953, /* B1 = -0.119202 */
9502 2099, /* B0 = 0.064064 */
9503 5, /* Internal filter scaling */
9504 159, /* Minimum in-band energy threshold */
9505 21, /* 21/32 in-band to broad-band ratio */
9506 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9508 { /* f500 */
9509 30202, /* A1 = -1.843431 */
9510 -32624, /* A2 = 0.995622 */
9511 -413, /* B2 = -0.012622 */
9512 0, /* B1 = 0.000000 */
9513 413, /* B0 = 0.012622 */
9514 30191, /* A1 = -1.842721 */
9515 -32714, /* A2 = 0.998364 */
9516 25954, /* B2 = 0.792057 */
9517 -23890, /* B1 = -1.458131 */
9518 25954, /* B0 = 0.792057 */
9519 30296, /* A1 = -1.849172 */
9520 -32715, /* A2 = 0.998397 */
9521 2007, /* B2 = 0.061264 */
9522 -1860, /* B1 = -0.113568 */
9523 2007, /* B0 = 0.061264 */
9524 5, /* Internal filter scaling */
9525 159, /* Minimum in-band energy threshold */
9526 21, /* 21/32 in-band to broad-band ratio */
9527 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9529 { /* f520 */
9530 30001, /* A1 = -1.831116 */
9531 -32613, /* A2 = 0.995270 */
9532 -155, /* B2 = -0.004750 */
9533 0, /* B1 = 0.000000 */
9534 155, /* B0 = 0.004750 */
9535 29985, /* A1 = -1.830200 */
9536 -32710, /* A2 = 0.998260 */
9537 6584, /* B2 = 0.200928 */
9538 -6018, /* B1 = -0.367355 */
9539 6584, /* B0 = 0.200928 */
9540 30105, /* A1 = -1.837524 */
9541 -32712, /* A2 = 0.998291 */
9542 23812, /* B2 = 0.726685 */
9543 -21936, /* B1 = -1.338928 */
9544 23812, /* B0 = 0.726685 */
9545 5, /* Internal filter scaling */
9546 159, /* Minimum in-band energy threshold */
9547 21, /* 21/32 in-band to broad-band ratio */
9548 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9550 { /* f523 */
9551 29964, /* A1 = -1.828918 */
9552 -32601, /* A2 = 0.994904 */
9553 -101, /* B2 = -0.003110 */
9554 0, /* B1 = 0.000000 */
9555 101, /* B0 = 0.003110 */
9556 29949, /* A1 = -1.827942 */
9557 -32700, /* A2 = 0.997925 */
9558 11041, /* B2 = 0.336975 */
9559 -10075, /* B1 = -0.614960 */
9560 11041, /* B0 = 0.336975 */
9561 30070, /* A1 = -1.835388 */
9562 -32702, /* A2 = 0.997986 */
9563 16762, /* B2 = 0.511536 */
9564 -15437, /* B1 = -0.942230 */
9565 16762, /* B0 = 0.511536 */
9566 5, /* Internal filter scaling */
9567 159, /* Minimum in-band energy threshold */
9568 21, /* 21/32 in-band to broad-band ratio */
9569 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9571 { /* f525 */
9572 29936, /* A1 = -1.827209 */
9573 -32584, /* A2 = 0.994415 */
9574 -91, /* B2 = -0.002806 */
9575 0, /* B1 = 0.000000 */
9576 91, /* B0 = 0.002806 */
9577 29921, /* A1 = -1.826233 */
9578 -32688, /* A2 = 0.997559 */
9579 11449, /* B2 = 0.349396 */
9580 -10426, /* B1 = -0.636383 */
9581 11449, /* B0 = 0.349396 */
9582 30045, /* A1 = -1.833862 */
9583 -32688, /* A2 = 0.997589 */
9584 13055, /* B2 = 0.398407 */
9585 -12028, /* B1 = -0.734161 */
9586 13055, /* B0 = 0.398407 */
9587 5, /* Internal filter scaling */
9588 159, /* Minimum in-band energy threshold */
9589 21, /* 21/32 in-band to broad-band ratio */
9590 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9592 { /* f540_660[] */
9593 28499, /* A1 = 1.739441 */
9594 -31129, /* A2 = -0.949982 */
9595 -849, /* B2 = -0.025922 */
9596 0, /* B1 = 0 */
9597 849, /* B0 = 0.025922 */
9598 28128, /* A1 = 1.716797 */
9599 -32130, /* A2 = -0.98056 */
9600 14556, /* B2 = 0.444214 */
9601 -12251, /* B1 = -0.747772 */
9602 14556, /* B0 = 0.444244 */
9603 29667, /* A1 = 1.81073 */
9604 -32244, /* A2 = -0.984039 */
9605 23038, /* B2 = 0.703064 */
9606 -21358, /* B1 = -1.303589 */
9607 23040, /* B0 = 0.703125 */
9608 7, /* Internal filter scaling */
9609 159, /* Minimum in-band energy threshold */
9610 21, /* 21/32 in-band to broad-band ratio */
9611 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9613 { /* f587 */
9614 29271, /* A1 = -1.786560 */
9615 -32599, /* A2 = 0.994873 */
9616 -490, /* B2 = -0.014957 */
9617 0, /* B1 = 0.000000 */
9618 490, /* B0 = 0.014957 */
9619 29246, /* A1 = -1.785095 */
9620 -32700, /* A2 = 0.997925 */
9621 28961, /* B2 = 0.883850 */
9622 -25796, /* B1 = -1.574463 */
9623 28961, /* B0 = 0.883850 */
9624 29383, /* A1 = -1.793396 */
9625 -32700, /* A2 = 0.997955 */
9626 1299, /* B2 = 0.039650 */
9627 -1169, /* B1 = -0.071396 */
9628 1299, /* B0 = 0.039650 */
9629 5, /* Internal filter scaling */
9630 159, /* Minimum in-band energy threshold */
9631 21, /* 21/32 in-band to broad-band ratio */
9632 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9634 { /* f590 */
9635 29230, /* A1 = -1.784058 */
9636 -32584, /* A2 = 0.994415 */
9637 -418, /* B2 = -0.012757 */
9638 0, /* B1 = 0.000000 */
9639 418, /* B0 = 0.012757 */
9640 29206, /* A1 = -1.782593 */
9641 -32688, /* A2 = 0.997559 */
9642 36556, /* B2 = 1.115601 */
9643 -32478, /* B1 = -1.982300 */
9644 36556, /* B0 = 1.115601 */
9645 29345, /* A1 = -1.791077 */
9646 -32688, /* A2 = 0.997589 */
9647 897, /* B2 = 0.027397 */
9648 -808, /* B1 = -0.049334 */
9649 897, /* B0 = 0.027397 */
9650 5, /* Internal filter scaling */
9651 159, /* Minimum in-band energy threshold */
9652 21, /* 21/32 in-band to broad-band ratio */
9653 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9655 { /* f600 */
9656 29116, /* A1 = -1.777100 */
9657 -32603, /* A2 = 0.994965 */
9658 -165, /* B2 = -0.005039 */
9659 0, /* B1 = 0.000000 */
9660 165, /* B0 = 0.005039 */
9661 29089, /* A1 = -1.775452 */
9662 -32708, /* A2 = 0.998199 */
9663 6963, /* B2 = 0.212494 */
9664 -6172, /* B1 = -0.376770 */
9665 6963, /* B0 = 0.212494 */
9666 29237, /* A1 = -1.784485 */
9667 -32710, /* A2 = 0.998230 */
9668 24197, /* B2 = 0.738464 */
9669 -21657, /* B1 = -1.321899 */
9670 24197, /* B0 = 0.738464 */
9671 5, /* Internal filter scaling */
9672 159, /* Minimum in-band energy threshold */
9673 21, /* 21/32 in-band to broad-band ratio */
9674 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9676 { /* f660 */
9677 28376, /* A1 = -1.731934 */
9678 -32567, /* A2 = 0.993896 */
9679 -363, /* B2 = -0.011102 */
9680 0, /* B1 = 0.000000 */
9681 363, /* B0 = 0.011102 */
9682 28337, /* A1 = -1.729614 */
9683 -32683, /* A2 = 0.997434 */
9684 21766, /* B2 = 0.664246 */
9685 -18761, /* B1 = -1.145081 */
9686 21766, /* B0 = 0.664246 */
9687 28513, /* A1 = -1.740356 */
9688 -32686, /* A2 = 0.997498 */
9689 2509, /* B2 = 0.076584 */
9690 -2196, /* B1 = -0.134041 */
9691 2509, /* B0 = 0.076584 */
9692 5, /* Internal filter scaling */
9693 159, /* Minimum in-band energy threshold */
9694 21, /* 21/32 in-band to broad-band ratio */
9695 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9697 { /* f700 */
9698 27844, /* A1 = -1.699463 */
9699 -32563, /* A2 = 0.993744 */
9700 -366, /* B2 = -0.011187 */
9701 0, /* B1 = 0.000000 */
9702 366, /* B0 = 0.011187 */
9703 27797, /* A1 = -1.696655 */
9704 -32686, /* A2 = 0.997498 */
9705 22748, /* B2 = 0.694214 */
9706 -19235, /* B1 = -1.174072 */
9707 22748, /* B0 = 0.694214 */
9708 27995, /* A1 = -1.708740 */
9709 -32688, /* A2 = 0.997559 */
9710 2964, /* B2 = 0.090477 */
9711 -2546, /* B1 = -0.155449 */
9712 2964, /* B0 = 0.090477 */
9713 5, /* Internal filter scaling */
9714 159, /* Minimum in-band energy threshold */
9715 21, /* 21/32 in-band to broad-band ratio */
9716 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9718 { /* f740 */
9719 27297, /* A1 = -1.666077 */
9720 -32551, /* A2 = 0.993408 */
9721 -345, /* B2 = -0.010540 */
9722 0, /* B1 = 0.000000 */
9723 345, /* B0 = 0.010540 */
9724 27240, /* A1 = -1.662598 */
9725 -32683, /* A2 = 0.997406 */
9726 22560, /* B2 = 0.688477 */
9727 -18688, /* B1 = -1.140625 */
9728 22560, /* B0 = 0.688477 */
9729 27461, /* A1 = -1.676147 */
9730 -32684, /* A2 = 0.997467 */
9731 3541, /* B2 = 0.108086 */
9732 -2985, /* B1 = -0.182220 */
9733 3541, /* B0 = 0.108086 */
9734 5, /* Internal filter scaling */
9735 159, /* Minimum in-band energy threshold */
9736 21, /* 21/32 in-band to broad-band ratio */
9737 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9739 { /* f750 */
9740 27155, /* A1 = -1.657410 */
9741 -32551, /* A2 = 0.993408 */
9742 -462, /* B2 = -0.014117 */
9743 0, /* B1 = 0.000000 */
9744 462, /* B0 = 0.014117 */
9745 27097, /* A1 = -1.653870 */
9746 -32683, /* A2 = 0.997406 */
9747 32495, /* B2 = 0.991699 */
9748 -26776, /* B1 = -1.634338 */
9749 32495, /* B0 = 0.991699 */
9750 27321, /* A1 = -1.667542 */
9751 -32684, /* A2 = 0.997467 */
9752 1835, /* B2 = 0.056007 */
9753 -1539, /* B1 = -0.093948 */
9754 1835, /* B0 = 0.056007 */
9755 5, /* Internal filter scaling */
9756 159, /* Minimum in-band energy threshold */
9757 21, /* 21/32 in-band to broad-band ratio */
9758 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9760 { /* f750_1450[] */
9761 19298, /* A1 = 1.177917 */
9762 -24471, /* A2 = -0.746796 */
9763 -4152, /* B2 = -0.126709 */
9764 0, /* B1 = 0 */
9765 4152, /* B0 = 0.126709 */
9766 12902, /* A1 = 0.787476 */
9767 -29091, /* A2 = -0.887817 */
9768 12491, /* B2 = 0.38121 */
9769 -1794, /* B1 = -0.109528 */
9770 12494, /* B0 = 0.381317 */
9771 26291, /* A1 = 1.604736 */
9772 -30470, /* A2 = -0.929901 */
9773 28859, /* B2 = 0.880737 */
9774 -26084, /* B1 = -1.592102 */
9775 28861, /* B0 = 0.880798 */
9776 7, /* Internal filter scaling */
9777 159, /* Minimum in-band energy threshold */
9778 21, /* 21/32 in-band to broad-band ratio */
9779 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9781 { /* f770 */
9782 26867, /* A1 = -1.639832 */
9783 -32551, /* A2 = 0.993408 */
9784 -123, /* B2 = -0.003755 */
9785 0, /* B1 = 0.000000 */
9786 123, /* B0 = 0.003755 */
9787 26805, /* A1 = -1.636108 */
9788 -32683, /* A2 = 0.997406 */
9789 17297, /* B2 = 0.527863 */
9790 -14096, /* B1 = -0.860382 */
9791 17297, /* B0 = 0.527863 */
9792 27034, /* A1 = -1.650085 */
9793 -32684, /* A2 = 0.997467 */
9794 12958, /* B2 = 0.395477 */
9795 -10756, /* B1 = -0.656525 */
9796 12958, /* B0 = 0.395477 */
9797 5, /* Internal filter scaling */
9798 159, /* Minimum in-band energy threshold */
9799 21, /* 21/32 in-band to broad-band ratio */
9800 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9802 { /* f800 */
9803 26413, /* A1 = -1.612122 */
9804 -32547, /* A2 = 0.993286 */
9805 -223, /* B2 = -0.006825 */
9806 0, /* B1 = 0.000000 */
9807 223, /* B0 = 0.006825 */
9808 26342, /* A1 = -1.607849 */
9809 -32686, /* A2 = 0.997498 */
9810 6391, /* B2 = 0.195053 */
9811 -5120, /* B1 = -0.312531 */
9812 6391, /* B0 = 0.195053 */
9813 26593, /* A1 = -1.623108 */
9814 -32688, /* A2 = 0.997559 */
9815 23681, /* B2 = 0.722717 */
9816 -19328, /* B1 = -1.179688 */
9817 23681, /* B0 = 0.722717 */
9818 5, /* Internal filter scaling */
9819 159, /* Minimum in-band energy threshold */
9820 21, /* 21/32 in-band to broad-band ratio */
9821 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9823 { /* f816 */
9824 26168, /* A1 = -1.597209 */
9825 -32528, /* A2 = 0.992706 */
9826 -235, /* B2 = -0.007182 */
9827 0, /* B1 = 0.000000 */
9828 235, /* B0 = 0.007182 */
9829 26092, /* A1 = -1.592590 */
9830 -32675, /* A2 = 0.997192 */
9831 20823, /* B2 = 0.635498 */
9832 -16510, /* B1 = -1.007751 */
9833 20823, /* B0 = 0.635498 */
9834 26363, /* A1 = -1.609070 */
9835 -32677, /* A2 = 0.997253 */
9836 6739, /* B2 = 0.205688 */
9837 -5459, /* B1 = -0.333206 */
9838 6739, /* B0 = 0.205688 */
9839 5, /* Internal filter scaling */
9840 159, /* Minimum in-band energy threshold */
9841 21, /* 21/32 in-band to broad-band ratio */
9842 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9844 { /* f850 */
9845 25641, /* A1 = -1.565063 */
9846 -32536, /* A2 = 0.992950 */
9847 -121, /* B2 = -0.003707 */
9848 0, /* B1 = 0.000000 */
9849 121, /* B0 = 0.003707 */
9850 25560, /* A1 = -1.560059 */
9851 -32684, /* A2 = 0.997437 */
9852 18341, /* B2 = 0.559753 */
9853 -14252, /* B1 = -0.869904 */
9854 18341, /* B0 = 0.559753 */
9855 25837, /* A1 = -1.577026 */
9856 -32684, /* A2 = 0.997467 */
9857 16679, /* B2 = 0.509003 */
9858 -13232, /* B1 = -0.807648 */
9859 16679, /* B0 = 0.509003 */
9860 5, /* Internal filter scaling */
9861 159, /* Minimum in-band energy threshold */
9862 21, /* 21/32 in-band to broad-band ratio */
9863 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9865 { /* f857_1645[] */
9866 16415, /* A1 = 1.001953 */
9867 -23669, /* A2 = -0.722321 */
9868 -4549, /* B2 = -0.138847 */
9869 0, /* B1 = 0 */
9870 4549, /* B0 = 0.138847 */
9871 8456, /* A1 = 0.516174 */
9872 -28996, /* A2 = -0.884918 */
9873 13753, /* B2 = 0.419724 */
9874 -12, /* B1 = -0.000763 */
9875 13757, /* B0 = 0.419846 */
9876 24632, /* A1 = 1.503418 */
9877 -30271, /* A2 = -0.923828 */
9878 29070, /* B2 = 0.887146 */
9879 -25265, /* B1 = -1.542114 */
9880 29073, /* B0 = 0.887268 */
9881 7, /* Internal filter scaling */
9882 159, /* Minimum in-band energy threshold */
9883 21, /* 21/32 in-band to broad-band ratio */
9884 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9886 { /* f900 */
9887 24806, /* A1 = -1.514099 */
9888 -32501, /* A2 = 0.991852 */
9889 -326, /* B2 = -0.009969 */
9890 0, /* B1 = 0.000000 */
9891 326, /* B0 = 0.009969 */
9892 24709, /* A1 = -1.508118 */
9893 -32659, /* A2 = 0.996674 */
9894 20277, /* B2 = 0.618835 */
9895 -15182, /* B1 = -0.926636 */
9896 20277, /* B0 = 0.618835 */
9897 25022, /* A1 = -1.527222 */
9898 -32661, /* A2 = 0.996735 */
9899 4320, /* B2 = 0.131836 */
9900 -3331, /* B1 = -0.203339 */
9901 4320, /* B0 = 0.131836 */
9902 5, /* Internal filter scaling */
9903 159, /* Minimum in-band energy threshold */
9904 21, /* 21/32 in-band to broad-band ratio */
9905 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9907 { /* f900_1300[] */
9908 19776, /* A1 = 1.207092 */
9909 -27437, /* A2 = -0.837341 */
9910 -2666, /* B2 = -0.081371 */
9911 0, /* B1 = 0 */
9912 2666, /* B0 = 0.081371 */
9913 16302, /* A1 = 0.995026 */
9914 -30354, /* A2 = -0.926361 */
9915 10389, /* B2 = 0.317062 */
9916 -3327, /* B1 = -0.203064 */
9917 10389, /* B0 = 0.317062 */
9918 24299, /* A1 = 1.483154 */
9919 -30930, /* A2 = -0.943909 */
9920 25016, /* B2 = 0.763428 */
9921 -21171, /* B1 = -1.292236 */
9922 25016, /* B0 = 0.763428 */
9923 7, /* Internal filter scaling */
9924 159, /* Minimum in-band energy threshold */
9925 21, /* 21/32 in-band to broad-band ratio */
9926 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9928 { /* f935_1215[] */
9929 20554, /* A1 = 1.254517 */
9930 -28764, /* A2 = -0.877838 */
9931 -2048, /* B2 = -0.062515 */
9932 0, /* B1 = 0 */
9933 2048, /* B0 = 0.062515 */
9934 18209, /* A1 = 1.11145 */
9935 -30951, /* A2 = -0.94458 */
9936 9390, /* B2 = 0.286575 */
9937 -3955, /* B1 = -0.241455 */
9938 9390, /* B0 = 0.286575 */
9939 23902, /* A1 = 1.458923 */
9940 -31286, /* A2 = -0.954803 */
9941 23252, /* B2 = 0.709595 */
9942 -19132, /* B1 = -1.167725 */
9943 23252, /* B0 = 0.709595 */
9944 7, /* Internal filter scaling */
9945 159, /* Minimum in-band energy threshold */
9946 21, /* 21/32 in-band to broad-band ratio */
9947 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9949 { /* f941_1477[] */
9950 17543, /* A1 = 1.07074 */
9951 -26220, /* A2 = -0.800201 */
9952 -3298, /* B2 = -0.100647 */
9953 0, /* B1 = 0 */
9954 3298, /* B0 = 0.100647 */
9955 12423, /* A1 = 0.75827 */
9956 -30036, /* A2 = -0.916626 */
9957 12651, /* B2 = 0.386078 */
9958 -2444, /* B1 = -0.14917 */
9959 12653, /* B0 = 0.386154 */
9960 23518, /* A1 = 1.435425 */
9961 -30745, /* A2 = -0.938293 */
9962 27282, /* B2 = 0.832581 */
9963 -22529, /* B1 = -1.375122 */
9964 27286, /* B0 = 0.832703 */
9965 7, /* Internal filter scaling */
9966 159, /* Minimum in-band energy threshold */
9967 21, /* 21/32 in-band to broad-band ratio */
9968 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9970 { /* f942 */
9971 24104, /* A1 = -1.471252 */
9972 -32507, /* A2 = 0.992065 */
9973 -351, /* B2 = -0.010722 */
9974 0, /* B1 = 0.000000 */
9975 351, /* B0 = 0.010722 */
9976 23996, /* A1 = -1.464600 */
9977 -32671, /* A2 = 0.997040 */
9978 22848, /* B2 = 0.697266 */
9979 -16639, /* B1 = -1.015564 */
9980 22848, /* B0 = 0.697266 */
9981 24332, /* A1 = -1.485168 */
9982 -32673, /* A2 = 0.997101 */
9983 4906, /* B2 = 0.149727 */
9984 -3672, /* B1 = -0.224174 */
9985 4906, /* B0 = 0.149727 */
9986 5, /* Internal filter scaling */
9987 159, /* Minimum in-band energy threshold */
9988 21, /* 21/32 in-band to broad-band ratio */
9989 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9991 { /* f950 */
9992 23967, /* A1 = -1.462830 */
9993 -32507, /* A2 = 0.992065 */
9994 -518, /* B2 = -0.015821 */
9995 0, /* B1 = 0.000000 */
9996 518, /* B0 = 0.015821 */
9997 23856, /* A1 = -1.456055 */
9998 -32671, /* A2 = 0.997040 */
9999 26287, /* B2 = 0.802246 */
10000 -19031, /* B1 = -1.161560 */
10001 26287, /* B0 = 0.802246 */
10002 24195, /* A1 = -1.476746 */
10003 -32673, /* A2 = 0.997101 */
10004 2890, /* B2 = 0.088196 */
10005 -2151, /* B1 = -0.131317 */
10006 2890, /* B0 = 0.088196 */
10007 5, /* Internal filter scaling */
10008 159, /* Minimum in-band energy threshold */
10009 21, /* 21/32 in-band to broad-band ratio */
10010 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10012 { /* f950_1400[] */
10013 18294, /* A1 = 1.116638 */
10014 -26962, /* A2 = -0.822845 */
10015 -2914, /* B2 = -0.088936 */
10016 0, /* B1 = 0 */
10017 2914, /* B0 = 0.088936 */
10018 14119, /* A1 = 0.861786 */
10019 -30227, /* A2 = -0.922455 */
10020 11466, /* B2 = 0.349945 */
10021 -2833, /* B1 = -0.172943 */
10022 11466, /* B0 = 0.349945 */
10023 23431, /* A1 = 1.430115 */
10024 -30828, /* A2 = -0.940796 */
10025 25331, /* B2 = 0.773071 */
10026 -20911, /* B1 = -1.276367 */
10027 25331, /* B0 = 0.773071 */
10028 7, /* Internal filter scaling */
10029 159, /* Minimum in-band energy threshold */
10030 21, /* 21/32 in-band to broad-band ratio */
10031 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10033 { /* f975 */
10034 23521, /* A1 = -1.435608 */
10035 -32489, /* A2 = 0.991516 */
10036 -193, /* B2 = -0.005915 */
10037 0, /* B1 = 0.000000 */
10038 193, /* B0 = 0.005915 */
10039 23404, /* A1 = -1.428467 */
10040 -32655, /* A2 = 0.996582 */
10041 17740, /* B2 = 0.541412 */
10042 -12567, /* B1 = -0.767029 */
10043 17740, /* B0 = 0.541412 */
10044 23753, /* A1 = -1.449829 */
10045 -32657, /* A2 = 0.996613 */
10046 9090, /* B2 = 0.277405 */
10047 -6662, /* B1 = -0.406647 */
10048 9090, /* B0 = 0.277405 */
10049 5, /* Internal filter scaling */
10050 159, /* Minimum in-band energy threshold */
10051 21, /* 21/32 in-band to broad-band ratio */
10052 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10054 { /* f1000 */
10055 23071, /* A1 = -1.408203 */
10056 -32489, /* A2 = 0.991516 */
10057 -293, /* B2 = -0.008965 */
10058 0, /* B1 = 0.000000 */
10059 293, /* B0 = 0.008965 */
10060 22951, /* A1 = -1.400818 */
10061 -32655, /* A2 = 0.996582 */
10062 5689, /* B2 = 0.173645 */
10063 -3951, /* B1 = -0.241150 */
10064 5689, /* B0 = 0.173645 */
10065 23307, /* A1 = -1.422607 */
10066 -32657, /* A2 = 0.996613 */
10067 18692, /* B2 = 0.570435 */
10068 -13447, /* B1 = -0.820770 */
10069 18692, /* B0 = 0.570435 */
10070 5, /* Internal filter scaling */
10071 159, /* Minimum in-band energy threshold */
10072 21, /* 21/32 in-band to broad-band ratio */
10073 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10075 { /* f1020 */
10076 22701, /* A1 = -1.385620 */
10077 -32474, /* A2 = 0.991058 */
10078 -292, /* B2 = -0.008933 */
10079 0, /*163840 , B1 = 10.000000 */
10080 292, /* B0 = 0.008933 */
10081 22564, /* A1 = -1.377258 */
10082 -32655, /* A2 = 0.996552 */
10083 20756, /* B2 = 0.633423 */
10084 -14176, /* B1 = -0.865295 */
10085 20756, /* B0 = 0.633423 */
10086 22960, /* A1 = -1.401428 */
10087 -32657, /* A2 = 0.996613 */
10088 6520, /* B2 = 0.198990 */
10089 -4619, /* B1 = -0.281937 */
10090 6520, /* B0 = 0.198990 */
10091 5, /* Internal filter scaling */
10092 159, /* Minimum in-band energy threshold */
10093 21, /* 21/32 in-band to broad-band ratio */
10094 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10096 { /* f1050 */
10097 22142, /* A1 = -1.351501 */
10098 -32474, /* A2 = 0.991058 */
10099 -147, /* B2 = -0.004493 */
10100 0, /* B1 = 0.000000 */
10101 147, /* B0 = 0.004493 */
10102 22000, /* A1 = -1.342834 */
10103 -32655, /* A2 = 0.996552 */
10104 15379, /* B2 = 0.469360 */
10105 -10237, /* B1 = -0.624847 */
10106 15379, /* B0 = 0.469360 */
10107 22406, /* A1 = -1.367554 */
10108 -32657, /* A2 = 0.996613 */
10109 17491, /* B2 = 0.533783 */
10110 -12096, /* B1 = -0.738312 */
10111 17491, /* B0 = 0.533783 */
10112 5, /* Internal filter scaling */
10113 159, /* Minimum in-band energy threshold */
10114 21, /* 21/32 in-band to broad-band ratio */
10115 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10117 { /* f1100_1750[] */
10118 12973, /* A1 = 0.79184 */
10119 -24916, /* A2 = -0.760376 */
10120 6655, /* B2 = 0.203102 */
10121 367, /* B1 = 0.0224 */
10122 6657, /* B0 = 0.203171 */
10123 5915, /* A1 = 0.361053 */
10124 -29560, /* A2 = -0.90213 */
10125 -7777, /* B2 = -0.23735 */
10126 0, /* B1 = 0 */
10127 7777, /* B0 = 0.23735 */
10128 20510, /* A1 = 1.251892 */
10129 -30260, /* A2 = -0.923462 */
10130 26662, /* B2 = 0.81366 */
10131 -20573, /* B1 = -1.255737 */
10132 26668, /* B0 = 0.813843 */
10133 7, /* Internal filter scaling */
10134 159, /* Minimum in-band energy threshold */
10135 21, /* 21/32 in-band to broad-band ratio */
10136 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10138 { /* f1140 */
10139 20392, /* A1 = -1.244629 */
10140 -32460, /* A2 = 0.990601 */
10141 -270, /* B2 = -0.008240 */
10142 0, /* B1 = 0.000000 */
10143 270, /* B0 = 0.008240 */
10144 20218, /* A1 = -1.234009 */
10145 -32655, /* A2 = 0.996582 */
10146 21337, /* B2 = 0.651154 */
10147 -13044, /* B1 = -0.796143 */
10148 21337, /* B0 = 0.651154 */
10149 20684, /* A1 = -1.262512 */
10150 -32657, /* A2 = 0.996643 */
10151 8572, /* B2 = 0.261612 */
10152 -5476, /* B1 = -0.334244 */
10153 8572, /* B0 = 0.261612 */
10154 5, /* Internal filter scaling */
10155 159, /* Minimum in-band energy threshold */
10156 21, /* 21/32 in-band to broad-band ratio */
10157 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10159 { /* f1200 */
10160 19159, /* A1 = -1.169373 */
10161 -32456, /* A2 = 0.990509 */
10162 -335, /* B2 = -0.010252 */
10163 0, /* B1 = 0.000000 */
10164 335, /* B0 = 0.010252 */
10165 18966, /* A1 = -1.157593 */
10166 -32661, /* A2 = 0.996735 */
10167 6802, /* B2 = 0.207588 */
10168 -3900, /* B1 = -0.238098 */
10169 6802, /* B0 = 0.207588 */
10170 19467, /* A1 = -1.188232 */
10171 -32661, /* A2 = 0.996765 */
10172 25035, /* B2 = 0.764008 */
10173 -15049, /* B1 = -0.918579 */
10174 25035, /* B0 = 0.764008 */
10175 5, /* Internal filter scaling */
10176 159, /* Minimum in-band energy threshold */
10177 21, /* 21/32 in-band to broad-band ratio */
10178 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10180 { /* f1209 */
10181 18976, /* A1 = -1.158264 */
10182 -32439, /* A2 = 0.989990 */
10183 -183, /* B2 = -0.005588 */
10184 0, /* B1 = 0.000000 */
10185 183, /* B0 = 0.005588 */
10186 18774, /* A1 = -1.145874 */
10187 -32650, /* A2 = 0.996429 */
10188 15468, /* B2 = 0.472076 */
10189 -8768, /* B1 = -0.535217 */
10190 15468, /* B0 = 0.472076 */
10191 19300, /* A1 = -1.177979 */
10192 -32652, /* A2 = 0.996490 */
10193 19840, /* B2 = 0.605499 */
10194 -11842, /* B1 = -0.722809 */
10195 19840, /* B0 = 0.605499 */
10196 5, /* Internal filter scaling */
10197 159, /* Minimum in-band energy threshold */
10198 21, /* 21/32 in-band to broad-band ratio */
10199 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10201 { /* f1330 */
10202 16357, /* A1 = -0.998413 */
10203 -32368, /* A2 = 0.987793 */
10204 -217, /* B2 = -0.006652 */
10205 0, /* B1 = 0.000000 */
10206 217, /* B0 = 0.006652 */
10207 16107, /* A1 = -0.983126 */
10208 -32601, /* A2 = 0.994904 */
10209 11602, /* B2 = 0.354065 */
10210 -5555, /* B1 = -0.339111 */
10211 11602, /* B0 = 0.354065 */
10212 16722, /* A1 = -1.020630 */
10213 -32603, /* A2 = 0.994965 */
10214 15574, /* B2 = 0.475311 */
10215 -8176, /* B1 = -0.499069 */
10216 15574, /* B0 = 0.475311 */
10217 5, /* Internal filter scaling */
10218 159, /* Minimum in-band energy threshold */
10219 21, /* 21/32 in-band to broad-band ratio */
10220 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10222 { /* f1336 */
10223 16234, /* A1 = -0.990875 */
10224 32404, /* A2 = -0.988922 */
10225 -193, /* B2 = -0.005908 */
10226 0, /* B1 = 0.000000 */
10227 193, /* B0 = 0.005908 */
10228 15986, /* A1 = -0.975769 */
10229 -32632, /* A2 = 0.995880 */
10230 18051, /* B2 = 0.550903 */
10231 -8658, /* B1 = -0.528473 */
10232 18051, /* B0 = 0.550903 */
10233 16591, /* A1 = -1.012695 */
10234 -32634, /* A2 = 0.995941 */
10235 15736, /* B2 = 0.480240 */
10236 -8125, /* B1 = -0.495926 */
10237 15736, /* B0 = 0.480240 */
10238 5, /* Internal filter scaling */
10239 159, /* Minimum in-band energy threshold */
10240 21, /* 21/32 in-band to broad-band ratio */
10241 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10243 { /* f1366 */
10244 15564, /* A1 = -0.949982 */
10245 -32404, /* A2 = 0.988922 */
10246 -269, /* B2 = -0.008216 */
10247 0, /* B1 = 0.000000 */
10248 269, /* B0 = 0.008216 */
10249 15310, /* A1 = -0.934479 */
10250 -32632, /* A2 = 0.995880 */
10251 10815, /* B2 = 0.330063 */
10252 -4962, /* B1 = -0.302887 */
10253 10815, /* B0 = 0.330063 */
10254 15924, /* A1 = -0.971924 */
10255 -32634, /* A2 = 0.995941 */
10256 18880, /* B2 = 0.576172 */
10257 -9364, /* B1 = -0.571594 */
10258 18880, /* B0 = 0.576172 */
10259 5, /* Internal filter scaling */
10260 159, /* Minimum in-band energy threshold */
10261 21, /* 21/32 in-band to broad-band ratio */
10262 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10264 { /* f1380 */
10265 15247, /* A1 = -0.930603 */
10266 -32397, /* A2 = 0.988708 */
10267 -244, /* B2 = -0.007451 */
10268 0, /* B1 = 0.000000 */
10269 244, /* B0 = 0.007451 */
10270 14989, /* A1 = -0.914886 */
10271 -32627, /* A2 = 0.995697 */
10272 18961, /* B2 = 0.578644 */
10273 -8498, /* B1 = -0.518707 */
10274 18961, /* B0 = 0.578644 */
10275 15608, /* A1 = -0.952667 */
10276 -32628, /* A2 = 0.995758 */
10277 11145, /* B2 = 0.340134 */
10278 -5430, /* B1 = -0.331467 */
10279 11145, /* B0 = 0.340134 */
10280 5, /* Internal filter scaling */
10281 159, /* Minimum in-band energy threshold */
10282 21, /* 21/32 in-band to broad-band ratio */
10283 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10285 { /* f1400 */
10286 14780, /* A1 = -0.902130 */
10287 -32393, /* A2 = 0.988586 */
10288 -396, /* B2 = -0.012086 */
10289 0, /* B1 = 0.000000 */
10290 396, /* B0 = 0.012086 */
10291 14510, /* A1 = -0.885651 */
10292 -32630, /* A2 = 0.995819 */
10293 6326, /* B2 = 0.193069 */
10294 -2747, /* B1 = -0.167671 */
10295 6326, /* B0 = 0.193069 */
10296 15154, /* A1 = -0.924957 */
10297 -32632, /* A2 = 0.995850 */
10298 23235, /* B2 = 0.709076 */
10299 -10983, /* B1 = -0.670380 */
10300 23235, /* B0 = 0.709076 */
10301 5, /* Internal filter scaling */
10302 159, /* Minimum in-band energy threshold */
10303 21, /* 21/32 in-band to broad-band ratio */
10304 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10306 { /* f1477 */
10307 13005, /* A1 = -0.793793 */
10308 -32368, /* A2 = 0.987823 */
10309 -500, /* B2 = -0.015265 */
10310 0, /* B1 = 0.000000 */
10311 500, /* B0 = 0.015265 */
10312 12708, /* A1 = -0.775665 */
10313 -32615, /* A2 = 0.995331 */
10314 11420, /* B2 = 0.348526 */
10315 -4306, /* B1 = -0.262833 */
10316 11420, /* B0 = 0.348526 */
10317 13397, /* A1 = -0.817688 */
10318 -32615, /* A2 = 0.995361 */
10319 9454, /* B2 = 0.288528 */
10320 -3981, /* B1 = -0.243027 */
10321 9454, /* B0 = 0.288528 */
10322 5, /* Internal filter scaling */
10323 159, /* Minimum in-band energy threshold */
10324 21, /* 21/32 in-band to broad-band ratio */
10325 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10327 { /* f1600 */
10328 10046, /* A1 = -0.613190 */
10329 -32331, /* A2 = 0.986694 */
10330 -455, /* B2 = -0.013915 */
10331 0, /* B1 = 0.000000 */
10332 455, /* B0 = 0.013915 */
10333 9694, /* A1 = -0.591705 */
10334 -32601, /* A2 = 0.994934 */
10335 6023, /* B2 = 0.183815 */
10336 -1708, /* B1 = -0.104279 */
10337 6023, /* B0 = 0.183815 */
10338 10478, /* A1 = -0.639587 */
10339 -32603, /* A2 = 0.994965 */
10340 22031, /* B2 = 0.672333 */
10341 -7342, /* B1 = -0.448151 */
10342 22031, /* B0 = 0.672333 */
10343 5, /* Internal filter scaling */
10344 159, /* Minimum in-band energy threshold */
10345 21, /* 21/32 in-band to broad-band ratio */
10346 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10348 { /* f1633_1638[] */
10349 9181, /* A1 = 0.560394 */
10350 -32256, /* A2 = -0.984375 */
10351 -556, /* B2 = -0.016975 */
10352 0, /* B1 = 0 */
10353 556, /* B0 = 0.016975 */
10354 8757, /* A1 = 0.534515 */
10355 -32574, /* A2 = -0.99408 */
10356 8443, /* B2 = 0.25769 */
10357 -2135, /* B1 = -0.130341 */
10358 8443, /* B0 = 0.25769 */
10359 9691, /* A1 = 0.591522 */
10360 -32574, /* A2 = -0.99411 */
10361 15446, /* B2 = 0.471375 */
10362 -4809, /* B1 = -0.293579 */
10363 15446, /* B0 = 0.471375 */
10364 7, /* Internal filter scaling */
10365 159, /* Minimum in-band energy threshold */
10366 21, /* 21/32 in-band to broad-band ratio */
10367 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10369 { /* f1800 */
10370 5076, /* A1 = -0.309875 */
10371 -32304, /* A2 = 0.985840 */
10372 -508, /* B2 = -0.015503 */
10373 0, /* B1 = 0.000000 */
10374 508, /* B0 = 0.015503 */
10375 4646, /* A1 = -0.283600 */
10376 -32605, /* A2 = 0.995026 */
10377 6742, /* B2 = 0.205780 */
10378 -878, /* B1 = -0.053635 */
10379 6742, /* B0 = 0.205780 */
10380 5552, /* A1 = -0.338928 */
10381 -32605, /* A2 = 0.995056 */
10382 23667, /* B2 = 0.722260 */
10383 -4297, /* B1 = -0.262329 */
10384 23667, /* B0 = 0.722260 */
10385 5, /* Internal filter scaling */
10386 159, /* Minimum in-band energy threshold */
10387 21, /* 21/32 in-band to broad-band ratio */
10388 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10390 { /* f1860 */
10391 3569, /* A1 = -0.217865 */
10392 -32292, /* A2 = 0.985504 */
10393 -239, /* B2 = -0.007322 */
10394 0, /* B1 = 0.000000 */
10395 239, /* B0 = 0.007322 */
10396 3117, /* A1 = -0.190277 */
10397 -32603, /* A2 = 0.994965 */
10398 18658, /* B2 = 0.569427 */
10399 -1557, /* B1 = -0.095032 */
10400 18658, /* B0 = 0.569427 */
10401 4054, /* A1 = -0.247437 */
10402 -32603, /* A2 = 0.994965 */
10403 18886, /* B2 = 0.576385 */
10404 -2566, /* B1 = -0.156647 */
10405 18886, /* B0 = 0.576385 */
10406 5, /* Internal filter scaling */
10407 159, /* Minimum in-band energy threshold */
10408 21, /* 21/32 in-band to broad-band ratio */
10409 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10412 static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf)
10414 unsigned short cmd;
10415 int cnt, max;
10417 if (jf->filter > 3) {
10418 return -1;
10420 if (ixj_WriteDSPCommand(0x5154 + jf->filter, j)) /* Select Filter */
10422 return -1;
10423 if (!jf->enable) {
10424 if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
10426 return -1;
10427 else
10428 return 0;
10429 } else {
10430 if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
10432 return -1;
10433 /* Select the filter (f0 - f3) to use. */
10434 if (ixj_WriteDSPCommand(0x5154 + jf->filter, j))
10435 return -1;
10437 if (jf->freq < 12 && jf->freq > 3) {
10438 /* Select the frequency for the selected filter. */
10439 if (ixj_WriteDSPCommand(0x5170 + jf->freq, j))
10440 return -1;
10441 } else if (jf->freq > 11) {
10442 /* We need to load a programmable filter set for undefined */
10443 /* frequencies. So we will point the filter to a programmable set. */
10444 /* Since there are only 4 filters and 4 programmable sets, we will */
10445 /* just point the filter to the same number set and program it for the */
10446 /* frequency we want. */
10447 if (ixj_WriteDSPCommand(0x5170 + jf->filter, j))
10448 return -1;
10449 if (j->ver.low != 0x12) {
10450 cmd = 0x515B;
10451 max = 19;
10452 } else {
10453 cmd = 0x515E;
10454 max = 15;
10456 if (ixj_WriteDSPCommand(cmd, j))
10457 return -1;
10458 for (cnt = 0; cnt < max; cnt++) {
10459 if (ixj_WriteDSPCommand(tone_table[jf->freq - 12][cnt], j))
10460 return -1;
10463 j->filter_en[jf->filter] = jf->enable;
10464 return 0;
10467 static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr)
10469 unsigned short cmd;
10470 int cnt, max;
10471 if (jfr->filter > 3) {
10472 return -1;
10474 if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j)) /* Select Filter */
10475 return -1;
10477 if (!jfr->enable) {
10478 if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
10479 return -1;
10480 else
10481 return 0;
10482 } else {
10483 if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
10484 return -1;
10485 /* Select the filter (f0 - f3) to use. */
10486 if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j))
10487 return -1;
10489 /* We need to load a programmable filter set for undefined */
10490 /* frequencies. So we will point the filter to a programmable set. */
10491 /* Since there are only 4 filters and 4 programmable sets, we will */
10492 /* just point the filter to the same number set and program it for the */
10493 /* frequency we want. */
10494 if (ixj_WriteDSPCommand(0x5170 + jfr->filter, j))
10495 return -1;
10496 if (j->ver.low != 0x12) {
10497 cmd = 0x515B;
10498 max = 19;
10499 } else {
10500 cmd = 0x515E;
10501 max = 15;
10503 if (ixj_WriteDSPCommand(cmd, j))
10504 return -1;
10505 for (cnt = 0; cnt < max; cnt++) {
10506 if (ixj_WriteDSPCommand(jfr->coeff[cnt], j))
10507 return -1;
10509 j->filter_en[jfr->filter] = jfr->enable;
10510 return 0;
10513 static int ixj_init_tone(IXJ *j, IXJ_TONE * ti)
10515 int freq0, freq1;
10516 unsigned short data;
10517 if (ti->freq0) {
10518 freq0 = ti->freq0;
10519 } else {
10520 freq0 = 0x7FFF;
10523 if (ti->freq1) {
10524 freq1 = ti->freq1;
10525 } else {
10526 freq1 = 0x7FFF;
10529 if(ti->tone_index > 12 && ti->tone_index < 28)
10531 if (ixj_WriteDSPCommand(0x6800 + ti->tone_index, j))
10532 return -1;
10533 if (ixj_WriteDSPCommand(0x6000 + (ti->gain1 << 4) + ti->gain0, j))
10534 return -1;
10535 data = freq0;
10536 if (ixj_WriteDSPCommand(data, j))
10537 return -1;
10538 data = freq1;
10539 if (ixj_WriteDSPCommand(data, j))
10540 return -1;
10542 return freq0;