[zaptel-commits] tzafrir: trunk r1388 - in /trunk/xpp: card_fxo.c xpp_zap.c xpp_zap.h

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Mon Sep 4 15:44:10 MST 2006


Author: tzafrir
Date: Mon Sep  4 17:44:10 2006
New Revision: 1388

URL: http://svn.digium.com/view/zaptel?rev=1388&view=rev
Log:
Send ring signalling to zaptel directly from card_fxo.c:
no need to xpp_ring_generate()

Modified:
    trunk/xpp/card_fxo.c
    trunk/xpp/xpp_zap.c
    trunk/xpp/xpp_zap.h

Modified: trunk/xpp/card_fxo.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/card_fxo.c?rev=1388&r1=1387&r2=1388&view=diff
==============================================================================
--- trunk/xpp/card_fxo.c (original)
+++ trunk/xpp/card_fxo.c Mon Sep  4 17:44:10 2006
@@ -204,11 +204,13 @@
 		DBG("%s/%s/%d: START\n", xpd->xbus->busname, xpd->xpdname, pos);
 		xpd->ringing[pos] = 1;
 		MARK_BLINK(priv, pos, LED_GREEN, LED_BLINK);
+		update_zap_ring(xpd, pos, 1);
 	} else if(!on && xpd->ringing[pos]) {
 		DBG("%s/%s/%d: STOP\n", xpd->xbus->busname, xpd->xpdname, pos);
 		xpd->ringing[pos] = 0;
 		if(IS_BLINKING(priv, pos, LED_GREEN))
 			MARK_BLINK(priv, pos, LED_GREEN, 0);
+		update_zap_ring(xpd, pos, 0);
 	}
 }
 

Modified: trunk/xpp/xpp_zap.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/xpp_zap.c?rev=1388&r1=1387&r2=1388&view=diff
==============================================================================
--- trunk/xpp/xpp_zap.c (original)
+++ trunk/xpp/xpp_zap.c Mon Sep  4 17:44:10 2006
@@ -79,7 +79,6 @@
 
 static int zaptel_register_xpd(xpd_t *xpd);
 static int zaptel_unregister_xpd(xpd_t *xpd);
-static void xpp_ring_generate(xpd_t *xpd);
 static void xpp_transmitprep(xpd_t *xpd);
 static void xpp_receiveprep(xpd_t *xpd);
 static int xpd_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data);
@@ -178,8 +177,6 @@
 			CALL_XMETHOD(card_tick, xbus, xpd);
 			if(!SPAN_REGISTERED(xpd))
 				continue;
-			if(xpd->direction == TO_PSTN)
-				xpp_ring_generate(xpd);
 			xpp_transmitprep(xpd);
 			xpp_receiveprep(xpd);
 		}
@@ -638,43 +635,18 @@
 
 #define	RING_TIME	15	/* in ticks */
 
-static void xpp_ring_generate(xpd_t *xpd)
-{
-	int		i;
-	static int	bug_counter = 0;
-	unsigned long	flags;
+void update_zap_ring(xpd_t *xpd, int pos, bool on)
+{
+	struct zt_chan	*chan;
 
 	BUG_ON(!xpd);
-
-	spin_lock_irqsave(&xpd->lock, flags);
-	if(xpd->direction != TO_PSTN && ((bug_counter++ % 1000) == 0)) {
-		ERR("%s: %s: Only FXO can report ring changes\n", __FUNCTION__, xpd->xpdname);
-		goto out;
-	}
-	if(!SPAN_REGISTERED(xpd)) {
-		NOTICE("%s: %s is not registered. Skipping.\n", __FUNCTION__, xpd->xpdname);
-		goto out;
-	}
-	/*
-	 * Ring detect logic:
-	 * 	fxo_power is toggled
-	 */
-	for_each_line(xpd, i) {
-		if(xpd->ringing[i] || xpd->ringer_on[i]) {
-			// ring state is only changed once per second:
-			if((xpd->timer_count % RING_TIME) == 0) {
-				DBG("pos=%d ringing=%d ringer_on=%d\n", i, xpd->ringing[i], xpd->ringer_on[i]);
-				if(xpd->ringer_on[i]) {
-					zt_hooksig(&xpd->chans[i], ZT_RXSIG_OFFHOOK);
-				} else {
-					zt_hooksig(&xpd->chans[i], ZT_RXSIG_RING);
-				}
-				xpd->ringer_on[i] = !xpd->ringer_on[i];
-			}
-		}
-	}
-out:
-	spin_unlock_irqrestore(&xpd->lock, flags);
+	if(!SPAN_REGISTERED(xpd))
+		return;
+	chan = &xpd->chans[pos];
+	if(on)
+		zt_hooksig(chan, ZT_RXSIG_RING);
+	else
+		zt_hooksig(chan, ZT_RXSIG_OFFHOOK);
 }
 
 #ifdef CONFIG_PROC_FS
@@ -1583,6 +1555,7 @@
 EXPORT_SYMBOL(xpd_disconnect);
 EXPORT_SYMBOL(packet_send);
 EXPORT_SYMBOL(update_xpd_status);
+EXPORT_SYMBOL(update_zap_ring);
 EXPORT_SYMBOL(update_line_status);
 EXPORT_SYMBOL(fill_beep);
 EXPORT_SYMBOL(xpp_tick);

Modified: trunk/xpp/xpp_zap.h
URL: http://svn.digium.com/view/zaptel/trunk/xpp/xpp_zap.h?rev=1388&r1=1387&r2=1388&view=diff
==============================================================================
--- trunk/xpp/xpp_zap.h (original)
+++ trunk/xpp/xpp_zap.h Mon Sep  4 17:44:10 2006
@@ -32,6 +32,7 @@
 xpd_t *xpd_alloc(size_t privsize, xbus_t *xbus, int xpd_num, const xproto_table_t *proto_table, int channels, byte revision);
 void xpd_remove(xpd_t *xpd);
 void update_xpd_status(xpd_t *xpd, int alarm_flag);
+void update_zap_ring(xpd_t *xpd, int pos, bool on);
 void update_line_status(xpd_t *xpd, int pos, bool good);
 void fill_beep(u_char *buf, int duration);
 void xpp_tick(unsigned long param);



More information about the zaptel-commits mailing list