[zaptel-commits] tzafrir: branch tzafrir/kernelmove_14 r2693 - in /team/tzafrir/kernelmove_14:...

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Wed Jul 4 23:55:42 CDT 2007


Author: tzafrir
Date: Wed Jul  4 23:55:42 2007
New Revision: 2693

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2693
Log:
Sync with branches/1.4 r2592:2691

Added:
    team/tzafrir/kernelmove_14/doc/fxstest.8
      - copied unchanged from r2691, branches/1.4/doc/fxstest.8
Removed:
    team/tzafrir/kernelmove_14/genconst.c
    team/tzafrir/kernelmove_14/kernel/wctc4xxp/tc400m-firmware.bin
Modified:
    team/tzafrir/kernelmove_14/Makefile
    team/tzafrir/kernelmove_14/README
    team/tzafrir/kernelmove_14/TODO
    team/tzafrir/kernelmove_14/doc/fxotune.8
    team/tzafrir/kernelmove_14/doc/ztcfg.8
    team/tzafrir/kernelmove_14/doc/ztmonitor.8
    team/tzafrir/kernelmove_14/doc/zttool.8
    team/tzafrir/kernelmove_14/firmware/Makefile
    team/tzafrir/kernelmove_14/kernel/wct4xxp/base.c
    team/tzafrir/kernelmove_14/kernel/wctc4xxp/Makefile.kernel26
    team/tzafrir/kernelmove_14/kernel/wctc4xxp/base.c
    team/tzafrir/kernelmove_14/kernel/wctdm.c
    team/tzafrir/kernelmove_14/kernel/xpp/utils/   (props changed)
    team/tzafrir/kernelmove_14/kernel/ztd-eth.c
    team/tzafrir/kernelmove_14/zaptel.init

Modified: team/tzafrir/kernelmove_14/Makefile
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/Makefile?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/Makefile (original)
+++ team/tzafrir/kernelmove_14/Makefile Wed Jul  4 23:55:42 2007
@@ -238,11 +238,8 @@
 fxotune: LDLIBS+=-lm
 fxsdump: LDLIBS+=-lm
 
-# What does this target mean?
-#devel: tor2ee 
-
 stackcheck: checkstack modules
-	./checkstack *.o
+	./checkstack kernel/*.ko */*.ko
 
 MISDNVERSION=1_1_3
 MISDNUSERVERSION=1_1_3

Modified: team/tzafrir/kernelmove_14/README
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/README?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/README (original)
+++ team/tzafrir/kernelmove_14/README Wed Jul  4 23:55:42 2007
@@ -1,49 +1,172 @@
 Zapata Telephony Interface Driver
+=================================
+Asterisk Development Team <asteriskteam at digium.com>
+$Revision$, $Date$
 
-Note:
-See
-http://www.voip-info.org/tiki-index.php?page=Asterisk%20Zaptel%20Installation
-for more verbose and updated version of this document.
+Zaptel is a short for ZAPata Telephony.
 
-Requirements:
-	Some of the testing programs still require the zapata library
-	The zttool program requires libnewt
+Supported Hardware
+------------------
+Digital Cards
+~~~~~~~~~~~~~
+- wct4xxp: 
+  - Digium newer quad-span T1/E1/J1 cards: Wildcard TE420P/TE410P/TE405P 
+  - Digium newer dual-span T1/E1/J1 cards: Wildcard TE220P/TE210P/TE205P 
+- wcte12xp: Digium Wildcard TE120P and the TE122P single-span T1/E1/J1 card
+- wcte11xp: Digium Wildcard TE110P T1/E1/J1
+- wct1xxp: 
+  - Wildcard T100P (old single-span T1)
+  - Wildcard E100P (old single-span E1)
+- tor2: Tormenta quad-span T1/E1 card from the Zapata Telephony project
+- torisa: The old dual-span ISA T1 card from Zapata Telephony
 
-To install:
-	check zconfig.h for any specific configuration changes
-	make
-	make install
 
-Here is a list of what module to use with what hardware
+Analog Cards
+~~~~~~~~~~~~
+- wctdm24xxp: 
+  - Digium TDM2400P card: up to 24 analog ports
+  - Digium TDM800P card: up to 8 analog ports
+- wctdm: Digium TDM400P card: up to 4 analog ports
+- xpp: Xorcom Astribank: a USB connected unit of up to 32 ports
+  (also BRI)
+- wcfxo: X100P, similar and clones. A simple single-port FXO card
+- wcusb: Digium S100U: A simple single-port USB FXS unit
 
-Module Name	Hardware
-tor2		T400P - Quad Span T1 Card
-		E400P - Quad Span E1 Card
 
-wct4xxp		TE405P - Quad Span T1/E1 Card (5v version)
-		TE410P - Quad Span T1/E1 Card (3.3v version)
+Other Drivers
+~~~~~~~~~~~~~
+- pciradio: Zapata Telephony PCI Quad Radio Interface
+- wctc4xxp: Digium hardware transcoder cards (also need zttranscode)
+- ztd-eth: TDM over Ethernet (TDMoE) driver. Requires ztdynamic
+- ztd-loc: Mirror a local span. Requires ztdynamic
+- ztdummy: A dummy driver that only provides a zaptel timing source.
 
-wct1xxp		T100P - Single Span T1 Card
-		E100P - Single Span E1 Card
 
-wcte11xp	TE110P - Single Span T1/E1 Card
+Build Requirements
+------------------
+You will need a matching kernel source tree and a working Linux build 
+system. Some of the programs require some additional libraries.
 
-wcfxo		X100P - Single port FXO interface
-		X101P - Single port FXO interface 
 
-wctdm or	TDM400P - Modular FXS/FXO interface (1-4 ports)
-wcfxs
+Kernel Source / "Headers"
+~~~~~~~~~~~~~~~~~~~~~~~~~
+- Building zaptel requires a kernel build tree.
+- This should basically be at least a partial kernel source tree and
+  most importantly, the exact kernel .config file used for the build as
+  well as several files generated at kernel build time.
+- KERNEL_VERSION is the output of the command `uname -r`
+- If you build your own kernel, you need to point to the exact kernel
+  build tree. Luckily for you, this will typically be pointed by the
+  symbolic link /lib/modules/KERNEL_VERSION/build which is the location
+  zaptel checks by default.
+- If you use a kernel from your distribution you will typically have a
+  package with all the files required to build a kernel modules for your
+  kernel image.
+  * On Debian Etch and above and any Ubuntu this is
+    +++ linux-headers-`uname -r` +++
+  * On Fedora RHEL and compatibles (e.g. CentOS) this is the
+    kernel-devel package. Or if you run kernel-smp or kernel-xen, you
+    need kernel-smp-devel or kernel-xen-devel, respectively.
+  * On SUSE you seem to need the package kernel-source .
+- To point explicitly to a different build tree: set KSRC to the kernel 
+  source tree and KVERS to the exact kernel version:
 
