[Pkg-voip-commits] r6284 - in /dahdi-linux/trunk: debian/rules drivers/dahdi/dahdi_echocan_oslec.c drivers/dahdi/oslec/Kbuild drivers/dahdi/oslec/echo.c drivers/dahdi/oslec/oslec.h drivers/dahdi/oslec/oslec_wrap.c drivers/dahdi/oslec/spandsp/echo.h
tzafrir-guest at alioth.debian.org
tzafrir-guest at alioth.debian.org
Thu Oct 9 20:40:20 UTC 2008
Author: tzafrir-guest
Date: Thu Oct 9 20:40:19 2008
New Revision: 6284
URL: http://svn.debian.org/wsvn/pkg-voip/?sc=1&rev=6284
Log:
A dahdi oslec echo canceller module. Adjust oslec interface
I started writing minimal dahdi_echocan_oslec.c (echo canceller module
for DAHDI using the published OSLEC interface (based on the one for
HPEC).
It tuned out that the interface needed fixing:
* No need to expose echo_can_state_t, as the interface
only uses pointers to it.
- This makes all the rest of the spandsp headers internal.
- ... and we don't need to redefine malloc in each module.
* "echo_can" is too common a prefix in the zaptel and dahdi echo
cancellers area. I prefixed everything with oslec_ .
* Made echo.c an independent module.
* Currently I use a separate oslec.h I had lying around as an external
header to minimize diffs. It should be included by echo.h .
It builds. Not yet tested to load.
Added:
dahdi-linux/trunk/drivers/dahdi/dahdi_echocan_oslec.c
Removed:
dahdi-linux/trunk/drivers/dahdi/oslec/oslec_wrap.c
Modified:
dahdi-linux/trunk/debian/rules
dahdi-linux/trunk/drivers/dahdi/oslec/Kbuild
dahdi-linux/trunk/drivers/dahdi/oslec/echo.c
dahdi-linux/trunk/drivers/dahdi/oslec/oslec.h
dahdi-linux/trunk/drivers/dahdi/oslec/spandsp/echo.h
Modified: dahdi-linux/trunk/debian/rules
URL: http://svn.debian.org/wsvn/pkg-voip/dahdi-linux/trunk/debian/rules?rev=6284&op=diff
==============================================================================
--- dahdi-linux/trunk/debian/rules (original)
+++ dahdi-linux/trunk/debian/rules Thu Oct 9 20:40:19 2008
@@ -60,13 +60,8 @@
EXTRA_SUBDIRS += vzaphfc
endif
-ifndef ECHO_CAN_NAME
-ECHO_CAN_NAME=OSLEC
-endif
-
-ifeq ($(ECHO_CAN_NAME),OSLEC)
- EXTRA_SUBDIRS += oslec
-endif
+EXTRA_SUBDIRS += oslec
+EXTRA_MODS += dahdi_echocan_oslec
MOD_ARGS=MODULES_EXTRA="$(EXTRA_MODS)" SUBDIRS_EXTRA="$(EXTRA_SUBDIRS)"
Added: dahdi-linux/trunk/drivers/dahdi/dahdi_echocan_oslec.c
URL: http://svn.debian.org/wsvn/pkg-voip/dahdi-linux/trunk/drivers/dahdi/dahdi_echocan_oslec.c?rev=6284&op=file
==============================================================================
--- dahdi-linux/trunk/drivers/dahdi/dahdi_echocan_oslec.c (added)
+++ dahdi-linux/trunk/drivers/dahdi/dahdi_echocan_oslec.c Thu Oct 9 20:40:19 2008
@@ -1,0 +1,101 @@
+/*
+ * DAHDI Telephony Interface to the Open Source Line Echo Canceller (OSLEC)
+ *
+ * Written by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+ * Copyright (C) 2008 Xorcom, Inc.
+ *
+ * All rights reserved.
+ *
+ * Based on dahdi_echocan_hpec.c, Copyright (C) 2006-2008 Digium, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ctype.h>
+#include <linux/moduleparam.h>
+
+#include <dahdi/kernel.h>
+
+#define module_printk(level, fmt, args...) printk(level "%s: " fmt, THIS_MODULE->name, ## args)
+
+#warning Fix the include of oslec to be a system include (Tzafrir)
+#include "oslec/oslec.h"
+//#include <linux/oslec.h>
+
+static void echo_can_free(struct echo_can_state *ec)
+{
+ oslec_echo_can_free(ec);
+}
+
+static void echo_can_update(struct echo_can_state *ec, short *iref, short *isig)
+{
+ oslec_echo_can_update(ec, *iref, *isig);
+}
+
+static int echo_can_create(struct dahdi_echocanparams *ecp, struct dahdi_echocanparam *p,
+ struct echo_can_state **ec)
+{
+ if (ecp->param_count > 0) {
+ printk(KERN_WARNING "OSLEC does not support parameters; failing request\n");
+ return -EINVAL;
+ }
+
+ /* TODO: get adaption mode from EC parameters? */
+ *ec = oslec_echo_can_create(ecp->tap_length, 0);
+
+ return *ec ? 0 : -ENOTTY;
+}
+
+static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)
+{
+ return 1;
+}
+
+static const struct dahdi_echocan me = {
+ .name = "OSLEC",
+ .owner = THIS_MODULE,
+ .echo_can_create = echo_can_create,
+ .echo_can_free = echo_can_free,
+ .echo_can_array_update = echo_can_update,
+ .echo_can_traintap = echo_can_traintap,
+};
+
+static int __init mod_init(void)
+{
+ if (dahdi_register_echocan(&me)) {
+ module_printk(KERN_ERR, "could not register with DAHDI core\n");
+
+ return -EPERM;
+ }
+
+ module_printk(KERN_INFO, "Registered echo canceler '%s'\n", me.name);
+
+ return 0;
+}
+
+static void __exit mod_exit(void)
+{
+ dahdi_unregister_echocan(&me);
+}
+
+MODULE_DESCRIPTION("DAHDI OSLEC wrapper");
+MODULE_AUTHOR("Tzafrir Cohen <tzafrir.cohen at xorcom.com>");
+MODULE_LICENSE("GPL");
+
+module_init(mod_init);
+module_exit(mod_exit);
Modified: dahdi-linux/trunk/drivers/dahdi/oslec/Kbuild
URL: http://svn.debian.org/wsvn/pkg-voip/dahdi-linux/trunk/drivers/dahdi/oslec/Kbuild?rev=6284&op=diff
==============================================================================
--- dahdi-linux/trunk/drivers/dahdi/oslec/Kbuild (original)
+++ dahdi-linux/trunk/drivers/dahdi/oslec/Kbuild Thu Oct 9 20:40:19 2008
@@ -1,4 +1,4 @@
obj-m = oslec.o
-oslec-objs = oslec_wrap.o echo.o
+oslec-objs = echo.o
Modified: dahdi-linux/trunk/drivers/dahdi/oslec/echo.c
URL: http://svn.debian.org/wsvn/pkg-voip/dahdi-linux/trunk/drivers/dahdi/oslec/echo.c?rev=6284&op=diff
==============================================================================
--- dahdi-linux/trunk/drivers/dahdi/oslec/echo.c (original)
+++ dahdi-linux/trunk/drivers/dahdi/oslec/echo.c Thu Oct 9 20:40:19 2008
@@ -257,7 +257,7 @@
/*- End of function --------------------------------------------------------*/
-echo_can_state_t *echo_can_create(int len, int adaption_mode)
+echo_can_state_t *oslec_echo_can_create(int len, int adaption_mode)
{
echo_can_state_t *ec;
int i;
@@ -296,7 +296,7 @@
}
ec->cng_level = 1000;
- echo_can_adaption_mode(ec, adaption_mode);
+ oslec_echo_can_adaption_mode(ec, adaption_mode);
ec->snapshot = (int16_t*)malloc(ec->taps*sizeof(int16_t));
memset(ec->snapshot, 0, sizeof(int16_t)*ec->taps);
@@ -312,9 +312,10 @@
return ec;
}
-/*- End of function --------------------------------------------------------*/
-
-void echo_can_free(echo_can_state_t *ec)
+EXPORT_SYMBOL(oslec_echo_can_create);
+/*- End of function --------------------------------------------------------*/
+
+void oslec_echo_can_free(echo_can_state_t *ec)
{
int i;
@@ -324,15 +325,17 @@
free(ec->snapshot);
free(ec);
}
-/*- End of function --------------------------------------------------------*/
-
-void echo_can_adaption_mode(echo_can_state_t *ec, int adaption_mode)
+EXPORT_SYMBOL(oslec_echo_can_free);
+/*- End of function --------------------------------------------------------*/
+
+void oslec_echo_can_adaption_mode(echo_can_state_t *ec, int adaption_mode)
{
ec->adaption_mode = adaption_mode;
}
-/*- End of function --------------------------------------------------------*/
-
-void echo_can_flush(echo_can_state_t *ec)
+EXPORT_SYMBOL(oslec_echo_can_adaption_mode);
+/*- End of function --------------------------------------------------------*/
+
+void oslec_echo_can_flush(echo_can_state_t *ec)
{
int i;
@@ -356,16 +359,18 @@
ec->curr_pos = ec->taps - 1;
ec->Pstates = 0;
}
-/*- End of function --------------------------------------------------------*/
-
-void echo_can_snapshot(echo_can_state_t *ec) {
+EXPORT_SYMBOL(oslec_echo_can_flush);
+/*- End of function --------------------------------------------------------*/
+
+void oslec_echo_can_snapshot(echo_can_state_t *ec) {
memcpy(ec->snapshot, ec->fir_taps16[0], ec->taps*sizeof(int16_t));
}
+EXPORT_SYMBOL(oslec_echo_can_snapshot);
/*- End of function --------------------------------------------------------*/
/* Dual Path Echo Canceller ------------------------------------------------*/
-int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx)
+int16_t oslec_echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx)
{
int32_t echo_value;
int clean_bg;
@@ -593,7 +598,7 @@
return (int16_t) ec->clean_nlp << 1;
}
-
+EXPORT_SYMBOL(oslec_echo_can_update);
/*- End of function --------------------------------------------------------*/
/* This function is seperated from the echo canceller is it is usually called
@@ -610,7 +615,7 @@
for LMS algorithms.
*/
-int16_t echo_can_hpf_tx(echo_can_state_t *ec, int16_t tx) {
+int16_t oslec_echo_can_hpf_tx(echo_can_state_t *ec, int16_t tx) {
int tmp, tmp1;
if (ec->adaption_mode & ECHO_CAN_USE_TX_HPF) {
@@ -625,6 +630,11 @@
return tx;
}
-
-/*- End of function --------------------------------------------------------*/
+EXPORT_SYMBOL(oslec_echo_can_hpf_tx);
+/*- End of function --------------------------------------------------------*/
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("David Rowe");
+MODULE_DESCRIPTION("Open Source Line Echo Canceller");
+MODULE_VERSION("0.3.0");
/*- End of file ------------------------------------------------------------*/
Modified: dahdi-linux/trunk/drivers/dahdi/oslec/oslec.h
URL: http://svn.debian.org/wsvn/pkg-voip/dahdi-linux/trunk/drivers/dahdi/oslec/oslec.h?rev=6284&op=diff
==============================================================================
--- dahdi-linux/trunk/drivers/dahdi/oslec/oslec.h (original)
+++ dahdi-linux/trunk/drivers/dahdi/oslec/oslec.h Thu Oct 9 20:40:19 2008
@@ -27,6 +27,9 @@
#ifndef __OSLEC__
+/* TODO: This should become an external interface of OSLEC and echo.h
+ * should become an internal header file */
+
struct echo_can_state {
void *ec;
};
Modified: dahdi-linux/trunk/drivers/dahdi/oslec/spandsp/echo.h
URL: http://svn.debian.org/wsvn/pkg-voip/dahdi-linux/trunk/drivers/dahdi/oslec/spandsp/echo.h?rev=6284&op=diff
==============================================================================
--- dahdi-linux/trunk/drivers/dahdi/oslec/spandsp/echo.h (original)
+++ dahdi-linux/trunk/drivers/dahdi/oslec/spandsp/echo.h Thu Oct 9 20:40:19 2008
@@ -181,25 +181,25 @@
\param len The length of the canceller, in samples.
\return The new canceller context, or NULL if the canceller could not be created.
*/
-echo_can_state_t *echo_can_create(int len, int adaption_mode);
+echo_can_state_t *oslec_echo_can_create(int len, int adaption_mode);
/*! Free a voice echo canceller context.
\param ec The echo canceller context.
*/
-void echo_can_free(echo_can_state_t *ec);
+void oslec_echo_can_free(echo_can_state_t *ec);
/*! Flush (reinitialise) a voice echo canceller context.
\param ec The echo canceller context.
*/
-void echo_can_flush(echo_can_state_t *ec);
+void oslec_echo_can_flush(echo_can_state_t *ec);
/*! Set the adaption mode of a voice echo canceller context.
\param ec The echo canceller context.
\param adapt The mode.
*/
-void echo_can_adaption_mode(echo_can_state_t *ec, int adaption_mode);
-
-void echo_can_snapshot(echo_can_state_t *ec);
+void oslec_echo_can_adaption_mode(echo_can_state_t *ec, int adaption_mode);
+
+void oslec_echo_can_snapshot(echo_can_state_t *ec);
/*! Process a sample through a voice echo canceller.
\param ec The echo canceller context.
@@ -207,14 +207,14 @@
\param rx The received audio sample.
\return The clean (echo cancelled) received sample.
*/
-int16_t echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx);
+int16_t oslec_echo_can_update(echo_can_state_t *ec, int16_t tx, int16_t rx);
/*! Process to high pass filter the tx signal.
\param ec The echo canceller context.
\param tx The transmitted auio sample.
\return The HP filtered transmit sample, send this to your D/A.
*/
-int16_t echo_can_hpf_tx(echo_can_state_t *ec, int16_t tx);
+int16_t oslec_echo_can_hpf_tx(echo_can_state_t *ec, int16_t tx);
#endif
/*- End of file ------------------------------------------------------------*/
More information about the Pkg-voip-commits
mailing list