[Asterisk-cvs] zaptel wcfxs.c,1.84.2.1,1.84.2.2

russell at lists.digium.com russell at lists.digium.com
Wed Jan 12 15:30:06 CST 2005


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

Modified Files:
      Tag: v1-0
	wcfxs.c 
Log Message:
remove prototypes and move static inline functions up to before they are used (bug #3320)


Index: wcfxs.c
===================================================================
RCS file: /usr/cvsroot/zaptel/Attic/wcfxs.c,v
retrieving revision 1.84.2.1
retrieving revision 1.84.2.2
diff -u -d -r1.84.2.1 -r1.84.2.2
--- wcfxs.c	9 Dec 2004 05:13:32 -0000	1.84.2.1
+++ wcfxs.c	12 Jan 2005 21:34:06 -0000	1.84.2.2
@@ -469,9 +469,7 @@
 	zt_receive(&wc->span);
 }
 
-static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card);
-static inline void wcfxs_proslic_check_hook(struct wcfxs *wc, int card);
-static inline void wcfxs_proslic_recheck_sanity(struct wcfxs *wc, int card);
+
 
 static void wcfxs_stop_dma(struct wcfxs *wc);
 static void wcfxs_reset_tdm(struct wcfxs *wc);
@@ -739,6 +737,229 @@
     return 0;
 }
 
