summaryrefslogtreecommitdiff
path: root/xpp/card_fxo.c
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-12-01 05:22:55 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-12-01 05:22:55 +0000
commit61cc6e4ac8324b1e38a5c3bb543d1d262552bb78 (patch)
treef7bb41b90f90de1da1fd639af14ebe33b9a8c5f3 /xpp/card_fxo.c
parentb3764b4070cb7a595062bf986236eafc03a4ef0b (diff)
Merging from 1.2:
* Removing -DSOFT_RING: unused, useless code. * Register init scripts are not as noisy by default. * Register init scripts read configuration from a standard location. * Fixed a FXO spinlock race. (Log was lost on previos merge) git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1680 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/card_fxo.c')
-rw-r--r--xpp/card_fxo.c115
1 files changed, 13 insertions, 102 deletions
diff --git a/xpp/card_fxo.c b/xpp/card_fxo.c
index 7672db3..d3e7637 100644
--- a/xpp/card_fxo.c
+++ b/xpp/card_fxo.c
@@ -80,11 +80,6 @@ static int handle_register_command(xpd_t *xpd, char *cmdline);
#define PROC_REGISTER_FNAME "slics"
#define PROC_FXO_INFO_FNAME "fxo_info"
-#ifdef SOFT_RING
-#define POLL_RING_INTERVAL 2
-#define RING_THRESHOLD 3
-#define NORING_THRESHOLD 10
-#endif
#define DAA_RING_REGISTER 0x05
struct FXO_priv_data {
@@ -96,15 +91,6 @@ struct FXO_priv_data {
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];
- 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
};
/*---------------- FXO: Static functions ----------------------------------*/
@@ -187,7 +173,7 @@ static void handle_fxo_leds(xpd_t *xpd)
spin_unlock_irqrestore(&xpd->lock, flags);
}
-static void mark_ring(xpd_t *xpd, lineno_t pos, bool on)
+static void mark_ring(xpd_t *xpd, lineno_t pos, bool on, bool update_zap)
{
struct FXO_priv_data *priv;
@@ -197,13 +183,15 @@ static void mark_ring(xpd_t *xpd, lineno_t pos, bool on)
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);
+ if(update_zap)
+ update_zap_ring(xpd, pos, on);
} 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);
+ if(update_zap)
+ update_zap_ring(xpd, pos, on);
}
}
@@ -224,14 +212,11 @@ static int do_sethook(xpd_t *xpd, int pos, bool to_offhook)
NOTICE("%s/%s/%d: WARNING: called while battery is off\n", xbus->busname, xpd->xpdname, pos);
}
spin_lock_irqsave(&xpd->lock, flags);
- mark_ring(xpd, pos, 0); // No more rings
+ mark_ring(xpd, pos, 0, 0); // No more rings
value = (to_offhook) ? 0x09 : 0x08; /* Bit 3 is for CID */
DBG("%s/%s/%d: SETHOOK: value=0x%02X %s\n", xbus->busname, xpd->xpdname, pos, value, (to_offhook)?"OFFHOOK":"ONHOOK");
MARK_LED(xpd, pos, LED_GREEN, (to_offhook)?LED_ON:LED_OFF);
ret = DAA_DIRECT_REQUEST(xbus, xpd, pos, DAA_WRITE, DAA_RING_REGISTER, value);
-#ifdef SOFT_RING
- priv->ring_sig[pos] = 0;
-#endif
if(to_offhook) {
BIT_SET(xpd->offhook, pos);
} else {
@@ -362,7 +347,7 @@ static int FXO_card_zaptel_preregistration(xpd_t *xpd, bool on)
MARK_LED(xpd, ALL_LINES, LED_GREEN, LED_OFF);
for_each_line(xpd, i) {
MARK_LED(xpd, i, LED_GREEN, LED_ON);
- mdelay(50);
+ msleep(50);
}
return 0;
}
@@ -381,7 +366,7 @@ static int FXO_card_zaptel_postregistration(xpd_t *xpd, bool on)
DBG("%s/%s (%d)\n", xbus->busname, xpd->xpdname, on);
for_each_line(xpd, i) {
MARK_LED(xpd, i, LED_GREEN, LED_OFF);
- mdelay(50);
+ msleep(50);
}
return 0;
}
@@ -420,21 +405,6 @@ static void poll_battery(xbus_t *xbus, xpd_t *xpd)
}
}
-#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_sig[i])
- DAA_DIRECT_REQUEST(xbus, xpd, i, DAA_READ, DAA_RING_REGISTER, 0);
- }
-}
-#endif
-
static int FXO_card_tick(xbus_t *xbus, xpd_t *xpd)
{
struct FXO_priv_data *priv;
@@ -445,10 +415,6 @@ static int FXO_card_tick(xbus_t *xbus, xpd_t *xpd)
if(poll_battery_interval != 0 && (priv->poll_counter % poll_battery_interval) == 0) {
poll_battery(xbus, xpd);
}
-#ifdef SOFT_RING
- if((priv->poll_counter % POLL_RING_INTERVAL) == 0)
- poll_ring(xbus, xpd);
-#endif
handle_fxo_leds(xpd);
priv->poll_counter++;
return 0;
@@ -489,7 +455,7 @@ static int FXO_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a
ret = handle_register_command(xpd, buf);
if(ret < 0)
return ret;
- mdelay(1);
+ msleep(1);
}
DBG("-- Set echo registers successfully\n");
@@ -546,11 +512,11 @@ static /* 0x0F */ HOSTCMD(FXO, XPD_STATE, bool on)
if(on) {
for_each_line(xpd, i) {
MARK_LED(xpd, i, LED_GREEN, LED_ON);
- mdelay(20);
+ msleep(20);
}
for_each_line(xpd, i) {
MARK_LED(xpd, i, LED_GREEN, LED_OFF);
- mdelay(20);
+ msleep(20);
}
}
return ret;
@@ -606,21 +572,7 @@ HANDLER_DEF(FXO, SIG_CHANGED)
xbus->busname, xpd->xpdname, i);
continue;
}
- if(IS_SET(sig_status, i)) {
-#ifdef SOFT_RING
- 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_sig[i] = 0;
-#endif
- mark_ring(xpd, i, 0);
- }
+ mark_ring(xpd, i, IS_SET(sig_status, i), 1);
}
}
spin_unlock_irqrestore(&xpd->lock, flags);
@@ -667,25 +619,6 @@ HANDLER_DEF(FXO, DAA_REPLY)
}
}
}
-#ifdef SOFT_RING
- if(REG_FIELD(info, regnum) == DAA_RING_REGISTER && priv->ring_sig[chipsel]) {
- bool ringit = (REG_FIELD(info, data_low) & (0x20 | 0x40)) ? 1 : 0; /* Ring positive | Ring negative */
-
- if(ringit) {
- if(priv->ring_thresh[chipsel] > RING_THRESHOLD) {
- mark_ring(xpd, chipsel, 1);
- priv->noring_thresh[chipsel] = 0;
- } else
- priv->ring_thresh[chipsel]++;
- } else {
- if(priv->noring_thresh[chipsel] > NORING_THRESHOLD) {
- mark_ring(xpd, chipsel, 0);
- priv->ring_thresh[chipsel] = 0;
- } else
- priv->noring_thresh[chipsel]++;
- }
- }
-#endif
#if 0
DBG("DAA_REPLY: xpd #%d %s reg_num=0x%X, dataL=0x%X dataH=0x%X\n",
xpd->id, (info->size == 3)?"I":"D",
@@ -779,23 +712,6 @@ 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 ", 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, "%2d ", priv->ring_thresh[i]);
- }
- len += sprintf(page + len, "\n\t%-17s: ", "noring_thresh");
- 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, "%2d ", priv->ring_sig[i]);
- }
-#endif
len += sprintf(page + len, "\n\t%-17s: ", "battery");
for_each_line(xpd, i) {
len += sprintf(page + len, "%2d ", IS_SET(priv->battery, i));
@@ -942,7 +858,7 @@ static int proc_xpd_register_write(struct file *file, const char __user *buffer,
ret = handle_register_command(xpd, buf);
if(ret < 0)
return ret;
- mdelay(1);
+ msleep(1);
}
return count;
}
@@ -982,11 +898,6 @@ static int proc_xpd_register_read(char *page, char **start, off_t off, int count
int __init card_fxo_startup(void)
{
INFO("%s revision %s\n", THIS_MODULE->name, ZAPTEL_VERSION);
-#ifdef SOFT_RING
- INFO("FEATURE: %s with SOFT_RING\n", THIS_MODULE->name);
-#else
- INFO("FEATURE: %s without SOFT_RING\n", THIS_MODULE->name);
-#endif
xproto_register(&PROTO_TABLE(FXO));
return 0;
}