[Asterisk-cvs] zaptel wcfxs.c,1.81,1.82

markster at lists.digium.com markster at lists.digium.com
Tue Sep 7 23:46:19 CDT 2004


Update of /usr/cvsroot/zaptel
In directory mongoose.digium.com:/tmp/cvs-serv29924

Modified Files:
	wcfxs.c 
Log Message:
Make loop current settable (bug #1200)


Index: wcfxs.c
===================================================================
RCS file: /usr/cvsroot/zaptel/wcfxs.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- wcfxs.c	5 Aug 2004 20:33:58 -0000	1.81
+++ wcfxs.c	8 Sep 2004 03:48:56 -0000	1.82
@@ -40,6 +40,22 @@
  */
 /* #define AUDIO_RINGCHECK  */
 
+/*
+  Experimental max loop current limit for the proslic
+  Loop current limit is from 20 mA to 41 mA in steps of 3
+  (according to datasheet)
+  So set the value below to:
+  0x00 : 20mA (default)
+  0x01 : 23mA
+  0x02 : 26mA
+  0x03 : 29mA
+  0x04 : 32mA
+  0x05 : 35mA
+  0x06 : 37mA
+  0x07 : 41mA
+*/
+static int loopcurrent = 20;
+
 static alpha  indirect_regs[] =
 {
 {0,"DTMF_ROW_0_PEAK",0x55C2},
@@ -941,6 +957,19 @@
 		       card, vbat * 376 / 1000, vbat, (int)(((jiffies - origjiffies) * 1000 / HZ)));
 	}
 
+        /* Proslic max allowed loop current, reg 71 LOOP_I_LIMIT */
+        /* If out of range, just set it to the default value     */
+        int lim;
+        lim = (loopcurrent - 20) / 3;
+        if ( loopcurrent > 41 ) {
+                lim = 0;
+                if (debug)
+                        printk("Loop current out of range! Setting to default 20mA!\n");
+        }
+        else if (debug)
+                        printk("Loop current set to %dmA!\n",(lim*3)+20);
+        wcfxs_setreg(wc,card,LOOP_I_LIMIT,lim);
+
 	/* Engage DC-DC converter */
 	wcfxs_setreg(wc, card, 93, 0x19 /* was 0x19 */);
 #if 0
@@ -1846,11 +1875,16 @@
 	wait_just_a_bit(HZ/4);
 
 	for (x=0;x<wc->cards;x++) {
-		int sane=0,ret=0;
+		int sane=0,ret=0,readi=0;
 #if 1
 		/* Init with Auto Calibration */
 		if (!(ret=wcfxs_init_proslic(wc, x, 0, 0, sane))) {
 			wc->cardflag |= (1 << x);
+                        if (debug) {
+                                readi = wcfxs_getreg(wc,x,LOOP_I_LIMIT);
+                                printk("Proslic module %d loop current is %dmA\n",x,
+                                ((readi*3)+20));
+                        }
 			printk("Module %d: Installed -- AUTO FXS/DPO\n",x);
 		} else {
 			if(ret!=-2) {
@@ -1858,6 +1892,11 @@
 				/* Init with Manual Calibration */
 				if (!wcfxs_init_proslic(wc, x, 0, 1, sane)) {
 					wc->cardflag |= (1 << x);
+                                if (debug) {
+                                        readi = wcfxs_getreg(wc,x,LOOP_I_LIMIT);
+                                        printk("Proslic module %d loop current is %dmA\n",x,
+                                        ((readi*3)+20));
+                                }
 					printk("Module %d: Installed -- MANUAL FXS\n",x);
 				} else {
 					printk("Module %d: FAILED FXS (%s)\n", x, fxshonormode ? fxo_modes[_opermode].name : "FCC");
@@ -2126,6 +2165,7 @@
 }
 
 MODULE_PARM(debug, "i");
+MODULE_PARM(loopcurrent, "i");
 MODULE_PARM(robust, "i");
 MODULE_PARM(_opermode, "i");
 MODULE_PARM(opermode, "s");




More information about the svn-commits mailing list