summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hpec/hpec_zaptel.h5
-rw-r--r--kb1ec.h14
-rw-r--r--mec.h14
-rw-r--r--mec2.h16
-rw-r--r--mec3.h14
-rw-r--r--mg2ec.h14
-rw-r--r--sec-2.h14
-rw-r--r--sec.h14
-rw-r--r--zaptel-base.c85
-rw-r--r--zaptel.h14
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();
diff --git a/kb1ec.h b/kb1ec.h
index 7fbede0..e0f63f6 100644
--- a/kb1ec.h
+++ b/kb1ec.h
@@ -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;
diff --git a/mec.h b/mec.h
index 79d9595..09421cd 100644
--- a/mec.h
+++ b/mec.h
@@ -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;
diff --git a/mec2.h b/mec2.h
index b15a768..98061ff 100644
--- a/mec2.h
+++ b/mec2.h
@@ -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;
diff --git a/mec3.h b/mec3.h
index c1ceaef..6de41f5 100644
--- a/mec3.h
+++ b/mec3.h
@@ -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);
diff --git a/mg2ec.h b/mg2ec.h
index a1d691e..84d9144 100644
--- a/mg2ec.h
+++ b/mg2ec.h
@@ -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;
diff --git a/sec-2.h b/sec-2.h
index c54836f..a8fed80 100644
--- a/sec-2.h
+++ b/sec-2.h
@@ -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...
*/
diff --git a/sec.h b/sec.h
index 0a05698..f795e4c 100644
--- a/sec.h
+++ b/sec.h
@@ -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);
diff --git a/zaptel.h b/zaptel.h
index b5dabec..59d6bac 100644
--- a/zaptel.h
+++ b/zaptel.h
@@ -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];