+static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card)
+{
+#ifndef AUDIO_RINGCHECK
+	unsigned char res;
+#endif	
+	signed char b;
+	int poopy = 0;
+	/* Try to track issues that plague slot one FXO's */
+	b = wcfxs_getreg(wc, card, 5);
+	if ((b & 0x2) || !(b & 0x8)) {
+		/* Not good -- don't look at anything else */
+		if (debug)
+			printk("Poopy (%02x) on card %d!\n", b, card + 1); 
+		poopy++;
+	}
+	b &= 0x9b;
+	if (wc->mod.fxo.offhook[card]) {
+		if (b != 0x9)
+			wcfxs_setreg(wc, card, 5, 0x9);
+	} else {
+		if (b != 0x8)
+			wcfxs_setreg(wc, card, 5, 0x8);
+	}
+	if (poopy)
+		return;
+#ifndef AUDIO_RINGCHECK
+	if (!wc->mod.fxo.offhook[card]) {
+		res = wcfxs_getreg(wc, card, 5);
+		if ((res & 0x60) && wc->mod.fxo.battery[card]) {
+			wc->mod.fxo.ringdebounce[card] += (ZT_CHUNKSIZE * 4);
+			if (wc->mod.fxo.ringdebounce[card] >= ZT_CHUNKSIZE * 64) {
+				if (!wc->mod.fxo.wasringing[card]) {
+					wc->mod.fxo.wasringing[card] = 1;
+					zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
+					if (debug)
+						printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
+				}
+				wc->mod.fxo.ringdebounce[card] = ZT_CHUNKSIZE * 64;
+			}
+		} else {
+			wc->mod.fxo.ringdebounce[card] -= ZT_CHUNKSIZE;
+			if (wc->mod.fxo.ringdebounce[card] <= 0) {
+				if (wc->mod.fxo.wasringing[card]) {
+					wc->mod.fxo.wasringing[card] =0;
+					zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+					if (debug)
+						printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
+				}
+				wc->mod.fxo.ringdebounce[card] = 0;
+			}
+				
+		}
+	}
+#endif
+	b = wcfxs_getreg(wc, card, 29);
+#if 0 
+	{
+		static int count = 0;
+		if (!(count++ % 100)) {
+			printk("Card %d: Voltage: %d  Debounce %d\n", card + 1, 
+			       b, wc->mod.fxo.battdebounce[card]);
+		}
+	}
+#endif	
+	if (abs(b) < BATT_THRESH) {
+		wc->mod.fxo.nobatttimer[card]++;
+#if 0
+		if (wc->mod.fxo.battery[card])
+			printk("Battery loss: %d (%d debounce)\n", b, wc->mod.fxo.battdebounce[card]);
+#endif
+		if (wc->mod.fxo.battery[card] && !wc->mod.fxo.battdebounce[card]) {
+			if (debug)
+				printk("NO BATTERY on %d/%d!\n", wc->span.spanno, card + 1);
+			wc->mod.fxo.battery[card] =  0;
+#ifdef	JAPAN
+			if ((!wc->ohdebounce) && wc->offhook) {
+				zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
+				if (debug)
+					printk("Signalled On Hook\n");
+#ifdef	ZERO_BATT_RING
+				wc->onhook++;
+#endif
+			}
+#else
+			zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
+#endif
+			wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE;
+		} else if (!wc->mod.fxo.battery[card])
+			wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE;
+	} else if (abs(b) > BATT_THRESH) {
+		if (!wc->mod.fxo.battery[card] && !wc->mod.fxo.battdebounce[card]) {
+			if (debug)
+				printk("BATTERY on %d/%d (%s)!\n", wc->span.spanno, card + 1, 
+					(b < 0) ? "-" : "+");			    
+#ifdef	ZERO_BATT_RING
+			if (wc->onhook) {
+				wc->onhook = 0;
+				zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+				if (debug)
+					printk("Signalled Off Hook\n");
+			}
+#else
+			zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+#endif
+			wc->mod.fxo.battery[card] = 1;
+			wc->mod.fxo.nobatttimer[card] = 0;
+			wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE;
+		} else if (wc->mod.fxo.battery[card])
+			wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE;
+
+		if (wc->mod.fxo.lastpol[card] >= 0) {
+		    if (b < 0) {
+			wc->mod.fxo.lastpol[card] = -1;
+			wc->mod.fxo.polaritydebounce[card] = POLARITY_DEBOUNCE;
+		    }
+		} 
+		if (wc->mod.fxo.lastpol[card] <= 0) {
+		    if (b > 0) {
+			wc->mod.fxo.lastpol[card] = 1;
+			wc->mod.fxo.polaritydebounce[card] = POLARITY_DEBOUNCE;
+		    }
+		}
+	} else {
+		/* It's something else... */
+		wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE;
+	}
+	if (wc->mod.fxo.battdebounce[card])
+		wc->mod.fxo.battdebounce[card]--;
+	if (wc->mod.fxo.polaritydebounce[card]) {
+	        wc->mod.fxo.polaritydebounce[card]--;
+		if (wc->mod.fxo.polaritydebounce[card] < 1) {
+		    if (wc->mod.fxo.lastpol[card] != wc->mod.fxo.polarity[card]) {
+			if (debug)
+				printk("%lu Polarity reversed (%d -> %d)\n", jiffies, 
+			       wc->mod.fxo.polarity[card], 
+			       wc->mod.fxo.lastpol[card]);
+			if (wc->mod.fxo.polarity[card])
+			    zt_qevent_lock(&wc->chans[card], ZT_EVENT_POLARITY);
+			wc->mod.fxo.polarity[card] = wc->mod.fxo.lastpol[card];
+		    }
+		}
+	}
+}
+
+static inline void wcfxs_proslic_check_hook(struct wcfxs *wc, int card)
+{
+	char res;
+	int hook;
+
+	/* For some reason we have to debounce the
+	   hook detector.  */
+
+	res = wcfxs_getreg(wc, card, 68);
+	hook = (res & 1);
+	if (hook != wc->mod.fxs.lastrxhook[card]) {
+		/* Reset the debounce (must be multiple of 4ms) */
+		wc->mod.fxs.debounce[card] = 8 * (4 * 8);
+#if 0
+		printk("Resetting debounce card %d hook %d, %d\n", card, hook, wc->mod.fxs.debounce[card]);
+#endif
+	} else {
+		if (wc->mod.fxs.debounce[card] > 0) {
+			wc->mod.fxs.debounce[card]-= 4 * ZT_CHUNKSIZE;
+#if 0
+			printk("Sustaining hook %d, %d\n", hook, wc->mod.fxs.debounce[card]);
+#endif
+			if (!wc->mod.fxs.debounce[card]) {
+#if 0
+				printk("Counted down debounce, newhook: %d...\n", hook);
+#endif
+				wc->mod.fxs.debouncehook[card] = hook;
+			}
+			if (!wc->mod.fxs.oldrxhook[card] && wc->mod.fxs.debouncehook[card]) {
+				/* Off hook */
+#if 1
+				if (debug)
+#endif				
+					printk("wcfxs: Card %d Going off hook\n", card);
+				zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
+				if (robust)
+					wcfxs_init_proslic(wc, card, 1, 0, 1);
+				wc->mod.fxs.oldrxhook[card] = 1;
+			
+			} else if (wc->mod.fxs.oldrxhook[card] && !wc->mod.fxs.debouncehook[card]) {
+				/* On hook */
+#if 1
+				if (debug)
+#endif				
+					printk("wcfxs: Card %d Going on hook\n", card);
+				zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
+				wc->mod.fxs.oldrxhook[card] = 0;
+			}
+		}
+	}
+	wc->mod.fxs.lastrxhook[card] = hook;
+
+	
+}
+
+static inline void wcfxs_proslic_recheck_sanity(struct wcfxs *wc, int card)
+{
+	int res;
+	/* Check loopback */
+	res = wcfxs_getreg(wc, card, 8);
+	if (res) {
+		printk("Ouch, part reset, quickly restoring reality (%d)\n", card);
+		wcfxs_init_proslic(wc, card, 1, 0, 1);
+	} else {
+		res = wcfxs_getreg(wc, card, 64);
+		if (!res && (res != wc->mod.fxs.lasttxhook[card])) {
+			if (wc->mod.fxs.palarms[card]++ < MAX_ALARMS) {
+				printk("Power alarm on module %d, resetting!\n", card + 1);
+				if (wc->mod.fxs.lasttxhook[card] == 4)
+					wc->mod.fxs.lasttxhook[card] = 1;
+				wcfxs_setreg(wc, card, 64, wc->mod.fxs.lasttxhook[card]);
+			} else {
+				if (wc->mod.fxs.palarms[card] == MAX_ALARMS)
+					printk("Too many power alarms on card %d, NOT resetting!\n", card + 1);
+			}
+		}
+	}
+}
+
 #ifdef LINUX26
 static irqreturn_t wcfxs_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 #else
