summaryrefslogtreecommitdiff
path: root/xpp/card_fxo.c
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-09-04 21:52:08 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-09-04 21:52:08 +0000
commit4d1a1aac91bcb80a42ccefa2b6ae50a00a2585a3 (patch)
tree683c96931828ed8754d926def1c7d64cb68e472d /xpp/card_fxo.c
parentf9d97f28383eba55a138e116171cf8cc153d18fe (diff)
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. git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1382 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/card_fxo.c')
-rw-r--r--xpp/card_fxo.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/xpp/card_fxo.c b/xpp/card_fxo.c
index 5600a9f..4bd9221 100644
--- a/xpp/card_fxo.c
+++ b/xpp/card_fxo.c
@@ -74,9 +74,9 @@ static int process_slic_cmdline(xpd_t *xpd, char *cmdline);
#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 @@ struct FXO_priv_data {
#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 @@ static void do_sethook(xpd_t *xpd, int pos, bool offhook)
}
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 @@ static void poll_ring(xbus_t *xbus, xpd_t *xpd)
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 @@ static /* 0x0F */ HOSTCMD(FXO, SETHOOK, int pos, bool offhook)
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 @@ static /* 0x0F */ HOSTCMD(FXO, SETHOOK, int pos, bool offhook)
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 @@ HANDLER_DEF(FXO, SIG_CHANGED)
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
- mark_ring(xpd, i, 0);
+ priv->ring_sig[i] = 0;
#endif
+ mark_ring(xpd, i, 0);
}
}
}
@@ -736,21 +747,26 @@ HANDLER_DEF(FXO, DAA_REPLY)
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);
@@ -862,6 +878,11 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in
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");
for_each_line(xpd, i) {