From fe2d13f0684d8bb1cfd16d5ac6f9d3d171a16fe1 Mon Sep 17 00:00:00 2001 From: mogorman Date: Mon, 2 Oct 2006 23:57:35 +0000 Subject: Merged revisions 1490 via svnmerge from https://svn.digium.com/svn/zaptel/branches/1.4 ........ r1490 | mogorman | 2006-10-02 18:50:44 -0500 (Mon, 02 Oct 2006) | 2 lines add support for setting gain registers on the fxo and fxs modules. ........ git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1491 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- wctdm.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- wctdm24xxp.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 157 insertions(+), 2 deletions(-) diff --git a/wctdm.c b/wctdm.c index 9f1bccc..01ca964 100644 --- a/wctdm.c +++ b/wctdm.c @@ -379,6 +379,10 @@ static char *opermode = "FCC"; static int fxshonormode = 0; static int alawoverride = 0; static int fastpickup = 0; +static int fxotxgain = 0; +static int fxorxgain = 0; +static int fxstxgain = 0; +static int fxsrxgain = 0; static int wctdm_init_proslic(struct wctdm *wc, int card, int fast , int manual, int sane); @@ -1510,12 +1514,45 @@ static int wctdm_init_voicedaa(struct wctdm *wc, int card, int fast, int manual, (wctdm_getreg(wc, card, 13) >> 2) & 0xf); /* Enable on-hook line monitor */ wctdm_setreg(wc, card, 5, 0x08); + + /* Take values for fxotxgain and fxorxgain and apply them to module */ + if (fxotxgain) { + if (fxotxgain >= -150 && fxotxgain < 0) { + wctdm_setreg(wc, card, 38, 16 + (fxotxgain/-10)); + if(fxotxgain % 10) { + wctdm_setreg(wc, card, 40, 16 + (-fxotxgain%10)); + } + } + else if (fxotxgain <= 120 && fxotxgain > 0) { + wctdm_setreg(wc, card, 38, fxotxgain/10); + if(fxotxgain%10) { + wctdm_setreg(wc, card, 40, (fxotxgain%10)); + } + } + } + if (fxorxgain) { + if (fxorxgain >= -150 && fxorxgain < 0) { + wctdm_setreg(wc, card, 39, 16 + (fxorxgain/-10)); + if(fxotxgain%10) { + wctdm_setreg(wc, card, 41, 16 + (-fxorxgain%10)); + } + } + else if (fxorxgain <= 120 && fxorxgain > 0) { + wctdm_setreg(wc, card, 39, fxorxgain/10); + if(fxorxgain % 10) { + wctdm_setreg(wc, card, 41, (fxorxgain%10)); + } + } + } /* NZ -- crank the tx gain up by 7 dB */ if (!strcmp(fxo_modes[_opermode].name, "NEWZEALAND")) { printk("Adjusting gain\n"); wctdm_setreg(wc, card, 38, 0x7); } + + if(debug) + printk("DEBUG fxotxgain:%i.%i fxorxgain:%i.%i\n", (wctdm_getreg(wc, card, 38)/16)?-(wctdm_getreg(wc, card, 38) - 16) : wctdm_getreg(wc, card, 38), (wctdm_getreg(wc, card, 40)/16)? -(wctdm_getreg(wc, card, 40) - 16):wctdm_getreg(wc, card, 40), (wctdm_getreg(wc, card, 39)/16)? -(wctdm_getreg(wc, card, 39) - 16) : wctdm_getreg(wc, card, 39),(wctdm_getreg(wc, card, 41)/16)?-(wctdm_getreg(wc, card, 41) - 16):wctdm_getreg(wc, card, 41)); return 0; @@ -1525,7 +1562,7 @@ static int wctdm_init_proslic(struct wctdm *wc, int card, int fast, int manual, { unsigned short tmp[5]; - unsigned char r19; + unsigned char r19,r9; int x; int fxsmode=0; @@ -1720,6 +1757,38 @@ static int wctdm_init_proslic(struct wctdm *wc, int card, int fast, int manual, printk("Reducing ring power on slot %d (50V peak)\n", card + 1); } } + + if(fxstxgain || fxsrxgain) { + r9 = wctdm_getreg(wc, card, 9); + switch (fxstxgain) { + + case 35: + r9+=8; + break; + case -35: + r9+=4; + break; + case 0: + break; + } + + switch (fxsrxgain) { + + case 35: + r9+=2; + break; + case -35: + r9+=1; + break; + case 0: + break; + } + wctdm_setreg(wc,card,9,r9); + } + + if(debug) + printk("DEBUG: fxstxgain:%s fxsrxgain:%s\n",((wctdm_getreg(wc, card, 9)/8) == 1)?"3.5":(((wctdm_getreg(wc,card,9)/4) == 1)?"-3.5":"0.0"),((wctdm_getreg(wc, card, 9)/2) == 1)?"3.5":((wctdm_getreg(wc,card,9)%2)?"-3.5":"0.0")); + wctdm_setreg(wc, card, 64, 0x01); return 0; } @@ -2419,6 +2488,10 @@ module_param(battdebounce, int, 0600); module_param(battthresh, int, 0600); module_param(alawoverride, int, 0600); module_param(fastpickup, int, 0600); +module_param(fxotxgain, int, 0600); +module_param(fxorxgain, int, 0600); +module_param(fxstxgain, int, 0600); +module_param(fxsrxgain, int, 0600); #else MODULE_PARM(debug, "i"); MODULE_PARM(loopcurrent, "i"); @@ -2435,6 +2508,10 @@ MODULE_PARM(battdebounce, "i"); MODULE_PARM(battthresh, "i"); MODULE_PARM(alawoverride, "i"); MODULE_PARM(fastpickup, "i"); +MODULE_PARM(fxotxgain, "i"); +MODULE_PARM(fxorxgain, "i"); +MODULE_PARM(fxstxgain, "i"); +MODULE_PARM(fxsrxgain, "i"); #endif MODULE_DESCRIPTION("Wildcard TDM400P Zaptel Driver"); MODULE_AUTHOR("Mark Spencer "); diff --git a/wctdm24xxp.c b/wctdm24xxp.c index 0d01117..3cc4767 100644 --- a/wctdm24xxp.c +++ b/wctdm24xxp.c @@ -432,6 +432,10 @@ static char *opermode = "FCC"; static int fxshonormode = 0; static int alawoverride = 0; static int fxo_addrs[4] = { 0x00, 0x08, 0x04, 0x0c }; +static int fxotxgain = 0; +static int fxorxgain = 0; +static int fxstxgain = 0; +static int fxsrxgain = 0; static int nativebridge = 1; #ifdef VPM_SUPPORT static int vpmsupport = 1; @@ -1955,6 +1959,40 @@ static int wctdm_init_voicedaa(struct wctdm *wc, int card, int fast, int manual, /* Apply negative Rx gain of 4.5db to DAA */ wctdm_setreg(wc, card, 39, 0x14); /* 4db */ wctdm_setreg(wc, card, 41, 0x15); /* 0.5db */ + + + /* Take values for fxotxgain and fxorxgain and apply them to module */ + if (fxotxgain) { + if (fxotxgain >= -150 && fxotxgain < 0) { + wctdm_setreg(wc, card, 38, 16 + (fxotxgain/-10)); + if(fxotxgain % 10) { + wctdm_setreg(wc, card, 40, 16 + (-fxotxgain%10)); + } + } + else if (fxotxgain <= 120 && fxotxgain > 0) { + wctdm_setreg(wc, card, 38, fxotxgain/10); + if(fxotxgain % 10) { + wctdm_setreg(wc, card, 40, (fxotxgain%10)); + } + } + } + if (fxorxgain) { + if (fxorxgain >= -150 && fxorxgain < 0) { + wctdm_setreg(wc, card, 39, 16+ (fxorxgain/-10)); + if(fxotxgain % 10) { + wctdm_setreg(wc, card, 41, 16 + (-fxorxgain%10)); + } + } + else if (fxorxgain <= 120 && fxorxgain > 0) { + wctdm_setreg(wc, card, 39, fxorxgain/10); + if(fxorxgain % 10) { + wctdm_setreg(wc, card, 41, (fxorxgain%10)); + } + } + } + + if(debug) + printk("DEBUG fxotxgain:%i.%i fxorxgain:%i.%i\n", (wctdm_getreg(wc, card, 38)/16) ? -(wctdm_getreg(wc, card, 38) - 16) : wctdm_getreg(wc, card, 38), (wctdm_getreg(wc, card, 40)/16) ? -(wctdm_getreg(wc, card, 40) - 16) : wctdm_getreg(wc, card, 40), (wctdm_getreg(wc, card, 39)/16) ? -(wctdm_getreg(wc, card, 39) - 16): wctdm_getreg(wc, card, 39), (wctdm_getreg(wc, card, 41)/16)?-(wctdm_getreg(wc, card, 41) - 16) : wctdm_getreg(wc, card, 41)); return 0; @@ -1964,7 +2002,7 @@ static int wctdm_init_proslic(struct wctdm *wc, int card, int fast, int manual, { unsigned short tmp[5]; - unsigned char r19; + unsigned char r19,r9; int x; int fxsmode=0; @@ -2159,6 +2197,38 @@ static int wctdm_init_proslic(struct wctdm *wc, int card, int fast, int manual, printk("Reducing ring power on slot %d (50V peak)\n", card + 1); } } + + if(fxstxgain || fxsrxgain) { + r9 = wctdm_getreg(wc, card, 9); + switch (fxstxgain) { + + case 35: + r9+=8; + break; + case -35: + r9+=4; + break; + case 0: + break; + } + + switch (fxsrxgain) { + + case 35: + r9+=2; + break; + case -35: + r9+=1; + break; + case 0: + break; + } + wctdm_setreg(wc,card,9,r9); + } + + if(debug) + printk("DEBUG: fxstxgain:%s fxsrxgain:%s\n",((wctdm_getreg(wc, card, 9)/8) == 1)?"3.5":(((wctdm_getreg(wc,card,9)/4) == 1)?"-3.5":"0.0"),((wctdm_getreg(wc, card, 9)/2) == 1)?"3.5":((wctdm_getreg(wc,card,9)%2)?"-3.5":"0.0")); + wctdm_setreg(wc, card, 64, 0x01); wc->mods[card].fxs.lasttxhook = 1; return 0; @@ -3443,6 +3513,10 @@ module_param(battdebounce, int, 0600); module_param(battthresh, int, 0600); module_param(alawoverride, int, 0600); module_param(nativebridge, int, 0600); +module_param(fxotxgain, int, 0600); +module_param(fxorxgain, int, 0600); +module_param(fxstxgain, int, 0600); +module_param(fxsrxgain, int, 0600); #ifdef VPM_SUPPORT module_param(vpmsupport, int, 0600); module_param(vpmdtmfsupport, int, 0600); @@ -3464,6 +3538,10 @@ MODULE_PARM(battdebounce, "i"); MODULE_PARM(battthresh, "i"); MODULE_PARM(alawoverride, "i"); MODULE_PARM(nativebridge, "i"); +MODULE_PARM(fxotxgain, "i"); +MODULE_PARM(fxorxgain, "i"); +MODULE_PARM(fxstxgain, "i"); +MODULE_PARM(fxsrxgain, "i"); #ifdef VPM_SUPPORT MODULE_PARM(vpmsupport, "i"); MODULE_PARM(vpmdtmfsupport, "i"); -- cgit v1.2.3