[zaptel-commits] mogorman: branch 1.4 r1490 - in /branches/1.4: wctdm.c wctdm24xxp.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Mon Oct 2 16:50:45 MST 2006


Author: mogorman
Date: Mon Oct  2 18:50:44 2006
New Revision: 1490

URL: http://svn.digium.com/view/zaptel?rev=1490&view=rev
Log:
add support for setting gain registers on the fxo and fxs modules.

Modified:
    branches/1.4/wctdm.c
    branches/1.4/wctdm24xxp.c

Modified: branches/1.4/wctdm.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm.c?rev=1490&r1=1489&r2=1490&view=diff
==============================================================================
--- branches/1.4/wctdm.c (original)
+++ branches/1.4/wctdm.c Mon Oct  2 18:50:44 2006
@@ -379,6 +379,10 @@
 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 @@
 		       (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 @@
 {
 
 	unsigned short tmp[5];
-	unsigned char r19;
+	unsigned char r19,r9;
 	int x;
 	int fxsmode=0;
 
@@ -1720,6 +1757,38 @@
 			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(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(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 at digium.com>");

Modified: branches/1.4/wctdm24xxp.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/wctdm24xxp.c?rev=1490&r1=1489&r2=1490&view=diff
==============================================================================
--- branches/1.4/wctdm24xxp.c (original)
+++ branches/1.4/wctdm24xxp.c Mon Oct  2 18:50:44 2006
@@ -432,6 +432,10 @@
 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 @@
 	/* 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 @@
 {
 
 	unsigned short tmp[5];
-	unsigned char r19;
+	unsigned char r19,r9;
 	int x;
 	int fxsmode=0;
 
@@ -2159,6 +2197,38 @@
 			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(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(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");



More information about the zaptel-commits mailing list