3 * builtin mISDN dsp pipeline element for enabling the hw echocanceller
5 * Copyright (C) 2007, Nadi Sarrar
7 * Nadi Sarrar <nadi@beronet.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * You should have received a copy of the GNU General Public License along with
20 * this program; if not, write to the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * The full GNU General Public License is included in this distribution in the
24 * file called LICENSE.
28 #include <linux/kernel.h>
29 #include <linux/string.h>
30 #include <linux/mISDNdsp.h>
31 #include <linux/mISDNif.h>
36 static struct mISDN_dsp_element_arg args[] = {
37 { "deftaps", "128", "Set the number of taps of cancellation." },
40 static struct mISDN_dsp_element dsp_hwec_p = {
46 .num_args = ARRAY_SIZE(args),
49 struct mISDN_dsp_element *dsp_hwec = &dsp_hwec_p;
51 void dsp_hwec_enable(struct dsp *dsp, const char *arg)
55 struct mISDN_ctrl_req cq;
58 printk(KERN_ERR "%s: failed to enable hwec: dsp is NULL\n",
72 char *dup, *tok, *name, *val;
78 while ((tok = strsep(&dup, ","))) {
81 name = strsep(&tok, "=");
87 if (!strcmp(name, "deftaps")) {
88 if (sscanf(val, "%d", &tmp) == 1)
95 printk(KERN_DEBUG "%s: enabling hwec with deftaps=%d\n",
97 memset(&cq, 0, sizeof(cq));
98 cq.op = MISDN_CTRL_HFC_ECHOCAN_ON;
100 if (!dsp->ch.peer->ctrl(&dsp->ch, CONTROL_CHANNEL, &cq)) {
101 printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n",
107 void dsp_hwec_disable(struct dsp *dsp)
109 struct mISDN_ctrl_req cq;
112 printk(KERN_ERR "%s: failed to disable hwec: dsp is NULL\n",
117 printk(KERN_DEBUG "%s: disabling hwec\n", __func__);
118 memset(&cq, 0, sizeof(cq));
119 cq.op = MISDN_CTRL_HFC_ECHOCAN_OFF;
120 if (!dsp->ch.peer->ctrl(&dsp->ch, CONTROL_CHANNEL, &cq)) {
121 printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n",
127 int dsp_hwec_init(void)
129 mISDN_dsp_element_register(dsp_hwec);
134 void dsp_hwec_exit(void)
136 mISDN_dsp_element_unregister(dsp_hwec);