@@ -1356,229 +1577,6 @@
 	return 0;
 }
 
-static inline void wcfxs_proslic_recheck_sanity(struct wcfxs *wc, int card)
-{
-	int res;
-	/* Check loopback */
-	res = wcfxs_getreg(wc, card, 8);
-	if (res) {
-		printk("Ouch, part reset, quickly restoring reality (%d)\n", card);
-		wcfxs_init_proslic(wc, card, 1, 0, 1);
-	} else {
-		res = wcfxs_getreg(wc, card, 64);
-		if (!res && (res != wc->mod.fxs.lasttxhook[card])) {
-			if (wc->mod.fxs.palarms[card]++ < MAX_ALARMS) {
-				printk("Power alarm on module %d, resetting!\n", card + 1);
-				if (wc->mod.fxs.lasttxhook[card] == 4)
-					wc->mod.fxs.lasttxhook[card] = 1;
-				wcfxs_setreg(wc, card, 64, wc->mod.fxs.lasttxhook[card]);
-			} else {
-				if (wc->mod.fxs.palarms[card] == MAX_ALARMS)
-					printk("Too many power alarms on card %d, NOT resetting!\n", card + 1);
-			}
-		}
-	}
-}
-
-static inline void wcfxs_voicedaa_check_hook(struct wcfxs *wc, int card)
-{
-#ifndef AUDIO_RINGCHECK
-	unsigned char res;
-#endif	
-	signed char b;
-	int poopy = 0;
-	/* Try to track issues that plague slot one FXO's */
-	b = wcfxs_getreg(wc, card, 5);
-	if ((b & 0x2) || !(b & 0x8)) {
-		/* Not good -- don't look at anything else */
-		if (debug)
-			printk("Poopy (%02x) on card %d!\n", b, card + 1); 
-		poopy++;
-	}
-	b &= 0x9b;
-	if (wc->mod.fxo.offhook[card]) {
-		if (b != 0x9)
-			wcfxs_setreg(wc, card, 5, 0x9);
-	} else {
-		if (b != 0x8)
-			wcfxs_setreg(wc, card, 5, 0x8);
-	}
-	if (poopy)
-		return;
-#ifndef AUDIO_RINGCHECK
-	if (!wc->mod.fxo.offhook[card]) {
-		res = wcfxs_getreg(wc, card, 5);
-		if ((res & 0x60) && wc->mod.fxo.battery[card]) {
-			wc->mod.fxo.ringdebounce[card] += (ZT_CHUNKSIZE * 4);
-			if (wc->mod.fxo.ringdebounce[card] >= ZT_CHUNKSIZE * 64) {
-				if (!wc->mod.fxo.wasringing[card]) {
-					wc->mod.fxo.wasringing[card] = 1;
-					zt_hooksig(&wc->chans[card], ZT_RXSIG_RING);
-					if (debug)
-						printk("RING on %d/%d!\n", wc->span.spanno, card + 1);
-				}
-				wc->mod.fxo.ringdebounce[card] = ZT_CHUNKSIZE * 64;
-			}
-		} else {
-			wc->mod.fxo.ringdebounce[card] -= ZT_CHUNKSIZE;
-			if (wc->mod.fxo.ringdebounce[card] <= 0) {
-				if (wc->mod.fxo.wasringing[card]) {
-					wc->mod.fxo.wasringing[card] =0;
-					zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
-					if (debug)
-						printk("NO RING on %d/%d!\n", wc->span.spanno, card + 1);
-				}
-				wc->mod.fxo.ringdebounce[card] = 0;
-			}
-				
-		}
-	}
-#endif
-	b = wcfxs_getreg(wc, card, 29);
-#if 0 
-	{
-		static int count = 0;
-		if (!(count++ % 100)) {
-			printk("Card %d: Voltage: %d  Debounce %d\n", card + 1, 
-			       b, wc->mod.fxo.battdebounce[card]);
-		}
-	}
-#endif	
-	if (abs(b) < BATT_THRESH) {
-		wc->mod.fxo.nobatttimer[card]++;
-#if 0
-		if (wc->mod.fxo.battery[card])
-			printk("Battery loss: %d (%d debounce)\n", b, wc->mod.fxo.battdebounce[card]);
-#endif
-		if (wc->mod.fxo.battery[card] && !wc->mod.fxo.battdebounce[card]) {
-			if (debug)
-				printk("NO BATTERY on %d/%d!\n", wc->span.spanno, card + 1);
-			wc->mod.fxo.battery[card] =  0;
-#ifdef	JAPAN
-			if ((!wc->ohdebounce) && wc->offhook) {
-				zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
-				if (debug)
-					printk("Signalled On Hook\n");
-#ifdef	ZERO_BATT_RING
-				wc->onhook++;
-#endif
-			}
-#else
-			zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
-#endif
-			wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE;
-		} else if (!wc->mod.fxo.battery[card])
-			wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE;
-	} else if (abs(b) > BATT_THRESH) {
-		if (!wc->mod.fxo.battery[card] && !wc->mod.fxo.battdebounce[card]) {
-			if (debug)
-				printk("BATTERY on %d/%d (%s)!\n", wc->span.spanno, card + 1, 
-					(b < 0) ? "-" : "+");			    
-#ifdef	ZERO_BATT_RING
-			if (wc->onhook) {
-				wc->onhook = 0;
-				zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
-				if (debug)
-					printk("Signalled Off Hook\n");
-			}
-#else
-			zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
-#endif
-			wc->mod.fxo.battery[card] = 1;
-			wc->mod.fxo.nobatttimer[card] = 0;
-			wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE;
-		} else if (wc->mod.fxo.battery[card])
-			wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE;
-
-		if (wc->mod.fxo.lastpol[card] >= 0) {
-		    if (b < 0) {
-			wc->mod.fxo.lastpol[card] = -1;
-			wc->mod.fxo.polaritydebounce[card] = POLARITY_DEBOUNCE;
-		    }
-		} 
-		if (wc->mod.fxo.lastpol[card] <= 0) {
-		    if (b > 0) {
-			wc->mod.fxo.lastpol[card] = 1;
-			wc->mod.fxo.polaritydebounce[card] = POLARITY_DEBOUNCE;
-		    }
-		}
-	} else {
-		/* It's something else... */
-		wc->mod.fxo.battdebounce[card] = BATT_DEBOUNCE;
-	}
-	if (wc->mod.fxo.battdebounce[card])
-		wc->mod.fxo.battdebounce[card]--;
-	if (wc->mod.fxo.polaritydebounce[card]) {
-	        wc->mod.fxo.polaritydebounce[card]--;
-		if (wc->mod.fxo.polaritydebounce[card] < 1) {
-		    if (wc->mod.fxo.lastpol[card] != wc->mod.fxo.polarity[card]) {
-			if (debug)
-				printk("%lu Polarity reversed (%d -> %d)\n", jiffies, 
-			       wc->mod.fxo.polarity[card], 
-			       wc->mod.fxo.lastpol[card]);
-			if (wc->mod.fxo.polarity[card])
-			    zt_qevent_lock(&wc->chans[card], ZT_EVENT_POLARITY);
-			wc->mod.fxo.polarity[card] = wc->mod.fxo.lastpol[card];
-		    }
-		}
-	}
-}
-
-static inline void wcfxs_proslic_check_hook(struct wcfxs *wc, int card)
-{
-	char res;
-	int hook;
-
-	/* For some reason we have to debounce the
-	   hook detector.  */
-
-	res = wcfxs_getreg(wc, card, 68);
-	hook = (res & 1);
-	if (hook != wc->mod.fxs.lastrxhook[card]) {
-		/* Reset the debounce (must be multiple of 4ms) */
-		wc->mod.fxs.debounce[card] = 8 * (4 * 8);
-#if 0
-		printk("Resetting debounce card %d hook %d, %d\n", card, hook, wc->mod.fxs.debounce[card]);
-#endif
-	} else {
-		if (wc->mod.fxs.debounce[card] > 0) {
-			wc->mod.fxs.debounce[card]-= 4 * ZT_CHUNKSIZE;
-#if 0
-			printk("Sustaining hook %d, %d\n", hook, wc->mod.fxs.debounce[card]);
-#endif
-			if (!wc->mod.fxs.debounce[card]) {
-#if 0
-				printk("Counted down debounce, newhook: %d...\n", hook);
-#endif
-				wc->mod.fxs.debouncehook[card] = hook;
-			}
-			if (!wc->mod.fxs.oldrxhook[card] && wc->mod.fxs.debouncehook[card]) {
-				/* Off hook */
-#if 1
-				if (debug)
-#endif				
-					printk("wcfxs: Card %d Going off hook\n", card);
-				zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
-				if (robust)
-					wcfxs_init_proslic(wc, card, 1, 0, 1);
-				wc->mod.fxs.oldrxhook[card] = 1;
-			
-			} else if (wc->mod.fxs.oldrxhook[card] && !wc->mod.fxs.debouncehook[card]) {
-				/* On hook */
-#if 1
-				if (debug)
-#endif				
-					printk("wcfxs: Card %d Going on hook\n", card);
-				zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
-				wc->mod.fxs.oldrxhook[card] = 0;
-			}
-		}
-	}
-	wc->mod.fxs.lastrxhook[card] = hook;
-
-	
-}
-
 static int wcfxs_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long data)
 {
 	struct wcfxs_stats stats;




More information about the svn-commits mailing list