diff -ruN zaptel-1.0.7.old/fxstest.c zaptel-1.0.7/fxstest.c --- zaptel-1.0.7.old/fxstest.c 2004-12-30 21:12:17.000000000 +0100 +++ zaptel-1.0.7/fxstest.c 2005-05-17 12:33:55.594339824 +0200 @@ -28,6 +28,7 @@ " stats - reports voltages\n" " regdump - dumps ProSLIC registers\n" " tones - plays a series of tones\n" + " polarity - changes polarity\n" " ring - rings phone\n"); exit(1); } @@ -46,6 +47,24 @@ 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 -ruN zaptel-1.0.7.old/wcfxs.c zaptel-1.0.7/wcfxs.c --- zaptel-1.0.7.old/wcfxs.c 2005-02-28 01:41:29.000000000 +0100 +++ zaptel-1.0.7/wcfxs.c 2005-05-17 12:33:18.753940416 +0200 @@ -1601,6 +1601,22 @@ wcfxs_setreg(wc, chan->chanpos - 1, 64, wc->mod.fxs.lasttxhook[chan->chanpos - 1]); } break; + case ZT_SETPOLARITY: + if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS) + return -EINVAL; + if (get_user(x, (int *)data)) + return -EFAULT; + /* 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 WCFXS_GET_STATS: if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS) { stats.tipvolt = wcfxs_getreg(wc, chan->chanpos - 1, 80) * -376; diff -ruN zaptel-1.0.7.old/zaptel.h zaptel-1.0.7/zaptel.h --- zaptel-1.0.7.old/zaptel.h 2004-09-27 21:50:03.000000000 +0200 +++ zaptel-1.0.7/zaptel.h 2005-05-17 12:33:18.754940264 +0200 @@ -604,6 +604,11 @@ */ #define ZT_DYNAMIC_DESTROY _IOW (ZT_CODE, 81, struct zt_dynamic_span) +/* + * Set polarity -- implemented by individual driver. 0 = forward, 1 = reverse + */ +#define ZT_SETPOLARITY _IOW (ZT_CODE, 92, int) + /* * Startup or Shutdown a span */