[zaptel-commits] tzafrir: trunk r1285 - in /trunk/xpp: Makefile
card_fxo.c xpp_zap.c
zaptel-commits at lists.digium.com
zaptel-commits at lists.digium.com
Wed Aug 9 20:12:26 MST 2006
Author: tzafrir
Date: Wed Aug 9 22:12:25 2006
New Revision: 1285
URL: http://svn.digium.com/view/zaptel?rev=1285&view=rev
Log:
* New SOFT_RING detection in FXO:
- Poll register 0x05 on each DAA
- When enough energy (value of 0x20|0x40 occurs enough times), raise
the ringing[] flag.
- When the value show no energy, lower the ringing[] flag.
- When we get SIG_CHANGED of stop ringing -- stop polling.
* More debugging messages for proc files
Modified:
trunk/xpp/Makefile
trunk/xpp/card_fxo.c
trunk/xpp/xpp_zap.c
Modified: trunk/xpp/Makefile
URL: http://svn.digium.com/view/zaptel/trunk/xpp/Makefile?rev=1285&r1=1284&r2=1285&view=diff
==============================================================================
--- trunk/xpp/Makefile (original)
+++ trunk/xpp/Makefile Wed Aug 9 22:12:25 2006
@@ -1,4 +1,4 @@
-EXTRA_CFLAGS = -I$(SUBDIRS) -DDEBUG -DPOLL_DIGITAL_INPUTS -DWITH_ECHO_SUPPRESSION -DWITH_RBS
+EXTRA_CFLAGS = -I$(SUBDIRS) -DDEBUG -DPOLL_DIGITAL_INPUTS -DWITH_ECHO_SUPPRESSION -DWITH_RBS -DSOFT_RING
obj-m = xpp.o xpp_usb.o xpd_fxs.o xpd_fxo.o
xpp-y += xbus-core.o xpp_zap.o xproto.o card_global.o
Modified: trunk/xpp/card_fxo.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/card_fxo.c?rev=1285&r1=1284&r2=1285&view=diff
==============================================================================
--- trunk/xpp/card_fxo.c (original)
+++ trunk/xpp/card_fxo.c Wed Aug 9 22:12:25 2006
@@ -70,6 +70,12 @@
#define PROC_DAA_FNAME "slics"
#define PROC_FXO_INFO_FNAME "fxo_info"
+#ifdef SOFT_RING
+#define POLL_RING_INTERVAL 1
+#define RING_THRESHOLD 5
+#define DAA_RING_REGISTER 0x05
+#endif
+
struct FXO_priv_data {
struct proc_dir_entry *xpd_slic;
struct proc_dir_entry *fxo_info;
@@ -79,6 +85,9 @@
xpp_line_t ledstate[NUM_LEDS]; /* 0 - OFF, 1 - ON */
xpp_line_t ledcontrol[NUM_LEDS]; /* 0 - OFF, 1 - ON */
int blinking[NUM_LEDS][CHANNELS_PERXPD];
+#ifdef SOFT_RING
+ ushort ring_thresh[CHANNELS_PERXPD];
+#endif
};
/*---------------- FXO: Static functions ----------------------------------*/
@@ -174,6 +183,24 @@
spin_unlock_irqrestore(&xpd->lock, flags);
}
+static void mark_ring(xpd_t *xpd, lineno_t pos, bool on)
+{
+ struct FXO_priv_data *priv;
+
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ if(on && !xpd->ringing[pos]) {
+ DBG("%s/%s/%d: START\n", xpd->xbus->busname, xpd->xpdname, pos);
+ xpd->ringing[pos] = 1;
+ MARK_BLINK(priv, pos, LED_GREEN, LED_BLINK);
+ } 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);
+ }
+}
+
static void do_sethook(xpd_t *xpd, int pos, bool offhook)
{
unsigned long flags;
@@ -187,7 +214,7 @@
DBG("%s/%s/%d: WARNING: called while battery is off\n", xpd->xbus->busname, xpd->xpdname, pos);
}
spin_lock_irqsave(&xpd->lock, flags);
- xpd->ringing[pos] = 0; // No more rings
+ mark_ring(xpd, pos, 0); // No more rings
CALL_XMETHOD(SETHOOK, xpd->xbus, xpd, pos, offhook);
if(offhook) {
BIT_SET(xpd->hookstate, pos);
@@ -413,6 +440,21 @@
}
}
+#ifdef SOFT_RING
+
+static void poll_ring(xbus_t *xbus, xpd_t *xpd)
+{
+ int i;
+ struct FXO_priv_data *priv;
+
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ for_each_line(xpd, i) {
+ if(priv->ring_thresh[i] > 0)
+ CALL_PROTO(FXO, DAA_QUERY, xbus, xpd, i, DAA_RING_REGISTER);
+ }
+}
+#endif
static int FXO_card_tick(xbus_t *xbus, xpd_t *xpd)
{
@@ -426,6 +468,10 @@
if(poll_battery_interval != 0 && (rate_limit % poll_battery_interval) == 0) {
poll_battery(xbus, xpd);
}
+#ifdef SOFT_RING
+ if((rate_limit % POLL_RING_INTERVAL) == 0)
+ poll_ring(xbus, xpd);
+#endif
handle_fxo_leds(xpd);
return 0;
}
@@ -552,7 +598,6 @@
xpacket_t *pack;
slic_cmd_t *sc;
int len;
- unsigned long flags;
bool value;
BUG_ON(!xbus);
@@ -560,7 +605,6 @@
value = (offhook) ? 0x09 : 0x08;
// value |= BIT(3); /* Bit 3 is for CID */
DBG("%s/%s/%d: SETHOOK: value=0x%02X %s\n", xbus->busname, xpd->xpdname, pos, value, (offhook)?"OFFHOOK":"ONHOOK");
- spin_lock_irqsave(&xpd->lock, flags);
MARK_LED(xpd, pos, LED_GREEN, (offhook)?LED_ON:LED_OFF);
XPACKET_NEW(pack, xbus, FXO, DAA_WRITE, xpd->id);
sc = &RPACKET_FIELD(pack, FXO, DAA_WRITE, slic_cmd);
@@ -568,8 +612,7 @@
pack->datalen = len;
packet_send(xbus, pack);
if(!offhook)
- xpd->ringing[pos] = 0;
- spin_unlock_irqrestore(&xpd->lock, flags);
+ mark_ring(xpd, pos, 0); // No more rings
return ret;
}
@@ -619,17 +662,18 @@
spin_lock_irqsave(&xpd->lock, flags);
for_each_line(xpd, i) {
if(IS_SET(sig_toggles, i)) {
- struct zt_chan *chan = &xpd->span.chans[i];
-
if(IS_SET(sig_status, i)) {
- DBG("%s/%s/%d: RING-ON\n", xbus->busname, xpd->xpdname, chan->channo);
- xpd->ringing[i] = 1;
- MARK_BLINK(priv, i, LED_GREEN, LED_BLINK);
+#ifdef SOFT_RING
+ priv->ring_thresh[i]++; /* trigger register polling */
+#else
+ mark_ring(xpd, i, 1);
+#endif
} else {
- DBG("%s/%s/%d: RING-OFF\n", xbus->busname, xpd->xpdname, chan->channo);
- xpd->ringing[i] = 0;
- if(IS_BLINKING(priv, i, LED_GREEN))
- MARK_BLINK(priv, i, LED_GREEN, 0);
+#ifdef SOFT_RING
+ priv->ring_thresh[i] = 0;
+#else
+ mark_ring(xpd, i, 0);
+#endif
}
}
}
@@ -671,6 +715,24 @@
}
}
}
+#ifdef SOFT_RING
+ if(!info->indirect && info->reg_num == DAA_RING_REGISTER) {
+ bool ringit = (info->data_low & (0x20 | 0x40)) ? 1 : 0; /* Ring positive | Ring negative */
+ int i;
+
+ for_each_line(xpd, i) {
+ if(IS_SET(lines, i)) {
+ if(ringit) {
+ if(priv->ring_thresh[i]++ > RING_THRESHOLD) {
+ mark_ring(xpd, i, 1);
+ }
+ } else {
+ mark_ring(xpd, i, 0);
+ }
+ }
+ }
+ }
+#endif
#if 0
DBG("DAA_REPLY: xpd #%d %s reg_num=0x%X, dataL=0x%X dataH=0x%X\n",
xpd->id, (info->indirect)?"I":"D",
@@ -772,6 +834,13 @@
if(!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i))
len += sprintf(page + len, "%d ", IS_BLINKING(priv,i,LED_GREEN));
}
+#ifdef SOFT_RING
+ len += sprintf(page + len, "\n\t%-17s: ", "ring_thresh");
+ for_each_line(xpd, i) {
+ if(!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i))
+ len += sprintf(page + len, "%d ", priv->ring_thresh[i]);
+ }
+#endif
len += sprintf(page + len, "\n\t%-17s: ", "battery");
for_each_line(xpd, i) {
len += sprintf(page + len, "%d ", IS_SET(priv->battery, i));
Modified: trunk/xpp/xpp_zap.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/xpp_zap.c?rev=1285&r1=1284&r2=1285&view=diff
==============================================================================
--- trunk/xpp/xpp_zap.c (original)
+++ trunk/xpp/xpp_zap.c Wed Aug 9 22:12:25 2006
@@ -634,6 +634,8 @@
zt_hooksig(chan, ZT_RXSIG_ONHOOK);
}
+#define RING_TIME 15 /* in ticks */
+
static void xpp_ring_generate(xpd_t *xpd)
{
int i;
@@ -658,7 +660,7 @@
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 % 1000) == 0) {
+ 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);
@@ -1488,8 +1490,10 @@
unregister_chrdev(XPP_CTL_MAJOR, THIS_MODULE->name);
#endif
#ifdef CONFIG_PROC_FS
+ DBG("Removing '%s' from proc\n", PROC_SYNC);
remove_proc_entry(PROC_SYNC, xpp_proc_toplevel);
if(xpp_proc_toplevel) {
+ DBG("Removing '%s' from proc\n", PROC_DIR);
remove_proc_entry(PROC_DIR, NULL);
xpp_proc_toplevel = NULL;
}
More information about the zaptel-commits
mailing list