4593896 [rkeene@sledge /home/rkeene/projects/build]$ cat dahdi.txt
# SHORT DESC: Zapata Telephony Driver
# LONG DESC: Zaptel is an open source telephony hardware driver API for various cards.

# Cleanup files that do not get managed
rm -f /lib/firmware/.zaptel-*

# Apply BRI D-Channel Patch
## http://updates.xorcom.com/astribank/bristuff/1.4/bristuff-current/patches/zaptel/bri_dchan
cat <<\__EOF__ > /tmp/bri_dchan-1tza.diff
# Translate the D channels to a standard channel data.
# The HFC chipset provides us the D channel as data, but
# Zaptel expects it as a standard channel with 1000 samples
# per second.

Index: zaptel-1.2.22/zaptel.h
===================================================================
--- zaptel-1.2.22.orig/zaptel.h	2007-12-04 10:40:30.000000000 +0100
+++ zaptel-1.2.22/zaptel.h	2007-12-04 14:35:14.545043151 +0100
@@ -1056,6 +1056,13 @@
 	int do_ppp_error;
 	struct sk_buff_head ppp_rq;
 #endif
+#ifdef CONFIG_ZAPATA_BRI_DCHANS
+	int bytes2receive;
+	int maxbytes2transmit; /* size of the tx buffer in the card driver */
+	int bytes2transmit;
+	int eofrx;
+	int eoftx;
+#endif
 	spinlock_t lock;
 	char name[40];		/* Name */
 	/* Specified by zaptel */
@@ -1294,6 +1301,10 @@
 #define ZT_FLAG_T1PPP			(1 << 15)
 #define ZT_FLAG_SIGFREEZE		(1 << 16)	/* Freeze signalling */
 
+#if defined(CONFIG_ZAPATA_BRI_DCHANS)
+#define ZT_FLAG_BRIDCHAN		(1 << 19)
+#endif
+
 struct zt_span {
 	spinlock_t lock;
 	void *pvt;			/* Private stuff */
Index: zaptel-1.2.22/zconfig.h
===================================================================
--- zaptel-1.2.22.orig/zconfig.h	2007-12-04 10:40:29.000000000 +0100
+++ zaptel-1.2.22/zconfig.h	2007-12-04 14:35:01.329541263 +0100
@@ -166,4 +166,10 @@
  */
 /* #define FXSFLASH */
 
+/*
+ * Uncomment the following for BRI D channels
+ *
+ */
+#define CONFIG_ZAPATA_BRI_DCHANS
+
 #endif
Index: zaptel-1.2.22/zaptel-base.c
===================================================================
--- zaptel-1.2.22.orig/zaptel-base.c	2007-12-04 10:40:31.000000000 +0100
+++ zaptel-1.2.22/zaptel-base.c	2007-12-04 14:35:14.553042850 +0100
@@ -5226,11 +5255,40 @@
 					*(txb++) = fasthdlc_tx_run_nocheck(&ms->txhdlc);
 				}
 				bytes -= left;
+#ifdef CONFIG_ZAPATA_BRI_DCHANS
+			} else if (ms->flags & ZT_FLAG_BRIDCHAN) {
+			    /*
+			     * Let's get this right, we want to transmit complete frames only.
+			     * The card driver will do the dirty HDLC work for us.
+			     * txb (transmit buffer) is supposed to be big enough to store one frame
+			     * we will make this as big as the D fifo (1KB or 2KB)
+			     */
+
+			    /* there are 'left' bytes in the user buffer left to transmit */
+			    left = ms->writen[ms->outwritebuf] - ms->writeidx[ms->outwritebuf] - 2;
+			    if (left > ms->maxbytes2transmit) {
+				memcpy(txb, buf + ms->writeidx[ms->outwritebuf], ms->maxbytes2transmit);
+				ms->writeidx[ms->outwritebuf] += ms->maxbytes2transmit;
+				txb += ms->maxbytes2transmit;
+				ms->bytes2transmit = ms->maxbytes2transmit;
+				ms->eoftx = 0;
+			    } else {
+				memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
+				ms->writeidx[ms->outwritebuf] += left + 2;
+				txb += left + 2;
+				ms->bytes2transmit = left;
+				ms->eoftx = 1;
+			    }
+			    bytes = 0;
+#endif
 			} else {
 				memcpy(txb, buf + ms->writeidx[ms->outwritebuf], left);
 				ms->writeidx[ms->outwritebuf]+=left;
 				txb += left;
 				bytes -= left;
+#if defined(CONFIG_ZAPATA_BRI_DCHANS)	
+				ms->bytes2transmit=ZT_CHUNKSIZE;
+#endif
 			}
 			/* Check buffer status */
 			if (ms->writeidx[ms->outwritebuf] >= ms->writen[ms->outwritebuf]) {
@@ -5275,6 +5333,17 @@
 				/* Transmit a flag if this is an HDLC channel */
 				if (ms->flags & ZT_FLAG_HDLC)
 					fasthdlc_tx_frame_nocheck(&ms->txhdlc);
+#if defined(CONFIG_ZAPATA_BRI_DCHANS)	
+				if(ms->flags & ZT_FLAG_BRIDCHAN) { 
+			//	    if (ms->bytes2transmit > 0) {
+					// txb += 2;
+					// ms->bytes2transmit -= 2;
+					bytes=0;
+					ms->eoftx = 1;
+//					printk(KERN_CRIT "zaptel EOF(%d) bytes2transmit %d\n",ms->eoftx,ms->bytes2transmit);
+			//	    }
+				}
+#endif
 #ifdef CONFIG_ZAPATA_NET
 				if (ms->flags & ZT_FLAG_NETDEV)
 					netif_wake_queue(ztchan_to_dev(ms));
@@ -5335,6 +5404,12 @@
 				memset(txb, 0xFF, bytes);
 			}
 			bytes = 0;
