voipblaster.h
上传用户:weyjxb
上传日期:2020-05-18
资源大小:52k
文件大小:11k
- /*
- * voipblaster.c
- * (C) Copyright 2001, 2002 by Thomas Davis (tdavis@beeble.homelinux.net)
- * (C) Copyright 2001 by Michael Bosland <mike@ring.org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
- #ifndef _VOIP_BLASTER_H
- #define _VOIP_BLASTER_H
- /* Buffer up to 300ms in and 3sec out */
- #define VB_R_BUFF_LENGTH 240
- #define VB_W_BUFF_LENGTH 2400
- #define VB_CMD_BUFF_LENGTH 20
- #define VB_EVENT_BUFF_LENGTH 20
- #define VB_DTMF_BUFF_LENGTH 80
- #define DRIVER_DESC "USB VOIPblaster driver"
- #if !defined(VOIP_MAX)
- #define VOIP_MAX 4
- #endif
- typedef struct {
- unsigned char low;
- unsigned char high;
- } BYTES;
- typedef union {
- BYTES bytes;
- short word;
- } IXJ_WORD;
- typedef struct{
- unsigned int b0:1;
- unsigned int b1:1;
- unsigned int b2:1;
- unsigned int b3:1;
- unsigned int b4:1;
- unsigned int b5:1;
- unsigned int b6:1;
- unsigned int b7:1;
- } IXJ_CBITS;
- typedef union{
- IXJ_CBITS cbits;
- char cbyte;
- } IXJ_CBYTE;
- typedef struct {
- unsigned int busytone:1;
- unsigned int dialtone:1;
- unsigned int ringback:1;
- unsigned int ringing:1;
- unsigned int playing:1;
- unsigned int recording:1;
- unsigned int cringing:1;
- unsigned int play_first_frame:1;
- unsigned int pstn_present:1;
- unsigned int pstn_ringing:1;
- unsigned int pots_correct:1;
- unsigned int pots_pstn:1;
- unsigned int dtmf_oob:1; /* DTMF Out-Of-Band */
- unsigned int pcmciascp:1; /* SmartCABLE Present */
- unsigned int pcmciasct:2; /* SmartCABLE Type */
- unsigned int pcmciastate:3; /* SmartCABLE Init State */
- unsigned int inwrite:1; /* Currently writing */
- unsigned int inread:1; /* Currently reading */
- unsigned int incheck:1; /* Currently checking the SmartCABLE */
- unsigned int cidplay:1; /* Currently playing Caller ID */
- unsigned int cidring:1; /* This is the ring for Caller ID */
- unsigned int cidsent:1; /* Caller ID has been sent */
- unsigned int cidcw_ack:1; /* Caller ID CW ACK (from CPE) */
- unsigned int firstring:1; /* First ring cadence is complete */
- unsigned int pstncheck:1; /* Currently checking the PSTN Line */
- unsigned int pstn_rmr:1;
- unsigned int x:3; /* unsed bits */
- } VOIP_FLAGS;
- typedef struct {
- char enable;
- char en_filter;
- unsigned int filter;
- unsigned int state; /* State 0 when cadence has not started. */
- unsigned int on1; /* State 1 */
- unsigned long on1min; /* State 1 - 10% + jiffies */
- unsigned long on1dot; /* State 1 + jiffies */
- unsigned long on1max; /* State 1 + 10% + jiffies */
- unsigned int off1; /* State 2 */
- unsigned long off1min;
- unsigned long off1dot; /* State 2 + jiffies */
- unsigned long off1max;
- unsigned int on2; /* State 3 */
- unsigned long on2min;
- unsigned long on2dot;
- unsigned long on2max;
- unsigned int off2; /* State 4 */
- unsigned long off2min;
- unsigned long off2dot; /* State 4 + jiffies */
- unsigned long off2max;
- unsigned int on3; /* State 5 */
- unsigned long on3min;
- unsigned long on3dot;
- unsigned long on3max;
- unsigned int off3; /* State 6 */
- unsigned long off3min;
- unsigned long off3dot; /* State 6 + jiffies */
- unsigned long off3max;
- } VOIP_CADENCE_F;
- struct queue {
- char *buffer;
- long head;
- long tail;
- long count;
- long size;
- };
- struct pipe {
- wait_queue_head_t q;
- urb_t *urb;
- char *buffer;
- long head;
- long length;
- long size;
- };
- struct usb_voipblaster {
- struct usb_device *udev;
- struct usb_interface * interface; /* the interface for this device */
- unsigned char minor; /* the minor number for this device */
- struct semaphore sem;
- int open_count;
- int ispresent;
- char *obuf, ibuf;
- struct phone_capability caplist[15];
- struct phone_device phone;
- struct timer_list timer;
- struct fasync_struct *async_queue;
- struct proc_dir_entry *dir;
- unsigned int DSPbase;
- unsigned int board;
- unsigned int caps;
- unsigned int cardtype;
- unsigned int maxrings;
- unsigned int ringcnt;
- unsigned int ringing;
- unsigned int play_codec;
- unsigned int rec_codec;
- int readers, writers;
- int aec_level;
- char hookstate;
- char tonestate;
- char port;
- unsigned char dsp_serial[10];
- unsigned char dsp_version[10];
- char serialnum[30];
- char revision[30];
- unsigned int serial, winktime;
- unsigned int daa_country;
- PHONE_CID cid;
- PHONE_CID cid_send;
- BYTES baseframe;
- union telephony_exception ex;
- union telephony_exception ex_sig;
- int signals[35];
- IXJ_SIGDEF sigdef;
- VOIP_CADENCE_F cadence_f[6];
- VOIP_FLAGS flags;
- int ring_cadence;
-
- unsigned long framesread, frameswritten;
- unsigned long read_wait, write_wait;
- unsigned long drybuffer;
- spinlock_t io_lock;
- wait_queue_head_t poll_q;
- wait_queue_head_t read_q;
- wait_queue_head_t write_q;
- wait_queue_head_t cmd_q;
- wait_queue_head_t event_q;
- urb_t *read_urb;
- urb_t *write_urb;
- urb_t *cmd_urb;
- urb_t *event_urb;
- char read_buffer[VB_R_BUFF_LENGTH];
- char read_buffer_urb[20];
- unsigned int read_buffer_ready;
- unsigned int read_buffer_in;
- unsigned int read_buffer_len;
- char write_buffer[VB_W_BUFF_LENGTH];
- unsigned int write_buffer_in;
- unsigned int write_buffer_len;
- char cmd_data[1];
- char cmd_buffer[VB_CMD_BUFF_LENGTH];
- unsigned int cmd_buffer_in;
- unsigned int cmd_buffer_len;
- char event_data[1];
- char event_buffer[VB_EVENT_BUFF_LENGTH];
- unsigned int event_buffer_in;
- unsigned int event_buffer_out;
- unsigned int event_buffer_len;
- char dtmf_buffer[VB_DTMF_BUFF_LENGTH];
- unsigned int dtmf_buffer_in;
- unsigned int dtmf_buffer_out;
- unsigned int dtmf_buffer_len;
- struct queue wq, rq, cq, eq;
- };
- /*
- * These are hex commands that are sent to the Voipblaster
- */
- /* ----------------------------------------------------------------------------
- * various commands that can send to the VOIP Blaster device
- * ----------------------------------------------------------------------------*/
- #define VB_CMD_NONE 0x00 /* (NONE) */
- #define VB_CMD_PHONE_OFF 0x01 /* (SWITCHRELAYPSTN) drop loop current */
- #define VB_CMD_PHONE_ON 0x02 /* (SWITCHRELAYIGSP) used on startup */
- #define VB_CMD_RING_ON 0x03 /* (STARTFING) start ringing */
- #define VB_CMD_RING_OFF 0x04 /* (STOPRING) used on startup & to stop ringing */
- #define VB_CMD_VOUT_START 0x05 /* (PLAYBACKSTART ) start voice out */
- #define VB_CMD_VOUT_STOP 0x06 /* (PLAYBACKSTOP ) */
- #define VB_CMD_VINP_START 0x07 /* (RECORDINGSTART) */
- #define VB_CMD_VINP_STOP 0x08 /* (RECORDINGSTOP ) */
- #define VB_CMD_UNKNOWN_1 0x09 /* (TESTSTART ) don't know what this does */
- #define VB_CMD_UNKNOWN_2 0x0a /* (TESTSTOP ) don't know what this does */
- #define VB_CMD_UNKNOWN_3 0x0b /* (SENDFAXTONE ) doesn't seem to do anything */
- /* ---------------------------------------------------------------------------- */
- #define VB_CMD_ON_HOOK 0x0c /* (APPONHOOK ) go offhook for headset */
- #define VB_CMD_OFF_HOOK 0x0d /* (APPOFFHOOK ) go onhook for headset */
- #define VB_CMD_SETUP_MODE 0x0e /* goto setup mode? */
- #define VB_CMD_VOUT_DONE 0x0f /* voice in/out off, report output drained */
- /* ---------------------------------------------------------------------------- */
- #define VB_CMD_0x10 0x10 /* used in file output, seems ok without */
- #define VB_CMD_0x11 0x11 /* used in file output, seems ok without */
- #define VB_CMD_MUTE_ON 0x12 /* audio mute on */
- #define VB_CMD_MUTE_OFF 0x13 /* audio mute off */
- /* ---------------------------------------------------------------------------- */
- #define VB_CMD_VOL_0 0x34 /* set volume (min) */
- #define VB_CMD_VOL_1 0x35 /* set volume */
- #define VB_CMD_VOL_2 0x36 /* set volume */
- #define VB_CMD_VOL_3 0x37 /* set volume (default) */
- #define VB_CMD_VOL_4 0x38 /* set volume */
- #define VB_CMD_VOL_5 0x39 /* set volume */
- #define VB_CMD_VOL_6 0x3a /* set volume (max) */
- #if 0
- #define VB_CMD_PSTN 0x01 /* Switch Relay pstn(?) - Happens when shutting down. Turn off dialtone? */
- #define VB_CMD_IGSP 0x02 /* Switch Relay igsp(?) - Happens when starting up. Turn on dialtone? */
- #define VB_CMD_RINGSTART 0x03 /* Ring the phone. */
- #define VB_CMD_RINGSTOP 0x04 /* Stop ringing the phone. */
- #define VB_CMD_AUDIOENABLE 0x05 /* Play Audio? - Happens just before 11. Could be close audio or reset... */
- #define VB_CMD_UNKN1 0x07 /* ? - Only happens when someone on other end... - Lots of these happen.. */
- #define VB_CMD_UNKN2 0x0c /* ? - Can happen when no one on other end of the line... */
- #define VB_CMD_UNKN3 0x0f /* ? - Can happen when no one on other end of the line... - Last command transmitted? */
- #endif
- /* These are events that return from the Voipblaster */
- #define VB_EVENT_NULL 0x00 /* Empty event occurred. */
- #define VB_EVENT_OFFHOOK 0x01 /* Off Hook */
- #define VB_EVENT_ONHOOK 0x02 /* On Hook */
- #define VB_EVENT_RINGING_ON 0x05 /* is ringing */
- #define VB_EVENT_RINGING_OFF 0x06 /* Stop Ringing Executed. */
- #define VB_EVENT_HEADSET_IN 0x08 /* headset plugged in */
- #define VB_EVENT_HEADSET_OUT 0x09 /* headset removed */
- #define VB_EVENT_VOUT_DONE 0x0c /* voice output done */
- #define VB_EVENT_DTMFSTAR 0x2a /* DTMF * */
- #define VB_EVENT_DTMFPND 0x23 /* DTMF # */
- #define VB_EVENT_DTMF0 0x30 /* DTMF 0 */
- #define VB_EVENT_DTMF1 0x31 /* DTMF 1 */
- #define VB_EVENT_DTMF2 0x32 /* DTMF 2 */
- #define VB_EVENT_DTMF3 0x33 /* DTMF 3 */
- #define VB_EVENT_DTMF4 0x34 /* DTMF 4 */
- #define VB_EVENT_DTMF5 0x35 /* DTMF 5 */
- #define VB_EVENT_DTMF6 0x36 /* DTMF 6 */
- #define VB_EVENT_DTMF7 0x37 /* DTMF 7 */
- #define VB_EVENT_DTMF8 0x38 /* DTMF 8 */
- #define VB_EVENT_DTMF9 0x39 /* DTMF 9 */
- #if 0
- /* ----------------------------------------------------------------------------
- various status that can be returned by the VOIP Blaster device
- ---------------------------------------------------------------------------- */
- #define STATUS_NONE 0x00 /* (NONE ) */
- #define STATUS_OFF_HOOK 0x01 /* (OFFHOOK ) */
- #define STATUS_ON_HOOK 0x02 /* (ONHOOK ) */
- #define STATUS_DEBUG 0x00 /* (DEBUG ) ?? not used ?? */
- #define STATUS_RINGDETECT 0x00 /* (RINGDETECT ) ?? not used ?? */
- #define STATUS_RINGING_ON 0x05 /* (STARTRINGEXEC) is ringing */
- #define STATUS_RINGING_OFF 0x06 /* (STOPRINGEXEC ) not ringing */
- #define STATUS_HEADSET_IN 0x08 /* 0000-1000 headset plugged in */
- #define STATUS_HEADSET_OUT 0x09 /* 0000-1001 headset un-plugged */
- #define STATUS_0x0a 0x0a /* 0000-1010 setup accepted? */
- #define STATUS_VOUT_DONE 0x0c /* 0000-1100 voice output done */
- #endif
- #endif
- /*
- * Local variables:
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */