[dahdi-commits] rmeyerriecks: linux/trunk r9101 - /linux/trunk/drivers/dahdi/wctdm24xxp/

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Fri Aug 6 15:10:35 CDT 2010


Author: rmeyerriecks
Date: Fri Aug  6 15:10:25 2010
New Revision: 9101

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9101
Log:
wctdm24xxp: Added "auto" companding option

Added the "auto" option for the module parameter "companding". In auto
mode its left up to each card to decide what companding mode it should
be in. If a BRI module is installed, it set everything to alaw; ulaw
is selected if no BRI module is installed.

Also fixed a bug where forcing companding one way or the other wasn't
affecting the BRI modules. dahdi-673

Modified:
    linux/trunk/drivers/dahdi/wctdm24xxp/base.c
    linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h

Modified: linux/trunk/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=9101&r1=9100&r2=9101
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/base.c Fri Aug  6 15:10:25 2010
@@ -231,7 +231,7 @@
 static char *opermode = "FCC";
 static int fxshonormode = 0;
 static int alawoverride = 0;
-static char *companding = "ulaw";
+static char *companding = "auto";
 static int fxotxgain = 0;
 static int fxorxgain = 0;
 static int fxstxgain = 0;
@@ -2637,10 +2637,18 @@
 	/* Wait just a bit */
 	wait_just_a_bit(HZ/10);
 
-	/* Enable PCM, ulaw */
-	if (!strcasecmp(companding, "alaw")) {
+	if (wc->companding == DAHDI_LAW_DEFAULT) {
+		if (wc->digi_mods)
+			/* If we have a BRI module, Auto set to alaw */
+			wctdm_setreg(wc, card, 33, 0x20);
+		else
+			/* Auto set to ulaw */
+			wctdm_setreg(wc, card, 33, 0x28);
+	} else if (wc->companding == DAHDI_LAW_ALAW) {
+		/* Force everything to alaw */
 		wctdm_setreg(wc, card, 33, 0x20);
 	} else {
+		/* Auto set to ulaw */
 		wctdm_setreg(wc, card, 33, 0x28);
 	}
 
@@ -2872,10 +2880,20 @@
 	}
 #endif
 
-    if (!strcasecmp(companding, "alaw"))
-    	wctdm_setreg(wc, card, 1, 0x20);
-    else
-    	wctdm_setreg(wc, card, 1, 0x28);
+	if (wc->companding == DAHDI_LAW_DEFAULT) {
+		if (wc->digi_mods)
+			/* If we have a BRI module, Auto set to alaw */
+			wctdm_setreg(wc, card, 1, 0x20);
+		else
+			/* Auto set to ulaw */
+			wctdm_setreg(wc, card, 1, 0x28);
+	} else if (wc->companding == DAHDI_LAW_ALAW) {
+		/* Force everything to alaw */
+		wctdm_setreg(wc, card, 1, 0x20);
+	} else {
+		/* Auto set to ulaw */
+		wctdm_setreg(wc, card, 1, 0x28);
+	}
 
 	/* U-Law 8-bit interface */
     wctdm_proslic_set_ts(wc, card, card);