-wcusb or	S100U - Single port FXS USB Interface
-wcfxsusb	
+  make KVERS=2.6.18.Custom KSRC=/home/tzafrir/kernels/2.6.18
 
-torisa		Old Tormenta1 ISA Card
 
-ztdummy		UHCI USB Zaptel Timing Only Interface
+Kernel Configuration
+~~~~~~~~~~~~~~~~~~~~
+If you build a custom kernel, note the following configuration items:
+- CONFIG_CRC_CCITT must be enabled ('y' or 'm'). On 2.6 kernels this can 
+  be selected These can be selected from the "Library Routines" submenu 
+  during kernel configuration via "make menuconfig".
+- ztdummy on i386/amd64 and later kernels (>= 2.6.15) can (and should)
+  use the system's RTC (Real Time Clock).
+- Alternatives to that for ztdummy are a UHCI USB controller (USB
+  controllers made by Intel or VIA) or a kernel that has HZ=1000
+  (default on kernels 2.6.0-2.6.12, optional on newer kernels. Not
+  possible on 2.4).
+
+
+A Build System
+~~~~~~~~~~~~~~
+gcc and friends. Generally you will need to install the package gcc.
+There may be cases where you will need a specific version of gcc to build
+kernel modules.
+
+On Debian and similar distributions run:
+
+   apt-get install build-essential
+
+On Centos and Fedora:
+
+  apt-get install gcc
+
+
+Extra Libraries
+~~~~~~~~~~~~~~~
+Some libraries are needed for extra utilities that are provided with
+Zaptel
+
+- libusb is needed for building fpgaload, needed for firmware loading of
+  the Xorcom Astribank.
+- libnewt is needed to build the optional but useful utility zttool.
+- For building usbfxstest you will need the zapata library. TODO:
+  Needed?
+
+Installing the first two on Debian:
+
+  apt-get install libusb-dev libnewt-dev
+
+Installing the first two on Centos/Fedora:
+
+  yum install libusb-devel libnewt-devel
+
+
+Installation
+------------
+
+  ./configure
+  # optional step: select custom configuration:
+  #make menuconfig
+  # optional step: enable zaptel-perl
+  make
+  make install
+  # To install init scripts and config files:
+  #make config
+
+
+Zaptel PERL modules
+-------------------
+The directory xpp/utils has, in addition to helper utilities for the
+Xorcom Astribank, a collection of perl modules to provide information
+related to Zaptel. The perl modules themselves are under xpp/utils/zconf .
+In xpp/utils there are several utilities that use those modules:
+- xpp-specific: zt_registration, xpp_sync, xpp_blink .
+- General: lszaptel, zapconf, zaptel_hardware
+
+Those utilities require the perl modules to be installed, however they
+will also look for them in the directory zconf, and thus can be run
+directly from the zaptel source tree. For example:
+
+  ./xpp/utils/zaptel_hardware
+
+The modules and utilities are not installed by default in this version
+of zaptel . In order to get them installed, you need do the following
+before running 'make install': remove the '#' in the line that sets 
+PERLLIBDIR in xpp/utils/Makefile . This can be done by e.g.:
+
+  sed -i -e 's/^#\(PERLLIBDIR\)/\1/' xpp/utils/Makefile
+
+To get usage information on a program, you can also use perldoc
+(sometimes provided in a package separate from perl itself). For
+instalnce:
+
+  perldoc ./xpp/utils/xpp_blink
 
 
 What is the license for the zaptel driver?
-===================================================
+------------------------------------------
 libpri is distributed under the terms of the GNU General Public License, 
 which permit its use and linking with other GPL'd software only.  
 The GNU GPL is included in the file LICENSE in this directory.
@@ -54,24 +177,20 @@
 at reasonable cost.
 
 
-Brief F.A.Q
-===========
-
-Q. Zaptel compiled with no errors but when I try to modprobe zaptel I
-receive "FATAL: Error insering zaptel (/lib/modules/2.6.x.x/misc/zaptel.ko):
-Unknown symol in module or unknown parameter (see dmesg)
-
-A. You need to recompile your kernel with CONFIG_CRC_CCITT=y or
-CONFIG_CRC_CCITT=m. To do this, run 'make menuconfig' and change it under 
-'Library Routines -> CRC-CCIT functions'. If you compiled it as a module,
-load it, otherwise reboot.
-
 How do I report bugs or contribute?
-===================================
+-----------------------------------
 Please report bug and patches to the Asterisk.org bug tracker at
 http://bugs.digium.com in the "zaptel" category.
 
+
 Does anything use this library so far?
-======================================
+--------------------------------------
 Yes, the Asterisk Open Source PBX does. http://www.asterisk.org
 
+
+Links
+-----
+- http://asterisk.org/ - The Asterisk PBX
+- http://voip-info.org/
+- http://voip-info.org/wiki/view/Asterisk+Zaptel+Installation
+- http://www.zapatatelephony.org/ - A historical site.

Modified: team/tzafrir/kernelmove_14/TODO
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/TODO?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/TODO (original)
+++ team/tzafrir/kernelmove_14/TODO Wed Jul  4 23:55:42 2007
@@ -2,13 +2,9 @@
 * Basic 2.6 build.
 * userspace build.
 
-* Hmm... reverted autoconf changes so far.
-* Call menuselect autoconf from menuselect autoconf.
-* Call menusect from autoconf and thus simplify make?
-
 * Test menuselect integration.
 * trim kernel/Makefile
-* build wct4xxp/ and wctc4xxp/ (the octasic API mess)
+* wctc4xxp seems to miss dependencies on octasic.
 * kernel 2.4 build
 * 'make clean' may trigger a configure of menuselect
 * install

Modified: team/tzafrir/kernelmove_14/doc/fxotune.8
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/doc/fxotune.8?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/doc/fxotune.8 (original)
+++ team/tzafrir/kernelmove_14/doc/fxotune.8 Wed Jul  4 23:55:42 2007
@@ -1,50 +1,149 @@
-.TH FXOTUNE 8 "September 10th, 2005" "Xorcom Rapid Asterisk" "Linux Programmer's Manual"
+.TH FXOTUNE "8" "9 June 2007" "asterisk" "System Manager's Manuals: Asterisk"
 .SH NAME