+#if defined(CONFIG_ZAPATA_BRI_DCHANS)	
+		} else if(ms->flags & ZT_FLAG_BRIDCHAN) { 
+		    ms->bytes2transmit = 0;
+		    ms->eoftx = 0;
+		    bytes = 0;
+#endif
 		} else {
 			memset(txb, ZT_LIN2X(0, ms), bytes);	/* Lastly we use silence on telephony channels */
 			bytes = 0;
@@ -6153,6 +6228,14 @@
 	int res;
 	int left, x;
 
+#if defined(CONFIG_ZAPATA_BRI_DCHANS)	
+	if (ms->flags & ZT_FLAG_BRIDCHAN) {
+	    bytes = ms->bytes2receive;
+	    if (bytes < 1) return;
+//	    printk(KERN_CRIT "bytes2receive %d\n",ms->bytes2receive);
+	}
+#endif
+
 	while(bytes) {
 #if defined(CONFIG_ZAPATA_NET)  || defined(CONFIG_ZAPATA_PPP)
 		skb = NULL;
@@ -6210,6 +6293,19 @@
 						}
 					}
 				}
+#ifdef CONFIG_ZAPATA_BRI_DCHANS
+			} else if (ms->flags & ZT_FLAG_BRIDCHAN) {
+			    memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
+			    rxb += left;
+			    ms->readidx[ms->inreadbuf] += left;
+			    bytes -= left;
+			    if (ms->eofrx == 1) {
+				eof=1;
+			    }
+//			    printk(KERN_CRIT "receiving %d bytes\n",ms->bytes2receive);
+			    ms->bytes2receive = 0;
+			    ms->eofrx = 0;
+#endif
 			} else {
 				/* Not HDLC */
 				memcpy(buf + ms->readidx[ms->inreadbuf], rxb, left);
__EOF__

# Apply BRI D-Channel Patch
(
	if echo "${pkgver}" | grep '^1\.4\.' >/dev/null; then
		cd kernel || exit 1
	fi

	patch -p1 < /tmp/bri_dchan-1tza.diff || exit 1

	rm -f /tmp/bri_dchan-1tza.diff

	exit 0
) || exit 1

./configure --prefix=/usr --libdir="${libdir}" --sysconfdir=/etc --localstatedir=/var || exit 1

COMPILE_KVERS=$(cat /usr/src/linux/include/config/kernel.release 2>/dev/null)
if [ -z "${COMPILE_KVERS}" ]; then
	eval $(grep -B30 '^KERNELRELEASE=' /usr/src/linux/Makefile | sed 's@ @@g;s@\$(@${@g;s@)@}@g') >/dev/null 2>/dev/null
	COMPILE_KVERS="${KERNELRELEASE}"
fi

if [ -z "${COMPILE_KVERS}" ] || echo "${COMPILE_KVERS}" | grep '^2\.4\.' >/dev/null; then
	echo ' *** We have LINUX 2.4 or unknown -- _NOT_ compiling kernel modules' "(kvers=${COMPILE_KVERS})"
	make KVERS="${COMPILE_KVERS}" programs || exit 1
	make KVERS="${COMPILE_KVERS}" install-programs || exit 1
else
	echo ' *** We have LINUX 2.6 or better -- compiling kernel modules' "(kvers=${COMPILE_KVERS})"

	rm -rf /etc/hotplug/usb

	make KVERS="${COMPILE_KVERS}" || exit 1
	make KVERS="${COMPILE_KVERS}" install || exit 1
	make KVERS="${COMPILE_KVERS}" UPDATE_RCD=true config || exit 1
fi

if [ -f /etc/init.d/zaptel ]; then
	# Fixups for broken Zaptel script
	sed 's@system=redhat@system=debian@g;s@^ *\. \$initdir@test -f $initdir/functions \&\& . $initdir@' /etc/init.d/zaptel > /tmp/zaptel.new
	cat /tmp/zaptel.new > /etc/init.d/zaptel
	rm -f /tmp/zaptel.new
fi

# Cleanup files that do not get managed
rm -f /lib/firmware/.zaptel-*

exit 0
4593897 [rkeene@sledge /home/rkeene/projects/build]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2012-05-07 00:52:05