248 #define PERFMON_STATS
252 #include <linux/module.h>
255 #include <linux/sched.h>
256 #include <linux/kernel.h>
257 #include <linux/fs.h>
258 #include <linux/errno.h>
259 #include <linux/slab.h>
265 #include <linux/poll.h>
268 #include <linux/pci.h>
271 #include <asm/uaccess.h>
277 #define TYPE(inode) (iminor(inode) >> 4)
278 #define NUM(inode) (iminor(inode) & 0xf)
282 static int hertz =
HZ;
283 static int samplerate = 100;
315 #define get_ixj(b) ixj[(b)]
321 static IXJ *ixj_alloc()
337 static void ixj_fsk_free(
IXJ *
j)
343 static void ixj_fsk_alloc(
IXJ *
j)
348 if(ixjdebug & 0x0200) {
349 printk(
"IXJ phone%d - allocate failed\n", j->
board);
354 if(ixjdebug & 0x0200) {
355 printk(
"IXJ phone%d - allocate succeeded\n", j->
board);
364 #define get_ixj(b) (&ixj[(b)])
370 static IXJ *ixj_alloc(
void)
373 for(cnt=0; cnt<
IXJMAX; cnt++) {
374 if(!ixj[cnt].DSPbase)
380 static inline void ixj_fsk_free(
IXJ *j) {;}
382 static inline void ixj_fsk_alloc(
IXJ *j)
390 #define ixj_perfmon(x) ((x)++)
392 #define ixj_perfmon(x) do { } while(0)
395 static int ixj_convert_loaded;
397 static int ixj_WriteDSPCommand(
unsigned short,
IXJ *j);
406 static int Stub(
IXJ * J,
unsigned long arg)
416 static void ixj_read_frame(
IXJ *j);
417 static void ixj_write_frame(
IXJ *j);
418 static void ixj_init_timer(
IXJ *j);
419 static void ixj_add_timer(
IXJ * j);
420 static void ixj_timeout(
unsigned long ptr);
421 static int read_filters(
IXJ *j);
422 static int LineMonitor(
IXJ *j);
423 static int ixj_fasync(
int fd,
struct file *,
int mode);
424 static int ixj_set_port(
IXJ *j,
int arg);
425 static int ixj_set_pots(
IXJ *j,
int arg);
426 static int ixj_hookstate(
IXJ *j);
427 static int ixj_record_start(
IXJ *j);
428 static void ixj_record_stop(
IXJ *j);
429 static void set_rec_volume(
IXJ *j,
int volume);
430 static int get_rec_volume(
IXJ *j);
431 static int set_rec_codec(
IXJ *j,
int rate);
432 static void ixj_vad(
IXJ *j,
int arg);
433 static int ixj_play_start(
IXJ *j);
434 static void ixj_play_stop(
IXJ *j);
435 static int ixj_set_tone_on(
unsigned short arg,
IXJ *j);
436 static int ixj_set_tone_off(
unsigned short,
IXJ *j);
437 static int ixj_play_tone(
IXJ *j,
char tone);
438 static void ixj_aec_start(
IXJ *j,
int level);
440 static void ixj_ring_on(
IXJ *j);
441 static void ixj_ring_off(
IXJ *j);
442 static void aec_stop(
IXJ *j);
443 static void ixj_ringback(
IXJ *j);
444 static void ixj_busytone(
IXJ *j);
445 static void ixj_dialtone(
IXJ *j);
446 static void ixj_cpt_stop(
IXJ *j);
447 static char daa_int_read(
IXJ *j);
448 static char daa_CR_read(
IXJ *j,
int cr);
449 static int daa_set_mode(
IXJ *j,
int mode);
450 static int ixj_linetest(
IXJ *j);
451 static int ixj_daa_write(
IXJ *j);
452 static int ixj_daa_cid_read(
IXJ *j);
453 static void DAA_Coeff_US(
IXJ *j);
454 static void DAA_Coeff_UK(
IXJ *j);
455 static void DAA_Coeff_France(
IXJ *j);
456 static void DAA_Coeff_Germany(
IXJ *j);
457 static void DAA_Coeff_Australia(
IXJ *j);
458 static void DAA_Coeff_Japan(
IXJ *j);
466 static int SCI_Prepare(
IXJ *j);
467 static int SCI_WaitHighSCI(
IXJ *j);
468 static int SCI_WaitLowSCI(
IXJ *j);
469 static DWORD PCIEE_GetSerialNumber(
WORD wAddress);
470 static int ixj_PCcontrol_wait(
IXJ *j);
471 static void ixj_pre_cid(
IXJ *j);
472 static void ixj_write_cid(
IXJ *j);
473 static void ixj_write_cid_bit(
IXJ *j,
int bit);
474 static int set_base_frame(
IXJ *j,
int size);
475 static int set_play_codec(
IXJ *j,
int rate);
476 static void set_rec_depth(
IXJ *j,
int depth);
477 static int ixj_mixer(
long val,
IXJ *j);
493 static inline void ixj_read_HSR(
IXJ *j)
499 static inline int IsControlReady(
IXJ *j)
505 static inline int IsPCControlReady(
IXJ *j)
511 static inline int IsStatusReady(
IXJ *j)
517 static inline int IsRxReady(
IXJ *j)
524 static inline int IsTxReady(
IXJ *j)
531 static inline void set_play_volume(
IXJ *j,
int volume)
533 if (ixjdebug & 0x0002)
535 ixj_WriteDSPCommand(0xCF02, j);
536 ixj_WriteDSPCommand(volume, j);
539 static int set_play_volume_linear(
IXJ *j,
int volume)
541 int newvolume, dspplaymax;
543 if (ixjdebug & 0x0002)
544 printk(
KERN_INFO "IXJ: /dev/phone %d Setting Linear Play Volume to 0x%4.4x\n", j->
board, volume);
545 if(volume > 100 || volume < 0) {
573 newvolume = (dspplaymax *
volume) / 100;
574 set_play_volume(j, newvolume);
578 static inline void set_play_depth(
IXJ *j,
int depth)
584 ixj_WriteDSPCommand(0x5280 + depth, j);
587 static inline int get_play_volume(
IXJ *j)
589 ixj_WriteDSPCommand(0xCF00, j);
593 static int get_play_volume_linear(
IXJ *j)
595 int volume, newvolume, dspplaymax;
621 volume = get_play_volume(j);
622 newvolume = (volume * 100) / dspplaymax;
628 static inline BYTE SLIC_GetState(
IXJ *j)
635 ixj_PCcontrol_wait(j);
637 ixj_PCcontrol_wait(j);
650 static bool SLIC_SetState(
BYTE byState,
IXJ *j)
652 bool fRetVal =
false;
694 ixj_PCcontrol_wait(j);
775 static int ixj_wink(
IXJ *j)
779 slicnow = SLIC_GetState(j);
786 SLIC_SetState(slicnow, j);
790 static void ixj_init_timer(
IXJ *j)
793 j->
timer.function = ixj_timeout;
797 static void ixj_add_timer(
IXJ *j)
803 static void ixj_tone_timeout(
IXJ *j)
829 ixj_init_tone(j, &ti);
843 ixj_init_tone(j, &ti);
856 if(ixjdebug & 0x0100)
857 printk(
"Sending signal for event %d\n", event);
864 static void ixj_pstn_state(
IXJ *j)
867 union XOPXR0 XR0, daaint;
880 daaint.bitreg.RING = 1;
881 if(ixjdebug & 0x0008) {
889 daaint.bitreg.Caller_ID = 1;
892 if(ixjdebug & 0x0008) {
897 daaint.bitreg.Cadence = 1;
898 if(ixjdebug & 0x0008) {
903 daaint.bitreg.VDD_OK = 1;
909 daaint.bitreg.RMR = 1;
911 if(ixjdebug & 0x0008) {
919 if (daaint.bitreg.RING) {
929 if (daaint.bitreg.RMR) {
930 if (ixjdebug & 0x0008) {
933 if (daaint.bitreg.SI_1) {
955 if (ixjdebug & 0x0008) {
956 printk(
KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
974 if (ixjdebug & 0x0008) {
975 printk(
KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
986 if (ixjdebug & 0x0008) {
987 printk(
KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1013 if (ixjdebug & 0x0008) {
1014 printk(
KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1032 if (ixjdebug & 0x0008) {
1033 printk(
KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1054 if (ixjdebug & 0x0008) {
1055 printk(
KERN_INFO "IXJ Ring Cadence fail state = %d /dev/phone%d at %ld should be %d\n",
1062 if (ixjdebug & 0x0010) {
1065 if (ixjdebug & 0x0010) {
1068 printk(
KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->
board,
1072 printk(
KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->
board,
1076 printk(
KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->
board,
1080 printk(
KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->
board,
1084 printk(
KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->
board,
1088 printk(
KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->
board,
1097 j->
ex.
bits.pstn_ring = 1;
1099 if(ixjdebug & 0x0008) {
1105 if(ixjdebug & 0x0008) {
1106 printk(
"IXJ DAA no ring in 5 seconds /dev/phone%d at %ld\n", j->
board, jiffies);
1115 ixj_daa_cid_read(j);
1116 j->
ex.
bits.caller_id = 1;
1120 if (daaint.bitreg.Cadence) {
1121 if(ixjdebug & 0x0008) {
1122 printk(
"IXJ DAA Cadence interrupt going to sleep /dev/phone%d\n", j->
board);
1125 j->
ex.
bits.pstn_ring = 0;
1129 if (daaint.bitreg.VDD_OK) {
1130 if(!daaint.bitreg.SI_0) {
1132 if(ixjdebug & 0x0008) {
1133 printk(
"IXJ DAA possible wink /dev/phone%d %ld\n", j->
board, jiffies);
1139 if(ixjdebug & 0x0008) {
1140 printk(
"IXJ DAA possible wink end /dev/phone%d %ld\n", j->
board, jiffies);
1147 if(ixjdebug & 0x0008) {
1148 printk(
"IXJ DAA wink detected going to sleep /dev/phone%d %ld\n", j->
board, jiffies);
1152 j->
ex.
bits.pstn_wink = 1;
1159 static void ixj_timeout(
unsigned long ptr)
1162 unsigned long jifon;
1174 j->
ex.
bits.hookstate = 1;
1188 if (j->
dsp.
low == 0x20) {
1194 ixj_play_tone(j, 0);
1195 if (j->
dsp.
low == 0x20) {
1202 ixj_tone_timeout(j);
1208 if (j->
dsp.
low == 0x20) {
1216 if (j->
dsp.
low == 0x20) {
1244 if(ixjdebug & 0x0004) {
1254 if(ixjdebug & 0x0004) {
1263 if(ixjdebug & 0x0004) {
1277 if(ixjdebug & 0x0004) {
1291 if(ixjdebug & 0x0004) {
1305 if(ixjdebug & 0x0004) {
1319 if(ixjdebug & 0x0004) {
1326 if(ixjdebug & 0x0004) {
1377 if (j->
dsp.
low != 0x20 &&
1383 ixj_WriteDSPCommand(0x511B, j);
1390 if (j->
ex.
bits.dtmf_ready) {
1395 j->
ex.
bits.hookstate = 1;
1411 static int ixj_status_wait(
IXJ *j)
1415 jif =
jiffies + ((60 * hertz) / 100);
1416 while (!IsStatusReady(j)) {
1426 static int ixj_PCcontrol_wait(
IXJ *j)
1430 jif =
jiffies + ((60 * hertz) / 100);
1431 while (!IsPCControlReady(j)) {
1441 static int ixj_WriteDSPCommand(
unsigned short cmd,
IXJ *j)
1448 printk(
"IXJ %d DSP write overlap attempting command 0x%4.4x\n", j->
board, cmd);
1451 bytes.
high = (cmd & 0xFF00) >> 8;
1452 bytes.
low = cmd & 0x00FF;
1453 jif =
jiffies + ((60 * hertz) / 100);
1454 while (!IsControlReady(j)) {
1460 printk(
"IXJ %d DSP overlaped command 0x%4.4x during control ready failure.\n", j->
board, cmd);
1471 if (ixj_status_wait(j)) {
1476 printk(
"IXJ %d DSP overlaped command 0x%4.4x during status wait failure.\n", j->
board, cmd);
1488 printk(
"IXJ %d DSP overlaped command 0x%4.4x\n", j->
board, cmd);
1501 static inline int ixj_gpio_read(
IXJ *j)
1503 if (ixj_WriteDSPCommand(0x5143, j))
1512 static inline void LED_SetState(
int state,
IXJ *j)
1538 static int ixj_set_port(
IXJ *j,
int arg)
1563 if (ixj_WriteDSPCommand(0xC528, j))
1574 ixj_mixer(0x1200, j);
1575 ixj_mixer(0x1401, j);
1576 ixj_mixer(0x1300, j);
1577 ixj_mixer(0x1501, j);
1578 ixj_mixer(0x0E80, j);
1579 ixj_mixer(0x0F00, j);
1580 ixj_mixer(0x0080, j);
1581 ixj_mixer(0x0180, j);
1589 ixj_WriteDSPCommand(j->
gpio.
word, j);
1595 ixj_WriteDSPCommand(0xC534, j);
1621 if (ixj_WriteDSPCommand(0xC528, j))
1632 ixj_mixer(0x1201, j);
1633 ixj_mixer(0x1400, j);
1634 ixj_mixer(0x1301, j);
1635 ixj_mixer(0x1500, j);
1636 ixj_mixer(0x0E06, j);
1637 ixj_mixer(0x0F80, j);
1638 ixj_mixer(0x0000, j);
1639 ixj_mixer(0x0100, j);
1645 ixj_WriteDSPCommand(j->
gpio.
word, j);
1656 ixj_WriteDSPCommand(j->
gpio.
word, j);
1667 static int ixj_set_pots(
IXJ *j,
int arg)
1691 static void ixj_ring_on(
IXJ *j)
1695 if (ixjdebug & 0x0004)
1703 ixj_WriteDSPCommand(j->
gpio.
word, j);
1706 if (ixjdebug & 0x0004)
1713 static int ixj_siadc(
IXJ *j,
int val)
1720 if(val < 0 || val > 0x1F)
1731 ixj_PCcontrol_wait(j);
1738 static int ixj_sidac(
IXJ *j,
int val)
1745 if(val < 0 || val > 0x1F)
1756 ixj_PCcontrol_wait(j);
1763 static int ixj_pcmcia_cable_check(
IXJ *j)
1777 ixj_PCcontrol_wait(j);
1783 ixj_PCcontrol_wait(j);
1822 ixj_PCcontrol_wait(j);
1848 ixj_PCcontrol_wait(j);
1860 ixj_PCcontrol_wait(j);
1867 ixj_PCcontrol_wait(j);
1874 ixj_PCcontrol_wait(j);
1887 ixj_PCcontrol_wait(j);
1898 ixj_PCcontrol_wait(j);
1906 ixj_PCcontrol_wait(j);
1917 static int ixj_hookstate(
IXJ *j)
1932 if(fOffHook != j->
p_hook) {
1942 printk(
"IXJ : /dev/phone%d pots-pstn hookstate check %d at %ld\n", j->
board, fOffHook, jiffies);
1965 fOffHook = ixj_pcmcia_cable_check(j);
1968 if (j->
r_hook != fOffHook) {
1971 j->
ex.
bits.hookstate = 1;
1973 }
else if (!fOffHook) {
2008 static void ixj_ring_off(
IXJ *j)
2012 if (ixjdebug & 0x0004)
2019 ixj_WriteDSPCommand(j->
gpio.
word, j);
2022 if (ixjdebug & 0x0004)
2032 static void ixj_ring_start(
IXJ *j)
2035 if (ixjdebug & 0x0004)
2037 if (ixj_hookstate(j) & 1) {
2041 if (ixjdebug & 0x0004)
2061 static int ixj_ring(
IXJ *j)
2067 if (ixj_hookstate(j) & 1) {
2072 for (cntr = 0; cntr < j->
maxrings; cntr++) {
2076 if (ixj_hookstate(j) & 1) {
2088 if (ixj_hookstate(j) & 1) {
2090 if (ixj_hookstate(j) & 1) {
2105 static int ixj_open(
struct phone_device *
p,
struct file *file_p)
2137 ixj_PCcontrol_wait(j);
2143 if (ixjdebug & 0x0002)
2155 int board = j->
p.board;
2163 if (ixjdebug & 0x0002)
2174 set_play_volume(j, 0x100);
2175 set_rec_volume(j, 0x100);
2184 ixj_init_tone(j, &ti);
2190 ixj_init_tone(j, &ti);
2196 ixj_init_tone(j, &ti);
2202 ixj_init_tone(j, &ti);
2208 ixj_init_tone(j, &ti);
2214 ixj_init_tone(j, &ti);
2220 ixj_init_tone(j, &ti);
2226 ixj_init_tone(j, &ti);
2232 ixj_init_tone(j, &ti);
2238 ixj_init_tone(j, &ti);
2244 ixj_init_tone(j, &ti);
2250 ixj_init_tone(j, &ti);
2256 ixj_init_tone(j, &ti);
2262 ixj_init_tone(j, &ti);
2268 ixj_init_tone(j, &ti);
2274 ixj_init_tone(j, &ti);
2280 ixj_init_tone(j, &ti);
2286 ixj_init_tone(j, &ti);
2288 set_rec_depth(j, 2);
2290 set_play_depth(j, 2);
2292 j->
ex.
bits.dtmf_ready = 0;
2305 for (cnt = 0; cnt < 4; cnt++)
2338 ixj_WriteDSPCommand(0x0FE3, j);
2341 for (cnt = 0; cnt < 35; cnt++)
2354 static int read_filters(
IXJ *j)
2356 unsigned short fc,
cnt, trg;
2360 if (ixj_WriteDSPCommand(0x5144, j)) {
2361 if(ixjdebug & 0x0001) {
2377 for (cnt = 0; cnt < 4; cnt++) {
2378 if (ixj_WriteDSPCommand(0x5154 + cnt, j)) {
2379 if(ixjdebug & 0x0001) {
2384 if (ixj_WriteDSPCommand(0x515C, j)) {
2385 if(ixjdebug & 0x0001) {
2498 if (ixjdebug & 0x0040) {
2537 if(ixjdebug & 0x0020) {
2544 if(ixjdebug & 0x0020) {
2551 if(ixjdebug & 0x0020) {
2558 if(ixjdebug & 0x0020) {
2575 if(ixjdebug & 0x0020) {
2582 if(ixjdebug & 0x0020) {
2589 if(ixjdebug & 0x0020) {
2596 if(ixjdebug & 0x0020) {
2608 static int LineMonitor(
IXJ *j)
2615 if (ixj_WriteDSPCommand(0x7000, j))
2631 j->
ex.
bits.dtmf_ready = 1;
2637 if(ixjdebug & 0x0020) {
2655 static void ulaw2alaw(
unsigned char *buff,
unsigned long len)
2657 static unsigned char table_ulaw2alaw[] =
2659 0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D,
2660 0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25,
2661 0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D,
2662 0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35,
2663 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02,
2664 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A,
2665 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12,
2666 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B,
2667 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63,
2668 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79,
2669 0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71,
2670 0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D,
2671 0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45,
2672 0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D,
2673 0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51,
2674 0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5,
2675 0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD,
2676 0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5,
2677 0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD,
2678 0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5,
2679 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82,
2680 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A,
2681 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92,
2682 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB,
2683 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3,
2684 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9,
2685 0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1,
2686 0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD,
2687 0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5,
2688 0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD,
2689 0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1,
2690 0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5
2695 *buff = table_ulaw2alaw[*(
unsigned char *)buff];
2700 static void alaw2ulaw(
unsigned char *buff,
unsigned long len)
2702 static unsigned char table_alaw2ulaw[] =
2704 0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C,
2705 0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24,
2706 0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C,
2707 0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34,
2708 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D,
2709 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
2710 0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D,
2711 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15,
2712 0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65,
2713 0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E,
2714 0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A,
2715 0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D,
2716 0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B,
2717 0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43,
2718 0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59,
2719 0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51,
2720 0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC,
2721 0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4,
2722 0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC,
2723 0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4,
2724 0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D,
2725 0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85,
2726 0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D,
2727 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95,
2728 0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5,
2729 0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE,
2730 0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA,
2731 0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED,
2732 0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB,
2733 0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3,
2734 0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9,
2735 0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1
2740 *buff = table_alaw2ulaw[*(
unsigned char *)buff];
2747 unsigned long i = *ppos;
2769 if (!ixj_hookstate(j)) {
2776 if (signal_pending(
current)) {
2800 static ssize_t ixj_enhanced_read(
struct file * file_p,
char __user *buf,
size_t length,
2807 pre_retval = ixj_PreRead(j, 0L);
2808 switch (pre_retval) {
2810 read_retval = ixj_read(file_p, buf, length, ppos);
2811 ixj_PostRead(j, 0L);
2814 read_retval = ixj_read(file_p, buf, length, ppos);
2817 ixj_PostRead(j, 0L);
2820 read_retval = pre_retval;
2825 static ssize_t ixj_write(
struct file *file_p,
const char __user *buf,
size_t count, loff_t * ppos)
2827 unsigned long i = *ppos;
2850 if (!ixj_hookstate(j)) {
2857 if (signal_pending(
current)) {
2879 static ssize_t ixj_enhanced_write(
struct file * file_p,
const char __user *buf,
size_t count, loff_t * ppos)
2886 pre_retval = ixj_PreWrite(j, 0L);
2887 switch (pre_retval) {
2889 write_retval = ixj_write(file_p, buf, count, ppos);
2890 if (write_retval > 0) {
2891 ixj_PostWrite(j, 0L);
2897 write_retval = ixj_write(file_p, buf, count, ppos);
2898 if (write_retval > 0) {
2904 ixj_PostWrite(j, 0L);
2907 write_retval = pre_retval;
2909 return write_retval;
2912 static void ixj_read_frame(
IXJ *j)
2918 if (!(cnt % 16) && !IsRxReady(j)) {
2920 while (!IsRxReady(j)) {
2929 if (j->
rec_codec ==
G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
2940 if (!(cnt % 16) && !IsTxReady(j)) {
2942 while (!IsTxReady(j)) {
2967 static short fsk[][6][20] =
2971 0, 17846, 29934, 32364, 24351, 8481, -10126, -25465, -32587, -29196,
2972 -16384, 1715, 19260, 30591, 32051, 23170, 6813, -11743, -26509, -32722
2975 -28377, -14876, 3425, 20621, 31163, 31650, 21925, 5126, -13328, -27481,
2976 -32767, -27481, -13328, 5126, 21925, 31650, 31163, 20621, 3425, -14876
2979 -28377, -32722, -26509, -11743, 6813, 23170, 32051, 30591, 19260, 1715,
2980 -16384, -29196, -32587, -25465, -10126, 8481, 24351, 32364, 29934, 17846
2983 0, -17846, -29934, -32364, -24351, -8481, 10126, 25465, 32587, 29196,
2984 16384, -1715, -19260, -30591, -32051, -23170, -6813, 11743, 26509, 32722
2987 28377, 14876, -3425, -20621, -31163, -31650, -21925, -5126, 13328, 27481,
2988 32767, 27481, 13328, -5126, -21925, -31650, -31163, -20621, -3425, 14876
2991 28377, 32722, 26509, 11743, -6813, -23170, -32051, -30591, -19260, -1715,
2992 16384, 29196, 32587, 25465, 10126, -8481, -24351, -32364, -29934, -17846
2997 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126,
2998 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126
3001 -28377, -21925, -13328, -3425, 6813, 16384, 24351, 29934, 32587, 32051,
3002 28377, 21925, 13328, 3425, -6813, -16384, -24351, -29934, -32587, -32051
3005 -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925,
3006 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925
3009 0, -10126, -19260, -26509, -31163, -32767, -31163, -26509, -19260, -10126,
3010 0, 10126, 19260, 26509, 31163, 32767, 31163, 26509, 19260, 10126
3013 28377, 21925, 13328, 3425, -6813, -16383, -24351, -29934, -32587, -32051,
3014 -28377, -21925, -13328, -3425, 6813, 16383, 24351, 29934, 32587, 32051
3017 28377, 32051, 32587, 29934, 24351, 16384, 6813, -3425, -13328, -21925,
3018 -28377, -32051, -32587, -29934, -24351, -16384, -6813, 3425, 13328, 21925
3024 static void ixj_write_cid_bit(
IXJ *j,
int bit)
3041 static void ixj_write_cid_byte(
IXJ *j,
char byte)
3046 ixj_write_cid_bit(j, 0);
3047 ixj_write_cid_bit(j, cb.
cbits.
b0 ? 1 : 0);
3048 ixj_write_cid_bit(j, cb.
cbits.
b1 ? 1 : 0);
3049 ixj_write_cid_bit(j, cb.
cbits.
b2 ? 1 : 0);
3050 ixj_write_cid_bit(j, cb.
cbits.
b3 ? 1 : 0);
3051 ixj_write_cid_bit(j, cb.
cbits.
b4 ? 1 : 0);
3052 ixj_write_cid_bit(j, cb.
cbits.
b5 ? 1 : 0);
3053 ixj_write_cid_bit(j, cb.
cbits.
b6 ? 1 : 0);
3054 ixj_write_cid_bit(j, cb.
cbits.
b7 ? 1 : 0);
3055 ixj_write_cid_bit(j, 1);
3058 static void ixj_write_cid_seize(
IXJ *j)
3062 for (cnt = 0; cnt < 150; cnt++) {
3063 ixj_write_cid_bit(j, 0);
3064 ixj_write_cid_bit(j, 1);
3066 for (cnt = 0; cnt < 180; cnt++) {
3067 ixj_write_cid_bit(j, 1);
3071 static void ixj_write_cidcw_seize(
IXJ *j)
3075 for (cnt = 0; cnt < 80; cnt++) {
3076 ixj_write_cid_bit(j, 1);
3080 static int ixj_write_cid_string(
IXJ *j,
char *
s,
int checksum)
3084 for (cnt = 0; cnt <
strlen(s); cnt++) {
3085 ixj_write_cid_byte(j, s[cnt]);
3086 checksum = (checksum + s[
cnt]);
3091 static void ixj_pad_fsk(
IXJ *j,
int pad)
3095 for (cnt = 0; cnt <
pad; cnt++) {
3099 for (cnt = 0; cnt < 720; cnt++) {
3105 static void ixj_pre_cid(
IXJ *j)
3135 set_base_frame(j, 30);
3137 set_play_volume(j, 0x1B);
3141 static void ixj_post_cid(
IXJ *j)
3149 if(ixjdebug & 0x0200) {
3150 printk(
"IXJ phone%d Finished Playing CallerID data %ld\n", j->
board, jiffies);
3165 ixj_record_start(j);
3175 static void ixj_write_cid(
IXJ *j)
3180 char mdmflen, len1, len2, len3;
3203 mdmflen = len1 + len2 + len3 + 6;
3206 ixj_write_cid_seize(j);
3208 ixj_write_cid_byte(j, 0x80);
3210 ixj_write_cid_byte(j, mdmflen);
3211 checksum = checksum + mdmflen;
3213 ixj_write_cid_byte(j, 0x01);
3214 checksum = checksum + 0x01;
3215 ixj_write_cid_byte(j, len1);
3216 checksum = checksum + len1;
3217 checksum = ixj_write_cid_string(j, sdmf1, checksum);
3218 if(ixj_hookstate(j) & 1)
3221 ixj_write_cid_byte(j, 0x02);
3222 checksum = checksum + 0x02;
3223 ixj_write_cid_byte(j, len2);
3224 checksum = checksum + len2;
3225 checksum = ixj_write_cid_string(j, sdmf2, checksum);
3226 if(ixj_hookstate(j) & 1)
3229 ixj_write_cid_byte(j, 0x07);
3230 checksum = checksum + 0x07;
3231 ixj_write_cid_byte(j, len3);
3232 checksum = checksum + len3;
3233 checksum = ixj_write_cid_string(j, sdmf3, checksum);
3234 if(ixj_hookstate(j) & 1)
3241 ixj_write_cid_byte(j, (
char) checksum);
3247 ixj_pad_fsk(j, pad);
3254 static void ixj_write_cidcw(
IXJ *j)
3261 char mdmflen, len1, len2, len3;
3281 ixj_init_tone(j, &ti);
3283 ixj_set_tone_on(1500, j);
3284 ixj_set_tone_off(32, j);
3285 if(ixjdebug & 0x0200) {
3286 printk(
"IXJ cidcw phone%d first tone start at %ld\n", j->
board, jiffies);
3288 ixj_play_tone(j, 23);
3295 if(ixjdebug & 0x0200) {
3296 printk(
"IXJ cidcw phone%d first tone end at %ld\n", j->
board, jiffies);
3304 ixj_init_tone(j, &ti);
3306 ixj_set_tone_off(10, j);
3307 ixj_set_tone_on(600, j);
3308 if(ixjdebug & 0x0200) {
3309 printk(
"IXJ cidcw phone%d second tone start at %ld\n", j->
board, jiffies);
3311 ixj_play_tone(j, 24);
3318 if(ixjdebug & 0x0200) {
3319 printk(
"IXJ cidcw phone%d sent second tone at %ld\n", j->
board, jiffies);
3331 if(ixjdebug & 0x0200) {
3332 printk(
"IXJ cidcw phone%d did not receive ACK from display %ld\n", j->
board, jiffies);
3353 mdmflen = len1 + len2 + len3 + 6;
3355 ixj_write_cidcw_seize(j);
3357 ixj_write_cid_byte(j, 0x80);
3359 ixj_write_cid_byte(j, mdmflen);
3360 checksum = checksum + mdmflen;
3362 ixj_write_cid_byte(j, 0x01);
3363 checksum = checksum + 0x01;
3364 ixj_write_cid_byte(j, len1);
3365 checksum = checksum + len1;
3366 checksum = ixj_write_cid_string(j, sdmf1, checksum);
3368 ixj_write_cid_byte(j, 0x02);
3369 checksum = checksum + 0x02;
3370 ixj_write_cid_byte(j, len2);
3371 checksum = checksum + len2;
3372 checksum = ixj_write_cid_string(j, sdmf2, checksum);
3374 ixj_write_cid_byte(j, 0x07);
3375 checksum = checksum + 0x07;
3376 ixj_write_cid_byte(j, len3);
3377 checksum = checksum + len3;
3378 checksum = ixj_write_cid_string(j, sdmf3, checksum);
3384 ixj_write_cid_byte(j, (
char) checksum);
3390 ixj_pad_fsk(j, pad);
3391 if(ixjdebug & 0x0200) {
3392 printk(
"IXJ cidcw phone%d sent FSK data at %ld\n", j->
board, jiffies);
3396 static void ixj_write_vmwi(
IXJ *j,
int msg)
3416 ixj_write_cid_seize(j);
3418 ixj_write_cid_byte(j, 0x82);
3420 ixj_write_cid_byte(j, mdmflen);
3421 checksum = checksum + mdmflen;
3423 ixj_write_cid_byte(j, 0x0B);
3424 checksum = checksum + 0x0B;
3425 ixj_write_cid_byte(j, 1);
3426 checksum = checksum + 1;
3429 ixj_write_cid_byte(j, 0xFF);
3430 checksum = checksum + 0xFF;
3433 ixj_write_cid_byte(j, 0x00);
3434 checksum = checksum + 0x00;
3441 ixj_write_cid_byte(j, (
char) checksum);
3447 ixj_pad_fsk(j, pad);
3450 static void ixj_write_frame(
IXJ *j)
3457 for(cnt = 0; cnt < 480; cnt++) {
3458 if (!(cnt % 16) && !IsTxReady(j)) {
3460 while (!IsTxReady(j)) {
3499 if (frame_count >= 1) {
3506 blankword.
low = blankword.
high = 0xFF;
3511 blankword.
low = blankword.
high = 0x00;
3514 blankword.
low = blankword.
high = 0x80;
3517 for (cnt = 0; cnt < 16; cnt++) {
3518 if (!(cnt % 16) && !IsTxReady(j)) {
3520 while (!IsTxReady(j)) {
3533 for (cnt = 0; cnt < 24; cnt++) {
3537 blankword.
low = 0x02;
3538 blankword.
high = 0x00;
3541 blankword.
low = blankword.
high = 0x00;
3543 if (!(cnt % 16) && !IsTxReady(j)) {
3545 while (!IsTxReady(j)) {
3559 if (!(cnt % 16) && !IsTxReady(j)) {
3561 while (!IsTxReady(j)) {
3570 if (j->
play_codec ==
G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
3616 if (ixj_WriteDSPCommand(0x0000, j))
3631 static int set_base_frame(
IXJ *j,
int size)
3639 for (cnt = 0; cnt < 10; cnt++) {
3645 if (j->
dsp.
low != 0x20) {
3668 if (ixj_WriteDSPCommand(cmd, j)) {
3683 static int set_rec_codec(
IXJ *j,
int rate)
3691 if (j->
ver.
low != 0x12 || ixj_convert_loaded) {
3699 if (j->
ver.
low != 0x12 || ixj_convert_loaded) {
3715 if (j->
ver.
low != 0x12 || ixj_convert_loaded) {
3723 if (j->
ver.
low != 0x12 || ixj_convert_loaded) {
3731 if (j->
dsp.
low != 0x20) {
3739 if (j->
dsp.
low != 0x20) {
3761 if (j->
dsp.
low != 0x20) {
3864 static int ixj_record_start(
IXJ *j)
3866 unsigned short cmd = 0x0000;
3872 ixj_WriteDSPCommand(0x0FE0, j);
3874 if(ixjdebug & 0x0002)
3907 if (ixj_WriteDSPCommand(cmd, j))
3914 printk(
"Read buffer allocation for ixj board %d failed!\n", j->
board);
3920 if (ixj_WriteDSPCommand(0x5102, j))
3930 if (j->
ver.
low == 0x12) {
3939 if (j->
ver.
low == 0x12) {
3948 if (j->
ver.
low == 0x12) {
3957 if (j->
ver.
low == 0x12) {
3964 if (ixj_WriteDSPCommand(cmd, j))
3973 static void ixj_record_stop(
IXJ *j)
3975 if (ixjdebug & 0x0002)
3982 ixj_WriteDSPCommand(0x5120, j);
3987 static void ixj_vad(
IXJ *j,
int arg)
3990 ixj_WriteDSPCommand(0x513F, j);
3992 ixj_WriteDSPCommand(0x513E, j);
3995 static void set_rec_depth(
IXJ *j,
int depth)
4001 ixj_WriteDSPCommand(0x5180 + depth, j);
4004 static void set_dtmf_prescale(
IXJ *j,
int volume)
4006 ixj_WriteDSPCommand(0xCF07, j);
4007 ixj_WriteDSPCommand(volume, j);
4010 static int get_dtmf_prescale(
IXJ *j)
4012 ixj_WriteDSPCommand(0xCF05, j);
4016 static void set_rec_volume(
IXJ *j,
int volume)
4019 if (ixjdebug & 0x0002)
4021 ixj_WriteDSPCommand(0xCF96, j);
4022 ixj_WriteDSPCommand(volume, j);
4024 if (ixjdebug & 0x0002)
4026 ixj_WriteDSPCommand(0xCF03, j);
4027 ixj_WriteDSPCommand(volume, j);
4031 static int set_rec_volume_linear(
IXJ *j,
int volume)
4033 int newvolume, dsprecmax;
4035 if (ixjdebug & 0x0002)
4036 printk(
KERN_INFO "IXJ: /dev/phone %d Setting Linear Record Volume to 0x%4.4x\n", j->
board, volume);
4037 if(volume > 100 || volume < 0) {
4048 ixj_mixer(0x0203, j);
4049 ixj_mixer(0x0303, j);
4050 ixj_mixer(0x0C00, j);
4064 newvolume = (dsprecmax *
volume) / 100;
4065 set_rec_volume(j, newvolume);
4069 static int get_rec_volume(
IXJ *j)
4072 if (ixjdebug & 0x0002)
4074 ixj_WriteDSPCommand(0xCF86, j);
4075 if (ixjdebug & 0x0002)
4079 if (ixjdebug & 0x0002)
4081 ixj_WriteDSPCommand(0xCF01, j);
4086 static int get_rec_volume_linear(
IXJ *j)
4088 int volume, newvolume, dsprecmax;
4109 volume = get_rec_volume(j);
4110 newvolume = (volume * 100) / dsprecmax;
4116 static int get_rec_level(
IXJ *j)
4120 ixj_WriteDSPCommand(0xCF88, j);
4123 retval = (retval * 256) / 240;
4127 static void ixj_aec_start(
IXJ *j,
int level)
4130 if (ixjdebug & 0x0002)
4136 ixj_WriteDSPCommand(0xE022, j);
4138 ixj_WriteDSPCommand(0x0300, j);
4140 ixj_WriteDSPCommand(0xB001, j);
4142 ixj_WriteDSPCommand(0xE013, j);
4146 ixj_WriteDSPCommand(0x0000, j);
4148 ixj_WriteDSPCommand(0xE011, j);
4149 ixj_WriteDSPCommand(0xFFFF, j);
4151 ixj_WriteDSPCommand(0xCF97, j);
4152 ixj_WriteDSPCommand(0x0000, j);
4157 ixj_WriteDSPCommand(0x0600, j);
4159 ixj_WriteDSPCommand(0xE011, j);
4160 ixj_WriteDSPCommand(0x0080, j);
4162 ixj_WriteDSPCommand(0xCF97, j);
4163 ixj_WriteDSPCommand(0x0000, j);
4168 ixj_WriteDSPCommand(0x0C00, j);
4170 ixj_WriteDSPCommand(0xE011, j);
4171 ixj_WriteDSPCommand(0x0080, j);
4173 ixj_WriteDSPCommand(0xCF97, j);
4174 ixj_WriteDSPCommand(0x0000, j);
4180 ixj_WriteDSPCommand(0x0002, j);
4182 ixj_WriteDSPCommand(0xE011, j);
4183 ixj_WriteDSPCommand(0x0100, j);
4185 ixj_WriteDSPCommand(0xE012, j);
4188 ixj_WriteDSPCommand(0x0224, j);
4190 ixj_WriteDSPCommand(0x1224, j);
4192 ixj_WriteDSPCommand(0xE014, j);
4193 ixj_WriteDSPCommand(0x0003, j);
4195 ixj_WriteDSPCommand(0xE338, j);
4198 ixj_WriteDSPCommand(0xCF90, j);
4199 ixj_WriteDSPCommand(0x0020, j);
4201 ixj_WriteDSPCommand(0xCF91, j);
4202 ixj_WriteDSPCommand(0x1000, j);
4204 ixj_WriteDSPCommand(0xCF92, j);
4205 ixj_WriteDSPCommand(0x0800, j);
4207 ixj_WriteDSPCommand(0xCF93, j);
4208 ixj_WriteDSPCommand(0x1F40, j);
4210 ixj_WriteDSPCommand(0xCF94, j);
4211 ixj_WriteDSPCommand(0x0005, j);
4213 ixj_WriteDSPCommand(0xCF95, j);
4214 ixj_WriteDSPCommand(0x000D, j);
4216 ixj_WriteDSPCommand(0xCF96, j);
4217 ixj_WriteDSPCommand(0x1200, j);
4219 ixj_WriteDSPCommand(0xCF97, j);
4220 ixj_WriteDSPCommand(0x0001, j);
4225 ixj_WriteDSPCommand(0x0002, j);
4227 ixj_WriteDSPCommand(0xE011, j);
4228 ixj_WriteDSPCommand(0x0100, j);
4230 ixj_WriteDSPCommand(0xE012, j);
4233 ixj_WriteDSPCommand(0x0224, j);
4235 ixj_WriteDSPCommand(0x1224, j);
4237 ixj_WriteDSPCommand(0xE014, j);
4238 ixj_WriteDSPCommand(0x0003, j);
4240 ixj_WriteDSPCommand(0xE338, j);
4247 static void aec_stop(
IXJ *j)
4251 ixj_WriteDSPCommand(0xE022, j);
4253 ixj_WriteDSPCommand(0x0700, j);
4257 ixj_WriteDSPCommand(0xB002, j);
4261 static int set_play_codec(
IXJ *j,
int rate)
4269 if (j->
ver.
low != 0x12 || ixj_convert_loaded) {
4277 if (j->
ver.
low != 0x12 || ixj_convert_loaded) {
4293 if (j->
ver.
low != 0x12 || ixj_convert_loaded) {
4301 if (j->
ver.
low != 0x12 || ixj_convert_loaded) {
4309 if (j->
dsp.
low != 0x20) {
4317 if (j->
dsp.
low != 0x20) {
4339 if (j->
dsp.
low != 0x20) {
4442 static int ixj_play_start(
IXJ *j)
4444 unsigned short cmd = 0x0000;
4450 if(ixjdebug & 0x0002)
4454 ixj_WriteDSPCommand(0x0FE0, j);
4489 if (ixj_WriteDSPCommand(cmd, j))
4494 printk(
"Write buffer allocation for ixj board %d failed!\n", j->
board);
4503 if (ixj_WriteDSPCommand(0x5202, j))
4512 if (j->
ver.
low == 0x12) {
4519 if (j->
ver.
low == 0x12) {
4526 if (j->
ver.
low == 0x12) {
4533 if (j->
ver.
low == 0x12) {
4540 if (ixj_WriteDSPCommand(cmd, j))
4543 if (ixj_WriteDSPCommand(0x2000, j))
4556 static void ixj_play_stop(
IXJ *j)
4558 if (ixjdebug & 0x0002)
4565 ixj_WriteDSPCommand(0x5221, j);
4572 static inline int get_play_level(
IXJ *j)
4576 ixj_WriteDSPCommand(0xCF8F, j);
4579 retval = (retval * 256) / 240;
4585 unsigned int mask = 0;
4589 poll_wait(file_p, &(j->
poll_q), wait);
4599 static int ixj_play_tone(
IXJ *j,
char tone)
4602 if(ixjdebug & 0x0002) {
4603 printk(
"IXJ %d starting tone %d at %ld\n", j->
board, tone, jiffies);
4605 if (j->
dsp.
low == 0x20) {
4614 if (ixj_WriteDSPCommand(0x6000 + j->
tone_index, j))
4620 static int ixj_set_tone_on(
unsigned short arg,
IXJ *j)
4624 if (ixj_WriteDSPCommand(0x6E04, j))
4628 if (ixj_WriteDSPCommand(arg, j))
4634 static int SCI_WaitHighSCI(
IXJ *j)
4640 for (cnt = 0; cnt < 10; cnt++) {
4647 if (ixjdebug & 0x0001)
4654 static int SCI_WaitLowSCI(
IXJ *j)
4660 for (cnt = 0; cnt < 10; cnt++) {
4667 if (ixjdebug & 0x0001)
4714 if (!SCI_WaitHighSCI(j))
4724 static int SCI_Prepare(
IXJ *j)
4729 if (!SCI_WaitLowSCI(j))
4735 static int ixj_get_mixer(
long val,
IXJ *j)
4737 int reg = (val & 0x1F00) >> 8;
4741 static int ixj_mixer(
long val,
IXJ *j)
4745 bytes.
high = (val & 0x1F00) >> 8;
4746 bytes.
low = val & 0x00FF;
4762 static int daa_load(
BYTES * p_bytes,
IXJ *j)
4772 static int ixj_daa_cr4(
IXJ *j,
char reg)
4810 if (!daa_load(&bytes, j))
4813 if (!SCI_Prepare(j))
4819 static char daa_int_read(
IXJ *j)
4823 if (!SCI_Prepare(j))
4837 if (ixjdebug & 0x0001)
4838 printk(
"Cannot read DAA ID Byte high = %d low = %d\n", bytes.
high, bytes.
low);
4854 static char daa_CR_read(
IXJ *j,
int cr)
4859 if (!SCI_Prepare(j))
4889 if (ixjdebug & 0x0001)
4890 printk(
"Cannot read DAA ID Byte high = %d low = %d\n", bytes.
high, bytes.
low);
4925 static int ixj_daa_cid_reset(
IXJ *j)
4930 if (ixjdebug & 0x0002)
4931 printk(
"DAA Clearing CID ram\n");
4933 if (!SCI_Prepare(j))
4944 if (!SCI_WaitHighSCI(j))
4948 bytes.
high = bytes.
low = 0x00;
4951 if (i < ALISDAA_CALLERID_SIZE - 1)
4957 if (!SCI_WaitHighSCI(j))
4965 if (ixjdebug & 0x0002)
4966 printk(
"DAA CID ram cleared\n");
4971 static int ixj_daa_cid_read(
IXJ *j)
4979 if (!SCI_Prepare(j))
4990 if (!SCI_WaitHighSCI(j))
4996 if (ixjdebug & 0x0001)
4997 printk(
"DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.
high, bytes.
low);
5001 bytes.
high = bytes.
low = 0x00;
5008 if (!SCI_WaitHighSCI(j))
5022 if ((pIn[1] & 0x03) == 0x01) {
5025 if ((pIn[2] & 0x0c) == 0x04) {
5026 pOut[1] = ((pIn[2] & 0x03) << 6) | ((pIn[1] & 0xfc) >> 2);
5028 if ((pIn[3] & 0x30) == 0x10) {
5029 pOut[2] = ((pIn[3] & 0x0f) << 4) | ((pIn[2] & 0xf0) >> 4);
5031 if ((pIn[4] & 0xc0) == 0x40) {
5032 pOut[3] = ((pIn[4] & 0x3f) << 2) | ((pIn[3] & 0xc0) >> 6);
5036 pIn += 5, pOut += 4;
5057 ixj_daa_cid_reset(j);
5061 static char daa_get_version(
IXJ *j)
5065 if (!SCI_Prepare(j))
5079 if (ixjdebug & 0x0001)
5080 printk(
"DAA Get Version Cannot read DAA ID Byte high = %d low = %d\n", bytes.
high, bytes.
low);
5091 if (ixjdebug & 0x0002)
5092 printk(
"DAA CR5 Byte high = 0x%x low = 0x%x\n", bytes.
high, bytes.
low);
5097 static int daa_set_mode(
IXJ *j,
int mode)
5117 if (!SCI_Prepare(j))
5129 daa_load(&bytes, j);
5130 if (!SCI_Prepare(j))
5140 if (ixjdebug & 0x0008)
5151 daa_load(&bytes, j);
5152 if (!SCI_Prepare(j))
5162 daa_load(&bytes, j);
5163 if (!SCI_Prepare(j))
5168 j->
ex.
bits.pstn_ring = 0;
5175 if (ixjdebug & 0x0008)
5184 daa_load(&bytes, j);
5185 if (!SCI_Prepare(j))
5190 if (ixjdebug & 0x0008)
5194 daa_load(&bytes, j);
5195 if (!SCI_Prepare(j))
5204 j->
ex.
bits.pstn_ring = 0;
5209 if (ixjdebug & 0x0008)
5218 daa_load(&bytes, j);
5219 if (!SCI_Prepare(j))
5229 static int ixj_daa_write(
IXJ *j)
5237 if (!SCI_Prepare(j))
5244 if (!daa_load(&bytes, j))
5249 if (!daa_load(&bytes, j))
5254 if (!daa_load(&bytes, j))
5257 if (!SCI_Prepare(j))
5262 if (!daa_load(&bytes, j))
5267 if (!daa_load(&bytes, j))
5272 if (!daa_load(&bytes, j))
5277 if (!daa_load(&bytes, j))
5282 if (!daa_load(&bytes, j))
5285 if (!SCI_Prepare(j))
5290 if (!daa_load(&bytes, j))
5295 if (!daa_load(&bytes, j))
5300 if (!daa_load(&bytes, j))
5305 if (!daa_load(&bytes, j))
5310 if (!daa_load(&bytes, j))
5315 if (!SCI_WaitLowSCI(j))
5320 if (!daa_load(&bytes, j))
5325 if (!daa_load(&bytes, j))
5330 if (!daa_load(&bytes, j))
5335 if (!daa_load(&bytes, j))
5340 if (!daa_load(&bytes, j))
5345 if (!SCI_WaitLowSCI(j))
5350 if (!daa_load(&bytes, j))
5355 if (!daa_load(&bytes, j))
5360 if (!daa_load(&bytes, j))
5365 if (!daa_load(&bytes, j))
5370 if (!daa_load(&bytes, j))
5375 if (!SCI_WaitLowSCI(j))
5380 if (!daa_load(&bytes, j))
5385 if (!daa_load(&bytes, j))
5390 if (!daa_load(&bytes, j))
5395 if (!daa_load(&bytes, j))
5400 if (!daa_load(&bytes, j))
5405 if (!SCI_WaitLowSCI(j))
5410 if (!daa_load(&bytes, j))
5415 if (!daa_load(&bytes, j))
5420 if (!daa_load(&bytes, j))
5425 if (!daa_load(&bytes, j))
5430 if (!daa_load(&bytes, j))
5435 if (!SCI_WaitLowSCI(j))
5440 if (!daa_load(&bytes, j))
5445 if (!daa_load(&bytes, j))
5450 if (!daa_load(&bytes, j))
5455 if (!daa_load(&bytes, j))
5460 if (!daa_load(&bytes, j))
5465 if (!SCI_WaitLowSCI(j))
5470 if (!daa_load(&bytes, j))
5475 if (!daa_load(&bytes, j))
5480 if (!daa_load(&bytes, j))
5485 if (!daa_load(&bytes, j))
5490 if (!daa_load(&bytes, j))
5495 if (!SCI_WaitLowSCI(j))
5500 if (!daa_load(&bytes, j))
5505 if (!daa_load(&bytes, j))
5510 if (!daa_load(&bytes, j))
5515 if (!daa_load(&bytes, j))
5520 if (!daa_load(&bytes, j))
5525 if (!SCI_WaitLowSCI(j))
5530 if (!daa_load(&bytes, j))
5535 if (!daa_load(&bytes, j))
5540 if (!daa_load(&bytes, j))
5545 if (!daa_load(&bytes, j))
5550 if (!daa_load(&bytes, j))
5555 if (!SCI_WaitLowSCI(j))
5560 if (!daa_load(&bytes, j))
5565 if (!daa_load(&bytes, j))
5570 if (!daa_load(&bytes, j))
5575 if (!SCI_WaitLowSCI(j))
5580 if (!daa_load(&bytes, j))
5585 if (!daa_load(&bytes, j))
5590 if (!daa_load(&bytes, j))
5595 if (!SCI_WaitLowSCI(j))
5600 if (!daa_load(&bytes, j))
5605 if (!daa_load(&bytes, j))
5610 if (!daa_load(&bytes, j))
5615 if (!SCI_WaitLowSCI(j))
5620 if (!daa_load(&bytes, j))
5625 if (!daa_load(&bytes, j))
5630 if (!daa_load(&bytes, j))
5635 if (!SCI_WaitLowSCI(j))
5640 if (!daa_load(&bytes, j))
5645 if (!daa_load(&bytes, j))
5650 if (!daa_load(&bytes, j))
5655 if (!SCI_WaitLowSCI(j))
5660 if (!daa_load(&bytes, j))
5665 if (!daa_load(&bytes, j))
5670 if (!daa_load(&bytes, j))
5675 if (!daa_load(&bytes, j))
5680 if (!daa_load(&bytes, j))
5685 if (!SCI_WaitLowSCI(j))
5690 if (!daa_load(&bytes, j))
5695 if (!daa_load(&bytes, j))
5700 if (!daa_load(&bytes, j))
5705 if (!daa_load(&bytes, j))
5710 if (!daa_load(&bytes, j))
5720 if (ixjdebug & 0x0002)
5721 printk(
"DAA Coefficients Loaded\n");
5727 static int ixj_set_tone_off(
unsigned short arg,
IXJ *j)
5730 if (ixj_WriteDSPCommand(0x6E05, j))
5733 if (ixj_WriteDSPCommand(arg, j))
5738 static int ixj_get_tone_on(
IXJ *j)
5740 if (ixj_WriteDSPCommand(0x6E06, j))
5746 static int ixj_get_tone_off(
IXJ *j)
5748 if (ixj_WriteDSPCommand(0x6E07, j))
5754 static void ixj_busytone(
IXJ *j)
5759 ixj_set_tone_on(0x07D0, j);
5760 ixj_set_tone_off(0x07D0, j);
5761 ixj_play_tone(j, 27);
5764 static void ixj_dialtone(
IXJ *j)
5769 if (j->
dsp.
low == 0x20) {
5772 ixj_set_tone_on(0xFFFF, j);
5773 ixj_set_tone_off(0x0000, j);
5774 ixj_play_tone(j, 25);
5778 static void ixj_cpt_stop(
IXJ *j)
5785 ixj_set_tone_on(0x0001, j);
5786 ixj_set_tone_off(0x0000, j);
5787 ixj_play_tone(j, 0);
5800 ixj_record_start(j);
5803 static void ixj_ringback(
IXJ *j)
5808 ixj_set_tone_on(0x0FA0, j);
5809 ixj_set_tone_off(0x2EE0, j);
5810 ixj_play_tone(j, 26);
5813 static void ixj_testram(
IXJ *j)
5815 ixj_WriteDSPCommand(0x3001, j);
5832 &cp->elements_used,
sizeof(
int)))
5857 lcp->
ce = (
void *) lcep;
5868 ixj_init_tone(j, &ti);
5870 ixj_play_tone(j, lcp->
ce[0].
index);
5884 if(ixjdebug & 0x0001) {
5885 printk(
KERN_INFO "Could not allocate memory for cadence or could not copy cadence to kernel\n");
5887 return PTR_ERR(lcp);
5890 if(ixjdebug & 0x0001) {
5917 if(ixjdebug & 0x0002) {
5924 static void add_caps(
IXJ *j)
5928 strcpy(j->
caplist[j->
caps].desc,
"Quicknet Technologies, Inc. (www.quicknet.net)");
6069 if (j->
dsp.
low == 0x21) {
6098 for (cnt = 0; cnt < j->
caps; cnt++) {
6108 static long do_ixj_ioctl(
struct file *file_p,
unsigned int cmd,
unsigned long arg)
6114 struct inode *inode = file_p->
f_path.dentry->d_inode;
6115 unsigned int minor = iminor(inode);
6116 unsigned int raise, mant;
6117 int board =
NUM(inode);
6129 if (ixjdebug & 0x0040)
6130 printk(
"phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
6131 if (minor >= IXJMAX) {
6204 retval = ixj_ring(j);
6212 j->
ex.
bits.pstn_ring = 0;
6213 j->
ex.
bits.caller_id = 0;
6214 j->
ex.
bits.pstn_wink = 0;
6226 j->
ex.
bits.hookstate = 0;
6230 LED_SetState(arg, j);
6233 retval = set_base_frame(j, arg);
6236 retval = set_rec_codec(j, arg);
6242 ixj_record_start(j);
6248 set_rec_depth(j, arg);
6252 retval = get_rec_volume(j);
6255 set_rec_volume(j, arg);
6261 retval = get_rec_volume_linear(j);
6264 set_rec_volume_linear(j, arg);
6270 retval = get_dtmf_prescale(j);
6273 set_dtmf_prescale(j, arg);
6278 retval = get_rec_level(j);
6281 retval = ixj_siadc(j, arg);
6284 retval = ixj_sidac(j, arg);
6287 ixj_aec_start(j, arg);
6296 retval = set_play_codec(j, arg);
6299 retval = ixj_play_start(j);
6305 set_play_depth(j, arg);
6309 retval = get_play_volume(j);
6312 set_play_volume(j, arg);
6318 retval = get_play_volume_linear(j);
6321 set_play_volume_linear(j, arg);
6326 retval = get_play_level(j);
6365 ixj_set_tone_on(arg, j);
6368 ixj_set_tone_off(arg, j);
6371 if (ixj_get_tone_on(j)) {
6378 if (ixj_get_tone_off(j)) {
6386 retval = ixj_play_tone(j, arg);
6394 retval = j->
ex.
bits.dtmf_ready;
6397 if (ixj_hookstate(j)) {
6410 if (ixj_hookstate(j)) {
6471 retval = ixj_wink(j);
6480 int proto_size[] = {
6482 12, 10, 16, 9, 8, 48, 5,
6483 40, 40, 80, 40, 40, 6
6489 if(
pd.type<1 ||
pd.type>13) {
6494 val=proto_size[
pd.type];
6497 case 0xA0:val=2*proto_size[
pd.type];
break;
6498 case 0x50:val=proto_size[
pd.type];
break;
6499 default:val=proto_size[
pd.type]*3;
break;
6510 if ((arg & 0xff) == 0xff)
6511 retval = ixj_get_mixer(arg, j);
6519 retval = ixj_daa_write(j);
6523 retval = ixj_daa_write(j);
6526 DAA_Coeff_France(j);
6527 retval = ixj_daa_write(j);
6530 DAA_Coeff_Germany(j);
6531 retval = ixj_daa_write(j);
6534 DAA_Coeff_Australia(j);
6535 retval = ixj_daa_write(j);
6539 retval = ixj_daa_write(j);
6547 ixj_daa_cr4(j, arg | 0x02);
6550 retval = ixj_linetest(j);
6553 ixj_write_vmwi(j, arg);
6558 j->
ex.
bits.caller_id = 0;
6565 retval = ixj_set_port(j, arg);
6570 retval = ixj_set_pots(j, arg);
6588 retval = capabilities_check(j, &
cap);
6593 daa_set_mode(j, arg);
6597 j->
ex.
bits.pstn_ring = 0;
6603 retval = ixj_init_filter(j, &jf);
6609 retval = ixj_init_filter_raw(j, &jfr);
6621 retval = ixj_init_tone(j, &ti);
6624 retval = ixj_build_cadence(j, argp);
6627 retval = ixj_build_filter_cadence(j, argp);
6647 if(arg < 0 || arg >= IXJMAX)
6654 ixj_record_stop(
get_ixj(arg));
6659 if(arg < 0 || arg >= IXJMAX)
6662 ixj_record_start(j);
6664 get_ixj(arg)->intercom = board;
6666 ixj_record_start(
get_ixj(arg));
6669 if (ixjdebug & 0x0040)
6670 printk(
"phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
6675 static long ixj_ioctl(
struct file *file_p,
unsigned int cmd,
unsigned long arg)
6679 ret = do_ixj_ioctl(file_p, cmd, arg);
6684 static int ixj_fasync(
int fd,
struct file *file_p,
int mode)
6694 .read = ixj_enhanced_read,
6695 .write = ixj_enhanced_write,
6697 .unlocked_ioctl = ixj_ioctl,
6698 .release = ixj_release,
6699 .fasync = ixj_fasync,
6703 static int ixj_linetest(
IXJ *j)
6724 LED_SetState(0x4, j);
6740 LED_SetState(0x4, j);
6745 LED_SetState(0x8, j);
6766 LED_SetState(0xA, j);
6768 LED_SetState(0x6, j);
6772 LED_SetState(0x9, j);
6774 LED_SetState(0x5, j);
6781 static int ixj_selfprobe(
IXJ *j)
6793 if (ixjdebug & 0x0002)
6795 ixj_WriteDSPCommand(0x0FE0, j);
6797 if (ixj_WriteDSPCommand(0x0000, j))
6802 if (ixjdebug & 0x0002)
6804 if (ixj_WriteDSPCommand(0x3400, j))
6808 if (ixjdebug & 0x0002)
6810 if (ixj_WriteDSPCommand(0x3800, j))
6815 if (j->
dsp.
low == 0x21) {
6838 }
else if (j->
dsp.
low == 0x22) {
6848 if (!j->
dsp.
low != 0x20) {
6851 ixj_WriteDSPCommand(0x3800, j);
6876 if (ixjdebug & 0x0002)
6877 printk(
KERN_INFO "Write CODEC config to Software Control Register\n");
6878 if (ixj_WriteDSPCommand(0xC462, j))
6880 if (ixjdebug & 0x0002)
6881 printk(
KERN_INFO "Write CODEC timing to Software Control Register\n");
6887 if (ixj_WriteDSPCommand(cmd, j))
6890 if (set_base_frame(j, 30) != 30)
6892 if (ixjdebug & 0x0002)
6893 printk(
KERN_INFO "Write CODEC config to Software Control Register\n");
6895 if (ixj_WriteDSPCommand(0xC528, j))
6899 if (ixj_WriteDSPCommand(0xC528, j))
6901 if (ixjdebug & 0x0002)
6908 if (j->
dsp.
low == 0x20) {
6909 if (ixjdebug & 0x0002)
6920 ixj_WriteDSPCommand(j->
gpio.
word, j);
6921 if (ixjdebug & 0x0002)
6928 ixj_WriteDSPCommand(j->
gpio.
word, j);
6932 LED_SetState(0x1, j);
6934 LED_SetState(0x2, j);
6936 LED_SetState(0x4, j);
6938 LED_SetState(0x8, j);
6940 LED_SetState(0x0, j);
6942 if (ixjdebug & 0x0002)
6943 printk(
"Loading DAA Coefficients\n");
6945 if (!ixj_daa_write(j)) {
6946 printk(
"DAA write failed on board %d\n", j->
board);
6949 if(!ixj_daa_cid_reset(j)) {
6950 printk(
"DAA CID reset failed on board %d\n", j->
board);
6969 if (ixjdebug & 0x0002)
6971 ixj_mixer(0x0000, j);
6972 ixj_mixer(0x0100, j);
6974 ixj_mixer(0x0203, j);
6975 ixj_mixer(0x0303, j);
6977 ixj_mixer(0x0480, j);
6978 ixj_mixer(0x0580, j);
6980 ixj_mixer(0x0680, j);
6981 ixj_mixer(0x0780, j);
6983 ixj_mixer(0x0880, j);
6984 ixj_mixer(0x0980, j);
6986 ixj_mixer(0x0A80, j);
6987 ixj_mixer(0x0B80, j);
6989 ixj_mixer(0x0C00, j);
6990 ixj_mixer(0x0D80, j);
6992 ixj_mixer(0x0E80, j);
6994 ixj_mixer(0x0F00, j);
6996 ixj_mixer(0x1000, j);
6997 ixj_mixer(0x110C, j);
7000 ixj_mixer(0x1200, j);
7001 ixj_mixer(0x1401, j);
7003 ixj_mixer(0x1300, j);
7004 ixj_mixer(0x1501, j);
7006 ixj_mixer(0x1700, j);
7008 ixj_mixer(0x1800, j);
7010 ixj_mixer(0x1901, j);
7012 if (ixjdebug & 0x0002)
7025 ixj_WriteDSPCommand(0xCF07, j);
7026 ixj_WriteDSPCommand(0x00B0, j);
7043 set_dtmf_prescale(j, 0x10);
7045 set_dtmf_prescale(j, 0x40);
7047 set_play_volume(j, 0x100);
7048 set_rec_volume(j, 0x100);
7050 if (ixj_WriteDSPCommand(0x0000, j))
7056 if (ixjdebug & 0x0002)
7059 if (ixjdebug & 0x0002)
7062 if (ixj_WriteDSPCommand(0x7E01, j))
7065 if (ixjdebug & 0x002)
7068 if (ixj_WriteDSPCommand(0x5151, j))
7071 if (ixj_WriteDSPCommand(0x6E01, j))
7074 set_rec_depth(j, 2);
7076 set_play_depth(j, 2);
7078 j->
ex.
bits.dtmf_ready = 0;
7088 for (cnt = 0; cnt < 4; cnt++)
7091 ixj_WriteDSPCommand(0x0FE3, j);
7094 for (cnt = 0; cnt < 35; cnt++)
7101 #ifdef IXJ_DYN_ALLOC
7108 j->
p.f_op = &ixj_fops;
7109 j->
p.open = ixj_open;
7124 IXJ *j = ixj_alloc();
7137 static int ixj_get_status_proc(
char *buf)
7144 len +=
sprintf(buf + len,
"\nsizeof IXJ struct %Zd bytes",
sizeof(
IXJ));
7145 len +=
sprintf(buf + len,
"\nsizeof DAA struct %Zd bytes",
sizeof(
DAA_REGS));
7146 len +=
sprintf(buf + len,
"\nUsing old telephony API");
7147 len +=
sprintf(buf + len,
"\nDebug Level %d\n", ixjdebug);
7149 for (cnt = 0; cnt <
IXJMAX; cnt++) {
7154 len +=
sprintf(buf + len,
"\nCard Num %d", cnt);
7155 len +=
sprintf(buf + len,
"\nDSP Base Address 0x%4.4x", j->
DSPbase);
7160 len +=
sprintf(buf + len,
"\nSerial Number %8.8x", j->
serial);
7163 len +=
sprintf(buf + len,
"\nCard Type = Internet PhoneJACK");
7166 len +=
sprintf(buf + len,
"\nCard Type = Internet LineJACK");
7168 len +=
sprintf(buf + len,
" w/G.729 A/B");
7172 len +=
sprintf(buf + len,
"\nCard Type = Internet PhoneJACK Lite");
7174 len +=
sprintf(buf + len,
" w/G.729 A/B");
7177 len +=
sprintf(buf + len,
"\nCard Type = Internet PhoneJACK PCI");
7179 len +=
sprintf(buf + len,
" w/G.729 A/B");
7182 len +=
sprintf(buf + len,
"\nCard Type = Internet PhoneCARD");
7184 len +=
sprintf(buf + len,
" w/G.729 A/B");
7197 len +=
sprintf(buf + len,
"\nCapabilities %d", j->
caps);
7201 len +=
sprintf(buf + len,
"\nCaller ID data sent");
7203 len +=
sprintf(buf + len,
"\nCaller ID data not sent");
7205 len +=
sprintf(buf + len,
"\nPlay CODEC ");
7208 len +=
sprintf(buf + len,
"G.723.1 6.3");
7211 len +=
sprintf(buf + len,
"G.723.1 5.3");
7214 len +=
sprintf(buf + len,
"TrueSpeech 8.5");
7217 len +=
sprintf(buf + len,
"TrueSpeech 4.8");
7220 len +=
sprintf(buf + len,
"TrueSpeech 4.1");
7223 len +=
sprintf(buf + len,
"G.728");
7226 len +=
sprintf(buf + len,
"G.729");
7229 len +=
sprintf(buf + len,
"G.729B");
7232 len +=
sprintf(buf + len,
"uLaw");
7235 len +=
sprintf(buf + len,
"aLaw");
7238 len +=
sprintf(buf + len,
"16 bit Linear");
7241 len +=
sprintf(buf + len,
"8 bit Linear");
7244 len +=
sprintf(buf + len,
"Windows Sound System");
7247 len +=
sprintf(buf + len,
"NO CODEC CHOSEN");
7250 len +=
sprintf(buf + len,
"\nRecord CODEC ");
7253 len +=
sprintf(buf + len,
"G.723.1 6.3");
7256 len +=
sprintf(buf + len,
"G.723.1 5.3");
7259 len +=
sprintf(buf + len,
"TrueSpeech 8.5");
7262 len +=
sprintf(buf + len,
"TrueSpeech 4.8");
7265 len +=
sprintf(buf + len,
"TrueSpeech 4.1");
7268 len +=
sprintf(buf + len,
"G.728");
7271 len +=
sprintf(buf + len,
"G.729");
7274 len +=
sprintf(buf + len,
"G.729B");
7277 len +=
sprintf(buf + len,
"uLaw");
7280 len +=
sprintf(buf + len,
"aLaw");
7283 len +=
sprintf(buf + len,
"16 bit Linear");
7286 len +=
sprintf(buf + len,
"8 bit Linear");
7289 len +=
sprintf(buf + len,
"Windows Sound System");
7292 len +=
sprintf(buf + len,
"NO CODEC CHOSEN");
7295 len +=
sprintf(buf + len,
"\nAEC ");
7298 len +=
sprintf(buf + len,
"Off");
7301 len +=
sprintf(buf + len,
"Low");
7304 len +=
sprintf(buf + len,
"Med");
7307 len +=
sprintf(buf + len,
"High");
7310 len +=
sprintf(buf + len,
"Auto");
7313 len +=
sprintf(buf + len,
"AEC/AGC");
7320 len +=
sprintf(buf + len,
"\nRec volume 0x%x", get_rec_volume(j));
7321 len +=
sprintf(buf + len,
"\nPlay volume 0x%x", get_play_volume(j));
7322 len +=
sprintf(buf + len,
"\nDTMF prescale 0x%x", get_dtmf_prescale(j));
7333 len +=
sprintf(buf + len,
"\nDAA PSTN On Hook");
7336 len +=
sprintf(buf + len,
"\nDAA PSTN Ringing");
7340 len +=
sprintf(buf + len,
"\nDAA PSTN Off Hook");
7343 len +=
sprintf(buf + len,
"\nDAA PSTN Pulse Dialing");
7359 len +=
sprintf(buf + len,
"\nPort POTS");
7362 len +=
sprintf(buf + len,
"\nPort PSTN");
7365 len +=
sprintf(buf + len,
"\nPort SPEAKER/MIC");
7368 len +=
sprintf(buf + len,
"\nPort HANDSET");
7372 len +=
sprintf(buf + len,
"\nSLIC state ");
7373 switch (SLIC_GetState(j)) {
7375 len +=
sprintf(buf + len,
"OC");
7378 len +=
sprintf(buf + len,
"RINGING");
7381 len +=
sprintf(buf + len,
"ACTIVE");
7384 len +=
sprintf(buf + len,
"OHT");
7387 len +=
sprintf(buf + len,
"TIPOPEN");
7390 len +=
sprintf(buf + len,
"STANDBY");
7393 len +=
sprintf(buf + len,
"APR");
7396 len +=
sprintf(buf + len,
"OHTPR");
7399 len +=
sprintf(buf + len,
"%d", SLIC_GetState(j));
7405 #ifdef PERFMON_STATS
7422 len +=
sprintf(buf + len,
"\n");
7429 int count,
int *eof,
void *
data)
7431 int len = ixj_get_status_proc(page);
7432 if (len <= off+count) *eof = 1;
7433 *start = page + off;
7435 if (len>count) len =
count;
7441 static void cleanup(
void)
7446 for (cnt = 0; cnt <
IXJMAX; cnt++) {
7449 if (ixjdebug & 0x0002)
7460 LED_SetState(0x0, j);
7461 if (ixjdebug & 0x0002)
7462 printk(
KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
7465 if (ixjdebug & 0x0002)
7466 printk(
KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
7473 if (ixjdebug & 0x0002)
7474 printk(
KERN_INFO "IXJ: Unregistering /dev/phone%d from LTAPI\n", cnt);
7476 if (ixjdebug & 0x0002)
7477 printk(
KERN_INFO "IXJ: Releasing DSP address for /dev/phone%d\n", cnt);
7479 #ifdef IXJ_DYN_ALLOC
7480 if (ixjdebug & 0x0002)
7487 if (ixjdebug & 0x0002)
7498 static void PCIEE_WriteBit(
WORD wEEPROMAddress,
BYTE lastLCC,
BYTE byData)
7500 lastLCC = lastLCC & 0xfb;
7501 lastLCC = lastLCC | (byData ? 4 : 0);
7502 outb(lastLCC, wEEPROMAddress);
7505 lastLCC = lastLCC | 0x01;
7506 outb(lastLCC, wEEPROMAddress);
7508 byData = byData << 1;
7509 lastLCC = lastLCC & 0xfe;
7511 outb(lastLCC, wEEPROMAddress);
7515 static BYTE PCIEE_ReadBit(
WORD wEEPROMAddress,
BYTE lastLCC)
7518 lastLCC = lastLCC | 0x01;
7519 outb(lastLCC, wEEPROMAddress);
7521 lastLCC = lastLCC & 0xfe;
7523 outb(lastLCC, wEEPROMAddress);
7525 return ((
inb(wEEPROMAddress) >> 3) & 1);
7528 static bool PCIEE_ReadWord(
WORD wAddress,
WORD wLoc,
WORD * pwResult)
7531 WORD wEEPROMAddress = wAddress + 3;
7535 lastLCC =
inb(wEEPROMAddress);
7536 lastLCC = lastLCC | 0x02;
7537 lastLCC = lastLCC & 0xfe;
7538 outb(lastLCC, wEEPROMAddress);
7542 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
7543 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 1);
7544 PCIEE_WriteBit(wEEPROMAddress, lastLCC, 0);
7545 for (i = 0; i < 8; i++) {
7546 PCIEE_WriteBit(wEEPROMAddress, lastLCC, wLoc & 0x80 ? 1 : 0);
7550 for (i = 0; i < 16; i++) {
7551 byResult = PCIEE_ReadBit(wEEPROMAddress, lastLCC);
7552 *pwResult = (*pwResult << 1) | byResult;
7557 lastLCC = lastLCC & 0xfd;
7558 outb(lastLCC, wEEPROMAddress);
7563 static DWORD PCIEE_GetSerialNumber(
WORD wAddress)
7566 if (PCIEE_ReadWord(wAddress, 62, &wLo))
7568 if (PCIEE_ReadWord(wAddress, 63, &wHi))
7570 return (((
DWORD) wHi << 16) | wLo);
7573 static int dspio[IXJMAX + 1] =
7577 static int xio[IXJMAX + 1] =
7588 static void __exit ixj_exit(
void)
7593 static IXJ *new_ixj(
unsigned long port)
7610 static int __init ixj_probe_isapnp(
int *cnt)
7624 if (!dev || !dev->
card)
7628 printk(
"pnp attach failed %d \n", result);
7632 printk(
"pnp activate failed (out of resources?)\n");
7637 if (!pnp_port_valid(dev, 0)) {
7642 j = new_ixj(pnp_port_start(dev, 0));
7661 probe = ixj_selfprobe(j);
7690 static int __init ixj_probe_isa(
int *cnt)
7695 for (i = 0; i <
IXJMAX; i++) {
7697 IXJ *j = new_ixj(dspio[i]);
7706 probe = ixj_selfprobe(j);
7714 static int __init ixj_probe_pci(
int *cnt)
7720 for (i = 0; i < IXJMAX - *
cnt; i++) {
7736 probe = ixj_selfprobe(j);
7745 static int __init ixj_init(
void)
7753 if ((probe = ixj_probe_isapnp(&cnt)) < 0) {
7756 if ((probe = ixj_probe_isa(&cnt)) < 0) {
7759 if ((probe = ixj_probe_pci(&cnt)) < 0) {
7763 create_proc_read_entry (
"ixj", 0,
NULL, ixj_read_proc,
NULL);
7770 static void DAA_Coeff_US(
IXJ *j)
7980 static void DAA_Coeff_UK(
IXJ *j)
8160 static void DAA_Coeff_France(
IXJ *j)
8340 static void DAA_Coeff_Germany(
IXJ *j)
8520 static void DAA_Coeff_Australia(
IXJ *j)
8700 static void DAA_Coeff_Japan(
IXJ *j)
8879 static s16 tone_table[][19] =
10441 unsigned short cmd;
10447 if (ixj_WriteDSPCommand(0x5154 + jf->
filter, j))
10451 if (ixj_WriteDSPCommand(0x5152, j))
10457 if (ixj_WriteDSPCommand(0x5153, j))
10461 if (ixj_WriteDSPCommand(0x5154 + jf->
filter, j))
10464 if (jf->
freq < 12 && jf->
freq > 3) {
10466 if (ixj_WriteDSPCommand(0x5170 + jf->
freq, j))
10468 }
else if (jf->
freq > 11) {
10474 if (ixj_WriteDSPCommand(0x5170 + jf->
filter, j))
10476 if (j->
ver.
low != 0x12) {
10483 if (ixj_WriteDSPCommand(cmd, j))
10485 for (cnt = 0; cnt <
max; cnt++) {
10486 if (ixj_WriteDSPCommand(tone_table[jf->
freq - 12][cnt], j))
10496 unsigned short cmd;
10501 if (ixj_WriteDSPCommand(0x5154 + jfr->
filter, j))
10505 if (ixj_WriteDSPCommand(0x5152, j))
10510 if (ixj_WriteDSPCommand(0x5153, j))
10513 if (ixj_WriteDSPCommand(0x5154 + jfr->
filter, j))
10521 if (ixj_WriteDSPCommand(0x5170 + jfr->
filter, j))
10523 if (j->
ver.
low != 0x12) {
10530 if (ixj_WriteDSPCommand(cmd, j))
10532 for (cnt = 0; cnt <
max; cnt++) {
10533 if (ixj_WriteDSPCommand(jfr->
coeff[cnt], j))
10543 unsigned short data;
10558 if (ixj_WriteDSPCommand(0x6800 + ti->
tone_index, j))
10560 if (ixj_WriteDSPCommand(0x6000 + (ti->
gain1 << 4) + ti->
gain0, j))
10563 if (ixj_WriteDSPCommand(data, j))
10566 if (ixj_WriteDSPCommand(data, j))