-.B fxotune
-\(em automatically tune FXO channels on a Digium TDM400 card
+fxotune \- automatically tune zaptel FXO channels
 .SH SYNOPSIS
 .B fxotune -i 
-.I OPTIONS 
-\(em detect 
-
-.B fxotune -s 
-\(em load settings
-
+.I [options]
+- detect mode
+
+.B fxotune -d
+.I [ options ]
+- dump mode
+
+.B fxotune -s
+- Startup mode
+.SH
 .SH DESCRIPTION
 .B fxotune 
-is a script that fine-tune parameters of the FXO modules of the TDM400
-card. Whene run in 
-.I detect
-mode (-i) it detects and tunes all the FXO channels of such cards. It 
-needs a dial string after which the line(s) will give dial tone.
-
-It writes settings to a configuration file (/etc/fxotune.conf , name 
-is hardwired) from which it can be loaded (e.g: at startup) using -s .
+is a script that fine-tune parameters of the FXO modules of the 
+card. It has three modes of operation:
+
+.I Detect mode (-i):
+it detects and tunes all the available FXO channels.
+It writes settings to a configuration file (/etc/fxotune.conf)
+from which it can be loaded (e.g: at startup) using -s .
+
+.I Dump mode (-d):
+Runs detection on a single Zaptel channel, and just dumps waveforms to
+.B fxotune_dump.vals
+is generated in the current directory.
+
+.I Startup mode (-s):
+fxotune just reads the settings from fxotune.conf into the FXO modules.
 
 You are advised to run fxotune on all FXO ports you have that support 
 it and that are connected. Note that the tunning is affected by e.g.
 the physical parameters of the connection, and thus if it has been 
 radically changed, you may need to re-run fxotune.
 
+FXOTune only works for the Digium TDM400P/800P/2400P cards and
+compatible and the Xorcom Astribank devices. Other cards (notably X100P
+cards and clones) do not have the hardware to support such tuning.
+
+The tuning process needs a clear line to do the tuning.  In order to do
+that, it runs in cycles of the following: sets the line off-hook, dials
+a dial string (which should set the PSTN provider waiting for the next
+digit), and then starts tuning. It has a limited ammount of time for
+tuning before the PSTN gives up and gives a busy tone. So after a while
+it hangs up and starts a new cycle.
+
 .B fxotune
 has two operation modes: tune (-i) and set (-s). In the tune mode it 
 generates /etc/fxotune.conf, and in the set mode it merely applies the 
 parameters from fxotune.conf to device's ports.
 
 .SH OPTIONS
-.B THIS SECTION CURRENTLY DOCUMENTS THE OLD SYNTAX OF FXOTUNE. RUN fxotune 
-WITHOUT ANY PARAMETERS TO GET A USAGE MESSAGE.
-
-.B -i
-.RS
-.I dialstr
-Start detecting optimal settings.  
-.I dialstr
-Is a number needed to dial to get a dial tone.
-The test can take several minutes, and must be performed when Asterisk
-is not running.
-
-For example: 
+The following options below except -v (verbose) affect only the
+detection process and hence apply only to the 
+.I detect
+and 
+.I dump
+modes.
+
+In addition, to maintain compatibility with older versions of fxotune,
+if in detect or dump mode there is a parameter with option before it, it
+is considered to be the 
+.I dialstring
+parameter (-n).
+
+.B -b
+.I startdev
+.RS
+Start tuning from zaptel channel num. \fI startdev\fR: skip all previous
+channels. By default starting from channel 1.
+
+In dump mode (-d) this is the single channel that will be tested.
+.RE
+
+.B -e
+.I stopdev
+.RS
+Tune only up to zaptel channel num. \fI stopdev\fR: skip all previous
+channels. By default stopping at channel 252.
+
+In dump mode (-d) this parameter is ignored.
+.RE
+
+.B -l
+.I delay-to-silence
+.RS
+Time in seconds to wait after dialing the dial-string to get a clear line.
+The default is 0. 
+before 
+.RE
+
+.B -m
+.I silence-good-for
+.RS
+Time in seconds which states how long the PSTN will wait after we dialed
+the dial-string until it starts giving a busy tone. You can test this by
+connecting an analog phone to the line and dialing.
+
+The default is 18 (18 seconds). 
+.RE
+
+.B -n
+.I dial-string
+.RS
+Digits to dial to the PSTN in order to get it stop its dialtone and
+waiting for the next digit. 
+
+The default is "4" (sending just the digit 4). It should work in most
+cases. Again, this can be tested by connecting a phone to the PSTN line
+and dialing the dial-string.
+.RE
+
+.B -t
+.I detect-type
+.RS
+This option allows using the older detection method used by fxotune of
+zaptel 1.2. use 
+.B -t 1
+for that older method. whereas
+.B -t 2
+(the default) uses the current method.
+
+This option only applies to detect mode (-i).
+.RE
+
+.B -v[vvvv]
+.RS
+Sets debugging on. The more v-s, the higher debug level. 
+
+Note that: -vv -v  will actually set debug level to 1 instead of 3.
+.RE
+
+.B -w
+.I wave-form
+.RS
+The default: -1, for multitone waveform. Alternatively: a frequency of a
+single tone.
+
+This option only applies to dump mode (-d).
+.RE
+
+
+.SH EXAMPLES
 .RS
 fxotune -i 9
 .RE
@@ -75,7 +174,7 @@
 
 .B fxotune
 writes immedietly to 
-.B /etc/fxo.conf
+.B /etc/fxotune.conf
 so if you stop it half-way, you may get a half-configured system. If you
 have already tuned your FXO channels and wish to test-run fxotune again, 
 you are advised to backup /etc/fxotune.conf .
@@ -83,7 +182,7 @@
 The default for -m is 18 seconds. This asusmes that you get a clear line 
 for at least 18 seconds. It is advised that you test that timeout earlier
 by connecting a phone to the FXO line, dialing 4 (or whatever dial string 
-you put with ___) and see how much time of silence you have.
+you put with -n) and see how much time of silence you have.
 
 If you connect your device to a PSTN provider that is not in the US, there
 is a similar operation you should apply before even getting to fxotune:
@@ -91,6 +190,8 @@
 parameters. For the Digium analog cards this is set through the kernel module 
 parameter 'opermode' . For the Xorcom Astribank this is set through the 
 variable 'opermode' in /etc/default/zaptel or /etc/sysconfig/zaptel .
+For valid values of this parameter, see
+/usr/share/asterisk/init_fxo_modes .
 
 .SH SEE ALSO 
 ztcfg(8), zttool(8), ztmonitor(8), asterisk(8). 

Modified: team/tzafrir/kernelmove_14/doc/ztcfg.8
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/doc/ztcfg.8?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/doc/ztcfg.8 (original)
+++ team/tzafrir/kernelmove_14/doc/ztcfg.8 Wed Jul  4 23:55:42 2007
@@ -50,7 +50,8 @@
 zttool(8), ztmonitor(8), asterisk(8).
 .SH "AUTHOR"
 .PP
-This manual page was written by Santiago Ruano Rincón <santiago at unicauca.edu.co> for
+This manual page was written by Santiago Ruano Rinc\['o]n 
+<santiago at unicauca.edu.co> for
 the Debian system (but may be used by others).  Permission is
 granted to copy, distribute and/or modify this document under
 the terms of the GNU General Public License, Version 2 any 

Modified: team/tzafrir/kernelmove_14/doc/ztmonitor.8
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/doc/ztmonitor.8?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/doc/ztmonitor.8 (original)
+++ team/tzafrir/kernelmove_14/doc/ztmonitor.8 Wed Jul  4 23:55:42 2007
@@ -32,7 +32,8 @@
 zttool(8), ztcfg(8), asterisk(8).
 .SH "AUTHOR"
 .PP
-This manual page was written by Santiago Ruano Rincón <santiago at unicauca.edu.co> for
+This manual page was written by Santiago Ruano Rinc\['o]n 
+<santiago at unicauca.edu.co> for
 the Debian system (but may be used by others).  Permission is
 granted to copy, distribute and/or modify this document under
 the terms of the GNU General Public License, Version 2 any 

Modified: team/tzafrir/kernelmove_14/doc/zttool.8
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/doc/zttool.8?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/doc/zttool.8 (original)
+++ team/tzafrir/kernelmove_14/doc/zttool.8 Wed Jul  4 23:55:42 2007
@@ -23,7 +23,8 @@
 ztmonitor(8), asterisk (8).
 .SH "AUTHOR"
 .PP
-This manual page was written by Santiago Ruano Rincón <santiago at unicauca.edu.co> for
+This manual page was written by Santiago Ruano Rinc\['o]n 
+<santiago at unicauca.edu.co> for
 the Debian system (but may be used by others).  Permission is
 granted to copy, distribute and/or modify this document under
 the terms of the GNU General Public License, Version 2 any 

Modified: team/tzafrir/kernelmove_14/firmware/Makefile
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/firmware/Makefile?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/firmware/Makefile (original)
+++ team/tzafrir/kernelmove_14/firmware/Makefile Wed Jul  4 23:55:42 2007
@@ -165,4 +165,6 @@
 	../build_tools/make_firmware_object zaptel-fw-oct6114-128.bin $@
 
 # Build object file of a TC400M firmware image for linking
-zaptel-fw-tc400m.o:
+zaptel-fw-tc400m.o: zaptel-fw-tc400m-$(TC400M_VERSION).tar.gz ../wctc4xxp/base.o zaptel-fw-tc400m.bin
+	@echo Making firmware object file for zaptel-fw-tc400m.bin
+	../build_tools/make_firmware_object zaptel-fw-tc400m.bin $@ ../wctc4xxp/base.o

Modified: team/tzafrir/kernelmove_14/kernel/wct4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/kernel/wct4xxp/base.c?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/kernel/wct4xxp/base.c (original)
+++ team/tzafrir/kernelmove_14/kernel/wct4xxp/base.c Wed Jul  4 23:55:42 2007
@@ -171,6 +171,7 @@
 
 #endif
 
+static int pedanticpci = 1;
 static int debug=0;
 static int timingcable = 0;
 static int highestorder;
@@ -230,13 +231,17 @@
 };
 
 static struct devtype wct4xxp = { "Wildcard TE410P/TE405P (1st Gen)", 0 };
-static struct devtype wct420p4 = { "Wildcard TE420P (4th Gen)", FLAG_BURST | FLAG_2NDGEN | FLAG_3RDGEN };
+static struct devtype wct420p4 = { "Wildcard TE420 (4th Gen)", FLAG_BURST | FLAG_2NDGEN | FLAG_3RDGEN };
+static struct devtype wct410p4 = { "Wildcard TE410P (4th Gen)", FLAG_BURST | FLAG_2NDGEN | FLAG_3RDGEN };
 static struct devtype wct410p3 = { "Wildcard TE410P (3rd Gen)", FLAG_2NDGEN | FLAG_3RDGEN };
+static struct devtype wct405p4 = { "Wildcard TE405P (4th Gen)", FLAG_BURST | FLAG_2NDGEN | FLAG_3RDGEN };
 static struct devtype wct405p3 = { "Wildcard TE405P (3rd Gen)", FLAG_2NDGEN | FLAG_3RDGEN };
 static struct devtype wct410p2 = { "Wildcard TE410P (2nd Gen)", FLAG_2NDGEN };
 static struct devtype wct405p2 = { "Wildcard TE405P (2nd Gen)", FLAG_2NDGEN };
-static struct devtype wct220p4 = { "Wildcard TE220P (4th Gen)", FLAG_BURST | FLAG_2NDGEN | FLAG_3RDGEN | FLAG_2PORT };
+static struct devtype wct220p4 = { "Wildcard TE220 (4th Gen)", FLAG_BURST | FLAG_2NDGEN | FLAG_3RDGEN | FLAG_2PORT };
+static struct devtype wct205p4 = { "Wildcard TE205P (4th Gen)", FLAG_BURST | FLAG_2NDGEN | FLAG_3RDGEN | FLAG_2PORT };
 static struct devtype wct205p3 = { "Wildcard TE205P (3rd Gen)", FLAG_2NDGEN | FLAG_3RDGEN | FLAG_2PORT };
+static struct devtype wct210p4 = { "Wildcard TE210P (4th Gen)", FLAG_BURST | FLAG_2NDGEN | FLAG_3RDGEN | FLAG_2PORT };
 static struct devtype wct210p3 = { "Wildcard TE210P (3rd Gen)", FLAG_2NDGEN | FLAG_3RDGEN | FLAG_2PORT };
 static struct devtype wct205 = { "Wildcard TE205P ", FLAG_2NDGEN | FLAG_2PORT };
 static struct devtype wct210 = { "Wildcard TE210P ", FLAG_2NDGEN | FLAG_2PORT };
@@ -429,9 +434,11 @@
 {
 	unsigned int tmp;
 	writel(value, &wc->membase[addr]);
-	tmp = __t4_pci_in(wc, WC_VERSION);
-	if ((tmp & 0xffff0000) != 0xc01a0000)
-		printk("TE4XXP: Version Synchronization Error!\n");
+	if (pedanticpci) {
+		tmp = __t4_pci_in(wc, WC_VERSION);
+		if ((tmp & 0xffff0000) != 0xc01a0000)
+			printk("TE4XXP: Version Synchronization Error!\n");
+	}
 #if 0
 	tmp = __t4_pci_in(wc, addr);
 	if ((value != tmp) && (addr != WC_LEDS) && (addr != WC_LDATA) &&
@@ -518,7 +525,9 @@
 	unit &= 0x3;
 	__t4_pci_out(wc, WC_LADDR, (unit << 8) | (addr & 0xff));
 	__t4_pci_out(wc, WC_LADDR, (unit << 8) | (addr & 0xff) | WC_LFRMR_CS | WC_LREAD);
-	__t4_pci_out(wc, WC_VERSION, 0);
+	if (pedanticpci) {
+		__t4_pci_out(wc, WC_VERSION, 0);
+	}
 	ret = __t4_pci_in(wc, WC_LDATA);
  	__t4_pci_out(wc, WC_LADDR, (unit << 8) | (addr & 0xff));
 	return ret & 0xff;
@@ -2867,6 +2876,21 @@
 	if (wc->intcount < 20)
 		printk("2G: Pre-interrupt\n");
 #endif
+
+	spin_lock_irqsave(&wc->reglock, flags);
+
+	if (wc->stopdma) {
+		/* Stop DMA cleanly if requested */
+		wc->dmactrl = 0x0;
+		__t4_pci_out(wc, WC_DMACTRL, 0x00000000);
+		/* Acknowledge any pending interrupts */
+		__t4_pci_out(wc, WC_INTR, 0x00000000);
+		__t4_set_timing_source(wc, 4, 0, 0);
+		wc->stopdma = 0x0;
+	}
+
+	spin_unlock_irqrestore(&wc->reglock, flags);
+
 	
 	inirq = 1;
 	/* Make sure it's really for us */
@@ -2884,7 +2908,6 @@
 #ifdef ENABLE_WORKQUEUES
 	t4_pci_out(wc, WC_INTR, status & 0x00000008);
 #endif
-
 	if (!wc->spansstarted) {
 		printk("Not prepped yet!\n");
 #ifdef LINUX26
@@ -3025,15 +3048,6 @@
 
 	if (wc->checktiming > 0)
 		__t4_set_timing_source_auto(wc);
-	if (wc->stopdma) {
-		/* Stop DMA cleanly if requested */
-		wc->dmactrl = 0x0;
-		__t4_pci_out(wc, WC_DMACTRL, 0x00000000);
-		/* Acknowledge any pending interrupts */
-		__t4_pci_out(wc, WC_INTR, 0x00000000);
-		__t4_set_timing_source(wc, 4, 0, 0);
-		wc->stopdma = 0x0;
-	}
 	spin_unlock_irqrestore(&wc->reglock, flags);
 
 	if (needcheckvpm450 && (vpmdtmfsupport == 1)) {
@@ -3830,12 +3844,16 @@
 	{ 0x10ee, 0x0314, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)&wct4xxp },
 
  	{ 0xd161, 0x0420, 0x0004,     PCI_ANY_ID, 0, 0, (unsigned long)&wct420p4 },
+	{ 0xd161, 0x0410, 0x0004,     PCI_ANY_ID, 0, 0, (unsigned long)&wct410p4 },
+	{ 0xd161, 0x0405, 0x0004,     PCI_ANY_ID, 0, 0, (unsigned long)&wct405p4 },
 	{ 0xd161, 0x0410, 0x0003,     PCI_ANY_ID, 0, 0, (unsigned long)&wct410p3 },
 	{ 0xd161, 0x0405, 0x0003,     PCI_ANY_ID, 0, 0, (unsigned long)&wct405p3 },
 	{ 0xd161, 0x0410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)&wct410p2 },
 	{ 0xd161, 0x0405, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)&wct405p2 },
 
  	{ 0xd161, 0x0220, 0x0004,     PCI_ANY_ID, 0, 0, (unsigned long)&wct220p4 },
+	{ 0xd161, 0x0205, 0x0004,     PCI_ANY_ID, 0, 0, (unsigned long)&wct205p4 },
+	{ 0xd161, 0x0210, 0x0004,     PCI_ANY_ID, 0, 0, (unsigned long)&wct210p4 },
 	{ 0xd161, 0x0205, 0x0003,     PCI_ANY_ID, 0, 0, (unsigned long)&wct205p3 },
 	{ 0xd161, 0x0210, 0x0003,     PCI_ANY_ID, 0, 0, (unsigned long)&wct210p3 },
 	{ 0xd161, 0x0205, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)&wct205 },
@@ -3880,6 +3898,7 @@
 MODULE_LICENSE("GPL");
 #endif
 #ifdef LINUX26
+module_param(pedanticpci, int, 0600);
 module_param(debug, int, 0600);
 module_param(loopback, int, 0600);
 module_param(noburst, int, 0600);
@@ -3897,6 +3916,7 @@
 module_param(dtmfthreshold, int, 0600);
 #endif
 #else
+MODULE_PARM(pedanticpci, "i");
 MODULE_PARM(debug, "i");
 MODULE_PARM(loopback, "i");
 MODULE_PARM(noburst, "i");

Modified: team/tzafrir/kernelmove_14/kernel/wctc4xxp/Makefile.kernel26
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/kernel/wctc4xxp/Makefile.kernel26?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/kernel/wctc4xxp/Makefile.kernel26 (original)
+++ team/tzafrir/kernelmove_14/kernel/wctc4xxp/Makefile.kernel26 Wed Jul  4 23:55:42 2007
@@ -6,11 +6,10 @@
 wctc4xxp-objs := base.o 
 
 ifneq ($(HOTPLUG_FIRMWARE),yes)
-wctc4xxp-objs += firmware_tc400m.o
+wctc4xxp-objs += ../firmware/zaptel-fw-tc400m.o
 endif
 
 $(obj)/base.o: $(src)/../zaptel.h
 
-$(obj)/firmware_tc400m.o: $(src)/tc400m-firmware.bin $(obj)/base.o
-	@echo Making firmware object file for $(notdir $<)
-	@cd $(src) && ../build_tools/make_firmware_object $(notdir $<) $@ $(obj)/base.o
+$(obj)/../firmware/zaptel-fw-tc400m.o: $(obj)/base.o
+	$(MAKE) -C $(obj)/../firmware zaptel-fw-tc400m.o

Modified: team/tzafrir/kernelmove_14/kernel/wctc4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/kernelmove_14/kernel/wctc4xxp/base.c?view=diff&rev=2693&r1=2692&r2=2693
==============================================================================
--- team/tzafrir/kernelmove_14/kernel/wctc4xxp/base.c (original)
+++ team/tzafrir/kernelmove_14/kernel/wctc4xxp/base.c Wed Jul  4 23:55:42 2007
@@ -53,15 +53,13 @@
 #endif
 
 #ifdef HOTPLUG_FIRMWARE
-static const char *dte_firmware = "tc400m-firmware.bin";
-#else
-extern u8 _binary_tc400m_firmware_bin_start[];
-extern void _binary_tc400m_firmware_bin_size;
+static const char *dte_firmware = "zaptel-fw-tc400m.bin";
 #endif
 
 
 /* #define USE_TEST_HW */
 #define USE_TDM_CONFIG
+#define QUIET_DSP
 
 #define WC_MAX_IFACES 128
 
@@ -238,6 +236,17 @@
 #define CMD_MSG_VOIP_INDCTRL(s,c) {0x00,0x11,0x22,0x33,0x44,0x55, 0xAA,0xBB,0xCC,0xDD,0xEE,0xFF, 0x88,0x9B, \
 	0x00,0x01, s&0x0F, 0x01, ((c&0xFF00)>>8),(c&0x00FF), 0x0A, 0x00, 0x00,0x02,0x84,0x80, 0x00,0x00, \
 	0x07,0x00, 0x00,0x00 }
+#define CMD_MSG_VOIP_DTMFOPT_LEN 32
+#define CMD_MSG_VOIP_DTMFOPT(s,c) { \
+	0x00,0x11,0x22,0x33,0x44,0x55, 0xAA,0xBB,0xCC,0xDD,0xEE,0xFF, 0x88,0x9B, \
+	0x00,0x01, s&0x0F, 0x01, ((c&0xFF00)>>8),(c&0x00FF), 0x0A, 0x00, 0x00,0x02,0x02,0x80, 0x00,0x00, \
+	0x08,0x00, 0x00,0x00 }
+
+#define CMD_MSG_VOIP_TONECTL_LEN 32
+#define CMD_MSG_VOIP_TONECTL(s,c) { \
+	0x00,0x11,0x22,0x33,0x44,0x55, 0xAA,0xBB,0xCC,0xDD,0xEE,0xFF, 0x88,0x9B, \
+	0x00,0x01, s&0x0F, 0x01, ((c&0xFF00)>>8),(c&0x00FF), 0x0A, 0x00, 0x00,0x02,0x5B,0x80, 0x00,0x00, \
+	0x00,0x00, 0x00,0x00 }
 
 /* CPU ACK command */ 
 #define CMD_MSG_ACK_LEN 20
@@ -274,6 +283,7 @@
 				wc->cmdq[wc->cmdq_wndx].cmdlen = length; \
 				for (i = 0; i < length; i++) \
 					wc->cmdq[wc->cmdq_wndx].cmd[i] = fifo[i]; \
+				wc->last_seqno = fifo[16]; \
 				wc->cmdq_wndx = (wc->cmdq_wndx + 1) % MAX_COMMANDS; \
 			} \
 			__transmit_demand(wc); \
