📄 ixj.c
字号:
j->gpio.bytes.low = 0x00; j->gpio.bits.gpio1 = 1; j->gpio.bits.gpio2 = 1; j->gpio.bits.gpio5 = 0; ixj_WriteDSPCommand(j->gpio.word, board); /* send the ring signal */ } else // Internet LineJACK, Internet PhoneJACK Lite or Internet PhoneJACK PCI { if (ixjdebug > 0) printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", board); SLIC_SetState(PLD_SLIC_STATE_RINGING, board); }}static int ixj_pcmcia_cable_check(int board){ IXJ *j = &ixj[board]; j->pccr1.byte = inb_p(j->XILINXbase + 0x03); if (!j->flags.pcmciastate) { j->pccr2.byte = inb_p(j->XILINXbase + 0x02); if (j->pccr1.bits.drf || j->pccr2.bits.rstc) { j->flags.pcmciastate = 4; return 0; } if (j->pccr1.bits.ed) { j->pccr1.bits.ed = 0; j->psccr.bits.dev = 3; j->psccr.bits.rw = 1; outw_p(j->psccr.byte << 8, j->XILINXbase + 0x00); ixj_PCcontrol_wait(board); j->pslic.byte = inw_p(j->XILINXbase + 0x00) & 0xFF; j->pslic.bits.led2 = j->pslic.bits.det ? 1 : 0; j->psccr.bits.dev = 3; j->psccr.bits.rw = 0; outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00); ixj_PCcontrol_wait(board); return j->pslic.bits.led2 ? 1 : 0; } else if (j->flags.pcmciasct) { return j->r_hook; } else { return 1; } } else if (j->flags.pcmciastate == 4) { if (!j->pccr1.bits.drf) { j->flags.pcmciastate = 3; } return 0; } else if (j->flags.pcmciastate == 3) { j->pccr2.bits.pwr = 0; j->pccr2.bits.rstc = 1; outb_p(j->pccr2.byte, j->XILINXbase + 0x02); j->checkwait = jiffies + hertz * 2; j->flags.incheck = 1; j->flags.pcmciastate = 2; return 0; } else if (j->flags.pcmciastate == 2) { if (j->flags.incheck) { if (time_before(jiffies, j->checkwait)) { return 0; } else { j->flags.incheck = 0; } } j->pccr2.bits.pwr = 0; j->pccr2.bits.rstc = 0; outb_p(j->pccr2.byte, j->XILINXbase + 0x02); j->flags.pcmciastate = 1; return 0; } else if (j->flags.pcmciastate == 1) { j->flags.pcmciastate = 0; if (!j->pccr1.bits.drf) { j->psccr.bits.dev = 3; j->psccr.bits.rw = 1; outb_p(j->psccr.byte, j->XILINXbase + 0x01); ixj_PCcontrol_wait(board); j->flags.pcmciascp = 1; // Set Cable Present Flag j->flags.pcmciasct = (inw_p(j->XILINXbase + 0x00) >> 8) & 0x03; // Get Cable Type if (j->flags.pcmciasct == 3) { j->flags.pcmciastate = 4; return 0; } else if (j->flags.pcmciasct == 0) { j->pccr2.bits.pwr = 1; j->pccr2.bits.rstc = 0; outb_p(j->pccr2.byte, j->XILINXbase + 0x02); j->port = PORT_SPEAKER; } else { j->port = PORT_POTS; } j->sic1.bits.cpd = 0; // Chip Power Down j->sic1.bits.mpd = 0; // MIC Bias Power Down j->sic1.bits.hpd = 0; // Handset Bias Power Down j->sic1.bits.lpd = 0; // Line Bias Power Down j->sic1.bits.spd = 1; // Speaker Drive Power Down j->psccr.bits.addr = 1; // R/W Smart Cable Register Address j->psccr.bits.rw = 0; // Read / Write flag j->psccr.bits.dev = 0; outb(j->sic1.byte, j->XILINXbase + 0x00); outb(j->psccr.byte, j->XILINXbase + 0x01); ixj_PCcontrol_wait(board); j->sic2.bits.al = 0; // Analog Loopback DAC analog -> ADC analog j->sic2.bits.dl2 = 0; // Digital Loopback DAC -> ADC one bit j->sic2.bits.dl1 = 0; // Digital Loopback ADC -> DAC one bit j->sic2.bits.pll = 0; // 1 = div 10, 0 = div 5 j->sic2.bits.hpd = 0; // HPF disable j->psccr.bits.addr = 2; // R/W Smart Cable Register Address j->psccr.bits.rw = 0; // Read / Write flag j->psccr.bits.dev = 0; outb(j->sic2.byte, j->XILINXbase + 0x00); outb(j->psccr.byte, j->XILINXbase + 0x01); ixj_PCcontrol_wait(board); j->psccr.bits.addr = 3; // R/W Smart Cable Register Address j->psccr.bits.rw = 0; // Read / Write flag j->psccr.bits.dev = 0; outb(0x00, j->XILINXbase + 0x00); // PLL Divide N1 outb(j->psccr.byte, j->XILINXbase + 0x01); ixj_PCcontrol_wait(board); j->psccr.bits.addr = 4; // R/W Smart Cable Register Address j->psccr.bits.rw = 0; // Read / Write flag j->psccr.bits.dev = 0; outb(0x09, j->XILINXbase + 0x00); // PLL Multiply M1 outb(j->psccr.byte, j->XILINXbase + 0x01); ixj_PCcontrol_wait(board); j->sirxg.bits.lig = 1; // Line In Gain j->sirxg.bits.lim = 1; // Line In Mute j->sirxg.bits.mcg = 0; // MIC In Gain // was 3 j->sirxg.bits.mcm = 0; // MIC In Mute j->sirxg.bits.him = 0; // Handset In Mute j->sirxg.bits.iir = 1; // IIR j->psccr.bits.addr = 5; // R/W Smart Cable Register Address j->psccr.bits.rw = 0; // Read / Write flag j->psccr.bits.dev = 0; outb(j->sirxg.byte, j->XILINXbase + 0x00); outb(j->psccr.byte, j->XILINXbase + 0x01); ixj_PCcontrol_wait(board); j->siadc.bits.hom = 0; // Handset Out Mute j->siadc.bits.lom = 0; // Line Out Mute j->siadc.bits.rxg = 23; //(0xC000 - 0x41C8) / 0x4EF; // RX PGA Gain j->psccr.bits.addr = 6; // R/W Smart Cable Register Address j->psccr.bits.rw = 0; // Read / Write flag j->psccr.bits.dev = 0; outb(j->siadc.byte, j->XILINXbase + 0x00); outb(j->psccr.byte, j->XILINXbase + 0x01); ixj_PCcontrol_wait(board); j->sidac.bits.srm = 1; // Speaker Right Mute j->sidac.bits.slm = 1; // Speaker Left Mute j->sidac.bits.txg = (0xC000 - 0x45E4) / 0x5D3; // TX PGA Gain j->psccr.bits.addr = 7; // R/W Smart Cable Register Address j->psccr.bits.rw = 0; // Read / Write flag j->psccr.bits.dev = 0; outb(j->sidac.byte, j->XILINXbase + 0x00); outb(j->psccr.byte, j->XILINXbase + 0x01); ixj_PCcontrol_wait(board); j->siaatt.bits.sot = 0; j->psccr.bits.addr = 9; // R/W Smart Cable Register Address j->psccr.bits.rw = 0; // Read / Write flag j->psccr.bits.dev = 0; outb(j->siaatt.byte, j->XILINXbase + 0x00); outb(j->psccr.byte, j->XILINXbase + 0x01); ixj_PCcontrol_wait(board); if (j->flags.pcmciasct == 1 && !j->readers && !j->writers) { j->psccr.byte = j->pslic.byte = 0; j->pslic.bits.powerdown = 1; j->psccr.bits.dev = 3; j->psccr.bits.rw = 0; outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00); ixj_PCcontrol_wait(board); } } return 0; } else { j->flags.pcmciascp = 0; return 0; } return 0;}static int ixj_hookstate(int board){ unsigned long det; IXJ *j = &ixj[board]; int fOffHook = 0; switch (j->cardtype) { case 100: ixj_gpio_read(board); fOffHook = j->gpio.bits.gpio3read ? 1 : 0; break; case 300: case 400: case 500: SLIC_GetState(board); if (j->pld_slicr.bits.state == PLD_SLIC_STATE_ACTIVE || j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) { if (j->flags.ringing) { if (!in_interrupt()) { det = jiffies + (hertz / 50); while (time_before(jiffies, det)) { set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); } } SLIC_GetState(board); if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) { ixj_ring_on(board); } } if (j->cardtype == 500) { j->pld_scrr.byte = inb_p(j->XILINXbase); fOffHook = j->pld_scrr.pcib.det ? 1 : 0; } else fOffHook = j->pld_slicr.bits.det ? 1 : 0; } break; case 600: fOffHook = ixj_pcmcia_cable_check(board); break; } if (j->r_hook != fOffHook) { j->r_hook = fOffHook; if (j->port != PORT_POTS) { j->ex.bits.hookstate = 1; ixj_kill_fasync(board, POLL_IN); } else if (!fOffHook) { j->flash_end = jiffies + (hertz / 10 * 6); } } if (j->port == PORT_PSTN && j->daa_mode == SOP_PU_CONVERSATION) fOffHook |= 2; if (j->port == PORT_SPEAKER) fOffHook |= 2; if (j->port == PORT_HANDSET) fOffHook |= 2; if (fOffHook && time_before(jiffies, j->flash_end)) return 0; else return fOffHook;}static void ixj_ring_off(board){ IXJ *j = &ixj[board]; if (j->dsp.low == 0x20) // Internet PhoneJACK { if (ixjdebug > 0) printk(KERN_INFO "IXJ Ring Off\n"); j->gpio.bytes.high = 0x0B; j->gpio.bytes.low = 0x00; j->gpio.bits.gpio1 = 0; j->gpio.bits.gpio2 = 1; j->gpio.bits.gpio5 = 0; ixj_WriteDSPCommand(j->gpio.word, board); } else // Internet LineJACK { if (ixjdebug > 0) printk(KERN_INFO "IXJ Ring Off\n"); SLIC_SetState(PLD_SLIC_STATE_STANDBY, board); SLIC_GetState(board); }}static void ixj_ring_start(int board){ IXJ *j = &ixj[board]; j->flags.cringing = 1; if (ixj_hookstate(board) & 1) { if (j->port == PORT_POTS) ixj_ring_off(board); j->flags.cringing = 0; } else { j->ring_cadence_jif = jiffies; j->ring_cadence_t = 15; if (j->ring_cadence & 1 << j->ring_cadence_t) { ixj_ring_on(board); } else { ixj_ring_off(board); } }}static int ixj_ring(int board){ char cntr; unsigned long jif, det; IXJ *j = &ixj[board]; j->flags.ringing = 1; if (ixj_hookstate(board) & 1) { ixj_ring_off(board); j->flags.ringing = 0; return 1; } det = 0; for (cntr = 0; cntr < j->maxrings; cntr++) { jif = jiffies + (1 * hertz); ixj_ring_on(board); while (time_before(jiffies, jif)) { if (ixj_hookstate(board) & 1) { ixj_ring_off(board); j->flags.ringing = 0; return 1; } set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); if (signal_pending(current)) break; } jif = jiffies + (3 * hertz); ixj_ring_off(board); while (time_before(jiffies, jif)) { if (ixj_hookstate(board) & 1) { det = jiffies + (hertz / 100); while (time_before(jiffies, det)) { set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); if (signal_pending(current)) break; } if (ixj_hookstate(board) & 1) { j->flags.ringing = 0; return 1; } } set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); if (signal_pending(current)) break; } } ixj_ring_off(board); j->flags.ringing = 0; return 0;}int ixj_open(struct phone_device *p, struct file *file_p){ IXJ *j = file_p->private_data = &ixj[p->board]; if (!j->DSPbase) return -ENODEV; if (file_p->f_mode & FMODE_READ) { if(!j->readers) { j->readers++; } else { return -EBUSY; } } if (file_p->f_mode & FMODE_WRITE) { if(!j->writers) { j->writers++; } else { if (file_p->f_mode & FMODE_READ){ j->readers--; } return -EBUSY; } } if (j->cardtype == 600) { j->pslic.bits.powerdown = 0; j->psccr.bits.dev = 3; j->psccr.bits.rw = 0; outw_p(j->psccr.byte << 8 | j->pslic.byte, j->XILINXbase + 0x00); ixj_PCcontrol_wait(p->board); } MOD_INC_USE_COUNT; if (ixjdebug > 0) printk(KERN_INFO "Opening board %d\n", p->board); j->framesread = j->frameswritten = 0; return 0;}int ixj_release(struct inode *inode, struct file *file_p){ IXJ_TONE ti;// int board = NUM(inode->i_rdev); IXJ *j = file_p->private_data; int board = j->p.board;// IXJ *j = &ixj[board]; if (ixjdebug > 0) printk(KERN_INFO "Closing board %d\n", NUM(inode->i_rdev)); daa_set_mode(board, SOP_PU_SLEEP); if (j->cardtype == 600) ixj_set_port(board, PORT_SPEAKER); else ixj_set_port(board, PORT_POTS); aec_stop(board); ixj_play_stop(board); ixj_record_stop(board); set_play_volume(board, 0x100); set_rec_volume(board, 0x100); ixj_ring_off(board); // Restore the tone table to default settings. ti.tone_index = 10; ti.gain0 = 1; ti.freq0 = hz941; ti.gain1 = 0; ti.freq1 = hz1209; ti.tone_index = 11; ti.gain0 = 1; ti.freq0 = hz941; ti.gain1 = 0; ti.freq1 = hz1336; ti.tone_index = 12; ti.gain0 = 1; ti.freq0 = hz941; ti.gain1 = 0; ti.freq1 = hz1477; ti.tone_index = 13; ti.gain0 = 1; ti.freq0 = hz800; ti.gain1 = 0; ti.freq1 = 0; ixj_init_tone(board, &ti); ti.tone_index = 14; ti.gain0 = 1; ti.freq0 = hz1000; ti.gain1 = 0; ti.freq1 = 0; ixj_init_tone(board, &ti); ti.tone_index = 15; ti.gain0 = 1; ti.freq0 = hz1250; ti.gain1 = 0; ti.freq1 = 0; ixj_init_tone(board, &ti); ti.tone_index = 16; ti.gain0 = 1; ti.freq0 = hz950; ti.gain1 = 0; ti.freq1 = 0; ixj_init_tone(board, &ti); ti.tone_index = 17; ti.gain0 = 1; ti.freq0 = hz1100; ti.gain1 = 0; ti.freq1 = 0; ixj_init_tone(board, &ti); ti.tone_index = 18; ti.gain0 = 1; ti.freq0 = hz1400; ti.gain1 = 0; ti.freq1 = 0; ixj_init_tone(board, &ti); ti.tone_index = 19; ti.gain0 = 1; ti.freq0 = hz1500; ti.gain1 = 0; ti.freq1 = 0; ixj_init_tone(board, &ti); ti.tone_index = 20;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -