[zaptel-commits] mattf: branch mattf/zaptel-1.4-ztmonitorstereo r4295 - in /team/mattf/zaptel-...

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Thu May 15 10:01:50 CDT 2008


Author: mattf
Date: Thu May 15 10:01:49 2008
New Revision: 4295

URL: http://svn.digium.com/view/zaptel?view=rev&rev=4295
Log: (empty)

Added:
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/init_card_1_30
      - copied unchanged from r4290, branches/1.4/kernel/xpp/init_card_1_30
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/init_card_2_30
      - copied unchanged from r4290, branches/1.4/kernel/xpp/init_card_2_30
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/init_card_3_30
      - copied unchanged from r4290, branches/1.4/kernel/xpp/init_card_3_30
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/init_card_4_30
      - copied unchanged from r4290, branches/1.4/kernel/xpp/init_card_4_30
Removed:
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/init_card_3_29
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/init_card_4_29
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/init_card_6_29
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/init_card_7_29
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/init_card_9_29
Modified:
    team/mattf/zaptel-1.4-ztmonitorstereo/   (props changed)
    team/mattf/zaptel-1.4-ztmonitorstereo/Makefile
    team/mattf/zaptel-1.4-ztmonitorstereo/README
    team/mattf/zaptel-1.4-ztmonitorstereo/build_tools/uninstall-modules
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/Kbuild
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/pciradio.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wct4xxp/base.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wct4xxp/wct4xxp.h
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wctdm.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wcte11xp.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wcte12xp/base.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/.version
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/Changelog_xpp
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/Kbuild
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/README.Astribank
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_bri.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_fxo.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_fxo.h
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_fxs.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_fxs.h
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_global.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_global.h
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_pri.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/firmwares/FPGA_1141.hex
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/firmwares/FPGA_1151.hex
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/firmwares/FPGA_FXS.hex
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/Makefile
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/fpga_load.8
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/fpga_load.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/genzaptelconf
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/print_modes.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/xpp_blink
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/xpp_fxloader
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/xpp_modprobe
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/zconf/Zaptel/Chans.pm
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/zconf/Zaptel/Config/Defaults.pm
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/zconf/Zaptel/Xpp/Line.pm
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xbus-core.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xbus-core.h
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xbus-pcm.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xbus-sysfs.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xdefs.h
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xframe_queue.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xpd.h
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xpp_usb.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xpp_zap.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xpp_zap.h
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xproto.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/xproto.h
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/zap_debug.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/zap_debug.h
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/zaptel-base.c
    team/mattf/zaptel-1.4-ztmonitorstereo/kernel/zaptel.h
    team/mattf/zaptel-1.4-ztmonitorstereo/live_zap
    team/mattf/zaptel-1.4-ztmonitorstereo/zaptel.init
    team/mattf/zaptel-1.4-ztmonitorstereo/ztcfg.c
    team/mattf/zaptel-1.4-ztmonitorstereo/ztscan.c

Propchange: team/mattf/zaptel-1.4-ztmonitorstereo/
------------------------------------------------------------------------------
--- branch-1.2-blocked (original)
+++ branch-1.2-blocked Thu May 15 10:01:49 2008
@@ -1,1 +1,1 @@
-/branches/1.2:917,937,1073,1206,1613,2018,2434,2583,2668,2750,2789,2868,2871,2878,3083,3098-3099,3201,3509,3645,3833,3847,3917,3951,4037-4038,4117
+/branches/1.2:917,937,1073,1206,1613,2018,2434,2583,2668,2750,2789,2868,2871,2878,3083,3098-3099,3201,3509,3645,3833,3847,3917,3951,4037-4038,4117,4233

Propchange: team/mattf/zaptel-1.4-ztmonitorstereo/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/mattf/zaptel-1.4-ztmonitorstereo/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu May 15 10:01:49 2008
@@ -7,6 +7,8 @@
 Module.symvers
 Modules.symvers
 README.html
