📄 ixj.c
字号:
ixj_set_tone_off(j->cadence_t->ce[0].tone_off_time, board); ixj_play_tone(board, j->cadence_t->ce[0].index); break; } } else { if (j->cadence_t->ce[j->tone_cadence_state].gain0) { ti.tone_index = j->cadence_t->ce[j->tone_cadence_state].index; ti.freq0 = j->cadence_t->ce[j->tone_cadence_state].freq0; ti.gain0 = j->cadence_t->ce[j->tone_cadence_state].gain0; ti.freq1 = j->cadence_t->ce[j->tone_cadence_state].freq1; ti.gain1 = j->cadence_t->ce[j->tone_cadence_state].gain1; ixj_init_tone(board, &ti); } ixj_set_tone_on(j->cadence_t->ce[j->tone_cadence_state].tone_on_time, board); ixj_set_tone_off(j->cadence_t->ce[j->tone_cadence_state].tone_off_time, board); ixj_play_tone(board, j->cadence_t->ce[j->tone_cadence_state].index); } } }}extern __inline__ void ixj_kill_fasync(int board, int dir){ kill_fasync(&ixj[board].async_queue, SIGIO, dir); // Send apps notice of change}static void ixj_timeout(unsigned long ptr){ int board; unsigned long jifon; IXJ *j; for (board = 0; board < IXJMAX; board++) { j = &ixj[board]; if (j->DSPbase) {#ifdef PERFMON_STATS j->timerchecks++;#endif if (j->tone_state) { if (!ixj_hookstate(board)) { ixj_cpt_stop(board); if (j->m_hook) { j->m_hook = 0; j->ex.bits.hookstate = 1; ixj_kill_fasync(board, POLL_IN); } continue; } if (j->tone_state == 1) jifon = (hertz * j->tone_on_time * 25 / 100000); else jifon = (hertz * j->tone_on_time * 25 / 100000) + (hertz * j->tone_off_time * 25 / 100000); if (time_before(jiffies, j->tone_start_jif + jifon)) { if (j->tone_state == 1) { ixj_play_tone(board, j->tone_index); if (j->dsp.low == 0x20) { continue; } } else { ixj_play_tone(board, 0); if (j->dsp.low == 0x20) { continue; } } } else { ixj_tone_timeout(board); if (j->flags.dialtone) { ixj_dialtone(board); } if (j->flags.busytone) { ixj_busytone(board); if (j->dsp.low == 0x20) { continue; } } if (j->flags.ringback) { ixj_ringback(board); if (j->dsp.low == 0x20) { continue; } } if (!j->tone_state) { if (j->dsp.low == 0x20 || (j->play_mode == -1 && j->rec_mode == -1)) idle(board); if (j->dsp.low == 0x20 && j->play_mode != -1) ixj_play_start(board); if (j->dsp.low == 0x20 && j->rec_mode != -1) ixj_record_start(board); } } } if (!j->tone_state || j->dsp.low != 0x20) { if (IsRxReady(board)) { ixj_read_frame(board); } if (IsTxReady(board) && !j->flags.cidplay) { ixj_write_frame(board); } } if (j->flags.cringing) { if (ixj_hookstate(board) & 1) { j->flags.cringing = 0; ixj_ring_off(board); } else { if (jiffies - j->ring_cadence_jif >= (hertz/2)) { if (j->flags.cidring && !j->flags.cidsent) { j->flags.cidsent = 1; ixj_write_cid(board); j->flags.cidring = 0; } j->ring_cadence_t--; if (j->ring_cadence_t == -1) j->ring_cadence_t = 15; j->ring_cadence_jif = jiffies; } if (j->ring_cadence & 1 << j->ring_cadence_t) { ixj_ring_on(board); } else { ixj_ring_off(board); j->flags.cidring = 1; } continue; } } if (!j->flags.ringing) { if (ixj_hookstate(board)) { if (j->dsp.low != 0x20 && SLIC_GetState(board) != PLD_SLIC_STATE_ACTIVE) { SLIC_SetState(PLD_SLIC_STATE_ACTIVE, board); } LineMonitor(board); read_filters(board); ixj_WriteDSPCommand(0x511B, board); j->proc_load = j->ssr.high << 8 | j->ssr.low; if (!j->m_hook) { j->m_hook = j->ex.bits.hookstate = 1; ixj_kill_fasync(board, POLL_IN); } } else { if (j->dsp.low != 0x20 && SLIC_GetState(board) == PLD_SLIC_STATE_ACTIVE) // Internet LineJACK { SLIC_SetState(PLD_SLIC_STATE_STANDBY, board); } if (j->ex.bits.dtmf_ready) { j->dtmf_wp = j->dtmf_rp = j->ex.bits.dtmf_ready = 0; } if (j->m_hook) { j->m_hook = 0; j->ex.bits.hookstate = 1; ixj_kill_fasync(board, POLL_IN); } } } if (j->cardtype == 300 && !j->flags.incheck) { if (j->flags.pstn_present) { j->pld_scrr.byte = inb_p(j->XILINXbase); if (j->pld_scrr.bits.daaflag) { daa_int_read(board); if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.RING) { if (!j->flags.pstn_ringing) { j->flags.pstn_ringing = 1; if (j->daa_mode != SOP_PU_RINGING) daa_set_mode(board, SOP_PU_RINGING); } } if (time_after(jiffies, j->pstn_sleeptil) && j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) { j->pstn_winkstart = 0; j->pstn_ring_stop = 0; ixj[board].pld_scrw.bits.led1 = 1; if (j->flags.pstn_ringing && !j->pstn_envelope) { if (j->daa_mode != SOP_PU_RINGING) { j->flags.pstn_ringing = 0; } else { ixj[board].pld_scrw.bits.led2 = 0; j->pstn_envelope = 1; j->pstn_ring_start = jiffies; j->pstn_ring_stop = 0; } j->ex.bits.pstn_ring = 0; } outb_p(ixj[board].pld_scrw.byte, ixj[board].XILINXbase); } else { ixj[board].pld_scrw.bits.led1 = 0; ixj[board].pld_scrw.bits.led2 = 1; outb_p(ixj[board].pld_scrw.byte, ixj[board].XILINXbase); if (j->flags.pstn_ringing && j->pstn_envelope) { if(!j->pstn_ring_stop) { j->pstn_ring_stop = jiffies; } else if (time_after(jiffies, j->pstn_ring_stop + ((hertz * 5) / 100))){ j->pstn_ring_stop = 0; j->ex.bits.pstn_ring = 1; j->pstn_envelope = 0; } } else if (j->daa_mode == SOP_PU_CONVERSATION) { if (!j->pstn_winkstart) { j->pstn_winkstart = jiffies; } else if (time_after(jiffies, j->pstn_winkstart + (hertz * j->winktime / 1000))) { daa_set_mode(board, SOP_PU_SLEEP); j->pstn_winkstart = 0; j->ex.bits.pstn_wink = 1; } } else { j->ex.bits.pstn_ring = 0; } } if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Cadence) { if (j->daa_mode == SOP_PU_RINGING) { daa_set_mode(board, SOP_PU_SLEEP); j->flags.pstn_ringing = 0; j->ex.bits.pstn_ring = 0; } } if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.Caller_ID) { if (j->daa_mode == SOP_PU_RINGING && j->flags.pstn_ringing) { j->pstn_cid_intr = 1; j->pstn_cid_received = jiffies; } } } else { if (j->pld_scrr.bits.daaflag) { daa_int_read(board); } j->ex.bits.pstn_ring = 0; if (j->pstn_cid_intr && jiffies > j->pstn_cid_received + (hertz * 3)) { if (j->daa_mode == SOP_PU_RINGING) { ixj_daa_cid_read(board); j->ex.bits.caller_id = 1; } j->pstn_cid_intr = 0; } else { j->ex.bits.caller_id = 0; } if (!j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) { ixj[board].pld_scrw.bits.led1 = 0; ixj[board].pld_scrw.bits.led2 = 1; outb_p(ixj[board].pld_scrw.byte, ixj[board].XILINXbase); if (j->flags.pstn_ringing && j->pstn_envelope) { if(!j->pstn_ring_stop) { j->pstn_ring_stop = jiffies; } else if (time_after(jiffies, j->pstn_ring_stop + ((hertz * 5) / 100))){ j->pstn_ring_stop = 0; j->ex.bits.pstn_ring = 1; j->pstn_envelope = 0; } ixj[board].pld_scrw.bits.led1 = 0; outb_p(ixj[board].pld_scrw.byte, ixj[board].XILINXbase); } else if (j->daa_mode == SOP_PU_CONVERSATION) { if (!j->pstn_winkstart) { j->pstn_winkstart = jiffies; } else if (time_after(jiffies, j->pstn_winkstart + (hertz * j->winktime / 1000))) { daa_set_mode(board, SOP_PU_SLEEP); j->pstn_winkstart = 0; j->ex.bits.pstn_wink = 1; } } } } } } if (j->ex.bytes) { wake_up_interruptible(&j->poll_q); // Wake any blocked selects ixj_kill_fasync(board, POLL_IN); } } else { break; } } ixj_add_timer();}static int ixj_status_wait(int board){ unsigned long jif; jif = jiffies; while (!IsStatusReady(board)) { if (jiffies - jif > (60 * (hertz / 100))) { return -1; } } return 0;}static int ixj_PCcontrol_wait(int board){ unsigned long jif; jif = jiffies; while (!IsPCControlReady(board)) { if (jiffies - jif > (60 * (hertz / 100))) { return -1; } } return 0;}int ixj_WriteDSPCommand(unsigned short cmd, int board){ BYTES bytes; unsigned long jif; bytes.high = (cmd & 0xFF00) >> 8; bytes.low = cmd & 0x00FF; jif = jiffies; while (!IsControlReady(board)) { if (jiffies - jif > (60 * (hertz / 100))) { return -1; } } outb_p(bytes.low, ixj[board].DSPbase + 6); outb_p(bytes.high, ixj[board].DSPbase + 7); if (ixj_status_wait(board)) { ixj[board].ssr.low = 0xFF; ixj[board].ssr.high = 0xFF; return -1; }/* Read Software Status Register */ ixj[board].ssr.low = inb_p(ixj[board].DSPbase + 2); ixj[board].ssr.high = inb_p(ixj[board].DSPbase + 3); return 0;}/***************************************************************************** General Purpose IO Register read routine****************************************************************************/extern __inline__ int ixj_gpio_read(int board){ if (ixj_WriteDSPCommand(0x5143, board)) return -1; ixj[board].gpio.bytes.low = ixj[board].ssr.low; ixj[board].gpio.bytes.high = ixj[board].ssr.high; return 0;}extern __inline__ void LED_SetState(int state, int board){ if (ixj[board].cardtype == 300) { ixj[board].pld_scrw.bits.led1 = state & 0x1 ? 1 : 0; ixj[board].pld_scrw.bits.led2 = state & 0x2 ? 1 : 0; ixj[board].pld_scrw.bits.led3 = state & 0x4 ? 1 : 0; ixj[board].pld_scrw.bits.led4 = state & 0x8 ? 1 : 0; outb_p(ixj[board].pld_scrw.byte, ixj[board].XILINXbase); }}/********************************************************************** GPIO Pins are configured as follows on the Quicknet Internet* PhoneJACK Telephony Cards* * POTS Select GPIO_6=0 GPIO_7=0* Mic/Speaker Select GPIO_6=0 GPIO_7=1* Handset Select GPIO_6=1 GPIO_7=0** SLIC Active GPIO_1=0 GPIO_2=1 GPIO_5=0* SLIC Ringing GPIO_1=1 GPIO_2=1 GPIO_5=0* SLIC Open Circuit GPIO_1=0 GPIO_2=0 GPIO_5=0** Hook Switch changes reported on GPIO_3*********************************************************************/static int ixj_set_port(int board, int arg){ IXJ *j = &ixj[board]; if (j->cardtype == 400) { if (arg != PORT_POTS) return 10; else return 0; } switch (arg) { case PORT_POTS: j->port = PORT_POTS; switch (j->cardtype) { case 600: if (j->flags.pcmciasct == 1) SLIC_SetState(PLD_SLIC_STATE_ACTIVE, board); else return 11; break; case 500: j->pld_slicw.pcib.mic = 0; j->pld_slicw.pcib.spk = 0; outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); break; case 300: ixj_set_pots(board, 0); if (ixj_WriteDSPCommand(0xC528, board)) /* Write CODEC config to Software Control Register */ return 2; j->pld_scrw.bits.daafsyncen = 0; // Turn off DAA Frame Sync outb_p(j->pld_scrw.byte, j->XILINXbase); j->pld_clock.byte = 0; outb_p(j->pld_clock.byte, j->XILINXbase + 0x04); j->pld_slicw.bits.rly1 = 1; j->pld_slicw.bits.spken = 0; outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); SLIC_SetState(PLD_SLIC_STATE_STANDBY, board); break; case 100: j->gpio.bytes.high = 0x0B; j->gpio.bits.gpio6 = 0; j->gpio.bits.gpio7 = 0; ixj_WriteDSPCommand(j->gpio.word, board); break; } break; case PORT_PSTN: if (j->cardtype == 300) { ixj_WriteDSPCommand(0xC534, board); /* Write CODEC config to Software Control Register */ j->pld_slicw.bits.rly3 = 0; j->pld_slicw.bits.rly1 = 1; j->pld_slicw.bits.spken = 0; outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); j->port = PORT_PSTN; } else { return 4; } break; case PORT_SPEAKER: j->port = PORT_SPEAKER; switch (j->cardtype) { case 600: if (j->flags.pcmciasct) { SLIC_SetState(PLD_SLIC_STATE_OC, board);// while(SLIC_GetState(board) != PLD_SLIC_STATE_OC) { // SLIC_SetState(PLD_SLIC_STATE_OC,board); // } } break; case 500: j->pld_slicw.pcib.mic = 1; j->pld_slicw.pcib.spk = 1; outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); break; case 300: ixj_set_pots(board, 0); break; case 100: j->gpio.bytes.high = 0x0B; j->gpio.bits.gpio6 = 0; j->gpio.bits.gpio7 = 1; ixj_WriteDSPCommand(j->gpio.word, board); break; } break; case PORT_HANDSET: if (j->cardtype == 300 || j->cardtype == 500) { return 5; } else { j->gpio.bytes.high = 0x0B; j->gpio.bits.gpio6 = 1; j->gpio.bits.gpio7 = 0; ixj_WriteDSPCommand(j->gpio.word, board); j->port = PORT_HANDSET; } break; default: return 6; break; } return 0;}static int ixj_set_pots(int board, int arg){ IXJ *j = &ixj[board]; if (j->cardtype == 300) { if (arg) { if (j->port == PORT_PSTN) { j->pld_slicw.bits.rly1 = 0; outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); return 1; } else { return 0; } } else { j->pld_slicw.bits.rly1 = 1; outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01); return 1; } } else { return 0; }}static void ixj_ring_on(int board){ IXJ *j = &ixj[board]; if (j->dsp.low == 0x20) // Internet PhoneJACK { if (ixjdebug > 0) printk(KERN_INFO "IXJ Ring On /dev/phone%d\n", board); j->gpio.bytes.high = 0x0B;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -