summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-02-01 00:55:41 +0000
committerkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-02-01 00:55:41 +0000
commit13179eb2fc4b2384550a1681513986584634bfd6 (patch)
tree5e450b5b4ef50a7dfb8268e75d04785ab0adc13e
parent7976f3ed8ba610c565d4cd80a7f8c0643005de49 (diff)
add support for Digium's High Performance Echo Canceller
rework the top-level Makefile so kernel 2.6 modules are built by a dedicated Makefile git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2076 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rw-r--r--Makefile176
-rw-r--r--Makefile.kernel2625
-rwxr-xr-xbuild_tools/make_svn_branch_name14
-rw-r--r--hpec/hpec.h47
-rw-r--r--hpec/hpec_user.h40
-rw-r--r--hpec/hpec_zaptel.h128
-rw-r--r--kb1ec.h31
-rw-r--r--mec.h25
-rw-r--r--mec2.h31
-rw-r--r--mec3.h27
-rw-r--r--mg2ec.h31
-rw-r--r--sec-2.h33
-rw-r--r--sec.h31
-rw-r--r--tor2.c2
-rw-r--r--wct1xxp.c2
-rw-r--r--wct4xxp/Makefile2
-rw-r--r--wct4xxp/Makefile.kernel26 (renamed from wct4xxp/Kbuild)0
-rw-r--r--wctc4xxp/Makefile2
-rw-r--r--wctc4xxp/Makefile.kernel26 (renamed from wctc4xxp/Kbuild)0
-rw-r--r--zaptel-base.c (renamed from zaptel.c)58
-rw-r--r--zaptel.h50
-rw-r--r--zconfig.h2
22 files changed, 558 insertions, 199 deletions
diff --git a/Makefile b/Makefile
index b6e139c..f25edba 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,17 @@
#
# Makefile for Zaptel driver modules and utilities
#
-# Copyright (C) 2001-2006 Digium, Inc.
+# Copyright (C) 2001-2007 Digium, Inc.
#
#
+CFLAGS+=-DSTANDALONE_ZAPATA -DBUILDING_TONEZONE
-HOSTCC=gcc
+ifeq ($(MAKELEVEL),0)
PWD:=$(shell pwd)
+endif
-INSTALL_PREFIX:=$(DESTDIR)
+ARCH:=$(shell uname -m | sed -e s/i.86/i386/)
# If you want to build for a kernel other than the current kernel, set KVERS
ifndef KVERS
@@ -25,7 +27,69 @@ ifndef KSRC
endif
KINCLUDES:=$(KSRC)/include
-CFLAGS+=-I. -O4 -g -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER
+ifeq (2.6,$(shell echo $(KVERS) | cut -d. -f1-2))
+ BUILDVER:=linux26
+else
+ BUILDVER:=linux24
+endif
+
+ifeq ($(BUILDVER),linux26)
+ ifneq (,$(wildcard $(INSTALL_PREFIX)/etc/udev/rules.d))
+ DYNFS=yes
+ UDEVRULES=yes
+ endif
+ HOTPLUG_FIRMWARE:=$(shell if grep CONFIG_FW_LOADER $(KINCLUDES)/linux/autoconf.h | grep -q undef; then echo "no"; else echo "yes"; fi)
+endif
+
+# Set this to override hotplug firmware loading and revert to embedded firmware
+HOTPLUG_FIRMWARE?=yes
+
+ifeq ($(HOTPLUG_FIRMWARE),yes)
+ CFLAGS+=-DHOTPLUG_FIRMWARE
+endif
+
+MODULES:=zaptel tor2 torisa wcusb wcfxo wctdm wctdm24xxp \
+ ztdynamic ztd-eth wct1xxp wcte11xp pciradio \
+ ztd-loc # ztdummy
+#MODULES+=wcfxsusb
+ifeq ($(BUILDVER),linux26)
+MODULES+=ztdummy zttranscode
+endif
+MODULE_ALIASES=wcfxs wctdm8xxp wct2xxp
+
+MODULESO:=$(MODULES:%=%.o)
+MODULESKO:=$(MODULES:%=%.ko)
+
+# add this later, so it doesn't become part of MODULESO/MODULESKO
+MODULES+=wct4xxp wctc4xxp
+
+ifeq ($(ARCH),i386)
+ifneq ($(wildcard $(PWD)/hpec/hpec_x86_32.o_shipped),)
+HPEC_PRESENT=yes
+endif
+endif
+
+ifeq ($(ARCH),x86_64)
+ifneq ($(wildcard $(PWD)/hpec/hpec_x86_64.o_shipped),)
+HPEC_PRESENT=yes
+endif
+endif
+
+#NOTE NOTE NOTE
+#
+# all variables set before the include of Kbuild are needed by the 2.6 kernel module build process
+
+ifneq ($(KBUILD_EXTMOD),)
+
+include $(src)/Makefile.kernel26
+
+else
+
+HOSTCC=gcc
+
+INSTALL_PREFIX:=$(DESTDIR)
+
+CFLAGS+=-I. -O4 -g -Wall
CFLAGS_PPC:=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
CFLAGS_X86-64:=$(shell if uname -m | grep -q x86_64; then echo "-m64"; fi)
CFLAGS+=$(CFLAGS_PPC) $(CFLAGS_X86-64)
@@ -45,32 +109,17 @@ KFLAGS+=$(shell if uname -r | grep -q 2.4; then if uname -m | grep -q x86_64; th
#
KFLAGS+=-DSTANDALONE_ZAPATA
-CFLAGS+=-DSTANDALONE_ZAPATA
KMAKE:= $(MAKE) -C $(KSRC) SUBDIRS=$(PWD)
KMAKE_INST:= $(KMAKE) INSTALL_MOD_PATH=$(INSTALL_PREFIX) INSTALL_MOD_DIR=misc modules_install
CONFIG_FILE:=$(INSTALL_PREFIX)/etc/zaptel.conf
CFLAGS+=-DZAPTEL_CONFIG=\"$(CONFIG_FILE)\"
-ifeq (2.6,$(shell echo $(KVERS) | cut -d. -f1-2))
- BUILDVER:=linux26
-else
- BUILDVER:=linux24
-endif
-
ifeq ($(BUILDVER),linux24)
#We only support DEVFS in linux 2.4 kernels, since its considered obsolete post 2.4
DYNFS:=$(shell ps ax | grep -v grep | grep -q devfsd && echo "yes")
endif
-ifeq ($(BUILDVER),linux26)
- ifneq (,$(wildcard $(INSTALL_PREFIX)/etc/udev/rules.d))
- DYNFS=yes
- UDEVRULES=yes
- endif
- HOTPLUG_FIRMWARE:=$(shell if grep CONFIG_FW_LOADER $(KINCLUDES)/linux/autoconf.h | grep -q undef; then echo "no"; else echo "yes"; fi)
-endif
-
CHKCONFIG:=$(shell sh -c 'type -p chkconfig' 2> /dev/null)
ifndef CHKCONFIG
CHKCONFIG:=:
@@ -80,22 +129,8 @@ ifneq ($(wildcard .version),)
ZAPTELVERSION:=$(shell cat .version)
endif
-# Set this to override hotplug firmware loading and revert to classic header based
-#HOTPLUG_FIRMWARE=no
-
-ifeq ($(HOTPLUG_FIRMWARE),yes)
- CFLAGS+=-DHOTPLUG_FIRMWARE
-endif
-
-# CVS mirrors of SVN have .svnrevision files showing
-# which SVN revision they are based on, and .svnbranch
-# showing the branch they are made from
-ifneq ($(wildcard .svnrevision),)
- ZAPTELVERSION:=SVN-$(shell cat .svnbranch)-r$(shell cat .svnrevision)
-else
- ifneq ($(wildcard .svn),)
- ZAPTELVERSION=SVN-$(shell build_tools/make_svn_branch_name)
- endif
+ifneq ($(wildcard .svn),)
+ ZAPTELVERSION=SVN-$(shell build_tools/make_svn_branch_name)
endif
TZOBJS:=zonedata.lo tonezone.lo
@@ -103,53 +138,42 @@ LIBTONEZONE_SO:=libtonezone.so
LIBTONEZONE_SO_MAJOR_VER:=1
LIBTONEZONE_SO_MINOR_VER:=0
-MODULES:=zaptel tor2 torisa wcusb wcfxo wctdm wctdm24xxp \
- ztdynamic ztd-eth wct1xxp wcte11xp pciradio \
- ztd-loc # ztdummy
-#MODULES+=wcfxsusb
-ifeq ($(BUILDVER),linux26)
-MODULES+=ztdummy zttranscode
-endif
-MODULE_ALIASES=wcfxs wctdm8xxp wct2xxp
-
-MODULESO:=$(MODULES:%=%.o)
-MODULESKO:=$(MODULES:%=%.ko)
-
MOD_DESTDIR:=zaptel
-obj-m:=$(MODULESO)
-obj-m+=wct4xxp/ wctc4xxp/
-MODULES+=wct4xxp wctc4xxp
-
-# Also build xpp in the subdirectory xpp/ . But only for >=2.6.10 and only
-# for i386. On other archs the module will probably build but panic.
-# This line is only meaningful when this Makefile is used as kconfig for
-# 2.6 build
+BINS=ztcfg torisatool makefw ztmonitor ztspeed zttest fxotune
+ifneq (,$(wildcard /usr/include/newt.h))
+BINS+=zttool
+endif
-ifneq (,$(shell [ 0$(SUBLEVEL) -ge 8 ] && echo 1))
-obj-m+=xpp/
+ifeq ($(BUILDVER),linux24)
+all: prereq $(MODULESO) wct4xxp/wct4xxp.o $(BINS) $(LIBTONEZONE_SO)
endif
-ifneq (,$(wildcard /usr/include/newt.h))
-ZTTOOL:=zttool
+ifeq ($(BUILDVER),linux26)
+all: prereq $(BINS) $(LIBTONEZONE_SO)
+ @if [ -z "$(KSRC)" -o ! -d "$(KSRC)" ]; then echo "You do not appear to have the sources for the $(KVERS) kernel installed."; exit 1 ; fi
+ $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) HOTPLUG_FIRMWARE=$(HOTPLUG_FIRMWARE) modules
endif
-BINS=ztcfg torisatool makefw ztmonitor ztspeed $(ZTTOOL) zttest fxotune
-all: $(BUILDVER) $(LIBTONEZONE_SO)
+ifeq ($(HPEC_PRESENT),yes)
+ifeq ($(ARCH),i386)
+ZAPTEL_HPEC:=hpec/hpec_x86_32.o_shipped
+endif
-linux24: prereq $(MODULESO) wct4xxp/wct4xxp.o $(BINS)
+ifeq ($(ARCH),x86_64)
+ZAPTEL_HPEC:=hpec/hpec_x86_64.o_shipped
+endif
-linux26: prereq $(BINS)
- @echo $(KSRC)
- @if [ -z "$(KSRC)" -o ! -d "$(KSRC)" ]; then echo "You do not appear to have the sources for the $(KVERS) kernel installed."; exit 1 ; fi
- $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) HOTPLUG_FIRMWARE=$(HOTPLUG_FIRMWARE) modules
+CFLAGS+=-DECHO_CAN_HPEC -I$(PWD)/hpec
+zaptel-base.o: hpec/hpec_zaptel.h hpec/hpec_user.h
+endif
version.h: FORCE
- ZAPTELVERSION="${ZAPTELVERSION}" build_tools/make_version_h > $@.tmp
- if cmp -s $@.tmp $@ ; then echo; else \
+ @ZAPTELVERSION="${ZAPTELVERSION}" build_tools/make_version_h > $@.tmp
+ @if cmp -s $@.tmp $@ ; then echo; else \
mv $@.tmp $@ ; \
fi
- rm -f $@.tmp
+ @rm -f $@.tmp
wct4xxp/wct4xxp.o:
$(MAKE) -C wct4xxp KFLAGS="$(KFLAGS) -I.." CFLAGS="$(CFLAGS) -I.."
@@ -159,9 +183,11 @@ devel: tor2ee
tests: patgen pattest patlooptest hdlcstress hdlctest hdlcgen hdlcverify timertest
$(MAKE) -C wctc4xxp tests CFLAGS="$(CFLAGS) -I.."
+$(MODULESO): zaptel.h
+
tor2.o: tor2-hw.h tor2fw.h
-zaptel.o: digits.h arith.h sec.h mec.h sec-2.h mec2.h mec3.h zconfig.h version.h
+zaptel-base.o: digits.h arith.h sec.h sec-2.h mec.h mec2.h mec3.h mg2ec.h kb1ec.h zconfig.h version.h tones.h
torisa.o: torisa.h
@@ -177,7 +203,10 @@ pciradio.o: radfw.h
ztdummy.o: ztdummy.h
-$(MODULESO): %.o: %.c zaptel.h
+zaptel.o: zaptel-base.o $(ZAPTEL_HPEC)
+ $(LD) -r -o $@ $< $(ZAPTEL_HPEC)
+
+$(filter-out zaptel.o,$(MODULESO)) zaptel-base.o: %.o: %.c
$(CC) $(KFLAGS) -o $@ -c $<
tor2ee.o: tor2-hw.h
@@ -206,8 +235,6 @@ radfw.h: makefw pciradio.rbt
gendigits: gendigits.o
$(CC) -o $@ $^ -lm
-zaptel.c: tones.h
-
prereq: tones.h tor2fw.h radfw.h version.h
zttool.o: zttool.c zaptel.h
@@ -428,3 +455,6 @@ clean:
rm -rf mISDNuser*
FORCE:
+
+endif
+
diff --git a/Makefile.kernel26 b/Makefile.kernel26
new file mode 100644
index 0000000..f119368
--- /dev/null
+++ b/Makefile.kernel26
@@ -0,0 +1,25 @@
+obj-m := $(MODULESO)
+obj-m += wct4xxp/ wctc4xxp/
+
+# Also build xpp in the subdirectory xpp/ . But only for >=2.6.10 and only
+# for i386. On other archs the module will probably build but panic.
+
+ifneq (,$(shell [ 0$(SUBLEVEL) -ge 8 ] && [ "$(ARCH)" = 'i386' ] && echo 1))
+obj-m += xpp/
+endif
+
+EXTRA_CFLAGS := -I$(src)
+
+zaptel-objs := zaptel-base.o
+
+ifeq ($(HPEC_PRESENT),yes)
+ifeq ($(ARCH),i386)
+zaptel-objs += hpec/hpec_x86_32.o
+endif
+
+ifeq ($(ARCH),x86_64)
+zaptel-objs += hpec/hpec_x86_64.o
+endif
+
+EXTRA_CFLAGS += -DECHO_CAN_HPEC -I$(src)/hpec
+endif
diff --git a/build_tools/make_svn_branch_name b/build_tools/make_svn_branch_name
index 1fe7507..525d282 100755
--- a/build_tools/make_svn_branch_name
+++ b/build_tools/make_svn_branch_name
@@ -1,6 +1,7 @@
#!/bin/sh
PARTS=`LANG=C svn info | grep URL | awk '{print $2;}' | sed -e s:^.*/svn/zaptel/:: | sed -e 's:/: :g'`
+BETA=0
BRANCH=0
TEAM=0
@@ -14,6 +15,12 @@ fi
for PART in $PARTS
do
+ if [ ${BETA} != 0 ]
+ then
+ RESULT="${RESULT}-${PART}"
+ break
+ fi
+
if [ ${BRANCH} != 0 ]
then
RESULT="${RESULT}-${PART}"
@@ -26,6 +33,13 @@ do
continue
fi
+ if [ "${PART}" = "betas" ]
+ then
+ BETA=1
+ RESULT="beta"
+ continue
+ fi
+
if [ "${PART}" = "branches" ]
then
BRANCH=1
diff --git a/hpec/hpec.h b/hpec/hpec.h
new file mode 100644
index 0000000..7e90f12
--- /dev/null
+++ b/hpec/hpec.h
@@ -0,0 +1,47 @@
+/*
+ * Zapata Telephony Interface to Digium High-Performance Echo Canceller
+ *
+ * Copyright (C) 2006 Digium, Inc.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#if !defined(_HPEC_H)
+#define _HPEC_H
+
+struct echo_can_state;
+
+void __attribute__((regparm(0))) hpec_init(int __attribute__((regparm(0))) __attribute__((format (printf, 1, 2))) (*logger)(const char *format, ...),
+ unsigned int debug,
+ unsigned int chunk_size,
+ void * (*memalloc)(size_t len),
+ void (*memfree)(void *ptr));
+
+void __attribute__((regparm(0))) hpec_shutdown(void);
+
+int __attribute__((regparm(0))) hpec_license_challenge(struct hpec_challenge *challenge);
+
+int __attribute__((regparm(0))) hpec_license_check(struct hpec_license *license);
+
+struct echo_can_state __attribute__((regparm(0))) *hpec_channel_alloc(unsigned int len);
+
+void __attribute__((regparm(0))) hpec_channel_free(struct echo_can_state *channel);
+
+void __attribute__((regparm(0))) hpec_channel_update(struct echo_can_state *channel, short *iref, short *isig);
+
+#endif /* !defined(_HPEC_H) */
+
diff --git a/hpec/hpec_user.h b/hpec/hpec_user.h
new file mode 100644
index 0000000..bf006eb
--- /dev/null
+++ b/hpec/hpec_user.h
@@ -0,0 +1,40 @@
+/*
+ * Zapata Telephony Interface to Digium High-Performance Echo Canceller
+ *
+ * Copyright (C) 2006 Digium, Inc.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#if !defined(_HPEC_USER_H)
+#define _HPEC_USER_H
+
+struct hpec_challenge {
+ __u8 challenge[16];
+};
+
+struct hpec_license {
+ __u32 numchannels;
+ __u8 userinfo[256];
+ __u8 response[16];
+};
+
+#define ZT_EC_LICENSE_CHALLENGE _IOR(ZT_CODE, 60, struct hpec_challenge)
+#define ZT_EC_LICENSE_RESPONSE _IOW(ZT_CODE, 61, struct hpec_license)
+
+#endif /* !defined(_HPEC_USER_H) */
+
diff --git a/hpec/hpec_zaptel.h b/hpec/hpec_zaptel.h
new file mode 100644
index 0000000..1de9a85
--- /dev/null
+++ b/hpec/hpec_zaptel.h
@@ -0,0 +1,128 @@
+/*
+ * Zapata Telephony Interface to Digium High-Performance Echo Canceller
+ *
+ * Copyright (C) 2006 Digium, Inc.
+ *
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#if !defined(_HPEC_ZAPTEL_H)
+#define _HPEC_ZAPTEL_H
+
+#define ZT_EC_ARRAY_UPDATE
+
+#include "hpec_user.h"
+#include "hpec.h"
+
+static int __attribute__((regparm(0))) __attribute__((format (printf, 1, 2))) logger(const char *format, ...)
+{
+ int res;
+ va_list args;
+
+ va_start(args, format);
+ res = vprintk(format, args);
+ va_end(args);
+
+ return res;
+}
+
+static void *memalloc(size_t len)
+{
+ return kmalloc(len, GFP_KERNEL);
+}
+
+static void memfree(void *ptr)
+{
+ kfree(ptr);
+}
+
+static void echo_can_init(void)
+{
+ printk("Zaptel Echo Canceller: Digium High-Performance Echo Canceller\n");
+ hpec_init(logger, debug, ZT_CHUNKSIZE, memalloc, memfree);
+}
+
+static void echo_can_shutdown(void)
+{
+ hpec_shutdown();
+}
+
+static inline void echo_can_free(struct echo_can_state *ec)
+{
+ hpec_channel_free(ec);
+}
+
+static inline void echo_can_array_update(struct echo_can_state *ec, short *iref, short *isig)
+{
+ hpec_channel_update(ec, iref, isig);
+}
+
+DECLARE_MUTEX(alloc_lock);
+
+static inline struct echo_can_state *echo_can_create(int len, int adaption_mode)
+{
+ struct echo_can_state *result = NULL;
+
+ if (down_interruptible(&alloc_lock))
+ return NULL;
+
+ result = hpec_channel_alloc(len);
+
+ up(&alloc_lock);
+
+ return result;
+}
+
+static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)
+{
+ return 0;
+}
+
+DECLARE_MUTEX(license_lock);
+
+static int hpec_license_ioctl(unsigned int cmd, unsigned long data)
+{
+ struct hpec_challenge challenge;
+ struct hpec_license license;
+ int result = 0;
+
+ switch (cmd) {
+ case ZT_EC_LICENSE_CHALLENGE:
+ if (down_interruptible(&license_lock))
+ return -EINTR;
+ memset(&challenge, 0, sizeof(challenge));
+ if (hpec_license_challenge(&challenge))
+ result = -ENODEV;
+ if (!result && copy_to_user((unsigned char *) data, &challenge, sizeof(challenge)))
+ result = -EFAULT;
+ up(&license_lock);
+ return result;
+ case ZT_EC_LICENSE_RESPONSE:
+ if (down_interruptible(&license_lock))
+ return -EINTR;
+ if (copy_from_user(&license, (unsigned char *) data, sizeof(license)))
+ result = -EFAULT;
+ if (!result && hpec_license_check(&license))
+ result = -EACCES;
+ up(&license_lock);
+ return result;
+ default:
+ return -ENOSYS;
+ }
+}
+
+#endif /* !defined(_HPEC_ZAPTEL_H) */
diff --git a/kb1ec.h b/kb1ec.h
index 5d614a8..b9e1cd9 100644
--- a/kb1ec.h
+++ b/kb1ec.h
@@ -74,7 +74,7 @@ typedef struct {
} echo_can_cb_s;
/* Echo canceller definition */
-typedef struct {
+struct echo_can_state {
/* an arbitrary ID for this echo can - this really should be settable from the calling channel... */
int id;
@@ -139,7 +139,16 @@ typedef struct {
int avg_Lu_i_ok;
#endif
-} echo_can_state_t;
+};
+
+static void echo_can_init(void)
+{
+ printk("Zaptel Echo Canceller: KB1%s\n", ZAPTEL_ECHO_AGGRESSIVE);
+}
+
+static void echo_can_shutdown(void)
+{
+}
static inline void init_cb_s(echo_can_cb_s *cb, int len, void *where)
{
@@ -167,13 +176,13 @@ static inline short get_cc_s(echo_can_cb_s *cb, int pos)
return cb->buf_d[cb->idx_d + pos];
}
-static inline void init_cc(echo_can_state_t *ec, int N, int maxy, int maxu)
+static inline void init_cc(struct echo_can_state *ec, int N, int maxy, int maxu)
{
void *ptr = ec;
unsigned long tmp;
/* Double-word align past end of state */
- ptr += sizeof(echo_can_state_t);
+ ptr += sizeof(struct echo_can_state);
tmp = (unsigned long)ptr;
tmp += 3;
tmp &= ~3L;
@@ -232,12 +241,12 @@ static inline void init_cc(echo_can_state_t *ec, int N, int maxy, int maxu)
}
-static inline void echo_can_free(echo_can_state_t *ec)
+static inline void echo_can_free(struct echo_can_state *ec)
{
FREE(ec);
}
-static inline short echo_can_update(echo_can_state_t *ec, short iref, short isig)
+static inline short echo_can_update(struct echo_can_state *ec, short iref, short isig)
{
/* Declare local variables that are used more than once */
@@ -515,9 +524,9 @@ static inline short echo_can_update(echo_can_state_t *ec, short iref, short isig
return u;
}
-static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
+static inline struct echo_can_state *echo_can_create(int len, int adaption_mode)
{
- echo_can_state_t *ec;
+ struct echo_can_state *ec;
int maxy;
int maxu;
maxy = len + DEFAULT_M;
@@ -528,7 +537,7 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
maxy = (1 << DEFAULT_SIGMA_LY_I);
if (maxu < (1 << DEFAULT_SIGMA_LU_I))
maxu = (1 << DEFAULT_SIGMA_LU_I);
- ec = (echo_can_state_t *)MALLOC(sizeof(echo_can_state_t) +
+ ec = (struct echo_can_state *)MALLOC(sizeof(struct echo_can_state) +
4 + /* align */
sizeof(int) * len + /* a_i */
sizeof(short) * len + /* a_s */
@@ -537,7 +546,7 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
2 * sizeof(short) * (maxu) + /* u_s */
2 * sizeof(short) * len); /* y_tilde_s */
if (ec) {
- memset(ec, 0, sizeof(echo_can_state_t) +
+ memset(ec, 0, sizeof(struct echo_can_state) +
4 + /* align */
sizeof(int) * len + /* a_i */
sizeof(short) * len + /* a_s */
@@ -550,7 +559,7 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
return ec;
}
-static inline int echo_can_traintap(echo_can_state_t *ec, int pos, short val)
+static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)
{
/* Set the hangover counter to the length of the can to
* avoid adjustments occuring immediately after initial forced training
diff --git a/mec.h b/mec.h
index f399e1b..51c8bbe 100644
--- a/mec.h
+++ b/mec.h
@@ -53,7 +53,7 @@
#define HANG_T 600 /* 600 samples, or 75ms */
-typedef struct mark_ec {
+struct echo_can_state {
/* Circular position */
int cpos;
short y[NUM_TAPS]; /* Last N samples (relative to cpos) transmitted */
@@ -80,7 +80,7 @@ typedef struct mark_ec {
int lastmax; /* Optimize maximum search */
int maxTy; /* Maximum Ty */
-} echo_can_state_t;
+};
#define INLINE inline
@@ -98,11 +98,20 @@ typedef struct mark_ec {
#define FREE(a) free(a)
#endif
-static INLINE echo_can_state_t *echo_can_create(int len, int adaption_mode)
+static void echo_can_init(void)
{
- echo_can_state_t *ec;
+ printk("Zaptel Echo Canceller: MARK%s\n", ZAPTEL_ECHO_AGGRESSIVE);
+}
+
+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;
/* Uhm, we're only one length, sorry. */
- ec = MALLOC(sizeof(echo_can_state_t));
+ ec = MALLOC(sizeof(struct echo_can_state));
if (ec)
memset(ec, 0, sizeof(*ec));
return ec;
@@ -111,12 +120,12 @@ static INLINE echo_can_state_t *echo_can_create(int len, int adaption_mode)
#define PASSPOS 32000
#undef PASSPOS
-static INLINE void echo_can_free(echo_can_state_t *ec)
+static INLINE void echo_can_free(struct echo_can_state *ec)
{
FREE(ec);
}
-static INLINE int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx)
+static INLINE int16_t echo_can_update(struct echo_can_state *ec, int16_t tx, int16_t rx)
{
/* Process a sample, where tx is the near end and rx is the far end + echo */
@@ -292,7 +301,7 @@ static INLINE int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t
return suppr;
}
-static inline int echo_can_traintap(echo_can_state_t *ec, int pos, short val)
+static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)
{
/* Reset hang counter to avoid adjustments after
initial forced training */
diff --git a/mec2.h b/mec2.h
index c539cfd..0df7f6a 100644
--- a/mec2.h
+++ b/mec2.h
@@ -51,7 +51,7 @@ typedef struct {
// class definition
//
-typedef struct {
+struct echo_can_state {
/* Echo canceller definition */
/* absolute time */
@@ -86,7 +86,16 @@ typedef struct {
short max_y_tilde;
int max_y_tilde_pos;
-} echo_can_state_t;
+};
+
+static void echo_can_init(void)
+{
+ printk("Zaptel Echo Canceller: MARK2%s\n", ZAPTEL_ECHO_AGGRESSIVE);
+}
+
+static void echo_can_shutdown(void)
+{
+}
static inline void init_cb_s(echo_can_cb_s *cb, int len, void *where)
{
@@ -112,12 +121,12 @@ static inline short get_cc_s(echo_can_cb_s *cb, int pos)
return cb->buf_d[cb->idx_d + pos];
}
-static inline void init_cc(echo_can_state_t *ec, int N, int maxy, int maxu) {
+static inline void init_cc(struct echo_can_state *ec, int N, int maxy, int maxu) {
void *ptr = ec;
unsigned long tmp;
/* double-word align past end of state */
- ptr += sizeof(echo_can_state_t);
+ ptr += sizeof(struct echo_can_state);
tmp = (unsigned long)ptr;
tmp += 3;
tmp &= ~3L;
@@ -170,12 +179,12 @@ static inline void init_cc(echo_can_state_t *ec, int N, int maxy, int maxu) {
//
}
-static inline void echo_can_free(echo_can_state_t *ec)
+static inline void echo_can_free(struct echo_can_state *ec)
{
FREE(ec);
}
-static inline short echo_can_update(echo_can_state_t *ec, short iref, short isig) {
+static inline short echo_can_update(struct echo_can_state *ec, short iref, short isig) {
/* declare local variables that are used more than once
*/
@@ -370,9 +379,9 @@ static inline short echo_can_update(echo_can_state_t *ec, short iref, short isig
return u;
}
-static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
+static inline struct echo_can_state *echo_can_create(int len, int adaption_mode)
{
- echo_can_state_t *ec;
+ struct echo_can_state *ec;
int maxy;
int maxu;
maxy = len + DEFAULT_M;
@@ -383,7 +392,7 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
maxy = (1 << DEFAULT_SIGMA_LY_I);
if (maxu < (1 << DEFAULT_SIGMA_LU_I))
maxu = (1 << DEFAULT_SIGMA_LU_I);
- ec = (echo_can_state_t *)MALLOC(sizeof(echo_can_state_t) +
+ ec = (struct echo_can_state *)MALLOC(sizeof(struct echo_can_state) +
4 + /* align */
sizeof(int) * len + /* a_i */
sizeof(short) * len + /* a_s */
@@ -392,7 +401,7 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
2 * sizeof(short) * (maxu) + /* u_s */
2 * sizeof(short) * len); /* y_tilde_s */
if (ec) {
- memset(ec, 0, sizeof(echo_can_state_t) +
+ memset(ec, 0, sizeof(struct echo_can_state) +
4 + /* align */
sizeof(int) * len + /* a_i */
sizeof(short) * len + /* a_s */
@@ -405,7 +414,7 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
return ec;
}
-static inline int echo_can_traintap(echo_can_state_t *ec, int pos, short val)
+static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)
{
/* Reset hang counter to avoid adjustments after
initial forced training */
diff --git a/mec3.h b/mec3.h
index e28c66b..b5cb56f 100644
--- a/mec3.h
+++ b/mec3.h
@@ -69,7 +69,7 @@ typedef struct {
int maxexp;
} cbuf_s;
-typedef struct {
+struct echo_can_state {
short a_s[NTAPS]; /* Coefficients in shorts */
int a_i[NTAPS]; /* Coefficients in ints*/
#ifdef DO_BACKUP
@@ -85,9 +85,18 @@ typedef struct {
int hcntr; /* Hangtime counter */
int pos; /* Position in curcular buffers */
int backup; /* Backup timer */
-} echo_can_state_t;
+};
+
+static void echo_can_init(void)
+{
+ printk("Zaptel Echo Canceller: MARK3%s\n", ZAPTEL_ECHO_AGGRESSIVE);
+}
+
+static void echo_can_shutdown(void)
+{
+}
-static inline void echo_can_free(echo_can_state_t *ec)
+static inline void echo_can_free(struct echo_can_state *ec)
{
FREE(ec);
}
@@ -114,7 +123,7 @@ static inline void buf_add(cbuf_s *b, short sample, int pos, int taps)
}
}
-static inline short echo_can_update(echo_can_state_t *ec, short ref, short sig)
+static inline short echo_can_update(struct echo_can_state *ec, short ref, short sig)
{
int x;
short u;
@@ -204,15 +213,15 @@ static inline short echo_can_update(echo_can_state_t *ec, short ref, short sig)
return u;
}
-static inline echo_can_state_t *echo_can_create(int taps, int adaption_mode)
+static inline struct echo_can_state *echo_can_create(int taps, int adaption_mode)
{
- echo_can_state_t *ec;
+ struct echo_can_state *ec;
int x;
taps = NTAPS;
- ec = MALLOC(sizeof(echo_can_state_t));
+ ec = MALLOC(sizeof(struct echo_can_state));
if (ec) {
- memset(ec, 0, sizeof(echo_can_state_t));
+ memset(ec, 0, sizeof(struct echo_can_state));
ec->taps = taps;
ec->pos = ec->taps-1;
for (x=0;x<31;x++) {
@@ -225,7 +234,7 @@ static inline echo_can_state_t *echo_can_create(int taps, int adaption_mode)
return ec;
}
-static inline int echo_can_traintap(echo_can_state_t *ec, int pos, short val)
+static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)
{
/* Reset hang counter to avoid adjustments after
initial forced training */
diff --git a/mg2ec.h b/mg2ec.h
index 84f3f10..5e634c0 100644
--- a/mg2ec.h
+++ b/mg2ec.h
@@ -76,7 +76,7 @@ typedef struct {
} echo_can_cb_s;
/* Echo canceller definition */
-typedef struct {
+struct echo_can_state {
/* an arbitrary ID for this echo can - this really should be settable from the calling channel... */
int id;
@@ -143,7 +143,16 @@ typedef struct {
short lastsig[256];
int lastpos;
-} echo_can_state_t;
+};
+
+static void echo_can_init(void)
+{
+ printk("Zaptel Echo Canceller: MG2%s\n", ZAPTEL_ECHO_AGGRESSIVE);
+}
+
+static void echo_can_shutdown(void)
+{
+}
static inline void init_cb_s(echo_can_cb_s *cb, int len, void *where)
{
@@ -171,13 +180,13 @@ static inline short get_cc_s(echo_can_cb_s *cb, int pos)
return cb->buf_d[cb->idx_d + pos];
}
-static inline void init_cc(echo_can_state_t *ec, int N, int maxy, int maxu)
+static inline void init_cc(struct echo_can_state *ec, int N, int maxy, int maxu)
{
void *ptr = ec;
unsigned long tmp;
/* Double-word align past end of state */
- ptr += sizeof(echo_can_state_t);
+ ptr += sizeof(struct echo_can_state);
tmp = (unsigned long)ptr;
tmp += 3;
tmp &= ~3L;
@@ -236,12 +245,12 @@ static inline void init_cc(echo_can_state_t *ec, int N, int maxy, int maxu)
}
-static inline void echo_can_free(echo_can_state_t *ec)
+static inline void echo_can_free(struct echo_can_state *ec)
{
FREE(ec);
}
-static inline short echo_can_update(echo_can_state_t *ec, short iref, short isig)
+static inline short echo_can_update(struct echo_can_state *ec, short iref, short isig)
{
/* Declare local variables that are used more than once */
@@ -556,9 +565,9 @@ static inline short echo_can_update(echo_can_state_t *ec, short iref, short isig
return u;
}
-static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
+static inline struct echo_can_state *echo_can_create(int len, int adaption_mode)
{
- echo_can_state_t *ec;
+ struct echo_can_state *ec;
int maxy;
int maxu;
maxy = len + DEFAULT_M;
@@ -569,7 +578,7 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
maxy = (1 << DEFAULT_SIGMA_LY_I);
if (maxu < (1 << DEFAULT_SIGMA_LU_I))
maxu = (1 << DEFAULT_SIGMA_LU_I);
- ec = (echo_can_state_t *)MALLOC(sizeof(echo_can_state_t) +
+ ec = (struct echo_can_state *)MALLOC(sizeof(struct echo_can_state) +
4 + /* align */
sizeof(int) * len + /* a_i */
sizeof(short) * len + /* a_s */
@@ -578,7 +587,7 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
2 * sizeof(short) * (maxu) + /* u_s */
2 * sizeof(short) * len); /* y_tilde_s */
if (ec) {
- memset(ec, 0, sizeof(echo_can_state_t) +
+ memset(ec, 0, sizeof(struct echo_can_state) +
4 + /* align */
sizeof(int) * len + /* a_i */
sizeof(short) * len + /* a_s */
@@ -591,7 +600,7 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
return ec;
}
-static inline int echo_can_traintap(echo_can_state_t *ec, int pos, short val)
+static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)
{
/* Set the hangover counter to the length of the can to
* avoid adjustments occuring immediately after initial forced training
diff --git a/sec-2.h b/sec-2.h
index dd7dcf7..7d2e996 100644
--- a/sec-2.h
+++ b/sec-2.h
@@ -67,7 +67,7 @@
#define NONUPDATE_DWELL_TIME 600 /* 600 samples, or 75ms */
-typedef struct
+struct echo_can_state
{
int tx_power;
int rx_power;
@@ -95,11 +95,20 @@ typedef struct
int32_t latest_correction; /* Indication of the magnitude of the latest
adaption, or a code to indicate why adaption
was skipped, for test purposes */
-} echo_can_state_t;
+};
-static echo_can_state_t *echo_can_create(int len, int adaption_mode);
-static void echo_can_free(echo_can_state_t *ec);
-static int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx);
+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_shutdown(void)
+{
+}
/*
* According to Jim...
@@ -113,12 +122,12 @@ static int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx);
/* #define MIN_TX_POWER_FOR_ADAPTION 4096
#define MIN_RX_POWER_FOR_ADAPTION 64 */
-static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
+static inline struct echo_can_state *echo_can_create(int len, int adaption_mode)
{
- echo_can_state_t *ec;
+ struct echo_can_state *ec;
void *ptr;
- ptr = ec = (echo_can_state_t *) MALLOC(sizeof(*ec) + len * sizeof(int32_t) +
+ ptr = ec = (struct echo_can_state *) MALLOC(sizeof(*ec) + len * sizeof(int32_t) +
len * sizeof(int16_t));
if (ec == NULL)
return NULL;
@@ -139,14 +148,14 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
}
/*- End of function --------------------------------------------------------*/
-static inline void echo_can_free(echo_can_state_t *ec)
+static inline void echo_can_free(struct echo_can_state *ec)
{
fir16_free(&ec->fir_state);
FREE(ec);
}
/*- End of function --------------------------------------------------------*/
-static inline int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx)
+static inline int16_t echo_can_update(struct echo_can_state *ec, int16_t tx, int16_t rx)
{
int offset1;
int offset2;
@@ -278,7 +287,7 @@ static inline int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t
}
#if 0
-static inline int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx)
+static inline int16_t echo_can_update(struct echo_can_state *ec, int16_t tx, int16_t rx)
{
int offset;
int limit;
@@ -412,7 +421,7 @@ static inline int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t
/*- End of function --------------------------------------------------------*/
#endif
-static inline int echo_can_traintap(echo_can_state_t *ec, int pos, short val)
+static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)
{
/* Reset hang counter to avoid adjustments after
initial forced training */
diff --git a/sec.h b/sec.h
index d4e98ce..738f6b5 100644
--- a/sec.h
+++ b/sec.h
@@ -70,7 +70,7 @@
#define NONUPDATE_DWELL_TIME 600 /* 600 samples, or 75ms */
-typedef struct
+struct echo_can_state
{
int tx_power;
int rx_power;
@@ -98,11 +98,20 @@ typedef struct
int32_t latest_correction; /* Indication of the magnitude of the latest
adaption, or a code to indicate why adaption
was skipped, for test purposes */
-} echo_can_state_t;
+};
-static echo_can_state_t *echo_can_create(int len, int adaption_mode);
-static void echo_can_free(echo_can_state_t *ec);
-static int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx);
+static void echo_can_init(void)
+{
+ printk("Zaptel Echo Canceller: STEVE%s\n", ZAPTEL_ECHO_AGGRESSIVE);
+}
+
+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);
/* Original parameters :
#define MIN_TX_POWER_FOR_ADAPTION 256
@@ -117,12 +126,12 @@ static int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx);
#define MIN_RX_POWER_FOR_ADAPTION 64
*/
-static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
+static inline struct echo_can_state *echo_can_create(int len, int adaption_mode)
{
- echo_can_state_t *ec;
+ struct echo_can_state *ec;
void *ptr;
- ptr = ec = (echo_can_state_t *) MALLOC(sizeof(*ec) + len * sizeof(int32_t) +
+ ptr = ec = (struct echo_can_state *) MALLOC(sizeof(*ec) + len * sizeof(int32_t) +
len * 3 * sizeof(int16_t));
if (ec == NULL)
return NULL;
@@ -141,13 +150,13 @@ static inline echo_can_state_t *echo_can_create(int len, int adaption_mode)
}
/*- End of function --------------------------------------------------------*/
-static inline void echo_can_free(echo_can_state_t *ec)
+static inline void echo_can_free(struct echo_can_state *ec)
{
FREE(ec);
}
/*- End of function --------------------------------------------------------*/
-static inline int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx)
+static inline int16_t echo_can_update(struct echo_can_state *ec, int16_t tx, int16_t rx)
{
int32_t echo_value;
int clean_rx;
@@ -268,7 +277,7 @@ static inline int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t
}
/*- End of function --------------------------------------------------------*/
-static inline int echo_can_traintap(echo_can_state_t *ec, int pos, short val)
+static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)
{
/* Reset hang counter to avoid adjustments after
initial forced training */
diff --git a/tor2.c b/tor2.c
index 9e84ab5..0ca35ee 100644
--- a/tor2.c
+++ b/tor2.c
@@ -23,8 +23,6 @@
* 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.
- *
- * $Id$
*/
#include <linux/kernel.h>
diff --git a/wct1xxp.c b/wct1xxp.c
index fa5191c..6a252f2 100644
--- a/wct1xxp.c
+++ b/wct1xxp.c
@@ -22,8 +22,6 @@
* 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.
- *
- * $Id$
*/
#include <linux/kernel.h>
diff --git a/wct4xxp/Makefile b/wct4xxp/Makefile
index 7fe2869..a5faf45 100644
--- a/wct4xxp/Makefile
+++ b/wct4xxp/Makefile
@@ -1,6 +1,6 @@
ifneq ($(KBUILD_EXTMOD),)
-include $(obj)/Kbuild
+include $(src)/Makefile.kernel26
else
diff --git a/wct4xxp/Kbuild b/wct4xxp/Makefile.kernel26
index ea6148b..ea6148b 100644
--- a/wct4xxp/Kbuild
+++ b/wct4xxp/Makefile.kernel26
diff --git a/wctc4xxp/Makefile b/wctc4xxp/Makefile
index d5d75f1..cad6216 100644
--- a/wctc4xxp/Makefile
+++ b/wctc4xxp/Makefile
@@ -1,6 +1,6 @@
ifneq ($(KBUILD_EXTMOD),)
-include $(obj)/Kbuild
+include $(obj)/Makefile.kernel26
endif
diff --git a/wctc4xxp/Kbuild b/wctc4xxp/Makefile.kernel26
index b034819..b034819 100644
--- a/wctc4xxp/Kbuild
+++ b/wctc4xxp/Makefile.kernel26
diff --git a/zaptel.c b/zaptel-base.c
index fc1bd35..1391335 100644
--- a/zaptel.c
+++ b/zaptel-base.c
@@ -32,8 +32,6 @@
* 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.
- *
- * $Id$
*/
@@ -186,7 +184,6 @@ static struct class_simple *zap_class = NULL;
static int deftaps = 64;
-#if !defined(LINUX26)
static
__u16 fcstab[256] =
{
@@ -223,7 +220,6 @@ __u16 fcstab[256] =
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
};
-#endif
static int debug;
@@ -397,6 +393,31 @@ static struct zt_zone *tone_zones[ZT_TONE_ZONE_MAX];
#define NUM_SIGS 10
+/* Echo Cancellation */
+
+#ifdef AGGRESSIVE_SUPPRESSOR
+#define ZAPTEL_ECHO_AGGRESSIVE " (aggressive)"
+#else
+#define ZAPTEL_ECHO_AGGRESSIVE ""
+#endif
+
+#if defined(ECHO_CAN_HPEC)
+#include "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)
{
@@ -939,7 +960,7 @@ static void close_channel(struct zt_chan *chan)
{
unsigned long flags;
void *rxgain = NULL;
- echo_can_state_t *ec = NULL;
+ struct echo_can_state *ec = NULL;
int oldconf;
#ifdef CONFIG_ZAPATA_PPP
struct ppp_channel *ppp;
@@ -2046,7 +2067,7 @@ static int initialize_channel(struct zt_chan *chan)
int res;
unsigned long flags;
void *rxgain=NULL;
- echo_can_state_t *ec=NULL;
+ struct echo_can_state *ec=NULL;
if ((res = zt_reallocbufs(chan, ZT_DEFAULT_BLOCKSIZE, ZT_DEFAULT_NUM_BUFS)))
return res;
@@ -3480,6 +3501,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);
}
@@ -4024,7 +4050,7 @@ static int zt_chan_ioctl(struct inode *inode, struct file *file, unsigned int cm
int ret;
int oldconf;
void *rxgain=NULL;
- echo_can_state_t *ec, *tec;
+ struct echo_can_state *ec, *tec;
if (!chan)
return -ENOSYS;
@@ -5511,11 +5537,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);
}
+#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();
@@ -6247,7 +6284,7 @@ static void __zt_getempty(struct zt_chan *ms, unsigned char *buf)
static void __zt_receive_chunk(struct zt_chan *chan, unsigned char *buf)
{
/* Receive chunk of audio -- called with chan->lock held */
- unsigned char waste[ZT_CHUNKSIZE];
+ char waste[ZT_CHUNKSIZE];
if (!buf) {
memset(waste, ZT_LIN2X(0, chan), sizeof(waste));
@@ -6625,8 +6662,8 @@ static int __init zt_init(void) {
#endif /* CONFIG_DEVFS_FS */
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();
@@ -6671,6 +6708,7 @@ 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 6ff6957..c974963 100644
--- a/zaptel.h
+++ b/zaptel.h
@@ -23,8 +23,6 @@
* 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.
- *
- * $Id$
*/
#ifndef _LINUX_ZAPTEL_H
@@ -171,38 +169,6 @@
#define RING_DEBOUNCE_TIME 2000 /* 2000 ms ring debounce time */
-#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
-
#define ZT_GET_PARAMS_RETURN_MASTER 0x40000000
typedef struct zt_params
@@ -1021,9 +987,21 @@ struct zt_hdlc {
#endif
struct zt_chan *chan;
};
-
#endif /* CONFIG_ZAPATA_NET */
+/* 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);
+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];
@@ -1187,7 +1165,7 @@ struct zt_chan {
/* Is echo cancellation enabled or disabled */
int echocancel;
- echo_can_state_t *ec;
+ struct echo_can_state *ec;
echo_can_disable_detector_state_t txecdis;
echo_can_disable_detector_state_t rxecdis;
diff --git a/zconfig.h b/zconfig.h
index 27bc4d4..284ad90 100644
--- a/zconfig.h
+++ b/zconfig.h
@@ -45,7 +45,7 @@
/* #define CONFIG_ZAPTEL_MMX */
/*
- * Pick your echo canceller: MARK2, MARK3, STEVE, or STEVE2 :)
+ * Pick your echo canceller.
*
*/
/* #define ECHO_CAN_STEVE */