Lines Matching full:dsp

23  * The dsp module provides layer 2 for b-channels (64kbit). It provides
96 * NOTE: The channel must be activated in order to make dsp work, even if
137 * When data is received from upper or lower layer (card), the complete dsp
139 * must lock timer events by DSP poll timer.
161 #include "dsp.h"
180 DEFINE_SPINLOCK(dsp_lock); /* global dsp lock */
189 dsp_rx_off_member(struct dsp *dsp) in dsp_rx_off_member() argument
196 if (!dsp->features_rx_off) in dsp_rx_off_member()
200 if (!dsp->rx_disabled) in dsp_rx_off_member()
203 else if (dsp->dtmf.software) in dsp_rx_off_member()
206 else if (dsp->echo.software) in dsp_rx_off_member()
209 else if (dsp->conf && dsp->conf->software) in dsp_rx_off_member()
214 if (rx_off == dsp->rx_is_off) in dsp_rx_off_member()
217 if (!dsp->ch.peer) { in dsp_rx_off_member()
225 if (dsp->ch.peer->ctrl(dsp->ch.peer, CONTROL_CHANNEL, &cq)) { in dsp_rx_off_member()
230 dsp->rx_is_off = rx_off; in dsp_rx_off_member()
233 __func__, dsp->name, rx_off); in dsp_rx_off_member()
236 dsp_rx_off(struct dsp *dsp) in dsp_rx_off() argument
244 if (!dsp->conf) { in dsp_rx_off()
245 dsp_rx_off_member(dsp); in dsp_rx_off()
249 list_for_each_entry(member, &dsp->conf->mlist, list) { in dsp_rx_off()
250 dsp_rx_off_member(member->dsp); in dsp_rx_off()
256 dsp_fill_empty(struct dsp *dsp) in dsp_fill_empty() argument
262 if (!dsp->ch.peer) { in dsp_fill_empty()
271 if (dsp->ch.peer->ctrl(dsp->ch.peer, CONTROL_CHANNEL, &cq)) { in dsp_fill_empty()
278 __func__, dsp->name); in dsp_fill_empty()
282 dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) in dsp_control_req() argument
300 if (dsp->hdlc) { in dsp_control_req()
310 dsp->dtmf.treshold = (*(int *)data) * 10000; in dsp_control_req()
312 dsp->dtmf.enable = 1; in dsp_control_req()
314 dsp_dtmf_goertzel_init(dsp); in dsp_control_req()
317 dsp_dtmf_hardware(dsp); in dsp_control_req()
318 dsp_rx_off(dsp); in dsp_control_req()
323 dsp->dtmf.enable = 0; in dsp_control_req()
324 dsp->dtmf.hardware = 0; in dsp_control_req()
325 dsp->dtmf.software = 0; in dsp_control_req()
337 ret = dsp_cmx_conf(dsp, *((u32 *)data)); in dsp_control_req()
339 dsp_rx_off(dsp); in dsp_control_req()
341 dsp_cmx_debug(dsp); in dsp_control_req()
347 ret = dsp_cmx_conf(dsp, 0); in dsp_control_req()
350 dsp_cmx_debug(dsp); in dsp_control_req()
351 dsp_rx_off(dsp); in dsp_control_req()
354 if (dsp->hdlc) { in dsp_control_req()
365 ret = dsp_tone(dsp, *((int *)data)); in dsp_control_req()
367 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
368 dsp_rx_off(dsp); in dsp_control_req()
370 if (!dsp->tone.tone) in dsp_control_req()
374 if (dsp->hdlc) { in dsp_control_req()
380 dsp_tone(dsp, 0); in dsp_control_req()
381 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
382 dsp_rx_off(dsp); in dsp_control_req()
385 dsp->rx_W = 0; in dsp_control_req()
386 dsp->rx_R = 0; in dsp_control_req()
389 if (dsp->hdlc) { in dsp_control_req()
397 dsp->tx_volume = *((int *)data); in dsp_control_req()
400 __func__, dsp->tx_volume); in dsp_control_req()
401 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
402 dsp_dtmf_hardware(dsp); in dsp_control_req()
403 dsp_rx_off(dsp); in dsp_control_req()
406 if (dsp->hdlc) { in dsp_control_req()
414 dsp->rx_volume = *((int *)data); in dsp_control_req()
417 __func__, dsp->tx_volume); in dsp_control_req()
418 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
419 dsp_dtmf_hardware(dsp); in dsp_control_req()
420 dsp_rx_off(dsp); in dsp_control_req()
423 dsp->echo.software = 1; /* soft echo */ in dsp_control_req()
426 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
427 dsp_rx_off(dsp); in dsp_control_req()
429 dsp_cmx_debug(dsp); in dsp_control_req()
432 dsp->echo.software = 0; in dsp_control_req()
433 dsp->echo.hardware = 0; in dsp_control_req()
436 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
437 dsp_rx_off(dsp); in dsp_control_req()
439 dsp_cmx_debug(dsp); in dsp_control_req()
445 dsp->rx_disabled = 0; in dsp_control_req()
446 dsp_rx_off(dsp); in dsp_control_req()
452 dsp->rx_disabled = 1; in dsp_control_req()
453 dsp_rx_off(dsp); in dsp_control_req()
456 if (dsp->hdlc) { in dsp_control_req()
463 dsp->tx_mix = 1; in dsp_control_req()
464 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
465 dsp_rx_off(dsp); in dsp_control_req()
467 dsp_cmx_debug(dsp); in dsp_control_req()
470 if (dsp->hdlc) { in dsp_control_req()
477 dsp->tx_mix = 0; in dsp_control_req()
478 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
479 dsp_rx_off(dsp); in dsp_control_req()
481 dsp_cmx_debug(dsp); in dsp_control_req()
484 dsp->tx_data = 1; in dsp_control_req()
487 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
488 dsp_rx_off(dsp); in dsp_control_req()
490 dsp_cmx_debug(dsp); in dsp_control_req()
493 dsp->tx_data = 0; in dsp_control_req()
496 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
497 dsp_rx_off(dsp); in dsp_control_req()
499 dsp_cmx_debug(dsp); in dsp_control_req()
503 if (dsp->hdlc) { in dsp_control_req()
511 dsp->cmx_delay = (*((int *)data)) << 3; in dsp_control_req()
513 if (dsp->cmx_delay >= (CMX_BUFF_HALF >> 1)) in dsp_control_req()
516 dsp->cmx_delay = (CMX_BUFF_HALF >> 1) - 1; in dsp_control_req()
520 __func__, dsp->cmx_delay); in dsp_control_req()
524 if (dsp->hdlc) { in dsp_control_req()
528 dsp->cmx_delay = 0; in dsp_control_req()
534 if (dsp->hdlc) { in dsp_control_req()
538 dsp->tx_dejitter = 1; in dsp_control_req()
544 if (dsp->hdlc) { in dsp_control_req()
548 dsp->tx_dejitter = 0; in dsp_control_req()
554 if (dsp->hdlc) { in dsp_control_req()
563 dsp->pipeline.inuse = 1; in dsp_control_req()
564 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
565 ret = dsp_pipeline_build(&dsp->pipeline, in dsp_control_req()
567 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
568 dsp_rx_off(dsp); in dsp_control_req()
572 if (dsp->hdlc) { in dsp_control_req()
583 ret = dsp_bf_init(dsp, (u8 *)data, len); in dsp_control_req()
593 if (dsp->up) { in dsp_control_req()
594 if (dsp->up->send(dsp->up, nskb)) in dsp_control_req()
600 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
601 dsp_dtmf_hardware(dsp); in dsp_control_req()
602 dsp_rx_off(dsp); in dsp_control_req()
606 if (dsp->hdlc) { in dsp_control_req()
612 dsp_bf_cleanup(dsp); in dsp_control_req()
613 dsp_cmx_hardware(dsp->conf, dsp); in dsp_control_req()
614 dsp_dtmf_hardware(dsp); in dsp_control_req()
615 dsp_rx_off(dsp); in dsp_control_req()
629 struct dsp *dsp = container_of(ch, struct dsp, ch); in get_features() local
646 dsp->features_rx_off = 1; in get_features()
648 dsp->features_fill_empty = 1; in get_features()
653 *((u_long *)&cq.p1) = (u_long)&dsp->features; in get_features()
661 __func__, dsp->name); in get_features()
667 struct dsp *dsp = container_of(ch, struct dsp, ch); in dsp_function() local
677 dsp->data_pending = 0; in dsp_function()
679 if (dsp->hdlc) { in dsp_function()
681 if (dsp->b_active) in dsp_function()
682 schedule_work(&dsp->workq); in dsp_function()
692 if (dsp->rx_is_off) { in dsp_function()
696 __func__, dsp->name); in dsp_function()
698 if (dsp->hdlc) { in dsp_function()
701 dsp_cmx_hdlc(dsp, skb); in dsp_function()
703 if (dsp->rx_disabled) { in dsp_function()
708 if (dsp->up) in dsp_function()
709 return dsp->up->send(dsp->up, skb); in dsp_function()
716 if (dsp->bf_enable) in dsp_function()
717 dsp_bf_decrypt(dsp, skb->data, skb->len); in dsp_function()
719 if (dsp->pipeline.inuse) in dsp_function()
720 dsp_pipeline_process_rx(&dsp->pipeline, skb->data, in dsp_function()
723 if (dsp->rx_volume) in dsp_function()
724 dsp_change_volume(skb, dsp->rx_volume); in dsp_function()
726 if (dsp->dtmf.software) { in dsp_function()
727 digits = dsp_dtmf_goertzel_decode(dsp, skb->data, in dsp_function()
731 if (dsp->conf && dsp->conf->software) { in dsp_function()
733 dsp_cmx_receive(dsp, skb); in dsp_function()
746 __func__, *digits, dsp->name); in dsp_function()
752 if (dsp->up) { in dsp_function()
753 if (dsp->up->send( in dsp_function()
754 dsp->up, nskb)) in dsp_function()
762 if (dsp->rx_disabled) { in dsp_function()
767 if (dsp->up) in dsp_function()
768 return dsp->up->send(dsp->up, skb); in dsp_function()
774 hh->id, skb->len, dsp->name); in dsp_function()
777 if (!dsp->dtmf.hardware) { in dsp_function()
784 digits = dsp_dtmf_goertzel_decode(dsp, skb->data, in dsp_function()
792 __func__, *digits, dsp->name); in dsp_function()
798 if (dsp->up) { in dsp_function()
799 if (dsp->up->send( in dsp_function()
800 dsp->up, nskb)) in dsp_function()
814 dsp->tx_volume = *((int *)skb->data); in dsp_function()
817 "%d\n", __func__, dsp->tx_volume); in dsp_function()
818 dsp_cmx_hardware(dsp->conf, dsp); in dsp_function()
819 dsp_dtmf_hardware(dsp); in dsp_function()
820 dsp_rx_off(dsp); in dsp_function()
826 "%s\n", __func__, hh->id, dsp->name); in dsp_function()
834 __func__, dsp->name); in dsp_function()
837 dsp->b_active = 1; in dsp_function()
838 dsp->data_pending = 0; in dsp_function()
839 dsp->rx_init = 1; in dsp_function()
841 dsp->rx_W = 0; in dsp_function()
842 dsp->rx_R = 0; in dsp_function()
843 memset(dsp->rx_buff, 0, sizeof(dsp->rx_buff)); in dsp_function()
844 dsp_cmx_hardware(dsp->conf, dsp); in dsp_function()
845 dsp_dtmf_hardware(dsp); in dsp_function()
846 dsp_rx_off(dsp); in dsp_function()
851 dsp->name); in dsp_function()
854 if (dsp->up) in dsp_function()
855 return dsp->up->send(dsp->up, skb); in dsp_function()
861 __func__, dsp->name); in dsp_function()
864 dsp->b_active = 0; in dsp_function()
865 dsp->data_pending = 0; in dsp_function()
866 dsp_cmx_hardware(dsp->conf, dsp); in dsp_function()
867 dsp_rx_off(dsp); in dsp_function()
870 if (dsp->up) in dsp_function()
871 return dsp->up->send(dsp->up, skb); in dsp_function()
880 if (dsp->hdlc) { in dsp_function()
882 if (!dsp->b_active) { in dsp_function()
888 skb_queue_tail(&dsp->sendq, skb); in dsp_function()
889 schedule_work(&dsp->workq); in dsp_function()
894 if (!dsp->tone.tone) { in dsp_function()
896 dsp_cmx_transmit(dsp, skb); in dsp_function()
902 ret = dsp_control_req(dsp, hh, skb); in dsp_function()
909 __func__, dsp->name); in dsp_function()
910 if (dsp->dtmf.hardware || dsp->dtmf.software) in dsp_function()
911 dsp_dtmf_goertzel_init(dsp); in dsp_function()
914 if (dsp->features_fill_empty) in dsp_function()
915 dsp_fill_empty(dsp); in dsp_function()
925 __func__, dsp->name); in dsp_function()
927 dsp->tone.tone = 0; in dsp_function()
928 dsp->tone.hardware = 0; in dsp_function()
929 dsp->tone.software = 0; in dsp_function()
930 if (timer_pending(&dsp->tone.tl)) in dsp_function()
931 del_timer(&dsp->tone.tl); in dsp_function()
932 if (dsp->conf) in dsp_function()
933 dsp_cmx_conf(dsp, 0); /* dsp_cmx_hardware will also be in dsp_function()
935 skb_queue_purge(&dsp->sendq); in dsp_function()
944 __func__, hh->prim, dsp->name); in dsp_function()
955 struct dsp *dsp = container_of(ch, struct dsp, ch); in dsp_ctrl() local
965 if (dsp->ch.peer) in dsp_ctrl()
966 dsp->ch.peer->ctrl(dsp->ch.peer, CLOSE_CHANNEL, NULL); in dsp_ctrl()
972 dsp->b_active = 0; in dsp_ctrl()
975 cancel_work_sync(&dsp->workq); in dsp_ctrl()
977 if (timer_pending(&dsp->tone.tl)) in dsp_ctrl()
978 del_timer(&dsp->tone.tl); in dsp_ctrl()
979 skb_queue_purge(&dsp->sendq); in dsp_ctrl()
982 __func__, dsp->name); in dsp_ctrl()
983 dsp->b_active = 0; in dsp_ctrl()
984 dsp_cmx_conf(dsp, 0); /* dsp_cmx_hardware will also be called in dsp_ctrl()
986 dsp_pipeline_destroy(&dsp->pipeline); in dsp_ctrl()
990 __func__, dsp->name); in dsp_ctrl()
991 list_del(&dsp->list); in dsp_ctrl()
995 printk(KERN_DEBUG "%s: dsp instance released\n", in dsp_ctrl()
997 vfree(dsp); in dsp_ctrl()
1007 struct dsp *dsp = container_of(work, struct dsp, workq); in dsp_send_bh() local
1011 if (dsp->hdlc && dsp->data_pending) in dsp_send_bh()
1015 while ((skb = skb_dequeue(&dsp->sendq))) { in dsp_send_bh()
1017 if (dsp->data_pending) { in dsp_send_bh()
1020 "no bug!\n", __func__, dsp->name); in dsp_send_bh()
1028 if (dsp->up) { in dsp_send_bh()
1029 if (dsp->up->send(dsp->up, skb)) in dsp_send_bh()
1035 if (dsp->ch.peer) { in dsp_send_bh()
1036 dsp->data_pending = 1; in dsp_send_bh()
1037 if (dsp->ch.recv(dsp->ch.peer, skb)) { in dsp_send_bh()
1039 dsp->data_pending = 0; in dsp_send_bh()
1050 struct dsp *ndsp; in dspcreate()
1056 ndsp = vzalloc(sizeof(struct dsp)); in dspcreate()
1058 printk(KERN_ERR "%s: vmalloc struct dsp failed\n", __func__); in dspcreate()
1062 printk(KERN_DEBUG "%s: creating new dsp instance\n", __func__); in dspcreate()
1109 static struct Bprotocol DSP = { variable
1112 .name = "dsp",
1121 printk(KERN_INFO "DSP module %s\n", mISDN_dsp_revision); in dsp_init()
1170 printk(KERN_INFO "mISDN_dsp: DSP clocks every %d samples. This equals " in dsp_init()
1192 err = mISDN_register_Bprotocol(&DSP); in dsp_init()
1194 printk(KERN_ERR "Can't register %s error(%d)\n", DSP.name, err); in dsp_init()
1210 mISDN_unregister_Bprotocol(&DSP); in dsp_cleanup()
1215 printk(KERN_ERR "mISDN_dsp: Audio DSP object inst list not " in dsp_cleanup()