[svn-commits] branch mogorman/zaptel-gain - commit revision 904

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Jan 17 09:38:49 MST 2006


Author: mogorman
Date: Tue Jan 17 10:38:49 2006
New Revision: 904

URL: http://svn.digium.com/view/zaptel?rev=904&view=rev
Log:
Adding in gain patch

Modified:
    team/mogorman/zaptel-gain/   (props changed)
    team/mogorman/zaptel-gain/wctdm.c
    team/mogorman/zaptel-gain/wctdm24xxp.c

Propchange: team/mogorman/zaptel-gain/
------------------------------------------------------------------------------
    svnmerge-integrated = /trunk:1-901

Modified: team/mogorman/zaptel-gain/wctdm.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-gain/wctdm.c?rev=904&r1=903&r2=904&view=diff
==============================================================================
--- team/mogorman/zaptel-gain/wctdm.c (original)
+++ team/mogorman/zaptel-gain/wctdm.c Tue Jan 17 10:38:49 2006
@@ -378,6 +378,10 @@
 static char *opermode = "FCC";
 static int fxshonormode = 0;
 static int alawoverride = 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);
 
@@ -1502,12 +1506,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;
 		
@@ -1517,7 +1554,7 @@
 {
 
 	unsigned short tmp[5];
-	unsigned char r19;
+	unsigned char r19,r9;
 	int x;
 	int fxsmode=0;
 
@@ -1712,6 +1749,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;
 }
@@ -2404,6 +2473,10 @@
 module_param(battdebounce, int, 0600);
 module_param(battthresh, int, 0600);
 module_param(alawoverride, 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");
@@ -2419,6 +2492,10 @@
 MODULE_PARM(battdebounce, "i");
 MODULE_PARM(battthresh, "i");
 MODULE_PARM(alawoverride, "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: team/mogorman/zaptel-gain/wctdm24xxp.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-gain/wctdm24xxp.c?rev=904&r1=903&r2=904&view=diff
==============================================================================
--- team/mogorman/zaptel-gain/wctdm24xxp.c (original)
+++ team/mogorman/zaptel-gain/wctdm24xxp.c Tue Jan 17 10:38:49 2006
@@ -407,6 +407,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;
 #ifdef VPM_SUPPORT
 static int vpmsupport = 1;
 static int vpmdtmfsupport = 0;
@@ -1824,6 +1828,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;
 		
@@ -1833,7 +1871,7 @@
 {
 
 	unsigned short tmp[5];
-	unsigned char r19;
+	unsigned char r19,r9;
 	int x;
 	int fxsmode=0;
 
@@ -2026,6 +2064,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;
@@ -2869,6 +2939,10 @@
 module_param(battdebounce, int, 0600);
 module_param(battthresh, int, 0600);
 module_param(alawoverride, 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);
@@ -2889,6 +2963,10 @@
 MODULE_PARM(battdebounce, "i");
 MODULE_PARM(battthresh, "i");
 MODULE_PARM(alawoverride, "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 svn-commits mailing list