@@ -287,7 +297,7 @@
 
 struct cmdq {
 	unsigned int cmdlen;
-	unsigned int cmd[MAX_COMMAND_LEN];
+	unsigned char cmd[MAX_COMMAND_LEN];
 };
 
 struct wcdte {
@@ -312,6 +322,8 @@
 	unsigned int cmdq_wndx;
 	unsigned int cmdq_rndx;
 
+	unsigned int last_seqno;
+	unsigned int last_rseqno;
 	unsigned int last_command_sent;
 	unsigned int last_rcommand;
 	unsigned int last_rparm2;
@@ -345,7 +357,8 @@
 	int flags;
 };
 
-static struct wcdte_desc wcdte = { "Wildcard TC400P+TC400M", 0 };
+static struct wcdte_desc wctc400p = { "Wildcard TC400P+TC400M", 0 };
+static struct wcdte_desc wctce400 = { "Wildcard TCE400+TC400M", 0 };
 
 static struct wcdte *ifaces[WC_MAX_IFACES];
 
@@ -366,6 +379,8 @@
 
 	unsigned int timestamp;
 	unsigned int seqno;
+
+	unsigned int cmd_seqno;
 
 	unsigned int timeslot_in_num;		/* DTE chennel on which results we be received from */
 	unsigned int timeslot_out_num;		/* DTE channel to send data to */
