[Asterisk-cvs] zaptel wcfxs.c,1.73,1.74

markster at lists.digium.com markster at lists.digium.com
Fri Jun 25 10:48:13 CDT 2004


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

Modified Files:
	wcfxs.c 
Log Message:
Add support for international impedence matching (improves echo abroad!)


Index: wcfxs.c
===================================================================
RCS file: /usr/cvsroot/zaptel/wcfxs.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- wcfxs.c	23 Jun 2004 18:24:21 -0000	1.73
+++ wcfxs.c	25 Jun 2004 14:34:07 -0000	1.74
@@ -28,7 +28,6 @@
 #include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/init.h>
-#include <linux/usb.h>
 #include <linux/errno.h>
 #include <linux/pci.h>
 
@@ -90,6 +89,95 @@
 {43,"LOOP_CLOSE_TRES_LOW",0x1000},
 };
 
+static struct fxo_mode {
+	char *name;
+	int ohs;
+	int ohs2;
+	int rz;
+	int rt;
+	int ilim;
+	int dcv;
+	int mini;
+	int acim;
+} fxo_modes[] =
+{
+	{ "FCC", 0, 0, 0, 0, 0, 0x3, 0, 0 }, 	/* US, Canada */
+	{ "TBR21", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },/* Austria, Belgium, Denmark, Finland, France, Germany, 
+										   Greece, Iceland, Ireland, Italy, Luxembourg, Netherlands,
+										   Norway, Portugal, Spain, Sweden, Switzerland, and UK */
+	{ "ARGENTINA", 0, 0, 0, 0, 0, 0x3, 0, 0 },
+	{ "AUSTRALIA", 1, 0, 0, 0, 0, 0, 0x3, 0x3 },
+	{ "AUSTRIA", 0, 1, 0, 0, 1, 0x3, 0, 0x3 },
+	{ "BAHRAIN", 0, 0, 0, 0, 1, 0x3, 0, 0x2 },
+	{ "BELGIUM", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
+	{ "BRAZIL", 0, 0, 0, 0, 0, 0, 0x3, 0 },
+	{ "BULGARIA", 0, 0, 0, 0, 1, 0x3,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0 },
+	{ "SLOVAKIA", 0, 0, 0, 0, 0, 0x3, 0, 0x3 },
+	{ "SLOVENIA", 0, 0, 0, 0, 0, 0x3, 0, 0x2 },
+	{ "SOUTHAFRICA", 1, 0, 1, 0, 0, 0x3, 0, 0x3 },
+	{ "SOUTHKOREA", 0, 0, 0, 0, 0, 0x3, 0, 0 },
+	{ "SPAIN", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
+	{ "SWEDEN", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
+	{ "SWITZERLAND", 0, 1, 0, 0, 1, 0x3, 0, 0x2 },
+	{ "SYRIA", 0, 0, 0, 0, 0, 0, 0x3, 0 },
+	{ "TAIWAN", 0, 0, 0, 0, 0, 0, 0x3, 0 },
+	{ "THAILAND", 0, 0, 0, 0, 0, 0, 0x3, 0 },
+	{ "UAE", 0, 0, 0, 0, 0, 0x3, 0, 0 },
+	{ "UK", 0, 1, 0, 0, 1, 0x3, 0, 0x5 },
+	{ "USA", 0, 0, 0, 0, 0, 0x3, 0, 0 },
+	{ "YEMEN", 0, 0, 0, 0, 0, 0x3, 0, 0 },
+};
+
 #ifdef STANDALONE_ZAPATA
 #include "zaptel.h"
 #else
@@ -237,6 +325,8 @@
 static int timingonly = 0;
 static int lowpower = 0;
 static int boostringer = 0;
+static int _opermode = 0;
+static char *opermode = "FCC";
 
 static int wcfxs_init_proslic(struct wcfxs *wc, int card, int fast , int manual, int sane);
 
@@ -974,6 +1064,8 @@
 static int wcfxs_init_voicedaa(struct wcfxs *wc, int card, int fast, int manual, int sane)
 {
 	long newjiffies;
+	unsigned char reg16=0, reg26=0, reg30=0, reg31=0;
+	
 	wc->modtype[card] = MOD_TYPE_FXO;
 	/* Sanity check the ProSLIC */
 	reset_spi(wc, card);
@@ -990,14 +1082,27 @@
 	/* Enable PCM, ulaw */
 	wcfxs_setreg(wc, card, 33, 0x28);
 
-	/* Misc. DAA parameters */
-	wcfxs_setreg(wc, card, 31, 0xa3);
+	/* Set On-hook speed, Ringer impedence, and ringer threshold */
+	reg16 |= (fxo_modes[_opermode].ohs << 6);
+	reg16 |= (fxo_modes[_opermode].rz << 1);
+	reg16 |= (fxo_modes[_opermode].rt);
+	wcfxs_setreg(wc, card, 16, reg16);
+	
+	/* Set DC Termination:
+	   Tip/Ring voltage adjust, minimum operational current, current limitation */
+	reg26 |= (fxo_modes[_opermode].dcv << 6);
+	reg26 |= (fxo_modes[_opermode].mini << 4);
+	reg26 |= (fxo_modes[_opermode].ilim << 1);
+	wcfxs_setreg(wc, card, 26, reg26);
 
 	/* Set AC Impedence */
-	wcfxs_setreg(wc, card, 30, 0x00);
+	reg30 = (fxo_modes[_opermode].acim);
+	wcfxs_setreg(wc, card, 30, reg30);
 
-	/* Set DC Termination */
-	wcfxs_setreg(wc, card, 26, 0xc0);
+	/* Misc. DAA parameters */
+	reg31 = 0xa3;
+	reg31 |= (fxo_modes[_opermode].ohs2 << 3);
+	wcfxs_setreg(wc, card, 31, reg31);
 
 	/* Set Transmit/Receive timeslot */
 	wcfxs_setreg(wc, card, 34, (3-card) * 8);
@@ -1562,6 +1667,7 @@
 static int wcfxs_initialize(struct wcfxs *wc)
 {
 	int x;
+
 	/* Zapata stuff */
 	sprintf(wc->span.name, "WCTDM/%d", wc->pos);
 	sprintf(wc->span.desc, "%s Board %d", wc->variety, wc->pos + 1);
@@ -1713,7 +1819,7 @@
 				} 
 			} else if (!(ret = wcfxs_init_voicedaa(wc, x, 0, 0, sane))) {
 				wc->cardflag |= (1 << x);
-				printk("Module %d: Installed -- AUTO FXO\n",x);
+				printk("Module %d: Installed -- AUTO FXO (%s mode)\n",x, fxo_modes[_opermode].name);
 			} else
 				printk("Module %d: Not installed\n", x);
 		}
@@ -1947,6 +2053,21 @@
 static int __init wcfxs_init(void)
 {
 	int res;
+	int x;
+	for (x=0;x<(sizeof(fxo_modes) / sizeof(fxo_modes[0])); x++) {
+		if (!strcmp(fxo_modes[x].name, opermode))
+			break;
+	}
+	if (x < sizeof(fxo_modes) / sizeof(fxo_modes[0])) {
+		_opermode = x;
+	} else {
+		printk("Invalid/unknown operating mode '%s' specified.  Please choose one of:\n", opermode);
+		for (x=0;x<sizeof(fxo_modes) / sizeof(fxo_modes[0]); x++)
+			printk("  %s\n", fxo_modes[x].name);
+		printk("Note this option is CASE SENSITIVE!\n");
+		return -ENODEV;
+	}
+
 	res = pci_module_init(&wcfxs_driver);
 	if (res)
 		return -ENODEV;
@@ -1960,11 +2081,13 @@
 
 MODULE_PARM(debug, "i");
 MODULE_PARM(robust, "i");
+MODULE_PARM(_opermode, "i");
+MODULE_PARM(opermode, "s");
 MODULE_PARM(timingonly, "i");
 MODULE_PARM(lowpower, "i");
 MODULE_PARM(boostringer, "i");
 MODULE_DESCRIPTION("Wildcard TDM400P Zaptel Driver");
-MODULE_AUTHOR("Mark Spencer <markster at linux-support.net>");
+MODULE_AUTHOR("Mark Spencer <markster at digium.com>");
 #ifdef MODULE_LICENSE
 MODULE_LICENSE("GPL");
 #endif




More information about the svn-commits mailing list