Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * Daniele Bellucci, <bellucda@tiscali.it> |
| 27 | * |
| 28 | * More information about the hardware related to this driver can be found |
| 29 | * at our website: http://www.quicknet.net |
| 30 | * |
| 31 | * IN NO EVENT SHALL QUICKNET TECHNOLOGIES, INC. BE LIABLE TO ANY PARTY FOR |
| 32 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT |
| 33 | * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF QUICKNET |
| 34 | * TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 35 | * |
| 36 | * QUICKNET TECHNOLOGIES, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES, |
| 37 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
| 38 | * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 39 | * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION |
| 40 | * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 41 | * |
| 42 | ***************************************************************************/ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | /* |
| 45 | * $Log: ixj.c,v $ |
| 46 | * |
| 47 | * Revision 4.8 2003/07/09 19:39:00 Daniele Bellucci |
| 48 | * Audit some copy_*_user and minor cleanup. |
| 49 | * |
| 50 | * Revision 4.7 2001/08/13 06:19:33 craigs |
| 51 | * Added additional changes from Alan Cox and John Anderson for |
| 52 | * 2.2 to 2.4 cleanup and bounds checking |
| 53 | * |
| 54 | * Revision 4.6 2001/08/13 01:05:05 craigs |
| 55 | * Really fixed PHONE_QUERY_CODEC problem this time |
| 56 | * |
| 57 | * Revision 4.5 2001/08/13 00:11:03 craigs |
| 58 | * Fixed problem in handling of PHONE_QUERY_CODEC, thanks to Shane Anderson |
| 59 | * |
| 60 | * Revision 4.4 2001/08/07 07:58:12 craigs |
| 61 | * Changed back to three digit version numbers |
| 62 | * Added tagbuild target to allow automatic and easy tagging of versions |
| 63 | * |
| 64 | * Revision 4.3 2001/08/07 07:24:47 craigs |
| 65 | * Added ixj-ver.h to allow easy configuration management of driver |
| 66 | * Added display of version number in /prox/ixj |
| 67 | * |
| 68 | * Revision 4.2 2001/08/06 07:07:19 craigs |
| 69 | * Reverted IXJCTL_DSP_TYPE and IXJCTL_DSP_VERSION files to original |
| 70 | * behaviour of returning int rather than short * |
| 71 | * |
| 72 | * Revision 4.1 2001/08/05 00:17:37 craigs |
| 73 | * More changes for correct PCMCIA installation |
| 74 | * Start of changes for backward Linux compatibility |
| 75 | * |
| 76 | * Revision 4.0 2001/08/04 12:33:12 craigs |
| 77 | * New version using GNU autoconf |
| 78 | * |
| 79 | * Revision 3.105 2001/07/20 23:14:32 eokerson |
| 80 | * More work on CallerID generation when using ring cadences. |
| 81 | * |
| 82 | * Revision 3.104 2001/07/06 01:33:55 eokerson |
| 83 | * Some bugfixes from Robert Vojta <vojta@ipex.cz> and a few mods to the Makefile. |
| 84 | * |
| 85 | * Revision 3.103 2001/07/05 19:20:16 eokerson |
| 86 | * Updated HOWTO |
| 87 | * Changed mic gain to 30dB on Internet LineJACK mic/speaker port. |
| 88 | * |
| 89 | * Revision 3.102 2001/07/03 23:51:21 eokerson |
| 90 | * Un-mute mic on Internet LineJACK when in speakerphone mode. |
| 91 | * |
| 92 | * Revision 3.101 2001/07/02 19:26:56 eokerson |
| 93 | * Removed initialiazation of ixjdebug and ixj_convert_loaded so they will go in the .bss instead of the .data |
| 94 | * |
| 95 | * Revision 3.100 2001/07/02 19:18:27 eokerson |
| 96 | * Changed driver to make dynamic allocation possible. We now pass IXJ * between functions instead of array indexes. |
| 97 | * Fixed the way the POTS and PSTN ports interact during a PSTN call to allow local answering. |
| 98 | * Fixed speaker mode on Internet LineJACK. |
| 99 | * |
| 100 | * Revision 3.99 2001/05/09 14:11:16 eokerson |
| 101 | * Fixed kmalloc error in ixj_build_filter_cadence. Thanks David Chan <cat@waulogy.stanford.edu>. |
| 102 | * |
| 103 | * Revision 3.98 2001/05/08 19:55:33 eokerson |
| 104 | * Fixed POTS hookstate detection while it is connected to PSTN port. |
| 105 | * |
| 106 | * Revision 3.97 2001/05/08 00:01:04 eokerson |
| 107 | * Fixed kernel oops when sending caller ID data. |
| 108 | * |
| 109 | * Revision 3.96 2001/05/04 23:09:30 eokerson |
| 110 | * Now uses one kernel timer for each card, instead of one for the entire driver. |
| 111 | * |
| 112 | * Revision 3.95 2001/04/25 22:06:47 eokerson |
| 113 | * Fixed squawking at beginning of some G.723.1 calls. |
| 114 | * |
| 115 | * Revision 3.94 2001/04/03 23:42:00 eokerson |
| 116 | * Added linear volume ioctls |
| 117 | * Added raw filter load ioctl |
| 118 | * |
| 119 | * Revision 3.93 2001/02/27 01:00:06 eokerson |
| 120 | * Fixed blocking in CallerID. |
| 121 | * Reduced size of ixj structure for smaller driver footprint. |
| 122 | * |
| 123 | * Revision 3.92 2001/02/20 22:02:59 eokerson |
| 124 | * Fixed isapnp and pcmcia module compatibility for 2.4.x kernels. |
| 125 | * Improved PSTN ring detection. |
| 126 | * Fixed wink generation on POTS ports. |
| 127 | * |
| 128 | * Revision 3.91 2001/02/13 00:55:44 eokerson |
| 129 | * Turn AEC back on after changing frame sizes. |
| 130 | * |
| 131 | * Revision 3.90 2001/02/12 16:42:00 eokerson |
| 132 | * Added ALAW codec, thanks to Fabio Ferrari for the table based converters to make ALAW from ULAW. |
| 133 | * |
| 134 | * Revision 3.89 2001/02/12 15:41:16 eokerson |
| 135 | * Fix from Artis Kugevics - Tone gains were not being set correctly. |
| 136 | * |
| 137 | * Revision 3.88 2001/02/05 23:25:42 eokerson |
| 138 | * Fixed lockup bugs with deregister. |
| 139 | * |
| 140 | * Revision 3.87 2001/01/29 21:00:39 eokerson |
| 141 | * Fix from Fabio Ferrari <fabio.ferrari@digitro.com.br> to properly handle EAGAIN and EINTR during non-blocking write. |
| 142 | * Updated copyright date. |
| 143 | * |
| 144 | * Revision 3.86 2001/01/23 23:53:46 eokerson |
| 145 | * Fixes to G.729 compatibility. |
| 146 | * |
| 147 | * Revision 3.85 2001/01/23 21:30:36 eokerson |
| 148 | * Added verbage about cards supported. |
| 149 | * Removed commands that put the card in low power mode at some times that it should not be in low power mode. |
| 150 | * |
| 151 | * Revision 3.84 2001/01/22 23:32:10 eokerson |
| 152 | * Some bugfixes from David Huggins-Daines, <dhd@cepstral.com> and other cleanups. |
| 153 | * |
| 154 | * Revision 3.83 2001/01/19 14:51:41 eokerson |
| 155 | * Fixed ixj_WriteDSPCommand to decrement usage counter when command fails. |
| 156 | * |
| 157 | * Revision 3.82 2001/01/19 00:34:49 eokerson |
| 158 | * Added verbosity to write overlap errors. |
| 159 | * |
| 160 | * Revision 3.81 2001/01/18 23:56:54 eokerson |
| 161 | * Fixed PSTN line test functions. |
| 162 | * |
| 163 | * Revision 3.80 2001/01/18 22:29:27 eokerson |
| 164 | * Updated AEC/AGC values for different cards. |
| 165 | * |
| 166 | * Revision 3.79 2001/01/17 02:58:54 eokerson |
| 167 | * Fixed AEC reset after Caller ID. |
| 168 | * Fixed Codec lockup after Caller ID on Call Waiting when not using 30ms frames. |
| 169 | * |
| 170 | * Revision 3.78 2001/01/16 19:43:09 eokerson |
| 171 | * Added support for Linux 2.4.x kernels. |
| 172 | * |
| 173 | * Revision 3.77 2001/01/09 04:00:52 eokerson |
| 174 | * Linetest will now test the line, even if it has previously succeded. |
| 175 | * |
| 176 | * Revision 3.76 2001/01/08 19:27:00 eokerson |
| 177 | * Fixed problem with standard cable on Internet PhoneCARD. |
| 178 | * |
| 179 | * Revision 3.75 2000/12/22 16:52:14 eokerson |
| 180 | * Modified to allow hookstate detection on the POTS port when the PSTN port is selected. |
| 181 | * |
| 182 | * Revision 3.74 2000/12/08 22:41:50 eokerson |
| 183 | * Added capability for G729B. |
| 184 | * |
| 185 | * Revision 3.73 2000/12/07 23:35:16 eokerson |
| 186 | * Added capability to have different ring pattern before CallerID data. |
| 187 | * Added hookstate checks in CallerID routines to stop FSK. |
| 188 | * |
| 189 | * Revision 3.72 2000/12/06 19:31:31 eokerson |
| 190 | * Modified signal behavior to only send one signal per event. |
| 191 | * |
| 192 | * Revision 3.71 2000/12/06 03:23:08 eokerson |
| 193 | * Fixed CallerID on Call Waiting. |
| 194 | * |
| 195 | * Revision 3.70 2000/12/04 21:29:37 eokerson |
| 196 | * Added checking to Smart Cable gain functions. |
| 197 | * |
| 198 | * Revision 3.69 2000/12/04 21:05:20 eokerson |
| 199 | * Changed ixjdebug levels. |
| 200 | * Added ioctls to change gains in Internet Phone CARD Smart Cable. |
| 201 | * |
| 202 | * Revision 3.68 2000/12/04 00:17:21 craigs |
| 203 | * Changed mixer voice gain to +6dB rather than 0dB |
| 204 | * |
| 205 | * Revision 3.67 2000/11/30 21:25:51 eokerson |
| 206 | * Fixed write signal errors. |
| 207 | * |
| 208 | * Revision 3.66 2000/11/29 22:42:44 eokerson |
| 209 | * Fixed PSTN ring detect problems. |
| 210 | * |
| 211 | * Revision 3.65 2000/11/29 07:31:55 craigs |
| 212 | * Added new 425Hz filter co-efficients |
| 213 | * Added card-specific DTMF prescaler initialisation |
| 214 | * |
| 215 | * Revision 3.64 2000/11/28 14:03:32 craigs |
| 216 | * Changed certain mixer initialisations to be 0dB rather than 12dB |
| 217 | * Added additional information to /proc/ixj |
| 218 | * |
| 219 | * Revision 3.63 2000/11/28 11:38:41 craigs |
| 220 | * Added display of AEC modes in AUTO and AGC mode |
| 221 | * |
| 222 | * Revision 3.62 2000/11/28 04:05:44 eokerson |
| 223 | * Improved PSTN ring detection routine. |
| 224 | * |
| 225 | * Revision 3.61 2000/11/27 21:53:12 eokerson |
| 226 | * Fixed flash detection. |
| 227 | * |
| 228 | * Revision 3.60 2000/11/27 15:57:29 eokerson |
| 229 | * More work on G.729 load routines. |
| 230 | * |
| 231 | * Revision 3.59 2000/11/25 21:55:12 eokerson |
| 232 | * Fixed errors in G.729 load routine. |
| 233 | * |
| 234 | * Revision 3.58 2000/11/25 04:08:29 eokerson |
| 235 | * Added board locks around G.729 and TS85 load routines. |
| 236 | * |
| 237 | * Revision 3.57 2000/11/24 05:35:17 craigs |
| 238 | * Added ability to retrieve mixer values on LineJACK |
| 239 | * Added complete initialisation of all mixer values at startup |
| 240 | * Fixed spelling mistake |
| 241 | * |
| 242 | * Revision 3.56 2000/11/23 02:52:11 robertj |
| 243 | * Added cvs change log keyword. |
| 244 | * Fixed bug in capabilities list when using G.729 module. |
| 245 | * |
| 246 | */ |
| 247 | |
| 248 | #include "ixj-ver.h" |
| 249 | |
| 250 | #define PERFMON_STATS |
| 251 | #define IXJDEBUG 0 |
| 252 | #define MAXRINGS 5 |
| 253 | |
| 254 | #include <linux/module.h> |
| 255 | |
| 256 | #include <linux/init.h> |
| 257 | #include <linux/sched.h> |
| 258 | #include <linux/kernel.h> /* printk() */ |
| 259 | #include <linux/fs.h> /* everything... */ |
| 260 | #include <linux/errno.h> /* error codes */ |
| 261 | #include <linux/slab.h> |
| 262 | #include <linux/mm.h> |
| 263 | #include <linux/ioport.h> |
| 264 | #include <linux/interrupt.h> |
| 265 | #include <linux/proc_fs.h> |
| 266 | #include <linux/poll.h> |
| 267 | #include <linux/timer.h> |
| 268 | #include <linux/delay.h> |
| 269 | #include <linux/pci.h> |
| 270 | |
| 271 | #include <asm/io.h> |
| 272 | #include <asm/uaccess.h> |
| 273 | |
| 274 | #include <linux/isapnp.h> |
| 275 | |
| 276 | #include "ixj.h" |
| 277 | |
| 278 | #define TYPE(inode) (iminor(inode) >> 4) |
| 279 | #define NUM(inode) (iminor(inode) & 0xf) |
| 280 | |
| 281 | static int ixjdebug; |
| 282 | static int hertz = HZ; |
| 283 | static int samplerate = 100; |
| 284 | |
| 285 | module_param(ixjdebug, int, 0); |
| 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 | |
| 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 | |
| 330 | static void ixj_fsk_free(IXJ *j) |
| 331 | { |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 332 | kfree(j->fskdata); |
| 333 | j->fskdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | static void ixj_fsk_alloc(IXJ *j) |
| 337 | { |
| 338 | if(!j->fskdata) { |
| 339 | j->fskdata = kmalloc(8000, GFP_KERNEL); |
| 340 | if (!j->fskdata) { |
| 341 | if(ixjdebug & 0x0200) { |
| 342 | printk("IXJ phone%d - allocate failed\n", j->board); |
| 343 | } |
| 344 | return; |
| 345 | } else { |
| 346 | j->fsksize = 8000; |
| 347 | if(ixjdebug & 0x0200) { |
| 348 | printk("IXJ phone%d - allocate succeded\n", j->board); |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | #else |
| 355 | |
| 356 | static IXJ ixj[IXJMAX]; |
| 357 | #define get_ixj(b) (&ixj[(b)]) |
| 358 | |
| 359 | /* |
| 360 | * Allocate a free IXJ device |
| 361 | */ |
| 362 | |
| 363 | static IXJ *ixj_alloc(void) |
| 364 | { |
| 365 | int cnt; |
| 366 | for(cnt=0; cnt<IXJMAX; cnt++) { |
| 367 | if(!ixj[cnt].DSPbase) |
| 368 | return &ixj[cnt]; |
| 369 | } |
| 370 | return NULL; |
| 371 | } |
| 372 | |
| 373 | static inline void ixj_fsk_free(IXJ *j) {;} |
| 374 | |
| 375 | static inline void ixj_fsk_alloc(IXJ *j) |
| 376 | { |
| 377 | j->fsksize = 8000; |
| 378 | } |
| 379 | |
| 380 | #endif |
| 381 | |
| 382 | #ifdef PERFMON_STATS |
| 383 | #define ixj_perfmon(x) ((x)++) |
| 384 | #else |
| 385 | #define ixj_perfmon(x) do { } while(0) |
| 386 | #endif |
| 387 | |
| 388 | static int ixj_convert_loaded; |
| 389 | |
| 390 | static int ixj_WriteDSPCommand(unsigned short, IXJ *j); |
| 391 | |
| 392 | /************************************************************************ |
| 393 | * |
| 394 | * These are function definitions to allow external modules to register |
| 395 | * enhanced functionality call backs. |
| 396 | * |
| 397 | ************************************************************************/ |
| 398 | |
| 399 | static int Stub(IXJ * J, unsigned long arg) |
| 400 | { |
| 401 | return 0; |
| 402 | } |
| 403 | |
| 404 | static IXJ_REGFUNC ixj_PreRead = &Stub; |
| 405 | static IXJ_REGFUNC ixj_PostRead = &Stub; |
| 406 | static IXJ_REGFUNC ixj_PreWrite = &Stub; |
| 407 | static IXJ_REGFUNC ixj_PostWrite = &Stub; |
| 408 | |
| 409 | static void ixj_read_frame(IXJ *j); |
| 410 | static void ixj_write_frame(IXJ *j); |
| 411 | static void ixj_init_timer(IXJ *j); |
| 412 | static void ixj_add_timer(IXJ * j); |
| 413 | static void ixj_timeout(unsigned long ptr); |
| 414 | static int read_filters(IXJ *j); |
| 415 | static int LineMonitor(IXJ *j); |
| 416 | static int ixj_fasync(int fd, struct file *, int mode); |
| 417 | static int ixj_set_port(IXJ *j, int arg); |
| 418 | static int ixj_set_pots(IXJ *j, int arg); |
| 419 | static int ixj_hookstate(IXJ *j); |
| 420 | static int ixj_record_start(IXJ *j); |
| 421 | static void ixj_record_stop(IXJ *j); |
| 422 | static void set_rec_volume(IXJ *j, int volume); |
| 423 | static int get_rec_volume(IXJ *j); |
| 424 | static int set_rec_codec(IXJ *j, int rate); |
| 425 | static void ixj_vad(IXJ *j, int arg); |
| 426 | static int ixj_play_start(IXJ *j); |
| 427 | static void ixj_play_stop(IXJ *j); |
| 428 | static int ixj_set_tone_on(unsigned short arg, IXJ *j); |
| 429 | static int ixj_set_tone_off(unsigned short, IXJ *j); |
| 430 | static int ixj_play_tone(IXJ *j, char tone); |
| 431 | static void ixj_aec_start(IXJ *j, int level); |
| 432 | static int idle(IXJ *j); |
| 433 | static void ixj_ring_on(IXJ *j); |
| 434 | static void ixj_ring_off(IXJ *j); |
| 435 | static void aec_stop(IXJ *j); |
| 436 | static void ixj_ringback(IXJ *j); |
| 437 | static void ixj_busytone(IXJ *j); |
| 438 | static void ixj_dialtone(IXJ *j); |
| 439 | static void ixj_cpt_stop(IXJ *j); |
| 440 | static char daa_int_read(IXJ *j); |
| 441 | static char daa_CR_read(IXJ *j, int cr); |
| 442 | static int daa_set_mode(IXJ *j, int mode); |
| 443 | static int ixj_linetest(IXJ *j); |
| 444 | static int ixj_daa_write(IXJ *j); |
| 445 | static int ixj_daa_cid_read(IXJ *j); |
| 446 | static void DAA_Coeff_US(IXJ *j); |
| 447 | static void DAA_Coeff_UK(IXJ *j); |
| 448 | static void DAA_Coeff_France(IXJ *j); |
| 449 | static void DAA_Coeff_Germany(IXJ *j); |
| 450 | static void DAA_Coeff_Australia(IXJ *j); |
| 451 | static void DAA_Coeff_Japan(IXJ *j); |
| 452 | static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf); |
| 453 | static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr); |
| 454 | static int ixj_init_tone(IXJ *j, IXJ_TONE * ti); |
| 455 | static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp); |
| 456 | static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp); |
| 457 | /* Serial Control Interface funtions */ |
| 458 | static int SCI_Control(IXJ *j, int control); |
| 459 | static int SCI_Prepare(IXJ *j); |
| 460 | static int SCI_WaitHighSCI(IXJ *j); |
| 461 | static int SCI_WaitLowSCI(IXJ *j); |
| 462 | static DWORD PCIEE_GetSerialNumber(WORD wAddress); |
| 463 | static int ixj_PCcontrol_wait(IXJ *j); |
| 464 | static void ixj_pre_cid(IXJ *j); |
| 465 | static void ixj_write_cid(IXJ *j); |
| 466 | static void ixj_write_cid_bit(IXJ *j, int bit); |
| 467 | static int set_base_frame(IXJ *j, int size); |
| 468 | static int set_play_codec(IXJ *j, int rate); |
| 469 | static void set_rec_depth(IXJ *j, int depth); |
| 470 | static int ixj_mixer(long val, IXJ *j); |
| 471 | |
| 472 | /************************************************************************ |
| 473 | CT8020/CT8021 Host Programmers Model |
| 474 | Host address Function Access |
| 475 | DSPbase + |
| 476 | 0-1 Aux Software Status Register (reserved) Read Only |
| 477 | 2-3 Software Status Register Read Only |
| 478 | 4-5 Aux Software Control Register (reserved) Read Write |
| 479 | 6-7 Software Control Register Read Write |
| 480 | 8-9 Hardware Status Register Read Only |
| 481 | A-B Hardware Control Register Read Write |
| 482 | C-D Host Transmit (Write) Data Buffer Access Port (buffer input)Write Only |
| 483 | E-F Host Recieve (Read) Data Buffer Access Port (buffer input) Read Only |
| 484 | ************************************************************************/ |
| 485 | |
| 486 | static inline void ixj_read_HSR(IXJ *j) |
| 487 | { |
| 488 | j->hsr.bytes.low = inb_p(j->DSPbase + 8); |
| 489 | j->hsr.bytes.high = inb_p(j->DSPbase + 9); |
| 490 | } |
| 491 | |
| 492 | static inline int IsControlReady(IXJ *j) |
| 493 | { |
| 494 | ixj_read_HSR(j); |
| 495 | return j->hsr.bits.controlrdy ? 1 : 0; |
| 496 | } |
| 497 | |
| 498 | static inline int IsPCControlReady(IXJ *j) |
| 499 | { |
| 500 | j->pccr1.byte = inb_p(j->XILINXbase + 3); |
| 501 | return j->pccr1.bits.crr ? 1 : 0; |
| 502 | } |
| 503 | |
| 504 | static inline int IsStatusReady(IXJ *j) |
| 505 | { |
| 506 | ixj_read_HSR(j); |
| 507 | return j->hsr.bits.statusrdy ? 1 : 0; |
| 508 | } |
| 509 | |
| 510 | static inline int IsRxReady(IXJ *j) |
| 511 | { |
| 512 | ixj_read_HSR(j); |
| 513 | ixj_perfmon(j->rxreadycheck); |
| 514 | return j->hsr.bits.rxrdy ? 1 : 0; |
| 515 | } |
| 516 | |
| 517 | static inline int IsTxReady(IXJ *j) |
| 518 | { |
| 519 | ixj_read_HSR(j); |
| 520 | ixj_perfmon(j->txreadycheck); |
| 521 | return j->hsr.bits.txrdy ? 1 : 0; |
| 522 | } |
| 523 | |
| 524 | static inline void set_play_volume(IXJ *j, int volume) |
| 525 | { |
| 526 | if (ixjdebug & 0x0002) |
| 527 | printk(KERN_INFO "IXJ: /dev/phone%d Setting Play Volume to 0x%4.4x\n", j->board, volume); |
| 528 | ixj_WriteDSPCommand(0xCF02, j); |
| 529 | ixj_WriteDSPCommand(volume, j); |
| 530 | } |
| 531 | |
| 532 | static int set_play_volume_linear(IXJ *j, int volume) |
| 533 | { |
| 534 | int newvolume, dspplaymax; |
| 535 | |
| 536 | if (ixjdebug & 0x0002) |
| 537 | printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Play Volume to 0x%4.4x\n", j->board, volume); |
| 538 | if(volume > 100 || volume < 0) { |
| 539 | return -1; |
| 540 | } |
| 541 | |
| 542 | /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */ |
| 543 | switch (j->cardtype) { |
| 544 | case QTI_PHONEJACK: |
| 545 | dspplaymax = 0x380; |
| 546 | break; |
| 547 | case QTI_LINEJACK: |
| 548 | if(j->port == PORT_PSTN) { |
| 549 | dspplaymax = 0x48; |
| 550 | } else { |
| 551 | dspplaymax = 0x100; |
| 552 | } |
| 553 | break; |
| 554 | case QTI_PHONEJACK_LITE: |
| 555 | dspplaymax = 0x380; |
| 556 | break; |
| 557 | case QTI_PHONEJACK_PCI: |
| 558 | dspplaymax = 0x6C; |
| 559 | break; |
| 560 | case QTI_PHONECARD: |
| 561 | dspplaymax = 0x50; |
| 562 | break; |
| 563 | default: |
| 564 | return -1; |
| 565 | } |
| 566 | newvolume = (dspplaymax * volume) / 100; |
| 567 | set_play_volume(j, newvolume); |
| 568 | return 0; |
| 569 | } |
| 570 | |
| 571 | static inline void set_play_depth(IXJ *j, int depth) |
| 572 | { |
| 573 | if (depth > 60) |
| 574 | depth = 60; |
| 575 | if (depth < 0) |
| 576 | depth = 0; |
| 577 | ixj_WriteDSPCommand(0x5280 + depth, j); |
| 578 | } |
| 579 | |
| 580 | static inline int get_play_volume(IXJ *j) |
| 581 | { |
| 582 | ixj_WriteDSPCommand(0xCF00, j); |
| 583 | return j->ssr.high << 8 | j->ssr.low; |
| 584 | } |
| 585 | |
| 586 | static int get_play_volume_linear(IXJ *j) |
| 587 | { |
| 588 | int volume, newvolume, dspplaymax; |
| 589 | |
| 590 | /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */ |
| 591 | switch (j->cardtype) { |
| 592 | case QTI_PHONEJACK: |
| 593 | dspplaymax = 0x380; |
| 594 | break; |
| 595 | case QTI_LINEJACK: |
| 596 | if(j->port == PORT_PSTN) { |
| 597 | dspplaymax = 0x48; |
| 598 | } else { |
| 599 | dspplaymax = 0x100; |
| 600 | } |
| 601 | break; |
| 602 | case QTI_PHONEJACK_LITE: |
| 603 | dspplaymax = 0x380; |
| 604 | break; |
| 605 | case QTI_PHONEJACK_PCI: |
| 606 | dspplaymax = 0x6C; |
| 607 | break; |
| 608 | case QTI_PHONECARD: |
| 609 | dspplaymax = 100; |
| 610 | break; |
| 611 | default: |
| 612 | return -1; |
| 613 | } |
| 614 | volume = get_play_volume(j); |
| 615 | newvolume = (volume * 100) / dspplaymax; |
| 616 | if(newvolume > 100) |
| 617 | newvolume = 100; |
| 618 | return newvolume; |
| 619 | } |
| 620 | |
| 621 | static inline BYTE SLIC_GetState(IXJ *j) |
| 622 | { |
| 623 | if (j->cardtype == QTI_PHONECARD) { |
| 624 | j->pccr1.byte = 0; |
| 625 | j->psccr.bits.dev = 3; |
| 626 | j->psccr.bits.rw = 1; |
| 627 | outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00); |
| 628 | ixj_PCcontrol_wait(j); |
| 629 | j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF; |
| 630 | ixj_PCcontrol_wait(j); |
| 631 | if (j->pslic.bits.powerdown) |
| 632 | return PLD_SLIC_STATE_OC; |
| 633 | else if (!j->pslic.bits.ring0 && !j->pslic.bits.ring1) |
| 634 | return PLD_SLIC_STATE_ACTIVE; |
| 635 | else |
| 636 | return PLD_SLIC_STATE_RINGING; |
| 637 | } else { |
| 638 | j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01); |
| 639 | } |
| 640 | return j->pld_slicr.bits.state; |
| 641 | } |
| 642 | |
| 643 | static BOOL SLIC_SetState(BYTE byState, IXJ *j) |
| 644 | { |
| 645 | BOOL fRetVal = FALSE; |
| 646 | |
| 647 | if (j->cardtype == QTI_PHONECARD) { |
| 648 | if (j->flags.pcmciasct) { |
| 649 | switch (byState) { |
| 650 | case PLD_SLIC_STATE_TIPOPEN: |
| 651 | case PLD_SLIC_STATE_OC: |
| 652 | j->pslic.bits.powerdown = 1; |
| 653 | j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0; |
| 654 | fRetVal = TRUE; |
| 655 | break; |
| 656 | case PLD_SLIC_STATE_RINGING: |
| 657 | if (j->readers || j->writers) { |
| 658 | j->pslic.bits.powerdown = 0; |
| 659 | j->pslic.bits.ring0 = 1; |
| 660 | j->pslic.bits.ring1 = 0; |
| 661 | fRetVal = TRUE; |
| 662 | } |
| 663 | break; |
| 664 | case PLD_SLIC_STATE_OHT: /* On-hook transmit */ |
| 665 | |
| 666 | case PLD_SLIC_STATE_STANDBY: |
| 667 | case PLD_SLIC_STATE_ACTIVE: |
| 668 | if (j->readers || j->writers) { |
| 669 | j->pslic.bits.powerdown = 0; |
| 670 | } else { |
| 671 | j->pslic.bits.powerdown = 1; |
| 672 | } |
| 673 | j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0; |
| 674 | fRetVal = TRUE; |
| 675 | break; |
| 676 | case PLD_SLIC_STATE_APR: /* Active polarity reversal */ |
| 677 | |
| 678 | case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */ |
| 679 | |
| 680 | default: |
| 681 | fRetVal = FALSE; |
| 682 | break; |
| 683 | } |
| 684 | j->psccr.bits.dev = 3; |
| 685 | j->psccr.bits.rw = 0; |
| 686 | outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00); |
| 687 | ixj_PCcontrol_wait(j); |
| 688 | } |
| 689 | } else { |
| 690 | /* Set the C1, C2, C3 & B2EN signals. */ |
| 691 | switch (byState) { |
| 692 | case PLD_SLIC_STATE_OC: |
| 693 | j->pld_slicw.bits.c1 = 0; |
| 694 | j->pld_slicw.bits.c2 = 0; |
| 695 | j->pld_slicw.bits.c3 = 0; |
| 696 | j->pld_slicw.bits.b2en = 0; |
| 697 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 698 | fRetVal = TRUE; |
| 699 | break; |
| 700 | case PLD_SLIC_STATE_RINGING: |
| 701 | j->pld_slicw.bits.c1 = 1; |
| 702 | j->pld_slicw.bits.c2 = 0; |
| 703 | j->pld_slicw.bits.c3 = 0; |
| 704 | j->pld_slicw.bits.b2en = 1; |
| 705 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 706 | fRetVal = TRUE; |
| 707 | break; |
| 708 | case PLD_SLIC_STATE_ACTIVE: |
| 709 | j->pld_slicw.bits.c1 = 0; |
| 710 | j->pld_slicw.bits.c2 = 1; |
| 711 | j->pld_slicw.bits.c3 = 0; |
| 712 | j->pld_slicw.bits.b2en = 0; |
| 713 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 714 | fRetVal = TRUE; |
| 715 | break; |
| 716 | case PLD_SLIC_STATE_OHT: /* On-hook transmit */ |
| 717 | |
| 718 | j->pld_slicw.bits.c1 = 1; |
| 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_TIPOPEN: |
| 726 | j->pld_slicw.bits.c1 = 0; |
| 727 | j->pld_slicw.bits.c2 = 0; |
| 728 | j->pld_slicw.bits.c3 = 1; |
| 729 | j->pld_slicw.bits.b2en = 0; |
| 730 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 731 | fRetVal = TRUE; |
| 732 | break; |
| 733 | case PLD_SLIC_STATE_STANDBY: |
| 734 | j->pld_slicw.bits.c1 = 1; |
| 735 | j->pld_slicw.bits.c2 = 0; |
| 736 | j->pld_slicw.bits.c3 = 1; |
| 737 | j->pld_slicw.bits.b2en = 1; |
| 738 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 739 | fRetVal = TRUE; |
| 740 | break; |
| 741 | case PLD_SLIC_STATE_APR: /* Active polarity reversal */ |
| 742 | |
| 743 | j->pld_slicw.bits.c1 = 0; |
| 744 | j->pld_slicw.bits.c2 = 1; |
| 745 | j->pld_slicw.bits.c3 = 1; |
| 746 | j->pld_slicw.bits.b2en = 0; |
| 747 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 748 | fRetVal = TRUE; |
| 749 | break; |
| 750 | case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */ |
| 751 | |
| 752 | j->pld_slicw.bits.c1 = 1; |
| 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 | default: |
| 760 | fRetVal = FALSE; |
| 761 | break; |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | return fRetVal; |
| 766 | } |
| 767 | |
| 768 | static int ixj_wink(IXJ *j) |
| 769 | { |
| 770 | BYTE slicnow; |
| 771 | |
| 772 | slicnow = SLIC_GetState(j); |
| 773 | |
| 774 | j->pots_winkstart = jiffies; |
| 775 | SLIC_SetState(PLD_SLIC_STATE_OC, j); |
| 776 | |
| 777 | while (time_before(jiffies, j->pots_winkstart + j->winktime)) { |
| 778 | set_current_state(TASK_INTERRUPTIBLE); |
| 779 | schedule_timeout(1); |
| 780 | } |
| 781 | |
| 782 | SLIC_SetState(slicnow, j); |
| 783 | return 0; |
| 784 | } |
| 785 | |
| 786 | static void ixj_init_timer(IXJ *j) |
| 787 | { |
| 788 | init_timer(&j->timer); |
| 789 | j->timer.function = ixj_timeout; |
| 790 | j->timer.data = (unsigned long)j; |
| 791 | } |
| 792 | |
| 793 | static void ixj_add_timer(IXJ *j) |
| 794 | { |
| 795 | j->timer.expires = jiffies + (hertz / samplerate); |
| 796 | add_timer(&j->timer); |
| 797 | } |
| 798 | |
| 799 | static void ixj_tone_timeout(IXJ *j) |
| 800 | { |
| 801 | IXJ_TONE ti; |
| 802 | |
| 803 | j->tone_state++; |
| 804 | if (j->tone_state == 3) { |
| 805 | j->tone_state = 0; |
| 806 | if (j->cadence_t) { |
| 807 | j->tone_cadence_state++; |
| 808 | if (j->tone_cadence_state >= j->cadence_t->elements_used) { |
| 809 | switch (j->cadence_t->termination) { |
| 810 | case PLAY_ONCE: |
| 811 | ixj_cpt_stop(j); |
| 812 | break; |
| 813 | case REPEAT_LAST_ELEMENT: |
| 814 | j->tone_cadence_state--; |
| 815 | ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index); |
| 816 | break; |
| 817 | case REPEAT_ALL: |
| 818 | j->tone_cadence_state = 0; |
| 819 | if (j->cadence_t->ce[j->tone_cadence_state].freq0) { |
| 820 | ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index; |
| 821 | ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0; |
| 822 | ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0; |
| 823 | ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1; |
| 824 | ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1; |
| 825 | ixj_init_tone(j, &ti); |
| 826 | } |
| 827 | ixj_set_tone_on(j->cadence_t->ce[0].tone_on_time, j); |
| 828 | ixj_set_tone_off(j->cadence_t->ce[0].tone_off_time, j); |
| 829 | ixj_play_tone(j, j->cadence_t->ce[0].index); |
| 830 | break; |
| 831 | } |
| 832 | } else { |
| 833 | if (j->cadence_t->ce[j->tone_cadence_state].gain0) { |
| 834 | ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index; |
| 835 | ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0; |
| 836 | ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0; |
| 837 | ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1; |
| 838 | ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1; |
| 839 | ixj_init_tone(j, &ti); |
| 840 | } |
| 841 | ixj_set_tone_on(j->cadence_t->ce[j->tone_cadence_state].tone_on_time, j); |
| 842 | ixj_set_tone_off(j->cadence_t->ce[j->tone_cadence_state].tone_off_time, j); |
| 843 | ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index); |
| 844 | } |
| 845 | } |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | static inline void ixj_kill_fasync(IXJ *j, IXJ_SIGEVENT event, int dir) |
| 850 | { |
| 851 | if(j->ixj_signals[event]) { |
| 852 | if(ixjdebug & 0x0100) |
| 853 | printk("Sending signal for event %d\n", event); |
| 854 | /* Send apps notice of change */ |
| 855 | /* see config.h for macro definition */ |
| 856 | kill_fasync(&(j->async_queue), j->ixj_signals[event], dir); |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | static void ixj_pstn_state(IXJ *j) |
| 861 | { |
| 862 | int var; |
| 863 | union XOPXR0 XR0, daaint; |
| 864 | |
| 865 | var = 10; |
| 866 | |
| 867 | XR0.reg = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg; |
| 868 | daaint.reg = 0; |
| 869 | XR0.bitreg.RMR = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR; |
| 870 | |
| 871 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 872 | if (j->pld_scrr.bits.daaflag) { |
| 873 | daa_int_read(j); |
| 874 | if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.RING) { |
| 875 | if(time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) { |
| 876 | daaint.bitreg.RING = 1; |
| 877 | if(ixjdebug & 0x0008) { |
| 878 | printk(KERN_INFO "IXJ DAA Ring Interrupt /dev/phone%d at %ld\n", j->board, jiffies); |
| 879 | } |
| 880 | } else { |
| 881 | daa_set_mode(j, SOP_PU_RESET); |
| 882 | } |
| 883 | } |
| 884 | if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Caller_ID) { |
| 885 | daaint.bitreg.Caller_ID = 1; |
| 886 | j->pstn_cid_intr = 1; |
| 887 | j->pstn_cid_received = jiffies; |
| 888 | if(ixjdebug & 0x0008) { |
| 889 | printk(KERN_INFO "IXJ DAA Caller_ID Interrupt /dev/phone%d at %ld\n", j->board, jiffies); |
| 890 | } |
| 891 | } |
| 892 | if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Cadence) { |
| 893 | daaint.bitreg.Cadence = 1; |
| 894 | if(ixjdebug & 0x0008) { |
| 895 | printk(KERN_INFO "IXJ DAA Cadence Interrupt /dev/phone%d at %ld\n", j->board, jiffies); |
| 896 | } |
| 897 | } |
| 898 | if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK != XR0.bitreg.VDD_OK) { |
| 899 | daaint.bitreg.VDD_OK = 1; |
| 900 | daaint.bitreg.SI_0 = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK; |
| 901 | } |
| 902 | } |
| 903 | daa_CR_read(j, 1); |
| 904 | 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)) { |
| 905 | daaint.bitreg.RMR = 1; |
| 906 | daaint.bitreg.SI_1 = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR; |
| 907 | if(ixjdebug & 0x0008) { |
| 908 | 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); |
| 909 | } |
| 910 | j->pstn_prev_rmr = j->pstn_last_rmr; |
| 911 | j->pstn_last_rmr = jiffies; |
| 912 | } |
| 913 | switch(j->daa_mode) { |
| 914 | case SOP_PU_SLEEP: |
| 915 | if (daaint.bitreg.RING) { |
| 916 | if (!j->flags.pstn_ringing) { |
| 917 | if (j->daa_mode != SOP_PU_RINGING) { |
| 918 | j->pstn_ring_int = jiffies; |
| 919 | daa_set_mode(j, SOP_PU_RINGING); |
| 920 | } |
| 921 | } |
| 922 | } |
| 923 | break; |
| 924 | case SOP_PU_RINGING: |
| 925 | if (daaint.bitreg.RMR) { |
| 926 | if (ixjdebug & 0x0008) { |
| 927 | printk(KERN_INFO "IXJ Ring Cadence a state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies); |
| 928 | } |
| 929 | if (daaint.bitreg.SI_1) { /* Rising edge of RMR */ |
| 930 | j->flags.pstn_rmr = 1; |
| 931 | j->pstn_ring_start = jiffies; |
| 932 | j->pstn_ring_stop = 0; |
| 933 | j->ex.bits.pstn_ring = 0; |
| 934 | if (j->cadence_f[4].state == 0) { |
| 935 | j->cadence_f[4].state = 1; |
| 936 | j->cadence_f[4].on1min = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 - var)) / 10000); |
| 937 | j->cadence_f[4].on1dot = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100)) / 10000); |
| 938 | j->cadence_f[4].on1max = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 + var)) / 10000); |
| 939 | } else if (j->cadence_f[4].state == 2) { |
| 940 | if((time_after(jiffies, j->cadence_f[4].off1min) && |
| 941 | time_before(jiffies, j->cadence_f[4].off1max))) { |
| 942 | if (j->cadence_f[4].on2) { |
| 943 | j->cadence_f[4].state = 3; |
| 944 | j->cadence_f[4].on2min = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 - var)) / 10000)); |
| 945 | j->cadence_f[4].on2dot = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100)) / 10000)); |
| 946 | j->cadence_f[4].on2max = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 + var)) / 10000)); |
| 947 | } else { |
| 948 | j->cadence_f[4].state = 7; |
| 949 | } |
| 950 | } else { |
| 951 | if (ixjdebug & 0x0008) { |
| 952 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 953 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 954 | j->cadence_f[4].off1); |
| 955 | } |
| 956 | j->cadence_f[4].state = 0; |
| 957 | } |
| 958 | } else if (j->cadence_f[4].state == 4) { |
| 959 | if((time_after(jiffies, j->cadence_f[4].off2min) && |
| 960 | time_before(jiffies, j->cadence_f[4].off2max))) { |
| 961 | if (j->cadence_f[4].on3) { |
| 962 | j->cadence_f[4].state = 5; |
| 963 | j->cadence_f[4].on3min = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 - var)) / 10000)); |
| 964 | j->cadence_f[4].on3dot = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100)) / 10000)); |
| 965 | j->cadence_f[4].on3max = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 + var)) / 10000)); |
| 966 | } else { |
| 967 | j->cadence_f[4].state = 7; |
| 968 | } |
| 969 | } else { |
| 970 | if (ixjdebug & 0x0008) { |
| 971 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 972 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 973 | j->cadence_f[4].off2); |
| 974 | } |
| 975 | j->cadence_f[4].state = 0; |
| 976 | } |
| 977 | } else if (j->cadence_f[4].state == 6) { |
| 978 | if((time_after(jiffies, j->cadence_f[4].off3min) && |
| 979 | time_before(jiffies, j->cadence_f[4].off3max))) { |
| 980 | j->cadence_f[4].state = 7; |
| 981 | } else { |
| 982 | if (ixjdebug & 0x0008) { |
| 983 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 984 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 985 | j->cadence_f[4].off3); |
| 986 | } |
| 987 | j->cadence_f[4].state = 0; |
| 988 | } |
| 989 | } else { |
| 990 | j->cadence_f[4].state = 0; |
| 991 | } |
| 992 | } else { /* Falling edge of RMR */ |
| 993 | j->pstn_ring_start = 0; |
| 994 | j->pstn_ring_stop = jiffies; |
| 995 | if (j->cadence_f[4].state == 1) { |
| 996 | if(!j->cadence_f[4].on1) { |
| 997 | j->cadence_f[4].state = 7; |
| 998 | } else if((time_after(jiffies, j->cadence_f[4].on1min) && |
| 999 | time_before(jiffies, j->cadence_f[4].on1max))) { |
| 1000 | if (j->cadence_f[4].off1) { |
| 1001 | j->cadence_f[4].state = 2; |
| 1002 | j->cadence_f[4].off1min = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 - var)) / 10000)); |
| 1003 | j->cadence_f[4].off1dot = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100)) / 10000)); |
| 1004 | j->cadence_f[4].off1max = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 + var)) / 10000)); |
| 1005 | } else { |
| 1006 | j->cadence_f[4].state = 7; |
| 1007 | } |
| 1008 | } else { |
| 1009 | if (ixjdebug & 0x0008) { |
| 1010 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 1011 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 1012 | j->cadence_f[4].on1); |
| 1013 | } |
| 1014 | j->cadence_f[4].state = 0; |
| 1015 | } |
| 1016 | } else if (j->cadence_f[4].state == 3) { |
| 1017 | if((time_after(jiffies, j->cadence_f[4].on2min) && |
| 1018 | time_before(jiffies, j->cadence_f[4].on2max))) { |
| 1019 | if (j->cadence_f[4].off2) { |
| 1020 | j->cadence_f[4].state = 4; |
| 1021 | j->cadence_f[4].off2min = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 - var)) / 10000)); |
| 1022 | j->cadence_f[4].off2dot = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100)) / 10000)); |
| 1023 | j->cadence_f[4].off2max = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 + var)) / 10000)); |
| 1024 | } else { |
| 1025 | j->cadence_f[4].state = 7; |
| 1026 | } |
| 1027 | } else { |
| 1028 | if (ixjdebug & 0x0008) { |
| 1029 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 1030 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 1031 | j->cadence_f[4].on2); |
| 1032 | } |
| 1033 | j->cadence_f[4].state = 0; |
| 1034 | } |
| 1035 | } else if (j->cadence_f[4].state == 5) { |
| 1036 | if((time_after(jiffies, j->cadence_f[4].on3min) && |
| 1037 | time_before(jiffies, j->cadence_f[4].on3max))) { |
| 1038 | if (j->cadence_f[4].off3) { |
| 1039 | j->cadence_f[4].state = 6; |
| 1040 | j->cadence_f[4].off3min = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 - var)) / 10000)); |
| 1041 | j->cadence_f[4].off3dot = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100)) / 10000)); |
| 1042 | j->cadence_f[4].off3max = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 + var)) / 10000)); |
| 1043 | } else { |
| 1044 | j->cadence_f[4].state = 7; |
| 1045 | } |
| 1046 | } else { |
| 1047 | j->cadence_f[4].state = 0; |
| 1048 | } |
| 1049 | } else { |
| 1050 | if (ixjdebug & 0x0008) { |
| 1051 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 1052 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 1053 | j->cadence_f[4].on3); |
| 1054 | } |
| 1055 | j->cadence_f[4].state = 0; |
| 1056 | } |
| 1057 | } |
| 1058 | if (ixjdebug & 0x0010) { |
| 1059 | printk(KERN_INFO "IXJ Ring Cadence b state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies); |
| 1060 | } |
| 1061 | if (ixjdebug & 0x0010) { |
| 1062 | switch(j->cadence_f[4].state) { |
| 1063 | case 1: |
| 1064 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1065 | j->cadence_f[4].on1, j->cadence_f[4].on1min, j->cadence_f[4].on1dot, j->cadence_f[4].on1max); |
| 1066 | break; |
| 1067 | case 2: |
| 1068 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1069 | j->cadence_f[4].off1, j->cadence_f[4].off1min, j->cadence_f[4].off1dot, j->cadence_f[4].off1max); |
| 1070 | break; |
| 1071 | case 3: |
| 1072 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1073 | j->cadence_f[4].on2, j->cadence_f[4].on2min, j->cadence_f[4].on2dot, j->cadence_f[4].on2max); |
| 1074 | break; |
| 1075 | case 4: |
| 1076 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1077 | j->cadence_f[4].off2, j->cadence_f[4].off2min, j->cadence_f[4].off2dot, j->cadence_f[4].off2max); |
| 1078 | break; |
| 1079 | case 5: |
| 1080 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1081 | j->cadence_f[4].on3, j->cadence_f[4].on3min, j->cadence_f[4].on3dot, j->cadence_f[4].on3max); |
| 1082 | break; |
| 1083 | case 6: |
| 1084 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1085 | j->cadence_f[4].off3, j->cadence_f[4].off3min, j->cadence_f[4].off3dot, j->cadence_f[4].off3max); |
| 1086 | break; |
| 1087 | } |
| 1088 | } |
| 1089 | } |
| 1090 | if (j->cadence_f[4].state == 7) { |
| 1091 | j->cadence_f[4].state = 0; |
| 1092 | j->pstn_ring_stop = jiffies; |
| 1093 | j->ex.bits.pstn_ring = 1; |
| 1094 | ixj_kill_fasync(j, SIG_PSTN_RING, POLL_IN); |
| 1095 | if(ixjdebug & 0x0008) { |
| 1096 | printk(KERN_INFO "IXJ Ring int set /dev/phone%d at %ld\n", j->board, jiffies); |
| 1097 | } |
| 1098 | } |
| 1099 | if((j->pstn_ring_int != 0 && time_after(jiffies, j->pstn_ring_int + (hertz * 5)) && !j->flags.pstn_rmr) || |
| 1100 | (j->pstn_ring_stop != 0 && time_after(jiffies, j->pstn_ring_stop + (hertz * 5)))) { |
| 1101 | if(ixjdebug & 0x0008) { |
| 1102 | printk("IXJ DAA no ring in 5 seconds /dev/phone%d at %ld\n", j->board, jiffies); |
| 1103 | printk("IXJ DAA pstn ring int /dev/phone%d at %ld\n", j->board, j->pstn_ring_int); |
| 1104 | printk("IXJ DAA pstn ring stop /dev/phone%d at %ld\n", j->board, j->pstn_ring_stop); |
| 1105 | } |
| 1106 | j->pstn_ring_stop = j->pstn_ring_int = 0; |
| 1107 | daa_set_mode(j, SOP_PU_SLEEP); |
| 1108 | } |
| 1109 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 1110 | if (j->pstn_cid_intr && time_after(jiffies, j->pstn_cid_received + hertz)) { |
| 1111 | ixj_daa_cid_read(j); |
| 1112 | j->ex.bits.caller_id = 1; |
| 1113 | ixj_kill_fasync(j, SIG_CALLER_ID, POLL_IN); |
| 1114 | j->pstn_cid_intr = 0; |
| 1115 | } |
| 1116 | if (daaint.bitreg.Cadence) { |
| 1117 | if(ixjdebug & 0x0008) { |
| 1118 | printk("IXJ DAA Cadence interrupt going to sleep /dev/phone%d\n", j->board); |
| 1119 | } |
| 1120 | daa_set_mode(j, SOP_PU_SLEEP); |
| 1121 | j->ex.bits.pstn_ring = 0; |
| 1122 | } |
| 1123 | break; |
| 1124 | case SOP_PU_CONVERSATION: |
| 1125 | if (daaint.bitreg.VDD_OK) { |
| 1126 | if(!daaint.bitreg.SI_0) { |
| 1127 | if (!j->pstn_winkstart) { |
| 1128 | if(ixjdebug & 0x0008) { |
| 1129 | printk("IXJ DAA possible wink /dev/phone%d %ld\n", j->board, jiffies); |
| 1130 | } |
| 1131 | j->pstn_winkstart = jiffies; |
| 1132 | } |
| 1133 | } else { |
| 1134 | if (j->pstn_winkstart) { |
| 1135 | if(ixjdebug & 0x0008) { |
| 1136 | printk("IXJ DAA possible wink end /dev/phone%d %ld\n", j->board, jiffies); |
| 1137 | } |
| 1138 | j->pstn_winkstart = 0; |
| 1139 | } |
| 1140 | } |
| 1141 | } |
| 1142 | if (j->pstn_winkstart && time_after(jiffies, j->pstn_winkstart + ((hertz * j->winktime) / 1000))) { |
| 1143 | if(ixjdebug & 0x0008) { |
| 1144 | printk("IXJ DAA wink detected going to sleep /dev/phone%d %ld\n", j->board, jiffies); |
| 1145 | } |
| 1146 | daa_set_mode(j, SOP_PU_SLEEP); |
| 1147 | j->pstn_winkstart = 0; |
| 1148 | j->ex.bits.pstn_wink = 1; |
| 1149 | ixj_kill_fasync(j, SIG_PSTN_WINK, POLL_IN); |
| 1150 | } |
| 1151 | break; |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | static void ixj_timeout(unsigned long ptr) |
| 1156 | { |
| 1157 | int board; |
| 1158 | unsigned long jifon; |
| 1159 | IXJ *j = (IXJ *)ptr; |
| 1160 | board = j->board; |
| 1161 | |
| 1162 | if (j->DSPbase && atomic_read(&j->DSPWrite) == 0 && test_and_set_bit(board, (void *)&j->busyflags) == 0) { |
| 1163 | ixj_perfmon(j->timerchecks); |
| 1164 | j->hookstate = ixj_hookstate(j); |
| 1165 | if (j->tone_state) { |
| 1166 | if (!(j->hookstate)) { |
| 1167 | ixj_cpt_stop(j); |
| 1168 | if (j->m_hook) { |
| 1169 | j->m_hook = 0; |
| 1170 | j->ex.bits.hookstate = 1; |
| 1171 | ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN); |
| 1172 | } |
| 1173 | clear_bit(board, &j->busyflags); |
| 1174 | ixj_add_timer(j); |
| 1175 | return; |
| 1176 | } |
| 1177 | if (j->tone_state == 1) |
| 1178 | jifon = ((hertz * j->tone_on_time) * 25 / 100000); |
| 1179 | else |
| 1180 | jifon = ((hertz * j->tone_on_time) * 25 / 100000) + ((hertz * j->tone_off_time) * 25 / 100000); |
| 1181 | if (time_before(jiffies, j->tone_start_jif + jifon)) { |
| 1182 | if (j->tone_state == 1) { |
| 1183 | ixj_play_tone(j, j->tone_index); |
| 1184 | if (j->dsp.low == 0x20) { |
| 1185 | clear_bit(board, &j->busyflags); |
| 1186 | ixj_add_timer(j); |
| 1187 | return; |
| 1188 | } |
| 1189 | } else { |
| 1190 | ixj_play_tone(j, 0); |
| 1191 | if (j->dsp.low == 0x20) { |
| 1192 | clear_bit(board, &j->busyflags); |
| 1193 | ixj_add_timer(j); |
| 1194 | return; |
| 1195 | } |
| 1196 | } |
| 1197 | } else { |
| 1198 | ixj_tone_timeout(j); |
| 1199 | if (j->flags.dialtone) { |
| 1200 | ixj_dialtone(j); |
| 1201 | } |
| 1202 | if (j->flags.busytone) { |
| 1203 | ixj_busytone(j); |
| 1204 | if (j->dsp.low == 0x20) { |
| 1205 | clear_bit(board, &j->busyflags); |
| 1206 | ixj_add_timer(j); |
| 1207 | return; |
| 1208 | } |
| 1209 | } |
| 1210 | if (j->flags.ringback) { |
| 1211 | ixj_ringback(j); |
| 1212 | if (j->dsp.low == 0x20) { |
| 1213 | clear_bit(board, &j->busyflags); |
| 1214 | ixj_add_timer(j); |
| 1215 | return; |
| 1216 | } |
| 1217 | } |
| 1218 | if (!j->tone_state) { |
| 1219 | ixj_cpt_stop(j); |
| 1220 | } |
| 1221 | } |
| 1222 | } |
| 1223 | if (!(j->tone_state && j->dsp.low == 0x20)) { |
| 1224 | if (IsRxReady(j)) { |
| 1225 | ixj_read_frame(j); |
| 1226 | } |
| 1227 | if (IsTxReady(j)) { |
| 1228 | ixj_write_frame(j); |
| 1229 | } |
| 1230 | } |
| 1231 | if (j->flags.cringing) { |
| 1232 | if (j->hookstate & 1) { |
| 1233 | j->flags.cringing = 0; |
| 1234 | ixj_ring_off(j); |
| 1235 | } else if(j->cadence_f[5].enable && ((!j->cadence_f[5].en_filter) || (j->cadence_f[5].en_filter && j->flags.firstring))) { |
| 1236 | switch(j->cadence_f[5].state) { |
| 1237 | case 0: |
| 1238 | j->cadence_f[5].on1dot = jiffies + (long)((j->cadence_f[5].on1 * (hertz * 100) / 10000)); |
| 1239 | if (time_before(jiffies, j->cadence_f[5].on1dot)) { |
| 1240 | if(ixjdebug & 0x0004) { |
| 1241 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1242 | } |
| 1243 | ixj_ring_on(j); |
| 1244 | } |
| 1245 | j->cadence_f[5].state = 1; |
| 1246 | break; |
| 1247 | case 1: |
| 1248 | if (time_after(jiffies, j->cadence_f[5].on1dot)) { |
| 1249 | j->cadence_f[5].off1dot = jiffies + (long)((j->cadence_f[5].off1 * (hertz * 100) / 10000)); |
| 1250 | if(ixjdebug & 0x0004) { |
| 1251 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1252 | } |
| 1253 | ixj_ring_off(j); |
| 1254 | j->cadence_f[5].state = 2; |
| 1255 | } |
| 1256 | break; |
| 1257 | case 2: |
| 1258 | if (time_after(jiffies, j->cadence_f[5].off1dot)) { |
| 1259 | if(ixjdebug & 0x0004) { |
| 1260 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1261 | } |
| 1262 | ixj_ring_on(j); |
| 1263 | if (j->cadence_f[5].on2) { |
| 1264 | j->cadence_f[5].on2dot = jiffies + (long)((j->cadence_f[5].on2 * (hertz * 100) / 10000)); |
| 1265 | j->cadence_f[5].state = 3; |
| 1266 | } else { |
| 1267 | j->cadence_f[5].state = 7; |
| 1268 | } |
| 1269 | } |
| 1270 | break; |
| 1271 | case 3: |
| 1272 | if (time_after(jiffies, j->cadence_f[5].on2dot)) { |
| 1273 | if(ixjdebug & 0x0004) { |
| 1274 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1275 | } |
| 1276 | ixj_ring_off(j); |
| 1277 | if (j->cadence_f[5].off2) { |
| 1278 | j->cadence_f[5].off2dot = jiffies + (long)((j->cadence_f[5].off2 * (hertz * 100) / 10000)); |
| 1279 | j->cadence_f[5].state = 4; |
| 1280 | } else { |
| 1281 | j->cadence_f[5].state = 7; |
| 1282 | } |
| 1283 | } |
| 1284 | break; |
| 1285 | case 4: |
| 1286 | if (time_after(jiffies, j->cadence_f[5].off2dot)) { |
| 1287 | if(ixjdebug & 0x0004) { |
| 1288 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1289 | } |
| 1290 | ixj_ring_on(j); |
| 1291 | if (j->cadence_f[5].on3) { |
| 1292 | j->cadence_f[5].on3dot = jiffies + (long)((j->cadence_f[5].on3 * (hertz * 100) / 10000)); |
| 1293 | j->cadence_f[5].state = 5; |
| 1294 | } else { |
| 1295 | j->cadence_f[5].state = 7; |
| 1296 | } |
| 1297 | } |
| 1298 | break; |
| 1299 | case 5: |
| 1300 | if (time_after(jiffies, j->cadence_f[5].on3dot)) { |
| 1301 | if(ixjdebug & 0x0004) { |
| 1302 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1303 | } |
| 1304 | ixj_ring_off(j); |
| 1305 | if (j->cadence_f[5].off3) { |
| 1306 | j->cadence_f[5].off3dot = jiffies + (long)((j->cadence_f[5].off3 * (hertz * 100) / 10000)); |
| 1307 | j->cadence_f[5].state = 6; |
| 1308 | } else { |
| 1309 | j->cadence_f[5].state = 7; |
| 1310 | } |
| 1311 | } |
| 1312 | break; |
| 1313 | case 6: |
| 1314 | if (time_after(jiffies, j->cadence_f[5].off3dot)) { |
| 1315 | if(ixjdebug & 0x0004) { |
| 1316 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1317 | } |
| 1318 | j->cadence_f[5].state = 7; |
| 1319 | } |
| 1320 | break; |
| 1321 | case 7: |
| 1322 | if(ixjdebug & 0x0004) { |
| 1323 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1324 | } |
| 1325 | j->flags.cidring = 1; |
| 1326 | j->cadence_f[5].state = 0; |
| 1327 | break; |
| 1328 | } |
| 1329 | if (j->flags.cidring && !j->flags.cidsent) { |
| 1330 | j->flags.cidsent = 1; |
| 1331 | if(j->fskdcnt) { |
| 1332 | SLIC_SetState(PLD_SLIC_STATE_OHT, j); |
| 1333 | ixj_pre_cid(j); |
| 1334 | } |
| 1335 | j->flags.cidring = 0; |
| 1336 | } |
| 1337 | clear_bit(board, &j->busyflags); |
| 1338 | ixj_add_timer(j); |
| 1339 | return; |
| 1340 | } else { |
| 1341 | if (time_after(jiffies, j->ring_cadence_jif + (hertz / 2))) { |
| 1342 | if (j->flags.cidring && !j->flags.cidsent) { |
| 1343 | j->flags.cidsent = 1; |
| 1344 | if(j->fskdcnt) { |
| 1345 | SLIC_SetState(PLD_SLIC_STATE_OHT, j); |
| 1346 | ixj_pre_cid(j); |
| 1347 | } |
| 1348 | j->flags.cidring = 0; |
| 1349 | } |
| 1350 | j->ring_cadence_t--; |
| 1351 | if (j->ring_cadence_t == -1) |
| 1352 | j->ring_cadence_t = 15; |
| 1353 | j->ring_cadence_jif = jiffies; |
| 1354 | |
| 1355 | if (j->ring_cadence & 1 << j->ring_cadence_t) { |
| 1356 | if(j->flags.cidsent && j->cadence_f[5].en_filter) |
| 1357 | j->flags.firstring = 1; |
| 1358 | else |
| 1359 | ixj_ring_on(j); |
| 1360 | } else { |
| 1361 | ixj_ring_off(j); |
| 1362 | if(!j->flags.cidsent) |
| 1363 | j->flags.cidring = 1; |
| 1364 | } |
| 1365 | } |
| 1366 | clear_bit(board, &j->busyflags); |
| 1367 | ixj_add_timer(j); |
| 1368 | return; |
| 1369 | } |
| 1370 | } |
| 1371 | if (!j->flags.ringing) { |
| 1372 | if (j->hookstate) { /* & 1) { */ |
| 1373 | if (j->dsp.low != 0x20 && |
| 1374 | SLIC_GetState(j) != PLD_SLIC_STATE_ACTIVE) { |
| 1375 | SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); |
| 1376 | } |
| 1377 | LineMonitor(j); |
| 1378 | read_filters(j); |
| 1379 | ixj_WriteDSPCommand(0x511B, j); |
| 1380 | j->proc_load = j->ssr.high << 8 | j->ssr.low; |
| 1381 | if (!j->m_hook && (j->hookstate & 1)) { |
| 1382 | j->m_hook = j->ex.bits.hookstate = 1; |
| 1383 | ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN); |
| 1384 | } |
| 1385 | } else { |
| 1386 | if (j->ex.bits.dtmf_ready) { |
| 1387 | j->dtmf_wp = j->dtmf_rp = j->ex.bits.dtmf_ready = 0; |
| 1388 | } |
| 1389 | if (j->m_hook) { |
| 1390 | j->m_hook = 0; |
| 1391 | j->ex.bits.hookstate = 1; |
| 1392 | ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN); |
| 1393 | } |
| 1394 | } |
| 1395 | } |
| 1396 | if (j->cardtype == QTI_LINEJACK && !j->flags.pstncheck && j->flags.pstn_present) { |
| 1397 | ixj_pstn_state(j); |
| 1398 | } |
| 1399 | if (j->ex.bytes) { |
| 1400 | wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */ |
| 1401 | } |
| 1402 | clear_bit(board, &j->busyflags); |
| 1403 | } |
| 1404 | ixj_add_timer(j); |
| 1405 | } |
| 1406 | |
| 1407 | static int ixj_status_wait(IXJ *j) |
| 1408 | { |
| 1409 | unsigned long jif; |
| 1410 | |
| 1411 | jif = jiffies + ((60 * hertz) / 100); |
| 1412 | while (!IsStatusReady(j)) { |
| 1413 | ixj_perfmon(j->statuswait); |
| 1414 | if (time_after(jiffies, jif)) { |
| 1415 | ixj_perfmon(j->statuswaitfail); |
| 1416 | return -1; |
| 1417 | } |
| 1418 | } |
| 1419 | return 0; |
| 1420 | } |
| 1421 | |
| 1422 | static int ixj_PCcontrol_wait(IXJ *j) |
| 1423 | { |
| 1424 | unsigned long jif; |
| 1425 | |
| 1426 | jif = jiffies + ((60 * hertz) / 100); |
| 1427 | while (!IsPCControlReady(j)) { |
| 1428 | ixj_perfmon(j->pcontrolwait); |
| 1429 | if (time_after(jiffies, jif)) { |
| 1430 | ixj_perfmon(j->pcontrolwaitfail); |
| 1431 | return -1; |
| 1432 | } |
| 1433 | } |
| 1434 | return 0; |
| 1435 | } |
| 1436 | |
| 1437 | static int ixj_WriteDSPCommand(unsigned short cmd, IXJ *j) |
| 1438 | { |
| 1439 | BYTES bytes; |
| 1440 | unsigned long jif; |
| 1441 | |
| 1442 | atomic_inc(&j->DSPWrite); |
| 1443 | if(atomic_read(&j->DSPWrite) > 1) { |
| 1444 | printk("IXJ %d DSP write overlap attempting command 0x%4.4x\n", j->board, cmd); |
| 1445 | return -1; |
| 1446 | } |
| 1447 | bytes.high = (cmd & 0xFF00) >> 8; |
| 1448 | bytes.low = cmd & 0x00FF; |
| 1449 | jif = jiffies + ((60 * hertz) / 100); |
| 1450 | while (!IsControlReady(j)) { |
| 1451 | ixj_perfmon(j->iscontrolready); |
| 1452 | if (time_after(jiffies, jif)) { |
| 1453 | ixj_perfmon(j->iscontrolreadyfail); |
| 1454 | atomic_dec(&j->DSPWrite); |
| 1455 | if(atomic_read(&j->DSPWrite) > 0) { |
| 1456 | printk("IXJ %d DSP overlaped command 0x%4.4x during control ready failure.\n", j->board, cmd); |
| 1457 | while(atomic_read(&j->DSPWrite) > 0) { |
| 1458 | atomic_dec(&j->DSPWrite); |
| 1459 | } |
| 1460 | } |
| 1461 | return -1; |
| 1462 | } |
| 1463 | } |
| 1464 | outb(bytes.low, j->DSPbase + 6); |
| 1465 | outb(bytes.high, j->DSPbase + 7); |
| 1466 | |
| 1467 | if (ixj_status_wait(j)) { |
| 1468 | j->ssr.low = 0xFF; |
| 1469 | j->ssr.high = 0xFF; |
| 1470 | atomic_dec(&j->DSPWrite); |
| 1471 | if(atomic_read(&j->DSPWrite) > 0) { |
| 1472 | printk("IXJ %d DSP overlaped command 0x%4.4x during status wait failure.\n", j->board, cmd); |
| 1473 | while(atomic_read(&j->DSPWrite) > 0) { |
| 1474 | atomic_dec(&j->DSPWrite); |
| 1475 | } |
| 1476 | } |
| 1477 | return -1; |
| 1478 | } |
| 1479 | /* Read Software Status Register */ |
| 1480 | j->ssr.low = inb_p(j->DSPbase + 2); |
| 1481 | j->ssr.high = inb_p(j->DSPbase + 3); |
| 1482 | atomic_dec(&j->DSPWrite); |
| 1483 | if(atomic_read(&j->DSPWrite) > 0) { |
| 1484 | printk("IXJ %d DSP overlaped command 0x%4.4x\n", j->board, cmd); |
| 1485 | while(atomic_read(&j->DSPWrite) > 0) { |
| 1486 | atomic_dec(&j->DSPWrite); |
| 1487 | } |
| 1488 | } |
| 1489 | return 0; |
| 1490 | } |
| 1491 | |
| 1492 | /*************************************************************************** |
| 1493 | * |
| 1494 | * General Purpose IO Register read routine |
| 1495 | * |
| 1496 | ***************************************************************************/ |
| 1497 | static inline int ixj_gpio_read(IXJ *j) |
| 1498 | { |
| 1499 | if (ixj_WriteDSPCommand(0x5143, j)) |
| 1500 | return -1; |
| 1501 | |
| 1502 | j->gpio.bytes.low = j->ssr.low; |
| 1503 | j->gpio.bytes.high = j->ssr.high; |
| 1504 | |
| 1505 | return 0; |
| 1506 | } |
| 1507 | |
| 1508 | static inline void LED_SetState(int state, IXJ *j) |
| 1509 | { |
| 1510 | if (j->cardtype == QTI_LINEJACK) { |
| 1511 | j->pld_scrw.bits.led1 = state & 0x1 ? 1 : 0; |
| 1512 | j->pld_scrw.bits.led2 = state & 0x2 ? 1 : 0; |
| 1513 | j->pld_scrw.bits.led3 = state & 0x4 ? 1 : 0; |
| 1514 | j->pld_scrw.bits.led4 = state & 0x8 ? 1 : 0; |
| 1515 | |
| 1516 | outb(j->pld_scrw.byte, j->XILINXbase); |
| 1517 | } |
| 1518 | } |
| 1519 | |
| 1520 | /********************************************************************* |
| 1521 | * GPIO Pins are configured as follows on the Quicknet Internet |
| 1522 | * PhoneJACK Telephony Cards |
| 1523 | * |
| 1524 | * POTS Select GPIO_6=0 GPIO_7=0 |
| 1525 | * Mic/Speaker Select GPIO_6=0 GPIO_7=1 |
| 1526 | * Handset Select GPIO_6=1 GPIO_7=0 |
| 1527 | * |
| 1528 | * SLIC Active GPIO_1=0 GPIO_2=1 GPIO_5=0 |
| 1529 | * SLIC Ringing GPIO_1=1 GPIO_2=1 GPIO_5=0 |
| 1530 | * SLIC Open Circuit GPIO_1=0 GPIO_2=0 GPIO_5=0 |
| 1531 | * |
| 1532 | * Hook Switch changes reported on GPIO_3 |
| 1533 | *********************************************************************/ |
| 1534 | static int ixj_set_port(IXJ *j, int arg) |
| 1535 | { |
| 1536 | if (j->cardtype == QTI_PHONEJACK_LITE) { |
| 1537 | if (arg != PORT_POTS) |
| 1538 | return 10; |
| 1539 | else |
| 1540 | return 0; |
| 1541 | } |
| 1542 | switch (arg) { |
| 1543 | case PORT_POTS: |
| 1544 | j->port = PORT_POTS; |
| 1545 | switch (j->cardtype) { |
| 1546 | case QTI_PHONECARD: |
| 1547 | if (j->flags.pcmciasct == 1) |
| 1548 | SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); |
| 1549 | else |
| 1550 | return 11; |
| 1551 | break; |
| 1552 | case QTI_PHONEJACK_PCI: |
| 1553 | j->pld_slicw.pcib.mic = 0; |
| 1554 | j->pld_slicw.pcib.spk = 0; |
| 1555 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1556 | break; |
| 1557 | case QTI_LINEJACK: |
| 1558 | ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */ |
| 1559 | if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to |
| 1560 | Software Control Register */ |
| 1561 | return 2; |
| 1562 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 1563 | |
| 1564 | outb(j->pld_scrw.byte, j->XILINXbase); |
| 1565 | j->pld_clock.byte = 0; |
| 1566 | outb(j->pld_clock.byte, j->XILINXbase + 0x04); |
| 1567 | j->pld_slicw.bits.rly1 = 1; |
| 1568 | j->pld_slicw.bits.spken = 0; |
| 1569 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1570 | ixj_mixer(0x1200, j); /* Turn Off MIC switch on mixer left */ |
| 1571 | ixj_mixer(0x1401, j); /* Turn On Mono1 switch on mixer left */ |
| 1572 | ixj_mixer(0x1300, j); /* Turn Off MIC switch on mixer right */ |
| 1573 | ixj_mixer(0x1501, j); /* Turn On Mono1 switch on mixer right */ |
| 1574 | ixj_mixer(0x0E80, j); /*Mic mute */ |
| 1575 | ixj_mixer(0x0F00, j); /* Set mono out (SLIC) to 0dB */ |
| 1576 | ixj_mixer(0x0080, j); /* Mute Master Left volume */ |
| 1577 | ixj_mixer(0x0180, j); /* Mute Master Right volume */ |
| 1578 | SLIC_SetState(PLD_SLIC_STATE_STANDBY, j); |
| 1579 | /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */ |
| 1580 | break; |
| 1581 | case QTI_PHONEJACK: |
| 1582 | j->gpio.bytes.high = 0x0B; |
| 1583 | j->gpio.bits.gpio6 = 0; |
| 1584 | j->gpio.bits.gpio7 = 0; |
| 1585 | ixj_WriteDSPCommand(j->gpio.word, j); |
| 1586 | break; |
| 1587 | } |
| 1588 | break; |
| 1589 | case PORT_PSTN: |
| 1590 | if (j->cardtype == QTI_LINEJACK) { |
| 1591 | ixj_WriteDSPCommand(0xC534, j); /* Write CODEC config to Software Control Register */ |
| 1592 | |
| 1593 | j->pld_slicw.bits.rly3 = 0; |
| 1594 | j->pld_slicw.bits.rly1 = 1; |
| 1595 | j->pld_slicw.bits.spken = 0; |
| 1596 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1597 | j->port = PORT_PSTN; |
| 1598 | } else { |
| 1599 | return 4; |
| 1600 | } |
| 1601 | break; |
| 1602 | case PORT_SPEAKER: |
| 1603 | j->port = PORT_SPEAKER; |
| 1604 | switch (j->cardtype) { |
| 1605 | case QTI_PHONECARD: |
| 1606 | if (j->flags.pcmciasct) { |
| 1607 | SLIC_SetState(PLD_SLIC_STATE_OC, j); |
| 1608 | } |
| 1609 | break; |
| 1610 | case QTI_PHONEJACK_PCI: |
| 1611 | j->pld_slicw.pcib.mic = 1; |
| 1612 | j->pld_slicw.pcib.spk = 1; |
| 1613 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1614 | break; |
| 1615 | case QTI_LINEJACK: |
| 1616 | ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */ |
| 1617 | if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to |
| 1618 | Software Control Register */ |
| 1619 | return 2; |
| 1620 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 1621 | |
| 1622 | outb(j->pld_scrw.byte, j->XILINXbase); |
| 1623 | j->pld_clock.byte = 0; |
| 1624 | outb(j->pld_clock.byte, j->XILINXbase + 0x04); |
| 1625 | j->pld_slicw.bits.rly1 = 1; |
| 1626 | j->pld_slicw.bits.spken = 1; |
| 1627 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1628 | ixj_mixer(0x1201, j); /* Turn On MIC switch on mixer left */ |
| 1629 | ixj_mixer(0x1400, j); /* Turn Off Mono1 switch on mixer left */ |
| 1630 | ixj_mixer(0x1301, j); /* Turn On MIC switch on mixer right */ |
| 1631 | ixj_mixer(0x1500, j); /* Turn Off Mono1 switch on mixer right */ |
| 1632 | ixj_mixer(0x0E06, j); /*Mic un-mute 0dB */ |
| 1633 | ixj_mixer(0x0F80, j); /* Mute mono out (SLIC) */ |
| 1634 | ixj_mixer(0x0000, j); /* Set Master Left volume to 0dB */ |
| 1635 | ixj_mixer(0x0100, j); /* Set Master Right volume to 0dB */ |
| 1636 | break; |
| 1637 | case QTI_PHONEJACK: |
| 1638 | j->gpio.bytes.high = 0x0B; |
| 1639 | j->gpio.bits.gpio6 = 0; |
| 1640 | j->gpio.bits.gpio7 = 1; |
| 1641 | ixj_WriteDSPCommand(j->gpio.word, j); |
| 1642 | break; |
| 1643 | } |
| 1644 | break; |
| 1645 | case PORT_HANDSET: |
| 1646 | if (j->cardtype != QTI_PHONEJACK) { |
| 1647 | return 5; |
| 1648 | } else { |
| 1649 | j->gpio.bytes.high = 0x0B; |
| 1650 | j->gpio.bits.gpio6 = 1; |
| 1651 | j->gpio.bits.gpio7 = 0; |
| 1652 | ixj_WriteDSPCommand(j->gpio.word, j); |
| 1653 | j->port = PORT_HANDSET; |
| 1654 | } |
| 1655 | break; |
| 1656 | default: |
| 1657 | return 6; |
| 1658 | break; |
| 1659 | } |
| 1660 | return 0; |
| 1661 | } |
| 1662 | |
| 1663 | static int ixj_set_pots(IXJ *j, int arg) |
| 1664 | { |
| 1665 | if (j->cardtype == QTI_LINEJACK) { |
| 1666 | if (arg) { |
| 1667 | if (j->port == PORT_PSTN) { |
| 1668 | j->pld_slicw.bits.rly1 = 0; |
| 1669 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1670 | j->flags.pots_pstn = 1; |
| 1671 | return 1; |
| 1672 | } else { |
| 1673 | j->flags.pots_pstn = 0; |
| 1674 | return 0; |
| 1675 | } |
| 1676 | } else { |
| 1677 | j->pld_slicw.bits.rly1 = 1; |
| 1678 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1679 | j->flags.pots_pstn = 0; |
| 1680 | return 1; |
| 1681 | } |
| 1682 | } else { |
| 1683 | return 0; |
| 1684 | } |
| 1685 | } |
| 1686 | |
| 1687 | static void ixj_ring_on(IXJ *j) |
| 1688 | { |
| 1689 | if (j->dsp.low == 0x20) /* Internet PhoneJACK */ |
| 1690 | { |
| 1691 | if (ixjdebug & 0x0004) |
| 1692 | printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board); |
| 1693 | |
| 1694 | j->gpio.bytes.high = 0x0B; |
| 1695 | j->gpio.bytes.low = 0x00; |
| 1696 | j->gpio.bits.gpio1 = 1; |
| 1697 | j->gpio.bits.gpio2 = 1; |
| 1698 | j->gpio.bits.gpio5 = 0; |
| 1699 | ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring signal */ |
| 1700 | } else /* Internet LineJACK, Internet PhoneJACK Lite or Internet PhoneJACK PCI */ |
| 1701 | { |
| 1702 | if (ixjdebug & 0x0004) |
| 1703 | printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board); |
| 1704 | |
| 1705 | SLIC_SetState(PLD_SLIC_STATE_RINGING, j); |
| 1706 | } |
| 1707 | } |
| 1708 | |
| 1709 | static int ixj_siadc(IXJ *j, int val) |
| 1710 | { |
| 1711 | if(j->cardtype == QTI_PHONECARD){ |
| 1712 | if(j->flags.pcmciascp){ |
| 1713 | if(val == -1) |
| 1714 | return j->siadc.bits.rxg; |
| 1715 | |
| 1716 | if(val < 0 || val > 0x1F) |
| 1717 | return -1; |
| 1718 | |
| 1719 | j->siadc.bits.hom = 0; /* Handset Out Mute */ |
| 1720 | j->siadc.bits.lom = 0; /* Line Out Mute */ |
| 1721 | j->siadc.bits.rxg = val; /*(0xC000 - 0x41C8) / 0x4EF; RX PGA Gain */ |
| 1722 | j->psccr.bits.addr = 6; /* R/W Smart Cable Register Address */ |
| 1723 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1724 | j->psccr.bits.dev = 0; |
| 1725 | outb(j->siadc.byte, j->XILINXbase + 0x00); |
| 1726 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1727 | ixj_PCcontrol_wait(j); |
| 1728 | return j->siadc.bits.rxg; |
| 1729 | } |
| 1730 | } |
| 1731 | return -1; |
| 1732 | } |
| 1733 | |
| 1734 | static int ixj_sidac(IXJ *j, int val) |
| 1735 | { |
| 1736 | if(j->cardtype == QTI_PHONECARD){ |
| 1737 | if(j->flags.pcmciascp){ |
| 1738 | if(val == -1) |
| 1739 | return j->sidac.bits.txg; |
| 1740 | |
| 1741 | if(val < 0 || val > 0x1F) |
| 1742 | return -1; |
| 1743 | |
| 1744 | j->sidac.bits.srm = 1; /* Speaker Right Mute */ |
| 1745 | j->sidac.bits.slm = 1; /* Speaker Left Mute */ |
| 1746 | j->sidac.bits.txg = val; /* (0xC000 - 0x45E4) / 0x5D3; TX PGA Gain */ |
| 1747 | j->psccr.bits.addr = 7; /* R/W Smart Cable Register Address */ |
| 1748 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1749 | j->psccr.bits.dev = 0; |
| 1750 | outb(j->sidac.byte, j->XILINXbase + 0x00); |
| 1751 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1752 | ixj_PCcontrol_wait(j); |
| 1753 | return j->sidac.bits.txg; |
| 1754 | } |
| 1755 | } |
| 1756 | return -1; |
| 1757 | } |
| 1758 | |
| 1759 | static int ixj_pcmcia_cable_check(IXJ *j) |
| 1760 | { |
| 1761 | j->pccr1.byte = inb_p(j->XILINXbase + 0x03); |
| 1762 | if (!j->flags.pcmciastate) { |
| 1763 | j->pccr2.byte = inb_p(j->XILINXbase + 0x02); |
| 1764 | if (j->pccr1.bits.drf || j->pccr2.bits.rstc) { |
| 1765 | j->flags.pcmciastate = 4; |
| 1766 | return 0; |
| 1767 | } |
| 1768 | if (j->pccr1.bits.ed) { |
| 1769 | j->pccr1.bits.ed = 0; |
| 1770 | j->psccr.bits.dev = 3; |
| 1771 | j->psccr.bits.rw = 1; |
| 1772 | outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00); |
| 1773 | ixj_PCcontrol_wait(j); |
| 1774 | j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF; |
| 1775 | j->pslic.bits.led2 = j->pslic.bits.det ? 1 : 0; |
| 1776 | j->psccr.bits.dev = 3; |
| 1777 | j->psccr.bits.rw = 0; |
| 1778 | outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00); |
| 1779 | ixj_PCcontrol_wait(j); |
| 1780 | return j->pslic.bits.led2 ? 1 : 0; |
| 1781 | } else if (j->flags.pcmciasct) { |
| 1782 | return j->r_hook; |
| 1783 | } else { |
| 1784 | return 1; |
| 1785 | } |
| 1786 | } else if (j->flags.pcmciastate == 4) { |
| 1787 | if (!j->pccr1.bits.drf) { |
| 1788 | j->flags.pcmciastate = 3; |
| 1789 | } |
| 1790 | return 0; |
| 1791 | } else if (j->flags.pcmciastate == 3) { |
| 1792 | j->pccr2.bits.pwr = 0; |
| 1793 | j->pccr2.bits.rstc = 1; |
| 1794 | outb(j->pccr2.byte, j->XILINXbase + 0x02); |
| 1795 | j->checkwait = jiffies + (hertz * 2); |
| 1796 | j->flags.incheck = 1; |
| 1797 | j->flags.pcmciastate = 2; |
| 1798 | return 0; |
| 1799 | } else if (j->flags.pcmciastate == 2) { |
| 1800 | if (j->flags.incheck) { |
| 1801 | if (time_before(jiffies, j->checkwait)) { |
| 1802 | return 0; |
| 1803 | } else { |
| 1804 | j->flags.incheck = 0; |
| 1805 | } |
| 1806 | } |
| 1807 | j->pccr2.bits.pwr = 0; |
| 1808 | j->pccr2.bits.rstc = 0; |
| 1809 | outb_p(j->pccr2.byte, j->XILINXbase + 0x02); |
| 1810 | j->flags.pcmciastate = 1; |
| 1811 | return 0; |
| 1812 | } else if (j->flags.pcmciastate == 1) { |
| 1813 | j->flags.pcmciastate = 0; |
| 1814 | if (!j->pccr1.bits.drf) { |
| 1815 | j->psccr.bits.dev = 3; |
| 1816 | j->psccr.bits.rw = 1; |
| 1817 | outb_p(j->psccr.byte, j->XILINXbase + 0x01); |
| 1818 | ixj_PCcontrol_wait(j); |
| 1819 | j->flags.pcmciascp = 1; /* Set Cable Present Flag */ |
| 1820 | |
| 1821 | j->flags.pcmciasct = (inw_p(j->XILINXbase + 0x00) >> 8) & 0x03; /* Get Cable Type */ |
| 1822 | |
| 1823 | if (j->flags.pcmciasct == 3) { |
| 1824 | j->flags.pcmciastate = 4; |
| 1825 | return 0; |
| 1826 | } else if (j->flags.pcmciasct == 0) { |
| 1827 | j->pccr2.bits.pwr = 1; |
| 1828 | j->pccr2.bits.rstc = 0; |
| 1829 | outb_p(j->pccr2.byte, j->XILINXbase + 0x02); |
| 1830 | j->port = PORT_SPEAKER; |
| 1831 | } else { |
| 1832 | j->port = PORT_POTS; |
| 1833 | } |
| 1834 | j->sic1.bits.cpd = 0; /* Chip Power Down */ |
| 1835 | j->sic1.bits.mpd = 0; /* MIC Bias Power Down */ |
| 1836 | j->sic1.bits.hpd = 0; /* Handset Bias Power Down */ |
| 1837 | j->sic1.bits.lpd = 0; /* Line Bias Power Down */ |
| 1838 | j->sic1.bits.spd = 1; /* Speaker Drive Power Down */ |
| 1839 | j->psccr.bits.addr = 1; /* R/W Smart Cable Register Address */ |
| 1840 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1841 | j->psccr.bits.dev = 0; |
| 1842 | outb(j->sic1.byte, j->XILINXbase + 0x00); |
| 1843 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1844 | ixj_PCcontrol_wait(j); |
| 1845 | |
| 1846 | j->sic2.bits.al = 0; /* Analog Loopback DAC analog -> ADC analog */ |
| 1847 | j->sic2.bits.dl2 = 0; /* Digital Loopback DAC -> ADC one bit */ |
| 1848 | j->sic2.bits.dl1 = 0; /* Digital Loopback ADC -> DAC one bit */ |
| 1849 | j->sic2.bits.pll = 0; /* 1 = div 10, 0 = div 5 */ |
| 1850 | j->sic2.bits.hpd = 0; /* HPF disable */ |
| 1851 | j->psccr.bits.addr = 2; /* R/W Smart Cable Register Address */ |
| 1852 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1853 | j->psccr.bits.dev = 0; |
| 1854 | outb(j->sic2.byte, j->XILINXbase + 0x00); |
| 1855 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1856 | ixj_PCcontrol_wait(j); |
| 1857 | |
| 1858 | j->psccr.bits.addr = 3; /* R/W Smart Cable Register Address */ |
| 1859 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1860 | j->psccr.bits.dev = 0; |
| 1861 | outb(0x00, j->XILINXbase + 0x00); /* PLL Divide N1 */ |
| 1862 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1863 | ixj_PCcontrol_wait(j); |
| 1864 | |
| 1865 | j->psccr.bits.addr = 4; /* R/W Smart Cable Register Address */ |
| 1866 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1867 | j->psccr.bits.dev = 0; |
| 1868 | outb(0x09, j->XILINXbase + 0x00); /* PLL Multiply M1 */ |
| 1869 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1870 | ixj_PCcontrol_wait(j); |
| 1871 | |
| 1872 | j->sirxg.bits.lig = 1; /* Line In Gain */ |
| 1873 | j->sirxg.bits.lim = 1; /* Line In Mute */ |
| 1874 | j->sirxg.bits.mcg = 0; /* MIC In Gain was 3 */ |
| 1875 | j->sirxg.bits.mcm = 0; /* MIC In Mute */ |
| 1876 | j->sirxg.bits.him = 0; /* Handset In Mute */ |
| 1877 | j->sirxg.bits.iir = 1; /* IIR */ |
| 1878 | j->psccr.bits.addr = 5; /* R/W Smart Cable Register Address */ |
| 1879 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1880 | j->psccr.bits.dev = 0; |
| 1881 | outb(j->sirxg.byte, j->XILINXbase + 0x00); |
| 1882 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1883 | ixj_PCcontrol_wait(j); |
| 1884 | |
| 1885 | ixj_siadc(j, 0x17); |
| 1886 | ixj_sidac(j, 0x1D); |
| 1887 | |
| 1888 | j->siaatt.bits.sot = 0; |
| 1889 | j->psccr.bits.addr = 9; /* R/W Smart Cable Register Address */ |
| 1890 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1891 | j->psccr.bits.dev = 0; |
| 1892 | outb(j->siaatt.byte, j->XILINXbase + 0x00); |
| 1893 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1894 | ixj_PCcontrol_wait(j); |
| 1895 | |
| 1896 | if (j->flags.pcmciasct == 1 && !j->readers && !j->writers) { |
| 1897 | j->psccr.byte = j->pslic.byte = 0; |
| 1898 | j->pslic.bits.powerdown = 1; |
| 1899 | j->psccr.bits.dev = 3; |
| 1900 | j->psccr.bits.rw = 0; |
| 1901 | outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00); |
| 1902 | ixj_PCcontrol_wait(j); |
| 1903 | } |
| 1904 | } |
| 1905 | return 0; |
| 1906 | } else { |
| 1907 | j->flags.pcmciascp = 0; |
| 1908 | return 0; |
| 1909 | } |
| 1910 | return 0; |
| 1911 | } |
| 1912 | |
| 1913 | static int ixj_hookstate(IXJ *j) |
| 1914 | { |
| 1915 | unsigned long det; |
| 1916 | int fOffHook = 0; |
| 1917 | |
| 1918 | switch (j->cardtype) { |
| 1919 | case QTI_PHONEJACK: |
| 1920 | ixj_gpio_read(j); |
| 1921 | fOffHook = j->gpio.bits.gpio3read ? 1 : 0; |
| 1922 | break; |
| 1923 | case QTI_LINEJACK: |
| 1924 | case QTI_PHONEJACK_LITE: |
| 1925 | case QTI_PHONEJACK_PCI: |
| 1926 | SLIC_GetState(j); |
| 1927 | if(j->cardtype == QTI_LINEJACK && j->flags.pots_pstn == 1 && (j->readers || j->writers)) { |
| 1928 | fOffHook = j->pld_slicr.bits.potspstn ? 1 : 0; |
| 1929 | if(fOffHook != j->p_hook) { |
| 1930 | if(!j->checkwait) { |
| 1931 | j->checkwait = jiffies; |
| 1932 | } |
| 1933 | if(time_before(jiffies, j->checkwait + 2)) { |
| 1934 | fOffHook ^= 1; |
| 1935 | } else { |
| 1936 | j->checkwait = 0; |
| 1937 | } |
| 1938 | j->p_hook = fOffHook; |
| 1939 | printk("IXJ : /dev/phone%d pots-pstn hookstate check %d at %ld\n", j->board, fOffHook, jiffies); |
| 1940 | } |
| 1941 | } else { |
| 1942 | if (j->pld_slicr.bits.state == PLD_SLIC_STATE_ACTIVE || |
| 1943 | j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) { |
| 1944 | if (j->flags.ringing || j->flags.cringing) { |
| 1945 | if (!in_interrupt()) { |
| 1946 | det = jiffies + (hertz / 50); |
| 1947 | while (time_before(jiffies, det)) { |
| 1948 | set_current_state(TASK_INTERRUPTIBLE); |
| 1949 | schedule_timeout(1); |
| 1950 | } |
| 1951 | } |
| 1952 | SLIC_GetState(j); |
| 1953 | if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) { |
| 1954 | ixj_ring_on(j); |
| 1955 | } |
| 1956 | } |
| 1957 | if (j->cardtype == QTI_PHONEJACK_PCI) { |
| 1958 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 1959 | fOffHook = j->pld_scrr.pcib.det ? 1 : 0; |
| 1960 | } else |
| 1961 | fOffHook = j->pld_slicr.bits.det ? 1 : 0; |
| 1962 | } |
| 1963 | } |
| 1964 | break; |
| 1965 | case QTI_PHONECARD: |
| 1966 | fOffHook = ixj_pcmcia_cable_check(j); |
| 1967 | break; |
| 1968 | } |
| 1969 | if (j->r_hook != fOffHook) { |
| 1970 | j->r_hook = fOffHook; |
| 1971 | if (j->port == PORT_SPEAKER || j->port == PORT_HANDSET) { // || (j->port == PORT_PSTN && j->flags.pots_pstn == 0)) { |
| 1972 | j->ex.bits.hookstate = 1; |
| 1973 | ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN); |
| 1974 | } else if (!fOffHook) { |
| 1975 | j->flash_end = jiffies + ((60 * hertz) / 100); |
| 1976 | } |
| 1977 | } |
| 1978 | if (fOffHook) { |
| 1979 | if(time_before(jiffies, j->flash_end)) { |
| 1980 | j->ex.bits.flash = 1; |
| 1981 | j->flash_end = 0; |
| 1982 | ixj_kill_fasync(j, SIG_FLASH, POLL_IN); |
| 1983 | } |
| 1984 | } else { |
| 1985 | if(time_before(jiffies, j->flash_end)) { |
| 1986 | fOffHook = 1; |
| 1987 | } |
| 1988 | } |
| 1989 | |
| 1990 | if (j->port == PORT_PSTN && j->daa_mode == SOP_PU_CONVERSATION) |
| 1991 | fOffHook |= 2; |
| 1992 | |
| 1993 | if (j->port == PORT_SPEAKER) { |
| 1994 | if(j->cardtype == QTI_PHONECARD) { |
| 1995 | if(j->flags.pcmciascp && j->flags.pcmciasct) { |
| 1996 | fOffHook |= 2; |
| 1997 | } |
| 1998 | } else { |
| 1999 | fOffHook |= 2; |
| 2000 | } |
| 2001 | } |
| 2002 | |
| 2003 | if (j->port == PORT_HANDSET) |
| 2004 | fOffHook |= 2; |
| 2005 | |
| 2006 | return fOffHook; |
| 2007 | } |
| 2008 | |
| 2009 | static void ixj_ring_off(IXJ *j) |
| 2010 | { |
| 2011 | if (j->dsp.low == 0x20) /* Internet PhoneJACK */ |
| 2012 | { |
| 2013 | if (ixjdebug & 0x0004) |
| 2014 | printk(KERN_INFO "IXJ Ring Off\n"); |
| 2015 | j->gpio.bytes.high = 0x0B; |
| 2016 | j->gpio.bytes.low = 0x00; |
| 2017 | j->gpio.bits.gpio1 = 0; |
| 2018 | j->gpio.bits.gpio2 = 1; |
| 2019 | j->gpio.bits.gpio5 = 0; |
| 2020 | ixj_WriteDSPCommand(j->gpio.word, j); |
| 2021 | } else /* Internet LineJACK */ |
| 2022 | { |
| 2023 | if (ixjdebug & 0x0004) |
| 2024 | printk(KERN_INFO "IXJ Ring Off\n"); |
| 2025 | |
| 2026 | if(!j->flags.cidplay) |
| 2027 | SLIC_SetState(PLD_SLIC_STATE_STANDBY, j); |
| 2028 | |
| 2029 | SLIC_GetState(j); |
| 2030 | } |
| 2031 | } |
| 2032 | |
| 2033 | static void ixj_ring_start(IXJ *j) |
| 2034 | { |
| 2035 | j->flags.cringing = 1; |
| 2036 | if (ixjdebug & 0x0004) |
| 2037 | printk(KERN_INFO "IXJ Cadence Ringing Start /dev/phone%d\n", j->board); |
| 2038 | if (ixj_hookstate(j) & 1) { |
| 2039 | if (j->port == PORT_POTS) |
| 2040 | ixj_ring_off(j); |
| 2041 | j->flags.cringing = 0; |
| 2042 | if (ixjdebug & 0x0004) |
| 2043 | printk(KERN_INFO "IXJ Cadence Ringing Stopped /dev/phone%d off hook\n", j->board); |
| 2044 | } else if(j->cadence_f[5].enable && (!j->cadence_f[5].en_filter)) { |
| 2045 | j->ring_cadence_jif = jiffies; |
| 2046 | j->flags.cidsent = j->flags.cidring = 0; |
| 2047 | j->cadence_f[5].state = 0; |
| 2048 | if(j->cadence_f[5].on1) |
| 2049 | ixj_ring_on(j); |
| 2050 | } else { |
| 2051 | j->ring_cadence_jif = jiffies; |
| 2052 | j->ring_cadence_t = 15; |
| 2053 | if (j->ring_cadence & 1 << j->ring_cadence_t) { |
| 2054 | ixj_ring_on(j); |
| 2055 | } else { |
| 2056 | ixj_ring_off(j); |
| 2057 | } |
| 2058 | j->flags.cidsent = j->flags.cidring = j->flags.firstring = 0; |
| 2059 | } |
| 2060 | } |
| 2061 | |
| 2062 | static int ixj_ring(IXJ *j) |
| 2063 | { |
| 2064 | char cntr; |
| 2065 | unsigned long jif, det; |
| 2066 | |
| 2067 | j->flags.ringing = 1; |
| 2068 | if (ixj_hookstate(j) & 1) { |
| 2069 | ixj_ring_off(j); |
| 2070 | j->flags.ringing = 0; |
| 2071 | return 1; |
| 2072 | } |
| 2073 | det = 0; |
| 2074 | for (cntr = 0; cntr < j->maxrings; cntr++) { |
| 2075 | jif = jiffies + (1 * hertz); |
| 2076 | ixj_ring_on(j); |
| 2077 | while (time_before(jiffies, jif)) { |
| 2078 | if (ixj_hookstate(j) & 1) { |
| 2079 | ixj_ring_off(j); |
| 2080 | j->flags.ringing = 0; |
| 2081 | return 1; |
| 2082 | } |
| 2083 | set_current_state(TASK_INTERRUPTIBLE); |
| 2084 | schedule_timeout(1); |
| 2085 | if (signal_pending(current)) |
| 2086 | break; |
| 2087 | } |
| 2088 | jif = jiffies + (3 * hertz); |
| 2089 | ixj_ring_off(j); |
| 2090 | while (time_before(jiffies, jif)) { |
| 2091 | if (ixj_hookstate(j) & 1) { |
| 2092 | det = jiffies + (hertz / 100); |
| 2093 | while (time_before(jiffies, det)) { |
| 2094 | set_current_state(TASK_INTERRUPTIBLE); |
| 2095 | schedule_timeout(1); |
| 2096 | if (signal_pending(current)) |
| 2097 | break; |
| 2098 | } |
| 2099 | if (ixj_hookstate(j) & 1) { |
| 2100 | j->flags.ringing = 0; |
| 2101 | return 1; |
| 2102 | } |
| 2103 | } |
| 2104 | set_current_state(TASK_INTERRUPTIBLE); |
| 2105 | schedule_timeout(1); |
| 2106 | if (signal_pending(current)) |
| 2107 | break; |
| 2108 | } |
| 2109 | } |
| 2110 | ixj_ring_off(j); |
| 2111 | j->flags.ringing = 0; |
| 2112 | return 0; |
| 2113 | } |
| 2114 | |
| 2115 | static int ixj_open(struct phone_device *p, struct file *file_p) |
| 2116 | { |
| 2117 | IXJ *j = get_ixj(p->board); |
| 2118 | file_p->private_data = j; |
| 2119 | |
| 2120 | if (!j->DSPbase) |
| 2121 | return -ENODEV; |
| 2122 | |
| 2123 | if (file_p->f_mode & FMODE_READ) { |
| 2124 | if(!j->readers) { |
| 2125 | j->readers++; |
| 2126 | } else { |
| 2127 | return -EBUSY; |
| 2128 | } |
| 2129 | } |
| 2130 | |
| 2131 | if (file_p->f_mode & FMODE_WRITE) { |
| 2132 | if(!j->writers) { |
| 2133 | j->writers++; |
| 2134 | } else { |
| 2135 | if (file_p->f_mode & FMODE_READ){ |
| 2136 | j->readers--; |
| 2137 | } |
| 2138 | return -EBUSY; |
| 2139 | } |
| 2140 | } |
| 2141 | |
| 2142 | if (j->cardtype == QTI_PHONECARD) { |
| 2143 | j->pslic.bits.powerdown = 0; |
| 2144 | j->psccr.bits.dev = 3; |
| 2145 | j->psccr.bits.rw = 0; |
| 2146 | outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00); |
| 2147 | ixj_PCcontrol_wait(j); |
| 2148 | } |
| 2149 | |
| 2150 | j->flags.cidplay = 0; |
| 2151 | j->flags.cidcw_ack = 0; |
| 2152 | |
| 2153 | if (ixjdebug & 0x0002) |
| 2154 | printk(KERN_INFO "Opening board %d\n", p->board); |
| 2155 | |
| 2156 | j->framesread = j->frameswritten = 0; |
| 2157 | return 0; |
| 2158 | } |
| 2159 | |
| 2160 | static int ixj_release(struct inode *inode, struct file *file_p) |
| 2161 | { |
| 2162 | IXJ_TONE ti; |
| 2163 | int cnt; |
| 2164 | IXJ *j = file_p->private_data; |
| 2165 | int board = j->p.board; |
| 2166 | |
| 2167 | /* |
| 2168 | * Set up locks to ensure that only one process is talking to the DSP at a time. |
| 2169 | * This is necessary to keep the DSP from locking up. |
| 2170 | */ |
| 2171 | while(test_and_set_bit(board, (void *)&j->busyflags) != 0) { |
| 2172 | set_current_state(TASK_INTERRUPTIBLE); |
| 2173 | schedule_timeout(1); |
| 2174 | } |
| 2175 | if (ixjdebug & 0x0002) |
| 2176 | printk(KERN_INFO "Closing board %d\n", NUM(inode)); |
| 2177 | |
| 2178 | if (j->cardtype == QTI_PHONECARD) |
| 2179 | ixj_set_port(j, PORT_SPEAKER); |
| 2180 | else |
| 2181 | ixj_set_port(j, PORT_POTS); |
| 2182 | |
| 2183 | aec_stop(j); |
| 2184 | ixj_play_stop(j); |
| 2185 | ixj_record_stop(j); |
| 2186 | set_play_volume(j, 0x100); |
| 2187 | set_rec_volume(j, 0x100); |
| 2188 | ixj_ring_off(j); |
| 2189 | |
| 2190 | /* Restore the tone table to default settings. */ |
| 2191 | ti.tone_index = 10; |
| 2192 | ti.gain0 = 1; |
| 2193 | ti.freq0 = hz941; |
| 2194 | ti.gain1 = 0; |
| 2195 | ti.freq1 = hz1209; |
| 2196 | ixj_init_tone(j, &ti); |
| 2197 | ti.tone_index = 11; |
| 2198 | ti.gain0 = 1; |
| 2199 | ti.freq0 = hz941; |
| 2200 | ti.gain1 = 0; |
| 2201 | ti.freq1 = hz1336; |
| 2202 | ixj_init_tone(j, &ti); |
| 2203 | ti.tone_index = 12; |
| 2204 | ti.gain0 = 1; |
| 2205 | ti.freq0 = hz941; |
| 2206 | ti.gain1 = 0; |
| 2207 | ti.freq1 = hz1477; |
| 2208 | ixj_init_tone(j, &ti); |
| 2209 | ti.tone_index = 13; |
| 2210 | ti.gain0 = 1; |
| 2211 | ti.freq0 = hz800; |
| 2212 | ti.gain1 = 0; |
| 2213 | ti.freq1 = 0; |
| 2214 | ixj_init_tone(j, &ti); |
| 2215 | ti.tone_index = 14; |
| 2216 | ti.gain0 = 1; |
| 2217 | ti.freq0 = hz1000; |
| 2218 | ti.gain1 = 0; |
| 2219 | ti.freq1 = 0; |
| 2220 | ixj_init_tone(j, &ti); |
| 2221 | ti.tone_index = 15; |
| 2222 | ti.gain0 = 1; |
| 2223 | ti.freq0 = hz1250; |
| 2224 | ti.gain1 = 0; |
| 2225 | ti.freq1 = 0; |
| 2226 | ixj_init_tone(j, &ti); |
| 2227 | ti.tone_index = 16; |
| 2228 | ti.gain0 = 1; |
| 2229 | ti.freq0 = hz950; |
| 2230 | ti.gain1 = 0; |
| 2231 | ti.freq1 = 0; |
| 2232 | ixj_init_tone(j, &ti); |
| 2233 | ti.tone_index = 17; |
| 2234 | ti.gain0 = 1; |
| 2235 | ti.freq0 = hz1100; |
| 2236 | ti.gain1 = 0; |
| 2237 | ti.freq1 = 0; |
| 2238 | ixj_init_tone(j, &ti); |
| 2239 | ti.tone_index = 18; |
| 2240 | ti.gain0 = 1; |
| 2241 | ti.freq0 = hz1400; |
| 2242 | ti.gain1 = 0; |
| 2243 | ti.freq1 = 0; |
| 2244 | ixj_init_tone(j, &ti); |
| 2245 | ti.tone_index = 19; |
| 2246 | ti.gain0 = 1; |
| 2247 | ti.freq0 = hz1500; |
| 2248 | ti.gain1 = 0; |
| 2249 | ti.freq1 = 0; |
| 2250 | ixj_init_tone(j, &ti); |
| 2251 | ti.tone_index = 20; |
| 2252 | ti.gain0 = 1; |
| 2253 | ti.freq0 = hz1600; |
| 2254 | ti.gain1 = 0; |
| 2255 | ti.freq1 = 0; |
| 2256 | ixj_init_tone(j, &ti); |
| 2257 | ti.tone_index = 21; |
| 2258 | ti.gain0 = 1; |
| 2259 | ti.freq0 = hz1800; |
| 2260 | ti.gain1 = 0; |
| 2261 | ti.freq1 = 0; |
| 2262 | ixj_init_tone(j, &ti); |
| 2263 | ti.tone_index = 22; |
| 2264 | ti.gain0 = 1; |
| 2265 | ti.freq0 = hz2100; |
| 2266 | ti.gain1 = 0; |
| 2267 | ti.freq1 = 0; |
| 2268 | ixj_init_tone(j, &ti); |
| 2269 | ti.tone_index = 23; |
| 2270 | ti.gain0 = 1; |
| 2271 | ti.freq0 = hz1300; |
| 2272 | ti.gain1 = 0; |
| 2273 | ti.freq1 = 0; |
| 2274 | ixj_init_tone(j, &ti); |
| 2275 | ti.tone_index = 24; |
| 2276 | ti.gain0 = 1; |
| 2277 | ti.freq0 = hz2450; |
| 2278 | ti.gain1 = 0; |
| 2279 | ti.freq1 = 0; |
| 2280 | ixj_init_tone(j, &ti); |
| 2281 | ti.tone_index = 25; |
| 2282 | ti.gain0 = 1; |
| 2283 | ti.freq0 = hz350; |
| 2284 | ti.gain1 = 0; |
| 2285 | ti.freq1 = hz440; |
| 2286 | ixj_init_tone(j, &ti); |
| 2287 | ti.tone_index = 26; |
| 2288 | ti.gain0 = 1; |
| 2289 | ti.freq0 = hz440; |
| 2290 | ti.gain1 = 0; |
| 2291 | ti.freq1 = hz480; |
| 2292 | ixj_init_tone(j, &ti); |
| 2293 | ti.tone_index = 27; |
| 2294 | ti.gain0 = 1; |
| 2295 | ti.freq0 = hz480; |
| 2296 | ti.gain1 = 0; |
| 2297 | ti.freq1 = hz620; |
| 2298 | ixj_init_tone(j, &ti); |
| 2299 | |
| 2300 | set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */ |
| 2301 | |
| 2302 | set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */ |
| 2303 | |
| 2304 | j->ex.bits.dtmf_ready = 0; |
| 2305 | j->dtmf_state = 0; |
| 2306 | j->dtmf_wp = j->dtmf_rp = 0; |
| 2307 | j->rec_mode = j->play_mode = -1; |
| 2308 | j->flags.ringing = 0; |
| 2309 | j->maxrings = MAXRINGS; |
| 2310 | j->ring_cadence = USA_RING_CADENCE; |
| 2311 | if(j->cadence_f[5].enable) { |
| 2312 | j->cadence_f[5].enable = j->cadence_f[5].en_filter = j->cadence_f[5].state = 0; |
| 2313 | } |
| 2314 | j->drybuffer = 0; |
| 2315 | j->winktime = 320; |
| 2316 | j->flags.dtmf_oob = 0; |
| 2317 | for (cnt = 0; cnt < 4; cnt++) |
| 2318 | j->cadence_f[cnt].enable = 0; |
| 2319 | |
| 2320 | idle(j); |
| 2321 | |
| 2322 | if(j->cardtype == QTI_PHONECARD) { |
| 2323 | SLIC_SetState(PLD_SLIC_STATE_OC, j); |
| 2324 | } |
| 2325 | |
| 2326 | if (file_p->f_mode & FMODE_READ) |
| 2327 | j->readers--; |
| 2328 | if (file_p->f_mode & FMODE_WRITE) |
| 2329 | j->writers--; |
| 2330 | |
| 2331 | if (j->read_buffer && !j->readers) { |
| 2332 | kfree(j->read_buffer); |
| 2333 | j->read_buffer = NULL; |
| 2334 | j->read_buffer_size = 0; |
| 2335 | } |
| 2336 | if (j->write_buffer && !j->writers) { |
| 2337 | kfree(j->write_buffer); |
| 2338 | j->write_buffer = NULL; |
| 2339 | j->write_buffer_size = 0; |
| 2340 | } |
| 2341 | j->rec_codec = j->play_codec = 0; |
| 2342 | j->rec_frame_size = j->play_frame_size = 0; |
| 2343 | j->flags.cidsent = j->flags.cidring = 0; |
| 2344 | ixj_fasync(-1, file_p, 0); /* remove from list of async notification */ |
| 2345 | |
| 2346 | if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) { |
| 2347 | ixj_set_port(j, PORT_PSTN); |
| 2348 | daa_set_mode(j, SOP_PU_SLEEP); |
| 2349 | ixj_set_pots(j, 1); |
| 2350 | } |
| 2351 | ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */ |
| 2352 | |
| 2353 | /* Set up the default signals for events */ |
| 2354 | for (cnt = 0; cnt < 35; cnt++) |
| 2355 | j->ixj_signals[cnt] = SIGIO; |
| 2356 | |
| 2357 | /* Set the excetion signal enable flags */ |
| 2358 | j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring = |
| 2359 | 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 = |
| 2360 | 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; |
| 2361 | |
| 2362 | file_p->private_data = NULL; |
| 2363 | clear_bit(board, &j->busyflags); |
| 2364 | return 0; |
| 2365 | } |
| 2366 | |
| 2367 | static int read_filters(IXJ *j) |
| 2368 | { |
| 2369 | unsigned short fc, cnt, trg; |
| 2370 | int var; |
| 2371 | |
| 2372 | trg = 0; |
| 2373 | if (ixj_WriteDSPCommand(0x5144, j)) { |
| 2374 | if(ixjdebug & 0x0001) { |
| 2375 | printk(KERN_INFO "Read Frame Counter failed!\n"); |
| 2376 | } |
| 2377 | return -1; |
| 2378 | } |
| 2379 | fc = j->ssr.high << 8 | j->ssr.low; |
| 2380 | if (fc == j->frame_count) |
| 2381 | return 1; |
| 2382 | |
| 2383 | j->frame_count = fc; |
| 2384 | |
| 2385 | if (j->dtmf_proc) |
| 2386 | return 1; |
| 2387 | |
| 2388 | var = 10; |
| 2389 | |
| 2390 | for (cnt = 0; cnt < 4; cnt++) { |
| 2391 | if (ixj_WriteDSPCommand(0x5154 + cnt, j)) { |
| 2392 | if(ixjdebug & 0x0001) { |
| 2393 | printk(KERN_INFO "Select Filter %d failed!\n", cnt); |
| 2394 | } |
| 2395 | return -1; |
| 2396 | } |
| 2397 | if (ixj_WriteDSPCommand(0x515C, j)) { |
| 2398 | if(ixjdebug & 0x0001) { |
| 2399 | printk(KERN_INFO "Read Filter History %d failed!\n", cnt); |
| 2400 | } |
| 2401 | return -1; |
| 2402 | } |
| 2403 | j->filter_hist[cnt] = j->ssr.high << 8 | j->ssr.low; |
| 2404 | |
| 2405 | if (j->cadence_f[cnt].enable) { |
| 2406 | if (j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) { |
| 2407 | if (j->cadence_f[cnt].state == 0) { |
| 2408 | j->cadence_f[cnt].state = 1; |
| 2409 | j->cadence_f[cnt].on1min = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 - var)) / 10000)); |
| 2410 | j->cadence_f[cnt].on1dot = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100)) / 10000)); |
| 2411 | j->cadence_f[cnt].on1max = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 + var)) / 10000)); |
| 2412 | } else if (j->cadence_f[cnt].state == 2 && |
| 2413 | (time_after(jiffies, j->cadence_f[cnt].off1min) && |
| 2414 | time_before(jiffies, j->cadence_f[cnt].off1max))) { |
| 2415 | if (j->cadence_f[cnt].on2) { |
| 2416 | j->cadence_f[cnt].state = 3; |
| 2417 | j->cadence_f[cnt].on2min = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 - var)) / 10000)); |
| 2418 | j->cadence_f[cnt].on2dot = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100)) / 10000)); |
| 2419 | j->cadence_f[cnt].on2max = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 + var)) / 10000)); |
| 2420 | } else { |
| 2421 | j->cadence_f[cnt].state = 7; |
| 2422 | } |
| 2423 | } else if (j->cadence_f[cnt].state == 4 && |
| 2424 | (time_after(jiffies, j->cadence_f[cnt].off2min) && |
| 2425 | time_before(jiffies, j->cadence_f[cnt].off2max))) { |
| 2426 | if (j->cadence_f[cnt].on3) { |
| 2427 | j->cadence_f[cnt].state = 5; |
| 2428 | j->cadence_f[cnt].on3min = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 - var)) / 10000)); |
| 2429 | j->cadence_f[cnt].on3dot = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100)) / 10000)); |
| 2430 | j->cadence_f[cnt].on3max = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 + var)) / 10000)); |
| 2431 | } else { |
| 2432 | j->cadence_f[cnt].state = 7; |
| 2433 | } |
| 2434 | } else { |
| 2435 | j->cadence_f[cnt].state = 0; |
| 2436 | } |
| 2437 | } else if (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)) { |
| 2438 | if (j->cadence_f[cnt].state == 1) { |
| 2439 | if(!j->cadence_f[cnt].on1) { |
| 2440 | j->cadence_f[cnt].state = 7; |
| 2441 | } else if((time_after(jiffies, j->cadence_f[cnt].on1min) && |
| 2442 | time_before(jiffies, j->cadence_f[cnt].on1max))) { |
| 2443 | if(j->cadence_f[cnt].off1) { |
| 2444 | j->cadence_f[cnt].state = 2; |
| 2445 | j->cadence_f[cnt].off1min = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 - var)) / 10000)); |
| 2446 | j->cadence_f[cnt].off1dot = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100)) / 10000)); |
| 2447 | j->cadence_f[cnt].off1max = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 + var)) / 10000)); |
| 2448 | } else { |
| 2449 | j->cadence_f[cnt].state = 7; |
| 2450 | } |
| 2451 | } else { |
| 2452 | j->cadence_f[cnt].state = 0; |
| 2453 | } |
| 2454 | } else if (j->cadence_f[cnt].state == 3) { |
| 2455 | if((time_after(jiffies, j->cadence_f[cnt].on2min) && |
| 2456 | time_before(jiffies, j->cadence_f[cnt].on2max))) { |
| 2457 | if(j->cadence_f[cnt].off2) { |
| 2458 | j->cadence_f[cnt].state = 4; |
| 2459 | j->cadence_f[cnt].off2min = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 - var)) / 10000)); |
| 2460 | j->cadence_f[cnt].off2dot = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100)) / 10000)); |
| 2461 | j->cadence_f[cnt].off2max = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 + var)) / 10000)); |
| 2462 | } else { |
| 2463 | j->cadence_f[cnt].state = 7; |
| 2464 | } |
| 2465 | } else { |
| 2466 | j->cadence_f[cnt].state = 0; |
| 2467 | } |
| 2468 | } else if (j->cadence_f[cnt].state == 5) { |
| 2469 | if ((time_after(jiffies, j->cadence_f[cnt].on3min) && |
| 2470 | time_before(jiffies, j->cadence_f[cnt].on3max))) { |
| 2471 | if(j->cadence_f[cnt].off3) { |
| 2472 | j->cadence_f[cnt].state = 6; |
| 2473 | j->cadence_f[cnt].off3min = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 - var)) / 10000)); |
| 2474 | j->cadence_f[cnt].off3dot = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100)) / 10000)); |
| 2475 | j->cadence_f[cnt].off3max = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 + var)) / 10000)); |
| 2476 | } else { |
| 2477 | j->cadence_f[cnt].state = 7; |
| 2478 | } |
| 2479 | } else { |
| 2480 | j->cadence_f[cnt].state = 0; |
| 2481 | } |
| 2482 | } else { |
| 2483 | j->cadence_f[cnt].state = 0; |
| 2484 | } |
| 2485 | } else { |
| 2486 | switch(j->cadence_f[cnt].state) { |
| 2487 | case 1: |
| 2488 | if(time_after(jiffies, j->cadence_f[cnt].on1dot) && |
| 2489 | !j->cadence_f[cnt].off1 && |
| 2490 | !j->cadence_f[cnt].on2 && !j->cadence_f[cnt].off2 && |
| 2491 | !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) { |
| 2492 | j->cadence_f[cnt].state = 7; |
| 2493 | } |
| 2494 | break; |
| 2495 | case 3: |
| 2496 | if(time_after(jiffies, j->cadence_f[cnt].on2dot) && |
| 2497 | !j->cadence_f[cnt].off2 && |
| 2498 | !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) { |
| 2499 | j->cadence_f[cnt].state = 7; |
| 2500 | } |
| 2501 | break; |
| 2502 | case 5: |
| 2503 | if(time_after(jiffies, j->cadence_f[cnt].on3dot) && |
| 2504 | !j->cadence_f[cnt].off3) { |
| 2505 | j->cadence_f[cnt].state = 7; |
| 2506 | } |
| 2507 | break; |
| 2508 | } |
| 2509 | } |
| 2510 | |
| 2511 | if (ixjdebug & 0x0040) { |
| 2512 | printk(KERN_INFO "IXJ Tone Cadence state = %d /dev/phone%d at %ld\n", j->cadence_f[cnt].state, j->board, jiffies); |
| 2513 | switch(j->cadence_f[cnt].state) { |
| 2514 | case 0: |
| 2515 | printk(KERN_INFO "IXJ /dev/phone%d No Tone detected\n", j->board); |
| 2516 | break; |
| 2517 | case 1: |
| 2518 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %u %ld - %ld - %ld\n", j->board, |
| 2519 | j->cadence_f[cnt].on1, j->cadence_f[cnt].on1min, j->cadence_f[cnt].on1dot, j->cadence_f[cnt].on1max); |
| 2520 | break; |
| 2521 | case 2: |
| 2522 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off1min, |
| 2523 | j->cadence_f[cnt].off1max); |
| 2524 | break; |
| 2525 | case 3: |
| 2526 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on2min, |
| 2527 | j->cadence_f[cnt].on2max); |
| 2528 | break; |
| 2529 | case 4: |
| 2530 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off2min, |
| 2531 | j->cadence_f[cnt].off2max); |
| 2532 | break; |
| 2533 | case 5: |
| 2534 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on3min, |
| 2535 | j->cadence_f[cnt].on3max); |
| 2536 | break; |
| 2537 | case 6: |
| 2538 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off3min, |
| 2539 | j->cadence_f[cnt].off3max); |
| 2540 | break; |
| 2541 | } |
| 2542 | } |
| 2543 | } |
| 2544 | if (j->cadence_f[cnt].state == 7) { |
| 2545 | j->cadence_f[cnt].state = 0; |
| 2546 | if (j->cadence_f[cnt].enable == 1) |
| 2547 | j->cadence_f[cnt].enable = 0; |
| 2548 | switch (cnt) { |
| 2549 | case 0: |
| 2550 | if(ixjdebug & 0x0020) { |
| 2551 | printk(KERN_INFO "Filter Cadence 0 triggered %ld\n", jiffies); |
| 2552 | } |
| 2553 | j->ex.bits.fc0 = 1; |
| 2554 | ixj_kill_fasync(j, SIG_FC0, POLL_IN); |
| 2555 | break; |
| 2556 | case 1: |
| 2557 | if(ixjdebug & 0x0020) { |
| 2558 | printk(KERN_INFO "Filter Cadence 1 triggered %ld\n", jiffies); |
| 2559 | } |
| 2560 | j->ex.bits.fc1 = 1; |
| 2561 | ixj_kill_fasync(j, SIG_FC1, POLL_IN); |
| 2562 | break; |
| 2563 | case 2: |
| 2564 | if(ixjdebug & 0x0020) { |
| 2565 | printk(KERN_INFO "Filter Cadence 2 triggered %ld\n", jiffies); |
| 2566 | } |
| 2567 | j->ex.bits.fc2 = 1; |
| 2568 | ixj_kill_fasync(j, SIG_FC2, POLL_IN); |
| 2569 | break; |
| 2570 | case 3: |
| 2571 | if(ixjdebug & 0x0020) { |
| 2572 | printk(KERN_INFO "Filter Cadence 3 triggered %ld\n", jiffies); |
| 2573 | } |
| 2574 | j->ex.bits.fc3 = 1; |
| 2575 | ixj_kill_fasync(j, SIG_FC3, POLL_IN); |
| 2576 | break; |
| 2577 | } |
| 2578 | } |
| 2579 | if (j->filter_en[cnt] && ((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) || |
| 2580 | (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)))) { |
| 2581 | if((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12))) { |
| 2582 | trg = 1; |
| 2583 | } else if((j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3))) { |
| 2584 | trg = 0; |
| 2585 | } |
| 2586 | switch (cnt) { |
| 2587 | case 0: |
| 2588 | if(ixjdebug & 0x0020) { |
| 2589 | printk(KERN_INFO "Filter 0 triggered %d at %ld\n", trg, jiffies); |
| 2590 | } |
| 2591 | j->ex.bits.f0 = 1; |
| 2592 | ixj_kill_fasync(j, SIG_F0, POLL_IN); |
| 2593 | break; |
| 2594 | case 1: |
| 2595 | if(ixjdebug & 0x0020) { |
| 2596 | printk(KERN_INFO "Filter 1 triggered %d at %ld\n", trg, jiffies); |
| 2597 | } |
| 2598 | j->ex.bits.f1 = 1; |
| 2599 | ixj_kill_fasync(j, SIG_F1, POLL_IN); |
| 2600 | break; |
| 2601 | case 2: |
| 2602 | if(ixjdebug & 0x0020) { |
| 2603 | printk(KERN_INFO "Filter 2 triggered %d at %ld\n", trg, jiffies); |
| 2604 | } |
| 2605 | j->ex.bits.f2 = 1; |
| 2606 | ixj_kill_fasync(j, SIG_F2, POLL_IN); |
| 2607 | break; |
| 2608 | case 3: |
| 2609 | if(ixjdebug & 0x0020) { |
| 2610 | printk(KERN_INFO "Filter 3 triggered %d at %ld\n", trg, jiffies); |
| 2611 | } |
| 2612 | j->ex.bits.f3 = 1; |
| 2613 | ixj_kill_fasync(j, SIG_F3, POLL_IN); |
| 2614 | break; |
| 2615 | } |
| 2616 | } |
| 2617 | } |
| 2618 | return 0; |
| 2619 | } |
| 2620 | |
| 2621 | static int LineMonitor(IXJ *j) |
| 2622 | { |
| 2623 | if (j->dtmf_proc) { |
| 2624 | return -1; |
| 2625 | } |
| 2626 | j->dtmf_proc = 1; |
| 2627 | |
| 2628 | if (ixj_WriteDSPCommand(0x7000, j)) /* Line Monitor */ |
| 2629 | return -1; |
| 2630 | |
| 2631 | j->dtmf.bytes.high = j->ssr.high; |
| 2632 | j->dtmf.bytes.low = j->ssr.low; |
| 2633 | if (!j->dtmf_state && j->dtmf.bits.dtmf_valid) { |
| 2634 | j->dtmf_state = 1; |
| 2635 | j->dtmf_current = j->dtmf.bits.digit; |
| 2636 | } |
| 2637 | if (j->dtmf_state && !j->dtmf.bits.dtmf_valid) /* && j->dtmf_wp != j->dtmf_rp) */ |
| 2638 | { |
| 2639 | if(!j->cidcw_wait) { |
| 2640 | j->dtmfbuffer[j->dtmf_wp] = j->dtmf_current; |
| 2641 | j->dtmf_wp++; |
| 2642 | if (j->dtmf_wp == 79) |
| 2643 | j->dtmf_wp = 0; |
| 2644 | j->ex.bits.dtmf_ready = 1; |
| 2645 | if(j->ex_sig.bits.dtmf_ready) { |
| 2646 | ixj_kill_fasync(j, SIG_DTMF_READY, POLL_IN); |
| 2647 | } |
| 2648 | } |
| 2649 | else if(j->dtmf_current == 0x00 || j->dtmf_current == 0x0D) { |
| 2650 | if(ixjdebug & 0x0020) { |
| 2651 | printk("IXJ phone%d saw CIDCW Ack DTMF %d from display at %ld\n", j->board, j->dtmf_current, jiffies); |
| 2652 | } |
| 2653 | j->flags.cidcw_ack = 1; |
| 2654 | } |
| 2655 | j->dtmf_state = 0; |
| 2656 | } |
| 2657 | j->dtmf_proc = 0; |
| 2658 | |
| 2659 | return 0; |
| 2660 | } |
| 2661 | |
| 2662 | /************************************************************************ |
| 2663 | * |
| 2664 | * Functions to allow alaw <-> ulaw conversions. |
| 2665 | * |
| 2666 | ************************************************************************/ |
| 2667 | |
| 2668 | static void ulaw2alaw(unsigned char *buff, unsigned long len) |
| 2669 | { |
| 2670 | static unsigned char table_ulaw2alaw[] = |
| 2671 | { |
| 2672 | 0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D, |
| 2673 | 0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25, |
| 2674 | 0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D, |
| 2675 | 0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35, |
| 2676 | 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02, |
| 2677 | 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A, |
| 2678 | 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12, |
| 2679 | 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B, |
| 2680 | 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63, |
| 2681 | 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79, |
| 2682 | 0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71, |
| 2683 | 0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D, |
| 2684 | 0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45, |
| 2685 | 0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D, |
| 2686 | 0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51, |
| 2687 | 0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5, |
| 2688 | 0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD, |
| 2689 | 0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5, |
| 2690 | 0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD, |
| 2691 | 0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5, |
| 2692 | 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82, |
| 2693 | 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A, |
| 2694 | 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92, |
| 2695 | 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB, |
| 2696 | 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3, |
| 2697 | 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9, |
| 2698 | 0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1, |
| 2699 | 0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD, |
| 2700 | 0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5, |
| 2701 | 0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD, |
| 2702 | 0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1, |
| 2703 | 0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5 |
| 2704 | }; |
| 2705 | |
| 2706 | while (len--) |
| 2707 | { |
| 2708 | *buff = table_ulaw2alaw[*(unsigned char *)buff]; |
| 2709 | buff++; |
| 2710 | } |
| 2711 | } |
| 2712 | |
| 2713 | static void alaw2ulaw(unsigned char *buff, unsigned long len) |
| 2714 | { |
| 2715 | static unsigned char table_alaw2ulaw[] = |
| 2716 | { |
| 2717 | 0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C, |
| 2718 | 0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24, |
| 2719 | 0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C, |
| 2720 | 0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34, |
| 2721 | 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, |
| 2722 | 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, |
| 2723 | 0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, |
| 2724 | 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, |
| 2725 | 0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, |
| 2726 | 0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E, |
| 2727 | 0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A, |
| 2728 | 0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, |
| 2729 | 0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B, |
| 2730 | 0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43, |
| 2731 | 0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59, |
| 2732 | 0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51, |
| 2733 | 0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC, |
| 2734 | 0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4, |
| 2735 | 0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC, |
| 2736 | 0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4, |
| 2737 | 0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, |
| 2738 | 0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, |
| 2739 | 0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, |
| 2740 | 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, |
| 2741 | 0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, |
| 2742 | 0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE, |
| 2743 | 0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA, |
| 2744 | 0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, |
| 2745 | 0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB, |
| 2746 | 0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3, |
| 2747 | 0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9, |
| 2748 | 0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1 |
| 2749 | }; |
| 2750 | |
| 2751 | while (len--) |
| 2752 | { |
| 2753 | *buff = table_alaw2ulaw[*(unsigned char *)buff]; |
| 2754 | buff++; |
| 2755 | } |
| 2756 | } |
| 2757 | |
| 2758 | static ssize_t ixj_read(struct file * file_p, char __user *buf, size_t length, loff_t * ppos) |
| 2759 | { |
| 2760 | unsigned long i = *ppos; |
| 2761 | IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode)); |
| 2762 | |
| 2763 | DECLARE_WAITQUEUE(wait, current); |
| 2764 | |
| 2765 | if (j->flags.inread) |
| 2766 | return -EALREADY; |
| 2767 | |
| 2768 | j->flags.inread = 1; |
| 2769 | |
| 2770 | add_wait_queue(&j->read_q, &wait); |
| 2771 | set_current_state(TASK_INTERRUPTIBLE); |
| 2772 | mb(); |
| 2773 | |
| 2774 | while (!j->read_buffer_ready || (j->dtmf_state && j->flags.dtmf_oob)) { |
| 2775 | ++j->read_wait; |
| 2776 | if (file_p->f_flags & O_NONBLOCK) { |
| 2777 | set_current_state(TASK_RUNNING); |
| 2778 | remove_wait_queue(&j->read_q, &wait); |
| 2779 | j->flags.inread = 0; |
| 2780 | return -EAGAIN; |
| 2781 | } |
| 2782 | if (!ixj_hookstate(j)) { |
| 2783 | set_current_state(TASK_RUNNING); |
| 2784 | remove_wait_queue(&j->read_q, &wait); |
| 2785 | j->flags.inread = 0; |
| 2786 | return 0; |
| 2787 | } |
| 2788 | interruptible_sleep_on(&j->read_q); |
| 2789 | if (signal_pending(current)) { |
| 2790 | set_current_state(TASK_RUNNING); |
| 2791 | remove_wait_queue(&j->read_q, &wait); |
| 2792 | j->flags.inread = 0; |
| 2793 | return -EINTR; |
| 2794 | } |
| 2795 | } |
| 2796 | |
| 2797 | remove_wait_queue(&j->read_q, &wait); |
| 2798 | set_current_state(TASK_RUNNING); |
| 2799 | /* Don't ever copy more than the user asks */ |
| 2800 | if(j->rec_codec == ALAW) |
| 2801 | ulaw2alaw(j->read_buffer, min(length, j->read_buffer_size)); |
| 2802 | i = copy_to_user(buf, j->read_buffer, min(length, j->read_buffer_size)); |
| 2803 | j->read_buffer_ready = 0; |
| 2804 | if (i) { |
| 2805 | j->flags.inread = 0; |
| 2806 | return -EFAULT; |
| 2807 | } else { |
| 2808 | j->flags.inread = 0; |
| 2809 | return min(length, j->read_buffer_size); |
| 2810 | } |
| 2811 | } |
| 2812 | |
| 2813 | static ssize_t ixj_enhanced_read(struct file * file_p, char __user *buf, size_t length, |
| 2814 | loff_t * ppos) |
| 2815 | { |
| 2816 | int pre_retval; |
| 2817 | ssize_t read_retval = 0; |
| 2818 | IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode)); |
| 2819 | |
| 2820 | pre_retval = ixj_PreRead(j, 0L); |
| 2821 | switch (pre_retval) { |
| 2822 | case NORMAL: |
| 2823 | read_retval = ixj_read(file_p, buf, length, ppos); |
| 2824 | ixj_PostRead(j, 0L); |
| 2825 | break; |
| 2826 | case NOPOST: |
| 2827 | read_retval = ixj_read(file_p, buf, length, ppos); |
| 2828 | break; |
| 2829 | case POSTONLY: |
| 2830 | ixj_PostRead(j, 0L); |
| 2831 | break; |
| 2832 | default: |
| 2833 | read_retval = pre_retval; |
| 2834 | } |
| 2835 | return read_retval; |
| 2836 | } |
| 2837 | |
| 2838 | static ssize_t ixj_write(struct file *file_p, const char __user *buf, size_t count, loff_t * ppos) |
| 2839 | { |
| 2840 | unsigned long i = *ppos; |
| 2841 | IXJ *j = file_p->private_data; |
| 2842 | |
| 2843 | DECLARE_WAITQUEUE(wait, current); |
| 2844 | |
| 2845 | if (j->flags.inwrite) |
| 2846 | return -EALREADY; |
| 2847 | |
| 2848 | j->flags.inwrite = 1; |
| 2849 | |
| 2850 | add_wait_queue(&j->write_q, &wait); |
| 2851 | set_current_state(TASK_INTERRUPTIBLE); |
| 2852 | mb(); |
| 2853 | |
| 2854 | |
| 2855 | while (!j->write_buffers_empty) { |
| 2856 | ++j->write_wait; |
| 2857 | if (file_p->f_flags & O_NONBLOCK) { |
| 2858 | set_current_state(TASK_RUNNING); |
| 2859 | remove_wait_queue(&j->write_q, &wait); |
| 2860 | j->flags.inwrite = 0; |
| 2861 | return -EAGAIN; |
| 2862 | } |
| 2863 | if (!ixj_hookstate(j)) { |
| 2864 | set_current_state(TASK_RUNNING); |
| 2865 | remove_wait_queue(&j->write_q, &wait); |
| 2866 | j->flags.inwrite = 0; |
| 2867 | return 0; |
| 2868 | } |
| 2869 | interruptible_sleep_on(&j->write_q); |
| 2870 | if (signal_pending(current)) { |
| 2871 | set_current_state(TASK_RUNNING); |
| 2872 | remove_wait_queue(&j->write_q, &wait); |
| 2873 | j->flags.inwrite = 0; |
| 2874 | return -EINTR; |
| 2875 | } |
| 2876 | } |
| 2877 | set_current_state(TASK_RUNNING); |
| 2878 | remove_wait_queue(&j->write_q, &wait); |
| 2879 | if (j->write_buffer_wp + count >= j->write_buffer_end) |
| 2880 | j->write_buffer_wp = j->write_buffer; |
| 2881 | i = copy_from_user(j->write_buffer_wp, buf, min(count, j->write_buffer_size)); |
| 2882 | if (i) { |
| 2883 | j->flags.inwrite = 0; |
| 2884 | return -EFAULT; |
| 2885 | } |
| 2886 | if(j->play_codec == ALAW) |
| 2887 | alaw2ulaw(j->write_buffer_wp, min(count, j->write_buffer_size)); |
| 2888 | j->flags.inwrite = 0; |
| 2889 | return min(count, j->write_buffer_size); |
| 2890 | } |
| 2891 | |
| 2892 | static ssize_t ixj_enhanced_write(struct file * file_p, const char __user *buf, size_t count, loff_t * ppos) |
| 2893 | { |
| 2894 | int pre_retval; |
| 2895 | ssize_t write_retval = 0; |
| 2896 | |
| 2897 | IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode)); |
| 2898 | |
| 2899 | pre_retval = ixj_PreWrite(j, 0L); |
| 2900 | switch (pre_retval) { |
| 2901 | case NORMAL: |
| 2902 | write_retval = ixj_write(file_p, buf, count, ppos); |
| 2903 | if (write_retval > 0) { |
| 2904 | ixj_PostWrite(j, 0L); |
| 2905 | j->write_buffer_wp += write_retval; |
| 2906 | j->write_buffers_empty--; |
| 2907 | } |
| 2908 | break; |
| 2909 | case NOPOST: |
| 2910 | write_retval = ixj_write(file_p, buf, count, ppos); |
| 2911 | if (write_retval > 0) { |
| 2912 | j->write_buffer_wp += write_retval; |
| 2913 | j->write_buffers_empty--; |
| 2914 | } |
| 2915 | break; |
| 2916 | case POSTONLY: |
| 2917 | ixj_PostWrite(j, 0L); |
| 2918 | break; |
| 2919 | default: |
| 2920 | write_retval = pre_retval; |
| 2921 | } |
| 2922 | return write_retval; |
| 2923 | } |
| 2924 | |
| 2925 | static void ixj_read_frame(IXJ *j) |
| 2926 | { |
| 2927 | int cnt, dly; |
| 2928 | |
| 2929 | if (j->read_buffer) { |
| 2930 | for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) { |
| 2931 | if (!(cnt % 16) && !IsRxReady(j)) { |
| 2932 | dly = 0; |
| 2933 | while (!IsRxReady(j)) { |
| 2934 | if (dly++ > 5) { |
| 2935 | dly = 0; |
| 2936 | break; |
| 2937 | } |
| 2938 | udelay(10); |
| 2939 | } |
| 2940 | } |
| 2941 | /* Throw away word 0 of the 8021 compressed format to get standard G.729. */ |
| 2942 | if (j->rec_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) { |
| 2943 | inb_p(j->DSPbase + 0x0E); |
| 2944 | inb_p(j->DSPbase + 0x0F); |
| 2945 | } |
| 2946 | *(j->read_buffer + cnt) = inb_p(j->DSPbase + 0x0E); |
| 2947 | *(j->read_buffer + cnt + 1) = inb_p(j->DSPbase + 0x0F); |
| 2948 | } |
| 2949 | ++j->framesread; |
| 2950 | if (j->intercom != -1) { |
| 2951 | if (IsTxReady(get_ixj(j->intercom))) { |
| 2952 | for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) { |
| 2953 | if (!(cnt % 16) && !IsTxReady(j)) { |
| 2954 | dly = 0; |
| 2955 | while (!IsTxReady(j)) { |
| 2956 | if (dly++ > 5) { |
| 2957 | dly = 0; |
| 2958 | break; |
| 2959 | } |
| 2960 | udelay(10); |
| 2961 | } |
| 2962 | } |
| 2963 | outb_p(*(j->read_buffer + cnt), get_ixj(j->intercom)->DSPbase + 0x0C); |
| 2964 | outb_p(*(j->read_buffer + cnt + 1), get_ixj(j->intercom)->DSPbase + 0x0D); |
| 2965 | } |
| 2966 | get_ixj(j->intercom)->frameswritten++; |
| 2967 | } |
| 2968 | } else { |
| 2969 | j->read_buffer_ready = 1; |
| 2970 | wake_up_interruptible(&j->read_q); /* Wake any blocked readers */ |
| 2971 | |
| 2972 | wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */ |
| 2973 | |
| 2974 | if(j->ixj_signals[SIG_READ_READY]) |
| 2975 | ixj_kill_fasync(j, SIG_READ_READY, POLL_OUT); |
| 2976 | } |
| 2977 | } |
| 2978 | } |
| 2979 | |
| 2980 | static short fsk[][6][20] = |
| 2981 | { |
| 2982 | { |
| 2983 | { |
| 2984 | 0, 17846, 29934, 32364, 24351, 8481, -10126, -25465, -32587, -29196, |
| 2985 | -16384, 1715, 19260, 30591, 32051, 23170, 6813, -11743, -26509, -32722 |
| 2986 | }, |
| 2987 | { |
| 2988 | -28377, -14876, 3425, 20621, 31163, 31650, 21925, 5126, -13328, -27481, |
| 2989 | -32767, -27481, -13328, 5126, 21925, 31650, 31163, 20621, 3425, -14876 |
| 2990 | }, |
| 2991 | { |
| 2992 | -28377, -32722, -26509, -11743, 6813, 23170, 32051, 30591, 19260, 1715, |
| 2993 | -16384, -29196, -32587, -25465, -10126, 8481, 24351, 32364, 29934, 17846 |
| 2994 | }, |
| 2995 | { |
| 2996 | 0, -17846, -29934, -32364, -24351, -8481, 10126, 25465, 32587, 29196, |
| 2997 | 16384, -1715, -19260, -30591, -32051, -23170, -6813, 11743, 26509, 32722 |
| 2998 | }, |
| 2999 | { |
| 3000 | 28377, 14876, -3425, -20621, -31163, -31650, -21925, -5126, 13328, 27481, |
| 3001 | 32767, 27481, 13328, -5126, -21925, -31650, -31163, -20621, -3425, 14876 |
| 3002 | }, |
| 3003 | { |
| 3004 | 28377, 32722, 26509, 11743, -6813, -23170, -32051, -30591, -19260, -1715, |
| 3005 | 16384, 29196, 32587, 25465, 10126, -8481, -24351, -32364, -29934, -17846 |
| 3006 | } |
| 3007 | }, |
| 3008 | { |
| 3009 | { |
| 3010 | 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126, |
| 3011 | 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126 |
| 3012 | }, |
| 3013 | { |
| 3014 | -28377, -21925, -13328, -3425, 6813, 16384, 24351, 29934, 32587, 32051, |
| 3015 | 28377, 21925, 13328, 3425, -6813, -16384, -24351, -29934, -32587, -32051 |
| 3016 | }, |
| 3017 | { |
| 3018 | -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925, |
| 3019 | 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925 |
| 3020 | }, |
| 3021 | { |
| 3022 | 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126, |
| 3023 | 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126 |
| 3024 | }, |
| 3025 | { |
| 3026 | 28377, 21925, 13328, 3425, -6813, -16383, -24351, -29934, -32587, -32051, |
| 3027 | -28377, -21925, -13328, -3425, 6813, 16383, 24351, 29934, 32587, 32051 |
| 3028 | }, |
| 3029 | { |
| 3030 | 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925, |
| 3031 | -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925 |
| 3032 | } |
| 3033 | } |
| 3034 | }; |
| 3035 | |
| 3036 | |
| 3037 | static void ixj_write_cid_bit(IXJ *j, int bit) |
| 3038 | { |
| 3039 | while (j->fskcnt < 20) { |
| 3040 | if(j->fskdcnt < (j->fsksize - 1)) |
| 3041 | j->fskdata[j->fskdcnt++] = fsk[bit][j->fskz][j->fskcnt]; |
| 3042 | |
| 3043 | j->fskcnt += 3; |
| 3044 | } |
| 3045 | j->fskcnt %= 20; |
| 3046 | |
| 3047 | if (!bit) |
| 3048 | j->fskz++; |
| 3049 | if (j->fskz >= 6) |
| 3050 | j->fskz = 0; |
| 3051 | |
| 3052 | } |
| 3053 | |
| 3054 | static void ixj_write_cid_byte(IXJ *j, char byte) |
| 3055 | { |
| 3056 | IXJ_CBYTE cb; |
| 3057 | |
| 3058 | cb.cbyte = byte; |
| 3059 | ixj_write_cid_bit(j, 0); |
| 3060 | ixj_write_cid_bit(j, cb.cbits.b0 ? 1 : 0); |
| 3061 | ixj_write_cid_bit(j, cb.cbits.b1 ? 1 : 0); |
| 3062 | ixj_write_cid_bit(j, cb.cbits.b2 ? 1 : 0); |
| 3063 | ixj_write_cid_bit(j, cb.cbits.b3 ? 1 : 0); |
| 3064 | ixj_write_cid_bit(j, cb.cbits.b4 ? 1 : 0); |
| 3065 | ixj_write_cid_bit(j, cb.cbits.b5 ? 1 : 0); |
| 3066 | ixj_write_cid_bit(j, cb.cbits.b6 ? 1 : 0); |
| 3067 | ixj_write_cid_bit(j, cb.cbits.b7 ? 1 : 0); |
| 3068 | ixj_write_cid_bit(j, 1); |
| 3069 | } |
| 3070 | |
| 3071 | static void ixj_write_cid_seize(IXJ *j) |
| 3072 | { |
| 3073 | int cnt; |
| 3074 | |
| 3075 | for (cnt = 0; cnt < 150; cnt++) { |
| 3076 | ixj_write_cid_bit(j, 0); |
| 3077 | ixj_write_cid_bit(j, 1); |
| 3078 | } |
| 3079 | for (cnt = 0; cnt < 180; cnt++) { |
| 3080 | ixj_write_cid_bit(j, 1); |
| 3081 | } |
| 3082 | } |
| 3083 | |
| 3084 | static void ixj_write_cidcw_seize(IXJ *j) |
| 3085 | { |
| 3086 | int cnt; |
| 3087 | |
| 3088 | for (cnt = 0; cnt < 80; cnt++) { |
| 3089 | ixj_write_cid_bit(j, 1); |
| 3090 | } |
| 3091 | } |
| 3092 | |
| 3093 | static int ixj_write_cid_string(IXJ *j, char *s, int checksum) |
| 3094 | { |
| 3095 | int cnt; |
| 3096 | |
| 3097 | for (cnt = 0; cnt < strlen(s); cnt++) { |
| 3098 | ixj_write_cid_byte(j, s[cnt]); |
| 3099 | checksum = (checksum + s[cnt]); |
| 3100 | } |
| 3101 | return checksum; |
| 3102 | } |
| 3103 | |
| 3104 | static void ixj_pad_fsk(IXJ *j, int pad) |
| 3105 | { |
| 3106 | int cnt; |
| 3107 | |
| 3108 | for (cnt = 0; cnt < pad; cnt++) { |
| 3109 | if(j->fskdcnt < (j->fsksize - 1)) |
| 3110 | j->fskdata[j->fskdcnt++] = 0x0000; |
| 3111 | } |
| 3112 | for (cnt = 0; cnt < 720; cnt++) { |
| 3113 | if(j->fskdcnt < (j->fsksize - 1)) |
| 3114 | j->fskdata[j->fskdcnt++] = 0x0000; |
| 3115 | } |
| 3116 | } |
| 3117 | |
| 3118 | static void ixj_pre_cid(IXJ *j) |
| 3119 | { |
| 3120 | j->cid_play_codec = j->play_codec; |
| 3121 | j->cid_play_frame_size = j->play_frame_size; |
| 3122 | j->cid_play_volume = get_play_volume(j); |
| 3123 | j->cid_play_flag = j->flags.playing; |
| 3124 | |
| 3125 | j->cid_rec_codec = j->rec_codec; |
| 3126 | j->cid_rec_volume = get_rec_volume(j); |
| 3127 | j->cid_rec_flag = j->flags.recording; |
| 3128 | |
| 3129 | j->cid_play_aec_level = j->aec_level; |
| 3130 | |
| 3131 | switch(j->baseframe.low) { |
| 3132 | case 0xA0: |
| 3133 | j->cid_base_frame_size = 20; |
| 3134 | break; |
| 3135 | case 0x50: |
| 3136 | j->cid_base_frame_size = 10; |
| 3137 | break; |
| 3138 | case 0xF0: |
| 3139 | j->cid_base_frame_size = 30; |
| 3140 | break; |
| 3141 | } |
| 3142 | |
| 3143 | ixj_play_stop(j); |
| 3144 | ixj_cpt_stop(j); |
| 3145 | |
| 3146 | j->flags.cidplay = 1; |
| 3147 | |
| 3148 | set_base_frame(j, 30); |
| 3149 | set_play_codec(j, LINEAR16); |
| 3150 | set_play_volume(j, 0x1B); |
| 3151 | ixj_play_start(j); |
| 3152 | } |
| 3153 | |
| 3154 | static void ixj_post_cid(IXJ *j) |
| 3155 | { |
| 3156 | ixj_play_stop(j); |
| 3157 | |
| 3158 | if(j->cidsize > 5000) { |
| 3159 | SLIC_SetState(PLD_SLIC_STATE_STANDBY, j); |
| 3160 | } |
| 3161 | j->flags.cidplay = 0; |
| 3162 | if(ixjdebug & 0x0200) { |
| 3163 | printk("IXJ phone%d Finished Playing CallerID data %ld\n", j->board, jiffies); |
| 3164 | } |
| 3165 | |
| 3166 | ixj_fsk_free(j); |
| 3167 | |
| 3168 | j->fskdcnt = 0; |
| 3169 | set_base_frame(j, j->cid_base_frame_size); |
| 3170 | set_play_codec(j, j->cid_play_codec); |
| 3171 | ixj_aec_start(j, j->cid_play_aec_level); |
| 3172 | set_play_volume(j, j->cid_play_volume); |
| 3173 | |
| 3174 | set_rec_codec(j, j->cid_rec_codec); |
| 3175 | set_rec_volume(j, j->cid_rec_volume); |
| 3176 | |
| 3177 | if(j->cid_rec_flag) |
| 3178 | ixj_record_start(j); |
| 3179 | |
| 3180 | if(j->cid_play_flag) |
| 3181 | ixj_play_start(j); |
| 3182 | |
| 3183 | if(j->cid_play_flag) { |
| 3184 | wake_up_interruptible(&j->write_q); /* Wake any blocked writers */ |
| 3185 | } |
| 3186 | } |
| 3187 | |
| 3188 | static void ixj_write_cid(IXJ *j) |
| 3189 | { |
| 3190 | char sdmf1[50]; |
| 3191 | char sdmf2[50]; |
| 3192 | char sdmf3[80]; |
| 3193 | char mdmflen, len1, len2, len3; |
| 3194 | int pad; |
| 3195 | |
| 3196 | int checksum = 0; |
| 3197 | |
| 3198 | if (j->dsp.low == 0x20 || j->flags.cidplay) |
| 3199 | return; |
| 3200 | |
| 3201 | j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0; |
| 3202 | j->cidsize = j->cidcnt = 0; |
| 3203 | |
| 3204 | ixj_fsk_alloc(j); |
| 3205 | |
| 3206 | strcpy(sdmf1, j->cid_send.month); |
| 3207 | strcat(sdmf1, j->cid_send.day); |
| 3208 | strcat(sdmf1, j->cid_send.hour); |
| 3209 | strcat(sdmf1, j->cid_send.min); |
| 3210 | strcpy(sdmf2, j->cid_send.number); |
| 3211 | strcpy(sdmf3, j->cid_send.name); |
| 3212 | |
| 3213 | len1 = strlen(sdmf1); |
| 3214 | len2 = strlen(sdmf2); |
| 3215 | len3 = strlen(sdmf3); |
| 3216 | mdmflen = len1 + len2 + len3 + 6; |
| 3217 | |
| 3218 | while(1){ |
| 3219 | ixj_write_cid_seize(j); |
| 3220 | |
| 3221 | ixj_write_cid_byte(j, 0x80); |
| 3222 | checksum = 0x80; |
| 3223 | ixj_write_cid_byte(j, mdmflen); |
| 3224 | checksum = checksum + mdmflen; |
| 3225 | |
| 3226 | ixj_write_cid_byte(j, 0x01); |
| 3227 | checksum = checksum + 0x01; |
| 3228 | ixj_write_cid_byte(j, len1); |
| 3229 | checksum = checksum + len1; |
| 3230 | checksum = ixj_write_cid_string(j, sdmf1, checksum); |
| 3231 | if(ixj_hookstate(j) & 1) |
| 3232 | break; |
| 3233 | |
| 3234 | ixj_write_cid_byte(j, 0x02); |
| 3235 | checksum = checksum + 0x02; |
| 3236 | ixj_write_cid_byte(j, len2); |
| 3237 | checksum = checksum + len2; |
| 3238 | checksum = ixj_write_cid_string(j, sdmf2, checksum); |
| 3239 | if(ixj_hookstate(j) & 1) |
| 3240 | break; |
| 3241 | |
| 3242 | ixj_write_cid_byte(j, 0x07); |
| 3243 | checksum = checksum + 0x07; |
| 3244 | ixj_write_cid_byte(j, len3); |
| 3245 | checksum = checksum + len3; |
| 3246 | checksum = ixj_write_cid_string(j, sdmf3, checksum); |
| 3247 | if(ixj_hookstate(j) & 1) |
| 3248 | break; |
| 3249 | |
| 3250 | checksum %= 256; |
| 3251 | checksum ^= 0xFF; |
| 3252 | checksum += 1; |
| 3253 | |
| 3254 | ixj_write_cid_byte(j, (char) checksum); |
| 3255 | |
| 3256 | pad = j->fskdcnt % 240; |
| 3257 | if (pad) { |
| 3258 | pad = 240 - pad; |
| 3259 | } |
| 3260 | ixj_pad_fsk(j, pad); |
| 3261 | break; |
| 3262 | } |
| 3263 | |
| 3264 | ixj_write_frame(j); |
| 3265 | } |
| 3266 | |
| 3267 | static void ixj_write_cidcw(IXJ *j) |
| 3268 | { |
| 3269 | IXJ_TONE ti; |
| 3270 | |
| 3271 | char sdmf1[50]; |
| 3272 | char sdmf2[50]; |
| 3273 | char sdmf3[80]; |
| 3274 | char mdmflen, len1, len2, len3; |
| 3275 | int pad; |
| 3276 | |
| 3277 | int checksum = 0; |
| 3278 | |
| 3279 | if (j->dsp.low == 0x20 || j->flags.cidplay) |
| 3280 | return; |
| 3281 | |
| 3282 | j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0; |
| 3283 | j->cidsize = j->cidcnt = 0; |
| 3284 | |
| 3285 | ixj_fsk_alloc(j); |
| 3286 | |
| 3287 | j->flags.cidcw_ack = 0; |
| 3288 | |
| 3289 | ti.tone_index = 23; |
| 3290 | ti.gain0 = 1; |
| 3291 | ti.freq0 = hz440; |
| 3292 | ti.gain1 = 0; |
| 3293 | ti.freq1 = 0; |
| 3294 | ixj_init_tone(j, &ti); |
| 3295 | |
| 3296 | ixj_set_tone_on(1500, j); |
| 3297 | ixj_set_tone_off(32, j); |
| 3298 | if(ixjdebug & 0x0200) { |
| 3299 | printk("IXJ cidcw phone%d first tone start at %ld\n", j->board, jiffies); |
| 3300 | } |
| 3301 | ixj_play_tone(j, 23); |
| 3302 | |
| 3303 | clear_bit(j->board, &j->busyflags); |
| 3304 | while(j->tone_state) { |
| 3305 | set_current_state(TASK_INTERRUPTIBLE); |
| 3306 | schedule_timeout(1); |
| 3307 | } |
| 3308 | while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) { |
| 3309 | set_current_state(TASK_INTERRUPTIBLE); |
| 3310 | schedule_timeout(1); |
| 3311 | } |
| 3312 | if(ixjdebug & 0x0200) { |
| 3313 | printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies); |
| 3314 | } |
| 3315 | |
| 3316 | ti.tone_index = 24; |
| 3317 | ti.gain0 = 1; |
| 3318 | ti.freq0 = hz2130; |
| 3319 | ti.gain1 = 0; |
| 3320 | ti.freq1 = hz2750; |
| 3321 | ixj_init_tone(j, &ti); |
| 3322 | |
| 3323 | ixj_set_tone_off(10, j); |
| 3324 | ixj_set_tone_on(600, j); |
| 3325 | if(ixjdebug & 0x0200) { |
| 3326 | printk("IXJ cidcw phone%d second tone start at %ld\n", j->board, jiffies); |
| 3327 | } |
| 3328 | ixj_play_tone(j, 24); |
| 3329 | |
| 3330 | clear_bit(j->board, &j->busyflags); |
| 3331 | while(j->tone_state) { |
| 3332 | set_current_state(TASK_INTERRUPTIBLE); |
| 3333 | schedule_timeout(1); |
| 3334 | } |
| 3335 | while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) { |
| 3336 | set_current_state(TASK_INTERRUPTIBLE); |
| 3337 | schedule_timeout(1); |
| 3338 | } |
| 3339 | if(ixjdebug & 0x0200) { |
| 3340 | printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies); |
| 3341 | } |
| 3342 | |
| 3343 | j->cidcw_wait = jiffies + ((50 * hertz) / 100); |
| 3344 | |
| 3345 | clear_bit(j->board, &j->busyflags); |
| 3346 | while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait)) { |
| 3347 | set_current_state(TASK_INTERRUPTIBLE); |
| 3348 | schedule_timeout(1); |
| 3349 | } |
| 3350 | while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) { |
| 3351 | set_current_state(TASK_INTERRUPTIBLE); |
| 3352 | schedule_timeout(1); |
| 3353 | } |
| 3354 | j->cidcw_wait = 0; |
| 3355 | if(!j->flags.cidcw_ack) { |
| 3356 | if(ixjdebug & 0x0200) { |
| 3357 | printk("IXJ cidcw phone%d did not receive ACK from display %ld\n", j->board, jiffies); |
| 3358 | } |
| 3359 | ixj_post_cid(j); |
| 3360 | if(j->cid_play_flag) { |
| 3361 | wake_up_interruptible(&j->write_q); /* Wake any blocked readers */ |
| 3362 | } |
| 3363 | return; |
| 3364 | } else { |
| 3365 | ixj_pre_cid(j); |
| 3366 | } |
| 3367 | j->flags.cidcw_ack = 0; |
| 3368 | strcpy(sdmf1, j->cid_send.month); |
| 3369 | strcat(sdmf1, j->cid_send.day); |
| 3370 | strcat(sdmf1, j->cid_send.hour); |
| 3371 | strcat(sdmf1, j->cid_send.min); |
| 3372 | strcpy(sdmf2, j->cid_send.number); |
| 3373 | strcpy(sdmf3, j->cid_send.name); |
| 3374 | |
| 3375 | len1 = strlen(sdmf1); |
| 3376 | len2 = strlen(sdmf2); |
| 3377 | len3 = strlen(sdmf3); |
| 3378 | mdmflen = len1 + len2 + len3 + 6; |
| 3379 | |
| 3380 | ixj_write_cidcw_seize(j); |
| 3381 | |
| 3382 | ixj_write_cid_byte(j, 0x80); |
| 3383 | checksum = 0x80; |
| 3384 | ixj_write_cid_byte(j, mdmflen); |
| 3385 | checksum = checksum + mdmflen; |
| 3386 | |
| 3387 | ixj_write_cid_byte(j, 0x01); |
| 3388 | checksum = checksum + 0x01; |
| 3389 | ixj_write_cid_byte(j, len1); |
| 3390 | checksum = checksum + len1; |
| 3391 | checksum = ixj_write_cid_string(j, sdmf1, checksum); |
| 3392 | |
| 3393 | ixj_write_cid_byte(j, 0x02); |
| 3394 | checksum = checksum + 0x02; |
| 3395 | ixj_write_cid_byte(j, len2); |
| 3396 | checksum = checksum + len2; |
| 3397 | checksum = ixj_write_cid_string(j, sdmf2, checksum); |
| 3398 | |
| 3399 | ixj_write_cid_byte(j, 0x07); |
| 3400 | checksum = checksum + 0x07; |
| 3401 | ixj_write_cid_byte(j, len3); |
| 3402 | checksum = checksum + len3; |
| 3403 | checksum = ixj_write_cid_string(j, sdmf3, checksum); |
| 3404 | |
| 3405 | checksum %= 256; |
| 3406 | checksum ^= 0xFF; |
| 3407 | checksum += 1; |
| 3408 | |
| 3409 | ixj_write_cid_byte(j, (char) checksum); |
| 3410 | |
| 3411 | pad = j->fskdcnt % 240; |
| 3412 | if (pad) { |
| 3413 | pad = 240 - pad; |
| 3414 | } |
| 3415 | ixj_pad_fsk(j, pad); |
| 3416 | if(ixjdebug & 0x0200) { |
| 3417 | printk("IXJ cidcw phone%d sent FSK data at %ld\n", j->board, jiffies); |
| 3418 | } |
| 3419 | } |
| 3420 | |
| 3421 | static void ixj_write_vmwi(IXJ *j, int msg) |
| 3422 | { |
| 3423 | char mdmflen; |
| 3424 | int pad; |
| 3425 | |
| 3426 | int checksum = 0; |
| 3427 | |
| 3428 | if (j->dsp.low == 0x20 || j->flags.cidplay) |
| 3429 | return; |
| 3430 | |
| 3431 | j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0; |
| 3432 | j->cidsize = j->cidcnt = 0; |
| 3433 | |
| 3434 | ixj_fsk_alloc(j); |
| 3435 | |
| 3436 | mdmflen = 3; |
| 3437 | |
| 3438 | if (j->port == PORT_POTS) |
| 3439 | SLIC_SetState(PLD_SLIC_STATE_OHT, j); |
| 3440 | |
| 3441 | ixj_write_cid_seize(j); |
| 3442 | |
| 3443 | ixj_write_cid_byte(j, 0x82); |
| 3444 | checksum = 0x82; |
| 3445 | ixj_write_cid_byte(j, mdmflen); |
| 3446 | checksum = checksum + mdmflen; |
| 3447 | |
| 3448 | ixj_write_cid_byte(j, 0x0B); |
| 3449 | checksum = checksum + 0x0B; |
| 3450 | ixj_write_cid_byte(j, 1); |
| 3451 | checksum = checksum + 1; |
| 3452 | |
| 3453 | if(msg) { |
| 3454 | ixj_write_cid_byte(j, 0xFF); |
| 3455 | checksum = checksum + 0xFF; |
| 3456 | } |
| 3457 | else { |
| 3458 | ixj_write_cid_byte(j, 0x00); |
| 3459 | checksum = checksum + 0x00; |
| 3460 | } |
| 3461 | |
| 3462 | checksum %= 256; |
| 3463 | checksum ^= 0xFF; |
| 3464 | checksum += 1; |
| 3465 | |
| 3466 | ixj_write_cid_byte(j, (char) checksum); |
| 3467 | |
| 3468 | pad = j->fskdcnt % 240; |
| 3469 | if (pad) { |
| 3470 | pad = 240 - pad; |
| 3471 | } |
| 3472 | ixj_pad_fsk(j, pad); |
| 3473 | } |
| 3474 | |
| 3475 | static void ixj_write_frame(IXJ *j) |
| 3476 | { |
| 3477 | int cnt, frame_count, dly; |
| 3478 | IXJ_WORD dat; |
| 3479 | BYTES blankword; |
| 3480 | |
| 3481 | frame_count = 0; |
| 3482 | if(j->flags.cidplay) { |
| 3483 | for(cnt = 0; cnt < 480; cnt++) { |
| 3484 | if (!(cnt % 16) && !IsTxReady(j)) { |
| 3485 | dly = 0; |
| 3486 | while (!IsTxReady(j)) { |
| 3487 | if (dly++ > 5) { |
| 3488 | dly = 0; |
| 3489 | break; |
| 3490 | } |
| 3491 | udelay(10); |
| 3492 | } |
| 3493 | } |
| 3494 | dat.word = j->fskdata[j->cidcnt++]; |
| 3495 | outb_p(dat.bytes.low, j->DSPbase + 0x0C); |
| 3496 | outb_p(dat.bytes.high, j->DSPbase + 0x0D); |
| 3497 | cnt++; |
| 3498 | } |
| 3499 | if(j->cidcnt >= j->fskdcnt) { |
| 3500 | ixj_post_cid(j); |
| 3501 | } |
| 3502 | /* This may seem rude, but if we just played one frame of FSK data for CallerID |
| 3503 | and there is real audio data in the buffer, we need to throw it away because |
| 3504 | we just used it's time slot */ |
| 3505 | if (j->write_buffer_rp > j->write_buffer_wp) { |
| 3506 | j->write_buffer_rp += j->cid_play_frame_size * 2; |
| 3507 | if (j->write_buffer_rp >= j->write_buffer_end) { |
| 3508 | j->write_buffer_rp = j->write_buffer; |
| 3509 | } |
| 3510 | j->write_buffers_empty++; |
| 3511 | wake_up_interruptible(&j->write_q); /* Wake any blocked writers */ |
| 3512 | |
| 3513 | wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */ |
| 3514 | } |
| 3515 | } else if (j->write_buffer && j->write_buffers_empty < 1) { |
| 3516 | if (j->write_buffer_wp > j->write_buffer_rp) { |
| 3517 | frame_count = |
| 3518 | (j->write_buffer_wp - j->write_buffer_rp) / (j->play_frame_size * 2); |
| 3519 | } |
| 3520 | if (j->write_buffer_rp > j->write_buffer_wp) { |
| 3521 | frame_count = |
| 3522 | (j->write_buffer_wp - j->write_buffer) / (j->play_frame_size * 2) + |
| 3523 | (j->write_buffer_end - j->write_buffer_rp) / (j->play_frame_size * 2); |
| 3524 | } |
| 3525 | if (frame_count >= 1) { |
| 3526 | if (j->ver.low == 0x12 && j->play_mode && j->flags.play_first_frame) { |
| 3527 | switch (j->play_mode) { |
| 3528 | case PLAYBACK_MODE_ULAW: |
| 3529 | case PLAYBACK_MODE_ALAW: |
| 3530 | blankword.low = blankword.high = 0xFF; |
| 3531 | break; |
| 3532 | case PLAYBACK_MODE_8LINEAR: |
| 3533 | case PLAYBACK_MODE_16LINEAR: |
| 3534 | blankword.low = blankword.high = 0x00; |
| 3535 | break; |
| 3536 | case PLAYBACK_MODE_8LINEAR_WSS: |
| 3537 | blankword.low = blankword.high = 0x80; |
| 3538 | break; |
| 3539 | } |
| 3540 | for (cnt = 0; cnt < 16; cnt++) { |
| 3541 | if (!(cnt % 16) && !IsTxReady(j)) { |
| 3542 | dly = 0; |
| 3543 | while (!IsTxReady(j)) { |
| 3544 | if (dly++ > 5) { |
| 3545 | dly = 0; |
| 3546 | break; |
| 3547 | } |
| 3548 | udelay(10); |
| 3549 | } |
| 3550 | } |
| 3551 | outb_p((blankword.low), j->DSPbase + 0x0C); |
| 3552 | outb_p((blankword.high), j->DSPbase + 0x0D); |
| 3553 | } |
| 3554 | j->flags.play_first_frame = 0; |
| 3555 | } else if (j->play_codec == G723_63 && j->flags.play_first_frame) { |
| 3556 | for (cnt = 0; cnt < 24; cnt++) { |
| 3557 | if(cnt == 12) { |
| 3558 | blankword.low = 0x02; |
| 3559 | blankword.high = 0x00; |
| 3560 | } |
| 3561 | else { |
| 3562 | blankword.low = blankword.high = 0x00; |
| 3563 | } |
| 3564 | if (!(cnt % 16) && !IsTxReady(j)) { |
| 3565 | dly = 0; |
| 3566 | while (!IsTxReady(j)) { |
| 3567 | if (dly++ > 5) { |
| 3568 | dly = 0; |
| 3569 | break; |
| 3570 | } |
| 3571 | udelay(10); |
| 3572 | } |
| 3573 | } |
| 3574 | outb_p((blankword.low), j->DSPbase + 0x0C); |
| 3575 | outb_p((blankword.high), j->DSPbase + 0x0D); |
| 3576 | } |
| 3577 | j->flags.play_first_frame = 0; |
| 3578 | } |
| 3579 | for (cnt = 0; cnt < j->play_frame_size * 2; cnt += 2) { |
| 3580 | if (!(cnt % 16) && !IsTxReady(j)) { |
| 3581 | dly = 0; |
| 3582 | while (!IsTxReady(j)) { |
| 3583 | if (dly++ > 5) { |
| 3584 | dly = 0; |
| 3585 | break; |
| 3586 | } |
| 3587 | udelay(10); |
| 3588 | } |
| 3589 | } |
| 3590 | /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */ |
| 3591 | if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) { |
| 3592 | if(j->write_buffer_rp + cnt == 0 && j->write_buffer_rp + cnt + 1 == 0 && j->write_buffer_rp + cnt + 2 == 0 && |
| 3593 | j->write_buffer_rp + cnt + 3 == 0 && j->write_buffer_rp + cnt + 4 == 0 && j->write_buffer_rp + cnt + 5 == 0 && |
| 3594 | j->write_buffer_rp + cnt + 6 == 0 && j->write_buffer_rp + cnt + 7 == 0 && j->write_buffer_rp + cnt + 8 == 0 && |
| 3595 | j->write_buffer_rp + cnt + 9 == 0) { |
| 3596 | /* someone is trying to write silence lets make this a type 0 frame. */ |
| 3597 | outb_p(0x00, j->DSPbase + 0x0C); |
| 3598 | outb_p(0x00, j->DSPbase + 0x0D); |
| 3599 | } else { |
| 3600 | /* so all other frames are type 1. */ |
| 3601 | outb_p(0x01, j->DSPbase + 0x0C); |
| 3602 | outb_p(0x00, j->DSPbase + 0x0D); |
| 3603 | } |
| 3604 | } |
| 3605 | outb_p(*(j->write_buffer_rp + cnt), j->DSPbase + 0x0C); |
| 3606 | outb_p(*(j->write_buffer_rp + cnt + 1), j->DSPbase + 0x0D); |
| 3607 | *(j->write_buffer_rp + cnt) = 0; |
| 3608 | *(j->write_buffer_rp + cnt + 1) = 0; |
| 3609 | } |
| 3610 | j->write_buffer_rp += j->play_frame_size * 2; |
| 3611 | if (j->write_buffer_rp >= j->write_buffer_end) { |
| 3612 | j->write_buffer_rp = j->write_buffer; |
| 3613 | } |
| 3614 | j->write_buffers_empty++; |
| 3615 | wake_up_interruptible(&j->write_q); /* Wake any blocked writers */ |
| 3616 | |
| 3617 | wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */ |
| 3618 | |
| 3619 | ++j->frameswritten; |
| 3620 | } |
| 3621 | } else { |
| 3622 | j->drybuffer++; |
| 3623 | } |
| 3624 | if(j->ixj_signals[SIG_WRITE_READY]) { |
| 3625 | ixj_kill_fasync(j, SIG_WRITE_READY, POLL_OUT); |
| 3626 | } |
| 3627 | } |
| 3628 | |
| 3629 | static int idle(IXJ *j) |
| 3630 | { |
| 3631 | if (ixj_WriteDSPCommand(0x0000, j)) /* DSP Idle */ |
| 3632 | |
| 3633 | return 0; |
| 3634 | |
| 3635 | if (j->ssr.high || j->ssr.low) { |
| 3636 | return 0; |
| 3637 | } else { |
| 3638 | j->play_mode = -1; |
| 3639 | j->flags.playing = 0; |
| 3640 | j->rec_mode = -1; |
| 3641 | j->flags.recording = 0; |
| 3642 | return 1; |
| 3643 | } |
| 3644 | } |
| 3645 | |
| 3646 | static int set_base_frame(IXJ *j, int size) |
| 3647 | { |
| 3648 | unsigned short cmd; |
| 3649 | int cnt; |
| 3650 | |
| 3651 | idle(j); |
| 3652 | j->cid_play_aec_level = j->aec_level; |
| 3653 | aec_stop(j); |
| 3654 | for (cnt = 0; cnt < 10; cnt++) { |
| 3655 | if (idle(j)) |
| 3656 | break; |
| 3657 | } |
| 3658 | if (j->ssr.high || j->ssr.low) |
| 3659 | return -1; |
| 3660 | if (j->dsp.low != 0x20) { |
| 3661 | switch (size) { |
| 3662 | case 30: |
| 3663 | cmd = 0x07F0; |
| 3664 | /* Set Base Frame Size to 240 pg9-10 8021 */ |
| 3665 | break; |
| 3666 | case 20: |
| 3667 | cmd = 0x07A0; |
| 3668 | /* Set Base Frame Size to 160 pg9-10 8021 */ |
| 3669 | break; |
| 3670 | case 10: |
| 3671 | cmd = 0x0750; |
| 3672 | /* Set Base Frame Size to 80 pg9-10 8021 */ |
| 3673 | break; |
| 3674 | default: |
| 3675 | return -1; |
| 3676 | } |
| 3677 | } else { |
| 3678 | if (size == 30) |
| 3679 | return size; |
| 3680 | else |
| 3681 | return -1; |
| 3682 | } |
| 3683 | if (ixj_WriteDSPCommand(cmd, j)) { |
| 3684 | j->baseframe.high = j->baseframe.low = 0xFF; |
| 3685 | return -1; |
| 3686 | } else { |
| 3687 | j->baseframe.high = j->ssr.high; |
| 3688 | j->baseframe.low = j->ssr.low; |
| 3689 | /* If the status returned is 0x0000 (pg9-9 8021) the call failed */ |
| 3690 | if(j->baseframe.high == 0x00 && j->baseframe.low == 0x00) { |
| 3691 | return -1; |
| 3692 | } |
| 3693 | } |
| 3694 | ixj_aec_start(j, j->cid_play_aec_level); |
| 3695 | return size; |
| 3696 | } |
| 3697 | |
| 3698 | static int set_rec_codec(IXJ *j, int rate) |
| 3699 | { |
| 3700 | int retval = 0; |
| 3701 | |
| 3702 | j->rec_codec = rate; |
| 3703 | |
| 3704 | switch (rate) { |
| 3705 | case G723_63: |
| 3706 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 3707 | j->rec_frame_size = 12; |
| 3708 | j->rec_mode = 0; |
| 3709 | } else { |
| 3710 | retval = 1; |
| 3711 | } |
| 3712 | break; |
| 3713 | case G723_53: |
| 3714 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 3715 | j->rec_frame_size = 10; |
| 3716 | j->rec_mode = 0; |
| 3717 | } else { |
| 3718 | retval = 1; |
| 3719 | } |
| 3720 | break; |
| 3721 | case TS85: |
| 3722 | if (j->dsp.low == 0x20 || j->flags.ts85_loaded) { |
| 3723 | j->rec_frame_size = 16; |
| 3724 | j->rec_mode = 0; |
| 3725 | } else { |
| 3726 | retval = 1; |
| 3727 | } |
| 3728 | break; |
| 3729 | case TS48: |
| 3730 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 3731 | j->rec_frame_size = 9; |
| 3732 | j->rec_mode = 0; |
| 3733 | } else { |
| 3734 | retval = 1; |
| 3735 | } |
| 3736 | break; |
| 3737 | case TS41: |
| 3738 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 3739 | j->rec_frame_size = 8; |
| 3740 | j->rec_mode = 0; |
| 3741 | } else { |
| 3742 | retval = 1; |
| 3743 | } |
| 3744 | break; |
| 3745 | case G728: |
| 3746 | if (j->dsp.low != 0x20) { |
| 3747 | j->rec_frame_size = 48; |
| 3748 | j->rec_mode = 0; |
| 3749 | } else { |
| 3750 | retval = 1; |
| 3751 | } |
| 3752 | break; |
| 3753 | case G729: |
| 3754 | if (j->dsp.low != 0x20) { |
| 3755 | if (!j->flags.g729_loaded) { |
| 3756 | retval = 1; |
| 3757 | break; |
| 3758 | } |
| 3759 | switch (j->baseframe.low) { |
| 3760 | case 0xA0: |
| 3761 | j->rec_frame_size = 10; |
| 3762 | break; |
| 3763 | case 0x50: |
| 3764 | j->rec_frame_size = 5; |
| 3765 | break; |
| 3766 | default: |
| 3767 | j->rec_frame_size = 15; |
| 3768 | break; |
| 3769 | } |
| 3770 | j->rec_mode = 0; |
| 3771 | } else { |
| 3772 | retval = 1; |
| 3773 | } |
| 3774 | break; |
| 3775 | case G729B: |
| 3776 | if (j->dsp.low != 0x20) { |
| 3777 | if (!j->flags.g729_loaded) { |
| 3778 | retval = 1; |
| 3779 | break; |
| 3780 | } |
| 3781 | switch (j->baseframe.low) { |
| 3782 | case 0xA0: |
| 3783 | j->rec_frame_size = 12; |
| 3784 | break; |
| 3785 | case 0x50: |
| 3786 | j->rec_frame_size = 6; |
| 3787 | break; |
| 3788 | default: |
| 3789 | j->rec_frame_size = 18; |
| 3790 | break; |
| 3791 | } |
| 3792 | j->rec_mode = 0; |
| 3793 | } else { |
| 3794 | retval = 1; |
| 3795 | } |
| 3796 | break; |
| 3797 | case ULAW: |
| 3798 | switch (j->baseframe.low) { |
| 3799 | case 0xA0: |
| 3800 | j->rec_frame_size = 80; |
| 3801 | break; |
| 3802 | case 0x50: |
| 3803 | j->rec_frame_size = 40; |
| 3804 | break; |
| 3805 | default: |
| 3806 | j->rec_frame_size = 120; |
| 3807 | break; |
| 3808 | } |
| 3809 | j->rec_mode = 4; |
| 3810 | break; |
| 3811 | case ALAW: |
| 3812 | switch (j->baseframe.low) { |
| 3813 | case 0xA0: |
| 3814 | j->rec_frame_size = 80; |
| 3815 | break; |
| 3816 | case 0x50: |
| 3817 | j->rec_frame_size = 40; |
| 3818 | break; |
| 3819 | default: |
| 3820 | j->rec_frame_size = 120; |
| 3821 | break; |
| 3822 | } |
| 3823 | j->rec_mode = 4; |
| 3824 | break; |
| 3825 | case LINEAR16: |
| 3826 | switch (j->baseframe.low) { |
| 3827 | case 0xA0: |
| 3828 | j->rec_frame_size = 160; |
| 3829 | break; |
| 3830 | case 0x50: |
| 3831 | j->rec_frame_size = 80; |
| 3832 | break; |
| 3833 | default: |
| 3834 | j->rec_frame_size = 240; |
| 3835 | break; |
| 3836 | } |
| 3837 | j->rec_mode = 5; |
| 3838 | break; |
| 3839 | case LINEAR8: |
| 3840 | switch (j->baseframe.low) { |
| 3841 | case 0xA0: |
| 3842 | j->rec_frame_size = 80; |
| 3843 | break; |
| 3844 | case 0x50: |
| 3845 | j->rec_frame_size = 40; |
| 3846 | break; |
| 3847 | default: |
| 3848 | j->rec_frame_size = 120; |
| 3849 | break; |
| 3850 | } |
| 3851 | j->rec_mode = 6; |
| 3852 | break; |
| 3853 | case WSS: |
| 3854 | switch (j->baseframe.low) { |
| 3855 | case 0xA0: |
| 3856 | j->rec_frame_size = 80; |
| 3857 | break; |
| 3858 | case 0x50: |
| 3859 | j->rec_frame_size = 40; |
| 3860 | break; |
| 3861 | default: |
| 3862 | j->rec_frame_size = 120; |
| 3863 | break; |
| 3864 | } |
| 3865 | j->rec_mode = 7; |
| 3866 | break; |
| 3867 | default: |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 3868 | kfree(j->read_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3869 | j->rec_frame_size = 0; |
| 3870 | j->rec_mode = -1; |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 3871 | j->read_buffer = NULL; |
| 3872 | j->read_buffer_size = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3873 | retval = 1; |
| 3874 | break; |
| 3875 | } |
| 3876 | return retval; |
| 3877 | } |
| 3878 | |
| 3879 | static int ixj_record_start(IXJ *j) |
| 3880 | { |
| 3881 | unsigned short cmd = 0x0000; |
| 3882 | |
| 3883 | if (j->read_buffer) { |
| 3884 | ixj_record_stop(j); |
| 3885 | } |
| 3886 | j->flags.recording = 1; |
| 3887 | ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */ |
| 3888 | |
| 3889 | if(ixjdebug & 0x0002) |
| 3890 | printk("IXJ %d Starting Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies); |
| 3891 | |
| 3892 | if (!j->rec_mode) { |
| 3893 | switch (j->rec_codec) { |
| 3894 | case G723_63: |
| 3895 | cmd = 0x5131; |
| 3896 | break; |
| 3897 | case G723_53: |
| 3898 | cmd = 0x5132; |
| 3899 | break; |
| 3900 | case TS85: |
| 3901 | cmd = 0x5130; /* TrueSpeech 8.5 */ |
| 3902 | |
| 3903 | break; |
| 3904 | case TS48: |
| 3905 | cmd = 0x5133; /* TrueSpeech 4.8 */ |
| 3906 | |
| 3907 | break; |
| 3908 | case TS41: |
| 3909 | cmd = 0x5134; /* TrueSpeech 4.1 */ |
| 3910 | |
| 3911 | break; |
| 3912 | case G728: |
| 3913 | cmd = 0x5135; |
| 3914 | break; |
| 3915 | case G729: |
| 3916 | case G729B: |
| 3917 | cmd = 0x5136; |
| 3918 | break; |
| 3919 | default: |
| 3920 | return 1; |
| 3921 | } |
| 3922 | if (ixj_WriteDSPCommand(cmd, j)) |
| 3923 | return -1; |
| 3924 | } |
| 3925 | if (!j->read_buffer) { |
| 3926 | if (!j->read_buffer) |
| 3927 | j->read_buffer = kmalloc(j->rec_frame_size * 2, GFP_ATOMIC); |
| 3928 | if (!j->read_buffer) { |
| 3929 | printk("Read buffer allocation for ixj board %d failed!\n", j->board); |
| 3930 | return -ENOMEM; |
| 3931 | } |
| 3932 | } |
| 3933 | j->read_buffer_size = j->rec_frame_size * 2; |
| 3934 | |
| 3935 | if (ixj_WriteDSPCommand(0x5102, j)) /* Set Poll sync mode */ |
| 3936 | |
| 3937 | return -1; |
| 3938 | |
| 3939 | switch (j->rec_mode) { |
| 3940 | case 0: |
| 3941 | cmd = 0x1C03; /* Record C1 */ |
| 3942 | |
| 3943 | break; |
| 3944 | case 4: |
| 3945 | if (j->ver.low == 0x12) { |
| 3946 | cmd = 0x1E03; /* Record C1 */ |
| 3947 | |
| 3948 | } else { |
| 3949 | cmd = 0x1E01; /* Record C1 */ |
| 3950 | |
| 3951 | } |
| 3952 | break; |
| 3953 | case 5: |
| 3954 | if (j->ver.low == 0x12) { |
| 3955 | cmd = 0x1E83; /* Record C1 */ |
| 3956 | |
| 3957 | } else { |
| 3958 | cmd = 0x1E81; /* Record C1 */ |
| 3959 | |
| 3960 | } |
| 3961 | break; |
| 3962 | case 6: |
| 3963 | if (j->ver.low == 0x12) { |
| 3964 | cmd = 0x1F03; /* Record C1 */ |
| 3965 | |
| 3966 | } else { |
| 3967 | cmd = 0x1F01; /* Record C1 */ |
| 3968 | |
| 3969 | } |
| 3970 | break; |
| 3971 | case 7: |
| 3972 | if (j->ver.low == 0x12) { |
| 3973 | cmd = 0x1F83; /* Record C1 */ |
| 3974 | } else { |
| 3975 | cmd = 0x1F81; /* Record C1 */ |
| 3976 | } |
| 3977 | break; |
| 3978 | } |
| 3979 | if (ixj_WriteDSPCommand(cmd, j)) |
| 3980 | return -1; |
| 3981 | |
| 3982 | if (j->flags.playing) { |
| 3983 | ixj_aec_start(j, j->aec_level); |
| 3984 | } |
| 3985 | return 0; |
| 3986 | } |
| 3987 | |
| 3988 | static void ixj_record_stop(IXJ *j) |
| 3989 | { |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 3990 | if (ixjdebug & 0x0002) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3991 | printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies); |
| 3992 | |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 3993 | kfree(j->read_buffer); |
| 3994 | j->read_buffer = NULL; |
| 3995 | j->read_buffer_size = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3996 | if (j->rec_mode > -1) { |
| 3997 | ixj_WriteDSPCommand(0x5120, j); |
| 3998 | j->rec_mode = -1; |
| 3999 | } |
| 4000 | j->flags.recording = 0; |
| 4001 | } |
| 4002 | static void ixj_vad(IXJ *j, int arg) |
| 4003 | { |
| 4004 | if (arg) |
| 4005 | ixj_WriteDSPCommand(0x513F, j); |
| 4006 | else |
| 4007 | ixj_WriteDSPCommand(0x513E, j); |
| 4008 | } |
| 4009 | |
| 4010 | static void set_rec_depth(IXJ *j, int depth) |
| 4011 | { |
| 4012 | if (depth > 60) |
| 4013 | depth = 60; |
| 4014 | if (depth < 0) |
| 4015 | depth = 0; |
| 4016 | ixj_WriteDSPCommand(0x5180 + depth, j); |
| 4017 | } |
| 4018 | |
| 4019 | static void set_dtmf_prescale(IXJ *j, int volume) |
| 4020 | { |
| 4021 | ixj_WriteDSPCommand(0xCF07, j); |
| 4022 | ixj_WriteDSPCommand(volume, j); |
| 4023 | } |
| 4024 | |
| 4025 | static int get_dtmf_prescale(IXJ *j) |
| 4026 | { |
| 4027 | ixj_WriteDSPCommand(0xCF05, j); |
| 4028 | return j->ssr.high << 8 | j->ssr.low; |
| 4029 | } |
| 4030 | |
| 4031 | static void set_rec_volume(IXJ *j, int volume) |
| 4032 | { |
| 4033 | if(j->aec_level == AEC_AGC) { |
| 4034 | if (ixjdebug & 0x0002) |
| 4035 | printk(KERN_INFO "IXJ: /dev/phone%d Setting AGC Threshold to 0x%4.4x\n", j->board, volume); |
| 4036 | ixj_WriteDSPCommand(0xCF96, j); |
| 4037 | ixj_WriteDSPCommand(volume, j); |
| 4038 | } else { |
| 4039 | if (ixjdebug & 0x0002) |
| 4040 | printk(KERN_INFO "IXJ: /dev/phone %d Setting Record Volume to 0x%4.4x\n", j->board, volume); |
| 4041 | ixj_WriteDSPCommand(0xCF03, j); |
| 4042 | ixj_WriteDSPCommand(volume, j); |
| 4043 | } |
| 4044 | } |
| 4045 | |
| 4046 | static int set_rec_volume_linear(IXJ *j, int volume) |
| 4047 | { |
| 4048 | int newvolume, dsprecmax; |
| 4049 | |
| 4050 | if (ixjdebug & 0x0002) |
| 4051 | printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Record Volume to 0x%4.4x\n", j->board, volume); |
| 4052 | if(volume > 100 || volume < 0) { |
| 4053 | return -1; |
| 4054 | } |
| 4055 | |
| 4056 | /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */ |
| 4057 | switch (j->cardtype) { |
| 4058 | case QTI_PHONEJACK: |
| 4059 | dsprecmax = 0x440; |
| 4060 | break; |
| 4061 | case QTI_LINEJACK: |
| 4062 | dsprecmax = 0x180; |
| 4063 | ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */ |
| 4064 | ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */ |
| 4065 | ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */ |
| 4066 | break; |
| 4067 | case QTI_PHONEJACK_LITE: |
| 4068 | dsprecmax = 0x4C0; |
| 4069 | break; |
| 4070 | case QTI_PHONEJACK_PCI: |
| 4071 | dsprecmax = 0x100; |
| 4072 | break; |
| 4073 | case QTI_PHONECARD: |
| 4074 | dsprecmax = 0x400; |
| 4075 | break; |
| 4076 | default: |
| 4077 | return -1; |
| 4078 | } |
| 4079 | newvolume = (dsprecmax * volume) / 100; |
| 4080 | set_rec_volume(j, newvolume); |
| 4081 | return 0; |
| 4082 | } |
| 4083 | |
| 4084 | static int get_rec_volume(IXJ *j) |
| 4085 | { |
| 4086 | if(j->aec_level == AEC_AGC) { |
| 4087 | if (ixjdebug & 0x0002) |
| 4088 | printk(KERN_INFO "Getting AGC Threshold\n"); |
| 4089 | ixj_WriteDSPCommand(0xCF86, j); |
| 4090 | if (ixjdebug & 0x0002) |
| 4091 | printk(KERN_INFO "AGC Threshold is 0x%2.2x%2.2x\n", j->ssr.high, j->ssr.low); |
| 4092 | return j->ssr.high << 8 | j->ssr.low; |
| 4093 | } else { |
| 4094 | if (ixjdebug & 0x0002) |
| 4095 | printk(KERN_INFO "Getting Record Volume\n"); |
| 4096 | ixj_WriteDSPCommand(0xCF01, j); |
| 4097 | return j->ssr.high << 8 | j->ssr.low; |
| 4098 | } |
| 4099 | } |
| 4100 | |
| 4101 | static int get_rec_volume_linear(IXJ *j) |
| 4102 | { |
| 4103 | int volume, newvolume, dsprecmax; |
| 4104 | |
| 4105 | switch (j->cardtype) { |
| 4106 | case QTI_PHONEJACK: |
| 4107 | dsprecmax = 0x440; |
| 4108 | break; |
| 4109 | case QTI_LINEJACK: |
| 4110 | dsprecmax = 0x180; |
| 4111 | break; |
| 4112 | case QTI_PHONEJACK_LITE: |
| 4113 | dsprecmax = 0x4C0; |
| 4114 | break; |
| 4115 | case QTI_PHONEJACK_PCI: |
| 4116 | dsprecmax = 0x100; |
| 4117 | break; |
| 4118 | case QTI_PHONECARD: |
| 4119 | dsprecmax = 0x400; |
| 4120 | break; |
| 4121 | default: |
| 4122 | return -1; |
| 4123 | } |
| 4124 | volume = get_rec_volume(j); |
| 4125 | newvolume = (volume * 100) / dsprecmax; |
| 4126 | if(newvolume > 100) |
| 4127 | newvolume = 100; |
| 4128 | return newvolume; |
| 4129 | } |
| 4130 | |
| 4131 | static int get_rec_level(IXJ *j) |
| 4132 | { |
| 4133 | int retval; |
| 4134 | |
| 4135 | ixj_WriteDSPCommand(0xCF88, j); |
| 4136 | |
| 4137 | retval = j->ssr.high << 8 | j->ssr.low; |
| 4138 | retval = (retval * 256) / 240; |
| 4139 | return retval; |
| 4140 | } |
| 4141 | |
| 4142 | static void ixj_aec_start(IXJ *j, int level) |
| 4143 | { |
| 4144 | j->aec_level = level; |
| 4145 | if (ixjdebug & 0x0002) |
| 4146 | printk(KERN_INFO "AGC set = 0x%2.2x\n", j->aec_level); |
| 4147 | if (!level) { |
| 4148 | aec_stop(j); |
| 4149 | } else { |
| 4150 | if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) { |
| 4151 | ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer */ |
| 4152 | |
| 4153 | ixj_WriteDSPCommand(0x0300, j); |
| 4154 | } |
| 4155 | ixj_WriteDSPCommand(0xB001, j); /* AEC On */ |
| 4156 | |
| 4157 | ixj_WriteDSPCommand(0xE013, j); /* Advanced AEC C1 */ |
| 4158 | |
| 4159 | switch (level) { |
| 4160 | case AEC_LOW: |
| 4161 | ixj_WriteDSPCommand(0x0000, j); /* Advanced AEC C2 = off */ |
| 4162 | |
| 4163 | ixj_WriteDSPCommand(0xE011, j); |
| 4164 | ixj_WriteDSPCommand(0xFFFF, j); |
| 4165 | |
| 4166 | ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */ |
| 4167 | ixj_WriteDSPCommand(0x0000, j); /* to off */ |
| 4168 | |
| 4169 | break; |
| 4170 | |
| 4171 | case AEC_MED: |
| 4172 | ixj_WriteDSPCommand(0x0600, j); /* Advanced AEC C2 = on medium */ |
| 4173 | |
| 4174 | ixj_WriteDSPCommand(0xE011, j); |
| 4175 | ixj_WriteDSPCommand(0x0080, j); |
| 4176 | |
| 4177 | ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */ |
| 4178 | ixj_WriteDSPCommand(0x0000, j); /* to off */ |
| 4179 | |
| 4180 | break; |
| 4181 | |
| 4182 | case AEC_HIGH: |
| 4183 | ixj_WriteDSPCommand(0x0C00, j); /* Advanced AEC C2 = on high */ |
| 4184 | |
| 4185 | ixj_WriteDSPCommand(0xE011, j); |
| 4186 | ixj_WriteDSPCommand(0x0080, j); |
| 4187 | |
| 4188 | ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */ |
| 4189 | ixj_WriteDSPCommand(0x0000, j); /* to off */ |
| 4190 | |
| 4191 | break; |
| 4192 | |
| 4193 | case AEC_AGC: |
| 4194 | /* First we have to put the AEC into advance auto mode so that AGC will not conflict with it */ |
| 4195 | ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */ |
| 4196 | |
| 4197 | ixj_WriteDSPCommand(0xE011, j); |
| 4198 | ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */ |
| 4199 | |
| 4200 | ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */ |
| 4201 | |
| 4202 | if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD) |
| 4203 | ixj_WriteDSPCommand(0x0224, j); |
| 4204 | else |
| 4205 | ixj_WriteDSPCommand(0x1224, j); |
| 4206 | |
| 4207 | ixj_WriteDSPCommand(0xE014, j); |
| 4208 | ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */ |
| 4209 | |
| 4210 | ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */ |
| 4211 | |
| 4212 | /* Now we can set the AGC initial parameters and turn it on */ |
| 4213 | ixj_WriteDSPCommand(0xCF90, j); /* Set AGC Minumum gain */ |
| 4214 | ixj_WriteDSPCommand(0x0020, j); /* to 0.125 (-18dB) */ |
| 4215 | |
| 4216 | ixj_WriteDSPCommand(0xCF91, j); /* Set AGC Maximum gain */ |
| 4217 | ixj_WriteDSPCommand(0x1000, j); /* to 16 (24dB) */ |
| 4218 | |
| 4219 | ixj_WriteDSPCommand(0xCF92, j); /* Set AGC start gain */ |
| 4220 | ixj_WriteDSPCommand(0x0800, j); /* to 8 (+18dB) */ |
| 4221 | |
| 4222 | ixj_WriteDSPCommand(0xCF93, j); /* Set AGC hold time */ |
| 4223 | ixj_WriteDSPCommand(0x1F40, j); /* to 2 seconds (units are 250us) */ |
| 4224 | |
| 4225 | ixj_WriteDSPCommand(0xCF94, j); /* Set AGC Attack Time Constant */ |
| 4226 | ixj_WriteDSPCommand(0x0005, j); /* to 8ms */ |
| 4227 | |
| 4228 | ixj_WriteDSPCommand(0xCF95, j); /* Set AGC Decay Time Constant */ |
| 4229 | ixj_WriteDSPCommand(0x000D, j); /* to 4096ms */ |
| 4230 | |
| 4231 | ixj_WriteDSPCommand(0xCF96, j); /* Set AGC Attack Threshold */ |
| 4232 | ixj_WriteDSPCommand(0x1200, j); /* to 25% */ |
| 4233 | |
| 4234 | ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */ |
| 4235 | ixj_WriteDSPCommand(0x0001, j); /* to on */ |
| 4236 | |
| 4237 | break; |
| 4238 | |
| 4239 | case AEC_AUTO: |
| 4240 | ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */ |
| 4241 | |
| 4242 | ixj_WriteDSPCommand(0xE011, j); |
| 4243 | ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */ |
| 4244 | |
| 4245 | ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */ |
| 4246 | |
| 4247 | if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD) |
| 4248 | ixj_WriteDSPCommand(0x0224, j); |
| 4249 | else |
| 4250 | ixj_WriteDSPCommand(0x1224, j); |
| 4251 | |
| 4252 | ixj_WriteDSPCommand(0xE014, j); |
| 4253 | ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */ |
| 4254 | |
| 4255 | ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */ |
| 4256 | |
| 4257 | break; |
| 4258 | } |
| 4259 | } |
| 4260 | } |
| 4261 | |
| 4262 | static void aec_stop(IXJ *j) |
| 4263 | { |
| 4264 | j->aec_level = AEC_OFF; |
| 4265 | if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) { |
| 4266 | ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer back */ |
| 4267 | |
| 4268 | ixj_WriteDSPCommand(0x0700, j); |
| 4269 | } |
| 4270 | if (j->play_mode != -1 && j->rec_mode != -1) |
| 4271 | { |
| 4272 | ixj_WriteDSPCommand(0xB002, j); /* AEC Stop */ |
| 4273 | } |
| 4274 | } |
| 4275 | |
| 4276 | static int set_play_codec(IXJ *j, int rate) |
| 4277 | { |
| 4278 | int retval = 0; |
| 4279 | |
| 4280 | j->play_codec = rate; |
| 4281 | |
| 4282 | switch (rate) { |
| 4283 | case G723_63: |
| 4284 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 4285 | j->play_frame_size = 12; |
| 4286 | j->play_mode = 0; |
| 4287 | } else { |
| 4288 | retval = 1; |
| 4289 | } |
| 4290 | break; |
| 4291 | case G723_53: |
| 4292 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 4293 | j->play_frame_size = 10; |
| 4294 | j->play_mode = 0; |
| 4295 | } else { |
| 4296 | retval = 1; |
| 4297 | } |
| 4298 | break; |
| 4299 | case TS85: |
| 4300 | if (j->dsp.low == 0x20 || j->flags.ts85_loaded) { |
| 4301 | j->play_frame_size = 16; |
| 4302 | j->play_mode = 0; |
| 4303 | } else { |
| 4304 | retval = 1; |
| 4305 | } |
| 4306 | break; |
| 4307 | case TS48: |
| 4308 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 4309 | j->play_frame_size = 9; |
| 4310 | j->play_mode = 0; |
| 4311 | } else { |
| 4312 | retval = 1; |
| 4313 | } |
| 4314 | break; |
| 4315 | case TS41: |
| 4316 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 4317 | j->play_frame_size = 8; |
| 4318 | j->play_mode = 0; |
| 4319 | } else { |
| 4320 | retval = 1; |
| 4321 | } |
| 4322 | break; |
| 4323 | case G728: |
| 4324 | if (j->dsp.low != 0x20) { |
| 4325 | j->play_frame_size = 48; |
| 4326 | j->play_mode = 0; |
| 4327 | } else { |
| 4328 | retval = 1; |
| 4329 | } |
| 4330 | break; |
| 4331 | case G729: |
| 4332 | if (j->dsp.low != 0x20) { |
| 4333 | if (!j->flags.g729_loaded) { |
| 4334 | retval = 1; |
| 4335 | break; |
| 4336 | } |
| 4337 | switch (j->baseframe.low) { |
| 4338 | case 0xA0: |
| 4339 | j->play_frame_size = 10; |
| 4340 | break; |
| 4341 | case 0x50: |
| 4342 | j->play_frame_size = 5; |
| 4343 | break; |
| 4344 | default: |
| 4345 | j->play_frame_size = 15; |
| 4346 | break; |
| 4347 | } |
| 4348 | j->play_mode = 0; |
| 4349 | } else { |
| 4350 | retval = 1; |
| 4351 | } |
| 4352 | break; |
| 4353 | case G729B: |
| 4354 | if (j->dsp.low != 0x20) { |
| 4355 | if (!j->flags.g729_loaded) { |
| 4356 | retval = 1; |
| 4357 | break; |
| 4358 | } |
| 4359 | switch (j->baseframe.low) { |
| 4360 | case 0xA0: |
| 4361 | j->play_frame_size = 12; |
| 4362 | break; |
| 4363 | case 0x50: |
| 4364 | j->play_frame_size = 6; |
| 4365 | break; |
| 4366 | default: |
| 4367 | j->play_frame_size = 18; |
| 4368 | break; |
| 4369 | } |
| 4370 | j->play_mode = 0; |
| 4371 | } else { |
| 4372 | retval = 1; |
| 4373 | } |
| 4374 | break; |
| 4375 | case ULAW: |
| 4376 | switch (j->baseframe.low) { |
| 4377 | case 0xA0: |
| 4378 | j->play_frame_size = 80; |
| 4379 | break; |
| 4380 | case 0x50: |
| 4381 | j->play_frame_size = 40; |
| 4382 | break; |
| 4383 | default: |
| 4384 | j->play_frame_size = 120; |
| 4385 | break; |
| 4386 | } |
| 4387 | j->play_mode = 2; |
| 4388 | break; |
| 4389 | case ALAW: |
| 4390 | switch (j->baseframe.low) { |
| 4391 | case 0xA0: |
| 4392 | j->play_frame_size = 80; |
| 4393 | break; |
| 4394 | case 0x50: |
| 4395 | j->play_frame_size = 40; |
| 4396 | break; |
| 4397 | default: |
| 4398 | j->play_frame_size = 120; |
| 4399 | break; |
| 4400 | } |
| 4401 | j->play_mode = 2; |
| 4402 | break; |
| 4403 | case LINEAR16: |
| 4404 | switch (j->baseframe.low) { |
| 4405 | case 0xA0: |
| 4406 | j->play_frame_size = 160; |
| 4407 | break; |
| 4408 | case 0x50: |
| 4409 | j->play_frame_size = 80; |
| 4410 | break; |
| 4411 | default: |
| 4412 | j->play_frame_size = 240; |
| 4413 | break; |
| 4414 | } |
| 4415 | j->play_mode = 6; |
| 4416 | break; |
| 4417 | case LINEAR8: |
| 4418 | switch (j->baseframe.low) { |
| 4419 | case 0xA0: |
| 4420 | j->play_frame_size = 80; |
| 4421 | break; |
| 4422 | case 0x50: |
| 4423 | j->play_frame_size = 40; |
| 4424 | break; |
| 4425 | default: |
| 4426 | j->play_frame_size = 120; |
| 4427 | break; |
| 4428 | } |
| 4429 | j->play_mode = 4; |
| 4430 | break; |
| 4431 | case WSS: |
| 4432 | switch (j->baseframe.low) { |
| 4433 | case 0xA0: |
| 4434 | j->play_frame_size = 80; |
| 4435 | break; |
| 4436 | case 0x50: |
| 4437 | j->play_frame_size = 40; |
| 4438 | break; |
| 4439 | default: |
| 4440 | j->play_frame_size = 120; |
| 4441 | break; |
| 4442 | } |
| 4443 | j->play_mode = 5; |
| 4444 | break; |
| 4445 | default: |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 4446 | kfree(j->write_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4447 | j->play_frame_size = 0; |
| 4448 | j->play_mode = -1; |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 4449 | j->write_buffer = NULL; |
| 4450 | j->write_buffer_size = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4451 | retval = 1; |
| 4452 | break; |
| 4453 | } |
| 4454 | return retval; |
| 4455 | } |
| 4456 | |
| 4457 | static int ixj_play_start(IXJ *j) |
| 4458 | { |
| 4459 | unsigned short cmd = 0x0000; |
| 4460 | |
| 4461 | if (j->write_buffer) { |
| 4462 | ixj_play_stop(j); |
| 4463 | } |
| 4464 | |
| 4465 | if(ixjdebug & 0x0002) |
| 4466 | printk("IXJ %d Starting Play Codec %d at %ld\n", j->board, j->play_codec, jiffies); |
| 4467 | |
| 4468 | j->flags.playing = 1; |
| 4469 | ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */ |
| 4470 | |
| 4471 | j->flags.play_first_frame = 1; |
| 4472 | j->drybuffer = 0; |
| 4473 | |
| 4474 | if (!j->play_mode) { |
| 4475 | switch (j->play_codec) { |
| 4476 | case G723_63: |
| 4477 | cmd = 0x5231; |
| 4478 | break; |
| 4479 | case G723_53: |
| 4480 | cmd = 0x5232; |
| 4481 | break; |
| 4482 | case TS85: |
| 4483 | cmd = 0x5230; /* TrueSpeech 8.5 */ |
| 4484 | |
| 4485 | break; |
| 4486 | case TS48: |
| 4487 | cmd = 0x5233; /* TrueSpeech 4.8 */ |
| 4488 | |
| 4489 | break; |
| 4490 | case TS41: |
| 4491 | cmd = 0x5234; /* TrueSpeech 4.1 */ |
| 4492 | |
| 4493 | break; |
| 4494 | case G728: |
| 4495 | cmd = 0x5235; |
| 4496 | break; |
| 4497 | case G729: |
| 4498 | case G729B: |
| 4499 | cmd = 0x5236; |
| 4500 | break; |
| 4501 | default: |
| 4502 | return 1; |
| 4503 | } |
| 4504 | if (ixj_WriteDSPCommand(cmd, j)) |
| 4505 | return -1; |
| 4506 | } |
| 4507 | j->write_buffer = kmalloc(j->play_frame_size * 2, GFP_ATOMIC); |
| 4508 | if (!j->write_buffer) { |
| 4509 | printk("Write buffer allocation for ixj board %d failed!\n", j->board); |
| 4510 | return -ENOMEM; |
| 4511 | } |
| 4512 | /* j->write_buffers_empty = 2; */ |
| 4513 | j->write_buffers_empty = 1; |
| 4514 | j->write_buffer_size = j->play_frame_size * 2; |
| 4515 | j->write_buffer_end = j->write_buffer + j->play_frame_size * 2; |
| 4516 | j->write_buffer_rp = j->write_buffer_wp = j->write_buffer; |
| 4517 | |
| 4518 | if (ixj_WriteDSPCommand(0x5202, j)) /* Set Poll sync mode */ |
| 4519 | |
| 4520 | return -1; |
| 4521 | |
| 4522 | switch (j->play_mode) { |
| 4523 | case 0: |
| 4524 | cmd = 0x2C03; |
| 4525 | break; |
| 4526 | case 2: |
| 4527 | if (j->ver.low == 0x12) { |
| 4528 | cmd = 0x2C23; |
| 4529 | } else { |
| 4530 | cmd = 0x2C21; |
| 4531 | } |
| 4532 | break; |
| 4533 | case 4: |
| 4534 | if (j->ver.low == 0x12) { |
| 4535 | cmd = 0x2C43; |
| 4536 | } else { |
| 4537 | cmd = 0x2C41; |
| 4538 | } |
| 4539 | break; |
| 4540 | case 5: |
| 4541 | if (j->ver.low == 0x12) { |
| 4542 | cmd = 0x2C53; |
| 4543 | } else { |
| 4544 | cmd = 0x2C51; |
| 4545 | } |
| 4546 | break; |
| 4547 | case 6: |
| 4548 | if (j->ver.low == 0x12) { |
| 4549 | cmd = 0x2C63; |
| 4550 | } else { |
| 4551 | cmd = 0x2C61; |
| 4552 | } |
| 4553 | break; |
| 4554 | } |
| 4555 | if (ixj_WriteDSPCommand(cmd, j)) |
| 4556 | return -1; |
| 4557 | |
| 4558 | if (ixj_WriteDSPCommand(0x2000, j)) /* Playback C2 */ |
| 4559 | return -1; |
| 4560 | |
| 4561 | if (ixj_WriteDSPCommand(0x2000 + j->play_frame_size, j)) /* Playback C3 */ |
| 4562 | return -1; |
| 4563 | |
| 4564 | if (j->flags.recording) { |
| 4565 | ixj_aec_start(j, j->aec_level); |
| 4566 | } |
| 4567 | |
| 4568 | return 0; |
| 4569 | } |
| 4570 | |
| 4571 | static void ixj_play_stop(IXJ *j) |
| 4572 | { |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 4573 | if (ixjdebug & 0x0002) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4574 | printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies); |
| 4575 | |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 4576 | kfree(j->write_buffer); |
| 4577 | j->write_buffer = NULL; |
| 4578 | j->write_buffer_size = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4579 | if (j->play_mode > -1) { |
| 4580 | ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */ |
| 4581 | |
| 4582 | j->play_mode = -1; |
| 4583 | } |
| 4584 | j->flags.playing = 0; |
| 4585 | } |
| 4586 | |
| 4587 | static inline int get_play_level(IXJ *j) |
| 4588 | { |
| 4589 | int retval; |
| 4590 | |
| 4591 | ixj_WriteDSPCommand(0xCF8F, j); /* 8022 Reference page 9-38 */ |
| 4592 | return j->ssr.high << 8 | j->ssr.low; |
| 4593 | retval = j->ssr.high << 8 | j->ssr.low; |
| 4594 | retval = (retval * 256) / 240; |
| 4595 | return retval; |
| 4596 | } |
| 4597 | |
| 4598 | static unsigned int ixj_poll(struct file *file_p, poll_table * wait) |
| 4599 | { |
| 4600 | unsigned int mask = 0; |
| 4601 | |
| 4602 | IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode)); |
| 4603 | |
| 4604 | poll_wait(file_p, &(j->poll_q), wait); |
| 4605 | if (j->read_buffer_ready > 0) |
| 4606 | mask |= POLLIN | POLLRDNORM; /* readable */ |
| 4607 | if (j->write_buffers_empty > 0) |
| 4608 | mask |= POLLOUT | POLLWRNORM; /* writable */ |
| 4609 | if (j->ex.bytes) |
| 4610 | mask |= POLLPRI; |
| 4611 | return mask; |
| 4612 | } |
| 4613 | |
| 4614 | static int ixj_play_tone(IXJ *j, char tone) |
| 4615 | { |
| 4616 | if (!j->tone_state) { |
| 4617 | if(ixjdebug & 0x0002) { |
| 4618 | printk("IXJ %d starting tone %d at %ld\n", j->board, tone, jiffies); |
| 4619 | } |
| 4620 | if (j->dsp.low == 0x20) { |
| 4621 | idle(j); |
| 4622 | } |
| 4623 | j->tone_start_jif = jiffies; |
| 4624 | |
| 4625 | j->tone_state = 1; |
| 4626 | } |
| 4627 | |
| 4628 | j->tone_index = tone; |
| 4629 | if (ixj_WriteDSPCommand(0x6000 + j->tone_index, j)) |
| 4630 | return -1; |
| 4631 | |
| 4632 | return 0; |
| 4633 | } |
| 4634 | |
| 4635 | static int ixj_set_tone_on(unsigned short arg, IXJ *j) |
| 4636 | { |
| 4637 | j->tone_on_time = arg; |
| 4638 | |
| 4639 | if (ixj_WriteDSPCommand(0x6E04, j)) /* Set Tone On Period */ |
| 4640 | |
| 4641 | return -1; |
| 4642 | |
| 4643 | if (ixj_WriteDSPCommand(arg, j)) |
| 4644 | return -1; |
| 4645 | |
| 4646 | return 0; |
| 4647 | } |
| 4648 | |
| 4649 | static int SCI_WaitHighSCI(IXJ *j) |
| 4650 | { |
| 4651 | int cnt; |
| 4652 | |
| 4653 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 4654 | if (!j->pld_scrr.bits.sci) { |
| 4655 | for (cnt = 0; cnt < 10; cnt++) { |
| 4656 | udelay(32); |
| 4657 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 4658 | |
| 4659 | if ((j->pld_scrr.bits.sci)) |
| 4660 | return 1; |
| 4661 | } |
| 4662 | if (ixjdebug & 0x0001) |
| 4663 | printk(KERN_INFO "SCI Wait High failed %x\n", j->pld_scrr.byte); |
| 4664 | return 0; |
| 4665 | } else |
| 4666 | return 1; |
| 4667 | } |
| 4668 | |
| 4669 | static int SCI_WaitLowSCI(IXJ *j) |
| 4670 | { |
| 4671 | int cnt; |
| 4672 | |
| 4673 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 4674 | if (j->pld_scrr.bits.sci) { |
| 4675 | for (cnt = 0; cnt < 10; cnt++) { |
| 4676 | udelay(32); |
| 4677 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 4678 | |
| 4679 | if (!(j->pld_scrr.bits.sci)) |
| 4680 | return 1; |
| 4681 | } |
| 4682 | if (ixjdebug & 0x0001) |
| 4683 | printk(KERN_INFO "SCI Wait Low failed %x\n", j->pld_scrr.byte); |
| 4684 | return 0; |
| 4685 | } else |
| 4686 | return 1; |
| 4687 | } |
| 4688 | |
| 4689 | static int SCI_Control(IXJ *j, int control) |
| 4690 | { |
| 4691 | switch (control) { |
| 4692 | case SCI_End: |
| 4693 | j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */ |
| 4694 | |
| 4695 | j->pld_scrw.bits.c1 = 0; /* to no selection */ |
| 4696 | |
| 4697 | break; |
| 4698 | case SCI_Enable_DAA: |
| 4699 | j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */ |
| 4700 | |
| 4701 | j->pld_scrw.bits.c1 = 0; /* to write to DAA */ |
| 4702 | |
| 4703 | break; |
| 4704 | case SCI_Enable_Mixer: |
| 4705 | j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */ |
| 4706 | |
| 4707 | j->pld_scrw.bits.c1 = 1; /* to write to mixer */ |
| 4708 | |
| 4709 | break; |
| 4710 | case SCI_Enable_EEPROM: |
| 4711 | j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */ |
| 4712 | |
| 4713 | j->pld_scrw.bits.c1 = 1; /* to write to EEPROM */ |
| 4714 | |
| 4715 | break; |
| 4716 | default: |
| 4717 | return 0; |
| 4718 | break; |
| 4719 | } |
| 4720 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 4721 | |
| 4722 | switch (control) { |
| 4723 | case SCI_End: |
| 4724 | return 1; |
| 4725 | break; |
| 4726 | case SCI_Enable_DAA: |
| 4727 | case SCI_Enable_Mixer: |
| 4728 | case SCI_Enable_EEPROM: |
| 4729 | if (!SCI_WaitHighSCI(j)) |
| 4730 | return 0; |
| 4731 | break; |
| 4732 | default: |
| 4733 | return 0; |
| 4734 | break; |
| 4735 | } |
| 4736 | return 1; |
| 4737 | } |
| 4738 | |
| 4739 | static int SCI_Prepare(IXJ *j) |
| 4740 | { |
| 4741 | if (!SCI_Control(j, SCI_End)) |
| 4742 | return 0; |
| 4743 | |
| 4744 | if (!SCI_WaitLowSCI(j)) |
| 4745 | return 0; |
| 4746 | |
| 4747 | return 1; |
| 4748 | } |
| 4749 | |
| 4750 | static int ixj_get_mixer(long val, IXJ *j) |
| 4751 | { |
| 4752 | int reg = (val & 0x1F00) >> 8; |
| 4753 | return j->mix.vol[reg]; |
| 4754 | } |
| 4755 | |
| 4756 | static int ixj_mixer(long val, IXJ *j) |
| 4757 | { |
| 4758 | BYTES bytes; |
| 4759 | |
| 4760 | bytes.high = (val & 0x1F00) >> 8; |
| 4761 | bytes.low = val & 0x00FF; |
| 4762 | |
| 4763 | /* save mixer value so we can get back later on */ |
| 4764 | j->mix.vol[bytes.high] = bytes.low; |
| 4765 | |
| 4766 | outb_p(bytes.high & 0x1F, j->XILINXbase + 0x03); /* Load Mixer Address */ |
| 4767 | |
| 4768 | outb_p(bytes.low, j->XILINXbase + 0x02); /* Load Mixer Data */ |
| 4769 | |
| 4770 | SCI_Control(j, SCI_Enable_Mixer); |
| 4771 | |
| 4772 | SCI_Control(j, SCI_End); |
| 4773 | |
| 4774 | return 0; |
| 4775 | } |
| 4776 | |
| 4777 | static int daa_load(BYTES * p_bytes, IXJ *j) |
| 4778 | { |
| 4779 | outb_p(p_bytes->high, j->XILINXbase + 0x03); |
| 4780 | outb_p(p_bytes->low, j->XILINXbase + 0x02); |
| 4781 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4782 | return 0; |
| 4783 | else |
| 4784 | return 1; |
| 4785 | } |
| 4786 | |
| 4787 | static int ixj_daa_cr4(IXJ *j, char reg) |
| 4788 | { |
| 4789 | BYTES bytes; |
| 4790 | |
| 4791 | switch (j->daa_mode) { |
| 4792 | case SOP_PU_SLEEP: |
| 4793 | bytes.high = 0x14; |
| 4794 | break; |
| 4795 | case SOP_PU_RINGING: |
| 4796 | bytes.high = 0x54; |
| 4797 | break; |
| 4798 | case SOP_PU_CONVERSATION: |
| 4799 | bytes.high = 0x94; |
| 4800 | break; |
| 4801 | case SOP_PU_PULSEDIALING: |
| 4802 | bytes.high = 0xD4; |
| 4803 | break; |
| 4804 | } |
| 4805 | |
| 4806 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = reg; |
| 4807 | |
| 4808 | switch (j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGX) { |
| 4809 | case 0: |
| 4810 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 0; |
| 4811 | break; |
| 4812 | case 1: |
| 4813 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 2; |
| 4814 | break; |
| 4815 | case 2: |
| 4816 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 1; |
| 4817 | break; |
| 4818 | case 3: |
| 4819 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 3; |
| 4820 | break; |
| 4821 | } |
| 4822 | |
| 4823 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg; |
| 4824 | |
| 4825 | if (!daa_load(&bytes, j)) |
| 4826 | return 0; |
| 4827 | |
| 4828 | if (!SCI_Prepare(j)) |
| 4829 | return 0; |
| 4830 | |
| 4831 | return 1; |
| 4832 | } |
| 4833 | |
| 4834 | static char daa_int_read(IXJ *j) |
| 4835 | { |
| 4836 | BYTES bytes; |
| 4837 | |
| 4838 | if (!SCI_Prepare(j)) |
| 4839 | return 0; |
| 4840 | |
| 4841 | bytes.high = 0x38; |
| 4842 | bytes.low = 0x00; |
| 4843 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4844 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4845 | |
| 4846 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4847 | return 0; |
| 4848 | |
| 4849 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 4850 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 4851 | if (bytes.low != ALISDAA_ID_BYTE) { |
| 4852 | if (ixjdebug & 0x0001) |
| 4853 | printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low); |
| 4854 | return 0; |
| 4855 | } |
| 4856 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4857 | return 0; |
| 4858 | if (!SCI_Control(j, SCI_End)) |
| 4859 | return 0; |
| 4860 | |
| 4861 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 4862 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 4863 | |
| 4864 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg = bytes.high; |
| 4865 | |
| 4866 | return 1; |
| 4867 | } |
| 4868 | |
| 4869 | static char daa_CR_read(IXJ *j, int cr) |
| 4870 | { |
| 4871 | IXJ_WORD wdata; |
| 4872 | BYTES bytes; |
| 4873 | |
| 4874 | if (!SCI_Prepare(j)) |
| 4875 | return 0; |
| 4876 | |
| 4877 | switch (j->daa_mode) { |
| 4878 | case SOP_PU_SLEEP: |
| 4879 | bytes.high = 0x30 + cr; |
| 4880 | break; |
| 4881 | case SOP_PU_RINGING: |
| 4882 | bytes.high = 0x70 + cr; |
| 4883 | break; |
| 4884 | case SOP_PU_CONVERSATION: |
| 4885 | bytes.high = 0xB0 + cr; |
| 4886 | break; |
| 4887 | case SOP_PU_PULSEDIALING: |
| 4888 | bytes.high = 0xF0 + cr; |
| 4889 | break; |
| 4890 | } |
| 4891 | |
| 4892 | bytes.low = 0x00; |
| 4893 | |
| 4894 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4895 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4896 | |
| 4897 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4898 | return 0; |
| 4899 | |
| 4900 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 4901 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 4902 | if (bytes.low != ALISDAA_ID_BYTE) { |
| 4903 | if (ixjdebug & 0x0001) |
| 4904 | printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low); |
| 4905 | return 0; |
| 4906 | } |
| 4907 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4908 | return 0; |
| 4909 | if (!SCI_Control(j, SCI_End)) |
| 4910 | return 0; |
| 4911 | |
| 4912 | wdata.word = inw_p(j->XILINXbase + 0x02); |
| 4913 | |
| 4914 | switch(cr){ |
| 4915 | case 5: |
| 4916 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = wdata.bytes.high; |
| 4917 | break; |
| 4918 | case 4: |
| 4919 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = wdata.bytes.high; |
| 4920 | break; |
| 4921 | case 3: |
| 4922 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = wdata.bytes.high; |
| 4923 | break; |
| 4924 | case 2: |
| 4925 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = wdata.bytes.high; |
| 4926 | break; |
| 4927 | case 1: |
| 4928 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = wdata.bytes.high; |
| 4929 | break; |
| 4930 | case 0: |
| 4931 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = wdata.bytes.high; |
| 4932 | break; |
| 4933 | default: |
| 4934 | return 0; |
| 4935 | } |
| 4936 | return 1; |
| 4937 | } |
| 4938 | |
| 4939 | static int ixj_daa_cid_reset(IXJ *j) |
| 4940 | { |
| 4941 | int i; |
| 4942 | BYTES bytes; |
| 4943 | |
| 4944 | if (ixjdebug & 0x0002) |
| 4945 | printk("DAA Clearing CID ram\n"); |
| 4946 | |
| 4947 | if (!SCI_Prepare(j)) |
| 4948 | return 0; |
| 4949 | |
| 4950 | bytes.high = 0x58; |
| 4951 | bytes.low = 0x00; |
| 4952 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4953 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4954 | |
| 4955 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4956 | return 0; |
| 4957 | |
| 4958 | if (!SCI_WaitHighSCI(j)) |
| 4959 | return 0; |
| 4960 | |
| 4961 | for (i = 0; i < ALISDAA_CALLERID_SIZE - 1; i += 2) { |
| 4962 | bytes.high = bytes.low = 0x00; |
| 4963 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4964 | |
| 4965 | if (i < ALISDAA_CALLERID_SIZE - 1) |
| 4966 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4967 | |
| 4968 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4969 | return 0; |
| 4970 | |
| 4971 | if (!SCI_WaitHighSCI(j)) |
| 4972 | return 0; |
| 4973 | |
| 4974 | } |
| 4975 | |
| 4976 | if (!SCI_Control(j, SCI_End)) |
| 4977 | return 0; |
| 4978 | |
| 4979 | if (ixjdebug & 0x0002) |
| 4980 | printk("DAA CID ram cleared\n"); |
| 4981 | |
| 4982 | return 1; |
| 4983 | } |
| 4984 | |
| 4985 | static int ixj_daa_cid_read(IXJ *j) |
| 4986 | { |
| 4987 | int i; |
| 4988 | BYTES bytes; |
| 4989 | char CID[ALISDAA_CALLERID_SIZE], mContinue; |
| 4990 | char *pIn, *pOut; |
| 4991 | |
| 4992 | if (!SCI_Prepare(j)) |
| 4993 | return 0; |
| 4994 | |
| 4995 | bytes.high = 0x78; |
| 4996 | bytes.low = 0x00; |
| 4997 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4998 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4999 | |
| 5000 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 5001 | return 0; |
| 5002 | |
| 5003 | if (!SCI_WaitHighSCI(j)) |
| 5004 | return 0; |
| 5005 | |
| 5006 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 5007 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 5008 | if (bytes.low != ALISDAA_ID_BYTE) { |
| 5009 | if (ixjdebug & 0x0001) |
| 5010 | printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low); |
| 5011 | return 0; |
| 5012 | } |
| 5013 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i += 2) { |
| 5014 | bytes.high = bytes.low = 0x00; |
| 5015 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 5016 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 5017 | |
| 5018 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 5019 | return 0; |
| 5020 | |
| 5021 | if (!SCI_WaitHighSCI(j)) |
| 5022 | return 0; |
| 5023 | |
| 5024 | CID[i + 0] = inb_p(j->XILINXbase + 0x03); |
| 5025 | CID[i + 1] = inb_p(j->XILINXbase + 0x02); |
| 5026 | } |
| 5027 | |
| 5028 | if (!SCI_Control(j, SCI_End)) |
| 5029 | return 0; |
| 5030 | |
| 5031 | pIn = CID; |
| 5032 | pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID; |
| 5033 | mContinue = 1; |
| 5034 | while (mContinue) { |
| 5035 | if ((pIn[1] & 0x03) == 0x01) { |
| 5036 | pOut[0] = pIn[0]; |
| 5037 | } |
| 5038 | if ((pIn[2] & 0x0c) == 0x04) { |
| 5039 | pOut[1] = ((pIn[2] & 0x03) << 6) | ((pIn[1] & 0xfc) >> 2); |
| 5040 | } |
| 5041 | if ((pIn[3] & 0x30) == 0x10) { |
| 5042 | pOut[2] = ((pIn[3] & 0x0f) << 4) | ((pIn[2] & 0xf0) >> 4); |
| 5043 | } |
| 5044 | if ((pIn[4] & 0xc0) == 0x40) { |
| 5045 | pOut[3] = ((pIn[4] & 0x3f) << 2) | ((pIn[3] & 0xc0) >> 6); |
| 5046 | } else { |
| 5047 | mContinue = FALSE; |
| 5048 | } |
| 5049 | pIn += 5, pOut += 4; |
| 5050 | } |
| 5051 | memset(&j->cid, 0, sizeof(PHONE_CID)); |
| 5052 | pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID; |
| 5053 | pOut += 4; |
| 5054 | strncpy(j->cid.month, pOut, 2); |
| 5055 | pOut += 2; |
| 5056 | strncpy(j->cid.day, pOut, 2); |
| 5057 | pOut += 2; |
| 5058 | strncpy(j->cid.hour, pOut, 2); |
| 5059 | pOut += 2; |
| 5060 | strncpy(j->cid.min, pOut, 2); |
| 5061 | pOut += 3; |
| 5062 | j->cid.numlen = *pOut; |
| 5063 | pOut += 1; |
| 5064 | strncpy(j->cid.number, pOut, j->cid.numlen); |
| 5065 | pOut += j->cid.numlen + 1; |
| 5066 | j->cid.namelen = *pOut; |
| 5067 | pOut += 1; |
| 5068 | strncpy(j->cid.name, pOut, j->cid.namelen); |
| 5069 | |
| 5070 | ixj_daa_cid_reset(j); |
| 5071 | return 1; |
| 5072 | } |
| 5073 | |
| 5074 | static char daa_get_version(IXJ *j) |
| 5075 | { |
| 5076 | BYTES bytes; |
| 5077 | |
| 5078 | if (!SCI_Prepare(j)) |
| 5079 | return 0; |
| 5080 | |
| 5081 | bytes.high = 0x35; |
| 5082 | bytes.low = 0x00; |
| 5083 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 5084 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 5085 | |
| 5086 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 5087 | return 0; |
| 5088 | |
| 5089 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 5090 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 5091 | if (bytes.low != ALISDAA_ID_BYTE) { |
| 5092 | if (ixjdebug & 0x0001) |
| 5093 | printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low); |
| 5094 | return 0; |
| 5095 | } |
| 5096 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 5097 | return 0; |
| 5098 | |
| 5099 | if (!SCI_Control(j, SCI_End)) |
| 5100 | return 0; |
| 5101 | |
| 5102 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 5103 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 5104 | if (ixjdebug & 0x0002) |
| 5105 | printk("DAA CR5 Byte high = 0x%x low = 0x%x\n", bytes.high, bytes.low); |
| 5106 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = bytes.high; |
| 5107 | return bytes.high; |
| 5108 | } |
| 5109 | |
| 5110 | static int daa_set_mode(IXJ *j, int mode) |
| 5111 | { |
| 5112 | /* NOTE: |
| 5113 | The DAA *MUST* be in the conversation mode if the |
| 5114 | PSTN line is to be seized (PSTN line off-hook). |
| 5115 | Taking the PSTN line off-hook while the DAA is in |
| 5116 | a mode other than conversation mode will cause a |
| 5117 | hardware failure of the ALIS-A part. |
| 5118 | |
| 5119 | NOTE: |
| 5120 | The DAA can only go to SLEEP, RINGING or PULSEDIALING modes |
| 5121 | if the PSTN line is on-hook. Failure to have the PSTN line |
| 5122 | in the on-hook state WILL CAUSE A HARDWARE FAILURE OF THE |
| 5123 | ALIS-A part. |
| 5124 | */ |
| 5125 | |
| 5126 | BYTES bytes; |
| 5127 | |
| 5128 | j->flags.pstn_rmr = 0; |
| 5129 | |
| 5130 | if (!SCI_Prepare(j)) |
| 5131 | return 0; |
| 5132 | |
| 5133 | switch (mode) { |
| 5134 | case SOP_PU_RESET: |
| 5135 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 5136 | |
| 5137 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5138 | j->pld_slicw.bits.rly2 = 0; |
| 5139 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5140 | bytes.high = 0x10; |
| 5141 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5142 | daa_load(&bytes, j); |
| 5143 | if (!SCI_Prepare(j)) |
| 5144 | return 0; |
| 5145 | |
| 5146 | j->daa_mode = SOP_PU_SLEEP; |
| 5147 | break; |
| 5148 | case SOP_PU_SLEEP: |
| 5149 | if(j->daa_mode == SOP_PU_SLEEP) |
| 5150 | { |
| 5151 | break; |
| 5152 | } |
| 5153 | if (ixjdebug & 0x0008) |
| 5154 | printk(KERN_INFO "phone DAA: SOP_PU_SLEEP at %ld\n", jiffies); |
| 5155 | /* if(j->daa_mode == SOP_PU_CONVERSATION) */ |
| 5156 | { |
| 5157 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 5158 | |
| 5159 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5160 | j->pld_slicw.bits.rly2 = 0; |
| 5161 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5162 | bytes.high = 0x10; |
| 5163 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5164 | daa_load(&bytes, j); |
| 5165 | if (!SCI_Prepare(j)) |
| 5166 | return 0; |
| 5167 | } |
| 5168 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 5169 | |
| 5170 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5171 | j->pld_slicw.bits.rly2 = 0; |
| 5172 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5173 | bytes.high = 0x10; |
| 5174 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5175 | daa_load(&bytes, j); |
| 5176 | if (!SCI_Prepare(j)) |
| 5177 | return 0; |
| 5178 | |
| 5179 | j->daa_mode = SOP_PU_SLEEP; |
| 5180 | j->flags.pstn_ringing = 0; |
| 5181 | j->ex.bits.pstn_ring = 0; |
| 5182 | j->pstn_sleeptil = jiffies + (hertz / 4); |
| 5183 | wake_up_interruptible(&j->read_q); /* Wake any blocked readers */ |
| 5184 | wake_up_interruptible(&j->write_q); /* Wake any blocked writers */ |
| 5185 | wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */ |
| 5186 | break; |
| 5187 | case SOP_PU_RINGING: |
| 5188 | if (ixjdebug & 0x0008) |
| 5189 | printk(KERN_INFO "phone DAA: SOP_PU_RINGING at %ld\n", jiffies); |
| 5190 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 5191 | |
| 5192 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5193 | j->pld_slicw.bits.rly2 = 0; |
| 5194 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5195 | bytes.high = 0x50; |
| 5196 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5197 | daa_load(&bytes, j); |
| 5198 | if (!SCI_Prepare(j)) |
| 5199 | return 0; |
| 5200 | j->daa_mode = SOP_PU_RINGING; |
| 5201 | break; |
| 5202 | case SOP_PU_CONVERSATION: |
| 5203 | if (ixjdebug & 0x0008) |
| 5204 | printk(KERN_INFO "phone DAA: SOP_PU_CONVERSATION at %ld\n", jiffies); |
| 5205 | bytes.high = 0x90; |
| 5206 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5207 | daa_load(&bytes, j); |
| 5208 | if (!SCI_Prepare(j)) |
| 5209 | return 0; |
| 5210 | j->pld_slicw.bits.rly2 = 1; |
| 5211 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5212 | j->pld_scrw.bits.daafsyncen = 1; /* Turn on DAA Frame Sync */ |
| 5213 | |
| 5214 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5215 | j->daa_mode = SOP_PU_CONVERSATION; |
| 5216 | j->flags.pstn_ringing = 0; |
| 5217 | j->ex.bits.pstn_ring = 0; |
| 5218 | j->pstn_sleeptil = jiffies; |
| 5219 | j->pstn_ring_start = j->pstn_ring_stop = j->pstn_ring_int = 0; |
| 5220 | break; |
| 5221 | case SOP_PU_PULSEDIALING: |
| 5222 | if (ixjdebug & 0x0008) |
| 5223 | printk(KERN_INFO "phone DAA: SOP_PU_PULSEDIALING at %ld\n", jiffies); |
| 5224 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 5225 | |
| 5226 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5227 | j->pld_slicw.bits.rly2 = 0; |
| 5228 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5229 | bytes.high = 0xD0; |
| 5230 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5231 | daa_load(&bytes, j); |
| 5232 | if (!SCI_Prepare(j)) |
| 5233 | return 0; |
| 5234 | j->daa_mode = SOP_PU_PULSEDIALING; |
| 5235 | break; |
| 5236 | default: |
| 5237 | break; |
| 5238 | } |
| 5239 | return 1; |
| 5240 | } |
| 5241 | |
| 5242 | static int ixj_daa_write(IXJ *j) |
| 5243 | { |
| 5244 | BYTES bytes; |
| 5245 | |
| 5246 | j->flags.pstncheck = 1; |
| 5247 | |
| 5248 | daa_set_mode(j, SOP_PU_SLEEP); |
| 5249 | |
| 5250 | if (!SCI_Prepare(j)) |
| 5251 | return 0; |
| 5252 | |
| 5253 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5254 | |
| 5255 | bytes.high = 0x14; |
| 5256 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg; |
| 5257 | if (!daa_load(&bytes, j)) |
| 5258 | return 0; |
| 5259 | |
| 5260 | bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg; |
| 5261 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg; |
| 5262 | if (!daa_load(&bytes, j)) |
| 5263 | return 0; |
| 5264 | |
| 5265 | bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg; |
| 5266 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5267 | if (!daa_load(&bytes, j)) |
| 5268 | return 0; |
| 5269 | |
| 5270 | if (!SCI_Prepare(j)) |
| 5271 | return 0; |
| 5272 | |
| 5273 | bytes.high = 0x1F; |
| 5274 | bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg; |
| 5275 | if (!daa_load(&bytes, j)) |
| 5276 | return 0; |
| 5277 | |
| 5278 | bytes.high = j->m_DAAShadowRegs.XOP_xr6_W.reg; |
| 5279 | bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg; |
| 5280 | if (!daa_load(&bytes, j)) |
| 5281 | return 0; |
| 5282 | |
| 5283 | bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg; |
| 5284 | bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg; |
| 5285 | if (!daa_load(&bytes, j)) |
| 5286 | return 0; |
| 5287 | |
| 5288 | bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg; |
| 5289 | bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg; |
| 5290 | if (!daa_load(&bytes, j)) |
| 5291 | return 0; |
| 5292 | |
| 5293 | bytes.high = j->m_DAAShadowRegs.XOP_xr0_W.reg; |
| 5294 | bytes.low = 0x00; |
| 5295 | if (!daa_load(&bytes, j)) |
| 5296 | return 0; |
| 5297 | |
| 5298 | if (!SCI_Prepare(j)) |
| 5299 | return 0; |
| 5300 | |
| 5301 | bytes.high = 0x00; |
| 5302 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7]; |
| 5303 | if (!daa_load(&bytes, j)) |
| 5304 | return 0; |
| 5305 | |
| 5306 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6]; |
| 5307 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5]; |
| 5308 | if (!daa_load(&bytes, j)) |
| 5309 | return 0; |
| 5310 | |
| 5311 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4]; |
| 5312 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3]; |
| 5313 | if (!daa_load(&bytes, j)) |
| 5314 | return 0; |
| 5315 | |
| 5316 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2]; |
| 5317 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1]; |
| 5318 | if (!daa_load(&bytes, j)) |
| 5319 | return 0; |
| 5320 | |
| 5321 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0]; |
| 5322 | bytes.low = 0x00; |
| 5323 | if (!daa_load(&bytes, j)) |
| 5324 | return 0; |
| 5325 | |
| 5326 | if (!SCI_Control(j, SCI_End)) |
| 5327 | return 0; |
| 5328 | if (!SCI_WaitLowSCI(j)) |
| 5329 | return 0; |
| 5330 | |
| 5331 | bytes.high = 0x01; |
| 5332 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7]; |
| 5333 | if (!daa_load(&bytes, j)) |
| 5334 | return 0; |
| 5335 | |
| 5336 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6]; |
| 5337 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5]; |
| 5338 | if (!daa_load(&bytes, j)) |
| 5339 | return 0; |
| 5340 | |
| 5341 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4]; |
| 5342 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3]; |
| 5343 | if (!daa_load(&bytes, j)) |
| 5344 | return 0; |
| 5345 | |
| 5346 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2]; |
| 5347 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1]; |
| 5348 | if (!daa_load(&bytes, j)) |
| 5349 | return 0; |
| 5350 | |
| 5351 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0]; |
| 5352 | bytes.low = 0x00; |
| 5353 | if (!daa_load(&bytes, j)) |
| 5354 | return 0; |
| 5355 | |
| 5356 | if (!SCI_Control(j, SCI_End)) |
| 5357 | return 0; |
| 5358 | if (!SCI_WaitLowSCI(j)) |
| 5359 | return 0; |
| 5360 | |
| 5361 | bytes.high = 0x02; |
| 5362 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7]; |
| 5363 | if (!daa_load(&bytes, j)) |
| 5364 | return 0; |
| 5365 | |
| 5366 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6]; |
| 5367 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5]; |
| 5368 | if (!daa_load(&bytes, j)) |
| 5369 | return 0; |
| 5370 | |
| 5371 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4]; |
| 5372 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3]; |
| 5373 | if (!daa_load(&bytes, j)) |
| 5374 | return 0; |
| 5375 | |
| 5376 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2]; |
| 5377 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1]; |
| 5378 | if (!daa_load(&bytes, j)) |
| 5379 | return 0; |
| 5380 | |
| 5381 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0]; |
| 5382 | bytes.low = 0x00; |
| 5383 | if (!daa_load(&bytes, j)) |
| 5384 | return 0; |
| 5385 | |
| 5386 | if (!SCI_Control(j, SCI_End)) |
| 5387 | return 0; |
| 5388 | if (!SCI_WaitLowSCI(j)) |
| 5389 | return 0; |
| 5390 | |
| 5391 | bytes.high = 0x03; |
| 5392 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7]; |
| 5393 | if (!daa_load(&bytes, j)) |
| 5394 | return 0; |
| 5395 | |
| 5396 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6]; |
| 5397 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5]; |
| 5398 | if (!daa_load(&bytes, j)) |
| 5399 | return 0; |
| 5400 | |
| 5401 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4]; |
| 5402 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3]; |
| 5403 | if (!daa_load(&bytes, j)) |
| 5404 | return 0; |
| 5405 | |
| 5406 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2]; |
| 5407 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1]; |
| 5408 | if (!daa_load(&bytes, j)) |
| 5409 | return 0; |
| 5410 | |
| 5411 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0]; |
| 5412 | bytes.low = 0x00; |
| 5413 | if (!daa_load(&bytes, j)) |
| 5414 | return 0; |
| 5415 | |
| 5416 | if (!SCI_Control(j, SCI_End)) |
| 5417 | return 0; |
| 5418 | if (!SCI_WaitLowSCI(j)) |
| 5419 | return 0; |
| 5420 | |
| 5421 | bytes.high = 0x04; |
| 5422 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7]; |
| 5423 | if (!daa_load(&bytes, j)) |
| 5424 | return 0; |
| 5425 | |
| 5426 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6]; |
| 5427 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5]; |
| 5428 | if (!daa_load(&bytes, j)) |
| 5429 | return 0; |
| 5430 | |
| 5431 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4]; |
| 5432 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3]; |
| 5433 | if (!daa_load(&bytes, j)) |
| 5434 | return 0; |
| 5435 | |
| 5436 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2]; |
| 5437 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1]; |
| 5438 | if (!daa_load(&bytes, j)) |
| 5439 | return 0; |
| 5440 | |
| 5441 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0]; |
| 5442 | bytes.low = 0x00; |
| 5443 | if (!daa_load(&bytes, j)) |
| 5444 | return 0; |
| 5445 | |
| 5446 | if (!SCI_Control(j, SCI_End)) |
| 5447 | return 0; |
| 5448 | if (!SCI_WaitLowSCI(j)) |
| 5449 | return 0; |
| 5450 | |
| 5451 | bytes.high = 0x05; |
| 5452 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7]; |
| 5453 | if (!daa_load(&bytes, j)) |
| 5454 | return 0; |
| 5455 | |
| 5456 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6]; |
| 5457 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5]; |
| 5458 | if (!daa_load(&bytes, j)) |
| 5459 | return 0; |
| 5460 | |
| 5461 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4]; |
| 5462 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3]; |
| 5463 | if (!daa_load(&bytes, j)) |
| 5464 | return 0; |
| 5465 | |
| 5466 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2]; |
| 5467 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1]; |
| 5468 | if (!daa_load(&bytes, j)) |
| 5469 | return 0; |
| 5470 | |
| 5471 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0]; |
| 5472 | bytes.low = 0x00; |
| 5473 | if (!daa_load(&bytes, j)) |
| 5474 | return 0; |
| 5475 | |
| 5476 | if (!SCI_Control(j, SCI_End)) |
| 5477 | return 0; |
| 5478 | if (!SCI_WaitLowSCI(j)) |
| 5479 | return 0; |
| 5480 | |
| 5481 | bytes.high = 0x06; |
| 5482 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7]; |
| 5483 | if (!daa_load(&bytes, j)) |
| 5484 | return 0; |
| 5485 | |
| 5486 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6]; |
| 5487 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5]; |
| 5488 | if (!daa_load(&bytes, j)) |
| 5489 | return 0; |
| 5490 | |
| 5491 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4]; |
| 5492 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3]; |
| 5493 | if (!daa_load(&bytes, j)) |
| 5494 | return 0; |
| 5495 | |
| 5496 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2]; |
| 5497 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1]; |
| 5498 | if (!daa_load(&bytes, j)) |
| 5499 | return 0; |
| 5500 | |
| 5501 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0]; |
| 5502 | bytes.low = 0x00; |
| 5503 | if (!daa_load(&bytes, j)) |
| 5504 | return 0; |
| 5505 | |
| 5506 | if (!SCI_Control(j, SCI_End)) |
| 5507 | return 0; |
| 5508 | if (!SCI_WaitLowSCI(j)) |
| 5509 | return 0; |
| 5510 | |
| 5511 | bytes.high = 0x07; |
| 5512 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7]; |
| 5513 | if (!daa_load(&bytes, j)) |
| 5514 | return 0; |
| 5515 | |
| 5516 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6]; |
| 5517 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5]; |
| 5518 | if (!daa_load(&bytes, j)) |
| 5519 | return 0; |
| 5520 | |
| 5521 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4]; |
| 5522 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3]; |
| 5523 | if (!daa_load(&bytes, j)) |
| 5524 | return 0; |
| 5525 | |
| 5526 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2]; |
| 5527 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1]; |
| 5528 | if (!daa_load(&bytes, j)) |
| 5529 | return 0; |
| 5530 | |
| 5531 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0]; |
| 5532 | bytes.low = 0x00; |
| 5533 | if (!daa_load(&bytes, j)) |
| 5534 | return 0; |
| 5535 | |
| 5536 | if (!SCI_Control(j, SCI_End)) |
| 5537 | return 0; |
| 5538 | if (!SCI_WaitLowSCI(j)) |
| 5539 | return 0; |
| 5540 | |
| 5541 | bytes.high = 0x08; |
| 5542 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7]; |
| 5543 | if (!daa_load(&bytes, j)) |
| 5544 | return 0; |
| 5545 | |
| 5546 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6]; |
| 5547 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5]; |
| 5548 | if (!daa_load(&bytes, j)) |
| 5549 | return 0; |
| 5550 | |
| 5551 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4]; |
| 5552 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3]; |
| 5553 | if (!daa_load(&bytes, j)) |
| 5554 | return 0; |
| 5555 | |
| 5556 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2]; |
| 5557 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1]; |
| 5558 | if (!daa_load(&bytes, j)) |
| 5559 | return 0; |
| 5560 | |
| 5561 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0]; |
| 5562 | bytes.low = 0x00; |
| 5563 | if (!daa_load(&bytes, j)) |
| 5564 | return 0; |
| 5565 | |
| 5566 | if (!SCI_Control(j, SCI_End)) |
| 5567 | return 0; |
| 5568 | if (!SCI_WaitLowSCI(j)) |
| 5569 | return 0; |
| 5570 | |
| 5571 | bytes.high = 0x09; |
| 5572 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3]; |
| 5573 | if (!daa_load(&bytes, j)) |
| 5574 | return 0; |
| 5575 | |
| 5576 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2]; |
| 5577 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1]; |
| 5578 | if (!daa_load(&bytes, j)) |
| 5579 | return 0; |
| 5580 | |
| 5581 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0]; |
| 5582 | bytes.low = 0x00; |
| 5583 | if (!daa_load(&bytes, j)) |
| 5584 | return 0; |
| 5585 | |
| 5586 | if (!SCI_Control(j, SCI_End)) |
| 5587 | return 0; |
| 5588 | if (!SCI_WaitLowSCI(j)) |
| 5589 | return 0; |
| 5590 | |
| 5591 | bytes.high = 0x0A; |
| 5592 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3]; |
| 5593 | if (!daa_load(&bytes, j)) |
| 5594 | return 0; |
| 5595 | |
| 5596 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2]; |
| 5597 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1]; |
| 5598 | if (!daa_load(&bytes, j)) |
| 5599 | return 0; |
| 5600 | |
| 5601 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0]; |
| 5602 | bytes.low = 0x00; |
| 5603 | if (!daa_load(&bytes, j)) |
| 5604 | return 0; |
| 5605 | |
| 5606 | if (!SCI_Control(j, SCI_End)) |
| 5607 | return 0; |
| 5608 | if (!SCI_WaitLowSCI(j)) |
| 5609 | return 0; |
| 5610 | |
| 5611 | bytes.high = 0x0B; |
| 5612 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3]; |
| 5613 | if (!daa_load(&bytes, j)) |
| 5614 | return 0; |
| 5615 | |
| 5616 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2]; |
| 5617 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1]; |
| 5618 | if (!daa_load(&bytes, j)) |
| 5619 | return 0; |
| 5620 | |
| 5621 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0]; |
| 5622 | bytes.low = 0x00; |
| 5623 | if (!daa_load(&bytes, j)) |
| 5624 | return 0; |
| 5625 | |
| 5626 | if (!SCI_Control(j, SCI_End)) |
| 5627 | return 0; |
| 5628 | if (!SCI_WaitLowSCI(j)) |
| 5629 | return 0; |
| 5630 | |
| 5631 | bytes.high = 0x0C; |
| 5632 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3]; |
| 5633 | if (!daa_load(&bytes, j)) |
| 5634 | return 0; |
| 5635 | |
| 5636 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2]; |
| 5637 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1]; |
| 5638 | if (!daa_load(&bytes, j)) |
| 5639 | return 0; |
| 5640 | |
| 5641 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0]; |
| 5642 | bytes.low = 0x00; |
| 5643 | if (!daa_load(&bytes, j)) |
| 5644 | return 0; |
| 5645 | |
| 5646 | if (!SCI_Control(j, SCI_End)) |
| 5647 | return 0; |
| 5648 | if (!SCI_WaitLowSCI(j)) |
| 5649 | return 0; |
| 5650 | |
| 5651 | bytes.high = 0x0D; |
| 5652 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3]; |
| 5653 | if (!daa_load(&bytes, j)) |
| 5654 | return 0; |
| 5655 | |
| 5656 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2]; |
| 5657 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1]; |
| 5658 | if (!daa_load(&bytes, j)) |
| 5659 | return 0; |
| 5660 | |
| 5661 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0]; |
| 5662 | bytes.low = 0x00; |
| 5663 | if (!daa_load(&bytes, j)) |
| 5664 | return 0; |
| 5665 | |
| 5666 | if (!SCI_Control(j, SCI_End)) |
| 5667 | return 0; |
| 5668 | if (!SCI_WaitLowSCI(j)) |
| 5669 | return 0; |
| 5670 | |
| 5671 | bytes.high = 0x0E; |
| 5672 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7]; |
| 5673 | if (!daa_load(&bytes, j)) |
| 5674 | return 0; |
| 5675 | |
| 5676 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6]; |
| 5677 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5]; |
| 5678 | if (!daa_load(&bytes, j)) |
| 5679 | return 0; |
| 5680 | |
| 5681 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4]; |
| 5682 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3]; |
| 5683 | if (!daa_load(&bytes, j)) |
| 5684 | return 0; |
| 5685 | |
| 5686 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2]; |
| 5687 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1]; |
| 5688 | if (!daa_load(&bytes, j)) |
| 5689 | return 0; |
| 5690 | |
| 5691 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0]; |
| 5692 | bytes.low = 0x00; |
| 5693 | if (!daa_load(&bytes, j)) |
| 5694 | return 0; |
| 5695 | |
| 5696 | if (!SCI_Control(j, SCI_End)) |
| 5697 | return 0; |
| 5698 | if (!SCI_WaitLowSCI(j)) |
| 5699 | return 0; |
| 5700 | |
| 5701 | bytes.high = 0x0F; |
| 5702 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7]; |
| 5703 | if (!daa_load(&bytes, j)) |
| 5704 | return 0; |
| 5705 | |
| 5706 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6]; |
| 5707 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5]; |
| 5708 | if (!daa_load(&bytes, j)) |
| 5709 | return 0; |
| 5710 | |
| 5711 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4]; |
| 5712 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3]; |
| 5713 | if (!daa_load(&bytes, j)) |
| 5714 | return 0; |
| 5715 | |
| 5716 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2]; |
| 5717 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1]; |
| 5718 | if (!daa_load(&bytes, j)) |
| 5719 | return 0; |
| 5720 | |
| 5721 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0]; |
| 5722 | bytes.low = 0x00; |
| 5723 | if (!daa_load(&bytes, j)) |
| 5724 | return 0; |
| 5725 | |
| 5726 | udelay(32); |
| 5727 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 5728 | if (!SCI_Control(j, SCI_End)) |
| 5729 | return 0; |
| 5730 | |
| 5731 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5732 | |
| 5733 | if (ixjdebug & 0x0002) |
| 5734 | printk("DAA Coefficients Loaded\n"); |
| 5735 | |
| 5736 | j->flags.pstncheck = 0; |
| 5737 | return 1; |
| 5738 | } |
| 5739 | |
| 5740 | int ixj_set_tone_off(unsigned short arg, IXJ *j) |
| 5741 | { |
| 5742 | j->tone_off_time = arg; |
| 5743 | if (ixj_WriteDSPCommand(0x6E05, j)) /* Set Tone Off Period */ |
| 5744 | |
| 5745 | return -1; |
| 5746 | if (ixj_WriteDSPCommand(arg, j)) |
| 5747 | return -1; |
| 5748 | return 0; |
| 5749 | } |
| 5750 | |
| 5751 | static int ixj_get_tone_on(IXJ *j) |
| 5752 | { |
| 5753 | if (ixj_WriteDSPCommand(0x6E06, j)) /* Get Tone On Period */ |
| 5754 | |
| 5755 | return -1; |
| 5756 | return 0; |
| 5757 | } |
| 5758 | |
| 5759 | static int ixj_get_tone_off(IXJ *j) |
| 5760 | { |
| 5761 | if (ixj_WriteDSPCommand(0x6E07, j)) /* Get Tone Off Period */ |
| 5762 | |
| 5763 | return -1; |
| 5764 | return 0; |
| 5765 | } |
| 5766 | |
| 5767 | static void ixj_busytone(IXJ *j) |
| 5768 | { |
| 5769 | j->flags.ringback = 0; |
| 5770 | j->flags.dialtone = 0; |
| 5771 | j->flags.busytone = 1; |
| 5772 | ixj_set_tone_on(0x07D0, j); |
| 5773 | ixj_set_tone_off(0x07D0, j); |
| 5774 | ixj_play_tone(j, 27); |
| 5775 | } |
| 5776 | |
| 5777 | static void ixj_dialtone(IXJ *j) |
| 5778 | { |
| 5779 | j->flags.ringback = 0; |
| 5780 | j->flags.dialtone = 1; |
| 5781 | j->flags.busytone = 0; |
| 5782 | if (j->dsp.low == 0x20) { |
| 5783 | return; |
| 5784 | } else { |
| 5785 | ixj_set_tone_on(0xFFFF, j); |
| 5786 | ixj_set_tone_off(0x0000, j); |
| 5787 | ixj_play_tone(j, 25); |
| 5788 | } |
| 5789 | } |
| 5790 | |
| 5791 | static void ixj_cpt_stop(IXJ *j) |
| 5792 | { |
| 5793 | if(j->tone_state || j->tone_cadence_state) |
| 5794 | { |
| 5795 | j->flags.dialtone = 0; |
| 5796 | j->flags.busytone = 0; |
| 5797 | j->flags.ringback = 0; |
| 5798 | ixj_set_tone_on(0x0001, j); |
| 5799 | ixj_set_tone_off(0x0000, j); |
| 5800 | ixj_play_tone(j, 0); |
| 5801 | j->tone_state = j->tone_cadence_state = 0; |
| 5802 | if (j->cadence_t) { |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 5803 | kfree(j->cadence_t->ce); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5804 | kfree(j->cadence_t); |
| 5805 | j->cadence_t = NULL; |
| 5806 | } |
| 5807 | } |
| 5808 | if (j->play_mode == -1 && j->rec_mode == -1) |
| 5809 | idle(j); |
| 5810 | if (j->play_mode != -1 && j->dsp.low == 0x20) |
| 5811 | ixj_play_start(j); |
| 5812 | if (j->rec_mode != -1 && j->dsp.low == 0x20) |
| 5813 | ixj_record_start(j); |
| 5814 | } |
| 5815 | |
| 5816 | static void ixj_ringback(IXJ *j) |
| 5817 | { |
| 5818 | j->flags.busytone = 0; |
| 5819 | j->flags.dialtone = 0; |
| 5820 | j->flags.ringback = 1; |
| 5821 | ixj_set_tone_on(0x0FA0, j); |
| 5822 | ixj_set_tone_off(0x2EE0, j); |
| 5823 | ixj_play_tone(j, 26); |
| 5824 | } |
| 5825 | |
| 5826 | static void ixj_testram(IXJ *j) |
| 5827 | { |
| 5828 | ixj_WriteDSPCommand(0x3001, j); /* Test External SRAM */ |
| 5829 | } |
| 5830 | |
| 5831 | static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp) |
| 5832 | { |
| 5833 | ixj_cadence *lcp; |
| 5834 | IXJ_CADENCE_ELEMENT __user *cep; |
| 5835 | IXJ_CADENCE_ELEMENT *lcep; |
| 5836 | IXJ_TONE ti; |
| 5837 | int err; |
| 5838 | |
| 5839 | lcp = kmalloc(sizeof(ixj_cadence), GFP_KERNEL); |
| 5840 | if (lcp == NULL) |
| 5841 | return -ENOMEM; |
| 5842 | |
| 5843 | err = -EFAULT; |
| 5844 | if (copy_from_user(&lcp->elements_used, |
| 5845 | &cp->elements_used, sizeof(int))) |
| 5846 | goto out; |
| 5847 | if (copy_from_user(&lcp->termination, |
| 5848 | &cp->termination, sizeof(IXJ_CADENCE_TERM))) |
| 5849 | goto out; |
| 5850 | if (get_user(cep, &cp->ce)) |
| 5851 | goto out; |
| 5852 | |
| 5853 | err = -EINVAL; |
| 5854 | if ((unsigned)lcp->elements_used >= ~0U/sizeof(IXJ_CADENCE_ELEMENT)) |
| 5855 | goto out; |
| 5856 | |
| 5857 | err = -ENOMEM; |
| 5858 | lcep = kmalloc(sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used, GFP_KERNEL); |
| 5859 | if (!lcep) |
| 5860 | goto out; |
| 5861 | |
| 5862 | err = -EFAULT; |
| 5863 | if (copy_from_user(lcep, cep, sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used)) |
| 5864 | goto out1; |
| 5865 | |
| 5866 | if (j->cadence_t) { |
| 5867 | kfree(j->cadence_t->ce); |
| 5868 | kfree(j->cadence_t); |
| 5869 | } |
| 5870 | lcp->ce = (void *) lcep; |
| 5871 | j->cadence_t = lcp; |
| 5872 | j->tone_cadence_state = 0; |
| 5873 | ixj_set_tone_on(lcp->ce[0].tone_on_time, j); |
| 5874 | ixj_set_tone_off(lcp->ce[0].tone_off_time, j); |
| 5875 | if (j->cadence_t->ce[j->tone_cadence_state].freq0) { |
| 5876 | ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index; |
| 5877 | ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0; |
| 5878 | ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0; |
| 5879 | ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1; |
| 5880 | ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1; |
| 5881 | ixj_init_tone(j, &ti); |
| 5882 | } |
| 5883 | ixj_play_tone(j, lcp->ce[0].index); |
| 5884 | return 1; |
| 5885 | out1: |
| 5886 | kfree(lcep); |
| 5887 | out: |
| 5888 | kfree(lcp); |
| 5889 | return err; |
| 5890 | } |
| 5891 | |
| 5892 | static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp) |
| 5893 | { |
| 5894 | IXJ_FILTER_CADENCE *lcp; |
| 5895 | lcp = kmalloc(sizeof(IXJ_FILTER_CADENCE), GFP_KERNEL); |
| 5896 | if (lcp == NULL) { |
| 5897 | if(ixjdebug & 0x0001) { |
| 5898 | printk(KERN_INFO "Could not allocate memory for cadence\n"); |
| 5899 | } |
| 5900 | return -ENOMEM; |
| 5901 | } |
| 5902 | if (copy_from_user(lcp, cp, sizeof(IXJ_FILTER_CADENCE))) { |
| 5903 | if(ixjdebug & 0x0001) { |
| 5904 | printk(KERN_INFO "Could not copy cadence to kernel\n"); |
| 5905 | } |
| 5906 | kfree(lcp); |
| 5907 | return -EFAULT; |
| 5908 | } |
| 5909 | if (lcp->filter > 5) { |
| 5910 | if(ixjdebug & 0x0001) { |
| 5911 | printk(KERN_INFO "Cadence out of range\n"); |
| 5912 | } |
| 5913 | kfree(lcp); |
| 5914 | return -1; |
| 5915 | } |
| 5916 | j->cadence_f[lcp->filter].state = 0; |
| 5917 | j->cadence_f[lcp->filter].enable = lcp->enable; |
| 5918 | j->filter_en[lcp->filter] = j->cadence_f[lcp->filter].en_filter = lcp->en_filter; |
| 5919 | j->cadence_f[lcp->filter].on1 = lcp->on1; |
| 5920 | j->cadence_f[lcp->filter].on1min = 0; |
| 5921 | j->cadence_f[lcp->filter].on1max = 0; |
| 5922 | j->cadence_f[lcp->filter].off1 = lcp->off1; |
| 5923 | j->cadence_f[lcp->filter].off1min = 0; |
| 5924 | j->cadence_f[lcp->filter].off1max = 0; |
| 5925 | j->cadence_f[lcp->filter].on2 = lcp->on2; |
| 5926 | j->cadence_f[lcp->filter].on2min = 0; |
| 5927 | j->cadence_f[lcp->filter].on2max = 0; |
| 5928 | j->cadence_f[lcp->filter].off2 = lcp->off2; |
| 5929 | j->cadence_f[lcp->filter].off2min = 0; |
| 5930 | j->cadence_f[lcp->filter].off2max = 0; |
| 5931 | j->cadence_f[lcp->filter].on3 = lcp->on3; |
| 5932 | j->cadence_f[lcp->filter].on3min = 0; |
| 5933 | j->cadence_f[lcp->filter].on3max = 0; |
| 5934 | j->cadence_f[lcp->filter].off3 = lcp->off3; |
| 5935 | j->cadence_f[lcp->filter].off3min = 0; |
| 5936 | j->cadence_f[lcp->filter].off3max = 0; |
| 5937 | if(ixjdebug & 0x0002) { |
| 5938 | printk(KERN_INFO "Cadence %d loaded\n", lcp->filter); |
| 5939 | } |
| 5940 | kfree(lcp); |
| 5941 | return 0; |
| 5942 | } |
| 5943 | |
| 5944 | static void add_caps(IXJ *j) |
| 5945 | { |
| 5946 | j->caps = 0; |
| 5947 | j->caplist[j->caps].cap = PHONE_VENDOR_QUICKNET; |
| 5948 | strcpy(j->caplist[j->caps].desc, "Quicknet Technologies, Inc. (www.quicknet.net)"); |
| 5949 | j->caplist[j->caps].captype = vendor; |
| 5950 | j->caplist[j->caps].handle = j->caps++; |
| 5951 | j->caplist[j->caps].captype = device; |
| 5952 | switch (j->cardtype) { |
| 5953 | case QTI_PHONEJACK: |
| 5954 | strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK"); |
| 5955 | break; |
| 5956 | case QTI_LINEJACK: |
| 5957 | strcpy(j->caplist[j->caps].desc, "Quicknet Internet LineJACK"); |
| 5958 | break; |
| 5959 | case QTI_PHONEJACK_LITE: |
| 5960 | strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK Lite"); |
| 5961 | break; |
| 5962 | case QTI_PHONEJACK_PCI: |
| 5963 | strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK PCI"); |
| 5964 | break; |
| 5965 | case QTI_PHONECARD: |
| 5966 | strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneCARD"); |
| 5967 | break; |
| 5968 | } |
| 5969 | j->caplist[j->caps].cap = j->cardtype; |
| 5970 | j->caplist[j->caps].handle = j->caps++; |
| 5971 | strcpy(j->caplist[j->caps].desc, "POTS"); |
| 5972 | j->caplist[j->caps].captype = port; |
| 5973 | j->caplist[j->caps].cap = pots; |
| 5974 | j->caplist[j->caps].handle = j->caps++; |
| 5975 | |
| 5976 | /* add devices that can do speaker/mic */ |
| 5977 | switch (j->cardtype) { |
| 5978 | case QTI_PHONEJACK: |
| 5979 | case QTI_LINEJACK: |
| 5980 | case QTI_PHONEJACK_PCI: |
| 5981 | case QTI_PHONECARD: |
| 5982 | strcpy(j->caplist[j->caps].desc, "SPEAKER"); |
| 5983 | j->caplist[j->caps].captype = port; |
| 5984 | j->caplist[j->caps].cap = speaker; |
| 5985 | j->caplist[j->caps].handle = j->caps++; |
| 5986 | default: |
| 5987 | break; |
| 5988 | } |
| 5989 | |
| 5990 | /* add devices that can do handset */ |
| 5991 | switch (j->cardtype) { |
| 5992 | case QTI_PHONEJACK: |
| 5993 | strcpy(j->caplist[j->caps].desc, "HANDSET"); |
| 5994 | j->caplist[j->caps].captype = port; |
| 5995 | j->caplist[j->caps].cap = handset; |
| 5996 | j->caplist[j->caps].handle = j->caps++; |
| 5997 | break; |
| 5998 | default: |
| 5999 | break; |
| 6000 | } |
| 6001 | |
| 6002 | /* add devices that can do PSTN */ |
| 6003 | switch (j->cardtype) { |
| 6004 | case QTI_LINEJACK: |
| 6005 | strcpy(j->caplist[j->caps].desc, "PSTN"); |
| 6006 | j->caplist[j->caps].captype = port; |
| 6007 | j->caplist[j->caps].cap = pstn; |
| 6008 | j->caplist[j->caps].handle = j->caps++; |
| 6009 | break; |
| 6010 | default: |
| 6011 | break; |
| 6012 | } |
| 6013 | |
| 6014 | /* add codecs - all cards can do uLaw, linear 8/16, and Windows sound system */ |
| 6015 | strcpy(j->caplist[j->caps].desc, "ULAW"); |
| 6016 | j->caplist[j->caps].captype = codec; |
| 6017 | j->caplist[j->caps].cap = ULAW; |
| 6018 | j->caplist[j->caps].handle = j->caps++; |
| 6019 | |
| 6020 | strcpy(j->caplist[j->caps].desc, "LINEAR 16 bit"); |
| 6021 | j->caplist[j->caps].captype = codec; |
| 6022 | j->caplist[j->caps].cap = LINEAR16; |
| 6023 | j->caplist[j->caps].handle = j->caps++; |
| 6024 | |
| 6025 | strcpy(j->caplist[j->caps].desc, "LINEAR 8 bit"); |
| 6026 | j->caplist[j->caps].captype = codec; |
| 6027 | j->caplist[j->caps].cap = LINEAR8; |
| 6028 | j->caplist[j->caps].handle = j->caps++; |
| 6029 | |
| 6030 | strcpy(j->caplist[j->caps].desc, "Windows Sound System"); |
| 6031 | j->caplist[j->caps].captype = codec; |
| 6032 | j->caplist[j->caps].cap = WSS; |
| 6033 | j->caplist[j->caps].handle = j->caps++; |
| 6034 | |
| 6035 | /* software ALAW codec, made from ULAW */ |
| 6036 | strcpy(j->caplist[j->caps].desc, "ALAW"); |
| 6037 | j->caplist[j->caps].captype = codec; |
| 6038 | j->caplist[j->caps].cap = ALAW; |
| 6039 | j->caplist[j->caps].handle = j->caps++; |
| 6040 | |
| 6041 | /* version 12 of the 8020 does the following codecs in a broken way */ |
| 6042 | if (j->dsp.low != 0x20 || j->ver.low != 0x12) { |
| 6043 | strcpy(j->caplist[j->caps].desc, "G.723.1 6.3kbps"); |
| 6044 | j->caplist[j->caps].captype = codec; |
| 6045 | j->caplist[j->caps].cap = G723_63; |
| 6046 | j->caplist[j->caps].handle = j->caps++; |
| 6047 | |
| 6048 | strcpy(j->caplist[j->caps].desc, "G.723.1 5.3kbps"); |
| 6049 | j->caplist[j->caps].captype = codec; |
| 6050 | j->caplist[j->caps].cap = G723_53; |
| 6051 | j->caplist[j->caps].handle = j->caps++; |
| 6052 | |
| 6053 | strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.8kbps"); |
| 6054 | j->caplist[j->caps].captype = codec; |
| 6055 | j->caplist[j->caps].cap = TS48; |
| 6056 | j->caplist[j->caps].handle = j->caps++; |
| 6057 | |
| 6058 | strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.1kbps"); |
| 6059 | j->caplist[j->caps].captype = codec; |
| 6060 | j->caplist[j->caps].cap = TS41; |
| 6061 | j->caplist[j->caps].handle = j->caps++; |
| 6062 | } |
| 6063 | |
| 6064 | /* 8020 chips can do TS8.5 native, and 8021/8022 can load it */ |
| 6065 | if (j->dsp.low == 0x20 || j->flags.ts85_loaded) { |
| 6066 | strcpy(j->caplist[j->caps].desc, "TrueSpeech 8.5kbps"); |
| 6067 | j->caplist[j->caps].captype = codec; |
| 6068 | j->caplist[j->caps].cap = TS85; |
| 6069 | j->caplist[j->caps].handle = j->caps++; |
| 6070 | } |
| 6071 | |
| 6072 | /* 8021 chips can do G728 */ |
| 6073 | if (j->dsp.low == 0x21) { |
| 6074 | strcpy(j->caplist[j->caps].desc, "G.728 16kbps"); |
| 6075 | j->caplist[j->caps].captype = codec; |
| 6076 | j->caplist[j->caps].cap = G728; |
| 6077 | j->caplist[j->caps].handle = j->caps++; |
| 6078 | } |
| 6079 | |
| 6080 | /* 8021/8022 chips can do G729 if loaded */ |
| 6081 | if (j->dsp.low != 0x20 && j->flags.g729_loaded) { |
| 6082 | strcpy(j->caplist[j->caps].desc, "G.729A 8kbps"); |
| 6083 | j->caplist[j->caps].captype = codec; |
| 6084 | j->caplist[j->caps].cap = G729; |
| 6085 | j->caplist[j->caps].handle = j->caps++; |
| 6086 | } |
| 6087 | if (j->dsp.low != 0x20 && j->flags.g729_loaded) { |
| 6088 | strcpy(j->caplist[j->caps].desc, "G.729B 8kbps"); |
| 6089 | j->caplist[j->caps].captype = codec; |
| 6090 | j->caplist[j->caps].cap = G729B; |
| 6091 | j->caplist[j->caps].handle = j->caps++; |
| 6092 | } |
| 6093 | } |
| 6094 | |
| 6095 | static int capabilities_check(IXJ *j, struct phone_capability *pcreq) |
| 6096 | { |
| 6097 | int cnt; |
| 6098 | int retval = 0; |
| 6099 | for (cnt = 0; cnt < j->caps; cnt++) { |
| 6100 | if (pcreq->captype == j->caplist[cnt].captype |
| 6101 | && pcreq->cap == j->caplist[cnt].cap) { |
| 6102 | retval = 1; |
| 6103 | break; |
| 6104 | } |
| 6105 | } |
| 6106 | return retval; |
| 6107 | } |
| 6108 | |
| 6109 | static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, unsigned long arg) |
| 6110 | { |
| 6111 | IXJ_TONE ti; |
| 6112 | IXJ_FILTER jf; |
| 6113 | IXJ_FILTER_RAW jfr; |
| 6114 | void __user *argp = (void __user *)arg; |
| 6115 | |
| 6116 | unsigned int raise, mant; |
| 6117 | unsigned int minor = iminor(inode); |
| 6118 | int board = NUM(inode); |
| 6119 | |
| 6120 | IXJ *j = get_ixj(NUM(inode)); |
| 6121 | |
| 6122 | int retval = 0; |
| 6123 | |
| 6124 | /* |
| 6125 | * Set up locks to ensure that only one process is talking to the DSP at a time. |
| 6126 | * This is necessary to keep the DSP from locking up. |
| 6127 | */ |
| 6128 | while(test_and_set_bit(board, (void *)&j->busyflags) != 0) { |
| 6129 | set_current_state(TASK_INTERRUPTIBLE); |
| 6130 | schedule_timeout(1); |
| 6131 | } |
| 6132 | if (ixjdebug & 0x0040) |
| 6133 | printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg); |
| 6134 | if (minor >= IXJMAX) { |
| 6135 | clear_bit(board, &j->busyflags); |
| 6136 | return -ENODEV; |
| 6137 | } |
| 6138 | /* |
| 6139 | * Check ioctls only root can use. |
| 6140 | */ |
| 6141 | if (!capable(CAP_SYS_ADMIN)) { |
| 6142 | switch (cmd) { |
| 6143 | case IXJCTL_TESTRAM: |
| 6144 | case IXJCTL_HZ: |
| 6145 | retval = -EPERM; |
| 6146 | } |
| 6147 | } |
| 6148 | switch (cmd) { |
| 6149 | case IXJCTL_TESTRAM: |
| 6150 | ixj_testram(j); |
| 6151 | retval = (j->ssr.high << 8) + j->ssr.low; |
| 6152 | break; |
| 6153 | case IXJCTL_CARDTYPE: |
| 6154 | retval = j->cardtype; |
| 6155 | break; |
| 6156 | case IXJCTL_SERIAL: |
| 6157 | retval = j->serial; |
| 6158 | break; |
| 6159 | case IXJCTL_VERSION: |
Domen Puncer | fba478b | 2005-05-05 16:16:13 -0700 | [diff] [blame] | 6160 | { |
| 6161 | char arg_str[100]; |
| 6162 | snprintf(arg_str, sizeof(arg_str), |
| 6163 | "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, |
| 6164 | IXJ_VER_MINOR, IXJ_BLD_VER); |
| 6165 | if (copy_to_user(argp, arg_str, strlen(arg_str))) |
| 6166 | retval = -EFAULT; |
| 6167 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6168 | break; |
| 6169 | case PHONE_RING_CADENCE: |
| 6170 | j->ring_cadence = arg; |
| 6171 | break; |
| 6172 | case IXJCTL_CIDCW: |
| 6173 | if(arg) { |
| 6174 | if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) { |
| 6175 | retval = -EFAULT; |
| 6176 | break; |
| 6177 | } |
| 6178 | } else { |
| 6179 | memset(&j->cid_send, 0, sizeof(PHONE_CID)); |
| 6180 | } |
| 6181 | ixj_write_cidcw(j); |
| 6182 | break; |
| 6183 | /* Binary compatbility */ |
| 6184 | case OLD_PHONE_RING_START: |
| 6185 | arg = 0; |
| 6186 | /* Fall through */ |
| 6187 | case PHONE_RING_START: |
| 6188 | if(arg) { |
| 6189 | if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) { |
| 6190 | retval = -EFAULT; |
| 6191 | break; |
| 6192 | } |
| 6193 | ixj_write_cid(j); |
| 6194 | } else { |
| 6195 | memset(&j->cid_send, 0, sizeof(PHONE_CID)); |
| 6196 | } |
| 6197 | ixj_ring_start(j); |
| 6198 | break; |
| 6199 | case PHONE_RING_STOP: |
| 6200 | j->flags.cringing = 0; |
| 6201 | if(j->cadence_f[5].enable) { |
| 6202 | j->cadence_f[5].state = 0; |
| 6203 | } |
| 6204 | ixj_ring_off(j); |
| 6205 | break; |
| 6206 | case PHONE_RING: |
| 6207 | retval = ixj_ring(j); |
| 6208 | break; |
| 6209 | case PHONE_EXCEPTION: |
| 6210 | retval = j->ex.bytes; |
| 6211 | if(j->ex.bits.flash) { |
| 6212 | j->flash_end = 0; |
| 6213 | j->ex.bits.flash = 0; |
| 6214 | } |
| 6215 | j->ex.bits.pstn_ring = 0; |
| 6216 | j->ex.bits.caller_id = 0; |
| 6217 | j->ex.bits.pstn_wink = 0; |
| 6218 | j->ex.bits.f0 = 0; |
| 6219 | j->ex.bits.f1 = 0; |
| 6220 | j->ex.bits.f2 = 0; |
| 6221 | j->ex.bits.f3 = 0; |
| 6222 | j->ex.bits.fc0 = 0; |
| 6223 | j->ex.bits.fc1 = 0; |
| 6224 | j->ex.bits.fc2 = 0; |
| 6225 | j->ex.bits.fc3 = 0; |
| 6226 | j->ex.bits.reserved = 0; |
| 6227 | break; |
| 6228 | case PHONE_HOOKSTATE: |
| 6229 | j->ex.bits.hookstate = 0; |
| 6230 | retval = j->hookstate; //j->r_hook; |
| 6231 | break; |
| 6232 | case IXJCTL_SET_LED: |
| 6233 | LED_SetState(arg, j); |
| 6234 | break; |
| 6235 | case PHONE_FRAME: |
| 6236 | retval = set_base_frame(j, arg); |
| 6237 | break; |
| 6238 | case PHONE_REC_CODEC: |
| 6239 | retval = set_rec_codec(j, arg); |
| 6240 | break; |
| 6241 | case PHONE_VAD: |
| 6242 | ixj_vad(j, arg); |
| 6243 | break; |
| 6244 | case PHONE_REC_START: |
| 6245 | ixj_record_start(j); |
| 6246 | break; |
| 6247 | case PHONE_REC_STOP: |
| 6248 | ixj_record_stop(j); |
| 6249 | break; |
| 6250 | case PHONE_REC_DEPTH: |
| 6251 | set_rec_depth(j, arg); |
| 6252 | break; |
| 6253 | case PHONE_REC_VOLUME: |
| 6254 | if(arg == -1) { |
| 6255 | retval = get_rec_volume(j); |
| 6256 | } |
| 6257 | else { |
| 6258 | set_rec_volume(j, arg); |
| 6259 | retval = arg; |
| 6260 | } |
| 6261 | break; |
| 6262 | case PHONE_REC_VOLUME_LINEAR: |
| 6263 | if(arg == -1) { |
| 6264 | retval = get_rec_volume_linear(j); |
| 6265 | } |
| 6266 | else { |
| 6267 | set_rec_volume_linear(j, arg); |
| 6268 | retval = arg; |
| 6269 | } |
| 6270 | break; |
| 6271 | case IXJCTL_DTMF_PRESCALE: |
| 6272 | if(arg == -1) { |
| 6273 | retval = get_dtmf_prescale(j); |
| 6274 | } |
| 6275 | else { |
| 6276 | set_dtmf_prescale(j, arg); |
| 6277 | retval = arg; |
| 6278 | } |
| 6279 | break; |
| 6280 | case PHONE_REC_LEVEL: |
| 6281 | retval = get_rec_level(j); |
| 6282 | break; |
| 6283 | case IXJCTL_SC_RXG: |
| 6284 | retval = ixj_siadc(j, arg); |
| 6285 | break; |
| 6286 | case IXJCTL_SC_TXG: |
| 6287 | retval = ixj_sidac(j, arg); |
| 6288 | break; |
| 6289 | case IXJCTL_AEC_START: |
| 6290 | ixj_aec_start(j, arg); |
| 6291 | break; |
| 6292 | case IXJCTL_AEC_STOP: |
| 6293 | aec_stop(j); |
| 6294 | break; |
| 6295 | case IXJCTL_AEC_GET_LEVEL: |
| 6296 | retval = j->aec_level; |
| 6297 | break; |
| 6298 | case PHONE_PLAY_CODEC: |
| 6299 | retval = set_play_codec(j, arg); |
| 6300 | break; |
| 6301 | case PHONE_PLAY_START: |
| 6302 | retval = ixj_play_start(j); |
| 6303 | break; |
| 6304 | case PHONE_PLAY_STOP: |
| 6305 | ixj_play_stop(j); |
| 6306 | break; |
| 6307 | case PHONE_PLAY_DEPTH: |
| 6308 | set_play_depth(j, arg); |
| 6309 | break; |
| 6310 | case PHONE_PLAY_VOLUME: |
| 6311 | if(arg == -1) { |
| 6312 | retval = get_play_volume(j); |
| 6313 | } |
| 6314 | else { |
| 6315 | set_play_volume(j, arg); |
| 6316 | retval = arg; |
| 6317 | } |
| 6318 | break; |
| 6319 | case PHONE_PLAY_VOLUME_LINEAR: |
| 6320 | if(arg == -1) { |
| 6321 | retval = get_play_volume_linear(j); |
| 6322 | } |
| 6323 | else { |
| 6324 | set_play_volume_linear(j, arg); |
| 6325 | retval = arg; |
| 6326 | } |
| 6327 | break; |
| 6328 | case PHONE_PLAY_LEVEL: |
| 6329 | retval = get_play_level(j); |
| 6330 | break; |
| 6331 | case IXJCTL_DSP_TYPE: |
| 6332 | retval = (j->dsp.high << 8) + j->dsp.low; |
| 6333 | break; |
| 6334 | case IXJCTL_DSP_VERSION: |
| 6335 | retval = (j->ver.high << 8) + j->ver.low; |
| 6336 | break; |
| 6337 | case IXJCTL_HZ: |
| 6338 | hertz = arg; |
| 6339 | break; |
| 6340 | case IXJCTL_RATE: |
| 6341 | if (arg > hertz) |
| 6342 | retval = -1; |
| 6343 | else |
| 6344 | samplerate = arg; |
| 6345 | break; |
| 6346 | case IXJCTL_DRYBUFFER_READ: |
| 6347 | put_user(j->drybuffer, (unsigned long __user *) argp); |
| 6348 | break; |
| 6349 | case IXJCTL_DRYBUFFER_CLEAR: |
| 6350 | j->drybuffer = 0; |
| 6351 | break; |
| 6352 | case IXJCTL_FRAMES_READ: |
| 6353 | put_user(j->framesread, (unsigned long __user *) argp); |
| 6354 | break; |
| 6355 | case IXJCTL_FRAMES_WRITTEN: |
| 6356 | put_user(j->frameswritten, (unsigned long __user *) argp); |
| 6357 | break; |
| 6358 | case IXJCTL_READ_WAIT: |
| 6359 | put_user(j->read_wait, (unsigned long __user *) argp); |
| 6360 | break; |
| 6361 | case IXJCTL_WRITE_WAIT: |
| 6362 | put_user(j->write_wait, (unsigned long __user *) argp); |
| 6363 | break; |
| 6364 | case PHONE_MAXRINGS: |
| 6365 | j->maxrings = arg; |
| 6366 | break; |
| 6367 | case PHONE_SET_TONE_ON_TIME: |
| 6368 | ixj_set_tone_on(arg, j); |
| 6369 | break; |
| 6370 | case PHONE_SET_TONE_OFF_TIME: |
| 6371 | ixj_set_tone_off(arg, j); |
| 6372 | break; |
| 6373 | case PHONE_GET_TONE_ON_TIME: |
| 6374 | if (ixj_get_tone_on(j)) { |
| 6375 | retval = -1; |
| 6376 | } else { |
| 6377 | retval = (j->ssr.high << 8) + j->ssr.low; |
| 6378 | } |
| 6379 | break; |
| 6380 | case PHONE_GET_TONE_OFF_TIME: |
| 6381 | if (ixj_get_tone_off(j)) { |
| 6382 | retval = -1; |
| 6383 | } else { |
| 6384 | retval = (j->ssr.high << 8) + j->ssr.low; |
| 6385 | } |
| 6386 | break; |
| 6387 | case PHONE_PLAY_TONE: |
| 6388 | if (!j->tone_state) |
| 6389 | retval = ixj_play_tone(j, arg); |
| 6390 | else |
| 6391 | retval = -1; |
| 6392 | break; |
| 6393 | case PHONE_GET_TONE_STATE: |
| 6394 | retval = j->tone_state; |
| 6395 | break; |
| 6396 | case PHONE_DTMF_READY: |
| 6397 | retval = j->ex.bits.dtmf_ready; |
| 6398 | break; |
| 6399 | case PHONE_GET_DTMF: |
| 6400 | if (ixj_hookstate(j)) { |
| 6401 | if (j->dtmf_rp != j->dtmf_wp) { |
| 6402 | retval = j->dtmfbuffer[j->dtmf_rp]; |
| 6403 | j->dtmf_rp++; |
| 6404 | if (j->dtmf_rp == 79) |
| 6405 | j->dtmf_rp = 0; |
| 6406 | if (j->dtmf_rp == j->dtmf_wp) { |
| 6407 | j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0; |
| 6408 | } |
| 6409 | } |
| 6410 | } |
| 6411 | break; |
| 6412 | case PHONE_GET_DTMF_ASCII: |
| 6413 | if (ixj_hookstate(j)) { |
| 6414 | if (j->dtmf_rp != j->dtmf_wp) { |
| 6415 | switch (j->dtmfbuffer[j->dtmf_rp]) { |
| 6416 | case 10: |
| 6417 | retval = 42; /* '*'; */ |
| 6418 | |
| 6419 | break; |
| 6420 | case 11: |
| 6421 | retval = 48; /*'0'; */ |
| 6422 | |
| 6423 | break; |
| 6424 | case 12: |
| 6425 | retval = 35; /*'#'; */ |
| 6426 | |
| 6427 | break; |
| 6428 | case 28: |
| 6429 | retval = 65; /*'A'; */ |
| 6430 | |
| 6431 | break; |
| 6432 | case 29: |
| 6433 | retval = 66; /*'B'; */ |
| 6434 | |
| 6435 | break; |
| 6436 | case 30: |
| 6437 | retval = 67; /*'C'; */ |
| 6438 | |
| 6439 | break; |
| 6440 | case 31: |
| 6441 | retval = 68; /*'D'; */ |
| 6442 | |
| 6443 | break; |
| 6444 | default: |
| 6445 | retval = 48 + j->dtmfbuffer[j->dtmf_rp]; |
| 6446 | break; |
| 6447 | } |
| 6448 | j->dtmf_rp++; |
| 6449 | if (j->dtmf_rp == 79) |
| 6450 | j->dtmf_rp = 0; |
| 6451 | if(j->dtmf_rp == j->dtmf_wp) |
| 6452 | { |
| 6453 | j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0; |
| 6454 | } |
| 6455 | } |
| 6456 | } |
| 6457 | break; |
| 6458 | case PHONE_DTMF_OOB: |
| 6459 | j->flags.dtmf_oob = arg; |
| 6460 | break; |
| 6461 | case PHONE_DIALTONE: |
| 6462 | ixj_dialtone(j); |
| 6463 | break; |
| 6464 | case PHONE_BUSY: |
| 6465 | ixj_busytone(j); |
| 6466 | break; |
| 6467 | case PHONE_RINGBACK: |
| 6468 | ixj_ringback(j); |
| 6469 | break; |
| 6470 | case PHONE_WINK: |
| 6471 | if(j->cardtype == QTI_PHONEJACK) |
| 6472 | retval = -1; |
| 6473 | else |
| 6474 | retval = ixj_wink(j); |
| 6475 | break; |
| 6476 | case PHONE_CPT_STOP: |
| 6477 | ixj_cpt_stop(j); |
| 6478 | break; |
| 6479 | case PHONE_QUERY_CODEC: |
| 6480 | { |
| 6481 | struct phone_codec_data pd; |
| 6482 | int val; |
| 6483 | int proto_size[] = { |
| 6484 | -1, |
| 6485 | 12, 10, 16, 9, 8, 48, 5, |
| 6486 | 40, 40, 80, 40, 40, 6 |
| 6487 | }; |
| 6488 | if(copy_from_user(&pd, argp, sizeof(pd))) { |
| 6489 | retval = -EFAULT; |
| 6490 | break; |
| 6491 | } |
| 6492 | if(pd.type<1 || pd.type>13) { |
| 6493 | retval = -EPROTONOSUPPORT; |
| 6494 | break; |
| 6495 | } |
| 6496 | if(pd.type<G729) |
| 6497 | val=proto_size[pd.type]; |
| 6498 | else switch(j->baseframe.low) |
| 6499 | { |
| 6500 | case 0xA0:val=2*proto_size[pd.type];break; |
| 6501 | case 0x50:val=proto_size[pd.type];break; |
| 6502 | default:val=proto_size[pd.type]*3;break; |
| 6503 | } |
| 6504 | pd.buf_min=pd.buf_max=pd.buf_opt=val; |
| 6505 | if(copy_to_user(argp, &pd, sizeof(pd))) |
| 6506 | retval = -EFAULT; |
| 6507 | break; |
| 6508 | } |
| 6509 | case IXJCTL_DSP_IDLE: |
| 6510 | idle(j); |
| 6511 | break; |
| 6512 | case IXJCTL_MIXER: |
| 6513 | if ((arg & 0xff) == 0xff) |
| 6514 | retval = ixj_get_mixer(arg, j); |
| 6515 | else |
| 6516 | ixj_mixer(arg, j); |
| 6517 | break; |
| 6518 | case IXJCTL_DAA_COEFF_SET: |
| 6519 | switch (arg) { |
| 6520 | case DAA_US: |
| 6521 | DAA_Coeff_US(j); |
| 6522 | retval = ixj_daa_write(j); |
| 6523 | break; |
| 6524 | case DAA_UK: |
| 6525 | DAA_Coeff_UK(j); |
| 6526 | retval = ixj_daa_write(j); |
| 6527 | break; |
| 6528 | case DAA_FRANCE: |
| 6529 | DAA_Coeff_France(j); |
| 6530 | retval = ixj_daa_write(j); |
| 6531 | break; |
| 6532 | case DAA_GERMANY: |
| 6533 | DAA_Coeff_Germany(j); |
| 6534 | retval = ixj_daa_write(j); |
| 6535 | break; |
| 6536 | case DAA_AUSTRALIA: |
| 6537 | DAA_Coeff_Australia(j); |
| 6538 | retval = ixj_daa_write(j); |
| 6539 | break; |
| 6540 | case DAA_JAPAN: |
| 6541 | DAA_Coeff_Japan(j); |
| 6542 | retval = ixj_daa_write(j); |
| 6543 | break; |
| 6544 | default: |
| 6545 | retval = 1; |
| 6546 | break; |
| 6547 | } |
| 6548 | break; |
| 6549 | case IXJCTL_DAA_AGAIN: |
| 6550 | ixj_daa_cr4(j, arg | 0x02); |
| 6551 | break; |
| 6552 | case IXJCTL_PSTN_LINETEST: |
| 6553 | retval = ixj_linetest(j); |
| 6554 | break; |
| 6555 | case IXJCTL_VMWI: |
| 6556 | ixj_write_vmwi(j, arg); |
| 6557 | break; |
| 6558 | case IXJCTL_CID: |
| 6559 | if (copy_to_user(argp, &j->cid, sizeof(PHONE_CID))) |
| 6560 | retval = -EFAULT; |
| 6561 | j->ex.bits.caller_id = 0; |
| 6562 | break; |
| 6563 | case IXJCTL_WINK_DURATION: |
| 6564 | j->winktime = arg; |
| 6565 | break; |
| 6566 | case IXJCTL_PORT: |
| 6567 | if (arg) |
| 6568 | retval = ixj_set_port(j, arg); |
| 6569 | else |
| 6570 | retval = j->port; |
| 6571 | break; |
| 6572 | case IXJCTL_POTS_PSTN: |
| 6573 | retval = ixj_set_pots(j, arg); |
| 6574 | break; |
| 6575 | case PHONE_CAPABILITIES: |
| 6576 | add_caps(j); |
| 6577 | retval = j->caps; |
| 6578 | break; |
| 6579 | case PHONE_CAPABILITIES_LIST: |
| 6580 | add_caps(j); |
| 6581 | if (copy_to_user(argp, j->caplist, sizeof(struct phone_capability) * j->caps)) |
| 6582 | retval = -EFAULT; |
| 6583 | break; |
| 6584 | case PHONE_CAPABILITIES_CHECK: |
| 6585 | { |
| 6586 | struct phone_capability cap; |
| 6587 | if (copy_from_user(&cap, argp, sizeof(cap))) |
| 6588 | retval = -EFAULT; |
| 6589 | else { |
| 6590 | add_caps(j); |
| 6591 | retval = capabilities_check(j, &cap); |
| 6592 | } |
| 6593 | } |
| 6594 | break; |
| 6595 | case PHONE_PSTN_SET_STATE: |
| 6596 | daa_set_mode(j, arg); |
| 6597 | break; |
| 6598 | case PHONE_PSTN_GET_STATE: |
| 6599 | retval = j->daa_mode; |
| 6600 | j->ex.bits.pstn_ring = 0; |
| 6601 | break; |
| 6602 | case IXJCTL_SET_FILTER: |
| 6603 | if (copy_from_user(&jf, argp, sizeof(jf))) |
| 6604 | retval = -EFAULT; |
| 6605 | retval = ixj_init_filter(j, &jf); |
| 6606 | break; |
| 6607 | case IXJCTL_SET_FILTER_RAW: |
| 6608 | if (copy_from_user(&jfr, argp, sizeof(jfr))) |
| 6609 | retval = -EFAULT; |
| 6610 | else |
| 6611 | retval = ixj_init_filter_raw(j, &jfr); |
| 6612 | break; |
| 6613 | case IXJCTL_GET_FILTER_HIST: |
| 6614 | if(arg<0||arg>3) |
| 6615 | retval = -EINVAL; |
| 6616 | else |
| 6617 | retval = j->filter_hist[arg]; |
| 6618 | break; |
| 6619 | case IXJCTL_INIT_TONE: |
| 6620 | if (copy_from_user(&ti, argp, sizeof(ti))) |
| 6621 | retval = -EFAULT; |
| 6622 | else |
| 6623 | retval = ixj_init_tone(j, &ti); |
| 6624 | break; |
| 6625 | case IXJCTL_TONE_CADENCE: |
| 6626 | retval = ixj_build_cadence(j, argp); |
| 6627 | break; |
| 6628 | case IXJCTL_FILTER_CADENCE: |
| 6629 | retval = ixj_build_filter_cadence(j, argp); |
| 6630 | break; |
| 6631 | case IXJCTL_SIGCTL: |
| 6632 | if (copy_from_user(&j->sigdef, argp, sizeof(IXJ_SIGDEF))) { |
| 6633 | retval = -EFAULT; |
| 6634 | break; |
| 6635 | } |
| 6636 | j->ixj_signals[j->sigdef.event] = j->sigdef.signal; |
| 6637 | if(j->sigdef.event < 33) { |
| 6638 | raise = 1; |
| 6639 | for(mant = 0; mant < j->sigdef.event; mant++){ |
| 6640 | raise *= 2; |
| 6641 | } |
| 6642 | if(j->sigdef.signal) |
| 6643 | j->ex_sig.bytes |= raise; |
| 6644 | else |
| 6645 | j->ex_sig.bytes &= (raise^0xffff); |
| 6646 | } |
| 6647 | break; |
| 6648 | case IXJCTL_INTERCOM_STOP: |
| 6649 | if(arg < 0 || arg >= IXJMAX) |
| 6650 | return -EINVAL; |
| 6651 | j->intercom = -1; |
| 6652 | ixj_record_stop(j); |
| 6653 | ixj_play_stop(j); |
| 6654 | idle(j); |
| 6655 | get_ixj(arg)->intercom = -1; |
| 6656 | ixj_record_stop(get_ixj(arg)); |
| 6657 | ixj_play_stop(get_ixj(arg)); |
| 6658 | idle(get_ixj(arg)); |
| 6659 | break; |
| 6660 | case IXJCTL_INTERCOM_START: |
| 6661 | if(arg < 0 || arg >= IXJMAX) |
| 6662 | return -EINVAL; |
| 6663 | j->intercom = arg; |
| 6664 | ixj_record_start(j); |
| 6665 | ixj_play_start(j); |
| 6666 | get_ixj(arg)->intercom = board; |
| 6667 | ixj_play_start(get_ixj(arg)); |
| 6668 | ixj_record_start(get_ixj(arg)); |
| 6669 | break; |
| 6670 | } |
| 6671 | if (ixjdebug & 0x0040) |
| 6672 | printk("phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg); |
| 6673 | clear_bit(board, &j->busyflags); |
| 6674 | return retval; |
| 6675 | } |
| 6676 | |
| 6677 | static int ixj_fasync(int fd, struct file *file_p, int mode) |
| 6678 | { |
| 6679 | IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode)); |
| 6680 | |
| 6681 | return fasync_helper(fd, file_p, mode, &j->async_queue); |
| 6682 | } |
| 6683 | |
| 6684 | static struct file_operations ixj_fops = |
| 6685 | { |
| 6686 | .owner = THIS_MODULE, |
| 6687 | .read = ixj_enhanced_read, |
| 6688 | .write = ixj_enhanced_write, |
| 6689 | .poll = ixj_poll, |
| 6690 | .ioctl = ixj_ioctl, |
| 6691 | .release = ixj_release, |
| 6692 | .fasync = ixj_fasync |
| 6693 | }; |
| 6694 | |
| 6695 | static int ixj_linetest(IXJ *j) |
| 6696 | { |
| 6697 | unsigned long jifwait; |
| 6698 | |
| 6699 | j->flags.pstncheck = 1; /* Testing */ |
| 6700 | j->flags.pstn_present = 0; /* Assume the line is not there */ |
| 6701 | |
| 6702 | daa_int_read(j); /*Clear DAA Interrupt flags */ |
| 6703 | /* */ |
| 6704 | /* Hold all relays in the normally de-energized position. */ |
| 6705 | /* */ |
| 6706 | |
| 6707 | j->pld_slicw.bits.rly1 = 0; |
| 6708 | j->pld_slicw.bits.rly2 = 0; |
| 6709 | j->pld_slicw.bits.rly3 = 0; |
| 6710 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6711 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 6712 | |
| 6713 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 6714 | j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01); |
| 6715 | if (j->pld_slicr.bits.potspstn) { |
| 6716 | j->flags.pots_pstn = 1; |
| 6717 | j->flags.pots_correct = 0; |
| 6718 | LED_SetState(0x4, j); |
| 6719 | } else { |
| 6720 | j->flags.pots_pstn = 0; |
| 6721 | j->pld_slicw.bits.rly1 = 0; |
| 6722 | j->pld_slicw.bits.rly2 = 0; |
| 6723 | j->pld_slicw.bits.rly3 = 1; |
| 6724 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6725 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 6726 | |
| 6727 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 6728 | daa_set_mode(j, SOP_PU_CONVERSATION); |
| 6729 | jifwait = jiffies + hertz; |
| 6730 | while (time_before(jiffies, jifwait)) { |
| 6731 | set_current_state(TASK_INTERRUPTIBLE); |
| 6732 | schedule_timeout(1); |
| 6733 | } |
| 6734 | daa_int_read(j); |
| 6735 | daa_set_mode(j, SOP_PU_RESET); |
| 6736 | if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) { |
| 6737 | j->flags.pots_correct = 0; /* Should not be line voltage on POTS port. */ |
| 6738 | LED_SetState(0x4, j); |
| 6739 | j->pld_slicw.bits.rly3 = 0; |
| 6740 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6741 | } else { |
| 6742 | j->flags.pots_correct = 1; |
| 6743 | LED_SetState(0x8, j); |
| 6744 | j->pld_slicw.bits.rly1 = 1; |
| 6745 | j->pld_slicw.bits.rly2 = 0; |
| 6746 | j->pld_slicw.bits.rly3 = 0; |
| 6747 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6748 | } |
| 6749 | } |
| 6750 | j->pld_slicw.bits.rly3 = 0; |
| 6751 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6752 | daa_set_mode(j, SOP_PU_CONVERSATION); |
| 6753 | jifwait = jiffies + hertz; |
| 6754 | while (time_before(jiffies, jifwait)) { |
| 6755 | set_current_state(TASK_INTERRUPTIBLE); |
| 6756 | schedule_timeout(1); |
| 6757 | } |
| 6758 | daa_int_read(j); |
| 6759 | daa_set_mode(j, SOP_PU_RESET); |
| 6760 | if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) { |
| 6761 | j->pstn_sleeptil = jiffies + (hertz / 4); |
| 6762 | j->flags.pstn_present = 1; |
| 6763 | } else { |
| 6764 | j->flags.pstn_present = 0; |
| 6765 | } |
| 6766 | if (j->flags.pstn_present) { |
| 6767 | if (j->flags.pots_correct) { |
| 6768 | LED_SetState(0xA, j); |
| 6769 | } else { |
| 6770 | LED_SetState(0x6, j); |
| 6771 | } |
| 6772 | } else { |
| 6773 | if (j->flags.pots_correct) { |
| 6774 | LED_SetState(0x9, j); |
| 6775 | } else { |
| 6776 | LED_SetState(0x5, j); |
| 6777 | } |
| 6778 | } |
| 6779 | j->flags.pstncheck = 0; /* Testing */ |
| 6780 | return j->flags.pstn_present; |
| 6781 | } |
| 6782 | |
| 6783 | static int ixj_selfprobe(IXJ *j) |
| 6784 | { |
| 6785 | unsigned short cmd; |
| 6786 | unsigned long jif; |
| 6787 | int cnt; |
| 6788 | BYTES bytes; |
| 6789 | |
| 6790 | init_waitqueue_head(&j->poll_q); |
| 6791 | init_waitqueue_head(&j->read_q); |
| 6792 | init_waitqueue_head(&j->write_q); |
| 6793 | |
| 6794 | while(atomic_read(&j->DSPWrite) > 0) |
| 6795 | atomic_dec(&j->DSPWrite); |
| 6796 | if (ixjdebug & 0x0002) |
| 6797 | printk(KERN_INFO "Write IDLE to Software Control Register\n"); |
| 6798 | ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */ |
| 6799 | |
| 6800 | if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */ |
| 6801 | return -1; |
| 6802 | /* The read values of the SSR should be 0x00 for the IDLE command */ |
| 6803 | if (j->ssr.low || j->ssr.high) |
| 6804 | return -1; |
| 6805 | if (ixjdebug & 0x0002) |
| 6806 | printk(KERN_INFO "Get Device ID Code\n"); |
| 6807 | if (ixj_WriteDSPCommand(0x3400, j)) /* Get Device ID Code */ |
| 6808 | return -1; |
| 6809 | j->dsp.low = j->ssr.low; |
| 6810 | j->dsp.high = j->ssr.high; |
| 6811 | if (ixjdebug & 0x0002) |
| 6812 | printk(KERN_INFO "Get Device Version Code\n"); |
| 6813 | if (ixj_WriteDSPCommand(0x3800, j)) /* Get Device Version Code */ |
| 6814 | return -1; |
| 6815 | j->ver.low = j->ssr.low; |
| 6816 | j->ver.high = j->ssr.high; |
| 6817 | if (!j->cardtype) { |
| 6818 | if (j->dsp.low == 0x21) { |
| 6819 | bytes.high = bytes.low = inb_p(j->XILINXbase + 0x02); |
| 6820 | outb_p(bytes.low ^ 0xFF, j->XILINXbase + 0x02); |
| 6821 | /* Test for Internet LineJACK or Internet PhoneJACK Lite */ |
| 6822 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 6823 | if (bytes.low == bytes.high) /* Register is read only on */ |
| 6824 | /* Internet PhoneJack Lite */ |
| 6825 | { |
| 6826 | j->cardtype = QTI_PHONEJACK_LITE; |
| 6827 | if (!request_region(j->XILINXbase, 4, "ixj control")) { |
| 6828 | printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase); |
| 6829 | return -1; |
| 6830 | } |
| 6831 | j->pld_slicw.pcib.e1 = 1; |
| 6832 | outb_p(j->pld_slicw.byte, j->XILINXbase); |
| 6833 | } else { |
| 6834 | j->cardtype = QTI_LINEJACK; |
| 6835 | |
| 6836 | if (!request_region(j->XILINXbase, 8, "ixj control")) { |
| 6837 | printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase); |
| 6838 | return -1; |
| 6839 | } |
| 6840 | } |
| 6841 | } else if (j->dsp.low == 0x22) { |
| 6842 | j->cardtype = QTI_PHONEJACK_PCI; |
| 6843 | request_region(j->XILINXbase, 4, "ixj control"); |
| 6844 | j->pld_slicw.pcib.e1 = 1; |
| 6845 | outb_p(j->pld_slicw.byte, j->XILINXbase); |
| 6846 | } else |
| 6847 | j->cardtype = QTI_PHONEJACK; |
| 6848 | } else { |
| 6849 | switch (j->cardtype) { |
| 6850 | case QTI_PHONEJACK: |
| 6851 | if (!j->dsp.low != 0x20) { |
| 6852 | j->dsp.high = 0x80; |
| 6853 | j->dsp.low = 0x20; |
| 6854 | ixj_WriteDSPCommand(0x3800, j); |
| 6855 | j->ver.low = j->ssr.low; |
| 6856 | j->ver.high = j->ssr.high; |
| 6857 | } |
| 6858 | break; |
| 6859 | case QTI_LINEJACK: |
| 6860 | if (!request_region(j->XILINXbase, 8, "ixj control")) { |
| 6861 | printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase); |
| 6862 | return -1; |
| 6863 | } |
| 6864 | break; |
| 6865 | case QTI_PHONEJACK_LITE: |
| 6866 | case QTI_PHONEJACK_PCI: |
| 6867 | if (!request_region(j->XILINXbase, 4, "ixj control")) { |
| 6868 | printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase); |
| 6869 | return -1; |
| 6870 | } |
| 6871 | j->pld_slicw.pcib.e1 = 1; |
| 6872 | outb_p(j->pld_slicw.byte, j->XILINXbase); |
| 6873 | break; |
| 6874 | case QTI_PHONECARD: |
| 6875 | break; |
| 6876 | } |
| 6877 | } |
| 6878 | if (j->dsp.low == 0x20 || j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) { |
| 6879 | if (ixjdebug & 0x0002) |
| 6880 | printk(KERN_INFO "Write CODEC config to Software Control Register\n"); |
| 6881 | if (ixj_WriteDSPCommand(0xC462, j)) /* Write CODEC config to Software Control Register */ |
| 6882 | return -1; |
| 6883 | if (ixjdebug & 0x0002) |
| 6884 | printk(KERN_INFO "Write CODEC timing to Software Control Register\n"); |
| 6885 | if (j->cardtype == QTI_PHONEJACK) { |
| 6886 | cmd = 0x9FF2; |
| 6887 | } else { |
| 6888 | cmd = 0x9FF5; |
| 6889 | } |
| 6890 | if (ixj_WriteDSPCommand(cmd, j)) /* Write CODEC timing to Software Control Register */ |
| 6891 | return -1; |
| 6892 | } else { |
| 6893 | if (set_base_frame(j, 30) != 30) |
| 6894 | return -1; |
| 6895 | if (ixjdebug & 0x0002) |
| 6896 | printk(KERN_INFO "Write CODEC config to Software Control Register\n"); |
| 6897 | if (j->cardtype == QTI_PHONECARD) { |
| 6898 | if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */ |
| 6899 | return -1; |
| 6900 | } |
| 6901 | if (j->cardtype == QTI_LINEJACK) { |
| 6902 | if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */ |
| 6903 | return -1; |
| 6904 | if (ixjdebug & 0x0002) |
| 6905 | printk(KERN_INFO "Turn on the PLD Clock at 8Khz\n"); |
| 6906 | j->pld_clock.byte = 0; |
| 6907 | outb_p(j->pld_clock.byte, j->XILINXbase + 0x04); |
| 6908 | } |
| 6909 | } |
| 6910 | |
| 6911 | if (j->dsp.low == 0x20) { |
| 6912 | if (ixjdebug & 0x0002) |
| 6913 | printk(KERN_INFO "Configure GPIO pins\n"); |
| 6914 | j->gpio.bytes.high = 0x09; |
| 6915 | /* bytes.low = 0xEF; 0xF7 */ |
| 6916 | j->gpio.bits.gpio1 = 1; |
| 6917 | j->gpio.bits.gpio2 = 1; |
| 6918 | j->gpio.bits.gpio3 = 0; |
| 6919 | j->gpio.bits.gpio4 = 1; |
| 6920 | j->gpio.bits.gpio5 = 1; |
| 6921 | j->gpio.bits.gpio6 = 1; |
| 6922 | j->gpio.bits.gpio7 = 1; |
| 6923 | ixj_WriteDSPCommand(j->gpio.word, j); /* Set GPIO pin directions */ |
| 6924 | if (ixjdebug & 0x0002) |
| 6925 | printk(KERN_INFO "Enable SLIC\n"); |
| 6926 | j->gpio.bytes.high = 0x0B; |
| 6927 | j->gpio.bytes.low = 0x00; |
| 6928 | j->gpio.bits.gpio1 = 0; |
| 6929 | j->gpio.bits.gpio2 = 1; |
| 6930 | j->gpio.bits.gpio5 = 0; |
| 6931 | ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring stop signal */ |
| 6932 | j->port = PORT_POTS; |
| 6933 | } else { |
| 6934 | if (j->cardtype == QTI_LINEJACK) { |
| 6935 | LED_SetState(0x1, j); |
| 6936 | jif = jiffies + (hertz / 10); |
| 6937 | while (time_before(jiffies, jif)) { |
| 6938 | set_current_state(TASK_INTERRUPTIBLE); |
| 6939 | schedule_timeout(1); |
| 6940 | } |
| 6941 | LED_SetState(0x2, j); |
| 6942 | jif = jiffies + (hertz / 10); |
| 6943 | while (time_before(jiffies, jif)) { |
| 6944 | set_current_state(TASK_INTERRUPTIBLE); |
| 6945 | schedule_timeout(1); |
| 6946 | } |
| 6947 | LED_SetState(0x4, j); |
| 6948 | jif = jiffies + (hertz / 10); |
| 6949 | while (time_before(jiffies, jif)) { |
| 6950 | set_current_state(TASK_INTERRUPTIBLE); |
| 6951 | schedule_timeout(1); |
| 6952 | } |
| 6953 | LED_SetState(0x8, j); |
| 6954 | jif = jiffies + (hertz / 10); |
| 6955 | while (time_before(jiffies, jif)) { |
| 6956 | set_current_state(TASK_INTERRUPTIBLE); |
| 6957 | schedule_timeout(1); |
| 6958 | } |
| 6959 | LED_SetState(0x0, j); |
| 6960 | daa_get_version(j); |
| 6961 | if (ixjdebug & 0x0002) |
| 6962 | printk("Loading DAA Coefficients\n"); |
| 6963 | DAA_Coeff_US(j); |
| 6964 | if (!ixj_daa_write(j)) { |
| 6965 | printk("DAA write failed on board %d\n", j->board); |
| 6966 | return -1; |
| 6967 | } |
| 6968 | if(!ixj_daa_cid_reset(j)) { |
| 6969 | printk("DAA CID reset failed on board %d\n", j->board); |
| 6970 | return -1; |
| 6971 | } |
| 6972 | j->flags.pots_correct = 0; |
| 6973 | j->flags.pstn_present = 0; |
| 6974 | ixj_linetest(j); |
| 6975 | if (j->flags.pots_correct) { |
| 6976 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 6977 | |
| 6978 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 6979 | j->pld_slicw.bits.rly1 = 1; |
| 6980 | j->pld_slicw.bits.spken = 1; |
| 6981 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6982 | SLIC_SetState(PLD_SLIC_STATE_STANDBY, j); |
| 6983 | /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */ |
| 6984 | j->port = PORT_POTS; |
| 6985 | } |
| 6986 | ixj_set_port(j, PORT_PSTN); |
| 6987 | ixj_set_pots(j, 1); |
| 6988 | if (ixjdebug & 0x0002) |
| 6989 | printk(KERN_INFO "Enable Mixer\n"); |
| 6990 | ixj_mixer(0x0000, j); /*Master Volume Left unmute 0db */ |
| 6991 | ixj_mixer(0x0100, j); /*Master Volume Right unmute 0db */ |
| 6992 | |
| 6993 | ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */ |
| 6994 | ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */ |
| 6995 | |
| 6996 | ixj_mixer(0x0480, j); /*FM Left mute */ |
| 6997 | ixj_mixer(0x0580, j); /*FM Right mute */ |
| 6998 | |
| 6999 | ixj_mixer(0x0680, j); /*CD Left mute */ |
| 7000 | ixj_mixer(0x0780, j); /*CD Right mute */ |
| 7001 | |
| 7002 | ixj_mixer(0x0880, j); /*Line Left mute */ |
| 7003 | ixj_mixer(0x0980, j); /*Line Right mute */ |
| 7004 | |
| 7005 | ixj_mixer(0x0A80, j); /*Aux left mute */ |
| 7006 | ixj_mixer(0x0B80, j); /*Aux right mute */ |
| 7007 | |
| 7008 | ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */ |
| 7009 | ixj_mixer(0x0D80, j); /*Mono2 mute */ |
| 7010 | |
| 7011 | ixj_mixer(0x0E80, j); /*Mic mute */ |
| 7012 | |
| 7013 | ixj_mixer(0x0F00, j); /*Mono Out Volume unmute 0db */ |
| 7014 | |
| 7015 | ixj_mixer(0x1000, j); /*Voice Left and Right out only */ |
| 7016 | ixj_mixer(0x110C, j); |
| 7017 | |
| 7018 | |
| 7019 | ixj_mixer(0x1200, j); /*Mono1 switch on mixer left */ |
| 7020 | ixj_mixer(0x1401, j); |
| 7021 | |
| 7022 | ixj_mixer(0x1300, j); /*Mono1 switch on mixer right */ |
| 7023 | ixj_mixer(0x1501, j); |
| 7024 | |
| 7025 | ixj_mixer(0x1700, j); /*Clock select */ |
| 7026 | |
| 7027 | ixj_mixer(0x1800, j); /*ADC input from mixer */ |
| 7028 | |
| 7029 | ixj_mixer(0x1901, j); /*Mic gain 30db */ |
| 7030 | |
| 7031 | if (ixjdebug & 0x0002) |
| 7032 | printk(KERN_INFO "Setting Default US Ring Cadence Detection\n"); |
| 7033 | j->cadence_f[4].state = 0; |
| 7034 | j->cadence_f[4].on1 = 0; /*Cadence Filter 4 is used for PSTN ring cadence */ |
| 7035 | j->cadence_f[4].off1 = 0; |
| 7036 | j->cadence_f[4].on2 = 0; |
| 7037 | j->cadence_f[4].off2 = 0; |
| 7038 | j->cadence_f[4].on3 = 0; |
| 7039 | j->cadence_f[4].off3 = 0; /* These should represent standard US ring pulse. */ |
| 7040 | j->pstn_last_rmr = jiffies; |
| 7041 | |
| 7042 | } else { |
| 7043 | if (j->cardtype == QTI_PHONECARD) { |
| 7044 | ixj_WriteDSPCommand(0xCF07, j); |
| 7045 | ixj_WriteDSPCommand(0x00B0, j); |
| 7046 | ixj_set_port(j, PORT_SPEAKER); |
| 7047 | } else { |
| 7048 | ixj_set_port(j, PORT_POTS); |
| 7049 | SLIC_SetState(PLD_SLIC_STATE_STANDBY, j); |
| 7050 | /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */ |
| 7051 | } |
| 7052 | } |
| 7053 | } |
| 7054 | |
| 7055 | j->intercom = -1; |
| 7056 | j->framesread = j->frameswritten = 0; |
| 7057 | j->read_wait = j->write_wait = 0; |
| 7058 | j->rxreadycheck = j->txreadycheck = 0; |
| 7059 | |
| 7060 | /* initialise the DTMF prescale to a sensible value */ |
| 7061 | if (j->cardtype == QTI_LINEJACK) { |
| 7062 | set_dtmf_prescale(j, 0x10); |
| 7063 | } else { |
| 7064 | set_dtmf_prescale(j, 0x40); |
| 7065 | } |
| 7066 | set_play_volume(j, 0x100); |
| 7067 | set_rec_volume(j, 0x100); |
| 7068 | |
| 7069 | if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */ |
| 7070 | return -1; |
| 7071 | /* The read values of the SSR should be 0x00 for the IDLE command */ |
| 7072 | if (j->ssr.low || j->ssr.high) |
| 7073 | return -1; |
| 7074 | |
| 7075 | if (ixjdebug & 0x0002) |
| 7076 | printk(KERN_INFO "Enable Line Monitor\n"); |
| 7077 | |
| 7078 | if (ixjdebug & 0x0002) |
| 7079 | printk(KERN_INFO "Set Line Monitor to Asyncronous Mode\n"); |
| 7080 | |
| 7081 | if (ixj_WriteDSPCommand(0x7E01, j)) /* Asynchronous Line Monitor */ |
| 7082 | return -1; |
| 7083 | |
| 7084 | if (ixjdebug & 0x002) |
| 7085 | printk(KERN_INFO "Enable DTMF Detectors\n"); |
| 7086 | |
| 7087 | if (ixj_WriteDSPCommand(0x5151, j)) /* Enable DTMF detection */ |
| 7088 | return -1; |
| 7089 | |
| 7090 | if (ixj_WriteDSPCommand(0x6E01, j)) /* Set Asyncronous Tone Generation */ |
| 7091 | return -1; |
| 7092 | |
| 7093 | set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */ |
| 7094 | |
| 7095 | set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */ |
| 7096 | |
| 7097 | j->ex.bits.dtmf_ready = 0; |
| 7098 | j->dtmf_state = 0; |
| 7099 | j->dtmf_wp = j->dtmf_rp = 0; |
| 7100 | j->rec_mode = j->play_mode = -1; |
| 7101 | j->flags.ringing = 0; |
| 7102 | j->maxrings = MAXRINGS; |
| 7103 | j->ring_cadence = USA_RING_CADENCE; |
| 7104 | j->drybuffer = 0; |
| 7105 | j->winktime = 320; |
| 7106 | j->flags.dtmf_oob = 0; |
| 7107 | for (cnt = 0; cnt < 4; cnt++) |
| 7108 | j->cadence_f[cnt].enable = 0; |
| 7109 | /* must be a device on the specified address */ |
| 7110 | ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */ |
| 7111 | |
| 7112 | /* Set up the default signals for events */ |
| 7113 | for (cnt = 0; cnt < 35; cnt++) |
| 7114 | j->ixj_signals[cnt] = SIGIO; |
| 7115 | |
| 7116 | /* Set the excetion signal enable flags */ |
| 7117 | j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring = |
| 7118 | 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 = |
| 7119 | 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; |
| 7120 | #ifdef IXJ_DYN_ALLOC |
| 7121 | j->fskdata = NULL; |
| 7122 | #endif |
| 7123 | j->fskdcnt = 0; |
| 7124 | j->cidcw_wait = 0; |
| 7125 | |
| 7126 | /* Register with the Telephony for Linux subsystem */ |
| 7127 | j->p.f_op = &ixj_fops; |
| 7128 | j->p.open = ixj_open; |
| 7129 | j->p.board = j->board; |
| 7130 | phone_register_device(&j->p, PHONE_UNIT_ANY); |
| 7131 | |
| 7132 | ixj_init_timer(j); |
| 7133 | ixj_add_timer(j); |
| 7134 | return 0; |
| 7135 | } |
| 7136 | |
| 7137 | /* |
| 7138 | * Exported service for pcmcia card handling |
| 7139 | */ |
| 7140 | |
| 7141 | IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx) |
| 7142 | { |
| 7143 | IXJ *j = ixj_alloc(); |
| 7144 | |
| 7145 | j->board = 0; |
| 7146 | |
| 7147 | j->DSPbase = dsp; |
| 7148 | j->XILINXbase = xilinx; |
| 7149 | j->cardtype = QTI_PHONECARD; |
| 7150 | ixj_selfprobe(j); |
| 7151 | return j; |
| 7152 | } |
| 7153 | |
| 7154 | EXPORT_SYMBOL(ixj_pcmcia_probe); /* Fpr PCMCIA */ |
| 7155 | |
| 7156 | static int ixj_get_status_proc(char *buf) |
| 7157 | { |
| 7158 | int len; |
| 7159 | int cnt; |
| 7160 | IXJ *j; |
| 7161 | len = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7162 | len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER); |
| 7163 | len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ)); |
| 7164 | len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS)); |
| 7165 | len += sprintf(buf + len, "\nUsing old telephony API"); |
| 7166 | len += sprintf(buf + len, "\nDebug Level %d\n", ixjdebug); |
| 7167 | |
| 7168 | for (cnt = 0; cnt < IXJMAX; cnt++) { |
| 7169 | j = get_ixj(cnt); |
| 7170 | if(j==NULL) |
| 7171 | continue; |
| 7172 | if (j->DSPbase) { |
| 7173 | len += sprintf(buf + len, "\nCard Num %d", cnt); |
| 7174 | len += sprintf(buf + len, "\nDSP Base Address 0x%4.4x", j->DSPbase); |
| 7175 | if (j->cardtype != QTI_PHONEJACK) |
| 7176 | len += sprintf(buf + len, "\nXILINX Base Address 0x%4.4x", j->XILINXbase); |
| 7177 | len += sprintf(buf + len, "\nDSP Type %2.2x%2.2x", j->dsp.high, j->dsp.low); |
| 7178 | len += sprintf(buf + len, "\nDSP Version %2.2x.%2.2x", j->ver.high, j->ver.low); |
| 7179 | len += sprintf(buf + len, "\nSerial Number %8.8x", j->serial); |
| 7180 | switch (j->cardtype) { |
| 7181 | case (QTI_PHONEJACK): |
| 7182 | len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK"); |
| 7183 | break; |
| 7184 | case (QTI_LINEJACK): |
| 7185 | len += sprintf(buf + len, "\nCard Type = Internet LineJACK"); |
| 7186 | if (j->flags.g729_loaded) |
| 7187 | len += sprintf(buf + len, " w/G.729 A/B"); |
| 7188 | len += sprintf(buf + len, " Country = %d", j->daa_country); |
| 7189 | break; |
| 7190 | case (QTI_PHONEJACK_LITE): |
| 7191 | len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK Lite"); |
| 7192 | if (j->flags.g729_loaded) |
| 7193 | len += sprintf(buf + len, " w/G.729 A/B"); |
| 7194 | break; |
| 7195 | case (QTI_PHONEJACK_PCI): |
| 7196 | len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK PCI"); |
| 7197 | if (j->flags.g729_loaded) |
| 7198 | len += sprintf(buf + len, " w/G.729 A/B"); |
| 7199 | break; |
| 7200 | case (QTI_PHONECARD): |
| 7201 | len += sprintf(buf + len, "\nCard Type = Internet PhoneCARD"); |
| 7202 | if (j->flags.g729_loaded) |
| 7203 | len += sprintf(buf + len, " w/G.729 A/B"); |
| 7204 | len += sprintf(buf + len, "\nSmart Cable %spresent", j->pccr1.bits.drf ? "not " : ""); |
| 7205 | if (!j->pccr1.bits.drf) |
| 7206 | len += sprintf(buf + len, "\nSmart Cable type %d", j->flags.pcmciasct); |
| 7207 | len += sprintf(buf + len, "\nSmart Cable state %d", j->flags.pcmciastate); |
| 7208 | break; |
| 7209 | default: |
| 7210 | len += sprintf(buf + len, "\nCard Type = %d", j->cardtype); |
| 7211 | break; |
| 7212 | } |
| 7213 | len += sprintf(buf + len, "\nReaders %d", j->readers); |
| 7214 | len += sprintf(buf + len, "\nWriters %d", j->writers); |
| 7215 | add_caps(j); |
| 7216 | len += sprintf(buf + len, "\nCapabilities %d", j->caps); |
| 7217 | if (j->dsp.low != 0x20) |
| 7218 | len += sprintf(buf + len, "\nDSP Processor load %d", j->proc_load); |
| 7219 | if (j->flags.cidsent) |
| 7220 | len += sprintf(buf + len, "\nCaller ID data sent"); |
| 7221 | else |
| 7222 | len += sprintf(buf + len, "\nCaller ID data not sent"); |
| 7223 | |
| 7224 | len += sprintf(buf + len, "\nPlay CODEC "); |
| 7225 | switch (j->play_codec) { |
| 7226 | case G723_63: |
| 7227 | len += sprintf(buf + len, "G.723.1 6.3"); |
| 7228 | break; |
| 7229 | case G723_53: |
| 7230 | len += sprintf(buf + len, "G.723.1 5.3"); |
| 7231 | break; |
| 7232 | case TS85: |
| 7233 | len += sprintf(buf + len, "TrueSpeech 8.5"); |
| 7234 | break; |
| 7235 | case TS48: |
| 7236 | len += sprintf(buf + len, "TrueSpeech 4.8"); |
| 7237 | break; |
| 7238 | case TS41: |
| 7239 | len += sprintf(buf + len, "TrueSpeech 4.1"); |
| 7240 | break; |
| 7241 | case G728: |
| 7242 | len += sprintf(buf + len, "G.728"); |
| 7243 | break; |
| 7244 | case G729: |
| 7245 | len += sprintf(buf + len, "G.729"); |
| 7246 | break; |
| 7247 | case G729B: |
| 7248 | len += sprintf(buf + len, "G.729B"); |
| 7249 | break; |
| 7250 | case ULAW: |
| 7251 | len += sprintf(buf + len, "uLaw"); |
| 7252 | break; |
| 7253 | case ALAW: |
| 7254 | len += sprintf(buf + len, "aLaw"); |
| 7255 | break; |
| 7256 | case LINEAR16: |
| 7257 | len += sprintf(buf + len, "16 bit Linear"); |
| 7258 | break; |
| 7259 | case LINEAR8: |
| 7260 | len += sprintf(buf + len, "8 bit Linear"); |
| 7261 | break; |
| 7262 | case WSS: |
| 7263 | len += sprintf(buf + len, "Windows Sound System"); |
| 7264 | break; |
| 7265 | default: |
| 7266 | len += sprintf(buf + len, "NO CODEC CHOSEN"); |
| 7267 | break; |
| 7268 | } |
| 7269 | len += sprintf(buf + len, "\nRecord CODEC "); |
| 7270 | switch (j->rec_codec) { |
| 7271 | case G723_63: |
| 7272 | len += sprintf(buf + len, "G.723.1 6.3"); |
| 7273 | break; |
| 7274 | case G723_53: |
| 7275 | len += sprintf(buf + len, "G.723.1 5.3"); |
| 7276 | break; |
| 7277 | case TS85: |
| 7278 | len += sprintf(buf + len, "TrueSpeech 8.5"); |
| 7279 | break; |
| 7280 | case TS48: |
| 7281 | len += sprintf(buf + len, "TrueSpeech 4.8"); |
| 7282 | break; |
| 7283 | case TS41: |
| 7284 | len += sprintf(buf + len, "TrueSpeech 4.1"); |
| 7285 | break; |
| 7286 | case G728: |
| 7287 | len += sprintf(buf + len, "G.728"); |
| 7288 | break; |
| 7289 | case G729: |
| 7290 | len += sprintf(buf + len, "G.729"); |
| 7291 | break; |
| 7292 | case G729B: |
| 7293 | len += sprintf(buf + len, "G.729B"); |
| 7294 | break; |
| 7295 | case ULAW: |
| 7296 | len += sprintf(buf + len, "uLaw"); |
| 7297 | break; |
| 7298 | case ALAW: |
| 7299 | len += sprintf(buf + len, "aLaw"); |
| 7300 | break; |
| 7301 | case LINEAR16: |
| 7302 | len += sprintf(buf + len, "16 bit Linear"); |
| 7303 | break; |
| 7304 | case LINEAR8: |
| 7305 | len += sprintf(buf + len, "8 bit Linear"); |
| 7306 | break; |
| 7307 | case WSS: |
| 7308 | len += sprintf(buf + len, "Windows Sound System"); |
| 7309 | break; |
| 7310 | default: |
| 7311 | len += sprintf(buf + len, "NO CODEC CHOSEN"); |
| 7312 | break; |
| 7313 | } |
| 7314 | len += sprintf(buf + len, "\nAEC "); |
| 7315 | switch (j->aec_level) { |
| 7316 | case AEC_OFF: |
| 7317 | len += sprintf(buf + len, "Off"); |
| 7318 | break; |
| 7319 | case AEC_LOW: |
| 7320 | len += sprintf(buf + len, "Low"); |
| 7321 | break; |
| 7322 | case AEC_MED: |
| 7323 | len += sprintf(buf + len, "Med"); |
| 7324 | break; |
| 7325 | case AEC_HIGH: |
| 7326 | len += sprintf(buf + len, "High"); |
| 7327 | break; |
| 7328 | case AEC_AUTO: |
| 7329 | len += sprintf(buf + len, "Auto"); |
| 7330 | break; |
| 7331 | case AEC_AGC: |
| 7332 | len += sprintf(buf + len, "AEC/AGC"); |
| 7333 | break; |
| 7334 | default: |
| 7335 | len += sprintf(buf + len, "unknown(%i)", j->aec_level); |
| 7336 | break; |
| 7337 | } |
| 7338 | |
| 7339 | len += sprintf(buf + len, "\nRec volume 0x%x", get_rec_volume(j)); |
| 7340 | len += sprintf(buf + len, "\nPlay volume 0x%x", get_play_volume(j)); |
| 7341 | len += sprintf(buf + len, "\nDTMF prescale 0x%x", get_dtmf_prescale(j)); |
| 7342 | |
| 7343 | len += sprintf(buf + len, "\nHook state %d", j->hookstate); /* j->r_hook); */ |
| 7344 | |
| 7345 | if (j->cardtype == QTI_LINEJACK) { |
| 7346 | len += sprintf(buf + len, "\nPOTS Correct %d", j->flags.pots_correct); |
| 7347 | len += sprintf(buf + len, "\nPSTN Present %d", j->flags.pstn_present); |
| 7348 | len += sprintf(buf + len, "\nPSTN Check %d", j->flags.pstncheck); |
| 7349 | len += sprintf(buf + len, "\nPOTS to PSTN %d", j->flags.pots_pstn); |
| 7350 | switch (j->daa_mode) { |
| 7351 | case SOP_PU_SLEEP: |
| 7352 | len += sprintf(buf + len, "\nDAA PSTN On Hook"); |
| 7353 | break; |
| 7354 | case SOP_PU_RINGING: |
| 7355 | len += sprintf(buf + len, "\nDAA PSTN Ringing"); |
| 7356 | len += sprintf(buf + len, "\nRinging state = %d", j->cadence_f[4].state); |
| 7357 | break; |
| 7358 | case SOP_PU_CONVERSATION: |
| 7359 | len += sprintf(buf + len, "\nDAA PSTN Off Hook"); |
| 7360 | break; |
| 7361 | case SOP_PU_PULSEDIALING: |
| 7362 | len += sprintf(buf + len, "\nDAA PSTN Pulse Dialing"); |
| 7363 | break; |
| 7364 | } |
| 7365 | len += sprintf(buf + len, "\nDAA RMR = %d", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR); |
| 7366 | len += sprintf(buf + len, "\nDAA VDD OK = %d", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK); |
| 7367 | len += sprintf(buf + len, "\nDAA CR0 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg); |
| 7368 | len += sprintf(buf + len, "\nDAA CR1 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg); |
| 7369 | len += sprintf(buf + len, "\nDAA CR2 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg); |
| 7370 | len += sprintf(buf + len, "\nDAA CR3 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg); |
| 7371 | len += sprintf(buf + len, "\nDAA CR4 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg); |
| 7372 | len += sprintf(buf + len, "\nDAA CR5 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg); |
| 7373 | len += sprintf(buf + len, "\nDAA XR0 = 0x%02x", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg); |
| 7374 | len += sprintf(buf + len, "\nDAA ringstop %ld - jiffies %ld", j->pstn_ring_stop, jiffies); |
| 7375 | } |
| 7376 | switch (j->port) { |
| 7377 | case PORT_POTS: |
| 7378 | len += sprintf(buf + len, "\nPort POTS"); |
| 7379 | break; |
| 7380 | case PORT_PSTN: |
| 7381 | len += sprintf(buf + len, "\nPort PSTN"); |
| 7382 | break; |
| 7383 | case PORT_SPEAKER: |
| 7384 | len += sprintf(buf + len, "\nPort SPEAKER/MIC"); |
| 7385 | break; |
| 7386 | case PORT_HANDSET: |
| 7387 | len += sprintf(buf + len, "\nPort HANDSET"); |
| 7388 | break; |
| 7389 | } |
| 7390 | if (j->dsp.low == 0x21 || j->dsp.low == 0x22) { |
| 7391 | len += sprintf(buf + len, "\nSLIC state "); |
| 7392 | switch (SLIC_GetState(j)) { |
| 7393 | case PLD_SLIC_STATE_OC: |
| 7394 | len += sprintf(buf + len, "OC"); |
| 7395 | break; |
| 7396 | case PLD_SLIC_STATE_RINGING: |
| 7397 | len += sprintf(buf + len, "RINGING"); |
| 7398 | break; |
| 7399 | case PLD_SLIC_STATE_ACTIVE: |
| 7400 | len += sprintf(buf + len, "ACTIVE"); |
| 7401 | break; |
| 7402 | case PLD_SLIC_STATE_OHT: /* On-hook transmit */ |
| 7403 | len += sprintf(buf + len, "OHT"); |
| 7404 | break; |
| 7405 | case PLD_SLIC_STATE_TIPOPEN: |
| 7406 | len += sprintf(buf + len, "TIPOPEN"); |
| 7407 | break; |
| 7408 | case PLD_SLIC_STATE_STANDBY: |
| 7409 | len += sprintf(buf + len, "STANDBY"); |
| 7410 | break; |
| 7411 | case PLD_SLIC_STATE_APR: /* Active polarity reversal */ |
| 7412 | len += sprintf(buf + len, "APR"); |
| 7413 | break; |
| 7414 | case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */ |
| 7415 | len += sprintf(buf + len, "OHTPR"); |
| 7416 | break; |
| 7417 | default: |
| 7418 | len += sprintf(buf + len, "%d", SLIC_GetState(j)); |
| 7419 | break; |
| 7420 | } |
| 7421 | } |
| 7422 | len += sprintf(buf + len, "\nBase Frame %2.2x.%2.2x", j->baseframe.high, j->baseframe.low); |
| 7423 | len += sprintf(buf + len, "\nCID Base Frame %2d", j->cid_base_frame_size); |
| 7424 | #ifdef PERFMON_STATS |
| 7425 | len += sprintf(buf + len, "\nTimer Checks %ld", j->timerchecks); |
| 7426 | len += sprintf(buf + len, "\nRX Ready Checks %ld", j->rxreadycheck); |
| 7427 | len += sprintf(buf + len, "\nTX Ready Checks %ld", j->txreadycheck); |
| 7428 | len += sprintf(buf + len, "\nFrames Read %ld", j->framesread); |
| 7429 | len += sprintf(buf + len, "\nFrames Written %ld", j->frameswritten); |
| 7430 | len += sprintf(buf + len, "\nDry Buffer %ld", j->drybuffer); |
| 7431 | len += sprintf(buf + len, "\nRead Waits %ld", j->read_wait); |
| 7432 | len += sprintf(buf + len, "\nWrite Waits %ld", j->write_wait); |
| 7433 | len += sprintf(buf + len, "\nStatus Waits %ld", j->statuswait); |
| 7434 | len += sprintf(buf + len, "\nStatus Wait Fails %ld", j->statuswaitfail); |
| 7435 | len += sprintf(buf + len, "\nPControl Waits %ld", j->pcontrolwait); |
| 7436 | len += sprintf(buf + len, "\nPControl Wait Fails %ld", j->pcontrolwaitfail); |
| 7437 | len += sprintf(buf + len, "\nIs Control Ready Checks %ld", j->iscontrolready); |
| 7438 | len += sprintf(buf + len, "\nIs Control Ready Check failures %ld", j->iscontrolreadyfail); |
| 7439 | |
| 7440 | #endif |
| 7441 | len += sprintf(buf + len, "\n"); |
| 7442 | } |
| 7443 | } |
| 7444 | return len; |
| 7445 | } |
| 7446 | |
| 7447 | static int ixj_read_proc(char *page, char **start, off_t off, |
| 7448 | int count, int *eof, void *data) |
| 7449 | { |
| 7450 | int len = ixj_get_status_proc(page); |
| 7451 | if (len <= off+count) *eof = 1; |
| 7452 | *start = page + off; |
| 7453 | len -= off; |
| 7454 | if (len>count) len = count; |
| 7455 | if (len<0) len = 0; |
| 7456 | return len; |
| 7457 | } |
| 7458 | |
| 7459 | |
| 7460 | static void cleanup(void) |
| 7461 | { |
| 7462 | int cnt; |
| 7463 | IXJ *j; |
| 7464 | |
| 7465 | for (cnt = 0; cnt < IXJMAX; cnt++) { |
| 7466 | j = get_ixj(cnt); |
| 7467 | if(j != NULL && j->DSPbase) { |
| 7468 | if (ixjdebug & 0x0002) |
| 7469 | printk(KERN_INFO "IXJ: Deleting timer for /dev/phone%d\n", cnt); |
| 7470 | del_timer(&j->timer); |
| 7471 | if (j->cardtype == QTI_LINEJACK) { |
| 7472 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 7473 | |
| 7474 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 7475 | j->pld_slicw.bits.rly1 = 0; |
| 7476 | j->pld_slicw.bits.rly2 = 0; |
| 7477 | j->pld_slicw.bits.rly3 = 0; |
| 7478 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 7479 | LED_SetState(0x0, j); |
| 7480 | if (ixjdebug & 0x0002) |
| 7481 | printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt); |
| 7482 | release_region(j->XILINXbase, 8); |
| 7483 | } else if (j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) { |
| 7484 | if (ixjdebug & 0x0002) |
| 7485 | printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt); |
| 7486 | release_region(j->XILINXbase, 4); |
| 7487 | } |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 7488 | kfree(j->read_buffer); |
| 7489 | kfree(j->write_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7490 | if (j->dev) |
| 7491 | pnp_device_detach(j->dev); |
| 7492 | if (ixjdebug & 0x0002) |
| 7493 | printk(KERN_INFO "IXJ: Unregistering /dev/phone%d from LTAPI\n", cnt); |
| 7494 | phone_unregister_device(&j->p); |
| 7495 | if (ixjdebug & 0x0002) |
| 7496 | printk(KERN_INFO "IXJ: Releasing DSP address for /dev/phone%d\n", cnt); |
| 7497 | release_region(j->DSPbase, 16); |
| 7498 | #ifdef IXJ_DYN_ALLOC |
| 7499 | if (ixjdebug & 0x0002) |
| 7500 | printk(KERN_INFO "IXJ: Freeing memory for /dev/phone%d\n", cnt); |
| 7501 | kfree(j); |
| 7502 | ixj[cnt] = NULL; |
| 7503 | #endif |
| 7504 | } |
| 7505 | } |
| 7506 | if (ixjdebug & 0x0002) |
| 7507 | printk(KERN_INFO "IXJ: Removing /proc/ixj\n"); |
| 7508 | remove_proc_entry ("ixj", NULL); |
| 7509 | } |
| 7510 | |
| 7511 | /* Typedefs */ |
| 7512 | typedef struct { |
| 7513 | BYTE length; |
| 7514 | DWORD bits; |
| 7515 | } DATABLOCK; |
| 7516 | |
| 7517 | static void PCIEE_WriteBit(WORD wEEPROMAddress, BYTE lastLCC, BYTE byData) |
| 7518 | { |
| 7519 | lastLCC = lastLCC & 0xfb; |
| 7520 | lastLCC = lastLCC | (byData ? 4 : 0); |
| 7521 | outb(lastLCC, wEEPROMAddress); /*set data out bit as appropriate */ |
| 7522 | |
| 7523 | mdelay(1); |
| 7524 | lastLCC = lastLCC | 0x01; |
| 7525 | outb(lastLCC, wEEPROMAddress); /*SK rising edge */ |
| 7526 | |
| 7527 | byData = byData << 1; |
| 7528 | lastLCC = lastLCC & 0xfe; |
| 7529 | mdelay(1); |
| 7530 | outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */ |
| 7531 | |
| 7532 | } |
| 7533 | |
| 7534 | static BYTE PCIEE_ReadBit(WORD wEEPROMAddress, BYTE lastLCC) |
| 7535 | { |
| 7536 | mdelay(1); |
| 7537 | lastLCC = lastLCC | 0x01; |
| 7538 | outb(lastLCC, wEEPROMAddress); /*SK rising edge */ |
| 7539 | |
| 7540 | lastLCC = lastLCC & 0xfe; |
| 7541 | mdelay(1); |
| 7542 | outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */ |
| 7543 | |
| 7544 | return ((inb(wEEPROMAddress) >> 3) & 1); |
| 7545 | } |
| 7546 | |
| 7547 | static BOOL PCIEE_ReadWord(WORD wAddress, WORD wLoc, WORD * pwResult) |
| 7548 | { |
| 7549 | BYTE lastLCC; |
| 7550 | WORD wEEPROMAddress = wAddress + 3; |
| 7551 | DWORD i; |
| 7552 | BYTE byResult; |
| 7553 | *pwResult = 0; |
| 7554 | lastLCC = inb(wEEPROMAddress); |
| 7555 | lastLCC = lastLCC | 0x02; |
| 7556 | lastLCC = lastLCC & 0xfe; |
| 7557 | outb(lastLCC, wEEPROMAddress); /* CS hi, SK lo */ |
| 7558 | |
| 7559 | mdelay(1); /* delay */ |
| 7560 | |
| 7561 | PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1); |
| 7562 | PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1); |
| 7563 | PCIEE_WriteBit(wEEPROMAddress, lastLCC, 0); |
| 7564 | for (i = 0; i < 8; i++) { |
| 7565 | PCIEE_WriteBit(wEEPROMAddress, lastLCC, wLoc & 0x80 ? 1 : 0); |
| 7566 | wLoc <<= 1; |
| 7567 | } |
| 7568 | |
| 7569 | for (i = 0; i < 16; i++) { |
| 7570 | byResult = PCIEE_ReadBit(wEEPROMAddress, lastLCC); |
| 7571 | *pwResult = (*pwResult << 1) | byResult; |
| 7572 | } |
| 7573 | |
| 7574 | mdelay(1); /* another delay */ |
| 7575 | |
| 7576 | lastLCC = lastLCC & 0xfd; |
| 7577 | outb(lastLCC, wEEPROMAddress); /* negate CS */ |
| 7578 | |
| 7579 | return 0; |
| 7580 | } |
| 7581 | |
| 7582 | static DWORD PCIEE_GetSerialNumber(WORD wAddress) |
| 7583 | { |
| 7584 | WORD wLo, wHi; |
| 7585 | if (PCIEE_ReadWord(wAddress, 62, &wLo)) |
| 7586 | return 0; |
| 7587 | if (PCIEE_ReadWord(wAddress, 63, &wHi)) |
| 7588 | return 0; |
| 7589 | return (((DWORD) wHi << 16) | wLo); |
| 7590 | } |
| 7591 | |
| 7592 | static int dspio[IXJMAX + 1] = |
| 7593 | { |
| 7594 | 0, |
| 7595 | }; |
| 7596 | static int xio[IXJMAX + 1] = |
| 7597 | { |
| 7598 | 0, |
| 7599 | }; |
| 7600 | |
| 7601 | module_param_array(dspio, int, NULL, 0); |
| 7602 | module_param_array(xio, int, NULL, 0); |
| 7603 | MODULE_DESCRIPTION("Quicknet VoIP Telephony card module - www.quicknet.net"); |
| 7604 | MODULE_AUTHOR("Ed Okerson <eokerson@quicknet.net>"); |
| 7605 | MODULE_LICENSE("GPL"); |
| 7606 | |
| 7607 | static void __exit ixj_exit(void) |
| 7608 | { |
| 7609 | cleanup(); |
| 7610 | } |
| 7611 | |
| 7612 | static IXJ *new_ixj(unsigned long port) |
| 7613 | { |
| 7614 | IXJ *res; |
| 7615 | if (!request_region(port, 16, "ixj DSP")) { |
| 7616 | printk(KERN_INFO "ixj: can't get I/O address 0x%lx\n", port); |
| 7617 | return NULL; |
| 7618 | } |
| 7619 | res = ixj_alloc(); |
| 7620 | if (!res) { |
| 7621 | release_region(port, 16); |
| 7622 | printk(KERN_INFO "ixj: out of memory\n"); |
| 7623 | return NULL; |
| 7624 | } |
| 7625 | res->DSPbase = port; |
| 7626 | return res; |
| 7627 | } |
| 7628 | |
| 7629 | static int __init ixj_probe_isapnp(int *cnt) |
| 7630 | { |
| 7631 | int probe = 0; |
| 7632 | int func = 0x110; |
| 7633 | struct pnp_dev *dev = NULL, *old_dev = NULL; |
| 7634 | |
| 7635 | while (1) { |
| 7636 | do { |
| 7637 | IXJ *j; |
| 7638 | int result; |
| 7639 | |
| 7640 | old_dev = dev; |
| 7641 | dev = pnp_find_dev(NULL, ISAPNP_VENDOR('Q', 'T', 'I'), |
| 7642 | ISAPNP_FUNCTION(func), old_dev); |
| 7643 | if (!dev || !dev->card) |
| 7644 | break; |
| 7645 | result = pnp_device_attach(dev); |
| 7646 | if (result < 0) { |
| 7647 | printk("pnp attach failed %d \n", result); |
| 7648 | break; |
| 7649 | } |
| 7650 | if (pnp_activate_dev(dev) < 0) { |
| 7651 | printk("pnp activate failed (out of resources?)\n"); |
| 7652 | pnp_device_detach(dev); |
| 7653 | return -ENOMEM; |
| 7654 | } |
| 7655 | |
| 7656 | if (!pnp_port_valid(dev, 0)) { |
| 7657 | pnp_device_detach(dev); |
| 7658 | return -ENODEV; |
| 7659 | } |
| 7660 | |
| 7661 | j = new_ixj(pnp_port_start(dev, 0)); |
| 7662 | if (!j) |
| 7663 | break; |
| 7664 | |
| 7665 | if (func != 0x110) |
| 7666 | j->XILINXbase = pnp_port_start(dev, 1); /* get real port */ |
| 7667 | |
| 7668 | switch (func) { |
| 7669 | case (0x110): |
| 7670 | j->cardtype = QTI_PHONEJACK; |
| 7671 | break; |
| 7672 | case (0x310): |
| 7673 | j->cardtype = QTI_LINEJACK; |
| 7674 | break; |
| 7675 | case (0x410): |
| 7676 | j->cardtype = QTI_PHONEJACK_LITE; |
| 7677 | break; |
| 7678 | } |
| 7679 | j->board = *cnt; |
| 7680 | probe = ixj_selfprobe(j); |
| 7681 | if(!probe) { |
| 7682 | j->serial = dev->card->serial; |
| 7683 | j->dev = dev; |
| 7684 | switch (func) { |
| 7685 | case 0x110: |
| 7686 | printk(KERN_INFO "ixj: found Internet PhoneJACK at 0x%x\n", j->DSPbase); |
| 7687 | break; |
| 7688 | case 0x310: |
| 7689 | printk(KERN_INFO "ixj: found Internet LineJACK at 0x%x\n", j->DSPbase); |
| 7690 | break; |
| 7691 | case 0x410: |
| 7692 | printk(KERN_INFO "ixj: found Internet PhoneJACK Lite at 0x%x\n", j->DSPbase); |
| 7693 | break; |
| 7694 | } |
| 7695 | } |
| 7696 | ++*cnt; |
| 7697 | } while (dev); |
| 7698 | if (func == 0x410) |
| 7699 | break; |
| 7700 | if (func == 0x310) |
| 7701 | func = 0x410; |
| 7702 | if (func == 0x110) |
| 7703 | func = 0x310; |
| 7704 | dev = NULL; |
| 7705 | } |
| 7706 | return probe; |
| 7707 | } |
| 7708 | |
| 7709 | static int __init ixj_probe_isa(int *cnt) |
| 7710 | { |
| 7711 | int i, probe; |
| 7712 | |
| 7713 | /* Use passed parameters for older kernels without PnP */ |
| 7714 | for (i = 0; i < IXJMAX; i++) { |
| 7715 | if (dspio[i]) { |
| 7716 | IXJ *j = new_ixj(dspio[i]); |
| 7717 | |
| 7718 | if (!j) |
| 7719 | break; |
| 7720 | |
| 7721 | j->XILINXbase = xio[i]; |
| 7722 | j->cardtype = 0; |
| 7723 | |
| 7724 | j->board = *cnt; |
| 7725 | probe = ixj_selfprobe(j); |
| 7726 | j->dev = NULL; |
| 7727 | ++*cnt; |
| 7728 | } |
| 7729 | } |
| 7730 | return 0; |
| 7731 | } |
| 7732 | |
| 7733 | static int __init ixj_probe_pci(int *cnt) |
| 7734 | { |
| 7735 | struct pci_dev *pci = NULL; |
| 7736 | int i, probe = 0; |
| 7737 | IXJ *j = NULL; |
| 7738 | |
| 7739 | for (i = 0; i < IXJMAX - *cnt; i++) { |
| 7740 | pci = pci_find_device(0x15E2, 0x0500, pci); |
| 7741 | if (!pci) |
| 7742 | break; |
| 7743 | |
| 7744 | if (pci_enable_device(pci)) |
| 7745 | break; |
| 7746 | j = new_ixj(pci_resource_start(pci, 0)); |
| 7747 | if (!j) |
| 7748 | break; |
| 7749 | |
| 7750 | j->serial = (PCIEE_GetSerialNumber)pci_resource_start(pci, 2); |
| 7751 | j->XILINXbase = j->DSPbase + 0x10; |
| 7752 | j->cardtype = QTI_PHONEJACK_PCI; |
| 7753 | j->board = *cnt; |
| 7754 | probe = ixj_selfprobe(j); |
| 7755 | if (!probe) |
| 7756 | printk(KERN_INFO "ixj: found Internet PhoneJACK PCI at 0x%x\n", j->DSPbase); |
| 7757 | ++*cnt; |
| 7758 | } |
| 7759 | return probe; |
| 7760 | } |
| 7761 | |
| 7762 | static int __init ixj_init(void) |
| 7763 | { |
| 7764 | int cnt = 0; |
| 7765 | int probe = 0; |
| 7766 | |
| 7767 | cnt = 0; |
| 7768 | |
| 7769 | /* These might be no-ops, see above. */ |
| 7770 | if ((probe = ixj_probe_isapnp(&cnt)) < 0) { |
| 7771 | return probe; |
| 7772 | } |
| 7773 | if ((probe = ixj_probe_isa(&cnt)) < 0) { |
| 7774 | return probe; |
| 7775 | } |
| 7776 | if ((probe = ixj_probe_pci(&cnt)) < 0) { |
| 7777 | return probe; |
| 7778 | } |
Domen Puncer | fba478b | 2005-05-05 16:16:13 -0700 | [diff] [blame] | 7779 | printk(KERN_INFO "ixj driver initialized.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7780 | create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL); |
| 7781 | return probe; |
| 7782 | } |
| 7783 | |
| 7784 | module_init(ixj_init); |
| 7785 | module_exit(ixj_exit); |
| 7786 | |
| 7787 | static void DAA_Coeff_US(IXJ *j) |
| 7788 | { |
| 7789 | int i; |
| 7790 | |
| 7791 | j->daa_country = DAA_US; |
| 7792 | /*----------------------------------------------- */ |
| 7793 | /* CAO */ |
| 7794 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 7795 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 7796 | } |
| 7797 | |
| 7798 | /* Bytes for IM-filter part 1 (04): 0E,32,E2,2F,C2,5A,C0,00 */ |
| 7799 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x03; |
| 7800 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0x4B; |
| 7801 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x5D; |
| 7802 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xCD; |
| 7803 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x24; |
| 7804 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xC5; |
| 7805 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0; |
| 7806 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 7807 | /* Bytes for IM-filter part 2 (05): 72,85,00,0E,2B,3A,D0,08 */ |
| 7808 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x71; |
| 7809 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x1A; |
| 7810 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 7811 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A; |
| 7812 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xB5; |
| 7813 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33; |
| 7814 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0; |
| 7815 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 7816 | /* Bytes for FRX-filter (08): 03,8F,48,F2,8F,48,70,08 */ |
| 7817 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x05; |
| 7818 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xA3; |
| 7819 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x72; |
| 7820 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34; |
| 7821 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x3F; |
| 7822 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x3B; |
| 7823 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30; |
| 7824 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 7825 | /* Bytes for FRR-filter (07): 04,8F,38,7F,9B,EA,B0,08 */ |
| 7826 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x05; |
| 7827 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87; |
| 7828 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9; |
| 7829 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x3E; |
| 7830 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x32; |
| 7831 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xDA; |
| 7832 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0; |
| 7833 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 7834 | /* Bytes for AX-filter (0A): 16,55,DD,CA */ |
| 7835 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x41; |
| 7836 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5; |
| 7837 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 7838 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 7839 | /* Bytes for AR-filter (09): 52,D3,11,42 */ |
| 7840 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25; |
| 7841 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7; |
| 7842 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10; |
| 7843 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6; |
| 7844 | /* Bytes for TH-filter part 1 (00): 00,42,48,81,B3,80,00,98 */ |
| 7845 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00; |
| 7846 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42; |
| 7847 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48; |
| 7848 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81; |
| 7849 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA5; |
| 7850 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80; |
| 7851 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 7852 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 7853 | /* Bytes for TH-filter part 2 (01): 02,F2,33,A0,68,AB,8A,AD */ |
| 7854 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 7855 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xA2; |
| 7856 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2B; |
| 7857 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0; |
| 7858 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8; |
| 7859 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAB; |
| 7860 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81; |
| 7861 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xCC; |
| 7862 | /* Bytes for TH-filter part 3 (02): 00,88,DA,54,A4,BA,2D,BB */ |
| 7863 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 7864 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 7865 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xD2; |
| 7866 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x24; |
| 7867 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBA; |
| 7868 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xA9; |
| 7869 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x3B; |
| 7870 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xA6; |
| 7871 | /* ; (10K, 0.68uF) */ |
| 7872 | /* */ |
| 7873 | /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */ |
| 7874 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 7875 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C; |
| 7876 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93; |
| 7877 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A; |
| 7878 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22; |
| 7879 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12; |
| 7880 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3; |
| 7881 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 7882 | /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */ |
| 7883 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12; |
| 7884 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2; |
| 7885 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 7886 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 7887 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22; |
| 7888 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A; |
| 7889 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; |
| 7890 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 7891 | |
| 7892 | /* Levelmetering Ringing (0D):B2,45,0F,8E */ |
| 7893 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; |
| 7894 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35; |
| 7895 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; |
| 7896 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; |
| 7897 | |
| 7898 | /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */ |
| 7899 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1C; */ |
| 7900 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0xB3; */ |
| 7901 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0xAB; */ |
| 7902 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xAB; */ |
| 7903 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x54; */ |
| 7904 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x2D; */ |
| 7905 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0x62; */ |
| 7906 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x2D; */ |
| 7907 | /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */ |
| 7908 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x2D; */ |
| 7909 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x62; */ |
| 7910 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; */ |
| 7911 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBB; */ |
| 7912 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x2A; */ |
| 7913 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7D; */ |
| 7914 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; */ |
| 7915 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD4; */ |
| 7916 | /* */ |
| 7917 | /* Levelmetering Ringing (0D):B2,45,0F,8E */ |
| 7918 | /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; */ |
| 7919 | /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x05; */ |
| 7920 | /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; */ |
| 7921 | /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; */ |
| 7922 | |
| 7923 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 7924 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 7925 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 7926 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 7927 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 7928 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 7929 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 7930 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 7931 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 7932 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 7933 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 7934 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 7935 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 7936 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 7937 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 7938 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 7939 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 7940 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 7941 | /* */ |
| 7942 | /* ;CR Registers */ |
| 7943 | /* Config. Reg. 0 (filters) (cr0):FE ; CLK gen. by crystal */ |
| 7944 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 7945 | /* Config. Reg. 1 (dialing) (cr1):05 */ |
| 7946 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 7947 | /* Config. Reg. 2 (caller ID) (cr2):04 */ |
| 7948 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 7949 | /* Config. Reg. 3 (testloops) (cr3):03 ; SEL Bit==0, HP-disabled */ |
| 7950 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 7951 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 7952 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 7953 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 7954 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 7955 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 7956 | /* */ |
| 7957 | /* ;xr Registers */ |
| 7958 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 7959 | |
| 7960 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 7961 | /* Ext. Reg. 1 (Interrupt enable) (xr1):3C Cadence, RING, Caller ID, VDD_OK */ |
| 7962 | |
| 7963 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x3C; |
| 7964 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 7965 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 7966 | /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off == 1 */ |
| 7967 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x3B; /*0x32; */ |
| 7968 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 7969 | |
| 7970 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 7971 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 7972 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 7973 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 7974 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 7975 | /* Ext. Reg. 7 (Vdd) (xr7):40 */ |
| 7976 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */ |
| 7977 | /* */ |
| 7978 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 7979 | /* 12,33,5A,C3 ; 770 Hz */ |
| 7980 | /* 13,3C,5B,32 ; 852 Hz */ |
| 7981 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 7982 | |
| 7983 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 7984 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 7985 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 7986 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 7987 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 7988 | /* EC,1D,52,22 ; 1336 Hz */ |
| 7989 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 7990 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 7991 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 7992 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 7993 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 7994 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 7995 | } |
| 7996 | |
| 7997 | static void DAA_Coeff_UK(IXJ *j) |
| 7998 | { |
| 7999 | int i; |
| 8000 | |
| 8001 | j->daa_country = DAA_UK; |
| 8002 | /*----------------------------------------------- */ |
| 8003 | /* CAO */ |
| 8004 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 8005 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 8006 | } |
| 8007 | |
| 8008 | /* Bytes for IM-filter part 1 (04): 00,C2,BB,A8,CB,81,A0,00 */ |
| 8009 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00; |
| 8010 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xC2; |
| 8011 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB; |
| 8012 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xA8; |
| 8013 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xCB; |
| 8014 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81; |
| 8015 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0; |
| 8016 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 8017 | /* Bytes for IM-filter part 2 (05): 40,00,00,0A,A4,33,E0,08 */ |
| 8018 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x40; |
| 8019 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x00; |
| 8020 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 8021 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A; |
| 8022 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xA4; |
| 8023 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33; |
| 8024 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0; |
| 8025 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 8026 | /* Bytes for FRX-filter (08): 07,9B,ED,24,B2,A2,A0,08 */ |
| 8027 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07; |
| 8028 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9B; |
| 8029 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xED; |
| 8030 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x24; |
| 8031 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0xB2; |
| 8032 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0xA2; |
| 8033 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xA0; |
| 8034 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 8035 | /* Bytes for FRR-filter (07): 0F,92,F2,B2,87,D2,30,08 */ |
| 8036 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F; |
| 8037 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x92; |
| 8038 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF2; |
| 8039 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0xB2; |
| 8040 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87; |
| 8041 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xD2; |
| 8042 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x30; |
| 8043 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 8044 | /* Bytes for AX-filter (0A): 1B,A5,DD,CA */ |
| 8045 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x1B; |
| 8046 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xA5; |
| 8047 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 8048 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 8049 | /* Bytes for AR-filter (09): E2,27,10,D6 */ |
| 8050 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2; |
| 8051 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x27; |
| 8052 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10; |
| 8053 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6; |
| 8054 | /* Bytes for TH-filter part 1 (00): 80,2D,38,8B,D0,00,00,98 */ |
| 8055 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80; |
| 8056 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x2D; |
| 8057 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x38; |
| 8058 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x8B; |
| 8059 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xD0; |
| 8060 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x00; |
| 8061 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 8062 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 8063 | /* Bytes for TH-filter part 2 (01): 02,5A,53,F0,0B,5F,84,D4 */ |
| 8064 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 8065 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x5A; |
| 8066 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x53; |
| 8067 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xF0; |
| 8068 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x0B; |
| 8069 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5F; |
| 8070 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x84; |
| 8071 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xD4; |
| 8072 | /* Bytes for TH-filter part 3 (02): 00,88,6A,A4,8F,52,F5,32 */ |
| 8073 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 8074 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 8075 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x6A; |
| 8076 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA4; |
| 8077 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x8F; |
| 8078 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x52; |
| 8079 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xF5; |
| 8080 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x32; |
| 8081 | /* ; idle */ |
| 8082 | /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */ |
| 8083 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 8084 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C; |
| 8085 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93; |
| 8086 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A; |
| 8087 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22; |
| 8088 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12; |
| 8089 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3; |
| 8090 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 8091 | /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */ |
| 8092 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12; |
| 8093 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2; |
| 8094 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 8095 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 8096 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22; |
| 8097 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A; |
| 8098 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; |
| 8099 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 8100 | /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V less possible? */ |
| 8101 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; |
| 8102 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35; |
| 8103 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; |
| 8104 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; |
| 8105 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 8106 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 8107 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 8108 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 8109 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 8110 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 8111 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 8112 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 8113 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 8114 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 8115 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 8116 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 8117 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 8118 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 8119 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 8120 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 8121 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 8122 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 8123 | /* ;CR Registers */ |
| 8124 | /* Config. Reg. 0 (filters) (cr0):FF */ |
| 8125 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 8126 | /* Config. Reg. 1 (dialing) (cr1):05 */ |
| 8127 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 8128 | /* Config. Reg. 2 (caller ID) (cr2):04 */ |
| 8129 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 8130 | /* Config. Reg. 3 (testloops) (cr3):00 ; */ |
| 8131 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 8132 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 8133 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 8134 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 8135 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 8136 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 8137 | /* ;xr Registers */ |
| 8138 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 8139 | |
| 8140 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 8141 | /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */ |
| 8142 | |
| 8143 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */ |
| 8144 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 8145 | |
| 8146 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 8147 | /* Ext. Reg. 3 (DC Char) (xr3):36 ; */ |
| 8148 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36; |
| 8149 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 8150 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 8151 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 8152 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 8153 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 8154 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 8155 | /* Ext. Reg. 7 (Vdd) (xr7):46 */ |
| 8156 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */ |
| 8157 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 8158 | /* 12,33,5A,C3 ; 770 Hz */ |
| 8159 | /* 13,3C,5B,32 ; 852 Hz */ |
| 8160 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 8161 | |
| 8162 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 8163 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 8164 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 8165 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 8166 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 8167 | /* EC,1D,52,22 ; 1336 Hz */ |
| 8168 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 8169 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 8170 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 8171 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 8172 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 8173 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 8174 | } |
| 8175 | |
| 8176 | |
| 8177 | static void DAA_Coeff_France(IXJ *j) |
| 8178 | { |
| 8179 | int i; |
| 8180 | |
| 8181 | j->daa_country = DAA_FRANCE; |
| 8182 | /*----------------------------------------------- */ |
| 8183 | /* CAO */ |
| 8184 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 8185 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 8186 | } |
| 8187 | |
| 8188 | /* Bytes for IM-filter part 1 (04): 02,A2,43,2C,22,AF,A0,00 */ |
| 8189 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x02; |
| 8190 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA2; |
| 8191 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x43; |
| 8192 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2C; |
| 8193 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x22; |
| 8194 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xAF; |
| 8195 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0; |
| 8196 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 8197 | /* Bytes for IM-filter part 2 (05): 67,CE,00,0C,22,33,E0,08 */ |
| 8198 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x67; |
| 8199 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xCE; |
| 8200 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 8201 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x2C; |
| 8202 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x22; |
| 8203 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33; |
| 8204 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0; |
| 8205 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 8206 | /* Bytes for FRX-filter (08): 07,9A,28,F6,23,4A,B0,08 */ |
| 8207 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07; |
| 8208 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9A; |
| 8209 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x28; |
| 8210 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0xF6; |
| 8211 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x23; |
| 8212 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x4A; |
| 8213 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xB0; |
| 8214 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 8215 | /* Bytes for FRR-filter (07): 03,8F,F9,2F,9E,FA,20,08 */ |
| 8216 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03; |
| 8217 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F; |
| 8218 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9; |
| 8219 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F; |
| 8220 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9E; |
| 8221 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xFA; |
| 8222 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20; |
| 8223 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 8224 | /* Bytes for AX-filter (0A): 16,B5,DD,CA */ |
| 8225 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x16; |
| 8226 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5; |
| 8227 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 8228 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 8229 | /* Bytes for AR-filter (09): 52,C7,10,D6 */ |
| 8230 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2; |
| 8231 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7; |
| 8232 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10; |
| 8233 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6; |
| 8234 | /* Bytes for TH-filter part 1 (00): 00,42,48,81,A6,80,00,98 */ |
| 8235 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00; |
| 8236 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42; |
| 8237 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48; |
| 8238 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81; |
| 8239 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA6; |
| 8240 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80; |
| 8241 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 8242 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 8243 | /* Bytes for TH-filter part 2 (01): 02,AC,2A,30,78,AC,8A,2C */ |
| 8244 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 8245 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAC; |
| 8246 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A; |
| 8247 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x30; |
| 8248 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x78; |
| 8249 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAC; |
| 8250 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x8A; |
| 8251 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x2C; |
| 8252 | /* Bytes for TH-filter part 3 (02): 00,88,DA,A5,22,BA,2C,45 */ |
| 8253 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 8254 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 8255 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA; |
| 8256 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA5; |
| 8257 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x22; |
| 8258 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xBA; |
| 8259 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x2C; |
| 8260 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x45; |
| 8261 | /* ; idle */ |
| 8262 | /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */ |
| 8263 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 8264 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C; |
| 8265 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93; |
| 8266 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A; |
| 8267 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22; |
| 8268 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12; |
| 8269 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3; |
| 8270 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 8271 | /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */ |
| 8272 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12; |
| 8273 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2; |
| 8274 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 8275 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 8276 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22; |
| 8277 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A; |
| 8278 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; |
| 8279 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 8280 | /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */ |
| 8281 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32; |
| 8282 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45; |
| 8283 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5; |
| 8284 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84; |
| 8285 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 8286 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 8287 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 8288 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 8289 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 8290 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 8291 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 8292 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 8293 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 8294 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 8295 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 8296 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 8297 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 8298 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 8299 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 8300 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 8301 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 8302 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 8303 | /* ;CR Registers */ |
| 8304 | /* Config. Reg. 0 (filters) (cr0):FF */ |
| 8305 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 8306 | /* Config. Reg. 1 (dialing) (cr1):05 */ |
| 8307 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 8308 | /* Config. Reg. 2 (caller ID) (cr2):04 */ |
| 8309 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 8310 | /* Config. Reg. 3 (testloops) (cr3):00 ; */ |
| 8311 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 8312 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 8313 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 8314 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 8315 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 8316 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 8317 | /* ;xr Registers */ |
| 8318 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 8319 | |
| 8320 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 8321 | /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */ |
| 8322 | |
| 8323 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */ |
| 8324 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 8325 | |
| 8326 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 8327 | /* Ext. Reg. 3 (DC Char) (xr3):36 ; */ |
| 8328 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36; |
| 8329 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 8330 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 8331 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 8332 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 8333 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 8334 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 8335 | /* Ext. Reg. 7 (Vdd) (xr7):46 */ |
| 8336 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */ |
| 8337 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 8338 | /* 12,33,5A,C3 ; 770 Hz */ |
| 8339 | /* 13,3C,5B,32 ; 852 Hz */ |
| 8340 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 8341 | |
| 8342 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 8343 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 8344 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 8345 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 8346 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 8347 | /* EC,1D,52,22 ; 1336 Hz */ |
| 8348 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 8349 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 8350 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 8351 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 8352 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 8353 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 8354 | } |
| 8355 | |
| 8356 | |
| 8357 | static void DAA_Coeff_Germany(IXJ *j) |
| 8358 | { |
| 8359 | int i; |
| 8360 | |
| 8361 | j->daa_country = DAA_GERMANY; |
| 8362 | /*----------------------------------------------- */ |
| 8363 | /* CAO */ |
| 8364 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 8365 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 8366 | } |
| 8367 | |
| 8368 | /* Bytes for IM-filter part 1 (04): 00,CE,BB,B8,D2,81,B0,00 */ |
| 8369 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00; |
| 8370 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xCE; |
| 8371 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB; |
| 8372 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xB8; |
| 8373 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xD2; |
| 8374 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81; |
| 8375 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xB0; |
| 8376 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 8377 | /* Bytes for IM-filter part 2 (05): 45,8F,00,0C,D2,3A,D0,08 */ |
| 8378 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x45; |
| 8379 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x8F; |
| 8380 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 8381 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0C; |
| 8382 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xD2; |
| 8383 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x3A; |
| 8384 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xD0; |
| 8385 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 8386 | /* Bytes for FRX-filter (08): 07,AA,E2,34,24,89,20,08 */ |
| 8387 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07; |
| 8388 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xAA; |
| 8389 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2; |
| 8390 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34; |
| 8391 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x24; |
| 8392 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x89; |
| 8393 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x20; |
| 8394 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 8395 | /* Bytes for FRR-filter (07): 02,87,FA,37,9A,CA,B0,08 */ |
| 8396 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x02; |
| 8397 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87; |
| 8398 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xFA; |
| 8399 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x37; |
| 8400 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9A; |
| 8401 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCA; |
| 8402 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0; |
| 8403 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 8404 | /* Bytes for AX-filter (0A): 72,D5,DD,CA */ |
| 8405 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x72; |
| 8406 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xD5; |
| 8407 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 8408 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 8409 | /* Bytes for AR-filter (09): 72,42,13,4B */ |
| 8410 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x72; |
| 8411 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x42; |
| 8412 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x13; |
| 8413 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0x4B; |
| 8414 | /* Bytes for TH-filter part 1 (00): 80,52,48,81,AD,80,00,98 */ |
| 8415 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80; |
| 8416 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52; |
| 8417 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48; |
| 8418 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81; |
| 8419 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAD; |
| 8420 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80; |
| 8421 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 8422 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 8423 | /* Bytes for TH-filter part 2 (01): 02,42,5A,20,E8,1A,81,27 */ |
| 8424 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 8425 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x42; |
| 8426 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x5A; |
| 8427 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20; |
| 8428 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8; |
| 8429 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x1A; |
| 8430 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81; |
| 8431 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x27; |
| 8432 | /* Bytes for TH-filter part 3 (02): 00,88,63,26,BD,4B,A3,C2 */ |
| 8433 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 8434 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 8435 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x63; |
| 8436 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x26; |
| 8437 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBD; |
| 8438 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x4B; |
| 8439 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xA3; |
| 8440 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xC2; |
| 8441 | /* ; (10K, 0.68uF) */ |
| 8442 | /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */ |
| 8443 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 8444 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3B; |
| 8445 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x9B; |
| 8446 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xBA; |
| 8447 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0xD4; |
| 8448 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x1C; |
| 8449 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xB3; |
| 8450 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 8451 | /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */ |
| 8452 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x13; |
| 8453 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x42; |
| 8454 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 8455 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 8456 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0xD4; |
| 8457 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x73; |
| 8458 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0xCA; |
| 8459 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 8460 | /* Levelmetering Ringing (0D):B2,45,0F,8E */ |
| 8461 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xB2; |
| 8462 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45; |
| 8463 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; |
| 8464 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; |
| 8465 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 8466 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 8467 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 8468 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 8469 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 8470 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 8471 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 8472 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 8473 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 8474 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 8475 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 8476 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 8477 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 8478 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 8479 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 8480 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 8481 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 8482 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 8483 | /* ;CR Registers */ |
| 8484 | /* Config. Reg. 0 (filters) (cr0):FF ; all Filters enabled, CLK from ext. source */ |
| 8485 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 8486 | /* Config. Reg. 1 (dialing) (cr1):05 ; Manual Ring, Ring metering enabled */ |
| 8487 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 8488 | /* Config. Reg. 2 (caller ID) (cr2):04 ; Analog Gain 0dB, FSC internal */ |
| 8489 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 8490 | /* Config. Reg. 3 (testloops) (cr3):00 ; SEL Bit==0, HP-enabled */ |
| 8491 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 8492 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 8493 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 8494 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 8495 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 8496 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 8497 | /* ;xr Registers */ |
| 8498 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 8499 | |
| 8500 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 8501 | /* Ext. Reg. 1 (Interrupt enable) (xr1):1C ; Ring, CID, VDDOK Interrupts enabled */ |
| 8502 | |
| 8503 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */ |
| 8504 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 8505 | |
| 8506 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 8507 | /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off==1, U0=3.5V, R=200Ohm */ |
| 8508 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x32; |
| 8509 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 8510 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 8511 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 8512 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 8513 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 8514 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 8515 | /* Ext. Reg. 7 (Vdd) (xr7):40 ; VDD=4.25 V */ |
| 8516 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */ |
| 8517 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 8518 | /* 12,33,5A,C3 ; 770 Hz */ |
| 8519 | /* 13,3C,5B,32 ; 852 Hz */ |
| 8520 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 8521 | |
| 8522 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 8523 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 8524 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 8525 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 8526 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 8527 | /* EC,1D,52,22 ; 1336 Hz */ |
| 8528 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 8529 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 8530 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 8531 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 8532 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 8533 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 8534 | } |
| 8535 | |
| 8536 | |
| 8537 | static void DAA_Coeff_Australia(IXJ *j) |
| 8538 | { |
| 8539 | int i; |
| 8540 | |
| 8541 | j->daa_country = DAA_AUSTRALIA; |
| 8542 | /*----------------------------------------------- */ |
| 8543 | /* CAO */ |
| 8544 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 8545 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 8546 | } |
| 8547 | |
| 8548 | /* Bytes for IM-filter part 1 (04): 00,A3,AA,28,B3,82,D0,00 */ |
| 8549 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00; |
| 8550 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA3; |
| 8551 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xAA; |
| 8552 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x28; |
| 8553 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xB3; |
| 8554 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x82; |
| 8555 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xD0; |
| 8556 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 8557 | /* Bytes for IM-filter part 2 (05): 70,96,00,09,32,6B,C0,08 */ |
| 8558 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x70; |
| 8559 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x96; |
| 8560 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 8561 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x09; |
| 8562 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x32; |
| 8563 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x6B; |
| 8564 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xC0; |
| 8565 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 8566 | /* Bytes for FRX-filter (08): 07,96,E2,34,32,9B,30,08 */ |
| 8567 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07; |
| 8568 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x96; |
| 8569 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2; |
| 8570 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34; |
| 8571 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x32; |
| 8572 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x9B; |
| 8573 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30; |
| 8574 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 8575 | /* Bytes for FRR-filter (07): 0F,9A,E9,2F,22,CC,A0,08 */ |
| 8576 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F; |
| 8577 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x9A; |
| 8578 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xE9; |
| 8579 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F; |
| 8580 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x22; |
| 8581 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCC; |
| 8582 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xA0; |
| 8583 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 8584 | /* Bytes for AX-filter (0A): CB,45,DD,CA */ |
| 8585 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0xCB; |
| 8586 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0x45; |
| 8587 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 8588 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 8589 | /* Bytes for AR-filter (09): 1B,67,10,D6 */ |
| 8590 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x1B; |
| 8591 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x67; |
| 8592 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10; |
| 8593 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6; |
| 8594 | /* Bytes for TH-filter part 1 (00): 80,52,48,81,AF,80,00,98 */ |
| 8595 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80; |
| 8596 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52; |
| 8597 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48; |
| 8598 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81; |
| 8599 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAF; |
| 8600 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80; |
| 8601 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 8602 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 8603 | /* Bytes for TH-filter part 2 (01): 02,DB,52,B0,38,01,82,AC */ |
| 8604 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 8605 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xDB; |
| 8606 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x52; |
| 8607 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0; |
| 8608 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x38; |
| 8609 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x01; |
| 8610 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x82; |
| 8611 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xAC; |
| 8612 | /* Bytes for TH-filter part 3 (02): 00,88,4A,3E,2C,3B,24,46 */ |
| 8613 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 8614 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 8615 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x4A; |
| 8616 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x3E; |
| 8617 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x2C; |
| 8618 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x3B; |
| 8619 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x24; |
| 8620 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x46; |
| 8621 | /* ; idle */ |
| 8622 | /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */ |
| 8623 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 8624 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C; |
| 8625 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93; |
| 8626 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A; |
| 8627 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22; |
| 8628 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12; |
| 8629 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3; |
| 8630 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 8631 | /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */ |
| 8632 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12; |
| 8633 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2; |
| 8634 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 8635 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 8636 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22; |
| 8637 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A; |
| 8638 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; |
| 8639 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 8640 | /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */ |
| 8641 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32; |
| 8642 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45; |
| 8643 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5; |
| 8644 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84; |
| 8645 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 8646 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 8647 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 8648 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 8649 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 8650 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 8651 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 8652 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 8653 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 8654 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 8655 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 8656 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 8657 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 8658 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 8659 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 8660 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 8661 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 8662 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 8663 | /* ;CR Registers */ |
| 8664 | /* Config. Reg. 0 (filters) (cr0):FF */ |
| 8665 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 8666 | /* Config. Reg. 1 (dialing) (cr1):05 */ |
| 8667 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 8668 | /* Config. Reg. 2 (caller ID) (cr2):04 */ |
| 8669 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 8670 | /* Config. Reg. 3 (testloops) (cr3):00 ; */ |
| 8671 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 8672 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 8673 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 8674 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 8675 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 8676 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 8677 | /* ;xr Registers */ |
| 8678 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 8679 | |
| 8680 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 8681 | /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */ |
| 8682 | |
| 8683 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */ |
| 8684 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 8685 | |
| 8686 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 8687 | /* Ext. Reg. 3 (DC Char) (xr3):2B ; */ |
| 8688 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x2B; |
| 8689 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 8690 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 8691 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 8692 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 8693 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 8694 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 8695 | /* Ext. Reg. 7 (Vdd) (xr7):40 */ |
| 8696 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */ |
| 8697 | |
| 8698 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 8699 | /* 12,33,5A,C3 ; 770 Hz */ |
| 8700 | /* 13,3C,5B,32 ; 852 Hz */ |
| 8701 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 8702 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 8703 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 8704 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 8705 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 8706 | |
| 8707 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 8708 | /* EC,1D,52,22 ; 1336 Hz */ |
| 8709 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 8710 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 8711 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 8712 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 8713 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 8714 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 8715 | } |
| 8716 | |
| 8717 | static void DAA_Coeff_Japan(IXJ *j) |
| 8718 | { |
| 8719 | int i; |
| 8720 | |
| 8721 | j->daa_country = DAA_JAPAN; |
| 8722 | /*----------------------------------------------- */ |
| 8723 | /* CAO */ |
| 8724 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 8725 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 8726 | } |
| 8727 | |
| 8728 | /* Bytes for IM-filter part 1 (04): 06,BD,E2,2D,BA,F9,A0,00 */ |
| 8729 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x06; |
| 8730 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xBD; |
| 8731 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xE2; |
| 8732 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2D; |
| 8733 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xBA; |
| 8734 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xF9; |
| 8735 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0; |
| 8736 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 8737 | /* Bytes for IM-filter part 2 (05): 6F,F7,00,0E,34,33,E0,08 */ |
| 8738 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x6F; |
| 8739 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xF7; |
| 8740 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 8741 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0E; |
| 8742 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x34; |
| 8743 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33; |
| 8744 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0; |
| 8745 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 8746 | /* Bytes for FRX-filter (08): 02,8F,68,77,9C,58,F0,08 */ |
| 8747 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x02; |
| 8748 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x8F; |
| 8749 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x68; |
| 8750 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x77; |
| 8751 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x9C; |
| 8752 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x58; |
| 8753 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xF0; |
| 8754 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 8755 | /* Bytes for FRR-filter (07): 03,8F,38,73,87,EA,20,08 */ |
| 8756 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03; |
| 8757 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F; |
| 8758 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0x38; |
| 8759 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x73; |
| 8760 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87; |
| 8761 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xEA; |
| 8762 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20; |
| 8763 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 8764 | /* Bytes for AX-filter (0A): 51,C5,DD,CA */ |
| 8765 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x51; |
| 8766 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xC5; |
| 8767 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 8768 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 8769 | /* Bytes for AR-filter (09): 25,A7,10,D6 */ |
| 8770 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25; |
| 8771 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xA7; |
| 8772 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10; |
| 8773 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6; |
| 8774 | /* Bytes for TH-filter part 1 (00): 00,42,48,81,AE,80,00,98 */ |
| 8775 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00; |
| 8776 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42; |
| 8777 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48; |
| 8778 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81; |
| 8779 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAE; |
| 8780 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80; |
| 8781 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 8782 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 8783 | /* Bytes for TH-filter part 2 (01): 02,AB,2A,20,99,5B,89,28 */ |
| 8784 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 8785 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAB; |
| 8786 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A; |
| 8787 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20; |
| 8788 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x99; |
| 8789 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5B; |
| 8790 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x89; |
| 8791 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x28; |
| 8792 | /* Bytes for TH-filter part 3 (02): 00,88,DA,25,34,C5,4C,BA */ |
| 8793 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 8794 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 8795 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA; |
| 8796 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x25; |
| 8797 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x34; |
| 8798 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xC5; |
| 8799 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x4C; |
| 8800 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xBA; |
| 8801 | /* ; idle */ |
| 8802 | /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */ |
| 8803 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 8804 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C; |
| 8805 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93; |
| 8806 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A; |
| 8807 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22; |
| 8808 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12; |
| 8809 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3; |
| 8810 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 8811 | /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */ |
| 8812 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12; |
| 8813 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2; |
| 8814 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 8815 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 8816 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22; |
| 8817 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A; |
| 8818 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; |
| 8819 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 8820 | /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V ????????? */ |
| 8821 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; |
| 8822 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35; |
| 8823 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; |
| 8824 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; |
| 8825 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 8826 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 8827 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 8828 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 8829 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 8830 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 8831 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 8832 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 8833 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 8834 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 8835 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 8836 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 8837 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 8838 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 8839 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 8840 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 8841 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 8842 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 8843 | /* ;CR Registers */ |
| 8844 | /* Config. Reg. 0 (filters) (cr0):FF */ |
| 8845 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 8846 | /* Config. Reg. 1 (dialing) (cr1):05 */ |
| 8847 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 8848 | /* Config. Reg. 2 (caller ID) (cr2):04 */ |
| 8849 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 8850 | /* Config. Reg. 3 (testloops) (cr3):00 ; */ |
| 8851 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 8852 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 8853 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 8854 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 8855 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 8856 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 8857 | /* ;xr Registers */ |
| 8858 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 8859 | |
| 8860 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 8861 | /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */ |
| 8862 | |
| 8863 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */ |
| 8864 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 8865 | |
| 8866 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 8867 | /* Ext. Reg. 3 (DC Char) (xr3):22 ; */ |
| 8868 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x22; |
| 8869 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 8870 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 8871 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 8872 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 8873 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 8874 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 8875 | /* Ext. Reg. 7 (Vdd) (xr7):40 */ |
| 8876 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */ |
| 8877 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 8878 | /* 12,33,5A,C3 ; 770 Hz */ |
| 8879 | /* 13,3C,5B,32 ; 852 Hz */ |
| 8880 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 8881 | |
| 8882 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 8883 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 8884 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 8885 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 8886 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 8887 | /* EC,1D,52,22 ; 1336 Hz */ |
| 8888 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 8889 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 8890 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 8891 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 8892 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 8893 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 8894 | } |
| 8895 | |
| 8896 | static s16 tone_table[][19] = |
| 8897 | { |
| 8898 | { /* f20_50[] 11 */ |
| 8899 | 32538, /* A1 = 1.985962 */ |
| 8900 | -32325, /* A2 = -0.986511 */ |
| 8901 | -343, /* B2 = -0.010493 */ |
| 8902 | 0, /* B1 = 0 */ |
| 8903 | 343, /* B0 = 0.010493 */ |
| 8904 | 32619, /* A1 = 1.990906 */ |
| 8905 | -32520, /* A2 = -0.992462 */ |
| 8906 | 19179, /* B2 = 0.585327 */ |
| 8907 | -19178, /* B1 = -1.170593 */ |
| 8908 | 19179, /* B0 = 0.585327 */ |
| 8909 | 32723, /* A1 = 1.997314 */ |
| 8910 | -32686, /* A2 = -0.997528 */ |
| 8911 | 9973, /* B2 = 0.304352 */ |
| 8912 | -9955, /* B1 = -0.607605 */ |
| 8913 | 9973, /* B0 = 0.304352 */ |
| 8914 | 7, /* Internal filter scaling */ |
| 8915 | 159, /* Minimum in-band energy threshold */ |
| 8916 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8917 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8918 | }, |
| 8919 | { /* f133_200[] 12 */ |
| 8920 | 32072, /* A1 = 1.95752 */ |
| 8921 | -31896, /* A2 = -0.973419 */ |
| 8922 | -435, /* B2 = -0.013294 */ |
| 8923 | 0, /* B1 = 0 */ |
| 8924 | 435, /* B0 = 0.013294 */ |
| 8925 | 32188, /* A1 = 1.9646 */ |
| 8926 | -32400, /* A2 = -0.98877 */ |
| 8927 | 15139, /* B2 = 0.462036 */ |
| 8928 | -14882, /* B1 = -0.908356 */ |
| 8929 | 15139, /* B0 = 0.462036 */ |
| 8930 | 32473, /* A1 = 1.981995 */ |
| 8931 | -32524, /* A2 = -0.992584 */ |
| 8932 | 23200, /* B2 = 0.708008 */ |
| 8933 | -23113, /* B1 = -1.410706 */ |
| 8934 | 23200, /* B0 = 0.708008 */ |
| 8935 | 7, /* Internal filter scaling */ |
| 8936 | 159, /* Minimum in-band energy threshold */ |
| 8937 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8938 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8939 | }, |
| 8940 | { /* f300 13 */ |
| 8941 | 31769, /* A1 = -1.939026 */ |
| 8942 | -32584, /* A2 = 0.994385 */ |
| 8943 | -475, /* B2 = -0.014522 */ |
| 8944 | 0, /* B1 = 0.000000 */ |
| 8945 | 475, /* B0 = 0.014522 */ |
| 8946 | 31789, /* A1 = -1.940247 */ |
| 8947 | -32679, /* A2 = 0.997284 */ |
| 8948 | 17280, /* B2 = 0.527344 */ |
| 8949 | -16865, /* B1 = -1.029358 */ |
| 8950 | 17280, /* B0 = 0.527344 */ |
| 8951 | 31841, /* A1 = -1.943481 */ |
| 8952 | -32681, /* A2 = 0.997345 */ |
| 8953 | 543, /* B2 = 0.016579 */ |
| 8954 | -525, /* B1 = -0.032097 */ |
| 8955 | 543, /* B0 = 0.016579 */ |
| 8956 | 5, /* Internal filter scaling */ |
| 8957 | 159, /* Minimum in-band energy threshold */ |
| 8958 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8959 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8960 | }, |
| 8961 | { /* f300_420[] 14 */ |
| 8962 | 30750, /* A1 = 1.876892 */ |
| 8963 | -31212, /* A2 = -0.952515 */ |
| 8964 | -804, /* B2 = -0.024541 */ |
| 8965 | 0, /* B1 = 0 */ |
| 8966 | 804, /* B0 = 0.024541 */ |
| 8967 | 30686, /* A1 = 1.872925 */ |
| 8968 | -32145, /* A2 = -0.980988 */ |
| 8969 | 14747, /* B2 = 0.450043 */ |
| 8970 | -13703, /* B1 = -0.836395 */ |
| 8971 | 14747, /* B0 = 0.450043 */ |
| 8972 | 31651, /* A1 = 1.931824 */ |
| 8973 | -32321, /* A2 = -0.986389 */ |
| 8974 | 24425, /* B2 = 0.745422 */ |
| 8975 | -23914, /* B1 = -1.459595 */ |
| 8976 | 24427, /* B0 = 0.745483 */ |
| 8977 | 7, /* Internal filter scaling */ |
| 8978 | 159, /* Minimum in-band energy threshold */ |
| 8979 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8980 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8981 | }, |
| 8982 | { /* f330 15 */ |
| 8983 | 31613, /* A1 = -1.929565 */ |
| 8984 | -32646, /* A2 = 0.996277 */ |
| 8985 | -185, /* B2 = -0.005657 */ |
| 8986 | 0, /* B1 = 0.000000 */ |
| 8987 | 185, /* B0 = 0.005657 */ |
| 8988 | 31620, /* A1 = -1.929932 */ |
| 8989 | -32713, /* A2 = 0.998352 */ |
| 8990 | 19253, /* B2 = 0.587585 */ |
| 8991 | -18566, /* B1 = -1.133179 */ |
| 8992 | 19253, /* B0 = 0.587585 */ |
| 8993 | 31674, /* A1 = -1.933228 */ |
| 8994 | -32715, /* A2 = 0.998413 */ |
| 8995 | 2575, /* B2 = 0.078590 */ |
| 8996 | -2495, /* B1 = -0.152283 */ |
| 8997 | 2575, /* B0 = 0.078590 */ |
| 8998 | 5, /* Internal filter scaling */ |
| 8999 | 159, /* Minimum in-band energy threshold */ |
| 9000 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9001 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9002 | }, |
| 9003 | { /* f300_425[] 16 */ |
| 9004 | 30741, /* A1 = 1.876282 */ |
| 9005 | -31475, /* A2 = -0.960541 */ |
| 9006 | -703, /* B2 = -0.021484 */ |
| 9007 | 0, /* B1 = 0 */ |
| 9008 | 703, /* B0 = 0.021484 */ |
| 9009 | 30688, /* A1 = 1.873047 */ |
| 9010 | -32248, /* A2 = -0.984161 */ |
| 9011 | 14542, /* B2 = 0.443787 */ |
| 9012 | -13523, /* B1 = -0.825439 */ |
| 9013 | 14542, /* B0 = 0.443817 */ |
| 9014 | 31494, /* A1 = 1.922302 */ |
| 9015 | -32366, /* A2 = -0.987762 */ |
| 9016 | 21577, /* B2 = 0.658508 */ |
| 9017 | -21013, /* B1 = -1.282532 */ |
| 9018 | 21577, /* B0 = 0.658508 */ |
| 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 | { /* f330_440[] 17 */ |
| 9025 | 30627, /* A1 = 1.869324 */ |
| 9026 | -31338, /* A2 = -0.95636 */ |
| 9027 | -843, /* B2 = -0.025749 */ |
| 9028 | 0, /* B1 = 0 */ |
| 9029 | 843, /* B0 = 0.025749 */ |
| 9030 | 30550, /* A1 = 1.864685 */ |
| 9031 | -32221, /* A2 = -0.983337 */ |
| 9032 | 13594, /* B2 = 0.414886 */ |
| 9033 | -12589, /* B1 = -0.768402 */ |
| 9034 | 13594, /* B0 = 0.414886 */ |
| 9035 | 31488, /* A1 = 1.921936 */ |
| 9036 | -32358, /* A2 = -0.987518 */ |
| 9037 | 24684, /* B2 = 0.753296 */ |
| 9038 | -24029, /* B1 = -1.466614 */ |
| 9039 | 24684, /* B0 = 0.753296 */ |
| 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 | { /* f340 18 */ |
| 9046 | 31546, /* A1 = -1.925476 */ |
| 9047 | -32646, /* A2 = 0.996277 */ |
| 9048 | -445, /* B2 = -0.013588 */ |
| 9049 | 0, /* B1 = 0.000000 */ |
| 9050 | 445, /* B0 = 0.013588 */ |
| 9051 | 31551, /* A1 = -1.925781 */ |
| 9052 | -32713, /* A2 = 0.998352 */ |
| 9053 | 23884, /* B2 = 0.728882 */ |
| 9054 | -22979, /* B1 = -1.402527 */ |
| 9055 | 23884, /* B0 = 0.728882 */ |
| 9056 | 31606, /* A1 = -1.929138 */ |
| 9057 | -32715, /* A2 = 0.998413 */ |
| 9058 | 863, /* B2 = 0.026367 */ |
| 9059 | -835, /* B1 = -0.050985 */ |
| 9060 | 863, /* B0 = 0.026367 */ |
| 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 | { /* f350_400[] 19 */ |
| 9067 | 31006, /* A1 = 1.892517 */ |
| 9068 | -32029, /* A2 = -0.977448 */ |
| 9069 | -461, /* B2 = -0.014096 */ |
| 9070 | 0, /* B1 = 0 */ |
| 9071 | 461, /* B0 = 0.014096 */ |
| 9072 | 30999, /* A1 = 1.892029 */ |
| 9073 | -32487, /* A2 = -0.991455 */ |
| 9074 | 11325, /* B2 = 0.345612 */ |
| 9075 | -10682, /* B1 = -0.651978 */ |
| 9076 | 11325, /* B0 = 0.345612 */ |
| 9077 | 31441, /* A1 = 1.919067 */ |
| 9078 | -32526, /* A2 = -0.992615 */ |
| 9079 | 24324, /* B2 = 0.74231 */ |
| 9080 | -23535, /* B1 = -1.436523 */ |
| 9081 | 24324, /* B0 = 0.74231 */ |
| 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 | { /* f350_440[] */ |
| 9088 | 30634, /* A1 = 1.869751 */ |
| 9089 | -31533, /* A2 = -0.962341 */ |
| 9090 | -680, /* B2 = -0.020782 */ |
| 9091 | 0, /* B1 = 0 */ |
| 9092 | 680, /* B0 = 0.020782 */ |
| 9093 | 30571, /* A1 = 1.865906 */ |
| 9094 | -32277, /* A2 = -0.985016 */ |
| 9095 | 12894, /* B2 = 0.393524 */ |
| 9096 | -11945, /* B1 = -0.729065 */ |
| 9097 | 12894, /* B0 = 0.393524 */ |
| 9098 | 31367, /* A1 = 1.91449 */ |
| 9099 | -32379, /* A2 = -0.988129 */ |
| 9100 | 23820, /* B2 = 0.726929 */ |
| 9101 | -23104, /* B1 = -1.410217 */ |
| 9102 | 23820, /* B0 = 0.726929 */ |
| 9103 | 7, /* 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 | { /* f350_450[] */ |
| 9109 | 30552, /* A1 = 1.864807 */ |
| 9110 | -31434, /* A2 = -0.95929 */ |
| 9111 | -690, /* B2 = -0.021066 */ |
| 9112 | 0, /* B1 = 0 */ |
| 9113 | 690, /* B0 = 0.021066 */ |
| 9114 | 30472, /* A1 = 1.859924 */ |
| 9115 | -32248, /* A2 = -0.984161 */ |
| 9116 | 13385, /* B2 = 0.408478 */ |
| 9117 | -12357, /* B1 = -0.754242 */ |
| 9118 | 13385, /* B0 = 0.408478 */ |
| 9119 | 31358, /* A1 = 1.914001 */ |
| 9120 | -32366, /* A2 = -0.987732 */ |
| 9121 | 26488, /* B2 = 0.80835 */ |
| 9122 | -25692, /* B1 = -1.568176 */ |
| 9123 | 26490, /* B0 = 0.808411 */ |
| 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 | { /* f360 */ |
| 9130 | 31397, /* A1 = -1.916321 */ |
| 9131 | -32623, /* A2 = 0.995605 */ |
| 9132 | -117, /* B2 = -0.003598 */ |
| 9133 | 0, /* B1 = 0.000000 */ |
| 9134 | 117, /* B0 = 0.003598 */ |
| 9135 | 31403, /* A1 = -1.916687 */ |
| 9136 | -32700, /* A2 = 0.997925 */ |
| 9137 | 3388, /* B2 = 0.103401 */ |
| 9138 | -3240, /* B1 = -0.197784 */ |
| 9139 | 3388, /* B0 = 0.103401 */ |
| 9140 | 31463, /* A1 = -1.920410 */ |
| 9141 | -32702, /* A2 = 0.997986 */ |
| 9142 | 13346, /* B2 = 0.407288 */ |
| 9143 | -12863, /* B1 = -0.785126 */ |
| 9144 | 13346, /* B0 = 0.407288 */ |
| 9145 | 5, /* 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 | { /* f380_420[] */ |
| 9151 | 30831, /* A1 = 1.881775 */ |
| 9152 | -32064, /* A2 = -0.978546 */ |
| 9153 | -367, /* B2 = -0.01122 */ |
| 9154 | 0, /* B1 = 0 */ |
| 9155 | 367, /* B0 = 0.01122 */ |
| 9156 | 30813, /* A1 = 1.880737 */ |
| 9157 | -32456, /* A2 = -0.990509 */ |
| 9158 | 11068, /* B2 = 0.337769 */ |
| 9159 | -10338, /* B1 = -0.631042 */ |
| 9160 | 11068, /* B0 = 0.337769 */ |
| 9161 | 31214, /* A1 = 1.905212 */ |
| 9162 | -32491, /* A2 = -0.991577 */ |
| 9163 | 16374, /* B2 = 0.499695 */ |
| 9164 | -15781, /* B1 = -0.963196 */ |
| 9165 | 16374, /* B0 = 0.499695 */ |
| 9166 | 7, /* 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 | { /* f392 */ |
| 9172 | 31152, /* A1 = -1.901428 */ |
| 9173 | -32613, /* A2 = 0.995300 */ |
| 9174 | -314, /* B2 = -0.009605 */ |
| 9175 | 0, /* B1 = 0.000000 */ |
| 9176 | 314, /* B0 = 0.009605 */ |
| 9177 | 31156, /* A1 = -1.901672 */ |
| 9178 | -32694, /* A2 = 0.997742 */ |
| 9179 | 28847, /* B2 = 0.880371 */ |
| 9180 | -2734, /* B1 = -0.166901 */ |
| 9181 | 28847, /* B0 = 0.880371 */ |
| 9182 | 31225, /* A1 = -1.905823 */ |
| 9183 | -32696, /* A2 = 0.997803 */ |
| 9184 | 462, /* B2 = 0.014108 */ |
| 9185 | -442, /* B1 = -0.027019 */ |
| 9186 | 462, /* B0 = 0.014108 */ |
| 9187 | 5, /* 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 | { /* f400_425[] */ |
| 9193 | 30836, /* A1 = 1.882141 */ |
| 9194 | -32296, /* A2 = -0.985596 */ |
| 9195 | -324, /* B2 = -0.009903 */ |
| 9196 | 0, /* B1 = 0 */ |
| 9197 | 324, /* B0 = 0.009903 */ |
| 9198 | 30825, /* A1 = 1.881409 */ |
| 9199 | -32570, /* A2 = -0.993958 */ |
| 9200 | 16847, /* B2 = 0.51416 */ |
| 9201 | -15792, /* B1 = -0.963898 */ |
| 9202 | 16847, /* B0 = 0.51416 */ |
| 9203 | 31106, /* A1 = 1.89856 */ |
| 9204 | -32584, /* A2 = -0.994415 */ |
| 9205 | 9579, /* B2 = 0.292328 */ |
| 9206 | -9164, /* B1 = -0.559357 */ |
| 9207 | 9579, /* B0 = 0.292328 */ |
| 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 | { /* f400_440[] */ |
| 9214 | 30702, /* A1 = 1.873962 */ |
| 9215 | -32134, /* A2 = -0.980682 */ |
| 9216 | -517, /* B2 = -0.015793 */ |
| 9217 | 0, /* B1 = 0 */ |
| 9218 | 517, /* B0 = 0.015793 */ |
| 9219 | 30676, /* A1 = 1.872375 */ |
| 9220 | -32520, /* A2 = -0.992462 */ |
| 9221 | 8144, /* B2 = 0.24855 */ |
| 9222 | -7596, /* B1 = -0.463684 */ |
| 9223 | 8144, /* B0 = 0.24855 */ |
| 9224 | 31084, /* A1 = 1.897217 */ |
| 9225 | -32547, /* A2 = -0.993256 */ |
| 9226 | 22713, /* B2 = 0.693176 */ |
| 9227 | -21734, /* B1 = -1.326599 */ |
| 9228 | 22713, /* B0 = 0.693176 */ |
| 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 | { /* f400_450[] */ |
| 9235 | 30613, /* A1 = 1.86853 */ |
| 9236 | -32031, /* A2 = -0.977509 */ |
| 9237 | -618, /* B2 = -0.018866 */ |
| 9238 | 0, /* B1 = 0 */ |
| 9239 | 618, /* B0 = 0.018866 */ |
| 9240 | 30577, /* A1 = 1.866272 */ |
| 9241 | -32491, /* A2 = -0.991577 */ |
| 9242 | 9612, /* B2 = 0.293335 */ |
| 9243 | -8935, /* B1 = -0.54541 */ |
| 9244 | 9612, /* B0 = 0.293335 */ |
| 9245 | 31071, /* A1 = 1.896484 */ |
| 9246 | -32524, /* A2 = -0.992584 */ |
| 9247 | 21596, /* B2 = 0.659058 */ |
| 9248 | -20667, /* B1 = -1.261414 */ |
| 9249 | 21596, /* B0 = 0.659058 */ |
| 9250 | 7, /* 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 | { /* f420 */ |
| 9256 | 30914, /* A1 = -1.886841 */ |
| 9257 | -32584, /* A2 = 0.994385 */ |
| 9258 | -426, /* B2 = -0.013020 */ |
| 9259 | 0, /* B1 = 0.000000 */ |
| 9260 | 426, /* B0 = 0.013020 */ |
| 9261 | 30914, /* A1 = -1.886841 */ |
| 9262 | -32679, /* A2 = 0.997314 */ |
| 9263 | 17520, /* B2 = 0.534668 */ |
| 9264 | -16471, /* B1 = -1.005310 */ |
| 9265 | 17520, /* B0 = 0.534668 */ |
| 9266 | 31004, /* A1 = -1.892334 */ |
| 9267 | -32683, /* A2 = 0.997406 */ |
| 9268 | 819, /* B2 = 0.025023 */ |
| 9269 | -780, /* B1 = -0.047619 */ |
| 9270 | 819, /* B0 = 0.025023 */ |
| 9271 | 5, /* 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 | #if 0 |
| 9277 | { /* f425 */ |
| 9278 | 30881, /* A1 = -1.884827 */ |
| 9279 | -32603, /* A2 = 0.994965 */ |
| 9280 | -496, /* B2 = -0.015144 */ |
| 9281 | 0, /* B1 = 0.000000 */ |
| 9282 | 496, /* B0 = 0.015144 */ |
| 9283 | 30880, /* A1 = -1.884766 */ |
| 9284 | -32692, /* A2 = 0.997711 */ |
| 9285 | 24767, /* B2 = 0.755859 */ |
| 9286 | -23290, /* B1 = -1.421509 */ |
| 9287 | 24767, /* B0 = 0.755859 */ |
| 9288 | 30967, /* A1 = -1.890076 */ |
| 9289 | -32694, /* A2 = 0.997772 */ |
| 9290 | 728, /* B2 = 0.022232 */ |
| 9291 | -691, /* B1 = -0.042194 */ |
| 9292 | 728, /* B0 = 0.022232 */ |
| 9293 | 5, /* Internal filter scaling */ |
| 9294 | 159, /* Minimum in-band energy threshold */ |
| 9295 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9296 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9297 | }, |
| 9298 | #else |
| 9299 | { |
| 9300 | 30850, |
| 9301 | -32534, |
| 9302 | -504, |
| 9303 | 0, |
| 9304 | 504, |
| 9305 | 30831, |
| 9306 | -32669, |
| 9307 | 24303, |
| 9308 | -22080, |
| 9309 | 24303, |
| 9310 | 30994, |
| 9311 | -32673, |
| 9312 | 1905, |
| 9313 | -1811, |
| 9314 | 1905, |
| 9315 | 5, |
| 9316 | 129, |
| 9317 | 17, |
| 9318 | 0xff5 |
| 9319 | }, |
| 9320 | #endif |
| 9321 | { /* f425_450[] */ |
| 9322 | 30646, /* A1 = 1.870544 */ |
| 9323 | -32327, /* A2 = -0.986572 */ |
| 9324 | -287, /* B2 = -0.008769 */ |
| 9325 | 0, /* B1 = 0 */ |
| 9326 | 287, /* B0 = 0.008769 */ |
| 9327 | 30627, /* A1 = 1.869324 */ |
| 9328 | -32607, /* A2 = -0.995087 */ |
| 9329 | 13269, /* B2 = 0.404968 */ |
| 9330 | -12376, /* B1 = -0.755432 */ |
| 9331 | 13269, /* B0 = 0.404968 */ |
| 9332 | 30924, /* A1 = 1.887512 */ |
| 9333 | -32619, /* A2 = -0.995453 */ |
| 9334 | 19950, /* B2 = 0.608826 */ |
| 9335 | -18940, /* B1 = -1.156006 */ |
| 9336 | 19950, /* B0 = 0.608826 */ |
| 9337 | 7, /* Internal filter scaling */ |
| 9338 | 159, /* Minimum in-band energy threshold */ |
| 9339 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9340 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9341 | }, |
| 9342 | { /* f425_475[] */ |
| 9343 | 30396, /* A1 = 1.855225 */ |
| 9344 | -32014, /* A2 = -0.97699 */ |
| 9345 | -395, /* B2 = -0.012055 */ |
| 9346 | 0, /* B1 = 0 */ |
| 9347 | 395, /* B0 = 0.012055 */ |
| 9348 | 30343, /* A1 = 1.85199 */ |
| 9349 | -32482, /* A2 = -0.991302 */ |
| 9350 | 17823, /* B2 = 0.543945 */ |
| 9351 | -16431, /* B1 = -1.002869 */ |
| 9352 | 17823, /* B0 = 0.543945 */ |
| 9353 | 30872, /* A1 = 1.884338 */ |
| 9354 | -32516, /* A2 = -0.99231 */ |
| 9355 | 18124, /* B2 = 0.553101 */ |
| 9356 | -17246, /* B1 = -1.052673 */ |
| 9357 | 18124, /* B0 = 0.553101 */ |
| 9358 | 7, /* Internal filter scaling */ |
| 9359 | 159, /* Minimum in-band energy threshold */ |
| 9360 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9361 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9362 | }, |
| 9363 | { /* f435 */ |
| 9364 | 30796, /* A1 = -1.879639 */ |
| 9365 | -32603, /* A2 = 0.994965 */ |
| 9366 | -254, /* B2 = -0.007762 */ |
| 9367 | 0, /* B1 = 0.000000 */ |
| 9368 | 254, /* B0 = 0.007762 */ |
| 9369 | 30793, /* A1 = -1.879456 */ |
| 9370 | -32692, /* A2 = 0.997711 */ |
| 9371 | 18934, /* B2 = 0.577820 */ |
| 9372 | -17751, /* B1 = -1.083496 */ |
| 9373 | 18934, /* B0 = 0.577820 */ |
| 9374 | 30882, /* A1 = -1.884888 */ |
| 9375 | -32694, /* A2 = 0.997772 */ |
| 9376 | 1858, /* B2 = 0.056713 */ |
| 9377 | -1758, /* B1 = -0.107357 */ |
| 9378 | 1858, /* B0 = 0.056713 */ |
| 9379 | 5, /* Internal filter scaling */ |
| 9380 | 159, /* Minimum in-band energy threshold */ |
| 9381 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9382 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9383 | }, |
| 9384 | { /* f440_450[] */ |
| 9385 | 30641, /* A1 = 1.870239 */ |
| 9386 | -32458, /* A2 = -0.99057 */ |
| 9387 | -155, /* B2 = -0.004735 */ |
| 9388 | 0, /* B1 = 0 */ |
| 9389 | 155, /* B0 = 0.004735 */ |
| 9390 | 30631, /* A1 = 1.869568 */ |
| 9391 | -32630, /* A2 = -0.995789 */ |
| 9392 | 11453, /* B2 = 0.349548 */ |
| 9393 | -10666, /* B1 = -0.651001 */ |
| 9394 | 11453, /* B0 = 0.349548 */ |
| 9395 | 30810, /* A1 = 1.880554 */ |
| 9396 | -32634, /* A2 = -0.995941 */ |
| 9397 | 12237, /* B2 = 0.373474 */ |
| 9398 | -11588, /* B1 = -0.707336 */ |
| 9399 | 12237, /* B0 = 0.373474 */ |
| 9400 | 7, /* Internal filter scaling */ |
| 9401 | 159, /* Minimum in-band energy threshold */ |
| 9402 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9403 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9404 | }, |
| 9405 | { /* f440_480[] */ |
| 9406 | 30367, /* A1 = 1.853455 */ |
| 9407 | -32147, /* A2 = -0.981079 */ |
| 9408 | -495, /* B2 = -0.015113 */ |
| 9409 | 0, /* B1 = 0 */ |
| 9410 | 495, /* B0 = 0.015113 */ |
| 9411 | 30322, /* A1 = 1.850769 */ |
| 9412 | -32543, /* A2 = -0.993134 */ |
| 9413 | 10031, /* B2 = 0.306152 */ |
| 9414 | -9252, /* B1 = -0.564728 */ |
| 9415 | 10031, /* B0 = 0.306152 */ |
| 9416 | 30770, /* A1 = 1.878052 */ |
| 9417 | -32563, /* A2 = -0.993774 */ |
| 9418 | 22674, /* B2 = 0.691956 */ |
| 9419 | -21465, /* B1 = -1.31012 */ |
| 9420 | 22674, /* B0 = 0.691956 */ |
| 9421 | 7, /* Internal filter scaling */ |
| 9422 | 159, /* Minimum in-band energy threshold */ |
| 9423 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9424 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9425 | }, |
| 9426 | { /* f445 */ |
| 9427 | 30709, /* A1 = -1.874329 */ |
| 9428 | -32603, /* A2 = 0.994965 */ |
| 9429 | -83, /* B2 = -0.002545 */ |
| 9430 | 0, /* B1 = 0.000000 */ |
| 9431 | 83, /* B0 = 0.002545 */ |
| 9432 | 30704, /* A1 = -1.874084 */ |
| 9433 | -32692, /* A2 = 0.997711 */ |
| 9434 | 10641, /* B2 = 0.324738 */ |
| 9435 | -9947, /* B1 = -0.607147 */ |
| 9436 | 10641, /* B0 = 0.324738 */ |
| 9437 | 30796, /* A1 = -1.879639 */ |
| 9438 | -32694, /* A2 = 0.997772 */ |
| 9439 | 10079, /* B2 = 0.307587 */ |
| 9440 | 9513, /* B1 = 0.580688 */ |
| 9441 | 10079, /* B0 = 0.307587 */ |
| 9442 | 5, /* 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 | { /* f450 */ |
| 9448 | 30664, /* A1 = -1.871643 */ |
| 9449 | -32603, /* A2 = 0.994965 */ |
| 9450 | -164, /* B2 = -0.005029 */ |
| 9451 | 0, /* B1 = 0.000000 */ |
| 9452 | 164, /* B0 = 0.005029 */ |
| 9453 | 30661, /* A1 = -1.871399 */ |
| 9454 | -32692, /* A2 = 0.997711 */ |
| 9455 | 15294, /* B2 = 0.466736 */ |
| 9456 | -14275, /* B1 = -0.871307 */ |
| 9457 | 15294, /* B0 = 0.466736 */ |
| 9458 | 30751, /* A1 = -1.876953 */ |
| 9459 | -32694, /* A2 = 0.997772 */ |
| 9460 | 3548, /* B2 = 0.108284 */ |
| 9461 | -3344, /* B1 = -0.204155 */ |
| 9462 | 3548, /* B0 = 0.108284 */ |
| 9463 | 5, /* 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 | { /* f452 */ |
| 9469 | 30653, /* A1 = -1.870911 */ |
| 9470 | -32615, /* A2 = 0.995361 */ |
| 9471 | -209, /* B2 = -0.006382 */ |
| 9472 | 0, /* B1 = 0.000000 */ |
| 9473 | 209, /* B0 = 0.006382 */ |
| 9474 | 30647, /* A1 = -1.870605 */ |
| 9475 | -32702, /* A2 = 0.997986 */ |
| 9476 | 18971, /* B2 = 0.578979 */ |
| 9477 | -17716, /* B1 = -1.081299 */ |
| 9478 | 18971, /* B0 = 0.578979 */ |
| 9479 | 30738, /* A1 = -1.876099 */ |
| 9480 | -32702, /* A2 = 0.998016 */ |
| 9481 | 2967, /* B2 = 0.090561 */ |
| 9482 | -2793, /* B1 = -0.170502 */ |
| 9483 | 2967, /* B0 = 0.090561 */ |
| 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 | { /* f475 */ |
| 9490 | 30437, /* A1 = -1.857727 */ |
| 9491 | -32603, /* A2 = 0.994965 */ |
| 9492 | -264, /* B2 = -0.008062 */ |
| 9493 | 0, /* B1 = 0.000000 */ |
| 9494 | 264, /* B0 = 0.008062 */ |
| 9495 | 30430, /* A1 = -1.857300 */ |
| 9496 | -32692, /* A2 = 0.997711 */ |
| 9497 | 21681, /* B2 = 0.661682 */ |
| 9498 | -20082, /* B1 = -1.225708 */ |
| 9499 | 21681, /* B0 = 0.661682 */ |
| 9500 | 30526, /* A1 = -1.863220 */ |
| 9501 | -32694, /* A2 = 0.997742 */ |
| 9502 | 1559, /* B2 = 0.047600 */ |
| 9503 | -1459, /* B1 = -0.089096 */ |
| 9504 | 1559, /* B0 = 0.047600 */ |
| 9505 | 5, /* 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 | { /* f480_620[] */ |
| 9511 | 28975, /* A1 = 1.768494 */ |
| 9512 | -30955, /* A2 = -0.944672 */ |
| 9513 | -1026, /* B2 = -0.03133 */ |
| 9514 | 0, /* B1 = 0 */ |
| 9515 | 1026, /* B0 = 0.03133 */ |
| 9516 | 28613, /* A1 = 1.746399 */ |
| 9517 | -32089, /* A2 = -0.979309 */ |
| 9518 | 14214, /* B2 = 0.433807 */ |
| 9519 | -12202, /* B1 = -0.744812 */ |
| 9520 | 14214, /* B0 = 0.433807 */ |
| 9521 | 30243, /* A1 = 1.845947 */ |
| 9522 | -32238, /* A2 = -0.983856 */ |
| 9523 | 24825, /* B2 = 0.757629 */ |
| 9524 | -23402, /* B1 = -1.428345 */ |
| 9525 | 24825, /* B0 = 0.757629 */ |
| 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 | { /* f494 */ |
| 9532 | 30257, /* A1 = -1.846741 */ |
| 9533 | -32605, /* A2 = 0.995056 */ |
| 9534 | -249, /* B2 = -0.007625 */ |
| 9535 | 0, /* B1 = 0.000000 */ |
| 9536 | 249, /* B0 = 0.007625 */ |
| 9537 | 30247, /* A1 = -1.846191 */ |
| 9538 | -32694, /* A2 = 0.997772 */ |
| 9539 | 18088, /* B2 = 0.552002 */ |
| 9540 | -16652, /* B1 = -1.016418 */ |
| 9541 | 18088, /* B0 = 0.552002 */ |
| 9542 | 30348, /* A1 = -1.852295 */ |
| 9543 | -32696, /* A2 = 0.997803 */ |
| 9544 | 2099, /* B2 = 0.064064 */ |
| 9545 | -1953, /* B1 = -0.119202 */ |
| 9546 | 2099, /* B0 = 0.064064 */ |
| 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 | { /* f500 */ |
| 9553 | 30202, /* A1 = -1.843431 */ |
| 9554 | -32624, /* A2 = 0.995622 */ |
| 9555 | -413, /* B2 = -0.012622 */ |
| 9556 | 0, /* B1 = 0.000000 */ |
| 9557 | 413, /* B0 = 0.012622 */ |
| 9558 | 30191, /* A1 = -1.842721 */ |
| 9559 | -32714, /* A2 = 0.998364 */ |
| 9560 | 25954, /* B2 = 0.792057 */ |
| 9561 | -23890, /* B1 = -1.458131 */ |
| 9562 | 25954, /* B0 = 0.792057 */ |
| 9563 | 30296, /* A1 = -1.849172 */ |
| 9564 | -32715, /* A2 = 0.998397 */ |
| 9565 | 2007, /* B2 = 0.061264 */ |
| 9566 | -1860, /* B1 = -0.113568 */ |
| 9567 | 2007, /* B0 = 0.061264 */ |
| 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 | { /* f520 */ |
| 9574 | 30001, /* A1 = -1.831116 */ |
| 9575 | -32613, /* A2 = 0.995270 */ |
| 9576 | -155, /* B2 = -0.004750 */ |
| 9577 | 0, /* B1 = 0.000000 */ |
| 9578 | 155, /* B0 = 0.004750 */ |
| 9579 | 29985, /* A1 = -1.830200 */ |
| 9580 | -32710, /* A2 = 0.998260 */ |
| 9581 | 6584, /* B2 = 0.200928 */ |
| 9582 | -6018, /* B1 = -0.367355 */ |
| 9583 | 6584, /* B0 = 0.200928 */ |
| 9584 | 30105, /* A1 = -1.837524 */ |
| 9585 | -32712, /* A2 = 0.998291 */ |
| 9586 | 23812, /* B2 = 0.726685 */ |
| 9587 | -21936, /* B1 = -1.338928 */ |
| 9588 | 23812, /* B0 = 0.726685 */ |
| 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 | { /* f523 */ |
| 9595 | 29964, /* A1 = -1.828918 */ |
| 9596 | -32601, /* A2 = 0.994904 */ |
| 9597 | -101, /* B2 = -0.003110 */ |
| 9598 | 0, /* B1 = 0.000000 */ |
| 9599 | 101, /* B0 = 0.003110 */ |
| 9600 | 29949, /* A1 = -1.827942 */ |
| 9601 | -32700, /* A2 = 0.997925 */ |
| 9602 | 11041, /* B2 = 0.336975 */ |
| 9603 | -10075, /* B1 = -0.614960 */ |
| 9604 | 11041, /* B0 = 0.336975 */ |
| 9605 | 30070, /* A1 = -1.835388 */ |
| 9606 | -32702, /* A2 = 0.997986 */ |
| 9607 | 16762, /* B2 = 0.511536 */ |
| 9608 | -15437, /* B1 = -0.942230 */ |
| 9609 | 16762, /* B0 = 0.511536 */ |
| 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 | { /* f525 */ |
| 9616 | 29936, /* A1 = -1.827209 */ |
| 9617 | -32584, /* A2 = 0.994415 */ |
| 9618 | -91, /* B2 = -0.002806 */ |
| 9619 | 0, /* B1 = 0.000000 */ |
| 9620 | 91, /* B0 = 0.002806 */ |
| 9621 | 29921, /* A1 = -1.826233 */ |
| 9622 | -32688, /* A2 = 0.997559 */ |
| 9623 | 11449, /* B2 = 0.349396 */ |
| 9624 | -10426, /* B1 = -0.636383 */ |
| 9625 | 11449, /* B0 = 0.349396 */ |
| 9626 | 30045, /* A1 = -1.833862 */ |
| 9627 | -32688, /* A2 = 0.997589 */ |
| 9628 | 13055, /* B2 = 0.398407 */ |
| 9629 | -12028, /* B1 = -0.734161 */ |
| 9630 | 13055, /* B0 = 0.398407 */ |
| 9631 | 5, /* 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 | { /* f540_660[] */ |
| 9637 | 28499, /* A1 = 1.739441 */ |
| 9638 | -31129, /* A2 = -0.949982 */ |
| 9639 | -849, /* B2 = -0.025922 */ |
| 9640 | 0, /* B1 = 0 */ |
| 9641 | 849, /* B0 = 0.025922 */ |
| 9642 | 28128, /* A1 = 1.716797 */ |
| 9643 | -32130, /* A2 = -0.98056 */ |
| 9644 | 14556, /* B2 = 0.444214 */ |
| 9645 | -12251, /* B1 = -0.747772 */ |
| 9646 | 14556, /* B0 = 0.444244 */ |
| 9647 | 29667, /* A1 = 1.81073 */ |
| 9648 | -32244, /* A2 = -0.984039 */ |
| 9649 | 23038, /* B2 = 0.703064 */ |
| 9650 | -21358, /* B1 = -1.303589 */ |
| 9651 | 23040, /* B0 = 0.703125 */ |
| 9652 | 7, /* 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 | { /* f587 */ |
| 9658 | 29271, /* A1 = -1.786560 */ |
| 9659 | -32599, /* A2 = 0.994873 */ |
| 9660 | -490, /* B2 = -0.014957 */ |
| 9661 | 0, /* B1 = 0.000000 */ |
| 9662 | 490, /* B0 = 0.014957 */ |
| 9663 | 29246, /* A1 = -1.785095 */ |
| 9664 | -32700, /* A2 = 0.997925 */ |
| 9665 | 28961, /* B2 = 0.883850 */ |
| 9666 | -25796, /* B1 = -1.574463 */ |
| 9667 | 28961, /* B0 = 0.883850 */ |
| 9668 | 29383, /* A1 = -1.793396 */ |
| 9669 | -32700, /* A2 = 0.997955 */ |
| 9670 | 1299, /* B2 = 0.039650 */ |
| 9671 | -1169, /* B1 = -0.071396 */ |
| 9672 | 1299, /* B0 = 0.039650 */ |
| 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 | { /* f590 */ |
| 9679 | 29230, /* A1 = -1.784058 */ |
| 9680 | -32584, /* A2 = 0.994415 */ |
| 9681 | -418, /* B2 = -0.012757 */ |
| 9682 | 0, /* B1 = 0.000000 */ |
| 9683 | 418, /* B0 = 0.012757 */ |
| 9684 | 29206, /* A1 = -1.782593 */ |
| 9685 | -32688, /* A2 = 0.997559 */ |
| 9686 | 36556, /* B2 = 1.115601 */ |
| 9687 | -32478, /* B1 = -1.982300 */ |
| 9688 | 36556, /* B0 = 1.115601 */ |
| 9689 | 29345, /* A1 = -1.791077 */ |
| 9690 | -32688, /* A2 = 0.997589 */ |
| 9691 | 897, /* B2 = 0.027397 */ |
| 9692 | -808, /* B1 = -0.049334 */ |
| 9693 | 897, /* B0 = 0.027397 */ |
| 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 | { /* f600 */ |
| 9700 | 29116, /* A1 = -1.777100 */ |
| 9701 | -32603, /* A2 = 0.994965 */ |
| 9702 | -165, /* B2 = -0.005039 */ |
| 9703 | 0, /* B1 = 0.000000 */ |
| 9704 | 165, /* B0 = 0.005039 */ |
| 9705 | 29089, /* A1 = -1.775452 */ |
| 9706 | -32708, /* A2 = 0.998199 */ |
| 9707 | 6963, /* B2 = 0.212494 */ |
| 9708 | -6172, /* B1 = -0.376770 */ |
| 9709 | 6963, /* B0 = 0.212494 */ |
| 9710 | 29237, /* A1 = -1.784485 */ |
| 9711 | -32710, /* A2 = 0.998230 */ |
| 9712 | 24197, /* B2 = 0.738464 */ |
| 9713 | -21657, /* B1 = -1.321899 */ |
| 9714 | 24197, /* B0 = 0.738464 */ |
| 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 | { /* f660 */ |
| 9721 | 28376, /* A1 = -1.731934 */ |
| 9722 | -32567, /* A2 = 0.993896 */ |
| 9723 | -363, /* B2 = -0.011102 */ |
| 9724 | 0, /* B1 = 0.000000 */ |
| 9725 | 363, /* B0 = 0.011102 */ |
| 9726 | 28337, /* A1 = -1.729614 */ |
| 9727 | -32683, /* A2 = 0.997434 */ |
| 9728 | 21766, /* B2 = 0.664246 */ |
| 9729 | -18761, /* B1 = -1.145081 */ |
| 9730 | 21766, /* B0 = 0.664246 */ |
| 9731 | 28513, /* A1 = -1.740356 */ |
| 9732 | -32686, /* A2 = 0.997498 */ |
| 9733 | 2509, /* B2 = 0.076584 */ |
| 9734 | -2196, /* B1 = -0.134041 */ |
| 9735 | 2509, /* B0 = 0.076584 */ |
| 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 | { /* f700 */ |
| 9742 | 27844, /* A1 = -1.699463 */ |
| 9743 | -32563, /* A2 = 0.993744 */ |
| 9744 | -366, /* B2 = -0.011187 */ |
| 9745 | 0, /* B1 = 0.000000 */ |
| 9746 | 366, /* B0 = 0.011187 */ |
| 9747 | 27797, /* A1 = -1.696655 */ |
| 9748 | -32686, /* A2 = 0.997498 */ |
| 9749 | 22748, /* B2 = 0.694214 */ |
| 9750 | -19235, /* B1 = -1.174072 */ |
| 9751 | 22748, /* B0 = 0.694214 */ |
| 9752 | 27995, /* A1 = -1.708740 */ |
| 9753 | -32688, /* A2 = 0.997559 */ |
| 9754 | 2964, /* B2 = 0.090477 */ |
| 9755 | -2546, /* B1 = -0.155449 */ |
| 9756 | 2964, /* B0 = 0.090477 */ |
| 9757 | 5, /* 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 | { /* f740 */ |
| 9763 | 27297, /* A1 = -1.666077 */ |
| 9764 | -32551, /* A2 = 0.993408 */ |
| 9765 | -345, /* B2 = -0.010540 */ |
| 9766 | 0, /* B1 = 0.000000 */ |
| 9767 | 345, /* B0 = 0.010540 */ |
| 9768 | 27240, /* A1 = -1.662598 */ |
| 9769 | -32683, /* A2 = 0.997406 */ |
| 9770 | 22560, /* B2 = 0.688477 */ |
| 9771 | -18688, /* B1 = -1.140625 */ |
| 9772 | 22560, /* B0 = 0.688477 */ |
| 9773 | 27461, /* A1 = -1.676147 */ |
| 9774 | -32684, /* A2 = 0.997467 */ |
| 9775 | 3541, /* B2 = 0.108086 */ |
| 9776 | -2985, /* B1 = -0.182220 */ |
| 9777 | 3541, /* B0 = 0.108086 */ |
| 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 | { /* f750 */ |
| 9784 | 27155, /* A1 = -1.657410 */ |
| 9785 | -32551, /* A2 = 0.993408 */ |
| 9786 | -462, /* B2 = -0.014117 */ |
| 9787 | 0, /* B1 = 0.000000 */ |
| 9788 | 462, /* B0 = 0.014117 */ |
| 9789 | 27097, /* A1 = -1.653870 */ |
| 9790 | -32683, /* A2 = 0.997406 */ |
| 9791 | 32495, /* B2 = 0.991699 */ |
| 9792 | -26776, /* B1 = -1.634338 */ |
| 9793 | 32495, /* B0 = 0.991699 */ |
| 9794 | 27321, /* A1 = -1.667542 */ |
| 9795 | -32684, /* A2 = 0.997467 */ |
| 9796 | 1835, /* B2 = 0.056007 */ |
| 9797 | -1539, /* B1 = -0.093948 */ |
| 9798 | 1835, /* B0 = 0.056007 */ |
| 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 | { /* f750_1450[] */ |
| 9805 | 19298, /* A1 = 1.177917 */ |
| 9806 | -24471, /* A2 = -0.746796 */ |
| 9807 | -4152, /* B2 = -0.126709 */ |
| 9808 | 0, /* B1 = 0 */ |
| 9809 | 4152, /* B0 = 0.126709 */ |
| 9810 | 12902, /* A1 = 0.787476 */ |
| 9811 | -29091, /* A2 = -0.887817 */ |
| 9812 | 12491, /* B2 = 0.38121 */ |
| 9813 | -1794, /* B1 = -0.109528 */ |
| 9814 | 12494, /* B0 = 0.381317 */ |
| 9815 | 26291, /* A1 = 1.604736 */ |
| 9816 | -30470, /* A2 = -0.929901 */ |
| 9817 | 28859, /* B2 = 0.880737 */ |
| 9818 | -26084, /* B1 = -1.592102 */ |
| 9819 | 28861, /* B0 = 0.880798 */ |
| 9820 | 7, /* 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 | { /* f770 */ |
| 9826 | 26867, /* A1 = -1.639832 */ |
| 9827 | -32551, /* A2 = 0.993408 */ |
| 9828 | -123, /* B2 = -0.003755 */ |
| 9829 | 0, /* B1 = 0.000000 */ |
| 9830 | 123, /* B0 = 0.003755 */ |
| 9831 | 26805, /* A1 = -1.636108 */ |
| 9832 | -32683, /* A2 = 0.997406 */ |
| 9833 | 17297, /* B2 = 0.527863 */ |
| 9834 | -14096, /* B1 = -0.860382 */ |
| 9835 | 17297, /* B0 = 0.527863 */ |
| 9836 | 27034, /* A1 = -1.650085 */ |
| 9837 | -32684, /* A2 = 0.997467 */ |
| 9838 | 12958, /* B2 = 0.395477 */ |
| 9839 | -10756, /* B1 = -0.656525 */ |
| 9840 | 12958, /* B0 = 0.395477 */ |
| 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 | { /* f800 */ |
| 9847 | 26413, /* A1 = -1.612122 */ |
| 9848 | -32547, /* A2 = 0.993286 */ |
| 9849 | -223, /* B2 = -0.006825 */ |
| 9850 | 0, /* B1 = 0.000000 */ |
| 9851 | 223, /* B0 = 0.006825 */ |
| 9852 | 26342, /* A1 = -1.607849 */ |
| 9853 | -32686, /* A2 = 0.997498 */ |
| 9854 | 6391, /* B2 = 0.195053 */ |
| 9855 | -5120, /* B1 = -0.312531 */ |
| 9856 | 6391, /* B0 = 0.195053 */ |
| 9857 | 26593, /* A1 = -1.623108 */ |
| 9858 | -32688, /* A2 = 0.997559 */ |
| 9859 | 23681, /* B2 = 0.722717 */ |
| 9860 | -19328, /* B1 = -1.179688 */ |
| 9861 | 23681, /* B0 = 0.722717 */ |
| 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 | { /* f816 */ |
| 9868 | 26168, /* A1 = -1.597209 */ |
| 9869 | -32528, /* A2 = 0.992706 */ |
| 9870 | -235, /* B2 = -0.007182 */ |
| 9871 | 0, /* B1 = 0.000000 */ |
| 9872 | 235, /* B0 = 0.007182 */ |
| 9873 | 26092, /* A1 = -1.592590 */ |
| 9874 | -32675, /* A2 = 0.997192 */ |
| 9875 | 20823, /* B2 = 0.635498 */ |
| 9876 | -16510, /* B1 = -1.007751 */ |
| 9877 | 20823, /* B0 = 0.635498 */ |
| 9878 | 26363, /* A1 = -1.609070 */ |
| 9879 | -32677, /* A2 = 0.997253 */ |
| 9880 | 6739, /* B2 = 0.205688 */ |
| 9881 | -5459, /* B1 = -0.333206 */ |
| 9882 | 6739, /* B0 = 0.205688 */ |
| 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 | { /* f850 */ |
| 9889 | 25641, /* A1 = -1.565063 */ |
| 9890 | -32536, /* A2 = 0.992950 */ |
| 9891 | -121, /* B2 = -0.003707 */ |
| 9892 | 0, /* B1 = 0.000000 */ |
| 9893 | 121, /* B0 = 0.003707 */ |
| 9894 | 25560, /* A1 = -1.560059 */ |
| 9895 | -32684, /* A2 = 0.997437 */ |
| 9896 | 18341, /* B2 = 0.559753 */ |
| 9897 | -14252, /* B1 = -0.869904 */ |
| 9898 | 18341, /* B0 = 0.559753 */ |
| 9899 | 25837, /* A1 = -1.577026 */ |
| 9900 | -32684, /* A2 = 0.997467 */ |
| 9901 | 16679, /* B2 = 0.509003 */ |
| 9902 | -13232, /* B1 = -0.807648 */ |
| 9903 | 16679, /* B0 = 0.509003 */ |
| 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 | { /* f857_1645[] */ |
| 9910 | 16415, /* A1 = 1.001953 */ |
| 9911 | -23669, /* A2 = -0.722321 */ |
| 9912 | -4549, /* B2 = -0.138847 */ |
| 9913 | 0, /* B1 = 0 */ |
| 9914 | 4549, /* B0 = 0.138847 */ |
| 9915 | 8456, /* A1 = 0.516174 */ |
| 9916 | -28996, /* A2 = -0.884918 */ |
| 9917 | 13753, /* B2 = 0.419724 */ |
| 9918 | -12, /* B1 = -0.000763 */ |
| 9919 | 13757, /* B0 = 0.419846 */ |
| 9920 | 24632, /* A1 = 1.503418 */ |
| 9921 | -30271, /* A2 = -0.923828 */ |
| 9922 | 29070, /* B2 = 0.887146 */ |
| 9923 | -25265, /* B1 = -1.542114 */ |
| 9924 | 29073, /* B0 = 0.887268 */ |
| 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 | { /* f900 */ |
| 9931 | 24806, /* A1 = -1.514099 */ |
| 9932 | -32501, /* A2 = 0.991852 */ |
| 9933 | -326, /* B2 = -0.009969 */ |
| 9934 | 0, /* B1 = 0.000000 */ |
| 9935 | 326, /* B0 = 0.009969 */ |
| 9936 | 24709, /* A1 = -1.508118 */ |
| 9937 | -32659, /* A2 = 0.996674 */ |
| 9938 | 20277, /* B2 = 0.618835 */ |
| 9939 | -15182, /* B1 = -0.926636 */ |
| 9940 | 20277, /* B0 = 0.618835 */ |
| 9941 | 25022, /* A1 = -1.527222 */ |
| 9942 | -32661, /* A2 = 0.996735 */ |
| 9943 | 4320, /* B2 = 0.131836 */ |
| 9944 | -3331, /* B1 = -0.203339 */ |
| 9945 | 4320, /* B0 = 0.131836 */ |
| 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 | { /* f900_1300[] */ |
| 9952 | 19776, /* A1 = 1.207092 */ |
| 9953 | -27437, /* A2 = -0.837341 */ |
| 9954 | -2666, /* B2 = -0.081371 */ |
| 9955 | 0, /* B1 = 0 */ |
| 9956 | 2666, /* B0 = 0.081371 */ |
| 9957 | 16302, /* A1 = 0.995026 */ |
| 9958 | -30354, /* A2 = -0.926361 */ |
| 9959 | 10389, /* B2 = 0.317062 */ |
| 9960 | -3327, /* B1 = -0.203064 */ |
| 9961 | 10389, /* B0 = 0.317062 */ |
| 9962 | 24299, /* A1 = 1.483154 */ |
| 9963 | -30930, /* A2 = -0.943909 */ |
| 9964 | 25016, /* B2 = 0.763428 */ |
| 9965 | -21171, /* B1 = -1.292236 */ |
| 9966 | 25016, /* B0 = 0.763428 */ |
| 9967 | 7, /* 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 | { /* f935_1215[] */ |
| 9973 | 20554, /* A1 = 1.254517 */ |
| 9974 | -28764, /* A2 = -0.877838 */ |
| 9975 | -2048, /* B2 = -0.062515 */ |
| 9976 | 0, /* B1 = 0 */ |
| 9977 | 2048, /* B0 = 0.062515 */ |
| 9978 | 18209, /* A1 = 1.11145 */ |
| 9979 | -30951, /* A2 = -0.94458 */ |
| 9980 | 9390, /* B2 = 0.286575 */ |
| 9981 | -3955, /* B1 = -0.241455 */ |
| 9982 | 9390, /* B0 = 0.286575 */ |
| 9983 | 23902, /* A1 = 1.458923 */ |
| 9984 | -31286, /* A2 = -0.954803 */ |
| 9985 | 23252, /* B2 = 0.709595 */ |
| 9986 | -19132, /* B1 = -1.167725 */ |
| 9987 | 23252, /* B0 = 0.709595 */ |
| 9988 | 7, /* 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 | { /* f941_1477[] */ |
| 9994 | 17543, /* A1 = 1.07074 */ |
| 9995 | -26220, /* A2 = -0.800201 */ |
| 9996 | -3298, /* B2 = -0.100647 */ |
| 9997 | 0, /* B1 = 0 */ |
| 9998 | 3298, /* B0 = 0.100647 */ |
| 9999 | 12423, /* A1 = 0.75827 */ |
| 10000 | -30036, /* A2 = -0.916626 */ |
| 10001 | 12651, /* B2 = 0.386078 */ |
| 10002 | -2444, /* B1 = -0.14917 */ |
| 10003 | 12653, /* B0 = 0.386154 */ |
| 10004 | 23518, /* A1 = 1.435425 */ |
| 10005 | -30745, /* A2 = -0.938293 */ |
| 10006 | 27282, /* B2 = 0.832581 */ |
| 10007 | -22529, /* B1 = -1.375122 */ |
| 10008 | 27286, /* B0 = 0.832703 */ |
| 10009 | 7, /* 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 | { /* f942 */ |
| 10015 | 24104, /* A1 = -1.471252 */ |
| 10016 | -32507, /* A2 = 0.992065 */ |
| 10017 | -351, /* B2 = -0.010722 */ |
| 10018 | 0, /* B1 = 0.000000 */ |
| 10019 | 351, /* B0 = 0.010722 */ |
| 10020 | 23996, /* A1 = -1.464600 */ |
| 10021 | -32671, /* A2 = 0.997040 */ |
| 10022 | 22848, /* B2 = 0.697266 */ |
| 10023 | -16639, /* B1 = -1.015564 */ |
| 10024 | 22848, /* B0 = 0.697266 */ |
| 10025 | 24332, /* A1 = -1.485168 */ |
| 10026 | -32673, /* A2 = 0.997101 */ |
| 10027 | 4906, /* B2 = 0.149727 */ |
| 10028 | -3672, /* B1 = -0.224174 */ |
| 10029 | 4906, /* B0 = 0.149727 */ |
| 10030 | 5, /* 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 | { /* f950 */ |
| 10036 | 23967, /* A1 = -1.462830 */ |
| 10037 | -32507, /* A2 = 0.992065 */ |
| 10038 | -518, /* B2 = -0.015821 */ |
| 10039 | 0, /* B1 = 0.000000 */ |
| 10040 | 518, /* B0 = 0.015821 */ |
| 10041 | 23856, /* A1 = -1.456055 */ |
| 10042 | -32671, /* A2 = 0.997040 */ |
| 10043 | 26287, /* B2 = 0.802246 */ |
| 10044 | -19031, /* B1 = -1.161560 */ |
| 10045 | 26287, /* B0 = 0.802246 */ |
| 10046 | 24195, /* A1 = -1.476746 */ |
| 10047 | -32673, /* A2 = 0.997101 */ |
| 10048 | 2890, /* B2 = 0.088196 */ |
| 10049 | -2151, /* B1 = -0.131317 */ |
| 10050 | 2890, /* B0 = 0.088196 */ |
| 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 | { /* f950_1400[] */ |
| 10057 | 18294, /* A1 = 1.116638 */ |
| 10058 | -26962, /* A2 = -0.822845 */ |
| 10059 | -2914, /* B2 = -0.088936 */ |
| 10060 | 0, /* B1 = 0 */ |
| 10061 | 2914, /* B0 = 0.088936 */ |
| 10062 | 14119, /* A1 = 0.861786 */ |
| 10063 | -30227, /* A2 = -0.922455 */ |
| 10064 | 11466, /* B2 = 0.349945 */ |
| 10065 | -2833, /* B1 = -0.172943 */ |
| 10066 | 11466, /* B0 = 0.349945 */ |
| 10067 | 23431, /* A1 = 1.430115 */ |
| 10068 | -30828, /* A2 = -0.940796 */ |
| 10069 | 25331, /* B2 = 0.773071 */ |
| 10070 | -20911, /* B1 = -1.276367 */ |
| 10071 | 25331, /* B0 = 0.773071 */ |
| 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 | { /* f975 */ |
| 10078 | 23521, /* A1 = -1.435608 */ |
| 10079 | -32489, /* A2 = 0.991516 */ |
| 10080 | -193, /* B2 = -0.005915 */ |
| 10081 | 0, /* B1 = 0.000000 */ |
| 10082 | 193, /* B0 = 0.005915 */ |
| 10083 | 23404, /* A1 = -1.428467 */ |
| 10084 | -32655, /* A2 = 0.996582 */ |
| 10085 | 17740, /* B2 = 0.541412 */ |
| 10086 | -12567, /* B1 = -0.767029 */ |
| 10087 | 17740, /* B0 = 0.541412 */ |
| 10088 | 23753, /* A1 = -1.449829 */ |
| 10089 | -32657, /* A2 = 0.996613 */ |
| 10090 | 9090, /* B2 = 0.277405 */ |
| 10091 | -6662, /* B1 = -0.406647 */ |
| 10092 | 9090, /* B0 = 0.277405 */ |
| 10093 | 5, /* 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 | { /* f1000 */ |
| 10099 | 23071, /* A1 = -1.408203 */ |
| 10100 | -32489, /* A2 = 0.991516 */ |
| 10101 | -293, /* B2 = -0.008965 */ |
| 10102 | 0, /* B1 = 0.000000 */ |
| 10103 | 293, /* B0 = 0.008965 */ |
| 10104 | 22951, /* A1 = -1.400818 */ |
| 10105 | -32655, /* A2 = 0.996582 */ |
| 10106 | 5689, /* B2 = 0.173645 */ |
| 10107 | -3951, /* B1 = -0.241150 */ |
| 10108 | 5689, /* B0 = 0.173645 */ |
| 10109 | 23307, /* A1 = -1.422607 */ |
| 10110 | -32657, /* A2 = 0.996613 */ |
| 10111 | 18692, /* B2 = 0.570435 */ |
| 10112 | -13447, /* B1 = -0.820770 */ |
| 10113 | 18692, /* B0 = 0.570435 */ |
| 10114 | 5, /* 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 | { /* f1020 */ |
| 10120 | 22701, /* A1 = -1.385620 */ |
| 10121 | -32474, /* A2 = 0.991058 */ |
| 10122 | -292, /* B2 = -0.008933 */ |
| 10123 | 0, /*163840 , B1 = 10.000000 */ |
| 10124 | 292, /* B0 = 0.008933 */ |
| 10125 | 22564, /* A1 = -1.377258 */ |
| 10126 | -32655, /* A2 = 0.996552 */ |
| 10127 | 20756, /* B2 = 0.633423 */ |
| 10128 | -14176, /* B1 = -0.865295 */ |
| 10129 | 20756, /* B0 = 0.633423 */ |
| 10130 | 22960, /* A1 = -1.401428 */ |
| 10131 | -32657, /* A2 = 0.996613 */ |
| 10132 | 6520, /* B2 = 0.198990 */ |
| 10133 | -4619, /* B1 = -0.281937 */ |
| 10134 | 6520, /* B0 = 0.198990 */ |
| 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 | { /* f1050 */ |
| 10141 | 22142, /* A1 = -1.351501 */ |
| 10142 | -32474, /* A2 = 0.991058 */ |
| 10143 | -147, /* B2 = -0.004493 */ |
| 10144 | 0, /* B1 = 0.000000 */ |
| 10145 | 147, /* B0 = 0.004493 */ |
| 10146 | 22000, /* A1 = -1.342834 */ |
| 10147 | -32655, /* A2 = 0.996552 */ |
| 10148 | 15379, /* B2 = 0.469360 */ |
| 10149 | -10237, /* B1 = -0.624847 */ |
| 10150 | 15379, /* B0 = 0.469360 */ |
| 10151 | 22406, /* A1 = -1.367554 */ |
| 10152 | -32657, /* A2 = 0.996613 */ |
| 10153 | 17491, /* B2 = 0.533783 */ |
| 10154 | -12096, /* B1 = -0.738312 */ |
| 10155 | 17491, /* B0 = 0.533783 */ |
| 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 | { /* f1100_1750[] */ |
| 10162 | 12973, /* A1 = 0.79184 */ |
| 10163 | -24916, /* A2 = -0.760376 */ |
| 10164 | 6655, /* B2 = 0.203102 */ |
| 10165 | 367, /* B1 = 0.0224 */ |
| 10166 | 6657, /* B0 = 0.203171 */ |
| 10167 | 5915, /* A1 = 0.361053 */ |
| 10168 | -29560, /* A2 = -0.90213 */ |
| 10169 | -7777, /* B2 = -0.23735 */ |
| 10170 | 0, /* B1 = 0 */ |
| 10171 | 7777, /* B0 = 0.23735 */ |
| 10172 | 20510, /* A1 = 1.251892 */ |
| 10173 | -30260, /* A2 = -0.923462 */ |
| 10174 | 26662, /* B2 = 0.81366 */ |
| 10175 | -20573, /* B1 = -1.255737 */ |
| 10176 | 26668, /* B0 = 0.813843 */ |
| 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 | { /* f1140 */ |
| 10183 | 20392, /* A1 = -1.244629 */ |
| 10184 | -32460, /* A2 = 0.990601 */ |
| 10185 | -270, /* B2 = -0.008240 */ |
| 10186 | 0, /* B1 = 0.000000 */ |
| 10187 | 270, /* B0 = 0.008240 */ |
| 10188 | 20218, /* A1 = -1.234009 */ |
| 10189 | -32655, /* A2 = 0.996582 */ |
| 10190 | 21337, /* B2 = 0.651154 */ |
| 10191 | -13044, /* B1 = -0.796143 */ |
| 10192 | 21337, /* B0 = 0.651154 */ |
| 10193 | 20684, /* A1 = -1.262512 */ |
| 10194 | -32657, /* A2 = 0.996643 */ |
| 10195 | 8572, /* B2 = 0.261612 */ |
| 10196 | -5476, /* B1 = -0.334244 */ |
| 10197 | 8572, /* B0 = 0.261612 */ |
| 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 | { /* f1200 */ |
| 10204 | 19159, /* A1 = -1.169373 */ |
| 10205 | -32456, /* A2 = 0.990509 */ |
| 10206 | -335, /* B2 = -0.010252 */ |
| 10207 | 0, /* B1 = 0.000000 */ |
| 10208 | 335, /* B0 = 0.010252 */ |
| 10209 | 18966, /* A1 = -1.157593 */ |
| 10210 | -32661, /* A2 = 0.996735 */ |
| 10211 | 6802, /* B2 = 0.207588 */ |
| 10212 | -3900, /* B1 = -0.238098 */ |
| 10213 | 6802, /* B0 = 0.207588 */ |
| 10214 | 19467, /* A1 = -1.188232 */ |
| 10215 | -32661, /* A2 = 0.996765 */ |
| 10216 | 25035, /* B2 = 0.764008 */ |
| 10217 | -15049, /* B1 = -0.918579 */ |
| 10218 | 25035, /* B0 = 0.764008 */ |
| 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 | { /* f1209 */ |
| 10225 | 18976, /* A1 = -1.158264 */ |
| 10226 | -32439, /* A2 = 0.989990 */ |
| 10227 | -183, /* B2 = -0.005588 */ |
| 10228 | 0, /* B1 = 0.000000 */ |
| 10229 | 183, /* B0 = 0.005588 */ |
| 10230 | 18774, /* A1 = -1.145874 */ |
| 10231 | -32650, /* A2 = 0.996429 */ |
| 10232 | 15468, /* B2 = 0.472076 */ |
| 10233 | -8768, /* B1 = -0.535217 */ |
| 10234 | 15468, /* B0 = 0.472076 */ |
| 10235 | 19300, /* A1 = -1.177979 */ |
| 10236 | -32652, /* A2 = 0.996490 */ |
| 10237 | 19840, /* B2 = 0.605499 */ |
| 10238 | -11842, /* B1 = -0.722809 */ |
| 10239 | 19840, /* B0 = 0.605499 */ |
| 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 | { /* f1330 */ |
| 10246 | 16357, /* A1 = -0.998413 */ |
| 10247 | -32368, /* A2 = 0.987793 */ |
| 10248 | -217, /* B2 = -0.006652 */ |
| 10249 | 0, /* B1 = 0.000000 */ |
| 10250 | 217, /* B0 = 0.006652 */ |
| 10251 | 16107, /* A1 = -0.983126 */ |
| 10252 | -32601, /* A2 = 0.994904 */ |
| 10253 | 11602, /* B2 = 0.354065 */ |
| 10254 | -5555, /* B1 = -0.339111 */ |
| 10255 | 11602, /* B0 = 0.354065 */ |
| 10256 | 16722, /* A1 = -1.020630 */ |
| 10257 | -32603, /* A2 = 0.994965 */ |
| 10258 | 15574, /* B2 = 0.475311 */ |
| 10259 | -8176, /* B1 = -0.499069 */ |
| 10260 | 15574, /* B0 = 0.475311 */ |
| 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 | { /* f1336 */ |
| 10267 | 16234, /* A1 = -0.990875 */ |
| 10268 | 32404, /* A2 = -0.988922 */ |
| 10269 | -193, /* B2 = -0.005908 */ |
| 10270 | 0, /* B1 = 0.000000 */ |
| 10271 | 193, /* B0 = 0.005908 */ |
| 10272 | 15986, /* A1 = -0.975769 */ |
| 10273 | -32632, /* A2 = 0.995880 */ |
| 10274 | 18051, /* B2 = 0.550903 */ |
| 10275 | -8658, /* B1 = -0.528473 */ |
| 10276 | 18051, /* B0 = 0.550903 */ |
| 10277 | 16591, /* A1 = -1.012695 */ |
| 10278 | -32634, /* A2 = 0.995941 */ |
| 10279 | 15736, /* B2 = 0.480240 */ |
| 10280 | -8125, /* B1 = -0.495926 */ |
| 10281 | 15736, /* B0 = 0.480240 */ |
| 10282 | 5, /* 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 | { /* f1366 */ |
| 10288 | 15564, /* A1 = -0.949982 */ |
| 10289 | -32404, /* A2 = 0.988922 */ |
| 10290 | -269, /* B2 = -0.008216 */ |
| 10291 | 0, /* B1 = 0.000000 */ |
| 10292 | 269, /* B0 = 0.008216 */ |
| 10293 | 15310, /* A1 = -0.934479 */ |
| 10294 | -32632, /* A2 = 0.995880 */ |
| 10295 | 10815, /* B2 = 0.330063 */ |
| 10296 | -4962, /* B1 = -0.302887 */ |
| 10297 | 10815, /* B0 = 0.330063 */ |
| 10298 | 15924, /* A1 = -0.971924 */ |
| 10299 | -32634, /* A2 = 0.995941 */ |
| 10300 | 18880, /* B2 = 0.576172 */ |
| 10301 | -9364, /* B1 = -0.571594 */ |
| 10302 | 18880, /* B0 = 0.576172 */ |
| 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 | { /* f1380 */ |
| 10309 | 15247, /* A1 = -0.930603 */ |
| 10310 | -32397, /* A2 = 0.988708 */ |
| 10311 | -244, /* B2 = -0.007451 */ |
| 10312 | 0, /* B1 = 0.000000 */ |
| 10313 | 244, /* B0 = 0.007451 */ |
| 10314 | 14989, /* A1 = -0.914886 */ |
| 10315 | -32627, /* A2 = 0.995697 */ |
| 10316 | 18961, /* B2 = 0.578644 */ |
| 10317 | -8498, /* B1 = -0.518707 */ |
| 10318 | 18961, /* B0 = 0.578644 */ |
| 10319 | 15608, /* A1 = -0.952667 */ |
| 10320 | -32628, /* A2 = 0.995758 */ |
| 10321 | 11145, /* B2 = 0.340134 */ |
| 10322 | -5430, /* B1 = -0.331467 */ |
| 10323 | 11145, /* B0 = 0.340134 */ |
| 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 | { /* f1400 */ |
| 10330 | 14780, /* A1 = -0.902130 */ |
| 10331 | -32393, /* A2 = 0.988586 */ |
| 10332 | -396, /* B2 = -0.012086 */ |
| 10333 | 0, /* B1 = 0.000000 */ |
| 10334 | 396, /* B0 = 0.012086 */ |
| 10335 | 14510, /* A1 = -0.885651 */ |
| 10336 | -32630, /* A2 = 0.995819 */ |
| 10337 | 6326, /* B2 = 0.193069 */ |
| 10338 | -2747, /* B1 = -0.167671 */ |
| 10339 | 6326, /* B0 = 0.193069 */ |
| 10340 | 15154, /* A1 = -0.924957 */ |
| 10341 | -32632, /* A2 = 0.995850 */ |
| 10342 | 23235, /* B2 = 0.709076 */ |
| 10343 | -10983, /* B1 = -0.670380 */ |
| 10344 | 23235, /* B0 = 0.709076 */ |
| 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 | { /* f1477 */ |
| 10351 | 13005, /* A1 = -0.793793 */ |
| 10352 | -32368, /* A2 = 0.987823 */ |
| 10353 | -500, /* B2 = -0.015265 */ |
| 10354 | 0, /* B1 = 0.000000 */ |
| 10355 | 500, /* B0 = 0.015265 */ |
| 10356 | 12708, /* A1 = -0.775665 */ |
| 10357 | -32615, /* A2 = 0.995331 */ |
| 10358 | 11420, /* B2 = 0.348526 */ |
| 10359 | -4306, /* B1 = -0.262833 */ |
| 10360 | 11420, /* B0 = 0.348526 */ |
| 10361 | 13397, /* A1 = -0.817688 */ |
| 10362 | -32615, /* A2 = 0.995361 */ |
| 10363 | 9454, /* B2 = 0.288528 */ |
| 10364 | -3981, /* B1 = -0.243027 */ |
| 10365 | 9454, /* B0 = 0.288528 */ |
| 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 | { /* f1600 */ |
| 10372 | 10046, /* A1 = -0.613190 */ |
| 10373 | -32331, /* A2 = 0.986694 */ |
| 10374 | -455, /* B2 = -0.013915 */ |
| 10375 | 0, /* B1 = 0.000000 */ |
| 10376 | 455, /* B0 = 0.013915 */ |
| 10377 | 9694, /* A1 = -0.591705 */ |
| 10378 | -32601, /* A2 = 0.994934 */ |
| 10379 | 6023, /* B2 = 0.183815 */ |
| 10380 | -1708, /* B1 = -0.104279 */ |
| 10381 | 6023, /* B0 = 0.183815 */ |
| 10382 | 10478, /* A1 = -0.639587 */ |
| 10383 | -32603, /* A2 = 0.994965 */ |
| 10384 | 22031, /* B2 = 0.672333 */ |
| 10385 | -7342, /* B1 = -0.448151 */ |
| 10386 | 22031, /* B0 = 0.672333 */ |
| 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 | { /* f1633_1638[] */ |
| 10393 | 9181, /* A1 = 0.560394 */ |
| 10394 | -32256, /* A2 = -0.984375 */ |
| 10395 | -556, /* B2 = -0.016975 */ |
| 10396 | 0, /* B1 = 0 */ |
| 10397 | 556, /* B0 = 0.016975 */ |
| 10398 | 8757, /* A1 = 0.534515 */ |
| 10399 | -32574, /* A2 = -0.99408 */ |
| 10400 | 8443, /* B2 = 0.25769 */ |
| 10401 | -2135, /* B1 = -0.130341 */ |
| 10402 | 8443, /* B0 = 0.25769 */ |
| 10403 | 9691, /* A1 = 0.591522 */ |
| 10404 | -32574, /* A2 = -0.99411 */ |
| 10405 | 15446, /* B2 = 0.471375 */ |
| 10406 | -4809, /* B1 = -0.293579 */ |
| 10407 | 15446, /* B0 = 0.471375 */ |
| 10408 | 7, /* 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 | { /* f1800 */ |
| 10414 | 5076, /* A1 = -0.309875 */ |
| 10415 | -32304, /* A2 = 0.985840 */ |
| 10416 | -508, /* B2 = -0.015503 */ |
| 10417 | 0, /* B1 = 0.000000 */ |
| 10418 | 508, /* B0 = 0.015503 */ |
| 10419 | 4646, /* A1 = -0.283600 */ |
| 10420 | -32605, /* A2 = 0.995026 */ |
| 10421 | 6742, /* B2 = 0.205780 */ |
| 10422 | -878, /* B1 = -0.053635 */ |
| 10423 | 6742, /* B0 = 0.205780 */ |
| 10424 | 5552, /* A1 = -0.338928 */ |
| 10425 | -32605, /* A2 = 0.995056 */ |
| 10426 | 23667, /* B2 = 0.722260 */ |
| 10427 | -4297, /* B1 = -0.262329 */ |
| 10428 | 23667, /* B0 = 0.722260 */ |
| 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 | { /* f1860 */ |
| 10435 | 3569, /* A1 = -0.217865 */ |
| 10436 | -32292, /* A2 = 0.985504 */ |
| 10437 | -239, /* B2 = -0.007322 */ |
| 10438 | 0, /* B1 = 0.000000 */ |
| 10439 | 239, /* B0 = 0.007322 */ |
| 10440 | 3117, /* A1 = -0.190277 */ |
| 10441 | -32603, /* A2 = 0.994965 */ |
| 10442 | 18658, /* B2 = 0.569427 */ |
| 10443 | -1557, /* B1 = -0.095032 */ |
| 10444 | 18658, /* B0 = 0.569427 */ |
| 10445 | 4054, /* A1 = -0.247437 */ |
| 10446 | -32603, /* A2 = 0.994965 */ |
| 10447 | 18886, /* B2 = 0.576385 */ |
| 10448 | -2566, /* B1 = -0.156647 */ |
| 10449 | 18886, /* B0 = 0.576385 */ |
| 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 | }; |
| 10456 | static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf) |
| 10457 | { |
| 10458 | unsigned short cmd; |
| 10459 | int cnt, max; |
| 10460 | |
| 10461 | if (jf->filter > 3) { |
| 10462 | return -1; |
| 10463 | } |
| 10464 | if (ixj_WriteDSPCommand(0x5154 + jf->filter, j)) /* Select Filter */ |
| 10465 | |
| 10466 | return -1; |
| 10467 | if (!jf->enable) { |
| 10468 | if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */ |
| 10469 | |
| 10470 | return -1; |
| 10471 | else |
| 10472 | return 0; |
| 10473 | } else { |
| 10474 | if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */ |
| 10475 | |
| 10476 | return -1; |
| 10477 | /* Select the filter (f0 - f3) to use. */ |
| 10478 | if (ixj_WriteDSPCommand(0x5154 + jf->filter, j)) |
| 10479 | return -1; |
| 10480 | } |
| 10481 | if (jf->freq < 12 && jf->freq > 3) { |
| 10482 | /* Select the frequency for the selected filter. */ |
| 10483 | if (ixj_WriteDSPCommand(0x5170 + jf->freq, j)) |
| 10484 | return -1; |
| 10485 | } else if (jf->freq > 11) { |
| 10486 | /* We need to load a programmable filter set for undefined */ |
| 10487 | /* frequencies. So we will point the filter to a programmable set. */ |
| 10488 | /* Since there are only 4 filters and 4 programmable sets, we will */ |
| 10489 | /* just point the filter to the same number set and program it for the */ |
| 10490 | /* frequency we want. */ |
| 10491 | if (ixj_WriteDSPCommand(0x5170 + jf->filter, j)) |
| 10492 | return -1; |
| 10493 | if (j->ver.low != 0x12) { |
| 10494 | cmd = 0x515B; |
| 10495 | max = 19; |
| 10496 | } else { |
| 10497 | cmd = 0x515E; |
| 10498 | max = 15; |
| 10499 | } |
| 10500 | if (ixj_WriteDSPCommand(cmd, j)) |
| 10501 | return -1; |
| 10502 | for (cnt = 0; cnt < max; cnt++) { |
| 10503 | if (ixj_WriteDSPCommand(tone_table[jf->freq - 12][cnt], j)) |
| 10504 | return -1; |
| 10505 | } |
| 10506 | } |
| 10507 | j->filter_en[jf->filter] = jf->enable; |
| 10508 | return 0; |
| 10509 | } |
| 10510 | |
| 10511 | static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr) |
| 10512 | { |
| 10513 | unsigned short cmd; |
| 10514 | int cnt, max; |
| 10515 | if (jfr->filter > 3) { |
| 10516 | return -1; |
| 10517 | } |
| 10518 | if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j)) /* Select Filter */ |
| 10519 | return -1; |
| 10520 | |
| 10521 | if (!jfr->enable) { |
| 10522 | if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */ |
| 10523 | return -1; |
| 10524 | else |
| 10525 | return 0; |
| 10526 | } else { |
| 10527 | if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */ |
| 10528 | return -1; |
| 10529 | /* Select the filter (f0 - f3) to use. */ |
| 10530 | if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j)) |
| 10531 | return -1; |
| 10532 | } |
| 10533 | /* We need to load a programmable filter set for undefined */ |
| 10534 | /* frequencies. So we will point the filter to a programmable set. */ |
| 10535 | /* Since there are only 4 filters and 4 programmable sets, we will */ |
| 10536 | /* just point the filter to the same number set and program it for the */ |
| 10537 | /* frequency we want. */ |
| 10538 | if (ixj_WriteDSPCommand(0x5170 + jfr->filter, j)) |
| 10539 | return -1; |
| 10540 | if (j->ver.low != 0x12) { |
| 10541 | cmd = 0x515B; |
| 10542 | max = 19; |
| 10543 | } else { |
| 10544 | cmd = 0x515E; |
| 10545 | max = 15; |
| 10546 | } |
| 10547 | if (ixj_WriteDSPCommand(cmd, j)) |
| 10548 | return -1; |
| 10549 | for (cnt = 0; cnt < max; cnt++) { |
| 10550 | if (ixj_WriteDSPCommand(jfr->coeff[cnt], j)) |
| 10551 | return -1; |
| 10552 | } |
| 10553 | j->filter_en[jfr->filter] = jfr->enable; |
| 10554 | return 0; |
| 10555 | } |
| 10556 | |
| 10557 | static int ixj_init_tone(IXJ *j, IXJ_TONE * ti) |
| 10558 | { |
| 10559 | int freq0, freq1; |
| 10560 | unsigned short data; |
| 10561 | if (ti->freq0) { |
| 10562 | freq0 = ti->freq0; |
| 10563 | } else { |
| 10564 | freq0 = 0x7FFF; |
| 10565 | } |
| 10566 | |
| 10567 | if (ti->freq1) { |
| 10568 | freq1 = ti->freq1; |
| 10569 | } else { |
| 10570 | freq1 = 0x7FFF; |
| 10571 | } |
| 10572 | |
| 10573 | if(ti->tone_index > 12 && ti->tone_index < 28) |
| 10574 | { |
| 10575 | if (ixj_WriteDSPCommand(0x6800 + ti->tone_index, j)) |
| 10576 | return -1; |
| 10577 | if (ixj_WriteDSPCommand(0x6000 + (ti->gain1 << 4) + ti->gain0, j)) |
| 10578 | return -1; |
| 10579 | data = freq0; |
| 10580 | if (ixj_WriteDSPCommand(data, j)) |
| 10581 | return -1; |
| 10582 | data = freq1; |
| 10583 | if (ixj_WriteDSPCommand(data, j)) |
| 10584 | return -1; |
| 10585 | } |
| 10586 | return freq0; |
| 10587 | } |
| 10588 | |