@@ -419,6 +434,8 @@
 	state_ptr->wc = wc;
 	state_ptr->timestamp = 0;
 	state_ptr->seqno = 0;
+
+	state_ptr->cmd_seqno = 0;
 
 	state_ptr->packets_sent = 0;
 	state_ptr->packets_received = 0;
@@ -648,6 +665,8 @@
 		up(&wc->chansem);
 		break;
 	case ZT_TCOP_TRANSCODE:
+		if (ztc->chan_built == 0)
+			printk("wcdte error: Sending data to a channel that isn't built yet\n");
 		if ( (((zth->srcfmt == ZT_FORMAT_ULAW) || (zth->srcfmt == ZT_FORMAT_ALAW)) && ((zth->dstfmt == ZT_FORMAT_G729A  && zth->srclen >= G729_SAMPLES) ||(zth->dstfmt == ZT_FORMAT_G723_1  && zth->srclen >= G723_SAMPLES)) )
 			|| ((zth->srcfmt == ZT_FORMAT_G729A) && (zth->srclen >= G729_BYTES))
 			|| ((zth->srcfmt == ZT_FORMAT_G723_1) && (zth->srclen >= G723_BYTES)) )
@@ -806,13 +825,19 @@
 
 		
 			wc->rcvflags = RCV_CSMENCAPS;
