]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/isdn/mISDN/dsp_core.c
c16cb7ac3d2a11d356d45b59cb3c76e200e3b0e4
[linux-2.6-omap-h63xx.git] / drivers / isdn / mISDN / dsp_core.c
1 /*
2  * Author       Andreas Eversberg (jolly@eversberg.eu)
3  * Based on source code structure by
4  *              Karsten Keil (keil@isdn4linux.de)
5  *
6  *              This file is (c) under GNU PUBLIC LICENSE
7  *              For changes and modifications please read
8  *              ../../../Documentation/isdn/mISDN.cert
9  *
10  * Thanks to    Karsten Keil (great drivers)
11  *              Cologne Chip (great chips)
12  *
13  * This module does:
14  *              Real-time tone generation
15  *              DTMF detection
16  *              Real-time cross-connection and conferrence
17  *              Compensate jitter due to system load and hardware fault.
18  *              All features are done in kernel space and will be realized
19  *              using hardware, if available and supported by chip set.
20  *              Blowfish encryption/decryption
21  */
22
23 /* STRUCTURE:
24  *
25  * The dsp module provides layer 2 for b-channels (64kbit). It provides
26  * transparent audio forwarding with special digital signal processing:
27  *
28  * - (1) generation of tones
29  * - (2) detection of dtmf tones
30  * - (3) crossconnecting and conferences (clocking)
31  * - (4) echo generation for delay test
32  * - (5) volume control
33  * - (6) disable receive data
34  * - (7) pipeline
35  * - (8) encryption/decryption
36  *
37  * Look:
38  *             TX            RX
39  *         ------upper layer------
40  *             |             ^
41  *             |             |(6)
42  *             v             |
43  *       +-----+-------------+-----+
44  *       |(3)(4)                   |
45  *       |           CMX           |
46  *       |                         |
47  *       |           +-------------+
48  *       |           |       ^
49  *       |           |       |
50  *       |+---------+|  +----+----+
51  *       ||(1)      ||  |(2)      |
52  *       ||         ||  |         |
53  *       ||  Tones  ||  |  DTMF   |
54  *       ||         ||  |         |
55  *       ||         ||  |         |
56  *       |+----+----+|  +----+----+
57  *       +-----+-----+       ^
58  *             |             |
59  *             v             |
60  *        +----+----+   +----+----+
61  *        |(5)      |   |(5)      |
62  *        |         |   |         |
63  *        |TX Volume|   |RX Volume|
64  *        |         |   |         |
65  *        |         |   |         |
66  *        +----+----+   +----+----+
67  *             |             ^
68  *             |             |
69  *             v             |
70  *        +----+-------------+----+
71  *        |(7)                    |
72  *        |                       |
73  *        |  Pipeline Processing  |
74  *        |                       |
75  *        |                       |
76  *        +----+-------------+----+
77  *             |             ^
78  *             |             |
79  *             v             |
80  *        +----+----+   +----+----+
81  *        |(8)      |   |(8)      |
82  *        |         |   |         |
83  *        | Encrypt |   | Decrypt |
84  *        |         |   |         |
85  *        |         |   |         |
86  *        +----+----+   +----+----+
87  *             |             ^
88  *             |             |
89  *             v             |
90  *         ------card  layer------
91  *             TX            RX
92  *
93  * Above you can see the logical data flow. If software is used to do the
94  * process, it is actually the real data flow. If hardware is used, data
95  * may not flow, but hardware commands to the card, to provide the data flow
96  * as shown.
97  *
98  * NOTE: The channel must be activated in order to make dsp work, even if
99  * no data flow to the upper layer is intended. Activation can be done
100  * after and before controlling the setting using PH_CONTROL requests.
101  *
102  * DTMF: Will be detected by hardware if possible. It is done before CMX
103  * processing.
104  *
105  * Tones: Will be generated via software if endless looped audio fifos are
106  * not supported by hardware. Tones will override all data from CMX.
107  * It is not required to join a conference to use tones at any time.
108  *
109  * CMX: Is transparent when not used. When it is used, it will do
110  * crossconnections and conferences via software if not possible through
111  * hardware. If hardware capability is available, hardware is used.
112  *
113  * Echo: Is generated by CMX and is used to check performane of hard and
114  * software CMX.
115  *
116  * The CMX has special functions for conferences with one, two and more
117  * members. It will allow different types of data flow. Receive and transmit
118  * data to/form upper layer may be swithed on/off individually without loosing
119  * features of CMX, Tones and DTMF.
120  *
121  * Echo Cancellation: Sometimes we like to cancel echo from the interface.
122  * Note that a VoIP call may not have echo caused by the IP phone. The echo
123  * is generated by the telephone line connected to it. Because the delay
124  * is high, it becomes an echo. RESULT: Echo Cachelation is required if
125  * both echo AND delay is applied to an interface.
126  * Remember that software CMX always generates a more or less delay.
127  *
128  * If all used features can be realized in hardware, and if transmit and/or
129  * receive data ist disabled, the card may not send/receive any data at all.
130  * Not receiving is usefull if only announcements are played. Not sending is
131  * usefull if an answering machine records audio. Not sending and receiving is
132  * usefull during most states of the call. If supported by hardware, tones
133  * will be played without cpu load. Small PBXs and NT-Mode applications will
134  * not need expensive hardware when processing calls.
135  *
136  *
137  * LOCKING:
138  *
139  * When data is received from upper or lower layer (card), the complete dsp
140  * module is locked by a global lock.  This lock MUST lock irq, because it
141  * must lock timer events by DSP poll timer.
142  * When data is ready to be transmitted down, the data is queued and sent
143  * outside lock and timer event.
144  * PH_CONTROL must not change any settings, join or split conference members
145  * during process of data.
146  *
147  * HDLC:
148  *
149  * It works quite the same as transparent, except that HDLC data is forwarded
150  * to all other conference members if no hardware bridging is possible.
151  * Send data will be writte to sendq. Sendq will be sent if confirm is received.
152  * Conference cannot join, if one member is not hdlc.
153  *
154  */
155
156 #include <linux/delay.h>
157 #include <linux/mISDNif.h>
158 #include <linux/mISDNdsp.h>
159 #include <linux/module.h>
160 #include <linux/vmalloc.h>
161 #include "core.h"
162 #include "dsp.h"
163
164 static const char *mISDN_dsp_revision = "2.0";
165
166 static int debug;
167 static int options;
168 static int poll;
169 static int dtmfthreshold = 100;
170
171 MODULE_AUTHOR("Andreas Eversberg");
172 module_param(debug, uint, S_IRUGO | S_IWUSR);
173 module_param(options, uint, S_IRUGO | S_IWUSR);
174 module_param(poll, uint, S_IRUGO | S_IWUSR);
175 module_param(dtmfthreshold, uint, S_IRUGO | S_IWUSR);
176 MODULE_LICENSE("GPL");
177
178 /*int spinnest = 0;*/
179
180 spinlock_t dsp_lock; /* global dsp lock */
181 struct list_head dsp_ilist;
182 struct list_head conf_ilist;
183 int dsp_debug;
184 int dsp_options;
185 int dsp_poll, dsp_tics;
186
187 /* check if rx may be turned off or must be turned on */
188 static void
189 dsp_rx_off_member(struct dsp *dsp)
190 {
191         struct mISDN_ctrl_req   cq;
192         int rx_off = 1;
193
194         memset(&cq, 0, sizeof(cq));
195
196         if (!dsp->features_rx_off)
197                 return;
198
199         /* not disabled */
200         if (!dsp->rx_disabled)
201                 rx_off = 0;
202         /* software dtmf */
203         else if (dsp->dtmf.software)
204                 rx_off = 0;
205         /* echo in software */
206         else if (dsp->echo && dsp->pcm_slot_tx < 0)
207                 rx_off = 0;
208         /* bridge in software */
209         else if (dsp->conf) {
210                 if (dsp->conf->software)
211                         rx_off = 0;
212         }
213
214         if (rx_off == dsp->rx_is_off)
215                 return;
216
217         if (!dsp->ch.peer) {
218                 if (dsp_debug & DEBUG_DSP_CORE)
219                         printk(KERN_DEBUG "%s: no peer, no rx_off\n",
220                                 __func__);
221                 return;
222         }
223         cq.op = MISDN_CTRL_RX_OFF;
224         cq.p1 = rx_off;
225         if (dsp->ch.peer->ctrl(dsp->ch.peer, CONTROL_CHANNEL, &cq)) {
226                 printk(KERN_DEBUG "%s: 2nd CONTROL_CHANNEL failed\n",
227                         __func__);
228                 return;
229         }
230         dsp->rx_is_off = rx_off;
231         if (dsp_debug & DEBUG_DSP_CORE)
232                 printk(KERN_DEBUG "%s: %s set rx_off = %d\n",
233                         __func__, dsp->name, rx_off);
234 }
235 static void
236 dsp_rx_off(struct dsp *dsp)
237 {
238         struct dsp_conf_member  *member;
239
240         if (dsp_options & DSP_OPT_NOHARDWARE)
241                 return;
242
243         /* no conf */
244         if (!dsp->conf) {
245                 dsp_rx_off_member(dsp);
246                 return;
247         }
248         /* check all members in conf */
249         list_for_each_entry(member, &dsp->conf->mlist, list) {
250                 dsp_rx_off_member(member->dsp);
251         }
252 }
253
254 /* enable "fill empty" feature */
255 static void
256 dsp_fill_empty(struct dsp *dsp)
257 {
258         struct mISDN_ctrl_req   cq;
259
260         memset(&cq, 0, sizeof(cq));
261
262         if (!dsp->ch.peer) {
263                 if (dsp_debug & DEBUG_DSP_CORE)
264                         printk(KERN_DEBUG "%s: no peer, no fill_empty\n",
265                                 __func__);
266                 return;
267         }
268         cq.op = MISDN_CTRL_FILL_EMPTY;
269         cq.p1 = 1;
270         if (dsp->ch.peer->ctrl(dsp->ch.peer, CONTROL_CHANNEL, &cq)) {
271                 printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n",
272                         __func__);
273                 return;
274         }
275         if (dsp_debug & DEBUG_DSP_CORE)
276                 printk(KERN_DEBUG "%s: %s set fill_empty = 1\n",
277                         __func__, dsp->name);
278 }
279
280 static int
281 dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb)
282 {
283         struct          sk_buff *nskb;
284         int ret = 0;
285         int cont;
286         u8 *data;
287         int len;
288
289         if (skb->len < sizeof(int))
290                 printk(KERN_ERR "%s: PH_CONTROL message too short\n", __func__);
291         cont = *((int *)skb->data);
292         len = skb->len - sizeof(int);
293         data = skb->data + sizeof(int);
294
295         switch (cont) {
296         case DTMF_TONE_START: /* turn on DTMF */
297                 if (dsp->hdlc) {
298                         ret = -EINVAL;
299                         break;
300                 }
301                 if (dsp_debug & DEBUG_DSP_CORE)
302                         printk(KERN_DEBUG "%s: start dtmf\n", __func__);
303                 if (len == sizeof(int)) {
304                         printk(KERN_NOTICE "changing DTMF Threshold "
305                                 "to %d\n", *((int *)data));
306                         dsp->dtmf.treshold = (*(int *)data) * 10000;
307                 }
308                 /* init goertzel */
309                 dsp_dtmf_goertzel_init(dsp);
310
311                 /* check dtmf hardware */
312                 dsp_dtmf_hardware(dsp);
313                 break;
314         case DTMF_TONE_STOP: /* turn off DTMF */
315                 if (dsp_debug & DEBUG_DSP_CORE)
316                         printk(KERN_DEBUG "%s: stop dtmf\n", __func__);
317                 dsp->dtmf.hardware = 0;
318                 dsp->dtmf.software = 0;
319                 break;
320         case DSP_CONF_JOIN: /* join / update conference */
321                 if (len < sizeof(int)) {
322                         ret = -EINVAL;
323                         break;
324                 }
325                 if (*((u32 *)data) == 0)
326                         goto conf_split;
327                 if (dsp_debug & DEBUG_DSP_CORE)
328                         printk(KERN_DEBUG "%s: join conference %d\n",
329                                 __func__, *((u32 *)data));
330                 ret = dsp_cmx_conf(dsp, *((u32 *)data));
331                         /* dsp_cmx_hardware will also be called here */
332                 dsp_rx_off(dsp);
333                 if (dsp_debug & DEBUG_DSP_CMX)
334                         dsp_cmx_debug(dsp);
335                 break;
336         case DSP_CONF_SPLIT: /* remove from conference */
337 conf_split:
338                 if (dsp_debug & DEBUG_DSP_CORE)
339                         printk(KERN_DEBUG "%s: release conference\n", __func__);
340                 ret = dsp_cmx_conf(dsp, 0);
341                         /* dsp_cmx_hardware will also be called here */
342                 if (dsp_debug & DEBUG_DSP_CMX)
343                         dsp_cmx_debug(dsp);
344                 dsp_rx_off(dsp);
345                 break;
346         case DSP_TONE_PATT_ON: /* play tone */
347                 if (dsp->hdlc) {
348                         ret = -EINVAL;
349                         break;
350                 }
351                 if (len < sizeof(int)) {
352                         ret = -EINVAL;
353                         break;
354                 }
355                 if (dsp_debug & DEBUG_DSP_CORE)
356                         printk(KERN_DEBUG "%s: turn tone 0x%x on\n",
357                                 __func__, *((int *)skb->data));
358                 ret = dsp_tone(dsp, *((int *)data));
359                 if (!ret) {
360                         dsp_cmx_hardware(dsp->conf, dsp);
361                         dsp_rx_off(dsp);
362                 }
363                 if (!dsp->tone.tone)
364                         goto tone_off;
365                 break;
366         case DSP_TONE_PATT_OFF: /* stop tone */
367                 if (dsp->hdlc) {
368                         ret = -EINVAL;
369                         break;
370                 }
371                 if (dsp_debug & DEBUG_DSP_CORE)
372                         printk(KERN_DEBUG "%s: turn tone off\n", __func__);
373                 dsp_tone(dsp, 0);
374                 dsp_cmx_hardware(dsp->conf, dsp);
375                 dsp_rx_off(dsp);
376                 /* reset tx buffers (user space data) */
377 tone_off:
378                 dsp->rx_W = 0;
379                 dsp->rx_R = 0;
380                 break;
381         case DSP_VOL_CHANGE_TX: /* change volume */
382                 if (dsp->hdlc) {
383                         ret = -EINVAL;
384                         break;
385                 }
386                 if (len < sizeof(int)) {
387                         ret = -EINVAL;
388                         break;
389                 }
390                 dsp->tx_volume = *((int *)data);
391                 if (dsp_debug & DEBUG_DSP_CORE)
392                         printk(KERN_DEBUG "%s: change tx vol to %d\n",
393                                 __func__, dsp->tx_volume);
394                 dsp_cmx_hardware(dsp->conf, dsp);
395                 dsp_dtmf_hardware(dsp);
396                 dsp_rx_off(dsp);
397                 break;
398         case DSP_VOL_CHANGE_RX: /* change volume */
399                 if (dsp->hdlc) {
400                         ret = -EINVAL;
401                         break;
402                 }
403                 if (len < sizeof(int)) {
404                         ret = -EINVAL;
405                         break;
406                 }
407                 dsp->rx_volume = *((int *)data);
408                 if (dsp_debug & DEBUG_DSP_CORE)
409                         printk(KERN_DEBUG "%s: change rx vol to %d\n",
410                                 __func__, dsp->tx_volume);
411                 dsp_cmx_hardware(dsp->conf, dsp);
412                 dsp_dtmf_hardware(dsp);
413                 dsp_rx_off(dsp);
414                 break;
415         case DSP_ECHO_ON: /* enable echo */
416                 dsp->echo = 1; /* soft echo */
417                 if (dsp_debug & DEBUG_DSP_CORE)
418                         printk(KERN_DEBUG "%s: enable cmx-echo\n", __func__);
419                 dsp_cmx_hardware(dsp->conf, dsp);
420                 dsp_rx_off(dsp);
421                 if (dsp_debug & DEBUG_DSP_CMX)
422                         dsp_cmx_debug(dsp);
423                 break;
424         case DSP_ECHO_OFF: /* disable echo */
425                 dsp->echo = 0;
426                 if (dsp_debug & DEBUG_DSP_CORE)
427                         printk(KERN_DEBUG "%s: disable cmx-echo\n", __func__);
428                 dsp_cmx_hardware(dsp->conf, dsp);
429                 dsp_rx_off(dsp);
430                 if (dsp_debug & DEBUG_DSP_CMX)
431                         dsp_cmx_debug(dsp);
432                 break;
433         case DSP_RECEIVE_ON: /* enable receive to user space */
434                 if (dsp_debug & DEBUG_DSP_CORE)
435                         printk(KERN_DEBUG "%s: enable receive to user "
436                                 "space\n", __func__);
437                 dsp->rx_disabled = 0;
438                 dsp_rx_off(dsp);
439                 break;
440         case DSP_RECEIVE_OFF: /* disable receive to user space */
441                 if (dsp_debug & DEBUG_DSP_CORE)
442                         printk(KERN_DEBUG "%s: disable receive to "
443                                 "user space\n", __func__);
444                 dsp->rx_disabled = 1;
445                 dsp_rx_off(dsp);
446                 break;
447         case DSP_MIX_ON: /* enable mixing of tx data */
448                 if (dsp->hdlc) {
449                         ret = -EINVAL;
450                         break;
451                 }
452                 if (dsp_debug & DEBUG_DSP_CORE)
453                         printk(KERN_DEBUG "%s: enable mixing of "
454                                 "tx-data with conf mebers\n", __func__);
455                 dsp->tx_mix = 1;
456                 dsp_cmx_hardware(dsp->conf, dsp);
457                 dsp_rx_off(dsp);
458                 if (dsp_debug & DEBUG_DSP_CMX)
459                         dsp_cmx_debug(dsp);
460                 break;
461         case DSP_MIX_OFF: /* disable mixing of tx data */
462                 if (dsp->hdlc) {
463                         ret = -EINVAL;
464                         break;
465                 }
466                 if (dsp_debug & DEBUG_DSP_CORE)
467                         printk(KERN_DEBUG "%s: disable mixing of "
468                                 "tx-data with conf mebers\n", __func__);
469                 dsp->tx_mix = 0;
470                 dsp_cmx_hardware(dsp->conf, dsp);
471                 dsp_rx_off(dsp);
472                 if (dsp_debug & DEBUG_DSP_CMX)
473                         dsp_cmx_debug(dsp);
474                 break;
475         case DSP_TXDATA_ON: /* enable txdata */
476                 dsp->tx_data = 1;
477                 if (dsp_debug & DEBUG_DSP_CORE)
478                         printk(KERN_DEBUG "%s: enable tx-data\n", __func__);
479                 dsp_cmx_hardware(dsp->conf, dsp);
480                 dsp_rx_off(dsp);
481                 if (dsp_debug & DEBUG_DSP_CMX)
482                         dsp_cmx_debug(dsp);
483                 break;
484         case DSP_TXDATA_OFF: /* disable txdata */
485                 dsp->tx_data = 0;
486                 if (dsp_debug & DEBUG_DSP_CORE)
487                         printk(KERN_DEBUG "%s: disable tx-data\n", __func__);
488                 dsp_cmx_hardware(dsp->conf, dsp);
489                 dsp_rx_off(dsp);
490                 if (dsp_debug & DEBUG_DSP_CMX)
491                         dsp_cmx_debug(dsp);
492                 break;
493         case DSP_DELAY: /* use delay algorithm instead of dynamic
494                            jitter algorithm */
495                 if (dsp->hdlc) {
496                         ret = -EINVAL;
497                         break;
498                 }
499                 if (len < sizeof(int)) {
500                         ret = -EINVAL;
501                         break;
502                 }
503                 dsp->cmx_delay = (*((int *)data)) << 3;
504                         /* miliseconds to samples */
505                 if (dsp->cmx_delay >= (CMX_BUFF_HALF>>1))
506                         /* clip to half of maximum usable buffer
507                         (half of half buffer) */
508                         dsp->cmx_delay = (CMX_BUFF_HALF>>1) - 1;
509                 if (dsp_debug & DEBUG_DSP_CORE)
510                         printk(KERN_DEBUG "%s: use delay algorithm to "
511                                 "compensate jitter (%d samples)\n",
512                                 __func__, dsp->cmx_delay);
513                 break;
514         case DSP_JITTER: /* use dynamic jitter algorithm instead of
515                     delay algorithm */
516                 if (dsp->hdlc) {
517                         ret = -EINVAL;
518                         break;
519                 }
520                 dsp->cmx_delay = 0;
521                 if (dsp_debug & DEBUG_DSP_CORE)
522                         printk(KERN_DEBUG "%s: use jitter algorithm to "
523                                 "compensate jitter\n", __func__);
524                 break;
525         case DSP_TX_DEJITTER: /* use dynamic jitter algorithm for tx-buffer */
526                 if (dsp->hdlc) {
527                         ret = -EINVAL;
528                         break;
529                 }
530                 dsp->tx_dejitter = 1;
531                 if (dsp_debug & DEBUG_DSP_CORE)
532                         printk(KERN_DEBUG "%s: use dejitter on TX "
533                                 "buffer\n", __func__);
534                 break;
535         case DSP_TX_DEJ_OFF: /* use tx-buffer without dejittering*/
536                 if (dsp->hdlc) {
537                         ret = -EINVAL;
538                         break;
539                 }
540                 dsp->tx_dejitter = 0;
541                 if (dsp_debug & DEBUG_DSP_CORE)
542                         printk(KERN_DEBUG "%s: use TX buffer without "
543                                 "dejittering\n", __func__);
544                 break;
545         case DSP_PIPELINE_CFG:
546                 if (dsp->hdlc) {
547                         ret = -EINVAL;
548                         break;
549                 }
550                 if (len > 0 && ((char *)data)[len - 1]) {
551                         printk(KERN_DEBUG "%s: pipeline config string "
552                                 "is not NULL terminated!\n", __func__);
553                         ret = -EINVAL;
554                 } else {
555                         dsp->pipeline.inuse = 1;
556                         dsp_cmx_hardware(dsp->conf, dsp);
557                         ret = dsp_pipeline_build(&dsp->pipeline,
558                                 len > 0 ? (char *)data : NULL);
559                         dsp_cmx_hardware(dsp->conf, dsp);
560                         dsp_rx_off(dsp);
561                 }
562                 break;
563         case DSP_BF_ENABLE_KEY: /* turn blowfish on */
564                 if (dsp->hdlc) {
565                         ret = -EINVAL;
566                         break;
567                 }
568                 if (len < 4 || len > 56) {
569                         ret = -EINVAL;
570                         break;
571                 }
572                 if (dsp_debug & DEBUG_DSP_CORE)
573                         printk(KERN_DEBUG "%s: turn blowfish on (key "
574                                 "not shown)\n", __func__);
575                 ret = dsp_bf_init(dsp, (u8 *)data, len);
576                 /* set new cont */
577                 if (!ret)
578                         cont = DSP_BF_ACCEPT;
579                 else
580                         cont = DSP_BF_REJECT;
581                 /* send indication if it worked to set it */
582                 nskb = _alloc_mISDN_skb(PH_CONTROL_IND, MISDN_ID_ANY,
583                         sizeof(int), &cont, GFP_ATOMIC);
584                 if (nskb) {
585                         if (dsp->up) {
586                                 if (dsp->up->send(dsp->up, nskb))
587                                         dev_kfree_skb(nskb);
588                         } else
589                                 dev_kfree_skb(nskb);
590                 }
591                 if (!ret) {
592                         dsp_cmx_hardware(dsp->conf, dsp);
593                         dsp_dtmf_hardware(dsp);
594                         dsp_rx_off(dsp);
595                 }
596                 break;
597         case DSP_BF_DISABLE: /* turn blowfish off */
598                 if (dsp->hdlc) {
599                         ret = -EINVAL;
600                         break;
601                 }
602                 if (dsp_debug & DEBUG_DSP_CORE)
603                         printk(KERN_DEBUG "%s: turn blowfish off\n", __func__);
604                 dsp_bf_cleanup(dsp);
605                 dsp_cmx_hardware(dsp->conf, dsp);
606                 dsp_dtmf_hardware(dsp);
607                 dsp_rx_off(dsp);
608                 break;
609         default:
610                 if (dsp_debug & DEBUG_DSP_CORE)
611                         printk(KERN_DEBUG "%s: ctrl req %x unhandled\n",
612                                 __func__, cont);
613                 ret = -EINVAL;
614         }
615         return ret;
616 }
617
618 static void
619 get_features(struct mISDNchannel *ch)
620 {
621         struct dsp              *dsp = container_of(ch, struct dsp, ch);
622         struct mISDN_ctrl_req   cq;
623
624         if (!ch->peer) {
625                 if (dsp_debug & DEBUG_DSP_CORE)
626                         printk(KERN_DEBUG "%s: no peer, no features\n",
627                                 __func__);
628                 return;
629         }
630         memset(&cq, 0, sizeof(cq));
631         cq.op = MISDN_CTRL_GETOP;
632         if (ch->peer->ctrl(ch->peer, CONTROL_CHANNEL, &cq) < 0) {
633                 printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n",
634                         __func__);
635                 return;
636         }
637         if (cq.op & MISDN_CTRL_RX_OFF)
638                 dsp->features_rx_off = 1;
639         if (cq.op & MISDN_CTRL_FILL_EMPTY)
640                 dsp->features_fill_empty = 1;
641         if (dsp_options & DSP_OPT_NOHARDWARE)
642                 return;
643         if ((cq.op & MISDN_CTRL_HW_FEATURES_OP)) {
644                 cq.op = MISDN_CTRL_HW_FEATURES;
645                 *((u_long *)&cq.p1) = (u_long)&dsp->features;
646                 if (ch->peer->ctrl(ch->peer, CONTROL_CHANNEL, &cq)) {
647                         printk(KERN_DEBUG "%s: 2nd CONTROL_CHANNEL failed\n",
648                                 __func__);
649                 }
650         } else
651                 if (dsp_debug & DEBUG_DSP_CORE)
652                         printk(KERN_DEBUG "%s: features not supported for %s\n",
653                                 __func__, dsp->name);
654 }
655
656 static int
657 dsp_function(struct mISDNchannel *ch,  struct sk_buff *skb)
658 {
659         struct dsp                      *dsp = container_of(ch, struct dsp, ch);
660         struct mISDNhead        *hh;
661         int                     ret = 0;
662         u8                      *digits;
663         int                     cont;
664         u_long                  flags;
665
666         hh = mISDN_HEAD_P(skb);
667         switch (hh->prim) {
668         /* FROM DOWN */
669         case (PH_DATA_CNF):
670                 dsp->data_pending = 0;
671                 /* trigger next hdlc frame, if any */
672                 if (dsp->hdlc) {
673                         spin_lock_irqsave(&dsp_lock, flags);
674                         if (dsp->b_active)
675                                 schedule_work(&dsp->workq);
676                         spin_unlock_irqrestore(&dsp_lock, flags);
677                 }
678                 break;
679         case (PH_DATA_IND):
680         case (DL_DATA_IND):
681                 if (skb->len < 1) {
682                         ret = -EINVAL;
683                         break;
684                 }
685                 if (dsp->rx_is_off) {
686                         if (dsp_debug & DEBUG_DSP_CORE)
687                                 printk(KERN_DEBUG "%s: rx-data during rx_off"
688                                         " for %s\n",
689                                 __func__, dsp->name);
690                 }
691                 if (dsp->hdlc) {
692                         /* hdlc */
693                         spin_lock_irqsave(&dsp_lock, flags);
694                         dsp_cmx_hdlc(dsp, skb);
695                         spin_unlock_irqrestore(&dsp_lock, flags);
696                         if (dsp->rx_disabled) {
697                                 /* if receive is not allowed */
698                                 break;
699                         }
700                         hh->prim = DL_DATA_IND;
701                         if (dsp->up)
702                                 return dsp->up->send(dsp->up, skb);
703                         break;
704                 }
705
706                 /* decrypt if enabled */
707                 if (dsp->bf_enable)
708                         dsp_bf_decrypt(dsp, skb->data, skb->len);
709                 /* pipeline */
710                 if (dsp->pipeline.inuse)
711                         dsp_pipeline_process_rx(&dsp->pipeline, skb->data,
712                                 skb->len);
713                 /* change volume if requested */
714                 if (dsp->rx_volume)
715                         dsp_change_volume(skb, dsp->rx_volume);
716
717                 /* check if dtmf soft decoding is turned on */
718                 if (dsp->dtmf.software) {
719                         digits = dsp_dtmf_goertzel_decode(dsp, skb->data,
720                                 skb->len, (dsp_options&DSP_OPT_ULAW)?1:0);
721                         while (*digits) {
722                                 struct sk_buff *nskb;
723                                 if (dsp_debug & DEBUG_DSP_DTMF)
724                                         printk(KERN_DEBUG "%s: digit"
725                                             "(%c) to layer %s\n",
726                                             __func__, *digits, dsp->name);
727                                 cont = DTMF_TONE_VAL | *digits;
728                                 nskb = _alloc_mISDN_skb(PH_CONTROL_IND,
729                                     MISDN_ID_ANY, sizeof(int), &cont,
730                                     GFP_ATOMIC);
731                                 if (nskb) {
732                                         if (dsp->up) {
733                                                 if (dsp->up->send(
734                                                     dsp->up, nskb))
735                                                 dev_kfree_skb(nskb);
736                                         } else
737                                                 dev_kfree_skb(nskb);
738                                 }
739                                 digits++;
740                         }
741                 }
742                 /* we need to process receive data if software */
743                 spin_lock_irqsave(&dsp_lock, flags);
744                 if (dsp->pcm_slot_tx < 0 && dsp->pcm_slot_rx < 0) {
745                         /* process data from card at cmx */
746                         dsp_cmx_receive(dsp, skb);
747                 }
748                 spin_unlock_irqrestore(&dsp_lock, flags);
749
750                 if (dsp->rx_disabled) {
751                         /* if receive is not allowed */
752                         break;
753                 }
754                 hh->prim = DL_DATA_IND;
755                 if (dsp->up)
756                         return dsp->up->send(dsp->up, skb);
757                 break;
758         case (PH_CONTROL_IND):
759                 if (dsp_debug & DEBUG_DSP_DTMFCOEFF)
760                         printk(KERN_DEBUG "%s: PH_CONTROL INDICATION "
761                                 "received: %x (len %d) %s\n", __func__,
762                                 hh->id, skb->len, dsp->name);
763                 switch (hh->id) {
764                 case (DTMF_HFC_COEF): /* getting coefficients */
765                         if (!dsp->dtmf.hardware) {
766                                 if (dsp_debug & DEBUG_DSP_DTMFCOEFF)
767                                         printk(KERN_DEBUG "%s: ignoring DTMF "
768                                                 "coefficients from HFC\n",
769                                                 __func__);
770                                 break;
771                         }
772                         digits = dsp_dtmf_goertzel_decode(dsp, skb->data,
773                                 skb->len, 2);
774                         while (*digits) {
775                                 int k;
776                                 struct sk_buff *nskb;
777                                 if (dsp_debug & DEBUG_DSP_DTMF)
778                                         printk(KERN_DEBUG "%s: digit"
779                                             "(%c) to layer %s\n",
780                                             __func__, *digits, dsp->name);
781                                 k = *digits | DTMF_TONE_VAL;
782                                 nskb = _alloc_mISDN_skb(PH_CONTROL_IND,
783                                         MISDN_ID_ANY, sizeof(int), &k,
784                                         GFP_ATOMIC);
785                                 if (nskb) {
786                                         if (dsp->up) {
787                                                 if (dsp->up->send(
788                                                     dsp->up, nskb))
789                                                 dev_kfree_skb(nskb);
790                                         } else
791                                                 dev_kfree_skb(nskb);
792                                 }
793                                 digits++;
794                         }
795                         break;
796                 case (HFC_VOL_CHANGE_TX): /* change volume */
797                         if (skb->len != sizeof(int)) {
798                                 ret = -EINVAL;
799                                 break;
800                         }
801                         spin_lock_irqsave(&dsp_lock, flags);
802                         dsp->tx_volume = *((int *)skb->data);
803                         if (dsp_debug & DEBUG_DSP_CORE)
804                                 printk(KERN_DEBUG "%s: change tx volume to "
805                                         "%d\n", __func__, dsp->tx_volume);
806                         dsp_cmx_hardware(dsp->conf, dsp);
807                         dsp_dtmf_hardware(dsp);
808                         dsp_rx_off(dsp);
809                         spin_unlock_irqrestore(&dsp_lock, flags);
810                         break;
811                 default:
812                         if (dsp_debug & DEBUG_DSP_CORE)
813                                 printk(KERN_DEBUG "%s: ctrl ind %x unhandled "
814                                         "%s\n", __func__, hh->id, dsp->name);
815                         ret = -EINVAL;
816                 }
817                 break;
818         case (PH_ACTIVATE_IND):
819         case (PH_ACTIVATE_CNF):
820                 if (dsp_debug & DEBUG_DSP_CORE)
821                         printk(KERN_DEBUG "%s: b_channel is now active %s\n",
822                                 __func__, dsp->name);
823                 /* bchannel now active */
824                 spin_lock_irqsave(&dsp_lock, flags);
825                 dsp->b_active = 1;
826                 dsp->data_pending = 0;
827                 dsp->rx_init = 1;
828                         /* rx_W and rx_R will be adjusted on first frame */
829                 dsp->rx_W = 0;
830                 dsp->rx_R = 0;
831                 memset(dsp->rx_buff, 0, sizeof(dsp->rx_buff));
832                 dsp_cmx_hardware(dsp->conf, dsp);
833                 dsp_dtmf_hardware(dsp);
834                 dsp_rx_off(dsp);
835                 spin_unlock_irqrestore(&dsp_lock, flags);
836                 if (dsp_debug & DEBUG_DSP_CORE)
837                         printk(KERN_DEBUG "%s: done with activation, sending "
838                                 "confirm to user space. %s\n", __func__,
839                                 dsp->name);
840                 /* send activation to upper layer */
841                 hh->prim = DL_ESTABLISH_CNF;
842                 if (dsp->up)
843                         return dsp->up->send(dsp->up, skb);
844                 break;
845         case (PH_DEACTIVATE_IND):
846         case (PH_DEACTIVATE_CNF):
847                 if (dsp_debug & DEBUG_DSP_CORE)
848                         printk(KERN_DEBUG "%s: b_channel is now inactive %s\n",
849                                 __func__, dsp->name);
850                 /* bchannel now inactive */
851                 spin_lock_irqsave(&dsp_lock, flags);
852                 dsp->b_active = 0;
853                 dsp->data_pending = 0;
854                 dsp_cmx_hardware(dsp->conf, dsp);
855                 dsp_rx_off(dsp);
856                 spin_unlock_irqrestore(&dsp_lock, flags);
857                 hh->prim = DL_RELEASE_CNF;
858                 if (dsp->up)
859                         return dsp->up->send(dsp->up, skb);
860                 break;
861         /* FROM UP */
862         case (DL_DATA_REQ):
863         case (PH_DATA_REQ):
864                 if (skb->len < 1) {
865                         ret = -EINVAL;
866                         break;
867                 }
868                 if (dsp->hdlc) {
869                         /* hdlc */
870                         if (!dsp->b_active) {
871                                 ret = -EIO;
872                                 break;
873                         }
874                         hh->prim = PH_DATA_REQ;
875                         spin_lock_irqsave(&dsp_lock, flags);
876                         skb_queue_tail(&dsp->sendq, skb);
877                         schedule_work(&dsp->workq);
878                         spin_unlock_irqrestore(&dsp_lock, flags);
879                         return 0;
880                 }
881                 /* send data to tx-buffer (if no tone is played) */
882                 if (!dsp->tone.tone) {
883                         spin_lock_irqsave(&dsp_lock, flags);
884                         dsp_cmx_transmit(dsp, skb);
885                         spin_unlock_irqrestore(&dsp_lock, flags);
886                 }
887                 break;
888         case (PH_CONTROL_REQ):
889                 spin_lock_irqsave(&dsp_lock, flags);
890                 ret = dsp_control_req(dsp, hh, skb);
891                 spin_unlock_irqrestore(&dsp_lock, flags);
892                 break;
893         case (DL_ESTABLISH_REQ):
894         case (PH_ACTIVATE_REQ):
895                 if (dsp_debug & DEBUG_DSP_CORE)
896                         printk(KERN_DEBUG "%s: activating b_channel %s\n",
897                                 __func__, dsp->name);
898                 if (dsp->dtmf.hardware || dsp->dtmf.software)
899                         dsp_dtmf_goertzel_init(dsp);
900                 get_features(ch);
901                 /* enable fill_empty feature */
902                 if (dsp->features_fill_empty)
903                         dsp_fill_empty(dsp);
904                 /* send ph_activate */
905                 hh->prim = PH_ACTIVATE_REQ;
906                 if (ch->peer)
907                         return ch->recv(ch->peer, skb);
908                 break;
909         case (DL_RELEASE_REQ):
910         case (PH_DEACTIVATE_REQ):
911                 if (dsp_debug & DEBUG_DSP_CORE)
912                         printk(KERN_DEBUG "%s: releasing b_channel %s\n",
913                                 __func__, dsp->name);
914                 spin_lock_irqsave(&dsp_lock, flags);
915                 dsp->tone.tone = 0;
916                 dsp->tone.hardware = 0;
917                 dsp->tone.software = 0;
918                 if (timer_pending(&dsp->tone.tl))
919                         del_timer(&dsp->tone.tl);
920                 if (dsp->conf)
921                         dsp_cmx_conf(dsp, 0); /* dsp_cmx_hardware will also be
922                                                  called here */
923                 skb_queue_purge(&dsp->sendq);
924                 spin_unlock_irqrestore(&dsp_lock, flags);
925                 hh->prim = PH_DEACTIVATE_REQ;
926                 if (ch->peer)
927                         return ch->recv(ch->peer, skb);
928                 break;
929         default:
930                 if (dsp_debug & DEBUG_DSP_CORE)
931                         printk(KERN_DEBUG "%s: msg %x unhandled %s\n",
932                                 __func__, hh->prim, dsp->name);
933                 ret = -EINVAL;
934         }
935         if (!ret)
936                 dev_kfree_skb(skb);
937         return ret;
938 }
939
940 static int
941 dsp_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
942 {
943         struct dsp              *dsp = container_of(ch, struct dsp, ch);
944         u_long          flags;
945         int             err = 0;
946
947         if (debug & DEBUG_DSP_CTRL)
948         printk(KERN_DEBUG "%s:(%x)\n", __func__, cmd);
949
950         switch (cmd) {
951         case OPEN_CHANNEL:
952                 break;
953         case CLOSE_CHANNEL:
954                 if (dsp->ch.peer)
955                         dsp->ch.peer->ctrl(dsp->ch.peer, CLOSE_CHANNEL, NULL);
956
957                 /* wait until workqueue has finished,
958                  * must lock here, or we may hit send-process currently
959                  * queueing. */
960                 spin_lock_irqsave(&dsp_lock, flags);
961                 dsp->b_active = 0;
962                 spin_unlock_irqrestore(&dsp_lock, flags);
963                 /* MUST not be locked, because it waits until queue is done. */
964                 cancel_work_sync(&dsp->workq);
965                 spin_lock_irqsave(&dsp_lock, flags);
966                 if (timer_pending(&dsp->tone.tl))
967                         del_timer(&dsp->tone.tl);
968                 skb_queue_purge(&dsp->sendq);
969                 if (dsp_debug & DEBUG_DSP_CTRL)
970                         printk(KERN_DEBUG "%s: releasing member %s\n",
971                                 __func__, dsp->name);
972                 dsp->b_active = 0;
973                 dsp_cmx_conf(dsp, 0); /* dsp_cmx_hardware will also be called
974                                          here */
975                 dsp_pipeline_destroy(&dsp->pipeline);
976
977                 if (dsp_debug & DEBUG_DSP_CTRL)
978                         printk(KERN_DEBUG "%s: remove & destroy object %s\n",
979                                 __func__, dsp->name);
980                 list_del(&dsp->list);
981                 spin_unlock_irqrestore(&dsp_lock, flags);
982
983                 if (dsp_debug & DEBUG_DSP_CTRL)
984                         printk(KERN_DEBUG "%s: dsp instance released\n",
985                                 __func__);
986                 vfree(dsp);
987                 module_put(THIS_MODULE);
988                 break;
989         }
990         return err;
991 }
992
993 static void
994 dsp_send_bh(struct work_struct *work)
995 {
996         struct dsp *dsp = container_of(work, struct dsp, workq);
997         struct sk_buff *skb;
998         struct mISDNhead        *hh;
999
1000         if (dsp->hdlc && dsp->data_pending)
1001                 return; /* wait until data has been acknowledged */
1002
1003         /* send queued data */
1004         while ((skb = skb_dequeue(&dsp->sendq))) {
1005                 /* in locked date, we must have still data in queue */
1006                 if (dsp->data_pending) {
1007                         if (dsp_debug & DEBUG_DSP_CORE)
1008                                 printk(KERN_DEBUG "%s: fifo full %s, this is "
1009                                         "no bug!\n", __func__, dsp->name);
1010                         /* flush transparent data, if not acked */
1011                         dev_kfree_skb(skb);
1012                         continue;
1013                 }
1014                 hh = mISDN_HEAD_P(skb);
1015                 if (hh->prim == DL_DATA_REQ) {
1016                         /* send packet up */
1017                         if (dsp->up) {
1018                                 if (dsp->up->send(dsp->up, skb))
1019                                         dev_kfree_skb(skb);
1020                         } else
1021                                 dev_kfree_skb(skb);
1022                 } else {
1023                         /* send packet down */
1024                         if (dsp->ch.peer) {
1025                                 dsp->data_pending = 1;
1026                                 if (dsp->ch.recv(dsp->ch.peer, skb)) {
1027                                         dev_kfree_skb(skb);
1028                                         dsp->data_pending = 0;
1029                                 }
1030                         } else
1031                                 dev_kfree_skb(skb);
1032                 }
1033         }
1034 }
1035
1036 static int
1037 dspcreate(struct channel_req *crq)
1038 {
1039         struct dsp              *ndsp;
1040         u_long          flags;
1041
1042         if (crq->protocol != ISDN_P_B_L2DSP
1043          && crq->protocol != ISDN_P_B_L2DSPHDLC)
1044                 return -EPROTONOSUPPORT;
1045         ndsp = vmalloc(sizeof(struct dsp));
1046         if (!ndsp) {
1047                 printk(KERN_ERR "%s: vmalloc struct dsp failed\n", __func__);
1048                 return -ENOMEM;
1049         }
1050         memset(ndsp, 0, sizeof(struct dsp));
1051         if (dsp_debug & DEBUG_DSP_CTRL)
1052                 printk(KERN_DEBUG "%s: creating new dsp instance\n", __func__);
1053
1054         /* default enabled */
1055         INIT_WORK(&ndsp->workq, (void *)dsp_send_bh);
1056         skb_queue_head_init(&ndsp->sendq);
1057         ndsp->ch.send = dsp_function;
1058         ndsp->ch.ctrl = dsp_ctrl;
1059         ndsp->up = crq->ch;
1060         crq->ch = &ndsp->ch;
1061         if (crq->protocol == ISDN_P_B_L2DSP) {
1062                 crq->protocol = ISDN_P_B_RAW;
1063                 ndsp->hdlc = 0;
1064         } else {
1065                 crq->protocol = ISDN_P_B_HDLC;
1066                 ndsp->hdlc = 1;
1067         }
1068         if (!try_module_get(THIS_MODULE))
1069                 printk(KERN_WARNING "%s:cannot get module\n",
1070                         __func__);
1071
1072         sprintf(ndsp->name, "DSP_C%x(0x%p)",
1073                 ndsp->up->st->dev->id + 1, ndsp);
1074         /* set frame size to start */
1075         ndsp->features.hfc_id = -1; /* current PCM id */
1076         ndsp->features.pcm_id = -1; /* current PCM id */
1077         ndsp->pcm_slot_rx = -1; /* current CPM slot */
1078         ndsp->pcm_slot_tx = -1;
1079         ndsp->pcm_bank_rx = -1;
1080         ndsp->pcm_bank_tx = -1;
1081         ndsp->hfc_conf = -1; /* current conference number */
1082         /* set tone timer */
1083         ndsp->tone.tl.function = (void *)dsp_tone_timeout;
1084         ndsp->tone.tl.data = (long) ndsp;
1085         init_timer(&ndsp->tone.tl);
1086
1087         if (dtmfthreshold < 20 || dtmfthreshold > 500)
1088                 dtmfthreshold = 200;
1089         ndsp->dtmf.treshold = dtmfthreshold*10000;
1090
1091         /* init pipeline append to list */
1092         spin_lock_irqsave(&dsp_lock, flags);
1093         dsp_pipeline_init(&ndsp->pipeline);
1094         list_add_tail(&ndsp->list, &dsp_ilist);
1095         spin_unlock_irqrestore(&dsp_lock, flags);
1096
1097         return 0;
1098 }
1099
1100
1101 static struct Bprotocol DSP = {
1102         .Bprotocols = (1 << (ISDN_P_B_L2DSP & ISDN_P_B_MASK))
1103                 | (1 << (ISDN_P_B_L2DSPHDLC & ISDN_P_B_MASK)),
1104         .name = "dsp",
1105         .create = dspcreate
1106 };
1107
1108 static int dsp_init(void)
1109 {
1110         int err;
1111         int tics;
1112
1113         printk(KERN_INFO "DSP modul %s\n", mISDN_dsp_revision);
1114
1115         dsp_options = options;
1116         dsp_debug = debug;
1117
1118         /* set packet size */
1119         dsp_poll = poll;
1120         if (dsp_poll) {
1121                 if (dsp_poll > MAX_POLL) {
1122                         printk(KERN_ERR "%s: Wrong poll value (%d), use %d "
1123                                 "maximum.\n", __func__, poll, MAX_POLL);
1124                         err = -EINVAL;
1125                         return err;
1126                 }
1127                 if (dsp_poll < 8) {
1128                         printk(KERN_ERR "%s: Wrong poll value (%d), use 8 "
1129                                 "minimum.\n", __func__, dsp_poll);
1130                         err = -EINVAL;
1131                         return err;
1132                 }
1133                 dsp_tics = poll * HZ / 8000;
1134                 if (dsp_tics * 8000 != poll * HZ) {
1135                         printk(KERN_INFO "mISDN_dsp: Cannot clock every %d "
1136                                 "samples (0,125 ms). It is not a multiple of "
1137                                 "%d HZ.\n", poll, HZ);
1138                         err = -EINVAL;
1139                         return err;
1140                 }
1141         } else {
1142                 poll = 8;
1143                 while (poll <= MAX_POLL) {
1144                         tics = poll * HZ / 8000;
1145                         if (tics * 8000 == poll * HZ) {
1146                                 dsp_tics = tics;
1147                                 dsp_poll = poll;
1148                                 if (poll >= 64)
1149                                         break;
1150                         }
1151                         poll++;
1152                 }
1153         }
1154         if (dsp_poll == 0) {
1155                 printk(KERN_INFO "mISDN_dsp: There is no multiple of kernel "
1156                         "clock that equals exactly the duration of 8-256 "
1157                         "samples. (Choose kernel clock speed like 100, 250, "
1158                         "300, 1000)\n");
1159                 err = -EINVAL;
1160                 return err;
1161         }
1162         printk(KERN_INFO "mISDN_dsp: DSP clocks every %d samples. This equals "
1163                 "%d jiffies.\n", dsp_poll, dsp_tics);
1164
1165         spin_lock_init(&dsp_lock);
1166         INIT_LIST_HEAD(&dsp_ilist);
1167         INIT_LIST_HEAD(&conf_ilist);
1168
1169         /* init conversion tables */
1170         dsp_audio_generate_law_tables();
1171         dsp_silence = (dsp_options&DSP_OPT_ULAW)?0xff:0x2a;
1172         dsp_audio_law_to_s32 = (dsp_options&DSP_OPT_ULAW)?dsp_audio_ulaw_to_s32:
1173                 dsp_audio_alaw_to_s32;
1174         dsp_audio_generate_s2law_table();
1175         dsp_audio_generate_seven();
1176         dsp_audio_generate_mix_table();
1177         if (dsp_options & DSP_OPT_ULAW)
1178                 dsp_audio_generate_ulaw_samples();
1179         dsp_audio_generate_volume_changes();
1180
1181         err = dsp_pipeline_module_init();
1182         if (err) {
1183                 printk(KERN_ERR "mISDN_dsp: Can't initialize pipeline, "
1184                         "error(%d)\n", err);
1185                 return err;
1186         }
1187
1188         err = mISDN_register_Bprotocol(&DSP);
1189         if (err) {
1190                 printk(KERN_ERR "Can't register %s error(%d)\n", DSP.name, err);
1191                 return err;
1192         }
1193
1194         /* set sample timer */
1195         dsp_spl_tl.function = (void *)dsp_cmx_send;
1196         dsp_spl_tl.data = 0;
1197         init_timer(&dsp_spl_tl);
1198         dsp_spl_tl.expires = jiffies + dsp_tics;
1199         dsp_spl_jiffies = dsp_spl_tl.expires;
1200         add_timer(&dsp_spl_tl);
1201
1202         return 0;
1203 }
1204
1205
1206 static void dsp_cleanup(void)
1207 {
1208         mISDN_unregister_Bprotocol(&DSP);
1209
1210         if (timer_pending(&dsp_spl_tl))
1211                 del_timer(&dsp_spl_tl);
1212
1213         if (!list_empty(&dsp_ilist)) {
1214                 printk(KERN_ERR "mISDN_dsp: Audio DSP object inst list not "
1215                         "empty.\n");
1216         }
1217         if (!list_empty(&conf_ilist)) {
1218                 printk(KERN_ERR "mISDN_dsp: Conference list not empty. Not "
1219                         "all memory freed.\n");
1220         }
1221
1222         dsp_pipeline_module_exit();
1223 }
1224
1225 module_init(dsp_init);
1226 module_exit(dsp_cleanup);
1227