1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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"
35
36static struct mISDN_dsp_element_arg args[] = {
37 { "deftaps", "128", "Set the number of taps of cancellation." },
38};
39
40static 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,
48};
49struct mISDN_dsp_element *dsp_hwec = &dsp_hwec_p;
50
51void dsp_hwec_enable(struct dsp *dsp, const char *arg)
52{
53 int deftaps = 128,
54 len;
55 struct mISDN_ctrl_req cq;
56
57 if (!dsp) {
58 printk(KERN_ERR "%s: failed to enable hwec: dsp is NULL\n",
59 __func__);
60 return;
61 }
62
63 if (!arg)
64 goto _do;
65
66 len = strlen(arg);
67 if (!len)
68 goto _do;
69
70 {
71 char _dup[len + 1];
72 char *dup, *tok, *name, *val;
73 int tmp;
74
75 strcpy(_dup, arg);
76 dup = _dup;
77
78 while ((tok = strsep(&dup, ","))) {
79 if (!strlen(tok))
80 continue;
81 name = strsep(&tok, "=");
82 val = tok;
83
84 if (!val)
85 continue;
86
87 if (!strcmp(name, "deftaps")) {
88 if (sscanf(val, "%d", &tmp) == 1)
89 deftaps = tmp;
90 }
91 }
92 }
93
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;
104 }
105}
106
107void dsp_hwec_disable(struct dsp *dsp)
108{
109 struct mISDN_ctrl_req cq;
110
111 if (!dsp) {
112 printk(KERN_ERR "%s: failed to disable hwec: dsp is NULL\n",
113 __func__);
114 return;
115 }
116
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;
124 }
125}
126
127int dsp_hwec_init(void)
128{
129 mISDN_dsp_element_register(dsp_hwec);
130
131 return 0;
132}
133
134void dsp_hwec_exit(void)
135{
136 mISDN_dsp_element_unregister(dsp_hwec);
137}
138