[zaptel-commits] tzafrir: trunk r1382 - /trunk/xpp/card_fxo.c
zaptel-commits at lists.digium.com
zaptel-commits at lists.digium.com
Mon Sep 4 14:52:09 MST 2006
Author: tzafrir
Date: Mon Sep 4 16:52:08 2006
New Revision: 1382
URL: http://svn.digium.com/view/zaptel?rev=1382&view=rev
Log:
Experimenting with SOFT_RING again:
* Poll R5 every 2 milliseconds; thresholds adjusted accordingly.
* experimenting a reduced noring_threshhold (20ms)
* Unset ring_sig[] for the FXO channel that is no longer being ringed.
* Added ring_sig[] to the fxo struct: set when we need to
check for reg 5 (instead of abusing the value of ring_thresh[])
* Don't increment ring_thresh/noring_thresh once they reached their threshold.
Modified:
trunk/xpp/card_fxo.c
Modified: trunk/xpp/card_fxo.c
URL: http://svn.digium.com/view/zaptel/trunk/xpp/card_fxo.c?rev=1382&r1=1381&r2=1382&view=diff
==============================================================================
--- trunk/xpp/card_fxo.c (original)
+++ trunk/xpp/card_fxo.c Mon Sep 4 16:52:08 2006
@@ -74,9 +74,9 @@
#define PROC_FXO_INFO_FNAME "fxo_info"
#ifdef SOFT_RING
-#define POLL_RING_INTERVAL 1
+#define POLL_RING_INTERVAL 2
#define RING_THRESHOLD 3
-#define NORING_THRESHOLD 50
+#define NORING_THRESHOLD 10
#define DAA_RING_REGISTER 0x05
#endif
@@ -93,6 +93,11 @@
#ifdef SOFT_RING
ushort ring_thresh[CHANNELS_PERXPD];
ushort noring_thresh[CHANNELS_PERXPD];
+ /* ring_sig is set when Reg5, bit 2 (Ring Detect) is set.
+ * While ring_sig=1 we check R5 bit 20H and 40H for ringing.
+ * When it drops to 0 that's the end of the ring sequence and
+ * we clear the ring detection variables */
+ ushort ring_sig[CHANNELS_PERXPD];
#endif
};
@@ -221,6 +226,7 @@
}
spin_lock_irqsave(&xpd->lock, flags);
mark_ring(xpd, pos, 0); // No more rings
+ priv->ring_sig[pos] = 0;
CALL_XMETHOD(SETHOOK, xpd->xbus, xpd, pos, offhook);
if(offhook) {
BIT_SET(xpd->hookstate, pos);
@@ -456,7 +462,7 @@
priv = xpd->priv;
BUG_ON(!priv);
for_each_line(xpd, i) {
- if(priv->ring_thresh[i] > 0)
+ if(priv->ring_sig[i])
CALL_PROTO(FXO, DAA_QUERY, xbus, xpd, i, DAA_RING_REGISTER);
}
}
@@ -605,9 +611,11 @@
slic_cmd_t *sc;
int len;
bool value;
+ struct FXO_priv_data *priv;
BUG_ON(!xbus);
BUG_ON(!xpd);
+ priv = (struct FXO_priv_data*)xpd->priv;
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");
@@ -619,6 +627,7 @@
packet_send(xbus, pack);
if(!offhook)
mark_ring(xpd, pos, 0); // No more rings
+ priv->ring_sig[pos] = 0;
return ret;
}
@@ -670,16 +679,18 @@
if(IS_SET(sig_toggles, i)) {
if(IS_SET(sig_status, i)) {
#ifdef SOFT_RING
- priv->ring_thresh[i]++; /* trigger register polling */
+ priv->ring_sig[i]=1; /* trigger register polling */
+ /* reset ring check counters */
+ priv->ring_thresh[i] = 0;
+ priv->noring_thresh[i] = 0;
#else
mark_ring(xpd, i, 1);
#endif
} else {
#ifdef SOFT_RING
- priv->ring_thresh[i] = 0;
-#else
+ priv->ring_sig[i] = 0;
+#endif
mark_ring(xpd, i, 0);
-#endif
}
}
}
@@ -736,21 +747,26 @@
for_each_line(xpd, i) {
if(!IS_SET(lines, i))
continue;
+ if (!priv->ring_sig[i])
+ continue;
if(ringit) {
- if(priv->ring_thresh[i]++ > RING_THRESHOLD) {
+ if(priv->ring_thresh[i] > RING_THRESHOLD) {
mark_ring(xpd, i, 1);
priv->noring_thresh[i] = 0;
- }
+ } else
+ priv->ring_thresh[i]++;
} else {
- if(priv->noring_thresh[i]++ > NORING_THRESHOLD) {
+ if(priv->noring_thresh[i] > NORING_THRESHOLD) {
mark_ring(xpd, i, 0);
priv->ring_thresh[i] = 0;
- }
+ } else
+ priv->noring_thresh[i]++;
}
}
}
#endif
#if 0
+ if (info->reg_num != 29)
DBG("DAA_REPLY: xpd #%d %s reg_num=0x%X, dataL=0x%X dataH=0x%X\n",
xpd->id, (info->indirect)?"I":"D",
info->reg_num, info->data_low, info->data_high);
@@ -861,6 +877,11 @@
for_each_line(xpd, i) {
if(!IS_SET(xpd->digital_outputs, i) && !IS_SET(xpd->digital_inputs, i))
len += sprintf(page + len, "%2d ", priv->noring_thresh[i]);
+ }
+ len += sprintf(page + len, "\n\t%-17s: ", "ring_sig");
+ 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_sig[i]);
}
#endif
len += sprintf(page + len, "\n\t%-17s: ", "battery");
More information about the zaptel-commits
mailing list