diff options
-rw-r--r-- | hpec/hpec_zaptel.h | 5 | ||||
-rw-r--r-- | kb1ec.h | 14 | ||||
-rw-r--r-- | mec.h | 14 | ||||
-rw-r--r-- | mec2.h | 16 | ||||
-rw-r--r-- | mec3.h | 14 | ||||
-rw-r--r-- | mg2ec.h | 14 | ||||
-rw-r--r-- | sec-2.h | 14 | ||||
-rw-r--r-- | sec.h | 14 | ||||
-rw-r--r-- | zaptel-base.c | 85 | ||||
-rw-r--r-- | zaptel.h | 14 |
10 files changed, 166 insertions, 38 deletions
diff --git a/hpec/hpec_zaptel.h b/hpec/hpec_zaptel.h index ded0226..99e753b 100644 --- a/hpec/hpec_zaptel.h +++ b/hpec/hpec_zaptel.h @@ -65,6 +65,11 @@ static void echo_can_init(void) hpec_init(logger, debug, ZT_CHUNKSIZE, memalloc, memfree); } +static void echo_can_identify(char *buf, size_t len) +{ + strncpy(buf, "HPEC", len); +} + static void echo_can_shutdown(void) { hpec_shutdown(); @@ -141,6 +141,20 @@ struct echo_can_state { }; +static void echo_can_init(void) +{ + printk("Zaptel Echo Canceller: KB1%s\n", ZAPTEL_ECHO_AGGRESSIVE); +} + +static void echo_can_identify(char *buf, size_t len) +{ + strncpy(buf, "KB1", len); +} + +static void echo_can_shutdown(void) +{ +} + static inline void init_cb_s(echo_can_cb_s *cb, int len, void *where) { cb->buf_d = (short *)where; @@ -98,6 +98,20 @@ struct echo_can_state { #define FREE(a) free(a) #endif +static void echo_can_init(void) +{ + printk("Zaptel Echo Canceller: MARK%s\n", ZAPTEL_ECHO_AGGRESSIVE); +} + +static void echo_can_identify(char *buf, size_t len) +{ + strncpy(buf, "MARK2", len); +} + +static void echo_can_shutdown(void) +{ +} + static INLINE struct echo_can_state *echo_can_create(int len, int adaption_mode) { struct echo_can_state *ec; @@ -51,7 +51,7 @@ typedef struct { // class definition // -struct echo_can_state { +struct echo_can_state { /* Echo canceller definition */ /* absolute time */ @@ -88,6 +88,20 @@ struct echo_can_state { }; +static void echo_can_init(void) +{ + printk("Zaptel Echo Canceller: MARK2%s\n", ZAPTEL_ECHO_AGGRESSIVE); +} + +static void echo_can_identify(char *buf, size_t len) +{ + strncpy(buf, "MARK2", len); +} + +static void echo_can_shutdown(void) +{ +} + static inline void init_cb_s(echo_can_cb_s *cb, int len, void *where) { cb->buf_d = (short *)where; @@ -87,6 +87,20 @@ struct echo_can_state { int backup; /* Backup timer */ }; +static void echo_can_init(void) +{ + printk("Zaptel Echo Canceller: MARK3%s\n", ZAPTEL_ECHO_AGGRESSIVE); +} + +static void echo_can_identify(char *buf, size_t len) +{ + strncpy(buf, "MARK3", len); +} + +static void echo_can_shutdown(void) +{ +} + static inline void echo_can_free(struct echo_can_state *ec) { FREE(ec); @@ -167,6 +167,20 @@ struct echo_can_state { }; +static void echo_can_init(void) +{ + printk("Zaptel Echo Canceller: MG2%s\n", ZAPTEL_ECHO_AGGRESSIVE); +} + +static void echo_can_identify(char *buf, size_t len) +{ + strncpy(buf, "MG2", len); +} + +static void echo_can_shutdown(void) +{ +} + static inline void init_cb_s(echo_can_cb_s *cb, int len, void *where) { cb->buf_d = (short *)where; @@ -101,6 +101,20 @@ static struct echo_can_state *echo_can_create(int len, int adaption_mode); static void echo_can_free(struct echo_can_state *ec); static int16_t echo_can_update(struct echo_can_state *ec, int16_t tx, int16_t rx); +static void echo_can_init(void) +{ + printk("Zaptel Echo Canceller: STEVE2%s\n", ZAPTEL_ECHO_AGGRESSIVE); +} + +static void echo_can_identify(char *buf, size_t len) +{ + strncpy(buf, "STEVE2", len); +} + +static void echo_can_shutdown(void) +{ +} + /* * According to Jim... */ @@ -100,6 +100,20 @@ struct echo_can_state was skipped, for test purposes */ }; +static void echo_can_init(void) +{ + printk("Zaptel Echo Canceller: STEVE%s\n", ZAPTEL_ECHO_AGGRESSIVE); +} + +static void echo_can_identify(char *buf, size_t len) +{ + strncpy(buf, "STEVE", len); +} + +static void echo_can_shutdown(void) +{ +} + static struct echo_can_state *echo_can_create(int len, int adaption_mode); static void echo_can_free(struct echo_can_state *ec); static int16_t echo_can_update(struct echo_can_state *ec, int16_t tx, int16_t rx); diff --git a/zaptel-base.c b/zaptel-base.c index c519310..a7686af 100644 --- a/zaptel-base.c +++ b/zaptel-base.c @@ -89,38 +89,6 @@ #include <linux/moduleparam.h> #endif -#ifdef AGGRESSIVE_SUPPRESSOR -#define ZAPTEL_ECHO_AGGRESSIVE " (aggressive)" -#else -#define ZAPTEL_ECHO_AGGRESSIVE -#endif - -#ifdef __KERNEL__ -/* Echo cancellation */ -#if defined(ECHO_CAN_STEVE) -#define ZAPTEL_ECHO_CANCELLER "STEVE" -#include "sec.h" -#elif defined(ECHO_CAN_STEVE2) -#define ZAPTEL_ECHO_CANCELLER "STEVE2" -#include "sec-2.h" -#elif defined(ECHO_CAN_MARK) -#define ZAPTEL_ECHO_CANCELLER "MARK" -#include "mec.h" -#elif defined(ECHO_CAN_MARK2) -#define ZAPTEL_ECHO_CANCELLER "MARK2" -#include "mec2.h" -#elif defined(ECHO_CAN_KB1) -#define ZAPTEL_ECHO_CANCELLER "KB1" -#include "kb1ec.h" -#elif defined(ECHO_CAN_MG2) -#define ZAPTEL_ECHO_CANCELLER "MG2" -#include "mg2ec.h" -#else -#define ZAPTEL_ECHO_CANCELLER "MARK3" -#include "mec3.h" -#endif -#endif - /* Get helper arithmetic */ #include "arith.h" #if defined(CONFIG_ZAPTEL_MMX) || defined(ECHO_CAN_FP) @@ -437,6 +405,31 @@ static struct zt_zone *tone_zones[ZT_TONE_ZONE_MAX]; #define NUM_SIGS 10 +#ifdef AGGRESSIVE_SUPPRESSOR +#define ZAPTEL_ECHO_AGGRESSIVE " (aggressive)" +#else +#define ZAPTEL_ECHO_AGGRESSIVE "" +#endif + +/* Echo cancellation */ +#if defined(ECHO_CAN_HPEC) +#include "hpec/hpec_zaptel.h" +#elif defined(ECHO_CAN_STEVE) +#include "sec.h" +#elif defined(ECHO_CAN_STEVE2) +#include "sec-2.h" +#elif defined(ECHO_CAN_MARK) +#include "mec.h" +#elif defined(ECHO_CAN_MARK2) +#include "mec2.h" +#elif defined(ECHO_CAN_KB1) +#include "kb1ec.h" +#elif defined(ECHO_CAN_MG2) +#include "mg2ec.h" +#else +#include "mec3.h" +#endif + static inline void rotate_sums(void) { /* Rotate where we sum and so forth */ @@ -3576,11 +3569,11 @@ static int zt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd case ZT_GETVERSION: memset(&vi, 0, sizeof(vi)); strncpy(vi.version, ZAPTEL_VERSION, sizeof(vi.version) - 1); - strncpy(vi.echo_canceller, ZAPTEL_ECHO_CANCELLER, sizeof(vi.echo_canceller) - 1); + echo_can_identify(vi.echo_canceller, sizeof(vi.echo_canceller) - 1); if (copy_to_user((struct zt_versioninfo *) data, &vi, sizeof(vi))) return -EFAULT; break; - case ZT_MAINT: /* do maintence stuff */ + case ZT_MAINT: /* do maintenance stuff */ /* get struct from user */ if (copy_from_user(&maint,(struct zt_maintinfo *) data, sizeof(maint))) return -EFAULT; @@ -3631,6 +3624,11 @@ static int zt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd return zt_dynamic_ioctl(cmd, data); } return -ENOSYS; +#if defined(ECHO_CAN_HPEC) + case ZT_EC_LICENSE_CHALLENGE: + case ZT_EC_LICENSE_RESPONSE: + return hpec_license_ioctl(cmd, data); +#endif /* defined(ECHO_CAN_HPEC) */ default: return zt_common_ioctl(inode, file, cmd, data, 0); } @@ -5704,11 +5702,22 @@ static inline void __zt_ec_chunk(struct zt_chan *ss, unsigned char *rxchunk, con rxchunk[x] = ZT_LIN2X((int)rxlin, ss); } } else { +#if !defined(ZT_EC_ARRAY_UPDATE) for (x=0;x<ZT_CHUNKSIZE;x++) { rxlin = ZT_XLAW(rxchunk[x], ss); rxlin = echo_can_update(ss->ec, ZT_XLAW(txchunk[x], ss), rxlin); - rxchunk[x] = ZT_LIN2X((int)rxlin, ss); + rxchunk[x] = ZT_LIN2X((int) rxlin, ss); } +#else /* defined(ZT_EC_ARRAY_UPDATE) */ + short rxlins[ZT_CHUNKSIZE], txlins[ZT_CHUNKSIZE]; + for (x = 0; x < ZT_CHUNKSIZE; x++) { + rxlins[x] = ZT_XLAW(rxchunk[x], ss); + txlins[x] = ZT_XLAW(txchunk[x], ss); + } + echo_can_array_update(ss->ec, rxlins, txlins); + for (x = 0; x < ZT_CHUNKSIZE; x++) + rxchunk[x] = ZT_LIN2X((int) rxlins[x], ss); +#endif /* defined(ZT_EC_ARRAY_UPDATE) */ } #if defined(CONFIG_ZAPTEL_MMX) || defined(ECHO_CAN_FP) kernel_fpu_end(); @@ -7002,8 +7011,8 @@ static int __init zt_init(void) { mfv1_tones_continuous[i].next = mfv1_tones_continuous + i; printk(KERN_INFO "Zapata Telephony Interface Registered on major %d\n", ZT_MAJOR); - printk(KERN_INFO "Zaptel Version: %s Echo Canceller: %s\n", ZAPTEL_VERSION, - ZAPTEL_ECHO_CANCELLER ZAPTEL_ECHO_AGGRESSIVE); + printk(KERN_INFO "Zaptel Version: %s\n", ZAPTEL_VERSION); + echo_can_init(); zt_conv_init(); tone_zone_init(); fasthdlc_precalc(); @@ -7060,6 +7069,8 @@ static void __exit zt_cleanup(void) { #ifdef CONFIG_ZAPTEL_WATCHDOG watchdog_cleanup(); #endif + + echo_can_shutdown(); } module_init(zt_init); @@ -1059,6 +1059,20 @@ struct zt_hdlc { }; #endif +/* Echo cancellation */ +struct echo_can_state; +#if 0 +/* echo can API consists of these functions */ +void echo_can_init(void); +void echo_chan_shutdown(void); +void echo_can_identify(char *buf, size_t len); +struct echo_can_state *echo_can_create(int len, int adaption_mode); +void echo_can_free(struct echo_can_state *ec); +short echo_can_update(struct echo_can_state *ec, short iref, short isig); +void echo_can_array_update(struct echo_can_state *ec, short *iref, short *isig); +int echo_can_traintap(struct echo_can_state *ec, int pos, short val); +#endif + /* Conference queue stucture */ struct confq { u_char buffer[ZT_CHUNKSIZE * ZT_CB_SIZE]; |