From: <isc...@us...> - 2007-11-28 10:21:31
|
Revision: 1397 http://astlinux.svn.sourceforge.net/astlinux/?rev=1397&view=rev Author: ischraub Date: 2007-11-28 02:21:29 -0800 (Wed, 28 Nov 2007) Log Message: ----------- mISDN version bump, chan_misdn version bump, rowe oslec patch integrated Modified Paths: -------------- trunk/package/chan_misdn/chan_misdn.mk trunk/package/mqueue-isdn/mqueue-isdn-make.patch trunk/package/mqueue-isdn/mqueue-isdn.mk Added Paths: ----------- trunk/package/mqueue-isdn/config-Makefile.patch trunk/package/mqueue-isdn/mISDN_alaw.patch trunk/package/mqueue-isdn/mISDN_oslec_patch_v1.1.5_rowe Modified: trunk/package/chan_misdn/chan_misdn.mk =================================================================== --- trunk/package/chan_misdn/chan_misdn.mk 2007-11-27 21:45:41 UTC (rev 1396) +++ trunk/package/chan_misdn/chan_misdn.mk 2007-11-28 10:21:29 UTC (rev 1397) @@ -3,7 +3,7 @@ # chan_misdn # ############################################################# -CHANMISDN_VER:=0.3.1-rc29 +CHANMISDN_VER:=0.3.1-rc36 CHANMISDN_SOURCE:=chan_misdn-$(CHANMISDN_VER).tar.gz CHANMISDN_SITE:=http://www.beronet.com/downloads/chan_misdn/stable/candidates CHANMISDN_DIR:=$(BUILD_DIR)/chan_misdn @@ -19,14 +19,16 @@ $(CHANMISDN_DIR)/.configured: $(CHANMISDN_DIR)/.unpacked toolchain/patch-kernel.sh $(CHANMISDN_DIR) package/chan_misdn/ chan_misdn\*.patch + cp $(BUILD_DIR)/asterisk/include/asterisk/lock.h $(BUILD_DIR)/asterisk/include/asterisk/lock.h.backup toolchain/patch-kernel.sh $(BUILD_DIR)/asterisk/include/asterisk package/chan_misdn/ astlock.patch touch $(CHANMISDN_DIR)/.configured $(CHANMISDN_DIR)/.built: $(CHANMISDN_DIR)/.configured - $(MAKE) MISDNUSERLIB=$(TARGET_DIR)/usr/lib CFLAGS+=-I$(BUILD_DIR)/asterisk/include CFLAGS+=-I$(CHANMISDN_DIR)/misdn CFLAGS+=-I$(STAGING_DIR)/include CFLAGS+=-I$(STAGING_DIR)/usr/include CC=$(TARGET_CC) -C $(CHANMISDN_DIR) + $(MAKE) PREFIX=$(STAGING_DIR) MISDNUSERLIB=$(TARGET_DIR)/usr/lib CFLAGS+=-I$(BUILD_DIR)/asterisk/include CFLAGS+=-I$(CHANMISDN_DIR)/misdn CFLAGS+=-I$(STAGING_DIR)/include CFLAGS+=-I$(STAGING_DIR)/usr/include CC=$(TARGET_CC) -C $(CHANMISDN_DIR) $(INSTALL) -m 644 $(CHANMISDN_DIR)/chan_misdn.so $(TARGET_DIR)/usr/lib/asterisk/modules/ $(STRIP) --strip-unneeded $(TARGET_DIR)/usr/lib/asterisk/modules/chan_misdn.so cp $(CHANMISDN_DIR)/misdn.conf $(TARGET_DIR)/stat/etc/asterisk/ + cp $(BUILD_DIR)/asterisk/include/asterisk/lock.h.backup $(BUILD_DIR)/asterisk/include/asterisk/lock.h touch $(CHANMISDN_DIR)/.built chan_misdn: uclibc linux asterisk mqueue_misdn $(CHANMISDN_DIR)/.built Added: trunk/package/mqueue-isdn/config-Makefile.patch =================================================================== --- trunk/package/mqueue-isdn/config-Makefile.patch (rev 0) +++ trunk/package/mqueue-isdn/config-Makefile.patch 2007-11-28 10:21:29 UTC (rev 1397) @@ -0,0 +1,9 @@ +--- config/Makefile.orig 2007-05-29 14:23:39.000000000 +0200 ++++ config/Makefile 2007-05-29 14:24:13.000000000 +0200 +@@ -7,5 +7,5 @@ + for file in $(shell echo *.xsl); do install -D -m644 $${file} $(INSTALL_PREFIX)/usr/lib/mISDN/$${file}; done + if [ -d $(INSTALL_PREFIX)/etc/init.d ]; then \ + if [ -e $(INSTALL_PREFIX)/etc/init.d/mISDN ]; then rm -rf $(INSTALL_PREFIX)/etc/init.d/mISDN; fi; \ +- ln -s $(INSTALL_PREFIX)/usr/sbin/mISDN $(INSTALL_PREFIX)/etc/init.d/mISDN; \ ++ ln -s ../../usr/sbin/mISDN $(INSTALL_PREFIX)/etc/init.d/mISDN; \ + fi Added: trunk/package/mqueue-isdn/mISDN_alaw.patch =================================================================== --- trunk/package/mqueue-isdn/mISDN_alaw.patch (rev 0) +++ trunk/package/mqueue-isdn/mISDN_alaw.patch 2007-11-28 10:21:29 UTC (rev 1397) @@ -0,0 +1,634 @@ +--- /home/peter/src/mISDN-1_1_5/drivers/isdn/hardware/mISDN/dsp_audio.c 2007-07-02 11:31:34.000000000 +0200 ++++ ./dsp_audio.c 2007-11-23 18:33:02.000000000 +0100 +@@ -15,331 +15,173 @@ + #include "dsp.h" + + /* ulaw[unsigned char] -> signed 16-bit */ +-s32 dsp_audio_ulaw_to_s32[256] = +-{ +- 0xffff8284, 0xffff8684, 0xffff8a84, 0xffff8e84, +- 0xffff9284, 0xffff9684, 0xffff9a84, 0xffff9e84, +- 0xffffa284, 0xffffa684, 0xffffaa84, 0xffffae84, +- 0xffffb284, 0xffffb684, 0xffffba84, 0xffffbe84, +- 0xffffc184, 0xffffc384, 0xffffc584, 0xffffc784, +- 0xffffc984, 0xffffcb84, 0xffffcd84, 0xffffcf84, +- 0xffffd184, 0xffffd384, 0xffffd584, 0xffffd784, +- 0xffffd984, 0xffffdb84, 0xffffdd84, 0xffffdf84, +- 0xffffe104, 0xffffe204, 0xffffe304, 0xffffe404, +- 0xffffe504, 0xffffe604, 0xffffe704, 0xffffe804, +- 0xffffe904, 0xffffea04, 0xffffeb04, 0xffffec04, +- 0xffffed04, 0xffffee04, 0xffffef04, 0xfffff004, +- 0xfffff0c4, 0xfffff144, 0xfffff1c4, 0xfffff244, +- 0xfffff2c4, 0xfffff344, 0xfffff3c4, 0xfffff444, +- 0xfffff4c4, 0xfffff544, 0xfffff5c4, 0xfffff644, +- 0xfffff6c4, 0xfffff744, 0xfffff7c4, 0xfffff844, +- 0xfffff8a4, 0xfffff8e4, 0xfffff924, 0xfffff964, +- 0xfffff9a4, 0xfffff9e4, 0xfffffa24, 0xfffffa64, +- 0xfffffaa4, 0xfffffae4, 0xfffffb24, 0xfffffb64, +- 0xfffffba4, 0xfffffbe4, 0xfffffc24, 0xfffffc64, +- 0xfffffc94, 0xfffffcb4, 0xfffffcd4, 0xfffffcf4, +- 0xfffffd14, 0xfffffd34, 0xfffffd54, 0xfffffd74, +- 0xfffffd94, 0xfffffdb4, 0xfffffdd4, 0xfffffdf4, +- 0xfffffe14, 0xfffffe34, 0xfffffe54, 0xfffffe74, +- 0xfffffe8c, 0xfffffe9c, 0xfffffeac, 0xfffffebc, +- 0xfffffecc, 0xfffffedc, 0xfffffeec, 0xfffffefc, +- 0xffffff0c, 0xffffff1c, 0xffffff2c, 0xffffff3c, +- 0xffffff4c, 0xffffff5c, 0xffffff6c, 0xffffff7c, +- 0xffffff88, 0xffffff90, 0xffffff98, 0xffffffa0, +- 0xffffffa8, 0xffffffb0, 0xffffffb8, 0xffffffc0, +- 0xffffffc8, 0xffffffd0, 0xffffffd8, 0xffffffe0, +- 0xffffffe8, 0xfffffff0, 0xfffffff8, 0xffffffff, +- 0x00007d7c, 0x0000797c, 0x0000757c, 0x0000717c, +- 0x00006d7c, 0x0000697c, 0x0000657c, 0x0000617c, +- 0x00005d7c, 0x0000597c, 0x0000557c, 0x0000517c, +- 0x00004d7c, 0x0000497c, 0x0000457c, 0x0000417c, +- 0x00003e7c, 0x00003c7c, 0x00003a7c, 0x0000387c, +- 0x0000367c, 0x0000347c, 0x0000327c, 0x0000307c, +- 0x00002e7c, 0x00002c7c, 0x00002a7c, 0x0000287c, +- 0x0000267c, 0x0000247c, 0x0000227c, 0x0000207c, +- 0x00001efc, 0x00001dfc, 0x00001cfc, 0x00001bfc, +- 0x00001afc, 0x000019fc, 0x000018fc, 0x000017fc, +- 0x000016fc, 0x000015fc, 0x000014fc, 0x000013fc, +- 0x000012fc, 0x000011fc, 0x000010fc, 0x00000ffc, +- 0x00000f3c, 0x00000ebc, 0x00000e3c, 0x00000dbc, +- 0x00000d3c, 0x00000cbc, 0x00000c3c, 0x00000bbc, +- 0x00000b3c, 0x00000abc, 0x00000a3c, 0x000009bc, +- 0x0000093c, 0x000008bc, 0x0000083c, 0x000007bc, +- 0x0000075c, 0x0000071c, 0x000006dc, 0x0000069c, +- 0x0000065c, 0x0000061c, 0x000005dc, 0x0000059c, +- 0x0000055c, 0x0000051c, 0x000004dc, 0x0000049c, +- 0x0000045c, 0x0000041c, 0x000003dc, 0x0000039c, +- 0x0000036c, 0x0000034c, 0x0000032c, 0x0000030c, +- 0x000002ec, 0x000002cc, 0x000002ac, 0x0000028c, +- 0x0000026c, 0x0000024c, 0x0000022c, 0x0000020c, +- 0x000001ec, 0x000001cc, 0x000001ac, 0x0000018c, +- 0x00000174, 0x00000164, 0x00000154, 0x00000144, +- 0x00000134, 0x00000124, 0x00000114, 0x00000104, +- 0x000000f4, 0x000000e4, 0x000000d4, 0x000000c4, +- 0x000000b4, 0x000000a4, 0x00000094, 0x00000084, +- 0x00000078, 0x00000070, 0x00000068, 0x00000060, +- 0x00000058, 0x00000050, 0x00000048, 0x00000040, +- 0x00000038, 0x00000030, 0x00000028, 0x00000020, +- 0x00000018, 0x00000010, 0x00000008, 0x00000000 +-}; +- ++s32 dsp_audio_ulaw_to_s32[256]; + /* alaw[unsigned char] -> signed 16-bit */ +-s32 dsp_audio_alaw_to_s32[256] = +-{ +- 0x000013fc, 0xffffec04, 0x00000144, 0xfffffebc, +- 0x0000517c, 0xffffae84, 0x0000051c, 0xfffffae4, +- 0x00000a3c, 0xfffff5c4, 0x00000048, 0xffffffb8, +- 0x0000287c, 0xffffd784, 0x0000028c, 0xfffffd74, +- 0x00001bfc, 0xffffe404, 0x000001cc, 0xfffffe34, +- 0x0000717c, 0xffff8e84, 0x0000071c, 0xfffff8e4, +- 0x00000e3c, 0xfffff1c4, 0x000000c4, 0xffffff3c, +- 0x0000387c, 0xffffc784, 0x0000039c, 0xfffffc64, +- 0x00000ffc, 0xfffff004, 0x00000104, 0xfffffefc, +- 0x0000417c, 0xffffbe84, 0x0000041c, 0xfffffbe4, +- 0x0000083c, 0xfffff7c4, 0x00000008, 0xfffffff8, +- 0x0000207c, 0xffffdf84, 0x0000020c, 0xfffffdf4, +- 0x000017fc, 0xffffe804, 0x0000018c, 0xfffffe74, +- 0x0000617c, 0xffff9e84, 0x0000061c, 0xfffff9e4, +- 0x00000c3c, 0xfffff3c4, 0x00000084, 0xffffff7c, +- 0x0000307c, 0xffffcf84, 0x0000030c, 0xfffffcf4, +- 0x000015fc, 0xffffea04, 0x00000164, 0xfffffe9c, +- 0x0000597c, 0xffffa684, 0x0000059c, 0xfffffa64, +- 0x00000b3c, 0xfffff4c4, 0x00000068, 0xffffff98, +- 0x00002c7c, 0xffffd384, 0x000002cc, 0xfffffd34, +- 0x00001dfc, 0xffffe204, 0x000001ec, 0xfffffe14, +- 0x0000797c, 0xffff8684, 0x000007bc, 0xfffff844, +- 0x00000f3c, 0xfffff0c4, 0x000000e4, 0xffffff1c, +- 0x00003c7c, 0xffffc384, 0x000003dc, 0xfffffc24, +- 0x000011fc, 0xffffee04, 0x00000124, 0xfffffedc, +- 0x0000497c, 0xffffb684, 0x0000049c, 0xfffffb64, +- 0x0000093c, 0xfffff6c4, 0x00000028, 0xffffffd8, +- 0x0000247c, 0xffffdb84, 0x0000024c, 0xfffffdb4, +- 0x000019fc, 0xffffe604, 0x000001ac, 0xfffffe54, +- 0x0000697c, 0xffff9684, 0x0000069c, 0xfffff964, +- 0x00000d3c, 0xfffff2c4, 0x000000a4, 0xffffff5c, +- 0x0000347c, 0xffffcb84, 0x0000034c, 0xfffffcb4, +- 0x000012fc, 0xffffed04, 0x00000134, 0xfffffecc, +- 0x00004d7c, 0xffffb284, 0x000004dc, 0xfffffb24, +- 0x000009bc, 0xfffff644, 0x00000038, 0xffffffc8, +- 0x0000267c, 0xffffd984, 0x0000026c, 0xfffffd94, +- 0x00001afc, 0xffffe504, 0x000001ac, 0xfffffe54, +- 0x00006d7c, 0xffff9284, 0x000006dc, 0xfffff924, +- 0x00000dbc, 0xfffff244, 0x000000b4, 0xffffff4c, +- 0x0000367c, 0xffffc984, 0x0000036c, 0xfffffc94, +- 0x00000f3c, 0xfffff0c4, 0x000000f4, 0xffffff0c, +- 0x00003e7c, 0xffffc184, 0x000003dc, 0xfffffc24, +- 0x000007bc, 0xfffff844, 0x00000008, 0xfffffff8, +- 0x00001efc, 0xffffe104, 0x000001ec, 0xfffffe14, +- 0x000016fc, 0xffffe904, 0x00000174, 0xfffffe8c, +- 0x00005d7c, 0xffffa284, 0x000005dc, 0xfffffa24, +- 0x00000bbc, 0xfffff444, 0x00000078, 0xffffff88, +- 0x00002e7c, 0xffffd184, 0x000002ec, 0xfffffd14, +- 0x000014fc, 0xffffeb04, 0x00000154, 0xfffffeac, +- 0x0000557c, 0xffffaa84, 0x0000055c, 0xfffffaa4, +- 0x00000abc, 0xfffff544, 0x00000058, 0xffffffa8, +- 0x00002a7c, 0xffffd584, 0x000002ac, 0xfffffd54, +- 0x00001cfc, 0xffffe304, 0x000001cc, 0xfffffe34, +- 0x0000757c, 0xffff8a84, 0x0000075c, 0xfffff8a4, +- 0x00000ebc, 0xfffff144, 0x000000d4, 0xffffff2c, +- 0x00003a7c, 0xffffc584, 0x0000039c, 0xfffffc64, +- 0x000010fc, 0xffffef04, 0x00000114, 0xfffffeec, +- 0x0000457c, 0xffffba84, 0x0000045c, 0xfffffba4, +- 0x000008bc, 0xfffff744, 0x00000018, 0xffffffe8, +- 0x0000227c, 0xffffdd84, 0x0000022c, 0xfffffdd4, +- 0x000018fc, 0xffffe704, 0x0000018c, 0xfffffe74, +- 0x0000657c, 0xffff9a84, 0x0000065c, 0xfffff9a4, +- 0x00000cbc, 0xfffff344, 0x00000094, 0xffffff6c, +- 0x0000327c, 0xffffcd84, 0x0000032c, 0xfffffcd4 +-}; ++s32 dsp_audio_alaw_to_s32[256]; + + s32 *dsp_audio_law_to_s32; + + /* signed 16-bit -> law */ + u8 dsp_audio_s16_to_law[65536]; + +-/* table is used to generate s16_to_alaw */ +-static short dsp_audio_alaw_relations[512] = ++/* alaw -> ulaw */ ++u8 dsp_audio_alaw_to_ulaw[256]; ++/* ulaw -> alaw */ ++u8 dsp_audio_ulaw_to_alaw[256]; ++u8 dsp_silence; ++ ++ ++/***************************************************** ++ * generate table for conversion of s16 to alaw/ulaw * ++ *****************************************************/ ++ ++#define AMI_MASK 0x55 ++ ++static inline unsigned char linear2alaw (short int linear) + { +- 0x8684, 0x55, 0x8a84, 0xd5, 0x8e84, 0x15, 0x9284, 0x95, +- 0x9684, 0x75, 0x9a84, 0xf5, 0x9e84, 0x35, 0xa284, 0xb5, +- 0xa684, 0x45, 0xaa84, 0xc5, 0xae84, 0x05, 0xb284, 0x85, +- 0xb684, 0x65, 0xba84, 0xe5, 0xbe84, 0x25, 0xc184, 0xa5, +- 0xc384, 0x5d, 0xc584, 0xdd, 0xc784, 0x1d, 0xc984, 0x9d, +- 0xcb84, 0x7d, 0xcd84, 0xfd, 0xcf84, 0x3d, 0xd184, 0xbd, +- 0xd384, 0x4d, 0xd584, 0xcd, 0xd784, 0x0d, 0xd984, 0x8d, +- 0xdb84, 0x6d, 0xdd84, 0xed, 0xdf84, 0x2d, 0xe104, 0xad, +- 0xe204, 0x51, 0xe304, 0xd1, 0xe404, 0x11, 0xe504, 0x91, +- 0xe604, 0x71, 0xe704, 0xf1, 0xe804, 0x31, 0xe904, 0xb1, +- 0xea04, 0x41, 0xeb04, 0xc1, 0xec04, 0x01, 0xed04, 0x81, +- 0xee04, 0x61, 0xef04, 0xe1, 0xf004, 0x21, 0xf0c4, 0x59, +- 0xf0c4, 0xa1, 0xf144, 0xd9, 0xf1c4, 0x19, 0xf244, 0x99, +- 0xf2c4, 0x79, 0xf344, 0xf9, 0xf3c4, 0x39, 0xf444, 0xb9, +- 0xf4c4, 0x49, 0xf544, 0xc9, 0xf5c4, 0x09, 0xf644, 0x89, +- 0xf6c4, 0x69, 0xf744, 0xe9, 0xf7c4, 0x29, 0xf844, 0x57, +- 0xf844, 0xa9, 0xf8a4, 0xd7, 0xf8e4, 0x17, 0xf924, 0x97, +- 0xf964, 0x77, 0xf9a4, 0xf7, 0xf9e4, 0x37, 0xfa24, 0xb7, +- 0xfa64, 0x47, 0xfaa4, 0xc7, 0xfae4, 0x07, 0xfb24, 0x87, +- 0xfb64, 0x67, 0xfba4, 0xe7, 0xfbe4, 0x27, 0xfc24, 0x5f, +- 0xfc24, 0xa7, 0xfc64, 0x1f, 0xfc64, 0xdf, 0xfc94, 0x9f, +- 0xfcb4, 0x7f, 0xfcd4, 0xff, 0xfcf4, 0x3f, 0xfd14, 0xbf, +- 0xfd34, 0x4f, 0xfd54, 0xcf, 0xfd74, 0x0f, 0xfd94, 0x8f, +- 0xfdb4, 0x6f, 0xfdd4, 0xef, 0xfdf4, 0x2f, 0xfe14, 0x53, +- 0xfe14, 0xaf, 0xfe34, 0x13, 0xfe34, 0xd3, 0xfe54, 0x73, +- 0xfe54, 0x93, 0xfe74, 0x33, 0xfe74, 0xf3, 0xfe8c, 0xb3, +- 0xfe9c, 0x43, 0xfeac, 0xc3, 0xfebc, 0x03, 0xfecc, 0x83, +- 0xfedc, 0x63, 0xfeec, 0xe3, 0xfefc, 0x23, 0xff0c, 0xa3, +- 0xff1c, 0x5b, 0xff2c, 0xdb, 0xff3c, 0x1b, 0xff4c, 0x9b, +- 0xff5c, 0x7b, 0xff6c, 0xfb, 0xff7c, 0x3b, 0xff88, 0xbb, +- 0xff98, 0x4b, 0xffa8, 0xcb, 0xffb8, 0x0b, 0xffc8, 0x8b, +- 0xffd8, 0x6b, 0xffe8, 0xeb, 0xfff8, 0x2b, 0xfff8, 0xab, +- 0x0008, 0x2a, 0x0008, 0xaa, 0x0018, 0xea, 0x0028, 0x6a, +- 0x0038, 0x8a, 0x0048, 0x0a, 0x0058, 0xca, 0x0068, 0x4a, +- 0x0078, 0xba, 0x0084, 0x3a, 0x0094, 0xfa, 0x00a4, 0x7a, +- 0x00b4, 0x9a, 0x00c4, 0x1a, 0x00d4, 0xda, 0x00e4, 0x5a, +- 0x00f4, 0xa2, 0x0104, 0x22, 0x0114, 0xe2, 0x0124, 0x62, +- 0x0134, 0x82, 0x0144, 0x02, 0x0154, 0xc2, 0x0164, 0x42, +- 0x0174, 0xb2, 0x018c, 0x32, 0x018c, 0xf2, 0x01ac, 0x72, +- 0x01ac, 0x92, 0x01cc, 0x12, 0x01cc, 0xd2, 0x01ec, 0x52, +- 0x01ec, 0xae, 0x020c, 0x2e, 0x022c, 0xee, 0x024c, 0x6e, +- 0x026c, 0x8e, 0x028c, 0x0e, 0x02ac, 0xce, 0x02cc, 0x4e, +- 0x02ec, 0xbe, 0x030c, 0x3e, 0x032c, 0xfe, 0x034c, 0x7e, +- 0x036c, 0x9e, 0x039c, 0x1e, 0x039c, 0xde, 0x03dc, 0x5e, +- 0x03dc, 0xa6, 0x041c, 0x26, 0x045c, 0xe6, 0x049c, 0x66, +- 0x04dc, 0x86, 0x051c, 0x06, 0x055c, 0xc6, 0x059c, 0x46, +- 0x05dc, 0xb6, 0x061c, 0x36, 0x065c, 0xf6, 0x069c, 0x76, +- 0x06dc, 0x96, 0x071c, 0x16, 0x075c, 0xd6, 0x07bc, 0x56, +- 0x07bc, 0xa8, 0x083c, 0x28, 0x08bc, 0xe8, 0x093c, 0x68, +- 0x09bc, 0x88, 0x0a3c, 0x08, 0x0abc, 0xc8, 0x0b3c, 0x48, +- 0x0bbc, 0xb8, 0x0c3c, 0x38, 0x0cbc, 0xf8, 0x0d3c, 0x78, +- 0x0dbc, 0x98, 0x0e3c, 0x18, 0x0ebc, 0xd8, 0x0f3c, 0x58, +- 0x0f3c, 0xa0, 0x0ffc, 0x20, 0x10fc, 0xe0, 0x11fc, 0x60, +- 0x12fc, 0x80, 0x13fc, 0x00, 0x14fc, 0xc0, 0x15fc, 0x40, +- 0x16fc, 0xb0, 0x17fc, 0x30, 0x18fc, 0xf0, 0x19fc, 0x70, +- 0x1afc, 0x90, 0x1bfc, 0x10, 0x1cfc, 0xd0, 0x1dfc, 0x50, +- 0x1efc, 0xac, 0x207c, 0x2c, 0x227c, 0xec, 0x247c, 0x6c, +- 0x267c, 0x8c, 0x287c, 0x0c, 0x2a7c, 0xcc, 0x2c7c, 0x4c, +- 0x2e7c, 0xbc, 0x307c, 0x3c, 0x327c, 0xfc, 0x347c, 0x7c, +- 0x367c, 0x9c, 0x387c, 0x1c, 0x3a7c, 0xdc, 0x3c7c, 0x5c, +- 0x3e7c, 0xa4, 0x417c, 0x24, 0x457c, 0xe4, 0x497c, 0x64, +- 0x4d7c, 0x84, 0x517c, 0x04, 0x557c, 0xc4, 0x597c, 0x44, +- 0x5d7c, 0xb4, 0x617c, 0x34, 0x657c, 0xf4, 0x697c, 0x74, +- 0x6d7c, 0x94, 0x717c, 0x14, 0x757c, 0xd4, 0x797c, 0x54 +-}; ++ 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; ++} + +-/* alaw -> ulaw */ +-u8 dsp_audio_alaw_to_ulaw[256] = ++ ++static inline short int alaw2linear (unsigned char alaw) + { +- 0xab, 0x2b, 0xe3, 0x63, 0x8b, 0x0b, 0xc9, 0x49, +- 0xba, 0x3a, 0xf6, 0x76, 0x9b, 0x1b, 0xd7, 0x57, +- 0xa3, 0x23, 0xdd, 0x5d, 0x83, 0x03, 0xc1, 0x41, +- 0xb2, 0x32, 0xeb, 0x6b, 0x93, 0x13, 0xcf, 0x4f, +- 0xaf, 0x2f, 0xe7, 0x67, 0x8f, 0x0f, 0xcd, 0x4d, +- 0xbe, 0x3e, 0xfe, 0x7e, 0x9f, 0x1f, 0xdb, 0x5b, +- 0xa7, 0x27, 0xdf, 0x5f, 0x87, 0x07, 0xc5, 0x45, +- 0xb6, 0x36, 0xef, 0x6f, 0x97, 0x17, 0xd3, 0x53, +- 0xa9, 0x29, 0xe1, 0x61, 0x89, 0x09, 0xc7, 0x47, +- 0xb8, 0x38, 0xf2, 0x72, 0x99, 0x19, 0xd5, 0x55, +- 0xa1, 0x21, 0xdc, 0x5c, 0x81, 0x01, 0xbf, 0x3f, +- 0xb0, 0x30, 0xe9, 0x69, 0x91, 0x11, 0xce, 0x4e, +- 0xad, 0x2d, 0xe5, 0x65, 0x8d, 0x0d, 0xcb, 0x4b, +- 0xbc, 0x3c, 0xfa, 0x7a, 0x9d, 0x1d, 0xd9, 0x59, +- 0xa5, 0x25, 0xde, 0x5e, 0x85, 0x05, 0xc3, 0x43, +- 0xb4, 0x34, 0xed, 0x6d, 0x95, 0x15, 0xd1, 0x51, +- 0xac, 0x2c, 0xe4, 0x64, 0x8c, 0x0c, 0xca, 0x4a, +- 0xbb, 0x3b, 0xf8, 0x78, 0x9c, 0x1c, 0xd8, 0x58, +- 0xa4, 0x24, 0xde, 0x5e, 0x84, 0x04, 0xc2, 0x42, +- 0xb3, 0x33, 0xec, 0x6c, 0x94, 0x14, 0xd0, 0x50, +- 0xb0, 0x30, 0xe8, 0x68, 0x90, 0x10, 0xce, 0x4e, +- 0xbf, 0x3f, 0xfe, 0x7e, 0xa0, 0x20, 0xdc, 0x5c, +- 0xa8, 0x28, 0xe0, 0x60, 0x88, 0x08, 0xc6, 0x46, +- 0xb7, 0x37, 0xf0, 0x70, 0x98, 0x18, 0xd4, 0x54, +- 0xaa, 0x2a, 0xe2, 0x62, 0x8a, 0x0a, 0xc8, 0x48, +- 0xb9, 0x39, 0xf4, 0x74, 0x9a, 0x1a, 0xd6, 0x56, +- 0xa2, 0x22, 0xdd, 0x5d, 0x82, 0x02, 0xc0, 0x40, +- 0xb1, 0x31, 0xea, 0x6a, 0x92, 0x12, 0xcf, 0x4f, +- 0xae, 0x2e, 0xe6, 0x66, 0x8e, 0x0e, 0xcc, 0x4c, +- 0xbd, 0x3d, 0xfc, 0x7c, 0x9e, 0x1e, 0xda, 0x5a, +- 0xa6, 0x26, 0xdf, 0x5f, 0x86, 0x06, 0xc4, 0x44, +- 0xb5, 0x35, 0xee, 0x6e, 0x96, 0x16, 0xd2, 0x52 +-}; ++ int i; ++ int seg; + +-/* ulaw -> alaw */ +-u8 dsp_audio_ulaw_to_alaw[256] = ++ alaw ^= AMI_MASK; ++ i = ((alaw & 0x0F) << 4) + 8 /* rounding error */; ++ seg = (((int) alaw & 0x70) >> 4); ++ if (seg) ++ i = (i + 0x100) << (seg - 1); ++ return (short int) ((alaw & 0x80) ? i : -i); ++} ++ ++static inline short int ulaw2linear(unsigned char ulaw) + { +- 0xab, 0x55, 0xd5, 0x15, 0x95, 0x75, 0xf5, 0x35, +- 0xb5, 0x45, 0xc5, 0x05, 0x85, 0x65, 0xe5, 0x25, +- 0xa5, 0x5d, 0xdd, 0x1d, 0x9d, 0x7d, 0xfd, 0x3d, +- 0xbd, 0x4d, 0xcd, 0x0d, 0x8d, 0x6d, 0xed, 0x2d, +- 0xad, 0x51, 0xd1, 0x11, 0x91, 0x71, 0xf1, 0x31, +- 0xb1, 0x41, 0xc1, 0x01, 0x81, 0x61, 0xe1, 0x21, +- 0x59, 0xd9, 0x19, 0x99, 0x79, 0xf9, 0x39, 0xb9, +- 0x49, 0xc9, 0x09, 0x89, 0x69, 0xe9, 0x29, 0xa9, +- 0xd7, 0x17, 0x97, 0x77, 0xf7, 0x37, 0xb7, 0x47, +- 0xc7, 0x07, 0x87, 0x67, 0xe7, 0x27, 0xa7, 0xdf, +- 0x9f, 0x7f, 0xff, 0x3f, 0xbf, 0x4f, 0xcf, 0x0f, +- 0x8f, 0x6f, 0xef, 0x2f, 0x53, 0x13, 0x73, 0x33, +- 0xb3, 0x43, 0xc3, 0x03, 0x83, 0x63, 0xe3, 0x23, +- 0xa3, 0x5b, 0xdb, 0x1b, 0x9b, 0x7b, 0xfb, 0x3b, +- 0xbb, 0xbb, 0x4b, 0x4b, 0xcb, 0xcb, 0x0b, 0x0b, +- 0x8b, 0x8b, 0x6b, 0x6b, 0xeb, 0xeb, 0x2b, 0x2b, +- 0xab, 0x54, 0xd4, 0x14, 0x94, 0x74, 0xf4, 0x34, +- 0xb4, 0x44, 0xc4, 0x04, 0x84, 0x64, 0xe4, 0x24, +- 0xa4, 0x5c, 0xdc, 0x1c, 0x9c, 0x7c, 0xfc, 0x3c, +- 0xbc, 0x4c, 0xcc, 0x0c, 0x8c, 0x6c, 0xec, 0x2c, +- 0xac, 0x50, 0xd0, 0x10, 0x90, 0x70, 0xf0, 0x30, +- 0xb0, 0x40, 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x20, +- 0x58, 0xd8, 0x18, 0x98, 0x78, 0xf8, 0x38, 0xb8, +- 0x48, 0xc8, 0x08, 0x88, 0x68, 0xe8, 0x28, 0xa8, +- 0xd6, 0x16, 0x96, 0x76, 0xf6, 0x36, 0xb6, 0x46, +- 0xc6, 0x06, 0x86, 0x66, 0xe6, 0x26, 0xa6, 0xde, +- 0x9e, 0x7e, 0xfe, 0x3e, 0xbe, 0x4e, 0xce, 0x0e, +- 0x8e, 0x6e, 0xee, 0x2e, 0x52, 0x12, 0x72, 0x32, +- 0xb2, 0x42, 0xc2, 0x02, 0x82, 0x62, 0xe2, 0x22, +- 0xa2, 0x5a, 0xda, 0x1a, 0x9a, 0x7a, 0xfa, 0x3a, +- 0xba, 0xba, 0x4a, 0x4a, 0xca, 0xca, 0x0a, 0x0a, +- 0x8a, 0x8a, 0x6a, 0x6a, 0xea, 0xea, 0x2a, 0x2a +-}; ++ short mu, e, f, y; ++ static short etab[] = {0,132,396,924,1980,4092,8316,16764}; + +-u8 dsp_silence; ++ mu = 255 - ulaw; ++ e = (mu & 0x70) / 16; ++ f = mu & 0x0f; ++ y = f * (1 << (e + 3)); ++ y += etab[e]; ++ if (mu & 0x80) ++ y = -y; ++ return y; ++} + ++#define BIAS 0x84 /*!< define the add-in bias for 16 bit samples */ + +-/***************************************************** +- * generate table for conversion of s16 to alaw/ulaw * +- *****************************************************/ ++static unsigned char linear2ulaw(short sample) ++{ ++ static int exp_lut[256] = { ++ 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3, ++ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, ++ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, ++ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, ++ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, ++ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, ++ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, ++ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 }; ++ int sign, exponent, mantissa; ++ unsigned char ulawbyte; ++ ++ /* Get the sample into sign-magnitude. */ ++ sign = (sample >> 8) & 0x80; /* set aside the sign */ ++ if (sign != 0) ++ sample = -sample; /* get magnitude */ ++ ++ /* Convert from 16 bit linear to ulaw. */ ++ sample = sample + BIAS; ++ exponent = exp_lut[(sample >> 7) & 0xFF]; ++ mantissa = (sample >> (exponent + 3)) & 0x0F; ++ ulawbyte = ~(sign | (exponent << 4) | mantissa); ++ ++ return ulawbyte; ++} ++ ++static int reverse_bits(int i) ++{ ++ int z,j; ++ z = 0; ++ ++ for (j = 0; j < 8; j++) { ++ if ((i & (1 << j)) != 0) { ++ z |= 1 << (7 - j); ++ } ++ } ++ return z; ++} ++ ++ ++void dsp_audio_generate_law_tables(void) ++{ ++ int i; ++ for (i = 0; i < 256; i++) { ++ dsp_audio_alaw_to_s32[i] = alaw2linear(reverse_bits(i)); ++ } ++ ++ for (i = 0; i < 256; i++) { ++ dsp_audio_ulaw_to_s32[i] = ulaw2linear(reverse_bits(i)); ++ } ++ ++ for (i = 0; i < 256; i++) { ++ dsp_audio_alaw_to_ulaw[i] = ++ linear2ulaw(dsp_audio_alaw_to_s32[i]); ++ dsp_audio_ulaw_to_alaw[i] = ++ linear2alaw(dsp_audio_ulaw_to_s32[i]); ++ } ++} + + void + dsp_audio_generate_s2law_table(void) + { +- int i, j; ++ int i; + + if (dsp_options & DSP_OPT_ULAW) { + /* generating ulaw-table */ +- i = j = 0; +- while(i < 32768) { +- if (i-32768 > dsp_audio_law_to_s32[j]) +- j++; +- dsp_audio_s16_to_law[(i-32768) & 0xffff] = j; +- i++; +- } +- j = 255; +- while(i < 65536) { +- if (i-32768 > dsp_audio_law_to_s32[j]) +- j--; +- dsp_audio_s16_to_law[(i-32768) & 0xffff] = j; +- i++; ++ for (i = -32768; i < 32768; i++) { ++ dsp_audio_s16_to_law[i & 0xffff] = ++ reverse_bits(linear2ulaw(i)); + } + } else { + /* generating alaw-table */ +- i = j = 0; +- while(i < 65536) { +- if (i-32768 > dsp_audio_alaw_relations[j<<1]) +- j++; +- if (j>255) +- j=255; +- dsp_audio_s16_to_law[(i-32768) & 0xffff] +- = dsp_audio_alaw_relations[(j<<1)|1]; +- i++; ++ for (i = -32768; i < 32768; i++) { ++ dsp_audio_s16_to_law[i & 0xffff] = ++ reverse_bits(linear2alaw(i)); + } + } + } +@@ -359,43 +201,42 @@ + void + dsp_audio_generate_seven(void) + { +- int i, j; +- u8 spl; +- +- /* conversion from law to seven bit audio */ +- i = 0; +- while(i < 256) { +- /* spl is the source: the law-sample (converted to alaw) */ +- spl = i; +- if (dsp_options & DSP_OPT_ULAW) +- spl = dsp_audio_ulaw_to_alaw[i]; +- /* find the 7-bit-sample */ +- j = 0; +- while(j < 256) { +- if (dsp_audio_alaw_relations[(j<<1)|1] == spl) +- break; +- j++; +- } +- if (j == 256) { +- printk(KERN_WARNING "fatal error in %s: alaw-sample '0x%2x' not found in relations-table.\n", __FUNCTION__, spl); +- } +- /* write 7-bit audio value */ +- dsp_audio_law2seven[i] = j >> 1; +- i++; +- } +- +- /* conversion from seven bit audio to law */ +- i = 0; +- while(i < 128) { +- /* find alaw-spl */ +- spl = dsp_audio_alaw_relations[(i<<2)|1]; +- /* convert to ulaw, if required */ +- if (dsp_options & DSP_OPT_ULAW) +- spl = dsp_audio_alaw_to_ulaw[spl]; +- /* write 8-bit law sample */ +- dsp_audio_seven2law[i] = spl; +- i++; +- } ++ int i, j, k; ++ u8 spl; ++ u8 sorted_alaw[256]; ++ ++ /* generate alaw table, sorted by the linear value */ ++ for (i = 0; i < 256; i++) { ++ j = 0; ++ for (k = 0; k < 256; k++) { ++ if (dsp_audio_alaw_to_s32[k] ++ < dsp_audio_alaw_to_s32[i]) { ++ j++; ++ } ++ } ++ sorted_alaw[j] = i; ++ } ++ ++ /* generate tabels */ ++ for (i = 0; i < 256; i++) { ++ /* spl is the source: the law-sample (converted to alaw) */ ++ spl = i; ++ if (dsp_options & DSP_OPT_ULAW) ++ spl = dsp_audio_ulaw_to_alaw[i]; ++ /* find the 7-bit-sample */ ++ for (j = 0; j < 256; j++) { ++ if (sorted_alaw[j] == spl) ++ break; ++ } ++ /* write 7-bit audio value */ ++ dsp_audio_law2seven[i] = j >> 1; ++ } ++ for (i = 0; i < 128; i++) { ++ spl = sorted_alaw[i << 1]; ++ if (dsp_options & DSP_OPT_ULAW) ++ spl = dsp_audio_alaw_to_ulaw[spl]; ++ dsp_audio_seven2law[i] = spl; ++ } + } + + +@@ -475,60 +316,62 @@ + { + register s32 sample; + int i; ++ int num[] = { 110, 125, 150, 175, 200, 300, 400, 500 }; ++ int denum[] = { 100, 100, 100, 100, 100, 100, 100, 100 }; + + i = 0; + while(i < 256) { +- dsp_audio_reduce8[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i]>>8) & 0xffff]; +- dsp_audio_reduce7[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i]>>7) & 0xffff]; +- dsp_audio_reduce6[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i]>>6) & 0xffff]; +- dsp_audio_reduce5[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i]>>5) & 0xffff]; +- dsp_audio_reduce4[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i]>>4) & 0xffff]; +- dsp_audio_reduce3[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i]>>3) & 0xffff]; +- dsp_audio_reduce2[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i]>>2) & 0xffff]; +- dsp_audio_reduce1[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i]>>1) & 0xffff]; +- sample = dsp_audio_law_to_s32[i] << 1; ++ dsp_audio_reduce8[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i] * denum[7] / num[7] ) & 0xffff]; ++ dsp_audio_reduce7[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i] * denum[6] / num[6]) & 0xffff]; ++ dsp_audio_reduce6[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i] * denum[5] / num[5]) & 0xffff]; ++ dsp_audio_reduce5[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i] * denum[4] / num[4]) & 0xffff]; ++ dsp_audio_reduce4[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i] * denum[3] / num[3]) & 0xffff]; ++ dsp_audio_reduce3[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i] * denum[2] / num[2]) & 0xffff]; ++ dsp_audio_reduce2[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i] * denum[1] / num[1]) & 0xffff]; ++ dsp_audio_reduce1[i] = dsp_audio_s16_to_law[(dsp_audio_law_to_s32[i] * denum[0] / num[0]) & 0xffff]; ++ sample = dsp_audio_law_to_s32[i] * num[0] / denum[0]; + if (sample < -32768) + sample = -32768; + else if (sample > 32767) + sample = 32767; + dsp_audio_increase1[i] = dsp_audio_s16_to_law[sample & 0xffff]; +- sample = dsp_audio_law_to_s32[i] << 2; ++ sample = dsp_audio_law_to_s32[i] * num[1] / denum[1]; + if (sample < -32768) + sample = -32768; + else if (sample > 32767) + sample = 32767; + dsp_audio_increase2[i] = dsp_audio_s16_to_law[sample & 0xffff]; +- sample = dsp_audio_law_to_s32[i] << 3; ++ sample = dsp_audio_law_to_s32[i] * num[2] / denum[2]; + if (sample < -32768) + sample = -32768; + else if (sample > 32767) + sample = 32767; + dsp_audio_increase3[i] = dsp_audio_s16_to_law[sample & 0xffff]; +- sample = dsp_audio_law_to_s32[i] << 4; ++ sample = dsp_audio_law_to_s32[i] * num[3] / denum[3]; + if (sample < -32768) + sample = -32768; + else if (sample > 32767) + sample = 32767; + dsp_audio_increase4[i] = dsp_audio_s16_to_law[sample & 0xffff]; +- sample = dsp_audio_law_to_s32[i] << 5; ++ sample = dsp_audio_law_to_s32[i] * num[4] / denum[4]; + if (sample < -32768) + sample = -32768; + else if (sample > 32767) + sample = 32767; + dsp_audio_increase5[i] = dsp_audio_s16_to_law[sample & 0xffff]; +- sample = dsp_audio_law_to_s32[i] << 6; ++ sample = dsp_audio_law_to_s32[i] * num[5] / denum[5]; + if (sample < -32768) + sample = -32768; + else if (sample > 32767) + sample = 32767; + dsp_audio_increase6[i] = dsp_audio_s16_to_law[sample & 0xffff]; +- sample = dsp_audio_law_to_s32[i] << 7; ++ sample = dsp_audio_law_to_s32[i] * num[6] / denum[6]; + if (sample < -32768) + sample = -32768; + else if (sample > 32767) + sample = 32767; + dsp_audio_increase7[i] = dsp_audio_s16_to_law[sample & 0xffff]; +- sample = dsp_audio_law_to_s32[i] << 8; ++ sample = dsp_audio_law_to_s32[i] * num[7] / denum[7]; + if (sample < -32768) + sample = -32768; + else if (sample > 32767) Added: trunk/package/mqueue-isdn/mISDN_oslec_patch_v1.1.5_rowe =================================================================== --- trunk/package/mqueue-isdn/mISDN_oslec_patch_v1.1.5_rowe (rev 0) +++ trunk/package/mqueue-isdn/mISDN_oslec_patch_v1.1.5_rowe 2007-11-28 10:21:29 UTC (rev 1397) @@ -0,0 +1,3504 @@ +diff -ruN mISDN-orig/drivers/isdn/hardware/mISDN/dsp_cancel.c mISDN/drivers/isdn/hardware/mISDN/dsp_cancel.c +--- mISDN-orig/drivers/isdn/hardware/mISDN/dsp_cancel.c 2007-07-02 19:01:34.000000000 +0930 ++++ mISDN/drivers/isdn/hardware/mISDN/dsp_cancel.c 2007-09-16 01:31:20.000000000 +0930 +@@ -52,6 +52,8 @@ + int bchdev_echocancel_activate(dsp_t* dev, int deftaps, int train); + void bchdev_echocancel_deactivate(dsp_t* dev); + ++static int samples; ++extern int sample_impulse; + + void + dsp_cancel_tx(dsp_t *dsp, u8 *data, int len) +@@ -60,6 +62,23 @@ + if (!data) return; + + if (dsp->txbuflen + len < ECHOCAN_BUFLEN) { ++ ++ /* Start Zaptap code -----------------------------------------*/ ++ ++ if (sample_impulse) { ++ int x; ++ for (x=0;x<len;x++) { ++ if (samples++ == 1000) { ++ data[0] = dsp_audio_s16_to_law[10000]; ++ samples = 0; ++ } ++ else ++ data[x] = dsp_audio_s16_to_law[0]; ++ } ++ } ++ ++ /* End Zaptap code -----------------------------------------*/ ++ + memcpy(&dsp->txbuf[dsp->txbuflen],data,len); + dsp->txbuflen+=len; + } else { +@@ -152,6 +171,7 @@ + + //printk("Enabling EC\n"); + dsp->cancel_enable = 1; ++ samples = 0; + return(0); + } + +@@ -301,6 +321,10 @@ + dev->ecdis_wr = NULL; + } + ++extern int ec_debug; ++void sample_echo_before(int channo, short rxlin, short txlin); ++void sample_echo_after(int channo, short rxlin); ++ + /** Processes one TX- and one RX-packet with echocancellation */ + void bchdev_echocancel_chunk(dsp_t* ss, uint8_t *rxchunk, uint8_t *txchunk, uint16_t size) + { +@@ -338,10 +362,16 @@ + } + } else { + for (x=0;x<size;x++) { ++ if (ec_debug & 0x2) { + rxlin = dsp_audio_law_to_s32[rxchunk[x]&0xff]; + txlin = dsp_audio_law_to_s32[txchunk[x]&0xff]; +- rxlin = echo_can_update(ss->ec, txlin, rxlin); ++ if (ec_debug & 0x4) { ++ sample_echo_before(1, rxlin, txlin); ++ rxlin = echo_can_update(ss->ec, txlin, rxlin); ++ sample_echo_after(1, rxlin); ++ } + rxchunk[x] = dsp_audio_s16_to_law[rxlin &0xffff]; ++ } + } + } + } +diff -ruN mISDN-orig/drivers/isdn/hardware/mISDN/dsp_core.c mISDN/drivers/isdn/hardware/mISDN/dsp_core.c +--- mISDN-orig/drivers/isdn/hardware/mISDN/dsp_core.c 2007-07-02 19:01:34.000000000 +0930 ++++ mISDN/drivers/isdn/hardware/mISDN/dsp_core.c 2007-09-16 01:06:14.000000000 +0930 +@@ -174,6 +174,7 @@ + #include <linux/delay.h> + #include <linux/module.h> + #include <linux/vmalloc.h> ++#include <linux/proc_fs.h> + #include "core.h" + #include "layer1.h" + #include "helper.h" +@@ -183,6 +184,8 @@ + static char DSPName[] = "DSP"; + mISDNobject_t dsp_obj; + ++int ec_debug; ++ + static int debug = 0; + int dsp_debug; + static int options = 0; +@@ -210,6 +213,169 @@ + #endif + #endif + ++/* Zaptap code -----------------------------------------------------------*/ ++ ++#define SAMPLE_BUF_SZ 1000 ++#define SAMPLE_IDLE 0 ++#define SAMPLE_PING 1 ++#define SAMPLE_PONG 2 ++ ++DECLARE_WAIT_QUEUE_HEAD(sample_wait); ++static int sample_state = 0; ++int samples = 0; ++static short *psample; ++static short ping[3*SAMPLE_BUF_SZ]; ++static short pong[3*SAMPLE_BUF_SZ]; ++static int sample_ch = 1; ++int sample_impulse = 0; ++static int tmp1,tmp2; ++ ++void sample_echo_before(int channo, short rxlin, short txlin) { ++ ++ // Sample echo canceller signals ++ // Notes: ++ // 1. Samples are multiplexed in buffer: ++ // tx sample ++ // rx sample ++ // ec sample ++ // 2. We needs to sample rx here before echo can as it is ++ // overwritten. ++ ++ tmp1++; ++ tmp2 = channo; ++ if ((sample_state != SAMPLE_IDLE) && (channo == sample_ch)) { ++ *psample++ = txlin; ++ *psample++ = rxlin; ++ } ++} ++ ++void sample_echo_after(int channo, short rxlin) { ++ ++ if ((sample_state != SAMPLE_IDLE) && (channo == sample_ch)) { ++ ++ *psample++ = rxlin; ++ ++ // sample collection ping-pong buffer logic ++ ++ samples++; ++ if (samples >= SAMPLE_BUF_SZ) { ++ // time to swap buffers ++ samples = 0; ++ ++ if (sample_state == SAMPLE_PING) { ++ sample_state = SAMPLE_PONG; ++ psample = pong; ++ } ++ else { ++ sample_state = SAMPLE_PING; ++ psample = ping; ++ } ++ wake_up_interruptible(&sample_wait); ++ } ++ } ++} ++ ++/* end Zaptap code -----------------------------------------------------*/ ++ ++/* Zaptap code -----------------------------------------------------*/ ++ ++static int sample_open (struct inode *inode, struct file *file) { ++ printk("sample_open:\n"); ++ tmp1 = tmp2 = -1; ++ ++ psample = ping; ++ samples = 0; ++ sample_state = SAMPLE_PING; ++ ++ return 0; ++} ++ ++static int sample_release (struct inode *inode, struct file *file) { ++ printk("sample_release: tmp1 = %d tmp2 = %d\n", tmp1, tmp2); ++ ++ sample_state = SAMPLE_IDLE; ++ sample_impulse = 0; ++ samples = 0; ++ ++ return 0; ++} ++ ++static ssize_t sample_read(struct file *file, char *buf, ++ size_t count, loff_t *ppos) { ++ int err, len; ++ short *pread; ++ ++ /* wait for next buffer to be prepared by ISR, we read ++ alternate buffer just after transition. ++ */ ++ interruptible_sleep_on(&sample_wait); ++ ++ if (sample_state == SAMPLE_PING) { ++ pread = pong; ++ } ++ else { ++ pread = ping; ++ } ++ ++ len = 3*sizeof(short)*SAMPLE_BUF_SZ; ++ err = copy_to_user(buf, pread, len); ++ ++ if (err != 0) ++ return -EFAULT; ++ ++ return len; ++} ++ ++/* ioctls for sample */ ++ ++#define SAMPLE_SET_CHANNEL 0 ++#define SAMPLE_TX_IMPULSE 1 ++ ++static int sample_ioctl(struct inode *inode, struct file *file, ++ unsigned int cmd, unsigned long arg) { ++ int retval = 0; ++ ++ switch ( cmd ) { ++ case SAMPLE_SET_CHANNEL: ++ if (copy_from_user(&sample_ch, (int *)arg, sizeof(int))) ++ return -EFAULT; ++ printk("sample_ioctl: sample_ch = %d\n", sample_ch); ++ break; ++ case SAMPLE_TX_IMPULSE: ++ sample_impulse = 1; ++ printk("sample_ioctl: under impulse power\n"); ++ break; ++ default: ++ retval = -EINVAL; ++ } ++ ++ return retval; ++} ++ ++// define which file operations are supported ++struct file_operations sample_fops = { ++ .owner = THIS_MODULE, ++ .llseek = NULL, ++ .read = sample_read, ++ .write = NULL, ++ .readdir= NULL, ++ .poll = NULL, ++ .ioctl = sample_ioctl, ++ .mmap = NULL, ++ .open = sample_open, ++ .flush = NULL, ++ .release= sample_release, ++ .fsync = NULL, ++ .fasync = NULL, ++ .lock = NULL, ++ ++ ++}; ++ ++#define SAMPLE_NAME "sample" ++#define SAMPLE_MAJOR 34 ++ ++/* end Zaptap code -----------------------------------------------------*/ + + /* + * special message process for DL_CONTROL | REQUEST +@@ -462,7 +628,7 @@ + if (dsp->tx_volume) + dsp_change_volume(skb, dsp->tx_volume); + /* cancel echo */ +- if (dsp->cancel_enable) ++ if (dsp->cancel_enable && ec_debug) + dsp_cancel_tx(dsp, skb->data, skb->len); + /* crypt */ + if (dsp->bf_enable) +@@ -570,7 +736,7 @@ + if (dsp->bf_enable) + dsp_bf_decrypt(dsp, skb->data, skb->len); + /* if echo cancellation is enabled */ +- if (dsp->cancel_enable) ++ if (dsp->cancel_enable && ec_debug) + dsp_cancel_rx(dsp, skb->data, skb->len); + /* check if dtmf soft decoding is turned on */ + if (dsp->dtmf.software) { +@@ -960,6 +1126,27 @@ + return(ret); + } + ++static int proc_read_debug(char *buf, char **start, off_t offset, ++ int count, int *eof, void *data) ++{ ++ int len; ++ ++ *eof = 1; ++ ++ len = sprintf(buf, "%d\n", ec_debug); ++ return len; ++} ++ ++ ++static int proc_write_debug(struct file *file, const char *buffer, ++ unsigned long count, void *data) ++{ ++ ++ char *endbuffer; ++ ++ ec_debug = simple_strtol (buffer, &endbuffer, 10); ++ return count; ++} + + /* + * initialize DSP object +@@ -1013,6 +1200,7 @@ + INIT_LIST_HEAD(&dsp_obj.ilist); + + /* initialize audio tables */ ++ dsp_audio_generate_law_tables(); + dsp_silence = (dsp_options&DSP_OPT_ULAW)?0xff:0x2a; + dsp_audio_law_to_s32 = (dsp_options&DSP_OPT_ULAW)?dsp_audio_ulaw_to_s32:dsp_audio_alaw_to_s32; + dsp_audio_generate_s2law_table(); +@@ -1037,7 +1225,34 @@ + add_timer(&dsp_spl_tl); + + mISDN_module_register(THIS_MODULE); ++ ++ /* proc interface for debugging echo can noise */ ++ ++ { ++ struct proc_dir_entry *proc_misdn, *proc_debug; ++ ++ printk("dsp_core.c: Creating /proc/misdn debug interface\n"); ++ ++ proc_misdn = proc_mkdir("misdn", 0); ++ proc_debug = create_proc_read_entry("misdn/debug", 0, NULL, proc_read_debug, NULL); ++ proc_debug->write_proc = proc_write_debug; ++ } + ++ /* start Zaptap code ----------------------------------------*/ ++ ++ { ++ int res; ++ sample_state = SAMPLE_IDLE; ++ sample_impulse = 0; ++ if ((res = register_chrdev (SAMPLE_MAJOR, SAMPLE_NAME, &sample_fops))) { ++ printk(KERN_ERR "Zaptap unable to register %s char driver on %d\n", SAMPLE_NAME, SAMPLE_MAJOR); ++ return res; ++ } ++ } ++ printk("Registered %s char driver on major %d\n", SAMPLE_NAME, SAMPLE_MAJOR); ++ ++ /* end Zaptap code ------------------------------------------*/ ++ + return(0); + } + +@@ -1050,6 +1265,13 @@ + dsp_t *dspl, *nd; + int err; + ++ unregister_chrdev (SAMPLE_MAJOR, SAMPLE_NAME); /* Zaptap code */ ++ ++ { ++ remove_proc_entry("misdn/debug", NULL); ++ remove_proc_entry("misdn", NULL); ++ } ++ + mISDN_module_unregister(THIS_MODULE); + + if (timer_pending(&dsp_spl_tl)) +diff -ruN mISDN-orig/drivers/isdn/hardware/mISDN/dsp_core.c.orig mISDN/drivers/isdn/hardware/mISDN/dsp_core.c.orig +--- mISDN-orig/drivers/isdn/hardware/mISDN/dsp_core.c.orig 1970-01-01 09:30:00.000000000 +0930 ++++ mISDN/drivers/isdn/hardware/mISDN/dsp_core.c.orig 2007-09-15 00:22:16.000000000 +0930 +@@ -0,0 +1,1120 @@ ++/* $Id: dsp_core.c,v 1.29 2007/03/27 15:06:29 jolly Exp $ ++ * ++ * Author Andreas Eversberg (jo...@ev...) ++ * Based on source code structure by ++ * Karsten Keil (ke...@is...) ++ * ++ * This file is (c) under GNU PUBLIC LICENSE ++ * For changes and modifications please read ++ * ../../../Documentation/isdn/mISDN.cert ++ * ++ * Thanks to Karsten Keil (great drivers) ++ * Cologne Chip (great chips) ++ * ++ * This module does: ++ * Real-time tone generation ++ * DTMF detection ++ * Real-time cross-connection and conferrence ++ * Compensate jitter due to system load and hardware fault. ++ * All features are done in kernel space and will be realized ++ * using hardware, if available and supported by chip set. ++ * Blowfish encryption/decryption ++ */ ++ ++/* STRUCTURE: ++ * ++ * The dsp module provides layer 2 for b-channels (64kbit). It provides ++ * transparent audio forwarding with special digital signal processing: ++ * ++ * - (1) generation of tones ++ * - (2) detection of dtmf tones ++ * - (3) crossconnecting and conferences ++ * - (4) echo generation for delay test ++ * - (5) volume control ++ * - (6) disable receive data ++ * - (7) echo cancelation ++ * - (8) encryption/decryption ++ * ++ * Look: ++ * TX RX ++ * ------upper layer------ ++ * | ^ ++ * | |(6) ++ * v | ++ * +-----+-------------+-----+ ++ * |(3)(4) | ++ * | CMX | ++ * | | ++ * | +-------------+ ++ * | | ^ ++ * | | | ++ * |+---------+| +----+----+ ++ * ||(1) || |(5) | ++ * || || | | ++ * || Tones || |RX Volume| ++ * || || | | ++ * || || | | ++ * |+----+----+| +----+----+ ++ * +-----+-----+ ^ ++ * | | ++ * v | ++ * +----+----+ +----+----+ ++ * |(5) | |(2) | ++ * | | | | ++ * |TX Volume| | DTMF | ++ * | | | | ++ * | | | | ++ * +----+----+ +----+----+ ++ * | ^ ++ * | | ++ * v | ++ * +----+-------------+----+ ++ * |(7) | ++ * | | ++ * | Echo Cancellation | ++ * | | ++ * | | ++ * +----+-------------+----+ ++ * | ^ ++ * | | ++ * v | ++ * +----+----+ +----+----+ ++ * |(8) | |(8) | ++ * | | | | ++ * | Encrypt | | Decrypt | ++ * | | | | ++ * | | | | ++ * +----+----+ +----+----+ ++ * | ^ ++ * | | ++ * v | ++ * ------card layer------ ++ * TX RX ++ * ++ * Above you can see the logical data flow. If software is used to do the ++ * process, it is actually the real data flow. If hardware is used, data ++ * may not flow, but hardware commands to the card, to provide the data flow ++ * as shown. ++ * ++ * NOTE: The channel must be activated in order to make dsp work, even if ++ * no data flow to the upper layer is intended. Activation can be done ++ * after and before controlling the setting using PH_CONTROL requests. ++ * ++ * DTMF: Will be detected by hardware if possible. It is done before CMX ++ * processing. ++ * ++ * Tones: Will be generated via software if endless looped audio fifos are ++ * not supported by hardware. Tones will override all data from CMX. ++ * It is not required to join a conference to use tones at any time. ++ * ++ * CMX: Is transparent when not used. When it is used, it will do ++ * crossconnections and conferences via software if not possible through ++ * hardware. If hardware capability is available, hardware is used. ++ * ++ * Echo: Is generated by CMX and is used to check performane of hard and ++ * software CMX. ++ * ++ * The CMX has special functions for conferences with one, two and more ++ * members. It will allow different types of data flow. Receive and transmit ++ * data to/form upper layer may be swithed on/off individually without loosing ++ * features of CMX, Tones and DTMF. ++ * ++ * Echo Cancellation: Sometimes we like to cancel echo from the interface. ++ * Note that a VoIP call may not have echo caused by the IP phone. The echo ++ * is generated by the telephone line connected to it. Because the delay ++ * is high, it becomes an echo. RESULT: Echo Cachelation is required if ++ * both echo AND delay is applied to an interface. ++ * Remember that software CMX always generates a more or less delay. ++ * ++ * If all used features can be realized in hardware, and if transmit and/or ++ * receive data ist disabled, the card may not send/receive any data at all. ++ * Not receiving is usefull if only announcements are played. Not sending is ++ * usefull if an answering machine records audio. Not sending and receiving is ++ * usefull during most states of the call. If supported by hardware, tones ++ * will be played without cpu load. Small PBXs and NT-Mode applications will ++ * not need expensive hardware when processing calls. ++ * ++ * ++ * LOCKING: ++ * ++ * When data is received from upper or lower layer (card), the complete dsp ++ * module is locked by a global lock. When data is ready to be transmitted ++ * to a different layer, the module is unlocked. It is not allowed to hold a ++ * lock outside own layer. ++ * Reasons: Multiple threads must not process cmx at the same time, if threads ++ * serve instances, that are connected in same conference. ++ * PH_CONTROL must not change any settings, join or split conference members ++ * during process of data. ++ * ++ * ++ * TRANSMISSION: ++ * ++ ++TBD ++ ++There are three things that need to receive data from card: ++ - software DTMF decoder ++ - software cmx (if conference exists) ++ - upper layer, if rx-data not disabled ++ ++Whenever dtmf decoder is turned on or off, software cmx changes, rx-data is disabled or enabled, or card becomes activated, then rx-data is disabled or enabled using a special command to the card. ++ ++There are three things that need to transmit data to card: ++ - software tone generation (part of cmx) ++ - software cmx ++ - upper layer, if tx-data is written to tx-buffer ++ ++ ++ ++ ++ */ ++ ++const char *dsp_revision = "$Revision: 1.29 $"; ++ ++#include <linux/delay.h> ++#include <linux/module.h> ++#include <linux/vmalloc.h> ++#include <linux/proc_fs.h> ++#include "core.h" ++#include "layer1.h" ++#include "helper.h" ++#include "debug.h" ++#include "dsp.h" ++ ++static char DSPName[] = "DSP"; ++mISDNobject_t dsp_obj; ++ ++int ec_debug; ++ ++static int debug = 0; ++int dsp_debug; ++static int options = 0; ++int dsp_options; ++static int poll = 0; ++int dsp_poll, dsp_tics; ++ ++int dtmfthreshold=100L; ++ ++#ifdef MODULE ++MODULE_AUTHOR("Andreas Eversberg"); ++#ifdef OLD_MODULE_PARAM ++MODULE_PARM(debug, "1i"); ++MODULE_PARM(options, "1i"); ++MODULE_PARM(poll, "1i"); ++MODULE_PARM(dtmfthreshold, "1i"); ++#else ++module_param(debug, uint, S_IRUGO | S_IWUSR); ++module_param(options, uint, S_IRUGO | S_IWUSR); ++module_param(poll, uint, S_IRUGO | S_IWUSR); ++module_param(dtmfthreshold, uint, S_IRUGO | S_IWUSR); ++#endif ++#ifdef MODULE_LICENSE ++MODULE_LICENSE("GPL"); ++#endif ++#endif ++ ++ ++/* ++ * special message process for DL_CONTROL | REQUEST ++ */ ++static int ++dsp_control_req(dsp_t *dsp, mISDN_head_t *hh, struct sk_buff *skb) ++{ ++ struct sk_buff *nskb; ++ int ret = 0; ++ int cont; ++ u8 *data; ++ int len; ++ ++ if (skb->len < sizeof(int)) { ++ printk(KERN_ERR "%s: PH_CONTROL message too short\n", __FUNCTION__); ++ } ++ cont = *((int *)skb->data); ++ len = skb->len - sizeof(int); ++ data = skb->data + sizeof(int); ++ ++ switch (cont) { ++ case DTMF_TONE_START: /* turn on DTMF */ ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: start dtmf\n", __FUNCTION__); ++#if 0 ++ if (len == sizeof(int)) { ++ printk(KERN_NOTICE "changing DTMF Threshold to %d\n",*((int*)data)); ++ dsp->dtmf.treshold=(*(int*)data)*10000; ++ } ++#endif ++ ++ dsp_dtmf_goertzel_init(dsp); ++ /* checking for hardware capability */ ++ if (dsp->features.hfc_dtmf) { ++ dsp->dtmf.hardware = 1; ++ dsp->dtmf.software = 0; ++ } else { ++ dsp->dtmf.hardware = 0; ++ dsp->dtmf.software = 1; ++ } ++ break; ++ case DTMF_TONE_STOP: /* turn off DTMF */ ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: stop dtmf\n", __FUNCTION__); ++ dsp->dtmf.hardware = 0; ++ dsp->dtmf.software = 0; ++ break; ++ case CMX_CONF_JOIN: /* join / update conference */ ++ if (len != sizeof(int)) { ++ ret = -EINVAL; ++ break; ++ } ++ if (*((u32 *)data) == 0) ++ goto conf_split; ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: join conference %d\n", __FUNCTION__, *((u32 *)data)); ++ ret = dsp_cmx_conf(dsp, *((u32 *)data)); ++ if (dsp_debug & DEBUG_DSP_CMX) ++ dsp_cmx_debug(dsp); ++ break; ++ case CMX_CONF_SPLIT: /* remove from conference */ ++ conf_split: ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: release conference\n", __FUNCTION__); ++ ret = dsp_cmx_conf(dsp, 0); ++ if (dsp_debug & DEBUG_DSP_CMX) ++ dsp_cmx_debug(dsp); ++ break; ++ case TONE_PATT_ON: /* play tone */ ++ if (len != sizeof(int)) { ++ ret = -EINVAL; ++ break; ++ } ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: turn tone 0x%x on\n", __FUNCTION__, *((int *)skb->data)); ++ ret = dsp_tone(dsp, *((int *)data)); ++ if (!ret) ++ dsp_cmx_hardware(dsp->conf, dsp); ++ if (!dsp->tone.tone) ++ goto tone_off; ++ break; ++ case TONE_PATT_OFF: /* stop tone */ ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: turn tone off\n", __FUNCTION__); ++ dsp_tone(dsp, 0); ++ dsp_cmx_hardware(dsp->conf, dsp); ++ /* reset tx buffers (user space data) */ ++ tone_off: ++ dsp->tx_R = dsp->tx_W = 0; ++ break; ++ case VOL_CHANGE_TX: /* change volume */ ++ if (len != sizeof(int)) { ++ ret = -EINVAL; ++ break; ++ } ++ dsp->tx_volume = *((int *)data); ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: change tx volume to %d\n", __FUNCTION__, dsp->tx_volume); ++ dsp_cmx_hardware(dsp->conf, dsp); ++ break; ++ case VOL_CHANGE_RX: /* change volume */ ++ if (len != sizeof(int)) { ++ ret = -EINVAL; ++ break; ++ } ++ dsp->rx_volume = *((int *)data); ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: change rx volume to %d\n", __FUNCTION__, dsp->tx_volume); ++ dsp_cmx_hardware(dsp->conf, dsp); ++ break; ++ case CMX_ECHO_ON: /* enable echo */ ++ dsp->echo = 1; /* soft echo */ ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: enable cmx-echo\n", __FUNCTION__); ++ dsp_cmx_hardware(dsp->conf, dsp); ++ if (dsp_debug & DEBUG_DSP_CMX) ++ dsp_cmx_debug(dsp); ++ break; ++ case CMX_ECHO_OFF: /* disable echo */ ++ dsp->echo = 0; ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: disable cmx-echo\n", __FUNCTION__); ++ dsp_cmx_hardware(dsp->conf, dsp); ++ if (dsp_debug & DEBUG_DSP_CMX) ++ dsp_cmx_debug(dsp); ++ break; ++ case CMX_RECEIVE_ON: /* enable receive to user space */ ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: enable receive to user space\n", __FUNCTION__); ++ dsp->rx_disabled = 0; ++ dsp_cmx_hardware(dsp->conf, dsp); ++ break; ++ case CMX_RECEIVE_OFF: /* disable receive to user space */ ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: disable receive to user space\n", __FUNCTION__); ++ dsp->rx_disabled = 1; ++ dsp_cmx_hardware(dsp->conf, dsp); ++ break; ++ case CMX_MIX_ON: /* enable mixing of transmit data with conference members */ ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: enable mixing of tx-data with conf mebers\n", __FUNCTION__); ++ dsp->tx_mix = 1; ++ dsp_cmx_hardware(dsp->conf, dsp); ++ if (dsp_debug & DEBUG_DSP_CMX) ++ dsp_cmx_debug(dsp); ++ break; ++ case CMX_MIX_OFF: /* disable mixing of transmit data with conference members */ ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: disable mixing of tx-data with conf mebers\n", __FUNCTION__); ++ dsp->tx_mix = 0; ++ dsp_cmx_hardware(dsp->conf, dsp); ++ if (dsp_debug & DEBUG_DSP_CMX) ++ dsp_cmx_debug(dsp); ++ break; ++ case ECHOCAN_ON: /* turn echo calcellation on */ ++ if (len<4) { ++ ret = -EINVAL; ++ } else { ++ int ec_arr[2]; ++ memcpy(&ec_arr,data,sizeof(ec_arr)); ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: turn echo cancelation on (delay=%d attenuation-shift=%d\n", ++ __FUNCTION__, ec_arr[0], ec_arr[1]); ++ ++ ret = dsp_cancel_init(dsp, ec_arr[0], ec_arr[1] ,1); ++ dsp_cmx_hardware(dsp->conf, dsp); ++ } ++ break; ++ case ECHOCAN_OFF: /* turn echo calcellation off */ ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: turn echo cancelation off\n", __FUNCTION__); ++ ++ ret = dsp_cancel_init(dsp, 0,0,-1); ++ dsp_cmx_hardware(dsp->conf, dsp); ++ break; ++ case BF_ENABLE_KEY: /* turn blowfish on */ ++ if (len<4 || len>56) { ++ ret = -EINVAL; ++ break; ++ } ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: turn blowfish on (key not shown)\n", __FUNCTION__); ++ ret = dsp_bf_init(dsp, (u8*)data, len); ++ /* set new cont */ ++ if (!ret) ++ cont = BF_ACCEPT; ++ else ++ cont = BF_REJECT; ++ /* send indication if it worked to set it */ ++ nskb = create_link_skb(PH_CONTROL | INDICATION, 0, sizeof(int), &cont, 0); ++ if (mISDN_queue_up(&dsp->inst, 0, nskb)) ++ dev_kfree_skb(nskb); ++ if (!ret) ++ dsp_cmx_hardware(dsp->conf, dsp); ++ break; ++ case BF_DISABLE: /* turn blowfish off */ ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: turn blowfish off\n", __FUNCTION__); ++ dsp_bf_cleanup(dsp); ++ dsp_cmx_hardware(dsp->conf, dsp); ++ break; ++ default: ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: ctrl req %x unhandled\n", __FUNCTION__, cont); ++ ret = -EINVAL; ++ } ++ if (!ret) ++ dev_kfree_skb(skb); ++ return(ret); ++} ++ ++ ++/* ++ * messages from upper layers ++ */ ++static int ++dsp_from_up(mISDNinstance_t *inst, struct sk_buff *skb) ++{ ++ dsp_t *dsp; ++ mISDN_head_t *hh; ++ int ret = 0; ++ u_long flags; ++ ++ if (!skb) ++ return(-EINVAL); ++ dsp = inst->privat; ++ if (!dsp) { ++ return(-EIO); ++ } ++ ++ hh = mISDN_HEAD_P(skb); ++ switch(hh->prim) { ++ case DL_DATA | RESPONSE: ++ case PH_DATA | RESPONSE: ++ /* ignore response */ ++ dev_kfree_skb(skb); ++ break; ++ case DL_DATA | REQUEST: ++ case PH_DATA | REQUEST: ++ if (skb->len < 1) ++ return(-EINVAL); ++ ++ if (!dsp->conf_id) { ++ /* PROCESS TONES/TX-DATA ONLY */ ++ if (dsp->tone.tone) { ++ /* -> copy tone */ ++ dsp_tone_copy(dsp, skb->data, skb->len); ++ } ++ ++ if (dsp->tx_volume) ++ dsp_change_volume(skb, dsp->tx_volume); ++ /* cancel echo */ ++ if (dsp->cancel_enable && ec_debug) ++ dsp_cancel_tx(dsp, skb->data, skb->len); ++ /* crypt */ ++ if (dsp->bf_enable) ++ dsp_bf_encrypt(dsp, skb->data, skb->len); ++ /* send packet */ ++ if (mISDN_queue_down(&dsp->inst, 0, skb)) { ++ dev_kfree_skb(skb); ++ printk(KERN_ERR "%s: failed to send tx-packet\n", __FUNCTION__); ++ ++ return (-EIO); ++ } ++ ++ } else { ++ if (dsp->features.pcm_id>=0) { ++ printk("Not sending Data to CMX -- > returning because of HW bridge\n"); ++ dev_kfree_skb(skb); ++ break; ++ } ++ /* send data to tx-buffer (if no tone is played) */ ++ spin_lock_irqsave(&dsp_obj.lock, flags); ++ if (!dsp->tone.tone) { ++ dsp_cmx_transmit(dsp, skb); ++ } ++ spin_unlock_irqrestore(&dsp_obj.lock, flags); ++ ++ dev_kfree_skb(skb); ++ } ++ break; ++ case PH_CONTROL | REQUEST: ++ ++ spin_lock_irqsave(&dsp_obj.lock, flags); ++ ret = dsp_control_req(dsp, hh, skb); ++ spin_unlock_irqrestore(&dsp_obj.lock, flags); ++ ++ break; ++ case DL_ESTABLISH | REQUEST: ++ case PH_ACTIVATE | REQUEST: ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: activating b_channel %s\n", __FUNCTION__, dsp->inst.name); ++ ++ if (dsp->dtmf.hardware || dsp->dtmf.software) ++ dsp_dtmf_goertzel_init(dsp); ++ hh->prim = PH_ACTIVATE | REQUEST; ++ ret = mISDN_queue_down(&dsp->inst, 0, skb); ++ ++ break; ++ case DL_RELEASE | REQUEST: ++ case PH_DEACTIVATE | REQUEST: ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: releasing b_channel %s\n", __FUNCTION__, dsp->inst.name); ++ ++ dsp->tone.tone = dsp->tone.hardware = dsp->tone.software = 0; ++ if (timer_pending(&dsp->tone.tl)) ++ del_timer(&dsp->tone.tl); ++ hh->prim = PH_DEACTIVATE | REQUEST; ++ ret = mISDN_queue_down(&dsp->inst, 0, skb); ++ ++ break; ++ default: ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: msg %x unhandled %s\n", __FUNCTION__, hh->prim, dsp->inst.name); ++ ret = -EINVAL; ++ break; ++ } ++ return(ret); ++} ++ ++ ++/* ++ * messages from lower layers ++ */ ++static int ++dsp_from_down(mISDNinstance_t *inst, struct sk_buff *skb) ++{ ++ dsp_t *dsp; ++ mISDN_head_t *hh; ++ int ret = 0; ++ u8 *digits; ++ int cont; ++ struct sk_buff *nskb; ++ u_long flags; ++ ++ if (!skb) ++ return(-EINVAL); ++ dsp = inst->privat; ++ if (!dsp) ++ return(-EIO); ++ ++ hh = mISDN_HEAD_P(skb); ++ switch(hh->prim) ++ { ++ case PH_DATA | CONFIRM: ++ case DL_DATA | CONFIRM: ++ /* flush response, because no relation to upper layer */ ++ dev_kfree_skb(skb); ++ break; ++ case PH_DATA | INDICATION: ++ case DL_DATA | INDICATION: ++ if (skb->len < 1) ++ return(-EINVAL); ++ ++ ++ ++ /* decrypt if enabled */ ++ if (dsp->bf_enable) ++ dsp_bf_decrypt(dsp, skb->data, skb->len); ++ /* if echo cancellation is enabled */ ++ if (dsp->cancel_enable && ec_debug) ++ dsp_cancel_rx(dsp, skb->data, skb->len); ++ /* check if dtmf soft decoding is turned on */ ++ if (dsp->dtmf.software) { ++ digits = dsp_dtmf_goertzel_decode(dsp, skb->data, skb->len, (dsp_options&DSP_OPT_ULAW)?1:0); ++ if (digits) while(*digits) { ++ if (dsp_debug & DEBUG_DSP_DTMF) ++ printk(KERN_DEBUG "%s: sending software decoded digit(%c) to upper layer %s\n", __FUNCTION__, *digits, dsp->inst.name); ++ cont = DTMF_TONE_VAL | *digits; ++ nskb = create_link_skb(PH_CONTROL | INDICATION, 0, sizeof(int), &cont, 0); ++ if (mISDN_queue_up(&dsp->inst, 0, nskb)) ++ dev_kfree_skb(nskb); ++ digits++; ++ } ++ } ++ /* change volume if requested */ ++ if (dsp->rx_volume) ++ dsp_change_volume(skb, dsp->rx_volume); ++ ++ if (dsp->conf_id) { ++ /* we need to process receive data if software */ ++ spin_lock_irqsave(&dsp_obj.lock, flags); ++ if (dsp->pcm_slot_tx<0 && dsp->pcm_slot_rx<0) { ++ /* process data from card at cmx */ ++ dsp_cmx_receive(dsp, skb); ++ } ++ spin_unlock_irqrestore(&dsp_obj.lock, flags); ++ } ++ ++ if (dsp->rx_disabled) { ++ /* if receive is not allowed */ ++ dev_kfree_skb(skb); ++ ++ break; ++ } ++ hh->prim = DL_DATA | INDICATION; ++ ret = mISDN_queue_up(&dsp->inst, 0, skb); ++ ++ break; ++ case PH_CONTROL | INDICATION: ++ ++ if (dsp_debug & DEBUG_DSP_DTMFCOEFF) ++ printk(KERN_DEBUG "%s: PH_CONTROL received: %x (len %d) %s\n", __FUNCTION__, hh->dinfo, skb->len, dsp->inst.name); ++ switch (hh->dinfo) { ++ case HW_HFC_COEFF: /* getting coefficients */ ++ if (!dsp->dtmf.hardware) { ++ if (dsp_debug & DEBUG_DSP_DTMFCOEFF) ++ printk(KERN_DEBUG "%s: ignoring DTMF coefficients from HFC\n", __FUNCTION__); ++ dev_kfree_skb(skb); ++ break; ++ } ++ digits = dsp_dtmf_goertzel_decode(dsp, skb->data, skb->len, 2); ++ if (digits) while(*digits) { ++ int k; ++ struct sk_buff *nskb; ++ if (dsp_debug & DEBUG_DSP_DTMF) ++ printk(KERN_DEBUG "%s: now sending software decoded digit(%c) to upper layer %s\n", __FUNCTION__, *digits, dsp->inst.name); ++ k = *digits | DTMF_TONE_VAL; ++ nskb = create_link_skb(PH_CONTROL | INDICATION, 0, sizeof(int), &k, 0); ++ if (mISDN_queue_up(&dsp->inst, 0, nskb)) ++ dev_kfree_skb(nskb); ++ digits++; ++ } ++ dev_kfree_skb(skb); ++ break; ++ ++ case VOL_CHANGE_TX: /* change volume */ ++ if (skb->len != sizeof(int)) { ++ ret = -EINVAL; ++ break; ++ } ++ dsp->tx_volume = *((int *)skb->data); ++ if (dsp_debug & DEBUG_DSP_CORE) ++ printk(KERN_DEBUG "%s: change tx volume to %d\n", __FUNCTION__, dsp... [truncated message content] |