-			wc->last_rcommand = rcommand;
-			wc->last_rparm2 = readchunk[30] | (readchunk[31] << 8);
-			wake_up_interruptible(&wc->regq);
+			if (rcommand == wc->last_command_sent) {
+				wc->last_rcommand = rcommand;
+				wc->last_rparm2 = readchunk[30] | (readchunk[31] << 8);
+				wake_up_interruptible(&wc->regq);
+			} else {
+				if (debug)
+				printk("wcdte error: unexpected command response received (sent: %04X, received: %04X)\n", wc->last_command_sent, rcommand);
+			}
 			up(&wc->cmdqsem);
 		}
 		else
 		{
+			wc->last_rseqno = readchunk[16];
 			wc->rcvflags = RCV_CSMENCAPS_ACK;
 			wake_up_interruptible(&wc->regq);
 		}
@@ -1024,20 +1049,11 @@
 #endif
 	int res;
 
-	if (wc->wqueints & 0x00000040) {
-		/* Loop descriptors is available */
-		do {
-			res = wcdte_check_descriptor(wc);
-		} while(res);
-	}
-	
-	/* Handle TX interrupts */
-	if (wc->wqueints & 0x00000001)
-	{
-		wc->txints++;
-		transmit_demand(wc);
-		wc->intcount++;
-	}
+	do {
+		res = wcdte_check_descriptor(wc);
+	} while(res);
+	
+	transmit_demand(wc);
 }
 
 ZAP_IRQ_HANDLER(wcdte_interrupt)
