tty/serial: atmel_serial: whitespace and braces modifications
[zen-stable.git] / drivers / isdn / mISDN / dsp_hwec.c
blob806a997fe7cc2907c7c21fb1cc130845b2cdcc9a
1 /*
2 * dsp_hwec.c:
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)
12 * any later version.
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
17 * more details.
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>
32 #include "core.h"
33 #include "dsp.h"
34 #include "dsp_hwec.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 = {
41 .name = "hwec",
42 .new = NULL,
43 .free = NULL,
44 .process_tx = NULL,
45 .process_rx = NULL,
46 .num_args = ARRAY_SIZE(args),
47 .args = args,
49 struct mISDN_dsp_element *dsp_hwec = &dsp_hwec_p;
51 void dsp_hwec_enable(struct dsp *dsp, const char *arg)
53 int deftaps = 128,
54 len;
55 struct mISDN_ctrl_req cq;
57 if (!dsp) {
58 printk(KERN_ERR "%s: failed to enable hwec: dsp is NULL\n",
59 __func__);
60 return;
63 if (!arg)
64 goto _do;
66 len = strlen(arg);
67 if (!len)
68 goto _do;
71 char _dup[len + 1];
72 char *dup, *tok, *name, *val;
73 int tmp;
75 strcpy(_dup, arg);
76 dup = _dup;
78 while ((tok = strsep(&dup, ","))) {
79 if (!strlen(tok))
80 continue;
81 name = strsep(&tok, "=");
82 val = tok;
84 if (!val)
85 continue;
87 if (!strcmp(name, "deftaps")) {
88 if (sscanf(val, "%d", &tmp) == 1)
89 deftaps = tmp;
94 _do:
95 printk(KERN_DEBUG "%s: enabling hwec with deftaps=%d\n",
96 __func__, deftaps);
97 memset(&cq, 0, sizeof(cq));
98 cq.op = MISDN_CTRL_HFC_ECHOCAN_ON;
99 cq.p1 = deftaps;
100 if (!dsp->ch.peer->ctrl(&dsp->ch, CONTROL_CHANNEL, &cq)) {
101 printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n",
102 __func__);
103 return;
107 void dsp_hwec_disable(struct dsp *dsp)
109 struct mISDN_ctrl_req cq;
111 if (!dsp) {
112 printk(KERN_ERR "%s: failed to disable hwec: dsp is NULL\n",
113 __func__);
114 return;
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",
122 __func__);
123 return;
127 int dsp_hwec_init(void)
129 mISDN_dsp_element_register(dsp_hwec);
131 return 0;
134 void dsp_hwec_exit(void)
136 mISDN_dsp_element_unregister(dsp_hwec);