From f04ea3143569dbadcdd5ed96e8feed0601464156 Mon Sep 17 00:00:00 2001 From: matteo Date: Mon, 17 Mar 2003 18:11:45 +0000 Subject: lun mar 17 19:11:15 CET 2003 git-svn-id: http://svn.digium.com/svn/zaptel/trunk@155 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- zaptel.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'zaptel.h') diff --git a/zaptel.h b/zaptel.h index 9a2f9a3..b053cbe 100755 --- a/zaptel.h +++ b/zaptel.h @@ -66,7 +66,6 @@ #define ZT_CONFIG_CCS (1 << 8) /* CCS (ISDN) instead of CAS (Robbed Bit) */ #define ZT_CONFIG_HDB3 (1 << 9) /* HDB3 instead of AMI (line coding) */ #define ZT_CONFIG_CRC4 (1 << 10) /* CRC4 framing */ - #define ZT_CONFIG_NOTOPEN (1 << 16) /* Signalling types */ @@ -91,8 +90,13 @@ #define ZT_SIG_HDLCFCS ((1 << 9) | ZT_SIG_HDLCRAW) /* HDLC with FCS calculation */ #define ZT_SIG_HDLCNET ((1 << 10) | ZT_SIG_HDLCFCS) /* HDLC Network */ #define ZT_SIG_SLAVE (1 << 11) /* Slave to another channel */ +#define ZT_SIG_SF (1 << 14) /* Single Freq. tone only, no sig bits */ #define ZT_SIG_CAS (1 << 15) /* Just get bits */ +/* tone flag values */ +#define ZT_REVERSE_RXTONE 1 /* reverse polarity rx tone logic */ +#define ZT_REVERSE_TXTONE 2 /* reverse polarity tx tone logic */ + #define ZT_ABIT 8 #define ZT_BBIT 4 #define ZT_CBIT 2 @@ -211,13 +215,26 @@ int sync; /* what level of sync source we are */ typedef struct zt_chanconfig { int chan; /* Channel we're applying this to (0 to use name) */ -char name[40]; /* Name of channel to use */ +char name[40]; /* Name of channel to use */ int sigtype; /* Signal type */ int deflaw; /* Default law (ZT_LAW_DEFAULT, ZT_LAW_MULAW, or ZT_LAW_ALAW */ int master; /* Master channel if sigtype is ZT_SLAVE */ int idlebits; /* Idle bits (if this is a CAS channel) */ } ZT_CHANCONFIG; +typedef struct zt_sfconfig +{ +int chan; /* Channel we're applying this to (0 to use name) */ +char name[40]; /* Name of channel to use */ +long rxp1; /* receive tone det. p1 */ +long rxp2; /* receive tone det. p2 */ +long rxp3; /* receive tone det. p3 */ +int txtone; /* Tx tone factor */ +int tx_v2; /* initial v2 value */ +int tx_v3; /* initial v3 value */ +int toneflag; /* Tone flags */ +} ZT_SFCONFIG; + typedef struct zt_bufferinfo { int txbufpolicy; /* Policy for handling receive buffers */ @@ -501,6 +518,11 @@ char dialstr[ZT_MAX_DTMF_BUF]; */ #define ZT_GETRXBITS _IOR (ZT_CODE, 45, int) +/* + * Set Channel's SF Tone Configuration + */ +#define ZT_SFCONFIG _IOW (ZT_CODE, 46, struct zt_sfconfig) + /* * 60-80 are reserved for private drivers * 80-85 are reserved for dynamic span stuff @@ -796,6 +818,18 @@ struct confq { int outbuf; }; +typedef struct +{ + long x1; + long x2; + long y1; + long y2; + long e1; + long e2; + int samps; + int lastdetect; +} sf_detect_state_t; + struct zt_chan { #ifdef CONFIG_ZAPATA_NET /* Must be first */ @@ -814,6 +848,17 @@ struct zt_chan { int channo; /* Zaptel Channel number */ int chanpos; int flags; + long rxp1; + long rxp2; + long rxp3; + int txtone; + int tx_v2; + int tx_v3; + int v1_1; + int v2_1; + int v3_1; + int toneflags; + sf_detect_state_t rd; struct zt_chan *master; /* Our Master channel (could be us) */ /* Next slave (if appropriate) */ @@ -1221,6 +1266,16 @@ static inline short zt_tone_nextsample(struct zt_tone_state *ts, struct zt_tone return ts->v3_1 + ts->v3_2; } +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)]) -- cgit v1.2.3