misdn.patch
来自「一个非常美妙的proxy。功能强大。基于sip的协议。如果还要的话」· PATCH 代码 · 共 2,345 行 · 第 1/5 页
PATCH
2,345 行
if (dsp->dtmf.software) { digits = dsp_dtmf_goertzel_decode(dsp, skb->data, skb->len, (dsp_options&DSP_OPT_ULAW)?1:0);@@ -919,6 +963,9 @@ dsp_audio_generate_ulaw_samples(); dsp_audio_generate_volume_changes(); ++ dsp_cancel_init_flip_bits();+ /* init global lock */ lock_HW_init(&dsp_lock); diff -u -r -P /tmp/mISDN/drivers/isdn/hardware/mISDN/dsp.h mISDN/drivers/isdn/hardware/mISDN/dsp.h--- /tmp/mISDN/drivers/isdn/hardware/mISDN/dsp.h 2005-01-29 17:15:31.000000000 +0100+++ mISDN/drivers/isdn/hardware/mISDN/dsp.h 2005-12-02 09:57:08.000000000 +0100@@ -40,6 +40,13 @@ #include "memdbg.h" #endif +#include "ecdis.h"+#include "mec2.h"++//#include "mec.h"+//#include "mec3.h"++ extern int dsp_options; extern int dsp_debug; @@ -109,6 +116,8 @@ #define DSP_DTMF_NPOINTS 102 +#define ECHOCAN_BUFLEN 4*128+ typedef struct _dtmf_t { int software; /* dtmf uses software decoding */ int hardware; /* dtmf uses hardware decoding */@@ -120,6 +129,13 @@ } dtmf_t; +/**************+ *Cancel Stuff*+ ***************/++void dsp_cancel_init_flip_bits(void);++ /*************** * tones stuff * ***************/@@ -200,6 +216,25 @@ u8 bf_crypt_inring[16]; u8 bf_data_out[9]; int bf_sync;++ /* echo cancellation stuff */+ int cancel_enable;+ echo_can_state_t* ec; /**< == NULL: echo cancellation disabled;+ != NULL: echo cancellation enabled */+ + echo_can_disable_detector_state_t* ecdis_rd;+ echo_can_disable_detector_state_t* ecdis_wr;+ + uint16_t echotimer;+ uint16_t echostate;+ uint16_t echolastupdate;+ + char txbuf[ECHOCAN_BUFLEN];+ int txbuflen;+ + char rxbuf[ECHOCAN_BUFLEN];+ int rxbuflen;+ } dsp_t; /* functions */@@ -228,4 +263,8 @@ extern int dsp_bf_init(dsp_t *dsp, const u8 *key, unsigned int keylen); extern void dsp_bf_cleanup(dsp_t *dsp); +extern void dsp_cancel_tx(dsp_t *dsp, u8 *data, int len);+extern void dsp_cancel_rx(dsp_t *dsp, u8 *data, int len);+extern int dsp_cancel_init(dsp_t *dsp, int taps, int training, int delay);+ diff -u -r -P /tmp/mISDN/drivers/isdn/hardware/mISDN/ec.c mISDN/drivers/isdn/hardware/mISDN/ec.c--- /tmp/mISDN/drivers/isdn/hardware/mISDN/ec.c 1970-01-01 01:00:00.000000000 +0100+++ mISDN/drivers/isdn/hardware/mISDN/ec.c 2005-12-02 09:57:08.000000000 +0100@@ -0,0 +1,105 @@+#include "mec2.h"+#include "ec.h"++++#define __ECHO_STATE_MUTE (1 << 8)+#define ECHO_STATE_IDLE (0)+#define ECHO_STATE_PRETRAINING (1 | (__ECHO_STATE_MUTE))+#define ECHO_STATE_STARTTRAINING (2 | (__ECHO_STATE_MUTE))+#define ECHO_STATE_AWAITINGECHO (3 | (__ECHO_STATE_MUTE))+#define ECHO_STATE_TRAINING (4 | (__ECHO_STATE_MUTE))+#define ECHO_STATE_ACTIVE (5)++#define AMI_MASK 0x55++static unsigned char linear2alaw (short linear)+{+ int mask;+ int seg;+ int pcm_val;+ static int seg_end[8] =+ {+ 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF+ };+ + pcm_val = linear;+ if (pcm_val >= 0)+ {+ /* Sign (7th) bit = 1 */+ mask = AMI_MASK | 0x80;+ }+ else+ {+ /* Sign bit = 0 */+ mask = AMI_MASK;+ pcm_val = -pcm_val;+ }++ /* Convert the scaled magnitude to segment number. */+ for (seg = 0; seg < 8; seg++)+ {+ if (pcm_val <= seg_end[seg])+ break;+ }+ /* Combine the sign, segment, and quantization bits. */+ return ((seg << 4) | ((pcm_val >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask;+}+/*- End of function --------------------------------------------------------*/++static short int alaw2linear (uint8_t alaw)+{+ int i;+ int seg;++ alaw ^= AMI_MASK;+ i = ((alaw & 0x0F) << 4);+ seg = (((int) alaw & 0x70) >> 4);+ if (seg)+ i = (i + 0x100) << (seg - 1);+ return (short int) ((alaw & 0x80) ? i : -i);+}+++void ec_chunk(struct echo_can_s *echo_can, unsigned char *rxchunk, const unsigned char *txchunk, int chunk_size)+{+ short rxlin, txlin;+ int x;+ //unsigned long flags;+ /* Perform echo cancellation on a chunk if necessary */+ if (echo_can->ec) {+ if (echo_can->echostate & __ECHO_STATE_MUTE) {+ /* Special stuff for training the echo can */+ for (x=0;x< chunk_size;x++) {+ rxlin = alaw2linear(rxchunk[x]);+ txlin = alaw2linear(txchunk[x]);+ if (echo_can->echostate == ECHO_STATE_PRETRAINING) {+ if (--echo_can->echotimer <= 0) {+ echo_can->echotimer = 0;+ echo_can->echostate = ECHO_STATE_STARTTRAINING;+ }+ }+ if ((echo_can->echostate == ECHO_STATE_AWAITINGECHO) && (txlin > 8000)) {+ echo_can->echolastupdate = 0;+ echo_can->echostate = ECHO_STATE_TRAINING;+ }+ if (echo_can->echostate == ECHO_STATE_TRAINING) {+ if (echo_can_traintap(echo_can->ec, echo_can->echolastupdate++, rxlin)) {+#if 0+ printf("Finished training (%d taps trained)!\n", echo_can->echolastupdate);+#endif + echo_can->echostate = ECHO_STATE_ACTIVE;+ }+ }+ rxlin = 0;+ rxchunk[x] = linear2alaw((int)rxlin);+ }+ } else {+ for (x=0;x<chunk_size;x++) {+ rxlin = alaw2linear(rxchunk[x]);+ rxlin = echo_can_update(echo_can->ec, alaw2linear(txchunk[x]), rxlin);+ rxchunk[x] = linear2alaw((int)rxlin);+ }+ }+ }+}diff -u -r -P /tmp/mISDN/drivers/isdn/hardware/mISDN/ecdis.h mISDN/drivers/isdn/hardware/mISDN/ecdis.h--- /tmp/mISDN/drivers/isdn/hardware/mISDN/ecdis.h 1970-01-01 01:00:00.000000000 +0100+++ mISDN/drivers/isdn/hardware/mISDN/ecdis.h 2005-12-02 09:57:08.000000000 +0100@@ -0,0 +1,118 @@+/*+ * SpanDSP - a series of DSP components for telephony+ *+ * ec_disable_detector.h - A detector which should eventually meet the+ * G.164/G.165 requirements for detecting the+ * 2100Hz echo cancellor disable tone.+ *+ * Written by Steve Underwood <steveu@coppice.org>+ *+ * Copyright (C) 2001 Steve Underwood+ *+ * All rights reserved.+ *+ * This program is free software; you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation; either version 2 of the License, or+ * (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with this program; if not, write to the Free Software+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.+ *+ */++#include "biquad.h"++typedef struct+{+ biquad2_state_t notch;+ int notch_level;+ int channel_level;+ int tone_present;+ int tone_cycle_duration;+ int good_cycles;+ int hit;+} echo_can_disable_detector_state_t;+++#define FALSE 0+#define TRUE (!FALSE)++static inline void echo_can_disable_detector_init (echo_can_disable_detector_state_t *det)+{+ /* Elliptic notch */+ /* This is actually centred at 2095Hz, but gets the balance we want, due+ to the asymmetric walls of the notch */+ biquad2_init (&det->notch,+ (int32_t) (-0.7600000*32768.0),+ (int32_t) (-0.1183852*32768.0),+ (int32_t) (-0.5104039*32768.0),+ (int32_t) ( 0.1567596*32768.0),+ (int32_t) ( 1.0000000*32768.0));++ det->channel_level = 0;+ det->notch_level = 0; + det->tone_present = FALSE;+ det->tone_cycle_duration = 0;+ det->good_cycles = 0;+ det->hit = 0;+}+/*- End of function --------------------------------------------------------*/++static inline int echo_can_disable_detector_update (echo_can_disable_detector_state_t *det,+ int16_t amp)+{+ int16_t notched;+ + notched = biquad2 (&det->notch, amp);+ /* Estimate the overall energy in the channel, and the energy in+ the notch (i.e. overall channel energy - tone energy => noise).+ Use abs instead of multiply for speed (is it really faster?).+ Damp the overall energy a little more for a stable result.+ Damp the notch energy a little less, so we don't damp out the+ blip every time the phase reverses */+ det->channel_level += ((abs(amp) - det->channel_level) >> 5);+ det->notch_level += ((abs(notched) - det->notch_level) >> 4);+ if (det->channel_level > 280)+ {+ /* There is adequate energy in the channel. Is it mostly at 2100Hz? */+ if (det->notch_level*6 < det->channel_level)+ {+ /* The notch says yes, so we have the tone. */+ if (!det->tone_present)+ {+ /* Do we get a kick every 450+-25ms? */+ if (det->tone_cycle_duration >= 425*8+ &&+ det->tone_cycle_duration <= 475*8)+ {+ det->good_cycles++;+ if (det->good_cycles > 2)+ det->hit = TRUE;+ }+ det->tone_cycle_duration = 0;+ }+ det->tone_present = TRUE;+ }+ else+ {+ det->tone_present = FALSE;+ }+ det->tone_cycle_duration++;+ }+ else+ {+ det->tone_present = FALSE;+ det->tone_cycle_duration = 0;+ det->good_cycles = 0;+ }+ return det->hit;+}+/*- End of function --------------------------------------------------------*/+/*- End of file ------------------------------------------------------------*/diff -u -r -P /tmp/mISDN/drivers/isdn/hardware/mISDN/ec.h mISDN/drivers/isdn/hardware/mISDN/ec.h--- /tmp/mISDN/drivers/isdn/hardware/mISDN/ec.h 1970-01-01 01:00:00.000000000 +0100+++ mISDN/drivers/isdn/hardware/mISDN/ec.h 2005-12-02 09:57:08.000000000 +0100@@ -0,0 +1,12 @@++++struct echo_can_s {+ int echostate;+ int echotimer;+ int echolastupdate;+ echo_can_state_t *ec;+}; +++diff -u -r -P /tmp/mISDN/drivers/isdn/hardware/mISDN/hfc_multi.c mISDN/drivers/isdn/hardware/mISDN/hfc_multi.c--- /tmp/mISDN/drivers/isdn/hardware/mISDN/hfc_multi.c 2005-01-31 18:24:03.000000000 +0100+++ mISDN/drivers/isdn/hardware/mISDN/hfc_multi.c 2005-12-02 09:57:08.000000000 +0100@@ -136,7 +136,7 @@ static int nt_t1_count[] = { 480, 240, 120, 60, 30, 15, 8, 4 }; #define CLKDEL_TE 0x0f /* CLKDEL in TE mode */ #define CLKDEL_NT 0x0c /* CLKDEL in NT mode (0x60 MUST not be included!) */-static u_char silence = 0xff; /* silence by LAW */+static u_char mysilence = 0xff; /* silence by LAW */ /* enable 32 bit fifo access (PC usage) */ #define FIFO_32BIT_ACCESS@@ -903,11 +903,11 @@ bch->tx_idx = bch->tx_len = 0; } /* now we have no more data, so in case of transparent,- * we set the last byte in fifo to 'silence' in case we will get+ * we set the last byte in fifo to 'mysilence' in case we will get * no more data at all. this prevents sending an undefined value. */ if (!hdlc)- HFC_outb_(hc, A_FIFO_DATA0_NOINC, silence);+ HFC_outb_(hc, A_FIFO_DATA0_NOINC, mysilence); } @@ -1551,7 +1551,7 @@ HFC_outb(hc, A_IRQ_MSK, 0); HFC_outb(hc, R_INC_RES_FIFO, V_RES_F); HFC_wait(hc);- HFC_outb_(hc, A_FIFO_DATA0_NOINC, silence); /* tx silence */+ HFC_outb_(hc, A_FIFO_DATA0_NOINC, mysilence); /* tx silence */ /* enable RX fifo */ HFC_outb(hc, R_FIFO, (ch<<1)|1); HFC_wait(hc);@@ -1692,7 +1692,7 @@ /* if off */ if (len <= 0) {- HFC_outb_(hc, A_FIFO_DATA0_NOINC, silence);+ HFC_outb_(hc, A_FIFO_DATA0_NOINC, mysilence); if (hc->chan[ch].slot_tx>=0) { if (debug & DEBUG_HFCMULTI_MODE) printk(KERN_DEBUG "%s: connecting PCM due to no more TONE: channel %d slot_tx %d\n", __FUNCTION__, ch, hc->chan[ch].slot_tx);@@ -2183,7 +2183,7 @@ ret = 0; break; - /* set silence */+ /* set mysilence */ case HW_SPL_LOOP_OFF: if (debug & DEBUG_HFCMULTI_MSG) printk(KERN_DEBUG "%s: HW_SPL_LOOP_OFF\n", __FUNCTION__);@@ -2799,7 +2799,13 @@ if (debug & DEBUG_HFCMULTI_INIT) printk(KERN_DEBUG "setup_pci(): investigating card entry %d (looking for type %d)\n", i, hc->type); inuse:++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)+ tmp_dev = pci_get_subsys(id_list[i].vendor_id, id_list[i].device_id, id_list[i].vendor_sub, id_list[i].device_sub, tmp_dev);+#else tmp_dev = pci_find_subsys(id_list[i].vendor_id, id_list[i].device_id, id_list[i].vendor_sub, id_list[i].device_sub, tmp_dev);+#endif+ if (tmp_dev) { /* skip if already in use */ list_for_each_entry_safe(hc_tmp, next, &HFCM_obj.ilist, list) {@@ -3318,9 +3324,9 @@ hc->type = type[HFC_cnt] & 0xff; if (type[HFC_cnt] & 0x100) { test_and_set_bit(HFC_CHIP_ULAW, &hc->chip);- silence = 0xff; /* ulaw silence */+ mysilence = 0xff; /* ulaw silence */ } else- silence = 0x2a; /* alaw silence */+ mysilence = 0x2a; /* alaw silence */ if (type[HFC_cnt] & 0x200) test_and_set_bit(HFC_CHIP_DTMF, &hc->chip); // if ((type[HFC_cnt]&0x400) && hc->type==4)diff -u -r -P /tmp/mISDN/drivers/isdn/hardware/mISDN/l3_udss1.c mISDN/drivers/isdn/hardware/mISDN/l3_udss1.c--- /tmp/mISDN/drivers/isdn/hardware/mISDN/l3_udss1.c 2005-03-26 11:21:39.000000000 +0100+++ mISDN/drivers/isdn/hardware/mISDN/l3_udss1.c 2005-12-02 09:57:08.000000000 +0100@@ -1202,6 +1202,14 @@ err = check_infoelements(pc, skb, ie_PROGRESS); if (err) l3dss1_std_ie_err(pc, err);+ /* START: patch by steinwej - http://www.beronet.com/bugs/bug_view_page.php?bug_id=0000095 */+ /* clear T310 if running */+ L3DelTimer(&pc->timer);+ if (pc->t303skb) {+ dev_kfree_skb(pc->t303skb);+ pc->t303skb = NULL;+ }+ /* END */ if (ERR_IE_COMPREHENSION != err) { if (mISDN_l3up(pc, CC_PROGRESS | INDICATION, skb)) dev_kfree_skb(skb);diff -u -r -P /tmp/mISDN/drivers/isdn/hardware/mISDN/Makefile mISDN/drivers/isdn/hardware/mISDN/Makefile--- /tmp/mISDN/drivers/isdn/hardware/mISDN/Makefile 2005-06-05 14:44:10.000000000 +0200+++ mISDN/drivers/isdn/hardware/mISDN/Makefile 2005-12-05 19:03:11.000000000 +0100@@ -30,6 +30,7 @@ ifdef CONFIG_MISDN_SPEEDFAX obj-$(CONFIG_MISDN_DRV) += sedlfax.o+obj-$(CONFIG_MISDN_DRV) += faxl3.o endif ifdef CONFIG_MISDN_W6692@@ -70,8 +71,6 @@ asn1_basic_service.o asn1_address.o asn1_enc.o capi_enc.o \ supp_serv.o mISDN_dtmf-objs := dtmf.o-mISDN_dsp-objs := dsp_core.o dsp_cmx.o dsp_tones.o dsp_dtmf.o dsp_audio.o dsp_blowfish.o+mISDN_dsp-objs := dsp_core.o dsp_cmx.o dsp_tones.o dsp_dtmf.o dsp_audio.o dsp_blowfish.o dsp_cancel.o mISDN_x25dte-objs := x25_dte.o x25_l3.o I4LmISDN-objs := i4l_mISDN.o--include Rules.mISDNdiff -u -r -P /tmp/mISDN/drivers/isdn/hardware/mISDN/Makefile.v2.6 mISDN/drivers/isdn/hardware/mISDN/Makefile.v2.6--- /tmp/mISDN/drivers/isdn/hardware/mISDN/Makefile.v2.6 2005-06-05 14:44:10.000000000 +0200+++ mISDN/drivers/isdn/hardware/mISDN/Makefile.v2.6 2005-12-02 09:57:08.000000000 +0100@@ -71,6 +71,6 @@ asn1_basic_service.o asn1_address.o asn1_enc.o capi_enc.o \ supp_serv.o mISDN_dtmf-objs := dtmf.o-mISDN_dsp-objs := dsp_core.o dsp_cmx.o dsp_tones.o dsp_dtmf.o dsp_audio.o dsp_blowfish.o+mISDN_dsp-objs := dsp_core.o dsp_cmx.o dsp_tones.o dsp_dtmf.o dsp_audio.o dsp_blowfish.o dsp_cancel.o mISDN_x25dte-objs := x25_dte.o x25_l3.o I4LmISDN-objs := i4l_mISDN.odiff -u -r -P /tmp/mISDN/drivers/isdn/hardware/mISDN/mec2_const.h mISDN/drivers/isdn/hardware/mISDN/mec2_const.h--- /tmp/mISDN/drivers/isdn/hardware/mISDN/mec2_const.h 1970-01-01 01:00:00.000000000 +0100+++ mISDN/drivers/isdn/hardware/mISDN/mec2_const.h 2005-12-02 09:57:08.000000000 +0100@@ -0,0 +1,25 @@+/* + Important constants for tuning mec2 echo can
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?