summaryrefslogtreecommitdiff
path: root/xivovp/base.c
diff options
context:
space:
mode:
authorNoe Rubinstein <nrubinstein@proformatique.com>2011-01-06 16:40:21 +0100
committerNoe Rubinstein <nrubinstein@proformatique.com>2011-01-06 16:40:21 +0100
commitd3319b733d4f59b75d03299358ac68fc702d6274 (patch)
treecb7a06f4e0c3def2a60a6088b96fe9b2e1ca19fb /xivovp/base.c
parentcee91eb231da1af9298a103e93b11ead669f35cb (diff)
polrev MWI, others
Diffstat (limited to 'xivovp/base.c')
-rw-r--r--xivovp/base.c68
1 files changed, 57 insertions, 11 deletions
diff --git a/xivovp/base.c b/xivovp/base.c
index afe2084..9036cc8 100644
--- a/xivovp/base.c
+++ b/xivovp/base.c
@@ -38,9 +38,11 @@
#define TS_MASK ((1u << FXS_TIMESLOT) | (1u << FXO_TIMESLOT))
#endif
-#define REVERSE_POLARITY(line) (!( \
- (!reverse_polarity) ^ \
- (!(line)->reverse_polarity) ^ \
+#define REVERSE_POLARITY(line) (!( \
+ (!reverse_polarity) ^ \
+ (!(line)->reverse_polarity && \
+ (line)->vmwi_info.vmwi_type & \
+ DAHDI_VMWI_LREV) ^ \
(!(line)->message_waiting)))
#define POL(line, sig) (REVERSE_POLARITY(line) ? sig ## _POLREV : sig)
@@ -81,8 +83,10 @@ struct xivovp_line {
spinlock_t lock;
+ struct dahdi_vmwi_info vmwi_info;
+
bool reverse_polarity;
- bool message_waiting;
+ int message_waiting;
bool previous_polarity;
};
@@ -150,12 +154,13 @@ static int xivovp_hooksig(struct dahdi_chan *chan, enum dahdi_txsig txsig)
return 0;
}
-#define HOOKSIG_TRACE(line, txsig, vpsig) \
- printk(KERN_DEBUG DRV_NAME "(chan %d): " \
- "transmitting %s on %s, setting to %s%s.\n", \
- chanpos, txsig, \
- (line->type == FXO_LINE ? "FXO" : "FXS"), vpsig, \
- (REVERSE_POLARITY(line) && line->type == FXS_LINE ? \
+#define HOOKSIG_TRACE(line, txsig, vpsig) \
+ printk(KERN_DEBUG DRV_NAME "(chan %d): " \
+ "transmitting %s on %s, setting to %s%s.\n", \
+ chanpos, txsig, \
+ (line->type == FXO_LINE ? "FXO" : "FXS"), vpsig,\
+ (REVERSE_POLARITY(line) && \
+ line->type == FXS_LINE ? \
"_POLREV" : ""));
/*
@@ -545,10 +550,52 @@ static void vp_tick(const unsigned long data)
mod_timer(&xivovp.vp_tick_timer, jiffies + VP_TICK_JIFFIES);
}
+static int xivovp_ioctl(struct dahdi_chan *chan, unsigned int cmd,
+ unsigned long data)
+{
+ struct xivovp_line* line = chan->pvt;
+ int x;
+
+ switch (cmd) {
+ case DAHDI_VMWI_CONFIG:
+ if (line->type != FXS_LINE)
+ return -EINVAL;
+ if (copy_from_user(&line->vmwi_info, (__user void *) data,
+ sizeof(line->vmwi_info)))
+ return -EFAULT;
+ if (!(line->vmwi_info.vmwi_type & DAHDI_VMWI_LREV))
+ printk(KERN_WARNING DRV_NAME "(chan %d): "
+ "Only lrev VMWI is supported\n",
+ chan->chanpos);
+ break;
+
+ case DAHDI_VMWI:
+ if (line->type != FXS_LINE)
+ return -EINVAL;
+ if (get_user(x, (__user int *) data))
+ return -EFAULT;
+ line->message_waiting = x;
+ break;
+
+ case DAHDI_SETPOLARITY:
+ if (line->type != FXS_LINE)
+ return -EINVAL;
+ if (get_user(x, (__user int *) data))
+ return -EFAULT;
+ line->reverse_polarity = !!x;
+ break;
+
+ default:
+ return -ENOTTY;
+ }
+ return 0;
+}
+
static const struct dahdi_span_ops xivovp_span_ops = {
.owner = THIS_MODULE,
.hooksig = xivovp_hooksig,
+ .ioctl = xivovp_ioctl,
};
static int span_init(void)
@@ -675,7 +722,6 @@ vp_init(void)
goto err_vp_make_line_object;
}
-#if 1
vpst = VpMakeLineObject(
VP_TERM_FXO_GENERIC,
FXO_LINE,