summaryrefslogtreecommitdiff
path: root/wctdm.c
diff options
context:
space:
mode:
authormogorman <mogorman@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-10-02 23:57:35 +0000
committermogorman <mogorman@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-10-02 23:57:35 +0000
commitfe2d13f0684d8bb1cfd16d5ac6f9d3d171a16fe1 (patch)
treefda2b0e88fada7595c45b6880d686cad814e01db /wctdm.c
parent9426f9b6374c2d4dd96ca4e92c7d315fe9af400f (diff)
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
Diffstat (limited to 'wctdm.c')
-rw-r--r--wctdm.c79
1 files changed, 78 insertions, 1 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 <markster@digium.com>");