summaryrefslogtreecommitdiff
path: root/wctdm.c
diff options
context:
space:
mode:
authormattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2005-01-08 00:05:24 +0000
committermattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2005-01-08 00:05:24 +0000
commitf59bc698cc7f139b93a9c51eb65f342a789e725f (patch)
tree24921b81b0417c112be5db999a4fd2de0c0041cd /wctdm.c
parent3ac20515e24dba5119fa2d5b06157d81d84e9cc3 (diff)
More TDM card echo API modifications. Making the fxotune program automatically
find the correct coefficients for the module. Lots of neat stuff. git-svn-id: http://svn.digium.com/svn/zaptel/trunk@531 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'wctdm.c')
-rwxr-xr-xwctdm.c204
1 files changed, 85 insertions, 119 deletions
diff --git a/wctdm.c b/wctdm.c
index 03f3105..136c97d 100755
--- a/wctdm.c
+++ b/wctdm.c
@@ -119,115 +119,86 @@ 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, 0 }, /* US, Canada */
- { "TBR21", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0x7e6c, 0x023a, 0 },
+ { "FCC", 0, 0, 0, 0, 0, 0x3, 0, 0, }, /* US, Canada */
+ { "TBR21", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0x7e6c, 0x023a, },
/* 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, 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 },
- { "CYRPUS", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "CZECH", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "DENMARK", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "ECUADOR", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
- { "EGYPT", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "ELSALVADOR", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
- { "FINLAND", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "FRANCE", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "GERMANY", 0, 1, 0, 0, 1, 0x3, 0, 0x3, 0 },
- { "GREECE", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "GUAM", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
- { "HONGKONG", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
- { "HUNGARY", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
- { "ICELAND", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "INDIA", 0, 0, 0, 0, 0, 0x3, 0, 0x4, 0 },
- { "INDONESIA", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
- { "IRELAND", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "ISRAEL", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "ITALY", 0, 1, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "JAPAN", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "JORDAN", 0, 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "KAZAKHSTAN", 0, 0, 0, 0, 0, 0x3, 0, 0 },
- { "KUWAIT", 0, 0, 0, 0, 0, 0x3, 0, 0, 0 },
- { "LATVIA", 0, 0, 0, 0, 1, 0x3, 0, 0x2, 0 },
- { "LEBANON", 0, 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 },
+ { "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, },
};
-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
@@ -1617,9 +1588,9 @@ static int wctdm_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
struct wctdm_stats stats;
struct wctdm_regs regs;
struct wctdm_regop regop;
+ struct wctdm_echo_coefs echoregs;
struct wctdm *wc = chan->pvt;
int x;
- int whichecho = -1;
switch (cmd) {
case ZT_ONHOOKTRANSFER:
if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
@@ -1677,27 +1648,22 @@ static int wctdm_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
}
break;
case WCTDM_SET_ECHOTUNE:
- whichecho = fxo_modes[_opermode].echoentry;
-
- if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXO)
- return -EINVAL;
-
- if (get_user(x, (int *)data))
+ if (copy_from_user(&echoregs, (struct wctdm_echo_coefs*)data, sizeof(echoregs)))
return -EFAULT;
- if (x > -1 && x < 8) {
+ if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXO) {
/* Set the ACIM register */
- wctdm_setreg(wc, chan->chanpos - 1, 30, echo_zones[whichecho].vals[x].acim);
+ wctdm_setreg(wc, chan->chanpos - 1, 30, echoregs.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);
+ wctdm_setreg(wc, chan->chanpos - 1, 45, echoregs.coef1);
+ wctdm_setreg(wc, chan->chanpos - 1, 46, echoregs.coef2);
+ wctdm_setreg(wc, chan->chanpos - 1, 47, echoregs.coef3);
+ wctdm_setreg(wc, chan->chanpos - 1, 48, echoregs.coef4);
+ wctdm_setreg(wc, chan->chanpos - 1, 49, echoregs.coef5);
+ wctdm_setreg(wc, chan->chanpos - 1, 50, echoregs.coef6);
+ wctdm_setreg(wc, chan->chanpos - 1, 51, echoregs.coef7);
+ wctdm_setreg(wc, chan->chanpos - 1, 52, echoregs.coef8);
break;
} else {