Debian Codegraph @

drivers/dahdi/dahdi_echocan_jpah.c

raw symbols SCIP
1 /*
2 * ECHO_CAN_JPAH
3 *
4 * by Jason Parker
5 *
6 * Based upon mg2ec.h - sort of.
7 * This "echo can" will completely hose your audio.
8 * Don't use it unless you're absolutely sure you know what you're doing.
9 *
10 * Copyright (C) 2007-2012, Digium, Inc.
11 *
12 * All rights reserved.
13 *
14 */
15
16 /*
17 * See http://www.asterisk.org for more information about
18 * the Asterisk project. Please do not directly contact
19 * any of the maintainers of this project for assistance;
20 * the project provides a web site, mailing lists and IRC
21 * channels for your use.
22 *
23 * This program is free software, distributed under the terms of
24 * the GNU General Public License Version 2 as published by the
25 * Free Software Foundation. See the LICENSE file included with
26 * this program for more details.
27 */
28
29 #include <linux/kernel.h>
30 #include <linux/slab.h>
31 #include <linux/errno.h>
32 #include <linux/module.h>
33 #include <linux/init.h>
34 #include <linux/ctype.h>
35 #include <linux/moduleparam.h>
36
37 #include <dahdi/kernel.h>
38
39 static int debug;
40
41 static int echo_can_create(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
42 struct dahdi_echocanparam *p, struct dahdi_echocan_state **ec);
43 static void echo_can_free(struct dahdi_chan *chan, struct dahdi_echocan_state *ec);
44 static void echo_can_process(struct dahdi_echocan_state *ec, short *isig, const short *iref, u32 size);
45 static int echo_can_traintap(struct dahdi_echocan_state *ec, int pos, short val);
46 static const char *name = "JPAH";
47 static const char *ec_name(const struct dahdi_chan *chan) { return name; }
48
49 static const struct dahdi_echocan_factory my_factory = {
50 .get_name = ec_name,
51 .owner = THIS_MODULE,
52 .echocan_create = echo_can_create,
53 };
54
55 static const struct dahdi_echocan_ops my_ops = {
56 .echocan_free = echo_can_free,
57 .echocan_process = echo_can_process,
58 .echocan_traintap = echo_can_traintap,
59 };
60
61 struct ec_pvt {
62 struct dahdi_echocan_state dahdi;
63 int blah;
64 };
65
66 #define dahdi_to_pvt(a) container_of(a, struct ec_pvt, dahdi)
67
68 static int echo_can_create(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
69 struct dahdi_echocanparam *p, struct dahdi_echocan_state **ec)
70 {
71 struct ec_pvt *pvt;
72
73 if (ecp->param_count > 0) {
74 printk(KERN_WARNING "JPAH does not support parameters; failing request\n");
75 return -EINVAL;
76 }
77
78 pvt = kzalloc(sizeof(*pvt), GFP_KERNEL);
79 if (!pvt)
80 return -ENOMEM;
81
82 pvt->dahdi.ops = &my_ops;
83
84 *ec = &pvt->dahdi;
85 return 0;
86 }
87
88 static void echo_can_free(struct dahdi_chan *chan, struct dahdi_echocan_state *ec)
89 {
90 struct ec_pvt *pvt = dahdi_to_pvt(ec);
91
92 kfree(pvt);
93 }
94
95 static void echo_can_process(struct dahdi_echocan_state *ec, short *isig, const short *iref, u32 size)
96 {
97 struct ec_pvt *pvt = dahdi_to_pvt(ec);
98 u32 x;
99
100 for (x = 0; x < size; x++) {
101 if (pvt->blah < 2) {
102 pvt->blah++;
103
104 *isig++ = 0;
105 } else {
106 pvt->blah = 0;
107
108 isig++;
109 }
110 }
111 }
112
113 static int echo_can_traintap(struct dahdi_echocan_state *ec, int pos, short val)
114 {
115 return 0;
116 }
117
118 static int __init mod_init(void)
119 {
120 if (dahdi_register_echocan_factory(&my_factory)) {
121 module_printk(KERN_ERR, "could not register with DAHDI core\n");
122
123 return -EPERM;
124 }
125
126 module_printk(KERN_NOTICE, "Registered echo canceler '%s'\n",
127 my_factory.get_name(NULL));
128
129 return 0;
130 }
131
132 static void __exit mod_exit(void)
133 {
134 dahdi_unregister_echocan_factory(&my_factory);
135 }
136
137 module_param(debug, int, S_IRUGO | S_IWUSR);
138
139 MODULE_DESCRIPTION("DAHDI Jason Parker Audio Hoser");
140 MODULE_AUTHOR("Jason Parker <[email protected]>");
141 MODULE_LICENSE("GPL v2");
142
143 module_init(mod_init);
144 module_exit(mod_exit);