summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2005-05-11 23:43:11 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2005-05-11 23:43:11 +0000
commit3957d619bb756563a03b3d15b9bffec5239dac19 (patch)
treea9fbeabe0fa07864461f2d753de4c9dee84218a2
parent0afdce07bf03c4ef19cd6754a7e6d8e2785e5e03 (diff)
Add support for polarity reversal
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@641 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-xfxstest.c19
-rwxr-xr-xwctdm.c16
-rwxr-xr-xzaptel.h6
3 files changed, 41 insertions, 0 deletions
diff --git a/fxstest.c b/fxstest.c
index f200c74..922a1a9 100755
--- a/fxstest.c
+++ b/fxstest.c
@@ -28,6 +28,7 @@ int main(int argc, char *argv[])
" stats - reports voltages\n"
" regdump - dumps ProSLIC registers\n"
" tones - plays a series of tones\n"
+ " polarity - tests polarity reversal\n"
" ring - rings phone\n");
exit(1);
}
@@ -46,6 +47,24 @@ int main(int argc, char *argv[])
fprintf(stderr, "Phone is ringing...\n");
sleep(2);
}
+ } else if (!strcasecmp(argv[2], "polarity")) {
+ fprintf(stderr, "Twiddling polarity...\n");
+ x = 0;
+ res = ioctl(fd, ZT_SETPOLARITY, &x);
+ if (res) {
+ fprintf(stderr, "Unable to polarity...\n");
+ } else {
+ fprintf(stderr, "Polarity is forward...\n");
+ sleep(2);
+ x = 1;
+ ioctl(fd, ZT_SETPOLARITY, &x);
+ fprintf(stderr, "Polarity is reversed...\n");
+ sleep(5);
+ x = 0;
+ ioctl(fd, ZT_SETPOLARITY, &x);
+ fprintf(stderr, "Polarity is forward...\n");
+ sleep(2);
+ }
} else if (!strcasecmp(argv[2], "tones")) {
int x = 0;
for (;;) {
diff --git a/wctdm.c b/wctdm.c
index 128b9ed..9c46f49 100755
--- a/wctdm.c
+++ b/wctdm.c
@@ -1657,6 +1657,22 @@ static int wctdm_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod.fxs.lasttxhook[chan->chanpos - 1]);
}
break;
+ case ZT_SETPOLARITY:
+ if (get_user(x, (int *)data))
+ return -EFAULT;
+ if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
+ return -EINVAL;
+ /* Can't change polarity while ringing or when open */
+ if ((wc->mod.fxs.lasttxhook[chan->chanpos -1 ] == 0x04) ||
+ (wc->mod.fxs.lasttxhook[chan->chanpos -1 ] == 0x00))
+ return -EINVAL;
+
+ if (x)
+ wc->mod.fxs.lasttxhook[chan->chanpos - 1] |= 0x04;
+ else
+ wc->mod.fxs.lasttxhook[chan->chanpos - 1] &= ~0x04;
+ wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod.fxs.lasttxhook[chan->chanpos - 1]);
+ break;
case WCTDM_GET_STATS:
if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS) {
stats.tipvolt = wctdm_getreg(wc, chan->chanpos - 1, 80) * -376;
diff --git a/zaptel.h b/zaptel.h
index 175279f..ff3d06b 100755
--- a/zaptel.h
+++ b/zaptel.h
@@ -623,6 +623,12 @@ void *data;
*/
#define ZT_TONEDETECT _IOW (ZT_CODE, 91, int)
+
+/*
+ * Set polarity -- implemented by individual driver. 0 = forward, 1 = reverse
+ */
+#define ZT_SETPOLARITY _IOW (ZT_CODE, 92, int)
+
/*
* Startup or Shutdown a span
*/