1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * builtin mISDN dsp pipeline element for enabling the hw echocanceller
6 * Copyright (C) 2007, Nadi Sarrar
8 * Nadi Sarrar <nadi@beronet.com>
11 #include <linux/kernel.h>
12 #include <linux/string.h>
13 #include <linux/mISDNdsp.h>
14 #include <linux/mISDNif.h>
19 static struct mISDN_dsp_element_arg args
[] = {
20 { "deftaps", "128", "Set the number of taps of cancellation." },
23 static struct mISDN_dsp_element dsp_hwec_p
= {
29 .num_args
= ARRAY_SIZE(args
),
32 struct mISDN_dsp_element
*dsp_hwec
= &dsp_hwec_p
;
34 void dsp_hwec_enable(struct dsp
*dsp
, const char *arg
)
38 struct mISDN_ctrl_req cq
;
41 printk(KERN_ERR
"%s: failed to enable hwec: dsp is NULL\n",
54 char *dup
, *tok
, *name
, *val
;
57 dup
= kstrdup(arg
, GFP_ATOMIC
);
61 while ((tok
= strsep(&dup
, ","))) {
64 name
= strsep(&tok
, "=");
70 if (!strcmp(name
, "deftaps")) {
71 if (sscanf(val
, "%d", &tmp
) == 1)
80 printk(KERN_DEBUG
"%s: enabling hwec with deftaps=%d\n",
82 memset(&cq
, 0, sizeof(cq
));
83 cq
.op
= MISDN_CTRL_HFC_ECHOCAN_ON
;
85 if (!dsp
->ch
.peer
->ctrl(&dsp
->ch
, CONTROL_CHANNEL
, &cq
)) {
86 printk(KERN_DEBUG
"%s: CONTROL_CHANNEL failed\n",
92 void dsp_hwec_disable(struct dsp
*dsp
)
94 struct mISDN_ctrl_req cq
;
97 printk(KERN_ERR
"%s: failed to disable hwec: dsp is NULL\n",
102 printk(KERN_DEBUG
"%s: disabling hwec\n", __func__
);
103 memset(&cq
, 0, sizeof(cq
));
104 cq
.op
= MISDN_CTRL_HFC_ECHOCAN_OFF
;
105 if (!dsp
->ch
.peer
->ctrl(&dsp
->ch
, CONTROL_CHANNEL
, &cq
)) {
106 printk(KERN_DEBUG
"%s: CONTROL_CHANNEL failed\n",
112 int dsp_hwec_init(void)
114 mISDN_dsp_element_register(dsp_hwec
);
119 void dsp_hwec_exit(void)
121 mISDN_dsp_element_unregister(dsp_hwec
);