[Asterisk-cvs] zaptel wcfxs.c,1.44,1.45 zaptel.c,1.63,1.64

markster at lists.digium.com markster at lists.digium.com
Thu Apr 8 04:03:15 CDT 2004


Update of /usr/cvsroot/zaptel
In directory mongoose.digium.com:/tmp/cvs-serv6207

Modified Files:
	wcfxs.c zaptel.c 
Log Message:
Ringing/battery enhancements and fix detect onhook during debounce when debounce is over.


Index: wcfxs.c
===================================================================
RCS file: /usr/cvsroot/zaptel/wcfxs.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- wcfxs.c	8 Apr 2004 07:03:40 -0000	1.44
+++ wcfxs.c	8 Apr 2004 08:04:05 -0000	1.45
@@ -175,13 +175,13 @@
 			int pegcount[NUM_CARDS];
 			int peg[NUM_CARDS];
 			int ring[NUM_CARDS];
-			int ringdebounce[NUM_CARDS];
+#else			
+			int wasringing[NUM_CARDS];
 #endif			
+			int ringdebounce[NUM_CARDS];
 			int offhook[NUM_CARDS];
-			int wasringing[NUM_CARDS];
 			int battdebounce[NUM_CARDS];
 			int nobatttimer[NUM_CARDS];
-			int ringdebounce[NUM_CARDS];
 			int battery[NUM_CARDS];
 		} fxo;
 		struct {
@@ -1186,32 +1186,47 @@
 
 static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card)
 {
-	unsigned char res, b;
+	unsigned char res;
+	signed char b;
+#ifndef AUDIO_RINGCHECK
 	if (!wc->fxo.offhook[card]) {
 		res = wcfxs_getreg(wc, card, 5);
 		if (res & 0x60) {
-			if (!wc->fxo.wasringing[card]) {
-				zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
-				if (debug)
-					printk("RING!\n");
+			wc->fxo.ringdebounce[card] += (ZT_CHUNKSIZE * 4);
+			if (wc->fxo.ringdebounce[card] >= ZT_CHUNKSIZE * 32) {
+				if (!wc->fxo.wasringing[card]) {
+					wc->fxo.wasringing[card] = 1;
+					zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
+					if (debug)
+						printk("RING!\n");
+				}
+				wc->fxo.ringdebounce[card] = ZT_CHUNKSIZE * 32;
 			}
-			wc->fxo.wasringing[card] = 100 * 8;
 		} else {
-			if (wc->fxo.wasringing[card]) {
-				wc->fxo.wasringing[card] -= ZT_CHUNKSIZE;
-				if (wc->fxo.wasringing[card] < 0)
-					wc->fxo.wasringing[card] = 0;
-				if (!wc->fxo.wasringing[card]) {
+			wc->fxo.ringdebounce[card] -= ZT_CHUNKSIZE;
+			if (wc->fxo.ringdebounce[card] <= 0) {
+				if (wc->fxo.wasringing[card]) {
+					wc->fxo.wasringing[card] =0;
 					zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
 					if (debug)
 						printk("NO RING!\n");
 				}
+				wc->fxo.ringdebounce[card] = 0;
 			}
 				
 		}
 	}
-	b = wcfxs_getreg(wc, card, 12) & 0x1f;
-	if (!b) {
+#endif
+	b = wcfxs_getreg(wc, card, 29);
+#if 0
+	{
+		static int count = 0;
+		if (!(count++ % 100)) {
+			printk("Voltage: %d\n", b);
+		}
+	}
+#endif	
+	if (abs(b) < 2) {
 		wc->fxo.nobatttimer[card]++;
 #if 0
 		if (wc->fxo.battery[card])
@@ -1236,7 +1251,7 @@
 			wc->fxo.battdebounce[card] = BATT_DEBOUNCE;
 		} else if (!wc->fxo.battery[card])
 			wc->fxo.battdebounce[card] = BATT_DEBOUNCE;
-	} else if (b >= 0x40) {
+	} else if (abs(b) > 1) {
 		if (!wc->fxo.battery[card] && !wc->fxo.battdebounce[card]) {
 			if (debug)
 				printk("BATTERY!\n");

Index: zaptel.c
===================================================================
RCS file: /usr/cvsroot/zaptel/zaptel.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- zaptel.c	19 Mar 2004 04:44:03 -0000	1.63
+++ zaptel.c	8 Apr 2004 08:04:05 -0000	1.64
@@ -4750,6 +4750,9 @@
 	
 	case ZT_TXSTATE_DEBOUNCE:
 		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->itimerset = chan->itimer = chan->rxflashtime * 8;
 		wake_up_interruptible(&chan->txstateq);
 		break;
 		




More information about the svn-commits mailing list