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 | |
Nishanth Aravamudan | f4c9925 | 2005-09-10 00:26:50 -0700 | [diff] [blame] | 777 | msleep(jiffies_to_msecs(j->winktime)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | |
| 779 | SLIC_SetState(slicnow, j); |
| 780 | return 0; |
| 781 | } |
| 782 | |
| 783 | static void ixj_init_timer(IXJ *j) |
| 784 | { |
| 785 | init_timer(&j->timer); |
| 786 | j->timer.function = ixj_timeout; |
| 787 | j->timer.data = (unsigned long)j; |
| 788 | } |
| 789 | |
| 790 | static void ixj_add_timer(IXJ *j) |
| 791 | { |
| 792 | j->timer.expires = jiffies + (hertz / samplerate); |
| 793 | add_timer(&j->timer); |
| 794 | } |
| 795 | |
| 796 | static void ixj_tone_timeout(IXJ *j) |
| 797 | { |
| 798 | IXJ_TONE ti; |
| 799 | |
| 800 | j->tone_state++; |
| 801 | if (j->tone_state == 3) { |
| 802 | j->tone_state = 0; |
| 803 | if (j->cadence_t) { |
| 804 | j->tone_cadence_state++; |
| 805 | if (j->tone_cadence_state >= j->cadence_t->elements_used) { |
| 806 | switch (j->cadence_t->termination) { |
| 807 | case PLAY_ONCE: |
| 808 | ixj_cpt_stop(j); |
| 809 | break; |
| 810 | case REPEAT_LAST_ELEMENT: |
| 811 | j->tone_cadence_state--; |
| 812 | ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index); |
| 813 | break; |
| 814 | case REPEAT_ALL: |
| 815 | j->tone_cadence_state = 0; |
| 816 | if (j->cadence_t->ce[j->tone_cadence_state].freq0) { |
| 817 | ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index; |
| 818 | ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0; |
| 819 | ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0; |
| 820 | ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1; |
| 821 | ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1; |
| 822 | ixj_init_tone(j, &ti); |
| 823 | } |
| 824 | ixj_set_tone_on(j->cadence_t->ce[0].tone_on_time, j); |
| 825 | ixj_set_tone_off(j->cadence_t->ce[0].tone_off_time, j); |
| 826 | ixj_play_tone(j, j->cadence_t->ce[0].index); |
| 827 | break; |
| 828 | } |
| 829 | } else { |
| 830 | if (j->cadence_t->ce[j->tone_cadence_state].gain0) { |
| 831 | ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index; |
| 832 | ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0; |
| 833 | ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0; |
| 834 | ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1; |
| 835 | ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1; |
| 836 | ixj_init_tone(j, &ti); |
| 837 | } |
| 838 | ixj_set_tone_on(j->cadence_t->ce[j->tone_cadence_state].tone_on_time, j); |
| 839 | ixj_set_tone_off(j->cadence_t->ce[j->tone_cadence_state].tone_off_time, j); |
| 840 | ixj_play_tone(j, j->cadence_t->ce[j->tone_cadence_state].index); |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | static inline void ixj_kill_fasync(IXJ *j, IXJ_SIGEVENT event, int dir) |
| 847 | { |
| 848 | if(j->ixj_signals[event]) { |
| 849 | if(ixjdebug & 0x0100) |
| 850 | printk("Sending signal for event %d\n", event); |
| 851 | /* Send apps notice of change */ |
| 852 | /* see config.h for macro definition */ |
| 853 | kill_fasync(&(j->async_queue), j->ixj_signals[event], dir); |
| 854 | } |
| 855 | } |
| 856 | |
| 857 | static void ixj_pstn_state(IXJ *j) |
| 858 | { |
| 859 | int var; |
| 860 | union XOPXR0 XR0, daaint; |
| 861 | |
| 862 | var = 10; |
| 863 | |
| 864 | XR0.reg = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg; |
| 865 | daaint.reg = 0; |
| 866 | XR0.bitreg.RMR = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR; |
| 867 | |
| 868 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 869 | if (j->pld_scrr.bits.daaflag) { |
| 870 | daa_int_read(j); |
| 871 | if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.RING) { |
| 872 | if(time_after(jiffies, j->pstn_sleeptil) && !(j->flags.pots_pstn && j->hookstate)) { |
| 873 | daaint.bitreg.RING = 1; |
| 874 | if(ixjdebug & 0x0008) { |
| 875 | printk(KERN_INFO "IXJ DAA Ring Interrupt /dev/phone%d at %ld\n", j->board, jiffies); |
| 876 | } |
| 877 | } else { |
| 878 | daa_set_mode(j, SOP_PU_RESET); |
| 879 | } |
| 880 | } |
| 881 | if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Caller_ID) { |
| 882 | daaint.bitreg.Caller_ID = 1; |
| 883 | j->pstn_cid_intr = 1; |
| 884 | j->pstn_cid_received = jiffies; |
| 885 | if(ixjdebug & 0x0008) { |
| 886 | printk(KERN_INFO "IXJ DAA Caller_ID Interrupt /dev/phone%d at %ld\n", j->board, jiffies); |
| 887 | } |
| 888 | } |
| 889 | if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Cadence) { |
| 890 | daaint.bitreg.Cadence = 1; |
| 891 | if(ixjdebug & 0x0008) { |
| 892 | printk(KERN_INFO "IXJ DAA Cadence Interrupt /dev/phone%d at %ld\n", j->board, jiffies); |
| 893 | } |
| 894 | } |
| 895 | if(j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK != XR0.bitreg.VDD_OK) { |
| 896 | daaint.bitreg.VDD_OK = 1; |
| 897 | daaint.bitreg.SI_0 = j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK; |
| 898 | } |
| 899 | } |
| 900 | daa_CR_read(j, 1); |
| 901 | 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)) { |
| 902 | daaint.bitreg.RMR = 1; |
| 903 | daaint.bitreg.SI_1 = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR; |
| 904 | if(ixjdebug & 0x0008) { |
| 905 | 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); |
| 906 | } |
| 907 | j->pstn_prev_rmr = j->pstn_last_rmr; |
| 908 | j->pstn_last_rmr = jiffies; |
| 909 | } |
| 910 | switch(j->daa_mode) { |
| 911 | case SOP_PU_SLEEP: |
| 912 | if (daaint.bitreg.RING) { |
| 913 | if (!j->flags.pstn_ringing) { |
| 914 | if (j->daa_mode != SOP_PU_RINGING) { |
| 915 | j->pstn_ring_int = jiffies; |
| 916 | daa_set_mode(j, SOP_PU_RINGING); |
| 917 | } |
| 918 | } |
| 919 | } |
| 920 | break; |
| 921 | case SOP_PU_RINGING: |
| 922 | if (daaint.bitreg.RMR) { |
| 923 | if (ixjdebug & 0x0008) { |
| 924 | printk(KERN_INFO "IXJ Ring Cadence a state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies); |
| 925 | } |
| 926 | if (daaint.bitreg.SI_1) { /* Rising edge of RMR */ |
| 927 | j->flags.pstn_rmr = 1; |
| 928 | j->pstn_ring_start = jiffies; |
| 929 | j->pstn_ring_stop = 0; |
| 930 | j->ex.bits.pstn_ring = 0; |
| 931 | if (j->cadence_f[4].state == 0) { |
| 932 | j->cadence_f[4].state = 1; |
| 933 | j->cadence_f[4].on1min = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 - var)) / 10000); |
| 934 | j->cadence_f[4].on1dot = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100)) / 10000); |
| 935 | j->cadence_f[4].on1max = jiffies + (long)((j->cadence_f[4].on1 * hertz * (100 + var)) / 10000); |
| 936 | } else if (j->cadence_f[4].state == 2) { |
| 937 | if((time_after(jiffies, j->cadence_f[4].off1min) && |
| 938 | time_before(jiffies, j->cadence_f[4].off1max))) { |
| 939 | if (j->cadence_f[4].on2) { |
| 940 | j->cadence_f[4].state = 3; |
| 941 | j->cadence_f[4].on2min = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 - var)) / 10000)); |
| 942 | j->cadence_f[4].on2dot = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100)) / 10000)); |
| 943 | j->cadence_f[4].on2max = jiffies + (long)((j->cadence_f[4].on2 * (hertz * (100 + var)) / 10000)); |
| 944 | } else { |
| 945 | j->cadence_f[4].state = 7; |
| 946 | } |
| 947 | } else { |
| 948 | if (ixjdebug & 0x0008) { |
| 949 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 950 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 951 | j->cadence_f[4].off1); |
| 952 | } |
| 953 | j->cadence_f[4].state = 0; |
| 954 | } |
| 955 | } else if (j->cadence_f[4].state == 4) { |
| 956 | if((time_after(jiffies, j->cadence_f[4].off2min) && |
| 957 | time_before(jiffies, j->cadence_f[4].off2max))) { |
| 958 | if (j->cadence_f[4].on3) { |
| 959 | j->cadence_f[4].state = 5; |
| 960 | j->cadence_f[4].on3min = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 - var)) / 10000)); |
| 961 | j->cadence_f[4].on3dot = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100)) / 10000)); |
| 962 | j->cadence_f[4].on3max = jiffies + (long)((j->cadence_f[4].on3 * (hertz * (100 + var)) / 10000)); |
| 963 | } else { |
| 964 | j->cadence_f[4].state = 7; |
| 965 | } |
| 966 | } else { |
| 967 | if (ixjdebug & 0x0008) { |
| 968 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 969 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 970 | j->cadence_f[4].off2); |
| 971 | } |
| 972 | j->cadence_f[4].state = 0; |
| 973 | } |
| 974 | } else if (j->cadence_f[4].state == 6) { |
| 975 | if((time_after(jiffies, j->cadence_f[4].off3min) && |
| 976 | time_before(jiffies, j->cadence_f[4].off3max))) { |
| 977 | j->cadence_f[4].state = 7; |
| 978 | } else { |
| 979 | if (ixjdebug & 0x0008) { |
| 980 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 981 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 982 | j->cadence_f[4].off3); |
| 983 | } |
| 984 | j->cadence_f[4].state = 0; |
| 985 | } |
| 986 | } else { |
| 987 | j->cadence_f[4].state = 0; |
| 988 | } |
| 989 | } else { /* Falling edge of RMR */ |
| 990 | j->pstn_ring_start = 0; |
| 991 | j->pstn_ring_stop = jiffies; |
| 992 | if (j->cadence_f[4].state == 1) { |
| 993 | if(!j->cadence_f[4].on1) { |
| 994 | j->cadence_f[4].state = 7; |
| 995 | } else if((time_after(jiffies, j->cadence_f[4].on1min) && |
| 996 | time_before(jiffies, j->cadence_f[4].on1max))) { |
| 997 | if (j->cadence_f[4].off1) { |
| 998 | j->cadence_f[4].state = 2; |
| 999 | j->cadence_f[4].off1min = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 - var)) / 10000)); |
| 1000 | j->cadence_f[4].off1dot = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100)) / 10000)); |
| 1001 | j->cadence_f[4].off1max = jiffies + (long)((j->cadence_f[4].off1 * (hertz * (100 + var)) / 10000)); |
| 1002 | } else { |
| 1003 | j->cadence_f[4].state = 7; |
| 1004 | } |
| 1005 | } else { |
| 1006 | if (ixjdebug & 0x0008) { |
| 1007 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 1008 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 1009 | j->cadence_f[4].on1); |
| 1010 | } |
| 1011 | j->cadence_f[4].state = 0; |
| 1012 | } |
| 1013 | } else if (j->cadence_f[4].state == 3) { |
| 1014 | if((time_after(jiffies, j->cadence_f[4].on2min) && |
| 1015 | time_before(jiffies, j->cadence_f[4].on2max))) { |
| 1016 | if (j->cadence_f[4].off2) { |
| 1017 | j->cadence_f[4].state = 4; |
| 1018 | j->cadence_f[4].off2min = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 - var)) / 10000)); |
| 1019 | j->cadence_f[4].off2dot = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100)) / 10000)); |
| 1020 | j->cadence_f[4].off2max = jiffies + (long)((j->cadence_f[4].off2 * (hertz * (100 + var)) / 10000)); |
| 1021 | } else { |
| 1022 | j->cadence_f[4].state = 7; |
| 1023 | } |
| 1024 | } else { |
| 1025 | if (ixjdebug & 0x0008) { |
| 1026 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 1027 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 1028 | j->cadence_f[4].on2); |
| 1029 | } |
| 1030 | j->cadence_f[4].state = 0; |
| 1031 | } |
| 1032 | } else if (j->cadence_f[4].state == 5) { |
| 1033 | if((time_after(jiffies, j->cadence_f[4].on3min) && |
| 1034 | time_before(jiffies, j->cadence_f[4].on3max))) { |
| 1035 | if (j->cadence_f[4].off3) { |
| 1036 | j->cadence_f[4].state = 6; |
| 1037 | j->cadence_f[4].off3min = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 - var)) / 10000)); |
| 1038 | j->cadence_f[4].off3dot = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100)) / 10000)); |
| 1039 | j->cadence_f[4].off3max = jiffies + (long)((j->cadence_f[4].off3 * (hertz * (100 + var)) / 10000)); |
| 1040 | } else { |
| 1041 | j->cadence_f[4].state = 7; |
| 1042 | } |
| 1043 | } else { |
| 1044 | j->cadence_f[4].state = 0; |
| 1045 | } |
| 1046 | } else { |
| 1047 | if (ixjdebug & 0x0008) { |
| 1048 | printk(KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n", |
| 1049 | j->cadence_f[4].state, j->board, jiffies - j->pstn_prev_rmr, |
| 1050 | j->cadence_f[4].on3); |
| 1051 | } |
| 1052 | j->cadence_f[4].state = 0; |
| 1053 | } |
| 1054 | } |
| 1055 | if (ixjdebug & 0x0010) { |
| 1056 | printk(KERN_INFO "IXJ Ring Cadence b state = %d /dev/phone%d at %ld\n", j->cadence_f[4].state, j->board, jiffies); |
| 1057 | } |
| 1058 | if (ixjdebug & 0x0010) { |
| 1059 | switch(j->cadence_f[4].state) { |
| 1060 | case 1: |
| 1061 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1062 | j->cadence_f[4].on1, j->cadence_f[4].on1min, j->cadence_f[4].on1dot, j->cadence_f[4].on1max); |
| 1063 | break; |
| 1064 | case 2: |
| 1065 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1066 | j->cadence_f[4].off1, j->cadence_f[4].off1min, j->cadence_f[4].off1dot, j->cadence_f[4].off1max); |
| 1067 | break; |
| 1068 | case 3: |
| 1069 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1070 | j->cadence_f[4].on2, j->cadence_f[4].on2min, j->cadence_f[4].on2dot, j->cadence_f[4].on2max); |
| 1071 | break; |
| 1072 | case 4: |
| 1073 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1074 | j->cadence_f[4].off2, j->cadence_f[4].off2min, j->cadence_f[4].off2dot, j->cadence_f[4].off2max); |
| 1075 | break; |
| 1076 | case 5: |
| 1077 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1078 | j->cadence_f[4].on3, j->cadence_f[4].on3min, j->cadence_f[4].on3dot, j->cadence_f[4].on3max); |
| 1079 | break; |
| 1080 | case 6: |
| 1081 | printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board, |
| 1082 | j->cadence_f[4].off3, j->cadence_f[4].off3min, j->cadence_f[4].off3dot, j->cadence_f[4].off3max); |
| 1083 | break; |
| 1084 | } |
| 1085 | } |
| 1086 | } |
| 1087 | if (j->cadence_f[4].state == 7) { |
| 1088 | j->cadence_f[4].state = 0; |
| 1089 | j->pstn_ring_stop = jiffies; |
| 1090 | j->ex.bits.pstn_ring = 1; |
| 1091 | ixj_kill_fasync(j, SIG_PSTN_RING, POLL_IN); |
| 1092 | if(ixjdebug & 0x0008) { |
| 1093 | printk(KERN_INFO "IXJ Ring int set /dev/phone%d at %ld\n", j->board, jiffies); |
| 1094 | } |
| 1095 | } |
| 1096 | if((j->pstn_ring_int != 0 && time_after(jiffies, j->pstn_ring_int + (hertz * 5)) && !j->flags.pstn_rmr) || |
| 1097 | (j->pstn_ring_stop != 0 && time_after(jiffies, j->pstn_ring_stop + (hertz * 5)))) { |
| 1098 | if(ixjdebug & 0x0008) { |
| 1099 | printk("IXJ DAA no ring in 5 seconds /dev/phone%d at %ld\n", j->board, jiffies); |
| 1100 | printk("IXJ DAA pstn ring int /dev/phone%d at %ld\n", j->board, j->pstn_ring_int); |
| 1101 | printk("IXJ DAA pstn ring stop /dev/phone%d at %ld\n", j->board, j->pstn_ring_stop); |
| 1102 | } |
| 1103 | j->pstn_ring_stop = j->pstn_ring_int = 0; |
| 1104 | daa_set_mode(j, SOP_PU_SLEEP); |
| 1105 | } |
| 1106 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 1107 | if (j->pstn_cid_intr && time_after(jiffies, j->pstn_cid_received + hertz)) { |
| 1108 | ixj_daa_cid_read(j); |
| 1109 | j->ex.bits.caller_id = 1; |
| 1110 | ixj_kill_fasync(j, SIG_CALLER_ID, POLL_IN); |
| 1111 | j->pstn_cid_intr = 0; |
| 1112 | } |
| 1113 | if (daaint.bitreg.Cadence) { |
| 1114 | if(ixjdebug & 0x0008) { |
| 1115 | printk("IXJ DAA Cadence interrupt going to sleep /dev/phone%d\n", j->board); |
| 1116 | } |
| 1117 | daa_set_mode(j, SOP_PU_SLEEP); |
| 1118 | j->ex.bits.pstn_ring = 0; |
| 1119 | } |
| 1120 | break; |
| 1121 | case SOP_PU_CONVERSATION: |
| 1122 | if (daaint.bitreg.VDD_OK) { |
| 1123 | if(!daaint.bitreg.SI_0) { |
| 1124 | if (!j->pstn_winkstart) { |
| 1125 | if(ixjdebug & 0x0008) { |
| 1126 | printk("IXJ DAA possible wink /dev/phone%d %ld\n", j->board, jiffies); |
| 1127 | } |
| 1128 | j->pstn_winkstart = jiffies; |
| 1129 | } |
| 1130 | } else { |
| 1131 | if (j->pstn_winkstart) { |
| 1132 | if(ixjdebug & 0x0008) { |
| 1133 | printk("IXJ DAA possible wink end /dev/phone%d %ld\n", j->board, jiffies); |
| 1134 | } |
| 1135 | j->pstn_winkstart = 0; |
| 1136 | } |
| 1137 | } |
| 1138 | } |
| 1139 | if (j->pstn_winkstart && time_after(jiffies, j->pstn_winkstart + ((hertz * j->winktime) / 1000))) { |
| 1140 | if(ixjdebug & 0x0008) { |
| 1141 | printk("IXJ DAA wink detected going to sleep /dev/phone%d %ld\n", j->board, jiffies); |
| 1142 | } |
| 1143 | daa_set_mode(j, SOP_PU_SLEEP); |
| 1144 | j->pstn_winkstart = 0; |
| 1145 | j->ex.bits.pstn_wink = 1; |
| 1146 | ixj_kill_fasync(j, SIG_PSTN_WINK, POLL_IN); |
| 1147 | } |
| 1148 | break; |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | static void ixj_timeout(unsigned long ptr) |
| 1153 | { |
| 1154 | int board; |
| 1155 | unsigned long jifon; |
| 1156 | IXJ *j = (IXJ *)ptr; |
| 1157 | board = j->board; |
| 1158 | |
| 1159 | if (j->DSPbase && atomic_read(&j->DSPWrite) == 0 && test_and_set_bit(board, (void *)&j->busyflags) == 0) { |
| 1160 | ixj_perfmon(j->timerchecks); |
| 1161 | j->hookstate = ixj_hookstate(j); |
| 1162 | if (j->tone_state) { |
| 1163 | if (!(j->hookstate)) { |
| 1164 | ixj_cpt_stop(j); |
| 1165 | if (j->m_hook) { |
| 1166 | j->m_hook = 0; |
| 1167 | j->ex.bits.hookstate = 1; |
| 1168 | ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN); |
| 1169 | } |
| 1170 | clear_bit(board, &j->busyflags); |
| 1171 | ixj_add_timer(j); |
| 1172 | return; |
| 1173 | } |
| 1174 | if (j->tone_state == 1) |
| 1175 | jifon = ((hertz * j->tone_on_time) * 25 / 100000); |
| 1176 | else |
| 1177 | jifon = ((hertz * j->tone_on_time) * 25 / 100000) + ((hertz * j->tone_off_time) * 25 / 100000); |
| 1178 | if (time_before(jiffies, j->tone_start_jif + jifon)) { |
| 1179 | if (j->tone_state == 1) { |
| 1180 | ixj_play_tone(j, j->tone_index); |
| 1181 | if (j->dsp.low == 0x20) { |
| 1182 | clear_bit(board, &j->busyflags); |
| 1183 | ixj_add_timer(j); |
| 1184 | return; |
| 1185 | } |
| 1186 | } else { |
| 1187 | ixj_play_tone(j, 0); |
| 1188 | if (j->dsp.low == 0x20) { |
| 1189 | clear_bit(board, &j->busyflags); |
| 1190 | ixj_add_timer(j); |
| 1191 | return; |
| 1192 | } |
| 1193 | } |
| 1194 | } else { |
| 1195 | ixj_tone_timeout(j); |
| 1196 | if (j->flags.dialtone) { |
| 1197 | ixj_dialtone(j); |
| 1198 | } |
| 1199 | if (j->flags.busytone) { |
| 1200 | ixj_busytone(j); |
| 1201 | if (j->dsp.low == 0x20) { |
| 1202 | clear_bit(board, &j->busyflags); |
| 1203 | ixj_add_timer(j); |
| 1204 | return; |
| 1205 | } |
| 1206 | } |
| 1207 | if (j->flags.ringback) { |
| 1208 | ixj_ringback(j); |
| 1209 | if (j->dsp.low == 0x20) { |
| 1210 | clear_bit(board, &j->busyflags); |
| 1211 | ixj_add_timer(j); |
| 1212 | return; |
| 1213 | } |
| 1214 | } |
| 1215 | if (!j->tone_state) { |
| 1216 | ixj_cpt_stop(j); |
| 1217 | } |
| 1218 | } |
| 1219 | } |
| 1220 | if (!(j->tone_state && j->dsp.low == 0x20)) { |
| 1221 | if (IsRxReady(j)) { |
| 1222 | ixj_read_frame(j); |
| 1223 | } |
| 1224 | if (IsTxReady(j)) { |
| 1225 | ixj_write_frame(j); |
| 1226 | } |
| 1227 | } |
| 1228 | if (j->flags.cringing) { |
| 1229 | if (j->hookstate & 1) { |
| 1230 | j->flags.cringing = 0; |
| 1231 | ixj_ring_off(j); |
| 1232 | } else if(j->cadence_f[5].enable && ((!j->cadence_f[5].en_filter) || (j->cadence_f[5].en_filter && j->flags.firstring))) { |
| 1233 | switch(j->cadence_f[5].state) { |
| 1234 | case 0: |
| 1235 | j->cadence_f[5].on1dot = jiffies + (long)((j->cadence_f[5].on1 * (hertz * 100) / 10000)); |
| 1236 | if (time_before(jiffies, j->cadence_f[5].on1dot)) { |
| 1237 | if(ixjdebug & 0x0004) { |
| 1238 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1239 | } |
| 1240 | ixj_ring_on(j); |
| 1241 | } |
| 1242 | j->cadence_f[5].state = 1; |
| 1243 | break; |
| 1244 | case 1: |
| 1245 | if (time_after(jiffies, j->cadence_f[5].on1dot)) { |
| 1246 | j->cadence_f[5].off1dot = jiffies + (long)((j->cadence_f[5].off1 * (hertz * 100) / 10000)); |
| 1247 | if(ixjdebug & 0x0004) { |
| 1248 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1249 | } |
| 1250 | ixj_ring_off(j); |
| 1251 | j->cadence_f[5].state = 2; |
| 1252 | } |
| 1253 | break; |
| 1254 | case 2: |
| 1255 | if (time_after(jiffies, j->cadence_f[5].off1dot)) { |
| 1256 | if(ixjdebug & 0x0004) { |
| 1257 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1258 | } |
| 1259 | ixj_ring_on(j); |
| 1260 | if (j->cadence_f[5].on2) { |
| 1261 | j->cadence_f[5].on2dot = jiffies + (long)((j->cadence_f[5].on2 * (hertz * 100) / 10000)); |
| 1262 | j->cadence_f[5].state = 3; |
| 1263 | } else { |
| 1264 | j->cadence_f[5].state = 7; |
| 1265 | } |
| 1266 | } |
| 1267 | break; |
| 1268 | case 3: |
| 1269 | if (time_after(jiffies, j->cadence_f[5].on2dot)) { |
| 1270 | if(ixjdebug & 0x0004) { |
| 1271 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1272 | } |
| 1273 | ixj_ring_off(j); |
| 1274 | if (j->cadence_f[5].off2) { |
| 1275 | j->cadence_f[5].off2dot = jiffies + (long)((j->cadence_f[5].off2 * (hertz * 100) / 10000)); |
| 1276 | j->cadence_f[5].state = 4; |
| 1277 | } else { |
| 1278 | j->cadence_f[5].state = 7; |
| 1279 | } |
| 1280 | } |
| 1281 | break; |
| 1282 | case 4: |
| 1283 | if (time_after(jiffies, j->cadence_f[5].off2dot)) { |
| 1284 | if(ixjdebug & 0x0004) { |
| 1285 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1286 | } |
| 1287 | ixj_ring_on(j); |
| 1288 | if (j->cadence_f[5].on3) { |
| 1289 | j->cadence_f[5].on3dot = jiffies + (long)((j->cadence_f[5].on3 * (hertz * 100) / 10000)); |
| 1290 | j->cadence_f[5].state = 5; |
| 1291 | } else { |
| 1292 | j->cadence_f[5].state = 7; |
| 1293 | } |
| 1294 | } |
| 1295 | break; |
| 1296 | case 5: |
| 1297 | if (time_after(jiffies, j->cadence_f[5].on3dot)) { |
| 1298 | if(ixjdebug & 0x0004) { |
| 1299 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1300 | } |
| 1301 | ixj_ring_off(j); |
| 1302 | if (j->cadence_f[5].off3) { |
| 1303 | j->cadence_f[5].off3dot = jiffies + (long)((j->cadence_f[5].off3 * (hertz * 100) / 10000)); |
| 1304 | j->cadence_f[5].state = 6; |
| 1305 | } else { |
| 1306 | j->cadence_f[5].state = 7; |
| 1307 | } |
| 1308 | } |
| 1309 | break; |
| 1310 | case 6: |
| 1311 | if (time_after(jiffies, j->cadence_f[5].off3dot)) { |
| 1312 | if(ixjdebug & 0x0004) { |
| 1313 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1314 | } |
| 1315 | j->cadence_f[5].state = 7; |
| 1316 | } |
| 1317 | break; |
| 1318 | case 7: |
| 1319 | if(ixjdebug & 0x0004) { |
| 1320 | printk("Ringing cadence state = %d - %ld\n", j->cadence_f[5].state, jiffies); |
| 1321 | } |
| 1322 | j->flags.cidring = 1; |
| 1323 | j->cadence_f[5].state = 0; |
| 1324 | break; |
| 1325 | } |
| 1326 | if (j->flags.cidring && !j->flags.cidsent) { |
| 1327 | j->flags.cidsent = 1; |
| 1328 | if(j->fskdcnt) { |
| 1329 | SLIC_SetState(PLD_SLIC_STATE_OHT, j); |
| 1330 | ixj_pre_cid(j); |
| 1331 | } |
| 1332 | j->flags.cidring = 0; |
| 1333 | } |
| 1334 | clear_bit(board, &j->busyflags); |
| 1335 | ixj_add_timer(j); |
| 1336 | return; |
| 1337 | } else { |
| 1338 | if (time_after(jiffies, j->ring_cadence_jif + (hertz / 2))) { |
| 1339 | if (j->flags.cidring && !j->flags.cidsent) { |
| 1340 | j->flags.cidsent = 1; |
| 1341 | if(j->fskdcnt) { |
| 1342 | SLIC_SetState(PLD_SLIC_STATE_OHT, j); |
| 1343 | ixj_pre_cid(j); |
| 1344 | } |
| 1345 | j->flags.cidring = 0; |
| 1346 | } |
| 1347 | j->ring_cadence_t--; |
| 1348 | if (j->ring_cadence_t == -1) |
| 1349 | j->ring_cadence_t = 15; |
| 1350 | j->ring_cadence_jif = jiffies; |
| 1351 | |
| 1352 | if (j->ring_cadence & 1 << j->ring_cadence_t) { |
| 1353 | if(j->flags.cidsent && j->cadence_f[5].en_filter) |
| 1354 | j->flags.firstring = 1; |
| 1355 | else |
| 1356 | ixj_ring_on(j); |
| 1357 | } else { |
| 1358 | ixj_ring_off(j); |
| 1359 | if(!j->flags.cidsent) |
| 1360 | j->flags.cidring = 1; |
| 1361 | } |
| 1362 | } |
| 1363 | clear_bit(board, &j->busyflags); |
| 1364 | ixj_add_timer(j); |
| 1365 | return; |
| 1366 | } |
| 1367 | } |
| 1368 | if (!j->flags.ringing) { |
| 1369 | if (j->hookstate) { /* & 1) { */ |
| 1370 | if (j->dsp.low != 0x20 && |
| 1371 | SLIC_GetState(j) != PLD_SLIC_STATE_ACTIVE) { |
| 1372 | SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); |
| 1373 | } |
| 1374 | LineMonitor(j); |
| 1375 | read_filters(j); |
| 1376 | ixj_WriteDSPCommand(0x511B, j); |
| 1377 | j->proc_load = j->ssr.high << 8 | j->ssr.low; |
| 1378 | if (!j->m_hook && (j->hookstate & 1)) { |
| 1379 | j->m_hook = j->ex.bits.hookstate = 1; |
| 1380 | ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN); |
| 1381 | } |
| 1382 | } else { |
| 1383 | if (j->ex.bits.dtmf_ready) { |
| 1384 | j->dtmf_wp = j->dtmf_rp = j->ex.bits.dtmf_ready = 0; |
| 1385 | } |
| 1386 | if (j->m_hook) { |
| 1387 | j->m_hook = 0; |
| 1388 | j->ex.bits.hookstate = 1; |
| 1389 | ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN); |
| 1390 | } |
| 1391 | } |
| 1392 | } |
| 1393 | if (j->cardtype == QTI_LINEJACK && !j->flags.pstncheck && j->flags.pstn_present) { |
| 1394 | ixj_pstn_state(j); |
| 1395 | } |
| 1396 | if (j->ex.bytes) { |
| 1397 | wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */ |
| 1398 | } |
| 1399 | clear_bit(board, &j->busyflags); |
| 1400 | } |
| 1401 | ixj_add_timer(j); |
| 1402 | } |
| 1403 | |
| 1404 | static int ixj_status_wait(IXJ *j) |
| 1405 | { |
| 1406 | unsigned long jif; |
| 1407 | |
| 1408 | jif = jiffies + ((60 * hertz) / 100); |
| 1409 | while (!IsStatusReady(j)) { |
| 1410 | ixj_perfmon(j->statuswait); |
| 1411 | if (time_after(jiffies, jif)) { |
| 1412 | ixj_perfmon(j->statuswaitfail); |
| 1413 | return -1; |
| 1414 | } |
| 1415 | } |
| 1416 | return 0; |
| 1417 | } |
| 1418 | |
| 1419 | static int ixj_PCcontrol_wait(IXJ *j) |
| 1420 | { |
| 1421 | unsigned long jif; |
| 1422 | |
| 1423 | jif = jiffies + ((60 * hertz) / 100); |
| 1424 | while (!IsPCControlReady(j)) { |
| 1425 | ixj_perfmon(j->pcontrolwait); |
| 1426 | if (time_after(jiffies, jif)) { |
| 1427 | ixj_perfmon(j->pcontrolwaitfail); |
| 1428 | return -1; |
| 1429 | } |
| 1430 | } |
| 1431 | return 0; |
| 1432 | } |
| 1433 | |
| 1434 | static int ixj_WriteDSPCommand(unsigned short cmd, IXJ *j) |
| 1435 | { |
| 1436 | BYTES bytes; |
| 1437 | unsigned long jif; |
| 1438 | |
| 1439 | atomic_inc(&j->DSPWrite); |
| 1440 | if(atomic_read(&j->DSPWrite) > 1) { |
| 1441 | printk("IXJ %d DSP write overlap attempting command 0x%4.4x\n", j->board, cmd); |
| 1442 | return -1; |
| 1443 | } |
| 1444 | bytes.high = (cmd & 0xFF00) >> 8; |
| 1445 | bytes.low = cmd & 0x00FF; |
| 1446 | jif = jiffies + ((60 * hertz) / 100); |
| 1447 | while (!IsControlReady(j)) { |
| 1448 | ixj_perfmon(j->iscontrolready); |
| 1449 | if (time_after(jiffies, jif)) { |
| 1450 | ixj_perfmon(j->iscontrolreadyfail); |
| 1451 | atomic_dec(&j->DSPWrite); |
| 1452 | if(atomic_read(&j->DSPWrite) > 0) { |
| 1453 | printk("IXJ %d DSP overlaped command 0x%4.4x during control ready failure.\n", j->board, cmd); |
| 1454 | while(atomic_read(&j->DSPWrite) > 0) { |
| 1455 | atomic_dec(&j->DSPWrite); |
| 1456 | } |
| 1457 | } |
| 1458 | return -1; |
| 1459 | } |
| 1460 | } |
| 1461 | outb(bytes.low, j->DSPbase + 6); |
| 1462 | outb(bytes.high, j->DSPbase + 7); |
| 1463 | |
| 1464 | if (ixj_status_wait(j)) { |
| 1465 | j->ssr.low = 0xFF; |
| 1466 | j->ssr.high = 0xFF; |
| 1467 | atomic_dec(&j->DSPWrite); |
| 1468 | if(atomic_read(&j->DSPWrite) > 0) { |
| 1469 | printk("IXJ %d DSP overlaped command 0x%4.4x during status wait failure.\n", j->board, cmd); |
| 1470 | while(atomic_read(&j->DSPWrite) > 0) { |
| 1471 | atomic_dec(&j->DSPWrite); |
| 1472 | } |
| 1473 | } |
| 1474 | return -1; |
| 1475 | } |
| 1476 | /* Read Software Status Register */ |
| 1477 | j->ssr.low = inb_p(j->DSPbase + 2); |
| 1478 | j->ssr.high = inb_p(j->DSPbase + 3); |
| 1479 | atomic_dec(&j->DSPWrite); |
| 1480 | if(atomic_read(&j->DSPWrite) > 0) { |
| 1481 | printk("IXJ %d DSP overlaped command 0x%4.4x\n", j->board, cmd); |
| 1482 | while(atomic_read(&j->DSPWrite) > 0) { |
| 1483 | atomic_dec(&j->DSPWrite); |
| 1484 | } |
| 1485 | } |
| 1486 | return 0; |
| 1487 | } |
| 1488 | |
| 1489 | /*************************************************************************** |
| 1490 | * |
| 1491 | * General Purpose IO Register read routine |
| 1492 | * |
| 1493 | ***************************************************************************/ |
| 1494 | static inline int ixj_gpio_read(IXJ *j) |
| 1495 | { |
| 1496 | if (ixj_WriteDSPCommand(0x5143, j)) |
| 1497 | return -1; |
| 1498 | |
| 1499 | j->gpio.bytes.low = j->ssr.low; |
| 1500 | j->gpio.bytes.high = j->ssr.high; |
| 1501 | |
| 1502 | return 0; |
| 1503 | } |
| 1504 | |
| 1505 | static inline void LED_SetState(int state, IXJ *j) |
| 1506 | { |
| 1507 | if (j->cardtype == QTI_LINEJACK) { |
| 1508 | j->pld_scrw.bits.led1 = state & 0x1 ? 1 : 0; |
| 1509 | j->pld_scrw.bits.led2 = state & 0x2 ? 1 : 0; |
| 1510 | j->pld_scrw.bits.led3 = state & 0x4 ? 1 : 0; |
| 1511 | j->pld_scrw.bits.led4 = state & 0x8 ? 1 : 0; |
| 1512 | |
| 1513 | outb(j->pld_scrw.byte, j->XILINXbase); |
| 1514 | } |
| 1515 | } |
| 1516 | |
| 1517 | /********************************************************************* |
| 1518 | * GPIO Pins are configured as follows on the Quicknet Internet |
| 1519 | * PhoneJACK Telephony Cards |
| 1520 | * |
| 1521 | * POTS Select GPIO_6=0 GPIO_7=0 |
| 1522 | * Mic/Speaker Select GPIO_6=0 GPIO_7=1 |
| 1523 | * Handset Select GPIO_6=1 GPIO_7=0 |
| 1524 | * |
| 1525 | * SLIC Active GPIO_1=0 GPIO_2=1 GPIO_5=0 |
| 1526 | * SLIC Ringing GPIO_1=1 GPIO_2=1 GPIO_5=0 |
| 1527 | * SLIC Open Circuit GPIO_1=0 GPIO_2=0 GPIO_5=0 |
| 1528 | * |
| 1529 | * Hook Switch changes reported on GPIO_3 |
| 1530 | *********************************************************************/ |
| 1531 | static int ixj_set_port(IXJ *j, int arg) |
| 1532 | { |
| 1533 | if (j->cardtype == QTI_PHONEJACK_LITE) { |
| 1534 | if (arg != PORT_POTS) |
| 1535 | return 10; |
| 1536 | else |
| 1537 | return 0; |
| 1538 | } |
| 1539 | switch (arg) { |
| 1540 | case PORT_POTS: |
| 1541 | j->port = PORT_POTS; |
| 1542 | switch (j->cardtype) { |
| 1543 | case QTI_PHONECARD: |
| 1544 | if (j->flags.pcmciasct == 1) |
| 1545 | SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); |
| 1546 | else |
| 1547 | return 11; |
| 1548 | break; |
| 1549 | case QTI_PHONEJACK_PCI: |
| 1550 | j->pld_slicw.pcib.mic = 0; |
| 1551 | j->pld_slicw.pcib.spk = 0; |
| 1552 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1553 | break; |
| 1554 | case QTI_LINEJACK: |
| 1555 | ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */ |
| 1556 | if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to |
| 1557 | Software Control Register */ |
| 1558 | return 2; |
| 1559 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 1560 | |
| 1561 | outb(j->pld_scrw.byte, j->XILINXbase); |
| 1562 | j->pld_clock.byte = 0; |
| 1563 | outb(j->pld_clock.byte, j->XILINXbase + 0x04); |
| 1564 | j->pld_slicw.bits.rly1 = 1; |
| 1565 | j->pld_slicw.bits.spken = 0; |
| 1566 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1567 | ixj_mixer(0x1200, j); /* Turn Off MIC switch on mixer left */ |
| 1568 | ixj_mixer(0x1401, j); /* Turn On Mono1 switch on mixer left */ |
| 1569 | ixj_mixer(0x1300, j); /* Turn Off MIC switch on mixer right */ |
| 1570 | ixj_mixer(0x1501, j); /* Turn On Mono1 switch on mixer right */ |
| 1571 | ixj_mixer(0x0E80, j); /*Mic mute */ |
| 1572 | ixj_mixer(0x0F00, j); /* Set mono out (SLIC) to 0dB */ |
| 1573 | ixj_mixer(0x0080, j); /* Mute Master Left volume */ |
| 1574 | ixj_mixer(0x0180, j); /* Mute Master Right volume */ |
| 1575 | SLIC_SetState(PLD_SLIC_STATE_STANDBY, j); |
| 1576 | /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */ |
| 1577 | break; |
| 1578 | case QTI_PHONEJACK: |
| 1579 | j->gpio.bytes.high = 0x0B; |
| 1580 | j->gpio.bits.gpio6 = 0; |
| 1581 | j->gpio.bits.gpio7 = 0; |
| 1582 | ixj_WriteDSPCommand(j->gpio.word, j); |
| 1583 | break; |
| 1584 | } |
| 1585 | break; |
| 1586 | case PORT_PSTN: |
| 1587 | if (j->cardtype == QTI_LINEJACK) { |
| 1588 | ixj_WriteDSPCommand(0xC534, j); /* Write CODEC config to Software Control Register */ |
| 1589 | |
| 1590 | j->pld_slicw.bits.rly3 = 0; |
| 1591 | j->pld_slicw.bits.rly1 = 1; |
| 1592 | j->pld_slicw.bits.spken = 0; |
| 1593 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1594 | j->port = PORT_PSTN; |
| 1595 | } else { |
| 1596 | return 4; |
| 1597 | } |
| 1598 | break; |
| 1599 | case PORT_SPEAKER: |
| 1600 | j->port = PORT_SPEAKER; |
| 1601 | switch (j->cardtype) { |
| 1602 | case QTI_PHONECARD: |
| 1603 | if (j->flags.pcmciasct) { |
| 1604 | SLIC_SetState(PLD_SLIC_STATE_OC, j); |
| 1605 | } |
| 1606 | break; |
| 1607 | case QTI_PHONEJACK_PCI: |
| 1608 | j->pld_slicw.pcib.mic = 1; |
| 1609 | j->pld_slicw.pcib.spk = 1; |
| 1610 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1611 | break; |
| 1612 | case QTI_LINEJACK: |
| 1613 | ixj_set_pots(j, 0); /* Disconnect POTS/PSTN relay */ |
| 1614 | if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to |
| 1615 | Software Control Register */ |
| 1616 | return 2; |
| 1617 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 1618 | |
| 1619 | outb(j->pld_scrw.byte, j->XILINXbase); |
| 1620 | j->pld_clock.byte = 0; |
| 1621 | outb(j->pld_clock.byte, j->XILINXbase + 0x04); |
| 1622 | j->pld_slicw.bits.rly1 = 1; |
| 1623 | j->pld_slicw.bits.spken = 1; |
| 1624 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1625 | ixj_mixer(0x1201, j); /* Turn On MIC switch on mixer left */ |
| 1626 | ixj_mixer(0x1400, j); /* Turn Off Mono1 switch on mixer left */ |
| 1627 | ixj_mixer(0x1301, j); /* Turn On MIC switch on mixer right */ |
| 1628 | ixj_mixer(0x1500, j); /* Turn Off Mono1 switch on mixer right */ |
| 1629 | ixj_mixer(0x0E06, j); /*Mic un-mute 0dB */ |
| 1630 | ixj_mixer(0x0F80, j); /* Mute mono out (SLIC) */ |
| 1631 | ixj_mixer(0x0000, j); /* Set Master Left volume to 0dB */ |
| 1632 | ixj_mixer(0x0100, j); /* Set Master Right volume to 0dB */ |
| 1633 | break; |
| 1634 | case QTI_PHONEJACK: |
| 1635 | j->gpio.bytes.high = 0x0B; |
| 1636 | j->gpio.bits.gpio6 = 0; |
| 1637 | j->gpio.bits.gpio7 = 1; |
| 1638 | ixj_WriteDSPCommand(j->gpio.word, j); |
| 1639 | break; |
| 1640 | } |
| 1641 | break; |
| 1642 | case PORT_HANDSET: |
| 1643 | if (j->cardtype != QTI_PHONEJACK) { |
| 1644 | return 5; |
| 1645 | } else { |
| 1646 | j->gpio.bytes.high = 0x0B; |
| 1647 | j->gpio.bits.gpio6 = 1; |
| 1648 | j->gpio.bits.gpio7 = 0; |
| 1649 | ixj_WriteDSPCommand(j->gpio.word, j); |
| 1650 | j->port = PORT_HANDSET; |
| 1651 | } |
| 1652 | break; |
| 1653 | default: |
| 1654 | return 6; |
| 1655 | break; |
| 1656 | } |
| 1657 | return 0; |
| 1658 | } |
| 1659 | |
| 1660 | static int ixj_set_pots(IXJ *j, int arg) |
| 1661 | { |
| 1662 | if (j->cardtype == QTI_LINEJACK) { |
| 1663 | if (arg) { |
| 1664 | if (j->port == PORT_PSTN) { |
| 1665 | j->pld_slicw.bits.rly1 = 0; |
| 1666 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1667 | j->flags.pots_pstn = 1; |
| 1668 | return 1; |
| 1669 | } else { |
| 1670 | j->flags.pots_pstn = 0; |
| 1671 | return 0; |
| 1672 | } |
| 1673 | } else { |
| 1674 | j->pld_slicw.bits.rly1 = 1; |
| 1675 | outb(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 1676 | j->flags.pots_pstn = 0; |
| 1677 | return 1; |
| 1678 | } |
| 1679 | } else { |
| 1680 | return 0; |
| 1681 | } |
| 1682 | } |
| 1683 | |
| 1684 | static void ixj_ring_on(IXJ *j) |
| 1685 | { |
| 1686 | if (j->dsp.low == 0x20) /* Internet PhoneJACK */ |
| 1687 | { |
| 1688 | if (ixjdebug & 0x0004) |
| 1689 | printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board); |
| 1690 | |
| 1691 | j->gpio.bytes.high = 0x0B; |
| 1692 | j->gpio.bytes.low = 0x00; |
| 1693 | j->gpio.bits.gpio1 = 1; |
| 1694 | j->gpio.bits.gpio2 = 1; |
| 1695 | j->gpio.bits.gpio5 = 0; |
| 1696 | ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring signal */ |
| 1697 | } else /* Internet LineJACK, Internet PhoneJACK Lite or Internet PhoneJACK PCI */ |
| 1698 | { |
| 1699 | if (ixjdebug & 0x0004) |
| 1700 | printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", j->board); |
| 1701 | |
| 1702 | SLIC_SetState(PLD_SLIC_STATE_RINGING, j); |
| 1703 | } |
| 1704 | } |
| 1705 | |
| 1706 | static int ixj_siadc(IXJ *j, int val) |
| 1707 | { |
| 1708 | if(j->cardtype == QTI_PHONECARD){ |
| 1709 | if(j->flags.pcmciascp){ |
| 1710 | if(val == -1) |
| 1711 | return j->siadc.bits.rxg; |
| 1712 | |
| 1713 | if(val < 0 || val > 0x1F) |
| 1714 | return -1; |
| 1715 | |
| 1716 | j->siadc.bits.hom = 0; /* Handset Out Mute */ |
| 1717 | j->siadc.bits.lom = 0; /* Line Out Mute */ |
| 1718 | j->siadc.bits.rxg = val; /*(0xC000 - 0x41C8) / 0x4EF; RX PGA Gain */ |
| 1719 | j->psccr.bits.addr = 6; /* R/W Smart Cable Register Address */ |
| 1720 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1721 | j->psccr.bits.dev = 0; |
| 1722 | outb(j->siadc.byte, j->XILINXbase + 0x00); |
| 1723 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1724 | ixj_PCcontrol_wait(j); |
| 1725 | return j->siadc.bits.rxg; |
| 1726 | } |
| 1727 | } |
| 1728 | return -1; |
| 1729 | } |
| 1730 | |
| 1731 | static int ixj_sidac(IXJ *j, int val) |
| 1732 | { |
| 1733 | if(j->cardtype == QTI_PHONECARD){ |
| 1734 | if(j->flags.pcmciascp){ |
| 1735 | if(val == -1) |
| 1736 | return j->sidac.bits.txg; |
| 1737 | |
| 1738 | if(val < 0 || val > 0x1F) |
| 1739 | return -1; |
| 1740 | |
| 1741 | j->sidac.bits.srm = 1; /* Speaker Right Mute */ |
| 1742 | j->sidac.bits.slm = 1; /* Speaker Left Mute */ |
| 1743 | j->sidac.bits.txg = val; /* (0xC000 - 0x45E4) / 0x5D3; TX PGA Gain */ |
| 1744 | j->psccr.bits.addr = 7; /* R/W Smart Cable Register Address */ |
| 1745 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1746 | j->psccr.bits.dev = 0; |
| 1747 | outb(j->sidac.byte, j->XILINXbase + 0x00); |
| 1748 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1749 | ixj_PCcontrol_wait(j); |
| 1750 | return j->sidac.bits.txg; |
| 1751 | } |
| 1752 | } |
| 1753 | return -1; |
| 1754 | } |
| 1755 | |
| 1756 | static int ixj_pcmcia_cable_check(IXJ *j) |
| 1757 | { |
| 1758 | j->pccr1.byte = inb_p(j->XILINXbase + 0x03); |
| 1759 | if (!j->flags.pcmciastate) { |
| 1760 | j->pccr2.byte = inb_p(j->XILINXbase + 0x02); |
| 1761 | if (j->pccr1.bits.drf || j->pccr2.bits.rstc) { |
| 1762 | j->flags.pcmciastate = 4; |
| 1763 | return 0; |
| 1764 | } |
| 1765 | if (j->pccr1.bits.ed) { |
| 1766 | j->pccr1.bits.ed = 0; |
| 1767 | j->psccr.bits.dev = 3; |
| 1768 | j->psccr.bits.rw = 1; |
| 1769 | outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00); |
| 1770 | ixj_PCcontrol_wait(j); |
| 1771 | j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF; |
| 1772 | j->pslic.bits.led2 = j->pslic.bits.det ? 1 : 0; |
| 1773 | j->psccr.bits.dev = 3; |
| 1774 | j->psccr.bits.rw = 0; |
| 1775 | outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00); |
| 1776 | ixj_PCcontrol_wait(j); |
| 1777 | return j->pslic.bits.led2 ? 1 : 0; |
| 1778 | } else if (j->flags.pcmciasct) { |
| 1779 | return j->r_hook; |
| 1780 | } else { |
| 1781 | return 1; |
| 1782 | } |
| 1783 | } else if (j->flags.pcmciastate == 4) { |
| 1784 | if (!j->pccr1.bits.drf) { |
| 1785 | j->flags.pcmciastate = 3; |
| 1786 | } |
| 1787 | return 0; |
| 1788 | } else if (j->flags.pcmciastate == 3) { |
| 1789 | j->pccr2.bits.pwr = 0; |
| 1790 | j->pccr2.bits.rstc = 1; |
| 1791 | outb(j->pccr2.byte, j->XILINXbase + 0x02); |
| 1792 | j->checkwait = jiffies + (hertz * 2); |
| 1793 | j->flags.incheck = 1; |
| 1794 | j->flags.pcmciastate = 2; |
| 1795 | return 0; |
| 1796 | } else if (j->flags.pcmciastate == 2) { |
| 1797 | if (j->flags.incheck) { |
| 1798 | if (time_before(jiffies, j->checkwait)) { |
| 1799 | return 0; |
| 1800 | } else { |
| 1801 | j->flags.incheck = 0; |
| 1802 | } |
| 1803 | } |
| 1804 | j->pccr2.bits.pwr = 0; |
| 1805 | j->pccr2.bits.rstc = 0; |
| 1806 | outb_p(j->pccr2.byte, j->XILINXbase + 0x02); |
| 1807 | j->flags.pcmciastate = 1; |
| 1808 | return 0; |
| 1809 | } else if (j->flags.pcmciastate == 1) { |
| 1810 | j->flags.pcmciastate = 0; |
| 1811 | if (!j->pccr1.bits.drf) { |
| 1812 | j->psccr.bits.dev = 3; |
| 1813 | j->psccr.bits.rw = 1; |
| 1814 | outb_p(j->psccr.byte, j->XILINXbase + 0x01); |
| 1815 | ixj_PCcontrol_wait(j); |
| 1816 | j->flags.pcmciascp = 1; /* Set Cable Present Flag */ |
| 1817 | |
| 1818 | j->flags.pcmciasct = (inw_p(j->XILINXbase + 0x00) >> 8) & 0x03; /* Get Cable Type */ |
| 1819 | |
| 1820 | if (j->flags.pcmciasct == 3) { |
| 1821 | j->flags.pcmciastate = 4; |
| 1822 | return 0; |
| 1823 | } else if (j->flags.pcmciasct == 0) { |
| 1824 | j->pccr2.bits.pwr = 1; |
| 1825 | j->pccr2.bits.rstc = 0; |
| 1826 | outb_p(j->pccr2.byte, j->XILINXbase + 0x02); |
| 1827 | j->port = PORT_SPEAKER; |
| 1828 | } else { |
| 1829 | j->port = PORT_POTS; |
| 1830 | } |
| 1831 | j->sic1.bits.cpd = 0; /* Chip Power Down */ |
| 1832 | j->sic1.bits.mpd = 0; /* MIC Bias Power Down */ |
| 1833 | j->sic1.bits.hpd = 0; /* Handset Bias Power Down */ |
| 1834 | j->sic1.bits.lpd = 0; /* Line Bias Power Down */ |
| 1835 | j->sic1.bits.spd = 1; /* Speaker Drive Power Down */ |
| 1836 | j->psccr.bits.addr = 1; /* R/W Smart Cable Register Address */ |
| 1837 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1838 | j->psccr.bits.dev = 0; |
| 1839 | outb(j->sic1.byte, j->XILINXbase + 0x00); |
| 1840 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1841 | ixj_PCcontrol_wait(j); |
| 1842 | |
| 1843 | j->sic2.bits.al = 0; /* Analog Loopback DAC analog -> ADC analog */ |
| 1844 | j->sic2.bits.dl2 = 0; /* Digital Loopback DAC -> ADC one bit */ |
| 1845 | j->sic2.bits.dl1 = 0; /* Digital Loopback ADC -> DAC one bit */ |
| 1846 | j->sic2.bits.pll = 0; /* 1 = div 10, 0 = div 5 */ |
| 1847 | j->sic2.bits.hpd = 0; /* HPF disable */ |
| 1848 | j->psccr.bits.addr = 2; /* R/W Smart Cable Register Address */ |
| 1849 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1850 | j->psccr.bits.dev = 0; |
| 1851 | outb(j->sic2.byte, j->XILINXbase + 0x00); |
| 1852 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1853 | ixj_PCcontrol_wait(j); |
| 1854 | |
| 1855 | j->psccr.bits.addr = 3; /* R/W Smart Cable Register Address */ |
| 1856 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1857 | j->psccr.bits.dev = 0; |
| 1858 | outb(0x00, j->XILINXbase + 0x00); /* PLL Divide N1 */ |
| 1859 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1860 | ixj_PCcontrol_wait(j); |
| 1861 | |
| 1862 | j->psccr.bits.addr = 4; /* R/W Smart Cable Register Address */ |
| 1863 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1864 | j->psccr.bits.dev = 0; |
| 1865 | outb(0x09, j->XILINXbase + 0x00); /* PLL Multiply M1 */ |
| 1866 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1867 | ixj_PCcontrol_wait(j); |
| 1868 | |
| 1869 | j->sirxg.bits.lig = 1; /* Line In Gain */ |
| 1870 | j->sirxg.bits.lim = 1; /* Line In Mute */ |
| 1871 | j->sirxg.bits.mcg = 0; /* MIC In Gain was 3 */ |
| 1872 | j->sirxg.bits.mcm = 0; /* MIC In Mute */ |
| 1873 | j->sirxg.bits.him = 0; /* Handset In Mute */ |
| 1874 | j->sirxg.bits.iir = 1; /* IIR */ |
| 1875 | j->psccr.bits.addr = 5; /* R/W Smart Cable Register Address */ |
| 1876 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1877 | j->psccr.bits.dev = 0; |
| 1878 | outb(j->sirxg.byte, j->XILINXbase + 0x00); |
| 1879 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1880 | ixj_PCcontrol_wait(j); |
| 1881 | |
| 1882 | ixj_siadc(j, 0x17); |
| 1883 | ixj_sidac(j, 0x1D); |
| 1884 | |
| 1885 | j->siaatt.bits.sot = 0; |
| 1886 | j->psccr.bits.addr = 9; /* R/W Smart Cable Register Address */ |
| 1887 | j->psccr.bits.rw = 0; /* Read / Write flag */ |
| 1888 | j->psccr.bits.dev = 0; |
| 1889 | outb(j->siaatt.byte, j->XILINXbase + 0x00); |
| 1890 | outb(j->psccr.byte, j->XILINXbase + 0x01); |
| 1891 | ixj_PCcontrol_wait(j); |
| 1892 | |
| 1893 | if (j->flags.pcmciasct == 1 && !j->readers && !j->writers) { |
| 1894 | j->psccr.byte = j->pslic.byte = 0; |
| 1895 | j->pslic.bits.powerdown = 1; |
| 1896 | j->psccr.bits.dev = 3; |
| 1897 | j->psccr.bits.rw = 0; |
| 1898 | outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00); |
| 1899 | ixj_PCcontrol_wait(j); |
| 1900 | } |
| 1901 | } |
| 1902 | return 0; |
| 1903 | } else { |
| 1904 | j->flags.pcmciascp = 0; |
| 1905 | return 0; |
| 1906 | } |
| 1907 | return 0; |
| 1908 | } |
| 1909 | |
| 1910 | static int ixj_hookstate(IXJ *j) |
| 1911 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1912 | int fOffHook = 0; |
| 1913 | |
| 1914 | switch (j->cardtype) { |
| 1915 | case QTI_PHONEJACK: |
| 1916 | ixj_gpio_read(j); |
| 1917 | fOffHook = j->gpio.bits.gpio3read ? 1 : 0; |
| 1918 | break; |
| 1919 | case QTI_LINEJACK: |
| 1920 | case QTI_PHONEJACK_LITE: |
| 1921 | case QTI_PHONEJACK_PCI: |
| 1922 | SLIC_GetState(j); |
| 1923 | if(j->cardtype == QTI_LINEJACK && j->flags.pots_pstn == 1 && (j->readers || j->writers)) { |
| 1924 | fOffHook = j->pld_slicr.bits.potspstn ? 1 : 0; |
| 1925 | if(fOffHook != j->p_hook) { |
| 1926 | if(!j->checkwait) { |
| 1927 | j->checkwait = jiffies; |
| 1928 | } |
| 1929 | if(time_before(jiffies, j->checkwait + 2)) { |
| 1930 | fOffHook ^= 1; |
| 1931 | } else { |
| 1932 | j->checkwait = 0; |
| 1933 | } |
| 1934 | j->p_hook = fOffHook; |
| 1935 | printk("IXJ : /dev/phone%d pots-pstn hookstate check %d at %ld\n", j->board, fOffHook, jiffies); |
| 1936 | } |
| 1937 | } else { |
| 1938 | if (j->pld_slicr.bits.state == PLD_SLIC_STATE_ACTIVE || |
| 1939 | j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) { |
| 1940 | if (j->flags.ringing || j->flags.cringing) { |
| 1941 | if (!in_interrupt()) { |
Nishanth Aravamudan | f4c9925 | 2005-09-10 00:26:50 -0700 | [diff] [blame] | 1942 | msleep(20); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1943 | } |
| 1944 | SLIC_GetState(j); |
| 1945 | if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) { |
| 1946 | ixj_ring_on(j); |
| 1947 | } |
| 1948 | } |
| 1949 | if (j->cardtype == QTI_PHONEJACK_PCI) { |
| 1950 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 1951 | fOffHook = j->pld_scrr.pcib.det ? 1 : 0; |
| 1952 | } else |
| 1953 | fOffHook = j->pld_slicr.bits.det ? 1 : 0; |
| 1954 | } |
| 1955 | } |
| 1956 | break; |
| 1957 | case QTI_PHONECARD: |
| 1958 | fOffHook = ixj_pcmcia_cable_check(j); |
| 1959 | break; |
| 1960 | } |
| 1961 | if (j->r_hook != fOffHook) { |
| 1962 | j->r_hook = fOffHook; |
| 1963 | if (j->port == PORT_SPEAKER || j->port == PORT_HANDSET) { // || (j->port == PORT_PSTN && j->flags.pots_pstn == 0)) { |
| 1964 | j->ex.bits.hookstate = 1; |
| 1965 | ixj_kill_fasync(j, SIG_HOOKSTATE, POLL_IN); |
| 1966 | } else if (!fOffHook) { |
| 1967 | j->flash_end = jiffies + ((60 * hertz) / 100); |
| 1968 | } |
| 1969 | } |
| 1970 | if (fOffHook) { |
| 1971 | if(time_before(jiffies, j->flash_end)) { |
| 1972 | j->ex.bits.flash = 1; |
| 1973 | j->flash_end = 0; |
| 1974 | ixj_kill_fasync(j, SIG_FLASH, POLL_IN); |
| 1975 | } |
| 1976 | } else { |
| 1977 | if(time_before(jiffies, j->flash_end)) { |
| 1978 | fOffHook = 1; |
| 1979 | } |
| 1980 | } |
| 1981 | |
| 1982 | if (j->port == PORT_PSTN && j->daa_mode == SOP_PU_CONVERSATION) |
| 1983 | fOffHook |= 2; |
| 1984 | |
| 1985 | if (j->port == PORT_SPEAKER) { |
| 1986 | if(j->cardtype == QTI_PHONECARD) { |
| 1987 | if(j->flags.pcmciascp && j->flags.pcmciasct) { |
| 1988 | fOffHook |= 2; |
| 1989 | } |
| 1990 | } else { |
| 1991 | fOffHook |= 2; |
| 1992 | } |
| 1993 | } |
| 1994 | |
| 1995 | if (j->port == PORT_HANDSET) |
| 1996 | fOffHook |= 2; |
| 1997 | |
| 1998 | return fOffHook; |
| 1999 | } |
| 2000 | |
| 2001 | static void ixj_ring_off(IXJ *j) |
| 2002 | { |
| 2003 | if (j->dsp.low == 0x20) /* Internet PhoneJACK */ |
| 2004 | { |
| 2005 | if (ixjdebug & 0x0004) |
| 2006 | printk(KERN_INFO "IXJ Ring Off\n"); |
| 2007 | j->gpio.bytes.high = 0x0B; |
| 2008 | j->gpio.bytes.low = 0x00; |
| 2009 | j->gpio.bits.gpio1 = 0; |
| 2010 | j->gpio.bits.gpio2 = 1; |
| 2011 | j->gpio.bits.gpio5 = 0; |
| 2012 | ixj_WriteDSPCommand(j->gpio.word, j); |
| 2013 | } else /* Internet LineJACK */ |
| 2014 | { |
| 2015 | if (ixjdebug & 0x0004) |
| 2016 | printk(KERN_INFO "IXJ Ring Off\n"); |
| 2017 | |
| 2018 | if(!j->flags.cidplay) |
| 2019 | SLIC_SetState(PLD_SLIC_STATE_STANDBY, j); |
| 2020 | |
| 2021 | SLIC_GetState(j); |
| 2022 | } |
| 2023 | } |
| 2024 | |
| 2025 | static void ixj_ring_start(IXJ *j) |
| 2026 | { |
| 2027 | j->flags.cringing = 1; |
| 2028 | if (ixjdebug & 0x0004) |
| 2029 | printk(KERN_INFO "IXJ Cadence Ringing Start /dev/phone%d\n", j->board); |
| 2030 | if (ixj_hookstate(j) & 1) { |
| 2031 | if (j->port == PORT_POTS) |
| 2032 | ixj_ring_off(j); |
| 2033 | j->flags.cringing = 0; |
| 2034 | if (ixjdebug & 0x0004) |
| 2035 | printk(KERN_INFO "IXJ Cadence Ringing Stopped /dev/phone%d off hook\n", j->board); |
| 2036 | } else if(j->cadence_f[5].enable && (!j->cadence_f[5].en_filter)) { |
| 2037 | j->ring_cadence_jif = jiffies; |
| 2038 | j->flags.cidsent = j->flags.cidring = 0; |
| 2039 | j->cadence_f[5].state = 0; |
| 2040 | if(j->cadence_f[5].on1) |
| 2041 | ixj_ring_on(j); |
| 2042 | } else { |
| 2043 | j->ring_cadence_jif = jiffies; |
| 2044 | j->ring_cadence_t = 15; |
| 2045 | if (j->ring_cadence & 1 << j->ring_cadence_t) { |
| 2046 | ixj_ring_on(j); |
| 2047 | } else { |
| 2048 | ixj_ring_off(j); |
| 2049 | } |
| 2050 | j->flags.cidsent = j->flags.cidring = j->flags.firstring = 0; |
| 2051 | } |
| 2052 | } |
| 2053 | |
| 2054 | static int ixj_ring(IXJ *j) |
| 2055 | { |
| 2056 | char cntr; |
Nishanth Aravamudan | f4c9925 | 2005-09-10 00:26:50 -0700 | [diff] [blame] | 2057 | unsigned long jif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2058 | |
| 2059 | j->flags.ringing = 1; |
| 2060 | if (ixj_hookstate(j) & 1) { |
| 2061 | ixj_ring_off(j); |
| 2062 | j->flags.ringing = 0; |
| 2063 | return 1; |
| 2064 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | for (cntr = 0; cntr < j->maxrings; cntr++) { |
| 2066 | jif = jiffies + (1 * hertz); |
| 2067 | ixj_ring_on(j); |
| 2068 | while (time_before(jiffies, jif)) { |
| 2069 | if (ixj_hookstate(j) & 1) { |
| 2070 | ixj_ring_off(j); |
| 2071 | j->flags.ringing = 0; |
| 2072 | return 1; |
| 2073 | } |
Nishanth Aravamudan | 1e63bc7 | 2005-09-10 00:27:31 -0700 | [diff] [blame] | 2074 | schedule_timeout_interruptible(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2075 | if (signal_pending(current)) |
| 2076 | break; |
| 2077 | } |
| 2078 | jif = jiffies + (3 * hertz); |
| 2079 | ixj_ring_off(j); |
| 2080 | while (time_before(jiffies, jif)) { |
| 2081 | if (ixj_hookstate(j) & 1) { |
Nishanth Aravamudan | f4c9925 | 2005-09-10 00:26:50 -0700 | [diff] [blame] | 2082 | msleep(10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2083 | if (ixj_hookstate(j) & 1) { |
| 2084 | j->flags.ringing = 0; |
| 2085 | return 1; |
| 2086 | } |
| 2087 | } |
Nishanth Aravamudan | 1e63bc7 | 2005-09-10 00:27:31 -0700 | [diff] [blame] | 2088 | schedule_timeout_interruptible(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | if (signal_pending(current)) |
| 2090 | break; |
| 2091 | } |
| 2092 | } |
| 2093 | ixj_ring_off(j); |
| 2094 | j->flags.ringing = 0; |
| 2095 | return 0; |
| 2096 | } |
| 2097 | |
| 2098 | static int ixj_open(struct phone_device *p, struct file *file_p) |
| 2099 | { |
| 2100 | IXJ *j = get_ixj(p->board); |
| 2101 | file_p->private_data = j; |
| 2102 | |
| 2103 | if (!j->DSPbase) |
| 2104 | return -ENODEV; |
| 2105 | |
| 2106 | if (file_p->f_mode & FMODE_READ) { |
| 2107 | if(!j->readers) { |
| 2108 | j->readers++; |
| 2109 | } else { |
| 2110 | return -EBUSY; |
| 2111 | } |
| 2112 | } |
| 2113 | |
| 2114 | if (file_p->f_mode & FMODE_WRITE) { |
| 2115 | if(!j->writers) { |
| 2116 | j->writers++; |
| 2117 | } else { |
| 2118 | if (file_p->f_mode & FMODE_READ){ |
| 2119 | j->readers--; |
| 2120 | } |
| 2121 | return -EBUSY; |
| 2122 | } |
| 2123 | } |
| 2124 | |
| 2125 | if (j->cardtype == QTI_PHONECARD) { |
| 2126 | j->pslic.bits.powerdown = 0; |
| 2127 | j->psccr.bits.dev = 3; |
| 2128 | j->psccr.bits.rw = 0; |
| 2129 | outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00); |
| 2130 | ixj_PCcontrol_wait(j); |
| 2131 | } |
| 2132 | |
| 2133 | j->flags.cidplay = 0; |
| 2134 | j->flags.cidcw_ack = 0; |
| 2135 | |
| 2136 | if (ixjdebug & 0x0002) |
| 2137 | printk(KERN_INFO "Opening board %d\n", p->board); |
| 2138 | |
| 2139 | j->framesread = j->frameswritten = 0; |
| 2140 | return 0; |
| 2141 | } |
| 2142 | |
| 2143 | static int ixj_release(struct inode *inode, struct file *file_p) |
| 2144 | { |
| 2145 | IXJ_TONE ti; |
| 2146 | int cnt; |
| 2147 | IXJ *j = file_p->private_data; |
| 2148 | int board = j->p.board; |
| 2149 | |
| 2150 | /* |
| 2151 | * Set up locks to ensure that only one process is talking to the DSP at a time. |
| 2152 | * This is necessary to keep the DSP from locking up. |
| 2153 | */ |
Nishanth Aravamudan | 1e63bc7 | 2005-09-10 00:27:31 -0700 | [diff] [blame] | 2154 | while(test_and_set_bit(board, (void *)&j->busyflags) != 0) |
| 2155 | schedule_timeout_interruptible(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2156 | if (ixjdebug & 0x0002) |
| 2157 | printk(KERN_INFO "Closing board %d\n", NUM(inode)); |
| 2158 | |
| 2159 | if (j->cardtype == QTI_PHONECARD) |
| 2160 | ixj_set_port(j, PORT_SPEAKER); |
| 2161 | else |
| 2162 | ixj_set_port(j, PORT_POTS); |
| 2163 | |
| 2164 | aec_stop(j); |
| 2165 | ixj_play_stop(j); |
| 2166 | ixj_record_stop(j); |
| 2167 | set_play_volume(j, 0x100); |
| 2168 | set_rec_volume(j, 0x100); |
| 2169 | ixj_ring_off(j); |
| 2170 | |
| 2171 | /* Restore the tone table to default settings. */ |
| 2172 | ti.tone_index = 10; |
| 2173 | ti.gain0 = 1; |
| 2174 | ti.freq0 = hz941; |
| 2175 | ti.gain1 = 0; |
| 2176 | ti.freq1 = hz1209; |
| 2177 | ixj_init_tone(j, &ti); |
| 2178 | ti.tone_index = 11; |
| 2179 | ti.gain0 = 1; |
| 2180 | ti.freq0 = hz941; |
| 2181 | ti.gain1 = 0; |
| 2182 | ti.freq1 = hz1336; |
| 2183 | ixj_init_tone(j, &ti); |
| 2184 | ti.tone_index = 12; |
| 2185 | ti.gain0 = 1; |
| 2186 | ti.freq0 = hz941; |
| 2187 | ti.gain1 = 0; |
| 2188 | ti.freq1 = hz1477; |
| 2189 | ixj_init_tone(j, &ti); |
| 2190 | ti.tone_index = 13; |
| 2191 | ti.gain0 = 1; |
| 2192 | ti.freq0 = hz800; |
| 2193 | ti.gain1 = 0; |
| 2194 | ti.freq1 = 0; |
| 2195 | ixj_init_tone(j, &ti); |
| 2196 | ti.tone_index = 14; |
| 2197 | ti.gain0 = 1; |
| 2198 | ti.freq0 = hz1000; |
| 2199 | ti.gain1 = 0; |
| 2200 | ti.freq1 = 0; |
| 2201 | ixj_init_tone(j, &ti); |
| 2202 | ti.tone_index = 15; |
| 2203 | ti.gain0 = 1; |
| 2204 | ti.freq0 = hz1250; |
| 2205 | ti.gain1 = 0; |
| 2206 | ti.freq1 = 0; |
| 2207 | ixj_init_tone(j, &ti); |
| 2208 | ti.tone_index = 16; |
| 2209 | ti.gain0 = 1; |
| 2210 | ti.freq0 = hz950; |
| 2211 | ti.gain1 = 0; |
| 2212 | ti.freq1 = 0; |
| 2213 | ixj_init_tone(j, &ti); |
| 2214 | ti.tone_index = 17; |
| 2215 | ti.gain0 = 1; |
| 2216 | ti.freq0 = hz1100; |
| 2217 | ti.gain1 = 0; |
| 2218 | ti.freq1 = 0; |
| 2219 | ixj_init_tone(j, &ti); |
| 2220 | ti.tone_index = 18; |
| 2221 | ti.gain0 = 1; |
| 2222 | ti.freq0 = hz1400; |
| 2223 | ti.gain1 = 0; |
| 2224 | ti.freq1 = 0; |
| 2225 | ixj_init_tone(j, &ti); |
| 2226 | ti.tone_index = 19; |
| 2227 | ti.gain0 = 1; |
| 2228 | ti.freq0 = hz1500; |
| 2229 | ti.gain1 = 0; |
| 2230 | ti.freq1 = 0; |
| 2231 | ixj_init_tone(j, &ti); |
| 2232 | ti.tone_index = 20; |
| 2233 | ti.gain0 = 1; |
| 2234 | ti.freq0 = hz1600; |
| 2235 | ti.gain1 = 0; |
| 2236 | ti.freq1 = 0; |
| 2237 | ixj_init_tone(j, &ti); |
| 2238 | ti.tone_index = 21; |
| 2239 | ti.gain0 = 1; |
| 2240 | ti.freq0 = hz1800; |
| 2241 | ti.gain1 = 0; |
| 2242 | ti.freq1 = 0; |
| 2243 | ixj_init_tone(j, &ti); |
| 2244 | ti.tone_index = 22; |
| 2245 | ti.gain0 = 1; |
| 2246 | ti.freq0 = hz2100; |
| 2247 | ti.gain1 = 0; |
| 2248 | ti.freq1 = 0; |
| 2249 | ixj_init_tone(j, &ti); |
| 2250 | ti.tone_index = 23; |
| 2251 | ti.gain0 = 1; |
| 2252 | ti.freq0 = hz1300; |
| 2253 | ti.gain1 = 0; |
| 2254 | ti.freq1 = 0; |
| 2255 | ixj_init_tone(j, &ti); |
| 2256 | ti.tone_index = 24; |
| 2257 | ti.gain0 = 1; |
| 2258 | ti.freq0 = hz2450; |
| 2259 | ti.gain1 = 0; |
| 2260 | ti.freq1 = 0; |
| 2261 | ixj_init_tone(j, &ti); |
| 2262 | ti.tone_index = 25; |
| 2263 | ti.gain0 = 1; |
| 2264 | ti.freq0 = hz350; |
| 2265 | ti.gain1 = 0; |
| 2266 | ti.freq1 = hz440; |
| 2267 | ixj_init_tone(j, &ti); |
| 2268 | ti.tone_index = 26; |
| 2269 | ti.gain0 = 1; |
| 2270 | ti.freq0 = hz440; |
| 2271 | ti.gain1 = 0; |
| 2272 | ti.freq1 = hz480; |
| 2273 | ixj_init_tone(j, &ti); |
| 2274 | ti.tone_index = 27; |
| 2275 | ti.gain0 = 1; |
| 2276 | ti.freq0 = hz480; |
| 2277 | ti.gain1 = 0; |
| 2278 | ti.freq1 = hz620; |
| 2279 | ixj_init_tone(j, &ti); |
| 2280 | |
| 2281 | set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */ |
| 2282 | |
| 2283 | set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */ |
| 2284 | |
| 2285 | j->ex.bits.dtmf_ready = 0; |
| 2286 | j->dtmf_state = 0; |
| 2287 | j->dtmf_wp = j->dtmf_rp = 0; |
| 2288 | j->rec_mode = j->play_mode = -1; |
| 2289 | j->flags.ringing = 0; |
| 2290 | j->maxrings = MAXRINGS; |
| 2291 | j->ring_cadence = USA_RING_CADENCE; |
| 2292 | if(j->cadence_f[5].enable) { |
| 2293 | j->cadence_f[5].enable = j->cadence_f[5].en_filter = j->cadence_f[5].state = 0; |
| 2294 | } |
| 2295 | j->drybuffer = 0; |
| 2296 | j->winktime = 320; |
| 2297 | j->flags.dtmf_oob = 0; |
| 2298 | for (cnt = 0; cnt < 4; cnt++) |
| 2299 | j->cadence_f[cnt].enable = 0; |
| 2300 | |
| 2301 | idle(j); |
| 2302 | |
| 2303 | if(j->cardtype == QTI_PHONECARD) { |
| 2304 | SLIC_SetState(PLD_SLIC_STATE_OC, j); |
| 2305 | } |
| 2306 | |
| 2307 | if (file_p->f_mode & FMODE_READ) |
| 2308 | j->readers--; |
| 2309 | if (file_p->f_mode & FMODE_WRITE) |
| 2310 | j->writers--; |
| 2311 | |
| 2312 | if (j->read_buffer && !j->readers) { |
| 2313 | kfree(j->read_buffer); |
| 2314 | j->read_buffer = NULL; |
| 2315 | j->read_buffer_size = 0; |
| 2316 | } |
| 2317 | if (j->write_buffer && !j->writers) { |
| 2318 | kfree(j->write_buffer); |
| 2319 | j->write_buffer = NULL; |
| 2320 | j->write_buffer_size = 0; |
| 2321 | } |
| 2322 | j->rec_codec = j->play_codec = 0; |
| 2323 | j->rec_frame_size = j->play_frame_size = 0; |
| 2324 | j->flags.cidsent = j->flags.cidring = 0; |
| 2325 | ixj_fasync(-1, file_p, 0); /* remove from list of async notification */ |
| 2326 | |
| 2327 | if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) { |
| 2328 | ixj_set_port(j, PORT_PSTN); |
| 2329 | daa_set_mode(j, SOP_PU_SLEEP); |
| 2330 | ixj_set_pots(j, 1); |
| 2331 | } |
| 2332 | ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */ |
| 2333 | |
| 2334 | /* Set up the default signals for events */ |
| 2335 | for (cnt = 0; cnt < 35; cnt++) |
| 2336 | j->ixj_signals[cnt] = SIGIO; |
| 2337 | |
| 2338 | /* Set the excetion signal enable flags */ |
| 2339 | j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring = |
| 2340 | 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 = |
| 2341 | 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; |
| 2342 | |
| 2343 | file_p->private_data = NULL; |
| 2344 | clear_bit(board, &j->busyflags); |
| 2345 | return 0; |
| 2346 | } |
| 2347 | |
| 2348 | static int read_filters(IXJ *j) |
| 2349 | { |
| 2350 | unsigned short fc, cnt, trg; |
| 2351 | int var; |
| 2352 | |
| 2353 | trg = 0; |
| 2354 | if (ixj_WriteDSPCommand(0x5144, j)) { |
| 2355 | if(ixjdebug & 0x0001) { |
| 2356 | printk(KERN_INFO "Read Frame Counter failed!\n"); |
| 2357 | } |
| 2358 | return -1; |
| 2359 | } |
| 2360 | fc = j->ssr.high << 8 | j->ssr.low; |
| 2361 | if (fc == j->frame_count) |
| 2362 | return 1; |
| 2363 | |
| 2364 | j->frame_count = fc; |
| 2365 | |
| 2366 | if (j->dtmf_proc) |
| 2367 | return 1; |
| 2368 | |
| 2369 | var = 10; |
| 2370 | |
| 2371 | for (cnt = 0; cnt < 4; cnt++) { |
| 2372 | if (ixj_WriteDSPCommand(0x5154 + cnt, j)) { |
| 2373 | if(ixjdebug & 0x0001) { |
| 2374 | printk(KERN_INFO "Select Filter %d failed!\n", cnt); |
| 2375 | } |
| 2376 | return -1; |
| 2377 | } |
| 2378 | if (ixj_WriteDSPCommand(0x515C, j)) { |
| 2379 | if(ixjdebug & 0x0001) { |
| 2380 | printk(KERN_INFO "Read Filter History %d failed!\n", cnt); |
| 2381 | } |
| 2382 | return -1; |
| 2383 | } |
| 2384 | j->filter_hist[cnt] = j->ssr.high << 8 | j->ssr.low; |
| 2385 | |
| 2386 | if (j->cadence_f[cnt].enable) { |
| 2387 | if (j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) { |
| 2388 | if (j->cadence_f[cnt].state == 0) { |
| 2389 | j->cadence_f[cnt].state = 1; |
| 2390 | j->cadence_f[cnt].on1min = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 - var)) / 10000)); |
| 2391 | j->cadence_f[cnt].on1dot = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100)) / 10000)); |
| 2392 | j->cadence_f[cnt].on1max = jiffies + (long)((j->cadence_f[cnt].on1 * (hertz * (100 + var)) / 10000)); |
| 2393 | } else if (j->cadence_f[cnt].state == 2 && |
| 2394 | (time_after(jiffies, j->cadence_f[cnt].off1min) && |
| 2395 | time_before(jiffies, j->cadence_f[cnt].off1max))) { |
| 2396 | if (j->cadence_f[cnt].on2) { |
| 2397 | j->cadence_f[cnt].state = 3; |
| 2398 | j->cadence_f[cnt].on2min = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 - var)) / 10000)); |
| 2399 | j->cadence_f[cnt].on2dot = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100)) / 10000)); |
| 2400 | j->cadence_f[cnt].on2max = jiffies + (long)((j->cadence_f[cnt].on2 * (hertz * (100 + var)) / 10000)); |
| 2401 | } else { |
| 2402 | j->cadence_f[cnt].state = 7; |
| 2403 | } |
| 2404 | } else if (j->cadence_f[cnt].state == 4 && |
| 2405 | (time_after(jiffies, j->cadence_f[cnt].off2min) && |
| 2406 | time_before(jiffies, j->cadence_f[cnt].off2max))) { |
| 2407 | if (j->cadence_f[cnt].on3) { |
| 2408 | j->cadence_f[cnt].state = 5; |
| 2409 | j->cadence_f[cnt].on3min = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 - var)) / 10000)); |
| 2410 | j->cadence_f[cnt].on3dot = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100)) / 10000)); |
| 2411 | j->cadence_f[cnt].on3max = jiffies + (long)((j->cadence_f[cnt].on3 * (hertz * (100 + var)) / 10000)); |
| 2412 | } else { |
| 2413 | j->cadence_f[cnt].state = 7; |
| 2414 | } |
| 2415 | } else { |
| 2416 | j->cadence_f[cnt].state = 0; |
| 2417 | } |
| 2418 | } else if (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)) { |
| 2419 | if (j->cadence_f[cnt].state == 1) { |
| 2420 | if(!j->cadence_f[cnt].on1) { |
| 2421 | j->cadence_f[cnt].state = 7; |
| 2422 | } else if((time_after(jiffies, j->cadence_f[cnt].on1min) && |
| 2423 | time_before(jiffies, j->cadence_f[cnt].on1max))) { |
| 2424 | if(j->cadence_f[cnt].off1) { |
| 2425 | j->cadence_f[cnt].state = 2; |
| 2426 | j->cadence_f[cnt].off1min = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 - var)) / 10000)); |
| 2427 | j->cadence_f[cnt].off1dot = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100)) / 10000)); |
| 2428 | j->cadence_f[cnt].off1max = jiffies + (long)((j->cadence_f[cnt].off1 * (hertz * (100 + var)) / 10000)); |
| 2429 | } else { |
| 2430 | j->cadence_f[cnt].state = 7; |
| 2431 | } |
| 2432 | } else { |
| 2433 | j->cadence_f[cnt].state = 0; |
| 2434 | } |
| 2435 | } else if (j->cadence_f[cnt].state == 3) { |
| 2436 | if((time_after(jiffies, j->cadence_f[cnt].on2min) && |
| 2437 | time_before(jiffies, j->cadence_f[cnt].on2max))) { |
| 2438 | if(j->cadence_f[cnt].off2) { |
| 2439 | j->cadence_f[cnt].state = 4; |
| 2440 | j->cadence_f[cnt].off2min = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 - var)) / 10000)); |
| 2441 | j->cadence_f[cnt].off2dot = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100)) / 10000)); |
| 2442 | j->cadence_f[cnt].off2max = jiffies + (long)((j->cadence_f[cnt].off2 * (hertz * (100 + var)) / 10000)); |
| 2443 | } else { |
| 2444 | j->cadence_f[cnt].state = 7; |
| 2445 | } |
| 2446 | } else { |
| 2447 | j->cadence_f[cnt].state = 0; |
| 2448 | } |
| 2449 | } else if (j->cadence_f[cnt].state == 5) { |
| 2450 | if ((time_after(jiffies, j->cadence_f[cnt].on3min) && |
| 2451 | time_before(jiffies, j->cadence_f[cnt].on3max))) { |
| 2452 | if(j->cadence_f[cnt].off3) { |
| 2453 | j->cadence_f[cnt].state = 6; |
| 2454 | j->cadence_f[cnt].off3min = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 - var)) / 10000)); |
| 2455 | j->cadence_f[cnt].off3dot = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100)) / 10000)); |
| 2456 | j->cadence_f[cnt].off3max = jiffies + (long)((j->cadence_f[cnt].off3 * (hertz * (100 + var)) / 10000)); |
| 2457 | } else { |
| 2458 | j->cadence_f[cnt].state = 7; |
| 2459 | } |
| 2460 | } else { |
| 2461 | j->cadence_f[cnt].state = 0; |
| 2462 | } |
| 2463 | } else { |
| 2464 | j->cadence_f[cnt].state = 0; |
| 2465 | } |
| 2466 | } else { |
| 2467 | switch(j->cadence_f[cnt].state) { |
| 2468 | case 1: |
| 2469 | if(time_after(jiffies, j->cadence_f[cnt].on1dot) && |
| 2470 | !j->cadence_f[cnt].off1 && |
| 2471 | !j->cadence_f[cnt].on2 && !j->cadence_f[cnt].off2 && |
| 2472 | !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) { |
| 2473 | j->cadence_f[cnt].state = 7; |
| 2474 | } |
| 2475 | break; |
| 2476 | case 3: |
| 2477 | if(time_after(jiffies, j->cadence_f[cnt].on2dot) && |
| 2478 | !j->cadence_f[cnt].off2 && |
| 2479 | !j->cadence_f[cnt].on3 && !j->cadence_f[cnt].off3) { |
| 2480 | j->cadence_f[cnt].state = 7; |
| 2481 | } |
| 2482 | break; |
| 2483 | case 5: |
| 2484 | if(time_after(jiffies, j->cadence_f[cnt].on3dot) && |
| 2485 | !j->cadence_f[cnt].off3) { |
| 2486 | j->cadence_f[cnt].state = 7; |
| 2487 | } |
| 2488 | break; |
| 2489 | } |
| 2490 | } |
| 2491 | |
| 2492 | if (ixjdebug & 0x0040) { |
| 2493 | printk(KERN_INFO "IXJ Tone Cadence state = %d /dev/phone%d at %ld\n", j->cadence_f[cnt].state, j->board, jiffies); |
| 2494 | switch(j->cadence_f[cnt].state) { |
| 2495 | case 0: |
| 2496 | printk(KERN_INFO "IXJ /dev/phone%d No Tone detected\n", j->board); |
| 2497 | break; |
| 2498 | case 1: |
| 2499 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %u %ld - %ld - %ld\n", j->board, |
| 2500 | j->cadence_f[cnt].on1, j->cadence_f[cnt].on1min, j->cadence_f[cnt].on1dot, j->cadence_f[cnt].on1max); |
| 2501 | break; |
| 2502 | case 2: |
| 2503 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off1min, |
| 2504 | j->cadence_f[cnt].off1max); |
| 2505 | break; |
| 2506 | case 3: |
| 2507 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on2min, |
| 2508 | j->cadence_f[cnt].on2max); |
| 2509 | break; |
| 2510 | case 4: |
| 2511 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off2min, |
| 2512 | j->cadence_f[cnt].off2max); |
| 2513 | break; |
| 2514 | case 5: |
| 2515 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on3min, |
| 2516 | j->cadence_f[cnt].on3max); |
| 2517 | break; |
| 2518 | case 6: |
| 2519 | printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off3min, |
| 2520 | j->cadence_f[cnt].off3max); |
| 2521 | break; |
| 2522 | } |
| 2523 | } |
| 2524 | } |
| 2525 | if (j->cadence_f[cnt].state == 7) { |
| 2526 | j->cadence_f[cnt].state = 0; |
| 2527 | if (j->cadence_f[cnt].enable == 1) |
| 2528 | j->cadence_f[cnt].enable = 0; |
| 2529 | switch (cnt) { |
| 2530 | case 0: |
| 2531 | if(ixjdebug & 0x0020) { |
| 2532 | printk(KERN_INFO "Filter Cadence 0 triggered %ld\n", jiffies); |
| 2533 | } |
| 2534 | j->ex.bits.fc0 = 1; |
| 2535 | ixj_kill_fasync(j, SIG_FC0, POLL_IN); |
| 2536 | break; |
| 2537 | case 1: |
| 2538 | if(ixjdebug & 0x0020) { |
| 2539 | printk(KERN_INFO "Filter Cadence 1 triggered %ld\n", jiffies); |
| 2540 | } |
| 2541 | j->ex.bits.fc1 = 1; |
| 2542 | ixj_kill_fasync(j, SIG_FC1, POLL_IN); |
| 2543 | break; |
| 2544 | case 2: |
| 2545 | if(ixjdebug & 0x0020) { |
| 2546 | printk(KERN_INFO "Filter Cadence 2 triggered %ld\n", jiffies); |
| 2547 | } |
| 2548 | j->ex.bits.fc2 = 1; |
| 2549 | ixj_kill_fasync(j, SIG_FC2, POLL_IN); |
| 2550 | break; |
| 2551 | case 3: |
| 2552 | if(ixjdebug & 0x0020) { |
| 2553 | printk(KERN_INFO "Filter Cadence 3 triggered %ld\n", jiffies); |
| 2554 | } |
| 2555 | j->ex.bits.fc3 = 1; |
| 2556 | ixj_kill_fasync(j, SIG_FC3, POLL_IN); |
| 2557 | break; |
| 2558 | } |
| 2559 | } |
| 2560 | if (j->filter_en[cnt] && ((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12)) || |
| 2561 | (j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3)))) { |
| 2562 | if((j->filter_hist[cnt] & 3 && !(j->filter_hist[cnt] & 12))) { |
| 2563 | trg = 1; |
| 2564 | } else if((j->filter_hist[cnt] & 12 && !(j->filter_hist[cnt] & 3))) { |
| 2565 | trg = 0; |
| 2566 | } |
| 2567 | switch (cnt) { |
| 2568 | case 0: |
| 2569 | if(ixjdebug & 0x0020) { |
| 2570 | printk(KERN_INFO "Filter 0 triggered %d at %ld\n", trg, jiffies); |
| 2571 | } |
| 2572 | j->ex.bits.f0 = 1; |
| 2573 | ixj_kill_fasync(j, SIG_F0, POLL_IN); |
| 2574 | break; |
| 2575 | case 1: |
| 2576 | if(ixjdebug & 0x0020) { |
| 2577 | printk(KERN_INFO "Filter 1 triggered %d at %ld\n", trg, jiffies); |
| 2578 | } |
| 2579 | j->ex.bits.f1 = 1; |
| 2580 | ixj_kill_fasync(j, SIG_F1, POLL_IN); |
| 2581 | break; |
| 2582 | case 2: |
| 2583 | if(ixjdebug & 0x0020) { |
| 2584 | printk(KERN_INFO "Filter 2 triggered %d at %ld\n", trg, jiffies); |
| 2585 | } |
| 2586 | j->ex.bits.f2 = 1; |
| 2587 | ixj_kill_fasync(j, SIG_F2, POLL_IN); |
| 2588 | break; |
| 2589 | case 3: |
| 2590 | if(ixjdebug & 0x0020) { |
| 2591 | printk(KERN_INFO "Filter 3 triggered %d at %ld\n", trg, jiffies); |
| 2592 | } |
| 2593 | j->ex.bits.f3 = 1; |
| 2594 | ixj_kill_fasync(j, SIG_F3, POLL_IN); |
| 2595 | break; |
| 2596 | } |
| 2597 | } |
| 2598 | } |
| 2599 | return 0; |
| 2600 | } |
| 2601 | |
| 2602 | static int LineMonitor(IXJ *j) |
| 2603 | { |
| 2604 | if (j->dtmf_proc) { |
| 2605 | return -1; |
| 2606 | } |
| 2607 | j->dtmf_proc = 1; |
| 2608 | |
| 2609 | if (ixj_WriteDSPCommand(0x7000, j)) /* Line Monitor */ |
| 2610 | return -1; |
| 2611 | |
| 2612 | j->dtmf.bytes.high = j->ssr.high; |
| 2613 | j->dtmf.bytes.low = j->ssr.low; |
| 2614 | if (!j->dtmf_state && j->dtmf.bits.dtmf_valid) { |
| 2615 | j->dtmf_state = 1; |
| 2616 | j->dtmf_current = j->dtmf.bits.digit; |
| 2617 | } |
| 2618 | if (j->dtmf_state && !j->dtmf.bits.dtmf_valid) /* && j->dtmf_wp != j->dtmf_rp) */ |
| 2619 | { |
| 2620 | if(!j->cidcw_wait) { |
| 2621 | j->dtmfbuffer[j->dtmf_wp] = j->dtmf_current; |
| 2622 | j->dtmf_wp++; |
| 2623 | if (j->dtmf_wp == 79) |
| 2624 | j->dtmf_wp = 0; |
| 2625 | j->ex.bits.dtmf_ready = 1; |
| 2626 | if(j->ex_sig.bits.dtmf_ready) { |
| 2627 | ixj_kill_fasync(j, SIG_DTMF_READY, POLL_IN); |
| 2628 | } |
| 2629 | } |
| 2630 | else if(j->dtmf_current == 0x00 || j->dtmf_current == 0x0D) { |
| 2631 | if(ixjdebug & 0x0020) { |
| 2632 | printk("IXJ phone%d saw CIDCW Ack DTMF %d from display at %ld\n", j->board, j->dtmf_current, jiffies); |
| 2633 | } |
| 2634 | j->flags.cidcw_ack = 1; |
| 2635 | } |
| 2636 | j->dtmf_state = 0; |
| 2637 | } |
| 2638 | j->dtmf_proc = 0; |
| 2639 | |
| 2640 | return 0; |
| 2641 | } |
| 2642 | |
| 2643 | /************************************************************************ |
| 2644 | * |
| 2645 | * Functions to allow alaw <-> ulaw conversions. |
| 2646 | * |
| 2647 | ************************************************************************/ |
| 2648 | |
| 2649 | static void ulaw2alaw(unsigned char *buff, unsigned long len) |
| 2650 | { |
| 2651 | static unsigned char table_ulaw2alaw[] = |
| 2652 | { |
| 2653 | 0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D, |
| 2654 | 0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25, |
| 2655 | 0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D, |
| 2656 | 0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35, |
| 2657 | 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02, |
| 2658 | 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A, |
| 2659 | 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12, |
| 2660 | 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B, |
| 2661 | 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63, |
| 2662 | 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79, |
| 2663 | 0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71, |
| 2664 | 0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D, |
| 2665 | 0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45, |
| 2666 | 0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D, |
| 2667 | 0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51, |
| 2668 | 0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5, |
| 2669 | 0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD, |
| 2670 | 0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5, |
| 2671 | 0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD, |
| 2672 | 0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5, |
| 2673 | 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82, |
| 2674 | 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A, |
| 2675 | 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92, |
| 2676 | 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB, |
| 2677 | 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3, |
| 2678 | 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9, |
| 2679 | 0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1, |
| 2680 | 0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD, |
| 2681 | 0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5, |
| 2682 | 0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD, |
| 2683 | 0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1, |
| 2684 | 0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5 |
| 2685 | }; |
| 2686 | |
| 2687 | while (len--) |
| 2688 | { |
| 2689 | *buff = table_ulaw2alaw[*(unsigned char *)buff]; |
| 2690 | buff++; |
| 2691 | } |
| 2692 | } |
| 2693 | |
| 2694 | static void alaw2ulaw(unsigned char *buff, unsigned long len) |
| 2695 | { |
| 2696 | static unsigned char table_alaw2ulaw[] = |
| 2697 | { |
| 2698 | 0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C, |
| 2699 | 0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24, |
| 2700 | 0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C, |
| 2701 | 0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34, |
| 2702 | 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, |
| 2703 | 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, |
| 2704 | 0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, |
| 2705 | 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, |
| 2706 | 0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, |
| 2707 | 0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E, |
| 2708 | 0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A, |
| 2709 | 0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, |
| 2710 | 0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B, |
| 2711 | 0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43, |
| 2712 | 0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59, |
| 2713 | 0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51, |
| 2714 | 0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC, |
| 2715 | 0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4, |
| 2716 | 0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC, |
| 2717 | 0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4, |
| 2718 | 0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, |
| 2719 | 0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, |
| 2720 | 0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, |
| 2721 | 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, |
| 2722 | 0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, |
| 2723 | 0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE, |
| 2724 | 0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA, |
| 2725 | 0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, |
| 2726 | 0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB, |
| 2727 | 0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3, |
| 2728 | 0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9, |
| 2729 | 0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1 |
| 2730 | }; |
| 2731 | |
| 2732 | while (len--) |
| 2733 | { |
| 2734 | *buff = table_alaw2ulaw[*(unsigned char *)buff]; |
| 2735 | buff++; |
| 2736 | } |
| 2737 | } |
| 2738 | |
| 2739 | static ssize_t ixj_read(struct file * file_p, char __user *buf, size_t length, loff_t * ppos) |
| 2740 | { |
| 2741 | unsigned long i = *ppos; |
| 2742 | IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode)); |
| 2743 | |
| 2744 | DECLARE_WAITQUEUE(wait, current); |
| 2745 | |
| 2746 | if (j->flags.inread) |
| 2747 | return -EALREADY; |
| 2748 | |
| 2749 | j->flags.inread = 1; |
| 2750 | |
| 2751 | add_wait_queue(&j->read_q, &wait); |
| 2752 | set_current_state(TASK_INTERRUPTIBLE); |
| 2753 | mb(); |
| 2754 | |
| 2755 | while (!j->read_buffer_ready || (j->dtmf_state && j->flags.dtmf_oob)) { |
| 2756 | ++j->read_wait; |
| 2757 | if (file_p->f_flags & O_NONBLOCK) { |
| 2758 | set_current_state(TASK_RUNNING); |
| 2759 | remove_wait_queue(&j->read_q, &wait); |
| 2760 | j->flags.inread = 0; |
| 2761 | return -EAGAIN; |
| 2762 | } |
| 2763 | if (!ixj_hookstate(j)) { |
| 2764 | set_current_state(TASK_RUNNING); |
| 2765 | remove_wait_queue(&j->read_q, &wait); |
| 2766 | j->flags.inread = 0; |
| 2767 | return 0; |
| 2768 | } |
| 2769 | interruptible_sleep_on(&j->read_q); |
| 2770 | if (signal_pending(current)) { |
| 2771 | set_current_state(TASK_RUNNING); |
| 2772 | remove_wait_queue(&j->read_q, &wait); |
| 2773 | j->flags.inread = 0; |
| 2774 | return -EINTR; |
| 2775 | } |
| 2776 | } |
| 2777 | |
| 2778 | remove_wait_queue(&j->read_q, &wait); |
| 2779 | set_current_state(TASK_RUNNING); |
| 2780 | /* Don't ever copy more than the user asks */ |
| 2781 | if(j->rec_codec == ALAW) |
| 2782 | ulaw2alaw(j->read_buffer, min(length, j->read_buffer_size)); |
| 2783 | i = copy_to_user(buf, j->read_buffer, min(length, j->read_buffer_size)); |
| 2784 | j->read_buffer_ready = 0; |
| 2785 | if (i) { |
| 2786 | j->flags.inread = 0; |
| 2787 | return -EFAULT; |
| 2788 | } else { |
| 2789 | j->flags.inread = 0; |
| 2790 | return min(length, j->read_buffer_size); |
| 2791 | } |
| 2792 | } |
| 2793 | |
| 2794 | static ssize_t ixj_enhanced_read(struct file * file_p, char __user *buf, size_t length, |
| 2795 | loff_t * ppos) |
| 2796 | { |
| 2797 | int pre_retval; |
| 2798 | ssize_t read_retval = 0; |
| 2799 | IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode)); |
| 2800 | |
| 2801 | pre_retval = ixj_PreRead(j, 0L); |
| 2802 | switch (pre_retval) { |
| 2803 | case NORMAL: |
| 2804 | read_retval = ixj_read(file_p, buf, length, ppos); |
| 2805 | ixj_PostRead(j, 0L); |
| 2806 | break; |
| 2807 | case NOPOST: |
| 2808 | read_retval = ixj_read(file_p, buf, length, ppos); |
| 2809 | break; |
| 2810 | case POSTONLY: |
| 2811 | ixj_PostRead(j, 0L); |
| 2812 | break; |
| 2813 | default: |
| 2814 | read_retval = pre_retval; |
| 2815 | } |
| 2816 | return read_retval; |
| 2817 | } |
| 2818 | |
| 2819 | static ssize_t ixj_write(struct file *file_p, const char __user *buf, size_t count, loff_t * ppos) |
| 2820 | { |
| 2821 | unsigned long i = *ppos; |
| 2822 | IXJ *j = file_p->private_data; |
| 2823 | |
| 2824 | DECLARE_WAITQUEUE(wait, current); |
| 2825 | |
| 2826 | if (j->flags.inwrite) |
| 2827 | return -EALREADY; |
| 2828 | |
| 2829 | j->flags.inwrite = 1; |
| 2830 | |
| 2831 | add_wait_queue(&j->write_q, &wait); |
| 2832 | set_current_state(TASK_INTERRUPTIBLE); |
| 2833 | mb(); |
| 2834 | |
| 2835 | |
| 2836 | while (!j->write_buffers_empty) { |
| 2837 | ++j->write_wait; |
| 2838 | if (file_p->f_flags & O_NONBLOCK) { |
| 2839 | set_current_state(TASK_RUNNING); |
| 2840 | remove_wait_queue(&j->write_q, &wait); |
| 2841 | j->flags.inwrite = 0; |
| 2842 | return -EAGAIN; |
| 2843 | } |
| 2844 | if (!ixj_hookstate(j)) { |
| 2845 | set_current_state(TASK_RUNNING); |
| 2846 | remove_wait_queue(&j->write_q, &wait); |
| 2847 | j->flags.inwrite = 0; |
| 2848 | return 0; |
| 2849 | } |
| 2850 | interruptible_sleep_on(&j->write_q); |
| 2851 | if (signal_pending(current)) { |
| 2852 | set_current_state(TASK_RUNNING); |
| 2853 | remove_wait_queue(&j->write_q, &wait); |
| 2854 | j->flags.inwrite = 0; |
| 2855 | return -EINTR; |
| 2856 | } |
| 2857 | } |
| 2858 | set_current_state(TASK_RUNNING); |
| 2859 | remove_wait_queue(&j->write_q, &wait); |
| 2860 | if (j->write_buffer_wp + count >= j->write_buffer_end) |
| 2861 | j->write_buffer_wp = j->write_buffer; |
| 2862 | i = copy_from_user(j->write_buffer_wp, buf, min(count, j->write_buffer_size)); |
| 2863 | if (i) { |
| 2864 | j->flags.inwrite = 0; |
| 2865 | return -EFAULT; |
| 2866 | } |
| 2867 | if(j->play_codec == ALAW) |
| 2868 | alaw2ulaw(j->write_buffer_wp, min(count, j->write_buffer_size)); |
| 2869 | j->flags.inwrite = 0; |
| 2870 | return min(count, j->write_buffer_size); |
| 2871 | } |
| 2872 | |
| 2873 | static ssize_t ixj_enhanced_write(struct file * file_p, const char __user *buf, size_t count, loff_t * ppos) |
| 2874 | { |
| 2875 | int pre_retval; |
| 2876 | ssize_t write_retval = 0; |
| 2877 | |
| 2878 | IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode)); |
| 2879 | |
| 2880 | pre_retval = ixj_PreWrite(j, 0L); |
| 2881 | switch (pre_retval) { |
| 2882 | case NORMAL: |
| 2883 | write_retval = ixj_write(file_p, buf, count, ppos); |
| 2884 | if (write_retval > 0) { |
| 2885 | ixj_PostWrite(j, 0L); |
| 2886 | j->write_buffer_wp += write_retval; |
| 2887 | j->write_buffers_empty--; |
| 2888 | } |
| 2889 | break; |
| 2890 | case NOPOST: |
| 2891 | write_retval = ixj_write(file_p, buf, count, ppos); |
| 2892 | if (write_retval > 0) { |
| 2893 | j->write_buffer_wp += write_retval; |
| 2894 | j->write_buffers_empty--; |
| 2895 | } |
| 2896 | break; |
| 2897 | case POSTONLY: |
| 2898 | ixj_PostWrite(j, 0L); |
| 2899 | break; |
| 2900 | default: |
| 2901 | write_retval = pre_retval; |
| 2902 | } |
| 2903 | return write_retval; |
| 2904 | } |
| 2905 | |
| 2906 | static void ixj_read_frame(IXJ *j) |
| 2907 | { |
| 2908 | int cnt, dly; |
| 2909 | |
| 2910 | if (j->read_buffer) { |
| 2911 | for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) { |
| 2912 | if (!(cnt % 16) && !IsRxReady(j)) { |
| 2913 | dly = 0; |
| 2914 | while (!IsRxReady(j)) { |
| 2915 | if (dly++ > 5) { |
| 2916 | dly = 0; |
| 2917 | break; |
| 2918 | } |
| 2919 | udelay(10); |
| 2920 | } |
| 2921 | } |
| 2922 | /* Throw away word 0 of the 8021 compressed format to get standard G.729. */ |
| 2923 | if (j->rec_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) { |
| 2924 | inb_p(j->DSPbase + 0x0E); |
| 2925 | inb_p(j->DSPbase + 0x0F); |
| 2926 | } |
| 2927 | *(j->read_buffer + cnt) = inb_p(j->DSPbase + 0x0E); |
| 2928 | *(j->read_buffer + cnt + 1) = inb_p(j->DSPbase + 0x0F); |
| 2929 | } |
| 2930 | ++j->framesread; |
| 2931 | if (j->intercom != -1) { |
| 2932 | if (IsTxReady(get_ixj(j->intercom))) { |
| 2933 | for (cnt = 0; cnt < j->rec_frame_size * 2; cnt += 2) { |
| 2934 | if (!(cnt % 16) && !IsTxReady(j)) { |
| 2935 | dly = 0; |
| 2936 | while (!IsTxReady(j)) { |
| 2937 | if (dly++ > 5) { |
| 2938 | dly = 0; |
| 2939 | break; |
| 2940 | } |
| 2941 | udelay(10); |
| 2942 | } |
| 2943 | } |
| 2944 | outb_p(*(j->read_buffer + cnt), get_ixj(j->intercom)->DSPbase + 0x0C); |
| 2945 | outb_p(*(j->read_buffer + cnt + 1), get_ixj(j->intercom)->DSPbase + 0x0D); |
| 2946 | } |
| 2947 | get_ixj(j->intercom)->frameswritten++; |
| 2948 | } |
| 2949 | } else { |
| 2950 | j->read_buffer_ready = 1; |
| 2951 | wake_up_interruptible(&j->read_q); /* Wake any blocked readers */ |
| 2952 | |
| 2953 | wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */ |
| 2954 | |
| 2955 | if(j->ixj_signals[SIG_READ_READY]) |
| 2956 | ixj_kill_fasync(j, SIG_READ_READY, POLL_OUT); |
| 2957 | } |
| 2958 | } |
| 2959 | } |
| 2960 | |
| 2961 | static short fsk[][6][20] = |
| 2962 | { |
| 2963 | { |
| 2964 | { |
| 2965 | 0, 17846, 29934, 32364, 24351, 8481, -10126, -25465, -32587, -29196, |
| 2966 | -16384, 1715, 19260, 30591, 32051, 23170, 6813, -11743, -26509, -32722 |
| 2967 | }, |
| 2968 | { |
| 2969 | -28377, -14876, 3425, 20621, 31163, 31650, 21925, 5126, -13328, -27481, |
| 2970 | -32767, -27481, -13328, 5126, 21925, 31650, 31163, 20621, 3425, -14876 |
| 2971 | }, |
| 2972 | { |
| 2973 | -28377, -32722, -26509, -11743, 6813, 23170, 32051, 30591, 19260, 1715, |
| 2974 | -16384, -29196, -32587, -25465, -10126, 8481, 24351, 32364, 29934, 17846 |
| 2975 | }, |
| 2976 | { |
| 2977 | 0, -17846, -29934, -32364, -24351, -8481, 10126, 25465, 32587, 29196, |
| 2978 | 16384, -1715, -19260, -30591, -32051, -23170, -6813, 11743, 26509, 32722 |
| 2979 | }, |
| 2980 | { |
| 2981 | 28377, 14876, -3425, -20621, -31163, -31650, -21925, -5126, 13328, 27481, |
| 2982 | 32767, 27481, 13328, -5126, -21925, -31650, -31163, -20621, -3425, 14876 |
| 2983 | }, |
| 2984 | { |
| 2985 | 28377, 32722, 26509, 11743, -6813, -23170, -32051, -30591, -19260, -1715, |
| 2986 | 16384, 29196, 32587, 25465, 10126, -8481, -24351, -32364, -29934, -17846 |
| 2987 | } |
| 2988 | }, |
| 2989 | { |
| 2990 | { |
| 2991 | 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126, |
| 2992 | 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126 |
| 2993 | }, |
| 2994 | { |
| 2995 | -28377, -21925, -13328, -3425, 6813, 16384, 24351, 29934, 32587, 32051, |
| 2996 | 28377, 21925, 13328, 3425, -6813, -16384, -24351, -29934, -32587, -32051 |
| 2997 | }, |
| 2998 | { |
| 2999 | -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925, |
| 3000 | 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925 |
| 3001 | }, |
| 3002 | { |
| 3003 | 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126, |
| 3004 | 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126 |
| 3005 | }, |
| 3006 | { |
| 3007 | 28377, 21925, 13328, 3425, -6813, -16383, -24351, -29934, -32587, -32051, |
| 3008 | -28377, -21925, -13328, -3425, 6813, 16383, 24351, 29934, 32587, 32051 |
| 3009 | }, |
| 3010 | { |
| 3011 | 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925, |
| 3012 | -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925 |
| 3013 | } |
| 3014 | } |
| 3015 | }; |
| 3016 | |
| 3017 | |
| 3018 | static void ixj_write_cid_bit(IXJ *j, int bit) |
| 3019 | { |
| 3020 | while (j->fskcnt < 20) { |
| 3021 | if(j->fskdcnt < (j->fsksize - 1)) |
| 3022 | j->fskdata[j->fskdcnt++] = fsk[bit][j->fskz][j->fskcnt]; |
| 3023 | |
| 3024 | j->fskcnt += 3; |
| 3025 | } |
| 3026 | j->fskcnt %= 20; |
| 3027 | |
| 3028 | if (!bit) |
| 3029 | j->fskz++; |
| 3030 | if (j->fskz >= 6) |
| 3031 | j->fskz = 0; |
| 3032 | |
| 3033 | } |
| 3034 | |
| 3035 | static void ixj_write_cid_byte(IXJ *j, char byte) |
| 3036 | { |
| 3037 | IXJ_CBYTE cb; |
| 3038 | |
| 3039 | cb.cbyte = byte; |
| 3040 | ixj_write_cid_bit(j, 0); |
| 3041 | ixj_write_cid_bit(j, cb.cbits.b0 ? 1 : 0); |
| 3042 | ixj_write_cid_bit(j, cb.cbits.b1 ? 1 : 0); |
| 3043 | ixj_write_cid_bit(j, cb.cbits.b2 ? 1 : 0); |
| 3044 | ixj_write_cid_bit(j, cb.cbits.b3 ? 1 : 0); |
| 3045 | ixj_write_cid_bit(j, cb.cbits.b4 ? 1 : 0); |
| 3046 | ixj_write_cid_bit(j, cb.cbits.b5 ? 1 : 0); |
| 3047 | ixj_write_cid_bit(j, cb.cbits.b6 ? 1 : 0); |
| 3048 | ixj_write_cid_bit(j, cb.cbits.b7 ? 1 : 0); |
| 3049 | ixj_write_cid_bit(j, 1); |
| 3050 | } |
| 3051 | |
| 3052 | static void ixj_write_cid_seize(IXJ *j) |
| 3053 | { |
| 3054 | int cnt; |
| 3055 | |
| 3056 | for (cnt = 0; cnt < 150; cnt++) { |
| 3057 | ixj_write_cid_bit(j, 0); |
| 3058 | ixj_write_cid_bit(j, 1); |
| 3059 | } |
| 3060 | for (cnt = 0; cnt < 180; cnt++) { |
| 3061 | ixj_write_cid_bit(j, 1); |
| 3062 | } |
| 3063 | } |
| 3064 | |
| 3065 | static void ixj_write_cidcw_seize(IXJ *j) |
| 3066 | { |
| 3067 | int cnt; |
| 3068 | |
| 3069 | for (cnt = 0; cnt < 80; cnt++) { |
| 3070 | ixj_write_cid_bit(j, 1); |
| 3071 | } |
| 3072 | } |
| 3073 | |
| 3074 | static int ixj_write_cid_string(IXJ *j, char *s, int checksum) |
| 3075 | { |
| 3076 | int cnt; |
| 3077 | |
| 3078 | for (cnt = 0; cnt < strlen(s); cnt++) { |
| 3079 | ixj_write_cid_byte(j, s[cnt]); |
| 3080 | checksum = (checksum + s[cnt]); |
| 3081 | } |
| 3082 | return checksum; |
| 3083 | } |
| 3084 | |
| 3085 | static void ixj_pad_fsk(IXJ *j, int pad) |
| 3086 | { |
| 3087 | int cnt; |
| 3088 | |
| 3089 | for (cnt = 0; cnt < pad; cnt++) { |
| 3090 | if(j->fskdcnt < (j->fsksize - 1)) |
| 3091 | j->fskdata[j->fskdcnt++] = 0x0000; |
| 3092 | } |
| 3093 | for (cnt = 0; cnt < 720; cnt++) { |
| 3094 | if(j->fskdcnt < (j->fsksize - 1)) |
| 3095 | j->fskdata[j->fskdcnt++] = 0x0000; |
| 3096 | } |
| 3097 | } |
| 3098 | |
| 3099 | static void ixj_pre_cid(IXJ *j) |
| 3100 | { |
| 3101 | j->cid_play_codec = j->play_codec; |
| 3102 | j->cid_play_frame_size = j->play_frame_size; |
| 3103 | j->cid_play_volume = get_play_volume(j); |
| 3104 | j->cid_play_flag = j->flags.playing; |
| 3105 | |
| 3106 | j->cid_rec_codec = j->rec_codec; |
| 3107 | j->cid_rec_volume = get_rec_volume(j); |
| 3108 | j->cid_rec_flag = j->flags.recording; |
| 3109 | |
| 3110 | j->cid_play_aec_level = j->aec_level; |
| 3111 | |
| 3112 | switch(j->baseframe.low) { |
| 3113 | case 0xA0: |
| 3114 | j->cid_base_frame_size = 20; |
| 3115 | break; |
| 3116 | case 0x50: |
| 3117 | j->cid_base_frame_size = 10; |
| 3118 | break; |
| 3119 | case 0xF0: |
| 3120 | j->cid_base_frame_size = 30; |
| 3121 | break; |
| 3122 | } |
| 3123 | |
| 3124 | ixj_play_stop(j); |
| 3125 | ixj_cpt_stop(j); |
| 3126 | |
| 3127 | j->flags.cidplay = 1; |
| 3128 | |
| 3129 | set_base_frame(j, 30); |
| 3130 | set_play_codec(j, LINEAR16); |
| 3131 | set_play_volume(j, 0x1B); |
| 3132 | ixj_play_start(j); |
| 3133 | } |
| 3134 | |
| 3135 | static void ixj_post_cid(IXJ *j) |
| 3136 | { |
| 3137 | ixj_play_stop(j); |
| 3138 | |
| 3139 | if(j->cidsize > 5000) { |
| 3140 | SLIC_SetState(PLD_SLIC_STATE_STANDBY, j); |
| 3141 | } |
| 3142 | j->flags.cidplay = 0; |
| 3143 | if(ixjdebug & 0x0200) { |
| 3144 | printk("IXJ phone%d Finished Playing CallerID data %ld\n", j->board, jiffies); |
| 3145 | } |
| 3146 | |
| 3147 | ixj_fsk_free(j); |
| 3148 | |
| 3149 | j->fskdcnt = 0; |
| 3150 | set_base_frame(j, j->cid_base_frame_size); |
| 3151 | set_play_codec(j, j->cid_play_codec); |
| 3152 | ixj_aec_start(j, j->cid_play_aec_level); |
| 3153 | set_play_volume(j, j->cid_play_volume); |
| 3154 | |
| 3155 | set_rec_codec(j, j->cid_rec_codec); |
| 3156 | set_rec_volume(j, j->cid_rec_volume); |
| 3157 | |
| 3158 | if(j->cid_rec_flag) |
| 3159 | ixj_record_start(j); |
| 3160 | |
| 3161 | if(j->cid_play_flag) |
| 3162 | ixj_play_start(j); |
| 3163 | |
| 3164 | if(j->cid_play_flag) { |
| 3165 | wake_up_interruptible(&j->write_q); /* Wake any blocked writers */ |
| 3166 | } |
| 3167 | } |
| 3168 | |
| 3169 | static void ixj_write_cid(IXJ *j) |
| 3170 | { |
| 3171 | char sdmf1[50]; |
| 3172 | char sdmf2[50]; |
| 3173 | char sdmf3[80]; |
| 3174 | char mdmflen, len1, len2, len3; |
| 3175 | int pad; |
| 3176 | |
| 3177 | int checksum = 0; |
| 3178 | |
| 3179 | if (j->dsp.low == 0x20 || j->flags.cidplay) |
| 3180 | return; |
| 3181 | |
| 3182 | j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0; |
| 3183 | j->cidsize = j->cidcnt = 0; |
| 3184 | |
| 3185 | ixj_fsk_alloc(j); |
| 3186 | |
| 3187 | strcpy(sdmf1, j->cid_send.month); |
| 3188 | strcat(sdmf1, j->cid_send.day); |
| 3189 | strcat(sdmf1, j->cid_send.hour); |
| 3190 | strcat(sdmf1, j->cid_send.min); |
| 3191 | strcpy(sdmf2, j->cid_send.number); |
| 3192 | strcpy(sdmf3, j->cid_send.name); |
| 3193 | |
| 3194 | len1 = strlen(sdmf1); |
| 3195 | len2 = strlen(sdmf2); |
| 3196 | len3 = strlen(sdmf3); |
| 3197 | mdmflen = len1 + len2 + len3 + 6; |
| 3198 | |
| 3199 | while(1){ |
| 3200 | ixj_write_cid_seize(j); |
| 3201 | |
| 3202 | ixj_write_cid_byte(j, 0x80); |
| 3203 | checksum = 0x80; |
| 3204 | ixj_write_cid_byte(j, mdmflen); |
| 3205 | checksum = checksum + mdmflen; |
| 3206 | |
| 3207 | ixj_write_cid_byte(j, 0x01); |
| 3208 | checksum = checksum + 0x01; |
| 3209 | ixj_write_cid_byte(j, len1); |
| 3210 | checksum = checksum + len1; |
| 3211 | checksum = ixj_write_cid_string(j, sdmf1, checksum); |
| 3212 | if(ixj_hookstate(j) & 1) |
| 3213 | break; |
| 3214 | |
| 3215 | ixj_write_cid_byte(j, 0x02); |
| 3216 | checksum = checksum + 0x02; |
| 3217 | ixj_write_cid_byte(j, len2); |
| 3218 | checksum = checksum + len2; |
| 3219 | checksum = ixj_write_cid_string(j, sdmf2, checksum); |
| 3220 | if(ixj_hookstate(j) & 1) |
| 3221 | break; |
| 3222 | |
| 3223 | ixj_write_cid_byte(j, 0x07); |
| 3224 | checksum = checksum + 0x07; |
| 3225 | ixj_write_cid_byte(j, len3); |
| 3226 | checksum = checksum + len3; |
| 3227 | checksum = ixj_write_cid_string(j, sdmf3, checksum); |
| 3228 | if(ixj_hookstate(j) & 1) |
| 3229 | break; |
| 3230 | |
| 3231 | checksum %= 256; |
| 3232 | checksum ^= 0xFF; |
| 3233 | checksum += 1; |
| 3234 | |
| 3235 | ixj_write_cid_byte(j, (char) checksum); |
| 3236 | |
| 3237 | pad = j->fskdcnt % 240; |
| 3238 | if (pad) { |
| 3239 | pad = 240 - pad; |
| 3240 | } |
| 3241 | ixj_pad_fsk(j, pad); |
| 3242 | break; |
| 3243 | } |
| 3244 | |
| 3245 | ixj_write_frame(j); |
| 3246 | } |
| 3247 | |
| 3248 | static void ixj_write_cidcw(IXJ *j) |
| 3249 | { |
| 3250 | IXJ_TONE ti; |
| 3251 | |
| 3252 | char sdmf1[50]; |
| 3253 | char sdmf2[50]; |
| 3254 | char sdmf3[80]; |
| 3255 | char mdmflen, len1, len2, len3; |
| 3256 | int pad; |
| 3257 | |
| 3258 | int checksum = 0; |
| 3259 | |
| 3260 | if (j->dsp.low == 0x20 || j->flags.cidplay) |
| 3261 | return; |
| 3262 | |
| 3263 | j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0; |
| 3264 | j->cidsize = j->cidcnt = 0; |
| 3265 | |
| 3266 | ixj_fsk_alloc(j); |
| 3267 | |
| 3268 | j->flags.cidcw_ack = 0; |
| 3269 | |
| 3270 | ti.tone_index = 23; |
| 3271 | ti.gain0 = 1; |
| 3272 | ti.freq0 = hz440; |
| 3273 | ti.gain1 = 0; |
| 3274 | ti.freq1 = 0; |
| 3275 | ixj_init_tone(j, &ti); |
| 3276 | |
| 3277 | ixj_set_tone_on(1500, j); |
| 3278 | ixj_set_tone_off(32, j); |
| 3279 | if(ixjdebug & 0x0200) { |
| 3280 | printk("IXJ cidcw phone%d first tone start at %ld\n", j->board, jiffies); |
| 3281 | } |
| 3282 | ixj_play_tone(j, 23); |
| 3283 | |
| 3284 | clear_bit(j->board, &j->busyflags); |
Nishanth Aravamudan | 1e63bc7 | 2005-09-10 00:27:31 -0700 | [diff] [blame] | 3285 | while(j->tone_state) |
| 3286 | schedule_timeout_interruptible(1); |
| 3287 | while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) |
| 3288 | schedule_timeout_interruptible(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3289 | if(ixjdebug & 0x0200) { |
| 3290 | printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies); |
| 3291 | } |
| 3292 | |
| 3293 | ti.tone_index = 24; |
| 3294 | ti.gain0 = 1; |
| 3295 | ti.freq0 = hz2130; |
| 3296 | ti.gain1 = 0; |
| 3297 | ti.freq1 = hz2750; |
| 3298 | ixj_init_tone(j, &ti); |
| 3299 | |
| 3300 | ixj_set_tone_off(10, j); |
| 3301 | ixj_set_tone_on(600, j); |
| 3302 | if(ixjdebug & 0x0200) { |
| 3303 | printk("IXJ cidcw phone%d second tone start at %ld\n", j->board, jiffies); |
| 3304 | } |
| 3305 | ixj_play_tone(j, 24); |
| 3306 | |
| 3307 | clear_bit(j->board, &j->busyflags); |
Nishanth Aravamudan | 1e63bc7 | 2005-09-10 00:27:31 -0700 | [diff] [blame] | 3308 | while(j->tone_state) |
| 3309 | schedule_timeout_interruptible(1); |
| 3310 | while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) |
| 3311 | schedule_timeout_interruptible(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3312 | if(ixjdebug & 0x0200) { |
| 3313 | printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies); |
| 3314 | } |
| 3315 | |
| 3316 | j->cidcw_wait = jiffies + ((50 * hertz) / 100); |
| 3317 | |
| 3318 | clear_bit(j->board, &j->busyflags); |
Nishanth Aravamudan | 1e63bc7 | 2005-09-10 00:27:31 -0700 | [diff] [blame] | 3319 | while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait)) |
| 3320 | schedule_timeout_interruptible(1); |
| 3321 | while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) |
| 3322 | schedule_timeout_interruptible(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3323 | j->cidcw_wait = 0; |
| 3324 | if(!j->flags.cidcw_ack) { |
| 3325 | if(ixjdebug & 0x0200) { |
| 3326 | printk("IXJ cidcw phone%d did not receive ACK from display %ld\n", j->board, jiffies); |
| 3327 | } |
| 3328 | ixj_post_cid(j); |
| 3329 | if(j->cid_play_flag) { |
| 3330 | wake_up_interruptible(&j->write_q); /* Wake any blocked readers */ |
| 3331 | } |
| 3332 | return; |
| 3333 | } else { |
| 3334 | ixj_pre_cid(j); |
| 3335 | } |
| 3336 | j->flags.cidcw_ack = 0; |
| 3337 | strcpy(sdmf1, j->cid_send.month); |
| 3338 | strcat(sdmf1, j->cid_send.day); |
| 3339 | strcat(sdmf1, j->cid_send.hour); |
| 3340 | strcat(sdmf1, j->cid_send.min); |
| 3341 | strcpy(sdmf2, j->cid_send.number); |
| 3342 | strcpy(sdmf3, j->cid_send.name); |
| 3343 | |
| 3344 | len1 = strlen(sdmf1); |
| 3345 | len2 = strlen(sdmf2); |
| 3346 | len3 = strlen(sdmf3); |
| 3347 | mdmflen = len1 + len2 + len3 + 6; |
| 3348 | |
| 3349 | ixj_write_cidcw_seize(j); |
| 3350 | |
| 3351 | ixj_write_cid_byte(j, 0x80); |
| 3352 | checksum = 0x80; |
| 3353 | ixj_write_cid_byte(j, mdmflen); |
| 3354 | checksum = checksum + mdmflen; |
| 3355 | |
| 3356 | ixj_write_cid_byte(j, 0x01); |
| 3357 | checksum = checksum + 0x01; |
| 3358 | ixj_write_cid_byte(j, len1); |
| 3359 | checksum = checksum + len1; |
| 3360 | checksum = ixj_write_cid_string(j, sdmf1, checksum); |
| 3361 | |
| 3362 | ixj_write_cid_byte(j, 0x02); |
| 3363 | checksum = checksum + 0x02; |
| 3364 | ixj_write_cid_byte(j, len2); |
| 3365 | checksum = checksum + len2; |
| 3366 | checksum = ixj_write_cid_string(j, sdmf2, checksum); |
| 3367 | |
| 3368 | ixj_write_cid_byte(j, 0x07); |
| 3369 | checksum = checksum + 0x07; |
| 3370 | ixj_write_cid_byte(j, len3); |
| 3371 | checksum = checksum + len3; |
| 3372 | checksum = ixj_write_cid_string(j, sdmf3, checksum); |
| 3373 | |
| 3374 | checksum %= 256; |
| 3375 | checksum ^= 0xFF; |
| 3376 | checksum += 1; |
| 3377 | |
| 3378 | ixj_write_cid_byte(j, (char) checksum); |
| 3379 | |
| 3380 | pad = j->fskdcnt % 240; |
| 3381 | if (pad) { |
| 3382 | pad = 240 - pad; |
| 3383 | } |
| 3384 | ixj_pad_fsk(j, pad); |
| 3385 | if(ixjdebug & 0x0200) { |
| 3386 | printk("IXJ cidcw phone%d sent FSK data at %ld\n", j->board, jiffies); |
| 3387 | } |
| 3388 | } |
| 3389 | |
| 3390 | static void ixj_write_vmwi(IXJ *j, int msg) |
| 3391 | { |
| 3392 | char mdmflen; |
| 3393 | int pad; |
| 3394 | |
| 3395 | int checksum = 0; |
| 3396 | |
| 3397 | if (j->dsp.low == 0x20 || j->flags.cidplay) |
| 3398 | return; |
| 3399 | |
| 3400 | j->fskz = j->fskphase = j->fskcnt = j->fskdcnt = 0; |
| 3401 | j->cidsize = j->cidcnt = 0; |
| 3402 | |
| 3403 | ixj_fsk_alloc(j); |
| 3404 | |
| 3405 | mdmflen = 3; |
| 3406 | |
| 3407 | if (j->port == PORT_POTS) |
| 3408 | SLIC_SetState(PLD_SLIC_STATE_OHT, j); |
| 3409 | |
| 3410 | ixj_write_cid_seize(j); |
| 3411 | |
| 3412 | ixj_write_cid_byte(j, 0x82); |
| 3413 | checksum = 0x82; |
| 3414 | ixj_write_cid_byte(j, mdmflen); |
| 3415 | checksum = checksum + mdmflen; |
| 3416 | |
| 3417 | ixj_write_cid_byte(j, 0x0B); |
| 3418 | checksum = checksum + 0x0B; |
| 3419 | ixj_write_cid_byte(j, 1); |
| 3420 | checksum = checksum + 1; |
| 3421 | |
| 3422 | if(msg) { |
| 3423 | ixj_write_cid_byte(j, 0xFF); |
| 3424 | checksum = checksum + 0xFF; |
| 3425 | } |
| 3426 | else { |
| 3427 | ixj_write_cid_byte(j, 0x00); |
| 3428 | checksum = checksum + 0x00; |
| 3429 | } |
| 3430 | |
| 3431 | checksum %= 256; |
| 3432 | checksum ^= 0xFF; |
| 3433 | checksum += 1; |
| 3434 | |
| 3435 | ixj_write_cid_byte(j, (char) checksum); |
| 3436 | |
| 3437 | pad = j->fskdcnt % 240; |
| 3438 | if (pad) { |
| 3439 | pad = 240 - pad; |
| 3440 | } |
| 3441 | ixj_pad_fsk(j, pad); |
| 3442 | } |
| 3443 | |
| 3444 | static void ixj_write_frame(IXJ *j) |
| 3445 | { |
| 3446 | int cnt, frame_count, dly; |
| 3447 | IXJ_WORD dat; |
| 3448 | BYTES blankword; |
| 3449 | |
| 3450 | frame_count = 0; |
| 3451 | if(j->flags.cidplay) { |
| 3452 | for(cnt = 0; cnt < 480; cnt++) { |
| 3453 | if (!(cnt % 16) && !IsTxReady(j)) { |
| 3454 | dly = 0; |
| 3455 | while (!IsTxReady(j)) { |
| 3456 | if (dly++ > 5) { |
| 3457 | dly = 0; |
| 3458 | break; |
| 3459 | } |
| 3460 | udelay(10); |
| 3461 | } |
| 3462 | } |
| 3463 | dat.word = j->fskdata[j->cidcnt++]; |
| 3464 | outb_p(dat.bytes.low, j->DSPbase + 0x0C); |
| 3465 | outb_p(dat.bytes.high, j->DSPbase + 0x0D); |
| 3466 | cnt++; |
| 3467 | } |
| 3468 | if(j->cidcnt >= j->fskdcnt) { |
| 3469 | ixj_post_cid(j); |
| 3470 | } |
| 3471 | /* This may seem rude, but if we just played one frame of FSK data for CallerID |
| 3472 | and there is real audio data in the buffer, we need to throw it away because |
| 3473 | we just used it's time slot */ |
| 3474 | if (j->write_buffer_rp > j->write_buffer_wp) { |
| 3475 | j->write_buffer_rp += j->cid_play_frame_size * 2; |
| 3476 | if (j->write_buffer_rp >= j->write_buffer_end) { |
| 3477 | j->write_buffer_rp = j->write_buffer; |
| 3478 | } |
| 3479 | j->write_buffers_empty++; |
| 3480 | wake_up_interruptible(&j->write_q); /* Wake any blocked writers */ |
| 3481 | |
| 3482 | wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */ |
| 3483 | } |
| 3484 | } else if (j->write_buffer && j->write_buffers_empty < 1) { |
| 3485 | if (j->write_buffer_wp > j->write_buffer_rp) { |
| 3486 | frame_count = |
| 3487 | (j->write_buffer_wp - j->write_buffer_rp) / (j->play_frame_size * 2); |
| 3488 | } |
| 3489 | if (j->write_buffer_rp > j->write_buffer_wp) { |
| 3490 | frame_count = |
| 3491 | (j->write_buffer_wp - j->write_buffer) / (j->play_frame_size * 2) + |
| 3492 | (j->write_buffer_end - j->write_buffer_rp) / (j->play_frame_size * 2); |
| 3493 | } |
| 3494 | if (frame_count >= 1) { |
| 3495 | if (j->ver.low == 0x12 && j->play_mode && j->flags.play_first_frame) { |
| 3496 | switch (j->play_mode) { |
| 3497 | case PLAYBACK_MODE_ULAW: |
| 3498 | case PLAYBACK_MODE_ALAW: |
| 3499 | blankword.low = blankword.high = 0xFF; |
| 3500 | break; |
| 3501 | case PLAYBACK_MODE_8LINEAR: |
| 3502 | case PLAYBACK_MODE_16LINEAR: |
| 3503 | blankword.low = blankword.high = 0x00; |
| 3504 | break; |
| 3505 | case PLAYBACK_MODE_8LINEAR_WSS: |
| 3506 | blankword.low = blankword.high = 0x80; |
| 3507 | break; |
| 3508 | } |
| 3509 | for (cnt = 0; cnt < 16; cnt++) { |
| 3510 | if (!(cnt % 16) && !IsTxReady(j)) { |
| 3511 | dly = 0; |
| 3512 | while (!IsTxReady(j)) { |
| 3513 | if (dly++ > 5) { |
| 3514 | dly = 0; |
| 3515 | break; |
| 3516 | } |
| 3517 | udelay(10); |
| 3518 | } |
| 3519 | } |
| 3520 | outb_p((blankword.low), j->DSPbase + 0x0C); |
| 3521 | outb_p((blankword.high), j->DSPbase + 0x0D); |
| 3522 | } |
| 3523 | j->flags.play_first_frame = 0; |
| 3524 | } else if (j->play_codec == G723_63 && j->flags.play_first_frame) { |
| 3525 | for (cnt = 0; cnt < 24; cnt++) { |
| 3526 | if(cnt == 12) { |
| 3527 | blankword.low = 0x02; |
| 3528 | blankword.high = 0x00; |
| 3529 | } |
| 3530 | else { |
| 3531 | blankword.low = blankword.high = 0x00; |
| 3532 | } |
| 3533 | if (!(cnt % 16) && !IsTxReady(j)) { |
| 3534 | dly = 0; |
| 3535 | while (!IsTxReady(j)) { |
| 3536 | if (dly++ > 5) { |
| 3537 | dly = 0; |
| 3538 | break; |
| 3539 | } |
| 3540 | udelay(10); |
| 3541 | } |
| 3542 | } |
| 3543 | outb_p((blankword.low), j->DSPbase + 0x0C); |
| 3544 | outb_p((blankword.high), j->DSPbase + 0x0D); |
| 3545 | } |
| 3546 | j->flags.play_first_frame = 0; |
| 3547 | } |
| 3548 | for (cnt = 0; cnt < j->play_frame_size * 2; cnt += 2) { |
| 3549 | if (!(cnt % 16) && !IsTxReady(j)) { |
| 3550 | dly = 0; |
| 3551 | while (!IsTxReady(j)) { |
| 3552 | if (dly++ > 5) { |
| 3553 | dly = 0; |
| 3554 | break; |
| 3555 | } |
| 3556 | udelay(10); |
| 3557 | } |
| 3558 | } |
| 3559 | /* Add word 0 to G.729 frames for the 8021. Right now we don't do VAD/CNG */ |
| 3560 | if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) { |
| 3561 | if(j->write_buffer_rp + cnt == 0 && j->write_buffer_rp + cnt + 1 == 0 && j->write_buffer_rp + cnt + 2 == 0 && |
| 3562 | j->write_buffer_rp + cnt + 3 == 0 && j->write_buffer_rp + cnt + 4 == 0 && j->write_buffer_rp + cnt + 5 == 0 && |
| 3563 | j->write_buffer_rp + cnt + 6 == 0 && j->write_buffer_rp + cnt + 7 == 0 && j->write_buffer_rp + cnt + 8 == 0 && |
| 3564 | j->write_buffer_rp + cnt + 9 == 0) { |
| 3565 | /* someone is trying to write silence lets make this a type 0 frame. */ |
| 3566 | outb_p(0x00, j->DSPbase + 0x0C); |
| 3567 | outb_p(0x00, j->DSPbase + 0x0D); |
| 3568 | } else { |
| 3569 | /* so all other frames are type 1. */ |
| 3570 | outb_p(0x01, j->DSPbase + 0x0C); |
| 3571 | outb_p(0x00, j->DSPbase + 0x0D); |
| 3572 | } |
| 3573 | } |
| 3574 | outb_p(*(j->write_buffer_rp + cnt), j->DSPbase + 0x0C); |
| 3575 | outb_p(*(j->write_buffer_rp + cnt + 1), j->DSPbase + 0x0D); |
| 3576 | *(j->write_buffer_rp + cnt) = 0; |
| 3577 | *(j->write_buffer_rp + cnt + 1) = 0; |
| 3578 | } |
| 3579 | j->write_buffer_rp += j->play_frame_size * 2; |
| 3580 | if (j->write_buffer_rp >= j->write_buffer_end) { |
| 3581 | j->write_buffer_rp = j->write_buffer; |
| 3582 | } |
| 3583 | j->write_buffers_empty++; |
| 3584 | wake_up_interruptible(&j->write_q); /* Wake any blocked writers */ |
| 3585 | |
| 3586 | wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */ |
| 3587 | |
| 3588 | ++j->frameswritten; |
| 3589 | } |
| 3590 | } else { |
| 3591 | j->drybuffer++; |
| 3592 | } |
| 3593 | if(j->ixj_signals[SIG_WRITE_READY]) { |
| 3594 | ixj_kill_fasync(j, SIG_WRITE_READY, POLL_OUT); |
| 3595 | } |
| 3596 | } |
| 3597 | |
| 3598 | static int idle(IXJ *j) |
| 3599 | { |
| 3600 | if (ixj_WriteDSPCommand(0x0000, j)) /* DSP Idle */ |
| 3601 | |
| 3602 | return 0; |
| 3603 | |
| 3604 | if (j->ssr.high || j->ssr.low) { |
| 3605 | return 0; |
| 3606 | } else { |
| 3607 | j->play_mode = -1; |
| 3608 | j->flags.playing = 0; |
| 3609 | j->rec_mode = -1; |
| 3610 | j->flags.recording = 0; |
| 3611 | return 1; |
| 3612 | } |
| 3613 | } |
| 3614 | |
| 3615 | static int set_base_frame(IXJ *j, int size) |
| 3616 | { |
| 3617 | unsigned short cmd; |
| 3618 | int cnt; |
| 3619 | |
| 3620 | idle(j); |
| 3621 | j->cid_play_aec_level = j->aec_level; |
| 3622 | aec_stop(j); |
| 3623 | for (cnt = 0; cnt < 10; cnt++) { |
| 3624 | if (idle(j)) |
| 3625 | break; |
| 3626 | } |
| 3627 | if (j->ssr.high || j->ssr.low) |
| 3628 | return -1; |
| 3629 | if (j->dsp.low != 0x20) { |
| 3630 | switch (size) { |
| 3631 | case 30: |
| 3632 | cmd = 0x07F0; |
| 3633 | /* Set Base Frame Size to 240 pg9-10 8021 */ |
| 3634 | break; |
| 3635 | case 20: |
| 3636 | cmd = 0x07A0; |
| 3637 | /* Set Base Frame Size to 160 pg9-10 8021 */ |
| 3638 | break; |
| 3639 | case 10: |
| 3640 | cmd = 0x0750; |
| 3641 | /* Set Base Frame Size to 80 pg9-10 8021 */ |
| 3642 | break; |
| 3643 | default: |
| 3644 | return -1; |
| 3645 | } |
| 3646 | } else { |
| 3647 | if (size == 30) |
| 3648 | return size; |
| 3649 | else |
| 3650 | return -1; |
| 3651 | } |
| 3652 | if (ixj_WriteDSPCommand(cmd, j)) { |
| 3653 | j->baseframe.high = j->baseframe.low = 0xFF; |
| 3654 | return -1; |
| 3655 | } else { |
| 3656 | j->baseframe.high = j->ssr.high; |
| 3657 | j->baseframe.low = j->ssr.low; |
| 3658 | /* If the status returned is 0x0000 (pg9-9 8021) the call failed */ |
| 3659 | if(j->baseframe.high == 0x00 && j->baseframe.low == 0x00) { |
| 3660 | return -1; |
| 3661 | } |
| 3662 | } |
| 3663 | ixj_aec_start(j, j->cid_play_aec_level); |
| 3664 | return size; |
| 3665 | } |
| 3666 | |
| 3667 | static int set_rec_codec(IXJ *j, int rate) |
| 3668 | { |
| 3669 | int retval = 0; |
| 3670 | |
| 3671 | j->rec_codec = rate; |
| 3672 | |
| 3673 | switch (rate) { |
| 3674 | case G723_63: |
| 3675 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 3676 | j->rec_frame_size = 12; |
| 3677 | j->rec_mode = 0; |
| 3678 | } else { |
| 3679 | retval = 1; |
| 3680 | } |
| 3681 | break; |
| 3682 | case G723_53: |
| 3683 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 3684 | j->rec_frame_size = 10; |
| 3685 | j->rec_mode = 0; |
| 3686 | } else { |
| 3687 | retval = 1; |
| 3688 | } |
| 3689 | break; |
| 3690 | case TS85: |
| 3691 | if (j->dsp.low == 0x20 || j->flags.ts85_loaded) { |
| 3692 | j->rec_frame_size = 16; |
| 3693 | j->rec_mode = 0; |
| 3694 | } else { |
| 3695 | retval = 1; |
| 3696 | } |
| 3697 | break; |
| 3698 | case TS48: |
| 3699 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 3700 | j->rec_frame_size = 9; |
| 3701 | j->rec_mode = 0; |
| 3702 | } else { |
| 3703 | retval = 1; |
| 3704 | } |
| 3705 | break; |
| 3706 | case TS41: |
| 3707 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 3708 | j->rec_frame_size = 8; |
| 3709 | j->rec_mode = 0; |
| 3710 | } else { |
| 3711 | retval = 1; |
| 3712 | } |
| 3713 | break; |
| 3714 | case G728: |
| 3715 | if (j->dsp.low != 0x20) { |
| 3716 | j->rec_frame_size = 48; |
| 3717 | j->rec_mode = 0; |
| 3718 | } else { |
| 3719 | retval = 1; |
| 3720 | } |
| 3721 | break; |
| 3722 | case G729: |
| 3723 | if (j->dsp.low != 0x20) { |
| 3724 | if (!j->flags.g729_loaded) { |
| 3725 | retval = 1; |
| 3726 | break; |
| 3727 | } |
| 3728 | switch (j->baseframe.low) { |
| 3729 | case 0xA0: |
| 3730 | j->rec_frame_size = 10; |
| 3731 | break; |
| 3732 | case 0x50: |
| 3733 | j->rec_frame_size = 5; |
| 3734 | break; |
| 3735 | default: |
| 3736 | j->rec_frame_size = 15; |
| 3737 | break; |
| 3738 | } |
| 3739 | j->rec_mode = 0; |
| 3740 | } else { |
| 3741 | retval = 1; |
| 3742 | } |
| 3743 | break; |
| 3744 | case G729B: |
| 3745 | if (j->dsp.low != 0x20) { |
| 3746 | if (!j->flags.g729_loaded) { |
| 3747 | retval = 1; |
| 3748 | break; |
| 3749 | } |
| 3750 | switch (j->baseframe.low) { |
| 3751 | case 0xA0: |
| 3752 | j->rec_frame_size = 12; |
| 3753 | break; |
| 3754 | case 0x50: |
| 3755 | j->rec_frame_size = 6; |
| 3756 | break; |
| 3757 | default: |
| 3758 | j->rec_frame_size = 18; |
| 3759 | break; |
| 3760 | } |
| 3761 | j->rec_mode = 0; |
| 3762 | } else { |
| 3763 | retval = 1; |
| 3764 | } |
| 3765 | break; |
| 3766 | case ULAW: |
| 3767 | switch (j->baseframe.low) { |
| 3768 | case 0xA0: |
| 3769 | j->rec_frame_size = 80; |
| 3770 | break; |
| 3771 | case 0x50: |
| 3772 | j->rec_frame_size = 40; |
| 3773 | break; |
| 3774 | default: |
| 3775 | j->rec_frame_size = 120; |
| 3776 | break; |
| 3777 | } |
| 3778 | j->rec_mode = 4; |
| 3779 | break; |
| 3780 | case ALAW: |
| 3781 | switch (j->baseframe.low) { |
| 3782 | case 0xA0: |
| 3783 | j->rec_frame_size = 80; |
| 3784 | break; |
| 3785 | case 0x50: |
| 3786 | j->rec_frame_size = 40; |
| 3787 | break; |
| 3788 | default: |
| 3789 | j->rec_frame_size = 120; |
| 3790 | break; |
| 3791 | } |
| 3792 | j->rec_mode = 4; |
| 3793 | break; |
| 3794 | case LINEAR16: |
| 3795 | switch (j->baseframe.low) { |
| 3796 | case 0xA0: |
| 3797 | j->rec_frame_size = 160; |
| 3798 | break; |
| 3799 | case 0x50: |
| 3800 | j->rec_frame_size = 80; |
| 3801 | break; |
| 3802 | default: |
| 3803 | j->rec_frame_size = 240; |
| 3804 | break; |
| 3805 | } |
| 3806 | j->rec_mode = 5; |
| 3807 | break; |
| 3808 | case LINEAR8: |
| 3809 | switch (j->baseframe.low) { |
| 3810 | case 0xA0: |
| 3811 | j->rec_frame_size = 80; |
| 3812 | break; |
| 3813 | case 0x50: |
| 3814 | j->rec_frame_size = 40; |
| 3815 | break; |
| 3816 | default: |
| 3817 | j->rec_frame_size = 120; |
| 3818 | break; |
| 3819 | } |
| 3820 | j->rec_mode = 6; |
| 3821 | break; |
| 3822 | case WSS: |
| 3823 | switch (j->baseframe.low) { |
| 3824 | case 0xA0: |
| 3825 | j->rec_frame_size = 80; |
| 3826 | break; |
| 3827 | case 0x50: |
| 3828 | j->rec_frame_size = 40; |
| 3829 | break; |
| 3830 | default: |
| 3831 | j->rec_frame_size = 120; |
| 3832 | break; |
| 3833 | } |
| 3834 | j->rec_mode = 7; |
| 3835 | break; |
| 3836 | default: |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 3837 | kfree(j->read_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3838 | j->rec_frame_size = 0; |
| 3839 | j->rec_mode = -1; |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 3840 | j->read_buffer = NULL; |
| 3841 | j->read_buffer_size = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3842 | retval = 1; |
| 3843 | break; |
| 3844 | } |
| 3845 | return retval; |
| 3846 | } |
| 3847 | |
| 3848 | static int ixj_record_start(IXJ *j) |
| 3849 | { |
| 3850 | unsigned short cmd = 0x0000; |
| 3851 | |
| 3852 | if (j->read_buffer) { |
| 3853 | ixj_record_stop(j); |
| 3854 | } |
| 3855 | j->flags.recording = 1; |
| 3856 | ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */ |
| 3857 | |
| 3858 | if(ixjdebug & 0x0002) |
| 3859 | printk("IXJ %d Starting Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies); |
| 3860 | |
| 3861 | if (!j->rec_mode) { |
| 3862 | switch (j->rec_codec) { |
| 3863 | case G723_63: |
| 3864 | cmd = 0x5131; |
| 3865 | break; |
| 3866 | case G723_53: |
| 3867 | cmd = 0x5132; |
| 3868 | break; |
| 3869 | case TS85: |
| 3870 | cmd = 0x5130; /* TrueSpeech 8.5 */ |
| 3871 | |
| 3872 | break; |
| 3873 | case TS48: |
| 3874 | cmd = 0x5133; /* TrueSpeech 4.8 */ |
| 3875 | |
| 3876 | break; |
| 3877 | case TS41: |
| 3878 | cmd = 0x5134; /* TrueSpeech 4.1 */ |
| 3879 | |
| 3880 | break; |
| 3881 | case G728: |
| 3882 | cmd = 0x5135; |
| 3883 | break; |
| 3884 | case G729: |
| 3885 | case G729B: |
| 3886 | cmd = 0x5136; |
| 3887 | break; |
| 3888 | default: |
| 3889 | return 1; |
| 3890 | } |
| 3891 | if (ixj_WriteDSPCommand(cmd, j)) |
| 3892 | return -1; |
| 3893 | } |
| 3894 | if (!j->read_buffer) { |
| 3895 | if (!j->read_buffer) |
| 3896 | j->read_buffer = kmalloc(j->rec_frame_size * 2, GFP_ATOMIC); |
| 3897 | if (!j->read_buffer) { |
| 3898 | printk("Read buffer allocation for ixj board %d failed!\n", j->board); |
| 3899 | return -ENOMEM; |
| 3900 | } |
| 3901 | } |
| 3902 | j->read_buffer_size = j->rec_frame_size * 2; |
| 3903 | |
| 3904 | if (ixj_WriteDSPCommand(0x5102, j)) /* Set Poll sync mode */ |
| 3905 | |
| 3906 | return -1; |
| 3907 | |
| 3908 | switch (j->rec_mode) { |
| 3909 | case 0: |
| 3910 | cmd = 0x1C03; /* Record C1 */ |
| 3911 | |
| 3912 | break; |
| 3913 | case 4: |
| 3914 | if (j->ver.low == 0x12) { |
| 3915 | cmd = 0x1E03; /* Record C1 */ |
| 3916 | |
| 3917 | } else { |
| 3918 | cmd = 0x1E01; /* Record C1 */ |
| 3919 | |
| 3920 | } |
| 3921 | break; |
| 3922 | case 5: |
| 3923 | if (j->ver.low == 0x12) { |
| 3924 | cmd = 0x1E83; /* Record C1 */ |
| 3925 | |
| 3926 | } else { |
| 3927 | cmd = 0x1E81; /* Record C1 */ |
| 3928 | |
| 3929 | } |
| 3930 | break; |
| 3931 | case 6: |
| 3932 | if (j->ver.low == 0x12) { |
| 3933 | cmd = 0x1F03; /* Record C1 */ |
| 3934 | |
| 3935 | } else { |
| 3936 | cmd = 0x1F01; /* Record C1 */ |
| 3937 | |
| 3938 | } |
| 3939 | break; |
| 3940 | case 7: |
| 3941 | if (j->ver.low == 0x12) { |
| 3942 | cmd = 0x1F83; /* Record C1 */ |
| 3943 | } else { |
| 3944 | cmd = 0x1F81; /* Record C1 */ |
| 3945 | } |
| 3946 | break; |
| 3947 | } |
| 3948 | if (ixj_WriteDSPCommand(cmd, j)) |
| 3949 | return -1; |
| 3950 | |
| 3951 | if (j->flags.playing) { |
| 3952 | ixj_aec_start(j, j->aec_level); |
| 3953 | } |
| 3954 | return 0; |
| 3955 | } |
| 3956 | |
| 3957 | static void ixj_record_stop(IXJ *j) |
| 3958 | { |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 3959 | if (ixjdebug & 0x0002) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3960 | printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies); |
| 3961 | |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 3962 | kfree(j->read_buffer); |
| 3963 | j->read_buffer = NULL; |
| 3964 | j->read_buffer_size = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3965 | if (j->rec_mode > -1) { |
| 3966 | ixj_WriteDSPCommand(0x5120, j); |
| 3967 | j->rec_mode = -1; |
| 3968 | } |
| 3969 | j->flags.recording = 0; |
| 3970 | } |
| 3971 | static void ixj_vad(IXJ *j, int arg) |
| 3972 | { |
| 3973 | if (arg) |
| 3974 | ixj_WriteDSPCommand(0x513F, j); |
| 3975 | else |
| 3976 | ixj_WriteDSPCommand(0x513E, j); |
| 3977 | } |
| 3978 | |
| 3979 | static void set_rec_depth(IXJ *j, int depth) |
| 3980 | { |
| 3981 | if (depth > 60) |
| 3982 | depth = 60; |
| 3983 | if (depth < 0) |
| 3984 | depth = 0; |
| 3985 | ixj_WriteDSPCommand(0x5180 + depth, j); |
| 3986 | } |
| 3987 | |
| 3988 | static void set_dtmf_prescale(IXJ *j, int volume) |
| 3989 | { |
| 3990 | ixj_WriteDSPCommand(0xCF07, j); |
| 3991 | ixj_WriteDSPCommand(volume, j); |
| 3992 | } |
| 3993 | |
| 3994 | static int get_dtmf_prescale(IXJ *j) |
| 3995 | { |
| 3996 | ixj_WriteDSPCommand(0xCF05, j); |
| 3997 | return j->ssr.high << 8 | j->ssr.low; |
| 3998 | } |
| 3999 | |
| 4000 | static void set_rec_volume(IXJ *j, int volume) |
| 4001 | { |
| 4002 | if(j->aec_level == AEC_AGC) { |
| 4003 | if (ixjdebug & 0x0002) |
| 4004 | printk(KERN_INFO "IXJ: /dev/phone%d Setting AGC Threshold to 0x%4.4x\n", j->board, volume); |
| 4005 | ixj_WriteDSPCommand(0xCF96, j); |
| 4006 | ixj_WriteDSPCommand(volume, j); |
| 4007 | } else { |
| 4008 | if (ixjdebug & 0x0002) |
| 4009 | printk(KERN_INFO "IXJ: /dev/phone %d Setting Record Volume to 0x%4.4x\n", j->board, volume); |
| 4010 | ixj_WriteDSPCommand(0xCF03, j); |
| 4011 | ixj_WriteDSPCommand(volume, j); |
| 4012 | } |
| 4013 | } |
| 4014 | |
| 4015 | static int set_rec_volume_linear(IXJ *j, int volume) |
| 4016 | { |
| 4017 | int newvolume, dsprecmax; |
| 4018 | |
| 4019 | if (ixjdebug & 0x0002) |
| 4020 | printk(KERN_INFO "IXJ: /dev/phone %d Setting Linear Record Volume to 0x%4.4x\n", j->board, volume); |
| 4021 | if(volume > 100 || volume < 0) { |
| 4022 | return -1; |
| 4023 | } |
| 4024 | |
| 4025 | /* This should normalize the perceived volumes between the different cards caused by differences in the hardware */ |
| 4026 | switch (j->cardtype) { |
| 4027 | case QTI_PHONEJACK: |
| 4028 | dsprecmax = 0x440; |
| 4029 | break; |
| 4030 | case QTI_LINEJACK: |
| 4031 | dsprecmax = 0x180; |
| 4032 | ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */ |
| 4033 | ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */ |
| 4034 | ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */ |
| 4035 | break; |
| 4036 | case QTI_PHONEJACK_LITE: |
| 4037 | dsprecmax = 0x4C0; |
| 4038 | break; |
| 4039 | case QTI_PHONEJACK_PCI: |
| 4040 | dsprecmax = 0x100; |
| 4041 | break; |
| 4042 | case QTI_PHONECARD: |
| 4043 | dsprecmax = 0x400; |
| 4044 | break; |
| 4045 | default: |
| 4046 | return -1; |
| 4047 | } |
| 4048 | newvolume = (dsprecmax * volume) / 100; |
| 4049 | set_rec_volume(j, newvolume); |
| 4050 | return 0; |
| 4051 | } |
| 4052 | |
| 4053 | static int get_rec_volume(IXJ *j) |
| 4054 | { |
| 4055 | if(j->aec_level == AEC_AGC) { |
| 4056 | if (ixjdebug & 0x0002) |
| 4057 | printk(KERN_INFO "Getting AGC Threshold\n"); |
| 4058 | ixj_WriteDSPCommand(0xCF86, j); |
| 4059 | if (ixjdebug & 0x0002) |
| 4060 | printk(KERN_INFO "AGC Threshold is 0x%2.2x%2.2x\n", j->ssr.high, j->ssr.low); |
| 4061 | return j->ssr.high << 8 | j->ssr.low; |
| 4062 | } else { |
| 4063 | if (ixjdebug & 0x0002) |
| 4064 | printk(KERN_INFO "Getting Record Volume\n"); |
| 4065 | ixj_WriteDSPCommand(0xCF01, j); |
| 4066 | return j->ssr.high << 8 | j->ssr.low; |
| 4067 | } |
| 4068 | } |
| 4069 | |
| 4070 | static int get_rec_volume_linear(IXJ *j) |
| 4071 | { |
| 4072 | int volume, newvolume, dsprecmax; |
| 4073 | |
| 4074 | switch (j->cardtype) { |
| 4075 | case QTI_PHONEJACK: |
| 4076 | dsprecmax = 0x440; |
| 4077 | break; |
| 4078 | case QTI_LINEJACK: |
| 4079 | dsprecmax = 0x180; |
| 4080 | break; |
| 4081 | case QTI_PHONEJACK_LITE: |
| 4082 | dsprecmax = 0x4C0; |
| 4083 | break; |
| 4084 | case QTI_PHONEJACK_PCI: |
| 4085 | dsprecmax = 0x100; |
| 4086 | break; |
| 4087 | case QTI_PHONECARD: |
| 4088 | dsprecmax = 0x400; |
| 4089 | break; |
| 4090 | default: |
| 4091 | return -1; |
| 4092 | } |
| 4093 | volume = get_rec_volume(j); |
| 4094 | newvolume = (volume * 100) / dsprecmax; |
| 4095 | if(newvolume > 100) |
| 4096 | newvolume = 100; |
| 4097 | return newvolume; |
| 4098 | } |
| 4099 | |
| 4100 | static int get_rec_level(IXJ *j) |
| 4101 | { |
| 4102 | int retval; |
| 4103 | |
| 4104 | ixj_WriteDSPCommand(0xCF88, j); |
| 4105 | |
| 4106 | retval = j->ssr.high << 8 | j->ssr.low; |
| 4107 | retval = (retval * 256) / 240; |
| 4108 | return retval; |
| 4109 | } |
| 4110 | |
| 4111 | static void ixj_aec_start(IXJ *j, int level) |
| 4112 | { |
| 4113 | j->aec_level = level; |
| 4114 | if (ixjdebug & 0x0002) |
| 4115 | printk(KERN_INFO "AGC set = 0x%2.2x\n", j->aec_level); |
| 4116 | if (!level) { |
| 4117 | aec_stop(j); |
| 4118 | } else { |
| 4119 | if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) { |
| 4120 | ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer */ |
| 4121 | |
| 4122 | ixj_WriteDSPCommand(0x0300, j); |
| 4123 | } |
| 4124 | ixj_WriteDSPCommand(0xB001, j); /* AEC On */ |
| 4125 | |
| 4126 | ixj_WriteDSPCommand(0xE013, j); /* Advanced AEC C1 */ |
| 4127 | |
| 4128 | switch (level) { |
| 4129 | case AEC_LOW: |
| 4130 | ixj_WriteDSPCommand(0x0000, j); /* Advanced AEC C2 = off */ |
| 4131 | |
| 4132 | ixj_WriteDSPCommand(0xE011, j); |
| 4133 | ixj_WriteDSPCommand(0xFFFF, j); |
| 4134 | |
| 4135 | ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */ |
| 4136 | ixj_WriteDSPCommand(0x0000, j); /* to off */ |
| 4137 | |
| 4138 | break; |
| 4139 | |
| 4140 | case AEC_MED: |
| 4141 | ixj_WriteDSPCommand(0x0600, j); /* Advanced AEC C2 = on medium */ |
| 4142 | |
| 4143 | ixj_WriteDSPCommand(0xE011, j); |
| 4144 | ixj_WriteDSPCommand(0x0080, j); |
| 4145 | |
| 4146 | ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */ |
| 4147 | ixj_WriteDSPCommand(0x0000, j); /* to off */ |
| 4148 | |
| 4149 | break; |
| 4150 | |
| 4151 | case AEC_HIGH: |
| 4152 | ixj_WriteDSPCommand(0x0C00, j); /* Advanced AEC C2 = on high */ |
| 4153 | |
| 4154 | ixj_WriteDSPCommand(0xE011, j); |
| 4155 | ixj_WriteDSPCommand(0x0080, j); |
| 4156 | |
| 4157 | ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */ |
| 4158 | ixj_WriteDSPCommand(0x0000, j); /* to off */ |
| 4159 | |
| 4160 | break; |
| 4161 | |
| 4162 | case AEC_AGC: |
| 4163 | /* First we have to put the AEC into advance auto mode so that AGC will not conflict with it */ |
| 4164 | ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */ |
| 4165 | |
| 4166 | ixj_WriteDSPCommand(0xE011, j); |
| 4167 | ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */ |
| 4168 | |
| 4169 | ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */ |
| 4170 | |
| 4171 | if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD) |
| 4172 | ixj_WriteDSPCommand(0x0224, j); |
| 4173 | else |
| 4174 | ixj_WriteDSPCommand(0x1224, j); |
| 4175 | |
| 4176 | ixj_WriteDSPCommand(0xE014, j); |
| 4177 | ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */ |
| 4178 | |
| 4179 | ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */ |
| 4180 | |
| 4181 | /* Now we can set the AGC initial parameters and turn it on */ |
| 4182 | ixj_WriteDSPCommand(0xCF90, j); /* Set AGC Minumum gain */ |
| 4183 | ixj_WriteDSPCommand(0x0020, j); /* to 0.125 (-18dB) */ |
| 4184 | |
| 4185 | ixj_WriteDSPCommand(0xCF91, j); /* Set AGC Maximum gain */ |
| 4186 | ixj_WriteDSPCommand(0x1000, j); /* to 16 (24dB) */ |
| 4187 | |
| 4188 | ixj_WriteDSPCommand(0xCF92, j); /* Set AGC start gain */ |
| 4189 | ixj_WriteDSPCommand(0x0800, j); /* to 8 (+18dB) */ |
| 4190 | |
| 4191 | ixj_WriteDSPCommand(0xCF93, j); /* Set AGC hold time */ |
| 4192 | ixj_WriteDSPCommand(0x1F40, j); /* to 2 seconds (units are 250us) */ |
| 4193 | |
| 4194 | ixj_WriteDSPCommand(0xCF94, j); /* Set AGC Attack Time Constant */ |
| 4195 | ixj_WriteDSPCommand(0x0005, j); /* to 8ms */ |
| 4196 | |
| 4197 | ixj_WriteDSPCommand(0xCF95, j); /* Set AGC Decay Time Constant */ |
| 4198 | ixj_WriteDSPCommand(0x000D, j); /* to 4096ms */ |
| 4199 | |
| 4200 | ixj_WriteDSPCommand(0xCF96, j); /* Set AGC Attack Threshold */ |
| 4201 | ixj_WriteDSPCommand(0x1200, j); /* to 25% */ |
| 4202 | |
| 4203 | ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */ |
| 4204 | ixj_WriteDSPCommand(0x0001, j); /* to on */ |
| 4205 | |
| 4206 | break; |
| 4207 | |
| 4208 | case AEC_AUTO: |
| 4209 | ixj_WriteDSPCommand(0x0002, j); /* Attenuation scaling factor of 2 */ |
| 4210 | |
| 4211 | ixj_WriteDSPCommand(0xE011, j); |
| 4212 | ixj_WriteDSPCommand(0x0100, j); /* Higher Threshold Floor */ |
| 4213 | |
| 4214 | ixj_WriteDSPCommand(0xE012, j); /* Set Train and Lock */ |
| 4215 | |
| 4216 | if(j->cardtype == QTI_LINEJACK || j->cardtype == QTI_PHONECARD) |
| 4217 | ixj_WriteDSPCommand(0x0224, j); |
| 4218 | else |
| 4219 | ixj_WriteDSPCommand(0x1224, j); |
| 4220 | |
| 4221 | ixj_WriteDSPCommand(0xE014, j); |
| 4222 | ixj_WriteDSPCommand(0x0003, j); /* Lock threashold at 3dB */ |
| 4223 | |
| 4224 | ixj_WriteDSPCommand(0xE338, j); /* Set Echo Suppresser Attenuation to 0dB */ |
| 4225 | |
| 4226 | break; |
| 4227 | } |
| 4228 | } |
| 4229 | } |
| 4230 | |
| 4231 | static void aec_stop(IXJ *j) |
| 4232 | { |
| 4233 | j->aec_level = AEC_OFF; |
| 4234 | if (j->rec_codec == G729 || j->play_codec == G729 || j->rec_codec == G729B || j->play_codec == G729B) { |
| 4235 | ixj_WriteDSPCommand(0xE022, j); /* Move AEC filter buffer back */ |
| 4236 | |
| 4237 | ixj_WriteDSPCommand(0x0700, j); |
| 4238 | } |
| 4239 | if (j->play_mode != -1 && j->rec_mode != -1) |
| 4240 | { |
| 4241 | ixj_WriteDSPCommand(0xB002, j); /* AEC Stop */ |
| 4242 | } |
| 4243 | } |
| 4244 | |
| 4245 | static int set_play_codec(IXJ *j, int rate) |
| 4246 | { |
| 4247 | int retval = 0; |
| 4248 | |
| 4249 | j->play_codec = rate; |
| 4250 | |
| 4251 | switch (rate) { |
| 4252 | case G723_63: |
| 4253 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 4254 | j->play_frame_size = 12; |
| 4255 | j->play_mode = 0; |
| 4256 | } else { |
| 4257 | retval = 1; |
| 4258 | } |
| 4259 | break; |
| 4260 | case G723_53: |
| 4261 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 4262 | j->play_frame_size = 10; |
| 4263 | j->play_mode = 0; |
| 4264 | } else { |
| 4265 | retval = 1; |
| 4266 | } |
| 4267 | break; |
| 4268 | case TS85: |
| 4269 | if (j->dsp.low == 0x20 || j->flags.ts85_loaded) { |
| 4270 | j->play_frame_size = 16; |
| 4271 | j->play_mode = 0; |
| 4272 | } else { |
| 4273 | retval = 1; |
| 4274 | } |
| 4275 | break; |
| 4276 | case TS48: |
| 4277 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 4278 | j->play_frame_size = 9; |
| 4279 | j->play_mode = 0; |
| 4280 | } else { |
| 4281 | retval = 1; |
| 4282 | } |
| 4283 | break; |
| 4284 | case TS41: |
| 4285 | if (j->ver.low != 0x12 || ixj_convert_loaded) { |
| 4286 | j->play_frame_size = 8; |
| 4287 | j->play_mode = 0; |
| 4288 | } else { |
| 4289 | retval = 1; |
| 4290 | } |
| 4291 | break; |
| 4292 | case G728: |
| 4293 | if (j->dsp.low != 0x20) { |
| 4294 | j->play_frame_size = 48; |
| 4295 | j->play_mode = 0; |
| 4296 | } else { |
| 4297 | retval = 1; |
| 4298 | } |
| 4299 | break; |
| 4300 | case G729: |
| 4301 | if (j->dsp.low != 0x20) { |
| 4302 | if (!j->flags.g729_loaded) { |
| 4303 | retval = 1; |
| 4304 | break; |
| 4305 | } |
| 4306 | switch (j->baseframe.low) { |
| 4307 | case 0xA0: |
| 4308 | j->play_frame_size = 10; |
| 4309 | break; |
| 4310 | case 0x50: |
| 4311 | j->play_frame_size = 5; |
| 4312 | break; |
| 4313 | default: |
| 4314 | j->play_frame_size = 15; |
| 4315 | break; |
| 4316 | } |
| 4317 | j->play_mode = 0; |
| 4318 | } else { |
| 4319 | retval = 1; |
| 4320 | } |
| 4321 | break; |
| 4322 | case G729B: |
| 4323 | if (j->dsp.low != 0x20) { |
| 4324 | if (!j->flags.g729_loaded) { |
| 4325 | retval = 1; |
| 4326 | break; |
| 4327 | } |
| 4328 | switch (j->baseframe.low) { |
| 4329 | case 0xA0: |
| 4330 | j->play_frame_size = 12; |
| 4331 | break; |
| 4332 | case 0x50: |
| 4333 | j->play_frame_size = 6; |
| 4334 | break; |
| 4335 | default: |
| 4336 | j->play_frame_size = 18; |
| 4337 | break; |
| 4338 | } |
| 4339 | j->play_mode = 0; |
| 4340 | } else { |
| 4341 | retval = 1; |
| 4342 | } |
| 4343 | break; |
| 4344 | case ULAW: |
| 4345 | switch (j->baseframe.low) { |
| 4346 | case 0xA0: |
| 4347 | j->play_frame_size = 80; |
| 4348 | break; |
| 4349 | case 0x50: |
| 4350 | j->play_frame_size = 40; |
| 4351 | break; |
| 4352 | default: |
| 4353 | j->play_frame_size = 120; |
| 4354 | break; |
| 4355 | } |
| 4356 | j->play_mode = 2; |
| 4357 | break; |
| 4358 | case ALAW: |
| 4359 | switch (j->baseframe.low) { |
| 4360 | case 0xA0: |
| 4361 | j->play_frame_size = 80; |
| 4362 | break; |
| 4363 | case 0x50: |
| 4364 | j->play_frame_size = 40; |
| 4365 | break; |
| 4366 | default: |
| 4367 | j->play_frame_size = 120; |
| 4368 | break; |
| 4369 | } |
| 4370 | j->play_mode = 2; |
| 4371 | break; |
| 4372 | case LINEAR16: |
| 4373 | switch (j->baseframe.low) { |
| 4374 | case 0xA0: |
| 4375 | j->play_frame_size = 160; |
| 4376 | break; |
| 4377 | case 0x50: |
| 4378 | j->play_frame_size = 80; |
| 4379 | break; |
| 4380 | default: |
| 4381 | j->play_frame_size = 240; |
| 4382 | break; |
| 4383 | } |
| 4384 | j->play_mode = 6; |
| 4385 | break; |
| 4386 | case LINEAR8: |
| 4387 | switch (j->baseframe.low) { |
| 4388 | case 0xA0: |
| 4389 | j->play_frame_size = 80; |
| 4390 | break; |
| 4391 | case 0x50: |
| 4392 | j->play_frame_size = 40; |
| 4393 | break; |
| 4394 | default: |
| 4395 | j->play_frame_size = 120; |
| 4396 | break; |
| 4397 | } |
| 4398 | j->play_mode = 4; |
| 4399 | break; |
| 4400 | case WSS: |
| 4401 | switch (j->baseframe.low) { |
| 4402 | case 0xA0: |
| 4403 | j->play_frame_size = 80; |
| 4404 | break; |
| 4405 | case 0x50: |
| 4406 | j->play_frame_size = 40; |
| 4407 | break; |
| 4408 | default: |
| 4409 | j->play_frame_size = 120; |
| 4410 | break; |
| 4411 | } |
| 4412 | j->play_mode = 5; |
| 4413 | break; |
| 4414 | default: |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 4415 | kfree(j->write_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4416 | j->play_frame_size = 0; |
| 4417 | j->play_mode = -1; |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 4418 | j->write_buffer = NULL; |
| 4419 | j->write_buffer_size = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4420 | retval = 1; |
| 4421 | break; |
| 4422 | } |
| 4423 | return retval; |
| 4424 | } |
| 4425 | |
| 4426 | static int ixj_play_start(IXJ *j) |
| 4427 | { |
| 4428 | unsigned short cmd = 0x0000; |
| 4429 | |
| 4430 | if (j->write_buffer) { |
| 4431 | ixj_play_stop(j); |
| 4432 | } |
| 4433 | |
| 4434 | if(ixjdebug & 0x0002) |
| 4435 | printk("IXJ %d Starting Play Codec %d at %ld\n", j->board, j->play_codec, jiffies); |
| 4436 | |
| 4437 | j->flags.playing = 1; |
| 4438 | ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */ |
| 4439 | |
| 4440 | j->flags.play_first_frame = 1; |
| 4441 | j->drybuffer = 0; |
| 4442 | |
| 4443 | if (!j->play_mode) { |
| 4444 | switch (j->play_codec) { |
| 4445 | case G723_63: |
| 4446 | cmd = 0x5231; |
| 4447 | break; |
| 4448 | case G723_53: |
| 4449 | cmd = 0x5232; |
| 4450 | break; |
| 4451 | case TS85: |
| 4452 | cmd = 0x5230; /* TrueSpeech 8.5 */ |
| 4453 | |
| 4454 | break; |
| 4455 | case TS48: |
| 4456 | cmd = 0x5233; /* TrueSpeech 4.8 */ |
| 4457 | |
| 4458 | break; |
| 4459 | case TS41: |
| 4460 | cmd = 0x5234; /* TrueSpeech 4.1 */ |
| 4461 | |
| 4462 | break; |
| 4463 | case G728: |
| 4464 | cmd = 0x5235; |
| 4465 | break; |
| 4466 | case G729: |
| 4467 | case G729B: |
| 4468 | cmd = 0x5236; |
| 4469 | break; |
| 4470 | default: |
| 4471 | return 1; |
| 4472 | } |
| 4473 | if (ixj_WriteDSPCommand(cmd, j)) |
| 4474 | return -1; |
| 4475 | } |
| 4476 | j->write_buffer = kmalloc(j->play_frame_size * 2, GFP_ATOMIC); |
| 4477 | if (!j->write_buffer) { |
| 4478 | printk("Write buffer allocation for ixj board %d failed!\n", j->board); |
| 4479 | return -ENOMEM; |
| 4480 | } |
| 4481 | /* j->write_buffers_empty = 2; */ |
| 4482 | j->write_buffers_empty = 1; |
| 4483 | j->write_buffer_size = j->play_frame_size * 2; |
| 4484 | j->write_buffer_end = j->write_buffer + j->play_frame_size * 2; |
| 4485 | j->write_buffer_rp = j->write_buffer_wp = j->write_buffer; |
| 4486 | |
| 4487 | if (ixj_WriteDSPCommand(0x5202, j)) /* Set Poll sync mode */ |
| 4488 | |
| 4489 | return -1; |
| 4490 | |
| 4491 | switch (j->play_mode) { |
| 4492 | case 0: |
| 4493 | cmd = 0x2C03; |
| 4494 | break; |
| 4495 | case 2: |
| 4496 | if (j->ver.low == 0x12) { |
| 4497 | cmd = 0x2C23; |
| 4498 | } else { |
| 4499 | cmd = 0x2C21; |
| 4500 | } |
| 4501 | break; |
| 4502 | case 4: |
| 4503 | if (j->ver.low == 0x12) { |
| 4504 | cmd = 0x2C43; |
| 4505 | } else { |
| 4506 | cmd = 0x2C41; |
| 4507 | } |
| 4508 | break; |
| 4509 | case 5: |
| 4510 | if (j->ver.low == 0x12) { |
| 4511 | cmd = 0x2C53; |
| 4512 | } else { |
| 4513 | cmd = 0x2C51; |
| 4514 | } |
| 4515 | break; |
| 4516 | case 6: |
| 4517 | if (j->ver.low == 0x12) { |
| 4518 | cmd = 0x2C63; |
| 4519 | } else { |
| 4520 | cmd = 0x2C61; |
| 4521 | } |
| 4522 | break; |
| 4523 | } |
| 4524 | if (ixj_WriteDSPCommand(cmd, j)) |
| 4525 | return -1; |
| 4526 | |
| 4527 | if (ixj_WriteDSPCommand(0x2000, j)) /* Playback C2 */ |
| 4528 | return -1; |
| 4529 | |
| 4530 | if (ixj_WriteDSPCommand(0x2000 + j->play_frame_size, j)) /* Playback C3 */ |
| 4531 | return -1; |
| 4532 | |
| 4533 | if (j->flags.recording) { |
| 4534 | ixj_aec_start(j, j->aec_level); |
| 4535 | } |
| 4536 | |
| 4537 | return 0; |
| 4538 | } |
| 4539 | |
| 4540 | static void ixj_play_stop(IXJ *j) |
| 4541 | { |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 4542 | if (ixjdebug & 0x0002) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4543 | printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies); |
| 4544 | |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 4545 | kfree(j->write_buffer); |
| 4546 | j->write_buffer = NULL; |
| 4547 | j->write_buffer_size = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4548 | if (j->play_mode > -1) { |
| 4549 | ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers. 8022 reference page 9-40 */ |
| 4550 | |
| 4551 | j->play_mode = -1; |
| 4552 | } |
| 4553 | j->flags.playing = 0; |
| 4554 | } |
| 4555 | |
| 4556 | static inline int get_play_level(IXJ *j) |
| 4557 | { |
| 4558 | int retval; |
| 4559 | |
| 4560 | ixj_WriteDSPCommand(0xCF8F, j); /* 8022 Reference page 9-38 */ |
| 4561 | return j->ssr.high << 8 | j->ssr.low; |
| 4562 | retval = j->ssr.high << 8 | j->ssr.low; |
| 4563 | retval = (retval * 256) / 240; |
| 4564 | return retval; |
| 4565 | } |
| 4566 | |
| 4567 | static unsigned int ixj_poll(struct file *file_p, poll_table * wait) |
| 4568 | { |
| 4569 | unsigned int mask = 0; |
| 4570 | |
| 4571 | IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode)); |
| 4572 | |
| 4573 | poll_wait(file_p, &(j->poll_q), wait); |
| 4574 | if (j->read_buffer_ready > 0) |
| 4575 | mask |= POLLIN | POLLRDNORM; /* readable */ |
| 4576 | if (j->write_buffers_empty > 0) |
| 4577 | mask |= POLLOUT | POLLWRNORM; /* writable */ |
| 4578 | if (j->ex.bytes) |
| 4579 | mask |= POLLPRI; |
| 4580 | return mask; |
| 4581 | } |
| 4582 | |
| 4583 | static int ixj_play_tone(IXJ *j, char tone) |
| 4584 | { |
| 4585 | if (!j->tone_state) { |
| 4586 | if(ixjdebug & 0x0002) { |
| 4587 | printk("IXJ %d starting tone %d at %ld\n", j->board, tone, jiffies); |
| 4588 | } |
| 4589 | if (j->dsp.low == 0x20) { |
| 4590 | idle(j); |
| 4591 | } |
| 4592 | j->tone_start_jif = jiffies; |
| 4593 | |
| 4594 | j->tone_state = 1; |
| 4595 | } |
| 4596 | |
| 4597 | j->tone_index = tone; |
| 4598 | if (ixj_WriteDSPCommand(0x6000 + j->tone_index, j)) |
| 4599 | return -1; |
| 4600 | |
| 4601 | return 0; |
| 4602 | } |
| 4603 | |
| 4604 | static int ixj_set_tone_on(unsigned short arg, IXJ *j) |
| 4605 | { |
| 4606 | j->tone_on_time = arg; |
| 4607 | |
| 4608 | if (ixj_WriteDSPCommand(0x6E04, j)) /* Set Tone On Period */ |
| 4609 | |
| 4610 | return -1; |
| 4611 | |
| 4612 | if (ixj_WriteDSPCommand(arg, j)) |
| 4613 | return -1; |
| 4614 | |
| 4615 | return 0; |
| 4616 | } |
| 4617 | |
| 4618 | static int SCI_WaitHighSCI(IXJ *j) |
| 4619 | { |
| 4620 | int cnt; |
| 4621 | |
| 4622 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 4623 | if (!j->pld_scrr.bits.sci) { |
| 4624 | for (cnt = 0; cnt < 10; cnt++) { |
| 4625 | udelay(32); |
| 4626 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 4627 | |
| 4628 | if ((j->pld_scrr.bits.sci)) |
| 4629 | return 1; |
| 4630 | } |
| 4631 | if (ixjdebug & 0x0001) |
| 4632 | printk(KERN_INFO "SCI Wait High failed %x\n", j->pld_scrr.byte); |
| 4633 | return 0; |
| 4634 | } else |
| 4635 | return 1; |
| 4636 | } |
| 4637 | |
| 4638 | static int SCI_WaitLowSCI(IXJ *j) |
| 4639 | { |
| 4640 | int cnt; |
| 4641 | |
| 4642 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 4643 | if (j->pld_scrr.bits.sci) { |
| 4644 | for (cnt = 0; cnt < 10; cnt++) { |
| 4645 | udelay(32); |
| 4646 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 4647 | |
| 4648 | if (!(j->pld_scrr.bits.sci)) |
| 4649 | return 1; |
| 4650 | } |
| 4651 | if (ixjdebug & 0x0001) |
| 4652 | printk(KERN_INFO "SCI Wait Low failed %x\n", j->pld_scrr.byte); |
| 4653 | return 0; |
| 4654 | } else |
| 4655 | return 1; |
| 4656 | } |
| 4657 | |
| 4658 | static int SCI_Control(IXJ *j, int control) |
| 4659 | { |
| 4660 | switch (control) { |
| 4661 | case SCI_End: |
| 4662 | j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */ |
| 4663 | |
| 4664 | j->pld_scrw.bits.c1 = 0; /* to no selection */ |
| 4665 | |
| 4666 | break; |
| 4667 | case SCI_Enable_DAA: |
| 4668 | j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */ |
| 4669 | |
| 4670 | j->pld_scrw.bits.c1 = 0; /* to write to DAA */ |
| 4671 | |
| 4672 | break; |
| 4673 | case SCI_Enable_Mixer: |
| 4674 | j->pld_scrw.bits.c0 = 0; /* Set PLD Serial control interface */ |
| 4675 | |
| 4676 | j->pld_scrw.bits.c1 = 1; /* to write to mixer */ |
| 4677 | |
| 4678 | break; |
| 4679 | case SCI_Enable_EEPROM: |
| 4680 | j->pld_scrw.bits.c0 = 1; /* Set PLD Serial control interface */ |
| 4681 | |
| 4682 | j->pld_scrw.bits.c1 = 1; /* to write to EEPROM */ |
| 4683 | |
| 4684 | break; |
| 4685 | default: |
| 4686 | return 0; |
| 4687 | break; |
| 4688 | } |
| 4689 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 4690 | |
| 4691 | switch (control) { |
| 4692 | case SCI_End: |
| 4693 | return 1; |
| 4694 | break; |
| 4695 | case SCI_Enable_DAA: |
| 4696 | case SCI_Enable_Mixer: |
| 4697 | case SCI_Enable_EEPROM: |
| 4698 | if (!SCI_WaitHighSCI(j)) |
| 4699 | return 0; |
| 4700 | break; |
| 4701 | default: |
| 4702 | return 0; |
| 4703 | break; |
| 4704 | } |
| 4705 | return 1; |
| 4706 | } |
| 4707 | |
| 4708 | static int SCI_Prepare(IXJ *j) |
| 4709 | { |
| 4710 | if (!SCI_Control(j, SCI_End)) |
| 4711 | return 0; |
| 4712 | |
| 4713 | if (!SCI_WaitLowSCI(j)) |
| 4714 | return 0; |
| 4715 | |
| 4716 | return 1; |
| 4717 | } |
| 4718 | |
| 4719 | static int ixj_get_mixer(long val, IXJ *j) |
| 4720 | { |
| 4721 | int reg = (val & 0x1F00) >> 8; |
| 4722 | return j->mix.vol[reg]; |
| 4723 | } |
| 4724 | |
| 4725 | static int ixj_mixer(long val, IXJ *j) |
| 4726 | { |
| 4727 | BYTES bytes; |
| 4728 | |
| 4729 | bytes.high = (val & 0x1F00) >> 8; |
| 4730 | bytes.low = val & 0x00FF; |
| 4731 | |
| 4732 | /* save mixer value so we can get back later on */ |
| 4733 | j->mix.vol[bytes.high] = bytes.low; |
| 4734 | |
| 4735 | outb_p(bytes.high & 0x1F, j->XILINXbase + 0x03); /* Load Mixer Address */ |
| 4736 | |
| 4737 | outb_p(bytes.low, j->XILINXbase + 0x02); /* Load Mixer Data */ |
| 4738 | |
| 4739 | SCI_Control(j, SCI_Enable_Mixer); |
| 4740 | |
| 4741 | SCI_Control(j, SCI_End); |
| 4742 | |
| 4743 | return 0; |
| 4744 | } |
| 4745 | |
| 4746 | static int daa_load(BYTES * p_bytes, IXJ *j) |
| 4747 | { |
| 4748 | outb_p(p_bytes->high, j->XILINXbase + 0x03); |
| 4749 | outb_p(p_bytes->low, j->XILINXbase + 0x02); |
| 4750 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4751 | return 0; |
| 4752 | else |
| 4753 | return 1; |
| 4754 | } |
| 4755 | |
| 4756 | static int ixj_daa_cr4(IXJ *j, char reg) |
| 4757 | { |
| 4758 | BYTES bytes; |
| 4759 | |
| 4760 | switch (j->daa_mode) { |
| 4761 | case SOP_PU_SLEEP: |
| 4762 | bytes.high = 0x14; |
| 4763 | break; |
| 4764 | case SOP_PU_RINGING: |
| 4765 | bytes.high = 0x54; |
| 4766 | break; |
| 4767 | case SOP_PU_CONVERSATION: |
| 4768 | bytes.high = 0x94; |
| 4769 | break; |
| 4770 | case SOP_PU_PULSEDIALING: |
| 4771 | bytes.high = 0xD4; |
| 4772 | break; |
| 4773 | } |
| 4774 | |
| 4775 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = reg; |
| 4776 | |
| 4777 | switch (j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGX) { |
| 4778 | case 0: |
| 4779 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 0; |
| 4780 | break; |
| 4781 | case 1: |
| 4782 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 2; |
| 4783 | break; |
| 4784 | case 2: |
| 4785 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 1; |
| 4786 | break; |
| 4787 | case 3: |
| 4788 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.bitreg.AGR_Z = 3; |
| 4789 | break; |
| 4790 | } |
| 4791 | |
| 4792 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg; |
| 4793 | |
| 4794 | if (!daa_load(&bytes, j)) |
| 4795 | return 0; |
| 4796 | |
| 4797 | if (!SCI_Prepare(j)) |
| 4798 | return 0; |
| 4799 | |
| 4800 | return 1; |
| 4801 | } |
| 4802 | |
| 4803 | static char daa_int_read(IXJ *j) |
| 4804 | { |
| 4805 | BYTES bytes; |
| 4806 | |
| 4807 | if (!SCI_Prepare(j)) |
| 4808 | return 0; |
| 4809 | |
| 4810 | bytes.high = 0x38; |
| 4811 | bytes.low = 0x00; |
| 4812 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4813 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4814 | |
| 4815 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4816 | return 0; |
| 4817 | |
| 4818 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 4819 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 4820 | if (bytes.low != ALISDAA_ID_BYTE) { |
| 4821 | if (ixjdebug & 0x0001) |
| 4822 | printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low); |
| 4823 | return 0; |
| 4824 | } |
| 4825 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4826 | return 0; |
| 4827 | if (!SCI_Control(j, SCI_End)) |
| 4828 | return 0; |
| 4829 | |
| 4830 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 4831 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 4832 | |
| 4833 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg = bytes.high; |
| 4834 | |
| 4835 | return 1; |
| 4836 | } |
| 4837 | |
| 4838 | static char daa_CR_read(IXJ *j, int cr) |
| 4839 | { |
| 4840 | IXJ_WORD wdata; |
| 4841 | BYTES bytes; |
| 4842 | |
| 4843 | if (!SCI_Prepare(j)) |
| 4844 | return 0; |
| 4845 | |
| 4846 | switch (j->daa_mode) { |
| 4847 | case SOP_PU_SLEEP: |
| 4848 | bytes.high = 0x30 + cr; |
| 4849 | break; |
| 4850 | case SOP_PU_RINGING: |
| 4851 | bytes.high = 0x70 + cr; |
| 4852 | break; |
| 4853 | case SOP_PU_CONVERSATION: |
| 4854 | bytes.high = 0xB0 + cr; |
| 4855 | break; |
| 4856 | case SOP_PU_PULSEDIALING: |
| 4857 | bytes.high = 0xF0 + cr; |
| 4858 | break; |
| 4859 | } |
| 4860 | |
| 4861 | bytes.low = 0x00; |
| 4862 | |
| 4863 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4864 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4865 | |
| 4866 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4867 | return 0; |
| 4868 | |
| 4869 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 4870 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 4871 | if (bytes.low != ALISDAA_ID_BYTE) { |
| 4872 | if (ixjdebug & 0x0001) |
| 4873 | printk("Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low); |
| 4874 | return 0; |
| 4875 | } |
| 4876 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4877 | return 0; |
| 4878 | if (!SCI_Control(j, SCI_End)) |
| 4879 | return 0; |
| 4880 | |
| 4881 | wdata.word = inw_p(j->XILINXbase + 0x02); |
| 4882 | |
| 4883 | switch(cr){ |
| 4884 | case 5: |
| 4885 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = wdata.bytes.high; |
| 4886 | break; |
| 4887 | case 4: |
| 4888 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = wdata.bytes.high; |
| 4889 | break; |
| 4890 | case 3: |
| 4891 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = wdata.bytes.high; |
| 4892 | break; |
| 4893 | case 2: |
| 4894 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = wdata.bytes.high; |
| 4895 | break; |
| 4896 | case 1: |
| 4897 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = wdata.bytes.high; |
| 4898 | break; |
| 4899 | case 0: |
| 4900 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = wdata.bytes.high; |
| 4901 | break; |
| 4902 | default: |
| 4903 | return 0; |
| 4904 | } |
| 4905 | return 1; |
| 4906 | } |
| 4907 | |
| 4908 | static int ixj_daa_cid_reset(IXJ *j) |
| 4909 | { |
| 4910 | int i; |
| 4911 | BYTES bytes; |
| 4912 | |
| 4913 | if (ixjdebug & 0x0002) |
| 4914 | printk("DAA Clearing CID ram\n"); |
| 4915 | |
| 4916 | if (!SCI_Prepare(j)) |
| 4917 | return 0; |
| 4918 | |
| 4919 | bytes.high = 0x58; |
| 4920 | bytes.low = 0x00; |
| 4921 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4922 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4923 | |
| 4924 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4925 | return 0; |
| 4926 | |
| 4927 | if (!SCI_WaitHighSCI(j)) |
| 4928 | return 0; |
| 4929 | |
| 4930 | for (i = 0; i < ALISDAA_CALLERID_SIZE - 1; i += 2) { |
| 4931 | bytes.high = bytes.low = 0x00; |
| 4932 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4933 | |
| 4934 | if (i < ALISDAA_CALLERID_SIZE - 1) |
| 4935 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4936 | |
| 4937 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4938 | return 0; |
| 4939 | |
| 4940 | if (!SCI_WaitHighSCI(j)) |
| 4941 | return 0; |
| 4942 | |
| 4943 | } |
| 4944 | |
| 4945 | if (!SCI_Control(j, SCI_End)) |
| 4946 | return 0; |
| 4947 | |
| 4948 | if (ixjdebug & 0x0002) |
| 4949 | printk("DAA CID ram cleared\n"); |
| 4950 | |
| 4951 | return 1; |
| 4952 | } |
| 4953 | |
| 4954 | static int ixj_daa_cid_read(IXJ *j) |
| 4955 | { |
| 4956 | int i; |
| 4957 | BYTES bytes; |
| 4958 | char CID[ALISDAA_CALLERID_SIZE], mContinue; |
| 4959 | char *pIn, *pOut; |
| 4960 | |
| 4961 | if (!SCI_Prepare(j)) |
| 4962 | return 0; |
| 4963 | |
| 4964 | bytes.high = 0x78; |
| 4965 | bytes.low = 0x00; |
| 4966 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4967 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4968 | |
| 4969 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4970 | return 0; |
| 4971 | |
| 4972 | if (!SCI_WaitHighSCI(j)) |
| 4973 | return 0; |
| 4974 | |
| 4975 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 4976 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 4977 | if (bytes.low != ALISDAA_ID_BYTE) { |
| 4978 | if (ixjdebug & 0x0001) |
| 4979 | printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low); |
| 4980 | return 0; |
| 4981 | } |
| 4982 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i += 2) { |
| 4983 | bytes.high = bytes.low = 0x00; |
| 4984 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 4985 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 4986 | |
| 4987 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 4988 | return 0; |
| 4989 | |
| 4990 | if (!SCI_WaitHighSCI(j)) |
| 4991 | return 0; |
| 4992 | |
| 4993 | CID[i + 0] = inb_p(j->XILINXbase + 0x03); |
| 4994 | CID[i + 1] = inb_p(j->XILINXbase + 0x02); |
| 4995 | } |
| 4996 | |
| 4997 | if (!SCI_Control(j, SCI_End)) |
| 4998 | return 0; |
| 4999 | |
| 5000 | pIn = CID; |
| 5001 | pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID; |
| 5002 | mContinue = 1; |
| 5003 | while (mContinue) { |
| 5004 | if ((pIn[1] & 0x03) == 0x01) { |
| 5005 | pOut[0] = pIn[0]; |
| 5006 | } |
| 5007 | if ((pIn[2] & 0x0c) == 0x04) { |
| 5008 | pOut[1] = ((pIn[2] & 0x03) << 6) | ((pIn[1] & 0xfc) >> 2); |
| 5009 | } |
| 5010 | if ((pIn[3] & 0x30) == 0x10) { |
| 5011 | pOut[2] = ((pIn[3] & 0x0f) << 4) | ((pIn[2] & 0xf0) >> 4); |
| 5012 | } |
| 5013 | if ((pIn[4] & 0xc0) == 0x40) { |
| 5014 | pOut[3] = ((pIn[4] & 0x3f) << 2) | ((pIn[3] & 0xc0) >> 6); |
| 5015 | } else { |
| 5016 | mContinue = FALSE; |
| 5017 | } |
| 5018 | pIn += 5, pOut += 4; |
| 5019 | } |
| 5020 | memset(&j->cid, 0, sizeof(PHONE_CID)); |
| 5021 | pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID; |
| 5022 | pOut += 4; |
| 5023 | strncpy(j->cid.month, pOut, 2); |
| 5024 | pOut += 2; |
| 5025 | strncpy(j->cid.day, pOut, 2); |
| 5026 | pOut += 2; |
| 5027 | strncpy(j->cid.hour, pOut, 2); |
| 5028 | pOut += 2; |
| 5029 | strncpy(j->cid.min, pOut, 2); |
| 5030 | pOut += 3; |
| 5031 | j->cid.numlen = *pOut; |
| 5032 | pOut += 1; |
| 5033 | strncpy(j->cid.number, pOut, j->cid.numlen); |
| 5034 | pOut += j->cid.numlen + 1; |
| 5035 | j->cid.namelen = *pOut; |
| 5036 | pOut += 1; |
| 5037 | strncpy(j->cid.name, pOut, j->cid.namelen); |
| 5038 | |
| 5039 | ixj_daa_cid_reset(j); |
| 5040 | return 1; |
| 5041 | } |
| 5042 | |
| 5043 | static char daa_get_version(IXJ *j) |
| 5044 | { |
| 5045 | BYTES bytes; |
| 5046 | |
| 5047 | if (!SCI_Prepare(j)) |
| 5048 | return 0; |
| 5049 | |
| 5050 | bytes.high = 0x35; |
| 5051 | bytes.low = 0x00; |
| 5052 | outb_p(bytes.high, j->XILINXbase + 0x03); |
| 5053 | outb_p(bytes.low, j->XILINXbase + 0x02); |
| 5054 | |
| 5055 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 5056 | return 0; |
| 5057 | |
| 5058 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 5059 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 5060 | if (bytes.low != ALISDAA_ID_BYTE) { |
| 5061 | if (ixjdebug & 0x0001) |
| 5062 | printk("DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.high, bytes.low); |
| 5063 | return 0; |
| 5064 | } |
| 5065 | if (!SCI_Control(j, SCI_Enable_DAA)) |
| 5066 | return 0; |
| 5067 | |
| 5068 | if (!SCI_Control(j, SCI_End)) |
| 5069 | return 0; |
| 5070 | |
| 5071 | bytes.high = inb_p(j->XILINXbase + 0x03); |
| 5072 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 5073 | if (ixjdebug & 0x0002) |
| 5074 | printk("DAA CR5 Byte high = 0x%x low = 0x%x\n", bytes.high, bytes.low); |
| 5075 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg = bytes.high; |
| 5076 | return bytes.high; |
| 5077 | } |
| 5078 | |
| 5079 | static int daa_set_mode(IXJ *j, int mode) |
| 5080 | { |
| 5081 | /* NOTE: |
| 5082 | The DAA *MUST* be in the conversation mode if the |
| 5083 | PSTN line is to be seized (PSTN line off-hook). |
| 5084 | Taking the PSTN line off-hook while the DAA is in |
| 5085 | a mode other than conversation mode will cause a |
| 5086 | hardware failure of the ALIS-A part. |
| 5087 | |
| 5088 | NOTE: |
| 5089 | The DAA can only go to SLEEP, RINGING or PULSEDIALING modes |
| 5090 | if the PSTN line is on-hook. Failure to have the PSTN line |
| 5091 | in the on-hook state WILL CAUSE A HARDWARE FAILURE OF THE |
| 5092 | ALIS-A part. |
| 5093 | */ |
| 5094 | |
| 5095 | BYTES bytes; |
| 5096 | |
| 5097 | j->flags.pstn_rmr = 0; |
| 5098 | |
| 5099 | if (!SCI_Prepare(j)) |
| 5100 | return 0; |
| 5101 | |
| 5102 | switch (mode) { |
| 5103 | case SOP_PU_RESET: |
| 5104 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 5105 | |
| 5106 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5107 | j->pld_slicw.bits.rly2 = 0; |
| 5108 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5109 | bytes.high = 0x10; |
| 5110 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5111 | daa_load(&bytes, j); |
| 5112 | if (!SCI_Prepare(j)) |
| 5113 | return 0; |
| 5114 | |
| 5115 | j->daa_mode = SOP_PU_SLEEP; |
| 5116 | break; |
| 5117 | case SOP_PU_SLEEP: |
| 5118 | if(j->daa_mode == SOP_PU_SLEEP) |
| 5119 | { |
| 5120 | break; |
| 5121 | } |
| 5122 | if (ixjdebug & 0x0008) |
| 5123 | printk(KERN_INFO "phone DAA: SOP_PU_SLEEP at %ld\n", jiffies); |
| 5124 | /* if(j->daa_mode == SOP_PU_CONVERSATION) */ |
| 5125 | { |
| 5126 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 5127 | |
| 5128 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5129 | j->pld_slicw.bits.rly2 = 0; |
| 5130 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5131 | bytes.high = 0x10; |
| 5132 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5133 | daa_load(&bytes, j); |
| 5134 | if (!SCI_Prepare(j)) |
| 5135 | return 0; |
| 5136 | } |
| 5137 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 5138 | |
| 5139 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5140 | j->pld_slicw.bits.rly2 = 0; |
| 5141 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5142 | bytes.high = 0x10; |
| 5143 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5144 | daa_load(&bytes, j); |
| 5145 | if (!SCI_Prepare(j)) |
| 5146 | return 0; |
| 5147 | |
| 5148 | j->daa_mode = SOP_PU_SLEEP; |
| 5149 | j->flags.pstn_ringing = 0; |
| 5150 | j->ex.bits.pstn_ring = 0; |
| 5151 | j->pstn_sleeptil = jiffies + (hertz / 4); |
| 5152 | wake_up_interruptible(&j->read_q); /* Wake any blocked readers */ |
| 5153 | wake_up_interruptible(&j->write_q); /* Wake any blocked writers */ |
| 5154 | wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */ |
| 5155 | break; |
| 5156 | case SOP_PU_RINGING: |
| 5157 | if (ixjdebug & 0x0008) |
| 5158 | printk(KERN_INFO "phone DAA: SOP_PU_RINGING at %ld\n", jiffies); |
| 5159 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 5160 | |
| 5161 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5162 | j->pld_slicw.bits.rly2 = 0; |
| 5163 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5164 | bytes.high = 0x50; |
| 5165 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5166 | daa_load(&bytes, j); |
| 5167 | if (!SCI_Prepare(j)) |
| 5168 | return 0; |
| 5169 | j->daa_mode = SOP_PU_RINGING; |
| 5170 | break; |
| 5171 | case SOP_PU_CONVERSATION: |
| 5172 | if (ixjdebug & 0x0008) |
| 5173 | printk(KERN_INFO "phone DAA: SOP_PU_CONVERSATION at %ld\n", jiffies); |
| 5174 | bytes.high = 0x90; |
| 5175 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5176 | daa_load(&bytes, j); |
| 5177 | if (!SCI_Prepare(j)) |
| 5178 | return 0; |
| 5179 | j->pld_slicw.bits.rly2 = 1; |
| 5180 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5181 | j->pld_scrw.bits.daafsyncen = 1; /* Turn on DAA Frame Sync */ |
| 5182 | |
| 5183 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5184 | j->daa_mode = SOP_PU_CONVERSATION; |
| 5185 | j->flags.pstn_ringing = 0; |
| 5186 | j->ex.bits.pstn_ring = 0; |
| 5187 | j->pstn_sleeptil = jiffies; |
| 5188 | j->pstn_ring_start = j->pstn_ring_stop = j->pstn_ring_int = 0; |
| 5189 | break; |
| 5190 | case SOP_PU_PULSEDIALING: |
| 5191 | if (ixjdebug & 0x0008) |
| 5192 | printk(KERN_INFO "phone DAA: SOP_PU_PULSEDIALING at %ld\n", jiffies); |
| 5193 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 5194 | |
| 5195 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5196 | j->pld_slicw.bits.rly2 = 0; |
| 5197 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 5198 | bytes.high = 0xD0; |
| 5199 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5200 | daa_load(&bytes, j); |
| 5201 | if (!SCI_Prepare(j)) |
| 5202 | return 0; |
| 5203 | j->daa_mode = SOP_PU_PULSEDIALING; |
| 5204 | break; |
| 5205 | default: |
| 5206 | break; |
| 5207 | } |
| 5208 | return 1; |
| 5209 | } |
| 5210 | |
| 5211 | static int ixj_daa_write(IXJ *j) |
| 5212 | { |
| 5213 | BYTES bytes; |
| 5214 | |
| 5215 | j->flags.pstncheck = 1; |
| 5216 | |
| 5217 | daa_set_mode(j, SOP_PU_SLEEP); |
| 5218 | |
| 5219 | if (!SCI_Prepare(j)) |
| 5220 | return 0; |
| 5221 | |
| 5222 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5223 | |
| 5224 | bytes.high = 0x14; |
| 5225 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg; |
| 5226 | if (!daa_load(&bytes, j)) |
| 5227 | return 0; |
| 5228 | |
| 5229 | bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg; |
| 5230 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg; |
| 5231 | if (!daa_load(&bytes, j)) |
| 5232 | return 0; |
| 5233 | |
| 5234 | bytes.high = j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg; |
| 5235 | bytes.low = j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg; |
| 5236 | if (!daa_load(&bytes, j)) |
| 5237 | return 0; |
| 5238 | |
| 5239 | if (!SCI_Prepare(j)) |
| 5240 | return 0; |
| 5241 | |
| 5242 | bytes.high = 0x1F; |
| 5243 | bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg; |
| 5244 | if (!daa_load(&bytes, j)) |
| 5245 | return 0; |
| 5246 | |
| 5247 | bytes.high = j->m_DAAShadowRegs.XOP_xr6_W.reg; |
| 5248 | bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg; |
| 5249 | if (!daa_load(&bytes, j)) |
| 5250 | return 0; |
| 5251 | |
| 5252 | bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg; |
| 5253 | bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg; |
| 5254 | if (!daa_load(&bytes, j)) |
| 5255 | return 0; |
| 5256 | |
| 5257 | bytes.high = j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg; |
| 5258 | bytes.low = j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg; |
| 5259 | if (!daa_load(&bytes, j)) |
| 5260 | return 0; |
| 5261 | |
| 5262 | bytes.high = j->m_DAAShadowRegs.XOP_xr0_W.reg; |
| 5263 | bytes.low = 0x00; |
| 5264 | if (!daa_load(&bytes, j)) |
| 5265 | return 0; |
| 5266 | |
| 5267 | if (!SCI_Prepare(j)) |
| 5268 | return 0; |
| 5269 | |
| 5270 | bytes.high = 0x00; |
| 5271 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7]; |
| 5272 | if (!daa_load(&bytes, j)) |
| 5273 | return 0; |
| 5274 | |
| 5275 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6]; |
| 5276 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5]; |
| 5277 | if (!daa_load(&bytes, j)) |
| 5278 | return 0; |
| 5279 | |
| 5280 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4]; |
| 5281 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3]; |
| 5282 | if (!daa_load(&bytes, j)) |
| 5283 | return 0; |
| 5284 | |
| 5285 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2]; |
| 5286 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1]; |
| 5287 | if (!daa_load(&bytes, j)) |
| 5288 | return 0; |
| 5289 | |
| 5290 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0]; |
| 5291 | bytes.low = 0x00; |
| 5292 | if (!daa_load(&bytes, j)) |
| 5293 | return 0; |
| 5294 | |
| 5295 | if (!SCI_Control(j, SCI_End)) |
| 5296 | return 0; |
| 5297 | if (!SCI_WaitLowSCI(j)) |
| 5298 | return 0; |
| 5299 | |
| 5300 | bytes.high = 0x01; |
| 5301 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7]; |
| 5302 | if (!daa_load(&bytes, j)) |
| 5303 | return 0; |
| 5304 | |
| 5305 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6]; |
| 5306 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5]; |
| 5307 | if (!daa_load(&bytes, j)) |
| 5308 | return 0; |
| 5309 | |
| 5310 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4]; |
| 5311 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3]; |
| 5312 | if (!daa_load(&bytes, j)) |
| 5313 | return 0; |
| 5314 | |
| 5315 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2]; |
| 5316 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1]; |
| 5317 | if (!daa_load(&bytes, j)) |
| 5318 | return 0; |
| 5319 | |
| 5320 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0]; |
| 5321 | bytes.low = 0x00; |
| 5322 | if (!daa_load(&bytes, j)) |
| 5323 | return 0; |
| 5324 | |
| 5325 | if (!SCI_Control(j, SCI_End)) |
| 5326 | return 0; |
| 5327 | if (!SCI_WaitLowSCI(j)) |
| 5328 | return 0; |
| 5329 | |
| 5330 | bytes.high = 0x02; |
| 5331 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7]; |
| 5332 | if (!daa_load(&bytes, j)) |
| 5333 | return 0; |
| 5334 | |
| 5335 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6]; |
| 5336 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5]; |
| 5337 | if (!daa_load(&bytes, j)) |
| 5338 | return 0; |
| 5339 | |
| 5340 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4]; |
| 5341 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3]; |
| 5342 | if (!daa_load(&bytes, j)) |
| 5343 | return 0; |
| 5344 | |
| 5345 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2]; |
| 5346 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1]; |
| 5347 | if (!daa_load(&bytes, j)) |
| 5348 | return 0; |
| 5349 | |
| 5350 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0]; |
| 5351 | bytes.low = 0x00; |
| 5352 | if (!daa_load(&bytes, j)) |
| 5353 | return 0; |
| 5354 | |
| 5355 | if (!SCI_Control(j, SCI_End)) |
| 5356 | return 0; |
| 5357 | if (!SCI_WaitLowSCI(j)) |
| 5358 | return 0; |
| 5359 | |
| 5360 | bytes.high = 0x03; |
| 5361 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7]; |
| 5362 | if (!daa_load(&bytes, j)) |
| 5363 | return 0; |
| 5364 | |
| 5365 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6]; |
| 5366 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5]; |
| 5367 | if (!daa_load(&bytes, j)) |
| 5368 | return 0; |
| 5369 | |
| 5370 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4]; |
| 5371 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3]; |
| 5372 | if (!daa_load(&bytes, j)) |
| 5373 | return 0; |
| 5374 | |
| 5375 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2]; |
| 5376 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1]; |
| 5377 | if (!daa_load(&bytes, j)) |
| 5378 | return 0; |
| 5379 | |
| 5380 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0]; |
| 5381 | bytes.low = 0x00; |
| 5382 | if (!daa_load(&bytes, j)) |
| 5383 | return 0; |
| 5384 | |
| 5385 | if (!SCI_Control(j, SCI_End)) |
| 5386 | return 0; |
| 5387 | if (!SCI_WaitLowSCI(j)) |
| 5388 | return 0; |
| 5389 | |
| 5390 | bytes.high = 0x04; |
| 5391 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7]; |
| 5392 | if (!daa_load(&bytes, j)) |
| 5393 | return 0; |
| 5394 | |
| 5395 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6]; |
| 5396 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5]; |
| 5397 | if (!daa_load(&bytes, j)) |
| 5398 | return 0; |
| 5399 | |
| 5400 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4]; |
| 5401 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3]; |
| 5402 | if (!daa_load(&bytes, j)) |
| 5403 | return 0; |
| 5404 | |
| 5405 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2]; |
| 5406 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1]; |
| 5407 | if (!daa_load(&bytes, j)) |
| 5408 | return 0; |
| 5409 | |
| 5410 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0]; |
| 5411 | bytes.low = 0x00; |
| 5412 | if (!daa_load(&bytes, j)) |
| 5413 | return 0; |
| 5414 | |
| 5415 | if (!SCI_Control(j, SCI_End)) |
| 5416 | return 0; |
| 5417 | if (!SCI_WaitLowSCI(j)) |
| 5418 | return 0; |
| 5419 | |
| 5420 | bytes.high = 0x05; |
| 5421 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7]; |
| 5422 | if (!daa_load(&bytes, j)) |
| 5423 | return 0; |
| 5424 | |
| 5425 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6]; |
| 5426 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5]; |
| 5427 | if (!daa_load(&bytes, j)) |
| 5428 | return 0; |
| 5429 | |
| 5430 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4]; |
| 5431 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3]; |
| 5432 | if (!daa_load(&bytes, j)) |
| 5433 | return 0; |
| 5434 | |
| 5435 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2]; |
| 5436 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1]; |
| 5437 | if (!daa_load(&bytes, j)) |
| 5438 | return 0; |
| 5439 | |
| 5440 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0]; |
| 5441 | bytes.low = 0x00; |
| 5442 | if (!daa_load(&bytes, j)) |
| 5443 | return 0; |
| 5444 | |
| 5445 | if (!SCI_Control(j, SCI_End)) |
| 5446 | return 0; |
| 5447 | if (!SCI_WaitLowSCI(j)) |
| 5448 | return 0; |
| 5449 | |
| 5450 | bytes.high = 0x06; |
| 5451 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7]; |
| 5452 | if (!daa_load(&bytes, j)) |
| 5453 | return 0; |
| 5454 | |
| 5455 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6]; |
| 5456 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5]; |
| 5457 | if (!daa_load(&bytes, j)) |
| 5458 | return 0; |
| 5459 | |
| 5460 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4]; |
| 5461 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3]; |
| 5462 | if (!daa_load(&bytes, j)) |
| 5463 | return 0; |
| 5464 | |
| 5465 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2]; |
| 5466 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1]; |
| 5467 | if (!daa_load(&bytes, j)) |
| 5468 | return 0; |
| 5469 | |
| 5470 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0]; |
| 5471 | bytes.low = 0x00; |
| 5472 | if (!daa_load(&bytes, j)) |
| 5473 | return 0; |
| 5474 | |
| 5475 | if (!SCI_Control(j, SCI_End)) |
| 5476 | return 0; |
| 5477 | if (!SCI_WaitLowSCI(j)) |
| 5478 | return 0; |
| 5479 | |
| 5480 | bytes.high = 0x07; |
| 5481 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7]; |
| 5482 | if (!daa_load(&bytes, j)) |
| 5483 | return 0; |
| 5484 | |
| 5485 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6]; |
| 5486 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5]; |
| 5487 | if (!daa_load(&bytes, j)) |
| 5488 | return 0; |
| 5489 | |
| 5490 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4]; |
| 5491 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3]; |
| 5492 | if (!daa_load(&bytes, j)) |
| 5493 | return 0; |
| 5494 | |
| 5495 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2]; |
| 5496 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1]; |
| 5497 | if (!daa_load(&bytes, j)) |
| 5498 | return 0; |
| 5499 | |
| 5500 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0]; |
| 5501 | bytes.low = 0x00; |
| 5502 | if (!daa_load(&bytes, j)) |
| 5503 | return 0; |
| 5504 | |
| 5505 | if (!SCI_Control(j, SCI_End)) |
| 5506 | return 0; |
| 5507 | if (!SCI_WaitLowSCI(j)) |
| 5508 | return 0; |
| 5509 | |
| 5510 | bytes.high = 0x08; |
| 5511 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7]; |
| 5512 | if (!daa_load(&bytes, j)) |
| 5513 | return 0; |
| 5514 | |
| 5515 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6]; |
| 5516 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5]; |
| 5517 | if (!daa_load(&bytes, j)) |
| 5518 | return 0; |
| 5519 | |
| 5520 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4]; |
| 5521 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3]; |
| 5522 | if (!daa_load(&bytes, j)) |
| 5523 | return 0; |
| 5524 | |
| 5525 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2]; |
| 5526 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1]; |
| 5527 | if (!daa_load(&bytes, j)) |
| 5528 | return 0; |
| 5529 | |
| 5530 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0]; |
| 5531 | bytes.low = 0x00; |
| 5532 | if (!daa_load(&bytes, j)) |
| 5533 | return 0; |
| 5534 | |
| 5535 | if (!SCI_Control(j, SCI_End)) |
| 5536 | return 0; |
| 5537 | if (!SCI_WaitLowSCI(j)) |
| 5538 | return 0; |
| 5539 | |
| 5540 | bytes.high = 0x09; |
| 5541 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3]; |
| 5542 | if (!daa_load(&bytes, j)) |
| 5543 | return 0; |
| 5544 | |
| 5545 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2]; |
| 5546 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1]; |
| 5547 | if (!daa_load(&bytes, j)) |
| 5548 | return 0; |
| 5549 | |
| 5550 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0]; |
| 5551 | bytes.low = 0x00; |
| 5552 | if (!daa_load(&bytes, j)) |
| 5553 | return 0; |
| 5554 | |
| 5555 | if (!SCI_Control(j, SCI_End)) |
| 5556 | return 0; |
| 5557 | if (!SCI_WaitLowSCI(j)) |
| 5558 | return 0; |
| 5559 | |
| 5560 | bytes.high = 0x0A; |
| 5561 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3]; |
| 5562 | if (!daa_load(&bytes, j)) |
| 5563 | return 0; |
| 5564 | |
| 5565 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2]; |
| 5566 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1]; |
| 5567 | if (!daa_load(&bytes, j)) |
| 5568 | return 0; |
| 5569 | |
| 5570 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0]; |
| 5571 | bytes.low = 0x00; |
| 5572 | if (!daa_load(&bytes, j)) |
| 5573 | return 0; |
| 5574 | |
| 5575 | if (!SCI_Control(j, SCI_End)) |
| 5576 | return 0; |
| 5577 | if (!SCI_WaitLowSCI(j)) |
| 5578 | return 0; |
| 5579 | |
| 5580 | bytes.high = 0x0B; |
| 5581 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3]; |
| 5582 | if (!daa_load(&bytes, j)) |
| 5583 | return 0; |
| 5584 | |
| 5585 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2]; |
| 5586 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1]; |
| 5587 | if (!daa_load(&bytes, j)) |
| 5588 | return 0; |
| 5589 | |
| 5590 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0]; |
| 5591 | bytes.low = 0x00; |
| 5592 | if (!daa_load(&bytes, j)) |
| 5593 | return 0; |
| 5594 | |
| 5595 | if (!SCI_Control(j, SCI_End)) |
| 5596 | return 0; |
| 5597 | if (!SCI_WaitLowSCI(j)) |
| 5598 | return 0; |
| 5599 | |
| 5600 | bytes.high = 0x0C; |
| 5601 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3]; |
| 5602 | if (!daa_load(&bytes, j)) |
| 5603 | return 0; |
| 5604 | |
| 5605 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2]; |
| 5606 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1]; |
| 5607 | if (!daa_load(&bytes, j)) |
| 5608 | return 0; |
| 5609 | |
| 5610 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0]; |
| 5611 | bytes.low = 0x00; |
| 5612 | if (!daa_load(&bytes, j)) |
| 5613 | return 0; |
| 5614 | |
| 5615 | if (!SCI_Control(j, SCI_End)) |
| 5616 | return 0; |
| 5617 | if (!SCI_WaitLowSCI(j)) |
| 5618 | return 0; |
| 5619 | |
| 5620 | bytes.high = 0x0D; |
| 5621 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3]; |
| 5622 | if (!daa_load(&bytes, j)) |
| 5623 | return 0; |
| 5624 | |
| 5625 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2]; |
| 5626 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1]; |
| 5627 | if (!daa_load(&bytes, j)) |
| 5628 | return 0; |
| 5629 | |
| 5630 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0]; |
| 5631 | bytes.low = 0x00; |
| 5632 | if (!daa_load(&bytes, j)) |
| 5633 | return 0; |
| 5634 | |
| 5635 | if (!SCI_Control(j, SCI_End)) |
| 5636 | return 0; |
| 5637 | if (!SCI_WaitLowSCI(j)) |
| 5638 | return 0; |
| 5639 | |
| 5640 | bytes.high = 0x0E; |
| 5641 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7]; |
| 5642 | if (!daa_load(&bytes, j)) |
| 5643 | return 0; |
| 5644 | |
| 5645 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6]; |
| 5646 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5]; |
| 5647 | if (!daa_load(&bytes, j)) |
| 5648 | return 0; |
| 5649 | |
| 5650 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4]; |
| 5651 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3]; |
| 5652 | if (!daa_load(&bytes, j)) |
| 5653 | return 0; |
| 5654 | |
| 5655 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2]; |
| 5656 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1]; |
| 5657 | if (!daa_load(&bytes, j)) |
| 5658 | return 0; |
| 5659 | |
| 5660 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0]; |
| 5661 | bytes.low = 0x00; |
| 5662 | if (!daa_load(&bytes, j)) |
| 5663 | return 0; |
| 5664 | |
| 5665 | if (!SCI_Control(j, SCI_End)) |
| 5666 | return 0; |
| 5667 | if (!SCI_WaitLowSCI(j)) |
| 5668 | return 0; |
| 5669 | |
| 5670 | bytes.high = 0x0F; |
| 5671 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7]; |
| 5672 | if (!daa_load(&bytes, j)) |
| 5673 | return 0; |
| 5674 | |
| 5675 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6]; |
| 5676 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5]; |
| 5677 | if (!daa_load(&bytes, j)) |
| 5678 | return 0; |
| 5679 | |
| 5680 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4]; |
| 5681 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3]; |
| 5682 | if (!daa_load(&bytes, j)) |
| 5683 | return 0; |
| 5684 | |
| 5685 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2]; |
| 5686 | bytes.low = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1]; |
| 5687 | if (!daa_load(&bytes, j)) |
| 5688 | return 0; |
| 5689 | |
| 5690 | bytes.high = j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0]; |
| 5691 | bytes.low = 0x00; |
| 5692 | if (!daa_load(&bytes, j)) |
| 5693 | return 0; |
| 5694 | |
| 5695 | udelay(32); |
| 5696 | j->pld_scrr.byte = inb_p(j->XILINXbase); |
| 5697 | if (!SCI_Control(j, SCI_End)) |
| 5698 | return 0; |
| 5699 | |
| 5700 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 5701 | |
| 5702 | if (ixjdebug & 0x0002) |
| 5703 | printk("DAA Coefficients Loaded\n"); |
| 5704 | |
| 5705 | j->flags.pstncheck = 0; |
| 5706 | return 1; |
| 5707 | } |
| 5708 | |
| 5709 | int ixj_set_tone_off(unsigned short arg, IXJ *j) |
| 5710 | { |
| 5711 | j->tone_off_time = arg; |
| 5712 | if (ixj_WriteDSPCommand(0x6E05, j)) /* Set Tone Off Period */ |
| 5713 | |
| 5714 | return -1; |
| 5715 | if (ixj_WriteDSPCommand(arg, j)) |
| 5716 | return -1; |
| 5717 | return 0; |
| 5718 | } |
| 5719 | |
| 5720 | static int ixj_get_tone_on(IXJ *j) |
| 5721 | { |
| 5722 | if (ixj_WriteDSPCommand(0x6E06, j)) /* Get Tone On Period */ |
| 5723 | |
| 5724 | return -1; |
| 5725 | return 0; |
| 5726 | } |
| 5727 | |
| 5728 | static int ixj_get_tone_off(IXJ *j) |
| 5729 | { |
| 5730 | if (ixj_WriteDSPCommand(0x6E07, j)) /* Get Tone Off Period */ |
| 5731 | |
| 5732 | return -1; |
| 5733 | return 0; |
| 5734 | } |
| 5735 | |
| 5736 | static void ixj_busytone(IXJ *j) |
| 5737 | { |
| 5738 | j->flags.ringback = 0; |
| 5739 | j->flags.dialtone = 0; |
| 5740 | j->flags.busytone = 1; |
| 5741 | ixj_set_tone_on(0x07D0, j); |
| 5742 | ixj_set_tone_off(0x07D0, j); |
| 5743 | ixj_play_tone(j, 27); |
| 5744 | } |
| 5745 | |
| 5746 | static void ixj_dialtone(IXJ *j) |
| 5747 | { |
| 5748 | j->flags.ringback = 0; |
| 5749 | j->flags.dialtone = 1; |
| 5750 | j->flags.busytone = 0; |
| 5751 | if (j->dsp.low == 0x20) { |
| 5752 | return; |
| 5753 | } else { |
| 5754 | ixj_set_tone_on(0xFFFF, j); |
| 5755 | ixj_set_tone_off(0x0000, j); |
| 5756 | ixj_play_tone(j, 25); |
| 5757 | } |
| 5758 | } |
| 5759 | |
| 5760 | static void ixj_cpt_stop(IXJ *j) |
| 5761 | { |
| 5762 | if(j->tone_state || j->tone_cadence_state) |
| 5763 | { |
| 5764 | j->flags.dialtone = 0; |
| 5765 | j->flags.busytone = 0; |
| 5766 | j->flags.ringback = 0; |
| 5767 | ixj_set_tone_on(0x0001, j); |
| 5768 | ixj_set_tone_off(0x0000, j); |
| 5769 | ixj_play_tone(j, 0); |
| 5770 | j->tone_state = j->tone_cadence_state = 0; |
| 5771 | if (j->cadence_t) { |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 5772 | kfree(j->cadence_t->ce); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5773 | kfree(j->cadence_t); |
| 5774 | j->cadence_t = NULL; |
| 5775 | } |
| 5776 | } |
| 5777 | if (j->play_mode == -1 && j->rec_mode == -1) |
| 5778 | idle(j); |
| 5779 | if (j->play_mode != -1 && j->dsp.low == 0x20) |
| 5780 | ixj_play_start(j); |
| 5781 | if (j->rec_mode != -1 && j->dsp.low == 0x20) |
| 5782 | ixj_record_start(j); |
| 5783 | } |
| 5784 | |
| 5785 | static void ixj_ringback(IXJ *j) |
| 5786 | { |
| 5787 | j->flags.busytone = 0; |
| 5788 | j->flags.dialtone = 0; |
| 5789 | j->flags.ringback = 1; |
| 5790 | ixj_set_tone_on(0x0FA0, j); |
| 5791 | ixj_set_tone_off(0x2EE0, j); |
| 5792 | ixj_play_tone(j, 26); |
| 5793 | } |
| 5794 | |
| 5795 | static void ixj_testram(IXJ *j) |
| 5796 | { |
| 5797 | ixj_WriteDSPCommand(0x3001, j); /* Test External SRAM */ |
| 5798 | } |
| 5799 | |
| 5800 | static int ixj_build_cadence(IXJ *j, IXJ_CADENCE __user * cp) |
| 5801 | { |
| 5802 | ixj_cadence *lcp; |
| 5803 | IXJ_CADENCE_ELEMENT __user *cep; |
| 5804 | IXJ_CADENCE_ELEMENT *lcep; |
| 5805 | IXJ_TONE ti; |
| 5806 | int err; |
| 5807 | |
| 5808 | lcp = kmalloc(sizeof(ixj_cadence), GFP_KERNEL); |
| 5809 | if (lcp == NULL) |
| 5810 | return -ENOMEM; |
| 5811 | |
| 5812 | err = -EFAULT; |
| 5813 | if (copy_from_user(&lcp->elements_used, |
| 5814 | &cp->elements_used, sizeof(int))) |
| 5815 | goto out; |
| 5816 | if (copy_from_user(&lcp->termination, |
| 5817 | &cp->termination, sizeof(IXJ_CADENCE_TERM))) |
| 5818 | goto out; |
| 5819 | if (get_user(cep, &cp->ce)) |
| 5820 | goto out; |
| 5821 | |
| 5822 | err = -EINVAL; |
| 5823 | if ((unsigned)lcp->elements_used >= ~0U/sizeof(IXJ_CADENCE_ELEMENT)) |
| 5824 | goto out; |
| 5825 | |
| 5826 | err = -ENOMEM; |
| 5827 | lcep = kmalloc(sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used, GFP_KERNEL); |
| 5828 | if (!lcep) |
| 5829 | goto out; |
| 5830 | |
| 5831 | err = -EFAULT; |
| 5832 | if (copy_from_user(lcep, cep, sizeof(IXJ_CADENCE_ELEMENT) * lcp->elements_used)) |
| 5833 | goto out1; |
| 5834 | |
| 5835 | if (j->cadence_t) { |
| 5836 | kfree(j->cadence_t->ce); |
| 5837 | kfree(j->cadence_t); |
| 5838 | } |
| 5839 | lcp->ce = (void *) lcep; |
| 5840 | j->cadence_t = lcp; |
| 5841 | j->tone_cadence_state = 0; |
| 5842 | ixj_set_tone_on(lcp->ce[0].tone_on_time, j); |
| 5843 | ixj_set_tone_off(lcp->ce[0].tone_off_time, j); |
| 5844 | if (j->cadence_t->ce[j->tone_cadence_state].freq0) { |
| 5845 | ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index; |
| 5846 | ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0; |
| 5847 | ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0; |
| 5848 | ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1; |
| 5849 | ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1; |
| 5850 | ixj_init_tone(j, &ti); |
| 5851 | } |
| 5852 | ixj_play_tone(j, lcp->ce[0].index); |
| 5853 | return 1; |
| 5854 | out1: |
| 5855 | kfree(lcep); |
| 5856 | out: |
| 5857 | kfree(lcp); |
| 5858 | return err; |
| 5859 | } |
| 5860 | |
| 5861 | static int ixj_build_filter_cadence(IXJ *j, IXJ_FILTER_CADENCE __user * cp) |
| 5862 | { |
| 5863 | IXJ_FILTER_CADENCE *lcp; |
| 5864 | lcp = kmalloc(sizeof(IXJ_FILTER_CADENCE), GFP_KERNEL); |
| 5865 | if (lcp == NULL) { |
| 5866 | if(ixjdebug & 0x0001) { |
| 5867 | printk(KERN_INFO "Could not allocate memory for cadence\n"); |
| 5868 | } |
| 5869 | return -ENOMEM; |
| 5870 | } |
| 5871 | if (copy_from_user(lcp, cp, sizeof(IXJ_FILTER_CADENCE))) { |
| 5872 | if(ixjdebug & 0x0001) { |
| 5873 | printk(KERN_INFO "Could not copy cadence to kernel\n"); |
| 5874 | } |
| 5875 | kfree(lcp); |
| 5876 | return -EFAULT; |
| 5877 | } |
| 5878 | if (lcp->filter > 5) { |
| 5879 | if(ixjdebug & 0x0001) { |
| 5880 | printk(KERN_INFO "Cadence out of range\n"); |
| 5881 | } |
| 5882 | kfree(lcp); |
| 5883 | return -1; |
| 5884 | } |
| 5885 | j->cadence_f[lcp->filter].state = 0; |
| 5886 | j->cadence_f[lcp->filter].enable = lcp->enable; |
| 5887 | j->filter_en[lcp->filter] = j->cadence_f[lcp->filter].en_filter = lcp->en_filter; |
| 5888 | j->cadence_f[lcp->filter].on1 = lcp->on1; |
| 5889 | j->cadence_f[lcp->filter].on1min = 0; |
| 5890 | j->cadence_f[lcp->filter].on1max = 0; |
| 5891 | j->cadence_f[lcp->filter].off1 = lcp->off1; |
| 5892 | j->cadence_f[lcp->filter].off1min = 0; |
| 5893 | j->cadence_f[lcp->filter].off1max = 0; |
| 5894 | j->cadence_f[lcp->filter].on2 = lcp->on2; |
| 5895 | j->cadence_f[lcp->filter].on2min = 0; |
| 5896 | j->cadence_f[lcp->filter].on2max = 0; |
| 5897 | j->cadence_f[lcp->filter].off2 = lcp->off2; |
| 5898 | j->cadence_f[lcp->filter].off2min = 0; |
| 5899 | j->cadence_f[lcp->filter].off2max = 0; |
| 5900 | j->cadence_f[lcp->filter].on3 = lcp->on3; |
| 5901 | j->cadence_f[lcp->filter].on3min = 0; |
| 5902 | j->cadence_f[lcp->filter].on3max = 0; |
| 5903 | j->cadence_f[lcp->filter].off3 = lcp->off3; |
| 5904 | j->cadence_f[lcp->filter].off3min = 0; |
| 5905 | j->cadence_f[lcp->filter].off3max = 0; |
| 5906 | if(ixjdebug & 0x0002) { |
| 5907 | printk(KERN_INFO "Cadence %d loaded\n", lcp->filter); |
| 5908 | } |
| 5909 | kfree(lcp); |
| 5910 | return 0; |
| 5911 | } |
| 5912 | |
| 5913 | static void add_caps(IXJ *j) |
| 5914 | { |
| 5915 | j->caps = 0; |
| 5916 | j->caplist[j->caps].cap = PHONE_VENDOR_QUICKNET; |
| 5917 | strcpy(j->caplist[j->caps].desc, "Quicknet Technologies, Inc. (www.quicknet.net)"); |
| 5918 | j->caplist[j->caps].captype = vendor; |
| 5919 | j->caplist[j->caps].handle = j->caps++; |
| 5920 | j->caplist[j->caps].captype = device; |
| 5921 | switch (j->cardtype) { |
| 5922 | case QTI_PHONEJACK: |
| 5923 | strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK"); |
| 5924 | break; |
| 5925 | case QTI_LINEJACK: |
| 5926 | strcpy(j->caplist[j->caps].desc, "Quicknet Internet LineJACK"); |
| 5927 | break; |
| 5928 | case QTI_PHONEJACK_LITE: |
| 5929 | strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK Lite"); |
| 5930 | break; |
| 5931 | case QTI_PHONEJACK_PCI: |
| 5932 | strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneJACK PCI"); |
| 5933 | break; |
| 5934 | case QTI_PHONECARD: |
| 5935 | strcpy(j->caplist[j->caps].desc, "Quicknet Internet PhoneCARD"); |
| 5936 | break; |
| 5937 | } |
| 5938 | j->caplist[j->caps].cap = j->cardtype; |
| 5939 | j->caplist[j->caps].handle = j->caps++; |
| 5940 | strcpy(j->caplist[j->caps].desc, "POTS"); |
| 5941 | j->caplist[j->caps].captype = port; |
| 5942 | j->caplist[j->caps].cap = pots; |
| 5943 | j->caplist[j->caps].handle = j->caps++; |
| 5944 | |
| 5945 | /* add devices that can do speaker/mic */ |
| 5946 | switch (j->cardtype) { |
| 5947 | case QTI_PHONEJACK: |
| 5948 | case QTI_LINEJACK: |
| 5949 | case QTI_PHONEJACK_PCI: |
| 5950 | case QTI_PHONECARD: |
| 5951 | strcpy(j->caplist[j->caps].desc, "SPEAKER"); |
| 5952 | j->caplist[j->caps].captype = port; |
| 5953 | j->caplist[j->caps].cap = speaker; |
| 5954 | j->caplist[j->caps].handle = j->caps++; |
| 5955 | default: |
| 5956 | break; |
| 5957 | } |
| 5958 | |
| 5959 | /* add devices that can do handset */ |
| 5960 | switch (j->cardtype) { |
| 5961 | case QTI_PHONEJACK: |
| 5962 | strcpy(j->caplist[j->caps].desc, "HANDSET"); |
| 5963 | j->caplist[j->caps].captype = port; |
| 5964 | j->caplist[j->caps].cap = handset; |
| 5965 | j->caplist[j->caps].handle = j->caps++; |
| 5966 | break; |
| 5967 | default: |
| 5968 | break; |
| 5969 | } |
| 5970 | |
| 5971 | /* add devices that can do PSTN */ |
| 5972 | switch (j->cardtype) { |
| 5973 | case QTI_LINEJACK: |
| 5974 | strcpy(j->caplist[j->caps].desc, "PSTN"); |
| 5975 | j->caplist[j->caps].captype = port; |
| 5976 | j->caplist[j->caps].cap = pstn; |
| 5977 | j->caplist[j->caps].handle = j->caps++; |
| 5978 | break; |
| 5979 | default: |
| 5980 | break; |
| 5981 | } |
| 5982 | |
| 5983 | /* add codecs - all cards can do uLaw, linear 8/16, and Windows sound system */ |
| 5984 | strcpy(j->caplist[j->caps].desc, "ULAW"); |
| 5985 | j->caplist[j->caps].captype = codec; |
| 5986 | j->caplist[j->caps].cap = ULAW; |
| 5987 | j->caplist[j->caps].handle = j->caps++; |
| 5988 | |
| 5989 | strcpy(j->caplist[j->caps].desc, "LINEAR 16 bit"); |
| 5990 | j->caplist[j->caps].captype = codec; |
| 5991 | j->caplist[j->caps].cap = LINEAR16; |
| 5992 | j->caplist[j->caps].handle = j->caps++; |
| 5993 | |
| 5994 | strcpy(j->caplist[j->caps].desc, "LINEAR 8 bit"); |
| 5995 | j->caplist[j->caps].captype = codec; |
| 5996 | j->caplist[j->caps].cap = LINEAR8; |
| 5997 | j->caplist[j->caps].handle = j->caps++; |
| 5998 | |
| 5999 | strcpy(j->caplist[j->caps].desc, "Windows Sound System"); |
| 6000 | j->caplist[j->caps].captype = codec; |
| 6001 | j->caplist[j->caps].cap = WSS; |
| 6002 | j->caplist[j->caps].handle = j->caps++; |
| 6003 | |
| 6004 | /* software ALAW codec, made from ULAW */ |
| 6005 | strcpy(j->caplist[j->caps].desc, "ALAW"); |
| 6006 | j->caplist[j->caps].captype = codec; |
| 6007 | j->caplist[j->caps].cap = ALAW; |
| 6008 | j->caplist[j->caps].handle = j->caps++; |
| 6009 | |
| 6010 | /* version 12 of the 8020 does the following codecs in a broken way */ |
| 6011 | if (j->dsp.low != 0x20 || j->ver.low != 0x12) { |
| 6012 | strcpy(j->caplist[j->caps].desc, "G.723.1 6.3kbps"); |
| 6013 | j->caplist[j->caps].captype = codec; |
| 6014 | j->caplist[j->caps].cap = G723_63; |
| 6015 | j->caplist[j->caps].handle = j->caps++; |
| 6016 | |
| 6017 | strcpy(j->caplist[j->caps].desc, "G.723.1 5.3kbps"); |
| 6018 | j->caplist[j->caps].captype = codec; |
| 6019 | j->caplist[j->caps].cap = G723_53; |
| 6020 | j->caplist[j->caps].handle = j->caps++; |
| 6021 | |
| 6022 | strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.8kbps"); |
| 6023 | j->caplist[j->caps].captype = codec; |
| 6024 | j->caplist[j->caps].cap = TS48; |
| 6025 | j->caplist[j->caps].handle = j->caps++; |
| 6026 | |
| 6027 | strcpy(j->caplist[j->caps].desc, "TrueSpeech 4.1kbps"); |
| 6028 | j->caplist[j->caps].captype = codec; |
| 6029 | j->caplist[j->caps].cap = TS41; |
| 6030 | j->caplist[j->caps].handle = j->caps++; |
| 6031 | } |
| 6032 | |
| 6033 | /* 8020 chips can do TS8.5 native, and 8021/8022 can load it */ |
| 6034 | if (j->dsp.low == 0x20 || j->flags.ts85_loaded) { |
| 6035 | strcpy(j->caplist[j->caps].desc, "TrueSpeech 8.5kbps"); |
| 6036 | j->caplist[j->caps].captype = codec; |
| 6037 | j->caplist[j->caps].cap = TS85; |
| 6038 | j->caplist[j->caps].handle = j->caps++; |
| 6039 | } |
| 6040 | |
| 6041 | /* 8021 chips can do G728 */ |
| 6042 | if (j->dsp.low == 0x21) { |
| 6043 | strcpy(j->caplist[j->caps].desc, "G.728 16kbps"); |
| 6044 | j->caplist[j->caps].captype = codec; |
| 6045 | j->caplist[j->caps].cap = G728; |
| 6046 | j->caplist[j->caps].handle = j->caps++; |
| 6047 | } |
| 6048 | |
| 6049 | /* 8021/8022 chips can do G729 if loaded */ |
| 6050 | if (j->dsp.low != 0x20 && j->flags.g729_loaded) { |
| 6051 | strcpy(j->caplist[j->caps].desc, "G.729A 8kbps"); |
| 6052 | j->caplist[j->caps].captype = codec; |
| 6053 | j->caplist[j->caps].cap = G729; |
| 6054 | j->caplist[j->caps].handle = j->caps++; |
| 6055 | } |
| 6056 | if (j->dsp.low != 0x20 && j->flags.g729_loaded) { |
| 6057 | strcpy(j->caplist[j->caps].desc, "G.729B 8kbps"); |
| 6058 | j->caplist[j->caps].captype = codec; |
| 6059 | j->caplist[j->caps].cap = G729B; |
| 6060 | j->caplist[j->caps].handle = j->caps++; |
| 6061 | } |
| 6062 | } |
| 6063 | |
| 6064 | static int capabilities_check(IXJ *j, struct phone_capability *pcreq) |
| 6065 | { |
| 6066 | int cnt; |
| 6067 | int retval = 0; |
| 6068 | for (cnt = 0; cnt < j->caps; cnt++) { |
| 6069 | if (pcreq->captype == j->caplist[cnt].captype |
| 6070 | && pcreq->cap == j->caplist[cnt].cap) { |
| 6071 | retval = 1; |
| 6072 | break; |
| 6073 | } |
| 6074 | } |
| 6075 | return retval; |
| 6076 | } |
| 6077 | |
| 6078 | static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, unsigned long arg) |
| 6079 | { |
| 6080 | IXJ_TONE ti; |
| 6081 | IXJ_FILTER jf; |
| 6082 | IXJ_FILTER_RAW jfr; |
| 6083 | void __user *argp = (void __user *)arg; |
| 6084 | |
| 6085 | unsigned int raise, mant; |
| 6086 | unsigned int minor = iminor(inode); |
| 6087 | int board = NUM(inode); |
| 6088 | |
| 6089 | IXJ *j = get_ixj(NUM(inode)); |
| 6090 | |
| 6091 | int retval = 0; |
| 6092 | |
| 6093 | /* |
| 6094 | * Set up locks to ensure that only one process is talking to the DSP at a time. |
| 6095 | * This is necessary to keep the DSP from locking up. |
| 6096 | */ |
Nishanth Aravamudan | 1e63bc7 | 2005-09-10 00:27:31 -0700 | [diff] [blame] | 6097 | while(test_and_set_bit(board, (void *)&j->busyflags) != 0) |
| 6098 | schedule_timeout_interruptible(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6099 | if (ixjdebug & 0x0040) |
| 6100 | printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg); |
| 6101 | if (minor >= IXJMAX) { |
| 6102 | clear_bit(board, &j->busyflags); |
| 6103 | return -ENODEV; |
| 6104 | } |
| 6105 | /* |
| 6106 | * Check ioctls only root can use. |
| 6107 | */ |
| 6108 | if (!capable(CAP_SYS_ADMIN)) { |
| 6109 | switch (cmd) { |
| 6110 | case IXJCTL_TESTRAM: |
| 6111 | case IXJCTL_HZ: |
| 6112 | retval = -EPERM; |
| 6113 | } |
| 6114 | } |
| 6115 | switch (cmd) { |
| 6116 | case IXJCTL_TESTRAM: |
| 6117 | ixj_testram(j); |
| 6118 | retval = (j->ssr.high << 8) + j->ssr.low; |
| 6119 | break; |
| 6120 | case IXJCTL_CARDTYPE: |
| 6121 | retval = j->cardtype; |
| 6122 | break; |
| 6123 | case IXJCTL_SERIAL: |
| 6124 | retval = j->serial; |
| 6125 | break; |
| 6126 | case IXJCTL_VERSION: |
Domen Puncer | fba478b | 2005-05-05 16:16:13 -0700 | [diff] [blame] | 6127 | { |
| 6128 | char arg_str[100]; |
| 6129 | snprintf(arg_str, sizeof(arg_str), |
| 6130 | "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, |
| 6131 | IXJ_VER_MINOR, IXJ_BLD_VER); |
| 6132 | if (copy_to_user(argp, arg_str, strlen(arg_str))) |
| 6133 | retval = -EFAULT; |
| 6134 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6135 | break; |
| 6136 | case PHONE_RING_CADENCE: |
| 6137 | j->ring_cadence = arg; |
| 6138 | break; |
| 6139 | case IXJCTL_CIDCW: |
| 6140 | if(arg) { |
| 6141 | if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) { |
| 6142 | retval = -EFAULT; |
| 6143 | break; |
| 6144 | } |
| 6145 | } else { |
| 6146 | memset(&j->cid_send, 0, sizeof(PHONE_CID)); |
| 6147 | } |
| 6148 | ixj_write_cidcw(j); |
| 6149 | break; |
| 6150 | /* Binary compatbility */ |
| 6151 | case OLD_PHONE_RING_START: |
| 6152 | arg = 0; |
| 6153 | /* Fall through */ |
| 6154 | case PHONE_RING_START: |
| 6155 | if(arg) { |
| 6156 | if (copy_from_user(&j->cid_send, argp, sizeof(PHONE_CID))) { |
| 6157 | retval = -EFAULT; |
| 6158 | break; |
| 6159 | } |
| 6160 | ixj_write_cid(j); |
| 6161 | } else { |
| 6162 | memset(&j->cid_send, 0, sizeof(PHONE_CID)); |
| 6163 | } |
| 6164 | ixj_ring_start(j); |
| 6165 | break; |
| 6166 | case PHONE_RING_STOP: |
| 6167 | j->flags.cringing = 0; |
| 6168 | if(j->cadence_f[5].enable) { |
| 6169 | j->cadence_f[5].state = 0; |
| 6170 | } |
| 6171 | ixj_ring_off(j); |
| 6172 | break; |
| 6173 | case PHONE_RING: |
| 6174 | retval = ixj_ring(j); |
| 6175 | break; |
| 6176 | case PHONE_EXCEPTION: |
| 6177 | retval = j->ex.bytes; |
| 6178 | if(j->ex.bits.flash) { |
| 6179 | j->flash_end = 0; |
| 6180 | j->ex.bits.flash = 0; |
| 6181 | } |
| 6182 | j->ex.bits.pstn_ring = 0; |
| 6183 | j->ex.bits.caller_id = 0; |
| 6184 | j->ex.bits.pstn_wink = 0; |
| 6185 | j->ex.bits.f0 = 0; |
| 6186 | j->ex.bits.f1 = 0; |
| 6187 | j->ex.bits.f2 = 0; |
| 6188 | j->ex.bits.f3 = 0; |
| 6189 | j->ex.bits.fc0 = 0; |
| 6190 | j->ex.bits.fc1 = 0; |
| 6191 | j->ex.bits.fc2 = 0; |
| 6192 | j->ex.bits.fc3 = 0; |
| 6193 | j->ex.bits.reserved = 0; |
| 6194 | break; |
| 6195 | case PHONE_HOOKSTATE: |
| 6196 | j->ex.bits.hookstate = 0; |
| 6197 | retval = j->hookstate; //j->r_hook; |
| 6198 | break; |
| 6199 | case IXJCTL_SET_LED: |
| 6200 | LED_SetState(arg, j); |
| 6201 | break; |
| 6202 | case PHONE_FRAME: |
| 6203 | retval = set_base_frame(j, arg); |
| 6204 | break; |
| 6205 | case PHONE_REC_CODEC: |
| 6206 | retval = set_rec_codec(j, arg); |
| 6207 | break; |
| 6208 | case PHONE_VAD: |
| 6209 | ixj_vad(j, arg); |
| 6210 | break; |
| 6211 | case PHONE_REC_START: |
| 6212 | ixj_record_start(j); |
| 6213 | break; |
| 6214 | case PHONE_REC_STOP: |
| 6215 | ixj_record_stop(j); |
| 6216 | break; |
| 6217 | case PHONE_REC_DEPTH: |
| 6218 | set_rec_depth(j, arg); |
| 6219 | break; |
| 6220 | case PHONE_REC_VOLUME: |
| 6221 | if(arg == -1) { |
| 6222 | retval = get_rec_volume(j); |
| 6223 | } |
| 6224 | else { |
| 6225 | set_rec_volume(j, arg); |
| 6226 | retval = arg; |
| 6227 | } |
| 6228 | break; |
| 6229 | case PHONE_REC_VOLUME_LINEAR: |
| 6230 | if(arg == -1) { |
| 6231 | retval = get_rec_volume_linear(j); |
| 6232 | } |
| 6233 | else { |
| 6234 | set_rec_volume_linear(j, arg); |
| 6235 | retval = arg; |
| 6236 | } |
| 6237 | break; |
| 6238 | case IXJCTL_DTMF_PRESCALE: |
| 6239 | if(arg == -1) { |
| 6240 | retval = get_dtmf_prescale(j); |
| 6241 | } |
| 6242 | else { |
| 6243 | set_dtmf_prescale(j, arg); |
| 6244 | retval = arg; |
| 6245 | } |
| 6246 | break; |
| 6247 | case PHONE_REC_LEVEL: |
| 6248 | retval = get_rec_level(j); |
| 6249 | break; |
| 6250 | case IXJCTL_SC_RXG: |
| 6251 | retval = ixj_siadc(j, arg); |
| 6252 | break; |
| 6253 | case IXJCTL_SC_TXG: |
| 6254 | retval = ixj_sidac(j, arg); |
| 6255 | break; |
| 6256 | case IXJCTL_AEC_START: |
| 6257 | ixj_aec_start(j, arg); |
| 6258 | break; |
| 6259 | case IXJCTL_AEC_STOP: |
| 6260 | aec_stop(j); |
| 6261 | break; |
| 6262 | case IXJCTL_AEC_GET_LEVEL: |
| 6263 | retval = j->aec_level; |
| 6264 | break; |
| 6265 | case PHONE_PLAY_CODEC: |
| 6266 | retval = set_play_codec(j, arg); |
| 6267 | break; |
| 6268 | case PHONE_PLAY_START: |
| 6269 | retval = ixj_play_start(j); |
| 6270 | break; |
| 6271 | case PHONE_PLAY_STOP: |
| 6272 | ixj_play_stop(j); |
| 6273 | break; |
| 6274 | case PHONE_PLAY_DEPTH: |
| 6275 | set_play_depth(j, arg); |
| 6276 | break; |
| 6277 | case PHONE_PLAY_VOLUME: |
| 6278 | if(arg == -1) { |
| 6279 | retval = get_play_volume(j); |
| 6280 | } |
| 6281 | else { |
| 6282 | set_play_volume(j, arg); |
| 6283 | retval = arg; |
| 6284 | } |
| 6285 | break; |
| 6286 | case PHONE_PLAY_VOLUME_LINEAR: |
| 6287 | if(arg == -1) { |
| 6288 | retval = get_play_volume_linear(j); |
| 6289 | } |
| 6290 | else { |
| 6291 | set_play_volume_linear(j, arg); |
| 6292 | retval = arg; |
| 6293 | } |
| 6294 | break; |
| 6295 | case PHONE_PLAY_LEVEL: |
| 6296 | retval = get_play_level(j); |
| 6297 | break; |
| 6298 | case IXJCTL_DSP_TYPE: |
| 6299 | retval = (j->dsp.high << 8) + j->dsp.low; |
| 6300 | break; |
| 6301 | case IXJCTL_DSP_VERSION: |
| 6302 | retval = (j->ver.high << 8) + j->ver.low; |
| 6303 | break; |
| 6304 | case IXJCTL_HZ: |
| 6305 | hertz = arg; |
| 6306 | break; |
| 6307 | case IXJCTL_RATE: |
| 6308 | if (arg > hertz) |
| 6309 | retval = -1; |
| 6310 | else |
| 6311 | samplerate = arg; |
| 6312 | break; |
| 6313 | case IXJCTL_DRYBUFFER_READ: |
| 6314 | put_user(j->drybuffer, (unsigned long __user *) argp); |
| 6315 | break; |
| 6316 | case IXJCTL_DRYBUFFER_CLEAR: |
| 6317 | j->drybuffer = 0; |
| 6318 | break; |
| 6319 | case IXJCTL_FRAMES_READ: |
| 6320 | put_user(j->framesread, (unsigned long __user *) argp); |
| 6321 | break; |
| 6322 | case IXJCTL_FRAMES_WRITTEN: |
| 6323 | put_user(j->frameswritten, (unsigned long __user *) argp); |
| 6324 | break; |
| 6325 | case IXJCTL_READ_WAIT: |
| 6326 | put_user(j->read_wait, (unsigned long __user *) argp); |
| 6327 | break; |
| 6328 | case IXJCTL_WRITE_WAIT: |
| 6329 | put_user(j->write_wait, (unsigned long __user *) argp); |
| 6330 | break; |
| 6331 | case PHONE_MAXRINGS: |
| 6332 | j->maxrings = arg; |
| 6333 | break; |
| 6334 | case PHONE_SET_TONE_ON_TIME: |
| 6335 | ixj_set_tone_on(arg, j); |
| 6336 | break; |
| 6337 | case PHONE_SET_TONE_OFF_TIME: |
| 6338 | ixj_set_tone_off(arg, j); |
| 6339 | break; |
| 6340 | case PHONE_GET_TONE_ON_TIME: |
| 6341 | if (ixj_get_tone_on(j)) { |
| 6342 | retval = -1; |
| 6343 | } else { |
| 6344 | retval = (j->ssr.high << 8) + j->ssr.low; |
| 6345 | } |
| 6346 | break; |
| 6347 | case PHONE_GET_TONE_OFF_TIME: |
| 6348 | if (ixj_get_tone_off(j)) { |
| 6349 | retval = -1; |
| 6350 | } else { |
| 6351 | retval = (j->ssr.high << 8) + j->ssr.low; |
| 6352 | } |
| 6353 | break; |
| 6354 | case PHONE_PLAY_TONE: |
| 6355 | if (!j->tone_state) |
| 6356 | retval = ixj_play_tone(j, arg); |
| 6357 | else |
| 6358 | retval = -1; |
| 6359 | break; |
| 6360 | case PHONE_GET_TONE_STATE: |
| 6361 | retval = j->tone_state; |
| 6362 | break; |
| 6363 | case PHONE_DTMF_READY: |
| 6364 | retval = j->ex.bits.dtmf_ready; |
| 6365 | break; |
| 6366 | case PHONE_GET_DTMF: |
| 6367 | if (ixj_hookstate(j)) { |
| 6368 | if (j->dtmf_rp != j->dtmf_wp) { |
| 6369 | retval = j->dtmfbuffer[j->dtmf_rp]; |
| 6370 | j->dtmf_rp++; |
| 6371 | if (j->dtmf_rp == 79) |
| 6372 | j->dtmf_rp = 0; |
| 6373 | if (j->dtmf_rp == j->dtmf_wp) { |
| 6374 | j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0; |
| 6375 | } |
| 6376 | } |
| 6377 | } |
| 6378 | break; |
| 6379 | case PHONE_GET_DTMF_ASCII: |
| 6380 | if (ixj_hookstate(j)) { |
| 6381 | if (j->dtmf_rp != j->dtmf_wp) { |
| 6382 | switch (j->dtmfbuffer[j->dtmf_rp]) { |
| 6383 | case 10: |
| 6384 | retval = 42; /* '*'; */ |
| 6385 | |
| 6386 | break; |
| 6387 | case 11: |
| 6388 | retval = 48; /*'0'; */ |
| 6389 | |
| 6390 | break; |
| 6391 | case 12: |
| 6392 | retval = 35; /*'#'; */ |
| 6393 | |
| 6394 | break; |
| 6395 | case 28: |
| 6396 | retval = 65; /*'A'; */ |
| 6397 | |
| 6398 | break; |
| 6399 | case 29: |
| 6400 | retval = 66; /*'B'; */ |
| 6401 | |
| 6402 | break; |
| 6403 | case 30: |
| 6404 | retval = 67; /*'C'; */ |
| 6405 | |
| 6406 | break; |
| 6407 | case 31: |
| 6408 | retval = 68; /*'D'; */ |
| 6409 | |
| 6410 | break; |
| 6411 | default: |
| 6412 | retval = 48 + j->dtmfbuffer[j->dtmf_rp]; |
| 6413 | break; |
| 6414 | } |
| 6415 | j->dtmf_rp++; |
| 6416 | if (j->dtmf_rp == 79) |
| 6417 | j->dtmf_rp = 0; |
| 6418 | if(j->dtmf_rp == j->dtmf_wp) |
| 6419 | { |
| 6420 | j->ex.bits.dtmf_ready = j->dtmf_rp = j->dtmf_wp = 0; |
| 6421 | } |
| 6422 | } |
| 6423 | } |
| 6424 | break; |
| 6425 | case PHONE_DTMF_OOB: |
| 6426 | j->flags.dtmf_oob = arg; |
| 6427 | break; |
| 6428 | case PHONE_DIALTONE: |
| 6429 | ixj_dialtone(j); |
| 6430 | break; |
| 6431 | case PHONE_BUSY: |
| 6432 | ixj_busytone(j); |
| 6433 | break; |
| 6434 | case PHONE_RINGBACK: |
| 6435 | ixj_ringback(j); |
| 6436 | break; |
| 6437 | case PHONE_WINK: |
| 6438 | if(j->cardtype == QTI_PHONEJACK) |
| 6439 | retval = -1; |
| 6440 | else |
| 6441 | retval = ixj_wink(j); |
| 6442 | break; |
| 6443 | case PHONE_CPT_STOP: |
| 6444 | ixj_cpt_stop(j); |
| 6445 | break; |
| 6446 | case PHONE_QUERY_CODEC: |
| 6447 | { |
| 6448 | struct phone_codec_data pd; |
| 6449 | int val; |
| 6450 | int proto_size[] = { |
| 6451 | -1, |
| 6452 | 12, 10, 16, 9, 8, 48, 5, |
| 6453 | 40, 40, 80, 40, 40, 6 |
| 6454 | }; |
| 6455 | if(copy_from_user(&pd, argp, sizeof(pd))) { |
| 6456 | retval = -EFAULT; |
| 6457 | break; |
| 6458 | } |
| 6459 | if(pd.type<1 || pd.type>13) { |
| 6460 | retval = -EPROTONOSUPPORT; |
| 6461 | break; |
| 6462 | } |
| 6463 | if(pd.type<G729) |
| 6464 | val=proto_size[pd.type]; |
| 6465 | else switch(j->baseframe.low) |
| 6466 | { |
| 6467 | case 0xA0:val=2*proto_size[pd.type];break; |
| 6468 | case 0x50:val=proto_size[pd.type];break; |
| 6469 | default:val=proto_size[pd.type]*3;break; |
| 6470 | } |
| 6471 | pd.buf_min=pd.buf_max=pd.buf_opt=val; |
| 6472 | if(copy_to_user(argp, &pd, sizeof(pd))) |
| 6473 | retval = -EFAULT; |
| 6474 | break; |
| 6475 | } |
| 6476 | case IXJCTL_DSP_IDLE: |
| 6477 | idle(j); |
| 6478 | break; |
| 6479 | case IXJCTL_MIXER: |
| 6480 | if ((arg & 0xff) == 0xff) |
| 6481 | retval = ixj_get_mixer(arg, j); |
| 6482 | else |
| 6483 | ixj_mixer(arg, j); |
| 6484 | break; |
| 6485 | case IXJCTL_DAA_COEFF_SET: |
| 6486 | switch (arg) { |
| 6487 | case DAA_US: |
| 6488 | DAA_Coeff_US(j); |
| 6489 | retval = ixj_daa_write(j); |
| 6490 | break; |
| 6491 | case DAA_UK: |
| 6492 | DAA_Coeff_UK(j); |
| 6493 | retval = ixj_daa_write(j); |
| 6494 | break; |
| 6495 | case DAA_FRANCE: |
| 6496 | DAA_Coeff_France(j); |
| 6497 | retval = ixj_daa_write(j); |
| 6498 | break; |
| 6499 | case DAA_GERMANY: |
| 6500 | DAA_Coeff_Germany(j); |
| 6501 | retval = ixj_daa_write(j); |
| 6502 | break; |
| 6503 | case DAA_AUSTRALIA: |
| 6504 | DAA_Coeff_Australia(j); |
| 6505 | retval = ixj_daa_write(j); |
| 6506 | break; |
| 6507 | case DAA_JAPAN: |
| 6508 | DAA_Coeff_Japan(j); |
| 6509 | retval = ixj_daa_write(j); |
| 6510 | break; |
| 6511 | default: |
| 6512 | retval = 1; |
| 6513 | break; |
| 6514 | } |
| 6515 | break; |
| 6516 | case IXJCTL_DAA_AGAIN: |
| 6517 | ixj_daa_cr4(j, arg | 0x02); |
| 6518 | break; |
| 6519 | case IXJCTL_PSTN_LINETEST: |
| 6520 | retval = ixj_linetest(j); |
| 6521 | break; |
| 6522 | case IXJCTL_VMWI: |
| 6523 | ixj_write_vmwi(j, arg); |
| 6524 | break; |
| 6525 | case IXJCTL_CID: |
| 6526 | if (copy_to_user(argp, &j->cid, sizeof(PHONE_CID))) |
| 6527 | retval = -EFAULT; |
| 6528 | j->ex.bits.caller_id = 0; |
| 6529 | break; |
| 6530 | case IXJCTL_WINK_DURATION: |
| 6531 | j->winktime = arg; |
| 6532 | break; |
| 6533 | case IXJCTL_PORT: |
| 6534 | if (arg) |
| 6535 | retval = ixj_set_port(j, arg); |
| 6536 | else |
| 6537 | retval = j->port; |
| 6538 | break; |
| 6539 | case IXJCTL_POTS_PSTN: |
| 6540 | retval = ixj_set_pots(j, arg); |
| 6541 | break; |
| 6542 | case PHONE_CAPABILITIES: |
| 6543 | add_caps(j); |
| 6544 | retval = j->caps; |
| 6545 | break; |
| 6546 | case PHONE_CAPABILITIES_LIST: |
| 6547 | add_caps(j); |
| 6548 | if (copy_to_user(argp, j->caplist, sizeof(struct phone_capability) * j->caps)) |
| 6549 | retval = -EFAULT; |
| 6550 | break; |
| 6551 | case PHONE_CAPABILITIES_CHECK: |
| 6552 | { |
| 6553 | struct phone_capability cap; |
| 6554 | if (copy_from_user(&cap, argp, sizeof(cap))) |
| 6555 | retval = -EFAULT; |
| 6556 | else { |
| 6557 | add_caps(j); |
| 6558 | retval = capabilities_check(j, &cap); |
| 6559 | } |
| 6560 | } |
| 6561 | break; |
| 6562 | case PHONE_PSTN_SET_STATE: |
| 6563 | daa_set_mode(j, arg); |
| 6564 | break; |
| 6565 | case PHONE_PSTN_GET_STATE: |
| 6566 | retval = j->daa_mode; |
| 6567 | j->ex.bits.pstn_ring = 0; |
| 6568 | break; |
| 6569 | case IXJCTL_SET_FILTER: |
| 6570 | if (copy_from_user(&jf, argp, sizeof(jf))) |
| 6571 | retval = -EFAULT; |
| 6572 | retval = ixj_init_filter(j, &jf); |
| 6573 | break; |
| 6574 | case IXJCTL_SET_FILTER_RAW: |
| 6575 | if (copy_from_user(&jfr, argp, sizeof(jfr))) |
| 6576 | retval = -EFAULT; |
| 6577 | else |
| 6578 | retval = ixj_init_filter_raw(j, &jfr); |
| 6579 | break; |
| 6580 | case IXJCTL_GET_FILTER_HIST: |
| 6581 | if(arg<0||arg>3) |
| 6582 | retval = -EINVAL; |
| 6583 | else |
| 6584 | retval = j->filter_hist[arg]; |
| 6585 | break; |
| 6586 | case IXJCTL_INIT_TONE: |
| 6587 | if (copy_from_user(&ti, argp, sizeof(ti))) |
| 6588 | retval = -EFAULT; |
| 6589 | else |
| 6590 | retval = ixj_init_tone(j, &ti); |
| 6591 | break; |
| 6592 | case IXJCTL_TONE_CADENCE: |
| 6593 | retval = ixj_build_cadence(j, argp); |
| 6594 | break; |
| 6595 | case IXJCTL_FILTER_CADENCE: |
| 6596 | retval = ixj_build_filter_cadence(j, argp); |
| 6597 | break; |
| 6598 | case IXJCTL_SIGCTL: |
| 6599 | if (copy_from_user(&j->sigdef, argp, sizeof(IXJ_SIGDEF))) { |
| 6600 | retval = -EFAULT; |
| 6601 | break; |
| 6602 | } |
| 6603 | j->ixj_signals[j->sigdef.event] = j->sigdef.signal; |
| 6604 | if(j->sigdef.event < 33) { |
| 6605 | raise = 1; |
| 6606 | for(mant = 0; mant < j->sigdef.event; mant++){ |
| 6607 | raise *= 2; |
| 6608 | } |
| 6609 | if(j->sigdef.signal) |
| 6610 | j->ex_sig.bytes |= raise; |
| 6611 | else |
| 6612 | j->ex_sig.bytes &= (raise^0xffff); |
| 6613 | } |
| 6614 | break; |
| 6615 | case IXJCTL_INTERCOM_STOP: |
| 6616 | if(arg < 0 || arg >= IXJMAX) |
| 6617 | return -EINVAL; |
| 6618 | j->intercom = -1; |
| 6619 | ixj_record_stop(j); |
| 6620 | ixj_play_stop(j); |
| 6621 | idle(j); |
| 6622 | get_ixj(arg)->intercom = -1; |
| 6623 | ixj_record_stop(get_ixj(arg)); |
| 6624 | ixj_play_stop(get_ixj(arg)); |
| 6625 | idle(get_ixj(arg)); |
| 6626 | break; |
| 6627 | case IXJCTL_INTERCOM_START: |
| 6628 | if(arg < 0 || arg >= IXJMAX) |
| 6629 | return -EINVAL; |
| 6630 | j->intercom = arg; |
| 6631 | ixj_record_start(j); |
| 6632 | ixj_play_start(j); |
| 6633 | get_ixj(arg)->intercom = board; |
| 6634 | ixj_play_start(get_ixj(arg)); |
| 6635 | ixj_record_start(get_ixj(arg)); |
| 6636 | break; |
| 6637 | } |
| 6638 | if (ixjdebug & 0x0040) |
| 6639 | printk("phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg); |
| 6640 | clear_bit(board, &j->busyflags); |
| 6641 | return retval; |
| 6642 | } |
| 6643 | |
| 6644 | static int ixj_fasync(int fd, struct file *file_p, int mode) |
| 6645 | { |
| 6646 | IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode)); |
| 6647 | |
| 6648 | return fasync_helper(fd, file_p, mode, &j->async_queue); |
| 6649 | } |
| 6650 | |
| 6651 | static struct file_operations ixj_fops = |
| 6652 | { |
| 6653 | .owner = THIS_MODULE, |
| 6654 | .read = ixj_enhanced_read, |
| 6655 | .write = ixj_enhanced_write, |
| 6656 | .poll = ixj_poll, |
| 6657 | .ioctl = ixj_ioctl, |
| 6658 | .release = ixj_release, |
| 6659 | .fasync = ixj_fasync |
| 6660 | }; |
| 6661 | |
| 6662 | static int ixj_linetest(IXJ *j) |
| 6663 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6664 | j->flags.pstncheck = 1; /* Testing */ |
| 6665 | j->flags.pstn_present = 0; /* Assume the line is not there */ |
| 6666 | |
| 6667 | daa_int_read(j); /*Clear DAA Interrupt flags */ |
| 6668 | /* */ |
| 6669 | /* Hold all relays in the normally de-energized position. */ |
| 6670 | /* */ |
| 6671 | |
| 6672 | j->pld_slicw.bits.rly1 = 0; |
| 6673 | j->pld_slicw.bits.rly2 = 0; |
| 6674 | j->pld_slicw.bits.rly3 = 0; |
| 6675 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6676 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 6677 | |
| 6678 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 6679 | j->pld_slicr.byte = inb_p(j->XILINXbase + 0x01); |
| 6680 | if (j->pld_slicr.bits.potspstn) { |
| 6681 | j->flags.pots_pstn = 1; |
| 6682 | j->flags.pots_correct = 0; |
| 6683 | LED_SetState(0x4, j); |
| 6684 | } else { |
| 6685 | j->flags.pots_pstn = 0; |
| 6686 | j->pld_slicw.bits.rly1 = 0; |
| 6687 | j->pld_slicw.bits.rly2 = 0; |
| 6688 | j->pld_slicw.bits.rly3 = 1; |
| 6689 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6690 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 6691 | |
| 6692 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 6693 | daa_set_mode(j, SOP_PU_CONVERSATION); |
Nishanth Aravamudan | f4c9925 | 2005-09-10 00:26:50 -0700 | [diff] [blame] | 6694 | msleep(1000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6695 | daa_int_read(j); |
| 6696 | daa_set_mode(j, SOP_PU_RESET); |
| 6697 | if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) { |
| 6698 | j->flags.pots_correct = 0; /* Should not be line voltage on POTS port. */ |
| 6699 | LED_SetState(0x4, j); |
| 6700 | j->pld_slicw.bits.rly3 = 0; |
| 6701 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6702 | } else { |
| 6703 | j->flags.pots_correct = 1; |
| 6704 | LED_SetState(0x8, j); |
| 6705 | j->pld_slicw.bits.rly1 = 1; |
| 6706 | j->pld_slicw.bits.rly2 = 0; |
| 6707 | j->pld_slicw.bits.rly3 = 0; |
| 6708 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6709 | } |
| 6710 | } |
| 6711 | j->pld_slicw.bits.rly3 = 0; |
| 6712 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6713 | daa_set_mode(j, SOP_PU_CONVERSATION); |
Nishanth Aravamudan | f4c9925 | 2005-09-10 00:26:50 -0700 | [diff] [blame] | 6714 | msleep(1000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6715 | daa_int_read(j); |
| 6716 | daa_set_mode(j, SOP_PU_RESET); |
| 6717 | if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) { |
| 6718 | j->pstn_sleeptil = jiffies + (hertz / 4); |
| 6719 | j->flags.pstn_present = 1; |
| 6720 | } else { |
| 6721 | j->flags.pstn_present = 0; |
| 6722 | } |
| 6723 | if (j->flags.pstn_present) { |
| 6724 | if (j->flags.pots_correct) { |
| 6725 | LED_SetState(0xA, j); |
| 6726 | } else { |
| 6727 | LED_SetState(0x6, j); |
| 6728 | } |
| 6729 | } else { |
| 6730 | if (j->flags.pots_correct) { |
| 6731 | LED_SetState(0x9, j); |
| 6732 | } else { |
| 6733 | LED_SetState(0x5, j); |
| 6734 | } |
| 6735 | } |
| 6736 | j->flags.pstncheck = 0; /* Testing */ |
| 6737 | return j->flags.pstn_present; |
| 6738 | } |
| 6739 | |
| 6740 | static int ixj_selfprobe(IXJ *j) |
| 6741 | { |
| 6742 | unsigned short cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6743 | int cnt; |
| 6744 | BYTES bytes; |
| 6745 | |
| 6746 | init_waitqueue_head(&j->poll_q); |
| 6747 | init_waitqueue_head(&j->read_q); |
| 6748 | init_waitqueue_head(&j->write_q); |
| 6749 | |
| 6750 | while(atomic_read(&j->DSPWrite) > 0) |
| 6751 | atomic_dec(&j->DSPWrite); |
| 6752 | if (ixjdebug & 0x0002) |
| 6753 | printk(KERN_INFO "Write IDLE to Software Control Register\n"); |
| 6754 | ixj_WriteDSPCommand(0x0FE0, j); /* Put the DSP in full power mode. */ |
| 6755 | |
| 6756 | if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */ |
| 6757 | return -1; |
| 6758 | /* The read values of the SSR should be 0x00 for the IDLE command */ |
| 6759 | if (j->ssr.low || j->ssr.high) |
| 6760 | return -1; |
| 6761 | if (ixjdebug & 0x0002) |
| 6762 | printk(KERN_INFO "Get Device ID Code\n"); |
| 6763 | if (ixj_WriteDSPCommand(0x3400, j)) /* Get Device ID Code */ |
| 6764 | return -1; |
| 6765 | j->dsp.low = j->ssr.low; |
| 6766 | j->dsp.high = j->ssr.high; |
| 6767 | if (ixjdebug & 0x0002) |
| 6768 | printk(KERN_INFO "Get Device Version Code\n"); |
| 6769 | if (ixj_WriteDSPCommand(0x3800, j)) /* Get Device Version Code */ |
| 6770 | return -1; |
| 6771 | j->ver.low = j->ssr.low; |
| 6772 | j->ver.high = j->ssr.high; |
| 6773 | if (!j->cardtype) { |
| 6774 | if (j->dsp.low == 0x21) { |
| 6775 | bytes.high = bytes.low = inb_p(j->XILINXbase + 0x02); |
| 6776 | outb_p(bytes.low ^ 0xFF, j->XILINXbase + 0x02); |
| 6777 | /* Test for Internet LineJACK or Internet PhoneJACK Lite */ |
| 6778 | bytes.low = inb_p(j->XILINXbase + 0x02); |
| 6779 | if (bytes.low == bytes.high) /* Register is read only on */ |
| 6780 | /* Internet PhoneJack Lite */ |
| 6781 | { |
| 6782 | j->cardtype = QTI_PHONEJACK_LITE; |
| 6783 | if (!request_region(j->XILINXbase, 4, "ixj control")) { |
| 6784 | printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase); |
| 6785 | return -1; |
| 6786 | } |
| 6787 | j->pld_slicw.pcib.e1 = 1; |
| 6788 | outb_p(j->pld_slicw.byte, j->XILINXbase); |
| 6789 | } else { |
| 6790 | j->cardtype = QTI_LINEJACK; |
| 6791 | |
| 6792 | if (!request_region(j->XILINXbase, 8, "ixj control")) { |
| 6793 | printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase); |
| 6794 | return -1; |
| 6795 | } |
| 6796 | } |
| 6797 | } else if (j->dsp.low == 0x22) { |
| 6798 | j->cardtype = QTI_PHONEJACK_PCI; |
| 6799 | request_region(j->XILINXbase, 4, "ixj control"); |
| 6800 | j->pld_slicw.pcib.e1 = 1; |
| 6801 | outb_p(j->pld_slicw.byte, j->XILINXbase); |
| 6802 | } else |
| 6803 | j->cardtype = QTI_PHONEJACK; |
| 6804 | } else { |
| 6805 | switch (j->cardtype) { |
| 6806 | case QTI_PHONEJACK: |
| 6807 | if (!j->dsp.low != 0x20) { |
| 6808 | j->dsp.high = 0x80; |
| 6809 | j->dsp.low = 0x20; |
| 6810 | ixj_WriteDSPCommand(0x3800, j); |
| 6811 | j->ver.low = j->ssr.low; |
| 6812 | j->ver.high = j->ssr.high; |
| 6813 | } |
| 6814 | break; |
| 6815 | case QTI_LINEJACK: |
| 6816 | if (!request_region(j->XILINXbase, 8, "ixj control")) { |
| 6817 | printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase); |
| 6818 | return -1; |
| 6819 | } |
| 6820 | break; |
| 6821 | case QTI_PHONEJACK_LITE: |
| 6822 | case QTI_PHONEJACK_PCI: |
| 6823 | if (!request_region(j->XILINXbase, 4, "ixj control")) { |
| 6824 | printk(KERN_INFO "ixj: can't get I/O address 0x%x\n", j->XILINXbase); |
| 6825 | return -1; |
| 6826 | } |
| 6827 | j->pld_slicw.pcib.e1 = 1; |
| 6828 | outb_p(j->pld_slicw.byte, j->XILINXbase); |
| 6829 | break; |
| 6830 | case QTI_PHONECARD: |
| 6831 | break; |
| 6832 | } |
| 6833 | } |
| 6834 | if (j->dsp.low == 0x20 || j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) { |
| 6835 | if (ixjdebug & 0x0002) |
| 6836 | printk(KERN_INFO "Write CODEC config to Software Control Register\n"); |
| 6837 | if (ixj_WriteDSPCommand(0xC462, j)) /* Write CODEC config to Software Control Register */ |
| 6838 | return -1; |
| 6839 | if (ixjdebug & 0x0002) |
| 6840 | printk(KERN_INFO "Write CODEC timing to Software Control Register\n"); |
| 6841 | if (j->cardtype == QTI_PHONEJACK) { |
| 6842 | cmd = 0x9FF2; |
| 6843 | } else { |
| 6844 | cmd = 0x9FF5; |
| 6845 | } |
| 6846 | if (ixj_WriteDSPCommand(cmd, j)) /* Write CODEC timing to Software Control Register */ |
| 6847 | return -1; |
| 6848 | } else { |
| 6849 | if (set_base_frame(j, 30) != 30) |
| 6850 | return -1; |
| 6851 | if (ixjdebug & 0x0002) |
| 6852 | printk(KERN_INFO "Write CODEC config to Software Control Register\n"); |
| 6853 | if (j->cardtype == QTI_PHONECARD) { |
| 6854 | if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */ |
| 6855 | return -1; |
| 6856 | } |
| 6857 | if (j->cardtype == QTI_LINEJACK) { |
| 6858 | if (ixj_WriteDSPCommand(0xC528, j)) /* Write CODEC config to Software Control Register */ |
| 6859 | return -1; |
| 6860 | if (ixjdebug & 0x0002) |
| 6861 | printk(KERN_INFO "Turn on the PLD Clock at 8Khz\n"); |
| 6862 | j->pld_clock.byte = 0; |
| 6863 | outb_p(j->pld_clock.byte, j->XILINXbase + 0x04); |
| 6864 | } |
| 6865 | } |
| 6866 | |
| 6867 | if (j->dsp.low == 0x20) { |
| 6868 | if (ixjdebug & 0x0002) |
| 6869 | printk(KERN_INFO "Configure GPIO pins\n"); |
| 6870 | j->gpio.bytes.high = 0x09; |
| 6871 | /* bytes.low = 0xEF; 0xF7 */ |
| 6872 | j->gpio.bits.gpio1 = 1; |
| 6873 | j->gpio.bits.gpio2 = 1; |
| 6874 | j->gpio.bits.gpio3 = 0; |
| 6875 | j->gpio.bits.gpio4 = 1; |
| 6876 | j->gpio.bits.gpio5 = 1; |
| 6877 | j->gpio.bits.gpio6 = 1; |
| 6878 | j->gpio.bits.gpio7 = 1; |
| 6879 | ixj_WriteDSPCommand(j->gpio.word, j); /* Set GPIO pin directions */ |
| 6880 | if (ixjdebug & 0x0002) |
| 6881 | printk(KERN_INFO "Enable SLIC\n"); |
| 6882 | j->gpio.bytes.high = 0x0B; |
| 6883 | j->gpio.bytes.low = 0x00; |
| 6884 | j->gpio.bits.gpio1 = 0; |
| 6885 | j->gpio.bits.gpio2 = 1; |
| 6886 | j->gpio.bits.gpio5 = 0; |
| 6887 | ixj_WriteDSPCommand(j->gpio.word, j); /* send the ring stop signal */ |
| 6888 | j->port = PORT_POTS; |
| 6889 | } else { |
| 6890 | if (j->cardtype == QTI_LINEJACK) { |
| 6891 | LED_SetState(0x1, j); |
Nishanth Aravamudan | f4c9925 | 2005-09-10 00:26:50 -0700 | [diff] [blame] | 6892 | msleep(100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6893 | LED_SetState(0x2, j); |
Nishanth Aravamudan | f4c9925 | 2005-09-10 00:26:50 -0700 | [diff] [blame] | 6894 | msleep(100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6895 | LED_SetState(0x4, j); |
Nishanth Aravamudan | f4c9925 | 2005-09-10 00:26:50 -0700 | [diff] [blame] | 6896 | msleep(100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6897 | LED_SetState(0x8, j); |
Nishanth Aravamudan | f4c9925 | 2005-09-10 00:26:50 -0700 | [diff] [blame] | 6898 | msleep(100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6899 | LED_SetState(0x0, j); |
| 6900 | daa_get_version(j); |
| 6901 | if (ixjdebug & 0x0002) |
| 6902 | printk("Loading DAA Coefficients\n"); |
| 6903 | DAA_Coeff_US(j); |
| 6904 | if (!ixj_daa_write(j)) { |
| 6905 | printk("DAA write failed on board %d\n", j->board); |
| 6906 | return -1; |
| 6907 | } |
| 6908 | if(!ixj_daa_cid_reset(j)) { |
| 6909 | printk("DAA CID reset failed on board %d\n", j->board); |
| 6910 | return -1; |
| 6911 | } |
| 6912 | j->flags.pots_correct = 0; |
| 6913 | j->flags.pstn_present = 0; |
| 6914 | ixj_linetest(j); |
| 6915 | if (j->flags.pots_correct) { |
| 6916 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 6917 | |
| 6918 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 6919 | j->pld_slicw.bits.rly1 = 1; |
| 6920 | j->pld_slicw.bits.spken = 1; |
| 6921 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 6922 | SLIC_SetState(PLD_SLIC_STATE_STANDBY, j); |
| 6923 | /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */ |
| 6924 | j->port = PORT_POTS; |
| 6925 | } |
| 6926 | ixj_set_port(j, PORT_PSTN); |
| 6927 | ixj_set_pots(j, 1); |
| 6928 | if (ixjdebug & 0x0002) |
| 6929 | printk(KERN_INFO "Enable Mixer\n"); |
| 6930 | ixj_mixer(0x0000, j); /*Master Volume Left unmute 0db */ |
| 6931 | ixj_mixer(0x0100, j); /*Master Volume Right unmute 0db */ |
| 6932 | |
| 6933 | ixj_mixer(0x0203, j); /*Voice Left Volume unmute 6db */ |
| 6934 | ixj_mixer(0x0303, j); /*Voice Right Volume unmute 6db */ |
| 6935 | |
| 6936 | ixj_mixer(0x0480, j); /*FM Left mute */ |
| 6937 | ixj_mixer(0x0580, j); /*FM Right mute */ |
| 6938 | |
| 6939 | ixj_mixer(0x0680, j); /*CD Left mute */ |
| 6940 | ixj_mixer(0x0780, j); /*CD Right mute */ |
| 6941 | |
| 6942 | ixj_mixer(0x0880, j); /*Line Left mute */ |
| 6943 | ixj_mixer(0x0980, j); /*Line Right mute */ |
| 6944 | |
| 6945 | ixj_mixer(0x0A80, j); /*Aux left mute */ |
| 6946 | ixj_mixer(0x0B80, j); /*Aux right mute */ |
| 6947 | |
| 6948 | ixj_mixer(0x0C00, j); /*Mono1 unmute 12db */ |
| 6949 | ixj_mixer(0x0D80, j); /*Mono2 mute */ |
| 6950 | |
| 6951 | ixj_mixer(0x0E80, j); /*Mic mute */ |
| 6952 | |
| 6953 | ixj_mixer(0x0F00, j); /*Mono Out Volume unmute 0db */ |
| 6954 | |
| 6955 | ixj_mixer(0x1000, j); /*Voice Left and Right out only */ |
| 6956 | ixj_mixer(0x110C, j); |
| 6957 | |
| 6958 | |
| 6959 | ixj_mixer(0x1200, j); /*Mono1 switch on mixer left */ |
| 6960 | ixj_mixer(0x1401, j); |
| 6961 | |
| 6962 | ixj_mixer(0x1300, j); /*Mono1 switch on mixer right */ |
| 6963 | ixj_mixer(0x1501, j); |
| 6964 | |
| 6965 | ixj_mixer(0x1700, j); /*Clock select */ |
| 6966 | |
| 6967 | ixj_mixer(0x1800, j); /*ADC input from mixer */ |
| 6968 | |
| 6969 | ixj_mixer(0x1901, j); /*Mic gain 30db */ |
| 6970 | |
| 6971 | if (ixjdebug & 0x0002) |
| 6972 | printk(KERN_INFO "Setting Default US Ring Cadence Detection\n"); |
| 6973 | j->cadence_f[4].state = 0; |
| 6974 | j->cadence_f[4].on1 = 0; /*Cadence Filter 4 is used for PSTN ring cadence */ |
| 6975 | j->cadence_f[4].off1 = 0; |
| 6976 | j->cadence_f[4].on2 = 0; |
| 6977 | j->cadence_f[4].off2 = 0; |
| 6978 | j->cadence_f[4].on3 = 0; |
| 6979 | j->cadence_f[4].off3 = 0; /* These should represent standard US ring pulse. */ |
| 6980 | j->pstn_last_rmr = jiffies; |
| 6981 | |
| 6982 | } else { |
| 6983 | if (j->cardtype == QTI_PHONECARD) { |
| 6984 | ixj_WriteDSPCommand(0xCF07, j); |
| 6985 | ixj_WriteDSPCommand(0x00B0, j); |
| 6986 | ixj_set_port(j, PORT_SPEAKER); |
| 6987 | } else { |
| 6988 | ixj_set_port(j, PORT_POTS); |
| 6989 | SLIC_SetState(PLD_SLIC_STATE_STANDBY, j); |
| 6990 | /* SLIC_SetState(PLD_SLIC_STATE_ACTIVE, j); */ |
| 6991 | } |
| 6992 | } |
| 6993 | } |
| 6994 | |
| 6995 | j->intercom = -1; |
| 6996 | j->framesread = j->frameswritten = 0; |
| 6997 | j->read_wait = j->write_wait = 0; |
| 6998 | j->rxreadycheck = j->txreadycheck = 0; |
| 6999 | |
| 7000 | /* initialise the DTMF prescale to a sensible value */ |
| 7001 | if (j->cardtype == QTI_LINEJACK) { |
| 7002 | set_dtmf_prescale(j, 0x10); |
| 7003 | } else { |
| 7004 | set_dtmf_prescale(j, 0x40); |
| 7005 | } |
| 7006 | set_play_volume(j, 0x100); |
| 7007 | set_rec_volume(j, 0x100); |
| 7008 | |
| 7009 | if (ixj_WriteDSPCommand(0x0000, j)) /* Write IDLE to Software Control Register */ |
| 7010 | return -1; |
| 7011 | /* The read values of the SSR should be 0x00 for the IDLE command */ |
| 7012 | if (j->ssr.low || j->ssr.high) |
| 7013 | return -1; |
| 7014 | |
| 7015 | if (ixjdebug & 0x0002) |
| 7016 | printk(KERN_INFO "Enable Line Monitor\n"); |
| 7017 | |
| 7018 | if (ixjdebug & 0x0002) |
| 7019 | printk(KERN_INFO "Set Line Monitor to Asyncronous Mode\n"); |
| 7020 | |
| 7021 | if (ixj_WriteDSPCommand(0x7E01, j)) /* Asynchronous Line Monitor */ |
| 7022 | return -1; |
| 7023 | |
| 7024 | if (ixjdebug & 0x002) |
| 7025 | printk(KERN_INFO "Enable DTMF Detectors\n"); |
| 7026 | |
| 7027 | if (ixj_WriteDSPCommand(0x5151, j)) /* Enable DTMF detection */ |
| 7028 | return -1; |
| 7029 | |
| 7030 | if (ixj_WriteDSPCommand(0x6E01, j)) /* Set Asyncronous Tone Generation */ |
| 7031 | return -1; |
| 7032 | |
| 7033 | set_rec_depth(j, 2); /* Set Record Channel Limit to 2 frames */ |
| 7034 | |
| 7035 | set_play_depth(j, 2); /* Set Playback Channel Limit to 2 frames */ |
| 7036 | |
| 7037 | j->ex.bits.dtmf_ready = 0; |
| 7038 | j->dtmf_state = 0; |
| 7039 | j->dtmf_wp = j->dtmf_rp = 0; |
| 7040 | j->rec_mode = j->play_mode = -1; |
| 7041 | j->flags.ringing = 0; |
| 7042 | j->maxrings = MAXRINGS; |
| 7043 | j->ring_cadence = USA_RING_CADENCE; |
| 7044 | j->drybuffer = 0; |
| 7045 | j->winktime = 320; |
| 7046 | j->flags.dtmf_oob = 0; |
| 7047 | for (cnt = 0; cnt < 4; cnt++) |
| 7048 | j->cadence_f[cnt].enable = 0; |
| 7049 | /* must be a device on the specified address */ |
| 7050 | ixj_WriteDSPCommand(0x0FE3, j); /* Put the DSP in 1/5 power mode. */ |
| 7051 | |
| 7052 | /* Set up the default signals for events */ |
| 7053 | for (cnt = 0; cnt < 35; cnt++) |
| 7054 | j->ixj_signals[cnt] = SIGIO; |
| 7055 | |
| 7056 | /* Set the excetion signal enable flags */ |
| 7057 | j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring = |
| 7058 | 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 = |
| 7059 | 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; |
| 7060 | #ifdef IXJ_DYN_ALLOC |
| 7061 | j->fskdata = NULL; |
| 7062 | #endif |
| 7063 | j->fskdcnt = 0; |
| 7064 | j->cidcw_wait = 0; |
| 7065 | |
| 7066 | /* Register with the Telephony for Linux subsystem */ |
| 7067 | j->p.f_op = &ixj_fops; |
| 7068 | j->p.open = ixj_open; |
| 7069 | j->p.board = j->board; |
| 7070 | phone_register_device(&j->p, PHONE_UNIT_ANY); |
| 7071 | |
| 7072 | ixj_init_timer(j); |
| 7073 | ixj_add_timer(j); |
| 7074 | return 0; |
| 7075 | } |
| 7076 | |
| 7077 | /* |
| 7078 | * Exported service for pcmcia card handling |
| 7079 | */ |
| 7080 | |
| 7081 | IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx) |
| 7082 | { |
| 7083 | IXJ *j = ixj_alloc(); |
| 7084 | |
| 7085 | j->board = 0; |
| 7086 | |
| 7087 | j->DSPbase = dsp; |
| 7088 | j->XILINXbase = xilinx; |
| 7089 | j->cardtype = QTI_PHONECARD; |
| 7090 | ixj_selfprobe(j); |
| 7091 | return j; |
| 7092 | } |
| 7093 | |
| 7094 | EXPORT_SYMBOL(ixj_pcmcia_probe); /* Fpr PCMCIA */ |
| 7095 | |
| 7096 | static int ixj_get_status_proc(char *buf) |
| 7097 | { |
| 7098 | int len; |
| 7099 | int cnt; |
| 7100 | IXJ *j; |
| 7101 | len = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7102 | len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER); |
| 7103 | len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ)); |
| 7104 | len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS)); |
| 7105 | len += sprintf(buf + len, "\nUsing old telephony API"); |
| 7106 | len += sprintf(buf + len, "\nDebug Level %d\n", ixjdebug); |
| 7107 | |
| 7108 | for (cnt = 0; cnt < IXJMAX; cnt++) { |
| 7109 | j = get_ixj(cnt); |
| 7110 | if(j==NULL) |
| 7111 | continue; |
| 7112 | if (j->DSPbase) { |
| 7113 | len += sprintf(buf + len, "\nCard Num %d", cnt); |
| 7114 | len += sprintf(buf + len, "\nDSP Base Address 0x%4.4x", j->DSPbase); |
| 7115 | if (j->cardtype != QTI_PHONEJACK) |
| 7116 | len += sprintf(buf + len, "\nXILINX Base Address 0x%4.4x", j->XILINXbase); |
| 7117 | len += sprintf(buf + len, "\nDSP Type %2.2x%2.2x", j->dsp.high, j->dsp.low); |
| 7118 | len += sprintf(buf + len, "\nDSP Version %2.2x.%2.2x", j->ver.high, j->ver.low); |
| 7119 | len += sprintf(buf + len, "\nSerial Number %8.8x", j->serial); |
| 7120 | switch (j->cardtype) { |
| 7121 | case (QTI_PHONEJACK): |
| 7122 | len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK"); |
| 7123 | break; |
| 7124 | case (QTI_LINEJACK): |
| 7125 | len += sprintf(buf + len, "\nCard Type = Internet LineJACK"); |
| 7126 | if (j->flags.g729_loaded) |
| 7127 | len += sprintf(buf + len, " w/G.729 A/B"); |
| 7128 | len += sprintf(buf + len, " Country = %d", j->daa_country); |
| 7129 | break; |
| 7130 | case (QTI_PHONEJACK_LITE): |
| 7131 | len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK Lite"); |
| 7132 | if (j->flags.g729_loaded) |
| 7133 | len += sprintf(buf + len, " w/G.729 A/B"); |
| 7134 | break; |
| 7135 | case (QTI_PHONEJACK_PCI): |
| 7136 | len += sprintf(buf + len, "\nCard Type = Internet PhoneJACK PCI"); |
| 7137 | if (j->flags.g729_loaded) |
| 7138 | len += sprintf(buf + len, " w/G.729 A/B"); |
| 7139 | break; |
| 7140 | case (QTI_PHONECARD): |
| 7141 | len += sprintf(buf + len, "\nCard Type = Internet PhoneCARD"); |
| 7142 | if (j->flags.g729_loaded) |
| 7143 | len += sprintf(buf + len, " w/G.729 A/B"); |
| 7144 | len += sprintf(buf + len, "\nSmart Cable %spresent", j->pccr1.bits.drf ? "not " : ""); |
| 7145 | if (!j->pccr1.bits.drf) |
| 7146 | len += sprintf(buf + len, "\nSmart Cable type %d", j->flags.pcmciasct); |
| 7147 | len += sprintf(buf + len, "\nSmart Cable state %d", j->flags.pcmciastate); |
| 7148 | break; |
| 7149 | default: |
| 7150 | len += sprintf(buf + len, "\nCard Type = %d", j->cardtype); |
| 7151 | break; |
| 7152 | } |
| 7153 | len += sprintf(buf + len, "\nReaders %d", j->readers); |
| 7154 | len += sprintf(buf + len, "\nWriters %d", j->writers); |
| 7155 | add_caps(j); |
| 7156 | len += sprintf(buf + len, "\nCapabilities %d", j->caps); |
| 7157 | if (j->dsp.low != 0x20) |
| 7158 | len += sprintf(buf + len, "\nDSP Processor load %d", j->proc_load); |
| 7159 | if (j->flags.cidsent) |
| 7160 | len += sprintf(buf + len, "\nCaller ID data sent"); |
| 7161 | else |
| 7162 | len += sprintf(buf + len, "\nCaller ID data not sent"); |
| 7163 | |
| 7164 | len += sprintf(buf + len, "\nPlay CODEC "); |
| 7165 | switch (j->play_codec) { |
| 7166 | case G723_63: |
| 7167 | len += sprintf(buf + len, "G.723.1 6.3"); |
| 7168 | break; |
| 7169 | case G723_53: |
| 7170 | len += sprintf(buf + len, "G.723.1 5.3"); |
| 7171 | break; |
| 7172 | case TS85: |
| 7173 | len += sprintf(buf + len, "TrueSpeech 8.5"); |
| 7174 | break; |
| 7175 | case TS48: |
| 7176 | len += sprintf(buf + len, "TrueSpeech 4.8"); |
| 7177 | break; |
| 7178 | case TS41: |
| 7179 | len += sprintf(buf + len, "TrueSpeech 4.1"); |
| 7180 | break; |
| 7181 | case G728: |
| 7182 | len += sprintf(buf + len, "G.728"); |
| 7183 | break; |
| 7184 | case G729: |
| 7185 | len += sprintf(buf + len, "G.729"); |
| 7186 | break; |
| 7187 | case G729B: |
| 7188 | len += sprintf(buf + len, "G.729B"); |
| 7189 | break; |
| 7190 | case ULAW: |
| 7191 | len += sprintf(buf + len, "uLaw"); |
| 7192 | break; |
| 7193 | case ALAW: |
| 7194 | len += sprintf(buf + len, "aLaw"); |
| 7195 | break; |
| 7196 | case LINEAR16: |
| 7197 | len += sprintf(buf + len, "16 bit Linear"); |
| 7198 | break; |
| 7199 | case LINEAR8: |
| 7200 | len += sprintf(buf + len, "8 bit Linear"); |
| 7201 | break; |
| 7202 | case WSS: |
| 7203 | len += sprintf(buf + len, "Windows Sound System"); |
| 7204 | break; |
| 7205 | default: |
| 7206 | len += sprintf(buf + len, "NO CODEC CHOSEN"); |
| 7207 | break; |
| 7208 | } |
| 7209 | len += sprintf(buf + len, "\nRecord CODEC "); |
| 7210 | switch (j->rec_codec) { |
| 7211 | case G723_63: |
| 7212 | len += sprintf(buf + len, "G.723.1 6.3"); |
| 7213 | break; |
| 7214 | case G723_53: |
| 7215 | len += sprintf(buf + len, "G.723.1 5.3"); |
| 7216 | break; |
| 7217 | case TS85: |
| 7218 | len += sprintf(buf + len, "TrueSpeech 8.5"); |
| 7219 | break; |
| 7220 | case TS48: |
| 7221 | len += sprintf(buf + len, "TrueSpeech 4.8"); |
| 7222 | break; |
| 7223 | case TS41: |
| 7224 | len += sprintf(buf + len, "TrueSpeech 4.1"); |
| 7225 | break; |
| 7226 | case G728: |
| 7227 | len += sprintf(buf + len, "G.728"); |
| 7228 | break; |
| 7229 | case G729: |
| 7230 | len += sprintf(buf + len, "G.729"); |
| 7231 | break; |
| 7232 | case G729B: |
| 7233 | len += sprintf(buf + len, "G.729B"); |
| 7234 | break; |
| 7235 | case ULAW: |
| 7236 | len += sprintf(buf + len, "uLaw"); |
| 7237 | break; |
| 7238 | case ALAW: |
| 7239 | len += sprintf(buf + len, "aLaw"); |
| 7240 | break; |
| 7241 | case LINEAR16: |
| 7242 | len += sprintf(buf + len, "16 bit Linear"); |
| 7243 | break; |
| 7244 | case LINEAR8: |
| 7245 | len += sprintf(buf + len, "8 bit Linear"); |
| 7246 | break; |
| 7247 | case WSS: |
| 7248 | len += sprintf(buf + len, "Windows Sound System"); |
| 7249 | break; |
| 7250 | default: |
| 7251 | len += sprintf(buf + len, "NO CODEC CHOSEN"); |
| 7252 | break; |
| 7253 | } |
| 7254 | len += sprintf(buf + len, "\nAEC "); |
| 7255 | switch (j->aec_level) { |
| 7256 | case AEC_OFF: |
| 7257 | len += sprintf(buf + len, "Off"); |
| 7258 | break; |
| 7259 | case AEC_LOW: |
| 7260 | len += sprintf(buf + len, "Low"); |
| 7261 | break; |
| 7262 | case AEC_MED: |
| 7263 | len += sprintf(buf + len, "Med"); |
| 7264 | break; |
| 7265 | case AEC_HIGH: |
| 7266 | len += sprintf(buf + len, "High"); |
| 7267 | break; |
| 7268 | case AEC_AUTO: |
| 7269 | len += sprintf(buf + len, "Auto"); |
| 7270 | break; |
| 7271 | case AEC_AGC: |
| 7272 | len += sprintf(buf + len, "AEC/AGC"); |
| 7273 | break; |
| 7274 | default: |
| 7275 | len += sprintf(buf + len, "unknown(%i)", j->aec_level); |
| 7276 | break; |
| 7277 | } |
| 7278 | |
| 7279 | len += sprintf(buf + len, "\nRec volume 0x%x", get_rec_volume(j)); |
| 7280 | len += sprintf(buf + len, "\nPlay volume 0x%x", get_play_volume(j)); |
| 7281 | len += sprintf(buf + len, "\nDTMF prescale 0x%x", get_dtmf_prescale(j)); |
| 7282 | |
| 7283 | len += sprintf(buf + len, "\nHook state %d", j->hookstate); /* j->r_hook); */ |
| 7284 | |
| 7285 | if (j->cardtype == QTI_LINEJACK) { |
| 7286 | len += sprintf(buf + len, "\nPOTS Correct %d", j->flags.pots_correct); |
| 7287 | len += sprintf(buf + len, "\nPSTN Present %d", j->flags.pstn_present); |
| 7288 | len += sprintf(buf + len, "\nPSTN Check %d", j->flags.pstncheck); |
| 7289 | len += sprintf(buf + len, "\nPOTS to PSTN %d", j->flags.pots_pstn); |
| 7290 | switch (j->daa_mode) { |
| 7291 | case SOP_PU_SLEEP: |
| 7292 | len += sprintf(buf + len, "\nDAA PSTN On Hook"); |
| 7293 | break; |
| 7294 | case SOP_PU_RINGING: |
| 7295 | len += sprintf(buf + len, "\nDAA PSTN Ringing"); |
| 7296 | len += sprintf(buf + len, "\nRinging state = %d", j->cadence_f[4].state); |
| 7297 | break; |
| 7298 | case SOP_PU_CONVERSATION: |
| 7299 | len += sprintf(buf + len, "\nDAA PSTN Off Hook"); |
| 7300 | break; |
| 7301 | case SOP_PU_PULSEDIALING: |
| 7302 | len += sprintf(buf + len, "\nDAA PSTN Pulse Dialing"); |
| 7303 | break; |
| 7304 | } |
| 7305 | len += sprintf(buf + len, "\nDAA RMR = %d", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.bitreg.RMR); |
| 7306 | len += sprintf(buf + len, "\nDAA VDD OK = %d", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK); |
| 7307 | len += sprintf(buf + len, "\nDAA CR0 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg); |
| 7308 | len += sprintf(buf + len, "\nDAA CR1 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg); |
| 7309 | len += sprintf(buf + len, "\nDAA CR2 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg); |
| 7310 | len += sprintf(buf + len, "\nDAA CR3 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg); |
| 7311 | len += sprintf(buf + len, "\nDAA CR4 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg); |
| 7312 | len += sprintf(buf + len, "\nDAA CR5 = 0x%02x", j->m_DAAShadowRegs.SOP_REGS.SOP.cr5.reg); |
| 7313 | len += sprintf(buf + len, "\nDAA XR0 = 0x%02x", j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.reg); |
| 7314 | len += sprintf(buf + len, "\nDAA ringstop %ld - jiffies %ld", j->pstn_ring_stop, jiffies); |
| 7315 | } |
| 7316 | switch (j->port) { |
| 7317 | case PORT_POTS: |
| 7318 | len += sprintf(buf + len, "\nPort POTS"); |
| 7319 | break; |
| 7320 | case PORT_PSTN: |
| 7321 | len += sprintf(buf + len, "\nPort PSTN"); |
| 7322 | break; |
| 7323 | case PORT_SPEAKER: |
| 7324 | len += sprintf(buf + len, "\nPort SPEAKER/MIC"); |
| 7325 | break; |
| 7326 | case PORT_HANDSET: |
| 7327 | len += sprintf(buf + len, "\nPort HANDSET"); |
| 7328 | break; |
| 7329 | } |
| 7330 | if (j->dsp.low == 0x21 || j->dsp.low == 0x22) { |
| 7331 | len += sprintf(buf + len, "\nSLIC state "); |
| 7332 | switch (SLIC_GetState(j)) { |
| 7333 | case PLD_SLIC_STATE_OC: |
| 7334 | len += sprintf(buf + len, "OC"); |
| 7335 | break; |
| 7336 | case PLD_SLIC_STATE_RINGING: |
| 7337 | len += sprintf(buf + len, "RINGING"); |
| 7338 | break; |
| 7339 | case PLD_SLIC_STATE_ACTIVE: |
| 7340 | len += sprintf(buf + len, "ACTIVE"); |
| 7341 | break; |
| 7342 | case PLD_SLIC_STATE_OHT: /* On-hook transmit */ |
| 7343 | len += sprintf(buf + len, "OHT"); |
| 7344 | break; |
| 7345 | case PLD_SLIC_STATE_TIPOPEN: |
| 7346 | len += sprintf(buf + len, "TIPOPEN"); |
| 7347 | break; |
| 7348 | case PLD_SLIC_STATE_STANDBY: |
| 7349 | len += sprintf(buf + len, "STANDBY"); |
| 7350 | break; |
| 7351 | case PLD_SLIC_STATE_APR: /* Active polarity reversal */ |
| 7352 | len += sprintf(buf + len, "APR"); |
| 7353 | break; |
| 7354 | case PLD_SLIC_STATE_OHTPR: /* OHT polarity reversal */ |
| 7355 | len += sprintf(buf + len, "OHTPR"); |
| 7356 | break; |
| 7357 | default: |
| 7358 | len += sprintf(buf + len, "%d", SLIC_GetState(j)); |
| 7359 | break; |
| 7360 | } |
| 7361 | } |
| 7362 | len += sprintf(buf + len, "\nBase Frame %2.2x.%2.2x", j->baseframe.high, j->baseframe.low); |
| 7363 | len += sprintf(buf + len, "\nCID Base Frame %2d", j->cid_base_frame_size); |
| 7364 | #ifdef PERFMON_STATS |
| 7365 | len += sprintf(buf + len, "\nTimer Checks %ld", j->timerchecks); |
| 7366 | len += sprintf(buf + len, "\nRX Ready Checks %ld", j->rxreadycheck); |
| 7367 | len += sprintf(buf + len, "\nTX Ready Checks %ld", j->txreadycheck); |
| 7368 | len += sprintf(buf + len, "\nFrames Read %ld", j->framesread); |
| 7369 | len += sprintf(buf + len, "\nFrames Written %ld", j->frameswritten); |
| 7370 | len += sprintf(buf + len, "\nDry Buffer %ld", j->drybuffer); |
| 7371 | len += sprintf(buf + len, "\nRead Waits %ld", j->read_wait); |
| 7372 | len += sprintf(buf + len, "\nWrite Waits %ld", j->write_wait); |
| 7373 | len += sprintf(buf + len, "\nStatus Waits %ld", j->statuswait); |
| 7374 | len += sprintf(buf + len, "\nStatus Wait Fails %ld", j->statuswaitfail); |
| 7375 | len += sprintf(buf + len, "\nPControl Waits %ld", j->pcontrolwait); |
| 7376 | len += sprintf(buf + len, "\nPControl Wait Fails %ld", j->pcontrolwaitfail); |
| 7377 | len += sprintf(buf + len, "\nIs Control Ready Checks %ld", j->iscontrolready); |
| 7378 | len += sprintf(buf + len, "\nIs Control Ready Check failures %ld", j->iscontrolreadyfail); |
| 7379 | |
| 7380 | #endif |
| 7381 | len += sprintf(buf + len, "\n"); |
| 7382 | } |
| 7383 | } |
| 7384 | return len; |
| 7385 | } |
| 7386 | |
| 7387 | static int ixj_read_proc(char *page, char **start, off_t off, |
| 7388 | int count, int *eof, void *data) |
| 7389 | { |
| 7390 | int len = ixj_get_status_proc(page); |
| 7391 | if (len <= off+count) *eof = 1; |
| 7392 | *start = page + off; |
| 7393 | len -= off; |
| 7394 | if (len>count) len = count; |
| 7395 | if (len<0) len = 0; |
| 7396 | return len; |
| 7397 | } |
| 7398 | |
| 7399 | |
| 7400 | static void cleanup(void) |
| 7401 | { |
| 7402 | int cnt; |
| 7403 | IXJ *j; |
| 7404 | |
| 7405 | for (cnt = 0; cnt < IXJMAX; cnt++) { |
| 7406 | j = get_ixj(cnt); |
| 7407 | if(j != NULL && j->DSPbase) { |
| 7408 | if (ixjdebug & 0x0002) |
| 7409 | printk(KERN_INFO "IXJ: Deleting timer for /dev/phone%d\n", cnt); |
| 7410 | del_timer(&j->timer); |
| 7411 | if (j->cardtype == QTI_LINEJACK) { |
| 7412 | j->pld_scrw.bits.daafsyncen = 0; /* Turn off DAA Frame Sync */ |
| 7413 | |
| 7414 | outb_p(j->pld_scrw.byte, j->XILINXbase); |
| 7415 | j->pld_slicw.bits.rly1 = 0; |
| 7416 | j->pld_slicw.bits.rly2 = 0; |
| 7417 | j->pld_slicw.bits.rly3 = 0; |
| 7418 | outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); |
| 7419 | LED_SetState(0x0, j); |
| 7420 | if (ixjdebug & 0x0002) |
| 7421 | printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt); |
| 7422 | release_region(j->XILINXbase, 8); |
| 7423 | } else if (j->cardtype == QTI_PHONEJACK_LITE || j->cardtype == QTI_PHONEJACK_PCI) { |
| 7424 | if (ixjdebug & 0x0002) |
| 7425 | printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt); |
| 7426 | release_region(j->XILINXbase, 4); |
| 7427 | } |
Jesper Juhl | 0159f76 | 2005-06-25 14:59:14 -0700 | [diff] [blame] | 7428 | kfree(j->read_buffer); |
| 7429 | kfree(j->write_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7430 | if (j->dev) |
| 7431 | pnp_device_detach(j->dev); |
| 7432 | if (ixjdebug & 0x0002) |
| 7433 | printk(KERN_INFO "IXJ: Unregistering /dev/phone%d from LTAPI\n", cnt); |
| 7434 | phone_unregister_device(&j->p); |
| 7435 | if (ixjdebug & 0x0002) |
| 7436 | printk(KERN_INFO "IXJ: Releasing DSP address for /dev/phone%d\n", cnt); |
| 7437 | release_region(j->DSPbase, 16); |
| 7438 | #ifdef IXJ_DYN_ALLOC |
| 7439 | if (ixjdebug & 0x0002) |
| 7440 | printk(KERN_INFO "IXJ: Freeing memory for /dev/phone%d\n", cnt); |
| 7441 | kfree(j); |
| 7442 | ixj[cnt] = NULL; |
| 7443 | #endif |
| 7444 | } |
| 7445 | } |
| 7446 | if (ixjdebug & 0x0002) |
| 7447 | printk(KERN_INFO "IXJ: Removing /proc/ixj\n"); |
| 7448 | remove_proc_entry ("ixj", NULL); |
| 7449 | } |
| 7450 | |
| 7451 | /* Typedefs */ |
| 7452 | typedef struct { |
| 7453 | BYTE length; |
| 7454 | DWORD bits; |
| 7455 | } DATABLOCK; |
| 7456 | |
| 7457 | static void PCIEE_WriteBit(WORD wEEPROMAddress, BYTE lastLCC, BYTE byData) |
| 7458 | { |
| 7459 | lastLCC = lastLCC & 0xfb; |
| 7460 | lastLCC = lastLCC | (byData ? 4 : 0); |
| 7461 | outb(lastLCC, wEEPROMAddress); /*set data out bit as appropriate */ |
| 7462 | |
| 7463 | mdelay(1); |
| 7464 | lastLCC = lastLCC | 0x01; |
| 7465 | outb(lastLCC, wEEPROMAddress); /*SK rising edge */ |
| 7466 | |
| 7467 | byData = byData << 1; |
| 7468 | lastLCC = lastLCC & 0xfe; |
| 7469 | mdelay(1); |
| 7470 | outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */ |
| 7471 | |
| 7472 | } |
| 7473 | |
| 7474 | static BYTE PCIEE_ReadBit(WORD wEEPROMAddress, BYTE lastLCC) |
| 7475 | { |
| 7476 | mdelay(1); |
| 7477 | lastLCC = lastLCC | 0x01; |
| 7478 | outb(lastLCC, wEEPROMAddress); /*SK rising edge */ |
| 7479 | |
| 7480 | lastLCC = lastLCC & 0xfe; |
| 7481 | mdelay(1); |
| 7482 | outb(lastLCC, wEEPROMAddress); /*after delay, SK falling edge */ |
| 7483 | |
| 7484 | return ((inb(wEEPROMAddress) >> 3) & 1); |
| 7485 | } |
| 7486 | |
| 7487 | static BOOL PCIEE_ReadWord(WORD wAddress, WORD wLoc, WORD * pwResult) |
| 7488 | { |
| 7489 | BYTE lastLCC; |
| 7490 | WORD wEEPROMAddress = wAddress + 3; |
| 7491 | DWORD i; |
| 7492 | BYTE byResult; |
| 7493 | *pwResult = 0; |
| 7494 | lastLCC = inb(wEEPROMAddress); |
| 7495 | lastLCC = lastLCC | 0x02; |
| 7496 | lastLCC = lastLCC & 0xfe; |
| 7497 | outb(lastLCC, wEEPROMAddress); /* CS hi, SK lo */ |
| 7498 | |
| 7499 | mdelay(1); /* delay */ |
| 7500 | |
| 7501 | PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1); |
| 7502 | PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1); |
| 7503 | PCIEE_WriteBit(wEEPROMAddress, lastLCC, 0); |
| 7504 | for (i = 0; i < 8; i++) { |
| 7505 | PCIEE_WriteBit(wEEPROMAddress, lastLCC, wLoc & 0x80 ? 1 : 0); |
| 7506 | wLoc <<= 1; |
| 7507 | } |
| 7508 | |
| 7509 | for (i = 0; i < 16; i++) { |
| 7510 | byResult = PCIEE_ReadBit(wEEPROMAddress, lastLCC); |
| 7511 | *pwResult = (*pwResult << 1) | byResult; |
| 7512 | } |
| 7513 | |
| 7514 | mdelay(1); /* another delay */ |
| 7515 | |
| 7516 | lastLCC = lastLCC & 0xfd; |
| 7517 | outb(lastLCC, wEEPROMAddress); /* negate CS */ |
| 7518 | |
| 7519 | return 0; |
| 7520 | } |
| 7521 | |
| 7522 | static DWORD PCIEE_GetSerialNumber(WORD wAddress) |
| 7523 | { |
| 7524 | WORD wLo, wHi; |
| 7525 | if (PCIEE_ReadWord(wAddress, 62, &wLo)) |
| 7526 | return 0; |
| 7527 | if (PCIEE_ReadWord(wAddress, 63, &wHi)) |
| 7528 | return 0; |
| 7529 | return (((DWORD) wHi << 16) | wLo); |
| 7530 | } |
| 7531 | |
| 7532 | static int dspio[IXJMAX + 1] = |
| 7533 | { |
| 7534 | 0, |
| 7535 | }; |
| 7536 | static int xio[IXJMAX + 1] = |
| 7537 | { |
| 7538 | 0, |
| 7539 | }; |
| 7540 | |
| 7541 | module_param_array(dspio, int, NULL, 0); |
| 7542 | module_param_array(xio, int, NULL, 0); |
| 7543 | MODULE_DESCRIPTION("Quicknet VoIP Telephony card module - www.quicknet.net"); |
| 7544 | MODULE_AUTHOR("Ed Okerson <eokerson@quicknet.net>"); |
| 7545 | MODULE_LICENSE("GPL"); |
| 7546 | |
| 7547 | static void __exit ixj_exit(void) |
| 7548 | { |
| 7549 | cleanup(); |
| 7550 | } |
| 7551 | |
| 7552 | static IXJ *new_ixj(unsigned long port) |
| 7553 | { |
| 7554 | IXJ *res; |
| 7555 | if (!request_region(port, 16, "ixj DSP")) { |
| 7556 | printk(KERN_INFO "ixj: can't get I/O address 0x%lx\n", port); |
| 7557 | return NULL; |
| 7558 | } |
| 7559 | res = ixj_alloc(); |
| 7560 | if (!res) { |
| 7561 | release_region(port, 16); |
| 7562 | printk(KERN_INFO "ixj: out of memory\n"); |
| 7563 | return NULL; |
| 7564 | } |
| 7565 | res->DSPbase = port; |
| 7566 | return res; |
| 7567 | } |
| 7568 | |
| 7569 | static int __init ixj_probe_isapnp(int *cnt) |
| 7570 | { |
| 7571 | int probe = 0; |
| 7572 | int func = 0x110; |
| 7573 | struct pnp_dev *dev = NULL, *old_dev = NULL; |
| 7574 | |
| 7575 | while (1) { |
| 7576 | do { |
| 7577 | IXJ *j; |
| 7578 | int result; |
| 7579 | |
| 7580 | old_dev = dev; |
| 7581 | dev = pnp_find_dev(NULL, ISAPNP_VENDOR('Q', 'T', 'I'), |
| 7582 | ISAPNP_FUNCTION(func), old_dev); |
| 7583 | if (!dev || !dev->card) |
| 7584 | break; |
| 7585 | result = pnp_device_attach(dev); |
| 7586 | if (result < 0) { |
| 7587 | printk("pnp attach failed %d \n", result); |
| 7588 | break; |
| 7589 | } |
| 7590 | if (pnp_activate_dev(dev) < 0) { |
| 7591 | printk("pnp activate failed (out of resources?)\n"); |
| 7592 | pnp_device_detach(dev); |
| 7593 | return -ENOMEM; |
| 7594 | } |
| 7595 | |
| 7596 | if (!pnp_port_valid(dev, 0)) { |
| 7597 | pnp_device_detach(dev); |
| 7598 | return -ENODEV; |
| 7599 | } |
| 7600 | |
| 7601 | j = new_ixj(pnp_port_start(dev, 0)); |
| 7602 | if (!j) |
| 7603 | break; |
| 7604 | |
| 7605 | if (func != 0x110) |
| 7606 | j->XILINXbase = pnp_port_start(dev, 1); /* get real port */ |
| 7607 | |
| 7608 | switch (func) { |
| 7609 | case (0x110): |
| 7610 | j->cardtype = QTI_PHONEJACK; |
| 7611 | break; |
| 7612 | case (0x310): |
| 7613 | j->cardtype = QTI_LINEJACK; |
| 7614 | break; |
| 7615 | case (0x410): |
| 7616 | j->cardtype = QTI_PHONEJACK_LITE; |
| 7617 | break; |
| 7618 | } |
| 7619 | j->board = *cnt; |
| 7620 | probe = ixj_selfprobe(j); |
| 7621 | if(!probe) { |
| 7622 | j->serial = dev->card->serial; |
| 7623 | j->dev = dev; |
| 7624 | switch (func) { |
| 7625 | case 0x110: |
| 7626 | printk(KERN_INFO "ixj: found Internet PhoneJACK at 0x%x\n", j->DSPbase); |
| 7627 | break; |
| 7628 | case 0x310: |
| 7629 | printk(KERN_INFO "ixj: found Internet LineJACK at 0x%x\n", j->DSPbase); |
| 7630 | break; |
| 7631 | case 0x410: |
| 7632 | printk(KERN_INFO "ixj: found Internet PhoneJACK Lite at 0x%x\n", j->DSPbase); |
| 7633 | break; |
| 7634 | } |
| 7635 | } |
| 7636 | ++*cnt; |
| 7637 | } while (dev); |
| 7638 | if (func == 0x410) |
| 7639 | break; |
| 7640 | if (func == 0x310) |
| 7641 | func = 0x410; |
| 7642 | if (func == 0x110) |
| 7643 | func = 0x310; |
| 7644 | dev = NULL; |
| 7645 | } |
| 7646 | return probe; |
| 7647 | } |
| 7648 | |
| 7649 | static int __init ixj_probe_isa(int *cnt) |
| 7650 | { |
| 7651 | int i, probe; |
| 7652 | |
| 7653 | /* Use passed parameters for older kernels without PnP */ |
| 7654 | for (i = 0; i < IXJMAX; i++) { |
| 7655 | if (dspio[i]) { |
| 7656 | IXJ *j = new_ixj(dspio[i]); |
| 7657 | |
| 7658 | if (!j) |
| 7659 | break; |
| 7660 | |
| 7661 | j->XILINXbase = xio[i]; |
| 7662 | j->cardtype = 0; |
| 7663 | |
| 7664 | j->board = *cnt; |
| 7665 | probe = ixj_selfprobe(j); |
| 7666 | j->dev = NULL; |
| 7667 | ++*cnt; |
| 7668 | } |
| 7669 | } |
| 7670 | return 0; |
| 7671 | } |
| 7672 | |
| 7673 | static int __init ixj_probe_pci(int *cnt) |
| 7674 | { |
| 7675 | struct pci_dev *pci = NULL; |
| 7676 | int i, probe = 0; |
| 7677 | IXJ *j = NULL; |
| 7678 | |
| 7679 | for (i = 0; i < IXJMAX - *cnt; i++) { |
| 7680 | pci = pci_find_device(0x15E2, 0x0500, pci); |
| 7681 | if (!pci) |
| 7682 | break; |
| 7683 | |
| 7684 | if (pci_enable_device(pci)) |
| 7685 | break; |
| 7686 | j = new_ixj(pci_resource_start(pci, 0)); |
| 7687 | if (!j) |
| 7688 | break; |
| 7689 | |
| 7690 | j->serial = (PCIEE_GetSerialNumber)pci_resource_start(pci, 2); |
| 7691 | j->XILINXbase = j->DSPbase + 0x10; |
| 7692 | j->cardtype = QTI_PHONEJACK_PCI; |
| 7693 | j->board = *cnt; |
| 7694 | probe = ixj_selfprobe(j); |
| 7695 | if (!probe) |
| 7696 | printk(KERN_INFO "ixj: found Internet PhoneJACK PCI at 0x%x\n", j->DSPbase); |
| 7697 | ++*cnt; |
| 7698 | } |
| 7699 | return probe; |
| 7700 | } |
| 7701 | |
| 7702 | static int __init ixj_init(void) |
| 7703 | { |
| 7704 | int cnt = 0; |
| 7705 | int probe = 0; |
| 7706 | |
| 7707 | cnt = 0; |
| 7708 | |
| 7709 | /* These might be no-ops, see above. */ |
| 7710 | if ((probe = ixj_probe_isapnp(&cnt)) < 0) { |
| 7711 | return probe; |
| 7712 | } |
| 7713 | if ((probe = ixj_probe_isa(&cnt)) < 0) { |
| 7714 | return probe; |
| 7715 | } |
| 7716 | if ((probe = ixj_probe_pci(&cnt)) < 0) { |
| 7717 | return probe; |
| 7718 | } |
Domen Puncer | fba478b | 2005-05-05 16:16:13 -0700 | [diff] [blame] | 7719 | printk(KERN_INFO "ixj driver initialized.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7720 | create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL); |
| 7721 | return probe; |
| 7722 | } |
| 7723 | |
| 7724 | module_init(ixj_init); |
| 7725 | module_exit(ixj_exit); |
| 7726 | |
| 7727 | static void DAA_Coeff_US(IXJ *j) |
| 7728 | { |
| 7729 | int i; |
| 7730 | |
| 7731 | j->daa_country = DAA_US; |
| 7732 | /*----------------------------------------------- */ |
| 7733 | /* CAO */ |
| 7734 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 7735 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 7736 | } |
| 7737 | |
| 7738 | /* Bytes for IM-filter part 1 (04): 0E,32,E2,2F,C2,5A,C0,00 */ |
| 7739 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x03; |
| 7740 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0x4B; |
| 7741 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x5D; |
| 7742 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xCD; |
| 7743 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x24; |
| 7744 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xC5; |
| 7745 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0; |
| 7746 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 7747 | /* Bytes for IM-filter part 2 (05): 72,85,00,0E,2B,3A,D0,08 */ |
| 7748 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x71; |
| 7749 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x1A; |
| 7750 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 7751 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A; |
| 7752 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xB5; |
| 7753 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33; |
| 7754 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0; |
| 7755 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 7756 | /* Bytes for FRX-filter (08): 03,8F,48,F2,8F,48,70,08 */ |
| 7757 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x05; |
| 7758 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xA3; |
| 7759 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x72; |
| 7760 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34; |
| 7761 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x3F; |
| 7762 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x3B; |
| 7763 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30; |
| 7764 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 7765 | /* Bytes for FRR-filter (07): 04,8F,38,7F,9B,EA,B0,08 */ |
| 7766 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x05; |
| 7767 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87; |
| 7768 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9; |
| 7769 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x3E; |
| 7770 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x32; |
| 7771 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xDA; |
| 7772 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0; |
| 7773 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 7774 | /* Bytes for AX-filter (0A): 16,55,DD,CA */ |
| 7775 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x41; |
| 7776 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5; |
| 7777 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 7778 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 7779 | /* Bytes for AR-filter (09): 52,D3,11,42 */ |
| 7780 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25; |
| 7781 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7; |
| 7782 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10; |
| 7783 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6; |
| 7784 | /* Bytes for TH-filter part 1 (00): 00,42,48,81,B3,80,00,98 */ |
| 7785 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00; |
| 7786 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42; |
| 7787 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48; |
| 7788 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81; |
| 7789 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA5; |
| 7790 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80; |
| 7791 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 7792 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 7793 | /* Bytes for TH-filter part 2 (01): 02,F2,33,A0,68,AB,8A,AD */ |
| 7794 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 7795 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xA2; |
| 7796 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2B; |
| 7797 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0; |
| 7798 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8; |
| 7799 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAB; |
| 7800 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81; |
| 7801 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xCC; |
| 7802 | /* Bytes for TH-filter part 3 (02): 00,88,DA,54,A4,BA,2D,BB */ |
| 7803 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 7804 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 7805 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xD2; |
| 7806 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x24; |
| 7807 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBA; |
| 7808 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xA9; |
| 7809 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x3B; |
| 7810 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xA6; |
| 7811 | /* ; (10K, 0.68uF) */ |
| 7812 | /* */ |
| 7813 | /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */ |
| 7814 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 7815 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C; |
| 7816 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93; |
| 7817 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A; |
| 7818 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22; |
| 7819 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12; |
| 7820 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3; |
| 7821 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 7822 | /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */ |
| 7823 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12; |
| 7824 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2; |
| 7825 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 7826 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 7827 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22; |
| 7828 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A; |
| 7829 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; |
| 7830 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 7831 | |
| 7832 | /* Levelmetering Ringing (0D):B2,45,0F,8E */ |
| 7833 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; |
| 7834 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35; |
| 7835 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; |
| 7836 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; |
| 7837 | |
| 7838 | /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */ |
| 7839 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1C; */ |
| 7840 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0xB3; */ |
| 7841 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0xAB; */ |
| 7842 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xAB; */ |
| 7843 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x54; */ |
| 7844 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x2D; */ |
| 7845 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0x62; */ |
| 7846 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x2D; */ |
| 7847 | /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */ |
| 7848 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x2D; */ |
| 7849 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x62; */ |
| 7850 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; */ |
| 7851 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBB; */ |
| 7852 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x2A; */ |
| 7853 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7D; */ |
| 7854 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; */ |
| 7855 | /* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD4; */ |
| 7856 | /* */ |
| 7857 | /* Levelmetering Ringing (0D):B2,45,0F,8E */ |
| 7858 | /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; */ |
| 7859 | /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x05; */ |
| 7860 | /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; */ |
| 7861 | /* j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; */ |
| 7862 | |
| 7863 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 7864 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 7865 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 7866 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 7867 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 7868 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 7869 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 7870 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 7871 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 7872 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 7873 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 7874 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 7875 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 7876 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 7877 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 7878 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 7879 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 7880 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 7881 | /* */ |
| 7882 | /* ;CR Registers */ |
| 7883 | /* Config. Reg. 0 (filters) (cr0):FE ; CLK gen. by crystal */ |
| 7884 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 7885 | /* Config. Reg. 1 (dialing) (cr1):05 */ |
| 7886 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 7887 | /* Config. Reg. 2 (caller ID) (cr2):04 */ |
| 7888 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 7889 | /* Config. Reg. 3 (testloops) (cr3):03 ; SEL Bit==0, HP-disabled */ |
| 7890 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 7891 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 7892 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 7893 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 7894 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 7895 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 7896 | /* */ |
| 7897 | /* ;xr Registers */ |
| 7898 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 7899 | |
| 7900 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 7901 | /* Ext. Reg. 1 (Interrupt enable) (xr1):3C Cadence, RING, Caller ID, VDD_OK */ |
| 7902 | |
| 7903 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x3C; |
| 7904 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 7905 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 7906 | /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off == 1 */ |
| 7907 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x3B; /*0x32; */ |
| 7908 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 7909 | |
| 7910 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 7911 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 7912 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 7913 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 7914 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 7915 | /* Ext. Reg. 7 (Vdd) (xr7):40 */ |
| 7916 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */ |
| 7917 | /* */ |
| 7918 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 7919 | /* 12,33,5A,C3 ; 770 Hz */ |
| 7920 | /* 13,3C,5B,32 ; 852 Hz */ |
| 7921 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 7922 | |
| 7923 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 7924 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 7925 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 7926 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 7927 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 7928 | /* EC,1D,52,22 ; 1336 Hz */ |
| 7929 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 7930 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 7931 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 7932 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 7933 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 7934 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 7935 | } |
| 7936 | |
| 7937 | static void DAA_Coeff_UK(IXJ *j) |
| 7938 | { |
| 7939 | int i; |
| 7940 | |
| 7941 | j->daa_country = DAA_UK; |
| 7942 | /*----------------------------------------------- */ |
| 7943 | /* CAO */ |
| 7944 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 7945 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 7946 | } |
| 7947 | |
| 7948 | /* Bytes for IM-filter part 1 (04): 00,C2,BB,A8,CB,81,A0,00 */ |
| 7949 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00; |
| 7950 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xC2; |
| 7951 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB; |
| 7952 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xA8; |
| 7953 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xCB; |
| 7954 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81; |
| 7955 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0; |
| 7956 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 7957 | /* Bytes for IM-filter part 2 (05): 40,00,00,0A,A4,33,E0,08 */ |
| 7958 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x40; |
| 7959 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x00; |
| 7960 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 7961 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0A; |
| 7962 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xA4; |
| 7963 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33; |
| 7964 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0; |
| 7965 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 7966 | /* Bytes for FRX-filter (08): 07,9B,ED,24,B2,A2,A0,08 */ |
| 7967 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07; |
| 7968 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9B; |
| 7969 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xED; |
| 7970 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x24; |
| 7971 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0xB2; |
| 7972 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0xA2; |
| 7973 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xA0; |
| 7974 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 7975 | /* Bytes for FRR-filter (07): 0F,92,F2,B2,87,D2,30,08 */ |
| 7976 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F; |
| 7977 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x92; |
| 7978 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF2; |
| 7979 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0xB2; |
| 7980 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87; |
| 7981 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xD2; |
| 7982 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x30; |
| 7983 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 7984 | /* Bytes for AX-filter (0A): 1B,A5,DD,CA */ |
| 7985 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x1B; |
| 7986 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xA5; |
| 7987 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 7988 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 7989 | /* Bytes for AR-filter (09): E2,27,10,D6 */ |
| 7990 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2; |
| 7991 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x27; |
| 7992 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10; |
| 7993 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6; |
| 7994 | /* Bytes for TH-filter part 1 (00): 80,2D,38,8B,D0,00,00,98 */ |
| 7995 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80; |
| 7996 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x2D; |
| 7997 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x38; |
| 7998 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x8B; |
| 7999 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xD0; |
| 8000 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x00; |
| 8001 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 8002 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 8003 | /* Bytes for TH-filter part 2 (01): 02,5A,53,F0,0B,5F,84,D4 */ |
| 8004 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 8005 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x5A; |
| 8006 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x53; |
| 8007 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xF0; |
| 8008 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x0B; |
| 8009 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5F; |
| 8010 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x84; |
| 8011 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xD4; |
| 8012 | /* Bytes for TH-filter part 3 (02): 00,88,6A,A4,8F,52,F5,32 */ |
| 8013 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 8014 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 8015 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x6A; |
| 8016 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA4; |
| 8017 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x8F; |
| 8018 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x52; |
| 8019 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xF5; |
| 8020 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x32; |
| 8021 | /* ; idle */ |
| 8022 | /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */ |
| 8023 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 8024 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C; |
| 8025 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93; |
| 8026 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A; |
| 8027 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22; |
| 8028 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12; |
| 8029 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3; |
| 8030 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 8031 | /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */ |
| 8032 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12; |
| 8033 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2; |
| 8034 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 8035 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 8036 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22; |
| 8037 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A; |
| 8038 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; |
| 8039 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 8040 | /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V less possible? */ |
| 8041 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; |
| 8042 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35; |
| 8043 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; |
| 8044 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; |
| 8045 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 8046 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 8047 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 8048 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 8049 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 8050 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 8051 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 8052 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 8053 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 8054 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 8055 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 8056 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 8057 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 8058 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 8059 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 8060 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 8061 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 8062 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 8063 | /* ;CR Registers */ |
| 8064 | /* Config. Reg. 0 (filters) (cr0):FF */ |
| 8065 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 8066 | /* Config. Reg. 1 (dialing) (cr1):05 */ |
| 8067 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 8068 | /* Config. Reg. 2 (caller ID) (cr2):04 */ |
| 8069 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 8070 | /* Config. Reg. 3 (testloops) (cr3):00 ; */ |
| 8071 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 8072 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 8073 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 8074 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 8075 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 8076 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 8077 | /* ;xr Registers */ |
| 8078 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 8079 | |
| 8080 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 8081 | /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */ |
| 8082 | |
| 8083 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */ |
| 8084 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 8085 | |
| 8086 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 8087 | /* Ext. Reg. 3 (DC Char) (xr3):36 ; */ |
| 8088 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36; |
| 8089 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 8090 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 8091 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 8092 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 8093 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 8094 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 8095 | /* Ext. Reg. 7 (Vdd) (xr7):46 */ |
| 8096 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */ |
| 8097 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 8098 | /* 12,33,5A,C3 ; 770 Hz */ |
| 8099 | /* 13,3C,5B,32 ; 852 Hz */ |
| 8100 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 8101 | |
| 8102 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 8103 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 8104 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 8105 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 8106 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 8107 | /* EC,1D,52,22 ; 1336 Hz */ |
| 8108 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 8109 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 8110 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 8111 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 8112 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 8113 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 8114 | } |
| 8115 | |
| 8116 | |
| 8117 | static void DAA_Coeff_France(IXJ *j) |
| 8118 | { |
| 8119 | int i; |
| 8120 | |
| 8121 | j->daa_country = DAA_FRANCE; |
| 8122 | /*----------------------------------------------- */ |
| 8123 | /* CAO */ |
| 8124 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 8125 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 8126 | } |
| 8127 | |
| 8128 | /* Bytes for IM-filter part 1 (04): 02,A2,43,2C,22,AF,A0,00 */ |
| 8129 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x02; |
| 8130 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA2; |
| 8131 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0x43; |
| 8132 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2C; |
| 8133 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0x22; |
| 8134 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xAF; |
| 8135 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0; |
| 8136 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 8137 | /* Bytes for IM-filter part 2 (05): 67,CE,00,0C,22,33,E0,08 */ |
| 8138 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x67; |
| 8139 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xCE; |
| 8140 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 8141 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x2C; |
| 8142 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x22; |
| 8143 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33; |
| 8144 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0; |
| 8145 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 8146 | /* Bytes for FRX-filter (08): 07,9A,28,F6,23,4A,B0,08 */ |
| 8147 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07; |
| 8148 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x9A; |
| 8149 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x28; |
| 8150 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0xF6; |
| 8151 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x23; |
| 8152 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x4A; |
| 8153 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xB0; |
| 8154 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 8155 | /* Bytes for FRR-filter (07): 03,8F,F9,2F,9E,FA,20,08 */ |
| 8156 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03; |
| 8157 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F; |
| 8158 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xF9; |
| 8159 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F; |
| 8160 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9E; |
| 8161 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xFA; |
| 8162 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20; |
| 8163 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 8164 | /* Bytes for AX-filter (0A): 16,B5,DD,CA */ |
| 8165 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x16; |
| 8166 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xB5; |
| 8167 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 8168 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 8169 | /* Bytes for AR-filter (09): 52,C7,10,D6 */ |
| 8170 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0xE2; |
| 8171 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xC7; |
| 8172 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10; |
| 8173 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6; |
| 8174 | /* Bytes for TH-filter part 1 (00): 00,42,48,81,A6,80,00,98 */ |
| 8175 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00; |
| 8176 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42; |
| 8177 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48; |
| 8178 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81; |
| 8179 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xA6; |
| 8180 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80; |
| 8181 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 8182 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 8183 | /* Bytes for TH-filter part 2 (01): 02,AC,2A,30,78,AC,8A,2C */ |
| 8184 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 8185 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAC; |
| 8186 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A; |
| 8187 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x30; |
| 8188 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x78; |
| 8189 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0xAC; |
| 8190 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x8A; |
| 8191 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x2C; |
| 8192 | /* Bytes for TH-filter part 3 (02): 00,88,DA,A5,22,BA,2C,45 */ |
| 8193 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 8194 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 8195 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA; |
| 8196 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0xA5; |
| 8197 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x22; |
| 8198 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xBA; |
| 8199 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x2C; |
| 8200 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x45; |
| 8201 | /* ; idle */ |
| 8202 | /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */ |
| 8203 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 8204 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C; |
| 8205 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93; |
| 8206 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A; |
| 8207 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22; |
| 8208 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12; |
| 8209 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3; |
| 8210 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 8211 | /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */ |
| 8212 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12; |
| 8213 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2; |
| 8214 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 8215 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 8216 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22; |
| 8217 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A; |
| 8218 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; |
| 8219 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 8220 | /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */ |
| 8221 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32; |
| 8222 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45; |
| 8223 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5; |
| 8224 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84; |
| 8225 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 8226 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 8227 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 8228 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 8229 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 8230 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 8231 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 8232 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 8233 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 8234 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 8235 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 8236 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 8237 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 8238 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 8239 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 8240 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 8241 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 8242 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 8243 | /* ;CR Registers */ |
| 8244 | /* Config. Reg. 0 (filters) (cr0):FF */ |
| 8245 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 8246 | /* Config. Reg. 1 (dialing) (cr1):05 */ |
| 8247 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 8248 | /* Config. Reg. 2 (caller ID) (cr2):04 */ |
| 8249 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 8250 | /* Config. Reg. 3 (testloops) (cr3):00 ; */ |
| 8251 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 8252 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 8253 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 8254 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 8255 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 8256 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 8257 | /* ;xr Registers */ |
| 8258 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 8259 | |
| 8260 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 8261 | /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */ |
| 8262 | |
| 8263 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */ |
| 8264 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 8265 | |
| 8266 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 8267 | /* Ext. Reg. 3 (DC Char) (xr3):36 ; */ |
| 8268 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x36; |
| 8269 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 8270 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 8271 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 8272 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 8273 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 8274 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 8275 | /* Ext. Reg. 7 (Vdd) (xr7):46 */ |
| 8276 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x46; /* 0x46 ??? Should it be 0x00? */ |
| 8277 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 8278 | /* 12,33,5A,C3 ; 770 Hz */ |
| 8279 | /* 13,3C,5B,32 ; 852 Hz */ |
| 8280 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 8281 | |
| 8282 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 8283 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 8284 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 8285 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 8286 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 8287 | /* EC,1D,52,22 ; 1336 Hz */ |
| 8288 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 8289 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 8290 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 8291 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 8292 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 8293 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 8294 | } |
| 8295 | |
| 8296 | |
| 8297 | static void DAA_Coeff_Germany(IXJ *j) |
| 8298 | { |
| 8299 | int i; |
| 8300 | |
| 8301 | j->daa_country = DAA_GERMANY; |
| 8302 | /*----------------------------------------------- */ |
| 8303 | /* CAO */ |
| 8304 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 8305 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 8306 | } |
| 8307 | |
| 8308 | /* Bytes for IM-filter part 1 (04): 00,CE,BB,B8,D2,81,B0,00 */ |
| 8309 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00; |
| 8310 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xCE; |
| 8311 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xBB; |
| 8312 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0xB8; |
| 8313 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xD2; |
| 8314 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x81; |
| 8315 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xB0; |
| 8316 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 8317 | /* Bytes for IM-filter part 2 (05): 45,8F,00,0C,D2,3A,D0,08 */ |
| 8318 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x45; |
| 8319 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x8F; |
| 8320 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 8321 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0C; |
| 8322 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0xD2; |
| 8323 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x3A; |
| 8324 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xD0; |
| 8325 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 8326 | /* Bytes for FRX-filter (08): 07,AA,E2,34,24,89,20,08 */ |
| 8327 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07; |
| 8328 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0xAA; |
| 8329 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2; |
| 8330 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34; |
| 8331 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x24; |
| 8332 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x89; |
| 8333 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x20; |
| 8334 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 8335 | /* Bytes for FRR-filter (07): 02,87,FA,37,9A,CA,B0,08 */ |
| 8336 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x02; |
| 8337 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x87; |
| 8338 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xFA; |
| 8339 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x37; |
| 8340 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x9A; |
| 8341 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCA; |
| 8342 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xB0; |
| 8343 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 8344 | /* Bytes for AX-filter (0A): 72,D5,DD,CA */ |
| 8345 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x72; |
| 8346 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xD5; |
| 8347 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 8348 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 8349 | /* Bytes for AR-filter (09): 72,42,13,4B */ |
| 8350 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x72; |
| 8351 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x42; |
| 8352 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x13; |
| 8353 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0x4B; |
| 8354 | /* Bytes for TH-filter part 1 (00): 80,52,48,81,AD,80,00,98 */ |
| 8355 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80; |
| 8356 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52; |
| 8357 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48; |
| 8358 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81; |
| 8359 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAD; |
| 8360 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80; |
| 8361 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 8362 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 8363 | /* Bytes for TH-filter part 2 (01): 02,42,5A,20,E8,1A,81,27 */ |
| 8364 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 8365 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0x42; |
| 8366 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x5A; |
| 8367 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20; |
| 8368 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0xE8; |
| 8369 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x1A; |
| 8370 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x81; |
| 8371 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x27; |
| 8372 | /* Bytes for TH-filter part 3 (02): 00,88,63,26,BD,4B,A3,C2 */ |
| 8373 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 8374 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 8375 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x63; |
| 8376 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x26; |
| 8377 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0xBD; |
| 8378 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x4B; |
| 8379 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0xA3; |
| 8380 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xC2; |
| 8381 | /* ; (10K, 0.68uF) */ |
| 8382 | /* Bytes for Ringing part 1 (03):1B,3B,9B,BA,D4,1C,B3,23 */ |
| 8383 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 8384 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3B; |
| 8385 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x9B; |
| 8386 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0xBA; |
| 8387 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0xD4; |
| 8388 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x1C; |
| 8389 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xB3; |
| 8390 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 8391 | /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */ |
| 8392 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x13; |
| 8393 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x42; |
| 8394 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 8395 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 8396 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0xD4; |
| 8397 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x73; |
| 8398 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0xCA; |
| 8399 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 8400 | /* Levelmetering Ringing (0D):B2,45,0F,8E */ |
| 8401 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xB2; |
| 8402 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45; |
| 8403 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; |
| 8404 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; |
| 8405 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 8406 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 8407 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 8408 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 8409 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 8410 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 8411 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 8412 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 8413 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 8414 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 8415 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 8416 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 8417 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 8418 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 8419 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 8420 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 8421 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 8422 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 8423 | /* ;CR Registers */ |
| 8424 | /* Config. Reg. 0 (filters) (cr0):FF ; all Filters enabled, CLK from ext. source */ |
| 8425 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 8426 | /* Config. Reg. 1 (dialing) (cr1):05 ; Manual Ring, Ring metering enabled */ |
| 8427 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 8428 | /* Config. Reg. 2 (caller ID) (cr2):04 ; Analog Gain 0dB, FSC internal */ |
| 8429 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 8430 | /* Config. Reg. 3 (testloops) (cr3):00 ; SEL Bit==0, HP-enabled */ |
| 8431 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 8432 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 8433 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 8434 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 8435 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 8436 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 8437 | /* ;xr Registers */ |
| 8438 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 8439 | |
| 8440 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 8441 | /* Ext. Reg. 1 (Interrupt enable) (xr1):1C ; Ring, CID, VDDOK Interrupts enabled */ |
| 8442 | |
| 8443 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */ |
| 8444 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 8445 | |
| 8446 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 8447 | /* Ext. Reg. 3 (DC Char) (xr3):32 ; B-Filter Off==1, U0=3.5V, R=200Ohm */ |
| 8448 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x32; |
| 8449 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 8450 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 8451 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 8452 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 8453 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 8454 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 8455 | /* Ext. Reg. 7 (Vdd) (xr7):40 ; VDD=4.25 V */ |
| 8456 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */ |
| 8457 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 8458 | /* 12,33,5A,C3 ; 770 Hz */ |
| 8459 | /* 13,3C,5B,32 ; 852 Hz */ |
| 8460 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 8461 | |
| 8462 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 8463 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 8464 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 8465 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 8466 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 8467 | /* EC,1D,52,22 ; 1336 Hz */ |
| 8468 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 8469 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 8470 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 8471 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 8472 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 8473 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 8474 | } |
| 8475 | |
| 8476 | |
| 8477 | static void DAA_Coeff_Australia(IXJ *j) |
| 8478 | { |
| 8479 | int i; |
| 8480 | |
| 8481 | j->daa_country = DAA_AUSTRALIA; |
| 8482 | /*----------------------------------------------- */ |
| 8483 | /* CAO */ |
| 8484 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 8485 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 8486 | } |
| 8487 | |
| 8488 | /* Bytes for IM-filter part 1 (04): 00,A3,AA,28,B3,82,D0,00 */ |
| 8489 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x00; |
| 8490 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xA3; |
| 8491 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xAA; |
| 8492 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x28; |
| 8493 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xB3; |
| 8494 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0x82; |
| 8495 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xD0; |
| 8496 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 8497 | /* Bytes for IM-filter part 2 (05): 70,96,00,09,32,6B,C0,08 */ |
| 8498 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x70; |
| 8499 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0x96; |
| 8500 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 8501 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x09; |
| 8502 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x32; |
| 8503 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x6B; |
| 8504 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xC0; |
| 8505 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 8506 | /* Bytes for FRX-filter (08): 07,96,E2,34,32,9B,30,08 */ |
| 8507 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x07; |
| 8508 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x96; |
| 8509 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0xE2; |
| 8510 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x34; |
| 8511 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x32; |
| 8512 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x9B; |
| 8513 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0x30; |
| 8514 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 8515 | /* Bytes for FRR-filter (07): 0F,9A,E9,2F,22,CC,A0,08 */ |
| 8516 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x0F; |
| 8517 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x9A; |
| 8518 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0xE9; |
| 8519 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x2F; |
| 8520 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x22; |
| 8521 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xCC; |
| 8522 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0xA0; |
| 8523 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 8524 | /* Bytes for AX-filter (0A): CB,45,DD,CA */ |
| 8525 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0xCB; |
| 8526 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0x45; |
| 8527 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 8528 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 8529 | /* Bytes for AR-filter (09): 1B,67,10,D6 */ |
| 8530 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x1B; |
| 8531 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0x67; |
| 8532 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10; |
| 8533 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6; |
| 8534 | /* Bytes for TH-filter part 1 (00): 80,52,48,81,AF,80,00,98 */ |
| 8535 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x80; |
| 8536 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x52; |
| 8537 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48; |
| 8538 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81; |
| 8539 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAF; |
| 8540 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80; |
| 8541 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 8542 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 8543 | /* Bytes for TH-filter part 2 (01): 02,DB,52,B0,38,01,82,AC */ |
| 8544 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 8545 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xDB; |
| 8546 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x52; |
| 8547 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0xB0; |
| 8548 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x38; |
| 8549 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x01; |
| 8550 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x82; |
| 8551 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0xAC; |
| 8552 | /* Bytes for TH-filter part 3 (02): 00,88,4A,3E,2C,3B,24,46 */ |
| 8553 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 8554 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 8555 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0x4A; |
| 8556 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x3E; |
| 8557 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x2C; |
| 8558 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0x3B; |
| 8559 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x24; |
| 8560 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0x46; |
| 8561 | /* ; idle */ |
| 8562 | /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */ |
| 8563 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 8564 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C; |
| 8565 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93; |
| 8566 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A; |
| 8567 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22; |
| 8568 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12; |
| 8569 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3; |
| 8570 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 8571 | /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */ |
| 8572 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12; |
| 8573 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2; |
| 8574 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 8575 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 8576 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22; |
| 8577 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A; |
| 8578 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; |
| 8579 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 8580 | /* Levelmetering Ringing (0D):32,45,B5,84 ; 50Hz 20V */ |
| 8581 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0x32; |
| 8582 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x45; |
| 8583 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0xB5; |
| 8584 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x84; |
| 8585 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 8586 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 8587 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 8588 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 8589 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 8590 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 8591 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 8592 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 8593 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 8594 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 8595 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 8596 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 8597 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 8598 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 8599 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 8600 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 8601 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 8602 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 8603 | /* ;CR Registers */ |
| 8604 | /* Config. Reg. 0 (filters) (cr0):FF */ |
| 8605 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 8606 | /* Config. Reg. 1 (dialing) (cr1):05 */ |
| 8607 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 8608 | /* Config. Reg. 2 (caller ID) (cr2):04 */ |
| 8609 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 8610 | /* Config. Reg. 3 (testloops) (cr3):00 ; */ |
| 8611 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 8612 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 8613 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 8614 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 8615 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 8616 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 8617 | /* ;xr Registers */ |
| 8618 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 8619 | |
| 8620 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 8621 | /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */ |
| 8622 | |
| 8623 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */ |
| 8624 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 8625 | |
| 8626 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 8627 | /* Ext. Reg. 3 (DC Char) (xr3):2B ; */ |
| 8628 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x2B; |
| 8629 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 8630 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 8631 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 8632 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 8633 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 8634 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 8635 | /* Ext. Reg. 7 (Vdd) (xr7):40 */ |
| 8636 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */ |
| 8637 | |
| 8638 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 8639 | /* 12,33,5A,C3 ; 770 Hz */ |
| 8640 | /* 13,3C,5B,32 ; 852 Hz */ |
| 8641 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 8642 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 8643 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 8644 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 8645 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 8646 | |
| 8647 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 8648 | /* EC,1D,52,22 ; 1336 Hz */ |
| 8649 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 8650 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 8651 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 8652 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 8653 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 8654 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 8655 | } |
| 8656 | |
| 8657 | static void DAA_Coeff_Japan(IXJ *j) |
| 8658 | { |
| 8659 | int i; |
| 8660 | |
| 8661 | j->daa_country = DAA_JAPAN; |
| 8662 | /*----------------------------------------------- */ |
| 8663 | /* CAO */ |
| 8664 | for (i = 0; i < ALISDAA_CALLERID_SIZE; i++) { |
| 8665 | j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID[i] = 0; |
| 8666 | } |
| 8667 | |
| 8668 | /* Bytes for IM-filter part 1 (04): 06,BD,E2,2D,BA,F9,A0,00 */ |
| 8669 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[7] = 0x06; |
| 8670 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[6] = 0xBD; |
| 8671 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[5] = 0xE2; |
| 8672 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[4] = 0x2D; |
| 8673 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[3] = 0xBA; |
| 8674 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[2] = 0xF9; |
| 8675 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[1] = 0xA0; |
| 8676 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_1[0] = 0x00; |
| 8677 | /* Bytes for IM-filter part 2 (05): 6F,F7,00,0E,34,33,E0,08 */ |
| 8678 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[7] = 0x6F; |
| 8679 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[6] = 0xF7; |
| 8680 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[5] = 0x00; |
| 8681 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[4] = 0x0E; |
| 8682 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[3] = 0x34; |
| 8683 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[2] = 0x33; |
| 8684 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[1] = 0xE0; |
| 8685 | j->m_DAAShadowRegs.COP_REGS.COP.IMFilterCoeff_2[0] = 0x08; |
| 8686 | /* Bytes for FRX-filter (08): 02,8F,68,77,9C,58,F0,08 */ |
| 8687 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[7] = 0x02; |
| 8688 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[6] = 0x8F; |
| 8689 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[5] = 0x68; |
| 8690 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[4] = 0x77; |
| 8691 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[3] = 0x9C; |
| 8692 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[2] = 0x58; |
| 8693 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[1] = 0xF0; |
| 8694 | j->m_DAAShadowRegs.COP_REGS.COP.FRXFilterCoeff[0] = 0x08; |
| 8695 | /* Bytes for FRR-filter (07): 03,8F,38,73,87,EA,20,08 */ |
| 8696 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[7] = 0x03; |
| 8697 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[6] = 0x8F; |
| 8698 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[5] = 0x38; |
| 8699 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[4] = 0x73; |
| 8700 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[3] = 0x87; |
| 8701 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[2] = 0xEA; |
| 8702 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[1] = 0x20; |
| 8703 | j->m_DAAShadowRegs.COP_REGS.COP.FRRFilterCoeff[0] = 0x08; |
| 8704 | /* Bytes for AX-filter (0A): 51,C5,DD,CA */ |
| 8705 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[3] = 0x51; |
| 8706 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[2] = 0xC5; |
| 8707 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[1] = 0xDD; |
| 8708 | j->m_DAAShadowRegs.COP_REGS.COP.AXFilterCoeff[0] = 0xCA; |
| 8709 | /* Bytes for AR-filter (09): 25,A7,10,D6 */ |
| 8710 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[3] = 0x25; |
| 8711 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[2] = 0xA7; |
| 8712 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[1] = 0x10; |
| 8713 | j->m_DAAShadowRegs.COP_REGS.COP.ARFilterCoeff[0] = 0xD6; |
| 8714 | /* Bytes for TH-filter part 1 (00): 00,42,48,81,AE,80,00,98 */ |
| 8715 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[7] = 0x00; |
| 8716 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[6] = 0x42; |
| 8717 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[5] = 0x48; |
| 8718 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[4] = 0x81; |
| 8719 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[3] = 0xAE; |
| 8720 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[2] = 0x80; |
| 8721 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[1] = 0x00; |
| 8722 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_1[0] = 0x98; |
| 8723 | /* Bytes for TH-filter part 2 (01): 02,AB,2A,20,99,5B,89,28 */ |
| 8724 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[7] = 0x02; |
| 8725 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[6] = 0xAB; |
| 8726 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[5] = 0x2A; |
| 8727 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[4] = 0x20; |
| 8728 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[3] = 0x99; |
| 8729 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[2] = 0x5B; |
| 8730 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[1] = 0x89; |
| 8731 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_2[0] = 0x28; |
| 8732 | /* Bytes for TH-filter part 3 (02): 00,88,DA,25,34,C5,4C,BA */ |
| 8733 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[7] = 0x00; |
| 8734 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[6] = 0x88; |
| 8735 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[5] = 0xDA; |
| 8736 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[4] = 0x25; |
| 8737 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[3] = 0x34; |
| 8738 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[2] = 0xC5; |
| 8739 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[1] = 0x4C; |
| 8740 | j->m_DAAShadowRegs.COP_REGS.COP.THFilterCoeff_3[0] = 0xBA; |
| 8741 | /* ; idle */ |
| 8742 | /* Bytes for Ringing part 1 (03):1B,3C,93,3A,22,12,A3,23 */ |
| 8743 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[7] = 0x1B; |
| 8744 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[6] = 0x3C; |
| 8745 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[5] = 0x93; |
| 8746 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[4] = 0x3A; |
| 8747 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[3] = 0x22; |
| 8748 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x12; |
| 8749 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0xA3; |
| 8750 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x23; |
| 8751 | /* Bytes for Ringing part 2 (06):12,A2,A6,BA,22,7A,0A,D5 */ |
| 8752 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x12; |
| 8753 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0xA2; |
| 8754 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; |
| 8755 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[4] = 0xBA; |
| 8756 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[3] = 0x22; |
| 8757 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[2] = 0x7A; |
| 8758 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[1] = 0x0A; |
| 8759 | j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[0] = 0xD5; |
| 8760 | /* Levelmetering Ringing (0D):AA,35,0F,8E ; 25Hz 30V ????????? */ |
| 8761 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[3] = 0xAA; |
| 8762 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[2] = 0x35; |
| 8763 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[1] = 0x0F; |
| 8764 | j->m_DAAShadowRegs.COP_REGS.COP.LevelmeteringRinging[0] = 0x8E; |
| 8765 | /* Caller ID 1st Tone (0E):CA,0E,CA,09,99,99,99,99 */ |
| 8766 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[7] = 0xCA; |
| 8767 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[6] = 0x0E; |
| 8768 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[5] = 0xCA; |
| 8769 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[4] = 0x09; |
| 8770 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[3] = 0x99; |
| 8771 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[2] = 0x99; |
| 8772 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[1] = 0x99; |
| 8773 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID1stTone[0] = 0x99; |
| 8774 | /* Caller ID 2nd Tone (0F):FD,B5,BA,07,DA,00,00,00 */ |
| 8775 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[7] = 0xFD; |
| 8776 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[6] = 0xB5; |
| 8777 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[5] = 0xBA; |
| 8778 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[4] = 0x07; |
| 8779 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[3] = 0xDA; |
| 8780 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[2] = 0x00; |
| 8781 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[1] = 0x00; |
| 8782 | j->m_DAAShadowRegs.COP_REGS.COP.CallerID2ndTone[0] = 0x00; |
| 8783 | /* ;CR Registers */ |
| 8784 | /* Config. Reg. 0 (filters) (cr0):FF */ |
| 8785 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr0.reg = 0xFF; |
| 8786 | /* Config. Reg. 1 (dialing) (cr1):05 */ |
| 8787 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr1.reg = 0x05; |
| 8788 | /* Config. Reg. 2 (caller ID) (cr2):04 */ |
| 8789 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr2.reg = 0x04; |
| 8790 | /* Config. Reg. 3 (testloops) (cr3):00 ; */ |
| 8791 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr3.reg = 0x00; |
| 8792 | /* Config. Reg. 4 (analog gain) (cr4):02 */ |
| 8793 | j->m_DAAShadowRegs.SOP_REGS.SOP.cr4.reg = 0x02; |
| 8794 | /* Config. Reg. 5 (Version) (cr5):02 */ |
| 8795 | /* Config. Reg. 6 (Reserved) (cr6):00 */ |
| 8796 | /* Config. Reg. 7 (Reserved) (cr7):00 */ |
| 8797 | /* ;xr Registers */ |
| 8798 | /* Ext. Reg. 0 (Interrupt Reg.) (xr0):02 */ |
| 8799 | |
| 8800 | j->m_DAAShadowRegs.XOP_xr0_W.reg = 0x02; /* SO_1 set to '1' because it is inverted. */ |
| 8801 | /* Ext. Reg. 1 (Interrupt enable) (xr1):1C */ |
| 8802 | |
| 8803 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr1.reg = 0x1C; /* RING, Caller ID, VDD_OK */ |
| 8804 | /* Ext. Reg. 2 (Cadence Time Out) (xr2):7D */ |
| 8805 | |
| 8806 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr2.reg = 0x7D; |
| 8807 | /* Ext. Reg. 3 (DC Char) (xr3):22 ; */ |
| 8808 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr3.reg = 0x22; |
| 8809 | /* Ext. Reg. 4 (Cadence) (xr4):00 */ |
| 8810 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr4.reg = 0x00; |
| 8811 | /* Ext. Reg. 5 (Ring timer) (xr5):22 */ |
| 8812 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr5.reg = 0x22; |
| 8813 | /* Ext. Reg. 6 (Power State) (xr6):00 */ |
| 8814 | j->m_DAAShadowRegs.XOP_xr6_W.reg = 0x00; |
| 8815 | /* Ext. Reg. 7 (Vdd) (xr7):40 */ |
| 8816 | j->m_DAAShadowRegs.XOP_REGS.XOP.xr7.reg = 0x40; /* 0x40 ??? Should it be 0x00? */ |
| 8817 | /* DTMF Tone 1 (0B): 11,B3,5A,2C ; 697 Hz */ |
| 8818 | /* 12,33,5A,C3 ; 770 Hz */ |
| 8819 | /* 13,3C,5B,32 ; 852 Hz */ |
| 8820 | /* 1D,1B,5C,CC ; 941 Hz */ |
| 8821 | |
| 8822 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[3] = 0x11; |
| 8823 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[2] = 0xB3; |
| 8824 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[1] = 0x5A; |
| 8825 | j->m_DAAShadowRegs.COP_REGS.COP.Tone1Coeff[0] = 0x2C; |
| 8826 | /* DTMF Tone 2 (0C): 32,32,52,B3 ; 1209 Hz */ |
| 8827 | /* EC,1D,52,22 ; 1336 Hz */ |
| 8828 | /* AA,AC,51,D2 ; 1477 Hz */ |
| 8829 | /* 9B,3B,51,25 ; 1633 Hz */ |
| 8830 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[3] = 0x32; |
| 8831 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[2] = 0x32; |
| 8832 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[1] = 0x52; |
| 8833 | j->m_DAAShadowRegs.COP_REGS.COP.Tone2Coeff[0] = 0xB3; |
| 8834 | } |
| 8835 | |
| 8836 | static s16 tone_table[][19] = |
| 8837 | { |
| 8838 | { /* f20_50[] 11 */ |
| 8839 | 32538, /* A1 = 1.985962 */ |
| 8840 | -32325, /* A2 = -0.986511 */ |
| 8841 | -343, /* B2 = -0.010493 */ |
| 8842 | 0, /* B1 = 0 */ |
| 8843 | 343, /* B0 = 0.010493 */ |
| 8844 | 32619, /* A1 = 1.990906 */ |
| 8845 | -32520, /* A2 = -0.992462 */ |
| 8846 | 19179, /* B2 = 0.585327 */ |
| 8847 | -19178, /* B1 = -1.170593 */ |
| 8848 | 19179, /* B0 = 0.585327 */ |
| 8849 | 32723, /* A1 = 1.997314 */ |
| 8850 | -32686, /* A2 = -0.997528 */ |
| 8851 | 9973, /* B2 = 0.304352 */ |
| 8852 | -9955, /* B1 = -0.607605 */ |
| 8853 | 9973, /* B0 = 0.304352 */ |
| 8854 | 7, /* Internal filter scaling */ |
| 8855 | 159, /* Minimum in-band energy threshold */ |
| 8856 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8857 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8858 | }, |
| 8859 | { /* f133_200[] 12 */ |
| 8860 | 32072, /* A1 = 1.95752 */ |
| 8861 | -31896, /* A2 = -0.973419 */ |
| 8862 | -435, /* B2 = -0.013294 */ |
| 8863 | 0, /* B1 = 0 */ |
| 8864 | 435, /* B0 = 0.013294 */ |
| 8865 | 32188, /* A1 = 1.9646 */ |
| 8866 | -32400, /* A2 = -0.98877 */ |
| 8867 | 15139, /* B2 = 0.462036 */ |
| 8868 | -14882, /* B1 = -0.908356 */ |
| 8869 | 15139, /* B0 = 0.462036 */ |
| 8870 | 32473, /* A1 = 1.981995 */ |
| 8871 | -32524, /* A2 = -0.992584 */ |
| 8872 | 23200, /* B2 = 0.708008 */ |
| 8873 | -23113, /* B1 = -1.410706 */ |
| 8874 | 23200, /* B0 = 0.708008 */ |
| 8875 | 7, /* Internal filter scaling */ |
| 8876 | 159, /* Minimum in-band energy threshold */ |
| 8877 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8878 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8879 | }, |
| 8880 | { /* f300 13 */ |
| 8881 | 31769, /* A1 = -1.939026 */ |
| 8882 | -32584, /* A2 = 0.994385 */ |
| 8883 | -475, /* B2 = -0.014522 */ |
| 8884 | 0, /* B1 = 0.000000 */ |
| 8885 | 475, /* B0 = 0.014522 */ |
| 8886 | 31789, /* A1 = -1.940247 */ |
| 8887 | -32679, /* A2 = 0.997284 */ |
| 8888 | 17280, /* B2 = 0.527344 */ |
| 8889 | -16865, /* B1 = -1.029358 */ |
| 8890 | 17280, /* B0 = 0.527344 */ |
| 8891 | 31841, /* A1 = -1.943481 */ |
| 8892 | -32681, /* A2 = 0.997345 */ |
| 8893 | 543, /* B2 = 0.016579 */ |
| 8894 | -525, /* B1 = -0.032097 */ |
| 8895 | 543, /* B0 = 0.016579 */ |
| 8896 | 5, /* Internal filter scaling */ |
| 8897 | 159, /* Minimum in-band energy threshold */ |
| 8898 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8899 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8900 | }, |
| 8901 | { /* f300_420[] 14 */ |
| 8902 | 30750, /* A1 = 1.876892 */ |
| 8903 | -31212, /* A2 = -0.952515 */ |
| 8904 | -804, /* B2 = -0.024541 */ |
| 8905 | 0, /* B1 = 0 */ |
| 8906 | 804, /* B0 = 0.024541 */ |
| 8907 | 30686, /* A1 = 1.872925 */ |
| 8908 | -32145, /* A2 = -0.980988 */ |
| 8909 | 14747, /* B2 = 0.450043 */ |
| 8910 | -13703, /* B1 = -0.836395 */ |
| 8911 | 14747, /* B0 = 0.450043 */ |
| 8912 | 31651, /* A1 = 1.931824 */ |
| 8913 | -32321, /* A2 = -0.986389 */ |
| 8914 | 24425, /* B2 = 0.745422 */ |
| 8915 | -23914, /* B1 = -1.459595 */ |
| 8916 | 24427, /* B0 = 0.745483 */ |
| 8917 | 7, /* Internal filter scaling */ |
| 8918 | 159, /* Minimum in-band energy threshold */ |
| 8919 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8920 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8921 | }, |
| 8922 | { /* f330 15 */ |
| 8923 | 31613, /* A1 = -1.929565 */ |
| 8924 | -32646, /* A2 = 0.996277 */ |
| 8925 | -185, /* B2 = -0.005657 */ |
| 8926 | 0, /* B1 = 0.000000 */ |
| 8927 | 185, /* B0 = 0.005657 */ |
| 8928 | 31620, /* A1 = -1.929932 */ |
| 8929 | -32713, /* A2 = 0.998352 */ |
| 8930 | 19253, /* B2 = 0.587585 */ |
| 8931 | -18566, /* B1 = -1.133179 */ |
| 8932 | 19253, /* B0 = 0.587585 */ |
| 8933 | 31674, /* A1 = -1.933228 */ |
| 8934 | -32715, /* A2 = 0.998413 */ |
| 8935 | 2575, /* B2 = 0.078590 */ |
| 8936 | -2495, /* B1 = -0.152283 */ |
| 8937 | 2575, /* B0 = 0.078590 */ |
| 8938 | 5, /* Internal filter scaling */ |
| 8939 | 159, /* Minimum in-band energy threshold */ |
| 8940 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8941 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8942 | }, |
| 8943 | { /* f300_425[] 16 */ |
| 8944 | 30741, /* A1 = 1.876282 */ |
| 8945 | -31475, /* A2 = -0.960541 */ |
| 8946 | -703, /* B2 = -0.021484 */ |
| 8947 | 0, /* B1 = 0 */ |
| 8948 | 703, /* B0 = 0.021484 */ |
| 8949 | 30688, /* A1 = 1.873047 */ |
| 8950 | -32248, /* A2 = -0.984161 */ |
| 8951 | 14542, /* B2 = 0.443787 */ |
| 8952 | -13523, /* B1 = -0.825439 */ |
| 8953 | 14542, /* B0 = 0.443817 */ |
| 8954 | 31494, /* A1 = 1.922302 */ |
| 8955 | -32366, /* A2 = -0.987762 */ |
| 8956 | 21577, /* B2 = 0.658508 */ |
| 8957 | -21013, /* B1 = -1.282532 */ |
| 8958 | 21577, /* B0 = 0.658508 */ |
| 8959 | 7, /* Internal filter scaling */ |
| 8960 | 159, /* Minimum in-band energy threshold */ |
| 8961 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8962 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8963 | }, |
| 8964 | { /* f330_440[] 17 */ |
| 8965 | 30627, /* A1 = 1.869324 */ |
| 8966 | -31338, /* A2 = -0.95636 */ |
| 8967 | -843, /* B2 = -0.025749 */ |
| 8968 | 0, /* B1 = 0 */ |
| 8969 | 843, /* B0 = 0.025749 */ |
| 8970 | 30550, /* A1 = 1.864685 */ |
| 8971 | -32221, /* A2 = -0.983337 */ |
| 8972 | 13594, /* B2 = 0.414886 */ |
| 8973 | -12589, /* B1 = -0.768402 */ |
| 8974 | 13594, /* B0 = 0.414886 */ |
| 8975 | 31488, /* A1 = 1.921936 */ |
| 8976 | -32358, /* A2 = -0.987518 */ |
| 8977 | 24684, /* B2 = 0.753296 */ |
| 8978 | -24029, /* B1 = -1.466614 */ |
| 8979 | 24684, /* B0 = 0.753296 */ |
| 8980 | 7, /* Internal filter scaling */ |
| 8981 | 159, /* Minimum in-band energy threshold */ |
| 8982 | 21, /* 21/32 in-band to broad-band ratio */ |
| 8983 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 8984 | }, |
| 8985 | { /* f340 18 */ |
| 8986 | 31546, /* A1 = -1.925476 */ |
| 8987 | -32646, /* A2 = 0.996277 */ |
| 8988 | -445, /* B2 = -0.013588 */ |
| 8989 | 0, /* B1 = 0.000000 */ |
| 8990 | 445, /* B0 = 0.013588 */ |
| 8991 | 31551, /* A1 = -1.925781 */ |
| 8992 | -32713, /* A2 = 0.998352 */ |
| 8993 | 23884, /* B2 = 0.728882 */ |
| 8994 | -22979, /* B1 = -1.402527 */ |
| 8995 | 23884, /* B0 = 0.728882 */ |
| 8996 | 31606, /* A1 = -1.929138 */ |
| 8997 | -32715, /* A2 = 0.998413 */ |
| 8998 | 863, /* B2 = 0.026367 */ |
| 8999 | -835, /* B1 = -0.050985 */ |
| 9000 | 863, /* B0 = 0.026367 */ |
| 9001 | 5, /* Internal filter scaling */ |
| 9002 | 159, /* Minimum in-band energy threshold */ |
| 9003 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9004 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9005 | }, |
| 9006 | { /* f350_400[] 19 */ |
| 9007 | 31006, /* A1 = 1.892517 */ |
| 9008 | -32029, /* A2 = -0.977448 */ |
| 9009 | -461, /* B2 = -0.014096 */ |
| 9010 | 0, /* B1 = 0 */ |
| 9011 | 461, /* B0 = 0.014096 */ |
| 9012 | 30999, /* A1 = 1.892029 */ |
| 9013 | -32487, /* A2 = -0.991455 */ |
| 9014 | 11325, /* B2 = 0.345612 */ |
| 9015 | -10682, /* B1 = -0.651978 */ |
| 9016 | 11325, /* B0 = 0.345612 */ |
| 9017 | 31441, /* A1 = 1.919067 */ |
| 9018 | -32526, /* A2 = -0.992615 */ |
| 9019 | 24324, /* B2 = 0.74231 */ |
| 9020 | -23535, /* B1 = -1.436523 */ |
| 9021 | 24324, /* B0 = 0.74231 */ |
| 9022 | 7, /* Internal filter scaling */ |
| 9023 | 159, /* Minimum in-band energy threshold */ |
| 9024 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9025 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9026 | }, |
| 9027 | { /* f350_440[] */ |
| 9028 | 30634, /* A1 = 1.869751 */ |
| 9029 | -31533, /* A2 = -0.962341 */ |
| 9030 | -680, /* B2 = -0.020782 */ |
| 9031 | 0, /* B1 = 0 */ |
| 9032 | 680, /* B0 = 0.020782 */ |
| 9033 | 30571, /* A1 = 1.865906 */ |
| 9034 | -32277, /* A2 = -0.985016 */ |
| 9035 | 12894, /* B2 = 0.393524 */ |
| 9036 | -11945, /* B1 = -0.729065 */ |
| 9037 | 12894, /* B0 = 0.393524 */ |
| 9038 | 31367, /* A1 = 1.91449 */ |
| 9039 | -32379, /* A2 = -0.988129 */ |
| 9040 | 23820, /* B2 = 0.726929 */ |
| 9041 | -23104, /* B1 = -1.410217 */ |
| 9042 | 23820, /* B0 = 0.726929 */ |
| 9043 | 7, /* Internal filter scaling */ |
| 9044 | 159, /* Minimum in-band energy threshold */ |
| 9045 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9046 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9047 | }, |
| 9048 | { /* f350_450[] */ |
| 9049 | 30552, /* A1 = 1.864807 */ |
| 9050 | -31434, /* A2 = -0.95929 */ |
| 9051 | -690, /* B2 = -0.021066 */ |
| 9052 | 0, /* B1 = 0 */ |
| 9053 | 690, /* B0 = 0.021066 */ |
| 9054 | 30472, /* A1 = 1.859924 */ |
| 9055 | -32248, /* A2 = -0.984161 */ |
| 9056 | 13385, /* B2 = 0.408478 */ |
| 9057 | -12357, /* B1 = -0.754242 */ |
| 9058 | 13385, /* B0 = 0.408478 */ |
| 9059 | 31358, /* A1 = 1.914001 */ |
| 9060 | -32366, /* A2 = -0.987732 */ |
| 9061 | 26488, /* B2 = 0.80835 */ |
| 9062 | -25692, /* B1 = -1.568176 */ |
| 9063 | 26490, /* B0 = 0.808411 */ |
| 9064 | 7, /* Internal filter scaling */ |
| 9065 | 159, /* Minimum in-band energy threshold */ |
| 9066 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9067 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9068 | }, |
| 9069 | { /* f360 */ |
| 9070 | 31397, /* A1 = -1.916321 */ |
| 9071 | -32623, /* A2 = 0.995605 */ |
| 9072 | -117, /* B2 = -0.003598 */ |
| 9073 | 0, /* B1 = 0.000000 */ |
| 9074 | 117, /* B0 = 0.003598 */ |
| 9075 | 31403, /* A1 = -1.916687 */ |
| 9076 | -32700, /* A2 = 0.997925 */ |
| 9077 | 3388, /* B2 = 0.103401 */ |
| 9078 | -3240, /* B1 = -0.197784 */ |
| 9079 | 3388, /* B0 = 0.103401 */ |
| 9080 | 31463, /* A1 = -1.920410 */ |
| 9081 | -32702, /* A2 = 0.997986 */ |
| 9082 | 13346, /* B2 = 0.407288 */ |
| 9083 | -12863, /* B1 = -0.785126 */ |
| 9084 | 13346, /* B0 = 0.407288 */ |
| 9085 | 5, /* Internal filter scaling */ |
| 9086 | 159, /* Minimum in-band energy threshold */ |
| 9087 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9088 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9089 | }, |
| 9090 | { /* f380_420[] */ |
| 9091 | 30831, /* A1 = 1.881775 */ |
| 9092 | -32064, /* A2 = -0.978546 */ |
| 9093 | -367, /* B2 = -0.01122 */ |
| 9094 | 0, /* B1 = 0 */ |
| 9095 | 367, /* B0 = 0.01122 */ |
| 9096 | 30813, /* A1 = 1.880737 */ |
| 9097 | -32456, /* A2 = -0.990509 */ |
| 9098 | 11068, /* B2 = 0.337769 */ |
| 9099 | -10338, /* B1 = -0.631042 */ |
| 9100 | 11068, /* B0 = 0.337769 */ |
| 9101 | 31214, /* A1 = 1.905212 */ |
| 9102 | -32491, /* A2 = -0.991577 */ |
| 9103 | 16374, /* B2 = 0.499695 */ |
| 9104 | -15781, /* B1 = -0.963196 */ |
| 9105 | 16374, /* B0 = 0.499695 */ |
| 9106 | 7, /* Internal filter scaling */ |
| 9107 | 159, /* Minimum in-band energy threshold */ |
| 9108 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9109 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9110 | }, |
| 9111 | { /* f392 */ |
| 9112 | 31152, /* A1 = -1.901428 */ |
| 9113 | -32613, /* A2 = 0.995300 */ |
| 9114 | -314, /* B2 = -0.009605 */ |
| 9115 | 0, /* B1 = 0.000000 */ |
| 9116 | 314, /* B0 = 0.009605 */ |
| 9117 | 31156, /* A1 = -1.901672 */ |
| 9118 | -32694, /* A2 = 0.997742 */ |
| 9119 | 28847, /* B2 = 0.880371 */ |
| 9120 | -2734, /* B1 = -0.166901 */ |
| 9121 | 28847, /* B0 = 0.880371 */ |
| 9122 | 31225, /* A1 = -1.905823 */ |
| 9123 | -32696, /* A2 = 0.997803 */ |
| 9124 | 462, /* B2 = 0.014108 */ |
| 9125 | -442, /* B1 = -0.027019 */ |
| 9126 | 462, /* B0 = 0.014108 */ |
| 9127 | 5, /* Internal filter scaling */ |
| 9128 | 159, /* Minimum in-band energy threshold */ |
| 9129 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9130 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9131 | }, |
| 9132 | { /* f400_425[] */ |
| 9133 | 30836, /* A1 = 1.882141 */ |
| 9134 | -32296, /* A2 = -0.985596 */ |
| 9135 | -324, /* B2 = -0.009903 */ |
| 9136 | 0, /* B1 = 0 */ |
| 9137 | 324, /* B0 = 0.009903 */ |
| 9138 | 30825, /* A1 = 1.881409 */ |
| 9139 | -32570, /* A2 = -0.993958 */ |
| 9140 | 16847, /* B2 = 0.51416 */ |
| 9141 | -15792, /* B1 = -0.963898 */ |
| 9142 | 16847, /* B0 = 0.51416 */ |
| 9143 | 31106, /* A1 = 1.89856 */ |
| 9144 | -32584, /* A2 = -0.994415 */ |
| 9145 | 9579, /* B2 = 0.292328 */ |
| 9146 | -9164, /* B1 = -0.559357 */ |
| 9147 | 9579, /* B0 = 0.292328 */ |
| 9148 | 7, /* Internal filter scaling */ |
| 9149 | 159, /* Minimum in-band energy threshold */ |
| 9150 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9151 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9152 | }, |
| 9153 | { /* f400_440[] */ |
| 9154 | 30702, /* A1 = 1.873962 */ |
| 9155 | -32134, /* A2 = -0.980682 */ |
| 9156 | -517, /* B2 = -0.015793 */ |
| 9157 | 0, /* B1 = 0 */ |
| 9158 | 517, /* B0 = 0.015793 */ |
| 9159 | 30676, /* A1 = 1.872375 */ |
| 9160 | -32520, /* A2 = -0.992462 */ |
| 9161 | 8144, /* B2 = 0.24855 */ |
| 9162 | -7596, /* B1 = -0.463684 */ |
| 9163 | 8144, /* B0 = 0.24855 */ |
| 9164 | 31084, /* A1 = 1.897217 */ |
| 9165 | -32547, /* A2 = -0.993256 */ |
| 9166 | 22713, /* B2 = 0.693176 */ |
| 9167 | -21734, /* B1 = -1.326599 */ |
| 9168 | 22713, /* B0 = 0.693176 */ |
| 9169 | 7, /* Internal filter scaling */ |
| 9170 | 159, /* Minimum in-band energy threshold */ |
| 9171 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9172 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9173 | }, |
| 9174 | { /* f400_450[] */ |
| 9175 | 30613, /* A1 = 1.86853 */ |
| 9176 | -32031, /* A2 = -0.977509 */ |
| 9177 | -618, /* B2 = -0.018866 */ |
| 9178 | 0, /* B1 = 0 */ |
| 9179 | 618, /* B0 = 0.018866 */ |
| 9180 | 30577, /* A1 = 1.866272 */ |
| 9181 | -32491, /* A2 = -0.991577 */ |
| 9182 | 9612, /* B2 = 0.293335 */ |
| 9183 | -8935, /* B1 = -0.54541 */ |
| 9184 | 9612, /* B0 = 0.293335 */ |
| 9185 | 31071, /* A1 = 1.896484 */ |
| 9186 | -32524, /* A2 = -0.992584 */ |
| 9187 | 21596, /* B2 = 0.659058 */ |
| 9188 | -20667, /* B1 = -1.261414 */ |
| 9189 | 21596, /* B0 = 0.659058 */ |
| 9190 | 7, /* Internal filter scaling */ |
| 9191 | 159, /* Minimum in-band energy threshold */ |
| 9192 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9193 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9194 | }, |
| 9195 | { /* f420 */ |
| 9196 | 30914, /* A1 = -1.886841 */ |
| 9197 | -32584, /* A2 = 0.994385 */ |
| 9198 | -426, /* B2 = -0.013020 */ |
| 9199 | 0, /* B1 = 0.000000 */ |
| 9200 | 426, /* B0 = 0.013020 */ |
| 9201 | 30914, /* A1 = -1.886841 */ |
| 9202 | -32679, /* A2 = 0.997314 */ |
| 9203 | 17520, /* B2 = 0.534668 */ |
| 9204 | -16471, /* B1 = -1.005310 */ |
| 9205 | 17520, /* B0 = 0.534668 */ |
| 9206 | 31004, /* A1 = -1.892334 */ |
| 9207 | -32683, /* A2 = 0.997406 */ |
| 9208 | 819, /* B2 = 0.025023 */ |
| 9209 | -780, /* B1 = -0.047619 */ |
| 9210 | 819, /* B0 = 0.025023 */ |
| 9211 | 5, /* Internal filter scaling */ |
| 9212 | 159, /* Minimum in-band energy threshold */ |
| 9213 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9214 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9215 | }, |
| 9216 | #if 0 |
| 9217 | { /* f425 */ |
| 9218 | 30881, /* A1 = -1.884827 */ |
| 9219 | -32603, /* A2 = 0.994965 */ |
| 9220 | -496, /* B2 = -0.015144 */ |
| 9221 | 0, /* B1 = 0.000000 */ |
| 9222 | 496, /* B0 = 0.015144 */ |
| 9223 | 30880, /* A1 = -1.884766 */ |
| 9224 | -32692, /* A2 = 0.997711 */ |
| 9225 | 24767, /* B2 = 0.755859 */ |
| 9226 | -23290, /* B1 = -1.421509 */ |
| 9227 | 24767, /* B0 = 0.755859 */ |
| 9228 | 30967, /* A1 = -1.890076 */ |
| 9229 | -32694, /* A2 = 0.997772 */ |
| 9230 | 728, /* B2 = 0.022232 */ |
| 9231 | -691, /* B1 = -0.042194 */ |
| 9232 | 728, /* B0 = 0.022232 */ |
| 9233 | 5, /* Internal filter scaling */ |
| 9234 | 159, /* Minimum in-band energy threshold */ |
| 9235 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9236 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9237 | }, |
| 9238 | #else |
| 9239 | { |
| 9240 | 30850, |
| 9241 | -32534, |
| 9242 | -504, |
| 9243 | 0, |
| 9244 | 504, |
| 9245 | 30831, |
| 9246 | -32669, |
| 9247 | 24303, |
| 9248 | -22080, |
| 9249 | 24303, |
| 9250 | 30994, |
| 9251 | -32673, |
| 9252 | 1905, |
| 9253 | -1811, |
| 9254 | 1905, |
| 9255 | 5, |
| 9256 | 129, |
| 9257 | 17, |
| 9258 | 0xff5 |
| 9259 | }, |
| 9260 | #endif |
| 9261 | { /* f425_450[] */ |
| 9262 | 30646, /* A1 = 1.870544 */ |
| 9263 | -32327, /* A2 = -0.986572 */ |
| 9264 | -287, /* B2 = -0.008769 */ |
| 9265 | 0, /* B1 = 0 */ |
| 9266 | 287, /* B0 = 0.008769 */ |
| 9267 | 30627, /* A1 = 1.869324 */ |
| 9268 | -32607, /* A2 = -0.995087 */ |
| 9269 | 13269, /* B2 = 0.404968 */ |
| 9270 | -12376, /* B1 = -0.755432 */ |
| 9271 | 13269, /* B0 = 0.404968 */ |
| 9272 | 30924, /* A1 = 1.887512 */ |
| 9273 | -32619, /* A2 = -0.995453 */ |
| 9274 | 19950, /* B2 = 0.608826 */ |
| 9275 | -18940, /* B1 = -1.156006 */ |
| 9276 | 19950, /* B0 = 0.608826 */ |
| 9277 | 7, /* Internal filter scaling */ |
| 9278 | 159, /* Minimum in-band energy threshold */ |
| 9279 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9280 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9281 | }, |
| 9282 | { /* f425_475[] */ |
| 9283 | 30396, /* A1 = 1.855225 */ |
| 9284 | -32014, /* A2 = -0.97699 */ |
| 9285 | -395, /* B2 = -0.012055 */ |
| 9286 | 0, /* B1 = 0 */ |
| 9287 | 395, /* B0 = 0.012055 */ |
| 9288 | 30343, /* A1 = 1.85199 */ |
| 9289 | -32482, /* A2 = -0.991302 */ |
| 9290 | 17823, /* B2 = 0.543945 */ |
| 9291 | -16431, /* B1 = -1.002869 */ |
| 9292 | 17823, /* B0 = 0.543945 */ |
| 9293 | 30872, /* A1 = 1.884338 */ |
| 9294 | -32516, /* A2 = -0.99231 */ |
| 9295 | 18124, /* B2 = 0.553101 */ |
| 9296 | -17246, /* B1 = -1.052673 */ |
| 9297 | 18124, /* B0 = 0.553101 */ |
| 9298 | 7, /* Internal filter scaling */ |
| 9299 | 159, /* Minimum in-band energy threshold */ |
| 9300 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9301 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9302 | }, |
| 9303 | { /* f435 */ |
| 9304 | 30796, /* A1 = -1.879639 */ |
| 9305 | -32603, /* A2 = 0.994965 */ |
| 9306 | -254, /* B2 = -0.007762 */ |
| 9307 | 0, /* B1 = 0.000000 */ |
| 9308 | 254, /* B0 = 0.007762 */ |
| 9309 | 30793, /* A1 = -1.879456 */ |
| 9310 | -32692, /* A2 = 0.997711 */ |
| 9311 | 18934, /* B2 = 0.577820 */ |
| 9312 | -17751, /* B1 = -1.083496 */ |
| 9313 | 18934, /* B0 = 0.577820 */ |
| 9314 | 30882, /* A1 = -1.884888 */ |
| 9315 | -32694, /* A2 = 0.997772 */ |
| 9316 | 1858, /* B2 = 0.056713 */ |
| 9317 | -1758, /* B1 = -0.107357 */ |
| 9318 | 1858, /* B0 = 0.056713 */ |
| 9319 | 5, /* Internal filter scaling */ |
| 9320 | 159, /* Minimum in-band energy threshold */ |
| 9321 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9322 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9323 | }, |
| 9324 | { /* f440_450[] */ |
| 9325 | 30641, /* A1 = 1.870239 */ |
| 9326 | -32458, /* A2 = -0.99057 */ |
| 9327 | -155, /* B2 = -0.004735 */ |
| 9328 | 0, /* B1 = 0 */ |
| 9329 | 155, /* B0 = 0.004735 */ |
| 9330 | 30631, /* A1 = 1.869568 */ |
| 9331 | -32630, /* A2 = -0.995789 */ |
| 9332 | 11453, /* B2 = 0.349548 */ |
| 9333 | -10666, /* B1 = -0.651001 */ |
| 9334 | 11453, /* B0 = 0.349548 */ |
| 9335 | 30810, /* A1 = 1.880554 */ |
| 9336 | -32634, /* A2 = -0.995941 */ |
| 9337 | 12237, /* B2 = 0.373474 */ |
| 9338 | -11588, /* B1 = -0.707336 */ |
| 9339 | 12237, /* B0 = 0.373474 */ |
| 9340 | 7, /* Internal filter scaling */ |
| 9341 | 159, /* Minimum in-band energy threshold */ |
| 9342 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9343 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9344 | }, |
| 9345 | { /* f440_480[] */ |
| 9346 | 30367, /* A1 = 1.853455 */ |
| 9347 | -32147, /* A2 = -0.981079 */ |
| 9348 | -495, /* B2 = -0.015113 */ |
| 9349 | 0, /* B1 = 0 */ |
| 9350 | 495, /* B0 = 0.015113 */ |
| 9351 | 30322, /* A1 = 1.850769 */ |
| 9352 | -32543, /* A2 = -0.993134 */ |
| 9353 | 10031, /* B2 = 0.306152 */ |
| 9354 | -9252, /* B1 = -0.564728 */ |
| 9355 | 10031, /* B0 = 0.306152 */ |
| 9356 | 30770, /* A1 = 1.878052 */ |
| 9357 | -32563, /* A2 = -0.993774 */ |
| 9358 | 22674, /* B2 = 0.691956 */ |
| 9359 | -21465, /* B1 = -1.31012 */ |
| 9360 | 22674, /* B0 = 0.691956 */ |
| 9361 | 7, /* Internal filter scaling */ |
| 9362 | 159, /* Minimum in-band energy threshold */ |
| 9363 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9364 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9365 | }, |
| 9366 | { /* f445 */ |
| 9367 | 30709, /* A1 = -1.874329 */ |
| 9368 | -32603, /* A2 = 0.994965 */ |
| 9369 | -83, /* B2 = -0.002545 */ |
| 9370 | 0, /* B1 = 0.000000 */ |
| 9371 | 83, /* B0 = 0.002545 */ |
| 9372 | 30704, /* A1 = -1.874084 */ |
| 9373 | -32692, /* A2 = 0.997711 */ |
| 9374 | 10641, /* B2 = 0.324738 */ |
| 9375 | -9947, /* B1 = -0.607147 */ |
| 9376 | 10641, /* B0 = 0.324738 */ |
| 9377 | 30796, /* A1 = -1.879639 */ |
| 9378 | -32694, /* A2 = 0.997772 */ |
| 9379 | 10079, /* B2 = 0.307587 */ |
| 9380 | 9513, /* B1 = 0.580688 */ |
| 9381 | 10079, /* B0 = 0.307587 */ |
| 9382 | 5, /* Internal filter scaling */ |
| 9383 | 159, /* Minimum in-band energy threshold */ |
| 9384 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9385 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9386 | }, |
| 9387 | { /* f450 */ |
| 9388 | 30664, /* A1 = -1.871643 */ |
| 9389 | -32603, /* A2 = 0.994965 */ |
| 9390 | -164, /* B2 = -0.005029 */ |
| 9391 | 0, /* B1 = 0.000000 */ |
| 9392 | 164, /* B0 = 0.005029 */ |
| 9393 | 30661, /* A1 = -1.871399 */ |
| 9394 | -32692, /* A2 = 0.997711 */ |
| 9395 | 15294, /* B2 = 0.466736 */ |
| 9396 | -14275, /* B1 = -0.871307 */ |
| 9397 | 15294, /* B0 = 0.466736 */ |
| 9398 | 30751, /* A1 = -1.876953 */ |
| 9399 | -32694, /* A2 = 0.997772 */ |
| 9400 | 3548, /* B2 = 0.108284 */ |
| 9401 | -3344, /* B1 = -0.204155 */ |
| 9402 | 3548, /* B0 = 0.108284 */ |
| 9403 | 5, /* Internal filter scaling */ |
| 9404 | 159, /* Minimum in-band energy threshold */ |
| 9405 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9406 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9407 | }, |
| 9408 | { /* f452 */ |
| 9409 | 30653, /* A1 = -1.870911 */ |
| 9410 | -32615, /* A2 = 0.995361 */ |
| 9411 | -209, /* B2 = -0.006382 */ |
| 9412 | 0, /* B1 = 0.000000 */ |
| 9413 | 209, /* B0 = 0.006382 */ |
| 9414 | 30647, /* A1 = -1.870605 */ |
| 9415 | -32702, /* A2 = 0.997986 */ |
| 9416 | 18971, /* B2 = 0.578979 */ |
| 9417 | -17716, /* B1 = -1.081299 */ |
| 9418 | 18971, /* B0 = 0.578979 */ |
| 9419 | 30738, /* A1 = -1.876099 */ |
| 9420 | -32702, /* A2 = 0.998016 */ |
| 9421 | 2967, /* B2 = 0.090561 */ |
| 9422 | -2793, /* B1 = -0.170502 */ |
| 9423 | 2967, /* B0 = 0.090561 */ |
| 9424 | 5, /* Internal filter scaling */ |
| 9425 | 159, /* Minimum in-band energy threshold */ |
| 9426 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9427 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9428 | }, |
| 9429 | { /* f475 */ |
| 9430 | 30437, /* A1 = -1.857727 */ |
| 9431 | -32603, /* A2 = 0.994965 */ |
| 9432 | -264, /* B2 = -0.008062 */ |
| 9433 | 0, /* B1 = 0.000000 */ |
| 9434 | 264, /* B0 = 0.008062 */ |
| 9435 | 30430, /* A1 = -1.857300 */ |
| 9436 | -32692, /* A2 = 0.997711 */ |
| 9437 | 21681, /* B2 = 0.661682 */ |
| 9438 | -20082, /* B1 = -1.225708 */ |
| 9439 | 21681, /* B0 = 0.661682 */ |
| 9440 | 30526, /* A1 = -1.863220 */ |
| 9441 | -32694, /* A2 = 0.997742 */ |
| 9442 | 1559, /* B2 = 0.047600 */ |
| 9443 | -1459, /* B1 = -0.089096 */ |
| 9444 | 1559, /* B0 = 0.047600 */ |
| 9445 | 5, /* Internal filter scaling */ |
| 9446 | 159, /* Minimum in-band energy threshold */ |
| 9447 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9448 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9449 | }, |
| 9450 | { /* f480_620[] */ |
| 9451 | 28975, /* A1 = 1.768494 */ |
| 9452 | -30955, /* A2 = -0.944672 */ |
| 9453 | -1026, /* B2 = -0.03133 */ |
| 9454 | 0, /* B1 = 0 */ |
| 9455 | 1026, /* B0 = 0.03133 */ |
| 9456 | 28613, /* A1 = 1.746399 */ |
| 9457 | -32089, /* A2 = -0.979309 */ |
| 9458 | 14214, /* B2 = 0.433807 */ |
| 9459 | -12202, /* B1 = -0.744812 */ |
| 9460 | 14214, /* B0 = 0.433807 */ |
| 9461 | 30243, /* A1 = 1.845947 */ |
| 9462 | -32238, /* A2 = -0.983856 */ |
| 9463 | 24825, /* B2 = 0.757629 */ |
| 9464 | -23402, /* B1 = -1.428345 */ |
| 9465 | 24825, /* B0 = 0.757629 */ |
| 9466 | 7, /* Internal filter scaling */ |
| 9467 | 159, /* Minimum in-band energy threshold */ |
| 9468 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9469 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9470 | }, |
| 9471 | { /* f494 */ |
| 9472 | 30257, /* A1 = -1.846741 */ |
| 9473 | -32605, /* A2 = 0.995056 */ |
| 9474 | -249, /* B2 = -0.007625 */ |
| 9475 | 0, /* B1 = 0.000000 */ |
| 9476 | 249, /* B0 = 0.007625 */ |
| 9477 | 30247, /* A1 = -1.846191 */ |
| 9478 | -32694, /* A2 = 0.997772 */ |
| 9479 | 18088, /* B2 = 0.552002 */ |
| 9480 | -16652, /* B1 = -1.016418 */ |
| 9481 | 18088, /* B0 = 0.552002 */ |
| 9482 | 30348, /* A1 = -1.852295 */ |
| 9483 | -32696, /* A2 = 0.997803 */ |
| 9484 | 2099, /* B2 = 0.064064 */ |
| 9485 | -1953, /* B1 = -0.119202 */ |
| 9486 | 2099, /* B0 = 0.064064 */ |
| 9487 | 5, /* Internal filter scaling */ |
| 9488 | 159, /* Minimum in-band energy threshold */ |
| 9489 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9490 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9491 | }, |
| 9492 | { /* f500 */ |
| 9493 | 30202, /* A1 = -1.843431 */ |
| 9494 | -32624, /* A2 = 0.995622 */ |
| 9495 | -413, /* B2 = -0.012622 */ |
| 9496 | 0, /* B1 = 0.000000 */ |
| 9497 | 413, /* B0 = 0.012622 */ |
| 9498 | 30191, /* A1 = -1.842721 */ |
| 9499 | -32714, /* A2 = 0.998364 */ |
| 9500 | 25954, /* B2 = 0.792057 */ |
| 9501 | -23890, /* B1 = -1.458131 */ |
| 9502 | 25954, /* B0 = 0.792057 */ |
| 9503 | 30296, /* A1 = -1.849172 */ |
| 9504 | -32715, /* A2 = 0.998397 */ |
| 9505 | 2007, /* B2 = 0.061264 */ |
| 9506 | -1860, /* B1 = -0.113568 */ |
| 9507 | 2007, /* B0 = 0.061264 */ |
| 9508 | 5, /* Internal filter scaling */ |
| 9509 | 159, /* Minimum in-band energy threshold */ |
| 9510 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9511 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9512 | }, |
| 9513 | { /* f520 */ |
| 9514 | 30001, /* A1 = -1.831116 */ |
| 9515 | -32613, /* A2 = 0.995270 */ |
| 9516 | -155, /* B2 = -0.004750 */ |
| 9517 | 0, /* B1 = 0.000000 */ |
| 9518 | 155, /* B0 = 0.004750 */ |
| 9519 | 29985, /* A1 = -1.830200 */ |
| 9520 | -32710, /* A2 = 0.998260 */ |
| 9521 | 6584, /* B2 = 0.200928 */ |
| 9522 | -6018, /* B1 = -0.367355 */ |
| 9523 | 6584, /* B0 = 0.200928 */ |
| 9524 | 30105, /* A1 = -1.837524 */ |
| 9525 | -32712, /* A2 = 0.998291 */ |
| 9526 | 23812, /* B2 = 0.726685 */ |
| 9527 | -21936, /* B1 = -1.338928 */ |
| 9528 | 23812, /* B0 = 0.726685 */ |
| 9529 | 5, /* Internal filter scaling */ |
| 9530 | 159, /* Minimum in-band energy threshold */ |
| 9531 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9532 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9533 | }, |
| 9534 | { /* f523 */ |
| 9535 | 29964, /* A1 = -1.828918 */ |
| 9536 | -32601, /* A2 = 0.994904 */ |
| 9537 | -101, /* B2 = -0.003110 */ |
| 9538 | 0, /* B1 = 0.000000 */ |
| 9539 | 101, /* B0 = 0.003110 */ |
| 9540 | 29949, /* A1 = -1.827942 */ |
| 9541 | -32700, /* A2 = 0.997925 */ |
| 9542 | 11041, /* B2 = 0.336975 */ |
| 9543 | -10075, /* B1 = -0.614960 */ |
| 9544 | 11041, /* B0 = 0.336975 */ |
| 9545 | 30070, /* A1 = -1.835388 */ |
| 9546 | -32702, /* A2 = 0.997986 */ |
| 9547 | 16762, /* B2 = 0.511536 */ |
| 9548 | -15437, /* B1 = -0.942230 */ |
| 9549 | 16762, /* B0 = 0.511536 */ |
| 9550 | 5, /* Internal filter scaling */ |
| 9551 | 159, /* Minimum in-band energy threshold */ |
| 9552 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9553 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9554 | }, |
| 9555 | { /* f525 */ |
| 9556 | 29936, /* A1 = -1.827209 */ |
| 9557 | -32584, /* A2 = 0.994415 */ |
| 9558 | -91, /* B2 = -0.002806 */ |
| 9559 | 0, /* B1 = 0.000000 */ |
| 9560 | 91, /* B0 = 0.002806 */ |
| 9561 | 29921, /* A1 = -1.826233 */ |
| 9562 | -32688, /* A2 = 0.997559 */ |
| 9563 | 11449, /* B2 = 0.349396 */ |
| 9564 | -10426, /* B1 = -0.636383 */ |
| 9565 | 11449, /* B0 = 0.349396 */ |
| 9566 | 30045, /* A1 = -1.833862 */ |
| 9567 | -32688, /* A2 = 0.997589 */ |
| 9568 | 13055, /* B2 = 0.398407 */ |
| 9569 | -12028, /* B1 = -0.734161 */ |
| 9570 | 13055, /* B0 = 0.398407 */ |
| 9571 | 5, /* Internal filter scaling */ |
| 9572 | 159, /* Minimum in-band energy threshold */ |
| 9573 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9574 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9575 | }, |
| 9576 | { /* f540_660[] */ |
| 9577 | 28499, /* A1 = 1.739441 */ |
| 9578 | -31129, /* A2 = -0.949982 */ |
| 9579 | -849, /* B2 = -0.025922 */ |
| 9580 | 0, /* B1 = 0 */ |
| 9581 | 849, /* B0 = 0.025922 */ |
| 9582 | 28128, /* A1 = 1.716797 */ |
| 9583 | -32130, /* A2 = -0.98056 */ |
| 9584 | 14556, /* B2 = 0.444214 */ |
| 9585 | -12251, /* B1 = -0.747772 */ |
| 9586 | 14556, /* B0 = 0.444244 */ |
| 9587 | 29667, /* A1 = 1.81073 */ |
| 9588 | -32244, /* A2 = -0.984039 */ |
| 9589 | 23038, /* B2 = 0.703064 */ |
| 9590 | -21358, /* B1 = -1.303589 */ |
| 9591 | 23040, /* B0 = 0.703125 */ |
| 9592 | 7, /* Internal filter scaling */ |
| 9593 | 159, /* Minimum in-band energy threshold */ |
| 9594 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9595 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9596 | }, |
| 9597 | { /* f587 */ |
| 9598 | 29271, /* A1 = -1.786560 */ |
| 9599 | -32599, /* A2 = 0.994873 */ |
| 9600 | -490, /* B2 = -0.014957 */ |
| 9601 | 0, /* B1 = 0.000000 */ |
| 9602 | 490, /* B0 = 0.014957 */ |
| 9603 | 29246, /* A1 = -1.785095 */ |
| 9604 | -32700, /* A2 = 0.997925 */ |
| 9605 | 28961, /* B2 = 0.883850 */ |
| 9606 | -25796, /* B1 = -1.574463 */ |
| 9607 | 28961, /* B0 = 0.883850 */ |
| 9608 | 29383, /* A1 = -1.793396 */ |
| 9609 | -32700, /* A2 = 0.997955 */ |
| 9610 | 1299, /* B2 = 0.039650 */ |
| 9611 | -1169, /* B1 = -0.071396 */ |
| 9612 | 1299, /* B0 = 0.039650 */ |
| 9613 | 5, /* Internal filter scaling */ |
| 9614 | 159, /* Minimum in-band energy threshold */ |
| 9615 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9616 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9617 | }, |
| 9618 | { /* f590 */ |
| 9619 | 29230, /* A1 = -1.784058 */ |
| 9620 | -32584, /* A2 = 0.994415 */ |
| 9621 | -418, /* B2 = -0.012757 */ |
| 9622 | 0, /* B1 = 0.000000 */ |
| 9623 | 418, /* B0 = 0.012757 */ |
| 9624 | 29206, /* A1 = -1.782593 */ |
| 9625 | -32688, /* A2 = 0.997559 */ |
| 9626 | 36556, /* B2 = 1.115601 */ |
| 9627 | -32478, /* B1 = -1.982300 */ |
| 9628 | 36556, /* B0 = 1.115601 */ |
| 9629 | 29345, /* A1 = -1.791077 */ |
| 9630 | -32688, /* A2 = 0.997589 */ |
| 9631 | 897, /* B2 = 0.027397 */ |
| 9632 | -808, /* B1 = -0.049334 */ |
| 9633 | 897, /* B0 = 0.027397 */ |
| 9634 | 5, /* Internal filter scaling */ |
| 9635 | 159, /* Minimum in-band energy threshold */ |
| 9636 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9637 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9638 | }, |
| 9639 | { /* f600 */ |
| 9640 | 29116, /* A1 = -1.777100 */ |
| 9641 | -32603, /* A2 = 0.994965 */ |
| 9642 | -165, /* B2 = -0.005039 */ |
| 9643 | 0, /* B1 = 0.000000 */ |
| 9644 | 165, /* B0 = 0.005039 */ |
| 9645 | 29089, /* A1 = -1.775452 */ |
| 9646 | -32708, /* A2 = 0.998199 */ |
| 9647 | 6963, /* B2 = 0.212494 */ |
| 9648 | -6172, /* B1 = -0.376770 */ |
| 9649 | 6963, /* B0 = 0.212494 */ |
| 9650 | 29237, /* A1 = -1.784485 */ |
| 9651 | -32710, /* A2 = 0.998230 */ |
| 9652 | 24197, /* B2 = 0.738464 */ |
| 9653 | -21657, /* B1 = -1.321899 */ |
| 9654 | 24197, /* B0 = 0.738464 */ |
| 9655 | 5, /* Internal filter scaling */ |
| 9656 | 159, /* Minimum in-band energy threshold */ |
| 9657 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9658 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9659 | }, |
| 9660 | { /* f660 */ |
| 9661 | 28376, /* A1 = -1.731934 */ |
| 9662 | -32567, /* A2 = 0.993896 */ |
| 9663 | -363, /* B2 = -0.011102 */ |
| 9664 | 0, /* B1 = 0.000000 */ |
| 9665 | 363, /* B0 = 0.011102 */ |
| 9666 | 28337, /* A1 = -1.729614 */ |
| 9667 | -32683, /* A2 = 0.997434 */ |
| 9668 | 21766, /* B2 = 0.664246 */ |
| 9669 | -18761, /* B1 = -1.145081 */ |
| 9670 | 21766, /* B0 = 0.664246 */ |
| 9671 | 28513, /* A1 = -1.740356 */ |
| 9672 | -32686, /* A2 = 0.997498 */ |
| 9673 | 2509, /* B2 = 0.076584 */ |
| 9674 | -2196, /* B1 = -0.134041 */ |
| 9675 | 2509, /* B0 = 0.076584 */ |
| 9676 | 5, /* Internal filter scaling */ |
| 9677 | 159, /* Minimum in-band energy threshold */ |
| 9678 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9679 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9680 | }, |
| 9681 | { /* f700 */ |
| 9682 | 27844, /* A1 = -1.699463 */ |
| 9683 | -32563, /* A2 = 0.993744 */ |
| 9684 | -366, /* B2 = -0.011187 */ |
| 9685 | 0, /* B1 = 0.000000 */ |
| 9686 | 366, /* B0 = 0.011187 */ |
| 9687 | 27797, /* A1 = -1.696655 */ |
| 9688 | -32686, /* A2 = 0.997498 */ |
| 9689 | 22748, /* B2 = 0.694214 */ |
| 9690 | -19235, /* B1 = -1.174072 */ |
| 9691 | 22748, /* B0 = 0.694214 */ |
| 9692 | 27995, /* A1 = -1.708740 */ |
| 9693 | -32688, /* A2 = 0.997559 */ |
| 9694 | 2964, /* B2 = 0.090477 */ |
| 9695 | -2546, /* B1 = -0.155449 */ |
| 9696 | 2964, /* B0 = 0.090477 */ |
| 9697 | 5, /* Internal filter scaling */ |
| 9698 | 159, /* Minimum in-band energy threshold */ |
| 9699 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9700 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9701 | }, |
| 9702 | { /* f740 */ |
| 9703 | 27297, /* A1 = -1.666077 */ |
| 9704 | -32551, /* A2 = 0.993408 */ |
| 9705 | -345, /* B2 = -0.010540 */ |
| 9706 | 0, /* B1 = 0.000000 */ |
| 9707 | 345, /* B0 = 0.010540 */ |
| 9708 | 27240, /* A1 = -1.662598 */ |
| 9709 | -32683, /* A2 = 0.997406 */ |
| 9710 | 22560, /* B2 = 0.688477 */ |
| 9711 | -18688, /* B1 = -1.140625 */ |
| 9712 | 22560, /* B0 = 0.688477 */ |
| 9713 | 27461, /* A1 = -1.676147 */ |
| 9714 | -32684, /* A2 = 0.997467 */ |
| 9715 | 3541, /* B2 = 0.108086 */ |
| 9716 | -2985, /* B1 = -0.182220 */ |
| 9717 | 3541, /* B0 = 0.108086 */ |
| 9718 | 5, /* Internal filter scaling */ |
| 9719 | 159, /* Minimum in-band energy threshold */ |
| 9720 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9721 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9722 | }, |
| 9723 | { /* f750 */ |
| 9724 | 27155, /* A1 = -1.657410 */ |
| 9725 | -32551, /* A2 = 0.993408 */ |
| 9726 | -462, /* B2 = -0.014117 */ |
| 9727 | 0, /* B1 = 0.000000 */ |
| 9728 | 462, /* B0 = 0.014117 */ |
| 9729 | 27097, /* A1 = -1.653870 */ |
| 9730 | -32683, /* A2 = 0.997406 */ |
| 9731 | 32495, /* B2 = 0.991699 */ |
| 9732 | -26776, /* B1 = -1.634338 */ |
| 9733 | 32495, /* B0 = 0.991699 */ |
| 9734 | 27321, /* A1 = -1.667542 */ |
| 9735 | -32684, /* A2 = 0.997467 */ |
| 9736 | 1835, /* B2 = 0.056007 */ |
| 9737 | -1539, /* B1 = -0.093948 */ |
| 9738 | 1835, /* B0 = 0.056007 */ |
| 9739 | 5, /* Internal filter scaling */ |
| 9740 | 159, /* Minimum in-band energy threshold */ |
| 9741 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9742 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9743 | }, |
| 9744 | { /* f750_1450[] */ |
| 9745 | 19298, /* A1 = 1.177917 */ |
| 9746 | -24471, /* A2 = -0.746796 */ |
| 9747 | -4152, /* B2 = -0.126709 */ |
| 9748 | 0, /* B1 = 0 */ |
| 9749 | 4152, /* B0 = 0.126709 */ |
| 9750 | 12902, /* A1 = 0.787476 */ |
| 9751 | -29091, /* A2 = -0.887817 */ |
| 9752 | 12491, /* B2 = 0.38121 */ |
| 9753 | -1794, /* B1 = -0.109528 */ |
| 9754 | 12494, /* B0 = 0.381317 */ |
| 9755 | 26291, /* A1 = 1.604736 */ |
| 9756 | -30470, /* A2 = -0.929901 */ |
| 9757 | 28859, /* B2 = 0.880737 */ |
| 9758 | -26084, /* B1 = -1.592102 */ |
| 9759 | 28861, /* B0 = 0.880798 */ |
| 9760 | 7, /* Internal filter scaling */ |
| 9761 | 159, /* Minimum in-band energy threshold */ |
| 9762 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9763 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9764 | }, |
| 9765 | { /* f770 */ |
| 9766 | 26867, /* A1 = -1.639832 */ |
| 9767 | -32551, /* A2 = 0.993408 */ |
| 9768 | -123, /* B2 = -0.003755 */ |
| 9769 | 0, /* B1 = 0.000000 */ |
| 9770 | 123, /* B0 = 0.003755 */ |
| 9771 | 26805, /* A1 = -1.636108 */ |
| 9772 | -32683, /* A2 = 0.997406 */ |
| 9773 | 17297, /* B2 = 0.527863 */ |
| 9774 | -14096, /* B1 = -0.860382 */ |
| 9775 | 17297, /* B0 = 0.527863 */ |
| 9776 | 27034, /* A1 = -1.650085 */ |
| 9777 | -32684, /* A2 = 0.997467 */ |
| 9778 | 12958, /* B2 = 0.395477 */ |
| 9779 | -10756, /* B1 = -0.656525 */ |
| 9780 | 12958, /* B0 = 0.395477 */ |
| 9781 | 5, /* Internal filter scaling */ |
| 9782 | 159, /* Minimum in-band energy threshold */ |
| 9783 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9784 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9785 | }, |
| 9786 | { /* f800 */ |
| 9787 | 26413, /* A1 = -1.612122 */ |
| 9788 | -32547, /* A2 = 0.993286 */ |
| 9789 | -223, /* B2 = -0.006825 */ |
| 9790 | 0, /* B1 = 0.000000 */ |
| 9791 | 223, /* B0 = 0.006825 */ |
| 9792 | 26342, /* A1 = -1.607849 */ |
| 9793 | -32686, /* A2 = 0.997498 */ |
| 9794 | 6391, /* B2 = 0.195053 */ |
| 9795 | -5120, /* B1 = -0.312531 */ |
| 9796 | 6391, /* B0 = 0.195053 */ |
| 9797 | 26593, /* A1 = -1.623108 */ |
| 9798 | -32688, /* A2 = 0.997559 */ |
| 9799 | 23681, /* B2 = 0.722717 */ |
| 9800 | -19328, /* B1 = -1.179688 */ |
| 9801 | 23681, /* B0 = 0.722717 */ |
| 9802 | 5, /* Internal filter scaling */ |
| 9803 | 159, /* Minimum in-band energy threshold */ |
| 9804 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9805 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9806 | }, |
| 9807 | { /* f816 */ |
| 9808 | 26168, /* A1 = -1.597209 */ |
| 9809 | -32528, /* A2 = 0.992706 */ |
| 9810 | -235, /* B2 = -0.007182 */ |
| 9811 | 0, /* B1 = 0.000000 */ |
| 9812 | 235, /* B0 = 0.007182 */ |
| 9813 | 26092, /* A1 = -1.592590 */ |
| 9814 | -32675, /* A2 = 0.997192 */ |
| 9815 | 20823, /* B2 = 0.635498 */ |
| 9816 | -16510, /* B1 = -1.007751 */ |
| 9817 | 20823, /* B0 = 0.635498 */ |
| 9818 | 26363, /* A1 = -1.609070 */ |
| 9819 | -32677, /* A2 = 0.997253 */ |
| 9820 | 6739, /* B2 = 0.205688 */ |
| 9821 | -5459, /* B1 = -0.333206 */ |
| 9822 | 6739, /* B0 = 0.205688 */ |
| 9823 | 5, /* Internal filter scaling */ |
| 9824 | 159, /* Minimum in-band energy threshold */ |
| 9825 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9826 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9827 | }, |
| 9828 | { /* f850 */ |
| 9829 | 25641, /* A1 = -1.565063 */ |
| 9830 | -32536, /* A2 = 0.992950 */ |
| 9831 | -121, /* B2 = -0.003707 */ |
| 9832 | 0, /* B1 = 0.000000 */ |
| 9833 | 121, /* B0 = 0.003707 */ |
| 9834 | 25560, /* A1 = -1.560059 */ |
| 9835 | -32684, /* A2 = 0.997437 */ |
| 9836 | 18341, /* B2 = 0.559753 */ |
| 9837 | -14252, /* B1 = -0.869904 */ |
| 9838 | 18341, /* B0 = 0.559753 */ |
| 9839 | 25837, /* A1 = -1.577026 */ |
| 9840 | -32684, /* A2 = 0.997467 */ |
| 9841 | 16679, /* B2 = 0.509003 */ |
| 9842 | -13232, /* B1 = -0.807648 */ |
| 9843 | 16679, /* B0 = 0.509003 */ |
| 9844 | 5, /* Internal filter scaling */ |
| 9845 | 159, /* Minimum in-band energy threshold */ |
| 9846 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9847 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9848 | }, |
| 9849 | { /* f857_1645[] */ |
| 9850 | 16415, /* A1 = 1.001953 */ |
| 9851 | -23669, /* A2 = -0.722321 */ |
| 9852 | -4549, /* B2 = -0.138847 */ |
| 9853 | 0, /* B1 = 0 */ |
| 9854 | 4549, /* B0 = 0.138847 */ |
| 9855 | 8456, /* A1 = 0.516174 */ |
| 9856 | -28996, /* A2 = -0.884918 */ |
| 9857 | 13753, /* B2 = 0.419724 */ |
| 9858 | -12, /* B1 = -0.000763 */ |
| 9859 | 13757, /* B0 = 0.419846 */ |
| 9860 | 24632, /* A1 = 1.503418 */ |
| 9861 | -30271, /* A2 = -0.923828 */ |
| 9862 | 29070, /* B2 = 0.887146 */ |
| 9863 | -25265, /* B1 = -1.542114 */ |
| 9864 | 29073, /* B0 = 0.887268 */ |
| 9865 | 7, /* Internal filter scaling */ |
| 9866 | 159, /* Minimum in-band energy threshold */ |
| 9867 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9868 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9869 | }, |
| 9870 | { /* f900 */ |
| 9871 | 24806, /* A1 = -1.514099 */ |
| 9872 | -32501, /* A2 = 0.991852 */ |
| 9873 | -326, /* B2 = -0.009969 */ |
| 9874 | 0, /* B1 = 0.000000 */ |
| 9875 | 326, /* B0 = 0.009969 */ |
| 9876 | 24709, /* A1 = -1.508118 */ |
| 9877 | -32659, /* A2 = 0.996674 */ |
| 9878 | 20277, /* B2 = 0.618835 */ |
| 9879 | -15182, /* B1 = -0.926636 */ |
| 9880 | 20277, /* B0 = 0.618835 */ |
| 9881 | 25022, /* A1 = -1.527222 */ |
| 9882 | -32661, /* A2 = 0.996735 */ |
| 9883 | 4320, /* B2 = 0.131836 */ |
| 9884 | -3331, /* B1 = -0.203339 */ |
| 9885 | 4320, /* B0 = 0.131836 */ |
| 9886 | 5, /* Internal filter scaling */ |
| 9887 | 159, /* Minimum in-band energy threshold */ |
| 9888 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9889 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9890 | }, |
| 9891 | { /* f900_1300[] */ |
| 9892 | 19776, /* A1 = 1.207092 */ |
| 9893 | -27437, /* A2 = -0.837341 */ |
| 9894 | -2666, /* B2 = -0.081371 */ |
| 9895 | 0, /* B1 = 0 */ |
| 9896 | 2666, /* B0 = 0.081371 */ |
| 9897 | 16302, /* A1 = 0.995026 */ |
| 9898 | -30354, /* A2 = -0.926361 */ |
| 9899 | 10389, /* B2 = 0.317062 */ |
| 9900 | -3327, /* B1 = -0.203064 */ |
| 9901 | 10389, /* B0 = 0.317062 */ |
| 9902 | 24299, /* A1 = 1.483154 */ |
| 9903 | -30930, /* A2 = -0.943909 */ |
| 9904 | 25016, /* B2 = 0.763428 */ |
| 9905 | -21171, /* B1 = -1.292236 */ |
| 9906 | 25016, /* B0 = 0.763428 */ |
| 9907 | 7, /* Internal filter scaling */ |
| 9908 | 159, /* Minimum in-band energy threshold */ |
| 9909 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9910 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9911 | }, |
| 9912 | { /* f935_1215[] */ |
| 9913 | 20554, /* A1 = 1.254517 */ |
| 9914 | -28764, /* A2 = -0.877838 */ |
| 9915 | -2048, /* B2 = -0.062515 */ |
| 9916 | 0, /* B1 = 0 */ |
| 9917 | 2048, /* B0 = 0.062515 */ |
| 9918 | 18209, /* A1 = 1.11145 */ |
| 9919 | -30951, /* A2 = -0.94458 */ |
| 9920 | 9390, /* B2 = 0.286575 */ |
| 9921 | -3955, /* B1 = -0.241455 */ |
| 9922 | 9390, /* B0 = 0.286575 */ |
| 9923 | 23902, /* A1 = 1.458923 */ |
| 9924 | -31286, /* A2 = -0.954803 */ |
| 9925 | 23252, /* B2 = 0.709595 */ |
| 9926 | -19132, /* B1 = -1.167725 */ |
| 9927 | 23252, /* B0 = 0.709595 */ |
| 9928 | 7, /* Internal filter scaling */ |
| 9929 | 159, /* Minimum in-band energy threshold */ |
| 9930 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9931 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9932 | }, |
| 9933 | { /* f941_1477[] */ |
| 9934 | 17543, /* A1 = 1.07074 */ |
| 9935 | -26220, /* A2 = -0.800201 */ |
| 9936 | -3298, /* B2 = -0.100647 */ |
| 9937 | 0, /* B1 = 0 */ |
| 9938 | 3298, /* B0 = 0.100647 */ |
| 9939 | 12423, /* A1 = 0.75827 */ |
| 9940 | -30036, /* A2 = -0.916626 */ |
| 9941 | 12651, /* B2 = 0.386078 */ |
| 9942 | -2444, /* B1 = -0.14917 */ |
| 9943 | 12653, /* B0 = 0.386154 */ |
| 9944 | 23518, /* A1 = 1.435425 */ |
| 9945 | -30745, /* A2 = -0.938293 */ |
| 9946 | 27282, /* B2 = 0.832581 */ |
| 9947 | -22529, /* B1 = -1.375122 */ |
| 9948 | 27286, /* B0 = 0.832703 */ |
| 9949 | 7, /* Internal filter scaling */ |
| 9950 | 159, /* Minimum in-band energy threshold */ |
| 9951 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9952 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9953 | }, |
| 9954 | { /* f942 */ |
| 9955 | 24104, /* A1 = -1.471252 */ |
| 9956 | -32507, /* A2 = 0.992065 */ |
| 9957 | -351, /* B2 = -0.010722 */ |
| 9958 | 0, /* B1 = 0.000000 */ |
| 9959 | 351, /* B0 = 0.010722 */ |
| 9960 | 23996, /* A1 = -1.464600 */ |
| 9961 | -32671, /* A2 = 0.997040 */ |
| 9962 | 22848, /* B2 = 0.697266 */ |
| 9963 | -16639, /* B1 = -1.015564 */ |
| 9964 | 22848, /* B0 = 0.697266 */ |
| 9965 | 24332, /* A1 = -1.485168 */ |
| 9966 | -32673, /* A2 = 0.997101 */ |
| 9967 | 4906, /* B2 = 0.149727 */ |
| 9968 | -3672, /* B1 = -0.224174 */ |
| 9969 | 4906, /* B0 = 0.149727 */ |
| 9970 | 5, /* Internal filter scaling */ |
| 9971 | 159, /* Minimum in-band energy threshold */ |
| 9972 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9973 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9974 | }, |
| 9975 | { /* f950 */ |
| 9976 | 23967, /* A1 = -1.462830 */ |
| 9977 | -32507, /* A2 = 0.992065 */ |
| 9978 | -518, /* B2 = -0.015821 */ |
| 9979 | 0, /* B1 = 0.000000 */ |
| 9980 | 518, /* B0 = 0.015821 */ |
| 9981 | 23856, /* A1 = -1.456055 */ |
| 9982 | -32671, /* A2 = 0.997040 */ |
| 9983 | 26287, /* B2 = 0.802246 */ |
| 9984 | -19031, /* B1 = -1.161560 */ |
| 9985 | 26287, /* B0 = 0.802246 */ |
| 9986 | 24195, /* A1 = -1.476746 */ |
| 9987 | -32673, /* A2 = 0.997101 */ |
| 9988 | 2890, /* B2 = 0.088196 */ |
| 9989 | -2151, /* B1 = -0.131317 */ |
| 9990 | 2890, /* B0 = 0.088196 */ |
| 9991 | 5, /* Internal filter scaling */ |
| 9992 | 159, /* Minimum in-band energy threshold */ |
| 9993 | 21, /* 21/32 in-band to broad-band ratio */ |
| 9994 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 9995 | }, |
| 9996 | { /* f950_1400[] */ |
| 9997 | 18294, /* A1 = 1.116638 */ |
| 9998 | -26962, /* A2 = -0.822845 */ |
| 9999 | -2914, /* B2 = -0.088936 */ |
| 10000 | 0, /* B1 = 0 */ |
| 10001 | 2914, /* B0 = 0.088936 */ |
| 10002 | 14119, /* A1 = 0.861786 */ |
| 10003 | -30227, /* A2 = -0.922455 */ |
| 10004 | 11466, /* B2 = 0.349945 */ |
| 10005 | -2833, /* B1 = -0.172943 */ |
| 10006 | 11466, /* B0 = 0.349945 */ |
| 10007 | 23431, /* A1 = 1.430115 */ |
| 10008 | -30828, /* A2 = -0.940796 */ |
| 10009 | 25331, /* B2 = 0.773071 */ |
| 10010 | -20911, /* B1 = -1.276367 */ |
| 10011 | 25331, /* B0 = 0.773071 */ |
| 10012 | 7, /* Internal filter scaling */ |
| 10013 | 159, /* Minimum in-band energy threshold */ |
| 10014 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10015 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10016 | }, |
| 10017 | { /* f975 */ |
| 10018 | 23521, /* A1 = -1.435608 */ |
| 10019 | -32489, /* A2 = 0.991516 */ |
| 10020 | -193, /* B2 = -0.005915 */ |
| 10021 | 0, /* B1 = 0.000000 */ |
| 10022 | 193, /* B0 = 0.005915 */ |
| 10023 | 23404, /* A1 = -1.428467 */ |
| 10024 | -32655, /* A2 = 0.996582 */ |
| 10025 | 17740, /* B2 = 0.541412 */ |
| 10026 | -12567, /* B1 = -0.767029 */ |
| 10027 | 17740, /* B0 = 0.541412 */ |
| 10028 | 23753, /* A1 = -1.449829 */ |
| 10029 | -32657, /* A2 = 0.996613 */ |
| 10030 | 9090, /* B2 = 0.277405 */ |
| 10031 | -6662, /* B1 = -0.406647 */ |
| 10032 | 9090, /* B0 = 0.277405 */ |
| 10033 | 5, /* Internal filter scaling */ |
| 10034 | 159, /* Minimum in-band energy threshold */ |
| 10035 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10036 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10037 | }, |
| 10038 | { /* f1000 */ |
| 10039 | 23071, /* A1 = -1.408203 */ |
| 10040 | -32489, /* A2 = 0.991516 */ |
| 10041 | -293, /* B2 = -0.008965 */ |
| 10042 | 0, /* B1 = 0.000000 */ |
| 10043 | 293, /* B0 = 0.008965 */ |
| 10044 | 22951, /* A1 = -1.400818 */ |
| 10045 | -32655, /* A2 = 0.996582 */ |
| 10046 | 5689, /* B2 = 0.173645 */ |
| 10047 | -3951, /* B1 = -0.241150 */ |
| 10048 | 5689, /* B0 = 0.173645 */ |
| 10049 | 23307, /* A1 = -1.422607 */ |
| 10050 | -32657, /* A2 = 0.996613 */ |
| 10051 | 18692, /* B2 = 0.570435 */ |
| 10052 | -13447, /* B1 = -0.820770 */ |
| 10053 | 18692, /* B0 = 0.570435 */ |
| 10054 | 5, /* Internal filter scaling */ |
| 10055 | 159, /* Minimum in-band energy threshold */ |
| 10056 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10057 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10058 | }, |
| 10059 | { /* f1020 */ |
| 10060 | 22701, /* A1 = -1.385620 */ |
| 10061 | -32474, /* A2 = 0.991058 */ |
| 10062 | -292, /* B2 = -0.008933 */ |
| 10063 | 0, /*163840 , B1 = 10.000000 */ |
| 10064 | 292, /* B0 = 0.008933 */ |
| 10065 | 22564, /* A1 = -1.377258 */ |
| 10066 | -32655, /* A2 = 0.996552 */ |
| 10067 | 20756, /* B2 = 0.633423 */ |
| 10068 | -14176, /* B1 = -0.865295 */ |
| 10069 | 20756, /* B0 = 0.633423 */ |
| 10070 | 22960, /* A1 = -1.401428 */ |
| 10071 | -32657, /* A2 = 0.996613 */ |
| 10072 | 6520, /* B2 = 0.198990 */ |
| 10073 | -4619, /* B1 = -0.281937 */ |
| 10074 | 6520, /* B0 = 0.198990 */ |
| 10075 | 5, /* Internal filter scaling */ |
| 10076 | 159, /* Minimum in-band energy threshold */ |
| 10077 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10078 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10079 | }, |
| 10080 | { /* f1050 */ |
| 10081 | 22142, /* A1 = -1.351501 */ |
| 10082 | -32474, /* A2 = 0.991058 */ |
| 10083 | -147, /* B2 = -0.004493 */ |
| 10084 | 0, /* B1 = 0.000000 */ |
| 10085 | 147, /* B0 = 0.004493 */ |
| 10086 | 22000, /* A1 = -1.342834 */ |
| 10087 | -32655, /* A2 = 0.996552 */ |
| 10088 | 15379, /* B2 = 0.469360 */ |
| 10089 | -10237, /* B1 = -0.624847 */ |
| 10090 | 15379, /* B0 = 0.469360 */ |
| 10091 | 22406, /* A1 = -1.367554 */ |
| 10092 | -32657, /* A2 = 0.996613 */ |
| 10093 | 17491, /* B2 = 0.533783 */ |
| 10094 | -12096, /* B1 = -0.738312 */ |
| 10095 | 17491, /* B0 = 0.533783 */ |
| 10096 | 5, /* Internal filter scaling */ |
| 10097 | 159, /* Minimum in-band energy threshold */ |
| 10098 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10099 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10100 | }, |
| 10101 | { /* f1100_1750[] */ |
| 10102 | 12973, /* A1 = 0.79184 */ |
| 10103 | -24916, /* A2 = -0.760376 */ |
| 10104 | 6655, /* B2 = 0.203102 */ |
| 10105 | 367, /* B1 = 0.0224 */ |
| 10106 | 6657, /* B0 = 0.203171 */ |
| 10107 | 5915, /* A1 = 0.361053 */ |
| 10108 | -29560, /* A2 = -0.90213 */ |
| 10109 | -7777, /* B2 = -0.23735 */ |
| 10110 | 0, /* B1 = 0 */ |
| 10111 | 7777, /* B0 = 0.23735 */ |
| 10112 | 20510, /* A1 = 1.251892 */ |
| 10113 | -30260, /* A2 = -0.923462 */ |
| 10114 | 26662, /* B2 = 0.81366 */ |
| 10115 | -20573, /* B1 = -1.255737 */ |
| 10116 | 26668, /* B0 = 0.813843 */ |
| 10117 | 7, /* Internal filter scaling */ |
| 10118 | 159, /* Minimum in-band energy threshold */ |
| 10119 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10120 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10121 | }, |
| 10122 | { /* f1140 */ |
| 10123 | 20392, /* A1 = -1.244629 */ |
| 10124 | -32460, /* A2 = 0.990601 */ |
| 10125 | -270, /* B2 = -0.008240 */ |
| 10126 | 0, /* B1 = 0.000000 */ |
| 10127 | 270, /* B0 = 0.008240 */ |
| 10128 | 20218, /* A1 = -1.234009 */ |
| 10129 | -32655, /* A2 = 0.996582 */ |
| 10130 | 21337, /* B2 = 0.651154 */ |
| 10131 | -13044, /* B1 = -0.796143 */ |
| 10132 | 21337, /* B0 = 0.651154 */ |
| 10133 | 20684, /* A1 = -1.262512 */ |
| 10134 | -32657, /* A2 = 0.996643 */ |
| 10135 | 8572, /* B2 = 0.261612 */ |
| 10136 | -5476, /* B1 = -0.334244 */ |
| 10137 | 8572, /* B0 = 0.261612 */ |
| 10138 | 5, /* Internal filter scaling */ |
| 10139 | 159, /* Minimum in-band energy threshold */ |
| 10140 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10141 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10142 | }, |
| 10143 | { /* f1200 */ |
| 10144 | 19159, /* A1 = -1.169373 */ |
| 10145 | -32456, /* A2 = 0.990509 */ |
| 10146 | -335, /* B2 = -0.010252 */ |
| 10147 | 0, /* B1 = 0.000000 */ |
| 10148 | 335, /* B0 = 0.010252 */ |
| 10149 | 18966, /* A1 = -1.157593 */ |
| 10150 | -32661, /* A2 = 0.996735 */ |
| 10151 | 6802, /* B2 = 0.207588 */ |
| 10152 | -3900, /* B1 = -0.238098 */ |
| 10153 | 6802, /* B0 = 0.207588 */ |
| 10154 | 19467, /* A1 = -1.188232 */ |
| 10155 | -32661, /* A2 = 0.996765 */ |
| 10156 | 25035, /* B2 = 0.764008 */ |
| 10157 | -15049, /* B1 = -0.918579 */ |
| 10158 | 25035, /* B0 = 0.764008 */ |
| 10159 | 5, /* Internal filter scaling */ |
| 10160 | 159, /* Minimum in-band energy threshold */ |
| 10161 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10162 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10163 | }, |
| 10164 | { /* f1209 */ |
| 10165 | 18976, /* A1 = -1.158264 */ |
| 10166 | -32439, /* A2 = 0.989990 */ |
| 10167 | -183, /* B2 = -0.005588 */ |
| 10168 | 0, /* B1 = 0.000000 */ |
| 10169 | 183, /* B0 = 0.005588 */ |
| 10170 | 18774, /* A1 = -1.145874 */ |
| 10171 | -32650, /* A2 = 0.996429 */ |
| 10172 | 15468, /* B2 = 0.472076 */ |
| 10173 | -8768, /* B1 = -0.535217 */ |
| 10174 | 15468, /* B0 = 0.472076 */ |
| 10175 | 19300, /* A1 = -1.177979 */ |
| 10176 | -32652, /* A2 = 0.996490 */ |
| 10177 | 19840, /* B2 = 0.605499 */ |
| 10178 | -11842, /* B1 = -0.722809 */ |
| 10179 | 19840, /* B0 = 0.605499 */ |
| 10180 | 5, /* Internal filter scaling */ |
| 10181 | 159, /* Minimum in-band energy threshold */ |
| 10182 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10183 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10184 | }, |
| 10185 | { /* f1330 */ |
| 10186 | 16357, /* A1 = -0.998413 */ |
| 10187 | -32368, /* A2 = 0.987793 */ |
| 10188 | -217, /* B2 = -0.006652 */ |
| 10189 | 0, /* B1 = 0.000000 */ |
| 10190 | 217, /* B0 = 0.006652 */ |
| 10191 | 16107, /* A1 = -0.983126 */ |
| 10192 | -32601, /* A2 = 0.994904 */ |
| 10193 | 11602, /* B2 = 0.354065 */ |
| 10194 | -5555, /* B1 = -0.339111 */ |
| 10195 | 11602, /* B0 = 0.354065 */ |
| 10196 | 16722, /* A1 = -1.020630 */ |
| 10197 | -32603, /* A2 = 0.994965 */ |
| 10198 | 15574, /* B2 = 0.475311 */ |
| 10199 | -8176, /* B1 = -0.499069 */ |
| 10200 | 15574, /* B0 = 0.475311 */ |
| 10201 | 5, /* Internal filter scaling */ |
| 10202 | 159, /* Minimum in-band energy threshold */ |
| 10203 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10204 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10205 | }, |
| 10206 | { /* f1336 */ |
| 10207 | 16234, /* A1 = -0.990875 */ |
| 10208 | 32404, /* A2 = -0.988922 */ |
| 10209 | -193, /* B2 = -0.005908 */ |
| 10210 | 0, /* B1 = 0.000000 */ |
| 10211 | 193, /* B0 = 0.005908 */ |
| 10212 | 15986, /* A1 = -0.975769 */ |
| 10213 | -32632, /* A2 = 0.995880 */ |
| 10214 | 18051, /* B2 = 0.550903 */ |
| 10215 | -8658, /* B1 = -0.528473 */ |
| 10216 | 18051, /* B0 = 0.550903 */ |
| 10217 | 16591, /* A1 = -1.012695 */ |
| 10218 | -32634, /* A2 = 0.995941 */ |
| 10219 | 15736, /* B2 = 0.480240 */ |
| 10220 | -8125, /* B1 = -0.495926 */ |
| 10221 | 15736, /* B0 = 0.480240 */ |
| 10222 | 5, /* Internal filter scaling */ |
| 10223 | 159, /* Minimum in-band energy threshold */ |
| 10224 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10225 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10226 | }, |
| 10227 | { /* f1366 */ |
| 10228 | 15564, /* A1 = -0.949982 */ |
| 10229 | -32404, /* A2 = 0.988922 */ |
| 10230 | -269, /* B2 = -0.008216 */ |
| 10231 | 0, /* B1 = 0.000000 */ |
| 10232 | 269, /* B0 = 0.008216 */ |
| 10233 | 15310, /* A1 = -0.934479 */ |
| 10234 | -32632, /* A2 = 0.995880 */ |
| 10235 | 10815, /* B2 = 0.330063 */ |
| 10236 | -4962, /* B1 = -0.302887 */ |
| 10237 | 10815, /* B0 = 0.330063 */ |
| 10238 | 15924, /* A1 = -0.971924 */ |
| 10239 | -32634, /* A2 = 0.995941 */ |
| 10240 | 18880, /* B2 = 0.576172 */ |
| 10241 | -9364, /* B1 = -0.571594 */ |
| 10242 | 18880, /* B0 = 0.576172 */ |
| 10243 | 5, /* Internal filter scaling */ |
| 10244 | 159, /* Minimum in-band energy threshold */ |
| 10245 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10246 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10247 | }, |
| 10248 | { /* f1380 */ |
| 10249 | 15247, /* A1 = -0.930603 */ |
| 10250 | -32397, /* A2 = 0.988708 */ |
| 10251 | -244, /* B2 = -0.007451 */ |
| 10252 | 0, /* B1 = 0.000000 */ |
| 10253 | 244, /* B0 = 0.007451 */ |
| 10254 | 14989, /* A1 = -0.914886 */ |
| 10255 | -32627, /* A2 = 0.995697 */ |
| 10256 | 18961, /* B2 = 0.578644 */ |
| 10257 | -8498, /* B1 = -0.518707 */ |
| 10258 | 18961, /* B0 = 0.578644 */ |
| 10259 | 15608, /* A1 = -0.952667 */ |
| 10260 | -32628, /* A2 = 0.995758 */ |
| 10261 | 11145, /* B2 = 0.340134 */ |
| 10262 | -5430, /* B1 = -0.331467 */ |
| 10263 | 11145, /* B0 = 0.340134 */ |
| 10264 | 5, /* Internal filter scaling */ |
| 10265 | 159, /* Minimum in-band energy threshold */ |
| 10266 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10267 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10268 | }, |
| 10269 | { /* f1400 */ |
| 10270 | 14780, /* A1 = -0.902130 */ |
| 10271 | -32393, /* A2 = 0.988586 */ |
| 10272 | -396, /* B2 = -0.012086 */ |
| 10273 | 0, /* B1 = 0.000000 */ |
| 10274 | 396, /* B0 = 0.012086 */ |
| 10275 | 14510, /* A1 = -0.885651 */ |
| 10276 | -32630, /* A2 = 0.995819 */ |
| 10277 | 6326, /* B2 = 0.193069 */ |
| 10278 | -2747, /* B1 = -0.167671 */ |
| 10279 | 6326, /* B0 = 0.193069 */ |
| 10280 | 15154, /* A1 = -0.924957 */ |
| 10281 | -32632, /* A2 = 0.995850 */ |
| 10282 | 23235, /* B2 = 0.709076 */ |
| 10283 | -10983, /* B1 = -0.670380 */ |
| 10284 | 23235, /* B0 = 0.709076 */ |
| 10285 | 5, /* Internal filter scaling */ |
| 10286 | 159, /* Minimum in-band energy threshold */ |
| 10287 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10288 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10289 | }, |
| 10290 | { /* f1477 */ |
| 10291 | 13005, /* A1 = -0.793793 */ |
| 10292 | -32368, /* A2 = 0.987823 */ |
| 10293 | -500, /* B2 = -0.015265 */ |
| 10294 | 0, /* B1 = 0.000000 */ |
| 10295 | 500, /* B0 = 0.015265 */ |
| 10296 | 12708, /* A1 = -0.775665 */ |
| 10297 | -32615, /* A2 = 0.995331 */ |
| 10298 | 11420, /* B2 = 0.348526 */ |
| 10299 | -4306, /* B1 = -0.262833 */ |
| 10300 | 11420, /* B0 = 0.348526 */ |
| 10301 | 13397, /* A1 = -0.817688 */ |
| 10302 | -32615, /* A2 = 0.995361 */ |
| 10303 | 9454, /* B2 = 0.288528 */ |
| 10304 | -3981, /* B1 = -0.243027 */ |
| 10305 | 9454, /* B0 = 0.288528 */ |
| 10306 | 5, /* Internal filter scaling */ |
| 10307 | 159, /* Minimum in-band energy threshold */ |
| 10308 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10309 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10310 | }, |
| 10311 | { /* f1600 */ |
| 10312 | 10046, /* A1 = -0.613190 */ |
| 10313 | -32331, /* A2 = 0.986694 */ |
| 10314 | -455, /* B2 = -0.013915 */ |
| 10315 | 0, /* B1 = 0.000000 */ |
| 10316 | 455, /* B0 = 0.013915 */ |
| 10317 | 9694, /* A1 = -0.591705 */ |
| 10318 | -32601, /* A2 = 0.994934 */ |
| 10319 | 6023, /* B2 = 0.183815 */ |
| 10320 | -1708, /* B1 = -0.104279 */ |
| 10321 | 6023, /* B0 = 0.183815 */ |
| 10322 | 10478, /* A1 = -0.639587 */ |
| 10323 | -32603, /* A2 = 0.994965 */ |
| 10324 | 22031, /* B2 = 0.672333 */ |
| 10325 | -7342, /* B1 = -0.448151 */ |
| 10326 | 22031, /* B0 = 0.672333 */ |
| 10327 | 5, /* Internal filter scaling */ |
| 10328 | 159, /* Minimum in-band energy threshold */ |
| 10329 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10330 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10331 | }, |
| 10332 | { /* f1633_1638[] */ |
| 10333 | 9181, /* A1 = 0.560394 */ |
| 10334 | -32256, /* A2 = -0.984375 */ |
| 10335 | -556, /* B2 = -0.016975 */ |
| 10336 | 0, /* B1 = 0 */ |
| 10337 | 556, /* B0 = 0.016975 */ |
| 10338 | 8757, /* A1 = 0.534515 */ |
| 10339 | -32574, /* A2 = -0.99408 */ |
| 10340 | 8443, /* B2 = 0.25769 */ |
| 10341 | -2135, /* B1 = -0.130341 */ |
| 10342 | 8443, /* B0 = 0.25769 */ |
| 10343 | 9691, /* A1 = 0.591522 */ |
| 10344 | -32574, /* A2 = -0.99411 */ |
| 10345 | 15446, /* B2 = 0.471375 */ |
| 10346 | -4809, /* B1 = -0.293579 */ |
| 10347 | 15446, /* B0 = 0.471375 */ |
| 10348 | 7, /* Internal filter scaling */ |
| 10349 | 159, /* Minimum in-band energy threshold */ |
| 10350 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10351 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10352 | }, |
| 10353 | { /* f1800 */ |
| 10354 | 5076, /* A1 = -0.309875 */ |
| 10355 | -32304, /* A2 = 0.985840 */ |
| 10356 | -508, /* B2 = -0.015503 */ |
| 10357 | 0, /* B1 = 0.000000 */ |
| 10358 | 508, /* B0 = 0.015503 */ |
| 10359 | 4646, /* A1 = -0.283600 */ |
| 10360 | -32605, /* A2 = 0.995026 */ |
| 10361 | 6742, /* B2 = 0.205780 */ |
| 10362 | -878, /* B1 = -0.053635 */ |
| 10363 | 6742, /* B0 = 0.205780 */ |
| 10364 | 5552, /* A1 = -0.338928 */ |
| 10365 | -32605, /* A2 = 0.995056 */ |
| 10366 | 23667, /* B2 = 0.722260 */ |
| 10367 | -4297, /* B1 = -0.262329 */ |
| 10368 | 23667, /* B0 = 0.722260 */ |
| 10369 | 5, /* Internal filter scaling */ |
| 10370 | 159, /* Minimum in-band energy threshold */ |
| 10371 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10372 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10373 | }, |
| 10374 | { /* f1860 */ |
| 10375 | 3569, /* A1 = -0.217865 */ |
| 10376 | -32292, /* A2 = 0.985504 */ |
| 10377 | -239, /* B2 = -0.007322 */ |
| 10378 | 0, /* B1 = 0.000000 */ |
| 10379 | 239, /* B0 = 0.007322 */ |
| 10380 | 3117, /* A1 = -0.190277 */ |
| 10381 | -32603, /* A2 = 0.994965 */ |
| 10382 | 18658, /* B2 = 0.569427 */ |
| 10383 | -1557, /* B1 = -0.095032 */ |
| 10384 | 18658, /* B0 = 0.569427 */ |
| 10385 | 4054, /* A1 = -0.247437 */ |
| 10386 | -32603, /* A2 = 0.994965 */ |
| 10387 | 18886, /* B2 = 0.576385 */ |
| 10388 | -2566, /* B1 = -0.156647 */ |
| 10389 | 18886, /* B0 = 0.576385 */ |
| 10390 | 5, /* Internal filter scaling */ |
| 10391 | 159, /* Minimum in-band energy threshold */ |
| 10392 | 21, /* 21/32 in-band to broad-band ratio */ |
| 10393 | 0x0FF5 /* shift-mask 0x0FF (look at 16 half-frames) bit count = 5 */ |
| 10394 | }, |
| 10395 | }; |
| 10396 | static int ixj_init_filter(IXJ *j, IXJ_FILTER * jf) |
| 10397 | { |
| 10398 | unsigned short cmd; |
| 10399 | int cnt, max; |
| 10400 | |
| 10401 | if (jf->filter > 3) { |
| 10402 | return -1; |
| 10403 | } |
| 10404 | if (ixj_WriteDSPCommand(0x5154 + jf->filter, j)) /* Select Filter */ |
| 10405 | |
| 10406 | return -1; |
| 10407 | if (!jf->enable) { |
| 10408 | if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */ |
| 10409 | |
| 10410 | return -1; |
| 10411 | else |
| 10412 | return 0; |
| 10413 | } else { |
| 10414 | if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */ |
| 10415 | |
| 10416 | return -1; |
| 10417 | /* Select the filter (f0 - f3) to use. */ |
| 10418 | if (ixj_WriteDSPCommand(0x5154 + jf->filter, j)) |
| 10419 | return -1; |
| 10420 | } |
| 10421 | if (jf->freq < 12 && jf->freq > 3) { |
| 10422 | /* Select the frequency for the selected filter. */ |
| 10423 | if (ixj_WriteDSPCommand(0x5170 + jf->freq, j)) |
| 10424 | return -1; |
| 10425 | } else if (jf->freq > 11) { |
| 10426 | /* We need to load a programmable filter set for undefined */ |
| 10427 | /* frequencies. So we will point the filter to a programmable set. */ |
| 10428 | /* Since there are only 4 filters and 4 programmable sets, we will */ |
| 10429 | /* just point the filter to the same number set and program it for the */ |
| 10430 | /* frequency we want. */ |
| 10431 | if (ixj_WriteDSPCommand(0x5170 + jf->filter, j)) |
| 10432 | return -1; |
| 10433 | if (j->ver.low != 0x12) { |
| 10434 | cmd = 0x515B; |
| 10435 | max = 19; |
| 10436 | } else { |
| 10437 | cmd = 0x515E; |
| 10438 | max = 15; |
| 10439 | } |
| 10440 | if (ixj_WriteDSPCommand(cmd, j)) |
| 10441 | return -1; |
| 10442 | for (cnt = 0; cnt < max; cnt++) { |
| 10443 | if (ixj_WriteDSPCommand(tone_table[jf->freq - 12][cnt], j)) |
| 10444 | return -1; |
| 10445 | } |
| 10446 | } |
| 10447 | j->filter_en[jf->filter] = jf->enable; |
| 10448 | return 0; |
| 10449 | } |
| 10450 | |
| 10451 | static int ixj_init_filter_raw(IXJ *j, IXJ_FILTER_RAW * jfr) |
| 10452 | { |
| 10453 | unsigned short cmd; |
| 10454 | int cnt, max; |
| 10455 | if (jfr->filter > 3) { |
| 10456 | return -1; |
| 10457 | } |
| 10458 | if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j)) /* Select Filter */ |
| 10459 | return -1; |
| 10460 | |
| 10461 | if (!jfr->enable) { |
| 10462 | if (ixj_WriteDSPCommand(0x5152, j)) /* Disable Filter */ |
| 10463 | return -1; |
| 10464 | else |
| 10465 | return 0; |
| 10466 | } else { |
| 10467 | if (ixj_WriteDSPCommand(0x5153, j)) /* Enable Filter */ |
| 10468 | return -1; |
| 10469 | /* Select the filter (f0 - f3) to use. */ |
| 10470 | if (ixj_WriteDSPCommand(0x5154 + jfr->filter, j)) |
| 10471 | return -1; |
| 10472 | } |
| 10473 | /* We need to load a programmable filter set for undefined */ |
| 10474 | /* frequencies. So we will point the filter to a programmable set. */ |
| 10475 | /* Since there are only 4 filters and 4 programmable sets, we will */ |
| 10476 | /* just point the filter to the same number set and program it for the */ |
| 10477 | /* frequency we want. */ |
| 10478 | if (ixj_WriteDSPCommand(0x5170 + jfr->filter, j)) |
| 10479 | return -1; |
| 10480 | if (j->ver.low != 0x12) { |
| 10481 | cmd = 0x515B; |
| 10482 | max = 19; |
| 10483 | } else { |
| 10484 | cmd = 0x515E; |
| 10485 | max = 15; |
| 10486 | } |
| 10487 | if (ixj_WriteDSPCommand(cmd, j)) |
| 10488 | return -1; |
| 10489 | for (cnt = 0; cnt < max; cnt++) { |
| 10490 | if (ixj_WriteDSPCommand(jfr->coeff[cnt], j)) |
| 10491 | return -1; |
| 10492 | } |
| 10493 | j->filter_en[jfr->filter] = jfr->enable; |
| 10494 | return 0; |
| 10495 | } |
| 10496 | |
| 10497 | static int ixj_init_tone(IXJ *j, IXJ_TONE * ti) |
| 10498 | { |
| 10499 | int freq0, freq1; |
| 10500 | unsigned short data; |
| 10501 | if (ti->freq0) { |
| 10502 | freq0 = ti->freq0; |
| 10503 | } else { |
| 10504 | freq0 = 0x7FFF; |
| 10505 | } |
| 10506 | |
| 10507 | if (ti->freq1) { |
| 10508 | freq1 = ti->freq1; |
| 10509 | } else { |
| 10510 | freq1 = 0x7FFF; |
| 10511 | } |
| 10512 | |
| 10513 | if(ti->tone_index > 12 && ti->tone_index < 28) |
| 10514 | { |
| 10515 | if (ixj_WriteDSPCommand(0x6800 + ti->tone_index, j)) |
| 10516 | return -1; |
| 10517 | if (ixj_WriteDSPCommand(0x6000 + (ti->gain1 << 4) + ti->gain0, j)) |
| 10518 | return -1; |
| 10519 | data = freq0; |
| 10520 | if (ixj_WriteDSPCommand(data, j)) |
| 10521 | return -1; |
| 10522 | data = freq1; |
| 10523 | if (ixj_WriteDSPCommand(data, j)) |
| 10524 | return -1; |
| 10525 | } |
| 10526 | return freq0; |
| 10527 | } |
| 10528 | |