[PATCH] aic7xxx_osm build fix
[cris-mirror.git] / drivers / telephony / ixj.c
blobd5863b8b56eeaf00745a03f3d3a76c11c12a512f
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 /************************************************************************
289 * ixjdebug meanings are now bit mapped instead of level based
290 * Values can be or'ed together to turn on multiple messages
292 * bit 0 (0x0001) = any failure
293 * bit 1 (0x0002) = general messages
294 * bit 2 (0x0004) = POTS ringing related
295 * bit 3 (0x0008) = PSTN events
296 * bit 4 (0x0010) = PSTN Cadence state details
297 * bit 5 (0x0020) = Tone detection triggers
298 * bit 6 (0x0040) = Tone detection cadence details
299 * bit 7 (0x0080) = ioctl tracking
300 * bit 8 (0x0100) = signal tracking
301 * bit 9 (0x0200) = CallerID generation details
303 ************************************************************************/
305 #ifdef IXJ_DYN_ALLOC
307 static IXJ *ixj[IXJMAX];
308 #define get_ixj(b) ixj[(b)]
311 * Allocate a free IXJ device
314 static IXJ *ixj_alloc()
316 for(cnt=0; cnt<IXJMAX; cnt++)
318 if(ixj[cnt] == NULL || !ixj[cnt]->DSPbase)
320 j = kmalloc(sizeof(IXJ), GFP_KERNEL);
321 if (j == NULL)
322 return NULL;
323 ixj[cnt] = j;
324 return j;
327 return NULL;
330 static void ixj_fsk_free(IXJ *j)
332 if(j->fskdata != NULL) {
333 kfree(j->fskdata);
334 j->fskdata = NULL;
338 static void ixj_fsk_alloc(IXJ *j)
340 if(!j->fskdata) {
341 j->fskdata = kmalloc(8000, GFP_KERNEL);
342 if (!j->fskdata) {
343 if(ixjdebug & 0x0200) {
344 printk("IXJ phone%d - allocate failed\n", j->board);
346 return;
347 } else {
348 j->fsksize = 8000;
349 if(ixjdebug & 0x0200) {
350 printk("IXJ phone%d - allocate succeded\n", j->board);
356 #else
358 static IXJ ixj[IXJMAX];
359 #define get_ixj(b) (&ixj[(b)])
362 * Allocate a free IXJ device
365 static IXJ *ixj_alloc(void)
367 int cnt;
368 for(cnt=0; cnt<IXJMAX; cnt++) {
369 if(!ixj[cnt].DSPbase)
370 return &ixj[cnt];
372 return NULL;
375 static inline void ixj_fsk_free(IXJ *j) {;}
377 static inline void ixj_fsk_alloc(IXJ *j)
379 j->fsksize = 8000;
382 #endif
384 #ifdef PERFMON_STATS
385 #define ixj_perfmon(x) ((x)++)
386 #else
387 #define ixj_perfmon(x) do { } while(0)
388 #endif
390 static int ixj_convert_loaded;
392 static int ixj_WriteDSPCommand(unsigned short, IXJ *j);
394 /************************************************************************
396 * These are function definitions to allow external modules to register
397 * enhanced functionality call backs.
399 ************************************************************************/
401 static int Stub(IXJ * J, unsigned long arg)
403 return 0;
406 static IXJ_REGFUNC ixj_PreRead = &Stub;
407 static IXJ_REGFUNC ixj_PostRead = &Stub;
408 static IXJ_REGFUNC ixj_PreWrite = &Stub;
409 static IXJ_REGFUNC ixj_PostWrite = &Stub;
411 static void ixj_read_frame(IXJ *j);
412 static void ixj_write_frame(IXJ *j);
413 static void ixj_init_timer(IXJ *j);
414 static void ixj_add_timer(IXJ * j);
415 static void ixj_timeout(unsigned long ptr);
416 static int read_filters(IXJ *j);
417 static int LineMonitor(IXJ *j);
418 static int ixj_fasync(int fd, struct file *, int mode);
419 static int ixj_set_port(IXJ *j, int arg);
420 static int ixj_set_pots(IXJ *j, int arg);
421 static int ixj_hookstate(IXJ *j);
422 static int ixj_record_start(IXJ *j);
423 static void ixj_record_stop(IXJ *j);
424 static void set_rec_volume(IXJ *j, int volume);
425 static int get_rec_volume(IXJ *j);
426 static int set_rec_codec(IXJ *j, int rate);
427 static void ixj_vad(IXJ *j, int arg);
428 static int ixj_play_start(IXJ *j);
429 static void ixj_play_stop(IXJ *j);
430 static int ixj_set_tone_on(unsigned short arg, IXJ *j);
431 static int ixj_set_tone_off(unsigned short, IXJ *j);
432 static int ixj_play_tone(IXJ *j, char tone);
433 static void ixj_aec_start(IXJ *j, int level);
434 static int idle(IXJ *j);
435 static void ixj_ring_on(IXJ *j);
436 static void ixj_ring_off(IXJ *j);
437 static void aec_stop(IXJ *j);
438 static void ixj_ringback(IXJ *j);
439 static void ixj_busytone(IXJ *j);
440 static void ixj_dialtone(IXJ *j);
441 static void ixj_cpt_stop(IXJ *j);
442 static char daa_int_read(IXJ *j);
443 static char daa_CR_read(IXJ *j, int cr);
444 static int daa_set_mode(IXJ *j, int mode);
445 static int ixj_linetest(IXJ *j);
446 static int ixj_daa_write(IXJ *j);
447 static int ixj_daa_cid_read(IXJ *j);
448 static void DAA_Coeff_US(IXJ *j);
449 static void DAA_Coeff_UK(IXJ *j);
450 static void DAA_Coeff_France(IXJ *j);
451 static void DAA_Coeff_Germany(IXJ *j);
452 static void DAA_Coeff_Australia(IXJ *j);
453 static void DAA_Coeff_Japan(IXJ *j);
454 static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf);
455 static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr);
456 static int ixj_init_tone(IXJ *j, IXJ_TONE * ti);
457 static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp);
458 static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp);
459 /* Serial Control Interface funtions */
460 static int SCI_Control(IXJ *j, int control);
461 static int SCI_Prepare(IXJ *j);
462 static int SCI_WaitHighSCI(IXJ *j);
463 static int SCI_WaitLowSCI(IXJ *j);
464 static DWORD PCIEE_GetSerialNumber(WORD wAddress);
465 static int ixj_PCcontrol_wait(IXJ *j);
466 static void ixj_pre_cid(IXJ *j);
467 static void ixj_write_cid(IXJ *j);
468 static void ixj_write_cid_bit(IXJ *j, int bit);
469 static int set_base_frame(IXJ *j, int size);
470 static int set_play_codec(IXJ *j, int rate);
471 static void set_rec_depth(IXJ *j, int depth);
472 static int ixj_mixer(long val, IXJ *j);
474 /************************************************************************
475 CT8020/CT8021 Host Programmers Model
476 Host address Function Access
477 DSPbase +
478 0-1 Aux Software Status Register (reserved) Read Only
479 2-3 Software Status Register Read Only
480 4-5 Aux Software Control Register (reserved) Read Write
481 6-7 Software Control Register Read Write
482 8-9 Hardware Status Register Read Only
483 A-B Hardware Control Register Read Write
484 C-D Host Transmit (Write) Data Buffer Access Port (buffer input)Write Only
485 E-F Host Recieve (Read) Data Buffer Access Port (buffer input) Read Only
486 ************************************************************************/
488 static inline void ixj_read_HSR(IXJ *j)
490 j->hsr.bytes.low = inb_p(j->DSPbase + 8);
491 j->hsr.bytes.high = inb_p(j->DSPbase + 9);
494 static inline int IsControlReady(IXJ *j)
496 ixj_read_HSR(j);
497 return j->hsr.bits.controlrdy ? 1 : 0;
500 static inline int IsPCControlReady(IXJ *j)
502 j->pccr1.byte = inb_p(j->XILINXbase + 3);
503 return j->pccr1.bits.crr ? 1 : 0;
506 static inline int IsStatusReady(IXJ *j)
508 ixj_read_HSR(j);
509 return j->hsr.bits.statusrdy ? 1 : 0;
512 static inline int IsRxReady(IXJ *j)
514 ixj_read_HSR(j);
515 ixj_perfmon(j->rxreadycheck);
516 return j->hsr.bits.rxrdy ? 1 : 0;
519 static inline int IsTxReady(IXJ *j)
521 ixj_read_HSR(j);
522 ixj_perfmon(j->txreadycheck);
523 return j->hsr.bits.txrdy ? 1 : 0;
526 static inline void set_play_volume(IXJ *j, int volume)
528 if (ixjdebug & 0x0002)
529 printk(KERN_INFO "IXJ: /dev/phone%d Setting Play Volume to 0x%4.4x\n", j->board, volume);
530 ixj_WriteDSPCommand(0xCF02, j);
531 ixj_WriteDSPCommand(volume, j);
534 static int set_play_volume_linear(IXJ *j, int volume)
536 int newvolume, dspplaymax;
538 if (ixjdebug & 0x0002)
539 printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Play Volume to 0x%4.4x\n", j->board, volume);
540 if(volume > 100 || volume < 0) {
541 return -1;
544 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
545 switch (j->cardtype) {
546 case QTI_PHONEJACK:
547 dspplaymax = 0x380;
548 break;
549 case QTI_LINEJACK:
550 if(j->port == PORT_PSTN) {
551 dspplaymax = 0x48;
552 } else {
553 dspplaymax = 0x100;
555 break;
556 case QTI_PHONEJACK_LITE:
557 dspplaymax = 0x380;
558 break;
559 case QTI_PHONEJACK_PCI:
560 dspplaymax = 0x6C;
561 break;
562 case QTI_PHONECARD:
563 dspplaymax = 0x50;
564 break;
565 default:
566 return -1;
568 newvolume = (dspplaymax * volume) / 100;
569 set_play_volume(j, newvolume);
570 return 0;
573 static inline void set_play_depth(IXJ *j, int depth)
575 if (depth > 60)
576 depth = 60;
577 if (depth < 0)
578 depth = 0;
579 ixj_WriteDSPCommand(0x5280 + depth, j);
582 static inline int get_play_volume(IXJ *j)
584 ixj_WriteDSPCommand(0xCF00, j);
585 return j->ssr.high << 8 | j->ssr.low;
588 static int get_play_volume_linear(IXJ *j)
590 int volume, newvolume, dspplaymax;
592 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
593 switch (j->cardtype) {
594 case QTI_PHONEJACK:
595 dspplaymax = 0x380;
596 break;
597 case QTI_LINEJACK:
598 if(j->port == PORT_PSTN) {
599 dspplaymax = 0x48;
600 } else {
601 dspplaymax = 0x100;
603 break;
604 case QTI_PHONEJACK_LITE:
605 dspplaymax = 0x380;
606 break;
607 case QTI_PHONEJACK_PCI:
608 dspplaymax = 0x6C;
609 break;
610 case QTI_PHONECARD:
611 dspplaymax = 100;
612 break;
613 default:
614 return -1;
616 volume = get_play_volume(j);
617 newvolume = (volume * 100) / dspplaymax;
618 if(newvolume > 100)
619 newvolume = 100;
620 return newvolume;
623 static inline BYTE SLIC_GetState(IXJ *j)
625 if (j->cardtype == QTI_PHONECARD) {
626 j->pccr1.byte = 0;
627 j->psccr.bits.dev = 3;
628 j->psccr.bits.rw = 1;
629 outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
630 ixj_PCcontrol_wait(j);
631 j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
632 ixj_PCcontrol_wait(j);
633 if (j->pslic.bits.powerdown)
634 return PLD_SLIC_STATE_OC;
635 else if (!j->pslic.bits.ring0 && !j->pslic.bits.ring1)
636 return PLD_SLIC_STATE_ACTIVE;
637 else
638 return PLD_SLIC_STATE_RINGING;
639 } else {
640 j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
642 return j->pld_slicr.bits.state;
645 static BOOL SLIC_SetState(BYTE byState, IXJ *j)
647 BOOL fRetVal = FALSE;
649 if (j->cardtype == QTI_PHONECARD) {
650 if (j->flags.pcmciasct) {
651 switch (byState) {
652 case PLD_SLIC_STATE_TIPOPEN:
653 case PLD_SLIC_STATE_OC:
654 j->pslic.bits.powerdown = 1;
655 j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
656 fRetVal = TRUE;
657 break;
658 case PLD_SLIC_STATE_RINGING:
659 if (j->readers || j->writers) {
660 j->pslic.bits.powerdown = 0;
661 j->pslic.bits.ring0 = 1;
662 j->pslic.bits.ring1 = 0;
663 fRetVal = TRUE;
665 break;
666 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
668 case PLD_SLIC_STATE_STANDBY:
669 case PLD_SLIC_STATE_ACTIVE:
670 if (j->readers || j->writers) {
671 j->pslic.bits.powerdown = 0;
672 } else {
673 j->pslic.bits.powerdown = 1;
675 j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
676 fRetVal = TRUE;
677 break;
678 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
680 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
682 default:
683 fRetVal = FALSE;
684 break;
686 j->psccr.bits.dev = 3;
687 j->psccr.bits.rw = 0;
688 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
689 ixj_PCcontrol_wait(j);
691 } else {
692 /* Set the C1, C2, C3 & B2EN signals. */
693 switch (byState) {
694 case PLD_SLIC_STATE_OC:
695 j->pld_slicw.bits.c1 = 0;
696 j->pld_slicw.bits.c2 = 0;
697 j->pld_slicw.bits.c3 = 0;
698 j->pld_slicw.bits.b2en = 0;
699 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
700 fRetVal = TRUE;
701 break;
702 case PLD_SLIC_STATE_RINGING:
703 j->pld_slicw.bits.c1 = 1;
704 j->pld_slicw.bits.c2 = 0;
705 j->pld_slicw.bits.c3 = 0;
706 j->pld_slicw.bits.b2en = 1;
707 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
708 fRetVal = TRUE;
709 break;
710 case PLD_SLIC_STATE_ACTIVE:
711 j->pld_slicw.bits.c1 = 0;
712 j->pld_slicw.bits.c2 = 1;
713 j->pld_slicw.bits.c3 = 0;
714 j->pld_slicw.bits.b2en = 0;
715 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
716 fRetVal = TRUE;
717 break;
718 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
720 j->pld_slicw.bits.c1 = 1;
721 j->pld_slicw.bits.c2 = 1;
722 j->pld_slicw.bits.c3 = 0;
723 j->pld_slicw.bits.b2en = 0;
724 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
725 fRetVal = TRUE;
726 break;
727 case PLD_SLIC_STATE_TIPOPEN:
728 j->pld_slicw.bits.c1 = 0;
729 j->pld_slicw.bits.c2 = 0;
730 j->pld_slicw.bits.c3 = 1;
731 j->pld_slicw.bits.b2en = 0;
732 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
733 fRetVal = TRUE;
734 break;
735 case PLD_SLIC_STATE_STANDBY:
736 j->pld_slicw.bits.c1 = 1;
737 j->pld_slicw.bits.c2 = 0;
738 j->pld_slicw.bits.c3 = 1;
739 j->pld_slicw.bits.b2en = 1;
740 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
741 fRetVal = TRUE;
742 break;
743 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
745 j->pld_slicw.bits.c1 = 0;
746 j->pld_slicw.bits.c2 = 1;
747 j->pld_slicw.bits.c3 = 1;
748 j->pld_slicw.bits.b2en = 0;
749 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
750 fRetVal = TRUE;
751 break;
752 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
754 j->pld_slicw.bits.c1 = 1;
755 j->pld_slicw.bits.c2 = 1;
756 j->pld_slicw.bits.c3 = 1;
757 j->pld_slicw.bits.b2en = 0;
758 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
759 fRetVal = TRUE;
760 break;
761 default:
762 fRetVal = FALSE;
763 break;
767 return fRetVal;
770 static int ixj_wink(IXJ *j)
772 BYTE slicnow;
774 slicnow = SLIC_GetState(j);
776 j->pots_winkstart = jiffies;
777 SLIC_SetState(PLD_SLIC_STATE_OC, j);
779 while (time_before(jiffies, j->pots_winkstart + j->winktime)) {
780 set_current_state(TASK_INTERRUPTIBLE);
781 schedule_timeout(1);
784 SLIC_SetState(slicnow, j);
785 return 0;
788 static void ixj_init_timer(IXJ *j)
790 init_timer(&j->timer);
791 j->timer.function = ixj_timeout;
792 j->timer.data = (unsigned long)j;
795 static void ixj_add_timer(IXJ *j)
797 j->timer.expires = jiffies + (hertz / samplerate);
798 add_timer(&j->timer);
801 static void ixj_tone_timeout(IXJ *j)
803 IXJ_TONE ti;
805 j->tone_state++;
806 if (j->tone_state == 3) {
807 j->tone_state = 0;
808 if (j->cadence_t) {
809 j->tone_cadence_state++;
810 if (j->tone_cadence_state >= j->cadence_t->elements_used) {
811 switch (j->cadence_t->termination) {
812 case PLAY_ONCE:
813 ixj_cpt_stop(j);
814 break;
815 case REPEAT_LAST_ELEMENT:
816 j->tone_cadence_state--;
817 ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
818 break;
819 case REPEAT_ALL:
820 j->tone_cadence_state = 0;
821 if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
822 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
823 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
824 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
825 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
826 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
827 ixj_init_tone(j, &ti);
829 ixj_set_tone_on(j->cadence_t->ce[0].tone_on_time, j);
830 ixj_set_tone_off(j->cadence_t->ce[0].tone_off_time, j);
831 ixj_play_tone(j, j->cadence_t->ce[0].index);
832 break;
834 } else {
835 if (j->cadence_t->ce[j->tone_cadence_state].gain0) {
836 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
837 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
838 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
839 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
840 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
841 ixj_init_tone(j, &ti);
843 ixj_set_tone_on(j->cadence_t->ce[j->tone_cadence_state].tone_on_time, j);
844 ixj_set_tone_off(j->cadence_t->ce[j->tone_cadence_state].tone_off_time, j);
845 ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
851 static inline void ixj_kill_fasync(IXJ *j, IXJ_SIGEVENT event, int dir)
853 if(j->ixj_signals[event]) {
854 if(ixjdebug & 0x0100)
855 printk("Sending signal for event %d\n", event);
856 /* Send apps notice of change */
857 /* see config.h for macro definition */
858 kill_fasync(&(j->async_queue), j->ixj_signals[event], dir);
862 static void ixj_pstn_state(IXJ *j)
864 int var;
865 union XOPXR0 XR0, daaint;
867 var = 10;
869 XR0.reg = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg;
870 daaint.reg = 0;
871 XR0.bitreg.RMR = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
873 j->pld_scrr.byte = inb_p(j->XILINXbase);
874 if (j->pld_scrr.bits.daaflag) {
875 daa_int_read(j);
876 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.RING) {
877 if(time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) {
878 daaint.bitreg.RING = 1;
879 if(ixjdebug & 0x0008) {
880 printk(KERN_INFO "IXJ DAA Ring Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
882 } else {
883 daa_set_mode(j, SOP_PU_RESET);
886 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Caller_ID) {
887 daaint.bitreg.Caller_ID = 1;
888 j->pstn_cid_intr = 1;
889 j->pstn_cid_received = jiffies;
890 if(ixjdebug & 0x0008) {
891 printk(KERN_INFO "IXJ DAA Caller_ID Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
894 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Cadence) {
895 daaint.bitreg.Cadence = 1;
896 if(ixjdebug & 0x0008) {
897 printk(KERN_INFO "IXJ DAA Cadence Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
900 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK != XR0.bitreg.VDD_OK) {
901 daaint.bitreg.VDD_OK = 1;
902 daaint.bitreg.SI_0 = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK;
905 daa_CR_read(j, 1);
906 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)) {
907 daaint.bitreg.RMR = 1;
908 daaint.bitreg.SI_1 = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
909 if(ixjdebug & 0x0008) {
910 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);
912 j->pstn_prev_rmr = j->pstn_last_rmr;
913 j->pstn_last_rmr = jiffies;
915 switch(j->daa_mode) {
916 case SOP_PU_SLEEP:
917 if (daaint.bitreg.RING) {
918 if (!j->flags.pstn_ringing) {
919 if (j->daa_mode != SOP_PU_RINGING) {
920 j->pstn_ring_int = jiffies;
921 daa_set_mode(j, SOP_PU_RINGING);
925 break;
926 case SOP_PU_RINGING:
927 if (daaint.bitreg.RMR) {
928 if (ixjdebug & 0x0008) {
929 printk(KERN_INFO "IXJ Ring Cadence a state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
931 if (daaint.bitreg.SI_1) { /* Rising edge of RMR */
932 j->flags.pstn_rmr = 1;
933 j->pstn_ring_start = jiffies;
934 j->pstn_ring_stop = 0;
935 j->ex.bits.pstn_ring = 0;
936 if (j->cadence_f[4].state == 0) {
937 j->cadence_f[4].state = 1;
938 j->cadence_f[4].on1min = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 - var)) / 10000);
939 j->cadence_f[4].on1dot = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100)) / 10000);
940 j->cadence_f[4].on1max = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 + var)) / 10000);
941 } else if (j->cadence_f[4].state == 2) {
942 if((time_after(jiffies, j->cadence_f[4].off1min) &&
943 time_before(jiffies, j->cadence_f[4].off1max))) {
944 if (j->cadence_f[4].on2) {
945 j->cadence_f[4].state = 3;
946 j->cadence_f[4].on2min = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 - var)) / 10000));
947 j->cadence_f[4].on2dot = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100)) / 10000));
948 j->cadence_f[4].on2max = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 + var)) / 10000));
949 } else {
950 j->cadence_f[4].state = 7;
952 } else {
953 if (ixjdebug & 0x0008) {
954 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
955 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
956 j->cadence_f[4].off1);
958 j->cadence_f[4].state = 0;
960 } else if (j->cadence_f[4].state == 4) {
961 if((time_after(jiffies, j->cadence_f[4].off2min) &&
962 time_before(jiffies, j->cadence_f[4].off2max))) {
963 if (j->cadence_f[4].on3) {
964 j->cadence_f[4].state = 5;
965 j->cadence_f[4].on3min = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 - var)) / 10000));
966 j->cadence_f[4].on3dot = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100)) / 10000));
967 j->cadence_f[4].on3max = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 + var)) / 10000));
968 } else {
969 j->cadence_f[4].state = 7;
971 } else {
972 if (ixjdebug & 0x0008) {
973 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
974 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
975 j->cadence_f[4].off2);
977 j->cadence_f[4].state = 0;
979 } else if (j->cadence_f[4].state == 6) {
980 if((time_after(jiffies, j->cadence_f[4].off3min) &&
981 time_before(jiffies, j->cadence_f[4].off3max))) {
982 j->cadence_f[4].state = 7;
983 } else {
984 if (ixjdebug & 0x0008) {
985 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
986 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
987 j->cadence_f[4].off3);
989 j->cadence_f[4].state = 0;
991 } else {
992 j->cadence_f[4].state = 0;
994 } else { /* Falling edge of RMR */
995 j->pstn_ring_start = 0;
996 j->pstn_ring_stop = jiffies;
997 if (j->cadence_f[4].state == 1) {
998 if(!j->cadence_f[4].on1) {
999 j->cadence_f[4].state = 7;
1000 } else if((time_after(jiffies, j->cadence_f[4].on1min) &&
1001 time_before(jiffies, j->cadence_f[4].on1max))) {
1002 if (j->cadence_f[4].off1) {
1003 j->cadence_f[4].state = 2;
1004 j->cadence_f[4].off1min = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 - var)) / 10000));
1005 j->cadence_f[4].off1dot = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100)) / 10000));
1006 j->cadence_f[4].off1max = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 + var)) / 10000));
1007 } else {
1008 j->cadence_f[4].state = 7;
1010 } else {
1011 if (ixjdebug & 0x0008) {
1012 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1013 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1014 j->cadence_f[4].on1);
1016 j->cadence_f[4].state = 0;
1018 } else if (j->cadence_f[4].state == 3) {
1019 if((time_after(jiffies, j->cadence_f[4].on2min) &&
1020 time_before(jiffies, j->cadence_f[4].on2max))) {
1021 if (j->cadence_f[4].off2) {
1022 j->cadence_f[4].state = 4;
1023 j->cadence_f[4].off2min = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 - var)) / 10000));
1024 j->cadence_f[4].off2dot = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100)) / 10000));
1025 j->cadence_f[4].off2max = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 + var)) / 10000));
1026 } else {
1027 j->cadence_f[4].state = 7;
1029 } else {
1030 if (ixjdebug & 0x0008) {
1031 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1032 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1033 j->cadence_f[4].on2);
1035 j->cadence_f[4].state = 0;
1037 } else if (j->cadence_f[4].state == 5) {
1038 if((time_after(jiffies, j->cadence_f[4].on3min) &&
1039 time_before(jiffies, j->cadence_f[4].on3max))) {
1040 if (j->cadence_f[4].off3) {
1041 j->cadence_f[4].state = 6;
1042 j->cadence_f[4].off3min = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 - var)) / 10000));
1043 j->cadence_f[4].off3dot = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100)) / 10000));
1044 j->cadence_f[4].off3max = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 + var)) / 10000));
1045 } else {
1046 j->cadence_f[4].state = 7;
1048 } else {
1049 j->cadence_f[4].state = 0;
1051 } else {
1052 if (ixjdebug & 0x0008) {
1053 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1054 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1055 j->cadence_f[4].on3);
1057 j->cadence_f[4].state = 0;
1060 if (ixjdebug & 0x0010) {
1061 printk(KERN_INFO "IXJ Ring Cadence b state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
1063 if (ixjdebug & 0x0010) {
1064 switch(j->cadence_f[4].state) {
1065 case 1:
1066 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1067 j->cadence_f[4].on1, j->cadence_f[4].on1min, j->cadence_f[4].on1dot, j->cadence_f[4].on1max);
1068 break;
1069 case 2:
1070 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1071 j->cadence_f[4].off1, j->cadence_f[4].off1min, j->cadence_f[4].off1dot, j->cadence_f[4].off1max);
1072 break;
1073 case 3:
1074 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1075 j->cadence_f[4].on2, j->cadence_f[4].on2min, j->cadence_f[4].on2dot, j->cadence_f[4].on2max);
1076 break;
1077 case 4:
1078 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1079 j->cadence_f[4].off2, j->cadence_f[4].off2min, j->cadence_f[4].off2dot, j->cadence_f[4].off2max);
1080 break;
1081 case 5:
1082 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1083 j->cadence_f[4].on3, j->cadence_f[4].on3min, j->cadence_f[4].on3dot, j->cadence_f[4].on3max);
1084 break;
1085 case 6:
1086 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1087 j->cadence_f[4].off3, j->cadence_f[4].off3min, j->cadence_f[4].off3dot, j->cadence_f[4].off3max);
1088 break;
1092 if (j->cadence_f[4].state == 7) {
1093 j->cadence_f[4].state = 0;
1094 j->pstn_ring_stop = jiffies;
1095 j->ex.bits.pstn_ring = 1;
1096 ixj_kill_fasync(j, SIG_PSTN_RING, POLL_IN);
1097 if(ixjdebug & 0x0008) {
1098 printk(KERN_INFO "IXJ Ring int set /dev/phone%d at %ld\n", j->board, jiffies);
1101 if((j->pstn_ring_int != 0 && time_after(jiffies, j->pstn_ring_int + (hertz * 5)) && !j->flags.pstn_rmr) ||
1102 (j->pstn_ring_stop != 0 && time_after(jiffies, j->pstn_ring_stop + (hertz * 5)))) {
1103 if(ixjdebug & 0x0008) {
1104 printk("IXJ DAA no ring in 5 seconds /dev/phone%d at %ld\n", j->board, jiffies);
1105 printk("IXJ DAA pstn ring int /dev/phone%d at %ld\n", j->board, j->pstn_ring_int);
1106 printk("IXJ DAA pstn ring stop /dev/phone%d at %ld\n", j->board, j->pstn_ring_stop);
1108 j->pstn_ring_stop = j->pstn_ring_int = 0;
1109 daa_set_mode(j, SOP_PU_SLEEP);
1111 outb_p(j->pld_scrw.byte, j->XILINXbase);
1112 if (j->pstn_cid_intr && time_after(jiffies, j->pstn_cid_received + hertz)) {
1113 ixj_daa_cid_read(j);
1114 j->ex.bits.caller_id = 1;
1115 ixj_kill_fasync(j, SIG_CALLER_ID, POLL_IN);
1116 j->pstn_cid_intr = 0;
1118 if (daaint.bitreg.Cadence) {
1119 if(ixjdebug & 0x0008) {
1120 printk("IXJ DAA Cadence interrupt going to sleep /dev/phone%d\n", j->board);
1122 daa_set_mode(j, SOP_PU_SLEEP);
1123 j->ex.bits.pstn_ring = 0;
1125 break;
1126 case SOP_PU_CONVERSATION:
1127 if (daaint.bitreg.VDD_OK) {
1128 if(!daaint.bitreg.SI_0) {
1129 if (!j->pstn_winkstart) {
1130 if(ixjdebug & 0x0008) {
1131 printk("IXJ DAA possible wink /dev/phone%d %ld\n", j->board, jiffies);
1133 j->pstn_winkstart = jiffies;
1135 } else {
1136 if (j->pstn_winkstart) {
1137 if(ixjdebug & 0x0008) {
1138 printk("IXJ DAA possible wink end /dev/phone%d %ld\n", j->board, jiffies);
1140 j->pstn_winkstart = 0;
1144 if (j->pstn_winkstart && time_after(jiffies, j->pstn_winkstart + ((hertz * j->winktime) / 1000))) {
1145 if(ixjdebug & 0x0008) {
1146 printk("IXJ DAA wink detected going to sleep /dev/phone%d %ld\n", j->board, jiffies);
1148 daa_set_mode(j, SOP_PU_SLEEP);
1149 j->pstn_winkstart = 0;
1150 j->ex.bits.pstn_wink = 1;
1151 ixj_kill_fasync(j, SIG_PSTN_WINK, POLL_IN);
1153 break;
1157 static void ixj_timeout(unsigned long ptr)
1159 int board;
1160 unsigned long jifon;
1161 IXJ *j = (IXJ *)ptr;
1162 board = j->board;
1164 if (j->DSPbase && atomic_read(&j->DSPWrite) == 0 && test_and_set_bit(board, (void *)&j->busyflags) == 0) {
1165 ixj_perfmon(j->timerchecks);
1166 j->hookstate = ixj_hookstate(j);
1167 if (j->tone_state) {
1168 if (!(j->hookstate)) {
1169 ixj_cpt_stop(j);
1170 if (j->m_hook) {
1171 j->m_hook = 0;
1172 j->ex.bits.hookstate = 1;
1173 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1175 clear_bit(board, &j->busyflags);
1176 ixj_add_timer(j);
1177 return;
1179 if (j->tone_state == 1)
1180 jifon = ((hertz * j->tone_on_time) * 25 / 100000);
1181 else
1182 jifon = ((hertz * j->tone_on_time) * 25 / 100000) + ((hertz * j->tone_off_time) * 25 / 100000);
1183 if (time_before(jiffies, j->tone_start_jif + jifon)) {
1184 if (j->tone_state == 1) {
1185 ixj_play_tone(j, j->tone_index);
1186 if (j->dsp.low == 0x20) {
1187 clear_bit(board, &j->busyflags);
1188 ixj_add_timer(j);
1189 return;
1191 } else {
1192 ixj_play_tone(j, 0);
1193 if (j->dsp.low == 0x20) {
1194 clear_bit(board, &j->busyflags);
1195 ixj_add_timer(j);
1196 return;
1199 } else {
1200 ixj_tone_timeout(j);
1201 if (j->flags.dialtone) {
1202 ixj_dialtone(j);
1204 if (j->flags.busytone) {
1205 ixj_busytone(j);
1206 if (j->dsp.low == 0x20) {
1207 clear_bit(board, &j->busyflags);
1208 ixj_add_timer(j);
1209 return;
1212 if (j->flags.ringback) {
1213 ixj_ringback(j);
1214 if (j->dsp.low == 0x20) {
1215 clear_bit(board, &j->busyflags);
1216 ixj_add_timer(j);
1217 return;
1220 if (!j->tone_state) {
1221 ixj_cpt_stop(j);
1225 if (!(j->tone_state && j->dsp.low == 0x20)) {
1226 if (IsRxReady(j)) {
1227 ixj_read_frame(j);
1229 if (IsTxReady(j)) {
1230 ixj_write_frame(j);
1233 if (j->flags.cringing) {
1234 if (j->hookstate & 1) {
1235 j->flags.cringing = 0;
1236 ixj_ring_off(j);
1237 } else if(j->cadence_f[5].enable && ((!j->cadence_f[5].en_filter) || (j->cadence_f[5].en_filter && j->flags.firstring))) {
1238 switch(j->cadence_f[5].state) {
1239 case 0:
1240 j->cadence_f[5].on1dot = jiffies + (long)((j->cadence_f[5].on1 * (hertz * 100) / 10000));
1241 if (time_before(jiffies, j->cadence_f[5].on1dot)) {
1242 if(ixjdebug & 0x0004) {
1243 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1245 ixj_ring_on(j);
1247 j->cadence_f[5].state = 1;
1248 break;
1249 case 1:
1250 if (time_after(jiffies, j->cadence_f[5].on1dot)) {
1251 j->cadence_f[5].off1dot = jiffies + (long)((j->cadence_f[5].off1 * (hertz * 100) / 10000));
1252 if(ixjdebug & 0x0004) {
1253 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1255 ixj_ring_off(j);
1256 j->cadence_f[5].state = 2;
1258 break;
1259 case 2:
1260 if (time_after(jiffies, j->cadence_f[5].off1dot)) {
1261 if(ixjdebug & 0x0004) {
1262 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1264 ixj_ring_on(j);
1265 if (j->cadence_f[5].on2) {
1266 j->cadence_f[5].on2dot = jiffies + (long)((j->cadence_f[5].on2 * (hertz * 100) / 10000));
1267 j->cadence_f[5].state = 3;
1268 } else {
1269 j->cadence_f[5].state = 7;
1272 break;
1273 case 3:
1274 if (time_after(jiffies, j->cadence_f[5].on2dot)) {
1275 if(ixjdebug & 0x0004) {
1276 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1278 ixj_ring_off(j);
1279 if (j->cadence_f[5].off2) {
1280 j->cadence_f[5].off2dot = jiffies + (long)((j->cadence_f[5].off2 * (hertz * 100) / 10000));
1281 j->cadence_f[5].state = 4;
1282 } else {
1283 j->cadence_f[5].state = 7;
1286 break;
1287 case 4:
1288 if (time_after(jiffies, j->cadence_f[5].off2dot)) {
1289 if(ixjdebug & 0x0004) {
1290 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1292 ixj_ring_on(j);
1293 if (j->cadence_f[5].on3) {
1294 j->cadence_f[5].on3dot = jiffies + (long)((j->cadence_f[5].on3 * (hertz * 100) / 10000));
1295 j->cadence_f[5].state = 5;
1296 } else {
1297 j->cadence_f[5].state = 7;
1300 break;
1301 case 5:
1302 if (time_after(jiffies, j->cadence_f[5].on3dot)) {
1303 if(ixjdebug & 0x0004) {
1304 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1306 ixj_ring_off(j);
1307 if (j->cadence_f[5].off3) {
1308 j->cadence_f[5].off3dot = jiffies + (long)((j->cadence_f[5].off3 * (hertz * 100) / 10000));
1309 j->cadence_f[5].state = 6;
1310 } else {
1311 j->cadence_f[5].state = 7;
1314 break;
1315 case 6:
1316 if (time_after(jiffies, j->cadence_f[5].off3dot)) {
1317 if(ixjdebug & 0x0004) {
1318 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1320 j->cadence_f[5].state = 7;
1322 break;
1323 case 7:
1324 if(ixjdebug & 0x0004) {
1325 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1327 j->flags.cidring = 1;
1328 j->cadence_f[5].state = 0;
1329 break;
1331 if (j->flags.cidring && !j->flags.cidsent) {
1332 j->flags.cidsent = 1;
1333 if(j->fskdcnt) {
1334 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
1335 ixj_pre_cid(j);
1337 j->flags.cidring = 0;
1339 clear_bit(board, &j->busyflags);
1340 ixj_add_timer(j);
1341 return;
1342 } else {
1343 if (time_after(jiffies, j->ring_cadence_jif + (hertz / 2))) {
1344 if (j->flags.cidring && !j->flags.cidsent) {
1345 j->flags.cidsent = 1;
1346 if(j->fskdcnt) {
1347 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
1348 ixj_pre_cid(j);
1350 j->flags.cidring = 0;
1352 j->ring_cadence_t--;
1353 if (j->ring_cadence_t == -1)
1354 j->ring_cadence_t = 15;
1355 j->ring_cadence_jif = jiffies;
1357 if (j->ring_cadence & 1 << j->ring_cadence_t) {
1358 if(j->flags.cidsent && j->cadence_f[5].en_filter)
1359 j->flags.firstring = 1;
1360 else
1361 ixj_ring_on(j);
1362 } else {
1363 ixj_ring_off(j);
1364 if(!j->flags.cidsent)
1365 j->flags.cidring = 1;
1368 clear_bit(board, &j->busyflags);
1369 ixj_add_timer(j);
1370 return;
1373 if (!j->flags.ringing) {
1374 if (j->hookstate) { /* & 1) { */
1375 if (j->dsp.low != 0x20 &&
1376 SLIC_GetState(j) != PLD_SLIC_STATE_ACTIVE) {
1377 SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
1379 LineMonitor(j);
1380 read_filters(j);
1381 ixj_WriteDSPCommand(0x511B, j);
1382 j->proc_load = j->ssr.high << 8 | j->ssr.low;
1383 if (!j->m_hook && (j->hookstate & 1)) {
1384 j->m_hook = j->ex.bits.hookstate = 1;
1385 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1387 } else {
1388 if (j->ex.bits.dtmf_ready) {
1389 j->dtmf_wp = j->dtmf_rp = j->ex.bits.dtmf_ready = 0;
1391 if (j->m_hook) {
1392 j->m_hook = 0;
1393 j->ex.bits.hookstate = 1;
1394 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1398 if (j->cardtype == QTI_LINEJACK && !j->flags.pstncheck && j->flags.pstn_present) {
1399 ixj_pstn_state(j);
1401 if (j->ex.bytes) {
1402 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
1404 clear_bit(board, &j->busyflags);
1406 ixj_add_timer(j);
1409 static int ixj_status_wait(IXJ *j)
1411 unsigned long jif;
1413 jif = jiffies + ((60 * hertz) / 100);
1414 while (!IsStatusReady(j)) {
1415 ixj_perfmon(j->statuswait);
1416 if (time_after(jiffies, jif)) {
1417 ixj_perfmon(j->statuswaitfail);
1418 return -1;
1421 return 0;
1424 static int ixj_PCcontrol_wait(IXJ *j)
1426 unsigned long jif;
1428 jif = jiffies + ((60 * hertz) / 100);
1429 while (!IsPCControlReady(j)) {
1430 ixj_perfmon(j->pcontrolwait);
1431 if (time_after(jiffies, jif)) {
1432 ixj_perfmon(j->pcontrolwaitfail);
1433 return -1;
1436 return 0;
1439 static int ixj_WriteDSPCommand(unsigned short cmd, IXJ *j)
1441 BYTES bytes;
1442 unsigned long jif;
1444 atomic_inc(&j->DSPWrite);
1445 if(atomic_read(&j->DSPWrite) > 1) {
1446 printk("IXJ %d DSP write overlap attempting command 0x%4.4x\n", j->board, cmd);
1447 return -1;
1449 bytes.high = (cmd & 0xFF00) >> 8;
1450 bytes.low = cmd & 0x00FF;
1451 jif = jiffies + ((60 * hertz) / 100);
1452 while (!IsControlReady(j)) {
1453 ixj_perfmon(j->iscontrolready);
1454 if (time_after(jiffies, jif)) {
1455 ixj_perfmon(j->iscontrolreadyfail);
1456 atomic_dec(&j->DSPWrite);
1457 if(atomic_read(&j->DSPWrite) > 0) {
1458 printk("IXJ %d DSP overlaped command 0x%4.4x during control ready failure.\n", j->board, cmd);
1459 while(atomic_read(&j->DSPWrite) > 0) {
1460 atomic_dec(&j->DSPWrite);
1463 return -1;
1466 outb(bytes.low, j->DSPbase + 6);
1467 outb(bytes.high, j->DSPbase + 7);
1469 if (ixj_status_wait(j)) {
1470 j->ssr.low = 0xFF;
1471 j->ssr.high = 0xFF;
1472 atomic_dec(&j->DSPWrite);
1473 if(atomic_read(&j->DSPWrite) > 0) {
1474 printk("IXJ %d DSP overlaped command 0x%4.4x during status wait failure.\n", j->board, cmd);
1475 while(atomic_read(&j->DSPWrite) > 0) {
1476 atomic_dec(&j->DSPWrite);
1479 return -1;
1481 /* Read Software Status Register */
1482 j->ssr.low = inb_p(j->DSPbase + 2);
1483 j->ssr.high = inb_p(j->DSPbase + 3);
1484 atomic_dec(&j->DSPWrite);
1485 if(atomic_read(&j->DSPWrite) > 0) {
1486 printk("IXJ %d DSP overlaped command 0x%4.4x\n", j->board, cmd);
1487 while(atomic_read(&j->DSPWrite) > 0) {
1488 atomic_dec(&j->DSPWrite);
1491 return 0;
1494 /***************************************************************************
1496 * General Purpose IO Register read routine
1498 ***************************************************************************/
1499 static inline int ixj_gpio_read(IXJ *j)
1501 if (ixj_WriteDSPCommand(0x5143, j))
1502 return -1;
1504 j->gpio.bytes.low = j->ssr.low;
1505 j->gpio.bytes.high = j->ssr.high;
1507 return 0;
1510 static inline void LED_SetState(int state, IXJ *j)
1512 if (j->cardtype == QTI_LINEJACK) {
1513 j->pld_scrw.bits.led1 = state & 0x1 ? 1 : 0;
1514 j->pld_scrw.bits.led2 = state & 0x2 ? 1 : 0;
1515 j->pld_scrw.bits.led3 = state & 0x4 ? 1 : 0;
1516 j->pld_scrw.bits.led4 = state & 0x8 ? 1 : 0;
1518 outb(j->pld_scrw.byte, j->XILINXbase);
1522 /*********************************************************************
1523 * GPIO Pins are configured as follows on the Quicknet Internet
1524 * PhoneJACK Telephony Cards
1526 * POTS Select GPIO_6=0 GPIO_7=0
1527 * Mic/Speaker Select GPIO_6=0 GPIO_7=1
1528 * Handset Select GPIO_6=1 GPIO_7=0
1530 * SLIC Active GPIO_1=0 GPIO_2=1 GPIO_5=0
1531 * SLIC Ringing GPIO_1=1 GPIO_2=1 GPIO_5=0
1532 * SLIC Open Circuit GPIO_1=0 GPIO_2=0 GPIO_5=0
1534 * Hook Switch changes reported on GPIO_3
1535 *********************************************************************/
1536 static int ixj_set_port(IXJ *j, int arg)
1538 if (j->cardtype == QTI_PHONEJACK_LITE) {
1539 if (arg != PORT_POTS)
1540 return 10;
1541 else
1542 return 0;
1544 switch (arg) {
1545 case PORT_POTS:
1546 j->port = PORT_POTS;
1547 switch (j->cardtype) {
1548 case QTI_PHONECARD:
1549 if (j->flags.pcmciasct == 1)
1550 SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
1551 else
1552 return 11;
1553 break;
1554 case QTI_PHONEJACK_PCI:
1555 j->pld_slicw.pcib.mic = 0;
1556 j->pld_slicw.pcib.spk = 0;
1557 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1558 break;
1559 case QTI_LINEJACK:
1560 ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
1561 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
1562 Software Control Register */
1563 return 2;
1564 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
1566 outb(j->pld_scrw.byte, j->XILINXbase);
1567 j->pld_clock.byte = 0;
1568 outb(j->pld_clock.byte, j->XILINXbase + 0x04);
1569 j->pld_slicw.bits.rly1 = 1;
1570 j->pld_slicw.bits.spken = 0;
1571 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1572 ixj_mixer(0x1200, j); /* Turn Off MIC switch on mixer left */
1573 ixj_mixer(0x1401, j); /* Turn On Mono1 switch on mixer left */
1574 ixj_mixer(0x1300, j); /* Turn Off MIC switch on mixer right */
1575 ixj_mixer(0x1501, j); /* Turn On Mono1 switch on mixer right */
1576 ixj_mixer(0x0E80, j); /*Mic mute */
1577 ixj_mixer(0x0F00, j); /* Set mono out (SLIC) to 0dB */
1578 ixj_mixer(0x0080, j); /* Mute Master Left volume */
1579 ixj_mixer(0x0180, j); /* Mute Master Right volume */
1580 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
1581 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
1582 break;
1583 case QTI_PHONEJACK:
1584 j->gpio.bytes.high = 0x0B;
1585 j->gpio.bits.gpio6 = 0;
1586 j->gpio.bits.gpio7 = 0;
1587 ixj_WriteDSPCommand(j->gpio.word, j);
1588 break;
1590 break;
1591 case PORT_PSTN:
1592 if (j->cardtype == QTI_LINEJACK) {
1593 ixj_WriteDSPCommand(0xC534, j); /* Write CODEC config to Software Control Register */
1595 j->pld_slicw.bits.rly3 = 0;
1596 j->pld_slicw.bits.rly1 = 1;
1597 j->pld_slicw.bits.spken = 0;
1598 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1599 j->port = PORT_PSTN;
1600 } else {
1601 return 4;
1603 break;
1604 case PORT_SPEAKER:
1605 j->port = PORT_SPEAKER;
1606 switch (j->cardtype) {
1607 case QTI_PHONECARD:
1608 if (j->flags.pcmciasct) {
1609 SLIC_SetState(PLD_SLIC_STATE_OC, j);
1611 break;
1612 case QTI_PHONEJACK_PCI:
1613 j->pld_slicw.pcib.mic = 1;
1614 j->pld_slicw.pcib.spk = 1;
1615 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1616 break;
1617 case QTI_LINEJACK:
1618 ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
1619 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
1620 Software Control Register */
1621 return 2;
1622 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
1624 outb(j->pld_scrw.byte, j->XILINXbase);
1625 j->pld_clock.byte = 0;
1626 outb(j->pld_clock.byte, j->XILINXbase + 0x04);
1627 j->pld_slicw.bits.rly1 = 1;
1628 j->pld_slicw.bits.spken = 1;
1629 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1630 ixj_mixer(0x1201, j); /* Turn On MIC switch on mixer left */
1631 ixj_mixer(0x1400, j); /* Turn Off Mono1 switch on mixer left */
1632 ixj_mixer(0x1301, j); /* Turn On MIC switch on mixer right */
1633 ixj_mixer(0x1500, j); /* Turn Off Mono1 switch on mixer right */
1634 ixj_mixer(0x0E06, j); /*Mic un-mute 0dB */
1635 ixj_mixer(0x0F80, j); /* Mute mono out (SLIC) */
1636 ixj_mixer(0x0000, j); /* Set Master Left volume to 0dB */
1637 ixj_mixer(0x0100, j); /* Set Master Right volume to 0dB */
1638 break;
1639 case QTI_PHONEJACK:
1640 j->gpio.bytes.high = 0x0B;
1641 j->gpio.bits.gpio6 = 0;
1642 j->gpio.bits.gpio7 = 1;
1643 ixj_WriteDSPCommand(j->gpio.word, j);
1644 break;
1646 break;
1647 case PORT_HANDSET:
1648 if (j->cardtype != QTI_PHONEJACK) {
1649 return 5;
1650 } else {
1651 j->gpio.bytes.high = 0x0B;
1652 j->gpio.bits.gpio6 = 1;
1653 j->gpio.bits.gpio7 = 0;
1654 ixj_WriteDSPCommand(j->gpio.word, j);
1655 j->port = PORT_HANDSET;
1657 break;
1658 default:
1659 return 6;
1660 break;
1662 return 0;
1665 static int ixj_set_pots(IXJ *j, int arg)
1667 if (j->cardtype == QTI_LINEJACK) {
1668 if (arg) {
1669 if (j->port == PORT_PSTN) {
1670 j->pld_slicw.bits.rly1 = 0;
1671 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1672 j->flags.pots_pstn = 1;
1673 return 1;
1674 } else {
1675 j->flags.pots_pstn = 0;
1676 return 0;
1678 } else {
1679 j->pld_slicw.bits.rly1 = 1;
1680 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1681 j->flags.pots_pstn = 0;
1682 return 1;
1684 } else {
1685 return 0;
1689 static void ixj_ring_on(IXJ *j)
1691 if (j->dsp.low == 0x20) /* Internet PhoneJACK */
1693 if (ixjdebug & 0x0004)
1694 printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
1696 j->gpio.bytes.high = 0x0B;
1697 j->gpio.bytes.low = 0x00;
1698 j->gpio.bits.gpio1 = 1;
1699 j->gpio.bits.gpio2 = 1;
1700 j->gpio.bits.gpio5 = 0;
1701 ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring signal */
1702 } else /* Internet LineJACK, Internet PhoneJACK Lite or Internet PhoneJACK PCI */
1704 if (ixjdebug & 0x0004)
1705 printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
1707 SLIC_SetState(PLD_SLIC_STATE_RINGING, j);
1711 static int ixj_siadc(IXJ *j, int val)
1713 if(j->cardtype == QTI_PHONECARD){
1714 if(j->flags.pcmciascp){
1715 if(val == -1)
1716 return j->siadc.bits.rxg;
1718 if(val < 0 || val > 0x1F)
1719 return -1;
1721 j->siadc.bits.hom = 0; /* Handset Out Mute */
1722 j->siadc.bits.lom = 0; /* Line Out Mute */
1723 j->siadc.bits.rxg = val; /*(0xC000 - 0x41C8) / 0x4EF; RX PGA Gain */
1724 j->psccr.bits.addr = 6; /* R/W Smart Cable Register Address */
1725 j->psccr.bits.rw = 0; /* Read / Write flag */
1726 j->psccr.bits.dev = 0;
1727 outb(j->siadc.byte, j->XILINXbase + 0x00);
1728 outb(j->psccr.byte, j->XILINXbase + 0x01);
1729 ixj_PCcontrol_wait(j);
1730 return j->siadc.bits.rxg;
1733 return -1;
1736 static int ixj_sidac(IXJ *j, int val)
1738 if(j->cardtype == QTI_PHONECARD){
1739 if(j->flags.pcmciascp){
1740 if(val == -1)
1741 return j->sidac.bits.txg;
1743 if(val < 0 || val > 0x1F)
1744 return -1;
1746 j->sidac.bits.srm = 1; /* Speaker Right Mute */
1747 j->sidac.bits.slm = 1; /* Speaker Left Mute */
1748 j->sidac.bits.txg = val; /* (0xC000 - 0x45E4) / 0x5D3; TX PGA Gain */
1749 j->psccr.bits.addr = 7; /* R/W Smart Cable Register Address */
1750 j->psccr.bits.rw = 0; /* Read / Write flag */
1751 j->psccr.bits.dev = 0;
1752 outb(j->sidac.byte, j->XILINXbase + 0x00);
1753 outb(j->psccr.byte, j->XILINXbase + 0x01);
1754 ixj_PCcontrol_wait(j);
1755 return j->sidac.bits.txg;
1758 return -1;
1761 static int ixj_pcmcia_cable_check(IXJ *j)
1763 j->pccr1.byte = inb_p(j->XILINXbase + 0x03);
1764 if (!j->flags.pcmciastate) {
1765 j->pccr2.byte = inb_p(j->XILINXbase + 0x02);
1766 if (j->pccr1.bits.drf || j->pccr2.bits.rstc) {
1767 j->flags.pcmciastate = 4;
1768 return 0;
1770 if (j->pccr1.bits.ed) {
1771 j->pccr1.bits.ed = 0;
1772 j->psccr.bits.dev = 3;
1773 j->psccr.bits.rw = 1;
1774 outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
1775 ixj_PCcontrol_wait(j);
1776 j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
1777 j->pslic.bits.led2 = j->pslic.bits.det ? 1 : 0;
1778 j->psccr.bits.dev = 3;
1779 j->psccr.bits.rw = 0;
1780 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
1781 ixj_PCcontrol_wait(j);
1782 return j->pslic.bits.led2 ? 1 : 0;
1783 } else if (j->flags.pcmciasct) {
1784 return j->r_hook;
1785 } else {
1786 return 1;
1788 } else if (j->flags.pcmciastate == 4) {
1789 if (!j->pccr1.bits.drf) {
1790 j->flags.pcmciastate = 3;
1792 return 0;
1793 } else if (j->flags.pcmciastate == 3) {
1794 j->pccr2.bits.pwr = 0;
1795 j->pccr2.bits.rstc = 1;
1796 outb(j->pccr2.byte, j->XILINXbase + 0x02);
1797 j->checkwait = jiffies + (hertz * 2);
1798 j->flags.incheck = 1;
1799 j->flags.pcmciastate = 2;
1800 return 0;
1801 } else if (j->flags.pcmciastate == 2) {
1802 if (j->flags.incheck) {
1803 if (time_before(jiffies, j->checkwait)) {
1804 return 0;
1805 } else {
1806 j->flags.incheck = 0;
1809 j->pccr2.bits.pwr = 0;
1810 j->pccr2.bits.rstc = 0;
1811 outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
1812 j->flags.pcmciastate = 1;
1813 return 0;
1814 } else if (j->flags.pcmciastate == 1) {
1815 j->flags.pcmciastate = 0;
1816 if (!j->pccr1.bits.drf) {
1817 j->psccr.bits.dev = 3;
1818 j->psccr.bits.rw = 1;
1819 outb_p(j->psccr.byte, j->XILINXbase + 0x01);
1820 ixj_PCcontrol_wait(j);
1821 j->flags.pcmciascp = 1; /* Set Cable Present Flag */
1823 j->flags.pcmciasct = (inw_p(j->XILINXbase + 0x00) >> 8) & 0x03; /* Get Cable Type */
1825 if (j->flags.pcmciasct == 3) {
1826 j->flags.pcmciastate = 4;
1827 return 0;
1828 } else if (j->flags.pcmciasct == 0) {
1829 j->pccr2.bits.pwr = 1;
1830 j->pccr2.bits.rstc = 0;
1831 outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
1832 j->port = PORT_SPEAKER;
1833 } else {
1834 j->port = PORT_POTS;
1836 j->sic1.bits.cpd = 0; /* Chip Power Down */
1837 j->sic1.bits.mpd = 0; /* MIC Bias Power Down */
1838 j->sic1.bits.hpd = 0; /* Handset Bias Power Down */
1839 j->sic1.bits.lpd = 0; /* Line Bias Power Down */
1840 j->sic1.bits.spd = 1; /* Speaker Drive Power Down */
1841 j->psccr.bits.addr = 1; /* R/W Smart Cable Register Address */
1842 j->psccr.bits.rw = 0; /* Read / Write flag */
1843 j->psccr.bits.dev = 0;
1844 outb(j->sic1.byte, j->XILINXbase + 0x00);
1845 outb(j->psccr.byte, j->XILINXbase + 0x01);
1846 ixj_PCcontrol_wait(j);
1848 j->sic2.bits.al = 0; /* Analog Loopback DAC analog -> ADC analog */
1849 j->sic2.bits.dl2 = 0; /* Digital Loopback DAC -> ADC one bit */
1850 j->sic2.bits.dl1 = 0; /* Digital Loopback ADC -> DAC one bit */
1851 j->sic2.bits.pll = 0; /* 1 = div 10, 0 = div 5 */
1852 j->sic2.bits.hpd = 0; /* HPF disable */
1853 j->psccr.bits.addr = 2; /* R/W Smart Cable Register Address */
1854 j->psccr.bits.rw = 0; /* Read / Write flag */
1855 j->psccr.bits.dev = 0;
1856 outb(j->sic2.byte, j->XILINXbase + 0x00);
1857 outb(j->psccr.byte, j->XILINXbase + 0x01);
1858 ixj_PCcontrol_wait(j);
1860 j->psccr.bits.addr = 3; /* R/W Smart Cable Register Address */
1861 j->psccr.bits.rw = 0; /* Read / Write flag */
1862 j->psccr.bits.dev = 0;
1863 outb(0x00, j->XILINXbase + 0x00); /* PLL Divide N1 */
1864 outb(j->psccr.byte, j->XILINXbase + 0x01);
1865 ixj_PCcontrol_wait(j);
1867 j->psccr.bits.addr = 4; /* R/W Smart Cable Register Address */
1868 j->psccr.bits.rw = 0; /* Read / Write flag */
1869 j->psccr.bits.dev = 0;
1870 outb(0x09, j->XILINXbase + 0x00); /* PLL Multiply M1 */
1871 outb(j->psccr.byte, j->XILINXbase + 0x01);
1872 ixj_PCcontrol_wait(j);
1874 j->sirxg.bits.lig = 1; /* Line In Gain */
1875 j->sirxg.bits.lim = 1; /* Line In Mute */
1876 j->sirxg.bits.mcg = 0; /* MIC In Gain was 3 */
1877 j->sirxg.bits.mcm = 0; /* MIC In Mute */
1878 j->sirxg.bits.him = 0; /* Handset In Mute */
1879 j->sirxg.bits.iir = 1; /* IIR */
1880 j->psccr.bits.addr = 5; /* R/W Smart Cable Register Address */
1881 j->psccr.bits.rw = 0; /* Read / Write flag */
1882 j->psccr.bits.dev = 0;
1883 outb(j->sirxg.byte, j->XILINXbase + 0x00);
1884 outb(j->psccr.byte, j->XILINXbase + 0x01);
1885 ixj_PCcontrol_wait(j);
1887 ixj_siadc(j, 0x17);
1888 ixj_sidac(j, 0x1D);
1890 j->siaatt.bits.sot = 0;
1891 j->psccr.bits.addr = 9; /* R/W Smart Cable Register Address */
1892 j->psccr.bits.rw = 0; /* Read / Write flag */
1893 j->psccr.bits.dev = 0;
1894 outb(j->siaatt.byte, j->XILINXbase + 0x00);
1895 outb(j->psccr.byte, j->XILINXbase + 0x01);
1896 ixj_PCcontrol_wait(j);
1898 if (j->flags.pcmciasct == 1 && !j->readers && !j->writers) {
1899 j->psccr.byte = j->pslic.byte = 0;
1900 j->pslic.bits.powerdown = 1;
1901 j->psccr.bits.dev = 3;
1902 j->psccr.bits.rw = 0;
1903 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
1904 ixj_PCcontrol_wait(j);
1907 return 0;
1908 } else {
1909 j->flags.pcmciascp = 0;
1910 return 0;
1912 return 0;
1915 static int ixj_hookstate(IXJ *j)
1917 unsigned long det;
1918 int fOffHook = 0;
1920 switch (j->cardtype) {
1921 case QTI_PHONEJACK:
1922 ixj_gpio_read(j);
1923 fOffHook = j->gpio.bits.gpio3read ? 1 : 0;
1924 break;
1925 case QTI_LINEJACK:
1926 case QTI_PHONEJACK_LITE:
1927 case QTI_PHONEJACK_PCI:
1928 SLIC_GetState(j);
1929 if(j->cardtype == QTI_LINEJACK && j->flags.pots_pstn == 1 && (j->readers || j->writers)) {
1930 fOffHook = j->pld_slicr.bits.potspstn ? 1 : 0;
1931 if(fOffHook != j->p_hook) {
1932 if(!j->checkwait) {
1933 j->checkwait = jiffies;
1935 if(time_before(jiffies, j->checkwait + 2)) {
1936 fOffHook ^= 1;
1937 } else {
1938 j->checkwait = 0;
1940 j->p_hook = fOffHook;
1941 printk("IXJ : /dev/phone%d pots-pstn hookstate check %d at %ld\n", j->board, fOffHook, jiffies);
1943 } else {
1944 if (j->pld_slicr.bits.state == PLD_SLIC_STATE_ACTIVE ||
1945 j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) {
1946 if (j->flags.ringing || j->flags.cringing) {
1947 if (!in_interrupt()) {
1948 det = jiffies + (hertz / 50);
1949 while (time_before(jiffies, det)) {
1950 set_current_state(TASK_INTERRUPTIBLE);
1951 schedule_timeout(1);
1954 SLIC_GetState(j);
1955 if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) {
1956 ixj_ring_on(j);
1959 if (j->cardtype == QTI_PHONEJACK_PCI) {
1960 j->pld_scrr.byte = inb_p(j->XILINXbase);
1961 fOffHook = j->pld_scrr.pcib.det ? 1 : 0;
1962 } else
1963 fOffHook = j->pld_slicr.bits.det ? 1 : 0;
1966 break;
1967 case QTI_PHONECARD:
1968 fOffHook = ixj_pcmcia_cable_check(j);
1969 break;
1971 if (j->r_hook != fOffHook) {
1972 j->r_hook = fOffHook;
1973 if (j->port == PORT_SPEAKER || j->port == PORT_HANDSET) { // || (j->port == PORT_PSTN && j->flags.pots_pstn == 0)) {
1974 j->ex.bits.hookstate = 1;
1975 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1976 } else if (!fOffHook) {
1977 j->flash_end = jiffies + ((60 * hertz) / 100);
1980 if (fOffHook) {
1981 if(time_before(jiffies, j->flash_end)) {
1982 j->ex.bits.flash = 1;
1983 j->flash_end = 0;
1984 ixj_kill_fasync(j, SIG_FLASH, POLL_IN);
1986 } else {
1987 if(time_before(jiffies, j->flash_end)) {
1988 fOffHook = 1;
1992 if (j->port == PORT_PSTN && j->daa_mode == SOP_PU_CONVERSATION)
1993 fOffHook |= 2;
1995 if (j->port == PORT_SPEAKER) {
1996 if(j->cardtype == QTI_PHONECARD) {
1997 if(j->flags.pcmciascp && j->flags.pcmciasct) {
1998 fOffHook |= 2;
2000 } else {
2001 fOffHook |= 2;
2005 if (j->port == PORT_HANDSET)
2006 fOffHook |= 2;
2008 return fOffHook;
2011 static void ixj_ring_off(IXJ *j)
2013 if (j->dsp.low == 0x20) /* Internet PhoneJACK */
2015 if (ixjdebug & 0x0004)
2016 printk(KERN_INFO "IXJ Ring Off\n");
2017 j->gpio.bytes.high = 0x0B;
2018 j->gpio.bytes.low = 0x00;
2019 j->gpio.bits.gpio1 = 0;
2020 j->gpio.bits.gpio2 = 1;
2021 j->gpio.bits.gpio5 = 0;
2022 ixj_WriteDSPCommand(j->gpio.word, j);
2023 } else /* Internet LineJACK */
2025 if (ixjdebug & 0x0004)
2026 printk(KERN_INFO "IXJ Ring Off\n");
2028 if(!j->flags.cidplay)
2029 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
2031 SLIC_GetState(j);
2035 static void ixj_ring_start(IXJ *j)
2037 j->flags.cringing = 1;
2038 if (ixjdebug & 0x0004)
2039 printk(KERN_INFO "IXJ Cadence Ringing Start /dev/phone%d\n", j->board);
2040 if (ixj_hookstate(j) & 1) {
2041 if (j->port == PORT_POTS)
2042 ixj_ring_off(j);
2043 j->flags.cringing = 0;
2044 if (ixjdebug & 0x0004)
2045 printk(KERN_INFO "IXJ Cadence Ringing Stopped /dev/phone%d off hook\n", j->board);
2046 } else if(j->cadence_f[5].enable && (!j->cadence_f[5].en_filter)) {
2047 j->ring_cadence_jif = jiffies;
2048 j->flags.cidsent = j->flags.cidring = 0;
2049 j->cadence_f[5].state = 0;
2050 if(j->cadence_f[5].on1)
2051 ixj_ring_on(j);
2052 } else {
2053 j->ring_cadence_jif = jiffies;
2054 j->ring_cadence_t = 15;
2055 if (j->ring_cadence & 1 << j->ring_cadence_t) {
2056 ixj_ring_on(j);
2057 } else {
2058 ixj_ring_off(j);
2060 j->flags.cidsent = j->flags.cidring = j->flags.firstring = 0;
2064 static int ixj_ring(IXJ *j)
2066 char cntr;
2067 unsigned long jif, det;
2069 j->flags.ringing = 1;
2070 if (ixj_hookstate(j) & 1) {
2071 ixj_ring_off(j);
2072 j->flags.ringing = 0;
2073 return 1;
2075 det = 0;
2076 for (cntr = 0; cntr < j->maxrings; cntr++) {
2077 jif = jiffies + (1 * hertz);
2078 ixj_ring_on(j);
2079 while (time_before(jiffies, jif)) {
2080 if (ixj_hookstate(j) & 1) {
2081 ixj_ring_off(j);
2082 j->flags.ringing = 0;
2083 return 1;
2085 set_current_state(TASK_INTERRUPTIBLE);
2086 schedule_timeout(1);
2087 if (signal_pending(current))
2088 break;
2090 jif = jiffies + (3 * hertz);
2091 ixj_ring_off(j);
2092 while (time_before(jiffies, jif)) {
2093 if (ixj_hookstate(j) & 1) {
2094 det = jiffies + (hertz / 100);
2095 while (time_before(jiffies, det)) {
2096 set_current_state(TASK_INTERRUPTIBLE);
2097 schedule_timeout(1);
2098 if (signal_pending(current))
2099 break;
2101 if (ixj_hookstate(j) & 1) {
2102 j->flags.ringing = 0;
2103 return 1;
2106 set_current_state(TASK_INTERRUPTIBLE);
2107 schedule_timeout(1);
2108 if (signal_pending(current))
2109 break;
2112 ixj_ring_off(j);
2113 j->flags.ringing = 0;
2114 return 0;
2117 static int ixj_open(struct phone_device *p, struct file *file_p)
2119 IXJ *j = get_ixj(p->board);
2120 file_p->private_data = j;
2122 if (!j->DSPbase)
2123 return -ENODEV;
2125 if (file_p->f_mode & FMODE_READ) {
2126 if(!j->readers) {
2127 j->readers++;
2128 } else {
2129 return -EBUSY;
2133 if (file_p->f_mode & FMODE_WRITE) {
2134 if(!j->writers) {
2135 j->writers++;
2136 } else {
2137 if (file_p->f_mode & FMODE_READ){
2138 j->readers--;
2140 return -EBUSY;
2144 if (j->cardtype == QTI_PHONECARD) {
2145 j->pslic.bits.powerdown = 0;
2146 j->psccr.bits.dev = 3;
2147 j->psccr.bits.rw = 0;
2148 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
2149 ixj_PCcontrol_wait(j);
2152 j->flags.cidplay = 0;
2153 j->flags.cidcw_ack = 0;
2155 if (ixjdebug & 0x0002)
2156 printk(KERN_INFO "Opening board %d\n", p->board);
2158 j->framesread = j->frameswritten = 0;
2159 return 0;
2162 static int ixj_release(struct inode *inode, struct file *file_p)
2164 IXJ_TONE ti;
2165 int cnt;
2166 IXJ *j = file_p->private_data;
2167 int board = j->p.board;
2170 * Set up locks to ensure that only one process is talking to the DSP at a time.
2171 * This is necessary to keep the DSP from locking up.
2173 while(test_and_set_bit(board, (void *)&j->busyflags) != 0) {
2174 set_current_state(TASK_INTERRUPTIBLE);
2175 schedule_timeout(1);
2177 if (ixjdebug & 0x0002)
2178 printk(KERN_INFO "Closing board %d\n", NUM(inode));
2180 if (j->cardtype == QTI_PHONECARD)
2181 ixj_set_port(j, PORT_SPEAKER);
2182 else
2183 ixj_set_port(j, PORT_POTS);
2185 aec_stop(j);
2186 ixj_play_stop(j);
2187 ixj_record_stop(j);
2188 set_play_volume(j, 0x100);
2189 set_rec_volume(j, 0x100);
2190 ixj_ring_off(j);
2192 /* Restore the tone table to default settings. */
2193 ti.tone_index = 10;
2194 ti.gain0 = 1;
2195 ti.freq0 = hz941;
2196 ti.gain1 = 0;
2197 ti.freq1 = hz1209;
2198 ixj_init_tone(j, &ti);
2199 ti.tone_index = 11;
2200 ti.gain0 = 1;
2201 ti.freq0 = hz941;
2202 ti.gain1 = 0;
2203 ti.freq1 = hz1336;
2204 ixj_init_tone(j, &ti);
2205 ti.tone_index = 12;
2206 ti.gain0 = 1;
2207 ti.freq0 = hz941;
2208 ti.gain1 = 0;
2209 ti.freq1 = hz1477;
2210 ixj_init_tone(j, &ti);
2211 ti.tone_index = 13;
2212 ti.gain0 = 1;
2213 ti.freq0 = hz800;
2214 ti.gain1 = 0;
2215 ti.freq1 = 0;
2216 ixj_init_tone(j, &ti);
2217 ti.tone_index = 14;
2218 ti.gain0 = 1;
2219 ti.freq0 = hz1000;
2220 ti.gain1 = 0;
2221 ti.freq1 = 0;
2222 ixj_init_tone(j, &ti);
2223 ti.tone_index = 15;
2224 ti.gain0 = 1;
2225 ti.freq0 = hz1250;
2226 ti.gain1 = 0;
2227 ti.freq1 = 0;
2228 ixj_init_tone(j, &ti);
2229 ti.tone_index = 16;
2230 ti.gain0 = 1;
2231 ti.freq0 = hz950;
2232 ti.gain1 = 0;
2233 ti.freq1 = 0;
2234 ixj_init_tone(j, &ti);
2235 ti.tone_index = 17;
2236 ti.gain0 = 1;
2237 ti.freq0 = hz1100;
2238 ti.gain1 = 0;
2239 ti.freq1 = 0;
2240 ixj_init_tone(j, &ti);
2241 ti.tone_index = 18;
2242 ti.gain0 = 1;
2243 ti.freq0 = hz1400;
2244 ti.gain1 = 0;
2245 ti.freq1 = 0;
2246 ixj_init_tone(j, &ti);
2247 ti.tone_index = 19;
2248 ti.gain0 = 1;
2249 ti.freq0 = hz1500;
2250 ti.gain1 = 0;
2251 ti.freq1 = 0;
2252 ixj_init_tone(j, &ti);
2253 ti.tone_index = 20;
2254 ti.gain0 = 1;
2255 ti.freq0 = hz1600;
2256 ti.gain1 = 0;
2257 ti.freq1 = 0;
2258 ixj_init_tone(j, &ti);
2259 ti.tone_index = 21;
2260 ti.gain0 = 1;
2261 ti.freq0 = hz1800;
2262 ti.gain1 = 0;
2263 ti.freq1 = 0;
2264 ixj_init_tone(j, &ti);
2265 ti.tone_index = 22;
2266 ti.gain0 = 1;
2267 ti.freq0 = hz2100;
2268 ti.gain1 = 0;
2269 ti.freq1 = 0;
2270 ixj_init_tone(j, &ti);
2271 ti.tone_index = 23;
2272 ti.gain0 = 1;
2273 ti.freq0 = hz1300;
2274 ti.gain1 = 0;
2275 ti.freq1 = 0;
2276 ixj_init_tone(j, &ti);
2277 ti.tone_index = 24;
2278 ti.gain0 = 1;
2279 ti.freq0 = hz2450;
2280 ti.gain1 = 0;
2281 ti.freq1 = 0;
2282 ixj_init_tone(j, &ti);
2283 ti.tone_index = 25;
2284 ti.gain0 = 1;
2285 ti.freq0 = hz350;
2286 ti.gain1 = 0;
2287 ti.freq1 = hz440;
2288 ixj_init_tone(j, &ti);
2289 ti.tone_index = 26;
2290 ti.gain0 = 1;
2291 ti.freq0 = hz440;
2292 ti.gain1 = 0;
2293 ti.freq1 = hz480;
2294 ixj_init_tone(j, &ti);
2295 ti.tone_index = 27;
2296 ti.gain0 = 1;
2297 ti.freq0 = hz480;
2298 ti.gain1 = 0;
2299 ti.freq1 = hz620;
2300 ixj_init_tone(j, &ti);
2302 set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
2304 set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
2306 j->ex.bits.dtmf_ready = 0;
2307 j->dtmf_state = 0;
2308 j->dtmf_wp = j->dtmf_rp = 0;
2309 j->rec_mode = j->play_mode = -1;
2310 j->flags.ringing = 0;
2311 j->maxrings = MAXRINGS;
2312 j->ring_cadence = USA_RING_CADENCE;
2313 if(j->cadence_f[5].enable) {
2314 j->cadence_f[5].enable = j->cadence_f[5].en_filter = j->cadence_f[5].state = 0;
2316 j->drybuffer = 0;
2317 j->winktime = 320;
2318 j->flags.dtmf_oob = 0;
2319 for (cnt = 0; cnt < 4; cnt++)
2320 j->cadence_f[cnt].enable = 0;
2322 idle(j);
2324 if(j->cardtype == QTI_PHONECARD) {
2325 SLIC_SetState(PLD_SLIC_STATE_OC, j);
2328 if (file_p->f_mode & FMODE_READ)
2329 j->readers--;
2330 if (file_p->f_mode & FMODE_WRITE)
2331 j->writers--;
2333 if (j->read_buffer && !j->readers) {
2334 kfree(j->read_buffer);
2335 j->read_buffer = NULL;
2336 j->read_buffer_size = 0;
2338 if (j->write_buffer && !j->writers) {
2339 kfree(j->write_buffer);
2340 j->write_buffer = NULL;
2341 j->write_buffer_size = 0;
2343 j->rec_codec = j->play_codec = 0;
2344 j->rec_frame_size = j->play_frame_size = 0;
2345 j->flags.cidsent = j->flags.cidring = 0;
2346 ixj_fasync(-1, file_p, 0); /* remove from list of async notification */
2348 if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) {
2349 ixj_set_port(j, PORT_PSTN);
2350 daa_set_mode(j, SOP_PU_SLEEP);
2351 ixj_set_pots(j, 1);
2353 ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
2355 /* Set up the default signals for events */
2356 for (cnt = 0; cnt < 35; cnt++)
2357 j->ixj_signals[cnt] = SIGIO;
2359 /* Set the excetion signal enable flags */
2360 j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
2361 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 =
2362 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;
2364 file_p->private_data = NULL;
2365 clear_bit(board, &j->busyflags);
2366 return 0;
2369 static int read_filters(IXJ *j)
2371 unsigned short fc, cnt, trg;
2372 int var;
2374 trg = 0;
2375 if (ixj_WriteDSPCommand(0x5144, j)) {
2376 if(ixjdebug & 0x0001) {
2377 printk(KERN_INFO "Read Frame Counter failed!\n");
2379 return -1;
2381 fc = j->ssr.high << 8 | j->ssr.low;
2382 if (fc == j->frame_count)
2383 return 1;
2385 j->frame_count = fc;
2387 if (j->dtmf_proc)
2388 return 1;
2390 var = 10;
2392 for (cnt = 0; cnt < 4; cnt++) {
2393 if (ixj_WriteDSPCommand(0x5154 + cnt, j)) {
2394 if(ixjdebug & 0x0001) {
2395 printk(KERN_INFO "Select Filter %d failed!\n", cnt);
2397 return -1;
2399 if (ixj_WriteDSPCommand(0x515C, j)) {
2400 if(ixjdebug & 0x0001) {
2401 printk(KERN_INFO "Read Filter History %d failed!\n", cnt);
2403 return -1;
2405 j->filter_hist[cnt] = j->ssr.high << 8 | j->ssr.low;
2407 if (j->cadence_f[cnt].enable) {
2408 if (j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) {
2409 if (j->cadence_f[cnt].state == 0) {
2410 j->cadence_f[cnt].state = 1;
2411 j->cadence_f[cnt].on1min = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 - var)) / 10000));
2412 j->cadence_f[cnt].on1dot = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100)) / 10000));
2413 j->cadence_f[cnt].on1max = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 + var)) / 10000));
2414 } else if (j->cadence_f[cnt].state == 2 &&
2415 (time_after(jiffies, j->cadence_f[cnt].off1min) &&
2416 time_before(jiffies, j->cadence_f[cnt].off1max))) {
2417 if (j->cadence_f[cnt].on2) {
2418 j->cadence_f[cnt].state = 3;
2419 j->cadence_f[cnt].on2min = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 - var)) / 10000));
2420 j->cadence_f[cnt].on2dot = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100)) / 10000));
2421 j->cadence_f[cnt].on2max = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 + var)) / 10000));
2422 } else {
2423 j->cadence_f[cnt].state = 7;
2425 } else if (j->cadence_f[cnt].state == 4 &&
2426 (time_after(jiffies, j->cadence_f[cnt].off2min) &&
2427 time_before(jiffies, j->cadence_f[cnt].off2max))) {
2428 if (j->cadence_f[cnt].on3) {
2429 j->cadence_f[cnt].state = 5;
2430 j->cadence_f[cnt].on3min = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 - var)) / 10000));
2431 j->cadence_f[cnt].on3dot = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100)) / 10000));
2432 j->cadence_f[cnt].on3max = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 + var)) / 10000));
2433 } else {
2434 j->cadence_f[cnt].state = 7;
2436 } else {
2437 j->cadence_f[cnt].state = 0;
2439 } else if (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)) {
2440 if (j->cadence_f[cnt].state == 1) {
2441 if(!j->cadence_f[cnt].on1) {
2442 j->cadence_f[cnt].state = 7;
2443 } else if((time_after(jiffies, j->cadence_f[cnt].on1min) &&
2444 time_before(jiffies, j->cadence_f[cnt].on1max))) {
2445 if(j->cadence_f[cnt].off1) {
2446 j->cadence_f[cnt].state = 2;
2447 j->cadence_f[cnt].off1min = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 - var)) / 10000));
2448 j->cadence_f[cnt].off1dot = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100)) / 10000));
2449 j->cadence_f[cnt].off1max = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 + var)) / 10000));
2450 } else {
2451 j->cadence_f[cnt].state = 7;
2453 } else {
2454 j->cadence_f[cnt].state = 0;
2456 } else if (j->cadence_f[cnt].state == 3) {
2457 if((time_after(jiffies, j->cadence_f[cnt].on2min) &&
2458 time_before(jiffies, j->cadence_f[cnt].on2max))) {
2459 if(j->cadence_f[cnt].off2) {
2460 j->cadence_f[cnt].state = 4;
2461 j->cadence_f[cnt].off2min = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 - var)) / 10000));
2462 j->cadence_f[cnt].off2dot = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100)) / 10000));
2463 j->cadence_f[cnt].off2max = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 + var)) / 10000));
2464 } else {
2465 j->cadence_f[cnt].state = 7;
2467 } else {
2468 j->cadence_f[cnt].state = 0;
2470 } else if (j->cadence_f[cnt].state == 5) {
2471 if ((time_after(jiffies, j->cadence_f[cnt].on3min) &&
2472 time_before(jiffies, j->cadence_f[cnt].on3max))) {
2473 if(j->cadence_f[cnt].off3) {
2474 j->cadence_f[cnt].state = 6;
2475 j->cadence_f[cnt].off3min = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 - var)) / 10000));
2476 j->cadence_f[cnt].off3dot = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100)) / 10000));
2477 j->cadence_f[cnt].off3max = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 + var)) / 10000));
2478 } else {
2479 j->cadence_f[cnt].state = 7;
2481 } else {
2482 j->cadence_f[cnt].state = 0;
2484 } else {
2485 j->cadence_f[cnt].state = 0;
2487 } else {
2488 switch(j->cadence_f[cnt].state) {
2489 case 1:
2490 if(time_after(jiffies, j->cadence_f[cnt].on1dot) &&
2491 !j->cadence_f[cnt].off1 &&
2492 !j->cadence_f[cnt].on2 && !j->cadence_f[cnt].off2 &&
2493 !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
2494 j->cadence_f[cnt].state = 7;
2496 break;
2497 case 3:
2498 if(time_after(jiffies, j->cadence_f[cnt].on2dot) &&
2499 !j->cadence_f[cnt].off2 &&
2500 !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
2501 j->cadence_f[cnt].state = 7;
2503 break;
2504 case 5:
2505 if(time_after(jiffies, j->cadence_f[cnt].on3dot) &&
2506 !j->cadence_f[cnt].off3) {
2507 j->cadence_f[cnt].state = 7;
2509 break;
2513 if (ixjdebug & 0x0040) {
2514 printk(KERN_INFO "IXJ Tone Cadence state = %d /dev/phone%d at %ld\n", j->cadence_f[cnt].state, j->board, jiffies);
2515 switch(j->cadence_f[cnt].state) {
2516 case 0:
2517 printk(KERN_INFO "IXJ /dev/phone%d No Tone detected\n", j->board);
2518 break;
2519 case 1:
2520 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %u %ld - %ld - %ld\n", j->board,
2521 j->cadence_f[cnt].on1, j->cadence_f[cnt].on1min, j->cadence_f[cnt].on1dot, j->cadence_f[cnt].on1max);
2522 break;
2523 case 2:
2524 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off1min,
2525 j->cadence_f[cnt].off1max);
2526 break;
2527 case 3:
2528 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on2min,
2529 j->cadence_f[cnt].on2max);
2530 break;
2531 case 4:
2532 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off2min,
2533 j->cadence_f[cnt].off2max);
2534 break;
2535 case 5:
2536 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on3min,
2537 j->cadence_f[cnt].on3max);
2538 break;
2539 case 6:
2540 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off3min,
2541 j->cadence_f[cnt].off3max);
2542 break;
2546 if (j->cadence_f[cnt].state == 7) {
2547 j->cadence_f[cnt].state = 0;
2548 if (j->cadence_f[cnt].enable == 1)
2549 j->cadence_f[cnt].enable = 0;
2550 switch (cnt) {
2551 case 0:
2552 if(ixjdebug & 0x0020) {
2553 printk(KERN_INFO "Filter Cadence 0 triggered %ld\n", jiffies);
2555 j->ex.bits.fc0 = 1;
2556 ixj_kill_fasync(j, SIG_FC0, POLL_IN);
2557 break;
2558 case 1:
2559 if(ixjdebug & 0x0020) {
2560 printk(KERN_INFO "Filter Cadence 1 triggered %ld\n", jiffies);
2562 j->ex.bits.fc1 = 1;
2563 ixj_kill_fasync(j, SIG_FC1, POLL_IN);
2564 break;
2565 case 2:
2566 if(ixjdebug & 0x0020) {
2567 printk(KERN_INFO "Filter Cadence 2 triggered %ld\n", jiffies);
2569 j->ex.bits.fc2 = 1;
2570 ixj_kill_fasync(j, SIG_FC2, POLL_IN);
2571 break;
2572 case 3:
2573 if(ixjdebug & 0x0020) {
2574 printk(KERN_INFO "Filter Cadence 3 triggered %ld\n", jiffies);
2576 j->ex.bits.fc3 = 1;
2577 ixj_kill_fasync(j, SIG_FC3, POLL_IN);
2578 break;
2581 if (j->filter_en[cnt] && ((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) ||
2582 (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)))) {
2583 if((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12))) {
2584 trg = 1;
2585 } else if((j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3))) {
2586 trg = 0;
2588 switch (cnt) {
2589 case 0:
2590 if(ixjdebug & 0x0020) {
2591 printk(KERN_INFO "Filter 0 triggered %d at %ld\n", trg, jiffies);
2593 j->ex.bits.f0 = 1;
2594 ixj_kill_fasync(j, SIG_F0, POLL_IN);
2595 break;
2596 case 1:
2597 if(ixjdebug & 0x0020) {
2598 printk(KERN_INFO "Filter 1 triggered %d at %ld\n", trg, jiffies);
2600 j->ex.bits.f1 = 1;
2601 ixj_kill_fasync(j, SIG_F1, POLL_IN);
2602 break;
2603 case 2:
2604 if(ixjdebug & 0x0020) {
2605 printk(KERN_INFO "Filter 2 triggered %d at %ld\n", trg, jiffies);
2607 j->ex.bits.f2 = 1;
2608 ixj_kill_fasync(j, SIG_F2, POLL_IN);
2609 break;
2610 case 3:
2611 if(ixjdebug & 0x0020) {
2612 printk(KERN_INFO "Filter 3 triggered %d at %ld\n", trg, jiffies);
2614 j->ex.bits.f3 = 1;
2615 ixj_kill_fasync(j, SIG_F3, POLL_IN);
2616 break;
2620 return 0;
2623 static int LineMonitor(IXJ *j)
2625 if (j->dtmf_proc) {
2626 return -1;
2628 j->dtmf_proc = 1;
2630 if (ixj_WriteDSPCommand(0x7000, j)) /* Line Monitor */
2631 return -1;
2633 j->dtmf.bytes.high = j->ssr.high;
2634 j->dtmf.bytes.low = j->ssr.low;
2635 if (!j->dtmf_state && j->dtmf.bits.dtmf_valid) {
2636 j->dtmf_state = 1;
2637 j->dtmf_current = j->dtmf.bits.digit;
2639 if (j->dtmf_state && !j->dtmf.bits.dtmf_valid) /* && j->dtmf_wp != j->dtmf_rp) */
2641 if(!j->cidcw_wait) {
2642 j->dtmfbuffer[j->dtmf_wp] = j->dtmf_current;
2643 j->dtmf_wp++;
2644 if (j->dtmf_wp == 79)
2645 j->dtmf_wp = 0;
2646 j->ex.bits.dtmf_ready = 1;
2647 if(j->ex_sig.bits.dtmf_ready) {
2648 ixj_kill_fasync(j, SIG_DTMF_READY, POLL_IN);
2651 else if(j->dtmf_current == 0x00 || j->dtmf_current == 0x0D) {
2652 if(ixjdebug & 0x0020) {
2653 printk("IXJ phone%d saw CIDCW Ack DTMF %d from display at %ld\n", j->board, j->dtmf_current, jiffies);
2655 j->flags.cidcw_ack = 1;
2657 j->dtmf_state = 0;
2659 j->dtmf_proc = 0;
2661 return 0;
2664 /************************************************************************
2666 * Functions to allow alaw <-> ulaw conversions.
2668 ************************************************************************/
2670 static void ulaw2alaw(unsigned char *buff, unsigned long len)
2672 static unsigned char table_ulaw2alaw[] =
2674 0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D,
2675 0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25,
2676 0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D,
2677 0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35,
2678 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02,
2679 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A,
2680 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12,
2681 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B,
2682 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63,
2683 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79,
2684 0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71,
2685 0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D,
2686 0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45,
2687 0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D,
2688 0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51,
2689 0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5,
2690 0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD,
2691 0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5,
2692 0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD,
2693 0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5,
2694 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82,
2695 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A,
2696 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92,
2697 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB,
2698 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3,
2699 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9,
2700 0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1,
2701 0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD,
2702 0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5,
2703 0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD,
2704 0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1,
2705 0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5
2708 while (len--)
2710 *buff = table_ulaw2alaw[*(unsigned char *)buff];
2711 buff++;
2715 static void alaw2ulaw(unsigned char *buff, unsigned long len)
2717 static unsigned char table_alaw2ulaw[] =
2719 0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C,
2720 0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24,
2721 0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C,
2722 0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34,
2723 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D,
2724 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
2725 0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D,
2726 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15,
2727 0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65,
2728 0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E,
2729 0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A,
2730 0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D,
2731 0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B,
2732 0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43,
2733 0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59,
2734 0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51,
2735 0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC,
2736 0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4,
2737 0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC,
2738 0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4,
2739 0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D,
2740 0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85,
2741 0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D,
2742 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95,
2743 0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5,
2744 0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE,
2745 0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA,
2746 0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED,
2747 0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB,
2748 0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3,
2749 0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9,
2750 0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1
2753 while (len--)
2755 *buff = table_alaw2ulaw[*(unsigned char *)buff];
2756 buff++;
2760 static ssize_t ixj_read(struct file * file_p, char __user *buf, size_t length, loff_t * ppos)
2762 unsigned long i = *ppos;
2763 IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode));
2765 DECLARE_WAITQUEUE(wait, current);
2767 if (j->flags.inread)
2768 return -EALREADY;
2770 j->flags.inread = 1;
2772 add_wait_queue(&j->read_q, &wait);
2773 set_current_state(TASK_INTERRUPTIBLE);
2774 mb();
2776 while (!j->read_buffer_ready || (j->dtmf_state && j->flags.dtmf_oob)) {
2777 ++j->read_wait;
2778 if (file_p->f_flags & O_NONBLOCK) {
2779 set_current_state(TASK_RUNNING);
2780 remove_wait_queue(&j->read_q, &wait);
2781 j->flags.inread = 0;
2782 return -EAGAIN;
2784 if (!ixj_hookstate(j)) {
2785 set_current_state(TASK_RUNNING);
2786 remove_wait_queue(&j->read_q, &wait);
2787 j->flags.inread = 0;
2788 return 0;
2790 interruptible_sleep_on(&j->read_q);
2791 if (signal_pending(current)) {
2792 set_current_state(TASK_RUNNING);
2793 remove_wait_queue(&j->read_q, &wait);
2794 j->flags.inread = 0;
2795 return -EINTR;
2799 remove_wait_queue(&j->read_q, &wait);
2800 set_current_state(TASK_RUNNING);
2801 /* Don't ever copy more than the user asks */
2802 if(j->rec_codec == ALAW)
2803 ulaw2alaw(j->read_buffer, min(length, j->read_buffer_size));
2804 i = copy_to_user(buf, j->read_buffer, min(length, j->read_buffer_size));
2805 j->read_buffer_ready = 0;
2806 if (i) {
2807 j->flags.inread = 0;
2808 return -EFAULT;
2809 } else {
2810 j->flags.inread = 0;
2811 return min(length, j->read_buffer_size);
2815 static ssize_t ixj_enhanced_read(struct file * file_p, char __user *buf, size_t length,
2816 loff_t * ppos)
2818 int pre_retval;
2819 ssize_t read_retval = 0;
2820 IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
2822 pre_retval = ixj_PreRead(j, 0L);
2823 switch (pre_retval) {
2824 case NORMAL:
2825 read_retval = ixj_read(file_p, buf, length, ppos);
2826 ixj_PostRead(j, 0L);
2827 break;
2828 case NOPOST:
2829 read_retval = ixj_read(file_p, buf, length, ppos);
2830 break;
2831 case POSTONLY:
2832 ixj_PostRead(j, 0L);
2833 break;
2834 default:
2835 read_retval = pre_retval;
2837 return read_retval;
2840 static ssize_t ixj_write(struct file *file_p, const char __user *buf, size_t count, loff_t * ppos)
2842 unsigned long i = *ppos;
2843 IXJ *j = file_p->private_data;
2845 DECLARE_WAITQUEUE(wait, current);
2847 if (j->flags.inwrite)
2848 return -EALREADY;
2850 j->flags.inwrite = 1;
2852 add_wait_queue(&j->write_q, &wait);
2853 set_current_state(TASK_INTERRUPTIBLE);
2854 mb();
2857 while (!j->write_buffers_empty) {
2858 ++j->write_wait;
2859 if (file_p->f_flags & O_NONBLOCK) {
2860 set_current_state(TASK_RUNNING);
2861 remove_wait_queue(&j->write_q, &wait);
2862 j->flags.inwrite = 0;
2863 return -EAGAIN;
2865 if (!ixj_hookstate(j)) {
2866 set_current_state(TASK_RUNNING);
2867 remove_wait_queue(&j->write_q, &wait);
2868 j->flags.inwrite = 0;
2869 return 0;
2871 interruptible_sleep_on(&j->write_q);
2872 if (signal_pending(current)) {
2873 set_current_state(TASK_RUNNING);
2874 remove_wait_queue(&j->write_q, &wait);
2875 j->flags.inwrite = 0;
2876 return -EINTR;
2879 set_current_state(TASK_RUNNING);
2880 remove_wait_queue(&j->write_q, &wait);
2881 if (j->write_buffer_wp + count >= j->write_buffer_end)
2882 j->write_buffer_wp = j->write_buffer;
2883 i = copy_from_user(j->write_buffer_wp, buf, min(count, j->write_buffer_size));
2884 if (i) {
2885 j->flags.inwrite = 0;
2886 return -EFAULT;
2888 if(j->play_codec == ALAW)
2889 alaw2ulaw(j->write_buffer_wp, min(count, j->write_buffer_size));
2890 j->flags.inwrite = 0;
2891 return min(count, j->write_buffer_size);
2894 static ssize_t ixj_enhanced_write(struct file * file_p, const char __user *buf, size_t count, loff_t * ppos)
2896 int pre_retval;
2897 ssize_t write_retval = 0;
2899 IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
2901 pre_retval = ixj_PreWrite(j, 0L);
2902 switch (pre_retval) {
2903 case NORMAL:
2904 write_retval = ixj_write(file_p, buf, count, ppos);
2905 if (write_retval > 0) {
2906 ixj_PostWrite(j, 0L);
2907 j->write_buffer_wp += write_retval;
2908 j->write_buffers_empty--;
2910 break;
2911 case NOPOST:
2912 write_retval = ixj_write(file_p, buf, count, ppos);
2913 if (write_retval > 0) {
2914 j->write_buffer_wp += write_retval;
2915 j->write_buffers_empty--;
2917 break;
2918 case POSTONLY:
2919 ixj_PostWrite(j, 0L);
2920 break;
2921 default:
2922 write_retval = pre_retval;
2924 return write_retval;
2927 static void ixj_read_frame(IXJ *j)
2929 int cnt, dly;
2931 if (j->read_buffer) {
2932 for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
2933 if (!(cnt % 16) && !IsRxReady(j)) {
2934 dly = 0;
2935 while (!IsRxReady(j)) {
2936 if (dly++ > 5) {
2937 dly = 0;
2938 break;
2940 udelay(10);
2943 /* Throw away word 0 of the 8021 compressed format to get standard G.729. */
2944 if (j->rec_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
2945 inb_p(j->DSPbase + 0x0E);
2946 inb_p(j->DSPbase + 0x0F);
2948 *(j->read_buffer + cnt) = inb_p(j->DSPbase + 0x0E);
2949 *(j->read_buffer + cnt + 1) = inb_p(j->DSPbase + 0x0F);
2951 ++j->framesread;
2952 if (j->intercom != -1) {
2953 if (IsTxReady(get_ixj(j->intercom))) {
2954 for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
2955 if (!(cnt % 16) && !IsTxReady(j)) {
2956 dly = 0;
2957 while (!IsTxReady(j)) {
2958 if (dly++ > 5) {
2959 dly = 0;
2960 break;
2962 udelay(10);
2965 outb_p(*(j->read_buffer + cnt), get_ixj(j->intercom)->DSPbase + 0x0C);
2966 outb_p(*(j->read_buffer + cnt + 1), get_ixj(j->intercom)->DSPbase + 0x0D);
2968 get_ixj(j->intercom)->frameswritten++;
2970 } else {
2971 j->read_buffer_ready = 1;
2972 wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
2974 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
2976 if(j->ixj_signals[SIG_READ_READY])
2977 ixj_kill_fasync(j, SIG_READ_READY, POLL_OUT);
2982 static short fsk[][6][20] =
2986 0, 17846, 29934, 32364, 24351, 8481, -10126, -25465, -32587, -29196,
2987 -16384, 1715, 19260, 30591, 32051, 23170, 6813, -11743, -26509, -32722
2990 -28377, -14876, 3425, 20621, 31163, 31650, 21925, 5126, -13328, -27481,
2991 -32767, -27481, -13328, 5126, 21925, 31650, 31163, 20621, 3425, -14876
2994 -28377, -32722, -26509, -11743, 6813, 23170, 32051, 30591, 19260, 1715,
2995 -16384, -29196, -32587, -25465, -10126, 8481, 24351, 32364, 29934, 17846
2998 0, -17846, -29934, -32364, -24351, -8481, 10126, 25465, 32587, 29196,
2999 16384, -1715, -19260, -30591, -32051, -23170, -6813, 11743, 26509, 32722
3002 28377, 14876, -3425, -20621, -31163, -31650, -21925, -5126, 13328, 27481,
3003 32767, 27481, 13328, -5126, -21925, -31650, -31163, -20621, -3425, 14876
3006 28377, 32722, 26509, 11743, -6813, -23170, -32051, -30591, -19260, -1715,
3007 16384, 29196, 32587, 25465, 10126, -8481, -24351, -32364, -29934, -17846
3012 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126,
3013 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126
3016 -28377, -21925, -13328, -3425, 6813, 16384, 24351, 29934, 32587, 32051,
3017 28377, 21925, 13328, 3425, -6813, -16384, -24351, -29934, -32587, -32051
3020 -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925,
3021 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925
3024 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126,
3025 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126
3028 28377, 21925, 13328, 3425, -6813, -16383, -24351, -29934, -32587, -32051,
3029 -28377, -21925, -13328, -3425, 6813, 16383, 24351, 29934, 32587, 32051
3032 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925,
3033 -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925
3039 static void ixj_write_cid_bit(IXJ *j, int bit)
3041 while (j->fskcnt < 20) {
3042 if(j->fskdcnt < (j->fsksize - 1))
3043 j->fskdata[j->fskdcnt++] = fsk[bit][j->fskz][j->fskcnt];
3045 j->fskcnt += 3;
3047 j->fskcnt %= 20;
3049 if (!bit)
3050 j->fskz++;
3051 if (j->fskz >= 6)
3052 j->fskz = 0;
3056 static void ixj_write_cid_byte(IXJ *j, char byte)
3058 IXJ_CBYTE cb;
3060 cb.cbyte = byte;
3061 ixj_write_cid_bit(j, 0);
3062 ixj_write_cid_bit(j, cb.cbits.b0 ? 1 : 0);
3063 ixj_write_cid_bit(j, cb.cbits.b1 ? 1 : 0);
3064 ixj_write_cid_bit(j, cb.cbits.b2 ? 1 : 0);
3065 ixj_write_cid_bit(j, cb.cbits.b3 ? 1 : 0);
3066 ixj_write_cid_bit(j, cb.cbits.b4 ? 1 : 0);
3067 ixj_write_cid_bit(j, cb.cbits.b5 ? 1 : 0);
3068 ixj_write_cid_bit(j, cb.cbits.b6 ? 1 : 0);
3069 ixj_write_cid_bit(j, cb.cbits.b7 ? 1 : 0);
3070 ixj_write_cid_bit(j, 1);
3073 static void ixj_write_cid_seize(IXJ *j)
3075 int cnt;
3077 for (cnt = 0; cnt < 150; cnt++) {
3078 ixj_write_cid_bit(j, 0);
3079 ixj_write_cid_bit(j, 1);
3081 for (cnt = 0; cnt < 180; cnt++) {
3082 ixj_write_cid_bit(j, 1);
3086 static void ixj_write_cidcw_seize(IXJ *j)
3088 int cnt;
3090 for (cnt = 0; cnt < 80; cnt++) {
3091 ixj_write_cid_bit(j, 1);
3095 static int ixj_write_cid_string(IXJ *j, char *s, int checksum)
3097 int cnt;
3099 for (cnt = 0; cnt < strlen(s); cnt++) {
3100 ixj_write_cid_byte(j, s[cnt]);
3101 checksum = (checksum + s[cnt]);
3103 return checksum;
3106 static void ixj_pad_fsk(IXJ *j, int pad)
3108 int cnt;
3110 for (cnt = 0; cnt < pad; cnt++) {
3111 if(j->fskdcnt < (j->fsksize - 1))
3112 j->fskdata[j->fskdcnt++] = 0x0000;
3114 for (cnt = 0; cnt < 720; cnt++) {
3115 if(j->fskdcnt < (j->fsksize - 1))
3116 j->fskdata[j->fskdcnt++] = 0x0000;
3120 static void ixj_pre_cid(IXJ *j)
3122 j->cid_play_codec = j->play_codec;
3123 j->cid_play_frame_size = j->play_frame_size;
3124 j->cid_play_volume = get_play_volume(j);
3125 j->cid_play_flag = j->flags.playing;
3127 j->cid_rec_codec = j->rec_codec;
3128 j->cid_rec_volume = get_rec_volume(j);
3129 j->cid_rec_flag = j->flags.recording;
3131 j->cid_play_aec_level = j->aec_level;
3133 switch(j->baseframe.low) {
3134 case 0xA0:
3135 j->cid_base_frame_size = 20;
3136 break;
3137 case 0x50:
3138 j->cid_base_frame_size = 10;
3139 break;
3140 case 0xF0:
3141 j->cid_base_frame_size = 30;
3142 break;
3145 ixj_play_stop(j);
3146 ixj_cpt_stop(j);
3148 j->flags.cidplay = 1;
3150 set_base_frame(j, 30);
3151 set_play_codec(j, LINEAR16);
3152 set_play_volume(j, 0x1B);
3153 ixj_play_start(j);
3156 static void ixj_post_cid(IXJ *j)
3158 ixj_play_stop(j);
3160 if(j->cidsize > 5000) {
3161 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
3163 j->flags.cidplay = 0;
3164 if(ixjdebug & 0x0200) {
3165 printk("IXJ phone%d Finished Playing CallerID data %ld\n", j->board, jiffies);
3168 ixj_fsk_free(j);
3170 j->fskdcnt = 0;
3171 set_base_frame(j, j->cid_base_frame_size);
3172 set_play_codec(j, j->cid_play_codec);
3173 ixj_aec_start(j, j->cid_play_aec_level);
3174 set_play_volume(j, j->cid_play_volume);
3176 set_rec_codec(j, j->cid_rec_codec);
3177 set_rec_volume(j, j->cid_rec_volume);
3179 if(j->cid_rec_flag)
3180 ixj_record_start(j);
3182 if(j->cid_play_flag)
3183 ixj_play_start(j);
3185 if(j->cid_play_flag) {
3186 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3190 static void ixj_write_cid(IXJ *j)
3192 char sdmf1[50];
3193 char sdmf2[50];
3194 char sdmf3[80];
3195 char mdmflen, len1, len2, len3;
3196 int pad;
3198 int checksum = 0;
3200 if (j->dsp.low == 0x20 || j->flags.cidplay)
3201 return;
3203 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3204 j->cidsize = j->cidcnt = 0;
3206 ixj_fsk_alloc(j);
3208 strcpy(sdmf1, j->cid_send.month);
3209 strcat(sdmf1, j->cid_send.day);
3210 strcat(sdmf1, j->cid_send.hour);
3211 strcat(sdmf1, j->cid_send.min);
3212 strcpy(sdmf2, j->cid_send.number);
3213 strcpy(sdmf3, j->cid_send.name);
3215 len1 = strlen(sdmf1);
3216 len2 = strlen(sdmf2);
3217 len3 = strlen(sdmf3);
3218 mdmflen = len1 + len2 + len3 + 6;
3220 while(1){
3221 ixj_write_cid_seize(j);
3223 ixj_write_cid_byte(j, 0x80);
3224 checksum = 0x80;
3225 ixj_write_cid_byte(j, mdmflen);
3226 checksum = checksum + mdmflen;
3228 ixj_write_cid_byte(j, 0x01);
3229 checksum = checksum + 0x01;
3230 ixj_write_cid_byte(j, len1);
3231 checksum = checksum + len1;
3232 checksum = ixj_write_cid_string(j, sdmf1, checksum);
3233 if(ixj_hookstate(j) & 1)
3234 break;
3236 ixj_write_cid_byte(j, 0x02);
3237 checksum = checksum + 0x02;
3238 ixj_write_cid_byte(j, len2);
3239 checksum = checksum + len2;
3240 checksum = ixj_write_cid_string(j, sdmf2, checksum);
3241 if(ixj_hookstate(j) & 1)
3242 break;
3244 ixj_write_cid_byte(j, 0x07);
3245 checksum = checksum + 0x07;
3246 ixj_write_cid_byte(j, len3);
3247 checksum = checksum + len3;
3248 checksum = ixj_write_cid_string(j, sdmf3, checksum);
3249 if(ixj_hookstate(j) & 1)
3250 break;
3252 checksum %= 256;
3253 checksum ^= 0xFF;
3254 checksum += 1;
3256 ixj_write_cid_byte(j, (char) checksum);
3258 pad = j->fskdcnt % 240;
3259 if (pad) {
3260 pad = 240 - pad;
3262 ixj_pad_fsk(j, pad);
3263 break;
3266 ixj_write_frame(j);
3269 static void ixj_write_cidcw(IXJ *j)
3271 IXJ_TONE ti;
3273 char sdmf1[50];
3274 char sdmf2[50];
3275 char sdmf3[80];
3276 char mdmflen, len1, len2, len3;
3277 int pad;
3279 int checksum = 0;
3281 if (j->dsp.low == 0x20 || j->flags.cidplay)
3282 return;
3284 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3285 j->cidsize = j->cidcnt = 0;
3287 ixj_fsk_alloc(j);
3289 j->flags.cidcw_ack = 0;
3291 ti.tone_index = 23;
3292 ti.gain0 = 1;
3293 ti.freq0 = hz440;
3294 ti.gain1 = 0;
3295 ti.freq1 = 0;
3296 ixj_init_tone(j, &ti);
3298 ixj_set_tone_on(1500, j);
3299 ixj_set_tone_off(32, j);
3300 if(ixjdebug & 0x0200) {
3301 printk("IXJ cidcw phone%d first tone start at %ld\n", j->board, jiffies);
3303 ixj_play_tone(j, 23);
3305 clear_bit(j->board, &j->busyflags);
3306 while(j->tone_state) {
3307 set_current_state(TASK_INTERRUPTIBLE);
3308 schedule_timeout(1);
3310 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
3311 set_current_state(TASK_INTERRUPTIBLE);
3312 schedule_timeout(1);
3314 if(ixjdebug & 0x0200) {
3315 printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies);
3318 ti.tone_index = 24;
3319 ti.gain0 = 1;
3320 ti.freq0 = hz2130;
3321 ti.gain1 = 0;
3322 ti.freq1 = hz2750;
3323 ixj_init_tone(j, &ti);
3325 ixj_set_tone_off(10, j);
3326 ixj_set_tone_on(600, j);
3327 if(ixjdebug & 0x0200) {
3328 printk("IXJ cidcw phone%d second tone start at %ld\n", j->board, jiffies);
3330 ixj_play_tone(j, 24);
3332 clear_bit(j->board, &j->busyflags);
3333 while(j->tone_state) {
3334 set_current_state(TASK_INTERRUPTIBLE);
3335 schedule_timeout(1);
3337 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
3338 set_current_state(TASK_INTERRUPTIBLE);
3339 schedule_timeout(1);
3341 if(ixjdebug & 0x0200) {
3342 printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies);
3345 j->cidcw_wait = jiffies + ((50 * hertz) / 100);
3347 clear_bit(j->board, &j->busyflags);
3348 while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait)) {
3349 set_current_state(TASK_INTERRUPTIBLE);
3350 schedule_timeout(1);
3352 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
3353 set_current_state(TASK_INTERRUPTIBLE);
3354 schedule_timeout(1);
3356 j->cidcw_wait = 0;
3357 if(!j->flags.cidcw_ack) {
3358 if(ixjdebug & 0x0200) {
3359 printk("IXJ cidcw phone%d did not receive ACK from display %ld\n", j->board, jiffies);
3361 ixj_post_cid(j);
3362 if(j->cid_play_flag) {
3363 wake_up_interruptible(&j->write_q); /* Wake any blocked readers */
3365 return;
3366 } else {
3367 ixj_pre_cid(j);
3369 j->flags.cidcw_ack = 0;
3370 strcpy(sdmf1, j->cid_send.month);
3371 strcat(sdmf1, j->cid_send.day);
3372 strcat(sdmf1, j->cid_send.hour);
3373 strcat(sdmf1, j->cid_send.min);
3374 strcpy(sdmf2, j->cid_send.number);
3375 strcpy(sdmf3, j->cid_send.name);
3377 len1 = strlen(sdmf1);
3378 len2 = strlen(sdmf2);
3379 len3 = strlen(sdmf3);
3380 mdmflen = len1 + len2 + len3 + 6;
3382 ixj_write_cidcw_seize(j);
3384 ixj_write_cid_byte(j, 0x80);
3385 checksum = 0x80;
3386 ixj_write_cid_byte(j, mdmflen);
3387 checksum = checksum + mdmflen;
3389 ixj_write_cid_byte(j, 0x01);
3390 checksum = checksum + 0x01;
3391 ixj_write_cid_byte(j, len1);
3392 checksum = checksum + len1;
3393 checksum = ixj_write_cid_string(j, sdmf1, checksum);
3395 ixj_write_cid_byte(j, 0x02);
3396 checksum = checksum + 0x02;
3397 ixj_write_cid_byte(j, len2);
3398 checksum = checksum + len2;
3399 checksum = ixj_write_cid_string(j, sdmf2, checksum);
3401 ixj_write_cid_byte(j, 0x07);
3402 checksum = checksum + 0x07;
3403 ixj_write_cid_byte(j, len3);
3404 checksum = checksum + len3;
3405 checksum = ixj_write_cid_string(j, sdmf3, checksum);
3407 checksum %= 256;
3408 checksum ^= 0xFF;
3409 checksum += 1;
3411 ixj_write_cid_byte(j, (char) checksum);
3413 pad = j->fskdcnt % 240;
3414 if (pad) {
3415 pad = 240 - pad;
3417 ixj_pad_fsk(j, pad);
3418 if(ixjdebug & 0x0200) {
3419 printk("IXJ cidcw phone%d sent FSK data at %ld\n", j->board, jiffies);
3423 static void ixj_write_vmwi(IXJ *j, int msg)
3425 char mdmflen;
3426 int pad;
3428 int checksum = 0;
3430 if (j->dsp.low == 0x20 || j->flags.cidplay)
3431 return;
3433 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3434 j->cidsize = j->cidcnt = 0;
3436 ixj_fsk_alloc(j);
3438 mdmflen = 3;
3440 if (j->port == PORT_POTS)
3441 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
3443 ixj_write_cid_seize(j);
3445 ixj_write_cid_byte(j, 0x82);
3446 checksum = 0x82;
3447 ixj_write_cid_byte(j, mdmflen);
3448 checksum = checksum + mdmflen;
3450 ixj_write_cid_byte(j, 0x0B);
3451 checksum = checksum + 0x0B;
3452 ixj_write_cid_byte(j, 1);
3453 checksum = checksum + 1;
3455 if(msg) {
3456 ixj_write_cid_byte(j, 0xFF);
3457 checksum = checksum + 0xFF;
3459 else {
3460 ixj_write_cid_byte(j, 0x00);
3461 checksum = checksum + 0x00;
3464 checksum %= 256;
3465 checksum ^= 0xFF;
3466 checksum += 1;
3468 ixj_write_cid_byte(j, (char) checksum);
3470 pad = j->fskdcnt % 240;
3471 if (pad) {
3472 pad = 240 - pad;
3474 ixj_pad_fsk(j, pad);
3477 static void ixj_write_frame(IXJ *j)
3479 int cnt, frame_count, dly;
3480 IXJ_WORD dat;
3481 BYTES blankword;
3483 frame_count = 0;
3484 if(j->flags.cidplay) {
3485 for(cnt = 0; cnt < 480; cnt++) {
3486 if (!(cnt % 16) && !IsTxReady(j)) {
3487 dly = 0;
3488 while (!IsTxReady(j)) {
3489 if (dly++ > 5) {
3490 dly = 0;
3491 break;
3493 udelay(10);
3496 dat.word = j->fskdata[j->cidcnt++];
3497 outb_p(dat.bytes.low, j->DSPbase + 0x0C);
3498 outb_p(dat.bytes.high, j->DSPbase + 0x0D);
3499 cnt++;
3501 if(j->cidcnt >= j->fskdcnt) {
3502 ixj_post_cid(j);
3504 /* This may seem rude, but if we just played one frame of FSK data for CallerID
3505 and there is real audio data in the buffer, we need to throw it away because
3506 we just used it's time slot */
3507 if (j->write_buffer_rp > j->write_buffer_wp) {
3508 j->write_buffer_rp += j->cid_play_frame_size * 2;
3509 if (j->write_buffer_rp >= j->write_buffer_end) {
3510 j->write_buffer_rp = j->write_buffer;
3512 j->write_buffers_empty++;
3513 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3515 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
3517 } else if (j->write_buffer && j->write_buffers_empty < 1) {
3518 if (j->write_buffer_wp > j->write_buffer_rp) {
3519 frame_count =
3520 (j->write_buffer_wp - j->write_buffer_rp) / (j->play_frame_size * 2);
3522 if (j->write_buffer_rp > j->write_buffer_wp) {
3523 frame_count =
3524 (j->write_buffer_wp - j->write_buffer) / (j->play_frame_size * 2) +
3525 (j->write_buffer_end - j->write_buffer_rp) / (j->play_frame_size * 2);
3527 if (frame_count >= 1) {
3528 if (j->ver.low == 0x12 && j->play_mode && j->flags.play_first_frame) {
3529 switch (j->play_mode) {
3530 case PLAYBACK_MODE_ULAW:
3531 case PLAYBACK_MODE_ALAW:
3532 blankword.low = blankword.high = 0xFF;
3533 break;
3534 case PLAYBACK_MODE_8LINEAR:
3535 case PLAYBACK_MODE_16LINEAR:
3536 blankword.low = blankword.high = 0x00;
3537 break;
3538 case PLAYBACK_MODE_8LINEAR_WSS:
3539 blankword.low = blankword.high = 0x80;
3540 break;
3542 for (cnt = 0; cnt < 16; cnt++) {
3543 if (!(cnt % 16) && !IsTxReady(j)) {
3544 dly = 0;
3545 while (!IsTxReady(j)) {
3546 if (dly++ > 5) {
3547 dly = 0;
3548 break;
3550 udelay(10);
3553 outb_p((blankword.low), j->DSPbase + 0x0C);
3554 outb_p((blankword.high), j->DSPbase + 0x0D);
3556 j->flags.play_first_frame = 0;
3557 } else if (j->play_codec == G723_63 && j->flags.play_first_frame) {
3558 for (cnt = 0; cnt < 24; cnt++) {
3559 if(cnt == 12) {
3560 blankword.low = 0x02;
3561 blankword.high = 0x00;
3563 else {
3564 blankword.low = blankword.high = 0x00;
3566 if (!(cnt % 16) && !IsTxReady(j)) {
3567 dly = 0;
3568 while (!IsTxReady(j)) {
3569 if (dly++ > 5) {
3570 dly = 0;
3571 break;
3573 udelay(10);
3576 outb_p((blankword.low), j->DSPbase + 0x0C);
3577 outb_p((blankword.high), j->DSPbase + 0x0D);
3579 j->flags.play_first_frame = 0;
3581 for (cnt = 0; cnt < j->play_frame_size * 2; cnt += 2) {
3582 if (!(cnt % 16) && !IsTxReady(j)) {
3583 dly = 0;
3584 while (!IsTxReady(j)) {
3585 if (dly++ > 5) {
3586 dly = 0;
3587 break;
3589 udelay(10);
3592 /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */
3593 if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
3594 if(j->write_buffer_rp + cnt == 0 && j->write_buffer_rp + cnt + 1 == 0 && j->write_buffer_rp + cnt + 2 == 0 &&
3595 j->write_buffer_rp + cnt + 3 == 0 && j->write_buffer_rp + cnt + 4 == 0 && j->write_buffer_rp + cnt + 5 == 0 &&
3596 j->write_buffer_rp + cnt + 6 == 0 && j->write_buffer_rp + cnt + 7 == 0 && j->write_buffer_rp + cnt + 8 == 0 &&
3597 j->write_buffer_rp + cnt + 9 == 0) {
3598 /* someone is trying to write silence lets make this a type 0 frame. */
3599 outb_p(0x00, j->DSPbase + 0x0C);
3600 outb_p(0x00, j->DSPbase + 0x0D);
3601 } else {
3602 /* so all other frames are type 1. */
3603 outb_p(0x01, j->DSPbase + 0x0C);
3604 outb_p(0x00, j->DSPbase + 0x0D);
3607 outb_p(*(j->write_buffer_rp + cnt), j->DSPbase + 0x0C);
3608 outb_p(*(j->write_buffer_rp + cnt + 1), j->DSPbase + 0x0D);
3609 *(j->write_buffer_rp + cnt) = 0;
3610 *(j->write_buffer_rp + cnt + 1) = 0;
3612 j->write_buffer_rp += j->play_frame_size * 2;
3613 if (j->write_buffer_rp >= j->write_buffer_end) {
3614 j->write_buffer_rp = j->write_buffer;
3616 j->write_buffers_empty++;
3617 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3619 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
3621 ++j->frameswritten;
3623 } else {
3624 j->drybuffer++;
3626 if(j->ixj_signals[SIG_WRITE_READY]) {
3627 ixj_kill_fasync(j, SIG_WRITE_READY, POLL_OUT);
3631 static int idle(IXJ *j)
3633 if (ixj_WriteDSPCommand(0x0000, j)) /* DSP Idle */
3635 return 0;
3637 if (j->ssr.high || j->ssr.low) {
3638 return 0;
3639 } else {
3640 j->play_mode = -1;
3641 j->flags.playing = 0;
3642 j->rec_mode = -1;
3643 j->flags.recording = 0;
3644 return 1;
3648 static int set_base_frame(IXJ *j, int size)
3650 unsigned short cmd;
3651 int cnt;
3653 idle(j);
3654 j->cid_play_aec_level = j->aec_level;
3655 aec_stop(j);
3656 for (cnt = 0; cnt < 10; cnt++) {
3657 if (idle(j))
3658 break;
3660 if (j->ssr.high || j->ssr.low)
3661 return -1;
3662 if (j->dsp.low != 0x20) {
3663 switch (size) {
3664 case 30:
3665 cmd = 0x07F0;
3666 /* Set Base Frame Size to 240 pg9-10 8021 */
3667 break;
3668 case 20:
3669 cmd = 0x07A0;
3670 /* Set Base Frame Size to 160 pg9-10 8021 */
3671 break;
3672 case 10:
3673 cmd = 0x0750;
3674 /* Set Base Frame Size to 80 pg9-10 8021 */
3675 break;
3676 default:
3677 return -1;
3679 } else {
3680 if (size == 30)
3681 return size;
3682 else
3683 return -1;
3685 if (ixj_WriteDSPCommand(cmd, j)) {
3686 j->baseframe.high = j->baseframe.low = 0xFF;
3687 return -1;
3688 } else {
3689 j->baseframe.high = j->ssr.high;
3690 j->baseframe.low = j->ssr.low;
3691 /* If the status returned is 0x0000 (pg9-9 8021) the call failed */
3692 if(j->baseframe.high == 0x00 && j->baseframe.low == 0x00) {
3693 return -1;
3696 ixj_aec_start(j, j->cid_play_aec_level);
3697 return size;
3700 static int set_rec_codec(IXJ *j, int rate)
3702 int retval = 0;
3704 j->rec_codec = rate;
3706 switch (rate) {
3707 case G723_63:
3708 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3709 j->rec_frame_size = 12;
3710 j->rec_mode = 0;
3711 } else {
3712 retval = 1;
3714 break;
3715 case G723_53:
3716 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3717 j->rec_frame_size = 10;
3718 j->rec_mode = 0;
3719 } else {
3720 retval = 1;
3722 break;
3723 case TS85:
3724 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
3725 j->rec_frame_size = 16;
3726 j->rec_mode = 0;
3727 } else {
3728 retval = 1;
3730 break;
3731 case TS48:
3732 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3733 j->rec_frame_size = 9;
3734 j->rec_mode = 0;
3735 } else {
3736 retval = 1;
3738 break;
3739 case TS41:
3740 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3741 j->rec_frame_size = 8;
3742 j->rec_mode = 0;
3743 } else {
3744 retval = 1;
3746 break;
3747 case G728:
3748 if (j->dsp.low != 0x20) {
3749 j->rec_frame_size = 48;
3750 j->rec_mode = 0;
3751 } else {
3752 retval = 1;
3754 break;
3755 case G729:
3756 if (j->dsp.low != 0x20) {
3757 if (!j->flags.g729_loaded) {
3758 retval = 1;
3759 break;
3761 switch (j->baseframe.low) {
3762 case 0xA0:
3763 j->rec_frame_size = 10;
3764 break;
3765 case 0x50:
3766 j->rec_frame_size = 5;
3767 break;
3768 default:
3769 j->rec_frame_size = 15;
3770 break;
3772 j->rec_mode = 0;
3773 } else {
3774 retval = 1;
3776 break;
3777 case G729B:
3778 if (j->dsp.low != 0x20) {
3779 if (!j->flags.g729_loaded) {
3780 retval = 1;
3781 break;
3783 switch (j->baseframe.low) {
3784 case 0xA0:
3785 j->rec_frame_size = 12;
3786 break;
3787 case 0x50:
3788 j->rec_frame_size = 6;
3789 break;
3790 default:
3791 j->rec_frame_size = 18;
3792 break;
3794 j->rec_mode = 0;
3795 } else {
3796 retval = 1;
3798 break;
3799 case ULAW:
3800 switch (j->baseframe.low) {
3801 case 0xA0:
3802 j->rec_frame_size = 80;
3803 break;
3804 case 0x50:
3805 j->rec_frame_size = 40;
3806 break;
3807 default:
3808 j->rec_frame_size = 120;
3809 break;
3811 j->rec_mode = 4;
3812 break;
3813 case ALAW:
3814 switch (j->baseframe.low) {
3815 case 0xA0:
3816 j->rec_frame_size = 80;
3817 break;
3818 case 0x50:
3819 j->rec_frame_size = 40;
3820 break;
3821 default:
3822 j->rec_frame_size = 120;
3823 break;
3825 j->rec_mode = 4;
3826 break;
3827 case LINEAR16:
3828 switch (j->baseframe.low) {
3829 case 0xA0:
3830 j->rec_frame_size = 160;
3831 break;
3832 case 0x50:
3833 j->rec_frame_size = 80;
3834 break;
3835 default:
3836 j->rec_frame_size = 240;
3837 break;
3839 j->rec_mode = 5;
3840 break;
3841 case LINEAR8:
3842 switch (j->baseframe.low) {
3843 case 0xA0:
3844 j->rec_frame_size = 80;
3845 break;
3846 case 0x50:
3847 j->rec_frame_size = 40;
3848 break;
3849 default:
3850 j->rec_frame_size = 120;
3851 break;
3853 j->rec_mode = 6;
3854 break;
3855 case WSS:
3856 switch (j->baseframe.low) {
3857 case 0xA0:
3858 j->rec_frame_size = 80;
3859 break;
3860 case 0x50:
3861 j->rec_frame_size = 40;
3862 break;
3863 default:
3864 j->rec_frame_size = 120;
3865 break;
3867 j->rec_mode = 7;
3868 break;
3869 default:
3870 j->rec_frame_size = 0;
3871 j->rec_mode = -1;
3872 if (j->read_buffer) {
3873 kfree(j->read_buffer);
3874 j->read_buffer = NULL;
3875 j->read_buffer_size = 0;
3877 retval = 1;
3878 break;
3880 return retval;
3883 static int ixj_record_start(IXJ *j)
3885 unsigned short cmd = 0x0000;
3887 if (j->read_buffer) {
3888 ixj_record_stop(j);
3890 j->flags.recording = 1;
3891 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
3893 if(ixjdebug & 0x0002)
3894 printk("IXJ %d Starting Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
3896 if (!j->rec_mode) {
3897 switch (j->rec_codec) {
3898 case G723_63:
3899 cmd = 0x5131;
3900 break;
3901 case G723_53:
3902 cmd = 0x5132;
3903 break;
3904 case TS85:
3905 cmd = 0x5130; /* TrueSpeech 8.5 */
3907 break;
3908 case TS48:
3909 cmd = 0x5133; /* TrueSpeech 4.8 */
3911 break;
3912 case TS41:
3913 cmd = 0x5134; /* TrueSpeech 4.1 */
3915 break;
3916 case G728:
3917 cmd = 0x5135;
3918 break;
3919 case G729:
3920 case G729B:
3921 cmd = 0x5136;
3922 break;
3923 default:
3924 return 1;
3926 if (ixj_WriteDSPCommand(cmd, j))
3927 return -1;
3929 if (!j->read_buffer) {
3930 if (!j->read_buffer)
3931 j->read_buffer = kmalloc(j->rec_frame_size * 2, GFP_ATOMIC);
3932 if (!j->read_buffer) {
3933 printk("Read buffer allocation for ixj board %d failed!\n", j->board);
3934 return -ENOMEM;
3937 j->read_buffer_size = j->rec_frame_size * 2;
3939 if (ixj_WriteDSPCommand(0x5102, j)) /* Set Poll sync mode */
3941 return -1;
3943 switch (j->rec_mode) {
3944 case 0:
3945 cmd = 0x1C03; /* Record C1 */
3947 break;
3948 case 4:
3949 if (j->ver.low == 0x12) {
3950 cmd = 0x1E03; /* Record C1 */
3952 } else {
3953 cmd = 0x1E01; /* Record C1 */
3956 break;
3957 case 5:
3958 if (j->ver.low == 0x12) {
3959 cmd = 0x1E83; /* Record C1 */
3961 } else {
3962 cmd = 0x1E81; /* Record C1 */
3965 break;
3966 case 6:
3967 if (j->ver.low == 0x12) {
3968 cmd = 0x1F03; /* Record C1 */
3970 } else {
3971 cmd = 0x1F01; /* Record C1 */
3974 break;
3975 case 7:
3976 if (j->ver.low == 0x12) {
3977 cmd = 0x1F83; /* Record C1 */
3978 } else {
3979 cmd = 0x1F81; /* Record C1 */
3981 break;
3983 if (ixj_WriteDSPCommand(cmd, j))
3984 return -1;
3986 if (j->flags.playing) {
3987 ixj_aec_start(j, j->aec_level);
3989 return 0;
3992 static void ixj_record_stop(IXJ *j)
3994 if(ixjdebug & 0x0002)
3995 printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
3997 if (j->read_buffer) {
3998 kfree(j->read_buffer);
3999 j->read_buffer = NULL;
4000 j->read_buffer_size = 0;
4002 if (j->rec_mode > -1) {
4003 ixj_WriteDSPCommand(0x5120, j);
4004 j->rec_mode = -1;
4006 j->flags.recording = 0;
4008 static void ixj_vad(IXJ *j, int arg)
4010 if (arg)
4011 ixj_WriteDSPCommand(0x513F, j);
4012 else
4013 ixj_WriteDSPCommand(0x513E, j);
4016 static void set_rec_depth(IXJ *j, int depth)
4018 if (depth > 60)
4019 depth = 60;
4020 if (depth < 0)
4021 depth = 0;
4022 ixj_WriteDSPCommand(0x5180 + depth, j);
4025 static void set_dtmf_prescale(IXJ *j, int volume)
4027 ixj_WriteDSPCommand(0xCF07, j);
4028 ixj_WriteDSPCommand(volume, j);
4031 static int get_dtmf_prescale(IXJ *j)
4033 ixj_WriteDSPCommand(0xCF05, j);
4034 return j->ssr.high << 8 | j->ssr.low;
4037 static void set_rec_volume(IXJ *j, int volume)
4039 if(j->aec_level == AEC_AGC) {
4040 if (ixjdebug & 0x0002)
4041 printk(KERN_INFO "IXJ: /dev/phone%d Setting AGC Threshold to 0x%4.4x\n", j->board, volume);
4042 ixj_WriteDSPCommand(0xCF96, j);
4043 ixj_WriteDSPCommand(volume, j);
4044 } else {
4045 if (ixjdebug & 0x0002)
4046 printk(KERN_INFO "IXJ: /dev/phone %d Setting Record Volume to 0x%4.4x\n", j->board, volume);
4047 ixj_WriteDSPCommand(0xCF03, j);
4048 ixj_WriteDSPCommand(volume, j);
4052 static int set_rec_volume_linear(IXJ *j, int volume)
4054 int newvolume, dsprecmax;
4056 if (ixjdebug & 0x0002)
4057 printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Record Volume to 0x%4.4x\n", j->board, volume);
4058 if(volume > 100 || volume < 0) {
4059 return -1;
4062 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
4063 switch (j->cardtype) {
4064 case QTI_PHONEJACK:
4065 dsprecmax = 0x440;
4066 break;
4067 case QTI_LINEJACK:
4068 dsprecmax = 0x180;
4069 ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
4070 ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
4071 ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
4072 break;
4073 case QTI_PHONEJACK_LITE:
4074 dsprecmax = 0x4C0;
4075 break;
4076 case QTI_PHONEJACK_PCI:
4077 dsprecmax = 0x100;
4078 break;
4079 case QTI_PHONECARD:
4080 dsprecmax = 0x400;
4081 break;
4082 default:
4083 return -1;
4085 newvolume = (dsprecmax * volume) / 100;
4086 set_rec_volume(j, newvolume);
4087 return 0;
4090 static int get_rec_volume(IXJ *j)
4092 if(j->aec_level == AEC_AGC) {
4093 if (ixjdebug & 0x0002)
4094 printk(KERN_INFO "Getting AGC Threshold\n");
4095 ixj_WriteDSPCommand(0xCF86, j);
4096 if (ixjdebug & 0x0002)
4097 printk(KERN_INFO "AGC Threshold is 0x%2.2x%2.2x\n", j->ssr.high, j->ssr.low);
4098 return j->ssr.high << 8 | j->ssr.low;
4099 } else {
4100 if (ixjdebug & 0x0002)
4101 printk(KERN_INFO "Getting Record Volume\n");
4102 ixj_WriteDSPCommand(0xCF01, j);
4103 return j->ssr.high << 8 | j->ssr.low;
4107 static int get_rec_volume_linear(IXJ *j)
4109 int volume, newvolume, dsprecmax;
4111 switch (j->cardtype) {
4112 case QTI_PHONEJACK:
4113 dsprecmax = 0x440;
4114 break;
4115 case QTI_LINEJACK:
4116 dsprecmax = 0x180;
4117 break;
4118 case QTI_PHONEJACK_LITE:
4119 dsprecmax = 0x4C0;
4120 break;
4121 case QTI_PHONEJACK_PCI:
4122 dsprecmax = 0x100;
4123 break;
4124 case QTI_PHONECARD:
4125 dsprecmax = 0x400;
4126 break;
4127 default:
4128 return -1;
4130 volume = get_rec_volume(j);
4131 newvolume = (volume * 100) / dsprecmax;
4132 if(newvolume > 100)
4133 newvolume = 100;
4134 return newvolume;
4137 static int get_rec_level(IXJ *j)
4139 int retval;
4141 ixj_WriteDSPCommand(0xCF88, j);
4143 retval = j->ssr.high << 8 | j->ssr.low;
4144 retval = (retval * 256) / 240;
4145 return retval;
4148 static void ixj_aec_start(IXJ *j, int level)
4150 j->aec_level = level;
4151 if (ixjdebug & 0x0002)
4152 printk(KERN_INFO "AGC set = 0x%2.2x\n", j->aec_level);
4153 if (!level) {
4154 aec_stop(j);
4155 } else {
4156 if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
4157 ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer */
4159 ixj_WriteDSPCommand(0x0300, j);
4161 ixj_WriteDSPCommand(0xB001, j); /* AEC On */
4163 ixj_WriteDSPCommand(0xE013, j); /* Advanced AEC C1 */
4165 switch (level) {
4166 case AEC_LOW:
4167 ixj_WriteDSPCommand(0x0000, j); /* Advanced AEC C2 = off */
4169 ixj_WriteDSPCommand(0xE011, j);
4170 ixj_WriteDSPCommand(0xFFFF, j);
4172 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4173 ixj_WriteDSPCommand(0x0000, j); /* to off */
4175 break;
4177 case AEC_MED:
4178 ixj_WriteDSPCommand(0x0600, j); /* Advanced AEC C2 = on medium */
4180 ixj_WriteDSPCommand(0xE011, j);
4181 ixj_WriteDSPCommand(0x0080, j);
4183 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4184 ixj_WriteDSPCommand(0x0000, j); /* to off */
4186 break;
4188 case AEC_HIGH:
4189 ixj_WriteDSPCommand(0x0C00, j); /* Advanced AEC C2 = on high */
4191 ixj_WriteDSPCommand(0xE011, j);
4192 ixj_WriteDSPCommand(0x0080, j);
4194 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4195 ixj_WriteDSPCommand(0x0000, j); /* to off */
4197 break;
4199 case AEC_AGC:
4200 /* First we have to put the AEC into advance auto mode so that AGC will not conflict with it */
4201 ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
4203 ixj_WriteDSPCommand(0xE011, j);
4204 ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
4206 ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
4208 if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
4209 ixj_WriteDSPCommand(0x0224, j);
4210 else
4211 ixj_WriteDSPCommand(0x1224, j);
4213 ixj_WriteDSPCommand(0xE014, j);
4214 ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */
4216 ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
4218 /* Now we can set the AGC initial parameters and turn it on */
4219 ixj_WriteDSPCommand(0xCF90, j); /* Set AGC Minumum gain */
4220 ixj_WriteDSPCommand(0x0020, j); /* to 0.125 (-18dB) */
4222 ixj_WriteDSPCommand(0xCF91, j); /* Set AGC Maximum gain */
4223 ixj_WriteDSPCommand(0x1000, j); /* to 16 (24dB) */
4225 ixj_WriteDSPCommand(0xCF92, j); /* Set AGC start gain */
4226 ixj_WriteDSPCommand(0x0800, j); /* to 8 (+18dB) */
4228 ixj_WriteDSPCommand(0xCF93, j); /* Set AGC hold time */
4229 ixj_WriteDSPCommand(0x1F40, j); /* to 2 seconds (units are 250us) */
4231 ixj_WriteDSPCommand(0xCF94, j); /* Set AGC Attack Time Constant */
4232 ixj_WriteDSPCommand(0x0005, j); /* to 8ms */
4234 ixj_WriteDSPCommand(0xCF95, j); /* Set AGC Decay Time Constant */
4235 ixj_WriteDSPCommand(0x000D, j); /* to 4096ms */
4237 ixj_WriteDSPCommand(0xCF96, j); /* Set AGC Attack Threshold */
4238 ixj_WriteDSPCommand(0x1200, j); /* to 25% */
4240 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4241 ixj_WriteDSPCommand(0x0001, j); /* to on */
4243 break;
4245 case AEC_AUTO:
4246 ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
4248 ixj_WriteDSPCommand(0xE011, j);
4249 ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
4251 ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
4253 if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
4254 ixj_WriteDSPCommand(0x0224, j);
4255 else
4256 ixj_WriteDSPCommand(0x1224, j);
4258 ixj_WriteDSPCommand(0xE014, j);
4259 ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */
4261 ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
4263 break;
4268 static void aec_stop(IXJ *j)
4270 j->aec_level = AEC_OFF;
4271 if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
4272 ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer back */
4274 ixj_WriteDSPCommand(0x0700, j);
4276 if (j->play_mode != -1 && j->rec_mode != -1)
4278 ixj_WriteDSPCommand(0xB002, j); /* AEC Stop */
4282 static int set_play_codec(IXJ *j, int rate)
4284 int retval = 0;
4286 j->play_codec = rate;
4288 switch (rate) {
4289 case G723_63:
4290 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4291 j->play_frame_size = 12;
4292 j->play_mode = 0;
4293 } else {
4294 retval = 1;
4296 break;
4297 case G723_53:
4298 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4299 j->play_frame_size = 10;
4300 j->play_mode = 0;
4301 } else {
4302 retval = 1;
4304 break;
4305 case TS85:
4306 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
4307 j->play_frame_size = 16;
4308 j->play_mode = 0;
4309 } else {
4310 retval = 1;
4312 break;
4313 case TS48:
4314 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4315 j->play_frame_size = 9;
4316 j->play_mode = 0;
4317 } else {
4318 retval = 1;
4320 break;
4321 case TS41:
4322 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4323 j->play_frame_size = 8;
4324 j->play_mode = 0;
4325 } else {
4326 retval = 1;
4328 break;
4329 case G728:
4330 if (j->dsp.low != 0x20) {
4331 j->play_frame_size = 48;
4332 j->play_mode = 0;
4333 } else {
4334 retval = 1;
4336 break;
4337 case G729:
4338 if (j->dsp.low != 0x20) {
4339 if (!j->flags.g729_loaded) {
4340 retval = 1;
4341 break;
4343 switch (j->baseframe.low) {
4344 case 0xA0:
4345 j->play_frame_size = 10;
4346 break;
4347 case 0x50:
4348 j->play_frame_size = 5;
4349 break;
4350 default:
4351 j->play_frame_size = 15;
4352 break;
4354 j->play_mode = 0;
4355 } else {
4356 retval = 1;
4358 break;
4359 case G729B:
4360 if (j->dsp.low != 0x20) {
4361 if (!j->flags.g729_loaded) {
4362 retval = 1;
4363 break;
4365 switch (j->baseframe.low) {
4366 case 0xA0:
4367 j->play_frame_size = 12;
4368 break;
4369 case 0x50:
4370 j->play_frame_size = 6;
4371 break;
4372 default:
4373 j->play_frame_size = 18;
4374 break;
4376 j->play_mode = 0;
4377 } else {
4378 retval = 1;
4380 break;
4381 case ULAW:
4382 switch (j->baseframe.low) {
4383 case 0xA0:
4384 j->play_frame_size = 80;
4385 break;
4386 case 0x50:
4387 j->play_frame_size = 40;
4388 break;
4389 default:
4390 j->play_frame_size = 120;
4391 break;
4393 j->play_mode = 2;
4394 break;
4395 case ALAW:
4396 switch (j->baseframe.low) {
4397 case 0xA0:
4398 j->play_frame_size = 80;
4399 break;
4400 case 0x50:
4401 j->play_frame_size = 40;
4402 break;
4403 default:
4404 j->play_frame_size = 120;
4405 break;
4407 j->play_mode = 2;
4408 break;
4409 case LINEAR16:
4410 switch (j->baseframe.low) {
4411 case 0xA0:
4412 j->play_frame_size = 160;
4413 break;
4414 case 0x50:
4415 j->play_frame_size = 80;
4416 break;
4417 default:
4418 j->play_frame_size = 240;
4419 break;
4421 j->play_mode = 6;
4422 break;
4423 case LINEAR8:
4424 switch (j->baseframe.low) {
4425 case 0xA0:
4426 j->play_frame_size = 80;
4427 break;
4428 case 0x50:
4429 j->play_frame_size = 40;
4430 break;
4431 default:
4432 j->play_frame_size = 120;
4433 break;
4435 j->play_mode = 4;
4436 break;
4437 case WSS:
4438 switch (j->baseframe.low) {
4439 case 0xA0:
4440 j->play_frame_size = 80;
4441 break;
4442 case 0x50:
4443 j->play_frame_size = 40;
4444 break;
4445 default:
4446 j->play_frame_size = 120;
4447 break;
4449 j->play_mode = 5;
4450 break;
4451 default:
4452 j->play_frame_size = 0;
4453 j->play_mode = -1;
4454 if (j->write_buffer) {
4455 kfree(j->write_buffer);
4456 j->write_buffer = NULL;
4457 j->write_buffer_size = 0;
4459 retval = 1;
4460 break;
4462 return retval;
4465 static int ixj_play_start(IXJ *j)
4467 unsigned short cmd = 0x0000;
4469 if (j->write_buffer) {
4470 ixj_play_stop(j);
4473 if(ixjdebug & 0x0002)
4474 printk("IXJ %d Starting Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
4476 j->flags.playing = 1;
4477 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
4479 j->flags.play_first_frame = 1;
4480 j->drybuffer = 0;
4482 if (!j->play_mode) {
4483 switch (j->play_codec) {
4484 case G723_63:
4485 cmd = 0x5231;
4486 break;
4487 case G723_53:
4488 cmd = 0x5232;
4489 break;
4490 case TS85:
4491 cmd = 0x5230; /* TrueSpeech 8.5 */
4493 break;
4494 case TS48:
4495 cmd = 0x5233; /* TrueSpeech 4.8 */
4497 break;
4498 case TS41:
4499 cmd = 0x5234; /* TrueSpeech 4.1 */
4501 break;
4502 case G728:
4503 cmd = 0x5235;
4504 break;
4505 case G729:
4506 case G729B:
4507 cmd = 0x5236;
4508 break;
4509 default:
4510 return 1;
4512 if (ixj_WriteDSPCommand(cmd, j))
4513 return -1;
4515 j->write_buffer = kmalloc(j->play_frame_size * 2, GFP_ATOMIC);
4516 if (!j->write_buffer) {
4517 printk("Write buffer allocation for ixj board %d failed!\n", j->board);
4518 return -ENOMEM;
4520 /* j->write_buffers_empty = 2; */
4521 j->write_buffers_empty = 1;
4522 j->write_buffer_size = j->play_frame_size * 2;
4523 j->write_buffer_end = j->write_buffer + j->play_frame_size * 2;
4524 j->write_buffer_rp = j->write_buffer_wp = j->write_buffer;
4526 if (ixj_WriteDSPCommand(0x5202, j)) /* Set Poll sync mode */
4528 return -1;
4530 switch (j->play_mode) {
4531 case 0:
4532 cmd = 0x2C03;
4533 break;
4534 case 2:
4535 if (j->ver.low == 0x12) {
4536 cmd = 0x2C23;
4537 } else {
4538 cmd = 0x2C21;
4540 break;
4541 case 4:
4542 if (j->ver.low == 0x12) {
4543 cmd = 0x2C43;
4544 } else {
4545 cmd = 0x2C41;
4547 break;
4548 case 5:
4549 if (j->ver.low == 0x12) {
4550 cmd = 0x2C53;
4551 } else {
4552 cmd = 0x2C51;
4554 break;
4555 case 6:
4556 if (j->ver.low == 0x12) {
4557 cmd = 0x2C63;
4558 } else {
4559 cmd = 0x2C61;
4561 break;
4563 if (ixj_WriteDSPCommand(cmd, j))
4564 return -1;
4566 if (ixj_WriteDSPCommand(0x2000, j)) /* Playback C2 */
4567 return -1;
4569 if (ixj_WriteDSPCommand(0x2000 + j->play_frame_size, j)) /* Playback C3 */
4570 return -1;
4572 if (j->flags.recording) {
4573 ixj_aec_start(j, j->aec_level);
4576 return 0;
4579 static void ixj_play_stop(IXJ *j)
4581 if(ixjdebug & 0x0002)
4582 printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
4584 if (j->write_buffer) {
4585 kfree(j->write_buffer);
4586 j->write_buffer = NULL;
4587 j->write_buffer_size = 0;
4589 if (j->play_mode > -1) {
4590 ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */
4592 j->play_mode = -1;
4594 j->flags.playing = 0;
4597 static inline int get_play_level(IXJ *j)
4599 int retval;
4601 ixj_WriteDSPCommand(0xCF8F, j); /* 8022 Reference page 9-38 */
4602 return j->ssr.high << 8 | j->ssr.low;
4603 retval = j->ssr.high << 8 | j->ssr.low;
4604 retval = (retval * 256) / 240;
4605 return retval;
4608 static unsigned int ixj_poll(struct file *file_p, poll_table * wait)
4610 unsigned int mask = 0;
4612 IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
4614 poll_wait(file_p, &(j->poll_q), wait);
4615 if (j->read_buffer_ready > 0)
4616 mask |= POLLIN | POLLRDNORM; /* readable */
4617 if (j->write_buffers_empty > 0)
4618 mask |= POLLOUT | POLLWRNORM; /* writable */
4619 if (j->ex.bytes)
4620 mask |= POLLPRI;
4621 return mask;
4624 static int ixj_play_tone(IXJ *j, char tone)
4626 if (!j->tone_state) {
4627 if(ixjdebug & 0x0002) {
4628 printk("IXJ %d starting tone %d at %ld\n", j->board, tone, jiffies);
4630 if (j->dsp.low == 0x20) {
4631 idle(j);
4633 j->tone_start_jif = jiffies;
4635 j->tone_state = 1;
4638 j->tone_index = tone;
4639 if (ixj_WriteDSPCommand(0x6000 + j->tone_index, j))
4640 return -1;
4642 return 0;
4645 static int ixj_set_tone_on(unsigned short arg, IXJ *j)
4647 j->tone_on_time = arg;
4649 if (ixj_WriteDSPCommand(0x6E04, j)) /* Set Tone On Period */
4651 return -1;
4653 if (ixj_WriteDSPCommand(arg, j))
4654 return -1;
4656 return 0;
4659 static int SCI_WaitHighSCI(IXJ *j)
4661 int cnt;
4663 j->pld_scrr.byte = inb_p(j->XILINXbase);
4664 if (!j->pld_scrr.bits.sci) {
4665 for (cnt = 0; cnt < 10; cnt++) {
4666 udelay(32);
4667 j->pld_scrr.byte = inb_p(j->XILINXbase);
4669 if ((j->pld_scrr.bits.sci))
4670 return 1;
4672 if (ixjdebug & 0x0001)
4673 printk(KERN_INFO "SCI Wait High failed %x\n", j->pld_scrr.byte);
4674 return 0;
4675 } else
4676 return 1;
4679 static int SCI_WaitLowSCI(IXJ *j)
4681 int cnt;
4683 j->pld_scrr.byte = inb_p(j->XILINXbase);
4684 if (j->pld_scrr.bits.sci) {
4685 for (cnt = 0; cnt < 10; cnt++) {
4686 udelay(32);
4687 j->pld_scrr.byte = inb_p(j->XILINXbase);
4689 if (!(j->pld_scrr.bits.sci))
4690 return 1;
4692 if (ixjdebug & 0x0001)
4693 printk(KERN_INFO "SCI Wait Low failed %x\n", j->pld_scrr.byte);
4694 return 0;
4695 } else
4696 return 1;
4699 static int SCI_Control(IXJ *j, int control)
4701 switch (control) {
4702 case SCI_End:
4703 j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
4705 j->pld_scrw.bits.c1 = 0; /* to no selection */
4707 break;
4708 case SCI_Enable_DAA:
4709 j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
4711 j->pld_scrw.bits.c1 = 0; /* to write to DAA */
4713 break;
4714 case SCI_Enable_Mixer:
4715 j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
4717 j->pld_scrw.bits.c1 = 1; /* to write to mixer */
4719 break;
4720 case SCI_Enable_EEPROM:
4721 j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
4723 j->pld_scrw.bits.c1 = 1; /* to write to EEPROM */
4725 break;
4726 default:
4727 return 0;
4728 break;
4730 outb_p(j->pld_scrw.byte, j->XILINXbase);
4732 switch (control) {
4733 case SCI_End:
4734 return 1;
4735 break;
4736 case SCI_Enable_DAA:
4737 case SCI_Enable_Mixer:
4738 case SCI_Enable_EEPROM:
4739 if (!SCI_WaitHighSCI(j))
4740 return 0;
4741 break;
4742 default:
4743 return 0;
4744 break;
4746 return 1;
4749 static int SCI_Prepare(IXJ *j)
4751 if (!SCI_Control(j, SCI_End))
4752 return 0;
4754 if (!SCI_WaitLowSCI(j))
4755 return 0;
4757 return 1;
4760 static int ixj_get_mixer(long val, IXJ *j)
4762 int reg = (val & 0x1F00) >> 8;
4763 return j->mix.vol[reg];
4766 static int ixj_mixer(long val, IXJ *j)
4768 BYTES bytes;
4770 bytes.high = (val & 0x1F00) >> 8;
4771 bytes.low = val & 0x00FF;
4773 /* save mixer value so we can get back later on */
4774 j->mix.vol[bytes.high] = bytes.low;
4776 outb_p(bytes.high & 0x1F, j->XILINXbase + 0x03); /* Load Mixer Address */
4778 outb_p(bytes.low, j->XILINXbase + 0x02); /* Load Mixer Data */
4780 SCI_Control(j, SCI_Enable_Mixer);
4782 SCI_Control(j, SCI_End);
4784 return 0;
4787 static int daa_load(BYTES * p_bytes, IXJ *j)
4789 outb_p(p_bytes->high, j->XILINXbase + 0x03);
4790 outb_p(p_bytes->low, j->XILINXbase + 0x02);
4791 if (!SCI_Control(j, SCI_Enable_DAA))
4792 return 0;
4793 else
4794 return 1;
4797 static int ixj_daa_cr4(IXJ *j, char reg)
4799 BYTES bytes;
4801 switch (j->daa_mode) {
4802 case SOP_PU_SLEEP:
4803 bytes.high = 0x14;
4804 break;
4805 case SOP_PU_RINGING:
4806 bytes.high = 0x54;
4807 break;
4808 case SOP_PU_CONVERSATION:
4809 bytes.high = 0x94;
4810 break;
4811 case SOP_PU_PULSEDIALING:
4812 bytes.high = 0xD4;
4813 break;
4816 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = reg;
4818 switch (j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGX) {
4819 case 0:
4820 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 0;
4821 break;
4822 case 1:
4823 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 2;
4824 break;
4825 case 2:
4826 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 1;
4827 break;
4828 case 3:
4829 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 3;
4830 break;
4833 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
4835 if (!daa_load(&bytes, j))
4836 return 0;
4838 if (!SCI_Prepare(j))
4839 return 0;
4841 return 1;
4844 static char daa_int_read(IXJ *j)
4846 BYTES bytes;
4848 if (!SCI_Prepare(j))
4849 return 0;
4851 bytes.high = 0x38;
4852 bytes.low = 0x00;
4853 outb_p(bytes.high, j->XILINXbase + 0x03);
4854 outb_p(bytes.low, j->XILINXbase + 0x02);
4856 if (!SCI_Control(j, SCI_Enable_DAA))
4857 return 0;
4859 bytes.high = inb_p(j->XILINXbase + 0x03);
4860 bytes.low = inb_p(j->XILINXbase + 0x02);
4861 if (bytes.low != ALISDAA_ID_BYTE) {
4862 if (ixjdebug & 0x0001)
4863 printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
4864 return 0;
4866 if (!SCI_Control(j, SCI_Enable_DAA))
4867 return 0;
4868 if (!SCI_Control(j, SCI_End))
4869 return 0;
4871 bytes.high = inb_p(j->XILINXbase + 0x03);
4872 bytes.low = inb_p(j->XILINXbase + 0x02);
4874 j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg = bytes.high;
4876 return 1;
4879 static char daa_CR_read(IXJ *j, int cr)
4881 IXJ_WORD wdata;
4882 BYTES bytes;
4884 if (!SCI_Prepare(j))
4885 return 0;
4887 switch (j->daa_mode) {
4888 case SOP_PU_SLEEP:
4889 bytes.high = 0x30 + cr;
4890 break;
4891 case SOP_PU_RINGING:
4892 bytes.high = 0x70 + cr;
4893 break;
4894 case SOP_PU_CONVERSATION:
4895 bytes.high = 0xB0 + cr;
4896 break;
4897 case SOP_PU_PULSEDIALING:
4898 bytes.high = 0xF0 + cr;
4899 break;
4902 bytes.low = 0x00;
4904 outb_p(bytes.high, j->XILINXbase + 0x03);
4905 outb_p(bytes.low, j->XILINXbase + 0x02);
4907 if (!SCI_Control(j, SCI_Enable_DAA))
4908 return 0;
4910 bytes.high = inb_p(j->XILINXbase + 0x03);
4911 bytes.low = inb_p(j->XILINXbase + 0x02);
4912 if (bytes.low != ALISDAA_ID_BYTE) {
4913 if (ixjdebug & 0x0001)
4914 printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
4915 return 0;
4917 if (!SCI_Control(j, SCI_Enable_DAA))
4918 return 0;
4919 if (!SCI_Control(j, SCI_End))
4920 return 0;
4922 wdata.word = inw_p(j->XILINXbase + 0x02);
4924 switch(cr){
4925 case 5:
4926 j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = wdata.bytes.high;
4927 break;
4928 case 4:
4929 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = wdata.bytes.high;
4930 break;
4931 case 3:
4932 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = wdata.bytes.high;
4933 break;
4934 case 2:
4935 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = wdata.bytes.high;
4936 break;
4937 case 1:
4938 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = wdata.bytes.high;
4939 break;
4940 case 0:
4941 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = wdata.bytes.high;
4942 break;
4943 default:
4944 return 0;
4946 return 1;
4949 static int ixj_daa_cid_reset(IXJ *j)
4951 int i;
4952 BYTES bytes;
4954 if (ixjdebug & 0x0002)
4955 printk("DAA Clearing CID ram\n");
4957 if (!SCI_Prepare(j))
4958 return 0;
4960 bytes.high = 0x58;
4961 bytes.low = 0x00;
4962 outb_p(bytes.high, j->XILINXbase + 0x03);
4963 outb_p(bytes.low, j->XILINXbase + 0x02);
4965 if (!SCI_Control(j, SCI_Enable_DAA))
4966 return 0;
4968 if (!SCI_WaitHighSCI(j))
4969 return 0;
4971 for (i = 0; i < ALISDAA_CALLERID_SIZE - 1; i += 2) {
4972 bytes.high = bytes.low = 0x00;
4973 outb_p(bytes.high, j->XILINXbase + 0x03);
4975 if (i < ALISDAA_CALLERID_SIZE - 1)
4976 outb_p(bytes.low, j->XILINXbase + 0x02);
4978 if (!SCI_Control(j, SCI_Enable_DAA))
4979 return 0;
4981 if (!SCI_WaitHighSCI(j))
4982 return 0;
4986 if (!SCI_Control(j, SCI_End))
4987 return 0;
4989 if (ixjdebug & 0x0002)
4990 printk("DAA CID ram cleared\n");
4992 return 1;
4995 static int ixj_daa_cid_read(IXJ *j)
4997 int i;
4998 BYTES bytes;
4999 char CID[ALISDAA_CALLERID_SIZE], mContinue;
5000 char *pIn, *pOut;
5002 if (!SCI_Prepare(j))
5003 return 0;
5005 bytes.high = 0x78;
5006 bytes.low = 0x00;
5007 outb_p(bytes.high, j->XILINXbase + 0x03);
5008 outb_p(bytes.low, j->XILINXbase + 0x02);
5010 if (!SCI_Control(j, SCI_Enable_DAA))
5011 return 0;
5013 if (!SCI_WaitHighSCI(j))
5014 return 0;
5016 bytes.high = inb_p(j->XILINXbase + 0x03);
5017 bytes.low = inb_p(j->XILINXbase + 0x02);
5018 if (bytes.low != ALISDAA_ID_BYTE) {
5019 if (ixjdebug & 0x0001)
5020 printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
5021 return 0;
5023 for (i = 0; i < ALISDAA_CALLERID_SIZE; i += 2) {
5024 bytes.high = bytes.low = 0x00;
5025 outb_p(bytes.high, j->XILINXbase + 0x03);
5026 outb_p(bytes.low, j->XILINXbase + 0x02);
5028 if (!SCI_Control(j, SCI_Enable_DAA))
5029 return 0;
5031 if (!SCI_WaitHighSCI(j))
5032 return 0;
5034 CID[i + 0] = inb_p(j->XILINXbase + 0x03);
5035 CID[i + 1] = inb_p(j->XILINXbase + 0x02);
5038 if (!SCI_Control(j, SCI_End))
5039 return 0;
5041 pIn = CID;
5042 pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
5043 mContinue = 1;
5044 while (mContinue) {
5045 if ((pIn[1] & 0x03) == 0x01) {
5046 pOut[0] = pIn[0];
5048 if ((pIn[2] & 0x0c) == 0x04) {
5049 pOut[1] = ((pIn[2] & 0x03) << 6) | ((pIn[1] & 0xfc) >> 2);
5051 if ((pIn[3] & 0x30) == 0x10) {
5052 pOut[2] = ((pIn[3] & 0x0f) << 4) | ((pIn[2] & 0xf0) >> 4);
5054 if ((pIn[4] & 0xc0) == 0x40) {
5055 pOut[3] = ((pIn[4] & 0x3f) << 2) | ((pIn[3] & 0xc0) >> 6);
5056 } else {
5057 mContinue = FALSE;
5059 pIn += 5, pOut += 4;
5061 memset(&j->cid, 0, sizeof(PHONE_CID));
5062 pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
5063 pOut += 4;
5064 strncpy(j->cid.month, pOut, 2);
5065 pOut += 2;
5066 strncpy(j->cid.day, pOut, 2);
5067 pOut += 2;
5068 strncpy(j->cid.hour, pOut, 2);
5069 pOut += 2;
5070 strncpy(j->cid.min, pOut, 2);
5071 pOut += 3;
5072 j->cid.numlen = *pOut;
5073 pOut += 1;
5074 strncpy(j->cid.number, pOut, j->cid.numlen);
5075 pOut += j->cid.numlen + 1;
5076 j->cid.namelen = *pOut;
5077 pOut += 1;
5078 strncpy(j->cid.name, pOut, j->cid.namelen);
5080 ixj_daa_cid_reset(j);
5081 return 1;
5084 static char daa_get_version(IXJ *j)
5086 BYTES bytes;
5088 if (!SCI_Prepare(j))
5089 return 0;
5091 bytes.high = 0x35;
5092 bytes.low = 0x00;
5093 outb_p(bytes.high, j->XILINXbase + 0x03);
5094 outb_p(bytes.low, j->XILINXbase + 0x02);
5096 if (!SCI_Control(j, SCI_Enable_DAA))
5097 return 0;
5099 bytes.high = inb_p(j->XILINXbase + 0x03);
5100 bytes.low = inb_p(j->XILINXbase + 0x02);
5101 if (bytes.low != ALISDAA_ID_BYTE) {
5102 if (ixjdebug & 0x0001)
5103 printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
5104 return 0;
5106 if (!SCI_Control(j, SCI_Enable_DAA))
5107 return 0;
5109 if (!SCI_Control(j, SCI_End))
5110 return 0;
5112 bytes.high = inb_p(j->XILINXbase + 0x03);
5113 bytes.low = inb_p(j->XILINXbase + 0x02);
5114 if (ixjdebug & 0x0002)
5115 printk("DAA CR5 Byte high = 0x%x low = 0x%x\n", bytes.high, bytes.low);
5116 j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = bytes.high;
5117 return bytes.high;
5120 static int daa_set_mode(IXJ *j, int mode)
5122 /* NOTE:
5123 The DAA *MUST* be in the conversation mode if the
5124 PSTN line is to be seized (PSTN line off-hook).
5125 Taking the PSTN line off-hook while the DAA is in
5126 a mode other than conversation mode will cause a
5127 hardware failure of the ALIS-A part.
5129 NOTE:
5130 The DAA can only go to SLEEP, RINGING or PULSEDIALING modes
5131 if the PSTN line is on-hook. Failure to have the PSTN line
5132 in the on-hook state WILL CAUSE A HARDWARE FAILURE OF THE
5133 ALIS-A part.
5136 BYTES bytes;
5138 j->flags.pstn_rmr = 0;
5140 if (!SCI_Prepare(j))
5141 return 0;
5143 switch (mode) {
5144 case SOP_PU_RESET:
5145 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5147 outb_p(j->pld_scrw.byte, j->XILINXbase);
5148 j->pld_slicw.bits.rly2 = 0;
5149 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5150 bytes.high = 0x10;
5151 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5152 daa_load(&bytes, j);
5153 if (!SCI_Prepare(j))
5154 return 0;
5156 j->daa_mode = SOP_PU_SLEEP;
5157 break;
5158 case SOP_PU_SLEEP:
5159 if(j->daa_mode == SOP_PU_SLEEP)
5161 break;
5163 if (ixjdebug & 0x0008)
5164 printk(KERN_INFO "phone DAA: SOP_PU_SLEEP at %ld\n", jiffies);
5165 /* if(j->daa_mode == SOP_PU_CONVERSATION) */
5167 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5169 outb_p(j->pld_scrw.byte, j->XILINXbase);
5170 j->pld_slicw.bits.rly2 = 0;
5171 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5172 bytes.high = 0x10;
5173 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5174 daa_load(&bytes, j);
5175 if (!SCI_Prepare(j))
5176 return 0;
5178 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5180 outb_p(j->pld_scrw.byte, j->XILINXbase);
5181 j->pld_slicw.bits.rly2 = 0;
5182 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5183 bytes.high = 0x10;
5184 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5185 daa_load(&bytes, j);
5186 if (!SCI_Prepare(j))
5187 return 0;
5189 j->daa_mode = SOP_PU_SLEEP;
5190 j->flags.pstn_ringing = 0;
5191 j->ex.bits.pstn_ring = 0;
5192 j->pstn_sleeptil = jiffies + (hertz / 4);
5193 wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
5194 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
5195 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
5196 break;
5197 case SOP_PU_RINGING:
5198 if (ixjdebug & 0x0008)
5199 printk(KERN_INFO "phone DAA: SOP_PU_RINGING at %ld\n", jiffies);
5200 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5202 outb_p(j->pld_scrw.byte, j->XILINXbase);
5203 j->pld_slicw.bits.rly2 = 0;
5204 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5205 bytes.high = 0x50;
5206 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5207 daa_load(&bytes, j);
5208 if (!SCI_Prepare(j))
5209 return 0;
5210 j->daa_mode = SOP_PU_RINGING;
5211 break;
5212 case SOP_PU_CONVERSATION:
5213 if (ixjdebug & 0x0008)
5214 printk(KERN_INFO "phone DAA: SOP_PU_CONVERSATION at %ld\n", jiffies);
5215 bytes.high = 0x90;
5216 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5217 daa_load(&bytes, j);
5218 if (!SCI_Prepare(j))
5219 return 0;
5220 j->pld_slicw.bits.rly2 = 1;
5221 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5222 j->pld_scrw.bits.daafsyncen = 1; /* Turn on DAA Frame Sync */
5224 outb_p(j->pld_scrw.byte, j->XILINXbase);
5225 j->daa_mode = SOP_PU_CONVERSATION;
5226 j->flags.pstn_ringing = 0;
5227 j->ex.bits.pstn_ring = 0;
5228 j->pstn_sleeptil = jiffies;
5229 j->pstn_ring_start = j->pstn_ring_stop = j->pstn_ring_int = 0;
5230 break;
5231 case SOP_PU_PULSEDIALING:
5232 if (ixjdebug & 0x0008)
5233 printk(KERN_INFO "phone DAA: SOP_PU_PULSEDIALING at %ld\n", jiffies);
5234 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5236 outb_p(j->pld_scrw.byte, j->XILINXbase);
5237 j->pld_slicw.bits.rly2 = 0;
5238 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5239 bytes.high = 0xD0;
5240 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5241 daa_load(&bytes, j);
5242 if (!SCI_Prepare(j))
5243 return 0;
5244 j->daa_mode = SOP_PU_PULSEDIALING;
5245 break;
5246 default:
5247 break;
5249 return 1;
5252 static int ixj_daa_write(IXJ *j)
5254 BYTES bytes;
5256 j->flags.pstncheck = 1;
5258 daa_set_mode(j, SOP_PU_SLEEP);
5260 if (!SCI_Prepare(j))
5261 return 0;
5263 outb_p(j->pld_scrw.byte, j->XILINXbase);
5265 bytes.high = 0x14;
5266 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
5267 if (!daa_load(&bytes, j))
5268 return 0;
5270 bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg;
5271 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg;
5272 if (!daa_load(&bytes, j))
5273 return 0;
5275 bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg;
5276 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5277 if (!daa_load(&bytes, j))
5278 return 0;
5280 if (!SCI_Prepare(j))
5281 return 0;
5283 bytes.high = 0x1F;
5284 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg;
5285 if (!daa_load(&bytes, j))
5286 return 0;
5288 bytes.high = j->m_DAAShadowRegs.XOP_xr6_W.reg;
5289 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg;
5290 if (!daa_load(&bytes, j))
5291 return 0;
5293 bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg;
5294 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg;
5295 if (!daa_load(&bytes, j))
5296 return 0;
5298 bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg;
5299 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg;
5300 if (!daa_load(&bytes, j))
5301 return 0;
5303 bytes.high = j->m_DAAShadowRegs.XOP_xr0_W.reg;
5304 bytes.low = 0x00;
5305 if (!daa_load(&bytes, j))
5306 return 0;
5308 if (!SCI_Prepare(j))
5309 return 0;
5311 bytes.high = 0x00;
5312 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7];
5313 if (!daa_load(&bytes, j))
5314 return 0;
5316 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6];
5317 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5];
5318 if (!daa_load(&bytes, j))
5319 return 0;
5321 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4];
5322 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3];
5323 if (!daa_load(&bytes, j))
5324 return 0;
5326 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2];
5327 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1];
5328 if (!daa_load(&bytes, j))
5329 return 0;
5331 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0];
5332 bytes.low = 0x00;
5333 if (!daa_load(&bytes, j))
5334 return 0;
5336 if (!SCI_Control(j, SCI_End))
5337 return 0;
5338 if (!SCI_WaitLowSCI(j))
5339 return 0;
5341 bytes.high = 0x01;
5342 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7];
5343 if (!daa_load(&bytes, j))
5344 return 0;
5346 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6];
5347 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5];
5348 if (!daa_load(&bytes, j))
5349 return 0;
5351 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4];
5352 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3];
5353 if (!daa_load(&bytes, j))
5354 return 0;
5356 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2];
5357 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1];
5358 if (!daa_load(&bytes, j))
5359 return 0;
5361 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0];
5362 bytes.low = 0x00;
5363 if (!daa_load(&bytes, j))
5364 return 0;
5366 if (!SCI_Control(j, SCI_End))
5367 return 0;
5368 if (!SCI_WaitLowSCI(j))
5369 return 0;
5371 bytes.high = 0x02;
5372 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7];
5373 if (!daa_load(&bytes, j))
5374 return 0;
5376 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6];
5377 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5];
5378 if (!daa_load(&bytes, j))
5379 return 0;
5381 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4];
5382 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3];
5383 if (!daa_load(&bytes, j))
5384 return 0;
5386 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2];
5387 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1];
5388 if (!daa_load(&bytes, j))
5389 return 0;
5391 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0];
5392 bytes.low = 0x00;
5393 if (!daa_load(&bytes, j))
5394 return 0;
5396 if (!SCI_Control(j, SCI_End))
5397 return 0;
5398 if (!SCI_WaitLowSCI(j))
5399 return 0;
5401 bytes.high = 0x03;
5402 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7];
5403 if (!daa_load(&bytes, j))
5404 return 0;
5406 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6];
5407 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5];
5408 if (!daa_load(&bytes, j))
5409 return 0;
5411 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4];
5412 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3];
5413 if (!daa_load(&bytes, j))
5414 return 0;
5416 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2];
5417 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1];
5418 if (!daa_load(&bytes, j))
5419 return 0;
5421 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0];
5422 bytes.low = 0x00;
5423 if (!daa_load(&bytes, j))
5424 return 0;
5426 if (!SCI_Control(j, SCI_End))
5427 return 0;
5428 if (!SCI_WaitLowSCI(j))
5429 return 0;
5431 bytes.high = 0x04;
5432 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7];
5433 if (!daa_load(&bytes, j))
5434 return 0;
5436 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6];
5437 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5];
5438 if (!daa_load(&bytes, j))
5439 return 0;
5441 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4];
5442 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3];
5443 if (!daa_load(&bytes, j))
5444 return 0;
5446 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2];
5447 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1];
5448 if (!daa_load(&bytes, j))
5449 return 0;
5451 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0];
5452 bytes.low = 0x00;
5453 if (!daa_load(&bytes, j))
5454 return 0;
5456 if (!SCI_Control(j, SCI_End))
5457 return 0;
5458 if (!SCI_WaitLowSCI(j))
5459 return 0;
5461 bytes.high = 0x05;
5462 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7];
5463 if (!daa_load(&bytes, j))
5464 return 0;
5466 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6];
5467 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5];
5468 if (!daa_load(&bytes, j))
5469 return 0;
5471 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4];
5472 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3];
5473 if (!daa_load(&bytes, j))
5474 return 0;
5476 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2];
5477 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1];
5478 if (!daa_load(&bytes, j))
5479 return 0;
5481 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0];
5482 bytes.low = 0x00;
5483 if (!daa_load(&bytes, j))
5484 return 0;
5486 if (!SCI_Control(j, SCI_End))
5487 return 0;
5488 if (!SCI_WaitLowSCI(j))
5489 return 0;
5491 bytes.high = 0x06;
5492 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7];
5493 if (!daa_load(&bytes, j))
5494 return 0;
5496 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6];
5497 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5];
5498 if (!daa_load(&bytes, j))
5499 return 0;
5501 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4];
5502 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3];
5503 if (!daa_load(&bytes, j))
5504 return 0;
5506 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2];
5507 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1];
5508 if (!daa_load(&bytes, j))
5509 return 0;
5511 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0];
5512 bytes.low = 0x00;
5513 if (!daa_load(&bytes, j))
5514 return 0;
5516 if (!SCI_Control(j, SCI_End))
5517 return 0;
5518 if (!SCI_WaitLowSCI(j))
5519 return 0;
5521 bytes.high = 0x07;
5522 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7];
5523 if (!daa_load(&bytes, j))
5524 return 0;
5526 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6];
5527 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5];
5528 if (!daa_load(&bytes, j))
5529 return 0;
5531 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4];
5532 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3];
5533 if (!daa_load(&bytes, j))
5534 return 0;
5536 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2];
5537 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1];
5538 if (!daa_load(&bytes, j))
5539 return 0;
5541 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0];
5542 bytes.low = 0x00;
5543 if (!daa_load(&bytes, j))
5544 return 0;
5546 if (!SCI_Control(j, SCI_End))
5547 return 0;
5548 if (!SCI_WaitLowSCI(j))
5549 return 0;
5551 bytes.high = 0x08;
5552 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7];
5553 if (!daa_load(&bytes, j))
5554 return 0;
5556 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6];
5557 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5];
5558 if (!daa_load(&bytes, j))
5559 return 0;
5561 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4];
5562 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3];
5563 if (!daa_load(&bytes, j))
5564 return 0;
5566 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2];
5567 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1];
5568 if (!daa_load(&bytes, j))
5569 return 0;
5571 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0];
5572 bytes.low = 0x00;
5573 if (!daa_load(&bytes, j))
5574 return 0;
5576 if (!SCI_Control(j, SCI_End))
5577 return 0;
5578 if (!SCI_WaitLowSCI(j))
5579 return 0;
5581 bytes.high = 0x09;
5582 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3];
5583 if (!daa_load(&bytes, j))
5584 return 0;
5586 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2];
5587 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1];
5588 if (!daa_load(&bytes, j))
5589 return 0;
5591 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0];
5592 bytes.low = 0x00;
5593 if (!daa_load(&bytes, j))
5594 return 0;
5596 if (!SCI_Control(j, SCI_End))
5597 return 0;
5598 if (!SCI_WaitLowSCI(j))
5599 return 0;
5601 bytes.high = 0x0A;
5602 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3];
5603 if (!daa_load(&bytes, j))
5604 return 0;
5606 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2];
5607 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1];
5608 if (!daa_load(&bytes, j))
5609 return 0;
5611 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0];
5612 bytes.low = 0x00;
5613 if (!daa_load(&bytes, j))
5614 return 0;
5616 if (!SCI_Control(j, SCI_End))
5617 return 0;
5618 if (!SCI_WaitLowSCI(j))
5619 return 0;
5621 bytes.high = 0x0B;
5622 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3];
5623 if (!daa_load(&bytes, j))
5624 return 0;
5626 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2];
5627 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1];
5628 if (!daa_load(&bytes, j))
5629 return 0;
5631 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0];
5632 bytes.low = 0x00;
5633 if (!daa_load(&bytes, j))
5634 return 0;
5636 if (!SCI_Control(j, SCI_End))
5637 return 0;
5638 if (!SCI_WaitLowSCI(j))
5639 return 0;
5641 bytes.high = 0x0C;
5642 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3];
5643 if (!daa_load(&bytes, j))
5644 return 0;
5646 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2];
5647 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1];
5648 if (!daa_load(&bytes, j))
5649 return 0;
5651 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0];
5652 bytes.low = 0x00;
5653 if (!daa_load(&bytes, j))
5654 return 0;
5656 if (!SCI_Control(j, SCI_End))
5657 return 0;
5658 if (!SCI_WaitLowSCI(j))
5659 return 0;
5661 bytes.high = 0x0D;
5662 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3];
5663 if (!daa_load(&bytes, j))
5664 return 0;
5666 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2];
5667 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1];
5668 if (!daa_load(&bytes, j))
5669 return 0;
5671 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0];
5672 bytes.low = 0x00;
5673 if (!daa_load(&bytes, j))
5674 return 0;
5676 if (!SCI_Control(j, SCI_End))
5677 return 0;
5678 if (!SCI_WaitLowSCI(j))
5679 return 0;
5681 bytes.high = 0x0E;
5682 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7];
5683 if (!daa_load(&bytes, j))
5684 return 0;
5686 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6];
5687 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5];
5688 if (!daa_load(&bytes, j))
5689 return 0;
5691 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4];
5692 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3];
5693 if (!daa_load(&bytes, j))
5694 return 0;
5696 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2];
5697 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1];
5698 if (!daa_load(&bytes, j))
5699 return 0;
5701 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0];
5702 bytes.low = 0x00;
5703 if (!daa_load(&bytes, j))
5704 return 0;
5706 if (!SCI_Control(j, SCI_End))
5707 return 0;
5708 if (!SCI_WaitLowSCI(j))
5709 return 0;
5711 bytes.high = 0x0F;
5712 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7];
5713 if (!daa_load(&bytes, j))
5714 return 0;
5716 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6];
5717 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5];
5718 if (!daa_load(&bytes, j))
5719 return 0;
5721 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4];
5722 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3];
5723 if (!daa_load(&bytes, j))
5724 return 0;
5726 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2];
5727 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1];
5728 if (!daa_load(&bytes, j))
5729 return 0;
5731 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0];
5732 bytes.low = 0x00;
5733 if (!daa_load(&bytes, j))
5734 return 0;
5736 udelay(32);
5737 j->pld_scrr.byte = inb_p(j->XILINXbase);
5738 if (!SCI_Control(j, SCI_End))
5739 return 0;
5741 outb_p(j->pld_scrw.byte, j->XILINXbase);
5743 if (ixjdebug & 0x0002)
5744 printk("DAA Coefficients Loaded\n");
5746 j->flags.pstncheck = 0;
5747 return 1;
5750 int ixj_set_tone_off(unsigned short arg, IXJ *j)
5752 j->tone_off_time = arg;
5753 if (ixj_WriteDSPCommand(0x6E05, j)) /* Set Tone Off Period */
5755 return -1;
5756 if (ixj_WriteDSPCommand(arg, j))
5757 return -1;
5758 return 0;
5761 static int ixj_get_tone_on(IXJ *j)
5763 if (ixj_WriteDSPCommand(0x6E06, j)) /* Get Tone On Period */
5765 return -1;
5766 return 0;
5769 static int ixj_get_tone_off(IXJ *j)
5771 if (ixj_WriteDSPCommand(0x6E07, j)) /* Get Tone Off Period */
5773 return -1;
5774 return 0;
5777 static void ixj_busytone(IXJ *j)
5779 j->flags.ringback = 0;
5780 j->flags.dialtone = 0;
5781 j->flags.busytone = 1;
5782 ixj_set_tone_on(0x07D0, j);
5783 ixj_set_tone_off(0x07D0, j);
5784 ixj_play_tone(j, 27);
5787 static void ixj_dialtone(IXJ *j)
5789 j->flags.ringback = 0;
5790 j->flags.dialtone = 1;
5791 j->flags.busytone = 0;
5792 if (j->dsp.low == 0x20) {
5793 return;
5794 } else {
5795 ixj_set_tone_on(0xFFFF, j);
5796 ixj_set_tone_off(0x0000, j);
5797 ixj_play_tone(j, 25);
5801 static void ixj_cpt_stop(IXJ *j)
5803 if(j->tone_state || j->tone_cadence_state)
5805 j->flags.dialtone = 0;
5806 j->flags.busytone = 0;
5807 j->flags.ringback = 0;
5808 ixj_set_tone_on(0x0001, j);
5809 ixj_set_tone_off(0x0000, j);
5810 ixj_play_tone(j, 0);
5811 j->tone_state = j->tone_cadence_state = 0;
5812 if (j->cadence_t) {
5813 if (j->cadence_t->ce) {
5814 kfree(j->cadence_t->ce);
5816 kfree(j->cadence_t);
5817 j->cadence_t = NULL;
5820 if (j->play_mode == -1 && j->rec_mode == -1)
5821 idle(j);
5822 if (j->play_mode != -1 && j->dsp.low == 0x20)
5823 ixj_play_start(j);
5824 if (j->rec_mode != -1 && j->dsp.low == 0x20)
5825 ixj_record_start(j);
5828 static void ixj_ringback(IXJ *j)
5830 j->flags.busytone = 0;
5831 j->flags.dialtone = 0;
5832 j->flags.ringback = 1;
5833 ixj_set_tone_on(0x0FA0, j);
5834 ixj_set_tone_off(0x2EE0, j);
5835 ixj_play_tone(j, 26);
5838 static void ixj_testram(IXJ *j)
5840 ixj_WriteDSPCommand(0x3001, j); /* Test External SRAM */
5843 static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp)
5845 ixj_cadence *lcp;
5846 IXJ_CADENCE_ELEMENT __user *cep;
5847 IXJ_CADENCE_ELEMENT *lcep;
5848 IXJ_TONE ti;
5849 int err;
5851 lcp = kmalloc(sizeof(ixj_cadence), GFP_KERNEL);
5852 if (lcp == NULL)
5853 return -ENOMEM;
5855 err = -EFAULT;
5856 if (copy_from_user(&lcp->elements_used,
5857 &cp->elements_used, sizeof(int)))
5858 goto out;
5859 if (copy_from_user(&lcp->termination,
5860 &cp->termination, sizeof(IXJ_CADENCE_TERM)))
5861 goto out;
5862 if (get_user(cep, &cp->ce))
5863 goto out;
5865 err = -EINVAL;
5866 if ((unsigned)lcp->elements_used >= ~0U/sizeof(IXJ_CADENCE_ELEMENT))
5867 goto out;
5869 err = -ENOMEM;
5870 lcep = kmalloc(sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used, GFP_KERNEL);
5871 if (!lcep)
5872 goto out;
5874 err = -EFAULT;
5875 if (copy_from_user(lcep, cep, sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used))
5876 goto out1;
5878 if (j->cadence_t) {
5879 kfree(j->cadence_t->ce);
5880 kfree(j->cadence_t);
5882 lcp->ce = (void *) lcep;
5883 j->cadence_t = lcp;
5884 j->tone_cadence_state = 0;
5885 ixj_set_tone_on(lcp->ce[0].tone_on_time, j);
5886 ixj_set_tone_off(lcp->ce[0].tone_off_time, j);
5887 if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
5888 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
5889 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
5890 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
5891 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
5892 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
5893 ixj_init_tone(j, &ti);
5895 ixj_play_tone(j, lcp->ce[0].index);
5896 return 1;
5897 out1:
5898 kfree(lcep);
5899 out:
5900 kfree(lcp);
5901 return err;
5904 static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp)
5906 IXJ_FILTER_CADENCE *lcp;
5907 lcp = kmalloc(sizeof(IXJ_FILTER_CADENCE), GFP_KERNEL);
5908 if (lcp == NULL) {
5909 if(ixjdebug & 0x0001) {
5910 printk(KERN_INFO "Could not allocate memory for cadence\n");
5912 return -ENOMEM;
5914 if (copy_from_user(lcp, cp, sizeof(IXJ_FILTER_CADENCE))) {
5915 if(ixjdebug & 0x0001) {
5916 printk(KERN_INFO "Could not copy cadence to kernel\n");
5918 kfree(lcp);
5919 return -EFAULT;
5921 if (lcp->filter > 5) {
5922 if(ixjdebug & 0x0001) {
5923 printk(KERN_INFO "Cadence out of range\n");
5925 kfree(lcp);
5926 return -1;
5928 j->cadence_f[lcp->filter].state = 0;
5929 j->cadence_f[lcp->filter].enable = lcp->enable;
5930 j->filter_en[lcp->filter] = j->cadence_f[lcp->filter].en_filter = lcp->en_filter;
5931 j->cadence_f[lcp->filter].on1 = lcp->on1;
5932 j->cadence_f[lcp->filter].on1min = 0;
5933 j->cadence_f[lcp->filter].on1max = 0;
5934 j->cadence_f[lcp->filter].off1 = lcp->off1;
5935 j->cadence_f[lcp->filter].off1min = 0;
5936 j->cadence_f[lcp->filter].off1max = 0;
5937 j->cadence_f[lcp->filter].on2 = lcp->on2;
5938 j->cadence_f[lcp->filter].on2min = 0;
5939 j->cadence_f[lcp->filter].on2max = 0;
5940 j->cadence_f[lcp->filter].off2 = lcp->off2;
5941 j->cadence_f[lcp->filter].off2min = 0;
5942 j->cadence_f[lcp->filter].off2max = 0;
5943 j->cadence_f[lcp->filter].on3 = lcp->on3;
5944 j->cadence_f[lcp->filter].on3min = 0;
5945 j->cadence_f[lcp->filter].on3max = 0;
5946 j->cadence_f[lcp->filter].off3 = lcp->off3;
5947 j->cadence_f[lcp->filter].off3min = 0;
5948 j->cadence_f[lcp->filter].off3max = 0;
5949 if(ixjdebug & 0x0002) {
5950 printk(KERN_INFO "Cadence %d loaded\n", lcp->filter);
5952 kfree(lcp);
5953 return 0;
5956 static void add_caps(IXJ *j)
5958 j->caps = 0;
5959 j->caplist[j->caps].cap = PHONE_VENDOR_QUICKNET;
5960 strcpy(j->caplist[j->caps].desc, "Quicknet Technologies, Inc. (www.quicknet.net)");
5961 j->caplist[j->caps].captype = vendor;
5962 j->caplist[j->caps].handle = j->caps++;
5963 j->caplist[j->caps].captype = device;
5964 switch (j->cardtype) {
5965 case QTI_PHONEJACK:
5966 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK");
5967 break;
5968 case QTI_LINEJACK:
5969 strcpy(j->caplist[j->caps].desc, "Quicknet Internet LineJACK");
5970 break;
5971 case QTI_PHONEJACK_LITE:
5972 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK Lite");
5973 break;
5974 case QTI_PHONEJACK_PCI:
5975 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK PCI");
5976 break;
5977 case QTI_PHONECARD:
5978 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneCARD");
5979 break;
5981 j->caplist[j->caps].cap = j->cardtype;
5982 j->caplist[j->caps].handle = j->caps++;
5983 strcpy(j->caplist[j->caps].desc, "POTS");
5984 j->caplist[j->caps].captype = port;
5985 j->caplist[j->caps].cap = pots;
5986 j->caplist[j->caps].handle = j->caps++;
5988 /* add devices that can do speaker/mic */
5989 switch (j->cardtype) {
5990 case QTI_PHONEJACK:
5991 case QTI_LINEJACK:
5992 case QTI_PHONEJACK_PCI:
5993 case QTI_PHONECARD:
5994 strcpy(j->caplist[j->caps].desc, "SPEAKER");
5995 j->caplist[j->caps].captype = port;
5996 j->caplist[j->caps].cap = speaker;
5997 j->caplist[j->caps].handle = j->caps++;
5998 default:
5999 break;
6002 /* add devices that can do handset */
6003 switch (j->cardtype) {
6004 case QTI_PHONEJACK:
6005 strcpy(j->caplist[j->caps].desc, "HANDSET");
6006 j->caplist[j->caps].captype = port;
6007 j->caplist[j->caps].cap = handset;
6008 j->caplist[j->caps].handle = j->caps++;
6009 break;
6010 default:
6011 break;
6014 /* add devices that can do PSTN */
6015 switch (j->cardtype) {
6016 case QTI_LINEJACK:
6017 strcpy(j->caplist[j->caps].desc, "PSTN");
6018 j->caplist[j->caps].captype = port;
6019 j->caplist[j->caps].cap = pstn;
6020 j->caplist[j->caps].handle = j->caps++;
6021 break;
6022 default:
6023 break;
6026 /* add codecs - all cards can do uLaw, linear 8/16, and Windows sound system */
6027 strcpy(j->caplist[j->caps].desc, "ULAW");
6028 j->caplist[j->caps].captype = codec;
6029 j->caplist[j->caps].cap = ULAW;
6030 j->caplist[j->caps].handle = j->caps++;
6032 strcpy(j->caplist[j->caps].desc, "LINEAR 16 bit");
6033 j->caplist[j->caps].captype = codec;
6034 j->caplist[j->caps].cap = LINEAR16;
6035 j->caplist[j->caps].handle = j->caps++;
6037 strcpy(j->caplist[j->caps].desc, "LINEAR 8 bit");
6038 j->caplist[j->caps].captype = codec;
6039 j->caplist[j->caps].cap = LINEAR8;
6040 j->caplist[j->caps].handle = j->caps++;
6042 strcpy(j->caplist[j->caps].desc, "Windows Sound System");
6043 j->caplist[j->caps].captype = codec;
6044 j->caplist[j->caps].cap = WSS;
6045 j->caplist[j->caps].handle = j->caps++;
6047 /* software ALAW codec, made from ULAW */
6048 strcpy(j->caplist[j->caps].desc, "ALAW");
6049 j->caplist[j->caps].captype = codec;
6050 j->caplist[j->caps].cap = ALAW;
6051 j->caplist[j->caps].handle = j->caps++;
6053 /* version 12 of the 8020 does the following codecs in a broken way */
6054 if (j->dsp.low != 0x20 || j->ver.low != 0x12) {
6055 strcpy(j->caplist[j->caps].desc, "G.723.1 6.3kbps");
6056 j->caplist[j->caps].captype = codec;
6057 j->caplist[j->caps].cap = G723_63;
6058 j->caplist[j->caps].handle = j->caps++;
6060 strcpy(j->caplist[j->caps].desc, "G.723.1 5.3kbps");
6061 j->caplist[j->caps].captype = codec;
6062 j->caplist[j->caps].cap = G723_53;
6063 j->caplist[j->caps].handle = j->caps++;
6065 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.8kbps");
6066 j->caplist[j->caps].captype = codec;
6067 j->caplist[j->caps].cap = TS48;
6068 j->caplist[j->caps].handle = j->caps++;
6070 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.1kbps");
6071 j->caplist[j->caps].captype = codec;
6072 j->caplist[j->caps].cap = TS41;
6073 j->caplist[j->caps].handle = j->caps++;
6076 /* 8020 chips can do TS8.5 native, and 8021/8022 can load it */
6077 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
6078 strcpy(j->caplist[j->caps].desc, "TrueSpeech 8.5kbps");
6079 j->caplist[j->caps].captype = codec;
6080 j->caplist[j->caps].cap = TS85;
6081 j->caplist[j->caps].handle = j->caps++;
6084 /* 8021 chips can do G728 */
6085 if (j->dsp.low == 0x21) {
6086 strcpy(j->caplist[j->caps].desc, "G.728 16kbps");
6087 j->caplist[j->caps].captype = codec;
6088 j->caplist[j->caps].cap = G728;
6089 j->caplist[j->caps].handle = j->caps++;
6092 /* 8021/8022 chips can do G729 if loaded */
6093 if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
6094 strcpy(j->caplist[j->caps].desc, "G.729A 8kbps");
6095 j->caplist[j->caps].captype = codec;
6096 j->caplist[j->caps].cap = G729;
6097 j->caplist[j->caps].handle = j->caps++;
6099 if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
6100 strcpy(j->caplist[j->caps].desc, "G.729B 8kbps");
6101 j->caplist[j->caps].captype = codec;
6102 j->caplist[j->caps].cap = G729B;
6103 j->caplist[j->caps].handle = j->caps++;
6107 static int capabilities_check(IXJ *j, struct phone_capability *pcreq)
6109 int cnt;
6110 int retval = 0;
6111 for (cnt = 0; cnt < j->caps; cnt++) {
6112 if (pcreq->captype == j->caplist[cnt].captype
6113 && pcreq->cap == j->caplist[cnt].cap) {
6114 retval = 1;
6115 break;
6118 return retval;
6121 static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, unsigned long arg)
6123 IXJ_TONE ti;
6124 IXJ_FILTER jf;
6125 IXJ_FILTER_RAW jfr;
6126 void __user *argp = (void __user *)arg;
6128 unsigned int raise, mant;
6129 unsigned int minor = iminor(inode);
6130 int board = NUM(inode);
6132 IXJ *j = get_ixj(NUM(inode));
6134 int retval = 0;
6137 * Set up locks to ensure that only one process is talking to the DSP at a time.
6138 * This is necessary to keep the DSP from locking up.
6140 while(test_and_set_bit(board, (void *)&j->busyflags) != 0) {
6141 set_current_state(TASK_INTERRUPTIBLE);
6142 schedule_timeout(1);
6144 if (ixjdebug & 0x0040)
6145 printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
6146 if (minor >= IXJMAX) {
6147 clear_bit(board, &j->busyflags);
6148 return -ENODEV;
6151 * Check ioctls only root can use.
6153 if (!capable(CAP_SYS_ADMIN)) {
6154 switch (cmd) {
6155 case IXJCTL_TESTRAM:
6156 case IXJCTL_HZ:
6157 retval = -EPERM;
6160 switch (cmd) {
6161 case IXJCTL_TESTRAM:
6162 ixj_testram(j);
6163 retval = (j->ssr.high << 8) + j->ssr.low;
6164 break;
6165 case IXJCTL_CARDTYPE:
6166 retval = j->cardtype;
6167 break;
6168 case IXJCTL_SERIAL:
6169 retval = j->serial;
6170 break;
6171 case IXJCTL_VERSION:
6173 char arg_str[100];
6174 snprintf(arg_str, sizeof(arg_str),
6175 "\nDriver version %i.%i.%i", IXJ_VER_MAJOR,
6176 IXJ_VER_MINOR, IXJ_BLD_VER);
6177 if (copy_to_user(argp, arg_str, strlen(arg_str)))
6178 retval = -EFAULT;
6180 break;
6181 case PHONE_RING_CADENCE:
6182 j->ring_cadence = arg;
6183 break;
6184 case IXJCTL_CIDCW:
6185 if(arg) {
6186 if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) {
6187 retval = -EFAULT;
6188 break;
6190 } else {
6191 memset(&j->cid_send, 0, sizeof(PHONE_CID));
6193 ixj_write_cidcw(j);
6194 break;
6195 /* Binary compatbility */
6196 case OLD_PHONE_RING_START:
6197 arg = 0;
6198 /* Fall through */
6199 case PHONE_RING_START:
6200 if(arg) {
6201 if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) {
6202 retval = -EFAULT;
6203 break;
6205 ixj_write_cid(j);
6206 } else {
6207 memset(&j->cid_send, 0, sizeof(PHONE_CID));
6209 ixj_ring_start(j);
6210 break;
6211 case PHONE_RING_STOP:
6212 j->flags.cringing = 0;
6213 if(j->cadence_f[5].enable) {
6214 j->cadence_f[5].state = 0;
6216 ixj_ring_off(j);
6217 break;
6218 case PHONE_RING:
6219 retval = ixj_ring(j);
6220 break;
6221 case PHONE_EXCEPTION:
6222 retval = j->ex.bytes;
6223 if(j->ex.bits.flash) {
6224 j->flash_end = 0;
6225 j->ex.bits.flash = 0;
6227 j->ex.bits.pstn_ring = 0;
6228 j->ex.bits.caller_id = 0;
6229 j->ex.bits.pstn_wink = 0;
6230 j->ex.bits.f0 = 0;
6231 j->ex.bits.f1 = 0;
6232 j->ex.bits.f2 = 0;
6233 j->ex.bits.f3 = 0;
6234 j->ex.bits.fc0 = 0;
6235 j->ex.bits.fc1 = 0;
6236 j->ex.bits.fc2 = 0;
6237 j->ex.bits.fc3 = 0;
6238 j->ex.bits.reserved = 0;
6239 break;
6240 case PHONE_HOOKSTATE:
6241 j->ex.bits.hookstate = 0;
6242 retval = j->hookstate; //j->r_hook;
6243 break;
6244 case IXJCTL_SET_LED:
6245 LED_SetState(arg, j);
6246 break;
6247 case PHONE_FRAME:
6248 retval = set_base_frame(j, arg);
6249 break;
6250 case PHONE_REC_CODEC:
6251 retval = set_rec_codec(j, arg);
6252 break;
6253 case PHONE_VAD:
6254 ixj_vad(j, arg);
6255 break;
6256 case PHONE_REC_START:
6257 ixj_record_start(j);
6258 break;
6259 case PHONE_REC_STOP:
6260 ixj_record_stop(j);
6261 break;
6262 case PHONE_REC_DEPTH:
6263 set_rec_depth(j, arg);
6264 break;
6265 case PHONE_REC_VOLUME:
6266 if(arg == -1) {
6267 retval = get_rec_volume(j);
6269 else {
6270 set_rec_volume(j, arg);
6271 retval = arg;
6273 break;
6274 case PHONE_REC_VOLUME_LINEAR:
6275 if(arg == -1) {
6276 retval = get_rec_volume_linear(j);
6278 else {
6279 set_rec_volume_linear(j, arg);
6280 retval = arg;
6282 break;
6283 case IXJCTL_DTMF_PRESCALE:
6284 if(arg == -1) {
6285 retval = get_dtmf_prescale(j);
6287 else {
6288 set_dtmf_prescale(j, arg);
6289 retval = arg;
6291 break;
6292 case PHONE_REC_LEVEL:
6293 retval = get_rec_level(j);
6294 break;
6295 case IXJCTL_SC_RXG:
6296 retval = ixj_siadc(j, arg);
6297 break;
6298 case IXJCTL_SC_TXG:
6299 retval = ixj_sidac(j, arg);
6300 break;
6301 case IXJCTL_AEC_START:
6302 ixj_aec_start(j, arg);
6303 break;
6304 case IXJCTL_AEC_STOP:
6305 aec_stop(j);
6306 break;
6307 case IXJCTL_AEC_GET_LEVEL:
6308 retval = j->aec_level;
6309 break;
6310 case PHONE_PLAY_CODEC:
6311 retval = set_play_codec(j, arg);
6312 break;
6313 case PHONE_PLAY_START:
6314 retval = ixj_play_start(j);
6315 break;
6316 case PHONE_PLAY_STOP:
6317 ixj_play_stop(j);
6318 break;
6319 case PHONE_PLAY_DEPTH:
6320 set_play_depth(j, arg);
6321 break;
6322 case PHONE_PLAY_VOLUME:
6323 if(arg == -1) {
6324 retval = get_play_volume(j);
6326 else {
6327 set_play_volume(j, arg);
6328 retval = arg;
6330 break;
6331 case PHONE_PLAY_VOLUME_LINEAR:
6332 if(arg == -1) {
6333 retval = get_play_volume_linear(j);
6335 else {
6336 set_play_volume_linear(j, arg);
6337 retval = arg;
6339 break;
6340 case PHONE_PLAY_LEVEL:
6341 retval = get_play_level(j);
6342 break;
6343 case IXJCTL_DSP_TYPE:
6344 retval = (j->dsp.high << 8) + j->dsp.low;
6345 break;
6346 case IXJCTL_DSP_VERSION:
6347 retval = (j->ver.high << 8) + j->ver.low;
6348 break;
6349 case IXJCTL_HZ:
6350 hertz = arg;
6351 break;
6352 case IXJCTL_RATE:
6353 if (arg > hertz)
6354 retval = -1;
6355 else
6356 samplerate = arg;
6357 break;
6358 case IXJCTL_DRYBUFFER_READ:
6359 put_user(j->drybuffer, (unsigned long __user *) argp);
6360 break;
6361 case IXJCTL_DRYBUFFER_CLEAR:
6362 j->drybuffer = 0;
6363 break;
6364 case IXJCTL_FRAMES_READ:
6365 put_user(j->framesread, (unsigned long __user *) argp);
6366 break;
6367 case IXJCTL_FRAMES_WRITTEN:
6368 put_user(j->frameswritten, (unsigned long __user *) argp);
6369 break;
6370 case IXJCTL_READ_WAIT:
6371 put_user(j->read_wait, (unsigned long __user *) argp);
6372 break;
6373 case IXJCTL_WRITE_WAIT:
6374 put_user(j->write_wait, (unsigned long __user *) argp);
6375 break;
6376 case PHONE_MAXRINGS:
6377 j->maxrings = arg;
6378 break;
6379 case PHONE_SET_TONE_ON_TIME:
6380 ixj_set_tone_on(arg, j);
6381 break;
6382 case PHONE_SET_TONE_OFF_TIME:
6383 ixj_set_tone_off(arg, j);
6384 break;
6385 case PHONE_GET_TONE_ON_TIME:
6386 if (ixj_get_tone_on(j)) {
6387 retval = -1;
6388 } else {
6389 retval = (j->ssr.high << 8) + j->ssr.low;
6391 break;
6392 case PHONE_GET_TONE_OFF_TIME:
6393 if (ixj_get_tone_off(j)) {
6394 retval = -1;
6395 } else {
6396 retval = (j->ssr.high << 8) + j->ssr.low;
6398 break;
6399 case PHONE_PLAY_TONE:
6400 if (!j->tone_state)
6401 retval = ixj_play_tone(j, arg);
6402 else
6403 retval = -1;
6404 break;
6405 case PHONE_GET_TONE_STATE:
6406 retval = j->tone_state;
6407 break;
6408 case PHONE_DTMF_READY:
6409 retval = j->ex.bits.dtmf_ready;
6410 break;
6411 case PHONE_GET_DTMF:
6412 if (ixj_hookstate(j)) {
6413 if (j->dtmf_rp != j->dtmf_wp) {
6414 retval = j->dtmfbuffer[j->dtmf_rp];
6415 j->dtmf_rp++;
6416 if (j->dtmf_rp == 79)
6417 j->dtmf_rp = 0;
6418 if (j->dtmf_rp == j->dtmf_wp) {
6419 j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
6423 break;
6424 case PHONE_GET_DTMF_ASCII:
6425 if (ixj_hookstate(j)) {
6426 if (j->dtmf_rp != j->dtmf_wp) {
6427 switch (j->dtmfbuffer[j->dtmf_rp]) {
6428 case 10:
6429 retval = 42; /* '*'; */
6431 break;
6432 case 11:
6433 retval = 48; /*'0'; */
6435 break;
6436 case 12:
6437 retval = 35; /*'#'; */
6439 break;
6440 case 28:
6441 retval = 65; /*'A'; */
6443 break;
6444 case 29:
6445 retval = 66; /*'B'; */
6447 break;
6448 case 30:
6449 retval = 67; /*'C'; */
6451 break;
6452 case 31:
6453 retval = 68; /*'D'; */
6455 break;
6456 default:
6457 retval = 48 + j->dtmfbuffer[j->dtmf_rp];
6458 break;
6460 j->dtmf_rp++;
6461 if (j->dtmf_rp == 79)
6462 j->dtmf_rp = 0;
6463 if(j->dtmf_rp == j->dtmf_wp)
6465 j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
6469 break;
6470 case PHONE_DTMF_OOB:
6471 j->flags.dtmf_oob = arg;
6472 break;
6473 case PHONE_DIALTONE:
6474 ixj_dialtone(j);
6475 break;
6476 case PHONE_BUSY:
6477 ixj_busytone(j);
6478 break;
6479 case PHONE_RINGBACK:
6480 ixj_ringback(j);
6481 break;
6482 case PHONE_WINK:
6483 if(j->cardtype == QTI_PHONEJACK)
6484 retval = -1;
6485 else
6486 retval = ixj_wink(j);
6487 break;
6488 case PHONE_CPT_STOP:
6489 ixj_cpt_stop(j);
6490 break;
6491 case PHONE_QUERY_CODEC:
6493 struct phone_codec_data pd;
6494 int val;
6495 int proto_size[] = {
6497 12, 10, 16, 9, 8, 48, 5,
6498 40, 40, 80, 40, 40, 6
6500 if(copy_from_user(&pd, argp, sizeof(pd))) {
6501 retval = -EFAULT;
6502 break;
6504 if(pd.type<1 || pd.type>13) {
6505 retval = -EPROTONOSUPPORT;
6506 break;
6508 if(pd.type<G729)
6509 val=proto_size[pd.type];
6510 else switch(j->baseframe.low)
6512 case 0xA0:val=2*proto_size[pd.type];break;
6513 case 0x50:val=proto_size[pd.type];break;
6514 default:val=proto_size[pd.type]*3;break;
6516 pd.buf_min=pd.buf_max=pd.buf_opt=val;
6517 if(copy_to_user(argp, &pd, sizeof(pd)))
6518 retval = -EFAULT;
6519 break;
6521 case IXJCTL_DSP_IDLE:
6522 idle(j);
6523 break;
6524 case IXJCTL_MIXER:
6525 if ((arg & 0xff) == 0xff)
6526 retval = ixj_get_mixer(arg, j);
6527 else
6528 ixj_mixer(arg, j);
6529 break;
6530 case IXJCTL_DAA_COEFF_SET:
6531 switch (arg) {
6532 case DAA_US:
6533 DAA_Coeff_US(j);
6534 retval = ixj_daa_write(j);
6535 break;
6536 case DAA_UK:
6537 DAA_Coeff_UK(j);
6538 retval = ixj_daa_write(j);
6539 break;
6540 case DAA_FRANCE:
6541 DAA_Coeff_France(j);
6542 retval = ixj_daa_write(j);
6543 break;
6544 case DAA_GERMANY:
6545 DAA_Coeff_Germany(j);
6546 retval = ixj_daa_write(j);
6547 break;
6548 case DAA_AUSTRALIA:
6549 DAA_Coeff_Australia(j);
6550 retval = ixj_daa_write(j);
6551 break;
6552 case DAA_JAPAN:
6553 DAA_Coeff_Japan(j);
6554 retval = ixj_daa_write(j);
6555 break;
6556 default:
6557 retval = 1;
6558 break;
6560 break;
6561 case IXJCTL_DAA_AGAIN:
6562 ixj_daa_cr4(j, arg | 0x02);
6563 break;
6564 case IXJCTL_PSTN_LINETEST:
6565 retval = ixj_linetest(j);
6566 break;
6567 case IXJCTL_VMWI:
6568 ixj_write_vmwi(j, arg);
6569 break;
6570 case IXJCTL_CID:
6571 if (copy_to_user(argp, &j->cid, sizeof(PHONE_CID)))
6572 retval = -EFAULT;
6573 j->ex.bits.caller_id = 0;
6574 break;
6575 case IXJCTL_WINK_DURATION:
6576 j->winktime = arg;
6577 break;
6578 case IXJCTL_PORT:
6579 if (arg)
6580 retval = ixj_set_port(j, arg);
6581 else
6582 retval = j->port;
6583 break;
6584 case IXJCTL_POTS_PSTN:
6585 retval = ixj_set_pots(j, arg);
6586 break;
6587 case PHONE_CAPABILITIES:
6588 add_caps(j);
6589 retval = j->caps;
6590 break;
6591 case PHONE_CAPABILITIES_LIST:
6592 add_caps(j);
6593 if (copy_to_user(argp, j->caplist, sizeof(struct phone_capability) * j->caps))
6594 retval = -EFAULT;
6595 break;
6596 case PHONE_CAPABILITIES_CHECK:
6598 struct phone_capability cap;
6599 if (copy_from_user(&cap, argp, sizeof(cap)))
6600 retval = -EFAULT;
6601 else {
6602 add_caps(j);
6603 retval = capabilities_check(j, &cap);
6606 break;
6607 case PHONE_PSTN_SET_STATE:
6608 daa_set_mode(j, arg);
6609 break;
6610 case PHONE_PSTN_GET_STATE:
6611 retval = j->daa_mode;
6612 j->ex.bits.pstn_ring = 0;
6613 break;
6614 case IXJCTL_SET_FILTER:
6615 if (copy_from_user(&jf, argp, sizeof(jf)))
6616 retval = -EFAULT;
6617 retval = ixj_init_filter(j, &jf);
6618 break;
6619 case IXJCTL_SET_FILTER_RAW:
6620 if (copy_from_user(&jfr, argp, sizeof(jfr)))
6621 retval = -EFAULT;
6622 else
6623 retval = ixj_init_filter_raw(j, &jfr);
6624 break;
6625 case IXJCTL_GET_FILTER_HIST:
6626 if(arg<0||arg>3)
6627 retval = -EINVAL;
6628 else
6629 retval = j->filter_hist[arg];
6630 break;
6631 case IXJCTL_INIT_TONE:
6632 if (copy_from_user(&ti, argp, sizeof(ti)))
6633 retval = -EFAULT;
6634 else
6635 retval = ixj_init_tone(j, &ti);
6636 break;
6637 case IXJCTL_TONE_CADENCE:
6638 retval = ixj_build_cadence(j, argp);
6639 break;
6640 case IXJCTL_FILTER_CADENCE:
6641 retval = ixj_build_filter_cadence(j, argp);
6642 break;
6643 case IXJCTL_SIGCTL:
6644 if (copy_from_user(&j->sigdef, argp, sizeof(IXJ_SIGDEF))) {
6645 retval = -EFAULT;
6646 break;
6648 j->ixj_signals[j->sigdef.event] = j->sigdef.signal;
6649 if(j->sigdef.event < 33) {
6650 raise = 1;
6651 for(mant = 0; mant < j->sigdef.event; mant++){
6652 raise *= 2;
6654 if(j->sigdef.signal)
6655 j->ex_sig.bytes |= raise;
6656 else
6657 j->ex_sig.bytes &= (raise^0xffff);
6659 break;
6660 case IXJCTL_INTERCOM_STOP:
6661 if(arg < 0 || arg >= IXJMAX)
6662 return -EINVAL;
6663 j->intercom = -1;
6664 ixj_record_stop(j);
6665 ixj_play_stop(j);
6666 idle(j);
6667 get_ixj(arg)->intercom = -1;
6668 ixj_record_stop(get_ixj(arg));
6669 ixj_play_stop(get_ixj(arg));
6670 idle(get_ixj(arg));
6671 break;
6672 case IXJCTL_INTERCOM_START:
6673 if(arg < 0 || arg >= IXJMAX)
6674 return -EINVAL;
6675 j->intercom = arg;
6676 ixj_record_start(j);
6677 ixj_play_start(j);
6678 get_ixj(arg)->intercom = board;
6679 ixj_play_start(get_ixj(arg));
6680 ixj_record_start(get_ixj(arg));
6681 break;
6683 if (ixjdebug & 0x0040)
6684 printk("phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
6685 clear_bit(board, &j->busyflags);
6686 return retval;
6689 static int ixj_fasync(int fd, struct file *file_p, int mode)
6691 IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
6693 return fasync_helper(fd, file_p, mode, &j->async_queue);
6696 static struct file_operations ixj_fops =
6698 .owner = THIS_MODULE,
6699 .read = ixj_enhanced_read,
6700 .write = ixj_enhanced_write,
6701 .poll = ixj_poll,
6702 .ioctl = ixj_ioctl,
6703 .release = ixj_release,
6704 .fasync = ixj_fasync
6707 static int ixj_linetest(IXJ *j)
6709 unsigned long jifwait;
6711 j->flags.pstncheck = 1; /* Testing */
6712 j->flags.pstn_present = 0; /* Assume the line is not there */
6714 daa_int_read(j); /*Clear DAA Interrupt flags */
6715 /* */
6716 /* Hold all relays in the normally de-energized position. */
6717 /* */
6719 j->pld_slicw.bits.rly1 = 0;
6720 j->pld_slicw.bits.rly2 = 0;
6721 j->pld_slicw.bits.rly3 = 0;
6722 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6723 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6725 outb_p(j->pld_scrw.byte, j->XILINXbase);
6726 j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
6727 if (j->pld_slicr.bits.potspstn) {
6728 j->flags.pots_pstn = 1;
6729 j->flags.pots_correct = 0;
6730 LED_SetState(0x4, j);
6731 } else {
6732 j->flags.pots_pstn = 0;
6733 j->pld_slicw.bits.rly1 = 0;
6734 j->pld_slicw.bits.rly2 = 0;
6735 j->pld_slicw.bits.rly3 = 1;
6736 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6737 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6739 outb_p(j->pld_scrw.byte, j->XILINXbase);
6740 daa_set_mode(j, SOP_PU_CONVERSATION);
6741 jifwait = jiffies + hertz;
6742 while (time_before(jiffies, jifwait)) {
6743 set_current_state(TASK_INTERRUPTIBLE);
6744 schedule_timeout(1);
6746 daa_int_read(j);
6747 daa_set_mode(j, SOP_PU_RESET);
6748 if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
6749 j->flags.pots_correct = 0; /* Should not be line voltage on POTS port. */
6750 LED_SetState(0x4, j);
6751 j->pld_slicw.bits.rly3 = 0;
6752 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6753 } else {
6754 j->flags.pots_correct = 1;
6755 LED_SetState(0x8, j);
6756 j->pld_slicw.bits.rly1 = 1;
6757 j->pld_slicw.bits.rly2 = 0;
6758 j->pld_slicw.bits.rly3 = 0;
6759 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6762 j->pld_slicw.bits.rly3 = 0;
6763 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6764 daa_set_mode(j, SOP_PU_CONVERSATION);
6765 jifwait = jiffies + hertz;
6766 while (time_before(jiffies, jifwait)) {
6767 set_current_state(TASK_INTERRUPTIBLE);
6768 schedule_timeout(1);
6770 daa_int_read(j);
6771 daa_set_mode(j, SOP_PU_RESET);
6772 if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
6773 j->pstn_sleeptil = jiffies + (hertz / 4);
6774 j->flags.pstn_present = 1;
6775 } else {
6776 j->flags.pstn_present = 0;
6778 if (j->flags.pstn_present) {
6779 if (j->flags.pots_correct) {
6780 LED_SetState(0xA, j);
6781 } else {
6782 LED_SetState(0x6, j);
6784 } else {
6785 if (j->flags.pots_correct) {
6786 LED_SetState(0x9, j);
6787 } else {
6788 LED_SetState(0x5, j);
6791 j->flags.pstncheck = 0; /* Testing */
6792 return j->flags.pstn_present;
6795 static int ixj_selfprobe(IXJ *j)
6797 unsigned short cmd;
6798 unsigned long jif;
6799 int cnt;
6800 BYTES bytes;
6802 init_waitqueue_head(&j->poll_q);
6803 init_waitqueue_head(&j->read_q);
6804 init_waitqueue_head(&j->write_q);
6806 while(atomic_read(&j->DSPWrite) > 0)
6807 atomic_dec(&j->DSPWrite);
6808 if (ixjdebug & 0x0002)
6809 printk(KERN_INFO "Write IDLE to Software Control Register\n");
6810 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
6812 if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
6813 return -1;
6814 /* The read values of the SSR should be 0x00 for the IDLE command */
6815 if (j->ssr.low || j->ssr.high)
6816 return -1;
6817 if (ixjdebug & 0x0002)
6818 printk(KERN_INFO "Get Device ID Code\n");
6819 if (ixj_WriteDSPCommand(0x3400, j)) /* Get Device ID Code */
6820 return -1;
6821 j->dsp.low = j->ssr.low;
6822 j->dsp.high = j->ssr.high;
6823 if (ixjdebug & 0x0002)
6824 printk(KERN_INFO "Get Device Version Code\n");
6825 if (ixj_WriteDSPCommand(0x3800, j)) /* Get Device Version Code */
6826 return -1;
6827 j->ver.low = j->ssr.low;
6828 j->ver.high = j->ssr.high;
6829 if (!j->cardtype) {
6830 if (j->dsp.low == 0x21) {
6831 bytes.high = bytes.low = inb_p(j->XILINXbase + 0x02);
6832 outb_p(bytes.low ^ 0xFF, j->XILINXbase + 0x02);
6833 /* Test for Internet LineJACK or Internet PhoneJACK Lite */
6834 bytes.low = inb_p(j->XILINXbase + 0x02);
6835 if (bytes.low == bytes.high) /* Register is read only on */
6836 /* Internet PhoneJack Lite */
6838 j->cardtype = QTI_PHONEJACK_LITE;
6839 if (!request_region(j->XILINXbase, 4, "ixj control")) {
6840 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6841 return -1;
6843 j->pld_slicw.pcib.e1 = 1;
6844 outb_p(j->pld_slicw.byte, j->XILINXbase);
6845 } else {
6846 j->cardtype = QTI_LINEJACK;
6848 if (!request_region(j->XILINXbase, 8, "ixj control")) {
6849 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6850 return -1;
6853 } else if (j->dsp.low == 0x22) {
6854 j->cardtype = QTI_PHONEJACK_PCI;
6855 request_region(j->XILINXbase, 4, "ixj control");
6856 j->pld_slicw.pcib.e1 = 1;
6857 outb_p(j->pld_slicw.byte, j->XILINXbase);
6858 } else
6859 j->cardtype = QTI_PHONEJACK;
6860 } else {
6861 switch (j->cardtype) {
6862 case QTI_PHONEJACK:
6863 if (!j->dsp.low != 0x20) {
6864 j->dsp.high = 0x80;
6865 j->dsp.low = 0x20;
6866 ixj_WriteDSPCommand(0x3800, j);
6867 j->ver.low = j->ssr.low;
6868 j->ver.high = j->ssr.high;
6870 break;
6871 case QTI_LINEJACK:
6872 if (!request_region(j->XILINXbase, 8, "ixj control")) {
6873 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6874 return -1;
6876 break;
6877 case QTI_PHONEJACK_LITE:
6878 case QTI_PHONEJACK_PCI:
6879 if (!request_region(j->XILINXbase, 4, "ixj control")) {
6880 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6881 return -1;
6883 j->pld_slicw.pcib.e1 = 1;
6884 outb_p(j->pld_slicw.byte, j->XILINXbase);
6885 break;
6886 case QTI_PHONECARD:
6887 break;
6890 if (j->dsp.low == 0x20 || j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
6891 if (ixjdebug & 0x0002)
6892 printk(KERN_INFO "Write CODEC config to Software Control Register\n");
6893 if (ixj_WriteDSPCommand(0xC462, j)) /* Write CODEC config to Software Control Register */
6894 return -1;
6895 if (ixjdebug & 0x0002)
6896 printk(KERN_INFO "Write CODEC timing to Software Control Register\n");
6897 if (j->cardtype == QTI_PHONEJACK) {
6898 cmd = 0x9FF2;
6899 } else {
6900 cmd = 0x9FF5;
6902 if (ixj_WriteDSPCommand(cmd, j)) /* Write CODEC timing to Software Control Register */
6903 return -1;
6904 } else {
6905 if (set_base_frame(j, 30) != 30)
6906 return -1;
6907 if (ixjdebug & 0x0002)
6908 printk(KERN_INFO "Write CODEC config to Software Control Register\n");
6909 if (j->cardtype == QTI_PHONECARD) {
6910 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
6911 return -1;
6913 if (j->cardtype == QTI_LINEJACK) {
6914 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
6915 return -1;
6916 if (ixjdebug & 0x0002)
6917 printk(KERN_INFO "Turn on the PLD Clock at 8Khz\n");
6918 j->pld_clock.byte = 0;
6919 outb_p(j->pld_clock.byte, j->XILINXbase + 0x04);
6923 if (j->dsp.low == 0x20) {
6924 if (ixjdebug & 0x0002)
6925 printk(KERN_INFO "Configure GPIO pins\n");
6926 j->gpio.bytes.high = 0x09;
6927 /* bytes.low = 0xEF; 0xF7 */
6928 j->gpio.bits.gpio1 = 1;
6929 j->gpio.bits.gpio2 = 1;
6930 j->gpio.bits.gpio3 = 0;
6931 j->gpio.bits.gpio4 = 1;
6932 j->gpio.bits.gpio5 = 1;
6933 j->gpio.bits.gpio6 = 1;
6934 j->gpio.bits.gpio7 = 1;
6935 ixj_WriteDSPCommand(j->gpio.word, j); /* Set GPIO pin directions */
6936 if (ixjdebug & 0x0002)
6937 printk(KERN_INFO "Enable SLIC\n");
6938 j->gpio.bytes.high = 0x0B;
6939 j->gpio.bytes.low = 0x00;
6940 j->gpio.bits.gpio1 = 0;
6941 j->gpio.bits.gpio2 = 1;
6942 j->gpio.bits.gpio5 = 0;
6943 ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring stop signal */
6944 j->port = PORT_POTS;
6945 } else {
6946 if (j->cardtype == QTI_LINEJACK) {
6947 LED_SetState(0x1, j);
6948 jif = jiffies + (hertz / 10);
6949 while (time_before(jiffies, jif)) {
6950 set_current_state(TASK_INTERRUPTIBLE);
6951 schedule_timeout(1);
6953 LED_SetState(0x2, j);
6954 jif = jiffies + (hertz / 10);
6955 while (time_before(jiffies, jif)) {
6956 set_current_state(TASK_INTERRUPTIBLE);
6957 schedule_timeout(1);
6959 LED_SetState(0x4, j);
6960 jif = jiffies + (hertz / 10);
6961 while (time_before(jiffies, jif)) {
6962 set_current_state(TASK_INTERRUPTIBLE);
6963 schedule_timeout(1);
6965 LED_SetState(0x8, j);
6966 jif = jiffies + (hertz / 10);
6967 while (time_before(jiffies, jif)) {
6968 set_current_state(TASK_INTERRUPTIBLE);
6969 schedule_timeout(1);
6971 LED_SetState(0x0, j);
6972 daa_get_version(j);
6973 if (ixjdebug & 0x0002)
6974 printk("Loading DAA Coefficients\n");
6975 DAA_Coeff_US(j);
6976 if (!ixj_daa_write(j)) {
6977 printk("DAA write failed on board %d\n", j->board);
6978 return -1;
6980 if(!ixj_daa_cid_reset(j)) {
6981 printk("DAA CID reset failed on board %d\n", j->board);
6982 return -1;
6984 j->flags.pots_correct = 0;
6985 j->flags.pstn_present = 0;
6986 ixj_linetest(j);
6987 if (j->flags.pots_correct) {
6988 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6990 outb_p(j->pld_scrw.byte, j->XILINXbase);
6991 j->pld_slicw.bits.rly1 = 1;
6992 j->pld_slicw.bits.spken = 1;
6993 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6994 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
6995 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
6996 j->port = PORT_POTS;
6998 ixj_set_port(j, PORT_PSTN);
6999 ixj_set_pots(j, 1);
7000 if (ixjdebug & 0x0002)
7001 printk(KERN_INFO "Enable Mixer\n");
7002 ixj_mixer(0x0000, j); /*Master Volume Left unmute 0db */
7003 ixj_mixer(0x0100, j); /*Master Volume Right unmute 0db */
7005 ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
7006 ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
7008 ixj_mixer(0x0480, j); /*FM Left mute */
7009 ixj_mixer(0x0580, j); /*FM Right mute */
7011 ixj_mixer(0x0680, j); /*CD Left mute */
7012 ixj_mixer(0x0780, j); /*CD Right mute */
7014 ixj_mixer(0x0880, j); /*Line Left mute */
7015 ixj_mixer(0x0980, j); /*Line Right mute */
7017 ixj_mixer(0x0A80, j); /*Aux left mute */
7018 ixj_mixer(0x0B80, j); /*Aux right mute */
7020 ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
7021 ixj_mixer(0x0D80, j); /*Mono2 mute */
7023 ixj_mixer(0x0E80, j); /*Mic mute */
7025 ixj_mixer(0x0F00, j); /*Mono Out Volume unmute 0db */
7027 ixj_mixer(0x1000, j); /*Voice Left and Right out only */
7028 ixj_mixer(0x110C, j);
7031 ixj_mixer(0x1200, j); /*Mono1 switch on mixer left */
7032 ixj_mixer(0x1401, j);
7034 ixj_mixer(0x1300, j); /*Mono1 switch on mixer right */
7035 ixj_mixer(0x1501, j);
7037 ixj_mixer(0x1700, j); /*Clock select */
7039 ixj_mixer(0x1800, j); /*ADC input from mixer */
7041 ixj_mixer(0x1901, j); /*Mic gain 30db */
7043 if (ixjdebug & 0x0002)
7044 printk(KERN_INFO "Setting Default US Ring Cadence Detection\n");
7045 j->cadence_f[4].state = 0;
7046 j->cadence_f[4].on1 = 0; /*Cadence Filter 4 is used for PSTN ring cadence */
7047 j->cadence_f[4].off1 = 0;
7048 j->cadence_f[4].on2 = 0;
7049 j->cadence_f[4].off2 = 0;
7050 j->cadence_f[4].on3 = 0;
7051 j->cadence_f[4].off3 = 0; /* These should represent standard US ring pulse. */
7052 j->pstn_last_rmr = jiffies;
7054 } else {
7055 if (j->cardtype == QTI_PHONECARD) {
7056 ixj_WriteDSPCommand(0xCF07, j);
7057 ixj_WriteDSPCommand(0x00B0, j);
7058 ixj_set_port(j, PORT_SPEAKER);
7059 } else {
7060 ixj_set_port(j, PORT_POTS);
7061 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
7062 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
7067 j->intercom = -1;
7068 j->framesread = j->frameswritten = 0;
7069 j->read_wait = j->write_wait = 0;
7070 j->rxreadycheck = j->txreadycheck = 0;
7072 /* initialise the DTMF prescale to a sensible value */
7073 if (j->cardtype == QTI_LINEJACK) {
7074 set_dtmf_prescale(j, 0x10);
7075 } else {
7076 set_dtmf_prescale(j, 0x40);
7078 set_play_volume(j, 0x100);
7079 set_rec_volume(j, 0x100);
7081 if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
7082 return -1;
7083 /* The read values of the SSR should be 0x00 for the IDLE command */
7084 if (j->ssr.low || j->ssr.high)
7085 return -1;
7087 if (ixjdebug & 0x0002)
7088 printk(KERN_INFO "Enable Line Monitor\n");
7090 if (ixjdebug & 0x0002)
7091 printk(KERN_INFO "Set Line Monitor to Asyncronous Mode\n");
7093 if (ixj_WriteDSPCommand(0x7E01, j)) /* Asynchronous Line Monitor */
7094 return -1;
7096 if (ixjdebug & 0x002)
7097 printk(KERN_INFO "Enable DTMF Detectors\n");
7099 if (ixj_WriteDSPCommand(0x5151, j)) /* Enable DTMF detection */
7100 return -1;
7102 if (ixj_WriteDSPCommand(0x6E01, j)) /* Set Asyncronous Tone Generation */
7103 return -1;
7105 set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
7107 set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
7109 j->ex.bits.dtmf_ready = 0;
7110 j->dtmf_state = 0;
7111 j->dtmf_wp = j->dtmf_rp = 0;
7112 j->rec_mode = j->play_mode = -1;
7113 j->flags.ringing = 0;
7114 j->maxrings = MAXRINGS;
7115 j->ring_cadence = USA_RING_CADENCE;
7116 j->drybuffer = 0;
7117 j->winktime = 320;
7118 j->flags.dtmf_oob = 0;
7119 for (cnt = 0; cnt < 4; cnt++)
7120 j->cadence_f[cnt].enable = 0;
7121 /* must be a device on the specified address */
7122 ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
7124 /* Set up the default signals for events */
7125 for (cnt = 0; cnt < 35; cnt++)
7126 j->ixj_signals[cnt] = SIGIO;
7128 /* Set the excetion signal enable flags */
7129 j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
7130 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 =
7131 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;
7132 #ifdef IXJ_DYN_ALLOC
7133 j->fskdata = NULL;
7134 #endif
7135 j->fskdcnt = 0;
7136 j->cidcw_wait = 0;
7138 /* Register with the Telephony for Linux subsystem */
7139 j->p.f_op = &ixj_fops;
7140 j->p.open = ixj_open;
7141 j->p.board = j->board;
7142 phone_register_device(&j->p, PHONE_UNIT_ANY);
7144 ixj_init_timer(j);
7145 ixj_add_timer(j);
7146 return 0;
7150 * Exported service for pcmcia card handling
7153 IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx)
7155 IXJ *j = ixj_alloc();
7157 j->board = 0;
7159 j->DSPbase = dsp;
7160 j->XILINXbase = xilinx;
7161 j->cardtype = QTI_PHONECARD;
7162 ixj_selfprobe(j);
7163 return j;
7166 EXPORT_SYMBOL(ixj_pcmcia_probe); /* Fpr PCMCIA */
7168 static int ixj_get_status_proc(char *buf)
7170 int len;
7171 int cnt;
7172 IXJ *j;
7173 len = 0;
7174 len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER);
7175 len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ));
7176 len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS));
7177 len += sprintf(buf + len, "\nUsing old telephony API");
7178 len += sprintf(buf + len, "\nDebug Level %d\n", ixjdebug);
7180 for (cnt = 0; cnt < IXJMAX; cnt++) {
7181 j = get_ixj(cnt);
7182 if(j==NULL)
7183 continue;
7184 if (j->DSPbase) {
7185 len += sprintf(buf + len, "\nCard Num %d", cnt);
7186 len += sprintf(buf + len, "\nDSP Base Address 0x%4.4x", j->DSPbase);
7187 if (j->cardtype != QTI_PHONEJACK)
7188 len += sprintf(buf + len, "\nXILINX Base Address 0x%4.4x", j->XILINXbase);
7189 len += sprintf(buf + len, "\nDSP Type %2.2x%2.2x", j->dsp.high, j->dsp.low);
7190 len += sprintf(buf + len, "\nDSP Version %2.2x.%2.2x", j->ver.high, j->ver.low);
7191 len += sprintf(buf + len, "\nSerial Number %8.8x", j->serial);
7192 switch (j->cardtype) {
7193 case (QTI_PHONEJACK):
7194 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK");
7195 break;
7196 case (QTI_LINEJACK):
7197 len += sprintf(buf + len, "\nCard Type = Internet LineJACK");
7198 if (j->flags.g729_loaded)
7199 len += sprintf(buf + len, " w/G.729 A/B");
7200 len += sprintf(buf + len, " Country = %d", j->daa_country);
7201 break;
7202 case (QTI_PHONEJACK_LITE):
7203 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK Lite");
7204 if (j->flags.g729_loaded)
7205 len += sprintf(buf + len, " w/G.729 A/B");
7206 break;
7207 case (QTI_PHONEJACK_PCI):
7208 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK PCI");
7209 if (j->flags.g729_loaded)
7210 len += sprintf(buf + len, " w/G.729 A/B");
7211 break;
7212 case (QTI_PHONECARD):
7213 len += sprintf(buf + len, "\nCard Type = Internet PhoneCARD");
7214 if (j->flags.g729_loaded)
7215 len += sprintf(buf + len, " w/G.729 A/B");
7216 len += sprintf(buf + len, "\nSmart Cable %spresent", j->pccr1.bits.drf ? "not " : "");
7217 if (!j->pccr1.bits.drf)
7218 len += sprintf(buf + len, "\nSmart Cable type %d", j->flags.pcmciasct);
7219 len += sprintf(buf + len, "\nSmart Cable state %d", j->flags.pcmciastate);
7220 break;
7221 default:
7222 len += sprintf(buf + len, "\nCard Type = %d", j->cardtype);
7223 break;
7225 len += sprintf(buf + len, "\nReaders %d", j->readers);
7226 len += sprintf(buf + len, "\nWriters %d", j->writers);
7227 add_caps(j);
7228 len += sprintf(buf + len, "\nCapabilities %d", j->caps);
7229 if (j->dsp.low != 0x20)
7230 len += sprintf(buf + len, "\nDSP Processor load %d", j->proc_load);
7231 if (j->flags.cidsent)
7232 len += sprintf(buf + len, "\nCaller ID data sent");
7233 else
7234 len += sprintf(buf + len, "\nCaller ID data not sent");
7236 len += sprintf(buf + len, "\nPlay CODEC ");
7237 switch (j->play_codec) {
7238 case G723_63:
7239 len += sprintf(buf + len, "G.723.1 6.3");
7240 break;
7241 case G723_53:
7242 len += sprintf(buf + len, "G.723.1 5.3");
7243 break;
7244 case TS85:
7245 len += sprintf(buf + len, "TrueSpeech 8.5");
7246 break;
7247 case TS48:
7248 len += sprintf(buf + len, "TrueSpeech 4.8");
7249 break;
7250 case TS41:
7251 len += sprintf(buf + len, "TrueSpeech 4.1");
7252 break;
7253 case G728:
7254 len += sprintf(buf + len, "G.728");
7255 break;
7256 case G729:
7257 len += sprintf(buf + len, "G.729");
7258 break;
7259 case G729B:
7260 len += sprintf(buf + len, "G.729B");
7261 break;
7262 case ULAW:
7263 len += sprintf(buf + len, "uLaw");
7264 break;
7265 case ALAW:
7266 len += sprintf(buf + len, "aLaw");
7267 break;
7268 case LINEAR16:
7269 len += sprintf(buf + len, "16 bit Linear");
7270 break;
7271 case LINEAR8:
7272 len += sprintf(buf + len, "8 bit Linear");
7273 break;
7274 case WSS:
7275 len += sprintf(buf + len, "Windows Sound System");
7276 break;
7277 default:
7278 len += sprintf(buf + len, "NO CODEC CHOSEN");
7279 break;
7281 len += sprintf(buf + len, "\nRecord CODEC ");
7282 switch (j->rec_codec) {
7283 case G723_63:
7284 len += sprintf(buf + len, "G.723.1 6.3");
7285 break;
7286 case G723_53:
7287 len += sprintf(buf + len, "G.723.1 5.3");
7288 break;
7289 case TS85:
7290 len += sprintf(buf + len, "TrueSpeech 8.5");
7291 break;
7292 case TS48:
7293 len += sprintf(buf + len, "TrueSpeech 4.8");
7294 break;
7295 case TS41:
7296 len += sprintf(buf + len, "TrueSpeech 4.1");
7297 break;
7298 case G728:
7299 len += sprintf(buf + len, "G.728");
7300 break;
7301 case G729:
7302 len += sprintf(buf + len, "G.729");
7303 break;
7304 case G729B:
7305 len += sprintf(buf + len, "G.729B");
7306 break;
7307 case ULAW:
7308 len += sprintf(buf + len, "uLaw");
7309 break;
7310 case ALAW:
7311 len += sprintf(buf + len, "aLaw");
7312 break;
7313 case LINEAR16:
7314 len += sprintf(buf + len, "16 bit Linear");
7315 break;
7316 case LINEAR8:
7317 len += sprintf(buf + len, "8 bit Linear");
7318 break;
7319 case WSS:
7320 len += sprintf(buf + len, "Windows Sound System");
7321 break;
7322 default:
7323 len += sprintf(buf + len, "NO CODEC CHOSEN");
7324 break;
7326 len += sprintf(buf + len, "\nAEC ");
7327 switch (j->aec_level) {
7328 case AEC_OFF:
7329 len += sprintf(buf + len, "Off");
7330 break;
7331 case AEC_LOW:
7332 len += sprintf(buf + len, "Low");
7333 break;
7334 case AEC_MED:
7335 len += sprintf(buf + len, "Med");
7336 break;
7337 case AEC_HIGH:
7338 len += sprintf(buf + len, "High");
7339 break;
7340 case AEC_AUTO:
7341 len += sprintf(buf + len, "Auto");
7342 break;
7343 case AEC_AGC:
7344 len += sprintf(buf + len, "AEC/AGC");
7345 break;
7346 default:
7347 len += sprintf(buf + len, "unknown(%i)", j->aec_level);
7348 break;
7351 len += sprintf(buf + len, "\nRec volume 0x%x", get_rec_volume(j));
7352 len += sprintf(buf + len, "\nPlay volume 0x%x", get_play_volume(j));
7353 len += sprintf(buf + len, "\nDTMF prescale 0x%x", get_dtmf_prescale(j));
7355 len += sprintf(buf + len, "\nHook state %d", j->hookstate); /* j->r_hook); */
7357 if (j->cardtype == QTI_LINEJACK) {
7358 len += sprintf(buf + len, "\nPOTS Correct %d", j->flags.pots_correct);
7359 len += sprintf(buf + len, "\nPSTN Present %d", j->flags.pstn_present);
7360 len += sprintf(buf + len, "\nPSTN Check %d", j->flags.pstncheck);
7361 len += sprintf(buf + len, "\nPOTS to PSTN %d", j->flags.pots_pstn);
7362 switch (j->daa_mode) {
7363 case SOP_PU_SLEEP:
7364 len += sprintf(buf + len, "\nDAA PSTN On Hook");
7365 break;
7366 case SOP_PU_RINGING:
7367 len += sprintf(buf + len, "\nDAA PSTN Ringing");
7368 len += sprintf(buf + len, "\nRinging state = %d", j->cadence_f[4].state);
7369 break;
7370 case SOP_PU_CONVERSATION:
7371 len += sprintf(buf + len, "\nDAA PSTN Off Hook");
7372 break;
7373 case SOP_PU_PULSEDIALING:
7374 len += sprintf(buf + len, "\nDAA PSTN Pulse Dialing");
7375 break;
7377 len += sprintf(buf + len, "\nDAA RMR = %d", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR);
7378 len += sprintf(buf + len, "\nDAA VDD OK = %d", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK);
7379 len += sprintf(buf + len, "\nDAA CR0 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg);
7380 len += sprintf(buf + len, "\nDAA CR1 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg);
7381 len += sprintf(buf + len, "\nDAA CR2 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg);
7382 len += sprintf(buf + len, "\nDAA CR3 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg);
7383 len += sprintf(buf + len, "\nDAA CR4 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg);
7384 len += sprintf(buf + len, "\nDAA CR5 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg);
7385 len += sprintf(buf + len, "\nDAA XR0 = 0x%02x", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg);
7386 len += sprintf(buf + len, "\nDAA ringstop %ld - jiffies %ld", j->pstn_ring_stop, jiffies);
7388 switch (j->port) {
7389 case PORT_POTS:
7390 len += sprintf(buf + len, "\nPort POTS");
7391 break;
7392 case PORT_PSTN:
7393 len += sprintf(buf + len, "\nPort PSTN");
7394 break;
7395 case PORT_SPEAKER:
7396 len += sprintf(buf + len, "\nPort SPEAKER/MIC");
7397 break;
7398 case PORT_HANDSET:
7399 len += sprintf(buf + len, "\nPort HANDSET");
7400 break;
7402 if (j->dsp.low == 0x21 || j->dsp.low == 0x22) {
7403 len += sprintf(buf + len, "\nSLIC state ");
7404 switch (SLIC_GetState(j)) {
7405 case PLD_SLIC_STATE_OC:
7406 len += sprintf(buf + len, "OC");
7407 break;
7408 case PLD_SLIC_STATE_RINGING:
7409 len += sprintf(buf + len, "RINGING");
7410 break;
7411 case PLD_SLIC_STATE_ACTIVE:
7412 len += sprintf(buf + len, "ACTIVE");
7413 break;
7414 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
7415 len += sprintf(buf + len, "OHT");
7416 break;
7417 case PLD_SLIC_STATE_TIPOPEN:
7418 len += sprintf(buf + len, "TIPOPEN");
7419 break;
7420 case PLD_SLIC_STATE_STANDBY:
7421 len += sprintf(buf + len, "STANDBY");
7422 break;
7423 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
7424 len += sprintf(buf + len, "APR");
7425 break;
7426 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
7427 len += sprintf(buf + len, "OHTPR");
7428 break;
7429 default:
7430 len += sprintf(buf + len, "%d", SLIC_GetState(j));
7431 break;
7434 len += sprintf(buf + len, "\nBase Frame %2.2x.%2.2x", j->baseframe.high, j->baseframe.low);
7435 len += sprintf(buf + len, "\nCID Base Frame %2d", j->cid_base_frame_size);
7436 #ifdef PERFMON_STATS
7437 len += sprintf(buf + len, "\nTimer Checks %ld", j->timerchecks);
7438 len += sprintf(buf + len, "\nRX Ready Checks %ld", j->rxreadycheck);
7439 len += sprintf(buf + len, "\nTX Ready Checks %ld", j->txreadycheck);
7440 len += sprintf(buf + len, "\nFrames Read %ld", j->framesread);
7441 len += sprintf(buf + len, "\nFrames Written %ld", j->frameswritten);
7442 len += sprintf(buf + len, "\nDry Buffer %ld", j->drybuffer);
7443 len += sprintf(buf + len, "\nRead Waits %ld", j->read_wait);
7444 len += sprintf(buf + len, "\nWrite Waits %ld", j->write_wait);
7445 len += sprintf(buf + len, "\nStatus Waits %ld", j->statuswait);
7446 len += sprintf(buf + len, "\nStatus Wait Fails %ld", j->statuswaitfail);
7447 len += sprintf(buf + len, "\nPControl Waits %ld", j->pcontrolwait);
7448 len += sprintf(buf + len, "\nPControl Wait Fails %ld", j->pcontrolwaitfail);
7449 len += sprintf(buf + len, "\nIs Control Ready Checks %ld", j->iscontrolready);
7450 len += sprintf(buf + len, "\nIs Control Ready Check failures %ld", j->iscontrolreadyfail);
7452 #endif
7453 len += sprintf(buf + len, "\n");
7456 return len;
7459 static int ixj_read_proc(char *page, char **start, off_t off,
7460 int count, int *eof, void *data)
7462 int len = ixj_get_status_proc(page);
7463 if (len <= off+count) *eof = 1;
7464 *start = page + off;
7465 len -= off;
7466 if (len>count) len = count;
7467 if (len<0) len = 0;
7468 return len;
7472 static void cleanup(void)
7474 int cnt;
7475 IXJ *j;
7477 for (cnt = 0; cnt < IXJMAX; cnt++) {
7478 j = get_ixj(cnt);
7479 if(j != NULL && j->DSPbase) {
7480 if (ixjdebug & 0x0002)
7481 printk(KERN_INFO "IXJ: Deleting timer for /dev/phone%d\n", cnt);
7482 del_timer(&j->timer);
7483 if (j->cardtype == QTI_LINEJACK) {
7484 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
7486 outb_p(j->pld_scrw.byte, j->XILINXbase);
7487 j->pld_slicw.bits.rly1 = 0;
7488 j->pld_slicw.bits.rly2 = 0;
7489 j->pld_slicw.bits.rly3 = 0;
7490 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
7491 LED_SetState(0x0, j);
7492 if (ixjdebug & 0x0002)
7493 printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
7494 release_region(j->XILINXbase, 8);
7495 } else if (j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
7496 if (ixjdebug & 0x0002)
7497 printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
7498 release_region(j->XILINXbase, 4);
7500 if (j->read_buffer)
7501 kfree(j->read_buffer);
7502 if (j->write_buffer)
7503 kfree(j->write_buffer);
7504 if (j->dev)
7505 pnp_device_detach(j->dev);
7506 if (ixjdebug & 0x0002)
7507 printk(KERN_INFO "IXJ: Unregistering /dev/phone%d from LTAPI\n", cnt);
7508 phone_unregister_device(&j->p);
7509 if (ixjdebug & 0x0002)
7510 printk(KERN_INFO "IXJ: Releasing DSP address for /dev/phone%d\n", cnt);
7511 release_region(j->DSPbase, 16);
7512 #ifdef IXJ_DYN_ALLOC
7513 if (ixjdebug & 0x0002)
7514 printk(KERN_INFO "IXJ: Freeing memory for /dev/phone%d\n", cnt);
7515 kfree(j);
7516 ixj[cnt] = NULL;
7517 #endif
7520 if (ixjdebug & 0x0002)
7521 printk(KERN_INFO "IXJ: Removing /proc/ixj\n");
7522 remove_proc_entry ("ixj", NULL);
7525 /* Typedefs */
7526 typedef struct {
7527 BYTE length;
7528 DWORD bits;
7529 } DATABLOCK;
7531 static void PCIEE_WriteBit(WORD wEEPROMAddress, BYTE lastLCC, BYTE byData)
7533 lastLCC = lastLCC & 0xfb;
7534 lastLCC = lastLCC | (byData ? 4 : 0);
7535 outb(lastLCC, wEEPROMAddress); /*set data out bit as appropriate */
7537 mdelay(1);
7538 lastLCC = lastLCC | 0x01;
7539 outb(lastLCC, wEEPROMAddress); /*SK rising edge */
7541 byData = byData << 1;
7542 lastLCC = lastLCC & 0xfe;
7543 mdelay(1);
7544 outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
7548 static BYTE PCIEE_ReadBit(WORD wEEPROMAddress, BYTE lastLCC)
7550 mdelay(1);
7551 lastLCC = lastLCC | 0x01;
7552 outb(lastLCC, wEEPROMAddress); /*SK rising edge */
7554 lastLCC = lastLCC & 0xfe;
7555 mdelay(1);
7556 outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
7558 return ((inb(wEEPROMAddress) >> 3) & 1);
7561 static BOOL PCIEE_ReadWord(WORD wAddress, WORD wLoc, WORD * pwResult)
7563 BYTE lastLCC;
7564 WORD wEEPROMAddress = wAddress + 3;
7565 DWORD i;
7566 BYTE byResult;
7567 *pwResult = 0;
7568 lastLCC = inb(wEEPROMAddress);
7569 lastLCC = lastLCC | 0x02;
7570 lastLCC = lastLCC & 0xfe;
7571 outb(lastLCC, wEEPROMAddress); /* CS hi, SK lo */
7573 mdelay(1); /* delay */
7575 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
7576 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
7577 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 0);
7578 for (i = 0; i < 8; i++) {
7579 PCIEE_WriteBit(wEEPROMAddress, lastLCC, wLoc & 0x80 ? 1 : 0);
7580 wLoc <<= 1;
7583 for (i = 0; i < 16; i++) {
7584 byResult = PCIEE_ReadBit(wEEPROMAddress, lastLCC);
7585 *pwResult = (*pwResult << 1) | byResult;
7588 mdelay(1); /* another delay */
7590 lastLCC = lastLCC & 0xfd;
7591 outb(lastLCC, wEEPROMAddress); /* negate CS */
7593 return 0;
7596 static DWORD PCIEE_GetSerialNumber(WORD wAddress)
7598 WORD wLo, wHi;
7599 if (PCIEE_ReadWord(wAddress, 62, &wLo))
7600 return 0;
7601 if (PCIEE_ReadWord(wAddress, 63, &wHi))
7602 return 0;
7603 return (((DWORD) wHi << 16) | wLo);
7606 static int dspio[IXJMAX + 1] =
7610 static int xio[IXJMAX + 1] =
7615 module_param_array(dspio, int, NULL, 0);
7616 module_param_array(xio, int, NULL, 0);
7617 MODULE_DESCRIPTION("Quicknet VoIP Telephony card module - www.quicknet.net");
7618 MODULE_AUTHOR("Ed Okerson <eokerson@quicknet.net>");
7619 MODULE_LICENSE("GPL");
7621 static void __exit ixj_exit(void)
7623 cleanup();
7626 static IXJ *new_ixj(unsigned long port)
7628 IXJ *res;
7629 if (!request_region(port, 16, "ixj DSP")) {
7630 printk(KERN_INFO "ixj: can't get I/O address 0x%lx\n", port);
7631 return NULL;
7633 res = ixj_alloc();
7634 if (!res) {
7635 release_region(port, 16);
7636 printk(KERN_INFO "ixj: out of memory\n");
7637 return NULL;
7639 res->DSPbase = port;
7640 return res;
7643 static int __init ixj_probe_isapnp(int *cnt)
7645 int probe = 0;
7646 int func = 0x110;
7647 struct pnp_dev *dev = NULL, *old_dev = NULL;
7649 while (1) {
7650 do {
7651 IXJ *j;
7652 int result;
7654 old_dev = dev;
7655 dev = pnp_find_dev(NULL, ISAPNP_VENDOR('Q', 'T', 'I'),
7656 ISAPNP_FUNCTION(func), old_dev);
7657 if (!dev || !dev->card)
7658 break;
7659 result = pnp_device_attach(dev);
7660 if (result < 0) {
7661 printk("pnp attach failed %d \n", result);
7662 break;
7664 if (pnp_activate_dev(dev) < 0) {
7665 printk("pnp activate failed (out of resources?)\n");
7666 pnp_device_detach(dev);
7667 return -ENOMEM;
7670 if (!pnp_port_valid(dev, 0)) {
7671 pnp_device_detach(dev);
7672 return -ENODEV;
7675 j = new_ixj(pnp_port_start(dev, 0));
7676 if (!j)
7677 break;
7679 if (func != 0x110)
7680 j->XILINXbase = pnp_port_start(dev, 1); /* get real port */
7682 switch (func) {
7683 case (0x110):
7684 j->cardtype = QTI_PHONEJACK;
7685 break;
7686 case (0x310):
7687 j->cardtype = QTI_LINEJACK;
7688 break;
7689 case (0x410):
7690 j->cardtype = QTI_PHONEJACK_LITE;
7691 break;
7693 j->board = *cnt;
7694 probe = ixj_selfprobe(j);
7695 if(!probe) {
7696 j->serial = dev->card->serial;
7697 j->dev = dev;
7698 switch (func) {
7699 case 0x110:
7700 printk(KERN_INFO "ixj: found Internet PhoneJACK at 0x%x\n", j->DSPbase);
7701 break;
7702 case 0x310:
7703 printk(KERN_INFO "ixj: found Internet LineJACK at 0x%x\n", j->DSPbase);
7704 break;
7705 case 0x410:
7706 printk(KERN_INFO "ixj: found Internet PhoneJACK Lite at 0x%x\n", j->DSPbase);
7707 break;
7710 ++*cnt;
7711 } while (dev);
7712 if (func == 0x410)
7713 break;
7714 if (func == 0x310)
7715 func = 0x410;
7716 if (func == 0x110)
7717 func = 0x310;
7718 dev = NULL;
7720 return probe;
7723 static int __init ixj_probe_isa(int *cnt)
7725 int i, probe;
7727 /* Use passed parameters for older kernels without PnP */
7728 for (i = 0; i < IXJMAX; i++) {
7729 if (dspio[i]) {
7730 IXJ *j = new_ixj(dspio[i]);
7732 if (!j)
7733 break;
7735 j->XILINXbase = xio[i];
7736 j->cardtype = 0;
7738 j->board = *cnt;
7739 probe = ixj_selfprobe(j);
7740 j->dev = NULL;
7741 ++*cnt;
7744 return 0;
7747 static int __init ixj_probe_pci(int *cnt)
7749 struct pci_dev *pci = NULL;
7750 int i, probe = 0;
7751 IXJ *j = NULL;
7753 for (i = 0; i < IXJMAX - *cnt; i++) {
7754 pci = pci_find_device(0x15E2, 0x0500, pci);
7755 if (!pci)
7756 break;
7758 if (pci_enable_device(pci))
7759 break;
7760 j = new_ixj(pci_resource_start(pci, 0));
7761 if (!j)
7762 break;
7764 j->serial = (PCIEE_GetSerialNumber)pci_resource_start(pci, 2);
7765 j->XILINXbase = j->DSPbase + 0x10;
7766 j->cardtype = QTI_PHONEJACK_PCI;
7767 j->board = *cnt;
7768 probe = ixj_selfprobe(j);
7769 if (!probe)
7770 printk(KERN_INFO "ixj: found Internet PhoneJACK PCI at 0x%x\n", j->DSPbase);
7771 ++*cnt;
7773 return probe;
7776 static int __init ixj_init(void)
7778 int cnt = 0;
7779 int probe = 0;
7781 cnt = 0;
7783 /* These might be no-ops, see above. */
7784 if ((probe = ixj_probe_isapnp(&cnt)) < 0) {
7785 return probe;
7787 if ((probe = ixj_probe_isa(&cnt)) < 0) {
7788 return probe;
7790 if ((probe = ixj_probe_pci(&cnt)) < 0) {
7791 return probe;
7793 printk(KERN_INFO "ixj driver initialized.\n");
7794 create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL);
7795 return probe;
7798 module_init(ixj_init);
7799 module_exit(ixj_exit);
7801 static void DAA_Coeff_US(IXJ *j)
7803 int i;
7805 j->daa_country = DAA_US;
7806 /*----------------------------------------------- */
7807 /* CAO */
7808 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
7809 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
7812 /* Bytes for IM-filter part 1 (04): 0E,32,E2,2F,C2,5A,C0,00 */
7813 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x03;
7814 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0x4B;
7815 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x5D;
7816 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xCD;
7817 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x24;
7818 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xC5;
7819 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
7820 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
7821 /* Bytes for IM-filter part 2 (05): 72,85,00,0E,2B,3A,D0,08 */
7822 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x71;
7823 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x1A;
7824 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
7825 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
7826 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xB5;
7827 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
7828 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
7829 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
7830 /* Bytes for FRX-filter (08): 03,8F,48,F2,8F,48,70,08 */
7831 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x05;
7832 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xA3;
7833 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x72;
7834 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
7835 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x3F;
7836 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x3B;
7837 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
7838 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
7839 /* Bytes for FRR-filter (07): 04,8F,38,7F,9B,EA,B0,08 */
7840 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x05;
7841 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
7842 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
7843 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x3E;
7844 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x32;
7845 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xDA;
7846 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
7847 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
7848 /* Bytes for AX-filter (0A): 16,55,DD,CA */
7849 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x41;
7850 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
7851 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
7852 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
7853 /* Bytes for AR-filter (09): 52,D3,11,42 */
7854 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
7855 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
7856 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
7857 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
7858 /* Bytes for TH-filter part 1 (00): 00,42,48,81,B3,80,00,98 */
7859 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
7860 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
7861 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
7862 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
7863 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA5;
7864 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
7865 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
7866 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
7867 /* Bytes for TH-filter part 2 (01): 02,F2,33,A0,68,AB,8A,AD */
7868 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
7869 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xA2;
7870 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2B;
7871 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
7872 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
7873 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAB;
7874 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
7875 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xCC;
7876 /* Bytes for TH-filter part 3 (02): 00,88,DA,54,A4,BA,2D,BB */
7877 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
7878 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
7879 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xD2;
7880 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x24;
7881 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBA;
7882 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xA9;
7883 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x3B;
7884 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xA6;
7885 /* ; (10K, 0.68uF) */
7886 /* */
7887 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
7888 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
7889 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
7890 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
7891 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
7892 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
7893 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
7894 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
7895 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
7896 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
7897 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
7898 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
7899 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
7900 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
7901 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
7902 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
7903 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
7904 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
7906 /* Levelmetering Ringing (0D):B2,45,0F,8E */
7907 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
7908 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
7909 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
7910 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
7912 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
7913 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1C; */
7914 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0xB3; */
7915 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0xAB; */
7916 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xAB; */
7917 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x54; */
7918 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x2D; */
7919 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0x62; */
7920 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x2D; */
7921 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
7922 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x2D; */
7923 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x62; */
7924 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; */
7925 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBB; */
7926 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x2A; */
7927 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7D; */
7928 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; */
7929 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD4; */
7930 /* */
7931 /* Levelmetering Ringing (0D):B2,45,0F,8E */
7932 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; */
7933 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x05; */
7934 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; */
7935 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; */
7937 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
7938 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
7939 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
7940 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
7941 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
7942 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
7943 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
7944 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
7945 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
7946 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
7947 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
7948 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
7949 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
7950 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
7951 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
7952 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
7953 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
7954 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
7955 /* */
7956 /* ;CR Registers */
7957 /* Config. Reg. 0 (filters) (cr0):FE ; CLK gen. by crystal */
7958 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
7959 /* Config. Reg. 1 (dialing) (cr1):05 */
7960 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
7961 /* Config. Reg. 2 (caller ID) (cr2):04 */
7962 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
7963 /* Config. Reg. 3 (testloops) (cr3):03 ; SEL Bit==0, HP-disabled */
7964 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
7965 /* Config. Reg. 4 (analog gain) (cr4):02 */
7966 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
7967 /* Config. Reg. 5 (Version) (cr5):02 */
7968 /* Config. Reg. 6 (Reserved) (cr6):00 */
7969 /* Config. Reg. 7 (Reserved) (cr7):00 */
7970 /* */
7971 /* ;xr Registers */
7972 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
7974 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
7975 /* Ext. Reg. 1 (Interrupt enable) (xr1):3C Cadence, RING, Caller ID, VDD_OK */
7977 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x3C;
7978 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
7979 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
7980 /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off == 1 */
7981 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x3B; /*0x32; */
7982 /* Ext. Reg. 4 (Cadence) (xr4):00 */
7984 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
7985 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
7986 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
7987 /* Ext. Reg. 6 (Power State) (xr6):00 */
7988 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
7989 /* Ext. Reg. 7 (Vdd) (xr7):40 */
7990 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
7991 /* */
7992 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
7993 /* 12,33,5A,C3 ; 770 Hz */
7994 /* 13,3C,5B,32 ; 852 Hz */
7995 /* 1D,1B,5C,CC ; 941 Hz */
7997 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
7998 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
7999 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8000 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8001 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8002 /* EC,1D,52,22 ; 1336 Hz */
8003 /* AA,AC,51,D2 ; 1477 Hz */
8004 /* 9B,3B,51,25 ; 1633 Hz */
8005 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8006 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8007 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8008 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8011 static void DAA_Coeff_UK(IXJ *j)
8013 int i;
8015 j->daa_country = DAA_UK;
8016 /*----------------------------------------------- */
8017 /* CAO */
8018 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8019 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8022 /* Bytes for IM-filter part 1 (04): 00,C2,BB,A8,CB,81,A0,00 */
8023 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
8024 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xC2;
8025 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
8026 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xA8;
8027 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xCB;
8028 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
8029 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
8030 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8031 /* Bytes for IM-filter part 2 (05): 40,00,00,0A,A4,33,E0,08 */
8032 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x40;
8033 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x00;
8034 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8035 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
8036 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xA4;
8037 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8038 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8039 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8040 /* Bytes for FRX-filter (08): 07,9B,ED,24,B2,A2,A0,08 */
8041 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8042 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9B;
8043 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xED;
8044 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x24;
8045 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0xB2;
8046 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0xA2;
8047 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xA0;
8048 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8049 /* Bytes for FRR-filter (07): 0F,92,F2,B2,87,D2,30,08 */
8050 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
8051 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x92;
8052 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF2;
8053 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0xB2;
8054 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
8055 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xD2;
8056 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x30;
8057 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8058 /* Bytes for AX-filter (0A): 1B,A5,DD,CA */
8059 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x1B;
8060 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xA5;
8061 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8062 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8063 /* Bytes for AR-filter (09): E2,27,10,D6 */
8064 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
8065 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x27;
8066 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8067 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8068 /* Bytes for TH-filter part 1 (00): 80,2D,38,8B,D0,00,00,98 */
8069 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8070 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x2D;
8071 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x38;
8072 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x8B;
8073 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xD0;
8074 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x00;
8075 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8076 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8077 /* Bytes for TH-filter part 2 (01): 02,5A,53,F0,0B,5F,84,D4 */
8078 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8079 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x5A;
8080 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x53;
8081 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xF0;
8082 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x0B;
8083 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5F;
8084 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x84;
8085 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xD4;
8086 /* Bytes for TH-filter part 3 (02): 00,88,6A,A4,8F,52,F5,32 */
8087 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8088 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8089 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x6A;
8090 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA4;
8091 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x8F;
8092 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x52;
8093 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xF5;
8094 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x32;
8095 /* ; idle */
8096 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8097 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8098 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8099 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8100 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8101 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8102 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8103 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8104 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8105 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8106 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8107 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8108 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8109 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8110 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8111 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8112 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8113 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8114 /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V less possible? */
8115 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
8116 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
8117 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8118 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8119 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8120 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8121 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8122 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8123 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8124 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8125 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8126 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8127 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8128 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8129 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8130 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8131 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8132 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8133 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8134 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8135 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8136 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8137 /* ;CR Registers */
8138 /* Config. Reg. 0 (filters) (cr0):FF */
8139 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8140 /* Config. Reg. 1 (dialing) (cr1):05 */
8141 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8142 /* Config. Reg. 2 (caller ID) (cr2):04 */
8143 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8144 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8145 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8146 /* Config. Reg. 4 (analog gain) (cr4):02 */
8147 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8148 /* Config. Reg. 5 (Version) (cr5):02 */
8149 /* Config. Reg. 6 (Reserved) (cr6):00 */
8150 /* Config. Reg. 7 (Reserved) (cr7):00 */
8151 /* ;xr Registers */
8152 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8154 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8155 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8157 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8158 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8160 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8161 /* Ext. Reg. 3 (DC Char) (xr3):36 ; */
8162 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
8163 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8164 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8165 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8166 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8167 /* Ext. Reg. 6 (Power State) (xr6):00 */
8168 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8169 /* Ext. Reg. 7 (Vdd) (xr7):46 */
8170 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
8171 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8172 /* 12,33,5A,C3 ; 770 Hz */
8173 /* 13,3C,5B,32 ; 852 Hz */
8174 /* 1D,1B,5C,CC ; 941 Hz */
8176 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8177 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8178 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8179 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8180 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8181 /* EC,1D,52,22 ; 1336 Hz */
8182 /* AA,AC,51,D2 ; 1477 Hz */
8183 /* 9B,3B,51,25 ; 1633 Hz */
8184 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8185 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8186 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8187 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8191 static void DAA_Coeff_France(IXJ *j)
8193 int i;
8195 j->daa_country = DAA_FRANCE;
8196 /*----------------------------------------------- */
8197 /* CAO */
8198 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8199 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8202 /* Bytes for IM-filter part 1 (04): 02,A2,43,2C,22,AF,A0,00 */
8203 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x02;
8204 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA2;
8205 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x43;
8206 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2C;
8207 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x22;
8208 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xAF;
8209 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
8210 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8211 /* Bytes for IM-filter part 2 (05): 67,CE,00,0C,22,33,E0,08 */
8212 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x67;
8213 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xCE;
8214 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8215 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x2C;
8216 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x22;
8217 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8218 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8219 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8220 /* Bytes for FRX-filter (08): 07,9A,28,F6,23,4A,B0,08 */
8221 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8222 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9A;
8223 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x28;
8224 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0xF6;
8225 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x23;
8226 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x4A;
8227 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xB0;
8228 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8229 /* Bytes for FRR-filter (07): 03,8F,F9,2F,9E,FA,20,08 */
8230 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
8231 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
8232 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
8233 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
8234 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9E;
8235 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xFA;
8236 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
8237 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8238 /* Bytes for AX-filter (0A): 16,B5,DD,CA */
8239 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x16;
8240 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
8241 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8242 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8243 /* Bytes for AR-filter (09): 52,C7,10,D6 */
8244 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
8245 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
8246 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8247 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8248 /* Bytes for TH-filter part 1 (00): 00,42,48,81,A6,80,00,98 */
8249 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
8250 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
8251 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8252 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8253 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA6;
8254 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8255 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8256 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8257 /* Bytes for TH-filter part 2 (01): 02,AC,2A,30,78,AC,8A,2C */
8258 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8259 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAC;
8260 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
8261 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x30;
8262 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x78;
8263 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAC;
8264 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x8A;
8265 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x2C;
8266 /* Bytes for TH-filter part 3 (02): 00,88,DA,A5,22,BA,2C,45 */
8267 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8268 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8269 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
8270 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA5;
8271 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x22;
8272 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xBA;
8273 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x2C;
8274 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x45;
8275 /* ; idle */
8276 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8277 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8278 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8279 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8280 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8281 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8282 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8283 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8284 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8285 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8286 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8287 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8288 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8289 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8290 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8291 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8292 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8293 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8294 /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
8295 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
8296 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8297 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
8298 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
8299 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8300 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8301 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8302 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8303 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8304 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8305 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8306 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8307 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8308 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8309 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8310 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8311 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8312 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8313 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8314 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8315 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8316 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8317 /* ;CR Registers */
8318 /* Config. Reg. 0 (filters) (cr0):FF */
8319 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8320 /* Config. Reg. 1 (dialing) (cr1):05 */
8321 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8322 /* Config. Reg. 2 (caller ID) (cr2):04 */
8323 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8324 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8325 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8326 /* Config. Reg. 4 (analog gain) (cr4):02 */
8327 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8328 /* Config. Reg. 5 (Version) (cr5):02 */
8329 /* Config. Reg. 6 (Reserved) (cr6):00 */
8330 /* Config. Reg. 7 (Reserved) (cr7):00 */
8331 /* ;xr Registers */
8332 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8334 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8335 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8337 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8338 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8340 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8341 /* Ext. Reg. 3 (DC Char) (xr3):36 ; */
8342 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
8343 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8344 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8345 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8346 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8347 /* Ext. Reg. 6 (Power State) (xr6):00 */
8348 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8349 /* Ext. Reg. 7 (Vdd) (xr7):46 */
8350 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
8351 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8352 /* 12,33,5A,C3 ; 770 Hz */
8353 /* 13,3C,5B,32 ; 852 Hz */
8354 /* 1D,1B,5C,CC ; 941 Hz */
8356 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8357 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8358 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8359 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8360 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8361 /* EC,1D,52,22 ; 1336 Hz */
8362 /* AA,AC,51,D2 ; 1477 Hz */
8363 /* 9B,3B,51,25 ; 1633 Hz */
8364 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8365 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8366 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8367 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8371 static void DAA_Coeff_Germany(IXJ *j)
8373 int i;
8375 j->daa_country = DAA_GERMANY;
8376 /*----------------------------------------------- */
8377 /* CAO */
8378 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8379 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8382 /* Bytes for IM-filter part 1 (04): 00,CE,BB,B8,D2,81,B0,00 */
8383 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
8384 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xCE;
8385 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
8386 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xB8;
8387 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xD2;
8388 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
8389 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xB0;
8390 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8391 /* Bytes for IM-filter part 2 (05): 45,8F,00,0C,D2,3A,D0,08 */
8392 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x45;
8393 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x8F;
8394 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8395 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0C;
8396 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xD2;
8397 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x3A;
8398 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xD0;
8399 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8400 /* Bytes for FRX-filter (08): 07,AA,E2,34,24,89,20,08 */
8401 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8402 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xAA;
8403 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
8404 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
8405 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x24;
8406 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x89;
8407 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x20;
8408 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8409 /* Bytes for FRR-filter (07): 02,87,FA,37,9A,CA,B0,08 */
8410 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x02;
8411 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
8412 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xFA;
8413 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x37;
8414 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9A;
8415 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCA;
8416 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
8417 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8418 /* Bytes for AX-filter (0A): 72,D5,DD,CA */
8419 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x72;
8420 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xD5;
8421 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8422 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8423 /* Bytes for AR-filter (09): 72,42,13,4B */
8424 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x72;
8425 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x42;
8426 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x13;
8427 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0x4B;
8428 /* Bytes for TH-filter part 1 (00): 80,52,48,81,AD,80,00,98 */
8429 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8430 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
8431 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8432 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8433 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAD;
8434 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8435 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8436 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8437 /* Bytes for TH-filter part 2 (01): 02,42,5A,20,E8,1A,81,27 */
8438 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8439 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x42;
8440 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x5A;
8441 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
8442 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
8443 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x1A;
8444 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
8445 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x27;
8446 /* Bytes for TH-filter part 3 (02): 00,88,63,26,BD,4B,A3,C2 */
8447 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8448 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8449 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x63;
8450 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x26;
8451 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBD;
8452 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x4B;
8453 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xA3;
8454 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xC2;
8455 /* ; (10K, 0.68uF) */
8456 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
8457 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8458 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3B;
8459 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x9B;
8460 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xBA;
8461 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0xD4;
8462 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x1C;
8463 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xB3;
8464 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8465 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
8466 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x13;
8467 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x42;
8468 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8469 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8470 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0xD4;
8471 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x73;
8472 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0xCA;
8473 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8474 /* Levelmetering Ringing (0D):B2,45,0F,8E */
8475 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xB2;
8476 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8477 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8478 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8479 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8480 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8481 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8482 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8483 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8484 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8485 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8486 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8487 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8488 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8489 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8490 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8491 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8492 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8493 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8494 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8495 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8496 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8497 /* ;CR Registers */
8498 /* Config. Reg. 0 (filters) (cr0):FF ; all Filters enabled, CLK from ext. source */
8499 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8500 /* Config. Reg. 1 (dialing) (cr1):05 ; Manual Ring, Ring metering enabled */
8501 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8502 /* Config. Reg. 2 (caller ID) (cr2):04 ; Analog Gain 0dB, FSC internal */
8503 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8504 /* Config. Reg. 3 (testloops) (cr3):00 ; SEL Bit==0, HP-enabled */
8505 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8506 /* Config. Reg. 4 (analog gain) (cr4):02 */
8507 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8508 /* Config. Reg. 5 (Version) (cr5):02 */
8509 /* Config. Reg. 6 (Reserved) (cr6):00 */
8510 /* Config. Reg. 7 (Reserved) (cr7):00 */
8511 /* ;xr Registers */
8512 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8514 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8515 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C ; Ring, CID, VDDOK Interrupts enabled */
8517 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8518 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8520 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8521 /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off==1, U0=3.5V, R=200Ohm */
8522 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x32;
8523 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8524 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8525 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8526 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8527 /* Ext. Reg. 6 (Power State) (xr6):00 */
8528 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8529 /* Ext. Reg. 7 (Vdd) (xr7):40 ; VDD=4.25 V */
8530 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8531 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8532 /* 12,33,5A,C3 ; 770 Hz */
8533 /* 13,3C,5B,32 ; 852 Hz */
8534 /* 1D,1B,5C,CC ; 941 Hz */
8536 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8537 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8538 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8539 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8540 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8541 /* EC,1D,52,22 ; 1336 Hz */
8542 /* AA,AC,51,D2 ; 1477 Hz */
8543 /* 9B,3B,51,25 ; 1633 Hz */
8544 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8545 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8546 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8547 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8551 static void DAA_Coeff_Australia(IXJ *j)
8553 int i;
8555 j->daa_country = DAA_AUSTRALIA;
8556 /*----------------------------------------------- */
8557 /* CAO */
8558 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8559 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8562 /* Bytes for IM-filter part 1 (04): 00,A3,AA,28,B3,82,D0,00 */
8563 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
8564 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA3;
8565 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xAA;
8566 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x28;
8567 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xB3;
8568 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x82;
8569 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xD0;
8570 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8571 /* Bytes for IM-filter part 2 (05): 70,96,00,09,32,6B,C0,08 */
8572 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x70;
8573 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x96;
8574 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8575 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x09;
8576 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x32;
8577 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x6B;
8578 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xC0;
8579 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8580 /* Bytes for FRX-filter (08): 07,96,E2,34,32,9B,30,08 */
8581 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8582 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x96;
8583 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
8584 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
8585 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x32;
8586 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x9B;
8587 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
8588 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8589 /* Bytes for FRR-filter (07): 0F,9A,E9,2F,22,CC,A0,08 */
8590 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
8591 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x9A;
8592 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xE9;
8593 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
8594 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x22;
8595 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCC;
8596 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xA0;
8597 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8598 /* Bytes for AX-filter (0A): CB,45,DD,CA */
8599 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0xCB;
8600 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0x45;
8601 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8602 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8603 /* Bytes for AR-filter (09): 1B,67,10,D6 */
8604 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x1B;
8605 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x67;
8606 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8607 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8608 /* Bytes for TH-filter part 1 (00): 80,52,48,81,AF,80,00,98 */
8609 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8610 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
8611 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8612 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8613 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAF;
8614 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8615 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8616 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8617 /* Bytes for TH-filter part 2 (01): 02,DB,52,B0,38,01,82,AC */
8618 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8619 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xDB;
8620 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x52;
8621 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
8622 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x38;
8623 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x01;
8624 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x82;
8625 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xAC;
8626 /* Bytes for TH-filter part 3 (02): 00,88,4A,3E,2C,3B,24,46 */
8627 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8628 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8629 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x4A;
8630 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x3E;
8631 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x2C;
8632 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x3B;
8633 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x24;
8634 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x46;
8635 /* ; idle */
8636 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8637 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8638 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8639 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8640 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8641 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8642 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8643 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8644 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8645 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8646 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8647 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8648 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8649 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8650 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8651 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8652 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8653 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8654 /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
8655 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
8656 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8657 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
8658 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
8659 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8660 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8661 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8662 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8663 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8664 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8665 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8666 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8667 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8668 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8669 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8670 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8671 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8672 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8673 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8674 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8675 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8676 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8677 /* ;CR Registers */
8678 /* Config. Reg. 0 (filters) (cr0):FF */
8679 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8680 /* Config. Reg. 1 (dialing) (cr1):05 */
8681 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8682 /* Config. Reg. 2 (caller ID) (cr2):04 */
8683 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8684 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8685 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8686 /* Config. Reg. 4 (analog gain) (cr4):02 */
8687 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8688 /* Config. Reg. 5 (Version) (cr5):02 */
8689 /* Config. Reg. 6 (Reserved) (cr6):00 */
8690 /* Config. Reg. 7 (Reserved) (cr7):00 */
8691 /* ;xr Registers */
8692 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8694 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8695 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8697 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8698 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8700 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8701 /* Ext. Reg. 3 (DC Char) (xr3):2B ; */
8702 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x2B;
8703 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8704 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8705 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8706 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8707 /* Ext. Reg. 6 (Power State) (xr6):00 */
8708 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8709 /* Ext. Reg. 7 (Vdd) (xr7):40 */
8710 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8712 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8713 /* 12,33,5A,C3 ; 770 Hz */
8714 /* 13,3C,5B,32 ; 852 Hz */
8715 /* 1D,1B,5C,CC ; 941 Hz */
8716 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8717 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8718 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8719 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8721 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8722 /* EC,1D,52,22 ; 1336 Hz */
8723 /* AA,AC,51,D2 ; 1477 Hz */
8724 /* 9B,3B,51,25 ; 1633 Hz */
8725 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8726 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8727 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8728 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8731 static void DAA_Coeff_Japan(IXJ *j)
8733 int i;
8735 j->daa_country = DAA_JAPAN;
8736 /*----------------------------------------------- */
8737 /* CAO */
8738 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8739 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8742 /* Bytes for IM-filter part 1 (04): 06,BD,E2,2D,BA,F9,A0,00 */
8743 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x06;
8744 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xBD;
8745 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xE2;
8746 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2D;
8747 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xBA;
8748 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xF9;
8749 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
8750 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8751 /* Bytes for IM-filter part 2 (05): 6F,F7,00,0E,34,33,E0,08 */
8752 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x6F;
8753 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xF7;
8754 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8755 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0E;
8756 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x34;
8757 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8758 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8759 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8760 /* Bytes for FRX-filter (08): 02,8F,68,77,9C,58,F0,08 */
8761 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x02;
8762 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x8F;
8763 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x68;
8764 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x77;
8765 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x9C;
8766 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x58;
8767 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xF0;
8768 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8769 /* Bytes for FRR-filter (07): 03,8F,38,73,87,EA,20,08 */
8770 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
8771 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
8772 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0x38;
8773 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x73;
8774 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
8775 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xEA;
8776 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
8777 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8778 /* Bytes for AX-filter (0A): 51,C5,DD,CA */
8779 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x51;
8780 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xC5;
8781 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8782 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8783 /* Bytes for AR-filter (09): 25,A7,10,D6 */
8784 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
8785 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xA7;
8786 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8787 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8788 /* Bytes for TH-filter part 1 (00): 00,42,48,81,AE,80,00,98 */
8789 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
8790 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
8791 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8792 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8793 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAE;
8794 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8795 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8796 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8797 /* Bytes for TH-filter part 2 (01): 02,AB,2A,20,99,5B,89,28 */
8798 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8799 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAB;
8800 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
8801 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
8802 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x99;
8803 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5B;
8804 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x89;
8805 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x28;
8806 /* Bytes for TH-filter part 3 (02): 00,88,DA,25,34,C5,4C,BA */
8807 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8808 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8809 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
8810 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x25;
8811 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x34;
8812 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xC5;
8813 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x4C;
8814 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xBA;
8815 /* ; idle */
8816 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8817 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8818 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8819 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8820 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8821 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8822 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8823 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8824 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8825 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8826 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8827 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8828 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8829 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8830 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8831 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8832 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8833 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8834 /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V ????????? */
8835 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
8836 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
8837 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8838 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8839 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8840 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8841 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8842 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8843 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8844 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8845 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8846 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8847 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8848 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8849 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8850 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8851 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8852 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8853 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8854 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8855 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8856 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8857 /* ;CR Registers */
8858 /* Config. Reg. 0 (filters) (cr0):FF */
8859 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8860 /* Config. Reg. 1 (dialing) (cr1):05 */
8861 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8862 /* Config. Reg. 2 (caller ID) (cr2):04 */
8863 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8864 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8865 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8866 /* Config. Reg. 4 (analog gain) (cr4):02 */
8867 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8868 /* Config. Reg. 5 (Version) (cr5):02 */
8869 /* Config. Reg. 6 (Reserved) (cr6):00 */
8870 /* Config. Reg. 7 (Reserved) (cr7):00 */
8871 /* ;xr Registers */
8872 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8874 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8875 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8877 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8878 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8880 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8881 /* Ext. Reg. 3 (DC Char) (xr3):22 ; */
8882 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x22;
8883 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8884 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8885 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8886 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8887 /* Ext. Reg. 6 (Power State) (xr6):00 */
8888 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8889 /* Ext. Reg. 7 (Vdd) (xr7):40 */
8890 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8891 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8892 /* 12,33,5A,C3 ; 770 Hz */
8893 /* 13,3C,5B,32 ; 852 Hz */
8894 /* 1D,1B,5C,CC ; 941 Hz */
8896 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8897 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8898 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8899 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8900 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8901 /* EC,1D,52,22 ; 1336 Hz */
8902 /* AA,AC,51,D2 ; 1477 Hz */
8903 /* 9B,3B,51,25 ; 1633 Hz */
8904 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8905 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8906 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8907 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8910 static s16 tone_table[][19] =
8912 { /* f20_50[] 11 */
8913 32538, /* A1 = 1.985962 */
8914 -32325, /* A2 = -0.986511 */
8915 -343, /* B2 = -0.010493 */
8916 0, /* B1 = 0 */
8917 343, /* B0 = 0.010493 */
8918 32619, /* A1 = 1.990906 */
8919 -32520, /* A2 = -0.992462 */
8920 19179, /* B2 = 0.585327 */
8921 -19178, /* B1 = -1.170593 */
8922 19179, /* B0 = 0.585327 */
8923 32723, /* A1 = 1.997314 */
8924 -32686, /* A2 = -0.997528 */
8925 9973, /* B2 = 0.304352 */
8926 -9955, /* B1 = -0.607605 */
8927 9973, /* B0 = 0.304352 */
8928 7, /* Internal filter scaling */
8929 159, /* Minimum in-band energy threshold */
8930 21, /* 21/32 in-band to broad-band ratio */
8931 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8933 { /* f133_200[] 12 */
8934 32072, /* A1 = 1.95752 */
8935 -31896, /* A2 = -0.973419 */
8936 -435, /* B2 = -0.013294 */
8937 0, /* B1 = 0 */
8938 435, /* B0 = 0.013294 */
8939 32188, /* A1 = 1.9646 */
8940 -32400, /* A2 = -0.98877 */
8941 15139, /* B2 = 0.462036 */
8942 -14882, /* B1 = -0.908356 */
8943 15139, /* B0 = 0.462036 */
8944 32473, /* A1 = 1.981995 */
8945 -32524, /* A2 = -0.992584 */
8946 23200, /* B2 = 0.708008 */
8947 -23113, /* B1 = -1.410706 */
8948 23200, /* B0 = 0.708008 */
8949 7, /* Internal filter scaling */
8950 159, /* Minimum in-band energy threshold */
8951 21, /* 21/32 in-band to broad-band ratio */
8952 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8954 { /* f300 13 */
8955 31769, /* A1 = -1.939026 */
8956 -32584, /* A2 = 0.994385 */
8957 -475, /* B2 = -0.014522 */
8958 0, /* B1 = 0.000000 */
8959 475, /* B0 = 0.014522 */
8960 31789, /* A1 = -1.940247 */
8961 -32679, /* A2 = 0.997284 */
8962 17280, /* B2 = 0.527344 */
8963 -16865, /* B1 = -1.029358 */
8964 17280, /* B0 = 0.527344 */
8965 31841, /* A1 = -1.943481 */
8966 -32681, /* A2 = 0.997345 */
8967 543, /* B2 = 0.016579 */
8968 -525, /* B1 = -0.032097 */
8969 543, /* B0 = 0.016579 */
8970 5, /* Internal filter scaling */
8971 159, /* Minimum in-band energy threshold */
8972 21, /* 21/32 in-band to broad-band ratio */
8973 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8975 { /* f300_420[] 14 */
8976 30750, /* A1 = 1.876892 */
8977 -31212, /* A2 = -0.952515 */
8978 -804, /* B2 = -0.024541 */
8979 0, /* B1 = 0 */
8980 804, /* B0 = 0.024541 */
8981 30686, /* A1 = 1.872925 */
8982 -32145, /* A2 = -0.980988 */
8983 14747, /* B2 = 0.450043 */
8984 -13703, /* B1 = -0.836395 */
8985 14747, /* B0 = 0.450043 */
8986 31651, /* A1 = 1.931824 */
8987 -32321, /* A2 = -0.986389 */
8988 24425, /* B2 = 0.745422 */
8989 -23914, /* B1 = -1.459595 */
8990 24427, /* B0 = 0.745483 */
8991 7, /* Internal filter scaling */
8992 159, /* Minimum in-band energy threshold */
8993 21, /* 21/32 in-band to broad-band ratio */
8994 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
8996 { /* f330 15 */
8997 31613, /* A1 = -1.929565 */
8998 -32646, /* A2 = 0.996277 */
8999 -185, /* B2 = -0.005657 */
9000 0, /* B1 = 0.000000 */
9001 185, /* B0 = 0.005657 */
9002 31620, /* A1 = -1.929932 */
9003 -32713, /* A2 = 0.998352 */
9004 19253, /* B2 = 0.587585 */
9005 -18566, /* B1 = -1.133179 */
9006 19253, /* B0 = 0.587585 */
9007 31674, /* A1 = -1.933228 */
9008 -32715, /* A2 = 0.998413 */
9009 2575, /* B2 = 0.078590 */
9010 -2495, /* B1 = -0.152283 */
9011 2575, /* B0 = 0.078590 */
9012 5, /* Internal filter scaling */
9013 159, /* Minimum in-band energy threshold */
9014 21, /* 21/32 in-band to broad-band ratio */
9015 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9017 { /* f300_425[] 16 */
9018 30741, /* A1 = 1.876282 */
9019 -31475, /* A2 = -0.960541 */
9020 -703, /* B2 = -0.021484 */
9021 0, /* B1 = 0 */
9022 703, /* B0 = 0.021484 */
9023 30688, /* A1 = 1.873047 */
9024 -32248, /* A2 = -0.984161 */
9025 14542, /* B2 = 0.443787 */
9026 -13523, /* B1 = -0.825439 */
9027 14542, /* B0 = 0.443817 */
9028 31494, /* A1 = 1.922302 */
9029 -32366, /* A2 = -0.987762 */
9030 21577, /* B2 = 0.658508 */
9031 -21013, /* B1 = -1.282532 */
9032 21577, /* B0 = 0.658508 */
9033 7, /* Internal filter scaling */
9034 159, /* Minimum in-band energy threshold */
9035 21, /* 21/32 in-band to broad-band ratio */
9036 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9038 { /* f330_440[] 17 */
9039 30627, /* A1 = 1.869324 */
9040 -31338, /* A2 = -0.95636 */
9041 -843, /* B2 = -0.025749 */
9042 0, /* B1 = 0 */
9043 843, /* B0 = 0.025749 */
9044 30550, /* A1 = 1.864685 */
9045 -32221, /* A2 = -0.983337 */
9046 13594, /* B2 = 0.414886 */
9047 -12589, /* B1 = -0.768402 */
9048 13594, /* B0 = 0.414886 */
9049 31488, /* A1 = 1.921936 */
9050 -32358, /* A2 = -0.987518 */
9051 24684, /* B2 = 0.753296 */
9052 -24029, /* B1 = -1.466614 */
9053 24684, /* B0 = 0.753296 */
9054 7, /* Internal filter scaling */
9055 159, /* Minimum in-band energy threshold */
9056 21, /* 21/32 in-band to broad-band ratio */
9057 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9059 { /* f340 18 */
9060 31546, /* A1 = -1.925476 */
9061 -32646, /* A2 = 0.996277 */
9062 -445, /* B2 = -0.013588 */
9063 0, /* B1 = 0.000000 */
9064 445, /* B0 = 0.013588 */
9065 31551, /* A1 = -1.925781 */
9066 -32713, /* A2 = 0.998352 */
9067 23884, /* B2 = 0.728882 */
9068 -22979, /* B1 = -1.402527 */
9069 23884, /* B0 = 0.728882 */
9070 31606, /* A1 = -1.929138 */
9071 -32715, /* A2 = 0.998413 */
9072 863, /* B2 = 0.026367 */
9073 -835, /* B1 = -0.050985 */
9074 863, /* B0 = 0.026367 */
9075 5, /* Internal filter scaling */
9076 159, /* Minimum in-band energy threshold */
9077 21, /* 21/32 in-band to broad-band ratio */
9078 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9080 { /* f350_400[] 19 */
9081 31006, /* A1 = 1.892517 */
9082 -32029, /* A2 = -0.977448 */
9083 -461, /* B2 = -0.014096 */
9084 0, /* B1 = 0 */
9085 461, /* B0 = 0.014096 */
9086 30999, /* A1 = 1.892029 */
9087 -32487, /* A2 = -0.991455 */
9088 11325, /* B2 = 0.345612 */
9089 -10682, /* B1 = -0.651978 */
9090 11325, /* B0 = 0.345612 */
9091 31441, /* A1 = 1.919067 */
9092 -32526, /* A2 = -0.992615 */
9093 24324, /* B2 = 0.74231 */
9094 -23535, /* B1 = -1.436523 */
9095 24324, /* B0 = 0.74231 */
9096 7, /* Internal filter scaling */
9097 159, /* Minimum in-band energy threshold */
9098 21, /* 21/32 in-band to broad-band ratio */
9099 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9101 { /* f350_440[] */
9102 30634, /* A1 = 1.869751 */
9103 -31533, /* A2 = -0.962341 */
9104 -680, /* B2 = -0.020782 */
9105 0, /* B1 = 0 */
9106 680, /* B0 = 0.020782 */
9107 30571, /* A1 = 1.865906 */
9108 -32277, /* A2 = -0.985016 */
9109 12894, /* B2 = 0.393524 */
9110 -11945, /* B1 = -0.729065 */
9111 12894, /* B0 = 0.393524 */
9112 31367, /* A1 = 1.91449 */
9113 -32379, /* A2 = -0.988129 */
9114 23820, /* B2 = 0.726929 */
9115 -23104, /* B1 = -1.410217 */
9116 23820, /* B0 = 0.726929 */
9117 7, /* Internal filter scaling */
9118 159, /* Minimum in-band energy threshold */
9119 21, /* 21/32 in-band to broad-band ratio */
9120 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9122 { /* f350_450[] */
9123 30552, /* A1 = 1.864807 */
9124 -31434, /* A2 = -0.95929 */
9125 -690, /* B2 = -0.021066 */
9126 0, /* B1 = 0 */
9127 690, /* B0 = 0.021066 */
9128 30472, /* A1 = 1.859924 */
9129 -32248, /* A2 = -0.984161 */
9130 13385, /* B2 = 0.408478 */
9131 -12357, /* B1 = -0.754242 */
9132 13385, /* B0 = 0.408478 */
9133 31358, /* A1 = 1.914001 */
9134 -32366, /* A2 = -0.987732 */
9135 26488, /* B2 = 0.80835 */
9136 -25692, /* B1 = -1.568176 */
9137 26490, /* B0 = 0.808411 */
9138 7, /* Internal filter scaling */
9139 159, /* Minimum in-band energy threshold */
9140 21, /* 21/32 in-band to broad-band ratio */
9141 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9143 { /* f360 */
9144 31397, /* A1 = -1.916321 */
9145 -32623, /* A2 = 0.995605 */
9146 -117, /* B2 = -0.003598 */
9147 0, /* B1 = 0.000000 */
9148 117, /* B0 = 0.003598 */
9149 31403, /* A1 = -1.916687 */
9150 -32700, /* A2 = 0.997925 */
9151 3388, /* B2 = 0.103401 */
9152 -3240, /* B1 = -0.197784 */
9153 3388, /* B0 = 0.103401 */
9154 31463, /* A1 = -1.920410 */
9155 -32702, /* A2 = 0.997986 */
9156 13346, /* B2 = 0.407288 */
9157 -12863, /* B1 = -0.785126 */
9158 13346, /* B0 = 0.407288 */
9159 5, /* Internal filter scaling */
9160 159, /* Minimum in-band energy threshold */
9161 21, /* 21/32 in-band to broad-band ratio */
9162 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9164 { /* f380_420[] */
9165 30831, /* A1 = 1.881775 */
9166 -32064, /* A2 = -0.978546 */
9167 -367, /* B2 = -0.01122 */
9168 0, /* B1 = 0 */
9169 367, /* B0 = 0.01122 */
9170 30813, /* A1 = 1.880737 */
9171 -32456, /* A2 = -0.990509 */
9172 11068, /* B2 = 0.337769 */
9173 -10338, /* B1 = -0.631042 */
9174 11068, /* B0 = 0.337769 */
9175 31214, /* A1 = 1.905212 */
9176 -32491, /* A2 = -0.991577 */
9177 16374, /* B2 = 0.499695 */
9178 -15781, /* B1 = -0.963196 */
9179 16374, /* B0 = 0.499695 */
9180 7, /* Internal filter scaling */
9181 159, /* Minimum in-band energy threshold */
9182 21, /* 21/32 in-band to broad-band ratio */
9183 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9185 { /* f392 */
9186 31152, /* A1 = -1.901428 */
9187 -32613, /* A2 = 0.995300 */
9188 -314, /* B2 = -0.009605 */
9189 0, /* B1 = 0.000000 */
9190 314, /* B0 = 0.009605 */
9191 31156, /* A1 = -1.901672 */
9192 -32694, /* A2 = 0.997742 */
9193 28847, /* B2 = 0.880371 */
9194 -2734, /* B1 = -0.166901 */
9195 28847, /* B0 = 0.880371 */
9196 31225, /* A1 = -1.905823 */
9197 -32696, /* A2 = 0.997803 */
9198 462, /* B2 = 0.014108 */
9199 -442, /* B1 = -0.027019 */
9200 462, /* B0 = 0.014108 */
9201 5, /* Internal filter scaling */
9202 159, /* Minimum in-band energy threshold */
9203 21, /* 21/32 in-band to broad-band ratio */
9204 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9206 { /* f400_425[] */
9207 30836, /* A1 = 1.882141 */
9208 -32296, /* A2 = -0.985596 */
9209 -324, /* B2 = -0.009903 */
9210 0, /* B1 = 0 */
9211 324, /* B0 = 0.009903 */
9212 30825, /* A1 = 1.881409 */
9213 -32570, /* A2 = -0.993958 */
9214 16847, /* B2 = 0.51416 */
9215 -15792, /* B1 = -0.963898 */
9216 16847, /* B0 = 0.51416 */
9217 31106, /* A1 = 1.89856 */
9218 -32584, /* A2 = -0.994415 */
9219 9579, /* B2 = 0.292328 */
9220 -9164, /* B1 = -0.559357 */
9221 9579, /* B0 = 0.292328 */
9222 7, /* Internal filter scaling */
9223 159, /* Minimum in-band energy threshold */
9224 21, /* 21/32 in-band to broad-band ratio */
9225 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9227 { /* f400_440[] */
9228 30702, /* A1 = 1.873962 */
9229 -32134, /* A2 = -0.980682 */
9230 -517, /* B2 = -0.015793 */
9231 0, /* B1 = 0 */
9232 517, /* B0 = 0.015793 */
9233 30676, /* A1 = 1.872375 */
9234 -32520, /* A2 = -0.992462 */
9235 8144, /* B2 = 0.24855 */
9236 -7596, /* B1 = -0.463684 */
9237 8144, /* B0 = 0.24855 */
9238 31084, /* A1 = 1.897217 */
9239 -32547, /* A2 = -0.993256 */
9240 22713, /* B2 = 0.693176 */
9241 -21734, /* B1 = -1.326599 */
9242 22713, /* B0 = 0.693176 */
9243 7, /* Internal filter scaling */
9244 159, /* Minimum in-band energy threshold */
9245 21, /* 21/32 in-band to broad-band ratio */
9246 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9248 { /* f400_450[] */
9249 30613, /* A1 = 1.86853 */
9250 -32031, /* A2 = -0.977509 */
9251 -618, /* B2 = -0.018866 */
9252 0, /* B1 = 0 */
9253 618, /* B0 = 0.018866 */
9254 30577, /* A1 = 1.866272 */
9255 -32491, /* A2 = -0.991577 */
9256 9612, /* B2 = 0.293335 */
9257 -8935, /* B1 = -0.54541 */
9258 9612, /* B0 = 0.293335 */
9259 31071, /* A1 = 1.896484 */
9260 -32524, /* A2 = -0.992584 */
9261 21596, /* B2 = 0.659058 */
9262 -20667, /* B1 = -1.261414 */
9263 21596, /* B0 = 0.659058 */
9264 7, /* Internal filter scaling */
9265 159, /* Minimum in-band energy threshold */
9266 21, /* 21/32 in-band to broad-band ratio */
9267 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9269 { /* f420 */
9270 30914, /* A1 = -1.886841 */
9271 -32584, /* A2 = 0.994385 */
9272 -426, /* B2 = -0.013020 */
9273 0, /* B1 = 0.000000 */
9274 426, /* B0 = 0.013020 */
9275 30914, /* A1 = -1.886841 */
9276 -32679, /* A2 = 0.997314 */
9277 17520, /* B2 = 0.534668 */
9278 -16471, /* B1 = -1.005310 */
9279 17520, /* B0 = 0.534668 */
9280 31004, /* A1 = -1.892334 */
9281 -32683, /* A2 = 0.997406 */
9282 819, /* B2 = 0.025023 */
9283 -780, /* B1 = -0.047619 */
9284 819, /* B0 = 0.025023 */
9285 5, /* Internal filter scaling */
9286 159, /* Minimum in-band energy threshold */
9287 21, /* 21/32 in-band to broad-band ratio */
9288 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9290 #if 0
9291 { /* f425 */
9292 30881, /* A1 = -1.884827 */
9293 -32603, /* A2 = 0.994965 */
9294 -496, /* B2 = -0.015144 */
9295 0, /* B1 = 0.000000 */
9296 496, /* B0 = 0.015144 */
9297 30880, /* A1 = -1.884766 */
9298 -32692, /* A2 = 0.997711 */
9299 24767, /* B2 = 0.755859 */
9300 -23290, /* B1 = -1.421509 */
9301 24767, /* B0 = 0.755859 */
9302 30967, /* A1 = -1.890076 */
9303 -32694, /* A2 = 0.997772 */
9304 728, /* B2 = 0.022232 */
9305 -691, /* B1 = -0.042194 */
9306 728, /* B0 = 0.022232 */
9307 5, /* Internal filter scaling */
9308 159, /* Minimum in-band energy threshold */
9309 21, /* 21/32 in-band to broad-band ratio */
9310 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9312 #else
9314 30850,
9315 -32534,
9316 -504,
9318 504,
9319 30831,
9320 -32669,
9321 24303,
9322 -22080,
9323 24303,
9324 30994,
9325 -32673,
9326 1905,
9327 -1811,
9328 1905,
9330 129,
9332 0xff5
9334 #endif
9335 { /* f425_450[] */
9336 30646, /* A1 = 1.870544 */
9337 -32327, /* A2 = -0.986572 */
9338 -287, /* B2 = -0.008769 */
9339 0, /* B1 = 0 */
9340 287, /* B0 = 0.008769 */
9341 30627, /* A1 = 1.869324 */
9342 -32607, /* A2 = -0.995087 */
9343 13269, /* B2 = 0.404968 */
9344 -12376, /* B1 = -0.755432 */
9345 13269, /* B0 = 0.404968 */
9346 30924, /* A1 = 1.887512 */
9347 -32619, /* A2 = -0.995453 */
9348 19950, /* B2 = 0.608826 */
9349 -18940, /* B1 = -1.156006 */
9350 19950, /* B0 = 0.608826 */
9351 7, /* Internal filter scaling */
9352 159, /* Minimum in-band energy threshold */
9353 21, /* 21/32 in-band to broad-band ratio */
9354 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9356 { /* f425_475[] */
9357 30396, /* A1 = 1.855225 */
9358 -32014, /* A2 = -0.97699 */
9359 -395, /* B2 = -0.012055 */
9360 0, /* B1 = 0 */
9361 395, /* B0 = 0.012055 */
9362 30343, /* A1 = 1.85199 */
9363 -32482, /* A2 = -0.991302 */
9364 17823, /* B2 = 0.543945 */
9365 -16431, /* B1 = -1.002869 */
9366 17823, /* B0 = 0.543945 */
9367 30872, /* A1 = 1.884338 */
9368 -32516, /* A2 = -0.99231 */
9369 18124, /* B2 = 0.553101 */
9370 -17246, /* B1 = -1.052673 */
9371 18124, /* B0 = 0.553101 */
9372 7, /* Internal filter scaling */
9373 159, /* Minimum in-band energy threshold */
9374 21, /* 21/32 in-band to broad-band ratio */
9375 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9377 { /* f435 */
9378 30796, /* A1 = -1.879639 */
9379 -32603, /* A2 = 0.994965 */
9380 -254, /* B2 = -0.007762 */
9381 0, /* B1 = 0.000000 */
9382 254, /* B0 = 0.007762 */
9383 30793, /* A1 = -1.879456 */
9384 -32692, /* A2 = 0.997711 */
9385 18934, /* B2 = 0.577820 */
9386 -17751, /* B1 = -1.083496 */
9387 18934, /* B0 = 0.577820 */
9388 30882, /* A1 = -1.884888 */
9389 -32694, /* A2 = 0.997772 */
9390 1858, /* B2 = 0.056713 */
9391 -1758, /* B1 = -0.107357 */
9392 1858, /* B0 = 0.056713 */
9393 5, /* Internal filter scaling */
9394 159, /* Minimum in-band energy threshold */
9395 21, /* 21/32 in-band to broad-band ratio */
9396 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9398 { /* f440_450[] */
9399 30641, /* A1 = 1.870239 */
9400 -32458, /* A2 = -0.99057 */
9401 -155, /* B2 = -0.004735 */
9402 0, /* B1 = 0 */
9403 155, /* B0 = 0.004735 */
9404 30631, /* A1 = 1.869568 */
9405 -32630, /* A2 = -0.995789 */
9406 11453, /* B2 = 0.349548 */
9407 -10666, /* B1 = -0.651001 */
9408 11453, /* B0 = 0.349548 */
9409 30810, /* A1 = 1.880554 */
9410 -32634, /* A2 = -0.995941 */
9411 12237, /* B2 = 0.373474 */
9412 -11588, /* B1 = -0.707336 */
9413 12237, /* B0 = 0.373474 */
9414 7, /* Internal filter scaling */
9415 159, /* Minimum in-band energy threshold */
9416 21, /* 21/32 in-band to broad-band ratio */
9417 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9419 { /* f440_480[] */
9420 30367, /* A1 = 1.853455 */
9421 -32147, /* A2 = -0.981079 */
9422 -495, /* B2 = -0.015113 */
9423 0, /* B1 = 0 */
9424 495, /* B0 = 0.015113 */
9425 30322, /* A1 = 1.850769 */
9426 -32543, /* A2 = -0.993134 */
9427 10031, /* B2 = 0.306152 */
9428 -9252, /* B1 = -0.564728 */
9429 10031, /* B0 = 0.306152 */
9430 30770, /* A1 = 1.878052 */
9431 -32563, /* A2 = -0.993774 */
9432 22674, /* B2 = 0.691956 */
9433 -21465, /* B1 = -1.31012 */
9434 22674, /* B0 = 0.691956 */
9435 7, /* Internal filter scaling */
9436 159, /* Minimum in-band energy threshold */
9437 21, /* 21/32 in-band to broad-band ratio */
9438 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9440 { /* f445 */
9441 30709, /* A1 = -1.874329 */
9442 -32603, /* A2 = 0.994965 */
9443 -83, /* B2 = -0.002545 */
9444 0, /* B1 = 0.000000 */
9445 83, /* B0 = 0.002545 */
9446 30704, /* A1 = -1.874084 */
9447 -32692, /* A2 = 0.997711 */
9448 10641, /* B2 = 0.324738 */
9449 -9947, /* B1 = -0.607147 */
9450 10641, /* B0 = 0.324738 */
9451 30796, /* A1 = -1.879639 */
9452 -32694, /* A2 = 0.997772 */
9453 10079, /* B2 = 0.307587 */
9454 9513, /* B1 = 0.580688 */
9455 10079, /* B0 = 0.307587 */
9456 5, /* Internal filter scaling */
9457 159, /* Minimum in-band energy threshold */
9458 21, /* 21/32 in-band to broad-band ratio */
9459 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9461 { /* f450 */
9462 30664, /* A1 = -1.871643 */
9463 -32603, /* A2 = 0.994965 */
9464 -164, /* B2 = -0.005029 */
9465 0, /* B1 = 0.000000 */
9466 164, /* B0 = 0.005029 */
9467 30661, /* A1 = -1.871399 */
9468 -32692, /* A2 = 0.997711 */
9469 15294, /* B2 = 0.466736 */
9470 -14275, /* B1 = -0.871307 */
9471 15294, /* B0 = 0.466736 */
9472 30751, /* A1 = -1.876953 */
9473 -32694, /* A2 = 0.997772 */
9474 3548, /* B2 = 0.108284 */
9475 -3344, /* B1 = -0.204155 */
9476 3548, /* B0 = 0.108284 */
9477 5, /* Internal filter scaling */
9478 159, /* Minimum in-band energy threshold */
9479 21, /* 21/32 in-band to broad-band ratio */
9480 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9482 { /* f452 */
9483 30653, /* A1 = -1.870911 */
9484 -32615, /* A2 = 0.995361 */
9485 -209, /* B2 = -0.006382 */
9486 0, /* B1 = 0.000000 */
9487 209, /* B0 = 0.006382 */
9488 30647, /* A1 = -1.870605 */
9489 -32702, /* A2 = 0.997986 */
9490 18971, /* B2 = 0.578979 */
9491 -17716, /* B1 = -1.081299 */
9492 18971, /* B0 = 0.578979 */
9493 30738, /* A1 = -1.876099 */
9494 -32702, /* A2 = 0.998016 */
9495 2967, /* B2 = 0.090561 */
9496 -2793, /* B1 = -0.170502 */
9497 2967, /* B0 = 0.090561 */
9498 5, /* Internal filter scaling */
9499 159, /* Minimum in-band energy threshold */
9500 21, /* 21/32 in-band to broad-band ratio */
9501 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9503 { /* f475 */
9504 30437, /* A1 = -1.857727 */
9505 -32603, /* A2 = 0.994965 */
9506 -264, /* B2 = -0.008062 */
9507 0, /* B1 = 0.000000 */
9508 264, /* B0 = 0.008062 */
9509 30430, /* A1 = -1.857300 */
9510 -32692, /* A2 = 0.997711 */
9511 21681, /* B2 = 0.661682 */
9512 -20082, /* B1 = -1.225708 */
9513 21681, /* B0 = 0.661682 */
9514 30526, /* A1 = -1.863220 */
9515 -32694, /* A2 = 0.997742 */
9516 1559, /* B2 = 0.047600 */
9517 -1459, /* B1 = -0.089096 */
9518 1559, /* B0 = 0.047600 */
9519 5, /* Internal filter scaling */
9520 159, /* Minimum in-band energy threshold */
9521 21, /* 21/32 in-band to broad-band ratio */
9522 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9524 { /* f480_620[] */
9525 28975, /* A1 = 1.768494 */
9526 -30955, /* A2 = -0.944672 */
9527 -1026, /* B2 = -0.03133 */
9528 0, /* B1 = 0 */
9529 1026, /* B0 = 0.03133 */
9530 28613, /* A1 = 1.746399 */
9531 -32089, /* A2 = -0.979309 */
9532 14214, /* B2 = 0.433807 */
9533 -12202, /* B1 = -0.744812 */
9534 14214, /* B0 = 0.433807 */
9535 30243, /* A1 = 1.845947 */
9536 -32238, /* A2 = -0.983856 */
9537 24825, /* B2 = 0.757629 */
9538 -23402, /* B1 = -1.428345 */
9539 24825, /* B0 = 0.757629 */
9540 7, /* Internal filter scaling */
9541 159, /* Minimum in-band energy threshold */
9542 21, /* 21/32 in-band to broad-band ratio */
9543 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9545 { /* f494 */
9546 30257, /* A1 = -1.846741 */
9547 -32605, /* A2 = 0.995056 */
9548 -249, /* B2 = -0.007625 */
9549 0, /* B1 = 0.000000 */
9550 249, /* B0 = 0.007625 */
9551 30247, /* A1 = -1.846191 */
9552 -32694, /* A2 = 0.997772 */
9553 18088, /* B2 = 0.552002 */
9554 -16652, /* B1 = -1.016418 */
9555 18088, /* B0 = 0.552002 */
9556 30348, /* A1 = -1.852295 */
9557 -32696, /* A2 = 0.997803 */
9558 2099, /* B2 = 0.064064 */
9559 -1953, /* B1 = -0.119202 */
9560 2099, /* B0 = 0.064064 */
9561 5, /* Internal filter scaling */
9562 159, /* Minimum in-band energy threshold */
9563 21, /* 21/32 in-band to broad-band ratio */
9564 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9566 { /* f500 */
9567 30202, /* A1 = -1.843431 */
9568 -32624, /* A2 = 0.995622 */
9569 -413, /* B2 = -0.012622 */
9570 0, /* B1 = 0.000000 */
9571 413, /* B0 = 0.012622 */
9572 30191, /* A1 = -1.842721 */
9573 -32714, /* A2 = 0.998364 */
9574 25954, /* B2 = 0.792057 */
9575 -23890, /* B1 = -1.458131 */
9576 25954, /* B0 = 0.792057 */
9577 30296, /* A1 = -1.849172 */
9578 -32715, /* A2 = 0.998397 */
9579 2007, /* B2 = 0.061264 */
9580 -1860, /* B1 = -0.113568 */
9581 2007, /* B0 = 0.061264 */
9582 5, /* Internal filter scaling */
9583 159, /* Minimum in-band energy threshold */
9584 21, /* 21/32 in-band to broad-band ratio */
9585 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9587 { /* f520 */
9588 30001, /* A1 = -1.831116 */
9589 -32613, /* A2 = 0.995270 */
9590 -155, /* B2 = -0.004750 */
9591 0, /* B1 = 0.000000 */
9592 155, /* B0 = 0.004750 */
9593 29985, /* A1 = -1.830200 */
9594 -32710, /* A2 = 0.998260 */
9595 6584, /* B2 = 0.200928 */
9596 -6018, /* B1 = -0.367355 */
9597 6584, /* B0 = 0.200928 */
9598 30105, /* A1 = -1.837524 */
9599 -32712, /* A2 = 0.998291 */
9600 23812, /* B2 = 0.726685 */
9601 -21936, /* B1 = -1.338928 */
9602 23812, /* B0 = 0.726685 */
9603 5, /* Internal filter scaling */
9604 159, /* Minimum in-band energy threshold */
9605 21, /* 21/32 in-band to broad-band ratio */
9606 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9608 { /* f523 */
9609 29964, /* A1 = -1.828918 */
9610 -32601, /* A2 = 0.994904 */
9611 -101, /* B2 = -0.003110 */
9612 0, /* B1 = 0.000000 */
9613 101, /* B0 = 0.003110 */
9614 29949, /* A1 = -1.827942 */
9615 -32700, /* A2 = 0.997925 */
9616 11041, /* B2 = 0.336975 */
9617 -10075, /* B1 = -0.614960 */
9618 11041, /* B0 = 0.336975 */
9619 30070, /* A1 = -1.835388 */
9620 -32702, /* A2 = 0.997986 */
9621 16762, /* B2 = 0.511536 */
9622 -15437, /* B1 = -0.942230 */
9623 16762, /* B0 = 0.511536 */
9624 5, /* Internal filter scaling */
9625 159, /* Minimum in-band energy threshold */
9626 21, /* 21/32 in-band to broad-band ratio */
9627 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9629 { /* f525 */
9630 29936, /* A1 = -1.827209 */
9631 -32584, /* A2 = 0.994415 */
9632 -91, /* B2 = -0.002806 */
9633 0, /* B1 = 0.000000 */
9634 91, /* B0 = 0.002806 */
9635 29921, /* A1 = -1.826233 */
9636 -32688, /* A2 = 0.997559 */
9637 11449, /* B2 = 0.349396 */
9638 -10426, /* B1 = -0.636383 */
9639 11449, /* B0 = 0.349396 */
9640 30045, /* A1 = -1.833862 */
9641 -32688, /* A2 = 0.997589 */
9642 13055, /* B2 = 0.398407 */
9643 -12028, /* B1 = -0.734161 */
9644 13055, /* B0 = 0.398407 */
9645 5, /* Internal filter scaling */
9646 159, /* Minimum in-band energy threshold */
9647 21, /* 21/32 in-band to broad-band ratio */
9648 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9650 { /* f540_660[] */
9651 28499, /* A1 = 1.739441 */
9652 -31129, /* A2 = -0.949982 */
9653 -849, /* B2 = -0.025922 */
9654 0, /* B1 = 0 */
9655 849, /* B0 = 0.025922 */
9656 28128, /* A1 = 1.716797 */
9657 -32130, /* A2 = -0.98056 */
9658 14556, /* B2 = 0.444214 */
9659 -12251, /* B1 = -0.747772 */
9660 14556, /* B0 = 0.444244 */
9661 29667, /* A1 = 1.81073 */
9662 -32244, /* A2 = -0.984039 */
9663 23038, /* B2 = 0.703064 */
9664 -21358, /* B1 = -1.303589 */
9665 23040, /* B0 = 0.703125 */
9666 7, /* Internal filter scaling */
9667 159, /* Minimum in-band energy threshold */
9668 21, /* 21/32 in-band to broad-band ratio */
9669 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9671 { /* f587 */
9672 29271, /* A1 = -1.786560 */
9673 -32599, /* A2 = 0.994873 */
9674 -490, /* B2 = -0.014957 */
9675 0, /* B1 = 0.000000 */
9676 490, /* B0 = 0.014957 */
9677 29246, /* A1 = -1.785095 */
9678 -32700, /* A2 = 0.997925 */
9679 28961, /* B2 = 0.883850 */
9680 -25796, /* B1 = -1.574463 */
9681 28961, /* B0 = 0.883850 */
9682 29383, /* A1 = -1.793396 */
9683 -32700, /* A2 = 0.997955 */
9684 1299, /* B2 = 0.039650 */
9685 -1169, /* B1 = -0.071396 */
9686 1299, /* B0 = 0.039650 */
9687 5, /* Internal filter scaling */
9688 159, /* Minimum in-band energy threshold */
9689 21, /* 21/32 in-band to broad-band ratio */
9690 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9692 { /* f590 */
9693 29230, /* A1 = -1.784058 */
9694 -32584, /* A2 = 0.994415 */
9695 -418, /* B2 = -0.012757 */
9696 0, /* B1 = 0.000000 */
9697 418, /* B0 = 0.012757 */
9698 29206, /* A1 = -1.782593 */
9699 -32688, /* A2 = 0.997559 */
9700 36556, /* B2 = 1.115601 */
9701 -32478, /* B1 = -1.982300 */
9702 36556, /* B0 = 1.115601 */
9703 29345, /* A1 = -1.791077 */
9704 -32688, /* A2 = 0.997589 */
9705 897, /* B2 = 0.027397 */
9706 -808, /* B1 = -0.049334 */
9707 897, /* B0 = 0.027397 */
9708 5, /* Internal filter scaling */
9709 159, /* Minimum in-band energy threshold */
9710 21, /* 21/32 in-band to broad-band ratio */
9711 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9713 { /* f600 */
9714 29116, /* A1 = -1.777100 */
9715 -32603, /* A2 = 0.994965 */
9716 -165, /* B2 = -0.005039 */
9717 0, /* B1 = 0.000000 */
9718 165, /* B0 = 0.005039 */
9719 29089, /* A1 = -1.775452 */
9720 -32708, /* A2 = 0.998199 */
9721 6963, /* B2 = 0.212494 */
9722 -6172, /* B1 = -0.376770 */
9723 6963, /* B0 = 0.212494 */
9724 29237, /* A1 = -1.784485 */
9725 -32710, /* A2 = 0.998230 */
9726 24197, /* B2 = 0.738464 */
9727 -21657, /* B1 = -1.321899 */
9728 24197, /* B0 = 0.738464 */
9729 5, /* Internal filter scaling */
9730 159, /* Minimum in-band energy threshold */
9731 21, /* 21/32 in-band to broad-band ratio */
9732 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9734 { /* f660 */
9735 28376, /* A1 = -1.731934 */
9736 -32567, /* A2 = 0.993896 */
9737 -363, /* B2 = -0.011102 */
9738 0, /* B1 = 0.000000 */
9739 363, /* B0 = 0.011102 */
9740 28337, /* A1 = -1.729614 */
9741 -32683, /* A2 = 0.997434 */
9742 21766, /* B2 = 0.664246 */
9743 -18761, /* B1 = -1.145081 */
9744 21766, /* B0 = 0.664246 */
9745 28513, /* A1 = -1.740356 */
9746 -32686, /* A2 = 0.997498 */
9747 2509, /* B2 = 0.076584 */
9748 -2196, /* B1 = -0.134041 */
9749 2509, /* B0 = 0.076584 */
9750 5, /* Internal filter scaling */
9751 159, /* Minimum in-band energy threshold */
9752 21, /* 21/32 in-band to broad-band ratio */
9753 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9755 { /* f700 */
9756 27844, /* A1 = -1.699463 */
9757 -32563, /* A2 = 0.993744 */
9758 -366, /* B2 = -0.011187 */
9759 0, /* B1 = 0.000000 */
9760 366, /* B0 = 0.011187 */
9761 27797, /* A1 = -1.696655 */
9762 -32686, /* A2 = 0.997498 */
9763 22748, /* B2 = 0.694214 */
9764 -19235, /* B1 = -1.174072 */
9765 22748, /* B0 = 0.694214 */
9766 27995, /* A1 = -1.708740 */
9767 -32688, /* A2 = 0.997559 */
9768 2964, /* B2 = 0.090477 */
9769 -2546, /* B1 = -0.155449 */
9770 2964, /* B0 = 0.090477 */
9771 5, /* Internal filter scaling */
9772 159, /* Minimum in-band energy threshold */
9773 21, /* 21/32 in-band to broad-band ratio */
9774 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9776 { /* f740 */
9777 27297, /* A1 = -1.666077 */
9778 -32551, /* A2 = 0.993408 */
9779 -345, /* B2 = -0.010540 */
9780 0, /* B1 = 0.000000 */
9781 345, /* B0 = 0.010540 */
9782 27240, /* A1 = -1.662598 */
9783 -32683, /* A2 = 0.997406 */
9784 22560, /* B2 = 0.688477 */
9785 -18688, /* B1 = -1.140625 */
9786 22560, /* B0 = 0.688477 */
9787 27461, /* A1 = -1.676147 */
9788 -32684, /* A2 = 0.997467 */
9789 3541, /* B2 = 0.108086 */
9790 -2985, /* B1 = -0.182220 */
9791 3541, /* B0 = 0.108086 */
9792 5, /* Internal filter scaling */
9793 159, /* Minimum in-band energy threshold */
9794 21, /* 21/32 in-band to broad-band ratio */
9795 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9797 { /* f750 */
9798 27155, /* A1 = -1.657410 */
9799 -32551, /* A2 = 0.993408 */
9800 -462, /* B2 = -0.014117 */
9801 0, /* B1 = 0.000000 */
9802 462, /* B0 = 0.014117 */
9803 27097, /* A1 = -1.653870 */
9804 -32683, /* A2 = 0.997406 */
9805 32495, /* B2 = 0.991699 */
9806 -26776, /* B1 = -1.634338 */
9807 32495, /* B0 = 0.991699 */
9808 27321, /* A1 = -1.667542 */
9809 -32684, /* A2 = 0.997467 */
9810 1835, /* B2 = 0.056007 */
9811 -1539, /* B1 = -0.093948 */
9812 1835, /* B0 = 0.056007 */
9813 5, /* Internal filter scaling */
9814 159, /* Minimum in-band energy threshold */
9815 21, /* 21/32 in-band to broad-band ratio */
9816 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9818 { /* f750_1450[] */
9819 19298, /* A1 = 1.177917 */
9820 -24471, /* A2 = -0.746796 */
9821 -4152, /* B2 = -0.126709 */
9822 0, /* B1 = 0 */
9823 4152, /* B0 = 0.126709 */
9824 12902, /* A1 = 0.787476 */
9825 -29091, /* A2 = -0.887817 */
9826 12491, /* B2 = 0.38121 */
9827 -1794, /* B1 = -0.109528 */
9828 12494, /* B0 = 0.381317 */
9829 26291, /* A1 = 1.604736 */
9830 -30470, /* A2 = -0.929901 */
9831 28859, /* B2 = 0.880737 */
9832 -26084, /* B1 = -1.592102 */
9833 28861, /* B0 = 0.880798 */
9834 7, /* Internal filter scaling */
9835 159, /* Minimum in-band energy threshold */
9836 21, /* 21/32 in-band to broad-band ratio */
9837 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9839 { /* f770 */
9840 26867, /* A1 = -1.639832 */
9841 -32551, /* A2 = 0.993408 */
9842 -123, /* B2 = -0.003755 */
9843 0, /* B1 = 0.000000 */
9844 123, /* B0 = 0.003755 */
9845 26805, /* A1 = -1.636108 */
9846 -32683, /* A2 = 0.997406 */
9847 17297, /* B2 = 0.527863 */
9848 -14096, /* B1 = -0.860382 */
9849 17297, /* B0 = 0.527863 */
9850 27034, /* A1 = -1.650085 */
9851 -32684, /* A2 = 0.997467 */
9852 12958, /* B2 = 0.395477 */
9853 -10756, /* B1 = -0.656525 */
9854 12958, /* B0 = 0.395477 */
9855 5, /* Internal filter scaling */
9856 159, /* Minimum in-band energy threshold */
9857 21, /* 21/32 in-band to broad-band ratio */
9858 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9860 { /* f800 */
9861 26413, /* A1 = -1.612122 */
9862 -32547, /* A2 = 0.993286 */
9863 -223, /* B2 = -0.006825 */
9864 0, /* B1 = 0.000000 */
9865 223, /* B0 = 0.006825 */
9866 26342, /* A1 = -1.607849 */
9867 -32686, /* A2 = 0.997498 */
9868 6391, /* B2 = 0.195053 */
9869 -5120, /* B1 = -0.312531 */
9870 6391, /* B0 = 0.195053 */
9871 26593, /* A1 = -1.623108 */
9872 -32688, /* A2 = 0.997559 */
9873 23681, /* B2 = 0.722717 */
9874 -19328, /* B1 = -1.179688 */
9875 23681, /* B0 = 0.722717 */
9876 5, /* Internal filter scaling */
9877 159, /* Minimum in-band energy threshold */
9878 21, /* 21/32 in-band to broad-band ratio */
9879 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9881 { /* f816 */
9882 26168, /* A1 = -1.597209 */
9883 -32528, /* A2 = 0.992706 */
9884 -235, /* B2 = -0.007182 */
9885 0, /* B1 = 0.000000 */
9886 235, /* B0 = 0.007182 */
9887 26092, /* A1 = -1.592590 */
9888 -32675, /* A2 = 0.997192 */
9889 20823, /* B2 = 0.635498 */
9890 -16510, /* B1 = -1.007751 */
9891 20823, /* B0 = 0.635498 */
9892 26363, /* A1 = -1.609070 */
9893 -32677, /* A2 = 0.997253 */
9894 6739, /* B2 = 0.205688 */
9895 -5459, /* B1 = -0.333206 */
9896 6739, /* B0 = 0.205688 */
9897 5, /* Internal filter scaling */
9898 159, /* Minimum in-band energy threshold */
9899 21, /* 21/32 in-band to broad-band ratio */
9900 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9902 { /* f850 */
9903 25641, /* A1 = -1.565063 */
9904 -32536, /* A2 = 0.992950 */
9905 -121, /* B2 = -0.003707 */
9906 0, /* B1 = 0.000000 */
9907 121, /* B0 = 0.003707 */
9908 25560, /* A1 = -1.560059 */
9909 -32684, /* A2 = 0.997437 */
9910 18341, /* B2 = 0.559753 */
9911 -14252, /* B1 = -0.869904 */
9912 18341, /* B0 = 0.559753 */
9913 25837, /* A1 = -1.577026 */
9914 -32684, /* A2 = 0.997467 */
9915 16679, /* B2 = 0.509003 */
9916 -13232, /* B1 = -0.807648 */
9917 16679, /* B0 = 0.509003 */
9918 5, /* Internal filter scaling */
9919 159, /* Minimum in-band energy threshold */
9920 21, /* 21/32 in-band to broad-band ratio */
9921 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9923 { /* f857_1645[] */
9924 16415, /* A1 = 1.001953 */
9925 -23669, /* A2 = -0.722321 */
9926 -4549, /* B2 = -0.138847 */
9927 0, /* B1 = 0 */
9928 4549, /* B0 = 0.138847 */
9929 8456, /* A1 = 0.516174 */
9930 -28996, /* A2 = -0.884918 */
9931 13753, /* B2 = 0.419724 */
9932 -12, /* B1 = -0.000763 */
9933 13757, /* B0 = 0.419846 */
9934 24632, /* A1 = 1.503418 */
9935 -30271, /* A2 = -0.923828 */
9936 29070, /* B2 = 0.887146 */
9937 -25265, /* B1 = -1.542114 */
9938 29073, /* B0 = 0.887268 */
9939 7, /* Internal filter scaling */
9940 159, /* Minimum in-band energy threshold */
9941 21, /* 21/32 in-band to broad-band ratio */
9942 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9944 { /* f900 */
9945 24806, /* A1 = -1.514099 */
9946 -32501, /* A2 = 0.991852 */
9947 -326, /* B2 = -0.009969 */
9948 0, /* B1 = 0.000000 */
9949 326, /* B0 = 0.009969 */
9950 24709, /* A1 = -1.508118 */
9951 -32659, /* A2 = 0.996674 */
9952 20277, /* B2 = 0.618835 */
9953 -15182, /* B1 = -0.926636 */
9954 20277, /* B0 = 0.618835 */
9955 25022, /* A1 = -1.527222 */
9956 -32661, /* A2 = 0.996735 */
9957 4320, /* B2 = 0.131836 */
9958 -3331, /* B1 = -0.203339 */
9959 4320, /* B0 = 0.131836 */
9960 5, /* Internal filter scaling */
9961 159, /* Minimum in-band energy threshold */
9962 21, /* 21/32 in-band to broad-band ratio */
9963 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9965 { /* f900_1300[] */
9966 19776, /* A1 = 1.207092 */
9967 -27437, /* A2 = -0.837341 */
9968 -2666, /* B2 = -0.081371 */
9969 0, /* B1 = 0 */
9970 2666, /* B0 = 0.081371 */
9971 16302, /* A1 = 0.995026 */
9972 -30354, /* A2 = -0.926361 */
9973 10389, /* B2 = 0.317062 */
9974 -3327, /* B1 = -0.203064 */
9975 10389, /* B0 = 0.317062 */
9976 24299, /* A1 = 1.483154 */
9977 -30930, /* A2 = -0.943909 */
9978 25016, /* B2 = 0.763428 */
9979 -21171, /* B1 = -1.292236 */
9980 25016, /* B0 = 0.763428 */
9981 7, /* Internal filter scaling */
9982 159, /* Minimum in-band energy threshold */
9983 21, /* 21/32 in-band to broad-band ratio */
9984 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9986 { /* f935_1215[] */
9987 20554, /* A1 = 1.254517 */
9988 -28764, /* A2 = -0.877838 */
9989 -2048, /* B2 = -0.062515 */
9990 0, /* B1 = 0 */
9991 2048, /* B0 = 0.062515 */
9992 18209, /* A1 = 1.11145 */
9993 -30951, /* A2 = -0.94458 */
9994 9390, /* B2 = 0.286575 */
9995 -3955, /* B1 = -0.241455 */
9996 9390, /* B0 = 0.286575 */
9997 23902, /* A1 = 1.458923 */
9998 -31286, /* A2 = -0.954803 */
9999 23252, /* B2 = 0.709595 */
10000 -19132, /* B1 = -1.167725 */
10001 23252, /* B0 = 0.709595 */
10002 7, /* Internal filter scaling */
10003 159, /* Minimum in-band energy threshold */
10004 21, /* 21/32 in-band to broad-band ratio */
10005 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10007 { /* f941_1477[] */
10008 17543, /* A1 = 1.07074 */
10009 -26220, /* A2 = -0.800201 */
10010 -3298, /* B2 = -0.100647 */
10011 0, /* B1 = 0 */
10012 3298, /* B0 = 0.100647 */
10013 12423, /* A1 = 0.75827 */
10014 -30036, /* A2 = -0.916626 */
10015 12651, /* B2 = 0.386078 */
10016 -2444, /* B1 = -0.14917 */
10017 12653, /* B0 = 0.386154 */
10018 23518, /* A1 = 1.435425 */
10019 -30745, /* A2 = -0.938293 */
10020 27282, /* B2 = 0.832581 */
10021 -22529, /* B1 = -1.375122 */
10022 27286, /* B0 = 0.832703 */
10023 7, /* Internal filter scaling */
10024 159, /* Minimum in-band energy threshold */
10025 21, /* 21/32 in-band to broad-band ratio */
10026 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10028 { /* f942 */
10029 24104, /* A1 = -1.471252 */
10030 -32507, /* A2 = 0.992065 */
10031 -351, /* B2 = -0.010722 */
10032 0, /* B1 = 0.000000 */
10033 351, /* B0 = 0.010722 */
10034 23996, /* A1 = -1.464600 */
10035 -32671, /* A2 = 0.997040 */
10036 22848, /* B2 = 0.697266 */
10037 -16639, /* B1 = -1.015564 */
10038 22848, /* B0 = 0.697266 */
10039 24332, /* A1 = -1.485168 */
10040 -32673, /* A2 = 0.997101 */
10041 4906, /* B2 = 0.149727 */
10042 -3672, /* B1 = -0.224174 */
10043 4906, /* B0 = 0.149727 */
10044 5, /* Internal filter scaling */
10045 159, /* Minimum in-band energy threshold */
10046 21, /* 21/32 in-band to broad-band ratio */
10047 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10049 { /* f950 */
10050 23967, /* A1 = -1.462830 */
10051 -32507, /* A2 = 0.992065 */
10052 -518, /* B2 = -0.015821 */
10053 0, /* B1 = 0.000000 */
10054 518, /* B0 = 0.015821 */
10055 23856, /* A1 = -1.456055 */
10056 -32671, /* A2 = 0.997040 */
10057 26287, /* B2 = 0.802246 */
10058 -19031, /* B1 = -1.161560 */
10059 26287, /* B0 = 0.802246 */
10060 24195, /* A1 = -1.476746 */
10061 -32673, /* A2 = 0.997101 */
10062 2890, /* B2 = 0.088196 */
10063 -2151, /* B1 = -0.131317 */
10064 2890, /* B0 = 0.088196 */
10065 5, /* Internal filter scaling */
10066 159, /* Minimum in-band energy threshold */
10067 21, /* 21/32 in-band to broad-band ratio */
10068 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10070 { /* f950_1400[] */
10071 18294, /* A1 = 1.116638 */
10072 -26962, /* A2 = -0.822845 */
10073 -2914, /* B2 = -0.088936 */
10074 0, /* B1 = 0 */
10075 2914, /* B0 = 0.088936 */
10076 14119, /* A1 = 0.861786 */
10077 -30227, /* A2 = -0.922455 */
10078 11466, /* B2 = 0.349945 */
10079 -2833, /* B1 = -0.172943 */
10080 11466, /* B0 = 0.349945 */
10081 23431, /* A1 = 1.430115 */
10082 -30828, /* A2 = -0.940796 */
10083 25331, /* B2 = 0.773071 */
10084 -20911, /* B1 = -1.276367 */
10085 25331, /* B0 = 0.773071 */
10086 7, /* Internal filter scaling */
10087 159, /* Minimum in-band energy threshold */
10088 21, /* 21/32 in-band to broad-band ratio */
10089 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10091 { /* f975 */
10092 23521, /* A1 = -1.435608 */
10093 -32489, /* A2 = 0.991516 */
10094 -193, /* B2 = -0.005915 */
10095 0, /* B1 = 0.000000 */
10096 193, /* B0 = 0.005915 */
10097 23404, /* A1 = -1.428467 */
10098 -32655, /* A2 = 0.996582 */
10099 17740, /* B2 = 0.541412 */
10100 -12567, /* B1 = -0.767029 */
10101 17740, /* B0 = 0.541412 */
10102 23753, /* A1 = -1.449829 */
10103 -32657, /* A2 = 0.996613 */
10104 9090, /* B2 = 0.277405 */
10105 -6662, /* B1 = -0.406647 */
10106 9090, /* B0 = 0.277405 */
10107 5, /* Internal filter scaling */
10108 159, /* Minimum in-band energy threshold */
10109 21, /* 21/32 in-band to broad-band ratio */
10110 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10112 { /* f1000 */
10113 23071, /* A1 = -1.408203 */
10114 -32489, /* A2 = 0.991516 */
10115 -293, /* B2 = -0.008965 */
10116 0, /* B1 = 0.000000 */
10117 293, /* B0 = 0.008965 */
10118 22951, /* A1 = -1.400818 */
10119 -32655, /* A2 = 0.996582 */
10120 5689, /* B2 = 0.173645 */
10121 -3951, /* B1 = -0.241150 */
10122 5689, /* B0 = 0.173645 */
10123 23307, /* A1 = -1.422607 */
10124 -32657, /* A2 = 0.996613 */
10125 18692, /* B2 = 0.570435 */
10126 -13447, /* B1 = -0.820770 */
10127 18692, /* B0 = 0.570435 */
10128 5, /* Internal filter scaling */
10129 159, /* Minimum in-band energy threshold */
10130 21, /* 21/32 in-band to broad-band ratio */
10131 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10133 { /* f1020 */
10134 22701, /* A1 = -1.385620 */
10135 -32474, /* A2 = 0.991058 */
10136 -292, /* B2 = -0.008933 */
10137 0, /*163840 , B1 = 10.000000 */
10138 292, /* B0 = 0.008933 */
10139 22564, /* A1 = -1.377258 */
10140 -32655, /* A2 = 0.996552 */
10141 20756, /* B2 = 0.633423 */
10142 -14176, /* B1 = -0.865295 */
10143 20756, /* B0 = 0.633423 */
10144 22960, /* A1 = -1.401428 */
10145 -32657, /* A2 = 0.996613 */
10146 6520, /* B2 = 0.198990 */
10147 -4619, /* B1 = -0.281937 */
10148 6520, /* B0 = 0.198990 */
10149 5, /* Internal filter scaling */
10150 159, /* Minimum in-band energy threshold */
10151 21, /* 21/32 in-band to broad-band ratio */
10152 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10154 { /* f1050 */
10155 22142, /* A1 = -1.351501 */
10156 -32474, /* A2 = 0.991058 */
10157 -147, /* B2 = -0.004493 */
10158 0, /* B1 = 0.000000 */
10159 147, /* B0 = 0.004493 */
10160 22000, /* A1 = -1.342834 */
10161 -32655, /* A2 = 0.996552 */
10162 15379, /* B2 = 0.469360 */
10163 -10237, /* B1 = -0.624847 */
10164 15379, /* B0 = 0.469360 */
10165 22406, /* A1 = -1.367554 */
10166 -32657, /* A2 = 0.996613 */
10167 17491, /* B2 = 0.533783 */
10168 -12096, /* B1 = -0.738312 */
10169 17491, /* B0 = 0.533783 */
10170 5, /* Internal filter scaling */
10171 159, /* Minimum in-band energy threshold */
10172 21, /* 21/32 in-band to broad-band ratio */
10173 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10175 { /* f1100_1750[] */
10176 12973, /* A1 = 0.79184 */
10177 -24916, /* A2 = -0.760376 */
10178 6655, /* B2 = 0.203102 */
10179 367, /* B1 = 0.0224 */
10180 6657, /* B0 = 0.203171 */
10181 5915, /* A1 = 0.361053 */
10182 -29560, /* A2 = -0.90213 */
10183 -7777, /* B2 = -0.23735 */
10184 0, /* B1 = 0 */
10185 7777, /* B0 = 0.23735 */
10186 20510, /* A1 = 1.251892 */
10187 -30260, /* A2 = -0.923462 */
10188 26662, /* B2 = 0.81366 */
10189 -20573, /* B1 = -1.255737 */
10190 26668, /* B0 = 0.813843 */
10191 7, /* Internal filter scaling */
10192 159, /* Minimum in-band energy threshold */
10193 21, /* 21/32 in-band to broad-band ratio */
10194 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10196 { /* f1140 */
10197 20392, /* A1 = -1.244629 */
10198 -32460, /* A2 = 0.990601 */
10199 -270, /* B2 = -0.008240 */
10200 0, /* B1 = 0.000000 */
10201 270, /* B0 = 0.008240 */
10202 20218, /* A1 = -1.234009 */
10203 -32655, /* A2 = 0.996582 */
10204 21337, /* B2 = 0.651154 */
10205 -13044, /* B1 = -0.796143 */
10206 21337, /* B0 = 0.651154 */
10207 20684, /* A1 = -1.262512 */
10208 -32657, /* A2 = 0.996643 */
10209 8572, /* B2 = 0.261612 */
10210 -5476, /* B1 = -0.334244 */
10211 8572, /* B0 = 0.261612 */
10212 5, /* Internal filter scaling */
10213 159, /* Minimum in-band energy threshold */
10214 21, /* 21/32 in-band to broad-band ratio */
10215 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10217 { /* f1200 */
10218 19159, /* A1 = -1.169373 */
10219 -32456, /* A2 = 0.990509 */
10220 -335, /* B2 = -0.010252 */
10221 0, /* B1 = 0.000000 */
10222 335, /* B0 = 0.010252 */
10223 18966, /* A1 = -1.157593 */
10224 -32661, /* A2 = 0.996735 */
10225 6802, /* B2 = 0.207588 */
10226 -3900, /* B1 = -0.238098 */
10227 6802, /* B0 = 0.207588 */
10228 19467, /* A1 = -1.188232 */
10229 -32661, /* A2 = 0.996765 */
10230 25035, /* B2 = 0.764008 */
10231 -15049, /* B1 = -0.918579 */
10232 25035, /* B0 = 0.764008 */
10233 5, /* Internal filter scaling */
10234 159, /* Minimum in-band energy threshold */
10235 21, /* 21/32 in-band to broad-band ratio */
10236 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10238 { /* f1209 */
10239 18976, /* A1 = -1.158264 */
10240 -32439, /* A2 = 0.989990 */
10241 -183, /* B2 = -0.005588 */
10242 0, /* B1 = 0.000000 */
10243 183, /* B0 = 0.005588 */
10244 18774, /* A1 = -1.145874 */
10245 -32650, /* A2 = 0.996429 */
10246 15468, /* B2 = 0.472076 */
10247 -8768, /* B1 = -0.535217 */
10248 15468, /* B0 = 0.472076 */
10249 19300, /* A1 = -1.177979 */
10250 -32652, /* A2 = 0.996490 */
10251 19840, /* B2 = 0.605499 */
10252 -11842, /* B1 = -0.722809 */
10253 19840, /* B0 = 0.605499 */
10254 5, /* Internal filter scaling */
10255 159, /* Minimum in-band energy threshold */
10256 21, /* 21/32 in-band to broad-band ratio */
10257 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10259 { /* f1330 */
10260 16357, /* A1 = -0.998413 */
10261 -32368, /* A2 = 0.987793 */
10262 -217, /* B2 = -0.006652 */
10263 0, /* B1 = 0.000000 */
10264 217, /* B0 = 0.006652 */
10265 16107, /* A1 = -0.983126 */
10266 -32601, /* A2 = 0.994904 */
10267 11602, /* B2 = 0.354065 */
10268 -5555, /* B1 = -0.339111 */
10269 11602, /* B0 = 0.354065 */
10270 16722, /* A1 = -1.020630 */
10271 -32603, /* A2 = 0.994965 */
10272 15574, /* B2 = 0.475311 */
10273 -8176, /* B1 = -0.499069 */
10274 15574, /* B0 = 0.475311 */
10275 5, /* Internal filter scaling */
10276 159, /* Minimum in-band energy threshold */
10277 21, /* 21/32 in-band to broad-band ratio */
10278 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10280 { /* f1336 */
10281 16234, /* A1 = -0.990875 */
10282 32404, /* A2 = -0.988922 */
10283 -193, /* B2 = -0.005908 */
10284 0, /* B1 = 0.000000 */
10285 193, /* B0 = 0.005908 */
10286 15986, /* A1 = -0.975769 */
10287 -32632, /* A2 = 0.995880 */
10288 18051, /* B2 = 0.550903 */
10289 -8658, /* B1 = -0.528473 */
10290 18051, /* B0 = 0.550903 */
10291 16591, /* A1 = -1.012695 */
10292 -32634, /* A2 = 0.995941 */
10293 15736, /* B2 = 0.480240 */
10294 -8125, /* B1 = -0.495926 */
10295 15736, /* B0 = 0.480240 */
10296 5, /* Internal filter scaling */
10297 159, /* Minimum in-band energy threshold */
10298 21, /* 21/32 in-band to broad-band ratio */
10299 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10301 { /* f1366 */
10302 15564, /* A1 = -0.949982 */
10303 -32404, /* A2 = 0.988922 */
10304 -269, /* B2 = -0.008216 */
10305 0, /* B1 = 0.000000 */
10306 269, /* B0 = 0.008216 */
10307 15310, /* A1 = -0.934479 */
10308 -32632, /* A2 = 0.995880 */
10309 10815, /* B2 = 0.330063 */
10310 -4962, /* B1 = -0.302887 */
10311 10815, /* B0 = 0.330063 */
10312 15924, /* A1 = -0.971924 */
10313 -32634, /* A2 = 0.995941 */
10314 18880, /* B2 = 0.576172 */
10315 -9364, /* B1 = -0.571594 */
10316 18880, /* B0 = 0.576172 */
10317 5, /* Internal filter scaling */
10318 159, /* Minimum in-band energy threshold */
10319 21, /* 21/32 in-band to broad-band ratio */
10320 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10322 { /* f1380 */
10323 15247, /* A1 = -0.930603 */
10324 -32397, /* A2 = 0.988708 */
10325 -244, /* B2 = -0.007451 */
10326 0, /* B1 = 0.000000 */
10327 244, /* B0 = 0.007451 */
10328 14989, /* A1 = -0.914886 */
10329 -32627, /* A2 = 0.995697 */
10330 18961, /* B2 = 0.578644 */
10331 -8498, /* B1 = -0.518707 */
10332 18961, /* B0 = 0.578644 */
10333 15608, /* A1 = -0.952667 */
10334 -32628, /* A2 = 0.995758 */
10335 11145, /* B2 = 0.340134 */
10336 -5430, /* B1 = -0.331467 */
10337 11145, /* B0 = 0.340134 */
10338 5, /* Internal filter scaling */
10339 159, /* Minimum in-band energy threshold */
10340 21, /* 21/32 in-band to broad-band ratio */
10341 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10343 { /* f1400 */
10344 14780, /* A1 = -0.902130 */
10345 -32393, /* A2 = 0.988586 */
10346 -396, /* B2 = -0.012086 */
10347 0, /* B1 = 0.000000 */
10348 396, /* B0 = 0.012086 */
10349 14510, /* A1 = -0.885651 */
10350 -32630, /* A2 = 0.995819 */
10351 6326, /* B2 = 0.193069 */
10352 -2747, /* B1 = -0.167671 */
10353 6326, /* B0 = 0.193069 */
10354 15154, /* A1 = -0.924957 */
10355 -32632, /* A2 = 0.995850 */
10356 23235, /* B2 = 0.709076 */
10357 -10983, /* B1 = -0.670380 */
10358 23235, /* B0 = 0.709076 */
10359 5, /* Internal filter scaling */
10360 159, /* Minimum in-band energy threshold */
10361 21, /* 21/32 in-band to broad-band ratio */
10362 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10364 { /* f1477 */
10365 13005, /* A1 = -0.793793 */
10366 -32368, /* A2 = 0.987823 */
10367 -500, /* B2 = -0.015265 */
10368 0, /* B1 = 0.000000 */
10369 500, /* B0 = 0.015265 */
10370 12708, /* A1 = -0.775665 */
10371 -32615, /* A2 = 0.995331 */
10372 11420, /* B2 = 0.348526 */
10373 -4306, /* B1 = -0.262833 */
10374 11420, /* B0 = 0.348526 */
10375 13397, /* A1 = -0.817688 */
10376 -32615, /* A2 = 0.995361 */
10377 9454, /* B2 = 0.288528 */
10378 -3981, /* B1 = -0.243027 */
10379 9454, /* B0 = 0.288528 */
10380 5, /* Internal filter scaling */
10381 159, /* Minimum in-band energy threshold */
10382 21, /* 21/32 in-band to broad-band ratio */
10383 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10385 { /* f1600 */
10386 10046, /* A1 = -0.613190 */
10387 -32331, /* A2 = 0.986694 */
10388 -455, /* B2 = -0.013915 */
10389 0, /* B1 = 0.000000 */
10390 455, /* B0 = 0.013915 */
10391 9694, /* A1 = -0.591705 */
10392 -32601, /* A2 = 0.994934 */
10393 6023, /* B2 = 0.183815 */
10394 -1708, /* B1 = -0.104279 */
10395 6023, /* B0 = 0.183815 */
10396 10478, /* A1 = -0.639587 */
10397 -32603, /* A2 = 0.994965 */
10398 22031, /* B2 = 0.672333 */
10399 -7342, /* B1 = -0.448151 */
10400 22031, /* B0 = 0.672333 */
10401 5, /* Internal filter scaling */
10402 159, /* Minimum in-band energy threshold */
10403 21, /* 21/32 in-band to broad-band ratio */
10404 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10406 { /* f1633_1638[] */
10407 9181, /* A1 = 0.560394 */
10408 -32256, /* A2 = -0.984375 */
10409 -556, /* B2 = -0.016975 */
10410 0, /* B1 = 0 */
10411 556, /* B0 = 0.016975 */
10412 8757, /* A1 = 0.534515 */
10413 -32574, /* A2 = -0.99408 */
10414 8443, /* B2 = 0.25769 */
10415 -2135, /* B1 = -0.130341 */
10416 8443, /* B0 = 0.25769 */
10417 9691, /* A1 = 0.591522 */
10418 -32574, /* A2 = -0.99411 */
10419 15446, /* B2 = 0.471375 */
10420 -4809, /* B1 = -0.293579 */
10421 15446, /* B0 = 0.471375 */
10422 7, /* Internal filter scaling */
10423 159, /* Minimum in-band energy threshold */
10424 21, /* 21/32 in-band to broad-band ratio */
10425 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10427 { /* f1800 */
10428 5076, /* A1 = -0.309875 */
10429 -32304, /* A2 = 0.985840 */
10430 -508, /* B2 = -0.015503 */
10431 0, /* B1 = 0.000000 */
10432 508, /* B0 = 0.015503 */
10433 4646, /* A1 = -0.283600 */
10434 -32605, /* A2 = 0.995026 */
10435 6742, /* B2 = 0.205780 */
10436 -878, /* B1 = -0.053635 */
10437 6742, /* B0 = 0.205780 */
10438 5552, /* A1 = -0.338928 */
10439 -32605, /* A2 = 0.995056 */
10440 23667, /* B2 = 0.722260 */
10441 -4297, /* B1 = -0.262329 */
10442 23667, /* B0 = 0.722260 */
10443 5, /* Internal filter scaling */
10444 159, /* Minimum in-band energy threshold */
10445 21, /* 21/32 in-band to broad-band ratio */
10446 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10448 { /* f1860 */
10449 3569, /* A1 = -0.217865 */
10450 -32292, /* A2 = 0.985504 */
10451 -239, /* B2 = -0.007322 */
10452 0, /* B1 = 0.000000 */
10453 239, /* B0 = 0.007322 */
10454 3117, /* A1 = -0.190277 */
10455 -32603, /* A2 = 0.994965 */
10456 18658, /* B2 = 0.569427 */
10457 -1557, /* B1 = -0.095032 */
10458 18658, /* B0 = 0.569427 */
10459 4054, /* A1 = -0.247437 */
10460 -32603, /* A2 = 0.994965 */
10461 18886, /* B2 = 0.576385 */
10462 -2566, /* B1 = -0.156647 */
10463 18886, /* B0 = 0.576385 */
10464 5, /* Internal filter scaling */
10465 159, /* Minimum in-band energy threshold */
10466 21, /* 21/32 in-band to broad-band ratio */
10467 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10470 static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf)
10472 unsigned short cmd;
10473 int cnt, max;
10475 if (jf->filter > 3) {
10476 return -1;
10478 if (ixj_WriteDSPCommand(0x5154 + jf->filter, j)) /* Select Filter */
10480 return -1;
10481 if (!jf->enable) {
10482 if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
10484 return -1;
10485 else
10486 return 0;
10487 } else {
10488 if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
10490 return -1;
10491 /* Select the filter (f0 - f3) to use. */
10492 if (ixj_WriteDSPCommand(0x5154 + jf->filter, j))
10493 return -1;
10495 if (jf->freq < 12 && jf->freq > 3) {
10496 /* Select the frequency for the selected filter. */
10497 if (ixj_WriteDSPCommand(0x5170 + jf->freq, j))
10498 return -1;
10499 } else if (jf->freq > 11) {
10500 /* We need to load a programmable filter set for undefined */
10501 /* frequencies. So we will point the filter to a programmable set. */
10502 /* Since there are only 4 filters and 4 programmable sets, we will */
10503 /* just point the filter to the same number set and program it for the */
10504 /* frequency we want. */
10505 if (ixj_WriteDSPCommand(0x5170 + jf->filter, j))
10506 return -1;
10507 if (j->ver.low != 0x12) {
10508 cmd = 0x515B;
10509 max = 19;
10510 } else {
10511 cmd = 0x515E;
10512 max = 15;
10514 if (ixj_WriteDSPCommand(cmd, j))
10515 return -1;
10516 for (cnt = 0; cnt < max; cnt++) {
10517 if (ixj_WriteDSPCommand(tone_table[jf->freq - 12][cnt], j))
10518 return -1;
10521 j->filter_en[jf->filter] = jf->enable;
10522 return 0;
10525 static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr)
10527 unsigned short cmd;
10528 int cnt, max;
10529 if (jfr->filter > 3) {
10530 return -1;
10532 if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j)) /* Select Filter */
10533 return -1;
10535 if (!jfr->enable) {
10536 if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
10537 return -1;
10538 else
10539 return 0;
10540 } else {
10541 if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
10542 return -1;
10543 /* Select the filter (f0 - f3) to use. */
10544 if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j))
10545 return -1;
10547 /* We need to load a programmable filter set for undefined */
10548 /* frequencies. So we will point the filter to a programmable set. */
10549 /* Since there are only 4 filters and 4 programmable sets, we will */
10550 /* just point the filter to the same number set and program it for the */
10551 /* frequency we want. */
10552 if (ixj_WriteDSPCommand(0x5170 + jfr->filter, j))
10553 return -1;
10554 if (j->ver.low != 0x12) {
10555 cmd = 0x515B;
10556 max = 19;
10557 } else {
10558 cmd = 0x515E;
10559 max = 15;
10561 if (ixj_WriteDSPCommand(cmd, j))
10562 return -1;
10563 for (cnt = 0; cnt < max; cnt++) {
10564 if (ixj_WriteDSPCommand(jfr->coeff[cnt], j))
10565 return -1;
10567 j->filter_en[jfr->filter] = jfr->enable;
10568 return 0;
10571 static int ixj_init_tone(IXJ *j, IXJ_TONE * ti)
10573 int freq0, freq1;
10574 unsigned short data;
10575 if (ti->freq0) {
10576 freq0 = ti->freq0;
10577 } else {
10578 freq0 = 0x7FFF;
10581 if (ti->freq1) {
10582 freq1 = ti->freq1;
10583 } else {
10584 freq1 = 0x7FFF;
10587 if(ti->tone_index > 12 && ti->tone_index < 28)
10589 if (ixj_WriteDSPCommand(0x6800 + ti->tone_index, j))
10590 return -1;
10591 if (ixj_WriteDSPCommand(0x6000 + (ti->gain1 << 4) + ti->gain0, j))
10592 return -1;
10593 data = freq0;
10594 if (ixj_WriteDSPCommand(data, j))
10595 return -1;
10596 data = freq1;
10597 if (ixj_WriteDSPCommand(data, j))
10598 return -1;
10600 return freq0;