@@ -3773,7 +3791,6 @@
 static struct wctdm_span *wctdm_init_span(struct wctdm *wc, int spanno, int chanoffset, int chancount, int digital_span)
 {
 	int x;
-	static int first = 1;
 	struct pci_dev *pdev = wc->vb.pdev;
 	struct wctdm_chan *c;
 	struct wctdm_span *s;
@@ -3802,18 +3819,18 @@
 	s->span.manufacturer = "Digium";
 	strncpy(s->span.devicetype, wc->desc->name, sizeof(s->span.devicetype) - 1);
 
-	if (!strcasecmp(companding, "alaw")) {
+	if (wc->companding == DAHDI_LAW_DEFAULT) {
+		if (wc->digi_mods || digital_span)
+			/* If we have a BRI module, Auto set to alaw */
+			s->span.deflaw = DAHDI_LAW_ALAW;
+		else
+			/* Auto set to ulaw */
+			s->span.deflaw = DAHDI_LAW_MULAW;
+	} else if (wc->companding == DAHDI_LAW_ALAW) {
+		/* Force everything to alaw */
 		s->span.deflaw = DAHDI_LAW_ALAW;
-		if (first) {
-			dev_info(&wc->vb.pdev->dev, "ALAW override parameter detected.  Device will be operating in ALAW\n");
-			first = 0;
-		}
-	} else if (digital_span) {
-		/* BRIs are in A-law */
-		s->span.deflaw = DAHDI_LAW_ALAW;
-	} else  {
-		/* Analog mods are ulaw unless modparam
-		   companding="alaw" is used */
+	} else {
+		/* Auto set to ulaw */
 		s->span.deflaw = DAHDI_LAW_MULAW;
 	}
 
@@ -3952,15 +3969,22 @@
 		/* Setup convergence rate */
 		reg = wctdm_vpm_in(wc,x,0x20);
 		reg &= 0xE0;
-		if (!strcasecmp(companding, "alaw")) {
-			if (!x)
-				dev_info(&wc->vb.pdev->dev, "VPM: A-law mode\n");
+
+		if (wc->companding == DAHDI_LAW_DEFAULT) {
+			if (wc->digi_mods)
+				/* If we have a BRI module, Auto set to alaw */
+				reg |= 0x01;
+			else
+				/* Auto set to ulaw */
+				reg &= ~0x01;
+		} else if (wc->companding == DAHDI_LAW_ALAW) {
+			/* Force everything to alaw */
 			reg |= 0x01;
 		} else {
-			if (!x)
-				dev_info(&wc->vb.pdev->dev, "VPM: U-law mode\n");
+			/* Auto set to ulaw */
 			reg &= ~0x01;
 		}
+
 		wctdm_vpm_out(wc,x,0x20,(reg | 0x20));
 
 		/* Initialize echo cans */
@@ -4909,6 +4933,16 @@
 					"parameter companding=alaw instead");
 	}
 
+	if (!strcasecmp(companding, "alaw"))
+		/* Force this card's companding to alaw */
+		wc->companding = DAHDI_LAW_ALAW;
+	else if (!strcasecmp(companding, "ulaw"))
+		/* Force this card's companding to ulaw */
+		wc->companding = DAHDI_LAW_MULAW;
+	else
+		/* Auto detect this card's companding */
+		wc->companding = DAHDI_LAW_DEFAULT;
+
 	for (i = 0; i < NUM_MODULES; i++) {
 		wc->flags[i] = wc->desc->flags;
 		wc->dacssrc[i] = -1;
@@ -5001,6 +5035,8 @@
 		}
 	}
 
+	wc->digi_mods = digimods;
+
 /* create an analog span if there are analog modules, or if there are no digital ones. */
 	if (anamods || !digimods) {
 		if (!digimods) {
@@ -5025,7 +5061,6 @@
 		}
 	}
 
-	wc->digi_mods = digimods;
 
 	/* This shouldn't ever occur, but if we don't try to trap it, the driver
 	 * will be scribbling into memory it doesn't own. */
@@ -5309,8 +5344,9 @@
 			     "the parameter \"companding\" instead");
 
 module_param(companding, charp, 0400);
-MODULE_PARM_DESC(companding, "Change the companding to \"alaw\" or \"ulaw\""\
-				"(ulaw by default)");
+MODULE_PARM_DESC(companding, "Change the companding to \"auto\" or \"alaw\" or"\
+		" \"ulaw\". Auto (default) will set everything to ulaw unless"\
+		" a BRI module is installed. It will use alaw in that case");
 
 MODULE_DESCRIPTION("VoiceBus Driver for Wildcard Analog and Hybrid Cards");
 MODULE_AUTHOR("Digium Incorporated <support at digium.com>");

Modified: linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h?view=diff&rev=9101&r1=9100&r2=9101
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/wctdm24xxp.h Fri Aug  6 15:10:25 2010
@@ -277,6 +277,7 @@
 
 	int initialized;				/* =1 when the entire card is ready to go */
 	unsigned long checkflag;			/* Internal state flags and task bits */
+	int companding;
 };
 
 /* Atomic flag bits for checkflag field */




More information about the dahdi-commits mailing list