+zaptel.conf.asciidoc
+tonezones.txt
 autom4te.cache
 config.log
 config.status

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/Makefile
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/Makefile?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/Makefile (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/Makefile Thu May 15 10:01:49 2008
@@ -18,7 +18,9 @@
 PWD:=$(shell pwd)
 endif
 
+ifeq ($(ARCH),)
 ARCH:=$(shell uname -m | sed -e s/i.86/i386/)
+endif
 
 ifeq ($(DEB_HOST_GNU_TYPE),)
 UNAME_M:=$(shell uname -m)
@@ -190,7 +192,7 @@
   UNAME_M=$(UNAME_M) \
   BUILD_TOPDIR_MODULES="$(BUILD_TOPDIR_MODULES)" BUILD_SUBDIR_MODULES="$(BUILD_SUBDIR_MODULES)"
 else
-KMAKE  = $(MAKE) -C $(KSRC) SUBDIRS=$(PWD)/kernel \
+KMAKE  = $(MAKE) -C $(KSRC) ARCH=$(ARCH) SUBDIRS=$(PWD)/kernel \
   HOTPLUG_FIRMWARE=$(HOTPLUG_FIRMWARE) KBUILD_OBJ_M="$(KBUILD_OBJ_M)"
 endif
 KMAKE_INST = $(KMAKE) \
@@ -371,12 +373,18 @@
 stackcheck: checkstack modules
 	./checkstack kernel/*.ko kernel/*/*.ko
 
+
+tonezones.txt: zonedata.c
+	perl -ne 'next unless (/\.(country|description) = *"([^"]*)/); \
+		print (($$1 eq "country")? "* $$2\t":"$$2\n");' $<  \
+	>$@
+
 zaptel.conf.asciidoc: zaptel.conf.sample
 	perl -n -e \
 		'if (/^#($$|\s)(.*)/){ if (!$$in_doc){print "\n"}; $$in_doc=1; print "$$2\n" } else { if ($$in_doc){print "\n"}; $$in_doc=0; print "  $$_" }' \
 		$< >$@
 
-README.html: README zaptel.conf.asciidoc
+README.html: README zaptel.conf.asciidoc tonezones.txt
 	$(ASCIIDOC) -n -a toc -a toclevels=3 $<
 
 kernel/xpp/README.Astribank.html: kernel/xpp/README.Astribank
@@ -517,15 +525,9 @@
 uninstall-hotplug:
 	$(MAKE) -C firmware hotplug-uninstall DESTDIR=$(DESTDIR)
 
-BASENAMES=$(sort $(shell for x in $(ALL_MODULES); do basename $x; done))
 uninstall-modules:
 ifneq ($(BUILDVER),linux24)
-	@./build_tools/uninstall-modules $(DESTDIR)/lib/modules/$(KVERS) $(BASENAMES)
-	@for x in $(ALL_MODULES); do \
-		rm -f $(DESTDIR)/lib/modules/$(KVERS)/extra/$$x ; \
-		rm -f $(DESTDIR)/lib/modules/$(KVERS)/misc/$$x ; \
-		rm -f $(DESTDIR)/lib/modules/$(KVERS)/zaptel/$$x ; \
-	done;
+	@./build_tools/uninstall-modules $(DESTDIR)/lib/modules/$(KVERS) $(ALL_MODULES)
 endif
 
 ifeq ($(BUILDVER),linux24)
@@ -533,7 +535,7 @@
 	$(INSTALL) -d $(DESTDIR)$(MOD_DIR)
 	$(INSTALL) -m 644 $(INSTALL_MODULES) $(DESTDIR)$(MOD_DIR)
 else
-install-modules: 
+install-modules: uninstall-modules
 	$(KMAKE_INST)
 endif
 	[ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/README
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/README?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/README (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/README Thu May 15 10:01:49 2008
@@ -384,8 +384,19 @@
     * 16: DEBUG_ECHOCAN
     * 32: DEBUG_RBS
     * 64: DEBUG_FRAMER
-  The 'xpp' modules use 'print_dbg' instead of 'debug' . Refer to
-  README.Astribank.
+  - xpp: Previously (before 1.2.26 / 1.4.11) it was called "print_dbg". 
+    See also README.Astribank:
+    * 1: GENERAL - General debug comments.
+    * 2: PCM - PCM-related messages. Tend to flood logs.
+    * 4: LEDS - Anything related to the LEDs status control. The driver
+      produces a lot of messages when the option is enabled.
+    * 8: SYNC - Synchronization related messages.
+    * 16: SIGNAL - Zaptel signalling related messages.
+    * 32: PROC - Messages related to the procfs interface.
+    * 64: REGS - Reading and writing to chip registers. Tends to flood
+          logs.
+    * 128: DEVICES - Device instantiation, destruction and such.
+    * 256 - COMMANDS - Protocol commands. Tends to flood logs.
 
 deftaps (zaptel)::
   The default size for the echo canceller. The number is in "taps", that
@@ -412,6 +423,13 @@
 Reference Configuration
 -----------------------
 include::zaptel.conf.asciidoc[]
+
+Tonezones
+~~~~~~~~~
+The file zonedata.c contains the information about the tone zones used
+in libtonezone (and hence also in ztcfg). Here is a list of those zones:
+
+include::tonezones.txt[]
 
 
 Zaptel PERL modules
@@ -644,8 +662,14 @@
 appear slightly confusing in the code, but it is useful for writing code
 that works with both versions of Zaptel. 
 
+
 Past Incompatibilities
 ^^^^^^^^^^^^^^^^^^^^^^
+
+.Zaptel 1.4.10:
+* Semantics of ZT_LOADZONE. Using newer ztcfg with older modules will
+  yield -EINVAL with the kernel message 'Invalid tone (96) defined'
+
 .Zaptel 1.4.8:
 * ZT_GET_PARAMS_V1
 * ZT_SET_PARAMS_V1

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/build_tools/uninstall-modules
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/build_tools/uninstall-modules?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/build_tools/uninstall-modules (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/build_tools/uninstall-modules Thu May 15 10:01:49 2008
@@ -14,8 +14,8 @@
 	echo "Usage:"
 	echo "  $0 MODULES_BASE_DIR mod1 [mod2 [...]]"
 	echo ""
-	echo "  MODULES_BASE_DIR - typically /lib/odules/KVERS"
-	echo "  modN -             (optinally partial) module name to remove."
+	echo "  MODULES_BASE_DIR - typically /lib/modules/KVERS"
+	echo "  modN -             (optionally partial) module name to remove."
 }
 
 if [ -z "$KERNEL_MODULES_DIR" ]; then
@@ -30,9 +30,10 @@
 	exit 1;
 fi
 for mod in $MODULES; do 
-	for file in `cat $KERNEL_MODULES_DIR/modules.dep | cut -d : -f 1 | grep $mod`; do
+	BASE=`basename $mod`
+	for file in `cat $KERNEL_MODULES_DIR/modules.dep | cut -d : -f 1 | grep "$BASE$"`; do
 		if [ -e "$file" ]; then
-			echo "Deleting $file."
+			#echo "Deleting $file."
 			rm -f $file
 		fi
 	done

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/Kbuild
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/Kbuild?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/Kbuild (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/Kbuild Thu May 15 10:01:49 2008
@@ -32,7 +32,7 @@
 
 ifeq ($(HPEC_PRESENT),yes)
 EXTRA_CFLAGS += -DECHO_CAN_HPEC -I$(src)/hpec
-$(obj)/zaptel-base.o: hpec/hpec_zaptel.h hpec/hpec_user.h
+$(obj)/zaptel-base.o: $(src)/hpec/hpec_zaptel.h $(src)/hpec/hpec_user.h
 endif
 
 $(obj)/pciradio.o: $(obj)/radfw.h

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/pciradio.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/pciradio.c?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/pciradio.c (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/pciradio.c Thu May 15 10:01:49 2008
@@ -1355,8 +1355,9 @@
 				stack.p.index = rad->rxindex;
 				break;
 			}
-			/* wait for done only if in SERIAL_ASCII mode */
-			if (rad->remmode[chan->chanpos - 1] == ZT_RADPAR_REM_SERIAL_ASCII)
+			/* wait for done if in SERIAL_ASCII mode, or if no Rx aftwards */
+			if ((rad->remmode[chan->chanpos - 1] == ZT_RADPAR_REM_SERIAL_ASCII) ||
+				(!stack.p.data))
 			{			
 				/* wait for TX to be done if not already */
 				while(rad->txlen && (rad->txindex < rad->txlen))

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wct4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wct4xxp/base.c?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wct4xxp/base.c (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wct4xxp/base.c Thu May 15 10:01:49 2008
@@ -306,7 +306,6 @@
 	int ledreg;				/* LED Register */
 	unsigned int gpio;
 	unsigned int gpioctl;
-	int stopdma;			/* Set to stop DMA */
 	int e1recover;			/* E1 recovery timer */
 	spinlock_t reglock;		/* lock register access */
 	int spansstarted;		/* number of spans started */
@@ -320,7 +319,6 @@
 	unsigned int passno;	/* number of interrupt passes */
 	char *variety;
 	int last0;		/* for detecting double-missed IRQ */
-	int checktiming;	/* Set >0 to cause the timing source to be checked */
 
 	/* DMA related fields */
 	unsigned int dmactrl;
@@ -329,6 +327,9 @@
 	unsigned long memaddr;		/* Base address of card */
 	unsigned long memlen;
 	volatile unsigned int *membase;	/* Base address of card */
+
+	/* Add this for our softlockup protector */
+	unsigned int oct_rw_count;
 
 	/* Flags for our bottom half */
 	unsigned long checkflag;
@@ -416,7 +417,8 @@
 		 * transactions, some host bridges appear to generate them.
 		 * This delay prevents this. 
 		 */
-		udelay(3);
+		if (!test_bit(T4_LOADING_FW, &wc->checkflag))
+			udelay(3);
 	}
 	return res;
 }
@@ -430,7 +432,8 @@
 		 * transactions, some host bridges appear to generate them.
 		 * This delay prevents this. 
 		 */
-		udelay(3);
+		if (!test_bit(T4_LOADING_FW, &wc->checkflag))
+			udelay(3);
 		tmp = __t4_pci_in(wc, WC_VERSION);
 		if ((tmp & 0xffff0000) != 0xc01a0000)
 			printk("TE4XXP: Version Synchronization Error!\n");
@@ -655,6 +658,7 @@
 {
 	unsigned long flags;
 	unsigned int ret;
+
 	spin_lock_irqsave(&wc->reglock, flags);
 	ret = __t4_oct_in(wc, addr);
 	spin_unlock_irqrestore(&wc->reglock, flags);
@@ -716,6 +720,7 @@
 static inline void t4_oct_out(struct t4 *wc, const unsigned int addr, const unsigned int value)
 {
 	unsigned long flags;
+
 	spin_lock_irqsave(&wc->reglock, flags);
 	__t4_oct_out(wc, addr, value);
 	spin_unlock_irqrestore(&wc->reglock, flags);
@@ -1403,8 +1408,10 @@
 	    (!(wc->tspans[1]->span.flags & ZT_FLAG_RUNNING)))) {
 		/* No longer in use, disable interrupts */
 		printk("TE%dXXP: Disabling interrupts since there are no active spans\n", wc->numspans);
-		wc->stopdma = 1;
-	} else wc->checktiming = 1;
+		set_bit(T4_STOP_DMA, &wc->checkflag);
+	} else
+		set_bit(T4_CHECK_TIMING, &wc->checkflag);
+
 	spin_unlock_irqrestore(&wc->reglock, flags);
 
 	/* Wait for interrupt routine to shut itself down */
@@ -1445,7 +1452,11 @@
 		wc->tspans[lc->sync - 1]->sync = span->spanno;
 		wc->tspans[lc->sync - 1]->psync = span->offset + 1;
 	}
-	wc->checktiming = 1;
+	set_bit(T4_CHECK_TIMING, &wc->checkflag);
+
+	/* Make sure this is clear in case of multiple startup and shutdown
+	 * iterations */
+	clear_bit(T4_STOP_DMA, &wc->checkflag);
 	
 	/* If we're already running, then go ahead and apply the changes */
 	if (span->flags & ZT_FLAG_RUNNING)
@@ -1615,7 +1626,7 @@
 		for (y=0;y<wc->tspans[x]->span.channels;y++) {
 			struct zt_chan *mychans = ts->chans + y;
 			sprintf(mychans->name, "TE%d/%d/%d/%d", wc->numspans, wc->num, x + 1, y + 1);
-			mychans->sigcap = ZT_SIG_EM | ZT_SIG_CLEAR | ZT_SIG_FXSLS | ZT_SIG_FXSGS | ZT_SIG_FXSKS | ZT_SIG_HARDHDLC |
+			mychans->sigcap = ZT_SIG_EM | ZT_SIG_CLEAR | ZT_SIG_FXSLS | ZT_SIG_FXSGS | ZT_SIG_FXSKS | ZT_SIG_HARDHDLC | ZT_SIG_MTP2 |
 									 ZT_SIG_FXOLS | ZT_SIG_FXOGS | ZT_SIG_FXOKS | ZT_SIG_CAS | ZT_SIG_EM_E1 | ZT_SIG_DACS_RBS;
 			mychans->pvt = wc;
 			mychans->chanpos = y + 1;
@@ -1804,7 +1815,7 @@
 			}
 		}
 	} else
