/* $Id: isdn_tty.c,v 1.1.2.3 2004/02/10 01:07:13 keil Exp $ * * Linux ISDN subsystem, tty functions and AT-command emulator (linklevel). * * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de) * Copyright 1995,96 by Thinking Objects Software GmbH Wuerzburg * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */#undef ISDN_TTY_STAT_DEBUG#include <linux/config.h>#include <linux/isdn.h>#include <linux/delay.h>#include "isdn_common.h"#include "isdn_tty.h"#ifdef CONFIG_ISDN_AUDIO#include "isdn_audio.h"#define VBUF 0x3e0#define VBUFX (VBUF/16)#endif#define FIX_FILE_TRANSFER#define DUMMY_HAYES_AT/* Prototypes */staticintisdn_tty_edit_at(constchar*,int,modem_info*);staticvoidisdn_tty_check_esc(constu_char*,u_char,int,int*,u_long*);staticvoidisdn_tty_modem_reset_regs(modem_info*,int);staticvoidisdn_tty_cmd_ATA(modem_info*);staticvoidisdn_tty_flush_buffer(structtty_struct*);staticvoidisdn_tty_modem_result(int,modem_info*);#ifdef CONFIG_ISDN_AUDIOstaticintisdn_tty_countDLE(unsignedchar*,int);#endif/* Leave this unchanged unless you know what you do! */#define MODEM_PARANOIA_CHECK#define MODEM_DO_RESTARTstaticintbit2si[8]={1,5,7,7,7,7,7,7};staticintsi2bit[8]={4,1,4,4,4,4,4,4};char*isdn_tty_revision="$Revision: 1.1.2.3 $";/* isdn_tty_try_read() is called from within isdn_tty_rcv_skb() * to stuff incoming data directly into a tty's flip-buffer. This * is done to speed up tty-receiving if the receive-queue is empty. * This routine MUST be called with interrupts off. * Return: * 1 = Success * 0 = Failure, data has to be buffered and later processed by * isdn_tty_readmodem(). */staticintisdn_tty_try_read(modem_info*info,structsk_buff*skb){intc;intlen;structtty_struct*tty;if(info->online){if((tty=info->tty)){if(info->mcr&UART_MCR_RTS){c=TTY_FLIPBUF_SIZE-tty->flip.count;len=skb->len#ifdef CONFIG_ISDN_AUDIO+ISDN_AUDIO_SKB_DLECOUNT(skb)#endif;if(c>=len){#ifdef CONFIG_ISDN_AUDIOif(ISDN_AUDIO_SKB_DLECOUNT(skb))while(skb->len--){if(*skb->data==DLE)tty_insert_flip_char(tty,DLE,0);tty_insert_flip_char(tty,*skb->data++,0);}else{#endifmemcpy(tty->flip.char_buf_ptr,skb->data,len);tty->flip.count+=len;tty->flip.char_buf_ptr+=len;memset(tty->flip.flag_buf_ptr,0,len);tty->flip.flag_buf_ptr+=len;#ifdef CONFIG_ISDN_AUDIO}#endifif(info->emu.mdmreg[REG_CPPP]&BIT_CPPP)tty->flip.flag_buf_ptr[len-1]=0xff;schedule_delayed_work(&tty->flip.work,1);kfree_skb(skb);return1;}}}}return0;}/* isdn_tty_readmodem() is called periodically from within timer-interrupt. * It tries getting received data from the receive queue an stuff it into * the tty's flip-buffer. */voidisdn_tty_readmodem(void){intresched=0;intmidx;inti;intc;intr;structtty_struct*tty;modem_info*info;for(i=0;i<ISDN_MAX_CHANNELS;i++){if((midx=dev->m_idx[i])>=0){info=&dev->mdm.info[midx];if(info->online){r=0;#ifdef CONFIG_ISDN_AUDIOisdn_audio_eval_dtmf(info);if((info->vonline&1)&&(info->emu.vpar[1]))isdn_audio_eval_silence(inf