@@ -1105,6 +1121,7 @@
 	newjiffies = jiffies + HZ/10;
 	while(((reg = wcdte_getctl(wc,0x0000)) & 0x00000001) && (newjiffies > jiffies));
 
+	wcdte_setctl(wc, 0x0000, 0xFFFA0000);
 	
 	/* Configure watchdogs, access, etc */
 	wcdte_setctl(wc, 0x0030, 0x00280048);
@@ -1169,18 +1186,20 @@
 	wcdte_setctl(wc, 0x0084, 0x00000000);
 }
 
-static int wcdte_waitfor_csmencaps(struct wcdte *wc, unsigned int mask, int use_mask)
+static int wcdte_waitfor_csmencaps(struct wcdte *wc, unsigned int mask, int wait_mode)
 {
 	int ret;
 
 
-	if (use_mask)
+	if (wait_mode == 1)
 		ret = wait_event_interruptible_timeout(wc->regq, (wc->rcvflags == mask), wc->timeout);
+	else if (wait_mode == 2)
+		ret = wait_event_interruptible_timeout(wc->regq, ((wc->last_seqno == wc->last_rseqno) && (wc->rcvflags == mask)), wc->timeout);
 	else
-		ret = wait_event_interruptible_timeout(wc->regq, (wc->last_rcommand == wc->last_command_sent), wc->timeout);
+		ret = wait_event_interruptible_timeout(wc->regq, ((wc->last_rcommand == wc->last_command_sent) && (wc->last_seqno == wc->last_rseqno) && (wc->rcvflags == mask)), wc->timeout);
 	wc->rcvflags = 0;
 	wc->last_rcommand = 0;
-	wc->last_command_sent = 0;
+	wc->last_seqno = 0;
 
 	if (ret < 0)
 	{
@@ -1191,9 +1210,12 @@
 	if (ret == 0)
 	{
 		if (debug)
-			printk("wcdte error: Waitfor CSMENCAPS response timed out (ret = %d)\n", ret);
+			printk("wcdte error: Waitfor CSMENCAPS response timed out (ret = %d) (cmd_snt = %04X)\n", ret, wc->last_command_sent);
 		return(2);
 	}
+	if (wait_mode == 0)
+		wc->last_command_sent = 999;
+	wc->last_rseqno = 999;
 	return(0);
 }
 
@@ -1345,6 +1367,7 @@
 
 	} while (byteloc < firmware->size-20);
 	wc->timeout = 10 * HZ;
+	wc->last_command_sent = 0;
 	if (wcdte_waitfor_csmencaps(wc, RCV_CSMENCAPS, 1))
 		return(1);
 	
@@ -1360,6 +1383,8 @@
 {
 	int length = 0;
 	unsigned char chan1, chan2;
+	struct zt_transcoder_channel *ztc1, *ztc2;
+	struct dte_state *st1, *st2;
 	if(complicated == DTE_FORMAT_G729A)
 		length = G729_LENGTH;
 	else if (complicated == DTE_FORMAT_G723_1)
@@ -1373,19 +1398,31 @@
 	zt_send_cmd(wc, CMD_MSG_CREATE_CHANNEL(wc->seq_num++, part2_id), CMD_MSG_CREATE_CHANNEL_LEN, 0x0010);
 	chan2 = wc->last_rparm2;
 
+	ztc1 = &(wc->uencode->channels[part1_id/2]);
+	ztc2 = &(wc->udecode->channels[part2_id/2]);
+	st1 = ztc1->pvt;
+	st2 = ztc2->pvt;
+
 	/* Configure complex channel */
-	zt_send_cmd(wc, CMD_MSG_SET_IP_HDR_CHANNEL(wc->seq_num++, chan1, part2_id, part1_id), CMD_MSG_SET_IP_HDR_CHANNEL_LEN, 0x9000);
-	zt_send_cmd(wc, CMD_MSG_VOIP_VCEOPT(wc->seq_num++, chan1, length, 0), CMD_MSG_VOIP_VCEOPT_LEN, 0x8001);
+	zt_send_cmd(wc, CMD_MSG_SET_IP_HDR_CHANNEL(st1->cmd_seqno++, chan1, part2_id, part1_id), CMD_MSG_SET_IP_HDR_CHANNEL_LEN, 0x9000);
+	zt_send_cmd(wc, CMD_MSG_VOIP_VCEOPT(st1->cmd_seqno++, chan1, length, 0), CMD_MSG_VOIP_VCEOPT_LEN, 0x8001);
 
 	/* Configure simple channel */
-	zt_send_cmd(wc, CMD_MSG_SET_IP_HDR_CHANNEL(wc->seq_num++, chan2, part1_id, part2_id), CMD_MSG_SET_IP_HDR_CHANNEL_LEN, 0x9000);
-	zt_send_cmd(wc, CMD_MSG_VOIP_VCEOPT(wc->seq_num++, chan2, length, 0), CMD_MSG_VOIP_VCEOPT_LEN, 0x8001);
+	zt_send_cmd(wc, CMD_MSG_SET_IP_HDR_CHANNEL(st2->cmd_seqno++, chan2, part1_id, part2_id), CMD_MSG_SET_IP_HDR_CHANNEL_LEN, 0x9000);
+	zt_send_cmd(wc, CMD_MSG_VOIP_VCEOPT(st2->cmd_seqno++, chan2, length, 0), CMD_MSG_VOIP_VCEOPT_LEN, 0x8001);
+
+#ifdef QUIET_DSP
+	zt_send_cmd(wc, CMD_MSG_VOIP_TONECTL(st1->cmd_seqno++, chan1), CMD_MSG_VOIP_TONECTL_LEN, 0x805B);
+	zt_send_cmd(wc, CMD_MSG_VOIP_DTMFOPT(st1->cmd_seqno++, chan1), CMD_MSG_VOIP_DTMFOPT_LEN, 0x8002);
+	zt_send_cmd(wc, CMD_MSG_VOIP_TONECTL(st2->cmd_seqno++, chan2), CMD_MSG_VOIP_TONECTL_LEN, 0x805B);
+	zt_send_cmd(wc, CMD_MSG_VOIP_DTMFOPT(st2->cmd_seqno++, chan2), CMD_MSG_VOIP_DTMFOPT_LEN, 0x8002);
+	zt_send_cmd(wc, CMD_MSG_VOIP_INDCTRL(st1->cmd_seqno++, chan1), CMD_MSG_VOIP_INDCTRL_LEN, 0x8084);
+	zt_send_cmd(wc, CMD_MSG_VOIP_INDCTRL(st2->cmd_seqno++, chan2), CMD_MSG_VOIP_INDCTRL_LEN, 0x8084);
+#endif
 
 	zt_send_cmd(wc, CMD_MSG_TRANS_CONNECT(wc->seq_num++, 1, chan1, chan2, complicated, simple), CMD_MSG_TRANS_CONNECT_LEN, 0x9322);
-	zt_send_cmd(wc, CMD_MSG_VOIP_INDCTRL(wc->seq_num++, chan1), CMD_MSG_VOIP_INDCTRL_LEN, 0x8084);
-	zt_send_cmd(wc, CMD_MSG_VOIP_INDCTRL(wc->seq_num++, chan2), CMD_MSG_VOIP_INDCTRL_LEN, 0x8084);
-	zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA(wc->seq_num++, chan1, complicated), CMD_MSG_VOIP_VOPENA_LEN, 0x8000);
-	zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA(wc->seq_num++, chan2, simple), CMD_MSG_VOIP_VOPENA_LEN, 0x8000);
+	zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA(st1->cmd_seqno++, chan1, complicated), CMD_MSG_VOIP_VOPENA_LEN, 0x8000);
+	zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA(st2->cmd_seqno++, chan2, simple), CMD_MSG_VOIP_VOPENA_LEN, 0x8000);
 
 	*dte_chan1 = chan1;
 	*dte_chan2 = chan2;
