summaryrefslogtreecommitdiff
path: root/wctdm.c
diff options
context:
space:
mode:
authormattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2004-12-30 18:07:34 +0000
committermattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2004-12-30 18:07:34 +0000
commit79631558e10918a958abb06bfe7d2f6bf341c6a0 (patch)
tree620d332f448cacffb313bc727f28db63aeb2751f /wctdm.c
parent2476adaa0c7d95967ee3d87019094b8d41a3c3c4 (diff)
Adding FXO module support for onboard echo cancellation
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@525 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'wctdm.c')
-rwxr-xr-xwctdm.c204
1 files changed, 131 insertions, 73 deletions
diff --git a/wctdm.c b/wctdm.c
index 1862bd3..b3e9ec7 100755
--- a/wctdm.c
+++ b/wctdm.c
@@ -119,86 +119,115 @@ static struct fxo_mode {
int acim;
int ring_osc;
int ring_x;
+ int echoentry;
} fxo_modes[] =
{
- { "FCC", 0, 0, 0, 0, 0, 0x3, 0, 0 }, /* US, Canada */
- { "TBR21", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0x7e6c, 0x023a },
+ { "FCC", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 }, /* US, Canada */
+ { "TBR21", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0x7e6c, 0x023a, 0 },
/* Austria, Belgium, Denmark, Finland, France, Germany,
Greece, Iceland, Ireland, Italy, Luxembourg, Netherlands,
Norway, Portugal, Spain, Sweden, Switzerland, and UK */
- { "ARGENTINA", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "AUSTRALIA", 1, 0, 0, 0, 0, 0, 0x3, 0x3 },
- { "AUSTRIA", 0, 1, 0, 0, 1, 0x3, 0, 0x3 },
- { "BAHRAIN", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },
- { "BELGIUM", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "BRAZIL", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "BULGARIA", 0, 0, 0, 0, 1, 0x3, 0x0, 0x3 },
- { "CANADA", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "CHILE", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "CHINA", 0, 0, 0, 0, 0, 0, 0x3, 0xf },
- { "COLUMBIA", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "CROATIA", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },
- { "CYRPUS", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },
- { "CZECH", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },
- { "DENMARK", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "ECUADOR", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "EGYPT", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "ELSALVADOR", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "FINLAND", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "FRANCE", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "GERMANY", 0, 1, 0, 0, 1, 0x3, 0, 0x3 },
- { "GREECE", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "GUAM", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "HONGKONG", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "HUNGARY", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "ICELAND", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "INDIA", 0, 0, 0, 0, 0, 0x3, 0, 0x4 },
- { "INDONESIA", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "IRELAND", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "ISRAEL", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },
- { "ITALY", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "JAPAN", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "JORDAN", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "KAZAKHSTAN", 0, 0, 0, 0, 0, 0x3, 0 },
- { "KUWAIT", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "LATVIA", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },
- { "LEBANON", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },
- { "LUXEMBOURG", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "MACAO", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "MALAYSIA", 0, 0, 0, 0, 0, 0, 0x3, 0 }, /* Current loop >= 20ma */
- { "MALTA", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },
- { "MEXICO", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "MOROCCO", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },
- { "NETHERLANDS", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "NEWZEALAND", 0, 0, 0, 0, 0, 0x3, 0, 0x4 },
- { "NIGERIA", 0, 0, 0, 0, 0x1, 0x3, 0, 0x2 },
- { "NORWAY", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "OMAN", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "PAKISTAN", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "PERU", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "PHILIPPINES", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "POLAND", 0, 0, 1, 1, 0, 0x3, 0, 0 },
- { "PORTUGAL", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "ROMANIA", 0, 0, 0, 0, 0, 3, 0, 0 },
- { "RUSSIA", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "SAUDIARABIA", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "SINGAPORE", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "SLOVAKIA", 0, 0, 0, 0, 0, 0x3, 0, 0x3 },
- { "SLOVENIA", 0, 0, 0, 0, 0, 0x3, 0, 0x2 },
- { "SOUTHAFRICA", 1, 0, 1, 0, 0, 0x3, 0, 0x3 },
- { "SOUTHKOREA", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "SPAIN", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "SWEDEN", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "SWITZERLAND", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
- { "SYRIA", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "TAIWAN", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "THAILAND", 0, 0, 0, 0, 0, 0, 0x3, 0 },
- { "UAE", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "UK", 0, 1, 0, 0, 1, 0x3, 0, 0x5 },
- { "USA", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "YEMEN", 0, 0, 0, 0, 0, 0x3, 0, 0 },
+ { "ARGENTINA", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "AUSTRALIA", 1, 0, 0, 0, 0, 0, 0x3, 0x3, 0 },
+ { "AUSTRIA", 0, 1, 0, 0, 1, 0x3, 0, 0x3, 0 },
+ { "BAHRAIN", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "BELGIUM", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "BRAZIL", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
+ { "BULGARIA", 0, 0, 0, 0, 1, 0x3, 0x0, 0x3, 0 },
+ { "CANADA", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "CHILE", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "CHINA", 0, 0, 0, 0, 0, 0, 0x3, 0xf, 0 },
+ { "COLUMBIA", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "CROATIA", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "C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, 0, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "LUXEMBOURG", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "MACAO", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "MALAYSIA", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 }, /* Current loop >= 20ma */
+ { "MALTA", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "MEXICO", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "MOROCCO", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "NETHERLANDS", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "NEWZEALAND", 0, 0, 0, 0, 0, 0x3, 0, 0x4, 0 },
+ { "NIGERIA", 0, 0, 0, 0, 0x1, 0x3, 0, 0x2, 0 },
+ { "NORWAY", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "OMAN", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
+ { "PAKISTAN", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
+ { "PERU", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "PHILIPPINES", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
+ { "POLAND", 0, 0, 1, 1, 0, 0x3, 0, 0, 0 },
+ { "PORTUGAL", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "ROMANIA", 0, 0, 0, 0, 0, 3, 0, 0, 0 },
+ { "RUSSIA", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
+ { "SAUDIARABIA", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "SINGAPORE", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "SLOVAKIA", 0, 0, 0, 0, 0, 0x3, 0, 0x3, 0 },
+ { "SLOVENIA", 0, 0, 0, 0, 0, 0x3, 0, 0x2, 0 },
+ { "SOUTHAFRICA", 1, 0, 1, 0, 0, 0x3, 0, 0x3, 0 },
+ { "SOUTHKOREA", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "SPAIN", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "SWEDEN", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "SWITZERLAND", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
+ { "SYRIA", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
+ { "TAIWAN", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
+ { "THAILAND", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
+ { "UAE", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "UK", 0, 1, 0, 0, 1, 0x3, 0, 0x5, 0 },
+ { "USA", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
+ { "YEMEN", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
};
+struct echo_zone {
+ struct regs {
+ int acim;
+ int coef1;
+ int coef2;
+ int coef3;
+ int coef4;
+ int coef5;
+ int coef6;
+ int coef7;
+ int coef8;
+ } vals[8];
+} echo_zones[] =
+{
+ {{
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 10, 0, 6, 1, 254, 2, 255, 0, 0},
+ { 3, 255, 255, 0, 1, 0, 0, 0, 0},
+ { 3, 1, 253, 253, 2, 255, 0, 0, 0},
+ { 9, 254, 251, 255, 2, 0, 1, 0, 0},
+ { 5, 3, 251, 250, 2, 254, 0, 0, 255},
+ { 8, 253, 2, 244, 255, 10, 244, 3, 253},
+ { 10, 249, 244, 8, 12, 245, 252, 0, 1},
+ }}
+};
+
+
+
#ifdef STANDALONE_ZAPATA
#include "zaptel.h"
#else
@@ -1590,6 +1619,7 @@ static int wctdm_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
struct wctdm_regop regop;
struct wctdm *wc = chan->pvt;
int x;
+ int whichecho = -1;
switch (cmd) {
case ZT_ONHOOKTRANSFER:
if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
@@ -1646,6 +1676,34 @@ static int wctdm_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
wctdm_setreg(wc, chan->chanpos - 1, regop.reg, regop.val);
}
break;
+ case WCTDM_SET_ECHOZONE:
+ whichecho = fxo_modes[_opermode].echoentry;
+
+ if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXO)
+ return -EINVAL;
+
+ if (get_user(x, (int *)data))
+ return -EFAULT;
+
+ if (x > -1 && x < 8) {
+ /* Set the ACIM register */
+ wctdm_setreg(wc, chan->chanpos - 1, 30, echo_zones[whichecho].vals[x].acim);
+
+ /* Set the digital echo canceller registers */
+ wctdm_setreg(wc, chan->chanpos - 1, 45, echo_zones[whichecho].vals[x].coef1);
+ wctdm_setreg(wc, chan->chanpos - 1, 46, echo_zones[whichecho].vals[x].coef2);
+ wctdm_setreg(wc, chan->chanpos - 1, 47, echo_zones[whichecho].vals[x].coef3);
+ wctdm_setreg(wc, chan->chanpos - 1, 48, echo_zones[whichecho].vals[x].coef4);
+ wctdm_setreg(wc, chan->chanpos - 1, 49, echo_zones[whichecho].vals[x].coef5);
+ wctdm_setreg(wc, chan->chanpos - 1, 50, echo_zones[whichecho].vals[x].coef6);
+ wctdm_setreg(wc, chan->chanpos - 1, 51, echo_zones[whichecho].vals[x].coef7);
+ wctdm_setreg(wc, chan->chanpos - 1, 52, echo_zones[whichecho].vals[x].coef8);
+
+ break;
+ } else {
+ return -EINVAL;
+ }
+ break;
default:
return -ENOTTY;
}