-		cards[0]->checktiming = 1;
+		set_bit(T4_CHECK_TIMING, &cards[0]->checkflag);
 #endif	
 	spin_unlock_irqrestore(&synclock, flags);
 	return 0;
@@ -1814,7 +1825,7 @@
 {
 	int x;
 	printk("timing source auto card %d!\n", wc->num);
-	wc->checktiming = 0;
+	clear_bit(T4_CHECK_TIMING, &wc->checkflag);
 	if (timingcable) {
 		__t4_findsync(wc);
 	} else {
@@ -2494,7 +2505,7 @@
 
 	if (((!ts->span.alarms) && alarms) || 
 	    (ts->span.alarms && (!alarms))) 
-		wc->checktiming = 1;
+		set_bit(T4_CHECK_TIMING, &wc->checkflag);
 
 	/* Keep track of recovering */
 	if ((!alarms) && ts->span.alarms) 
@@ -2858,7 +2869,7 @@
 
 	__handle_leds(wc);
 
-	if (wc->checktiming > 0)
+	if (test_bit(T4_CHECK_TIMING, &wc->checkflag))
 		__t4_set_timing_source_auto(wc);
 
 	spin_unlock_irqrestore(&wc->reglock, flags);
@@ -2892,6 +2903,19 @@
 	struct t4 *wc = dev_id;
 	unsigned int status;
 	
+	/* Check this first in case we get a spurious interrupt */
+	if (unlikely(test_bit(T4_STOP_DMA, &wc->checkflag))) {
+		/* 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);
+		spin_lock(&wc->reglock);
+		__t4_set_timing_source(wc, 4, 0, 0);
+		spin_unlock(&wc->reglock);
+		return IRQ_RETVAL(1);
+	}
+
 	/* Make sure it's really for us */
 	status = __t4_pci_in(wc, WC_INTR);
 
@@ -2985,18 +3009,8 @@
 
 	spin_lock(&wc->reglock);
 
-	if (unlikely(wc->checktiming > 0)) {
+	if (unlikely(test_bit(T4_CHECK_TIMING, &wc->checkflag))) {
 		__t4_set_timing_source_auto(wc);
-	}
-
-	if (unlikely(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(&wc->reglock);
@@ -3182,12 +3196,15 @@
 		return;
 	}
 
+	set_bit(T4_LOADING_FW, &wc->checkflag);
 	if (!(wc->vpm450m = init_vpm450m(wc, laws, wc->numspans, firmware))) {
 		printk("VPM450: Failed to initialize\n");
 		if (firmware != &embedded_firmware)
 			release_firmware(firmware);
+		clear_bit(T4_LOADING_FW, &wc->checkflag);
 		return;
 	}
+	clear_bit(T4_LOADING_FW, &wc->checkflag);
 
 	if (firmware != &embedded_firmware)
 		release_firmware(firmware);
@@ -3497,7 +3514,7 @@
 			return -1;
 		}
 	}
-	wc->checktiming = 1;
+	set_bit(T4_CHECK_TIMING, &wc->checkflag);
 	spin_lock_irqsave(&wc->reglock, flags);
 	__t4_set_timing_source(wc,4, 0, 0);
 	spin_unlock_irqrestore(&wc->reglock, flags);
@@ -3702,10 +3719,10 @@
 {
 
 	/* Turn off DMA, leave interrupts enabled */
-	wc->stopdma = 1;
-
-	current->state = TASK_UNINTERRUPTIBLE;
-	schedule_timeout((25 * HZ) / 1000);
+	set_bit(T4_STOP_DMA, &wc->checkflag);
+
+	/* Wait for interrupts to stop */
+	msleep(25);
 
 	/* Turn off counter, address, etc */
 	if (wc->tspans[0]->spanflags & FLAG_2NDGEN) {
@@ -3752,30 +3769,16 @@
 			destroy_workqueue(wc->workq);
 		}
 #endif			
-#if 0
-		/* Stop any DMA */
-		__t1xxp_stop_dma(wc);
-
-		/* In case hardware is still there */
-		__t1xxp_disable_interrupts(wc);
-		
-		t1xxp_stop_stuff(wc);
-#endif
+
+		free_irq(pdev->irq, wc);
 
 		if (wc->membase)
 			iounmap((void *)wc->membase);
 
 		pci_release_regions(pdev);		
-#if 0
-		if (wc->memaddr)
-			release_mem_region(wc->memaddr, wc->memlen);
-#endif
 
 		/* Immediately free resources */
 		pci_free_consistent(pdev, ZT_MAX_CHUNKSIZE * 2 * 2 * 32 * 4, (void *)wc->writechunk, wc->writedma);
-#if 1
-		free_irq(pdev->irq, wc);
-#endif		
 
 		order_index[wc->order]--;
 

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wct4xxp/wct4xxp.h
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wct4xxp/wct4xxp.h?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wct4xxp/wct4xxp.h (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wct4xxp/wct4xxp.h Thu May 15 10:01:49 2008
@@ -106,6 +106,9 @@
 };
 
 #define T4_CHECK_VPM		0
+#define T4_LOADING_FW		1
+#define T4_STOP_DMA		2
+#define T4_CHECK_TIMING		3
 
 #define WCT4_GET_REGS	_IOW (ZT_CODE, 60, struct t4_regs)
 

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wctdm.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wctdm.c?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wctdm.c (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wctdm.c Thu May 15 10:01:49 2008
@@ -909,18 +909,18 @@
 				fxo->battdebounce = battdebounce / MS_PER_CHECK_HOOK;
 			}
 		}
-
-		if (fxo->lastpol >= 0) {
-			if (b < 0) {
-				fxo->lastpol = -1;
-				fxo->polaritydebounce = POLARITY_DEBOUNCE / MS_PER_CHECK_HOOK;
-			}
-		} 
-		if (fxo->lastpol <= 0) {
-			if (b > 0) {
-				fxo->lastpol = 1;
-				fxo->polaritydebounce = POLARITY_DEBOUNCE / MS_PER_CHECK_HOOK;
-			}
+	}
+
+	if (fxo->lastpol >= 0) {
+		if (b < 0) {
+			fxo->lastpol = -1;
+			fxo->polaritydebounce = POLARITY_DEBOUNCE / MS_PER_CHECK_HOOK;
+		}
+	} 
+	if (fxo->lastpol <= 0) {
+		if (b > 0) {
+			fxo->lastpol = 1;
+			fxo->polaritydebounce = POLARITY_DEBOUNCE / MS_PER_CHECK_HOOK;
 		}
 	}
 

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wcte11xp.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wcte11xp.c?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wcte11xp.c (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wcte11xp.c Thu May 15 10:01:49 2008
@@ -1006,7 +1006,7 @@
 	for (x=0;x<wc->span.channels;x++) {
 		sprintf(wc->chans[x].name, "WCT1/%d/%d", wc->num, x + 1);
 		wc->chans[x].sigcap = ZT_SIG_EM | ZT_SIG_CLEAR | ZT_SIG_EM_E1 | 
-				      ZT_SIG_FXSLS | ZT_SIG_FXSGS | 
+				      ZT_SIG_FXSLS | ZT_SIG_FXSGS | ZT_SIG_MTP2 |
 				      ZT_SIG_FXSKS | ZT_SIG_FXOLS | ZT_SIG_DACS_RBS |
 				      ZT_SIG_FXOGS | ZT_SIG_FXOKS | ZT_SIG_CAS | ZT_SIG_SF;
 		wc->chans[x].pvt = wc;

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wcte12xp/base.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wcte12xp/base.c?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wcte12xp/base.c (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/wcte12xp/base.c Thu May 15 10:01:49 2008
@@ -1164,7 +1164,7 @@
 	for (x = 0; x < wc->span.channels; x++) {
 		sprintf(wc->chans[x].name, "WCT1/%d/%d", wc->num, x + 1);
 		wc->chans[x].sigcap = ZT_SIG_EM | ZT_SIG_CLEAR | ZT_SIG_EM_E1 | 
-				      ZT_SIG_FXSLS | ZT_SIG_FXSGS | 
+				      ZT_SIG_FXSLS | ZT_SIG_FXSGS | ZT_SIG_MTP2 |
 				      ZT_SIG_FXSKS | ZT_SIG_FXOLS | ZT_SIG_DACS_RBS |
 				      ZT_SIG_FXOGS | ZT_SIG_FXOKS | ZT_SIG_CAS | ZT_SIG_SF;
 		wc->chans[x].pvt = wc;

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/.version
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/.version?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/.version (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/.version Thu May 15 10:01:49 2008
@@ -1,1 +1,1 @@
-trunk-r5566
+trunk-r5723

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/Changelog_xpp
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/Changelog_xpp?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/Changelog_xpp (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/Changelog_xpp Thu May 15 10:01:49 2008
@@ -1,3 +1,27 @@
+Tue, 13 May 2008 Oron Peled <oron at actcom.co.il> - xpp.r5723
+  * [A temporary changelog. More to come]
+  * New firmware protocol version: 3.0 .
+  * New numbers for the device types: (e.g. in card_init* scripts)
+    - FXS: 1 (was: 3)
+    - FXO: 2 (was: 4)
+    - BRI: 3 (was: 6 for TE, 7 for NT)
+    - PRI: 4 (was: 9)
+  * Init scripts of FXS and FXO modules are now written in Perl as well
+    (be sure to have File::Basename, e.g: perl-modules in Debian).
+  * calibrate_slics merged into init_card_1_30 .
+  * Module parameter print_dbg replaced with debug . Same meaning.
+  * init_fxo_modes removed: content moved into init_card_2_30, verified
+    at build time.
+  * Code tested with sparse. Most warnings were fixed.
+  * Set ZT_SIG_DACS for the bchans in the PRI and BRI modules to not get
+    ignored by ztscan.
+  * Handle null config_desc we get from some crazy USB controllers.
+  * genzaptelconf: Fix reporting of empty slots in list mode.
+  * xpp_blink can now blink a single analog port.
+  * "slics" has been renamed "chipregs".
+  * Fixed a small typo in fpga_load(8).
+  * Fixed bashism in xpp_fxloader.
+
 Thu, 20 Mar 2008 Oron Peled <oron at actcom.co.il> - xpp.r5566
   * Build:
     - Zaptel >= 1.4.9 is migrating to storing kernel stuff in zaptel/kernel/*

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/Kbuild
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/Kbuild?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/Kbuild (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/Kbuild Thu May 15 10:01:49 2008
@@ -20,7 +20,7 @@
 
 obj-m		+= xpp.o xpd_fxs.o xpd_fxo.o xpd_pri.o
 
-HAS_BRISTUFF		:= $(shell cpp $(CPPFLAGS) -dM $(ZAP_KERNEL)/zconfig.h | sed -n 's/^.*CONFIG_ZAPATA_BRI_DCHANS/y/p')
+HAS_BRISTUFF	:= $(shell grep '^[[:space:]]*\#[[:space:]]*define[[:space:]]\+CONFIG_ZAPATA_BRI_DCHANS\>' $(ZAP_KERNEL)/zconfig.h)
 
 # Build only supported modules
 ifneq	(,$(filter y m,$(CONFIG_USB)))

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/README.Astribank
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/README.Astribank?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/README.Astribank (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/README.Astribank Thu May 15 10:01:49 2008
@@ -588,6 +588,62 @@
 once a new call needs to be made.
 
 
+Both default and sysconfig Exist
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.Symptoms:
+The firmware fails to load. Manually running xpp_fxloader gives:
+
+  Both '/etc/default/zaptel' and '/etc/sysconfig/zaptel' exist
+
+Alternatively: an initialization script fails and gives the error
+
+  An '/etc/default/zaptel' collides with 'etc/sysconfig/zaptel'
+
+.Cause:
+/etc/default/<service name> is the place used in Debian-based 
+systems for initialization scripts. /etc/sysconfig/<service name> is
+used in Redhat and similar for the same purpose. For historical reasons
+many of our programs read configuration from there: either from
+/etc/default/zaptel or from /etc/sysconfig/zaptel .
+
+The problem is what to do if both of those exist. Selecting an arbitrary
+one can lead to unexpected results. Likewise sourcing both of them.
+Therefore we prefer to fail in a noisy and expected way. In the future
+we will probably me to reading configuration from a file under /etc/zaptel .
+
+.Fix:
+Remove one of those two. There should be no reason to have both on the
+same system.
+
+
+Astribank not initialized: Premature packet end
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.Symptoms:
+After upgrading to Zaptel 1.4.12 / 1.2.25 the initialization of the
+Astribank times out. In the logs you see:
+
+  kernel: NOTICE-xpp: XBUS-00(00): FIRMWARE: ERROR_CODE CODE = 0x3 (Premature packet end) 
+
+.Cause:
+When an Astribank is detected, the driver asks it what is its version
+and what components it has. Normally if the version of the firmware and
+of the driver does not match the driver gives an ugly message and fails
+the initialization.
+
+However in the change of the protocol between versions 2.9 (29) and 3.0
+(30), the response that the new driver recieves from a device with the
+old version is now considered to be an illegal packet and gets
+discarded. As a result, the Astribank waits till time-out for the
+initilization to end.
+
+.Fix:
+Reset the firmware of the Astribank by either:
+
+  /usr/share/zaptel/xpp_fxloader reset
+
+or disconnecting it from the power and reconnecting it.
+
+
 Reference
 ---------
 LEDs Indication
@@ -1254,27 +1310,28 @@
   separate tasklets. This should probably help on higher-end systems with
   multiple Astribanks.
 
-print_dbg (all modules)::
+debug (all modules)::
   It will make the driver to print tons of debugging messages. You can 
-  set/unset the parameter at run-time.
-
-  The parameter value is a bitmask of several values. The different bits 
-  meaning as it defined in xpp/zap_debug.h: 
+  set/unset the parameter at run-time. The parameter value is a bitmask 
+  of several values. The different bits  meaning as it defined in 
+  xpp/zap_debug.h: 
 
   * 0  - Disable debug messages
   * 1  - GENERAL - General debug comments.
-  * 2  - PCM - PCM-related messages. Tend to flood logs.
+  * 2  - PCM - PCM-related messages. Tends to flood logs.
   * 4  - LEDS - Anything related to the LEDs status control. The driver
          produces a lot of messages when the option is enabled.
   * 8  - SYNC - Synchronization related messages.
   * 16 - SIGNAL - Zaptel signalling related messages.
-  * 32 - PROC - procfs interface related messages.
-  * 64 - REGS - Reading and writing to chip registers. The driver produces
-         a lot of messages when the option is enabled.
+  * 32 - PROC - Messages related to the procfs interface.
+  * 64 - REGS - Reading and writing to chip registers. Tends to flood
+  	 logs.
+  * 128 - DEVICES - Device instantiation, destruction and such.
+  * 256 - COMMANDS - Protocol commands. Tends to flood logs.
 
   For example,
 
-    echo 33 >/sys/modules/xpp/parameters/print_dbg 
+    echo 33 >/sys/modules/xpp/parameters/debug 
 
   forces module xpp to print general debugging messages (1) and procfs
   debugging messages (32).
@@ -1288,24 +1345,22 @@
 
 usb1 (xpp_usb)::
   Enable (1) or disable (0) support of USB1 devices. Disabled by default.
-  +
-  +
+
   USB1 devices are not well-tested. It seems that they don't work at all
   for Astribank BRI. Generally they should work with the current code, but
-  we expect the voice quality issues. Hence we would like to make it very clear that
-  you if you have a USB1 port (rather than a USB2 one, as recommended) you
-  will have to take an action to enable the device.
+  we expect the voice quality issues. Hence we would like to make it
+  very clear that you if you have a USB1 port (rather than a USB2 one, as 
+  recommended) you will have to take an action to enable the device.
 
 poll intervals (various)::
   There are various values which the driver occasionally polls the device
   for. For instance, the parameter poll_battery_interval for xpd_fxo
-  to poll the battery (in order to know if the telco line is actually
-  connected.)
-  +
-  +
-  The value of those parameters is typically a number in milliseconds or 0
-  to disable. Under normal operation there should be no reason to play
-  with those parameters.
+  to poll the battery, in order to know if the telco line is actually
+  connected.
+
+  The value of those parameters is typically a number in milliseconds. 
+  0 is used to disable polling. Under normal operation there should be 
+  no reason to play with those parameters.
 
 dtmf_detection (xpd_fxs)::
   Enable (1) or disable (0) support of hardware DTMF detection by the 

Modified: team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_bri.c
URL: http://svn.digium.com/view/zaptel/team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_bri.c?view=diff&rev=4295&r1=4294&r2=4295
==============================================================================
--- team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_bri.c (original)
+++ team/mattf/zaptel-1.4-ztmonitorstereo/kernel/xpp/card_bri.c Thu May 15 10:01:49 2008
@@ -31,7 +31,6 @@
 #include "xpp_zap.h"
 #include "card_bri.h"
 #include "zap_debug.h"
-#include "xpd.h"
 #include "xbus-core.h"
 
 static const char rcsid[] = "$Id$";
@@ -40,9 +39,9 @@
 #error CONFIG_ZAPATA_BRI_DCHANS is not defined
 #endif
 
-DEF_PARM(int, print_dbg, 0, 0644, "Print DBG statements");	/* must be before zap_debug.h */
-DEF_PARM(uint, poll_interval, 500, 0644, "Poll channel state interval in milliseconds (0 - disable)");
-DEF_PARM_BOOL(nt_keepalive, 1, 0644, "Force BRI_NT to keep trying connection");
+static DEF_PARM(int, debug, 0, 0644, "Print DBG statements");	/* must be before zap_debug.h */
+static DEF_PARM(uint, poll_interval, 500, 0644, "Poll channel state interval in milliseconds (0 - disable)");
+static DEF_PARM_BOOL(nt_keepalive, 1, 0644, "Force BRI_NT to keep trying connection");
 
 enum xhfc_states {
 	ST_RESET		= 0,	/* G/F0	*/
@@ -61,7 +60,7 @@
 	ST_NT_DEACTIVTING	= 4,	/* G4	*/
 };
 
-static const char *xhfc_state_name(xpd_type_t xpd_type, enum xhfc_states state)
+static const char *xhfc_state_name(bool is_nt, enum xhfc_states state)
 {
 	const char	*p;
 
@@ -84,16 +83,16 @@
 		_E(NT_DEACTIVTING),
 	};
 #undef	_E
-	if(xpd_type == XPD_TYPE_BRI_TE) {
+	if(is_nt) {
+		if ((state < ST_RESET) || (state > ST_NT_DEACTIVTING))
+			p = "NT ???";
+		else
+			p = nt_names[state];
+	} else {
 		if ((state < ST_RESET) || (state > ST_TE_LOST_FRAMING))
 			p = "TE ???";
 		else
 			p = te_names[state];
-	} else {
-		if ((state < ST_RESET) || (state > ST_NT_DEACTIVTING))
-			p = "NT ???";
-		else
-			p = nt_names[state];
 	}
 	return p;
 }
@@ -106,9 +105,8 @@
 
 #define HFC_L1_ACTIVATING	1
 #define HFC_L1_ACTIVATED	2
-#define	TIMER_T1_MAX		2500
+#define	HFC_TIMER_T1		2500
 #define	HFC_TIMER_T3		8000	/* 8s activation timer T3 */
-#define	HFC_TIMER_T4		500	/* 500ms deactivation timer T4 */
 #define	HFC_TIMER_OFF		-1	/* timer disabled */
 
 #define	A_SU_WR_STA		0x30	/* ST/Up state machine register		*/
@@ -145,9 +143,10 @@
 					ZT_SIG_CAS	| \
 					ZT_SIG_SF	  \
 				)
-#define	BRI_BCHAN_SIGCAP	ZT_SIG_CLEAR
-
-#define	IS_NT(xpd)		((xpd)->type == XPD_TYPE_BRI_NT)
+#define	BRI_BCHAN_SIGCAP	(ZT_SIG_CLEAR | ZT_SIG_DACS)
+
+#define	IS_NT(xpd)		((xpd)->direction == TO_PHONE)
+#define	BRI_PORT(xpd)		((xpd)->addr.subunit)
 
 /* shift in PCM highway */
 #define	SUBUNIT_PCM_SHIFT	4
@@ -159,8 +158,6 @@
 static bool bri_packet_is_valid(xpacket_t *pack);
 static void bri_packet_dump(const char *msg, xpacket_t *pack);
 static int proc_bri_info_read(char *page, char **start, off_t off, int count, int *eof, void *data);
-static int proc_xpd_register_read(char *page, char **start, off_t off, int count, int *eof, void *data);
-static int proc_xpd_register_write(struct file *file, const char __user *buffer, unsigned long count, void *data);
 static int bri_spanconfig(struct zt_span *span, struct zt_lineconfig *lc);
 static int bri_chanconfig(struct zt_chan *chan, int sigtype);
 static int bri_startup(struct zt_span *span);
@@ -168,8 +165,6 @@
 
 #define	PROC_REGISTER_FNAME	"slics"
 #define	PROC_BRI_INFO_FNAME	"bri_info"
-
-#define	VALID_CHIPSEL(x)	((x) == 0)
 
 enum led_state {
 	BRI_LED_OFF		= 0x0,
@@ -204,13 +199,11 @@
 #define	DCHAN_BUFSIZE	MAX_DFRAME_LEN_L1
 
 struct BRI_priv_data {
-	struct proc_dir_entry		*regfile;
 	struct proc_dir_entry		*bri_info;
 	su_rd_sta_t			state_register;
 	bool				initialized;
-	int				t1; /* timer 1 for NT deactivation */
-	int				t3; /* timer 3 for activation */
-	int				t4; /* timer 4 for deactivation */
+	int				t1;	/* timer 1 for NT deactivation */
+	int				t3;	/* timer 3 for TE activation */
 	ulong				l1_flags;
 	bool				reg30_good;
 	uint				reg30_ticks;
@@ -225,8 +218,6 @@
 	byte				dchan_tbuf[DCHAN_BUFSIZE];
 	bool				txframe_begin;
 
-	reg_cmd_t			requested_reply;
-	reg_cmd_t			last_reply;
 	uint				tick_counter;
 	uint				poll_counter;
 	uint				dchan_tx_counter;
@@ -239,8 +230,7 @@
 	enum led_state			ledstate[NUM_LEDS];
 };
 
-static xproto_table_t	PROTO_TABLE(BRI_NT);
-static xproto_table_t	PROTO_TABLE(BRI_TE);
+static xproto_table_t	PROTO_TABLE(BRI);
 
 
 DEF_RPACKET_DATA(BRI, SET_LED,	/* Set one of the LED's */
@@ -300,17 +290,13 @@
 	dump_hex_buf(xpd, msgbuf, buf, len);
 }
 
-static void layer1_state(xpd_t *xpd, bool up)
-{
-	struct BRI_priv_data	*priv;
-
-	BUG_ON(!xpd);
-	priv = xpd->priv;
-	BUG_ON(!priv);
-	if(priv->layer1_up == up)
-		return;
-	priv->layer1_up = up;
-	XPD_DBG(SIGNAL, xpd, "STATE CHANGE: Layer1 %s\n", (up)?"UP":"DOWN");
+static void set_bri_timer(xpd_t *xpd, const char *name, int *bri_timer, int value)
+{
+	if(value == HFC_TIMER_OFF)
+		XPD_DBG(SIGNAL, xpd, "Timer %s DISABLE\n", name);
+	else
+		XPD_DBG(SIGNAL, xpd, "Timer %s: set to %d\n", name, value);
+	*bri_timer = value;
 }
 
 static void dchan_state(xpd_t *xpd, bool up)
@@ -333,42 +319,113 @@
 	}
 }
 
-static void xpd_activation(xpd_t *xpd, bool on)
+static void layer1_state(xpd_t *xpd, bool up)
+{
+	struct BRI_priv_data	*priv;
+
+	BUG_ON(!xpd);
+	priv = xpd->priv;
+	BUG_ON(!priv);
+	if(priv->layer1_up == up)
+		return;
+	priv->layer1_up = up;
+	XPD_DBG(SIGNAL, xpd, "STATE CHANGE: Layer1 %s\n", (up)?"UP":"DOWN");
+	if(!up)
+		dchan_state(xpd, 0);
+}
+
+static void te_activation(xpd_t *xpd, bool on)
 {
 	struct BRI_priv_data	*priv;
 	xbus_t			*xbus;
+	byte			curr_state;
 
 	BUG_ON(!xpd);
 	priv = xpd->priv;
 	BUG_ON(!priv);
+	curr_state = priv->state_register.bits.v_su_sta;
 	xbus = xpd->xbus;
 	XPD_DBG(SIGNAL, xpd, "%s\n", (on)?"ON":"OFF");
-	switch(xpd->type) {
-		case XPD_TYPE_BRI_TE:
-			if(on) {
-				XPD_DBG(SIGNAL, xpd, "HFC_L1_ACTIVATE_TE\n");
+	if(on) {
+		if(curr_state == ST_TE_DEACTIVATED) {
+			XPD_DBG(SIGNAL, xpd, "HFC_L1_ACTIVATE_TE\n");
+			set_bit(HFC_L1_ACTIVATING, &priv->l1_flags);
+			write_state_register(xpd, STA_ACTIVATE);
+			set_bri_timer(xpd, "T3", &priv->t3, HFC_TIMER_T3);
+		} else {
+			XPD_DBG(SIGNAL, xpd,
+				"HFC_L1_ACTIVATE_TE (state %d, ignored)\n",
+				curr_state);
+		}
+	} else {	/* happen only because of T3 expiry */
+		switch (curr_state) {
+			case ST_TE_DEACTIVATED:		/* F3	*/
+			case ST_TE_SYNCED:		/* F6	*/

[... 13021 lines stripped ...]



More information about the zaptel-commits mailing list