@@ -1395,16 +1432,23 @@
 
 static int wcdte_destroy_channel(struct wcdte *wc, unsigned int chan1, unsigned int chan2)
 {
+	struct zt_transcoder_channel *ztc1, *ztc2;
+	struct dte_state *st1, *st2;
+
+	ztc1 = &(wc->uencode->channels[chan1/2]);
+	ztc2 = &(wc->udecode->channels[chan2/2]);
+	st1 = ztc1->pvt;
+	st2 = ztc2->pvt;
 
 	/* Turn off both channels */
-	zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA_CLOSE(wc->seq_num++, chan1), CMD_MSG_VOIP_VOPENA_CLOSE_LEN, 0x8000);
-	zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA_CLOSE(wc->seq_num++, chan2), CMD_MSG_VOIP_VOPENA_CLOSE_LEN, 0x8000);
+	zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA_CLOSE(st1->cmd_seqno++, chan1), CMD_MSG_VOIP_VOPENA_CLOSE_LEN, 0x8000);
+	zt_send_cmd(wc, CMD_MSG_VOIP_VOPENA_CLOSE(st2->cmd_seqno++, chan2), CMD_MSG_VOIP_VOPENA_CLOSE_LEN, 0x8000);
 	
 	/* Disconnect the channels */
 	zt_send_cmd(wc, CMD_MSG_TRANS_CONNECT(wc->seq_num++, 0, chan1, chan2, 0, 0), CMD_MSG_TRANS_CONNECT_LEN, 0x9322);
 
 	/* Remove the channels */
-	zt_send_cmd(wc, CMD_MSG_DESTROY_CHANNEL(wc->seq_num++, chan1), CMD_MSG_DESTROY_CHANNEL_LEN,  0x0011);
+	zt_send_cmd(wc, CMD_MSG_DESTROY_CHANNEL(wc->seq_num++, chan1), CMD_MSG_DESTROY_CHANNEL_LEN, 0x0011);
 	zt_send_cmd(wc, CMD_MSG_DESTROY_CHANNEL(wc->seq_num++, chan2), CMD_MSG_DESTROY_CHANNEL_LEN, 0x0011);
 
 	return 1;
@@ -1412,6 +1456,8 @@
 
 static int wcdte_setup_channels(struct wcdte *wc)	
 {
+	down(&wc->chansem);
+
 #ifndef USE_TEST_HW
 	zt_send_cmd(wc, CMD_MSG_SET_ARM_CLK(wc->seq_num++), CMD_MSG_SET_ARM_CLK_LEN, 0x0411);
 	zt_send_cmd(wc, CMD_MSG_SET_SPU_CLK(wc->seq_num++), CMD_MSG_SET_SPU_CLK_LEN, 0x0412);
@@ -1443,7 +1489,9 @@
 	zt_send_cmd(wc, CMD_MSG_TDM_OPT(wc->seq_num++), CMD_MSG_TDM_OPT_LEN, 0x0435);
 #endif
 
-	wc->timeout = HZ/100 + 1; 	/* 10msec */
+	wc->timeout = HZ/10 + 1; 	/* 100msec */
+
+	up(&wc->chansem);
 
 	return(0);
 }
@@ -1457,6 +1505,10 @@
 	static int initd_ifaces=0;
 	unsigned char g729_numchannels, g723_numchannels, min_numchannels, dte_firmware_ver;
 	unsigned int complexfmts;
+#if !defined(HOTPLUG_FIRMWARE)
+	extern void _binary_zaptel_fw_tc400m_bin_size;
+	extern u8 _binary_zaptel_fw_tc400m_bin_start[];
+#endif
 	struct firmware embedded_firmware = {
 #if !defined(HOTPLUG_FIRMWARE)
 		/* Yes... this is weird. objcopy gives us a symbol containing
@@ -1465,8 +1517,8 @@
 		   is to take its address, so we define it as a pointer and
 		   then cast that value to the proper type.

[... 328 lines stripped ...]



More information about the zaptel-commits mailing list