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

📄 zaptel.h

📁 This a SOFTWARE pbx DRIVER
💻 H
📖 第 1 页 / 共 3 页
字号:
		/* Whether or not we have allocated gains or are using the default */	int gainalloc;	/* Specified by driver, readable by zaptel */	void *pvt;			/* Private channel data */	struct file *file;	/* File structure */			struct zt_span *span;		/* Span we're a member of */	int sig;			/* Signalling */	int sigcap;			/* Capability for signalling */		/* Used only by zaptel -- NO DRIVER SERVICEABLE PARTS BELOW */	/* Buffer declarations */	u_char		*readbuf[ZT_MAX_NUM_BUFS];	/* read buffer */	int		inreadbuf;	int		outreadbuf;	wait_queue_head_t readbufq; /* read wait queue */	u_char		*writebuf[ZT_MAX_NUM_BUFS]; /* write buffers */	int		inwritebuf;	int		outwritebuf;	wait_queue_head_t writebufq; /* write wait queue */		int		blocksize;	/* Block size */	int		eventinidx;  /* out index in event buf (circular) */	int		eventoutidx;  /* in index in event buf (circular) */	unsigned int	eventbuf[ZT_MAX_EVENTSIZE];  /* event circ. buffer */	wait_queue_head_t eventbufq; /* event wait queue */		wait_queue_head_t txstateq;	/* waiting on the tx state to change */		int		readn[ZT_MAX_NUM_BUFS];  /* # of bytes ready in read buf */	int		readidx[ZT_MAX_NUM_BUFS];  /* current read pointer */	int		writen[ZT_MAX_NUM_BUFS];  /* # of bytes ready in write buf */	int		writeidx[ZT_MAX_NUM_BUFS];  /* current write pointer */		int		numbufs;			/* How many buffers in channel */	int		txbufpolicy;			/* Buffer policy */	int		rxbufpolicy;			/* Buffer policy */	int		txdisable;				/* Disable transmitter */	int 	rxdisable;				/* Disable receiver */			/* Tone zone stuff */	struct zt_zone *curzone;		/* Zone for selecting tones */	int 	tonezone;				/* Tone zone for this channel */	struct zt_tone *curtone;		/* Current tone we're playing (if any) */	int		tonep;					/* Current position in tone */	struct zt_tone_state ts;		/* Tone state */	/* Pulse dial stuff */	int	pdialcount;			/* pulse dial count */	/* Ring cadence */	int ringcadence[ZT_MAX_CADENCE];	int firstcadencepos;				/* Where to restart ring cadence */	/* Digit string dialing stuff */	int		digitmode;			/* What kind of tones are we sending? */	char	txdialbuf[ZT_MAX_DTMF_BUF];	int 	dialing;	int	afterdialingtimer;	int		cadencepos;				/* Where in the cadence we are */	/* I/O Mask */		int		iomask;  /* I/O Mux signal mask */	wait_queue_head_t sel;	/* thingy for select stuff */		/* HDLC state machines */	struct fasthdlc_state txhdlc;	struct fasthdlc_state rxhdlc;	int infcs;	/* Conferencing stuff */	int		confna;	/* conference number (alias) */	int		_confn;	/* Actual conference number */	int		confmode;  /* conference mode */	int		confmute; /* conference mute mode */	/* Incoming and outgoing conference chunk queues for	   communicating between zaptel master time and	   other boards */	struct confq confin;	struct confq confout;	short	getlin[ZT_MAX_CHUNKSIZE];			/* Last transmitted samples */	unsigned char getraw[ZT_MAX_CHUNKSIZE];		/* Last received raw data */	short	getlin_lastchunk[ZT_MAX_CHUNKSIZE];	/* Last transmitted samples from last chunk */	short	putlin[ZT_MAX_CHUNKSIZE];			/* Last received samples */	unsigned char putraw[ZT_MAX_CHUNKSIZE];		/* Last received raw data */	short	conflast[ZT_MAX_CHUNKSIZE];			/* Last conference sample -- base part of channel */	short	conflast1[ZT_MAX_CHUNKSIZE];		/* Last conference sample  -- pseudo part of channel */	short	conflast2[ZT_MAX_CHUNKSIZE];		/* Previous last conference sample -- pseudo part of channel */		/* Is echo cancellation enabled or disabled */	int		echocancel;	echo_can_state_t	*ec;	echo_can_disable_detector_state_t txecdis;	echo_can_disable_detector_state_t rxecdis;		int 	echostate;		/* State of echo canceller */	int		echolastupdate;	/* Last echo can update pos */	int		echotimer;		/* Timer for echo update */	/* RBS timings  */	int		prewinktime;  /* pre-wink time (ms) */	int		preflashtime;	/* pre-flash time (ms) */	int		winktime;  /* wink time (ms) */	int		flashtime;  /* flash time (ms) */	int		starttime;  /* start time (ms) */	int		rxwinktime;  /* rx wink time (ms) */	int		rxflashtime; /* rx flash time (ms) */	int		debouncetime;  /* FXS GS sig debounce time (ms) */	int		pulsebreaktime; /* pulse line open time (ms) */	int		pulsemaketime;  /* pulse line closed time (ms) */	int		pulseaftertime; /* pulse time between digits (ms) */	/* RING debounce timer */	int	ringdebtimer;		/* RING trailing detector to make sure a RING is really over */	int ringtrailer;	/* PULSE digit receiver stuff */	int	pulsecount;	int	pulsetimer;	/* RBS timers */	int 	itimerset;		/* what the itimer was set to last */	int 	itimer;	int 	otimer;		/* RBS state */	int gotgs;	int txstate;	int rxsig;	int txsig;	int rxsigstate;	/* non-RBS rx state */	int rxhooksig;	int txhooksig;	int kewlonhook;	/* Idle signalling if CAS signalling */	int idlebits;	int deflaw;		/* 1 = mulaw, 2=alaw, 0=undefined */	short *xlaw;#ifdef CONFIG_CALC_XLAW	unsigned char (*lineartoxlaw)(short a);#else	unsigned char *lin2x;#endif#ifdef CONFIG_DEVFS_FS	devfs_handle_t fhandle;  /* File handle in devfs for the channel */	devfs_handle_t fhandle_symlink;#endif /* CONFIG_DEVFS_FS */};/* defines for transmit signalling */typedef enum {	ZT_TXSIG_ONHOOK,			/* On hook */	ZT_TXSIG_OFFHOOK,			/* Off hook */	ZT_TXSIG_START,				/* Start / Ring */	ZT_TXSIG_KEWL				/* Drop battery if possible */} zt_txsig_t;typedef enum {	ZT_RXSIG_ONHOOK,	ZT_RXSIG_OFFHOOK,	ZT_RXSIG_START,	ZT_RXSIG_RING,	ZT_RXSIG_INITIAL} zt_rxsig_t;	/* Span flags */#define ZT_FLAG_REGISTERED		(1 << 0)#define ZT_FLAG_RUNNING			(1 << 1)#define ZT_FLAG_RBS			(1 << 12)	/* Span uses RBS signalling *//* Channel flags */#define ZT_FLAG_DTMFDECODE		(1 << 2)	/* Channel supports native DTMF decode */#define ZT_FLAG_MFDECODE		(1 << 3)	/* Channel supports native MFr2 decode */#define ZT_FLAG_ECHOCANCEL		(1 << 4)	/* Channel supports native echo cancellation */#define ZT_FLAG_HDLC			(1 << 5)	/* Perform HDLC */#define ZT_FLAG_NETDEV			(1 << 6)	/* Send to network */#define ZT_FLAG_PSEUDO			(1 << 7)	/* Pseudo channel */#define ZT_FLAG_CLEAR			(1 << 8)	/* Clear channel */#define ZT_FLAG_AUDIO			(1 << 9)	/* Audio mode channel */#define ZT_FLAG_OPEN			(1 << 10)	/* Channel is open */#define ZT_FLAG_FCS			(1 << 11)	/* Calculate FCS *//* Reserve 12 for uniqueness with span flags */#define ZT_FLAG_LINEAR			(1 << 13)	/* Talk to user space in linear */#define ZT_FLAG_PPP			(1 << 14)	/* PPP is available */#define ZT_FLAG_T1PPP			(1 << 15)#define ZT_FLAG_SIGFREEZE		(1 << 16)	/* Freeze signalling */struct zt_span {	spinlock_t lock;	void *pvt;			/* Private stuff */	char name[40];			/* Span name */	char desc[80];			/* Span description */	int deflaw;			/* Default law (ZT_MULAW or ZT_ALAW) */	int alarms;			/* Pending alarms on span */	int flags;	int irq;			/* IRQ for this span's hardware */	int lbo;			/* Span Line-Buildout */	int lineconfig;			/* Span line configuration */	int linecompat;			/* Span line compatibility */	int channels;			/* Number of channels in span */	int txlevel;			/* Tx level */	int rxlevel;			/* Rx level */	int syncsrc;			/* current sync src (gets copied here) */	unsigned int bpvcount;		/* BPV counter */	unsigned int crc4count;	        /* CRC4 error counter */	unsigned int ebitcount;		/* current E-bit error count */	unsigned int fascount;		/* current FAS error count */	int maintstat;			/* Maintenance state */	wait_queue_head_t maintq;	/* Maintenance queue */	int mainttimer;			/* Maintenance timer */		int irqmisses;			/* Interrupt misses */	struct zt_chan *chans;		/* Member channel structures */	/*   ==== Span Callback Operations ====   */	/* Req: Set the requested chunk size.  This is the unit in which you must	   report results for conferencing, etc */	int (*setchunksize)(struct zt_span *span, int chunksize);	/* Opt: Configure the span (if appropriate) */	int (*spanconfig)(struct zt_span *span, struct zt_lineconfig *lc);		/* Opt: Start the span */	int (*startup)(struct zt_span *span);		/* Opt: Shutdown the span */	int (*shutdown)(struct zt_span *span);		/* Opt: Enable maintenance modes */	int (*maint)(struct zt_span *span, int mode);	/* ====  Channel Callback Operations ==== */	/* Opt: Set signalling type (if appropriate) */	int (*chanconfig)(struct zt_chan *chan, int sigtype);	/* Opt: Prepare a channel for I/O */	int (*open)(struct zt_chan *chan);	/* Opt: Close channel for I/O */	int (*close)(struct zt_chan *chan);		/* Opt: IOCTL */	int (*ioctl)(struct zt_chan *chan, unsigned int cmd, unsigned long data);		/* Okay, now we get to the signalling.  You have several options: */	/* Option 1: If you're a T1 like interface, you can just provide a	   rbsbits function and we'll assert robbed bits for you.  Be sure to 	   set the ZT_FLAG_RBS in this case.  */	/* Opt: If the span uses A/B bits, set them here */	int (*rbsbits)(struct zt_chan *chan, int bits);		/* Option 2: If you don't know about sig bits, but do have their	   equivalents (i.e. you can disconnect battery, detect off hook,	   generate ring, etc directly) then you can just specify a	   sethook function, and we'll call you with appropriate hook states	   to set.  Still set the ZT_FLAG_RBS in this case as well */	int (*hooksig)(struct zt_chan *chan, zt_txsig_t hookstate);		/* Option 3: If you can't use sig bits, you can write a function	   which handles the individual hook states  */	int (*sethook)(struct zt_chan *chan, int hookstate);	/* Used by zaptel only -- no user servicable parts inside */	int spanno;			/* Span number for zaptel */	int offset;			/* Offset within a given card */	int lastalarms;		/* Previous alarms */#ifdef CONFIG_DEVFS_FS	devfs_handle_t dhandle;  /* Directory name */#endif		/* If the watchdog detects no received data, it will call the	   watchdog routine */	int (*watchdog)(struct zt_span *span, int cause);#ifdef CONFIG_ZAPTEL_WATCHDOG	int watchcounter;	int watchstate;#endif	};#define ZT_WATCHDOG_NOINTS		(1 << 0)#define ZT_WATCHDOG_INIT			1000#define ZT_WATCHSTATE_UNKNOWN		0#define ZT_WATCHSTATE_OK			1#define ZT_WATCHSTATE_RECOVERING	2#define ZT_WATCHSTATE_FAILED		3struct zt_dynamic_driver {	/* Driver name (e.g. Eth) */	char name[20];	/* Driver description */	char desc[80];	/* Create a new transmission pipe */	void *(*create)(struct zt_span *span, char *address);	/* Destroy a created transmission pipe */	void (*destroy)(void *tpipe);	/* Transmit a given message */	int (*transmit)(void *tpipe, unsigned char *msg, int msglen);	struct zt_dynamic_driver *next;};/* Receive a dynamic span message */extern void zt_dynamic_receive(struct zt_span *span, unsigned char *msg, int msglen);/* Register a dynamic driver */extern int zt_dynamic_register(struct zt_dynamic_driver *driver);/* Unregister a dynamic driver */extern void zt_dynamic_unregister(struct zt_dynamic_driver *driver);/* Receive on a span.  The zaptel interface will handle all the calculations for   all member channels of the span, pulling the data from the readchunk buffer */extern int zt_receive(struct zt_span *span);/* Prepare writechunk buffers on all channels for this span */extern int zt_transmit(struct zt_span *span);/* Register a span.  Returns 0 on success, -1 on failure.  Pref-master is non-zero if   we should have preference in being the master device */extern int zt_register(struct zt_span *span, int prefmaster);/* Unregister a span */extern int zt_unregister(struct zt_span *span);/* Gives a name to an LBO */extern char *zt_lboname(int lbo);/* Tell Zaptel about changes in received rbs bits */extern void zt_rbsbits(struct zt_chan *chan, int bits);/* Tell Zaptel abou changes in received signalling */extern void zt_hooksig(struct zt_chan *chan, zt_rxsig_t rxsig);/* Queue an event on a channel */extern void zt_qevent_nolock(struct zt_chan *chan, int event);/* Queue an event on a channel, locking it first */extern void zt_qevent_lock(struct zt_chan *chan, int event);/* Notify a change possible change in alarm status */extern void zt_alarm_notify(struct zt_span *span);/* Initialize a tone state */extern void zt_init_tone_state(struct zt_tone_state *ts, struct zt_tone *zt);/* Get a given DTMF or MF tone struct, suitable for zt_tone_nextsample.   Set 'mf' to 0 for DTMF or 1 for MFv1 */extern struct zt_tone *zt_dtmf_tone(char digit, int mf);/* Echo cancel a receive and transmit chunk for a given channel.  This   should be called by the low-level driver as close to the interface   as possible.  ECHO CANCELLATION IS NO LONGER AUTOMATICALLY DONE   AT THE ZAPTEL LEVEL.  zt_ec_chunk will not echo cancel if it should   not be doing so.  rxchunk is modified in-place */extern void zt_ec_chunk(struct zt_chan *chan, unsigned char *rxchunk, const unsigned char *txchunk);/* Don't use these directly -- they're not guaranteed to   be there. */extern short __zt_mulaw[256];extern short __zt_alaw[256];#ifdef CONFIG_CALC_XLAWextern u_char __zt_lineartoulaw(short a);extern u_char __zt_lineartoalaw(short a);#elseextern u_char __zt_lin2mu[16384];extern u_char __zt_lin2a[16384];#endif/* Used by dynamic zaptel -- don't use directly */extern void zt_set_dynamic_ioctl(int (*func)(unsigned int cmd, unsigned long data));/* Used privately by zaptel.  Avoid touching directly */struct zt_tone {	int fac1;	int init_v2_1;	int init_v3_1;	int fac2;	int init_v2_2;	int init_v3_2;	int tonesamples;		/* How long to play this tone before 					   going to the next (in samples) */	struct zt_tone *next;		/* Next tone in this sequence */	int modulate;};static inline short zt_tone_nextsample(struct zt_tone_state *ts, struct zt_tone *zt){	/* follow the curves, return the sum */	int p;	ts->v1_1 = ts->v2_1;	ts->v2_1 = ts->v3_1;	ts->v3_1 = (zt->fac1 * ts->v2_1 >> 15) - ts->v1_1;	ts->v1_2 = ts->v2_2;	ts->v2_2 = ts->v3_2;	ts->v3_2 = (zt->fac2 * ts->v2_2 >> 15) - ts->v1_2;	/* Return top 16 bits */	if (!ts->modulate) return ts->v3_1 + ts->v3_2;	/* we are modulating */	p = ts->v3_2 - 32768;	if (p < 0) p = -p;	p = ((p * 9) / 10) + 1;	return (ts->v3_1 * p) >> 15;}static inline short zt_txtone_nextsample(struct zt_chan *ss){	/* follow the curves, return the sum */	ss->v1_1 = ss->v2_1;	ss->v2_1 = ss->v3_1;	ss->v3_1 = (ss->txtone * ss->v2_1 >> 15) - ss->v1_1;	return ss->v3_1;}/* These are the right functions to use.  */#define ZT_MULAW(a) (__zt_mulaw[(a)])#define ZT_ALAW(a) (__zt_alaw[(a)])#define ZT_XLAW(a,c) (c->xlaw[(a)])#ifdef CONFIG_CALC_XLAW#define ZT_LIN2MU(a) (__zt_lineartoulaw((a)))#define ZT_LIN2A(a) (__zt_lineartoalaw((a)))#define ZT_LIN2X(a,c) ((c)->lineartoxlaw((a)))#else/* Use tables */#define ZT_LIN2MU(a) (__zt_lin2mu[((unsigned short)(a)) >> 2])#define ZT_LIN2A(a) (__zt_lin2a[((unsigned short)(a)) >> 2])/* Manipulate as appropriate for x-law */#define ZT_LIN2X(a,c) ((c)->lin2x[((unsigned short)(a)) >> 2])#endif /* CONFIG_CALC_XLAW */#endif /* __KERNEL__ */#endif /* _LINUX_ZAPTEL_H */

⌨️ 快捷键说明

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