diff -u zaptel-1.2.19-origin/Makefile zaptel-1.2.19-hack/Makefile --- zaptel-1.2.19-origin/Makefile 2007-07-12 20:01:12.000000000 +0400 +++ zaptel-1.2.19-hack/Makefile 2007-07-22 10:46:40.000000000 +0400 @@ -63,7 +63,16 @@ MODULESKO:=$(MODULES:%=%.ko) # add this later, so it doesn't become part of MODULESO/MODULESKO -MODULES+=wct4xxp wctc4xxp +MODULES+=wctc4xxp + +ifndef ZT_CHUNKSIZE +ZT_CHUNKSIZE:=$(shell cat zaptel.h | grep 'define ZT_CHUNKSIZE' | sed 's/[^0-9]*\([0-9]\+\)[^0-9]*/\1/') +endif + +ifeq ($(ZT_CHUNKSIZE),8) +MODULES+=wct4xxp +WCT4XXP+=wct4xxp/wct4xxp.o +endif ifeq ($(ARCH),i386) ifneq ($(wildcard $(PWD)/hpec/hpec_x86_32.o_shipped),) @@ -183,7 +192,7 @@ MAN_PAGES = $(MAN_PAGES_BASE:%=doc/%.8) ifeq ($(BUILDVER),linux24) -all: prereq $(MODULESO) wct4xxp/wct4xxp.o $(BINS) $(LIBTONEZONE_SO) +all: prereq $(MODULESO) $(WCT4XXP) $(BINS) $(LIBTONEZONE_SO) endif ifeq ($(BUILDVER),linux26) @@ -212,8 +221,10 @@ fi @rm -f $@.tmp +ifdef WCT4XXP wct4xxp/wct4xxp.o: $(MAKE) -C wct4xxp KFLAGS="$(KFLAGS) -I.." CFLAGS="$(CFLAGS) -I.." +endif devel: tor2ee @@ -400,7 +411,7 @@ done; \ $(KMAKE_INST); else - for x in $(MODULESO) wct4xxp/wct4xxp.o; do \ + for x in $(MODULESO) $(WCT4XXP); do \ install -D -m 644 $$x $(INSTALL_PREFIX)/lib/modules/$(KVERS)/misc/$$x ; \ done; @@ -434,11 +445,15 @@ firmware: ifeq ($(HOTPLUG_FIRMWARE),yes) if [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ]; then \ +ifdef WCT4XXP install -m 644 wct4xxp/*.ima $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \ +endif install -m 644 wctc4xxp/*.bin $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \ fi if [ -d $(INSTALL_PREFIX)/lib/firmware ]; then \ +ifdef WCT4XXP install -m 644 wct4xxp/*.ima $(INSTALL_PREFIX)/lib/firmware; \ +endif install -m 644 wctc4xxp/*.bin $(INSTALL_PREFIX)/lib/firmware; \ fi @echo "Installed firmware" @@ -492,7 +507,9 @@ rm -f *.o ztcfg tzdriver sethdlc sethdlc-new rm -f $(TZOBJS) $(LIBTONEZONE_SO) *.lo $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) clean +ifdef WCT4XXP $(MAKE) -C wct4xxp clean +endif $(MAKE) -C wctc4xxp clean rm -rf .tmp_versions rm -f gendigits tones.h diff -u zaptel-1.2.19-origin/Makefile.kernel26 zaptel-1.2.19-hack/Makefile.kernel26 --- zaptel-1.2.19-origin/Makefile.kernel26 2007-02-08 21:13:41.000000000 +0300 +++ zaptel-1.2.19-hack/Makefile.kernel26 2007-07-22 10:44:15.000000000 +0400 @@ -1,5 +1,9 @@ obj-m := $(MODULESO) -obj-m += wct4xxp/ wctc4xxp/ +obj-m += wctc4xxp/ + +ifdef WCT4XXP +obj-m += wct4xxp/ +endif # Also build xpp in the subdirectory xpp/ . But only for >=2.6.8 and only # for i386 or x86_64. On other platforms it has still not been tested well diff -u zaptel-1.2.19-origin/zaptel-base.c zaptel-1.2.19-hack/zaptel-base.c --- zaptel-1.2.19-origin/zaptel-base.c 2007-07-05 22:08:53.000000000 +0400 +++ zaptel-1.2.19-hack/zaptel-base.c 2007-07-22 09:17:48.000000000 +0400 @@ -1978,7 +1978,7 @@ set_txtone(chan,0,0,0); } } - chan->otimer = timeout * ZT_CHUNKSIZE; /* Otimer is timer in samples */ + chan->otimer = timeout; /* Otimer is timer in ms */ return; } if (chan->span->hooksig) { @@ -1986,7 +1986,7 @@ chan->txhooksig = txsig; chan->span->hooksig(chan, txsig); } - chan->otimer = timeout * ZT_CHUNKSIZE; /* Otimer is timer in samples */ + chan->otimer = timeout; /* Otimer is timer in ms */ return; } else { for (x=0;xtxhooksig = txsig; chan->txsig = outs[x][txsig+1]; chan->span->rbsbits(chan, chan->txsig); - chan->otimer = timeout * ZT_CHUNKSIZE; /* Otimer is timer in samples */ + chan->otimer = timeout; /* Otimer is timer in ms */ return; } } @@ -3501,7 +3501,7 @@ break; case ZT_MAINT_LOOPUP: case ZT_MAINT_LOOPDOWN: - spans[maint.spanno]->mainttimer = ZT_LOOPCODE_TIME * ZT_CHUNKSIZE; + spans[maint.spanno]->mainttimer = ZT_LOOPCODE_TIME; /* in ms */ rv = spans[maint.spanno]->maint(spans[maint.spanno], maint.command); spin_unlock_irqrestore(&spans[maint.spanno]->lock, flags); if (rv) return rv; @@ -5320,7 +5320,7 @@ zt_rbs_sethook(chan, ZT_TXSIG_OFFHOOK, ZT_TXSTATE_OFFHOOK, 0); /* See if we've gone back on hook */ if ((chan->rxhooksig == ZT_RXSIG_ONHOOK) && (chan->rxflashtime > 2)) - chan->itimerset = chan->itimer = chan->rxflashtime * ZT_CHUNKSIZE; + chan->itimerset = chan->itimer = chan->rxflashtime; /* in ms */ wake_up_interruptible(&chan->txstateq); break; @@ -5362,7 +5362,7 @@ break; } chan->txstate = ZT_TXSTATE_PULSEAFTER; - chan->otimer = chan->pulseaftertime * ZT_CHUNKSIZE; + chan->otimer = chan->pulseaftertime; /* in ms */ wake_up_interruptible(&chan->txstateq); break; @@ -5408,7 +5408,7 @@ } #endif /* set wink timer */ - chan->itimerset = chan->itimer = chan->rxwinktime * ZT_CHUNKSIZE; + chan->itimerset = chan->itimer = chan->rxwinktime; /* in ms */ break; case ZT_RXSIG_ONHOOK: /* went on hook */ /* This interface is now going on hook. @@ -5417,7 +5417,7 @@ __qevent(chan,ZT_EVENT_WINKFLASH); #ifdef EMFLASH else { - chan->itimerset = chan->itimer = chan->rxflashtime * ZT_CHUNKSIZE; + chan->itimerset = chan->itimer = chan->rxflashtime; /* in ms */ chan->gotgs = 0; break; } @@ -5438,12 +5438,12 @@ if (chan->txstate != ZT_TXSTATE_OFFHOOK) break; #ifdef FXSFLASH if (rxsig == ZT_RXSIG_ONHOOK) { - chan->itimer = ZT_FXSFLASHMAXTIME * ZT_CHUNKSIZE; + chan->itimer = ZT_FXSFLASHMAXTIME; /* in ms */ break; } else if (rxsig == ZT_RXSIG_OFFHOOK) { if (chan->itimer) { /* did the offhook occur in the window? if not, ignore both events */ - if (chan->itimer <= ((ZT_FXSFLASHMAXTIME - ZT_FXSFLASHMINTIME) * ZT_CHUNKSIZE)) + if (chan->itimer <= (ZT_FXSFLASHMAXTIME - ZT_FXSFLASHMINTIME)) /* in ms */ __qevent(chan, ZT_EVENT_WINKFLASH); } chan->itimer = 0; @@ -5512,7 +5512,7 @@ if ((chan->txstate != ZT_TXSTATE_DEBOUNCE) && (chan->txstate != ZT_TXSTATE_KEWL) && (chan->txstate != ZT_TXSTATE_AFTERKEWL)) { - chan->itimerset = chan->itimer = chan->rxflashtime * ZT_CHUNKSIZE; + chan->itimerset = chan->itimer = chan->rxflashtime; /* in ms */ } if (chan->txstate == ZT_TXSTATE_KEWL) chan->kewlonhook = 1; @@ -5616,7 +5616,8 @@ rxlin = ZT_XLAW(rxchunk[x], ss); txlin = ZT_XLAW(txchunk[x], ss); if (ss->echostate == ECHO_STATE_PRETRAINING) { - if (--ss->echotimer <= 0) { + ss->echotimer -= ZT_CHUNKTIME; + if (ss->echotimer <= 0) { ss->echotimer = 0; ss->echostate = ECHO_STATE_STARTTRAINING; } @@ -5734,7 +5735,7 @@ int x,r; if (ms->dialing) ms->afterdialingtimer = 50; - else if (ms->afterdialingtimer) ms->afterdialingtimer--; + else if (ms->afterdialingtimer) ms->afterdialingtimer -= ZT_CHUNKTIME; if (ms->afterdialingtimer && (!(ms->flags & ZT_FLAG_PSEUDO))) { /* Be careful since memset is likely a macro */ rxb[0] = ZT_LIN2X(0, ms); @@ -6473,7 +6474,7 @@ spin_lock_irqsave(&span->chans[x].lock, flags); if (&span->chans[x] == span->chans[x].master) { if (span->chans[x].otimer) { - span->chans[x].otimer -= ZT_CHUNKSIZE; + span->chans[x].otimer -= ZT_CHUNKTIME; if (span->chans[x].otimer <= 0) { __rbs_otimer_expire(&span->chans[x]); } @@ -6517,7 +6518,7 @@ spin_unlock_irqrestore(&span->chans[x].lock, flags); } if (span->mainttimer) { - span->mainttimer -= ZT_CHUNKSIZE; + span->mainttimer -= ZT_CHUNKTIME; if (span->mainttimer <= 0) { span->mainttimer = 0; if (span->maint) @@ -6563,18 +6564,18 @@ __zt_real_receive(&span->chans[x]); } if (span->chans[x].itimer) { - span->chans[x].itimer -= ZT_CHUNKSIZE; + span->chans[x].itimer -= ZT_CHUNKTIME; if (span->chans[x].itimer <= 0) { rbs_itimer_expire(&span->chans[x]); } } if (span->chans[x].ringdebtimer) - span->chans[x].ringdebtimer--; + span->chans[x].ringdebtimer -= ZT_CHUNKTIME; if (span->chans[x].sig & __ZT_SIG_FXS) { if (span->chans[x].rxhooksig == ZT_RXSIG_RING) span->chans[x].ringtrailer = ZT_RINGTRAILER; else if (span->chans[x].ringtrailer) { - span->chans[x].ringtrailer-= ZT_CHUNKSIZE; + span->chans[x].ringtrailer -= ZT_CHUNKTIME; /* See if RING trailer is expired */ if (!span->chans[x].ringtrailer && !span->chans[x].ringdebtimer) __qevent(&span->chans[x],ZT_EVENT_RINGOFFHOOK); @@ -6582,7 +6583,7 @@ } if (span->chans[x].pulsetimer) { - span->chans[x].pulsetimer--; + span->chans[x].pulsetimer -= ZT_CHUNKTIME; if (span->chans[x].pulsetimer <= 0) { if (span->chans[x].pulsecount) diff -u zaptel-1.2.19-origin/zaptel.h zaptel-1.2.19-hack/zaptel.h --- zaptel-1.2.19-origin/zaptel.h 2007-04-24 22:33:29.000000000 +0400 +++ zaptel-1.2.19-hack/zaptel.h 2007-07-22 10:45:15.000000000 +0400 @@ -146,10 +146,11 @@ #define ZT_CODE 'J' -/* Default chunk size for conferences and such -- static right now, might make - variable sometime. 8 samples = 1 ms = most frequent service interval possible - for a USB device */ +/* Default chunk size for conferences and such. + * 8 samples = 1 ms = most frequent service interval possible for a USB device + */ #define ZT_CHUNKSIZE 8 +#define ZT_CHUNKTIME (ZT_CHUNKSIZE / 8) /* 8kHz */ #define ZT_MIN_CHUNKSIZE ZT_CHUNKSIZE #define ZT_DEFAULT_CHUNKSIZE ZT_CHUNKSIZE #define ZT_MAX_CHUNKSIZE ZT_CHUNKSIZE @@ -946,11 +947,11 @@ #define ZT_DEFAULT_PULSEBREAKTIME 50 /* 50 ms of line open when dial pulsing */ #define ZT_DEFAULT_PULSEAFTERTIME 750 /* 750ms between dial pulse digits */ -#define ZT_MINPULSETIME (15 * 8) /* 15 ms minimum */ -#define ZT_MAXPULSETIME (200 * 8) /* 200 ms maximum */ -#define ZT_PULSETIMEOUT ((ZT_MAXPULSETIME / 8) + 50) +#define ZT_MINPULSETIME 15 /* 15 ms minimum */ +#define ZT_MAXPULSETIME 200 /* 200 ms maximum */ +#define ZT_PULSETIMEOUT (ZT_MAXPULSETIME + 50) /* in ms */ -#define ZT_RINGTRAILER (50 * 8) /* Don't consider a ring "over" until it's been gone at least this +#define ZT_RINGTRAILER 50 /* in ms, don't consider a ring "over" until it's been gone at least this much time */ #define ZT_LOOPCODE_TIME 10000 /* send loop codes for 10 secs */