⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ixj.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 5 页
字号:
							if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {								j->pstn_winkstart = 0;								if (j->flags.pstn_ringing && !j->pstn_envelope) {									j->ex.bits.pstn_ring = 0;									j->pstn_envelope = 1;									j->pstn_ring_start = jiffies;								}							} else {								if (j->flags.pstn_ringing && j->pstn_envelope &&								    jiffies > j->pstn_ring_start + ((hertz * 15) / 10)) {									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 (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_recieved = 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_recieved + (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) {								if (j->flags.pstn_ringing && j->pstn_envelope) {									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 (jiffies > j->pstn_winkstart + (hertz * 320 / 1000)) {										daa_set_mode(board, SOP_PU_SLEEP);										j->pstn_winkstart = 0;										j->ex.bits.pstn_wink = 1;									}								}							}						}					}				}				if ((j->ex.bits.f0 || j->ex.bits.f1 || j->ex.bits.f2 || j->ex.bits.f3)				    && j->filter_cadence) {				}				if (j->ex.bytes) {					wake_up_interruptible(&j->poll_q);	// Wake any blocked selects					if (j->async_queue)						kill_fasync(j->async_queue, SIGIO);	// Send apps notice of change				}			} else {				break;			}		}	}      timer_end:	if (mutex == 1) {		ixj_init_timer();		mutex--;	}}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;}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(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].dsp.low == 0x21) {		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 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:			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 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:			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/ixj%d\n", board);		j->gpio.bytes.high = 0x0B;		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_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) {				det = jiffies + (hertz / 50);				while (time_before(jiffies, det)) {					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;	}	if (j->r_hook != fOffHook) {		j->r_hook = fOffHook;		if (j->port != PORT_POTS) {			j->ex.bits.hookstate = 1;			if (j->async_queue)				kill_fasync(j->async_queue, SIGIO);	// Send apps notice of change		}	}	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;	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(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(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;			}			current->state = TASK_INTERRUPTIBLE;			schedule_timeout(1);		}		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)) {					current->state = TASK_INTERRUPTIBLE;					schedule_timeout(1);				}				if (ixj_hookstate(board) & 1) {					j->flags.ringing = 0;					return 1;				}			}			current->state = TASK_INTERRUPTIBLE;			schedule_timeout(1);		}	}	ixj_ring_off(board);	j->flags.ringing = 0;	return 0;}int ixj_open(struct phone_device *p, struct file *file_p){	IXJ *j = &ixj[p->board];	if (!j->DSPbase)		return -ENODEV;	if (file_p->f_mode & FMODE_READ)		j->readers++;	if (file_p->f_mode & FMODE_WRITE)		j->writers++;	MOD_INC_USE_COUNT;	if (ixjdebug > 0)//    printk(KERN_INFO "Opening board %d\n", NUM(inode->i_rdev));		printk(KERN_INFO "Opening board %d\n", p->board);	return 0;}int ixj_release(struct inode *inode, struct file *file_p){	IXJ_TONE ti;	int board = NUM(inode->i_rdev);	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);	ixj_set_port(board, PORT_POTS);	aec_stop(board);	ixj_play_stop(board);	ixj_record_stop(board);	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;	ti.gain0 = 1;	ti.freq0 = hz1600;	ti.gain1 = 0;	ti.freq1 = 0;	ixj_init_tone(board, &ti);	ti.tone_index = 21;	ti.gain0 = 1;	ti.freq0 = hz1800;	ti.gain1 = 0;	ti.freq1 = 0;	ixj_init_tone(board, &ti);	ti.tone_index = 22;	ti.gain0 = 1;	ti.freq0 = hz2100;	ti.gain1 = 0;	ti.freq1 = 0;	ixj_init_tone(board, &ti);	ti.tone_index = 23;	ti.gain0 = 1;	ti.freq0 = hz1300;	ti.gain1 = 0;	ti.freq1 = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -