1 /****************************************************************************
2 * ixj.c
3 *
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
8 *
9 * (c) Copyright 1999-2001 Quicknet Technologies, Inc.
10 *
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.
15 *
16 * Author: Ed Okerson, <eokerson@quicknet.net>
17 *
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>
22 *
23 * Fixes: David Huggins-Daines, <dhd@cepstral.com>
24 * Fabio Ferrari, <fabio.ferrari@digitro.com.br>
25 * Artis Kugevics, <artis@mt.lv>
26 *
27 * More information about the hardware related to this driver can be found
28 * at our website: http://www.quicknet.net
29 *
30 * IN NO EVENT SHALL QUICKNET TECHNOLOGIES, INC. BE LIABLE TO ANY PARTY FOR
31 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
32 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF QUICKNET
33 * TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 * QUICKNET TECHNOLOGIES, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
36 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
37 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
38 * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION
39 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
40 *
41 ***************************************************************************/
42
43 static char ixj_c_rcsid[] = "$Id: ixj.c,v 4.7 2001/08/13 06:19:33 craigs Exp $";
44 static char ixj_c_revision[] = "$Revision: 4.7 $";
45
46 /*
47 * $Log: ixj.c,v $
48 * Revision 4.7 2001/08/13 06:19:33 craigs
49 * Added additional changes from Alan Cox and John Anderson for
50 * 2.2 to 2.4 cleanup and bounds checking
51 *
52 * Revision 4.6 2001/08/13 01:05:05 craigs
53 * Really fixed PHONE_QUERY_CODEC problem this time
54 *
55 * Revision 4.5 2001/08/13 00:11:03 craigs
56 * Fixed problem in handling of PHONE_QUERY_CODEC, thanks to Shane Anderson
57 *
58 * Revision 4.4 2001/08/07 07:58:12 craigs
59 * Changed back to three digit version numbers
60 * Added tagbuild target to allow automatic and easy tagging of versions
61 *
62 * Revision 4.3 2001/08/07 07:24:47 craigs
63 * Added ixj-ver.h to allow easy configuration management of driver
64 * Added display of version number in /prox/ixj
65 *
66 * Revision 4.2 2001/08/06 07:07:19 craigs
67 * Reverted IXJCTL_DSP_TYPE and IXJCTL_DSP_VERSION files to original
68 * behaviour of returning int rather than short *
69 *
70 * Revision 4.1 2001/08/05 00:17:37 craigs
71 * More changes for correct PCMCIA installation
72 * Start of changes for backward Linux compatibility
73 *
74 * Revision 4.0 2001/08/04 12:33:12 craigs
75 * New version using GNU autoconf
76 *
77 * Revision 3.105 2001/07/20 23:14:32 eokerson
78 * More work on CallerID generation when using ring cadences.
79 *
80 * Revision 3.104 2001/07/06 01:33:55 eokerson
81 * Some bugfixes from Robert Vojta <vojta@ipex.cz> and a few mods to the Makefile.
82 *
83 * Revision 3.103 2001/07/05 19:20:16 eokerson
84 * Updated HOWTO
85 * Changed mic gain to 30dB on Internet LineJACK mic/speaker port.
86 *
87 * Revision 3.102 2001/07/03 23:51:21 eokerson
88 * Un-mute mic on Internet LineJACK when in speakerphone mode.
89 *
90 * Revision 3.101 2001/07/02 19:26:56 eokerson
91 * Removed initialiazation of ixjdebug and ixj_convert_loaded so they will go in the .bss instead of the .data
92 *
93 * Revision 3.100 2001/07/02 19:18:27 eokerson
94 * Changed driver to make dynamic allocation possible. We now pass IXJ * between functions instead of array indexes.
95 * Fixed the way the POTS and PSTN ports interact during a PSTN call to allow local answering.
96 * Fixed speaker mode on Internet LineJACK.
97 *
98 * Revision 3.99 2001/05/09 14:11:16 eokerson
99 * Fixed kmalloc error in ixj_build_filter_cadence. Thanks David Chan <cat@waulogy.stanford.edu>.
100 *
101 * Revision 3.98 2001/05/08 19:55:33 eokerson
102 * Fixed POTS hookstate detection while it is connected to PSTN port.
103 *
104 * Revision 3.97 2001/05/08 00:01:04 eokerson
105 * Fixed kernel oops when sending caller ID data.
106 *
107 * Revision 3.96 2001/05/04 23:09:30 eokerson
108 * Now uses one kernel timer for each card, instead of one for the entire driver.
109 *
110 * Revision 3.95 2001/04/25 22:06:47 eokerson
111 * Fixed squawking at beginning of some G.723.1 calls.
112 *
113 * Revision 3.94 2001/04/03 23:42:00 eokerson
114 * Added linear volume ioctls
115 * Added raw filter load ioctl
116 *
117 * Revision 3.93 2001/02/27 01:00:06 eokerson
118 * Fixed blocking in CallerID.
119 * Reduced size of ixj structure for smaller driver footprint.
120 *
121 * Revision 3.92 2001/02/20 22:02:59 eokerson
122 * Fixed isapnp and pcmcia module compatibility for 2.4.x kernels.
123 * Improved PSTN ring detection.
124 * Fixed wink generation on POTS ports.
125 *
126 * Revision 3.91 2001/02/13 00:55:44 eokerson
127 * Turn AEC back on after changing frame sizes.
128 *
129 * Revision 3.90 2001/02/12 16:42:00 eokerson
130 * Added ALAW codec, thanks to Fabio Ferrari for the table based converters to make ALAW from ULAW.
131 *
132 * Revision 3.89 2001/02/12 15:41:16 eokerson
133 * Fix from Artis Kugevics - Tone gains were not being set correctly.
134 *
135 * Revision 3.88 2001/02/05 23:25:42 eokerson
136 * Fixed lockup bugs with deregister.
137 *
138 * Revision 3.87 2001/01/29 21:00:39 eokerson
139 * Fix from Fabio Ferrari <fabio.ferrari@digitro.com.br> to properly handle EAGAIN and EINTR during non-blocking write.
140 * Updated copyright date.
141 *
142 * Revision 3.86 2001/01/23 23:53:46 eokerson
143 * Fixes to G.729 compatibility.
144 *
145 * Revision 3.85 2001/01/23 21:30:36 eokerson
146 * Added verbage about cards supported.
147 * Removed commands that put the card in low power mode at some times that it should not be in low power mode.
148 *
149 * Revision 3.84 2001/01/22 23:32:10 eokerson
150 * Some bugfixes from David Huggins-Daines, <dhd@cepstral.com> and other cleanups.
151 *
152 * Revision 3.83 2001/01/19 14:51:41 eokerson
153 * Fixed ixj_WriteDSPCommand to decrement usage counter when command fails.
154 *
155 * Revision 3.82 2001/01/19 00:34:49 eokerson
156 * Added verbosity to write overlap errors.
157 *
158 * Revision 3.81 2001/01/18 23:56:54 eokerson
159 * Fixed PSTN line test functions.
160 *
161 * Revision 3.80 2001/01/18 22:29:27 eokerson
162 * Updated AEC/AGC values for different cards.
163 *
164 * Revision 3.79 2001/01/17 02:58:54 eokerson
165 * Fixed AEC reset after Caller ID.
166 * Fixed Codec lockup after Caller ID on Call Waiting when not using 30ms frames.
167 *
168 * Revision 3.78 2001/01/16 19:43:09 eokerson
169 * Added support for Linux 2.4.x kernels.
170 *
171 * Revision 3.77 2001/01/09 04:00:52 eokerson
172 * Linetest will now test the line, even if it has previously succeded.
173 *
174 * Revision 3.76 2001/01/08 19:27:00 eokerson
175 * Fixed problem with standard cable on Internet PhoneCARD.
176 *
177 * Revision 3.75 2000/12/22 16:52:14 eokerson
178 * Modified to allow hookstate detection on the POTS port when the PSTN port is selected.
179 *
180 * Revision 3.74 2000/12/08 22:41:50 eokerson
181 * Added capability for G729B.
182 *
183 * Revision 3.73 2000/12/07 23:35:16 eokerson
184 * Added capability to have different ring pattern before CallerID data.
185 * Added hookstate checks in CallerID routines to stop FSK.
186 *
187 * Revision 3.72 2000/12/06 19:31:31 eokerson
188 * Modified signal behavior to only send one signal per event.
189 *
190 * Revision 3.71 2000/12/06 03:23:08 eokerson
191 * Fixed CallerID on Call Waiting.
192 *
193 * Revision 3.70 2000/12/04 21:29:37 eokerson
194 * Added checking to Smart Cable gain functions.
195 *
196 * Revision 3.69 2000/12/04 21:05:20 eokerson
197 * Changed ixjdebug levels.
198 * Added ioctls to change gains in Internet Phone CARD Smart Cable.
199 *
200 * Revision 3.68 2000/12/04 00:17:21 craigs
201 * Changed mixer voice gain to +6dB rather than 0dB
202 *
203 * Revision 3.67 2000/11/30 21:25:51 eokerson
204 * Fixed write signal errors.
205 *
206 * Revision 3.66 2000/11/29 22:42:44 eokerson
207 * Fixed PSTN ring detect problems.
208 *
209 * Revision 3.65 2000/11/29 07:31:55 craigs
210 * Added new 425Hz filter co-efficients
211 * Added card-specific DTMF prescaler initialisation
212 *
213 * Revision 3.64 2000/11/28 14:03:32 craigs
214 * Changed certain mixer initialisations to be 0dB rather than 12dB
215 * Added additional information to /proc/ixj
216 *
217 * Revision 3.63 2000/11/28 11:38:41 craigs
218 * Added display of AEC modes in AUTO and AGC mode
219 *
220 * Revision 3.62 2000/11/28 04:05:44 eokerson
221 * Improved PSTN ring detection routine.
222 *
223 * Revision 3.61 2000/11/27 21:53:12 eokerson
224 * Fixed flash detection.
225 *
226 * Revision 3.60 2000/11/27 15:57:29 eokerson
227 * More work on G.729 load routines.
228 *
229 * Revision 3.59 2000/11/25 21:55:12 eokerson
230 * Fixed errors in G.729 load routine.
231 *
232 * Revision 3.58 2000/11/25 04:08:29 eokerson
233 * Added board locks around G.729 and TS85 load routines.
234 *
235 * Revision 3.57 2000/11/24 05:35:17 craigs
236 * Added ability to retrieve mixer values on LineJACK
237 * Added complete initialisation of all mixer values at startup
238 * Fixed spelling mistake
239 *
240 * Revision 3.56 2000/11/23 02:52:11 robertj
241 * Added cvs change log keyword.
242 * Fixed bug in capabilities list when using G.729 module.
243 *
244 */
245
246 #include "ixj-ver.h"
247
248 #define PERFMON_STATS
249 #define IXJDEBUG 0
250 #define MAXRINGS 5
251
252 #include <linux/module.h>
253
254 #include <linux/init.h>
255 #include <linux/sched.h>
256 #include <linux/kernel.h> /* printk() */
257 #include <linux/fs.h> /* everything... */
258 #include <linux/errno.h> /* error codes */
259 #include <linux/slab.h>
260 #include <linux/mm.h>
261 #include <linux/ioport.h>
262 #include <linux/interrupt.h>
263 #include <linux/tqueue.h>
264 #include <linux/proc_fs.h>
265 #include <linux/poll.h>
266 #include <linux/timer.h>
267 #include <linux/delay.h>
268 #include <linux/pci.h>
269
270 #include <asm/io.h>
271 #include <asm/segment.h>
272 #include <asm/uaccess.h>
273
274 #include <linux/isapnp.h>
275
276 #include "ixj.h"
277
278 #define TYPE(dev) (MINOR(dev) >> 4)
279 #define NUM(dev) (MINOR(dev) & 0xf)
280
281 static int ixjdebug;
282 static int hertz = HZ;
283 static int samplerate = 100;
284
285 MODULE_PARM(ixjdebug, "i");
286
287 /************************************************************************
288 *
289 * ixjdebug meanings are now bit mapped instead of level based
290 * Values can be or'ed together to turn on multiple messages
291 *
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
302 *
303 ************************************************************************/
304
305 #ifdef IXJ_DYN_ALLOC
306
307 static IXJ *ixj[IXJMAX];
308 #define get_ixj(b) ixj[(b)]
309
310 /*
311 * Allocate a free IXJ device
312 */
313
ixj_alloc()314 static IXJ *ixj_alloc()
315 {
316 for(cnt=0; cnt<IXJMAX; cnt++)
317 {
318 if(ixj[cnt] == NULL || !ixj[cnt]->DSPbase)
319 {
320 j = kmalloc(sizeof(IXJ), GFP_KERNEL);
321 if (j == NULL)
322 return NULL;
323 ixj[cnt] = j;
324 return j;
325 }
326 }
327 return NULL;
328 }
329
ixj_fsk_free(IXJ * j)330 static void ixj_fsk_free(IXJ *j)
331 {
332 if(j->fskdata != NULL) {
333 kfree(j->fskdata);
334 j->fskdata = NULL;
335 }
336 }
337
ixj_fsk_alloc(IXJ * j)338 static void ixj_fsk_alloc(IXJ *j)
339 {
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);
345 }
346 return;
347 } else {
348 j->fsksize = 8000;
349 if(ixjdebug & 0x0200) {
350 printk("IXJ phone%d - allocate succeded\n", j->board);
351 }
352 }
353 }
354 }
355
356 #else
357
358 static IXJ ixj[IXJMAX];
359 #define get_ixj(b) (&ixj[(b)])
360
361 /*
362 * Allocate a free IXJ device
363 */
364
ixj_alloc(void)365 static IXJ *ixj_alloc(void)
366 {
367 int cnt;
368 for(cnt=0; cnt<IXJMAX; cnt++)
369 {
370 if(!ixj[cnt].DSPbase)
371 {
372 return &ixj[cnt];
373 }
374 }
375 return NULL;
376 }
377
ixj_fsk_free(IXJ * j)378 static inline void ixj_fsk_free(IXJ *j) {;}
379
ixj_fsk_alloc(IXJ * j)380 static inline void ixj_fsk_alloc(IXJ *j)
381 {
382 j->fsksize = 8000;
383 }
384
385 #endif
386
387 #ifdef PERFMON_STATS
388 #define ixj_perfmon(x) ((x)++)
389 #else
390 #define ixj_perfmon(x) do { } while(0)
391 #endif
392
393 static int ixj_convert_loaded;
394
395 static int ixj_WriteDSPCommand(unsigned short, IXJ *j);
396
397 /************************************************************************
398 *
399 * These are function definitions to allow external modules to register
400 * enhanced functionality call backs.
401 *
402 ************************************************************************/
403
Stub(IXJ * J,unsigned long arg)404 static int Stub(IXJ * J, unsigned long arg)
405 {
406 return 0;
407 }
408
409 static IXJ_REGFUNC ixj_DownloadG729 = &Stub;
410 static IXJ_REGFUNC ixj_DownloadTS85 = &Stub;
411 static IXJ_REGFUNC ixj_PreRead = &Stub;
412 static IXJ_REGFUNC ixj_PostRead = &Stub;
413 static IXJ_REGFUNC ixj_PreWrite = &Stub;
414 static IXJ_REGFUNC ixj_PostWrite = &Stub;
415 static IXJ_REGFUNC ixj_PreIoctl = &Stub;
416 static IXJ_REGFUNC ixj_PostIoctl = &Stub;
417
418 static void ixj_read_frame(IXJ *j);
419 static void ixj_write_frame(IXJ *j);
420 static void ixj_init_timer(IXJ *j);
421 static void ixj_add_timer(IXJ * j);
422 static void ixj_timeout(unsigned long ptr);
423 static int read_filters(IXJ *j);
424 static int LineMonitor(IXJ *j);
425 static int ixj_fasync(int fd, struct file *, int mode);
426 static int ixj_set_port(IXJ *j, int arg);
427 static int ixj_set_pots(IXJ *j, int arg);
428 static int ixj_hookstate(IXJ *j);
429 static int ixj_record_start(IXJ *j);
430 static void ixj_record_stop(IXJ *j);
431 static void set_rec_volume(IXJ *j, int volume);
432 static int get_rec_volume(IXJ *j);
433 static int set_rec_codec(IXJ *j, int rate);
434 static void ixj_vad(IXJ *j, int arg);
435 static int ixj_play_start(IXJ *j);
436 static void ixj_play_stop(IXJ *j);
437 static int ixj_set_tone_on(unsigned short arg, IXJ *j);
438 static int ixj_set_tone_off(unsigned short, IXJ *j);
439 static int ixj_play_tone(IXJ *j, char tone);
440 static void ixj_aec_start(IXJ *j, int level);
441 static int idle(IXJ *j);
442 static void ixj_ring_on(IXJ *j);
443 static void ixj_ring_off(IXJ *j);
444 static void aec_stop(IXJ *j);
445 static void ixj_ringback(IXJ *j);
446 static void ixj_busytone(IXJ *j);
447 static void ixj_dialtone(IXJ *j);
448 static void ixj_cpt_stop(IXJ *j);
449 static char daa_int_read(IXJ *j);
450 static char daa_CR_read(IXJ *j, int cr);
451 static int daa_set_mode(IXJ *j, int mode);
452 static int ixj_linetest(IXJ *j);
453 static int ixj_daa_write(IXJ *j);
454 static int ixj_daa_cid_read(IXJ *j);
455 static void DAA_Coeff_US(IXJ *j);
456 static void DAA_Coeff_UK(IXJ *j);
457 static void DAA_Coeff_France(IXJ *j);
458 static void DAA_Coeff_Germany(IXJ *j);
459 static void DAA_Coeff_Australia(IXJ *j);
460 static void DAA_Coeff_Japan(IXJ *j);
461 static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf);
462 static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr);
463 static int ixj_init_tone(IXJ *j, IXJ_TONE * ti);
464 static int ixj_build_cadence(IXJ *j, IXJ_CADENCE * cp);
465 static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE * cp);
466 /* Serial Control Interface funtions */
467 static int SCI_Control(IXJ *j, int control);
468 static int SCI_Prepare(IXJ *j);
469 static int SCI_WaitHighSCI(IXJ *j);
470 static int SCI_WaitLowSCI(IXJ *j);
471 static DWORD PCIEE_GetSerialNumber(WORD wAddress);
472 static int ixj_PCcontrol_wait(IXJ *j);
473 static void ixj_pre_cid(IXJ *j);
474 static void ixj_write_cid(IXJ *j);
475 static void ixj_write_cid_bit(IXJ *j, int bit);
476 static int set_base_frame(IXJ *j, int size);
477 static int set_play_codec(IXJ *j, int rate);
478 static void set_rec_depth(IXJ *j, int depth);
479 static int ixj_mixer(long val, IXJ *j);
480
481 /************************************************************************
482 CT8020/CT8021 Host Programmers Model
483 Host address Function Access
484 DSPbase +
485 0-1 Aux Software Status Register (reserved) Read Only
486 2-3 Software Status Register Read Only
487 4-5 Aux Software Control Register (reserved) Read Write
488 6-7 Software Control Register Read Write
489 8-9 Hardware Status Register Read Only
490 A-B Hardware Control Register Read Write
491 C-D Host Transmit (Write) Data Buffer Access Port (buffer input)Write Only
492 E-F Host Recieve (Read) Data Buffer Access Port (buffer input) Read Only
493 ************************************************************************/
494
ixj_read_HSR(IXJ * j)495 static inline void ixj_read_HSR(IXJ *j)
496 {
497 j->hsr.bytes.low = inb_p(j->DSPbase + 8);
498 j->hsr.bytes.high = inb_p(j->DSPbase + 9);
499 }
500
IsControlReady(IXJ * j)501 static inline int IsControlReady(IXJ *j)
502 {
503 ixj_read_HSR(j);
504 return j->hsr.bits.controlrdy ? 1 : 0;
505 }
506
IsPCControlReady(IXJ * j)507 static inline int IsPCControlReady(IXJ *j)
508 {
509 j->pccr1.byte = inb_p(j->XILINXbase + 3);
510 return j->pccr1.bits.crr ? 1 : 0;
511 }
512
IsStatusReady(IXJ * j)513 static inline int IsStatusReady(IXJ *j)
514 {
515 ixj_read_HSR(j);
516 return j->hsr.bits.statusrdy ? 1 : 0;
517 }
518
IsRxReady(IXJ * j)519 static inline int IsRxReady(IXJ *j)
520 {
521 ixj_read_HSR(j);
522 ixj_perfmon(j->rxreadycheck);
523 return j->hsr.bits.rxrdy ? 1 : 0;
524 }
525
IsTxReady(IXJ * j)526 static inline int IsTxReady(IXJ *j)
527 {
528 ixj_read_HSR(j);
529 ixj_perfmon(j->txreadycheck);
530 return j->hsr.bits.txrdy ? 1 : 0;
531 }
532
set_play_volume(IXJ * j,int volume)533 static inline void set_play_volume(IXJ *j, int volume)
534 {
535 if (ixjdebug & 0x0002)
536 printk(KERN_INFO "IXJ: /dev/phone%d Setting Play Volume to 0x%4.4x\n", j->board, volume);
537 ixj_WriteDSPCommand(0xCF02, j);
538 ixj_WriteDSPCommand(volume, j);
539 }
540
set_play_volume_linear(IXJ * j,int volume)541 static int set_play_volume_linear(IXJ *j, int volume)
542 {
543 int newvolume, dspplaymax;
544
545 if (ixjdebug & 0x0002)
546 printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Play Volume to 0x%4.4x\n", j->board, volume);
547 if(volume > 100 || volume < 0) {
548 return -1;
549 }
550
551 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
552 switch (j->cardtype) {
553 case QTI_PHONEJACK:
554 dspplaymax = 0x380;
555 break;
556 case QTI_LINEJACK:
557 if(j->port == PORT_PSTN) {
558 dspplaymax = 0x48;
559 } else {
560 dspplaymax = 0x100;
561 }
562 break;
563 case QTI_PHONEJACK_LITE:
564 dspplaymax = 0x380;
565 break;
566 case QTI_PHONEJACK_PCI:
567 dspplaymax = 0x6C;
568 break;
569 case QTI_PHONECARD:
570 dspplaymax = 0x50;
571 break;
572 default:
573 return -1;
574 }
575 newvolume = (dspplaymax * volume) / 100;
576 set_play_volume(j, newvolume);
577 return 0;
578 }
579
set_play_depth(IXJ * j,int depth)580 static inline void set_play_depth(IXJ *j, int depth)
581 {
582 if (depth > 60)
583 depth = 60;
584 if (depth < 0)
585 depth = 0;
586 ixj_WriteDSPCommand(0x5280 + depth, j);
587 }
588
get_play_volume(IXJ * j)589 static inline int get_play_volume(IXJ *j)
590 {
591 ixj_WriteDSPCommand(0xCF00, j);
592 return j->ssr.high << 8 | j->ssr.low;
593 }
594
get_play_volume_linear(IXJ * j)595 static int get_play_volume_linear(IXJ *j)
596 {
597 int volume, newvolume, dspplaymax;
598
599 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
600 switch (j->cardtype) {
601 case QTI_PHONEJACK:
602 dspplaymax = 0x380;
603 break;
604 case QTI_LINEJACK:
605 if(j->port == PORT_PSTN) {
606 dspplaymax = 0x48;
607 } else {
608 dspplaymax = 0x100;
609 }
610 break;
611 case QTI_PHONEJACK_LITE:
612 dspplaymax = 0x380;
613 break;
614 case QTI_PHONEJACK_PCI:
615 dspplaymax = 0x6C;
616 break;
617 case QTI_PHONECARD:
618 dspplaymax = 100;
619 break;
620 default:
621 return -1;
622 }
623 volume = get_play_volume(j);
624 newvolume = (volume * 100) / dspplaymax;
625 if(newvolume > 100)
626 newvolume = 100;
627 return newvolume;
628 }
629
SLIC_GetState(IXJ * j)630 static inline BYTE SLIC_GetState(IXJ *j)
631 {
632 if (j->cardtype == QTI_PHONECARD) {
633 j->pccr1.byte = 0;
634 j->psccr.bits.dev = 3;
635 j->psccr.bits.rw = 1;
636 outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
637 ixj_PCcontrol_wait(j);
638 j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
639 ixj_PCcontrol_wait(j);
640 if (j->pslic.bits.powerdown)
641 return PLD_SLIC_STATE_OC;
642 else if (!j->pslic.bits.ring0 && !j->pslic.bits.ring1)
643 return PLD_SLIC_STATE_ACTIVE;
644 else
645 return PLD_SLIC_STATE_RINGING;
646 } else {
647 j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
648 }
649 return j->pld_slicr.bits.state;
650 }
651
SLIC_SetState(BYTE byState,IXJ * j)652 static BOOL SLIC_SetState(BYTE byState, IXJ *j)
653 {
654 BOOL fRetVal = FALSE;
655
656 if (j->cardtype == QTI_PHONECARD) {
657 if (j->flags.pcmciasct) {
658 switch (byState) {
659 case PLD_SLIC_STATE_TIPOPEN:
660 case PLD_SLIC_STATE_OC:
661 j->pslic.bits.powerdown = 1;
662 j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
663 fRetVal = TRUE;
664 break;
665 case PLD_SLIC_STATE_RINGING:
666 if (j->readers || j->writers) {
667 j->pslic.bits.powerdown = 0;
668 j->pslic.bits.ring0 = 1;
669 j->pslic.bits.ring1 = 0;
670 fRetVal = TRUE;
671 }
672 break;
673 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
674
675 case PLD_SLIC_STATE_STANDBY:
676 case PLD_SLIC_STATE_ACTIVE:
677 if (j->readers || j->writers) {
678 j->pslic.bits.powerdown = 0;
679 } else {
680 j->pslic.bits.powerdown = 1;
681 }
682 j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
683 fRetVal = TRUE;
684 break;
685 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
686
687 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
688
689 default:
690 fRetVal = FALSE;
691 break;
692 }
693 j->psccr.bits.dev = 3;
694 j->psccr.bits.rw = 0;
695 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
696 ixj_PCcontrol_wait(j);
697 }
698 } else {
699 /* Set the C1, C2, C3 & B2EN signals. */
700 switch (byState) {
701 case PLD_SLIC_STATE_OC:
702 j->pld_slicw.bits.c1 = 0;
703 j->pld_slicw.bits.c2 = 0;
704 j->pld_slicw.bits.c3 = 0;
705 j->pld_slicw.bits.b2en = 0;
706 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
707 fRetVal = TRUE;
708 break;
709 case PLD_SLIC_STATE_RINGING:
710 j->pld_slicw.bits.c1 = 1;
711 j->pld_slicw.bits.c2 = 0;
712 j->pld_slicw.bits.c3 = 0;
713 j->pld_slicw.bits.b2en = 1;
714 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
715 fRetVal = TRUE;
716 break;
717 case PLD_SLIC_STATE_ACTIVE:
718 j->pld_slicw.bits.c1 = 0;
719 j->pld_slicw.bits.c2 = 1;
720 j->pld_slicw.bits.c3 = 0;
721 j->pld_slicw.bits.b2en = 0;
722 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
723 fRetVal = TRUE;
724 break;
725 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
726
727 j->pld_slicw.bits.c1 = 1;
728 j->pld_slicw.bits.c2 = 1;
729 j->pld_slicw.bits.c3 = 0;
730 j->pld_slicw.bits.b2en = 0;
731 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
732 fRetVal = TRUE;
733 break;
734 case PLD_SLIC_STATE_TIPOPEN:
735 j->pld_slicw.bits.c1 = 0;
736 j->pld_slicw.bits.c2 = 0;
737 j->pld_slicw.bits.c3 = 1;
738 j->pld_slicw.bits.b2en = 0;
739 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
740 fRetVal = TRUE;
741 break;
742 case PLD_SLIC_STATE_STANDBY:
743 j->pld_slicw.bits.c1 = 1;
744 j->pld_slicw.bits.c2 = 0;
745 j->pld_slicw.bits.c3 = 1;
746 j->pld_slicw.bits.b2en = 1;
747 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
748 fRetVal = TRUE;
749 break;
750 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
751
752 j->pld_slicw.bits.c1 = 0;
753 j->pld_slicw.bits.c2 = 1;
754 j->pld_slicw.bits.c3 = 1;
755 j->pld_slicw.bits.b2en = 0;
756 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
757 fRetVal = TRUE;
758 break;
759 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
760
761 j->pld_slicw.bits.c1 = 1;
762 j->pld_slicw.bits.c2 = 1;
763 j->pld_slicw.bits.c3 = 1;
764 j->pld_slicw.bits.b2en = 0;
765 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
766 fRetVal = TRUE;
767 break;
768 default:
769 fRetVal = FALSE;
770 break;
771 }
772 }
773
774 return fRetVal;
775 }
776
ixj_wink(IXJ * j)777 static int ixj_wink(IXJ *j)
778 {
779 BYTE slicnow;
780
781 slicnow = SLIC_GetState(j);
782
783 j->pots_winkstart = jiffies;
784 SLIC_SetState(PLD_SLIC_STATE_OC, j);
785
786 while (time_before(jiffies, j->pots_winkstart + j->winktime)) {
787 set_current_state(TASK_INTERRUPTIBLE);
788 schedule_timeout(1);
789 }
790
791 SLIC_SetState(slicnow, j);
792 return 0;
793 }
794
ixj_register(int index,IXJ_REGFUNC regfunc)795 static int ixj_register(int index, IXJ_REGFUNC regfunc)
796 {
797 int cnt;
798 int retval = 0;
799 switch (index) {
800 case G729LOADER:
801 ixj_DownloadG729 = regfunc;
802 for (cnt = 0; cnt < IXJMAX; cnt++) {
803 IXJ *j = get_ixj(cnt);
804 while(test_and_set_bit(cnt, (void *)&j->busyflags) != 0) {
805 set_current_state(TASK_INTERRUPTIBLE);
806 schedule_timeout(1);
807 }
808 ixj_DownloadG729(j, 0L);
809 clear_bit(cnt, &j->busyflags);
810 }
811 break;
812 case TS85LOADER:
813 ixj_DownloadTS85 = regfunc;
814 for (cnt = 0; cnt < IXJMAX; cnt++) {
815 IXJ *j = get_ixj(cnt);
816 while(test_and_set_bit(cnt, (void *)&j->busyflags) != 0) {
817 set_current_state(TASK_INTERRUPTIBLE);
818 schedule_timeout(1);
819 }
820 ixj_DownloadTS85(j, 0L);
821 clear_bit(cnt, &j->busyflags);
822 }
823 break;
824 case PRE_READ:
825 ixj_PreRead = regfunc;
826 break;
827 case POST_READ:
828 ixj_PostRead = regfunc;
829 break;
830 case PRE_WRITE:
831 ixj_PreWrite = regfunc;
832 break;
833 case POST_WRITE:
834 ixj_PostWrite = regfunc;
835 break;
836 case PRE_IOCTL:
837 ixj_PreIoctl = regfunc;
838 break;
839 case POST_IOCTL:
840 ixj_PostIoctl = regfunc;
841 break;
842 default:
843 retval = 1;
844 }
845 return retval;
846 }
847
848 EXPORT_SYMBOL(ixj_register);
849
ixj_unregister(int index)850 static int ixj_unregister(int index)
851 {
852 int retval = 0;
853 switch (index) {
854 case G729LOADER:
855 ixj_DownloadG729 = &Stub;
856 break;
857 case TS85LOADER:
858 ixj_DownloadTS85 = &Stub;
859 break;
860 case PRE_READ:
861 ixj_PreRead = &Stub;
862 break;
863 case POST_READ:
864 ixj_PostRead = &Stub;
865 break;
866 case PRE_WRITE:
867 ixj_PreWrite = &Stub;
868 break;
869 case POST_WRITE:
870 ixj_PostWrite = &Stub;
871 break;
872 case PRE_IOCTL:
873 ixj_PreIoctl = &Stub;
874 break;
875 case POST_IOCTL:
876 ixj_PostIoctl = &Stub;
877 break;
878 default:
879 retval = 1;
880 }
881 return retval;
882 }
883
884 EXPORT_SYMBOL(ixj_unregister);
885
ixj_init_timer(IXJ * j)886 static void ixj_init_timer(IXJ *j)
887 {
888 init_timer(&j->timer);
889 j->timer.function = ixj_timeout;
890 j->timer.data = (unsigned long)j;
891 }
892
ixj_add_timer(IXJ * j)893 static void ixj_add_timer(IXJ *j)
894 {
895 j->timer.expires = jiffies + (hertz / samplerate);
896 add_timer(&j->timer);
897 }
898
ixj_tone_timeout(IXJ * j)899 static void ixj_tone_timeout(IXJ *j)
900 {
901 IXJ_TONE ti;
902
903 j->tone_state++;
904 if (j->tone_state == 3) {
905 j->tone_state = 0;
906 if (j->cadence_t) {
907 j->tone_cadence_state++;
908 if (j->tone_cadence_state >= j->cadence_t->elements_used) {
909 switch (j->cadence_t->termination) {
910 case PLAY_ONCE:
911 ixj_cpt_stop(j);
912 break;
913 case REPEAT_LAST_ELEMENT:
914 j->tone_cadence_state--;
915 ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
916 break;
917 case REPEAT_ALL:
918 j->tone_cadence_state = 0;
919 if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
920 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
921 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
922 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
923 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
924 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
925 ixj_init_tone(j, &ti);
926 }
927 ixj_set_tone_on(j->cadence_t->ce[0].tone_on_time, j);
928 ixj_set_tone_off(j->cadence_t->ce[0].tone_off_time, j);
929 ixj_play_tone(j, j->cadence_t->ce[0].index);
930 break;
931 }
932 } else {
933 if (j->cadence_t->ce[j->tone_cadence_state].gain0) {
934 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
935 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
936 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
937 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
938 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
939 ixj_init_tone(j, &ti);
940 }
941 ixj_set_tone_on(j->cadence_t->ce[j->tone_cadence_state].tone_on_time, j);
942 ixj_set_tone_off(j->cadence_t->ce[j->tone_cadence_state].tone_off_time, j);
943 ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index);
944 }
945 }
946 }
947 }
948
ixj_kill_fasync(IXJ * j,IXJ_SIGEVENT event,int dir)949 static inline void ixj_kill_fasync(IXJ *j, IXJ_SIGEVENT event, int dir)
950 {
951 if(j->ixj_signals[event]) {
952 if(ixjdebug & 0x0100)
953 printk("Sending signal for event %d\n", event);
954 /* Send apps notice of change */
955 /* see config.h for macro definition */
956 kill_fasync(&(j->async_queue), j->ixj_signals[event], dir);
957 }
958 }
959
ixj_pstn_state(IXJ * j)960 static void ixj_pstn_state(IXJ *j)
961 {
962 int var;
963 union XOPXR0 XR0, daaint;
964
965 var = 10;
966
967 XR0.reg = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg;
968 daaint.reg = 0;
969 XR0.bitreg.RMR = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
970
971 j->pld_scrr.byte = inb_p(j->XILINXbase);
972 if (j->pld_scrr.bits.daaflag) {
973 daa_int_read(j);
974 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.RING) {
975 if(time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) {
976 daaint.bitreg.RING = 1;
977 if(ixjdebug & 0x0008) {
978 printk(KERN_INFO "IXJ DAA Ring Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
979 }
980 } else {
981 daa_set_mode(j, SOP_PU_RESET);
982 }
983 }
984 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Caller_ID) {
985 daaint.bitreg.Caller_ID = 1;
986 j->pstn_cid_intr = 1;
987 j->pstn_cid_received = jiffies;
988 if(ixjdebug & 0x0008) {
989 printk(KERN_INFO "IXJ DAA Caller_ID Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
990 }
991 }
992 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Cadence) {
993 daaint.bitreg.Cadence = 1;
994 if(ixjdebug & 0x0008) {
995 printk(KERN_INFO "IXJ DAA Cadence Interrupt /dev/phone%d at %ld\n", j->board, jiffies);
996 }
997 }
998 if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK != XR0.bitreg.VDD_OK) {
999 daaint.bitreg.VDD_OK = 1;
1000 daaint.bitreg.SI_0 = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK;
1001 }
1002 }
1003 daa_CR_read(j, 1);
1004 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)) {
1005 daaint.bitreg.RMR = 1;
1006 daaint.bitreg.SI_1 = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR;
1007 if(ixjdebug & 0x0008) {
1008 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);
1009 }
1010 j->pstn_prev_rmr = j->pstn_last_rmr;
1011 j->pstn_last_rmr = jiffies;
1012 }
1013 switch(j->daa_mode) {
1014 case SOP_PU_SLEEP:
1015 if (daaint.bitreg.RING) {
1016 if (!j->flags.pstn_ringing) {
1017 if (j->daa_mode != SOP_PU_RINGING) {
1018 j->pstn_ring_int = jiffies;
1019 daa_set_mode(j, SOP_PU_RINGING);
1020 }
1021 }
1022 }
1023 break;
1024 case SOP_PU_RINGING:
1025 if (daaint.bitreg.RMR) {
1026 if (ixjdebug & 0x0008) {
1027 printk(KERN_INFO "IXJ Ring Cadence a state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
1028 }
1029 if (daaint.bitreg.SI_1) { /* Rising edge of RMR */
1030 j->flags.pstn_rmr = 1;
1031 j->pstn_ring_start = jiffies;
1032 j->pstn_ring_stop = 0;
1033 j->ex.bits.pstn_ring = 0;
1034 if (j->cadence_f[4].state == 0) {
1035 j->cadence_f[4].state = 1;
1036 j->cadence_f[4].on1min = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 - var)) / 10000);
1037 j->cadence_f[4].on1dot = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100)) / 10000);
1038 j->cadence_f[4].on1max = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 + var)) / 10000);
1039 } else if (j->cadence_f[4].state == 2) {
1040 if((time_after(jiffies, j->cadence_f[4].off1min) &&
1041 time_before(jiffies, j->cadence_f[4].off1max))) {
1042 if (j->cadence_f[4].on2) {
1043 j->cadence_f[4].state = 3;
1044 j->cadence_f[4].on2min = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 - var)) / 10000));
1045 j->cadence_f[4].on2dot = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100)) / 10000));
1046 j->cadence_f[4].on2max = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 + var)) / 10000));
1047 } else {
1048 j->cadence_f[4].state = 7;
1049 }
1050 } else {
1051 if (ixjdebug & 0x0008) {
1052 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1053 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1054 j->cadence_f[4].off1);
1055 }
1056 j->cadence_f[4].state = 0;
1057 }
1058 } else if (j->cadence_f[4].state == 4) {
1059 if((time_after(jiffies, j->cadence_f[4].off2min) &&
1060 time_before(jiffies, j->cadence_f[4].off2max))) {
1061 if (j->cadence_f[4].on3) {
1062 j->cadence_f[4].state = 5;
1063 j->cadence_f[4].on3min = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 - var)) / 10000));
1064 j->cadence_f[4].on3dot = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100)) / 10000));
1065 j->cadence_f[4].on3max = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 + var)) / 10000));
1066 } else {
1067 j->cadence_f[4].state = 7;
1068 }
1069 } else {
1070 if (ixjdebug & 0x0008) {
1071 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1072 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1073 j->cadence_f[4].off2);
1074 }
1075 j->cadence_f[4].state = 0;
1076 }
1077 } else if (j->cadence_f[4].state == 6) {
1078 if((time_after(jiffies, j->cadence_f[4].off3min) &&
1079 time_before(jiffies, j->cadence_f[4].off3max))) {
1080 j->cadence_f[4].state = 7;
1081 } else {
1082 if (ixjdebug & 0x0008) {
1083 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1084 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1085 j->cadence_f[4].off3);
1086 }
1087 j->cadence_f[4].state = 0;
1088 }
1089 } else {
1090 j->cadence_f[4].state = 0;
1091 }
1092 } else { /* Falling edge of RMR */
1093 j->pstn_ring_start = 0;
1094 j->pstn_ring_stop = jiffies;
1095 if (j->cadence_f[4].state == 1) {
1096 if(!j->cadence_f[4].on1) {
1097 j->cadence_f[4].state = 7;
1098 } else if((time_after(jiffies, j->cadence_f[4].on1min) &&
1099 time_before(jiffies, j->cadence_f[4].on1max))) {
1100 if (j->cadence_f[4].off1) {
1101 j->cadence_f[4].state = 2;
1102 j->cadence_f[4].off1min = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 - var)) / 10000));
1103 j->cadence_f[4].off1dot = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100)) / 10000));
1104 j->cadence_f[4].off1max = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 + var)) / 10000));
1105 } else {
1106 j->cadence_f[4].state = 7;
1107 }
1108 } else {
1109 if (ixjdebug & 0x0008) {
1110 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1111 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1112 j->cadence_f[4].on1);
1113 }
1114 j->cadence_f[4].state = 0;
1115 }
1116 } else if (j->cadence_f[4].state == 3) {
1117 if((time_after(jiffies, j->cadence_f[4].on2min) &&
1118 time_before(jiffies, j->cadence_f[4].on2max))) {
1119 if (j->cadence_f[4].off2) {
1120 j->cadence_f[4].state = 4;
1121 j->cadence_f[4].off2min = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 - var)) / 10000));
1122 j->cadence_f[4].off2dot = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100)) / 10000));
1123 j->cadence_f[4].off2max = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 + var)) / 10000));
1124 } else {
1125 j->cadence_f[4].state = 7;
1126 }
1127 } else {
1128 if (ixjdebug & 0x0008) {
1129 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1130 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1131 j->cadence_f[4].on2);
1132 }
1133 j->cadence_f[4].state = 0;
1134 }
1135 } else if (j->cadence_f[4].state == 5) {
1136 if((time_after(jiffies, j->cadence_f[4].on3min) &&
1137 time_before(jiffies, j->cadence_f[4].on3max))) {
1138 if (j->cadence_f[4].off3) {
1139 j->cadence_f[4].state = 6;
1140 j->cadence_f[4].off3min = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 - var)) / 10000));
1141 j->cadence_f[4].off3dot = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100)) / 10000));
1142 j->cadence_f[4].off3max = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 + var)) / 10000));
1143 } else {
1144 j->cadence_f[4].state = 7;
1145 }
1146 } else {
1147 j->cadence_f[4].state = 0;
1148 }
1149 } else {
1150 if (ixjdebug & 0x0008) {
1151 printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1152 j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr,
1153 j->cadence_f[4].on3);
1154 }
1155 j->cadence_f[4].state = 0;
1156 }
1157 }
1158 if (ixjdebug & 0x0010) {
1159 printk(KERN_INFO "IXJ Ring Cadence b state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies);
1160 }
1161 if (ixjdebug & 0x0010) {
1162 switch(j->cadence_f[4].state) {
1163 case 1:
1164 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1165 j->cadence_f[4].on1, j->cadence_f[4].on1min, j->cadence_f[4].on1dot, j->cadence_f[4].on1max);
1166 break;
1167 case 2:
1168 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1169 j->cadence_f[4].off1, j->cadence_f[4].off1min, j->cadence_f[4].off1dot, j->cadence_f[4].off1max);
1170 break;
1171 case 3:
1172 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1173 j->cadence_f[4].on2, j->cadence_f[4].on2min, j->cadence_f[4].on2dot, j->cadence_f[4].on2max);
1174 break;
1175 case 4:
1176 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1177 j->cadence_f[4].off2, j->cadence_f[4].off2min, j->cadence_f[4].off2dot, j->cadence_f[4].off2max);
1178 break;
1179 case 5:
1180 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1181 j->cadence_f[4].on3, j->cadence_f[4].on3min, j->cadence_f[4].on3dot, j->cadence_f[4].on3max);
1182 break;
1183 case 6:
1184 printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
1185 j->cadence_f[4].off3, j->cadence_f[4].off3min, j->cadence_f[4].off3dot, j->cadence_f[4].off3max);
1186 break;
1187 }
1188 }
1189 }
1190 if (j->cadence_f[4].state == 7) {
1191 j->cadence_f[4].state = 0;
1192 j->pstn_ring_stop = jiffies;
1193 j->ex.bits.pstn_ring = 1;
1194 ixj_kill_fasync(j, SIG_PSTN_RING, POLL_IN);
1195 if(ixjdebug & 0x0008) {
1196 printk(KERN_INFO "IXJ Ring int set /dev/phone%d at %ld\n", j->board, jiffies);
1197 }
1198 }
1199 if((j->pstn_ring_int != 0 && time_after(jiffies, j->pstn_ring_int + (hertz * 5)) && !j->flags.pstn_rmr) ||
1200 (j->pstn_ring_stop != 0 && time_after(jiffies, j->pstn_ring_stop + (hertz * 5)))) {
1201 if(ixjdebug & 0x0008) {
1202 printk("IXJ DAA no ring in 5 seconds /dev/phone%d at %ld\n", j->board, jiffies);
1203 printk("IXJ DAA pstn ring int /dev/phone%d at %ld\n", j->board, j->pstn_ring_int);
1204 printk("IXJ DAA pstn ring stop /dev/phone%d at %ld\n", j->board, j->pstn_ring_stop);
1205 }
1206 j->pstn_ring_stop = j->pstn_ring_int = 0;
1207 daa_set_mode(j, SOP_PU_SLEEP);
1208 }
1209 outb_p(j->pld_scrw.byte, j->XILINXbase);
1210 if (j->pstn_cid_intr && time_after(jiffies, j->pstn_cid_received + hertz)) {
1211 ixj_daa_cid_read(j);
1212 j->ex.bits.caller_id = 1;
1213 ixj_kill_fasync(j, SIG_CALLER_ID, POLL_IN);
1214 j->pstn_cid_intr = 0;
1215 }
1216 if (daaint.bitreg.Cadence) {
1217 if(ixjdebug & 0x0008) {
1218 printk("IXJ DAA Cadence interrupt going to sleep /dev/phone%d\n", j->board);
1219 }
1220 daa_set_mode(j, SOP_PU_SLEEP);
1221 j->ex.bits.pstn_ring = 0;
1222 }
1223 break;
1224 case SOP_PU_CONVERSATION:
1225 if (daaint.bitreg.VDD_OK) {
1226 if(!daaint.bitreg.SI_0) {
1227 if (!j->pstn_winkstart) {
1228 if(ixjdebug & 0x0008) {
1229 printk("IXJ DAA possible wink /dev/phone%d %ld\n", j->board, jiffies);
1230 }
1231 j->pstn_winkstart = jiffies;
1232 }
1233 } else {
1234 if (j->pstn_winkstart) {
1235 if(ixjdebug & 0x0008) {
1236 printk("IXJ DAA possible wink end /dev/phone%d %ld\n", j->board, jiffies);
1237 }
1238 j->pstn_winkstart = 0;
1239 }
1240 }
1241 }
1242 if (j->pstn_winkstart && time_after(jiffies, j->pstn_winkstart + ((hertz * j->winktime) / 1000))) {
1243 if(ixjdebug & 0x0008) {
1244 printk("IXJ DAA wink detected going to sleep /dev/phone%d %ld\n", j->board, jiffies);
1245 }
1246 daa_set_mode(j, SOP_PU_SLEEP);
1247 j->pstn_winkstart = 0;
1248 j->ex.bits.pstn_wink = 1;
1249 ixj_kill_fasync(j, SIG_PSTN_WINK, POLL_IN);
1250 }
1251 break;
1252 }
1253 }
1254
ixj_timeout(unsigned long ptr)1255 static void ixj_timeout(unsigned long ptr)
1256 {
1257 int board;
1258 unsigned long jifon;
1259 IXJ *j = (IXJ *)ptr;
1260 board = j->board;
1261
1262 if (j->DSPbase && atomic_read(&j->DSPWrite) == 0 && test_and_set_bit(board, (void *)&j->busyflags) == 0) {
1263 ixj_perfmon(j->timerchecks);
1264 j->hookstate = ixj_hookstate(j);
1265 if (j->tone_state) {
1266 if (!(j->hookstate)) {
1267 ixj_cpt_stop(j);
1268 if (j->m_hook) {
1269 j->m_hook = 0;
1270 j->ex.bits.hookstate = 1;
1271 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1272 }
1273 clear_bit(board, &j->busyflags);
1274 ixj_add_timer(j);
1275 return;
1276 }
1277 if (j->tone_state == 1)
1278 jifon = ((hertz * j->tone_on_time) * 25 / 100000);
1279 else
1280 jifon = ((hertz * j->tone_on_time) * 25 / 100000) + ((hertz * j->tone_off_time) * 25 / 100000);
1281 if (time_before(jiffies, j->tone_start_jif + jifon)) {
1282 if (j->tone_state == 1) {
1283 ixj_play_tone(j, j->tone_index);
1284 if (j->dsp.low == 0x20) {
1285 clear_bit(board, &j->busyflags);
1286 ixj_add_timer(j);
1287 return;
1288 }
1289 } else {
1290 ixj_play_tone(j, 0);
1291 if (j->dsp.low == 0x20) {
1292 clear_bit(board, &j->busyflags);
1293 ixj_add_timer(j);
1294 return;
1295 }
1296 }
1297 } else {
1298 ixj_tone_timeout(j);
1299 if (j->flags.dialtone) {
1300 ixj_dialtone(j);
1301 }
1302 if (j->flags.busytone) {
1303 ixj_busytone(j);
1304 if (j->dsp.low == 0x20) {
1305 clear_bit(board, &j->busyflags);
1306 ixj_add_timer(j);
1307 return;
1308 }
1309 }
1310 if (j->flags.ringback) {
1311 ixj_ringback(j);
1312 if (j->dsp.low == 0x20) {
1313 clear_bit(board, &j->busyflags);
1314 ixj_add_timer(j);
1315 return;
1316 }
1317 }
1318 if (!j->tone_state) {
1319 ixj_cpt_stop(j);
1320 }
1321 }
1322 }
1323 if (!(j->tone_state && j->dsp.low == 0x20)) {
1324 if (IsRxReady(j)) {
1325 ixj_read_frame(j);
1326 }
1327 if (IsTxReady(j)) {
1328 ixj_write_frame(j);
1329 }
1330 }
1331 if (j->flags.cringing) {
1332 if (j->hookstate & 1) {
1333 j->flags.cringing = 0;
1334 ixj_ring_off(j);
1335 } else if(j->cadence_f[5].enable && ((!j->cadence_f[5].en_filter) || (j->cadence_f[5].en_filter && j->flags.firstring))) {
1336 switch(j->cadence_f[5].state) {
1337 case 0:
1338 j->cadence_f[5].on1dot = jiffies + (long)((j->cadence_f[5].on1 * (hertz * 100) / 10000));
1339 if (time_before(jiffies, j->cadence_f[5].on1dot)) {
1340 if(ixjdebug & 0x0004) {
1341 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1342 }
1343 ixj_ring_on(j);
1344 }
1345 j->cadence_f[5].state = 1;
1346 break;
1347 case 1:
1348 if (time_after(jiffies, j->cadence_f[5].on1dot)) {
1349 j->cadence_f[5].off1dot = jiffies + (long)((j->cadence_f[5].off1 * (hertz * 100) / 10000));
1350 if(ixjdebug & 0x0004) {
1351 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1352 }
1353 ixj_ring_off(j);
1354 j->cadence_f[5].state = 2;
1355 }
1356 break;
1357 case 2:
1358 if (time_after(jiffies, j->cadence_f[5].off1dot)) {
1359 if(ixjdebug & 0x0004) {
1360 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1361 }
1362 ixj_ring_on(j);
1363 if (j->cadence_f[5].on2) {
1364 j->cadence_f[5].on2dot = jiffies + (long)((j->cadence_f[5].on2 * (hertz * 100) / 10000));
1365 j->cadence_f[5].state = 3;
1366 } else {
1367 j->cadence_f[5].state = 7;
1368 }
1369 }
1370 break;
1371 case 3:
1372 if (time_after(jiffies, j->cadence_f[5].on2dot)) {
1373 if(ixjdebug & 0x0004) {
1374 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1375 }
1376 ixj_ring_off(j);
1377 if (j->cadence_f[5].off2) {
1378 j->cadence_f[5].off2dot = jiffies + (long)((j->cadence_f[5].off2 * (hertz * 100) / 10000));
1379 j->cadence_f[5].state = 4;
1380 } else {
1381 j->cadence_f[5].state = 7;
1382 }
1383 }
1384 break;
1385 case 4:
1386 if (time_after(jiffies, j->cadence_f[5].off2dot)) {
1387 if(ixjdebug & 0x0004) {
1388 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1389 }
1390 ixj_ring_on(j);
1391 if (j->cadence_f[5].on3) {
1392 j->cadence_f[5].on3dot = jiffies + (long)((j->cadence_f[5].on3 * (hertz * 100) / 10000));
1393 j->cadence_f[5].state = 5;
1394 } else {
1395 j->cadence_f[5].state = 7;
1396 }
1397 }
1398 break;
1399 case 5:
1400 if (time_after(jiffies, j->cadence_f[5].on3dot)) {
1401 if(ixjdebug & 0x0004) {
1402 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1403 }
1404 ixj_ring_off(j);
1405 if (j->cadence_f[5].off3) {
1406 j->cadence_f[5].off3dot = jiffies + (long)((j->cadence_f[5].off3 * (hertz * 100) / 10000));
1407 j->cadence_f[5].state = 6;
1408 } else {
1409 j->cadence_f[5].state = 7;
1410 }
1411 }
1412 break;
1413 case 6:
1414 if (time_after(jiffies, j->cadence_f[5].off3dot)) {
1415 if(ixjdebug & 0x0004) {
1416 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1417 }
1418 j->cadence_f[5].state = 7;
1419 }
1420 break;
1421 case 7:
1422 if(ixjdebug & 0x0004) {
1423 printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies);
1424 }
1425 j->flags.cidring = 1;
1426 j->cadence_f[5].state = 0;
1427 break;
1428 }
1429 if (j->flags.cidring && !j->flags.cidsent) {
1430 j->flags.cidsent = 1;
1431 if(j->fskdcnt) {
1432 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
1433 ixj_pre_cid(j);
1434 }
1435 j->flags.cidring = 0;
1436 }
1437 clear_bit(board, &j->busyflags);
1438 ixj_add_timer(j);
1439 return;
1440 } else {
1441 if (time_after(jiffies, j->ring_cadence_jif + (hertz / 2))) {
1442 if (j->flags.cidring && !j->flags.cidsent) {
1443 j->flags.cidsent = 1;
1444 if(j->fskdcnt) {
1445 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
1446 ixj_pre_cid(j);
1447 }
1448 j->flags.cidring = 0;
1449 }
1450 j->ring_cadence_t--;
1451 if (j->ring_cadence_t == -1)
1452 j->ring_cadence_t = 15;
1453 j->ring_cadence_jif = jiffies;
1454
1455 if (j->ring_cadence & 1 << j->ring_cadence_t) {
1456 if(j->flags.cidsent && j->cadence_f[5].en_filter)
1457 j->flags.firstring = 1;
1458 else
1459 ixj_ring_on(j);
1460 } else {
1461 ixj_ring_off(j);
1462 if(!j->flags.cidsent)
1463 j->flags.cidring = 1;
1464 }
1465 }
1466 clear_bit(board, &j->busyflags);
1467 ixj_add_timer(j);
1468 return;
1469 }
1470 }
1471 if (!j->flags.ringing) {
1472 if (j->hookstate) { /* & 1) { */
1473 if (j->dsp.low != 0x20 &&
1474 SLIC_GetState(j) != PLD_SLIC_STATE_ACTIVE) {
1475 SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
1476 }
1477 LineMonitor(j);
1478 read_filters(j);
1479 ixj_WriteDSPCommand(0x511B, j);
1480 j->proc_load = j->ssr.high << 8 | j->ssr.low;
1481 if (!j->m_hook && (j->hookstate & 1)) {
1482 j->m_hook = j->ex.bits.hookstate = 1;
1483 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1484 }
1485 } else {
1486 if (j->ex.bits.dtmf_ready) {
1487 j->dtmf_wp = j->dtmf_rp = j->ex.bits.dtmf_ready = 0;
1488 }
1489 if (j->m_hook) {
1490 j->m_hook = 0;
1491 j->ex.bits.hookstate = 1;
1492 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
1493 }
1494 }
1495 }
1496 if (j->cardtype == QTI_LINEJACK && !j->flags.pstncheck && j->flags.pstn_present) {
1497 ixj_pstn_state(j);
1498 }
1499 if (j->ex.bytes) {
1500 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
1501 }
1502 clear_bit(board, &j->busyflags);
1503 }
1504 ixj_add_timer(j);
1505 }
1506
ixj_status_wait(IXJ * j)1507 static int ixj_status_wait(IXJ *j)
1508 {
1509 unsigned long jif;
1510
1511 jif = jiffies + ((60 * hertz) / 100);
1512 while (!IsStatusReady(j)) {
1513 ixj_perfmon(j->statuswait);
1514 if (time_after(jiffies, jif)) {
1515 ixj_perfmon(j->statuswaitfail);
1516 return -1;
1517 }
1518 }
1519 return 0;
1520 }
1521
ixj_PCcontrol_wait(IXJ * j)1522 static int ixj_PCcontrol_wait(IXJ *j)
1523 {
1524 unsigned long jif;
1525
1526 jif = jiffies + ((60 * hertz) / 100);
1527 while (!IsPCControlReady(j)) {
1528 ixj_perfmon(j->pcontrolwait);
1529 if (time_after(jiffies, jif)) {
1530 ixj_perfmon(j->pcontrolwaitfail);
1531 return -1;
1532 }
1533 }
1534 return 0;
1535 }
1536
ixj_WriteDSPCommand(unsigned short cmd,IXJ * j)1537 static int ixj_WriteDSPCommand(unsigned short cmd, IXJ *j)
1538 {
1539 BYTES bytes;
1540 unsigned long jif;
1541
1542 atomic_inc(&j->DSPWrite);
1543 if(atomic_read(&j->DSPWrite) > 1) {
1544 printk("IXJ %d DSP write overlap attempting command 0x%4.4x\n", j->board, cmd);
1545 return -1;
1546 }
1547 bytes.high = (cmd & 0xFF00) >> 8;
1548 bytes.low = cmd & 0x00FF;
1549 jif = jiffies + ((60 * hertz) / 100);
1550 while (!IsControlReady(j)) {
1551 ixj_perfmon(j->iscontrolready);
1552 if (time_after(jiffies, jif)) {
1553 ixj_perfmon(j->iscontrolreadyfail);
1554 atomic_dec(&j->DSPWrite);
1555 if(atomic_read(&j->DSPWrite) > 0) {
1556 printk("IXJ %d DSP overlaped command 0x%4.4x during control ready failure.\n", j->board, cmd);
1557 while(atomic_read(&j->DSPWrite) > 0) {
1558 atomic_dec(&j->DSPWrite);
1559 }
1560 }
1561 return -1;
1562 }
1563 }
1564 outb(bytes.low, j->DSPbase + 6);
1565 outb(bytes.high, j->DSPbase + 7);
1566
1567 if (ixj_status_wait(j)) {
1568 j->ssr.low = 0xFF;
1569 j->ssr.high = 0xFF;
1570 atomic_dec(&j->DSPWrite);
1571 if(atomic_read(&j->DSPWrite) > 0) {
1572 printk("IXJ %d DSP overlaped command 0x%4.4x during status wait failure.\n", j->board, cmd);
1573 while(atomic_read(&j->DSPWrite) > 0) {
1574 atomic_dec(&j->DSPWrite);
1575 }
1576 }
1577 return -1;
1578 }
1579 /* Read Software Status Register */
1580 j->ssr.low = inb_p(j->DSPbase + 2);
1581 j->ssr.high = inb_p(j->DSPbase + 3);
1582 atomic_dec(&j->DSPWrite);
1583 if(atomic_read(&j->DSPWrite) > 0) {
1584 printk("IXJ %d DSP overlaped command 0x%4.4x\n", j->board, cmd);
1585 while(atomic_read(&j->DSPWrite) > 0) {
1586 atomic_dec(&j->DSPWrite);
1587 }
1588 }
1589 return 0;
1590 }
1591
1592 /***************************************************************************
1593 *
1594 * General Purpose IO Register read routine
1595 *
1596 ***************************************************************************/
ixj_gpio_read(IXJ * j)1597 static inline int ixj_gpio_read(IXJ *j)
1598 {
1599 if (ixj_WriteDSPCommand(0x5143, j))
1600 return -1;
1601
1602 j->gpio.bytes.low = j->ssr.low;
1603 j->gpio.bytes.high = j->ssr.high;
1604
1605 return 0;
1606 }
1607
LED_SetState(int state,IXJ * j)1608 static inline void LED_SetState(int state, IXJ *j)
1609 {
1610 if (j->cardtype == QTI_LINEJACK) {
1611 j->pld_scrw.bits.led1 = state & 0x1 ? 1 : 0;
1612 j->pld_scrw.bits.led2 = state & 0x2 ? 1 : 0;
1613 j->pld_scrw.bits.led3 = state & 0x4 ? 1 : 0;
1614 j->pld_scrw.bits.led4 = state & 0x8 ? 1 : 0;
1615
1616 outb(j->pld_scrw.byte, j->XILINXbase);
1617 }
1618 }
1619
1620 /*********************************************************************
1621 * GPIO Pins are configured as follows on the Quicknet Internet
1622 * PhoneJACK Telephony Cards
1623 *
1624 * POTS Select GPIO_6=0 GPIO_7=0
1625 * Mic/Speaker Select GPIO_6=0 GPIO_7=1
1626 * Handset Select GPIO_6=1 GPIO_7=0
1627 *
1628 * SLIC Active GPIO_1=0 GPIO_2=1 GPIO_5=0
1629 * SLIC Ringing GPIO_1=1 GPIO_2=1 GPIO_5=0
1630 * SLIC Open Circuit GPIO_1=0 GPIO_2=0 GPIO_5=0
1631 *
1632 * Hook Switch changes reported on GPIO_3
1633 *********************************************************************/
ixj_set_port(IXJ * j,int arg)1634 static int ixj_set_port(IXJ *j, int arg)
1635 {
1636 if (j->cardtype == QTI_PHONEJACK_LITE) {
1637 if (arg != PORT_POTS)
1638 return 10;
1639 else
1640 return 0;
1641 }
1642 switch (arg) {
1643 case PORT_POTS:
1644 j->port = PORT_POTS;
1645 switch (j->cardtype) {
1646 case QTI_PHONECARD:
1647 if (j->flags.pcmciasct == 1)
1648 SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j);
1649 else
1650 return 11;
1651 break;
1652 case QTI_PHONEJACK_PCI:
1653 j->pld_slicw.pcib.mic = 0;
1654 j->pld_slicw.pcib.spk = 0;
1655 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1656 break;
1657 case QTI_LINEJACK:
1658 ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
1659 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
1660 Software Control Register */
1661 return 2;
1662 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
1663
1664 outb(j->pld_scrw.byte, j->XILINXbase);
1665 j->pld_clock.byte = 0;
1666 outb(j->pld_clock.byte, j->XILINXbase + 0x04);
1667 j->pld_slicw.bits.rly1 = 1;
1668 j->pld_slicw.bits.spken = 0;
1669 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1670 ixj_mixer(0x1200, j); /* Turn Off MIC switch on mixer left */
1671 ixj_mixer(0x1401, j); /* Turn On Mono1 switch on mixer left */
1672 ixj_mixer(0x1300, j); /* Turn Off MIC switch on mixer right */
1673 ixj_mixer(0x1501, j); /* Turn On Mono1 switch on mixer right */
1674 ixj_mixer(0x0E80, j); /*Mic mute */
1675 ixj_mixer(0x0F00, j); /* Set mono out (SLIC) to 0dB */
1676 ixj_mixer(0x0080, j); /* Mute Master Left volume */
1677 ixj_mixer(0x0180, j); /* Mute Master Right volume */
1678 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
1679 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
1680 break;
1681 case QTI_PHONEJACK:
1682 j->gpio.bytes.high = 0x0B;
1683 j->gpio.bits.gpio6 = 0;
1684 j->gpio.bits.gpio7 = 0;
1685 ixj_WriteDSPCommand(j->gpio.word, j);
1686 break;
1687 }
1688 break;
1689 case PORT_PSTN:
1690 if (j->cardtype == QTI_LINEJACK) {
1691 ixj_WriteDSPCommand(0xC534, j); /* Write CODEC config to Software Control Register */
1692
1693 j->pld_slicw.bits.rly3 = 0;
1694 j->pld_slicw.bits.rly1 = 1;
1695 j->pld_slicw.bits.spken = 0;
1696 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1697 j->port = PORT_PSTN;
1698 } else {
1699 return 4;
1700 }
1701 break;
1702 case PORT_SPEAKER:
1703 j->port = PORT_SPEAKER;
1704 switch (j->cardtype) {
1705 case QTI_PHONECARD:
1706 if (j->flags.pcmciasct) {
1707 SLIC_SetState(PLD_SLIC_STATE_OC, j);
1708 }
1709 break;
1710 case QTI_PHONEJACK_PCI:
1711 j->pld_slicw.pcib.mic = 1;
1712 j->pld_slicw.pcib.spk = 1;
1713 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1714 break;
1715 case QTI_LINEJACK:
1716 ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */
1717 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to
1718 Software Control Register */
1719 return 2;
1720 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
1721
1722 outb(j->pld_scrw.byte, j->XILINXbase);
1723 j->pld_clock.byte = 0;
1724 outb(j->pld_clock.byte, j->XILINXbase + 0x04);
1725 j->pld_slicw.bits.rly1 = 1;
1726 j->pld_slicw.bits.spken = 1;
1727 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1728 ixj_mixer(0x1201, j); /* Turn On MIC switch on mixer left */
1729 ixj_mixer(0x1400, j); /* Turn Off Mono1 switch on mixer left */
1730 ixj_mixer(0x1301, j); /* Turn On MIC switch on mixer right */
1731 ixj_mixer(0x1500, j); /* Turn Off Mono1 switch on mixer right */
1732 ixj_mixer(0x0E06, j); /*Mic un-mute 0dB */
1733 ixj_mixer(0x0F80, j); /* Mute mono out (SLIC) */
1734 ixj_mixer(0x0000, j); /* Set Master Left volume to 0dB */
1735 ixj_mixer(0x0100, j); /* Set Master Right volume to 0dB */
1736 break;
1737 case QTI_PHONEJACK:
1738 j->gpio.bytes.high = 0x0B;
1739 j->gpio.bits.gpio6 = 0;
1740 j->gpio.bits.gpio7 = 1;
1741 ixj_WriteDSPCommand(j->gpio.word, j);
1742 break;
1743 }
1744 break;
1745 case PORT_HANDSET:
1746 if (j->cardtype != QTI_PHONEJACK) {
1747 return 5;
1748 } else {
1749 j->gpio.bytes.high = 0x0B;
1750 j->gpio.bits.gpio6 = 1;
1751 j->gpio.bits.gpio7 = 0;
1752 ixj_WriteDSPCommand(j->gpio.word, j);
1753 j->port = PORT_HANDSET;
1754 }
1755 break;
1756 default:
1757 return 6;
1758 break;
1759 }
1760 return 0;
1761 }
1762
ixj_set_pots(IXJ * j,int arg)1763 static int ixj_set_pots(IXJ *j, int arg)
1764 {
1765 if (j->cardtype == QTI_LINEJACK) {
1766 if (arg) {
1767 if (j->port == PORT_PSTN) {
1768 j->pld_slicw.bits.rly1 = 0;
1769 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1770 j->flags.pots_pstn = 1;
1771 return 1;
1772 } else {
1773 j->flags.pots_pstn = 0;
1774 return 0;
1775 }
1776 } else {
1777 j->pld_slicw.bits.rly1 = 1;
1778 outb(j->pld_slicw.byte, j->XILINXbase + 0x01);
1779 j->flags.pots_pstn = 0;
1780 return 1;
1781 }
1782 } else {
1783 return 0;
1784 }
1785 }
1786
ixj_ring_on(IXJ * j)1787 static void ixj_ring_on(IXJ *j)
1788 {
1789 if (j->dsp.low == 0x20) /* Internet PhoneJACK */
1790 {
1791 if (ixjdebug & 0x0004)
1792 printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
1793
1794 j->gpio.bytes.high = 0x0B;
1795 j->gpio.bytes.low = 0x00;
1796 j->gpio.bits.gpio1 = 1;
1797 j->gpio.bits.gpio2 = 1;
1798 j->gpio.bits.gpio5 = 0;
1799 ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring signal */
1800 } else /* Internet LineJACK, Internet PhoneJACK Lite or Internet PhoneJACK PCI */
1801 {
1802 if (ixjdebug & 0x0004)
1803 printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board);
1804
1805 SLIC_SetState(PLD_SLIC_STATE_RINGING, j);
1806 }
1807 }
1808
ixj_siadc(IXJ * j,int val)1809 static int ixj_siadc(IXJ *j, int val)
1810 {
1811 if(j->cardtype == QTI_PHONECARD){
1812 if(j->flags.pcmciascp){
1813 if(val == -1)
1814 return j->siadc.bits.rxg;
1815
1816 if(val < 0 || val > 0x1F)
1817 return -1;
1818
1819 j->siadc.bits.hom = 0; /* Handset Out Mute */
1820 j->siadc.bits.lom = 0; /* Line Out Mute */
1821 j->siadc.bits.rxg = val; /*(0xC000 - 0x41C8) / 0x4EF; RX PGA Gain */
1822 j->psccr.bits.addr = 6; /* R/W Smart Cable Register Address */
1823 j->psccr.bits.rw = 0; /* Read / Write flag */
1824 j->psccr.bits.dev = 0;
1825 outb(j->siadc.byte, j->XILINXbase + 0x00);
1826 outb(j->psccr.byte, j->XILINXbase + 0x01);
1827 ixj_PCcontrol_wait(j);
1828 return j->siadc.bits.rxg;
1829 }
1830 }
1831 return -1;
1832 }
1833
ixj_sidac(IXJ * j,int val)1834 static int ixj_sidac(IXJ *j, int val)
1835 {
1836 if(j->cardtype == QTI_PHONECARD){
1837 if(j->flags.pcmciascp){
1838 if(val == -1)
1839 return j->sidac.bits.txg;
1840
1841 if(val < 0 || val > 0x1F)
1842 return -1;
1843
1844 j->sidac.bits.srm = 1; /* Speaker Right Mute */
1845 j->sidac.bits.slm = 1; /* Speaker Left Mute */
1846 j->sidac.bits.txg = val; /* (0xC000 - 0x45E4) / 0x5D3; TX PGA Gain */
1847 j->psccr.bits.addr = 7; /* R/W Smart Cable Register Address */
1848 j->psccr.bits.rw = 0; /* Read / Write flag */
1849 j->psccr.bits.dev = 0;
1850 outb(j->sidac.byte, j->XILINXbase + 0x00);
1851 outb(j->psccr.byte, j->XILINXbase + 0x01);
1852 ixj_PCcontrol_wait(j);
1853 return j->sidac.bits.txg;
1854 }
1855 }
1856 return -1;
1857 }
1858
ixj_pcmcia_cable_check(IXJ * j)1859 static int ixj_pcmcia_cable_check(IXJ *j)
1860 {
1861 j->pccr1.byte = inb_p(j->XILINXbase + 0x03);
1862 if (!j->flags.pcmciastate) {
1863 j->pccr2.byte = inb_p(j->XILINXbase + 0x02);
1864 if (j->pccr1.bits.drf || j->pccr2.bits.rstc) {
1865 j->flags.pcmciastate = 4;
1866 return 0;
1867 }
1868 if (j->pccr1.bits.ed) {
1869 j->pccr1.bits.ed = 0;
1870 j->psccr.bits.dev = 3;
1871 j->psccr.bits.rw = 1;
1872 outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00);
1873 ixj_PCcontrol_wait(j);
1874 j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF;
1875 j->pslic.bits.led2 = j->pslic.bits.det ? 1 : 0;
1876 j->psccr.bits.dev = 3;
1877 j->psccr.bits.rw = 0;
1878 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
1879 ixj_PCcontrol_wait(j);
1880 return j->pslic.bits.led2 ? 1 : 0;
1881 } else if (j->flags.pcmciasct) {
1882 return j->r_hook;
1883 } else {
1884 return 1;
1885 }
1886 } else if (j->flags.pcmciastate == 4) {
1887 if (!j->pccr1.bits.drf) {
1888 j->flags.pcmciastate = 3;
1889 }
1890 return 0;
1891 } else if (j->flags.pcmciastate == 3) {
1892 j->pccr2.bits.pwr = 0;
1893 j->pccr2.bits.rstc = 1;
1894 outb(j->pccr2.byte, j->XILINXbase + 0x02);
1895 j->checkwait = jiffies + (hertz * 2);
1896 j->flags.incheck = 1;
1897 j->flags.pcmciastate = 2;
1898 return 0;
1899 } else if (j->flags.pcmciastate == 2) {
1900 if (j->flags.incheck) {
1901 if (time_before(jiffies, j->checkwait)) {
1902 return 0;
1903 } else {
1904 j->flags.incheck = 0;
1905 }
1906 }
1907 j->pccr2.bits.pwr = 0;
1908 j->pccr2.bits.rstc = 0;
1909 outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
1910 j->flags.pcmciastate = 1;
1911 return 0;
1912 } else if (j->flags.pcmciastate == 1) {
1913 j->flags.pcmciastate = 0;
1914 if (!j->pccr1.bits.drf) {
1915 j->psccr.bits.dev = 3;
1916 j->psccr.bits.rw = 1;
1917 outb_p(j->psccr.byte, j->XILINXbase + 0x01);
1918 ixj_PCcontrol_wait(j);
1919 j->flags.pcmciascp = 1; /* Set Cable Present Flag */
1920
1921 j->flags.pcmciasct = (inw_p(j->XILINXbase + 0x00) >> 8) & 0x03; /* Get Cable Type */
1922
1923 if (j->flags.pcmciasct == 3) {
1924 j->flags.pcmciastate = 4;
1925 return 0;
1926 } else if (j->flags.pcmciasct == 0) {
1927 j->pccr2.bits.pwr = 1;
1928 j->pccr2.bits.rstc = 0;
1929 outb_p(j->pccr2.byte, j->XILINXbase + 0x02);
1930 j->port = PORT_SPEAKER;
1931 } else {
1932 j->port = PORT_POTS;
1933 }
1934 j->sic1.bits.cpd = 0; /* Chip Power Down */
1935 j->sic1.bits.mpd = 0; /* MIC Bias Power Down */
1936 j->sic1.bits.hpd = 0; /* Handset Bias Power Down */
1937 j->sic1.bits.lpd = 0; /* Line Bias Power Down */
1938 j->sic1.bits.spd = 1; /* Speaker Drive Power Down */
1939 j->psccr.bits.addr = 1; /* R/W Smart Cable Register Address */
1940 j->psccr.bits.rw = 0; /* Read / Write flag */
1941 j->psccr.bits.dev = 0;
1942 outb(j->sic1.byte, j->XILINXbase + 0x00);
1943 outb(j->psccr.byte, j->XILINXbase + 0x01);
1944 ixj_PCcontrol_wait(j);
1945
1946 j->sic2.bits.al = 0; /* Analog Loopback DAC analog -> ADC analog */
1947 j->sic2.bits.dl2 = 0; /* Digital Loopback DAC -> ADC one bit */
1948 j->sic2.bits.dl1 = 0; /* Digital Loopback ADC -> DAC one bit */
1949 j->sic2.bits.pll = 0; /* 1 = div 10, 0 = div 5 */
1950 j->sic2.bits.hpd = 0; /* HPF disable */
1951 j->psccr.bits.addr = 2; /* R/W Smart Cable Register Address */
1952 j->psccr.bits.rw = 0; /* Read / Write flag */
1953 j->psccr.bits.dev = 0;
1954 outb(j->sic2.byte, j->XILINXbase + 0x00);
1955 outb(j->psccr.byte, j->XILINXbase + 0x01);
1956 ixj_PCcontrol_wait(j);
1957
1958 j->psccr.bits.addr = 3; /* R/W Smart Cable Register Address */
1959 j->psccr.bits.rw = 0; /* Read / Write flag */
1960 j->psccr.bits.dev = 0;
1961 outb(0x00, j->XILINXbase + 0x00); /* PLL Divide N1 */
1962 outb(j->psccr.byte, j->XILINXbase + 0x01);
1963 ixj_PCcontrol_wait(j);
1964
1965 j->psccr.bits.addr = 4; /* R/W Smart Cable Register Address */
1966 j->psccr.bits.rw = 0; /* Read / Write flag */
1967 j->psccr.bits.dev = 0;
1968 outb(0x09, j->XILINXbase + 0x00); /* PLL Multiply M1 */
1969 outb(j->psccr.byte, j->XILINXbase + 0x01);
1970 ixj_PCcontrol_wait(j);
1971
1972 j->sirxg.bits.lig = 1; /* Line In Gain */
1973 j->sirxg.bits.lim = 1; /* Line In Mute */
1974 j->sirxg.bits.mcg = 0; /* MIC In Gain was 3 */
1975 j->sirxg.bits.mcm = 0; /* MIC In Mute */
1976 j->sirxg.bits.him = 0; /* Handset In Mute */
1977 j->sirxg.bits.iir = 1; /* IIR */
1978 j->psccr.bits.addr = 5; /* R/W Smart Cable Register Address */
1979 j->psccr.bits.rw = 0; /* Read / Write flag */
1980 j->psccr.bits.dev = 0;
1981 outb(j->sirxg.byte, j->XILINXbase + 0x00);
1982 outb(j->psccr.byte, j->XILINXbase + 0x01);
1983 ixj_PCcontrol_wait(j);
1984
1985 ixj_siadc(j, 0x17);
1986 ixj_sidac(j, 0x1D);
1987
1988 j->siaatt.bits.sot = 0;
1989 j->psccr.bits.addr = 9; /* R/W Smart Cable Register Address */
1990 j->psccr.bits.rw = 0; /* Read / Write flag */
1991 j->psccr.bits.dev = 0;
1992 outb(j->siaatt.byte, j->XILINXbase + 0x00);
1993 outb(j->psccr.byte, j->XILINXbase + 0x01);
1994 ixj_PCcontrol_wait(j);
1995
1996 if (j->flags.pcmciasct == 1 && !j->readers && !j->writers) {
1997 j->psccr.byte = j->pslic.byte = 0;
1998 j->pslic.bits.powerdown = 1;
1999 j->psccr.bits.dev = 3;
2000 j->psccr.bits.rw = 0;
2001 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
2002 ixj_PCcontrol_wait(j);
2003 }
2004 }
2005 return 0;
2006 } else {
2007 j->flags.pcmciascp = 0;
2008 return 0;
2009 }
2010 return 0;
2011 }
2012
ixj_hookstate(IXJ * j)2013 static int ixj_hookstate(IXJ *j)
2014 {
2015 unsigned long det;
2016 int fOffHook = 0;
2017
2018 switch (j->cardtype) {
2019 case QTI_PHONEJACK:
2020 ixj_gpio_read(j);
2021 fOffHook = j->gpio.bits.gpio3read ? 1 : 0;
2022 break;
2023 case QTI_LINEJACK:
2024 case QTI_PHONEJACK_LITE:
2025 case QTI_PHONEJACK_PCI:
2026 SLIC_GetState(j);
2027 if(j->cardtype == QTI_LINEJACK && j->flags.pots_pstn == 1 && (j->readers || j->writers)) {
2028 fOffHook = j->pld_slicr.bits.potspstn ? 1 : 0;
2029 if(fOffHook != j->p_hook) {
2030 if(!j->checkwait) {
2031 j->checkwait = jiffies;
2032 }
2033 if(time_before(jiffies, j->checkwait + 2)) {
2034 fOffHook ^= 1;
2035 } else {
2036 j->checkwait = 0;
2037 }
2038 j->p_hook = fOffHook;
2039 printk("IXJ : /dev/phone%d pots-pstn hookstate check %d at %ld\n", j->board, fOffHook, jiffies);
2040 }
2041 } else {
2042 if (j->pld_slicr.bits.state == PLD_SLIC_STATE_ACTIVE ||
2043 j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) {
2044 if (j->flags.ringing || j->flags.cringing) {
2045 if (!in_interrupt()) {
2046 det = jiffies + (hertz / 50);
2047 while (time_before(jiffies, det)) {
2048 set_current_state(TASK_INTERRUPTIBLE);
2049 schedule_timeout(1);
2050 }
2051 }
2052 SLIC_GetState(j);
2053 if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) {
2054 ixj_ring_on(j);
2055 }
2056 }
2057 if (j->cardtype == QTI_PHONEJACK_PCI) {
2058 j->pld_scrr.byte = inb_p(j->XILINXbase);
2059 fOffHook = j->pld_scrr.pcib.det ? 1 : 0;
2060 } else
2061 fOffHook = j->pld_slicr.bits.det ? 1 : 0;
2062 }
2063 }
2064 break;
2065 case QTI_PHONECARD:
2066 fOffHook = ixj_pcmcia_cable_check(j);
2067 break;
2068 }
2069 if (j->r_hook != fOffHook) {
2070 j->r_hook = fOffHook;
2071 if (j->port == PORT_SPEAKER || j->port == PORT_HANDSET) { // || (j->port == PORT_PSTN && j->flags.pots_pstn == 0)) {
2072 j->ex.bits.hookstate = 1;
2073 ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN);
2074 } else if (!fOffHook) {
2075 j->flash_end = jiffies + ((60 * hertz) / 100);
2076 }
2077 }
2078 if (fOffHook) {
2079 if(time_before(jiffies, j->flash_end)) {
2080 j->ex.bits.flash = 1;
2081 j->flash_end = 0;
2082 ixj_kill_fasync(j, SIG_FLASH, POLL_IN);
2083 }
2084 } else {
2085 if(time_before(jiffies, j->flash_end)) {
2086 fOffHook = 1;
2087 }
2088 }
2089
2090 if (j->port == PORT_PSTN && j->daa_mode == SOP_PU_CONVERSATION)
2091 fOffHook |= 2;
2092
2093 if (j->port == PORT_SPEAKER) {
2094 if(j->cardtype == QTI_PHONECARD) {
2095 if(j->flags.pcmciascp && j->flags.pcmciasct) {
2096 fOffHook |= 2;
2097 }
2098 } else {
2099 fOffHook |= 2;
2100 }
2101 }
2102
2103 if (j->port == PORT_HANDSET)
2104 fOffHook |= 2;
2105
2106 return fOffHook;
2107 }
2108
ixj_ring_off(IXJ * j)2109 static void ixj_ring_off(IXJ *j)
2110 {
2111 if (j->dsp.low == 0x20) /* Internet PhoneJACK */
2112 {
2113 if (ixjdebug & 0x0004)
2114 printk(KERN_INFO "IXJ Ring Off\n");
2115 j->gpio.bytes.high = 0x0B;
2116 j->gpio.bytes.low = 0x00;
2117 j->gpio.bits.gpio1 = 0;
2118 j->gpio.bits.gpio2 = 1;
2119 j->gpio.bits.gpio5 = 0;
2120 ixj_WriteDSPCommand(j->gpio.word, j);
2121 } else /* Internet LineJACK */
2122 {
2123 if (ixjdebug & 0x0004)
2124 printk(KERN_INFO "IXJ Ring Off\n");
2125
2126 if(!j->flags.cidplay)
2127 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
2128
2129 SLIC_GetState(j);
2130 }
2131 }
2132
ixj_ring_start(IXJ * j)2133 static void ixj_ring_start(IXJ *j)
2134 {
2135 j->flags.cringing = 1;
2136 if (ixjdebug & 0x0004)
2137 printk(KERN_INFO "IXJ Cadence Ringing Start /dev/phone%d\n", j->board);
2138 if (ixj_hookstate(j) & 1) {
2139 if (j->port == PORT_POTS)
2140 ixj_ring_off(j);
2141 j->flags.cringing = 0;
2142 if (ixjdebug & 0x0004)
2143 printk(KERN_INFO "IXJ Cadence Ringing Stopped /dev/phone%d off hook\n", j->board);
2144 } else if(j->cadence_f[5].enable && (!j->cadence_f[5].en_filter)) {
2145 j->ring_cadence_jif = jiffies;
2146 j->flags.cidsent = j->flags.cidring = 0;
2147 j->cadence_f[5].state = 0;
2148 if(j->cadence_f[5].on1)
2149 ixj_ring_on(j);
2150 } else {
2151 j->ring_cadence_jif = jiffies;
2152 j->ring_cadence_t = 15;
2153 if (j->ring_cadence & 1 << j->ring_cadence_t) {
2154 ixj_ring_on(j);
2155 } else {
2156 ixj_ring_off(j);
2157 }
2158 j->flags.cidsent = j->flags.cidring = j->flags.firstring = 0;
2159 }
2160 }
2161
ixj_ring(IXJ * j)2162 static int ixj_ring(IXJ *j)
2163 {
2164 char cntr;
2165 unsigned long jif, det;
2166
2167 j->flags.ringing = 1;
2168 if (ixj_hookstate(j) & 1) {
2169 ixj_ring_off(j);
2170 j->flags.ringing = 0;
2171 return 1;
2172 }
2173 det = 0;
2174 for (cntr = 0; cntr < j->maxrings; cntr++) {
2175 jif = jiffies + (1 * hertz);
2176 ixj_ring_on(j);
2177 while (time_before(jiffies, jif)) {
2178 if (ixj_hookstate(j) & 1) {
2179 ixj_ring_off(j);
2180 j->flags.ringing = 0;
2181 return 1;
2182 }
2183 set_current_state(TASK_INTERRUPTIBLE);
2184 schedule_timeout(1);
2185 if (signal_pending(current))
2186 break;
2187 }
2188 jif = jiffies + (3 * hertz);
2189 ixj_ring_off(j);
2190 while (time_before(jiffies, jif)) {
2191 if (ixj_hookstate(j) & 1) {
2192 det = jiffies + (hertz / 100);
2193 while (time_before(jiffies, det)) {
2194 set_current_state(TASK_INTERRUPTIBLE);
2195 schedule_timeout(1);
2196 if (signal_pending(current))
2197 break;
2198 }
2199 if (ixj_hookstate(j) & 1) {
2200 j->flags.ringing = 0;
2201 return 1;
2202 }
2203 }
2204 set_current_state(TASK_INTERRUPTIBLE);
2205 schedule_timeout(1);
2206 if (signal_pending(current))
2207 break;
2208 }
2209 }
2210 ixj_ring_off(j);
2211 j->flags.ringing = 0;
2212 return 0;
2213 }
2214
ixj_open(struct phone_device * p,struct file * file_p)2215 static int ixj_open(struct phone_device *p, struct file *file_p)
2216 {
2217 IXJ *j = get_ixj(p->board);
2218 file_p->private_data = j;
2219
2220 if (!j->DSPbase)
2221 return -ENODEV;
2222
2223 if (file_p->f_mode & FMODE_READ) {
2224 if(!j->readers) {
2225 j->readers++;
2226 } else {
2227 return -EBUSY;
2228 }
2229 }
2230
2231 if (file_p->f_mode & FMODE_WRITE) {
2232 if(!j->writers) {
2233 j->writers++;
2234 } else {
2235 if (file_p->f_mode & FMODE_READ){
2236 j->readers--;
2237 }
2238 return -EBUSY;
2239 }
2240 }
2241
2242 if (j->cardtype == QTI_PHONECARD) {
2243 j->pslic.bits.powerdown = 0;
2244 j->psccr.bits.dev = 3;
2245 j->psccr.bits.rw = 0;
2246 outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00);
2247 ixj_PCcontrol_wait(j);
2248 }
2249
2250 j->flags.cidplay = 0;
2251 j->flags.cidcw_ack = 0;
2252
2253 MOD_INC_USE_COUNT;
2254
2255 if (ixjdebug & 0x0002)
2256 printk(KERN_INFO "Opening board %d\n", p->board);
2257
2258 j->framesread = j->frameswritten = 0;
2259 return 0;
2260 }
2261
ixj_release(struct inode * inode,struct file * file_p)2262 int ixj_release(struct inode *inode, struct file *file_p)
2263 {
2264 IXJ_TONE ti;
2265 int cnt;
2266 IXJ *j = file_p->private_data;
2267 int board = j->p.board;
2268
2269 /*
2270 * Set up locks to ensure that only one process is talking to the DSP at a time.
2271 * This is necessary to keep the DSP from locking up.
2272 */
2273 while(test_and_set_bit(board, (void *)&j->busyflags) != 0) {
2274 set_current_state(TASK_INTERRUPTIBLE);
2275 schedule_timeout(1);
2276 }
2277 if (ixjdebug & 0x0002)
2278 printk(KERN_INFO "Closing board %d\n", NUM(inode->i_rdev));
2279
2280 if (j->cardtype == QTI_PHONECARD)
2281 ixj_set_port(j, PORT_SPEAKER);
2282 else
2283 ixj_set_port(j, PORT_POTS);
2284
2285 aec_stop(j);
2286 ixj_play_stop(j);
2287 ixj_record_stop(j);
2288 set_play_volume(j, 0x100);
2289 set_rec_volume(j, 0x100);
2290 ixj_ring_off(j);
2291
2292 /* Restore the tone table to default settings. */
2293 ti.tone_index = 10;
2294 ti.gain0 = 1;
2295 ti.freq0 = hz941;
2296 ti.gain1 = 0;
2297 ti.freq1 = hz1209;
2298 ixj_init_tone(j, &ti);
2299 ti.tone_index = 11;
2300 ti.gain0 = 1;
2301 ti.freq0 = hz941;
2302 ti.gain1 = 0;
2303 ti.freq1 = hz1336;
2304 ixj_init_tone(j, &ti);
2305 ti.tone_index = 12;
2306 ti.gain0 = 1;
2307 ti.freq0 = hz941;
2308 ti.gain1 = 0;
2309 ti.freq1 = hz1477;
2310 ixj_init_tone(j, &ti);
2311 ti.tone_index = 13;
2312 ti.gain0 = 1;
2313 ti.freq0 = hz800;
2314 ti.gain1 = 0;
2315 ti.freq1 = 0;
2316 ixj_init_tone(j, &ti);
2317 ti.tone_index = 14;
2318 ti.gain0 = 1;
2319 ti.freq0 = hz1000;
2320 ti.gain1 = 0;
2321 ti.freq1 = 0;
2322 ixj_init_tone(j, &ti);
2323 ti.tone_index = 15;
2324 ti.gain0 = 1;
2325 ti.freq0 = hz1250;
2326 ti.gain1 = 0;
2327 ti.freq1 = 0;
2328 ixj_init_tone(j, &ti);
2329 ti.tone_index = 16;
2330 ti.gain0 = 1;
2331 ti.freq0 = hz950;
2332 ti.gain1 = 0;
2333 ti.freq1 = 0;
2334 ixj_init_tone(j, &ti);
2335 ti.tone_index = 17;
2336 ti.gain0 = 1;
2337 ti.freq0 = hz1100;
2338 ti.gain1 = 0;
2339 ti.freq1 = 0;
2340 ixj_init_tone(j, &ti);
2341 ti.tone_index = 18;
2342 ti.gain0 = 1;
2343 ti.freq0 = hz1400;
2344 ti.gain1 = 0;
2345 ti.freq1 = 0;
2346 ixj_init_tone(j, &ti);
2347 ti.tone_index = 19;
2348 ti.gain0 = 1;
2349 ti.freq0 = hz1500;
2350 ti.gain1 = 0;
2351 ti.freq1 = 0;
2352 ixj_init_tone(j, &ti);
2353 ti.tone_index = 20;
2354 ti.gain0 = 1;
2355 ti.freq0 = hz1600;
2356 ti.gain1 = 0;
2357 ti.freq1 = 0;
2358 ixj_init_tone(j, &ti);
2359 ti.tone_index = 21;
2360 ti.gain0 = 1;
2361 ti.freq0 = hz1800;
2362 ti.gain1 = 0;
2363 ti.freq1 = 0;
2364 ixj_init_tone(j, &ti);
2365 ti.tone_index = 22;
2366 ti.gain0 = 1;
2367 ti.freq0 = hz2100;
2368 ti.gain1 = 0;
2369 ti.freq1 = 0;
2370 ixj_init_tone(j, &ti);
2371 ti.tone_index = 23;
2372 ti.gain0 = 1;
2373 ti.freq0 = hz1300;
2374 ti.gain1 = 0;
2375 ti.freq1 = 0;
2376 ixj_init_tone(j, &ti);
2377 ti.tone_index = 24;
2378 ti.gain0 = 1;
2379 ti.freq0 = hz2450;
2380 ti.gain1 = 0;
2381 ti.freq1 = 0;
2382 ixj_init_tone(j, &ti);
2383 ti.tone_index = 25;
2384 ti.gain0 = 1;
2385 ti.freq0 = hz350;
2386 ti.gain1 = 0;
2387 ti.freq1 = hz440;
2388 ixj_init_tone(j, &ti);
2389 ti.tone_index = 26;
2390 ti.gain0 = 1;
2391 ti.freq0 = hz440;
2392 ti.gain1 = 0;
2393 ti.freq1 = hz480;
2394 ixj_init_tone(j, &ti);
2395 ti.tone_index = 27;
2396 ti.gain0 = 1;
2397 ti.freq0 = hz480;
2398 ti.gain1 = 0;
2399 ti.freq1 = hz620;
2400 ixj_init_tone(j, &ti);
2401
2402 set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
2403
2404 set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
2405
2406 j->ex.bits.dtmf_ready = 0;
2407 j->dtmf_state = 0;
2408 j->dtmf_wp = j->dtmf_rp = 0;
2409 j->rec_mode = j->play_mode = -1;
2410 j->flags.ringing = 0;
2411 j->maxrings = MAXRINGS;
2412 j->ring_cadence = USA_RING_CADENCE;
2413 if(j->cadence_f[5].enable) {
2414 j->cadence_f[5].enable = j->cadence_f[5].en_filter = j->cadence_f[5].state = 0;
2415 }
2416 j->drybuffer = 0;
2417 j->winktime = 320;
2418 j->flags.dtmf_oob = 0;
2419 for (cnt = 0; cnt < 4; cnt++)
2420 j->cadence_f[cnt].enable = 0;
2421
2422 idle(j);
2423
2424 if(j->cardtype == QTI_PHONECARD) {
2425 SLIC_SetState(PLD_SLIC_STATE_OC, j);
2426 }
2427
2428 if (file_p->f_mode & FMODE_READ)
2429 j->readers--;
2430 if (file_p->f_mode & FMODE_WRITE)
2431 j->writers--;
2432
2433 if (j->read_buffer && !j->readers) {
2434 kfree(j->read_buffer);
2435 j->read_buffer = NULL;
2436 j->read_buffer_size = 0;
2437 }
2438 if (j->write_buffer && !j->writers) {
2439 kfree(j->write_buffer);
2440 j->write_buffer = NULL;
2441 j->write_buffer_size = 0;
2442 }
2443 j->rec_codec = j->play_codec = 0;
2444 j->rec_frame_size = j->play_frame_size = 0;
2445 j->flags.cidsent = j->flags.cidring = 0;
2446 ixj_fasync(-1, file_p, 0); /* remove from list of async notification */
2447
2448 if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) {
2449 ixj_set_port(j, PORT_PSTN);
2450 daa_set_mode(j, SOP_PU_SLEEP);
2451 ixj_set_pots(j, 1);
2452 }
2453 ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
2454
2455 /* Set up the default signals for events */
2456 for (cnt = 0; cnt < 35; cnt++)
2457 j->ixj_signals[cnt] = SIGIO;
2458
2459 /* Set the excetion signal enable flags */
2460 j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
2461 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 =
2462 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;
2463
2464 file_p->private_data = NULL;
2465 clear_bit(board, &j->busyflags);
2466 MOD_DEC_USE_COUNT;
2467 return 0;
2468 }
2469
read_filters(IXJ * j)2470 static int read_filters(IXJ *j)
2471 {
2472 unsigned short fc, cnt, trg;
2473 int var;
2474
2475 trg = 0;
2476 if (ixj_WriteDSPCommand(0x5144, j)) {
2477 if(ixjdebug & 0x0001) {
2478 printk(KERN_INFO "Read Frame Counter failed!\n");
2479 }
2480 return -1;
2481 }
2482 fc = j->ssr.high << 8 | j->ssr.low;
2483 if (fc == j->frame_count)
2484 return 1;
2485
2486 j->frame_count = fc;
2487
2488 if (j->dtmf_proc)
2489 return 1;
2490
2491 var = 10;
2492
2493 for (cnt = 0; cnt < 4; cnt++) {
2494 if (ixj_WriteDSPCommand(0x5154 + cnt, j)) {
2495 if(ixjdebug & 0x0001) {
2496 printk(KERN_INFO "Select Filter %d failed!\n", cnt);
2497 }
2498 return -1;
2499 }
2500 if (ixj_WriteDSPCommand(0x515C, j)) {
2501 if(ixjdebug & 0x0001) {
2502 printk(KERN_INFO "Read Filter History %d failed!\n", cnt);
2503 }
2504 return -1;
2505 }
2506 j->filter_hist[cnt] = j->ssr.high << 8 | j->ssr.low;
2507
2508 if (j->cadence_f[cnt].enable) {
2509 if (j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) {
2510 if (j->cadence_f[cnt].state == 0) {
2511 j->cadence_f[cnt].state = 1;
2512 j->cadence_f[cnt].on1min = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 - var)) / 10000));
2513 j->cadence_f[cnt].on1dot = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100)) / 10000));
2514 j->cadence_f[cnt].on1max = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 + var)) / 10000));
2515 } else if (j->cadence_f[cnt].state == 2 &&
2516 (time_after(jiffies, j->cadence_f[cnt].off1min) &&
2517 time_before(jiffies, j->cadence_f[cnt].off1max))) {
2518 if (j->cadence_f[cnt].on2) {
2519 j->cadence_f[cnt].state = 3;
2520 j->cadence_f[cnt].on2min = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 - var)) / 10000));
2521 j->cadence_f[cnt].on2dot = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100)) / 10000));
2522 j->cadence_f[cnt].on2max = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 + var)) / 10000));
2523 } else {
2524 j->cadence_f[cnt].state = 7;
2525 }
2526 } else if (j->cadence_f[cnt].state == 4 &&
2527 (time_after(jiffies, j->cadence_f[cnt].off2min) &&
2528 time_before(jiffies, j->cadence_f[cnt].off2max))) {
2529 if (j->cadence_f[cnt].on3) {
2530 j->cadence_f[cnt].state = 5;
2531 j->cadence_f[cnt].on3min = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 - var)) / 10000));
2532 j->cadence_f[cnt].on3dot = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100)) / 10000));
2533 j->cadence_f[cnt].on3max = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 + var)) / 10000));
2534 } else {
2535 j->cadence_f[cnt].state = 7;
2536 }
2537 } else {
2538 j->cadence_f[cnt].state = 0;
2539 }
2540 } else if (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)) {
2541 if (j->cadence_f[cnt].state == 1) {
2542 if(!j->cadence_f[cnt].on1) {
2543 j->cadence_f[cnt].state = 7;
2544 } else if((time_after(jiffies, j->cadence_f[cnt].on1min) &&
2545 time_before(jiffies, j->cadence_f[cnt].on1max))) {
2546 if(j->cadence_f[cnt].off1) {
2547 j->cadence_f[cnt].state = 2;
2548 j->cadence_f[cnt].off1min = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 - var)) / 10000));
2549 j->cadence_f[cnt].off1dot = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100)) / 10000));
2550 j->cadence_f[cnt].off1max = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 + var)) / 10000));
2551 } else {
2552 j->cadence_f[cnt].state = 7;
2553 }
2554 } else {
2555 j->cadence_f[cnt].state = 0;
2556 }
2557 } else if (j->cadence_f[cnt].state == 3) {
2558 if((time_after(jiffies, j->cadence_f[cnt].on2min) &&
2559 time_before(jiffies, j->cadence_f[cnt].on2max))) {
2560 if(j->cadence_f[cnt].off2) {
2561 j->cadence_f[cnt].state = 4;
2562 j->cadence_f[cnt].off2min = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 - var)) / 10000));
2563 j->cadence_f[cnt].off2dot = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100)) / 10000));
2564 j->cadence_f[cnt].off2max = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 + var)) / 10000));
2565 } else {
2566 j->cadence_f[cnt].state = 7;
2567 }
2568 } else {
2569 j->cadence_f[cnt].state = 0;
2570 }
2571 } else if (j->cadence_f[cnt].state == 5) {
2572 if ((time_after(jiffies, j->cadence_f[cnt].on3min) &&
2573 time_before(jiffies, j->cadence_f[cnt].on3max))) {
2574 if(j->cadence_f[cnt].off3) {
2575 j->cadence_f[cnt].state = 6;
2576 j->cadence_f[cnt].off3min = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 - var)) / 10000));
2577 j->cadence_f[cnt].off3dot = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100)) / 10000));
2578 j->cadence_f[cnt].off3max = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 + var)) / 10000));
2579 } else {
2580 j->cadence_f[cnt].state = 7;
2581 }
2582 } else {
2583 j->cadence_f[cnt].state = 0;
2584 }
2585 } else {
2586 j->cadence_f[cnt].state = 0;
2587 }
2588 } else {
2589 switch(j->cadence_f[cnt].state) {
2590 case 1:
2591 if(time_after(jiffies, j->cadence_f[cnt].on1dot) &&
2592 !j->cadence_f[cnt].off1 &&
2593 !j->cadence_f[cnt].on2 && !j->cadence_f[cnt].off2 &&
2594 !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
2595 j->cadence_f[cnt].state = 7;
2596 }
2597 break;
2598 case 3:
2599 if(time_after(jiffies, j->cadence_f[cnt].on2dot) &&
2600 !j->cadence_f[cnt].off2 &&
2601 !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) {
2602 j->cadence_f[cnt].state = 7;
2603 }
2604 break;
2605 case 5:
2606 if(time_after(jiffies, j->cadence_f[cnt].on3dot) &&
2607 !j->cadence_f[cnt].off3) {
2608 j->cadence_f[cnt].state = 7;
2609 }
2610 break;
2611 }
2612 }
2613
2614 if (ixjdebug & 0x0040) {
2615 printk(KERN_INFO "IXJ Tone Cadence state = %d /dev/phone%d at %ld\n", j->cadence_f[cnt].state, j->board, jiffies);
2616 switch(j->cadence_f[cnt].state) {
2617 case 0:
2618 printk(KERN_INFO "IXJ /dev/phone%d No Tone detected\n", j->board);
2619 break;
2620 case 1:
2621 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %u %ld - %ld - %ld\n", j->board,
2622 j->cadence_f[cnt].on1, j->cadence_f[cnt].on1min, j->cadence_f[cnt].on1dot, j->cadence_f[cnt].on1max);
2623 break;
2624 case 2:
2625 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off1min,
2626 j->cadence_f[cnt].off1max);
2627 break;
2628 case 3:
2629 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on2min,
2630 j->cadence_f[cnt].on2max);
2631 break;
2632 case 4:
2633 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off2min,
2634 j->cadence_f[cnt].off2max);
2635 break;
2636 case 5:
2637 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on3min,
2638 j->cadence_f[cnt].on3max);
2639 break;
2640 case 6:
2641 printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off3min,
2642 j->cadence_f[cnt].off3max);
2643 break;
2644 }
2645 }
2646 }
2647 if (j->cadence_f[cnt].state == 7) {
2648 j->cadence_f[cnt].state = 0;
2649 if (j->cadence_f[cnt].enable == 1)
2650 j->cadence_f[cnt].enable = 0;
2651 switch (cnt) {
2652 case 0:
2653 if(ixjdebug & 0x0020) {
2654 printk(KERN_INFO "Filter Cadence 0 triggered %ld\n", jiffies);
2655 }
2656 j->ex.bits.fc0 = 1;
2657 ixj_kill_fasync(j, SIG_FC0, POLL_IN);
2658 break;
2659 case 1:
2660 if(ixjdebug & 0x0020) {
2661 printk(KERN_INFO "Filter Cadence 1 triggered %ld\n", jiffies);
2662 }
2663 j->ex.bits.fc1 = 1;
2664 ixj_kill_fasync(j, SIG_FC1, POLL_IN);
2665 break;
2666 case 2:
2667 if(ixjdebug & 0x0020) {
2668 printk(KERN_INFO "Filter Cadence 2 triggered %ld\n", jiffies);
2669 }
2670 j->ex.bits.fc2 = 1;
2671 ixj_kill_fasync(j, SIG_FC2, POLL_IN);
2672 break;
2673 case 3:
2674 if(ixjdebug & 0x0020) {
2675 printk(KERN_INFO "Filter Cadence 3 triggered %ld\n", jiffies);
2676 }
2677 j->ex.bits.fc3 = 1;
2678 ixj_kill_fasync(j, SIG_FC3, POLL_IN);
2679 break;
2680 }
2681 }
2682 if (j->filter_en[cnt] && ((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) ||
2683 (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)))) {
2684 if((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12))) {
2685 trg = 1;
2686 } else if((j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3))) {
2687 trg = 0;
2688 }
2689 switch (cnt) {
2690 case 0:
2691 if(ixjdebug & 0x0020) {
2692 printk(KERN_INFO "Filter 0 triggered %d at %ld\n", trg, jiffies);
2693 }
2694 j->ex.bits.f0 = 1;
2695 ixj_kill_fasync(j, SIG_F0, POLL_IN);
2696 break;
2697 case 1:
2698 if(ixjdebug & 0x0020) {
2699 printk(KERN_INFO "Filter 1 triggered %d at %ld\n", trg, jiffies);
2700 }
2701 j->ex.bits.f1 = 1;
2702 ixj_kill_fasync(j, SIG_F1, POLL_IN);
2703 break;
2704 case 2:
2705 if(ixjdebug & 0x0020) {
2706 printk(KERN_INFO "Filter 2 triggered %d at %ld\n", trg, jiffies);
2707 }
2708 j->ex.bits.f2 = 1;
2709 ixj_kill_fasync(j, SIG_F2, POLL_IN);
2710 break;
2711 case 3:
2712 if(ixjdebug & 0x0020) {
2713 printk(KERN_INFO "Filter 3 triggered %d at %ld\n", trg, jiffies);
2714 }
2715 j->ex.bits.f3 = 1;
2716 ixj_kill_fasync(j, SIG_F3, POLL_IN);
2717 break;
2718 }
2719 }
2720 }
2721 return 0;
2722 }
2723
LineMonitor(IXJ * j)2724 static int LineMonitor(IXJ *j)
2725 {
2726 if (j->dtmf_proc) {
2727 return -1;
2728 }
2729 j->dtmf_proc = 1;
2730
2731 if (ixj_WriteDSPCommand(0x7000, j)) /* Line Monitor */
2732 return -1;
2733
2734 j->dtmf.bytes.high = j->ssr.high;
2735 j->dtmf.bytes.low = j->ssr.low;
2736 if (!j->dtmf_state && j->dtmf.bits.dtmf_valid) {
2737 j->dtmf_state = 1;
2738 j->dtmf_current = j->dtmf.bits.digit;
2739 }
2740 if (j->dtmf_state && !j->dtmf.bits.dtmf_valid) /* && j->dtmf_wp != j->dtmf_rp) */
2741 {
2742 if(!j->cidcw_wait) {
2743 j->dtmfbuffer[j->dtmf_wp] = j->dtmf_current;
2744 j->dtmf_wp++;
2745 if (j->dtmf_wp == 79)
2746 j->dtmf_wp = 0;
2747 j->ex.bits.dtmf_ready = 1;
2748 if(j->ex_sig.bits.dtmf_ready) {
2749 ixj_kill_fasync(j, SIG_DTMF_READY, POLL_IN);
2750 }
2751 }
2752 else if(j->dtmf_current == 0x00 || j->dtmf_current == 0x0D) {
2753 if(ixjdebug & 0x0020) {
2754 printk("IXJ phone%d saw CIDCW Ack DTMF %d from display at %ld\n", j->board, j->dtmf_current, jiffies);
2755 }
2756 j->flags.cidcw_ack = 1;
2757 }
2758 j->dtmf_state = 0;
2759 }
2760 j->dtmf_proc = 0;
2761
2762 return 0;
2763 }
2764
2765 /************************************************************************
2766 *
2767 * Functions to allow alaw <-> ulaw conversions.
2768 *
2769 ************************************************************************/
2770
ulaw2alaw(unsigned char * buff,unsigned long len)2771 static void ulaw2alaw(unsigned char *buff, unsigned long len)
2772 {
2773 static unsigned char table_ulaw2alaw[] =
2774 {
2775 0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D,
2776 0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25,
2777 0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D,
2778 0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35,
2779 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02,
2780 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A,
2781 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12,
2782 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B,
2783 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63,
2784 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79,
2785 0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71,
2786 0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D,
2787 0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45,
2788 0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D,
2789 0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51,
2790 0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5,
2791 0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD,
2792 0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5,
2793 0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD,
2794 0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5,
2795 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82,
2796 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A,
2797 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92,
2798 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB,
2799 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3,
2800 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9,
2801 0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1,
2802 0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD,
2803 0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5,
2804 0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD,
2805 0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1,
2806 0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5
2807 };
2808
2809 while (len--)
2810 {
2811 *buff = table_ulaw2alaw[*(unsigned char *)buff];
2812 buff++;
2813 }
2814 }
2815
alaw2ulaw(unsigned char * buff,unsigned long len)2816 static void alaw2ulaw(unsigned char *buff, unsigned long len)
2817 {
2818 static unsigned char table_alaw2ulaw[] =
2819 {
2820 0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C,
2821 0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24,
2822 0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C,
2823 0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34,
2824 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D,
2825 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
2826 0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D,
2827 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15,
2828 0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65,
2829 0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E,
2830 0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A,
2831 0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D,
2832 0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B,
2833 0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43,
2834 0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59,
2835 0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51,
2836 0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC,
2837 0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4,
2838 0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC,
2839 0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4,
2840 0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D,
2841 0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85,
2842 0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D,
2843 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95,
2844 0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5,
2845 0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE,
2846 0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA,
2847 0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED,
2848 0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB,
2849 0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3,
2850 0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9,
2851 0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1
2852 };
2853
2854 while (len--)
2855 {
2856 *buff = table_alaw2ulaw[*(unsigned char *)buff];
2857 buff++;
2858 }
2859 }
2860
ixj_read(struct file * file_p,char * buf,size_t length,loff_t * ppos)2861 static ssize_t ixj_read(struct file * file_p, char *buf, size_t length, loff_t * ppos)
2862 {
2863 unsigned long i = *ppos;
2864 IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
2865
2866 DECLARE_WAITQUEUE(wait, current);
2867
2868 if (j->flags.inread)
2869 return -EALREADY;
2870
2871 j->flags.inread = 1;
2872
2873 add_wait_queue(&j->read_q, &wait);
2874 set_current_state(TASK_INTERRUPTIBLE);
2875 mb();
2876
2877 while (!j->read_buffer_ready || (j->dtmf_state && j->flags.dtmf_oob)) {
2878 ++j->read_wait;
2879 if (file_p->f_flags & O_NONBLOCK) {
2880 set_current_state(TASK_RUNNING);
2881 remove_wait_queue(&j->read_q, &wait);
2882 j->flags.inread = 0;
2883 return -EAGAIN;
2884 }
2885 if (!ixj_hookstate(j)) {
2886 set_current_state(TASK_RUNNING);
2887 remove_wait_queue(&j->read_q, &wait);
2888 j->flags.inread = 0;
2889 return 0;
2890 }
2891 interruptible_sleep_on(&j->read_q);
2892 if (signal_pending(current)) {
2893 set_current_state(TASK_RUNNING);
2894 remove_wait_queue(&j->read_q, &wait);
2895 j->flags.inread = 0;
2896 return -EINTR;
2897 }
2898 }
2899
2900 remove_wait_queue(&j->read_q, &wait);
2901 set_current_state(TASK_RUNNING);
2902 /* Don't ever copy more than the user asks */
2903 if(j->rec_codec == ALAW)
2904 ulaw2alaw(j->read_buffer, min(length, j->read_buffer_size));
2905 i = copy_to_user(buf, j->read_buffer, min(length, j->read_buffer_size));
2906 j->read_buffer_ready = 0;
2907 if (i) {
2908 j->flags.inread = 0;
2909 return -EFAULT;
2910 } else {
2911 j->flags.inread = 0;
2912 return min(length, j->read_buffer_size);
2913 }
2914 }
2915
ixj_enhanced_read(struct file * file_p,char * buf,size_t length,loff_t * ppos)2916 static ssize_t ixj_enhanced_read(struct file * file_p, char *buf, size_t length,
2917 loff_t * ppos)
2918 {
2919 int pre_retval;
2920 ssize_t read_retval = 0;
2921 IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
2922
2923 pre_retval = ixj_PreRead(j, 0L);
2924 switch (pre_retval) {
2925 case NORMAL:
2926 read_retval = ixj_read(file_p, buf, length, ppos);
2927 ixj_PostRead(j, 0L);
2928 break;
2929 case NOPOST:
2930 read_retval = ixj_read(file_p, buf, length, ppos);
2931 break;
2932 case POSTONLY:
2933 ixj_PostRead(j, 0L);
2934 break;
2935 default:
2936 read_retval = pre_retval;
2937 }
2938 return read_retval;
2939 }
2940
ixj_write(struct file * file_p,const char * buf,size_t count,loff_t * ppos)2941 static ssize_t ixj_write(struct file *file_p, const char *buf, size_t count, loff_t * ppos)
2942 {
2943 unsigned long i = *ppos;
2944 IXJ *j = file_p->private_data;
2945
2946 DECLARE_WAITQUEUE(wait, current);
2947
2948 if (j->flags.inwrite)
2949 return -EALREADY;
2950
2951 j->flags.inwrite = 1;
2952
2953 add_wait_queue(&j->write_q, &wait);
2954 set_current_state(TASK_INTERRUPTIBLE);
2955 mb();
2956
2957
2958 while (!j->write_buffers_empty) {
2959 ++j->write_wait;
2960 if (file_p->f_flags & O_NONBLOCK) {
2961 set_current_state(TASK_RUNNING);
2962 remove_wait_queue(&j->write_q, &wait);
2963 j->flags.inwrite = 0;
2964 return -EAGAIN;
2965 }
2966 if (!ixj_hookstate(j)) {
2967 set_current_state(TASK_RUNNING);
2968 remove_wait_queue(&j->write_q, &wait);
2969 j->flags.inwrite = 0;
2970 return 0;
2971 }
2972 interruptible_sleep_on(&j->write_q);
2973 if (signal_pending(current)) {
2974 set_current_state(TASK_RUNNING);
2975 remove_wait_queue(&j->write_q, &wait);
2976 j->flags.inwrite = 0;
2977 return -EINTR;
2978 }
2979 }
2980 set_current_state(TASK_RUNNING);
2981 remove_wait_queue(&j->write_q, &wait);
2982 if (j->write_buffer_wp + count >= j->write_buffer_end)
2983 j->write_buffer_wp = j->write_buffer;
2984 i = copy_from_user(j->write_buffer_wp, buf, min(count, j->write_buffer_size));
2985 if (i) {
2986 j->flags.inwrite = 0;
2987 return -EFAULT;
2988 }
2989 if(j->play_codec == ALAW)
2990 alaw2ulaw(j->write_buffer_wp, min(count, j->write_buffer_size));
2991 j->flags.inwrite = 0;
2992 return min(count, j->write_buffer_size);
2993 }
2994
ixj_enhanced_write(struct file * file_p,const char * buf,size_t count,loff_t * ppos)2995 static ssize_t ixj_enhanced_write(struct file * file_p, const char *buf, size_t count, loff_t * ppos)
2996 {
2997 int pre_retval;
2998 ssize_t write_retval = 0;
2999
3000 IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
3001
3002 pre_retval = ixj_PreWrite(j, 0L);
3003 switch (pre_retval) {
3004 case NORMAL:
3005 write_retval = ixj_write(file_p, buf, count, ppos);
3006 if (write_retval > 0) {
3007 ixj_PostWrite(j, 0L);
3008 j->write_buffer_wp += write_retval;
3009 j->write_buffers_empty--;
3010 }
3011 break;
3012 case NOPOST:
3013 write_retval = ixj_write(file_p, buf, count, ppos);
3014 if (write_retval > 0) {
3015 j->write_buffer_wp += write_retval;
3016 j->write_buffers_empty--;
3017 }
3018 break;
3019 case POSTONLY:
3020 ixj_PostWrite(j, 0L);
3021 break;
3022 default:
3023 write_retval = pre_retval;
3024 }
3025 return write_retval;
3026 }
3027
ixj_read_frame(IXJ * j)3028 static void ixj_read_frame(IXJ *j)
3029 {
3030 int cnt, dly;
3031
3032 if (j->read_buffer) {
3033 for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
3034 if (!(cnt % 16) && !IsRxReady(j)) {
3035 dly = 0;
3036 while (!IsRxReady(j)) {
3037 if (dly++ > 5) {
3038 dly = 0;
3039 break;
3040 }
3041 udelay(10);
3042 }
3043 }
3044 /* Throw away word 0 of the 8021 compressed format to get standard G.729. */
3045 if (j->rec_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
3046 inb_p(j->DSPbase + 0x0E);
3047 inb_p(j->DSPbase + 0x0F);
3048 }
3049 *(j->read_buffer + cnt) = inb_p(j->DSPbase + 0x0E);
3050 *(j->read_buffer + cnt + 1) = inb_p(j->DSPbase + 0x0F);
3051 }
3052 ++j->framesread;
3053 if (j->intercom != -1) {
3054 if (IsTxReady(get_ixj(j->intercom))) {
3055 for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) {
3056 if (!(cnt % 16) && !IsTxReady(j)) {
3057 dly = 0;
3058 while (!IsTxReady(j)) {
3059 if (dly++ > 5) {
3060 dly = 0;
3061 break;
3062 }
3063 udelay(10);
3064 }
3065 }
3066 outb_p(*(j->read_buffer + cnt), get_ixj(j->intercom)->DSPbase + 0x0C);
3067 outb_p(*(j->read_buffer + cnt + 1), get_ixj(j->intercom)->DSPbase + 0x0D);
3068 }
3069 get_ixj(j->intercom)->frameswritten++;
3070 }
3071 } else {
3072 j->read_buffer_ready = 1;
3073 wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
3074
3075 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
3076
3077 if(j->ixj_signals[SIG_READ_READY])
3078 ixj_kill_fasync(j, SIG_READ_READY, POLL_OUT);
3079 }
3080 }
3081 }
3082
3083 static short fsk[][6][20] =
3084 {
3085 {
3086 {
3087 0, 17846, 29934, 32364, 24351, 8481, -10126, -25465, -32587, -29196,
3088 -16384, 1715, 19260, 30591, 32051, 23170, 6813, -11743, -26509, -32722
3089 },
3090 {
3091 -28377, -14876, 3425, 20621, 31163, 31650, 21925, 5126, -13328, -27481,
3092 -32767, -27481, -13328, 5126, 21925, 31650, 31163, 20621, 3425, -14876
3093 },
3094 {
3095 -28377, -32722, -26509, -11743, 6813, 23170, 32051, 30591, 19260, 1715,
3096 -16384, -29196, -32587, -25465, -10126, 8481, 24351, 32364, 29934, 17846
3097 },
3098 {
3099 0, -17846, -29934, -32364, -24351, -8481, 10126, 25465, 32587, 29196,
3100 16384, -1715, -19260, -30591, -32051, -23170, -6813, 11743, 26509, 32722
3101 },
3102 {
3103 28377, 14876, -3425, -20621, -31163, -31650, -21925, -5126, 13328, 27481,
3104 32767, 27481, 13328, -5126, -21925, -31650, -31163, -20621, -3425, 14876
3105 },
3106 {
3107 28377, 32722, 26509, 11743, -6813, -23170, -32051, -30591, -19260, -1715,
3108 16384, 29196, 32587, 25465, 10126, -8481, -24351, -32364, -29934, -17846
3109 }
3110 },
3111 {
3112 {
3113 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126,
3114 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126
3115 },
3116 {
3117 -28377, -21925, -13328, -3425, 6813, 16384, 24351, 29934, 32587, 32051,
3118 28377, 21925, 13328, 3425, -6813, -16384, -24351, -29934, -32587, -32051
3119 },
3120 {
3121 -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925,
3122 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925
3123 },
3124 {
3125 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126,
3126 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126
3127 },
3128 {
3129 28377, 21925, 13328, 3425, -6813, -16383, -24351, -29934, -32587, -32051,
3130 -28377, -21925, -13328, -3425, 6813, 16383, 24351, 29934, 32587, 32051
3131 },
3132 {
3133 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925,
3134 -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925
3135 }
3136 }
3137 };
3138
3139
ixj_write_cid_bit(IXJ * j,int bit)3140 static void ixj_write_cid_bit(IXJ *j, int bit)
3141 {
3142 while (j->fskcnt < 20) {
3143 if(j->fskdcnt < (j->fsksize - 1))
3144 j->fskdata[j->fskdcnt++] = fsk[bit][j->fskz][j->fskcnt];
3145
3146 j->fskcnt += 3;
3147 }
3148 j->fskcnt %= 20;
3149
3150 if (!bit)
3151 j->fskz++;
3152 if (j->fskz >= 6)
3153 j->fskz = 0;
3154
3155 }
3156
ixj_write_cid_byte(IXJ * j,char byte)3157 static void ixj_write_cid_byte(IXJ *j, char byte)
3158 {
3159 IXJ_CBYTE cb;
3160
3161 cb.cbyte = byte;
3162 ixj_write_cid_bit(j, 0);
3163 ixj_write_cid_bit(j, cb.cbits.b0 ? 1 : 0);
3164 ixj_write_cid_bit(j, cb.cbits.b1 ? 1 : 0);
3165 ixj_write_cid_bit(j, cb.cbits.b2 ? 1 : 0);
3166 ixj_write_cid_bit(j, cb.cbits.b3 ? 1 : 0);
3167 ixj_write_cid_bit(j, cb.cbits.b4 ? 1 : 0);
3168 ixj_write_cid_bit(j, cb.cbits.b5 ? 1 : 0);
3169 ixj_write_cid_bit(j, cb.cbits.b6 ? 1 : 0);
3170 ixj_write_cid_bit(j, cb.cbits.b7 ? 1 : 0);
3171 ixj_write_cid_bit(j, 1);
3172 }
3173
ixj_write_cid_seize(IXJ * j)3174 static void ixj_write_cid_seize(IXJ *j)
3175 {
3176 int cnt;
3177
3178 for (cnt = 0; cnt < 150; cnt++) {
3179 ixj_write_cid_bit(j, 0);
3180 ixj_write_cid_bit(j, 1);
3181 }
3182 for (cnt = 0; cnt < 180; cnt++) {
3183 ixj_write_cid_bit(j, 1);
3184 }
3185 }
3186
ixj_write_cidcw_seize(IXJ * j)3187 static void ixj_write_cidcw_seize(IXJ *j)
3188 {
3189 int cnt;
3190
3191 for (cnt = 0; cnt < 80; cnt++) {
3192 ixj_write_cid_bit(j, 1);
3193 }
3194 }
3195
ixj_write_cid_string(IXJ * j,char * s,int checksum)3196 static int ixj_write_cid_string(IXJ *j, char *s, int checksum)
3197 {
3198 int cnt;
3199
3200 for (cnt = 0; cnt < strlen(s); cnt++) {
3201 ixj_write_cid_byte(j, s[cnt]);
3202 checksum = (checksum + s[cnt]);
3203 }
3204 return checksum;
3205 }
3206
ixj_pad_fsk(IXJ * j,int pad)3207 static void ixj_pad_fsk(IXJ *j, int pad)
3208 {
3209 int cnt;
3210
3211 for (cnt = 0; cnt < pad; cnt++) {
3212 if(j->fskdcnt < (j->fsksize - 1))
3213 j->fskdata[j->fskdcnt++] = 0x0000;
3214 }
3215 for (cnt = 0; cnt < 720; cnt++) {
3216 if(j->fskdcnt < (j->fsksize - 1))
3217 j->fskdata[j->fskdcnt++] = 0x0000;
3218 }
3219 }
3220
ixj_pre_cid(IXJ * j)3221 static void ixj_pre_cid(IXJ *j)
3222 {
3223 j->cid_play_codec = j->play_codec;
3224 j->cid_play_frame_size = j->play_frame_size;
3225 j->cid_play_volume = get_play_volume(j);
3226 j->cid_play_flag = j->flags.playing;
3227
3228 j->cid_rec_codec = j->rec_codec;
3229 j->cid_rec_volume = get_rec_volume(j);
3230 j->cid_rec_flag = j->flags.recording;
3231
3232 j->cid_play_aec_level = j->aec_level;
3233
3234 switch(j->baseframe.low) {
3235 case 0xA0:
3236 j->cid_base_frame_size = 20;
3237 break;
3238 case 0x50:
3239 j->cid_base_frame_size = 10;
3240 break;
3241 case 0xF0:
3242 j->cid_base_frame_size = 30;
3243 break;
3244 }
3245
3246 ixj_play_stop(j);
3247 ixj_cpt_stop(j);
3248
3249 j->flags.cidplay = 1;
3250
3251 set_base_frame(j, 30);
3252 set_play_codec(j, LINEAR16);
3253 set_play_volume(j, 0x1B);
3254 ixj_play_start(j);
3255 }
3256
ixj_post_cid(IXJ * j)3257 static void ixj_post_cid(IXJ *j)
3258 {
3259 ixj_play_stop(j);
3260
3261 if(j->cidsize > 5000) {
3262 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
3263 }
3264 j->flags.cidplay = 0;
3265 if(ixjdebug & 0x0200) {
3266 printk("IXJ phone%d Finished Playing CallerID data %ld\n", j->board, jiffies);
3267 }
3268
3269 ixj_fsk_free(j);
3270
3271 j->fskdcnt = 0;
3272 set_base_frame(j, j->cid_base_frame_size);
3273 set_play_codec(j, j->cid_play_codec);
3274 ixj_aec_start(j, j->cid_play_aec_level);
3275 set_play_volume(j, j->cid_play_volume);
3276
3277 set_rec_codec(j, j->cid_rec_codec);
3278 set_rec_volume(j, j->cid_rec_volume);
3279
3280 if(j->cid_rec_flag)
3281 ixj_record_start(j);
3282
3283 if(j->cid_play_flag)
3284 ixj_play_start(j);
3285
3286 if(j->cid_play_flag) {
3287 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3288 }
3289 }
3290
ixj_write_cid(IXJ * j)3291 static void ixj_write_cid(IXJ *j)
3292 {
3293 char sdmf1[50];
3294 char sdmf2[50];
3295 char sdmf3[80];
3296 char mdmflen, len1, len2, len3;
3297 int pad;
3298
3299 int checksum = 0;
3300
3301 if (j->dsp.low == 0x20 || j->flags.cidplay)
3302 return;
3303
3304 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3305 j->cidsize = j->cidcnt = 0;
3306
3307 ixj_fsk_alloc(j);
3308
3309 strcpy(sdmf1, j->cid_send.month);
3310 strcat(sdmf1, j->cid_send.day);
3311 strcat(sdmf1, j->cid_send.hour);
3312 strcat(sdmf1, j->cid_send.min);
3313 strcpy(sdmf2, j->cid_send.number);
3314 strcpy(sdmf3, j->cid_send.name);
3315
3316 len1 = strlen(sdmf1);
3317 len2 = strlen(sdmf2);
3318 len3 = strlen(sdmf3);
3319 mdmflen = len1 + len2 + len3 + 6;
3320
3321 while(1){
3322 ixj_write_cid_seize(j);
3323
3324 ixj_write_cid_byte(j, 0x80);
3325 checksum = 0x80;
3326 ixj_write_cid_byte(j, mdmflen);
3327 checksum = checksum + mdmflen;
3328
3329 ixj_write_cid_byte(j, 0x01);
3330 checksum = checksum + 0x01;
3331 ixj_write_cid_byte(j, len1);
3332 checksum = checksum + len1;
3333 checksum = ixj_write_cid_string(j, sdmf1, checksum);
3334 if(ixj_hookstate(j) & 1)
3335 break;
3336
3337 ixj_write_cid_byte(j, 0x02);
3338 checksum = checksum + 0x02;
3339 ixj_write_cid_byte(j, len2);
3340 checksum = checksum + len2;
3341 checksum = ixj_write_cid_string(j, sdmf2, checksum);
3342 if(ixj_hookstate(j) & 1)
3343 break;
3344
3345 ixj_write_cid_byte(j, 0x07);
3346 checksum = checksum + 0x07;
3347 ixj_write_cid_byte(j, len3);
3348 checksum = checksum + len3;
3349 checksum = ixj_write_cid_string(j, sdmf3, checksum);
3350 if(ixj_hookstate(j) & 1)
3351 break;
3352
3353 checksum %= 256;
3354 checksum ^= 0xFF;
3355 checksum += 1;
3356
3357 ixj_write_cid_byte(j, (char) checksum);
3358
3359 pad = j->fskdcnt % 240;
3360 if (pad) {
3361 pad = 240 - pad;
3362 }
3363 ixj_pad_fsk(j, pad);
3364 break;
3365 }
3366
3367 ixj_write_frame(j);
3368 }
3369
ixj_write_cidcw(IXJ * j)3370 static void ixj_write_cidcw(IXJ *j)
3371 {
3372 IXJ_TONE ti;
3373
3374 char sdmf1[50];
3375 char sdmf2[50];
3376 char sdmf3[80];
3377 char mdmflen, len1, len2, len3;
3378 int pad;
3379
3380 int checksum = 0;
3381
3382 if (j->dsp.low == 0x20 || j->flags.cidplay)
3383 return;
3384
3385 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3386 j->cidsize = j->cidcnt = 0;
3387
3388 ixj_fsk_alloc(j);
3389
3390 j->flags.cidcw_ack = 0;
3391
3392 ti.tone_index = 23;
3393 ti.gain0 = 1;
3394 ti.freq0 = hz440;
3395 ti.gain1 = 0;
3396 ti.freq1 = 0;
3397 ixj_init_tone(j, &ti);
3398
3399 ixj_set_tone_on(1500, j);
3400 ixj_set_tone_off(32, j);
3401 if(ixjdebug & 0x0200) {
3402 printk("IXJ cidcw phone%d first tone start at %ld\n", j->board, jiffies);
3403 }
3404 ixj_play_tone(j, 23);
3405
3406 clear_bit(j->board, &j->busyflags);
3407 while(j->tone_state) {
3408 set_current_state(TASK_INTERRUPTIBLE);
3409 schedule_timeout(1);
3410 }
3411 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
3412 set_current_state(TASK_INTERRUPTIBLE);
3413 schedule_timeout(1);
3414 }
3415 if(ixjdebug & 0x0200) {
3416 printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies);
3417 }
3418
3419 ti.tone_index = 24;
3420 ti.gain0 = 1;
3421 ti.freq0 = hz2130;
3422 ti.gain1 = 0;
3423 ti.freq1 = hz2750;
3424 ixj_init_tone(j, &ti);
3425
3426 ixj_set_tone_off(10, j);
3427 ixj_set_tone_on(600, j);
3428 if(ixjdebug & 0x0200) {
3429 printk("IXJ cidcw phone%d second tone start at %ld\n", j->board, jiffies);
3430 }
3431 ixj_play_tone(j, 24);
3432
3433 clear_bit(j->board, &j->busyflags);
3434 while(j->tone_state) {
3435 set_current_state(TASK_INTERRUPTIBLE);
3436 schedule_timeout(1);
3437 }
3438 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
3439 set_current_state(TASK_INTERRUPTIBLE);
3440 schedule_timeout(1);
3441 }
3442 if(ixjdebug & 0x0200) {
3443 printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies);
3444 }
3445
3446 j->cidcw_wait = jiffies + ((50 * hertz) / 100);
3447
3448 clear_bit(j->board, &j->busyflags);
3449 while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait)) {
3450 set_current_state(TASK_INTERRUPTIBLE);
3451 schedule_timeout(1);
3452 }
3453 while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
3454 set_current_state(TASK_INTERRUPTIBLE);
3455 schedule_timeout(1);
3456 }
3457 j->cidcw_wait = 0;
3458 if(!j->flags.cidcw_ack) {
3459 if(ixjdebug & 0x0200) {
3460 printk("IXJ cidcw phone%d did not receive ACK from display %ld\n", j->board, jiffies);
3461 }
3462 ixj_post_cid(j);
3463 if(j->cid_play_flag) {
3464 wake_up_interruptible(&j->write_q); /* Wake any blocked readers */
3465 }
3466 return;
3467 } else {
3468 ixj_pre_cid(j);
3469 }
3470 j->flags.cidcw_ack = 0;
3471 strcpy(sdmf1, j->cid_send.month);
3472 strcat(sdmf1, j->cid_send.day);
3473 strcat(sdmf1, j->cid_send.hour);
3474 strcat(sdmf1, j->cid_send.min);
3475 strcpy(sdmf2, j->cid_send.number);
3476 strcpy(sdmf3, j->cid_send.name);
3477
3478 len1 = strlen(sdmf1);
3479 len2 = strlen(sdmf2);
3480 len3 = strlen(sdmf3);
3481 mdmflen = len1 + len2 + len3 + 6;
3482
3483 ixj_write_cidcw_seize(j);
3484
3485 ixj_write_cid_byte(j, 0x80);
3486 checksum = 0x80;
3487 ixj_write_cid_byte(j, mdmflen);
3488 checksum = checksum + mdmflen;
3489
3490 ixj_write_cid_byte(j, 0x01);
3491 checksum = checksum + 0x01;
3492 ixj_write_cid_byte(j, len1);
3493 checksum = checksum + len1;
3494 checksum = ixj_write_cid_string(j, sdmf1, checksum);
3495
3496 ixj_write_cid_byte(j, 0x02);
3497 checksum = checksum + 0x02;
3498 ixj_write_cid_byte(j, len2);
3499 checksum = checksum + len2;
3500 checksum = ixj_write_cid_string(j, sdmf2, checksum);
3501
3502 ixj_write_cid_byte(j, 0x07);
3503 checksum = checksum + 0x07;
3504 ixj_write_cid_byte(j, len3);
3505 checksum = checksum + len3;
3506 checksum = ixj_write_cid_string(j, sdmf3, checksum);
3507
3508 checksum %= 256;
3509 checksum ^= 0xFF;
3510 checksum += 1;
3511
3512 ixj_write_cid_byte(j, (char) checksum);
3513
3514 pad = j->fskdcnt % 240;
3515 if (pad) {
3516 pad = 240 - pad;
3517 }
3518 ixj_pad_fsk(j, pad);
3519 if(ixjdebug & 0x0200) {
3520 printk("IXJ cidcw phone%d sent FSK data at %ld\n", j->board, jiffies);
3521 }
3522 }
3523
ixj_write_vmwi(IXJ * j,int msg)3524 static void ixj_write_vmwi(IXJ *j, int msg)
3525 {
3526 char mdmflen;
3527 int pad;
3528
3529 int checksum = 0;
3530
3531 if (j->dsp.low == 0x20 || j->flags.cidplay)
3532 return;
3533
3534 j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0;
3535 j->cidsize = j->cidcnt = 0;
3536
3537 ixj_fsk_alloc(j);
3538
3539 mdmflen = 3;
3540
3541 if (j->port == PORT_POTS)
3542 SLIC_SetState(PLD_SLIC_STATE_OHT, j);
3543
3544 ixj_write_cid_seize(j);
3545
3546 ixj_write_cid_byte(j, 0x82);
3547 checksum = 0x82;
3548 ixj_write_cid_byte(j, mdmflen);
3549 checksum = checksum + mdmflen;
3550
3551 ixj_write_cid_byte(j, 0x0B);
3552 checksum = checksum + 0x0B;
3553 ixj_write_cid_byte(j, 1);
3554 checksum = checksum + 1;
3555
3556 if(msg) {
3557 ixj_write_cid_byte(j, 0xFF);
3558 checksum = checksum + 0xFF;
3559 }
3560 else {
3561 ixj_write_cid_byte(j, 0x00);
3562 checksum = checksum + 0x00;
3563 }
3564
3565 checksum %= 256;
3566 checksum ^= 0xFF;
3567 checksum += 1;
3568
3569 ixj_write_cid_byte(j, (char) checksum);
3570
3571 pad = j->fskdcnt % 240;
3572 if (pad) {
3573 pad = 240 - pad;
3574 }
3575 ixj_pad_fsk(j, pad);
3576 }
3577
ixj_write_frame(IXJ * j)3578 static void ixj_write_frame(IXJ *j)
3579 {
3580 int cnt, frame_count, dly;
3581 IXJ_WORD dat;
3582 BYTES blankword;
3583
3584 frame_count = 0;
3585 if(j->flags.cidplay) {
3586 for(cnt = 0; cnt < 480; cnt++) {
3587 if (!(cnt % 16) && !IsTxReady(j)) {
3588 dly = 0;
3589 while (!IsTxReady(j)) {
3590 if (dly++ > 5) {
3591 dly = 0;
3592 break;
3593 }
3594 udelay(10);
3595 }
3596 }
3597 dat.word = j->fskdata[j->cidcnt++];
3598 outb_p(dat.bytes.low, j->DSPbase + 0x0C);
3599 outb_p(dat.bytes.high, j->DSPbase + 0x0D);
3600 cnt++;
3601 }
3602 if(j->cidcnt >= j->fskdcnt) {
3603 ixj_post_cid(j);
3604 }
3605 /* This may seem rude, but if we just played one frame of FSK data for CallerID
3606 and there is real audio data in the buffer, we need to throw it away because
3607 we just used it's time slot */
3608 if (j->write_buffer_rp > j->write_buffer_wp) {
3609 j->write_buffer_rp += j->cid_play_frame_size * 2;
3610 if (j->write_buffer_rp >= j->write_buffer_end) {
3611 j->write_buffer_rp = j->write_buffer;
3612 }
3613 j->write_buffers_empty++;
3614 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3615
3616 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
3617 }
3618 } else if (j->write_buffer && j->write_buffers_empty < 1) {
3619 if (j->write_buffer_wp > j->write_buffer_rp) {
3620 frame_count =
3621 (j->write_buffer_wp - j->write_buffer_rp) / (j->play_frame_size * 2);
3622 }
3623 if (j->write_buffer_rp > j->write_buffer_wp) {
3624 frame_count =
3625 (j->write_buffer_wp - j->write_buffer) / (j->play_frame_size * 2) +
3626 (j->write_buffer_end - j->write_buffer_rp) / (j->play_frame_size * 2);
3627 }
3628 if (frame_count >= 1) {
3629 if (j->ver.low == 0x12 && j->play_mode && j->flags.play_first_frame) {
3630 switch (j->play_mode) {
3631 case PLAYBACK_MODE_ULAW:
3632 case PLAYBACK_MODE_ALAW:
3633 blankword.low = blankword.high = 0xFF;
3634 break;
3635 case PLAYBACK_MODE_8LINEAR:
3636 case PLAYBACK_MODE_16LINEAR:
3637 blankword.low = blankword.high = 0x00;
3638 break;
3639 case PLAYBACK_MODE_8LINEAR_WSS:
3640 blankword.low = blankword.high = 0x80;
3641 break;
3642 }
3643 for (cnt = 0; cnt < 16; cnt++) {
3644 if (!(cnt % 16) && !IsTxReady(j)) {
3645 dly = 0;
3646 while (!IsTxReady(j)) {
3647 if (dly++ > 5) {
3648 dly = 0;
3649 break;
3650 }
3651 udelay(10);
3652 }
3653 }
3654 outb_p((blankword.low), j->DSPbase + 0x0C);
3655 outb_p((blankword.high), j->DSPbase + 0x0D);
3656 }
3657 j->flags.play_first_frame = 0;
3658 } else if (j->play_codec == G723_63 && j->flags.play_first_frame) {
3659 for (cnt = 0; cnt < 24; cnt++) {
3660 if(cnt == 12) {
3661 blankword.low = 0x02;
3662 blankword.high = 0x00;
3663 }
3664 else {
3665 blankword.low = blankword.high = 0x00;
3666 }
3667 if (!(cnt % 16) && !IsTxReady(j)) {
3668 dly = 0;
3669 while (!IsTxReady(j)) {
3670 if (dly++ > 5) {
3671 dly = 0;
3672 break;
3673 }
3674 udelay(10);
3675 }
3676 }
3677 outb_p((blankword.low), j->DSPbase + 0x0C);
3678 outb_p((blankword.high), j->DSPbase + 0x0D);
3679 }
3680 j->flags.play_first_frame = 0;
3681 }
3682 for (cnt = 0; cnt < j->play_frame_size * 2; cnt += 2) {
3683 if (!(cnt % 16) && !IsTxReady(j)) {
3684 dly = 0;
3685 while (!IsTxReady(j)) {
3686 if (dly++ > 5) {
3687 dly = 0;
3688 break;
3689 }
3690 udelay(10);
3691 }
3692 }
3693 /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */
3694 if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
3695 if(j->write_buffer_rp + cnt == 0 && j->write_buffer_rp + cnt + 1 == 0 && j->write_buffer_rp + cnt + 2 == 0 &&
3696 j->write_buffer_rp + cnt + 3 == 0 && j->write_buffer_rp + cnt + 4 == 0 && j->write_buffer_rp + cnt + 5 == 0 &&
3697 j->write_buffer_rp + cnt + 6 == 0 && j->write_buffer_rp + cnt + 7 == 0 && j->write_buffer_rp + cnt + 8 == 0 &&
3698 j->write_buffer_rp + cnt + 9 == 0) {
3699 /* someone is trying to write silence lets make this a type 0 frame. */
3700 outb_p(0x00, j->DSPbase + 0x0C);
3701 outb_p(0x00, j->DSPbase + 0x0D);
3702 } else {
3703 /* so all other frames are type 1. */
3704 outb_p(0x01, j->DSPbase + 0x0C);
3705 outb_p(0x00, j->DSPbase + 0x0D);
3706 }
3707 }
3708 outb_p(*(j->write_buffer_rp + cnt), j->DSPbase + 0x0C);
3709 outb_p(*(j->write_buffer_rp + cnt + 1), j->DSPbase + 0x0D);
3710 *(j->write_buffer_rp + cnt) = 0;
3711 *(j->write_buffer_rp + cnt + 1) = 0;
3712 }
3713 j->write_buffer_rp += j->play_frame_size * 2;
3714 if (j->write_buffer_rp >= j->write_buffer_end) {
3715 j->write_buffer_rp = j->write_buffer;
3716 }
3717 j->write_buffers_empty++;
3718 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
3719
3720 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
3721
3722 ++j->frameswritten;
3723 }
3724 } else {
3725 j->drybuffer++;
3726 }
3727 if(j->ixj_signals[SIG_WRITE_READY]) {
3728 ixj_kill_fasync(j, SIG_WRITE_READY, POLL_OUT);
3729 }
3730 }
3731
idle(IXJ * j)3732 static int idle(IXJ *j)
3733 {
3734 if (ixj_WriteDSPCommand(0x0000, j)) /* DSP Idle */
3735
3736 return 0;
3737
3738 if (j->ssr.high || j->ssr.low) {
3739 return 0;
3740 } else {
3741 j->play_mode = -1;
3742 j->flags.playing = 0;
3743 j->rec_mode = -1;
3744 j->flags.recording = 0;
3745 return 1;
3746 }
3747 }
3748
set_base_frame(IXJ * j,int size)3749 static int set_base_frame(IXJ *j, int size)
3750 {
3751 unsigned short cmd;
3752 int cnt;
3753
3754 idle(j);
3755 j->cid_play_aec_level = j->aec_level;
3756 aec_stop(j);
3757 for (cnt = 0; cnt < 10; cnt++) {
3758 if (idle(j))
3759 break;
3760 }
3761 if (j->ssr.high || j->ssr.low)
3762 return -1;
3763 if (j->dsp.low != 0x20) {
3764 switch (size) {
3765 case 30:
3766 cmd = 0x07F0;
3767 /* Set Base Frame Size to 240 pg9-10 8021 */
3768 break;
3769 case 20:
3770 cmd = 0x07A0;
3771 /* Set Base Frame Size to 160 pg9-10 8021 */
3772 break;
3773 case 10:
3774 cmd = 0x0750;
3775 /* Set Base Frame Size to 80 pg9-10 8021 */
3776 break;
3777 default:
3778 return -1;
3779 }
3780 } else {
3781 if (size == 30)
3782 return size;
3783 else
3784 return -1;
3785 }
3786 if (ixj_WriteDSPCommand(cmd, j)) {
3787 j->baseframe.high = j->baseframe.low = 0xFF;
3788 return -1;
3789 } else {
3790 j->baseframe.high = j->ssr.high;
3791 j->baseframe.low = j->ssr.low;
3792 /* If the status returned is 0x0000 (pg9-9 8021) the call failed */
3793 if(j->baseframe.high == 0x00 && j->baseframe.low == 0x00) {
3794 return -1;
3795 }
3796 }
3797 ixj_aec_start(j, j->cid_play_aec_level);
3798 return size;
3799 }
3800
set_rec_codec(IXJ * j,int rate)3801 static int set_rec_codec(IXJ *j, int rate)
3802 {
3803 int retval = 0;
3804
3805 j->rec_codec = rate;
3806
3807 switch (rate) {
3808 case G723_63:
3809 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3810 j->rec_frame_size = 12;
3811 j->rec_mode = 0;
3812 } else {
3813 retval = 1;
3814 }
3815 break;
3816 case G723_53:
3817 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3818 j->rec_frame_size = 10;
3819 j->rec_mode = 0;
3820 } else {
3821 retval = 1;
3822 }
3823 break;
3824 case TS85:
3825 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
3826 j->rec_frame_size = 16;
3827 j->rec_mode = 0;
3828 } else {
3829 retval = 1;
3830 }
3831 break;
3832 case TS48:
3833 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3834 j->rec_frame_size = 9;
3835 j->rec_mode = 0;
3836 } else {
3837 retval = 1;
3838 }
3839 break;
3840 case TS41:
3841 if (j->ver.low != 0x12 || ixj_convert_loaded) {
3842 j->rec_frame_size = 8;
3843 j->rec_mode = 0;
3844 } else {
3845 retval = 1;
3846 }
3847 break;
3848 case G728:
3849 if (j->dsp.low != 0x20) {
3850 j->rec_frame_size = 48;
3851 j->rec_mode = 0;
3852 } else {
3853 retval = 1;
3854 }
3855 break;
3856 case G729:
3857 if (j->dsp.low != 0x20) {
3858 if (!j->flags.g729_loaded) {
3859 retval = 1;
3860 break;
3861 }
3862 switch (j->baseframe.low) {
3863 case 0xA0:
3864 j->rec_frame_size = 10;
3865 break;
3866 case 0x50:
3867 j->rec_frame_size = 5;
3868 break;
3869 default:
3870 j->rec_frame_size = 15;
3871 break;
3872 }
3873 j->rec_mode = 0;
3874 } else {
3875 retval = 1;
3876 }
3877 break;
3878 case G729B:
3879 if (j->dsp.low != 0x20) {
3880 if (!j->flags.g729_loaded) {
3881 retval = 1;
3882 break;
3883 }
3884 switch (j->baseframe.low) {
3885 case 0xA0:
3886 j->rec_frame_size = 12;
3887 break;
3888 case 0x50:
3889 j->rec_frame_size = 6;
3890 break;
3891 default:
3892 j->rec_frame_size = 18;
3893 break;
3894 }
3895 j->rec_mode = 0;
3896 } else {
3897 retval = 1;
3898 }
3899 break;
3900 case ULAW:
3901 switch (j->baseframe.low) {
3902 case 0xA0:
3903 j->rec_frame_size = 80;
3904 break;
3905 case 0x50:
3906 j->rec_frame_size = 40;
3907 break;
3908 default:
3909 j->rec_frame_size = 120;
3910 break;
3911 }
3912 j->rec_mode = 4;
3913 break;
3914 case ALAW:
3915 switch (j->baseframe.low) {
3916 case 0xA0:
3917 j->rec_frame_size = 80;
3918 break;
3919 case 0x50:
3920 j->rec_frame_size = 40;
3921 break;
3922 default:
3923 j->rec_frame_size = 120;
3924 break;
3925 }
3926 j->rec_mode = 4;
3927 break;
3928 case LINEAR16:
3929 switch (j->baseframe.low) {
3930 case 0xA0:
3931 j->rec_frame_size = 160;
3932 break;
3933 case 0x50:
3934 j->rec_frame_size = 80;
3935 break;
3936 default:
3937 j->rec_frame_size = 240;
3938 break;
3939 }
3940 j->rec_mode = 5;
3941 break;
3942 case LINEAR8:
3943 switch (j->baseframe.low) {
3944 case 0xA0:
3945 j->rec_frame_size = 80;
3946 break;
3947 case 0x50:
3948 j->rec_frame_size = 40;
3949 break;
3950 default:
3951 j->rec_frame_size = 120;
3952 break;
3953 }
3954 j->rec_mode = 6;
3955 break;
3956 case WSS:
3957 switch (j->baseframe.low) {
3958 case 0xA0:
3959 j->rec_frame_size = 80;
3960 break;
3961 case 0x50:
3962 j->rec_frame_size = 40;
3963 break;
3964 default:
3965 j->rec_frame_size = 120;
3966 break;
3967 }
3968 j->rec_mode = 7;
3969 break;
3970 default:
3971 j->rec_frame_size = 0;
3972 j->rec_mode = -1;
3973 if (j->read_buffer) {
3974 kfree(j->read_buffer);
3975 j->read_buffer = NULL;
3976 j->read_buffer_size = 0;
3977 }
3978 retval = 1;
3979 break;
3980 }
3981 return retval;
3982 }
3983
ixj_record_start(IXJ * j)3984 static int ixj_record_start(IXJ *j)
3985 {
3986 unsigned short cmd = 0x0000;
3987
3988 if (j->read_buffer) {
3989 ixj_record_stop(j);
3990 }
3991 j->flags.recording = 1;
3992 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
3993
3994 if(ixjdebug & 0x0002)
3995 printk("IXJ %d Starting Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
3996
3997 if (!j->rec_mode) {
3998 switch (j->rec_codec) {
3999 case G723_63:
4000 cmd = 0x5131;
4001 break;
4002 case G723_53:
4003 cmd = 0x5132;
4004 break;
4005 case TS85:
4006 cmd = 0x5130; /* TrueSpeech 8.5 */
4007
4008 break;
4009 case TS48:
4010 cmd = 0x5133; /* TrueSpeech 4.8 */
4011
4012 break;
4013 case TS41:
4014 cmd = 0x5134; /* TrueSpeech 4.1 */
4015
4016 break;
4017 case G728:
4018 cmd = 0x5135;
4019 break;
4020 case G729:
4021 case G729B:
4022 cmd = 0x5136;
4023 break;
4024 default:
4025 return 1;
4026 }
4027 if (ixj_WriteDSPCommand(cmd, j))
4028 return -1;
4029 }
4030 if (!j->read_buffer) {
4031 if (!j->read_buffer)
4032 j->read_buffer = kmalloc(j->rec_frame_size * 2, GFP_ATOMIC);
4033 if (!j->read_buffer) {
4034 printk("Read buffer allocation for ixj board %d failed!\n", j->board);
4035 return -ENOMEM;
4036 }
4037 }
4038 j->read_buffer_size = j->rec_frame_size * 2;
4039
4040 if (ixj_WriteDSPCommand(0x5102, j)) /* Set Poll sync mode */
4041
4042 return -1;
4043
4044 switch (j->rec_mode) {
4045 case 0:
4046 cmd = 0x1C03; /* Record C1 */
4047
4048 break;
4049 case 4:
4050 if (j->ver.low == 0x12) {
4051 cmd = 0x1E03; /* Record C1 */
4052
4053 } else {
4054 cmd = 0x1E01; /* Record C1 */
4055
4056 }
4057 break;
4058 case 5:
4059 if (j->ver.low == 0x12) {
4060 cmd = 0x1E83; /* Record C1 */
4061
4062 } else {
4063 cmd = 0x1E81; /* Record C1 */
4064
4065 }
4066 break;
4067 case 6:
4068 if (j->ver.low == 0x12) {
4069 cmd = 0x1F03; /* Record C1 */
4070
4071 } else {
4072 cmd = 0x1F01; /* Record C1 */
4073
4074 }
4075 break;
4076 case 7:
4077 if (j->ver.low == 0x12) {
4078 cmd = 0x1F83; /* Record C1 */
4079 } else {
4080 cmd = 0x1F81; /* Record C1 */
4081 }
4082 break;
4083 }
4084 if (ixj_WriteDSPCommand(cmd, j))
4085 return -1;
4086
4087 if (j->flags.playing) {
4088 ixj_aec_start(j, j->aec_level);
4089 }
4090 return 0;
4091 }
4092
ixj_record_stop(IXJ * j)4093 static void ixj_record_stop(IXJ *j)
4094 {
4095 if(ixjdebug & 0x0002)
4096 printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
4097
4098 if (j->read_buffer) {
4099 kfree(j->read_buffer);
4100 j->read_buffer = NULL;
4101 j->read_buffer_size = 0;
4102 }
4103 if (j->rec_mode > -1) {
4104 ixj_WriteDSPCommand(0x5120, j);
4105 j->rec_mode = -1;
4106 }
4107 j->flags.recording = 0;
4108 }
ixj_vad(IXJ * j,int arg)4109 static void ixj_vad(IXJ *j, int arg)
4110 {
4111 if (arg)
4112 ixj_WriteDSPCommand(0x513F, j);
4113 else
4114 ixj_WriteDSPCommand(0x513E, j);
4115 }
4116
set_rec_depth(IXJ * j,int depth)4117 static void set_rec_depth(IXJ *j, int depth)
4118 {
4119 if (depth > 60)
4120 depth = 60;
4121 if (depth < 0)
4122 depth = 0;
4123 ixj_WriteDSPCommand(0x5180 + depth, j);
4124 }
4125
set_dtmf_prescale(IXJ * j,int volume)4126 static void set_dtmf_prescale(IXJ *j, int volume)
4127 {
4128 ixj_WriteDSPCommand(0xCF07, j);
4129 ixj_WriteDSPCommand(volume, j);
4130 }
4131
get_dtmf_prescale(IXJ * j)4132 static int get_dtmf_prescale(IXJ *j)
4133 {
4134 ixj_WriteDSPCommand(0xCF05, j);
4135 return j->ssr.high << 8 | j->ssr.low;
4136 }
4137
set_rec_volume(IXJ * j,int volume)4138 static void set_rec_volume(IXJ *j, int volume)
4139 {
4140 if(j->aec_level == AEC_AGC) {
4141 if (ixjdebug & 0x0002)
4142 printk(KERN_INFO "IXJ: /dev/phone%d Setting AGC Threshold to 0x%4.4x\n", j->board, volume);
4143 ixj_WriteDSPCommand(0xCF96, j);
4144 ixj_WriteDSPCommand(volume, j);
4145 } else {
4146 if (ixjdebug & 0x0002)
4147 printk(KERN_INFO "IXJ: /dev/phone %d Setting Record Volume to 0x%4.4x\n", j->board, volume);
4148 ixj_WriteDSPCommand(0xCF03, j);
4149 ixj_WriteDSPCommand(volume, j);
4150 }
4151 }
4152
set_rec_volume_linear(IXJ * j,int volume)4153 static int set_rec_volume_linear(IXJ *j, int volume)
4154 {
4155 int newvolume, dsprecmax;
4156
4157 if (ixjdebug & 0x0002)
4158 printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Record Volume to 0x%4.4x\n", j->board, volume);
4159 if(volume > 100 || volume < 0) {
4160 return -1;
4161 }
4162
4163 /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */
4164 switch (j->cardtype) {
4165 case QTI_PHONEJACK:
4166 dsprecmax = 0x440;
4167 break;
4168 case QTI_LINEJACK:
4169 dsprecmax = 0x180;
4170 ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
4171 ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
4172 ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
4173 break;
4174 case QTI_PHONEJACK_LITE:
4175 dsprecmax = 0x4C0;
4176 break;
4177 case QTI_PHONEJACK_PCI:
4178 dsprecmax = 0x100;
4179 break;
4180 case QTI_PHONECARD:
4181 dsprecmax = 0x400;
4182 break;
4183 default:
4184 return -1;
4185 }
4186 newvolume = (dsprecmax * volume) / 100;
4187 set_rec_volume(j, newvolume);
4188 return 0;
4189 }
4190
get_rec_volume(IXJ * j)4191 static int get_rec_volume(IXJ *j)
4192 {
4193 if(j->aec_level == AEC_AGC) {
4194 if (ixjdebug & 0x0002)
4195 printk(KERN_INFO "Getting AGC Threshold\n");
4196 ixj_WriteDSPCommand(0xCF86, j);
4197 if (ixjdebug & 0x0002)
4198 printk(KERN_INFO "AGC Threshold is 0x%2.2x%2.2x\n", j->ssr.high, j->ssr.low);
4199 return j->ssr.high << 8 | j->ssr.low;
4200 } else {
4201 if (ixjdebug & 0x0002)
4202 printk(KERN_INFO "Getting Record Volume\n");
4203 ixj_WriteDSPCommand(0xCF01, j);
4204 return j->ssr.high << 8 | j->ssr.low;
4205 }
4206 }
4207
get_rec_volume_linear(IXJ * j)4208 static int get_rec_volume_linear(IXJ *j)
4209 {
4210 int volume, newvolume, dsprecmax;
4211
4212 switch (j->cardtype) {
4213 case QTI_PHONEJACK:
4214 dsprecmax = 0x440;
4215 break;
4216 case QTI_LINEJACK:
4217 dsprecmax = 0x180;
4218 break;
4219 case QTI_PHONEJACK_LITE:
4220 dsprecmax = 0x4C0;
4221 break;
4222 case QTI_PHONEJACK_PCI:
4223 dsprecmax = 0x100;
4224 break;
4225 case QTI_PHONECARD:
4226 dsprecmax = 0x400;
4227 break;
4228 default:
4229 return -1;
4230 }
4231 volume = get_rec_volume(j);
4232 newvolume = (volume * 100) / dsprecmax;
4233 if(newvolume > 100)
4234 newvolume = 100;
4235 return newvolume;
4236 }
4237
get_rec_level(IXJ * j)4238 static int get_rec_level(IXJ *j)
4239 {
4240 int retval;
4241
4242 ixj_WriteDSPCommand(0xCF88, j);
4243
4244 retval = j->ssr.high << 8 | j->ssr.low;
4245 retval = (retval * 256) / 240;
4246 return retval;
4247 }
4248
ixj_aec_start(IXJ * j,int level)4249 static void ixj_aec_start(IXJ *j, int level)
4250 {
4251 j->aec_level = level;
4252 if (ixjdebug & 0x0002)
4253 printk(KERN_INFO "AGC set = 0x%2.2x\n", j->aec_level);
4254 if (!level) {
4255 aec_stop(j);
4256 } else {
4257 if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
4258 ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer */
4259
4260 ixj_WriteDSPCommand(0x0300, j);
4261 }
4262 ixj_WriteDSPCommand(0xB001, j); /* AEC On */
4263
4264 ixj_WriteDSPCommand(0xE013, j); /* Advanced AEC C1 */
4265
4266 switch (level) {
4267 case AEC_LOW:
4268 ixj_WriteDSPCommand(0x0000, j); /* Advanced AEC C2 = off */
4269
4270 ixj_WriteDSPCommand(0xE011, j);
4271 ixj_WriteDSPCommand(0xFFFF, j);
4272
4273 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4274 ixj_WriteDSPCommand(0x0000, j); /* to off */
4275
4276 break;
4277
4278 case AEC_MED:
4279 ixj_WriteDSPCommand(0x0600, j); /* Advanced AEC C2 = on medium */
4280
4281 ixj_WriteDSPCommand(0xE011, j);
4282 ixj_WriteDSPCommand(0x0080, j);
4283
4284 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4285 ixj_WriteDSPCommand(0x0000, j); /* to off */
4286
4287 break;
4288
4289 case AEC_HIGH:
4290 ixj_WriteDSPCommand(0x0C00, j); /* Advanced AEC C2 = on high */
4291
4292 ixj_WriteDSPCommand(0xE011, j);
4293 ixj_WriteDSPCommand(0x0080, j);
4294
4295 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4296 ixj_WriteDSPCommand(0x0000, j); /* to off */
4297
4298 break;
4299
4300 case AEC_AGC:
4301 /* First we have to put the AEC into advance auto mode so that AGC will not conflict with it */
4302 ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
4303
4304 ixj_WriteDSPCommand(0xE011, j);
4305 ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
4306
4307 ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
4308
4309 if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
4310 ixj_WriteDSPCommand(0x0224, j);
4311 else
4312 ixj_WriteDSPCommand(0x1224, j);
4313
4314 ixj_WriteDSPCommand(0xE014, j);
4315 ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */
4316
4317 ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
4318
4319 /* Now we can set the AGC initial parameters and turn it on */
4320 ixj_WriteDSPCommand(0xCF90, j); /* Set AGC Minumum gain */
4321 ixj_WriteDSPCommand(0x0020, j); /* to 0.125 (-18dB) */
4322
4323 ixj_WriteDSPCommand(0xCF91, j); /* Set AGC Maximum gain */
4324 ixj_WriteDSPCommand(0x1000, j); /* to 16 (24dB) */
4325
4326 ixj_WriteDSPCommand(0xCF92, j); /* Set AGC start gain */
4327 ixj_WriteDSPCommand(0x0800, j); /* to 8 (+18dB) */
4328
4329 ixj_WriteDSPCommand(0xCF93, j); /* Set AGC hold time */
4330 ixj_WriteDSPCommand(0x1F40, j); /* to 2 seconds (units are 250us) */
4331
4332 ixj_WriteDSPCommand(0xCF94, j); /* Set AGC Attack Time Constant */
4333 ixj_WriteDSPCommand(0x0005, j); /* to 8ms */
4334
4335 ixj_WriteDSPCommand(0xCF95, j); /* Set AGC Decay Time Constant */
4336 ixj_WriteDSPCommand(0x000D, j); /* to 4096ms */
4337
4338 ixj_WriteDSPCommand(0xCF96, j); /* Set AGC Attack Threshold */
4339 ixj_WriteDSPCommand(0x1200, j); /* to 25% */
4340
4341 ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
4342 ixj_WriteDSPCommand(0x0001, j); /* to on */
4343
4344 break;
4345
4346 case AEC_AUTO:
4347 ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */
4348
4349 ixj_WriteDSPCommand(0xE011, j);
4350 ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */
4351
4352 ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */
4353
4354 if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD)
4355 ixj_WriteDSPCommand(0x0224, j);
4356 else
4357 ixj_WriteDSPCommand(0x1224, j);
4358
4359 ixj_WriteDSPCommand(0xE014, j);
4360 ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */
4361
4362 ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */
4363
4364 break;
4365 }
4366 }
4367 }
4368
aec_stop(IXJ * j)4369 static void aec_stop(IXJ *j)
4370 {
4371 j->aec_level = AEC_OFF;
4372 if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) {
4373 ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer back */
4374
4375 ixj_WriteDSPCommand(0x0700, j);
4376 }
4377 if (j->play_mode != -1 && j->rec_mode != -1)
4378 {
4379 ixj_WriteDSPCommand(0xB002, j); /* AEC Stop */
4380 }
4381 }
4382
set_play_codec(IXJ * j,int rate)4383 static int set_play_codec(IXJ *j, int rate)
4384 {
4385 int retval = 0;
4386
4387 j->play_codec = rate;
4388
4389 switch (rate) {
4390 case G723_63:
4391 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4392 j->play_frame_size = 12;
4393 j->play_mode = 0;
4394 } else {
4395 retval = 1;
4396 }
4397 break;
4398 case G723_53:
4399 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4400 j->play_frame_size = 10;
4401 j->play_mode = 0;
4402 } else {
4403 retval = 1;
4404 }
4405 break;
4406 case TS85:
4407 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
4408 j->play_frame_size = 16;
4409 j->play_mode = 0;
4410 } else {
4411 retval = 1;
4412 }
4413 break;
4414 case TS48:
4415 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4416 j->play_frame_size = 9;
4417 j->play_mode = 0;
4418 } else {
4419 retval = 1;
4420 }
4421 break;
4422 case TS41:
4423 if (j->ver.low != 0x12 || ixj_convert_loaded) {
4424 j->play_frame_size = 8;
4425 j->play_mode = 0;
4426 } else {
4427 retval = 1;
4428 }
4429 break;
4430 case G728:
4431 if (j->dsp.low != 0x20) {
4432 j->play_frame_size = 48;
4433 j->play_mode = 0;
4434 } else {
4435 retval = 1;
4436 }
4437 break;
4438 case G729:
4439 if (j->dsp.low != 0x20) {
4440 if (!j->flags.g729_loaded) {
4441 retval = 1;
4442 break;
4443 }
4444 switch (j->baseframe.low) {
4445 case 0xA0:
4446 j->play_frame_size = 10;
4447 break;
4448 case 0x50:
4449 j->play_frame_size = 5;
4450 break;
4451 default:
4452 j->play_frame_size = 15;
4453 break;
4454 }
4455 j->play_mode = 0;
4456 } else {
4457 retval = 1;
4458 }
4459 break;
4460 case G729B:
4461 if (j->dsp.low != 0x20) {
4462 if (!j->flags.g729_loaded) {
4463 retval = 1;
4464 break;
4465 }
4466 switch (j->baseframe.low) {
4467 case 0xA0:
4468 j->play_frame_size = 12;
4469 break;
4470 case 0x50:
4471 j->play_frame_size = 6;
4472 break;
4473 default:
4474 j->play_frame_size = 18;
4475 break;
4476 }
4477 j->play_mode = 0;
4478 } else {
4479 retval = 1;
4480 }
4481 break;
4482 case ULAW:
4483 switch (j->baseframe.low) {
4484 case 0xA0:
4485 j->play_frame_size = 80;
4486 break;
4487 case 0x50:
4488 j->play_frame_size = 40;
4489 break;
4490 default:
4491 j->play_frame_size = 120;
4492 break;
4493 }
4494 j->play_mode = 2;
4495 break;
4496 case ALAW:
4497 switch (j->baseframe.low) {
4498 case 0xA0:
4499 j->play_frame_size = 80;
4500 break;
4501 case 0x50:
4502 j->play_frame_size = 40;
4503 break;
4504 default:
4505 j->play_frame_size = 120;
4506 break;
4507 }
4508 j->play_mode = 2;
4509 break;
4510 case LINEAR16:
4511 switch (j->baseframe.low) {
4512 case 0xA0:
4513 j->play_frame_size = 160;
4514 break;
4515 case 0x50:
4516 j->play_frame_size = 80;
4517 break;
4518 default:
4519 j->play_frame_size = 240;
4520 break;
4521 }
4522 j->play_mode = 6;
4523 break;
4524 case LINEAR8:
4525 switch (j->baseframe.low) {
4526 case 0xA0:
4527 j->play_frame_size = 80;
4528 break;
4529 case 0x50:
4530 j->play_frame_size = 40;
4531 break;
4532 default:
4533 j->play_frame_size = 120;
4534 break;
4535 }
4536 j->play_mode = 4;
4537 break;
4538 case WSS:
4539 switch (j->baseframe.low) {
4540 case 0xA0:
4541 j->play_frame_size = 80;
4542 break;
4543 case 0x50:
4544 j->play_frame_size = 40;
4545 break;
4546 default:
4547 j->play_frame_size = 120;
4548 break;
4549 }
4550 j->play_mode = 5;
4551 break;
4552 default:
4553 j->play_frame_size = 0;
4554 j->play_mode = -1;
4555 if (j->write_buffer) {
4556 kfree(j->write_buffer);
4557 j->write_buffer = NULL;
4558 j->write_buffer_size = 0;
4559 }
4560 retval = 1;
4561 break;
4562 }
4563 return retval;
4564 }
4565
ixj_play_start(IXJ * j)4566 static int ixj_play_start(IXJ *j)
4567 {
4568 unsigned short cmd = 0x0000;
4569
4570 if (j->write_buffer) {
4571 ixj_play_stop(j);
4572 }
4573
4574 if(ixjdebug & 0x0002)
4575 printk("IXJ %d Starting Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
4576
4577 j->flags.playing = 1;
4578 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
4579
4580 j->flags.play_first_frame = 1;
4581 j->drybuffer = 0;
4582
4583 if (!j->play_mode) {
4584 switch (j->play_codec) {
4585 case G723_63:
4586 cmd = 0x5231;
4587 break;
4588 case G723_53:
4589 cmd = 0x5232;
4590 break;
4591 case TS85:
4592 cmd = 0x5230; /* TrueSpeech 8.5 */
4593
4594 break;
4595 case TS48:
4596 cmd = 0x5233; /* TrueSpeech 4.8 */
4597
4598 break;
4599 case TS41:
4600 cmd = 0x5234; /* TrueSpeech 4.1 */
4601
4602 break;
4603 case G728:
4604 cmd = 0x5235;
4605 break;
4606 case G729:
4607 case G729B:
4608 cmd = 0x5236;
4609 break;
4610 default:
4611 return 1;
4612 }
4613 if (ixj_WriteDSPCommand(cmd, j))
4614 return -1;
4615 }
4616 j->write_buffer = kmalloc(j->play_frame_size * 2, GFP_ATOMIC);
4617 if (!j->write_buffer) {
4618 printk("Write buffer allocation for ixj board %d failed!\n", j->board);
4619 return -ENOMEM;
4620 }
4621 /* j->write_buffers_empty = 2; */
4622 j->write_buffers_empty = 1;
4623 j->write_buffer_size = j->play_frame_size * 2;
4624 j->write_buffer_end = j->write_buffer + j->play_frame_size * 2;
4625 j->write_buffer_rp = j->write_buffer_wp = j->write_buffer;
4626
4627 if (ixj_WriteDSPCommand(0x5202, j)) /* Set Poll sync mode */
4628
4629 return -1;
4630
4631 switch (j->play_mode) {
4632 case 0:
4633 cmd = 0x2C03;
4634 break;
4635 case 2:
4636 if (j->ver.low == 0x12) {
4637 cmd = 0x2C23;
4638 } else {
4639 cmd = 0x2C21;
4640 }
4641 break;
4642 case 4:
4643 if (j->ver.low == 0x12) {
4644 cmd = 0x2C43;
4645 } else {
4646 cmd = 0x2C41;
4647 }
4648 break;
4649 case 5:
4650 if (j->ver.low == 0x12) {
4651 cmd = 0x2C53;
4652 } else {
4653 cmd = 0x2C51;
4654 }
4655 break;
4656 case 6:
4657 if (j->ver.low == 0x12) {
4658 cmd = 0x2C63;
4659 } else {
4660 cmd = 0x2C61;
4661 }
4662 break;
4663 }
4664 if (ixj_WriteDSPCommand(cmd, j))
4665 return -1;
4666
4667 if (ixj_WriteDSPCommand(0x2000, j)) /* Playback C2 */
4668 return -1;
4669
4670 if (ixj_WriteDSPCommand(0x2000 + j->play_frame_size, j)) /* Playback C3 */
4671 return -1;
4672
4673 if (j->flags.recording) {
4674 ixj_aec_start(j, j->aec_level);
4675 }
4676
4677 return 0;
4678 }
4679
ixj_play_stop(IXJ * j)4680 static void ixj_play_stop(IXJ *j)
4681 {
4682 if(ixjdebug & 0x0002)
4683 printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
4684
4685 if (j->write_buffer) {
4686 kfree(j->write_buffer);
4687 j->write_buffer = NULL;
4688 j->write_buffer_size = 0;
4689 }
4690 if (j->play_mode > -1) {
4691 ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */
4692
4693 j->play_mode = -1;
4694 }
4695 j->flags.playing = 0;
4696 }
4697
get_play_level(IXJ * j)4698 static inline int get_play_level(IXJ *j)
4699 {
4700 int retval;
4701
4702 ixj_WriteDSPCommand(0xCF8F, j); /* 8022 Reference page 9-38 */
4703 return j->ssr.high << 8 | j->ssr.low;
4704 retval = j->ssr.high << 8 | j->ssr.low;
4705 retval = (retval * 256) / 240;
4706 return retval;
4707 }
4708
ixj_poll(struct file * file_p,poll_table * wait)4709 static unsigned int ixj_poll(struct file *file_p, poll_table * wait)
4710 {
4711 unsigned int mask = 0;
4712
4713 IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
4714
4715 poll_wait(file_p, &(j->poll_q), wait);
4716 if (j->read_buffer_ready > 0)
4717 mask |= POLLIN | POLLRDNORM; /* readable */
4718 if (j->write_buffers_empty > 0)
4719 mask |= POLLOUT | POLLWRNORM; /* writable */
4720 if (j->ex.bytes)
4721 mask |= POLLPRI;
4722 return mask;
4723 }
4724
ixj_play_tone(IXJ * j,char tone)4725 static int ixj_play_tone(IXJ *j, char tone)
4726 {
4727 if (!j->tone_state) {
4728 if(ixjdebug & 0x0002) {
4729 printk("IXJ %d starting tone %d at %ld\n", j->board, tone, jiffies);
4730 }
4731 if (j->dsp.low == 0x20) {
4732 idle(j);
4733 }
4734 j->tone_start_jif = jiffies;
4735
4736 j->tone_state = 1;
4737 }
4738
4739 j->tone_index = tone;
4740 if (ixj_WriteDSPCommand(0x6000 + j->tone_index, j))
4741 return -1;
4742
4743 return 0;
4744 }
4745
ixj_set_tone_on(unsigned short arg,IXJ * j)4746 static int ixj_set_tone_on(unsigned short arg, IXJ *j)
4747 {
4748 j->tone_on_time = arg;
4749
4750 if (ixj_WriteDSPCommand(0x6E04, j)) /* Set Tone On Period */
4751
4752 return -1;
4753
4754 if (ixj_WriteDSPCommand(arg, j))
4755 return -1;
4756
4757 return 0;
4758 }
4759
SCI_WaitHighSCI(IXJ * j)4760 static int SCI_WaitHighSCI(IXJ *j)
4761 {
4762 int cnt;
4763
4764 j->pld_scrr.byte = inb_p(j->XILINXbase);
4765 if (!j->pld_scrr.bits.sci) {
4766 for (cnt = 0; cnt < 10; cnt++) {
4767 udelay(32);
4768 j->pld_scrr.byte = inb_p(j->XILINXbase);
4769
4770 if ((j->pld_scrr.bits.sci))
4771 return 1;
4772 }
4773 if (ixjdebug & 0x0001)
4774 printk(KERN_INFO "SCI Wait High failed %x\n", j->pld_scrr.byte);
4775 return 0;
4776 } else
4777 return 1;
4778 }
4779
SCI_WaitLowSCI(IXJ * j)4780 static int SCI_WaitLowSCI(IXJ *j)
4781 {
4782 int cnt;
4783
4784 j->pld_scrr.byte = inb_p(j->XILINXbase);
4785 if (j->pld_scrr.bits.sci) {
4786 for (cnt = 0; cnt < 10; cnt++) {
4787 udelay(32);
4788 j->pld_scrr.byte = inb_p(j->XILINXbase);
4789
4790 if (!(j->pld_scrr.bits.sci))
4791 return 1;
4792 }
4793 if (ixjdebug & 0x0001)
4794 printk(KERN_INFO "SCI Wait Low failed %x\n", j->pld_scrr.byte);
4795 return 0;
4796 } else
4797 return 1;
4798 }
4799
SCI_Control(IXJ * j,int control)4800 static int SCI_Control(IXJ *j, int control)
4801 {
4802 switch (control) {
4803 case SCI_End:
4804 j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
4805
4806 j->pld_scrw.bits.c1 = 0; /* to no selection */
4807
4808 break;
4809 case SCI_Enable_DAA:
4810 j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
4811
4812 j->pld_scrw.bits.c1 = 0; /* to write to DAA */
4813
4814 break;
4815 case SCI_Enable_Mixer:
4816 j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */
4817
4818 j->pld_scrw.bits.c1 = 1; /* to write to mixer */
4819
4820 break;
4821 case SCI_Enable_EEPROM:
4822 j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */
4823
4824 j->pld_scrw.bits.c1 = 1; /* to write to EEPROM */
4825
4826 break;
4827 default:
4828 return 0;
4829 break;
4830 }
4831 outb_p(j->pld_scrw.byte, j->XILINXbase);
4832
4833 switch (control) {
4834 case SCI_End:
4835 return 1;
4836 break;
4837 case SCI_Enable_DAA:
4838 case SCI_Enable_Mixer:
4839 case SCI_Enable_EEPROM:
4840 if (!SCI_WaitHighSCI(j))
4841 return 0;
4842 break;
4843 default:
4844 return 0;
4845 break;
4846 }
4847 return 1;
4848 }
4849
SCI_Prepare(IXJ * j)4850 static int SCI_Prepare(IXJ *j)
4851 {
4852 if (!SCI_Control(j, SCI_End))
4853 return 0;
4854
4855 if (!SCI_WaitLowSCI(j))
4856 return 0;
4857
4858 return 1;
4859 }
4860
ixj_get_mixer(long val,IXJ * j)4861 static int ixj_get_mixer(long val, IXJ *j)
4862 {
4863 int reg = (val & 0x1F00) >> 8;
4864 return j->mix.vol[reg];
4865 }
4866
ixj_mixer(long val,IXJ * j)4867 static int ixj_mixer(long val, IXJ *j)
4868 {
4869 BYTES bytes;
4870
4871 bytes.high = (val & 0x1F00) >> 8;
4872 bytes.low = val & 0x00FF;
4873
4874 /* save mixer value so we can get back later on */
4875 j->mix.vol[bytes.high] = bytes.low;
4876
4877 outb_p(bytes.high & 0x1F, j->XILINXbase + 0x03); /* Load Mixer Address */
4878
4879 outb_p(bytes.low, j->XILINXbase + 0x02); /* Load Mixer Data */
4880
4881 SCI_Control(j, SCI_Enable_Mixer);
4882
4883 SCI_Control(j, SCI_End);
4884
4885 return 0;
4886 }
4887
daa_load(BYTES * p_bytes,IXJ * j)4888 static int daa_load(BYTES * p_bytes, IXJ *j)
4889 {
4890 outb_p(p_bytes->high, j->XILINXbase + 0x03);
4891 outb_p(p_bytes->low, j->XILINXbase + 0x02);
4892 if (!SCI_Control(j, SCI_Enable_DAA))
4893 return 0;
4894 else
4895 return 1;
4896 }
4897
ixj_daa_cr4(IXJ * j,char reg)4898 static int ixj_daa_cr4(IXJ *j, char reg)
4899 {
4900 BYTES bytes;
4901
4902 switch (j->daa_mode) {
4903 case SOP_PU_SLEEP:
4904 bytes.high = 0x14;
4905 break;
4906 case SOP_PU_RINGING:
4907 bytes.high = 0x54;
4908 break;
4909 case SOP_PU_CONVERSATION:
4910 bytes.high = 0x94;
4911 break;
4912 case SOP_PU_PULSEDIALING:
4913 bytes.high = 0xD4;
4914 break;
4915 }
4916
4917 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = reg;
4918
4919 switch (j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGX) {
4920 case 0:
4921 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 0;
4922 break;
4923 case 1:
4924 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 2;
4925 break;
4926 case 2:
4927 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 1;
4928 break;
4929 case 3:
4930 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 3;
4931 break;
4932 }
4933
4934 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
4935
4936 if (!daa_load(&bytes, j))
4937 return 0;
4938
4939 if (!SCI_Prepare(j))
4940 return 0;
4941
4942 return 1;
4943 }
4944
daa_int_read(IXJ * j)4945 static char daa_int_read(IXJ *j)
4946 {
4947 BYTES bytes;
4948
4949 if (!SCI_Prepare(j))
4950 return 0;
4951
4952 bytes.high = 0x38;
4953 bytes.low = 0x00;
4954 outb_p(bytes.high, j->XILINXbase + 0x03);
4955 outb_p(bytes.low, j->XILINXbase + 0x02);
4956
4957 if (!SCI_Control(j, SCI_Enable_DAA))
4958 return 0;
4959
4960 bytes.high = inb_p(j->XILINXbase + 0x03);
4961 bytes.low = inb_p(j->XILINXbase + 0x02);
4962 if (bytes.low != ALISDAA_ID_BYTE) {
4963 if (ixjdebug & 0x0001)
4964 printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
4965 return 0;
4966 }
4967 if (!SCI_Control(j, SCI_Enable_DAA))
4968 return 0;
4969 if (!SCI_Control(j, SCI_End))
4970 return 0;
4971
4972 bytes.high = inb_p(j->XILINXbase + 0x03);
4973 bytes.low = inb_p(j->XILINXbase + 0x02);
4974
4975 j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg = bytes.high;
4976
4977 return 1;
4978 }
4979
daa_CR_read(IXJ * j,int cr)4980 static char daa_CR_read(IXJ *j, int cr)
4981 {
4982 IXJ_WORD wdata;
4983 BYTES bytes;
4984
4985 if (!SCI_Prepare(j))
4986 return 0;
4987
4988 switch (j->daa_mode) {
4989 case SOP_PU_SLEEP:
4990 bytes.high = 0x30 + cr;
4991 break;
4992 case SOP_PU_RINGING:
4993 bytes.high = 0x70 + cr;
4994 break;
4995 case SOP_PU_CONVERSATION:
4996 bytes.high = 0xB0 + cr;
4997 break;
4998 case SOP_PU_PULSEDIALING:
4999 bytes.high = 0xF0 + cr;
5000 break;
5001 }
5002
5003 bytes.low = 0x00;
5004
5005 outb_p(bytes.high, j->XILINXbase + 0x03);
5006 outb_p(bytes.low, j->XILINXbase + 0x02);
5007
5008 if (!SCI_Control(j, SCI_Enable_DAA))
5009 return 0;
5010
5011 bytes.high = inb_p(j->XILINXbase + 0x03);
5012 bytes.low = inb_p(j->XILINXbase + 0x02);
5013 if (bytes.low != ALISDAA_ID_BYTE) {
5014 if (ixjdebug & 0x0001)
5015 printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
5016 return 0;
5017 }
5018 if (!SCI_Control(j, SCI_Enable_DAA))
5019 return 0;
5020 if (!SCI_Control(j, SCI_End))
5021 return 0;
5022
5023 wdata.word = inw_p(j->XILINXbase + 0x02);
5024
5025 switch(cr){
5026 case 5:
5027 j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = wdata.bytes.high;
5028 break;
5029 case 4:
5030 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = wdata.bytes.high;
5031 break;
5032 case 3:
5033 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = wdata.bytes.high;
5034 break;
5035 case 2:
5036 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = wdata.bytes.high;
5037 break;
5038 case 1:
5039 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = wdata.bytes.high;
5040 break;
5041 case 0:
5042 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = wdata.bytes.high;
5043 break;
5044 default:
5045 return 0;
5046 }
5047 return 1;
5048 }
5049
ixj_daa_cid_reset(IXJ * j)5050 static int ixj_daa_cid_reset(IXJ *j)
5051 {
5052 int i;
5053 BYTES bytes;
5054
5055 if (ixjdebug & 0x0002)
5056 printk("DAA Clearing CID ram\n");
5057
5058 if (!SCI_Prepare(j))
5059 return 0;
5060
5061 bytes.high = 0x58;
5062 bytes.low = 0x00;
5063 outb_p(bytes.high, j->XILINXbase + 0x03);
5064 outb_p(bytes.low, j->XILINXbase + 0x02);
5065
5066 if (!SCI_Control(j, SCI_Enable_DAA))
5067 return 0;
5068
5069 if (!SCI_WaitHighSCI(j))
5070 return 0;
5071
5072 for (i = 0; i < ALISDAA_CALLERID_SIZE - 1; i += 2) {
5073 bytes.high = bytes.low = 0x00;
5074 outb_p(bytes.high, j->XILINXbase + 0x03);
5075
5076 if (i < ALISDAA_CALLERID_SIZE - 1)
5077 outb_p(bytes.low, j->XILINXbase + 0x02);
5078
5079 if (!SCI_Control(j, SCI_Enable_DAA))
5080 return 0;
5081
5082 if (!SCI_WaitHighSCI(j))
5083 return 0;
5084
5085 }
5086
5087 if (!SCI_Control(j, SCI_End))
5088 return 0;
5089
5090 if (ixjdebug & 0x0002)
5091 printk("DAA CID ram cleared\n");
5092
5093 return 1;
5094 }
5095
ixj_daa_cid_read(IXJ * j)5096 static int ixj_daa_cid_read(IXJ *j)
5097 {
5098 int i;
5099 BYTES bytes;
5100 char CID[ALISDAA_CALLERID_SIZE], mContinue;
5101 char *pIn, *pOut;
5102
5103 if (!SCI_Prepare(j))
5104 return 0;
5105
5106 bytes.high = 0x78;
5107 bytes.low = 0x00;
5108 outb_p(bytes.high, j->XILINXbase + 0x03);
5109 outb_p(bytes.low, j->XILINXbase + 0x02);
5110
5111 if (!SCI_Control(j, SCI_Enable_DAA))
5112 return 0;
5113
5114 if (!SCI_WaitHighSCI(j))
5115 return 0;
5116
5117 bytes.high = inb_p(j->XILINXbase + 0x03);
5118 bytes.low = inb_p(j->XILINXbase + 0x02);
5119 if (bytes.low != ALISDAA_ID_BYTE) {
5120 if (ixjdebug & 0x0001)
5121 printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
5122 return 0;
5123 }
5124 for (i = 0; i < ALISDAA_CALLERID_SIZE; i += 2) {
5125 bytes.high = bytes.low = 0x00;
5126 outb_p(bytes.high, j->XILINXbase + 0x03);
5127 outb_p(bytes.low, j->XILINXbase + 0x02);
5128
5129 if (!SCI_Control(j, SCI_Enable_DAA))
5130 return 0;
5131
5132 if (!SCI_WaitHighSCI(j))
5133 return 0;
5134
5135 CID[i + 0] = inb_p(j->XILINXbase + 0x03);
5136 CID[i + 1] = inb_p(j->XILINXbase + 0x02);
5137 }
5138
5139 if (!SCI_Control(j, SCI_End))
5140 return 0;
5141
5142 pIn = CID;
5143 pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
5144 mContinue = 1;
5145 while (mContinue) {
5146 if ((pIn[1] & 0x03) == 0x01) {
5147 pOut[0] = pIn[0];
5148 }
5149 if ((pIn[2] & 0x0c) == 0x04) {
5150 pOut[1] = ((pIn[2] & 0x03) << 6) | ((pIn[1] & 0xfc) >> 2);
5151 }
5152 if ((pIn[3] & 0x30) == 0x10) {
5153 pOut[2] = ((pIn[3] & 0x0f) << 4) | ((pIn[2] & 0xf0) >> 4);
5154 }
5155 if ((pIn[4] & 0xc0) == 0x40) {
5156 pOut[3] = ((pIn[4] & 0x3f) << 2) | ((pIn[3] & 0xc0) >> 6);
5157 } else {
5158 mContinue = FALSE;
5159 }
5160 pIn += 5, pOut += 4;
5161 }
5162 memset(&j->cid, 0, sizeof(PHONE_CID));
5163 pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
5164 pOut += 4;
5165 strncpy(j->cid.month, pOut, 2);
5166 pOut += 2;
5167 strncpy(j->cid.day, pOut, 2);
5168 pOut += 2;
5169 strncpy(j->cid.hour, pOut, 2);
5170 pOut += 2;
5171 strncpy(j->cid.min, pOut, 2);
5172 pOut += 3;
5173 j->cid.numlen = *pOut;
5174 pOut += 1;
5175 strncpy(j->cid.number, pOut, j->cid.numlen);
5176 pOut += j->cid.numlen + 1;
5177 j->cid.namelen = *pOut;
5178 pOut += 1;
5179 strncpy(j->cid.name, pOut, j->cid.namelen);
5180
5181 ixj_daa_cid_reset(j);
5182 return 1;
5183 }
5184
daa_get_version(IXJ * j)5185 static char daa_get_version(IXJ *j)
5186 {
5187 BYTES bytes;
5188
5189 if (!SCI_Prepare(j))
5190 return 0;
5191
5192 bytes.high = 0x35;
5193 bytes.low = 0x00;
5194 outb_p(bytes.high, j->XILINXbase + 0x03);
5195 outb_p(bytes.low, j->XILINXbase + 0x02);
5196
5197 if (!SCI_Control(j, SCI_Enable_DAA))
5198 return 0;
5199
5200 bytes.high = inb_p(j->XILINXbase + 0x03);
5201 bytes.low = inb_p(j->XILINXbase + 0x02);
5202 if (bytes.low != ALISDAA_ID_BYTE) {
5203 if (ixjdebug & 0x0001)
5204 printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low);
5205 return 0;
5206 }
5207 if (!SCI_Control(j, SCI_Enable_DAA))
5208 return 0;
5209
5210 if (!SCI_Control(j, SCI_End))
5211 return 0;
5212
5213 bytes.high = inb_p(j->XILINXbase + 0x03);
5214 bytes.low = inb_p(j->XILINXbase + 0x02);
5215 if (ixjdebug & 0x0002)
5216 printk("DAA CR5 Byte high = 0x%x low = 0x%x\n", bytes.high, bytes.low);
5217 j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = bytes.high;
5218 return bytes.high;
5219 }
5220
daa_set_mode(IXJ * j,int mode)5221 static int daa_set_mode(IXJ *j, int mode)
5222 {
5223 /* NOTE:
5224 The DAA *MUST* be in the conversation mode if the
5225 PSTN line is to be seized (PSTN line off-hook).
5226 Taking the PSTN line off-hook while the DAA is in
5227 a mode other than conversation mode will cause a
5228 hardware failure of the ALIS-A part.
5229
5230 NOTE:
5231 The DAA can only go to SLEEP, RINGING or PULSEDIALING modes
5232 if the PSTN line is on-hook. Failure to have the PSTN line
5233 in the on-hook state WILL CAUSE A HARDWARE FAILURE OF THE
5234 ALIS-A part.
5235 */
5236
5237 BYTES bytes;
5238
5239 j->flags.pstn_rmr = 0;
5240
5241 if (!SCI_Prepare(j))
5242 return 0;
5243
5244 switch (mode) {
5245 case SOP_PU_RESET:
5246 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5247
5248 outb_p(j->pld_scrw.byte, j->XILINXbase);
5249 j->pld_slicw.bits.rly2 = 0;
5250 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5251 bytes.high = 0x10;
5252 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5253 daa_load(&bytes, j);
5254 if (!SCI_Prepare(j))
5255 return 0;
5256
5257 j->daa_mode = SOP_PU_SLEEP;
5258 break;
5259 case SOP_PU_SLEEP:
5260 if(j->daa_mode == SOP_PU_SLEEP)
5261 {
5262 break;
5263 }
5264 if (ixjdebug & 0x0008)
5265 printk(KERN_INFO "phone DAA: SOP_PU_SLEEP at %ld\n", jiffies);
5266 /* if(j->daa_mode == SOP_PU_CONVERSATION) */
5267 {
5268 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5269
5270 outb_p(j->pld_scrw.byte, j->XILINXbase);
5271 j->pld_slicw.bits.rly2 = 0;
5272 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5273 bytes.high = 0x10;
5274 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5275 daa_load(&bytes, j);
5276 if (!SCI_Prepare(j))
5277 return 0;
5278 }
5279 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5280
5281 outb_p(j->pld_scrw.byte, j->XILINXbase);
5282 j->pld_slicw.bits.rly2 = 0;
5283 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5284 bytes.high = 0x10;
5285 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5286 daa_load(&bytes, j);
5287 if (!SCI_Prepare(j))
5288 return 0;
5289
5290 j->daa_mode = SOP_PU_SLEEP;
5291 j->flags.pstn_ringing = 0;
5292 j->ex.bits.pstn_ring = 0;
5293 j->pstn_sleeptil = jiffies + (hertz / 4);
5294 wake_up_interruptible(&j->read_q); /* Wake any blocked readers */
5295 wake_up_interruptible(&j->write_q); /* Wake any blocked writers */
5296 wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
5297 break;
5298 case SOP_PU_RINGING:
5299 if (ixjdebug & 0x0008)
5300 printk(KERN_INFO "phone DAA: SOP_PU_RINGING at %ld\n", jiffies);
5301 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5302
5303 outb_p(j->pld_scrw.byte, j->XILINXbase);
5304 j->pld_slicw.bits.rly2 = 0;
5305 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5306 bytes.high = 0x50;
5307 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5308 daa_load(&bytes, j);
5309 if (!SCI_Prepare(j))
5310 return 0;
5311 j->daa_mode = SOP_PU_RINGING;
5312 break;
5313 case SOP_PU_CONVERSATION:
5314 if (ixjdebug & 0x0008)
5315 printk(KERN_INFO "phone DAA: SOP_PU_CONVERSATION at %ld\n", jiffies);
5316 bytes.high = 0x90;
5317 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5318 daa_load(&bytes, j);
5319 if (!SCI_Prepare(j))
5320 return 0;
5321 j->pld_slicw.bits.rly2 = 1;
5322 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5323 j->pld_scrw.bits.daafsyncen = 1; /* Turn on DAA Frame Sync */
5324
5325 outb_p(j->pld_scrw.byte, j->XILINXbase);
5326 j->daa_mode = SOP_PU_CONVERSATION;
5327 j->flags.pstn_ringing = 0;
5328 j->ex.bits.pstn_ring = 0;
5329 j->pstn_sleeptil = jiffies;
5330 j->pstn_ring_start = j->pstn_ring_stop = j->pstn_ring_int = 0;
5331 break;
5332 case SOP_PU_PULSEDIALING:
5333 if (ixjdebug & 0x0008)
5334 printk(KERN_INFO "phone DAA: SOP_PU_PULSEDIALING at %ld\n", jiffies);
5335 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
5336
5337 outb_p(j->pld_scrw.byte, j->XILINXbase);
5338 j->pld_slicw.bits.rly2 = 0;
5339 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
5340 bytes.high = 0xD0;
5341 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5342 daa_load(&bytes, j);
5343 if (!SCI_Prepare(j))
5344 return 0;
5345 j->daa_mode = SOP_PU_PULSEDIALING;
5346 break;
5347 default:
5348 break;
5349 }
5350 return 1;
5351 }
5352
ixj_daa_write(IXJ * j)5353 static int ixj_daa_write(IXJ *j)
5354 {
5355 BYTES bytes;
5356
5357 j->flags.pstncheck = 1;
5358
5359 daa_set_mode(j, SOP_PU_SLEEP);
5360
5361 if (!SCI_Prepare(j))
5362 return 0;
5363
5364 outb_p(j->pld_scrw.byte, j->XILINXbase);
5365
5366 bytes.high = 0x14;
5367 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg;
5368 if (!daa_load(&bytes, j))
5369 return 0;
5370
5371 bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg;
5372 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg;
5373 if (!daa_load(&bytes, j))
5374 return 0;
5375
5376 bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg;
5377 bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg;
5378 if (!daa_load(&bytes, j))
5379 return 0;
5380
5381 if (!SCI_Prepare(j))
5382 return 0;
5383
5384 bytes.high = 0x1F;
5385 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg;
5386 if (!daa_load(&bytes, j))
5387 return 0;
5388
5389 bytes.high = j->m_DAAShadowRegs.XOP_xr6_W.reg;
5390 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg;
5391 if (!daa_load(&bytes, j))
5392 return 0;
5393
5394 bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg;
5395 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg;
5396 if (!daa_load(&bytes, j))
5397 return 0;
5398
5399 bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg;
5400 bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg;
5401 if (!daa_load(&bytes, j))
5402 return 0;
5403
5404 bytes.high = j->m_DAAShadowRegs.XOP_xr0_W.reg;
5405 bytes.low = 0x00;
5406 if (!daa_load(&bytes, j))
5407 return 0;
5408
5409 if (!SCI_Prepare(j))
5410 return 0;
5411
5412 bytes.high = 0x00;
5413 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7];
5414 if (!daa_load(&bytes, j))
5415 return 0;
5416
5417 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6];
5418 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5];
5419 if (!daa_load(&bytes, j))
5420 return 0;
5421
5422 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4];
5423 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3];
5424 if (!daa_load(&bytes, j))
5425 return 0;
5426
5427 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2];
5428 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1];
5429 if (!daa_load(&bytes, j))
5430 return 0;
5431
5432 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0];
5433 bytes.low = 0x00;
5434 if (!daa_load(&bytes, j))
5435 return 0;
5436
5437 if (!SCI_Control(j, SCI_End))
5438 return 0;
5439 if (!SCI_WaitLowSCI(j))
5440 return 0;
5441
5442 bytes.high = 0x01;
5443 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7];
5444 if (!daa_load(&bytes, j))
5445 return 0;
5446
5447 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6];
5448 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5];
5449 if (!daa_load(&bytes, j))
5450 return 0;
5451
5452 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4];
5453 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3];
5454 if (!daa_load(&bytes, j))
5455 return 0;
5456
5457 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2];
5458 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1];
5459 if (!daa_load(&bytes, j))
5460 return 0;
5461
5462 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0];
5463 bytes.low = 0x00;
5464 if (!daa_load(&bytes, j))
5465 return 0;
5466
5467 if (!SCI_Control(j, SCI_End))
5468 return 0;
5469 if (!SCI_WaitLowSCI(j))
5470 return 0;
5471
5472 bytes.high = 0x02;
5473 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7];
5474 if (!daa_load(&bytes, j))
5475 return 0;
5476
5477 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6];
5478 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5];
5479 if (!daa_load(&bytes, j))
5480 return 0;
5481
5482 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4];
5483 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3];
5484 if (!daa_load(&bytes, j))
5485 return 0;
5486
5487 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2];
5488 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1];
5489 if (!daa_load(&bytes, j))
5490 return 0;
5491
5492 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0];
5493 bytes.low = 0x00;
5494 if (!daa_load(&bytes, j))
5495 return 0;
5496
5497 if (!SCI_Control(j, SCI_End))
5498 return 0;
5499 if (!SCI_WaitLowSCI(j))
5500 return 0;
5501
5502 bytes.high = 0x03;
5503 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7];
5504 if (!daa_load(&bytes, j))
5505 return 0;
5506
5507 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6];
5508 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5];
5509 if (!daa_load(&bytes, j))
5510 return 0;
5511
5512 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4];
5513 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3];
5514 if (!daa_load(&bytes, j))
5515 return 0;
5516
5517 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2];
5518 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1];
5519 if (!daa_load(&bytes, j))
5520 return 0;
5521
5522 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0];
5523 bytes.low = 0x00;
5524 if (!daa_load(&bytes, j))
5525 return 0;
5526
5527 if (!SCI_Control(j, SCI_End))
5528 return 0;
5529 if (!SCI_WaitLowSCI(j))
5530 return 0;
5531
5532 bytes.high = 0x04;
5533 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7];
5534 if (!daa_load(&bytes, j))
5535 return 0;
5536
5537 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6];
5538 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5];
5539 if (!daa_load(&bytes, j))
5540 return 0;
5541
5542 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4];
5543 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3];
5544 if (!daa_load(&bytes, j))
5545 return 0;
5546
5547 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2];
5548 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1];
5549 if (!daa_load(&bytes, j))
5550 return 0;
5551
5552 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0];
5553 bytes.low = 0x00;
5554 if (!daa_load(&bytes, j))
5555 return 0;
5556
5557 if (!SCI_Control(j, SCI_End))
5558 return 0;
5559 if (!SCI_WaitLowSCI(j))
5560 return 0;
5561
5562 bytes.high = 0x05;
5563 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7];
5564 if (!daa_load(&bytes, j))
5565 return 0;
5566
5567 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6];
5568 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5];
5569 if (!daa_load(&bytes, j))
5570 return 0;
5571
5572 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4];
5573 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3];
5574 if (!daa_load(&bytes, j))
5575 return 0;
5576
5577 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2];
5578 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1];
5579 if (!daa_load(&bytes, j))
5580 return 0;
5581
5582 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0];
5583 bytes.low = 0x00;
5584 if (!daa_load(&bytes, j))
5585 return 0;
5586
5587 if (!SCI_Control(j, SCI_End))
5588 return 0;
5589 if (!SCI_WaitLowSCI(j))
5590 return 0;
5591
5592 bytes.high = 0x06;
5593 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7];
5594 if (!daa_load(&bytes, j))
5595 return 0;
5596
5597 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6];
5598 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5];
5599 if (!daa_load(&bytes, j))
5600 return 0;
5601
5602 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4];
5603 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3];
5604 if (!daa_load(&bytes, j))
5605 return 0;
5606
5607 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2];
5608 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1];
5609 if (!daa_load(&bytes, j))
5610 return 0;
5611
5612 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0];
5613 bytes.low = 0x00;
5614 if (!daa_load(&bytes, j))
5615 return 0;
5616
5617 if (!SCI_Control(j, SCI_End))
5618 return 0;
5619 if (!SCI_WaitLowSCI(j))
5620 return 0;
5621
5622 bytes.high = 0x07;
5623 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7];
5624 if (!daa_load(&bytes, j))
5625 return 0;
5626
5627 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6];
5628 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5];
5629 if (!daa_load(&bytes, j))
5630 return 0;
5631
5632 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4];
5633 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3];
5634 if (!daa_load(&bytes, j))
5635 return 0;
5636
5637 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2];
5638 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1];
5639 if (!daa_load(&bytes, j))
5640 return 0;
5641
5642 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0];
5643 bytes.low = 0x00;
5644 if (!daa_load(&bytes, j))
5645 return 0;
5646
5647 if (!SCI_Control(j, SCI_End))
5648 return 0;
5649 if (!SCI_WaitLowSCI(j))
5650 return 0;
5651
5652 bytes.high = 0x08;
5653 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7];
5654 if (!daa_load(&bytes, j))
5655 return 0;
5656
5657 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6];
5658 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5];
5659 if (!daa_load(&bytes, j))
5660 return 0;
5661
5662 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4];
5663 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3];
5664 if (!daa_load(&bytes, j))
5665 return 0;
5666
5667 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2];
5668 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1];
5669 if (!daa_load(&bytes, j))
5670 return 0;
5671
5672 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0];
5673 bytes.low = 0x00;
5674 if (!daa_load(&bytes, j))
5675 return 0;
5676
5677 if (!SCI_Control(j, SCI_End))
5678 return 0;
5679 if (!SCI_WaitLowSCI(j))
5680 return 0;
5681
5682 bytes.high = 0x09;
5683 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3];
5684 if (!daa_load(&bytes, j))
5685 return 0;
5686
5687 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2];
5688 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1];
5689 if (!daa_load(&bytes, j))
5690 return 0;
5691
5692 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0];
5693 bytes.low = 0x00;
5694 if (!daa_load(&bytes, j))
5695 return 0;
5696
5697 if (!SCI_Control(j, SCI_End))
5698 return 0;
5699 if (!SCI_WaitLowSCI(j))
5700 return 0;
5701
5702 bytes.high = 0x0A;
5703 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3];
5704 if (!daa_load(&bytes, j))
5705 return 0;
5706
5707 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2];
5708 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1];
5709 if (!daa_load(&bytes, j))
5710 return 0;
5711
5712 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0];
5713 bytes.low = 0x00;
5714 if (!daa_load(&bytes, j))
5715 return 0;
5716
5717 if (!SCI_Control(j, SCI_End))
5718 return 0;
5719 if (!SCI_WaitLowSCI(j))
5720 return 0;
5721
5722 bytes.high = 0x0B;
5723 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3];
5724 if (!daa_load(&bytes, j))
5725 return 0;
5726
5727 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2];
5728 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1];
5729 if (!daa_load(&bytes, j))
5730 return 0;
5731
5732 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0];
5733 bytes.low = 0x00;
5734 if (!daa_load(&bytes, j))
5735 return 0;
5736
5737 if (!SCI_Control(j, SCI_End))
5738 return 0;
5739 if (!SCI_WaitLowSCI(j))
5740 return 0;
5741
5742 bytes.high = 0x0C;
5743 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3];
5744 if (!daa_load(&bytes, j))
5745 return 0;
5746
5747 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2];
5748 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1];
5749 if (!daa_load(&bytes, j))
5750 return 0;
5751
5752 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0];
5753 bytes.low = 0x00;
5754 if (!daa_load(&bytes, j))
5755 return 0;
5756
5757 if (!SCI_Control(j, SCI_End))
5758 return 0;
5759 if (!SCI_WaitLowSCI(j))
5760 return 0;
5761
5762 bytes.high = 0x0D;
5763 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3];
5764 if (!daa_load(&bytes, j))
5765 return 0;
5766
5767 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2];
5768 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1];
5769 if (!daa_load(&bytes, j))
5770 return 0;
5771
5772 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0];
5773 bytes.low = 0x00;
5774 if (!daa_load(&bytes, j))
5775 return 0;
5776
5777 if (!SCI_Control(j, SCI_End))
5778 return 0;
5779 if (!SCI_WaitLowSCI(j))
5780 return 0;
5781
5782 bytes.high = 0x0E;
5783 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7];
5784 if (!daa_load(&bytes, j))
5785 return 0;
5786
5787 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6];
5788 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5];
5789 if (!daa_load(&bytes, j))
5790 return 0;
5791
5792 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4];
5793 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3];
5794 if (!daa_load(&bytes, j))
5795 return 0;
5796
5797 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2];
5798 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1];
5799 if (!daa_load(&bytes, j))
5800 return 0;
5801
5802 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0];
5803 bytes.low = 0x00;
5804 if (!daa_load(&bytes, j))
5805 return 0;
5806
5807 if (!SCI_Control(j, SCI_End))
5808 return 0;
5809 if (!SCI_WaitLowSCI(j))
5810 return 0;
5811
5812 bytes.high = 0x0F;
5813 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7];
5814 if (!daa_load(&bytes, j))
5815 return 0;
5816
5817 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6];
5818 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5];
5819 if (!daa_load(&bytes, j))
5820 return 0;
5821
5822 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4];
5823 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3];
5824 if (!daa_load(&bytes, j))
5825 return 0;
5826
5827 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2];
5828 bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1];
5829 if (!daa_load(&bytes, j))
5830 return 0;
5831
5832 bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0];
5833 bytes.low = 0x00;
5834 if (!daa_load(&bytes, j))
5835 return 0;
5836
5837 udelay(32);
5838 j->pld_scrr.byte = inb_p(j->XILINXbase);
5839 if (!SCI_Control(j, SCI_End))
5840 return 0;
5841
5842 outb_p(j->pld_scrw.byte, j->XILINXbase);
5843
5844 if (ixjdebug & 0x0002)
5845 printk("DAA Coefficients Loaded\n");
5846
5847 j->flags.pstncheck = 0;
5848 return 1;
5849 }
5850
ixj_set_tone_off(unsigned short arg,IXJ * j)5851 int ixj_set_tone_off(unsigned short arg, IXJ *j)
5852 {
5853 j->tone_off_time = arg;
5854 if (ixj_WriteDSPCommand(0x6E05, j)) /* Set Tone Off Period */
5855
5856 return -1;
5857 if (ixj_WriteDSPCommand(arg, j))
5858 return -1;
5859 return 0;
5860 }
5861
ixj_get_tone_on(IXJ * j)5862 static int ixj_get_tone_on(IXJ *j)
5863 {
5864 if (ixj_WriteDSPCommand(0x6E06, j)) /* Get Tone On Period */
5865
5866 return -1;
5867 return 0;
5868 }
5869
ixj_get_tone_off(IXJ * j)5870 static int ixj_get_tone_off(IXJ *j)
5871 {
5872 if (ixj_WriteDSPCommand(0x6E07, j)) /* Get Tone Off Period */
5873
5874 return -1;
5875 return 0;
5876 }
5877
ixj_busytone(IXJ * j)5878 static void ixj_busytone(IXJ *j)
5879 {
5880 j->flags.ringback = 0;
5881 j->flags.dialtone = 0;
5882 j->flags.busytone = 1;
5883 ixj_set_tone_on(0x07D0, j);
5884 ixj_set_tone_off(0x07D0, j);
5885 ixj_play_tone(j, 27);
5886 }
5887
ixj_dialtone(IXJ * j)5888 static void ixj_dialtone(IXJ *j)
5889 {
5890 j->flags.ringback = 0;
5891 j->flags.dialtone = 1;
5892 j->flags.busytone = 0;
5893 if (j->dsp.low == 0x20) {
5894 return;
5895 } else {
5896 ixj_set_tone_on(0xFFFF, j);
5897 ixj_set_tone_off(0x0000, j);
5898 ixj_play_tone(j, 25);
5899 }
5900 }
5901
ixj_cpt_stop(IXJ * j)5902 static void ixj_cpt_stop(IXJ *j)
5903 {
5904 if(j->tone_state || j->tone_cadence_state)
5905 {
5906 j->flags.dialtone = 0;
5907 j->flags.busytone = 0;
5908 j->flags.ringback = 0;
5909 ixj_set_tone_on(0x0001, j);
5910 ixj_set_tone_off(0x0000, j);
5911 ixj_play_tone(j, 0);
5912 j->tone_state = j->tone_cadence_state = 0;
5913 if (j->cadence_t) {
5914 if (j->cadence_t->ce) {
5915 kfree(j->cadence_t->ce);
5916 }
5917 kfree(j->cadence_t);
5918 j->cadence_t = NULL;
5919 }
5920 }
5921 if (j->play_mode == -1 && j->rec_mode == -1)
5922 idle(j);
5923 if (j->play_mode != -1 && j->dsp.low == 0x20)
5924 ixj_play_start(j);
5925 if (j->rec_mode != -1 && j->dsp.low == 0x20)
5926 ixj_record_start(j);
5927 }
5928
ixj_ringback(IXJ * j)5929 static void ixj_ringback(IXJ *j)
5930 {
5931 j->flags.busytone = 0;
5932 j->flags.dialtone = 0;
5933 j->flags.ringback = 1;
5934 ixj_set_tone_on(0x0FA0, j);
5935 ixj_set_tone_off(0x2EE0, j);
5936 ixj_play_tone(j, 26);
5937 }
5938
ixj_testram(IXJ * j)5939 static void ixj_testram(IXJ *j)
5940 {
5941 ixj_WriteDSPCommand(0x3001, j); /* Test External SRAM */
5942 }
5943
ixj_build_cadence(IXJ * j,IXJ_CADENCE * cp)5944 static int ixj_build_cadence(IXJ *j, IXJ_CADENCE * cp)
5945 {
5946 IXJ_CADENCE *lcp;
5947 IXJ_CADENCE_ELEMENT *lcep;
5948 IXJ_TONE ti;
5949
5950 lcp = kmalloc(sizeof(IXJ_CADENCE), GFP_KERNEL);
5951 if (lcp == NULL)
5952 return -ENOMEM;
5953 if (copy_from_user(lcp, (char *) cp, sizeof(IXJ_CADENCE)) || (unsigned)lcp->elements_used >= ~0U/sizeof(IXJ_CADENCE_ELEMENT) )
5954 {
5955 kfree(lcp);
5956 return -EFAULT;
5957 }
5958 lcep = kmalloc(sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used, GFP_KERNEL);
5959 if (lcep == NULL) {
5960 kfree(lcp);
5961 return -ENOMEM;
5962 }
5963 if (copy_from_user(lcep, lcp->ce, sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used))
5964 {
5965 kfree(lcep);
5966 kfree(lcp);
5967 return -EFAULT;
5968 }
5969 if (j->cadence_t) {
5970 kfree(j->cadence_t->ce);
5971 kfree(j->cadence_t);
5972 }
5973 lcp->ce = (void *) lcep;
5974 j->cadence_t = lcp;
5975 j->tone_cadence_state = 0;
5976 ixj_set_tone_on(lcp->ce[0].tone_on_time, j);
5977 ixj_set_tone_off(lcp->ce[0].tone_off_time, j);
5978 if (j->cadence_t->ce[j->tone_cadence_state].freq0) {
5979 ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index;
5980 ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0;
5981 ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0;
5982 ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1;
5983 ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1;
5984 ixj_init_tone(j, &ti);
5985 }
5986 ixj_play_tone(j, lcp->ce[0].index);
5987 return 1;
5988 }
5989
ixj_build_filter_cadence(IXJ * j,IXJ_FILTER_CADENCE * cp)5990 static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE * cp)
5991 {
5992 IXJ_FILTER_CADENCE *lcp;
5993 lcp = kmalloc(sizeof(IXJ_FILTER_CADENCE), GFP_KERNEL);
5994 if (lcp == NULL) {
5995 if(ixjdebug & 0x0001) {
5996 printk(KERN_INFO "Could not allocate memory for cadence\n");
5997 }
5998 return -ENOMEM;
5999 }
6000 if (copy_from_user(lcp, (char *) cp, sizeof(IXJ_FILTER_CADENCE))) {
6001 if(ixjdebug & 0x0001) {
6002 printk(KERN_INFO "Could not copy cadence to kernel\n");
6003 }
6004 kfree(lcp);
6005 return -EFAULT;
6006 }
6007 if (lcp->filter > 5) {
6008 if(ixjdebug & 0x0001) {
6009 printk(KERN_INFO "Cadence out of range\n");
6010 }
6011 kfree(lcp);
6012 return -1;
6013 }
6014 j->cadence_f[lcp->filter].state = 0;
6015 j->cadence_f[lcp->filter].enable = lcp->enable;
6016 j->filter_en[lcp->filter] = j->cadence_f[lcp->filter].en_filter = lcp->en_filter;
6017 j->cadence_f[lcp->filter].on1 = lcp->on1;
6018 j->cadence_f[lcp->filter].on1min = 0;
6019 j->cadence_f[lcp->filter].on1max = 0;
6020 j->cadence_f[lcp->filter].off1 = lcp->off1;
6021 j->cadence_f[lcp->filter].off1min = 0;
6022 j->cadence_f[lcp->filter].off1max = 0;
6023 j->cadence_f[lcp->filter].on2 = lcp->on2;
6024 j->cadence_f[lcp->filter].on2min = 0;
6025 j->cadence_f[lcp->filter].on2max = 0;
6026 j->cadence_f[lcp->filter].off2 = lcp->off2;
6027 j->cadence_f[lcp->filter].off2min = 0;
6028 j->cadence_f[lcp->filter].off2max = 0;
6029 j->cadence_f[lcp->filter].on3 = lcp->on3;
6030 j->cadence_f[lcp->filter].on3min = 0;
6031 j->cadence_f[lcp->filter].on3max = 0;
6032 j->cadence_f[lcp->filter].off3 = lcp->off3;
6033 j->cadence_f[lcp->filter].off3min = 0;
6034 j->cadence_f[lcp->filter].off3max = 0;
6035 kfree(lcp);
6036 if(ixjdebug & 0x0002) {
6037 printk(KERN_INFO "Cadence %d loaded\n", lcp->filter);
6038 }
6039 return 0;
6040 }
6041
add_caps(IXJ * j)6042 static void add_caps(IXJ *j)
6043 {
6044 j->caps = 0;
6045 j->caplist[j->caps].cap = PHONE_VENDOR_QUICKNET;
6046 strcpy(j->caplist[j->caps].desc, "Quicknet Technologies, Inc. (www.quicknet.net)");
6047 j->caplist[j->caps].captype = vendor;
6048 j->caplist[j->caps].handle = j->caps++;
6049 j->caplist[j->caps].captype = device;
6050 switch (j->cardtype) {
6051 case QTI_PHONEJACK:
6052 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK");
6053 break;
6054 case QTI_LINEJACK:
6055 strcpy(j->caplist[j->caps].desc, "Quicknet Internet LineJACK");
6056 break;
6057 case QTI_PHONEJACK_LITE:
6058 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK Lite");
6059 break;
6060 case QTI_PHONEJACK_PCI:
6061 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK PCI");
6062 break;
6063 case QTI_PHONECARD:
6064 strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneCARD");
6065 break;
6066 }
6067 j->caplist[j->caps].cap = j->cardtype;
6068 j->caplist[j->caps].handle = j->caps++;
6069 strcpy(j->caplist[j->caps].desc, "POTS");
6070 j->caplist[j->caps].captype = port;
6071 j->caplist[j->caps].cap = pots;
6072 j->caplist[j->caps].handle = j->caps++;
6073
6074 /* add devices that can do speaker/mic */
6075 switch (j->cardtype) {
6076 case QTI_PHONEJACK:
6077 case QTI_LINEJACK:
6078 case QTI_PHONEJACK_PCI:
6079 case QTI_PHONECARD:
6080 strcpy(j->caplist[j->caps].desc, "SPEAKER");
6081 j->caplist[j->caps].captype = port;
6082 j->caplist[j->caps].cap = speaker;
6083 j->caplist[j->caps].handle = j->caps++;
6084 default:
6085 break;
6086 }
6087
6088 /* add devices that can do handset */
6089 switch (j->cardtype) {
6090 case QTI_PHONEJACK:
6091 strcpy(j->caplist[j->caps].desc, "HANDSET");
6092 j->caplist[j->caps].captype = port;
6093 j->caplist[j->caps].cap = handset;
6094 j->caplist[j->caps].handle = j->caps++;
6095 break;
6096 default:
6097 break;
6098 }
6099
6100 /* add devices that can do PSTN */
6101 switch (j->cardtype) {
6102 case QTI_LINEJACK:
6103 strcpy(j->caplist[j->caps].desc, "PSTN");
6104 j->caplist[j->caps].captype = port;
6105 j->caplist[j->caps].cap = pstn;
6106 j->caplist[j->caps].handle = j->caps++;
6107 break;
6108 default:
6109 break;
6110 }
6111
6112 /* add codecs - all cards can do uLaw, linear 8/16, and Windows sound system */
6113 strcpy(j->caplist[j->caps].desc, "ULAW");
6114 j->caplist[j->caps].captype = codec;
6115 j->caplist[j->caps].cap = ULAW;
6116 j->caplist[j->caps].handle = j->caps++;
6117
6118 strcpy(j->caplist[j->caps].desc, "LINEAR 16 bit");
6119 j->caplist[j->caps].captype = codec;
6120 j->caplist[j->caps].cap = LINEAR16;
6121 j->caplist[j->caps].handle = j->caps++;
6122
6123 strcpy(j->caplist[j->caps].desc, "LINEAR 8 bit");
6124 j->caplist[j->caps].captype = codec;
6125 j->caplist[j->caps].cap = LINEAR8;
6126 j->caplist[j->caps].handle = j->caps++;
6127
6128 strcpy(j->caplist[j->caps].desc, "Windows Sound System");
6129 j->caplist[j->caps].captype = codec;
6130 j->caplist[j->caps].cap = WSS;
6131 j->caplist[j->caps].handle = j->caps++;
6132
6133 /* software ALAW codec, made from ULAW */
6134 strcpy(j->caplist[j->caps].desc, "ALAW");
6135 j->caplist[j->caps].captype = codec;
6136 j->caplist[j->caps].cap = ALAW;
6137 j->caplist[j->caps].handle = j->caps++;
6138
6139 /* version 12 of the 8020 does the following codecs in a broken way */
6140 if (j->dsp.low != 0x20 || j->ver.low != 0x12) {
6141 strcpy(j->caplist[j->caps].desc, "G.723.1 6.3kbps");
6142 j->caplist[j->caps].captype = codec;
6143 j->caplist[j->caps].cap = G723_63;
6144 j->caplist[j->caps].handle = j->caps++;
6145
6146 strcpy(j->caplist[j->caps].desc, "G.723.1 5.3kbps");
6147 j->caplist[j->caps].captype = codec;
6148 j->caplist[j->caps].cap = G723_53;
6149 j->caplist[j->caps].handle = j->caps++;
6150
6151 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.8kbps");
6152 j->caplist[j->caps].captype = codec;
6153 j->caplist[j->caps].cap = TS48;
6154 j->caplist[j->caps].handle = j->caps++;
6155
6156 strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.1kbps");
6157 j->caplist[j->caps].captype = codec;
6158 j->caplist[j->caps].cap = TS41;
6159 j->caplist[j->caps].handle = j->caps++;
6160 }
6161
6162 /* 8020 chips can do TS8.5 native, and 8021/8022 can load it */
6163 if (j->dsp.low == 0x20 || j->flags.ts85_loaded) {
6164 strcpy(j->caplist[j->caps].desc, "TrueSpeech 8.5kbps");
6165 j->caplist[j->caps].captype = codec;
6166 j->caplist[j->caps].cap = TS85;
6167 j->caplist[j->caps].handle = j->caps++;
6168 }
6169
6170 /* 8021 chips can do G728 */
6171 if (j->dsp.low == 0x21) {
6172 strcpy(j->caplist[j->caps].desc, "G.728 16kbps");
6173 j->caplist[j->caps].captype = codec;
6174 j->caplist[j->caps].cap = G728;
6175 j->caplist[j->caps].handle = j->caps++;
6176 }
6177
6178 /* 8021/8022 chips can do G729 if loaded */
6179 if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
6180 strcpy(j->caplist[j->caps].desc, "G.729A 8kbps");
6181 j->caplist[j->caps].captype = codec;
6182 j->caplist[j->caps].cap = G729;
6183 j->caplist[j->caps].handle = j->caps++;
6184 }
6185 if (j->dsp.low != 0x20 && j->flags.g729_loaded) {
6186 strcpy(j->caplist[j->caps].desc, "G.729B 8kbps");
6187 j->caplist[j->caps].captype = codec;
6188 j->caplist[j->caps].cap = G729B;
6189 j->caplist[j->caps].handle = j->caps++;
6190 }
6191 }
6192
capabilities_check(IXJ * j,struct phone_capability * pcreq)6193 static int capabilities_check(IXJ *j, struct phone_capability *pcreq)
6194 {
6195 int cnt;
6196 int retval = 0;
6197 for (cnt = 0; cnt < j->caps; cnt++) {
6198 if (pcreq->captype == j->caplist[cnt].captype
6199 && pcreq->cap == j->caplist[cnt].cap) {
6200 retval = 1;
6201 break;
6202 }
6203 }
6204 return retval;
6205 }
6206
ixj_ioctl(struct inode * inode,struct file * file_p,unsigned int cmd,unsigned long arg)6207 static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, unsigned long arg)
6208 {
6209 IXJ_TONE ti;
6210 IXJ_FILTER jf;
6211 IXJ_FILTER_RAW jfr;
6212
6213 unsigned int raise, mant;
6214 unsigned int minor = MINOR(inode->i_rdev);
6215 int board = NUM(inode->i_rdev);
6216
6217 IXJ *j = get_ixj(NUM(inode->i_rdev));
6218
6219 int retval = 0;
6220
6221 /*
6222 * Set up locks to ensure that only one process is talking to the DSP at a time.
6223 * This is necessary to keep the DSP from locking up.
6224 */
6225 while(test_and_set_bit(board, (void *)&j->busyflags) != 0) {
6226 set_current_state(TASK_INTERRUPTIBLE);
6227 schedule_timeout(1);
6228 }
6229 if (ixjdebug & 0x0040)
6230 printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
6231 if (minor >= IXJMAX) {
6232 clear_bit(board, &j->busyflags);
6233 return -ENODEV;
6234 }
6235 /*
6236 * Check ioctls only root can use.
6237 */
6238 if (!capable(CAP_SYS_ADMIN)) {
6239 switch (cmd) {
6240 case IXJCTL_TESTRAM:
6241 case IXJCTL_HZ:
6242 retval = -EPERM;
6243 }
6244 }
6245 switch (cmd) {
6246 case IXJCTL_TESTRAM:
6247 ixj_testram(j);
6248 retval = (j->ssr.high << 8) + j->ssr.low;
6249 break;
6250 case IXJCTL_CARDTYPE:
6251 retval = j->cardtype;
6252 break;
6253 case IXJCTL_SERIAL:
6254 retval = j->serial;
6255 break;
6256 case IXJCTL_VERSION:
6257 if (copy_to_user((char *) arg, ixj_c_revision, strlen(ixj_c_revision)))
6258 retval = -EFAULT;
6259 break;
6260 case PHONE_RING_CADENCE:
6261 j->ring_cadence = arg;
6262 break;
6263 case IXJCTL_CIDCW:
6264 if(arg) {
6265 copy_from_user(&j->cid_send, (char *)arg, sizeof(PHONE_CID));
6266 }
6267 else {
6268 memset(&j->cid_send, 0, sizeof(PHONE_CID));
6269 }
6270 ixj_write_cidcw(j);
6271 break;
6272 /* Binary compatbility */
6273 case OLD_PHONE_RING_START:
6274 arg = 0;
6275 /* Fall through */
6276 case PHONE_RING_START:
6277 if(arg) {
6278 if(copy_from_user(&j->cid_send, (char *)arg, sizeof(PHONE_CID)))
6279 {
6280 retval = -EFAULT;
6281 break;
6282 }
6283 ixj_write_cid(j);
6284 }
6285 else {
6286 memset(&j->cid_send, 0, sizeof(PHONE_CID));
6287 }
6288 ixj_ring_start(j);
6289 break;
6290 case PHONE_RING_STOP:
6291 j->flags.cringing = 0;
6292 if(j->cadence_f[5].enable) {
6293 j->cadence_f[5].state = 0;
6294 }
6295 ixj_ring_off(j);
6296 break;
6297 case PHONE_RING:
6298 retval = ixj_ring(j);
6299 break;
6300 case PHONE_EXCEPTION:
6301 retval = j->ex.bytes;
6302 if(j->ex.bits.flash) {
6303 j->flash_end = 0;
6304 j->ex.bits.flash = 0;
6305 }
6306 j->ex.bits.pstn_ring = 0;
6307 j->ex.bits.caller_id = 0;
6308 j->ex.bits.pstn_wink = 0;
6309 j->ex.bits.f0 = 0;
6310 j->ex.bits.f1 = 0;
6311 j->ex.bits.f2 = 0;
6312 j->ex.bits.f3 = 0;
6313 j->ex.bits.fc0 = 0;
6314 j->ex.bits.fc1 = 0;
6315 j->ex.bits.fc2 = 0;
6316 j->ex.bits.fc3 = 0;
6317 j->ex.bits.reserved = 0;
6318 break;
6319 case PHONE_HOOKSTATE:
6320 j->ex.bits.hookstate = 0;
6321 retval = j->hookstate; //j->r_hook;
6322 break;
6323 case IXJCTL_SET_LED:
6324 LED_SetState(arg, j);
6325 break;
6326 case PHONE_FRAME:
6327 retval = set_base_frame(j, arg);
6328 break;
6329 case PHONE_REC_CODEC:
6330 retval = set_rec_codec(j, arg);
6331 break;
6332 case PHONE_VAD:
6333 ixj_vad(j, arg);
6334 break;
6335 case PHONE_REC_START:
6336 ixj_record_start(j);
6337 break;
6338 case PHONE_REC_STOP:
6339 ixj_record_stop(j);
6340 break;
6341 case PHONE_REC_DEPTH:
6342 set_rec_depth(j, arg);
6343 break;
6344 case PHONE_REC_VOLUME:
6345 if(arg == -1) {
6346 retval = get_rec_volume(j);
6347 }
6348 else {
6349 set_rec_volume(j, arg);
6350 retval = arg;
6351 }
6352 break;
6353 case PHONE_REC_VOLUME_LINEAR:
6354 if(arg == -1) {
6355 retval = get_rec_volume_linear(j);
6356 }
6357 else {
6358 set_rec_volume_linear(j, arg);
6359 retval = arg;
6360 }
6361 break;
6362 case IXJCTL_DTMF_PRESCALE:
6363 if(arg == -1) {
6364 retval = get_dtmf_prescale(j);
6365 }
6366 else {
6367 set_dtmf_prescale(j, arg);
6368 retval = arg;
6369 }
6370 break;
6371 case PHONE_REC_LEVEL:
6372 retval = get_rec_level(j);
6373 break;
6374 case IXJCTL_SC_RXG:
6375 retval = ixj_siadc(j, arg);
6376 break;
6377 case IXJCTL_SC_TXG:
6378 retval = ixj_sidac(j, arg);
6379 break;
6380 case IXJCTL_AEC_START:
6381 ixj_aec_start(j, arg);
6382 break;
6383 case IXJCTL_AEC_STOP:
6384 aec_stop(j);
6385 break;
6386 case IXJCTL_AEC_GET_LEVEL:
6387 retval = j->aec_level;
6388 break;
6389 case PHONE_PLAY_CODEC:
6390 retval = set_play_codec(j, arg);
6391 break;
6392 case PHONE_PLAY_START:
6393 retval = ixj_play_start(j);
6394 break;
6395 case PHONE_PLAY_STOP:
6396 ixj_play_stop(j);
6397 break;
6398 case PHONE_PLAY_DEPTH:
6399 set_play_depth(j, arg);
6400 break;
6401 case PHONE_PLAY_VOLUME:
6402 if(arg == -1) {
6403 retval = get_play_volume(j);
6404 }
6405 else {
6406 set_play_volume(j, arg);
6407 retval = arg;
6408 }
6409 break;
6410 case PHONE_PLAY_VOLUME_LINEAR:
6411 if(arg == -1) {
6412 retval = get_play_volume_linear(j);
6413 }
6414 else {
6415 set_play_volume_linear(j, arg);
6416 retval = arg;
6417 }
6418 break;
6419 case PHONE_PLAY_LEVEL:
6420 retval = get_play_level(j);
6421 break;
6422 case IXJCTL_DSP_TYPE:
6423 retval = (j->dsp.high << 8) + j->dsp.low;
6424 break;
6425 case IXJCTL_DSP_VERSION:
6426 retval = (j->ver.high << 8) + j->ver.low;
6427 break;
6428 case IXJCTL_HZ:
6429 hertz = arg;
6430 break;
6431 case IXJCTL_RATE:
6432 if (arg > hertz)
6433 retval = -1;
6434 else
6435 samplerate = arg;
6436 break;
6437 case IXJCTL_DRYBUFFER_READ:
6438 put_user(j->drybuffer, (unsigned long *) arg);
6439 break;
6440 case IXJCTL_DRYBUFFER_CLEAR:
6441 j->drybuffer = 0;
6442 break;
6443 case IXJCTL_FRAMES_READ:
6444 put_user(j->framesread, (unsigned long *) arg);
6445 break;
6446 case IXJCTL_FRAMES_WRITTEN:
6447 put_user(j->frameswritten, (unsigned long *) arg);
6448 break;
6449 case IXJCTL_READ_WAIT:
6450 put_user(j->read_wait, (unsigned long *) arg);
6451 break;
6452 case IXJCTL_WRITE_WAIT:
6453 put_user(j->write_wait, (unsigned long *) arg);
6454 break;
6455 case PHONE_MAXRINGS:
6456 j->maxrings = arg;
6457 break;
6458 case PHONE_SET_TONE_ON_TIME:
6459 ixj_set_tone_on(arg, j);
6460 break;
6461 case PHONE_SET_TONE_OFF_TIME:
6462 ixj_set_tone_off(arg, j);
6463 break;
6464 case PHONE_GET_TONE_ON_TIME:
6465 if (ixj_get_tone_on(j)) {
6466 retval = -1;
6467 } else {
6468 retval = (j->ssr.high << 8) + j->ssr.low;
6469 }
6470 break;
6471 case PHONE_GET_TONE_OFF_TIME:
6472 if (ixj_get_tone_off(j)) {
6473 retval = -1;
6474 } else {
6475 retval = (j->ssr.high << 8) + j->ssr.low;
6476 }
6477 break;
6478 case PHONE_PLAY_TONE:
6479 if (!j->tone_state)
6480 retval = ixj_play_tone(j, arg);
6481 else
6482 retval = -1;
6483 break;
6484 case PHONE_GET_TONE_STATE:
6485 retval = j->tone_state;
6486 break;
6487 case PHONE_DTMF_READY:
6488 retval = j->ex.bits.dtmf_ready;
6489 break;
6490 case PHONE_GET_DTMF:
6491 if (ixj_hookstate(j)) {
6492 if (j->dtmf_rp != j->dtmf_wp) {
6493 retval = j->dtmfbuffer[j->dtmf_rp];
6494 j->dtmf_rp++;
6495 if (j->dtmf_rp == 79)
6496 j->dtmf_rp = 0;
6497 if (j->dtmf_rp == j->dtmf_wp) {
6498 j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
6499 }
6500 }
6501 }
6502 break;
6503 case PHONE_GET_DTMF_ASCII:
6504 if (ixj_hookstate(j)) {
6505 if (j->dtmf_rp != j->dtmf_wp) {
6506 switch (j->dtmfbuffer[j->dtmf_rp]) {
6507 case 10:
6508 retval = 42; /* '*'; */
6509
6510 break;
6511 case 11:
6512 retval = 48; /*'0'; */
6513
6514 break;
6515 case 12:
6516 retval = 35; /*'#'; */
6517
6518 break;
6519 case 28:
6520 retval = 65; /*'A'; */
6521
6522 break;
6523 case 29:
6524 retval = 66; /*'B'; */
6525
6526 break;
6527 case 30:
6528 retval = 67; /*'C'; */
6529
6530 break;
6531 case 31:
6532 retval = 68; /*'D'; */
6533
6534 break;
6535 default:
6536 retval = 48 + j->dtmfbuffer[j->dtmf_rp];
6537 break;
6538 }
6539 j->dtmf_rp++;
6540 if (j->dtmf_rp == 79)
6541 j->dtmf_rp = 0;
6542 if(j->dtmf_rp == j->dtmf_wp)
6543 {
6544 j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0;
6545 }
6546 }
6547 }
6548 break;
6549 case PHONE_DTMF_OOB:
6550 j->flags.dtmf_oob = arg;
6551 break;
6552 case PHONE_DIALTONE:
6553 ixj_dialtone(j);
6554 break;
6555 case PHONE_BUSY:
6556 ixj_busytone(j);
6557 break;
6558 case PHONE_RINGBACK:
6559 ixj_ringback(j);
6560 break;
6561 case PHONE_WINK:
6562 if(j->cardtype == QTI_PHONEJACK)
6563 retval = -1;
6564 else
6565 retval = ixj_wink(j);
6566 break;
6567 case PHONE_CPT_STOP:
6568 ixj_cpt_stop(j);
6569 break;
6570 case PHONE_QUERY_CODEC:
6571 {
6572 struct phone_codec_data pd;
6573 int val;
6574 int proto_size[] = {
6575 -1,
6576 12, 10, 16, 9, 8, 48, 5,
6577 40, 40, 80, 40, 40, 6
6578 };
6579 if(copy_from_user(&pd, (void *)arg, sizeof(pd))) {
6580 retval = -EFAULT;
6581 break;
6582 }
6583 if(pd.type<1 || pd.type>13) {
6584 retval = -EPROTONOSUPPORT;
6585 break;
6586 }
6587 if(pd.type<G729)
6588 val=proto_size[pd.type];
6589 else switch(j->baseframe.low)
6590 {
6591 case 0xA0:val=2*proto_size[pd.type];break;
6592 case 0x50:val=proto_size[pd.type];break;
6593 default:val=proto_size[pd.type]*3;break;
6594 }
6595 pd.buf_min=pd.buf_max=pd.buf_opt=val;
6596 if(copy_to_user((void *)arg, &pd, sizeof(pd)))
6597 retval = -EFAULT;
6598 break;
6599 }
6600 case IXJCTL_DSP_IDLE:
6601 idle(j);
6602 break;
6603 case IXJCTL_MIXER:
6604 if ((arg & 0xff) == 0xff)
6605 retval = ixj_get_mixer(arg, j);
6606 else
6607 ixj_mixer(arg, j);
6608 break;
6609 case IXJCTL_DAA_COEFF_SET:
6610 switch (arg) {
6611 case DAA_US:
6612 DAA_Coeff_US(j);
6613 retval = ixj_daa_write(j);
6614 break;
6615 case DAA_UK:
6616 DAA_Coeff_UK(j);
6617 retval = ixj_daa_write(j);
6618 break;
6619 case DAA_FRANCE:
6620 DAA_Coeff_France(j);
6621 retval = ixj_daa_write(j);
6622 break;
6623 case DAA_GERMANY:
6624 DAA_Coeff_Germany(j);
6625 retval = ixj_daa_write(j);
6626 break;
6627 case DAA_AUSTRALIA:
6628 DAA_Coeff_Australia(j);
6629 retval = ixj_daa_write(j);
6630 break;
6631 case DAA_JAPAN:
6632 DAA_Coeff_Japan(j);
6633 retval = ixj_daa_write(j);
6634 break;
6635 default:
6636 retval = 1;
6637 break;
6638 }
6639 break;
6640 case IXJCTL_DAA_AGAIN:
6641 ixj_daa_cr4(j, arg | 0x02);
6642 break;
6643 case IXJCTL_PSTN_LINETEST:
6644 retval = ixj_linetest(j);
6645 break;
6646 case IXJCTL_VMWI:
6647 ixj_write_vmwi(j, arg);
6648 break;
6649 case IXJCTL_CID:
6650 if (copy_to_user((char *) arg, &j->cid, sizeof(PHONE_CID)))
6651 retval = -EFAULT;
6652 j->ex.bits.caller_id = 0;
6653 break;
6654 case IXJCTL_WINK_DURATION:
6655 j->winktime = arg;
6656 break;
6657 case IXJCTL_PORT:
6658 if (arg)
6659 retval = ixj_set_port(j, arg);
6660 else
6661 retval = j->port;
6662 break;
6663 case IXJCTL_POTS_PSTN:
6664 retval = ixj_set_pots(j, arg);
6665 break;
6666 case PHONE_CAPABILITIES:
6667 add_caps(j);
6668 retval = j->caps;
6669 break;
6670 case PHONE_CAPABILITIES_LIST:
6671 add_caps(j);
6672 if (copy_to_user((char *) arg, j->caplist, sizeof(struct phone_capability) * j->caps))
6673 retval = -EFAULT;
6674 break;
6675 case PHONE_CAPABILITIES_CHECK:
6676 {
6677 struct phone_capability cap;
6678 if (copy_from_user(&cap, (char *) arg, sizeof(cap)))
6679 retval = -EFAULT;
6680 else {
6681 add_caps(j);
6682 retval = capabilities_check(j, &cap);
6683 }
6684 }
6685 break;
6686 case PHONE_PSTN_SET_STATE:
6687 daa_set_mode(j, arg);
6688 break;
6689 case PHONE_PSTN_GET_STATE:
6690 retval = j->daa_mode;
6691 j->ex.bits.pstn_ring = 0;
6692 break;
6693 case IXJCTL_SET_FILTER:
6694 if (copy_from_user(&jf, (char *) arg, sizeof(jf)))
6695 retval = -EFAULT;
6696 retval = ixj_init_filter(j, &jf);
6697 break;
6698 case IXJCTL_SET_FILTER_RAW:
6699 if (copy_from_user(&jfr, (char *) arg, sizeof(jfr)))
6700 retval = -EFAULT;
6701 retval = ixj_init_filter_raw(j, &jfr);
6702 break;
6703 case IXJCTL_GET_FILTER_HIST:
6704 if(arg<0||arg>3)
6705 retval = -EINVAL;
6706 else
6707 retval = j->filter_hist[arg];
6708 break;
6709 case IXJCTL_INIT_TONE:
6710 copy_from_user(&ti, (char *) arg, sizeof(ti));
6711 retval = ixj_init_tone(j, &ti);
6712 break;
6713 case IXJCTL_TONE_CADENCE:
6714 retval = ixj_build_cadence(j, (IXJ_CADENCE *) arg);
6715 break;
6716 case IXJCTL_FILTER_CADENCE:
6717 retval = ixj_build_filter_cadence(j, (IXJ_FILTER_CADENCE *) arg);
6718 break;
6719 case IXJCTL_SIGCTL:
6720 if (copy_from_user(&j->sigdef, (char *)arg, sizeof(IXJ_SIGDEF)))
6721 retval = -EFAULT;
6722 j->ixj_signals[j->sigdef.event] = j->sigdef.signal;
6723 if(j->sigdef.event < 33) {
6724 raise = 1;
6725 for(mant = 0; mant < j->sigdef.event; mant++){
6726 raise *= 2;
6727 }
6728 if(j->sigdef.signal)
6729 j->ex_sig.bytes |= raise;
6730 else
6731 j->ex_sig.bytes &= (raise^0xffff);
6732 }
6733 break;
6734 case IXJCTL_INTERCOM_STOP:
6735 if(arg < 0 || arg >= IXJMAX)
6736 return -EINVAL;
6737 j->intercom = -1;
6738 ixj_record_stop(j);
6739 ixj_play_stop(j);
6740 idle(j);
6741 get_ixj(arg)->intercom = -1;
6742 ixj_record_stop(get_ixj(arg));
6743 ixj_play_stop(get_ixj(arg));
6744 idle(get_ixj(arg));
6745 break;
6746 case IXJCTL_INTERCOM_START:
6747 if(arg < 0 || arg >= IXJMAX)
6748 return -EINVAL;
6749 j->intercom = arg;
6750 ixj_record_start(j);
6751 ixj_play_start(j);
6752 get_ixj(arg)->intercom = board;
6753 ixj_play_start(get_ixj(arg));
6754 ixj_record_start(get_ixj(arg));
6755 break;
6756 }
6757 if (ixjdebug & 0x0040)
6758 printk("phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
6759 clear_bit(board, &j->busyflags);
6760 return retval;
6761 }
6762
ixj_fasync(int fd,struct file * file_p,int mode)6763 static int ixj_fasync(int fd, struct file *file_p, int mode)
6764 {
6765 IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode->i_rdev));
6766
6767 return fasync_helper(fd, file_p, mode, &j->async_queue);
6768 }
6769
6770 struct file_operations ixj_fops =
6771 {
6772 owner: THIS_MODULE,
6773 read: ixj_enhanced_read,
6774 write: ixj_enhanced_write,
6775 poll: ixj_poll,
6776 ioctl: ixj_ioctl,
6777 release: ixj_release,
6778 fasync: ixj_fasync
6779 };
6780
ixj_linetest(IXJ * j)6781 static int ixj_linetest(IXJ *j)
6782 {
6783 unsigned long jifwait;
6784
6785 j->flags.pstncheck = 1; /* Testing */
6786 j->flags.pstn_present = 0; /* Assume the line is not there */
6787
6788 daa_int_read(j); /*Clear DAA Interrupt flags */
6789 /* */
6790 /* Hold all relays in the normally de-energized position. */
6791 /* */
6792
6793 j->pld_slicw.bits.rly1 = 0;
6794 j->pld_slicw.bits.rly2 = 0;
6795 j->pld_slicw.bits.rly3 = 0;
6796 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6797 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6798
6799 outb_p(j->pld_scrw.byte, j->XILINXbase);
6800 j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01);
6801 if (j->pld_slicr.bits.potspstn) {
6802 j->flags.pots_pstn = 1;
6803 j->flags.pots_correct = 0;
6804 LED_SetState(0x4, j);
6805 } else {
6806 j->flags.pots_pstn = 0;
6807 j->pld_slicw.bits.rly1 = 0;
6808 j->pld_slicw.bits.rly2 = 0;
6809 j->pld_slicw.bits.rly3 = 1;
6810 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6811 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
6812
6813 outb_p(j->pld_scrw.byte, j->XILINXbase);
6814 daa_set_mode(j, SOP_PU_CONVERSATION);
6815 jifwait = jiffies + hertz;
6816 while (time_before(jiffies, jifwait)) {
6817 set_current_state(TASK_INTERRUPTIBLE);
6818 schedule_timeout(1);
6819 }
6820 daa_int_read(j);
6821 daa_set_mode(j, SOP_PU_RESET);
6822 if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
6823 j->flags.pots_correct = 0; /* Should not be line voltage on POTS port. */
6824 LED_SetState(0x4, j);
6825 j->pld_slicw.bits.rly3 = 0;
6826 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6827 } else {
6828 j->flags.pots_correct = 1;
6829 LED_SetState(0x8, j);
6830 j->pld_slicw.bits.rly1 = 1;
6831 j->pld_slicw.bits.rly2 = 0;
6832 j->pld_slicw.bits.rly3 = 0;
6833 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6834 }
6835 }
6836 j->pld_slicw.bits.rly3 = 0;
6837 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
6838 daa_set_mode(j, SOP_PU_CONVERSATION);
6839 jifwait = jiffies + hertz;
6840 while (time_before(jiffies, jifwait)) {
6841 set_current_state(TASK_INTERRUPTIBLE);
6842 schedule_timeout(1);
6843 }
6844 daa_int_read(j);
6845 daa_set_mode(j, SOP_PU_RESET);
6846 if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
6847 j->pstn_sleeptil = jiffies + (hertz / 4);
6848 j->flags.pstn_present = 1;
6849 } else {
6850 j->flags.pstn_present = 0;
6851 }
6852 if (j->flags.pstn_present) {
6853 if (j->flags.pots_correct) {
6854 LED_SetState(0xA, j);
6855 } else {
6856 LED_SetState(0x6, j);
6857 }
6858 } else {
6859 if (j->flags.pots_correct) {
6860 LED_SetState(0x9, j);
6861 } else {
6862 LED_SetState(0x5, j);
6863 }
6864 }
6865 j->flags.pstncheck = 0; /* Testing */
6866 return j->flags.pstn_present;
6867 }
6868
ixj_selfprobe(IXJ * j)6869 static int ixj_selfprobe(IXJ *j)
6870 {
6871 unsigned short cmd;
6872 unsigned long jif;
6873 int cnt;
6874 BYTES bytes;
6875
6876 init_waitqueue_head(&j->poll_q);
6877 init_waitqueue_head(&j->read_q);
6878 init_waitqueue_head(&j->write_q);
6879
6880 while(atomic_read(&j->DSPWrite) > 0)
6881 atomic_dec(&j->DSPWrite);
6882 if (ixjdebug & 0x0002)
6883 printk(KERN_INFO "Write IDLE to Software Control Register\n");
6884 ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */
6885
6886 if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
6887 return -1;
6888 /* The read values of the SSR should be 0x00 for the IDLE command */
6889 if (j->ssr.low || j->ssr.high)
6890 return -1;
6891 if (ixjdebug & 0x0002)
6892 printk(KERN_INFO "Get Device ID Code\n");
6893 if (ixj_WriteDSPCommand(0x3400, j)) /* Get Device ID Code */
6894 return -1;
6895 j->dsp.low = j->ssr.low;
6896 j->dsp.high = j->ssr.high;
6897 if (ixjdebug & 0x0002)
6898 printk(KERN_INFO "Get Device Version Code\n");
6899 if (ixj_WriteDSPCommand(0x3800, j)) /* Get Device Version Code */
6900 return -1;
6901 j->ver.low = j->ssr.low;
6902 j->ver.high = j->ssr.high;
6903 if (!j->cardtype) {
6904 if (j->dsp.low == 0x21) {
6905 bytes.high = bytes.low = inb_p(j->XILINXbase + 0x02);
6906 outb_p(bytes.low ^ 0xFF, j->XILINXbase + 0x02);
6907 /* Test for Internet LineJACK or Internet PhoneJACK Lite */
6908 bytes.low = inb_p(j->XILINXbase + 0x02);
6909 if (bytes.low == bytes.high) /* Register is read only on */
6910 /* Internet PhoneJack Lite */
6911 {
6912 j->cardtype = QTI_PHONEJACK_LITE;
6913 if (check_region(j->XILINXbase, 4)) {
6914 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6915 return -1;
6916 }
6917 request_region(j->XILINXbase, 4, "ixj control");
6918 j->pld_slicw.pcib.e1 = 1;
6919 outb_p(j->pld_slicw.byte, j->XILINXbase);
6920 } else {
6921 j->cardtype = QTI_LINEJACK;
6922
6923 if (check_region(j->XILINXbase, 8)) {
6924 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6925 return -1;
6926 }
6927 request_region(j->XILINXbase, 8, "ixj control");
6928 }
6929 } else if (j->dsp.low == 0x22) {
6930 j->cardtype = QTI_PHONEJACK_PCI;
6931 request_region(j->XILINXbase, 4, "ixj control");
6932 j->pld_slicw.pcib.e1 = 1;
6933 outb_p(j->pld_slicw.byte, j->XILINXbase);
6934 } else
6935 j->cardtype = QTI_PHONEJACK;
6936 } else {
6937 switch (j->cardtype) {
6938 case QTI_PHONEJACK:
6939 if (!j->dsp.low != 0x20) {
6940 j->dsp.high = 0x80;
6941 j->dsp.low = 0x20;
6942 ixj_WriteDSPCommand(0x3800, j);
6943 j->ver.low = j->ssr.low;
6944 j->ver.high = j->ssr.high;
6945 }
6946 break;
6947 case QTI_LINEJACK:
6948 if (check_region(j->XILINXbase, 8)) {
6949 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6950 return -1;
6951 }
6952 request_region(j->XILINXbase, 8, "ixj control");
6953 break;
6954 case QTI_PHONEJACK_LITE:
6955 case QTI_PHONEJACK_PCI:
6956 if (check_region(j->XILINXbase, 4)) {
6957 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase);
6958 return -1;
6959 }
6960 request_region(j->XILINXbase, 4, "ixj control");
6961 j->pld_slicw.pcib.e1 = 1;
6962 outb_p(j->pld_slicw.byte, j->XILINXbase);
6963 break;
6964 case QTI_PHONECARD:
6965 break;
6966 }
6967 }
6968 if (j->dsp.low == 0x20 || j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
6969 if (ixjdebug & 0x0002)
6970 printk(KERN_INFO "Write CODEC config to Software Control Register\n");
6971 if (ixj_WriteDSPCommand(0xC462, j)) /* Write CODEC config to Software Control Register */
6972 return -1;
6973 if (ixjdebug & 0x0002)
6974 printk(KERN_INFO "Write CODEC timing to Software Control Register\n");
6975 if (j->cardtype == QTI_PHONEJACK) {
6976 cmd = 0x9FF2;
6977 } else {
6978 cmd = 0x9FF5;
6979 }
6980 if (ixj_WriteDSPCommand(cmd, j)) /* Write CODEC timing to Software Control Register */
6981 return -1;
6982 } else {
6983 if (set_base_frame(j, 30) != 30)
6984 return -1;
6985 if (ixjdebug & 0x0002)
6986 printk(KERN_INFO "Write CODEC config to Software Control Register\n");
6987 if (j->cardtype == QTI_PHONECARD) {
6988 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
6989 return -1;
6990 }
6991 if (j->cardtype == QTI_LINEJACK) {
6992 if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */
6993 return -1;
6994 if (ixjdebug & 0x0002)
6995 printk(KERN_INFO "Turn on the PLD Clock at 8Khz\n");
6996 j->pld_clock.byte = 0;
6997 outb_p(j->pld_clock.byte, j->XILINXbase + 0x04);
6998 }
6999 }
7000
7001 if (j->dsp.low == 0x20) {
7002 if (ixjdebug & 0x0002)
7003 printk(KERN_INFO "Configure GPIO pins\n");
7004 j->gpio.bytes.high = 0x09;
7005 /* bytes.low = 0xEF; 0xF7 */
7006 j->gpio.bits.gpio1 = 1;
7007 j->gpio.bits.gpio2 = 1;
7008 j->gpio.bits.gpio3 = 0;
7009 j->gpio.bits.gpio4 = 1;
7010 j->gpio.bits.gpio5 = 1;
7011 j->gpio.bits.gpio6 = 1;
7012 j->gpio.bits.gpio7 = 1;
7013 ixj_WriteDSPCommand(j->gpio.word, j); /* Set GPIO pin directions */
7014 if (ixjdebug & 0x0002)
7015 printk(KERN_INFO "Enable SLIC\n");
7016 j->gpio.bytes.high = 0x0B;
7017 j->gpio.bytes.low = 0x00;
7018 j->gpio.bits.gpio1 = 0;
7019 j->gpio.bits.gpio2 = 1;
7020 j->gpio.bits.gpio5 = 0;
7021 ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring stop signal */
7022 j->port = PORT_POTS;
7023 } else {
7024 if (j->cardtype == QTI_LINEJACK) {
7025 LED_SetState(0x1, j);
7026 jif = jiffies + (hertz / 10);
7027 while (time_before(jiffies, jif)) {
7028 set_current_state(TASK_INTERRUPTIBLE);
7029 schedule_timeout(1);
7030 }
7031 LED_SetState(0x2, j);
7032 jif = jiffies + (hertz / 10);
7033 while (time_before(jiffies, jif)) {
7034 set_current_state(TASK_INTERRUPTIBLE);
7035 schedule_timeout(1);
7036 }
7037 LED_SetState(0x4, j);
7038 jif = jiffies + (hertz / 10);
7039 while (time_before(jiffies, jif)) {
7040 set_current_state(TASK_INTERRUPTIBLE);
7041 schedule_timeout(1);
7042 }
7043 LED_SetState(0x8, j);
7044 jif = jiffies + (hertz / 10);
7045 while (time_before(jiffies, jif)) {
7046 set_current_state(TASK_INTERRUPTIBLE);
7047 schedule_timeout(1);
7048 }
7049 LED_SetState(0x0, j);
7050 daa_get_version(j);
7051 if (ixjdebug & 0x0002)
7052 printk("Loading DAA Coefficients\n");
7053 DAA_Coeff_US(j);
7054 if (!ixj_daa_write(j)) {
7055 printk("DAA write failed on board %d\n", j->board);
7056 return -1;
7057 }
7058 if(!ixj_daa_cid_reset(j)) {
7059 printk("DAA CID reset failed on board %d\n", j->board);
7060 return -1;
7061 }
7062 j->flags.pots_correct = 0;
7063 j->flags.pstn_present = 0;
7064 ixj_linetest(j);
7065 if (j->flags.pots_correct) {
7066 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
7067
7068 outb_p(j->pld_scrw.byte, j->XILINXbase);
7069 j->pld_slicw.bits.rly1 = 1;
7070 j->pld_slicw.bits.spken = 1;
7071 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
7072 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
7073 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
7074 j->port = PORT_POTS;
7075 }
7076 ixj_set_port(j, PORT_PSTN);
7077 ixj_set_pots(j, 1);
7078 if (ixjdebug & 0x0002)
7079 printk(KERN_INFO "Enable Mixer\n");
7080 ixj_mixer(0x0000, j); /*Master Volume Left unmute 0db */
7081 ixj_mixer(0x0100, j); /*Master Volume Right unmute 0db */
7082
7083 ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */
7084 ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */
7085
7086 ixj_mixer(0x0480, j); /*FM Left mute */
7087 ixj_mixer(0x0580, j); /*FM Right mute */
7088
7089 ixj_mixer(0x0680, j); /*CD Left mute */
7090 ixj_mixer(0x0780, j); /*CD Right mute */
7091
7092 ixj_mixer(0x0880, j); /*Line Left mute */
7093 ixj_mixer(0x0980, j); /*Line Right mute */
7094
7095 ixj_mixer(0x0A80, j); /*Aux left mute */
7096 ixj_mixer(0x0B80, j); /*Aux right mute */
7097
7098 ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */
7099 ixj_mixer(0x0D80, j); /*Mono2 mute */
7100
7101 ixj_mixer(0x0E80, j); /*Mic mute */
7102
7103 ixj_mixer(0x0F00, j); /*Mono Out Volume unmute 0db */
7104
7105 ixj_mixer(0x1000, j); /*Voice Left and Right out only */
7106 ixj_mixer(0x110C, j);
7107
7108
7109 ixj_mixer(0x1200, j); /*Mono1 switch on mixer left */
7110 ixj_mixer(0x1401, j);
7111
7112 ixj_mixer(0x1300, j); /*Mono1 switch on mixer right */
7113 ixj_mixer(0x1501, j);
7114
7115 ixj_mixer(0x1700, j); /*Clock select */
7116
7117 ixj_mixer(0x1800, j); /*ADC input from mixer */
7118
7119 ixj_mixer(0x1901, j); /*Mic gain 30db */
7120
7121 if (ixjdebug & 0x0002)
7122 printk(KERN_INFO "Setting Default US Ring Cadence Detection\n");
7123 j->cadence_f[4].state = 0;
7124 j->cadence_f[4].on1 = 0; /*Cadence Filter 4 is used for PSTN ring cadence */
7125 j->cadence_f[4].off1 = 0;
7126 j->cadence_f[4].on2 = 0;
7127 j->cadence_f[4].off2 = 0;
7128 j->cadence_f[4].on3 = 0;
7129 j->cadence_f[4].off3 = 0; /* These should represent standard US ring pulse. */
7130 j->pstn_last_rmr = jiffies;
7131
7132 } else {
7133 if (j->cardtype == QTI_PHONECARD) {
7134 ixj_WriteDSPCommand(0xCF07, j);
7135 ixj_WriteDSPCommand(0x00B0, j);
7136 ixj_set_port(j, PORT_SPEAKER);
7137 } else {
7138 ixj_set_port(j, PORT_POTS);
7139 SLIC_SetState(PLD_SLIC_STATE_STANDBY, j);
7140 /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */
7141 }
7142 }
7143 }
7144
7145 j->intercom = -1;
7146 j->framesread = j->frameswritten = 0;
7147 j->read_wait = j->write_wait = 0;
7148 j->rxreadycheck = j->txreadycheck = 0;
7149
7150 /* initialise the DTMF prescale to a sensible value */
7151 if (j->cardtype == QTI_LINEJACK) {
7152 set_dtmf_prescale(j, 0x10);
7153 } else {
7154 set_dtmf_prescale(j, 0x40);
7155 }
7156 set_play_volume(j, 0x100);
7157 set_rec_volume(j, 0x100);
7158
7159 if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */
7160 return -1;
7161 /* The read values of the SSR should be 0x00 for the IDLE command */
7162 if (j->ssr.low || j->ssr.high)
7163 return -1;
7164
7165 if (ixjdebug & 0x0002)
7166 printk(KERN_INFO "Enable Line Monitor\n");
7167
7168 if (ixjdebug & 0x0002)
7169 printk(KERN_INFO "Set Line Monitor to Asyncronous Mode\n");
7170
7171 if (ixj_WriteDSPCommand(0x7E01, j)) /* Asynchronous Line Monitor */
7172 return -1;
7173
7174 if (ixjdebug & 0x002)
7175 printk(KERN_INFO "Enable DTMF Detectors\n");
7176
7177 if (ixj_WriteDSPCommand(0x5151, j)) /* Enable DTMF detection */
7178 return -1;
7179
7180 if (ixj_WriteDSPCommand(0x6E01, j)) /* Set Asyncronous Tone Generation */
7181 return -1;
7182
7183 set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */
7184
7185 set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */
7186
7187 j->ex.bits.dtmf_ready = 0;
7188 j->dtmf_state = 0;
7189 j->dtmf_wp = j->dtmf_rp = 0;
7190 j->rec_mode = j->play_mode = -1;
7191 j->flags.ringing = 0;
7192 j->maxrings = MAXRINGS;
7193 j->ring_cadence = USA_RING_CADENCE;
7194 j->drybuffer = 0;
7195 j->winktime = 320;
7196 j->flags.dtmf_oob = 0;
7197 for (cnt = 0; cnt < 4; cnt++)
7198 j->cadence_f[cnt].enable = 0;
7199 /* must be a device on the specified address */
7200 ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */
7201
7202 /* Set up the default signals for events */
7203 for (cnt = 0; cnt < 35; cnt++)
7204 j->ixj_signals[cnt] = SIGIO;
7205
7206 /* Set the excetion signal enable flags */
7207 j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
7208 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 =
7209 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;
7210 #ifdef IXJ_DYN_ALLOC
7211 j->fskdata = NULL;
7212 #endif
7213 j->fskdcnt = 0;
7214 j->cidcw_wait = 0;
7215
7216 /* Register with the Telephony for Linux subsystem */
7217 j->p.f_op = &ixj_fops;
7218 j->p.open = ixj_open;
7219 j->p.board = j->board;
7220 phone_register_device(&j->p, PHONE_UNIT_ANY);
7221
7222 ixj_init_timer(j);
7223 ixj_add_timer(j);
7224 return 0;
7225 }
7226
7227 /*
7228 * Exported service for pcmcia card handling
7229 */
7230
ixj_pcmcia_probe(unsigned long dsp,unsigned long xilinx)7231 IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx)
7232 {
7233 IXJ *j = ixj_alloc();
7234
7235 j->board = 0;
7236
7237 j->DSPbase = dsp;
7238 j->XILINXbase = xilinx;
7239 j->cardtype = QTI_PHONECARD;
7240 ixj_selfprobe(j);
7241 return j;
7242 }
7243
7244 EXPORT_SYMBOL(ixj_pcmcia_probe); /* Fpr PCMCIA */
7245
ixj_get_status_proc(char * buf)7246 static int ixj_get_status_proc(char *buf)
7247 {
7248 int len;
7249 int cnt;
7250 IXJ *j;
7251 len = 0;
7252 len += sprintf(buf + len, "%s", ixj_c_rcsid);
7253 len += sprintf(buf + len, "\n%s", ixj_h_rcsid);
7254 len += sprintf(buf + len, "\n%s", ixjuser_h_rcsid);
7255 len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER);
7256 len += sprintf(buf + len, "\nsizeof IXJ struct %d bytes", sizeof(IXJ));
7257 len += sprintf(buf + len, "\nsizeof DAA struct %d bytes", sizeof(DAA_REGS));
7258 len += sprintf(buf + len, "\nUsing old telephony API");
7259 len += sprintf(buf + len, "\nDebug Level %d\n", ixjdebug);
7260
7261 for (cnt = 0; cnt < IXJMAX; cnt++) {
7262 j = get_ixj(cnt);
7263 if(j==NULL)
7264 continue;
7265 if (j->DSPbase) {
7266 len += sprintf(buf + len, "\nCard Num %d", cnt);
7267 len += sprintf(buf + len, "\nDSP Base Address 0x%4.4x", j->DSPbase);
7268 if (j->cardtype != QTI_PHONEJACK)
7269 len += sprintf(buf + len, "\nXILINX Base Address 0x%4.4x", j->XILINXbase);
7270 len += sprintf(buf + len, "\nDSP Type %2.2x%2.2x", j->dsp.high, j->dsp.low);
7271 len += sprintf(buf + len, "\nDSP Version %2.2x.%2.2x", j->ver.high, j->ver.low);
7272 len += sprintf(buf + len, "\nSerial Number %8.8x", j->serial);
7273 switch (j->cardtype) {
7274 case (QTI_PHONEJACK):
7275 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK");
7276 break;
7277 case (QTI_LINEJACK):
7278 len += sprintf(buf + len, "\nCard Type = Internet LineJACK");
7279 if (j->flags.g729_loaded)
7280 len += sprintf(buf + len, " w/G.729 A/B");
7281 len += sprintf(buf + len, " Country = %d", j->daa_country);
7282 break;
7283 case (QTI_PHONEJACK_LITE):
7284 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK Lite");
7285 if (j->flags.g729_loaded)
7286 len += sprintf(buf + len, " w/G.729 A/B");
7287 break;
7288 case (QTI_PHONEJACK_PCI):
7289 len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK PCI");
7290 if (j->flags.g729_loaded)
7291 len += sprintf(buf + len, " w/G.729 A/B");
7292 break;
7293 case (QTI_PHONECARD):
7294 len += sprintf(buf + len, "\nCard Type = Internet PhoneCARD");
7295 if (j->flags.g729_loaded)
7296 len += sprintf(buf + len, " w/G.729 A/B");
7297 len += sprintf(buf + len, "\nSmart Cable %spresent", j->pccr1.bits.drf ? "not " : "");
7298 if (!j->pccr1.bits.drf)
7299 len += sprintf(buf + len, "\nSmart Cable type %d", j->flags.pcmciasct);
7300 len += sprintf(buf + len, "\nSmart Cable state %d", j->flags.pcmciastate);
7301 break;
7302 default:
7303 len += sprintf(buf + len, "\nCard Type = %d", j->cardtype);
7304 break;
7305 }
7306 len += sprintf(buf + len, "\nReaders %d", j->readers);
7307 len += sprintf(buf + len, "\nWriters %d", j->writers);
7308 add_caps(j);
7309 len += sprintf(buf + len, "\nCapabilities %d", j->caps);
7310 if (j->dsp.low != 0x20)
7311 len += sprintf(buf + len, "\nDSP Processor load %d", j->proc_load);
7312 if (j->flags.cidsent)
7313 len += sprintf(buf + len, "\nCaller ID data sent");
7314 else
7315 len += sprintf(buf + len, "\nCaller ID data not sent");
7316
7317 len += sprintf(buf + len, "\nPlay CODEC ");
7318 switch (j->play_codec) {
7319 case G723_63:
7320 len += sprintf(buf + len, "G.723.1 6.3");
7321 break;
7322 case G723_53:
7323 len += sprintf(buf + len, "G.723.1 5.3");
7324 break;
7325 case TS85:
7326 len += sprintf(buf + len, "TrueSpeech 8.5");
7327 break;
7328 case TS48:
7329 len += sprintf(buf + len, "TrueSpeech 4.8");
7330 break;
7331 case TS41:
7332 len += sprintf(buf + len, "TrueSpeech 4.1");
7333 break;
7334 case G728:
7335 len += sprintf(buf + len, "G.728");
7336 break;
7337 case G729:
7338 len += sprintf(buf + len, "G.729");
7339 break;
7340 case G729B:
7341 len += sprintf(buf + len, "G.729B");
7342 break;
7343 case ULAW:
7344 len += sprintf(buf + len, "uLaw");
7345 break;
7346 case ALAW:
7347 len += sprintf(buf + len, "aLaw");
7348 break;
7349 case LINEAR16:
7350 len += sprintf(buf + len, "16 bit Linear");
7351 break;
7352 case LINEAR8:
7353 len += sprintf(buf + len, "8 bit Linear");
7354 break;
7355 case WSS:
7356 len += sprintf(buf + len, "Windows Sound System");
7357 break;
7358 default:
7359 len += sprintf(buf + len, "NO CODEC CHOSEN");
7360 break;
7361 }
7362 len += sprintf(buf + len, "\nRecord CODEC ");
7363 switch (j->rec_codec) {
7364 case G723_63:
7365 len += sprintf(buf + len, "G.723.1 6.3");
7366 break;
7367 case G723_53:
7368 len += sprintf(buf + len, "G.723.1 5.3");
7369 break;
7370 case TS85:
7371 len += sprintf(buf + len, "TrueSpeech 8.5");
7372 break;
7373 case TS48:
7374 len += sprintf(buf + len, "TrueSpeech 4.8");
7375 break;
7376 case TS41:
7377 len += sprintf(buf + len, "TrueSpeech 4.1");
7378 break;
7379 case G728:
7380 len += sprintf(buf + len, "G.728");
7381 break;
7382 case G729:
7383 len += sprintf(buf + len, "G.729");
7384 break;
7385 case G729B:
7386 len += sprintf(buf + len, "G.729B");
7387 break;
7388 case ULAW:
7389 len += sprintf(buf + len, "uLaw");
7390 break;
7391 case ALAW:
7392 len += sprintf(buf + len, "aLaw");
7393 break;
7394 case LINEAR16:
7395 len += sprintf(buf + len, "16 bit Linear");
7396 break;
7397 case LINEAR8:
7398 len += sprintf(buf + len, "8 bit Linear");
7399 break;
7400 case WSS:
7401 len += sprintf(buf + len, "Windows Sound System");
7402 break;
7403 default:
7404 len += sprintf(buf + len, "NO CODEC CHOSEN");
7405 break;
7406 }
7407 len += sprintf(buf + len, "\nAEC ");
7408 switch (j->aec_level) {
7409 case AEC_OFF:
7410 len += sprintf(buf + len, "Off");
7411 break;
7412 case AEC_LOW:
7413 len += sprintf(buf + len, "Low");
7414 break;
7415 case AEC_MED:
7416 len += sprintf(buf + len, "Med");
7417 break;
7418 case AEC_HIGH:
7419 len += sprintf(buf + len, "High");
7420 break;
7421 case AEC_AUTO:
7422 len += sprintf(buf + len, "Auto");
7423 break;
7424 case AEC_AGC:
7425 len += sprintf(buf + len, "AEC/AGC");
7426 break;
7427 default:
7428 len += sprintf(buf + len, "unknown(%i)", j->aec_level);
7429 break;
7430 }
7431
7432 len += sprintf(buf + len, "\nRec volume 0x%x", get_rec_volume(j));
7433 len += sprintf(buf + len, "\nPlay volume 0x%x", get_play_volume(j));
7434 len += sprintf(buf + len, "\nDTMF prescale 0x%x", get_dtmf_prescale(j));
7435
7436 len += sprintf(buf + len, "\nHook state %d", j->hookstate); /* j->r_hook); */
7437
7438 if (j->cardtype == QTI_LINEJACK) {
7439 len += sprintf(buf + len, "\nPOTS Correct %d", j->flags.pots_correct);
7440 len += sprintf(buf + len, "\nPSTN Present %d", j->flags.pstn_present);
7441 len += sprintf(buf + len, "\nPSTN Check %d", j->flags.pstncheck);
7442 len += sprintf(buf + len, "\nPOTS to PSTN %d", j->flags.pots_pstn);
7443 switch (j->daa_mode) {
7444 case SOP_PU_SLEEP:
7445 len += sprintf(buf + len, "\nDAA PSTN On Hook");
7446 break;
7447 case SOP_PU_RINGING:
7448 len += sprintf(buf + len, "\nDAA PSTN Ringing");
7449 len += sprintf(buf + len, "\nRinging state = %d", j->cadence_f[4].state);
7450 break;
7451 case SOP_PU_CONVERSATION:
7452 len += sprintf(buf + len, "\nDAA PSTN Off Hook");
7453 break;
7454 case SOP_PU_PULSEDIALING:
7455 len += sprintf(buf + len, "\nDAA PSTN Pulse Dialing");
7456 break;
7457 }
7458 len += sprintf(buf + len, "\nDAA RMR = %d", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR);
7459 len += sprintf(buf + len, "\nDAA VDD OK = %d", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK);
7460 len += sprintf(buf + len, "\nDAA CR0 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg);
7461 len += sprintf(buf + len, "\nDAA CR1 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg);
7462 len += sprintf(buf + len, "\nDAA CR2 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg);
7463 len += sprintf(buf + len, "\nDAA CR3 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg);
7464 len += sprintf(buf + len, "\nDAA CR4 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg);
7465 len += sprintf(buf + len, "\nDAA CR5 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg);
7466 len += sprintf(buf + len, "\nDAA XR0 = 0x%02x", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg);
7467 len += sprintf(buf + len, "\nDAA ringstop %ld - jiffies %ld", j->pstn_ring_stop, jiffies);
7468 }
7469 switch (j->port) {
7470 case PORT_POTS:
7471 len += sprintf(buf + len, "\nPort POTS");
7472 break;
7473 case PORT_PSTN:
7474 len += sprintf(buf + len, "\nPort PSTN");
7475 break;
7476 case PORT_SPEAKER:
7477 len += sprintf(buf + len, "\nPort SPEAKER/MIC");
7478 break;
7479 case PORT_HANDSET:
7480 len += sprintf(buf + len, "\nPort HANDSET");
7481 break;
7482 }
7483 if (j->dsp.low == 0x21 || j->dsp.low == 0x22) {
7484 len += sprintf(buf + len, "\nSLIC state ");
7485 switch (SLIC_GetState(j)) {
7486 case PLD_SLIC_STATE_OC:
7487 len += sprintf(buf + len, "OC");
7488 break;
7489 case PLD_SLIC_STATE_RINGING:
7490 len += sprintf(buf + len, "RINGING");
7491 break;
7492 case PLD_SLIC_STATE_ACTIVE:
7493 len += sprintf(buf + len, "ACTIVE");
7494 break;
7495 case PLD_SLIC_STATE_OHT: /* On-hook transmit */
7496 len += sprintf(buf + len, "OHT");
7497 break;
7498 case PLD_SLIC_STATE_TIPOPEN:
7499 len += sprintf(buf + len, "TIPOPEN");
7500 break;
7501 case PLD_SLIC_STATE_STANDBY:
7502 len += sprintf(buf + len, "STANDBY");
7503 break;
7504 case PLD_SLIC_STATE_APR: /* Active polarity reversal */
7505 len += sprintf(buf + len, "APR");
7506 break;
7507 case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */
7508 len += sprintf(buf + len, "OHTPR");
7509 break;
7510 default:
7511 len += sprintf(buf + len, "%d", SLIC_GetState(j));
7512 break;
7513 }
7514 }
7515 len += sprintf(buf + len, "\nBase Frame %2.2x.%2.2x", j->baseframe.high, j->baseframe.low);
7516 len += sprintf(buf + len, "\nCID Base Frame %2d", j->cid_base_frame_size);
7517 #ifdef PERFMON_STATS
7518 len += sprintf(buf + len, "\nTimer Checks %ld", j->timerchecks);
7519 len += sprintf(buf + len, "\nRX Ready Checks %ld", j->rxreadycheck);
7520 len += sprintf(buf + len, "\nTX Ready Checks %ld", j->txreadycheck);
7521 len += sprintf(buf + len, "\nFrames Read %ld", j->framesread);
7522 len += sprintf(buf + len, "\nFrames Written %ld", j->frameswritten);
7523 len += sprintf(buf + len, "\nDry Buffer %ld", j->drybuffer);
7524 len += sprintf(buf + len, "\nRead Waits %ld", j->read_wait);
7525 len += sprintf(buf + len, "\nWrite Waits %ld", j->write_wait);
7526 len += sprintf(buf + len, "\nStatus Waits %ld", j->statuswait);
7527 len += sprintf(buf + len, "\nStatus Wait Fails %ld", j->statuswaitfail);
7528 len += sprintf(buf + len, "\nPControl Waits %ld", j->pcontrolwait);
7529 len += sprintf(buf + len, "\nPControl Wait Fails %ld", j->pcontrolwaitfail);
7530 len += sprintf(buf + len, "\nIs Control Ready Checks %ld", j->iscontrolready);
7531 len += sprintf(buf + len, "\nIs Control Ready Check failures %ld", j->iscontrolreadyfail);
7532
7533 #endif
7534 len += sprintf(buf + len, "\n");
7535 }
7536 }
7537 return len;
7538 }
7539
ixj_read_proc(char * page,char ** start,off_t off,int count,int * eof,void * data)7540 static int ixj_read_proc(char *page, char **start, off_t off,
7541 int count, int *eof, void *data)
7542 {
7543 int len = ixj_get_status_proc(page);
7544 if (len <= off+count) *eof = 1;
7545 *start = page + off;
7546 len -= off;
7547 if (len>count) len = count;
7548 if (len<0) len = 0;
7549 return len;
7550 }
7551
7552
cleanup(void)7553 static void cleanup(void)
7554 {
7555 int cnt;
7556 IXJ *j;
7557
7558 for (cnt = 0; cnt < IXJMAX; cnt++) {
7559 j = get_ixj(cnt);
7560 if(j != NULL && j->DSPbase) {
7561 if (ixjdebug & 0x0002)
7562 printk(KERN_INFO "IXJ: Deleting timer for /dev/phone%d\n", cnt);
7563 del_timer(&j->timer);
7564 if (j->cardtype == QTI_LINEJACK) {
7565 j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */
7566
7567 outb_p(j->pld_scrw.byte, j->XILINXbase);
7568 j->pld_slicw.bits.rly1 = 0;
7569 j->pld_slicw.bits.rly2 = 0;
7570 j->pld_slicw.bits.rly3 = 0;
7571 outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
7572 LED_SetState(0x0, j);
7573 if (ixjdebug & 0x0002)
7574 printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
7575 release_region(j->XILINXbase, 8);
7576 } else if (j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) {
7577 if (ixjdebug & 0x0002)
7578 printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
7579 release_region(j->XILINXbase, 4);
7580 }
7581 if (j->read_buffer)
7582 kfree(j->read_buffer);
7583 if (j->write_buffer)
7584 kfree(j->write_buffer);
7585 if (j->dev && j->dev->deactivate)
7586 j->dev->deactivate(j->dev);
7587 if (ixjdebug & 0x0002)
7588 printk(KERN_INFO "IXJ: Unregistering /dev/phone%d from LTAPI\n", cnt);
7589 phone_unregister_device(&j->p);
7590 if (ixjdebug & 0x0002)
7591 printk(KERN_INFO "IXJ: Releasing DSP address for /dev/phone%d\n", cnt);
7592 release_region(j->DSPbase, 16);
7593 #ifdef IXJ_DYN_ALLOC
7594 if (ixjdebug & 0x0002)
7595 printk(KERN_INFO "IXJ: Freeing memory for /dev/phone%d\n", cnt);
7596 kfree(j);
7597 ixj[cnt] = NULL;
7598 #endif
7599 }
7600 }
7601 if (ixjdebug & 0x0002)
7602 printk(KERN_INFO "IXJ: Removing /proc/ixj\n");
7603 remove_proc_entry ("ixj", NULL);
7604 }
7605
7606 /* Typedefs */
7607 typedef struct {
7608 BYTE length;
7609 DWORD bits;
7610 } DATABLOCK;
7611
PCIEE_WriteBit(WORD wEEPROMAddress,BYTE lastLCC,BYTE byData)7612 static void PCIEE_WriteBit(WORD wEEPROMAddress, BYTE lastLCC, BYTE byData)
7613 {
7614 lastLCC = lastLCC & 0xfb;
7615 lastLCC = lastLCC | (byData ? 4 : 0);
7616 outb(lastLCC, wEEPROMAddress); /*set data out bit as appropriate */
7617
7618 mdelay(1);
7619 lastLCC = lastLCC | 0x01;
7620 outb(lastLCC, wEEPROMAddress); /*SK rising edge */
7621
7622 byData = byData << 1;
7623 lastLCC = lastLCC & 0xfe;
7624 mdelay(1);
7625 outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
7626
7627 }
7628
PCIEE_ReadBit(WORD wEEPROMAddress,BYTE lastLCC)7629 static BYTE PCIEE_ReadBit(WORD wEEPROMAddress, BYTE lastLCC)
7630 {
7631 mdelay(1);
7632 lastLCC = lastLCC | 0x01;
7633 outb(lastLCC, wEEPROMAddress); /*SK rising edge */
7634
7635 lastLCC = lastLCC & 0xfe;
7636 mdelay(1);
7637 outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */
7638
7639 return ((inb(wEEPROMAddress) >> 3) & 1);
7640 }
7641
PCIEE_ReadWord(WORD wAddress,WORD wLoc,WORD * pwResult)7642 static BOOL PCIEE_ReadWord(WORD wAddress, WORD wLoc, WORD * pwResult)
7643 {
7644 BYTE lastLCC;
7645 WORD wEEPROMAddress = wAddress + 3;
7646 DWORD i;
7647 BYTE byResult;
7648 *pwResult = 0;
7649 lastLCC = inb(wEEPROMAddress);
7650 lastLCC = lastLCC | 0x02;
7651 lastLCC = lastLCC & 0xfe;
7652 outb(lastLCC, wEEPROMAddress); /* CS hi, SK lo */
7653
7654 mdelay(1); /* delay */
7655
7656 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
7657 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
7658 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 0);
7659 for (i = 0; i < 8; i++) {
7660 PCIEE_WriteBit(wEEPROMAddress, lastLCC, wLoc & 0x80 ? 1 : 0);
7661 wLoc <<= 1;
7662 }
7663
7664 for (i = 0; i < 16; i++) {
7665 byResult = PCIEE_ReadBit(wEEPROMAddress, lastLCC);
7666 *pwResult = (*pwResult << 1) | byResult;
7667 }
7668
7669 mdelay(1); /* another delay */
7670
7671 lastLCC = lastLCC & 0xfd;
7672 outb(lastLCC, wEEPROMAddress); /* negate CS */
7673
7674 return 0;
7675 }
7676
PCIEE_GetSerialNumber(WORD wAddress)7677 static DWORD PCIEE_GetSerialNumber(WORD wAddress)
7678 {
7679 WORD wLo, wHi;
7680 if (PCIEE_ReadWord(wAddress, 62, &wLo))
7681 return 0;
7682 if (PCIEE_ReadWord(wAddress, 63, &wHi))
7683 return 0;
7684 return (((DWORD) wHi << 16) | wLo);
7685 }
7686
7687 static int dspio[IXJMAX + 1] =
7688 {
7689 0,
7690 };
7691 static int xio[IXJMAX + 1] =
7692 {
7693 0,
7694 };
7695
7696 MODULE_PARM(dspio, "1-" __MODULE_STRING(IXJMAX) "i");
7697 MODULE_PARM(xio, "1-" __MODULE_STRING(IXJMAX) "i");
7698 MODULE_DESCRIPTION("Quicknet VoIP Telephony card module - www.quicknet.net");
7699 MODULE_AUTHOR("Ed Okerson <eokerson@quicknet.net>");
7700 MODULE_LICENSE("GPL");
7701
ixj_exit(void)7702 void ixj_exit(void)
7703 {
7704 cleanup();
7705 }
7706
ixj_probe_isapnp(int * cnt)7707 int __init ixj_probe_isapnp(int *cnt)
7708 {
7709 int probe = 0;
7710 int func = 0x110;
7711 struct pci_dev *dev = NULL, *old_dev = NULL;
7712
7713 while (1) {
7714 do {
7715 IXJ *j;
7716 int result;
7717
7718 old_dev = dev;
7719 dev = isapnp_find_dev(NULL, ISAPNP_VENDOR('Q', 'T', 'I'),
7720 ISAPNP_FUNCTION(func), old_dev);
7721 if (!dev)
7722 break;
7723 result = dev->prepare(dev);
7724 if (result < 0) {
7725 printk("preparing failed %d \n", result);
7726 break;
7727 }
7728
7729 if (!(dev->resource[0].flags & IORESOURCE_IO))
7730 return -ENODEV;
7731
7732 dev->resource[0].flags |= IORESOURCE_AUTO;
7733 if (func != 0x110)
7734 dev->resource[1].flags |= IORESOURCE_AUTO;
7735 if (dev->activate(dev) < 0) {
7736 printk("isapnp configure failed (out of resources?)\n");
7737 return -ENOMEM;
7738 }
7739
7740 result = check_region(dev->resource[0].start, 16);
7741 if (result) {
7742 printk(KERN_INFO "ixj: can't get I/O address 0x%lx\n", dev->resource[0].start);
7743 break;
7744 }
7745
7746 j = ixj_alloc();
7747 request_region(j->DSPbase, 16, "ixj DSP");
7748
7749 if (func != 0x110)
7750 j->XILINXbase = dev->resource[1].start; /* get real port */
7751
7752 switch (func) {
7753 case (0x110):
7754 j->cardtype = QTI_PHONEJACK;
7755 break;
7756 case (0x310):
7757 j->cardtype = QTI_LINEJACK;
7758 break;
7759 case (0x410):
7760 j->cardtype = QTI_PHONEJACK_LITE;
7761 break;
7762 }
7763 j->board = *cnt;
7764 probe = ixj_selfprobe(j);
7765 if(!probe) {
7766 j->serial = dev->bus->serial;
7767 j->dev = dev;
7768 switch (func) {
7769 case 0x110:
7770 printk(KERN_INFO "ixj: found Internet PhoneJACK at 0x%x\n", j->DSPbase);
7771 break;
7772 case 0x310:
7773 printk(KERN_INFO "ixj: found Internet LineJACK at 0x%x\n", j->DSPbase);
7774 break;
7775 case 0x410:
7776 printk(KERN_INFO "ixj: found Internet PhoneJACK Lite at 0x%x\n", j->DSPbase);
7777 break;
7778 }
7779 }
7780 ++*cnt;
7781 } while (dev);
7782 if (func == 0x410)
7783 break;
7784 if (func == 0x310)
7785 func = 0x410;
7786 if (func == 0x110)
7787 func = 0x310;
7788 dev = NULL;
7789 }
7790 return probe;
7791 }
7792
ixj_probe_isa(int * cnt)7793 int __init ixj_probe_isa(int *cnt)
7794 {
7795 int i, result, probe;
7796
7797 /* Use passed parameters for older kernels without PnP */
7798 for (i = 0; i < IXJMAX; i++) {
7799 if (dspio[i]) {
7800 IXJ *j;
7801
7802 if ((result = check_region(ixj[*cnt].DSPbase, 16)) < 0) {
7803 printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", ixj[*cnt].DSPbase);
7804 break;
7805 }
7806
7807 j = ixj_alloc();
7808
7809 j->DSPbase = dspio[i];
7810 request_region(j->DSPbase, 16, "ixj DSP");
7811
7812 j->XILINXbase = xio[i];
7813 j->cardtype = 0;
7814
7815 j->board = *cnt;
7816 probe = ixj_selfprobe(j);
7817 j->dev = NULL;
7818 ++*cnt;
7819 }
7820 }
7821 return 0;
7822 }
7823
ixj_probe_pci(int * cnt)7824 int __init ixj_probe_pci(int *cnt)
7825 {
7826 struct pci_dev *pci = NULL;
7827 int i, probe = 0;
7828 IXJ *j = NULL;
7829 int result;
7830
7831 if(!pci_present())
7832 return 0;
7833
7834 for (i = 0; i < IXJMAX - *cnt; i++) {
7835 pci = pci_find_device(0x15E2, 0x0500, pci);
7836 if (!pci)
7837 break;
7838
7839 if (pci_enable_device(pci))
7840 break;
7841 if ((result = check_region(pci_resource_start(pci, 0), 16)) < 0) {
7842 printk(KERN_INFO "ixj: can't get I/O address\n");
7843 break;
7844 }
7845
7846 /* Grab a device slot */
7847 j = ixj_alloc();
7848 if(j == NULL)
7849 break;
7850
7851 j->DSPbase = pci_resource_start(pci, 0);
7852 j->serial = (PCIEE_GetSerialNumber)pci_resource_start(pci, 2);
7853 j->XILINXbase = j->DSPbase + 0x10;
7854 request_region(j->DSPbase, 16, "ixj DSP");
7855 j->cardtype = QTI_PHONEJACK_PCI;
7856 j->board = *cnt;
7857 probe = ixj_selfprobe(j);
7858 if (!probe)
7859 printk(KERN_INFO "ixj: found Internet PhoneJACK PCI at 0x%x\n", j->DSPbase);
7860 ++*cnt;
7861 }
7862 return probe;
7863 }
7864
ixj_init(void)7865 int __init ixj_init(void)
7866 {
7867 int cnt = 0;
7868 int probe = 0;
7869
7870 cnt = 0;
7871
7872 /* These might be no-ops, see above. */
7873 if ((probe = ixj_probe_isapnp(&cnt)) < 0) {
7874 return probe;
7875 }
7876 if ((probe = ixj_probe_isa(&cnt)) < 0) {
7877 return probe;
7878 }
7879 if (pci_present()) {
7880 if ((probe = ixj_probe_pci(&cnt)) < 0) {
7881 return probe;
7882 }
7883 }
7884 printk("%s\n", ixj_c_rcsid);
7885 create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL);
7886 return probe;
7887 }
7888
7889 module_init(ixj_init);
7890 module_exit(ixj_exit);
7891
DAA_Coeff_US(IXJ * j)7892 static void DAA_Coeff_US(IXJ *j)
7893 {
7894 int i;
7895
7896 j->daa_country = DAA_US;
7897 /*----------------------------------------------- */
7898 /* CAO */
7899 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
7900 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
7901 }
7902
7903 /* Bytes for IM-filter part 1 (04): 0E,32,E2,2F,C2,5A,C0,00 */
7904 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x03;
7905 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0x4B;
7906 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x5D;
7907 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xCD;
7908 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x24;
7909 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xC5;
7910 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
7911 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
7912 /* Bytes for IM-filter part 2 (05): 72,85,00,0E,2B,3A,D0,08 */
7913 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x71;
7914 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x1A;
7915 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
7916 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
7917 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xB5;
7918 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
7919 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
7920 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
7921 /* Bytes for FRX-filter (08): 03,8F,48,F2,8F,48,70,08 */
7922 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x05;
7923 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xA3;
7924 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x72;
7925 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
7926 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x3F;
7927 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x3B;
7928 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
7929 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
7930 /* Bytes for FRR-filter (07): 04,8F,38,7F,9B,EA,B0,08 */
7931 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x05;
7932 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
7933 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
7934 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x3E;
7935 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x32;
7936 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xDA;
7937 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
7938 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
7939 /* Bytes for AX-filter (0A): 16,55,DD,CA */
7940 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x41;
7941 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
7942 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
7943 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
7944 /* Bytes for AR-filter (09): 52,D3,11,42 */
7945 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
7946 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
7947 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
7948 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
7949 /* Bytes for TH-filter part 1 (00): 00,42,48,81,B3,80,00,98 */
7950 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
7951 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
7952 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
7953 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
7954 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA5;
7955 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
7956 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
7957 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
7958 /* Bytes for TH-filter part 2 (01): 02,F2,33,A0,68,AB,8A,AD */
7959 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
7960 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xA2;
7961 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2B;
7962 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
7963 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
7964 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAB;
7965 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
7966 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xCC;
7967 /* Bytes for TH-filter part 3 (02): 00,88,DA,54,A4,BA,2D,BB */
7968 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
7969 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
7970 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xD2;
7971 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x24;
7972 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBA;
7973 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xA9;
7974 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x3B;
7975 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xA6;
7976 /* ; (10K, 0.68uF) */
7977 /* */
7978 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
7979 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
7980 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
7981 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
7982 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
7983 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
7984 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
7985 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
7986 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
7987 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
7988 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
7989 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
7990 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
7991 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
7992 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
7993 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
7994 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
7995 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
7996
7997 /* Levelmetering Ringing (0D):B2,45,0F,8E */
7998 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
7999 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
8000 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8001 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8002
8003 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
8004 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1C; */
8005 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0xB3; */
8006 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0xAB; */
8007 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xAB; */
8008 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x54; */
8009 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x2D; */
8010 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0x62; */
8011 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x2D; */
8012 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
8013 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x2D; */
8014 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x62; */
8015 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; */
8016 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBB; */
8017 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x2A; */
8018 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7D; */
8019 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; */
8020 /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD4; */
8021 /* */
8022 /* Levelmetering Ringing (0D):B2,45,0F,8E */
8023 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; */
8024 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x05; */
8025 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; */
8026 /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; */
8027
8028 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8029 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8030 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8031 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8032 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8033 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8034 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8035 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8036 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8037 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8038 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8039 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8040 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8041 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8042 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8043 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8044 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8045 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8046 /* */
8047 /* ;CR Registers */
8048 /* Config. Reg. 0 (filters) (cr0):FE ; CLK gen. by crystal */
8049 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8050 /* Config. Reg. 1 (dialing) (cr1):05 */
8051 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8052 /* Config. Reg. 2 (caller ID) (cr2):04 */
8053 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8054 /* Config. Reg. 3 (testloops) (cr3):03 ; SEL Bit==0, HP-disabled */
8055 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8056 /* Config. Reg. 4 (analog gain) (cr4):02 */
8057 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8058 /* Config. Reg. 5 (Version) (cr5):02 */
8059 /* Config. Reg. 6 (Reserved) (cr6):00 */
8060 /* Config. Reg. 7 (Reserved) (cr7):00 */
8061 /* */
8062 /* ;xr Registers */
8063 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8064
8065 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8066 /* Ext. Reg. 1 (Interrupt enable) (xr1):3C Cadence, RING, Caller ID, VDD_OK */
8067
8068 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x3C;
8069 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8070 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8071 /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off == 1 */
8072 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x3B; /*0x32; */
8073 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8074
8075 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8076 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8077 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8078 /* Ext. Reg. 6 (Power State) (xr6):00 */
8079 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8080 /* Ext. Reg. 7 (Vdd) (xr7):40 */
8081 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8082 /* */
8083 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8084 /* 12,33,5A,C3 ; 770 Hz */
8085 /* 13,3C,5B,32 ; 852 Hz */
8086 /* 1D,1B,5C,CC ; 941 Hz */
8087
8088 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8089 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8090 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8091 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8092 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8093 /* EC,1D,52,22 ; 1336 Hz */
8094 /* AA,AC,51,D2 ; 1477 Hz */
8095 /* 9B,3B,51,25 ; 1633 Hz */
8096 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8097 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8098 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8099 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8100 }
8101
DAA_Coeff_UK(IXJ * j)8102 static void DAA_Coeff_UK(IXJ *j)
8103 {
8104 int i;
8105
8106 j->daa_country = DAA_UK;
8107 /*----------------------------------------------- */
8108 /* CAO */
8109 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8110 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8111 }
8112
8113 /* Bytes for IM-filter part 1 (04): 00,C2,BB,A8,CB,81,A0,00 */
8114 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
8115 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xC2;
8116 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
8117 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xA8;
8118 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xCB;
8119 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
8120 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
8121 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8122 /* Bytes for IM-filter part 2 (05): 40,00,00,0A,A4,33,E0,08 */
8123 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x40;
8124 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x00;
8125 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8126 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A;
8127 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xA4;
8128 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8129 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8130 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8131 /* Bytes for FRX-filter (08): 07,9B,ED,24,B2,A2,A0,08 */
8132 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8133 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9B;
8134 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xED;
8135 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x24;
8136 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0xB2;
8137 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0xA2;
8138 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xA0;
8139 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8140 /* Bytes for FRR-filter (07): 0F,92,F2,B2,87,D2,30,08 */
8141 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
8142 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x92;
8143 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF2;
8144 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0xB2;
8145 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
8146 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xD2;
8147 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x30;
8148 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8149 /* Bytes for AX-filter (0A): 1B,A5,DD,CA */
8150 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x1B;
8151 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xA5;
8152 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8153 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8154 /* Bytes for AR-filter (09): E2,27,10,D6 */
8155 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
8156 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x27;
8157 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8158 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8159 /* Bytes for TH-filter part 1 (00): 80,2D,38,8B,D0,00,00,98 */
8160 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8161 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x2D;
8162 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x38;
8163 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x8B;
8164 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xD0;
8165 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x00;
8166 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8167 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8168 /* Bytes for TH-filter part 2 (01): 02,5A,53,F0,0B,5F,84,D4 */
8169 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8170 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x5A;
8171 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x53;
8172 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xF0;
8173 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x0B;
8174 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5F;
8175 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x84;
8176 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xD4;
8177 /* Bytes for TH-filter part 3 (02): 00,88,6A,A4,8F,52,F5,32 */
8178 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8179 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8180 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x6A;
8181 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA4;
8182 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x8F;
8183 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x52;
8184 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xF5;
8185 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x32;
8186 /* ; idle */
8187 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8188 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8189 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8190 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8191 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8192 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8193 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8194 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8195 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8196 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8197 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8198 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8199 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8200 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8201 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8202 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8203 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8204 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8205 /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V less possible? */
8206 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
8207 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
8208 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8209 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8210 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8211 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8212 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8213 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8214 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8215 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8216 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8217 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8218 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8219 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8220 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8221 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8222 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8223 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8224 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8225 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8226 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8227 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8228 /* ;CR Registers */
8229 /* Config. Reg. 0 (filters) (cr0):FF */
8230 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8231 /* Config. Reg. 1 (dialing) (cr1):05 */
8232 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8233 /* Config. Reg. 2 (caller ID) (cr2):04 */
8234 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8235 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8236 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8237 /* Config. Reg. 4 (analog gain) (cr4):02 */
8238 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8239 /* Config. Reg. 5 (Version) (cr5):02 */
8240 /* Config. Reg. 6 (Reserved) (cr6):00 */
8241 /* Config. Reg. 7 (Reserved) (cr7):00 */
8242 /* ;xr Registers */
8243 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8244
8245 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8246 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8247
8248 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8249 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8250
8251 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8252 /* Ext. Reg. 3 (DC Char) (xr3):36 ; */
8253 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
8254 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8255 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8256 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8257 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8258 /* Ext. Reg. 6 (Power State) (xr6):00 */
8259 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8260 /* Ext. Reg. 7 (Vdd) (xr7):46 */
8261 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
8262 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8263 /* 12,33,5A,C3 ; 770 Hz */
8264 /* 13,3C,5B,32 ; 852 Hz */
8265 /* 1D,1B,5C,CC ; 941 Hz */
8266
8267 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8268 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8269 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8270 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8271 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8272 /* EC,1D,52,22 ; 1336 Hz */
8273 /* AA,AC,51,D2 ; 1477 Hz */
8274 /* 9B,3B,51,25 ; 1633 Hz */
8275 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8276 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8277 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8278 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8279 }
8280
8281
DAA_Coeff_France(IXJ * j)8282 static void DAA_Coeff_France(IXJ *j)
8283 {
8284 int i;
8285
8286 j->daa_country = DAA_FRANCE;
8287 /*----------------------------------------------- */
8288 /* CAO */
8289 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8290 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8291 }
8292
8293 /* Bytes for IM-filter part 1 (04): 02,A2,43,2C,22,AF,A0,00 */
8294 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x02;
8295 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA2;
8296 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x43;
8297 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2C;
8298 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x22;
8299 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xAF;
8300 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
8301 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8302 /* Bytes for IM-filter part 2 (05): 67,CE,00,0C,22,33,E0,08 */
8303 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x67;
8304 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xCE;
8305 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8306 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x2C;
8307 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x22;
8308 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8309 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8310 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8311 /* Bytes for FRX-filter (08): 07,9A,28,F6,23,4A,B0,08 */
8312 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8313 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9A;
8314 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x28;
8315 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0xF6;
8316 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x23;
8317 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x4A;
8318 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xB0;
8319 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8320 /* Bytes for FRR-filter (07): 03,8F,F9,2F,9E,FA,20,08 */
8321 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
8322 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
8323 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9;
8324 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
8325 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9E;
8326 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xFA;
8327 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
8328 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8329 /* Bytes for AX-filter (0A): 16,B5,DD,CA */
8330 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x16;
8331 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5;
8332 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8333 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8334 /* Bytes for AR-filter (09): 52,C7,10,D6 */
8335 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2;
8336 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7;
8337 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8338 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8339 /* Bytes for TH-filter part 1 (00): 00,42,48,81,A6,80,00,98 */
8340 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
8341 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
8342 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8343 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8344 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA6;
8345 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8346 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8347 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8348 /* Bytes for TH-filter part 2 (01): 02,AC,2A,30,78,AC,8A,2C */
8349 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8350 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAC;
8351 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
8352 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x30;
8353 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x78;
8354 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAC;
8355 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x8A;
8356 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x2C;
8357 /* Bytes for TH-filter part 3 (02): 00,88,DA,A5,22,BA,2C,45 */
8358 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8359 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8360 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
8361 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA5;
8362 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x22;
8363 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xBA;
8364 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x2C;
8365 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x45;
8366 /* ; idle */
8367 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8368 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8369 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8370 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8371 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8372 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8373 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8374 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8375 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8376 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8377 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8378 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8379 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8380 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8381 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8382 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8383 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8384 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8385 /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
8386 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
8387 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8388 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
8389 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
8390 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8391 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8392 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8393 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8394 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8395 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8396 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8397 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8398 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8399 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8400 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8401 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8402 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8403 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8404 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8405 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8406 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8407 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8408 /* ;CR Registers */
8409 /* Config. Reg. 0 (filters) (cr0):FF */
8410 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8411 /* Config. Reg. 1 (dialing) (cr1):05 */
8412 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8413 /* Config. Reg. 2 (caller ID) (cr2):04 */
8414 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8415 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8416 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8417 /* Config. Reg. 4 (analog gain) (cr4):02 */
8418 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8419 /* Config. Reg. 5 (Version) (cr5):02 */
8420 /* Config. Reg. 6 (Reserved) (cr6):00 */
8421 /* Config. Reg. 7 (Reserved) (cr7):00 */
8422 /* ;xr Registers */
8423 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8424
8425 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8426 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8427
8428 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8429 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8430
8431 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8432 /* Ext. Reg. 3 (DC Char) (xr3):36 ; */
8433 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36;
8434 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8435 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8436 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8437 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8438 /* Ext. Reg. 6 (Power State) (xr6):00 */
8439 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8440 /* Ext. Reg. 7 (Vdd) (xr7):46 */
8441 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */
8442 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8443 /* 12,33,5A,C3 ; 770 Hz */
8444 /* 13,3C,5B,32 ; 852 Hz */
8445 /* 1D,1B,5C,CC ; 941 Hz */
8446
8447 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8448 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8449 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8450 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8451 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8452 /* EC,1D,52,22 ; 1336 Hz */
8453 /* AA,AC,51,D2 ; 1477 Hz */
8454 /* 9B,3B,51,25 ; 1633 Hz */
8455 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8456 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8457 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8458 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8459 }
8460
8461
DAA_Coeff_Germany(IXJ * j)8462 static void DAA_Coeff_Germany(IXJ *j)
8463 {
8464 int i;
8465
8466 j->daa_country = DAA_GERMANY;
8467 /*----------------------------------------------- */
8468 /* CAO */
8469 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8470 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8471 }
8472
8473 /* Bytes for IM-filter part 1 (04): 00,CE,BB,B8,D2,81,B0,00 */
8474 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
8475 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xCE;
8476 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB;
8477 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xB8;
8478 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xD2;
8479 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81;
8480 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xB0;
8481 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8482 /* Bytes for IM-filter part 2 (05): 45,8F,00,0C,D2,3A,D0,08 */
8483 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x45;
8484 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x8F;
8485 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8486 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0C;
8487 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xD2;
8488 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x3A;
8489 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xD0;
8490 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8491 /* Bytes for FRX-filter (08): 07,AA,E2,34,24,89,20,08 */
8492 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8493 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xAA;
8494 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
8495 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
8496 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x24;
8497 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x89;
8498 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x20;
8499 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8500 /* Bytes for FRR-filter (07): 02,87,FA,37,9A,CA,B0,08 */
8501 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x02;
8502 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87;
8503 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xFA;
8504 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x37;
8505 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9A;
8506 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCA;
8507 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0;
8508 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8509 /* Bytes for AX-filter (0A): 72,D5,DD,CA */
8510 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x72;
8511 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xD5;
8512 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8513 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8514 /* Bytes for AR-filter (09): 72,42,13,4B */
8515 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x72;
8516 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x42;
8517 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x13;
8518 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0x4B;
8519 /* Bytes for TH-filter part 1 (00): 80,52,48,81,AD,80,00,98 */
8520 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8521 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
8522 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8523 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8524 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAD;
8525 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8526 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8527 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8528 /* Bytes for TH-filter part 2 (01): 02,42,5A,20,E8,1A,81,27 */
8529 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8530 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x42;
8531 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x5A;
8532 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
8533 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8;
8534 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x1A;
8535 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81;
8536 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x27;
8537 /* Bytes for TH-filter part 3 (02): 00,88,63,26,BD,4B,A3,C2 */
8538 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8539 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8540 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x63;
8541 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x26;
8542 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBD;
8543 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x4B;
8544 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xA3;
8545 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xC2;
8546 /* ; (10K, 0.68uF) */
8547 /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */
8548 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8549 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3B;
8550 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x9B;
8551 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xBA;
8552 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0xD4;
8553 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x1C;
8554 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xB3;
8555 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8556 /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
8557 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x13;
8558 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x42;
8559 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8560 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8561 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0xD4;
8562 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x73;
8563 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0xCA;
8564 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8565 /* Levelmetering Ringing (0D):B2,45,0F,8E */
8566 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xB2;
8567 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8568 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8569 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8570 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8571 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8572 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8573 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8574 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8575 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8576 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8577 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8578 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8579 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8580 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8581 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8582 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8583 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8584 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8585 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8586 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8587 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8588 /* ;CR Registers */
8589 /* Config. Reg. 0 (filters) (cr0):FF ; all Filters enabled, CLK from ext. source */
8590 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8591 /* Config. Reg. 1 (dialing) (cr1):05 ; Manual Ring, Ring metering enabled */
8592 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8593 /* Config. Reg. 2 (caller ID) (cr2):04 ; Analog Gain 0dB, FSC internal */
8594 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8595 /* Config. Reg. 3 (testloops) (cr3):00 ; SEL Bit==0, HP-enabled */
8596 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8597 /* Config. Reg. 4 (analog gain) (cr4):02 */
8598 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8599 /* Config. Reg. 5 (Version) (cr5):02 */
8600 /* Config. Reg. 6 (Reserved) (cr6):00 */
8601 /* Config. Reg. 7 (Reserved) (cr7):00 */
8602 /* ;xr Registers */
8603 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8604
8605 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8606 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C ; Ring, CID, VDDOK Interrupts enabled */
8607
8608 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8609 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8610
8611 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8612 /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off==1, U0=3.5V, R=200Ohm */
8613 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x32;
8614 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8615 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8616 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8617 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8618 /* Ext. Reg. 6 (Power State) (xr6):00 */
8619 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8620 /* Ext. Reg. 7 (Vdd) (xr7):40 ; VDD=4.25 V */
8621 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8622 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8623 /* 12,33,5A,C3 ; 770 Hz */
8624 /* 13,3C,5B,32 ; 852 Hz */
8625 /* 1D,1B,5C,CC ; 941 Hz */
8626
8627 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8628 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8629 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8630 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8631 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8632 /* EC,1D,52,22 ; 1336 Hz */
8633 /* AA,AC,51,D2 ; 1477 Hz */
8634 /* 9B,3B,51,25 ; 1633 Hz */
8635 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8636 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8637 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8638 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8639 }
8640
8641
DAA_Coeff_Australia(IXJ * j)8642 static void DAA_Coeff_Australia(IXJ *j)
8643 {
8644 int i;
8645
8646 j->daa_country = DAA_AUSTRALIA;
8647 /*----------------------------------------------- */
8648 /* CAO */
8649 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8650 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8651 }
8652
8653 /* Bytes for IM-filter part 1 (04): 00,A3,AA,28,B3,82,D0,00 */
8654 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00;
8655 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA3;
8656 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xAA;
8657 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x28;
8658 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xB3;
8659 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x82;
8660 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xD0;
8661 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8662 /* Bytes for IM-filter part 2 (05): 70,96,00,09,32,6B,C0,08 */
8663 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x70;
8664 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x96;
8665 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8666 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x09;
8667 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x32;
8668 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x6B;
8669 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xC0;
8670 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8671 /* Bytes for FRX-filter (08): 07,96,E2,34,32,9B,30,08 */
8672 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07;
8673 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x96;
8674 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2;
8675 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34;
8676 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x32;
8677 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x9B;
8678 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30;
8679 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8680 /* Bytes for FRR-filter (07): 0F,9A,E9,2F,22,CC,A0,08 */
8681 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F;
8682 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x9A;
8683 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xE9;
8684 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F;
8685 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x22;
8686 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCC;
8687 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xA0;
8688 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8689 /* Bytes for AX-filter (0A): CB,45,DD,CA */
8690 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0xCB;
8691 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0x45;
8692 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8693 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8694 /* Bytes for AR-filter (09): 1B,67,10,D6 */
8695 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x1B;
8696 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x67;
8697 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8698 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8699 /* Bytes for TH-filter part 1 (00): 80,52,48,81,AF,80,00,98 */
8700 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80;
8701 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52;
8702 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8703 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8704 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAF;
8705 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8706 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8707 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8708 /* Bytes for TH-filter part 2 (01): 02,DB,52,B0,38,01,82,AC */
8709 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8710 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xDB;
8711 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x52;
8712 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0;
8713 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x38;
8714 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x01;
8715 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x82;
8716 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xAC;
8717 /* Bytes for TH-filter part 3 (02): 00,88,4A,3E,2C,3B,24,46 */
8718 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8719 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8720 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x4A;
8721 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x3E;
8722 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x2C;
8723 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x3B;
8724 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x24;
8725 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x46;
8726 /* ; idle */
8727 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8728 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8729 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8730 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8731 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8732 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8733 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8734 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8735 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8736 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8737 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8738 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8739 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8740 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8741 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8742 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8743 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8744 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8745 /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */
8746 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32;
8747 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45;
8748 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5;
8749 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84;
8750 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8751 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8752 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8753 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8754 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8755 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8756 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8757 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8758 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8759 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8760 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8761 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8762 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8763 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8764 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8765 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8766 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8767 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8768 /* ;CR Registers */
8769 /* Config. Reg. 0 (filters) (cr0):FF */
8770 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8771 /* Config. Reg. 1 (dialing) (cr1):05 */
8772 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8773 /* Config. Reg. 2 (caller ID) (cr2):04 */
8774 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8775 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8776 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8777 /* Config. Reg. 4 (analog gain) (cr4):02 */
8778 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8779 /* Config. Reg. 5 (Version) (cr5):02 */
8780 /* Config. Reg. 6 (Reserved) (cr6):00 */
8781 /* Config. Reg. 7 (Reserved) (cr7):00 */
8782 /* ;xr Registers */
8783 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8784
8785 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8786 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8787
8788 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8789 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8790
8791 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8792 /* Ext. Reg. 3 (DC Char) (xr3):2B ; */
8793 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x2B;
8794 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8795 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8796 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8797 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8798 /* Ext. Reg. 6 (Power State) (xr6):00 */
8799 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8800 /* Ext. Reg. 7 (Vdd) (xr7):40 */
8801 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8802
8803 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8804 /* 12,33,5A,C3 ; 770 Hz */
8805 /* 13,3C,5B,32 ; 852 Hz */
8806 /* 1D,1B,5C,CC ; 941 Hz */
8807 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8808 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8809 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8810 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8811
8812 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8813 /* EC,1D,52,22 ; 1336 Hz */
8814 /* AA,AC,51,D2 ; 1477 Hz */
8815 /* 9B,3B,51,25 ; 1633 Hz */
8816 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8817 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8818 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8819 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8820 }
8821
DAA_Coeff_Japan(IXJ * j)8822 static void DAA_Coeff_Japan(IXJ *j)
8823 {
8824 int i;
8825
8826 j->daa_country = DAA_JAPAN;
8827 /*----------------------------------------------- */
8828 /* CAO */
8829 for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) {
8830 j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0;
8831 }
8832
8833 /* Bytes for IM-filter part 1 (04): 06,BD,E2,2D,BA,F9,A0,00 */
8834 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x06;
8835 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xBD;
8836 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xE2;
8837 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2D;
8838 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xBA;
8839 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xF9;
8840 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0;
8841 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00;
8842 /* Bytes for IM-filter part 2 (05): 6F,F7,00,0E,34,33,E0,08 */
8843 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x6F;
8844 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xF7;
8845 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00;
8846 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0E;
8847 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x34;
8848 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33;
8849 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0;
8850 j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08;
8851 /* Bytes for FRX-filter (08): 02,8F,68,77,9C,58,F0,08 */
8852 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x02;
8853 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x8F;
8854 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x68;
8855 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x77;
8856 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x9C;
8857 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x58;
8858 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xF0;
8859 j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08;
8860 /* Bytes for FRR-filter (07): 03,8F,38,73,87,EA,20,08 */
8861 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03;
8862 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F;
8863 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0x38;
8864 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x73;
8865 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87;
8866 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xEA;
8867 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20;
8868 j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08;
8869 /* Bytes for AX-filter (0A): 51,C5,DD,CA */
8870 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x51;
8871 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xC5;
8872 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD;
8873 j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA;
8874 /* Bytes for AR-filter (09): 25,A7,10,D6 */
8875 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25;
8876 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xA7;
8877 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10;
8878 j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6;
8879 /* Bytes for TH-filter part 1 (00): 00,42,48,81,AE,80,00,98 */
8880 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00;
8881 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42;
8882 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48;
8883 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81;
8884 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAE;
8885 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80;
8886 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00;
8887 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98;
8888 /* Bytes for TH-filter part 2 (01): 02,AB,2A,20,99,5B,89,28 */
8889 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02;
8890 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAB;
8891 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A;
8892 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20;
8893 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x99;
8894 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5B;
8895 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x89;
8896 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x28;
8897 /* Bytes for TH-filter part 3 (02): 00,88,DA,25,34,C5,4C,BA */
8898 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00;
8899 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88;
8900 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA;
8901 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x25;
8902 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x34;
8903 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xC5;
8904 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x4C;
8905 j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xBA;
8906 /* ; idle */
8907 /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */
8908 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B;
8909 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C;
8910 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93;
8911 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A;
8912 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22;
8913 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12;
8914 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3;
8915 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23;
8916 /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */
8917 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12;
8918 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2;
8919 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6;
8920 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA;
8921 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22;
8922 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A;
8923 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A;
8924 j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5;
8925 /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V ????????? */
8926 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA;
8927 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35;
8928 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F;
8929 j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E;
8930 /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */
8931 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA;
8932 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E;
8933 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA;
8934 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09;
8935 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99;
8936 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99;
8937 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99;
8938 j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99;
8939 /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */
8940 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD;
8941 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5;
8942 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA;
8943 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07;
8944 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA;
8945 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00;
8946 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00;
8947 j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00;
8948 /* ;CR Registers */
8949 /* Config. Reg. 0 (filters) (cr0):FF */
8950 j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF;
8951 /* Config. Reg. 1 (dialing) (cr1):05 */
8952 j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05;
8953 /* Config. Reg. 2 (caller ID) (cr2):04 */
8954 j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04;
8955 /* Config. Reg. 3 (testloops) (cr3):00 ; */
8956 j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00;
8957 /* Config. Reg. 4 (analog gain) (cr4):02 */
8958 j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02;
8959 /* Config. Reg. 5 (Version) (cr5):02 */
8960 /* Config. Reg. 6 (Reserved) (cr6):00 */
8961 /* Config. Reg. 7 (Reserved) (cr7):00 */
8962 /* ;xr Registers */
8963 /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */
8964
8965 j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */
8966 /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */
8967
8968 j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */
8969 /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */
8970
8971 j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D;
8972 /* Ext. Reg. 3 (DC Char) (xr3):22 ; */
8973 j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x22;
8974 /* Ext. Reg. 4 (Cadence) (xr4):00 */
8975 j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00;
8976 /* Ext. Reg. 5 (Ring timer) (xr5):22 */
8977 j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22;
8978 /* Ext. Reg. 6 (Power State) (xr6):00 */
8979 j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00;
8980 /* Ext. Reg. 7 (Vdd) (xr7):40 */
8981 j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */
8982 /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */
8983 /* 12,33,5A,C3 ; 770 Hz */
8984 /* 13,3C,5B,32 ; 852 Hz */
8985 /* 1D,1B,5C,CC ; 941 Hz */
8986
8987 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11;
8988 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3;
8989 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A;
8990 j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C;
8991 /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */
8992 /* EC,1D,52,22 ; 1336 Hz */
8993 /* AA,AC,51,D2 ; 1477 Hz */
8994 /* 9B,3B,51,25 ; 1633 Hz */
8995 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32;
8996 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32;
8997 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52;
8998 j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3;
8999 }
9000
9001 static s16 tone_table[][19] =
9002 {
9003 { /* f20_50[] 11 */
9004 32538, /* A1 = 1.985962 */
9005 -32325, /* A2 = -0.986511 */
9006 -343, /* B2 = -0.010493 */
9007 0, /* B1 = 0 */
9008 343, /* B0 = 0.010493 */
9009 32619, /* A1 = 1.990906 */
9010 -32520, /* A2 = -0.992462 */
9011 19179, /* B2 = 0.585327 */
9012 -19178, /* B1 = -1.170593 */
9013 19179, /* B0 = 0.585327 */
9014 32723, /* A1 = 1.997314 */
9015 -32686, /* A2 = -0.997528 */
9016 9973, /* B2 = 0.304352 */
9017 -9955, /* B1 = -0.607605 */
9018 9973, /* B0 = 0.304352 */
9019 7, /* Internal filter scaling */
9020 159, /* Minimum in-band energy threshold */
9021 21, /* 21/32 in-band to broad-band ratio */
9022 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9023 },
9024 { /* f133_200[] 12 */
9025 32072, /* A1 = 1.95752 */
9026 -31896, /* A2 = -0.973419 */
9027 -435, /* B2 = -0.013294 */
9028 0, /* B1 = 0 */
9029 435, /* B0 = 0.013294 */
9030 32188, /* A1 = 1.9646 */
9031 -32400, /* A2 = -0.98877 */
9032 15139, /* B2 = 0.462036 */
9033 -14882, /* B1 = -0.908356 */
9034 15139, /* B0 = 0.462036 */
9035 32473, /* A1 = 1.981995 */
9036 -32524, /* A2 = -0.992584 */
9037 23200, /* B2 = 0.708008 */
9038 -23113, /* B1 = -1.410706 */
9039 23200, /* B0 = 0.708008 */
9040 7, /* Internal filter scaling */
9041 159, /* Minimum in-band energy threshold */
9042 21, /* 21/32 in-band to broad-band ratio */
9043 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9044 },
9045 { /* f300 13 */
9046 31769, /* A1 = -1.939026 */
9047 -32584, /* A2 = 0.994385 */
9048 -475, /* B2 = -0.014522 */
9049 0, /* B1 = 0.000000 */
9050 475, /* B0 = 0.014522 */
9051 31789, /* A1 = -1.940247 */
9052 -32679, /* A2 = 0.997284 */
9053 17280, /* B2 = 0.527344 */
9054 -16865, /* B1 = -1.029358 */
9055 17280, /* B0 = 0.527344 */
9056 31841, /* A1 = -1.943481 */
9057 -32681, /* A2 = 0.997345 */
9058 543, /* B2 = 0.016579 */
9059 -525, /* B1 = -0.032097 */
9060 543, /* B0 = 0.016579 */
9061 5, /* Internal filter scaling */
9062 159, /* Minimum in-band energy threshold */
9063 21, /* 21/32 in-band to broad-band ratio */
9064 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9065 },
9066 { /* f300_420[] 14 */
9067 30750, /* A1 = 1.876892 */
9068 -31212, /* A2 = -0.952515 */
9069 -804, /* B2 = -0.024541 */
9070 0, /* B1 = 0 */
9071 804, /* B0 = 0.024541 */
9072 30686, /* A1 = 1.872925 */
9073 -32145, /* A2 = -0.980988 */
9074 14747, /* B2 = 0.450043 */
9075 -13703, /* B1 = -0.836395 */
9076 14747, /* B0 = 0.450043 */
9077 31651, /* A1 = 1.931824 */
9078 -32321, /* A2 = -0.986389 */
9079 24425, /* B2 = 0.745422 */
9080 -23914, /* B1 = -1.459595 */
9081 24427, /* B0 = 0.745483 */
9082 7, /* Internal filter scaling */
9083 159, /* Minimum in-band energy threshold */
9084 21, /* 21/32 in-band to broad-band ratio */
9085 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9086 },
9087 { /* f330 15 */
9088 31613, /* A1 = -1.929565 */
9089 -32646, /* A2 = 0.996277 */
9090 -185, /* B2 = -0.005657 */
9091 0, /* B1 = 0.000000 */
9092 185, /* B0 = 0.005657 */
9093 31620, /* A1 = -1.929932 */
9094 -32713, /* A2 = 0.998352 */
9095 19253, /* B2 = 0.587585 */
9096 -18566, /* B1 = -1.133179 */
9097 19253, /* B0 = 0.587585 */
9098 31674, /* A1 = -1.933228 */
9099 -32715, /* A2 = 0.998413 */
9100 2575, /* B2 = 0.078590 */
9101 -2495, /* B1 = -0.152283 */
9102 2575, /* B0 = 0.078590 */
9103 5, /* Internal filter scaling */
9104 159, /* Minimum in-band energy threshold */
9105 21, /* 21/32 in-band to broad-band ratio */
9106 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9107 },
9108 { /* f300_425[] 16 */
9109 30741, /* A1 = 1.876282 */
9110 -31475, /* A2 = -0.960541 */
9111 -703, /* B2 = -0.021484 */
9112 0, /* B1 = 0 */
9113 703, /* B0 = 0.021484 */
9114 30688, /* A1 = 1.873047 */
9115 -32248, /* A2 = -0.984161 */
9116 14542, /* B2 = 0.443787 */
9117 -13523, /* B1 = -0.825439 */
9118 14542, /* B0 = 0.443817 */
9119 31494, /* A1 = 1.922302 */
9120 -32366, /* A2 = -0.987762 */
9121 21577, /* B2 = 0.658508 */
9122 -21013, /* B1 = -1.282532 */
9123 21577, /* B0 = 0.658508 */
9124 7, /* Internal filter scaling */
9125 159, /* Minimum in-band energy threshold */
9126 21, /* 21/32 in-band to broad-band ratio */
9127 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9128 },
9129 { /* f330_440[] 17 */
9130 30627, /* A1 = 1.869324 */
9131 -31338, /* A2 = -0.95636 */
9132 -843, /* B2 = -0.025749 */
9133 0, /* B1 = 0 */
9134 843, /* B0 = 0.025749 */
9135 30550, /* A1 = 1.864685 */
9136 -32221, /* A2 = -0.983337 */
9137 13594, /* B2 = 0.414886 */
9138 -12589, /* B1 = -0.768402 */
9139 13594, /* B0 = 0.414886 */
9140 31488, /* A1 = 1.921936 */
9141 -32358, /* A2 = -0.987518 */
9142 24684, /* B2 = 0.753296 */
9143 -24029, /* B1 = -1.466614 */
9144 24684, /* B0 = 0.753296 */
9145 7, /* Internal filter scaling */
9146 159, /* Minimum in-band energy threshold */
9147 21, /* 21/32 in-band to broad-band ratio */
9148 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9149 },
9150 { /* f340 18 */
9151 31546, /* A1 = -1.925476 */
9152 -32646, /* A2 = 0.996277 */
9153 -445, /* B2 = -0.013588 */
9154 0, /* B1 = 0.000000 */
9155 445, /* B0 = 0.013588 */
9156 31551, /* A1 = -1.925781 */
9157 -32713, /* A2 = 0.998352 */
9158 23884, /* B2 = 0.728882 */
9159 -22979, /* B1 = -1.402527 */
9160 23884, /* B0 = 0.728882 */
9161 31606, /* A1 = -1.929138 */
9162 -32715, /* A2 = 0.998413 */
9163 863, /* B2 = 0.026367 */
9164 -835, /* B1 = -0.050985 */
9165 863, /* B0 = 0.026367 */
9166 5, /* Internal filter scaling */
9167 159, /* Minimum in-band energy threshold */
9168 21, /* 21/32 in-band to broad-band ratio */
9169 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9170 },
9171 { /* f350_400[] 19 */
9172 31006, /* A1 = 1.892517 */
9173 -32029, /* A2 = -0.977448 */
9174 -461, /* B2 = -0.014096 */
9175 0, /* B1 = 0 */
9176 461, /* B0 = 0.014096 */
9177 30999, /* A1 = 1.892029 */
9178 -32487, /* A2 = -0.991455 */
9179 11325, /* B2 = 0.345612 */
9180 -10682, /* B1 = -0.651978 */
9181 11325, /* B0 = 0.345612 */
9182 31441, /* A1 = 1.919067 */
9183 -32526, /* A2 = -0.992615 */
9184 24324, /* B2 = 0.74231 */
9185 -23535, /* B1 = -1.436523 */
9186 24324, /* B0 = 0.74231 */
9187 7, /* Internal filter scaling */
9188 159, /* Minimum in-band energy threshold */
9189 21, /* 21/32 in-band to broad-band ratio */
9190 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9191 },
9192 { /* f350_440[] */
9193 30634, /* A1 = 1.869751 */
9194 -31533, /* A2 = -0.962341 */
9195 -680, /* B2 = -0.020782 */
9196 0, /* B1 = 0 */
9197 680, /* B0 = 0.020782 */
9198 30571, /* A1 = 1.865906 */
9199 -32277, /* A2 = -0.985016 */
9200 12894, /* B2 = 0.393524 */
9201 -11945, /* B1 = -0.729065 */
9202 12894, /* B0 = 0.393524 */
9203 31367, /* A1 = 1.91449 */
9204 -32379, /* A2 = -0.988129 */
9205 23820, /* B2 = 0.726929 */
9206 -23104, /* B1 = -1.410217 */
9207 23820, /* B0 = 0.726929 */
9208 7, /* Internal filter scaling */
9209 159, /* Minimum in-band energy threshold */
9210 21, /* 21/32 in-band to broad-band ratio */
9211 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9212 },
9213 { /* f350_450[] */
9214 30552, /* A1 = 1.864807 */
9215 -31434, /* A2 = -0.95929 */
9216 -690, /* B2 = -0.021066 */
9217 0, /* B1 = 0 */
9218 690, /* B0 = 0.021066 */
9219 30472, /* A1 = 1.859924 */
9220 -32248, /* A2 = -0.984161 */
9221 13385, /* B2 = 0.408478 */
9222 -12357, /* B1 = -0.754242 */
9223 13385, /* B0 = 0.408478 */
9224 31358, /* A1 = 1.914001 */
9225 -32366, /* A2 = -0.987732 */
9226 26488, /* B2 = 0.80835 */
9227 -25692, /* B1 = -1.568176 */
9228 26490, /* B0 = 0.808411 */
9229 7, /* Internal filter scaling */
9230 159, /* Minimum in-band energy threshold */
9231 21, /* 21/32 in-band to broad-band ratio */
9232 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9233 },
9234 { /* f360 */
9235 31397, /* A1 = -1.916321 */
9236 -32623, /* A2 = 0.995605 */
9237 -117, /* B2 = -0.003598 */
9238 0, /* B1 = 0.000000 */
9239 117, /* B0 = 0.003598 */
9240 31403, /* A1 = -1.916687 */
9241 -32700, /* A2 = 0.997925 */
9242 3388, /* B2 = 0.103401 */
9243 -3240, /* B1 = -0.197784 */
9244 3388, /* B0 = 0.103401 */
9245 31463, /* A1 = -1.920410 */
9246 -32702, /* A2 = 0.997986 */
9247 13346, /* B2 = 0.407288 */
9248 -12863, /* B1 = -0.785126 */
9249 13346, /* B0 = 0.407288 */
9250 5, /* Internal filter scaling */
9251 159, /* Minimum in-band energy threshold */
9252 21, /* 21/32 in-band to broad-band ratio */
9253 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9254 },
9255 { /* f380_420[] */
9256 30831, /* A1 = 1.881775 */
9257 -32064, /* A2 = -0.978546 */
9258 -367, /* B2 = -0.01122 */
9259 0, /* B1 = 0 */
9260 367, /* B0 = 0.01122 */
9261 30813, /* A1 = 1.880737 */
9262 -32456, /* A2 = -0.990509 */
9263 11068, /* B2 = 0.337769 */
9264 -10338, /* B1 = -0.631042 */
9265 11068, /* B0 = 0.337769 */
9266 31214, /* A1 = 1.905212 */
9267 -32491, /* A2 = -0.991577 */
9268 16374, /* B2 = 0.499695 */
9269 -15781, /* B1 = -0.963196 */
9270 16374, /* B0 = 0.499695 */
9271 7, /* Internal filter scaling */
9272 159, /* Minimum in-band energy threshold */
9273 21, /* 21/32 in-band to broad-band ratio */
9274 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9275 },
9276 { /* f392 */
9277 31152, /* A1 = -1.901428 */
9278 -32613, /* A2 = 0.995300 */
9279 -314, /* B2 = -0.009605 */
9280 0, /* B1 = 0.000000 */
9281 314, /* B0 = 0.009605 */
9282 31156, /* A1 = -1.901672 */
9283 -32694, /* A2 = 0.997742 */
9284 28847, /* B2 = 0.880371 */
9285 -2734, /* B1 = -0.166901 */
9286 28847, /* B0 = 0.880371 */
9287 31225, /* A1 = -1.905823 */
9288 -32696, /* A2 = 0.997803 */
9289 462, /* B2 = 0.014108 */
9290 -442, /* B1 = -0.027019 */
9291 462, /* B0 = 0.014108 */
9292 5, /* Internal filter scaling */
9293 159, /* Minimum in-band energy threshold */
9294 21, /* 21/32 in-band to broad-band ratio */
9295 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9296 },
9297 { /* f400_425[] */
9298 30836, /* A1 = 1.882141 */
9299 -32296, /* A2 = -0.985596 */
9300 -324, /* B2 = -0.009903 */
9301 0, /* B1 = 0 */
9302 324, /* B0 = 0.009903 */
9303 30825, /* A1 = 1.881409 */
9304 -32570, /* A2 = -0.993958 */
9305 16847, /* B2 = 0.51416 */
9306 -15792, /* B1 = -0.963898 */
9307 16847, /* B0 = 0.51416 */
9308 31106, /* A1 = 1.89856 */
9309 -32584, /* A2 = -0.994415 */
9310 9579, /* B2 = 0.292328 */
9311 -9164, /* B1 = -0.559357 */
9312 9579, /* B0 = 0.292328 */
9313 7, /* Internal filter scaling */
9314 159, /* Minimum in-band energy threshold */
9315 21, /* 21/32 in-band to broad-band ratio */
9316 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9317 },
9318 { /* f400_440[] */
9319 30702, /* A1 = 1.873962 */
9320 -32134, /* A2 = -0.980682 */
9321 -517, /* B2 = -0.015793 */
9322 0, /* B1 = 0 */
9323 517, /* B0 = 0.015793 */
9324 30676, /* A1 = 1.872375 */
9325 -32520, /* A2 = -0.992462 */
9326 8144, /* B2 = 0.24855 */
9327 -7596, /* B1 = -0.463684 */
9328 8144, /* B0 = 0.24855 */
9329 31084, /* A1 = 1.897217 */
9330 -32547, /* A2 = -0.993256 */
9331 22713, /* B2 = 0.693176 */
9332 -21734, /* B1 = -1.326599 */
9333 22713, /* B0 = 0.693176 */
9334 7, /* Internal filter scaling */
9335 159, /* Minimum in-band energy threshold */
9336 21, /* 21/32 in-band to broad-band ratio */
9337 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9338 },
9339 { /* f400_450[] */
9340 30613, /* A1 = 1.86853 */
9341 -32031, /* A2 = -0.977509 */
9342 -618, /* B2 = -0.018866 */
9343 0, /* B1 = 0 */
9344 618, /* B0 = 0.018866 */
9345 30577, /* A1 = 1.866272 */
9346 -32491, /* A2 = -0.991577 */
9347 9612, /* B2 = 0.293335 */
9348 -8935, /* B1 = -0.54541 */
9349 9612, /* B0 = 0.293335 */
9350 31071, /* A1 = 1.896484 */
9351 -32524, /* A2 = -0.992584 */
9352 21596, /* B2 = 0.659058 */
9353 -20667, /* B1 = -1.261414 */
9354 21596, /* B0 = 0.659058 */
9355 7, /* Internal filter scaling */
9356 159, /* Minimum in-band energy threshold */
9357 21, /* 21/32 in-band to broad-band ratio */
9358 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9359 },
9360 { /* f420 */
9361 30914, /* A1 = -1.886841 */
9362 -32584, /* A2 = 0.994385 */
9363 -426, /* B2 = -0.013020 */
9364 0, /* B1 = 0.000000 */
9365 426, /* B0 = 0.013020 */
9366 30914, /* A1 = -1.886841 */
9367 -32679, /* A2 = 0.997314 */
9368 17520, /* B2 = 0.534668 */
9369 -16471, /* B1 = -1.005310 */
9370 17520, /* B0 = 0.534668 */
9371 31004, /* A1 = -1.892334 */
9372 -32683, /* A2 = 0.997406 */
9373 819, /* B2 = 0.025023 */
9374 -780, /* B1 = -0.047619 */
9375 819, /* B0 = 0.025023 */
9376 5, /* Internal filter scaling */
9377 159, /* Minimum in-band energy threshold */
9378 21, /* 21/32 in-band to broad-band ratio */
9379 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9380 },
9381 #if 0
9382 { /* f425 */
9383 30881, /* A1 = -1.884827 */
9384 -32603, /* A2 = 0.994965 */
9385 -496, /* B2 = -0.015144 */
9386 0, /* B1 = 0.000000 */
9387 496, /* B0 = 0.015144 */
9388 30880, /* A1 = -1.884766 */
9389 -32692, /* A2 = 0.997711 */
9390 24767, /* B2 = 0.755859 */
9391 -23290, /* B1 = -1.421509 */
9392 24767, /* B0 = 0.755859 */
9393 30967, /* A1 = -1.890076 */
9394 -32694, /* A2 = 0.997772 */
9395 728, /* B2 = 0.022232 */
9396 -691, /* B1 = -0.042194 */
9397 728, /* B0 = 0.022232 */
9398 5, /* Internal filter scaling */
9399 159, /* Minimum in-band energy threshold */
9400 21, /* 21/32 in-band to broad-band ratio */
9401 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9402 },
9403 #else
9404 {
9405 30850,
9406 -32534,
9407 -504,
9408 0,
9409 504,
9410 30831,
9411 -32669,
9412 24303,
9413 -22080,
9414 24303,
9415 30994,
9416 -32673,
9417 1905,
9418 -1811,
9419 1905,
9420 5,
9421 129,
9422 17,
9423 0xff5
9424 },
9425 #endif
9426 { /* f425_450[] */
9427 30646, /* A1 = 1.870544 */
9428 -32327, /* A2 = -0.986572 */
9429 -287, /* B2 = -0.008769 */
9430 0, /* B1 = 0 */
9431 287, /* B0 = 0.008769 */
9432 30627, /* A1 = 1.869324 */
9433 -32607, /* A2 = -0.995087 */
9434 13269, /* B2 = 0.404968 */
9435 -12376, /* B1 = -0.755432 */
9436 13269, /* B0 = 0.404968 */
9437 30924, /* A1 = 1.887512 */
9438 -32619, /* A2 = -0.995453 */
9439 19950, /* B2 = 0.608826 */
9440 -18940, /* B1 = -1.156006 */
9441 19950, /* B0 = 0.608826 */
9442 7, /* Internal filter scaling */
9443 159, /* Minimum in-band energy threshold */
9444 21, /* 21/32 in-band to broad-band ratio */
9445 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9446 },
9447 { /* f425_475[] */
9448 30396, /* A1 = 1.855225 */
9449 -32014, /* A2 = -0.97699 */
9450 -395, /* B2 = -0.012055 */
9451 0, /* B1 = 0 */
9452 395, /* B0 = 0.012055 */
9453 30343, /* A1 = 1.85199 */
9454 -32482, /* A2 = -0.991302 */
9455 17823, /* B2 = 0.543945 */
9456 -16431, /* B1 = -1.002869 */
9457 17823, /* B0 = 0.543945 */
9458 30872, /* A1 = 1.884338 */
9459 -32516, /* A2 = -0.99231 */
9460 18124, /* B2 = 0.553101 */
9461 -17246, /* B1 = -1.052673 */
9462 18124, /* B0 = 0.553101 */
9463 7, /* Internal filter scaling */
9464 159, /* Minimum in-band energy threshold */
9465 21, /* 21/32 in-band to broad-band ratio */
9466 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9467 },
9468 { /* f435 */
9469 30796, /* A1 = -1.879639 */
9470 -32603, /* A2 = 0.994965 */
9471 -254, /* B2 = -0.007762 */
9472 0, /* B1 = 0.000000 */
9473 254, /* B0 = 0.007762 */
9474 30793, /* A1 = -1.879456 */
9475 -32692, /* A2 = 0.997711 */
9476 18934, /* B2 = 0.577820 */
9477 -17751, /* B1 = -1.083496 */
9478 18934, /* B0 = 0.577820 */
9479 30882, /* A1 = -1.884888 */
9480 -32694, /* A2 = 0.997772 */
9481 1858, /* B2 = 0.056713 */
9482 -1758, /* B1 = -0.107357 */
9483 1858, /* B0 = 0.056713 */
9484 5, /* Internal filter scaling */
9485 159, /* Minimum in-band energy threshold */
9486 21, /* 21/32 in-band to broad-band ratio */
9487 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9488 },
9489 { /* f440_450[] */
9490 30641, /* A1 = 1.870239 */
9491 -32458, /* A2 = -0.99057 */
9492 -155, /* B2 = -0.004735 */
9493 0, /* B1 = 0 */
9494 155, /* B0 = 0.004735 */
9495 30631, /* A1 = 1.869568 */
9496 -32630, /* A2 = -0.995789 */
9497 11453, /* B2 = 0.349548 */
9498 -10666, /* B1 = -0.651001 */
9499 11453, /* B0 = 0.349548 */
9500 30810, /* A1 = 1.880554 */
9501 -32634, /* A2 = -0.995941 */
9502 12237, /* B2 = 0.373474 */
9503 -11588, /* B1 = -0.707336 */
9504 12237, /* B0 = 0.373474 */
9505 7, /* Internal filter scaling */
9506 159, /* Minimum in-band energy threshold */
9507 21, /* 21/32 in-band to broad-band ratio */
9508 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9509 },
9510 { /* f440_480[] */
9511 30367, /* A1 = 1.853455 */
9512 -32147, /* A2 = -0.981079 */
9513 -495, /* B2 = -0.015113 */
9514 0, /* B1 = 0 */
9515 495, /* B0 = 0.015113 */
9516 30322, /* A1 = 1.850769 */
9517 -32543, /* A2 = -0.993134 */
9518 10031, /* B2 = 0.306152 */
9519 -9252, /* B1 = -0.564728 */
9520 10031, /* B0 = 0.306152 */
9521 30770, /* A1 = 1.878052 */
9522 -32563, /* A2 = -0.993774 */
9523 22674, /* B2 = 0.691956 */
9524 -21465, /* B1 = -1.31012 */
9525 22674, /* B0 = 0.691956 */
9526 7, /* Internal filter scaling */
9527 159, /* Minimum in-band energy threshold */
9528 21, /* 21/32 in-band to broad-band ratio */
9529 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9530 },
9531 { /* f445 */
9532 30709, /* A1 = -1.874329 */
9533 -32603, /* A2 = 0.994965 */
9534 -83, /* B2 = -0.002545 */
9535 0, /* B1 = 0.000000 */
9536 83, /* B0 = 0.002545 */
9537 30704, /* A1 = -1.874084 */
9538 -32692, /* A2 = 0.997711 */
9539 10641, /* B2 = 0.324738 */
9540 -9947, /* B1 = -0.607147 */
9541 10641, /* B0 = 0.324738 */
9542 30796, /* A1 = -1.879639 */
9543 -32694, /* A2 = 0.997772 */
9544 10079, /* B2 = 0.307587 */
9545 9513, /* B1 = 0.580688 */
9546 10079, /* B0 = 0.307587 */
9547 5, /* Internal filter scaling */
9548 159, /* Minimum in-band energy threshold */
9549 21, /* 21/32 in-band to broad-band ratio */
9550 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9551 },
9552 { /* f450 */
9553 30664, /* A1 = -1.871643 */
9554 -32603, /* A2 = 0.994965 */
9555 -164, /* B2 = -0.005029 */
9556 0, /* B1 = 0.000000 */
9557 164, /* B0 = 0.005029 */
9558 30661, /* A1 = -1.871399 */
9559 -32692, /* A2 = 0.997711 */
9560 15294, /* B2 = 0.466736 */
9561 -14275, /* B1 = -0.871307 */
9562 15294, /* B0 = 0.466736 */
9563 30751, /* A1 = -1.876953 */
9564 -32694, /* A2 = 0.997772 */
9565 3548, /* B2 = 0.108284 */
9566 -3344, /* B1 = -0.204155 */
9567 3548, /* B0 = 0.108284 */
9568 5, /* Internal filter scaling */
9569 159, /* Minimum in-band energy threshold */
9570 21, /* 21/32 in-band to broad-band ratio */
9571 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9572 },
9573 { /* f452 */
9574 30653, /* A1 = -1.870911 */
9575 -32615, /* A2 = 0.995361 */
9576 -209, /* B2 = -0.006382 */
9577 0, /* B1 = 0.000000 */
9578 209, /* B0 = 0.006382 */
9579 30647, /* A1 = -1.870605 */
9580 -32702, /* A2 = 0.997986 */
9581 18971, /* B2 = 0.578979 */
9582 -17716, /* B1 = -1.081299 */
9583 18971, /* B0 = 0.578979 */
9584 30738, /* A1 = -1.876099 */
9585 -32702, /* A2 = 0.998016 */
9586 2967, /* B2 = 0.090561 */
9587 -2793, /* B1 = -0.170502 */
9588 2967, /* B0 = 0.090561 */
9589 5, /* Internal filter scaling */
9590 159, /* Minimum in-band energy threshold */
9591 21, /* 21/32 in-band to broad-band ratio */
9592 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9593 },
9594 { /* f475 */
9595 30437, /* A1 = -1.857727 */
9596 -32603, /* A2 = 0.994965 */
9597 -264, /* B2 = -0.008062 */
9598 0, /* B1 = 0.000000 */
9599 264, /* B0 = 0.008062 */
9600 30430, /* A1 = -1.857300 */
9601 -32692, /* A2 = 0.997711 */
9602 21681, /* B2 = 0.661682 */
9603 -20082, /* B1 = -1.225708 */
9604 21681, /* B0 = 0.661682 */
9605 30526, /* A1 = -1.863220 */
9606 -32694, /* A2 = 0.997742 */
9607 1559, /* B2 = 0.047600 */
9608 -1459, /* B1 = -0.089096 */
9609 1559, /* B0 = 0.047600 */
9610 5, /* Internal filter scaling */
9611 159, /* Minimum in-band energy threshold */
9612 21, /* 21/32 in-band to broad-band ratio */
9613 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9614 },
9615 { /* f480_620[] */
9616 28975, /* A1 = 1.768494 */
9617 -30955, /* A2 = -0.944672 */
9618 -1026, /* B2 = -0.03133 */
9619 0, /* B1 = 0 */
9620 1026, /* B0 = 0.03133 */
9621 28613, /* A1 = 1.746399 */
9622 -32089, /* A2 = -0.979309 */
9623 14214, /* B2 = 0.433807 */
9624 -12202, /* B1 = -0.744812 */
9625 14214, /* B0 = 0.433807 */
9626 30243, /* A1 = 1.845947 */
9627 -32238, /* A2 = -0.983856 */
9628 24825, /* B2 = 0.757629 */
9629 -23402, /* B1 = -1.428345 */
9630 24825, /* B0 = 0.757629 */
9631 7, /* Internal filter scaling */
9632 159, /* Minimum in-band energy threshold */
9633 21, /* 21/32 in-band to broad-band ratio */
9634 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9635 },
9636 { /* f494 */
9637 30257, /* A1 = -1.846741 */
9638 -32605, /* A2 = 0.995056 */
9639 -249, /* B2 = -0.007625 */
9640 0, /* B1 = 0.000000 */
9641 249, /* B0 = 0.007625 */
9642 30247, /* A1 = -1.846191 */
9643 -32694, /* A2 = 0.997772 */
9644 18088, /* B2 = 0.552002 */
9645 -16652, /* B1 = -1.016418 */
9646 18088, /* B0 = 0.552002 */
9647 30348, /* A1 = -1.852295 */
9648 -32696, /* A2 = 0.997803 */
9649 2099, /* B2 = 0.064064 */
9650 -1953, /* B1 = -0.119202 */
9651 2099, /* B0 = 0.064064 */
9652 5, /* Internal filter scaling */
9653 159, /* Minimum in-band energy threshold */
9654 21, /* 21/32 in-band to broad-band ratio */
9655 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9656 },
9657 { /* f500 */
9658 30202, /* A1 = -1.843431 */
9659 -32624, /* A2 = 0.995622 */
9660 -413, /* B2 = -0.012622 */
9661 0, /* B1 = 0.000000 */
9662 413, /* B0 = 0.012622 */
9663 30191, /* A1 = -1.842721 */
9664 -32714, /* A2 = 0.998364 */
9665 25954, /* B2 = 0.792057 */
9666 -23890, /* B1 = -1.458131 */
9667 25954, /* B0 = 0.792057 */
9668 30296, /* A1 = -1.849172 */
9669 -32715, /* A2 = 0.998397 */
9670 2007, /* B2 = 0.061264 */
9671 -1860, /* B1 = -0.113568 */
9672 2007, /* B0 = 0.061264 */
9673 5, /* Internal filter scaling */
9674 159, /* Minimum in-band energy threshold */
9675 21, /* 21/32 in-band to broad-band ratio */
9676 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9677 },
9678 { /* f520 */
9679 30001, /* A1 = -1.831116 */
9680 -32613, /* A2 = 0.995270 */
9681 -155, /* B2 = -0.004750 */
9682 0, /* B1 = 0.000000 */
9683 155, /* B0 = 0.004750 */
9684 29985, /* A1 = -1.830200 */
9685 -32710, /* A2 = 0.998260 */
9686 6584, /* B2 = 0.200928 */
9687 -6018, /* B1 = -0.367355 */
9688 6584, /* B0 = 0.200928 */
9689 30105, /* A1 = -1.837524 */
9690 -32712, /* A2 = 0.998291 */
9691 23812, /* B2 = 0.726685 */
9692 -21936, /* B1 = -1.338928 */
9693 23812, /* B0 = 0.726685 */
9694 5, /* Internal filter scaling */
9695 159, /* Minimum in-band energy threshold */
9696 21, /* 21/32 in-band to broad-band ratio */
9697 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9698 },
9699 { /* f523 */
9700 29964, /* A1 = -1.828918 */
9701 -32601, /* A2 = 0.994904 */
9702 -101, /* B2 = -0.003110 */
9703 0, /* B1 = 0.000000 */
9704 101, /* B0 = 0.003110 */
9705 29949, /* A1 = -1.827942 */
9706 -32700, /* A2 = 0.997925 */
9707 11041, /* B2 = 0.336975 */
9708 -10075, /* B1 = -0.614960 */
9709 11041, /* B0 = 0.336975 */
9710 30070, /* A1 = -1.835388 */
9711 -32702, /* A2 = 0.997986 */
9712 16762, /* B2 = 0.511536 */
9713 -15437, /* B1 = -0.942230 */
9714 16762, /* B0 = 0.511536 */
9715 5, /* Internal filter scaling */
9716 159, /* Minimum in-band energy threshold */
9717 21, /* 21/32 in-band to broad-band ratio */
9718 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9719 },
9720 { /* f525 */
9721 29936, /* A1 = -1.827209 */
9722 -32584, /* A2 = 0.994415 */
9723 -91, /* B2 = -0.002806 */
9724 0, /* B1 = 0.000000 */
9725 91, /* B0 = 0.002806 */
9726 29921, /* A1 = -1.826233 */
9727 -32688, /* A2 = 0.997559 */
9728 11449, /* B2 = 0.349396 */
9729 -10426, /* B1 = -0.636383 */
9730 11449, /* B0 = 0.349396 */
9731 30045, /* A1 = -1.833862 */
9732 -32688, /* A2 = 0.997589 */
9733 13055, /* B2 = 0.398407 */
9734 -12028, /* B1 = -0.734161 */
9735 13055, /* B0 = 0.398407 */
9736 5, /* Internal filter scaling */
9737 159, /* Minimum in-band energy threshold */
9738 21, /* 21/32 in-band to broad-band ratio */
9739 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9740 },
9741 { /* f540_660[] */
9742 28499, /* A1 = 1.739441 */
9743 -31129, /* A2 = -0.949982 */
9744 -849, /* B2 = -0.025922 */
9745 0, /* B1 = 0 */
9746 849, /* B0 = 0.025922 */
9747 28128, /* A1 = 1.716797 */
9748 -32130, /* A2 = -0.98056 */
9749 14556, /* B2 = 0.444214 */
9750 -12251, /* B1 = -0.747772 */
9751 14556, /* B0 = 0.444244 */
9752 29667, /* A1 = 1.81073 */
9753 -32244, /* A2 = -0.984039 */
9754 23038, /* B2 = 0.703064 */
9755 -21358, /* B1 = -1.303589 */
9756 23040, /* B0 = 0.703125 */
9757 7, /* Internal filter scaling */
9758 159, /* Minimum in-band energy threshold */
9759 21, /* 21/32 in-band to broad-band ratio */
9760 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9761 },
9762 { /* f587 */
9763 29271, /* A1 = -1.786560 */
9764 -32599, /* A2 = 0.994873 */
9765 -490, /* B2 = -0.014957 */
9766 0, /* B1 = 0.000000 */
9767 490, /* B0 = 0.014957 */
9768 29246, /* A1 = -1.785095 */
9769 -32700, /* A2 = 0.997925 */
9770 28961, /* B2 = 0.883850 */
9771 -25796, /* B1 = -1.574463 */
9772 28961, /* B0 = 0.883850 */
9773 29383, /* A1 = -1.793396 */
9774 -32700, /* A2 = 0.997955 */
9775 1299, /* B2 = 0.039650 */
9776 -1169, /* B1 = -0.071396 */
9777 1299, /* B0 = 0.039650 */
9778 5, /* Internal filter scaling */
9779 159, /* Minimum in-band energy threshold */
9780 21, /* 21/32 in-band to broad-band ratio */
9781 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9782 },
9783 { /* f590 */
9784 29230, /* A1 = -1.784058 */
9785 -32584, /* A2 = 0.994415 */
9786 -418, /* B2 = -0.012757 */
9787 0, /* B1 = 0.000000 */
9788 418, /* B0 = 0.012757 */
9789 29206, /* A1 = -1.782593 */
9790 -32688, /* A2 = 0.997559 */
9791 36556, /* B2 = 1.115601 */
9792 -32478, /* B1 = -1.982300 */
9793 36556, /* B0 = 1.115601 */
9794 29345, /* A1 = -1.791077 */
9795 -32688, /* A2 = 0.997589 */
9796 897, /* B2 = 0.027397 */
9797 -808, /* B1 = -0.049334 */
9798 897, /* B0 = 0.027397 */
9799 5, /* Internal filter scaling */
9800 159, /* Minimum in-band energy threshold */
9801 21, /* 21/32 in-band to broad-band ratio */
9802 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9803 },
9804 { /* f600 */
9805 29116, /* A1 = -1.777100 */
9806 -32603, /* A2 = 0.994965 */
9807 -165, /* B2 = -0.005039 */
9808 0, /* B1 = 0.000000 */
9809 165, /* B0 = 0.005039 */
9810 29089, /* A1 = -1.775452 */
9811 -32708, /* A2 = 0.998199 */
9812 6963, /* B2 = 0.212494 */
9813 -6172, /* B1 = -0.376770 */
9814 6963, /* B0 = 0.212494 */
9815 29237, /* A1 = -1.784485 */
9816 -32710, /* A2 = 0.998230 */
9817 24197, /* B2 = 0.738464 */
9818 -21657, /* B1 = -1.321899 */
9819 24197, /* B0 = 0.738464 */
9820 5, /* Internal filter scaling */
9821 159, /* Minimum in-band energy threshold */
9822 21, /* 21/32 in-band to broad-band ratio */
9823 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9824 },
9825 { /* f660 */
9826 28376, /* A1 = -1.731934 */
9827 -32567, /* A2 = 0.993896 */
9828 -363, /* B2 = -0.011102 */
9829 0, /* B1 = 0.000000 */
9830 363, /* B0 = 0.011102 */
9831 28337, /* A1 = -1.729614 */
9832 -32683, /* A2 = 0.997434 */
9833 21766, /* B2 = 0.664246 */
9834 -18761, /* B1 = -1.145081 */
9835 21766, /* B0 = 0.664246 */
9836 28513, /* A1 = -1.740356 */
9837 -32686, /* A2 = 0.997498 */
9838 2509, /* B2 = 0.076584 */
9839 -2196, /* B1 = -0.134041 */
9840 2509, /* B0 = 0.076584 */
9841 5, /* Internal filter scaling */
9842 159, /* Minimum in-band energy threshold */
9843 21, /* 21/32 in-band to broad-band ratio */
9844 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9845 },
9846 { /* f700 */
9847 27844, /* A1 = -1.699463 */
9848 -32563, /* A2 = 0.993744 */
9849 -366, /* B2 = -0.011187 */
9850 0, /* B1 = 0.000000 */
9851 366, /* B0 = 0.011187 */
9852 27797, /* A1 = -1.696655 */
9853 -32686, /* A2 = 0.997498 */
9854 22748, /* B2 = 0.694214 */
9855 -19235, /* B1 = -1.174072 */
9856 22748, /* B0 = 0.694214 */
9857 27995, /* A1 = -1.708740 */
9858 -32688, /* A2 = 0.997559 */
9859 2964, /* B2 = 0.090477 */
9860 -2546, /* B1 = -0.155449 */
9861 2964, /* B0 = 0.090477 */
9862 5, /* Internal filter scaling */
9863 159, /* Minimum in-band energy threshold */
9864 21, /* 21/32 in-band to broad-band ratio */
9865 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9866 },
9867 { /* f740 */
9868 27297, /* A1 = -1.666077 */
9869 -32551, /* A2 = 0.993408 */
9870 -345, /* B2 = -0.010540 */
9871 0, /* B1 = 0.000000 */
9872 345, /* B0 = 0.010540 */
9873 27240, /* A1 = -1.662598 */
9874 -32683, /* A2 = 0.997406 */
9875 22560, /* B2 = 0.688477 */
9876 -18688, /* B1 = -1.140625 */
9877 22560, /* B0 = 0.688477 */
9878 27461, /* A1 = -1.676147 */
9879 -32684, /* A2 = 0.997467 */
9880 3541, /* B2 = 0.108086 */
9881 -2985, /* B1 = -0.182220 */
9882 3541, /* B0 = 0.108086 */
9883 5, /* Internal filter scaling */
9884 159, /* Minimum in-band energy threshold */
9885 21, /* 21/32 in-band to broad-band ratio */
9886 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9887 },
9888 { /* f750 */
9889 27155, /* A1 = -1.657410 */
9890 -32551, /* A2 = 0.993408 */
9891 -462, /* B2 = -0.014117 */
9892 0, /* B1 = 0.000000 */
9893 462, /* B0 = 0.014117 */
9894 27097, /* A1 = -1.653870 */
9895 -32683, /* A2 = 0.997406 */
9896 32495, /* B2 = 0.991699 */
9897 -26776, /* B1 = -1.634338 */
9898 32495, /* B0 = 0.991699 */
9899 27321, /* A1 = -1.667542 */
9900 -32684, /* A2 = 0.997467 */
9901 1835, /* B2 = 0.056007 */
9902 -1539, /* B1 = -0.093948 */
9903 1835, /* B0 = 0.056007 */
9904 5, /* Internal filter scaling */
9905 159, /* Minimum in-band energy threshold */
9906 21, /* 21/32 in-band to broad-band ratio */
9907 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9908 },
9909 { /* f750_1450[] */
9910 19298, /* A1 = 1.177917 */
9911 -24471, /* A2 = -0.746796 */
9912 -4152, /* B2 = -0.126709 */
9913 0, /* B1 = 0 */
9914 4152, /* B0 = 0.126709 */
9915 12902, /* A1 = 0.787476 */
9916 -29091, /* A2 = -0.887817 */
9917 12491, /* B2 = 0.38121 */
9918 -1794, /* B1 = -0.109528 */
9919 12494, /* B0 = 0.381317 */
9920 26291, /* A1 = 1.604736 */
9921 -30470, /* A2 = -0.929901 */
9922 28859, /* B2 = 0.880737 */
9923 -26084, /* B1 = -1.592102 */
9924 28861, /* B0 = 0.880798 */
9925 7, /* Internal filter scaling */
9926 159, /* Minimum in-band energy threshold */
9927 21, /* 21/32 in-band to broad-band ratio */
9928 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9929 },
9930 { /* f770 */
9931 26867, /* A1 = -1.639832 */
9932 -32551, /* A2 = 0.993408 */
9933 -123, /* B2 = -0.003755 */
9934 0, /* B1 = 0.000000 */
9935 123, /* B0 = 0.003755 */
9936 26805, /* A1 = -1.636108 */
9937 -32683, /* A2 = 0.997406 */
9938 17297, /* B2 = 0.527863 */
9939 -14096, /* B1 = -0.860382 */
9940 17297, /* B0 = 0.527863 */
9941 27034, /* A1 = -1.650085 */
9942 -32684, /* A2 = 0.997467 */
9943 12958, /* B2 = 0.395477 */
9944 -10756, /* B1 = -0.656525 */
9945 12958, /* B0 = 0.395477 */
9946 5, /* Internal filter scaling */
9947 159, /* Minimum in-band energy threshold */
9948 21, /* 21/32 in-band to broad-band ratio */
9949 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9950 },
9951 { /* f800 */
9952 26413, /* A1 = -1.612122 */
9953 -32547, /* A2 = 0.993286 */
9954 -223, /* B2 = -0.006825 */
9955 0, /* B1 = 0.000000 */
9956 223, /* B0 = 0.006825 */
9957 26342, /* A1 = -1.607849 */
9958 -32686, /* A2 = 0.997498 */
9959 6391, /* B2 = 0.195053 */
9960 -5120, /* B1 = -0.312531 */
9961 6391, /* B0 = 0.195053 */
9962 26593, /* A1 = -1.623108 */
9963 -32688, /* A2 = 0.997559 */
9964 23681, /* B2 = 0.722717 */
9965 -19328, /* B1 = -1.179688 */
9966 23681, /* B0 = 0.722717 */
9967 5, /* Internal filter scaling */
9968 159, /* Minimum in-band energy threshold */
9969 21, /* 21/32 in-band to broad-band ratio */
9970 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9971 },
9972 { /* f816 */
9973 26168, /* A1 = -1.597209 */
9974 -32528, /* A2 = 0.992706 */
9975 -235, /* B2 = -0.007182 */
9976 0, /* B1 = 0.000000 */
9977 235, /* B0 = 0.007182 */
9978 26092, /* A1 = -1.592590 */
9979 -32675, /* A2 = 0.997192 */
9980 20823, /* B2 = 0.635498 */
9981 -16510, /* B1 = -1.007751 */
9982 20823, /* B0 = 0.635498 */
9983 26363, /* A1 = -1.609070 */
9984 -32677, /* A2 = 0.997253 */
9985 6739, /* B2 = 0.205688 */
9986 -5459, /* B1 = -0.333206 */
9987 6739, /* B0 = 0.205688 */
9988 5, /* Internal filter scaling */
9989 159, /* Minimum in-band energy threshold */
9990 21, /* 21/32 in-band to broad-band ratio */
9991 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
9992 },
9993 { /* f850 */
9994 25641, /* A1 = -1.565063 */
9995 -32536, /* A2 = 0.992950 */
9996 -121, /* B2 = -0.003707 */
9997 0, /* B1 = 0.000000 */
9998 121, /* B0 = 0.003707 */
9999 25560, /* A1 = -1.560059 */
10000 -32684, /* A2 = 0.997437 */
10001 18341, /* B2 = 0.559753 */
10002 -14252, /* B1 = -0.869904 */
10003 18341, /* B0 = 0.559753 */
10004 25837, /* A1 = -1.577026 */
10005 -32684, /* A2 = 0.997467 */
10006 16679, /* B2 = 0.509003 */
10007 -13232, /* B1 = -0.807648 */
10008 16679, /* B0 = 0.509003 */
10009 5, /* Internal filter scaling */
10010 159, /* Minimum in-band energy threshold */
10011 21, /* 21/32 in-band to broad-band ratio */
10012 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10013 },
10014 { /* f857_1645[] */
10015 16415, /* A1 = 1.001953 */
10016 -23669, /* A2 = -0.722321 */
10017 -4549, /* B2 = -0.138847 */
10018 0, /* B1 = 0 */
10019 4549, /* B0 = 0.138847 */
10020 8456, /* A1 = 0.516174 */
10021 -28996, /* A2 = -0.884918 */
10022 13753, /* B2 = 0.419724 */
10023 -12, /* B1 = -0.000763 */
10024 13757, /* B0 = 0.419846 */
10025 24632, /* A1 = 1.503418 */
10026 -30271, /* A2 = -0.923828 */
10027 29070, /* B2 = 0.887146 */
10028 -25265, /* B1 = -1.542114 */
10029 29073, /* B0 = 0.887268 */
10030 7, /* Internal filter scaling */
10031 159, /* Minimum in-band energy threshold */
10032 21, /* 21/32 in-band to broad-band ratio */
10033 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10034 },
10035 { /* f900 */
10036 24806, /* A1 = -1.514099 */
10037 -32501, /* A2 = 0.991852 */
10038 -326, /* B2 = -0.009969 */
10039 0, /* B1 = 0.000000 */
10040 326, /* B0 = 0.009969 */
10041 24709, /* A1 = -1.508118 */
10042 -32659, /* A2 = 0.996674 */
10043 20277, /* B2 = 0.618835 */
10044 -15182, /* B1 = -0.926636 */
10045 20277, /* B0 = 0.618835 */
10046 25022, /* A1 = -1.527222 */
10047 -32661, /* A2 = 0.996735 */
10048 4320, /* B2 = 0.131836 */
10049 -3331, /* B1 = -0.203339 */
10050 4320, /* B0 = 0.131836 */
10051 5, /* Internal filter scaling */
10052 159, /* Minimum in-band energy threshold */
10053 21, /* 21/32 in-band to broad-band ratio */
10054 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10055 },
10056 { /* f900_1300[] */
10057 19776, /* A1 = 1.207092 */
10058 -27437, /* A2 = -0.837341 */
10059 -2666, /* B2 = -0.081371 */
10060 0, /* B1 = 0 */
10061 2666, /* B0 = 0.081371 */
10062 16302, /* A1 = 0.995026 */
10063 -30354, /* A2 = -0.926361 */
10064 10389, /* B2 = 0.317062 */
10065 -3327, /* B1 = -0.203064 */
10066 10389, /* B0 = 0.317062 */
10067 24299, /* A1 = 1.483154 */
10068 -30930, /* A2 = -0.943909 */
10069 25016, /* B2 = 0.763428 */
10070 -21171, /* B1 = -1.292236 */
10071 25016, /* B0 = 0.763428 */
10072 7, /* Internal filter scaling */
10073 159, /* Minimum in-band energy threshold */
10074 21, /* 21/32 in-band to broad-band ratio */
10075 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10076 },
10077 { /* f935_1215[] */
10078 20554, /* A1 = 1.254517 */
10079 -28764, /* A2 = -0.877838 */
10080 -2048, /* B2 = -0.062515 */
10081 0, /* B1 = 0 */
10082 2048, /* B0 = 0.062515 */
10083 18209, /* A1 = 1.11145 */
10084 -30951, /* A2 = -0.94458 */
10085 9390, /* B2 = 0.286575 */
10086 -3955, /* B1 = -0.241455 */
10087 9390, /* B0 = 0.286575 */
10088 23902, /* A1 = 1.458923 */
10089 -31286, /* A2 = -0.954803 */
10090 23252, /* B2 = 0.709595 */
10091 -19132, /* B1 = -1.167725 */
10092 23252, /* B0 = 0.709595 */
10093 7, /* Internal filter scaling */
10094 159, /* Minimum in-band energy threshold */
10095 21, /* 21/32 in-band to broad-band ratio */
10096 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10097 },
10098 { /* f941_1477[] */
10099 17543, /* A1 = 1.07074 */
10100 -26220, /* A2 = -0.800201 */
10101 -3298, /* B2 = -0.100647 */
10102 0, /* B1 = 0 */
10103 3298, /* B0 = 0.100647 */
10104 12423, /* A1 = 0.75827 */
10105 -30036, /* A2 = -0.916626 */
10106 12651, /* B2 = 0.386078 */
10107 -2444, /* B1 = -0.14917 */
10108 12653, /* B0 = 0.386154 */
10109 23518, /* A1 = 1.435425 */
10110 -30745, /* A2 = -0.938293 */
10111 27282, /* B2 = 0.832581 */
10112 -22529, /* B1 = -1.375122 */
10113 27286, /* B0 = 0.832703 */
10114 7, /* Internal filter scaling */
10115 159, /* Minimum in-band energy threshold */
10116 21, /* 21/32 in-band to broad-band ratio */
10117 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10118 },
10119 { /* f942 */
10120 24104, /* A1 = -1.471252 */
10121 -32507, /* A2 = 0.992065 */
10122 -351, /* B2 = -0.010722 */
10123 0, /* B1 = 0.000000 */
10124 351, /* B0 = 0.010722 */
10125 23996, /* A1 = -1.464600 */
10126 -32671, /* A2 = 0.997040 */
10127 22848, /* B2 = 0.697266 */
10128 -16639, /* B1 = -1.015564 */
10129 22848, /* B0 = 0.697266 */
10130 24332, /* A1 = -1.485168 */
10131 -32673, /* A2 = 0.997101 */
10132 4906, /* B2 = 0.149727 */
10133 -3672, /* B1 = -0.224174 */
10134 4906, /* B0 = 0.149727 */
10135 5, /* Internal filter scaling */
10136 159, /* Minimum in-band energy threshold */
10137 21, /* 21/32 in-band to broad-band ratio */
10138 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10139 },
10140 { /* f950 */
10141 23967, /* A1 = -1.462830 */
10142 -32507, /* A2 = 0.992065 */
10143 -518, /* B2 = -0.015821 */
10144 0, /* B1 = 0.000000 */
10145 518, /* B0 = 0.015821 */
10146 23856, /* A1 = -1.456055 */
10147 -32671, /* A2 = 0.997040 */
10148 26287, /* B2 = 0.802246 */
10149 -19031, /* B1 = -1.161560 */
10150 26287, /* B0 = 0.802246 */
10151 24195, /* A1 = -1.476746 */
10152 -32673, /* A2 = 0.997101 */
10153 2890, /* B2 = 0.088196 */
10154 -2151, /* B1 = -0.131317 */
10155 2890, /* B0 = 0.088196 */
10156 5, /* Internal filter scaling */
10157 159, /* Minimum in-band energy threshold */
10158 21, /* 21/32 in-band to broad-band ratio */
10159 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10160 },
10161 { /* f950_1400[] */
10162 18294, /* A1 = 1.116638 */
10163 -26962, /* A2 = -0.822845 */
10164 -2914, /* B2 = -0.088936 */
10165 0, /* B1 = 0 */
10166 2914, /* B0 = 0.088936 */
10167 14119, /* A1 = 0.861786 */
10168 -30227, /* A2 = -0.922455 */
10169 11466, /* B2 = 0.349945 */
10170 -2833, /* B1 = -0.172943 */
10171 11466, /* B0 = 0.349945 */
10172 23431, /* A1 = 1.430115 */
10173 -30828, /* A2 = -0.940796 */
10174 25331, /* B2 = 0.773071 */
10175 -20911, /* B1 = -1.276367 */
10176 25331, /* B0 = 0.773071 */
10177 7, /* Internal filter scaling */
10178 159, /* Minimum in-band energy threshold */
10179 21, /* 21/32 in-band to broad-band ratio */
10180 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10181 },
10182 { /* f975 */
10183 23521, /* A1 = -1.435608 */
10184 -32489, /* A2 = 0.991516 */
10185 -193, /* B2 = -0.005915 */
10186 0, /* B1 = 0.000000 */
10187 193, /* B0 = 0.005915 */
10188 23404, /* A1 = -1.428467 */
10189 -32655, /* A2 = 0.996582 */
10190 17740, /* B2 = 0.541412 */
10191 -12567, /* B1 = -0.767029 */
10192 17740, /* B0 = 0.541412 */
10193 23753, /* A1 = -1.449829 */
10194 -32657, /* A2 = 0.996613 */
10195 9090, /* B2 = 0.277405 */
10196 -6662, /* B1 = -0.406647 */
10197 9090, /* B0 = 0.277405 */
10198 5, /* Internal filter scaling */
10199 159, /* Minimum in-band energy threshold */
10200 21, /* 21/32 in-band to broad-band ratio */
10201 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10202 },
10203 { /* f1000 */
10204 23071, /* A1 = -1.408203 */
10205 -32489, /* A2 = 0.991516 */
10206 -293, /* B2 = -0.008965 */
10207 0, /* B1 = 0.000000 */
10208 293, /* B0 = 0.008965 */
10209 22951, /* A1 = -1.400818 */
10210 -32655, /* A2 = 0.996582 */
10211 5689, /* B2 = 0.173645 */
10212 -3951, /* B1 = -0.241150 */
10213 5689, /* B0 = 0.173645 */
10214 23307, /* A1 = -1.422607 */
10215 -32657, /* A2 = 0.996613 */
10216 18692, /* B2 = 0.570435 */
10217 -13447, /* B1 = -0.820770 */
10218 18692, /* B0 = 0.570435 */
10219 5, /* Internal filter scaling */
10220 159, /* Minimum in-band energy threshold */
10221 21, /* 21/32 in-band to broad-band ratio */
10222 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10223 },
10224 { /* f1020 */
10225 22701, /* A1 = -1.385620 */
10226 -32474, /* A2 = 0.991058 */
10227 -292, /* B2 = -0.008933 */
10228 0, /*163840 , B1 = 10.000000 */
10229 292, /* B0 = 0.008933 */
10230 22564, /* A1 = -1.377258 */
10231 -32655, /* A2 = 0.996552 */
10232 20756, /* B2 = 0.633423 */
10233 -14176, /* B1 = -0.865295 */
10234 20756, /* B0 = 0.633423 */
10235 22960, /* A1 = -1.401428 */
10236 -32657, /* A2 = 0.996613 */
10237 6520, /* B2 = 0.198990 */
10238 -4619, /* B1 = -0.281937 */
10239 6520, /* B0 = 0.198990 */
10240 5, /* Internal filter scaling */
10241 159, /* Minimum in-band energy threshold */
10242 21, /* 21/32 in-band to broad-band ratio */
10243 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10244 },
10245 { /* f1050 */
10246 22142, /* A1 = -1.351501 */
10247 -32474, /* A2 = 0.991058 */
10248 -147, /* B2 = -0.004493 */
10249 0, /* B1 = 0.000000 */
10250 147, /* B0 = 0.004493 */
10251 22000, /* A1 = -1.342834 */
10252 -32655, /* A2 = 0.996552 */
10253 15379, /* B2 = 0.469360 */
10254 -10237, /* B1 = -0.624847 */
10255 15379, /* B0 = 0.469360 */
10256 22406, /* A1 = -1.367554 */
10257 -32657, /* A2 = 0.996613 */
10258 17491, /* B2 = 0.533783 */
10259 -12096, /* B1 = -0.738312 */
10260 17491, /* B0 = 0.533783 */
10261 5, /* Internal filter scaling */
10262 159, /* Minimum in-band energy threshold */
10263 21, /* 21/32 in-band to broad-band ratio */
10264 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10265 },
10266 { /* f1100_1750[] */
10267 12973, /* A1 = 0.79184 */
10268 -24916, /* A2 = -0.760376 */
10269 6655, /* B2 = 0.203102 */
10270 367, /* B1 = 0.0224 */
10271 6657, /* B0 = 0.203171 */
10272 5915, /* A1 = 0.361053 */
10273 -29560, /* A2 = -0.90213 */
10274 -7777, /* B2 = -0.23735 */
10275 0, /* B1 = 0 */
10276 7777, /* B0 = 0.23735 */
10277 20510, /* A1 = 1.251892 */
10278 -30260, /* A2 = -0.923462 */
10279 26662, /* B2 = 0.81366 */
10280 -20573, /* B1 = -1.255737 */
10281 26668, /* B0 = 0.813843 */
10282 7, /* Internal filter scaling */
10283 159, /* Minimum in-band energy threshold */
10284 21, /* 21/32 in-band to broad-band ratio */
10285 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10286 },
10287 { /* f1140 */
10288 20392, /* A1 = -1.244629 */
10289 -32460, /* A2 = 0.990601 */
10290 -270, /* B2 = -0.008240 */
10291 0, /* B1 = 0.000000 */
10292 270, /* B0 = 0.008240 */
10293 20218, /* A1 = -1.234009 */
10294 -32655, /* A2 = 0.996582 */
10295 21337, /* B2 = 0.651154 */
10296 -13044, /* B1 = -0.796143 */
10297 21337, /* B0 = 0.651154 */
10298 20684, /* A1 = -1.262512 */
10299 -32657, /* A2 = 0.996643 */
10300 8572, /* B2 = 0.261612 */
10301 -5476, /* B1 = -0.334244 */
10302 8572, /* B0 = 0.261612 */
10303 5, /* Internal filter scaling */
10304 159, /* Minimum in-band energy threshold */
10305 21, /* 21/32 in-band to broad-band ratio */
10306 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10307 },
10308 { /* f1200 */
10309 19159, /* A1 = -1.169373 */
10310 -32456, /* A2 = 0.990509 */
10311 -335, /* B2 = -0.010252 */
10312 0, /* B1 = 0.000000 */
10313 335, /* B0 = 0.010252 */
10314 18966, /* A1 = -1.157593 */
10315 -32661, /* A2 = 0.996735 */
10316 6802, /* B2 = 0.207588 */
10317 -3900, /* B1 = -0.238098 */
10318 6802, /* B0 = 0.207588 */
10319 19467, /* A1 = -1.188232 */
10320 -32661, /* A2 = 0.996765 */
10321 25035, /* B2 = 0.764008 */
10322 -15049, /* B1 = -0.918579 */
10323 25035, /* B0 = 0.764008 */
10324 5, /* Internal filter scaling */
10325 159, /* Minimum in-band energy threshold */
10326 21, /* 21/32 in-band to broad-band ratio */
10327 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10328 },
10329 { /* f1209 */
10330 18976, /* A1 = -1.158264 */
10331 -32439, /* A2 = 0.989990 */
10332 -183, /* B2 = -0.005588 */
10333 0, /* B1 = 0.000000 */
10334 183, /* B0 = 0.005588 */
10335 18774, /* A1 = -1.145874 */
10336 -32650, /* A2 = 0.996429 */
10337 15468, /* B2 = 0.472076 */
10338 -8768, /* B1 = -0.535217 */
10339 15468, /* B0 = 0.472076 */
10340 19300, /* A1 = -1.177979 */
10341 -32652, /* A2 = 0.996490 */
10342 19840, /* B2 = 0.605499 */
10343 -11842, /* B1 = -0.722809 */
10344 19840, /* B0 = 0.605499 */
10345 5, /* Internal filter scaling */
10346 159, /* Minimum in-band energy threshold */
10347 21, /* 21/32 in-band to broad-band ratio */
10348 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10349 },
10350 { /* f1330 */
10351 16357, /* A1 = -0.998413 */
10352 -32368, /* A2 = 0.987793 */
10353 -217, /* B2 = -0.006652 */
10354 0, /* B1 = 0.000000 */
10355 217, /* B0 = 0.006652 */
10356 16107, /* A1 = -0.983126 */
10357 -32601, /* A2 = 0.994904 */
10358 11602, /* B2 = 0.354065 */
10359 -5555, /* B1 = -0.339111 */
10360 11602, /* B0 = 0.354065 */
10361 16722, /* A1 = -1.020630 */
10362 -32603, /* A2 = 0.994965 */
10363 15574, /* B2 = 0.475311 */
10364 -8176, /* B1 = -0.499069 */
10365 15574, /* B0 = 0.475311 */
10366 5, /* Internal filter scaling */
10367 159, /* Minimum in-band energy threshold */
10368 21, /* 21/32 in-band to broad-band ratio */
10369 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10370 },
10371 { /* f1336 */
10372 16234, /* A1 = -0.990875 */
10373 32404, /* A2 = -0.988922 */
10374 -193, /* B2 = -0.005908 */
10375 0, /* B1 = 0.000000 */
10376 193, /* B0 = 0.005908 */
10377 15986, /* A1 = -0.975769 */
10378 -32632, /* A2 = 0.995880 */
10379 18051, /* B2 = 0.550903 */
10380 -8658, /* B1 = -0.528473 */
10381 18051, /* B0 = 0.550903 */
10382 16591, /* A1 = -1.012695 */
10383 -32634, /* A2 = 0.995941 */
10384 15736, /* B2 = 0.480240 */
10385 -8125, /* B1 = -0.495926 */
10386 15736, /* B0 = 0.480240 */
10387 5, /* Internal filter scaling */
10388 159, /* Minimum in-band energy threshold */
10389 21, /* 21/32 in-band to broad-band ratio */
10390 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10391 },
10392 { /* f1366 */
10393 15564, /* A1 = -0.949982 */
10394 -32404, /* A2 = 0.988922 */
10395 -269, /* B2 = -0.008216 */
10396 0, /* B1 = 0.000000 */
10397 269, /* B0 = 0.008216 */
10398 15310, /* A1 = -0.934479 */
10399 -32632, /* A2 = 0.995880 */
10400 10815, /* B2 = 0.330063 */
10401 -4962, /* B1 = -0.302887 */
10402 10815, /* B0 = 0.330063 */
10403 15924, /* A1 = -0.971924 */
10404 -32634, /* A2 = 0.995941 */
10405 18880, /* B2 = 0.576172 */
10406 -9364, /* B1 = -0.571594 */
10407 18880, /* B0 = 0.576172 */
10408 5, /* Internal filter scaling */
10409 159, /* Minimum in-band energy threshold */
10410 21, /* 21/32 in-band to broad-band ratio */
10411 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10412 },
10413 { /* f1380 */
10414 15247, /* A1 = -0.930603 */
10415 -32397, /* A2 = 0.988708 */
10416 -244, /* B2 = -0.007451 */
10417 0, /* B1 = 0.000000 */
10418 244, /* B0 = 0.007451 */
10419 14989, /* A1 = -0.914886 */
10420 -32627, /* A2 = 0.995697 */
10421 18961, /* B2 = 0.578644 */
10422 -8498, /* B1 = -0.518707 */
10423 18961, /* B0 = 0.578644 */
10424 15608, /* A1 = -0.952667 */
10425 -32628, /* A2 = 0.995758 */
10426 11145, /* B2 = 0.340134 */
10427 -5430, /* B1 = -0.331467 */
10428 11145, /* B0 = 0.340134 */
10429 5, /* Internal filter scaling */
10430 159, /* Minimum in-band energy threshold */
10431 21, /* 21/32 in-band to broad-band ratio */
10432 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10433 },
10434 { /* f1400 */
10435 14780, /* A1 = -0.902130 */
10436 -32393, /* A2 = 0.988586 */
10437 -396, /* B2 = -0.012086 */
10438 0, /* B1 = 0.000000 */
10439 396, /* B0 = 0.012086 */
10440 14510, /* A1 = -0.885651 */
10441 -32630, /* A2 = 0.995819 */
10442 6326, /* B2 = 0.193069 */
10443 -2747, /* B1 = -0.167671 */
10444 6326, /* B0 = 0.193069 */
10445 15154, /* A1 = -0.924957 */
10446 -32632, /* A2 = 0.995850 */
10447 23235, /* B2 = 0.709076 */
10448 -10983, /* B1 = -0.670380 */
10449 23235, /* B0 = 0.709076 */
10450 5, /* Internal filter scaling */
10451 159, /* Minimum in-band energy threshold */
10452 21, /* 21/32 in-band to broad-band ratio */
10453 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10454 },
10455 { /* f1477 */
10456 13005, /* A1 = -0.793793 */
10457 -32368, /* A2 = 0.987823 */
10458 -500, /* B2 = -0.015265 */
10459 0, /* B1 = 0.000000 */
10460 500, /* B0 = 0.015265 */
10461 12708, /* A1 = -0.775665 */
10462 -32615, /* A2 = 0.995331 */
10463 11420, /* B2 = 0.348526 */
10464 -4306, /* B1 = -0.262833 */
10465 11420, /* B0 = 0.348526 */
10466 13397, /* A1 = -0.817688 */
10467 -32615, /* A2 = 0.995361 */
10468 9454, /* B2 = 0.288528 */
10469 -3981, /* B1 = -0.243027 */
10470 9454, /* B0 = 0.288528 */
10471 5, /* Internal filter scaling */
10472 159, /* Minimum in-band energy threshold */
10473 21, /* 21/32 in-band to broad-band ratio */
10474 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10475 },
10476 { /* f1600 */
10477 10046, /* A1 = -0.613190 */
10478 -32331, /* A2 = 0.986694 */
10479 -455, /* B2 = -0.013915 */
10480 0, /* B1 = 0.000000 */
10481 455, /* B0 = 0.013915 */
10482 9694, /* A1 = -0.591705 */
10483 -32601, /* A2 = 0.994934 */
10484 6023, /* B2 = 0.183815 */
10485 -1708, /* B1 = -0.104279 */
10486 6023, /* B0 = 0.183815 */
10487 10478, /* A1 = -0.639587 */
10488 -32603, /* A2 = 0.994965 */
10489 22031, /* B2 = 0.672333 */
10490 -7342, /* B1 = -0.448151 */
10491 22031, /* B0 = 0.672333 */
10492 5, /* Internal filter scaling */
10493 159, /* Minimum in-band energy threshold */
10494 21, /* 21/32 in-band to broad-band ratio */
10495 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10496 },
10497 { /* f1633_1638[] */
10498 9181, /* A1 = 0.560394 */
10499 -32256, /* A2 = -0.984375 */
10500 -556, /* B2 = -0.016975 */
10501 0, /* B1 = 0 */
10502 556, /* B0 = 0.016975 */
10503 8757, /* A1 = 0.534515 */
10504 -32574, /* A2 = -0.99408 */
10505 8443, /* B2 = 0.25769 */
10506 -2135, /* B1 = -0.130341 */
10507 8443, /* B0 = 0.25769 */
10508 9691, /* A1 = 0.591522 */
10509 -32574, /* A2 = -0.99411 */
10510 15446, /* B2 = 0.471375 */
10511 -4809, /* B1 = -0.293579 */
10512 15446, /* B0 = 0.471375 */
10513 7, /* Internal filter scaling */
10514 159, /* Minimum in-band energy threshold */
10515 21, /* 21/32 in-band to broad-band ratio */
10516 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10517 },
10518 { /* f1800 */
10519 5076, /* A1 = -0.309875 */
10520 -32304, /* A2 = 0.985840 */
10521 -508, /* B2 = -0.015503 */
10522 0, /* B1 = 0.000000 */
10523 508, /* B0 = 0.015503 */
10524 4646, /* A1 = -0.283600 */
10525 -32605, /* A2 = 0.995026 */
10526 6742, /* B2 = 0.205780 */
10527 -878, /* B1 = -0.053635 */
10528 6742, /* B0 = 0.205780 */
10529 5552, /* A1 = -0.338928 */
10530 -32605, /* A2 = 0.995056 */
10531 23667, /* B2 = 0.722260 */
10532 -4297, /* B1 = -0.262329 */
10533 23667, /* B0 = 0.722260 */
10534 5, /* Internal filter scaling */
10535 159, /* Minimum in-band energy threshold */
10536 21, /* 21/32 in-band to broad-band ratio */
10537 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10538 },
10539 { /* f1860 */
10540 3569, /* A1 = -0.217865 */
10541 -32292, /* A2 = 0.985504 */
10542 -239, /* B2 = -0.007322 */
10543 0, /* B1 = 0.000000 */
10544 239, /* B0 = 0.007322 */
10545 3117, /* A1 = -0.190277 */
10546 -32603, /* A2 = 0.994965 */
10547 18658, /* B2 = 0.569427 */
10548 -1557, /* B1 = -0.095032 */
10549 18658, /* B0 = 0.569427 */
10550 4054, /* A1 = -0.247437 */
10551 -32603, /* A2 = 0.994965 */
10552 18886, /* B2 = 0.576385 */
10553 -2566, /* B1 = -0.156647 */
10554 18886, /* B0 = 0.576385 */
10555 5, /* Internal filter scaling */
10556 159, /* Minimum in-band energy threshold */
10557 21, /* 21/32 in-band to broad-band ratio */
10558 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */
10559 },
10560 };
ixj_init_filter(IXJ * j,IXJ_FILTER * jf)10561 static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf)
10562 {
10563 unsigned short cmd;
10564 int cnt, max;
10565
10566 if (jf->filter > 3) {
10567 return -1;
10568 }
10569 if (ixj_WriteDSPCommand(0x5154 + jf->filter, j)) /* Select Filter */
10570
10571 return -1;
10572 if (!jf->enable) {
10573 if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
10574
10575 return -1;
10576 else
10577 return 0;
10578 } else {
10579 if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
10580
10581 return -1;
10582 /* Select the filter (f0 - f3) to use. */
10583 if (ixj_WriteDSPCommand(0x5154 + jf->filter, j))
10584 return -1;
10585 }
10586 if (jf->freq < 12 && jf->freq > 3) {
10587 /* Select the frequency for the selected filter. */
10588 if (ixj_WriteDSPCommand(0x5170 + jf->freq, j))
10589 return -1;
10590 } else if (jf->freq > 11) {
10591 /* We need to load a programmable filter set for undefined */
10592 /* frequencies. So we will point the filter to a programmable set. */
10593 /* Since there are only 4 filters and 4 programmable sets, we will */
10594 /* just point the filter to the same number set and program it for the */
10595 /* frequency we want. */
10596 if (ixj_WriteDSPCommand(0x5170 + jf->filter, j))
10597 return -1;
10598 if (j->ver.low != 0x12) {
10599 cmd = 0x515B;
10600 max = 19;
10601 } else {
10602 cmd = 0x515E;
10603 max = 15;
10604 }
10605 if (ixj_WriteDSPCommand(cmd, j))
10606 return -1;
10607 for (cnt = 0; cnt < max; cnt++) {
10608 if (ixj_WriteDSPCommand(tone_table[jf->freq - 12][cnt], j))
10609 return -1;
10610 }
10611 }
10612 j->filter_en[jf->filter] = jf->enable;
10613 return 0;
10614 }
10615
ixj_init_filter_raw(IXJ * j,IXJ_FILTER_RAW * jfr)10616 static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr)
10617 {
10618 unsigned short cmd;
10619 int cnt, max;
10620 if (jfr->filter > 3) {
10621 return -1;
10622 }
10623 if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j)) /* Select Filter */
10624 return -1;
10625
10626 if (!jfr->enable) {
10627 if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */
10628 return -1;
10629 else
10630 return 0;
10631 } else {
10632 if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */
10633 return -1;
10634 /* Select the filter (f0 - f3) to use. */
10635 if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j))
10636 return -1;
10637 }
10638 /* We need to load a programmable filter set for undefined */
10639 /* frequencies. So we will point the filter to a programmable set. */
10640 /* Since there are only 4 filters and 4 programmable sets, we will */
10641 /* just point the filter to the same number set and program it for the */
10642 /* frequency we want. */
10643 if (ixj_WriteDSPCommand(0x5170 + jfr->filter, j))
10644 return -1;
10645 if (j->ver.low != 0x12) {
10646 cmd = 0x515B;
10647 max = 19;
10648 } else {
10649 cmd = 0x515E;
10650 max = 15;
10651 }
10652 if (ixj_WriteDSPCommand(cmd, j))
10653 return -1;
10654 for (cnt = 0; cnt < max; cnt++) {
10655 if (ixj_WriteDSPCommand(jfr->coeff[cnt], j))
10656 return -1;
10657 }
10658 j->filter_en[jfr->filter] = jfr->enable;
10659 return 0;
10660 }
10661
ixj_init_tone(IXJ * j,IXJ_TONE * ti)10662 static int ixj_init_tone(IXJ *j, IXJ_TONE * ti)
10663 {
10664 int freq0, freq1;
10665 unsigned short data;
10666 if (ti->freq0) {
10667 freq0 = ti->freq0;
10668 } else {
10669 freq0 = 0x7FFF;
10670 }
10671
10672 if (ti->freq1) {
10673 freq1 = ti->freq1;
10674 } else {
10675 freq1 = 0x7FFF;
10676 }
10677
10678 if(ti->tone_index > 12 && ti->tone_index < 28)
10679 {
10680 if (ixj_WriteDSPCommand(0x6800 + ti->tone_index, j))
10681 return -1;
10682 if (ixj_WriteDSPCommand(0x6000 + (ti->gain1 << 4) + ti->gain0, j))
10683 return -1;
10684 data = freq0;
10685 if (ixj_WriteDSPCommand(data, j))
10686 return -1;
10687 data = freq1;
10688 if (ixj_WriteDSPCommand(data, j))
10689 return -1;
10690 }
10691 return freq0;
10692 }
10693
10694